diff --git a/src/game.c b/src/game.c index 5a56eefcfd..05c54ac1ed 100644 --- a/src/game.c +++ b/src/game.c @@ -187,12 +187,14 @@ void update_palette_effects() // animate the water/lava/chain movement palette int q = 0; - extern const sint32 WeatherColours[4]; - int weather_colour = WeatherColours[gClimateCurrentWeatherGloom]; - if (weather_colour != -1 && gConfigGeneral.render_weather_gloom) { - q = 1; - if (weather_colour != 0x2000031) { - q = 2; + if (gConfigGeneral.render_weather_gloom) { + uint8 gloom = gClimateCurrentWeatherGloom; + if (gloom != 0) { + uint32 weatherColour = ClimateWeatherGloomColours[gloom]; + q = 1; + if (weatherColour != 0x2000031) { + q = 2; + } } } uint32 j = gPaletteEffectFrame; diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 4168032887..d28daf0d4f 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -69,7 +69,8 @@ static sint16 _unk9AC14E; static uint16 _unk9AC154; static sint16 _unk9ABDAE; -static void viewport_paint_column(rct_drawpixelinfo * dpi); +static void viewport_paint_column(rct_drawpixelinfo * dpi, uint32 viewFlags); +static void viewport_paint_weather_gloom(rct_drawpixelinfo * dpi); /** * This is not a viewport function. It is used to setup many variables for @@ -671,14 +672,6 @@ void viewport_render(rct_drawpixelinfo *dpi, rct_viewport *viewport, int left, i #endif } -/** rct2: 0x0098195C */ -const sint32 WeatherColours[] = { - -1, - 0x2000000 | 49, - 0x2000000 | 50, - 0x2000000 | 47, -}; - /** * * rct2: 0x00685CBF @@ -691,8 +684,7 @@ const sint32 WeatherColours[] = { */ void viewport_paint(rct_viewport* viewport, rct_drawpixelinfo* dpi, sint16 left, sint16 top, sint16 right, sint16 bottom) { - gCurrentViewportFlags = viewport->flags; - + uint32 viewFlags = viewport->flags; uint16 width = right - left; uint16 height = bottom - top; uint16 bitmask = 0xFFFF & (0xFFFF << viewport->zoom); @@ -740,46 +732,54 @@ void viewport_paint(rct_viewport* viewport, rct_drawpixelinfo* dpi, sint16 left, } dpi2.width = paintRight - dpi2.x; - viewport_paint_column(&dpi2); + viewport_paint_column(&dpi2, viewFlags); } } -static void viewport_paint_column(rct_drawpixelinfo * dpi) +static void viewport_paint_column(rct_drawpixelinfo * dpi, uint32 viewFlags) { - if (gCurrentViewportFlags & (VIEWPORT_FLAG_HIDE_VERTICAL | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_UNDERGROUND_INSIDE)){ - uint8 colour = 0x0A; - if (gCurrentViewportFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES){ + gCurrentViewportFlags = viewFlags; + unk_140E9A8 = dpi; + + if (viewFlags & (VIEWPORT_FLAG_HIDE_VERTICAL | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_UNDERGROUND_INSIDE)) { + uint8 colour = 10; + if (viewFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES) { colour = 0; } gfx_clear(dpi, colour); } gEndOfPaintStructArray = &gPaintStructs[4000 - 1]; - unk_140E9A8 = dpi; painter_setup(); viewport_paint_setup(); sub_688217(); - paint_quadrant_ps(dpi, &unk_EE7884->basic, gCurrentViewportFlags); + paint_quadrant_ps(dpi, &unk_EE7884->basic, viewFlags); - int weather_colour = WeatherColours[gClimateCurrentWeatherGloom]; - if ( - (weather_colour != -1) - && (!(gCurrentViewportFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES)) - && (!gTrackDesignSaveMode) - && (gConfigGeneral.render_weather_gloom) + if (gConfigGeneral.render_weather_gloom && + !gTrackDesignSaveMode && + !(viewFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES) ) { + viewport_paint_weather_gloom(dpi); + } + + if (gPaintPSStringHead != NULL) { + paint_ps_money_effects(dpi, gPaintPSStringHead); + } +} + +static void viewport_paint_weather_gloom(rct_drawpixelinfo * dpi) +{ + uint8 gloom = gClimateCurrentWeatherGloom; + if (gloom != 0) { + uint32 colour = ClimateWeatherGloomColours[gloom]; gfx_fill_rect( dpi, dpi->x, dpi->y, dpi->width + dpi->x - 1, dpi->height + dpi->y - 1, - weather_colour + colour ); } - - if (gPaintPSStringHead != NULL) { - paint_ps_money_effects(dpi, gPaintPSStringHead); - } } /** diff --git a/src/world/climate.c b/src/world/climate.c index a61782c8c9..3f2bee2394 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -345,6 +345,14 @@ static int climate_play_thunder(int instanceIndex, int soundId, int volume, int #pragma region Climate / Weather data tables +/** rct2: 0x0098195C */ +const uint32 ClimateWeatherGloomColours[4] = { + 0xFFFFFFFF, + 0x2000000 | 49, + 0x2000000 | 50, + 0x2000000 | 47, +}; + // rct2: 0x00993C94 // There is actually a sprite at 0x5A9C for snow but only these weather types seem to be fully implemented const rct_weather climate_weather_data[6] = { diff --git a/src/world/climate.h b/src/world/climate.h index 349c6a6df0..a76a489bfc 100644 --- a/src/world/climate.h +++ b/src/world/climate.h @@ -62,6 +62,7 @@ extern uint16 gClimateUpdateTimer; extern uint16 gClimateLightningFlash; extern const rct_weather climate_weather_data[6]; +extern const uint32 ClimateWeatherGloomColours[4]; int climate_celsius_to_fahrenheit(int celsius); void climate_reset(int climate);