summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arm9/arm9.lsf1
-rw-r--r--arm9/asm/scrcmd_asm.s (renamed from arm9/asm/scrcmd.s)371
-rw-r--r--arm9/asm/unk_02038C78.s42
-rw-r--r--arm9/global.inc42
-rw-r--r--arm9/src/scrcmd.c182
-rw-r--r--arm9/src/scrcmd_18_c.c2
-rw-r--r--arm9/src/script.c2
-rw-r--r--include/scrcmd.h28
-rw-r--r--include/script.h4
9 files changed, 256 insertions, 418 deletions
diff --git a/arm9/arm9.lsf b/arm9/arm9.lsf
index b8accee4..fbe54fd5 100644
--- a/arm9/arm9.lsf
+++ b/arm9/arm9.lsf
@@ -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..493fea57 100644
--- a/arm9/asm/scrcmd.s
+++ b/arm9/asm/scrcmd_asm.s
@@ -15,377 +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}
diff --git a/arm9/asm/unk_02038C78.s b/arm9/asm/unk_02038C78.s
index f35fd58e..28fad682 100644
--- a/arm9/asm/unk_02038C78.s
+++ b/arm9/asm/unk_02038C78.s
@@ -149,25 +149,25 @@ 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 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 FUN_02039C40
.word FUN_02039C78
.word FUN_02039CE4
@@ -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,7 +654,7 @@ gScriptCmdTable: ; 0x020F355C
.word ScrCmd_countpartymonsatorbelowlevel
.word ScrCmd_survivepsn
.word FUN_0203BC2C
- .word FUN_02039A10
+ .word ScrCmd_DebugWatch
.word ScrCmd_message_from
.word FUN_0203A098
.word FUN_0203A0FC
diff --git a/arm9/global.inc b/arm9/global.inc
index d816d92a..c45c0a45 100644
--- a/arm9/global.inc
+++ b/arm9/global.inc
@@ -2699,26 +2699,26 @@
.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 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 FUN_02039C40
.extern FUN_02039C78
.extern FUN_02039CE4
@@ -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/src/scrcmd.c b/arm9/src/scrcmd.c
new file mode 100644
index 00000000..ae25050d
--- /dev/null
+++ b/arm9/src/scrcmd.c
@@ -0,0 +1,182 @@
+#include "scrcmd.h"
+
+extern u16 *GetVarPointer(struct UnkStruct_0204639C* arg, u16);
+extern u16 VarGet(struct UnkStruct_0204639C* arg, u16 wk);
+
+static BOOL RunPauseTimer(struct ScriptContext* ctx);
+static u32 Compare(u16 a, u16 b);
+
+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 UnkStruct_0204639C* 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;
+}
diff --git a/arm9/src/scrcmd_18_c.c b/arm9/src/scrcmd_18_c.c
index b8bbbcdd..510e181f 100644
--- a/arm9/src/scrcmd_18_c.c
+++ b/arm9/src/scrcmd_18_c.c
@@ -10,7 +10,7 @@ extern u16 VarGet(struct UnkStruct_0204639C* arg, u16 wk);
extern u16 *GetVarPointer(struct UnkStruct_0204639C* 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;
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/include/scrcmd.h b/include/scrcmd.h
index 5ebec947..0aa3fd75 100644
--- a/include/scrcmd.h
+++ b/include/scrcmd.h
@@ -1,6 +1,32 @@
#ifndef POKEDIAMOND_SCRCMD_H
#define POKEDIAMOND_SCRCMD_H
-BOOL ScrCmd_givemon(struct ScriptContext* ctx);
+#include "global.h"
+#include "script.h"
+
+//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);
+
+//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..c25751e4 100644
--- a/include/script.h
+++ b/include/script.h
@@ -15,7 +15,7 @@ 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;
@@ -31,7 +31,7 @@ struct ScriptContext
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);