From b3ea71c080b72abbbbd5e39a181da697462d84c3 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Sun, 4 May 2014 12:56:35 +0200 Subject: [PATCH] Replace more addresses with their named constants Also named window.var_4B2/4 as saved_view_x/y --- src/addresses.h | 3 +++ src/game.c | 12 ++++++------ src/scenario.c | 8 ++++---- src/title.c | 8 ++++---- src/viewport.c | 2 +- src/window.h | 4 ++-- src/window_footpath.c | 6 +++--- src/window_park.c | 14 +++++++------- src/window_water.c | 8 ++++---- 9 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index d9c7a46036..c6a9bd19a6 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -202,6 +202,9 @@ #define RCT2_ADDRESS_SCENARIO_NAME 0x0141F5B8 +#define RCT2_ADDRESS_WATER_RAISE_COST 0x0141F738 +#define RCT2_ADDRESS_WATER_LOWER_COST 0x0141F73C + #define RCT2_ADDRESS_WINDOW_LIST 0x01420078 #define RCT2_ADDRESS_NEW_WINDOW_PTR 0x014234B8 #define RCT2_ADDRESS_VIEWPORT_LIST 0x014234BC diff --git a/src/game.c b/src/game.c index e8bafaeb33..38243ce888 100644 --- a/src/game.c +++ b/src/game.c @@ -399,8 +399,8 @@ static void game_handle_input_mouse(int x, int y, int state) RCT2_GLOBAL(0x009DE540, sint16) = 1000; dx <<= viewport->zoom + 1; dy <<= viewport->zoom + 1; - w->var_4B2 += dx; - w->var_4B4 += dy; + w->saved_view_x += dx; + w->saved_view_y += dy; } } } else if (state == 4) { @@ -795,11 +795,11 @@ void game_handle_edge_scroll() // Scroll viewport if (scrollX != 0) { - mainWindow->var_4B2 += scrollX * (12 << mainWindow->viewport->zoom); + mainWindow->saved_view_x += scrollX * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } if (scrollY != 0) { - mainWindow->var_4B4 += scrollY * (12 << mainWindow->viewport->zoom); + mainWindow->saved_view_y += scrollY * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } } @@ -836,11 +836,11 @@ void game_handle_key_scroll() // Scroll viewport if (scrollX != 0) { - mainWindow->var_4B2 += scrollX * (12 << mainWindow->viewport->zoom); + mainWindow->saved_view_x += scrollX * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } if (scrollY != 0) { - mainWindow->var_4B4 += scrollY * (12 << mainWindow->viewport->zoom); + mainWindow->saved_view_y += scrollY * (12 << mainWindow->viewport->zoom); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 7); } } diff --git a/src/scenario.c b/src/scenario.c index 800d364a0a..05871c5780 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -422,8 +422,8 @@ void scenario_load_and_play(rct_scenario_basic *scenario) mainWindow = window_get_main(); mainWindow->var_4B0 = -1; - mainWindow->var_4B2 = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16); - mainWindow->var_4B4 = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16); + mainWindow->saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16); + mainWindow->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16); uint8 _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - mainWindow->viewport->zoom; mainWindow->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF; @@ -438,8 +438,8 @@ void scenario_load_and_play(rct_scenario_basic *scenario) mainWindow->viewport->view_height <<= _cl; } } - mainWindow->var_4B2 -= mainWindow->viewport->view_width >> 1; - mainWindow->var_4B4 -= mainWindow->viewport->view_height >> 1; + mainWindow->saved_view_x -= mainWindow->viewport->view_width >> 1; + mainWindow->saved_view_y -= mainWindow->viewport->view_height >> 1; window_invalidate(mainWindow); RCT2_CALLPROC_EBPSAFE(0x0069E9A7); diff --git a/src/title.c b/src/title.c index 6a85e4e6c0..17cc541e60 100644 --- a/src/title.c +++ b/src/title.c @@ -167,8 +167,8 @@ static void title_update_showcase() w = window_get_main(); w->var_4B0 = -1; - w->var_4B2 = RCT2_GLOBAL(0x0138869A, sint16); - w->var_4B4 = RCT2_GLOBAL(0x0138869C, sint16); + w->saved_view_x = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_X, sint16); + w->saved_view_y = RCT2_GLOBAL(RCT2_ADDRESS_SAVED_VIEW_Y, sint16); { char _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - w->viewport->zoom; @@ -184,8 +184,8 @@ static void title_update_showcase() w->viewport->view_height <<= _cl; } } - w->var_4B2 -= w->viewport->view_width >> 1; - w->var_4B4 -= w->viewport->view_height >> 1; + w->saved_view_x -= w->viewport->view_width >> 1; + w->saved_view_y -= w->viewport->view_height >> 1; } window_invalidate(w); diff --git a/src/viewport.c b/src/viewport.c index 857072af39..a22af3cf24 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -63,7 +63,7 @@ void viewport_init_all() RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = -1; RCT2_GLOBAL(0x009DE550, sint32) = -1; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, sint16) = -1; - RCT2_GLOBAL(0x009DE58A, sint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, sint16) = 0; RCT2_GLOBAL(0x009DEA50, sint16) = -1; RCT2_CALLPROC_EBPSAFE(0x006EE3C3); format_string((char*)0x0141FA44, STR_CANCEL, NULL); diff --git a/src/window.h b/src/window.h index 9fab72b82c..a1a1305167 100644 --- a/src/window.h +++ b/src/window.h @@ -136,8 +136,8 @@ typedef struct rct_window { sint16 var_4AC; sint16 var_4AE; sint16 var_4B0; // viewport target sprite? - sint16 var_4B2; // viewport target x? - sint16 var_4B4; // viewport target y? + sint16 saved_view_x; // 0x4B2 + sint16 saved_view_y; // 0x4B4 rct_windowclass classification; // 0x4B6 uint8 pad_4B7; sint8 var_4B8; diff --git a/src/window_footpath.c b/src/window_footpath.c index de147ada3d..d88cf014a3 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -223,7 +223,7 @@ static void window_footpath_close() RCT2_CALLPROC_EBPSAFE(0x006A7831); RCT2_CALLPROC_X(0x006CB70A, 0, 0, 0, 0, 0, 0, 0); RCT2_CALLPROC_EBPSAFE(0x0068AB1B); - RCT2_GLOBAL(0x009DE58A, uint16) &= ~2; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; window_invalidate_by_id(WC_TOP_TOOLBAR, 0); hide_gridlines(); } @@ -258,7 +258,7 @@ static void window_footpath_mouseup() tool_cancel(); RCT2_CALLPROC_EBPSAFE(0x006A7831); RCT2_CALLPROC_EBPSAFE(0x0068AB1B); - RCT2_GLOBAL(0x009DE58A, uint16) &= ~2; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; RCT2_GLOBAL(0x00F3EF99, uint8) = PATH_CONSTRUCTION_MODE_LAND; tool_set(w, WIDX_CONSTRUCT_ON_LAND, 17); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); @@ -273,7 +273,7 @@ static void window_footpath_mouseup() RCT2_CALLPROC_EBPSAFE(0x006EE281); RCT2_CALLPROC_EBPSAFE(0x006A7831); RCT2_CALLPROC_EBPSAFE(0x0068AB1B); - RCT2_GLOBAL(0x009DE58A, uint16) &= ~2; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; RCT2_GLOBAL(0x00F3EF99, uint8) = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL; tool_set(w, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, 12); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); diff --git a/src/window_park.c b/src/window_park.c index 8d2c3078f7..4700b6f479 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -800,15 +800,15 @@ static void window_park_entrance_toolupdate() if (widgetIndex == WIDX_BUY_LAND_RIGHTS) { RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, w, 0, 0); - RCT2_GLOBAL(0x009DE58A, uint16) &= 0xFFFE; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; screen_pos_to_map_pos(&x, &y); if (x != SPRITE_LOCATION_NULL) { - RCT2_GLOBAL(0x009DE58A, uint16) |= 1; - RCT2_GLOBAL(0x009DE594, uint16) = 4; - RCT2_GLOBAL(0x009DE58C, uint16) = x; - RCT2_GLOBAL(0x009DE58E, uint16) = x; - RCT2_GLOBAL(0x009DE590, uint16) = y; - RCT2_GLOBAL(0x009DE592, uint16) = y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 1; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = y; RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, w, 0, 0); } } diff --git a/src/window_water.c b/src/window_water.c index 56be72a634..1e91cbf5b5 100644 --- a/src/window_water.c +++ b/src/window_water.c @@ -102,8 +102,8 @@ void window_water_open() window_init_scroll_widgets(window); window_push_others_below(window); - RCT2_GLOBAL(0x0141F738, uint32) = 0x80000000; - RCT2_GLOBAL(0x0141F73C, uint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) = 0x80000000; window->colours[0] = 24; window->colours[1] = 24; window->colours[2] = 24; @@ -215,12 +215,12 @@ static void window_water_paint() // Draw raise cost amount x = (window_water_widgets[WIDX_PREVIEW].left + window_water_widgets[WIDX_PREVIEW].right) / 2 + w->x; y = window_water_widgets[WIDX_PREVIEW].bottom + w->y + 5; - if (RCT2_GLOBAL(0x0141F738, uint32) != 0x80000000 && RCT2_GLOBAL(0x0141F738, uint32) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_WATER_RAISE_COST, uint32) != 0) gfx_draw_string_centred(dpi, 984, x, y, 0, (void*)0x0141F738); y += 10; // Draw lower cost amount - if (RCT2_GLOBAL(0x0141F73C, uint32) != 0x80000000 && RCT2_GLOBAL(0x0141F73C, uint32) != 0) + if (RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_WATER_LOWER_COST, uint32) != 0) gfx_draw_string_centred(dpi, 985, x, y, 0, (void*)0x0141F73C); }