summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2020-06-02 14:57:40 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2020-06-02 14:57:40 -0400
commit38571ea575fe718f764803afe917ad973f0e2230 (patch)
tree4de1044688f5b414c6f2079e7b9969199fd4297a
parent1aa55436483f75e72779ab50b406c67be16aa7a9 (diff)
Decompile unk_0204639C
-rw-r--r--arm9/asm/unk_0204639C.s253
-rw-r--r--arm9/src/unk_0204639C.c182
-rw-r--r--include/script.h3
3 files changed, 185 insertions, 253 deletions
diff --git a/arm9/asm/unk_0204639C.s b/arm9/asm/unk_0204639C.s
deleted file mode 100644
index 07a73204..00000000
--- a/arm9/asm/unk_0204639C.s
+++ /dev/null
@@ -1,253 +0,0 @@
- .include "asm/macros.inc"
- .include "global.inc"
-
- .text
-
- thumb_func_start FUN_0204639C
-FUN_0204639C: ; 0x0204639C
- push {r3-r7, lr}
- add r5, r0, #0x0
- mov r0, #0x20
- add r6, r1, #0x0
- add r1, r0, #0x0
- add r7, r2, #0x0
- bl AllocFromHeapAtEnd
- add r4, r0, #0x0
- mov r0, #0x0
- str r0, [r4, #0x0]
- str r6, [r4, #0x4]
- str r0, [r4, #0x8]
- str r7, [r4, #0xc]
- str r0, [r4, #0x10]
- str r0, [r4, #0x14]
- mov r0, #0x20
- mov r1, #0x4
- str r5, [r4, #0x18]
- bl AllocFromHeapAtEnd
- str r0, [r4, #0x1c]
- add r0, r4, #0x0
- pop {r3-r7, pc}
-
- thumb_func_start FUN_020463CC
-FUN_020463CC: ; 0x020463CC
- push {r4-r6, lr}
- add r5, r0, #0x0
- ldr r0, [r5, #0x10]
- add r4, r1, #0x0
- add r6, r2, #0x0
- cmp r0, #0x0
- beq _020463DE
- bl ErrorHandling
-_020463DE:
- add r0, r5, #0x0
- add r1, r4, #0x0
- add r2, r6, #0x0
- bl FUN_0204639C
- str r0, [r5, #0x10]
- pop {r4-r6, pc}
-
- thumb_func_start FUN_020463EC
-FUN_020463EC: ; 0x020463EC
- push {r4, lr}
- add r4, r0, #0x0
- str r1, [r4, #0x4]
- mov r0, #0x0
- str r0, [r4, #0x8]
- str r2, [r4, #0xc]
- ldr r0, [r4, #0x14]
- cmp r0, #0x0
- bne _02046400
- beq _0204640A
-_02046400:
- bl FreeToHeap
- mov r0, #0x0
- str r0, [r4, #0x10]
- str r0, [r4, #0x14]
-_0204640A:
- pop {r4, pc}
-
- thumb_func_start FUN_0204640C
-FUN_0204640C: ; 0x0204640C
- push {r4, lr}
- add r4, r0, #0x0
- ldr r0, [r4, #0x18]
- bl FUN_0204639C
- str r4, [r0, #0x0]
- ldr r1, [r4, #0x18]
- str r0, [r1, #0x10]
- pop {r4, pc}
- .balign 4
-
- thumb_func_start FUN_02046420
-FUN_02046420: ; 0x02046420
- push {r3-r5, lr}
- add r5, r0, #0x0
- ldr r0, [r5, #0x10]
- cmp r0, #0x0
- bne _0204642E
- mov r0, #0x0
- pop {r3-r5, pc}
-_0204642E:
- ldr r1, [r0, #0x4]
- blx r1
- cmp r0, #0x1
- bne _02046466
-_02046436:
- ldr r0, [r5, #0x10]
- ldr r4, [r0, #0x0]
- ldr r0, [r0, #0x14]
- cmp r0, #0x0
- beq _02046444
- bl FreeToHeap
-_02046444:
- ldr r0, [r5, #0x10]
- ldr r0, [r0, #0x1c]
- bl FreeToHeap
- ldr r0, [r5, #0x10]
- bl FreeToHeap
- str r4, [r5, #0x10]
- cmp r4, #0x0
- bne _0204645C
- mov r0, #0x1
- pop {r3-r5, pc}
-_0204645C:
- ldr r0, [r5, #0x10]
- ldr r1, [r0, #0x4]
- blx r1
- cmp r0, #0x1
- beq _02046436
-_02046466:
- mov r0, #0x0
- pop {r3-r5, pc}
- .balign 4
-
- thumb_func_start FUN_0204646C
-FUN_0204646C: ; 0x0204646C
- ldr r0, [r0, #0x10]
- cmp r0, #0x0
- beq _02046476
- mov r0, #0x1
- bx lr
-_02046476:
- mov r0, #0x0
- bx lr
- .balign 4
-
- thumb_func_start FUN_0204647C
-FUN_0204647C: ; 0x0204647C
- push {r4, lr}
- add r4, r0, #0x0
- bl FUN_0203739C
- cmp r0, #0x0
- bne _02046492
- add r0, r4, #0x0
- bl FUN_020373C4
- cmp r0, #0x0
- beq _02046496
-_02046492:
- mov r0, #0x1
- pop {r4, pc}
-_02046496:
- mov r0, #0x0
- pop {r4, pc}
- .balign 4
-
- thumb_func_start FUN_0204649C
-FUN_0204649C: ; 0x0204649C
- ldr r3, _020464A0 ; =LoadOverlay_MODULE_05
- bx r3
- .balign 4
-_020464A0: .word LoadOverlay_MODULE_05
-
- thumb_func_start FUN_020464A4
-FUN_020464A4: ; 0x020464A4
- push {r3, lr}
- bl FUN_020373AC
- cmp r0, #0x0
- beq _020464B2
- mov r0, #0x1
- pop {r3, pc}
-_020464B2:
- mov r0, #0x0
- pop {r3, pc}
- .balign 4
-
- thumb_func_start FUN_020464B8
-FUN_020464B8: ; 0x020464B8
- push {r3-r5, lr}
- add r4, r0, #0x0
- bl FUN_02046528
- add r5, r0, #0x0
- add r0, r4, #0x0
- bl FUN_0204652C
- add r4, r0, #0x0
- ldr r0, [r4, #0x0]
- cmp r0, #0x0
- beq _020464D6
- cmp r0, #0x1
- beq _020464E8
- b _020464FC
-_020464D6:
- ldr r1, [r4, #0x4]
- ldr r2, [r4, #0x8]
- add r0, r5, #0x0
- bl FUN_020373D4
- ldr r0, [r4, #0x0]
- add r0, r0, #0x1
- str r0, [r4, #0x0]
- b _020464FC
-_020464E8:
- add r0, r5, #0x0
- bl FUN_0204647C
- cmp r0, #0x0
- bne _020464FC
- add r0, r4, #0x0
- bl FreeToHeap
- mov r0, #0x1
- pop {r3-r5, pc}
-_020464FC:
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start FUN_02046500
-FUN_02046500: ; 0x02046500
- push {r4-r6, lr}
- add r6, r0, #0x0
- add r5, r1, #0x0
- mov r0, #0x20
- mov r1, #0xc
- add r4, r2, #0x0
- bl AllocFromHeapAtEnd
- add r2, r0, #0x0
- mov r0, #0x0
- str r0, [r2, #0x0]
- str r5, [r2, #0x4]
- ldr r1, _02046524 ; =FUN_020464B8
- add r0, r6, #0x0
- str r4, [r2, #0x8]
- bl FUN_0204640C
- pop {r4-r6, pc}
- .balign 4
-_02046524: .word FUN_020464B8
-
- thumb_func_start FUN_02046528
-FUN_02046528: ; 0x02046528
- ldr r0, [r0, #0x18]
- bx lr
-
- thumb_func_start FUN_0204652C
-FUN_0204652C: ; 0x0204652C
- ldr r0, [r0, #0xc]
- bx lr
-
- thumb_func_start FUN_02046530
-FUN_02046530: ; 0x02046530
- add r0, #0x8
- bx lr
-
- thumb_func_start FUN_02046534
-FUN_02046534: ; 0x02046534
- ldr r0, [r0, #0x1c]
- ldr r0, [r0, #0x0]
- bx lr
- .balign 4
diff --git a/arm9/src/unk_0204639C.c b/arm9/src/unk_0204639C.c
new file mode 100644
index 00000000..f9241dc6
--- /dev/null
+++ b/arm9/src/unk_0204639C.c
@@ -0,0 +1,182 @@
+#include "global.h"
+#include "heap.h"
+
+#pragma thumb on
+
+struct UnkStruct_0204639C;
+
+typedef BOOL (*UnkStruct_0204639C_cb)(struct UnkStruct_0204639C * );
+
+struct UnkStruct_0204639C
+{
+ struct UnkStruct_0204639C * unk0;
+ UnkStruct_0204639C_cb unk4;
+ u32 unk8;
+ u32 * unkC;
+ struct UnkStruct_0204639C * unk10;
+ void * unk14;
+ struct UnkStruct_0204639C * unk18;
+ u32 * unk1C;
+};
+
+extern void LoadOverlay_MODULE_05(void *);
+extern void FUN_020373D4(struct UnkStruct_0204639C *, u32, u32);
+extern BOOL FUN_020373AC(void *);
+extern BOOL FUN_0203739C(void *);
+extern BOOL FUN_020373C4(void *);
+
+struct UnkStruct_0204639C * FUN_0204639C(struct UnkStruct_0204639C * r5, UnkStruct_0204639C_cb r6, u32 * r7);
+void FUN_020463CC(struct UnkStruct_0204639C * r5, UnkStruct_0204639C_cb r4, u32 * r6);
+void FUN_020463EC(struct UnkStruct_0204639C * r4, UnkStruct_0204639C_cb r1, u32 * r2);
+void FUN_0204640C(struct UnkStruct_0204639C * r4, UnkStruct_0204639C_cb r1, u32 * r2);
+BOOL FUN_02046420(struct UnkStruct_0204639C * r5);
+BOOL FUN_0204646C(struct UnkStruct_0204639C * r0);
+BOOL FUN_0204647C(void * r4);
+void FUN_0204649C(void * r0);
+BOOL FUN_020464A4(void * r0);
+BOOL FUN_020464B8(struct UnkStruct_0204639C * r4);
+void FUN_02046500(struct UnkStruct_0204639C * r6, u32 r5, u32 r4);
+u32 * FUN_0204652C(struct UnkStruct_0204639C * r0);
+u32 * FUN_02046530(struct UnkStruct_0204639C * r0);
+u32 FUN_02046534(struct UnkStruct_0204639C * r0);
+
+struct UnkStruct_0204639C * FUN_02046528(struct UnkStruct_0204639C *);
+u32 * FUN_0204652C(struct UnkStruct_0204639C *);
+
+struct UnkStruct_0204639C * FUN_0204639C(struct UnkStruct_0204639C * r5, UnkStruct_0204639C_cb r6, u32 * r7)
+{
+ struct UnkStruct_0204639C * ret = AllocFromHeapAtEnd(32, sizeof(struct UnkStruct_0204639C));
+ ret->unk0 = 0;
+ ret->unk4 = r6;
+ ret->unk8 = 0;
+ ret->unkC = r7;
+ ret->unk10 = NULL;
+ ret->unk14 = NULL;
+ ret->unk18 = r5;
+ ret->unk1C = AllocFromHeapAtEnd(32, 4);
+ return ret;
+}
+
+void FUN_020463CC(struct UnkStruct_0204639C * r5, UnkStruct_0204639C_cb r4, u32 * r6)
+{
+ if (r5->unk10 != NULL)
+ ErrorHandling();
+ r5->unk10 = FUN_0204639C(r5, r4, r6);
+}
+
+void FUN_020463EC(struct UnkStruct_0204639C * r4, UnkStruct_0204639C_cb r1, u32 * r2)
+{
+ r4->unk4 = r1;
+ r4->unk8 = 0;
+ r4->unkC = r2;
+ if (r4->unk14 != NULL || r4->unk14 != NULL)
+ {
+ FreeToHeap(r4->unk14);
+ r4->unk10 = NULL;
+ r4->unk14 = NULL;
+ }
+}
+
+void FUN_0204640C(struct UnkStruct_0204639C * r4, UnkStruct_0204639C_cb r1, u32 * r2)
+{
+ struct UnkStruct_0204639C * r0 = FUN_0204639C(r4->unk18, r1, r2);
+ r0->unk0 = r4;
+ r4->unk18->unk10 = r0;
+}
+
+BOOL FUN_02046420(struct UnkStruct_0204639C * r5)
+{
+ if (r5->unk10 == NULL)
+ return FALSE;
+ while (r5->unk10->unk4(r5->unk10) == TRUE)
+ {
+ struct UnkStruct_0204639C * r4 = r5->unk10->unk0;
+ if (r5->unk10->unk14 != NULL)
+ FreeToHeap(r5->unk10->unk14);
+ FreeToHeap(r5->unk10->unk1C);
+ FreeToHeap(r5->unk10);
+ r5->unk10 = r4;
+ if (r4 == NULL)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL FUN_0204646C(struct UnkStruct_0204639C * r0)
+{
+ if (r0->unk10 != NULL)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+BOOL FUN_0204647C(void * r4)
+{
+ if (FUN_0203739C(r4) || FUN_020373C4(r4))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+void FUN_0204649C(void * r0)
+{
+ LoadOverlay_MODULE_05(r0);
+}
+
+BOOL FUN_020464A4(void * r0)
+{
+ if (FUN_020373AC(r0))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+BOOL FUN_020464B8(struct UnkStruct_0204639C * r4)
+{
+ struct UnkStruct_0204639C * r5 = FUN_02046528(r4);
+ u32 * r4_2 = FUN_0204652C(r4);
+ switch (r4_2[0])
+ {
+ case 0:
+ FUN_020373D4(r5, r4_2[1], r4_2[2]);
+ r4_2[0]++;
+ break;
+ case 1:
+ if (!FUN_0204647C(r5))
+ {
+ FreeToHeap(r4_2);
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+void FUN_02046500(struct UnkStruct_0204639C * r6, u32 r5, u32 r4)
+{
+ u32 * r2 = AllocFromHeapAtEnd(32, 3 * sizeof(u32));
+ r2[0] = 0;
+ r2[1] = r5;
+ r2[2] = r4;
+ FUN_0204640C(r6, FUN_020464B8, r2);
+}
+
+struct UnkStruct_0204639C * FUN_02046528(struct UnkStruct_0204639C * r0)
+{
+ return r0->unk18;
+}
+
+u32 * FUN_0204652C(struct UnkStruct_0204639C * r0)
+{
+ return r0->unkC;
+}
+
+u32 * FUN_02046530(struct UnkStruct_0204639C * r0)
+{
+ return &r0->unk8;
+}
+
+u32 FUN_02046534(struct UnkStruct_0204639C * r0)
+{
+ return *r0->unk1C;
+}
diff --git a/include/script.h b/include/script.h
index 0a69f7dd..87ac778b 100644
--- a/include/script.h
+++ b/include/script.h
@@ -20,6 +20,9 @@ struct ScriptContext
ScrCmdFunc *cmdTableEnd;
u32 data[4];
u32 unk74;
+ u32 unk78;
+ u32 unk7C;
+ void * unk80;
};
#define ScriptReadByte(ctx) (*(ctx->scriptPtr++))