diff --git a/src/addresses.h b/src/addresses.h index d042c530d9..c59bb061a4 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -168,6 +168,14 @@ #define RCT2_ADDRESS_CURRENT_WEATHER 0x013CA74A #define RCT2_ADDRESS_NEXT_WEATHER 0x013CA74B #define RCT2_ADDRESS_CURRENT_TEMPERATURE 0x013CA74C +#define RCT2_ADDRESS_NEXT_TEMPERATURE 0x013CA74D +#define RCT2_ADDRESS_CLIMATE_UPDATE_TIMER 0x013CA748 +#define RCT2_ADDRESS_CURRENT_WEATHER_EFFECT 0x013CA74E +#define RCT2_ADDRESS_NEXT_WEATHER_EFFECT 0x013CA74F +#define RCT2_ADDRESS_CURRENT_WEATHER_GLOOM 0x013CA750 +#define RCT2_ADDRESS_NEXT_WEATHER_GLOOM 0x013CA751 +#define RCT2_ADDRESS_CURRENT_RAIN_LEVEL 0x013CA752 +#define RCT2_ADDRESS_NEXT_RAIN_LEVEL 0x013CA753 #define RCT2_ADDRESS_NEWS_ITEM_LIST 0x013CA754 diff --git a/src/climate.c b/src/climate.c index 71ae908eda..dd2275be2a 100644 --- a/src/climate.c +++ b/src/climate.c @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Ted John + * Copyright (c) 2014 Ted John, Matthias Lanzinger * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -19,32 +19,234 @@ *****************************************************************************/ #include "addresses.h" +#include "climate.h" #include "date.h" +#include "gfx.h" #include "rct2.h" +typedef struct { + sint8 base_temperature; + sint8 distribution_size; + sint8 distribution[24]; +} rct_weather_transition; + +int gClimateNextWeather; + +static int _climateNextTemperature; +static int _climateNextWeatherEffect; +static int _climateNextWeatherGloom; +static int _climateNextRainLevel; + +static const rct_weather_transition* climate_transitions[4]; + +static void climate_determine_future_weather(); + int climate_celcius_to_fahrenheit(int celcius) { return (celcius * 29) / 16 + 32; } /** - * + * Set climate and determine start weather. * rct2: 0x006C45ED */ void climate_reset(int climate) { - int eax, ebx, ecx, edx, esi, edi, ebp; - RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, sint8) = climate; - - eax = 1; - RCT2_CALLFUNC_X(0x006C4672, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) = eax & 0xFF; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TEMPERATURE, sint8) = ebx & 0xFF; - - RCT2_GLOBAL(0x013CA74E, sint8) = (ebx >> 8) & 0xFF; - RCT2_GLOBAL(0x013CA750, sint8) = ecx & 0xFF; - RCT2_GLOBAL(0x013CA752, sint8) = (ecx >> 8) & 0xFF; - RCT2_CALLPROC_X(0x6C461C, 0, 0, 0, 0, 0, 0, 0); + climate_determine_future_weather(); } + + +/** + * Weather & climate update iteration. + * Gradually changes the weather parameters towards their determined next values. + * + * rct2: 0x006C46B1 + */ +void climate_update() +{ + uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8); + sint8 temperature = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TEMPERATURE, sint8), + target_temperature = _climateNextTemperature, + cur_gloom = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER_GLOOM, sint8), + next_gloom = _climateNextWeatherGloom, + cur_rain = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RAIN_LEVEL, sint8), + next_rain = _climateNextRainLevel; + + + if (screen_flags & (~SCREEN_FLAGS_PLAYING)) // only normal play mode gets climate + return; + + if (RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16)) { + + if (RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16) == 960) + RCT2_GLOBAL(0x009A9804, uint32) |= 8; // climate dirty flag? + + RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16)--; + + } else if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, sint32) & 0x7F)) { + + if (temperature == target_temperature) { + if (cur_gloom == next_gloom) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER_EFFECT, sint8) = _climateNextWeatherEffect; + + if (cur_rain == next_rain) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) = gClimateNextWeather; + climate_determine_future_weather(); + RCT2_GLOBAL(0x009A9804, uint32) |= 8; // climate dirty flag? + } else { + if (next_rain == 3) { + cur_rain = 3; + } else { + sint8 next_rain_step = cur_rain + 1; + if (cur_rain > next_rain) + next_rain_step = cur_rain - 1; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RAIN_LEVEL, sint8) = next_rain_step; + } + } + } else { + sint8 next_gloom_step = cur_gloom + 1; + if (cur_gloom > next_gloom) + next_gloom_step = cur_gloom - 1; + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER_GLOOM, sint8) = next_gloom_step; + gfx_invalidate_screen(); + } + + } else { + sint8 newtemp = temperature + 1; + if (temperature > target_temperature) + newtemp = temperature - 1; + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TEMPERATURE, sint8) = newtemp; + RCT2_GLOBAL(0x009A9804, uint32) |= 8; // climate dirty flag? + } + } +} + + +/** + * Calculates future weather development. + * RCT2 implements this as discrete probability distributions dependant on month and climate + * for next_weather. The other weather parameters are then looked up depending only on the + * next weather. + * + * rct2: 0x006C461C + */ +static void climate_determine_future_weather() +{ + sint8 climate = RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, sint8); + const rct_weather_transition* climate_table = climate_transitions[climate]; + sint8 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7; + rct_weather_transition transition = climate_table[month]; + + // Generate a random variable with values 0 upto distribution_size-1 and chose weather from the distribution table accordingly + sint8 next_weather = transition.distribution[ ((rand() & 0xFF) * transition.distribution_size) >> 8 ]; + gClimateNextWeather = next_weather; + + _climateNextTemperature = transition.base_temperature + climate_weather_data[next_weather].temp_delta; + _climateNextWeatherEffect = climate_weather_data[next_weather].effect_level; + _climateNextWeatherGloom = climate_weather_data[next_weather].gloom_level; + _climateNextRainLevel = climate_weather_data[next_weather].rain_level; + + RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16) = 1920; +} + + + +#pragma region Climate / Weather data tables + +// 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] = { + { .temp_delta = 10, .effect_level = 0, .gloom_level = 0, .rain_level = 0, .sprite_id = 0x5A96 }, // Sunny + { .temp_delta = 5, .effect_level = 0, .gloom_level = 0, .rain_level = 0, .sprite_id = 0x5A97 }, // Partially Cloudy + { .temp_delta = 0, .effect_level = 0, .gloom_level = 0, .rain_level = 0, .sprite_id = 0x5A98 }, // Cloudy + { .temp_delta = -2, .effect_level = 1, .gloom_level = 1, .rain_level = 1, .sprite_id = 0x5A99 }, // Rain + { .temp_delta = -4, .effect_level = 1, .gloom_level = 2, .rain_level = 2, .sprite_id = 0x5A9A }, // Heavy Rain + { .temp_delta = 2, .effect_level = 2, .gloom_level = 2, .rain_level = 2, .sprite_id = 0x5A9B }, // Thunderstorm +}; + + +// rct2: 00993998 +static const rct_weather_transition climate_cool_and_wet_transitions[] = { + { .base_temperature = 8, .distribution_size = 18, + .distribution = { 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 0, 0, 0, 0, 0 } }, + { .base_temperature = 10, .distribution_size = 21, + .distribution = { 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 0, 0 } }, + { .base_temperature = 14, .distribution_size = 17, + .distribution = { 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 17, .distribution_size = 17, + .distribution = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 19, .distribution_size = 23, + .distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 4 } }, + { .base_temperature = 20, .distribution_size = 23, + .distribution = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 } }, + { .base_temperature = 16, .distribution_size = 19, + .distribution = { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 0, 0, 0, 0 } }, + { .base_temperature = 13, .distribution_size = 16, + .distribution = { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0 } } +}; +static const rct_weather_transition climate_warm_transitions[] = { + { .base_temperature = 12, .distribution_size = 21, + .distribution = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 4, 0, 0 } }, + { .base_temperature = 13, .distribution_size = 22, + .distribution = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 5, 0 } }, + { .base_temperature = 16, .distribution_size = 17, + .distribution = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 19, .distribution_size = 18, + .distribution = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0 } }, + { .base_temperature = 21, .distribution_size = 22, + .distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 0 } }, + { .base_temperature = 22, .distribution_size = 17, + .distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 5, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 19, .distribution_size = 17, + .distribution = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 16, .distribution_size = 17, + .distribution = { 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 0, 0, 0, 0, 0, 0 } } +}; +static const rct_weather_transition climate_hot_and_dry_transitions[] = { + { .base_temperature = 12, .distribution_size = 15, + .distribution = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 14, .distribution_size = 12, + .distribution = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 16, .distribution_size = 11, + .distribution = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 19, .distribution_size = 9, + .distribution = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 21, .distribution_size = 13, + .distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 22, .distribution_size = 11, + .distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 21, .distribution_size = 12, + .distribution = { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 16, .distribution_size = 13, + .distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } +}; +static const rct_weather_transition climate_cold_transitions[] = { + { .base_temperature = 4, .distribution_size = 18, + .distribution = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 4, 0, 0, 0, 0, 0 } }, + { .base_temperature = 5, .distribution_size = 21, + .distribution = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0, 0 } }, + { .base_temperature = 7, .distribution_size = 17, + .distribution = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 9, .distribution_size = 17, + .distribution = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0 } }, + { .base_temperature = 10, .distribution_size = 23, + .distribution = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 4 } }, + { .base_temperature = 11, .distribution_size = 23, + .distribution = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 5 } }, + { .base_temperature = 9, .distribution_size = 19, + .distribution = { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0, 0, 0, 0 } }, + { .base_temperature = 6, .distribution_size = 16, + .distribution = { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0 } } +}; + +static const rct_weather_transition* climate_transitions[] = { + climate_cool_and_wet_transitions, + climate_warm_transitions, + climate_hot_and_dry_transitions, + climate_cold_transitions +}; + +#pragma endregion \ No newline at end of file diff --git a/src/climate.h b/src/climate.h index 7325bfd8b1..2c035b86f7 100644 --- a/src/climate.h +++ b/src/climate.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Ted John + * Copyright (c) 2014 Ted John, Matthias Lanzinger * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -21,6 +21,8 @@ #ifndef _CLIMATE_H_ #define _CLIMATE_H_ +#include "rct2.h" + enum { CLIMATE_COOL_AND_WET, CLIMATE_WARM, @@ -28,7 +30,19 @@ enum { CLIMATE_COLD }; +typedef struct { + sint8 temp_delta; + sint8 effect_level; + sint8 gloom_level; + sint8 rain_level; + uint32 sprite_id; +} rct_weather; + +extern int gClimateNextWeather; +extern const rct_weather climate_weather_data[6]; + int climate_celcius_to_fahrenheit(int celcius); void climate_reset(int climate); +void climate_update(); #endif diff --git a/src/game.c b/src/game.c index 5e57312080..d5f909d3b1 100644 --- a/src/game.c +++ b/src/game.c @@ -20,6 +20,7 @@ #include "addresses.h" #include "audio.h" +#include "climate.h" #include "config.h" #include "rct2.h" #include "game.h" @@ -128,7 +129,7 @@ void game_logic_update() { short stringId, _dx; - RCT2_GLOBAL(0x013628F4, sint32)++; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, sint32)++; RCT2_GLOBAL(0x00F663AC, sint32)++; RCT2_GLOBAL(0x009DEA66, sint16)++; if (RCT2_GLOBAL(0x009DEA66, sint16) == 0) @@ -136,7 +137,7 @@ void game_logic_update() RCT2_CALLPROC_EBPSAFE(0x0068B089); RCT2_CALLPROC_EBPSAFE(0x006C44B1); // update_objective - RCT2_CALLPROC_EBPSAFE(0x006C46B1); // update_climate + climate_update(); RCT2_CALLPROC_EBPSAFE(0x006646E1); RCT2_CALLPROC_EBPSAFE(0x006A876D); peep_update_all(); @@ -321,8 +322,8 @@ static void game_handle_input_mouse(int x, int y, int state) RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_VIEWPORT_DRAG; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; - RCT2_GLOBAL(0x009DE530, rct_windowclass) = w->classification; - RCT2_GLOBAL(0x009DE52E, rct_windownumber) = w->number; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = w->classification; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = w->number; RCT2_GLOBAL(0x009DE540, sint16) = 0; // hide cursor // RCT2_CALLPROC_X(0x00407045, 0, 0, 0, 0, 0, 0, 0); @@ -384,7 +385,7 @@ static void game_handle_input_mouse(int x, int y, int state) dx = x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16); dy = y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16); - w = window_find_by_id(RCT2_GLOBAL(0x009DE530, rct_windowclass), RCT2_GLOBAL(0x009DE52E, rct_windownumber)); + w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber)); if (state == 0) { rct_viewport *viewport = w->viewport; RCT2_GLOBAL(0x009DE540, sint16) += RCT2_GLOBAL(0x009DE588, sint16); @@ -908,7 +909,7 @@ void game_handle_keyboard_input() // Handle mouse scrolling if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) - if (RCT2_GLOBAL(0x009AACBA, uint8) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, uint8) != 0) if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 1) if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 3)) game_handle_edge_scroll(); diff --git a/src/gfx.c b/src/gfx.c index 9cebbf2674..1a313818c3 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -243,7 +243,7 @@ void gfx_set_dirty_blocks(int left, int top, int right, int bottom) for (y = top; y <= bottom; y++) for (x = left; x <= right; x++) - screenDirtyBlocks[y * RCT2_GLOBAL(0x009ABDE8, sint32) + x] = 0xFF; + screenDirtyBlocks[y * RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32) + x] = 0xFF; } /** diff --git a/src/osinterface.c b/src/osinterface.c index f2d0ff306a..2b2484f70c 100644 --- a/src/osinterface.c +++ b/src/osinterface.c @@ -72,8 +72,8 @@ static void osinterface_create_window() RCT2_CALLPROC_EBPSAFE(0x0068352C); RCT2_CALLPROC_EBPSAFE(0x0068371D); - width = RCT2_GLOBAL(0x009AB4C2, sint16); - height = RCT2_GLOBAL(0x009AB4C4, sint16); + width = RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_RESOLUTION_WIDTH, sint16); + height = RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_RESOLUTION_HEIGHT, sint16); width = 640; height = 480; @@ -140,10 +140,10 @@ static void osinterface_resize(int width, int height) RCT2_GLOBAL(0x009ABDF0, uint8) = 6; RCT2_GLOBAL(0x009ABDF1, uint8) = 3; RCT2_GLOBAL(0x009ABDF2, uint8) = 1; - RCT2_GLOBAL(0x009ABDE4, sint16) = 64; - RCT2_GLOBAL(0x009ABDE6, sint16) = 8; - RCT2_GLOBAL(0x009ABDE8, sint32) = (width >> 6) + 1; - RCT2_GLOBAL(0x009ABDEC, sint32) = (height >> 3) + 1; + RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_WIDTH, sint16) = 64; + RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_HEIGHT, sint16) = 8; + RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32) = (width >> 6) + 1; + RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_ROWS, sint32) = (height >> 3) + 1; RCT2_CALLPROC_EBPSAFE(0x0066B905); // resize_gui() gfx_invalidate_screen(); diff --git a/src/peep.c b/src/peep.c index e50fb7c80a..0a16060ca2 100644 --- a/src/peep.c +++ b/src/peep.c @@ -60,7 +60,7 @@ void peep_update_all() peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_index].peep); sprite_index = peep->next; - if ((i & 0x7F) != (RCT2_GLOBAL(0x013628F4, uint32) & 0x7F)) { + if ((i & 0x7F) != (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 0x7F)) { RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, peep, 0, 0); } else { RCT2_CALLPROC_X(0x0068F41A, 0, 0, 0, i, peep, 0, 0); diff --git a/src/rct2.c b/src/rct2.c index 64fd70c1a9..df687dca0c 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -103,8 +103,8 @@ void rct2_init() RCT2_GLOBAL(0x00F663AC, int) = 0; RCT2_GLOBAL(0x009AC310, char*) = RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, char*); get_system_time(); - RCT2_GLOBAL(0x009DEA69, short) = RCT2_GLOBAL(0x01424304, short); - RCT2_GLOBAL(0x009DEA6B, short) = RCT2_GLOBAL(0x01424304, short); + RCT2_GLOBAL(0x009DEA69, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, short); + RCT2_GLOBAL(0x009DEA6B, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, short); rct2_init_directories(); rct2_startup_checks(); config_reset_shortcut_keys(); diff --git a/src/scenario.c b/src/scenario.c index 61b9108483..6eee3c4849 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -424,7 +424,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) uint8 _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - mainWindow->viewport->zoom; mainWindow->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF; - *((char*)(&RCT2_GLOBAL(0x0141E9E0, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8; + *((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8; if (_cl != 0) { if (_cl < 0) { _cl = -_cl; @@ -451,7 +451,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) RCT2_CALLPROC_EBPSAFE(0x00684AC3); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); - if (RCT2_ADDRESS(0x013580F8, uint8) != OBJECTIVE_NONE) + if (RCT2_ADDRESS(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) != OBJECTIVE_NONE) window_park_objective_open(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16) = calculate_park_rating(); diff --git a/src/title.c b/src/title.c index 6eb9fd77c7..5b447bca8a 100644 --- a/src/title.c +++ b/src/title.c @@ -172,7 +172,7 @@ static void title_update_showcase() { char _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - w->viewport->zoom; w->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF; - *((char*)(&RCT2_GLOBAL(0x0141E9E0, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8; + *((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8; if (_cl != 0) { if (_cl < 0) { _cl = -_cl; diff --git a/src/window_clear_scenery.c b/src/window_clear_scenery.c index 567a9358f8..061de23294 100644 --- a/src/window_clear_scenery.c +++ b/src/window_clear_scenery.c @@ -226,9 +226,9 @@ static int window_clear_scenery_should_close() { if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3))) return 1; - if (RCT2_GLOBAL(0x009DE544, rct_windowclass) != WC_TOP_TOOLBAR) + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) != WC_TOP_TOOLBAR) return 1; - if (RCT2_GLOBAL(0x009DE546, uint16) != 16) + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) != 16) return 1; return 0; } diff --git a/src/window_dropdown.c b/src/window_dropdown.c index 0aecd65450..9050dd6c64 100644 --- a/src/window_dropdown.c +++ b/src/window_dropdown.c @@ -108,7 +108,7 @@ void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 fla max_string_width = 0; for (i = 0; i < num_items; i++) { format_string(buffer, gDropdownItemsFormat[i], (void*)(&gDropdownItemsArgs[i])); - RCT2_GLOBAL(0x013CE950, sint16) = 224; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, sint16) = 224; string_width = gfx_get_string_width(buffer); max_string_width = max(string_width, max_string_width); } diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 9723e30a65..c161165956 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -390,7 +390,7 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, r dpi, (*((int*)0x013CE952) < 0 ? 1391 : 1390), x, y - 3, - (RCT2_GLOBAL(0x009DE55C, rct_windowclass) == 2 && RCT2_GLOBAL(0x009DE560, sint32) == WIDX_MONEY ? 2 : w->colours[0] & 0x7F), + (RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) == 2 && RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, sint32) == WIDX_MONEY ? 2 : w->colours[0] & 0x7F), (void*)0x013CE952 ); y += 7; @@ -401,7 +401,7 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, r dpi, STR_NUM_GUESTS + RCT2_GLOBAL(0x013573FE, uint8), x, y, - (RCT2_GLOBAL(0x009DE55C, rct_windowclass) == 2 && RCT2_GLOBAL(0x009DE560, sint32) == WIDX_GUESTS ? 2 : w->colours[0] & 0x7F), + (RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) == 2 && RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, sint32) == WIDX_GUESTS ? 2 : w->colours[0] & 0x7F), (void*)0x01357844 ); @@ -426,7 +426,7 @@ static void window_game_bottom_toolbar_draw_park_rating(rct_drawpixelinfo *dpi, bar_width = (factor * 90) / 256; gfx_fill_rect_inset(dpi, x, y + 1, x + 93, y + 9, w->colours[1], 48); - if (!(colour & 0x80000000) || RCT2_GLOBAL(0x009DEA6E, uint8) != 0 || (RCT2_GLOBAL(0x013628F4, uint8) & 8)) { + if (!(colour & 0x80000000) || RCT2_GLOBAL(0x009DEA6E, uint8) != 0 || (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint8) & 8)) { if (bar_width > 2) gfx_fill_rect_inset(dpi, x + 2, y + 2, x + bar_width - 1, y + 8, colour & 0x7FFFFFFF, 0); } @@ -461,7 +461,7 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, 1845, x, y, - (RCT2_GLOBAL(0x009DE55C, rct_windowclass) == 2 && RCT2_GLOBAL(0x009DE560, sint32) == WIDX_DATE ? 2 : w->colours[0] & 0x7F), + (RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) == 2 && RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, sint32) == WIDX_DATE ? 2 : w->colours[0] & 0x7F), (void*)0x013CE952 ); @@ -480,13 +480,13 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, x += 30; // Current weather - gfx_draw_sprite(dpi, ((int*)0x00993C98)[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) * 2], x, y); + gfx_draw_sprite(dpi, climate_weather_data[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8)].sprite_id, x, y); // Next weather - if (((int*)0x00993C98)[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) * 2] != ((int*)0x00993C98)[RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER, sint8) * 2]) { - if (RCT2_GLOBAL(0x013CA748, sint16) < 960) { + if (climate_weather_data[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8)].sprite_id != climate_weather_data[gClimateNextWeather].sprite_id) { + if (RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE_UPDATE_TIMER, sint16) < 960) { gfx_draw_sprite(dpi, SPR_NEXT_WEATHER, x + 27, y + 5); - gfx_draw_sprite(dpi, ((int*)0x00993C98)[RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER, sint8) * 2], x + 40, y); + gfx_draw_sprite(dpi, climate_weather_data[gClimateNextWeather].sprite_id, x + 40, y); } } } diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index a0527fba7c..020afbb811 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -174,7 +174,7 @@ static void window_game_top_toolbar_mouseup() break; case WIDX_CLEAR_SCENERY: - if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(0x009DE544, uint8) == 1 && RCT2_GLOBAL(0x009DE546, uint16) == 16) { + if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 16) { RCT2_CALLPROC_EBPSAFE(0x006EE281); } else { show_gridlines(); @@ -185,7 +185,7 @@ static void window_game_top_toolbar_mouseup() } break; case WIDX_LAND: - if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(0x009DE544, uint8) == 1 && RCT2_GLOBAL(0x009DE546, uint16) == 7) { + if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 7) { RCT2_CALLPROC_EBPSAFE(0x006EE281); } else { show_gridlines(); @@ -196,7 +196,7 @@ static void window_game_top_toolbar_mouseup() } break; case WIDX_WATER: - if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(0x009DE544, uint8) == 1 && RCT2_GLOBAL(0x009DE546, uint16) == 8) { + if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 8) { RCT2_CALLPROC_EBPSAFE(0x006EE281); } else { show_gridlines(); @@ -378,7 +378,7 @@ static void window_game_top_toolbar_dropdown() RCT2_CALLPROC_EBPSAFE(0x006BAC5B); break; case 5: // screenshot - RCT2_GLOBAL(0x009DEA6D, sint8) = 10; + RCT2_GLOBAL(RCT2_ADDRESS_SCREENSHOT_COUNTDOWN, sint8) = 10; break; case 7: // quit game RCT2_CALLPROC_X(0x006677F2, 0, 1, 0, 0, 5, 1, 0); diff --git a/src/window_land.c b/src/window_land.c index 46db92465c..0c196b46f1 100644 --- a/src/window_land.c +++ b/src/window_land.c @@ -137,8 +137,8 @@ void window_land_open() RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) = 255; _selectedFloorTexture = 0; _selectedWallTexture = 0; - RCT2_GLOBAL(0x009E2E1C, sint32) = 0x80000000; - RCT2_GLOBAL(0x009E2E20, sint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, sint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, sint32) = 0x80000000; window->colours[0] = 24; window->colours[1] = 24; window->colours[2] = 24; @@ -405,9 +405,9 @@ static int window_land_should_close() { if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3))) return 1; - if (RCT2_GLOBAL(0x009DE544, rct_windowclass) != WC_TOP_TOOLBAR) + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) != WC_TOP_TOOLBAR) return 1; - if (RCT2_GLOBAL(0x009DE546, sint16) != 7) + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, sint16) != 7) return 1; return 0; } diff --git a/src/window_main.c b/src/window_main.c index ba79333998..2c95d7cbc8 100644 --- a/src/window_main.c +++ b/src/window_main.c @@ -63,7 +63,7 @@ void window_main_open() or word ptr [edi+12h], 400h } - RCT2_GLOBAL(0x0141E9E0, sint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32) = 0; RCT2_GLOBAL(0x009E32B0, uint8) = 0; RCT2_GLOBAL(0x009E32B2, uint8) = 0; RCT2_GLOBAL(0x009E32B3, uint8) = 0; diff --git a/src/window_park.c b/src/window_park.c index 8480be7627..84550d2026 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -644,7 +644,7 @@ static void window_park_entrance_close() __asm mov w, esi if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) - if (w->classification == RCT2_GLOBAL(0x009DE544, rct_windowclass) && w->number == RCT2_GLOBAL(0x009DE542, rct_windownumber)) + if (w->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && w->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) RCT2_CALLPROC_EBPSAFE(0x006EE281); } @@ -1617,7 +1617,7 @@ void window_park_objective_open() } if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) - if (window->classification == RCT2_GLOBAL(0x009DE544, rct_windowclass) && window->number == RCT2_GLOBAL(0x009DE542, rct_windownumber)) + if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)) RCT2_CALLPROC_EBPSAFE(0x006EE281); window->viewport = NULL; diff --git a/src/window_water.c b/src/window_water.c index fa0a0c12c2..6b7eab58a5 100644 --- a/src/window_water.c +++ b/src/window_water.c @@ -232,9 +232,9 @@ static int window_water_should_close() { if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3))) return 1; - if (RCT2_GLOBAL(0x009DE544, rct_windowclass) != WC_TOP_TOOLBAR) + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) != WC_TOP_TOOLBAR) return 1; - if (RCT2_GLOBAL(0x009DE546, uint16) != 8) + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) != 8) return 1; return 0; }