first stab at making configable BW map pop-ups in expansion

This commit is contained in:
RavePossum 2024-04-15 15:26:43 -04:00
parent 5bf379720f
commit 406f87c534
14 changed files with 410 additions and 19 deletions

View file

@ -0,0 +1,19 @@
JASC-PAL
0100
16
0 0 0
0 0 0
255 255 255
41 49 90
0 0 0
238 230 238
189 180 197
139 139 164
90 90 123
41 49 90
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9 KiB

View file

@ -0,0 +1,19 @@
JASC-PAL
0100
16
0 0 0
255 255 255
0 0 0
158 158 158
0 0 0
238 230 238
189 180 197
139 139 164
90 90 123
41 49 90
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0

View file

@ -0,0 +1,23 @@
#ifndef GUARD_CONFIG_MAP_POPUP_H
#define GUARD_CONFIG_MAP_POPUP_H
// General map pop-up config
#define MAP_POPUP_GENERATION GEN_3 // Different generations display location names in overworld pop-ups differently
// current vaid choices are GEN_3 and GEN_5
// Gen 5 specific pop-up config
// Constants
#define MAP_POPUP_BW_TIME_NONE 0 // don't show the time
#define MAP_POPUP_BW_TIME_12_HR 1 // use 12 hour (AM/PM) time
#define MAP_POPUP_BW_TIME_24_HR 2 // use 24 hour time
#define MAP_POPUP_BW_COLOR_BLACK 0
#define MAP_POPUP_BW_COLOR_WHITE 1
// Configuration
#define MAP_POPUP_BW_COLOR MAP_POPUP_BW_COLOR_BLACK // Black 2 and White 2 use different colors for their map pop-ups
#define MAP_POPUP_BW_TIME_MODE MAP_POPUP_BW_TIME_NONE // determines what type of time is shown
#define MAP_POPUP_BW_ALPHA_BLEND FALSE // enables alpha blending/transparency for the pop-ups
// mostly intended to be used with the black color option
#endif // GUARD_CONFIG_MAP_POPUP_H

View file

@ -170,6 +170,7 @@ void SetWeatherScreenFadeOut(void);
void SetWeatherPalStateIdle(void); void SetWeatherPalStateIdle(void);
void PreservePaletteInWeather(u8 preservedPalIndex); void PreservePaletteInWeather(u8 preservedPalIndex);
void ResetPreservedPalettesInWeather(void); void ResetPreservedPalettesInWeather(void);
bool8 IsWeatherAlphaBlend(void);
// field_weather_effect.c // field_weather_effect.c
void Clouds_InitVars(void); void Clouds_InitVars(void);

View file

@ -41,6 +41,7 @@ struct MenuAction
}; };
extern const u16 gStandardMenuPalette[]; extern const u16 gStandardMenuPalette[];
extern EWRAM_DATA u8 gPopupTaskId;
void FreeAllOverworldWindowBuffers(void); void FreeAllOverworldWindowBuffers(void);
void InitStandardTextBoxWindows(void); void InitStandardTextBoxWindows(void);
@ -124,5 +125,9 @@ void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonP
void EraseYesNoWindow(void); void EraseYesNoWindow(void);
void PrintMenuActionTextsAtPos(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs); void PrintMenuActionTextsAtPos(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *strs);
void Menu_LoadStdPal(void); void Menu_LoadStdPal(void);
u8 AddSecondaryPopUpWindow(void);
u8 GetSecondaryPopUpWindowId(void);
void RemoveSecondaryPopUpWindow(void);
void HBlankCB_DoublePopupWindow(void);
#endif // GUARD_MENU_H #endif // GUARD_MENU_H

View file

@ -118,5 +118,6 @@ void RtcCalcLocalTimeOffset(s32 days, s32 hours, s32 minutes, s32 seconds);
void CalcTimeDifference(struct Time *result, struct Time *t1, struct Time *t2); void CalcTimeDifference(struct Time *result, struct Time *t1, struct Time *t2);
u32 RtcGetMinuteCount(void); u32 RtcGetMinuteCount(void);
u32 RtcGetLocalDayCount(void); u32 RtcGetLocalDayCount(void);
void FormatDecimalTimeWithoutSeconds(u8 *dest, s8 hour, s8 minute, bool8 is24Hour);
#endif // GUARD_RTC_UTIL_H #endif // GUARD_RTC_UTIL_H

