From 811f24bfee0c96e75c6308723046992afbbe215b Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 18 May 2016 19:18:05 +0200 Subject: [PATCH] Paint 3d cinema (#3651) --- src/ride/thrill/3d_cinema.c | 96 +++++++++++++++++++++++++++++++++++++ src/ride/track_data.c | 4 +- src/ride/track_paint.h | 1 + 3 files changed, 99 insertions(+), 2 deletions(-) diff --git a/src/ride/thrill/3d_cinema.c b/src/ride/thrill/3d_cinema.c index 846fd9695d..1a697bbf8e 100644 --- a/src/ride/thrill/3d_cinema.c +++ b/src/ride/thrill/3d_cinema.c @@ -13,3 +13,99 @@ * 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: 0x007664C2 + */ +static void paint_3d_cinema_structure(uint8 rideIndex, uint8 direction, sint8 xOffset, sint8 yOffset, 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, xOffset, yOffset, 24, 24, 47, height + 3, xOffset + 16, yOffset + 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: 0x0076574C + */ +static void paint_3d_cinema(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), 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(0x00F441A0, uint32), height, fenceSpritesRope, get_current_rotation()); + + + switch(trackSequence) { + case 1: paint_3d_cinema_structure(rideIndex, direction, 32, 32, height); break; + case 3: paint_3d_cinema_structure(rideIndex, direction, 32, -32, height); break; + case 5: paint_3d_cinema_structure(rideIndex, direction, 0, -32, height); break; + case 6: paint_3d_cinema_structure(rideIndex, direction, -32, 32, height); break; + case 7: paint_3d_cinema_structure(rideIndex, direction, -32, -32, height); break; + case 8: paint_3d_cinema_structure(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); +} + +/* 0x0076554C */ +TRACK_PAINT_FUNCTION get_track_paint_function_3d_cinema(int trackType, int direction) +{ + if (trackType != 123) { + return NULL; + } + + return paint_3d_cinema; +} diff --git a/src/ride/track_data.c b/src/ride/track_data.c index 8b65cfcfff..a5d2b0a1c9 100644 --- a/src/ride/track_data.c +++ b/src/ride/track_data.c @@ -5506,7 +5506,7 @@ const uint32 RideTypeTrackPaintFunctionsOld[91] = { 0, // RIDE_TYPE_TOILETS 0x008A8CC8, // RIDE_TYPE_FERRIS_WHEEL 0x00763520, // RIDE_TYPE_MOTION_SIMULATOR - 0x0076554C, // RIDE_TYPE_3D_CINEMA + 0, // RIDE_TYPE_3D_CINEMA 0, // RIDE_TYPE_TOP_SPIN 0x00767A40, // RIDE_TYPE_SPACE_RINGS 0x00768BAC, // RIDE_TYPE_REVERSE_FREEFALL_COASTER @@ -5601,7 +5601,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = { get_track_paint_function_facility, // RIDE_TYPE_TOILETS 0, // RIDE_TYPE_FERRIS_WHEEL 0, // RIDE_TYPE_MOTION_SIMULATOR - 0, // RIDE_TYPE_3D_CINEMA + get_track_paint_function_3d_cinema, // RIDE_TYPE_3D_CINEMA get_track_paint_function_topspin, // RIDE_TYPE_TOP_SPIN 0, // RIDE_TYPE_SPACE_RINGS 0, // RIDE_TYPE_REVERSE_FREEFALL_COASTER diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 4a7192337b..5291ad3bf9 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -55,6 +55,7 @@ typedef TRACK_PAINT_FUNCTION (*TRACK_PAINT_FUNCTION_GETTER)(int trackType, int d TRACK_PAINT_FUNCTION get_track_paint_function_maze(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_spiral_slide(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_dodgems(int trackType, int direction); +TRACK_PAINT_FUNCTION get_track_paint_function_3d_cinema(int trackType, int direction); 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);