Merge commit '7fd0029ed7b9a245f866b6a7467f6d0bd7c0f717' into pret-merge

sha1sum changed

 Conflicts:
	include/global.h
	include/overworld.h
	include/pokemon.h
	src/map_name_popup.c
	src/pokedex_area_screen.c
	src/pokemon.c
This commit is contained in:
Hedara 2025-11-01 15:09:20 +01:00
commit dd17524fc9
25 changed files with 183 additions and 100 deletions

67
include/gametypes.h Normal file
View File

@ -0,0 +1,67 @@
#ifndef GUARD_GAMETYPES_H
#define GUARD_GAMETYPES_H
#include "gba/types.h"
//
// This header includes typedefs for fields that commonly appear throughout
// the codebase, and which ROM hacks might benefit from being able to widen.
//
// These typedefs include the underlying type in their name for two reasons:
//
// - Game Freak wasn't fully consistent about field widths throughout
// their codebase. For example, when Region Map Sections are persistently
// stored in savedata, they're stored as 8-bit values; but much of the
// codebase handles them as 16-bit values.
//
// - Although Pokemon Emerald doesn't come close to maxing out RAM, it *does*
// use nearly all of its EEPROM. That is: the vanilla game uses 96% of the
// flash memory available for storing players' save files, leaving 2172
// bytes to spare within each of the game's two save files (primary and
// backup). These spare bytes are not contiguous: SaveBlock1 can only grow
// by 84 bytes, and SaveBlock2 can only grow by 120 bytes, with the rest
// of the free space located after the player's PC-boxed Pokemon.
//
// With so little flash memory to spare, keeping track of how much space
// you're using is vital -- and so is arranging struct members to minimize
// compiler-inserted padding. It's easier to deal with this when you can
// see these types' widths at a glance.
//
// Accordingly, this file generally doesn't contain just single types, but
// rather families of types. For example, Region Map Sections are saved as
// u8s within the player's save file, but are sometimes handled as u16s or
// even s16s and ints; and so there are multiple typedefs for Map Sections
// corresponding to each of these underlying types, and each typedef has a
// name which indicates the underlying type.
//
// For a given family of typedefs, the smallest one should be considered
// the "real" or "canonical" type. Continuing with Map Sections as our
// example, the smallest type is an 8-bit integer, and so any values that
// can't fit in an 8-bit integer will be truncated and lost at some point
// within the codebase. Therefore mapsec_u8_t is the "canonical" type for
// Map Sections, and the larger typedefs just exist to describe situations
// where the game handles Map Sections inconsistently with that "canon."
//
// Map Sections are named areas that can appear in the region map. Each
// individual map can be assigned to a Map Section as appropriate. The
// possible values are in constants/region_map_sections.h.
//
// If you choose to widen Map Sections, be aware that Met Locations (below)
// are based on Map Sections and will also be widened.
typedef u8 mapsec_u8_t;
typedef u16 mapsec_u16_t;
typedef s16 mapsec_s16_t;
typedef s32 mapsec_s32_t;
// Met Locations for caught Pokemon use the same values as Map Sections,
// except that 0xFD, 0xFE, and 0xFF have special meanings.
//
// Because this value appears inside every Pokemon's data, widening it will
// consume a lot more space within flash memory. The space usage will be
// greater than you expect due to how Pokemon substructs are laid out; you
// would have to rearrange the substructs' contents in order to minimize
// how much more space a wider Met Location would consume.
typedef mapsec_u8_t metloc_u8_t;
#endif //GUARD_GAMETYPES_H

View File

@ -169,7 +169,7 @@ struct MapHeader
/* 0x0C */ const struct MapConnections *connections;
/* 0x10 */ u16 music;
/* 0x12 */ u16 mapLayoutId;
/* 0x14 */ u8 regionMapSectionId;
/* 0x14 */ mapsec_u8_t regionMapSectionId;
/* 0x15 */ u8 cave;
/* 0x16 */ u8 weather;
/* 0x17 */ u8 mapType;

View File

@ -5,6 +5,7 @@
#include <limits.h>
#include "config/general.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines.
#include "gba/gba.h"
#include "gametypes.h"
#include "siirtc.h"
#include "fpmath.h"
#include "metaprogram.h"