View file

@ -3061,4 +3061,8 @@ extern const u8 gText_BasePointsResetToZero[];
extern const u8 gText_Fertilize[]; extern const u8 gText_Fertilize[];
extern const u8 gText_PlantBerry[]; extern const u8 gText_PlantBerry[];
// Map name pop-up
extern const u8 gText_AM[];
extern const u8 gText_PM[];
#endif // GUARD_STRINGS_H #endif // GUARD_STRINGS_H

View file

@ -1104,3 +1104,11 @@ void ResetPreservedPalettesInWeather(void)
{ {
sPaletteColorMapTypes = sBasePaletteColorMapTypes; sPaletteColorMapTypes = sBasePaletteColorMapTypes;
} }
bool8 IsWeatherAlphaBlend(void)
{
return gWeatherPtr->currWeather == WEATHER_FOG_HORIZONTAL ||
gWeatherPtr->currWeather == WEATHER_FOG_DIAGONAL ||
gWeatherPtr->currWeather == WEATHER_UNDERWATER_BUBBLES ||
gWeatherPtr->currWeather == WEATHER_UNDERWATER;
}

View file

@ -2,12 +2,16 @@
#include "battle_pyramid.h" #include "battle_pyramid.h"
#include "bg.h" #include "bg.h"
#include "event_data.h" #include "event_data.h"
#include "field_weather.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "graphics.h"
#include "international_string_util.h" #include "international_string_util.h"
#include "main.h"
#include "menu.h" #include "menu.h"
#include "map_name_popup.h" #include "map_name_popup.h"
#include "palette.h" #include "palette.h"
#include "region_map.h" #include "region_map.h"
#include "rtc.h"
#include "start_menu.h" #include "start_menu.h"
#include "string_util.h" #include "string_util.h"
#include "task.h" #include "task.h"
@ -16,7 +20,142 @@
#include "constants/layouts.h" #include "constants/layouts.h"
#include "constants/region_map_sections.h" #include "constants/region_map_sections.h"
#include "constants/weather.h" #include "constants/weather.h"
#include "config/map_name_popup.h"
#include "config.h"
#if MAP_POPUP_GENERATION != GEN_3 && MAP_POPUP_GENERATION != GEN_5
#error "Invalid choice for MAP_POPUP_GENERATION, must be one of [GEN_3, GEN_5]"
#endif
// static functions
static void Task_MapNamePopUpWindow(u8 taskId);
static void ShowMapNamePopUpWindow(void);
static void LoadMapNamePopUpWindowBg(void);
// EWRAM
EWRAM_DATA u8 gPopupTaskId = 0;
#if MAP_POPUP_GENERATION == GEN_5
// enums
enum MapPopUp_Themes
{
MAPPOPUP_THEME_DEFAULT,
};
// .rodata
static const u8 sMapPopUpTilesPrimary_BW[] = INCBIN_U8("graphics/map_popup/bw/bw_primary.4bpp");
static const u8 sMapPopUpTilesSecondary_BW[] = INCBIN_U8("graphics/map_popup/bw/bw_secondary.4bpp");
static const u16 sMapPopUpTilesPalette_BW_Black[16] = INCBIN_U16("graphics/map_popup/bw/black.gbapal");
static const u16 sMapPopUpTilesPalette_BW_White[16] = INCBIN_U16("graphics/map_popup/bw/white.gbapal");
static const u8 sRegionMapSectionId_To_PopUpThemeIdMapping[] =
{
[MAPSEC_LITTLEROOT_TOWN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_OLDALE_TOWN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_DEWFORD_TOWN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_LAVARIDGE_TOWN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_FALLARBOR_TOWN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_VERDANTURF_TOWN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_PACIFIDLOG_TOWN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_PETALBURG_CITY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SLATEPORT_CITY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_MAUVILLE_CITY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_RUSTBORO_CITY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_FORTREE_CITY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_LILYCOVE_CITY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_MOSSDEEP_CITY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SOOTOPOLIS_CITY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_EVER_GRANDE_CITY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_101] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_102] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_103] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_104] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_105] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_106] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_107] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_108] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_109] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_110] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_111] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_112] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_113] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_114] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_115] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_116] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_117] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_118] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_119] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_120] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_121] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_122] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_123] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_124] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_125] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_126] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_127] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_128] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_129] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_130] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_131] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_132] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_133] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ROUTE_134] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_124] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_126] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_127] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_128] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_SOOTOPOLIS] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_GRANITE_CAVE] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_MT_CHIMNEY] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SAFARI_ZONE] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_BATTLE_FRONTIER] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_PETALBURG_WOODS] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_RUSTURF_TUNNEL] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ABANDONED_SHIP] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_NEW_MAUVILLE] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_METEOR_FALLS] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_METEOR_FALLS2] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_MT_PYRE] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_AQUA_HIDEOUT_OLD] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SHOAL_CAVE] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SEAFLOOR_CAVERN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_SEAFLOOR_CAVERN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_VICTORY_ROAD] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_MIRAGE_ISLAND] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_CAVE_OF_ORIGIN] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SOUTHERN_ISLAND] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_FIERY_PATH] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_FIERY_PATH2] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_JAGGED_PASS] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_JAGGED_PASS2] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SEALED_CHAMBER] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_SEALED_CHAMBER] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SCORCHED_SLAB] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ISLAND_CAVE] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_DESERT_RUINS] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ANCIENT_TOMB] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_INSIDE_OF_TRUCK] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SKY_PILLAR] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_SECRET_BASE] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_DYNAMIC] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_AQUA_HIDEOUT - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_MAGMA_HIDEOUT - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_MIRAGE_TOWER - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_BIRTH_ISLAND - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_FARAWAY_ISLAND - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ARTISAN_CAVE - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_MARINE_CAVE - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_MARINE_CAVE - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_TERRA_CAVE - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_105 - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_125 - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_UNDERWATER_129 - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_DESERT_UNDERPASS - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_ALTERING_CAVE - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_NAVEL_ROCK - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
[MAPSEC_TRAINER_HILL - KANTO_MAPSEC_COUNT] = MAPPOPUP_THEME_DEFAULT,
};
#else
// enums // enums
enum MapPopUp_Themes enum MapPopUp_Themes
{ {
@ -28,14 +167,6 @@ enum MapPopUp_Themes
MAPPOPUP_THEME_STONE2, MAPPOPUP_THEME_STONE2,
}; };
// static functions
static void Task_MapNamePopUpWindow(u8 taskId);
static void ShowMapNamePopUpWindow(void);
static void LoadMapNamePopUpWindowBg(void);
// EWRAM
static EWRAM_DATA u8 sPopupTaskId = 0;
// .rodata // .rodata
static const u8 sMapPopUp_Table[][960] = static const u8 sMapPopUp_Table[][960] =
{ {
@ -176,6 +307,7 @@ static const u8 sRegionMapSectionId_To_PopUpThemeIdMapping[] =
[MAPSEC_NAVEL_ROCK - 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
}; };
#endif
static const u8 sText_PyramidFloor1[] = _("PYRAMID FLOOR 1"); static const u8 sText_PyramidFloor1[] = _("PYRAMID FLOOR 1");
static const u8 sText_PyramidFloor2[] = _("PYRAMID FLOOR 2"); static const u8 sText_PyramidFloor2[] = _("PYRAMID FLOOR 2");
@ -216,7 +348,7 @@ enum {
STATE_PRINT, // For some reason the first state is numerically last. STATE_PRINT, // For some reason the first state is numerically last.
}; };
#define POPUP_OFFSCREEN_Y 40 #define POPUP_OFFSCREEN_Y ((MAP_POPUP_GENERATION == GEN_5) ? 24 : 40)
#define POPUP_SLIDE_SPEED 2 #define POPUP_SLIDE_SPEED 2
#define tState data[0] #define tState data[0]
@ -232,18 +364,26 @@ void ShowMapNamePopup(void)
if (!FuncIsActiveTask(Task_MapNamePopUpWindow)) if (!FuncIsActiveTask(Task_MapNamePopUpWindow))
{ {
// New pop up window // New pop up window
sPopupTaskId = CreateTask(Task_MapNamePopUpWindow, 90); #if MAP_POPUP_GENERATION == GEN_5
gPopupTaskId = CreateTask(Task_MapNamePopUpWindow, 100);
if (MAP_POPUP_BW_ALPHA_BLEND && !IsWeatherAlphaBlend())
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND);
#else
gPopupTaskId = CreateTask(Task_MapNamePopUpWindow, 90);
SetGpuReg(REG_OFFSET_BG0VOFS, POPUP_OFFSCREEN_Y); SetGpuReg(REG_OFFSET_BG0VOFS, POPUP_OFFSCREEN_Y);
gTasks[sPopupTaskId].tState = STATE_PRINT; #endif
gTasks[sPopupTaskId].tYOffset = POPUP_OFFSCREEN_Y;
gTasks[gPopupTaskId].tState = STATE_PRINT;
gTasks[gPopupTaskId].tYOffset = POPUP_OFFSCREEN_Y;
} }
else else
{ {
// There's already a pop up window running. // There's already a pop up window running.
// Hurry the old pop up offscreen so the new one can appear. // Hurry the old pop up offscreen so the new one can appear.
if (gTasks[sPopupTaskId].tState != STATE_SLIDE_OUT) if (gTasks[gPopupTaskId].tState != STATE_SLIDE_OUT)
gTasks[sPopupTaskId].tState = STATE_SLIDE_OUT; gTasks[gPopupTaskId].tState = STATE_SLIDE_OUT;
gTasks[sPopupTaskId].tIncomingPopUp = TRUE; gTasks[gPopupTaskId].tIncomingPopUp = TRUE;
} }
} }
} }
@ -261,6 +401,10 @@ static void Task_MapNamePopUpWindow(u8 taskId)
task->tState = STATE_SLIDE_IN; task->tState = STATE_SLIDE_IN;
task->tPrintTimer = 0; task->tPrintTimer = 0;
ShowMapNamePopUpWindow(); ShowMapNamePopUpWindow();
#if MAP_POPUP_GENERATION == GEN_5
EnableInterrupts(INTR_FLAG_HBLANK);
SetHBlankCallback(HBlankCB_DoublePopupWindow);
#endif
} }
break; break;
case STATE_SLIDE_IN: case STATE_SLIDE_IN:
@ -270,7 +414,7 @@ static void Task_MapNamePopUpWindow(u8 taskId)
{ {
task->tYOffset = 0; task->tYOffset = 0;
task->tState = STATE_WAIT; task->tState = STATE_WAIT;
gTasks[sPopupTaskId].data[1] = 0; gTasks[gPopupTaskId].data[1] = 0;
} }
break; break;
case STATE_WAIT: case STATE_WAIT:
@ -304,13 +448,18 @@ static void Task_MapNamePopUpWindow(u8 taskId)
break; break;
case STATE_ERASE: case STATE_ERASE:
ClearStdWindowAndFrame(GetMapNamePopUpWindowId(), TRUE); ClearStdWindowAndFrame(GetMapNamePopUpWindowId(), TRUE);
#if MAP_POPUP_GENERATION == GEN_5
ClearStdWindowAndFrame(GetSecondaryPopUpWindowId(), TRUE);
#endif
task->tState = STATE_END; task->tState = STATE_END;
break; break;
case STATE_END: case STATE_END:
HideMapNamePopUpWindow(); HideMapNamePopUpWindow();
return; return;
} }
#if MAP_POPUP_GENERATION != GEN_5
SetGpuReg(REG_OFFSET_BG0VOFS, task->tYOffset); SetGpuReg(REG_OFFSET_BG0VOFS, task->tYOffset);
#endif
} }
void HideMapNamePopUpWindow(void) void HideMapNamePopUpWindow(void)
@ -324,8 +473,28 @@ void HideMapNamePopUpWindow(void)
ClearStdWindowAndFrame(GetMapNamePopUpWindowId(), TRUE); ClearStdWindowAndFrame(GetMapNamePopUpWindowId(), TRUE);
RemoveMapNamePopUpWindow(); RemoveMapNamePopUpWindow();
} }
#if MAP_POPUP_GENERATION == GEN_5
#ifdef UBFIX
if (GetSecondaryPopUpWindowId() != WINDOW_NONE)
#endif // UBFIX
{
ClearStdWindowAndFrame(GetSecondaryPopUpWindowId(), TRUE);
RemoveSecondaryPopUpWindow();
}
DisableInterrupts(INTR_FLAG_HBLANK);
SetHBlankCallback(NULL);
if (MAP_POPUP_BW_ALPHA_BLEND && !IsWeatherAlphaBlend())
{
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 10));
}
#endif
SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, 0); SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, 0);
DestroyTask(sPopupTaskId); DestroyTask(gPopupTaskId);
} }
} }
@ -333,8 +502,12 @@ static void ShowMapNamePopUpWindow(void)
{ {
u8 mapDisplayHeader[24]; u8 mapDisplayHeader[24];
u8 *withoutPrefixPtr; u8 *withoutPrefixPtr;
u8 x;
const u8 *mapDisplayHeaderSource; const u8 *mapDisplayHeaderSource;
#if MAP_POPUP_GENERATION == GEN_5
u8 mapNamePopUpWindowId, secondaryPopUpWindowId;
#else
u8 x;
#endif
if (InBattlePyramid()) if (InBattlePyramid())
{ {
@ -355,16 +528,43 @@ static void ShowMapNamePopUpWindow(void)
withoutPrefixPtr = &(mapDisplayHeader[3]); withoutPrefixPtr = &(mapDisplayHeader[3]);
GetMapName(withoutPrefixPtr, gMapHeader.regionMapSectionId, 0); GetMapName(withoutPrefixPtr, gMapHeader.regionMapSectionId, 0);
} }
#if MAP_POPUP_GENERATION == GEN_5
if (MAP_POPUP_BW_ALPHA_BLEND && !IsWeatherAlphaBlend())
SetGpuRegBits(REG_OFFSET_WININ, WININ_WIN0_CLR);
mapNamePopUpWindowId = AddMapNamePopUpWindow();
secondaryPopUpWindowId = AddSecondaryPopUpWindow();
#else
AddMapNamePopUpWindow(); AddMapNamePopUpWindow();
#endif
LoadMapNamePopUpWindowBg(); LoadMapNamePopUpWindowBg();
x = GetStringCenterAlignXOffset(FONT_NARROW, withoutPrefixPtr, 80);
mapDisplayHeader[0] = EXT_CTRL_CODE_BEGIN; mapDisplayHeader[0] = EXT_CTRL_CODE_BEGIN;
mapDisplayHeader[1] = EXT_CTRL_CODE_HIGHLIGHT; mapDisplayHeader[1] = EXT_CTRL_CODE_HIGHLIGHT;
mapDisplayHeader[2] = TEXT_COLOR_TRANSPARENT; mapDisplayHeader[2] = TEXT_COLOR_TRANSPARENT;
#if MAP_POPUP_GENERATION == GEN_5
AddTextPrinterParameterized(mapNamePopUpWindowId, FONT_SHORT, mapDisplayHeader, 8, 2, TEXT_SKIP_DRAW, NULL);
if (MAP_POPUP_BW_TIME_MODE != MAP_POPUP_BW_TIME_NONE)
{
RtcCalcLocalTime();
FormatDecimalTimeWithoutSeconds(withoutPrefixPtr, gLocalTime.hours, gLocalTime.minutes, MAP_POPUP_BW_TIME_MODE == MAP_POPUP_BW_TIME_24_HR);
AddTextPrinterParameterized(secondaryPopUpWindowId, FONT_SMALL, mapDisplayHeader, GetStringRightAlignXOffset(FONT_SMALL, mapDisplayHeader, DISPLAY_WIDTH) - 5, 8, TEXT_SKIP_DRAW, NULL);
}
CopyWindowToVram(mapNamePopUpWindowId, COPYWIN_FULL);
CopyWindowToVram(secondaryPopUpWindowId, COPYWIN_FULL);
#else
x = GetStringCenterAlignXOffset(FONT_NARROW, withoutPrefixPtr, 80);
AddTextPrinterParameterized(GetMapNamePopUpWindowId(), FONT_NARROW, mapDisplayHeader, x, 3, TEXT_SKIP_DRAW, NULL); AddTextPrinterParameterized(GetMapNamePopUpWindowId(), FONT_NARROW, mapDisplayHeader, x, 3, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(GetMapNamePopUpWindowId(), COPYWIN_FULL); CopyWindowToVram(GetMapNamePopUpWindowId(), COPYWIN_FULL);
#endif
} }
#if MAP_POPUP_GENERATION != GEN_5
#define TILE_TOP_EDGE_START 0x21D #define TILE_TOP_EDGE_START 0x21D
#define TILE_TOP_EDGE_END 0x228 #define TILE_TOP_EDGE_END 0x228
#define TILE_LEFT_EDGE_TOP 0x229 #define TILE_LEFT_EDGE_TOP 0x229
@ -396,12 +596,16 @@ static void DrawMapNamePopUpFrame(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 un
for (i = 0; i < 1 + TILE_BOT_EDGE_END - TILE_BOT_EDGE_START; i++) for (i = 0; i < 1 + TILE_BOT_EDGE_END - TILE_BOT_EDGE_START; i++)
FillBgTilemapBufferRect(bg, TILE_BOT_EDGE_START + i, i - 1 + x, y + deltaY, 1, 1, 14); FillBgTilemapBufferRect(bg, TILE_BOT_EDGE_START + i, i - 1 + x, y + deltaY, 1, 1, 14);
} }
#endif
static void LoadMapNamePopUpWindowBg(void) static void LoadMapNamePopUpWindowBg(void)
{ {
u8 popUpThemeId; u8 popUpThemeId;
u8 popupWindowId = GetMapNamePopUpWindowId(); u8 popupWindowId = GetMapNamePopUpWindowId();
u16 regionMapSectionId = gMapHeader.regionMapSectionId; u16 regionMapSectionId = gMapHeader.regionMapSectionId;
#if MAP_POPUP_GENERATION == GEN_5
u8 secondaryPopUpWindowId = GetSecondaryPopUpWindowId();
#endif
if (regionMapSectionId >= KANTO_MAPSEC_START) if (regionMapSectionId >= KANTO_MAPSEC_START)
{ {
@ -412,6 +616,23 @@ static void LoadMapNamePopUpWindowBg(void)
} }
popUpThemeId = sRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId]; popUpThemeId = sRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId];
#if MAP_POPUP_GENERATION == GEN_5
switch (popUpThemeId) {
// add more themes as case statements here
default:
if (MAP_POPUP_BW_COLOR == MAP_POPUP_BW_COLOR_WHITE)
LoadPalette(sMapPopUpTilesPalette_BW_White, BG_PLTT_ID(14), sizeof(sMapPopUpTilesPalette_BW_White));
else
LoadPalette(sMapPopUpTilesPalette_BW_Black, BG_PLTT_ID(14), sizeof(sMapPopUpTilesPalette_BW_Black));
CopyToWindowPixelBuffer(popupWindowId, sMapPopUpTilesPrimary_BW, sizeof(sMapPopUpTilesPrimary_BW), 0);
CopyToWindowPixelBuffer(secondaryPopUpWindowId, sMapPopUpTilesSecondary_BW, sizeof(sMapPopUpTilesSecondary_BW), 0);
break;
}
PutWindowTilemap(popupWindowId);
PutWindowTilemap(secondaryPopUpWindowId);
#else
LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), sMapPopUp_OutlineTable[popUpThemeId], 0x400, 0x21D); LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), sMapPopUp_OutlineTable[popUpThemeId], 0x400, 0x21D);
CallWindowFunction(popupWindowId, DrawMapNamePopUpFrame); CallWindowFunction(popupWindowId, DrawMapNamePopUpFrame);
PutWindowTilemap(popupWindowId); PutWindowTilemap(popupWindowId);
@ -420,4 +641,5 @@ static void LoadMapNamePopUpWindowBg(void)
else else
LoadPalette(sMapPopUp_PaletteTable[popUpThemeId], BG_PLTT_ID(14), sizeof(sMapPopUp_PaletteTable[0])); LoadPalette(sMapPopUp_PaletteTable[popUpThemeId], BG_PLTT_ID(14), sizeof(sMapPopUp_PaletteTable[0]));
BlitBitmapToWindow(popupWindowId, sMapPopUp_Table[popUpThemeId], 0, 0, 80, 24); BlitBitmapToWindow(popupWindowId, sMapPopUp_Table[popUpThemeId], 0, 0, 80, 24);
#endif
} }

View file

@ -4,8 +4,10 @@
#include "blit.h" #include "blit.h"
#include "dma3.h" #include "dma3.h"
#include "event_data.h" #include "event_data.h"
#include "field_weather.h"
#include "graphics.h" #include "graphics.h"
#include "main.h" #include "main.h"
#include "map_name_popup.h"
#include "menu.h" #include "menu.h"
#include "menu_helpers.h" #include "menu_helpers.h"
#include "palette.h" #include "palette.h"
@ -18,6 +20,7 @@
#include "task.h" #include "task.h"
#include "text_window.h" #include "text_window.h"
#include "window.h" #include "window.h"
#include "config/map_name_popup.h"
#include "constants/songs.h" #include "constants/songs.h"
#define DLG_WINDOW_PALETTE_NUM 15 #define DLG_WINDOW_PALETTE_NUM 15
@ -62,6 +65,9 @@ static void task_free_buf_after_copying_tile_data_to_vram(u8 taskId);
static EWRAM_DATA u8 sStartMenuWindowId = 0; static EWRAM_DATA u8 sStartMenuWindowId = 0;
static EWRAM_DATA u8 sMapNamePopupWindowId = 0; static EWRAM_DATA u8 sMapNamePopupWindowId = 0;
#if MAP_POPUP_GENERATION == GEN_5
static EWRAM_DATA u8 sSecondaryPopupWindowId = 0;
#endif
static EWRAM_DATA struct Menu sMenu = {0}; static EWRAM_DATA struct Menu sMenu = {0};
static EWRAM_DATA u16 sTileNum = 0; static EWRAM_DATA u16 sTileNum = 0;
static EWRAM_DATA u8 sPaletteNum = 0; static EWRAM_DATA u8 sPaletteNum = 0;
@ -145,6 +151,9 @@ void InitStandardTextBoxWindows(void)
InitWindows(sStandardTextBox_WindowTemplates); InitWindows(sStandardTextBox_WindowTemplates);
sStartMenuWindowId = WINDOW_NONE; sStartMenuWindowId = WINDOW_NONE;
sMapNamePopupWindowId = WINDOW_NONE; sMapNamePopupWindowId = WINDOW_NONE;
#if MAP_POPUP_GENERATION == GEN_5
sSecondaryPopupWindowId = WINDOW_NONE;
#endif
} }
void FreeAllOverworldWindowBuffers(void) void FreeAllOverworldWindowBuffers(void)
@ -521,7 +530,13 @@ static u16 UNUSED GetStandardFrameBaseTileNum(void)
u8 AddMapNamePopUpWindow(void) u8 AddMapNamePopUpWindow(void)
{ {
if (sMapNamePopupWindowId == WINDOW_NONE) if (sMapNamePopupWindowId == WINDOW_NONE)
{
#if MAP_POPUP_GENERATION == GEN_5
sMapNamePopupWindowId = AddWindowParameterized(0, 0, 0, 30, 3, 14, 0x107);
#else
sMapNamePopupWindowId = AddWindowParameterized(0, 1, 1, 10, 3, 14, 0x107); sMapNamePopupWindowId = AddWindowParameterized(0, 1, 1, 10, 3, 14, 0x107);
#endif
}
return sMapNamePopupWindowId; return sMapNamePopupWindowId;
} }
@ -2145,3 +2160,44 @@ void BufferSaveMenuText(u8 textId, u8 *dest, u8 color)
break; break;
} }
} }
// BW map pop-ups
#if MAP_POPUP_GENERATION == GEN_5
u8 AddSecondaryPopUpWindow(void)
{
if (sSecondaryPopupWindowId == WINDOW_NONE)
sSecondaryPopupWindowId = AddWindowParameterized(0, 0, 17, 30, 3, 14, 0x161);
return sSecondaryPopupWindowId;
}
u8 GetSecondaryPopUpWindowId(void)
{
return sSecondaryPopupWindowId;
}
void RemoveSecondaryPopUpWindow(void)
{
if (sSecondaryPopupWindowId != WINDOW_NONE)
{
RemoveWindow(sSecondaryPopupWindowId);
sSecondaryPopupWindowId = WINDOW_NONE;
}
}
void HBlankCB_DoublePopupWindow(void)
{
u16 offset = gTasks[gPopupTaskId].data[2];
u16 scanline = REG_VCOUNT;
if (scanline < 80 || scanline > 160)
{
REG_BG0VOFS = offset;
if(MAP_POPUP_BW_ALPHA_BLEND && !IsWeatherAlphaBlend())
REG_BLDALPHA = BLDALPHA_BLEND(15, 5);
}
else
{
REG_BG0VOFS = 512 - offset;
}
}
#endif

