merge + fix

This commit is contained in:
theo3
2021-04-20 21:24:44 -07:00
parent 167fe388b6
commit c99408c849
282 changed files with 27480 additions and 19142 deletions
+1368
View File
File diff suppressed because it is too large Load Diff
-10
View File
@@ -21,16 +21,6 @@ typedef struct {
u8 unk1;
} UStruct;
typedef struct {
u8 unk0;
u8 unk1;
u8 unk2;
u8 unk3;
u16 unk4;
u16 unk6;
void* unk8;
} WStruct;
void sub_0805F820(WStruct* r0, u32* r1);
u32 sub_0805F7DC(u32 r0, WStruct* r1) {
+3 -5
View File
@@ -7,8 +7,6 @@
#include "structures.h"
#include "textbox.h"
extern u8 gBG3Buffer[];
extern void (*const gUnk_08109A30[])();
void HandleDebugTextScreen() {
@@ -17,8 +15,8 @@ void HandleDebugTextScreen() {
void sub_0805FA04(void) {
DispReset(1);
MemClear(&gBG0Buffer, sizeof(BGBuffer));
MemClear(&gBG3Buffer, 0x1000);
MemClear(&gBG0Buffer, sizeof(gBG0Buffer));
MemClear(&gBG3Buffer, sizeof(gBG3Buffer));
gScreen.lcd.displayControl = 0x940;
gScreen.bg.bg0xOffset = 0;
gScreen.bg.bg0yOffset = 0;
@@ -33,7 +31,7 @@ void sub_0805FA04(void) {
sub_08053320();
sub_0801D79C(0, 0x1144);
gMain.funcIndex = 1;
sub_080A3210();
InitSoundPlayingInfo();
sub_08050008();
}
+2 -2
View File
@@ -908,7 +908,7 @@ void sub_08047BA4(Entity* this) {
} else {
this->field_0x76.HWORD = 0x88;
}
SoundReq(0x1B5);
SoundReq(SFX_1B5);
sub_08047BF0(this);
}
@@ -938,7 +938,7 @@ void sub_08047BF0(Entity* this) {
if (this->y.HALF.HI > gRoomControls.roomOriginY + 0x270) {
this->subAction = 2;
this->field_0x7c.HALF.HI = 0xAA;
SoundReq(0x12D);
SoundReq(SFX_12D);
InitAnimationForceUpdate(this, 1);
}
} else {
+2 -1
View File
@@ -2,6 +2,7 @@
#include "entity.h"
#include "enemy.h"
#include "random.h"
#include "audio.h"
#include "functions.h"
extern void (*const gRope[6])(Entity*);
@@ -83,7 +84,7 @@ void sub_08031480(Entity* this) {
this->spriteSettings.b.draw = 3;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
SoundReq(0x12d);
SoundReq(SFX_12D);
}
} else {
if (sub_08003FC4(this, 0x1800) == 0) {
+2 -1
View File
@@ -1,6 +1,7 @@
#include "enemy.h"
#include "entity.h"
#include "random.h"
#include "audio.h"
#include "functions.h"
extern void sub_08001318(Entity*);
@@ -123,7 +124,7 @@ void sub_08022654(Entity* this) {
if (--this->field_0xf)
return;
this->subAction = 1;
SoundReq(0x12d);
SoundReq(SFX_12D);
InitializeAnimation(this, 0);
/* fallthrough */
case 1:
+3 -2
View File
@@ -2,6 +2,7 @@
#include "player.h"
#include "screen.h"
#include "createObject.h"
#include "audio.h"
#include "functions.h"
typedef struct {
@@ -39,7 +40,7 @@ void VaatiBall(Entity* this) {
this->currentHealth = -1;
parent->field_0x80.HALF.LO--;
CreateDust(this);
SoundReq(0x1c3);
SoundReq(SFX_1C3);
}
}
}
@@ -368,7 +369,7 @@ void sub_08044B04(Entity* this) {
if (this->actionDelay) {
if (--this->actionDelay == 0) {
this->speed = 1280;
SoundReq(0x14f);
SoundReq(SFX_14F);
}
}
if (this->field_0x78.HALF.HI == 3)
+1 -2
View File
@@ -3,12 +3,11 @@
#include "screen.h"
#include "random.h"
#include "functions.h"
#include "structures.h"
void sub_0802A39C(Entity*);
void sub_0802A334(Entity*);
extern u16 gBG3Buffer[];
extern void (*const gUnk_080CD030[])(Entity*);
extern const u8 gUnk_080CD03C[];
extern const s8 gUnk_080CD040[];
+1 -2
View File
@@ -1,6 +1,5 @@
#include "audio.h"
#include "global.h"
#include "functions.h"
#include "audio.h"
#include "textbox.h"
#include "structures.h"
+3 -2
View File
@@ -6,6 +6,7 @@
#include "menu.h"
#include "random.h"
#include "textbox.h"
#include "functions.h"
// copy, erase, start
#define NUM_FILE_OPERATIONS 3
@@ -190,7 +191,7 @@ static void HandleFileScreenEnter(void) {
u32 i;
DispReset(1);
sub_080A3210();
InitSoundPlayingInfo();
MemClear((void*)VRAM, 0x80); // clear palettes
MessageInitialize();
EraseAllEntities();
@@ -498,7 +499,7 @@ void sub_08050AFC(u32 idx) {
SetActiveSave(idx);
MemClear(&gBG1Buffer, sizeof(gBG1Buffer));
if (gUnk_02019EE0.saveStatus[idx] == SAVE_VALID) {
sub_08050B3C(&gBG1Buffer.unk29C);
sub_08050B3C(&gBG1Buffer[0x14E]);
}
gScreen.bg.bg1Updated = 1;
}
+2 -1
View File
@@ -1,6 +1,5 @@
#include "global.h"
#include "screen.h"
#include "structures.h"
#include "screen.h"
#include "entity.h"
#include "player.h"
@@ -10,7 +9,9 @@
#include "save.h"
#include "utils.h"
#include "fileScreen.h"
#include "menu.h"
#include "functions.h"
#include "structures.h"
extern u8 gArea;
extern Entity gPlayerEntity;
+1676
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -158,7 +158,7 @@ static void HandleTitlescreen(void) {
gIntroState.swordBgScaleRatio = 0x10;
UpdateSwordBgAffineData();
}
sub_080A3210();
InitSoundPlayingInfo();
SoundReq(BGM_TITLE_SCREEN);
DoFade(6, 8);
break;
-2
View File
@@ -1,7 +1,5 @@
#include "global.h"
#include "entity.h"
#include "item.h"
#include "functions.h"
// TODO - How does this relate to PlayerItemFunctions? Is this just a lookup table?
void (*const gItemFunctions[])(ItemBehavior*, u32) = {
+3 -3
View File
@@ -10,7 +10,7 @@ extern Entity* LoadRoomEntity(EntityData*);
extern void* GetRoomProperty(u32, u32, u32);
extern u32 gUnk_02017654;
extern u32* gAreaEntities;
extern u32* gAreaTable;
extern void sub_080186EC();
extern void sub_0804B16C();
@@ -74,7 +74,7 @@ void sub_0804B0B0(u32 arg0, u32 arg1) {
void SetCurrentRoomPropertyList(u32 arg0, u32 arg1) {
u32** arr;
gUnk_02017654 = 0;
arr = &gAreaEntities;
arr = &gAreaTable;
if (arr[arg0] != 0) {
gUnk_02017654 = arr[arg0][arg1];
}
@@ -94,7 +94,7 @@ void* GetRoomProperty(u32 arg0, u32 arg1, u32 arg2) {
u32 temp;
u32** arr;
temp = 0;
arr = &gAreaEntities;
arr = &gAreaTable;
if (arr[arg0] != NULL) {
temp = arr[arg0][arg1];
if (temp != 0) {
+3 -3
View File
@@ -73,7 +73,7 @@ void AgbMain(void) {
sScreenHandlers[gMain.screen]();
MessageUpdate();
sub_08050154();
sub_080A3480();
SoundLoop();
break;
}
PrepNextFrame();
@@ -206,7 +206,7 @@ u32 sub_08056134(void) {
}
void InitDMA() {
SoundReq(SND_VSYNC_OFF);
SoundReq(SONG_VSYNC_OFF);
gScreen._6d = gScreen._6c;
gScreen._6c = 0;
@@ -219,7 +219,7 @@ void InitDMA() {
}
void sub_08056208() {
SoundReq(SND_VSYNC_ON);
SoundReq(SONG_VSYNC_ON);
gScreen._6c = gScreen._6d;
gScreen._6d = 0;
}
+1 -3
View File
@@ -81,7 +81,7 @@ void sub_0805A370(Manager15* this) {
if (this->manager.unk_0d) {
LoadRoomEntityList((EntityData*)&gUnk_080E4C08);
this->manager.action = 3;
SoundReq(SONG_RESET_UNK);
SoundReq(SONG_STOP_BGM);
}
}
@@ -426,8 +426,6 @@ void sub_0805A94C(Manager15* this) {
gScreen.controls.window1VerticalDimensions = (tmp1 << 8 | tmp2);
}
extern u8 gBG3Buffer[];
#ifdef NON_MATCHING
void sub_0805A9CC(Manager15* this) {
int tmp1, tmp2;
+2 -2
View File
@@ -5,7 +5,7 @@
#include "room.h"
#include "player.h"
#include "random.h"
#include "functions.h"
#include "audio.h"
// Facilitates the usage of minish portals.
@@ -58,7 +58,7 @@ void sub_080576C0(Manager3* this) {
this->manager.unk_0e);
if (!this->manager.unk_0f) {
this->manager.unk_0f = 1;
SoundReq(0x152);
SoundReq(SFX_152);
}
}
}
+4 -5
View File
@@ -39,7 +39,6 @@ void sub_08057EFC(Manager8* this) {
void sub_08058004(u32, void*, void*);
extern u8 gBG3Buffer[];
extern u8 gUnk_02006F00[];
void sub_08057F20(Manager8* this) {
@@ -59,8 +58,8 @@ void sub_08057F20(Manager8* this) {
tmp = tmp + (tmp >> 2) + ((0x400 - gRoomControls.width) / 2);
gScreen.bg.bg1xOffset = tmp & 0xF;
gScreen.bg.bg1yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1);
gScreen.bg.bg1Tilemap = gBG3Buffer + 0x800;
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gBG3Buffer + 0x800);
gScreen.bg.bg1Tilemap = gBG3Buffer + 0x400;
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gBG3Buffer + 0x400);
tmp = ((tmp >> 4) << 1);
if (this->unk_3c != tmp) {
this->unk_3c = tmp;
@@ -123,11 +122,11 @@ void sub_080580B0(u32 unk1) {
gScreen.affine.bg3Updated = 1;
tmp = gRoomControls.roomScrollX - gRoomControls.roomOriginX; // r7
tmp = tmp + (tmp >> 2) + (0x400 - gRoomControls.width) / 2;
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gBG3Buffer + 0x800);
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gBG3Buffer + 0x400);
gScreen.bg.bg1xOffset = tmp & 0xF;
gScreen.bg.bg1yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1); //?
gScreen.bg.bg1Control = 0x1E09;
gScreen.bg.bg1Tilemap = gBG3Buffer + 0x800;
gScreen.bg.bg1Tilemap = gBG3Buffer + 0x400;
gScreen.bg.bg1Updated = 1;
gScreen.controls.layerFXControl = 0x3C48;
gScreen.controls.alphaBlend = 0x609;
+3 -4
View File
@@ -13,11 +13,10 @@ typedef struct {
void sub_08058204(Manager9*);
void sub_08058210(Manager9*);
u32 sub_08058244(int);
void sub_080582A0(u32, u32*, u8*);
void sub_080582A0(u32, u32*, u16*);
void sub_080582F8(u8*, u8*);
extern u32 gUnk_02006F00[];
extern u8 gBG3Buffer[];
const u16 gUnk_081081EC[] = { 0x30, 0x30, 0x30, 0x38 };
@@ -55,13 +54,13 @@ u32 sub_08058244(int i) {
return tmp;
}
void sub_080582A0(u32 unk, u32* unk2, u8* unk3) {
void sub_080582A0(u32 unk, u32* unk2, u16* unk3) {
int i = 0x20;
unk2 += unk >> 4;
for (; i != 0; i--) {
DmaSet(3, unk2, unk3, 0x80000020);
unk2 += 0x40;
unk3 += 0x40;
unk3 += 0x20;
}
}
+3 -2
View File
@@ -5,6 +5,7 @@
#include "room.h"
#include "area.h"
#include "utils.h"
#include "audio.h"
#include "functions.h"
/*
@@ -18,7 +19,7 @@
void (*const ManagerB_ActionFuncs[])(Manager*);
void sub_080585F0(Manager* this) {
// make a distincion if this is a controller (unk_0a = 0) or a helper (unk_0a = 1)
// make a distincion if this is a controller (volumeMasterTarget = 0) or a helper (volumeMasterTarget = 1)
ManagerB_ActionFuncs[this->unk_0a](this);
}
@@ -140,7 +141,7 @@ void ManagerBHelper_Monitor(ManagerBHelper* this, Entity* ent, u32 index) {
this->manager.unk_0e++;
}
// case unk_0a is 1: The manager is a helper
// case volumeMasterTarget is 1: The manager is a helper
void ManagerBHelper_Main(Manager* this) {
u8 i, anyRemaining;
+1
View File
@@ -3,6 +3,7 @@
#include "manager.h"
#include "flags.h"
#include "room.h"
#include "audio.h"
#include "functions.h"
void sub_08058E60(ManagerE* this) {
+1
View File
@@ -4,6 +4,7 @@
#include "structures.h"
#include "script.h"
#include "random.h"
#include "audio.h"
#include "functions.h"
extern void (*gUnk_081140D4[])(Entity*);
+2 -1
View File
@@ -7,6 +7,7 @@
#include "save.h"
#include "script.h"
#include "npc.h"
#include "audio.h"
#include "functions.h"
extern void (*gUnk_081115C0[])(Entity*);
@@ -168,7 +169,7 @@ void sub_08068BEC(Entity* this, u32 unused) {
if (target) {
target->spritePriority.b0 = 1;
PositionRelative(this, target, 0, -0x100000);
SoundReq(0xfa);
SoundReq(SFX_FA);
}
}
+3 -2
View File
@@ -1,9 +1,10 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
#include "flags.h"
#include "save.h"
#include "script.h"
#include "audio.h"
#include "functions.h"
extern Hitbox gUnk_080FD170;
extern void script_08016030; // Cutscene data type?
@@ -184,7 +185,7 @@ void sub_0806DAE8(Entity* this) {
break;
}
SoundReq(0xcd);
SoundReq(SFX_TASK_COMPLETE);
}
void sub_0806DB44(Entity* this, ScriptExecutionContext* context) {
+1
View File
@@ -4,6 +4,7 @@
#include "textbox.h"
#include "script.h"
#include "random.h"
#include "audio.h"
#include "functions.h"
extern void sub_08068780(Entity*);
+4 -3
View File
@@ -1,7 +1,8 @@
#include "global.h"
#include "functions.h"
#include "entity.h"
#include "script.h"
#include "audio.h"
#include "functions.h"
extern void sub_0806A8C8(Entity*);
@@ -26,11 +27,11 @@ void sub_0806a370(Entity* this) {
pbVar1 = &this->frames.all;
if (*pbVar1 == 1) {
*pbVar1 = 0;
SoundReq(0x218);
SoundReq(SFX_218);
}
if (*pbVar1 == 2) {
*pbVar1 = 0;
SoundReq(0x219);
SoundReq(SFX_219);
}
}
}
+1
View File
@@ -5,6 +5,7 @@
#include "script.h"
#include "random.h"
#include "npc.h"
#include "audio.h"
#include "functions.h"
extern void sub_08078850(Entity*, u32, u32, u32*);
+1 -1
View File
@@ -34,7 +34,7 @@ void sub_0809CF54(Entity* this) {
this->direction = 8;
this->collisionLayer = 2;
this->x.HALF.HI = gRoomControls.roomScrollX;
SoundReq(0x123);
SoundReq(SFX_123);
UpdateSpriteForCollisionLayer(this);
InitAnimationForceUpdate(this, 0);
target = CreateObject(0x95, 1, 0);
+3 -2
View File
@@ -2,6 +2,7 @@
#include "entity.h"
#include "flags.h"
#include "room.h"
#include "audio.h"
#include "functions.h"
extern void (*const gUnk_0811EE38[])(Entity*);
@@ -94,7 +95,7 @@ void sub_08081C30(Entity* this) {
this->action = 2;
ClearFlag(this->field_0x86.HWORD);
SetTileType(0x77, this->field_0x74.HWORD, this->collisionLayer);
SoundReq(0x10C);
SoundReq(SFX_10C);
}
}
@@ -260,7 +261,7 @@ u32 sub_08081F7C(Entity* this, u32 r7) {
SetFlag(this->field_0x86.HWORD);
SetTileType(r7, this->field_0x74.HWORD, this->collisionLayer);
sub_08081F24(this);
SoundReq(0x10C);
SoundReq(SFX_10C);
if (this->field_0x70.HALF_U.LO != 0xFFFF)
SetTile(this->field_0x70.HALF_U.LO, this->field_0x74.HWORD, this->collisionLayer);
return 0;
+3 -3
View File
@@ -46,7 +46,7 @@ void sub_0809F548(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 2;
this->actionDelay = 90;
SoundReq(285);
SoundReq(SFX_11D);
sub_0809F814((((this->x.HALF.HI - gRoomControls.roomOriginX) >> 4) & 63) |
(((this->y.HALF.HI - gRoomControls.roomOriginY) >> 4) & 63) << 6);
} else {
@@ -94,7 +94,7 @@ void sub_0809F61C(Entity* this) {
if (--this->actionDelay == 0) {
this->action = 3;
this->actionDelay = 120;
SoundReq(285);
SoundReq(SFX_11D);
sub_0809F814((((this->x.HALF.HI - gRoomControls.roomOriginX) >> 4) & 63) |
(((this->y.HALF.HI - gRoomControls.roomOriginY) >> 4) & 63) << 6);
} else {
@@ -178,7 +178,7 @@ void sub_0809F7BC(Entity* this) {
void sub_0809F7F4(Entity* this) {
if (--this->field_0x68.HALF.LO == 0) {
this->field_0x68.HALF.LO = 12;
SoundReq(388);
SoundReq(SFX_184);
}
}
+1 -1
View File
@@ -105,7 +105,7 @@ void GreatFairy_SpawningUpdate(Entity* this) {
if (mini != NULL) {
CopyPosition(this, mini);
DoFade(6, 4);
SoundReq(325);
SoundReq(SFX_145);
this->action = 4;
this->actionDelay = 60;
this->spriteSettings.b.draw = 1;
+3 -2
View File
@@ -1,9 +1,10 @@
#include "global.h"
#include "entity.h"
#include "flags.h"
#include "functions.h"
#include "room.h"
#include "script.h"
#include "audio.h"
#include "functions.h"
typedef struct {
/*0x00*/ u16 unk0;
@@ -111,7 +112,7 @@ void sub_0808681C(Entity* this) {
this->action++;
this->frameIndex = 1;
sub_08078AC0(16, 0, 1);
SoundReq(0x111);
SoundReq(SFX_111);
}
break;
}
+24 -24
View File
@@ -5,16 +5,16 @@
#include "functions.h"
#include "player.h"
static void sub_08081150(Entity*);
static u8 sub_0808147C(u32);
static void sub_080814A4(Entity*);
static u32 sub_080814C0(Entity*);
static void sub_08081500(Entity*);
static void sub_0808153C(Entity*);
static void sub_08081598(Entity*);
static void sub_080813BC(Entity*);
static void sub_080810FC(Entity*);
static bool32 CheckShouldPlayItemGetCutscene(Entity*);
void sub_08081150(Entity*);
u8 sub_0808147C(u32);
void sub_080814A4(Entity*);
u32 sub_080814C0(Entity*);
void sub_08081500(Entity*);
void sub_0808153C(Entity*);
void sub_08081598(Entity*);
void sub_080813BC(Entity*);
void sub_080810FC(Entity*);
bool32 CheckShouldPlayItemGetCutscene(Entity*);
extern u32 sub_080002D0(Entity*);
extern u32 sub_080177A0(Entity*, Entity*);
@@ -137,7 +137,7 @@ void sub_08080F20(Entity* this) {
}
}
static void sub_080810A8(Entity* this) {
void sub_080810A8(Entity* this) {
this->action = 1;
sub_080814A4(this);
if (this->direction & 0x80) {
@@ -158,7 +158,7 @@ static void sub_080810A8(Entity* this) {
}
}
static void sub_080810FC(Entity* this) {
void sub_080810FC(Entity* this) {
if (this->type != 0x5F) {
sub_08081598(this);
} else {
@@ -176,16 +176,16 @@ void sub_08081134(Entity* this) {
sub_08081150(this);
}
static void sub_08081150(Entity* this) {
void sub_08081150(Entity* this) {
this->action = 2;
this->flags |= 0x80;
this->height.HALF.HI = -0x80;
this->spriteOrientation.flipY = 1;
this->spriteRendering.b3 = 1;
SoundReq(0x12D);
SoundReq(SFX_12D);
}
static void sub_08081188(Entity* this) {
void sub_08081188(Entity* this) {
this->action = 2;
this->flags |= 0x80;
if (this->collisionLayer == 2) {
@@ -206,7 +206,7 @@ void sub_080811C8(Entity* this) {
void sub_080811D8(Entity* this) {
sub_08081188(this);
SoundReq(0x215);
SoundReq(SFX_215);
}
void sub_080811EC(Entity* this) {
@@ -304,7 +304,7 @@ void sub_0808136C(Entity* this) {
}
}
static void sub_080813BC(Entity* this) {
void sub_080813BC(Entity* this) {
gUnk_0811E840[this->subAction](this);
}
@@ -343,7 +343,7 @@ bool32 sub_08081420(Entity* this) {
}
}
static bool32 CheckShouldPlayItemGetCutscene(Entity* this) {
bool32 CheckShouldPlayItemGetCutscene(Entity* this) {
bool32 result = FALSE;
if ((gUnk_080FD5B4[this->type].unk0[3] & 0x2) || !GetInventoryValue(this->type)) {
result = TRUE;
@@ -351,7 +351,7 @@ static bool32 CheckShouldPlayItemGetCutscene(Entity* this) {
return result;
}
static u8 sub_0808147C(u32 arg0) {
u8 sub_0808147C(u32 arg0) {
const Unk_0811E84C* var0 = &gUnk_0811E84C[arg0];
return var0->unk4;
}
@@ -363,7 +363,7 @@ void sub_0808148C(u32 arg0) {
}
}
static void sub_080814A4(Entity* this) {
void sub_080814A4(Entity* this) {
if (this->field_0x68.HALF.HI == 10) {
this->field_0x6c.HWORD = 120;
} else {
@@ -371,7 +371,7 @@ static void sub_080814A4(Entity* this) {
}
}
static u32 sub_080814C0(Entity* this) {
u32 sub_080814C0(Entity* this) {
if (!sub_0805E40C(this)) {
if (--this->field_0x6c.HWORD == 0) {
return TRUE;
@@ -385,7 +385,7 @@ static u32 sub_080814C0(Entity* this) {
return FALSE;
}
static void sub_08081500(Entity* this) {
void sub_08081500(Entity* this) {
if (this->field_0x68.HALF.LO == 0) {
u32 var0 = sub_080044EC(this, 0x2800);
if (var0 == 0) {
@@ -401,7 +401,7 @@ static void sub_08081500(Entity* this) {
}
}
static void sub_0808153C(Entity* this) {
void sub_0808153C(Entity* this) {
if (this->field_0x68.HALF.LO > 1)
return;
@@ -420,7 +420,7 @@ static void sub_0808153C(Entity* this) {
}
}
static void sub_08081598(Entity* this) {
void sub_08081598(Entity* this) {
if (this->currentHealth == 0) {
sub_08081404(this, 1);
}
+2 -2
View File
@@ -2,7 +2,7 @@
#include "entity.h"
#include "flags.h"
#include "room.h"
#include "functions.h"
#include "audio.h"
extern void sub_080A0960(Entity*, u32);
extern void sub_0801AF18(u8*, u32, u32);
@@ -33,7 +33,7 @@ void sub_080A0910(Entity* this) {
if (CheckFlags(this->field_0x86.HWORD) != 0) {
this->action = 2;
sub_080A0960(this, 1);
SoundReq(0x10b);
SoundReq(SFX_10B);
}
}
+2 -1
View File
@@ -2,6 +2,7 @@
#include "entity.h"
#include "room.h"
#include "flags.h"
#include "audio.h"
#include "functions.h"
extern u32 sub_08083734(Entity*, u32);
@@ -76,7 +77,7 @@ void sub_080A07BC(Entity* this) {
this->direction = 0x10;
this->y.HALF.HI += 2;
sub_080A0870(this);
SoundReq(0x10b);
SoundReq(SFX_10B);
}
}
+4 -4
View File
@@ -63,7 +63,7 @@ void sub_080917DC(Entity* this) {
this->field_0x20 = 0x2a000;
this->action = 7;
InitAnimationForceUpdate(this, this->type2 + 4 + this->animationState);
SoundReq(0x13b);
SoundReq(SFX_13B);
} else {
if (sub_0800445C(this) != 0) {
if (((gPlayerState.flags.all & 0x40080) == 0) && (gPlayerState.field_0x1c == 0) &&
@@ -113,7 +113,7 @@ void sub_080918A4(Entity* this) {
this->field_0x44 = 8;
sub_0801766C(this);
sub_0807BA8C(COORD_TO_TILE(this), this->collisionLayer);
SoundReq(0x137);
SoundReq(SFX_137);
}
} else {
gPlayerEntity.direction = GetFacingDirection(&gPlayerEntity, this);
@@ -149,7 +149,7 @@ void sub_080919AC(Entity* this) {
gPlayerEntity.spritePriority.b0 = this->spritePriority.b0 - 1;
if (!sub_08091DDC(this)) {
if ((gScreenTransition.frameCount & 0xf) == 0) {
SoundReq(0x138);
SoundReq(SFX_138);
}
if (--this->field_0xf == 0xff) {
@@ -183,7 +183,7 @@ void sub_080919AC(Entity* this) {
sub_08004168(this);
InitAnimationForceUpdate(this, this->animationState + 0xc);
SoundReq(SFX_PLY_VO4);
SoundReq(0x139);
SoundReq(SFX_139);
return;
case 0x67:
case 0x68:
+1 -1
View File
@@ -218,7 +218,7 @@ void sub_0808F498(Entity* this) {
if (this->action != 0) {
if (sub_0806F3E4(this)) {
if (gScreenTransition.frameCount % 16 == 0) {
SoundReq(0xEF);
SoundReq(SFX_EF);
}
DeleteThisEntity();
}
+3 -2
View File
@@ -2,6 +2,7 @@
#include "object.h"
#include "menu.h"
#include "random.h"
#include "audio.h"
#include "structures.h"
#include "functions.h"
@@ -48,7 +49,7 @@ void sub_0809F374(Entity* this) {
this->height.WORD = 0;
this->action = 2;
InitializeAnimation(this, 1);
SoundReq(0x186);
SoundReq(SFX_186);
} else {
this->actionDelay++;
}
@@ -64,7 +65,7 @@ void sub_0809F374(Entity* this) {
case 1:
this->actionDelay = 0;
sub_0809F448(this);
SoundReq(0x186);
SoundReq(SFX_186);
}
}
}
+1
View File
@@ -1,5 +1,6 @@
#include "global.h"
#include "entity.h"
#include "audio.h"
#include "functions.h"
extern void (*const ThoughtBubble_Behaviors[])(Entity*);
+1
View File
@@ -3,6 +3,7 @@
#include "entity.h"
#include "save.h"
#include "script.h"
#include "functions.h"
extern void sub_08078850(Entity*, u32, u32, u8*);
+6 -6
View File
@@ -185,7 +185,7 @@ void sub_08070D38(Entity* this) {
}
gPlayerState.jumpStatus = 0x80;
SoundReq(0x14c);
SoundReq(SFX_14C);
ResetPlayer();
sub_08078F60();
}
@@ -467,7 +467,7 @@ void sub_0807127C(Entity* this) {
if (gPlayerState.flags.all & 0x80) {
this->actionDelay = 0x3c;
gPlayerState.field_0x8 = 0xc19;
SoundReq(0x84);
SoundReq(SFX_WATER_SPLASH);
} else {
if ((gPlayerState.flags.all & 0x10000) == 0)
sub_08004168(this);
@@ -528,7 +528,7 @@ static void PlayerUsePortal(Entity* this) {
this->subAction = 7;
this->actionDelay = 30;
DoFade(7, 16);
SoundReq(0xf8);
SoundReq(SFX_F8);
} else {
sub_0804ACF8();
}
@@ -641,7 +641,7 @@ void PortalShrinkInit(Entity* this) {
sub_0805EC9C(this, 0x100, 0x100, 0);
gPlayerState.field_0x8 = 0x2c3;
gPlayerState.flags.all |= 0x80;
SoundReq(0x16f);
SoundReq(SFX_PLY_SHRINKING);
}
// horrible
@@ -912,7 +912,7 @@ void sub_08071BDC(Entity* this) {
gPlayerState.pushedObject = 0;
sub_0800451C(this);
ResetPlayer();
SoundReq(0x87);
SoundReq(SFX_PLY_DIE);
}
void sub_08071CAC(Entity* this) {
@@ -927,7 +927,7 @@ void sub_08071CAC(Entity* this) {
this->subAction = 2;
this->actionDelay = 0xf0;
SoundReq(0x7b);
SoundReq(SFX_PLY_VO7);
}
}
+17 -17
View File
@@ -1027,7 +1027,7 @@ void sub_0804C018(void) {
if (CheckGlobalFlag(MAZE_CLEAR))
if (gScreenTransition.playerStartPos.WORD == 0x2780078) // todo: wtf
SoundReq(0x72);
SoundReq(SFX_SECRET);
ClearGlobalFlag(MAZE_CLEAR);
}
@@ -2241,7 +2241,7 @@ void sub_0804CD48(void) {
if (CheckGlobalFlag(LV1_CLEAR)) {
LoadRoomEntityList(&gUnk_080DF94C);
} else {
SoundReq(SONG_RESET_UNK);
SoundReq(SONG_STOP_BGM);
gArea.musicIndex = gArea.pMusicIndex;
}
}
@@ -2429,7 +2429,7 @@ void sub_0804CED8(void) {
sub_0807AABC(&gPlayerEntity);
LoadRoomEntityList(&gUnk_080E1814);
} else {
SoundReq(SONG_RESET_UNK);
SoundReq(SONG_STOP_BGM);
gArea.musicIndex = gArea.pMusicIndex;
}
}
@@ -2523,7 +2523,7 @@ void sub_0804CFB0(void) {
if (!CheckFlags(0x31)) {
if (gScreenTransition.field_0x38 == 0) {
SoundReq(SONG_RESET_UNK);
SoundReq(SONG_STOP_BGM);
} else {
if (gScreenTransition.field_0x39 == 0) {
SoundReq(SONG_STOP);
@@ -2761,7 +2761,7 @@ void sub_0804D140(void) {
if (CheckGlobalFlag(LV4_CLEAR)) {
LoadRoomEntityList(&gUnk_080E49F4);
} else {
SoundReq(SONG_RESET_UNK);
SoundReq(SONG_STOP_BGM);
gArea.musicIndex = gArea.pMusicIndex;
}
}
@@ -3090,7 +3090,7 @@ void sub_0804D384(void) {
sub_08078A90(3);
LoadRoomEntityList(&gUnk_080E72E4);
gArea.musicIndex = gArea.pMusicIndex;
SoundReq(SONG_RESET_UNK);
SoundReq(SONG_STOP_BGM);
}
}
}
@@ -3498,7 +3498,7 @@ u32 sub_0804D6C4() {
}
void sub_0804D6C8(void) {
SoundReq(SONG_RESET_UNK);
SoundReq(SONG_STOP_BGM);
gArea.musicIndex = gArea.pMusicIndex;
}
@@ -4506,7 +4506,7 @@ void sub_0804E3C4() {
index = 0xE;
}
sub_0804B3C4(&gUnk_080F0E1C[index]);
SoundReq(SONG_RESET_UNK);
SoundReq(SONG_STOP_BGM);
}
u32 sub_0804E45C() {
@@ -4714,7 +4714,7 @@ extern EntityData gUnk_080F2E2C;
void sub_0804E6E8(void) {
if (!CheckGlobalFlag(OUTDOOR)) {
gArea.musicIndex = gArea.pMusicIndex;
SoundReq(SONG_VOL_RESET | BGM_MINISH_CAP);
SoundReq(SONG_PLAY_VOL_RESET | BGM_MINISH_CAP);
}
if (!CheckGlobalFlag(START)) {
LoadRoomEntityList(&gUnk_080F2E2C);
@@ -4731,7 +4731,7 @@ extern EntityData gUnk_080F2EC4;
void sub_0804E72C(void) {
if (!CheckGlobalFlag(OUTDOOR)) {
gArea.musicIndex = gArea.pMusicIndex;
SoundReq(SONG_VOL_RESET | BGM_MINISH_CAP);
SoundReq(SONG_PLAY_VOL_RESET | BGM_MINISH_CAP);
}
if (!CheckGlobalFlag(START)) {
LoadRoomEntityList(&gUnk_080F2E94);
@@ -4783,7 +4783,7 @@ void sub_0804E7DC(void) {
}
if (!CheckGlobalFlag(OUTDOOR)) {
gArea.musicIndex = gArea.pMusicIndex;
SoundReq(SONG_VOL_RESET | BGM_MINISH_CAP);
SoundReq(SONG_PLAY_VOL_RESET | BGM_MINISH_CAP);
}
if ((gPlayerState.flags.all & 8) == 0) {
LoadRoomEntityList(&gUnk_080F31D8);
@@ -5595,7 +5595,7 @@ extern void sub_0804F5E8();
extern u32 gUnk_080F7C80;
extern void sub_0804F4E4();
u32 sub_0804F468(void) {
u32 Vars_HyruleField_OutsideCastle(void) {
if (CheckGlobalFlag(TABIDACHI) && !GetInventoryValue(0x11)) {
gRoomVars.field_0x6c = &gUnk_080F7CD0;
gRoomVars.field_0x88 = sub_0804F5E8;
@@ -5618,7 +5618,7 @@ void sub_0804F4E4() {
extern EntityData gUnk_080F7D70;
void sub_0804F4F4(void) {
void Load_HyruleField_OutsideCastle(void) {
sub_0804F4E4();
if (!CheckLocalFlag(0x8b)) {
LoadRoomEntityList(&gUnk_080F7D70);
@@ -5781,13 +5781,13 @@ void sub_0804F9C8(void) {
sub_0807BA8C(0x4d9, 1);
}
u32 sub_0804F9FC() {
u32 Vars_HyruleField_OutsideCastleWest() {
return 1;
}
extern EntityData gUnk_080F806C;
void sub_0804FA00(void) {
void Load_HyruleField_OutsideCastleWest(void) {
sub_0805ADD8(0);
if ((gSave.unk8 > 3) && CheckGlobalFlag(TINGLE_TALK1ST)) {
@@ -5795,13 +5795,13 @@ void sub_0804FA00(void) {
}
}
u32 sub_0804FA2C() {
u32 Vars_HyruleField_TrilbyHighlands() {
return 1;
}
extern EntityData gUnk_080F82E0;
void sub_0804FA30(void) {
void Load_HyruleField_TrilbyHighlands(void) {
sub_0805ADD8(0);
if (CheckGlobalFlag(LV2_CLEAR) && GetInventoryValue(0x3) && !CheckLocalFlag(0x9c)) {
+8 -7
View File
@@ -1,5 +1,8 @@
#include "save.h"
#include "gba/eeprom.h"
#include "audio.h"
#include "menu.h"
#include "functions.h"
typedef struct SaveFileStatus {
u16 checksum1;
@@ -58,8 +61,6 @@ const SaveFileEEPROMAddresses gSaveFileEEPROMAddresses[] = { { 0x500, 0x30, 0x10
{ 0x20, 0x60, 0x1060, 0xf80, 0x1f80 },
{ 0x8, 0xfa0, 0x1fa0, 0xfa0, 0x1fa0 } };
extern s16 gUnk_02021EE0[6];
void sub_0807CD9C() {
sub_080530C8();
}
@@ -69,8 +70,8 @@ SaveResult HandleSave(u32 arg0) {
}
SaveResult HandleSaveInit(u32 arg0) {
gUnk_02021EE0[5] -= 8;
if (gUnk_02021EE0[4] <= 0) {
gSoundPlayingInfo.volumeMasterTarget -= 8;
if (gSoundPlayingInfo.volumeMaster <= 0) {
gMenu.field_0xa = 8;
gMenu.storyPanelIndex = SAVE_IN_PROGRESS;
}
@@ -107,9 +108,9 @@ SaveResult HandleSaveDone(u32 arg0) {
SaveResult result;
result = SAVE_BUSY;
gUnk_02021EE0[5] += 8;
if (gUnk_02021EE0[3] <= gUnk_02021EE0[5]) {
gUnk_02021EE0[5] = gUnk_02021EE0[3];
gSoundPlayingInfo.volumeMasterTarget += 8;
if (gSoundPlayingInfo.volumeMasterUnk <= gSoundPlayingInfo.volumeMasterTarget) {
gSoundPlayingInfo.volumeMasterTarget = gSoundPlayingInfo.volumeMasterUnk;
sub_08050384();
gMenu.storyPanelIndex = SAVE_INIT;
if (gMenu.field_0xa == 1) {
+12 -11
View File
@@ -9,6 +9,7 @@
#include "utils.h"
#include "save.h"
#include "random.h"
#include "audio.h"
#include "functions.h"
void InitScriptForEntity(Entity*, ScriptExecutionContext*, u16*);
@@ -137,10 +138,10 @@ void ScriptCommand_0807EEF4(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_0807EF3C(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_DoPostScriptAction(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_DoPostScriptAction2(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_PlaySound(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_PlayBgm(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_SoundReq(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_SoundReq2(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_SoundReq3(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_SoundReq0x80100000(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_StopBgm(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_ModRupees(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_ModHealth(Entity* entity, ScriptExecutionContext* context);
void ScriptCommand_IncreaseMaxHealth(Entity* entity, ScriptExecutionContext* context);
@@ -283,10 +284,10 @@ const ScriptCommand gScriptCommands[] = { ScriptCommandNop,
ScriptCommand_0807EF3C,
ScriptCommand_DoPostScriptAction,
ScriptCommand_DoPostScriptAction2,
ScriptCommand_PlaySound,
ScriptCommand_PlayBgm,
ScriptCommand_SoundReq,
ScriptCommand_SoundReq2,
ScriptCommand_SoundReq3,
ScriptCommand_SoundReq0x80100000,
ScriptCommand_StopBgm,
ScriptCommand_ModRupees,
ScriptCommand_ModHealth,
ScriptCommand_IncreaseMaxHealth,
@@ -1450,11 +1451,11 @@ void ScriptCommand_DoPostScriptAction2(Entity* entity, ScriptExecutionContext* c
context->postScriptActions |= 1 << context->scriptInstructionPointer[1];
}
void ScriptCommand_SoundReq(Entity* entity, ScriptExecutionContext* context) {
void ScriptCommand_PlaySound(Entity* entity, ScriptExecutionContext* context) {
SoundReq(context->scriptInstructionPointer[1]);
}
void ScriptCommand_SoundReq2(Entity* entity, ScriptExecutionContext* context) {
void ScriptCommand_PlayBgm(Entity* entity, ScriptExecutionContext* context) {
if (context->scriptInstructionPointer[1] >= 100) {
SoundReq(gArea.musicIndex);
} else {
@@ -1462,12 +1463,12 @@ void ScriptCommand_SoundReq2(Entity* entity, ScriptExecutionContext* context) {
}
}
void ScriptCommand_SoundReq3(Entity* entity, ScriptExecutionContext* context) {
void ScriptCommand_SoundReq(Entity* entity, ScriptExecutionContext* context) {
SoundReq(GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer));
}
void ScriptCommand_SoundReq0x80100000(Entity* entity, ScriptExecutionContext* context) {
SoundReq(SONG_RESET_UNK);
void ScriptCommand_StopBgm(Entity* entity, ScriptExecutionContext* context) {
SoundReq(SONG_STOP_BGM);
}
void ScriptCommand_ModRupees(Entity* entity, ScriptExecutionContext* context) {
+632 -86
View File
@@ -8,15 +8,50 @@
#include "structures.h"
#include "save.h"
u32 sub_080564DC(void);
u32 sub_080564EC(void);
u32 sub_08056654(void);
u32 sub_080565B4(void);
u32 sub_080565F8(void);
u32 sub_08056640(void);
#define TEXTBOX_ADVANCE_KEYS (A_BUTTON | B_BUTTON | DPAD_ANY | R_BUTTON)
#define TEXTBOX_PRESS_ANY_ADVANCE_KEYS ((gInput.newKeys & TEXTBOX_ADVANCE_KEYS) != 0)
u32 (*const gUnk_08107BC8[])(void) = {
sub_080564DC, sub_080564EC, sub_08056654, sub_080565B4, sub_080565F8, sub_08056640,
#define TEXTBOX_WIDTH 0x20
#define TEXTBOX_POSITION_INDEX(window) ((window).yPos * TEXTBOX_WIDTH + (window).xPos)
extern void WriteBit(u32*, u32);
extern void sub_0805EF40(u8*, u8*);
extern void sub_0801C4A0(u32, u32);
extern void sub_0801C494(void);
extern void sub_0805F918(u32, u32, u32);
extern u32 sub_0801D51C(u32, u8*, u32);
u32 sub_08056FEC(u32, u8*);
u16 sub_08056750(CurrentTextBox*);
u32 sub_0805EFE8(u8*);
void sub_08056ABC(u32, u32);
void sub_080569C4(CurrentTextBox*, u32);
u16 sub_0805F7DC(u32, u8*);
u32 sub_GetFontStrWidth(u8*, u32);
void sub_08056FBC(CurrentTextBox*);
void SetDoTextBox(u32 doTextbox);
void Load_02000D00_Asyc(void);
void DeleteWindow(void);
void CreateWindow(void);
u32 CalcWindowSize(u32 fade);
void DispMessageFrame(u16*, u32, u32, u32);
void DispString(void);
void DispCursor(void);
typedef u32 (*TextBoxFunction)(void);
u32 TextBoxFunction0(void);
u32 TextBoxFunction1(void);
u32 HandleTextBox(void);
u32 TextBoxFunctionOpen(void);
u32 TextBoxFunctionClose(void);
u32 TextBoxFunction5(void);
const TextBoxFunction gTextBoxFunctions[] = {
TextBoxFunction0, TextBoxFunction1, HandleTextBox, TextBoxFunctionOpen, TextBoxFunctionClose, TextBoxFunction5,
};
extern u8 gUnk_020227DC, gUnk_020227E8, gUnk_020227F0, gUnk_020227F8, gUnk_02022800;
@@ -24,22 +59,49 @@ u8* const gUnk_08107BE0[] = {
&gUnk_020227DC, &gUnk_020227E8, &gUnk_020227F0, &gUnk_020227F8, &gUnk_02022800,
};
void sub_08056684(struct_02022780*);
void sub_080566B8(struct_02022780*);
void sub_08056BA0(struct_02022780*);
void sub_08056B1C(struct_02022780*);
void sub_08056B7C(struct_02022780*);
void sub_080569D4(struct_02022780*);
typedef void (*TextBoxHandler)(CurrentTextBox*);
void (*const gUnk_08107BF4[])(struct_02022780*) = {
sub_08056684, sub_080566B8, sub_08056BA0, sub_08056B1C, sub_08056B7C, sub_080569D4,
void TextBoxHandler0(CurrentTextBox* this);
void TextBoxHandler1(CurrentTextBox* param_1);
void TextBoxHandlerAdvance(CurrentTextBox* ctb);
void TextBoxHandlerNextBox(CurrentTextBox* ctb);
void TextBoxHandler4(CurrentTextBox* ctb);
void TextBoxHandlerQuestion(CurrentTextBox* ctb);
const TextBoxHandler gTextBoxHandlers[] = {
TextBoxHandler0, TextBoxHandler1, TextBoxHandlerAdvance,
TextBoxHandlerNextBox, TextBoxHandler4, TextBoxHandlerQuestion,
};
extern u32 gUnk_02036A40;
extern u32 gUnk_02036A38;
extern u8 gUnk_02024030;
typedef struct Window {
u8 unk0;
u8 unk1;
u8 unk2;
u8 unk3;
u8 xPos;
u8 yPos;
u8 width;
u8 height;
} Window;
extern Window gCurrentWindow;
extern Window gNewWindow;
extern struct {
u8 unk_00;
u8 unk_01[1];
s8 unk_02;
s8 unk_03;
u8 unk_04[4];
u16 unk_08[4];
u16 unk_10[4];
} gUnk_02024030;
extern u32 gUnk_0200005C;
extern u8 gUnk_020227A0;
extern u8 gUnk_02000D00;
extern u8 gUnk_02000D00[0xD00];
extern const u8 gUnk_08107C0C[];
s32 sub_08056338(void) {
s32 result;
@@ -52,7 +114,7 @@ s32 sub_08056338(void) {
void sub_08056360(void) {
if ((gTextBox.doTextBox & 0x7f) != 0) {
gTextBox.doTextBox = 0x80 | 0x8;
gTextBox.doTextBox = 0x88;
}
}
@@ -64,22 +126,22 @@ void TextboxNoOverlapFollow(u32 index) {
}
}
void TextboxNoOverlap(u32 index, Entity* ent) {
void TextboxNoOverlap(u32 index, Entity* entity) {
s16 y;
s16 h;
s16 height;
ShowTextbox(index);
y = ent->y.HALF.HI;
h = ent->height.HALF.HI;
y = entity->y.HALF.HI;
height = entity->height.HALF.HI;
if (((y + h) - gRoomControls.roomScrollY) > 0x58) {
if (((y + height) - gRoomControls.roomScrollY) > 0x58) {
gTextBox.textWindowPosY = 1;
}
}
void sub_080563C8(u32 param_1, u32 param_2) {
TextboxAtPosition(param_1, 1, param_2);
void TextBoxAtYPosition(u32 index, u32 y) {
TextboxAtPosition(index, 1, y);
}
void TextboxAtPosition(u32 index, u32 x, u32 y) {
@@ -89,7 +151,7 @@ void TextboxAtPosition(u32 index, u32 x, u32 y) {
}
void ShowTextbox(u32 index) {
MemClear(&gTextBox, 32);
MemClear(&gTextBox, sizeof(gTextBox));
gTextBox.textIndex = index;
gTextBox.textSpeed = 99;
gTextBox.textWindowWidth = 26;
@@ -100,10 +162,10 @@ void ShowTextbox(u32 index) {
}
void MessageInitialize(void) {
MemClear(&gTextBox, 32);
MemClear(&gUnk_02022780, 168);
MemClear(&gUnk_02036A40, 8);
MemClear(&gUnk_02036A38, 8);
MemClear(&gTextBox, sizeof(gTextBox));
MemClear(&gCurrentTextBox, sizeof(gCurrentTextBox));
MemClear(&gNewWindow, sizeof(gNewWindow));
MemClear(&gCurrentWindow, sizeof(gCurrentWindow));
MemClear(&gUnk_02000040, 4);
}
@@ -111,125 +173,609 @@ void MessageUpdate(void) {
int iVar1;
if (gTextBox.doTextBox == 1) {
MemClear((u32*)&gUnk_02022780, sizeof(gUnk_02022780));
MemClear((u32*)&gCurrentTextBox, sizeof(gCurrentTextBox));
sub_080564C8(1);
}
if (gUnk_02022780._8a != 0) {
gUnk_02022780._8a--;
if (gCurrentTextBox._8a != 0) {
gCurrentTextBox._8a--;
} else {
do {
iVar1 = gUnk_08107BC8[gUnk_02022780._88]();
iVar1 = gTextBoxFunctions[gCurrentTextBox._88]();
} while (iVar1 != 0);
}
if (gUnk_02022780._9d != 0) {
gUnk_02022780._9d = 0;
sub_08056F70();
if (gCurrentTextBox._9d != 0) {
gCurrentTextBox._9d = 0;
Load_02000D00_Asyc();
}
DeleteWindow();
CreateWindow();
}
void sub_080564C8(u32 a1) {
gUnk_02022780._88 = a1;
gUnk_02022780._89 = 0;
void sub_080564C8(u32 unk) {
gCurrentTextBox._88 = unk;
gCurrentTextBox.state = 0;
}
u32 sub_080564DC(void) {
gUnk_02022780._99 = 0;
u32 TextBoxFunction0(void) {
gCurrentTextBox._98.bytes.b1 = 0;
return 0;
}
// regalloc in loop
NONMATCH("asm/non_matching/textbox/sub_080564EC.inc", u32 sub_080564EC(void)) {
NONMATCH("asm/non_matching/textbox/TextBoxFunction1.inc", u32 TextBoxFunction1(void)) {
u32 uVar1;
char* dest;
u32 i;
char c;
MemClear((void*)&gUnk_02036A40, 8);
MemClear((void*)&gNewWindow, 8);
MemClear((void*)&gUnk_02024030, 0x18);
MemClear((void*)&gUnk_02022780, 0xa8);
MemCopy(&gTextBox, &gUnk_02022780, 32);
if (gUnk_02022780._2 == 0x63) {
gUnk_02022780._2 = gUnk_02000000->messageSpeed;
MemClear((void*)&gCurrentTextBox, sizeof(gCurrentTextBox));
MemCopy(&gTextBox, &gCurrentTextBox, sizeof(gTextBox));
if (gCurrentTextBox.textBox.textSpeed == 0x63) {
gCurrentTextBox.textBox.textSpeed = gUnk_02000000->messageSpeed;
}
gUnk_02022780._9c = 0xff;
sub_0805EEB4(&gUnk_02022780._20, gUnk_02022780._8, 32);
gUnk_02022780._5c = 2;
gUnk_02022780._5d = 0xe;
dest = gUnk_02022780._5e;
gCurrentTextBox._9c = 0xff;
sub_0805EEB4(&gCurrentTextBox._20, gCurrentTextBox.textBox.textIndex);
gCurrentTextBox.playerName[0] = 2;
gCurrentTextBox.playerName[1] = 0xe;
dest = &gCurrentTextBox.playerName[2];
for (i = 0; i < 6; ++i) {
for (i = 0; i < FILENAME_LENGTH; ++i) {
c = gSave.playerName[i];
if (c == '\0')
break;
dest[i] = c;
*dest = c;
dest++;
}
dest[0] = 2;
dest[1] = 15;
dest[2] = 0;
sub_08056FBC(&gUnk_02022780);
gUnk_02022780._2c = &gUnk_08107BE0;
gUnk_02022780._58 = &gUnk_02000D00;
gUnk_02022780._54 = 0xd0;
sub_08056C54(2);
sub_08056FBC(&gCurrentTextBox);
gCurrentTextBox._2c = &gUnk_08107BE0;
gCurrentTextBox._50.unk8 = gUnk_02000D00;
gCurrentTextBox._50.unk4 = 0xd0;
SetDoTextBox(2);
sub_08056BDC(0);
sub_080564C8(2);
return 1;
}
END_NONMATCH
u32 sub_080565B4(void) {
if (gUnk_02022780._89 == 0) {
gUnk_02022780._89 = 1;
gUnk_02022780._99 = 1;
sub_08056F88(gUnk_02022780._3[0], gUnk_02022780._53);
u32 TextBoxFunctionOpen(void) {
if (gCurrentTextBox.state == 0) {
gCurrentTextBox.state = 1;
gCurrentTextBox._98.bytes.b1 = 1;
sub_08056F88(gCurrentTextBox.textBox.unk3, gCurrentTextBox._50.unk3);
SoundReq(SFX_TEXTBOX_OPEN);
}
if (sub_08056CC0(1)) {
gUnk_02022780._99 = 2;
if (CalcWindowSize(1)) {
gCurrentTextBox._98.bytes.b1 = 2;
sub_080564C8(2);
}
return 0;
}
u32 sub_080565F8(void) {
if (gUnk_02022780._89 == 0) {
gUnk_02022780._89 = 1;
gUnk_02022780._99 = 3;
u32 TextBoxFunctionClose(void) {
if (gCurrentTextBox.state == 0) {
gCurrentTextBox.state = 1;
gCurrentTextBox._98.bytes.b1 = 3;
sub_08056BDC(0);
SoundReq(SFX_TEXTBOX_CLOSE);
}
if (sub_08056CC0(-1)) {
gUnk_02022780._99 = 0;
if (CalcWindowSize(-1)) {
gCurrentTextBox._98.bytes.b1 = 0;
sub_080564C8(2);
}
return 0;
}
u32 sub_08056640() {
sub_08056C54(0);
u32 TextBoxFunction5(void) {
SetDoTextBox(0);
sub_080564C8(0);
return 0;
}
u32 sub_08056654(void) {
sub_08056C54(4);
gUnk_08107BF4[gUnk_02022780._89](&gUnk_02022780);
sub_08056CC0(0);
u32 HandleTextBox(void) {
SetDoTextBox(4);
gTextBoxHandlers[gCurrentTextBox.state](&gCurrentTextBox);
CalcWindowSize(0);
return 0;
}
void sub_08056684(struct_02022780* this) {
if ((gUnk_02022780._20 & 1) == 0) {
if (gUnk_02022780._99 == '\0') {
void TextBoxHandler0(CurrentTextBox* this) {
if ((gCurrentTextBox._20 & 1) == 0) {
if (gCurrentTextBox._98.bytes.b1 == 0) {
sub_080564C8(5);
}
} else {
this->_89 = 1;
this->state = 1;
}
}
void TextBoxHandler1(CurrentTextBox* param_1) {
u32 uVar3;
s32 iVar4;
int iVar5;
int iVar6;
if (param_1->_95 != 0) {
param_1->_95--;
} else {
if ((gInput.heldKeys & B_BUTTON) != 0) {
iVar4 = 8;
} else {
iVar4 = 1;
}
param_1->_92 -= iVar4;
if (param_1->_92 < 1) {
iVar5 = 0;
do {
iVar5++;
param_1->_92 += gUnk_08107C0C[param_1->textBox.textSpeed];
} while (param_1->_92 < 1);
iVar6 = 0;
do {
uVar3 = sub_08056750(param_1);
if (((uVar3 == 0) || (param_1->_95 != 0)) || (param_1->_8a != 0))
break;
iVar6 += uVar3;
iVar5--;
} while (0 < iVar5);
if (iVar6 != 0) {
gCurrentTextBox._9d = 1;
} else {
param_1->_92 = 0;
}
}
}
}
NONMATCH("asm/non_matching/textbox/sub_08056750.inc", u16 sub_08056750(CurrentTextBox* param_1)) {
s32 r0, r1, r2, r3;
u32 r7;
s32 tmp;
u32 t;
u32* t2;
r7 = param_1->_24;
if (r7 == 0) {
r7 = sub_0805EFE8(&param_1->_20);
switch (r7) {
case 0:
if (gUnk_02000040.unk_00 == 1) {
param_1->state = 5;
sub_08056ABC(0, 0);
} else {
param_1->state = 2;
}
break;
case 1:
param_1->_8a = 2;
if (param_1->_98.bytes.b0 == 0) {
sub_08056BDC(1);
} else {
param_1->state = 3;
}
break;
case 2:
sub_080564C8(3);
break;
case 3:
sub_080564C8(4);
break;
case 4:
param_1->_50.unk6 +=
(param_1->_50.unk4 - param_1->_50.unk6 - sub_GetFontStrWidth(&param_1->_20, 0)) / 2;
break;
case 5:
gTextBox.unk = param_1->_22;
break;
case 6:
t2 = &gUnk_0200005C;
t = param_1->_22;
WriteBit(t2, 0x1f & t);
break;
case 7:
switch (param_1->_22) {
case 0xe:
param_1->_91 = param_1->_8f;
r3 = 2;
break;
case 0xf:
r3 = param_1->_91;
break;
default:
r3 = param_1->_22;
break;
}
param_1->_90 = 0;
sub_080569C4(param_1, r3);
break;
case 8:
SoundReq(param_1->_22);
break;
case 9:
gCurrentTextBox.textBox.unk3 = param_1->_22;
sub_08056F88(param_1->_22, param_1->_50.unk3);
break;
case 10:
param_1->textBox.textWindowPosY = param_1->_22;
break;
case 12:
if (gUnk_02000040.unk_00 != 1) {
MemClear(&gUnk_02000040, 4);
MemClear(&gUnk_02024030, sizeof(gUnk_02024030));
gUnk_02024030.unk_00 = 1;
gUnk_02000040.unk_00 = 1;
}
if (gUnk_02024030.unk_02 > 3)
break;
gUnk_02024030.unk_10[gUnk_02024030.unk_02] = param_1->_26;
gUnk_02024030.unk_08[gUnk_02024030.unk_02] = param_1->_50.unk6;
gUnk_02024030.unk_02++;
param_1->_50.unk6 += 8;
break;
case 13:
switch (param_1->_22) {
case 0xff:
param_1->_8e = 1;
break;
case 0xfe:
param_1->_8e = 2;
break;
default:
param_1->_95 = param_1->_22;
break;
}
break;
case 14:
r1 = param_1->_22;
param_1->_94 = r1;
break;
default:
break;
}
if (r7 >> 8 == 0)
return 0;
}
if (gCurrentTextBox._98.bytes.b1 != 2) {
sub_080564C8(3);
return 0;
}
if (gTextBox.unk == 0) {
gTextBox.unk = 0x80;
}
param_1->_24 = 0;
if (r7 >> 8 == 7) {
param_1->_90 = param_1->_8f | 0x80;
sub_080569C4(param_1, 0);
} else {
if ((param_1->_90 & 0x80) != 0) {
r3 = param_1->_90;
param_1->_90 = 0;
sub_080569C4(param_1, r3);
}
}
return sub_0805F7DC(r7, &param_1->_30[0x20]);
}
END_NONMATCH
void sub_080569C4(CurrentTextBox* ctb, u32 unk) {
u32 temp = unk & 0x7;
ctb->_8f = temp;
ctb->_50.unk2 = temp;
}
extern u8 gUnk_08107C14;
extern u8 gUnk_08107C0F;
void TextBoxHandlerQuestion(CurrentTextBox* ctb) {
s32 r1, r5, r6;
u32 error;
u8* ptr1;
u8* ptr2;
r5 = gUnk_02024030.unk_03;
switch (gInput.newKeys) {
case START_BUTTON:
case A_BUTTON:
r1 = gUnk_02024030.unk_10[r5];
if (r1 == 0) {
ptr2 = &gUnk_08107C14;
ptr1 = &ctb->_20;
} else {
ctb->textBox.textIndex = r1;
sub_0805EEB4(&ctb->_20, r1);
ptr2 = &gUnk_08107C0F;
ptr1 = &ctb->_20;
}
sub_0805EF40(ptr1, ptr2);
gUnk_02000040.unk_01 = gUnk_02024030.unk_03;
gUnk_02000040.unk_00 = 3;
MemClear(&gUnk_02024030, sizeof(gUnk_02024030));
SoundReq(0x6a); // SFX_TEXTBOX_SELECT
ctb->state = 1;
break;
case DPAD_LEFT:
r5--;
break;
case DPAD_RIGHT:
r5++;
break;
default:
break;
}
r5 = (r5 + gUnk_02024030.unk_02) % gUnk_02024030.unk_02;
r6 = gUnk_02024030.unk_03;
if (r5 != r6) {
gUnk_02024030.unk_03 = r5;
SoundReq(0x69); // SFX_TEXTBOX_CHOICE
error = 1;
} else {
error = 0;
}
if (gUnk_02000040.unk_00 == 1) {
gUnk_02024030.unk_00 = gUnk_02000040.unk_00 = 2;
error = 1;
}
if (error != 0) {
sub_08056ABC(r5, r6);
}
}
void sub_08056ABC(u32 unk_0, u32 unk_1) {
u16 t;
t = gCurrentTextBox._50.unk6;
gCurrentTextBox._50.unk6 = gUnk_02024030.unk_08[unk_1];
sub_0805F8E4(0, &gCurrentTextBox._50);
gCurrentTextBox._50.unk6 = gUnk_02024030.unk_08[unk_0];
sub_0805F8E4(1, &gCurrentTextBox._50);
gCurrentTextBox._50.unk6 = t;
gCurrentTextBox._9d = 1;
}
void TextBoxHandlerNextBox(CurrentTextBox* ctb) {
u32 t;
u8* ptr;
gTextBox.unk = 0;
if (ctb->_94 != 0) {
ctb->_94--;
if (ctb->_94 != 0)
return;
ptr = &ctb->state;
t = 4;
} else {
if (TEXTBOX_PRESS_ANY_ADVANCE_KEYS) {
SoundReq(0x68); // SFX_TEXTBOX_SWAP
ctb->_98.bytes.b2 = 0;
ptr = &ctb->state;
t = 4;
} else {
ptr = &ctb->_98.bytes.b2;
t = *ptr + 1;
}
}
*ptr = t;
}
void TextBoxHandler4(CurrentTextBox* ctb) {
sub_08056BDC(0);
sub_080569C4(ctb, ctb->_8f | 0x40);
ctb->state = 1;
}
void TextBoxHandlerAdvance(CurrentTextBox* ctb) {
gTextBox.unk = 0;
SetDoTextBox(7);
if ((ctb->_8e != 1) && (ctb->_8e == 2 || TEXTBOX_PRESS_ANY_ADVANCE_KEYS)) {
sub_080564C8(4);
}
}
void sub_08056BDC(u32 unk) {
gCurrentTextBox._98.bytes.b0 = unk;
if (unk == 0) {
MemFill32(0xFFFFFFFF, gUnk_02000D00, sizeof(gUnk_02000D00));
Load_02000D00_Asyc();
gCurrentTextBox._9e = 0xf082;
gCurrentTextBox._a0 = 0xf083;
gCurrentTextBox._a2 = 0xf0b6;
gCurrentTextBox._a4 = 0xf0b7;
gCurrentTextBox._50.unk6 = 0;
gCurrentTextBox._50.unk4 = 0xd0;
} else {
gCurrentTextBox._50.unk6 = 0xd0;
gCurrentTextBox._50.unk4 = 0x1a0;
}
sub_080569C4(&gCurrentTextBox, gCurrentTextBox._8f | 0x40);
}
void SetDoTextBox(u32 doTextbox) {
gTextBox.doTextBox = gCurrentTextBox.textBox.doTextBox = doTextbox;
}
void DeleteWindow(void) {
u16* ptr;
int i, j;
Window* window = &gCurrentWindow;
if (window->unk1 != 0) {
window->unk1 = 0;
ptr = &gBG0Buffer[TEXTBOX_POSITION_INDEX(*window)];
i = window->height + 2;
do {
j = 0;
do {
ptr[j] = 0;
} while (j++, j < window->width + 2);
ptr += TEXTBOX_WIDTH;
i--;
} while (i > 0);
sub_0801C4A0(window->yPos, window->height);
sub_0801C494();
}
}
u32 CalcWindowSize(u32 fade) {
u32 scale;
u32 ret;
Window* window;
ret = 0;
gCurrentTextBox._98.bytes.sizeScale += fade;
if (gCurrentTextBox._98.bytes.sizeScale < 1) {
gCurrentTextBox._98.bytes.sizeScale = 0;
} else {
if (gCurrentTextBox._98.bytes.sizeScale < 8)
goto LAB_08056cee;
gCurrentTextBox._98.bytes.sizeScale = 8;
}
ret = 1;
LAB_08056cee:
window = &gNewWindow;
if (gCurrentTextBox._98.bytes.sizeScale != 0) {
scale = gCurrentTextBox._98.bytes.sizeScale;
window->width = (scale * (gCurrentTextBox.textBox.textWindowWidth << 1)) / 16;
if ((window->width & 1) != 0) {
window->width++;
}
window->xPos = ((gCurrentTextBox.textBox.textWindowWidth / 2) + gCurrentTextBox.textBox.textWindowPosX) -
(window->width / 2);
window->height = (scale * (gCurrentTextBox.textBox.textWindowHeight << 1)) / 16;
if ((window->height & 1) != 0) {
window->height++;
}
window->yPos = ((gCurrentTextBox.textBox.textWindowHeight / 2) + gCurrentTextBox.textBox.textWindowPosY) -
(window->height / 2);
} else {
window->yPos = -1;
window->xPos = -1;
window->height = -1;
window->width = -1;
}
window->unk1 = 1;
return ret;
}
void CreateWindow(void) {
s32 r0, r3;
u16* ptr;
r0 = gCurrentTextBox._98.bytes.sizeScale;
if (r0 <= 0)
return;
ptr = &gBG0Buffer[TEXTBOX_POSITION_INDEX(gNewWindow)];
r3 = 0xf07b;
DispMessageFrame(ptr, gNewWindow.width, gNewWindow.height, r3);
DispString();
DispCursor();
gCurrentWindow = gNewWindow;
sub_0801C494();
}
NONMATCH("asm/non_matching/textbox/DispMessageFrame.inc",
void DispMessageFrame(u16* buffer, u32 width_, u32 height_, u32 flags_)) {
}
END_NONMATCH
extern u16 gUnk_02034CB2[];
extern u16 gUnk_0202281E[];
void DispString(void) {
u32 r0, r2, r4;
u16 *ptr, *ptr2;
s32 i, j;
Window* window = &gNewWindow;
if (window->width != 0) {
if (window->height != 0) {
r4 = window->height;
ptr = &gUnk_02034CB2[TEXTBOX_POSITION_INDEX(*window)];
i = (s32)(4 - r4) / 2;
do {
j = window->width;
r2 = gUnk_0202281E[i];
ptr += TEXTBOX_WIDTH;
r0 = i + 1;
r4--;
ptr2 = ptr;
do {
*ptr2 = r2;
ptr2++;
r2 += 2;
j--;
} while (j > 0);
i = r0;
} while (r4 != 0);
}
}
}
void DispCursor(void) {
u32 offset;
u16* ptr;
if ((gCurrentTextBox._98.word & 0x10ff00) == 0x100200) {
ptr = &gBG0Buffer[TEXTBOX_POSITION_INDEX(gNewWindow)];
offset = (((gNewWindow.height + 1) * TEXTBOX_WIDTH) - 2);
offset += gNewWindow.width;
ptr += offset;
*ptr = 0xf080;
}
}
void Load_02000D00_Asyc(void) {
LoadResourceAsync(gUnk_02000D00, 0x0600D040, sizeof(gUnk_02000D00));
}
void sub_08056F88(u32 unk_1, u32 unk_2) {
u32 uVar1;
if (0xf < unk_1) {
unk_1 = 0;
}
uVar1 = unk_1 << 4 | unk_2;
if (gCurrentTextBox._9c != uVar1) {
gCurrentTextBox._9c = uVar1;
sub_0805F918(unk_1, unk_2, 0x0600CF60);
}
}
void sub_08056FBC(CurrentTextBox* ctb) {
sub_08056FEC(ctb->textBox.field_0x10, &ctb->_66[0x2]);
sub_08056FEC(ctb->textBox.field_0x14, &ctb->_66[0xa]);
sub_08056FEC(ctb->textBox.field_0x18, &ctb->_77[0x1]);
sub_08056FEC(ctb->textBox.field_0x1c, &ctb->_77[0x9]);
}
NONMATCH("asm/non_matching/textbox/sub_08056FEC.inc", u32 sub_08056FEC(u32 param_1, u8* param_2)) {
u32 uVar1;
int iVar2;
int iVar3;
int iVar4;
u8 local_1c[8];
uVar1 = sub_0801D51C(param_1, param_2, param_1);
uVar1 = uVar1 & 0xfffffff;
iVar4 = 0;
do {
local_1c[iVar4++] = uVar1 & 0xf;
uVar1 = uVar1 / 16;
} while (uVar1 != 0);
for (iVar3 = 0; --iVar4 >= 0; iVar3++) {
param_2[iVar3] = local_1c[iVar4] | 0x30;
}
param_2[iVar3] = 0;
return iVar4;
}
END_NONMATCH