diff --git a/src/paint/map_element/entrance.c b/src/paint/map_element/entrance.c index fb76af8c38..d3d39bc9c7 100644 --- a/src/paint/map_element/entrance.c +++ b/src/paint/map_element/entrance.c @@ -24,6 +24,7 @@ #include "../../ride/ride_data.h" #include "../../world/entrance.h" #include "../../world/footpath.h" +#include "map_element.h" /** * @@ -103,14 +104,10 @@ void ride_entrance_exit_paint(uint8 direction, int height, rct_map_element* map_ sub_98199C(transparant_image_id, 0, 0, lengthX, lengthY, ah, height, (direction & 1) ? 28 : 2, (direction & 1) ? 2 : 28, height, get_current_rotation()); } - uint32 eax = 0xFFFF0600 | ((height / 16) & 0xFF); - if (direction & 1){ - RCT2_ADDRESS(0x009E30B6, uint32)[RCT2_GLOBAL(0x141F56B, uint8) / 2] = eax; - RCT2_GLOBAL(0x141F56B, uint8)++; - } - else{ - RCT2_ADDRESS(0x009E3138, uint32)[RCT2_GLOBAL(0x141F56A, uint8) / 2] = eax; - RCT2_GLOBAL(0x141F56A, uint8)++; + if (direction & 1) { + paint_util_push_tunnel_right(height, TUNNEL_6); + } else { + paint_util_push_tunnel_left(height, TUNNEL_6); } if (!is_exit && @@ -152,21 +149,10 @@ void ride_entrance_exit_paint(uint8 direction, int height, rct_map_element* map_ } wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); height += is_exit ? 40 : 56; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height){ - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } + paint_util_set_general_support_height(height, 0x20); } /** @@ -249,21 +235,8 @@ void park_entrance_paint(uint8 direction, int height, rct_map_element* map_eleme } wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 80; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height){ - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 80, 0x20); } /** diff --git a/src/paint/map_element/map_element.c b/src/paint/map_element/map_element.c index 03514d24b3..bd7fb42e19 100644 --- a/src/paint/map_element/map_element.c +++ b/src/paint/map_element/map_element.c @@ -36,6 +36,8 @@ static void blank_tiles_paint(int x, int y); static void sub_68B3FB(int x, int y); +const int SEGMENTS_ALL = SEGMENT_B4 | SEGMENT_B8 | SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4; + /** * * rct2: 0x0068B35F @@ -48,17 +50,8 @@ void map_element_paint_setup(int x, int y) x >= 32 && y >= 32 ) { - RCT2_GLOBAL(0x0141E9B4, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9B8, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9BC, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C0, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C4, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C8, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9CC, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D0, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D4, uint32) = 0xFFFF; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = -1; - RCT2_GLOBAL(0x0141E9DA, sint16) = 0; + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_force_set_general_support_height(-1, 0); RCT2_GLOBAL(0x0141E9DC, uint32) = 0xFFFF; sub_68B3FB(x, y); @@ -79,17 +72,8 @@ void sub_68B2B7(int x, int y) x >= 32 && y >= 32 ) { - RCT2_GLOBAL(0x0141E9B4, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9B8, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9BC, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C0, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C4, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C8, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9CC, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D0, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D4, uint32) = 0xFFFF; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = -1; - RCT2_GLOBAL(0x0141E9DA, uint16) = 0; + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_force_set_general_support_height(-1, 0); RCT2_GLOBAL(0x0141E9DC, uint32) = 0xFFFF; RCT2_GLOBAL(0x0141E9DB, uint8) |= 2; @@ -277,3 +261,56 @@ static void sub_68B3FB(int x, int y) RCT2_GLOBAL(0x9DE574, uint32_t) = dword_9DE574; } while (!map_element_is_last_for_tile(map_element++)); } + +void paint_util_push_tunnel_left(uint16 height, uint8 type) +{ + uint32 eax = 0xFFFF0000 | ((height / 16) & 0xFF) | type << 8; + RCT2_ADDRESS(0x009E3138, uint32)[RCT2_GLOBAL(0x141F56A, uint8) / 2] = eax; + RCT2_GLOBAL(0x141F56A, uint8)++; +} + +void paint_util_push_tunnel_right(uint16 height, uint8 type) +{ + uint32 eax = 0xFFFF0000 | ((height / 16) & 0xFF) | type << 8; + RCT2_ADDRESS(0x009E30B6, uint32)[RCT2_GLOBAL(0x141F56B, uint8) / 2] = eax; + RCT2_GLOBAL(0x141F56B, uint8)++; +} + +void paint_util_set_general_support_height(sint16 height, uint8 slope) +{ + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) >= height) { + return; + } + + paint_util_force_set_general_support_height(height, slope); +} + +void paint_util_force_set_general_support_height(sint16 height, uint8 slope) +{ + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; + RCT2_GLOBAL(0x141E9DA, uint8) = slope; +} + +const uint16 segment_offsets[9] = { + SEGMENT_B4, + SEGMENT_B8, + SEGMENT_BC, + SEGMENT_C0, + SEGMENT_C4, + SEGMENT_C8, + SEGMENT_CC, + SEGMENT_D0, + SEGMENT_D4 +}; + +void paint_util_set_segment_support_height(int segments, uint16 height, uint8 slope) +{ + for (int s = 0; s < 9; s++) { + if (segments & segment_offsets[s]) { + RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = height; + if (height != 0xFFFF) { + RCT2_GLOBAL(0x0141E9B6 + s * 4, uint8) = slope; + } + } + } +} \ No newline at end of file diff --git a/src/paint/map_element/map_element.h b/src/paint/map_element/map_element.h index 1cf1a1c07b..f129a3ccdf 100644 --- a/src/paint/map_element/map_element.h +++ b/src/paint/map_element/map_element.h @@ -20,6 +20,45 @@ #include "../../common.h" #include "../../world/map.h" +typedef enum edge +{ + EDGE_NE = (1 << 0), + EDGE_SE = (1 << 1), + EDGE_SW = (1 << 2), + EDGE_NW = (1 << 3), + EDGE_BOTTOMLEFT = EDGE_SW, + EDGE_BOTTOMRIGHT = EDGE_SE, + EDGE_TOPLEFT = EDGE_NW, + EDGE_TOPRIGHT = EDGE_NE +} edge; + +enum +{ + SEGMENT_B4 = (1 << 0), // 0 + SEGMENT_CC = (1 << 1), // 6 + SEGMENT_BC = (1 << 2), // 2 + SEGMENT_D4 = (1 << 3), // 8 + SEGMENT_C0 = (1 << 4), // 3 + SEGMENT_D0 = (1 << 5), // 7 + SEGMENT_B8 = (1 << 6), // 1 + SEGMENT_C8 = (1 << 7), // 5 + SEGMENT_C4 = (1 << 8), // 4 +}; + +extern const int SEGMENTS_ALL; + +enum +{ + TUNNEL_6 = 6, +}; + +void paint_util_push_tunnel_left(uint16 height, uint8 type); +void paint_util_push_tunnel_right(uint16 height, uint8 type); + +void paint_util_set_general_support_height(sint16 height, uint8 slope); +void paint_util_force_set_general_support_height(sint16 height, uint8 slope); +void paint_util_set_segment_support_height(int segments, uint16 height, uint8 slope); + void map_element_paint_setup(int x, int y); void entrance_paint(uint8 direction, int height, rct_map_element* map_element); diff --git a/src/paint/map_element/surface.c b/src/paint/map_element/surface.c index ef395635db..f624565363 100644 --- a/src/paint/map_element/surface.c +++ b/src/paint/map_element/surface.c @@ -21,6 +21,7 @@ #include "../../config.h" #include "../../peep/staff.h" #include "../../world/map.h" +#include "map_element.h" const uint8 byte_97B444[] = { 0, 2, 1, 3, 8, 10, 9, 11, 4, 6, @@ -303,20 +304,6 @@ const uint32 dword_97B898[][2] = { {SPR_TERRAIN_GRASS_MOWED, SPR_TERRAIN_GRASS_MOWED_GRID} }; - -enum -{ - SEGMENT_B4 = (1 << 0), - SEGMENT_B8 = (1 << 1), - SEGMENT_BC = (1 << 2), - SEGMENT_C0 = (1 << 3), - SEGMENT_C4 = (1 << 4), - SEGMENT_C8 = (1 << 5), - SEGMENT_CC = (1 << 6), - SEGMENT_D0 = (1 << 7), - SEGMENT_D4 = (1 << 8), -}; - typedef struct tile_descriptor tile_descriptor; struct tile_descriptor @@ -327,22 +314,6 @@ struct tile_descriptor corner_height corner_heights; }; -static void paint_setup_set_segment_support_height(int flags, uint16 height, uint8 segment_flags) -{ - for (int s = 0; s < 9; s++) { - if (flags & (1 << s)) { - RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = height; - RCT2_GLOBAL(0x0141E9B6 + s * 4, uint8) = segment_flags; - } - } -} - -static void paint_setup_set_support_height(uint16 height, uint8 segment_flags) -{ - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, uint16) = height; - RCT2_GLOBAL(0x0141E9DA, uint8) = segment_flags; -} - uint8 viewport_surface_paint_setup_get_relative_slope(rct_map_element * mapElement, int rotation) { uint8 slope = mapElement->properties.surface.slope; @@ -354,15 +325,6 @@ uint8 viewport_surface_paint_setup_get_relative_slope(rct_map_element * mapEleme return ebx | di; } -enum edge -{ - EDGE_BOTTOMLEFT, - EDGE_BOTTOMRIGHT, - EDGE_TOPLEFT, - EDGE_TOPRIGHT -}; - - typedef struct viewport_surface_paint_struct_0 { uint32 var_00; uint32 var_04; @@ -1552,12 +1514,12 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) // 00 00 00 // 00 00 // 00 - paint_setup_set_segment_support_height( + paint_util_set_segment_support_height( SEGMENT_B4 | SEGMENT_B8 | SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, height, 0 ); - paint_setup_set_support_height(height, 0); + paint_util_force_set_general_support_height(height, 0); break; case 1: @@ -1567,11 +1529,11 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) // 01 01 01 // 1B 1B // 1B - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC, height, 0); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height, 1); - paint_setup_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 6, 0x1B); - paint_setup_set_segment_support_height(SEGMENT_C0, height + 6 + 6, 0x1B); - paint_setup_set_support_height(height, 1); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC, height, 0); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height, 1); + paint_util_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 6, 0x1B); + paint_util_set_segment_support_height(SEGMENT_C0, height + 6 + 6, 0x1B); + paint_util_force_set_general_support_height(height, 1); break; case 2: @@ -1581,11 +1543,11 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) // 17 02 00 // 17 00 // 02 - paint_setup_set_segment_support_height(SEGMENT_BC | SEGMENT_CC | SEGMENT_D4, height, 0); - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height, 2); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 6, 0x17); - paint_setup_set_segment_support_height(SEGMENT_B8, height + 6 + 6, 0x17); - paint_setup_set_support_height(height, 2); + paint_util_set_segment_support_height(SEGMENT_BC | SEGMENT_CC | SEGMENT_D4, height, 0); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height, 2); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 6, 0x17); + paint_util_set_segment_support_height(SEGMENT_B8, height + 6 + 6, 0x17); + paint_util_force_set_general_support_height(height, 2); break; case 3: @@ -1595,10 +1557,10 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) // 03 03 03 // 03 03 // 03 - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_CC | SEGMENT_BC, height + 2, 3); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_C4 | SEGMENT_D4, height + 2 + 6, 3); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_D0 | SEGMENT_C0, height + 2 + 6 + 6, 3); - paint_setup_set_support_height(height, 3); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_CC | SEGMENT_BC, height + 2, 3); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_C4 | SEGMENT_D4, height + 2 + 6, 3); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_D0 | SEGMENT_C0, height + 2 + 6 + 6, 3); + paint_util_force_set_general_support_height(height, 3); break; case 4: @@ -1608,11 +1570,11 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) // 04 04 04 // 00 00 // 00 - paint_setup_set_segment_support_height(SEGMENT_C0 | SEGMENT_D0 | SEGMENT_D4, height, 0); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height, 4); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 6, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_B4, height + 6 + 6, 0x1E); - paint_setup_set_support_height(height, 4); + paint_util_set_segment_support_height(SEGMENT_C0 | SEGMENT_D0 | SEGMENT_D4, height, 0); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height, 4); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 6, 0x1E); + paint_util_set_segment_support_height(SEGMENT_B4, height + 6 + 6, 0x1E); + paint_util_force_set_general_support_height(height, 4); break; case 5: @@ -1622,12 +1584,12 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) // 05 05 05 ░░ ░░ ░░ // 1B 1B ▒▒ ▒▒ // 1B ▓▓ - paint_setup_set_segment_support_height(SEGMENT_B4, height + 6 + 6, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 6, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height, 5); - paint_setup_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 6, 0x1B); - paint_setup_set_segment_support_height(SEGMENT_C0, height + 6 + 6, 0x1B); - paint_setup_set_support_height(height, 5); + paint_util_set_segment_support_height(SEGMENT_B4, height + 6 + 6, 0x1E); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 6, 0x1E); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height, 5); + paint_util_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 6, 0x1B); + paint_util_set_segment_support_height(SEGMENT_C0, height + 6 + 6, 0x1B); + paint_util_force_set_general_support_height(height, 5); break; case 6: @@ -1637,10 +1599,10 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) // 06 06 06 ▓▓ ▒▒ ░░ // 06 06 ▒▒ ░░ // 06 ░░ - paint_setup_set_segment_support_height(SEGMENT_BC | SEGMENT_D4 | SEGMENT_C0, height + 2, 6); - paint_setup_set_segment_support_height(SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC, height + 2 + 6, 6); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_C8 | SEGMENT_B4, height + 2 + 6 + 6, 6); - paint_setup_set_support_height(height, 6); + paint_util_set_segment_support_height(SEGMENT_BC | SEGMENT_D4 | SEGMENT_C0, height + 2, 6); + paint_util_set_segment_support_height(SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC, height + 2 + 6, 6); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_C8 | SEGMENT_B4, height + 2 + 6 + 6, 6); + paint_util_force_set_general_support_height(height, 6); break; case 7: @@ -1650,113 +1612,113 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) // 00 07 17 ▓▓ ▓▓ ░░ // 00 17 ▓▓ ▒▒ // 07 ▓▓ - paint_setup_set_segment_support_height(SEGMENT_BC, height + 4, 0x17); - paint_setup_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 4 + 6, 0x17); - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height + 4 + 6 + 6, 7); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0 | SEGMENT_B8, height + 4 + 6 + 6, 0); - paint_setup_set_support_height(height, 7); + paint_util_set_segment_support_height(SEGMENT_BC, height + 4, 0x17); + paint_util_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 4 + 6, 0x17); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height + 4 + 6 + 6, 7); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0 | SEGMENT_B8, height + 4 + 6 + 6, 0); + paint_util_force_set_general_support_height(height, 7); break; case 8: // loc_6620D8 - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_C8 | SEGMENT_D0, height, 0); - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height, 8); - paint_setup_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 6, 0x1D); - paint_setup_set_segment_support_height(SEGMENT_BC, height + 6 + 6, 0x1D); - paint_setup_set_support_height(height, 8); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_C8 | SEGMENT_D0, height, 0); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height, 8); + paint_util_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 6, 0x1D); + paint_util_set_segment_support_height(SEGMENT_BC, height + 6 + 6, 0x1D); + paint_util_force_set_general_support_height(height, 8); break; case 9: // loc_66216D - paint_setup_set_support_height(height, 9); - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_B8, height + 2, 9); - paint_setup_set_segment_support_height(SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC, height + 2 + 6, 9); - paint_setup_set_segment_support_height(SEGMENT_C0 | SEGMENT_D4 | SEGMENT_BC, height + 2 + 6 + 6, 9); + paint_util_force_set_general_support_height(height, 9); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_B8, height + 2, 9); + paint_util_set_segment_support_height(SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC, height + 2 + 6, 9); + paint_util_set_segment_support_height(SEGMENT_C0 | SEGMENT_D4 | SEGMENT_BC, height + 2 + 6 + 6, 9); break; case 10: // loc_662206 - paint_setup_set_support_height(height, 0xA); - paint_setup_set_segment_support_height(SEGMENT_B8, height + 6 + 6, 0x17); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 6, 0x17); - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height, 0xA); - paint_setup_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 6, 0x1D); - paint_setup_set_segment_support_height(SEGMENT_BC, height + 6 + 6, 0x1D); + paint_util_force_set_general_support_height(height, 0xA); + paint_util_set_segment_support_height(SEGMENT_B8, height + 6 + 6, 0x17); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 6, 0x17); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height, 0xA); + paint_util_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 6, 0x1D); + paint_util_set_segment_support_height(SEGMENT_BC, height + 6 + 6, 0x1D); break; case 11: // loc_66229B - paint_setup_set_support_height(height, 0xB); - paint_setup_set_segment_support_height(SEGMENT_B4, height + 4, 0x1B); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 4 + 6, 0x1B); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height + 4 + 6 + 6, 0xB); - paint_setup_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4 | SEGMENT_C0, height + 4 + 6 + 6, 0); + paint_util_force_set_general_support_height(height, 0xB); + paint_util_set_segment_support_height(SEGMENT_B4, height + 4, 0x1B); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 4 + 6, 0x1B); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height + 4 + 6 + 6, 0xB); + paint_util_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4 | SEGMENT_C0, height + 4 + 6 + 6, 0); break; case 12: // loc_662334 - paint_setup_set_support_height(height, 0xC); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_D0 | SEGMENT_C0, height + 2, 0xC); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_C4 | SEGMENT_D4, height + 2 + 6, 0xC); - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_CC | SEGMENT_BC, height + 2 + 6 + 6, 0xC); + paint_util_force_set_general_support_height(height, 0xC); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_D0 | SEGMENT_C0, height + 2, 0xC); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_C4 | SEGMENT_D4, height + 2 + 6, 0xC); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_CC | SEGMENT_BC, height + 2 + 6 + 6, 0xC); break; case 13: // loc_6623CD - paint_setup_set_support_height(height, 0xD); - paint_setup_set_segment_support_height(SEGMENT_B8, height + 4, 0x1D); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 4 + 6, 0x1D); - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height + 4 + 6 + 6, 0xD); - paint_setup_set_segment_support_height(SEGMENT_CC | SEGMENT_D4 | SEGMENT_BC, height + 4 + 6 + 6, 0); + paint_util_force_set_general_support_height(height, 0xD); + paint_util_set_segment_support_height(SEGMENT_B8, height + 4, 0x1D); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 4 + 6, 0x1D); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height + 4 + 6 + 6, 0xD); + paint_util_set_segment_support_height(SEGMENT_CC | SEGMENT_D4 | SEGMENT_BC, height + 4 + 6 + 6, 0); break; case 14: // loc_662466 - paint_setup_set_support_height(height, 0xE); - paint_setup_set_segment_support_height(SEGMENT_C0, height + 4, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 4 + 6, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height + 4 + 6 + 6, 0xE); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC | SEGMENT_B4, height + 4 + 6 + 6, 0); + paint_util_force_set_general_support_height(height, 0xE); + paint_util_set_segment_support_height(SEGMENT_C0, height + 4, 0x1E); + paint_util_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 4 + 6, 0x1E); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height + 4 + 6 + 6, 0xE); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC | SEGMENT_B4, height + 4 + 6 + 6, 0); break; case 23: // loc_6624FF - paint_setup_set_support_height(height, 0x17); - paint_setup_set_segment_support_height(SEGMENT_BC, height + 4, 0x17); - paint_setup_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 4 + 6, 0x17); - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height + 4 + 6 + 6, 0x17); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 4 + 6 + 6 + 6, 0x17); - paint_setup_set_segment_support_height(SEGMENT_B8, height + 4 + 6 + 6 + 6 + 6, 0x17); + paint_util_force_set_general_support_height(height, 0x17); + paint_util_set_segment_support_height(SEGMENT_BC, height + 4, 0x17); + paint_util_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 4 + 6, 0x17); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height + 4 + 6 + 6, 0x17); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 4 + 6 + 6 + 6, 0x17); + paint_util_set_segment_support_height(SEGMENT_B8, height + 4 + 6 + 6 + 6 + 6, 0x17); break; case 27: // loc_6625A0 - paint_setup_set_support_height(height, 0x1B); - paint_setup_set_segment_support_height(SEGMENT_B4, height + 4, 0x1B); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 4 + 6, 0x1B); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height + 4 + 6 + 6, 0x1B); - paint_setup_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 4 + 6 + 6 + 6, 0x1B); - paint_setup_set_segment_support_height(SEGMENT_C0, height + 4 + 6 + 6 + 6 + 6, 0x1B); + paint_util_force_set_general_support_height(height, 0x1B); + paint_util_set_segment_support_height(SEGMENT_B4, height + 4, 0x1B); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 4 + 6, 0x1B); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height + 4 + 6 + 6, 0x1B); + paint_util_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 4 + 6 + 6 + 6, 0x1B); + paint_util_set_segment_support_height(SEGMENT_C0, height + 4 + 6 + 6 + 6 + 6, 0x1B); break; case 29: // loc_662641 - paint_setup_set_support_height(height, 0x1D); - paint_setup_set_segment_support_height(SEGMENT_B8, height + 4, 0x1D); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 4 + 6, 0x1D); - paint_setup_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height + 4 + 6 + 6, 0x1D); - paint_setup_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 4 + 6 + 6 + 6, 0x1D); - paint_setup_set_segment_support_height(SEGMENT_BC, height + 4 + 6 + 6 + 6 + 6, 0x1D); + paint_util_force_set_general_support_height(height, 0x1D); + paint_util_set_segment_support_height(SEGMENT_B8, height + 4, 0x1D); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_D0, height + 4 + 6, 0x1D); + paint_util_set_segment_support_height(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C0, height + 4 + 6 + 6, 0x1D); + paint_util_set_segment_support_height(SEGMENT_CC | SEGMENT_D4, height + 4 + 6 + 6 + 6, 0x1D); + paint_util_set_segment_support_height(SEGMENT_BC, height + 4 + 6 + 6 + 6 + 6, 0x1D); break; case 30: // loc_6626E2 - paint_setup_set_support_height(height, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_C0, height + 4, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 4 + 6, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height + 4 + 6 + 6, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 4 + 6 + 6 + 6, 0x1E); - paint_setup_set_segment_support_height(SEGMENT_B4, height + 4 + 6 + 6 + 6 + 6, 0x1E); + paint_util_force_set_general_support_height(height, 0x1E); + paint_util_set_segment_support_height(SEGMENT_C0, height + 4, 0x1E); + paint_util_set_segment_support_height(SEGMENT_D0 | SEGMENT_D4, height + 4 + 6, 0x1E); + paint_util_set_segment_support_height(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_BC, height + 4 + 6 + 6, 0x1E); + paint_util_set_segment_support_height(SEGMENT_C8 | SEGMENT_CC, height + 4 + 6 + 6 + 6, 0x1E); + paint_util_set_segment_support_height(SEGMENT_B4, height + 4 + 6 + 6 + 6 + 6, 0x1E); break; } diff --git a/src/ride/gentle/crooked_house.c b/src/ride/gentle/crooked_house.c index cf41704390..fccde822b1 100644 --- a/src/ride/gentle/crooked_house.c +++ b/src/ride/gentle/crooked_house.c @@ -19,109 +19,6 @@ #include "../../paint/supports.h" #include "../track_paint.h" -/* rct2: 0x007667AE */ -static rct_xy16 loc_7667AE[] = { - { .x = 0, .y = -1 }, - { .x = 1, .y = 0 }, - { .x = 0, .y = 1}, - { .x = -1, .y = 0 }, -}; - -/* rct2: 0x007667AC */ -static rct_xy16 loc_7667AC[] = { - { .x = -1, .y = 0 }, - { .x = 0, .y = -1 }, - { .x = 1, .y = 0 }, - { .x = 0, .y = 1 }, -}; - -static void crooked_house_paint_supports(uint8 direction, int height) { - wooden_a_supports_paint_setup((direction & 1), 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); -} - -static void crooked_house_paint_floor(int height, int floor_sprite_id) { - uint32 image_id = floor_sprite_id | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 31, 31, 1, height, 0, 0, height, get_current_rotation()); -} - -static void crooked_house_paint_support_heights() { - RCT2_GLOBAL(0x0141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D4, uint16) = 0xFFFF; -} - -enum { - SEGMENT_B4 = (1 << 0), - SEGMENT_B8 = (1 << 1), - SEGMENT_BC = (1 << 2), - SEGMENT_C0 = (1 << 3), - SEGMENT_C4 = (1 << 4), - SEGMENT_C8 = (1 << 5), - SEGMENT_CC = (1 << 6), - SEGMENT_D0 = (1 << 7), - SEGMENT_D4 = (1 << 8), -}; - -static void crooked_house_paint_support_height(int flags, uint16 height, uint8 segment_flags) { - for (int s = 0; s < 9; s++) { - if (flags & (1 << s)) { - RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = height; - RCT2_GLOBAL(0x0141E9B6 + s * 4, uint8) = segment_flags; - } - } -} - -static void crooked_house_paint_max_height(int height) { - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x00141E9DA, uint8) = 0x20; - } -} - -static void crooked_house_fence_top_left(rct_ride *ride, int height, rct_map_element *mapElement) { - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint8 entranceId = (mapElement->properties.entrance.index & 0x70) >> 4; - - uint16 entranceLoc = - ((x / 32) + loc_7667AE[get_current_rotation()].x) | - (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - uint32 image_id = 22141 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); - } -} - -static void crooked_house_fence_top_right(rct_ride *ride, int height, rct_map_element *mapElement) { - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint8 entranceId = (mapElement->properties.entrance.index & 0x70) >> 4; - - uint16 entranceLoc = - ((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) { - uint32 image_id = 22138 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0, 2, height + 2, get_current_rotation()); - } -} - -static void crooked_house_fence_bottom_right(rct_ride *ride, int height, rct_map_element *mapElement) { - uint32 image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, get_current_rotation()); -} - -static void crooked_house_fence_bottom_left(rct_ride *ride, int height, rct_map_element *mapElement) { - uint32 image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 30, 0, height + 2, get_current_rotation()); -} - typedef struct rct_crooked_house_bound_box { sint16 offset_x; sint16 offset_y; @@ -176,177 +73,51 @@ static void sub_88ABA4(uint8 direction, uint8 x_offset, uint8 y_offset, uint32 s sub_98197C(image_id, x_offset, y_offset, boundBox.length_x, boundBox.length_y, 127, height + 3, boundBox.offset_x, boundBox.offset_y, height + 3, get_current_rotation()); } -static void crooked_house_paint_setup_889F08(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_supports(direction, height); - crooked_house_paint_floor(height, 22137); - crooked_house_paint_support_heights(); - crooked_house_paint_max_height(height + 128); -} +static void paint_crooked_house(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + trackSequence = track_map_3x3[direction][trackSequence]; -static void crooked_house_paint_setup_889FCC(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_supports(direction, height); - crooked_house_paint_floor(height, 22137); + int edges = edges_3x3[trackSequence]; + rct_ride * ride = get_ride(rideIndex); + rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; - rct_ride *ride = get_ride(rideIndex); - crooked_house_fence_top_left(ride, height, mapElement); - crooked_house_fence_top_right(ride, height, mapElement); + wooden_a_supports_paint_setup((direction & 1), 0, height, RCT2_GLOBAL(0x00F441A0, uint32_t), NULL); - height += 2; - crooked_house_paint_support_heights(); - crooked_house_paint_support_height(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC, height, 0x20); + track_paint_util_paint_floor(edges, RCT2_GLOBAL(0x00F44198, uint32), height, floorSpritesCork, get_current_rotation()); - crooked_house_paint_max_height(height + 126); -} + track_paint_util_paint_fences(edges, position, mapElement, ride, RCT2_GLOBAL(0x00F441A0, uint32), height, fenceSpritesRope, get_current_rotation()); -static void crooked_house_paint_setup_88A1D0(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_supports(direction, height); - crooked_house_paint_floor(height, 22136); + switch(trackSequence) { + case 3: sub_88ABA4(direction, 32, 224, 0, height); break; + case 5: sub_88ABA4(direction, 0, 224, 1, height); break; + case 6: sub_88ABA4(direction, 224, 32, 4, height); break; + case 7: sub_88ABA4(direction, 224, 224, 2, height); break; + //case 8: sub_88ABA4(rideIndex, 224, 0, 3, height); break; + } - rct_ride *ride = get_ride(rideIndex); - crooked_house_fence_top_right(ride, height, mapElement); - crooked_house_fence_bottom_right(ride, height, mapElement); + int cornerSegments = 0; + switch (trackSequence) { + case 1: + // top + cornerSegments = SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC; + break; + case 3: + // right + cornerSegments = SEGMENT_CC | SEGMENT_BC | SEGMENT_D4; + break; + case 6: + // left + cornerSegments = SEGMENT_C8 | SEGMENT_B8 | SEGMENT_D0; + break; + case 7: + // bottom + cornerSegments = SEGMENT_D0 | SEGMENT_C0 | SEGMENT_D4; + break; + } - sub_88ABA4(direction, 32, 224, 0, height); - - height += 2; - crooked_house_paint_support_heights(); - crooked_house_paint_support_height(SEGMENT_CC | SEGMENT_BC | SEGMENT_D4, height, 0x20); - - crooked_house_paint_max_height(height + 126); -} - -static void crooked_house_paint_setup_88A392(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_supports(direction, height); - crooked_house_paint_floor(height, 22135); - - rct_ride *ride = get_ride(rideIndex); - crooked_house_fence_top_left(ride, height, mapElement); - crooked_house_fence_bottom_left(ride, height, mapElement); - - sub_88ABA4(direction, 224, 32, 4, height); - - height += 2; - crooked_house_paint_support_heights(); - crooked_house_paint_support_height(SEGMENT_C8 | SEGMENT_B8 | SEGMENT_D0, height, 0x20); - - crooked_house_paint_max_height(height + 126); -} - -static void crooked_house_paint_setup_88A554(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_supports(direction, height); - crooked_house_paint_floor(height, 22134); - - rct_ride *ride = get_ride(rideIndex); - crooked_house_fence_bottom_left(ride, height, mapElement); - crooked_house_fence_bottom_right(ride, height, mapElement); - - sub_88ABA4(direction, 224, 224, 2, height); - - height += 2; - crooked_house_paint_support_heights(); - crooked_house_paint_support_height(SEGMENT_D0 | SEGMENT_C0 | SEGMENT_D4, height, 0x20); - - crooked_house_paint_max_height(height + 126); -} - - -static void crooked_house_paint_setup_88A97C(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_supports(direction, height); - crooked_house_paint_floor(height, 22136); - - rct_ride *ride = get_ride(rideIndex); - crooked_house_fence_bottom_right(ride, height, mapElement); - - sub_88ABA4(direction, 0, 224, 1, height); - - crooked_house_paint_support_heights(); - crooked_house_paint_max_height(height + 128); -} - -static void crooked_house_paint_setup_88A821(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_supports(direction, height); - crooked_house_paint_floor(height, 22137); - - rct_ride *ride = get_ride(rideIndex); - crooked_house_fence_top_left(ride, height, mapElement); - - crooked_house_paint_support_heights(); - crooked_house_paint_max_height(height + 128); -} - -static void crooked_house_paint_setup_88A6C6(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_supports(direction, height); - crooked_house_paint_floor(height, 22137); - - rct_ride *ride = get_ride(rideIndex); - crooked_house_fence_top_right(ride, height, mapElement); - crooked_house_paint_support_heights(); - crooked_house_paint_max_height(height + 128); -} - -// bottom center -static void crooked_house_paint_setup_88AA90(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_supports(direction, height); - crooked_house_paint_floor(height, 22135); - - rct_ride *ride = get_ride(rideIndex); - crooked_house_fence_bottom_left(ride, height, mapElement); - - //sub_88ABA4(rideIndex, 224, 0, 3, height); - - crooked_house_paint_support_heights(); - crooked_house_paint_max_height(height + 128); -} - -TRACK_PAINT_FUNCTION crooked_house_paint_setup_functions[][9] = { - { - crooked_house_paint_setup_889F08, - crooked_house_paint_setup_889FCC, - crooked_house_paint_setup_88A6C6, - crooked_house_paint_setup_88A1D0, - crooked_house_paint_setup_88A821, - crooked_house_paint_setup_88A97C, - crooked_house_paint_setup_88A392, - crooked_house_paint_setup_88A554, - crooked_house_paint_setup_88AA90, - }, - { - crooked_house_paint_setup_889F08, - crooked_house_paint_setup_88A1D0, - crooked_house_paint_setup_88A97C, - crooked_house_paint_setup_88A554, - crooked_house_paint_setup_88A6C6, - crooked_house_paint_setup_88AA90, - crooked_house_paint_setup_889FCC, - crooked_house_paint_setup_88A392, - crooked_house_paint_setup_88A821, - }, - { - crooked_house_paint_setup_889F08, - crooked_house_paint_setup_88A554, - crooked_house_paint_setup_88AA90, - crooked_house_paint_setup_88A392, - crooked_house_paint_setup_88A97C, - crooked_house_paint_setup_88A821, - crooked_house_paint_setup_88A1D0, - crooked_house_paint_setup_889FCC, - crooked_house_paint_setup_88A6C6, - }, - { - crooked_house_paint_setup_889F08, - crooked_house_paint_setup_88A392, - crooked_house_paint_setup_88A821, - crooked_house_paint_setup_889FCC, - crooked_house_paint_setup_88AA90, - crooked_house_paint_setup_88A6C6, - crooked_house_paint_setup_88A554, - crooked_house_paint_setup_88A1D0, - crooked_house_paint_setup_88A97C, - }, -}; - -static void crooked_house_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - crooked_house_paint_setup_functions[direction][trackSequence](rideIndex, trackSequence, direction, height, mapElement); + paint_util_set_segment_support_height(cornerSegments, height + 2, 0x20); + paint_util_set_segment_support_height(SEGMENTS_ALL & ~cornerSegments, 0xFFFF, 0); + paint_util_set_general_support_height(height + 128, 0x20); } TRACK_PAINT_FUNCTION get_track_paint_function_crooked_house(int trackType, int direction) { @@ -354,5 +125,5 @@ TRACK_PAINT_FUNCTION get_track_paint_function_crooked_house(int trackType, int d return NULL; } - return crooked_house_paint_setup; + return paint_crooked_house; } diff --git a/src/ride/gentle/dodgems.c b/src/ride/gentle/dodgems.c index 8211bd4df9..3610bec821 100644 --- a/src/ride/gentle/dodgems.c +++ b/src/ride/gentle/dodgems.c @@ -19,228 +19,73 @@ #include "../../paint/supports.h" #include "../track_paint.h" -/* rct2: 0x007667AE */ -static rct_xy16 loc_7667AE[] = { - { .x = 0, .y = -1 }, - { .x = 1, .y = 0 }, - { .x = 0, .y = 1}, - { .x = -1, .y = 0 }, -}; - -/* rct2: 0x007667AC */ -static rct_xy16 loc_7667AC[] = { - { .x = -1, .y = 0 }, - { .x = 0, .y = -1 }, - { .x = 1, .y = 0 }, - { .x = 0, .y = 1 }, -}; - enum { - DODGEMS_FLOOR = 21925, - DODGEMS_ROOF_FRAME = 21926, // 4 directions - DODGEMS_ROOF_GLASS = 21930, // 4 directions - DODGEMS_FENCE_TOP_RIGHT = 21934, - DODGEMS_FENCE_BOTTOM_RIGHT = 21935, - DODGEMS_FENCE_BOTTOM_LEFT = 21936, - DODGEMS_FENCE_TOP_LEFT = 21937 + SPR_DODGEMS_FLOOR = 21925, + SPR_DODGEMS_ROOF_FRAME = 21926, // 4 directions + SPR_DODGEMS_ROOF_GLASS = 21930, // 4 directions + SPR_DODGEMS_FENCE_TOP_RIGHT = 21934, + SPR_DODGEMS_FENCE_BOTTOM_RIGHT = 21935, + SPR_DODGEMS_FENCE_BOTTOM_LEFT = 21936, + SPR_DODGEMS_FENCE_TOP_LEFT = 21937 }; -static void dodgems_paint_sub_floor(uint8 direction, int height) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); +const uint32 dodgems_fence_sprites[] = { + SPR_DODGEMS_FENCE_TOP_RIGHT, + SPR_DODGEMS_FENCE_BOTTOM_RIGHT, + SPR_DODGEMS_FENCE_BOTTOM_LEFT, + SPR_DODGEMS_FENCE_TOP_LEFT +}; - image_id = DODGEMS_FLOOR | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(image_id, 0, 0, 30, 30, 1, height, 1, 1, height, get_current_rotation()); -} - -static void dodgems_paint_sub_fence_top_left(uint8 rideIndex, int height, rct_map_element *mapElement) { - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - 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); - - if (ride->entrances[entranceId] == entranceLoc || ride->exits[entranceId] == entranceLoc) { - return; - } - - uint32 image_id = DODGEMS_FENCE_TOP_LEFT | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); -} - -static void dodgems_paint_sub_fence_top_right(uint8 rideIndex, int height, rct_map_element *mapElement) { - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((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); - - if (ride->entrances[entranceId] == entranceLoc || ride->exits[entranceId] == entranceLoc) { - return; - } - - uint32 image_id = DODGEMS_FENCE_TOP_RIGHT | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 2, 0, height + 2, get_current_rotation()); -} - -static void dodgems_paint_sub_fence_bottom_right(uint8 rideIndex, int height, rct_map_element *mapElement) { - uint32 image_id = DODGEMS_FENCE_BOTTOM_RIGHT | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, get_current_rotation()); -} - -static void dodgems_paint_sub_fence_bottom_left(uint8 rideIndex, int height, rct_map_element *mapElement) { - uint32 image_id = DODGEMS_FENCE_BOTTOM_LEFT | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(image_id, 0, 0, 1, 13, 7, height, 30, 0, height + 2, get_current_rotation()); -} - -static void dodgems_paint_sub_roof(int height, int offset) { - uint32 image_id = (DODGEMS_ROOF_FRAME + offset) | RCT2_GLOBAL(0x00F44198, uint32); +static void paint_dodgems_roof(int height, int offset) +{ + uint32 image_id = (SPR_DODGEMS_ROOF_FRAME + offset) | RCT2_GLOBAL(0x00F44198, uint32); sub_98196C(image_id, 0, 0, 32, 32, 2, height, get_current_rotation()); - image_id = (DODGEMS_ROOF_GLASS + offset) | (0xF << 19) | (0x1 << 24) | 0x40000000; + image_id = (SPR_DODGEMS_ROOF_GLASS + offset) | (0xF << 19) | (0x1 << 24) | 0x40000000; paint_attach_to_previous_ps(image_id, 0, 0); } -static void dodgems_paint_setup_rot_0(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - dodgems_paint_sub_floor(direction, height); +static void paint_dodgems(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + uint8 relativeTrackSequence = track_map_4x4[direction][trackSequence]; - switch (trackSequence) { - case 0: - dodgems_paint_sub_fence_top_left(rideIndex, height, mapElement); - dodgems_paint_sub_fence_top_right(rideIndex, height, mapElement); - break; + int edges = edges_4x4[relativeTrackSequence]; + rct_ride * ride = get_ride(rideIndex); + rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; - case 1: + wooden_a_supports_paint_setup(direction & 1, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); + + uint32 imageId = SPR_DODGEMS_FLOOR | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 30, 30, 1, height, 1, 1, height, get_current_rotation()); + + track_paint_util_paint_fences(edges, position, mapElement, ride, RCT2_GLOBAL(0x00F4419C, uint32), height, dodgems_fence_sprites, get_current_rotation()); + + switch (direction) { case 2: - dodgems_paint_sub_fence_top_right(rideIndex, height, mapElement); + trackSequence = 15 - trackSequence; + // fallthrough + case 0: + if ((trackSequence / 4) & 1) { + paint_dodgems_roof(height + 30, 0); + } else { + paint_dodgems_roof(height + 30, 2); + } break; case 3: - dodgems_paint_sub_fence_top_right(rideIndex, height, mapElement); - dodgems_paint_sub_fence_bottom_right(rideIndex, height, mapElement); - break; - - case 4: - case 8: - dodgems_paint_sub_fence_top_left(rideIndex, height, mapElement); - break; - - case 7: - case 11: - dodgems_paint_sub_fence_bottom_right(rideIndex, height, mapElement); - break; - - case 12: - dodgems_paint_sub_fence_top_left(rideIndex, height, mapElement); - dodgems_paint_sub_fence_bottom_left(rideIndex, height, mapElement); - break; - - case 13: - case 14: - dodgems_paint_sub_fence_bottom_left(rideIndex, height, mapElement); - break; - - case 15: - dodgems_paint_sub_fence_bottom_right(rideIndex, height, mapElement); - dodgems_paint_sub_fence_bottom_left(rideIndex, height, mapElement); - break; - } - - height += 30; - if ((trackSequence / 4) & 1) { - dodgems_paint_sub_roof(height, 0); - } else { - dodgems_paint_sub_roof(height, 2); - } - - height += 6; - for (int i = 0; i < 9; ++i) { - RCT2_GLOBAL(0x141E9B4 + i * 4, uint16) = height; - RCT2_GLOBAL(0x141E9B6 + i * 4, uint8) = 0x20; - } - - height += 12; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 0x20; - } -} - -static void dodgems_paint_setup_rot_1(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - dodgems_paint_sub_floor(direction, height); - - switch (trackSequence) { - case 0: - dodgems_paint_sub_fence_top_right(rideIndex, height, mapElement); - dodgems_paint_sub_fence_bottom_right(rideIndex, height, mapElement); - break; - + trackSequence = 15 - trackSequence; + // fallthrough case 1: - case 2: - dodgems_paint_sub_fence_bottom_right(rideIndex, height, mapElement); - break; - - case 3: - dodgems_paint_sub_fence_bottom_right(rideIndex, height, mapElement); - dodgems_paint_sub_fence_bottom_left(rideIndex, height, mapElement); - break; - - case 4: - case 8: - dodgems_paint_sub_fence_top_right(rideIndex, height, mapElement); - break; - - case 7: - case 11: - dodgems_paint_sub_fence_bottom_left(rideIndex, height, mapElement); - break; - - case 12: - dodgems_paint_sub_fence_top_left(rideIndex, height, mapElement); - dodgems_paint_sub_fence_top_right(rideIndex, height, mapElement); - break; - - case 13: - case 14: - dodgems_paint_sub_fence_top_left(rideIndex, height, mapElement); - break; - - case 15: - dodgems_paint_sub_fence_top_left(rideIndex, height, mapElement); - dodgems_paint_sub_fence_bottom_left(rideIndex, height, mapElement); + if ((trackSequence / 4) & 1) { + paint_dodgems_roof(height + 30, 1); + } else { + paint_dodgems_roof(height + 30, 3); + } break; } - height += 30; - if ((trackSequence / 4) & 1) { - dodgems_paint_sub_roof(height, 1); - } else { - dodgems_paint_sub_roof(height, 3); - } - - height += 6; - for (int i = 0; i < 9; ++i) { - RCT2_GLOBAL(0x141E9B4 + i * 4, uint16) = height; - RCT2_GLOBAL(0x141E9B6 + i * 4, uint8) = 0x20; - } - - height += 12; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 0x20; - } -} - -static void dodgems_paint_setup_rot_2(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - dodgems_paint_setup_rot_0(rideIndex, 15 - trackSequence, direction, height, mapElement); -} - -static void dodgems_paint_setup_rot_3(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - dodgems_paint_setup_rot_1(rideIndex, 15 - trackSequence, direction, height, mapElement); + paint_util_set_segment_support_height(SEGMENTS_ALL, height + 36, 0x20); + paint_util_set_general_support_height(height + 48, 0x20); } /** @@ -251,12 +96,5 @@ TRACK_PAINT_FUNCTION get_track_paint_function_dodgems(int trackType, int directi return NULL; } - switch (direction) { - case 0: return dodgems_paint_setup_rot_0; - case 1: return dodgems_paint_setup_rot_1; - case 2: return dodgems_paint_setup_rot_2; - case 3: return dodgems_paint_setup_rot_3; - } - - return NULL; + return paint_dodgems; } diff --git a/src/ride/gentle/maze.c b/src/ride/gentle/maze.c index 68048b226a..698633e513 100644 --- a/src/ride/gentle/maze.c +++ b/src/ride/gentle/maze.c @@ -21,6 +21,7 @@ #include "../../sprites.h" #include "../../world/map.h" #include "../track_paint.h" +#include "../../paint/map_element/surface.h" enum { SPR_MAZE_BASE_HEDGE = 21938, @@ -54,19 +55,12 @@ static void maze_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 directi uint32 rotation = get_current_rotation(); // draw ground - int image_id = 2485 | RCT2_GLOBAL(0x00F441A0, uint32); + int image_id = SPR_TERRAIN_DIRT | RCT2_GLOBAL(0x00F441A0, uint32); sub_98196C(image_id, 0, 0, 32, 32, 0, height, rotation); wooden_a_supports_paint_setup(direction & 1, 0, height, RCT2_GLOBAL(0x00F441A4, uint32), NULL); - RCT2_GLOBAL(0x0141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D4, uint16) = 0xFFFF; + paint_util_set_segment_support_height(SEGMENTS_ALL & ~SEGMENT_C4, 0xFFFF, 0); int base_image_id; switch (get_ride(rideIndex)->track_colour_supports[0]) { @@ -174,15 +168,10 @@ static void maze_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 directi if (maze_entry & (1 << 2 | 1 << 6 | 1 << 10 | 1 << 14)) { sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_CENTER, 14, 14, 2, 2, 8, height, 15, 15, height + 2, rotation); - RCT2_GLOBAL(0x141E9C4, uint16) = height + 12; - RCT2_GLOBAL(0x141E9C6, uint8) = 0x20; + paint_util_set_segment_support_height(SEGMENT_C4, height + 12, 0x20); } - height += 32; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 0x20; - } + paint_util_set_general_support_height(height + 32, 0x20); } /** diff --git a/src/ride/gentle/spiral_slide.c b/src/ride/gentle/spiral_slide.c index c734e4117b..e29a4da3ab 100644 --- a/src/ride/gentle/spiral_slide.c +++ b/src/ride/gentle/spiral_slide.c @@ -19,38 +19,6 @@ #include "../../paint/supports.h" #include "../track_paint.h" -/* rct2: 0x007485D8 (same as loc_7667AC) */ -static rct_xy16 dword_7485D8[] = { - {.x = -1, .y = 0}, - {.x = 0, .y = -1}, - {.x = 1, .y = 0}, - {.x = 0, .y = 1}, -}; - -/* rct2: 0x007485D8 (same as loc_7667AC) */ -static rct_xy16 dword_7485da[] = { - {.x = 0, .y = -1}, - {.x = 1, .y = 0}, - {.x = 0, .y = 1}, - {.x = -1, .y = 0}, -}; - -/* rct2: 0x007667AE */ -static rct_xy16 loc_7667AE[] = { - { .x = 0, .y = -1 }, - { .x = 1, .y = 0 }, - { .x = 0, .y = 1}, - { .x = -1, .y = 0 }, -}; - -/* rct2: 0x007667AC */ -static rct_xy16 loc_7667AC[] = { - { .x = -1, .y = 0 }, - { .x = 0, .y = -1 }, - { .x = 1, .y = 0 }, - { .x = 0, .y = 1 }, -}; - enum { SPIRAL_SLIDE_LEFT_R0 = 20548, SPIRAL_SLIDE_CENTER_R0 = 20549, @@ -82,76 +50,8 @@ enum { SPIRAL_SLIDE_PEEP = 20568, // 46 sprites per direction }; -static void spiral_slide_paint_tile_back(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - // Base - image_id = ((direction & 1) ? SPIRAL_SLIDE_BASE_B : SPIRAL_SLIDE_BASE_A) | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); - - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - 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); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = SPIRAL_SLIDE_FENCE_TOP_LEFT | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); - } - - entranceLoc = - ((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) { - image_id = SPIRAL_SLIDE_FENCE_TOP_RIGHT | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 2, 0, height + 2, get_current_rotation()); - } - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 128; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } -} - -static void spiral_slide_paint_tile_right(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - // Base - image_id = ((direction & 1) ? SPIRAL_SLIDE_BASE_B : SPIRAL_SLIDE_BASE_A) | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); - - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((x / 32) + dword_7485D8[get_current_rotation()].x) | - (((y / 32) + dword_7485D8[get_current_rotation()].y) << 8); - - uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; - rct_ride *ride = get_ride(rideIndex); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = SPIRAL_SLIDE_FENCE_TOP_RIGHT | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 2, 0, height + 2, 0); - } - - image_id = SPIRAL_SLIDE_FENCE_BOTTOM_RIGHT | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, get_current_rotation()); //TODO 1, 32 +static void spiral_slide_paint_tile_right(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + uint32 image_id; if (direction == 0) image_id = SPIRAL_SLIDE_RIGHT_R0 | RCT2_GLOBAL(0x00F44198, uint32); if (direction == 1) image_id = SPIRAL_SLIDE_RIGHT_R1 | RCT2_GLOBAL(0x00F44198, uint32); @@ -160,48 +60,10 @@ static void spiral_slide_paint_tile_right(uint8 rideIndex, uint8 trackSequence, sub_98197C(image_id, 16, 16, 16, 16, 108, height, 16, 0, height + 3, get_current_rotation()); - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 128; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } } -static void spiral_slide_paint_tile_left(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - // Base - image_id = ((direction & 1) ? SPIRAL_SLIDE_BASE_B : SPIRAL_SLIDE_BASE_A) | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); - - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((x / 32) + dword_7485da[get_current_rotation()].x) | - (((y / 32) + dword_7485da[get_current_rotation()].y) << 8); - - uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; - rct_ride *ride = get_ride(rideIndex); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = SPIRAL_SLIDE_FENCE_TOP_LEFT | RCT2_GLOBAL(0x00F44198, uint32); - - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, 0); - } - - // Fence - image_id = SPIRAL_SLIDE_FENCE_BOTTOM_LEFT | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 1, 32, 7, height, 30, 0, height + 2, get_current_rotation()); +static void spiral_slide_paint_tile_left(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + uint32 image_id; if (direction == 0) image_id = SPIRAL_SLIDE_LEFT_R0 | RCT2_GLOBAL(0x00F44198, uint32); if (direction == 1) image_id = SPIRAL_SLIDE_LEFT_R1 | RCT2_GLOBAL(0x00F44198, uint32); @@ -209,39 +71,14 @@ static void spiral_slide_paint_tile_left(uint8 rideIndex, uint8 trackSequence, u if (direction == 3) image_id = SPIRAL_SLIDE_LEFT_R3 | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(image_id, 16, 16, 16, 16, 108, height, 0, 16, height + 3, get_current_rotation()); - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 128; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } } -static void spiral_slide_paint_tile_front(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); +static void spiral_slide_paint_tile_front(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + uint32 image_id; + - // Base - image_id = ((direction & 1) ? SPIRAL_SLIDE_BASE_B : SPIRAL_SLIDE_BASE_A) | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); - // Fence 1 - image_id = SPIRAL_SLIDE_FENCE_BOTTOM_LEFT | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 1, 32, 7, height, 30, 0, height + 2, get_current_rotation()); - - // Fence 2 - image_id = SPIRAL_SLIDE_FENCE_BOTTOM_RIGHT | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, get_current_rotation()); + rct_ride *ride = get_ride(rideIndex); if (direction == 1) { image_id = SPIRAL_SLIDE_INSIDE_R1 | RCT2_GLOBAL(0x00F44198, uint32); @@ -251,7 +88,6 @@ static void spiral_slide_paint_tile_front(uint8 rideIndex, uint8 trackSequence, sub_98197C(image_id, 16, 16, 16, 2, 108, height, 0, -12, height + 3, get_current_rotation()); } - if (direction == 0) { image_id = SPIRAL_SLIDE_CENTER_R0 | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(image_id, 16, 16, 16, 8, 108, height, 0, 8, height + 3, get_current_rotation()); @@ -267,7 +103,6 @@ static void spiral_slide_paint_tile_front(uint8 rideIndex, uint8 trackSequence, } rct_drawpixelinfo *dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*); - rct_ride *ride = get_ride(rideIndex); if (dpi->zoom_level == 0 && ride->slide_in_use != 0) { uint8 slide_progress = ride->spiral_slide_progress; if (slide_progress != 0) { @@ -315,61 +150,41 @@ static void spiral_slide_paint_tile_front(uint8 rideIndex, uint8 trackSequence, sub_98199C(image_id, 16, 16, boundingBox.x, boundingBox.y, boundingBox.z, height, boundingBoxOffset.x, boundingBoxOffset.y, boundingBoxOffset.z, get_current_rotation()); } } - - height += 128; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } } +static const uint32 spiral_slide_fence_sprites[] = { + SPIRAL_SLIDE_FENCE_TOP_RIGHT, + SPIRAL_SLIDE_FENCE_BOTTOM_RIGHT, + SPIRAL_SLIDE_FENCE_BOTTOM_LEFT, + SPIRAL_SLIDE_FENCE_TOP_LEFT, +}; /** - * rct: 0x007485E8 + * rct: 0x007485C8 */ -static void spiral_slide_paint_setup_rot_0(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { +static void paint_spiral_slide(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + trackSequence = track_map_2x2[direction][trackSequence]; + + int edges = edges_2x2[trackSequence]; + rct_ride * ride = get_ride(rideIndex); + rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + + wooden_a_supports_paint_setup(direction & 1, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); + + // Base + uint32 imageId = ((direction & 1) ? SPIRAL_SLIDE_BASE_B : SPIRAL_SLIDE_BASE_A) | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + + track_paint_util_paint_fences(edges, position, mapElement, ride, RCT2_GLOBAL(0x00F44198, uint32), height, spiral_slide_fence_sprites, get_current_rotation()); + switch (trackSequence) { - case 0: spiral_slide_paint_tile_back(rideIndex, trackSequence, direction, height, mapElement); break; case 1: spiral_slide_paint_tile_right(rideIndex, trackSequence, direction, height, mapElement); break; case 2: spiral_slide_paint_tile_left(rideIndex, trackSequence, direction, height, mapElement); break; case 3: spiral_slide_paint_tile_front(rideIndex, trackSequence, direction, height, mapElement); break; } -} -/** - * rct: 0x00748DE4 - */ -static void spiral_slide_paint_setup_rot_1(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - switch (trackSequence) { - case 0: spiral_slide_paint_tile_right(rideIndex, trackSequence, direction, height, mapElement); break; - case 1: spiral_slide_paint_tile_front(rideIndex, trackSequence, direction, height, mapElement); break; - case 2: spiral_slide_paint_tile_back(rideIndex, trackSequence, direction, height, mapElement); break; - case 3: spiral_slide_paint_tile_left(rideIndex, trackSequence, direction, height, mapElement); break; - } -} - -/** - * rct: 0x00749628 - */ -static void spiral_slide_paint_setup_rot_2(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - switch (trackSequence) { - case 0: spiral_slide_paint_tile_front(rideIndex, trackSequence, direction, height, mapElement); break; - case 1: spiral_slide_paint_tile_left(rideIndex, trackSequence, direction, height, mapElement); break; - case 2: spiral_slide_paint_tile_right(rideIndex, trackSequence, direction, height, mapElement); break; - case 3: spiral_slide_paint_tile_back(rideIndex, trackSequence, direction, height, mapElement); break; - } -} - -/** - * rct: 0x00749E6C - */ -static void spiral_slide_paint_setup_rot_3(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - switch (trackSequence) { - case 0: spiral_slide_paint_tile_left(rideIndex, trackSequence, direction, height, mapElement); break; - case 1: spiral_slide_paint_tile_back(rideIndex, trackSequence, direction, height, mapElement); break; - case 2: spiral_slide_paint_tile_front(rideIndex, trackSequence, direction, height, mapElement); break; - case 3: spiral_slide_paint_tile_right(rideIndex, trackSequence, direction, height, mapElement); break; - } + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 128, 0x20); } /** @@ -380,12 +195,5 @@ TRACK_PAINT_FUNCTION get_track_paint_function_spiral_slide(int trackType, int di return NULL; } - switch (direction) { - case 0: return spiral_slide_paint_setup_rot_0; - case 1: return spiral_slide_paint_setup_rot_1; - case 2: return spiral_slide_paint_setup_rot_2; - case 3: return spiral_slide_paint_setup_rot_3; - } - - return NULL; + return paint_spiral_slide; } diff --git a/src/ride/shops/facility.c b/src/ride/shops/facility.c index 8c9df4ff89..2d92337ed9 100644 --- a/src/ride/shops/facility.c +++ b/src/ride/shops/facility.c @@ -33,16 +33,6 @@ static void facility_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 dir { bool hasSupports = wooden_a_supports_paint_setup(direction & 1, 0, height, RCT2_GLOBAL(0x00F441A4, uint32), NULL); - RCT2_GLOBAL(0x0141E9D0, sint16) = -1; - RCT2_GLOBAL(0x0141E9C4, sint16) = -1; - RCT2_GLOBAL(0x0141E9CC, sint16) = -1; - RCT2_GLOBAL(0x0141E9B8, sint16) = -1; - RCT2_GLOBAL(0x0141E9BC, sint16) = -1; - RCT2_GLOBAL(0x0141E9B4, sint16) = -1; - RCT2_GLOBAL(0x0141E9C0, sint16) = -1; - RCT2_GLOBAL(0x0141E9C8, sint16) = -1; - RCT2_GLOBAL(0x0141E9D4, sint16) = -1; - rct_ride *ride = get_ride(rideIndex); rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); rct_ride_entry_vehicle *firstVehicleEntry = &rideEntry->vehicles[0]; @@ -51,36 +41,31 @@ static void facility_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 dir imageId |= firstVehicleEntry->base_image_id; imageId += (direction + 2) & 3; - sint16 height16 = (sint16)height; int rotation = get_current_rotation(); int lengthX = (direction & 1) == 0 ? 28 : 2; int lengthY = (direction & 1) == 0 ? 2 : 28; if (hasSupports) { - uint32 foundationImageId = RCT2_GLOBAL(0x00F441A4, uint32); - foundationImageId |= 3395; - sub_98197C(foundationImageId, 0, 0, lengthX, lengthY, 29, height, direction == 3 ? 28 : 2, direction == 0 ? 28 : 2, height16, rotation); + uint32 foundationImageId = (direction & 1 ? 3396 : 3395) | RCT2_GLOBAL(0x00F441A4, uint32); + sub_98197C(foundationImageId, 0, 0, lengthX, lengthY, 29, height, direction == 3 ? 28 : 2, direction == 0 ? 28 : 2, height, rotation); // Door image or base - sub_98199C(imageId, 0, 0, lengthX, lengthY, 29, height, direction == 3 ? 28 : 2, direction == 0 ? 28 : 2, height16, rotation); + sub_98199C(imageId, 0, 0, lengthX, lengthY, 29, height, direction == 3 ? 28 : 2, direction == 0 ? 28 : 2, height, rotation); } else { // Door image or base - sub_98197C(imageId, 0, 0, lengthX, lengthY, 29, height, direction == 3 ? 28 : 2, direction == 0 ? 28 : 2, height16, rotation); + sub_98197C(imageId, 0, 0, lengthX, lengthY, 29, height, direction == 3 ? 28 : 2, direction == 0 ? 28 : 2, height, rotation); } // Base image if door was drawn if (direction == 1) { imageId += 2; - sub_98197C(imageId, 0, 0, 2, 28, 29, height, 28, 2, height16, rotation); + sub_98197C(imageId, 0, 0, 2, 28, 29, height, 28, 2, height, rotation); } else if (direction == 2) { imageId += 4; - sub_98197C(imageId, 0, 0, 28, 2, 29, height, 2, 28, height16, rotation); + sub_98197C(imageId, 0, 0, 28, 2, 29, height, 2, 28, height, rotation); } - height16 += 32; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height16) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height16; - RCT2_GLOBAL(0x00141E9DA, uint8) = 32; - } + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); } /* 0x00762D44 */ diff --git a/src/ride/shops/misc.c b/src/ride/shops/misc.c index 06ad312ecd..d12f791795 100644 --- a/src/ride/shops/misc.c +++ b/src/ride/shops/misc.c @@ -22,57 +22,4 @@ #include "../../world/map.h" #include "../track_paint.h" -/** - * rct2: 0x00761378, 0x007614DB, 0x0076163F, 0x007617A5 - */ -static void ride_50_52_53_54_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { - bool supportsDrawn = wooden_a_supports_paint_setup(direction & 1, 0, height, RCT2_GLOBAL(0x00F441A4, uint32), NULL); - RCT2_GLOBAL(0x0141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D4, uint16) = 0xFFFF; - - rct_ride *ride = get_ride(rideIndex); - - rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); - - uint32 image_id = RCT2_GLOBAL(0x00F44198, uint32); - if (image_id & 0x80000000) { - image_id &= 0x60FFFFFF; - } - - image_id += rideEntry->vehicles[0].base_image_id; - image_id += direction; - if (supportsDrawn) { - uint32 ebx = (direction & 1 ? 3396 : 3395) | RCT2_GLOBAL(0x00F441A4, uint32); - sub_98197C(ebx, 0, 0, 28, 28, 45, height, 2, 2, height, get_current_rotation()); - - sub_98199C(image_id, 0, 0, 28, 28, 45, height, 2, 2, height, get_current_rotation()); - } else { - sub_98197C(image_id, 0, 0, 28, 28, 45, height, 2, 2, height, get_current_rotation()); - } - - height += 48; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x00141E9DA, uint8) = 0x20; - } -} - -/** - * rct2: 0x00761160 - */ -TRACK_PAINT_FUNCTION get_track_paint_function_50_52_53_54(int trackType, int direction) { - switch (trackType) { - case 118: - case 121: - return ride_50_52_53_54_paint_setup; - } - return NULL; -} diff --git a/src/ride/shops/shop.c b/src/ride/shops/shop.c index bc52cb8e15..691bae70de 100644 --- a/src/ride/shops/shop.c +++ b/src/ride/shops/shop.c @@ -33,16 +33,6 @@ static void shop_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 directi { bool hasSupports = wooden_a_supports_paint_setup(direction & 1, 0, height, RCT2_GLOBAL(0x00F441A4, uint32), NULL); - RCT2_GLOBAL(0x0141E9D0, sint16) = -1; - RCT2_GLOBAL(0x0141E9C4, sint16) = -1; - RCT2_GLOBAL(0x0141E9CC, sint16) = -1; - RCT2_GLOBAL(0x0141E9B8, sint16) = -1; - RCT2_GLOBAL(0x0141E9BC, sint16) = -1; - RCT2_GLOBAL(0x0141E9B4, sint16) = -1; - RCT2_GLOBAL(0x0141E9C0, sint16) = -1; - RCT2_GLOBAL(0x0141E9C8, sint16) = -1; - RCT2_GLOBAL(0x0141E9D4, sint16) = -1; - rct_ride *ride = get_ride(rideIndex); rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); rct_ride_entry_vehicle *firstVehicleEntry = &rideEntry->vehicles[0]; @@ -54,23 +44,17 @@ static void shop_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 directi imageId += firstVehicleEntry->base_image_id; imageId += direction; - sint16 height16 = (sint16)height; - int rotation = get_current_rotation(); if (hasSupports) { - uint32 foundationImageId = RCT2_GLOBAL(0x00F441A4, uint32); - foundationImageId |= 3395; - sub_98197C(foundationImageId, 0, 0, 28, 28, 45, height, 2, 2, height16, rotation); + uint32 foundationImageId = (direction & 1 ? 3396 : 3395) | RCT2_GLOBAL(0x00F441A4, uint32); + sub_98197C(foundationImageId, 0, 0, 28, 28, 45, height, 2, 2, height, get_current_rotation()); - sub_98199C(imageId, 0, 0, 28, 28, 45, height, 2, 2, height16, rotation); + sub_98199C(imageId, 0, 0, 28, 28, 45, height, 2, 2, height, get_current_rotation()); } else { - sub_98197C(imageId, 0, 0, 28, 28, 45, height, 2, 2, height16, rotation); + sub_98197C(imageId, 0, 0, 28, 28, 45, height, 2, 2, height, get_current_rotation()); } - height16 += 48; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height16) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height16; - RCT2_GLOBAL(0x00141E9DA, uint8) = 32; - } + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 48, 0x20); } /* 0x00761160 */ diff --git a/src/ride/thrill/top_spin.c b/src/ride/thrill/top_spin.c index e035f856e6..a8fff7e8f0 100644 --- a/src/ride/thrill/top_spin.c +++ b/src/ride/thrill/top_spin.c @@ -26,50 +26,6 @@ #include "../track_data.h" #include "../track_paint.h" -/** - * - * rct2: 0x0076687C - */ -static void top_spin_paint_tile_0(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - image_id = 22137 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 112; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } -} - -/* rct2: 0x007667AE */ -static rct_xy16 loc_7667AE[] = { - { .x = 0, .y = -1 }, - { .x = 1, .y = 0 }, - { .x = 0, .y = 1}, - { .x = -1, .y = 0 }, -}; - -/* rct2: 0x007667AC */ -static rct_xy16 loc_7667AC[] = { - { .x = -1, .y = 0 }, - { .x = 0, .y = -1 }, - { .x = 1, .y = 0 }, - { .x = 0, .y = 1 }, -}; - /** * * rct2: 0x0142811C @@ -296,569 +252,62 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di } /** - * - * rct2: 0x0076693F + * rct2: 0x0076679C */ -static void top_spin_paint_tile_1(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); +static void paint_top_spin(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + trackSequence = track_map_3x3[direction][trackSequence]; - const uint8 rotation = get_current_rotation(); - image_id = 22137 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); + int edges = edges_3x3[trackSequence]; + rct_ride *ride = get_ride(rideIndex); + rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((x / 32) + loc_7667AE[rotation].x) | - (((y / 32) + loc_7667AE[rotation].y) << 8); + wooden_a_supports_paint_setup(direction & 1, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); - uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; - rct_ride* ride = get_ride(rideIndex); + track_paint_util_paint_floor(edges, RCT2_GLOBAL(0x00F44198, uint32), height, floorSpritesCork, get_current_rotation()); - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = 22141 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, rotation); + track_paint_util_paint_fences(edges, position, mapElement, ride, RCT2_GLOBAL(0x00F441A0, uint32), height, fenceSpritesRope, get_current_rotation()); + + switch (trackSequence) { + case 1: top_spin_paint_vehicle(32, 32, rideIndex, direction, height, mapElement); break; + case 3: top_spin_paint_vehicle(32, -32, rideIndex, direction, height, mapElement); break; + case 5: top_spin_paint_vehicle(0, -32, rideIndex, direction, height, mapElement); break; + case 6: top_spin_paint_vehicle(-32, 32, rideIndex, direction, height, mapElement); break; + case 7: top_spin_paint_vehicle(-32, -32, rideIndex, direction, height, mapElement); break; + case 8: top_spin_paint_vehicle(-32, 0, rideIndex, direction, height, mapElement); break; } - entranceLoc = - ((x / 32) + loc_7667AC[rotation].x) | - (((y / 32) + loc_7667AC[rotation].y) << 8); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = 22138 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0, 2, height + 2, rotation); + int cornerSegments = 0; + switch (trackSequence) { + case 1: + // top + cornerSegments = SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC; + break; + case 3: + // right + cornerSegments = SEGMENT_CC | SEGMENT_BC | SEGMENT_D4; + break; + case 6: + // left + cornerSegments = SEGMENT_C8 | SEGMENT_B8 | SEGMENT_D0; + break; + case 7: + // bottom + cornerSegments = SEGMENT_D0 | SEGMENT_C0 | SEGMENT_D4; + break; } - 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; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = height + 2; - RCT2_GLOBAL(0x141E9CA, uint16) = 32; - RCT2_GLOBAL(0x141E9CC, uint16) = height + 2; - RCT2_GLOBAL(0x141E9CE, uint16) = 32; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 110; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } + paint_util_set_segment_support_height(cornerSegments, height + 2, 0x20); + paint_util_set_segment_support_height(SEGMENTS_ALL & ~cornerSegments, 0xFFFF, 0); + paint_util_set_general_support_height(height + 112, 0x20); } -/** - * - * rct2: 0x00767033 - */ -static void top_spin_paint_tile_2(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - const uint8 rotation = get_current_rotation(); - image_id = 22137 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); - - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((x / 32) + loc_7667AC[rotation].x) | - (((y / 32) + loc_7667AC[rotation].y) << 8); - - uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; - rct_ride* ride = get_ride(rideIndex); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = 22138 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 2, 0, height + 2, rotation); - } - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 110; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } -} - -/** - * - * rct2: 0x0076718D - */ -static void top_spin_paint_tile_4(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - const uint8 rotation = get_current_rotation(); - image_id = 22137 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); - - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((x / 32) + loc_7667AE[rotation].x) | - (((y / 32) + loc_7667AE[rotation].y) << 8); - - uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; - rct_ride* ride = get_ride(rideIndex); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = 22141 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, rotation); - } - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 110; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } -} - -/** - * - * rct2: 0x00766B4C - */ -static void top_spin_paint_tile_3(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - const uint8 rotation = get_current_rotation(); - image_id = 22136 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); - - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((x / 32) + loc_7667AC[rotation].x) | - (((y / 32) + loc_7667AC[rotation].y) << 8); - - uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; - rct_ride* ride = get_ride(rideIndex); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = 22138 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 2, 0, height + 2, rotation); - } - - entranceLoc = - ((x / 32) + loc_7667AC[(rotation + 3) & 3].x) | - (((y / 32) + loc_7667AC[(rotation + 3) & 3].y) << 8); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - - image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, rotation); - } - - top_spin_paint_vehicle(32, -32, rideIndex, direction, height, mapElement); - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = height + 2; - RCT2_GLOBAL(0x141E9BE, uint16) = 32; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = height + 2; - RCT2_GLOBAL(0x141E9CE, uint16) = 32; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = height + 2; - RCT2_GLOBAL(0x141E9D6, uint16) = 32; - - height += 110; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } -} - -/** - * - * rct2: 0x007672E7 - */ -static void top_spin_paint_tile_5(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - const uint8 rotation = get_current_rotation(); - image_id = 22136 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, 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[(rotation + 3) & 3].x) | - (((y / 32) + loc_7667AC[(rotation + 3) & 3].y) << 8); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, rotation); - } - - top_spin_paint_vehicle(0, -32, rideIndex, direction, height, mapElement); - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 112; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } -} - -/** - * - * rct2: 0x00766D09 - */ -static void top_spin_paint_tile_6(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - const uint8 rotation = get_current_rotation(); - image_id = 22135 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); - - sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); - uint16 entranceLoc = - ((x / 32) + loc_7667AE[rotation].x) | - (((y / 32) + loc_7667AE[rotation].y) << 8); - - uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; - rct_ride* ride = get_ride(rideIndex); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - image_id = 22141 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, rotation); - } - - entranceLoc = - ((x / 32) + loc_7667AE[(rotation + 1) & 3].x) | - (((y / 32) + loc_7667AE[(rotation + 1) & 3].y) << 8); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - - image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 1, 32, 7, height, 30, 2, height + 2, rotation); - } - - top_spin_paint_vehicle(-32, 32, rideIndex, direction, height, mapElement); - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = height + 2; - RCT2_GLOBAL(0x141E9BA, uint16) = 32; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = height + 2; - RCT2_GLOBAL(0x141E9CA, uint16) = 32; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = height + 2; - RCT2_GLOBAL(0x141E9D2, uint16) = 32; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 110; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } -} - -/** - * - * rct2: 0x00766EC6 - */ -static void top_spin_paint_tile_7(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - const uint8 rotation = get_current_rotation(); - image_id = 22134 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, 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[(rotation + 1) & 3].x) | - (((y / 32) + loc_7667AE[(rotation + 1) & 3].y) << 8); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - - image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 1, 28, 7, height, 29, 0, height + 3, rotation); - } - - entranceLoc = - ((x / 32) + loc_7667AC[(rotation + 3) & 3].x) | - (((y / 32) + loc_7667AC[(rotation + 3) & 3].y) << 8); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - - image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 28, 1, 7, height, 0, 29, height + 3, rotation); - } - - top_spin_paint_vehicle(-32, -32, rideIndex, direction, height, mapElement); - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = height + 2; - RCT2_GLOBAL(0x141E9C2, uint16) = 32; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = height + 2; - RCT2_GLOBAL(0x141E9D2, uint16) = 32; - RCT2_GLOBAL(0x141E9D4, uint16) = height + 2; - RCT2_GLOBAL(0x141E9D6, uint16) = 32; - - height += 110; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } -} - -/** - * - * rct2: 0x007673FA - */ -static void top_spin_paint_tile_8(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); - wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - - const uint8 rotation = get_current_rotation(); - image_id = 22135 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, 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[(rotation + 1) & 3].x) | - (((y / 32) + loc_7667AE[(rotation + 1) & 3].y) << 8); - - if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { - - image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 1, 32, 7, height, 30, 0, height + 2, rotation); - } - top_spin_paint_vehicle(-32, 0, rideIndex, direction, height, mapElement); - - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 112; - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = 32; - } -} - -/** - * - * rct2: 0x007667BC - */ -static void top_spin_paint_setup_rot_0(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - switch (trackSequence) - { - case 0: - top_spin_paint_tile_0(rideIndex, trackSequence, direction, height, mapElement); - break; - case 1: - top_spin_paint_tile_1(rideIndex, trackSequence, direction, height, mapElement); - break; - case 2: - top_spin_paint_tile_2(rideIndex, trackSequence, direction, height, mapElement); - break; - case 3: - top_spin_paint_tile_3(rideIndex, trackSequence, direction, height, mapElement); - break; - case 4: - top_spin_paint_tile_4(rideIndex, trackSequence, direction, height, mapElement); - break; - case 5: - top_spin_paint_tile_5(rideIndex, trackSequence, direction, height, mapElement); - break; - case 6: - top_spin_paint_tile_6(rideIndex, trackSequence, direction, height, mapElement); - break; - case 7: - top_spin_paint_tile_7(rideIndex, trackSequence, direction, height, mapElement); - break; - case 8: - top_spin_paint_tile_8(rideIndex, trackSequence, direction, height, mapElement); - break; - } - return; -} - -/** - * - * rct2: 0x007667EC -*/ -static void top_spin_paint_setup_rot_1(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - switch (trackSequence) - { - case 0: - top_spin_paint_tile_0(rideIndex, trackSequence, direction, height, mapElement); - break; - case 1: - top_spin_paint_tile_3(rideIndex, trackSequence, direction, height, mapElement); - break; - case 2: - top_spin_paint_tile_5(rideIndex, trackSequence, direction, height, mapElement); - break; - case 3: - top_spin_paint_tile_7(rideIndex, trackSequence, direction, height, mapElement); - break; - case 4: - top_spin_paint_tile_2(rideIndex, trackSequence, direction, height, mapElement); - break; - case 5: - top_spin_paint_tile_8(rideIndex, trackSequence, direction, height, mapElement); - break; - case 6: - top_spin_paint_tile_1(rideIndex, trackSequence, direction, height, mapElement); - break; - case 7: - top_spin_paint_tile_6(rideIndex, trackSequence, direction, height, mapElement); - break; - case 8: - top_spin_paint_tile_4(rideIndex, trackSequence, direction, height, mapElement); - break; - } - return; -} - -/** - * - * rct2: 0x0076681C -*/ -static void top_spin_paint_setup_rot_2(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - switch (trackSequence) - { - case 0: - top_spin_paint_tile_0(rideIndex, trackSequence, direction, height, mapElement); - break; - case 1: - top_spin_paint_tile_7(rideIndex, trackSequence, direction, height, mapElement); - break; - case 2: - top_spin_paint_tile_8(rideIndex, trackSequence, direction, height, mapElement); - break; - case 3: - top_spin_paint_tile_6(rideIndex, trackSequence, direction, height, mapElement); - break; - case 4: - top_spin_paint_tile_5(rideIndex, trackSequence, direction, height, mapElement); - break; - case 5: - top_spin_paint_tile_4(rideIndex, trackSequence, direction, height, mapElement); - break; - case 6: - top_spin_paint_tile_3(rideIndex, trackSequence, direction, height, mapElement); - break; - case 7: - top_spin_paint_tile_1(rideIndex, trackSequence, direction, height, mapElement); - break; - case 8: - top_spin_paint_tile_2(rideIndex, trackSequence, direction, height, mapElement); - break; - } - return; -} - -/** - * - * rct2: 0x0076684C -*/ -static void top_spin_paint_setup_rot_3(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) { - switch (trackSequence) - { - case 0: - top_spin_paint_tile_0(rideIndex, trackSequence, direction, height, mapElement); - break; - case 1: - top_spin_paint_tile_6(rideIndex, trackSequence, direction, height, mapElement); - break; - case 2: - top_spin_paint_tile_4(rideIndex, trackSequence, direction, height, mapElement); - break; - case 3: - top_spin_paint_tile_1(rideIndex, trackSequence, direction, height, mapElement); - break; - case 4: - top_spin_paint_tile_8(rideIndex, trackSequence, direction, height, mapElement); - break; - case 5: - top_spin_paint_tile_2(rideIndex, trackSequence, direction, height, mapElement); - break; - case 6: - top_spin_paint_tile_7(rideIndex, trackSequence, direction, height, mapElement); - break; - case 7: - top_spin_paint_tile_3(rideIndex, trackSequence, direction, height, mapElement); - break; - case 8: - top_spin_paint_tile_5(rideIndex, trackSequence, direction, height, mapElement); - break; - } - return; -} /* 0x0076659C */ TRACK_PAINT_FUNCTION get_track_paint_function_topspin(int trackType, int direction) { - switch (trackType) { - case 123: - switch (direction) { - case 0: return top_spin_paint_setup_rot_0; - case 1: return top_spin_paint_setup_rot_1; - case 2: return top_spin_paint_setup_rot_2; - case 3: return top_spin_paint_setup_rot_3; - } - break; + if (trackType != 123) { + return NULL; } - return NULL; + + return paint_top_spin; } diff --git a/src/ride/track_data.c b/src/ride/track_data.c index 2787531eb9..069504b189 100644 --- a/src/ride/track_data.c +++ b/src/ride/track_data.c @@ -5642,11 +5642,11 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = { 0, // RIDE_TYPE_MAGIC_CARPET 0, // RIDE_TYPE_SUBMARINE_RIDE 0, // RIDE_TYPE_RIVER_RAFTS - get_track_paint_function_50_52_53_54, // RIDE_TYPE_50 + get_track_paint_function_shop, // RIDE_TYPE_50 0, // RIDE_TYPE_ENTERPRISE - 0, // RIDE_TYPE_52 - 0, // RIDE_TYPE_53 - 0, // RIDE_TYPE_54 + get_track_paint_function_shop, // RIDE_TYPE_52 + get_track_paint_function_shop, // RIDE_TYPE_53 + get_track_paint_function_shop, // RIDE_TYPE_54 0, // RIDE_TYPE_55 0, // RIDE_TYPE_INVERTED_IMPULSE_COASTER 0, // RIDE_TYPE_MINI_ROLLER_COASTER diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 6d5421ae3b..09ef4ab715 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -28,6 +28,163 @@ #include "ride_data.h" #include "track_data.h" #include "track_paint.h" +#include "../paint/map_element/map_element.h" + +/* rct2: 0x007667AC */ +static rct_xy16 loc_7667AC[] = { + {.x = -1, .y = 0}, + {.x = 0, .y = -1}, + {.x = 1, .y = 0}, + {.x = 0, .y = 1}, +}; + +/* rct2: 0x007667AE */ +static rct_xy16 loc_7667AE[] = { + {.x = 0, .y = -1}, + {.x = 1, .y = 0}, + {.x = 0, .y = 1}, + {.x = -1, .y = 0}, +}; + +const uint8 track_map_2x2[][4] = { + {0, 1, 2, 3}, + {1, 3, 0, 2}, + {3, 2, 1, 0}, + {2, 0, 3, 1} +}; + +const uint8 edges_2x2[] = { + EDGE_NE | EDGE_NW, + EDGE_NE | EDGE_SE, + EDGE_SW | EDGE_NW, + EDGE_SW | EDGE_SE, +}; + +const uint8 track_map_3x3[][9] = { + {0, 1, 2, 3, 4, 5, 6, 7, 8}, + {0, 3, 5, 7, 2, 8, 1, 6, 4}, + {0, 7, 8, 6, 5, 4, 3, 1, 2}, + {0, 6, 4, 1, 8, 2, 7, 3, 5} +}; + +const uint8 edges_3x3[] = { + 0, + EDGE_NE | EDGE_NW, + EDGE_NE, + EDGE_NE | EDGE_SE, + EDGE_NW, + EDGE_SE, + EDGE_SW | EDGE_NW, + EDGE_SW | EDGE_SE, + EDGE_SW, +}; + +const uint8 track_map_4x4[][16] = { + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}, + {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, + {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3}, +}; + +const uint8 edges_4x4[] = { + EDGE_NE | EDGE_NW, + EDGE_NE, + EDGE_NE, + EDGE_NE | EDGE_SE, + EDGE_NW, + 0, + 0, + EDGE_SE, + EDGE_NW, + 0, + 0, + EDGE_SE, + EDGE_NW | EDGE_SW, + EDGE_SW, + EDGE_SW, + EDGE_SW | EDGE_SE +}; + +const uint32 floorSpritesCork[] = { + SPR_FLOOR_CORK_SE_SW, + SPR_FLOOR_CORK_SW, + SPR_FLOOR_CORK_SE, + SPR_FLOOR_CORK +}; + +const uint32 fenceSpritesRope[] = { + SPR_FENCE_ROPE_NE, + SPR_FENCE_ROPE_SE, + SPR_FENCE_ROPE_SW, + SPR_FENCE_ROPE_NW +}; + +bool track_paint_util_has_fence(enum edge edge, rct_xy16 position, rct_map_element * mapElement, rct_ride * ride, uint8 rotation) +{ + rct_xy16 offset; + switch (edge) { + case EDGE_NE: + offset = loc_7667AC[rotation]; + break; + case EDGE_SE: + offset = loc_7667AE[(rotation + 2) & 3]; + break; + case EDGE_SW: + offset = loc_7667AC[(rotation + 2) & 3]; + break; + case EDGE_NW: + offset = loc_7667AE[rotation]; + break; + } + + uint16 entranceLoc = + ((position.x / 32) + offset.x) | + (((position.y / 32) + offset.y) << 8); + + uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; + + return (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc); +} + +void track_paint_util_paint_floor(uint8 edges, uint32 colourFlags, uint16 height, const uint32 floorSprites[4], uint8 rotation) +{ + uint32 imageId; + + if (edges & EDGE_SW && edges & EDGE_SE) { + imageId = floorSprites[0]; + } else if (edges & EDGE_SW) { + imageId = floorSprites[1]; + } else if (edges & EDGE_SE) { + imageId = floorSprites[2]; + } else { + imageId = floorSprites[3]; + } + + sub_98197C(imageId | colourFlags, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); +} + +void track_paint_util_paint_fences(uint8 edges, rct_xy16 position, rct_map_element * mapElement, rct_ride * ride, uint32 colourFlags, uint16 height, const uint32 fenceSprites[4], uint8 rotation) +{ + uint32 imageId; + + if (edges & EDGE_NW && track_paint_util_has_fence(EDGE_NW, position, mapElement, ride, get_current_rotation())) { + imageId = fenceSprites[3] | colourFlags; + sub_98199C(imageId, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); + } + if (edges & EDGE_NE && track_paint_util_has_fence(EDGE_NE, position, mapElement, ride, get_current_rotation())) { + imageId = fenceSprites[0] | colourFlags; + sub_98199C(imageId, 0, 0, 1, 32, 7, height, 2, 0, height + 2, get_current_rotation()); + } + if (edges & EDGE_SW && track_paint_util_has_fence(EDGE_SW, position, mapElement, ride, get_current_rotation())) { + imageId = fenceSprites[2] | colourFlags; + sub_98197C(imageId, 0, 0, 1, 32, 7, height, 30, 0, height + 2, get_current_rotation()); + } + if (edges & EDGE_SE && track_paint_util_has_fence(EDGE_SE, position, mapElement, ride, get_current_rotation())) { + imageId = fenceSprites[1] | colourFlags; + sub_98197C(imageId, 0, 0, 32, 1, 7, height, 0, 30, height + 2, get_current_rotation()); + } +} + /** * diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index f4de64f46c..54c440c16f 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -18,6 +18,36 @@ #define _TRACK_PAINT_H #include "../common.h" +#include "../world/map.h" +#include "../paint/map_element/map_element.h" + +extern const uint8 track_map_2x2[][4]; +extern const uint8 edges_2x2[]; + +extern const uint8 track_map_3x3[][9]; +extern const uint8 edges_3x3[]; + +extern const uint8 track_map_4x4[][16]; +extern const uint8 edges_4x4[]; + +enum { + SPR_FLOOR_CORK_SE_SW = 22134, + SPR_FLOOR_CORK_SW = 22135, + SPR_FLOOR_CORK_SE = 22136, + SPR_FLOOR_CORK = 22137, + SPR_FENCE_ROPE_NE = 22138, + SPR_FENCE_ROPE_SE = 22139, + SPR_FENCE_ROPE_SW = 22140, + SPR_FENCE_ROPE_NW = 22141, +}; + +extern const uint32 floorSpritesCork[]; + +extern const uint32 fenceSpritesRope[]; + +bool track_paint_util_has_fence(enum edge edge, rct_xy16 position, rct_map_element * mapElement, rct_ride * ride, uint8 rotation); +void track_paint_util_paint_floor(uint8 edges, uint32 colourFlags, uint16 height, const uint32 floorSprites[4], uint8 rotation); +void track_paint_util_paint_fences(uint8 edges, rct_xy16 position, rct_map_element * mapElement, rct_ride * ride, uint32 colourFlags, uint16 height, const uint32 fenceSprites[4], uint8 rotation); typedef void (*TRACK_PAINT_FUNCTION)(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement); typedef TRACK_PAINT_FUNCTION (*TRACK_PAINT_FUNCTION_GETTER)(int trackType, int direction); @@ -29,6 +59,5 @@ TRACK_PAINT_FUNCTION get_track_paint_function_topspin(int trackType, int directi TRACK_PAINT_FUNCTION get_track_paint_function_shop(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_facility(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_crooked_house(int trackType, int direction); -TRACK_PAINT_FUNCTION get_track_paint_function_50_52_53_54(int trackType, int direction); #endif