View File

@ -226,7 +226,7 @@ typedef union // size = 0x24
/*0x04*/ u8 filler_04[2];
/*0x06*/ u16 itemIds[SMARTSHOPPER_NUM_ITEMS];
/*0x0C*/ u16 itemAmounts[SMARTSHOPPER_NUM_ITEMS];
/*0x12*/ u8 shopLocation;
/*0x12*/ mapsec_u8_t shopLocation;
/*0x13*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
/*0x1B*/ //u8 padding;
} smartshopperShow;
@ -241,7 +241,7 @@ typedef union // size = 0x24
/*0x0E*/ u16 species2;
/*0x10*/ u8 nBallsUsed;
/*0x11*/ u8 outcome;
/*0x12*/ u8 location;
/*0x12*/ mapsec_u8_t location;
/*0x13*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
/*0x1B*/ //u8 padding;
} pokemonTodayFailed;
@ -267,7 +267,7 @@ typedef union // size = 0x24
/*0x04*/ u16 caughtPoke;
/*0x06*/ u16 steps;
/*0x08*/ u16 species;
/*0x0A*/ u8 location;
/*0x0A*/ mapsec_u8_t location;
/*0x0B*/ u8 language;
/*0x0C*/ u8 filler_0C[7];
/*0x13*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
@ -282,7 +282,7 @@ typedef union // size = 0x24
/*0x04*/ u8 badgeCount;
/*0x05*/ u8 nSilverSymbols;
/*0x06*/ u8 nGoldSymbols;
/*0x07*/ u8 location;
/*0x07*/ mapsec_u8_t location;
/*0x08*/ u16 battlePoints;
/*0x0A*/ u16 mapLayoutId;
/*0x0C*/ u8 language;
@ -309,7 +309,7 @@ typedef union // size = 0x24
/*0x00*/ u8 kind;
/*0x01*/ bool8 active;
/*0x02*/ u16 item;
/*0x04*/ u8 location;
/*0x04*/ mapsec_u8_t location;
/*0x05*/ u8 language;
/*0x06*/ u16 mapLayoutId;
/*0x08*/ u8 filler_08[11];
@ -336,7 +336,7 @@ typedef union // size = 0x24
/*0x00*/ u8 kind;
/*0x01*/ bool8 active;
/*0x02*/ u16 lastOpponentSpecies;
/*0x04*/ u8 location;
/*0x04*/ mapsec_u8_t location;
/*0x05*/ u8 outcome;
/*0x06*/ u16 caughtMonBall;
/*0x08*/ u16 balls;
@ -505,7 +505,7 @@ struct GabbyAndTyData
/*2BA6*/ u16 mon2;
/*2BA8*/ u16 lastMove;
/*2BAA*/ u16 quote[1];
/*2BAC*/ u8 mapnum;
/*2BAC*/ mapsec_u8_t mapnum;
/*2BAD*/ u8 battleNum;
/*2BAE*/ u8 battleTookMoreThanOneTurn:1;
u8 playerLostAMon:1;

View File

@ -1,6 +1,6 @@
#ifndef GUARD_LANDMARK_H
#define GUARD_LANDMARK_H
const u8 *GetLandmarkName(u8 mapSection, u8 id, u8 count);
const u8 *GetLandmarkName(mapsec_u8_t mapSection, u8 id, u8 count);
#endif // GUARD_LANDMARK_H

View File

@ -135,8 +135,8 @@ enum MapType GetLastUsedWarpMapType(void);
bool8 IsMapTypeOutdoors(enum MapType mapType);
bool8 Overworld_MapTypeAllowsTeleportAndFly(enum MapType mapType);
bool8 IsMapTypeIndoors(enum MapType mapType);
u8 GetSavedWarpRegionMapSectionId(void);
u8 GetCurrentRegionMapSectionId(void);
mapsec_u8_t GetSavedWarpRegionMapSectionId(void);
mapsec_u8_t GetCurrentRegionMapSectionId(void);
enum MapBattleScene GetCurrentMapBattleScene(void);
void CleanupOverworldWindowsAndTilemaps(void);
bool32 IsOverworldLinkActive(void);

