Use window constants in field_region_map

This commit is contained in:
GriffinR 2022-09-29 13:37:32 -04:00
parent 2cd07d80b8
commit 9ae918bb35

View file

@ -23,9 +23,15 @@
* For the fly map, and utility functions all of the maps use, see region_map.c * For the fly map, and utility functions all of the maps use, see region_map.c
*/ */
// Static type declarations enum {
WIN_MAPSEC_NAME,
WIN_TITLE,
};
// Static RAM declarations enum {
TAG_PLAYER_ICON,
TAG_CURSOR,
};
static EWRAM_DATA struct { static EWRAM_DATA struct {
MainCallback callback; MainCallback callback;
@ -34,16 +40,12 @@ static EWRAM_DATA struct {
u16 state; u16 state;
} *sFieldRegionMapHandler = NULL; } *sFieldRegionMapHandler = NULL;
// Static ROM declarations
static void MCB2_InitRegionMapRegisters(void); static void MCB2_InitRegionMapRegisters(void);
static void VBCB_FieldUpdateRegionMap(void); static void VBCB_FieldUpdateRegionMap(void);
static void MCB2_FieldUpdateRegionMap(void); static void MCB2_FieldUpdateRegionMap(void);
static void FieldUpdateRegionMap(void); static void FieldUpdateRegionMap(void);
static void PrintRegionMapSecName(void); static void PrintRegionMapSecName(void);
// .rodata
static const struct BgTemplate sFieldRegionMapBgTemplates[] = { static const struct BgTemplate sFieldRegionMapBgTemplates[] = {
{ {
.bg = 0, .bg = 0,
@ -66,7 +68,7 @@ static const struct BgTemplate sFieldRegionMapBgTemplates[] = {
static const struct WindowTemplate sFieldRegionMapWindowTemplates[] = static const struct WindowTemplate sFieldRegionMapWindowTemplates[] =
{ {
{ [WIN_MAPSEC_NAME] = {
.bg = 0, .bg = 0,
.tilemapLeft = 17, .tilemapLeft = 17,
.tilemapTop = 17, .tilemapTop = 17,
@ -75,7 +77,7 @@ static const struct WindowTemplate sFieldRegionMapWindowTemplates[] =
.paletteNum = 15, .paletteNum = 15,
.baseBlock = 1 .baseBlock = 1
}, },
{ [WIN_TITLE] = {
.bg = 0, .bg = 0,
.tilemapLeft = 22, .tilemapLeft = 22,
.tilemapTop = 1, .tilemapTop = 1,
@ -87,8 +89,6 @@ static const struct WindowTemplate sFieldRegionMapWindowTemplates[] =
DUMMY_WIN_TEMPLATE DUMMY_WIN_TEMPLATE
}; };
// .text
void FieldInitRegionMap(MainCallback callback) void FieldInitRegionMap(MainCallback callback)
{ {
SetVBlankCallback(NULL); SetVBlankCallback(NULL);
@ -145,16 +145,16 @@ static void FieldUpdateRegionMap(void)
{ {
case 0: case 0:
InitRegionMap(&sFieldRegionMapHandler->regionMap, FALSE); InitRegionMap(&sFieldRegionMapHandler->regionMap, FALSE);
CreateRegionMapPlayerIcon(0, 0); CreateRegionMapPlayerIcon(TAG_PLAYER_ICON, TAG_PLAYER_ICON);
CreateRegionMapCursor(1, 1); CreateRegionMapCursor(TAG_CURSOR, TAG_CURSOR);
sFieldRegionMapHandler->state++; sFieldRegionMapHandler->state++;
break; break;
case 1: case 1:
DrawStdFrameWithCustomTileAndPalette(1, FALSE, 0x27, 0xd); DrawStdFrameWithCustomTileAndPalette(WIN_TITLE, FALSE, 0x27, 0xd);
offset = GetStringCenterAlignXOffset(FONT_NORMAL, gText_Hoenn, 0x38); offset = GetStringCenterAlignXOffset(FONT_NORMAL, gText_Hoenn, 0x38);
AddTextPrinterParameterized(1, FONT_NORMAL, gText_Hoenn, offset, 1, 0, NULL); AddTextPrinterParameterized(WIN_TITLE, FONT_NORMAL, gText_Hoenn, offset, 1, 0, NULL);
ScheduleBgCopyTilemapToVram(0); ScheduleBgCopyTilemapToVram(0);
DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x27, 0xd); DrawStdFrameWithCustomTileAndPalette(WIN_MAPSEC_NAME, FALSE, 0x27, 0xd);
PrintRegionMapSecName(); PrintRegionMapSecName();
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
sFieldRegionMapHandler->state++; sFieldRegionMapHandler->state++;
@ -203,13 +203,13 @@ static void PrintRegionMapSecName(void)
{ {
if (sFieldRegionMapHandler->regionMap.mapSecType != MAPSECTYPE_NONE) if (sFieldRegionMapHandler->regionMap.mapSecType != MAPSECTYPE_NONE)
{ {
FillWindowPixelBuffer(0, PIXEL_FILL(1)); FillWindowPixelBuffer(WIN_MAPSEC_NAME, PIXEL_FILL(1));
AddTextPrinterParameterized(0, FONT_NORMAL, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL); AddTextPrinterParameterized(WIN_MAPSEC_NAME, FONT_NORMAL, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL);
ScheduleBgCopyTilemapToVram(0); ScheduleBgCopyTilemapToVram(WIN_MAPSEC_NAME);
} }
else else
{ {
FillWindowPixelBuffer(0, PIXEL_FILL(1)); FillWindowPixelBuffer(WIN_MAPSEC_NAME, PIXEL_FILL(1));
CopyWindowToVram(0, COPYWIN_FULL); CopyWindowToVram(WIN_MAPSEC_NAME, COPYWIN_FULL);
} }
} }