From f5696831fa7dc11db9e71ce781e4f9c7ca79513d Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 19 May 2016 19:20:32 +0200 Subject: [PATCH] Draw observation tower (#3669) --- src/ride/gentle/observation_tower.c | 101 +++++++++++++++++++++++++++- src/ride/track_data.c | 4 +- src/ride/track_paint.c | 7 ++ src/ride/track_paint.h | 8 +++ 4 files changed, 115 insertions(+), 5 deletions(-) diff --git a/src/ride/gentle/observation_tower.c b/src/ride/gentle/observation_tower.c index 60e74715de..f6aae38009 100644 --- a/src/ride/gentle/observation_tower.c +++ b/src/ride/gentle/observation_tower.c @@ -14,11 +14,20 @@ *****************************************************************************/ #pragma endregion -#include "../../addresses.h" -#include "../../config.h" +#include "../../common.h" #include "../../interface/viewport.h" -#include "../../world/sprite.h" #include "../../paint/paint.h" +#include "../track_paint.h" +#include "../track.h" +#include "../../world/map.h" +#include "../../paint/supports.h" + +enum +{ + SPR_OBSERVATION_TOWER_SEGMENT_BASE = 14986, + SPR_OBSERVATION_TOWER_SEGMENT = 14987, + SPR_OBSERVATION_TOWER_SEGMENT_TOP = 14988, +}; /** * @@ -57,3 +66,89 @@ void vehicle_visual_observation_tower(int x, int imageDirection, int y, int z, r assert(vehicleEntry->effect_visual == 1); } + +/** rct2: 0x0070DD6C */ +static void paint_observation_tower_base(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); + + uint32 imageId = SPR_FLOOR_METAL_B | 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, fenceSpritesMetalB, get_current_rotation()); + + if (trackSequence == 0) { + imageId = SPR_OBSERVATION_TOWER_SEGMENT_BASE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 8, 8, height + 3, get_current_rotation()); + + height += 32; + imageId = SPR_OBSERVATION_TOWER_SEGMENT | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 30, height, 8, 8, height, get_current_rotation()); + + height += 32; + imageId = SPR_OBSERVATION_TOWER_SEGMENT | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 30, height, 8, 8, height, get_current_rotation()); + + RCT2_GLOBAL(0x9E323C, uint16) = (((height + 32) >> 4) & 0x00FF) | (6 << 8); + } + + int blockedSegments = 0; + switch (trackSequence) { + case 0: blockedSegments = SEGMENTS_ALL; break; + case 1: blockedSegments = SEGMENT_B8 | SEGMENT_C8 | SEGMENT_B4 | SEGMENT_CC | SEGMENT_BC; break; + case 2: blockedSegments = SEGMENT_B4 | SEGMENT_CC | SEGMENT_BC; break; + case 3: blockedSegments = SEGMENT_B4 | SEGMENT_CC | SEGMENT_BC | SEGMENT_D4 | SEGMENT_C0; break; + case 4: blockedSegments = SEGMENT_B4 | SEGMENT_C8 | SEGMENT_B8; break; + case 5: blockedSegments = SEGMENT_BC | SEGMENT_D4 | SEGMENT_C0; break; + case 6: blockedSegments = SEGMENT_B4 | SEGMENT_C8 | SEGMENT_B8 | SEGMENT_D0 | SEGMENT_C0; break; + case 7: blockedSegments = SEGMENT_B8 | SEGMENT_D0 | SEGMENT_C0 | SEGMENT_D4 | SEGMENT_BC; break; + case 8: blockedSegments = SEGMENT_B8 | SEGMENT_D0 | SEGMENT_C0; break; + } + paint_util_set_segment_support_height(blockedSegments, 0xFFFF, 0); + paint_util_set_segment_support_height(SEGMENTS_ALL & ~blockedSegments, height + 2, 0x20); + paint_util_set_general_support_height(height + 32, 0x20); +} + +/** rct2: 0x0070DD7C */ +static void paint_observation_tower_section(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + if (trackSequence == 1) { + return; + } + + uint32 imageId = SPR_OBSERVATION_TOWER_SEGMENT | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 30, height, 8, 8, height, get_current_rotation()); + + rct_map_element * nextMapElement = mapElement + 1; + if (map_element_is_last_for_tile(mapElement) || mapElement->clearance_height != nextMapElement->base_height) { + uint32 imageId = SPR_OBSERVATION_TOWER_SEGMENT_TOP | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 2, 2, 30, height, 8, 8, height, get_current_rotation()); + } + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + + RCT2_GLOBAL(0x9E323C, uint16) = (((height + 32) >> 4) & 0x00FF) | (6 << 8); + paint_util_set_general_support_height(height + 32, 0x20); +} + +/** + * rct2: 0x0070DC5C + */ +TRACK_PAINT_FUNCTION get_track_paint_function_observation_tower(int trackType, int direction) +{ + switch (trackType) { + case TRACK_ELEM_TOWER_BASE: + return paint_observation_tower_base; + + case TRACK_ELEM_TOWER_SECTION: + return paint_observation_tower_section; + } + + return NULL; +} diff --git a/src/ride/track_data.c b/src/ride/track_data.c index fa664cb657..e2a0056088 100644 --- a/src/ride/track_data.c +++ b/src/ride/track_data.c @@ -5481,7 +5481,7 @@ const uint32 RideTypeTrackPaintFunctionsOld[91] = { 0x006F7000, // RIDE_TYPE_CAR_RIDE 0x006FD0E8, // RIDE_TYPE_LAUNCHED_FREEFALL 0x006FE240, // RIDE_TYPE_BOBSLEIGH_COASTER - 0x0070DC5C, // RIDE_TYPE_OBSERVATION_TOWER + 0, // RIDE_TYPE_OBSERVATION_TOWER 0x008A5B88, // RIDE_TYPE_LOOPING_ROLLER_COASTER 0x0070EDB4, // RIDE_TYPE_DINGHY_SLIDE 0x0071BC40, // RIDE_TYPE_MINE_TRAIN_COASTER @@ -5576,7 +5576,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = { 0, // RIDE_TYPE_CAR_RIDE 0, // RIDE_TYPE_LAUNCHED_FREEFALL 0, // RIDE_TYPE_BOBSLEIGH_COASTER - 0, // RIDE_TYPE_OBSERVATION_TOWER + get_track_paint_function_observation_tower, // RIDE_TYPE_OBSERVATION_TOWER 0, // RIDE_TYPE_LOOPING_ROLLER_COASTER 0, // RIDE_TYPE_DINGHY_SLIDE 0, // RIDE_TYPE_MINE_TRAIN_COASTER diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 08c8e49b1f..d9e6522876 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -119,6 +119,13 @@ const uint32 fenceSpritesRope[] = { SPR_FENCE_ROPE_NW }; +const uint32 fenceSpritesMetalB[] = { + SPR_FENCE_METAL_B_NE, + SPR_FENCE_METAL_B_SE, + SPR_FENCE_METAL_B_SW, + SPR_FENCE_METAL_B_NW +}; + enum { SPR_STATION_COVER_OFFSET_NE_SW_BACK_0 = 0, diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index e120a43935..e26207f855 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -38,6 +38,12 @@ enum { SPR_FENCE_METAL_SW = 14570, SPR_FENCE_METAL_NW = 14571, + SPR_FLOOR_METAL_B = 14989, + SPR_FENCE_METAL_B_NE = 14990, + SPR_FENCE_METAL_B_SE = 14991, + SPR_FENCE_METAL_B_SW = 14992, + SPR_FENCE_METAL_B_NW = 14993, + SPR_FLOOR_CORK_SE_SW = 22134, SPR_FLOOR_CORK_SW = 22135, SPR_FLOOR_CORK_SE = 22136, @@ -60,6 +66,7 @@ enum { extern const uint32 floorSpritesCork[]; extern const uint32 fenceSpritesRope[]; +extern const uint32 fenceSpritesMetalB[]; 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); @@ -70,6 +77,7 @@ bool track_paint_util_should_paint_supports(rct_xy16 position); 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_observation_tower(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_chairlift(int trackType, int direction); 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);