diff --git a/asm/high_scores.s b/asm/high_scores.s index 5fb92fe..eddc470 100644 --- a/asm/high_scores.s +++ b/asm/high_scores.s @@ -7,7 +7,7 @@ thumb_func_start HighScoresMain HighScoresMain: @ 0x0800CE48 push {lr} - ldr r1, _0800CE60 @ =gUnknown_080793E8 + ldr r1, _0800CE60 @ =gHighScoresStateFuncs ldr r0, _0800CE64 @ =gMain ldrb r0, [r0, #3] lsls r0, r0, #2 @@ -17,14 +17,14 @@ HighScoresMain: @ 0x0800CE48 pop {r0} bx r0 .align 2, 0 -_0800CE60: .4byte gUnknown_080793E8 +_0800CE60: .4byte gHighScoresStateFuncs _0800CE64: .4byte gMain @ This is triggered after the idle pinball game catches its first pokemon thumb_func_start IdleHighScoresMain IdleHighScoresMain: @ 0x0800CE68 push {lr} - ldr r1, _0800CE80 @ =gUnknown_08079424 + ldr r1, _0800CE80 @ =gIdleHighScoresStateFuncs ldr r0, _0800CE84 @ =gMain ldrb r0, [r0, #3] lsls r0, r0, #2 @@ -34,7 +34,7 @@ IdleHighScoresMain: @ 0x0800CE68 pop {r0} bx r0 .align 2, 0 -_0800CE80: .4byte gUnknown_08079424 +_0800CE80: .4byte gIdleHighScoresStateFuncs _0800CE84: .4byte gMain thumb_func_start sub_CE88 diff --git a/asm/intro.s b/asm/intro.s index 6fec002..738b94e 100644 --- a/asm/intro.s +++ b/asm/intro.s @@ -7,7 +7,7 @@ thumb_func_start IntroMain IntroMain: @ 0x0800927C push {lr} - ldr r1, _08009294 @ =gUnknown_080792CC + ldr r1, _08009294 @ =gIntroStateFuncs ldr r0, _08009298 @ =gMain ldrb r0, [r0, #3] lsls r0, r0, #2 @@ -17,7 +17,7 @@ IntroMain: @ 0x0800927C pop {r0} bx r0 .align 2, 0 -_08009294: .4byte gUnknown_080792CC +_08009294: .4byte gIntroStateFuncs _08009298: .4byte gMain thumb_func_start sub_929C diff --git a/asm/pokedex.s b/asm/pokedex.s index 08a9229..ca2bb87 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -4,22 +4,6 @@ .text - thumb_func_start PokedexMain -PokedexMain: @ 0x08003DAC - push {lr} - ldr r1, _08003DC4 @ =gUnknown_0805C880 - ldr r0, _08003DC8 @ =gMain - ldrb r0, [r0, #3] - lsls r0, r0, #2 - adds r0, r0, r1 - ldr r0, [r0] - bl _call_via_r0 - pop {r0} - bx r0 - .align 2, 0 -_08003DC4: .4byte gUnknown_0805C880 -_08003DC8: .4byte gMain - thumb_func_start sub_3DCC sub_3DCC: @ 0x08003DCC push {r4, r5, r6, r7, lr} @@ -9419,39 +9403,3 @@ _08008A68: .4byte 0x040000D4 _08008A6C: .4byte gMonHatchSpriteGroupPals _08008A70: .4byte 0x05000260 _08008A74: .4byte 0x80000010 - - thumb_func_start sub_8A78 -sub_8A78: @ 0x08008A78 - ldr r1, _08008AA0 @ =gUnknown_0202A1C0 - lsls r0, r0, #0x10 - asrs r2, r0, #0xf - adds r1, r2, r1 - movs r3, #0 - ldrsh r0, [r1, r3] - cmp r0, #4 - bne _08008AAC - ldr r0, _08008AA4 @ =gUnknown_086A61BC - adds r0, r2, r0 - movs r2, #0 - ldrsh r1, [r0, r2] - movs r0, #1 - rsbs r0, r0, #0 - cmp r1, r0 - beq _08008AAC - ldr r1, _08008AA8 @ =gUnknown_0202A588 - movs r0, #1 - b _08008AB0 - .align 2, 0 -_08008AA0: .4byte gUnknown_0202A1C0 -_08008AA4: .4byte gUnknown_086A61BC -_08008AA8: .4byte gUnknown_0202A588 -_08008AAC: - ldr r1, _08008AB8 @ =gUnknown_0202A588 - movs r0, #0 -_08008AB0: - strh r0, [r1] - movs r3, #0 - ldrsh r0, [r1, r3] - bx lr - .align 2, 0 -_08008AB8: .4byte gUnknown_0202A588 diff --git a/asm/rom_11B9C.s b/asm/rom_11B9C.s index 90dc3cd..f733d36 100644 --- a/asm/rom_11B9C.s +++ b/asm/rom_11B9C.s @@ -14550,7 +14550,7 @@ _08019024: .4byte 0x00000532 thumb_func_start IdlePinballGameMain IdlePinballGameMain: @ 0x08019028 push {lr} - ldr r1, _08019040 @ =gUnknown_08137918 + ldr r1, _08019040 @ =gIdlePinballGameStateFuncs ldr r0, _08019044 @ =gMain ldrb r0, [r0, #3] lsls r0, r0, #2 @@ -14560,7 +14560,7 @@ IdlePinballGameMain: @ 0x08019028 pop {r0} bx r0 .align 2, 0 -_08019040: .4byte gUnknown_08137918 +_08019040: .4byte gIdlePinballGameStateFuncs _08019044: .4byte gMain thumb_func_start sub_19048 diff --git a/asm/rom_3219C.s b/asm/rom_3219C.s index c553142..df95ca9 100644 --- a/asm/rom_3219C.s +++ b/asm/rom_3219C.s @@ -45538,7 +45538,7 @@ _08049EB0: .4byte 0x0000131C thumb_func_start PinballGameMain PinballGameMain: @ 0x08049EB4 push {lr} - ldr r1, _08049ECC @ =gUnknown_08137E04 + ldr r1, _08049ECC @ =gPinballGameStateFuncs ldr r0, _08049ED0 @ =gMain ldrb r0, [r0, #3] lsls r0, r0, #2 @@ -45548,7 +45548,7 @@ PinballGameMain: @ 0x08049EB4 pop {r0} bx r0 .align 2, 0 -_08049ECC: .4byte gUnknown_08137E04 +_08049ECC: .4byte gPinballGameStateFuncs _08049ED0: .4byte gMain thumb_func_start sub_49ED4 diff --git a/data/rom.s b/data/rom.s index 907bc8f..02fd1aa 100644 --- a/data/rom.s +++ b/data/rom.s @@ -666,11 +666,21 @@ gUnknown_0805C248:: @ 0x0805C248 gUnknown_0805C748:: @ 0x0805C748 .incbin "baserom.gba", 0x5C748, 0x8 -gUnknown_0805C750:: @ 0x0805C750 - .incbin "baserom.gba", 0x5C750, 0xC - -gUnknown_0805C75C:: @ 0x0805C75C - .incbin "baserom.gba", 0x5C75C, 0x24 +gBonusFieldSelectStateFuncs:: @ 0x0805C750 + .4byte LoadBonusFieldSelectGraphics + .4byte sub_2768 + .4byte sub_2990 + +gEReaderStateFuncs:: @ 0x0805C75C + .4byte LoadEReaderGraphics + .4byte sub_2E40 + .4byte sub_2FC0 + .4byte sub_304C + .4byte sub_3208 + .4byte sub_33A0 + .4byte sub_343C + .4byte sub_35C8 + .4byte sub_374C gUnknown_0805C780:: @ 0x0805C780 .incbin "baserom.gba", 0x5C780, 0x40 @@ -684,8 +694,20 @@ gUnknown_0805C800:: @ 0x0805C800 gUnknown_0805C840:: @ 0x0805C840 .incbin "baserom.gba", 0x5C840, 0x40 -gUnknown_0805C880:: @ 0x0805C880 - .incbin "baserom.gba", 0x5C880, 0x34 +gPokedexStateFuncs:: @ 0x0805C880 + .4byte sub_3DCC + .4byte sub_4150 + .4byte sub_43D4 + .4byte sub_4428 + .4byte sub_4860 + .4byte sub_45A4 + .4byte sub_49A8 + .4byte sub_49D0 + .4byte sub_4B34 + .4byte sub_4BB4 + .4byte sub_4B10 + .4byte sub_4C80 + .4byte sub_4D50 gUnknown_0805C8B4:: @ 0x0805C8B4 .incbin "baserom.gba", 0x5C8B4, 0x18 @@ -700,19 +722,41 @@ gUnknown_0805C8F6:: @ 0x0805C8F6 .incbin "baserom.gba", 0x5C8F6, 0x1C9CA gFieldSelectStateFuncs:: @ 0x080792C0 - .incbin "baserom.gba", 0x792C0, 0xC + .4byte LoadFieldSelectGraphics + .4byte sub_8C7C + .4byte sub_8F64 -gUnknown_080792CC:: @ 0x080792CC - .incbin "baserom.gba", 0x792CC, 0x14 +gIntroStateFuncs:: @ 0x080792CC + .4byte sub_929C + .4byte sub_9348 + .4byte sub_9370 + .4byte sub_938C + .4byte sub_93D0 gUnknown_080792E0:: @ 0x080792E0 .incbin "baserom.gba", 0x792E0, 0x108 -gUnknown_080793E8:: @ 0x080793E8 - .incbin "baserom.gba", 0x793E8, 0x3C - -gUnknown_08079424:: @ 0x08079424 - .incbin "baserom.gba", 0x79424, 0xC +gHighScoresStateFuncs:: @ 0x080793E8 + .4byte sub_CE88 + .4byte sub_D20C + .4byte sub_D308 + .4byte sub_D4B8 + .4byte sub_D664 + .4byte sub_D9F8 + .4byte sub_DA20 + .4byte sub_DB70 + .4byte sub_DBF4 + .4byte sub_DB4C + .4byte sub_DCF0 + .4byte sub_DD4C + .4byte sub_E0EC + .4byte sub_E230 + .4byte sub_E390 + +gIdleHighScoresStateFuncs:: @ 0x08079424 + .4byte sub_DD70 + .4byte sub_DF68 + .4byte sub_E0C4 gUnknown_08079430:: @ 0x08079430 .incbin "baserom.gba", 0x79430, 0x300 @@ -1025,8 +1069,11 @@ gUnknown_08137908:: @ 0x08137908 gUnknown_08137910:: @ 0x08137910 .incbin "baserom.gba", 0x137910, 0x8 -gUnknown_08137918:: @ 0x08137918 - .incbin "baserom.gba", 0x137918, 0x10 +gIdlePinballGameStateFuncs:: @ 0x08137918 + .4byte sub_19048 + .4byte sub_19190 + .4byte sub_4ABC8 + .4byte sub_19288 gUnknown_08137928:: @ 0x08137928 .incbin "baserom.gba", 0x137928, 0x1C @@ -1097,8 +1144,11 @@ gUnknown_08137DE8:: @ 0x08137DE8 gUnknown_08137E00:: @ 0x08137E00 .incbin "baserom.gba", 0x137E00, 0x4 -gUnknown_08137E04:: @ 0x08137E04 - .incbin "baserom.gba", 0x137E04, 0x10 +gPinballGameStateFuncs:: @ 0x08137E04 + .4byte sub_49ED4 + .4byte sub_4AAD8 + .4byte sub_4ABC8 + .4byte sub_4B20C gUnknown_08137E14:: @ 0x08137E14 .incbin "baserom.gba", 0x137E14, 0x100 @@ -1793,8 +1843,11 @@ gUnknown_08527ED6:: @ 0x08527ED6 gUnknown_08527EFE:: @ 0x08527EFE .incbin "baserom.gba", 0x527EFE, 0xA -gUnknown_08527F08:: @ 0x08527F08 - .incbin "baserom.gba", 0x527F08, 0x10 +gOptionsStateFuncs:: @ 0x08527F08 + .4byte LoadOptionsGraphics + .4byte sub_514B8 + .4byte sub_51C3C + .4byte sub_51C60 gUnknown_08527F18:: @ 0x08527F18 .incbin "baserom.gba", 0x527F18, 0x110 diff --git a/include/functions.h b/include/functions.h index e256693..ad20bd9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -80,7 +80,7 @@ void SetMatrixScale(s16 xScale, s16 yScale, s16 matrixNum); // src/bonus_field_select.s extern void BonusFieldSelectMain(void); -extern void sub_25C4(void); +extern void LoadBonusFieldSelectGraphics(void); extern void sub_2710(void); extern void sub_2768(void); extern void sub_2990(void); @@ -328,7 +328,7 @@ extern void sub_1050C(void); // asm/options.s //extern ? OptionsMain(); -//extern ? sub_51240(); +//extern ? LoadOptionsGraphics(); extern void sub_513B8(void); //extern ? sub_514B8(); //extern ? sub_51C3C(); diff --git a/include/variables.h b/include/variables.h index 3cc1efd..c348882 100644 --- a/include/variables.h +++ b/include/variables.h @@ -15,7 +15,7 @@ extern struct {u8 unk0; s16 unk2;} gUnknown_086BB9B4[]; extern u16 gUnknown_08527D66[]; extern u8 gUnknown_02031AF0[][10]; extern u8 gUnknown_08527ED6[][10]; -extern void (*const gUnknown_08527F08[])(void); +extern void (*const gOptionsStateFuncs[])(void); extern u16 gUnknown_0201A520[]; extern u16 gUnknown_0201AD20[]; extern u32 gUnknown_0201A500[]; diff --git a/ld_script.txt b/ld_script.txt index f3c423b..95502f5 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -38,6 +38,7 @@ SECTIONS src/bonus_field_select.o(.text); src/ereader.o(.text); asm/ereader.o(.text); + src/pokedex.o(.text); asm/pokedex.o(.text); src/pokedex_end.o(.text); src/field_select.o(.text); diff --git a/src/bonus_field_select.c b/src/bonus_field_select.c index 7f836aa..496fe14 100644 --- a/src/bonus_field_select.c +++ b/src/bonus_field_select.c @@ -15,7 +15,7 @@ EWRAM_DATA s8 gUnknown_0202BED0 = 0; EWRAM_DATA s8 gUnknown_0202BEE4 = 0; EWRAM_DATA u8 gUnknown_0202BEE8 = 0; -extern void (*const gUnknown_0805C750[])(void); +extern void (*const gBonusFieldSelectStateFuncs[])(void); extern const struct SpriteSet *const gUnknown_086A4C80[16]; extern const struct Coord16 gUnknown_086A4CC0[]; @@ -33,10 +33,10 @@ void sub_29C8(void); void BonusFieldSelectMain(void) { - gUnknown_0805C750[gMain.subState](); + gBonusFieldSelectStateFuncs[gMain.subState](); } -void sub_25C4(void) +void LoadBonusFieldSelectGraphics(void) { ResetSomeGraphicsRelatedStuff(); diff --git a/src/ereader.c b/src/ereader.c index 24c58c7..f1a14f1 100644 --- a/src/ereader.c +++ b/src/ereader.c @@ -6,7 +6,7 @@ #include "m4a.h" #include "titlescreen.h" -extern StateFunc gUnknown_0805C75C[11]; +extern StateFunc gEReaderStateFuncs[11]; extern s8 gUnknown_0202C604; extern s8 gUnknown_0202A580; extern s8 gUnknown_0202C5A4; @@ -51,7 +51,7 @@ s32 sub_1B04(u32 *, u32 *, u32 *); void EReaderMain(void) { - gUnknown_0805C75C[gMain.subState](); + gEReaderStateFuncs[gMain.subState](); } void LoadEReaderGraphics(void) diff --git a/src/options.c b/src/options.c index 5cbea2e..6beb34e 100644 --- a/src/options.c +++ b/src/options.c @@ -47,10 +47,10 @@ extern const u8 gOptionsBackground_Tilemap[]; void OptionsMain(void) { - gUnknown_08527F08[gMain.subState](); + gOptionsStateFuncs[gMain.subState](); } -void sub_51240(void) +void LoadOptionsGraphics(void) { ResetSomeGraphicsRelatedStuff(); @@ -492,6 +492,7 @@ void sub_51C60(void) SetMainGameState(STATE_TITLE); } +// TODO NAKED void sub_51C9C(void) { diff --git a/src/pokedex.c b/src/pokedex.c new file mode 100644 index 0000000..c18d2a8 --- /dev/null +++ b/src/pokedex.c @@ -0,0 +1,9 @@ +#include "global.h" +#include "main.h" + +extern StateFunc gPokedexStateFuncs[]; + +void PokedexMain(void) +{ + gPokedexStateFuncs[gMain.subState](); +} diff --git a/src/pokedex_end.c b/src/pokedex_end.c index 3c7d668..1895931 100644 --- a/src/pokedex_end.c +++ b/src/pokedex_end.c @@ -1,6 +1,59 @@ #include "global.h" #include "main.h" +extern s16 gUnknown_0202A1C0[]; +extern s16 gUnknown_0202A588; +extern s32 gUnknown_0202BF14; + +extern s16 gUnknown_086A61BC[]; + +/* TODO unfinished +void sub_8974(s32 arg0) +{ + s32 var0 = gUnknown_086A61BC[(s16) arg0]; + s32 quotient; + s16 remainder; + s16 var1; + + if (var0 != -1) + { + if (var0 < 100) + { + gUnknown_0202BF14 = 0; + quotient = var0 / 5; + remainder = var0 % 5; + var1 = (s16) var0; + + sub_10708(___ + remainder * 0xD80, (void *)(OBJ_VRAM0 + 0x3800), 0x6C, 1); + } + else + { + gUnknown_0202BF14 = 1; + quotient = (var0 - 100) / 6; + remainder = (var0 - 100) / 6; + var1 = (s16) var0; + + sub_10708((void *)(gMonHatchSpriteGroupGfx[var1] + remainder * 0x10E0), (void *)(OBJ_VRAM0 + 0x4800), 0x87, 1); + } + } +}*/ + +s16 sub_8A78(s32 arg0) +{ + s16 var0 = (s16) arg0; + + if ((gUnknown_0202A1C0[var0] == 4) && (gUnknown_086A61BC[var0] != -1)) + { + gUnknown_0202A588 = 1; + } + else + { + gUnknown_0202A588 = 0; + } + + return gUnknown_0202A588; +} + void ResetPokedex(void) { s32 i;