mirror of
https://github.com/pret/pokediamond.git
synced 2026-04-26 00:11:26 -05:00
Decompile first few functions
This commit is contained in:
parent
79f9721132
commit
29ee53ca63
|
|
@ -266,6 +266,7 @@ SECTIONS {
|
|||
unk_020377F0.o (.text)
|
||||
script.o (.text)
|
||||
unk_02038C78.o (.text)
|
||||
scrcmd_c.o (.text)
|
||||
scrcmd.o (.text)
|
||||
scrcmd_2.o (.text)
|
||||
scrcmd_3.o (.text)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
.extern UNK_020F34E8
|
||||
.extern UNK_020F34FC
|
||||
.extern UNK_020F3538
|
||||
.extern CompareUtil
|
||||
.extern gUnknown21C48B8
|
||||
.extern gUnk021C4918
|
||||
|
||||
|
|
@ -16,483 +17,6 @@ UNK_021C5A0C: ; 0x021C5A0C
|
|||
|
||||
.text
|
||||
|
||||
thumb_func_start FUN_020399A0
|
||||
FUN_020399A0: ; 0x020399A0
|
||||
mov r0, #0x0
|
||||
bx lr
|
||||
|
||||
thumb_func_start FUN_020399A4
|
||||
FUN_020399A4: ; 0x020399A4
|
||||
mov r0, #0x0
|
||||
bx lr
|
||||
|
||||
thumb_func_start FUN_020399A8
|
||||
FUN_020399A8: ; 0x020399A8
|
||||
push {r3, lr}
|
||||
bl StopScript
|
||||
mov r0, #0x0
|
||||
pop {r3, pc}
|
||||
.balign 4
|
||||
|
||||
thumb_func_start FUN_020399B4
|
||||
FUN_020399B4: ; 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 FUN_020394B8
|
||||
strh r7, [r0, #0x0]
|
||||
ldr r1, _020399E4 ; =FUN_020399E8
|
||||
add r0, r5, #0x0
|
||||
str r4, [r5, #0x64]
|
||||
bl SetupNativeScript
|
||||
mov r0, #0x1
|
||||
pop {r3-r7, pc}
|
||||
.balign 4
|
||||
_020399E4: .word FUN_020399E8
|
||||
|
||||
thumb_func_start FUN_020399E8
|
||||
FUN_020399E8: ; 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 FUN_020394B8
|
||||
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 FUN_020394F0
|
||||
mov r0, #0x0
|
||||
pop {r4, pc}
|
||||
.balign 4
|
||||
|
||||
thumb_func_start FUN_02039A28
|
||||
FUN_02039A28: ; 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 FUN_02039A40
|
||||
FUN_02039A40: ; 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 FUN_02039A5C
|
||||
FUN_02039A5C: ; 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 FUN_02039A78
|
||||
FUN_02039A78: ; 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 FUN_02039A90
|
||||
FUN_02039A90: ; 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 FUN_02039AAC
|
||||
FUN_02039AAC: ; 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 FUN_02039ACC
|
||||
FUN_02039ACC: ; 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 FUN_02039AE4
|
||||
FUN_02039AE4: ; 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 FUN_02039AF8
|
||||
FUN_02039AF8: ; 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 FUN_02039AE4
|
||||
strb r0, [r4, #0x2]
|
||||
mov r0, #0x0
|
||||
pop {r4, pc}
|
||||
|
||||
thumb_func_start FUN_02039B28
|
||||
FUN_02039B28: ; 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 FUN_02039AE4
|
||||
strb r0, [r4, #0x2]
|
||||
mov r0, #0x0
|
||||
pop {r4, pc}
|
||||
.balign 4
|
||||
|
||||
thumb_func_start FUN_02039B50
|
||||
FUN_02039B50: ; 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 FUN_02039AE4
|
||||
strb r0, [r4, #0x2]
|
||||
mov r0, #0x0
|
||||
pop {r3-r5, pc}
|
||||
|
||||
thumb_func_start FUN_02039B78
|
||||
FUN_02039B78: ; 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 FUN_02039AE4
|
||||
strb r0, [r4, #0x2]
|
||||
mov r0, #0x0
|
||||
pop {r4, pc}
|
||||
.balign 4
|
||||
|
||||
thumb_func_start FUN_02039BA0
|
||||
FUN_02039BA0: ; 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 FUN_02039AE4
|
||||
strb r0, [r4, #0x2]
|
||||
mov r0, #0x0
|
||||
pop {r4, pc}
|
||||
|
||||
thumb_func_start FUN_02039BBC
|
||||
FUN_02039BBC: ; 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 FUN_02039AE4
|
||||
strb r0, [r5, #0x2]
|
||||
mov r0, #0x0
|
||||
pop {r3-r5, pc}
|
||||
.balign 4
|
||||
|
||||
thumb_func_start FUN_02039BDC
|
||||
FUN_02039BDC: ; 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 FUN_020394B8
|
||||
ldrh r5, [r0, #0x0]
|
||||
add r0, r4, #0x0
|
||||
bl ScriptReadHalfword
|
||||
add r1, r0, #0x0
|
||||
add r0, r5, #0x0
|
||||
bl FUN_02039AE4
|
||||
strb r0, [r4, #0x2]
|
||||
mov r0, #0x0
|
||||
pop {r3-r5, pc}
|
||||
.balign 4
|
||||
|
||||
thumb_func_start FUN_02039C08
|
||||
FUN_02039C08: ; 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 FUN_020394B8
|
||||
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 FUN_020394B8
|
||||
add r1, r0, #0x0
|
||||
ldrh r0, [r4, #0x0]
|
||||
ldrh r1, [r1, #0x0]
|
||||
bl FUN_02039AE4
|
||||
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 FUN_02038EB0
|
||||
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 FUN_02038EB0
|
||||
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 FUN_02039CF8
|
||||
FUN_02039CF8: ; 0x02039CF8
|
||||
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}
|
||||
|
|
|
|||
|
|
@ -149,29 +149,29 @@ UNK_020F3538: ; 0x020F3538
|
|||
|
||||
.global gScriptCmdTable
|
||||
gScriptCmdTable: ; 0x020F355C
|
||||
.word FUN_020399A0
|
||||
.word FUN_020399A4
|
||||
.word FUN_020399A8
|
||||
.word FUN_020399B4
|
||||
.word FUN_02039A28
|
||||
.word FUN_02039A40
|
||||
.word FUN_02039A5C
|
||||
.word FUN_02039A78
|
||||
.word FUN_02039A90
|
||||
.word FUN_02039AAC
|
||||
.word FUN_02039ACC
|
||||
.word FUN_02039AF8
|
||||
.word FUN_02039B28
|
||||
.word FUN_02039B50
|
||||
.word FUN_02039B78
|
||||
.word FUN_02039BA0
|
||||
.word FUN_02039BBC
|
||||
.word FUN_02039BDC
|
||||
.word FUN_02039C08
|
||||
.word FUN_02039C40
|
||||
.word FUN_02039C78
|
||||
.word FUN_02039CE4
|
||||
.word FUN_02039CF8
|
||||
.word ScrCmd_Nop
|
||||
.word ScrCmd_Dummy
|
||||
.word ScrCmd_End
|
||||
.word ScrCmd_TimeWait
|
||||
.word ScrCmd_LoadRegValue
|
||||
.word ScrCmd_LoadRegWData
|
||||
.word ScrCmd_LoadRegAdrs
|
||||
.word ScrCmd_LoadAdrsValue
|
||||
.word ScrCmd_LoadAdrsReg
|
||||
.word ScrCmd_LoadRegReg
|
||||
.word ScrCmd_LoadAdrsAdrs
|
||||
.word ScrCmd_CmpRegReg
|
||||
.word ScrCmd_CmpRegValue
|
||||
.word ScrCmd_CmpRegAdrs
|
||||
.word ScrCmd_CmpAdrsReg
|
||||
.word ScrCmd_CmpAdrsValue
|
||||
.word ScrCmd_CmpAdrsAdrs
|
||||
.word ScrCmd_CmpWkValue
|
||||
.word ScrCmd_CmpWkWk
|
||||
.word ScrCmd_VMMachineAdd
|
||||
.word ScrCmd_ChangeCommonScr
|
||||
.word ScrCmd_ChangeLocalScr
|
||||
.word ScrCmd_GlobalJump
|
||||
.word FUN_02039D10
|
||||
.word FUN_02039D48
|
||||
.word FUN_02039D78
|
||||
|
|
@ -654,7 +654,7 @@ gScriptCmdTable: ; 0x020F355C
|
|||
.word FUN_0204469C
|
||||
.word FUN_02044658
|
||||
.word FUN_0203BC2C
|
||||
.word FUN_02039A10
|
||||
.word ScrCmd_DebugWatch
|
||||
.word FUN_0203A04C
|
||||
.word FUN_0203A098
|
||||
.word FUN_0203A0FC
|
||||
|
|
|
|||
|
|
@ -2678,30 +2678,30 @@
|
|||
.extern FUN_02039754
|
||||
.extern FUN_02039874
|
||||
.extern FUN_0203989C
|
||||
.extern FUN_020399A0
|
||||
.extern FUN_020399A4
|
||||
.extern FUN_020399A8
|
||||
.extern FUN_020399B4
|
||||
.extern FUN_02039A10
|
||||
.extern FUN_02039A28
|
||||
.extern FUN_02039A40
|
||||
.extern FUN_02039A5C
|
||||
.extern FUN_02039A78
|
||||
.extern FUN_02039A90
|
||||
.extern FUN_02039AAC
|
||||
.extern FUN_02039ACC
|
||||
.extern FUN_02039AF8
|
||||
.extern FUN_02039B28
|
||||
.extern FUN_02039B50
|
||||
.extern FUN_02039B78
|
||||
.extern FUN_02039BA0
|
||||
.extern FUN_02039BBC
|
||||
.extern FUN_02039BDC
|
||||
.extern FUN_02039C08
|
||||
.extern FUN_02039C40
|
||||
.extern FUN_02039C78
|
||||
.extern FUN_02039CE4
|
||||
.extern FUN_02039CF8
|
||||
.extern ScrCmd_Nop
|
||||
.extern ScrCmd_Dummy
|
||||
.extern ScrCmd_End
|
||||
.extern ScrCmd_TimeWait
|
||||
.extern ScrCmd_DebugWatch
|
||||
.extern ScrCmd_LoadRegValue
|
||||
.extern ScrCmd_LoadRegWData
|
||||
.extern ScrCmd_LoadRegAdrs
|
||||
.extern ScrCmd_LoadAdrsValue
|
||||
.extern ScrCmd_LoadAdrsReg
|
||||
.extern ScrCmd_LoadRegReg
|
||||
.extern ScrCmd_LoadAdrsAdrs
|
||||
.extern ScrCmd_CmpRegReg
|
||||
.extern ScrCmd_CmpRegValue
|
||||
.extern ScrCmd_CmpRegAdrs
|
||||
.extern ScrCmd_CmpAdrsReg
|
||||
.extern ScrCmd_CmpAdrsValue
|
||||
.extern ScrCmd_CmpAdrsAdrs
|
||||
.extern ScrCmd_CmpWkValue
|
||||
.extern ScrCmd_CmpWkWk
|
||||
.extern ScrCmd_VMMachineAdd
|
||||
.extern ScrCmd_ChangeCommonScr
|
||||
.extern ScrCmd_ChangeLocalScr
|
||||
.extern ScrCmd_GlobalJump
|
||||
.extern FUN_02039D10
|
||||
.extern FUN_02039D48
|
||||
.extern FUN_02039D78
|
||||
|
|
|
|||
218
arm9/src/scrcmd_c.c
Normal file
218
arm9/src/scrcmd_c.c
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
|
||||
#include "function_target.h"
|
||||
#include "script.h"
|
||||
#include "types.h"
|
||||
|
||||
// External funcs
|
||||
extern u16* FUN_020394B8(u32 arg, u16 wk);
|
||||
extern u16 FUN_020394F0(u32 arg, u16 wk);
|
||||
extern void* FUN_02039438(u32 arg, u16 id);
|
||||
extern void* FUN_02038EB0(u32 arg, u16 id);
|
||||
|
||||
// Early definitions
|
||||
extern BOOL FUN_020399E8(struct ScriptContext* ctx);
|
||||
extern BOOL FUN_02039CC8(struct ScriptContext* ctx);
|
||||
|
||||
// Functions
|
||||
// Names taken from
|
||||
// https://docs.google.com/spreadsheets/d/16OKEM1UjX8BWE3Gab1DCRChs4jOIPXj06CA5aHee9KQ/edit?usp=sharing
|
||||
THUMB_FUNC BOOL ScrCmd_Nop(struct ScriptContext* ctx) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_Dummy(struct ScriptContext* ctx) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_End(struct ScriptContext* ctx) {
|
||||
StopScript(ctx);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_TimeWait(struct ScriptContext* ctx) {
|
||||
u32 unk80 = ctx->unk80;
|
||||
u16 num = ScriptReadHalfword(ctx);
|
||||
u16 wk = ScriptReadHalfword(ctx);
|
||||
u16* unk = FUN_020394B8(unk80, wk);
|
||||
*unk = num;
|
||||
ctx->data[0] = wk;
|
||||
SetupNativeScript(ctx, FUN_020399E8);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL FUN_020399E8(struct ScriptContext* ctx) {
|
||||
u16* unk = FUN_020394B8(ctx->unk80, ctx->data[0]);
|
||||
*unk = *unk - 1;
|
||||
if (*unk == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_DebugWatch(struct ScriptContext* ctx) {
|
||||
u16 unk = ScriptReadHalfword(ctx);
|
||||
FUN_020394F0(ctx->unk80, unk);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_LoadRegValue(struct ScriptContext* ctx) {
|
||||
u8 index = ScriptReadByte(ctx);
|
||||
ctx->data[index] = ScriptReadByte(ctx);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_LoadRegWData(struct ScriptContext* ctx) {
|
||||
u8 index = ScriptReadByte(ctx);
|
||||
u32 val = ScriptReadWord(ctx);
|
||||
ctx->data[index] = val;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_LoadRegAdrs(struct ScriptContext* ctx) {
|
||||
u8 index = ScriptReadByte(ctx);
|
||||
u8* ptr = (u8*)ScriptReadWord(ctx);
|
||||
ctx->data[index] = *ptr;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_LoadAdrsValue(struct ScriptContext* ctx) {
|
||||
u8* ptr = (u8*)ScriptReadWord(ctx);
|
||||
u8 val = ScriptReadByte(ctx);
|
||||
*ptr = val;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_LoadAdrsReg(struct ScriptContext* ctx) {
|
||||
u8* ptr = (u8*)ScriptReadWord(ctx);
|
||||
u8 index = ScriptReadByte(ctx);
|
||||
*ptr = ctx->data[index];
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_LoadRegReg(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_LoadAdrsAdrs(struct ScriptContext* ctx) {
|
||||
u8* target = (u8*)ScriptReadWord(ctx);
|
||||
u8* source = (u8*)ScriptReadWord(ctx);
|
||||
*target = *source;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC u32 CompareUtil(u16 a, u16 b) {
|
||||
if (a < b) {
|
||||
return 0;
|
||||
} else if (a == b) {
|
||||
return 1;
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_CmpRegReg(struct ScriptContext* ctx) {
|
||||
u8 a = ctx->data[ScriptReadByte(ctx)];
|
||||
u8 b = ctx->data[ScriptReadByte(ctx)];
|
||||
ctx->comparisonResult = CompareUtil(a, b);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_CmpRegValue(struct ScriptContext* ctx) {
|
||||
u8 a = ctx->data[ScriptReadByte(ctx)];
|
||||
u8 b = ScriptReadByte(ctx);
|
||||
ctx->comparisonResult = CompareUtil(a, b);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_CmpRegAdrs(struct ScriptContext* ctx) {
|
||||
u8 a = ctx->data[ScriptReadByte(ctx)];
|
||||
u8 b = *(u8*)ScriptReadWord(ctx);
|
||||
ctx->comparisonResult = CompareUtil(a, b);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_CmpAdrsReg(struct ScriptContext* ctx) {
|
||||
u8 a = *(u8*)ScriptReadWord(ctx);
|
||||
u8 b = ctx->data[ScriptReadByte(ctx)];
|
||||
ctx->comparisonResult = CompareUtil(a, b);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_CmpAdrsValue(struct ScriptContext* ctx) {
|
||||
u8 a = *(u8*)ScriptReadWord(ctx);
|
||||
u8 b = ScriptReadByte(ctx);
|
||||
ctx->comparisonResult = CompareUtil(a, b);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_CmpAdrsAdrs(struct ScriptContext* ctx) {
|
||||
u8 a = *(u8*)ScriptReadWord(ctx);
|
||||
u8 b = *(u8*)ScriptReadWord(ctx);
|
||||
ctx->comparisonResult = CompareUtil(a, b);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_CmpWkValue(struct ScriptContext* ctx) {
|
||||
u16* wk = FUN_020394B8(ctx->unk80, ScriptReadHalfword(ctx));
|
||||
u16 a = *wk;
|
||||
u16 b = ScriptReadHalfword(ctx);
|
||||
ctx->comparisonResult = CompareUtil(a, b);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_CmpWkWk(struct ScriptContext* ctx) {
|
||||
u16* wk1 = FUN_020394B8(ctx->unk80, ScriptReadHalfword(ctx));
|
||||
u16* wk2 = FUN_020394B8(ctx->unk80, ScriptReadHalfword(ctx));
|
||||
ctx->comparisonResult = CompareUtil(*wk1, *wk2);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_VMMachineAdd(struct ScriptContext* ctx) {
|
||||
u32 unk80 = ctx->unk80;
|
||||
u8* unk1 = FUN_02039438(unk80, 0x7);
|
||||
u32** unk2 = FUN_02039438(unk80, 0xe);
|
||||
u16 id = ScriptReadHalfword(ctx);
|
||||
|
||||
*unk2 = FUN_02038EB0(unk80, id);
|
||||
*unk1 = *unk1 + 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_ChangeCommonScr(struct ScriptContext* ctx) {
|
||||
u32 unk80 = ctx->unk80;
|
||||
u8* unk_flag_0x5 = FUN_02039438(unk80, 0x5);
|
||||
u8* unk2 = FUN_02039438(unk80, 0x7);
|
||||
u32** unk3 = FUN_02039438(unk80, 0xe);
|
||||
|
||||
u16 id = ScriptReadHalfword(ctx);
|
||||
*unk_flag_0x5 = 1;
|
||||
*unk3 = FUN_02038EB0(unk80, id);
|
||||
*unk2 = *unk2 + 1;
|
||||
|
||||
SetupNativeScript(ctx, FUN_02039CC8);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL FUN_02039CC8(struct ScriptContext* ctx) {
|
||||
u8* unk_flag_0x5 = FUN_02039438(ctx->unk80, 0x5);
|
||||
|
||||
if (*unk_flag_0x5 == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_ChangeLocalScr(struct ScriptContext* ctx) {
|
||||
u8* unk_flag_0x5 = FUN_02039438(ctx->unk80, 0x5);
|
||||
*unk_flag_0x5 = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
THUMB_FUNC BOOL ScrCmd_GlobalJump(struct ScriptContext* ctx) {
|
||||
s32 offset = (s32)ScriptReadWord(ctx); // Using s32 since it's also used negative
|
||||
ScriptJump(ctx, ctx->scriptPtr + offset);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -13,20 +13,23 @@ 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;
|
||||
ScrCmdFunc *cmdTableEnd;
|
||||
u32 data[4];
|
||||
u32 unk74;
|
||||
u32 unk78;
|
||||
u32 unk7C;
|
||||
u32 unk80;
|
||||
};
|
||||
|
||||
#define ScriptReadByte(ctx) (*(ctx->scriptPtr++))
|
||||
|
||||
void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTableEnd);
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user