Name pokenav region map structs

This commit is contained in:
GriffinR
2021-11-15 01:37:17 -05:00
parent 4275cf4b90
commit d98bd4dba7
+46 -43
View File
@@ -17,22 +17,25 @@
#include "constants/songs.h" #include "constants/songs.h"
#include "constants/region_map_sections.h" #include "constants/region_map_sections.h"
#define GFXTAG_CITY_ZOOM 6
#define PALTAG_CITY_ZOOM 11
#define NUM_CITY_MAPS 22 #define NUM_CITY_MAPS 22
struct Pokenav5Struct struct Pokenav_RegionMapMenu
{ {
u8 filler0[0xC]; u8 unused[12];
bool32 zoomDisabled; bool32 zoomDisabled;
u32 (*callback)(struct Pokenav5Struct *); u32 (*callback)(struct Pokenav_RegionMapMenu *);
}; };
struct Pokenav5Struct_2 struct Pokenav_RegionMapGfx
{ {
bool32 (*isTaskActiveCB)(void); bool32 (*isTaskActiveCB)(void);
u32 loopTaskId; u32 loopTaskId;
u16 infoWindowId; u16 infoWindowId;
struct Sprite *cityZoomTextSprites[3]; struct Sprite *cityZoomTextSprites[3];
u8 tilemapBuffer[0x800]; u8 tilemapBuffer[BG_SCREEN_SIZE];
u8 cityZoomPics[NUM_CITY_MAPS][200]; u8 cityZoomPics[NUM_CITY_MAPS][200];
}; };
@@ -43,9 +46,9 @@ struct CityMapEntry
const u32 *tilemap; const u32 *tilemap;
}; };
static u32 HandleRegionMapInput(struct Pokenav5Struct *); static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *);
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *); static u32 HandleRegionMapInputZoomDisabled(struct Pokenav_RegionMapMenu *);
static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *); static u32 GetExitRegionMapMenuId(struct Pokenav_RegionMapMenu *);
static u32 LoopedTask_OpenRegionMap(s32); static u32 LoopedTask_OpenRegionMap(s32);
static u32 LoopedTask_DecompressCityMaps(s32); static u32 LoopedTask_DecompressCityMaps(s32);
static bool32 GetCurrentLoopedTaskActive(void); static bool32 GetCurrentLoopedTaskActive(void);
@@ -53,15 +56,15 @@ static void FreeCityZoomViewGfx(void);
static void LoadCityZoomViewGfx(void); static void LoadCityZoomViewGfx(void);
static void DecompressCityMaps(void); static void DecompressCityMaps(void);
static bool32 IsDecompressCityMapsActive(void); static bool32 IsDecompressCityMapsActive(void);
static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *); static void LoadPokenavRegionMapGfx(struct Pokenav_RegionMapGfx *);
static bool32 TryFreeTempTileDataBuffers(void); static bool32 TryFreeTempTileDataBuffers(void);
static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *); static void UpdateMapSecInfoWindow(struct Pokenav_RegionMapGfx *);
static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav5Struct_2 *); static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav_RegionMapGfx *);
static void ChangeBgYForZoom(bool32); static void ChangeBgYForZoom(bool32);
static bool32 IsChangeBgYForZoomActive(void); static bool32 IsChangeBgYForZoomActive(void);
static void CreateCityZoomTextSprites(void); static void CreateCityZoomTextSprites(void);
static void DrawCityMap(struct Pokenav5Struct_2 *, int, int); static void DrawCityMap(struct Pokenav_RegionMapGfx *, int, int);
static void PrintLandmarkNames(struct Pokenav5Struct_2 *, int, int); static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *, int, int);
static void SetCityZoomTextInvisibility(bool32); static void SetCityZoomTextInvisibility(bool32);
static void Task_ChangeBgYForZoom(u8 taskId); static void Task_ChangeBgYForZoom(u8 taskId);
static void UpdateCityZoomTextPosition(void); static void UpdateCityZoomTextPosition(void);
@@ -121,12 +124,12 @@ static const LoopedTask sRegionMapLoopTaskFuncs[] =
static const struct CompressedSpriteSheet sCityZoomTextSpriteSheet[1] = static const struct CompressedSpriteSheet sCityZoomTextSpriteSheet[1] =
{ {
{gRegionMapCityZoomText_Gfx, 0x800, 6} {gRegionMapCityZoomText_Gfx, 0x800, GFXTAG_CITY_ZOOM}
}; };
static const struct SpritePalette sCityZoomTilesSpritePalette[] = static const struct SpritePalette sCityZoomTilesSpritePalette[] =
{ {
{gRegionMapCityZoomTiles_Pal, 11}, {gRegionMapCityZoomTiles_Pal, PALTAG_CITY_ZOOM},
{} {}
}; };
@@ -159,8 +162,8 @@ const struct OamData sCityZoomTextSprite_OamData =
static const struct SpriteTemplate sCityZoomTextSpriteTemplate = static const struct SpriteTemplate sCityZoomTextSpriteTemplate =
{ {
.tileTag = 6, .tileTag = GFXTAG_CITY_ZOOM,
.paletteTag = 11, .paletteTag = PALTAG_CITY_ZOOM,
.oam = &sCityZoomTextSprite_OamData, .oam = &sCityZoomTextSprite_OamData,
.anims = gDummySpriteAnimTable, .anims = gDummySpriteAnimTable,
.images = NULL, .images = NULL,
@@ -170,7 +173,7 @@ static const struct SpriteTemplate sCityZoomTextSpriteTemplate =
u32 PokenavCallback_Init_RegionMap(void) u32 PokenavCallback_Init_RegionMap(void)
{ {
struct Pokenav5Struct *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_STATE, sizeof(struct Pokenav5Struct)); struct Pokenav_RegionMapMenu *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_STATE, sizeof(struct Pokenav_RegionMapMenu));
if (!state) if (!state)
return FALSE; return FALSE;
@@ -195,11 +198,11 @@ void FreeRegionMapSubstruct1(void)
u32 GetRegionMapCallback(void) u32 GetRegionMapCallback(void)
{ {
struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE); struct Pokenav_RegionMapMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE);
return state->callback(state); return state->callback(state);
} }
static u32 HandleRegionMapInput(struct Pokenav5Struct *state) static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *state)
{ {
switch (DoRegionMapInputCallback()) switch (DoRegionMapInputCallback())
{ {
@@ -217,7 +220,7 @@ static u32 HandleRegionMapInput(struct Pokenav5Struct *state)
return POKENAV_MAP_FUNC_NONE; return POKENAV_MAP_FUNC_NONE;
} }
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state) static u32 HandleRegionMapInputZoomDisabled(struct Pokenav_RegionMapMenu *state)
{ {
if (JOY_NEW(B_BUTTON)) if (JOY_NEW(B_BUTTON))
{ {
@@ -228,20 +231,20 @@ static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state)
return POKENAV_MAP_FUNC_NONE; return POKENAV_MAP_FUNC_NONE;
} }
static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *state) static u32 GetExitRegionMapMenuId(struct Pokenav_RegionMapMenu *state)
{ {
return POKENAV_MAIN_MENU_CURSOR_ON_MAP; return POKENAV_MAIN_MENU_CURSOR_ON_MAP;
} }
bool32 GetZoomDisabled(void) bool32 GetZoomDisabled(void)
{ {
struct Pokenav5Struct *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE); struct Pokenav_RegionMapMenu *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_STATE);
return state->zoomDisabled; return state->zoomDisabled;
} }
bool32 OpenPokenavRegionMap(void) bool32 OpenPokenavRegionMap(void)
{ {
struct Pokenav5Struct_2 *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, sizeof(struct Pokenav5Struct_2)); struct Pokenav_RegionMapGfx *state = AllocSubstruct(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM, sizeof(struct Pokenav_RegionMapGfx));
if (!state) if (!state)
return FALSE; return FALSE;
@@ -252,20 +255,20 @@ bool32 OpenPokenavRegionMap(void)
void CreateRegionMapLoopedTask(s32 index) void CreateRegionMapLoopedTask(s32 index)
{ {
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
state->loopTaskId = CreateLoopedTask(sRegionMapLoopTaskFuncs[index], 1); state->loopTaskId = CreateLoopedTask(sRegionMapLoopTaskFuncs[index], 1);
state->isTaskActiveCB = GetCurrentLoopedTaskActive; state->isTaskActiveCB = GetCurrentLoopedTaskActive;
} }
bool32 IsRegionMapLoopedTaskActive(void) bool32 IsRegionMapLoopedTaskActive(void)
{ {
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
return state->isTaskActiveCB(); return state->isTaskActiveCB();
} }
void FreeRegionMapSubstruct2(void) void FreeRegionMapSubstruct2(void)
{ {
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
FreeRegionMapIconResources(); FreeRegionMapIconResources();
FreeCityZoomViewGfx(); FreeCityZoomViewGfx();
RemoveWindow(state->infoWindowId); RemoveWindow(state->infoWindowId);
@@ -285,7 +288,7 @@ static void VBlankCB_RegionMap(void)
static bool32 GetCurrentLoopedTaskActive(void) static bool32 GetCurrentLoopedTaskActive(void)
{ {
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
return IsLoopedTaskActive(state->loopTaskId); return IsLoopedTaskActive(state->loopTaskId);
} }
@@ -301,7 +304,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
{ {
int menuGfxId; int menuGfxId;
struct RegionMap *regionMap; struct RegionMap *regionMap;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@@ -377,7 +380,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
static u32 LoopedTask_UpdateInfoAfterCursorMove(s32 taskState) static u32 LoopedTask_UpdateInfoAfterCursorMove(s32 taskState)
{ {
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@@ -420,7 +423,7 @@ static u32 LoopedTask_RegionMapZoomOut(s32 taskState)
static u32 LoopedTask_RegionMapZoomIn(s32 taskState) static u32 LoopedTask_RegionMapZoomIn(s32 taskState)
{ {
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
switch (taskState) switch (taskState)
{ {
case 0: case 0:
@@ -492,14 +495,14 @@ static void LoadCityZoomViewGfx(void)
static void FreeCityZoomViewGfx(void) static void FreeCityZoomViewGfx(void)
{ {
int i; int i;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
FreeSpriteTilesByTag(6); FreeSpriteTilesByTag(GFXTAG_CITY_ZOOM);
FreeSpritePaletteByTag(11); FreeSpritePaletteByTag(PALTAG_CITY_ZOOM);
for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++)
DestroySprite(state->cityZoomTextSprites[i]); DestroySprite(state->cityZoomTextSprites[i]);
} }
static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *state) static void LoadPokenavRegionMapGfx(struct Pokenav_RegionMapGfx *state)
{ {
BgDmaFill(1, PIXEL_FILL(0), 0x40, 1); BgDmaFill(1, PIXEL_FILL(0), 0x40, 1);
BgDmaFill(1, PIXEL_FILL(1), 0x41, 1); BgDmaFill(1, PIXEL_FILL(1), 0x41, 1);
@@ -527,7 +530,7 @@ static bool32 TryFreeTempTileDataBuffers(void)
return FreeTempTileDataBuffersIfPossible(); return FreeTempTileDataBuffersIfPossible();
} }
static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state) static void UpdateMapSecInfoWindow(struct Pokenav_RegionMapGfx *state)
{ {
struct RegionMap *regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP); struct RegionMap *regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP);
switch (regionMap->mapSecType) switch (regionMap->mapSecType)
@@ -565,7 +568,7 @@ static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state)
} }
} }
static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav5Struct_2 *state) static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav_RegionMapGfx *state)
{ {
return IsDma3ManagerBusyWithBgCopy(); return IsDma3ManagerBusyWithBgCopy();
} }
@@ -621,7 +624,7 @@ static bool32 IsDecompressCityMapsActive(void)
static u32 LoopedTask_DecompressCityMaps(s32 taskState) static u32 LoopedTask_DecompressCityMaps(s32 taskState)
{ {
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
if (taskState < NUM_CITY_MAPS) if (taskState < NUM_CITY_MAPS)
{ {
LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]); LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]);
@@ -631,7 +634,7 @@ static u32 LoopedTask_DecompressCityMaps(s32 taskState)
return LT_FINISH; return LT_FINISH;
} }
static void DrawCityMap(struct Pokenav5Struct_2 *state, int mapSecId, int pos) static void DrawCityMap(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos)
{ {
int i; int i;
for (i = 0; i < NUM_CITY_MAPS && (sPokenavCityMaps[i].mapSecId != mapSecId || sPokenavCityMaps[i].index != pos); i++) for (i = 0; i < NUM_CITY_MAPS && (sPokenavCityMaps[i].mapSecId != mapSecId || sPokenavCityMaps[i].index != pos); i++)
@@ -644,7 +647,7 @@ static void DrawCityMap(struct Pokenav5Struct_2 *state, int mapSecId, int pos)
CopyToBgTilemapBufferRect(1, state->cityZoomPics[i], 18, 6, 10, 10); CopyToBgTilemapBufferRect(1, state->cityZoomPics[i], 18, 6, 10, 10);
} }
static void PrintLandmarkNames(struct Pokenav5Struct_2 *state, int mapSecId, int pos) static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *state, int mapSecId, int pos)
{ {
int i = 0; int i = 0;
while (1) while (1)
@@ -664,7 +667,7 @@ static void CreateCityZoomTextSprites(void)
int i; int i;
int y; int y;
struct Sprite *sprite; struct Sprite *sprite;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
// When not zoomed in the text is still created but its pushed off screen // When not zoomed in the text is still created but its pushed off screen
if (!IsRegionMapZoomed()) if (!IsRegionMapZoomed())
@@ -724,7 +727,7 @@ static void SpriteCB_CityZoomText(struct Sprite *sprite)
static void UpdateCityZoomTextPosition(void) static void UpdateCityZoomTextPosition(void)
{ {
int i; int i;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
int y = 132 - (GetBgY(1) >> 8); int y = 132 - (GetBgY(1) >> 8);
for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++)
state->cityZoomTextSprites[i]->y = y; state->cityZoomTextSprites[i]->y = y;
@@ -733,7 +736,7 @@ static void UpdateCityZoomTextPosition(void)
static void SetCityZoomTextInvisibility(bool32 invisible) static void SetCityZoomTextInvisibility(bool32 invisible)
{ {
int i; int i;
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM); struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++) for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++)
state->cityZoomTextSprites[i]->invisible = invisible; state->cityZoomTextSprites[i]->invisible = invisible;
} }