From e3bdb08efa3ea0f2d55e77c5ab57528f6d604b6a Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sun, 14 Apr 2019 10:13:51 -0500 Subject: [PATCH] Start decompiling pokenav_unk_3.c --- asm/pokenav_unk_3.s | 50 --------------------------------------------- include/pokenav.h | 4 ++++ ld_script.txt | 1 + src/pokenav.c | 5 +---- src/pokenav_unk_3.c | 40 ++++++++++++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 54 deletions(-) create mode 100755 src/pokenav_unk_3.c diff --git a/asm/pokenav_unk_3.s b/asm/pokenav_unk_3.s index d1632f7e7..202c573bf 100644 --- a/asm/pokenav_unk_3.s +++ b/asm/pokenav_unk_3.s @@ -5,56 +5,6 @@ @ File centered around AllocSubstruct(5) - thumb_func_start sub_81CAAE8 -sub_81CAAE8: @ 81CAAE8 - push {r4,lr} - movs r1, 0xD4 - lsls r1, 1 - movs r0, 0x5 - bl AllocSubstruct - adds r4, r0, 0 - cmp r4, 0 - beq _081CAB1C - ldr r0, =sub_81CAB44 - str r0, [r4, 0x18] - movs r0, 0 - strh r0, [r4, 0x8] - str r0, [r4, 0x10] - ldr r0, =sub_81CAD20 - movs r1, 0x1 - bl CreateLoopedTask - str r0, [r4, 0x14] - movs r0, 0x1 - b _081CAB1E - .pool -_081CAB1C: - movs r0, 0 -_081CAB1E: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CAAE8 - - thumb_func_start sub_81CAB24 -sub_81CAB24: @ 81CAB24 - push {lr} - movs r0, 0x5 - bl GetSubstructPtr - ldr r1, [r0, 0x18] - bl _call_via_r1 - pop {r1} - bx r1 - thumb_func_end sub_81CAB24 - - thumb_func_start sub_81CAB38 -sub_81CAB38: @ 81CAB38 - push {lr} - movs r0, 0x5 - bl FreePokenavSubstruct - pop {r0} - bx r0 - thumb_func_end sub_81CAB38 - thumb_func_start sub_81CAB44 sub_81CAB44: @ 81CAB44 push {r4,r5,lr} diff --git a/include/pokenav.h b/include/pokenav.h index e9ec99037..7ae640637 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -76,5 +76,9 @@ int sub_81C9894(void); u32 sub_81C99D4(void); void sub_81CAADC(void); +// pokenav_unk_3.c +bool32 sub_81CAAE8(void); +u32 sub_81CAB24(void); +void sub_81CAB38(void); #endif //GUARD_POKENAV_H diff --git a/ld_script.txt b/ld_script.txt index 0d2e3dbaa..b3602c47e 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -305,6 +305,7 @@ SECTIONS { src/pokenav_match_call_ui.o(.text); src/pokenav_unk_1.o(.text); asm/pokenav_unk_2.o(.text); + src/pokenav_unk_3.o(.text); asm/pokenav_unk_3.o(.text); asm/pokenav_unk_4.o(.text); asm/pokenav_unk_5.o(.text); diff --git a/src/pokenav.c b/src/pokenav.c index dcafa4f20..734d37c46 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -28,7 +28,7 @@ struct PokenavResources struct UnknownPokenavCallbackStruct { - u32 (*unk0)(void); + bool32 (*unk0)(void); u32 (*unk4)(void); u32 (*unk8)(void); u32 (*unkC)(void); @@ -65,12 +65,9 @@ extern u32 sub_81CF3F8(void); extern u32 sub_81CD024(void); extern u32 sub_81CEF98(void); extern u32 sub_81CF368(void); -extern u32 sub_81CAAE8(void); -extern u32 sub_81CAB24(void); extern u32 sub_81CB260(void); extern u32 sub_81CB29C(void); extern u32 sub_81CB2CC(void); -extern void sub_81CAB38(void); extern u32 sub_81CB2E0(void); extern u32 sub_81CF9BC(void); extern u32 sub_81CFA34(void); diff --git a/src/pokenav_unk_3.c b/src/pokenav_unk_3.c new file mode 100755 index 000000000..be1926e0d --- /dev/null +++ b/src/pokenav_unk_3.c @@ -0,0 +1,40 @@ +#include "global.h" +#include "pokenav.h" + +struct Pokenav3Struct +{ + u8 filler0[0x8]; + u16 unk8; + u8 fillerA[0x6]; + u32 unk10; + u32 unk14; + u32 (*unk18)(struct Pokenav3Struct*); + u8 filler1C[0x18C]; +}; + +u32 sub_81CAB44(struct Pokenav3Struct *); +u32 sub_81CAD20(int); + +bool32 sub_81CAAE8(void) +{ + struct Pokenav3Struct *state = AllocSubstruct(5, sizeof(struct Pokenav3Struct)); + if (!state) + return FALSE; + + state->unk18 = sub_81CAB44; + state->unk8 = 0; + state->unk10 = 0; + state->unk14 = CreateLoopedTask(sub_81CAD20, 1); + return TRUE; +} + +u32 sub_81CAB24(void) +{ + struct Pokenav3Struct *state = GetSubstructPtr(5); + return state->unk18(state); +} + +void sub_81CAB38(void) +{ + FreePokenavSubstruct(5); +}