From 3855f2f0d07051db75440a941c117931f8a86abd Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 12:18:04 +0100 Subject: [PATCH 01/14] remove fake global gUnk_020344F0 part of gBG2Buffer --- asm/src/veneer.s | 4 ++-- linker.ld | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/asm/src/veneer.s b/asm/src/veneer.s index 42a0af6b..254eb81b 100644 --- a/asm/src/veneer.s +++ b/asm/src/veneer.s @@ -27,7 +27,7 @@ _08000126: cmp r0, #0 beq _08000136 ldr r0, _080001FC @ =gMapDataTopSpecial - ldr r1, _08000200 @ =gUnk_020344F0 + ldr r1, _08000200 @ =gBG2Buffer+0x40 bl _call_via_r4 _08000136: pop {r4, pc} @@ -127,7 +127,7 @@ _080001F0: .4byte gMapDataBottomSpecial _080001F4: .4byte gUnk_02021F70 _080001F8: .4byte gMapTop _080001FC: .4byte gMapDataTopSpecial -_08000200: .4byte gUnk_020344F0 +_08000200: .4byte gBG2Buffer+0x40 _08000204: .4byte gUnk_08000248 _08000208: .4byte gUnk_08000228 _0800020C: .4byte 0x00004000 diff --git a/linker.ld b/linker.ld index 50a77389..e9819af8 100644 --- a/linker.ld +++ b/linker.ld @@ -90,7 +90,6 @@ SECTIONS { . = 0x00034492; gUnk_02034492 = .; . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; - . = 0x000344F0; gUnk_020344F0 = .; . = 0x00034CB0; gBG0Buffer = .; . = 0x00034CF0; gUnk_02034CF0 = .; . = 0x00034D30; gUnk_02034D30 = .; From 33a62419a98cf6c31c7b421c20fae554f500de5b Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 12:24:00 +0100 Subject: [PATCH 02/14] remove fake global gUnk_02021F70 part of gBG1Buffer --- asm/src/veneer.s | 4 ++-- linker.ld | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/asm/src/veneer.s b/asm/src/veneer.s index 254eb81b..c3fc5da8 100644 --- a/asm/src/veneer.s +++ b/asm/src/veneer.s @@ -19,7 +19,7 @@ UpdateScrollVram: @ 0x08000108 cmp r0, #0 beq _08000126 ldr r0, _080001F0 @ =gMapDataBottomSpecial - ldr r1, _080001F4 @ =gUnk_02021F70 + ldr r1, _080001F4 @ =gBG1Buffer+0x40 bl _call_via_r4 _08000126: ldr r0, _080001F8 @ =gMapTop @@ -124,7 +124,7 @@ GetTileIndex: @ 0x080001DA _080001E8: .4byte gUpdateVisibleTiles _080001EC: .4byte gMapBottom _080001F0: .4byte gMapDataBottomSpecial -_080001F4: .4byte gUnk_02021F70 +_080001F4: .4byte gBG1Buffer+0x40 _080001F8: .4byte gMapTop _080001FC: .4byte gMapDataTopSpecial _08000200: .4byte gBG2Buffer+0x40 diff --git a/linker.ld b/linker.ld index e9819af8..5cb7ac0a 100644 --- a/linker.ld +++ b/linker.ld @@ -56,7 +56,6 @@ SECTIONS { . = 0x00021F00; gUnk_02021F00 = .; . = 0x00021F20; gUnk_02021F20 = .; . = 0x00021F30; gBG1Buffer = .; - . = 0x00021F70; gUnk_02021F70 = .; . = 0x00022030; gUnk_02022030 = .; . = 0x00022130; gUnk_02022130 = .; . = 0x00022730; gVBlankDMA = .; From 08de04a87b042a2a9effb5109399a86eef2a2620 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 12:26:49 +0100 Subject: [PATCH 03/14] remove fake global gUnk_02022030 part of gBG1Buffer --- include/fileselect.h | 1 - linker.ld | 1 - src/fileselect.c | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/fileselect.h b/include/fileselect.h index 29923481..9c17bad7 100644 --- a/include/fileselect.h +++ b/include/fileselect.h @@ -69,6 +69,5 @@ extern void (*const gUnk_080FC908[])(void); extern const u8 gGlobalGfxAndPalettes[]; extern u32 gUsedPalettes; extern u8 gTextGfxBuffer[]; -extern u8 gUnk_02022030; #endif // FILESELECT_H \ No newline at end of file diff --git a/linker.ld b/linker.ld index 5cb7ac0a..bf6e36d5 100644 --- a/linker.ld +++ b/linker.ld @@ -56,7 +56,6 @@ SECTIONS { . = 0x00021F00; gUnk_02021F00 = .; . = 0x00021F20; gUnk_02021F20 = .; . = 0x00021F30; gBG1Buffer = .; - . = 0x00022030; gUnk_02022030 = .; . = 0x00022130; gUnk_02022130 = .; . = 0x00022730; gVBlankDMA = .; . = 0x00022740; gFuseInfo = .; diff --git a/src/fileselect.c b/src/fileselect.c index 5324661c..d41126f6 100644 --- a/src/fileselect.c +++ b/src/fileselect.c @@ -1359,7 +1359,7 @@ void sub_0805144C(void) { void sub_08051458(void) { sub_080503A8(gMenu.column_idx + 9); - MemCopy(gBG3Buffer + 0x80, &gUnk_02022030, 0x400); + MemCopy(&gBG3Buffer[0x80], &gBG1Buffer[0x80], 0x400); } u32 sub_080514BC(u32); From a37c48285004ab4fd1152b3f1ff80562879b4cb6 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 12:28:49 +0100 Subject: [PATCH 04/14] remove fake global gUnk_02022130 part of gBG1Buffer --- linker.ld | 1 - src/subtask.c | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/linker.ld b/linker.ld index bf6e36d5..823bcba3 100644 --- a/linker.ld +++ b/linker.ld @@ -56,7 +56,6 @@ SECTIONS { . = 0x00021F00; gUnk_02021F00 = .; . = 0x00021F20; gUnk_02021F20 = .; . = 0x00021F30; gBG1Buffer = .; - . = 0x00022130; gUnk_02022130 = .; . = 0x00022730; gVBlankDMA = .; . = 0x00022740; gFuseInfo = .; . = 0x00022750; gPlayerScriptExecutionContext = .; diff --git a/src/subtask.c b/src/subtask.c index 054d0c05..a08de5b4 100644 --- a/src/subtask.c +++ b/src/subtask.c @@ -97,11 +97,10 @@ void sub_080A6FB4(u32 param_1, u32 param_2) { void sub_080A7040(u32 param_1) { extern Font gUnk_08129004; - extern u8 gUnk_02022130[]; if (gGenericMenu.unk2e.HWORD != param_1) { gGenericMenu.unk2e.HWORD = param_1; - MemClear(gUnk_02022130, 0x300); - MemCopy(gUnk_02022130 - 0x200, (void*)0x600e000, 0x800); + MemClear(&gBG1Buffer[0x100], 0x300); + MemCopy(gBG1Buffer, (void*)0x600e000, 0x800); if (GetInventoryValue(gUnk_08128D70[param_1].item) != 0) { ShowTextBox(gUnk_08128D70[param_1].textIndex, &gUnk_08129004); } From 7228a0387484076276d61692c8bbf6485883b777 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 13:59:22 +0100 Subject: [PATCH 05/14] remove fake global gUnk_02034CF0 part of gBG0Buffer --- linker.ld | 2 +- src/ui.c | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/linker.ld b/linker.ld index 823bcba3..f3bf8c18 100644 --- a/linker.ld +++ b/linker.ld @@ -88,7 +88,6 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x00034CF0; gUnk_02034CF0 = .; . = 0x00034D30; gUnk_02034D30 = .; . = 0x00034DF0; gUnk_02034DF0 = .; . = 0x00034E4E; gUnk_02034E4E = .; @@ -97,6 +96,7 @@ SECTIONS { . = 0x000350F0; gUnk_020350F0 = .; . = 0x0003510E; gUnk_0203510E = .; . = 0x00035160; gUnk_02035160 = .; + . = 0x000354B0; gUnk_020354B0 = .; . = 0x000354B4; gManagerCount = .; . = 0x000354C0; gUnk_020354C0 = .; diff --git a/src/ui.c b/src/ui.c index a7834601..5c683e84 100644 --- a/src/ui.c +++ b/src/ui.c @@ -38,8 +38,6 @@ typedef struct { u8 unk_18[40]; } struct_02034CF0; -extern struct_02034CF0 gUnk_02034CF0[]; - typedef struct { struct_02034CF0 unk_0; struct_02034CF0 unk_40; @@ -352,7 +350,7 @@ void DrawDigits(u32 iconVramIndex, u32 count, u32 isTextYellow, u32 digits) { } void sub_0801C66C(void) { - struct_02034CF0* ptr; + u32* ptr; s32 index; if (gUnk_0200AF00.unk_2 != 0) { @@ -362,15 +360,15 @@ void sub_0801C66C(void) { } else { index = 1; } - ptr = gUnk_02034CF0; + ptr = (u32*)&gBG0Buffer[0x20]; do { - ptr->unk_0 = 0; - ptr->unk_4 = 0; - ptr->unk_8 = 0; - ptr->unk_c = 0; - ptr->unk_10 = 0; - ptr->unk_14 = 0; - ptr++; + ptr[0] = 0; + ptr[1] = 0; + ptr[2] = 0; + ptr[3] = 0; + ptr[4] = 0; + ptr[5] = 0; + ptr += 0x10; index--; } while (index > 0); gScreen.bg0.updated = 1; @@ -381,10 +379,8 @@ void DrawHearts(void) { s32 health; s32 uVar1; s32 uVar2; - s32 uVar4; u32 uVar6; s32 maxHealth; - const u16* ptr; s32 tmp1; u16* ptr2; @@ -456,7 +452,7 @@ void DrawHearts(void) { *ptr2 = 0xf010; DmaSet(3, gUnk_080C8F2C + (10 - uVar6), ptr2 + 1, (uVar1 - 10) | 0x80000000); } - ptr2 = (u16*)&gUnk_02034CF0[0].unk_0; + ptr2 = &gBG0Buffer[0x20]; *ptr2 = 0xf010; DmaSet(3, gUnk_080C8F2C + (10 - tmp1), ptr2 + 1, maxHealth | 0x80000000); From ba7b5dbccd045c32835d2aafbb1b0b397c5004dd Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 14:13:40 +0100 Subject: [PATCH 06/14] remove fake global gUnk_02034D30 part of gBG0Buffer --- linker.ld | 1 - src/ui.c | 41 ++++++++++++----------------------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/linker.ld b/linker.ld index f3bf8c18..d3c71a45 100644 --- a/linker.ld +++ b/linker.ld @@ -88,7 +88,6 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x00034D30; gUnk_02034D30 = .; . = 0x00034DF0; gUnk_02034DF0 = .; . = 0x00034E4E; gUnk_02034E4E = .; . = 0x0003508E; gUnk_0203508E = .; diff --git a/src/ui.c b/src/ui.c index 5c683e84..6ef01a1c 100644 --- a/src/ui.c +++ b/src/ui.c @@ -28,23 +28,6 @@ typedef struct { } struct_02035160; extern struct_02035160 gUnk_02035160; -typedef struct { - u32 unk_0; - u32 unk_4; - u32 unk_8; - u32 unk_c; - u32 unk_10; - u32 unk_14; - u8 unk_18[40]; -} struct_02034CF0; - -typedef struct { - struct_02034CF0 unk_0; - struct_02034CF0 unk_40; -} struct_02034D30; - -extern struct_02034D30 gUnk_02034D30; - typedef struct { u16 unk_0; u16 unk_2; @@ -448,7 +431,7 @@ void DrawHearts(void) { } if (uVar1 - 10 > 0) { - ptr2 = (u16*)&gUnk_02034D30; + ptr2 = &gBG0Buffer[0x40]; *ptr2 = 0xf010; DmaSet(3, gUnk_080C8F2C + (10 - uVar6), ptr2 + 1, (uVar1 - 10) | 0x80000000); } @@ -469,21 +452,21 @@ void DrawHearts(void) { } void sub_0801C824(void) { - struct_02034CF0* ptr; + u32* ptr; if (gUnk_0200AF00.unk_6 != 0) { gUnk_0200AF00.unk_6 = 0; - if (gUnk_0200AF00.maxHealth > 4 * 10) { - ptr = &gUnk_02034D30.unk_40; // Show second row of hearts + if (gUnk_0200AF00.maxHealth > 10 * 4) { + ptr = (u32*)&gBG0Buffer[0x60]; // Show second row of hearts } else { - ptr = &gUnk_02034D30.unk_0; + ptr = (u32*)&gBG0Buffer[0x40]; } - ptr->unk_0 = 0; - ptr->unk_4 = 0; - ptr->unk_8 = 0; - ptr->unk_c = 0; - ptr->unk_10 = 0; - ptr->unk_14 = 0; + ptr[0] = 0; + ptr[1] = 0; + ptr[2] = 0; + ptr[3] = 0; + ptr[4] = 0; + ptr[5] = 0; gScreen.bg0.updated = 1; } } @@ -504,7 +487,7 @@ void DrawChargeBar(void) { if (!tmp1) return sub_0801C824(); - ptr1 = (gUnk_0200AF00.maxHealth > 0x28) ? (u16*)((u8*)(&gUnk_02034D30) + 0x40) : (u16*)&gUnk_02034D30.unk_0; + ptr1 = (gUnk_0200AF00.maxHealth > 10 * 4) ? &gBG0Buffer[0x60] : &gBG0Buffer[0x40]; tmp2 = Div(gPlayerState.chargeState.chargeTimer + 19, 20); if (tmp2 > 40) { From 0b0f469f7ac55d6ab5013d6e317b7e69afeb450a Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 14:17:24 +0100 Subject: [PATCH 07/14] remove fake global gUnk_02034DF0 part of gBG0Buffer --- linker.ld | 1 - src/manager/enterRoomTextboxManager.c | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/linker.ld b/linker.ld index d3c71a45..a0abba56 100644 --- a/linker.ld +++ b/linker.ld @@ -88,7 +88,6 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x00034DF0; gUnk_02034DF0 = .; . = 0x00034E4E; gUnk_02034E4E = .; . = 0x0003508E; gUnk_0203508E = .; . = 0x000350E2; gUnk_020350E2 = .; diff --git a/src/manager/enterRoomTextboxManager.c b/src/manager/enterRoomTextboxManager.c index 59f31e2f..959e90f9 100644 --- a/src/manager/enterRoomTextboxManager.c +++ b/src/manager/enterRoomTextboxManager.c @@ -13,8 +13,6 @@ #include "message.h" #include "screen.h" -extern u8 gUnk_02034DF0[0x2F2]; - const u16 gUnk_08108DE8[] = { 0, 0x70b, 0x70c, 0x70d, 0x70e, 0x70f, 0x710, 0x711, 0x712, 0x713, 0x714, 0x715, 0x716, 0x717, 0x718, 0x719, 0x71a, 0x71b, 0x71c, 0x71d, 0x71e, 0x71f, 0x726, 0x720, 0x720, 0x721, 0x722, 0x723, 0x725, 0x727, 0x724, 0x728 }; @@ -67,7 +65,7 @@ void sub_0805E18C(EnterRoomTextboxManager* this) { } void sub_0805E1D8(EnterRoomTextboxManager* this) { - MemClear(&gUnk_02034DF0, 0x80); + MemClear(&gBG0Buffer[0xa0], 0x80); gScreen.bg0.updated = 1; DeleteThisEntity(); } @@ -80,7 +78,7 @@ void sub_0805E1F8(u32 unk0, bool32 isDungeon) { u8 unk_06[3]; } PACKED tmp; const Font* font; - MemClear(&gUnk_02034DF0, 0x80); + MemClear(&gBG0Buffer[0xa0], 0x80); MemCopy(gUnk_08108E60, &tmp, sizeof(tmp)); tmp.unk_04 = unk0 >> 8; tmp.unk_05 = unk0; From 4fd8013c8d13b12ecb0f90dd801bff7b5ac97ab3 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 14:37:58 +0100 Subject: [PATCH 08/14] remove fake global gUnk_02034E4E part of gBG0Buffer --- linker.ld | 1 - src/fileselect.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/linker.ld b/linker.ld index a0abba56..1b3e0e70 100644 --- a/linker.ld +++ b/linker.ld @@ -88,7 +88,6 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x00034E4E; gUnk_02034E4E = .; . = 0x0003508E; gUnk_0203508E = .; . = 0x000350E2; gUnk_020350E2 = .; . = 0x000350F0; gUnk_020350F0 = .; diff --git a/src/fileselect.c b/src/fileselect.c index d41126f6..7676d0e1 100644 --- a/src/fileselect.c +++ b/src/fileselect.c @@ -210,9 +210,8 @@ const struct_080FC3E4 gUnk_080FC3E4[] = { { 0, 0xffff, 0, 1 }, }; -extern u16 gUnk_02034E4E[]; const Font gUnk_080FC844 = { - gUnk_02034E4E, BG_TILE_ADDR(0x198), gTextGfxBuffer, 0, 96, 224, 1, 1, 0, 1, 3, 0, 0, 1, 0 + &gBG0Buffer[0xcf], BG_TILE_ADDR(0x198), gTextGfxBuffer, 0, 96, 224, 1, 1, 0, 1, 3, 0, 0, 1, 0 }; const u16 gUnk_080FC85C[][3] = { From eb60063cdebe122ee682e4eaad3cb0fe0a9bae2c Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 14:40:07 +0100 Subject: [PATCH 09/14] remove fake global gUnk_0203508E part of gBG0Buffer --- linker.ld | 1 - src/demo.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/linker.ld b/linker.ld index 1b3e0e70..8fdd5f06 100644 --- a/linker.ld +++ b/linker.ld @@ -88,7 +88,6 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x0003508E; gUnk_0203508E = .; . = 0x000350E2; gUnk_020350E2 = .; . = 0x000350F0; gUnk_020350F0 = .; . = 0x0003510E; gUnk_0203510E = .; diff --git a/src/demo.c b/src/demo.c index 36bde8b3..5ab9dfca 100644 --- a/src/demo.c +++ b/src/demo.c @@ -30,7 +30,6 @@ extern u8 gUnk_08A05751[]; // sprite_table extern void gUnk_089FD1B4; extern void gUnk_089FD2F4; -extern u16 gUnk_0203508E[]; extern u16 gUnk_0203510E[]; extern u8 gUnk_08A068BF[129]; @@ -190,7 +189,7 @@ void sub_080A30AC(void) { void sub_080A3198(u32 param_1, u32 param_2) { static const Font gUnk_08127C98[] = { - { gUnk_0203508E, BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x1080, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, + { &gBG0Buffer[0x1ef], BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x1080, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, { gUnk_0203510E, BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x80, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, }; static const u16 gUnk_08127CC8[4] = { From 7f25b35c2dcb62e389a1ead1afe855de6e781155 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 14:50:59 +0100 Subject: [PATCH 10/14] remove fake global gUnk_020350E2 part of gBG0Buffer --- linker.ld | 1 - src/ui.c | 56 +++++++++++++++++++++---------------------------------- 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/linker.ld b/linker.ld index 8fdd5f06..d7b764cd 100644 --- a/linker.ld +++ b/linker.ld @@ -88,7 +88,6 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x000350E2; gUnk_020350E2 = .; . = 0x000350F0; gUnk_020350F0 = .; . = 0x0003510E; gUnk_0203510E = .; . = 0x00035160; gUnk_02035160 = .; diff --git a/src/ui.c b/src/ui.c index 6ef01a1c..4423a0c6 100644 --- a/src/ui.c +++ b/src/ui.c @@ -28,20 +28,6 @@ typedef struct { } struct_02035160; extern struct_02035160 gUnk_02035160; -typedef struct { - u16 unk_0; - u16 unk_2; - u16 unk_4; - u16 unk_6; - u8 pad[56]; -} substruct_0E2; - -typedef struct { - substruct_0E2 unk_0[2]; -} struct_020350E2; - -extern struct_020350E2 gUnk_020350E2; - extern const u16 gUnk_080C8F2C[]; extern u32 gUnk_085C4620[]; extern Frame* gSpriteAnimations_322[]; @@ -527,38 +513,38 @@ void DrawChargeBar(void) { void DrawKeys(void) { s32 iVar1; - substruct_0E2* ptr1; - substruct_0E2* ptr2; + u16* ptr1; + u16* ptr2; u32 temp; if (!(((gUnk_0200AF00.unk_1 & 0x80) == 0) && (AreaHasKeys()))) { if (gUnk_0200AF00.unk_10 != 0) { gUnk_0200AF00.unk_10 = 0; - ptr1 = &gUnk_020350E2.unk_0[0]; - ptr1->unk_0 = 0; - ptr1->unk_2 = 0; - ptr1->unk_4 = 0; - ptr1->unk_6 = 0; - gUnk_020350E2.unk_0[1].unk_0 = 0; - gUnk_020350E2.unk_0[1].unk_2 = 0; - gUnk_020350E2.unk_0[1].unk_4 = 0; - gUnk_020350E2.unk_0[1].unk_6 = 0; + ptr1 = &gBG0Buffer[0x219]; + ptr1[0] = 0; + ptr1[1] = 0; + ptr1[2] = 0; + ptr1[3] = 0; + ptr1[0x20] = 0; + ptr1[0x21] = 0; + ptr1[0x22] = 0; + ptr1[0x23] = 0; gScreen.bg0.updated = 1; } } else { if (gUnk_0200AF00.unk_10 == 0) { - ptr1 = &gUnk_020350E2.unk_0[0]; - ptr2 = &gUnk_020350E2.unk_0[1]; + ptr1 = &gBG0Buffer[0x219]; + ptr2 = &gBG0Buffer[0x239]; temp = 0xf01c; - ptr1->unk_0 = temp; - ptr1->unk_2 = temp + 1; - ptr2->unk_0 = temp + 2; - ptr2->unk_2 = temp + 3; + ptr1[0] = temp; + ptr1[1] = temp + 1; + ptr2[0] = temp + 2; + ptr2[1] = temp + 3; temp = 0xf076; - ptr1->unk_4 = temp; - ptr2->unk_4 = temp + 1; - ptr1->unk_6 = temp + 2; - ptr2->unk_6 = temp + 3; + ptr1[2] = temp; + ptr2[2] = temp + 1; + ptr1[3] = temp + 2; + ptr2[3] = temp + 3; gScreen.bg0.updated = 1; } if ((gUnk_0200AF00.dungeonKeys != gSave.dungeonKeys[gArea.dungeon_idx]) || (gUnk_0200AF00.unk_10 == 0)) { From 78120062b230139bea143aa91b3b62ac267267fa Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 16:58:39 +0100 Subject: [PATCH 11/14] remove fake global gUnk_020350F0 part of gBG0Buffer --- linker.ld | 1 - src/subtask.c | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/linker.ld b/linker.ld index d7b764cd..c7582803 100644 --- a/linker.ld +++ b/linker.ld @@ -88,7 +88,6 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x000350F0; gUnk_020350F0 = .; . = 0x0003510E; gUnk_0203510E = .; . = 0x00035160; gUnk_02035160 = .; diff --git a/src/subtask.c b/src/subtask.c index a08de5b4..3661f8a6 100644 --- a/src/subtask.c +++ b/src/subtask.c @@ -14,7 +14,6 @@ #include "subtask.h" #include "ui.h" -extern u8 gUnk_020350F0[]; extern Screen gUnk_03001020; extern u8 gPaletteBufferBackup[]; extern u8 gUnk_03000420[]; @@ -53,7 +52,7 @@ void sub_080A6F6C(u32 textIndexOrPtr) { extern Font gUnk_08128FA8; if (gGenericMenu.unk2e.HWORD != textIndexOrPtr) { gGenericMenu.unk2e.HWORD = textIndexOrPtr; - MemClear(gUnk_020350F0, 0x100); + MemClear(&gBG0Buffer[0x220], 0x100); if ((textIndexOrPtr & 0xff) != 0) { ShowTextBox(textIndexOrPtr, &gUnk_08128FA8); } @@ -86,7 +85,7 @@ void sub_080A6FB4(u32 param_1, u32 param_2) { if (gGenericMenu.unk2e.HWORD != textIndexOrPtr) { gGenericMenu.unk2e.HWORD = textIndexOrPtr; - MemClear(&gUnk_020350F0, 0x100); + MemClear(&gBG0Buffer[0x220], 0x100); if ((textIndexOrPtr & 0xff) != 0) { ShowTextBox(textIndexOrPtr, font); } From 86a5c82ec9af8ae6b5bf530ccead12cc8ad0ae9e Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 16:59:52 +0100 Subject: [PATCH 12/14] remove fake global gUnk_0203510E part of gBG0Buffer --- linker.ld | 1 - src/demo.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/linker.ld b/linker.ld index c7582803..3c7967de 100644 --- a/linker.ld +++ b/linker.ld @@ -88,7 +88,6 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x0003510E; gUnk_0203510E = .; . = 0x00035160; gUnk_02035160 = .; . = 0x000354B0; gUnk_020354B0 = .; diff --git a/src/demo.c b/src/demo.c index 5ab9dfca..0cb7d039 100644 --- a/src/demo.c +++ b/src/demo.c @@ -30,7 +30,6 @@ extern u8 gUnk_08A05751[]; // sprite_table extern void gUnk_089FD1B4; extern void gUnk_089FD2F4; -extern u16 gUnk_0203510E[]; extern u8 gUnk_08A068BF[129]; @@ -190,7 +189,7 @@ void sub_080A30AC(void) { void sub_080A3198(u32 param_1, u32 param_2) { static const Font gUnk_08127C98[] = { { &gBG0Buffer[0x1ef], BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x1080, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, - { gUnk_0203510E, BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x80, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, + { &gBG0Buffer[0x22f], BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x80, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, }; static const u16 gUnk_08127CC8[4] = { TEXT_INDEX(TEXT_WINDCRESTS, 0x1c), From e38301fc174b4892f971e1ddb07e107904d01708 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 19:33:17 +0100 Subject: [PATCH 13/14] remove fake global gUnk_02035160 part of gBG0Buffer --- linker.ld | 2 -- src/ui.c | 69 +++++++++++++++++++++---------------------------------- 2 files changed, 26 insertions(+), 45 deletions(-) diff --git a/linker.ld b/linker.ld index 3c7967de..17221aa0 100644 --- a/linker.ld +++ b/linker.ld @@ -88,8 +88,6 @@ SECTIONS { . = 0x000344A0; gUnk_020344A0 = .; . = 0x000344B0; gBG2Buffer = .; . = 0x00034CB0; gBG0Buffer = .; - . = 0x00035160; gUnk_02035160 = .; - . = 0x000354B0; gUnk_020354B0 = .; . = 0x000354B4; gManagerCount = .; . = 0x000354C0; gUnk_020354C0 = .; diff --git a/src/ui.c b/src/ui.c index 4423a0c6..0f9b05b9 100644 --- a/src/ui.c +++ b/src/ui.c @@ -13,21 +13,6 @@ extern void sub_0805ECEC(u32, u32, u32, u32); extern bool32 ItemIsBottle(u32); extern u32 sub_08000E44(u32); -typedef struct { - u16 unk_0; - u16 unk_2; - u16 unk_4; - u16 unk_6; - u16 unk_8; -} substruct_160; - -typedef struct { - substruct_160 unk_0; - u8 unk_9[50]; - substruct_160 unk_40; -} struct_02035160; -extern struct_02035160 gUnk_02035160; - extern const u16 gUnk_080C8F2C[]; extern u32 gUnk_085C4620[]; extern Frame* gSpriteAnimations_322[]; @@ -216,44 +201,42 @@ void DrawRupees(void) { u32 cVar1; u32 temp; u32 temp2; - substruct_160* ptr; - substruct_160* ptr2; - struct_02035160* ptr4; + u16* ptr; + u16* ptr2; if ((gUnk_0200AF00.unk_1 & 0x40) != 0) { if (gUnk_0200AF00.unk_a != 0) { gUnk_0200AF00.unk_a = 0; - ptr4 = &gUnk_02035160; - ptr = &ptr4->unk_0; - ptr->unk_0 = 0; - ptr->unk_2 = 0; - ptr->unk_4 = 0; - ptr->unk_6 = 0; - ptr->unk_8 = 0; - ptr2 = &ptr4->unk_40; - ptr2->unk_0 = 0; - ptr2->unk_2 = 0; - ptr2->unk_4 = 0; - ptr2->unk_6 = 0; - ptr2->unk_8 = 0; + ptr = &gBG0Buffer[0x258]; + ptr[0] = 0; + ptr[1] = 0; + ptr[2] = 0; + ptr[3] = 0; + ptr[4] = 0; + ptr2 = &gBG0Buffer[0x278]; + ptr2[0] = 0; + ptr2[1] = 0; + ptr2[2] = 0; + ptr2[3] = 0; + ptr2[4] = 0; gScreen.bg0.updated = 1; } } else { if (gUnk_0200AF00.unk_a == 0) { gUnk_0200AF00.unk_a = 2; - ptr4 = &gUnk_02035160; - ptr2 = &ptr4->unk_40; - ptr4->unk_0.unk_0 = temp2 = gWalletSizes[gSave.stats.walletType].iconStartTile; - ptr4->unk_0.unk_2 = temp2 + 1; - ptr2->unk_0 = temp2 + 2; - ptr2->unk_2 = temp2 + 3; + ptr = &gBG0Buffer[0x258]; + ptr2 = &gBG0Buffer[0x278]; + ptr[0] = temp2 = gWalletSizes[gSave.stats.walletType].iconStartTile; + ptr[1] = temp2 + 1; + ptr2[0] = temp2 + 2; + ptr2[1] = temp2 + 3; temp2 = 0xf070; - ptr4->unk_0.unk_4 = temp2; - ptr2->unk_4 = temp2 + 1; - ptr4->unk_0.unk_6 = temp2 + 2; - ptr2->unk_6 = temp2 + 3; - ptr4->unk_0.unk_8 = temp2 + 4; - ptr2->unk_8 = temp2 + 5; + ptr[2] = temp2; + ptr2[2] = temp2 + 1; + ptr[3] = temp2 + 2; + ptr2[3] = temp2 + 3; + ptr[4] = temp2 + 4; + ptr2[4] = temp2 + 5; gScreen.bg0.updated = 1; cVar1 = 1; } else { From 42a8d94e8f4b5376ed8e80c973db06bde7f8d8ea Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 4 Jan 2023 23:13:52 +0100 Subject: [PATCH 14/14] clean ui.c a bit --- src/ui.c | 162 +++++++++++++++++++++++++++---------------------------- 1 file changed, 78 insertions(+), 84 deletions(-) diff --git a/src/ui.c b/src/ui.c index 0f9b05b9..9d104798 100644 --- a/src/ui.c +++ b/src/ui.c @@ -10,7 +10,6 @@ #include "game.h" extern void sub_0805ECEC(u32, u32, u32, u32); -extern bool32 ItemIsBottle(u32); extern u32 sub_08000E44(u32); extern const u16 gUnk_080C8F2C[]; @@ -45,13 +44,13 @@ void DrawChargeBar(void); void DrawRupees(void); void DrawKeys(void); void CreateUIElement(u32, u32); -void DrawDigits(u32, u32, u32, u32); +void RenderDigits(u32, u32, u32, u32); void sub_0801CAFC(UIElement*, u32); void sub_0801CB20(UIElement*, UIElementDefinition*); UIElement* FindUIElement(u32); void sub_0801CAD0(UIElement*); void sub_0801CAB8(UIElement*, Frame*); -void sub_0801C824(void); +void EraseChargeBar(void); void UpdateUIElements(void) { u32 index; @@ -70,7 +69,7 @@ void DrawUIElements(void) { u32 index; UIElement* element; UIElementDefinition* definition; - index = 0; + for (index = 0; index < MAX_UI_ELEMENTS; index++) { element = &gUnk_0200AF00.elements[index]; if (element->used == 1 && element->unk_0_1 == 1) { @@ -86,7 +85,6 @@ void DrawUIElements(void) { } void sub_0801C25C(void) { - u32 uVar1; s32 index; u8 tmp; UIElement* element; @@ -116,7 +114,6 @@ void sub_0801C25C(void) { void sub_0801C2F0(u32 param_1, u32 param_2) { u32 uVar1; register u32 rem asm("r1"); - vu32* ptr; param_1 = param_1 * 0x20 + 0x6010000; uVar1 = Div(param_2, 10); @@ -201,42 +198,42 @@ void DrawRupees(void) { u32 cVar1; u32 temp; u32 temp2; - u16* ptr; - u16* ptr2; + u16* row1; + u16* row2; if ((gUnk_0200AF00.unk_1 & 0x40) != 0) { if (gUnk_0200AF00.unk_a != 0) { gUnk_0200AF00.unk_a = 0; - ptr = &gBG0Buffer[0x258]; - ptr[0] = 0; - ptr[1] = 0; - ptr[2] = 0; - ptr[3] = 0; - ptr[4] = 0; - ptr2 = &gBG0Buffer[0x278]; - ptr2[0] = 0; - ptr2[1] = 0; - ptr2[2] = 0; - ptr2[3] = 0; - ptr2[4] = 0; + row1 = &gBG0Buffer[0x258]; + row1[0] = 0; + row1[1] = 0; + row1[2] = 0; + row1[3] = 0; + row1[4] = 0; + row2 = &gBG0Buffer[0x278]; + row2[0] = 0; + row2[1] = 0; + row2[2] = 0; + row2[3] = 0; + row2[4] = 0; gScreen.bg0.updated = 1; } } else { if (gUnk_0200AF00.unk_a == 0) { gUnk_0200AF00.unk_a = 2; - ptr = &gBG0Buffer[0x258]; - ptr2 = &gBG0Buffer[0x278]; - ptr[0] = temp2 = gWalletSizes[gSave.stats.walletType].iconStartTile; - ptr[1] = temp2 + 1; - ptr2[0] = temp2 + 2; - ptr2[1] = temp2 + 3; + row1 = &gBG0Buffer[0x258]; + row2 = &gBG0Buffer[0x278]; + row1[0] = temp2 = gWalletSizes[gSave.stats.walletType].iconStartTile; + row1[1] = temp2 + 1; + row2[0] = temp2 + 2; + row2[1] = temp2 + 3; temp2 = 0xf070; - ptr[2] = temp2; - ptr2[2] = temp2 + 1; - ptr[3] = temp2 + 2; - ptr2[3] = temp2 + 3; - ptr[4] = temp2 + 4; - ptr2[4] = temp2 + 5; + row1[2] = temp2; + row2[2] = temp2 + 1; + row1[3] = temp2 + 2; + row2[3] = temp2 + 3; + row1[4] = temp2 + 4; + row2[4] = temp2 + 5; gScreen.bg0.updated = 1; cVar1 = 1; } else { @@ -259,8 +256,8 @@ void DrawRupees(void) { SoundReq(SFX_RUPEE_GET); } case 1: - DrawDigits(0x70, gUnk_0200AF00.rupees, - gWalletSizes[(u32)gSave.stats.walletType].size <= gUnk_0200AF00.rupees, 3); + RenderDigits(0x70, gUnk_0200AF00.rupees, + gWalletSizes[(u32)gSave.stats.walletType].size <= gUnk_0200AF00.rupees, 3); cVar1 = gUnk_0200AF00.unk_c + 1; default: gUnk_0200AF00.unk_c = cVar1; @@ -269,8 +266,7 @@ void DrawRupees(void) { } } -// Draw icon with text for rupees or keys -void DrawDigits(u32 iconVramIndex, u32 count, u32 isTextYellow, u32 digits) { +void RenderDigits(u32 iconVramIndex, u32 count, u32 isTextYellow, u32 digits) { int iVar2; int iVar3; u8* puVar4; @@ -290,7 +286,7 @@ void DrawDigits(u32 iconVramIndex, u32 count, u32 isTextYellow, u32 digits) { digit = Div(count, 100); count = r1; DmaCopy32(3, puVar4 + digit * 0x40, iVar2, 0x10 * 4); - iVar2 = iVar3 + 0x600c040; + iVar2 += 0x40; case 2: digit = Div(count, 10); count = r1; @@ -301,13 +297,13 @@ void DrawDigits(u32 iconVramIndex, u32 count, u32 isTextYellow, u32 digits) { DmaCopy32(3, puVar4 + count * 0x40, iVar2, 0x10 * 4); } -void sub_0801C66C(void) { +void EraseHearts(void) { u32* ptr; s32 index; if (gUnk_0200AF00.unk_2 != 0) { gUnk_0200AF00.unk_2 = 0; - if (gUnk_0200AF00.maxHealth > 0x28) { + if (gUnk_0200AF00.maxHealth > 10 * 4) { index = 2; } else { index = 1; @@ -334,18 +330,18 @@ void DrawHearts(void) { u32 uVar6; s32 maxHealth; s32 tmp1; - u16* ptr2; + u16* ptr; if ((gUnk_0200AF00.unk_1 & 0x10) != 0) { - sub_0801C824(); - sub_0801C66C(); + EraseChargeBar(); + EraseHearts(); return; } maxHealth = gSave.stats.maxHealth / 2; if (maxHealth != gUnk_0200AF00.maxHealth) { gUnk_0200AF00.maxHealth = maxHealth; - sub_0801C824(); - sub_0801C66C(); + EraseChargeBar(); + EraseHearts(); } if (gSave.stats.health != 1) { health = gSave.stats.health / 2; @@ -400,33 +396,33 @@ void DrawHearts(void) { } if (uVar1 - 10 > 0) { - ptr2 = &gBG0Buffer[0x40]; - *ptr2 = 0xf010; - DmaSet(3, gUnk_080C8F2C + (10 - uVar6), ptr2 + 1, (uVar1 - 10) | 0x80000000); + ptr = &gBG0Buffer[0x40]; + *ptr = 0xf010; + DmaSet(3, gUnk_080C8F2C + (10 - uVar6), ptr + 1, (uVar1 - 10) | 0x80000000); } - ptr2 = &gBG0Buffer[0x20]; - *ptr2 = 0xf010; + ptr = &gBG0Buffer[0x20]; + *ptr = 0xf010; - DmaSet(3, gUnk_080C8F2C + (10 - tmp1), ptr2 + 1, maxHealth | 0x80000000); + DmaSet(3, gUnk_080C8F2C + (10 - tmp1), ptr + 1, maxHealth | 0x80000000); if ((gUnk_0200AF00.health & 3) != 0) { if (9 < uVar2) { uVar2 -= 10; - ptr2 += 0x20; + ptr += 0x20; } - ptr2[uVar2 + 1] = ((gUnk_0200AF00.health & 3) + 0x11) | 0xf000; + ptr[uVar2 + 1] = ((gUnk_0200AF00.health & 3) + 0x11) | 0xf000; } gScreen.bg0.updated = 1; } } -void sub_0801C824(void) { +void EraseChargeBar(void) { u32* ptr; if (gUnk_0200AF00.unk_6 != 0) { gUnk_0200AF00.unk_6 = 0; if (gUnk_0200AF00.maxHealth > 10 * 4) { - ptr = (u32*)&gBG0Buffer[0x60]; // Show second row of hearts + ptr = (u32*)&gBG0Buffer[0x60]; } else { ptr = (u32*)&gBG0Buffer[0x40]; } @@ -454,9 +450,13 @@ void DrawChargeBar(void) { } if (!tmp1) - return sub_0801C824(); + return EraseChargeBar(); - ptr1 = (gUnk_0200AF00.maxHealth > 10 * 4) ? &gBG0Buffer[0x60] : &gBG0Buffer[0x40]; + if (gUnk_0200AF00.maxHealth > 10 * 4) { + ptr1 = &gBG0Buffer[0x60]; + } else { + ptr1 = &gBG0Buffer[0x40]; + } tmp2 = Div(gPlayerState.chargeState.chargeTimer + 19, 20); if (tmp2 > 40) { @@ -495,52 +495,50 @@ void DrawChargeBar(void) { } void DrawKeys(void) { - s32 iVar1; - u16* ptr1; - u16* ptr2; + u16* row1; + u16* row2; u32 temp; if (!(((gUnk_0200AF00.unk_1 & 0x80) == 0) && (AreaHasKeys()))) { if (gUnk_0200AF00.unk_10 != 0) { gUnk_0200AF00.unk_10 = 0; - ptr1 = &gBG0Buffer[0x219]; - ptr1[0] = 0; - ptr1[1] = 0; - ptr1[2] = 0; - ptr1[3] = 0; - ptr1[0x20] = 0; - ptr1[0x21] = 0; - ptr1[0x22] = 0; - ptr1[0x23] = 0; + row1 = &gBG0Buffer[0x219]; + row1[0] = 0; + row1[1] = 0; + row1[2] = 0; + row1[3] = 0; + row1[0x20] = 0; + row1[0x21] = 0; + row1[0x22] = 0; + row1[0x23] = 0; gScreen.bg0.updated = 1; } } else { if (gUnk_0200AF00.unk_10 == 0) { - ptr1 = &gBG0Buffer[0x219]; - ptr2 = &gBG0Buffer[0x239]; + row1 = &gBG0Buffer[0x219]; + row2 = &gBG0Buffer[0x239]; temp = 0xf01c; - ptr1[0] = temp; - ptr1[1] = temp + 1; - ptr2[0] = temp + 2; - ptr2[1] = temp + 3; + row1[0] = temp; + row1[1] = temp + 1; + row2[0] = temp + 2; + row2[1] = temp + 3; temp = 0xf076; - ptr1[2] = temp; - ptr2[2] = temp + 1; - ptr1[3] = temp + 2; - ptr2[3] = temp + 3; + row1[2] = temp; + row2[2] = temp + 1; + row1[3] = temp + 2; + row2[3] = temp + 3; gScreen.bg0.updated = 1; } if ((gUnk_0200AF00.dungeonKeys != gSave.dungeonKeys[gArea.dungeon_idx]) || (gUnk_0200AF00.unk_10 == 0)) { gUnk_0200AF00.unk_10 = 2; gUnk_0200AF00.dungeonKeys = gSave.dungeonKeys[gArea.dungeon_idx]; - DrawDigits(0x76, gUnk_0200AF00.dungeonKeys, 0, 2); + RenderDigits(0x76, gUnk_0200AF00.dungeonKeys, 0, 2); } } } void CreateUIElement(u32 type, u32 type2) { u32 index; - UIElement* new_var; UIElement* element; for (index = 0; index < MAX_UI_ELEMENTS; index++) { @@ -674,7 +672,6 @@ u32 sub_0801CC80(UIElement* element) { void ItemUIElement(UIElement* element) { u32 itemMaxNumber; u32 itemId; - u8* puVar3; UIElement* element2; u32 uVar5; u32 playerItemCount; @@ -743,9 +740,6 @@ void ItemUIElement(UIElement* element) { void TextUIElement(UIElement* element) { UIElement* buttonUIElement; u32 tmp; - extern struct_0200AF00* ptr; - u32 tmp1; - UIElement* ptr2; if (element->type2 == 9) { tmp = gUnk_0200AF00.unk_2f;