fix dumb rtc mistake, disable blending when the weather conflicts with the effect

This commit is contained in:
ravepossum 2024-01-24 16:40:33 -05:00
parent 6d2a869d7f
commit f67c012532
5 changed files with 18 additions and 6 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -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);

View file

@ -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

View file

@ -348,7 +348,6 @@ u32 RtcGetLocalDayCount(void)
void FormatDecimalTimeWithoutSeconds(u8 *txtPtr, s8 hour, s8 minute, bool8 is24Hour)
{
RtcCalcLocalTime();
switch (is24Hour)
{
case TRUE: