From bb81bfd5d08c17e154ca1124a3f3f67ffb18043a Mon Sep 17 00:00:00 2001 From: Marco Costa Date: Sun, 24 Aug 2014 21:27:20 -0400 Subject: [PATCH] Created named address RCT2_ADDRESS_SCENARIO_TICKS * 0x00F663AC is now named RCT2_ADDRESS_SCENARIO_TICKS. This variable starts at an arbitrary value, defined by the current scenario, and increments by 1 on every game tick. * Also, added meaningful name to some variables in draw_light_rain and draw_heavy_rain. --- src/addresses.h | 1 + src/game.c | 74 ++++++++++++++++++++--------------------- src/gfx.c | 2 +- src/park.c | 2 +- src/rct2.c | 2 +- src/scenario.c | 5 ++- src/window_guest_list.c | 2 +- 7 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index bc1493a850..8b28dad719 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -196,6 +196,7 @@ #define RCT2_ADDRESS_CURRENT_MONTH_YEAR 0x00F663A8 #define RCT2_ADDRESS_CURRENT_MONTH_TICKS 0x00F663AA +#define RCT2_ADDRESS_SCENARIO_TICKS 0x00F663AC #define RCT2_ADDRESS_SCENARIO_SRAND_0 0x00F663B0 #define RCT2_ADDRESS_SCENARIO_SRAND_1 0x00F663B4 diff --git a/src/game.c b/src/game.c index 2ea9e63a97..1bafb3d29e 100644 --- a/src/game.c +++ b/src/game.c @@ -55,22 +55,22 @@ typedef void(*draw_rain_func)(int left, int top, int width, int height); * rct2: 0x00684114 */ void draw_light_rain(int left, int top, int width, int height){ - int edi = -RCT2_GLOBAL(0x00F663AC, int) + 8; - int esi = (RCT2_GLOBAL(0x00F663AC, int) * 3) + 7; - esi = -esi; + int x_start = -RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) + 8; + int y_start = (RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) * 3) + 7; + y_start = -y_start; - edi += left; - esi += top; + x_start += left; + y_start += top; - gfx_draw_rain(left, top, width, height, edi, esi); + gfx_draw_rain(left, top, width, height, x_start, y_start); - edi = -RCT2_GLOBAL(0x00F663AC, int) + 0x18; - esi = (RCT2_GLOBAL(0x00F663AC, int) * 4) + 0x0D; - esi = -esi; + x_start = -RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) + 0x18; + y_start = (RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) * 4) + 0x0D; + y_start = -y_start; - edi += left; - esi += top; - gfx_draw_rain(left, top, width, height, edi, esi); + x_start += left; + y_start += top; + gfx_draw_rain(left, top, width, height, x_start, y_start); } /** @@ -78,41 +78,41 @@ void draw_light_rain(int left, int top, int width, int height){ * rct2: 0x0068416D */ void draw_heavy_rain(int left, int top, int width, int height){ - int edi = -RCT2_GLOBAL(0x00F663AC, int); - int esi = RCT2_GLOBAL(0x00F663AC, int) * 5; - esi = -esi; + int x_start = -RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int); + int y_start = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) * 5; + y_start = -y_start; - edi += left; - esi += top; + x_start += left; + y_start += top; - gfx_draw_rain(left, top, width, height, edi, esi); + gfx_draw_rain(left, top, width, height, x_start, y_start); - edi = -RCT2_GLOBAL(0x00F663AC, int) + 0x10; - esi = (RCT2_GLOBAL(0x00F663AC, int) * 6) + 5; - esi = -esi; + x_start = -RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) + 0x10; + y_start = (RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) * 6) + 5; + y_start = -y_start; - edi += left; - esi += top; + x_start += left; + y_start += top; - gfx_draw_rain(left, top, width, height, edi, esi); + gfx_draw_rain(left, top, width, height, x_start, y_start); - edi = -RCT2_GLOBAL(0x00F663AC, int) + 8; - esi = (RCT2_GLOBAL(0x00F663AC, int) * 3) + 7; - esi = -esi; + x_start = -RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) + 8; + y_start = (RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) * 3) + 7; + y_start = -y_start; - edi += left; - esi += top; + x_start += left; + y_start += top; - gfx_draw_rain(left, top, width, height, edi, esi); + gfx_draw_rain(left, top, width, height, x_start, y_start); - edi = -RCT2_GLOBAL(0x00F663AC, int) + 0x18; - esi = (RCT2_GLOBAL(0x00F663AC, int) * 4) + 0x0D; - esi = -esi; + x_start = -RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) + 0x18; + y_start = (RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) * 4) + 0x0D; + y_start = -y_start; - edi += left; - esi += top; + x_start += left; + y_start += top; - gfx_draw_rain(left, top, width, height, edi, esi); + gfx_draw_rain(left, top, width, height, x_start, y_start); } /** @@ -363,7 +363,7 @@ void game_logic_update() short stringId, _dx; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, sint32)++; - RCT2_GLOBAL(0x00F663AC, sint32)++; + RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, sint32)++; RCT2_GLOBAL(0x009DEA66, sint16)++; if (RCT2_GLOBAL(0x009DEA66, sint16) == 0) RCT2_GLOBAL(0x009DEA66, sint16)--; diff --git a/src/gfx.c b/src/gfx.c index d31cda585a..6e771560a4 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -2317,7 +2317,7 @@ rct_drawpixelinfo* clip_drawpixelinfo(rct_drawpixelinfo* dpi, int left, int widt * x_start: edi * y_start: esi */ -void gfx_draw_rain(int left, int top, int width, int height, uint32 x_start, uint32 y_start){ +void gfx_draw_rain(int left, int top, int width, int height, sint32 x_start, sint32 y_start){ uint8* pattern = RCT2_GLOBAL(RCT2_ADDRESS_RAIN_PATTERN, uint8*); uint8 pattern_x_space = *pattern++; uint8 pattern_y_space = *pattern++; diff --git a/src/park.c b/src/park.c index 59a4d9c431..1779458712 100644 --- a/src/park.c +++ b/src/park.c @@ -265,7 +265,7 @@ int calculate_park_rating() litter = &(g_sprite_list[sprite_idx].litter); // Guessing this eliminates recently dropped litter - if (litter->var_24 - RCT2_GLOBAL(0x00F663AC, uint32) >= 7680) + if (litter->var_24 - RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32) >= 7680) num_litter++; } result -= 600 - (4 * (150 - min(150, num_litter))); diff --git a/src/rct2.c b/src/rct2.c index f23ba2552e..b413820fd9 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -146,7 +146,7 @@ void rct2_quit() { void rct2_init() { - RCT2_GLOBAL(0x00F663AC, int) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, int) = 0; RCT2_GLOBAL(0x009AC310, char*) = RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, char*); get_system_time(); RCT2_GLOBAL(0x009DEA69, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, short); diff --git a/src/scenario.c b/src/scenario.c index c566324890..a2884a39d0 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -116,7 +116,10 @@ void scenario_load(const char *path) object_read_and_load_entries(file); - // Read flags (16 bytes) + // Read flags (16 bytes). Loads: + // RCT2_ADDRESS_CURRENT_MONTH_YEAR + // RCT2_ADDRESS_CURRENT_MONTH_TICKS + // RCT2_ADDRESS_SCENARIO_TICKS sawyercoding_read_chunk(file, (uint8*)RCT2_ADDRESS_CURRENT_MONTH_YEAR); // Read map elements diff --git a/src/window_guest_list.c b/src/window_guest_list.c index bb61a45100..a5953114be 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -804,7 +804,7 @@ static void window_guest_list_find_groups() int spriteIndex, spriteIndex2, groupIndex, faceIndex; rct_peep *peep, *peep2; - int eax = RCT2_GLOBAL(0x00F663AC, uint32) & 0xFFFFFF00; + int eax = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32) & 0xFFFFFF00; if (_window_guest_list_selected_view == RCT2_GLOBAL(0x00F1EE02, uint32)) if (RCT2_GLOBAL(0x00F1AF20, uint16) != 0 || eax == RCT2_GLOBAL(0x00F1AF1C, uint32)) return;