From c0e2a5c7beea46ef6c92e5765c253f142b8b5e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 30 Oct 2015 11:00:35 +0100 Subject: [PATCH] Add get_current_rotation function and DEBUG_LEVEL macros --- CMakeLists.txt | 8 +- src/audio/audio.c | 2 +- src/diagnostic.h | 43 +++++++++++ src/interface/screenshot.c | 2 +- src/interface/viewport.c | 72 +++++++++++------- src/interface/viewport.h | 2 + src/interface/window.c | 4 +- src/ride/ride.c | 4 +- src/ride/track.c | 2 +- src/ride/track_paint.c | 130 ++++++++++++++++---------------- src/scenario.c | 4 +- src/windows/footpath.c | 6 +- src/windows/guest.c | 2 +- src/windows/map.c | 18 ++--- src/windows/maze_construction.c | 2 +- src/windows/park.c | 2 +- src/windows/ride.c | 2 +- src/windows/ride_construction.c | 2 +- src/windows/staff.c | 2 +- src/windows/top_toolbar.c | 8 +- src/windows/track_place.c | 6 +- src/windows/viewport.c | 4 +- src/world/map.c | 10 +-- src/world/map_animation.c | 5 +- src/world/money_effect.c | 4 +- src/world/sprite.c | 2 +- 26 files changed, 209 insertions(+), 139 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20a9c6416a..3664d6f6a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,10 @@ else (DISABLE_NETWORK) endif (WIN32) endif (DISABLE_NETWORK) +set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in range 0–3.") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG=${DEBUG_LEVEL}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}") + # include lib include_directories("lib/") # add source files @@ -57,8 +61,8 @@ file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "lib/argparse/*.c" "lib/cu if (UNIX) # force 32bit build for now and set necessary flags to compile code as is - set(CMAKE_C_FLAGS "-m32 -std=gnu99") - set(CMAKE_CXX_FLAGS "-m32 -std=gnu++11") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -std=gnu99") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -std=gnu++11") set(CMAKE_SHARED_LINKER_FLAGS "-m32") set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) endif (UNIX) diff --git a/src/audio/audio.c b/src/audio/audio.c index ac90544cc4..02f67c061e 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -108,7 +108,7 @@ int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z) } sint16 rx; sint16 ry; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 0: rx = y - x; ry = ((y + x) / 2) - z; diff --git a/src/diagnostic.h b/src/diagnostic.h index 556ff98324..00c03bd154 100644 --- a/src/diagnostic.h +++ b/src/diagnostic.h @@ -30,6 +30,49 @@ enum { DIAGNOSTIC_LEVEL_COUNT }; +/* + * Compile-time debug levels. + * + * When compiling, just add -DDEBUG={0,1,2,3} (where 0 means disabled) + * Regardless of DEBUG value, a set of defines will be created: + * - DEBUG_LEVEL_1 + * - DEBUG_LEVEL_2 + * - DEBUG_LEVEL_3 + * which you would use like so: + * + * #if DEBUG_LEVEL_1 + * (... some debug code ...) + * #if DEBUG_LEVEL_2 + * (... more debug code ...) + * #endif // DEBUG_LEVEL_2 + * #endif // DEBUG_LEVEL_1 + * + * The defines will be either 0 or 1 so compiler will complain about undefined + * macro if you forget to include the file, which would not happen if we were + * only checking whether the define is present or not. + */ + +#if defined(DEBUG) + #if DEBUG > 0 + #define DEBUG_LEVEL_1 1 + #if DEBUG > 1 + #define DEBUG_LEVEL_2 1 + #if DEBUG > 2 + #define DEBUG_LEVEL_3 1 + #else + #define DEBUG_LEVEL_3 0 + #endif // DEBUG > 2 + #else + #define DEBUG_LEVEL_3 0 + #define DEBUG_LEVEL_2 0 + #endif // DEBUG > 1 + #endif // DEBUG > 0 +#else + #define DEBUG_LEVEL_3 0 + #define DEBUG_LEVEL_2 0 + #define DEBUG_LEVEL_1 0 +#endif // defined(DEBUG) + extern int _log_levels[DIAGNOSTIC_LEVEL_COUNT]; void diagnostic_log(int diagnosticLevel, const char *format, ...); diff --git a/src/interface/screenshot.c b/src/interface/screenshot.c index 9ac0c16546..79c1ae2ccf 100644 --- a/src/interface/screenshot.c +++ b/src/interface/screenshot.c @@ -357,7 +357,7 @@ bool screenshot_write_png(rct_drawpixelinfo *dpi, const char *path) void screenshot_giant() { - int originalRotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + int originalRotation = get_current_rotation(); int originalZoom = 0; rct_window *mainWindow = window_get_main(); diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 20d5a872f8..f10ba0d4d0 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -140,7 +140,7 @@ void center_2d_coordinates(int x, int y, int z, int* out_x, int* out_y, rct_view .z = z }; - rct_xy16 coord_2d = coordinate_3d_to_2d(&coord_3d, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + rct_xy16 coord_2d = coordinate_3d_to_2d(&coord_3d, get_current_rotation()); // If the start location was invalid // propagate the invalid location to the output. @@ -259,7 +259,7 @@ void sub_689174(sint16* x, sint16* y, sint16 *z) if (pos.x > max && pos.y > max) { int x_corr[] = { -1, 1, 1, -1 }; int y_corr[] = { -1, -1, 1, 1 }; - uint32 rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + uint32 rotation = get_current_rotation(); pos.x += x_corr[rotation] * height; pos.y += y_corr[rotation] * height; } @@ -816,7 +816,7 @@ void sub_688485(){ /* rct2: 0x006874B0, 0x00687618, 0x0068778C, 0x00687902, 0x0098199C */ int sub_98199C(sint8 al, sint8 ah, int image_id, sint8 cl, int height, sint16 length_y, sint16 length_x, uint32 rotation){ - RCT2_CALLPROC_X(RCT2_ADDRESS(0x98199C, uint32_t)[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)], + RCT2_CALLPROC_X(RCT2_ADDRESS(0x98199C, uint32_t)[get_current_rotation()], al | (ah << 8), image_id, cl, @@ -858,7 +858,7 @@ int sub_98197C(sint8 al, sint8 ah, int image_id, sint8 cl, int height, sint16 le }; switch (rotation) { - case 0: + case 0: rotate_map_coordinates(&coord_3d.x, &coord_3d.y, 0); break; case 1: @@ -1008,7 +1008,7 @@ void viewport_vehicle_paint_setup(rct_vehicle *vehicle, int imageDirection) RCT2_GLOBAL(0x9DEA52, uint16) = 0; RCT2_GLOBAL(0x9DEA54, uint16) = 0; RCT2_GLOBAL(0x9DEA56, uint16) = z + 2; - sub_98197C(0, 0, ebx, 0, z, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 0, ebx, 0, z, 1, 1, get_current_rotation()); return; } @@ -1087,7 +1087,7 @@ void viewport_litter_paint_setup(rct_litter *litter, int imageDirection) RCT2_GLOBAL(0x9DEA54, uint16) = 0xFFFC; RCT2_GLOBAL(0x9DEA56, uint16) = litter->z + 2; - sub_98197C(0, 0xFF, image_id, 0, litter->z, 4, 4, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 0xFF, image_id, 0, litter->z, 4, 4, get_current_rotation()); } @@ -1125,7 +1125,7 @@ void sprite_paint_setup(uint16 eax, uint16 ecx){ if (dpi->x + dpi->width <= spr->unknown.sprite_left)continue; if (spr->unknown.sprite_right <= dpi->x)continue; - int image_direction = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + int image_direction = get_current_rotation(); image_direction <<= 3; image_direction += spr->unknown.sprite_direction; image_direction &= 0x1F; @@ -1230,7 +1230,7 @@ void viewport_ride_entrance_exit_paint_setup(uint8 direction, int height, rct_ma sint16 lengthY = (direction & 1) ? 28 : 2; sint16 lengthX = (direction & 1) ? 2 : 28; - sub_98197C(0, ah, image_id, 0, height, lengthY, lengthX, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, ah, image_id, 0, height, lengthY, lengthX, get_current_rotation()); if (transparant_image_id){ if (is_exit){ @@ -1252,7 +1252,7 @@ void viewport_ride_entrance_exit_paint_setup(uint8 direction, int height, rct_ma RCT2_GLOBAL(0x009DEA54, uint16) = (direction & 1) ? 2 : 28; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, ah, image_id, 0, height, lengthY, lengthX, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, ah, image_id, 0, height, lengthY, lengthX, get_current_rotation()); if (transparant_image_id){ transparant_image_id += 4; @@ -1367,7 +1367,7 @@ void viewport_park_entrance_paint_setup(uint8 direction, int height, rct_map_ele RCT2_GLOBAL(0x009DEA54, uint16) = 2; RCT2_GLOBAL(0x009DEA56, sint16) = height; - sub_98197C(0, 0, image_id, 0, height, 0x1C, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0, image_id, 0, height, 0x1C, 32, get_current_rotation()); entrance = (rct_entrance_type*)object_entry_groups[OBJECT_TYPE_PARK_ENTRANCE].chunks[0]; image_id = (entrance->image_id + direction * 3) | ghost_id; @@ -1376,7 +1376,7 @@ void viewport_park_entrance_paint_setup(uint8 direction, int height, rct_map_ele RCT2_GLOBAL(0x009DEA54, uint16) = 2; RCT2_GLOBAL(0x009DEA56, sint16) = height + 32; - sub_98197C(0, 0x2F, image_id, 0, height, 0x1C, 0x1C, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0x2F, image_id, 0, height, 0x1C, 0x1C, get_current_rotation()); if ((direction + 1) & (1 << 1)) break; @@ -1423,7 +1423,7 @@ void viewport_park_entrance_paint_setup(uint8 direction, int height, rct_map_ele RCT2_GLOBAL(0x009DEA54, uint16) = 3; RCT2_GLOBAL(0x009DEA56, sint16) = height; - sub_98197C(0, 0x4F, image_id, 0, height, di, 0x1A, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0x4F, image_id, 0, height, di, 0x1A, get_current_rotation()); break; } @@ -1491,7 +1491,7 @@ void viewport_track_paint_setup(uint8 direction, int height, rct_map_element *ma RCT2_GLOBAL(0x009DEA52, uint16) = 1000; RCT2_GLOBAL(0x009DEA54, uint16) = 1000; RCT2_GLOBAL(0x009DEA56, uint16) = 2047; - sub_98197C(16, 0, ebx, 16, height + ax + 3, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(16, 0, ebx, 16, height + ax + 3, 1, 1, get_current_rotation()); } } @@ -1571,7 +1571,7 @@ void viewport_entrance_paint_setup(uint8 direction, int height, rct_map_element* RCT2_GLOBAL(0x009DEA56, sint16) = z; RCT2_GLOBAL(0x009DEA56, uint16) += 64; - sub_98197C(16, 0, image_id, 16, height, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(16, 0, image_id, 16, height, 1, 1, get_current_rotation()); } } @@ -1620,11 +1620,11 @@ void viewport_banner_paint_setup(uint8 direction, int height, rct_map_element* m 0x20000000; } - sub_98197C(0, 0x15, image_id, 0, height, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0x15, image_id, 0, height, 1, 1, get_current_rotation()); RCT2_GLOBAL(0x9DEA52, uint32) = RCT2_ADDRESS(0x98D888, uint32)[direction * 2]; image_id++; - sub_98197C(0, 0x15, image_id, 0, height, 1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)); + sub_98197C(0, 0x15, image_id, 0, height, 1, 1, get_current_rotation()); // Opposite direction direction ^= 2; @@ -1678,7 +1678,7 @@ static void sub_68B3FB(int x, int y) rct_map_element* map_element = map_get_first_element_at(x >> 5, y >> 5); int dx = 0; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)) { + switch (get_current_rotation()) { case 0: dx = x + y; break; @@ -1702,7 +1702,7 @@ static void sub_68B3FB(int x, int y) RCT2_GLOBAL(0x9DE56A, uint16) == RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) && RCT2_GLOBAL(0x9DE56E, uint16) == RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16)){ uint8 arrowRotation = - (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + (get_current_rotation() + (RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) & 3)) & 3; uint32 imageId = @@ -1719,7 +1719,7 @@ static void sub_68B3FB(int x, int y) RCT2_GLOBAL(0x9DEA54, uint16) = 0; RCT2_GLOBAL(0x9DEA56, uint16) = arrowZ + 18; - sub_98197C(0, 0xFF, imageId, 0, arrowZ, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 0xFF, imageId, 0, arrowZ, 32, 32, get_current_rotation()); } int bx = dx + 52; @@ -1753,7 +1753,7 @@ static void sub_68B3FB(int x, int y) RCT2_GLOBAL(0x9DE56C, sint16) = y; RCT2_GLOBAL(0x9DE57C, uint16) = 0; do { - int direction = (map_element->type + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)) & MAP_ELEMENT_DIRECTION_MASK; + int direction = (map_element->type + get_current_rotation()) & MAP_ELEMENT_DIRECTION_MASK; int height = map_element->base_height * 8; uint32_t dword_9DE574 = RCT2_GLOBAL(0x9DE574, uint32_t); @@ -1806,7 +1806,7 @@ static void viewport_blank_tiles_paint_setup(int x, int y) rct_drawpixelinfo *dpi = RCT2_GLOBAL(0x0140E9A8, rct_drawpixelinfo*); int dx; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)) { + switch (get_current_rotation()) { case 0: dx = x + y; break; @@ -1835,14 +1835,14 @@ static void viewport_blank_tiles_paint_setup(int x, int y) RCT2_GLOBAL(0x9DE56C, sint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8_t) = VIEWPORT_INTERACTION_ITEM_NONE; RCT2_CALLPROC_X( - (int)RCT2_ADDRESS(0x98196C, uint32_t*)[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)], + (int)RCT2_ADDRESS(0x98196C, uint32_t*)[get_current_rotation()], 0xFF00, 3123, y & 0xFF00, 16, 32, 32, - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t) + get_current_rotation() ); } @@ -1925,7 +1925,7 @@ void viewport_paint_setup() uint16 num_vertical_quadrants = (dpi->height + 2128) >> 5; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)){ + switch (get_current_rotation()){ case 0: mapTile.x = mapTile.y - half_x; mapTile.y = mapTile.y + half_x; @@ -2074,7 +2074,7 @@ void sub_688217_helper(uint16 ax, uint8 flag) if (!(ps_next->var_1B & (1 << 1))) continue; int yes = 0; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 0: if (my_some_y >= ps_next->some_x && my_other_y >= ps_next->attached_y && my_other_x >= ps_next->attached_x && !(my_some_x < ps_next->some_y && my_attached_y < ps_next->other_y && my_attached_x < ps_next->other_x)) @@ -2339,7 +2339,7 @@ rct_xy16 screen_coord_to_viewport_coord(rct_viewport *viewport, uint16 x, uint16 rct_xy16 viewport_coord_to_map_coord(int x, int y, int z) { rct_xy16 ret; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 0: ret.x = -x / 2 + y + z; ret.y = x / 2 + y + z; @@ -2854,3 +2854,23 @@ void screen_get_map_xy_side_with_z(sint16 screenX, sint16 screenY, sint16 z, sin *mapX = floor2(*mapX, 32); *mapY = floor2(*mapY, 32); } + +/** + * Get current viewport rotation. + * + * If an invalid rotation is detected and DEBUG_LEVEL_1 is enabled, an error + * will be reported. + * + * @returns rotation in range 0-3 (inclusive) + */ +int get_current_rotation() +{ + int rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + int rotation_masked = rotation & 3; +#if DEBUG_LEVEL_1 + if (rotation != rotation_masked) { + log_error("Found wrong rotation %d! Will return %d instead.", rotation, rotation_masked); + } +#endif // DEBUG_LEVEL_1 + return rotation_masked; +} diff --git a/src/interface/viewport.h b/src/interface/viewport.h index d416a96494..16b585f82e 100644 --- a/src/interface/viewport.h +++ b/src/interface/viewport.h @@ -144,4 +144,6 @@ void screen_get_map_xy_quadrant_with_z(sint16 screenX, sint16 screenY, sint16 z, void screen_get_map_xy_side(sint16 screenX, sint16 screenY, sint16 *mapX, sint16 *mapY, uint8 *side); void screen_get_map_xy_side_with_z(sint16 screenX, sint16 screenY, sint16 z, sint16 *mapX, sint16 *mapY, uint8 *side); +int get_current_rotation(); + #endif diff --git a/src/interface/window.c b/src/interface/window.c index e40ca34f86..90865813d7 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -1301,7 +1301,7 @@ void window_scroll_to_location(rct_window *w, int x, int y, int z) } } - rct_xy16 map_coordinate = coordinate_3d_to_2d(&location_3d, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)); + rct_xy16 map_coordinate = coordinate_3d_to_2d(&location_3d, get_current_rotation()); int i = 0; if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO)) { @@ -1389,7 +1389,7 @@ void window_rotate_camera(rct_window *w, int direction) z = map_element_height(x, y); } - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) = (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + direction) % 4; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) = (get_current_rotation() + direction) % 4; int new_x, new_y; center_2d_coordinates(x, y, z, &new_x, &new_y, viewport); diff --git a/src/ride/ride.c b/src/ride/ride.c index dc97e233ce..5f3c4d5c15 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -1986,7 +1986,7 @@ static void ride_spiral_slide_update(rct_ride *ride) z = ride->station_heights[i]; mapElement = ride_get_station_start_track_element(ride, i); - int rotation = ((mapElement->type & 3) << 2) | RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + int rotation = ((mapElement->type & 3) << 2) | get_current_rotation(); x *= 32; y *= 32; x += RCT2_GLOBAL(0x0098DDB8 + (rotation * 4), sint16); @@ -3231,7 +3231,7 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint RCT2_GLOBAL(0x009AF47C, uint16) = sampleRate; sint16 v11; sint16 v12; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 0: v11 = y - x; v12 = ((y + x) / 2) - z; diff --git a/src/ride/track.c b/src/ride/track.c index 290bb7ae46..8d12c0a5f2 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -716,7 +716,7 @@ int backup_map(){ *(uint16*)(backup_info + 4) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16); *(uint16*)(backup_info + 6) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, uint16); *(uint16*)(backup_info + 8) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16); - *(uint32*)(backup_info + 10) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + *(uint32*)(backup_info + 10) = get_current_rotation(); return 1; } diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 5f6f0c2f2a..5d6920f3ec 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -182,7 +182,7 @@ void top_spin_paint_tile_0(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; @@ -265,7 +265,7 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction // Left back bottom support image_id += 572; - sub_98197C(al, 90, image_id, cl, height, lengthY, lengthX, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(al, 90, image_id, cl, height, lengthY, lengthX, get_current_rotation()); image_id = RCT2_GLOBAL(0x00F441A0, uint32); if (image_id == 0x20000000) { @@ -290,10 +290,10 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction sub_98199C( al, 90, - image_id, - cl, - height, - lengthY, + image_id, + cl, + height, + lengthY, lengthX, 0); @@ -352,18 +352,18 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction sub_98199C( (sint8)seatCoords.x, - 90, - image_id, + 90, + image_id, (sint8)seatCoords.y, - seatCoords.z, - lengthY, + seatCoords.z, + lengthY, lengthX, 0); rct_drawpixelinfo* dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*); if (dpi->zoom_level < 2 && vehicle != NULL && vehicle->num_peeps != 0) { - image_id = - (vehicle->peep_tshirt_colours[0] << 19) | + image_id = + (vehicle->peep_tshirt_colours[0] << 19) | (vehicle->peep_tshirt_colours[1] << 24); image_id += seatImageId; image_id += 0xA0000000; @@ -403,7 +403,7 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction sub_98199C((sint8)seatCoords.x, 90, image_id, (sint8)seatCoords.y, seatCoords.z, lengthY, lengthX, 0); } - } + } image_id = RCT2_GLOBAL(0x00F441A0, uint32); if (image_id == 0x20000000) { @@ -420,12 +420,12 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction image_id += 476; sub_98199C( - al, + al, 90, - image_id, - cl, - height, - lengthY, + image_id, + cl, + height, + lengthY, lengthX, 0); @@ -445,10 +445,10 @@ void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 direction sub_98199C( al, 90, - image_id, - cl, - height, - lengthY, + image_id, + cl, + height, + lengthY, lengthX, 0); @@ -466,12 +466,12 @@ void top_spin_paint_tile_1(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((x / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + uint16 entranceLoc = + ((x / 32) + loc_7667AE[get_current_rotation()].x) | + (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -487,8 +487,8 @@ void top_spin_paint_tile_1(uint8 rideIndex, uint8 trackSequence, uint8 direction } entranceLoc = - ((x / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AC[get_current_rotation()].x) | + (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -499,9 +499,9 @@ void top_spin_paint_tile_1(uint8 rideIndex, uint8 trackSequence, uint8 direction sub_98199C(0, 7, image_id, 0, height, 32, 1, 0); } - + top_spin_paint_vehicle(32, 32, rideIndex, direction, height, mapElement); - + RCT2_GLOBAL(0x141E9B4, uint16) = height + 2; RCT2_GLOBAL(0x141E9B6, uint16) = 32; RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; @@ -532,12 +532,12 @@ void top_spin_paint_tile_2(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AC[get_current_rotation()].x) | + (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -579,12 +579,12 @@ void top_spin_paint_tile_4(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AE[get_current_rotation()].x) | + (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -626,12 +626,12 @@ void top_spin_paint_tile_3(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AC[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AC[get_current_rotation()].x) | + (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -647,8 +647,8 @@ void top_spin_paint_tile_3(uint8 rideIndex, uint8 trackSequence, uint8 direction } entranceLoc = - ((x / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].x) | - (((y / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].y) << 8); + ((x / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].x) | + (((y / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -657,7 +657,7 @@ void top_spin_paint_tile_3(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 30; RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 1, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 1, 32, get_current_rotation()); } top_spin_paint_vehicle(32, -32, rideIndex, direction, height, mapElement); @@ -692,15 +692,15 @@ void top_spin_paint_tile_5(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); uint16 entranceLoc = - ((x / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].x) | - (((y / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].y) << 8); + ((x / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].x) | + (((y / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); @@ -708,7 +708,7 @@ void top_spin_paint_tile_5(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 30; RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 1, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 1, 32, get_current_rotation()); } top_spin_paint_vehicle(0, -32, rideIndex, direction, height, mapElement); @@ -740,12 +740,12 @@ void top_spin_paint_tile_6(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].x) | - (((y / 32) + loc_7667AE[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)].y) << 8); + ((x / 32) + loc_7667AE[get_current_rotation()].x) | + (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); @@ -761,8 +761,8 @@ void top_spin_paint_tile_6(uint8 rideIndex, uint8 trackSequence, uint8 direction } entranceLoc = - ((x / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].x) | - (((y / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].y) << 8); + ((x / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].x) | + (((y / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -771,7 +771,7 @@ void top_spin_paint_tile_6(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA54, uint16) = 2; RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 32, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 32, 1, get_current_rotation()); } top_spin_paint_vehicle(-32, 32, rideIndex, direction, height, mapElement); @@ -806,15 +806,15 @@ void top_spin_paint_tile_7(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); uint16 entranceLoc = - ((x / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].x) | - (((y / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].y) << 8); + ((x / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].x) | + (((y / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -823,12 +823,12 @@ void top_spin_paint_tile_7(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 29; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; - sub_98197C(0, 7, image_id, 0, height, 28, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 28, 1, get_current_rotation()); } entranceLoc = - ((x / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].x) | - (((y / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].y) << 8); + ((x / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].x) | + (((y / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -837,7 +837,7 @@ void top_spin_paint_tile_7(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 29; RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; - sub_98197C(0, 7, image_id, 0, height, 1, 28, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 1, 28, get_current_rotation()); } top_spin_paint_vehicle(-32, -32, rideIndex, direction, height, mapElement); @@ -872,15 +872,15 @@ void top_spin_paint_tile_8(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA52, uint16) = 0; RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height; - sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 1, image_id, 0, height, 32, 32, get_current_rotation()); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = GET_RIDE(rideIndex); uint16 entranceLoc = - ((x / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].x) | - (((y / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].y) << 8); + ((x / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].x) | + (((y / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { @@ -889,7 +889,7 @@ void top_spin_paint_tile_8(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA54, uint16) = 0; RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 32, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + sub_98197C(0, 7, image_id, 0, height, 32, 1, get_current_rotation()); } top_spin_paint_vehicle(-32, 0, rideIndex, direction, height, mapElement); @@ -910,7 +910,7 @@ void top_spin_paint_tile_8(uint8 rideIndex, uint8 trackSequence, uint8 direction } } -/* rct2: 0x007667BC +/* rct2: 0x007667BC */ void top_spin_paint_setup_rot_0(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { switch (trackSequence) @@ -1052,4 +1052,4 @@ void top_spin_paint_setup_rot_3(uint8 rideIndex, uint8 trackSequence, uint8 dire break; } return; -} \ No newline at end of file +} diff --git a/src/scenario.c b/src/scenario.c index d250db71cd..597c0d452e 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -991,7 +991,7 @@ int scenario_save(SDL_RWops* rw, int flags) viewX = viewport->view_width / 2 + viewport->view_x; viewY = viewport->view_height / 2 + viewport->view_y; viewZoom = viewport->zoom; - viewRotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + viewRotation = get_current_rotation(); } else { viewX = 0; viewY = 0; @@ -1064,7 +1064,7 @@ int scenario_save_network(SDL_RWops* rw) viewX = viewport->view_width / 2 + viewport->view_x; viewY = viewport->view_height / 2 + viewport->view_y; viewZoom = viewport->zoom; - viewRotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + viewRotation = get_current_rotation(); } else { viewX = 0; viewY = 0; diff --git a/src/windows/footpath.c b/src/windows/footpath.c index adcd719edb..51309bc1ac 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -537,7 +537,7 @@ static void window_footpath_paint(rct_window *w, rct_drawpixelinfo *dpi) if (!(w->disabled_widgets & (1 << WIDX_CONSTRUCT))) { // Get construction image - image = (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) % 4; + image = (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) + get_current_rotation()) % 4; if (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_SLOPE, uint8) == 2) image += 4; else if (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_SLOPE, uint8) == 6) @@ -618,7 +618,7 @@ static void window_footpath_show_footpath_types_dialog(rct_window *w, rct_widget static void window_footpath_mousedown_direction(int direction) { footpath_provisional_update(); - RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) = (direction - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) & 3; + RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) = (direction - get_current_rotation()) & 3; _window_footpath_cost = MONEY32_UNDEFINED; window_footpath_set_enabled_and_pressed_widgets(); } @@ -1012,7 +1012,7 @@ static void window_footpath_set_enabled_and_pressed_widgets() pressedWidgets = w->pressed_widgets & 0xFFFF887F; disabledWidgets = 0; - currentRotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + currentRotation = get_current_rotation(); if (RCT2_GLOBAL(RCT2_ADDRESS_PATH_CONSTRUCTION_MODE, uint8) >= PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL) { // Set pressed directional widget direction = (RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8) + currentRotation) & 3; diff --git a/src/windows/guest.c b/src/windows/guest.c index f460e0329d..f0e18f6739 100644 --- a/src/windows/guest.c +++ b/src/windows/guest.c @@ -732,7 +732,7 @@ void window_guest_viewport_init(rct_window* w){ focus.sprite.type |= VIEWPORT_FOCUS_TYPE_SPRITE | VIEWPORT_FOCUS_TYPE_COORDINATE; focus.sprite.pad_486 &= 0xFFFF; } - focus.coordinate.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + focus.coordinate.rotation = get_current_rotation(); } uint16 viewport_flags; diff --git a/src/windows/map.c b/src/windows/map.c index 13b7f1bf63..22179e1b98 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -224,7 +224,7 @@ void window_map_open() window_init_scroll_widgets(w); - w->map.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint16); + w->map.rotation = get_current_rotation(); window_map_init_map(); RCT2_GLOBAL(0x00F64F05, uint8) = 0; @@ -394,8 +394,8 @@ static void window_map_mousedown(int widgetIndex, rct_window *w, rct_widget *wid */ static void window_map_update(rct_window *w) { - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) != w->map.rotation) { - w->map.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + if (get_current_rotation() != w->map.rotation) { + w->map.rotation = get_current_rotation(); window_map_init_map(); window_map_center_on_view_point(); } @@ -885,7 +885,7 @@ static void window_map_center_on_view_point() if (w_map == NULL) return; - rct_xy16 offset = MiniMapOffsets[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) & 3]; + rct_xy16 offset = MiniMapOffsets[get_current_rotation()]; // calculate center view point of viewport and transform it to minimap coordinates @@ -975,7 +975,7 @@ static void window_map_transform_to_map_coords(sint16 *left, sint16 *top) sint16 x = *left, y = *top; sint16 temp; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) { + switch (get_current_rotation()) { case 3: temp = x; x = y; @@ -1097,7 +1097,7 @@ static void window_map_paint_hud_rectangle(rct_drawpixelinfo *dpi) if (viewport == NULL) return; - rct_xy16 offset = MiniMapOffsets[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) & 3]; + rct_xy16 offset = MiniMapOffsets[get_current_rotation()]; sint16 left = (viewport->view_x >> 5) + offset.x; sint16 right = ((viewport->view_x + viewport->view_width) >> 5) + offset.x; sint16 top = (viewport->view_y >> 4) + offset.y; @@ -1176,7 +1176,7 @@ void sub_666EEF(int x, int y, sint16 *mapX, sint16 *mapY, sint16 *mapZ, int *dir } } } - *direction = (window_scenery_rotation - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) & 3; + *direction = (window_scenery_rotation - get_current_rotation()) & 3; } /** @@ -1604,7 +1604,7 @@ static void map_window_set_pixels(rct_window *w) int x, y, dx, dy; destination = (uint16*)((RCT2_GLOBAL(0x00F1AD6C, uint32) * 511) + RCT2_GLOBAL(RCT2_ADDRESS_MAP_IMAGE_DATA, uint32) + 255); - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) { + switch (get_current_rotation()) { case 0: x = RCT2_GLOBAL(0x00F1AD6C, uint32) * 32; y = 0; @@ -1665,7 +1665,7 @@ static void map_window_screen_to_map(int screenX, int screenY, int *mapX, int *m screenY = ((screenY + 8) ) / 2; x = (screenY - screenX) * 32; y = (screenX + screenY) * 32; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) & 3) { + switch (get_current_rotation()) { case 0: *mapX = x; *mapY = y; diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index 5dc90c56f6..f815181b43 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -225,7 +225,7 @@ static void window_maze_construction_mouseup(rct_window *w, int widgetIndex) case WIDX_MAZE_DIRECTION_SE: case WIDX_MAZE_DIRECTION_SW: window_maze_construction_construct( - ((widgetIndex - WIDX_MAZE_DIRECTION_NW) - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) & 3 + ((widgetIndex - WIDX_MAZE_DIRECTION_NW) - get_current_rotation()) & 3 ); break; } diff --git a/src/windows/park.c b/src/windows/park.c index 8f761e9f31..6b32b71bed 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -1064,7 +1064,7 @@ static void window_park_init_viewport(rct_window *w) x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, sint16)[i] + 16; y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, sint16)[i] + 16; z = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Z, sint16)[i] + 32; - r = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + r = get_current_rotation(); xy = 0x40000000 | (y << 16) | x; zr = (z << 16) | (r << 8); diff --git a/src/windows/ride.c b/src/windows/ride.c index e3dadfd032..4032b18685 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -1488,7 +1488,7 @@ static void window_ride_init_viewport(rct_window *w) focus.sprite.sprite_id = -1; focus.coordinate.zoom = 0; - focus.coordinate.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + focus.coordinate.rotation = get_current_rotation(); if (eax >= 0 && eax < ride->num_vehicles && ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK){ diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index 7ebe6f8527..d81b6e7c0f 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -2152,7 +2152,7 @@ static void window_ride_construction_draw_track_piece( z -= bx; int start_x = x; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t)) { + switch (get_current_rotation()) { case 0: x = y - x; y = (y + start_x) / 2 - z; diff --git a/src/windows/staff.c b/src/windows/staff.c index d47741ee1c..9d4f41b29a 100644 --- a/src/windows/staff.c +++ b/src/windows/staff.c @@ -1188,7 +1188,7 @@ void window_staff_viewport_init(rct_window* w){ } else{ focus.type |= VIEWPORT_FOCUS_TYPE_SPRITE | VIEWPORT_FOCUS_TYPE_COORDINATE; - focus.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + focus.rotation = get_current_rotation(); } uint16 viewport_flags; diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 3eb2511f76..154019aabe 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1117,7 +1117,7 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin rotation = scenario_rand() & 0xFF; } - rotation -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + rotation -= get_current_rotation(); rotation &= 0x3; // Also places it in lower but think thats for clobering @@ -1195,7 +1195,7 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin rotation = scenario_rand() & 0xFF; } - rotation -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + rotation -= get_current_rotation(); rotation &= 0x3; // Also places it in lower but think thats for clobering @@ -1344,7 +1344,7 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin *grid_y &= 0xFFE0; uint8 rotation = window_scenery_rotation; - rotation -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + rotation -= get_current_rotation(); rotation &= 0x3; *parameter_1 = (rotation << 8); @@ -1371,7 +1371,7 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin } uint8 rotation = window_scenery_rotation; - rotation -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + rotation -= get_current_rotation(); rotation &= 0x3; sint16 z = map_element->base_height; diff --git a/src/windows/track_place.c b/src/windows/track_place.c index 9d73faee30..12eddb7ee8 100644 --- a/src/windows/track_place.c +++ b/src/windows/track_place.c @@ -150,7 +150,7 @@ static void window_track_place_draw_mini_preview() if (track->type != RIDE_TYPE_MAZE) { #pragma region Track - rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); + rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + get_current_rotation(); trackElement = RCT2_ADDRESS(0x009D821B, rct_track_element); while (trackElement->type != 255) { @@ -249,7 +249,7 @@ static void window_track_place_draw_mini_preview() } else { #pragma region Maze - rotation = (RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)) & 3; + rotation = (RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) + get_current_rotation()) & 3; mazeElement = RCT2_ADDRESS(0x009D821B, rct_maze_element); while (mazeElement->all != 0) { x = mazeElement->x * 32; @@ -393,7 +393,7 @@ void window_track_place_open() show_gridlines(); _window_track_place_last_cost = MONEY32_UNDEFINED; _window_track_place_last_x = 0xFFFF; - RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = (-RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) + 2) & 3; + RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8) = (-get_current_rotation() + 2) & 3; window_track_place_draw_mini_preview(); } diff --git a/src/windows/viewport.c b/src/windows/viewport.c index 166759a19a..9a09015bb0 100644 --- a/src/windows/viewport.c +++ b/src/windows/viewport.c @@ -119,7 +119,7 @@ void window_viewport_open() (1 << WIDX_LOCATE); w->number = _viewportNumber++; - rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32); + rotation = get_current_rotation(); // Create viewport viewport_create(w, w->x, w->y, w->width, w->height, 0, 128 * 32, 128 * 32, 0, 1, -1); @@ -245,4 +245,4 @@ static void window_viewport_paint(rct_window *w, rct_drawpixelinfo *dpi) // Draw viewport if (w->viewport != NULL) window_draw_viewport(dpi, w); -} \ No newline at end of file +} diff --git a/src/world/map.c b/src/world/map.c index fbc12b811a..81919c5ff4 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -3539,28 +3539,28 @@ void map_get_bounding_box(int ax, int ay, int bx, int by, int *left, int *top, i int x, y; x = ax; y = ay; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); *left = x; *right = x; *top = y; *bottom = y; x = bx; y = ay; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); if (x < *left) *left = x; if (x > *right) *right = x; if (y > *bottom) *bottom = y; if (y < *top) *top = y; x = bx; y = by; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); if (x < *left) *left = x; if (x > *right) *right = x; if (y > *bottom) *bottom = y; if (y < *top) *top = y; x = ax; y = by; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); if (x < *left) *left = x; if (x > *right) *right = x; if (y > *bottom) *bottom = y; @@ -4431,7 +4431,7 @@ void map_invalidate_tile_under_zoom(int x, int y, int z0, int z1, int maxZoom) x += 16; y += 16; - translate_3d_to_2d(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32), &x, &y); + translate_3d_to_2d(get_current_rotation(), &x, &y); x1 = x - 32; y1 = y - 32 - z1; diff --git a/src/world/map_animation.c b/src/world/map_animation.c index b68a6a9e52..0ce1832451 100644 --- a/src/world/map_animation.c +++ b/src/world/map_animation.c @@ -22,6 +22,7 @@ #include "../ride/ride.h" #include "../ride/ride_data.h" #include "../ride/track.h" +#include "../interface/viewport.h" #include "map_animation.h" #include "map.h" #include "scenery.h" @@ -150,7 +151,7 @@ static bool map_animation_invalidate_queue_banner(int x, int y, int baseZ) if (!(mapElement->properties.path.type & PATH_FLAG_QUEUE_BANNER)) continue; - int direction = ((mapElement->type >> 6) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) & 3; + int direction = ((mapElement->type >> 6) + get_current_rotation()) & 3; if (direction == MAP_ELEMENT_DIRECTION_NORTH || direction == MAP_ELEMENT_DIRECTION_EAST) { baseZ = mapElement->base_height * 8; map_invalidate_tile_zoom1(x, y, baseZ + 16, baseZ + 30); @@ -542,4 +543,4 @@ static const map_animation_invalidate_event_handler _animatedObjectEventHandlers map_animation_invalidate_large_scenery, map_animation_invalidate_wall_unknown, map_animation_invalidate_wall -}; \ No newline at end of file +}; diff --git a/src/world/money_effect.c b/src/world/money_effect.c index 132d6293a3..b33565531f 100644 --- a/src/world/money_effect.c +++ b/src/world/money_effect.c @@ -96,8 +96,8 @@ void money_effect_update(rct_money_effect *moneyEffect) return; moneyEffect->move_delay = 0; - int x = moneyEffect->x + _moneyEffectMoveOffset[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)].x; - int y = moneyEffect->y + _moneyEffectMoveOffset[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)].y; + int x = moneyEffect->x + _moneyEffectMoveOffset[get_current_rotation()].x; + int y = moneyEffect->y + _moneyEffectMoveOffset[get_current_rotation()].y; int z = moneyEffect->z; sprite_move(x, y, z, (rct_sprite*)moneyEffect); diff --git a/src/world/sprite.c b/src/world/sprite.c index 51098ca2b4..3be296848e 100644 --- a/src/world/sprite.c +++ b/src/world/sprite.c @@ -451,7 +451,7 @@ void sprite_move(sint16 x, sint16 y, sint16 z, rct_sprite* sprite){ return; } sint16 new_x = x, new_y = y, start_x = x; - switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)){ + switch (get_current_rotation()){ case 0: new_x = new_y - new_x; new_y = (new_y + start_x) / 2 - z;