From 4b459cd4607a48a84bcc14122d2ad324424fdff2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 5 Jan 2019 17:08:30 -0500 Subject: through sub_815E1F0 --- src/load_save.c | 2 +- src/trainer_tower.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/load_save.c b/src/load_save.c index da55869aa..6f388e451 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -287,7 +287,7 @@ void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey) int i; for(i = 0; i < 4; i++) - ApplyNewEncryptionKeyToWord(&gSaveBlock1Ptr->unkArray[i][1], encryptionKey); + ApplyNewEncryptionKeyToWord(&gSaveBlock1Ptr->unkArray[i].unk4, encryptionKey); sub_8054F38(encryptionKey); ApplyNewEncryptionKeyToBagItems_(encryptionKey); diff --git a/src/trainer_tower.c b/src/trainer_tower.c index 91132c07b..eb9637b71 100644 --- a/src/trainer_tower.c +++ b/src/trainer_tower.c @@ -1,5 +1,6 @@ #include "global.h" #include "main.h" +#include "task.h" #include "constants/flags.h" #include "constants/vars.h" #include "malloc.h" @@ -11,6 +12,10 @@ #include "cereader_tool.h" #include "easy_chat.h" #include "text.h" +#include "battle_setup.h" +#include "battle_transition.h" +#include "battle.h" +#include "battle_2.h" #include "overworld.h" struct UnkStruct_8479D34 @@ -28,7 +33,6 @@ struct UnkSubstruct_203F458_000C_004 /* 0x000 */ u8 unk_000[11]; /* 0x00B */ u8 unk_00B; /* 0x00C */ u8 unk_00C; - /* 0x00D */ u8 unk_00D; /* 0x00E */ u16 unk_00E[6]; /* 0x01A */ u16 unk_01A[6]; /* 0x026 */ u16 unk_026[6]; @@ -122,6 +126,7 @@ void sub_815E8CC(void); void sub_815E908(void); void sub_815E948(void); void sub_815E9C8(void); +void sub_815E9FC(void); void sub_815EC0C(void); extern const struct UnkStruct_8479D34 gUnknown_8479D34[15]; @@ -280,7 +285,7 @@ void sub_815DA54(void) gUnknown_203F45C->unk_3C = gUnknown_203F458->unk_0004.unk_0008[gUnknown_203F458->unk_0000].unk_002; gUnknown_203F45C->unk_3D = gUnknown_203F458->unk_0004.unk_0008[gUnknown_203F458->unk_0000].unk_004[r10].unk_00B; gUnknown_203F45C->unk_3E = gUnknown_203F458->unk_0004.unk_0008[gUnknown_203F458->unk_0000].unk_004[r10].unk_00C; - SetVBlankCounter1Ptr(gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx]); + SetVBlankCounter1Ptr(&gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk0); sub_815DD2C(); } @@ -692,3 +697,77 @@ void sub_815DF54(void) "_0815E064: .4byte gStringVar4"); } #endif // NONMATCHING + +void sub_815E068(u8 battleType, u8 facilityClass) +{ + u16 r5 = FALSE; + s32 r4; + switch (battleType) + { + case 0: + case 2: + for (r4 = 0; r4 < NELEMS(gUnknown_8479ED8); r4++) + { + if (gUnknown_8479ED8[r4].unk1 == facilityClass) + break; + } + if (r4 != NELEMS(gUnknown_8479ED8)) + r5 = gUnknown_8479ED8[r4].unk2; + break; + case 1: + for (r4 = 0; r4 < NELEMS(gUnknown_847A024); r4++) + { + if (gUnknown_847A024[r4].unk2 == facilityClass) + break; + } + if (r4 != NELEMS(gUnknown_847A024)) + { + if (VarGet(VAR_0x4003)) + r5 = gUnknown_847A024[r4].unk4; + else + r5 = gUnknown_847A024[r4].unk3; + } + break; + } + gUnknown_20370DC = gUnknown_20370DA; + gUnknown_20370DA = r5; +} + +void sub_815E114(void) +{ + SetMainCallback2(c2_exit_to_overworld_1_continue_scripts_restart_music); +} + +void sub_815E124(u8 taskId) +{ + if (sub_80D08F8() == TRUE) + { + gMain.savedCallback = sub_815E114; + sub_80563F0(); + SetMainCallback2(sub_800FD9C); + DestroyTask(taskId); + } +} + +void sub_815E160(void) +{ + gBattleTypeFlags = BATTLE_TYPE_TRAINER | BATTLE_TYPE_FACTORY; + if (gUnknown_203F458->unk_0004.unk_0008[gUnknown_203F458->unk_0000].unk_002 == 1) + gBattleTypeFlags |= BATTLE_TYPE_DOUBLE; + gTrainerBattleOpponent_A = 0; + sub_815E9FC(); + CreateTask(sub_815E124, 1); + PlayMapChosenOrBattleBGM(0); + sub_80D08B8(sub_8080060()); +} + +void sub_815E1C0(void) +{ + if (!gSpecialVar_0x8005) + gSpecialVar_Result = gUnknown_203F458->unk_0004.unk_0008[gUnknown_203F458->unk_0000].unk_002; +} + +void sub_815E1F0(void) +{ + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk8++; +} -- cgit v1.2.3 From 1e699465bdef048f0c2d9574db6ca9a0dd77b051 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 5 Jan 2019 18:12:00 -0500 Subject: through sub_815E5C4 --- src/trainer_tower.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/trainer_tower.c b/src/trainer_tower.c index eb9637b71..b196c49f7 100644 --- a/src/trainer_tower.c +++ b/src/trainer_tower.c @@ -17,6 +17,7 @@ #include "battle.h" #include "battle_2.h" #include "overworld.h" +#include "item.h" struct UnkStruct_8479D34 { @@ -42,7 +43,8 @@ struct UnkSubstruct_203F458_000C_004 struct UnkSubstruct_203F458_000C { - /* 0x000 */ u8 filler_000[2]; + /* 0x000 */ u8 unk_000; + /* 0x000 */ u8 unk_001; /* 0x002 */ u8 unk_002; /* 0x003 */ u8 unk_003; /* 0x004 */ struct UnkSubstruct_203F458_000C_004 unk_004[3]; @@ -128,14 +130,17 @@ void sub_815E948(void); void sub_815E9C8(void); void sub_815E9FC(void); void sub_815EC0C(void); +u32 sub_815EDDC(u32 *); +void sub_815EDF4(u32 *, u32); extern const struct UnkStruct_8479D34 gUnknown_8479D34[15]; +extern const struct UnkStruct_8479ED8 gUnknown_8479ED8[83]; +extern const struct UnkStruct_847A024 gUnknown_847A024[10]; extern void (*const gUnknown_847A230[])(void); extern const struct Unk_203F458_Header gUnknown_84827AC; extern const struct UnkSubstruct_203F458_000C *const gUnknown_84827B4[][8]; extern const u16 gUnknown_847A284[8][3]; -extern const struct UnkStruct_8479ED8 gUnknown_8479ED8[83]; -extern const struct UnkStruct_847A024 gUnknown_847A024[10]; +extern const u16 gUnknown_847A2B4[]; bool32 sub_815D7BC(void * dest, void * buffer) { @@ -771,3 +776,85 @@ void sub_815E1F0(void) { gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk8++; } + +void sub_815E218(void) +{ + u16 mapDataId = gMapHeader.mapDataId; + if (mapDataId - 0x12A == gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk8 && mapDataId - 0x129 <= gUnknown_203F458->unk_0004.unk_0008[gUnknown_203F458->unk_0000].unk_001) + gSpecialVar_Result = FALSE; + else + gSpecialVar_Result = TRUE; +} + +void sub_815E28C(void) +{ + gSaveBlock1Ptr->unkArrayIdx = gSpecialVar_0x8005; + if (gSaveBlock1Ptr->unkArrayIdx >= NELEMS(gSaveBlock1Ptr->unkArray)) + gSaveBlock1Ptr->unkArrayIdx = 0; + sub_815EC0C(); + if (!sub_815D834()) + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_5 = TRUE; + else + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_5 = FALSE; + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk8 = 0; + SetVBlankCounter1Ptr(&gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk0); + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk0 = 0; + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_2 = FALSE; + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_1 = FALSE; +} + +void sub_815E394(void) +{ + DisableVBlankCounter1(); + gSpecialVar_Result = 0; + if (gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_2) + gSpecialVar_Result++; + if (gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_0 && gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_1) + gSpecialVar_Result++; + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_2 = TRUE; +} + +void sub_815E408(void) +{ + u16 itemId = gUnknown_847A2B4[gUnknown_203F458->unk_0004.unk_0008->unk_003]; + if (gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_0) + gSpecialVar_Result = 2; + else if (sub_809A084(itemId, 1) == 1) + { + sub_8099E90(itemId, gStringVar2); + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_0 = TRUE; + gSpecialVar_Result = 0; + } + else + gSpecialVar_Result = 1; +} + +void sub_815E4B0(void) +{ + if (gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_1) + gSpecialVar_Result = 2; + else if (sub_815EDDC(&gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk4) > gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk0) + { + sub_815EDF4(&gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk4, gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk0); + gSpecialVar_Result = 0; + } + else + gSpecialVar_Result = 1; + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_1 = TRUE; +} + +void sub_815E56C(void) +{ + if (!gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_2) + { + if (gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk0 >= 215999) + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk0 = 215999; + else + SetVBlankCounter1Ptr(&gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unk0); + } +} + +void sub_815E5C4(void) +{ + gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_3 = 1; +} -- cgit v1.2.3 From 0eba7e0870f3f7e51b69a1f1a7e1e436a977f78b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 5 Jan 2019 23:13:12 -0500 Subject: Start porting scrcmd from emerald --- src/scrcmd.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 src/scrcmd.c (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c new file mode 100644 index 000000000..bb8d969c1 --- /dev/null +++ b/src/scrcmd.c @@ -0,0 +1,223 @@ +#include "global.h" +#include "gba/isagbprint.h" +#include "script.h" +#include "event_data.h" + +extern u16 (*const gSpecials[])(void); +extern u16 (*const gSpecialsEnd[])(void); +extern const u8 *const gStdScripts[]; +extern const u8 *const gStdScriptsEnd[]; + +EWRAM_DATA ptrdiff_t gVScriptOffset = 0; +EWRAM_DATA u8 gUnknown_20370AC = 0; +EWRAM_DATA u16 gUnknown_20370AE = 0; +EWRAM_DATA u16 gUnknown_20370B0 = 0; +EWRAM_DATA u16 gUnknown_20370B2 = 0; +EWRAM_DATA u16 gUnknown_20370B4 = 0; +EWRAM_DATA u16 gUnknown_20370B6 = 0; + +// This is defined in here so the optimizer can't see its value when compiling +// script.c. +void * const gNullScriptPtr = NULL; + +const u8 sScriptConditionTable[6][3] = + { +// < = > + 1, 0, 0, // < + 0, 1, 0, // = + 0, 0, 1, // > + 1, 1, 0, // <= + 0, 1, 1, // >= + 1, 0, 1, // != + }; + + + +#define SCRCMD_DEF(name) bool8 name(struct ScriptContext *ctx) + +SCRCMD_DEF(ScrCmd_nop) +{ + return FALSE; +} + +SCRCMD_DEF(ScrCmd_nop1) +{ + return FALSE; +} + +SCRCMD_DEF(ScrCmd_end) +{ + StopScript(ctx); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_gotonative) +{ + bool8 (*func)(void) = (bool8 (*)(void))ScriptReadWord(ctx); + SetupNativeScript(ctx, func); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_special) +{ + u16 (*const *specialPtr)(void) = gSpecials + ScriptReadHalfword(ctx); + if (specialPtr < gSpecialsEnd) + (*specialPtr)(); + else + AGB_ASSERT_EX(0, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/scrcmd.c", 241); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_specialvar) +{ + u16 * varPtr = GetVarPointer(ScriptReadHalfword(ctx)); + u16 (*const *specialPtr)(void) = gSpecials + ScriptReadHalfword(ctx); + if (specialPtr < gSpecialsEnd) + *varPtr = (*specialPtr)(); + else + AGB_ASSERT_EX(0, "C:/WORK/POKeFRLG/src/pm_lgfr_ose/source/scrcmd.c", 263); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_callnative) +{ + void (*func )(void) = ((void (*)(void))ScriptReadWord(ctx)); + func(); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_waitstate) +{ + ScriptContext1_Stop(); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_goto) +{ + const u8 * scrptr = (const u8 *)ScriptReadWord(ctx); + ScriptJump(ctx, scrptr); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_return) +{ + ScriptReturn(ctx); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_call) +{ + const u8 * scrptr = (const u8 *)ScriptReadWord(ctx); + ScriptCall(ctx, scrptr); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_goto_if) +{ + u8 condition = ScriptReadByte(ctx); + const u8 * scrptr = (const u8 *)ScriptReadWord(ctx); + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) + ScriptJump(ctx, scrptr); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_call_if) +{ + u8 condition = ScriptReadByte(ctx); + const u8 * scrptr = (const u8 *)ScriptReadWord(ctx); + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) + ScriptCall(ctx, scrptr); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setvaddress) +{ + u32 addr1 = (u32)ctx->scriptPtr - 1; + u32 addr2 = ScriptReadWord(ctx); + + gVScriptOffset = addr2 - addr1; + return FALSE; +} + +SCRCMD_DEF(ScrCmd_vgoto) +{ + const u8 * scrptr = (const u8 *)ScriptReadWord(ctx); + ScriptJump(ctx, scrptr - gVScriptOffset); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_vcall) +{ + const u8 * scrptr = (const u8 *)ScriptReadWord(ctx); + ScriptCall(ctx, scrptr - gVScriptOffset); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_vgoto_if) +{ + u8 condition = ScriptReadByte(ctx); + const u8 * scrptr = (const u8 *)ScriptReadWord(ctx) - gVScriptOffset; + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) + ScriptJump(ctx, scrptr); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_vcall_if) +{ + u8 condition = ScriptReadByte(ctx); + const u8 * scrptr = (const u8 *)ScriptReadWord(ctx) - gVScriptOffset; + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) + ScriptCall(ctx, scrptr); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_gotostd) +{ + u8 stdIdx = ScriptReadByte(ctx); + const u8 *const * script = gStdScripts + stdIdx; + if (script < gStdScriptsEnd) + ScriptJump(ctx, *script); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_callstd) +{ + u8 stdIdx = ScriptReadByte(ctx); + const u8 *const * script = gStdScripts + stdIdx; + if (script < gStdScriptsEnd) + ScriptCall(ctx, *script); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_gotostd_if) +{ + u8 condition = ScriptReadByte(ctx); + u8 stdIdx = ScriptReadByte(ctx); + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) + { + const u8 *const * script = gStdScripts + stdIdx; + if (script < gStdScriptsEnd) + ScriptJump(ctx, *script); + } + return FALSE; +} + +SCRCMD_DEF(ScrCmd_callstd_if) +{ + u8 condition = ScriptReadByte(ctx); + u8 stdIdx = ScriptReadByte(ctx); + if (sScriptConditionTable[condition][ctx->comparisonResult] == 1) + { + const u8 *const * script = gStdScripts + stdIdx; + if (script < gStdScriptsEnd) + ScriptCall(ctx, *script); + } + return FALSE; +} + +u8 * const sScriptStringVars[] = +{ + gStringVar1, + gStringVar2, + gStringVar3, +}; -- cgit v1.2.3 From d2538cffa03a21aca4e116971a7eb8b760f98ce0 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 6 Jan 2019 07:54:57 -0500 Subject: through ScrCmd_copyvar --- src/scrcmd.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/script.c | 6 ++-- 2 files changed, 99 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index bb8d969c1..20f1dbc3b 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1,6 +1,7 @@ #include "global.h" #include "gba/isagbprint.h" #include "script.h" +#include "mystery_event_script.h" #include "event_data.h" extern u16 (*const gSpecials[])(void); @@ -215,6 +216,101 @@ SCRCMD_DEF(ScrCmd_callstd_if) return FALSE; } +SCRCMD_DEF(ScrCmd_gotoram) +{ + ScriptJump(ctx, gRAMScriptPtr); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_killscript) +{ + ClearRamScript(); + StopScript(ctx); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_setmysteryeventstatus) +{ + SetMysteryEventScriptStatus(ScriptReadByte(ctx)); + return FALSE; +} + +SCRCMD_DEF(sub_806A28C) +{ + const u8 * script = sub_8069E48(); + if (script != NULL) + { + gRAMScriptPtr = ctx->scriptPtr; + ScriptJump(ctx, script); + } + return FALSE; +} + +SCRCMD_DEF(ScrCmd_loadword) +{ + u8 which = ScriptReadByte(ctx); + ctx->data[which] = ScriptReadWord(ctx); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_loadbytefromaddr) +{ + u8 which = ScriptReadByte(ctx); + ctx->data[which] = *(const u8 *)ScriptReadWord(ctx); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_writebytetoaddr) +{ + u8 value = ScriptReadByte(ctx); + *(u8 *)ScriptReadWord(ctx) = value; + return FALSE; +} + +SCRCMD_DEF(ScrCmd_loadbyte) +{ + u8 which = ScriptReadByte(ctx); + ctx->data[which] = ScriptReadByte(ctx); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setptrbyte) +{ + u8 which = ScriptReadByte(ctx); + *(u8 *)ScriptReadWord(ctx) = ctx->data[which]; + return FALSE; +} + +SCRCMD_DEF(ScrCmd_copylocal) +{ + u8 whichDst = ScriptReadByte(ctx); + u8 whichSrc = ScriptReadByte(ctx); + ctx->data[whichDst] = ctx->data[whichSrc]; + return FALSE; +} + +SCRCMD_DEF(ScrCmd_copybyte) +{ + u8 * dest = (u8 *)ScriptReadWord(ctx); + *dest = *(const u8 *)ScriptReadWord(ctx); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setvar) +{ + u16 * varPtr = GetVarPointer(ScriptReadHalfword(ctx)); + *varPtr = ScriptReadHalfword(ctx); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_copyvar) +{ + u16 * destPtr = GetVarPointer(ScriptReadHalfword(ctx)); + u16 * srcPtr = GetVarPointer(ScriptReadHalfword(ctx)); + *destPtr = *srcPtr; + return FALSE; +} + u8 * const sScriptStringVars[] = { gStringVar1, diff --git a/src/script.c b/src/script.c index 59ef4e579..d7246752c 100644 --- a/src/script.c +++ b/src/script.c @@ -19,7 +19,7 @@ enum }; EWRAM_DATA u8 gUnknown_20370A0 = 0; -EWRAM_DATA u8 *gUnknown_20370A4 = NULL; +EWRAM_DATA const u8 *gRAMScriptPtr = NULL; // ewram bss /*IWRAM_DATA*/ static u8 sScriptContext1Status; @@ -485,7 +485,7 @@ bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objec u8 *GetRamScript(u8 objectId, u8 *script) { struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data; - gUnknown_20370A4 = NULL; + gRAMScriptPtr = NULL; if (scriptData->magic != RAM_SCRIPT_MAGIC) return script; if (scriptData->mapGroup != gSaveBlock1Ptr->location.mapGroup) @@ -501,7 +501,7 @@ u8 *GetRamScript(u8 objectId, u8 *script) } else { - gUnknown_20370A4 = script; + gRAMScriptPtr = script; return scriptData->script; } } -- cgit v1.2.3 From 1cb1fd2bf8416821a897fbc6b5a60c60595b4a7b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 6 Jan 2019 10:09:03 -0500 Subject: through ScrCmd_checkdecor --- src/scrcmd.c | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index 20f1dbc3b..9802791bf 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -3,6 +3,8 @@ #include "script.h" #include "mystery_event_script.h" #include "event_data.h" +#include "random.h" +#include "item.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); @@ -311,9 +313,218 @@ SCRCMD_DEF(ScrCmd_copyvar) return FALSE; } +SCRCMD_DEF(ScrCmd_setorcopyvar) +{ + u16 * destPtr = GetVarPointer(ScriptReadHalfword(ctx)); + *destPtr = VarGet(ScriptReadHalfword(ctx)); + return FALSE; +} + u8 * const sScriptStringVars[] = { gStringVar1, gStringVar2, gStringVar3, }; + +u8 compare_012(u16 left, u16 right) +{ + if (left < right) + return 0; + else if (left == right) + return 1; + else + return 2; +} + +// comparelocaltolocal +SCRCMD_DEF(ScrCmd_compare_local_to_local) +{ + const u8 value1 = ctx->data[ScriptReadByte(ctx)]; + const u8 value2 = ctx->data[ScriptReadByte(ctx)]; + + ctx->comparisonResult = compare_012(value1, value2); + return FALSE; +} + +// comparelocaltoimm +SCRCMD_DEF(ScrCmd_compare_local_to_value) +{ + const u8 value1 = ctx->data[ScriptReadByte(ctx)]; + const u8 value2 = ScriptReadByte(ctx); + + ctx->comparisonResult = compare_012(value1, value2); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_compare_local_to_addr) +{ + const u8 value1 = ctx->data[ScriptReadByte(ctx)]; + const u8 value2 = *(const u8 *)ScriptReadWord(ctx); + + ctx->comparisonResult = compare_012(value1, value2); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_compare_addr_to_local) +{ + const u8 value1 = *(const u8 *)ScriptReadWord(ctx); + const u8 value2 = ctx->data[ScriptReadByte(ctx)]; + + ctx->comparisonResult = compare_012(value1, value2); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_compare_addr_to_value) +{ + const u8 value1 = *(const u8 *)ScriptReadWord(ctx); + const u8 value2 = ScriptReadByte(ctx); + + ctx->comparisonResult = compare_012(value1, value2); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_compare_addr_to_addr) +{ + const u8 value1 = *(const u8 *)ScriptReadWord(ctx); + const u8 value2 = *(const u8 *)ScriptReadWord(ctx); + + ctx->comparisonResult = compare_012(value1, value2); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_compare_var_to_value) +{ + const u16 value1 = *GetVarPointer(ScriptReadHalfword(ctx)); + const u16 value2 = ScriptReadHalfword(ctx); + + ctx->comparisonResult = compare_012(value1, value2); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_compare_var_to_var) +{ + const u16 *ptr1 = GetVarPointer(ScriptReadHalfword(ctx)); + const u16 *ptr2 = GetVarPointer(ScriptReadHalfword(ctx)); + + ctx->comparisonResult = compare_012(*ptr1, *ptr2); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_addvar) +{ + u16 *ptr = GetVarPointer(ScriptReadHalfword(ctx)); + *ptr += ScriptReadHalfword(ctx); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_subvar) +{ + u16 *ptr = GetVarPointer(ScriptReadHalfword(ctx)); + *ptr -= VarGet(ScriptReadHalfword(ctx)); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_random) +{ + u16 max = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = Random() % max; + return FALSE; +} + +SCRCMD_DEF(ScrCmd_giveitem) +{ + u16 itemId = VarGet(ScriptReadHalfword(ctx)); + u32 quantity = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = AddBagItem(itemId, (u8)quantity); + sub_809A824(itemId); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_takeitem) +{ + u16 itemId = VarGet(ScriptReadHalfword(ctx)); + u32 quantity = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = RemoveBagItem(itemId, (u8)quantity); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_checkitemspace) +{ + u16 itemId = VarGet(ScriptReadHalfword(ctx)); + u32 quantity = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = CheckBagHasSpace(itemId, (u8)quantity); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_checkitem) +{ + u16 itemId = VarGet(ScriptReadHalfword(ctx)); + u32 quantity = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = CheckBagHasItem(itemId, (u8)quantity); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_checkitemtype) +{ + u16 itemId = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = GetPocketByItemId(itemId); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_givepcitem) +{ + u16 itemId = VarGet(ScriptReadHalfword(ctx)); + u16 quantity = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = AddPCItem(itemId, quantity); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_checkpcitem) +{ + u16 itemId = VarGet(ScriptReadHalfword(ctx)); + u16 quantity = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = CheckPCHasItem(itemId, quantity); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_givedecoration) +{ + u32 decorId = VarGet(ScriptReadHalfword(ctx)); + +// gSpecialVar_Result = DecorationAdd(decorId); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_takedecoration) +{ + u32 decorId = VarGet(ScriptReadHalfword(ctx)); + +// gSpecialVar_Result = DecorationRemove(decorId); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_checkdecorspace) +{ + u32 decorId = VarGet(ScriptReadHalfword(ctx)); + +// gSpecialVar_Result = DecorationCheckSpace(decorId); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_checkdecor) +{ + u32 decorId = VarGet(ScriptReadHalfword(ctx)); + +// gSpecialVar_Result = CheckHasDecoration(decorId); + return FALSE; +} + -- cgit v1.2.3 From 257bde9b08e907b59aed05d662a1d8daed8d79fa Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 6 Jan 2019 10:22:04 -0500 Subject: through ScrCmd_fadescreenspeed --- src/scrcmd.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index 9802791bf..c8e7babcc 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1,10 +1,16 @@ #include "global.h" #include "gba/isagbprint.h" +#include "palette.h" #include "script.h" #include "mystery_event_script.h" #include "event_data.h" #include "random.h" #include "item.h" +#include "overworld.h" +#include "field_screen_effect.h" +#include "quest_log.h" +#include "map_preview_screen.h" +#include "field_weather.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); @@ -528,3 +534,89 @@ SCRCMD_DEF(ScrCmd_checkdecor) return FALSE; } +SCRCMD_DEF(ScrCmd_setflag) +{ + FlagSet(ScriptReadHalfword(ctx)); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_clearflag) +{ + FlagClear(ScriptReadHalfword(ctx)); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_checkflag) +{ + ctx->comparisonResult = FlagGet(ScriptReadHalfword(ctx)); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_incrementgamestat) +{ + IncrementGameStat(ScriptReadByte(ctx)); + return FALSE; +} + +SCRCMD_DEF(sub_806A888) +{ + u8 statIdx = ScriptReadByte(ctx); + u32 value = ScriptReadWord(ctx); + u32 statValue = GetGameStat(statIdx); + + if (statValue < value) + ctx ->comparisonResult = 0; + else if (statValue == value) + ctx->comparisonResult = 1; + else + ctx->comparisonResult = 2; + return FALSE; +} + +SCRCMD_DEF(sub_806A8C0) +{ + u16 value = ScriptReadHalfword(ctx); + sub_8115748(value); + sub_80F85BC(value); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_animateflash) +{ + sub_807F028(ScriptReadByte(ctx)); + ScriptContext1_Stop(); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_setflashradius) +{ + u16 flashLevel = VarGet(ScriptReadHalfword(ctx)); + + Overworld_SetFlashLevel(flashLevel); + return FALSE; +} + +static bool8 IsPaletteNotActive(void) +{ + if (!gPaletteFade.active) + return TRUE; + else + return FALSE; +} + +SCRCMD_DEF(ScrCmd_fadescreen) +{ + fade_screen(ScriptReadByte(ctx), 0); + SetupNativeScript(ctx, IsPaletteNotActive); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_fadescreenspeed) +{ + u8 mode = ScriptReadByte(ctx); + u8 speed = ScriptReadByte(ctx); + + fade_screen(mode, speed); + SetupNativeScript(ctx, IsPaletteNotActive); + return TRUE; +} -- cgit v1.2.3 From b16831e97bb8b94c29854a81e11647e8a5db68c6 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 6 Jan 2019 11:57:00 -0500 Subject: through ScrCmd_fadeinbgm --- src/scrcmd.c | 348 +++++++++++++++++++++++++++++++++++++++++++++++++++- src/trainer_tower.c | 4 +- 2 files changed, 349 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index c8e7babcc..8b9551c64 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -11,6 +11,10 @@ #include "quest_log.h" #include "map_preview_screen.h" #include "field_weather.h" +#include "field_tasks.h" +#include "field_fadetransition.h" +#include "field_player_avatar.h" +#include "sound.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); @@ -19,7 +23,7 @@ extern const u8 *const gStdScriptsEnd[]; EWRAM_DATA ptrdiff_t gVScriptOffset = 0; EWRAM_DATA u8 gUnknown_20370AC = 0; -EWRAM_DATA u16 gUnknown_20370AE = 0; +EWRAM_DATA u16 sPauseCounter = 0; EWRAM_DATA u16 gUnknown_20370B0 = 0; EWRAM_DATA u16 gUnknown_20370B2 = 0; EWRAM_DATA u16 gUnknown_20370B4 = 0; @@ -620,3 +624,345 @@ SCRCMD_DEF(ScrCmd_fadescreenspeed) SetupNativeScript(ctx, IsPaletteNotActive); return TRUE; } + +static bool8 RunPauseTimer(void) +{ + sPauseCounter--; + + if (sPauseCounter == 0) + return TRUE; + else + return FALSE; +} + +SCRCMD_DEF(ScrCmd_delay) +{ + sPauseCounter = ScriptReadHalfword(ctx); + SetupNativeScript(ctx, RunPauseTimer); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_initclock) +{ +// u8 hour = VarGet(ScriptReadHalfword(ctx)); +// u8 minute = VarGet(ScriptReadHalfword(ctx)); +// +// RtcInitLocalTimeOffset(hour, minute); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_dodailyevents) +{ +// DoTimeBasedEvents(); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_gettime) +{ +// RtcCalcLocalTime(); +// gSpecialVar_0x8000 = gLocalTime.hours; +// gSpecialVar_0x8001 = gLocalTime.minutes; +// gSpecialVar_0x8002 = gLocalTime.seconds; + gSpecialVar_0x8000 = 0; + gSpecialVar_0x8001 = 0; + gSpecialVar_0x8002 = 0; + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setweather) +{ + u16 weather = VarGet(ScriptReadHalfword(ctx)); + + SetSav1Weather(weather); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_resetweather) +{ + SetSav1WeatherFromCurrMapHeader(); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_doweather) +{ + DoCurrentWeather(); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setstepcallback) +{ + ActivatePerStepCallback(ScriptReadByte(ctx)); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setmaplayoutindex) +{ + u16 value = VarGet(ScriptReadHalfword(ctx)); + + SetCurrentMapLayout(value); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_warp) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + DoWarp(); + ResetInitialPlayerAvatarState(); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_warpsilent) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + DoDiveWarp(); + ResetInitialPlayerAvatarState(); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_warpdoor) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + DoDoorWarp(); + ResetInitialPlayerAvatarState(); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_warphole) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u16 x; + u16 y; + + PlayerGetDestCoords(&x, &y); + if (mapGroup == 0xFF && mapNum == 0xFF) + SetWarpDestinationToFixedHoleWarp(x - 7, y - 7); + else + Overworld_SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7); + DoFallWarp(); + ResetInitialPlayerAvatarState(); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_warpteleport) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + sub_807E59C(); + ResetInitialPlayerAvatarState(); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_warpD7) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + sub_805DAE4(player_get_direction_lower_nybble()); + sub_807E500(); + ResetInitialPlayerAvatarState(); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_setwarp) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + Overworld_SetWarpDestination(mapGroup, mapNum, warpId, x, y); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setdynamicwarp) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + SetDynamicWarpWithCoords(0, mapGroup, mapNum, warpId, x, y); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setdivewarp) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + SetFixedDiveWarp(mapGroup, mapNum, warpId, x, y); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setholewarp) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + SetFixedHoleWarp(mapGroup, mapNum, warpId, x, y); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setescapewarp) +{ + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 warpId = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + SetEscapeWarp(mapGroup, mapNum, warpId, x, y); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_getplayerxy) +{ + u16 *pX = GetVarPointer(ScriptReadHalfword(ctx)); + u16 *pY = GetVarPointer(ScriptReadHalfword(ctx)); + + *pX = gSaveBlock1Ptr->pos.x; + *pY = gSaveBlock1Ptr->pos.y; + return FALSE; +} + +SCRCMD_DEF(ScrCmd_getpartysize) +{ + gSpecialVar_Result = CalculatePlayerPartyCount(); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_playse) +{ + PlaySE(ScriptReadHalfword(ctx)); + return FALSE; +} + +static bool8 WaitForSoundEffectFinish(void) +{ + if (!IsSEPlaying()) + return TRUE; + else + return FALSE; +} + +SCRCMD_DEF(ScrCmd_waitse) +{ + SetupNativeScript(ctx, WaitForSoundEffectFinish); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_playfanfare) +{ + PlayFanfare(ScriptReadHalfword(ctx)); + return FALSE; +} + +static bool8 WaitForFanfareFinish(void) +{ + return IsFanfareTaskInactive(); +} + +SCRCMD_DEF(ScrCmd_waitfanfare) +{ + SetupNativeScript(ctx, WaitForFanfareFinish); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_playbgm) +{ + u16 songId = ScriptReadHalfword(ctx); + bool8 val = ScriptReadByte(ctx); + + if (gUnknown_203ADFA == 2 || gUnknown_203ADFA == 3) + return FALSE; + if (val == TRUE) + Overworld_SetSavedMusic(songId); + PlayNewMapMusic(songId); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_savebgm) +{ + Overworld_SetSavedMusic(ScriptReadHalfword(ctx)); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_fadedefaultbgm) +{ + if (gUnknown_203ADFA == 2 || gUnknown_203ADFA == 3) + return FALSE; + Overworld_ChangeMusicToDefault(); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_fadenewbgm) +{ + u16 music = ScriptReadHalfword(ctx); + if (gUnknown_203ADFA == 2 || gUnknown_203ADFA == 3) + return FALSE; + Overworld_ChangeMusicTo(music); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_fadeoutbgm) +{ + u8 speed = ScriptReadByte(ctx); + + if (gUnknown_203ADFA == 2 || gUnknown_203ADFA == 3) + return FALSE; + if (speed != 0) + FadeOutBGMTemporarily(4 * speed); + else + FadeOutBGMTemporarily(4); + SetupNativeScript(ctx, IsBGMPausedOrStopped); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_fadeinbgm) +{ + u8 speed = ScriptReadByte(ctx); + + if (gUnknown_203ADFA == 2 || gUnknown_203ADFA == 3) + return FALSE; + if (speed != 0) + FadeInBGM(4 * speed); + else + FadeInBGM(4); + return FALSE; +} diff --git a/src/trainer_tower.c b/src/trainer_tower.c index 91132c07b..74065445a 100644 --- a/src/trainer_tower.c +++ b/src/trainer_tower.c @@ -430,12 +430,12 @@ void sub_815DD44(void) if (gMapHeader.mapDataId - 0x129 > gUnknown_203F458->unk_0004.unk_0000.unk0) { gSpecialVar_Result = 3; - sub_8055D40(0x132); + SetCurrentMapLayout(0x132); } else { gSpecialVar_Result = gUnknown_203F458->unk_0004.unk_0008[gUnknown_203F458->unk_0000].unk_002; - sub_8055D40(gUnknown_847A284[gUnknown_203F458->unk_0000][gSpecialVar_Result]); + SetCurrentMapLayout(gUnknown_847A284[gUnknown_203F458->unk_0000][gSpecialVar_Result]); sub_815DDB0(); } } -- cgit v1.2.3 From 96e1b19dc1ea9dbf686fd26743d79c68d12e0f24 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 6 Jan 2019 13:06:56 -0500 Subject: through ScrCmd_release; propose names for remaining funcs --- src/scrcmd.c | 293 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/vs_seeker.c | 4 +- 2 files changed, 288 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index 8b9551c64..ce1519b94 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -15,6 +15,11 @@ #include "field_fadetransition.h" #include "field_player_avatar.h" #include "sound.h" +#include "script_movement.h" +#include "field_map_obj.h" +#include "field_map_obj_helpers.h" +#include "map_obj_lock.h" +#include "field_message_box.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); @@ -24,11 +29,13 @@ extern const u8 *const gStdScriptsEnd[]; EWRAM_DATA ptrdiff_t gVScriptOffset = 0; EWRAM_DATA u8 gUnknown_20370AC = 0; EWRAM_DATA u16 sPauseCounter = 0; -EWRAM_DATA u16 gUnknown_20370B0 = 0; -EWRAM_DATA u16 gUnknown_20370B2 = 0; -EWRAM_DATA u16 gUnknown_20370B4 = 0; +EWRAM_DATA u16 sMovingNpcId = 0; +EWRAM_DATA u16 sMovingNpcMapBank = 0; +EWRAM_DATA u16 sMovingNpcMapId = 0; EWRAM_DATA u16 gUnknown_20370B6 = 0; +extern u8 gSelectedEventObject; + // This is defined in here so the optimizer can't see its value when compiling // script.c. void * const gNullScriptPtr = NULL; @@ -247,7 +254,7 @@ SCRCMD_DEF(ScrCmd_setmysteryeventstatus) return FALSE; } -SCRCMD_DEF(sub_806A28C) +SCRCMD_DEF(ScrCmd_cmdCF) { const u8 * script = sub_8069E48(); if (script != NULL) @@ -562,7 +569,7 @@ SCRCMD_DEF(ScrCmd_incrementgamestat) return FALSE; } -SCRCMD_DEF(sub_806A888) +SCRCMD_DEF(ScrCmd_comparestattoword) { u8 statIdx = ScriptReadByte(ctx); u32 value = ScriptReadWord(ctx); @@ -577,7 +584,7 @@ SCRCMD_DEF(sub_806A888) return FALSE; } -SCRCMD_DEF(sub_806A8C0) +SCRCMD_DEF(ScrCmd_cmdD0) { u16 value = ScriptReadHalfword(ctx); sub_8115748(value); @@ -776,7 +783,7 @@ SCRCMD_DEF(ScrCmd_warpteleport) return TRUE; } -SCRCMD_DEF(ScrCmd_warpD7) +SCRCMD_DEF(ScrCmd_warpD1) { u8 mapGroup = ScriptReadByte(ctx); u8 mapNum = ScriptReadByte(ctx); @@ -966,3 +973,275 @@ SCRCMD_DEF(ScrCmd_fadeinbgm) FadeInBGM(4); return FALSE; } + +SCRCMD_DEF(ScrCmd_applymovement) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + const void *movementScript = (const void *)ScriptReadWord(ctx); + + ScriptMovement_StartObjectMovementScript(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, movementScript); + sMovingNpcId = localId; + return FALSE; +} + +SCRCMD_DEF(ScrCmd_applymovement_at) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + const void *movementScript = (const void *)ScriptReadWord(ctx); + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + + ScriptMovement_StartObjectMovementScript(localId, mapNum, mapGroup, movementScript); + sMovingNpcId = localId; + return FALSE; +} + +static bool8 WaitForMovementFinish(void) +{ + return ScriptMovement_IsObjectMovementFinished(sMovingNpcId, sMovingNpcMapId, sMovingNpcMapBank); +} + +SCRCMD_DEF(ScrCmd_waitmovement) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + + if (localId != 0) + sMovingNpcId = localId; + sMovingNpcMapBank = gSaveBlock1Ptr->location.mapGroup; + sMovingNpcMapId = gSaveBlock1Ptr->location.mapNum; + SetupNativeScript(ctx, WaitForMovementFinish); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_waitmovement_at) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + u8 mapBank; + u8 mapId; + + if (localId != 0) + sMovingNpcId = localId; + mapBank = ScriptReadByte(ctx); + mapId = ScriptReadByte(ctx); + sMovingNpcMapBank = mapBank; + sMovingNpcMapId = mapId; + SetupNativeScript(ctx, WaitForMovementFinish); + return TRUE; +} + +SCRCMD_DEF(ScrCmd_removeobject) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + + RemoveFieldObjectByLocalIdAndMap(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_removeobject_at) +{ + u16 objectId = VarGet(ScriptReadHalfword(ctx)); + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + + RemoveFieldObjectByLocalIdAndMap(objectId, mapNum, mapGroup); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_addobject) +{ + u16 objectId = VarGet(ScriptReadHalfword(ctx)); + + show_sprite(objectId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_addobject_at) +{ + u16 objectId = VarGet(ScriptReadHalfword(ctx)); + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + + show_sprite(objectId, mapNum, mapGroup); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setobjectxy) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + sub_805F7C4(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, x, y); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setobjectxyperm) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + Overworld_SetMapObjTemplateCoords(localId, x, y); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_moveobjectoffscreen) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + + sub_805FE94(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_showobject_at) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + + npc_by_local_id_and_map_set_field_1_bit_x20(localId, mapNum, mapGroup, 0); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_hideobject_at) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + + npc_by_local_id_and_map_set_field_1_bit_x20(localId, mapNum, mapGroup, 1); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setobjectpriority) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + u8 priority = ScriptReadByte(ctx); + + sub_805F3A8(localId, mapNum, mapGroup, priority + 83); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_resetobjectpriority) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + u8 mapGroup = ScriptReadByte(ctx); + u8 mapNum = ScriptReadByte(ctx); + + sub_805F400(localId, mapNum, mapGroup); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_faceplayer) +{ + if (gMapObjects[gSelectedEventObject].active) + { + FieldObjectFaceOppositeDirection(&gMapObjects[gSelectedEventObject], + player_get_direction_lower_nybble()); + } + return FALSE; +} + +SCRCMD_DEF(ScrCmd_turnobject) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + u8 direction = ScriptReadByte(ctx); + + FieldObjectTurnByLocalIdAndMap(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, direction); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_setobjectmovementtype) +{ + u16 localId = VarGet(ScriptReadHalfword(ctx)); + u8 movementType = ScriptReadByte(ctx); + + Overworld_SetMapObjTemplateMovementType(localId, movementType); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_createvobject) +{ + u8 graphicsId = ScriptReadByte(ctx); + u8 v2 = ScriptReadByte(ctx); + u16 x = VarGet(ScriptReadHalfword(ctx)); + u32 y = VarGet(ScriptReadHalfword(ctx)); + u8 elevation = ScriptReadByte(ctx); + u8 direction = ScriptReadByte(ctx); + + sprite_new(graphicsId, v2, x, y, elevation, direction); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_turnvobject) +{ + u8 v1 = ScriptReadByte(ctx); + u8 direction = ScriptReadByte(ctx); + + sub_8069058(v1, direction); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_lockall) +{ + if (is_c1_link_related_active()) + { + return FALSE; + } + else + { + ScriptFreezeMapObjects(); + SetupNativeScript(ctx, sub_8069590); + return TRUE; + } +} + +SCRCMD_DEF(ScrCmd_lock) +{ + if (is_c1_link_related_active()) + { + return FALSE; + } + else + { + if (gMapObjects[gSelectedEventObject].active) + { + LockSelectedMapObject(); + SetupNativeScript(ctx, sub_8069648); + } + else + { + ScriptFreezeMapObjects(); + SetupNativeScript(ctx, sub_8069590); + } + return TRUE; + } +} + +SCRCMD_DEF(ScrCmd_releaseall) +{ + u8 playerObjectId; + + HideFieldMessageBox(); + playerObjectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[playerObjectId]); + sub_80974D8(); + UnfreezeMapObjects(); + return FALSE; +} + +SCRCMD_DEF(ScrCmd_release) +{ + u8 playerObjectId; + + HideFieldMessageBox(); + if (gMapObjects[gSelectedEventObject].active) + FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[gSelectedEventObject]); + playerObjectId = GetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0); + FieldObjectClearAnimIfSpecialAnimFinished(&gMapObjects[playerObjectId]); + sub_80974D8(); + UnfreezeMapObjects(); + return FALSE; +} diff --git a/src/vs_seeker.c b/src/vs_seeker.c index 4d42f270d..579800576 100644 --- a/src/vs_seeker.c +++ b/src/vs_seeker.c @@ -65,7 +65,7 @@ struct VsSeekerStruct extern u16 gSpecialVar_LastTalked; extern struct MapObject gMapObjects[MAP_OBJECTS_COUNT]; -extern u8 gUnknown_3005074; +extern u8 gSelectedEventObject; // static declarations static EWRAM_DATA struct VsSeekerStruct *sVsSeeker = NULL; @@ -1012,7 +1012,7 @@ void sub_810CB90(void) sub_810CF54(&r4[r8]); // You are using this function incorrectly. Please consult the manual. sub_805FE7C(r4_2, gUnknown_8453F67[r4_2->mapobj_unk_18]); gSaveBlock1Ptr->trainerRematches[r4[r8].localId] = 0; - if (gUnknown_3005074 == sp0) + if (gSelectedEventObject == sp0) r4_2->animPattern = gUnknown_8453F67[r4_2->mapobj_unk_18]; else r4_2->animPattern = 0x08; -- cgit v1.2.3 From 607d6e13d4378ea6530f03d2c290ddd30506aa14 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 6 Jan 2019 14:52:00 -0500 Subject: ScrCmd_waitbuttonpress --- src/scrcmd.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index 4cd0fdad2..976b80564 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -20,6 +20,9 @@ #include "field_map_obj_helpers.h" #include "map_obj_lock.h" #include "field_message_box.h" +#include "new_menu_helpers.h" +#include "window.h" +#include "start_menu.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); @@ -1252,3 +1255,155 @@ SCRCMD_DEF(cmdC7) gUnknown_20370DA = ScriptReadByte(ctx); return FALSE; } + +SCRCMD_DEF(message) +{ + const u8 *msg = (const u8 *)ScriptReadWord(ctx); + + if (msg == NULL) + msg = (const u8 *)ctx->data[0]; + ShowFieldMessage(msg); + return FALSE; +} + +SCRCMD_DEF(cmdC8) +{ + const u8 *msg = (const u8 *)ScriptReadWord(ctx); + + if (msg == NULL) + msg = (const u8 *)ctx->data[0]; + sub_80F7974(msg); + CopyWindowToVram(GetStartMenuWindowId(), 1); + return FALSE; +} + +SCRCMD_DEF(cmdC9) +{ + sub_80F7998(); + return FALSE; +} + +SCRCMD_DEF(messageautoscroll) +{ + const u8 *msg = (const u8 *)ScriptReadWord(ctx); + + if (msg == NULL) + msg = (const u8 *)ctx->data[0]; + ShowFieldAutoScrollMessage(msg); + return FALSE; +} + +SCRCMD_DEF(waitmessage) +{ + SetupNativeScript(ctx, IsFieldMessageBoxHidden); + return TRUE; +} + +SCRCMD_DEF(closemessage) +{ + HideFieldMessageBox(); + return FALSE; +} + +extern IWRAM_DATA struct ScriptContext * gUnknown_3005070; + +bool8 sub_806B93C(struct ScriptContext * ctx); +u8 sub_806B96C(struct ScriptContext * ctx); + +bool8 WaitForAorBPress(void) +{ + if (gMain.newKeys & A_BUTTON) + return TRUE; + if (gMain.newKeys & B_BUTTON) + return TRUE; + + if (sub_806B93C(gUnknown_3005070) == TRUE) + { + u8 r4 = sub_806B96C(gUnknown_3005070); + sub_8069998(r4); + if (r4) + { + if (gUnknown_203ADFA != 2) + { + sub_80699F8(); + if (r4 < 9 || r4 > 10) + sub_8069964(); + else + { + sub_80699A4(); + sub_8069970(); + } + return TRUE; + } + } + } + if (sub_8112CAC() == 1 || gUnknown_203ADFA == 2) + { + if (gUnknown_20370AC == 120) + return TRUE; + else + gUnknown_20370AC++; + } + + return FALSE; +} + +bool8 sub_806B93C(struct ScriptContext * ctx) +{ + const u8 * script = ctx->scriptPtr; + u8 nextCmd = *script; + if (nextCmd == 3) // return + { + script = ctx->stack[ctx->stackDepth - 1]; + nextCmd = *script; + } + if (nextCmd < 0x6B || nextCmd > 0x6C) // releaseall or release + return FALSE; + else + return TRUE; +} + +u8 sub_806B96C(struct ScriptContext * ctx) +{ + if (gMain.heldKeys & DPAD_UP && gSpecialVar_Facing != 2) + return 1; + + if (gMain.heldKeys & DPAD_DOWN && gSpecialVar_Facing != 1) + return 2; + + if (gMain.heldKeys & DPAD_LEFT && gSpecialVar_Facing != 3) + return 3; + + if (gMain.heldKeys & DPAD_RIGHT && gSpecialVar_Facing != 4) + return 4; + + if (gMain.newKeys & L_BUTTON) + return 5; + + if (gMain.heldKeys & R_BUTTON) + return 6; + + if (gMain.heldKeys & START_BUTTON) + return 7; + + if (gMain.heldKeys & SELECT_BUTTON) + return 8; + + if (gMain.newKeys & A_BUTTON) + return 9; + + if (gMain.newKeys & B_BUTTON) + return 10; + + return 0; +} + +SCRCMD_DEF(waitbuttonpress) +{ + gUnknown_3005070 = ctx; + + if (sub_8112CAC() == 1 || gUnknown_203ADFA == 2) + gUnknown_20370AC = 0; + SetupNativeScript(ctx, WaitForAorBPress); + return TRUE; +} -- cgit v1.2.3 From 6a064a4fa4bedaa1e46470645e175ba7d11a2e41 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 6 Jan 2019 15:08:17 -0500 Subject: Through ScrCmd_getbraillestringwidth --- src/scrcmd.c | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index 976b80564..c77dda666 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -23,6 +23,7 @@ #include "new_menu_helpers.h" #include "window.h" #include "start_menu.h" +#include "script_menu.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); @@ -1407,3 +1408,170 @@ SCRCMD_DEF(waitbuttonpress) SetupNativeScript(ctx, WaitForAorBPress); return TRUE; } + +SCRCMD_DEF(yesnobox) +{ + u8 left = ScriptReadByte(ctx); + u8 top = ScriptReadByte(ctx); + + if (ScriptMenu_YesNo(left, top) == TRUE) + { + ScriptContext1_Stop(); + return TRUE; + } + else + { + return FALSE; + } +} + +SCRCMD_DEF(multichoice) +{ + u8 left = ScriptReadByte(ctx); + u8 top = ScriptReadByte(ctx); + u8 multichoiceId = ScriptReadByte(ctx); + u8 ignoreBPress = ScriptReadByte(ctx); + + if (ScriptMenu_Multichoice(left, top, multichoiceId, ignoreBPress) == TRUE) + { + ScriptContext1_Stop(); + return TRUE; + } + else + { + return FALSE; + } +} + +SCRCMD_DEF(multichoicedefault) +{ + u8 left = ScriptReadByte(ctx); + u8 top = ScriptReadByte(ctx); + u8 multichoiceId = ScriptReadByte(ctx); + u8 defaultChoice = ScriptReadByte(ctx); + u8 ignoreBPress = ScriptReadByte(ctx); + + if (ScriptMenu_MultichoiceWithDefault(left, top, multichoiceId, ignoreBPress, defaultChoice) == TRUE) + { + ScriptContext1_Stop(); + return TRUE; + } + else + { + return FALSE; + } +} + +SCRCMD_DEF(drawbox) +{ + /*u8 left = ScriptReadByte(ctx); + u8 top = ScriptReadByte(ctx); + u8 right = ScriptReadByte(ctx); + u8 bottom = ScriptReadByte(ctx); + + MenuDrawTextWindow(left, top, right, bottom);*/ + return FALSE; +} + +SCRCMD_DEF(multichoicegrid) +{ + u8 left = ScriptReadByte(ctx); + u8 top = ScriptReadByte(ctx); + u8 multichoiceId = ScriptReadByte(ctx); + u8 numColumns = ScriptReadByte(ctx); + u8 ignoreBPress = ScriptReadByte(ctx); + + if (ScriptMenu_MultichoiceGrid(left, top, multichoiceId, ignoreBPress, numColumns) == TRUE) + { + ScriptContext1_Stop(); + return TRUE; + } + else + { + return FALSE; + } +} + +SCRCMD_DEF(erasebox) +{ + u8 left = ScriptReadByte(ctx); + u8 top = ScriptReadByte(ctx); + u8 right = ScriptReadByte(ctx); + u8 bottom = ScriptReadByte(ctx); + + // MenuZeroFillWindowRect(left, top, right, bottom); + return FALSE; +} + +SCRCMD_DEF(drawboxtext) +{ +// u8 left = ScriptReadByte(ctx); +// u8 top = ScriptReadByte(ctx); +// u8 multichoiceId = ScriptReadByte(ctx); +// u8 ignoreBPress = ScriptReadByte(ctx); + + /*if (Multichoice(left, top, multichoiceId, ignoreBPress) == TRUE) + { + ScriptContext1_Stop(); + return TRUE; + }*/ + return FALSE; +} + +SCRCMD_DEF(showmonpic) +{ + u16 species = VarGet(ScriptReadHalfword(ctx)); + u8 x = ScriptReadByte(ctx); + u8 y = ScriptReadByte(ctx); + + ScriptMenu_ShowPokemonPic(species, x, y); + PlayCry7(species, 0); + return FALSE; +} + +SCRCMD_DEF(hidemonpic) +{ + bool8 (*func)(void) = ScriptMenu_GetPicboxWaitFunc(); + + if (func == NULL) + return FALSE; + SetupNativeScript(ctx, func); + return TRUE; +} + +SCRCMD_DEF(showcontestwinner) +{ + u8 v1 = ScriptReadByte(ctx); + + /* + if (v1) + sub_812FDA8(v1); + ShowContestWinner(); + ScriptContext1_Stop(); + return TRUE; + */ + + return FALSE; +} + +SCRCMD_DEF(braillemessage) +{ + u8 *ptr = (u8 *)ScriptReadWord(ctx); + if (ptr == NULL) + ptr = (u8 *)ctx->data[0]; + + sub_80F6E9C(); + sub_80F6EE4(0, 1); + AddTextPrinterParameterized(0, 6, ptr, 0, 1, 0, NULL); + return FALSE; +} + +SCRCMD_DEF(getbraillestringwidth) +{ + u8 *ptr = (u8 *)ScriptReadWord(ctx); + if (ptr == NULL) + ptr = (u8 *)ctx->data[0]; + + gSpecialVar_0x8004 = GetStringWidth(6, ptr, -1); + return FALSE; +} -- cgit v1.2.3 From 2822d29c0bd7e579388f9d0772a7b5d1af430b31 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 6 Jan 2019 15:28:10 -0500 Subject: through ScrCmd_bufferstring --- src/quest_log.c | 4 +- src/scrcmd.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++++--- src/trainer_tower.c | 2 +- 3 files changed, 144 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/quest_log.c b/src/quest_log.c index 4f462505a..a01cbde2d 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -4312,7 +4312,7 @@ u16 * sub_8114C68(u16 * a0, const u16 * a1) const u16 * sub_8114C8C(const u16 * a0) { const u16 *r4 = sub_8113E88(28, a0); - sub_8099E90(r4[0], gStringVar1); + CopyItemName(r4[0], gStringVar1); StringExpandPlaceholders(gStringVar4, gUnknown_841A391); return r4 + 1; } @@ -4329,7 +4329,7 @@ u16 * sub_8114CC0(u16 * a0, const u16 * a1) const u16 * sub_8114CE4(const u16 * a0) { const u16 *r4 = sub_8113E88(29, a0); - sub_8099E90(r4[0], gStringVar1); + CopyItemName(r4[0], gStringVar1); StringExpandPlaceholders(gStringVar4, gUnknown_841A3DA); return r4 + 1; } diff --git a/src/scrcmd.c b/src/scrcmd.c index c77dda666..98a3fa027 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -24,6 +24,10 @@ #include "window.h" #include "start_menu.h" #include "script_menu.h" +#include "string_util.h" +#include "data2.h" +#include "field_specials.h" +#include "constants/items.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); @@ -341,13 +345,6 @@ SCRCMD_DEF(setorcopyvar) return FALSE; } -u8 * const sScriptStringVars[] = -{ - gStringVar1, - gStringVar2, - gStringVar3, -}; - u8 compare_012(u16 left, u16 right) { if (left < right) @@ -1575,3 +1572,140 @@ SCRCMD_DEF(getbraillestringwidth) gSpecialVar_0x8004 = GetStringWidth(6, ptr, -1); return FALSE; } + +SCRCMD_DEF(vmessage) +{ + u32 v1 = ScriptReadWord(ctx); + + ShowFieldMessage((u8 *)(v1 - gVScriptOffset)); + return FALSE; +} + +u8 * const sScriptStringVars[] = +{ + gStringVar1, + gStringVar2, + gStringVar3, +}; + +bool8 ScrCmd_bufferspeciesname(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 species = VarGet(ScriptReadHalfword(ctx)); + + StringCopy(sScriptStringVars[stringVarIndex], gSpeciesNames[species]); + return FALSE; +} + +bool8 ScrCmd_bufferleadmonspeciesname(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + + u8 *dest = sScriptStringVars[stringVarIndex]; + u8 partyIndex = GetLeadMonIndex(); + u32 species = GetMonData(&gPlayerParty[partyIndex], MON_DATA_SPECIES, NULL); + StringCopy(dest, gSpeciesNames[species]); + return FALSE; +} + +bool8 ScrCmd_bufferpartymonnick(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); + + GetMonData(&gPlayerParty[partyIndex], MON_DATA_NICKNAME, sScriptStringVars[stringVarIndex]); + StringGetEnd10(sScriptStringVars[stringVarIndex]); + return FALSE; +} + +bool8 ScrCmd_bufferitemname(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 itemId = VarGet(ScriptReadHalfword(ctx)); + + CopyItemName(itemId, sScriptStringVars[stringVarIndex]); + return FALSE; +} + +extern const u8 gUnknown_83A72A0[]; +extern const u8 gUnknown_83A72A2[]; + +bool8 ScrCmd_bufferitemnameplural(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 itemId = VarGet(ScriptReadHalfword(ctx)); + u16 quantity = VarGet(ScriptReadHalfword(ctx)); + + CopyItemName(itemId, sScriptStringVars[stringVarIndex]); + if (itemId == ITEM_POKE_BALL && quantity >= 2) + StringAppend(sScriptStringVars[stringVarIndex], gUnknown_83A72A0); + else if (itemId >= ITEM_CHERI_BERRY && itemId < ITEM_ENIGMA_BERRY && quantity >= 2) + { + u16 strlength = StringLength(sScriptStringVars[stringVarIndex]); + if (strlength != 0) + { + u8 * endptr = sScriptStringVars[stringVarIndex] + strlength; + endptr[-1] = EOS; + StringAppend(sScriptStringVars[stringVarIndex], gUnknown_83A72A2); + } + } + + return FALSE; +} + +bool8 ScrCmd_bufferdecorationname(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 decorId = VarGet(ScriptReadHalfword(ctx)); + +// StringCopy(sScriptStringVars[stringVarIndex], gDecorations[decorId].name); + return FALSE; +} + +bool8 ScrCmd_buffermovename(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 moveId = VarGet(ScriptReadHalfword(ctx)); + + StringCopy(sScriptStringVars[stringVarIndex], gMoveNames[moveId]); + return FALSE; +} + +bool8 ScrCmd_buffernumberstring(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 v1 = VarGet(ScriptReadHalfword(ctx)); + u8 v2 = CountDigits(v1); + + ConvertIntToDecimalStringN(sScriptStringVars[stringVarIndex], v1, 0, v2); + return FALSE; +} + +bool8 ScrCmd_bufferstdstring(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 index = VarGet(ScriptReadHalfword(ctx)); + + StringCopy(sScriptStringVars[stringVarIndex], gStdStringPtrs[index]); + return FALSE; +} + +/* +bool8 ScrCmd_buffercontesttype(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 index = VarGet(ScriptReadHalfword(ctx)); + + sub_818E868(sScriptStringVars[stringVarIndex], index); + return FALSE; +} +*/ + +bool8 ScrCmd_bufferstring(struct ScriptContext *ctx) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + const u8 *text = (u8 *)ScriptReadWord(ctx); + + StringCopy(sScriptStringVars[stringVarIndex], text); + return FALSE; +} diff --git a/src/trainer_tower.c b/src/trainer_tower.c index c968f24c3..f4e18eee6 100644 --- a/src/trainer_tower.c +++ b/src/trainer_tower.c @@ -821,7 +821,7 @@ void sub_815E408(void) gSpecialVar_Result = 2; else if (AddBagItem(itemId, 1) == 1) { - sub_8099E90(itemId, gStringVar2); + CopyItemName(itemId, gStringVar2); gSaveBlock1Ptr->unkArray[gSaveBlock1Ptr->unkArrayIdx].unkA_0 = TRUE; gSpecialVar_Result = 0; } -- cgit v1.2.3 From fdd7b1033cb32f02eb861ca87fa92b9886bdfe37 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 6 Jan 2019 16:00:27 -0500 Subject: Through ScrCmd_pokemart --- src/scrcmd.c | 273 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 262 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index 98a3fa027..3d7200b5b 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -28,6 +28,14 @@ #include "data2.h" #include "field_specials.h" #include "constants/items.h" +#include "script_pokemon_util_80A0058.h" +#include "pokemon_storage_system.h" +#include "party_menu.h" +#include "money.h" +#include "coins.h" +#include "battle_setup.h" +#include "shop.h" +#include "script_pokemon_80F8.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); @@ -1588,7 +1596,7 @@ u8 * const sScriptStringVars[] = gStringVar3, }; -bool8 ScrCmd_bufferspeciesname(struct ScriptContext *ctx) +SCRCMD_DEF(bufferspeciesname) { u8 stringVarIndex = ScriptReadByte(ctx); u16 species = VarGet(ScriptReadHalfword(ctx)); @@ -1597,7 +1605,7 @@ bool8 ScrCmd_bufferspeciesname(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_bufferleadmonspeciesname(struct ScriptContext *ctx) +SCRCMD_DEF(bufferleadmonspeciesname) { u8 stringVarIndex = ScriptReadByte(ctx); @@ -1608,7 +1616,7 @@ bool8 ScrCmd_bufferleadmonspeciesname(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_bufferpartymonnick(struct ScriptContext *ctx) +SCRCMD_DEF(bufferpartymonnick) { u8 stringVarIndex = ScriptReadByte(ctx); u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); @@ -1618,7 +1626,7 @@ bool8 ScrCmd_bufferpartymonnick(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_bufferitemname(struct ScriptContext *ctx) +SCRCMD_DEF(bufferitemname) { u8 stringVarIndex = ScriptReadByte(ctx); u16 itemId = VarGet(ScriptReadHalfword(ctx)); @@ -1630,7 +1638,7 @@ bool8 ScrCmd_bufferitemname(struct ScriptContext *ctx) extern const u8 gUnknown_83A72A0[]; extern const u8 gUnknown_83A72A2[]; -bool8 ScrCmd_bufferitemnameplural(struct ScriptContext *ctx) +SCRCMD_DEF(bufferitemnameplural) { u8 stringVarIndex = ScriptReadByte(ctx); u16 itemId = VarGet(ScriptReadHalfword(ctx)); @@ -1653,7 +1661,7 @@ bool8 ScrCmd_bufferitemnameplural(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_bufferdecorationname(struct ScriptContext *ctx) +SCRCMD_DEF(bufferdecorationname) { u8 stringVarIndex = ScriptReadByte(ctx); u16 decorId = VarGet(ScriptReadHalfword(ctx)); @@ -1662,7 +1670,7 @@ bool8 ScrCmd_bufferdecorationname(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_buffermovename(struct ScriptContext *ctx) +SCRCMD_DEF(buffermovename) { u8 stringVarIndex = ScriptReadByte(ctx); u16 moveId = VarGet(ScriptReadHalfword(ctx)); @@ -1671,7 +1679,7 @@ bool8 ScrCmd_buffermovename(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_buffernumberstring(struct ScriptContext *ctx) +SCRCMD_DEF(buffernumberstring) { u8 stringVarIndex = ScriptReadByte(ctx); u16 v1 = VarGet(ScriptReadHalfword(ctx)); @@ -1681,7 +1689,7 @@ bool8 ScrCmd_buffernumberstring(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_bufferstdstring(struct ScriptContext *ctx) +SCRCMD_DEF(bufferstdstring) { u8 stringVarIndex = ScriptReadByte(ctx); u16 index = VarGet(ScriptReadHalfword(ctx)); @@ -1691,7 +1699,7 @@ bool8 ScrCmd_bufferstdstring(struct ScriptContext *ctx) } /* -bool8 ScrCmd_buffercontesttype(struct ScriptContext *ctx) +SCRCMD_DEF(buffercontesttype) { u8 stringVarIndex = ScriptReadByte(ctx); u16 index = VarGet(ScriptReadHalfword(ctx)); @@ -1701,7 +1709,7 @@ bool8 ScrCmd_buffercontesttype(struct ScriptContext *ctx) } */ -bool8 ScrCmd_bufferstring(struct ScriptContext *ctx) +SCRCMD_DEF(bufferstring) { u8 stringVarIndex = ScriptReadByte(ctx); const u8 *text = (u8 *)ScriptReadWord(ctx); @@ -1709,3 +1717,246 @@ bool8 ScrCmd_bufferstring(struct ScriptContext *ctx) StringCopy(sScriptStringVars[stringVarIndex], text); return FALSE; } + +SCRCMD_DEF(vloadword) +{ + const u8 *ptr = (u8 *)(ScriptReadWord(ctx) - gVScriptOffset); + + StringExpandPlaceholders(gStringVar4, ptr); + return FALSE; +} + +SCRCMD_DEF(vbufferstring) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u32 addr = ScriptReadWord(ctx); + + const u8 *src = (u8 *)(addr - gVScriptOffset); + u8 *dest = sScriptStringVars[stringVarIndex]; + StringCopy(dest, src); + return FALSE; +} + +SCRCMD_DEF(bufferboxname) +{ + u8 stringVarIndex = ScriptReadByte(ctx); + u16 boxId = VarGet(ScriptReadHalfword(ctx)); + + StringCopy(sScriptStringVars[stringVarIndex], GetBoxNamePtr(boxId)); + return FALSE; +} + +SCRCMD_DEF(givemon) +{ + u16 species = VarGet(ScriptReadHalfword(ctx)); + u8 level = ScriptReadByte(ctx); + u16 item = VarGet(ScriptReadHalfword(ctx)); + u32 unkParam1 = ScriptReadWord(ctx); + u32 unkParam2 = ScriptReadWord(ctx); + u8 unkParam3 = ScriptReadByte(ctx); + + gSpecialVar_Result = ScriptGiveMon(species, level, item, unkParam1, unkParam2, unkParam3); + return FALSE; +} + +SCRCMD_DEF(giveegg) +{ + u16 species = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = ScriptGiveEgg(species); + return FALSE; +} + +SCRCMD_DEF(setmonmove) +{ + u8 partyIndex = ScriptReadByte(ctx); + u8 slot = ScriptReadByte(ctx); + u16 move = ScriptReadHalfword(ctx); + + ScriptSetMonMoveSlot(partyIndex, move, slot); + return FALSE; +} + +SCRCMD_DEF(checkpartymove) +{ + u8 i; + u16 moveId = ScriptReadHalfword(ctx); + + gSpecialVar_Result = PARTY_SIZE; + for (i = 0; i < PARTY_SIZE; i++) + { + u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL); + if (!species) + break; + if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) && MonKnowsMove(&gPlayerParty[i], moveId) == TRUE) + { + gSpecialVar_Result = i; + gSpecialVar_0x8004 = species; + break; + } + } + return FALSE; +} + +SCRCMD_DEF(givemoney) +{ + u32 amount = ScriptReadWord(ctx); + u8 ignore = ScriptReadByte(ctx); + + if (!ignore) + AddMoney(&gSaveBlock1Ptr->money, amount); + return FALSE; +} + +SCRCMD_DEF(takemoney) +{ + u32 amount = ScriptReadWord(ctx); + u8 ignore = ScriptReadByte(ctx); + + if (!ignore) + RemoveMoney(&gSaveBlock1Ptr->money, amount); + return FALSE; +} + +SCRCMD_DEF(checkmoney) +{ + u32 amount = ScriptReadWord(ctx); + u8 ignore = ScriptReadByte(ctx); + + if (!ignore) + gSpecialVar_Result = IsEnoughMoney(&gSaveBlock1Ptr->money, amount); + return FALSE; +} + +SCRCMD_DEF(showmoneybox) +{ + u8 x = ScriptReadByte(ctx); + u8 y = ScriptReadByte(ctx); + u8 ignore = ScriptReadByte(ctx); + + if (!ignore && sub_81119D4(sub_809D6D4) != TRUE) + DrawMoneyBox(GetMoney(&gSaveBlock1Ptr->money), x, y); + return FALSE; +} + +SCRCMD_DEF(hidemoneybox) +{ + /*u8 x = ScriptReadByte(ctx); + u8 y = ScriptReadByte(ctx);*/ + + HideMoneyBox(); + return FALSE; +} + +SCRCMD_DEF(updatemoneybox) +{ + u8 x = ScriptReadByte(ctx); + u8 y = ScriptReadByte(ctx); + u8 ignore = ScriptReadByte(ctx); + + if (!ignore) + ChangeAmountInMoneyBox(GetMoney(&gSaveBlock1Ptr->money)); + return FALSE; +} + +SCRCMD_DEF(showcoinsbox) +{ + u8 x = ScriptReadByte(ctx); + u8 y = ScriptReadByte(ctx); + + if (sub_81119D4(sub_809D6D4) != TRUE) + ShowCoinsWindow(GetCoins(), x, y); + return FALSE; +} + +SCRCMD_DEF(hidecoinsbox) +{ + u8 x = ScriptReadByte(ctx); + u8 y = ScriptReadByte(ctx); + + HideCoinsWindow(); + return FALSE; +} + +SCRCMD_DEF(updatecoinsbox) +{ + u8 x = ScriptReadByte(ctx); + u8 y = ScriptReadByte(ctx); + + PrintCoinsString(GetCoins()); + return FALSE; +} + +SCRCMD_DEF(trainerbattle) +{ + ctx->scriptPtr = BattleSetup_ConfigureTrainerBattle(ctx->scriptPtr); + return FALSE; +} + +SCRCMD_DEF(dotrainerbattle) +{ + BattleSetup_StartTrainerBattle(); + return TRUE; +} + +SCRCMD_DEF(gotopostbattlescript) +{ + ctx->scriptPtr = BattleSetup_GetScriptAddrAfterBattle(); + return FALSE; +} + +SCRCMD_DEF(gotobeatenscript) +{ + ctx->scriptPtr = BattleSetup_GetTrainerPostBattleScript(); + return FALSE; +} + +SCRCMD_DEF(checktrainerflag) +{ + u16 index = VarGet(ScriptReadHalfword(ctx)); + + ctx->comparisonResult = HasTrainerAlreadyBeenFought(index); + return FALSE; +} + +SCRCMD_DEF(settrainerflag) +{ + u16 index = VarGet(ScriptReadHalfword(ctx)); + + SetTrainerFlag(index); + return FALSE; +} + +SCRCMD_DEF(cleartrainerflag) +{ + u16 index = VarGet(ScriptReadHalfword(ctx)); + + ClearTrainerFlag(index); + return FALSE; +} + +SCRCMD_DEF(setwildbattle) +{ + u16 species = ScriptReadHalfword(ctx); + u8 level = ScriptReadByte(ctx); + u16 item = ScriptReadHalfword(ctx); + + CreateScriptedWildMon(species, level, item); + return FALSE; +} + +SCRCMD_DEF(dowildbattle) +{ + BattleSetup_StartScriptedWildBattle(); + ScriptContext1_Stop(); + return TRUE; +} + +SCRCMD_DEF(pokemart) +{ + const void *ptr = (void *)ScriptReadWord(ctx); + + CreatePokemartMenu(ptr); + ScriptContext1_Stop(); + return TRUE; +} -- cgit v1.2.3 From abac6f3ec853f451a7d456cfd336d8c51c0541c1 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 6 Jan 2019 16:14:59 -0500 Subject: Through ScrCmd_takecoins --- src/scrcmd.c | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 269 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index 3d7200b5b..c6f6ab5d3 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -36,6 +36,10 @@ #include "battle_setup.h" #include "shop.h" #include "script_pokemon_80F8.h" +#include "slot_machine.h" +#include "field_effect.h" +#include "fieldmap.h" +#include "field_door.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); @@ -48,7 +52,7 @@ EWRAM_DATA u16 sPauseCounter = 0; EWRAM_DATA u16 sMovingNpcId = 0; EWRAM_DATA u16 sMovingNpcMapBank = 0; EWRAM_DATA u16 sMovingNpcMapId = 0; -EWRAM_DATA u16 gUnknown_20370B6 = 0; +EWRAM_DATA u16 sFieldEffectScriptId = 0; extern u8 gSelectedEventObject; @@ -1960,3 +1964,267 @@ SCRCMD_DEF(pokemart) ScriptContext1_Stop(); return TRUE; } + +SCRCMD_DEF(pokemartdecoration) +{ + const void *ptr = (void *)ScriptReadWord(ctx); + + CreateDecorationShop1Menu(ptr); + ScriptContext1_Stop(); + return TRUE; +} + +SCRCMD_DEF(pokemartdecoration2) +{ + const void *ptr = (void *)ScriptReadWord(ctx); + + CreateDecorationShop2Menu(ptr); + ScriptContext1_Stop(); + return TRUE; +} + +SCRCMD_DEF(playslotmachine) +{ + u8 slotMachineIndex = VarGet(ScriptReadHalfword(ctx)); + + PlaySlotMachine(slotMachineIndex, c2_exit_to_overworld_1_continue_scripts_restart_music); + ScriptContext1_Stop(); + return TRUE; +} + +SCRCMD_DEF(setberrytree) +{ +// u8 treeId = ScriptReadByte(ctx); +// u8 berry = ScriptReadByte(ctx); +// u8 growthStage = ScriptReadByte(ctx); +// +// if (berry == 0) +// PlantBerryTree(treeId, 0, growthStage, FALSE); +// else +// PlantBerryTree(treeId, berry, growthStage, FALSE); + return FALSE; +} + +SCRCMD_DEF(getpricereduction) +{ +// u16 value = VarGet(ScriptReadHalfword(ctx)); +// +// gSpecialVar_Result = GetPriceReduction(value); + return FALSE; +} + +SCRCMD_DEF(choosecontestmon) +{ +// sub_81B9404(); + ScriptContext1_Stop(); + return TRUE; +} + + +SCRCMD_DEF(startcontest) +{ +// sub_80F840C(); +// ScriptContext1_Stop(); +// return TRUE; + return FALSE; +} + +SCRCMD_DEF(showcontestresults) +{ +// sub_80F8484(); +// ScriptContext1_Stop(); +// return TRUE; + return FALSE; +} + +SCRCMD_DEF(contestlinktransfer) +{ +// sub_80F84C4(gSpecialVar_ContestCategory); +// ScriptContext1_Stop(); +// return TRUE; + return FALSE; +} + +SCRCMD_DEF(dofieldeffect) +{ + u16 effectId = VarGet(ScriptReadHalfword(ctx)); + + sFieldEffectScriptId = effectId; + FieldEffectStart(sFieldEffectScriptId); + return FALSE; +} + +SCRCMD_DEF(setfieldeffectarg) +{ + u8 argNum = ScriptReadByte(ctx); + + gFieldEffectArguments[argNum] = (s16)VarGet(ScriptReadHalfword(ctx)); + return FALSE; +} + +static bool8 WaitForFieldEffectFinish(void) +{ + if (!FieldEffectActiveListContains(sFieldEffectScriptId)) + return TRUE; + else + return FALSE; +} + +SCRCMD_DEF(waitfieldeffect) +{ + sFieldEffectScriptId = VarGet(ScriptReadHalfword(ctx)); + SetupNativeScript(ctx, WaitForFieldEffectFinish); + return TRUE; +} + +SCRCMD_DEF(setrespawn) +{ + u16 healLocationId = VarGet(ScriptReadHalfword(ctx)); + + SetLastHealLocationWarp(healLocationId); + return FALSE; +} + +SCRCMD_DEF(checkplayergender) +{ + gSpecialVar_Result = gSaveBlock2Ptr->playerGender; + return FALSE; +} + +SCRCMD_DEF(playmoncry) +{ + u16 species = VarGet(ScriptReadHalfword(ctx)); + u16 mode = VarGet(ScriptReadHalfword(ctx)); + + PlayCry7(species, mode); + return FALSE; +} + +SCRCMD_DEF(waitmoncry) +{ + SetupNativeScript(ctx, IsCryFinished); + return TRUE; +} + +SCRCMD_DEF(setmetatile) +{ + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + u16 tileId = VarGet(ScriptReadHalfword(ctx)); + u16 v8 = VarGet(ScriptReadHalfword(ctx)); + + x += 7; + y += 7; + if (!v8) + MapGridSetMetatileIdAt(x, y, tileId); + else + MapGridSetMetatileIdAt(x, y, tileId | 0xC00); + return FALSE; +} + +SCRCMD_DEF(opendoor) +{ + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + x += 7; + y += 7; + PlaySE(GetDoorSoundEffect(x, y)); + FieldAnimateDoorOpen(x, y); + return FALSE; +} + +SCRCMD_DEF(closedoor) +{ + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + x += 7; + y += 7; + FieldAnimateDoorClose(x, y); + return FALSE; +} + +static bool8 IsDoorAnimationStopped(void) +{ + if (!FieldIsDoorAnimationRunning()) + return TRUE; + else + return FALSE; +} + +SCRCMD_DEF(waitdooranim) +{ + SetupNativeScript(ctx, IsDoorAnimationStopped); + return TRUE; +} + +SCRCMD_DEF(setdooropen) +{ + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + x += 7; + y += 7; + FieldSetDoorOpened(x, y); + return FALSE; +} + +SCRCMD_DEF(setdoorclosed) +{ + u16 x = VarGet(ScriptReadHalfword(ctx)); + u16 y = VarGet(ScriptReadHalfword(ctx)); + + x += 7; + y += 7; + FieldSetDoorClosed(x, y); + return FALSE; +} + +SCRCMD_DEF(addelevmenuitem) +{ +// u8 v3 = ScriptReadByte(ctx); +// u16 v5 = VarGet(ScriptReadHalfword(ctx)); +// u16 v7 = VarGet(ScriptReadHalfword(ctx)); +// u16 v9 = VarGet(ScriptReadHalfword(ctx)); + + //ScriptAddElevatorMenuItem(v3, v5, v7, v9); + return FALSE; +} + +SCRCMD_DEF(showelevmenu) +{ + /*ScriptShowElevatorMenu(); + ScriptContext1_Stop(); + return TRUE;*/ + return FALSE; +} + +SCRCMD_DEF(checkcoins) +{ + u16 *ptr = GetVarPointer(ScriptReadHalfword(ctx)); + *ptr = GetCoins(); + return FALSE; +} + +SCRCMD_DEF(givecoins) +{ + u16 coins = VarGet(ScriptReadHalfword(ctx)); + + if (GiveCoins(coins) == TRUE) + gSpecialVar_Result = 0; + else + gSpecialVar_Result = 1; + return FALSE; +} + +SCRCMD_DEF(takecoins) +{ + u16 coins = VarGet(ScriptReadHalfword(ctx)); + + if (TakeCoins(coins) == TRUE) + gSpecialVar_Result = 0; + else + gSpecialVar_Result = 1; + return FALSE; +} -- cgit v1.2.3 From 1581631e6286e0ec8178630433e8c15cd7076ead Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 6 Jan 2019 16:17:40 -0500 Subject: Finish decompiling scrcmd --- src/scrcmd.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src') diff --git a/src/scrcmd.c b/src/scrcmd.c index c6f6ab5d3..911ad2a42 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2228,3 +2228,43 @@ SCRCMD_DEF(takecoins) gSpecialVar_Result = 1; return FALSE; } + +SCRCMD_DEF(cmdCA) +{ + sub_8069A20(); + return FALSE; +} + +SCRCMD_DEF(cmdCB) +{ + sub_8069A2C(); + return FALSE; +} + +// This command will force the Pokémon to be obedient, you don't get to make it disobedient. +SCRCMD_DEF(setmonobedient) +{ + bool8 obedient = TRUE; + u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); + + SetMonData(&gPlayerParty[partyIndex], MON_DATA_OBEDIENCE, &obedient); + return FALSE; +} + +SCRCMD_DEF(checkmonobedience) +{ + u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); + + gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_OBEDIENCE, NULL); + return FALSE; +} + +SCRCMD_DEF(setmonmetlocation) +{ + u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); + u8 location = ScriptReadByte(ctx); + + if (partyIndex < PARTY_SIZE) + SetMonData(&gPlayerParty[partyIndex], MON_DATA_MET_LOCATION, &location); + return FALSE; +} -- cgit v1.2.3