mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-13 23:23:43 +01:00
Name pokenav region map structs
This commit is contained in:
parent
4275cf4b90
commit
d98bd4dba7
@ -17,22 +17,25 @@
|
||||
#include "constants/songs.h"
|
||||
#include "constants/region_map_sections.h"
|
||||
|
||||
#define GFXTAG_CITY_ZOOM 6
|
||||
#define PALTAG_CITY_ZOOM 11
|
||||
|
||||
#define NUM_CITY_MAPS 22
|
||||
|
||||
struct Pokenav5Struct
|
||||
struct Pokenav_RegionMapMenu
|
||||
{
|
||||
u8 filler0[0xC];
|
||||
u8 unused[12];
|
||||
bool32 zoomDisabled;
|
||||
u32 (*callback)(struct Pokenav5Struct *);
|
||||
u32 (*callback)(struct Pokenav_RegionMapMenu *);
|
||||
};
|
||||
|
||||
struct Pokenav5Struct_2
|
||||
struct Pokenav_RegionMapGfx
|
||||
{
|
||||
bool32 (*isTaskActiveCB)(void);
|
||||
u32 loopTaskId;
|
||||
u16 infoWindowId;
|
||||
struct Sprite *cityZoomTextSprites[3];
|
||||
u8 tilemapBuffer[0x800];
|
||||
u8 tilemapBuffer[BG_SCREEN_SIZE];
|
||||
u8 cityZoomPics[NUM_CITY_MAPS][200];
|
||||
};
|
||||
|
||||
@ -43,9 +46,9 @@ struct CityMapEntry
|
||||
const u32 *tilemap;
|
||||
};
|
||||
|
||||
static u32 HandleRegionMapInput(struct Pokenav5Struct *);
|
||||
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *);
|
||||
static u32 GetExitRegionMapMenuId(struct Pokenav5Struct *);
|
||||
static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *);
|
||||
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav_RegionMapMenu *);
|
||||
static u32 GetExitRegionMapMenuId(struct Pokenav_RegionMapMenu *);
|
||||
static u32 LoopedTask_OpenRegionMap(s32);
|
||||
static u32 LoopedTask_DecompressCityMaps(s32);
|
||||
static bool32 GetCurrentLoopedTaskActive(void);
|
||||
@ -53,15 +56,15 @@ static void FreeCityZoomViewGfx(void);
|
||||
static void LoadCityZoomViewGfx(void);
|
||||
static void DecompressCityMaps(void);
|
||||
static bool32 IsDecompressCityMapsActive(void);
|
||||
static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *);
|
||||
static void LoadPokenavRegionMapGfx(struct Pokenav_RegionMapGfx *);
|
||||
static bool32 TryFreeTempTileDataBuffers(void);
|
||||
static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *);
|
||||
static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav5Struct_2 *);
|
||||
static void UpdateMapSecInfoWindow(struct Pokenav_RegionMapGfx *);
|
||||
static bool32 IsDma3ManagerBusyWithBgCopy_(struct Pokenav_RegionMapGfx *);
|
||||
static void ChangeBgYForZoom(bool32);
|
||||
static bool32 IsChangeBgYForZoomActive(void);
|
||||
static void CreateCityZoomTextSprites(void);
|
||||
static void DrawCityMap(struct Pokenav5Struct_2 *, int, int);
|
||||
static void PrintLandmarkNames(struct Pokenav5Struct_2 *, int, int);
|
||||
static void DrawCityMap(struct Pokenav_RegionMapGfx *, int, int);
|
||||
static void PrintLandmarkNames(struct Pokenav_RegionMapGfx *, int, int);
|
||||
static void SetCityZoomTextInvisibility(bool32);
|
||||
static void Task_ChangeBgYForZoom(u8 taskId);
|
||||
static void UpdateCityZoomTextPosition(void);
|
||||
@ -121,12 +124,12 @@ static const LoopedTask sRegionMapLoopTaskFuncs[] =
|
||||
|
||||
static const struct CompressedSpriteSheet sCityZoomTextSpriteSheet[1] =
|
||||
{
|
||||
{gRegionMapCityZoomText_Gfx, 0x800, 6}
|
||||
{gRegionMapCityZoomText_Gfx, 0x800, GFXTAG_CITY_ZOOM}
|
||||
};
|
||||
|
||||
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 =
|
||||
{
|
||||
.tileTag = 6,
|
||||
.paletteTag = 11,
|
||||
.tileTag = GFXTAG_CITY_ZOOM,
|
||||
.paletteTag = PALTAG_CITY_ZOOM,
|
||||
.oam = &sCityZoomTextSprite_OamData,
|
||||
.anims = gDummySpriteAnimTable,
|
||||
.images = NULL,
|
||||
@ -170,7 +173,7 @@ static const struct SpriteTemplate sCityZoomTextSpriteTemplate =
|
||||
|
||||
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)
|
||||
return FALSE;
|
||||
|
||||
@ -195,11 +198,11 @@ void FreeRegionMapSubstruct1(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);
|
||||
}
|
||||
|
||||
static u32 HandleRegionMapInput(struct Pokenav5Struct *state)
|
||||
static u32 HandleRegionMapInput(struct Pokenav_RegionMapMenu *state)
|
||||
{
|
||||
switch (DoRegionMapInputCallback())
|
||||
{
|
||||
@ -217,7 +220,7 @@ static u32 HandleRegionMapInput(struct Pokenav5Struct *state)
|
||||
return POKENAV_MAP_FUNC_NONE;
|
||||
}
|
||||
|
||||
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state)
|
||||
static u32 HandleRegionMapInputZoomDisabled(struct Pokenav_RegionMapMenu *state)
|
||||
{
|
||||
if (JOY_NEW(B_BUTTON))
|
||||
{
|
||||
@ -228,20 +231,20 @@ static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state)
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
return FALSE;
|
||||
|
||||
@ -252,20 +255,20 @@ bool32 OpenPokenavRegionMap(void)
|
||||
|
||||
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->isTaskActiveCB = GetCurrentLoopedTaskActive;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void FreeRegionMapSubstruct2(void)
|
||||
{
|
||||
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
|
||||
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
|
||||
FreeRegionMapIconResources();
|
||||
FreeCityZoomViewGfx();
|
||||
RemoveWindow(state->infoWindowId);
|
||||
@ -285,7 +288,7 @@ static void VBlankCB_RegionMap(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);
|
||||
}
|
||||
|
||||
@ -301,7 +304,7 @@ static u32 LoopedTask_OpenRegionMap(s32 taskState)
|
||||
{
|
||||
int menuGfxId;
|
||||
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)
|
||||
{
|
||||
case 0:
|
||||
@ -377,7 +380,7 @@ static u32 LoopedTask_OpenRegionMap(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)
|
||||
{
|
||||
case 0:
|
||||
@ -420,7 +423,7 @@ static u32 LoopedTask_RegionMapZoomOut(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)
|
||||
{
|
||||
case 0:
|
||||
@ -492,14 +495,14 @@ static void LoadCityZoomViewGfx(void)
|
||||
static void FreeCityZoomViewGfx(void)
|
||||
{
|
||||
int i;
|
||||
struct Pokenav5Struct_2 *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
|
||||
FreeSpriteTilesByTag(6);
|
||||
FreeSpritePaletteByTag(11);
|
||||
struct Pokenav_RegionMapGfx *state = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP_ZOOM);
|
||||
FreeSpriteTilesByTag(GFXTAG_CITY_ZOOM);
|
||||
FreeSpritePaletteByTag(PALTAG_CITY_ZOOM);
|
||||
for (i = 0; i < (int)ARRAY_COUNT(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(1), 0x41, 1);
|
||||
@ -527,7 +530,7 @@ static bool32 TryFreeTempTileDataBuffers(void)
|
||||
return FreeTempTileDataBuffersIfPossible();
|
||||
}
|
||||
|
||||
static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state)
|
||||
static void UpdateMapSecInfoWindow(struct Pokenav_RegionMapGfx *state)
|
||||
{
|
||||
struct RegionMap *regionMap = GetSubstructPtr(POKENAV_SUBSTRUCT_REGION_MAP);
|
||||
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();
|
||||
}
|
||||
@ -621,7 +624,7 @@ static bool32 IsDecompressCityMapsActive(void)
|
||||
|
||||
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)
|
||||
{
|
||||
LZ77UnCompWram(sPokenavCityMaps[taskState].tilemap, state->cityZoomPics[taskState]);
|
||||
@ -631,7 +634,7 @@ static u32 LoopedTask_DecompressCityMaps(s32 taskState)
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
while (1)
|
||||
@ -664,7 +667,7 @@ static void CreateCityZoomTextSprites(void)
|
||||
int i;
|
||||
int y;
|
||||
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
|
||||
if (!IsRegionMapZoomed())
|
||||
@ -724,7 +727,7 @@ static void SpriteCB_CityZoomText(struct Sprite *sprite)
|
||||
static void UpdateCityZoomTextPosition(void)
|
||||
{
|
||||
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);
|
||||
for (i = 0; i < (int)ARRAY_COUNT(state->cityZoomTextSprites); i++)
|
||||
state->cityZoomTextSprites[i]->y = y;
|
||||
@ -733,7 +736,7 @@ static void UpdateCityZoomTextPosition(void)
|
||||
static void SetCityZoomTextInvisibility(bool32 invisible)
|
||||
{
|
||||
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++)
|
||||
state->cityZoomTextSprites[i]->invisible = invisible;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user