View File

@ -17,7 +17,7 @@ struct PokenavMonListItem
struct PokenavMatchCallEntry
{
bool8 isSpecialTrainer;
u8 mapSec;
mapsec_u8_t mapSec;
u16 headerId;
};
@ -413,7 +413,7 @@ void FreeMatchCallSubstruct1(void);
int IsMatchCallListInitFinished(void);
int GetNumberRegistered(void);
struct PokenavMatchCallEntry *GetMatchCallList(void);
u16 GetMatchCallMapSec(int index);
mapsec_u16_t GetMatchCallMapSec(int index);
bool32 ShouldDrawRematchPokeballIcon(int index);
void ClearRematchPokeballIcon(u16 windowId, u32 tileOffset);
int GetMatchCallTrainerPic(int index);
@ -422,7 +422,7 @@ const u8 *GetMatchCallMessageText(int index, bool8 *newRematchRequest);
u16 GetMatchCallOptionCursorPos(void);
u16 GetMatchCallOptionId(int optionId);
void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry *matchCallEntry, u8 *str);
u8 GetMatchTableMapSectionId(int rematchIndex);
mapsec_u8_t GetMatchTableMapSectionId(int rematchIndex);
int GetIndexDeltaOfNextCheckPageDown(int index);
int GetIndexDeltaOfNextCheckPageUp(int index);
bool32 IsRematchEntryRegistered(int rematchIndex);

View File

@ -27,7 +27,7 @@ enum {
};
struct RegionMap {
/*0x000*/ u16 mapSecId;
/*0x000*/ mapsec_u16_t mapSecId;
/*0x002*/ u8 mapSecType;
/*0x003*/ u8 posWithinMapSec;
/*0x004*/ u8 mapSecName[20];
@ -100,14 +100,14 @@ void InitRegionMap(struct RegionMap *regionMap, bool8 zoomed);
u8 DoRegionMapInputCallback(void);
bool8 UpdateRegionMapZoom(void);
void FreeRegionMapIconResources(void);
u16 GetRegionMapSecIdAt(u16 x, u16 y);
mapsec_u16_t GetRegionMapSecIdAt(u16 x, u16 y);
void CreateRegionMapPlayerIcon(u16 tileTag, u16 paletteTag);
void CreateRegionMapCursor(u16 tileTag, u16 paletteTag);
bool32 IsEventIslandMapSecId(u8 mapSecId);
u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength);
u8 *GetMapNameGeneric(u8 *dest, u16 mapSecId);
u8 *GetMapNameHandleAquaHideout(u8 *dest, u16 mapSecId);
u16 CorrectSpecialMapSecId(u16 mapSecId);
bool32 IsEventIslandMapSecId(mapsec_u8_t mapSecId);
u8 *GetMapName(u8 *dest, mapsec_u16_t regionMapId, u16 padLength);
u8 *GetMapNameGeneric(u8 *dest, mapsec_u16_t mapSecId);
u8 *GetMapNameHandleAquaHideout(u8 *dest, mapsec_u16_t mapSecId);
mapsec_u16_t CorrectSpecialMapSecId(mapsec_u16_t mapSecId);
void ShowRegionMapForPokedexAreaScreen(struct RegionMap *regionMap);
void PokedexAreaScreen_UpdateRegionMapVariablesAndVideoRegs(s16 x, s16 y);
void CB2_OpenFlyMap(void);

View File

