diff options
Diffstat (limited to 'src/scrcmd.c')
-rw-r--r-- | src/scrcmd.c | 101 |
1 files changed, 48 insertions, 53 deletions
diff --git a/src/scrcmd.c b/src/scrcmd.c index 6007fb493..5b7c95e8e 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -49,7 +49,6 @@ #include "tv.h" #include "window.h" #include "constants/event_objects.h" -#include "constants/maps.h" typedef u16 (*SpecialFunc)(void); typedef void (*NativeFunc)(void); @@ -58,11 +57,11 @@ EWRAM_DATA const u8 *gRamScriptRetAddr = NULL; static EWRAM_DATA u32 sAddressOffset = 0; // For relative addressing in vgoto etc., used by saved scripts (e.g. Mystery Event) static EWRAM_DATA u16 sPauseCounter = 0; static EWRAM_DATA u16 sMovingNpcId = 0; -static EWRAM_DATA u16 sMovingNpcMapBank = 0; -static EWRAM_DATA u16 sMovingNpcMapId = 0; +static EWRAM_DATA u16 sMovingNpcMapGroup = 0; +static EWRAM_DATA u16 sMovingNpcMapNum = 0; static EWRAM_DATA u16 sFieldEffectScriptId = 0; -static u8 gBrailleWindowId; +static u8 sBrailleWindowId; extern const SpecialFunc gSpecials[]; extern const u8 *gStdScripts[]; @@ -610,11 +609,9 @@ bool8 ScrCmd_animateflash(struct ScriptContext *ctx) return TRUE; } -bool8 ScrCmd_setflashradius(struct ScriptContext *ctx) +bool8 ScrCmd_setflashlevel(struct ScriptContext *ctx) { - u16 flashLevel = VarGet(ScriptReadHalfword(ctx)); - - Overworld_SetFlashLevel(flashLevel); + SetFlashLevel(VarGet(ScriptReadHalfword(ctx))); return FALSE; } @@ -668,9 +665,7 @@ bool8 ScrCmd_fadescreenswapbuffers(struct ScriptContext *ctx) static bool8 RunPauseTimer(void) { - sPauseCounter--; - - if (sPauseCounter == 0) + if (--sPauseCounter == 0) return TRUE; else return FALSE; @@ -711,13 +706,13 @@ bool8 ScrCmd_setweather(struct ScriptContext *ctx) { u16 weather = VarGet(ScriptReadHalfword(ctx)); - SetSav1Weather(weather); + SetSavedWeather(weather); return FALSE; } bool8 ScrCmd_resetweather(struct ScriptContext *ctx) { - SetSav1WeatherFromCurrMapHeader(); + SetSavedWeatherFromCurrMapHeader(); return FALSE; } @@ -794,7 +789,7 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx) if (mapGroup == MAP_GROUP(UNDEFINED) && mapNum == MAP_NUM(UNDEFINED)) SetWarpDestinationToFixedHoleWarp(x - MAP_OFFSET, y - MAP_OFFSET); else - SetWarpDestination(mapGroup, mapNum, -1, x - MAP_OFFSET, y - MAP_OFFSET); + SetWarpDestination(mapGroup, mapNum, WARP_ID_NONE, x - MAP_OFFSET, y - MAP_OFFSET); DoFallWarp(); ResetInitialPlayerAvatarState(); return TRUE; @@ -945,9 +940,9 @@ bool8 ScrCmd_waitfanfare(struct ScriptContext *ctx) bool8 ScrCmd_playbgm(struct ScriptContext *ctx) { u16 songId = ScriptReadHalfword(ctx); - bool8 val = ScriptReadByte(ctx); + bool8 save = ScriptReadByte(ctx); - if (val == TRUE) + if (save == TRUE) Overworld_SetSavedMusic(songId); PlayNewMapMusic(songId); return FALSE; @@ -1018,7 +1013,7 @@ bool8 ScrCmd_applymovement_at(struct ScriptContext *ctx) static bool8 WaitForMovementFinish(void) { - return ScriptMovement_IsObjectMovementFinished(sMovingNpcId, sMovingNpcMapId, sMovingNpcMapBank); + return ScriptMovement_IsObjectMovementFinished(sMovingNpcId, sMovingNpcMapNum, sMovingNpcMapGroup); } bool8 ScrCmd_waitmovement(struct ScriptContext *ctx) @@ -1027,8 +1022,8 @@ bool8 ScrCmd_waitmovement(struct ScriptContext *ctx) if (localId != 0) sMovingNpcId = localId; - sMovingNpcMapBank = gSaveBlock1Ptr->location.mapGroup; - sMovingNpcMapId = gSaveBlock1Ptr->location.mapNum; + sMovingNpcMapGroup = gSaveBlock1Ptr->location.mapGroup; + sMovingNpcMapNum = gSaveBlock1Ptr->location.mapNum; SetupNativeScript(ctx, WaitForMovementFinish); return TRUE; } @@ -1036,15 +1031,15 @@ bool8 ScrCmd_waitmovement(struct ScriptContext *ctx) bool8 ScrCmd_waitmovement_at(struct ScriptContext *ctx) { u16 localId = VarGet(ScriptReadHalfword(ctx)); - u8 mapBank; - u8 mapId; + u8 mapGroup; + u8 mapNum; if (localId != 0) sMovingNpcId = localId; - mapBank = ScriptReadByte(ctx); - mapId = ScriptReadByte(ctx); - sMovingNpcMapBank = mapBank; - sMovingNpcMapId = mapId; + mapGroup = ScriptReadByte(ctx); + mapNum = ScriptReadByte(ctx); + sMovingNpcMapGroup = mapGroup; + sMovingNpcMapNum = mapNum; SetupNativeScript(ctx, WaitForMovementFinish); return TRUE; } @@ -1101,7 +1096,7 @@ bool8 ScrCmd_setobjectxyperm(struct ScriptContext *ctx) u16 x = VarGet(ScriptReadHalfword(ctx)); u16 y = VarGet(ScriptReadHalfword(ctx)); - Overworld_SetObjEventTemplateCoords(localId, x, y); + SetObjEventTemplateCoords(localId, x, y); return FALSE; } @@ -1133,24 +1128,24 @@ bool8 ScrCmd_hideobject_at(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_setobjectpriority(struct ScriptContext *ctx) +bool8 ScrCmd_setobjectsubpriority(struct ScriptContext *ctx) { u16 localId = VarGet(ScriptReadHalfword(ctx)); u8 mapGroup = ScriptReadByte(ctx); u8 mapNum = ScriptReadByte(ctx); u8 priority = ScriptReadByte(ctx); - SetObjectPriority(localId, mapNum, mapGroup, priority + 83); + SetObjectSubpriority(localId, mapNum, mapGroup, priority + 83); return FALSE; } -bool8 ScrCmd_resetobjectpriority(struct ScriptContext *ctx) +bool8 ScrCmd_resetobjectsubpriority(struct ScriptContext *ctx) { u16 localId = VarGet(ScriptReadHalfword(ctx)); u8 mapGroup = ScriptReadByte(ctx); u8 mapNum = ScriptReadByte(ctx); - ResetObjectPriority(localId, mapNum, mapGroup); + ResetObjectSubpriority(localId, mapNum, mapGroup); return FALSE; } @@ -1178,7 +1173,7 @@ bool8 ScrCmd_setobjectmovementtype(struct ScriptContext *ctx) u16 localId = VarGet(ScriptReadHalfword(ctx)); u8 movementType = ScriptReadByte(ctx); - Overworld_SetObjEventTemplateMovementType(localId, movementType); + SetObjEventTemplateMovementType(localId, movementType); return FALSE; } @@ -1311,7 +1306,7 @@ bool8 ScrCmd_messageinstant(struct ScriptContext *ctx) msg = (const u8 *)ctx->data[0]; LoadMessageBoxAndBorderGfx(); DrawDialogueFrame(0, 1); - AddTextPrinterParameterized(0, FONT_NORMAL, msg, 0, 1, 0, 0); + AddTextPrinterParameterized(0, FONT_NORMAL, msg, 0, 1, 0, NULL); return FALSE; } @@ -1463,7 +1458,9 @@ bool8 ScrCmd_showmonpic(struct ScriptContext *ctx) bool8 ScrCmd_hidemonpic(struct ScriptContext *ctx) { - bool8 (*func)(void) = ScriptMenu_GetPicboxWaitFunc(); + // The hide function returns a pointer to a function + // that returns true once the pic is hidden + bool8 (*func)(void) = ScriptMenu_HidePokemonPic(); if (func == NULL) return FALSE; @@ -1528,13 +1525,13 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) yText = (yText - yWindow - 1) * 8; winTemplate = CreateWindowTemplate(0, xWindow, yWindow + 1, width, height, 0xF, 0x1); - gBrailleWindowId = AddWindow(&winTemplate); - LoadUserWindowBorderGfx(gBrailleWindowId, 0x214, 0xE0); - DrawStdWindowFrame(gBrailleWindowId, 0); - PutWindowTilemap(gBrailleWindowId); - FillWindowPixelBuffer(gBrailleWindowId, PIXEL_FILL(1)); - AddTextPrinterParameterized(gBrailleWindowId, FONT_BRAILLE, gStringVar4, xText, yText, TEXT_SKIP_DRAW, NULL); - CopyWindowToVram(gBrailleWindowId, COPYWIN_FULL); + sBrailleWindowId = AddWindow(&winTemplate); + LoadUserWindowBorderGfx(sBrailleWindowId, 0x214, 0xE0); + DrawStdWindowFrame(sBrailleWindowId, 0); + PutWindowTilemap(sBrailleWindowId); + FillWindowPixelBuffer(sBrailleWindowId, PIXEL_FILL(1)); + AddTextPrinterParameterized(sBrailleWindowId, FONT_BRAILLE, gStringVar4, xText, yText, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sBrailleWindowId, COPYWIN_FULL); return FALSE; } @@ -1638,12 +1635,12 @@ bool8 ScrCmd_bufferstdstring(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_buffercontesttype(struct ScriptContext *ctx) +bool8 ScrCmd_buffercontestname(struct ScriptContext *ctx) { u8 stringVarIndex = ScriptReadByte(ctx); - u16 index = VarGet(ScriptReadHalfword(ctx)); + u16 category = VarGet(ScriptReadHalfword(ctx)); - BufferContestName(sScriptStringVars[stringVarIndex], index); + BufferContestName(sScriptStringVars[stringVarIndex], category); return FALSE; } @@ -1933,17 +1930,17 @@ bool8 ScrCmd_setberrytree(struct ScriptContext *ctx) u8 growthStage = ScriptReadByte(ctx); if (berry == 0) - PlantBerryTree(treeId, 0, growthStage, FALSE); + PlantBerryTree(treeId, berry, growthStage, FALSE); else PlantBerryTree(treeId, berry, growthStage, FALSE); return FALSE; } -bool8 ScrCmd_getpricereduction(struct ScriptContext *ctx) +bool8 ScrCmd_getpokenewsactive(struct ScriptContext *ctx) { u16 newsKind = VarGet(ScriptReadHalfword(ctx)); - gSpecialVar_Result = GetPriceReduction(newsKind); + gSpecialVar_Result = IsPokeNewsActive(newsKind); return FALSE; } @@ -1985,7 +1982,7 @@ bool8 ScrCmd_dofieldeffect(struct ScriptContext *ctx) return FALSE; } -bool8 ScrCmd_setfieldeffectarg(struct ScriptContext *ctx) +bool8 ScrCmd_setfieldeffectargument(struct ScriptContext *ctx) { u8 argNum = ScriptReadByte(ctx); @@ -2230,9 +2227,7 @@ bool8 ScrCmd_checkmoneventlegal(struct ScriptContext *ctx) return FALSE; } -// TODO: Should be renamed. Name implies general usage, but its specifically for Wonder Card -// See GetSavedRamScriptIfValid, which is NULL if ValidateSavedWonderCard returns FALSE -bool8 ScrCmd_gotoram(struct ScriptContext *ctx) +bool8 ScrCmd_gotowondercardscript(struct ScriptContext *ctx) { const u8* script = GetSavedRamScriptIfValid(); @@ -2244,7 +2239,7 @@ bool8 ScrCmd_gotoram(struct ScriptContext *ctx) return FALSE; } -// Unused +// This warp is only used by the Union Room. // For the warp used by the Aqua Hideout, see DoTeleportTileWarp bool8 ScrCmd_warpspinenter(struct ScriptContext *ctx) { @@ -2273,8 +2268,8 @@ bool8 ScrCmd_setmonmetlocation(struct ScriptContext *ctx) static void CloseBrailleWindow(void) { - ClearStdWindowAndFrame(gBrailleWindowId, 1); - RemoveWindow(gBrailleWindowId); + ClearStdWindowAndFrame(sBrailleWindowId, 1); + RemoveWindow(sBrailleWindowId); } bool8 ScrCmd_buffertrainerclassname(struct ScriptContext *ctx) |