From 883031b83ce7530913da83f207d24f4480e299ea Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 25 May 2016 13:58:50 +0200 Subject: [PATCH 01/11] Draw Monorail half-corners --- src/ride/track_data.c | 2 +- src/ride/track_paint.h | 1 + src/ride/transport/monorail.c | 492 ++++++++++++++++++++++++++++++++++ 3 files changed, 494 insertions(+), 1 deletion(-) diff --git a/src/ride/track_data.c b/src/ride/track_data.c index 5333bf40da..7c8ebea852 100644 --- a/src/ride/track_data.c +++ b/src/ride/track_data.c @@ -5568,7 +5568,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = { 0, // RIDE_TYPE_INVERTED_ROLLER_COASTER 0, // RIDE_TYPE_JUNIOR_ROLLER_COASTER 0, // RIDE_TYPE_MINIATURE_RAILWAY - 0, // RIDE_TYPE_MONORAIL + get_track_paint_function_monorail, // RIDE_TYPE_MONORAIL 0, // RIDE_TYPE_MINI_SUSPENDED_COASTER get_track_paint_function_boat_ride, // RIDE_TYPE_BOAT_RIDE 0, // RIDE_TYPE_WOODEN_WILD_MOUSE diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 1682498231..725ce3d74b 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -207,6 +207,7 @@ void track_paint_util_spinning_tunnel_paint(sint8 thickness, sint16 height, uint 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); +TRACK_PAINT_FUNCTION get_track_paint_function_monorail(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_boat_ride(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_car_ride(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_launched_freefall(int trackType, int direction); diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index 846fd9695d..3105e4f9a4 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -13,3 +13,495 @@ * A full copy of the GNU General Public License can be found in licence.txt *****************************************************************************/ #pragma endregion + +#include "../../common.h" +#include "../track_paint.h" +#include "../track.h" +#include "../vehicle_paint.h" +#include "../../interface/viewport.h" +#include "../../paint/paint.h" +#include "../../paint/supports.h" +#include "../ride_data.h" +#include "../../world/map.h" + +enum +{ + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0 = 23293, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_1 = 23294, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_2 = 23295, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_3 = 23296, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_S_PART_0 = 23297, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_S_PART_1 = 23298, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_S_PART_2 = 23299, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_S_PART_3 = 23300, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_W_PART_0 = 23301, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_W_PART_1 = 23302, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_W_PART_2 = 23303, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_W_PART_3 = 23304, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_N_PART_0 = 23305, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_N_PART_1 = 23306, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_N_PART_2 = 23307, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_N_PART_3 = 23308, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_N_PART_0 = 23309, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_N_PART_1 = 23310, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_N_PART_2 = 23311, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_N_PART_3 = 23312, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_E_PART_0 = 23313, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_E_PART_1 = 23314, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_E_PART_2 = 23315, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_E_PART_3 = 23316, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_S_PART_0 = 23317, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_S_PART_1 = 23318, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_S_PART_2 = 23319, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_S_PART_3 = 23320, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_0 = 23321, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_1 = 23322, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_2 = 23323, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_3 = 23324, +}; + +static const uint32 ghost_train_track_pieces_right_eight_to_diag[4][4] = { + { + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_1, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_2, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_3, + }, + { + SPR_MONORAIL_EIGHT_TO_DIAG_NW_S_PART_0, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_S_PART_1, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_S_PART_2, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_S_PART_3, + }, + { + SPR_MONORAIL_EIGHT_TO_DIAG_NE_W_PART_0, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_W_PART_1, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_W_PART_2, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_W_PART_3, + }, + { + SPR_MONORAIL_EIGHT_TO_DIAG_SE_N_PART_0, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_N_PART_1, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_N_PART_2, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_N_PART_3, + }, +}; + +static const rct_xy16 ghost_train_track_pieces_right_eight_to_diag_bounds[4][4] = { + { + {32, 20}, + {32, 16}, + {16, 16}, + {16, 16}, + }, + { + {20, 32}, + {16, 32}, + {16, 16}, + {16, 16}, + }, + { + {32, 20}, + {34, 16}, + {28, 28}, + {16, 18}, + }, + { + {20, 32}, + {16, 32}, + {16, 16}, + {16, 16}, + }, +}; + +static const rct_xy16 ghost_train_track_pieces_right_eight_to_diag_offset[4][4] = { + { + {0, 6}, + {0, 16}, + {0, 0}, + {16, 0}, + }, + { + {6, 0}, + {16, 0}, + {0, 16}, + {0, 0}, + }, + { + {0, 6}, + {0, 0}, + {4, 4}, + {0, 16}, + }, + { + {6, 0}, + {0, 0}, + {16, 0}, + {16, 16}, + }, +}; + +static const uint32 ghost_train_track_pieces_left_eight_to_diag[4][4] = { + { + SPR_MONORAIL_EIGHT_TO_DIAG_SW_N_PART_0, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_N_PART_1, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_N_PART_2, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_N_PART_3, + }, + { + SPR_MONORAIL_EIGHT_TO_DIAG_NW_E_PART_0, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_E_PART_1, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_E_PART_2, + SPR_MONORAIL_EIGHT_TO_DIAG_NW_E_PART_3, + }, + { + SPR_MONORAIL_EIGHT_TO_DIAG_NE_S_PART_0, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_S_PART_1, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_S_PART_2, + SPR_MONORAIL_EIGHT_TO_DIAG_NE_S_PART_3, + }, + { + SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_0, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_1, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_2, + SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_3, + }, +}; + +static const rct_xy16 ghost_train_track_pieces_left_eight_to_diag_bounds[4][4] = { + { + {32, 20}, + {32, 16}, + {16, 16}, + {16, 16}, + }, + { + {20, 32}, + {16, 34}, + {16, 16}, + {18, 16}, + }, + { + {32, 20}, + {32, 16}, + {16, 16}, + {16, 16}, + }, + { + {20, 32}, + {16, 32}, + {16, 16}, + {16, 16}, + }, +}; + +static const rct_xy16 ghost_train_track_pieces_left_eight_to_diag_offset[4][4] = { + { + {0, 6}, + {0, 0}, + {0, 16}, + {16, 16}, + }, + { + {6, 0}, + {0, 0}, + {16, 16}, + {16, 0}, + }, + { + {0, 6}, + {0, 16}, + {16, 0}, + {0, 0}, + }, + { + {6, 0}, + {16, 0}, + {0, 0}, + {0, 16}, + }, +}; + +/** rct2: 0x */ +static void paint_monorail_track_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_flat_to_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_25_deg_up_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_flat_to_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_25_deg_down_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_right_quarter_turn_5_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_left_quarter_turn_5_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_s_bend_left(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_s_bend_right(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_right_quarter_turn_3_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_left_quarter_turn_3_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +static const sint8 paint_monorail_eighth_to_diag_index[] = {0, 1, 2, -1, 3}; + +/** rct2: 0x008AE31C */ +static void paint_monorail_track_left_eighth_to_diag(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + uint32 imageId; + sint8 index = paint_monorail_eighth_to_diag_index[trackSequence]; + if (index >= 0) { + imageId = ghost_train_track_pieces_left_eight_to_diag[direction][index] | RCT2_GLOBAL(0x00F44198, uint32); + const rct_xy16 offset = ghost_train_track_pieces_left_eight_to_diag_offset[direction][index]; + const rct_xy16 bounds = ghost_train_track_pieces_left_eight_to_diag_bounds[direction][index]; + sub_98197C(imageId, 0, 0, bounds.x, bounds.y, 2, height, offset.x, offset.y, height, get_current_rotation()); + } + + switch (trackSequence) { + case 0: + metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + case 4: + if (direction == 0) metal_a_supports_paint_setup(3, 3, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + if (direction == 1) metal_a_supports_paint_setup(3, 1, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + if (direction == 2) metal_a_supports_paint_setup(3, 0, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + if (direction == 3) metal_a_supports_paint_setup(3, 2, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + } + + if (direction == 0 && trackSequence == 0) { + paint_util_push_tunnel_left(height, TUNNEL_0); + } + if (direction == 3 && trackSequence == 0) { + paint_util_push_tunnel_right(height, TUNNEL_0); + } + + int blockedSegments; + switch (trackSequence) { + case 0: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC; break; + case 1: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_B8 | SEGMENT_C8 | SEGMENT_B4; break; + case 2: blockedSegments = SEGMENT_C4 | SEGMENT_CC | SEGMENT_C0 | SEGMENT_D4 | SEGMENT_BC; break; + case 3: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_B8 | SEGMENT_C8; break; + case 4: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_C8 | SEGMENT_C0 | SEGMENT_D4; break; + } + + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); +} + +/** rct2: 0x008AE32C */ +static void paint_monorail_track_right_eighth_to_diag(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + uint32 imageId; + sint8 index = paint_monorail_eighth_to_diag_index[trackSequence]; + if (index >= 0) { + imageId = ghost_train_track_pieces_right_eight_to_diag[direction][index] | RCT2_GLOBAL(0x00F44198, uint32); + const rct_xy16 offset = ghost_train_track_pieces_right_eight_to_diag_offset[direction][index]; + const rct_xy16 bounds = ghost_train_track_pieces_right_eight_to_diag_bounds[direction][index]; + sub_98197C(imageId, 0, 0, bounds.x, bounds.y, 2, height, offset.x, offset.y, height, get_current_rotation()); + } + + switch (trackSequence) { + case 0: + metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + case 4: + if (direction == 0) metal_a_supports_paint_setup(3, 1, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + if (direction == 1) metal_a_supports_paint_setup(3, 0, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + if (direction == 2) metal_a_supports_paint_setup(3, 2, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + if (direction == 3) metal_a_supports_paint_setup(3, 3, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + } + + if (direction == 0 && trackSequence == 0) { + paint_util_push_tunnel_left(height, TUNNEL_0); + } + if (direction == 3 && trackSequence == 0) { + paint_util_push_tunnel_right(height, TUNNEL_0); + } + + int blockedSegments; + switch (trackSequence) { + case 0: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC; break; + case 1: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_C0 | SEGMENT_D4 | SEGMENT_BC; break; + case 2: blockedSegments = SEGMENT_C4 | SEGMENT_CC | SEGMENT_B8 | SEGMENT_C8 | SEGMENT_B4; break; + case 3: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_C0 | SEGMENT_D4; break; + case 4: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_B8 | SEGMENT_C8 | SEGMENT_D4; break; + } + + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); +} + +/** rct2: 0x008AE33C */ +static void paint_monorail_track_left_eighth_to_orthogonal(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + const uint8 map[] = {4, 2, 3, 1, 0}; + trackSequence = map[trackSequence]; + paint_monorail_track_right_eighth_to_diag(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); +} + +/** rct2: 0x008AE34C */ +static void paint_monorail_track_right_eighth_to_orthogonal(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + const uint8 map[] = {4, 2, 3, 1, 0}; + trackSequence = map[trackSequence]; + paint_monorail_track_left_eighth_to_diag(rideIndex, trackSequence, (direction + 3) % 4, height, mapElement); +} + +/** rct2: 0x */ +static void paint_monorail_track_diag_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_diag_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_diag_flat_to_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_diag_25_deg_up_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_diag_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_diag_flat_to_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** rct2: 0x */ +static void paint_monorail_track_diag_25_deg_down_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ +} + +/** + * rct2: 0x008ADF34 + */ +TRACK_PAINT_FUNCTION get_track_paint_function_monorail(int trackType, int direction) +{ + switch (trackType) { + case TRACK_ELEM_FLAT: + return paint_monorail_track_flat; + + case TRACK_ELEM_END_STATION: + case TRACK_ELEM_BEGIN_STATION: + case TRACK_ELEM_MIDDLE_STATION: + return paint_monorail_station; + + case TRACK_ELEM_25_DEG_UP: + return paint_monorail_track_25_deg_up; + case TRACK_ELEM_FLAT_TO_25_DEG_UP: + return paint_monorail_track_flat_to_25_deg_up; + case TRACK_ELEM_25_DEG_UP_TO_FLAT: + return paint_monorail_track_25_deg_up_to_flat; + + case TRACK_ELEM_25_DEG_DOWN: + return paint_monorail_track_25_deg_down; + case TRACK_ELEM_FLAT_TO_25_DEG_DOWN: + return paint_monorail_track_flat_to_25_deg_down; + case TRACK_ELEM_25_DEG_DOWN_TO_FLAT: + return paint_monorail_track_25_deg_down_to_flat; + + case TRACK_ELEM_LEFT_QUARTER_TURN_5_TILES: + return paint_monorail_track_left_quarter_turn_5_tiles; + case TRACK_ELEM_RIGHT_QUARTER_TURN_5_TILES: + return paint_monorail_track_right_quarter_turn_5_tiles; + + case TRACK_ELEM_S_BEND_LEFT: + return paint_monorail_track_s_bend_left; + case TRACK_ELEM_S_BEND_RIGHT: + return paint_monorail_track_s_bend_right; + + case TRACK_ELEM_LEFT_QUARTER_TURN_3_TILES: + return paint_monorail_track_left_quarter_turn_3_tiles; + case TRACK_ELEM_RIGHT_QUARTER_TURN_3_TILES: + return paint_monorail_track_right_quarter_turn_3_tiles; + + case TRACK_ELEM_LEFT_EIGHTH_TO_DIAG: + return paint_monorail_track_left_eighth_to_diag; + case TRACK_ELEM_RIGHT_EIGHTH_TO_DIAG: + return paint_monorail_track_right_eighth_to_diag; + case TRACK_ELEM_LEFT_EIGHTH_TO_ORTHOGONAL: + return paint_monorail_track_left_eighth_to_orthogonal; + case TRACK_ELEM_RIGHT_EIGHTH_TO_ORTHOGONAL: + return paint_monorail_track_right_eighth_to_orthogonal; + + case TRACK_ELEM_DIAG_FLAT: + return paint_monorail_track_diag_flat; + + case TRACK_ELEM_DIAG_25_DEG_UP: + return paint_monorail_track_diag_25_deg_up; + case TRACK_ELEM_DIAG_FLAT_TO_25_DEG_UP: + return paint_monorail_track_diag_flat_to_25_deg_up; + case TRACK_ELEM_DIAG_25_DEG_UP_TO_FLAT: + return paint_monorail_track_diag_25_deg_up_to_flat; + + case TRACK_ELEM_DIAG_25_DEG_DOWN: + return paint_monorail_track_diag_25_deg_down; + case TRACK_ELEM_DIAG_FLAT_TO_25_DEG_DOWN: + return paint_monorail_track_diag_flat_to_25_deg_down; + case TRACK_ELEM_DIAG_25_DEG_DOWN_TO_FLAT: + return paint_monorail_track_diag_25_deg_down_to_flat; + } + + return NULL; +} From 22e20aa4dcf9db6858f676bef580799dfbe96737 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 25 May 2016 22:58:40 +0200 Subject: [PATCH 02/11] Draw flat track --- src/ride/transport/monorail.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index 3105e4f9a4..7385d717f5 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -26,6 +26,9 @@ enum { + SPR_MONORAIL_FLAT_SW_NE = 23231, + SPR_MONORAIL_FLAT_NW_SE = 23232, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0 = 23293, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_1 = 23294, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_2 = 23295, @@ -60,6 +63,13 @@ enum SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_3 = 23324, }; +static const uint32 monorail_track_pieces_flat[4] = { + SPR_MONORAIL_FLAT_SW_NE, + SPR_MONORAIL_FLAT_NW_SE, + SPR_MONORAIL_FLAT_SW_NE, + SPR_MONORAIL_FLAT_NW_SE, +}; + static const uint32 ghost_train_track_pieces_right_eight_to_diag[4][4] = { { SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0, @@ -222,9 +232,31 @@ static const rct_xy16 ghost_train_track_pieces_left_eight_to_diag_offset[4][4] = }, }; -/** rct2: 0x */ +/** rct2: 0x008AE1AC */ static void paint_monorail_track_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + + uint32 imageId = monorail_track_pieces_flat[direction] | RCT2_GLOBAL(0x00F44198, uint32); + + if (direction == 0 || direction == 2) { + sub_98196C(imageId, 0, 6, 32, 20, 3, height, get_current_rotation()); + } else { + sub_98196C(imageId, 6, 0, 20, 32, 3, height, get_current_rotation()); + } + + if (direction == 0 || direction == 2) { + paint_util_push_tunnel_left(height, TUNNEL_6); + } else { + paint_util_push_tunnel_right(height, TUNNEL_6); + } + + if (track_paint_util_should_paint_supports(position)) { + metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); } /** rct2: 0x */ From 85c6f75acd9e138221e2edcbc5a85fa4760f62c5 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 25 May 2016 23:06:36 +0200 Subject: [PATCH 03/11] Draw 25 deg up --- src/ride/transport/monorail.c | 41 +++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index 7385d717f5..6aa6002812 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -29,6 +29,12 @@ enum SPR_MONORAIL_FLAT_SW_NE = 23231, SPR_MONORAIL_FLAT_NW_SE = 23232, + SPR_MONORAIL_25_DEG_UP_SW_NE = 23253, + SPR_MONORAIL_25_DEG_UP_NE_SW = 23255, + + SPR_MONORAIL_25_DEG_UP_NW_SE = 23259, + SPR_MONORAIL_25_DEG_UP_SE_NW = 23260, + SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0 = 23293, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_1 = 23294, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_2 = 23295, @@ -70,6 +76,13 @@ static const uint32 monorail_track_pieces_flat[4] = { SPR_MONORAIL_FLAT_NW_SE, }; +static const uint32 monorail_track_pieces_25_deg_up[4] = { + SPR_MONORAIL_25_DEG_UP_SW_NE, + SPR_MONORAIL_25_DEG_UP_NW_SE, + SPR_MONORAIL_25_DEG_UP_NE_SW, + SPR_MONORAIL_25_DEG_UP_SE_NW, +}; + static const uint32 ghost_train_track_pieces_right_eight_to_diag[4][4] = { { SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0, @@ -264,9 +277,32 @@ static void paint_monorail_station(uint8 rideIndex, uint8 trackSequence, uint8 d { } -/** rct2: 0x */ +/** rct2: 0x008AE1BC */ static void paint_monorail_track_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + + uint32 imageId = monorail_track_pieces_25_deg_up[direction] | RCT2_GLOBAL(0x00F44198, uint32); + + if (direction == 0 || direction == 2) { + sub_98196C(imageId, 0, 6, 32, 20, 3, height, get_current_rotation()); + } else { + sub_98196C(imageId, 6, 0, 20, 32, 3, height, get_current_rotation()); + } + + switch (direction) { + case 0: paint_util_push_tunnel_left(height - 8, TUNNEL_7); break; + case 1: paint_util_push_tunnel_right(height + 8, TUNNEL_8); break; + case 2: paint_util_push_tunnel_left(height + 8, TUNNEL_8); break; + case 3: paint_util_push_tunnel_right(height - 8, TUNNEL_7); break; + } + + if (track_paint_util_should_paint_supports(position)) { + metal_a_supports_paint_setup(3, 4, 8, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 56, 0x20); } /** rct2: 0x */ @@ -279,9 +315,10 @@ static void paint_monorail_track_25_deg_up_to_flat(uint8 rideIndex, uint8 trackS { } -/** rct2: 0x */ +/** rct2: 0x008AE1EC */ static void paint_monorail_track_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + paint_monorail_track_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); } /** rct2: 0x */ From 4c0ea515402211e801c94e4e28d39fd7c243a5c8 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 25 May 2016 23:18:52 +0200 Subject: [PATCH 04/11] Draw flat to 25 deg up --- src/ride/transport/monorail.c | 39 +++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index 6aa6002812..ff7b80d757 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -30,10 +30,14 @@ enum SPR_MONORAIL_FLAT_NW_SE = 23232, SPR_MONORAIL_25_DEG_UP_SW_NE = 23253, + SPR_MONORAIL_FLAT_TO_25_DEG_UP_SW_NE = 23254, SPR_MONORAIL_25_DEG_UP_NE_SW = 23255, + SPR_MONORAIL_FLAT_TO_25_DEG_UP_NE_SW = 23256, SPR_MONORAIL_25_DEG_UP_NW_SE = 23259, SPR_MONORAIL_25_DEG_UP_SE_NW = 23260, + SPR_MONORAIL_FLAT_TO_25_DEG_UP_NW_SE = 23261, + SPR_MONORAIL_FLAT_TO_25_DEG_UP_SE_NW = 23262, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0 = 23293, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_1 = 23294, @@ -83,6 +87,13 @@ static const uint32 monorail_track_pieces_25_deg_up[4] = { SPR_MONORAIL_25_DEG_UP_SE_NW, }; +static const uint32 monorail_track_pieces_flat_to_25_deg_up[4] = { + SPR_MONORAIL_FLAT_TO_25_DEG_UP_SW_NE, + SPR_MONORAIL_FLAT_TO_25_DEG_UP_NW_SE, + SPR_MONORAIL_FLAT_TO_25_DEG_UP_NE_SW, + SPR_MONORAIL_FLAT_TO_25_DEG_UP_SE_NW, +}; + static const uint32 ghost_train_track_pieces_right_eight_to_diag[4][4] = { { SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0, @@ -305,9 +316,32 @@ static void paint_monorail_track_25_deg_up(uint8 rideIndex, uint8 trackSequence, paint_util_set_general_support_height(height + 56, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE1CC */ static void paint_monorail_track_flat_to_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + + uint32 imageId = monorail_track_pieces_flat_to_25_deg_up[direction] | RCT2_GLOBAL(0x00F44198, uint32); + + if (direction == 0 || direction == 2) { + sub_98196C(imageId, 0, 6, 32, 20, 3, height, get_current_rotation()); + } else { + sub_98196C(imageId, 6, 0, 20, 32, 3, height, get_current_rotation()); + } + + switch (direction) { + case 0: paint_util_push_tunnel_left(height, TUNNEL_6); break; + case 1: paint_util_push_tunnel_right(height, TUNNEL_8); break; + case 2: paint_util_push_tunnel_left(height, TUNNEL_8); break; + case 3: paint_util_push_tunnel_right(height, TUNNEL_6); break; + } + + if (track_paint_util_should_paint_supports(position)) { + metal_a_supports_paint_setup(3, 4, 3, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 48, 0x20); } /** rct2: 0x */ @@ -326,9 +360,10 @@ static void paint_monorail_track_flat_to_25_deg_down(uint8 rideIndex, uint8 trac { } -/** rct2: 0x */ +/** rct2: 0x008AE20C */ static void paint_monorail_track_25_deg_down_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + paint_monorail_track_flat_to_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); } /** rct2: 0x */ From 45686c2ab217f4dddcc1c76f93a303a620113012 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 25 May 2016 23:25:11 +0200 Subject: [PATCH 05/11] Paint 25 deg up to flat --- src/ride/transport/monorail.c | 40 ++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index ff7b80d757..b3494231c3 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -33,11 +33,14 @@ enum SPR_MONORAIL_FLAT_TO_25_DEG_UP_SW_NE = 23254, SPR_MONORAIL_25_DEG_UP_NE_SW = 23255, SPR_MONORAIL_FLAT_TO_25_DEG_UP_NE_SW = 23256, - + SPR_MONORAIL_25_DEG_UP_TO_FLAT_NE_SW = 23257, + SPR_MONORAIL_25_DEG_UP_TO_FLAT_SW_NE = 23258, SPR_MONORAIL_25_DEG_UP_NW_SE = 23259, SPR_MONORAIL_25_DEG_UP_SE_NW = 23260, SPR_MONORAIL_FLAT_TO_25_DEG_UP_NW_SE = 23261, SPR_MONORAIL_FLAT_TO_25_DEG_UP_SE_NW = 23262, + SPR_MONORAIL_25_DEG_UP_TO_FLAT_SE_NW = 23263, + SPR_MONORAIL_25_DEG_UP_TO_FLAT_NW_SE = 23264, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0 = 23293, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_1 = 23294, @@ -94,6 +97,13 @@ static const uint32 monorail_track_pieces_flat_to_25_deg_up[4] = { SPR_MONORAIL_FLAT_TO_25_DEG_UP_SE_NW, }; +static const uint32 monorail_track_pieces_25_deg_up_to_flat[4] = { + SPR_MONORAIL_25_DEG_UP_TO_FLAT_SW_NE, + SPR_MONORAIL_25_DEG_UP_TO_FLAT_NW_SE, + SPR_MONORAIL_25_DEG_UP_TO_FLAT_NE_SW, + SPR_MONORAIL_25_DEG_UP_TO_FLAT_SE_NW, +}; + static const uint32 ghost_train_track_pieces_right_eight_to_diag[4][4] = { { SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0, @@ -344,9 +354,32 @@ static void paint_monorail_track_flat_to_25_deg_up(uint8 rideIndex, uint8 trackS paint_util_set_general_support_height(height + 48, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE1DC */ static void paint_monorail_track_25_deg_up_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + + uint32 imageId = monorail_track_pieces_25_deg_up_to_flat[direction] | RCT2_GLOBAL(0x00F44198, uint32); + + if (direction == 0 || direction == 2) { + sub_98196C(imageId, 0, 6, 32, 20, 3, height, get_current_rotation()); + } else { + sub_98196C(imageId, 6, 0, 20, 32, 3, height, get_current_rotation()); + } + + switch (direction) { + case 0: paint_util_push_tunnel_left(height - 8, TUNNEL_6); break; + case 1: paint_util_push_tunnel_right(height + 8, TUNNEL_14); break; + case 2: paint_util_push_tunnel_left(height + 8, TUNNEL_14); break; + case 3: paint_util_push_tunnel_right(height - 8, TUNNEL_6); break; + } + + if (track_paint_util_should_paint_supports(position)) { + metal_a_supports_paint_setup(3, 4, 6, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + paint_util_set_segment_support_height(paint_util_rotate_segments(SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 40, 0x20); } /** rct2: 0x008AE1EC */ @@ -355,9 +388,10 @@ static void paint_monorail_track_25_deg_down(uint8 rideIndex, uint8 trackSequenc paint_monorail_track_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); } -/** rct2: 0x */ +/** rct2: 0x008AE1FC */ static void paint_monorail_track_flat_to_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + paint_monorail_track_25_deg_up_to_flat(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); } /** rct2: 0x008AE20C */ From 7d5f842d0f5353d7ac3dcf17bb48fc6cfab01424 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 25 May 2016 23:50:27 +0200 Subject: [PATCH 06/11] Paint 5-tile turn --- src/ride/gentle/monorail_cycles.c | 7 +- src/ride/track_paint.c | 117 ++++++++++++++++++------------ src/ride/track_paint.h | 6 +- src/ride/transport/monorail.c | 96 +++++++++++++++++++++++- 4 files changed, 172 insertions(+), 54 deletions(-) diff --git a/src/ride/gentle/monorail_cycles.c b/src/ride/gentle/monorail_cycles.c index fd6e046352..a2f9b9a989 100644 --- a/src/ride/gentle/monorail_cycles.c +++ b/src/ride/gentle/monorail_cycles.c @@ -283,8 +283,7 @@ static const sint8 monorail_cycles_track_right_quarter_turn_5_tiles_support_spec /** rct2: 0x0088ADB8 */ static void paint_monorail_cycles_track_right_quarter_turn_5_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - track_paint_util_right_quarter_turn_5_tiles_paint(1, height, direction, trackSequence, RCT2_GLOBAL(0x00F44198, uint32), monorail_cycles_track_pieces_flat_quarter_turn_5_tiles, get_current_rotation()); - + track_paint_util_right_quarter_turn_5_tiles_paint(1, height, direction, trackSequence, RCT2_GLOBAL(0x00F44198, uint32), monorail_cycles_track_pieces_flat_quarter_turn_5_tiles, NULL, defaultRightQuarterTurn5TilesBoundLengths, defaultRightQuarterTurn5TilesOffsets, get_current_rotation()); int supportHeight = height + monorail_cycles_track_right_quarter_turn_5_tiles_support_height_offset[direction][trackSequence]; int supportSpecial = monorail_cycles_track_right_quarter_turn_5_tiles_support_special[direction][trackSequence]; @@ -336,12 +335,10 @@ static void paint_monorail_cycles_track_right_quarter_turn_5_tiles(uint8 rideInd paint_util_set_general_support_height(height + 32, 0x20); } -static const uint8 left_quarter_turn_5_tiles_to_right_turn_map[] = {6, 4, 5, 3, 1, 2, 0}; - /** rct2: 0x0088ADA8 */ static void paint_monorail_cycles_track_left_quarter_turn_5_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - trackSequence = left_quarter_turn_5_tiles_to_right_turn_map[trackSequence]; + trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; paint_monorail_cycles_track_right_quarter_turn_5_tiles(rideIndex, trackSequence, (direction + 1) % 4, height, mapElement); } diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 3bc377d454..a28a22082c 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -551,57 +551,84 @@ void track_paint_util_draw_pier(rct_ride * ride, const rct_ride_entrance_definit } } +const uint8 mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[] = {6, 4, 5, 3, 1, 2, 0}; + +const rct_xy16 defaultRightQuarterTurn5TilesOffsets[4][5] = { + { + {0, 6}, + {0, 16}, + {0, 0}, + {16, 0}, + {6, 0}, + }, + { + {6, 0}, + {16, 0}, + {0, 16}, + {0, 0}, + {0, 6}, + }, + { + {0, 6}, + {0, 0}, + {16, 16}, + {0, 0}, + {6, 0}, + }, + { + {6, 0}, + {0, 0}, + {16, 0}, + {0, 16}, + {0, 6}, + } +}; + +const rct_xy16 defaultRightQuarterTurn5TilesBoundLengths[4][5] = { + { + {32, 20}, + {32, 16}, + {16, 16}, + {16, 32}, + {20, 32}, + }, + { + {20, 32}, + {16, 32}, + {16, 16}, + {32, 16}, + {32, 20}, + }, + { + {32, 20}, + {32, 16}, + {16, 16}, + {16, 32}, + {20, 32}, + }, + { + {20, 32}, + {16, 32}, + {16, 16}, + {32, 16}, + {32, 20}, + } +}; + static const sint8 right_quarter_turn_5_tiles_sprite_map[] = {0, -1, 1, 2, -1, 3, 4}; -void track_paint_util_right_quarter_turn_5_tiles_paint(sint8 thickness, sint16 height, int direction, uint8 trackSequence, uint32 colourFlags, const uint32 sprites[4][5], uint8 rotation) +void track_paint_util_right_quarter_turn_5_tiles_paint(sint8 thickness, sint16 height, int direction, uint8 trackSequence, uint32 colourFlags, const uint32 sprites[4][5], const rct_xy16 offsets[4][5], const rct_xy16 boundsLengths[4][5], const rct_xy16 boundsOffsets[4][5], uint8 rotation) { - sint8 sprite = right_quarter_turn_5_tiles_sprite_map[trackSequence]; - if (sprite < 0) { + int index = right_quarter_turn_5_tiles_sprite_map[trackSequence]; + if (index < 0) { return; } - uint32 imageId = sprites[direction][sprite] | colourFlags; + uint32 imageId = sprites[direction][index] | colourFlags; + rct_xy16 offset = (offsets == NULL ? (rct_xy16){0, 0} : offsets[direction][index]); + rct_xy16 boundsLength = boundsLengths[direction][index]; + rct_xy16 boundsOffset = (boundsOffsets == NULL ? offset : boundsOffsets[direction][index]); - switch (direction) { - case 0: - switch (trackSequence) { - case 0: sub_98197C(imageId, 0, 0, 32, 20, thickness, height, 0, 6, height, rotation); break; - case 2: sub_98197C(imageId, 0, 0, 32, 16, thickness, height, 0, 16, height, rotation); break; - case 3: sub_98197C(imageId, 0, 0, 16, 16, thickness, height, 0, 0, height, rotation); break; - case 5: sub_98197C(imageId, 0, 0, 16, 32, thickness, height, 16, 0, height, rotation); break; - case 6: sub_98197C(imageId, 0, 0, 20, 32, thickness, height, 6, 0, height, rotation); break; - } - break; - - case 1: - switch (trackSequence) { - case 0: sub_98197C(imageId, 0, 0, 20, 32, thickness, height, 6, 0, height, rotation); break; - case 2: sub_98197C(imageId, 0, 0, 16, 32, thickness, height, 16, 0, height, rotation); break; - case 3: sub_98197C(imageId, 0, 0, 16, 16, thickness, height, 0, 16, height, rotation); break; - case 5: sub_98197C(imageId, 0, 0, 32, 16, thickness, height, 0, 0, height, rotation); break; - case 6: sub_98197C(imageId, 0, 0, 32, 20, thickness, height, 0, 6, height, rotation); break; - } - break; - - case 2: - switch (trackSequence) { - case 0: sub_98197C(imageId, 0, 0, 32, 20, thickness, height, 0, 6, height, rotation); break; - case 2: sub_98197C(imageId, 0, 0, 32, 16, thickness, height, 0, 0, height, rotation); break; - case 3: sub_98197C(imageId, 0, 0, 16, 16, thickness, height, 16, 16, height, rotation); break; - case 5: sub_98197C(imageId, 0, 0, 20, 32, thickness, height, 0, 0, height, rotation); break; - case 6: sub_98197C(imageId, 0, 0, 20, 32, thickness, height, 6, 0, height, rotation); break; - } - break; - - case 3: - switch (trackSequence) { - case 0: sub_98197C(imageId, 0, 0, 20, 32, thickness, height, 6, 0, height, rotation); break; - case 2: sub_98197C(imageId, 0, 0, 16, 32, thickness, height, 0, 0, height, rotation); break; - case 3: sub_98197C(imageId, 0, 0, 16, 16, thickness, height, 16, 0, height, rotation); break; - case 5: sub_98197C(imageId, 0, 0, 32, 16, thickness, height, 0, 16, height, rotation); break; - case 6: sub_98197C(imageId, 0, 0, 32, 20, thickness, height, 0, 6, height, rotation); break; - } - break; - } + sub_98197C(imageId, (sint8) offset.x, (sint8) offset.y, boundsLength.x, boundsLength.y, thickness, height, boundsOffset.x, boundsOffset.y, height, rotation); } void track_paint_util_right_quarter_turn_5_tiles_paint_2(sint16 height, int direction, uint8 rotation, uint8 trackSequence, uint32 colourFlags, const sprite_bb sprites[][5]) diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 725ce3d74b..4aaf1efd89 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -179,6 +179,10 @@ extern const uint32 fenceSpritesMetalB[]; extern const uint32 trackSpritesSubmarineRideMiniHelicoptersQuarterTurn3Tiles[4][3]; extern const uint32 trackSpritesSubmarineRideMiniHelicoptersQuarterTurn1Tile[4]; +extern const uint8 mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[]; +extern const rct_xy16 defaultRightQuarterTurn5TilesOffsets[4][5]; +extern const rct_xy16 defaultRightQuarterTurn5TilesBoundLengths[4][5]; + extern const uint8 mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[]; extern const rct_xy16 defaultRightQuarterTurn3TilesOffsets[4][3]; extern const rct_xy16 defaultRightQuarterTurn3TilesBoundLengths[4][3]; @@ -194,7 +198,7 @@ void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 d bool track_paint_util_should_paint_supports(rct_xy16 position); void track_paint_util_draw_pier(rct_ride * ride, const rct_ride_entrance_definition * entranceStyle, rct_xy16 position, uint8 direction, int height, rct_map_element * mapElement, uint8 rotation); -void track_paint_util_right_quarter_turn_5_tiles_paint(sint8 thickness, sint16 height, int direction, uint8 trackSequence, uint32 colourFlags, const uint32 sprites[4][5], uint8 rotation); +void track_paint_util_right_quarter_turn_5_tiles_paint(sint8 thickness, sint16 height, int direction, uint8 trackSequence, uint32 colourFlags, const uint32 sprites[4][5], const rct_xy16 offsets[4][5], const rct_xy16 boundsLengths[4][5], const rct_xy16 boundsOffsets[4][5], uint8 rotation); void track_paint_util_right_quarter_turn_5_tiles_paint_2(sint16 height, int direction, uint8 rotation, uint8 trackSequence, uint32 colourFlags, const sprite_bb sprites[][5]); void track_paint_util_right_quarter_turn_3_tiles_paint(sint8 thickness, sint16 height, int direction, uint8 trackSequence, uint32 colourFlags, const uint32 sprites[4][3], const rct_xy16 offsets[4][3], const rct_xy16 boundsLengths[4][3], const rct_xy16 boundsOffsets[4][3], uint8 rotation); void track_paint_util_right_quarter_turn_3_tiles_tunnel(sint16 height, uint8 direction, uint8 trackSequence); diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index b3494231c3..1e2eda8ccf 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -28,7 +28,26 @@ enum { SPR_MONORAIL_FLAT_SW_NE = 23231, SPR_MONORAIL_FLAT_NW_SE = 23232, - + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_0 = 23233, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_1 = 23234, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_2 = 23235, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_3 = 23236, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_4 = 23237, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_0 = 23238, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_1 = 23239, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_2 = 23240, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_3 = 23241, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_4 = 23242, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_0 = 23243, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_1 = 23244, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_2 = 23245, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_3 = 23246, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_4 = 23247, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_0 = 23248, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_1 = 23249, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_2 = 23250, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_3 = 23251, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_4 = 23252, SPR_MONORAIL_25_DEG_UP_SW_NE = 23253, SPR_MONORAIL_FLAT_TO_25_DEG_UP_SW_NE = 23254, SPR_MONORAIL_25_DEG_UP_NE_SW = 23255, @@ -83,6 +102,37 @@ static const uint32 monorail_track_pieces_flat[4] = { SPR_MONORAIL_FLAT_NW_SE, }; +static const uint32 monorail_track_pieces_flat_quarter_turn_5_tiles[4][5] = { + { + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_0, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_1, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_2, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_3, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SW_SE_PART_4, + }, + { + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_0, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_1, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_2, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_3, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NW_SW_PART_4, + }, + { + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_0, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_1, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_2, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_3, + SPR_MONORAIL_QUARTER_TURN_5_TILES_NE_NW_PART_4, + }, + { + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_0, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_1, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_2, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_3, + SPR_MONORAIL_QUARTER_TURN_5_TILES_SE_NE_PART_4, + } +}; + static const uint32 monorail_track_pieces_25_deg_up[4] = { SPR_MONORAIL_25_DEG_UP_SW_NE, SPR_MONORAIL_25_DEG_UP_NW_SE, @@ -400,14 +450,54 @@ static void paint_monorail_track_25_deg_down_to_flat(uint8 rideIndex, uint8 trac paint_monorail_track_flat_to_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); } -/** rct2: 0x */ +/** rct2: 0x008AE22C */ static void paint_monorail_track_right_quarter_turn_5_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + track_paint_util_right_quarter_turn_5_tiles_paint(3, height, direction, trackSequence, RCT2_GLOBAL(0x00F44198, uint32), monorail_track_pieces_flat_quarter_turn_5_tiles, defaultRightQuarterTurn5TilesOffsets, defaultRightQuarterTurn5TilesBoundLengths, NULL, get_current_rotation()); + + switch (trackSequence) { + case 0: + case 6: + metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + } + + if (direction == 0 && trackSequence == 0) { + paint_util_push_tunnel_left(height, TUNNEL_6); + } + + if (direction == 0 && trackSequence == 6) { + paint_util_push_tunnel_right(height, TUNNEL_6); + } + + if (direction == 1 && trackSequence == 6) { + paint_util_push_tunnel_left(height, TUNNEL_6); + } + + if (direction == 3 && trackSequence == 0) { + paint_util_push_tunnel_right(height, TUNNEL_6); + } + + int blockedSegments = 0; + switch (trackSequence) { + case 0: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_BC; break; + case 2: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_D4 | SEGMENT_BC | SEGMENT_C0 | SEGMENT_CC; break; + case 3: blockedSegments = SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_C4; break; + case 5: blockedSegments = SEGMENT_D4 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C8; break; + case 6: blockedSegments = SEGMENT_D4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_B8; break; + } + + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + + + paint_util_set_general_support_height(height + 32, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE21C */ static void paint_monorail_track_left_quarter_turn_5_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence]; + paint_monorail_track_right_quarter_turn_5_tiles(rideIndex, trackSequence, (direction + 1) % 4, height, mapElement); } /** rct2: 0x */ From 23a9cdb6ce6e7fb2c5419540d7e895217844ecd7 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 26 May 2016 00:00:23 +0200 Subject: [PATCH 07/11] Draw 3-tile turns --- src/ride/gentle/car_ride.c | 2 +- src/ride/gentle/ghost_train.c | 2 +- src/ride/track_paint.c | 10 +++--- src/ride/track_paint.h | 2 +- src/ride/transport/monorail.c | 61 +++++++++++++++++++++++++++++++++-- 5 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/ride/gentle/car_ride.c b/src/ride/gentle/car_ride.c index 04cc64343e..143fd64b59 100644 --- a/src/ride/gentle/car_ride.c +++ b/src/ride/gentle/car_ride.c @@ -338,7 +338,7 @@ static void paint_car_ride_station(uint8 rideIndex, uint8 trackSequence, uint8 d static void paint_car_ride_track_right_quarter_turn_3_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { track_paint_util_right_quarter_turn_3_tiles_paint(3, height, direction, trackSequence, RCT2_GLOBAL(0x00F44198, uint32), car_ride_track_pieces_quarter_turn_3_tiles, defaultRightQuarterTurn3TilesOffsets, defaultRightQuarterTurn3TilesBoundLengths, NULL, get_current_rotation()); - track_paint_util_right_quarter_turn_3_tiles_tunnel(height, direction, trackSequence); + track_paint_util_right_quarter_turn_3_tiles_tunnel(height, direction, trackSequence, TUNNEL_0); switch (trackSequence) { case 0: diff --git a/src/ride/gentle/ghost_train.c b/src/ride/gentle/ghost_train.c index 1b1071799e..9c26d614fd 100644 --- a/src/ride/gentle/ghost_train.c +++ b/src/ride/gentle/ghost_train.c @@ -362,7 +362,7 @@ static void paint_ghost_train_station(uint8 rideIndex, uint8 trackSequence, uint static void paint_ghost_train_track_right_quarter_turn_3_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { track_paint_util_right_quarter_turn_3_tiles_paint(3, height, direction, trackSequence, RCT2_GLOBAL(0x00F44198, uint32), ghost_train_track_pieces_quarter_turn_3_tiles, NULL, defaultRightQuarterTurn3TilesBoundLengths, defaultRightQuarterTurn3TilesOffsets, get_current_rotation()); - track_paint_util_right_quarter_turn_3_tiles_tunnel(height, direction, trackSequence); + track_paint_util_right_quarter_turn_3_tiles_tunnel(height, direction, trackSequence, TUNNEL_0); switch (trackSequence) { case 0: diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index a28a22082c..8e6d20c3cd 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -712,24 +712,24 @@ void track_paint_util_right_quarter_turn_3_tiles_paint(sint8 thickness, sint16 h sub_98197C(imageId, (sint8) offset.x, (sint8) offset.y, boundsLength.x, boundsLength.y, thickness, height, boundsOffset.x, boundsOffset.y, height, rotation); } -void track_paint_util_right_quarter_turn_3_tiles_tunnel(sint16 height, uint8 direction, uint8 trackSequence) +void track_paint_util_right_quarter_turn_3_tiles_tunnel(sint16 height, uint8 direction, uint8 trackSequence, uint8 tunnelType) { if (direction == 0 && trackSequence == 0) { - paint_util_push_tunnel_left(height, TUNNEL_0); + paint_util_push_tunnel_left(height, tunnelType); } if (direction == 0 && trackSequence == 3) { - paint_util_push_tunnel_right(height, TUNNEL_0); + paint_util_push_tunnel_right(height, tunnelType); } if (direction == 1 && trackSequence == 3) { - paint_util_push_tunnel_left(height, TUNNEL_0); + paint_util_push_tunnel_left(height, tunnelType); } if (direction == 3 && trackSequence == 0) { - paint_util_push_tunnel_left(height, TUNNEL_0); + paint_util_push_tunnel_right(height, tunnelType); } } diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 4aaf1efd89..be522c3a93 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -201,7 +201,7 @@ void track_paint_util_draw_pier(rct_ride * ride, const rct_ride_entrance_definit void track_paint_util_right_quarter_turn_5_tiles_paint(sint8 thickness, sint16 height, int direction, uint8 trackSequence, uint32 colourFlags, const uint32 sprites[4][5], const rct_xy16 offsets[4][5], const rct_xy16 boundsLengths[4][5], const rct_xy16 boundsOffsets[4][5], uint8 rotation); void track_paint_util_right_quarter_turn_5_tiles_paint_2(sint16 height, int direction, uint8 rotation, uint8 trackSequence, uint32 colourFlags, const sprite_bb sprites[][5]); void track_paint_util_right_quarter_turn_3_tiles_paint(sint8 thickness, sint16 height, int direction, uint8 trackSequence, uint32 colourFlags, const uint32 sprites[4][3], const rct_xy16 offsets[4][3], const rct_xy16 boundsLengths[4][3], const rct_xy16 boundsOffsets[4][3], uint8 rotation); -void track_paint_util_right_quarter_turn_3_tiles_tunnel(sint16 height, uint8 direction, uint8 trackSequence); +void track_paint_util_right_quarter_turn_3_tiles_tunnel(sint16 height, uint8 direction, uint8 trackSequence, uint8 tunnelType); void track_paint_util_left_quarter_turn_3_tiles_paint(sint8 thickness, sint16 height, int direction, uint8 trackSequence, uint32 colourFlags, const uint32 sprites[4][3], uint8 rotation); void track_paint_util_left_quarter_turn_3_tiles_tunnel(sint16 height, uint8 direction, uint8 trackSequence); void track_paint_util_left_quarter_turn_1_tile_paint(sint8 thickness, sint16 height, sint16 boundBoxZOffset, int direction, uint32 colourFlags, const uint32 * sprites, uint8 rotation); diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index 1e2eda8ccf..25ccd3436b 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -61,6 +61,18 @@ enum SPR_MONORAIL_25_DEG_UP_TO_FLAT_SE_NW = 23263, SPR_MONORAIL_25_DEG_UP_TO_FLAT_NW_SE = 23264, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_0 = 23281, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_1 = 23282, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_2 = 23283, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NW_SW_PART_0 = 23284, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NW_SW_PART_1 = 23285, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NW_SW_PART_2 = 23286, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NE_NW_PART_0 = 23287, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NE_NW_PART_1 = 23288, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NE_NW_PART_2 = 23289, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SE_NE_PART_0 = 23290, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SE_NE_PART_1 = 23291, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SE_NE_PART_2 = 23292, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0 = 23293, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_1 = 23294, SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_2 = 23295, @@ -154,6 +166,29 @@ static const uint32 monorail_track_pieces_25_deg_up_to_flat[4] = { SPR_MONORAIL_25_DEG_UP_TO_FLAT_SE_NW, }; +static const uint32 monorail_track_pieces_flat_quarter_turn_3_tiles[4][3] = { + { + SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_0, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_1, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_2 + }, + { + SPR_MONORAIL_QUARTER_TURN_3_TILES_NW_SW_PART_0, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NW_SW_PART_1, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NW_SW_PART_2 + }, + { + SPR_MONORAIL_QUARTER_TURN_3_TILES_NE_NW_PART_0, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NE_NW_PART_1, + SPR_MONORAIL_QUARTER_TURN_3_TILES_NE_NW_PART_2 + }, + { + SPR_MONORAIL_QUARTER_TURN_3_TILES_SE_NE_PART_0, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SE_NE_PART_1, + SPR_MONORAIL_QUARTER_TURN_3_TILES_SE_NE_PART_2 + } +}; + static const uint32 ghost_train_track_pieces_right_eight_to_diag[4][4] = { { SPR_MONORAIL_EIGHT_TO_DIAG_SW_E_PART_0, @@ -510,14 +545,34 @@ static void paint_monorail_track_s_bend_right(uint8 rideIndex, uint8 trackSequen { } -/** rct2: 0x */ +/** rct2: 0x008AE29C */ static void paint_monorail_track_right_quarter_turn_3_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + track_paint_util_right_quarter_turn_3_tiles_paint(3, height, direction, trackSequence, RCT2_GLOBAL(0x00F44198, uint32), monorail_track_pieces_flat_quarter_turn_3_tiles, defaultRightQuarterTurn3TilesOffsets, defaultRightQuarterTurn3TilesBoundLengths, NULL, get_current_rotation()); + track_paint_util_right_quarter_turn_3_tiles_tunnel(height, direction, trackSequence, TUNNEL_6); + + switch (trackSequence) { + case 0: + case 3: + metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + } + + int blockedSegments = 0; + switch (trackSequence) { + case 0: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_BC; break; + case 2: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_D4 | SEGMENT_C0; break; + case 3: blockedSegments = SEGMENT_D4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_B8; break; + } + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + + paint_util_set_general_support_height(height + 32, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE28C */ static void paint_monorail_track_left_quarter_turn_3_tiles(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) -{ +{trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence]; + paint_monorail_track_right_quarter_turn_3_tiles(rideIndex, trackSequence, (direction + 1) % 4, height, mapElement); } static const sint8 paint_monorail_eighth_to_diag_index[] = {0, 1, 2, -1, 3}; From dbb4933c635b1ebfcf1dbf09c85c785e9fbfb846 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 26 May 2016 00:18:15 +0200 Subject: [PATCH 08/11] Draw S-bends --- src/ride/transport/monorail.c | 165 +++++++++++++++++++++++++++++++++- 1 file changed, 164 insertions(+), 1 deletion(-) diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index 25ccd3436b..906933e2cd 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -60,7 +60,22 @@ enum SPR_MONORAIL_FLAT_TO_25_DEG_UP_SE_NW = 23262, SPR_MONORAIL_25_DEG_UP_TO_FLAT_SE_NW = 23263, SPR_MONORAIL_25_DEG_UP_TO_FLAT_NW_SE = 23264, - + SPR_MONORAIL_S_BEND_RIGHT_SW_NE_PART_0 = 23265, + SPR_MONORAIL_S_BEND_RIGHT_SW_NE_PART_1 = 23266, + SPR_MONORAIL_S_BEND_RIGHT_SW_NE_PART_2 = 23267, + SPR_MONORAIL_S_BEND_RIGHT_SW_NE_PART_3 = 23268, + SPR_MONORAIL_S_BEND_LEFT_SW_NE_PART_0 = 23269, + SPR_MONORAIL_S_BEND_LEFT_SW_NE_PART_1 = 23270, + SPR_MONORAIL_S_BEND_LEFT_SW_NE_PART_2 = 23271, + SPR_MONORAIL_S_BEND_LEFT_SW_NE_PART_3 = 23272, + SPR_MONORAIL_S_BEND_LEFT_SE_NW_PART_0 = 23273, + SPR_MONORAIL_S_BEND_LEFT_SE_NW_PART_1 = 23274, + SPR_MONORAIL_S_BEND_LEFT_SE_NW_PART_2 = 23275, + SPR_MONORAIL_S_BEND_LEFT_SE_NW_PART_3 = 23276, + SPR_MONORAIL_S_BEND_RIGHT_SE_NW_PART_0 = 23277, + SPR_MONORAIL_S_BEND_RIGHT_SE_NW_PART_1 = 23278, + SPR_MONORAIL_S_BEND_RIGHT_SE_NW_PART_2 = 23279, + SPR_MONORAIL_S_BEND_RIGHT_SE_NW_PART_3 = 23280, SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_0 = 23281, SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_1 = 23282, SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_2 = 23283, @@ -166,6 +181,36 @@ static const uint32 monorail_track_pieces_25_deg_up_to_flat[4] = { SPR_MONORAIL_25_DEG_UP_TO_FLAT_SE_NW, }; +static const uint32 monorail_track_pieces_s_bend_left[2][4] = { + { + SPR_MONORAIL_S_BEND_LEFT_SW_NE_PART_0, + SPR_MONORAIL_S_BEND_LEFT_SW_NE_PART_1, + SPR_MONORAIL_S_BEND_LEFT_SW_NE_PART_2, + SPR_MONORAIL_S_BEND_LEFT_SW_NE_PART_3, + }, + { + SPR_MONORAIL_S_BEND_LEFT_SE_NW_PART_3, + SPR_MONORAIL_S_BEND_LEFT_SE_NW_PART_2, + SPR_MONORAIL_S_BEND_LEFT_SE_NW_PART_1, + SPR_MONORAIL_S_BEND_LEFT_SE_NW_PART_0, + } +}; + +static const uint32 monorail_track_pieces_s_bend_right[2][4] = { + { + SPR_MONORAIL_S_BEND_RIGHT_SW_NE_PART_0, + SPR_MONORAIL_S_BEND_RIGHT_SW_NE_PART_1, + SPR_MONORAIL_S_BEND_RIGHT_SW_NE_PART_2, + SPR_MONORAIL_S_BEND_RIGHT_SW_NE_PART_3, + }, + { + SPR_MONORAIL_S_BEND_RIGHT_SE_NW_PART_3, + SPR_MONORAIL_S_BEND_RIGHT_SE_NW_PART_2, + SPR_MONORAIL_S_BEND_RIGHT_SE_NW_PART_1, + SPR_MONORAIL_S_BEND_RIGHT_SE_NW_PART_0, + } +}; + static const uint32 monorail_track_pieces_flat_quarter_turn_3_tiles[4][3] = { { SPR_MONORAIL_QUARTER_TURN_3_TILES_SW_SE_PART_0, @@ -538,11 +583,129 @@ static void paint_monorail_track_left_quarter_turn_5_tiles(uint8 rideIndex, uint /** rct2: 0x */ static void paint_monorail_track_s_bend_left(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + if (direction == 2 || direction == 3) { + trackSequence = 3 - trackSequence; + } + + const rct_xy16 offsetList[] = { + {0, 6}, + {0, 0}, + {0, 6}, + {0, 6}, + }; + + const rct_xy16 boundsList[] = { + {32, 20}, + {32, 26}, + {32, 26}, + {32, 20}, + }; + + uint32 imageId = monorail_track_pieces_s_bend_left[direction & 1][trackSequence] | RCT2_GLOBAL(0x00F44198, uint32); + rct_xy16 offset = offsetList[trackSequence]; + rct_xy16 bounds = boundsList[trackSequence]; + if (direction == 0 || direction == 2) { + sub_98196C(imageId, (sint8) offset.x, (sint8) offset.y, bounds.x, bounds.y, 3, height, get_current_rotation()); + } else { + sub_98196C(imageId, (sint8) offset.y, (sint8) offset.x, bounds.y, bounds.x, 3, height, get_current_rotation()); + } + + if (direction == 0 || direction == 2) { + if (trackSequence == 0) { + paint_util_push_tunnel_left(height, TUNNEL_6); + } + + switch (trackSequence) { + case 0: metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 1: metal_a_supports_paint_setup(3, 5, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 3: metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + } + } else { + if (trackSequence == 3) { + paint_util_push_tunnel_right(height, TUNNEL_6); + } + + switch (trackSequence) { + case 0: metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 1: metal_a_supports_paint_setup(3, 6, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 3: metal_a_supports_paint_setup(3, 4, 0, height - 2, RCT2_GLOBAL(0x00F4419C, uint32)); break; + } + } + + int blockedSegments = 0; + switch (trackSequence) { + case 0: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_B4; break; + case 1: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_B8 | SEGMENT_C8 | SEGMENT_B4; break; + case 2: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_C0 | SEGMENT_D4 | SEGMENT_BC; break; + case 3: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_C0; break; + } + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction & 1), 0xFFFF, 0); + + paint_util_set_general_support_height(height + 32, 0x20); } /** rct2: 0x */ static void paint_monorail_track_s_bend_right(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + if (direction == 2 || direction == 3) { + trackSequence = 3 - trackSequence; + } + + const rct_xy16 offsetList[] = { + {0, 6}, + {0, 6}, + {0, 0}, + {0, 6}, + }; + + const rct_xy16 boundsList[] = { + {32, 20}, + {32, 26}, + {32, 26}, + {32, 20}, + }; + + uint32 imageId = monorail_track_pieces_s_bend_right[direction&1][trackSequence] | RCT2_GLOBAL(0x00F44198, uint32); + rct_xy16 offset = offsetList[trackSequence]; + rct_xy16 bounds = boundsList[trackSequence]; + if (direction == 0 || direction == 2) { + sub_98196C(imageId, (sint8) offset.x, (sint8) offset.y, bounds.x, bounds.y, 3, height, get_current_rotation()); + } else { + sub_98196C(imageId, (sint8) offset.y, (sint8) offset.x, bounds.y, bounds.x, 3, height, get_current_rotation()); + } + + if (direction == 0 || direction == 2) { + if (trackSequence == 0) { + paint_util_push_tunnel_left(height, TUNNEL_6); + } + + switch (trackSequence) { + case 0: metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 1: metal_a_supports_paint_setup(3, 8, 0, height - 2, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 3: metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + } + } else { + if (trackSequence == 3) { + paint_util_push_tunnel_right(height, TUNNEL_6); + } + + switch (trackSequence) { + case 0: metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 1: metal_a_supports_paint_setup(3, 7, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 3: metal_a_supports_paint_setup(3, 4, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + } + } + + int blockedSegments = 0; + switch (trackSequence) { + case 0: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_BC; break; + case 1: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_C0 | SEGMENT_D4 | SEGMENT_BC; break; + case 2: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_B8 | SEGMENT_C8 | SEGMENT_B4; break; + case 3: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_B8; break; + } + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction & 1), 0xFFFF, 0); + + paint_util_set_general_support_height(height + 32, 0x20); } /** rct2: 0x008AE29C */ From abdf86c6fb1fdcb2478ac8f51eb95e9e5ca6b5a3 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 26 May 2016 11:19:03 +0200 Subject: [PATCH 09/11] Draw flat diagonal --- src/ride/transport/monorail.c | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index 906933e2cd..b257dddc29 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -120,6 +120,10 @@ enum SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_1 = 23322, SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_2 = 23323, SPR_MONORAIL_EIGHT_TO_DIAG_SE_W_PART_3 = 23324, + SPR_MONORAIL_DIAG_FLAT_W_E = 23325, + SPR_MONORAIL_DIAG_FLAT_N_S = 23326, + SPR_MONORAIL_DIAG_FLAT_E_W = 23327, + SPR_MONORAIL_DIAG_FLAT_S_N = 23328, }; static const uint32 monorail_track_pieces_flat[4] = { @@ -396,6 +400,13 @@ static const rct_xy16 ghost_train_track_pieces_left_eight_to_diag_offset[4][4] = }, }; +static const uint32 monorail_track_pieces_diag_flat[4] = { + SPR_MONORAIL_DIAG_FLAT_W_E, + SPR_MONORAIL_DIAG_FLAT_N_S, + SPR_MONORAIL_DIAG_FLAT_E_W, + SPR_MONORAIL_DIAG_FLAT_S_N, +}; + /** rct2: 0x008AE1AC */ static void paint_monorail_track_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { @@ -644,7 +655,7 @@ static void paint_monorail_track_s_bend_left(uint8 rideIndex, uint8 trackSequenc paint_util_set_general_support_height(height + 32, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE24C */ static void paint_monorail_track_s_bend_right(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { if (direction == 2 || direction == 3) { @@ -844,9 +855,36 @@ static void paint_monorail_track_right_eighth_to_orthogonal(uint8 rideIndex, uin paint_monorail_track_left_eighth_to_diag(rideIndex, trackSequence, (direction + 3) % 4, height, mapElement); } -/** rct2: 0x */ +/** rct2: 0x008AE2AC */ static void paint_monorail_track_diag_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + if ((direction == 0 && trackSequence == 1) + || (direction == 1 && trackSequence == 3) + || (direction == 2 && trackSequence == 2) + || (direction == 3 && trackSequence == 0)) { + uint32 imageId = monorail_track_pieces_diag_flat[direction] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, -16, -16, 32, 32, 2, height, -16, -16, height, get_current_rotation()); + } + + if (trackSequence == 3) { + switch (direction) { + case 0: metal_a_supports_paint_setup(3, 1, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 1: metal_a_supports_paint_setup(3, 0, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 2: metal_a_supports_paint_setup(3, 2, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + case 3: metal_a_supports_paint_setup(3, 3, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; + } + } + + int blockedSegments; + switch (trackSequence) { + case 0: blockedSegments = SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4 | SEGMENT_BC; break; + case 1: blockedSegments = SEGMENT_C4 | SEGMENT_CC | SEGMENT_C8 | SEGMENT_B4; break; + case 2: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_C0 | SEGMENT_D4; break; + case 3: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_B8 | SEGMENT_C8; break; + } + + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); } /** rct2: 0x */ From 9089a9d560ca1941dc413ef5d2c1e549f137d52c Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 26 May 2016 11:52:52 +0200 Subject: [PATCH 10/11] Paint other diagonal tracks --- src/paint/supports.c | 4 +- src/paint/supports.h | 2 + src/ride/transport/monorail.c | 172 +++++++++++++++++++++++++++++----- 3 files changed, 152 insertions(+), 26 deletions(-) diff --git a/src/paint/supports.c b/src/paint/supports.c index 15af70c17a..cbc676416f 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -509,9 +509,9 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int * Metal pole supports * rct2: 0x00663584 */ -bool metal_b_wooden_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags) +bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, int height, uint32 imageColourFlags) { - int eax = special, ebx = 0, ecx = 0, edx = height, esi = 0, _edi = supportType, ebp = imageColourFlags; + int eax = special, ebx = segment, ecx = 0, edx = height, esi = 0, _edi = supportType, ebp = imageColourFlags; RCT2_CALLFUNC_X(0x00663584, &eax, &ebx, &ecx, &edx, &esi, &_edi, &ebp); return eax & 0xFF; } diff --git a/src/paint/supports.h b/src/paint/supports.h index 8bacef8bd7..eefde8536f 100644 --- a/src/paint/supports.h +++ b/src/paint/supports.h @@ -22,4 +22,6 @@ bool wooden_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags, bool* underground); bool wooden_b_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags); bool metal_a_supports_paint_setup(int supportType, int segment, int special, int height, uint32 imageColourFlags); +bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, int height, uint32 imageColourFlags); + #endif diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index b257dddc29..49911e5530 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -124,6 +124,18 @@ enum SPR_MONORAIL_DIAG_FLAT_N_S = 23326, SPR_MONORAIL_DIAG_FLAT_E_W = 23327, SPR_MONORAIL_DIAG_FLAT_S_N = 23328, + SPR_MONORAIL_DIAG_FLAT_TO_25_DEG_UP_W_E = 23329, + SPR_MONORAIL_DIAG_FLAT_TO_25_DEG_UP_N_S = 23330, + SPR_MONORAIL_DIAG_FLAT_TO_25_DEG_UP_E_W = 23331, + SPR_MONORAIL_DIAG_FLAT_TO_25_DEG_UP_S_N = 23332, + SPR_MONORAIL_DIAG_25_DEG_UP_TO_FLAT_W_E = 23333, + SPR_MONORAIL_DIAG_25_DEG_UP_TO_FLAT_N_S = 23334, + SPR_MONORAIL_DIAG_25_DEG_UP_TO_FLAT_E_W = 23335, + SPR_MONORAIL_DIAG_25_DEG_UP_TO_FLAT_S_N = 23336, + SPR_MONORAIL_DIAG_25_DEG_UP_W_E = 23337, + SPR_MONORAIL_DIAG_25_DEG_UP_N_S = 23338, + SPR_MONORAIL_DIAG_25_DEG_UP_E_W = 23339, + SPR_MONORAIL_DIAG_25_DEG_UP_S_N = 23340, }; static const uint32 monorail_track_pieces_flat[4] = { @@ -407,6 +419,27 @@ static const uint32 monorail_track_pieces_diag_flat[4] = { SPR_MONORAIL_DIAG_FLAT_S_N, }; +static const uint32 monorail_track_pieces_diag_flat_to_25_deg_up[4] = { + SPR_MONORAIL_DIAG_FLAT_TO_25_DEG_UP_W_E, + SPR_MONORAIL_DIAG_FLAT_TO_25_DEG_UP_N_S, + SPR_MONORAIL_DIAG_FLAT_TO_25_DEG_UP_E_W, + SPR_MONORAIL_DIAG_FLAT_TO_25_DEG_UP_S_N, +}; + +static const uint32 monorail_track_pieces_diag_25_deg_up_to_flat[4] = { + SPR_MONORAIL_DIAG_25_DEG_UP_TO_FLAT_W_E, + SPR_MONORAIL_DIAG_25_DEG_UP_TO_FLAT_N_S, + SPR_MONORAIL_DIAG_25_DEG_UP_TO_FLAT_E_W, + SPR_MONORAIL_DIAG_25_DEG_UP_TO_FLAT_S_N, +}; + +static const uint32 monorail_track_pieces_diag_25_deg_up[4] = { + SPR_MONORAIL_DIAG_25_DEG_UP_W_E, + SPR_MONORAIL_DIAG_25_DEG_UP_N_S, + SPR_MONORAIL_DIAG_25_DEG_UP_E_W, + SPR_MONORAIL_DIAG_25_DEG_UP_S_N, +}; + /** rct2: 0x008AE1AC */ static void paint_monorail_track_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { @@ -855,66 +888,157 @@ static void paint_monorail_track_right_eighth_to_orthogonal(uint8 rideIndex, uin paint_monorail_track_left_eighth_to_diag(rideIndex, trackSequence, (direction + 3) % 4, height, mapElement); } +static void paint_monorail_util_diag_supports(uint8 direction, int height) +{ + switch (direction) { + case 0: + metal_a_supports_paint_setup(3, 1, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + case 1: + metal_a_supports_paint_setup(3, 0, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + case 2: + metal_a_supports_paint_setup(3, 2, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + case 3: + metal_a_supports_paint_setup(3, 3, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + break; + } +} + +static const bool monorail_diag_image_segment[][4] = { + {false, true, false, false}, + {false, false, false, true}, + {false, false, true, false}, + {true, false, false, false}, +}; + +static const uint8 monorail_diag_support_segment[] = {1, 0, 2, 3}; + +static const int monorail_diag_blocked_segments[] = { + SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4 | SEGMENT_BC, + SEGMENT_C4 | SEGMENT_CC | SEGMENT_C8 | SEGMENT_B4, + SEGMENT_D0 | SEGMENT_C4 | SEGMENT_C0 | SEGMENT_D4, + SEGMENT_D0 | SEGMENT_C4 | SEGMENT_B8 | SEGMENT_C8 +}; + /** rct2: 0x008AE2AC */ static void paint_monorail_track_diag_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - if ((direction == 0 && trackSequence == 1) - || (direction == 1 && trackSequence == 3) - || (direction == 2 && trackSequence == 2) - || (direction == 3 && trackSequence == 0)) { + if (monorail_diag_image_segment[direction][trackSequence]) { uint32 imageId = monorail_track_pieces_diag_flat[direction] | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(imageId, -16, -16, 32, 32, 2, height, -16, -16, height, get_current_rotation()); } if (trackSequence == 3) { - switch (direction) { - case 0: metal_a_supports_paint_setup(3, 1, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; - case 1: metal_a_supports_paint_setup(3, 0, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; - case 2: metal_a_supports_paint_setup(3, 2, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; - case 3: metal_a_supports_paint_setup(3, 3, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); break; - } - } - - int blockedSegments; - switch (trackSequence) { - case 0: blockedSegments = SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4 | SEGMENT_BC; break; - case 1: blockedSegments = SEGMENT_C4 | SEGMENT_CC | SEGMENT_C8 | SEGMENT_B4; break; - case 2: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_C0 | SEGMENT_D4; break; - case 3: blockedSegments = SEGMENT_D0 | SEGMENT_C4 | SEGMENT_B8 | SEGMENT_C8; break; + metal_a_supports_paint_setup(3, monorail_diag_support_segment[direction], 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); } + int blockedSegments = monorail_diag_blocked_segments[trackSequence]; paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); paint_util_set_general_support_height(height + 32, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE2DC */ static void paint_monorail_track_diag_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + if (monorail_diag_image_segment[direction][trackSequence]) { + uint32 imageId = monorail_track_pieces_diag_25_deg_up[direction] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, -16, -16, 32, 32, 2, height, -16, -16, height, get_current_rotation()); + } + + if (trackSequence == 3) { + metal_b_supports_paint_setup(3, monorail_diag_support_segment[direction], 8, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + int blockedSegments = monorail_diag_blocked_segments[trackSequence]; + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 56, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE2BC */ static void paint_monorail_track_diag_flat_to_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + if (monorail_diag_image_segment[direction][trackSequence]) { + uint32 imageId = monorail_track_pieces_diag_flat_to_25_deg_up[direction] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, -16, -16, 32, 32, 2, height, -16, -16, height, get_current_rotation()); + } + + if (trackSequence == 3) { + metal_b_supports_paint_setup(3, monorail_diag_support_segment[direction], 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + int blockedSegments = monorail_diag_blocked_segments[trackSequence]; + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 48, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE2CC */ static void paint_monorail_track_diag_25_deg_up_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + if (monorail_diag_image_segment[direction][trackSequence]) { + uint32 imageId = monorail_track_pieces_diag_25_deg_up_to_flat[direction] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, -16, -16, 32, 32, 2, height, -16, -16, height, get_current_rotation()); + } + + if (trackSequence == 3) { + metal_b_supports_paint_setup(3, monorail_diag_support_segment[direction], 4, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + int blockedSegments = monorail_diag_blocked_segments[trackSequence]; + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 56, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE30C */ static void paint_monorail_track_diag_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + if (monorail_diag_image_segment[direction][trackSequence]) { + uint32 imageId = monorail_track_pieces_diag_25_deg_up[(direction + 2) % 4] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, -16, -16, 32, 32, 2, height, -16, -16, height, get_current_rotation()); + } + + if (trackSequence == 3) { + metal_b_supports_paint_setup(3, monorail_diag_support_segment[direction], 8, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + int blockedSegments = monorail_diag_blocked_segments[trackSequence]; + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 56, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE2EC */ static void paint_monorail_track_diag_flat_to_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + if (monorail_diag_image_segment[direction][trackSequence]) { + uint32 imageId = monorail_track_pieces_diag_25_deg_up_to_flat[(direction + 2) % 4] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, -16, -16, 32, 32, 2, height, -16, -16, height, get_current_rotation()); + } + + if (trackSequence == 3) { + metal_b_supports_paint_setup(3, monorail_diag_support_segment[direction], 4, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + int blockedSegments = monorail_diag_blocked_segments[trackSequence]; + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 56, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE2FC */ static void paint_monorail_track_diag_25_deg_down_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + if (monorail_diag_image_segment[direction][trackSequence]) { + uint32 imageId = monorail_track_pieces_diag_flat_to_25_deg_up[(direction + 2) % 4] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, -16, -16, 32, 32, 2, height, -16, -16, height, get_current_rotation()); + } + + if (trackSequence == 3) { + metal_b_supports_paint_setup(3, monorail_diag_support_segment[direction], 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + int blockedSegments = monorail_diag_blocked_segments[trackSequence]; + paint_util_set_segment_support_height(paint_util_rotate_segments(blockedSegments, direction), 0xFFFF, 0); + paint_util_set_general_support_height(height + 48, 0x20); } /** From b39c08629387826b90b3dab577a4fa168b1138b5 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 26 May 2016 12:07:01 +0200 Subject: [PATCH 11/11] Draw station --- src/ride/transport/monorail.c | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/ride/transport/monorail.c b/src/ride/transport/monorail.c index 49911e5530..550de5ccdd 100644 --- a/src/ride/transport/monorail.c +++ b/src/ride/transport/monorail.c @@ -467,9 +467,44 @@ static void paint_monorail_track_flat(uint8 rideIndex, uint8 trackSequence, uint paint_util_set_general_support_height(height + 32, 0x20); } -/** rct2: 0x */ +/** rct2: 0x008AE25C, 0x008AE26C, 0x008AE27C */ static void paint_monorail_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { + uint32 imageId; + + if (direction == 0 || direction == 2) { + imageId = SPR_STATION_BASE_B_SW_NE | RCT2_GLOBAL(0x00F441A0, uint32); + sub_98197C(imageId, 0, 0, 32, 28, 2, height - 2, 0, 2, height, get_current_rotation()); + } else if (direction == 1 || direction == 3) { + imageId = SPR_STATION_BASE_B_NW_SE | RCT2_GLOBAL(0x00F441A0, uint32); + sub_98197C(imageId, 0, 0, 28, 32, 2, height - 2, 2, 0, height, get_current_rotation()); + } + + imageId = monorail_track_pieces_flat[direction] | RCT2_GLOBAL(0x00F44198, uint32); + if (direction == 0 || direction == 2) { + sub_98199C(imageId, 0, 6, 32, 20, 2, height, 0, 0, height, get_current_rotation()); + } else { + sub_98199C(imageId, 6, 0, 20, 32, 2, height, 0, 0, height, get_current_rotation()); + } + + if (direction == 0 || direction == 2) { + paint_util_push_tunnel_left(height, TUNNEL_6); + } else { + paint_util_push_tunnel_right(height, TUNNEL_6); + } + + if (direction == 0 || direction == 2) { + metal_a_supports_paint_setup(3, 5, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + metal_a_supports_paint_setup(3, 8, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } else { + metal_a_supports_paint_setup(3, 6, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + metal_a_supports_paint_setup(3, 7, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + } + + track_paint_util_draw_station(rideIndex, trackSequence, direction, height, mapElement); + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); } /** rct2: 0x008AE1BC */