diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/quest_log.c | 4 | ||||
-rw-r--r-- | src/scrcmd.c | 148 | ||||
-rw-r--r-- | src/trainer_tower.c | 2 |
3 files changed, 144 insertions, 10 deletions
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; } |