@ -1,4 +1,4 @@
static const u8 sRegionMap_MapSectionLayout[MAP_HEIGHT][MAP_WIDTH] = {
static const mapsec_u8_t sRegionMap_MapSectionLayout[MAP_HEIGHT][MAP_WIDTH] = {
{MAPSEC_NONE, MAPSEC_ROUTE_114, MAPSEC_ROUTE_114, MAPSEC_FALLARBOR_TOWN, MAPSEC_ROUTE_113, MAPSEC_ROUTE_113, MAPSEC_ROUTE_113, MAPSEC_ROUTE_113, MAPSEC_ROUTE_111, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_ROUTE_119, MAPSEC_FORTREE_CITY, MAPSEC_ROUTE_120, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE},
{MAPSEC_NONE, MAPSEC_ROUTE_114, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_MT_CHIMNEY, MAPSEC_MT_CHIMNEY, MAPSEC_ROUTE_111, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_ROUTE_119, MAPSEC_NONE, MAPSEC_ROUTE_120, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE},
{MAPSEC_ROUTE_115, MAPSEC_ROUTE_114, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_MT_CHIMNEY, MAPSEC_MT_CHIMNEY, MAPSEC_ROUTE_111, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_ROUTE_119, MAPSEC_NONE, MAPSEC_ROUTE_120, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_SAFARI_ZONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE, MAPSEC_NONE},

View File

@ -1107,7 +1107,7 @@ void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation)
u8 metLevel;
enum PokeBall ball;
u8 language;
u8 metLocation;
metloc_u8_t metLocation;
u8 isEgg;
CreateMon(mon, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0);

View File

@ -365,7 +365,7 @@ static void AddHatchedMonToParty(u8 id)
enum NationalDexOrder species;
u8 name[POKEMON_NAME_LENGTH + 1];
u16 metLevel;
u8 metLocation;
metloc_u8_t metLocation;
struct Pokemon *mon = &gPlayerParty[id];
CreateHatchedMon(mon, &gEnemyParty[0]);

View File

@ -606,7 +606,9 @@ static void LeaveFrontierPass(void)
static u32 AllocateFrontierPassData(MainCallback callback)
{
u8 i;
// This variable is a MAPSEC initially, but is recycled as a
// bare integer near the end of the function.
mapsec_u8_t i;
if (sPassData != NULL)
return ERR_ALREADY_DONE;

View File

@ -10,7 +10,7 @@ struct Landmark
struct LandmarkList
{
u8 mapSection;
mapsec_u8_t mapSection;
u8 id;
const struct Landmark *const *landmarks;
};
@ -392,9 +392,9 @@ static const struct LandmarkList sLandmarkLists[] =
{MAPSEC_NONE, 0, NULL},
};
static const struct Landmark *const *GetLandmarks(u8 mapSection, u8 id);
static const struct Landmark *const *GetLandmarks(mapsec_u8_t mapSection, u8 id);
const u8 *GetLandmarkName(u8 mapSection, u8 id, u8 count)
const u8 *GetLandmarkName(mapsec_u8_t mapSection, u8 id, u8 count)
{
const struct Landmark *const *landmarks = GetLandmarks(mapSection, id);
@ -421,7 +421,7 @@ const u8 *GetLandmarkName(u8 mapSection, u8 id, u8 count)
return (*landmarks)->name;
}
static const struct Landmark *const *GetLandmarks(u8 mapSection, u8 id)
static const struct Landmark *const *GetLandmarks(mapsec_u8_t mapSection, u8 id)
{
u16 i = 0;

View File

@ -615,7 +615,7 @@ static void LoadMapNamePopUpWindowBg(void)
{
u8 popUpThemeId;
u8 popupWindowId = GetMapNamePopUpWindowId();
u16 regionMapSectionId = gMapHeader.regionMapSectionId;
mapsec_u16_t regionMapSectionId = gMapHeader.regionMapSectionId;
u8 secondaryPopUpWindowId;
if (OW_POPUP_GENERATION == GEN_5)

View File

@ -135,7 +135,7 @@ static u32 GetCurrentTotalMinutes(struct Time *);
static u32 GetNumRegisteredTrainers(void);
static u32 GetActiveMatchCallTrainerId(u32);
static int GetTrainerMatchCallId(int);
static u16 GetRematchTrainerLocation(int);
static mapsec_u16_t GetRematchTrainerLocation(int);
static bool32 TrainerIsEligibleForRematch(int);
static void StartMatchCall(void);
static void ExecuteMatchCall(u8);
@ -1468,7 +1468,7 @@ static bool32 TrainerIsEligibleForRematch(int matchCallId)
#endif //FREE_MATCH_CALL
}
static u16 GetRematchTrainerLocation(int matchCallId)
static mapsec_u16_t GetRematchTrainerLocation(int matchCallId)
{
const struct MapHeader *mapHeader = Overworld_GetMapHeaderByGroupAndId(gRematchTable[matchCallId].mapGroup, gRematchTable[matchCallId].mapNum);
return mapHeader->regionMapSectionId;

View File

@ -211,7 +211,7 @@ EWRAM_DATA struct WarpData gLastUsedWarp = {0};
EWRAM_DATA static struct WarpData sWarpDestination = {0}; // new warp position
EWRAM_DATA static struct WarpData sFixedDiveWarp = {0};
EWRAM_DATA static struct WarpData sFixedHoleWarp = {0};
EWRAM_DATA static u16 sLastMapSectionId = 0;
EWRAM_DATA static mapsec_u16_t sLastMapSectionId = 0;
EWRAM_DATA static struct InitialPlayerAvatarState sInitialPlayerAvatarState = {0};
EWRAM_DATA static u16 sAmbientCrySpecies = 0;
EWRAM_DATA static bool8 sIsAmbientCryWaterMon = FALSE;
@ -1464,12 +1464,12 @@ bool8 IsMapTypeIndoors(enum MapType mapType)
return FALSE;
}
u8 GetSavedWarpRegionMapSectionId(void)
mapsec_u8_t GetSavedWarpRegionMapSectionId(void)
{
return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->dynamicWarp.mapGroup, gSaveBlock1Ptr->dynamicWarp.mapNum)->regionMapSectionId;
}
u8 GetCurrentRegionMapSectionId(void)
mapsec_u8_t GetCurrentRegionMapSectionId(void)
{
return Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum)->regionMapSectionId;
}

