Skip to content

Commit

Permalink
Use size constants for MAPSEC popup theme array
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards committed Nov 13, 2024
1 parent b89fda7 commit 039bc02
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/map_name_popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ static const u16 sMapPopUp_PaletteTable[][16] =

static const u16 sMapPopUp_Palette_Underwater[16] = INCBIN_U16("graphics/map_popup/underwater.gbapal");

static const u8 sRegionMapSectionId_To_PopUpThemeIdMapping[] =
// -1 in the size excludes MAPSEC_NONE.
// The MAPSEC values for Kanto (between MAPSEC_DYNAMIC and MAPSEC_AQUA_HIDEOUT) are also excluded,
// and this is then handled by subtracting KANTO_MAPSEC_COUNT here and in LoadMapNamePopUpWindowBg.
static const u8 sMapSectionToThemeId[MAPSEC_COUNT - KANTO_MAPSEC_COUNT - 1] =
{
[MAPSEC_LITTLEROOT_TOWN] = MAPPOPUP_THEME_WOOD,
[MAPSEC_OLDALE_TOWN] = MAPPOPUP_THEME_WOOD,
Expand Down Expand Up @@ -174,7 +177,7 @@ static const u8 sRegionMapSectionId_To_PopUpThemeIdMapping[] =
[MAPSEC_DESERT_UNDERPASS - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE,
[MAPSEC_ALTERING_CAVE - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE,
[MAPSEC_NAVEL_ROCK - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_STONE,
[MAPSEC_TRAINER_HILL - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_MARBLE
[MAPSEC_TRAINER_HILL - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_MARBLE,
};

static const u8 sText_PyramidFloor1[] = _("PYRAMID FLOOR 1");
Expand Down Expand Up @@ -410,7 +413,7 @@ static void LoadMapNamePopUpWindowBg(void)
else
regionMapSectionId = 0; // Discard kanto region sections;
}
popUpThemeId = sRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId];
popUpThemeId = sMapSectionToThemeId[regionMapSectionId];

LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), sMapPopUp_OutlineTable[popUpThemeId], 0x400, 0x21D);
CallWindowFunction(popupWindowId, DrawMapNamePopUpFrame);
Expand Down

0 comments on commit 039bc02

Please sign in to comment.