Files
PokemonEmeraldSafariFrontier/include/region_map.h
DavidJCobb 7fd0029ed7 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.
2025-10-19 17:37:13 +01:00

121 lines
3.5 KiB
C

#ifndef GUARD_REGION_MAP_H
#define GUARD_REGION_MAP_H
#include "bg.h"
// Exported type declarations
#define MAP_NAME_LENGTH 16
enum
{
MAP_INPUT_NONE,
MAP_INPUT_MOVE_START,
MAP_INPUT_MOVE_CONT,
MAP_INPUT_MOVE_END,
MAP_INPUT_A_BUTTON,
MAP_INPUT_B_BUTTON,
};
enum {
MAPSECTYPE_NONE,
MAPSECTYPE_ROUTE,
MAPSECTYPE_CITY_CANFLY,
MAPSECTYPE_CITY_CANTFLY,
MAPSECTYPE_BATTLE_FRONTIER,
NUM_MAPSEC_TYPES
};
struct RegionMap {
/*0x000*/ mapsec_u16_t mapSecId;
/*0x002*/ u8 mapSecType;
/*0x003*/ u8 posWithinMapSec;
/*0x004*/ u8 mapSecName[20];
/*0x018*/ u8 (*inputCallback)(void);
/*0x01c*/ struct Sprite *cursorSprite;
/*0x020*/ struct Sprite *playerIconSprite;
/*0x024*/ s32 bg2x;
/*0x028*/ s32 bg2y;
/*0x02c*/ u32 bg2pa;
/*0x034*/ u32 bg2pc;
/*0x030*/ u32 bg2pb;
/*0x038*/ u32 bg2pd;
/*0x03c*/ s32 unk_03c;
/*0x040*/ s32 unk_040;
/*0x044*/ s32 unk_044;
/*0x048*/ s32 unk_048;
/*0x04c*/ s32 unk_04c;
/*0x050*/ s32 unk_050;
/*0x054*/ u16 cursorPosX;
/*0x056*/ u16 cursorPosY;
/*0x058*/ u16 cursorTileTag;
/*0x05a*/ u16 cursorPaletteTag;
/*0x05c*/ s16 scrollX;
/*0x05e*/ s16 scrollY;
/*0x060*/ s16 unk_060;
/*0x062*/ s16 unk_062;
/*0x064*/ u16 zoomedCursorPosX;
/*0x066*/ u16 zoomedCursorPosY;
/*0x068*/ s16 zoomedCursorDeltaY;
/*0x06a*/ s16 zoomedCursorDeltaX;
/*0x06c*/ u16 zoomedCursorMovementFrameCounter;
/*0x06e*/ u16 unk_06e;
/*0x070*/ u16 playerIconTileTag;
/*0x072*/ u16 playerIconPaletteTag;
/*0x074*/ u16 playerIconSpritePosX;
/*0x076*/ u16 playerIconSpritePosY;
/*0x078*/ bool8 zoomed;
/*0x079*/ u8 initStep;
/*0x07a*/ s8 cursorMovementFrameCounter;
/*0x07b*/ s8 cursorDeltaX;
/*0x07c*/ s8 cursorDeltaY;
/*0x07d*/ bool8 needUpdateVideoRegs;
/*0x07e*/ bool8 blinkPlayerIcon;
/*0x07f*/ bool8 playerIsInCave;
/*0x080*/ u8 bgNum;
/*0x081*/ u8 charBaseIdx;
/*0x082*/ u8 mapBaseIdx;
/*0x083*/ bool8 bgManaged;
/*0x084*/ u8 filler_084[0x100];
/*0x184*/ u8 cursorSmallImage[0x100];
/*0x284*/ u8 cursorLargeImage[0x600];
}; // size = 0x884
struct RegionMapLocation
{
u8 x;
u8 y;
u8 width;
u8 height;
const u8 *name;
};
// Exported RAM declarations
// Exported ROM declarations
void InitRegionMapData(struct RegionMap *regionMap, const struct BgTemplate *template, bool8 zoomed);
bool8 LoadRegionMapGfx(void);
void UpdateRegionMapVideoRegs(void);
void InitRegionMap(struct RegionMap *regionMap, bool8 zoomed);
u8 DoRegionMapInputCallback(void);
bool8 UpdateRegionMapZoom(void);
void FreeRegionMapIconResources(void);
mapsec_u16_t GetRegionMapSecIdAt(u16 x, u16 y);
void CreateRegionMapPlayerIcon(u16 tileTag, u16 paletteTag);
void CreateRegionMapCursor(u16 tileTag, u16 paletteTag);
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);
bool8 IsRegionMapZoomed(void);
void TrySetPlayerIconBlink(void);
void BlendRegionMap(u16 color, u32 coeff);
void SetRegionMapDataForZoom(void);
extern const struct RegionMapLocation gRegionMapEntries[];
#endif //GUARD_REGION_MAP_H