From f67c012532171728e139ff8d26667bd98e52fd4a Mon Sep 17 00:00:00 2001 From: ravepossum Date: Wed, 24 Jan 2024 16:40:33 -0500 Subject: [PATCH] fix dumb rtc mistake, disable blending when the weather conflicts with the effect --- include/field_weather.h | 1 + src/field_weather.c | 8 ++++++++ src/map_name_popup.c | 11 +++++++---- src/menu.c | 3 ++- src/rtc.c | 1 - 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/field_weather.h b/include/field_weather.h index 8ce0cc9e50..805047d288 100644 --- a/include/field_weather.h +++ b/include/field_weather.h @@ -170,6 +170,7 @@ void SetWeatherScreenFadeOut(void); void SetWeatherPalStateIdle(void); void PreservePaletteInWeather(u8 preservedPalIndex); void ResetPreservedPalettesInWeather(void); +bool8 IsWeatherAlphaBlend(void); // field_weather_effect.c void Clouds_InitVars(void); diff --git a/src/field_weather.c b/src/field_weather.c index 5ca9075250..151667ae7d 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -1108,3 +1108,11 @@ void ResetPreservedPalettesInWeather(void) { 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; +} diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 40e6c4513d..83701b25f0 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -2,6 +2,7 @@ #include "battle_pyramid.h" #include "bg.h" #include "event_data.h" +#include "field_weather.h" #include "gpu_regs.h" #include "graphics.h" #include "international_string_util.h" @@ -201,7 +202,7 @@ void ShowMapNamePopup(void) // New pop up window gPopupTaskId = CreateTask(Task_MapNamePopUpWindow, 100); - if (MAPPOPUP_ALPHA_BLEND) + if (MAPPOPUP_ALPHA_BLEND && !IsWeatherAlphaBlend()) SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND); gTasks[gPopupTaskId].tState = STATE_PRINT; @@ -297,7 +298,7 @@ void HideMapNamePopUpWindow(void) SetHBlankCallback(NULL); SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, 0); - if (MAPPOPUP_ALPHA_BLEND) + if (MAPPOPUP_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); @@ -320,7 +321,7 @@ static void ShowMapNamePopUpWindow(void) timeX = 5; timeY = 8; - if (MAPPOPUP_ALPHA_BLEND) + if (MAPPOPUP_ALPHA_BLEND && !IsWeatherAlphaBlend()) SetGpuRegBits(REG_OFFSET_WININ, WININ_WIN0_CLR); primaryPopUpWindowId = AddPrimaryPopUpWindow(); @@ -351,9 +352,11 @@ static void ShowMapNamePopUpWindow(void) mapDisplayHeader[0] = EXT_CTRL_CODE_BEGIN; mapDisplayHeader[1] = EXT_CTRL_CODE_HIGHLIGHT; mapDisplayHeader[2] = TEXT_COLOR_TRANSPARENT; - AddTextPrinterParameterized(primaryPopUpWindowId, FONT_SHORT, mapDisplayHeader, mapNameX, mapNameY, TEXT_SKIP_DRAW, NULL); + + RtcCalcLocalTime(); FormatDecimalTimeWithoutSeconds(withoutPrefixPtr, gLocalTime.hours, gLocalTime.minutes, MAPPOPUP_24_HOUR_TIME); + AddTextPrinterParameterized(secondaryPopUpWindowId, FONT_SMALL, mapDisplayHeader, GetStringRightAlignXOffset(FONT_SMALL, mapDisplayHeader, DISPLAY_WIDTH) - timeX, timeY, TEXT_SKIP_DRAW, NULL); CopyWindowToVram(primaryPopUpWindowId, COPYWIN_FULL); diff --git a/src/menu.c b/src/menu.c index 5ceb0f5996..c1b7fd290c 100644 --- a/src/menu.c +++ b/src/menu.c @@ -4,6 +4,7 @@ #include "blit.h" #include "dma3.h" #include "event_data.h" +#include "field_weather.h" #include "graphics.h" #include "main.h" #include "map_name_popup.h" @@ -2181,7 +2182,7 @@ void HBlankCB_DoublePopupWindow(void) if (scanline < 80 || scanline > 160) { REG_BG0VOFS = offset; - if(MAPPOPUP_ALPHA_BLEND) + if(MAPPOPUP_ALPHA_BLEND && !IsWeatherAlphaBlend()) REG_BLDALPHA = BLDALPHA_BLEND(15, 5); } else diff --git a/src/rtc.c b/src/rtc.c index 0344d17131..e78429aeb2 100644 --- a/src/rtc.c +++ b/src/rtc.c @@ -348,7 +348,6 @@ u32 RtcGetLocalDayCount(void) void FormatDecimalTimeWithoutSeconds(u8 *txtPtr, s8 hour, s8 minute, bool8 is24Hour) { - RtcCalcLocalTime(); switch (is24Hour) { case TRUE: