From 25534c0d54f16f379391b9a1348b890bfb9f6f11 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Thu, 24 Aug 2023 21:11:43 -0500 Subject: [PATCH 01/12] Decompile LoadPokedexGraphics --- asm/pokedex.s | 199 -------------------------------------------- data/rom.s | 2 +- include/functions.h | 22 ++--- src/pokedex.c | 65 +++++++++++++++ 4 files changed, 77 insertions(+), 211 deletions(-) diff --git a/asm/pokedex.s b/asm/pokedex.s index ca2bb87..4723f6c 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -4,205 +4,6 @@ .text - thumb_func_start sub_3DCC -sub_3DCC: @ 0x08003DCC - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - bl ResetSomeGraphicsRelatedStuff - movs r2, #0x80 - lsls r2, r2, #0x13 - movs r1, #0x86 - lsls r1, r1, #5 - adds r0, r1, #0 - strh r0, [r2] - ldr r1, _08003F30 @ =0x0400000A - movs r0, #5 - strh r0, [r1] - ldrh r0, [r2] - movs r3, #0x80 - lsls r3, r3, #2 - adds r1, r3, #0 - orrs r0, r1 - strh r0, [r2] - ldr r1, _08003F34 @ =0x0400000C - subs r3, #0xf2 - adds r0, r3, #0 - strh r0, [r1] - ldrh r0, [r2] - movs r3, #0x80 - lsls r3, r3, #3 - adds r1, r3, #0 - orrs r0, r1 - strh r0, [r2] - ldr r1, _08003F38 @ =0x0400000E - ldr r3, _08003F3C @ =0x0000020F - adds r0, r3, #0 - strh r0, [r1] - ldrh r0, [r2] - movs r3, #0x80 - lsls r3, r3, #4 - adds r1, r3, #0 - orrs r0, r1 - strh r0, [r2] - ldr r7, _08003F40 @ =gMain - ldrh r0, [r2] - strh r0, [r7, #0x16] - ldr r4, _08003F44 @ =0x040000D4 - ldr r0, _08003F48 @ =gUnknown_08082720 - str r0, [r4] - ldr r0, _08003F4C @ =0x06004000 - str r0, [r4, #4] - ldr r0, _08003F50 @ =0x80002200 - str r0, [r4, #8] - ldr r0, [r4, #8] - ldr r0, _08003F54 @ =gUnknown_08087B40 - str r0, [r4] - ldr r0, _08003F58 @ =0x0600C000 - str r0, [r4, #4] - ldr r0, _08003F5C @ =0x80000A00 - str r0, [r4, #8] - ldr r0, [r4, #8] - ldr r0, _08003F60 @ =gUnknown_08089760 - str r0, [r4] - movs r0, #0xa0 - lsls r0, r0, #0x13 - str r0, [r4, #4] - ldr r1, _08003F64 @ =0x80000100 - str r1, [r4, #8] - ldr r0, [r4, #8] - ldr r0, _08003F68 @ =gUnknown_08081F20 - str r0, [r4] - ldr r0, _08003F6C @ =gUnknown_03005C00 - mov sl, r0 - str r0, [r4, #4] - ldr r2, _08003F70 @ =0x80000400 - mov r8, r2 - str r2, [r4, #8] - ldr r0, [r4, #8] - ldr r0, _08003F74 @ =gUnknown_08087340 - str r0, [r4] - ldr r3, _08003F78 @ =gUnknown_02019C40 - mov sb, r3 - str r3, [r4, #4] - str r2, [r4, #8] - ldr r0, [r4, #8] - ldr r0, _08003F7C @ =gUnknown_08088F60 - str r0, [r4] - ldr r0, _08003F80 @ =0x06001000 - str r0, [r4, #4] - str r2, [r4, #8] - ldr r0, [r4, #8] - ldr r0, _08003F84 @ =gUnknown_08089960 - str r0, [r4] - ldr r0, _08003F88 @ =0x05000200 - str r0, [r4, #4] - str r1, [r4, #8] - ldr r0, [r4, #8] - ldr r0, _08003F8C @ =gUnknown_08089B60 - str r0, [r4] - ldr r0, _08003F90 @ =0x06010000 - str r0, [r4, #4] - ldr r0, _08003F94 @ =0x80003610 - str r0, [r4, #8] - ldr r0, [r4, #8] - bl sub_3FAC - ldr r0, _08003F98 @ =gUnknown_0202BEB8 - movs r1, #0 - ldrsh r0, [r0, r1] - ldr r1, _08003F9C @ =gUnknown_0201A514 - movs r2, #0 - ldrsh r1, [r1, r2] - bl sub_6BEC - ldr r6, _08003FA0 @ =gUnknown_0202ADE0 - movs r3, #0 - ldrsh r0, [r6, r3] - bl sub_681C - ldr r5, _08003FA4 @ =gUnknown_0202C5B0 - movs r1, #0 - ldrsh r0, [r5, r1] - bl sub_6CA0 - movs r2, #0 - ldrsh r0, [r5, r2] - bl sub_6F30 - movs r3, #0 - ldrsh r0, [r6, r3] - bl sub_6F78 - movs r1, #0 - ldrsh r0, [r6, r1] - bl sub_8974 - movs r2, #0 - ldrsh r0, [r6, r2] - bl sub_8A78 - movs r1, #0x9a - lsls r1, r1, #2 - add r1, sb - movs r0, #0x59 - strh r0, [r1] - mov r3, sl - str r3, [r4] - movs r0, #0xc0 - lsls r0, r0, #0x13 - str r0, [r4, #4] - mov r0, r8 - str r0, [r4, #8] - ldr r0, [r4, #8] - mov r1, sb - str r1, [r4] - ldr r0, _08003FA8 @ =0x06000800 - str r0, [r4, #4] - mov r2, r8 - str r2, [r4, #8] - ldr r0, [r4, #8] - bl sub_51FC - bl sub_0CBC - bl sub_024C - movs r0, #1 - strb r0, [r7, #3] - movs r0, #0x2e - bl m4aSongNumStart - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08003F30: .4byte 0x0400000A -_08003F34: .4byte 0x0400000C -_08003F38: .4byte 0x0400000E -_08003F3C: .4byte 0x0000020F -_08003F40: .4byte gMain -_08003F44: .4byte 0x040000D4 -_08003F48: .4byte gUnknown_08082720 -_08003F4C: .4byte 0x06004000 -_08003F50: .4byte 0x80002200 -_08003F54: .4byte gUnknown_08087B40 -_08003F58: .4byte 0x0600C000 -_08003F5C: .4byte 0x80000A00 -_08003F60: .4byte gUnknown_08089760 -_08003F64: .4byte 0x80000100 -_08003F68: .4byte gUnknown_08081F20 -_08003F6C: .4byte gUnknown_03005C00 -_08003F70: .4byte 0x80000400 -_08003F74: .4byte gUnknown_08087340 -_08003F78: .4byte gUnknown_02019C40 -_08003F7C: .4byte gUnknown_08088F60 -_08003F80: .4byte 0x06001000 -_08003F84: .4byte gUnknown_08089960 -_08003F88: .4byte 0x05000200 -_08003F8C: .4byte gUnknown_08089B60 -_08003F90: .4byte 0x06010000 -_08003F94: .4byte 0x80003610 -_08003F98: .4byte gUnknown_0202BEB8 -_08003F9C: .4byte gUnknown_0201A514 -_08003FA0: .4byte gUnknown_0202ADE0 -_08003FA4: .4byte gUnknown_0202C5B0 -_08003FA8: .4byte 0x06000800 - thumb_func_start sub_3FAC sub_3FAC: @ 0x08003FAC push {r4, r5, lr} diff --git a/data/rom.s b/data/rom.s index 02fd1aa..cd0f8c7 100644 --- a/data/rom.s +++ b/data/rom.s @@ -695,7 +695,7 @@ gUnknown_0805C840:: @ 0x0805C840 .incbin "baserom.gba", 0x5C840, 0x40 gPokedexStateFuncs:: @ 0x0805C880 - .4byte sub_3DCC + .4byte LoadPokedexGraphics .4byte sub_4150 .4byte sub_43D4 .4byte sub_4428 diff --git a/include/functions.h b/include/functions.h index ad20bd9..342657d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -340,9 +340,9 @@ extern void sub_525CC(s8); // asm/pokedex.s -//extern ? PokedexMain(); -//extern ? sub_3DCC(); -//extern ? sub_3FAC(); +extern void PokedexMain(void); +//extern ? LoadPokedexGraphics(); +extern void sub_3FAC(void); //extern ? sub_4150(); //extern ? sub_43D4(); //extern ? sub_4428(); @@ -364,7 +364,7 @@ extern void sub_525CC(s8); //extern ? sub_5134(); //extern ? sub_5174(); //extern ? sub_51CC(); -//extern ? sub_51FC(); +extern void sub_51FC(void); //extern ? sub_599C(); //extern ? sub_5E60(); //extern ? sub_5EA4(); @@ -373,16 +373,16 @@ extern void sub_525CC(s8); //extern ? sub_6144(); //extern ? sub_639C(); //extern ? sub_65DC(); -//extern ? sub_681C(); -//extern ? sub_6BEC(); -//extern ? sub_6CA0(); -//extern ? sub_6F30(); -//extern ? sub_6F78(); +extern void sub_681C(); +extern void sub_6BEC(); +extern void sub_6CA0(s16); +extern void sub_6F30(s16); +extern void sub_6F78(); //extern ? sub_70E0(); //extern ? sub_71DC(); //extern ? sub_88E4(); -//extern ? sub_8974(); -//extern ? sub_8A78(); +extern void sub_8974(); +extern s16 sub_8A78(s32); extern void ResetPokedex(void); // asm/rom_1068C.s diff --git a/src/pokedex.c b/src/pokedex.c index c18d2a8..12db614 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -1,9 +1,74 @@ #include "global.h" +#include "constants/bg_music.h" +#include "functions.h" +#include "m4a.h" #include "main.h" +extern u16 gUnknown_02019C40[]; +extern s16 gUnknown_0201A514; +extern s16 gUnknown_0202ADE0; +extern s16 gUnknown_0202BEB8; +extern s32 gUnknown_0202C5B0; + extern StateFunc gPokedexStateFuncs[]; +extern u16 gUnknown_08081F20[]; +extern u16 gUnknown_08082720[]; +extern u16 gUnknown_08087340[]; +extern u16 gUnknown_08087B40[]; +extern u16 gUnknown_08088F60[]; +extern u16 gUnknown_08089760[]; +extern u16 gUnknown_08089960[]; +extern u16 gUnknown_08089B60[]; void PokedexMain(void) { gPokedexStateFuncs[gMain.subState](); } + +void LoadPokedexGraphics(void) +{ + ResetSomeGraphicsRelatedStuff(); + + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_FORCED_BLANK | DISPCNT_OBJ_ON; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_16COLOR | BGCNT_SCREENBASE(0) | BGCNT_TXT256x256; + REG_DISPCNT |= DISPCNT_BG1_ON; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(3) | BGCNT_16COLOR | BGCNT_SCREENBASE(1) | BGCNT_TXT256x256; + REG_DISPCNT |= DISPCNT_BG2_ON; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_16COLOR | BGCNT_SCREENBASE(2) | BGCNT_TXT256x256; + REG_DISPCNT |= DISPCNT_BG3_ON; + + gMain.unk16 = REG_DISPCNT; + + DmaCopy16(3, gUnknown_08082720, (void *)BG_CHAR_ADDR(1), 0x4400); + DmaCopy16(3, gUnknown_08087B40, (void *)BG_CHAR_ADDR(3), 0x1400); + DmaCopy16(3, gUnknown_08089760, (void *)BG_PLTT, BG_PLTT_SIZE); + DmaCopy16(3, gUnknown_08081F20, gUnknown_03005C00, BG_SCREEN_SIZE); + DmaCopy16(3, gUnknown_08087340, gUnknown_02019C40, BG_SCREEN_SIZE); + DmaCopy16(3, gUnknown_08088F60, (void *)BG_SCREEN_ADDR(2), BG_SCREEN_SIZE); + DmaCopy16(3, gUnknown_08089960, (void *)OBJ_PLTT, OBJ_PLTT_SIZE); + DmaCopy16(3, gUnknown_08089B60, (void *)OBJ_VRAM0, 0x6C20); + + sub_3FAC(); + sub_6BEC(gUnknown_0202BEB8, gUnknown_0201A514); + sub_681C(gUnknown_0202ADE0); + sub_6CA0(gUnknown_0202C5B0); + sub_6F30(gUnknown_0202C5B0); + sub_6F78(gUnknown_0202ADE0); + sub_8974(gUnknown_0202ADE0); + sub_8A78(gUnknown_0202ADE0); + + // I'm pretty sure this is genuinely an array access rather than a separate variable + gUnknown_02019C40[0x134] = 0x59; + + DmaCopy16(3, gUnknown_03005C00, (void *)BG_SCREEN_ADDR(0), BG_SCREEN_SIZE); + DmaCopy16(3, gUnknown_02019C40, (void *)BG_SCREEN_ADDR(1), BG_SCREEN_SIZE); + + sub_51FC(); + sub_0CBC(); + sub_024C(); + + // Must be `= 1` to match, cannot be `++` + gMain.subState = 1; + + m4aSongNumStart(MUS_POKEDEX); +} From aab285c133e2a354907d1107e0293328241b5807 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Thu, 24 Aug 2023 21:26:02 -0500 Subject: [PATCH 02/12] Clean up some comments --- src/gbplayer.c | 2 +- src/pokedex.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gbplayer.c b/src/gbplayer.c index aa8122b..3cc1ee8 100644 --- a/src/gbplayer.c +++ b/src/gbplayer.c @@ -120,7 +120,7 @@ void sub_10C0(void) void sub_111C(void) { - // This probably wasn't the original code, but it matches. + // TODO This probably wasn't the original code, but it matches. int *var0 = &gUnknown_02019BF4; int val = 0; gUnknown_02019C00 = val; diff --git a/src/pokedex.c b/src/pokedex.c index 12db614..ba5fb70 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -57,7 +57,6 @@ void LoadPokedexGraphics(void) sub_8974(gUnknown_0202ADE0); sub_8A78(gUnknown_0202ADE0); - // I'm pretty sure this is genuinely an array access rather than a separate variable gUnknown_02019C40[0x134] = 0x59; DmaCopy16(3, gUnknown_03005C00, (void *)BG_SCREEN_ADDR(0), BG_SCREEN_SIZE); From 6399243ad7fbde9edf324a46fdf33ff24ec24bc4 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Fri, 25 Aug 2023 19:51:52 -0500 Subject: [PATCH 03/12] Update pokedex.c --- src/pokedex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pokedex.c b/src/pokedex.c index ba5fb70..af3f385 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -8,7 +8,7 @@ extern u16 gUnknown_02019C40[]; extern s16 gUnknown_0201A514; extern s16 gUnknown_0202ADE0; extern s16 gUnknown_0202BEB8; -extern s32 gUnknown_0202C5B0; +extern s16 gUnknown_0202C5B0; extern StateFunc gPokedexStateFuncs[]; extern u16 gUnknown_08081F20[]; From 0df3e2ff9d45b1d6f60e15bd36dc5d4789a5f182 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sat, 26 Aug 2023 18:51:29 -0500 Subject: [PATCH 04/12] Decompile sub_3FAC --- asm/pokedex.s | 187 -------------------------------------------------- src/pokedex.c | 113 ++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 187 deletions(-) diff --git a/asm/pokedex.s b/asm/pokedex.s index 4723f6c..92dbffa 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -4,193 +4,6 @@ .text - thumb_func_start sub_3FAC -sub_3FAC: @ 0x08003FAC - push {r4, r5, lr} - ldr r0, _0800401C @ =gUnknown_0202ADE0 - movs r4, #0 - strh r4, [r0] - ldr r0, _08004020 @ =gUnknown_0202C5B0 - strh r4, [r0] - ldr r0, _08004024 @ =gUnknown_0201A448 - strh r4, [r0] - ldr r0, _08004028 @ =gUnknown_0202BF00 - strh r4, [r0] - ldr r0, _0800402C @ =gUnknown_0202A57C - strh r4, [r0] - ldr r0, _08004030 @ =gUnknown_0201A4F0 - strh r4, [r0] - ldr r0, _08004034 @ =gUnknown_0202BE20 - strh r4, [r0] - ldr r0, _08004038 @ =gUnknown_0202C58C - strh r4, [r0] - ldr r0, _0800403C @ =gUnknown_02019C24 - strb r4, [r0] - ldr r0, _08004040 @ =gUnknown_0202BF0C - strh r4, [r0] - ldr r0, _08004044 @ =gUnknown_0201A440 - strh r4, [r0] - ldr r0, _08004048 @ =gUnknown_0202C5E8 - strh r4, [r0] - ldr r0, _0800404C @ =gUnknown_0202BEF4 - strh r4, [r0] - ldr r0, _08004050 @ =gUnknown_0202A588 - movs r5, #1 - strh r5, [r0] - ldr r0, _08004054 @ =gUnknown_0202A55C - strh r5, [r0] - ldr r0, _08004058 @ =gUnknown_0202A568 - movs r1, #0 - strh r1, [r0] - strh r1, [r0, #2] - ldr r0, _0800405C @ =gUnknown_0202BF14 - strh r1, [r0] - ldr r0, _08004060 @ =gUnknown_0202A558 - strh r1, [r0] - ldr r0, _08004064 @ =gUnknown_0202BEE0 - strb r4, [r0] - ldr r0, _08004068 @ =gUnknown_0202BF04 - strb r5, [r0] - bl sub_88E4 - bl sub_FD20 - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #1 - bne _08004070 - ldr r0, _0800406C @ =gUnknown_0202C590 - strb r5, [r0] - b _08004074 - .align 2, 0 -_0800401C: .4byte gUnknown_0202ADE0 -_08004020: .4byte gUnknown_0202C5B0 -_08004024: .4byte gUnknown_0201A448 -_08004028: .4byte gUnknown_0202BF00 -_0800402C: .4byte gUnknown_0202A57C -_08004030: .4byte gUnknown_0201A4F0 -_08004034: .4byte gUnknown_0202BE20 -_08004038: .4byte gUnknown_0202C58C -_0800403C: .4byte gUnknown_02019C24 -_08004040: .4byte gUnknown_0202BF0C -_08004044: .4byte gUnknown_0201A440 -_08004048: .4byte gUnknown_0202C5E8 -_0800404C: .4byte gUnknown_0202BEF4 -_08004050: .4byte gUnknown_0202A588 -_08004054: .4byte gUnknown_0202A55C -_08004058: .4byte gUnknown_0202A568 -_0800405C: .4byte gUnknown_0202BF14 -_08004060: .4byte gUnknown_0202A558 -_08004064: .4byte gUnknown_0202BEE0 -_08004068: .4byte gUnknown_0202BF04 -_0800406C: .4byte gUnknown_0202C590 -_08004070: - ldr r0, _080040C8 @ =gUnknown_0202C590 - strb r4, [r0] -_08004074: - ldr r0, _080040CC @ =gUnknown_0202BEC4 - movs r1, #0 - strb r1, [r0] - ldr r0, _080040D0 @ =gUnknown_0202BEFC - strb r1, [r0] - ldr r0, _080040D4 @ =gUnknown_0201B120 - movs r1, #0 - strh r1, [r0] - ldr r0, _080040D8 @ =gUnknown_02002830 - strb r1, [r0] - ldr r0, _080040DC @ =gUnknown_02002831 - strb r1, [r0] - ldr r0, _080040E0 @ =gUnknown_0202C794 - strb r1, [r0] - ldr r0, _080040E4 @ =gUnknown_0201C1B4 - strb r1, [r0] - ldr r0, _080040E8 @ =gUnknown_0202C5AC - strb r1, [r0] - ldr r0, _080040EC @ =gUnknown_02019C28 - strb r1, [r0] - ldr r5, _080040F0 @ =gUnknown_0202A1C0 - ldr r4, _080040F4 @ =gUnknown_0202A574 - adds r3, r5, #0 - ldr r2, _080040F8 @ =gUnknown_0202A390 - movs r1, #0xe0 -_080040A6: - ldrh r0, [r3] - strh r0, [r2] - adds r3, #2 - adds r2, #2 - subs r1, #1 - cmp r1, #0 - bge _080040A6 - adds r1, r5, #0 - movs r2, #0xcc - lsls r2, r2, #1 - adds r0, r1, r2 - movs r2, #0 - ldrsh r0, [r0, r2] - cmp r0, #0 - beq _080040FC - movs r0, #0xcd - b _08004146 - .align 2, 0 -_080040C8: .4byte gUnknown_0202C590 -_080040CC: .4byte gUnknown_0202BEC4 -_080040D0: .4byte gUnknown_0202BEFC -_080040D4: .4byte gUnknown_0201B120 -_080040D8: .4byte gUnknown_02002830 -_080040DC: .4byte gUnknown_02002831 -_080040E0: .4byte gUnknown_0202C794 -_080040E4: .4byte gUnknown_0201C1B4 -_080040E8: .4byte gUnknown_0202C5AC -_080040EC: .4byte gUnknown_02019C28 -_080040F0: .4byte gUnknown_0202A1C0 -_080040F4: .4byte gUnknown_0202A574 -_080040F8: .4byte gUnknown_0202A390 -_080040FC: - movs r2, #0xcb - lsls r2, r2, #1 - adds r0, r1, r2 - movs r2, #0 - ldrsh r0, [r0, r2] - cmp r0, #0 - beq _0800410E - movs r0, #0xcc - b _08004146 -_0800410E: - movs r2, #0xca - lsls r2, r2, #1 - adds r0, r1, r2 - movs r2, #0 - ldrsh r0, [r0, r2] - cmp r0, #0 - beq _08004120 - movs r0, #0xcb - b _08004146 -_08004120: - movs r2, #0xc9 - lsls r2, r2, #1 - adds r0, r1, r2 - movs r1, #0 - ldrsh r0, [r0, r1] - cmp r0, #0 - beq _08004132 - movs r0, #0xca - b _08004146 -_08004132: - movs r2, #0xc8 - lsls r2, r2, #1 - adds r0, r5, r2 - movs r1, #0 - ldrsh r0, [r0, r1] - cmp r0, #0 - beq _08004144 - movs r0, #0xc9 - b _08004146 -_08004144: - movs r0, #0xc8 -_08004146: - strh r0, [r4] - pop {r4, r5} - pop {r0} - bx r0 - thumb_func_start sub_4150 sub_4150: @ 0x08004150 push {r4, r5, r6, r7, lr} diff --git a/src/pokedex.c b/src/pokedex.c index af3f385..275d32c 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -20,6 +20,41 @@ extern u16 gUnknown_08089760[]; extern u16 gUnknown_08089960[]; extern u16 gUnknown_08089B60[]; +extern s16 gUnknown_0201A448; +extern s16 gUnknown_0202BF00; +extern s16 gUnknown_0202A57C; +extern s16 gUnknown_0201A4F0; +extern s16 gUnknown_0202BE20; +extern s16 gUnknown_0202C58C; +extern s8 gUnknown_02019C24; +extern s16 gUnknown_0202BF0C; +extern s16 gUnknown_0201A440; +extern s16 gUnknown_0202BEF4; +extern s16 gUnknown_0202A588; +extern s16 gUnknown_0202A55C; +extern s16 gUnknown_0202A568[2]; +extern s16 gUnknown_0202C5E8; +extern s16 gUnknown_0202A558; +extern s8 gUnknown_0202BEE0; +extern s8 gUnknown_0202BF04; +extern s16 gUnknown_0202BF14; +extern s8 gUnknown_0202C590; +extern s16 gUnknown_0201B120; +extern s8 gUnknown_0202BEC4; +extern s8 gUnknown_0202BEFC; +extern s8 gUnknown_02002830; +extern s8 gUnknown_02002831; +extern s8 gUnknown_0202C794; +extern s8 gUnknown_0201C1B4; +extern s8 gUnknown_0202C5AC; +extern s8 gUnknown_02019C28; +extern s16 gUnknown_0202A1C0[]; +extern s16 gUnknown_0202A390[]; +extern s16 gUnknown_0202A574; + +void sub_88E4(void); +s8 sub_FD20(void); + void PokedexMain(void) { gPokedexStateFuncs[gMain.subState](); @@ -71,3 +106,81 @@ void LoadPokedexGraphics(void) m4aSongNumStart(MUS_POKEDEX); } + +void sub_3FAC(void) { + s32 i; + + gUnknown_0202ADE0 = 0; + gUnknown_0202C5B0 = 0; + gUnknown_0201A448 = 0; + gUnknown_0202BF00 = 0; + gUnknown_0202A57C = 0; + gUnknown_0201A4F0 = 0; + gUnknown_0202BE20 = 0; + gUnknown_0202C58C = 0; + gUnknown_02019C24 = 0; + gUnknown_0202BF0C = 0; + gUnknown_0201A440 = 0; + gUnknown_0202C5E8 = 0; + gUnknown_0202BEF4 = 0; + gUnknown_0202A588 = 1; + gUnknown_0202A55C = 1; + + gUnknown_0202A568[0] = 0; + gUnknown_0202A568[1] = 0; + + gUnknown_0202BF14 = 0; + gUnknown_0202A558 = 0; + gUnknown_0202BEE0 = 0; + gUnknown_0202BF04 = 1; + + sub_88E4(); + if (sub_FD20() == 1) + { + gUnknown_0202C590 = 1; + } + else + { + gUnknown_0202C590 = 0; + } + + gUnknown_0202BEC4 = 0; + gUnknown_0202BEFC = 0; + gUnknown_0201B120 = 0; + gUnknown_02002830 = 0; + gUnknown_02002831 = 0; + gUnknown_0202C794 = 0; + gUnknown_0201C1B4 = 0; + gUnknown_0202C5AC = 0; + gUnknown_02019C28 = 0; + + for (i = 0; i < 0xE1; i++) + { + gUnknown_0202A390[i] = gUnknown_0202A1C0[i]; + } + + if (gUnknown_0202A1C0[SPECIES_AERODACTYL]) + { + gUnknown_0202A574 = SPECIES_AERODACTYL + 1; + } + else if (gUnknown_0202A1C0[SPECIES_TOTODILE]) + { + gUnknown_0202A574 = SPECIES_TOTODILE + 1; + } + else if (gUnknown_0202A1C0[SPECIES_CYNDAQUIL]) + { + gUnknown_0202A574 = SPECIES_CYNDAQUIL + 1; + } + else if (gUnknown_0202A1C0[SPECIES_CHIKORITA]) + { + gUnknown_0202A574 = SPECIES_CHIKORITA + 1; + } + else if (gUnknown_0202A1C0[SPECIES_JIRACHI]) + { + gUnknown_0202A574 = SPECIES_JIRACHI + 1; + } + else + { + gUnknown_0202A574 = SPECIES_RAYQUAZA + 1; + } +} From 2415f1989081c3f3c7ce07f24c8f9968a3507a7a Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sat, 26 Aug 2023 19:16:18 -0500 Subject: [PATCH 05/12] Fix io_reg.h error --- include/gba/io_reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index b5aac20..1d14aee 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -696,7 +696,7 @@ #define R_BUTTON 0x0100 #define L_BUTTON 0x0200 #define KEYS_MASK 0x03FF -#define KEY_INTR_ENABLE 0x0400 +#define KEY_INTR_ENABLE 0x4000 #define KEY_OR_INTR 0x0000 #define KEY_AND_INTR 0x8000 #define DPAD_ANY ((DPAD_RIGHT | DPAD_LEFT | DPAD_UP | DPAD_DOWN)) From fd9f465c989f861e34b5ee6147e56148185ad078 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sun, 27 Aug 2023 14:58:55 -0500 Subject: [PATCH 06/12] Decompile sub_4150 --- asm/pokedex.s | 291 -------------------------------------------------- src/pokedex.c | 153 ++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 291 deletions(-) diff --git a/asm/pokedex.s b/asm/pokedex.s index 92dbffa..b70d685 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -4,297 +4,6 @@ .text - thumb_func_start sub_4150 -sub_4150: @ 0x08004150 - push {r4, r5, r6, r7, lr} - ldr r4, _08004174 @ =gMain - ldrh r2, [r4, #0x1c] - movs r0, #4 - ands r0, r2 - cmp r0, #0 - beq _08004230 - ldr r1, _08004178 @ =gUnknown_0202BF04 - movs r0, #0 - strb r0, [r1] - movs r0, #0x40 - ands r0, r2 - cmp r0, #0 - beq _0800417C - bl sub_4D74 - b _080041A8 - .align 2, 0 -_08004174: .4byte gMain -_08004178: .4byte gUnknown_0202BF04 -_0800417C: - movs r0, #0x80 - ands r0, r2 - cmp r0, #0 - beq _0800418A - bl sub_4E34 - b _080041A8 -_0800418A: - movs r0, #0x20 - ands r0, r2 - cmp r0, #0 - beq _08004198 - bl sub_4EF0 - b _080041A8 -_08004198: - movs r0, #0x10 - ands r0, r2 - lsls r0, r0, #0x10 - lsrs r1, r0, #0x10 - cmp r1, #0 - beq _080041B6 - bl sub_4F50 -_080041A8: - bl sub_5064 - bl sub_51CC - movs r0, #2 - strb r0, [r4, #3] - b _080041BE -_080041B6: - ldr r0, _08004200 @ =gUnknown_02019C24 - strb r1, [r0] - bl sub_5064 -_080041BE: - ldr r3, _08004204 @ =gMain - ldrh r1, [r3, #0x18] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - bne _080041CC - b _08004388 -_080041CC: - ldr r0, _08004208 @ =gUnknown_0202C5E8 - movs r2, #0 - strh r2, [r0] - ldr r1, _0800420C @ =gUnknown_0202A1C0 - ldr r0, _08004210 @ =gUnknown_0202ADE0 - movs r4, #0 - ldrsh r0, [r0, r4] - lsls r0, r0, #1 - adds r0, r0, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - cmp r0, #1 - ble _08004228 - ldr r0, _08004214 @ =gUnknown_0202BF04 - strb r2, [r0] - ldr r1, _08004218 @ =0x040000D4 - ldr r0, _0800421C @ =0x06000280 - str r0, [r1] - ldr r0, _08004220 @ =gUnknown_0202A590 - str r0, [r1, #4] - ldr r0, _08004224 @ =0x80000100 - str r0, [r1, #8] - ldr r0, [r1, #8] - movs r0, #3 - strb r0, [r3, #3] - b _08004388 - .align 2, 0 -_08004200: .4byte gUnknown_02019C24 -_08004204: .4byte gMain -_08004208: .4byte gUnknown_0202C5E8 -_0800420C: .4byte gUnknown_0202A1C0 -_08004210: .4byte gUnknown_0202ADE0 -_08004214: .4byte gUnknown_0202BF04 -_08004218: .4byte 0x040000D4 -_0800421C: .4byte 0x06000280 -_08004220: .4byte gUnknown_0202A590 -_08004224: .4byte 0x80000100 -_08004228: - movs r0, #0x8a - bl m4aSongNumStart - b _08004388 -_08004230: - ldr r1, _08004248 @ =gUnknown_0202BF04 - movs r0, #1 - strb r0, [r1] - movs r0, #0x40 - ands r0, r2 - cmp r0, #0 - beq _0800424C - bl sub_4D74 - bl sub_5174 - b _0800428A - .align 2, 0 -_08004248: .4byte gUnknown_0202BF04 -_0800424C: - movs r0, #0x80 - ands r0, r2 - cmp r0, #0 - beq _0800425E - bl sub_4E34 - bl sub_5174 - b _0800428A -_0800425E: - movs r0, #0x20 - ands r0, r2 - cmp r0, #0 - beq _08004270 - bl sub_4EF0 - bl sub_5174 - b _0800428A -_08004270: - movs r0, #0x10 - ands r0, r2 - lsls r0, r0, #0x10 - lsrs r1, r0, #0x10 - cmp r1, #0 - beq _08004286 - bl sub_4F50 - bl sub_5174 - b _0800428A -_08004286: - ldr r0, _080042A4 @ =gUnknown_02019C24 - strb r1, [r0] -_0800428A: - ldr r0, _080042A8 @ =gUnknown_0202ADE0 - movs r2, #0 - ldrsh r0, [r0, r2] - bl sub_8A78 - lsls r0, r0, #0x10 - asrs r1, r0, #0x10 - cmp r1, #1 - bne _080042B0 - ldr r0, _080042AC @ =gUnknown_0202A588 - strh r1, [r0] - b _080042B6 - .align 2, 0 -_080042A4: .4byte gUnknown_02019C24 -_080042A8: .4byte gUnknown_0202ADE0 -_080042AC: .4byte gUnknown_0202A588 -_080042B0: - ldr r1, _0800430C @ =gUnknown_0202A588 - movs r0, #0 - strh r0, [r1] -_080042B6: - ldr r0, _08004310 @ =gUnknown_0202A55C - movs r7, #1 - strh r7, [r0] - ldr r0, _08004314 @ =gUnknown_0202A568 - movs r6, #0 - movs r2, #0 - strh r2, [r0] - strh r2, [r0, #2] - ldr r0, _08004318 @ =gUnknown_0201A440 - strh r2, [r0] - ldr r0, _0800431C @ =gUnknown_0202BF0C - strh r2, [r0] - ldr r5, _08004320 @ =gMain - ldrh r1, [r5, #0x18] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _0800434C - ldr r0, _08004324 @ =gUnknown_0202C5E8 - strh r2, [r0] - ldr r1, _08004328 @ =gUnknown_0202A1C0 - ldr r0, _0800432C @ =gUnknown_0202ADE0 - movs r3, #0 - ldrsh r0, [r0, r3] - lsls r0, r0, #1 - adds r0, r0, r1 - movs r4, #0 - ldrsh r0, [r0, r4] - cmp r0, #1 - ble _08004344 - ldr r0, _08004330 @ =gUnknown_0202BF04 - strb r6, [r0] - ldr r1, _08004334 @ =0x040000D4 - ldr r0, _08004338 @ =0x06000280 - str r0, [r1] - ldr r0, _0800433C @ =gUnknown_0202A590 - str r0, [r1, #4] - ldr r0, _08004340 @ =0x80000100 - str r0, [r1, #8] - ldr r0, [r1, #8] - movs r0, #3 - b _08004382 - .align 2, 0 -_0800430C: .4byte gUnknown_0202A588 -_08004310: .4byte gUnknown_0202A55C -_08004314: .4byte gUnknown_0202A568 -_08004318: .4byte gUnknown_0201A440 -_0800431C: .4byte gUnknown_0202BF0C -_08004320: .4byte gMain -_08004324: .4byte gUnknown_0202C5E8 -_08004328: .4byte gUnknown_0202A1C0 -_0800432C: .4byte gUnknown_0202ADE0 -_08004330: .4byte gUnknown_0202BF04 -_08004334: .4byte 0x040000D4 -_08004338: .4byte 0x06000280 -_0800433C: .4byte gUnknown_0202A590 -_08004340: .4byte 0x80000100 -_08004344: - movs r0, #0x8a - bl m4aSongNumStart - b _08004384 -_0800434C: - movs r0, #2 - ands r0, r1 - lsls r0, r0, #0x10 - lsrs r4, r0, #0x10 - cmp r4, #0 - beq _08004362 - movs r0, #0x66 - bl m4aSongNumStart - movs r0, #0xc - b _08004382 -_08004362: - movs r0, #8 - ands r0, r1 - cmp r0, #0 - beq _08004384 - movs r0, #0x68 - bl m4aSongNumStart - ldr r0, _080043B4 @ =gUnknown_0202BEC4 - strb r7, [r0] - ldr r0, _080043B8 @ =gUnknown_0202BEFC - strb r6, [r0] - ldr r0, _080043BC @ =gUnknown_0202BF04 - strb r6, [r0] - ldr r0, _080043C0 @ =gUnknown_0202A588 - strh r4, [r0] - movs r0, #6 -_08004382: - strb r0, [r5, #3] -_08004384: - bl sub_4FC8 -_08004388: - ldr r1, _080043C4 @ =gUnknown_0202C58C - ldrh r2, [r1] - movs r3, #0 - ldrsh r0, [r1, r3] - cmp r0, #0 - ble _08004398 - subs r0, r2, #1 - strh r0, [r1] -_08004398: - bl sub_51FC - ldr r1, _080043C8 @ =0x040000D4 - ldr r0, _080043CC @ =gUnknown_03005C00 - str r0, [r1] - movs r0, #0xc0 - lsls r0, r0, #0x13 - str r0, [r1, #4] - ldr r0, _080043D0 @ =0x80000400 - str r0, [r1, #8] - ldr r0, [r1, #8] - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_080043B4: .4byte gUnknown_0202BEC4 -_080043B8: .4byte gUnknown_0202BEFC -_080043BC: .4byte gUnknown_0202BF04 -_080043C0: .4byte gUnknown_0202A588 -_080043C4: .4byte gUnknown_0202C58C -_080043C8: .4byte 0x040000D4 -_080043CC: .4byte gUnknown_03005C00 -_080043D0: .4byte 0x80000400 - thumb_func_start sub_43D4 sub_43D4: @ 0x080043D4 push {lr} diff --git a/src/pokedex.c b/src/pokedex.c index 275d32c..d090c81 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -55,6 +55,17 @@ extern s16 gUnknown_0202A574; void sub_88E4(void); s8 sub_FD20(void); +void sub_4F50(void); +void sub_5174(void); +void sub_4EF0(void); +void sub_4E34(void); +void sub_4D74(void); +void sub_4FC8(void); +void sub_5064(void); +void sub_51CC(void); + +extern u8 gUnknown_0202A590[]; + void PokedexMain(void) { gPokedexStateFuncs[gMain.subState](); @@ -184,3 +195,145 @@ void sub_3FAC(void) { gUnknown_0202A574 = SPECIES_RAYQUAZA + 1; } } + +void sub_4150(void) { + if (gMain.heldKeys & SELECT_BUTTON) + { + gUnknown_0202BF04 = 0; + + if (gMain.heldKeys & DPAD_UP) + { + sub_4D74(); + sub_5064(); + sub_51CC(); + gMain.subState = 2; + } + else if (gMain.heldKeys & DPAD_DOWN) + { + sub_4E34(); + sub_5064(); + sub_51CC(); + gMain.subState = 2; + } + else if (gMain.heldKeys & DPAD_LEFT) + { + sub_4EF0(); + sub_5064(); + sub_51CC(); + gMain.subState = 2; + } + else if (gMain.heldKeys & DPAD_RIGHT) + { + sub_4F50(); + sub_5064(); + sub_51CC(); + gMain.subState = 2; + } + else + { + gUnknown_02019C24 = 0; + sub_5064(); + } + + if (gMain.newKeys & A_BUTTON) + { + gUnknown_0202C5E8 = 0; + + if (gUnknown_0202A1C0[gUnknown_0202ADE0] >= 2) + { + gUnknown_0202BF04 = 0; + DmaCopy16(3, 0x6000280, (void *)gUnknown_0202A590, 0x200); + gMain.subState = 3; + } + else + { + m4aSongNumStart(0x8A); + } + } + } + else + { + gUnknown_0202BF04 = 1; + + if (gMain.heldKeys & DPAD_UP) + { + sub_4D74(); + sub_5174(); + } + else if (gMain.heldKeys & DPAD_DOWN) + { + sub_4E34(); + sub_5174(); + } + else if (gMain.heldKeys & DPAD_LEFT) + { + sub_4EF0(); + sub_5174(); + } + else if (gMain.heldKeys & DPAD_RIGHT) + { + sub_4F50(); + sub_5174(); + } + else + { + gUnknown_02019C24 = 0; + } + + if (sub_8A78(gUnknown_0202ADE0) == 1) + { + gUnknown_0202A588 = 1; + } + else + { + gUnknown_0202A588 = 0; + } + + gUnknown_0202A55C = 1; + gUnknown_0202A568[0] = 0; + gUnknown_0202A568[1] = 0; + gUnknown_0201A440 = 0; + gUnknown_0202BF0C = 0; + + if (gMain.newKeys & A_BUTTON) + { + gUnknown_0202C5E8 = 0; + + if (gUnknown_0202A1C0[gUnknown_0202ADE0] >= 2) + { + gUnknown_0202BF04 = 0; + DmaCopy16(3, 0x6000280, (void *)gUnknown_0202A590, 0x200); + gMain.subState = 3; + } + else + { + m4aSongNumStart(0x8A); + } + } + else if (gMain.newKeys & B_BUTTON) + { + m4aSongNumStart(0x66); + gMain.subState = 12; + } + else if (gMain.newKeys & START_BUTTON) + { + m4aSongNumStart(0x68); + gUnknown_0202BEC4 = 1; + gUnknown_0202BEFC = 0; + gUnknown_0202BF04 = 0; + gUnknown_0202A588 = 0; + gMain.subState = 6; + } + + sub_4FC8(); + } + + if (gUnknown_0202C58C > 0) + { + gUnknown_0202C58C--; + } + + sub_51FC(); + DmaCopy16(3, gUnknown_03005C00, (void *)BG_SCREEN_ADDR(0), BG_SCREEN_SIZE); +} + From 5e961ef256f3db632f8a622e3b0f041a7d3bd55c Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sun, 27 Aug 2023 15:19:42 -0500 Subject: [PATCH 07/12] Stop reporting agbcc code as separate --- .github/calcrom/calcrom.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/calcrom/calcrom.pl b/.github/calcrom/calcrom.pl index 639a03d..06e53d4 100755 --- a/.github/calcrom/calcrom.pl +++ b/.github/calcrom/calcrom.pl @@ -187,8 +187,8 @@ my $total = $src + $lib + $asm; +$src = $src + $lib; my $srcPct = 100 * $src / $total; -my $libPct = 100 * $lib / $total; my $asmPct = 100 * $asm / $total; if ($asm == 0) @@ -199,7 +199,6 @@ { printf "%8d total bytes of code\n", $total; printf "%8d bytes of code in src (%.4f%%)\n", $src, $srcPct; - printf "%8d bytes of code in agbcc libraries (%.4f%%)\n", $lib, $libPct; printf "%8d bytes of code in asm (%.4f%%)\n", $asm, $asmPct; } print "\n"; From 5c00fb721435a1135b328ae4a50c931bbe24599c Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sun, 27 Aug 2023 20:04:16 -0500 Subject: [PATCH 08/12] Decompile sub_43D4 and sub_4428 --- asm/pokedex.s | 209 ------------------------------------- include/gba/m4a_internal.h | 1 + src/pokedex.c | 67 ++++++++++++ 3 files changed, 68 insertions(+), 209 deletions(-) diff --git a/asm/pokedex.s b/asm/pokedex.s index b70d685..cc09fc7 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -4,215 +4,6 @@ .text - thumb_func_start sub_43D4 -sub_43D4: @ 0x080043D4 - push {lr} - bl sub_5174 - ldr r0, _08004410 @ =gUnknown_0202A588 - movs r1, #0 - strh r1, [r0] - ldr r1, _08004414 @ =gUnknown_0202C58C - ldrh r2, [r1] - movs r3, #0 - ldrsh r0, [r1, r3] - cmp r0, #0 - ble _080043F0 - subs r0, r2, #1 - strh r0, [r1] -_080043F0: - bl sub_51FC - ldr r1, _08004418 @ =0x040000D4 - ldr r0, _0800441C @ =gUnknown_03005C00 - str r0, [r1] - movs r0, #0xc0 - lsls r0, r0, #0x13 - str r0, [r1, #4] - ldr r0, _08004420 @ =0x80000400 - str r0, [r1, #8] - ldr r0, [r1, #8] - ldr r1, _08004424 @ =gMain - movs r0, #1 - strb r0, [r1, #3] - pop {r0} - bx r0 - .align 2, 0 -_08004410: .4byte gUnknown_0202A588 -_08004414: .4byte gUnknown_0202C58C -_08004418: .4byte 0x040000D4 -_0800441C: .4byte gUnknown_03005C00 -_08004420: .4byte 0x80000400 -_08004424: .4byte gMain - - thumb_func_start sub_4428 -sub_4428: @ 0x08004428 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - movs r3, #0 - ldr r7, _08004548 @ =gUnknown_0202A558 - ldr r0, _0800454C @ =gUnknown_02019C40 - mov ip, r0 - ldr r1, _08004550 @ =gUnknown_0805C780 - mov sl, r1 - ldr r6, _08004554 @ =gUnknown_0805C7C0 - mov sb, r6 - ldr r0, _08004558 @ =gUnknown_03005C00 - mov r8, r0 - adds r5, r7, #0 - ldr r4, _0800455C @ =gUnknown_0805C840 -_0800444A: - movs r1, #0 - ldrsh r0, [r5, r1] - adds r0, #0xa - lsls r0, r0, #5 - adds r0, r0, r3 - lsls r0, r0, #1 - add r0, r8 - lsls r2, r3, #1 - ldrh r1, [r4] - strh r1, [r0] - movs r6, #0 - ldrsh r0, [r5, r6] - adds r0, #9 - lsls r0, r0, #5 - adds r0, r0, r3 - lsls r0, r0, #1 - ldr r1, _0800454C @ =gUnknown_02019C40 - adds r0, r0, r1 - mov r6, sl - adds r1, r2, r6 - ldrh r1, [r1] - strh r1, [r0] - movs r1, #0 - ldrsh r0, [r5, r1] - adds r0, #0xa - lsls r0, r0, #5 - adds r0, r0, r3 - lsls r0, r0, #1 - ldr r6, _0800454C @ =gUnknown_02019C40 - adds r0, r0, r6 - add r2, sb - ldrh r1, [r2] - strh r1, [r0] - adds r4, #2 - adds r3, #1 - cmp r3, #0x1f - ble _0800444A - ldrh r0, [r7] - adds r0, #1 - strh r0, [r7] - movs r1, #0x9a - lsls r1, r1, #2 - add r1, ip - movs r4, #0 - movs r3, #0 - movs r0, #0x59 - strh r0, [r1] - ldr r2, _08004560 @ =0x040000D4 - ldr r0, _08004558 @ =gUnknown_03005C00 - str r0, [r2] - movs r0, #0xc0 - lsls r0, r0, #0x13 - str r0, [r2, #4] - ldr r1, _08004564 @ =0x80000400 - str r1, [r2, #8] - ldr r0, [r2, #8] - mov r6, ip - str r6, [r2] - ldr r0, _08004568 @ =0x06000800 - str r0, [r2, #4] - str r1, [r2, #8] - ldr r0, [r2, #8] - movs r1, #0 - ldrsh r0, [r7, r1] - cmp r0, #7 - ble _08004538 - strh r3, [r7] - ldr r0, _0800456C @ =gUnknown_0202C5E8 - strh r3, [r0] - ldr r0, _08004570 @ =gUnknown_0202BEF4 - strh r3, [r0] - ldr r0, _08004574 @ =gUnknown_02019C28 - strb r4, [r0] - ldr r0, _08004578 @ =gUnknown_0202C5AC - strb r4, [r0] - ldr r4, _0800457C @ =gUnknown_0202ADE0 - movs r6, #0 - ldrsh r0, [r4, r6] - cmp r0, #0xc8 - bgt _080044F0 - ldr r1, _08004580 @ =gUnknown_0201C1B4 - movs r0, #1 - strb r0, [r1] -_080044F0: - ldr r0, _08004584 @ =gUnknown_08086B40 - str r0, [r2] - ldr r0, _08004588 @ =0x06000280 - str r0, [r2, #4] - ldr r0, _0800458C @ =0x800000E0 - str r0, [r2, #8] - ldr r0, [r2, #8] - movs r1, #0 - ldrsh r0, [r4, r1] - ldr r1, _08004590 @ =gUnknown_0202C794 - ldrb r1, [r1] - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - bl sub_70E0 - ldr r0, _08004594 @ =gMPlayInfo_BGM - ldr r1, _08004598 @ =0x0000FFFF - movs r2, #0x40 - bl m4aMPlayVolumeControl - ldr r2, _0800459C @ =gUnknown_086A3700 - movs r6, #0 - ldrsh r1, [r4, r6] - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #3 - adds r0, r0, r2 - ldrh r0, [r0] - movs r1, #0 - movs r2, #0x7f - movs r3, #0xa - bl sub_5291C - ldr r1, _080045A0 @ =gMain - movs r0, #5 - strb r0, [r1, #3] -_08004538: - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08004548: .4byte gUnknown_0202A558 -_0800454C: .4byte gUnknown_02019C40 -_08004550: .4byte gUnknown_0805C780 -_08004554: .4byte gUnknown_0805C7C0 -_08004558: .4byte gUnknown_03005C00 -_0800455C: .4byte gUnknown_0805C840 -_08004560: .4byte 0x040000D4 -_08004564: .4byte 0x80000400 -_08004568: .4byte 0x06000800 -_0800456C: .4byte gUnknown_0202C5E8 -_08004570: .4byte gUnknown_0202BEF4 -_08004574: .4byte gUnknown_02019C28 -_08004578: .4byte gUnknown_0202C5AC -_0800457C: .4byte gUnknown_0202ADE0 -_08004580: .4byte gUnknown_0201C1B4 -_08004584: .4byte gUnknown_08086B40 -_08004588: .4byte 0x06000280 -_0800458C: .4byte 0x800000E0 -_08004590: .4byte gUnknown_0202C794 -_08004594: .4byte gMPlayInfo_BGM -_08004598: .4byte 0x0000FFFF -_0800459C: .4byte gUnknown_086A3700 -_080045A0: .4byte gMain - thumb_func_start sub_45A4 sub_45A4: @ 0x080045A4 push {r4, r5, r6, lr} diff --git a/include/gba/m4a_internal.h b/include/gba/m4a_internal.h index 0bd6ed7..d04e874 100644 --- a/include/gba/m4a_internal.h +++ b/include/gba/m4a_internal.h @@ -285,6 +285,7 @@ struct MusicPlayerTrack #define MUSICPLAYER_STATUS_PAUSE 0x80000000 #define MAX_MUSICPLAYER_TRACKS 16 +#define TRACKS_ALL 0xFFFF #define TEMPORARY_FADE 0x0001 #define FADE_IN 0x0002 diff --git a/src/pokedex.c b/src/pokedex.c index d090c81..566d39b 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -66,6 +66,22 @@ void sub_51CC(void); extern u8 gUnknown_0202A590[]; +extern u16 gUnknown_08086B40[]; + +void sub_70E0(s16, s32); + +extern void sub_5291C(u16, s8, s8, u8); + +struct Unk086A3700 { + u16 unk0; + u8 unk2[0x16]; +}; + +extern struct Unk086A3700 gUnknown_086A3700[]; +extern u16 gUnknown_0805C840[]; +extern u16 gUnknown_0805C780[]; +extern u16 gUnknown_0805C7C0[]; + void PokedexMain(void) { gPokedexStateFuncs[gMain.subState](); @@ -337,3 +353,54 @@ void sub_4150(void) { DmaCopy16(3, gUnknown_03005C00, (void *)BG_SCREEN_ADDR(0), BG_SCREEN_SIZE); } +void sub_43D4(void) { + sub_5174(); + gUnknown_0202A588 = 0; + + if (gUnknown_0202C58C > 0) + { + gUnknown_0202C58C--; + } + + sub_51FC(); + DmaCopy16(3, gUnknown_03005C00, (void *)BG_SCREEN_ADDR(0), BG_SCREEN_SIZE); + gMain.subState = 1; +} + +void sub_4428(void) { + s32 i; + + for (i = 0; i < 0x20; i++) + { + gUnknown_03005C00[0x20*(gUnknown_0202A558 + 10) + i] = gUnknown_0805C840[i]; + gUnknown_02019C40[0x20*(gUnknown_0202A558 + 9) + i] = gUnknown_0805C780[i]; + gUnknown_02019C40[0x20*(gUnknown_0202A558 + 10) + i] = gUnknown_0805C7C0[i]; + } + + gUnknown_0202A558++; + gUnknown_02019C40[0x134] = 0x59; + DmaCopy16(3, gUnknown_03005C00, (void *)BG_SCREEN_ADDR(0), BG_SCREEN_SIZE); + DmaCopy16(3, gUnknown_02019C40, (void *)BG_SCREEN_ADDR(1), BG_SCREEN_SIZE); + + if (gUnknown_0202A558 > 7) + { + gUnknown_0202A558 = 0; + gUnknown_0202C5E8 = 0; + gUnknown_0202BEF4 = 0; + gUnknown_02019C28 = 0; + gUnknown_0202C5AC = 0; + + if (gUnknown_0202ADE0 < BONUS_SPECIES_START) { + gUnknown_0201C1B4 = 1; + } + + DmaCopy16(3, gUnknown_08086B40, (void *)0x6000280, 2*0xE0); + sub_70E0(gUnknown_0202ADE0, gUnknown_0202C794); + m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x40); + sub_5291C(gUnknown_086A3700[gUnknown_0202ADE0].unk0, 0, 0x7F, 10); + gMain.subState = 5; + } + +} + + From dc1ddf68a6f2cc0757e3556923e08e13c887d717 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sun, 27 Aug 2023 21:48:44 -0500 Subject: [PATCH 09/12] Decompile sub_45A4 --- asm/pokedex.s | 317 -------------------------------------------------- src/pokedex.c | 134 +++++++++++++++++++++ 2 files changed, 134 insertions(+), 317 deletions(-) diff --git a/asm/pokedex.s b/asm/pokedex.s index cc09fc7..b7a50f0 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -4,323 +4,6 @@ .text - thumb_func_start sub_45A4 -sub_45A4: @ 0x080045A4 - push {r4, r5, r6, lr} - ldr r1, _08004620 @ =gUnknown_0202C5E8 - ldrh r2, [r1] - movs r3, #0 - ldrsh r0, [r1, r3] - cmp r0, #0x50 - bgt _080045CA - adds r0, r2, #1 - strh r0, [r1] - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - cmp r0, #0x50 - bne _080045CA - ldr r0, _08004624 @ =gMPlayInfo_BGM - ldr r1, _08004628 @ =0x0000FFFF - movs r2, #0x80 - lsls r2, r2, #1 - bl m4aMPlayVolumeControl -_080045CA: - ldr r1, _0800462C @ =gUnknown_0202BEF4 - ldrh r0, [r1] - adds r0, #1 - strh r0, [r1] - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - cmp r0, #0x1e - ble _080045E8 - movs r0, #0 - strh r0, [r1] - ldr r2, _08004630 @ =gUnknown_0202C5AC - ldrb r1, [r2] - movs r0, #1 - subs r0, r0, r1 - strb r0, [r2] -_080045E8: - ldr r0, _08004634 @ =gUnknown_0202BE20 - movs r6, #0 - strh r6, [r0] - ldr r0, _08004638 @ =gMain - ldrh r1, [r0, #0x18] - movs r0, #0x40 - ands r0, r1 - cmp r0, #0 - beq _08004644 - ldr r5, _0800463C @ =gUnknown_0202ADE0 - movs r1, #0 - ldrsh r0, [r5, r1] - cmp r0, #0xc8 - bgt _0800467A - ldr r4, _08004640 @ =gUnknown_0202C794 - movs r0, #0 - ldrsb r0, [r4, r0] - cmp r0, #1 - bne _0800467A - movs r0, #0x6d - bl m4aSongNumStart - strb r6, [r4] - movs r2, #0 - ldrsh r0, [r5, r2] - movs r1, #0 - b _08004670 - .align 2, 0 -_08004620: .4byte gUnknown_0202C5E8 -_08004624: .4byte gMPlayInfo_BGM -_08004628: .4byte 0x0000FFFF -_0800462C: .4byte gUnknown_0202BEF4 -_08004630: .4byte gUnknown_0202C5AC -_08004634: .4byte gUnknown_0202BE20 -_08004638: .4byte gMain -_0800463C: .4byte gUnknown_0202ADE0 -_08004640: .4byte gUnknown_0202C794 -_08004644: - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _0800467A - ldr r5, _080046BC @ =gUnknown_0202ADE0 - movs r3, #0 - ldrsh r0, [r5, r3] - cmp r0, #0xc8 - bgt _0800467A - ldr r4, _080046C0 @ =gUnknown_0202C794 - movs r0, #0 - ldrsb r0, [r4, r0] - cmp r0, #0 - bne _0800467A - movs r0, #0x6d - bl m4aSongNumStart - movs r0, #1 - strb r0, [r4] - movs r1, #0 - ldrsh r0, [r5, r1] - movs r1, #1 -_08004670: - bl sub_70E0 - ldr r1, _080046C4 @ =gUnknown_02019C28 - ldrb r0, [r4] - strb r0, [r1] -_0800467A: - ldr r6, _080046C8 @ =gMain - ldrh r1, [r6, #0x18] - movs r4, #1 - ands r4, r1 - cmp r4, #0 - beq _08004700 - ldr r5, _080046BC @ =gUnknown_0202ADE0 - movs r2, #0 - ldrsh r0, [r5, r2] - cmp r0, #0xc8 - bgt _08004730 - ldr r4, _080046C0 @ =gUnknown_0202C794 - movs r0, #0 - ldrsb r0, [r4, r0] - cmp r0, #0 - bne _080046CC - movs r0, #0x6d - bl m4aSongNumStart - ldrb r1, [r4] - movs r0, #1 - subs r0, r0, r1 - strb r0, [r4] - movs r3, #0 - ldrsh r0, [r5, r3] - movs r1, #0 - ldrsb r1, [r4, r1] - bl sub_70E0 - ldr r1, _080046C4 @ =gUnknown_02019C28 - ldrb r0, [r4] - strb r0, [r1] - b _08004730 - .align 2, 0 -_080046BC: .4byte gUnknown_0202ADE0 -_080046C0: .4byte gUnknown_0202C794 -_080046C4: .4byte gUnknown_02019C28 -_080046C8: .4byte gMain -_080046CC: - movs r0, #0x69 - bl m4aSongNumStart - ldr r0, _080046F0 @ =gMPlayInfo_BGM - ldr r1, _080046F4 @ =0x0000FFFF - movs r2, #0x80 - lsls r2, r2, #1 - bl m4aMPlayVolumeControl - movs r0, #0 - strb r0, [r4] - ldr r0, _080046F8 @ =gUnknown_0202C5E8 - movs r1, #0 - strh r1, [r0] - ldr r0, _080046FC @ =gUnknown_0202BEF4 - strh r1, [r0] - b _08004728 - .align 2, 0 -_080046F0: .4byte gMPlayInfo_BGM -_080046F4: .4byte 0x0000FFFF -_080046F8: .4byte gUnknown_0202C5E8 -_080046FC: .4byte gUnknown_0202BEF4 -_08004700: - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _08004730 - movs r0, #0x69 - bl m4aSongNumStart - ldr r0, _0800476C @ =gMPlayInfo_BGM - ldr r1, _08004770 @ =0x0000FFFF - movs r2, #0x80 - lsls r2, r2, #1 - bl m4aMPlayVolumeControl - ldr r0, _08004774 @ =gUnknown_0202C794 - strb r4, [r0] - ldr r0, _08004778 @ =gUnknown_0202C5E8 - movs r1, #0 - strh r4, [r0] - ldr r0, _0800477C @ =gUnknown_0202BEF4 - strh r4, [r0] -_08004728: - ldr r0, _08004780 @ =gUnknown_0201C1B4 - strb r1, [r0] - movs r0, #4 - strb r0, [r6, #3] -_08004730: - ldr r0, _08004784 @ =gMain - ldrh r1, [r0, #0x1c] - movs r0, #4 - ands r0, r1 - lsls r0, r0, #0x10 - lsrs r4, r0, #0x10 - cmp r4, #0 - beq _08004808 - ldr r1, _08004788 @ =gUnknown_0202A1C0 - ldr r0, _0800478C @ =gUnknown_0202ADE0 - movs r2, #0 - ldrsh r0, [r0, r2] - lsls r2, r0, #1 - adds r1, r2, r1 - movs r3, #0 - ldrsh r0, [r1, r3] - cmp r0, #4 - bne _080047E4 - ldr r0, _08004790 @ =gUnknown_086A61BC - adds r0, r2, r0 - movs r2, #0 - ldrsh r1, [r0, r2] - movs r0, #1 - rsbs r0, r0, #0 - cmp r1, r0 - bne _08004798 - ldr r1, _08004794 @ =gUnknown_0202A588 - movs r0, #0 - strh r0, [r1] - b _0800482C - .align 2, 0 -_0800476C: .4byte gMPlayInfo_BGM -_08004770: .4byte 0x0000FFFF -_08004774: .4byte gUnknown_0202C794 -_08004778: .4byte gUnknown_0202C5E8 -_0800477C: .4byte gUnknown_0202BEF4 -_08004780: .4byte gUnknown_0201C1B4 -_08004784: .4byte gMain -_08004788: .4byte gUnknown_0202A1C0 -_0800478C: .4byte gUnknown_0202ADE0 -_08004790: .4byte gUnknown_086A61BC -_08004794: .4byte gUnknown_0202A588 -_08004798: - cmp r1, #0x63 - bgt _080047C0 - ldr r0, _080047B4 @ =gUnknown_0202A588 - movs r1, #0 - strh r1, [r0] - ldr r0, _080047B8 @ =gUnknown_0202A55C - strh r1, [r0] - ldr r1, _080047BC @ =gUnknown_0202A568 - movs r2, #0 - movs r0, #1 - strh r0, [r1] - strh r2, [r1, #2] - b _08004842 - .align 2, 0 -_080047B4: .4byte gUnknown_0202A588 -_080047B8: .4byte gUnknown_0202A55C -_080047BC: .4byte gUnknown_0202A568 -_080047C0: - ldr r0, _080047D8 @ =gUnknown_0202A588 - movs r1, #0 - strh r1, [r0] - ldr r0, _080047DC @ =gUnknown_0202A55C - strh r1, [r0] - ldr r1, _080047E0 @ =gUnknown_0202A568 - movs r0, #0 - strh r0, [r1] - movs r0, #1 - strh r0, [r1, #2] - b _08004842 - .align 2, 0 -_080047D8: .4byte gUnknown_0202A588 -_080047DC: .4byte gUnknown_0202A55C -_080047E0: .4byte gUnknown_0202A568 -_080047E4: - ldr r1, _080047FC @ =gUnknown_0202A588 - movs r0, #0 - strh r0, [r1] - ldr r1, _08004800 @ =gUnknown_0202A55C - movs r0, #1 - strh r0, [r1] - ldr r1, _08004804 @ =gUnknown_0202A568 - movs r0, #0 - strh r0, [r1] - strh r0, [r1, #2] - b _08004842 - .align 2, 0 -_080047FC: .4byte gUnknown_0202A588 -_08004800: .4byte gUnknown_0202A55C -_08004804: .4byte gUnknown_0202A568 -_08004808: - ldr r0, _08004820 @ =gUnknown_0202ADE0 - movs r3, #0 - ldrsh r0, [r0, r3] - bl sub_8A78 - lsls r0, r0, #0x10 - asrs r1, r0, #0x10 - cmp r1, #1 - bne _08004828 - ldr r0, _08004824 @ =gUnknown_0202A588 - strh r1, [r0] - b _0800482C - .align 2, 0 -_08004820: .4byte gUnknown_0202ADE0 -_08004824: .4byte gUnknown_0202A588 -_08004828: - ldr r0, _0800484C @ =gUnknown_0202A588 - strh r4, [r0] -_0800482C: - ldr r1, _08004850 @ =gUnknown_0202A55C - movs r0, #1 - strh r0, [r1] - ldr r0, _08004854 @ =gUnknown_0202A568 - movs r1, #0 - strh r1, [r0] - strh r1, [r0, #2] - ldr r0, _08004858 @ =gUnknown_0201A440 - strh r1, [r0] - ldr r0, _0800485C @ =gUnknown_0202BF0C - strh r1, [r0] -_08004842: - bl sub_51FC - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_0800484C: .4byte gUnknown_0202A588 -_08004850: .4byte gUnknown_0202A55C -_08004854: .4byte gUnknown_0202A568 -_08004858: .4byte gUnknown_0201A440 -_0800485C: .4byte gUnknown_0202BF0C - thumb_func_start sub_4860 sub_4860: @ 0x08004860 push {r4, r5, r6, r7, lr} diff --git a/src/pokedex.c b/src/pokedex.c index 566d39b..5e3e05e 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -82,6 +82,8 @@ extern u16 gUnknown_0805C840[]; extern u16 gUnknown_0805C780[]; extern u16 gUnknown_0805C7C0[]; +extern s16 gUnknown_086A61BC[]; + void PokedexMain(void) { gPokedexStateFuncs[gMain.subState](); @@ -403,4 +405,136 @@ void sub_4428(void) { } +void sub_45A4(void) { + u16 var0; + + if (gUnknown_0202C5E8 < 0x51) + { + gUnknown_0202C5E8++; + if (gUnknown_0202C5E8 == 0x50) + { + m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100); + } + } + gUnknown_0202BEF4 = gUnknown_0202BEF4 + 1; + if (0x1e < gUnknown_0202BEF4) + { + gUnknown_0202BEF4 = 0; + gUnknown_0202C5AC = 1 - gUnknown_0202C5AC; + } + gUnknown_0202BE20 = 0; + + if (gMain.newKeys & DPAD_UP) + { + if ((gUnknown_0202ADE0 < BONUS_SPECIES_START) && (gUnknown_0202C794 == 1)) + { + m4aSongNumStart(0x6D); + gUnknown_0202C794 = 0; + sub_70E0(gUnknown_0202ADE0, 0); + gUnknown_02019C28 = gUnknown_0202C794; + } + } + else if (gMain.newKeys & DPAD_DOWN) + { + if ((gUnknown_0202ADE0 < BONUS_SPECIES_START) && (gUnknown_0202C794 == 0)) + { + m4aSongNumStart(0x6D); + gUnknown_0202C794 = 1; + sub_70E0(gUnknown_0202ADE0, 1); + gUnknown_02019C28 = gUnknown_0202C794; + } + } + + if (gMain.newKeys & A_BUTTON) + { + if (gUnknown_0202ADE0 < BONUS_SPECIES_START) + { + if (!gUnknown_0202C794) + { + m4aSongNumStart(0x6D); + gUnknown_0202C794 = 1 - gUnknown_0202C794; + sub_70E0(gUnknown_0202ADE0,gUnknown_0202C794); + gUnknown_02019C28 = gUnknown_0202C794; + } + else + { + m4aSongNumStart(0x69); + m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100); + gUnknown_0202C794 = 0; + gUnknown_0202C5E8 = 0; + gUnknown_0202BEF4 = gUnknown_0202C5E8; + gUnknown_0201C1B4 = 0; + gMain.subState = 4; + } + } + } + else if (gMain.newKeys & B_BUTTON) + { + m4aSongNumStart(0x69); + m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100); + gUnknown_0202C794 = 0; + gUnknown_0202C5E8 = 0; + gUnknown_0202BEF4 = gUnknown_0202C5E8; + gUnknown_0201C1B4 = 0; + gMain.subState = 4; + } + + if (gMain.heldKeys & SELECT_BUTTON) + { + if (gUnknown_0202A1C0[gUnknown_0202ADE0] == 4) + { + if (gUnknown_086A61BC[gUnknown_0202ADE0] == -1) + { + gUnknown_0202A588 = 0; + gUnknown_0202A55C = 1; + gUnknown_0202A568[0] = 0; + gUnknown_0202A568[1] = 0; + gUnknown_0201A440 = 0; + gUnknown_0202BF0C = 0; + } + else + { + if (gUnknown_086A61BC[gUnknown_0202ADE0] < 100) + { + gUnknown_0202A588 = 0; + gUnknown_0202A55C = 0; + gUnknown_0202A568[0] = 1; + gUnknown_0202A568[1] = 0; + } + else + { + gUnknown_0202A588 = 0; + gUnknown_0202A55C = 0; + gUnknown_0202A568[0] = 0; + gUnknown_0202A568[1] = 1; + } + } + } + else + { + gUnknown_0202A588 = 0; + gUnknown_0202A55C = 1; + gUnknown_0202A568[0] = 0; + gUnknown_0202A568[1] = 0; + } + } + else + { + if (sub_8A78(gUnknown_0202ADE0) == 1) + { + gUnknown_0202A588 = 1; + } + else + { + gUnknown_0202A588 = 0; + } + + gUnknown_0202A55C = 1; + gUnknown_0202A568[0] = 0; + gUnknown_0202A568[1] = 0; + gUnknown_0201A440 = 0; + gUnknown_0202BF0C = 0; + } + sub_51FC(); +} From 50fe6f31480b0017d25f1b57e3baf08bcac38687 Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Sun, 27 Aug 2023 22:01:02 -0500 Subject: [PATCH 10/12] Update main.c Apparently it matched already? --- src/main.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/src/main.c b/src/main.c index e58bfc1..bb07c01 100644 --- a/src/main.c +++ b/src/main.c @@ -181,7 +181,6 @@ u32 Random(void) return gMain.rngValue & 0xFFFF; } -#ifdef NONMATCHING s16 sub_0C24(u16 arg0) { u16 index = arg0 / 4; @@ -197,51 +196,6 @@ s16 sub_0C24(u16 arg0) return gUnknown_08055C44[index] * var0; } -#else -NAKED -s16 sub_0C24(u16 arg0) -{ - asm_unified("\n\ - lsls r0, r0, #0x10\n\ - lsrs r2, r0, #0x12\n\ - movs r3, #1\n\ - ldr r0, _08000C60 @ =0x00001FFF\n\ - cmp r2, r0\n\ - bls _08000C3A\n\ - ldr r1, _08000C64 @ =0xFFFFE000\n\ - adds r0, r2, r1\n\ - lsls r0, r0, #0x10\n\ - lsrs r2, r0, #0x10\n\ - ldr r3, _08000C68 @ =0x0000FFFF\n\ -_08000C3A:\n\ - ldr r0, _08000C6C @ =0x00000FFF\n\ - cmp r2, r0\n\ - bls _08000C4C\n\ - movs r1, #0x80\n\ - lsls r1, r1, #6\n\ - adds r0, r1, #0\n\ - subs r0, r0, r2\n\ - lsls r0, r0, #0x10\n\ - lsrs r2, r0, #0x10\n\ -_08000C4C:\n\ - ldr r1, _08000C70 @ =0x08055C44\n\ - lsls r0, r2, #1\n\ - adds r0, r0, r1\n\ - ldrh r1, [r0]\n\ - lsls r0, r3, #0x10\n\ - asrs r0, r0, #0x10\n\ - muls r0, r1, r0\n\ - lsls r0, r0, #0x10\n\ - asrs r0, r0, #0x10\n\ - bx lr\n\ - .align 2, 0\n\ -_08000C60: .4byte 0x00001FFF\n\ -_08000C64: .4byte 0xFFFFE000\n\ -_08000C68: .4byte 0x0000FFFF\n\ -_08000C6C: .4byte 0x00000FFF\n\ -_08000C70: .4byte 0x08055C44"); -} -#endif // NONMATCHING s16 sub_0C74(u16 arg0) { From 9826f3f3d7033b12f23193b575c6f2928bdf733a Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:54:57 -0500 Subject: [PATCH 11/12] Work on NONMATCHING --- include/global.h | 2 +- src/rom_3219C.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/global.h b/include/global.h index 130b963..58c9104 100644 --- a/include/global.h +++ b/include/global.h @@ -117,7 +117,7 @@ struct PinballGame /*0x598*/ u16 unk598; // Current catch/hatch mode species? Is it evo mode as well? /*0x59A*/ u8 filler59A[0x2]; /*0x59C*/ u16 unk59C; // Previous catch mode species? - /*0x59E*/ u16 unk59E; // Previous hatch mode species? + /*0x59E*/ u16 unk59E; // Previous hatch/evo mode species? /*0x5A0*/ u8 filler5A0[0x50]; /*0x5F0*/ u16 unk5F0; /*0x5F2*/ u8 filler5F2[0x5]; diff --git a/src/rom_3219C.c b/src/rom_3219C.c index 31181d9..9cc2ae9 100644 --- a/src/rom_3219C.c +++ b/src/rom_3219C.c @@ -388,7 +388,6 @@ void sub_327C0(void) sub_31498(); } - // TODO: if this is a fake match, it will take a braver one than I to fix it. if (gUnknown_020314E0->unk13 < 3) { if ((gUnknown_020314E0->unk344 & 0xFFFF00) == 0x300) From 6884a5c123a28164f6fd84803f3ddc7b68c64edf Mon Sep 17 00:00:00 2001 From: WhenGryphonsFly <84215159+WhenGryphonsFly@users.noreply.github.com> Date: Wed, 30 Aug 2023 22:27:34 -0500 Subject: [PATCH 12/12] Clean up --- include/functions.h | 4 +-- include/types.h | 9 ++++++ include/variables.h | 57 ++++++++++++++++++++++++++++++++++ src/pokedex.c | 75 +++------------------------------------------ src/pokedex_end.c | 2 +- 5 files changed, 73 insertions(+), 74 deletions(-) diff --git a/include/functions.h b/include/functions.h index 342657d..2e2c37c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -165,7 +165,7 @@ extern void sub_F6E0(void); //extern ? sub_F74C(); //extern ? sub_F8B0(); //extern ? sub_FAE8(); -//extern ? sub_FD20(); +extern s8 sub_FD20(void); extern void sub_FD5C(void (*func)(void)); extern void sub_FE04(void (*func)(void)); //extern ? sub_FEB8(); @@ -772,7 +772,7 @@ extern void sub_4F814(); //extern ? sub_528AC(); //extern ? sub_528DC(); -//extern ? sub_5291C(); +extern void sub_5291C(u16, s8, s8, u8); //extern ? sub_52940(); extern void SaveFile_LoadGameData(void); //extern ? LoadSaveDataFromSram(); diff --git a/include/types.h b/include/types.h index e43b6dc..42c7fa9 100644 --- a/include/types.h +++ b/include/types.h @@ -40,4 +40,13 @@ struct Coord16 u16 y; }; +struct PokemonSpecies { + u16 mainSeriesIndexNumber; // Refers to the generation three internal index number; e.g. Treecko is 0x115 (decimal 227). + u8 unk2[0x5]; + u8 name[10]; + u8 unk11[0x4]; + u8 evolutionTarget; // Uses the standard index numbers; e.g. Treecko is 0x00 (SPECIES_TREECKO) + u8 unk16[0x2]; +}; + #endif // GUARD_TYPES_H diff --git a/include/variables.h b/include/variables.h index c348882..dacdb7b 100644 --- a/include/variables.h +++ b/include/variables.h @@ -188,4 +188,61 @@ extern struct Coord16 gUnknown_086A9694[]; extern struct Coord16 gUnknown_086A96AC[]; extern struct Coord16 gUnknown_086A96C0[]; +extern u16 gUnknown_02019C40[]; +extern s16 gUnknown_0201A514; +extern s16 gUnknown_0202ADE0; +extern s16 gUnknown_0202BEB8; +extern s16 gUnknown_0202C5B0; + +extern StateFunc gPokedexStateFuncs[]; +extern u16 gUnknown_08081F20[]; +extern u16 gUnknown_08082720[]; +extern u16 gUnknown_08087340[]; +extern u16 gUnknown_08087B40[]; +extern u16 gUnknown_08088F60[]; +extern u16 gUnknown_08089760[]; +extern u8 gUnknown_08089960[]; +extern u8 gUnknown_08089B60[]; + +extern s16 gUnknown_0201A448; +extern s16 gUnknown_0202BF00; +extern s16 gUnknown_0202A57C; +extern s16 gUnknown_0201A4F0; +extern s16 gUnknown_0202BE20; +extern s16 gUnknown_0202C58C; +extern s8 gUnknown_02019C24; +extern s16 gUnknown_0202BF0C; +extern s16 gUnknown_0201A440; +extern s16 gUnknown_0202BEF4; +extern s16 gUnknown_0202A588; +extern s16 gUnknown_0202A55C; +extern s16 gUnknown_0202A568[2]; +extern s16 gUnknown_0202C5E8; +extern s16 gUnknown_0202A558; +extern s8 gUnknown_0202BEE0; +extern s8 gUnknown_0202BF04; +extern s16 gUnknown_0202BF14; +extern s8 gUnknown_0202C590; +extern s16 gUnknown_0201B120; +extern s8 gUnknown_0202BEC4; +extern s8 gUnknown_0202BEFC; +extern s8 gUnknown_02002830; +extern s8 gUnknown_02002831; +extern s8 gUnknown_0202C794; +extern s8 gUnknown_0201C1B4; +extern s8 gUnknown_0202C5AC; +extern s8 gUnknown_02019C28; +extern s16 gUnknown_0202A1C0[]; +extern s16 gUnknown_0202A390[]; +extern s16 gUnknown_0202A574; + +extern u16 gUnknown_0805C840[]; +extern u16 gUnknown_0805C780[]; +extern u16 gUnknown_0805C7C0[]; +extern u8 gUnknown_0202A590[]; +extern u16 gUnknown_08086B40[]; +extern s16 gUnknown_086A61BC[]; + +extern struct PokemonSpecies gUnknown_086A3700[]; + #endif // GUARD_VARIABLES_H diff --git a/src/pokedex.c b/src/pokedex.c index 5e3e05e..6de4d15 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -3,57 +3,8 @@ #include "functions.h" #include "m4a.h" #include "main.h" - -extern u16 gUnknown_02019C40[]; -extern s16 gUnknown_0201A514; -extern s16 gUnknown_0202ADE0; -extern s16 gUnknown_0202BEB8; -extern s16 gUnknown_0202C5B0; - -extern StateFunc gPokedexStateFuncs[]; -extern u16 gUnknown_08081F20[]; -extern u16 gUnknown_08082720[]; -extern u16 gUnknown_08087340[]; -extern u16 gUnknown_08087B40[]; -extern u16 gUnknown_08088F60[]; -extern u16 gUnknown_08089760[]; -extern u16 gUnknown_08089960[]; -extern u16 gUnknown_08089B60[]; - -extern s16 gUnknown_0201A448; -extern s16 gUnknown_0202BF00; -extern s16 gUnknown_0202A57C; -extern s16 gUnknown_0201A4F0; -extern s16 gUnknown_0202BE20; -extern s16 gUnknown_0202C58C; -extern s8 gUnknown_02019C24; -extern s16 gUnknown_0202BF0C; -extern s16 gUnknown_0201A440; -extern s16 gUnknown_0202BEF4; -extern s16 gUnknown_0202A588; -extern s16 gUnknown_0202A55C; -extern s16 gUnknown_0202A568[2]; -extern s16 gUnknown_0202C5E8; -extern s16 gUnknown_0202A558; -extern s8 gUnknown_0202BEE0; -extern s8 gUnknown_0202BF04; -extern s16 gUnknown_0202BF14; -extern s8 gUnknown_0202C590; -extern s16 gUnknown_0201B120; -extern s8 gUnknown_0202BEC4; -extern s8 gUnknown_0202BEFC; -extern s8 gUnknown_02002830; -extern s8 gUnknown_02002831; -extern s8 gUnknown_0202C794; -extern s8 gUnknown_0201C1B4; -extern s8 gUnknown_0202C5AC; -extern s8 gUnknown_02019C28; -extern s16 gUnknown_0202A1C0[]; -extern s16 gUnknown_0202A390[]; -extern s16 gUnknown_0202A574; - -void sub_88E4(void); -s8 sub_FD20(void); +#include "types.h" +#include "variables.h" void sub_4F50(void); void sub_5174(void); @@ -63,26 +14,8 @@ void sub_4D74(void); void sub_4FC8(void); void sub_5064(void); void sub_51CC(void); - -extern u8 gUnknown_0202A590[]; - -extern u16 gUnknown_08086B40[]; - void sub_70E0(s16, s32); - -extern void sub_5291C(u16, s8, s8, u8); - -struct Unk086A3700 { - u16 unk0; - u8 unk2[0x16]; -}; - -extern struct Unk086A3700 gUnknown_086A3700[]; -extern u16 gUnknown_0805C840[]; -extern u16 gUnknown_0805C780[]; -extern u16 gUnknown_0805C7C0[]; - -extern s16 gUnknown_086A61BC[]; +void sub_88E4(void); void PokedexMain(void) { @@ -399,7 +332,7 @@ void sub_4428(void) { DmaCopy16(3, gUnknown_08086B40, (void *)0x6000280, 2*0xE0); sub_70E0(gUnknown_0202ADE0, gUnknown_0202C794); m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x40); - sub_5291C(gUnknown_086A3700[gUnknown_0202ADE0].unk0, 0, 0x7F, 10); + sub_5291C(gUnknown_086A3700[gUnknown_0202ADE0].mainSeriesIndexNumber, 0, 0x7F, 10); gMain.subState = 5; } diff --git a/src/pokedex_end.c b/src/pokedex_end.c index 1895931..4b34265 100644 --- a/src/pokedex_end.c +++ b/src/pokedex_end.c @@ -3,7 +3,7 @@ extern s16 gUnknown_0202A1C0[]; extern s16 gUnknown_0202A588; -extern s32 gUnknown_0202BF14; +extern s16 gUnknown_0202BF14; extern s16 gUnknown_086A61BC[];