From 7fd0029ed7b9a245f866b6a7467f6d0bd7c0f717 Mon Sep 17 00:00:00 2001 From: DavidJCobb <831497+DavidJCobb@users.noreply.github.com> Date: Sun, 19 Oct 2025 18:37:13 +0200 Subject: [PATCH] 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. --- include/gametypes.h | 67 +++++++++++++++++++++++++ include/global.fieldmap.h | 2 +- include/global.h | 1 + include/global.tv.h | 14 +++--- include/landmark.h | 2 +- include/overworld.h | 4 +- include/pokemon.h | 2 +- include/pokenav.h | 6 +-- include/region_map.h | 14 +++--- src/data/region_map/region_map_layout.h | 2 +- src/daycare.c | 2 +- src/egg_hatch.c | 2 +- src/frontier_pass.c | 4 +- src/landmark.c | 8 +-- src/map_name_popup.c | 2 +- src/match_call.c | 4 +- src/overworld.c | 6 +-- src/pokedex_area_screen.c | 16 +++--- src/pokemon.c | 15 +++++- src/pokemon_summary_screen.c | 2 +- src/pokenav_match_call_data.c | 36 ++++++------- src/pokenav_match_call_gfx.c | 2 +- src/pokenav_match_call_list.c | 4 +- src/pokenav_region_map.c | 10 ++-- src/region_map.c | 58 ++++++++++----------- src/trade.c | 2 +- 26 files changed, 185 insertions(+), 102 deletions(-) create mode 100644 include/gametypes.h diff --git a/include/gametypes.h b/include/gametypes.h new file mode 100644 index 0000000000..242fc9d9db --- /dev/null +++ b/include/gametypes.h @@ -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 diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 1207bd80ea..90f2080d71 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -167,7 +167,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; diff --git a/include/global.h b/include/global.h index f0882710e5..bdfc426fb9 100644 --- a/include/global.h +++ b/include/global.h @@ -5,6 +5,7 @@ #include #include "config.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 "constants/global.h" #include "constants/flags.h" #include "constants/vars.h" diff --git a/include/global.tv.h b/include/global.tv.h index 9c3902e7cc..a2721b06b4 100644 --- a/include/global.tv.h +++ b/include/global.tv.h @@ -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; diff --git a/include/landmark.h b/include/landmark.h index 395905033a..f5feb407bc 100644 --- a/include/landmark.h +++ b/include/landmark.h @@ -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 diff --git a/include/overworld.h b/include/overworld.h index bde6896569..8ac0ddc81e 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -121,8 +121,8 @@ u8 GetLastUsedWarpMapType(void); bool8 IsMapTypeOutdoors(u8 mapType); bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType); bool8 IsMapTypeIndoors(u8 mapType); -u8 GetSavedWarpRegionMapSectionId(void); -u8 GetCurrentRegionMapSectionId(void); +mapsec_u8_t GetSavedWarpRegionMapSectionId(void); +mapsec_u8_t GetCurrentRegionMapSectionId(void); u8 GetCurrentMapBattleScene(void); void CleanupOverworldWindowsAndTilemaps(void); bool32 IsOverworldLinkActive(void); diff --git a/include/pokemon.h b/include/pokemon.h index 53f7f02fd0..3d75157f91 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -131,7 +131,7 @@ struct PokemonSubstruct2 struct PokemonSubstruct3 { /* 0x00 */ u8 pokerus; - /* 0x01 */ u8 metLocation; + /* 0x01 */ metloc_u8_t metLocation; /* 0x02 */ u16 metLevel:7; /* 0x02 */ u16 metGame:4; diff --git a/include/pokenav.h b/include/pokenav.h index 553d2ad0f6..b548824234 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -17,7 +17,7 @@ struct PokenavMonListItem struct PokenavMatchCallEntry { bool8 isSpecialTrainer; - u8 mapSec; + mapsec_u8_t mapSec; u16 headerId; }; @@ -410,7 +410,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); @@ -419,7 +419,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); diff --git a/include/region_map.h b/include/region_map.h index 2bca9e7f7d..abdb44b16c 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -26,7 +26,7 @@ enum { }; struct RegionMap { - /*0x000*/ u16 mapSecId; + /*0x000*/ mapsec_u16_t mapSecId; /*0x002*/ u8 mapSecType; /*0x003*/ u8 posWithinMapSec; /*0x004*/ u8 mapSecName[20]; @@ -99,14 +99,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); diff --git a/src/data/region_map/region_map_layout.h b/src/data/region_map/region_map_layout.h index 95a4e94f31..32ce91724d 100644 --- a/src/data/region_map/region_map_layout.h +++ b/src/data/region_map/region_map_layout.h @@ -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}, diff --git a/src/daycare.c b/src/daycare.c index 5ebe255b39..eb9a5fdeb0 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -830,7 +830,7 @@ void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation) u8 metLevel; u16 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); diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 5aa955d7e9..00a194ea70 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -362,7 +362,7 @@ static void AddHatchedMonToParty(u8 id) u8 name[POKEMON_NAME_LENGTH + 1]; u16 ball; u16 metLevel; - u8 metLocation; + metloc_u8_t metLocation; struct Pokemon *mon = &gPlayerParty[id]; CreateHatchedMon(mon, &gEnemyParty[0]); diff --git a/src/frontier_pass.c b/src/frontier_pass.c index a053badc62..fb6920e3cc 100644 --- a/src/frontier_pass.c +++ b/src/frontier_pass.c @@ -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; diff --git a/src/landmark.c b/src/landmark.c index d2bb3c4105..a8cf6c1233 100644 --- a/src/landmark.c +++ b/src/landmark.c @@ -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; diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 4b30068f3c..665cccec3c 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -404,7 +404,7 @@ static void LoadMapNamePopUpWindowBg(void) { u8 popUpThemeId; u8 popupWindowId = GetMapNamePopUpWindowId(); - u16 regionMapSectionId = gMapHeader.regionMapSectionId; + mapsec_u16_t regionMapSectionId = gMapHeader.regionMapSectionId; if (regionMapSectionId >= KANTO_MAPSEC_START) { diff --git a/src/match_call.c b/src/match_call.c index e6a141a1bc..41188f51bb 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -134,7 +134,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); @@ -1463,7 +1463,7 @@ static bool32 TrainerIsEligibleForRematch(int matchCallId) return gSaveBlock1Ptr->trainerRematches[matchCallId] > 0; } -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; diff --git a/src/overworld.c b/src/overworld.c index 32c5eb0678..d1d3ddcd37 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -194,7 +194,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; @@ -1383,12 +1383,12 @@ bool8 IsMapTypeIndoors(u8 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; } diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index 8b0a845102..c3211ed454 100755 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -58,7 +58,7 @@ struct OverworldArea { u8 mapGroup; u8 mapNum; - u16 regionMapSectionId; + mapsec_u16_t regionMapSectionId; }; struct @@ -79,7 +79,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; @@ -95,7 +95,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 WildPokemonHeader *, u16); static bool8 MonListHasSpecies(const struct WildPokemonInfo *, u16, u16); static void DoAreaGlow(void); @@ -112,7 +112,7 @@ static const u32 sAreaGlow_Gfx[] = INCBIN_U32("graphics/pokedex/area_glow.4bpp.l 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, @@ -125,7 +125,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}, @@ -336,7 +336,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) @@ -370,7 +370,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; } @@ -710,7 +710,7 @@ static void CreateAreaMarkerSprites(void) static s16 x; static s16 y; static s16 i; - static s16 mapSecId; + static mapsec_s16_t mapSecId; static s16 numSprites; LoadSpriteSheet(&sAreaMarkerSpriteSheet); diff --git a/src/pokemon.c b/src/pokemon.c index a06693dc8a..7283e0e456 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4074,6 +4074,19 @@ u32 GetBoxMonData2(struct BoxPokemon *boxMon, s32 field) __attribute__((alias("G #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) { @@ -4263,7 +4276,7 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) SET8(substruct3->pokerus); break; case MON_DATA_MET_LOCATION: - SET8(substruct3->metLocation); + SET_BY_WIDTH(substruct3->metLocation); break; case MON_DATA_MET_LEVEL: { diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index a77df48327..734d925358 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -143,7 +143,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 diff --git a/src/pokenav_match_call_data.c b/src/pokenav_match_call_data.c index 1c3cf9aeeb..3f47550f17 100644 --- a/src/pokenav_match_call_data.c +++ b/src/pokenav_match_call_data.c @@ -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); @@ -609,7 +609,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, @@ -779,7 +779,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; @@ -791,17 +791,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; @@ -813,12 +813,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; } diff --git a/src/pokenav_match_call_gfx.c b/src/pokenav_match_call_gfx.c index 4271e2ff23..dde725d8bd 100755 --- a/src/pokenav_match_call_gfx.c +++ b/src/pokenav_match_call_gfx.c @@ -1022,7 +1022,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 diff --git a/src/pokenav_match_call_list.c b/src/pokenav_match_call_list.c index fb89e33e0b..8f8fc6b4c2 100755 --- a/src/pokenav_match_call_list.c +++ b/src/pokenav_match_call_list.c @@ -306,7 +306,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; @@ -424,7 +424,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; diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index f81ff42966..8475bbacb8 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -41,7 +41,7 @@ struct Pokenav_RegionMapGfx struct CityMapEntry { - u16 mapSecId; + mapsec_u16_t mapSecId; u16 index; const u32 *tilemap; }; @@ -63,8 +63,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); @@ -634,7 +634,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++) @@ -647,7 +647,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) diff --git a/src/region_map.c b/src/region_map.c index 22a3f567b4..a418b7fe4f 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -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++) diff --git a/src/trade.c b/src/trade.c index e07e418d1a..e9c2984087 100644 --- a/src/trade.c +++ b/src/trade.c @@ -4552,7 +4552,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];