Add typedefs for MAPSEC and METLOC values (#2183)

Added typedefs: mapsec_t, metloc_t, and variants for MAPSEC and METLOC values. There are some rough edges that could do with smoothing out, but for now, this gets us close to ideal with a ROM that compares equal.

Per feedback, all typedefs to mention the underlying type within the typedef name. The documentation comments reflect and explain the naming convention.

Updated comments to reflect the fact that we're no longer using SET8 for a Pokemon's met locations, in favor of a new macro (added by this PR) that adjusts to match the width of whatever is being set.
This commit is contained in:
DavidJCobb authored and GitHub committed 2025-10-19 17:37:13 +01:00
1 parent 0965dffe70
commit 7fd0029ed7
26 files changed
+185 -102

No files matched your search

+29 -29
View File
@@ -63,7 +63,7 @@ enum {
struct MultiNameFlyDest
{
const u8 *const *name;
u16 mapSecId;
mapsec_u16_t mapSecId;
u16 flag;
};
@@ -72,7 +72,7 @@ static EWRAM_DATA struct RegionMap *sRegionMap = NULL;
static EWRAM_DATA struct {
void (*callback)(void);
u16 state;
u16 mapSecId;
mapsec_u16_t mapSecId;
struct RegionMap regionMap;
u8 tileBuffer[0x1c0];
u8 nameBuffer[0x26]; // never read
@@ -86,15 +86,15 @@ static u8 MoveRegionMapCursor_Full(void);
static u8 ProcessRegionMapInput_Zoomed(void);
static u8 MoveRegionMapCursor_Zoomed(void);
static void CalcZoomScrollParams(s16 scrollX, s16 scrollY, s16 c, s16 d, u16 e, u16 f, u8 rotation);
static u16 GetMapSecIdAt(u16 x, u16 y);
static mapsec_u16_t GetMapSecIdAt(u16 x, u16 y);
static void RegionMap_SetBG2XAndBG2Y(s16 x, s16 y);
static void InitMapBasedOnPlayerLocation(void);
static void RegionMap_InitializeStateBasedOnSSTidalLocation(void);
static u8 GetMapsecType(u16 mapSecId);
static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId);
static u16 GetTerraOrMarineCaveMapSecId(void);
static u8 GetMapsecType(mapsec_u16_t mapSecId);
static mapsec_u16_t CorrectSpecialMapSecId_Internal(mapsec_u16_t mapSecId);
static mapsec_u16_t GetTerraOrMarineCaveMapSecId(void);
static void GetMarineCaveCoords(u16 *x, u16 *y);
static bool32 IsPlayerInAquaHideout(u8 mapSecId);
static bool32 IsPlayerInAquaHideout(mapsec_u8_t mapSecId);
static void GetPositionOfCursorWithinMapSec(void);
static bool8 RegionMap_IsMapSecIdInNextRow(u16 y);
static void SpriteCB_CursorMapFull(struct Sprite *sprite);
@@ -130,7 +130,7 @@ static const u8 sRegionMapPlayerIcon_MayGfx[] = INCBIN_U8("graphics/pokenav/regi
#include "data/region_map/region_map_layout.h"
#include "data/region_map/region_map_entries.h"
static const u16 sRegionMap_SpecialPlaceLocations[][2] =
static const mapsec_u16_t sRegionMap_SpecialPlaceLocations[][2] =
{
{MAPSEC_UNDERWATER_105, MAPSEC_ROUTE_105},
{MAPSEC_UNDERWATER_124, MAPSEC_ROUTE_124},
@@ -162,14 +162,14 @@ static const u16 sRegionMap_SpecialPlaceLocations[][2] =
{MAPSEC_NONE, MAPSEC_NONE}
};
static const u16 sMarineCaveMapSecIds[] =
static const mapsec_u16_t sMarineCaveMapSecIds[] =
{
MAPSEC_MARINE_CAVE,
MAPSEC_UNDERWATER_MARINE_CAVE,
MAPSEC_UNDERWATER_MARINE_CAVE
};
static const u16 sTerraOrMarineCaveMapSecIds[ABNORMAL_WEATHER_LOCATIONS] =
static const mapsec_u16_t sTerraOrMarineCaveMapSecIds[ABNORMAL_WEATHER_LOCATIONS] =
{
[ABNORMAL_WEATHER_ROUTE_114_NORTH - 1] = MAPSEC_ROUTE_114,
[ABNORMAL_WEATHER_ROUTE_114_SOUTH - 1] = MAPSEC_ROUTE_114,
@@ -203,7 +203,7 @@ static const struct UCoords16 sMarineCaveLocationCoords[MARINE_CAVE_LOCATIONS] =
[MARINE_CAVE_COORD(ROUTE_129_EAST)] = {24, 10}
};
static const u8 sMapSecAquaHideoutOld[] =
static const mapsec_u8_t sMapSecAquaHideoutOld[] =
{
MAPSEC_AQUA_HIDEOUT_OLD
};
@@ -273,7 +273,7 @@ static const union AnimCmd *const sRegionMapPlayerIconAnimTable[] =
};
// Event islands that don't appear on map. (Southern Island does)
static const u8 sMapSecIdsOffMap[] =
static const mapsec_u8_t sMapSecIdsOffMap[] =
{
MAPSEC_BIRTH_ISLAND,
MAPSEC_FARAWAY_ISLAND,
@@ -421,7 +421,7 @@ static const struct SpritePalette sFlyTargetIconsSpritePalette =
.tag = TAG_FLY_ICON
};
static const u16 sRedOutlineFlyDestinations[][2] =
static const mapsec_u16_t sRedOutlineFlyDestinations[][2] =
{
{
FLAG_LANDMARK_BATTLE_FRONTIER,
@@ -690,7 +690,7 @@ static u8 ProcessRegionMapInput_Full(void)
static u8 MoveRegionMapCursor_Full(void)
{
u16 mapSecId;
mapsec_u16_t mapSecId;
if (sRegionMap->cursorMovementFrameCounter != 0)
return MAP_INPUT_MOVE_CONT;
@@ -771,7 +771,7 @@ static u8 MoveRegionMapCursor_Zoomed(void)
{
u16 x;
u16 y;
u16 mapSecId;
mapsec_u16_t mapSecId;
sRegionMap->scrollY += sRegionMap->zoomedCursorDeltaY;
sRegionMap->scrollX += sRegionMap->zoomedCursorDeltaX;
@@ -954,7 +954,7 @@ void PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(s16 x, s16 y)
}
}
static u16 GetMapSecIdAt(u16 x, u16 y)
static mapsec_u16_t GetMapSecIdAt(u16 x, u16 y)
{
if (y < MAPCURSOR_Y_MIN || y > MAPCURSOR_Y_MAX || x < MAPCURSOR_X_MIN || x > MAPCURSOR_X_MAX)
{
@@ -1172,7 +1172,7 @@ static void RegionMap_InitializeStateBasedOnSSTidalLocation(void)
sRegionMap->cursorPosY = gRegionMapEntries[sRegionMap->mapSecId].y + y + MAPCURSOR_Y_MIN;
}
static u8 GetMapsecType(u16 mapSecId)
static u8 GetMapsecType(mapsec_u16_t mapSecId)
{
switch (mapSecId)
{
@@ -1219,12 +1219,12 @@ static u8 GetMapsecType(u16 mapSecId)
}
}
u16 GetRegionMapSecIdAt(u16 x, u16 y)
mapsec_u16_t GetRegionMapSecIdAt(u16 x, u16 y)
{
return GetMapSecIdAt(x, y);
}
static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId)
static mapsec_u16_t CorrectSpecialMapSecId_Internal(mapsec_u16_t mapSecId)
{
u32 i;
@@ -1245,7 +1245,7 @@ static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId)
return mapSecId;
}
static u16 GetTerraOrMarineCaveMapSecId(void)
static mapsec_u16_t GetTerraOrMarineCaveMapSecId(void)
{
s16 idx;
@@ -1274,7 +1274,7 @@ static void GetMarineCaveCoords(u16 *x, u16 *y)
// Probably meant to be an "IsPlayerInIndoorDungeon" function, but in practice it only has the one mapsec
// Additionally, because the mapsec doesnt exist in Emerald, this function always returns FALSE
static bool32 IsPlayerInAquaHideout(u8 mapSecId)
static bool32 IsPlayerInAquaHideout(mapsec_u8_t mapSecId)
{
u32 i;
@@ -1286,7 +1286,7 @@ static bool32 IsPlayerInAquaHideout(u8 mapSecId)
return FALSE;
}
u16 CorrectSpecialMapSecId(u16 mapSecId)
mapsec_u16_t CorrectSpecialMapSecId(mapsec_u16_t mapSecId)
{
return CorrectSpecialMapSecId_Internal(mapSecId);
}
@@ -1565,7 +1565,7 @@ void TrySetPlayerIconBlink(void)
#undef sVisible
#undef sTimer
u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength)
u8 *GetMapName(u8 *dest, mapsec_u16_t regionMapId, u16 padLength)
{
u8 *str;
u16 i;
@@ -1598,7 +1598,7 @@ u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength)
}
// TODO: probably needs a better name
u8 *GetMapNameGeneric(u8 *dest, u16 mapSecId)
u8 *GetMapNameGeneric(u8 *dest, mapsec_u16_t mapSecId)
{
switch (mapSecId)
{
@@ -1611,7 +1611,7 @@ u8 *GetMapNameGeneric(u8 *dest, u16 mapSecId)
}
}
u8 *GetMapNameHandleAquaHideout(u8 *dest, u16 mapSecId)
u8 *GetMapNameHandleAquaHideout(u8 *dest, mapsec_u16_t mapSecId)
{
if (mapSecId == MAPSEC_AQUA_HIDEOUT_OLD)
return StringCopy(dest, gText_Hideout);
@@ -1619,7 +1619,7 @@ u8 *GetMapNameHandleAquaHideout(u8 *dest, u16 mapSecId)
return GetMapNameGeneric(dest, mapSecId);
}
static void GetMapSecDimensions(u16 mapSecId, u16 *x, u16 *y, u16 *width, u16 *height)
static void GetMapSecDimensions(mapsec_u16_t mapSecId, u16 *x, u16 *y, u16 *width, u16 *height)
{
*x = gRegionMapEntries[mapSecId].x;
*y = gRegionMapEntries[mapSecId].y;
@@ -1632,7 +1632,7 @@ bool8 IsRegionMapZoomed(void)
return sRegionMap->zoomed;
}
bool32 IsEventIslandMapSecId(u8 mapSecId)
bool32 IsEventIslandMapSecId(mapsec_u8_t mapSecId)
{
u32 i;
@@ -1839,7 +1839,7 @@ static void LoadFlyDestIcons(void)
static void CreateFlyDestIcons(void)
{
u16 canFlyFlag;
u16 mapSecId;
mapsec_u16_t mapSecId;
u16 x;
u16 y;
u16 width;
@@ -1887,7 +1887,7 @@ static void TryCreateRedOutlineFlyDestIcons(void)
u16 y;
u16 width;
u16 height;
u16 mapSecId;
mapsec_u16_t mapSecId;
u8 spriteId;
for (i = 0; sRedOutlineFlyDestinations[i][1] != MAPSEC_NONE; i++)