View File

@ -75,7 +75,7 @@ struct OverworldArea
{
u8 mapGroup;
u8 mapNum;
u16 regionMapSectionId;
mapsec_u16_t regionMapSectionId;
};
struct
@ -96,7 +96,7 @@ struct
/*0x61C*/ u16 areaShadeBldArgHi;
/*0x61E*/ bool8 showingMarkers;
/*0x61F*/ u8 markerFlashCounter;
/*0x620*/ u16 specialAreaRegionMapSectionIds[MAX_AREA_MARKERS];
/*0x620*/ mapsec_u16_t specialAreaRegionMapSectionIds[MAX_AREA_MARKERS];
/*0x660*/ struct Sprite *areaMarkerSprites[MAX_AREA_MARKERS];
/*0x6E0*/ u16 numAreaMarkerSprites;
/*0x6E2*/ u16 alteringCaveCounter;
@ -116,7 +116,7 @@ static void FindMapsWithMon(u16);
static void BuildAreaGlowTilemap(void);
static void SetAreaHasMon(u16, u16);
static void SetSpecialMapHasMon(u16, u16);
static u16 GetRegionMapSectionId(u8, u8);
static mapsec_u16_t GetRegionMapSectionId(u8, u8);
static bool8 MapHasSpecies(const struct WildEncounterTypes *, u16);
static bool8 MonListHasSpecies(const struct WildPokemonInfo *, u16, u16);
static void DoAreaGlow(void);
@ -144,7 +144,7 @@ static void LoadHGSSScreenSelectBarSubmenu(void);
static const u16 sSpeciesHiddenFromAreaScreen[] = { SPECIES_WYNAUT };
static const u16 sMovingRegionMapSections[3] =
static const mapsec_u16_t sMovingRegionMapSections[3] =
{
MAPSEC_MARINE_CAVE,
MAPSEC_UNDERWATER_MARINE_CAVE,
@ -157,7 +157,7 @@ static const u16 sFeebasData[][3] =
{NUM_SPECIES}
};
static const u16 sLandmarkData[][2] =
static const mapsec_u16_t sLandmarkData[][2] =
{
{MAPSEC_SKY_PILLAR, FLAG_LANDMARK_SKY_PILLAR},
{MAPSEC_SEAFLOOR_CAVERN, FLAG_LANDMARK_SEAFLOOR_CAVERN},
@ -389,7 +389,7 @@ static void SetSpecialMapHasMon(u16 mapGroup, u16 mapNum)
if (sPokedexAreaScreen->numSpecialAreas < MAX_AREA_MARKERS)
{
u16 regionMapSectionId = GetRegionMapSectionId(mapGroup, mapNum);
mapsec_u16_t regionMapSectionId = GetRegionMapSectionId(mapGroup, mapNum);
if (regionMapSectionId < MAPSEC_NONE)
{
// Don't highlight the area if it's a moving area (Marine/Terra Cave)
@ -423,7 +423,7 @@ static void SetSpecialMapHasMon(u16 mapGroup, u16 mapNum)
}
}
static u16 GetRegionMapSectionId(u8 mapGroup, u8 mapNum)
static mapsec_u16_t GetRegionMapSectionId(u8 mapGroup, u8 mapNum)
{
return Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum)->regionMapSectionId;
}
@ -947,7 +947,7 @@ static void CreateAreaMarkerSprites(void)
s16 x;
s16 y;
s16 i;
s16 mapSecId;
mapsec_u16_t mapSecId;
s16 numSprites;
LoadSpriteSheet(&sAreaMarkerSpriteSheet);

