Drop some overworld prefixes

This commit is contained in:
GriffinR 2021-11-15 10:57:22 -05:00
parent 65d3b58374
commit c1130592fa
8 changed files with 64 additions and 70 deletions

View File

@ -67,8 +67,8 @@ void SetGameStat(u8 index, u32 value);
void ApplyNewEncryptionKeyToGameStats(u32 newKey);
void LoadObjEventTemplatesFromHeader(void);
void LoadSaveblockObjEventScripts(void);
void Overworld_SetObjEventTemplateCoords(u8 localId, s16 x, s16 y);
void Overworld_SetObjEventTemplateMovementType(u8 localId, u8 movementType);
void SetObjEventTemplateCoords(u8 localId, s16 x, s16 y);
void SetObjEventTemplateMovementType(u8 localId, u8 movementType);
const struct MapLayout *GetMapLayout(void);
void ApplyCurrentWarp(void);
struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum);
@ -98,8 +98,8 @@ void ResetInitialPlayerAvatarState(void);
void StoreInitialPlayerAvatarState(void);
bool32 Overworld_IsBikingAllowed(void);
void SetDefaultFlashLevel(void);
void Overworld_SetFlashLevel(s32 flashLevel);
u8 Overworld_GetFlashLevel(void);
void SetFlashLevel(s32 flashLevel);
u8 GetFlashLevel(void);
void SetCurrentMapLayout(u16 mapLayoutId);
void SetObjectEventLoadFlag(u8 var);
u16 GetLocationMusic(struct WarpData *warp);

View File

