diff --git a/src/ride/gentle/circus_show.c b/src/ride/gentle/circus_show.c index 846fd9695d..587266d592 100644 --- a/src/ride/gentle/circus_show.c +++ b/src/ride/gentle/circus_show.c @@ -13,3 +13,98 @@ * A full copy of the GNU General Public License can be found in licence.txt *****************************************************************************/ #pragma endregion + +#include "../../interface/viewport.h" +#include "../../paint/paint.h" +#include "../../paint/supports.h" +#include "../track_paint.h" + +/** + * rct2: 0x0077084A + */ +static void paint_circus_show_tent(uint8 rideIndex, uint8 direction, sint8 al, sint8 cl, uint16 height) +{ + rct_map_element * savedMapElement = RCT2_GLOBAL(0x009DE578, rct_map_element*); + + rct_ride * ride = get_ride(rideIndex); + rct_ride_entry * ride_type = get_ride_entry(ride->subtype); + + if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK + && ride->vehicles[0] != SPRITE_INDEX_NULL) { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_SPRITE; + RCT2_GLOBAL(0x009DE578, rct_vehicle*) = GET_VEHICLE(ride->vehicles[0]); + } + + uint32 imageColourFlags = RCT2_GLOBAL(0x00F441A0, uint32); + if (imageColourFlags == 0x20000000) { + imageColourFlags = ride->vehicle_colours[0].body_colour << 19 | ride->vehicle_colours[0].trim_colour << 24 | 0xA0000000; + } + + uint32 imageId = (ride_type->vehicles[0].base_image_id + direction) | imageColourFlags; + sub_98197C(imageId, al, cl, 24, 24, 47, height + 3, al + 16, cl + 16, height + 3, get_current_rotation()); + + RCT2_GLOBAL(0x009DE578, rct_map_element*) = savedMapElement; + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_RIDE; +} +/** + * rct2: 0x0076FAD4 + */ +static void paint_circus_show(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + trackSequence = track_map_3x3[direction][trackSequence]; + + int edges = edges_3x3[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_t), NULL); + + track_paint_util_paint_floor(edges, RCT2_GLOBAL(0x00F44198, uint32), height, floorSpritesCork, get_current_rotation()); + + track_paint_util_paint_fences(edges, position, mapElement, ride, RCT2_GLOBAL(0x00F4419C, uint32), height, fenceSpritesRope, get_current_rotation()); + + switch (trackSequence) { + case 1: paint_circus_show_tent(rideIndex, direction, 32, 32, height); break; + case 3: paint_circus_show_tent(rideIndex, direction, 32, -32, height); break; + case 5: paint_circus_show_tent(rideIndex, direction, 0, -32, height); break; + case 6: paint_circus_show_tent(rideIndex, direction, -32, 32, height); break; + case 7: paint_circus_show_tent(rideIndex, direction, -32, -32, height); break; + case 8: paint_circus_show_tent(rideIndex, direction, -32, 0, height); break; + } + + 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; + } + + 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); +} + +/** + * rct2: 0x0076F8D4 + */ +TRACK_PAINT_FUNCTION get_track_paint_function_circus_show(int trackType, int direction) +{ + if (trackType != 123) { + return NULL; + } + + return paint_circus_show; +} diff --git a/src/ride/track_data.c b/src/ride/track_data.c index 069504b189..8b65cfcfff 100644 --- a/src/ride/track_data.c +++ b/src/ride/track_data.c @@ -5516,7 +5516,7 @@ const uint32 RideTypeTrackPaintFunctionsOld[91] = { 0x0076D658, // RIDE_TYPE_TWIST 0x0076E7B0, // RIDE_TYPE_HAUNTED_HOUSE 0, // RIDE_TYPE_FIRST_AID - 0x0076F8D4, // RIDE_TYPE_CIRCUS_SHOW + 0, // RIDE_TYPE_CIRCUS_SHOW 0x00770924, // RIDE_TYPE_GHOST_TRAIN 0x008AB2A0, // RIDE_TYPE_TWISTER_ROLLER_COASTER 0x008AC164, // RIDE_TYPE_WOODEN_ROLLER_COASTER @@ -5611,7 +5611,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = { 0, // RIDE_TYPE_TWIST 0, // RIDE_TYPE_HAUNTED_HOUSE get_track_paint_function_facility, // RIDE_TYPE_FIRST_AID - 0, // RIDE_TYPE_CIRCUS_SHOW + get_track_paint_function_circus_show, // RIDE_TYPE_CIRCUS_SHOW 0, // RIDE_TYPE_GHOST_TRAIN 0, // RIDE_TYPE_TWISTER_ROLLER_COASTER 0, // RIDE_TYPE_WOODEN_ROLLER_COASTER diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 54c440c16f..4a7192337b 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -58,6 +58,7 @@ TRACK_PAINT_FUNCTION get_track_paint_function_dodgems(int trackType, int directi TRACK_PAINT_FUNCTION get_track_paint_function_topspin(int trackType, int direction); 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_circus_show(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_crooked_house(int trackType, int direction); #endif