diff options
-rw-r--r-- | arm9/asm/scrcmd_asm.s | 169 | ||||
-rw-r--r-- | arm9/asm/unk_02038C78.s | 2 | ||||
-rw-r--r-- | arm9/global.inc | 2 | ||||
-rw-r--r-- | arm9/src/scrcmd.c | 98 | ||||
-rw-r--r-- | include/scrcmd.h | 2 | ||||
-rw-r--r-- | include/script.h | 3 |
6 files changed, 99 insertions, 177 deletions
diff --git a/arm9/asm/scrcmd_asm.s b/arm9/asm/scrcmd_asm.s index ef0c42fa..417c0605 100644 --- a/arm9/asm/scrcmd_asm.s +++ b/arm9/asm/scrcmd_asm.s @@ -14,175 +14,6 @@ UNK_021C5A0C: ; 0x021C5A0C .text - thumb_func_start ScrCmd_Unk02A1 -ScrCmd_Unk02A1: ; 0x0203B024 - push {r3-r7, lr} - sub sp, #0x8 - add r5, r0, #0x0 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - 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 VarGet - str r0, [sp, #0x0] - add r0, r5, #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 - add r0, #0x80 - ldr r0, [r0, #0x0] - add r1, r4, #0x0 - bl FUN_0203B120 - str r0, [sp, #0x4] - cmp r0, #0x0 - bne _0203B07A - bl GF_AssertFail -_0203B07A: - mov r0, #0x4 - add r1, r0, #0x0 - add r1, #0xfc - bl AllocFromHeap - add r4, r0, #0x0 - ldr r0, [sp, #0x4] - bl FUN_02058B2C - lsl r0, r0, #0x10 - lsr r6, r0, #0x10 - ldr r0, [sp, #0x4] - bl FUN_02058B4C - lsl r0, r0, #0x10 - ldr r2, [sp, #0x0] - lsr r0, r0, #0x10 - mov r1, #0x0 - cmp r6, r2 - bhs _0203B0B0 - mov r2, #0xf - strh r2, [r4, #0x0] - ldr r2, [sp, #0x0] - add r1, r1, #0x1 - sub r2, r2, r6 - strh r2, [r4, #0x2] - b _0203B0C0 -_0203B0B0: - cmp r6, r2 - bls _0203B0C0 - mov r2, #0xe - strh r2, [r4, #0x0] - ldr r2, [sp, #0x0] - add r1, r1, #0x1 - sub r2, r6, r2 - strh r2, [r4, #0x2] -_0203B0C0: - cmp r0, r7 - bhs _0203B0D4 - lsl r2, r1, #0x2 - mov r3, #0xc - strh r3, [r4, r2] - sub r3, r7, r0 - add r0, r4, r2 - strh r3, [r0, #0x2] - add r1, r1, #0x1 - b _0203B0E6 -_0203B0D4: - cmp r0, r7 - bls _0203B0E6 - lsl r2, r1, #0x2 - mov r3, #0xd - strh r3, [r4, r2] - sub r3, r0, r7 - add r0, r4, r2 - strh r3, [r0, #0x2] - add r1, r1, #0x1 -_0203B0E6: - lsl r2, r1, #0x2 - mov r0, #0xfe - strh r0, [r4, r2] - mov r1, #0x0 - add r0, r4, r2 - strh r1, [r0, #0x2] - ldr r0, [sp, #0x4] - add r1, r4, #0x0 - bl FUN_0205AEA4 - add r6, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - mov r1, #0x4 - bl FUN_02039438 - ldrb r1, [r0, #0x0] - add r5, #0x80 - add r2, r4, #0x0 - add r1, r1, #0x1 - strb r1, [r0, #0x0] - ldr r0, [r5, #0x0] - add r1, r6, #0x0 - bl FUN_0203B174 - mov r0, #0x0 - add sp, #0x8 - pop {r3-r7, pc} - - thumb_func_start FUN_0203B120 -FUN_0203B120: ; 0x0203B120 - push {r3, lr} - cmp r1, #0xf2 - bne _0203B130 - ldr r0, [r0, #0x34] - mov r1, #0x30 - bl FUN_020580B4 - pop {r3, pc} -_0203B130: - cmp r1, #0xf1 - bne _0203B13E - mov r1, #0xb - bl FUN_02039438 - ldr r0, [r0, #0x0] - pop {r3, pc} -_0203B13E: - ldr r0, [r0, #0x34] - bl FUN_02058060 - pop {r3, pc} - .balign 4 - - thumb_func_start ScrCmd_Unk005F -ScrCmd_Unk005F: ; 0x0203B148 - push {r3, lr} - ldr r1, _0203B154 ; =FUN_0203B158 - bl SetupNativeScript - mov r0, #0x1 - pop {r3, pc} - .balign 4 -_0203B154: .word FUN_0203B158 - - thumb_func_start FUN_0203B158 -FUN_0203B158: ; 0x0203B158 - push {r3, lr} - add r0, #0x80 - ldr r0, [r0, #0x0] - mov r1, #0x4 - bl FUN_02039438 - ldrb r0, [r0, #0x0] - cmp r0, #0x0 - bne _0203B16E - mov r0, #0x1 - pop {r3, pc} -_0203B16E: - mov r0, #0x0 - pop {r3, pc} - .balign 4 - thumb_func_start FUN_0203B174 FUN_0203B174: ; 0x0203B174 push {r3-r7, lr} diff --git a/arm9/asm/unk_02038C78.s b/arm9/asm/unk_02038C78.s index e40bd803..aea1dbf8 100644 --- a/arm9/asm/unk_02038C78.s +++ b/arm9/asm/unk_02038C78.s @@ -244,7 +244,7 @@ gScriptCmdTable: ; 0x020F355C .word ScrCmd_SaveChatotCry .word ScrCmd_Unk005D .word ScrCmd_Unk005E - .word ScrCmd_Unk005F + .word ScrCmd_WaitForMovement .word ScrCmd_Unk0060 .word ScrCmd_Unk0061 .word ScrCmd_Unk0062 diff --git a/arm9/global.inc b/arm9/global.inc index 63ec31b2..e5ea8659 100644 --- a/arm9/global.inc +++ b/arm9/global.inc @@ -2788,7 +2788,7 @@ .extern ScrCmd_Unk02D0 .extern ScrCmd_Unk005E .extern ScrCmd_Unk02A1 -.extern ScrCmd_Unk005F +.extern ScrCmd_WaitForMovement .extern ScrCmd_Unk0060 .extern ScrCmd_Unk02B4 .extern ScrCmd_Unk0061 diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index 6287579c..c79684a0 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -53,10 +53,12 @@ extern void MOD05_021E1F60(u32 param0); extern void MOD05_021E26CC(u32 param0, u8 param1); extern void MOD05_021E2B80(u32 param0, u8 param1); extern void MOD05_021E2B9C(u32 param0, u8 param1); - -extern u32 FUN_0203B120(struct UnkSavStruct80 *arg, u16 param1); -extern u32 FUN_0205AEA4(u32 param0, const u8 *ptr); -extern void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, u32 param2); +extern u32 FUN_0205AEA4(u32 param0, const void *ptr); +extern void FUN_0203B174(struct UnkSavStruct80 *arg, u32 param1, void *param2); +extern u32 FUN_02058B2C(u32 param0); +extern u32 FUN_02058B4C(u32 param0); +extern u32 FUN_020580B4(u32 param0, u32 param1); +extern u32 FUN_02058060(u32 param0, u32 param1); extern u8 *UNK_020F34E0; @@ -75,6 +77,8 @@ static BOOL FUN_0203AA0C(struct ScriptContext *ctx); static BOOL FUN_0203AB00(struct ScriptContext *ctx); static BOOL FUN_0203AD2C(struct ScriptContext *ctx); static BOOL FUN_0203AD78(struct ScriptContext *ctx); +static u32 FUN_0203B120(struct UnkSavStruct80 *arg, u16 param1); +static BOOL FUN_0203B158(struct ScriptContext *ctx); extern u8 sScriptConditionTable[6][3]; @@ -1314,6 +1318,90 @@ THUMB_FUNC BOOL ScrCmd_Unk005E(struct ScriptContext *ctx) //ApplyMovement? u8 *unk5 = FUN_02039438(ctx->unk80, 4); (*unk5)++; - FUN_0203B174(ctx->unk80, unk4, 0); + FUN_0203B174(ctx->unk80, unk4, NULL); return FALSE; } + +THUMB_FUNC BOOL ScrCmd_Unk02A1(struct ScriptContext *ctx) +{ + u32 unk3; //has to be defined first to match + u16 unk0 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 unk1 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 unk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + + unk3 = FUN_0203B120(ctx->unk80, unk0); + + GF_ASSERT(unk3 != 0); + + u16 *unk4 = AllocFromHeap(4, 0x100); + u16 unk5 = (u16)FUN_02058B2C(unk3); + u16 unk6 = (u16)FUN_02058B4C(unk3); + + u32 pos = 0; + + if (unk5 < unk1) + { + unk4[0] = 15; + pos++; + unk4[1] = unk1 - unk5; + } + else if (unk5 > unk1) + { + unk4[0] = 14; + pos++; + unk4[1] = unk5 - unk1; + } + + if (unk6 < unk2) + { + unk4[pos * 2] = 12; + unk4[pos * 2 + 1] = unk2 - unk6; + pos++; + } + else if (unk6 > unk2) + { + unk4[pos * 2] = 13; + unk4[pos * 2 + 1] = unk6 - unk2; + pos++; + } + + unk4[pos * 2] = 254; + unk4[pos * 2 + 1] = 0; + + u32 unk7 = FUN_0205AEA4(unk3, unk4); + u8 *unk8 = FUN_02039438(ctx->unk80, 4); + + (*unk8)++; + + FUN_0203B174(ctx->unk80, unk7, unk4); + return FALSE; +} + +THUMB_FUNC static u32 FUN_0203B120(struct UnkSavStruct80 *arg, u16 param1) +{ + if (param1 == 242) + { + return FUN_020580B4(arg->unk34, 48); + } + else if (param1 == 241) + { + u32 *res = FUN_02039438(arg, 11); + return *res; + } + else + { + return FUN_02058060(arg->unk34, param1); + } +} + +THUMB_FUNC BOOL ScrCmd_WaitForMovement(struct ScriptContext *ctx) +{ + SetupNativeScript(ctx, FUN_0203B158); + return TRUE; +} + +THUMB_FUNC static BOOL FUN_0203B158(struct ScriptContext *ctx) +{ + u8 *unk = FUN_02039438(ctx->unk80, 4); + return *unk == 0 ? TRUE : FALSE; +} diff --git a/include/scrcmd.h b/include/scrcmd.h index 826b74d3..5e28a4d0 100644 --- a/include/scrcmd.h +++ b/include/scrcmd.h @@ -106,6 +106,8 @@ BOOL ScrCmd_Unk0048(struct ScriptContext *ctx); BOOL ScrCmd_Unk02CF(struct ScriptContext *ctx); BOOL ScrCmd_Unk02D0(struct ScriptContext *ctx); BOOL ScrCmd_Unk005E(struct ScriptContext *ctx); +BOOL ScrCmd_Unk02A1(struct ScriptContext *ctx); +BOOL ScrCmd_WaitForMovement(struct ScriptContext *ctx); // scrcmd_mart.c BOOL ScrCmd_NormalMart(struct ScriptContext * ctx); diff --git a/include/script.h b/include/script.h index 75b65f90..f6eec142 100644 --- a/include/script.h +++ b/include/script.h @@ -33,7 +33,8 @@ struct UnkSavStruct80 struct UnkStruct_0204639C *unk10;
u8 padding2[0x8];
u32 *mapId; //0x1C
- u8 padding3[0x18];
+ u8 padding3[0x14];
+ u32 unk34;
u32 unk38;
u8 padding4[0x24];
u32 unk60;
|