@ -700,7 +700,7 @@ static u8 GetBattleTransitionTypeByMap(void)
PlayerGetDestCoords(&x, &y);
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (Overworld_GetFlashLevel())
if (GetFlashLevel())
return TRANSITION_TYPE_FLASH;
if (!MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior))
{

View File

@ -1141,7 +1141,7 @@ static const u8 sPlayerDirectionToCopyDirection[][4] = {
static void ClearObjectEvent(struct ObjectEvent *objectEvent)
{
*objectEvent = (struct ObjectEvent){};
objectEvent->localId = 0xFF;
objectEvent->localId = OBJ_EVENT_ID_PLAYER;
objectEvent->mapNum = MAP_NUM(UNDEFINED);
objectEvent->mapGroup = MAP_GROUP(UNDEFINED);
objectEvent->movementActionId = MOVEMENT_ACTION_NONE;

View File

@ -974,7 +974,7 @@ static u8 StartUpdateOrbFlashEffect(s32 centerX, s32 centerY, s32 initialFlashRa
// A higher flashLevel value is a smaller flash radius (more darkness). 0 is full brightness
void AnimateFlash(u8 flashLevel)
{
u8 curFlashLevel = Overworld_GetFlashLevel();
u8 curFlashLevel = GetFlashLevel();
bool8 fullBrightness = FALSE;
if (!flashLevel)
fullBrightness = TRUE;

View File

@ -3029,6 +3029,8 @@ void CloseFrontierExchangeCornerItemIconWindow(void)
RemoveWindow(sFrontierExchangeCorner_ItemIconWindowId);
}
#define TAG_ITEM_ICON 5500
static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
{
#include "data/battle_frontier/battle_frontier_exchange_corner.h"
@ -3046,9 +3048,9 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
}
else
{
FreeSpriteTilesByTag(5500);
FreeSpritePaletteByTag(5500);
sScrollableMultichoice_ItemSpriteId = AddDecorationIconObject(sFrontierExchangeCorner_Decor1[selection], 33, 88, 0, 5500, 5500);
FreeSpriteTilesByTag(TAG_ITEM_ICON);
FreeSpritePaletteByTag(TAG_ITEM_ICON);
sScrollableMultichoice_ItemSpriteId = AddDecorationIconObject(sFrontierExchangeCorner_Decor1[selection], 33, 88, 0, TAG_ITEM_ICON, TAG_ITEM_ICON);
}
break;
case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2:
@ -3059,9 +3061,9 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
}
else
{
FreeSpriteTilesByTag(5500);
FreeSpritePaletteByTag(5500);
sScrollableMultichoice_ItemSpriteId = AddDecorationIconObject(sFrontierExchangeCorner_Decor2[selection], 33, 88, 0, 5500, 5500);
FreeSpriteTilesByTag(TAG_ITEM_ICON);
FreeSpritePaletteByTag(TAG_ITEM_ICON);
sScrollableMultichoice_ItemSpriteId = AddDecorationIconObject(sFrontierExchangeCorner_Decor2[selection], 33, 88, 0, TAG_ITEM_ICON, TAG_ITEM_ICON);
}
break;
case SCROLL_MULTI_BF_EXCHANGE_CORNER_VITAMIN_VENDOR:
@ -3078,9 +3080,9 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection)
static void ShowFrontierExchangeCornerItemIcon(u16 item)
{
FreeSpriteTilesByTag(5500);
FreeSpritePaletteByTag(5500);
sScrollableMultichoice_ItemSpriteId = AddItemIconSprite(5500, 5500, item);
FreeSpriteTilesByTag(TAG_ITEM_ICON);
FreeSpritePaletteByTag(TAG_ITEM_ICON);
sScrollableMultichoice_ItemSpriteId = AddItemIconSprite(TAG_ITEM_ICON, TAG_ITEM_ICON, item);
if (sScrollableMultichoice_ItemSpriteId != MAX_SPRITES)
{
@ -3416,7 +3418,7 @@ static void ChangeDeoxysRockLevel(u8 rockLevel)
gFieldEffectArguments[5] = 5;
FieldEffectStart(FLDEFF_MOVE_DEOXYS_ROCK);
Overworld_SetObjEventTemplateCoords(1, sDeoxysRockCoords[rockLevel][0], sDeoxysRockCoords[rockLevel][1]);
SetObjEventTemplateCoords(LOCALID_BIRTH_ISLAND_EXTERIOR_ROCK, sDeoxysRockCoords[rockLevel][0], sDeoxysRockCoords[rockLevel][1]);
}
static void WaitForDeoxysRockMovement(u8 taskId)

View File

@ -175,7 +175,6 @@ static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *, u
static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *, u8, u16, u8);
static u16 GetCenterScreenMetatileBehavior(void);
// IWRAM bss vars
static void *sUnusedOverworldCallback;
static u8 sPlayerLinkStates[MAX_LINK_PLAYERS];
// This callback is called with a player's key code. It then returns an
@ -185,7 +184,6 @@ static u16 (*sPlayerKeyInterceptCallback)(u32);
static bool8 sReceivingFromLink;
static u8 sRfuKeepAliveTimer;
// IWRAM common
u16 *gBGTilemapBuffers1;
u16 *gBGTilemapBuffers2;
u16 *gBGTilemapBuffers3;
@ -195,7 +193,6 @@ bool8 (*gFieldCallback2)(void);
u8 gLocalLinkPlayerId; // This is our player id in a multiplayer mode.
u8 gFieldLinkPlayerCount;
// EWRAM vars
EWRAM_DATA static u8 sObjectEventLoadFlag = 0;
EWRAM_DATA struct WarpData gLastUsedWarp = {0};
EWRAM_DATA static struct WarpData sWarpDestination = {0}; // new warp position
@ -207,11 +204,10 @@ EWRAM_DATA static u16 sAmbientCrySpecies = 0;
EWRAM_DATA static bool8 sIsAmbientCryWaterMon = FALSE;
EWRAM_DATA struct LinkPlayerObjectEvent gLinkPlayerObjectEvents[4] = {0};
// const rom data
static const struct WarpData sDummyWarpData =
{
.mapGroup = -1,
.mapNum = -1,
.mapGroup = MAP_GROUP(UNDEFINED),
.mapNum = MAP_NUM(UNDEFINED),
.warpId = -1,
.x = -1,
.y = -1,
@ -495,7 +491,7 @@ void LoadSaveblockObjEventScripts(void)
savObjTemplates[i].script = mapHeaderObjTemplates[i].script;
}
void Overworld_SetObjEventTemplateCoords(u8 localId, s16 x, s16 y)
void SetObjEventTemplateCoords(u8 localId, s16 x, s16 y)
{
s32 i;
struct ObjectEventTemplate *savObjTemplates = gSaveBlock1Ptr->objectEventTemplates;
@ -512,7 +508,7 @@ void Overworld_SetObjEventTemplateCoords(u8 localId, s16 x, s16 y)
}
}
void Overworld_SetObjEventTemplateMovementType(u8 localId, u8 movementType)
void SetObjEventTemplateMovementType(u8 localId, u8 movementType)
{
s32 i;
@ -570,9 +566,9 @@ static void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId
static bool32 IsDummyWarp(struct WarpData *warp)
{
if (warp->mapGroup != -1)
if (warp->mapGroup != (s8)MAP_GROUP(UNDEFINED))
return FALSE;
else if (warp->mapNum != -1)
else if (warp->mapNum != (s8)MAP_NUM(UNDEFINED))
return FALSE;
else if (warp->warpId != -1)
return FALSE;
@ -978,14 +974,14 @@ void SetDefaultFlashLevel(void)
gSaveBlock1Ptr->flashLevel = gMaxFlashLevel - 1;
}
void Overworld_SetFlashLevel(s32 flashLevel)
void SetFlashLevel(s32 flashLevel)
{
if (flashLevel < 0 || flashLevel > gMaxFlashLevel)
flashLevel = 0;
gSaveBlock1Ptr->flashLevel = flashLevel;
}
u8 Overworld_GetFlashLevel(void)
u8 GetFlashLevel(void)
{
return gSaveBlock1Ptr->flashLevel;
}
@ -1790,7 +1786,7 @@ static void InitCurrentFlashLevelScanlineEffect(void)
WriteBattlePyramidViewScanlineEffectBuffer();
ScanlineEffect_SetParams(sFlashEffectParams);
}
else if ((flashLevel = Overworld_GetFlashLevel()))
else if ((flashLevel = GetFlashLevel()))
{
WriteFlashScanlineEffectBuffer(flashLevel);
ScanlineEffect_SetParams(sFlashEffectParams);

View File

@ -58,11 +58,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[];
@ -612,9 +612,7 @@ bool8 ScrCmd_animateflash(struct ScriptContext *ctx)
bool8 ScrCmd_setflashradius(struct ScriptContext *ctx)
{
u16 flashLevel = VarGet(ScriptReadHalfword(ctx));
Overworld_SetFlashLevel(flashLevel);
SetFlashLevel(VarGet(ScriptReadHalfword(ctx)));
return FALSE;
}
@ -668,9 +666,7 @@ bool8 ScrCmd_fadescreenswapbuffers(struct ScriptContext *ctx)
static bool8 RunPauseTimer(void)
{
sPauseCounter--;
if (sPauseCounter == 0)
if (--sPauseCounter == 0)
return TRUE;
else
return FALSE;
@ -945,9 +941,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 +1014,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 +1023,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 +1032,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 +1097,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;
}
@ -1178,7 +1174,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 +1307,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;
}
@ -1528,13 +1524,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;
}
@ -1933,7 +1929,7 @@ 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;
@ -2230,9 +2226,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 +2238,6 @@ bool8 ScrCmd_gotoram(struct ScriptContext *ctx)
return FALSE;
}
// Unused
// For the warp used by the Aqua Hideout, see DoTeleportTileWarp
bool8 ScrCmd_warpspinenter(struct ScriptContext *ctx)
{
@ -2273,8 +2266,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)

