Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decompile and document some stuff #31

Merged
merged 7 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions asm/high_scores.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions asm/intro.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
52 changes: 0 additions & 52 deletions asm/pokedex.s
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions asm/rom_11B9C.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions asm/rom_3219C.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
95 changes: 74 additions & 21 deletions data/rom.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
1 change: 1 addition & 0 deletions ld_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/bonus_field_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions src/ereader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,7 +51,7 @@ s32 sub_1B04(u32 *, u32 *, u32 *);

void EReaderMain(void)
{
gUnknown_0805C75C[gMain.subState]();
gEReaderStateFuncs[gMain.subState]();
}

void LoadEReaderGraphics(void)
Expand Down
5 changes: 3 additions & 2 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -492,6 +492,7 @@ void sub_51C60(void)
SetMainGameState(STATE_TITLE);
}

// TODO
NAKED
void sub_51C9C(void)
{
Expand Down
9 changes: 9 additions & 0 deletions src/pokedex.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "global.h"
#include "main.h"

extern StateFunc gPokedexStateFuncs[];

void PokedexMain(void)
{
gPokedexStateFuncs[gMain.subState]();
}
Loading