From ca1a1e0ddd31e212e834ae558e294e475092d0cb Mon Sep 17 00:00:00 2001 From: medsouz Date: Sun, 16 Aug 2015 13:05:49 -0400 Subject: [PATCH] Document various memory addresses --- src/addresses.h | 9 +++++++++ src/editor.c | 12 ++++++------ src/game.c | 23 ++++++++++++----------- src/scenario.c | 4 ++-- src/title.c | 18 +++++++++--------- src/windows/map.c | 2 +- src/windows/save_prompt.c | 4 ++-- 7 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 7254456cc2..1cc739446e 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -75,6 +75,10 @@ // When all sounds reversed replace with gConfigSound.ride_music #define RCT2_ADDRESS_CONFIG_MUSIC 0x009AAC72 +// Is supposed to be set to 0 whenever the screen resolution is changed +// it will then count up 255 ticks before saving the config +// In OpenRCT2 this value is only set to 0 on startup +#define RCT2_ADDRESS_CONFIG_SAVE_TIMER 0x009AAC73 #define RCT2_ADDRESS_CONFIG_FLAGS 0x009AAC74 // MAX vehicle sounds not used anymore @@ -228,6 +232,8 @@ #define RCT2_ADDRESS_MAP_ARROW_Z 0x009DEA4C #define RCT2_ADDRESS_MAP_ARROW_DIRECTION 0x009DEA4E +//Counts how many ticks the current screen has been open for +#define RCT2_ADDRESS_SCREEN_AGE 0x009DEA66 #define RCT2_ADDRESS_SCREEN_FLAGS 0x009DEA68 #define RCT2_ADDRESS_SCREENSHOT_COUNTDOWN 0x009DEA6D // Note: not only the zeroth bit can be set to control pause @@ -456,6 +462,9 @@ #define RCT2_ADDRESS_RIDE_LIST 0x013628F8 #define RCT2_ADDRESS_RIDE_COUNT 0x013587C8 #define RCT2_ADDRESS_RIDE_FLAGS 0x0097CF40 + +//How many ticks the scenario has existed for +#define RCT2_ADDRESS_SAVED_AGE 0x01388698 #define RCT2_ADDRESS_SAVED_VIEW_X 0x0138869A #define RCT2_ADDRESS_SAVED_VIEW_Y 0x0138869C #define RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION 0x0138869E diff --git a/src/editor.c b/src/editor.c index 193f393900..d13386693c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -88,7 +88,7 @@ void editor_load() mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; load_palette(); gfx_invalidate_screen(); - RCT2_GLOBAL(0x009DEA66, sint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, sint16) = 0; strcpy((char*)RCT2_ADDRESS_SCENARIO_NAME, language_get_string(2749)); } @@ -166,7 +166,7 @@ void editor_convert_save_to_scenario() news_item_init_queue(); window_editor_main_open(); editor_finalise_main_view(); - RCT2_GLOBAL(0x009DEA66, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) = 0; } /** @@ -203,7 +203,7 @@ void trackdesigner_load() mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; load_palette(); gfx_invalidate_screen(); - RCT2_GLOBAL(0x009DEA66, sint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, sint16) = 0; } /** @@ -240,7 +240,7 @@ void trackmanager_load() mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; load_palette(); gfx_invalidate_screen(); - RCT2_GLOBAL(0x009DEA66, sint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, sint16) = 0; } /** @@ -295,7 +295,7 @@ static int editor_load_landscape_from_sv4(const char *path) rct1_fix_landscape(); editor_finalise_main_view(); - RCT2_GLOBAL(0x009DEA66, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) = 0; return 1; } @@ -313,7 +313,7 @@ static int editor_load_landscape_from_sc4(const char *path) rct1_fix_landscape(); editor_finalise_main_view(); - RCT2_GLOBAL(0x009DEA66, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) = 0; return 1; } diff --git a/src/game.c b/src/game.c index af06998e03..4af68c767c 100644 --- a/src/game.c +++ b/src/game.c @@ -330,9 +330,9 @@ void game_update() RCT2_GLOBAL(0x0141F568, uint8) = RCT2_GLOBAL(0x0013CA740, uint8); game_handle_input(); - if (RCT2_GLOBAL(0x009AAC73, uint8) != 255) { - RCT2_GLOBAL(0x009AAC73, uint8)++; - if (RCT2_GLOBAL(0x009AAC73, uint8) == 255) + if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SAVE_TIMER, uint8) != 255) { + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SAVE_TIMER, uint8)++; + if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SAVE_TIMER, uint8) == 255) config_save_default(); } } @@ -341,9 +341,9 @@ void game_logic_update() { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32)++; RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32)++; - RCT2_GLOBAL(0x009DEA66, sint16)++; - if (RCT2_GLOBAL(0x009DEA66, sint16) == 0) - RCT2_GLOBAL(0x009DEA66, sint16)--; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, sint16)++; + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, sint16) == 0) + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, sint16)--; sub_68B089(); scenario_update(); @@ -364,7 +364,7 @@ void game_logic_update() climate_update_sound(); editor_open_windows_for_current_step(); - RCT2_GLOBAL(0x01388698, uint16)++; + RCT2_GLOBAL(RCT2_ADDRESS_SAVED_AGE, uint16)++; // Update windows //window_dispatch_update_all(); @@ -392,11 +392,12 @@ static int game_check_affordability(int cost) { if (cost <= 0)return cost; if (RCT2_GLOBAL(0x141F568, uint8) & 0xF0)return cost; - + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32)&(1 << 8))){ if (cost <= (sint32)(DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32))))return cost; } - RCT2_GLOBAL(0x13CE952, uint32) = cost; + RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint32) = cost; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 827; return MONEY32_UNDEFINED; } @@ -648,7 +649,7 @@ static void load_landscape() gfx_invalidate_screen(); rct2_endupdate(); } else { - RCT2_GLOBAL(0x009DEA66, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) = 0; rct2_endupdate(); } } @@ -959,7 +960,7 @@ static void load_game() gfx_invalidate_screen(); rct2_endupdate(); } else { - RCT2_GLOBAL(0x009DEA66, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) = 0; rct2_endupdate(); } } diff --git a/src/scenario.c b/src/scenario.c index 52c072b186..f8f772bf9c 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -339,7 +339,7 @@ void scenario_begin() load_palette(); gfx_invalidate_screen(); - RCT2_GLOBAL(0x009DEA66, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) = 0; RCT2_GLOBAL(0x009DEA5C, uint16) = 62000; // (doesn't appear to ever be read) gGameSpeed = 1; } @@ -975,7 +975,7 @@ int scenario_save(SDL_RWops* rw, int flags) reset_loaded_objects(); gfx_invalidate_screen(); - RCT2_GLOBAL(0x009DEA66, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) = 0; return 1; } diff --git a/src/title.c b/src/title.c index e875ecfd19..7e2cc7be4a 100644 --- a/src/title.c +++ b/src/title.c @@ -130,7 +130,7 @@ void title_load() title_create_windows(); title_init_showcase(); gfx_invalidate_screen(); - RCT2_GLOBAL(0x009DEA66, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) = 0; if (gOpenRCT2ShowChangelog) { gOpenRCT2ShowChangelog = false; @@ -188,9 +188,9 @@ static int title_load_park(const char *path) w->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16); { - char _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - w->viewport->zoom; - w->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF; - *((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8; + char _cl = (RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, sint16) & 0xFF) - w->viewport->zoom; + w->viewport->zoom = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, sint16) & 0xFF; + *((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_ZOOM_AND_ROTATION, sint16) >> 8; if (_cl != 0) { if (_cl < 0) { _cl = -_cl; @@ -213,7 +213,7 @@ static int title_load_park(const char *path) scenery_set_default_placement_configuration(); news_item_init_queue(); gfx_invalidate_screen(); - RCT2_GLOBAL(0x009DEA66, sint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, sint16) = 0; RCT2_GLOBAL(0x009DEA5C, sint16) = 0x0D6D8; gGameSpeed = 1; return 1; @@ -486,14 +486,14 @@ void title_update() window_map_tooltip_update_visibility(); window_dispatch_update_all(); - RCT2_GLOBAL(0x01388698, uint16)++; + RCT2_GLOBAL(RCT2_ADDRESS_SAVED_AGE, uint16)++; // Input game_handle_input(); - if (RCT2_GLOBAL(0x009AAC73, uint8) != 255) { - RCT2_GLOBAL(0x009AAC73, uint8)++; - if (RCT2_GLOBAL(0x009AAC73, uint8) == 255) + if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SAVE_TIMER, uint8) != 255) { + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SAVE_TIMER, uint8)++; + if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SAVE_TIMER, uint8) == 255) config_save_default(); } } diff --git a/src/windows/map.c b/src/windows/map.c index eeaddaa0bf..165093cd99 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -1286,7 +1286,7 @@ static void window_map_place_park_entrance_tool_down(int x, int y) 0x8001, RCT2_GLOBAL(0x009DEA62, uint16), RCT2_GLOBAL(0x009DEA64, uint16), - RCT2_GLOBAL(0x009DEA66, uint16) + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) ); } diff --git a/src/windows/save_prompt.c b/src/windows/save_prompt.c index 3bd10840cc..8abd3a72e8 100644 --- a/src/windows/save_prompt.c +++ b/src/windows/save_prompt.c @@ -146,7 +146,7 @@ void window_save_prompt_open() } } - if (RCT2_GLOBAL(0x009DEA66, uint16) < 3840) { + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) < 3840) { game_load_or_quit_no_save_prompt(); return; } @@ -263,7 +263,7 @@ static void window_save_prompt_mouseup(rct_window *w, int widgetIndex) } } - if (RCT2_GLOBAL(0x009DEA66, uint16) < 3840) { + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_AGE, uint16) < 3840) { game_load_or_quit_no_save_prompt(); return; }