View File

@ -3,6 +3,7 @@
#include "event_data.h"
#include "mystery_gift.h"
#include "util.h"
#include "constants/event_objects.h"
#include "constants/maps.h"
#include "constants/map_scripts.h"
@ -399,6 +400,8 @@ const u8 *GetRamScript(u8 objectId, const u8 *script)
}
}
#define NO_OBJECT OBJ_EVENT_ID_PLAYER
bool32 ValidateSavedRamScript(void)
{
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
@ -408,7 +411,7 @@ bool32 ValidateSavedRamScript(void)
return FALSE;
if (scriptData->mapNum != MAP_NUM(UNDEFINED))
return FALSE;
if (scriptData->objectId != 0xFF)
if (scriptData->objectId != NO_OBJECT)
return FALSE;
if (CalculateRamScriptChecksum() != gSaveBlock1Ptr->ramScript.checksum)
return FALSE;
@ -426,7 +429,7 @@ u8 *GetSavedRamScriptIfValid(void)
return NULL;
if (scriptData->mapNum != MAP_NUM(UNDEFINED))
return NULL;
if (scriptData->objectId != 0xFF)
if (scriptData->objectId != NO_OBJECT)
return NULL;
if (CalculateRamScriptChecksum() != gSaveBlock1Ptr->ramScript.checksum)
{
@ -443,5 +446,5 @@ void InitRamScript_NoObjectEvent(u8 *script, u16 scriptSize)
{
if (scriptSize > sizeof(gSaveBlock1Ptr->ramScript.data.script))
scriptSize = sizeof(gSaveBlock1Ptr->ramScript.data.script);
InitRamScript(script, scriptSize, MAP_GROUP(UNDEFINED), MAP_NUM(UNDEFINED), 0xFF);
InitRamScript(script, scriptSize, MAP_GROUP(UNDEFINED), MAP_NUM(UNDEFINED), NO_OBJECT);
}