diff --git a/src/addresses.h b/src/addresses.h index 31cea24828..490f7d7822 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -151,29 +151,6 @@ #define RCT2_ADDRESS_TICKS_SINCE_LAST_UPDATE 0x009DE588 -// Flags: -// 0x1 Enable selection -// 0x2 Enable construct selection, see CONSTRUCT_PATH_* -// 0x4 Show yellow arrow, see MAP_ARROW_* -// 0x8 ? -#define RCT2_ADDRESS_MAP_SELECTION_FLAGS 0x009DE58A -#define RCT2_ADDRESS_MAP_SELECTION_A_X 0x009DE58C -#define RCT2_ADDRESS_MAP_SELECTION_B_X 0x009DE58E -#define RCT2_ADDRESS_MAP_SELECTION_A_Y 0x009DE590 -#define RCT2_ADDRESS_MAP_SELECTION_B_Y 0x009DE592 -// Types: -// 0-3 Corners -// 4 Whole tile -// 5 ? -// 6-9 Quarters -// 10-13 Edges -#define RCT2_ADDRESS_MAP_SELECTION_TYPE 0x009DE594 - -#define RCT2_ADDRESS_MAP_ARROW_X 0x009DEA48 -#define RCT2_ADDRESS_MAP_ARROW_Y 0x009DEA4A -#define RCT2_ADDRESS_MAP_ARROW_Z 0x009DEA4C -#define RCT2_ADDRESS_MAP_ARROW_DIRECTION 0x009DEA4E - #define RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_X 0x009DEA52 #define RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Y 0x009DEA54 #define RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Z 0x009DEA56 @@ -555,6 +532,29 @@ #define RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO 0x009DE584 +// Flags: +// 0x1 Enable selection +// 0x2 Enable construct selection, see CONSTRUCT_PATH_* +// 0x4 Show yellow arrow, see MAP_ARROW_* +// 0x8 ? +#define RCT2_ADDRESS_MAP_SELECTION_FLAGS 0x009DE58A +#define RCT2_ADDRESS_MAP_SELECTION_A_X 0x009DE58C +#define RCT2_ADDRESS_MAP_SELECTION_B_X 0x009DE58E +#define RCT2_ADDRESS_MAP_SELECTION_A_Y 0x009DE590 +#define RCT2_ADDRESS_MAP_SELECTION_B_Y 0x009DE592 +// Types: +// 0-3 Corners +// 4 Whole tile +// 5 ? +// 6-9 Quarters +// 10-13 Edges +#define RCT2_ADDRESS_MAP_SELECTION_TYPE 0x009DE594 + +#define RCT2_ADDRESS_MAP_ARROW_X 0x009DEA48 +#define RCT2_ADDRESS_MAP_ARROW_Y 0x009DEA4A +#define RCT2_ADDRESS_MAP_ARROW_Z 0x009DEA4C +#define RCT2_ADDRESS_MAP_ARROW_DIRECTION 0x009DEA4E + #define RCT2_ADDRESS_COMMAND_MAP_X 0x009DEA5E #define RCT2_ADDRESS_COMMAND_MAP_Y 0x009DEA60 #define RCT2_ADDRESS_COMMAND_MAP_Z 0x009DEA62 diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 74f245e1e4..e8b14e6a52 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -64,7 +64,7 @@ void viewport_init_all() gPressedWidget.window_classification = 255; gPickupPeepImage = UINT32_MAX; gTooltipNotShownTicks = -1; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, sint16) = 0; + gMapSelectFlags = 0; RCT2_GLOBAL(0x009DEA50, sint16) = -1; textinput_cancel(); format_string((char*)0x0141FA44, STR_CANCEL, NULL); diff --git a/src/interface/window.c b/src/interface/window.c index 58250b8458..02f4cd04e4 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -1798,7 +1798,7 @@ void tool_cancel() map_invalidate_map_selection_tiles(); // Reset map selection - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) = 0; + gMapSelectFlags = 0; if (gCurrentToolWidget.widget_index != -1) { // Invalidate tool widget diff --git a/src/paint/map_element/map_element.c b/src/paint/map_element/map_element.c index e0fe681686..03514d24b3 100644 --- a/src/paint/map_element/map_element.c +++ b/src/paint/map_element/map_element.c @@ -180,18 +180,19 @@ static void sub_68B3FB(int x, int y) } dx >>= 1; // Display little yellow arrow when building footpaths? - if ((RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & 4) && - RCT2_GLOBAL(0x9DE56A, uint16) == RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) && - RCT2_GLOBAL(0x9DE56E, uint16) == RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16)){ + if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_ARROW) && + RCT2_GLOBAL(0x9DE56A, uint16) == gMapSelectArrowPosition.x && + RCT2_GLOBAL(0x9DE56E, uint16) == gMapSelectArrowPosition.y + ) { uint8 arrowRotation = (rotation - + (RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) & 3)) & 3; + + (gMapSelectArrowDirection & 3)) & 3; uint32 imageId = arrowRotation + - (RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) & 0xFC) + + (gMapSelectArrowDirection & 0xFC) + 0x20900C27; - int arrowZ = RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16); + int arrowZ = gMapSelectArrowPosition.z; RCT2_GLOBAL(0x9DE568, sint16) = x; RCT2_GLOBAL(0x9DE56C, sint16) = y; diff --git a/src/paint/map_element/surface.c b/src/paint/map_element/surface.c index cca5ea0ad9..ef395635db 100644 --- a/src/paint/map_element/surface.c +++ b/src/paint/map_element/surface.c @@ -1247,31 +1247,31 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) // ebp[4] = ebp; // ebp[8] = ebx - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint8) & 1) { + if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) { // loc_660FB8: rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; - if (pos.x >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) - && pos.x <= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) - && pos.y >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) - && pos.y <= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16)) { - - uint16 mapSelectionType = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16); - if (mapSelectionType >= 0xA) { + if (pos.x >= gMapSelectPositionA.x && + pos.x <= gMapSelectPositionB.x && + pos.y >= gMapSelectPositionA.y && + pos.y <= gMapSelectPositionB.y + ) { + uint16 mapSelectionType = gMapSelectType; + if (mapSelectionType >= MAP_SELECT_TYPE_EDGE_0) { // Walls // loc_661089: uint32 eax = ((((mapSelectionType - 9) + rotation) & 3) + 0x21) << 19; uint32 image_id = (SPR_TERRAIN_SELECTION_EDGE + byte_97B444[surfaceShape]) | eax | 0x20000000; paint_attach_to_previous_ps(image_id, 0, 0); - } else if (mapSelectionType >= 6) { + } else if (mapSelectionType >= MAP_SELECT_TYPE_QUARTER_0) { // loc_661051:(no jump) // Selection split into four quarter segments - uint32 eax = ((((mapSelectionType - 6) + rotation) & 3) + 0x27) << 19; + uint32 eax = ((((mapSelectionType - MAP_SELECT_TYPE_QUARTER_0) + rotation) & 3) + 0x27) << 19; uint32 image_id = (SPR_TERRAIN_SELECTION_QUARTER + byte_97B444[surfaceShape]) | eax | 0x20000000; paint_attach_to_previous_ps(image_id, 0, 0); - } else if (mapSelectionType <= 4) { + } else if (mapSelectionType <= MAP_SELECT_TYPE_FULL) { // Corners uint32 eax = mapSelectionType; - if (mapSelectionType != 4) { + if (mapSelectionType != MAP_SELECT_TYPE_FULL) { eax = (mapSelectionType + rotation) & 3; } @@ -1310,7 +1310,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) } } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint8) & 2) { + if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) { rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; rct_xy16 * tile; @@ -1319,9 +1319,9 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) continue; } - uint32 colours = COLOUR_GREY << 24 | COLOUR_SATURATED_GREEN << 19; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint8) & 8)) { - colours = COLOUR_GREY << 24 | COLOUR_BRIGHT_PURPLE << 19; + uint32 colours = COLOUR_GREY << 24 | COLOUR_BRIGHT_PURPLE << 19; + if (gMapSelectFlags & MAP_SELECT_FLAG_GREEN) { + colours = COLOUR_GREY << 24 | COLOUR_SATURATED_GREEN << 19; } uint32 image_id = (SPR_TERRAIN_SELECTION_CORNER + byte_97B444[surfaceShape]) | colours | 0x20000000; diff --git a/src/ride/ride.c b/src/ride/ride.c index bd94b65b82..faa33bf10a 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -1375,13 +1375,13 @@ void sub_6C9627() _currentTrackBeginX & 0xFFE0, _currentTrackBeginY & 0xFFE0 ); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~4; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; } break; default: if (_currentTrackSelectionFlags & 1) { _currentTrackSelectionFlags &= ~1; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint8) &= ~4; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; map_invalidate_tile_full(_currentTrackBeginX, _currentTrackBeginY); } sub_6C96C0(); @@ -1693,7 +1693,7 @@ static int ride_modify_entrance_or_exit(rct_map_element *mapElement, int x, int } sub_6C84CE(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; } else { // Remove entrance / exit game_do_command(x, (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY), y, rideIndex, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, bl, 0); diff --git a/src/ride/track_design.c b/src/ride/track_design.c index 936a024a98..dd26692e94 100644 --- a/src/ride/track_design.c +++ b/src/ride/track_design.c @@ -891,11 +891,10 @@ int track_design_place_maze(rct_track_td6 *td6, sint16 x, sint16 y, sint16 z, ui { if (_trackDesignPlaceOperation == PTD_OPERATION_DRAW_OUTLINES) { gMapSelectionTiles->x = -1; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, sint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, sint16) = y; - - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, sint16) = map_element_height(x, y) & 0xFFFF; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = _currentTrackPieceDirection; + gMapSelectArrowPosition.x = x; + gMapSelectArrowPosition.y = y; + gMapSelectArrowPosition.z = map_element_height(x, y) & 0xFFFF; + gMapSelectArrowDirection = _currentTrackPieceDirection; } _trackDesignPlaceZ = 0; @@ -1026,10 +1025,10 @@ bool track_design_place_ride(rct_track_td6 *td6, sint16 x, sint16 y, sint16 z, u gTrackPreviewOrigin = (rct_xyz16) { x, y, z }; if (_trackDesignPlaceOperation == PTD_OPERATION_DRAW_OUTLINES) { gMapSelectionTiles->x = -1; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, sint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, sint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, sint16) = map_element_height(x, y) & 0xFFFF; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = _currentTrackPieceDirection; + gMapSelectArrowPosition.x = x; + gMapSelectArrowPosition.y = y; + gMapSelectArrowPosition.z = map_element_height(x, y) & 0xFFFF; + gMapSelectArrowDirection = _currentTrackPieceDirection; } _trackDesignPlaceZ = 0; @@ -1294,8 +1293,9 @@ int sub_6D01B3(rct_track_td6 *td6, uint8 bl, uint8 rideIndex, int x, int y, int // 0x6D0FE6 if (_trackDesignPlaceOperation == PTD_OPERATION_DRAW_OUTLINES) { - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 0x6; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 3); + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN; map_invalidate_map_selection_tiles(); } diff --git a/src/ride/track_design_save.c b/src/ride/track_design_save.c index 280d94255b..89e2415f6f 100644 --- a/src/ride/track_design_save.c +++ b/src/ride/track_design_save.c @@ -953,8 +953,9 @@ static bool track_design_save_to_td6_for_maze(uint8 rideIndex, rct_track_td6 *td sub_6D01B3(td6, PTD_OPERATION_DRAW_OUTLINES, 0, 4096, 4096, 0); gTrackPreviewOrigin = (rct_xyz16) { startX, startY, startZ }; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, sint16) &= 0xFFF9; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, sint16) &= 0xFFF7; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN; td6->space_required_x = ((gTrackPreviewMax.x - gTrackPreviewMin.x) / 32) + 1; td6->space_required_y = ((gTrackPreviewMax.y - gTrackPreviewMin.y) / 32) + 1; @@ -1189,8 +1190,9 @@ static bool track_design_save_to_td6_for_tracked_ride(uint8 rideIndex, rct_track // Resave global vars for scenery reasons. gTrackPreviewOrigin = (rct_xyz16) { start_x, start_y, start_z }; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, sint16) &= 0xFFF9; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, sint16) &= 0xFFF7; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN; td6->space_required_x = ((gTrackPreviewMax.x - gTrackPreviewMin.x) / 32) + 1; td6->space_required_y = ((gTrackPreviewMax.y - gTrackPreviewMin.y) / 32) + 1; diff --git a/src/windows/footpath.c b/src/windows/footpath.c index f6a2ff8c76..2bb19766ac 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -228,7 +228,7 @@ static void window_footpath_close(rct_window *w) footpath_provisional_update(); viewport_set_visibility(0); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; window_invalidate_by_class(WC_TOP_TOOLBAR); hide_gridlines(); } @@ -257,7 +257,7 @@ static void window_footpath_mouseup(rct_window *w, int widgetIndex) tool_cancel(); footpath_provisional_update(); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_LAND; tool_set(w, WIDX_CONSTRUCT_ON_LAND, 17); gInputFlags |= INPUT_FLAG_6; @@ -272,7 +272,7 @@ static void window_footpath_mouseup(rct_window *w, int widgetIndex) tool_cancel(); footpath_provisional_update(); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL_TOOL; tool_set(w, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, 12); gInputFlags |= INPUT_FLAG_6; @@ -445,14 +445,14 @@ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window * _window_footpath_provisional_path_arrow_timer = 5; gFootpathProvisionalFlags ^= PROVISIONAL_PATH_FLAG_SHOW_ARROW; footpath_get_next_path_info(&type, &x, &y, &z, &slope); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = z * 8; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = gFootpathConstructDirection; + gMapSelectArrowPosition.x = x; + gMapSelectArrowPosition.y = y; + gMapSelectArrowPosition.z = z * 8; + gMapSelectArrowDirection = gFootpathConstructDirection; if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_SHOW_ARROW) - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 2); + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; else - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 2); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; map_invalidate_tile_full(x, y); } } @@ -655,7 +655,7 @@ static void window_footpath_set_provisional_path_at_point(int x, int y) rct_map_element *mapElement; map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 2); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; rct_xy16 mapCoord = { 0 }; get_map_coordinates_from_pos(x, y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y, &interactionType, &mapElement, NULL); @@ -663,7 +663,7 @@ static void window_footpath_set_provisional_path_at_point(int x, int y) y = mapCoord.y; if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE) { - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; footpath_provisional_update(); } else { // Check for change @@ -677,12 +677,12 @@ static void window_footpath_set_provisional_path_at_point(int x, int y) } // Set map selection - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = y; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectPositionA.x = x; + gMapSelectPositionA.y = y; + gMapSelectPositionB.x = x; + gMapSelectPositionB.y = y; footpath_provisional_update(); @@ -707,22 +707,24 @@ static void window_footpath_set_selection_start_bridge_at_point(int screenX, int rct_map_element *mapElement; map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0) & ~(1 << 2); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; footpath_bridge_get_info_from_pos(screenX, screenY, &x, &y, &direction, &mapElement); if (x == (sint16)0x8000) return; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0) | (1 << 2); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = y; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectPositionA.x = x; + gMapSelectPositionB.x = x; + gMapSelectPositionA.y = y; + gMapSelectPositionB.y = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = direction; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16) = y; + gMapSelectArrowDirection = direction; + gMapSelectArrowPosition.x = x; + gMapSelectArrowPosition.y = y; int z = mapElement->base_height; @@ -734,7 +736,7 @@ static void window_footpath_set_selection_start_bridge_at_point(int screenX, int z += 2; // Add another 2 for a steep slope } - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = z << 3; + gMapSelectArrowPosition.z = z << 3; map_invalidate_selection_rect(); } @@ -1016,7 +1018,8 @@ static void window_footpath_set_enabled_and_pressed_widgets() if (gFootpathConstructionMode == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL) { map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 1) | (1 << 3); + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags |= MAP_SELECT_FLAG_GREEN; direction = gFootpathConstructDirection; gMapSelectionTiles[0].x = gFootpathConstructFromPosition.x + TileDirectionDelta[direction].x; diff --git a/src/windows/guest.c b/src/windows/guest.c index 8f1aec44e0..f38c7d916d 100644 --- a/src/windows/guest.c +++ b/src/windows/guest.c @@ -1171,17 +1171,17 @@ void window_guest_overview_tool_update(rct_window* w, int widgetIndex, int x, in map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; int map_x, map_y; footpath_get_coordinates_from_pos(x, y + 16, &map_x, &map_y, NULL, NULL); if (map_x != (sint16)0x8000){ - 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, sint16) = map_x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = map_x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = map_y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = map_y; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectPositionA.x = map_x; + gMapSelectPositionB.x = map_x; + gMapSelectPositionA.y = map_y; + gMapSelectPositionB.y = map_y; map_invalidate_selection_rect(); } diff --git a/src/windows/map.c b/src/windows/map.c index aa802c9ac1..4352ffbddb 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -461,16 +461,16 @@ static void window_map_tooldrag(rct_window* w, int widgetIndex, int x, int y) { switch (widgetIndex) { case WIDX_SET_LAND_RIGHTS: - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0)) { + if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) { gGameCommandErrorTitle = 0; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16), + gMapSelectPositionA.x, GAME_COMMAND_FLAG_APPLY, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16), + gMapSelectPositionA.y, RCT2_GLOBAL(0x00F1AD61, uint8), GAME_COMMAND_SET_LAND_OWNERSHIP, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); } break; @@ -546,23 +546,23 @@ static void window_map_scrollmousedown(rct_window *w, int scrollIndex, int x, in mapY = (mapY - radius) & 0xFFE0; map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = mapX; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = mapY; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = mapX + size; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = mapY + size; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectPositionA.x = mapX; + gMapSelectPositionA.y = mapY; + gMapSelectPositionB.x = mapX + size; + gMapSelectPositionB.y = mapY + size; map_invalidate_selection_rect(); gGameCommandErrorTitle = STR_CANT_CHANGE_LAND_TYPE; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, GAME_COMMAND_FLAG_APPLY, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, gLandToolTerrainSurface | (gLandToolTerrainEdge << 8), GAME_COMMAND_CHANGE_SURFACE_STYLE, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); } else if (widget_is_active_tool(w, WIDX_SET_LAND_RIGHTS)) { // Set land rights @@ -573,23 +573,23 @@ static void window_map_scrollmousedown(rct_window *w, int scrollIndex, int x, in mapY = (mapY - radius) & 0xFFE0; map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = mapX; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = mapY; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = mapX + size; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = mapY + size; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectPositionA.x = mapX; + gMapSelectPositionA.y = mapY; + gMapSelectPositionB.x = mapX + size; + gMapSelectPositionB.y = mapY + size; map_invalidate_selection_rect(); gGameCommandErrorTitle = 0; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16), + gMapSelectPositionA.x, GAME_COMMAND_FLAG_APPLY, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16), + gMapSelectPositionA.y, RCT2_GLOBAL(0x00F1AD61, uint8), GAME_COMMAND_SET_LAND_OWNERSHIP, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); } } @@ -1127,13 +1127,13 @@ static void window_map_set_land_rights_tool_update(int x, int y) rct_viewport *viewport; map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; screen_get_map_xy(x, y, &mapX, &mapY, &viewport); if (mapX == (sint16)0x8000) return; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectType = MAP_SELECT_TYPE_FULL; int landToolSize = gLandToolSize; if (landToolSize == 0) @@ -1143,10 +1143,10 @@ static void window_map_set_land_rights_tool_update(int x, int y) int radius = (landToolSize * 16) - 16; mapX = (mapX - radius) & 0xFFE0; mapY = (mapY - radius) & 0xFFE0; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = mapX; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = mapY; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = mapX + size; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = mapY + size; + gMapSelectPositionA.x = mapX; + gMapSelectPositionA.y = mapY; + gMapSelectPositionB.x = mapX + size; + gMapSelectPositionB.y = mapY + size; map_invalidate_selection_rect(); } @@ -1187,8 +1187,8 @@ static void window_map_place_park_entrance_tool_update(int x, int y) map_invalidate_selection_rect(); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 1); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; sub_666EEF(x, y, &mapX, &mapY, &mapZ, &direction); if (mapX == (sint16)-1) { park_remove_ghost_entrance(); @@ -1205,7 +1205,7 @@ static void window_map_place_park_entrance_tool_update(int x, int y) gMapSelectionTiles[3].x = -1; gMapSelectionTiles[3].y = -1; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 1); + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; map_invalidate_map_selection_tiles(); if ( gParkEntranceGhostExists && @@ -1230,8 +1230,8 @@ static void window_map_set_peep_spawn_tool_update(int x, int y) rct_map_element *mapElement; map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 2); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; footpath_bridge_get_info_from_pos(x, y, &mapX, &mapY, &direction, &mapElement); if ((mapX & 0xFFFF) == 0x8000) return; @@ -1244,17 +1244,17 @@ static void window_map_set_peep_spawn_tool_update(int x, int y) mapZ += 16; } - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 2); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = mapX; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = mapY; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = mapX; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = mapY; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = direction ^ 2; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) = mapX; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16) = mapY; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = mapZ; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectPositionA.x = mapX; + gMapSelectPositionA.y = mapY; + gMapSelectPositionB.x = mapX; + gMapSelectPositionB.y = mapY; + gMapSelectArrowDirection = direction ^ 2; + gMapSelectArrowPosition.x = mapX; + gMapSelectArrowPosition.y = mapY; + gMapSelectArrowPosition.z = mapZ; map_invalidate_selection_rect(); } diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index 81bb713d9d..724b65e7dc 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -163,7 +163,7 @@ static void window_maze_construction_close(rct_window *w) viewport_set_visibility(0); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 1); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; // In order to cancel the yellow arrow correctly the // selection tool should be cancelled. @@ -349,7 +349,8 @@ static void window_maze_construction_entrance_tooldown(int x, int y, rct_window* map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~((1 << 0) | (1 << 2)); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; int direction = 0; ride_get_entrance_or_exit_position_from_screen_position(x, y, &x, &y, &direction); diff --git a/src/windows/park.c b/src/windows/park.c index 75b601dd94..8830d81a19 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -726,9 +726,10 @@ static void window_park_entrance_update(rct_window *w) } -void window_park_entrance_tool_update_land_rights(sint16 x, sint16 y){ +void window_park_entrance_tool_update_land_rights(sint16 x, sint16 y) +{ map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; rct_xy16 mapTile = { 0 }; screen_get_map_xy(x, y, &mapTile.x, &mapTile.y, NULL); @@ -743,13 +744,13 @@ void window_park_entrance_tool_update_land_rights(sint16 x, sint16 y){ uint8 state_changed = 0; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) { + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) != 4){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + if (gMapSelectType != MAP_SELECT_TYPE_FULL) { + gMapSelectType = MAP_SELECT_TYPE_FULL; state_changed++; } @@ -765,26 +766,26 @@ void window_park_entrance_tool_update_land_rights(sint16 x, sint16 y){ mapTile.x &= 0xFFE0; mapTile.y &= 0xFFE0; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; + if (gMapSelectPositionA.x != mapTile.x){ + gMapSelectPositionA.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; + if (gMapSelectPositionA.y != mapTile.y){ + gMapSelectPositionA.y = mapTile.y; state_changed++; } mapTile.x += tool_length; mapTile.y += tool_length; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; + if (gMapSelectPositionB.x != mapTile.x){ + gMapSelectPositionB.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; + if (gMapSelectPositionB.y != mapTile.y){ + gMapSelectPositionB.y = mapTile.y; state_changed++; } @@ -793,13 +794,13 @@ void window_park_entrance_tool_update_land_rights(sint16 x, sint16 y){ return; RCT2_GLOBAL(0x00F1AD62, uint32) = game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 0x4, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, LandRightsMode ? 0x00E : 0x20F, 35, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); } @@ -828,13 +829,13 @@ static void window_park_entrance_tooldown(rct_window* w, int widgetIndex, int x, if (x != (sint16)0x8000) { gGameCommandErrorTitle = 0x6BD; // Can't buy land... game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, 0x00E, GAME_COMMAND_BUY_LAND_RIGHTS, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); } } @@ -842,13 +843,13 @@ static void window_park_entrance_tooldown(rct_window* w, int widgetIndex, int x, if (x != (sint16)0x8000) { gGameCommandErrorTitle = 0x6C0; // Can't buy construction rights here... game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, 0x20F, GAME_COMMAND_BUY_LAND_RIGHTS, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); } } @@ -871,13 +872,13 @@ static void window_park_entrance_tooldrag(rct_window* w, int widgetIndex, int x, if (x != (sint16)0x8000) { gGameCommandErrorTitle = 0x6BD; // Can't buy land... game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, 0x00E, GAME_COMMAND_BUY_LAND_RIGHTS, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); } } @@ -885,13 +886,13 @@ static void window_park_entrance_tooldrag(rct_window* w, int widgetIndex, int x, if (x != (sint16)0x8000) { gGameCommandErrorTitle = 0x6C0; // Can't buy construction rights here... game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, 0x20F, GAME_COMMAND_BUY_LAND_RIGHTS, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); } } diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index 8c403d51f3..75eb7171b6 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -585,7 +585,7 @@ static void window_ride_construction_close(rct_window *w) viewport_set_visibility(0); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 1); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; // In order to cancel the yellow arrow correctly the // selection tool should be cancelled. Don't do a tool cancel if @@ -2753,17 +2753,17 @@ void sub_6C94D8() z = _currentTrackBeginZ; direction = _currentTrackPieceDirection; type = _currentTrackPieceType; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = z; + gMapSelectArrowPosition.x = x; + gMapSelectArrowPosition.y = y; + gMapSelectArrowPosition.z = z; if (direction >= 4) direction += 4; if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_BACK) direction ^= 2; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = direction; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~4; + gMapSelectArrowDirection = direction; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; if (_currentTrackSelectionFlags & 1) - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 4; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; map_invalidate_tile_full(x, y); break; case RIDE_CONSTRUCTION_STATE_SELECTED: @@ -2795,21 +2795,21 @@ void sub_6C94D8() x = _currentTrackBeginX & 0xFFE0; y = _currentTrackBeginY & 0xFFE0; z = _currentTrackBeginZ + 15; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = z; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = 4; + gMapSelectArrowPosition.x = x; + gMapSelectArrowPosition.y = y; + gMapSelectArrowPosition.z = z; + gMapSelectArrowDirection = 4; if (((_currentTrackBeginX & 0x1F) | (_currentTrackBeginY & 0x1F)) != 0) { - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = 6; + gMapSelectArrowDirection = 6; if (((_currentTrackBeginX & 0x1F) & (_currentTrackBeginY & 0x1F)) == 0) { - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = 5; + gMapSelectArrowDirection = 5; if ((_currentTrackBeginY & 0x1F) == 0) - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = 7; + gMapSelectArrowDirection = 7; } } - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~4; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; if (_currentTrackSelectionFlags & 1) - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 4; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; map_invalidate_tile_full(x, y); break; } @@ -2825,7 +2825,8 @@ static void window_ride_construction_update_map_selection() int trackType, trackDirection, x, y; map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 10; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags |= MAP_SELECT_FLAG_GREEN; switch (_rideConstructionState) { case RIDE_CONSTRUCTION_STATE_0: @@ -3546,7 +3547,9 @@ void ride_construction_toolupdate_construct(int screenX, int screenY) const rct_preview_track *trackBlock; map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 | 2 | 4); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; if (!ride_get_place_position_from_screen_position(screenX, screenY, &x, &y)) { sub_6C9627(); map_invalidate_map_selection_tiles(); @@ -3557,13 +3560,13 @@ void ride_construction_toolupdate_construct(int screenX, int screenY) if (z == 0) z = map_get_highest_z(x >> 5, y >> 5); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 2; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~8; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 4; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = _currentTrackPieceDirection; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = z; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN; + gMapSelectArrowDirection = _currentTrackPieceDirection; + gMapSelectArrowPosition.x = x; + gMapSelectArrowPosition.y = y; + gMapSelectArrowPosition.z = z; gMapSelectionTiles[0].x = x; gMapSelectionTiles[0].y = y; gMapSelectionTiles[1].x = -1; @@ -3583,11 +3586,11 @@ void ride_construction_toolupdate_construct(int screenX, int screenY) // - Original code checks this first as its already set origin tile, probably just a micro optimisation window_ride_construction_select_map_tiles(ride, trackType, trackDirection, x, y); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = z; + gMapSelectArrowPosition.z = z; if (_trackPlaceZ == 0) { // Raise z above all slopes and water highestZ = 0; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & 2) { + if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) { rct_xy16 *selectedTile = gMapSelectionTiles; while (selectedTile->x != -1) { if (selectedTile->x < (256 * 32) && selectedTile->y < (256 * 32)) { @@ -3610,7 +3613,7 @@ void ride_construction_toolupdate_construct(int screenX, int screenY) } while (trackBlock->index != 255); z -= bx; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = z; + gMapSelectArrowPosition.z = z; bx = 41; _currentTrackBeginX = x; _currentTrackBeginY = y; @@ -3685,22 +3688,25 @@ void ride_construction_toolupdate_entrance_exit(int screenX, int screenY) map_invalidate_selection_rect(); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 | 2 | 4); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; ride_get_entrance_or_exit_position_from_screen_position(screenX, screenY, &x, &y, &direction); if (RCT2_GLOBAL(0x00F44194, uint8) == 255) { sub_6C9627(); return; } - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 1 | 4; - 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_A_Y, uint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = direction ^ 2; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16) = y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = RCT2_GLOBAL(0x00F44190, uint8) * 8; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectPositionA.x = x; + gMapSelectPositionA.y = y; + gMapSelectPositionB.x = x; + gMapSelectPositionB.y = y; + gMapSelectArrowDirection = direction ^ 2; + gMapSelectArrowPosition.x = x; + gMapSelectArrowPosition.y = y; + gMapSelectArrowPosition.z = RCT2_GLOBAL(0x00F44190, uint8) * 8; map_invalidate_selection_rect(); direction = RCT2_GLOBAL(0x00F44194, uint8) ^ 2; @@ -3738,7 +3744,7 @@ void ride_construction_tooldown_construct(int screenX, int screenY) // Raise z above all slopes and water highestZ = 0; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & 2) { + if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) { rct_xy16 *selectedTile = gMapSelectionTiles; while (selectedTile->x != -1) { if (selectedTile->x >= (256 * 32) || selectedTile->y >= (256 * 32)) @@ -3754,7 +3760,9 @@ void ride_construction_tooldown_construct(int screenX, int screenY) RCT2_GLOBAL(0x00F440E2, uint16) = z; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 | 2 | 4); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; if (!ride_get_place_position_from_screen_position(screenX, screenY, &x, &y)) return; @@ -3927,7 +3935,8 @@ static void ride_construction_tooldown_entrance_exit(int screenX, int screenY) { sub_6C9627(); map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 | 4); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; int mapX, mapY, direction; ride_get_entrance_or_exit_position_from_screen_position(screenX, screenY, &mapX, &mapY, &direction); diff --git a/src/windows/staff.c b/src/windows/staff.c index fecde9f2f3..a2591db387 100644 --- a/src/windows/staff.c +++ b/src/windows/staff.c @@ -1092,17 +1092,17 @@ void window_staff_overview_tool_update(rct_window* w, int widgetIndex, int x, in map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; int map_x, map_y; footpath_get_coordinates_from_pos(x, y + 16, &map_x, &map_y, NULL, NULL); if (map_x != (sint16)0x8000) { - 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, sint16) = map_x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = map_x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = map_y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = map_y; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectType = MAP_SELECT_TYPE_FULL; + gMapSelectPositionA.x = map_x; + gMapSelectPositionB.x = map_x; + gMapSelectPositionA.y = map_y; + gMapSelectPositionB.y = map_y; map_invalidate_selection_rect(); } diff --git a/src/windows/tile_inspector.c b/src/windows/tile_inspector.c index ee68577fbe..96053e9553 100644 --- a/src/windows/tile_inspector.c +++ b/src/windows/tile_inspector.c @@ -348,7 +348,7 @@ static void window_tile_inspector_tool_update(rct_window* w, int widgetIndex, in short mapX, mapY; map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; mapX = x; mapY = y; @@ -357,12 +357,12 @@ static void window_tile_inspector_tool_update(rct_window* w, int widgetIndex, in return; } - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapX; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapY; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapX; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapY; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectPositionA.x = mapX; + gMapSelectPositionA.y = mapY; + gMapSelectPositionB.x = mapX; + gMapSelectPositionB.y = mapY; + gMapSelectType = MAP_SELECT_TYPE_FULL; map_invalidate_selection_rect(); diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index e49bd99f00..6ad6f2d436 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1653,7 +1653,7 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w */ void top_toolbar_tool_update_scenery_clear(sint16 x, sint16 y){ map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; rct_xy16 mapTile = { 0 }; screen_get_map_xy(x, y, &mapTile.x, &mapTile.y, NULL); @@ -1668,13 +1668,13 @@ void top_toolbar_tool_update_scenery_clear(sint16 x, sint16 y){ uint8 state_changed = 0; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) { + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) != 4){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + if (gMapSelectType != MAP_SELECT_TYPE_FULL) { + gMapSelectType = MAP_SELECT_TYPE_FULL; state_changed++; } @@ -1690,26 +1690,26 @@ void top_toolbar_tool_update_scenery_clear(sint16 x, sint16 y){ mapTile.x &= 0xFFE0; mapTile.y &= 0xFFE0; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; + if (gMapSelectPositionA.x != mapTile.x){ + gMapSelectPositionA.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; + if (gMapSelectPositionA.y != mapTile.y){ + gMapSelectPositionA.y = mapTile.y; state_changed++; } mapTile.x += tool_length; mapTile.y += tool_length; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; + if (gMapSelectPositionB.x != mapTile.x){ + gMapSelectPositionB.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; + if (gMapSelectPositionB.y != mapTile.y){ + gMapSelectPositionB.y = mapTile.y; state_changed++; } @@ -1717,10 +1717,10 @@ void top_toolbar_tool_update_scenery_clear(sint16 x, sint16 y){ if (!state_changed) return; - int eax = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16); - int ecx = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16); - int edi = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16); - int ebp = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16); + int eax = gMapSelectPositionA.x; + int ecx = gMapSelectPositionA.y; + int edi = gMapSelectPositionB.x; + int ebp = gMapSelectPositionB.y; money32 cost = game_do_command(eax, 0, ecx, 0, GAME_COMMAND_CLEAR_SCENERY, edi, ebp); if (RCT2_GLOBAL(0x00F1AD62, money32) != cost){ @@ -1732,7 +1732,7 @@ void top_toolbar_tool_update_scenery_clear(sint16 x, sint16 y){ void top_toolbar_tool_update_land_paint(sint16 x, sint16 y){ map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; rct_xy16 mapTile = { 0 }; screen_get_map_xy(x, y, &mapTile.x, &mapTile.y, NULL); @@ -1747,13 +1747,13 @@ void top_toolbar_tool_update_land_paint(sint16 x, sint16 y){ uint8 state_changed = 0; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) { + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) != 4){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + if (gMapSelectType != MAP_SELECT_TYPE_FULL) { + gMapSelectType = MAP_SELECT_TYPE_FULL; state_changed++; } @@ -1769,26 +1769,26 @@ void top_toolbar_tool_update_land_paint(sint16 x, sint16 y){ mapTile.x &= 0xFFE0; mapTile.y &= 0xFFE0; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; + if (gMapSelectPositionA.x != mapTile.x){ + gMapSelectPositionA.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; + if (gMapSelectPositionA.y != mapTile.y){ + gMapSelectPositionA.y = mapTile.y; state_changed++; } mapTile.x += tool_length; mapTile.y += tool_length; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; + if (gMapSelectPositionB.x != mapTile.x){ + gMapSelectPositionB.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; + if (gMapSelectPositionB.y != mapTile.y){ + gMapSelectPositionB.y = mapTile.y; state_changed++; } @@ -1805,7 +1805,7 @@ void top_toolbar_tool_update_land(sint16 x, sint16 y){ map_invalidate_selection_rect(); if (gCurrentToolId == 3){ - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))) + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) return; money32 lower_cost = selection_lower_land(0); @@ -1823,7 +1823,7 @@ void top_toolbar_tool_update_land(sint16 x, sint16 y){ sint16 tool_size = gLandToolSize; rct_xy16 mapTile = { .x = x, .y = y }; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; if (tool_size == 1 && !gLandMountainMode){ int direction; screen_pos_to_map_pos(&mapTile.x, &mapTile.y, &direction); @@ -1843,34 +1843,34 @@ void top_toolbar_tool_update_land(sint16 x, sint16 y){ uint8 state_changed = 0; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) { + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) != direction){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = direction; + if (gMapSelectType != direction) { + gMapSelectType = direction; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; + if (gMapSelectPositionA.x != mapTile.x){ + gMapSelectPositionA.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; + if (gMapSelectPositionA.y != mapTile.y){ + gMapSelectPositionA.y = mapTile.y; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; + if (gMapSelectPositionB.x != mapTile.x){ + gMapSelectPositionB.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; + if (gMapSelectPositionB.y != mapTile.y){ + gMapSelectPositionB.y = mapTile.y; state_changed++; } @@ -1907,13 +1907,13 @@ void top_toolbar_tool_update_land(sint16 x, sint16 y){ uint8 state_changed = 0; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) { + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) != 4){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + if (gMapSelectType != MAP_SELECT_TYPE_FULL) { + gMapSelectType = MAP_SELECT_TYPE_FULL; state_changed++; } @@ -1929,26 +1929,26 @@ void top_toolbar_tool_update_land(sint16 x, sint16 y){ mapTile.x &= 0xFFE0; mapTile.y &= 0xFFE0; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; + if (gMapSelectPositionA.x != mapTile.x){ + gMapSelectPositionA.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; + if (gMapSelectPositionA.y != mapTile.y){ + gMapSelectPositionA.y = mapTile.y; state_changed++; } mapTile.x += tool_length; mapTile.y += tool_length; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; + if (gMapSelectPositionB.x != mapTile.x){ + gMapSelectPositionB.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; + if (gMapSelectPositionB.y != mapTile.y){ + gMapSelectPositionB.y = mapTile.y; state_changed++; } @@ -1975,21 +1975,21 @@ void top_toolbar_tool_update_water(sint16 x, sint16 y){ map_invalidate_selection_rect(); if (gCurrentToolId == 3){ - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))) + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) return; money32 lower_cost = lower_water( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16), + gMapSelectPositionA.x, + gMapSelectPositionA.y, + gMapSelectPositionB.x, + gMapSelectPositionB.y, 0); money32 raise_cost = raise_water( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16), + gMapSelectPositionA.x, + gMapSelectPositionA.y, + gMapSelectPositionB.x, + gMapSelectPositionB.y, 0); if (gWaterToolRaiseCost != raise_cost || gWaterToolLowerCost != lower_cost) { @@ -2000,7 +2000,7 @@ void top_toolbar_tool_update_water(sint16 x, sint16 y){ return; } - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; rct_xy16 mapTile = { 0 }; int interaction_type = 0; @@ -2028,13 +2028,13 @@ void top_toolbar_tool_update_water(sint16 x, sint16 y){ uint8 state_changed = 0; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) { + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) != 5){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 5; + if (gMapSelectType != MAP_SELECT_TYPE_5) { + gMapSelectType = MAP_SELECT_TYPE_5; state_changed++; } @@ -2050,26 +2050,26 @@ void top_toolbar_tool_update_water(sint16 x, sint16 y){ mapTile.x &= 0xFFE0; mapTile.y &= 0xFFE0; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; + if (gMapSelectPositionA.x != mapTile.x){ + gMapSelectPositionA.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; + if (gMapSelectPositionA.y != mapTile.y){ + gMapSelectPositionA.y = mapTile.y; state_changed++; } mapTile.x += tool_length; mapTile.y += tool_length; - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) != mapTile.x){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; + if (gMapSelectPositionB.x != mapTile.x){ + gMapSelectPositionB.x = mapTile.x; state_changed++; } - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) != mapTile.y){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; + if (gMapSelectPositionB.y != mapTile.y){ + gMapSelectPositionB.y = mapTile.y; state_changed++; } @@ -2078,17 +2078,17 @@ void top_toolbar_tool_update_water(sint16 x, sint16 y){ return; money32 lower_cost = lower_water( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16), + gMapSelectPositionA.x, + gMapSelectPositionA.y, + gMapSelectPositionB.x, + gMapSelectPositionB.y, 0); money32 raise_cost = raise_water( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16), + gMapSelectPositionA.x, + gMapSelectPositionA.y, + gMapSelectPositionB.x, + gMapSelectPositionB.y, 0); if (gWaterToolRaiseCost != raise_cost || gWaterToolLowerCost != lower_cost) { @@ -2267,7 +2267,8 @@ void top_toolbar_tool_update_scenery(sint16 x, sint16 y){ map_invalidate_selection_rect(); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~((1 << 0) | (1 << 1)); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; if (window_scenery_is_repaint_scenery_tool_on) return; @@ -2297,17 +2298,17 @@ void top_toolbar_tool_update_scenery(sint16 x, sint16 y){ switch (scenery_type){ case 0: - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectPositionA.x = mapTile.x; + gMapSelectPositionA.y = mapTile.y; + gMapSelectPositionB.x = mapTile.x; + gMapSelectPositionB.y = mapTile.y; scenery = g_smallSceneryEntries[selected_scenery]; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + gMapSelectType = MAP_SELECT_TYPE_FULL; if (!(scenery->small_scenery.flags & SMALL_SCENERY_FLAG_FULL_TILE)){ - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = ((parameter2 & 0xFF) ^ 2) + 6; + gMapSelectType = MAP_SELECT_TYPE_QUARTER_0 + ((parameter2 & 0xFF) ^ 2); } map_invalidate_selection_rect(); @@ -2349,12 +2350,12 @@ void top_toolbar_tool_update_scenery(sint16 x, sint16 y){ RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_COST, money32) = cost; break; case 1: - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectPositionA.x = mapTile.x; + gMapSelectPositionA.y = mapTile.y; + gMapSelectPositionB.x = mapTile.x; + gMapSelectPositionB.y = mapTile.y; + gMapSelectType = MAP_SELECT_TYPE_FULL; map_invalidate_selection_rect(); @@ -2378,12 +2379,12 @@ void top_toolbar_tool_update_scenery(sint16 x, sint16 y){ RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_COST, money32) = cost; break; case 2: - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 10 + (parameter2 & 0xFF); + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectPositionA.x = mapTile.x; + gMapSelectPositionA.y = mapTile.y; + gMapSelectPositionB.x = mapTile.x; + gMapSelectPositionB.y = mapTile.y; + gMapSelectType = MAP_SELECT_TYPE_EDGE_0 + (parameter2 & 0xFF); map_invalidate_selection_rect(); @@ -2445,7 +2446,7 @@ void top_toolbar_tool_update_scenery(sint16 x, sint16 y){ } selectedTile->x = 0xFFFF; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 1); + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; map_invalidate_map_selection_tiles(); // If no change in ghost placement @@ -2485,12 +2486,12 @@ void top_toolbar_tool_update_scenery(sint16 x, sint16 y){ RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_COST, money32) = cost; break; case 4: - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) = mapTile.x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) = mapTile.y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) = mapTile.x; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) = mapTile.y; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectPositionA.x = mapTile.x; + gMapSelectPositionA.y = mapTile.y; + gMapSelectPositionB.x = mapTile.x; + gMapSelectPositionB.y = mapTile.y; + gMapSelectType = MAP_SELECT_TYPE_FULL; map_invalidate_selection_rect(); @@ -2550,39 +2551,39 @@ static void window_top_toolbar_tool_down(rct_window* w, int widgetIndex, int x, { switch (widgetIndex){ case WIDX_CLEAR_SCENERY: - if (!RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0)) + if (!gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) break; gGameCommandErrorTitle = STR_UNABLE_TO_REMOVE_ALL_SCENERY_FROM_HERE; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, (gClearSmallScenery | gClearLargeScenery << 1 | gClearFootpath << 2), GAME_COMMAND_CLEAR_SCENERY, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); gCurrentToolId = 12; break; case WIDX_LAND: - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16)&(1 << 0)){ + if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) { gGameCommandErrorTitle = STR_CANT_CHANGE_LAND_TYPE; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, gLandToolTerrainSurface | (gLandToolTerrainEdge << 8), GAME_COMMAND_CHANGE_SURFACE_STYLE, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); gCurrentToolId = 3; } break; case WIDX_WATER: - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16)&(1 << 0)){ + if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) { gCurrentToolId = 3; } break; @@ -2598,19 +2599,19 @@ static void window_top_toolbar_tool_down(rct_window* w, int widgetIndex, int x, */ money32 selection_raise_land(uint8 flags) { - int centreX = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16)) / 2; - int centreY = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16)) / 2; + int centreX = (gMapSelectPositionA.x + gMapSelectPositionB.x) / 2; + int centreY = (gMapSelectPositionA.y + gMapSelectPositionB.y) / 2; centreX += 16; centreY += 16; - uint32 xBounds = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) & 0xFFFF) | (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) << 16); - uint32 yBounds = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) & 0xFFFF) | (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) << 16); + uint32 xBounds = (gMapSelectPositionA.x & 0xFFFF) | (gMapSelectPositionB.x << 16); + uint32 yBounds = (gMapSelectPositionA.y & 0xFFFF) | (gMapSelectPositionB.y << 16); gGameCommandErrorTitle = STR_CANT_RAISE_LAND_HERE; if (gLandMountainMode) { return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_EDIT_LAND_SMOOTH, 1, yBounds); } else { - return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_RAISE_LAND, RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16), yBounds); + return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_RAISE_LAND, gMapSelectType, yBounds); } } @@ -2620,19 +2621,19 @@ money32 selection_raise_land(uint8 flags) */ money32 selection_lower_land(uint8 flags) { - int centreX = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16)) / 2; - int centreY = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16)) / 2; + int centreX = (gMapSelectPositionA.x + gMapSelectPositionB.x) / 2; + int centreY = (gMapSelectPositionA.y + gMapSelectPositionB.y) / 2; centreX += 16; centreY += 16; - uint32 xBounds = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) & 0xFFFF) | (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) << 16); - uint32 yBounds = (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) & 0xFFFF) | (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) << 16); + uint32 xBounds = (gMapSelectPositionA.x & 0xFFFF) | (gMapSelectPositionB.x << 16); + uint32 yBounds = (gMapSelectPositionA.y & 0xFFFF) | (gMapSelectPositionB.y << 16); gGameCommandErrorTitle = STR_CANT_LOWER_LAND_HERE; if (gLandMountainMode) { return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_EDIT_LAND_SMOOTH, 0xFFFF, yBounds); } else { - return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_LOWER_LAND, RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16), yBounds); + return game_do_command(centreX, flags, centreY, xBounds, GAME_COMMAND_LOWER_LAND, gMapSelectType, yBounds); } } @@ -2705,13 +2706,13 @@ void window_top_toolbar_water_tool_drag(short x, short y) gGameCommandErrorTitle = STR_CANT_RAISE_WATER_LEVEL_HERE; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, dx, GAME_COMMAND_RAISE_WATER, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); gWaterToolRaiseCost = MONEY32_UNDEFINED; gWaterToolLowerCost = MONEY32_UNDEFINED; @@ -2727,13 +2728,13 @@ void window_top_toolbar_water_tool_drag(short x, short y) gGameCommandErrorTitle = STR_CANT_LOWER_WATER_LEVEL_HERE; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, dx, GAME_COMMAND_LOWER_WATER, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); gWaterToolRaiseCost = MONEY32_UNDEFINED; gWaterToolLowerCost = MONEY32_UNDEFINED; @@ -2753,35 +2754,35 @@ static void window_top_toolbar_tool_drag(rct_window* w, int widgetIndex, int x, if (window_find_by_class(WC_ERROR) != NULL) break; - if (!RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0)) + if (!gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) break; gGameCommandErrorTitle = STR_UNABLE_TO_REMOVE_ALL_SCENERY_FROM_HERE; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, (gClearSmallScenery | gClearLargeScenery << 1 | gClearFootpath << 2), GAME_COMMAND_CLEAR_SCENERY, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); gCurrentToolId = 12; break; case WIDX_LAND: // Custom setting to only change land style instead of raising or lowering land if (gLandPaintMode) { - if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16)&(1 << 0)){ + if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) { gGameCommandErrorTitle = STR_CANT_CHANGE_LAND_TYPE; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16), + gMapSelectPositionA.x, 1, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16), + gMapSelectPositionA.y, gLandToolTerrainSurface | (gLandToolTerrainEdge << 8), GAME_COMMAND_CHANGE_SURFACE_STYLE, - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16), - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + gMapSelectPositionB.x, + gMapSelectPositionB.y ); // The tool is set to 12 here instead of 3 so that the dragging cursor is not the elevation change cursor gCurrentToolId = 12; @@ -2809,17 +2810,17 @@ static void window_top_toolbar_tool_up(rct_window* w, int widgetIndex, int x, in switch (widgetIndex) { case WIDX_LAND: map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; gCurrentToolId = 0x12; break; case WIDX_WATER: map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; gCurrentToolId = 0x13; break; case WIDX_CLEAR_SCENERY: map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; gCurrentToolId = 0x0C; break; } diff --git a/src/windows/track_place.c b/src/windows/track_place.c index 558a08da84..ac39c338ed 100644 --- a/src/windows/track_place.c +++ b/src/windows/track_place.c @@ -184,7 +184,8 @@ static void window_track_place_close(rct_window *w) window_track_place_clear_provisional(); viewport_set_visibility(0); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~6; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; hide_gridlines(); SafeFree(_window_track_place_mini_preview); track_design_dispose(_trackDesign); @@ -245,7 +246,9 @@ static void window_track_place_toolupdate(rct_window* w, int widgetIndex, int x, uint8 rideIndex; map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~7; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; // Get the tool map position sub_68A15E(x, y, &mapX, &mapY, NULL, NULL); @@ -305,7 +308,9 @@ static void window_track_place_tooldown(rct_window* w, int widgetIndex, int x, i window_track_place_clear_provisional(); map_invalidate_map_selection_tiles(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~7; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; sub_68A15E(x, y, &mapX, &mapY, NULL, NULL); if (mapX == (short)0x8000) diff --git a/src/world/footpath.c b/src/world/footpath.c index e987db5982..e1a64bad3f 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -620,7 +620,7 @@ void footpath_provisional_update() if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_SHOW_ARROW) { gFootpathProvisionalFlags &= ~PROVISIONAL_PATH_FLAG_SHOW_ARROW; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint8) &= ~(1 << 2); + gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; map_invalidate_tile_full( gFootpathConstructFromPosition.x, gFootpathConstructFromPosition.y diff --git a/src/world/map.c b/src/world/map.c index 957ebc0c50..b1689ceda6 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -52,6 +52,13 @@ const rct_xy16 TileDirectionDelta[] = { { -32, -32 } }; +uint16 gMapSelectFlags; +uint16 gMapSelectType; +rct_xy16 gMapSelectPositionA; +rct_xy16 gMapSelectPositionB; +rct_xyz16 gMapSelectArrowPosition; +uint8 gMapSelectArrowDirection; + rct_map_element *gMapElements = (rct_map_element*)RCT2_ADDRESS_MAP_ELEMENTS; rct_map_element **gMapElementTilePointers = (rct_map_element**)RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS; rct_xy16 *gMapSelectionTiles = (rct_xy16*)0x009DE596; @@ -3826,7 +3833,7 @@ void map_invalidate_map_selection_tiles() { rct_xy16 *position; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 1))) + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)) return; for (position = gMapSelectionTiles; position->x != -1; position++) @@ -3875,13 +3882,13 @@ void map_invalidate_selection_rect() { int x0, y0, x1, y1, left, right, top, bottom; - if (!(RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) & (1 << 0))) + if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) return; - x0 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, sint16) + 16; - y0 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, sint16) + 16; - x1 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, sint16) + 16; - y1 = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, sint16) + 16; + x0 = gMapSelectPositionA.x + 16; + y0 = gMapSelectPositionA.y + 16; + x1 = gMapSelectPositionB.x + 16; + y1 = gMapSelectPositionB.y + 16; map_get_bounding_box(x0, y0, x1, y1, &left, &top, &right, &bottom); left -= 32; right += 32; diff --git a/src/world/map.h b/src/world/map.h index c30ed59fe0..9e5532a279 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -265,6 +265,30 @@ typedef struct rct2_peep_spawn { uint8 direction; } rct2_peep_spawn; +enum { + MAP_SELECT_FLAG_ENABLE = 1 << 0, + MAP_SELECT_FLAG_ENABLE_CONSTRUCT = 1 << 1, + MAP_SELECT_FLAG_ENABLE_ARROW = 1 << 2, + MAP_SELECT_FLAG_GREEN = 1 << 3, +}; + +enum { + MAP_SELECT_TYPE_CORNER_0, + MAP_SELECT_TYPE_CORNER_1, + MAP_SELECT_TYPE_CORNER_2, + MAP_SELECT_TYPE_CORNER_3, + MAP_SELECT_TYPE_FULL, + MAP_SELECT_TYPE_5, + MAP_SELECT_TYPE_QUARTER_0, + MAP_SELECT_TYPE_QUARTER_1, + MAP_SELECT_TYPE_QUARTER_2, + MAP_SELECT_TYPE_QUARTER_3, + MAP_SELECT_TYPE_EDGE_0, + MAP_SELECT_TYPE_EDGE_1, + MAP_SELECT_TYPE_EDGE_2, + MAP_SELECT_TYPE_EDGE_3, +}; + extern const rct_xy16 TileDirectionDelta[]; #define gWidePathTileLoopX RCT2_GLOBAL(0x013CE774, uint16) @@ -276,6 +300,13 @@ extern const rct_xy16 TileDirectionDelta[]; #define gMapSize RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16) #define gMapSizeMaxXY RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, sint16) +extern uint16 gMapSelectFlags; +extern uint16 gMapSelectType; +extern rct_xy16 gMapSelectPositionA; +extern rct_xy16 gMapSelectPositionB; +extern rct_xyz16 gMapSelectArrowPosition; +extern uint8 gMapSelectArrowDirection; + extern rct_map_element *gMapElements; extern rct_map_element **gMapElementTilePointers;