From 28f7626d24511428986ce9c47d29ecc28047b256 Mon Sep 17 00:00:00 2001 From: red031000 Date: Wed, 24 Mar 2021 22:38:46 +0000 Subject: more scrcmd --- arm9/src/scrcmd.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 2 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index bad0d69c..0b11ba0a 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -50,6 +50,12 @@ extern void MOD05_021E1C4C(u32 param0, u32 param1, u32 param2); extern void MOD05_021E1C54(u32 param0); extern u32 FUN_02052714(u32 param0); extern void MOD05_021E1ECC(u32 param0); +extern u32 MOD05_021E1F34(struct UnkSavStruct80 *arg, u8 param1, u8 param2, u8 param3, u8 param4, u16 *param5, u32 param6, u32 *param7, struct MsgData *msgData); +extern void MOD05_021E1F58(u32 param0, u8 param1, u8 param2, u8 param3); +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 u8 *UNK_020F34E0; @@ -66,7 +72,7 @@ static BOOL FUN_0203A8A0(struct ScriptContext *ctx); static BOOL FUN_0203A94C(struct ScriptContext *ctx); static BOOL FUN_0203AA0C(struct ScriptContext *ctx); static BOOL FUN_0203AB00(struct ScriptContext *ctx); -/*static*/ BOOL FUN_0203AD2C(struct ScriptContext *ctx); +static BOOL FUN_0203AD2C(struct ScriptContext *ctx); static BOOL FUN_0203AD78(struct ScriptContext *ctx); extern u8 sScriptConditionTable[6][3]; @@ -1173,7 +1179,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0043(struct ScriptContext *ctx) return TRUE; } -THUMB_FUNC BOOL FUN_0203AD2C(struct ScriptContext *ctx) +THUMB_FUNC static BOOL FUN_0203AD2C(struct ScriptContext *ctx) { u16 *varPtr = GetVarPointer(ctx->unk80, (u16)ctx->data[0]); if (*varPtr == 0xEEEE) @@ -1218,3 +1224,79 @@ THUMB_FUNC static BOOL FUN_0203AD78(struct ScriptContext *ctx) return TRUE; } } + +THUMB_FUNC BOOL ScrCmd_Unk0044(struct ScriptContext *ctx) +{ + struct UnkSavStruct80 *unk80 = ctx->unk80; + u32 *unk = FUN_02039438(unk80, 0); + u32 *unk2 = FUN_02039438(unk80, 15); + u8 unk3 = ScriptReadByte(ctx); + u8 unk4 = ScriptReadByte(ctx); + u8 unk5 = ScriptReadByte(ctx); + u8 unk6 = ScriptReadByte(ctx); + + u16 halfWord = ScriptReadHalfword(ctx); + u16 *varPtr = GetVarPointer(unk80, halfWord); + u32 *unk7 = FUN_02039438(ctx->unk80, 1); + *unk = MOD05_021E1F34(unk80, unk3, unk4, unk5, unk6, varPtr, *unk2, unk7, NULL); + ctx->data[0] = halfWord; + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0045(struct ScriptContext *ctx) +{ + struct UnkSavStruct80 *unk80 = ctx->unk80; + u32 *unk = FUN_02039438(unk80, 0); + u32 *unk2 = FUN_02039438(unk80, 15); + u8 unk3 = ScriptReadByte(ctx); + u8 unk4 = ScriptReadByte(ctx); + u8 unk5 = ScriptReadByte(ctx); + u8 unk6 = ScriptReadByte(ctx); + + u16 halfWord = ScriptReadHalfword(ctx); + u16 *varPtr = GetVarPointer(unk80, halfWord); + u32 *unk7 = FUN_02039438(ctx->unk80, 1); + *unk = MOD05_021E1F34(unk80, unk3, unk4, unk5, unk6, varPtr, *unk2, unk7, ctx->msgData); + ctx->data[0] = halfWord; + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0046(struct ScriptContext *ctx) +{ + u32 *unk = FUN_02039438(ctx->unk80, 0); + u16 unk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 unk3 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 unk4 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + MOD05_021E1F58(*unk, (u8)unk2, (u8)unk3, (u8)unk4); + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0047(struct ScriptContext *ctx) +{ + u32 *unk = FUN_02039438(ctx->unk80, 0); + MOD05_021E1F60(*unk); + SetupNativeScript(ctx, FUN_0203AD2C); + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0048(struct ScriptContext *ctx) +{ + u32 *unk = FUN_02039438(ctx->unk80, 0); + MOD05_021E26CC(*unk, ScriptReadByte(ctx)); + SetupNativeScript(ctx, FUN_0203AD2C); + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk02CF(struct ScriptContext *ctx) +{ + u32 *unk = FUN_02039438(ctx->unk80, 0); + MOD05_021E2B80(*unk, ScriptReadByte(ctx)); + return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk02D0(struct ScriptContext *ctx) +{ + u32 *unk = FUN_02039438(ctx->unk80, 0); + MOD05_021E2B9C(*unk, ScriptReadByte(ctx)); + return TRUE; +} -- cgit v1.2.3 From 5e505aa880f4e07dbd20ba698d2936965f6170f1 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Fri, 26 Mar 2021 18:37:38 -0500 Subject: decomp unk_02025484 --- arm9/src/unk_02025484.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 arm9/src/unk_02025484.c (limited to 'arm9/src') diff --git a/arm9/src/unk_02025484.c b/arm9/src/unk_02025484.c new file mode 100644 index 00000000..7a394da8 --- /dev/null +++ b/arm9/src/unk_02025484.c @@ -0,0 +1,28 @@ +#include "global.h" +#include "MI_memory.h" +#include "error_handling.h" +#include "unk_02025484.h" + +THUMB_FUNC void FUN_02025484(struct unk_2025484 *r0, u32 r1) +{ + MI_CpuFill8(r0, 0, sizeof(struct unk_2025484)); +} + +THUMB_FUNC u32 *FUN_02025490(struct unk_2025484 *r0, u32 r1) +{ + FUN_02025484(r0, r1); + r0->unk0 = r1; + return &r0->unk4; +} + +THUMB_FUNC u32 *FUN_020254A0(struct unk_2025484 *r0, u32 r1) +{ + if(r0->unk0 != r1) + ErrorHandling(); + return &r0->unk4; +} + +THUMB_FUNC u32 FUN_020254B4(struct unk_2025484 *r0) +{ + return r0->unk0; +} -- cgit v1.2.3 From c93f033923e84964e8f096cb914e695d0d4f3444 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Fri, 26 Mar 2021 18:49:48 -0500 Subject: use GF_ASSERT --- arm9/src/unk_02025484.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/unk_02025484.c b/arm9/src/unk_02025484.c index 7a394da8..733ac23a 100644 --- a/arm9/src/unk_02025484.c +++ b/arm9/src/unk_02025484.c @@ -17,8 +17,7 @@ THUMB_FUNC u32 *FUN_02025490(struct unk_2025484 *r0, u32 r1) THUMB_FUNC u32 *FUN_020254A0(struct unk_2025484 *r0, u32 r1) { - if(r0->unk0 != r1) - ErrorHandling(); + GF_ASSERT(r0->unk0 == r1); return &r0->unk4; } -- cgit v1.2.3 From 0cc774d83e739f041f92b10c9703e8520727795f Mon Sep 17 00:00:00 2001 From: tgsm Date: Tue, 30 Mar 2021 06:00:23 -0400 Subject: scrcmd: move some extern declarations into scrcmd.h Prevents us from having to copy and paste these over and over when decompiling more scrcmd files. --- arm9/src/scrcmd.c | 2 -- arm9/src/scrcmd_18_c.c | 2 -- arm9/src/scrcmd_19.c | 3 --- arm9/src/scrcmd_20.c | 3 --- arm9/src/scrcmd_coins.c | 4 ---- arm9/src/scrcmd_money.c | 4 ---- 6 files changed, 18 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index bad0d69c..a40ed547 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -5,8 +5,6 @@ #include "player_data.h" #include "text.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); diff --git a/arm9/src/scrcmd_18_c.c b/arm9/src/scrcmd_18_c.c index c683bc8c..d4437c5f 100644 --- a/arm9/src/scrcmd_18_c.c +++ b/arm9/src/scrcmd_18_c.c @@ -6,8 +6,6 @@ #include "map_header.h" #include "scrcmd.h" -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) diff --git a/arm9/src/scrcmd_19.c b/arm9/src/scrcmd_19.c index f0fb9b42..b0a201b7 100644 --- a/arm9/src/scrcmd_19.c +++ b/arm9/src/scrcmd_19.c @@ -1,9 +1,6 @@ #include "scrcmd.h" #include "bag.h" -extern u16 VarGet(struct UnkSavStruct80* arg, u16); -extern u16* GetVarPointer(struct UnkSavStruct80* arg, u16); - const u16 UNK_020F450C[7][2] = { { 0x0067, 0x008E }, { 0x0065, 0x008A }, diff --git a/arm9/src/scrcmd_20.c b/arm9/src/scrcmd_20.c index bf4fb7f1..882126a0 100644 --- a/arm9/src/scrcmd_20.c +++ b/arm9/src/scrcmd_20.c @@ -1,8 +1,5 @@ #include "scrcmd.h" -extern u16 VarGet(struct UnkSavStruct80* arg, u16); -extern u16* GetVarPointer(struct UnkSavStruct80* arg, u16); - const u16 UNK_020F452A[19][2] = { { 0x00FB, 0x03E8 }, { 0x0109, 0x03E8 }, diff --git a/arm9/src/scrcmd_coins.c b/arm9/src/scrcmd_coins.c index 5f7c4aa8..59638c83 100644 --- a/arm9/src/scrcmd_coins.c +++ b/arm9/src/scrcmd_coins.c @@ -1,10 +1,6 @@ #include "scrcmd.h" #include "coins.h" -extern u16 VarGet(struct UnkSavStruct80* arg, u16); -extern u16* GetVarPointer(struct UnkSavStruct80* arg, u16); -extern struct SaveBlock2 * ScriptEnvironment_GetSav2Ptr(struct UnkSavStruct80* unk); - extern void * FUN_02039438(struct UnkSavStruct80* arg, u8 idx); extern u32 MOD05_021E2950(struct UnkSavStruct80* arg, u8, u8); diff --git a/arm9/src/scrcmd_money.c b/arm9/src/scrcmd_money.c index b61a7ff7..d2254844 100644 --- a/arm9/src/scrcmd_money.c +++ b/arm9/src/scrcmd_money.c @@ -1,10 +1,6 @@ #include "scrcmd.h" #include "player_data.h" -extern u16 VarGet(struct UnkSavStruct80* arg, u16); -extern u16* GetVarPointer(struct UnkSavStruct80* arg, u16); -extern struct SaveBlock2 * ScriptEnvironment_GetSav2Ptr(struct UnkSavStruct80* unk); - extern void * FUN_02039438(struct UnkSavStruct80* arg, u8 idx); extern u32 MOD05_021E27E8(struct UnkSavStruct80* arg, u8, u8); -- cgit v1.2.3 From 14d341e09decfc061f567ef51f615d7bcb012ea8 Mon Sep 17 00:00:00 2001 From: tgsm Date: Tue, 30 Mar 2021 06:28:49 -0400 Subject: Decompile scrcmd_22 -> scrcmd_items --- arm9/src/scrcmd_items.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 arm9/src/scrcmd_items.c (limited to 'arm9/src') diff --git a/arm9/src/scrcmd_items.c b/arm9/src/scrcmd_items.c new file mode 100644 index 00000000..0184d02e --- /dev/null +++ b/arm9/src/scrcmd_items.c @@ -0,0 +1,96 @@ +#include "scrcmd.h" +#include "bag.h" + +extern BOOL FUN_02054CB0(u16 item_id); + +THUMB_FUNC BOOL ScrCmd_GiveItem(struct ScriptContext* ctx) +{ + struct UnkSavStruct80* sav_ptr = ctx->unk80; + + u16 item_id = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 quantity = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16* item_was_added = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + struct Bag* bag = Sav2_Bag_get(sav_ptr->saveBlock2); + + *item_was_added = (u16)Bag_AddItem(bag, item_id, quantity, 4); + + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_TakeItem(struct ScriptContext* ctx) +{ + struct UnkSavStruct80* sav_ptr = ctx->unk80; + + u16 item_id = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 quantity = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16* item_was_taken = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + struct Bag* bag = Sav2_Bag_get(sav_ptr->saveBlock2); + + *item_was_taken = (u16)Bag_TakeItem(bag, item_id, quantity, 4); + + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_HasSpaceForItem(struct ScriptContext* ctx) +{ + struct UnkSavStruct80* sav_ptr = ctx->unk80; + + u16 item_id = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 quantity = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16* has_space = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + struct Bag* bag = Sav2_Bag_get(sav_ptr->saveBlock2); + + *has_space = (u16)Bag_HasSpaceForItem(bag, item_id, quantity, 4); + + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_HasItem(struct ScriptContext* ctx) +{ + struct UnkSavStruct80* sav_ptr = ctx->unk80; + + u16 item_id = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16 quantity = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16* has_item = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + struct Bag* bag = Sav2_Bag_get(sav_ptr->saveBlock2); + + *has_item = (u16)Bag_HasItem(bag, item_id, quantity, 11); + + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_ItemIdIsTMOrHM(struct ScriptContext* ctx) +{ + struct UnkSavStruct80* sav_ptr = ctx->unk80; + + u16 item_id = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16* is_tm_or_hm = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + + *is_tm_or_hm = (u16)FUN_02054CB0(item_id); + + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_GetItemPocketId(struct ScriptContext* ctx) +{ + struct UnkSavStruct80* sav_ptr = ctx->unk80; + + u16 item_id = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); + u16* pocket = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); + + *pocket = (u16)GetItemAttr(item_id, ITEMATTR_POCKET, 11); + + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0081(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0082(struct ScriptContext* ctx) +{ +#pragma unused(ctx) + return FALSE; +} -- cgit v1.2.3