diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2020-05-29 11:29:42 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2020-05-29 11:29:42 -0400 |
commit | a56c25246a4b14d22ac5fc3b7d0dab6b0fc32908 (patch) | |
tree | bbe8325b4900b2c6aca9ccd5cd64b1458f467107 | |
parent | ea5d879160e36cab09abd44c8ed68a4008580f4a (diff) |
Decompile unk_02006234
-rw-r--r-- | arm9/Makefile | 1 | ||||
-rw-r--r-- | arm9/asm/unk_02006234.s | 139 | ||||
-rw-r--r-- | arm9/asm/unk_02089960.s | 7 | ||||
-rw-r--r-- | arm9/modules/63/asm/module_63.s | 6 | ||||
-rw-r--r-- | arm9/src/main.c | 6 | ||||
-rw-r--r-- | arm9/src/unk_02006234.c | 78 | ||||
-rw-r--r-- | include/main.h | 18 | ||||
-rw-r--r-- | include/poke_overlay.h | 2 |
8 files changed, 109 insertions, 148 deletions
diff --git a/arm9/Makefile b/arm9/Makefile index 6ec32834..994575ff 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -202,6 +202,7 @@ TOOLBASE = $(TOOLDIRS:$(TOOLS_DIR)/%=%) TOOLS = $(foreach tool,$(TOOLBASE),$(TOOLS_DIR)/$(tool)/$(tool)$(EXE)) export LM_LICENSE_FILE := $(TOOLS_DIR)/mwccarm/license.dat +export MWCIncludes := lib/include ######################### Targets ########################### diff --git a/arm9/asm/unk_02006234.s b/arm9/asm/unk_02006234.s deleted file mode 100644 index 974dd22b..00000000 --- a/arm9/asm/unk_02006234.s +++ /dev/null @@ -1,139 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - .section .text - - thumb_func_start FUN_02006234 -FUN_02006234: ; 0x02006234 - push {r3-r5, lr} - add r5, r0, #0x0 - add r4, r1, #0x0 - add r0, r2, #0x0 - mov r1, #0x28 - bl AllocFromHeap - add r3, r0, #0x0 - add r2, r3, #0x0 - ldmia r5!, {r0-r1} - stmia r2!, {r0-r1} - ldmia r5!, {r0-r1} - stmia r2!, {r0-r1} - mov r0, #0x0 - str r0, [r3, #0x10] - str r0, [r3, #0x14] - str r4, [r3, #0x18] - str r0, [r3, #0x1c] - str r0, [r3, #0x20] - str r0, [r3, #0x24] - add r0, r3, #0x0 - pop {r3-r5, pc} - - thumb_func_start FUN_02006260 -FUN_02006260: ; 0x02006260 - ldr r3, _02006264 ; =FreeToHeap - bx r3 - .balign 4 -_02006264: .word FreeToHeap - - thumb_func_start FUN_02006268 -FUN_02006268: ; 0x02006268 - push {r4, lr} - add r4, r0, #0x0 - add r0, r2, #0x0 - bl AllocFromHeap - str r0, [r4, #0x1c] - pop {r4, pc} - .balign 4 - - thumb_func_start FUN_02006278 -FUN_02006278: ; 0x02006278 - ldr r0, [r0, #0x1c] - bx lr - - thumb_func_start FUN_0200627C -FUN_0200627C: ; 0x0200627C - push {r4, lr} - add r4, r0, #0x0 - ldr r0, [r4, #0x1c] - bl FreeToHeap - mov r0, #0x0 - str r0, [r4, #0x1c] - pop {r4, pc} - - thumb_func_start FUN_0200628C -FUN_0200628C: ; 0x0200628C - ldr r0, [r0, #0x18] - bx lr - - thumb_func_start FUN_02006290 -FUN_02006290: ; 0x02006290 - push {r4, lr} - add r4, r0, #0x0 - ldr r1, [r4, #0x10] - cmp r1, #0x3 - bhi _0200630E - add r1, r1, r1 - add r1, pc - ldrh r1, [r1, #0x6] - lsl r1, r1, #0x10 - asr r1, r1, #0x10 - add pc, r1 -_020062A6: ; jump table (using 16-bit offset) - .short _020062AE - _020062A6 - 2; case 0 - .short _020062C2 - _020062A6 - 2; case 1 - .short _020062DA - _020062A6 - 2; case 2 - .short _020062F0 - _020062A6 - 2; case 3 -_020062AE: - mov r1, #0x0 - ldr r0, [r4, #0xc] - mvn r1, r1 - cmp r0, r1 - beq _020062BE - mov r1, #0x2 - bl HandleLoadOverlay -_020062BE: - mov r0, #0x1 - str r0, [r4, #0x10] -_020062C2: - add r1, r4, #0x0 - ldr r2, [r4, #0x0] - add r0, r4, #0x0 - add r1, #0x14 - blx r2 - cmp r0, #0x1 - bne _0200630E - mov r0, #0x2 - str r0, [r4, #0x10] - mov r0, #0x0 - str r0, [r4, #0x14] - b _0200630E -_020062DA: - add r1, r4, #0x0 - ldr r2, [r4, #0x4] - add r1, #0x14 - blx r2 - cmp r0, #0x1 - bne _0200630E - mov r0, #0x3 - str r0, [r4, #0x10] - mov r0, #0x0 - str r0, [r4, #0x14] - b _0200630E -_020062F0: - add r1, r4, #0x0 - ldr r2, [r4, #0x8] - add r1, #0x14 - blx r2 - cmp r0, #0x1 - bne _0200630E - mov r1, #0x0 - ldr r0, [r4, #0xc] - mvn r1, r1 - cmp r0, r1 - beq _0200630A - bl UnloadOverlayByID -_0200630A: - mov r0, #0x1 - pop {r4, pc} -_0200630E: - mov r0, #0x0 - pop {r4, pc} - .balign 4 diff --git a/arm9/asm/unk_02089960.s b/arm9/asm/unk_02089960.s index 4386be11..94f81187 100644 --- a/arm9/asm/unk_02089960.s +++ b/arm9/asm/unk_02089960.s @@ -22,8 +22,11 @@ UNK_020FF390: ; 0x020FF390 UNK_020FF3AC: ; 0x020FF3AC .byte 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x99, 0x08, 0x02, 0x9D, 0x99, 0x08, 0x02 - .byte 0x41, 0x9A, 0x08, 0x02, 0xFF, 0xFF, 0xFF, 0xFF + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + + .global UNK_020FF3D4 +UNK_020FF3D4: ; 0x020FF3D4 + .word FUN_02089960, FUN_0208999C, FUN_02089A40, 0xFFFFFFFF .text diff --git a/arm9/modules/63/asm/module_63.s b/arm9/modules/63/asm/module_63.s index 861f4283..c294d4a0 100644 --- a/arm9/modules/63/asm/module_63.s +++ b/arm9/modules/63/asm/module_63.s @@ -372,13 +372,13 @@ MOD63_021D77B4: ; 0x021D77B4 beq _021D780A _021D77F2: mov r0, #0 - ldr r1, _021D781C ; =0x020FF3D4 + ldr r1, _021D781C ; =UNK_020FF3D4 mvn r0, r0 bl FUN_02000E7C b _021D7818 _021D77FE: mov r0, #0 - ldr r1, _021D7820 ; =0x020FF368 + ldr r1, _021D7820 ; =UNK_020FF368 mvn r0, r0 bl FUN_02000E7C b _021D7818 @@ -8653,7 +8653,7 @@ UNK63_021DBAB8: ; 0x021DBAB8 .global MOD63_UNK_021DBE18 MOD63_UNK_021DBE18: - .byte 0x11, 0x8D, 0x1D, 0x02, 0x99, 0x8D, 0x1D, 0x02, 0x69, 0x8E, 0x1D, 0x02, 0xFF, 0xFF, 0xFF, 0xFF + .word MOD63_021D8D10, MOD63_021D8D98, MOD63_021D8E68, 0xFFFFFFFF .byte 0x05, 0x05, 0x05, 0x05, 0x4C, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00 .byte 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 .byte 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 diff --git a/arm9/src/main.c b/arm9/src/main.c index 44f4127a..82b8b734 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -156,18 +156,18 @@ THUMB_FUNC void FUN_02000E0C(void) { if (gBacklightTop.unk14 == NULL) return; - if (gBacklightTop.unk10 != -1u) + if (gBacklightTop.unk10 != SDK_OVERLAY_INVALID_ID) HandleLoadOverlay(gBacklightTop.unk10, 0); gBacklightTop.unk8 = gBacklightTop.unk10; gBacklightTop.unkC = FUN_02006234(gBacklightTop.unk14, &gBacklightTop.unk18, 0); - gBacklightTop.unk10 = -1u; + gBacklightTop.unk10 = SDK_OVERLAY_INVALID_ID; gBacklightTop.unk14 = NULL; } if (FUN_02006290(gBacklightTop.unkC)) { FUN_02006260(gBacklightTop.unkC); gBacklightTop.unkC = 0; - if (gBacklightTop.unk8 != -1u) + if (gBacklightTop.unk8 != SDK_OVERLAY_INVALID_ID) UnloadOverlayByID(gBacklightTop.unk8); } } diff --git a/arm9/src/unk_02006234.c b/arm9/src/unk_02006234.c new file mode 100644 index 00000000..8915ab83 --- /dev/null +++ b/arm9/src/unk_02006234.c @@ -0,0 +1,78 @@ +#include "global.h" +#include "main.h" +#include "poke_overlay.h" +#include "heap.h" + +THUMB_FUNC struct UnkStruct_02006234 * FUN_02006234(struct Unk21DBE18 * ovly_mgr, int * a1, u32 heap_id) +{ + struct UnkStruct_02006234 * ret = (struct UnkStruct_02006234 *)AllocFromHeap(heap_id, sizeof(struct UnkStruct_02006234)); + ret->ovly_mgr = *ovly_mgr; + ret->unk10 = 0; + ret->unk14 = 0; + ret->unk18 = a1; + ret->unk1C = NULL; + ret->unk20 = 0; + ret->unk24 = 0; + return ret; +} + +THUMB_FUNC void FUN_02006260(struct UnkStruct_02006234 * a0) +{ + FreeToHeap(a0); +} + +THUMB_FUNC void * FUN_02006268(struct UnkStruct_02006234 * a0, u32 size, u32 heap_id) +{ + return a0->unk1C = AllocFromHeap(heap_id, size); +} + +THUMB_FUNC void * FUN_02006278(struct UnkStruct_02006234 * a0) +{ + return a0->unk1C; +} + +THUMB_FUNC void FUN_0200627C(struct UnkStruct_02006234 * a0) +{ + FreeToHeap(a0->unk1C); + a0->unk1C = NULL; +} + +THUMB_FUNC int * FUN_0200628C(struct UnkStruct_02006234 * a0) +{ + return a0->unk18; +} + +THUMB_FUNC BOOL FUN_02006290(struct UnkStruct_02006234 * a0) +{ + switch (a0->unk10) + { + case 0: + if (a0->ovly_mgr.ovly != SDK_OVERLAY_INVALID_ID) + HandleLoadOverlay(a0->ovly_mgr.ovly, 2); + a0->unk10 = 1; + // fallthrough + case 1: + if (a0->ovly_mgr.unk0(a0, &a0->unk14) == TRUE) + { + a0->unk10 = 2; + a0->unk14 = 0; + } + break; + case 2: + if (a0->ovly_mgr.unk4(a0, &a0->unk14) == TRUE) + { + a0->unk10 = 3; + a0->unk14 = 0; + } + break; + case 3: + if (a0->ovly_mgr.unk8(a0, &a0->unk14) == TRUE) + { + if (a0->ovly_mgr.ovly != SDK_OVERLAY_INVALID_ID) + UnloadOverlayByID(a0->ovly_mgr.ovly); + return TRUE; + } + break; + } + return FALSE; +} diff --git a/include/main.h b/include/main.h index ff710655..7a6f4c36 100644 --- a/include/main.h +++ b/include/main.h @@ -5,9 +5,25 @@ #include "SPI_pm.h" #include "structs.h" +struct UnkStruct_02006234; + struct Unk21DBE18 { - u8 filler_00[16]; + BOOL (*unk0)(struct UnkStruct_02006234 *, u32 *); + BOOL (*unk4)(struct UnkStruct_02006234 *, u32 *); + BOOL (*unk8)(struct UnkStruct_02006234 *, u32 *); + FSOverlayID ovly; +}; + +struct UnkStruct_02006234 +{ + struct Unk21DBE18 ovly_mgr; + u32 unk10; + u32 unk14; + int * unk18; + void * unk1C; + u32 unk20; + u32 unk24; }; struct Unk2106FA0 diff --git a/include/poke_overlay.h b/include/poke_overlay.h index 400f600e..1ac69665 100644 --- a/include/poke_overlay.h +++ b/include/poke_overlay.h @@ -3,6 +3,8 @@ #include "FS_overlay.h" +#define SDK_OVERLAY_INVALID_ID -1u + #define OVERLAY_LOAD_WRAM 0 #define OVERLAY_LOAD_ITCM 1 #define OVERLAY_LOAD_DTCM 2 |