From 394c0f5546aa152012f0c812d1e6cf0a696bfe86 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Mon, 15 Apr 2019 17:51:11 -0500 Subject: [PATCH] Start decompiling pokenav_unk_4.c --- asm/pokenav_unk_4.s | 93 --------------------------------------------- include/pokenav.h | 7 +++- ld_script.txt | 1 + src/pokenav.c | 15 +++----- src/pokenav_unk_4.c | 67 ++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 103 deletions(-) create mode 100755 src/pokenav_unk_4.c diff --git a/asm/pokenav_unk_4.s b/asm/pokenav_unk_4.s index cc3c17b423..51dc5eebb7 100644 --- a/asm/pokenav_unk_4.s +++ b/asm/pokenav_unk_4.s @@ -5,99 +5,6 @@ @ File centered around AllocSubstruct(6) - thumb_func_start sub_81CB260 -sub_81CB260: @ 81CB260 - push {r4,lr} - ldr r1, =0x00002048 - movs r0, 0x6 - bl AllocSubstruct - adds r4, r0, 0 - cmp r4, 0 - beq _081CB294 - movs r0, 0 - strb r0, [r4, 0x19] - ldr r0, =sub_81CB324 - movs r1, 0x1 - bl CreateLoopedTask - str r0, [r4, 0x4] - ldr r0, =sub_81CB310 - str r0, [r4] - movs r0, 0x1 - b _081CB296 - .pool -_081CB294: - movs r0, 0 -_081CB296: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81CB260 - - thumb_func_start sub_81CB29C -sub_81CB29C: @ 81CB29C - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x6 - bl GetSubstructPtr - adds r5, r0, 0 - ldr r0, =gUnknown_08622798 - lsls r4, 2 - adds r4, r0 - ldr r0, [r4] - movs r1, 0x1 - bl CreateLoopedTask - str r0, [r5, 0x4] - ldr r0, =sub_81CB310 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81CB29C - - thumb_func_start sub_81CB2CC -sub_81CB2CC: @ 81CB2CC - push {lr} - movs r0, 0x6 - bl GetSubstructPtr - ldr r0, [r0] - bl _call_via_r0 - pop {r1} - bx r1 - thumb_func_end sub_81CB2CC - - thumb_func_start sub_81CB2E0 -sub_81CB2E0: @ 81CB2E0 - push {r4,lr} - movs r0, 0x6 - bl GetSubstructPtr - adds r4, r0, 0 - bl sub_81CC2B4 - bl sub_81CBC1C - ldrb r0, [r4, 0x12] - bl RemoveWindow - ldrb r0, [r4, 0x10] - bl RemoveWindow - ldrb r0, [r4, 0x14] - bl RemoveWindow - movs r0, 0x6 - bl FreePokenavSubstruct - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81CB2E0 - - thumb_func_start sub_81CB310 -sub_81CB310: @ 81CB310 - push {lr} - movs r0, 0x6 - bl GetSubstructPtr - ldr r0, [r0, 0x4] - bl IsLoopedTaskActive - pop {r1} - bx r1 - thumb_func_end sub_81CB310 - thumb_func_start sub_81CB324 sub_81CB324: @ 81CB324 push {r4,r5,lr} diff --git a/include/pokenav.h b/include/pokenav.h index fb2644e83f..bf075694e5 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -87,7 +87,7 @@ int sub_81C9894(void); const u8 *sub_81CAF78(int index, u8 *arg1); // pokenav_unk_2.c -u32 sub_81C99D4(void); +void sub_81C99D4(void); void sub_81CAADC(void); // pokenav_unk_3.c @@ -115,4 +115,9 @@ int sub_81CB0C8(int rematchIndex); int sub_81CB0E4(int index); bool32 sub_81CAE08(int); +// pokenav_unk_4.c +u32 sub_81CB260(void); +u32 sub_81CB2CC(void); +void sub_81CB2E0(void); + #endif //GUARD_POKENAV_H diff --git a/ld_script.txt b/ld_script.txt index 9ed1e9b1c3..9c45dd3d09 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -306,6 +306,7 @@ SECTIONS { src/pokenav_unk_1.o(.text); asm/pokenav_unk_2.o(.text); src/pokenav_unk_3.o(.text); + src/pokenav_unk_4.o(.text); asm/pokenav_unk_4.o(.text); asm/pokenav_unk_5.o(.text); asm/pokenav_unk_6.o(.text); diff --git a/src/pokenav.c b/src/pokenav.c index 734d37c466..fde79682b4 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -34,7 +34,7 @@ struct UnknownPokenavCallbackStruct u32 (*unkC)(void); u32 (*unk10)(void); void (*unk14)(void); - u32 (*unk18)(void); + void (*unk18)(void); }; extern u32 sub_81C9924(void); @@ -47,42 +47,39 @@ extern u32 sub_81CC5F4(void); extern u32 sub_81CC62C(void); extern u32 sub_81CC65C(void); extern void sub_81CC524(void); -extern u32 sub_81CC670(void); +extern void sub_81CC670(void); extern u32 sub_81CCFD8(void); extern u32 sub_81CD070(void); extern u32 sub_81CDDD4(void); extern u32 sub_81CDE2C(void); extern u32 sub_81CDE64(void); extern void sub_81CD1C0(void); -extern u32 sub_81CECA0(void); +extern void sub_81CECA0(void); extern u32 sub_81CEF3C(void); extern u32 sub_81CEFDC(void); extern u32 sub_81CF330(void); extern u32 sub_81CF3A0(void); extern u32 sub_81CF3D0(void); extern void sub_81CEFF0(void); -extern u32 sub_81CF3F8(void); +extern void sub_81CF3F8(void); extern u32 sub_81CD024(void); extern u32 sub_81CEF98(void); extern u32 sub_81CF368(void); -extern u32 sub_81CB260(void); extern u32 sub_81CB29C(void); -extern u32 sub_81CB2CC(void); -extern u32 sub_81CB2E0(void); extern u32 sub_81CF9BC(void); extern u32 sub_81CFA34(void); extern u32 sub_81CFDD0(void); extern u32 sub_81CFE40(void); extern u32 sub_81CFE70(void); extern void sub_81CFA48(void); -extern u32 sub_81CFE98(void); +extern void sub_81CFE98(void); extern u32 sub_81D0450(void); extern u32 sub_81D04A0(void); extern u32 sub_81D0978(void); extern u32 sub_81D09B0(void); extern u32 sub_81D09E0(void); extern void sub_81D04B8(void); -extern u32 sub_81D09F4(void); +extern void sub_81D09F4(void); extern u32 sub_81CFA04(void); extern u32 sub_81CFE08(void); diff --git a/src/pokenav_unk_4.c b/src/pokenav_unk_4.c new file mode 100755 index 0000000000..c07794126a --- /dev/null +++ b/src/pokenav_unk_4.c @@ -0,0 +1,67 @@ +#include "global.h" +#include "pokenav.h" +#include "window.h" + +struct Pokenav4Struct +{ + u32 (*unk0)(void); + u32 unk4; + u8 filler8[0x8]; + u8 unk10; + u8 filler11[0x1]; + u8 unk12; + u8 filler13[0x1]; + u8 unk14; + u8 filler15[0x4]; + u8 unk19; + u8 filler1A[0x202E]; +}; + +static bool32 sub_81CB310(void); +u32 sub_81CB324(int); +void sub_81CBC1C(void); +void sub_81CC2B4(void); + +extern const LoopedTask gUnknown_08622798[]; + +bool32 sub_81CB260(void) +{ + struct Pokenav4Struct *state = AllocSubstruct(6, sizeof(struct Pokenav4Struct)); + if (!state) + return FALSE; + + state->unk19 = 0; + state->unk4 = CreateLoopedTask(sub_81CB324, 1); + state->unk0 = sub_81CB310; + return TRUE; +} + +void sub_81CB29C(int index) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + state->unk4 = CreateLoopedTask(gUnknown_08622798[index], 1); + state->unk0 = sub_81CB310; +} + +u32 sub_81CB2CC(void) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + return state->unk0(); +} + +void sub_81CB2E0(void) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + sub_81CC2B4(); + sub_81CBC1C(); + RemoveWindow(state->unk12); + RemoveWindow(state->unk10); + RemoveWindow(state->unk14); + FreePokenavSubstruct(6); +} + +static bool32 sub_81CB310(void) +{ + struct Pokenav4Struct *state = GetSubstructPtr(6); + return IsLoopedTaskActive(state->unk4); +}