summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arm9/arm9.lsf3
-rw-r--r--arm9/asm/scrcmd_asm.s (renamed from arm9/asm/scrcmd.s)1229
-rw-r--r--arm9/asm/unk_02015E30.s72
-rw-r--r--arm9/asm/unk_020166C8.s665
-rw-r--r--arm9/asm/unk_02038C78.s108
-rw-r--r--arm9/global.inc112
-rw-r--r--arm9/modules/05/src/mod05_021E72FC.c2
-rw-r--r--arm9/modules/52/asm/module_52.s293
-rw-r--r--arm9/modules/52/include/module_52.h42
-rw-r--r--arm9/modules/52/src/module_52.c647
-rw-r--r--arm9/modules/59/asm/mod59_021D74E0_asm.s2
-rw-r--r--arm9/modules/59/src/mod59_021D74E0_src.c3
-rw-r--r--arm9/src/game_init.c5
-rw-r--r--arm9/src/heap.c380
-rw-r--r--arm9/src/scrcmd.c556
-rw-r--r--arm9/src/scrcmd_18_c.c14
-rw-r--r--arm9/src/script.c2
-rw-r--r--arm9/src/script_buffers.c2
-rw-r--r--arm9/src/trainer_data.c2
-rw-r--r--arm9/src/unk_02015E30.c38
-rw-r--r--arm9/src/unk_02024E64.c38
-rw-r--r--include/event_data.h2
-rw-r--r--include/heap.h34
-rw-r--r--include/scrcmd.h68
-rw-r--r--include/script.h33
-rw-r--r--include/unk_02015E30.h21
-rw-r--r--include/unk_02024E64.h27
27 files changed, 1980 insertions, 2420 deletions
diff --git a/arm9/arm9.lsf b/arm9/arm9.lsf
index b8accee4..ba128605 100644
--- a/arm9/arm9.lsf
+++ b/arm9/arm9.lsf
@@ -48,7 +48,7 @@ Static arm9
Object unk_02015D14.o
Object unk_02015E30.o
Object game_init.o
- Object unk_020166C8.o
+ Object heap.o
Object unk_02016B94.o
Object unk_0201B1A8.o
Object unk_0201B4E8.o
@@ -152,6 +152,7 @@ Static arm9
Object script.o
Object unk_02038C78.o
Object scrcmd.o
+ Object scrcmd_asm.o
Object scrcmd_2.o
Object scrcmd_3.o
Object scrcmd_4.o
diff --git a/arm9/asm/scrcmd.s b/arm9/asm/scrcmd_asm.s
index c5ae760b..c2751ee2 100644
--- a/arm9/asm/scrcmd.s
+++ b/arm9/asm/scrcmd_asm.s
@@ -2,10 +2,10 @@
.include "global.inc"
.extern UNK_020F34E0
- .extern sScriptConditionTable
.extern UNK_020F34FC
.extern UNK_020F3538
.extern gMain
+ .extern FUN_0203A2F0
.section .bss
@@ -15,1233 +15,6 @@ UNK_021C5A0C: ; 0x021C5A0C
.text
- thumb_func_start ScrCmd_nop
-ScrCmd_nop: ; 0x020399A0
- mov r0, #0x0
- bx lr
-
- thumb_func_start ScrCmd_nop2
-ScrCmd_nop2: ; 0x020399A4
- mov r0, #0x0
- bx lr
-
- thumb_func_start ScrCmd_end
-ScrCmd_end: ; 0x020399A8
- push {r3, lr}
- bl StopScript
- mov r0, #0x0
- pop {r3, pc}
- .balign 4
-
- thumb_func_start ScrCmd_delay
-ScrCmd_delay: ; 0x020399B4
- push {r3-r7, lr}
- add r5, r0, #0x0
- add r1, r5, #0x0
- add r1, #0x80
- ldr r6, [r1, #0x0]
- bl ScriptReadHalfword
- add r7, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- add r4, r0, #0x0
- add r0, r6, #0x0
- add r1, r4, #0x0
- bl GetVarPointer
- strh r7, [r0, #0x0]
- ldr r1, _020399E4 ; =RunPauseTimer
- add r0, r5, #0x0
- str r4, [r5, #0x64]
- bl SetupNativeScript
- mov r0, #0x1
- pop {r3-r7, pc}
- .balign 4
-_020399E4: .word RunPauseTimer
-
- thumb_func_start RunPauseTimer
-RunPauseTimer: ; 0x020399E8
- push {r3, lr}
- add r1, r0, #0x0
- ldr r1, [r1, #0x64]
- add r0, #0x80
- lsl r1, r1, #0x10
- ldr r0, [r0, #0x0]
- lsr r1, r1, #0x10
- bl GetVarPointer
- ldrh r1, [r0, #0x0]
- sub r1, r1, #0x1
- strh r1, [r0, #0x0]
- ldrh r0, [r0, #0x0]
- cmp r0, #0x0
- bne _02039A0A
- mov r0, #0x1
- pop {r3, pc}
-_02039A0A:
- mov r0, #0x0
- pop {r3, pc}
- .balign 4
-
- thumb_func_start FUN_02039A10
-FUN_02039A10: ; 0x02039A10
- push {r4, lr}
- add r4, r0, #0x0
- bl ScriptReadHalfword
- add r4, #0x80
- add r1, r0, #0x0
- ldr r0, [r4, #0x0]
- bl VarGet
- mov r0, #0x0
- pop {r4, pc}
- .balign 4
-
- thumb_func_start ScrCmd_loadbyte
-ScrCmd_loadbyte: ; 0x02039A28
- ldr r1, [r0, #0x8]
- add r2, r1, #0x1
- str r2, [r0, #0x8]
- ldrb r3, [r1, #0x0]
- add r1, r2, #0x1
- str r1, [r0, #0x8]
- ldrb r2, [r2, #0x0]
- lsl r1, r3, #0x2
- add r0, r0, r1
- str r2, [r0, #0x64]
- mov r0, #0x0
- bx lr
-
- thumb_func_start ScrCmd_loadword
-ScrCmd_loadword: ; 0x02039A40
- push {r3-r5, lr}
- add r4, r0, #0x0
- ldr r2, [r4, #0x8]
- add r1, r2, #0x1
- str r1, [r4, #0x8]
- ldrb r5, [r2, #0x0]
- bl ScriptReadWord
- lsl r1, r5, #0x2
- add r1, r4, r1
- str r0, [r1, #0x64]
- mov r0, #0x0
- pop {r3-r5, pc}
- .balign 4
-
- thumb_func_start ScrCmd_loadbytefromaddr
-ScrCmd_loadbytefromaddr: ; 0x02039A5C
- push {r3-r5, lr}
- add r5, r0, #0x0
- ldr r2, [r5, #0x8]
- add r1, r2, #0x1
- str r1, [r5, #0x8]
- ldrb r4, [r2, #0x0]
- bl ScriptReadWord
- ldrb r1, [r0, #0x0]
- lsl r0, r4, #0x2
- add r0, r5, r0
- str r1, [r0, #0x64]
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start ScrCmd_writebytetoaddr
-ScrCmd_writebytetoaddr: ; 0x02039A78
- push {r4, lr}
- add r4, r0, #0x0
- bl ScriptReadWord
- ldr r2, [r4, #0x8]
- add r1, r2, #0x1
- str r1, [r4, #0x8]
- ldrb r1, [r2, #0x0]
- strb r1, [r0, #0x0]
- mov r0, #0x0
- pop {r4, pc}
- .balign 4
-
- thumb_func_start ScrCmd_setptrbyte
-ScrCmd_setptrbyte: ; 0x02039A90
- push {r4, lr}
- add r4, r0, #0x0
- bl ScriptReadWord
- ldr r2, [r4, #0x8]
- add r1, r2, #0x1
- str r1, [r4, #0x8]
- ldrb r1, [r2, #0x0]
- lsl r1, r1, #0x2
- add r1, r4, r1
- ldr r1, [r1, #0x64]
- strb r1, [r0, #0x0]
- mov r0, #0x0
- pop {r4, pc}
-
- thumb_func_start ScrCmd_copylocal
-ScrCmd_copylocal: ; 0x02039AAC
- ldr r1, [r0, #0x8]
- add r2, r1, #0x1
- str r2, [r0, #0x8]
- ldrb r3, [r1, #0x0]
- add r1, r2, #0x1
- str r1, [r0, #0x8]
- ldrb r1, [r2, #0x0]
- lsl r1, r1, #0x2
- add r1, r0, r1
- ldr r2, [r1, #0x64]
- lsl r1, r3, #0x2
- add r0, r0, r1
- str r2, [r0, #0x64]
- mov r0, #0x0
- bx lr
- .balign 4
-
- thumb_func_start ScrCmd_copybyte
-ScrCmd_copybyte: ; 0x02039ACC
- push {r3-r5, lr}
- add r5, r0, #0x0
- bl ScriptReadWord
- add r4, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadWord
- ldrb r0, [r0, #0x0]
- strb r0, [r4, #0x0]
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start compare_012
-compare_012: ; 0x02039AE4
- cmp r0, r1
- bhs _02039AEC
- mov r0, #0x0
- bx lr
-_02039AEC:
- cmp r0, r1
- bne _02039AF4
- mov r0, #0x1
- bx lr
-_02039AF4:
- mov r0, #0x2
- bx lr
-
- thumb_func_start ScrCmd_compare_local_to_local
-ScrCmd_compare_local_to_local: ; 0x02039AF8
- push {r4, lr}
- add r4, r0, #0x0
- ldr r0, [r4, #0x8]
- add r1, r0, #0x1
- str r1, [r4, #0x8]
- ldrb r0, [r0, #0x0]
- add r2, r1, #0x1
- lsl r0, r0, #0x2
- add r0, r4, r0
- ldr r0, [r0, #0x64]
- str r2, [r4, #0x8]
- ldrb r1, [r1, #0x0]
- lsl r0, r0, #0x18
- lsr r0, r0, #0x18
- lsl r1, r1, #0x2
- add r1, r4, r1
- ldr r1, [r1, #0x64]
- lsl r1, r1, #0x18
- lsr r1, r1, #0x18
- bl compare_012
- strb r0, [r4, #0x2]
- mov r0, #0x0
- pop {r4, pc}
-
- thumb_func_start ScrCmd_compare_local_to_value
-ScrCmd_compare_local_to_value: ; 0x02039B28
- push {r4, lr}
- add r4, r0, #0x0
- ldr r0, [r4, #0x8]
- add r1, r0, #0x1
- str r1, [r4, #0x8]
- ldrb r0, [r0, #0x0]
- add r2, r1, #0x1
- lsl r0, r0, #0x2
- add r0, r4, r0
- ldr r0, [r0, #0x64]
- str r2, [r4, #0x8]
- ldrb r1, [r1, #0x0]
- lsl r0, r0, #0x18
- lsr r0, r0, #0x18
- bl compare_012
- strb r0, [r4, #0x2]
- mov r0, #0x0
- pop {r4, pc}
- .balign 4
-
- thumb_func_start ScrCmd_compare_local_to_addr
-ScrCmd_compare_local_to_addr: ; 0x02039B50
- push {r3-r5, lr}
- add r4, r0, #0x0
- ldr r2, [r4, #0x8]
- add r1, r2, #0x1
- str r1, [r4, #0x8]
- ldrb r1, [r2, #0x0]
- lsl r1, r1, #0x2
- add r1, r4, r1
- ldr r1, [r1, #0x64]
- lsl r1, r1, #0x18
- lsr r5, r1, #0x18
- bl ScriptReadWord
- ldrb r1, [r0, #0x0]
- add r0, r5, #0x0
- bl compare_012
- strb r0, [r4, #0x2]
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start ScrCmd_compare_addr_to_local
-ScrCmd_compare_addr_to_local: ; 0x02039B78
- push {r4, lr}
- add r4, r0, #0x0
- bl ScriptReadWord
- ldr r2, [r4, #0x8]
- ldrb r0, [r0, #0x0]
- add r1, r2, #0x1
- str r1, [r4, #0x8]
- ldrb r1, [r2, #0x0]
- lsl r1, r1, #0x2
- add r1, r4, r1
- ldr r1, [r1, #0x64]
- lsl r1, r1, #0x18
- lsr r1, r1, #0x18
- bl compare_012
- strb r0, [r4, #0x2]
- mov r0, #0x0
- pop {r4, pc}
- .balign 4
-
- thumb_func_start ScrCmd_compare_addr_to_value
-ScrCmd_compare_addr_to_value: ; 0x02039BA0
- push {r4, lr}
- add r4, r0, #0x0
- bl ScriptReadWord
- ldr r2, [r4, #0x8]
- ldrb r0, [r0, #0x0]
- add r1, r2, #0x1
- str r1, [r4, #0x8]
- ldrb r1, [r2, #0x0]
- bl compare_012
- strb r0, [r4, #0x2]
- mov r0, #0x0
- pop {r4, pc}
-
- thumb_func_start ScrCmd_compare_addr_to_addr
-ScrCmd_compare_addr_to_addr: ; 0x02039BBC
- push {r3-r5, lr}
- add r5, r0, #0x0
- bl ScriptReadWord
- ldrb r4, [r0, #0x0]
- add r0, r5, #0x0
- bl ScriptReadWord
- ldrb r1, [r0, #0x0]
- add r0, r4, #0x0
- bl compare_012
- strb r0, [r5, #0x2]
- mov r0, #0x0
- pop {r3-r5, pc}
- .balign 4
-
- thumb_func_start ScrCmd_compare_var_to_value
-ScrCmd_compare_var_to_value: ; 0x02039BDC
- push {r3-r5, lr}
- add r4, r0, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl GetVarPointer
- ldrh r5, [r0, #0x0]
- add r0, r4, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- bl compare_012
- strb r0, [r4, #0x2]
- mov r0, #0x0
- pop {r3-r5, pc}
- .balign 4
-
- thumb_func_start ScrCmd_compare_var_to_var
-ScrCmd_compare_var_to_var: ; 0x02039C08
- push {r3-r5, lr}
- add r5, r0, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl GetVarPointer
- add r4, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl GetVarPointer
- add r1, r0, #0x0
- ldrh r0, [r4, #0x0]
- ldrh r1, [r1, #0x0]
- bl compare_012
- strb r0, [r5, #0x2]
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start FUN_02039C40
-FUN_02039C40: ; 0x02039C40
- push {r3-r7, lr}
- add r7, r0, #0x0
- add r0, #0x80
- ldr r5, [r0, #0x0]
- mov r1, #0x7
- add r0, r5, #0x0
- bl FUN_02039438
- add r4, r0, #0x0
- add r0, r5, #0x0
- mov r1, #0xe
- bl FUN_02039438
- add r6, r0, #0x0
- add r0, r7, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- bl CreateScriptContext
- str r0, [r6, #0x0]
- ldrb r0, [r4, #0x0]
- add r0, r0, #0x1
- strb r0, [r4, #0x0]
- mov r0, #0x1
- pop {r3-r7, pc}
- .balign 4
-
- thumb_func_start FUN_02039C78
-FUN_02039C78: ; 0x02039C78
- push {r3-r7, lr}
- str r0, [sp, #0x0]
- add r0, #0x80
- ldr r5, [r0, #0x0]
- mov r1, #0x5
- add r0, r5, #0x0
- bl FUN_02039438
- add r6, r0, #0x0
- add r0, r5, #0x0
- mov r1, #0x7
- bl FUN_02039438
- add r4, r0, #0x0
- add r0, r5, #0x0
- mov r1, #0xe
- bl FUN_02039438
- add r7, r0, #0x0
- ldr r0, [sp, #0x0]
- bl ScriptReadHalfword
- add r1, r0, #0x0
- mov r0, #0x1
- strb r0, [r6, #0x0]
- add r0, r5, #0x0
- bl CreateScriptContext
- str r0, [r7, #0x0]
- ldrb r0, [r4, #0x0]
- ldr r1, _02039CC4 ; =FUN_02039CC8
- add r0, r0, #0x1
- strb r0, [r4, #0x0]
- ldr r0, [sp, #0x0]
- bl SetupNativeScript
- mov r0, #0x1
- pop {r3-r7, pc}
- .balign 4
-_02039CC4: .word FUN_02039CC8
-
- thumb_func_start FUN_02039CC8
-FUN_02039CC8: ; 0x02039CC8
- push {r3, lr}
- add r0, #0x80
- ldr r0, [r0, #0x0]
- mov r1, #0x5
- bl FUN_02039438
- ldrb r0, [r0, #0x0]
- cmp r0, #0x0
- bne _02039CDE
- mov r0, #0x1
- pop {r3, pc}
-_02039CDE:
- mov r0, #0x0
- pop {r3, pc}
- .balign 4
-
- thumb_func_start FUN_02039CE4
-FUN_02039CE4: ; 0x02039CE4
- push {r3, lr}
- add r0, #0x80
- ldr r0, [r0, #0x0]
- mov r1, #0x5
- bl FUN_02039438
- mov r1, #0x0
- strb r1, [r0, #0x0]
- add r0, r1, #0x0
- pop {r3, pc}
-
- thumb_func_start ScrCmd_goto
-ScrCmd_goto: ; 0x02039CF8
- ; relative jump
- push {r4, lr}
- add r4, r0, #0x0
- bl ScriptReadWord
- add r2, r0, #0x0
- ldr r1, [r4, #0x8]
- add r0, r4, #0x0
- add r1, r1, r2
- bl ScriptJump
- mov r0, #0x0
- pop {r4, pc}
-
- thumb_func_start FUN_02039D10
-FUN_02039D10: ; 0x02039D10
- push {r3-r7, lr}
- add r5, r0, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- mov r1, #0xa
- bl FUN_02039438
- ldr r1, [r5, #0x8]
- add r6, r0, #0x0
- add r0, r1, #0x1
- str r0, [r5, #0x8]
- add r0, r5, #0x0
- ldrb r4, [r1, #0x0]
- bl ScriptReadWord
- add r7, r0, #0x0
- ldr r0, [r6, #0x0]
- bl FUN_02058448
- cmp r4, r0
- bne _02039D44
- ldr r1, [r5, #0x8]
- add r0, r5, #0x0
- add r1, r1, r7
- bl ScriptJump
-_02039D44:
- mov r0, #0x0
- pop {r3-r7, pc}
-
- thumb_func_start FUN_02039D48
-FUN_02039D48: ; 0x02039D48
- push {r4-r6, lr}
- add r5, r0, #0x0
- ldr r0, [r5, #0x74]
- bl FUN_02046534
- ldr r1, [r5, #0x8]
- add r6, r0, #0x0
- add r0, r1, #0x1
- str r0, [r5, #0x8]
- ldrb r4, [r1, #0x0]
- add r0, r5, #0x0
- bl ScriptReadWord
- add r2, r0, #0x0
- cmp r6, r4
- bne _02039D72
- ldr r1, [r5, #0x8]
- add r0, r5, #0x0
- add r1, r1, r2
- bl ScriptJump
-_02039D72:
- mov r0, #0x0
- pop {r4-r6, pc}
- .balign 4
-
- thumb_func_start FUN_02039D78
-FUN_02039D78: ; 0x02039D78
- push {r4-r6, lr}
- add r5, r0, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- mov r1, #0x9
- bl FUN_02039438
- ldr r1, [r5, #0x8]
- add r6, r0, #0x0
- add r0, r1, #0x1
- str r0, [r5, #0x8]
- ldrb r4, [r1, #0x0]
- add r0, r5, #0x0
- bl ScriptReadWord
- add r2, r0, #0x0
- ldr r0, [r6, #0x0]
- cmp r0, r4
- bne _02039DA8
- ldr r1, [r5, #0x8]
- add r0, r5, #0x0
- add r1, r1, r2
- bl ScriptJump
-_02039DA8:
- mov r0, #0x0
- pop {r4-r6, pc}
-
- thumb_func_start ScrCmd_call
-ScrCmd_call: ; 0x02039DAC
- push {r4, lr}
- add r4, r0, #0x0
- bl ScriptReadWord
- add r2, r0, #0x0
- ldr r1, [r4, #0x8]
- add r0, r4, #0x0
- add r1, r1, r2
- bl ScriptCall
- mov r0, #0x0
- pop {r4, pc}
-
- thumb_func_start ScrCmd_return
-ScrCmd_return: ; 0x02039DC4
- push {r3, lr}
- bl ScriptReturn
- mov r0, #0x0
- pop {r3, pc}
- .balign 4
-
- thumb_func_start ScrCmd_goto_if
-ScrCmd_goto_if: ; 0x02039DD0
- push {r3-r5, lr}
- add r5, r0, #0x0
- ldr r2, [r5, #0x8]
- add r1, r2, #0x1
- str r1, [r5, #0x8]
- ldrb r4, [r2, #0x0]
- bl ScriptReadWord
- add r1, r0, #0x0
- lsl r0, r4, #0x1
- add r3, r4, r0
- ldr r0, _02039E00 ; =sScriptConditionTable
- ldrb r2, [r5, #0x2]
- add r0, r0, r3
- ldrb r0, [r2, r0]
- cmp r0, #0x1
- bne _02039DFC
- ldr r2, [r5, #0x8]
- add r0, r5, #0x0
- add r1, r2, r1
- bl ScriptJump
-_02039DFC:
- mov r0, #0x0
- pop {r3-r5, pc}
- .balign 4
-_02039E00: .word sScriptConditionTable
-
- thumb_func_start ScrCmd_call_if
-ScrCmd_call_if: ; 0x02039E04
- push {r3-r5, lr}
- add r5, r0, #0x0
- ldr r2, [r5, #0x8]
- add r1, r2, #0x1
- str r1, [r5, #0x8]
- ldrb r4, [r2, #0x0]
- bl ScriptReadWord
- add r1, r0, #0x0
- lsl r0, r4, #0x1
- add r3, r4, r0
- ldr r0, _02039E34 ; =sScriptConditionTable
- ldrb r2, [r5, #0x2]
- add r0, r0, r3
- ldrb r0, [r2, r0]
- cmp r0, #0x1
- bne _02039E30
- ldr r2, [r5, #0x8]
- add r0, r5, #0x0
- add r1, r2, r1
- bl ScriptCall
-_02039E30:
- mov r0, #0x0
- pop {r3-r5, pc}
- .balign 4
-_02039E34: .word sScriptConditionTable
-
- thumb_func_start ScrCmd_setflag
-ScrCmd_setflag: ; 0x02039E38
- push {r4, lr}
- add r1, r0, #0x0
- add r1, #0x80
- ldr r4, [r1, #0x0]
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- bl FlagSet
- mov r0, #0x0
- pop {r4, pc}
-
- thumb_func_start ScrCmd_clearflag
-ScrCmd_clearflag: ; 0x02039E50
- push {r4, lr}
- add r1, r0, #0x0
- add r1, #0x80
- ldr r4, [r1, #0x0]
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- bl FlagClear
- mov r0, #0x0
- pop {r4, pc}
-
- thumb_func_start ScrCmd_checkflag
-ScrCmd_checkflag: ; 0x02039E68
- push {r3-r5, lr}
- add r4, r0, #0x0
- add r1, r4, #0x0
- add r1, #0x80
- ldr r5, [r1, #0x0]
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- bl FlagCheck
- strb r0, [r4, #0x2]
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start FUN_02039E84
-FUN_02039E84: ; 0x02039E84
- push {r4-r6, lr}
- add r4, r0, #0x0
- add r1, r4, #0x0
- add r1, #0x80
- ldr r5, [r1, #0x0]
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl GetVarPointer
- add r6, r0, #0x0
- add r0, r4, #0x0
- bl ScriptReadHalfword
- add r4, #0x80
- add r1, r0, #0x0
- ldr r0, [r4, #0x0]
- bl GetVarPointer
- add r4, r0, #0x0
- ldrh r1, [r6, #0x0]
- add r0, r5, #0x0
- bl FlagCheck
- strh r0, [r4, #0x0]
- mov r0, #0x0
- pop {r4-r6, pc}
-
- thumb_func_start FUN_02039EC0
-FUN_02039EC0: ; 0x02039EC0
- push {r3-r5, lr}
- add r5, r0, #0x0
- add r1, r5, #0x0
- add r1, #0x80
- ldr r4, [r1, #0x0]
- bl ScriptReadHalfword
- add r5, #0x80
- add r1, r0, #0x0
- ldr r0, [r5, #0x0]
- bl GetVarPointer
- add r1, r0, #0x0
- ldrh r1, [r1, #0x0]
- add r0, r4, #0x0
- bl FlagSet
- mov r0, #0x0
- pop {r3-r5, pc}
- .balign 4
-
- thumb_func_start ScrCmd_settrainerflag
-ScrCmd_settrainerflag: ; 0x02039EE8
- push {r3-r5, lr}
- add r4, r0, #0x0
- add r1, r4, #0x0
- add r1, #0x80
- ldr r5, [r1, #0x0]
- bl ScriptReadHalfword
- add r4, #0x80
- add r1, r0, #0x0
- ldr r0, [r4, #0x0]
- bl VarGet
- add r1, r0, #0x0
- add r0, r5, #0x0
- bl TrainerFlagSet
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start ScrCmd_cleartrainerflag
-ScrCmd_cleartrainerflag: ; 0x02039F0C
- push {r3-r5, lr}
- add r4, r0, #0x0
- add r1, r4, #0x0
- add r1, #0x80
- ldr r5, [r1, #0x0]
- bl ScriptReadHalfword
- add r4, #0x80
- add r1, r0, #0x0
- ldr r0, [r4, #0x0]
- bl VarGet
- add r1, r0, #0x0
- add r0, r5, #0x0
- bl TrainerFlagClear
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start ScrCmd_checktrainerflag
-ScrCmd_checktrainerflag: ; 0x02039F30
- push {r3-r5, lr}
- add r5, r0, #0x0
- add r1, r5, #0x0
- add r1, #0x80
- ldr r4, [r1, #0x0]
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl VarGet
- add r1, r0, #0x0
- add r0, r4, #0x0
- bl TrainerFlagCheck
- strb r0, [r5, #0x2]
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start ScrCmd_addvar
-ScrCmd_addvar: ; 0x02039F58
- push {r3-r5, lr}
- add r5, r0, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl GetVarPointer
- add r4, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- add r5, #0x80
- add r1, r0, #0x0
- ldr r0, [r5, #0x0]
- bl VarGet
- ldrh r1, [r4, #0x0]
- add r0, r1, r0
- strh r0, [r4, #0x0]
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start ScrCmd_subvar
-ScrCmd_subvar: ; 0x02039F88
- push {r3-r5, lr}
- add r5, r0, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl GetVarPointer
- add r4, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- add r5, #0x80
- add r1, r0, #0x0
- ldr r0, [r5, #0x0]
- bl VarGet
- ldrh r1, [r4, #0x0]
- sub r0, r1, r0
- strh r0, [r4, #0x0]
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start ScrCmd_setvar
-ScrCmd_setvar: ; 0x02039FB8
- push {r3-r5, lr}
- add r4, r0, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl GetVarPointer
- add r5, r0, #0x0
- add r0, r4, #0x0
- bl ScriptReadHalfword
- strh r0, [r5, #0x0]
- mov r0, #0x0
- pop {r3-r5, pc}
- .balign 4
-
- thumb_func_start ScrCmd_copyvar
-ScrCmd_copyvar: ; 0x02039FDC
- push {r3-r5, lr}
- add r5, r0, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl GetVarPointer
- add r4, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- add r5, #0x80
- add r1, r0, #0x0
- ldr r0, [r5, #0x0]
- bl GetVarPointer
- ldrh r0, [r0, #0x0]
- strh r0, [r4, #0x0]
- mov r0, #0x0
- pop {r3-r5, pc}
- .balign 4
-
- thumb_func_start ScrCmd_setorcopyvar
-ScrCmd_setorcopyvar: ; 0x0203A00C
- push {r3-r5, lr}
- add r4, r0, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl GetVarPointer
- add r5, r0, #0x0
- add r0, r4, #0x0
- bl ScriptReadHalfword
- add r4, #0x80
- add r1, r0, #0x0
- ldr r0, [r4, #0x0]
- bl VarGet
- strh r0, [r5, #0x0]
- mov r0, #0x0
- pop {r3-r5, pc}
-
- thumb_func_start ScrCmd_message
-ScrCmd_message: ; 0x0203A038
- push {r3, lr}
- ldr r2, [r0, #0x8]
- add r1, r2, #0x1
- str r1, [r0, #0x8]
- ldrb r2, [r2, #0x0]
- ldr r1, [r0, #0x78]
- bl MOD05_ShowMessageInField
- mov r0, #0x0
- pop {r3, pc}
-
- thumb_func_start ScrCmd_message_from
-ScrCmd_message_from: ; 0x0203A04C
- ; message_from bank, id
- push {r4-r6, lr}
- add r4, r0, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl VarGet
- add r5, r0, #0x0
- add r0, r4, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl VarGet
- add r6, r0, #0x0
- mov r0, #0x1
- mov r1, #0x1a
- add r2, r5, #0x0
- mov r3, #0x20
- bl NewMsgDataFromNarc
- add r5, r0, #0x0
- add r0, r4, #0x0
- add r1, r5, #0x0
- add r2, r6, #0x0
- bl MOD05_ShowMessageInField
- add r0, r5, #0x0
- bl DestroyMsgData
- mov r0, #0x0
- pop {r4-r6, pc}
-
- thumb_func_start FUN_0203A098
-FUN_0203A098: ; 0x0203A098
- push {r3-r6, lr}
- sub sp, #0x4
- add r4, r0, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl VarGet
- add r5, r0, #0x0
- add r0, r4, #0x0
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r4, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl VarGet
- add r6, r0, #0x0
- mov r0, #0x1
- mov r1, #0x1a
- add r2, r5, #0x0
- mov r3, #0x20
- bl NewMsgDataFromNarc
- add r5, r0, #0x0
- mov r0, #0x0
- str r0, [sp, #0x0]
- add r0, r4, #0x0
- add r1, r5, #0x0
- add r2, r6, #0x0
- mov r3, #0x1
- bl MOD05_021E2BD0
- add r0, r5, #0x0
- bl DestroyMsgData
- ldr r1, _0203A0F8 ; =FUN_0203A2F0
- add r0, r4, #0x0
- bl SetupNativeScript
- mov r0, #0x1
- add sp, #0x4
- pop {r3-r6, pc}
- nop
-_0203A0F8: .word FUN_0203A2F0
-
- thumb_func_start FUN_0203A0FC
-FUN_0203A0FC: ; 0x0203A0FC
- push {r3-r7, lr}
- sub sp, #0x8
- add r5, r0, #0x0
- bl ScriptReadHalfword
- add r4, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- add r6, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- add r7, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- lsl r0, r0, #0x10
- asr r0, r0, #0x10
- str r0, [sp, #0x0]
- mov r0, #0xff
- str r0, [sp, #0x4]
- add r0, r5, #0x0
- add r1, r4, #0x0
- add r2, r6, #0x0
- add r3, r7, #0x0
- bl MOD05_021E2C58
- mov r0, #0x0
- add sp, #0x8
- pop {r3-r7, pc}
- .balign 4
-
- thumb_func_start FUN_0203A13C
-FUN_0203A13C: ; 0x0203A13C
- push {r3-r7, lr}
- sub sp, #0x8
- add r5, r0, #0x0
- bl ScriptReadHalfword
- add r4, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- add r6, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- add r7, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- lsl r0, r0, #0x10
- asr r0, r0, #0x10
- str r0, [sp, #0x0]
- mov r0, #0x1
- str r0, [sp, #0x4]
- add r0, r5, #0x0
- add r1, r4, #0x0
- add r2, r6, #0x0
- add r3, r7, #0x0
- bl MOD05_021E2C58
- ldr r1, _0203A184 ; =FUN_0203A2F0
- add r0, r5, #0x0
- bl SetupNativeScript
- mov r0, #0x1
- add sp, #0x8
- pop {r3-r7, pc}
- nop
-_0203A184: .word FUN_0203A2F0
-
- thumb_func_start FUN_0203A188
-FUN_0203A188: ; 0x0203A188
- push {r4-r6, lr}
- sub sp, #0x8
- add r5, r0, #0x0
- ldr r2, [r5, #0x8]
- add r1, r2, #0x1
- str r1, [r5, #0x8]
- add r1, r5, #0x0
- add r1, #0x80
- ldr r1, [r1, #0x0]
- ldrb r3, [r2, #0x0]
- add r1, #0xa8
- ldr r2, [r1, #0x0]
- cmp r2, #0x0
- bne _0203A1AA
- add sp, #0x8
- mov r0, #0x0
- pop {r4-r6, pc}
-_0203A1AA:
- lsl r1, r3, #0x4
- add r1, r3, r1
- add r2, #0x90
- lsl r1, r1, #0x4
- add r4, r2, r1
- ldrh r1, [r2, r1]
- ldr r2, _0203A204 ; =0x0000FFFF
- cmp r1, r2
- bne _0203A1E2
- ldr r2, _0203A208 ; =0x0000022B
- mov r0, #0x1
- mov r1, #0x1a
- mov r3, #0x20
- bl NewMsgDataFromNarc
- add r6, r0, #0x0
- mov r0, #0x0
- str r0, [sp, #0x0]
- ldrh r2, [r4, #0x2]
- add r0, r5, #0x0
- add r1, r6, #0x0
- mov r3, #0x1
- bl MOD05_021E2BD0
- add r0, r6, #0x0
- bl DestroyMsgData
- b _0203A1F4
-_0203A1E2:
- mov r2, #0x6
- ldrsh r2, [r4, r2]
- str r2, [sp, #0x0]
- mov r2, #0x1
- str r2, [sp, #0x4]
- ldrh r2, [r4, #0x2]
- ldrh r3, [r4, #0x4]
- bl MOD05_021E2C58
-_0203A1F4:
- ldr r1, _0203A20C ; =FUN_0203A2F0
- add r0, r5, #0x0
- bl SetupNativeScript
- mov r0, #0x1
- add sp, #0x8
- pop {r4-r6, pc}
- nop
-_0203A204: .word 0x0000FFFF
-_0203A208: .word 0x0000022B
-_0203A20C: .word FUN_0203A2F0
-
- thumb_func_start FUN_0203A210
-FUN_0203A210: ; 0x0203A210
- push {r3-r7, lr}
- sub sp, #0x8
- add r5, r0, #0x0
- add r1, r5, #0x0
- add r1, #0x80
- ldr r2, [r5, #0x8]
- ldr r6, [r1, #0x0]
- add r1, r2, #0x1
- str r1, [r5, #0x8]
- ldrb r4, [r2, #0x0]
- bl ScriptReadHalfword
- add r1, r0, #0x0
- add r0, r5, #0x0
- add r0, #0x80
- ldr r0, [r0, #0x0]
- bl VarGet
- add r7, r0, #0x0
- add r0, r5, #0x0
- bl ScriptReadHalfword
- ldr r1, [r5, #0x8]
- add r2, r0, #0x0
- add r0, r1, #0x1
- str r0, [r5, #0x8]
- ldrb r3, [r1, #0x0]
- mov r1, #0x0
- add r0, sp, #0x4
- strb r1, [r0, #0x0]
- add r0, sp, #0x4
- str r0, [sp, #0x0]
- ldr r0, [r6, #0xc]
- add r1, r7, #0x0
- bl MOD06_02244210
- add r6, r0, #0x0
- add r2, sp, #0x4
- ldrb r2, [r2, #0x0]
- add r0, r5, #0x0
- add r1, r6, #0x0
- add r2, r4, r2
- lsl r2, r2, #0x18
- lsr r2, r2, #0x18
- mov r3, #0x1
- bl MOD05_021E2CBC
- add r0, r6, #0x0
- bl ScrStrBufs_delete
- ldr r1, _0203A284 ; =FUN_0203A2F0
- add r0, r5, #0x0
- bl SetupNativeScript
- mov r0, #0x1
- add sp, #0x8
- pop {r3-r7, pc}
- nop
-_0203A284: .word FUN_0203A2F0
-
- thumb_func_start FUN_0203A288
-FUN_0203A288: ; 0x0203A288
- push {r3-r5, lr}
- sub sp, #0x8
- add r5, r0, #0x0
- bl ScriptReadHalfword
- add r4, r0, #0x0
- add r0, sp, #0x4
- add r1, r5, #0x0
- bl MOD05_021E2BB8
- mov r1, #0x3
- add r0, sp, #0x4
- strb r1, [r0, #0x2]
- add r0, sp, #0x4
- str r0, [sp, #0x0]
- ldr r1, [r5, #0x78]
- add r0, r5, #0x0
- add r2, r4, #0x0
- mov r3, #0x0
- bl MOD05_021E2BD0
- ldr r1, _0203A2C0 ; =FUN_0203A2F0
- add r0, r5, #0x0
- bl SetupNativeScript
- mov r0, #0x1
- add sp, #0x8
- pop {r3-r5, pc}
- .balign 4
-_0203A2C0: .word FUN_0203A2F0
-
- thumb_func_start FUN_0203A2C4
-FUN_0203A2C4: ; 0x0203A2C4
- push {r3-r4, lr}
- sub sp, #0x4
- add r4, r0, #0x0
- ldr r2, [r4, #0x8]
- mov r3, #0x1
- add r1, r2, #0x1
- str r1, [r4, #0x8]
- mov r1, #0x0
- str r1, [sp, #0x0]
- ldrb r2, [r2, #0x0]
- ldr r1, [r4, #0x78]
- bl MOD05_021E2BD0
- ldr r1, _0203A2EC ; =FUN_0203A2F0
- add r0, r4, #0x0
- bl SetupNativeScript
- mov r0, #0x1
- add sp, #0x4
- pop {r3-r4, pc}
- .balign 4
-_0203A2EC: .word FUN_0203A2F0
-
- thumb_func_start FUN_0203A2F0
-FUN_0203A2F0: ; 0x0203A2F0
- push {r3, lr}
- add r0, #0x80
- ldr r0, [r0, #0x0]
- mov r1, #0x3
- bl FUN_02039438
- ldrb r0, [r0, #0x0]
- bl FUN_020546C8
- pop {r3, pc}
-
thumb_func_start FUN_0203A304
FUN_0203A304: ; 0x0203A304
push {r3-r4, lr}
diff --git a/arm9/asm/unk_02015E30.s b/arm9/asm/unk_02015E30.s
deleted file mode 100644
index 9ca09399..00000000
--- a/arm9/asm/unk_02015E30.s
+++ /dev/null
@@ -1,72 +0,0 @@
- .include "asm/macros.inc"
- .include "global.inc"
-
- .section .bss
-
- .global UNK_021C4898
-UNK_021C4898: ; 0x021C4898
- .space 0x20
-
- .text
-
- thumb_func_start FUN_02015E30
-FUN_02015E30: ; 0x02015E30
- ldr r0, _02015E38 ; =UNK_021C4898
- mov r1, #0x0
- str r1, [r0, #0x0]
- bx lr
- .balign 4
-_02015E38: .word UNK_021C4898
-
- thumb_func_start FUN_02015E3C
-FUN_02015E3C: ; 0x02015E3C
- push {r3, lr}
- ldr r1, _02015E5C ; =UNK_021C4898
- mov r2, #0x1
- str r2, [r1, #0x0]
- mov r2, #0x0
- str r2, [r1, #0x10]
- str r2, [r1, #0x14]
- str r2, [r1, #0x8]
- str r2, [r1, #0xc]
- str r0, [r1, #0x4]
- bl FUN_02020BF4
- ldr r2, _02015E5C ; =UNK_021C4898
- str r0, [r2, #0x18]
- str r1, [r2, #0x1c]
- pop {r3, pc}
- .balign 4
-_02015E5C: .word UNK_021C4898
-
- thumb_func_start FUN_02015E60
-FUN_02015E60: ; 0x02015E60
- push {r3-r5, lr}
- ldr r0, _02015E9C ; =UNK_021C4898
- ldr r0, [r0, #0x0]
- cmp r0, #0x0
- beq _02015E9A
- bl FUN_02020BF4
- ldr r2, _02015E9C ; =UNK_021C4898
- ldr r3, [r2, #0x18]
- ldr r2, [r2, #0x1c]
- sub r0, r0, r3
- sbc r1, r2
- bl FUN_02020C14
- add r5, r1, #0x0
- ldr r1, _02015E9C ; =UNK_021C4898
- add r4, r0, #0x0
- ldr r3, [r1, #0x8]
- ldr r2, [r1, #0xc]
- sub r0, r3, r4
- sbc r2, r5
- bhs _02015E9A
- ldr r0, [r1, #0x4]
- sub r1, r4, r3
- bl AddIGTSeconds
- ldr r0, _02015E9C ; =UNK_021C4898
- str r4, [r0, #0x8]
- str r5, [r0, #0xc]
-_02015E9A:
- pop {r3-r5, pc}
- .balign 4
-_02015E9C: .word UNK_021C4898
diff --git a/arm9/asm/unk_020166C8.s b/arm9/asm/unk_020166C8.s
deleted file mode 100644
index 3c251114..00000000
--- a/arm9/asm/unk_020166C8.s
+++ /dev/null
@@ -1,665 +0,0 @@
- .include "asm/macros.inc"
- .include "global.inc"
-
- .section .bss
-
- .global UNK_021C4D28
-UNK_021C4D28: ; 0x021C4D28
- .space 0x1c
-
- .text
-
- thumb_func_start FUN_020166C8
-FUN_020166C8: ; 0x020166C8
- push {r3-r7, lr}
- sub sp, #0x8
- add r4, r1, #0x0
- add r5, r0, #0x0
- add r0, r4, #0x0
- str r0, [sp, #0x4]
- add r0, #0x18
- add r6, r2, #0x0
- str r0, [sp, #0x4]
- cmp r6, r0
- bhs _020166E0
- add r6, r0, #0x0
-_020166E0:
- cmp r3, #0x0
- beq _020166FE
- mov r0, #0x3
- tst r0, r3
- beq _020166F4
- mov r0, #0x3
-_020166EC:
- add r3, r3, #0x1
- add r1, r3, #0x0
- tst r1, r0
- bne _020166EC
-_020166F4:
- mov r0, #0x0
- add r1, r3, #0x0
- mov r2, #0x4
- bl OS_AllocFromArenaLo
-_020166FE:
- ldr r1, [sp, #0x4]
- lsl r7, r6, #0x1
- lsl r2, r1, #0x1
- add r1, r1, r2
- add r1, r1, #0x1
- lsl r1, r1, #0x2
- add r1, r7, r1
- mov r0, #0x0
- add r1, r6, r1
- mov r2, #0x4
- bl OS_AllocFromArenaLo
- ldr r1, _020167F0 ; =UNK_021C4D28
- str r0, [r1, #0x0]
- ldr r1, [sp, #0x4]
- add r1, r1, #0x1
- lsl r1, r1, #0x2
- add r1, r0, r1
- ldr r0, _020167F0 ; =UNK_021C4D28
- str r1, [r0, #0x4]
- ldr r0, [sp, #0x4]
- lsl r0, r0, #0x2
- add r2, r1, r0
- ldr r1, _020167F0 ; =UNK_021C4D28
- str r2, [r1, #0x8]
- add r1, r2, r0
- ldr r0, _020167F0 ; =UNK_021C4D28
- str r1, [r0, #0xc]
- add r1, r1, r7
- str r1, [r0, #0x10]
- strh r6, [r0, #0x14]
- strh r4, [r0, #0x16]
- ldr r0, [sp, #0x4]
- mov r7, #0x0
- lsl r0, r0, #0x10
- lsr r1, r0, #0x10
- ldr r0, _020167F0 ; =UNK_021C4D28
- cmp r4, #0x0
- strh r1, [r0, #0x1a]
- strh r1, [r0, #0x18]
- bls _020167A0
- str r7, [sp, #0x0]
-_02016752:
- ldr r0, [r5, #0x4]
- cmp r0, #0x0
- beq _0201675C
- cmp r0, #0x2
- beq _02016768
-_0201675C:
- ldr r1, [r5, #0x0]
- mov r0, #0x0
- mov r2, #0x4
- bl OS_AllocFromArenaLo
- b _02016772
-_02016768:
- ldr r1, [r5, #0x0]
- mov r0, #0x2
- mov r2, #0x4
- bl OS_AllocFromArenaHi
-_02016772:
- cmp r0, #0x0
- beq _0201678E
- ldr r1, [r5, #0x0]
- mov r2, #0x0
- bl tempName_NNS_FndCreateExpHeapEx
- ldr r1, _020167F0 ; =UNK_021C4D28
- ldr r2, [r1, #0x0]
- ldr r1, [sp, #0x0]
- str r0, [r2, r1]
- ldr r0, _020167F0 ; =UNK_021C4D28
- ldr r0, [r0, #0x10]
- strb r7, [r0, r7]
- b _02016792
-_0201678E:
- bl ErrorHandling
-_02016792:
- ldr r0, [sp, #0x0]
- add r7, r7, #0x1
- add r0, r0, #0x4
- add r5, #0x8
- str r0, [sp, #0x0]
- cmp r7, r4
- blo _02016752
-_020167A0:
- ldr r0, [sp, #0x4]
- add r1, r0, #0x1
- cmp r4, r1
- bhs _020167C0
- ldr r3, _020167F0 ; =UNK_021C4D28
- lsl r2, r4, #0x2
- mov r0, #0x0
-_020167AE:
- ldr r5, [r3, #0x0]
- str r0, [r5, r2]
- ldrh r7, [r3, #0x1a]
- ldr r5, [r3, #0x10]
- add r2, r2, #0x4
- strb r7, [r5, r4]
- add r4, r4, #0x1
- cmp r4, r1
- blo _020167AE
-_020167C0:
- cmp r4, r6
- bhs _020167D2
- ldr r0, _020167F0 ; =UNK_021C4D28
-_020167C6:
- ldrh r2, [r0, #0x1a]
- ldr r1, [r0, #0x10]
- strb r2, [r1, r4]
- add r4, r4, #0x1
- cmp r4, r6
- blo _020167C6
-_020167D2:
- mov r4, #0x0
- cmp r6, #0x0
- bls _020167EA
- ldr r0, _020167F0 ; =UNK_021C4D28
- add r3, r4, #0x0
- add r2, r4, #0x0
-_020167DE:
- ldr r1, [r0, #0xc]
- add r4, r4, #0x1
- strh r2, [r1, r3]
- add r3, r3, #0x2
- cmp r4, r6
- blo _020167DE
-_020167EA:
- add sp, #0x8
- pop {r3-r7, pc}
- nop
-_020167F0: .word UNK_021C4D28
-
- thumb_func_start FUN_020167F4
-FUN_020167F4: ; 0x020167F4
- ldr r1, _02016818 ; =UNK_021C4D28
- ldrh r0, [r1, #0x16]
- ldrh r3, [r1, #0x18]
- cmp r0, r3
- bge _02016812
- ldr r2, [r1, #0x0]
- lsl r1, r0, #0x2
- add r2, r2, r1
-_02016804:
- ldr r1, [r2, #0x0]
- cmp r1, #0x0
- beq _02016816
- add r0, r0, #0x1
- add r2, r2, #0x4
- cmp r0, r3
- blt _02016804
-_02016812:
- mov r0, #0x0
- mvn r0, r0
-_02016816:
- bx lr
- .balign 4
-_02016818: .word UNK_021C4D28
-
- thumb_func_start FUN_0201681C
-FUN_0201681C: ; 0x0201681C
- push {r3, lr}
- mov r3, #0x4
- bl FUN_02016834
- pop {r3, pc}
- .balign 4
-
- thumb_func_start FUN_02016828
-FUN_02016828: ; 0x02016828
- push {r3, lr}
- mov r3, #0x3
- mvn r3, r3
- bl FUN_02016834
- pop {r3, pc}
-
- thumb_func_start FUN_02016834
-FUN_02016834: ; 0x02016834
- push {r3-r7, lr}
- sub sp, #0x8
- add r4, r0, #0x0
- add r5, r1, #0x0
- str r2, [sp, #0x0]
- add r7, r3, #0x0
- bl OS_GetProcMode
- cmp r0, #0x12
- bne _0201684C
- bl ErrorHandling
-_0201684C:
- ldr r1, _020168CC ; =UNK_021C4D28
- ldr r0, [r1, #0x10]
- ldrh r3, [r1, #0x1a]
- ldrb r2, [r0, r5]
- cmp r3, r2
- bne _020168C2
- ldrb r0, [r0, r4]
- ldr r1, [r1, #0x0]
- lsl r0, r0, #0x2
- ldr r6, [r1, r0]
- cmp r6, #0x0
- beq _020168BC
- ldr r1, [sp, #0x0]
- add r0, r6, #0x0
- add r2, r7, #0x0
- bl tempName_NNS_FndAllocFromExpHeapEx
- str r0, [sp, #0x4]
- cmp r0, #0x0
- beq _020168B6
- bl FUN_020167F4
- add r7, r0, #0x0
- bmi _020168B0
- ldr r0, [sp, #0x4]
- ldr r1, [sp, #0x0]
- mov r2, #0x0
- lsl r4, r7, #0x2
- bl tempName_NNS_FndCreateExpHeapEx
- ldr r1, _020168CC ; =UNK_021C4D28
- ldr r2, [r1, #0x0]
- str r0, [r2, r4]
- ldr r0, [r1, #0x0]
- ldr r0, [r0, r4]
- cmp r0, #0x0
- beq _020168AA
- ldr r0, [r1, #0x4]
- str r6, [r0, r4]
- ldr r0, [sp, #0x4]
- ldr r2, [r1, #0x8]
- add sp, #0x8
- str r0, [r2, r4]
- ldr r0, [r1, #0x10]
- strb r7, [r0, r5]
- mov r0, #0x1
- pop {r3-r7, pc}
-_020168AA:
- bl ErrorHandling
- b _020168C6
-_020168B0:
- bl ErrorHandling
- b _020168C6
-_020168B6:
- bl ErrorHandling
- b _020168C6
-_020168BC:
- bl ErrorHandling
- b _020168C6
-_020168C2:
- bl ErrorHandling
-_020168C6:
- mov r0, #0x0
- add sp, #0x8
- pop {r3-r7, pc}
- .balign 4
-_020168CC: .word UNK_021C4D28
-
- thumb_func_start FUN_020168D0
-FUN_020168D0: ; 0x020168D0
- push {r4, lr}
- add r4, r0, #0x0
- bl OS_GetProcMode
- cmp r0, #0x12
- bne _020168E0
- bl ErrorHandling
-_020168E0:
- ldr r0, _02016940 ; =UNK_021C4D28
- ldr r1, [r0, #0x0]
- ldr r0, [r0, #0x10]
- ldrb r0, [r0, r4]
- lsl r0, r0, #0x2
- ldr r0, [r1, r0]
- cmp r0, #0x0
- beq _0201693E
- bl thunk_FUN_020adc8c
- ldr r1, _02016940 ; =UNK_021C4D28
- ldr r0, [r1, #0x10]
- ldrb r0, [r0, r4]
- lsl r2, r0, #0x2
- ldr r0, [r1, #0x4]
- ldr r1, [r1, #0x8]
- ldr r0, [r0, r2]
- ldr r1, [r1, r2]
- cmp r0, #0x0
- beq _02016912
- cmp r1, #0x0
- beq _02016912
- bl FUN_020ADDF0
- b _02016916
-_02016912:
- bl ErrorHandling
-_02016916:
- ldr r1, _02016940 ; =UNK_021C4D28
- mov r0, #0x0
- ldr r2, [r1, #0x10]
- ldr r3, [r1, #0x0]
- ldrb r2, [r2, r4]
- lsl r2, r2, #0x2
- str r0, [r3, r2]
- ldr r2, [r1, #0x10]
- ldr r3, [r1, #0x4]
- ldrb r2, [r2, r4]
- lsl r2, r2, #0x2
- str r0, [r3, r2]
- ldr r2, [r1, #0x10]
- ldr r3, [r1, #0x8]
- ldrb r2, [r2, r4]
- lsl r2, r2, #0x2
- str r0, [r3, r2]
- ldrh r2, [r1, #0x1a]
- ldr r0, [r1, #0x10]
- strb r2, [r0, r4]
-_0201693E:
- pop {r4, pc}
- .balign 4
-_02016940: .word UNK_021C4D28
-
- thumb_func_start FUN_02016944
-FUN_02016944: ; 0x02016944
- push {r3-r7, lr}
- add r5, r0, #0x0
- add r4, r1, #0x0
- add r7, r2, #0x0
- add r6, r3, #0x0
- cmp r5, #0x0
- bne _02016956
- bl ErrorHandling
-_02016956:
- bl OS_DisableInterrupts
- add r4, #0x10
- str r0, [sp, #0x0]
- add r0, r5, #0x0
- add r1, r4, #0x0
- add r2, r7, #0x0
- bl tempName_NNS_FndAllocFromExpHeapEx
- add r4, r0, #0x0
- ldr r0, [sp, #0x0]
- bl OS_RestoreInterrupts
- cmp r4, #0x0
- beq _02016984
- ldr r1, [r4, #0xc]
- mov r0, #0xff
- bic r1, r0
- lsl r0, r6, #0x18
- lsr r0, r0, #0x18
- orr r0, r1
- str r0, [r4, #0xc]
- add r4, #0x10
-_02016984:
- add r0, r4, #0x0
- pop {r3-r7, pc}
-
- thumb_func_start FUN_02016988
-FUN_02016988: ; 0x02016988
- push {r3, lr}
- bl FUN_02031810
- cmp r0, #0x0
- beq _02016996
- bl PrintErrorMessageAndReset
-_02016996:
- pop {r3, pc}
-
- thumb_func_start AllocFromHeap
-AllocFromHeap: ; 0x02016998
- push {r3-r5, lr}
- add r5, r0, #0x0
- ldr r0, _020169D4 ; =UNK_021C4D28
- mov r4, #0x0
- ldrh r2, [r0, #0x14]
- cmp r5, r2
- bhs _020169BA
- ldr r2, [r0, #0x0]
- ldr r0, [r0, #0x10]
- add r3, r5, #0x0
- ldrb r0, [r0, r5]
- lsl r0, r0, #0x2
- ldr r0, [r2, r0]
- mov r2, #0x4
- bl FUN_02016944
- add r4, r0, #0x0
-_020169BA:
- cmp r4, #0x0
- beq _020169CC
- ldr r0, _020169D4 ; =UNK_021C4D28
- lsl r1, r5, #0x1
- ldr r2, [r0, #0xc]
- ldrh r0, [r2, r1]
- add r0, r0, #0x1
- strh r0, [r2, r1]
- b _020169D0
-_020169CC:
- bl FUN_02016988
-_020169D0:
- add r0, r4, #0x0
- pop {r3-r5, pc}
- .balign 4
-_020169D4: .word UNK_021C4D28
-
- thumb_func_start AllocFromHeapAtEnd
-AllocFromHeapAtEnd: ; 0x020169D8
- push {r3-r5, lr}
- ldr r2, _02016A14 ; =UNK_021C4D28
- add r5, r0, #0x0
- ldrh r0, [r2, #0x14]
- mov r4, #0x0
- cmp r5, r0
- bhs _020169FA
- ldr r0, [r2, #0x0]
- ldr r2, [r2, #0x10]
- add r3, r5, #0x0
- ldrb r2, [r2, r5]
- lsl r2, r2, #0x2
- ldr r0, [r0, r2]
- sub r2, r4, #0x4
- bl FUN_02016944
- add r4, r0, #0x0
-_020169FA:
- cmp r4, #0x0
- beq _02016A0C
- ldr r0, _02016A14 ; =UNK_021C4D28
- lsl r1, r5, #0x1
- ldr r2, [r0, #0xc]
- ldrh r0, [r2, r1]
- add r0, r0, #0x1
- strh r0, [r2, r1]
- b _02016A10
-_02016A0C:
- bl FUN_02016988
-_02016A10:
- add r0, r4, #0x0
- pop {r3-r5, pc}
- .balign 4
-_02016A14: .word UNK_021C4D28
-
- thumb_func_start FreeToHeap
-FreeToHeap: ; 0x02016A18
- push {r3-r7, lr}
- add r6, r0, #0x0
- sub r0, r6, #0x4
- ldr r0, [r0, #0x0]
- lsl r0, r0, #0x18
- lsr r4, r0, #0x18
- ldr r0, _02016A88 ; =UNK_021C4D28
- ldrh r1, [r0, #0x14]
- cmp r4, r1
- bhs _02016A80
- ldr r1, [r0, #0x0]
- ldr r0, [r0, #0x10]
- ldrb r0, [r0, r4]
- lsl r0, r0, #0x2
- ldr r7, [r1, r0]
- cmp r7, #0x0
- bne _02016A3E
- bl ErrorHandling
-_02016A3E:
- ldr r0, _02016A88 ; =UNK_021C4D28
- lsl r5, r4, #0x1
- ldr r0, [r0, #0xc]
- ldrh r0, [r0, r5]
- cmp r0, #0x0
- bne _02016A50
- add r0, r4, #0x0
- bl FUN_02016B90
-_02016A50:
- ldr r0, _02016A88 ; =UNK_021C4D28
- ldr r0, [r0, #0xc]
- ldrh r0, [r0, r5]
- cmp r0, #0x0
- bne _02016A5E
- bl ErrorHandling
-_02016A5E:
- ldr r0, _02016A88 ; =UNK_021C4D28
- ldr r1, [r0, #0xc]
- ldrh r0, [r1, r5]
- sub r0, r0, #0x1
- strh r0, [r1, r5]
- bl OS_DisableInterrupts
- sub r6, #0x10
- add r4, r0, #0x0
- add r0, r7, #0x0
- add r1, r6, #0x0
- bl FUN_020ADDF0
- add r0, r4, #0x0
- bl OS_RestoreInterrupts
- pop {r3-r7, pc}
-_02016A80:
- bl ErrorHandling
- pop {r3-r7, pc}
- nop
-_02016A88: .word UNK_021C4D28
-
- thumb_func_start FUN_02016A8C
-FUN_02016A8C: ; 0x02016A8C
- push {r4-r6, lr}
- add r5, r0, #0x0
- add r4, r1, #0x0
- bl OS_GetProcMode
- cmp r0, #0x12
- bne _02016A9E
- bl ErrorHandling
-_02016A9E:
- ldr r0, _02016AF4 ; =UNK_021C4D28
- ldrh r1, [r0, #0x14]
- cmp r5, r1
- bhs _02016AEE
- ldr r1, [r0, #0x0]
- ldr r0, [r0, #0x10]
- ldrb r0, [r0, r5]
- lsl r0, r0, #0x2
- ldr r6, [r1, r0]
- cmp r6, #0x0
- bne _02016AB8
- bl ErrorHandling
-_02016AB8:
- sub r0, r4, #0x4
- ldr r0, [r0, #0x0]
- lsl r0, r0, #0x18
- lsr r0, r0, #0x18
- cmp r0, r5
- beq _02016AC8
- bl ErrorHandling
-_02016AC8:
- sub r4, #0x10
- add r0, r6, #0x0
- add r1, r4, #0x0
- bl FUN_020ADDF0
- ldr r0, _02016AF4 ; =UNK_021C4D28
- lsl r4, r5, #0x1
- ldr r0, [r0, #0xc]
- ldrh r0, [r0, r4]
- cmp r0, #0x0
- bne _02016AE2
- bl ErrorHandling
-_02016AE2:
- ldr r0, _02016AF4 ; =UNK_021C4D28
- ldr r1, [r0, #0xc]
- ldrh r0, [r1, r4]
- sub r0, r0, #0x1
- strh r0, [r1, r4]
- pop {r4-r6, pc}
-_02016AEE:
- bl ErrorHandling
- pop {r4-r6, pc}
- .balign 4
-_02016AF4: .word UNK_021C4D28
-
- thumb_func_start FUN_02016AF8
-FUN_02016AF8: ; 0x02016AF8
- push {r3, lr}
- ldr r1, _02016B1C ; =UNK_021C4D28
- ldrh r2, [r1, #0x14]
- cmp r0, r2
- bhs _02016B12
- ldr r2, [r1, #0x0]
- ldr r1, [r1, #0x10]
- ldrb r0, [r1, r0]
- lsl r0, r0, #0x2
- ldr r0, [r2, r0]
- bl FUN_020ADDC8
- pop {r3, pc}
-_02016B12:
- bl ErrorHandling
- mov r0, #0x0
- pop {r3, pc}
- nop
-_02016B1C: .word UNK_021C4D28
-
- thumb_func_start FUN_02016B20
-FUN_02016B20: ; 0x02016B20
- push {r4, lr}
- ldr r4, _02016B40 ; =UNK_021C4D28
- ldrh r3, [r4, #0x14]
- cmp r1, r3
- bhs _02016B3A
- ldr r3, [r4, #0x0]
- ldr r4, [r4, #0x10]
- ldrb r1, [r4, r1]
- lsl r1, r1, #0x2
- ldr r1, [r3, r1]
- bl FUN_020AE82C
- pop {r4, pc}
-_02016B3A:
- bl ErrorHandling
- pop {r4, pc}
- .balign 4
-_02016B40: .word UNK_021C4D28
-
- thumb_func_start FUN_02016B44
-FUN_02016B44: ; 0x02016B44
- push {r3-r5, lr}
- add r5, r0, #0x0
- add r4, r1, #0x0
- bl OS_GetProcMode
- cmp r0, #0x12
- bne _02016B56
- bl ErrorHandling
-_02016B56:
- add r0, r5, #0x0
- sub r0, #0x10
- bl FUN_020ADDC0
- add r4, #0x10
- cmp r0, r4
- blo _02016B84
- sub r2, r5, #0x4
- ldr r0, _02016B8C ; =UNK_021C4D28
- ldr r2, [r2, #0x0]
- ldr r1, [r0, #0x0]
- lsl r2, r2, #0x18
- ldr r0, [r0, #0x10]
- lsr r2, r2, #0x18
- ldrb r0, [r0, r2]
- sub r5, #0x10
- add r2, r4, #0x0
- lsl r0, r0, #0x2
- ldr r0, [r1, r0]
- add r1, r5, #0x0
- bl FUN_020ADE2C
- pop {r3-r5, pc}
-_02016B84:
- bl ErrorHandling
- pop {r3-r5, pc}
- nop
-_02016B8C: .word UNK_021C4D28
-
- thumb_func_start FUN_02016B90
-FUN_02016B90: ; 0x02016B90
- mov r0, #0x1
- bx lr
diff --git a/arm9/asm/unk_02038C78.s b/arm9/asm/unk_02038C78.s
index f35fd58e..3978d8c1 100644
--- a/arm9/asm/unk_02038C78.s
+++ b/arm9/asm/unk_02038C78.s
@@ -149,51 +149,51 @@ UNK_020F3538: ; 0x020F3538
.global gScriptCmdTable
gScriptCmdTable: ; 0x020F355C
- .word ScrCmd_nop
- .word ScrCmd_nop2
- .word ScrCmd_end
- .word ScrCmd_delay
- .word ScrCmd_loadbyte
- .word ScrCmd_loadword
- .word ScrCmd_loadbytefromaddr
- .word ScrCmd_writebytetoaddr
- .word ScrCmd_setptrbyte
- .word ScrCmd_copylocal
- .word ScrCmd_copybyte
- .word ScrCmd_compare_local_to_local
- .word ScrCmd_compare_local_to_value
- .word ScrCmd_compare_local_to_addr
- .word ScrCmd_compare_addr_to_local
- .word ScrCmd_compare_addr_to_value
- .word ScrCmd_compare_addr_to_addr
- .word ScrCmd_compare_var_to_value
- .word ScrCmd_compare_var_to_var
- .word FUN_02039C40
- .word FUN_02039C78
- .word FUN_02039CE4
- .word ScrCmd_goto
- .word FUN_02039D10
- .word FUN_02039D48
- .word FUN_02039D78
- .word ScrCmd_call
- .word ScrCmd_return
- .word ScrCmd_goto_if
- .word ScrCmd_call_if
- .word ScrCmd_setflag
- .word ScrCmd_clearflag
- .word ScrCmd_checkflag
- .word FUN_02039E84
- .word FUN_02039EC0
- .word ScrCmd_settrainerflag
- .word ScrCmd_cleartrainerflag
- .word ScrCmd_checktrainerflag
- .word ScrCmd_addvar
- .word ScrCmd_subvar
- .word ScrCmd_setvar
- .word ScrCmd_copyvar
- .word ScrCmd_setorcopyvar
- .word ScrCmd_message
- .word FUN_0203A2C4
+ .word ScrCmd_Nop
+ .word ScrCmd_Dummy
+ .word ScrCmd_End
+ .word ScrCmd_Wait
+ .word ScrCmd_LoadByte
+ .word ScrCmd_LoadWord
+ .word ScrCmd_LoadByteFromAddr
+ .word ScrCmd_WriteByteToAddr
+ .word ScrCmd_SetPtrByte
+ .word ScrCmd_CopyLocal
+ .word ScrCmd_CopyByte
+ .word ScrCmd_CompareLocalToLocal
+ .word ScrCmd_CompareLocalToValue
+ .word ScrCmd_CompareLocalToAddr
+ .word ScrCmd_CompareAddrToLocal
+ .word ScrCmd_CompareAddrToValue
+ .word ScrCmd_CompareAddrToAddr
+ .word ScrCmd_CompareVarToValue
+ .word ScrCmd_CompareVarToVar
+ .word ScrCmd_RunScript
+ .word ScrCmd_RunScriptWait
+ .word ScrCmd_RestartCurrentScript
+ .word ScrCmd_GoTo
+ .word ScrCmd_ObjectGoTo
+ .word ScrCmd_BgGoTo
+ .word ScrCmd_DirectionGoTo
+ .word ScrCmd_Call
+ .word ScrCmd_Return
+ .word ScrCmd_GoToIf
+ .word ScrCmd_CallIf
+ .word ScrCmd_SetFlag
+ .word ScrCmd_ClearFlag
+ .word ScrCmd_CheckFlag
+ .word ScrCmd_CheckFlagVar
+ .word ScrCmd_SetFlagVar
+ .word ScrCmd_SetTrainerFlag
+ .word ScrCmd_ClearTrainerFlag
+ .word ScrCmd_CheckTrainerFlag
+ .word ScrCmd_AddVar
+ .word ScrCmd_SubVar
+ .word ScrCmd_SetVar
+ .word ScrCmd_CopyVar
+ .word ScrCmd_SetOrCopyVar
+ .word ScrCmd_Message
+ .word ScrCmd_Unk002C
.word FUN_0203A304
.word FUN_0203A388
.word FUN_0203A400
@@ -299,7 +299,7 @@ gScriptCmdTable: ; 0x020F355C
.word FUN_0203B81C
.word FUN_0203B85C
.word FUN_0203B8A0
- .word ScrCmd_givemon
+ .word ScrCmd_GiveMon
.word ScrCmd_giveegg
.word ScrCmd_setpartymonmove
.word ScrCmd_partymonhasmove
@@ -654,13 +654,13 @@ gScriptCmdTable: ; 0x020F355C
.word ScrCmd_countpartymonsatorbelowlevel
.word ScrCmd_survivepsn
.word FUN_0203BC2C
- .word FUN_02039A10
- .word ScrCmd_message_from
- .word FUN_0203A098
- .word FUN_0203A0FC
- .word FUN_0203A13C
- .word FUN_0203A188
- .word FUN_0203A210
+ .word ScrCmd_DebugWatch
+ .word ScrCmd_MessageFrom
+ .word ScrCmd_MessageFrom2
+ .word ScrCmd_Unk01FC
+ .word ScrCmd_Unk01FD
+ .word ScrCmd_Unk01FE
+ .word ScrCmd_Unk01FF
.word FUN_0203C7F4
.word FUN_0203C820
.word FUN_0203E5DC
@@ -770,7 +770,7 @@ gScriptCmdTable: ; 0x020F355C
.word FUN_0203F110
.word FUN_0203F174
.word FUN_0203F19C
- .word FUN_0203A288
+ .word ScrCmd_Unk026D
.word FUN_0203F234
.word FUN_0203F254
.word FUN_0203F26C
diff --git a/arm9/global.inc b/arm9/global.inc
index d816d92a..0190b134 100644
--- a/arm9/global.inc
+++ b/arm9/global.inc
@@ -1582,8 +1582,8 @@
.extern FUN_02024EC0
.extern FUN_02024ECC
.extern FUN_02024ED8
-.extern FUN_02024EE8
-.extern FUN_02024EF4
+.extern GetRivalNamePtr
+.extern RivalsNameToU16Array
.extern FUN_02024F0C
.extern FUN_02024F18
.extern Options_new
@@ -2699,59 +2699,59 @@
.extern FUN_02039754
.extern RunPokemonCenterScriptsInNewContext
.extern FUN_0203989C
-.extern ScrCmd_nop
-.extern ScrCmd_nop2
-.extern ScrCmd_end
-.extern ScrCmd_delay
-.extern FUN_02039A10
-.extern ScrCmd_loadbyte
-.extern ScrCmd_loadword
-.extern ScrCmd_loadbytefromaddr
-.extern ScrCmd_writebytetoaddr
-.extern ScrCmd_setptrbyte
-.extern ScrCmd_copylocal
-.extern ScrCmd_copybyte
-.extern ScrCmd_compare_local_to_local
-.extern ScrCmd_compare_local_to_value
-.extern ScrCmd_compare_local_to_addr
-.extern ScrCmd_compare_addr_to_local
-.extern ScrCmd_compare_addr_to_value
-.extern ScrCmd_compare_addr_to_addr
-.extern ScrCmd_compare_var_to_value
-.extern ScrCmd_compare_var_to_var
-.extern FUN_02039C40
-.extern FUN_02039C78
-.extern FUN_02039CE4
-.extern ScrCmd_goto
-.extern FUN_02039D10
-.extern FUN_02039D48
-.extern FUN_02039D78
-.extern ScrCmd_call
-.extern ScrCmd_return
-.extern ScrCmd_goto_if
-.extern ScrCmd_call_if
-.extern ScrCmd_setflag
-.extern ScrCmd_clearflag
-.extern ScrCmd_checkflag
-.extern FUN_02039E84
-.extern FUN_02039EC0
-.extern ScrCmd_settrainerflag
-.extern ScrCmd_cleartrainerflag
-.extern ScrCmd_checktrainerflag
-.extern ScrCmd_addvar
-.extern ScrCmd_subvar
-.extern ScrCmd_setvar
-.extern ScrCmd_copyvar
-.extern ScrCmd_setorcopyvar
-.extern ScrCmd_message
-.extern ScrCmd_message_from
-.extern FUN_0203A098
-.extern FUN_0203A0FC
-.extern FUN_0203A13C
-.extern FUN_0203A188
-.extern FUN_0203A210
-.extern FUN_0203A288
-.extern FUN_0203A2C4
+.extern ScrCmd_Nop
+.extern ScrCmd_Dummy
+.extern ScrCmd_End
+.extern ScrCmd_Wait
+.extern ScrCmd_DebugWatch
+.extern ScrCmd_LoadByte
+.extern ScrCmd_LoadWord
+.extern ScrCmd_LoadByteFromAddr
+.extern ScrCmd_WriteByteToAddr
+.extern ScrCmd_SetPtrByte
+.extern ScrCmd_CopyLocal
+.extern ScrCmd_CopyByte
+.extern ScrCmd_CompareLocalToLocal
+.extern ScrCmd_CompareLocalToValue
+.extern ScrCmd_CompareLocalToAddr
+.extern ScrCmd_CompareAddrToLocal
+.extern ScrCmd_CompareAddrToValue
+.extern ScrCmd_CompareAddrToAddr
+.extern ScrCmd_CompareVarToValue
+.extern ScrCmd_CompareVarToVar
+.extern ScrCmd_RunScript
+.extern ScrCmd_RunScriptWait
+.extern ScrCmd_RestartCurrentScript
+.extern ScrCmd_GoTo
+.extern ScrCmd_ObjectGoTo
+.extern ScrCmd_BgGoTo
+.extern ScrCmd_DirectionGoTo
+.extern ScrCmd_Call
+.extern ScrCmd_Return
+.extern ScrCmd_GoToIf
+.extern ScrCmd_CallIf
+.extern ScrCmd_SetFlag
+.extern ScrCmd_ClearFlag
+.extern ScrCmd_CheckFlag
+.extern ScrCmd_CheckFlagVar
+.extern ScrCmd_SetFlagVar
+.extern ScrCmd_SetTrainerFlag
+.extern ScrCmd_ClearTrainerFlag
+.extern ScrCmd_CheckTrainerFlag
+.extern ScrCmd_AddVar
+.extern ScrCmd_SubVar
+.extern ScrCmd_SetVar
+.extern ScrCmd_CopyVar
+.extern ScrCmd_SetOrCopyVar
+.extern ScrCmd_Message
+.extern ScrCmd_MessageFrom
+.extern ScrCmd_MessageFrom2
+.extern ScrCmd_Unk01FC
+.extern ScrCmd_Unk01FD
+.extern ScrCmd_Unk01FE
+.extern ScrCmd_Unk01FF
+.extern ScrCmd_Unk026D
+.extern ScrCmd_Unk002C
.extern FUN_0203A304
.extern FUN_0203A340
.extern FUN_0203A388
@@ -3320,7 +3320,7 @@
.extern FUN_02044158
.extern FUN_0204416C
.extern FUN_02044198
-.extern ScrCmd_givemon
+.extern ScrCmd_GiveMon
.extern ScrCmd_getpartyspecies
.extern ScrCmd_checkpartymonotid
.extern ScrCmd_giveegg
diff --git a/arm9/modules/05/src/mod05_021E72FC.c b/arm9/modules/05/src/mod05_021E72FC.c
index 8a31d032..c24a7bd3 100644
--- a/arm9/modules/05/src/mod05_021E72FC.c
+++ b/arm9/modules/05/src/mod05_021E72FC.c
@@ -2,6 +2,7 @@
#include "mod05_021E72FC.h"
#include "heap.h"
+
extern void FUN_020054C8(u32 param0);
extern void FUN_020463CC(u32 param0, void *func, UnkStruct021E7358 *param2);
extern u32 FUN_020553A0(u32 param0);
@@ -19,7 +20,6 @@ extern void FUN_02055304(u32 param0, u32 param1);
extern BOOL FUN_02056B74(u32 param0, u32 param1, u32 param2);
extern void FUN_02058418(u32 param0, u32 param1);
extern void FUN_020054F0(u32 param0, u32 param1);
-extern void FUN_02016A8C(u32 param0, void *param1);
THUMB_FUNC BOOL MOD05_021E72FC(u32 param0, u32 param1)
{
diff --git a/arm9/modules/52/asm/module_52.s b/arm9/modules/52/asm/module_52.s
deleted file mode 100644
index 22824930..00000000
--- a/arm9/modules/52/asm/module_52.s
+++ /dev/null
@@ -1,293 +0,0 @@
- .include "asm/macros.inc"
- .include "global.inc"
- .section .text
- .balign 4, 0
-
- thumb_func_start MOD52_021D74E0
-MOD52_021D74E0: ; 0x021D74E0
- push {r3, lr}
- mov r2, #2
- mov r0, #3
- mov r1, #0x4d
- lsl r2, r2, #0x10
- bl FUN_0201681C
- bl InitializeMainRNG
- mov r0, #1
- pop {r3, pc}
- .align 2, 0
- thumb_func_end MOD52_021D74E0
-
- thumb_func_start MOD52_021D74F8
-MOD52_021D74F8: ; 0x021D74F8
- push {r3, lr}
- bl OverlayManager_GetField18
- ldr r1, [r0, #8]
- mov r0, #0x4d
- bl MOD52_021D769C
- mov r0, #1
- pop {r3, pc}
- .align 2, 0
- thumb_func_end MOD52_021D74F8
-
- thumb_func_start MOD52_021D750C
-MOD52_021D750C: ; 0x021D750C
- push {r3, lr}
- mov r0, #0x4d
- bl FUN_020168D0
- mov r0, #0
- ldr r1, _021D7524 ; =UNK_020FD144
- mvn r0, r0
- bl RegisterMainOverlay
- mov r0, #1
- pop {r3, pc}
- nop
-_021D7524: .word UNK_020FD144
- thumb_func_end MOD52_021D750C
-
- thumb_func_start MOD52_021D7528
-MOD52_021D7528: ; 0x021D7528
- push {r3, lr}
- mov r2, #2
- mov r0, #3
- mov r1, #0x4d
- lsl r2, r2, #0x10
- bl FUN_0201681C
- bl InitializeMainRNG
- mov r0, #1
- pop {r3, pc}
- .align 2, 0
- thumb_func_end MOD52_021D7528
-
- thumb_func_start MOD52_021D7540
-MOD52_021D7540: ; 0x021D7540
- push {r4, lr}
- bl OverlayManager_GetField18
- ldr r4, [r0, #8]
- mov r0, #0x4d
- add r1, r4, #0
- mov r2, #1
- bl MOD52_021D7604
- add r0, r4, #0
- bl Sav2_PlayerData_GetIGTAddr
- bl FUN_02015E3C
- mov r0, #1
- pop {r4, pc}
- thumb_func_end MOD52_021D7540
-
- thumb_func_start MOD52_021D7560
-MOD52_021D7560: ; 0x021D7560
- push {r3, lr}
- mov r0, #0x4d
- bl FUN_020168D0
- mov r0, #0
- ldr r1, _021D7578 ; =UNK_020F2B7C
- mvn r0, r0
- bl RegisterMainOverlay
- mov r0, #1
- pop {r3, pc}
- nop
-_021D7578: .word UNK_020F2B7C
- thumb_func_end MOD52_021D7560
-
- thumb_func_start MOD52_021D757C
-MOD52_021D757C: ; 0x021D757C
- push {r3, lr}
- mov r2, #2
- mov r0, #3
- mov r1, #0x4d
- lsl r2, r2, #0x10
- bl FUN_0201681C
- bl InitializeMainRNG
- mov r0, #1
- pop {r3, pc}
- .align 2, 0
- thumb_func_end MOD52_021D757C
-
- thumb_func_start MOD52_021D7594
-MOD52_021D7594: ; 0x021D7594
- push {r3, r4, r5, lr}
- bl OverlayManager_GetField18
- ldr r4, [r0, #8]
- add r0, r4, #0
- bl Sav2_SysInfo_get
- add r5, r0, #0
- mov r0, #0x4d
- add r1, r4, #0
- bl MOD52_021D7688
- add r0, r4, #0
- mov r1, #0
- bl Options_SetButtonModeOnMain
- add r0, r5, #0
- bl Sav2_SysInfo_MacAddressIsMine
- cmp r0, #0
- beq _021D75C8
- add r0, r5, #0
- bl Sav2_SysInfo_RTCOffsetIsMine
- cmp r0, #0
- bne _021D75D8
-_021D75C8:
- add r0, r4, #0
- bl Sav2_SysInfo_RTC_get
- bl FUN_020238A4
- add r0, r5, #0
- bl Sav2_SysInfo_InitFromSystem
-_021D75D8:
- add r0, r4, #0
- bl Sav2_PlayerData_GetIGTAddr
- bl FUN_02015E3C
- mov r0, #1
- pop {r3, r4, r5, pc}
- .align 2, 0
- thumb_func_end MOD52_021D7594
-
- thumb_func_start MOD52_021D75E8
-MOD52_021D75E8: ; 0x021D75E8
- push {r3, lr}
- mov r0, #0x4d
- bl FUN_020168D0
- mov r0, #0
- ldr r1, _021D7600 ; =UNK_020F2B8C
- mvn r0, r0
- bl RegisterMainOverlay
- mov r0, #1
- pop {r3, pc}
- nop
-_021D7600: .word UNK_020F2B8C
- thumb_func_end MOD52_021D75E8
-
- thumb_func_start MOD52_021D7604
-MOD52_021D7604: ; 0x021D7604
- push {r3, r4, r5, r6, r7, lr}
- add r5, r1, #0
- str r0, [sp]
- add r0, r5, #0
- add r6, r2, #0
- bl Sav2_SysInfo_get
- bl Sav2_SysInfo_InitFromSystem
- add r0, r5, #0
- bl Sav2_SysInfo_RTC_get
- bl Sav2_SysInfo_RTC_init
- add r0, r5, #0
- bl FUN_0202881C
- add r4, r0, #0
- bl MTRandom
- add r2, r0, #0
- add r0, r4, #0
- mov r1, #1
- bl FUN_02028788
- add r0, r5, #0
- bl FUN_0206007C
- add r0, r5, #0
- bl Sav2_PlayerData_GetProfileAddr
- add r4, r0, #0
- bl MTRandom
- add r7, r0, #0
- cmp r6, #0
- beq _021D7656
- add r0, r4, #0
- add r1, r7, #0
- bl PlayerProfile_SetTrainerID
-_021D7656:
- add r0, r4, #0
- bl PlayerProfile_GetTrainerGender
- add r1, r0, #0
- add r0, r7, #0
- mov r2, #0
- bl FUN_02053678
- add r1, r0, #0
- lsl r1, r1, #0x18
- add r0, r4, #0
- lsr r1, r1, #0x18
- bl PlayerProfile_SetAvatar
- add r0, r5, #0
- bl FUN_02024ECC
- ldr r1, [sp]
- ldr r2, _021D7684 ; =0x021D76F8
- mov r3, #0x76
- bl FUN_020250C4
- pop {r3, r4, r5, r6, r7, pc}
- .align 2, 0
-_021D7684: .word MOD52_021D76F8
- thumb_func_end MOD52_021D7604
-
- thumb_func_start MOD52_021D7688
-MOD52_021D7688: ; 0x021D7688
- push {r3, lr}
- add r0, r1, #0
- bl FUN_020226FC
- cmp r0, #0
- bne _021D769A
- mov r0, #0
- bl OS_ResetSystem
-_021D769A:
- pop {r3, pc}
- thumb_func_end MOD52_021D7688
-
- thumb_func_start MOD52_021D769C
-MOD52_021D769C: ; 0x021D769C
- push {r4, lr}
- add r4, r1, #0
- add r0, r4, #0
- bl Sav2_InitDynamicRegion
- add r0, r4, #0
- bl FUN_020377E0
- add r0, r4, #0
- bl Sav2_PlayerData_GetProfileAddr
- ldr r1, _021D76C4 ; =0x00000BB8
- bl PlayerProfile_SetMoney
- add r0, r4, #0
- bl SavArray_Flags_get
- bl FUN_0205ECD4
- pop {r4, pc}
- .align 2, 0
-_021D76C4: .word 0x00000BB8
- thumb_func_end MOD52_021D769C
-
- .rodata
- .global MOD52_021D76C8
-MOD52_021D76C8: ; 0x021D76C8
- .word MOD52_021D757C, MOD52_021D7594, MOD52_021D75E8, 0xFFFFFFFF
-
- .global MOD52_021D76D8
-MOD52_021D76D8: ; 0x021D76D8
- .word MOD52_021D7528, MOD52_021D7540, MOD52_021D7560, 0xFFFFFFFF
-
- .global MOD52_021D76E8
-MOD52_021D76E8: ; 0x021D76E8
- .word MOD52_021D74E0, MOD52_021D74F8, MOD52_021D750C, 0xFFFFFFFF
-
- .global MOD52_021D76F8
-MOD52_021D76F8: ; 0x021D76F8
- .byte 0x9B, 0x00, 0x01, 0x00, 0x95, 0x00, 0x01, 0x00, 0x96, 0x00, 0x01, 0x00, 0x97, 0x00, 0x01, 0x00
- .byte 0x9B, 0x00, 0x01, 0x00, 0x97, 0x00, 0x01, 0x00, 0xA4, 0x00, 0x02, 0x00, 0xA5, 0x00, 0x02, 0x00
- .byte 0x95, 0x00, 0x01, 0x00, 0x9B, 0x00, 0x02, 0x00, 0x9E, 0x00, 0x01, 0x00, 0xA7, 0x00, 0x02, 0x00
- .byte 0xA7, 0x00, 0x02, 0x00, 0xAA, 0x00, 0x01, 0x00, 0x95, 0x00, 0x01, 0x00, 0x97, 0x00, 0x01, 0x00
- .byte 0x9B, 0x00, 0x01, 0x00, 0x9B, 0x00, 0x01, 0x00, 0x98, 0x00, 0x01, 0x00, 0x98, 0x00, 0x01, 0x00
- .byte 0xA4, 0x00, 0x01, 0x00, 0xA4, 0x00, 0x01, 0x00, 0x95, 0x00, 0x01, 0x00, 0x9B, 0x00, 0x01, 0x00
- .byte 0x9B, 0x00, 0x01, 0x00, 0xA5, 0x00, 0x01, 0x00, 0xA6, 0x00, 0x02, 0x00, 0xA4, 0x00, 0x02, 0x00
- .byte 0xA5, 0x00, 0x02, 0x00, 0xA8, 0x00, 0x02, 0x00, 0x9A, 0x00, 0x01, 0x00, 0x96, 0x00, 0x01, 0x00
- .byte 0xA4, 0x00, 0x01, 0x00, 0xA4, 0x00, 0x01, 0x00, 0x9C, 0x00, 0x01, 0x00, 0xA6, 0x00, 0x01, 0x00
- .byte 0xA6, 0x00, 0x01, 0x00, 0x9F, 0x00, 0x01, 0x00, 0x99, 0x00, 0x01, 0x00, 0x99, 0x00, 0x01, 0x00
- .byte 0xA4, 0x00, 0x01, 0x00, 0xA8, 0x00, 0x01, 0x00, 0x9E, 0x00, 0x01, 0x00, 0x96, 0x00, 0x01, 0x00
- .byte 0xA0, 0x00, 0x01, 0x00, 0xA2, 0x00, 0x01, 0x00, 0x97, 0x00, 0x01, 0x00, 0x99, 0x00, 0x01, 0x00
- .byte 0xA3, 0x00, 0x01, 0x00, 0xAD, 0x00, 0x01, 0x00, 0x9E, 0x00, 0x01, 0x00, 0x99, 0x00, 0x01, 0x00
- .byte 0xAE, 0x00, 0x01, 0x00, 0x9D, 0x00, 0x01, 0x00, 0x97, 0x00, 0x01, 0x00, 0xA8, 0x00, 0x01, 0x00
- .byte 0xA8, 0x00, 0x01, 0x00, 0xA8, 0x00, 0x01, 0x00, 0x9C, 0x00, 0x01, 0x00, 0x9C, 0x00, 0x01, 0x00
- .byte 0xA6, 0x00, 0x01, 0x00, 0xA6, 0x00, 0x01, 0x00, 0xA2, 0x00, 0x01, 0x00, 0xA3, 0x00, 0x01, 0x00
- .byte 0x98, 0x00, 0x01, 0x00, 0x98, 0x00, 0x01, 0x00, 0x95, 0x00, 0x01, 0x00, 0x9E, 0x00, 0x01, 0x00
- .byte 0x96, 0x00, 0x01, 0x00, 0xA9, 0x00, 0x01, 0x00, 0x97, 0x00, 0x02, 0x00, 0xA5, 0x00, 0x02, 0x00
- .byte 0xA0, 0x00, 0x01, 0x00, 0xA1, 0x00, 0x01, 0x00, 0x98, 0x00, 0x01, 0x00, 0x9C, 0x00, 0x01, 0x00
- .byte 0x9F, 0x00, 0x01, 0x00, 0xA8, 0x00, 0x02, 0x00, 0x9A, 0x00, 0x01, 0x00, 0x97, 0x00, 0x01, 0x00
- .byte 0xA1, 0x00, 0x01, 0x00, 0xAC, 0x00, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x00, 0xA1, 0x00, 0x02, 0x00
- .byte 0xA2, 0x00, 0x02, 0x00, 0xAB, 0x00, 0x01, 0x00, 0x9E, 0x00, 0x02, 0x00, 0xA5, 0x00, 0x03, 0x00
- .byte 0xA6, 0x00, 0x03, 0x00, 0xA7, 0x00, 0x03, 0x00, 0xA9, 0x00, 0x01, 0x00, 0xA9, 0x00, 0x01, 0x00
- .byte 0xAC, 0x00, 0x02, 0x00, 0xAC, 0x00, 0x02, 0x00, 0xAA, 0x00, 0x01, 0x00, 0xAA, 0x00, 0x01, 0x00
- .byte 0xAE, 0x00, 0x01, 0x00, 0xAE, 0x00, 0x01, 0x00, 0xAB, 0x00, 0x01, 0x00, 0xAB, 0x00, 0x01, 0x00
- .byte 0xA9, 0x00, 0x01, 0x00, 0xA9, 0x00, 0x01, 0x00, 0xAC, 0x00, 0x01, 0x00, 0xAC, 0x00, 0x01, 0x00
- .byte 0xAE, 0x00, 0x01, 0x00, 0xAE, 0x00, 0x01, 0x00, 0xAD, 0x00, 0x01, 0x00, 0xAD, 0x00, 0x01, 0x00
- .byte 0xAB, 0x00, 0x01, 0x00, 0xAB, 0x00, 0x01, 0x00, 0x9D, 0x00, 0x01, 0x00, 0x9A, 0x00, 0x01, 0x00
- .byte 0xAB, 0x00, 0x02, 0x00, 0xAD, 0x00, 0x02, 0x00, 0xAA, 0x00, 0x02, 0x00, 0xAA, 0x00, 0x02, 0x00
- .byte 0xAD, 0x00, 0x01, 0x00, 0xAD, 0x00, 0x01, 0x00
-
- .data
- .bss
diff --git a/arm9/modules/52/include/module_52.h b/arm9/modules/52/include/module_52.h
new file mode 100644
index 00000000..4c47a82d
--- /dev/null
+++ b/arm9/modules/52/include/module_52.h
@@ -0,0 +1,42 @@
+#ifndef POKEDIAMOND_MODULE_52_H
+#define POKEDIAMOND_MODULE_52_H
+
+#include "global.h"
+#include "event_data.h"
+#include "main.h"
+#include "math_util.h"
+#include "options.h"
+#include "overlay_manager.h"
+#include "player_data.h"
+#include "sav_system_info.h"
+#include "save_block_2.h"
+#include "unk_02024E64.h"
+#include "unk_020286F8.h"
+
+const u8 MOD52_021D76F8[];
+
+THUMB_FUNC int MOD52_021D74E0();
+THUMB_FUNC int MOD52_021D74F8(struct UnkStruct_02006234 *param0);
+THUMB_FUNC int MOD52_021D750C();
+
+THUMB_FUNC int MOD52_021D7528();
+THUMB_FUNC int MOD52_021D7540(struct UnkStruct_02006234 *param0);
+THUMB_FUNC int MOD52_021D7560();
+
+THUMB_FUNC int MOD52_021D757C();
+THUMB_FUNC int MOD52_021D7594(struct UnkStruct_02006234 *param0);
+THUMB_FUNC int MOD52_021D75E8();
+
+THUMB_FUNC void MOD52_021D7604(u32 heap_id, struct SaveBlock2 *sav2, BOOL set_trainerid);
+THUMB_FUNC void MOD52_021D7688(u32 param0, struct SaveBlock2 *sav2);
+THUMB_FUNC void MOD52_021D769C(u32 param0, struct SaveBlock2 *sav2);
+
+struct MOD52_Struct
+{
+ int (*func1)(void);
+ int (*func2)(struct UnkStruct_02006234 *param0);
+ int (*func3)(void);
+ u32 terminator;
+};
+
+#endif // POKEDIAMOND_MODULE_52_H \ No newline at end of file
diff --git a/arm9/modules/52/src/module_52.c b/arm9/modules/52/src/module_52.c
new file mode 100644
index 00000000..a5b53e6c
--- /dev/null
+++ b/arm9/modules/52/src/module_52.c
@@ -0,0 +1,647 @@
+#include "module_52.h"
+#include "heap.h"
+
+
+extern struct Unk21DBE18 UNK_020FD144;
+extern struct Unk21DBE18 UNK_020F2B7C;
+extern struct Unk21DBE18 UNK_020F2B8C;
+
+extern void FUN_02015E3C(struct IGT *igt);
+extern void FUN_0206007C(struct SaveBlock2 *sav2);
+extern int FUN_02053678(u32 random, u32 gender, u32 param2);
+extern void FUN_020250C4(void *sav_ptr, u32 heap_id, const u8 param2[], u32 param3);
+extern void FUN_020377E0(struct SaveBlock2 *sav2);
+extern void FUN_0205ECD4(struct ScriptState *script_state);
+
+THUMB_FUNC int MOD52_021D74E0()
+{
+ FUN_0201681C(3, 0x4d, 2 << 16);
+ InitializeMainRNG();
+
+ return 1;
+}
+
+THUMB_FUNC int MOD52_021D74F8(struct UnkStruct_02006234 *param0)
+{
+ struct SaveBlock2 *sav2 = (struct SaveBlock2 *)OverlayManager_GetField18(param0)[2]; // weird
+
+ MOD52_021D769C(0x4d, sav2);
+
+ return 1;
+}
+
+THUMB_FUNC int MOD52_021D750C()
+{
+ FUN_020168D0(0x4d);
+ RegisterMainOverlay(0XFFFFFFFF, &UNK_020FD144);
+
+ return 1;
+}
+
+THUMB_FUNC int MOD52_021D7528()
+{
+ FUN_0201681C(3, 0x4d, 2 << 16);
+ InitializeMainRNG();
+
+ return 1;
+}
+
+THUMB_FUNC int MOD52_021D7540(struct UnkStruct_02006234 *param0)
+{
+ struct SaveBlock2 *sav2 = (struct SaveBlock2 *)OverlayManager_GetField18(param0)[2]; // weird
+
+ MOD52_021D7604(0x4d, sav2, 1);
+ struct IGT *igt = Sav2_PlayerData_GetIGTAddr(sav2);
+ FUN_02015E3C(igt);
+
+ return 1;
+}
+
+THUMB_FUNC int MOD52_021D7560()
+{
+ FUN_020168D0(0x4d);
+ RegisterMainOverlay(0xFFFFFFFF, &UNK_020F2B7C);
+
+ return 1;
+}
+
+THUMB_FUNC int MOD52_021D757C()
+{
+ FUN_0201681C(3, 0x4d, 2 << 16);
+ InitializeMainRNG();
+
+ return 1;
+}
+
+THUMB_FUNC int MOD52_021D7594(struct UnkStruct_02006234 *param0)
+{
+ struct SaveBlock2 *sav2 = (struct SaveBlock2 *)OverlayManager_GetField18(param0)[2]; // weird
+
+ struct SavSysInfo *sav2_info = Sav2_SysInfo_get(sav2);
+
+ MOD52_021D7688(0x4d, sav2);
+ Options_SetButtonModeOnMain(sav2, 0);
+
+ if (!Sav2_SysInfo_MacAddressIsMine(sav2_info) || !Sav2_SysInfo_RTCOffsetIsMine(sav2_info))
+ {
+ FUN_020238A4(Sav2_SysInfo_RTC_get(sav2));
+ Sav2_SysInfo_InitFromSystem(sav2_info);
+ }
+
+ FUN_02015E3C(Sav2_PlayerData_GetIGTAddr(sav2));
+
+ return 1;
+}
+
+THUMB_FUNC int MOD52_021D75E8()
+{
+ FUN_020168D0(0x4d);
+ RegisterMainOverlay(0XFFFFFFFF, &UNK_020F2B8C);
+
+ return 1;
+}
+
+THUMB_FUNC void MOD52_021D7604(u32 heap_id, struct SaveBlock2 *sav2, BOOL set_trainerid)
+{
+ Sav2_SysInfo_InitFromSystem(Sav2_SysInfo_get(sav2));
+ Sav2_SysInfo_RTC_init(Sav2_SysInfo_RTC_get(sav2));
+
+ struct UnkSaveStruct_020286F8 *unk_sav2 = FUN_0202881C(sav2);
+
+ FUN_02028788(unk_sav2, 1, MTRandom());
+ FUN_0206007C(sav2);
+
+ struct PlayerData *player_data = Sav2_PlayerData_GetProfileAddr(sav2);
+ u32 trainerid = MTRandom();
+
+ if (set_trainerid)
+ {
+ PlayerProfile_SetTrainerID(player_data, trainerid);
+ }
+
+ u32 gender = PlayerProfile_GetTrainerGender(player_data);
+ int avatar = FUN_02053678(trainerid, gender, 0);
+
+ PlayerProfile_SetAvatar(player_data, (u8)avatar);
+
+ FUN_020250C4(FUN_02024ECC(sav2), heap_id, MOD52_021D76F8, 0x76);
+}
+
+THUMB_FUNC void MOD52_021D7688(u32 unused, struct SaveBlock2 *sav2)
+{
+#pragma unused(unused)
+
+ if (FUN_020226FC(sav2))
+ {
+ return;
+ }
+
+ OS_ResetSystem(0);
+}
+
+THUMB_FUNC void MOD52_021D769C(u32 unused, struct SaveBlock2 *sav2)
+{
+#pragma unused(unused)
+
+ Sav2_InitDynamicRegion(sav2);
+ FUN_020377E0(sav2);
+ struct PlayerData *player_data = Sav2_PlayerData_GetProfileAddr(sav2);
+ PlayerProfile_SetMoney(player_data, 3000);
+ FUN_0205ECD4(SavArray_Flags_get(sav2));
+}
+
+const struct MOD52_Struct MOD52_021D76C8 = {
+ MOD52_021D757C,
+ MOD52_021D7594,
+ MOD52_021D75E8,
+ 0xFFFFFFFF,
+};
+
+const struct MOD52_Struct MOD52_021D76D8 = {
+ MOD52_021D7528,
+ MOD52_021D7540,
+ MOD52_021D7560,
+ 0xFFFFFFFF,
+};
+
+const struct MOD52_Struct MOD52_021D76E8 = {
+ MOD52_021D74E0,
+ MOD52_021D74F8,
+ MOD52_021D750C,
+ 0xFFFFFFFF,
+};
+
+const u8 MOD52_021D76F8[] = {
+ 0x9B,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x95,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x96,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x97,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9B,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x97,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA4,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA5,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0x95,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9B,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0x9E,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA7,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA7,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xAA,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x95,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x97,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9B,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9B,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x98,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x98,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA4,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA4,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x95,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9B,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9B,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA5,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA6,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA4,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA5,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA8,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0x9A,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x96,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA4,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA4,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9C,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA6,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA6,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9F,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x99,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x99,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA4,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA8,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9E,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x96,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA0,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA2,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x97,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x99,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA3,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAD,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9E,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x99,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAE,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9D,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x97,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA8,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA8,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA8,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9C,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9C,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA6,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA6,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA2,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA3,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x98,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x98,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x95,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9E,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x96,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA9,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x97,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA5,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA0,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA1,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x98,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9C,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9F,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA8,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0x9A,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x97,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA1,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAC,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA0,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA1,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA2,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xAB,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9E,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xA5,
+ 0x00,
+ 0x03,
+ 0x00,
+ 0xA6,
+ 0x00,
+ 0x03,
+ 0x00,
+ 0xA7,
+ 0x00,
+ 0x03,
+ 0x00,
+ 0xA9,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA9,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAC,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xAC,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xAA,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAA,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAE,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAE,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAB,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAB,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA9,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xA9,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAC,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAC,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAE,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAE,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAD,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAD,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAB,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAB,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9D,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0x9A,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAB,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xAD,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xAA,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xAA,
+ 0x00,
+ 0x02,
+ 0x00,
+ 0xAD,
+ 0x00,
+ 0x01,
+ 0x00,
+ 0xAD,
+ 0x00,
+ 0x01,
+ 0x00,
+}; \ No newline at end of file
diff --git a/arm9/modules/59/asm/mod59_021D74E0_asm.s b/arm9/modules/59/asm/mod59_021D74E0_asm.s
index cd947e57..447b763f 100644
--- a/arm9/modules/59/asm/mod59_021D74E0_asm.s
+++ b/arm9/modules/59/asm/mod59_021D74E0_asm.s
@@ -181,7 +181,7 @@ MOD59_021D76C0: ; 0x021D76C0
bl FUN_02024EB4
ldr r1, [r4, #0x74]
ldr r1, [r1, #0x18]
- bl FUN_02024EF4
+ bl RivalsNameToU16Array
ldr r0, [r4, #0x70]
bl FUN_02077AC4
ldr r0, [r4, #0x74]
diff --git a/arm9/modules/59/src/mod59_021D74E0_src.c b/arm9/modules/59/src/mod59_021D74E0_src.c
index 9fccfd95..4d7a4a98 100644
--- a/arm9/modules/59/src/mod59_021D74E0_src.c
+++ b/arm9/modules/59/src/mod59_021D74E0_src.c
@@ -2,8 +2,9 @@
#include "player_data.h"
#include "overlay_manager.h"
#include "mod59_021D74E0.h"
+#include "heap.h"
+
-extern void FUN_0201681C(u32 param0, u32 heap_id, u32 param2);
extern u32 FUN_02077A84(u32 heap_id, u32 param1, u32 param2, u32 param3, struct Options *options);
THUMB_FUNC BOOL MOD59_Init(struct UnkStruct_02006234 *param0)
diff --git a/arm9/src/game_init.c b/arm9/src/game_init.c
index 327c66c6..a7508fab 100644
--- a/arm9/src/game_init.c
+++ b/arm9/src/game_init.c
@@ -4,16 +4,15 @@
#include "main.h"
#include "FS_rom.h"
#include "PAD_pad.h"
-#include "heap.h"
#include "MWC_string.h"
#include "tp.h"
#include "unk_0201B4E8.h"
#include "game_init.h"
#include "registers.h"
+#include "heap.h"
#pragma thumb on
-extern void FUN_020166C8(const u32 (*)[2], int, int, int);
extern void FUN_02022450(void);
typedef volatile struct
@@ -142,7 +141,7 @@ void FUN_02015FC8(void)
{
csum++;
}
- FUN_020166C8(UNK_020EDB10, 4, 92, (int)csum);
+ FUN_020166C8((u32 *)UNK_020EDB10, 4, 92, (int)csum);
}
void InitSystemForTheGame(void)
diff --git a/arm9/src/heap.c b/arm9/src/heap.c
new file mode 100644
index 00000000..c27a40c0
--- /dev/null
+++ b/arm9/src/heap.c
@@ -0,0 +1,380 @@
+#include "heap.h"
+
+extern void *tempName_NNS_FndCreateExpHeapEx(void *param0, u32 param1, u32 param2);
+extern void *tempName_NNS_FndAllocFromExpHeapEx(void *param0, u32 param1, s32 param2);
+extern void thunk_FUN_020adc8c();
+extern void FUN_020ADDF0(void *ptr1, void *ptr2);
+extern u32 FUN_02031810(void);
+extern void PrintErrorMessageAndReset(void);
+extern u32 FUN_020ADDC8(void *param0);
+extern void FUN_020AE82C(u32 param0, void *param1, u32 param2);
+extern u32 FUN_020ADDC0(void *param0);
+extern void FUN_020ADE2C(void *ptr1, void *ptr2, u32 param2);
+
+
+struct UnkStruct_020166C8 UNK_021C4D28;
+
+
+THUMB_FUNC void FUN_020166C8(u32 *param0, u32 param1, u32 param2, u32 pre_size)
+{
+ u32 unk_size = param1 + 24;
+
+ if (param2 < unk_size)
+ {
+ param2 = unk_size;
+ }
+ if (pre_size != 0)
+ {
+ while (pre_size % 4 != 0)
+ {
+ pre_size++;
+ }
+
+ OS_AllocFromArenaLo(OS_ARENA_MAIN, pre_size, 4);
+ }
+
+ u32 r7 = param2 * 2;
+
+ void *ptr = OS_AllocFromArenaLo(OS_ARENA_MAIN, (unk_size * 3 + 1) * sizeof(u32) + r7 + param2, 4);
+ UNK_021C4D28.unk00 = ptr;
+ ptr += (unk_size + 1) * 4;
+ UNK_021C4D28.unk04 = ptr;
+ ptr += unk_size * 4;
+ UNK_021C4D28.unk08 = ptr;
+ ptr += unk_size * 4;
+ UNK_021C4D28.unk0c = ptr;
+ ptr += r7;
+ UNK_021C4D28.unk10 = ptr;
+ UNK_021C4D28.unk14 = (u16)param2;
+ UNK_021C4D28.unk16 = (u16)param1;
+
+ r7 = 0;
+ UNK_021C4D28.unk1a = (u16)unk_size;
+ UNK_021C4D28.unk18 = (u16)unk_size;
+
+ while (r7 < param1)
+ {
+ void *ptr;
+ if (param0[1] == 0 || param0[1] != 2)
+ {
+ ptr = OS_AllocFromArenaLo(OS_ARENA_MAIN, param0[0], 4);
+ }
+ else
+ {
+ ptr = OS_AllocFromArenaHi(OS_ARENA_MAINEX, param0[0], 4);
+ }
+
+ if (ptr != 0)
+ {
+
+ UNK_021C4D28.unk00[r7] = tempName_NNS_FndCreateExpHeapEx(ptr, param0[0], 0);
+ UNK_021C4D28.unk10[r7] = (u8)r7;
+ }
+ else
+ {
+ ErrorHandling();
+ }
+
+ param0 += 2;
+ r7++;
+ }
+
+ while (param1 < unk_size + 1)
+ {
+ UNK_021C4D28.unk00[param1] = 0;
+ UNK_021C4D28.unk10[param1] = (u8)UNK_021C4D28.unk1a;
+
+ param1++;
+ }
+
+ while (param1 < param2)
+ {
+ UNK_021C4D28.unk10[param1] = (u8)UNK_021C4D28.unk1a;
+
+ param1++;
+ }
+
+ for (param1 = 0; param1 < param2; param1++)
+ {
+ UNK_021C4D28.unk0c[param1] = 0;
+ }
+}
+
+THUMB_FUNC s32 FUN_020167F4()
+{
+ s32 i = UNK_021C4D28.unk16;
+ s32 j = UNK_021C4D28.unk18;
+
+ if (i < j)
+ {
+ void **ptr = UNK_021C4D28.unk00 + i;
+ do
+ {
+ if (*ptr == 0)
+ {
+ return i;
+ }
+ i++;
+ ptr++;
+ } while (i < j);
+ }
+
+ return -1;
+}
+
+THUMB_FUNC u32 FUN_0201681C(u32 param0, u32 param1, u32 param2)
+{
+ return FUN_02016834(param0, param1, param2, 4);
+}
+
+THUMB_FUNC u32 FUN_02016828(u32 param0, u32 param1, u32 param2)
+{
+ return FUN_02016834(param0, param1, param2, -4);
+}
+
+THUMB_FUNC u32 FUN_02016834(u32 param0, u32 param1, u32 param2, s32 param3)
+{
+ GF_ASSERT(OS_GetProcMode() != OS_PROCMODE_IRQ);
+
+ u8 *ptr = UNK_021C4D28.unk10;
+ if (UNK_021C4D28.unk1a == ptr[param1])
+ {
+ void *ptr2 = UNK_021C4D28.unk00[ptr[param0]];
+ if (ptr2 != 0)
+ {
+ void *ptr3 = tempName_NNS_FndAllocFromExpHeapEx(ptr2, param2, param3);
+ if (ptr3 != 0)
+ {
+ param3 = FUN_020167F4();
+ if (param3 >= 0)
+ {
+ UNK_021C4D28.unk00[param3] = tempName_NNS_FndCreateExpHeapEx(ptr3, param2, 0);
+
+
+ if (UNK_021C4D28.unk00[param3] != 0)
+ {
+ UNK_021C4D28.unk04[param3] = ptr2;
+ UNK_021C4D28.unk08[param3] = ptr3;
+ UNK_021C4D28.unk10[param1] = (u8)param3;
+
+ return 1;
+ }
+ else
+ {
+ ErrorHandling();
+ }
+ }
+ else
+ {
+ ErrorHandling();
+ }
+ }
+ else
+ {
+ ErrorHandling();
+ }
+ }
+ else
+ {
+ ErrorHandling();
+ }
+ }
+ else
+ {
+ ErrorHandling();
+ }
+ return 0;
+}
+
+THUMB_FUNC void FUN_020168D0(u32 heap_id)
+{
+ GF_ASSERT (OS_GetProcMode() != OS_PROCMODE_IRQ);
+
+ if (UNK_021C4D28.unk00[UNK_021C4D28.unk10[heap_id]] != 0)
+ {
+ thunk_FUN_020adc8c();
+
+ u8 index = UNK_021C4D28.unk10[heap_id];
+ void *ptr1 = UNK_021C4D28.unk04[index];
+ void *ptr2 = UNK_021C4D28.unk08[index];
+ if (ptr1 != 0 && ptr2 != 0)
+ {
+ FUN_020ADDF0(ptr1, ptr2);
+ }
+ else
+ {
+ ErrorHandling();
+ }
+
+ UNK_021C4D28.unk00[UNK_021C4D28.unk10[heap_id]] = 0;
+ UNK_021C4D28.unk04[UNK_021C4D28.unk10[heap_id]] = 0;
+ UNK_021C4D28.unk08[UNK_021C4D28.unk10[heap_id]] = 0;
+
+ UNK_021C4D28.unk10[heap_id] = (u8)UNK_021C4D28.unk1a;
+ }
+}
+
+THUMB_FUNC u32 *FUN_02016944(void *param0, u32 param1, s32 param2, u32 param3)
+{
+ GF_ASSERT(param0);
+
+ OSIntrMode intr_mode = OS_DisableInterrupts();
+ param1 += 16;
+ u32 *ptr = (u32 *)tempName_NNS_FndAllocFromExpHeapEx(param0, param1, param2);
+
+ OS_RestoreInterrupts(intr_mode);
+ if (ptr != 0)
+ {
+ ptr[3] = (ptr[3] & ~0xff) | (param3 & 0xff);
+
+ ptr += 4;
+ }
+
+ return ptr;
+}
+
+THUMB_FUNC void FUN_02016988()
+{
+ if (FUN_02031810() != 0)
+ {
+ PrintErrorMessageAndReset();
+ }
+}
+
+void *AllocFromHeap(u32 heap_id, u32 size)
+{
+ void *ptr = 0;
+ if (heap_id < UNK_021C4D28.unk14)
+ {
+ u8 index = UNK_021C4D28.unk10[heap_id];
+ ptr = FUN_02016944(UNK_021C4D28.unk00[index], size, 4, heap_id);
+ }
+ if (ptr != 0)
+ {
+ UNK_021C4D28.unk0c[heap_id]++;
+ }
+ else
+ {
+ FUN_02016988();
+ }
+
+ return ptr;
+}
+
+void *AllocFromHeapAtEnd(u32 heap_id, u32 size)
+{
+ void *ptr = 0;
+ if (heap_id < UNK_021C4D28.unk14)
+ {
+ u8 index = UNK_021C4D28.unk10[heap_id];
+ ptr = FUN_02016944(UNK_021C4D28.unk00[index], size, -4, heap_id);
+ }
+
+ if (ptr != 0)
+ {
+ UNK_021C4D28.unk0c[heap_id]++;
+ }
+ else
+ {
+ FUN_02016988();
+ }
+
+ return ptr;
+}
+
+void FreeToHeap(void *ptr)
+{
+ u8 heap_id = (u8)((u32 *)ptr)[-1];
+
+ if ((u16)heap_id < UNK_021C4D28.unk14)
+ {
+ u8 index = UNK_021C4D28.unk10[heap_id];
+ void *ptr2 = UNK_021C4D28.unk00[index];
+ GF_ASSERT(ptr2);
+
+ if (UNK_021C4D28.unk0c[heap_id] == 0)
+ {
+ FUN_02016B90(heap_id);
+ }
+ GF_ASSERT(UNK_021C4D28.unk0c[heap_id]);
+
+ UNK_021C4D28.unk0c[heap_id]--;
+ OSIntrMode intr_mode = OS_DisableInterrupts();
+ FUN_020ADDF0(ptr2, ptr - 16);
+ OS_RestoreInterrupts(intr_mode);
+ return;
+ }
+
+ ErrorHandling();
+}
+
+void FUN_02016A8C(u32 param0, void *param1)
+{
+ GF_ASSERT (OS_GetProcMode() != OS_PROCMODE_IRQ);
+
+ if (param0 < UNK_021C4D28.unk14)
+ {
+ u8 index = UNK_021C4D28.unk10[param0];
+ void *ptr = UNK_021C4D28.unk00[index];
+ GF_ASSERT (ptr );
+
+ u8 heap_id = (u8)((u32 *)param1)[-1];
+ GF_ASSERT (heap_id == param0);
+
+ FUN_020ADDF0(ptr, param1 - 16);
+ GF_ASSERT (UNK_021C4D28.unk0c[param0]);
+
+ UNK_021C4D28.unk0c[param0]--;
+ return;
+ }
+
+ ErrorHandling();
+}
+
+THUMB_FUNC u32 FUN_02016AF8(u32 param0)
+{
+ if (param0 < UNK_021C4D28.unk14)
+ {
+ u8 index = UNK_021C4D28.unk10[param0];
+ return FUN_020ADDC8(UNK_021C4D28.unk00[index]);
+ }
+
+ ErrorHandling();
+ return 0;
+}
+
+THUMB_FUNC void FUN_02016B20(u32 param0, u32 param1, u32 param2)
+{
+ if (param1 < UNK_021C4D28.unk14)
+ {
+
+ u8 index = UNK_021C4D28.unk10[param1];
+ FUN_020AE82C(param0, UNK_021C4D28.unk00[index], param2);
+ return;
+ }
+
+ ErrorHandling();
+}
+
+THUMB_FUNC void FUN_02016B44(void *ptr, u32 param1)
+{
+ GF_ASSERT (OS_GetProcMode() != OS_PROCMODE_IRQ);
+
+ param1 += 16;
+ if (FUN_020ADDC0(ptr - 16) >= param1)
+ {
+ u8 heap_id = (u8)((u32 *)ptr)[-1];
+
+ u8 index = UNK_021C4D28.unk10[heap_id];
+
+ FUN_020ADE2C(UNK_021C4D28.unk00[index], ptr - 16, param1);
+ return;
+ }
+ ErrorHandling();
+}
+
+THUMB_FUNC u32 FUN_02016B90(u32 param0)
+{
+#pragma unused(param0)
+ return 1;
+}
diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c
new file mode 100644
index 00000000..9e6a337a
--- /dev/null
+++ b/arm9/src/scrcmd.c
@@ -0,0 +1,556 @@
+#include "scrcmd.h"
+#include "unk_0204639C.h"
+
+extern u16 *GetVarPointer(struct UnkSavStruct80* arg, u16);
+extern u16 VarGet(struct UnkSavStruct80* arg, u16 wk);
+extern void *FUN_02039438(struct UnkSavStruct80* arg, u32 id);
+extern void *CreateScriptContext(struct UnkSavStruct80* arg, u16 id);
+extern u8 FUN_02058448(u32 param0);
+extern void FlagSet(struct UnkSavStruct80 *arg, u16 flag);
+extern void FlagClear(struct UnkSavStruct80 *arg, u16 flag);
+extern u8 FlagCheck(struct UnkSavStruct80 *arg, u16 flag);
+extern void TrainerFlagSet(struct UnkSavStruct80 *arg, u16 flag);
+extern void TrainerFlagClear(struct UnkSavStruct80 *arg, u16 flag);
+extern u8 TrainerFlagCheck(struct UnkSavStruct80 *arg, u16 flag);
+extern void MOD05_ShowMessageInField(struct ScriptContext *ctx, struct MsgData *msgData, u16 id);
+extern void MOD05_021E2BD0(struct ScriptContext *ctx, struct MsgData *msgData, u16 msgId, u32 param4, void *param5);
+extern void MOD05_021E2C58(struct ScriptContext *ctx, u16 typ, u16 id, u16 word1, s16 word2, u8 param5);
+extern struct ScrStrBufs *MOD06_02244210(struct SaveBlock2 *sav, u16 poke, u16 sex, u8 flag, u8 *unk);
+extern void MOD05_021E2CBC(struct ScriptContext *ctx, struct ScrStrBufs *str, u8 param2, u32 param3);
+extern void MOD05_021E2BB8(void *param0, struct ScriptContext *ctx);
+extern BOOL FUN_020546C8(u8 param0);
+
+static BOOL RunPauseTimer(struct ScriptContext* ctx);
+static u32 Compare(u16 a, u16 b);
+static BOOL FUN_02039CC8(struct ScriptContext* ctx);
+/*static*/ BOOL FUN_0203A2F0(struct ScriptContext* ctx);
+
+extern u8 sScriptConditionTable[6][3];
+
+THUMB_FUNC BOOL ScrCmd_Nop(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Dummy(struct ScriptContext* ctx)
+{
+#pragma unused(ctx)
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_End(struct ScriptContext* ctx)
+{
+ StopScript(ctx);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Wait(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* arg = ctx->unk80;
+ u16 num = ScriptReadHalfword(ctx);
+ u16 wk = ScriptReadHalfword(ctx);
+ u16* VarPointer = GetVarPointer(arg, wk);
+ *VarPointer = num;
+ ctx->data[0] = wk;
+ SetupNativeScript(ctx, RunPauseTimer);
+ return TRUE;
+}
+
+THUMB_FUNC static BOOL RunPauseTimer(struct ScriptContext* ctx)
+{
+ u16* VarPointer = GetVarPointer(ctx->unk80, (u16)ctx->data[0]);
+ *VarPointer = (u16)(*VarPointer - 1);
+ return !(*VarPointer);
+}
+
+THUMB_FUNC BOOL ScrCmd_DebugWatch(struct ScriptContext* ctx)
+{
+ u16 wk = ScriptReadHalfword(ctx);
+ VarGet(ctx->unk80, wk);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_LoadByte(struct ScriptContext* ctx)
+{
+ u8 index = ScriptReadByte(ctx);
+ ctx->data[index] = ScriptReadByte(ctx);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_LoadWord(struct ScriptContext* ctx)
+{
+ u8 index = ScriptReadByte(ctx);
+ ctx->data[index] = ScriptReadWord(ctx);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_LoadByteFromAddr(struct ScriptContext* ctx)
+{
+ u8 index = ScriptReadByte(ctx);
+ ctx->data[index] = *(u8 *)ScriptReadWord(ctx);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_WriteByteToAddr(struct ScriptContext* ctx)
+{
+ u8* ptr = (u8*)ScriptReadWord(ctx);
+ *ptr = ScriptReadByte(ctx);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SetPtrByte(struct ScriptContext* ctx)
+{
+ u8* ptr = (u8*)ScriptReadWord(ctx);
+ *ptr = (u8)ctx->data[ScriptReadByte(ctx)];
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CopyLocal(struct ScriptContext* ctx)
+{
+ u8 index_store = ScriptReadByte(ctx);
+ u8 index_load = ScriptReadByte(ctx);
+ ctx->data[index_store] = ctx->data[index_load];
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CopyByte(struct ScriptContext* ctx)
+{
+ u8 *target = (u8 *)ScriptReadWord(ctx);
+ u8 *source = (u8 *)ScriptReadWord(ctx);
+ *target = *source;
+ return FALSE;
+}
+
+THUMB_FUNC static u32 Compare(u16 a, u16 b)
+{
+ if (a < b)
+ {
+ return 0;
+ }
+ else if (a == b)
+ {
+ return 1;
+ }
+ else
+ {
+ return 2;
+ }
+}
+
+THUMB_FUNC BOOL ScrCmd_CompareLocalToLocal(struct ScriptContext* ctx)
+{
+ u8 a = (u8)ctx->data[ScriptReadByte(ctx)];
+ u8 b = (u8)ctx->data[ScriptReadByte(ctx)];
+ ctx->comparisonResult = (u8)Compare(a, b);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CompareLocalToValue(struct ScriptContext* ctx)
+{
+ u8 a = (u8)ctx->data[ScriptReadByte(ctx)];
+ u8 b = ScriptReadByte(ctx);
+ ctx->comparisonResult = (u8)Compare(a, b);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CompareLocalToAddr(struct ScriptContext* ctx)
+{
+ u8 a = (u8)ctx->data[ScriptReadByte(ctx)];
+ u8 b = *(u8*)ScriptReadWord(ctx);
+ ctx->comparisonResult = (u8)Compare(a, b);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CompareAddrToLocal(struct ScriptContext* ctx)
+{
+ u8 a = *(u8*)ScriptReadWord(ctx);
+ u8 b = (u8)ctx->data[ScriptReadByte(ctx)];
+ ctx->comparisonResult = (u8)Compare(a, b);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CompareAddrToValue(struct ScriptContext* ctx)
+{
+ u8 a = *(u8*)ScriptReadWord(ctx);
+ u8 b = (u8)ScriptReadByte(ctx);
+ ctx->comparisonResult = (u8)Compare(a, b);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CompareAddrToAddr(struct ScriptContext* ctx)
+{
+ u8 a = *(u8*)ScriptReadWord(ctx);
+ u8 b = *(u8*)ScriptReadWord(ctx);
+ ctx->comparisonResult = (u8)Compare(a, b);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CompareVarToValue(struct ScriptContext* ctx)
+{
+ u16 a = *GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 b = ScriptReadHalfword(ctx);
+ ctx->comparisonResult = (u8)Compare(a, b);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CompareVarToVar(struct ScriptContext* ctx)
+{
+ u16 *a = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 *b = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ ctx->comparisonResult = (u8)Compare(*a, *b);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_RunScript(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* unk80 = ctx->unk80;
+ u8 *unk1 = (u8 *)FUN_02039438(unk80, 0x7);
+ u32 **unk2 = (u32 **)FUN_02039438(unk80, 0xe);
+ u16 id = ScriptReadHalfword(ctx);
+
+ *unk2 = CreateScriptContext(unk80, id);
+ *unk1 = (u8)(*unk1 + 1);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_RunScriptWait(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80* unk80 = ctx->unk80;
+ u8 *unk1 = (u8 *)FUN_02039438(unk80, 0x5);
+ u8 *unk2 = (u8 *)FUN_02039438(unk80, 0x7);
+ u32 **unk3 = (u32 **)FUN_02039438(unk80, 0xe);
+
+ u16 id = ScriptReadHalfword(ctx);
+ *unk1 = 1;
+ *unk3 = CreateScriptContext(unk80, id);
+ *unk2 = (u8)(*unk2 + 1);
+
+ SetupNativeScript(ctx, FUN_02039CC8);
+ return TRUE;
+}
+
+THUMB_FUNC static BOOL FUN_02039CC8(struct ScriptContext* ctx)
+{
+ u8* unk = FUN_02039438(ctx->unk80, 0x5);
+
+ if (*unk == 0)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_RestartCurrentScript(struct ScriptContext* ctx)
+{
+ u8* unk = (u8 *)FUN_02039438(ctx->unk80, 0x5);
+
+ *unk = 0;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GoTo(struct ScriptContext* ctx)
+{
+ s32 offset = (s32)ScriptReadWord(ctx);
+ ScriptJump(ctx, ctx->scriptPtr + offset);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_ObjectGoTo(struct ScriptContext* ctx)
+{
+ u32* unk = FUN_02039438(ctx->unk80, 0xa);
+ u8 id = ScriptReadByte(ctx);
+ s32 offset = (s32)ScriptReadWord(ctx);
+ if (FUN_02058448(*unk) == id)
+ {
+ ScriptJump(ctx, ctx->scriptPtr + offset);
+ }
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_BgGoTo(struct ScriptContext* ctx)
+{
+ u32 bgId = FUN_02046534(ctx->unk74);
+ u8 id = ScriptReadByte(ctx);
+ s32 offset = (s32)ScriptReadWord(ctx);
+
+ if (bgId == id)
+ {
+ ScriptJump(ctx, ctx->scriptPtr + offset);
+ }
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_DirectionGoTo(struct ScriptContext* ctx)
+{
+ u32 *playerDirection = FUN_02039438(ctx->unk80, 0x9);
+ u8 dir = ScriptReadByte(ctx);
+ s32 offset = (s32)ScriptReadWord(ctx);
+
+ if (*playerDirection == dir)
+ {
+ ScriptJump(ctx, ctx->scriptPtr + offset);
+ }
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Call(struct ScriptContext* ctx)
+{
+ s32 offset = (s32)ScriptReadWord(ctx);
+ ScriptCall(ctx, ctx->scriptPtr + offset);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Return(struct ScriptContext* ctx)
+{
+ ScriptReturn(ctx);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_GoToIf(struct ScriptContext* ctx)
+{
+ u8 compareType = ScriptReadByte(ctx);
+ s32 offset = (s32)ScriptReadWord(ctx);
+
+ if (sScriptConditionTable[compareType][ctx->comparisonResult] == TRUE)
+ {
+ ScriptJump(ctx, ctx->scriptPtr + offset);
+ }
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CallIf(struct ScriptContext* ctx)
+{
+ u8 compareType = ScriptReadByte(ctx);
+ s32 offset = (s32)ScriptReadWord(ctx);
+
+ if (sScriptConditionTable[compareType][ctx->comparisonResult] == TRUE)
+ {
+ ScriptCall(ctx, ctx->scriptPtr + offset);
+ }
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SetFlag(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80 *unk80 = ctx->unk80;
+ u16 flag = ScriptReadHalfword(ctx);
+ FlagSet(unk80, flag);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_ClearFlag(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80 *unk80 = ctx->unk80;
+ u16 flag = ScriptReadHalfword(ctx);
+ FlagClear(unk80, flag);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckFlag(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80 *unk80 = ctx->unk80;
+ u16 flag = ScriptReadHalfword(ctx);
+ ctx->comparisonResult = FlagCheck(unk80, flag);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckFlagVar(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80 *unk80 = ctx->unk80;
+ u16 *wk1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 *wk2 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ *wk2 = FlagCheck(unk80, *wk1);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SetFlagVar(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80 *unk80 = ctx->unk80;
+ u16 *wk = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ FlagSet(unk80, *wk);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SetTrainerFlag(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80 *unk80 = ctx->unk80;
+ u16 flag = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ TrainerFlagSet(unk80, flag);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_ClearTrainerFlag(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80 *unk80 = ctx->unk80;
+ u16 flag = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ TrainerFlagClear(unk80, flag);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CheckTrainerFlag(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80 *unk80 = ctx->unk80;
+ u16 flag = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ ctx->comparisonResult = TrainerFlagCheck(unk80, flag);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_AddVar(struct ScriptContext* ctx)
+{
+ u16 *wk1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 wk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ *wk1 = (u16)(*wk1 + wk2);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SubVar(struct ScriptContext* ctx)
+{
+ u16 *wk1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 wk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ *wk1 = (u16)(*wk1 - wk2);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SetVar(struct ScriptContext* ctx)
+{
+ u16 *wk = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ *wk = ScriptReadHalfword(ctx);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_CopyVar(struct ScriptContext* ctx)
+{
+ u16 *wk1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 *wk2 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ *wk1 = *wk2;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_SetOrCopyVar(struct ScriptContext* ctx)
+{
+ u16 *wk1 = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 wk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ *wk1 = wk2;
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Message(struct ScriptContext* ctx)
+{
+ u8 id = ScriptReadByte(ctx);
+ MOD05_ShowMessageInField(ctx, ctx->msgData, id);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_MessageFrom(struct ScriptContext* ctx)
+{
+ u16 arc = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 msg = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct MsgData *msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, arc, 32);
+ MOD05_ShowMessageInField(ctx, msgData, msg);
+ DestroyMsgData(msgData);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_MessageFrom2(struct ScriptContext* ctx)
+{
+ u16 arc = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 msg = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ struct MsgData *msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, arc, 32);
+ MOD05_021E2BD0(ctx, msgData, msg, 1, NULL);
+ DestroyMsgData(msgData);
+ SetupNativeScript(ctx, FUN_0203A2F0);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk01FC(struct ScriptContext* ctx)
+{
+ u16 typ = ScriptReadHalfword(ctx);
+ u16 id = ScriptReadHalfword(ctx);
+ u16 word1 = ScriptReadHalfword(ctx);
+ s16 word2 = (s16)ScriptReadHalfword(ctx);
+
+ MOD05_021E2C58(ctx, typ, id, word1, word2, 0xff);
+ return FALSE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk01FD(struct ScriptContext* ctx)
+{
+ u16 typ = ScriptReadHalfword(ctx);
+ u16 id = ScriptReadHalfword(ctx);
+ u16 word1 = ScriptReadHalfword(ctx);
+ s16 word2 = (s16)ScriptReadHalfword(ctx);
+
+ MOD05_021E2C58(ctx, typ, id, word1, word2, 1);
+ SetupNativeScript(ctx, FUN_0203A2F0);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk01FE(struct ScriptContext* ctx)
+{
+ u8 id = ScriptReadByte(ctx);
+
+ if (ctx->unk80->unkA8 == NULL)
+ {
+ return FALSE;
+ }
+
+ u16 *unkArr = ctx->unk80->unkA8->unk90[id].unk0;
+ if (unkArr[0] == 0xFFFF)
+ {
+ struct MsgData *msgdata = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 0x22b, 32);
+ MOD05_021E2BD0(ctx, msgdata, unkArr[1], 1, NULL);
+ DestroyMsgData(msgdata);
+ }
+ else
+ {
+ MOD05_021E2C58(ctx, unkArr[0], unkArr[1], unkArr[2], (s16)unkArr[3], 1);
+ }
+ SetupNativeScript(ctx, FUN_0203A2F0);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk01FF(struct ScriptContext* ctx)
+{
+ struct UnkSavStruct80 *unk80 = ctx->unk80;
+ u8 msg = ScriptReadByte(ctx);
+ u16 poke = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
+ u16 sex = ScriptReadHalfword(ctx);
+ u8 flag = ScriptReadByte(ctx);
+ u8 unk = 0;
+
+ struct ScrStrBufs *str = MOD06_02244210(unk80->saveBlock2, poke, sex, flag, &unk);
+ MOD05_021E2CBC(ctx, str, (u8)(msg + unk), 1);
+ ScrStrBufs_delete(str);
+
+ SetupNativeScript(ctx, FUN_0203A2F0);
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk026D(struct ScriptContext* ctx) //message unown font?
+{
+ struct UnkStruct_0203A288 myLocalStruct;
+ u16 msg = ScriptReadHalfword(ctx);
+
+ MOD05_021E2BB8(&myLocalStruct, ctx);
+ myLocalStruct.unk2 = 3;
+
+ MOD05_021E2BD0(ctx, ctx->msgData, msg, 0, &myLocalStruct);
+ SetupNativeScript(ctx, FUN_0203A2F0);
+
+ return TRUE;
+}
+
+THUMB_FUNC BOOL ScrCmd_Unk002C(struct ScriptContext* ctx)
+{
+ u8 msg = ScriptReadByte(ctx);
+ MOD05_021E2BD0(ctx, ctx->msgData, msg, 1, NULL);
+ SetupNativeScript(ctx, FUN_0203A2F0);
+ return TRUE;
+}
+
+THUMB_FUNC /*static*/ BOOL FUN_0203A2F0(struct ScriptContext* ctx)
+{
+ u8 *unk = (u8 *)FUN_02039438(ctx->unk80, 3);
+ return FUN_020546C8(*unk);
+}
diff --git a/arm9/src/scrcmd_18_c.c b/arm9/src/scrcmd_18_c.c
index b8bbbcdd..633ad71c 100644
--- a/arm9/src/scrcmd_18_c.c
+++ b/arm9/src/scrcmd_18_c.c
@@ -6,19 +6,19 @@
#include "map_header.h"
#include "scrcmd.h"
-extern u16 VarGet(struct UnkStruct_0204639C* arg, u16 wk);
-extern u16 *GetVarPointer(struct UnkStruct_0204639C* arg, u16);
+extern u16 VarGet(struct UnkSavStruct80* arg, u16 wk);
+extern u16 *GetVarPointer(struct UnkSavStruct80* arg, u16);
extern BOOL GiveMon(u32 heap_id, struct SaveBlock2 * sav2, u16 species, u8 level, u16 item, u32 mapSec, u8 encounterType);
-THUMB_FUNC BOOL ScrCmd_givemon(struct ScriptContext* ctx)
+THUMB_FUNC BOOL ScrCmd_GiveMon(struct ScriptContext* ctx)
{
- u32 mapSec = FUN_02034824(*(ctx->unk80->unk1C));
- struct UnkStruct_0204639C *savePtr = ctx->unk80;
+ u32 mapSec = FUN_02034824(*(ctx->unk80->mapId));
+ struct UnkSavStruct80 *savePtr = ctx->unk80;
u16 species = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 level = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 item = VarGet(ctx->unk80, ScriptReadHalfword(ctx));
u16 * varPtr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx));
- struct PlayerParty * party = SavArray_PlayerParty_get((struct SaveBlock2 *) savePtr->unkC);
- *varPtr = (u16)GiveMon(11, (struct SaveBlock2 *) savePtr->unkC, species, (u8)level, item, mapSec, 12);
+ struct PlayerParty * party = SavArray_PlayerParty_get(savePtr->saveBlock2);
+ *varPtr = (u16)GiveMon(11, savePtr->saveBlock2, species, (u8)level, item, mapSec, 12);
return FALSE;
}
diff --git a/arm9/src/script.c b/arm9/src/script.c
index a5a5a6e4..d067ac79 100644
--- a/arm9/src/script.c
+++ b/arm9/src/script.c
@@ -27,7 +27,7 @@ THUMB_FUNC u8 SetupBytecodeScript(struct ScriptContext *ctx, const u8 *ptr)
return 1;
}
-THUMB_FUNC void SetupNativeScript(struct ScriptContext *ctx, u8 (*ptr)(struct ScriptContext *))
+THUMB_FUNC void SetupNativeScript(struct ScriptContext *ctx, BOOL (*ptr)(struct ScriptContext *))
{
ctx->mode = 2;
ctx->nativePtr = ptr;
diff --git a/arm9/src/script_buffers.c b/arm9/src/script_buffers.c
index 293c0bac..e9a55051 100644
--- a/arm9/src/script_buffers.c
+++ b/arm9/src/script_buffers.c
@@ -130,7 +130,7 @@ void BufferPlayersName(struct ScrStrBufs * mgr, u32 idx, struct PlayerData * dat
void BufferRivalsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav2)
{
- u16 * name = FUN_02024EE8(FUN_02024EC0(sav2));
+ u16 * name = GetRivalNamePtr(FUN_02024EC0(sav2));
CopyU16ArrayToString(mgr->tmpbuf, name);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
}
diff --git a/arm9/src/trainer_data.c b/arm9/src/trainer_data.c
index a797956c..f161b302 100644
--- a/arm9/src/trainer_data.c
+++ b/arm9/src/trainer_data.c
@@ -22,7 +22,7 @@ void EnemyTrainerSet_Init(struct BattleSetupStruct * enemies, struct SaveBlock2
// FIXME: String formatting in files/msgdata/msg/narc_0559.txt is abnormal.
msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 559, heap_id);
- rivalName = FUN_02024EE8(FUN_02024EC0(sav2));
+ rivalName = GetRivalNamePtr(FUN_02024EC0(sav2));
for (i = 0; i < 4; i++)
{
if (enemies->trainer_idxs[i] != 0)
diff --git a/arm9/src/unk_02015E30.c b/arm9/src/unk_02015E30.c
new file mode 100644
index 00000000..d52fb236
--- /dev/null
+++ b/arm9/src/unk_02015E30.c
@@ -0,0 +1,38 @@
+
+#include "unk_02015E30.h"
+
+extern u64 FUN_02020BF4();
+extern u64 FUN_02020C14(u64 param0);
+
+struct UnkStruct_02015E30 UNK_021C4898;
+
+THUMB_FUNC void FUN_02015E30()
+{
+ UNK_021C4898.unk00 = 0;
+}
+
+THUMB_FUNC void FUN_02015E3C(struct IGT *igt)
+{
+ struct UnkStruct_02015E30 *unk1 = &UNK_021C4898;
+ UNK_021C4898.unk00 = 1;
+ UNK_021C4898.unk10 = 0;
+ UNK_021C4898.unk14 = 0;
+ UNK_021C4898.unk08 = 0;
+ UNK_021C4898.unk04 = igt;
+
+ UNK_021C4898.unk18 = FUN_02020BF4();
+}
+
+THUMB_FUNC void FUN_02015E60()
+{
+ if (UNK_021C4898.unk00 != 0)
+ {
+ u64 res = FUN_02020C14(FUN_02020BF4() - UNK_021C4898.unk18);
+
+ if (UNK_021C4898.unk08 < res)
+ {
+ AddIGTSeconds(UNK_021C4898.unk04, (u32)(res - UNK_021C4898.unk08));
+ UNK_021C4898.unk08 = res;
+ }
+ }
+}
diff --git a/arm9/src/unk_02024E64.c b/arm9/src/unk_02024E64.c
index fc596418..d8682531 100644
--- a/arm9/src/unk_02024E64.c
+++ b/arm9/src/unk_02024E64.c
@@ -5,22 +5,22 @@ extern void FUN_02025484(void *param0);
THUMB_FUNC u32 FUN_02024E64()
{
- return 0x74C;
+ return sizeof(struct UnkStruct_02024E64);
}
-THUMB_FUNC void FUN_02024E6C(void *param0)
+THUMB_FUNC void FUN_02024E6C(struct UnkStruct_02024E64 *param0)
{
- MIi_CpuClearFast(0, param0, 0x74C);
+ MIi_CpuClearFast(0, param0, sizeof(struct UnkStruct_02024E64));
- FUN_020250A4(param0);
+ FUN_020250A4(param0->unk0);
- FUN_02025484(param0 + (7 << 8));
+ FUN_02025484(param0->unk700);
- MIi_CpuClear16(0xFFFF, param0 + 0x724, 8);
- MIi_CpuClear16(0xFFFF, param0 + 0x734, 0xb);
+ MIi_CpuClear16(0xFFFF, param0->rival_name_buf, sizeof(param0->rival_name_buf) / sizeof(u16));
+ MIi_CpuClear16(0xFFFF, param0->unk734, sizeof(param0->unk734) / sizeof(u16));
}
-THUMB_FUNC void *FUN_02024EB4(struct SaveBlock2 *sav2)
+THUMB_FUNC struct UnkStruct_02024E64 *FUN_02024EB4(struct SaveBlock2 *sav2)
{
return SavArray_get(sav2, 0xa);
}
@@ -30,33 +30,33 @@ THUMB_FUNC void *FUN_02024EC0(struct SaveBlock2 *sav2)
return FUN_02022634(sav2, 0xa);
}
-THUMB_FUNC void *FUN_02024ECC(struct SaveBlock2 *sav2)
+THUMB_FUNC struct UnkStruct_02024E64 *FUN_02024ECC(struct SaveBlock2 *sav2)
{
return SavArray_get(sav2, 0xa);
}
THUMB_FUNC void *FUN_02024ED8(struct SaveBlock2 *sav2)
{
- void *res = SavArray_get(sav2, 0xa);
- return res + (7 << 8);
+ struct UnkStruct_02024E64 *res = SavArray_get(sav2, 0xa);
+ return res->unk700;
}
-THUMB_FUNC u16 *FUN_02024EE8(void *buf)
+THUMB_FUNC u16 *GetRivalNamePtr(struct UnkStruct_02024E64 *unk)
{
- return buf + 0x724;
+ return unk->rival_name_buf;
}
-THUMB_FUNC void FUN_02024EF4(u16 *buf, struct String *str)
+THUMB_FUNC void RivalsNameToU16Array(struct UnkStruct_02024E64 *unk, struct String *str)
{
- CopyStringToU16Array(str, buf + 0x392, 8);
+ CopyStringToU16Array(str, unk->rival_name_buf, sizeof(unk->rival_name_buf) / sizeof(u16));
}
-THUMB_FUNC u16 *FUN_02024F0C(void *buf)
+THUMB_FUNC u16 *FUN_02024F0C(struct UnkStruct_02024E64 *unk)
{
- return buf + 0x734;
+ return unk->unk734;
}
-THUMB_FUNC void FUN_02024F18(u16 *buf, struct String *str)
+THUMB_FUNC void FUN_02024F18(struct UnkStruct_02024E64 *unk, struct String *str)
{
- CopyStringToU16Array(str, buf + 0x39A, 0xb);
+ CopyStringToU16Array(str, unk->unk734, sizeof(unk->unk734) / sizeof(u16));
}
diff --git a/include/event_data.h b/include/event_data.h
index e1d46348..1f0f090a 100644
--- a/include/event_data.h
+++ b/include/event_data.h
@@ -1,6 +1,8 @@
#ifndef GUARD_SCRIPT_STATE_H
#define GUARD_SCRIPT_STATE_H
+#include "save_block_2.h"
+
struct ScriptState
{
u16 vars[288];
diff --git a/include/heap.h b/include/heap.h
index 6f04c5bc..69aedd9e 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -1,9 +1,37 @@
#ifndef POKEDIAMOND_HEAP_H
#define POKEDIAMOND_HEAP_H
-void * AllocFromHeap(u32 heap_id, u32 size);
-void * AllocFromHeapAtEnd(u32 heap_id, u32 size);
-void FreeToHeap(void * ptr);
+#include "global.h"
+
+struct UnkStruct_020166C8
+{
+ void **unk00;
+ void **unk04;
+ void **unk08;
+ u16 *unk0c;
+ u8 *unk10;
+ u16 unk14;
+ u16 unk16;
+ u16 unk18;
+ u16 unk1a;
+};
+
+
+THUMB_FUNC void FUN_020166C8(u32 *param0, u32 param1, u32 param2, u32 pre_size);
+THUMB_FUNC s32 FUN_020167F4();
+THUMB_FUNC u32 FUN_0201681C(u32 param0, u32 heap_id, u32 param2);
+THUMB_FUNC u32 FUN_02016828(u32 param0, u32 param1, u32 param2);
+THUMB_FUNC u32 FUN_02016834(u32 param0, u32 param1, u32 param2, s32 param3);
+THUMB_FUNC void FUN_020168D0(u32 heap_id);
+THUMB_FUNC u32 *FUN_02016944(void *param0, u32 param1, s32 param2, u32 param3);
+THUMB_FUNC void FUN_02016988();
+void *AllocFromHeap(u32 heap_id, u32 size);
+void *AllocFromHeapAtEnd(u32 heap_id, u32 size);
+void FreeToHeap(void *ptr);
void FUN_02016A8C(u32 heap_id, void * ptr);
+THUMB_FUNC u32 FUN_02016AF8(u32 param0);
+THUMB_FUNC void FUN_02016B20(u32 param0, u32 param1, u32 param2);
+THUMB_FUNC void FUN_02016B44(void *ptr, u32 param1);
+THUMB_FUNC u32 FUN_02016B90(u32 param0);
#endif //POKEDIAMOND_HEAP_H
diff --git a/include/scrcmd.h b/include/scrcmd.h
index 5ebec947..f40f7841 100644
--- a/include/scrcmd.h
+++ b/include/scrcmd.h
@@ -1,6 +1,72 @@
#ifndef POKEDIAMOND_SCRCMD_H
#define POKEDIAMOND_SCRCMD_H
-BOOL ScrCmd_givemon(struct ScriptContext* ctx);
+#include "global.h"
+#include "script.h"
+
+struct UnkStruct_0203A288 {
+ u8 unk0;
+ u8 unk1;
+ u8 unk2;
+ u8 padding[1];
+};
+
+//scrcmd.c
+BOOL ScrCmd_Nop(struct ScriptContext* ctx);
+BOOL ScrCmd_Dummy(struct ScriptContext* ctx);
+BOOL ScrCmd_End(struct ScriptContext* ctx);
+BOOL ScrCmd_Wait(struct ScriptContext* ctx);
+BOOL ScrCmd_DebugWatch(struct ScriptContext* ctx);
+BOOL ScrCmd_LoadByte(struct ScriptContext* ctx);
+BOOL ScrCmd_LoadWord(struct ScriptContext* ctx);
+BOOL ScrCmd_LoadByteFromAddr(struct ScriptContext* ctx);
+BOOL ScrCmd_WriteByteToAddr(struct ScriptContext* ctx);
+BOOL ScrCmd_SetPtrByte(struct ScriptContext* ctx);
+BOOL ScrCmd_CopyLocal(struct ScriptContext* ctx);
+BOOL ScrCmd_CopyByte(struct ScriptContext* ctx);
+BOOL ScrCmd_CompareLocalToLocal(struct ScriptContext* ctx);
+BOOL ScrCmd_CompareLocalToValue(struct ScriptContext* ctx);
+BOOL ScrCmd_CompareLocalToAddr(struct ScriptContext* ctx);
+BOOL ScrCmd_CompareAddrToLocal(struct ScriptContext* ctx);
+BOOL ScrCmd_CompareAddrToValue(struct ScriptContext* ctx);
+BOOL ScrCmd_CompareAddrToAddr(struct ScriptContext* ctx);
+BOOL ScrCmd_CompareVarToValue(struct ScriptContext* ctx);
+BOOL ScrCmd_CompareVarToVar(struct ScriptContext* ctx);
+BOOL ScrCmd_RunScript(struct ScriptContext* ctx);
+BOOL ScrCmd_RunScriptWait(struct ScriptContext* ctx);
+BOOL ScrCmd_RestartCurrentScript(struct ScriptContext* ctx);
+BOOL ScrCmd_GoTo(struct ScriptContext* ctx);
+BOOL ScrCmd_ObjectGoTo(struct ScriptContext* ctx);
+BOOL ScrCmd_BgGoTo(struct ScriptContext* ctx);
+BOOL ScrCmd_DirectionGoTo(struct ScriptContext* ctx);
+BOOL ScrCmd_Call(struct ScriptContext* ctx);
+BOOL ScrCmd_Return(struct ScriptContext* ctx);
+BOOL ScrCmd_GoToIf(struct ScriptContext* ctx);
+BOOL ScrCmd_CallIf(struct ScriptContext* ctx);
+BOOL ScrCmd_SetFlag(struct ScriptContext* ctx);
+BOOL ScrCmd_ClearFlag(struct ScriptContext* ctx);
+BOOL ScrCmd_CheckFlag(struct ScriptContext* ctx);
+BOOL ScrCmd_CheckFlagVar(struct ScriptContext* ctx);
+BOOL ScrCmd_SetFlagVar(struct ScriptContext* ctx);
+BOOL ScrCmd_SetTrainerFlag(struct ScriptContext* ctx);
+BOOL ScrCmd_ClearTrainerFlag(struct ScriptContext* ctx);
+BOOL ScrCmd_CheckTrainerFlag(struct ScriptContext* ctx);
+BOOL ScrCmd_AddVar(struct ScriptContext* ctx);
+BOOL ScrCmd_SubVar(struct ScriptContext* ctx);
+BOOL ScrCmd_SetVar(struct ScriptContext* ctx);
+BOOL ScrCmd_CopyVar(struct ScriptContext* ctx);
+BOOL ScrCmd_SetOrCopyVar(struct ScriptContext* ctx);
+BOOL ScrCmd_Message(struct ScriptContext* ctx);
+BOOL ScrCmd_MessageFrom(struct ScriptContext* ctx);
+BOOL ScrCmd_MessageFrom2(struct ScriptContext* ctx);
+BOOL ScrCmd_Unk01FC(struct ScriptContext* ctx);
+BOOL ScrCmd_Unk01FD(struct ScriptContext* ctx);
+BOOL ScrCmd_Unk01FE(struct ScriptContext* ctx);
+BOOL ScrCmd_Unk01FF(struct ScriptContext* ctx);
+BOOL ScrCmd_Unk026D(struct ScriptContext* ctx);
+BOOL ScrCmd_Unk002C(struct ScriptContext* ctx);
+
+//scrcmd_18.c
+BOOL ScrCmd_GiveMon(struct ScriptContext* ctx);
#endif //POKEDIAMOND_SCRCMD_H
diff --git a/include/script.h b/include/script.h
index 8fd7696f..5da251b5 100644
--- a/include/script.h
+++ b/include/script.h
@@ -10,28 +10,51 @@ struct ScriptContext;
typedef u8 (*ScrCmdFunc)(struct ScriptContext *);
typedef u8 Script[];
+
+struct UnkStruct_020464D4
+{
+ u16 unk0[4];
+ u8 padding[0x108];
+};
+
+struct UnkStruct_02046444
+{
+ u8 padding[0x90];
+ struct UnkStruct_020464D4 unk90[1]; //todo find size
+};
+
+struct UnkSavStruct80
+{
+ u8 padding[0xC];
+ struct SaveBlock2 *saveBlock2;
+ u8 padding2[0xC];
+ u32 *mapId;
+ u8 padding3[0x88];
+ struct UnkStruct_02046444 * unkA8;
+};
+
struct ScriptContext
{
u8 stackDepth;
u8 mode;
u8 comparisonResult;
- u8 (*nativePtr)(struct ScriptContext *);
+ BOOL (*nativePtr)(struct ScriptContext *);
const u8 *scriptPtr;
const u8 *stack[20];
ScrCmdFunc *cmdTable;
u32 cmdCount;
u32 data[4];
- u32 unk74;
- struct MsgData * unk78;
+ struct UnkStruct_0204639C * unk74;
+ struct MsgData * msgData;
u8 *unk7C;
- struct UnkStruct_0204639C * unk80;
+ struct UnkSavStruct80 * unk80;
};
#define ScriptReadByte(ctx) (*(ctx->scriptPtr++))
void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, u32 cmdCount);
u8 SetupBytecodeScript(struct ScriptContext *ctx, const u8 *ptr);
-void SetupNativeScript(struct ScriptContext *ctx, u8 (*ptr)(struct ScriptContext *));
+void SetupNativeScript(struct ScriptContext *ctx, BOOL (*ptr)(struct ScriptContext *));
void StopScript(struct ScriptContext *ctx);
void FUN_02038B6C(struct ScriptContext *ctx, s32 r1);
u8 RunScriptCommand(struct ScriptContext *ctx);
diff --git a/include/unk_02015E30.h b/include/unk_02015E30.h
new file mode 100644
index 00000000..32a46d39
--- /dev/null
+++ b/include/unk_02015E30.h
@@ -0,0 +1,21 @@
+#ifndef POKEDIAMOND_UNK_02015E30_H
+#define POKEDIAMOND_UNK_02015E30_H
+
+#include "global.h"
+#include "igt.h"
+
+struct UnkStruct_02015E30
+{
+ u32 unk00;
+ struct IGT *unk04;
+ u64 unk08;
+ u32 unk10;
+ u32 unk14;
+ u64 unk18;
+};
+
+THUMB_FUNC void FUN_02015E30();
+THUMB_FUNC void FUN_02015E3C(struct IGT *igt);
+THUMB_FUNC void FUN_02015E60();
+
+#endif //POKEDIAMOND_UNK_02015E30_H
diff --git a/include/unk_02024E64.h b/include/unk_02024E64.h
index b5cfaa6e..ed1bd447 100644
--- a/include/unk_02024E64.h
+++ b/include/unk_02024E64.h
@@ -1,15 +1,28 @@
+#ifndef POKEDIAMOND_UNK_02024E64_H
+#define POKEDIAMOND_UNK_02024E64_H
+
#include "global.h"
#include "MI_memory.h"
#include "save_block_2.h"
#include "string16.h"
+struct UnkStruct_02024E64 {
+ u8 unk0[0xE][0x80];
+ u8 unk700[0x24];
+ u16 rival_name_buf[0x8];
+ u16 unk734[0xB];
+ u8 unk74A[2]; // might be padding
+};
+
THUMB_FUNC u32 FUN_02024E64();
-THUMB_FUNC void FUN_02024E6C(void *param0);
-THUMB_FUNC void *FUN_02024EB4(struct SaveBlock2 *sav2);
+THUMB_FUNC void FUN_02024E6C(struct UnkStruct_02024E64 *param0);
+THUMB_FUNC struct UnkStruct_02024E64 *FUN_02024EB4(struct SaveBlock2 *sav2);
THUMB_FUNC void *FUN_02024EC0(struct SaveBlock2 *sav2);
-THUMB_FUNC void *FUN_02024ECC(struct SaveBlock2 *sav2);
+THUMB_FUNC struct UnkStruct_02024E64 *FUN_02024ECC(struct SaveBlock2 *sav2);
THUMB_FUNC void *FUN_02024ED8(struct SaveBlock2 *sav2);
-THUMB_FUNC u16 *FUN_02024EE8(void *buf);
-THUMB_FUNC void FUN_02024EF4(u16 *buf, struct String *str);
-THUMB_FUNC u16 *FUN_02024F0C(void *buf);
-THUMB_FUNC void FUN_02024F18(u16 *buf, struct String *str);
+THUMB_FUNC u16 *GetRivalNamePtr(struct UnkStruct_02024E64 *unk);
+THUMB_FUNC void RivalsNameToU16Array(struct UnkStruct_02024E64 *unk, struct String *str);
+THUMB_FUNC u16 *FUN_02024F0C(struct UnkStruct_02024E64 *unk);
+THUMB_FUNC void FUN_02024F18(struct UnkStruct_02024E64 *unk, struct String *str);
+
+#endif