View file

@ -1,6 +1,7 @@
#include "global.h" #include "global.h"
#include "rtc.h" #include "rtc.h"
#include "string_util.h" #include "string_util.h"
#include "strings.h"
#include "text.h" #include "text.h"
// iwram bss // iwram bss
@ -364,3 +365,33 @@ u32 RtcGetLocalDayCount(void)
{ {
return RtcGetDayCount(&sRtc); return RtcGetDayCount(&sRtc);
} }
void FormatDecimalTimeWithoutSeconds(u8 *txtPtr, s8 hour, s8 minute, bool8 is24Hour)
{
if (is24Hour)
{
txtPtr = ConvertIntToDecimalStringN(txtPtr, hour, STR_CONV_MODE_LEADING_ZEROS, 2);
*txtPtr++ = CHAR_COLON;
txtPtr = ConvertIntToDecimalStringN(txtPtr, minute, STR_CONV_MODE_LEADING_ZEROS, 2);
}
else
{
if (hour == 0)
txtPtr = ConvertIntToDecimalStringN(txtPtr, 12, STR_CONV_MODE_LEADING_ZEROS, 2);
else if (hour < 13)
txtPtr = ConvertIntToDecimalStringN(txtPtr, hour, STR_CONV_MODE_LEADING_ZEROS, 2);
else
txtPtr = ConvertIntToDecimalStringN(txtPtr, hour - 12, STR_CONV_MODE_LEADING_ZEROS, 2);
*txtPtr++ = CHAR_COLON;
txtPtr = ConvertIntToDecimalStringN(txtPtr, minute, STR_CONV_MODE_LEADING_ZEROS, 2);
txtPtr = StringAppend(txtPtr, gText_Space);
if (hour < 12)
txtPtr = StringAppend(txtPtr, gText_AM);
else
txtPtr = StringAppend(txtPtr, gText_PM);
}
*txtPtr++ = EOS;
*txtPtr = EOS;
}

View file

@ -1856,3 +1856,5 @@ const u8 gText_ExpShareOff[] = _("The Exp. Share has been turned off.{PAUSE_UNTI
const u8 gText_BasePointsResetToZero[] = _("{STR_VAR_1}'s base points\nwere all reset to zero!{PAUSE_UNTIL_PRESS}"); const u8 gText_BasePointsResetToZero[] = _("{STR_VAR_1}'s base points\nwere all reset to zero!{PAUSE_UNTIL_PRESS}");
const u8 gText_Fertilize[] = _("FERTILIZE"); const u8 gText_Fertilize[] = _("FERTILIZE");
const u8 gText_PlantBerry[] = _("PLANT BERRY"); const u8 gText_PlantBerry[] = _("PLANT BERRY");
const u8 gText_AM[] = _("AM");
const u8 gText_PM[] = _("PM");