View File

@ -2842,6 +2842,19 @@ u32 GetBoxMonData2(struct BoxPokemon *boxMon, s32 field)
#define SET8(lhs) (lhs) = *data
#define SET16(lhs) (lhs) = data[0] + (data[1] << 8)
#define SET32(lhs) (lhs) = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24)
//
// Prefer SET_BY_WIDTH for fields whose types might be extended (e.g.
// anything whose typedef is in gametypes.h).
//
#define SET_BY_WIDTH(lhs) \
do { \
if (sizeof(lhs) == 1) \
SET8(lhs); \
else if (sizeof(lhs) == 2) \
SET16(lhs); \
else if (sizeof(lhs) == 4) \
SET32(lhs); \
} while (0)
void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg)
{

View File

@ -142,7 +142,7 @@ static EWRAM_DATA struct PokemonSummaryScreenData
u8 ribbonCount; // 0x6
u8 ailment; // 0x7
u8 abilityNum; // 0x8
u8 metLocation; // 0x9
metloc_u8_t metLocation; // 0x9
u8 metLevel; // 0xA
u8 metGame; // 0xB
u32 pid; // 0xC

View File

@ -34,13 +34,13 @@ typedef struct MatchCallTextDataStruct {
struct MatchCallStructCommon {
u8 type;
u8 mapSec;
mapsec_u8_t mapSec;
u16 flag;
};
struct MatchCallStructNPC {
u8 type;
u8 mapSec;
mapsec_u8_t mapSec;
u16 flag;
const u8 *desc;
const u8 *name;
@ -50,7 +50,7 @@ struct MatchCallStructNPC {
// Shared by MC_TYPE_TRAINER and MC_TYPE_LEADER
struct MatchCallStructTrainer {
u8 type;
u8 mapSec;
mapsec_u8_t mapSec;
u16 flag;
u16 rematchTableIdx;
const u8 *desc;
@ -60,12 +60,12 @@ struct MatchCallStructTrainer {
struct MatchCallLocationOverride {
u16 flag;
u8 mapSec;
mapsec_u8_t mapSec;
};
struct MatchCallWally {
u8 type;
u8 mapSec;
mapsec_u8_t mapSec;
u16 flag;
u16 rematchTableIdx;
const u8 *desc;
@ -75,7 +75,7 @@ struct MatchCallWally {
struct MatchCallBirch {
u8 type;
u8 mapSec;
mapsec_u8_t mapSec;
u16 flag;
const u8 *desc;
const u8 *name;
@ -117,11 +117,11 @@ static bool32 MatchCall_GetEnabled_Wally(match_call_t);
static bool32 MatchCall_GetEnabled_Birch(match_call_t);
static bool32 MatchCall_GetEnabled_Rival(match_call_t);
static u8 MatchCall_GetMapSec_NPC(match_call_t);
static u8 MatchCall_GetMapSec_Trainer(match_call_t);
static u8 MatchCall_GetMapSec_Wally(match_call_t);
static u8 MatchCall_GetMapSec_Birch(match_call_t);
static u8 MatchCall_GetMapSec_Rival(match_call_t);
static mapsec_u8_t MatchCall_GetMapSec_NPC(match_call_t);
static mapsec_u8_t MatchCall_GetMapSec_Trainer(match_call_t);
static mapsec_u8_t MatchCall_GetMapSec_Wally(match_call_t);
static mapsec_u8_t MatchCall_GetMapSec_Birch(match_call_t);
static mapsec_u8_t MatchCall_GetMapSec_Rival(match_call_t);
static bool32 MatchCall_IsRematchable_NPC(match_call_t);
static bool32 MatchCall_IsRematchable_Trainer(match_call_t);
@ -613,7 +613,7 @@ static bool32 (*const sMatchCallGetEnabledFuncs[])(match_call_t) = {
MatchCall_GetEnabled_Birch
};
static u8 (*const sMatchCallGetMapSecFuncs[])(match_call_t) = {
static mapsec_u8_t (*const sMatchCallGetMapSecFuncs[])(match_call_t) = {
MatchCall_GetMapSec_NPC,
MatchCall_GetMapSec_Trainer,
MatchCall_GetMapSec_Wally,
@ -796,7 +796,7 @@ static bool32 MatchCall_GetEnabled_Birch(match_call_t matchCall)
return FlagGet(matchCall.birch->flag);
}
u8 MatchCall_GetMapSec(u32 idx)
mapsec_u8_t MatchCall_GetMapSec(u32 idx)
{
match_call_t matchCall;
u32 i;
@ -808,17 +808,17 @@ u8 MatchCall_GetMapSec(u32 idx)
return sMatchCallGetMapSecFuncs[i](matchCall);
}
static u8 MatchCall_GetMapSec_NPC(match_call_t matchCall)
static mapsec_u8_t MatchCall_GetMapSec_NPC(match_call_t matchCall)
{
return matchCall.npc->mapSec;
}
static u8 MatchCall_GetMapSec_Trainer(match_call_t matchCall)
static mapsec_u8_t MatchCall_GetMapSec_Trainer(match_call_t matchCall)
{
return matchCall.trainer->mapSec;
}
static u8 MatchCall_GetMapSec_Wally(match_call_t matchCall)
static mapsec_u8_t MatchCall_GetMapSec_Wally(match_call_t matchCall)
{
s32 i;
@ -830,12 +830,12 @@ static u8 MatchCall_GetMapSec_Wally(match_call_t matchCall)
return matchCall.wally->locationData[i].mapSec;
}
static u8 MatchCall_GetMapSec_Rival(match_call_t matchCall)
static mapsec_u8_t MatchCall_GetMapSec_Rival(match_call_t matchCall)
{
return MAPSEC_NONE;
}
static u8 MatchCall_GetMapSec_Birch(match_call_t matchCall)
static mapsec_u8_t MatchCall_GetMapSec_Birch(match_call_t matchCall)
{
return MAPSEC_NONE;
}

View File

@ -1027,7 +1027,7 @@ static void PrintMatchCallLocation(struct Pokenav_MatchCallGfx *gfx, int delta)
u8 mapName[32];
int x;
int index = PokenavList_GetSelectedIndex() + delta;
int mapSec = GetMatchCallMapSec(index);
mapsec_s32_t mapSec = GetMatchCallMapSec(index);
if (mapSec != MAPSEC_NONE)
GetMapName(mapName, mapSec, 0);
else

View File

@ -308,7 +308,7 @@ struct PokenavMatchCallEntry *GetMatchCallList(void)
return state->matchCallEntries;
}
u16 GetMatchCallMapSec(int index)
mapsec_u16_t GetMatchCallMapSec(int index)
{
struct Pokenav_MatchCallMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_MAIN);
return state->matchCallEntries[index].mapSec;
@ -430,7 +430,7 @@ void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntry *matchCallEntry, u8
}
}
u8 GetMatchTableMapSectionId(int rematchIndex)
mapsec_u8_t GetMatchTableMapSectionId(int rematchIndex)
{
int mapGroup = gRematchTable[rematchIndex].mapGroup;
int mapNum = gRematchTable[rematchIndex].mapNum;

View File

@ -44,7 +44,7 @@ struct Pokenav_RegionMapGfx
struct CityMapEntry
{
u16 mapSecId;
mapsec_u16_t mapSecId;
u16 index;
const u32 *tilemap;
};
@ -66,8 +66,8 @@ static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav_RegionMapGfx *);
static void ChangeBgYForZoom(bool32);
static bool32 IsChangeBgYForZoomActive(void);
static void CreateCityZoomTextSprites(void);
static void DrawCityMap(struct Pokenav_RegionMapGfx *, int, int);
static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *, int, int);
static void DrawCityMap(struct Pokenav_RegionMapGfx *, mapsec_s32_t, int);
static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *, mapsec_s32_t, int);
static void SetCityZoomTextInvisibility(bool32);
static void Task_ChangeBgYForZoom(u8 taskId);
static void UpdateCityZoomTextPosition(void);
@ -664,7 +664,7 @@ static u32 LoopedTask_DecompressCityMaps(s32 taskState)
return LT_FINISH;
}
static void DrawCityMap(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos)
static void DrawCityMap(struct Pokenav_RegionMapGfx *state, mapsec_s32_t mapSecId, int pos)
{
int i;
for (i = 0; i < NUM_CITY_MAPS && (sPokenavCityMaps[i].mapSecId != mapSecId || sPokenavCityMaps[i].index != pos); i++)
@ -677,7 +677,7 @@ static void DrawCityMap(struct Pokenav_RegionMapGfx *state, int mapSecId, int po
CopyToBgTilemapBufferRect(1, state->cityZoomPics[i], 18, 6, 10, 10);
}
static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos)
static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *state, mapsec_s32_t mapSecId, int pos)
{
int i = 0;
while (1)

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,
@ -694,7 +694,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;
@ -779,7 +779,7 @@ static u8 MoveRegionMapCursor_Zoomed(void)
{
u16 x;
u16 y;
u16 mapSecId;
mapsec_u16_t mapSecId;
sRegionMap->scrollY += sRegionMap->zoomedCursorDeltaY;
sRegionMap->scrollX += sRegionMap->zoomedCursorDeltaX;
@ -962,7 +962,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)
{
@ -1180,7 +1180,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)
{
@ -1227,12 +1227,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;
@ -1253,7 +1253,7 @@ static u16 CorrectSpecialMapSecId_Internal(u16 mapSecId)
return mapSecId;
}
static u16 GetTerraOrMarineCaveMapSecId(void)
static mapsec_u16_t GetTerraOrMarineCaveMapSecId(void)
{
s16 idx;
@ -1282,7 +1282,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;
@ -1294,7 +1294,7 @@ static bool32 IsPlayerInAquaHideout(u8 mapSecId)
return FALSE;
}
u16 CorrectSpecialMapSecId(u16 mapSecId)
mapsec_u16_t CorrectSpecialMapSecId(mapsec_u16_t mapSecId)
{
return CorrectSpecialMapSecId_Internal(mapSecId);
}
@ -1573,7 +1573,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;
@ -1606,7 +1606,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)
{
@ -1619,7 +1619,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);
@ -1627,7 +1627,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;
@ -1640,7 +1640,7 @@ bool8 IsRegionMapZoomed(void)
return sRegionMap->zoomed;
}
bool32 IsEventIslandMapSecId(u8 mapSecId)
bool32 IsEventIslandMapSecId(mapsec_u8_t mapSecId)
{
u32 i;
@ -1847,7 +1847,7 @@ static void LoadFlyDestIcons(void)
static void CreateFlyDestIcons(void)
{
u16 canFlyFlag;
u16 mapSecId;
mapsec_u16_t mapSecId;
u16 x;
u16 y;
u16 width;
@ -1895,7 +1895,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++)

View File

@ -4535,7 +4535,7 @@ static void CreateInGameTradePokemonInternal(u8 whichPlayerMon, u8 whichInGameTr
u8 level = GetMonData(&gPlayerParty[whichPlayerMon], MON_DATA_LEVEL);
struct Mail mail;
u8 metLocation = METLOC_IN_GAME_TRADE;
metloc_u8_t metLocation = METLOC_IN_GAME_TRADE;
u8 mailNum;
struct Pokemon *pokemon = &gEnemyParty[0];