summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornotyourav <65437533+notyourav@users.noreply.github.com>2022-02-01 20:28:25 -0800
committerGitHub <noreply@github.com>2022-02-01 20:28:25 -0800
commitdcc3ac219204e181117e366a1fb082c1ff4aabdd (patch)
tree9354649cab3c0e3f12d5a84ac01793461fcbb2c2 /src
parentb455aaf0133f9bae4a08efab65d9d9f1bc5b506f (diff)
parent5824dc8467b41e064ddc7d5118b54cf1bf08e54d (diff)
Merge pull request #341 from Henny022p/subtask
Diffstat (limited to 'src')
-rw-r--r--src/common.c7
-rw-r--r--src/debug.c26
-rw-r--r--src/enemy/gleerok.c6
-rw-r--r--src/enemy/octorokBoss.c6
-rw-r--r--src/fileselect.c60
-rw-r--r--src/game.c28
-rw-r--r--src/item/itemOcarina.c4
-rw-r--r--src/itemMenuTable.c53
-rw-r--r--src/manager/manager15.c2
-rw-r--r--src/manager/manager7.c8
-rw-r--r--src/menu/figurine_menu.c637
-rw-r--r--src/menu/kinstone_menu.c660
-rw-r--r--src/menu/pause_menu.c598
-rw-r--r--src/npc/npc23.c4
-rw-r--r--src/object/cloud.c2
-rw-r--r--src/object/fileScreenObjects.c14
-rw-r--r--src/objectUtils.c2
-rw-r--r--src/player.c6
-rw-r--r--src/playerItem/playerItemPacciCane.c6
-rw-r--r--src/script.c6
-rw-r--r--src/subtask.c62
-rw-r--r--src/subtask2.c24
22 files changed, 1985 insertions, 236 deletions
diff --git a/src/common.c b/src/common.c
index 28560dca..be03807d 100644
--- a/src/common.c
+++ b/src/common.c
@@ -62,13 +62,6 @@ extern struct_02017AA0 gUnk_02017AA0[];
extern u8 gUnk_03003DE4;
typedef struct {
- u8 _0[4];
- u8 evt_type;
- u8 _5[3];
-} struct_080C9CBC;
-extern struct_080C9CBC gUnk_080C9CBC[];
-
-typedef struct {
u8 evt_type;
u8 entity_idx;
u8 _2[6];
diff --git a/src/debug.c b/src/debug.c
index 19b3ae04..eaa65981 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -34,8 +34,8 @@ void sub_0805FA04(void) {
gScreen.bg3.updated = 1;
MessageInitialize();
MemClear((void*)&gUnk_02032EC0, sizeof(UI));
- MemClear((void*)&gMenu, sizeof(Menu));
- gMenu.unk16 = gSaveHeader->language;
+ MemClear((void*)&gGenericMenu, sizeof(GenericMenu));
+ gGenericMenu.unk16 = gSaveHeader->language;
LoadGfxGroups();
SetColor(0, 0x1144);
gMain.state = 1;
@@ -48,14 +48,14 @@ void sub_0805FA98(void) {
switch (gInput.newKeys) {
case DPAD_UP:
- gMenu.focusCoords[1] -= 1;
+ gGenericMenu.unk10.a[1] -= 1;
break;
case DPAD_DOWN:
- gMenu.focusCoords[1] += 1;
+ gGenericMenu.unk10.a[1] += 1;
break;
case L_BUTTON:
- gMenu.focusCoords[0] ^= 1;
- if (gMenu.focusCoords[0] == 0) {
+ gGenericMenu.unk10.a[0] ^= 1;
+ if (gGenericMenu.unk10.a[0] == 0) {
gScreen.bg0.control = BGCNT_SCREENBASE(31) | BGCNT_CHARBASE(3);
gScreen.bg3.control = BGCNT_SCREENBASE(30) | BGCNT_CHARBASE(3) | BGCNT_PRIORITY(3);
} else {
@@ -64,8 +64,8 @@ void sub_0805FA98(void) {
}
break;
case R_BUTTON:
- gSaveHeader->language = gMenu.unk16;
- MessageFromTarget(gMenu.unk14 * 0x100 + gMenu.unk15);
+ gSaveHeader->language = gGenericMenu.unk16;
+ MessageFromTarget(gGenericMenu.unk14 * 0x100 + gGenericMenu.unk15);
break;
case B_BUTTON:
MessageInitialize();
@@ -82,19 +82,19 @@ void sub_0805FA98(void) {
iVar1 = 0;
break;
}
- switch (gMenu.focusCoords[1]) {
+ switch (gGenericMenu.unk10.a[1]) {
case 0:
- gMenu.unk14 = (gMenu.unk14 + iVar1 + 0x50) % 0x50;
+ gGenericMenu.unk14 = (gGenericMenu.unk14 + iVar1 + 0x50) % 0x50;
break;
case 1:
- gMenu.unk15 += iVar1;
+ gGenericMenu.unk15 += iVar1;
break;
case 2:
- gMenu.unk16 = (gMenu.unk16 + iVar1 + 7) % 7;
+ gGenericMenu.unk16 = (gGenericMenu.unk16 + iVar1 + 7) % 7;
break;
}
}
- gMenu.focusCoords[1] = (gMenu.focusCoords[1] + 3) % 3;
+ gGenericMenu.unk10.a[1] = (gGenericMenu.unk10.a[1] + 3) % 3;
gScreen.bg3.updated = 1;
}
diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c
index d190e4c3..f7170f8e 100644
--- a/src/enemy/gleerok.c
+++ b/src/enemy/gleerok.c
@@ -125,7 +125,7 @@ void sub_0802D034(GleerokEntity* this) {
void sub_0802D158(GleerokEntity* this) {
super->action = 1;
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
SetFade(7, 8);
}
@@ -373,7 +373,7 @@ void sub_0802D650(GleerokEntity* this) {
void sub_0802D674(GleerokEntity* this) {
u32 val;
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
if (gPlayerEntity.z.WORD != 0)
return;
@@ -464,7 +464,7 @@ void sub_0802D7B4(GleerokEntity* this) {
#ifndef EU
gPlayerState.controlMode = CONTROL_1;
#endif
- gUnk_02034490[0] = 0;
+ gUnk_02034490.unk0 = 0;
SoundReq(BGM_BOSS_THEME);
return;
} else {
diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c
index 57c55849..bdbd9144 100644
--- a/src/enemy/octorokBoss.c
+++ b/src/enemy/octorokBoss.c
@@ -197,7 +197,7 @@ void OctorokBoss_Hit_SubAction0(Entity* this) {
GET_HELPER(this)->fallingStonesTimer = 0;
if (GET_BOSS_PHASE(this) == 4) {
this->subAction = 4;
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
sub_08078B48();
SoundReq(SFX_BOSS_DIE);
} else {
@@ -504,7 +504,7 @@ ASM_FUNC("asm/non_matching/octorokBoss/OctorokBoss_Init.inc", void OctorokBoss_I
void OctorokBoss_Intro(Entity* this) {
sub_08078B48();
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
sub_08036F60(this);
OctorokBoss_Intro_SubActions[this->subAction](this);
sub_0805EC9C(this, this->field_0x76.HWORD, this->field_0x74.HWORD, GET_ANGLE(this));
@@ -578,7 +578,7 @@ void OctorokBoss_Intro_SubAction5(Entity* this) {
this->subAction = 0;
gRoomControls.unk5 = gPlayerEntity.animationState;
OctorokBoss_SetAttackTimer(this);
- gUnk_02034490[0] = 0;
+ gUnk_02034490.unk0 = 0;
SoundReq(BGM_BOSS_THEME);
}
} else {
diff --git a/src/fileselect.c b/src/fileselect.c
index f2e1cb39..129bd6da 100644
--- a/src/fileselect.c
+++ b/src/fileselect.c
@@ -363,7 +363,7 @@ void sub_08050848(void) {
sub_0805070C();
gUnk_02019EE0.unk7 = 0;
sub_08050AFC(gUnk_02019EE0.unk6);
- sub_080A7114(1);
+ SetMenuType(1);
}
void sub_0805086C(void) {
@@ -404,7 +404,7 @@ void sub_080508E4(void) {
void sub_08050910(void) {
sub_08050384();
if (++gUnk_02019EE0.unk7 > 2) {
- sub_080A7114(2);
+ SetMenuType(2);
} else {
gChooseFileState.subState = 0;
}
@@ -630,7 +630,7 @@ void sub_08050C54(void) {
SoundReq(SONG_VOL_FADE_OUT);
}
gMenu.transitionTimer = 0xf;
- sub_080A7114(1);
+ SetMenuType(1);
SoundReq(SFX_TEXTBOX_SELECT);
break;
case B_BUTTON:
@@ -686,7 +686,7 @@ void sub_08050DB8(void) {
MemClear(&gBG2Buffer, sizeof(gBG2Buffer));
sub_080503A8(0xc);
gMenu.field_0x4 = gSaveHeader->language;
- sub_080A7114(1);
+ SetMenuType(1);
}
void sub_08050DE4(void) {
@@ -707,7 +707,7 @@ void sub_08050DE4(void) {
case START_BUTTON:
SoundReq(SFX_TEXTBOX_SELECT);
if (gMenu.field_0x4 != row_idx) {
- sub_080A7114(2);
+ SetMenuType(2);
CreateDialogBox(8, 0);
} else {
SetFileSelectState(STATE_NONE);
@@ -751,7 +751,7 @@ void sub_08050EB8(void) {
gUnk_02019EE0.unk5 = save->brightness;
gMenu.column_idx = 0;
gMenu.transitionTimer = 0xff;
- sub_080A7114(1);
+ SetMenuType(1);
}
NONMATCH("asm/non_matching/fileScreen/sub_08050EF4.inc", void sub_08050EF4(void)) {
@@ -804,7 +804,7 @@ NONMATCH("asm/non_matching/fileScreen/sub_08050EF4.inc", void sub_08050EF4(void)
gUnk_02019EE0.saves[gUnk_02019EE0.unk6].msg_speed = gUnk_02019EE0.unk4;
gUnk_02019EE0.saves[gUnk_02019EE0.unk6].brightness = gUnk_02019EE0.unk5;
SoundReq(SFX_MENU_CANCEL);
- sub_080A7114(mode);
+ SetMenuType(mode);
SetActiveSave(gUnk_02019EE0.unk6);
break;
case 2:
@@ -812,7 +812,7 @@ NONMATCH("asm/non_matching/fileScreen/sub_08050EF4.inc", void sub_08050EF4(void)
SoundReq(SFX_TEXTBOX_SELECT);
default:
case 1:
- sub_080A7114(mode);
+ SetMenuType(mode);
SetActiveSave(gUnk_02019EE0.unk6);
break;
case 0:
@@ -836,7 +836,7 @@ void sub_08050FFC(void) {
sub_0805194C(gUnk_02019EE0.unk6);
CreateDialogBox(9, 0);
case SAVE_OK:
- sub_080A7114(3);
+ SetMenuType(3);
break;
}
}
@@ -867,7 +867,7 @@ void sub_08051090(void) {
sub_08051458();
gScreen.bg1.yOffset = 0xff;
gScreen.bg2.yOffset = 0xff;
- sub_080A7114(1);
+ SetMenuType(1);
}
NONMATCH("asm/non_matching/fileScreen/sub_080610B8.inc", void sub_080610B8(void)) {
@@ -875,11 +875,11 @@ NONMATCH("asm/non_matching/fileScreen/sub_080610B8.inc", void sub_080610B8(void)
END_NONMATCH
void sub_08051358(void) {
- gMenu.field_0x12 = gSaveHeader->language == 0 ? 4 : 3;
+ gGenericMenu.unk10.a[2] = gSaveHeader->language == 0 ? 4 : 3;
- if (gMenu.focusCoords[0] != 0x0b || gMenu.focusCoords[1] != 0x5) {
- gMenu.focusCoords[1] = 0x5;
- gMenu.focusCoords[0] = 0xb;
+ if (gGenericMenu.unk10.a[0] != 0x0b || gGenericMenu.unk10.a[1] != 0x5) {
+ gGenericMenu.unk10.a[1] = 0x5;
+ gGenericMenu.unk10.a[0] = 0xb;
SoundReq(SFX_TEXTBOX_NEXT);
}
}
@@ -897,7 +897,7 @@ void sub_080513C0(void) {
switch (HandleSave(0)) {
case 1:
gUnk_02019EE0.saveStatus[gUnk_02019EE0.unk6] = 1;
- sub_080A7114(3);
+ SetMenuType(3);
break;
case 0:
break;
@@ -914,7 +914,7 @@ void sub_0805141C(void) {
switch (gMenu.transitionTimer) {
case 0:
if (gInput.newKeys & (A_BUTTON | START_BUTTON)) {
- sub_080A7114(3);
+ SetMenuType(3);
}
break;
default:
@@ -940,7 +940,7 @@ void sub_08051480(u32 c) {
u32 idx;
result = sub_080514BC(c);
- idx = gMenu.unk13;
+ idx = gGenericMenu.unk10.a[3];
if (result == RESULT_INVALID) {
return;
@@ -955,7 +955,7 @@ void sub_08051480(u32 c) {
idx = FILENAME_LENGTH - 1;
}
- gMenu.unk13 = idx + 1;
+ gGenericMenu.unk10.a[3] = idx + 1;
gSave.name[idx] = c;
sub_08051574(SFX_6B);
}
@@ -976,7 +976,7 @@ u32 sub_080514BC(u32 a1) {
return 1;
}
- idx = gMenu.unk13;
+ idx = gGenericMenu.unk10.a[3];
if (idx == 0)
return 0;
@@ -1039,7 +1039,7 @@ void HandleFileDelete(void) {
}
void sub_080515c8(void) {
- sub_080A7114(1);
+ SetMenuType(1);
}
void sub_080515D4(void) {
@@ -1058,7 +1058,7 @@ void sub_080515D4(void) {
case START_BUTTON:
if (column_idx == 1) {
CreateDialogBox(4, 0);
- sub_080A7114(2);
+ SetMenuType(2);
SoundReq(SFX_TEXTBOX_SELECT);
} else {
SetFileSelectState(0);
@@ -1108,19 +1108,19 @@ NONMATCH("asm/non_matching/fileScreen/sub_08051738.inc", void sub_08051738(void)
} else {
uVar3++;
}
- (&gMenu.selectMtx)[i] = uVar3;
+ (&gGenericMenu.selectMtx)[i] = uVar3;
}
if (uVar3 == 0) {
gMenu.transitionTimer = 0x3c;
CreateDialogBox(1, 0);
- sub_080A7114(3);
+ SetMenuType(3);
} else {
- sub_080A7114(1);
+ SetMenuType(1);
}
uVar3++;
- gMenu.unk16 = uVar3;
- gMenu.unk13 = 4;
- gMenu.unk14 = uVar3;
+ gGenericMenu.unk16 = uVar3;
+ gGenericMenu.unk10.a[3] = 4;
+ gGenericMenu.unk14 = uVar3;
}
END_NONMATCH
@@ -1128,7 +1128,7 @@ s32 sub_080517B4(s32 a1) {
u32 i = gUnk_02019EE0.unk7;
if (a1 != 0) {
for (i = i + a1; i < 5; i += a1) {
- if ((&gMenu.focusCoords[0])[i] != 0 && (&gMenu.focusCoords[0])[i] != 4)
+ if (gGenericMenu.unk10.a[i] != 0 && gGenericMenu.unk10.a[i] != 4)
return i;
}
@@ -1156,7 +1156,7 @@ void sub_080517EC(void) {
case START_BUTTON:
if (gUnk_02019EE0.unk7 < 3) {
CreateDialogBox(2, 0);
- sub_080A7114(2);
+ SetMenuType(2);
SoundReq(SFX_TEXTBOX_SELECT);
break;
}
@@ -1188,7 +1188,7 @@ void sub_08051874(void) {
sub_0805194C(gUnk_02019EE0.unk7);
CreateDialogBox(3, 0);
gMenu.transitionTimer = 0x1e;
- sub_080A7114(3);
+ SetMenuType(3);
break;
}
}
diff --git a/src/game.c b/src/game.c
index b2aefb17..009c9859 100644
--- a/src/game.c
+++ b/src/game.c
@@ -323,7 +323,7 @@ static void GameMain_ChangeRoom(void) {
sub_080300C4();
gMain.substate = GAMEMAIN_UPDATE;
SetPlayerControl(0);
- gUnk_02034490[0] = 0;
+ gUnk_02034490.unk0 = 0;
#if defined(USA) || defined(DEMO_USA)
if (gArea.inventoryGfxIdx != 0xff) {
sub_0801855C();
@@ -645,14 +645,14 @@ void GameOverTask(void) {
static void switch_state(u32 idx) {
gMain.state = idx;
- sub_080A7114(0);
+ SetMenuType(0);
}
static void GameOver_Init(void) {
if (gFadeControl.active)
return;
sub_08052010();
- gMenu.focusCoords[0] = 80;
+ gGenericMenu.unk10.a[0] = 80;
gMenu.transitionTimer = 60;
gSave.stats.health = 24;
gMain.field_0x5 = 60;
@@ -667,8 +667,8 @@ static void GameOver_FadeIn(void) {
return;
if (gMain.field_0x5 == 0) {
- if (gMenu.focusCoords[0] >= 38) {
- gMenu.focusCoords[0]--;
+ if (gGenericMenu.unk10.a[0] >= 38) {
+ gGenericMenu.unk10.a[0]--;
} else {
gMenu.transitionTimer--;
if (gMenu.transitionTimer == 0) {
@@ -706,7 +706,7 @@ static void GameOver_TextMove(void) {
case 0:
gMenu.transitionTimer = 30;
gMenu.field_0x3 = 0;
- sub_080A7114(1);
+ SetMenuType(1);
SetPopupState(0, 0);
gFadeControl.mask = 0xffffffff;
return;
@@ -728,7 +728,7 @@ static void GameOver_TextMove(void) {
temp2 = 2;
}
gMenu.transitionTimer = 60;
- sub_080A7114(temp2);
+ SetMenuType(temp2);
SoundReq(SFX_TEXTBOX_SELECT);
break;
}
@@ -746,12 +746,12 @@ static void GameOver_TextMove(void) {
gMenu.field_0x0 = temp3;
switch (temp3) {
case 1:
- sub_080A7114(4);
+ SetMenuType(4);
break;
case -1:
gMenu.transitionTimer = 60;
CreateDialogBox(9, 0);
- sub_080A7114(3);
+ SetMenuType(3);
break;
}
return;
@@ -759,7 +759,7 @@ static void GameOver_TextMove(void) {
if (gMenu.transitionTimer != 0) {
gMenu.transitionTimer--;
} else if (gInput.newKeys & (A_BUTTON | B_BUTTON | START_BUTTON)) {
- sub_080A7114(0);
+ SetMenuType(0);
}
return;
case 4:
@@ -777,7 +777,7 @@ static void GameOver_Update(void) {
case 0x0:
gMenu.transitionTimer = 0x1e;
gMenu.field_0x3 = 0;
- sub_080A7114(1);
+ SetMenuType(1);
SetPopupState(1, 0);
return;
case 0x1:
@@ -795,7 +795,7 @@ static void GameOver_Update(void) {
temp = 1;
break;
case A_BUTTON:
- sub_080A7114(2);
+ SetMenuType(2);
SoundReq(SFX_TEXTBOX_SELECT);
if (temp == 0) {
SetFade(5, 8);
@@ -839,7 +839,7 @@ static void DrawGameOverText(void) {
gOamCmd._4 = 0;
gOamCmd._6 = 0;
gOamCmd._8 = 0x8600;
- gOamCmd.y = gMenu.focusCoords[0];
+ gOamCmd.y = gGenericMenu.unk10.a[0];
for (i = 0; i < 8; ++i) {
gOamCmd.x = sOffsets[i];
#ifdef EU
@@ -1233,7 +1233,7 @@ static void InitRoomTransition(void) {
bool32 CanDispEzloMessage(void) {
s32 tmp = PL_STATE_WALK;
- if (!(gInput.heldKeys & SELECT_BUTTON) || gPlayerState.controlMode != CONTROL_ENABLED || gUnk_02034490[0] ||
+ if (!(gInput.heldKeys & SELECT_BUTTON) || gPlayerState.controlMode != CONTROL_ENABLED || gUnk_02034490.unk0 ||
gUnk_0200AF00.filler0[1])
return 0;
diff --git a/src/item/itemOcarina.c b/src/item/itemOcarina.c
index af8812bb..fff83945 100644
--- a/src/item/itemOcarina.c
+++ b/src/item/itemOcarina.c
@@ -24,7 +24,7 @@ void OcarinaUse(ItemBehavior* this, u32 arg1) {
gPlayerEntity.field_0x7a.HWORD = 2;
gPlayerState.flags |= PL_USE_OCARINA;
gPlayerState.field_0x27[0] = -1;
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
gPlayerState.field_0xa = (8 >> arg1) | gPlayerState.field_0xa;
gPlayerState.keepFacing = (8 >> arg1) | gPlayerState.keepFacing;
ResetPlayerVelocity();
@@ -41,7 +41,7 @@ NONMATCH("asm/non_matching/ocarina/OcarinaUpdate.inc", void OcarinaUpdate(ItemBe
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerState.flags &= ~PL_USE_OCARINA;
gPlayerState.field_0x27[0] = 0;
- gUnk_02034490[0] = 0;
+ gUnk_02034490.unk0 = 0;
CreateBird();
ResetPlayerEventPriority();
sub_08077E78(this, arg1);
diff --git a/src/itemMenuTable.c b/src/itemMenuTable.c
deleted file mode 100644
index 04622c7a..00000000
--- a/src/itemMenuTable.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "global.h"
-
-typedef enum {
- SWORD,
- GUST_JAR,
- CANE,
- BOOMERANG,
- SHIELD,
- MOLE_MITTS,
- LANTERN,
- BOMBS,
- PEGASUS_BOOTS,
- ROCS_CAPE,
- OCARINA,
- BOW,
- BOTTLE0,
- BOTTLE1,
- BOTTLE2,
- BOTTLE3,
- SAVE_BUTTON,
-} ItemMenuTableSlot;
-
-typedef struct {
- u8 up;
- u8 down;
- u8 left;
- u8 right;
- u8 type;
- u8 unk0;
- u8 x;
- u8 y;
-} ItemMenuTableEntry;
-
-const ItemMenuTableEntry gItemMenuTable[] = {
- [SWORD] = { BOTTLE0, SHIELD, BOOMERANG, GUST_JAR, 0x01, 0x0c, 0x42, 0x33 },
- [GUST_JAR] = { BOTTLE1, MOLE_MITTS, SWORD, CANE, 0x01, 0x10, 0x66, 0x33 },
- [CANE] = { BOTTLE3, LANTERN, GUST_JAR, BOOMERANG, 0x01, 0x14, 0x8a, 0x33 },
- [BOOMERANG] = { SAVE_BUTTON, BOMBS, CANE, SWORD, 0x01, 0x15, 0xae, 0x33 },
- [SHIELD] = { SWORD, PEGASUS_BOOTS, BOMBS, MOLE_MITTS, 0x01, 0x16, 0x42, 0x4b },
- [MOLE_MITTS] = { GUST_JAR, ROCS_CAPE, SHIELD, LANTERN, 0x01, 0x17, 0x66, 0x4b },
- [LANTERN] = { CANE, OCARINA, MOLE_MITTS, BOMBS, 0x01, 0x00, 0x8a, 0x4b },
- [BOMBS] = { BOOMERANG, BOW, LANTERN, SHIELD, 0x01, 0x00, 0xae, 0x4b },
- [PEGASUS_BOOTS] = { SHIELD, BOTTLE0, BOW, ROCS_CAPE, 0x01, 0x00, 0x42, 0x63 },
- [ROCS_CAPE] = { MOLE_MITTS, BOTTLE1, PEGASUS_BOOTS, OCARINA, 0x01, 0x00, 0x66, 0x63 },
- [OCARINA] = { LANTERN, BOTTLE3, ROCS_CAPE, BOW, 0x01, 0x00, 0x8a, 0x63 },
- [BOW] = { BOMBS, SAVE_BUTTON, OCARINA, PEGASUS_BOOTS, 0x01, 0x00, 0xae, 0x63 },
- [BOTTLE0] = { PEGASUS_BOOTS, SWORD, SAVE_BUTTON, BOTTLE1, 0x01, 0x00, 0x42, 0x7b },
- [BOTTLE1] = { ROCS_CAPE, GUST_JAR, BOTTLE0, BOTTLE2, 0x01, 0x00, 0x5a, 0x7b },
- [BOTTLE2] = { ROCS_CAPE, GUST_JAR, BOTTLE1, BOTTLE3, 0x01, 0x00, 0x72, 0x7b },
- [BOTTLE3] = { OCARINA, CANE, BOTTLE2, SAVE_BUTTON, 0x01, 0x00, 0x8a, 0x7b },
- [SAVE_BUTTON] = { BOW, BOOMERANG, BOTTLE3, BOTTLE0, 0x03, 0x00, 0xb5, 0x75 },
- { BOW, BOOMERANG, BOTTLE3, BOTTLE0, 0x05, 0x00, 0xb5, 0x75 },
-};
diff --git a/src/manager/manager15.c b/src/manager/manager15.c
index 21cad632..598f7b04 100644
--- a/src/manager/manager15.c
+++ b/src/manager/manager15.c
@@ -306,7 +306,7 @@ void sub_0805A76C(Manager15* this) {
gPlayerEntity.animationState = 4;
RequestPriorityDuration((Entity*)this, 600);
SetPlayerControl(0xFF);
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
gRoomControls.camera_target = NULL;
sub_08077B20();
}
diff --git a/src/manager/manager7.c b/src/manager/manager7.c
index 7666d365..25a73eb4 100644
--- a/src/manager/manager7.c
+++ b/src/manager/manager7.c
@@ -80,7 +80,7 @@ void Manager7_Main(Manager7* this) {
tmp2 = &gUnk_081080A4[tmp << 4];
tmp3 = this->manager.unk_0e;
if (tmp3 == 0) {
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000);
LoadPaletteGroup(gUnk_081081E4[tmp]);
this->manager.unk_0e++;
@@ -97,7 +97,7 @@ void Manager7_Main(Manager7* this) {
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[(this->manager.unk_0e << 1)]],
tmp2[(this->manager.unk_0e << 1) + 1], 0x1000);
this->manager.unk_0e++;
- gUnk_02034490[0] = 0;
+ gUnk_02034490.unk0 = 0;
case 8:
break;
}
@@ -130,7 +130,7 @@ void Manager7_Main(Manager7* this) {
tmp2 = &gUnk_081080A4[tmp << 4];
switch (this->manager.unk_0e) {
case 0:
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000);
LoadPaletteGroup(gUnk_081081E4[tmp]);
this->manager.unk_0e++;
@@ -147,7 +147,7 @@ void Manager7_Main(Manager7* this) {
this->manager.unk_0e++;
break;
case 8:
- gUnk_02034490[0] = 0;
+ gUnk_02034490.unk0 = 0;
this->manager.unk_0e++;
break;
}
diff --git a/src/menu/figurine_menu.c b/src/menu/figurine_menu.c
new file mode 100644
index 00000000..7405260e
--- /dev/null
+++ b/src/menu/figurine_menu.c
@@ -0,0 +1,637 @@
+#include "global.h"
+#include "main.h"
+#include "menu.h"
+#include "sound.h"
+#include "common.h"
+#include "screen.h"
+#include "save.h"
+#include "flags.h"
+#include "subtask.h"
+#include "object.h"
+#include "game.h"
+#include "functions.h"
+
+extern const struct {
+ u8 filler[7];
+ u8 unk7;
+} gUnk_080FC3E4[];
+extern u32 gUnk_02002B0E;
+
+void sub_080A4DA8(u32);
+void sub_080A4B44(void);
+void FigurineMenu_080A4978(void);
+u32 sub_080A4CBC(u32);
+u32 sub_080A4BA0(u32, u32);
+void sub_080A4DB8(u32);
+
+const KeyButtonLayout gUnk_0812813C = {
+ 0xffu,
+ 0xd8u,
+ 0u,
+ 0xd0u,
+ 0x10u,
+ 0xeu,
+ 0xffu,
+ 0xd8u,
+ 0u,
+ {
+ 0xau,
+ 0u,
+ 0x1u,
+ 0x1u,
+ 0xffu,
+ 0u,
+ 0u,
+ },
+};
+
+extern u8 gUnk_020344A0[8];
+typedef struct {
+ u8 unk0;
+ u8 unk1;
+ u16 unk2;
+ u16 unk4;
+ u16 unk6;
+} struct_08128AD8;
+extern const struct_08128AD8 gUnk_08128AD8[];
+
+Subtask FigurineMenu0_Type0;
+Subtask FigurineMenu0_Type1;
+Subtask FigurineMenu0_Type2;
+Subtask FigurineMenu0_Type3;
+Subtask FigurineMenu1_Type0;
+Subtask FigurineMenu1_Type1;
+Subtask FigurineMenu1_Type2;
+Subtask FigurineMenu1_Type3;
+void Subtask_FigurineMenu(void) {
+ static Subtask* const figurineMenu1_Types[] = {
+ FigurineMenu0_Type0,
+ FigurineMenu0_Type1,
+ FigurineMenu0_Type2,
+ FigurineMenu0_Type3,
+ };
+ static Subtask* const figurineMenu0_Types[] = {
+ FigurineMenu1_Type0,
+ FigurineMenu1_Type1,
+ FigurineMenu1_Type2,
+ FigurineMenu1_Type3,
+ };
+#if !(defined(DEMO_USA) || defined(DEMO_JP))
+ FlushSprites();
+ if (gUnk_02032EC0.field_0x3 == 0xff) {
+ figurineMenu0_Types[gMenu.menuType]();
+ } else {
+ figurineMenu1_Types[gMenu.menuType]();
+ }
+ UpdateEntities();
+ sub_0801C1D4();
+ DrawOAMCmd();
+ DrawEntities();
+ FigurineMenu_080A4978();
+ CopyOAM();
+ sub_080A4B44();
+#endif
+}
+
+void FigurineMenu_080A4608(void) {
+ s32 iVar2;
+
+ SetBgmVolume(0x80);
+ sub_080A4DA8(3);
+ SetColor(0, gPaletteBuffer[0xfb]);
+ SetColor(0x15c, gPaletteBuffer[0xd3]);
+ MemClear(&gBG0Buffer, 0x800);
+ MemClear(&gBG3Buffer, 0x1000);
+ gScreen.controls.window0HorizontalDimensions = 0xf0;
+ gScreen.controls.window0VerticalDimensions = 0x7898;
+ gScreen.controls.windowInsideControl = 0x1f;
+ gScreen.controls.windowOutsideControl = 0x1d;
+ gScreen.bg1.updated = 1;
+ for (iVar2 = 0; iVar2 < 0x10; iVar2++) {
+ gFigurineMenu.unk10.a[iVar2] = 0xee;
+ }
+ {
+ int r0, r1, r2;
+
+ r1 = gUnk_02032EC0.field_0x3;
+ r0 = gSave.unk6;
+ r2 = 0x88;
+ if (r0 == 0) {
+ r2 = 0x82;
+ }
+ if (r2 < r1) {
+ r1 = 1;
+ }
+ gFigurineMenu.unk1c = r1;
+ }
+ SetFade(4, 8);
+}
+
+void FigurineMenu_080A46C0(void) {
+ SetBgmVolume(0x100);
+ SoundReq(SFX_MENU_CANCEL);
+ ClearRoomFlag(2);
+ Subtask_Exit();
+}
+
+void FigurineMenu0_Type0(void) {
+ FigurineMenu_080A4608();
+ SetMenuType(1);
+}
+
+void FigurineMenu0_Type1(void) {
+ if (gFadeControl.active == 0) {
+ CreateObject(OBJECT_A2, gUnk_080FC3E4[gFigurineMenu.unk1c].unk7, 0);
+ SetMenuType(2);
+ }
+}
+
+void FigurineMenu0_Type2(void) {
+ u32 bVar1;
+ Sound sound;
+
+ if (gMenu.field_0x0 != 0) {
+ gFigurineMenu.unk20 += 1;
+ switch (gFigurineMenu.unk20) {
+ case 0x40:
+ gFigurineMenu.unk21 = WriteBit(&gUnk_02002B0E, gFigurineMenu.unk1c);
+ gMenu.column_idx = 1;
+ default:
+ bVar1 = gFigurineMenu.unk20 >> 2;
+ if (0x10 < bVar1) {
+ bVar1 = 0x20 - bVar1;
+ }
+ gScreen.controls.layerBrightness = bVar1;
+ gScreen.controls.layerFXControl = 0xbf;
+ break;
+ case 0x80:
+ gScreen.controls.layerBrightness = 0;
+ gScreen.controls.layerFXControl = 0;
+ gScreen.lcd.displayControl |= 0x2000;
+ SetMenuType(3);
+ sub_080A70AC((KeyButtonLayout*)&gUnk_0812813C);
+ gMenu.column_idx = 0x15;
+ if (gFigurineMenu.unk21 == 0) {
+ sound = SFX_109;
+ } else {
+ sound = SFX_MENU_ERROR;
+ }
+ SoundReq(sound);
+ return;
+ }
+ }
+}
+
+void FigurineMenu0_Type3(void) {
+ s32 uVar1;
+ s32 t;
+
+ uVar1 = gFigurineMenu.unk1f;
+ switch (gInput.unk4) {
+ case 2:
+ case 8:
+ FigurineMenu_080A46C0();
+ break;
+ case 0x10:
+ uVar1 += 8;
+ break;
+ case 0x20:
+ uVar1 -= 8;
+ break;
+ }
+ t = gFigurineMenu.unk1e;
+ if (uVar1 < 0) {
+ uVar1 = 0;
+ }
+ if (t < uVar1) {
+ uVar1 = t;
+ }
+ gFigurineMenu.unk1f = uVar1;
+ gScreen.bg1.yOffset = uVar1 - 0x70;
+}
+
+void FigurineMenu1_Type0(void) {
+ FigurineMenu_080A4608();
+ gScreen.lcd.displayControl |= 0x2000;
+ sub_080A70AC(&gUnk_0812813C);
+ gMenu.column_idx = 0xff;
+ SetMenuType(1);
+}
+
+void FigurineMenu1_Type1(void) {
+ int r0, r1, r4, r5;
+
+ if (gFadeControl.active)
+ return;
+
+ r5 = gFigurineMenu.unk1f;
+ r4 = gFigurineMenu.unk1c;
+ switch (gInput.unk4) {
+ case 2:
+ case 8:
+ SetMenuType(3);
+ break;
+ case 0x200:
+ r4 -= 5;
+ break;
+ case 0x100:
+ r4 += 5;
+ break;
+ case 0x40:
+ r4--;
+ break;
+ case 0x80:
+ r4++;
+ break;
+ case 0x10:
+ r5 += 8;
+ break;
+ case 0x20:
+ r5 -= 8;
+ break;
+ case 1:
+ break;
+ }
+ r1 = (gSave.unk6 == 0) ? 0x82 : 0x88;
+ if (r4 <= 0) {
+ r4 = 1;
+ }
+ if (r1 < r4) {
+ r4 = r1;
+ }
+ r0 = gFigurineMenu.unk1c;
+ if (r0 != r4) {
+ gFigurineMenu.unk1c = r4;
+ SoundReq(SFX_TEXTBOX_CHOICE);
+ SetMenuType(2);
+ r5 = 0;
+ }
+ r0 = gFigurineMenu.unk1e;
+ if (r5 < 0) {
+ r5 = 0;
+ }
+ if (r0 < r5) {
+ r5 = r0;
+ }
+ gFigurineMenu.unk1f = r5;
+ gScreen.bg1.yOffset = r5 - 0x70;
+}
+
+void FigurineMenu1_Type2(void) {
+ SetMenuType(1);
+}
+
+void FigurineMenu1_Type3(void) {
+ FigurineMenu_080A46C0();
+}
+
+u32 sub_080A4948(s32 param_1) {
+ s32 iVar1;
+ u32 uVar2;
+
+ uVar2 = 0;
+ iVar1 = gSave.unk6 == 0 ? 0x82 : 0x88;
+ if ((0 < param_1) || (iVar1 >= param_1)) {
+ if (ReadBit((u32*)&gSave.stats.filler4[4], param_1)) {
+ uVar2 = 1;
+ }
+ }
+ return uVar2;
+}
+
+typedef struct {
+ u8* pal;
+ u8* gfx;
+ int size;
+ int zero;
+} Figurine;
+
+extern const Figurine gFigurines[];
+
+#ifdef EU
+#define sub_080A4978_draw_constant 0x1fb
+#else
+#define sub_080A4978_draw_constant 0x1fc
+#endif
+void FigurineMenu_080A4978(void) {
+ int r0, r2, r4, r6;
+
+ gOamCmd._4 = 0;
+ gOamCmd._6 = 0;
+ gOamCmd._8 = 0x800;
+ gOamCmd.x = 0x9c;
+ gOamCmd.y = 0x48;
+ DrawDirect(sub_080A4978_draw_constant, 0);
+ r2 = (gSave.unk6 == 0) ? 0x82 : 0x88;
+ if ((gMenu.column_idx & 2) != 0) {
+ if (r2 >= (gFigurineMenu.unk1c)) {
+ gOamCmd.x = 0xe8;
+ r0 = (0x5000 / r2) * (gFigurineMenu.unk1c - 1);
+ if (r0 < 0) {
+ r0 += 0xff;
+ }
+ r0 >>= 8;
+ r0 += 0x20;
+ gOamCmd.y = r0;
+ DrawDirect(sub_080A4978_draw_constant, 1);
+ r0 = gMain.ticks.HWORD & 0x10;
+ r4 = (r0) ? 4 : 2;
+ gOamCmd.x = 0xe8;
+ gOamCmd.y = 0x1a;
+ DrawDirect(sub_080A4978_draw_constant, r4);
+ gOamCmd.x = 0xe8;
+ gOamCmd.y = 0x76;
+ DrawDirect(sub_080A4978_draw_constant, r4 + 1);
+ }
+ }
+ if (gMain.ticks.HWORD & 0x10) {
+ if (gMenu.column_idx & 0x10) {
+ if (gFigurineMenu.unk1e) {
+ gOamCmd.y = 0x10;
+ if (gFigurineMenu.unk1f > 0) {
+ gOamCmd.x = 6;
+ gOamCmd.y = 0x9c;
+ DrawDirect(sub_080A4978_draw_constant, 6);
+ }
+ if (gFigurineMenu.unk1e > gFigurineMenu.unk1f) {
+ gOamCmd.x = 0xea;
+ gOamCmd.y = 0x9c;
+ DrawDirect(sub_080A4978_draw_constant, 7);
+ }
+ }
+ }
+ }
+ if (gSaveHeader->language) {
+ if (gMenu.column_idx & 0x4) {
+ gOamCmd.y = 0x10;
+ r4 = gFigurineMenu.unk1c;
+ for (r6 = 2; r6 >= 0; r6--) {
+ gOamCmd.x = 0x5d + (r6 * 7);
+ gOamCmd._8 = ((r4 % 10) << 1) | 0x9e0;
+ DrawDirect(0, 9);
+ r4 = r4 / 10;
+ }
+ }
+ }
+ if (gMenu.column_idx & 1) {
+ if (sub_080A4948(gFigurineMenu.unk1c)) {
+ gOamCmd.x = 0x2c;
+ gOamCmd.y = 0x48;
+ gOamCmd._8 = 0xd4 << 7;
+ DrawDirect(sub_080A4978_draw_constant - 4, gFigurineMenu.unk1c - 1);
+ if (gFigurineMenu.unk1d != gFigurineMenu.unk1c) {
+ const Figurine* fig;
+ u8* gfx;
+ gFigurineMenu.unk1d = gFigurineMenu.unk1c;
+ fig = &gFigurines[gFigurineMenu.unk1c];
+ LoadPalettes(fig->pal, 0x16, 9);
+ gfx = fig->gfx;
+ if (fig->size < 0) {
+ LZ77UnCompVram(gfx, (void*)0x6014000);
+ } else {
+ LoadResourceAsync(gfx, 0x6014000, fig->size);
+ }
+ }
+ }
+ }
+}
+
+void sub_080A4B44(void) {
+ u32 uVar1;
+
+ uVar1 = gFigurineMenu.unk1c;
+ if ((gMenu.column_idx & 0x10) != 0) {
+ gFigurineMenu.unk1e = sub_080A4CBC(uVar1);
+ }
+ if ((gMenu.column_idx & 4) != 0) {
+ sub_080A4BA0(uVar1, 2);
+ }
+ if ((gMenu.column_idx & 8) != 0) {
+ sub_080A4BA0(uVar1 - 2, 0);
+ sub_080A4BA0(uVar1 - 1, 1);
+ sub_080A4BA0(uVar1 + 1, 3);
+ sub_080A4BA0(uVar1 + 2, 4);
+ }
+}
+
+typedef struct {
+ u16* unk0;
+ u32 unk4;
+ u8 filler8[8];
+ u16 unk10;
+ u8 filler12[2];
+ u8 unk14;
+} struct_0812816C;
+static_assert(sizeof(struct_0812816C) == 0x18);
+const struct_0812816C gUnk_0812816C = {
+ (u16*)0x02001b40,
+ 0x0600a000,
+ { 0u, 0xdu, 0u, 0x2u, 0u, 0u, 0u, 0u },
+ 0xf100,
+ {
+ 0x88u,
+ 0u,
+ },
+ 0x4u,
+};
+
+typedef struct {
+ u32 unk0;
+ u32 unk4;
+ u8 unk8;
+ u8 unk9;
+} struct_08128184;
+static_assert(sizeof(struct_08128184) == 0xc);
+const struct_08128184 gUnk_08128184 = {
+ 0x01061504,
+ 0x073a1404,
+ 0xffu,
+ 0xffu,
+};
+
+extern u8 gUnk_020227E8[];
+extern void sub_08057044(u32, u8*, u8*);
+extern void sub_0805F46C(u32, const struct_0812816C*);
+
+NONMATCH("asm/non_matching/menu/figurine_menu/sub_080A4BA0.inc", u32 sub_080A4BA0(u32 unk1, u32 unk2)) {
+ int r0, r1, r2, r3, r4, r5, r6;
+
+ struct_0812816C s0;
+ u8 buffer[0x30];
+ struct_08128184 s2;
+
+ r5 = unk1;
+ r6 = unk2;
+ MemClear(buffer, sizeof(buffer));
+ MemCopy(&gUnk_0812816C, &s0, sizeof(gUnk_0812816C));
+ MemCopy(&gUnk_08128184, &s2, sizeof(gUnk_08128184));
+ r1 = r6 << 1;
+ r1 += r6;
+ r2 = r1 << 9;
+ s0.unk4 += r2;
+ s0.unk10 += r1 << 4;
+ r1 = r6 << 7;
+ s0.unk0 += r1;
+ if (r6 == 2) {
+ s0.unk14 = r6;
+ }
+ r1 = (gSave.unk6 == 0) ? 0x82 : 0x88;
+ if (r5 <= 0 || r1 < r5) {
+ r0 = -1;
+ } else {
+ sub_08057044(r5, gUnk_020227E8, (void*)0x303030);
+ if (sub_080A4948(r5) == 0) {
+ r5 += 0x8000;
+ } else {
+ r5 += 0x800;
+ }
+ }
+ if ((r0 = gFigurineMenu.unk10.h[r6]) == r5)
+ return r0;
+ gFigurineMenu.unk10.h[r6] = r5;
+ r0 = (r6 != 2) ? 0xf00b : 7;
+ MemFill16(r0, s0.unk0, 0x80);
+ if (r5 > 0) {
+ if (r5 > 0x7fff) {
+ r5 = 0x889;
+ }
+ r0 = r5;
+ if (r5 < 0) {
+ r0 += 0xff;
+ }
+ s2.unk8 = r0 >> 8;
+ s2.unk9 = r5;
+ s0.unk0 += 0x16;
+ if (gSaveHeader->language == 0) {
+ sub_0805F46C((u32)&s2, &s0);
+ } else {
+ sub_0805F46C(r5, &s0);
+ }
+ }
+ gScreen.bg3.updated = 1;
+ return 1;
+}
+END_NONMATCH
+
+const struct_0812816C gUnk_08128190 = {
+ (u16*)0x02021f72,
+ 0x06004000,
+ {
+ 0u,
+ 0xdu,
+ 0u,
+ 0x2u,
+ 0u,
+ 0u,
+ 0u,
+ 0u,
+ },
+ 0xc200,
+ {
+ 0xe0u,
+ 0u,
+ },
+ 0x5u,
+};
+
+u32 sub_080A4CBC(u32 param_1) {
+ s32 iVar1;
+ const u16* psVar2;
+ u32 uVar3;
+
+ if (gFigurineMenu.unk1a != param_1) {
+ gFigurineMenu.unk1a = param_1;
+ MemClear(&gBG1Buffer, 0x800);
+ MemCopy(&gBG1Buffer, (void*)0x600e000, 0x800);
+ iVar1 = sub_080A4948(param_1);
+ if (iVar1 != 0) {
+ sub_0805F46C(param_1 + 0x900, &gUnk_08128190);
+ }
+ gScreen.bg1.updated = 1;
+ }
+ psVar2 = gUnk_08128190.unk0 + 0x80;
+
+ for (uVar3 = 0; uVar3 < 0x14; uVar3++) {
+ if (*psVar2 == 0)
+ break;
+ psVar2 += 0x20;
+ }
+ return uVar3 << 3;
+}
+
+void sub_080A4D34(void) {
+ s32 iVar1;
+
+ LoadGfxGroups();
+ LoadPaletteGroup(0xb5);
+ if (gSave.stats.health <= 8) {
+ iVar1 = 2;
+ } else {
+ s32 missingHealth = gSave.stats.maxHealth - gSave.stats.health;
+ if (missingHealth < 9) {
+ iVar1 = 0;
+ } else {
+ iVar1 = 1;
+ }
+ }
+ LoadGfxGroup(iVar1 + 0x56);
+ gScreen.bg3.xOffset = 0;
+ gScreen.bg3.yOffset = 0;
+ gScreen.bg3.control = 0x1e0b;
+ gScreen.bg3.updated = 1;
+}
+
+void sub_080A4D88(void) {
+ MemClear(gUnk_020344A0, sizeof(gUnk_020344A0));
+ MenuFadeIn(1, 0);
+ SetBgmVolume(0x80);
+}
+
+void sub_080A4DA8(u32 param_1) {
+ sub_080A4D34();
+ sub_080A4DB8(param_1);
+}
+
+void sub_080A4DB8(u32 param_1) {
+ const struct_08128AD8* ptr;
+
+ sub_08056250();
+ MemClear(&gBG0Buffer, 0x800);
+ MemClear(&gBG1Buffer, 0x800);
+ MemClear(&gBG2Buffer, 0x800);
+ MemClear(gUnk_0200AF00.filler25 + 0xf, 0x300);
+ MemClear(&gFigurineMenu, sizeof(gFigurineMenu));
+ gFigurineMenu.unk2e = 0xffff;
+ gMenu.field_0x3 = gUnk_02034490.unk2[param_1];
+ ptr = &gUnk_08128AD8[gUnk_08128A38[param_1].unk0];
+ gScreen.lcd.displayControl = ptr->unk2 | 0x1940;
+ gScreen.bg0.xOffset = 0;
+ gScreen.bg0.yOffset = 0;
+ gScreen.bg0.updated = 1;
+ gScreen.bg1.xOffset = 0;
+ gScreen.bg1.yOffset = 0;
+ gScreen.bg1.control = ptr->unk4;
+ gScreen.bg1.updated = 1;
+ gScreen.bg2.xOffset = 0;
+ gScreen.bg2.yOffset = 0;
+ gScreen.bg2.control = ptr->unk6;
+ gScreen.bg2.updated = 1;
+ gScreen.bg3.xOffset = 0;
+ gScreen.bg3.yOffset = 0;
+ gScreen.bg3.control = 0x1e0b;
+ if (ptr->unk0 != 0) {
+ LoadPaletteGroup(ptr->unk0);
+ }
+ if (ptr->unk1 != 0) {
+ LoadGfxGroup(ptr->unk1);
+ }
+}
+
+void sub_080A4E84(u8 param_1) {
+ gUnk_02034490.unk14 = param_1;
+}
+
+void sub_080A4E90(u8 param_1) {
+ gUnk_02034490.unk11 = param_1;
+ gUnk_02034490.unk12 = 0;
+}
diff --git a/src/menu/kinstone_menu.c b/src/menu/kinstone_menu.c
new file mode 100644
index 00000000..890ac05e
--- /dev/null
+++ b/src/menu/kinstone_menu.c
@@ -0,0 +1,660 @@
+#include "global.h"
+#include "menu.h"
+#include "room.h"
+#include "subtask.h"
+#include "common.h"
+#include "screen.h"
+#include "sound.h"
+#include "save.h"
+#include "kinstone.h"
+#include "flags.h"
+#include "message.h"
+#include "main.h"
+#include "object.h"
+#include "npc.h"
+#include "enemy.h"
+#include "functions.h"
+
+typedef struct {
+ u8 filler0[0x1];
+ u8 unk1;
+ u8 charColor;
+ u8 bgColor;
+ u16 unk4;
+ u16 unk6;
+ u8* unk8;
+} struct_02036540;
+
+extern u32 sub_08000E44(u32);
+extern void sub_080A3B74(void);
+extern s32 sub_080A3B48(void);
+extern void sub_0805ECEC(u32, u32, u32, u32);
+extern void sub_0801C2F0(u32, u32);
+extern void sub_0801E6C8(u32);
+extern void sub_0801E798(u32);
+extern struct_02036540* sub_0805F2C8(void);
+extern void sub_0805F300(struct_02036540*);
+extern u32 sub_0805F76C(u8*, struct_02036540*);
+
+typedef struct {
+ void* sourceAddress;
+ void* destinationAddress;
+ union {
+ u32 word;
+ struct {
+ u16 low;
+ u16 high;
+ } half;
+ } control;
+} DMARegisters;
+
+#define DMA3 ((volatile DMARegisters*)REG_ADDR_DMA3SAD)
+
+extern const u32 gUnk_080CA06C[];
+extern const u8 gGlobalGfxAndPalettes[];
+extern u8 gTextGfxBuffer[];
+extern u8 gUnk_02002AC0[];
+
+u32 sub_080A44E0(struct_02036540*, u8*, u32);
+u32 sub_080A4418(u32, u32);
+u32 sub_080A43DC(u32);
+u32 sub_080A43A8(u32);
+void sub_080A42E0(u32, u32);
+void KinstoneMenu_080A4054(void);
+void KinstoneMenu_080A4468(void);
+void KinstoneMenu_080A422C(void);
+void KinstoneMenu_080A414C(void);
+void KinstoneMenu_080A4080(void);
+u32 KinstoneMenu_080A4494(void);
+void KinstoneMenu_080A4528(void);
+
+Subtask KinstoneMenu_Type0;
+Subtask KinstoneMenu_Type1;
+Subtask KinstoneMenu_Type2;
+Subtask KinstoneMenu_Type3;
+Subtask KinstoneMenu_Type4;
+Subtask KinstoneMenu_Type5;
+void Subtask_KinstoneMenu(void) {
+ static Subtask* const kinstoneMenuTypes[] = {
+ KinstoneMenu_Type0, KinstoneMenu_Type1, KinstoneMenu_Type2,
+ KinstoneMenu_Type3, KinstoneMenu_Type4, KinstoneMenu_Type5,
+ };
+#if !(defined(DEMO_USA) || defined(DEMO_JP))
+ gRoomTransition.player_status.field_0x24[8] = 2;
+ FlushSprites();
+ kinstoneMenuTypes[gMenu.menuType]();
+ sub_080A3B74();
+ KinstoneMenu_080A4054();
+ sub_0801C1D4();
+ DrawOAMCmd();
+ UpdateEntities();
+ DrawEntities();
+ CopyOAM();
+ gRoomTransition.player_status.field_0x24[8] = 0;
+#endif
+}
+
+const u8 gUnk_081280DC[] = {
+ 0xd8u, 0xeu, 0xdu, 0xc4u, 0x1au, 0xeu, 0xffu, 0xd8u, 0u, 0x9u, 0u, 0u, 0x1u, 0xau, 0u, 0x1u, 0x1u, 0xffu,
+};
+
+void KinstoneMenu_Type0(void) {
+ s32 iVar1;
+ s32 iVar2;
+
+ gMenu.column_idx = 1;
+ gKinstoneMenu.unk2a = 0;
+ sub_080A4D34();
+ LoadPaletteGroup(0xcb);
+ LoadGfxGroup(0x75);
+
+ iVar1 = KinstoneMenu_080A4494();
+ iVar2 = iVar1 + 7;
+ if (iVar2 < 0) {
+ iVar2 += 0x7;
+ }
+
+ iVar1 = (iVar2 >> 3) - 6;
+ iVar1 = max(iVar1, 0);
+ iVar1 = min(iVar1, 6);
+
+ LoadGfxGroup(iVar1 + 0x76);
+ gScreen.lcd.displayControl |= 0x1e00;
+ gScreen.bg1.control = 0x1c01;
+ gScreen.bg2.control = 0x1d02;
+ gScreen.bg3.control = 0x1e0b;
+ gScreen.bg1.updated = 1;
+ gScreen.bg2.updated = 1;
+ gScreen.bg3.updated = 1;
+ KinstoneMenu_080A4528();
+ sub_080A4398();
+ sub_0801E738(0);
+ sub_080A70AC((void*)gUnk_081280DC);
+ SetMenuType(1);
+ SetFade(6, 8);
+}
+
+const u8 gUnk_081280EE[] = {
+ 0x5u, 0x7u, 0xau, 0xeu, 0x13u, 0x1au,
+};
+
+NONMATCH("asm/non_matching/menu/kinstone_menu/KinstoneMenu_Type1.inc", void KinstoneMenu_Type1(void)) {
+ s32 tmp1, tmp2, tmp3, tmp4, tmp5;
+ u8* ptr;
+ GenericMenu* menu;
+ if (gFadeControl.active) {
+ return;
+ }
+ menu = &gGenericMenu;
+ menu->base.column_idx = 2;
+ tmp2 = menu->unk28 * 0x10000;
+ tmp1 = tmp2 - menu->unk10.i;
+ if ((tmp1 < 0 ? -tmp1 : tmp1) <= 0x1ffdu) {
+ menu->unk10.i = tmp2;
+ } else {
+ menu->base.column_idx = 1;
+ tmp2 = sub_08000E44(tmp1);
+ tmp1 = tmp1 / 0x20000;
+ if (tmp1 < 0)
+ tmp1 = -tmp1;
+ if (tmp1 > 5) {
+ tmp1 = 5;
+ }
+ menu->unk10.i += gUnk_081280EE[tmp1] * 0x666 * tmp2;
+ }
+ if (menu->unk29 != menu->unk10.i / 0x10000) {
+ menu->unk29 = menu->unk10.i / 0x10000;
+ SoundReq(SFX_TEXTBOX_CHOICE);
+ }
+ if ((gInput.newKeys & 0x20a) != 0) {
+ SetMenuType(2);
+ SoundReq(SFX_MENU_CANCEL);
+ return;
+ }
+ tmp3 = menu->unk28;
+ switch (gInput.unk4) {
+ case 0x20:
+ case 0x40:
+ tmp3 -= 1;
+ break;
+ case 0x10:
+ case 0x80:
+ tmp3 += 1;
+ break;
+ case 1:
+ if (gMenu.column_idx == 2) {
+ tmp3 = gGenericMenu.unk10.i / 0x10000;
+ gGenericMenu.unk2a = gSave.unk118[tmp3];
+ SetMenuType(3);
+ }
+ break;
+ }
+ tmp4 = sub_080A3B48();
+ if (tmp4 <= tmp3) {
+ tmp3 = tmp4 - 1;
+ }
+ if (tmp4 < 2) {
+ tmp3 = 0;
+ }
+ if (tmp3 < 0) {
+ tmp3 = 0;
+ }
+ if (menu->unk28 != tmp3) {
+ menu->unk28 = tmp3;
+ }
+}
+END_NONMATCH
+
+void KinstoneMenu_Type2(void) {
+ const struct_080C9CBC* ptr;
+ if (gMenu.column_idx == 6) {
+ gFuseInfo._0 = 6;
+ ptr = &gUnk_080C9CBC[gFuseInfo._3];
+ if (ptr->unk3 != 0) {
+ MenuFadeIn(ptr->unk3, ptr->evt_type);
+ } else {
+ Subtask_Exit();
+ }
+ } else {
+ gFuseInfo._0 = 5;
+ Subtask_Exit();
+ }
+}
+
+Subtask KinstoneMenu_Type3_Overlay0;
+Subtask KinstoneMenu_Type3_Overlay1;
+Subtask KinstoneMenu_Type3_Overlay2;
+void KinstoneMenu_Type3(void) {
+ static Subtask* const kinstoneMenu_Type3_overlays[] = {
+ KinstoneMenu_Type3_Overlay0,
+ KinstoneMenu_Type3_Overlay1,
+ KinstoneMenu_Type3_Overlay2,
+ };
+ gMenu.column_idx = 3;
+ kinstoneMenu_Type3_overlays[gMenu.overlayType]();
+}
+
+void KinstoneMenu_Type3_Overlay0(void) {
+ gKinstoneMenu.unk18 = 0;
+ gKinstoneMenu.unk2c += 2;
+ if (0x45 < gKinstoneMenu.unk2c) {
+ gKinstoneMenu.unk2c = 0x46;
+ gMenu.overlayType = 1;
+ }
+}
+
+void KinstoneMenu_Type3_Overlay1(void) {
+ u32 temp = gUnk_080C9CBC[gKinstoneMenu.unk2a].unk5;
+ if (temp != gUnk_080C9CBC[gFuseInfo._3].unk5) {
+ SoundReq(SFX_ITEM_SHIELD_BOUNCE);
+ SetMenuType(4);
+ } else {
+ gMenu.overlayType = 2;
+ gMenu.transitionTimer = 0x14;
+ gScreen.lcd.displayControl |= 0x2000;
+ gScreen.controls.window0HorizontalDimensions = 0x6887;
+ gScreen.controls.window0VerticalDimensions = 0x405f;
+ gScreen.controls.windowInsideControl = 0x3f;
+ gScreen.controls.windowOutsideControl = 0x1f;
+ gScreen.controls.layerFXControl = 0x3f90;
+ gScreen.controls.layerBrightness = 0;
+ SoundReq(SFX_FA);
+ }
+}
+
+void KinstoneMenu_Type3_Overlay2(void) {
+ if (++gScreen.controls.layerBrightness > 14) {
+ gScreen.controls.layerBrightness = 0;
+ gScreen.lcd.displayControl &= 0xdfff;
+ SetMenuType(5);
+ }
+}
+
+void KinstoneMenu_Type4(void) {
+ gMenu.column_idx = 4;
+ gKinstoneMenu.unk2c -= 3;
+ gKinstoneMenu.unk18 += 0x100;
+ if (gKinstoneMenu.unk2c < 0) {
+ gKinstoneMenu.unk18 = 0;
+ gKinstoneMenu.unk2c = 0;
+ SetMenuType(1);
+ SoundReq(SFX_MENU_ERROR);
+ }
+}
+
+Subtask KinstoneMenu_Type5_Overlay0;
+Subtask KinstoneMenu_Type5_Overlay1;
+Subtask KinstoneMenu_Type5_Overlay2;
+Subtask KinstoneMenu_Type5_Overlay3;
+void KinstoneMenu_Type5(void) {
+ static Subtask* const kinstoneMenu_Type5_Overlays[] = {
+ KinstoneMenu_Type5_Overlay0,
+ KinstoneMenu_Type5_Overlay1,
+ KinstoneMenu_Type5_Overlay2,
+ KinstoneMenu_Type5_Overlay3,
+ };
+ kinstoneMenu_Type5_Overlays[gMenu.overlayType]();
+}
+
+extern u8 gUnk_02002C81[];
+
+void KinstoneMenu_Type5_Overlay0(void) {
+ gMenu.column_idx = 5;
+ WriteBit((u32*)gUnk_02002C81, gFuseInfo._3);
+ if (99 < ++gUnk_02002C81[-298]) {
+ gUnk_02002C81[-299] = 1;
+ }
+ KinstoneMenu_080A4468();
+ SoundReq(SFX_TASK_COMPLETE);
+ MessageAtHeight(0x702, 0xe);
+ gMenu.overlayType = 1;
+ gMenu.transitionTimer = 0x78;
+}
+
+void KinstoneMenu_Type5_Overlay1(void) {
+ if ((gMessage.doTextBox & 0x7f) == 0) {
+ gMenu.overlayType = 2;
+ SoundReq(SFX_147);
+ }
+}
+
+void KinstoneMenu_Type5_Overlay2(void) {
+ gMenu.transitionTimer -= 1;
+ if (gMenu.transitionTimer != 0) {
+ gKinstoneMenu.unk18 += gKinstoneMenu.unk1a;
+ gKinstoneMenu.unk1a += 0x20;
+ } else {
+ gMenu.column_idx = 6;
+ gMenu.overlayType = 3;
+ gMenu.transitionTimer = 0x4f;
+ CreateObject(OBJECT_B3, 1, 0);
+ SoundReq(SFX_1CA);
+ }
+}
+
+void KinstoneMenu_Type5_Overlay3(void) {
+ // TODO figure out why in some place s16 is needed and u16 in others
+ if (--(s16)gMenu.transitionTimer < 0) {
+ SetMenuType(2);
+ }
+}
+
+// something kinstone related, maybe inventory
+typedef struct {
+ u8 unk_00[1];
+ u8 unk_01;
+ u8 unk_02[2];
+} struct_02019EE0;
+extern struct_02019EE0 gUnk_02019EE0[16];
+
+void KinstoneMenu_080A4054(void) {
+ u32 uVar2;
+ KinstoneMenu_080A422C();
+ KinstoneMenu_080A414C();
+ KinstoneMenu_080A4080();
+ for (uVar2 = 0; uVar2 < 0x10; uVar2++) {
+ if (gUnk_02019EE0[uVar2].unk_01 != 0) {
+ gUnk_02019EE0[uVar2].unk_01 -= 1;
+ }
+ }
+}
+
+void KinstoneMenu_080A4080(void) {
+ static const u8 gUnk_08128110[] = {
+ 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0x1u, 0x1u, 0x1u, 0x2u, 0x2u, 0x3u, 0x2u, 0x3u, 0x2u,
+ };
+
+ u32 uVar1;
+ s32 iVar2;
+ s32 iVar3;
+ const u8* temp;
+
+ u32 t;
+
+ gOamCmd._4 = 0;
+ gOamCmd._6 = 0;
+ gOamCmd.y = 0x10 - gKinstoneMenu.unk2f;
+ gOamCmd.x = 0x40;
+ gOamCmd._8 = 0x400;
+#ifdef EU
+ DrawDirect(0x1fa, 0);
+#else
+ DrawDirect(0x1fb, 0);
+#endif
+ gOamCmd.y = 0x94;
+ gOamCmd.x = 0x50;
+ gOamCmd._8 = 0x480;
+#ifdef EU
+ t = 0x1f9;
+#else
+ t = 0x1fa;
+#endif
+ DrawDirect(t, 0);
+ gOamCmd.x = 0xb8;
+ gOamCmd._8 = 0x4a0;
+ DrawDirect(t, 1);
+ uVar1 = gMain.ticks.HWORD >> 2 & 0xe;
+ temp = &gUnk_08128110[uVar1];
+ gOamCmd.x = 10 - temp[0];
+ gOamCmd._8 = 0x4e0;
+ iVar2 = sub_080A3B48() - 1;
+ if (0 < iVar2) {
+ iVar3 = gKinstoneMenu.unk10.WORD;
+ if (iVar3 < 0) {
+ iVar3 = gKinstoneMenu.unk10.WORD + 0xffff;
+ }
+ if (iVar3 >> 0x10 != iVar2) {
+ gOamCmd.y = temp[1] + 0x77;
+ DrawDirect(t, 3);
+ }
+ if (iVar3 >> 0x10 != 0) {
+ gOamCmd.y = 0x27 - temp[1];
+ DrawDirect(t, 2);
+ }
+ }
+}
+
+NONMATCH("asm/non_matching/menu/kinstone_menu/KinstoneMenu_080A414C.inc", void KinstoneMenu_080A414C(void)) {
+ s32 uVar1;
+ s32 iVar2;
+ s32 uVar3;
+
+ s32 i;
+
+ gOamCmd._4 = 0;
+ gOamCmd._6 = 0;
+ uVar1 = gKinstoneMenu.unk10.HALF.LO / 0xb21;
+ for (i = -3, uVar1 = -uVar1 - 0x45; i < 4; uVar1 += 0x17, i++) {
+ gOamCmd.y = ((gSineTable[uVar1 & 0xff] * 0x44) / 0x100) + 0x4f;
+ gOamCmd.x = ((gSineTable[(uVar1 + 0x40) & 0xff] * 0x42) / 0x100) - 0x10;
+ iVar2 = gKinstoneMenu.unk10.WORD / 0x10000 + i;
+ if (iVar2 >= 0) {
+ uVar3 = gSave.unk12B[iVar2];
+ if (i == 0) {
+ switch (gMenu.column_idx) {
+ case 3:
+ case 4:
+ uVar3 -= 1;
+ break;
+ default:
+ break;
+ }
+ }
+ if (0 < uVar3) {
+ sub_080A42E0(gSave.unk118[iVar2], uVar3);
+ }
+ }
+ }
+}
+END_NONMATCH
+
+void KinstoneMenu_080A422C(void) {
+ static const s8 gUnk_08128120[] = {
+ 16, 18, 19, 22, 25, 34, 64, 123, -64, -34, -25, -22, -19, -18,
+ -16, -18, -19, -22, -25, -34, -64, 123, 64, 34, 25, 22, 19, 0,
+ };
+
+ s32 uVar2;
+ s32 t, t2;
+ u16 t3;
+
+ uVar2 = gKinstoneMenu.unk18 / 256;
+ uVar2 %= 27;
+ t3 = uVar2;
+ sub_0805ECEC(0, gUnk_08128120[t3] << 4, 0x100, 0);
+ gOamCmd._4 = 0x100;
+ gOamCmd._6 = 0;
+ gOamCmd.y = 0x4f;
+ t = gKinstoneMenu.unk2a;
+ t2 = 0x180;
+ switch (gMenu.column_idx) {
+ case 5:
+ gOamCmd.x = 0x78;
+ sub_080A42E0(t, 0xff);
+ break;
+ case 3:
+ case 4:
+ gOamCmd.x = gKinstoneMenu.unk2c + 0x32;
+ sub_080A42E0(t, 0);
+ t2 = 0x8a - (gKinstoneMenu.unk2c * 0x12 / 0x46);
+ break;
+ case 6:
+ break;
+ default:
+ t2 = 0x8a;
+ break;
+ }
+
+ gOamCmd.x = t2;
+ sub_080A42E0(gFuseInfo._3, 0);
+}
+
+void sub_080A42E0(u32 param_1, u32 param_2) {
+ u8 uVar1;
+ s32 sVar2;
+ s32 sVar3;
+ s32 iVar4;
+
+ const struct_080C9CBC* ptr = &gUnk_080C9CBC[param_1];
+
+ if (param_2 == 0xff) {
+ uVar1 = ptr->unk2;
+ } else {
+ uVar1 = ptr->unk1;
+ }
+ iVar4 = sub_080A43A8(uVar1);
+ if ((param_2 != 0) && (param_2 != 0xff)) {
+ int index = iVar4 * 4;
+ if (param_2 != gUnk_02019EE0[iVar4].unk_02[0]) {
+ gUnk_02019EE0[iVar4].unk_02[0] = param_2;
+ sub_0801C2F0(iVar4 * 2 + 0x2e0, param_2);
+ }
+ gOamCmd._8 = (s16)(iVar4 * 2) + 0x3ae0;
+ sVar2 = gOamCmd.x;
+ sVar3 = gOamCmd.y;
+ if (gMenu.column_idx == 0) {
+ gOamCmd.x += 0x10;
+ gOamCmd.y += 9;
+ } else {
+ gOamCmd.x += 8;
+ gOamCmd.y += 10;
+ }
+ DrawDirect(0, 5);
+ gOamCmd.x = sVar2;
+ gOamCmd.y = sVar3;
+ }
+ {
+ int t;
+ t = ptr->unk0;
+ t <<= 0xc;
+ t |= 0x800;
+ t |= (iVar4 << 4) + 0x300;
+ gOamCmd._8 = t;
+ }
+ DrawDirect(0, 3);
+}
+
+void sub_080A4398(void) {
+ MemClear(&gUnk_02019EE0, sizeof(gUnk_02019EE0));
+}
+
+u32 sub_080A43A8(u32 param_1) {
+ u32 uVar1;
+
+ uVar1 = sub_080A43DC(param_1);
+ if (0xf < uVar1) {
+ uVar1 &= 0xf;
+ sub_080A4418(param_1, uVar1 * 0x10 + 0x300);
+ }
+ { int index = uVar1 * 4; }
+ gUnk_02019EE0[uVar1].unk_00[0] = param_1;
+ gUnk_02019EE0[uVar1].unk_01 = 2;
+ return uVar1;
+}
+
+u32 sub_080A43DC(u32 unk1) {
+ u32 i;
+ for (i = 0; i < 16; i++) {
+ if (unk1 == gUnk_02019EE0[i].unk_00[0]) {
+ return i;
+ }
+ }
+ for (i = 0; i < 16; i++) {
+ if (gUnk_02019EE0[i].unk_01 == 0) {
+ return i + 0x10;
+ }
+ }
+ return 0;
+}
+
+u32 sub_080A4418(u32 param_1, u32 param_2) {
+ void* src;
+ u32 t, t2;
+ void* dest;
+
+ dest = (void*)(param_2 * 0x20 + 0x6010000);
+ t = gUnk_080CA06C[param_1];
+ t2 = t & 0x80000000;
+ src = (void*)&gGlobalGfxAndPalettes[~t2 & t];
+ if (t2) {
+ LZ77UnCompVram(src, dest);
+ } else {
+ DMA3->sourceAddress = src;
+ DMA3->destinationAddress = dest;
+ DMA3->control.word = 0x84000080;
+ return DMA3->control.word;
+ }
+}
+
+void KinstoneMenu_080A4468(void) {
+ gUnk_03003DF0[0].unk[2] = 0;
+ gUnk_03003DF0[0].unk2[3] = 0;
+ sub_0801E6C8(gFuseInfo._3);
+ sub_0801E798(gKinstoneMenu.unk2a);
+}
+
+u32 KinstoneMenu_080A4494(void) {
+ struct_02036540* psVar1;
+ u8* r1;
+ u32 ret;
+
+ psVar1 = sub_0805F2C8();
+ if (psVar1 != NULL) {
+ psVar1->unk8 = gTextGfxBuffer;
+ psVar1->charColor = 0;
+ psVar1->bgColor = 5;
+ psVar1->unk1 = 0;
+ sub_080A44E0(psVar1, gUnk_02002AC0, 0x80);
+#if NON_MATCHING
+ ret = sub_080A44E0(psVar1, sub_08002632(gFuseInfo.ent) >> 0x20, 0xa0);
+#else
+ sub_08002632(gFuseInfo.ent);
+ asm("" : "=r"(r1));
+ ret = sub_080A44E0(psVar1, r1, 0xa0);
+#endif
+ sub_0805F300(psVar1);
+ }
+ return ret;
+}
+
+u32 sub_080A44E0(struct_02036540* param_1, u8* param_2, u32 param_3) {
+ u32 uVar1;
+ u32 size;
+
+ param_1->unk6 = 0;
+ param_1->unk4 = 0x60;
+ size = 0x300;
+ MemClear(param_1->unk8, size);
+ uVar1 = sub_0805F76C(param_2, param_1);
+ MemCopy(param_1->unk8, (void*)(param_3 * 0x20 + 0x6010000), size);
+ return uVar1;
+}
+
+void KinstoneMenu_080A4528(void) {
+ Entity* entity;
+
+ if (gFuseInfo.ent->kind == NPC) {
+ entity = CreateNPC(gFuseInfo.ent->id, gFuseInfo.ent->type, gFuseInfo.ent->type2);
+ } else {
+ if (gFuseInfo.ent->kind != ENEMY) {
+ return;
+ }
+ entity = CreateEnemy(gFuseInfo.ent->id, gFuseInfo.ent->type);
+ }
+ if (entity != NULL) {
+ if (entity->kind == NPC) {
+ NPCInit(entity);
+ entity->field_0xf = entity->id;
+ entity->id = 0x56;
+ } else {
+ EnemyInit(entity);
+ entity->field_0xf = entity->id;
+ entity->id = 0x66;
+ }
+ entity->x.HALF.HI = 0xcc;
+ entity->y.HALF.HI = 0x60;
+ entity->spritePriority.b1 = 2;
+ entity->spriteSettings.draw = 1;
+ entity->hitbox = NULL;
+ }
+}
diff --git a/src/menu/pause_menu.c b/src/menu/pause_menu.c
new file mode 100644
index 00000000..4213bc47
--- /dev/null
+++ b/src/menu/pause_menu.c
@@ -0,0 +1,598 @@
+#include "global.h"
+#include "menu.h"
+#include "sound.h"
+#include "subtask.h"
+#include "screen.h"
+#include "item.h"
+#include "common.h"
+#include "game.h"
+#include "main.h"
+#include "save.h"
+#include "structures.h"
+#include "functions.h"
+
+extern void sub_080A4DB8(u32);
+
+void sub_080A5128(void);
+void sub_080A51D4(void);
+u32 sub_080A51F4(void);
+void sub_080A5F48(u32, u32);
+
+extern const u8 gUnk_080FD5B4[];
+
+Subtask PauseMenu_Variant0;
+Subtask PauseMenu_Variant1;
+Subtask PauseMenu_Variant2;
+Subtask PauseMenu_Variant3;
+Subtask PauseMenu_Variant4;
+Subtask PauseMenu_Variant5;
+void Subtask_PauseMenu(void) {
+ static Subtask* const pauseMenu_Variants[] = {
+ PauseMenu_Variant0, PauseMenu_Variant1, PauseMenu_Variant2,
+ PauseMenu_Variant3, PauseMenu_Variant4, PauseMenu_Variant5,
+ };
+
+ if (gUnk_02034490.unk11 == 6) {
+ SetBgmVolume(0x100);
+ Subtask_Exit();
+ } else {
+ FlushSprites();
+ pauseMenu_Variants[gUnk_02034490.unk11]();
+ sub_080A5128();
+ sub_0801C1D4();
+ DrawOAMCmd();
+ if (gUnk_02034490.unk11 != 4) {
+ gUnk_08128A38[gUnk_02034490.unk1].func();
+ }
+ CopyOAM();
+ {
+ u32 t = gUnk_02034490.unk16;
+ u32 t2 = (t != 0) ? 0xe46 : 0;
+ gScreen.controls.layerFXControl = t2;
+ gScreen.controls.alphaBlend = (t << 8) | (0x10 - t);
+ }
+ }
+}
+
+typedef struct {
+ u8 _0;
+ u8 _1;
+ u8 _2;
+ u8 _3;
+ u8 _4;
+ u16 _6;
+} struct_08127F94;
+struct_08127F94* sub_080A6A80(u32, u32);
+
+extern u8 gUnk_02034492[];
+void sub_0801E8D4(void);
+u32 sub_0801DB94(void);
+s32 sub_080A50A0(s32);
+
+void PauseMenu_Variant0(void) {
+ struct_08127F94* ptr;
+ int r0, r1;
+
+ sub_0801E8D4();
+ sub_080A4D34();
+ r1 = 4;
+ do {
+ gUnk_02034492[r1] = 0;
+ r1++;
+ } while (r1 <= 0xd);
+ ptr = sub_080A6A80((u16)gRoomTransition.player_status.overworld_map_x,
+ (u16)gRoomTransition.player_status.overworld_map_y);
+ gUnk_02034490.unk2[4] = ptr->_4;
+ gUnk_02034490.unk2[5] = sub_0801DB94();
+ if (IsItemEquipped(ITEM_LANTERN_ON) != 2) {
+ r1 = 0x10;
+ } else {
+ r1 = 0xf;
+ }
+ gUnk_02034490.unk15 = r1;
+ r0 = gUnk_08128A38[gUnk_02034490.unk1].unk1;
+ r0 = sub_080A50A0(r0);
+ gUnk_02034490.unk1 = r0;
+ gUnk_02034490.unk14 = r0;
+ sub_080A4DB8(r0);
+ SetFade(4, 0x20);
+ sub_080A4E90(1);
+}
+
+void PauseMenu_Variant1(void) {
+ if (gFadeControl.active == 0) {
+ sub_080A4E90(2);
+ }
+}
+
+void PauseMenu_Variant2(void) {
+ int iVar1;
+ u32 uVar2;
+ int iVar4;
+ s32 bVar5;
+
+ if ((sub_080A51F4() != 0) && (gMenu.field_0xc != NULL)) {
+ iVar1 = -1;
+ switch (gInput.newKeys) {
+ case START_BUTTON:
+ iVar1 = 0;
+ break;
+ case L_BUTTON:
+ iVar1 = 1;
+ break;
+ case R_BUTTON:
+ iVar1 = 2;
+ break;
+ case B_BUTTON:
+ iVar1 = 3;
+ break;
+ }
+ if (iVar1 >= 0) {
+ switch (bVar5 = gMenu.field_0xc[iVar1]) {
+ case 0:
+ break;
+ case 4 ... 6:
+ case 0xf:
+ uVar2 = GetInventoryValue(ITEM_MAP);
+ if (uVar2 == 0) {
+ iVar4 = 1;
+ if (iVar1 == 1) {
+ iVar4 = 2;
+ }
+ bVar5 = gMenu.field_0xc[iVar4];
+ }
+ default:
+ gUnk_02034490.unk14 = bVar5;
+ SoundReq(SFX_TEXTBOX_OPEN);
+ gMenu.field_0xc = NULL;
+ break;
+ }
+ }
+ }
+ bVar5 = sub_080A50A0(gUnk_02034490.unk14);
+ if (gUnk_02034490.unk1 != bVar5) {
+ gUnk_02034490.unk14 = bVar5;
+ sub_080A51D4();
+ if (bVar5 == 0xe) {
+ sub_080A4E90(6);
+ } else {
+ sub_080A4E90(3);
+ MemClear(&gBG0Buffer, 0x800);
+ gScreen.bg0.updated = 1;
+ }
+ }
+}
+
+s32 sub_080A50A0(s32 param_1) {
+ s32 iVar1;
+
+ if (param_1 == 0xf) {
+ iVar1 = AreaHasMap();
+ param_1 = 4;
+ if (iVar1 != 0) {
+ param_1 = 5;
+ }
+ }
+ return param_1;
+}
+
+void PauseMenu_Variant3(void) {
+ s32 iVar1;
+
+ iVar1 = gUnk_02034490.unk16 + 2;
+ if (0x10 < iVar1) {
+ gScreen.lcd.displayControl &= 0xf8ff;
+ sub_080A4E90(4);
+ iVar1 = 0x10;
+ }
+ gUnk_02034490.unk16 = iVar1;
+}
+
+void PauseMenu_Variant4(void) {
+ u32 t;
+ gUnk_02034490.unk16 = 0x10;
+ gUnk_02034490.unk1 = t = gUnk_02034490.unk14;
+ sub_080A4DB8(t);
+ sub_080A4E90(5);
+}
+
+void PauseMenu_Variant5(void) {
+ s32 iVar1;
+
+ iVar1 = gUnk_02034490.unk16 - 2;
+ if (iVar1 < 0) {
+ sub_080A4E90(2);
+ iVar1 = 0;
+ }
+ gUnk_02034490.unk16 = iVar1;
+}
+
+void sub_080A5128(void) {
+ int r5, t;
+ struct {
+ int x;
+ int y;
+ } p[3];
+
+ switch (gUnk_02034490.unk1) {
+ case 7:
+ case 8:
+ p[0].x = 0x60;
+ p[0].y = 0x18;
+ p[1].x = -0x10;
+ p[1].y = 0x48;
+ p[2].x = 0x100;
+ p[2].y = 0x48;
+ break;
+ case 9:
+ case 10:
+ case 11:
+ return;
+ default:
+ p[0].x = 0x40;
+ p[0].y = 0x10 - (gUnk_02034490.unk16 << 1);
+ t = (gUnk_02034490.unk16 / 3);
+ p[1].x = 0x10 - t;
+ p[1].y = 0x48;
+ p[2].x = 0xe0 + t;
+ p[2].y = 0x48;
+ break;
+ }
+ gOamCmd._4 = 0;
+ gOamCmd._6 = 0;
+ gOamCmd._8 = 0x400;
+ gOamCmd.x = p[0].x;
+ gOamCmd.y = p[0].y;
+#ifdef EU
+ r5 = 0x1fa;
+#else
+ r5 = 0x1fb;
+#endif
+ DrawDirect(r5, 0);
+ gOamCmd.x = p[1].x;
+ gOamCmd.y = p[1].y;
+ DrawDirect(r5, 1);
+ gOamCmd.x = p[2].x;
+ gOamCmd.y = p[2].y;
+ DrawDirect(r5, 2);
+}
+
+void sub_080A51D4(void) {
+ u32 i = gUnk_02034490.unk1;
+ if (i < 0xe) {
+ gUnk_02034490.unk2[i] = gMenu.field_0x3;
+ }
+}
+
+u32 sub_080A51F4(void) {
+ u32 retval = 1;
+ if (gFadeControl.active != 0)
+ retval = 0;
+ if (gUnk_02034490.unk11 != 2)
+ retval = 0;
+ return retval;
+}
+
+typedef enum {
+ MENU_SLOT_SWORD,
+ MENU_SLOT_GUST_JAR,
+ MENU_SLOT_CANE,
+ MENU_SLOT_BOOMERANG,
+ MENU_SLOT_SHIELD,
+ MENU_SLOT_MOLE_MITTS,
+ MENU_SLOT_LANTERN,
+ MENU_SLOT_BOMBS,
+ MENU_SLOT_PEGASUS_BOOTS,
+ MENU_SLOT_ROCS_CAPE,
+ MENU_SLOT_OCARINA,
+ MENU_SLOT_BOW,
+ MENU_SLOT_BOTTLE0,
+ MENU_SLOT_BOTTLE1,
+ MENU_SLOT_BOTTLE2,
+ MENU_SLOT_BOTTLE3,
+ MENU_SLOT_SAVE_BUTTON,
+ MENU_SLOT_SAVE_BUTTON_JP,
+ MENU_SLOT_COUNT = MENU_SLOT_SAVE_BUTTON_JP
+} ItemMenuTableSlot;
+
+typedef struct {
+ u8 up;
+ u8 down;
+ u8 left;
+ u8 right;
+ u8 type;
+ u8 unk0;
+ u8 x;
+ u8 y;
+} ItemMenuTableEntry;
+
+Subtask PauseMenu_ItemMenu_Draw;
+Subtask PauseMenu_ItemMenu_Init;
+Subtask PauseMenu_ItemMenu_Update;
+void PauseMenu_ItemMenu(void) {
+ static Subtask* const pauseMenu_Types[] = { PauseMenu_ItemMenu_Init, PauseMenu_ItemMenu_Update };
+
+ pauseMenu_Types[gMenu.menuType]();
+ PauseMenu_ItemMenu_Draw();
+}
+
+void PauseMenu_ItemMenu_Init(void) {
+ static const KeyButtonLayout gUnk_08128B50 = {
+ 0xd0u,
+ 0x10u,
+ 0u,
+ 0xb8u,
+ 0x10u,
+ 0u,
+ 0xffu,
+ 0xd8u,
+ 0u,
+ {
+ 0x3u,
+ 0u,
+ 0x4u,
+ 0u,
+ 0u,
+ 0u,
+ 0x1u,
+ 0u,
+ 0xffu,
+ 0u,
+ 0u,
+ },
+ };
+
+ u32 uVar1;
+ u32 i;
+ u32 item;
+
+ gMenu.field_0xc = NULL;
+ sub_080A70AC((KeyButtonLayout*)&gUnk_08128B50);
+ for (item = ITEM_SMITH_SWORD; item < ITEM_BOTTLE_EMPTY; item++) {
+ uVar1 = GetInventoryValue(item);
+ if ((uVar1 == 1) && (i = gUnk_080FD5B4[item * 8], i <= MENU_SLOT_SAVE_BUTTON_JP)) {
+ switch (item) {
+ case ITEM_LANTERN_OFF:
+ case ITEM_LANTERN_ON:
+ item = gUnk_02034490.unk15;
+ break;
+ default:
+ break;
+ }
+ gPauseMenu.items[i] = item;
+ sub_080A5F48(item, i * 8 + 0x360);
+ }
+ }
+ SetMenuType(1);
+}
+
+const ItemMenuTableEntry gItemMenuTable[] = {
+ [MENU_SLOT_SWORD] = { MENU_SLOT_BOTTLE0, MENU_SLOT_SHIELD, MENU_SLOT_BOOMERANG, MENU_SLOT_GUST_JAR, 0x01, 0x0c,
+ 0x42, 0x33 },
+ [MENU_SLOT_GUST_JAR] = { MENU_SLOT_BOTTLE1, MENU_SLOT_MOLE_MITTS, MENU_SLOT_SWORD, MENU_SLOT_CANE, 0x01, 0x10, 0x66,
+ 0x33 },
+ [MENU_SLOT_CANE] = { MENU_SLOT_BOTTLE3, MENU_SLOT_LANTERN, MENU_SLOT_GUST_JAR, MENU_SLOT_BOOMERANG, 0x01, 0x14,
+ 0x8a, 0x33 },
+ [MENU_SLOT_BOOMERANG] = { MENU_SLOT_SAVE_BUTTON, MENU_SLOT_BOMBS, MENU_SLOT_CANE, MENU_SLOT_SWORD, 0x01, 0x15, 0xae,
+ 0x33 },
+ [MENU_SLOT_SHIELD] = { MENU_SLOT_SWORD, MENU_SLOT_PEGASUS_BOOTS, MENU_SLOT_BOMBS, MENU_SLOT_MOLE_MITTS, 0x01, 0x16,
+ 0x42, 0x4b },
+ [MENU_SLOT_MOLE_MITTS] = { MENU_SLOT_GUST_JAR, MENU_SLOT_ROCS_CAPE, MENU_SLOT_SHIELD, MENU_SLOT_LANTERN, 0x01, 0x17,
+ 0x66, 0x4b },
+ [MENU_SLOT_LANTERN] = { MENU_SLOT_CANE, MENU_SLOT_OCARINA, MENU_SLOT_MOLE_MITTS, MENU_SLOT_BOMBS, 0x01, 0x00, 0x8a,
+ 0x4b },
+ [MENU_SLOT_BOMBS] = { MENU_SLOT_BOOMERANG, MENU_SLOT_BOW, MENU_SLOT_LANTERN, MENU_SLOT_SHIELD, 0x01, 0x00, 0xae,
+ 0x4b },
+ [MENU_SLOT_PEGASUS_BOOTS] = { MENU_SLOT_SHIELD, MENU_SLOT_BOTTLE0, MENU_SLOT_BOW, MENU_SLOT_ROCS_CAPE, 0x01, 0x00,
+ 0x42, 0x63 },
+ [MENU_SLOT_ROCS_CAPE] = { MENU_SLOT_MOLE_MITTS, MENU_SLOT_BOTTLE1, MENU_SLOT_PEGASUS_BOOTS, MENU_SLOT_OCARINA, 0x01,
+ 0x00, 0x66, 0x63 },
+ [MENU_SLOT_OCARINA] = { MENU_SLOT_LANTERN, MENU_SLOT_BOTTLE3, MENU_SLOT_ROCS_CAPE, MENU_SLOT_BOW, 0x01, 0x00, 0x8a,
+ 0x63 },
+ [MENU_SLOT_BOW] = { MENU_SLOT_BOMBS, MENU_SLOT_SAVE_BUTTON, MENU_SLOT_OCARINA, MENU_SLOT_PEGASUS_BOOTS, 0x01, 0x00,
+ 0xae, 0x63 },
+ [MENU_SLOT_BOTTLE0] = { MENU_SLOT_PEGASUS_BOOTS, MENU_SLOT_SWORD, MENU_SLOT_SAVE_BUTTON, MENU_SLOT_BOTTLE1, 0x01,
+ 0x00, 0x42, 0x7b },
+ [MENU_SLOT_BOTTLE1] = { MENU_SLOT_ROCS_CAPE, MENU_SLOT_GUST_JAR, MENU_SLOT_BOTTLE0, MENU_SLOT_BOTTLE2, 0x01, 0x00,
+ 0x5a, 0x7b },
+ [MENU_SLOT_BOTTLE2] = { MENU_SLOT_ROCS_CAPE, MENU_SLOT_GUST_JAR, MENU_SLOT_BOTTLE1, MENU_SLOT_BOTTLE3, 0x01, 0x00,
+ 0x72, 0x7b },
+ [MENU_SLOT_BOTTLE3] = { MENU_SLOT_OCARINA, MENU_SLOT_CANE, MENU_SLOT_BOTTLE2, MENU_SLOT_SAVE_BUTTON, 0x01, 0x00,
+ 0x8a, 0x7b },
+ [MENU_SLOT_SAVE_BUTTON] = { MENU_SLOT_BOW, MENU_SLOT_BOOMERANG, MENU_SLOT_BOTTLE3, MENU_SLOT_BOTTLE0, 0x03, 0x00,
+ 0xb5, 0x75 },
+ [MENU_SLOT_SAVE_BUTTON_JP] = { MENU_SLOT_BOW, MENU_SLOT_BOOMERANG, MENU_SLOT_BOTTLE3, MENU_SLOT_BOTTLE0, 0x05, 0x00,
+ 0xb5, 0x75 },
+};
+
+void sub_080A6F6C(u32);
+void PauseMenu_ItemMenu_Update(void) {
+ static const u8 gUnk_08128BF4[] = { 14, 15, 2, 0 };
+ u32 item;
+ u32 menuSlot;
+ const ItemMenuTableEntry* entry;
+
+ if (sub_080A51F4()) {
+ gMenu.field_0xc = (u8*)gUnk_08128BF4;
+ menuSlot = gMenu.field_0x3;
+
+ entry = &gItemMenuTable[menuSlot];
+ switch (gInput.newKeys) {
+ case A_BUTTON:
+ if (menuSlot == MENU_SLOT_SAVE_BUTTON) {
+#if defined(DEMO_USA) || defined(DEMO_JP)
+ SoundReq(SFX_MENU_ERROR);
+#else
+ sub_080A4E84(0xb);
+ SoundReq(SFX_TEXTBOX_SELECT);
+#endif
+ break;
+ }
+ case B_BUTTON:
+ if (gPauseMenu.items[menuSlot] != 0) {
+ u32 t = !!(gInput.newKeys ^ 1);
+ ForceEquipItem(gPauseMenu.items[menuSlot], t);
+ SoundReq(SFX_TEXTBOX_SELECT);
+ }
+ break;
+ default:
+ switch (gInput.unk4) {
+ case DPAD_UP:
+ menuSlot = entry->up;
+ break;
+ case DPAD_DOWN:
+ menuSlot = entry->down;
+ break;
+ case DPAD_LEFT:
+ menuSlot = entry->left;
+ break;
+ case DPAD_RIGHT:
+ menuSlot = entry->right;
+ break;
+ }
+ break;
+ }
+ if (gMenu.field_0x3 != menuSlot) {
+ gMenu.field_0x3 = menuSlot;
+ SoundReq(SFX_TEXTBOX_CHOICE);
+ }
+ item = gPauseMenu.items[menuSlot];
+ switch (menuSlot) {
+ case MENU_SLOT_BOTTLE0:
+ case MENU_SLOT_BOTTLE1:
+ case MENU_SLOT_BOTTLE2:
+ case MENU_SLOT_BOTTLE3:
+ if (item != 0) {
+ item = gSave.saved_status.field_0x24[item - 6];
+ }
+ break;
+ case MENU_SLOT_SAVE_BUTTON:
+ // ITEM_SKILL_FAST_SPIN, but that does not make any sense at all
+ item = 0x73;
+ break;
+ default:
+ break;
+ }
+ sub_080A6F6C(item + 0x400);
+ }
+}
+
+u32 GetMenuSlotForItem(u32 item);
+extern u8* gSpriteAnimations_322[];
+#ifdef EU
+#define sub_080A5384_draw_constant0 0x1fa
+#define sub_080A5384_draw_constant1 0x141
+#else
+#define sub_080A5384_draw_constant0 0x1fb
+#define sub_080A5384_draw_constant1 0x142
+#endif
+void PauseMenu_ItemMenu_Draw(void) {
+ u32 tmp;
+ u32 i;
+ s32 color;
+ const ItemMenuTableEntry* entry;
+
+ gOamCmd._4 = 0x400;
+ gOamCmd._6 = 0;
+ gOamCmd._8 = 0;
+ for (i = 0; i < MENU_SLOT_COUNT; i++) {
+ u32 item;
+ if (gPauseMenu.items[i] != 0) {
+ entry = &gItemMenuTable[i];
+ gOamCmd.x = entry->x;
+ gOamCmd.y = entry->y;
+ item = gPauseMenu.items[i];
+ switch (item) {
+ case ITEM_BOTTLE1:
+ case ITEM_BOTTLE2:
+ case ITEM_BOTTLE3:
+ case ITEM_BOTTLE4:
+ item = gSave.stats.bottles[item - ITEM_BOTTLE1];
+ break;
+ default:
+ break;
+ }
+ color = 3;
+ switch (item) {
+ case ITEM_BOMBS:
+ case ITEM_REMOTE_BOMBS:
+ if (gBombBagSizes[gSave.stats.bombBagType] <= gSave.stats.bombCount) {
+ color = 4;
+ }
+ break;
+ case ITEM_BOW:
+ case ITEM_LIGHT_ARROW:
+ if (gQuiverSizes[gSave.stats.quiverType] <= gSave.stats.arrowCount) {
+ color = 4;
+ }
+ break;
+ default:
+ break;
+ }
+ gOamCmd._8 = 0x800 | color << 0xc | ((i * 8) + 0x360);
+ DrawDirect(sub_080A5384_draw_constant1, *gSpriteAnimations_322[item]);
+ }
+ }
+ gOamCmd._8 = 0x800;
+ {
+ u32 slot = gMenu.field_0x3;
+ if ((slot == MENU_SLOT_SAVE_BUTTON) && (gSaveHeader->language != 0)) {
+ slot = MENU_SLOT_SAVE_BUTTON_JP;
+ }
+ entry = &gItemMenuTable[slot];
+ gOamCmd.x = entry->x;
+ gOamCmd.y = entry->y;
+ tmp = entry->type + ((gMain.ticks.HWORD & 0x10) != 0 ? 3 : 4);
+ DrawDirect(sub_080A5384_draw_constant0, tmp);
+ }
+ {
+ u32 slot;
+ if (gSaveHeader->language != 0) {
+ slot = MENU_SLOT_SAVE_BUTTON;
+ } else {
+ slot = MENU_SLOT_SAVE_BUTTON_JP;
+ }
+ entry = &gItemMenuTable[slot];
+ gOamCmd.x = entry->x;
+ gOamCmd.y = entry->y;
+ gOamCmd._8 = 0x800;
+ DrawDirect(sub_080A5384_draw_constant0, 0x22);
+ }
+ i = GetMenuSlotForItem(gSave.stats.itemButtons[0]);
+ if (i < MENU_SLOT_COUNT) {
+ entry = &gItemMenuTable[i];
+ gOamCmd.x = entry->x;
+ gOamCmd.y = entry->y;
+ DrawDirect(sub_080A5384_draw_constant0, 3);
+ }
+ i = GetMenuSlotForItem(gSave.stats.itemButtons[1]);
+ if (i < MENU_SLOT_COUNT) {
+ entry = &gItemMenuTable[i];
+ gOamCmd.x = entry->x;
+ gOamCmd.y = entry->y;
+ DrawDirect(sub_080A5384_draw_constant0, 3);
+ }
+}
+
+u32 GetMenuSlotForItem(u32 item) {
+ u32 i;
+
+ if (item != 0) {
+ for (i = 0; i < MENU_SLOT_COUNT; i++) {
+ if (item == gPauseMenu.items[i])
+ return i;
+ }
+ }
+ return MENU_SLOT_SAVE_BUTTON_JP;
+}
+
+Subtask sub_080A5594;
+Subtask sub_080A56A0;
+void PauseMenu2(void) {
+ static Subtask* const pauseMenu2_Types[] = {
+ sub_080A5594,
+ sub_080A56A0,
+ };
+ pauseMenu2_Types[gMenu.menuType]();
+ sub_080A57F4();
+}
diff --git a/src/npc/npc23.c b/src/npc/npc23.c
index c4a9399c..9630e18a 100644
--- a/src/npc/npc23.c
+++ b/src/npc/npc23.c
@@ -49,7 +49,7 @@ void sub_08066358(Entity* this) {
}
this->speed = 0x80;
this->cutsceneBeh.HWORD = 1;
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
sub_080788E0(this);
}
} else {
@@ -96,7 +96,7 @@ void sub_0806643C(Entity* this) {
void sub_08066474(void) {
if (gPlayerEntity.action != PLAYER_080720DC) {
- gUnk_02034490[0] = 0;
+ gUnk_02034490.unk0 = 0;
}
}
diff --git a/src/object/cloud.c b/src/object/cloud.c
index 37899c33..dcf64e9b 100644
--- a/src/object/cloud.c
+++ b/src/object/cloud.c
@@ -33,7 +33,7 @@ void sub_0809F514(Entity* this) {
this->spriteSettings.draw = 0;
this->field_0x68.HALF.LO = 12;
gRoomControls.camera_target = this;
- gUnk_02034490[0] = 255;
+ gUnk_02034490.unk0 = 255;
sub_0809F7BC(this);
}
diff --git a/src/object/fileScreenObjects.c b/src/object/fileScreenObjects.c
index d2af86c9..f68a531d 100644
--- a/src/object/fileScreenObjects.c
+++ b/src/object/fileScreenObjects.c
@@ -219,7 +219,7 @@ void sub_0808EABC(Entity* this) {
}
break;
case 5:
- switch (gMenu.focusCoords[this->type]) {
+ switch (gGenericMenu.unk10.a[this->type]) {
case 0:
var0 = 42;
var1 = 40;
@@ -228,7 +228,7 @@ void sub_0808EABC(Entity* this) {
case 2:
var0 = 20;
var1 = 144;
- var1 -= (gMenu.unk16 - gMenu.focusCoords[this->type]) * 32;
+ var1 -= (gGenericMenu.unk16 - gGenericMenu.unk10.a[this->type]) * 32;
break;
}
break;
@@ -371,9 +371,9 @@ void sub_0808ECBC(Entity* this) {
void sub_0808ED64(Entity* this) {
int y = 255;
- if (gUnk_02032EC0.lastState == 1 && gMenu.focusCoords[1] != 5) {
- this->x.HALF.HI = gMenu.focusCoords[0] * 16 + 28;
- y = gMenu.focusCoords[1] * 16 + 58;
+ if (gUnk_02032EC0.lastState == 1 && gGenericMenu.unk10.a[1] != 5) {
+ this->x.HALF.HI = gGenericMenu.unk10.a[0] * 16 + 28;
+ y = gGenericMenu.unk10.a[1] * 16 + 58;
}
this->y.HALF.HI = y;
}
@@ -384,7 +384,7 @@ void sub_0808ED98(Entity* this) {
this->field_0x68.HWORD = 27;
y = -10;
} else {
- u32 var0 = gMenu.unk13;
+ u32 var0 = gGenericMenu.unk10.a[3];
if (var0 > 5) {
var0 = 5;
}
@@ -416,7 +416,7 @@ void sub_0808EE00(Entity* this) {
}
this->field_0x6a.HWORD = var2;
- this->palette.b.b0 = gMenu.focusCoords[1] == 5 && var1 == gMenu.field_0x12 ? 11 : 9;
+ this->palette.b.b0 = gGenericMenu.unk10.a[1] == 5 && var1 == gGenericMenu.unk10.a[2] ? 11 : 9;
gUnk_02019EE0.isTransitioning |= sub_0808EF6C(this);
}
diff --git a/src/objectUtils.c b/src/objectUtils.c
index ab1bc5a0..745bd0fd 100644
--- a/src/objectUtils.c
+++ b/src/objectUtils.c
@@ -24,7 +24,7 @@ Entity* sub_080A276C(Entity* parent, u32 type, u32 type2) {
PrependEntityToList(e, 6);
CopyPosition(&gPlayerEntity, e);
gPriorityHandler.sys_priority = 6;
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
e->field_0x68.HALF.HI = gPlayerEntity.flags;
e->field_0x68.HALF.LO = gPlayerEntity.spriteSettings.draw;
e->field_0x6a.HALF.LO = gPlayerEntity.iframes;
diff --git a/src/player.c b/src/player.c
index d118728e..37376999 100644
--- a/src/player.c
+++ b/src/player.c
@@ -323,7 +323,7 @@ extern u16 script_BedAtSimons;
extern ScriptExecutionContext gPlayerScriptExecutionContext;
NONMATCH("asm/non_matching/playerItemPacciCane/CheckPlayerInactive.inc", u32 CheckPlayerInactive(void)) {
- if (!((gInput.newKeys & START_BUTTON) == 0 || gFadeControl.active || gUnk_02034490[0] ||
+ if (!((gInput.newKeys & START_BUTTON) == 0 || gFadeControl.active || gUnk_02034490.unk0 ||
(gMessage.doTextBox & 0x7F) || gSave.stats.health == 0 || !gSave.fillerD0[34] ||
gPlayerState.controlMode != CONTROL_ENABLED || gPriorityHandler.priority_timer != 0)) {
u32 tmp = gPlayerState.framestate ? gPlayerState.framestate : gPlayerState.framestate_last;
@@ -1143,7 +1143,7 @@ static void PortalStandUpdate(Entity* this) {
static void PortalActivateInit(Entity* this) {
gRoomControls.camera_target = NULL;
- gUnk_02034490[0] = 1;
+ gUnk_02034490.unk0 = 1;
this->subAction = 3;
this->field_0xf = 0x1e;
gPlayerState.animation = 0x738;
@@ -1226,7 +1226,7 @@ static void sub_080717F8(Entity* this) {
this->x.HALF.HI = gArea.curPortalX + sOffsets[gArea.curPortalExitDirection * 2];
this->y.HALF.HI = gArea.curPortalY + sOffsets[gArea.curPortalExitDirection * 2 + 1];
gArea.unk1A = 0xb4;
- gUnk_02034490[0] = 0;
+ gUnk_02034490.unk0 = 0;
this->action = PLAYER_MINISH;
this->subAction = 0;
gPlayerState.flags = (gPlayerState.flags & ~PL_USE_PORTAL) | PL_MINISH;
diff --git a/src/playerItem/playerItemPacciCane.c b/src/playerItem/playerItemPacciCane.c
index 3a6f533c..3f797d84 100644
--- a/src/playerItem/playerItemPacciCane.c
+++ b/src/playerItem/playerItemPacciCane.c
@@ -4,13 +4,12 @@
#include "common.h"
#include "message.h"
#include "save.h"
+#include "structures.h"
extern void (*const gUnk_0811B9D8[])(Entity*);
void sub_080704FC(Entity*);
-extern u8 gUnk_02034490[0x18];
-
void PlayerItemPacciCane(Entity* this) {
gUnk_0811B9D8[this->action](this);
}
@@ -25,6 +24,7 @@ void sub_080704D4(Entity* this) {
ASM_FUNC("asm/non_matching/playerItemPacciCane/sub_080704FC.inc", void sub_080704FC(Entity* this))
+// TODO This name sounds like this does not belong in this file
void ClearMenuSavestate(void) {
- MemClear(gUnk_02034490, sizeof(gUnk_02034490));
+ MemClear(&gUnk_02034490, sizeof(gUnk_02034490));
}
diff --git a/src/script.c b/src/script.c
index fed1f183..6c837afd 100644
--- a/src/script.c
+++ b/src/script.c
@@ -450,11 +450,11 @@ void sub_0807DF28(void) {
void sub_0807DF38(void) {
gUnk_0200AF00.filler0[1] = 0xff;
- gUnk_02034490[0] = 0xff;
+ gUnk_02034490.unk0 = 0xff;
}
void sub_0807DF50(void) {
- gUnk_02034490[0] = 0;
+ gUnk_02034490.unk0 = 0;
gUnk_0200AF00.filler0[1] = 0;
RecoverUI(0);
ResetPlayerAnimationAndAction();
@@ -1158,7 +1158,7 @@ void ScriptCommand_0807E9F0(Entity* entity, ScriptExecutionContext* context) {
switch (gFuseInfo._0) {
case 2:
gPlayerState.controlMode = CONTROL_DISABLED;
- gUnk_02034490[0] = tmp;
+ gUnk_02034490.unk0 = tmp;
context->condition = tmp;
break;
case 1:
diff --git a/src/subtask.c b/src/subtask.c
deleted file mode 100644
index f73b719f..00000000
--- a/src/subtask.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "global.h"
-#include "functions.h"
-#include "menu.h"
-#include "screen.h"
-#include "common.h"
-#include "subtask.h"
-
-extern void (*const gUnk_081280C4[])(void);
-
-void Subtask_KinstoneMenu(void) {
-#if !(defined(DEMO_USA) || defined(DEMO_JP))
- gRoomTransition.player_status.field_0x24[8] = 2;
- FlushSprites();
- gUnk_081280C4[gMenu.menuType]();
- sub_080A3B74();
- sub_080A4054();
- sub_0801C1D4();
- DrawOAMCmd();
- UpdateEntities();
- DrawEntities();
- CopyOAM();
- gRoomTransition.player_status.field_0x24[8] = 0;
-#endif
-}
-
-extern void gUnk_081280DC;
-
-void sub_080A3BD0(void) {
- s32 iVar1;
- s32 iVar2;
-
- gMenu.column_idx = 1;
- gMenu.unk2a = 0;
- sub_080A4D34();
- LoadPaletteGroup(0xcb);
- LoadGfxGroup(0x75);
-
- iVar1 = sub_080A4494();
- iVar2 = iVar1 + 7;
- if (iVar2 < 0) {
- iVar2 += 0x7;
- }
-
- iVar1 = (iVar2 >> 3) - 6;
- iVar1 = max(iVar1, 0);
- iVar1 = min(iVar1, 6);
-
- LoadGfxGroup(iVar1 + 0x76);
- gScreen.lcd.displayControl |= 0x1e00;
- gScreen.bg1.control = 0x1c01;
- gScreen.bg2.control = 0x1d02;
- gScreen.bg3.control = 0x1e0b;
- gScreen.bg1.updated = 1;
- gScreen.bg2.updated = 1;
- gScreen.bg3.updated = 1;
- sub_080A4528();
- sub_080A4398();
- sub_0801E738(0);
- sub_080A70AC(&gUnk_081280DC);
- sub_080A7114(1);
- SetFade(6, 8);
-}
diff --git a/src/subtask2.c b/src/subtask2.c
deleted file mode 100644
index dffcbab0..00000000
--- a/src/subtask2.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "global.h"
-#include "menu.h"
-#include "functions.h"
-
-extern void (*const gUnk_08128BF8[])(void);
-
-extern u8 gUnk_02000090;
-
-u32 sub_080A554C(u32 arg0) {
- u32 i;
-
- if (arg0 != 0) {
- for (i = 0; i < 17; i++) {
- if (arg0 == gMenu.focusCoords[i])
- return i;
- }
- }
- return 17;
-}
-
-void sub_080A5574(void) {
- gUnk_08128BF8[gMenu.menuType]();
- sub_080A57F4();
-}