From 14caf2c1ca7827e13299970b9d4bc5245a3d84b5 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 11 Apr 2016 15:21:13 +0200 Subject: [PATCH 1/4] Paint crooked house base --- src/ride/track_data.c | 4 +- src/ride/track_paint.c | 286 +++++++++++++++++++++++++++++++++++++++++ src/ride/track_paint.h | 1 + 3 files changed, 289 insertions(+), 2 deletions(-) diff --git a/src/ride/track_data.c b/src/ride/track_data.c index 2a7d6ecec6..959b415d3a 100644 --- a/src/ride/track_data.c +++ b/src/ride/track_data.c @@ -5542,7 +5542,7 @@ const uint32 RideTypeTrackPaintFunctionsOld[91] = { 0x008AD280, // RIDE_TYPE_GIGA_COASTER 0x00886074, // RIDE_TYPE_ROTO_DROP 0x00887208, // RIDE_TYPE_FLYING_SAUCERS - 0x00889C28, // RIDE_TYPE_CROOKED_HOUSE + 0, // RIDE_TYPE_CROOKED_HOUSE 0x0088AC88, // RIDE_TYPE_MONORAIL_CYCLES 0x008AE36C, // RIDE_TYPE_COMPACT_INVERTED_COASTER 0x008AEDE0, // RIDE_TYPE_WATER_COASTER @@ -5637,7 +5637,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = { 0, // RIDE_TYPE_GIGA_COASTER 0, // RIDE_TYPE_ROTO_DROP 0, // RIDE_TYPE_FLYING_SAUCERS - 0, // RIDE_TYPE_CROOKED_HOUSE + get_track_paint_function_crooked_house, // RIDE_TYPE_CROOKED_HOUSE 0, // RIDE_TYPE_MONORAIL_CYCLES 0, // RIDE_TYPE_COMPACT_INVERTED_COASTER 0, // RIDE_TYPE_WATER_COASTER diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index ca861e3867..f41e22927b 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -990,3 +990,289 @@ TRACK_PAINT_FUNCTION get_track_paint_function_facility(int trackType, int direct } return NULL; } + +static void crooked_house_paint_supports(uint8 direction, int height) { + wooden_a_supports_paint_setup((direction & 1), 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); +} + +static void crooked_house_paint_floor(int height, int floor_sprite_id) { + uint32 image_id = floor_sprite_id | RCT2_GLOBAL(0x00F44198, uint32); + RCT2_GLOBAL(0x009DEA52, uint16) = 0; + RCT2_GLOBAL(0x009DEA54, uint16) = 0; + RCT2_GLOBAL(0x009DEA56, sint16) = height; + sub_98197C(image_id, 0, 0, 31, 31, 1, height, get_current_rotation()); +} + +static void crooked_house_paint_support_heights() { + RCT2_GLOBAL(0x0141E9D0, sint16) = -1; + RCT2_GLOBAL(0x0141E9C4, sint16) = -1; + RCT2_GLOBAL(0x0141E9CC, sint16) = -1; + RCT2_GLOBAL(0x0141E9B8, sint16) = -1; + RCT2_GLOBAL(0x0141E9BC, sint16) = -1; + RCT2_GLOBAL(0x0141E9B4, sint16) = -1; + RCT2_GLOBAL(0x0141E9C0, sint16) = -1; + RCT2_GLOBAL(0x0141E9C8, sint16) = -1; + RCT2_GLOBAL(0x0141E9D4, sint16) = -1; + +} + +static void crooked_house_paint_max_height(int height) { + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; + RCT2_GLOBAL(0x00141E9DA, uint8) = 32; + } +} + +static void crooked_house_fence_top_left(rct_ride *ride, int height, rct_map_element *mapElement) { + sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); + uint8 entranceId = (mapElement->properties.entrance.index & 0x70) >> 4; + + uint16 entranceLoc = + ((x / 32) + loc_7667AE[get_current_rotation()].x) | + (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); + + if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { + uint32 image_id = 22141 | RCT2_GLOBAL(0x00F441A0, uint32); + RCT2_GLOBAL(0x009DEA52, uint16) = 0; + RCT2_GLOBAL(0x009DEA54, uint16) = 2; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + + sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0); + } +} + +static void crooked_house_fence_top_right(rct_ride *ride, int height, rct_map_element *mapElement) { + sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); + uint8 entranceId = (mapElement->properties.entrance.index & 0x70) >> 4; + + uint16 entranceLoc = + ((x / 32) + loc_7667AC[get_current_rotation()].x) | + (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); + + if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { + uint32 image_id = 22138 | RCT2_GLOBAL(0x00F441A0, uint32); + RCT2_GLOBAL(0x009DEA52, uint16) = 0; + RCT2_GLOBAL(0x009DEA54, uint16) = 2; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + + sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0); + } +} + +static void crooked_house_fence_bottom_right(rct_ride *ride, int height, rct_map_element *mapElement) { + uint32 image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); + RCT2_GLOBAL(0x009DEA52, uint16) = 0; + RCT2_GLOBAL(0x009DEA54, uint16) = 30; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0); +} + +static void crooked_house_fence_bottom_left(rct_ride *ride, int height, rct_map_element *mapElement) { + uint32 image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); + RCT2_GLOBAL(0x009DEA52, uint16) = 30; + RCT2_GLOBAL(0x009DEA54, uint16) = 0; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0); +} + +/** + * rct2: 0x0088ABA4 + * @param (edi) rideIndex + * @param (al) al + * @param (cl) cl + * @param (ebx) image_id + * @param (edx) height + */ +static void sub_88ABA4(uint8 rideIndex, uint8 al, uint8 cl, uint32 image_id, int height) { + RCT2_CALLPROC_X(0x88ABA4, al, image_id, cl, height, 0, rideIndex * sizeof(rct_ride), 0); +} + +static void crooked_house_paint_setup_889F08(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_supports(direction, height); + crooked_house_paint_floor(height, 22137); + crooked_house_paint_support_heights(); + crooked_house_paint_max_height(height + 128); +} + +static void crooked_house_paint_setup_889FCC(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_supports(direction, height); + crooked_house_paint_floor(height, 22137); + + rct_ride *ride = get_ride(rideIndex); + crooked_house_fence_top_left(ride, height, mapElement); + crooked_house_fence_top_right(ride, height, mapElement); + + height += 2; + crooked_house_paint_support_heights(); + RCT2_GLOBAL(0x141E9B4, sint16) = (height & 0xFF00) | 0x20; + RCT2_GLOBAL(0x141E9C8, sint16) = (height & 0xFF00) | 0x20; + RCT2_GLOBAL(0x141E9CC, sint16) = (height & 0xFF00) | 0x20; + + crooked_house_paint_max_height(height + 126); +} + +static void crooked_house_paint_setup_88A1D0(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_supports(direction, height); + crooked_house_paint_floor(height, 22136); + + rct_ride *ride = get_ride(rideIndex); + crooked_house_fence_top_right(ride, height, mapElement); + crooked_house_fence_bottom_right(ride, height, mapElement); + + // unpop edi + sub_88ABA4(rideIndex, 32, 224, 0, height); + + height += 2; + crooked_house_paint_support_heights(); + RCT2_GLOBAL(0x141E9CC, sint16) = (height & 0xFF00) | 0x20; + RCT2_GLOBAL(0x141E9BC, sint16) = (height & 0xFF00) | 0x20; + RCT2_GLOBAL(0x141E9D4, sint16) = (height & 0xFF00) | 0x20; + + crooked_house_paint_max_height(height + 126); +} + +static void crooked_house_paint_setup_88A392(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_supports(direction, height); + crooked_house_paint_floor(height, 22135); + + rct_ride *ride = get_ride(rideIndex); + crooked_house_fence_top_left(ride, height, mapElement); + crooked_house_fence_bottom_left(ride, height, mapElement); + + sub_88ABA4(rideIndex, 224, 32, 4, height); + + height += 2; + crooked_house_paint_support_heights(); + RCT2_GLOBAL(0x141E9C8, sint16) = (height & 0xFF00) | 0x20; + RCT2_GLOBAL(0x141E9B8, sint16) = (height & 0xFF00) | 0x20; + RCT2_GLOBAL(0x141E9D0, sint16) = (height & 0xFF00) | 0x20; + + crooked_house_paint_max_height(height + 126); +} + +static void crooked_house_paint_setup_88A554(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_supports(direction, height); + crooked_house_paint_floor(height, 22134); + + rct_ride *ride = get_ride(rideIndex); + crooked_house_fence_bottom_left(ride, height, mapElement); + crooked_house_fence_bottom_right(ride, height, mapElement); + + sub_88ABA4(rideIndex, 224, 224, 2, height); + + height += 2; + crooked_house_paint_support_heights(); + RCT2_GLOBAL(0x141E9D0, sint16) = (height & 0xFF00) | 0x20; + RCT2_GLOBAL(0x141E9C0, sint16) = (height & 0xFF00) | 0x20; + RCT2_GLOBAL(0x141E9D4, sint16) = (height & 0xFF00) | 0x20; + + crooked_house_paint_max_height(height + 126); +} + + +static void crooked_house_paint_setup_88A97C(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_supports(direction, height); + crooked_house_paint_floor(height, 22136); + + rct_ride *ride = get_ride(rideIndex); + crooked_house_fence_bottom_right(ride, height, mapElement); + + sub_88ABA4(rideIndex, 0, 224, 1, height); + + crooked_house_paint_support_heights(); + crooked_house_paint_max_height(height + 128); +} + +static void crooked_house_paint_setup_88A821(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_supports(direction, height); + crooked_house_paint_floor(height, 22137); + + rct_ride *ride = get_ride(rideIndex); + crooked_house_fence_top_left(ride, height, mapElement); + + crooked_house_paint_support_heights(); + crooked_house_paint_max_height(height + 128); +} + +static void crooked_house_paint_setup_88A6C6(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_supports(direction, height); + crooked_house_paint_floor(height, 22137); + + rct_ride *ride = get_ride(rideIndex); + crooked_house_fence_top_right(ride, height, mapElement); + crooked_house_paint_support_heights(); + crooked_house_paint_max_height(height + 128); +} + +// bottom center +static void crooked_house_paint_setup_88AA90(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_supports(direction, height); + crooked_house_paint_floor(height, 22135); + + rct_ride *ride = get_ride(rideIndex); + crooked_house_fence_bottom_left(ride, height, mapElement); + + //sub_88ABA4(rideIndex, 224, 0, 3, height); + + crooked_house_paint_support_heights(); + crooked_house_paint_max_height(height + 128); +} + +TRACK_PAINT_FUNCTION crooked_house_paint_setup_functions[][9] = { + { + crooked_house_paint_setup_889F08, + crooked_house_paint_setup_889FCC, + crooked_house_paint_setup_88A6C6, + crooked_house_paint_setup_88A1D0, + crooked_house_paint_setup_88A821, + crooked_house_paint_setup_88A97C, + crooked_house_paint_setup_88A392, + crooked_house_paint_setup_88A554, + crooked_house_paint_setup_88AA90, + }, + { + crooked_house_paint_setup_889F08, + crooked_house_paint_setup_88A1D0, + crooked_house_paint_setup_88A97C, + crooked_house_paint_setup_88A554, + crooked_house_paint_setup_88A6C6, + crooked_house_paint_setup_88AA90, + crooked_house_paint_setup_889FCC, + crooked_house_paint_setup_88A392, + crooked_house_paint_setup_88A821, + }, + { + crooked_house_paint_setup_889F08, + crooked_house_paint_setup_88A554, + crooked_house_paint_setup_88AA90, + crooked_house_paint_setup_88A392, + crooked_house_paint_setup_88A97C, + crooked_house_paint_setup_88A821, + crooked_house_paint_setup_88A1D0, + crooked_house_paint_setup_889FCC, + crooked_house_paint_setup_88A6C6, + }, + { + crooked_house_paint_setup_889F08, + crooked_house_paint_setup_88A392, + crooked_house_paint_setup_88A821, + crooked_house_paint_setup_889FCC, + crooked_house_paint_setup_88AA90, + crooked_house_paint_setup_88A6C6, + crooked_house_paint_setup_88A554, + crooked_house_paint_setup_88A1D0, + crooked_house_paint_setup_88A97C, + }, +}; + +static void crooked_house_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { + crooked_house_paint_setup_functions[direction][trackSequence](rideIndex, trackSequence, direction, height, mapElement); +} + +TRACK_PAINT_FUNCTION get_track_paint_function_crooked_house(int trackType, int direction) { + if (trackType != 123) { + return NULL; + } + + return crooked_house_paint_setup; +} diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 410a85ce1d..94cd01d636 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -9,5 +9,6 @@ typedef TRACK_PAINT_FUNCTION (*TRACK_PAINT_FUNCTION_GETTER)(int trackType, int d 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_crooked_house(int trackType, int direction); #endif From 7a409371c838c1f62d28f79d811c888de2c943fd Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 11 Apr 2016 16:33:39 +0200 Subject: [PATCH 2/4] Implement sub_88ABA4 --- src/ride/track_paint.c | 62 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index f41e22927b..60e070a36c 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -31,6 +31,7 @@ #include "ride_data.h" #include "track_data.h" #include "track_paint.h" +#include "ride.h" /** * @@ -1075,16 +1076,62 @@ static void crooked_house_fence_bottom_left(rct_ride *ride, int height, rct_map_ sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0); } +typedef struct { + sint16 dword_52; + sint16 dword_54; + sint16 length_x; + sint16 length_y; +} rct_crooked_house_data; + +rct_crooked_house_data crooked_house_data[] = { + {6, 0, 42, 24}, + {0, 0, 0, 0}, + {-16, -16, 32, 32}, + {0, 0, 0, 0}, + {0, 6, 24, 42} +}; + /** * rct2: 0x0088ABA4 - * @param (edi) rideIndex + * @param (edi) direction * @param (al) al * @param (cl) cl * @param (ebx) image_id * @param (edx) height */ -static void sub_88ABA4(uint8 rideIndex, uint8 al, uint8 cl, uint32 image_id, int height) { - RCT2_CALLPROC_X(0x88ABA4, al, image_id, cl, height, 0, rideIndex * sizeof(rct_ride), 0); +static void sub_88ABA4(uint8 direction, uint8 al, uint8 cl, uint32 segment, int height) { + //RCT2_CALLPROC_X(0x88ABA4, al, segment, cl, height, 0, direction, 0); + //return; + + // push dword_9DE578 + rct_map_element *original_map_element = RCT2_GLOBAL(0x9DE578, rct_map_element*); + // push edx + RCT2_GLOBAL(0x14281B0, uint32) = segment; + RCT2_GLOBAL(0x14281B4, uint32) = direction; + + rct_ride *ride = get_ride(original_map_element->properties.track.ride_index); + + rct_ride_entry *ride_type = get_ride_entry(ride->subtype); + + RCT2_GLOBAL(0x0014281B8, uint32) = ride_type->vehicles[0].base_image_id; + + uint32 ebx = 0xFFFFFFFF; + if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK) { + if (ride->vehicles[0] != 0xFFFF && ride->vehicles[1] != 0xFFFF) { + rct_g1_element *sprite = &g1Elements[ride->vehicles[1]]; + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_SPRITE; + RCT2_GLOBAL(0x9DE578, rct_g1_element *) = sprite; + } + } + + + uint32 image_id = (direction + ride_type->vehicles[0].base_image_id) | RCT2_GLOBAL(0x00F441A0, uint32); + + rct_crooked_house_data esi = crooked_house_data[segment]; + RCT2_GLOBAL(0x009DEA52, sint16) = esi.dword_52; + RCT2_GLOBAL(0x009DEA54, sint16) = esi.dword_54; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; + sub_98197C(image_id, al, cl, esi.length_x, esi.length_y, 127, height + 3, get_current_rotation()); } static void crooked_house_paint_setup_889F08(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { @@ -1119,8 +1166,7 @@ static void crooked_house_paint_setup_88A1D0(uint8 rideIndex, uint8 trackSequenc crooked_house_fence_top_right(ride, height, mapElement); crooked_house_fence_bottom_right(ride, height, mapElement); - // unpop edi - sub_88ABA4(rideIndex, 32, 224, 0, height); + sub_88ABA4(direction, 32, 224, 0, height); height += 2; crooked_house_paint_support_heights(); @@ -1139,7 +1185,7 @@ static void crooked_house_paint_setup_88A392(uint8 rideIndex, uint8 trackSequenc crooked_house_fence_top_left(ride, height, mapElement); crooked_house_fence_bottom_left(ride, height, mapElement); - sub_88ABA4(rideIndex, 224, 32, 4, height); + sub_88ABA4(direction, 224, 32, 4, height); height += 2; crooked_house_paint_support_heights(); @@ -1158,7 +1204,7 @@ static void crooked_house_paint_setup_88A554(uint8 rideIndex, uint8 trackSequenc crooked_house_fence_bottom_left(ride, height, mapElement); crooked_house_fence_bottom_right(ride, height, mapElement); - sub_88ABA4(rideIndex, 224, 224, 2, height); + sub_88ABA4(direction, 224, 224, 2, height); height += 2; crooked_house_paint_support_heights(); @@ -1177,7 +1223,7 @@ static void crooked_house_paint_setup_88A97C(uint8 rideIndex, uint8 trackSequenc rct_ride *ride = get_ride(rideIndex); crooked_house_fence_bottom_right(ride, height, mapElement); - sub_88ABA4(rideIndex, 0, 224, 1, height); + sub_88ABA4(direction, 0, 224, 1, height); crooked_house_paint_support_heights(); crooked_house_paint_max_height(height + 128); From 90a7abbbdbc1cb194fc73bbb2b2c84bcda3087e2 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 18 Apr 2016 21:09:59 +0200 Subject: [PATCH 3/4] Update code --- src/ride/track_paint.c | 102 +++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 55 deletions(-) diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 60e070a36c..14aa0ed53b 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -998,29 +998,46 @@ static void crooked_house_paint_supports(uint8 direction, int height) { static void crooked_house_paint_floor(int height, int floor_sprite_id) { uint32 image_id = floor_sprite_id | RCT2_GLOBAL(0x00F44198, uint32); - RCT2_GLOBAL(0x009DEA52, uint16) = 0; - RCT2_GLOBAL(0x009DEA54, uint16) = 0; - RCT2_GLOBAL(0x009DEA56, sint16) = height; - sub_98197C(image_id, 0, 0, 31, 31, 1, height, get_current_rotation()); + sub_98197C(image_id, 0, 0, 31, 31, 1, height, 0, 0, height, get_current_rotation()); } static void crooked_house_paint_support_heights() { - RCT2_GLOBAL(0x0141E9D0, sint16) = -1; - RCT2_GLOBAL(0x0141E9C4, sint16) = -1; - RCT2_GLOBAL(0x0141E9CC, sint16) = -1; - RCT2_GLOBAL(0x0141E9B8, sint16) = -1; - RCT2_GLOBAL(0x0141E9BC, sint16) = -1; - RCT2_GLOBAL(0x0141E9B4, sint16) = -1; - RCT2_GLOBAL(0x0141E9C0, sint16) = -1; - RCT2_GLOBAL(0x0141E9C8, sint16) = -1; - RCT2_GLOBAL(0x0141E9D4, sint16) = -1; + RCT2_GLOBAL(0x0141E9D0, uint16) = 0xFFFF; + RCT2_GLOBAL(0x0141E9C4, uint16) = 0xFFFF; + RCT2_GLOBAL(0x0141E9CC, uint16) = 0xFFFF; + RCT2_GLOBAL(0x0141E9B8, uint16) = 0xFFFF; + RCT2_GLOBAL(0x0141E9BC, uint16) = 0xFFFF; + RCT2_GLOBAL(0x0141E9B4, uint16) = 0xFFFF; + RCT2_GLOBAL(0x0141E9C0, uint16) = 0xFFFF; + RCT2_GLOBAL(0x0141E9C8, uint16) = 0xFFFF; + RCT2_GLOBAL(0x0141E9D4, uint16) = 0xFFFF; +} +enum { + SEGMENT_B4 = (1 << 0), + SEGMENT_B8 = (1 << 1), + SEGMENT_BC = (1 << 2), + SEGMENT_C0 = (1 << 3), + SEGMENT_C4 = (1 << 4), + SEGMENT_C8 = (1 << 5), + SEGMENT_CC = (1 << 6), + SEGMENT_D0 = (1 << 7), + SEGMENT_D4 = (1 << 8), +}; + +static void crooked_house_paint_support_height(int flags, uint16 height, uint8 segment_flags) { + for (int s = 0; s < 9; s++) { + if (flags & (1 << s)) { + RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = height; + RCT2_GLOBAL(0x0141E9B6 + s * 4, uint8) = segment_flags; + } + } } static void crooked_house_paint_max_height(int height) { if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x00141E9DA, uint8) = 32; + RCT2_GLOBAL(0x00141E9DA, uint8) = 0x20; } } @@ -1034,11 +1051,7 @@ static void crooked_house_fence_top_left(rct_ride *ride, int height, rct_map_ele if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { uint32 image_id = 22141 | RCT2_GLOBAL(0x00F441A0, uint32); - RCT2_GLOBAL(0x009DEA52, uint16) = 0; - RCT2_GLOBAL(0x009DEA54, uint16) = 2; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0); + sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); } } @@ -1052,42 +1065,32 @@ static void crooked_house_fence_top_right(rct_ride *ride, int height, rct_map_el if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { uint32 image_id = 22138 | RCT2_GLOBAL(0x00F441A0, uint32); - RCT2_GLOBAL(0x009DEA52, uint16) = 0; - RCT2_GLOBAL(0x009DEA54, uint16) = 2; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0); + sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0, 2, height + 2, get_current_rotation()); } } static void crooked_house_fence_bottom_right(rct_ride *ride, int height, rct_map_element *mapElement) { uint32 image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); - RCT2_GLOBAL(0x009DEA52, uint16) = 0; - RCT2_GLOBAL(0x009DEA54, uint16) = 30; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0); + sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, get_current_rotation()); } static void crooked_house_fence_bottom_left(rct_ride *ride, int height, rct_map_element *mapElement) { uint32 image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - RCT2_GLOBAL(0x009DEA52, uint16) = 30; - RCT2_GLOBAL(0x009DEA54, uint16) = 0; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0); + sub_98199C(image_id, 0, 0, 1, 32, 7, height, 30, 0, height + 2, get_current_rotation()); } typedef struct { - sint16 dword_52; - sint16 dword_54; + sint16 offset_x; + sint16 offset_y; sint16 length_x; sint16 length_y; -} rct_crooked_house_data; +} rct_crooked_house_bound_box; -rct_crooked_house_data crooked_house_data[] = { +rct_crooked_house_bound_box crooked_house_data[] = { {6, 0, 42, 24}, {0, 0, 0, 0}, {-16, -16, 32, 32}, - {0, 0, 0, 0}, + {0, 0, 0, 0}, // unused {0, 6, 24, 42} }; @@ -1099,7 +1102,7 @@ rct_crooked_house_data crooked_house_data[] = { * @param (ebx) image_id * @param (edx) height */ -static void sub_88ABA4(uint8 direction, uint8 al, uint8 cl, uint32 segment, int height) { +static void sub_88ABA4(uint8 direction, uint8 x_offset, uint8 y_offset, uint32 segment, int height) { //RCT2_CALLPROC_X(0x88ABA4, al, segment, cl, height, 0, direction, 0); //return; @@ -1127,11 +1130,8 @@ static void sub_88ABA4(uint8 direction, uint8 al, uint8 cl, uint32 segment, int uint32 image_id = (direction + ride_type->vehicles[0].base_image_id) | RCT2_GLOBAL(0x00F441A0, uint32); - rct_crooked_house_data esi = crooked_house_data[segment]; - RCT2_GLOBAL(0x009DEA52, sint16) = esi.dword_52; - RCT2_GLOBAL(0x009DEA54, sint16) = esi.dword_54; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; - sub_98197C(image_id, al, cl, esi.length_x, esi.length_y, 127, height + 3, get_current_rotation()); + rct_crooked_house_bound_box esi = crooked_house_data[segment]; + sub_98197C(image_id, x_offset, y_offset, esi.length_x, esi.length_y, 127, height + 3, esi.offset_x, esi.offset_y, height + 3, get_current_rotation()); } static void crooked_house_paint_setup_889F08(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) { @@ -1151,9 +1151,7 @@ static void crooked_house_paint_setup_889FCC(uint8 rideIndex, uint8 trackSequenc height += 2; crooked_house_paint_support_heights(); - RCT2_GLOBAL(0x141E9B4, sint16) = (height & 0xFF00) | 0x20; - RCT2_GLOBAL(0x141E9C8, sint16) = (height & 0xFF00) | 0x20; - RCT2_GLOBAL(0x141E9CC, sint16) = (height & 0xFF00) | 0x20; + crooked_house_paint_support_height(SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC, height, 0x20); crooked_house_paint_max_height(height + 126); } @@ -1170,9 +1168,7 @@ static void crooked_house_paint_setup_88A1D0(uint8 rideIndex, uint8 trackSequenc height += 2; crooked_house_paint_support_heights(); - RCT2_GLOBAL(0x141E9CC, sint16) = (height & 0xFF00) | 0x20; - RCT2_GLOBAL(0x141E9BC, sint16) = (height & 0xFF00) | 0x20; - RCT2_GLOBAL(0x141E9D4, sint16) = (height & 0xFF00) | 0x20; + crooked_house_paint_support_height(SEGMENT_CC | SEGMENT_BC | SEGMENT_D4, height, 0x20); crooked_house_paint_max_height(height + 126); } @@ -1189,9 +1185,7 @@ static void crooked_house_paint_setup_88A392(uint8 rideIndex, uint8 trackSequenc height += 2; crooked_house_paint_support_heights(); - RCT2_GLOBAL(0x141E9C8, sint16) = (height & 0xFF00) | 0x20; - RCT2_GLOBAL(0x141E9B8, sint16) = (height & 0xFF00) | 0x20; - RCT2_GLOBAL(0x141E9D0, sint16) = (height & 0xFF00) | 0x20; + crooked_house_paint_support_height(SEGMENT_C8 | SEGMENT_B8 | SEGMENT_D0, height, 0x20); crooked_house_paint_max_height(height + 126); } @@ -1208,9 +1202,7 @@ static void crooked_house_paint_setup_88A554(uint8 rideIndex, uint8 trackSequenc height += 2; crooked_house_paint_support_heights(); - RCT2_GLOBAL(0x141E9D0, sint16) = (height & 0xFF00) | 0x20; - RCT2_GLOBAL(0x141E9C0, sint16) = (height & 0xFF00) | 0x20; - RCT2_GLOBAL(0x141E9D4, sint16) = (height & 0xFF00) | 0x20; + crooked_house_paint_support_height(SEGMENT_D0 | SEGMENT_C0 | SEGMENT_D4, height, 0x20); crooked_house_paint_max_height(height + 126); } From 75627105c679e9515138cf55f06b400b644fdfa5 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 20 Apr 2016 20:06:19 +0200 Subject: [PATCH 4/4] Clean up crooked house --- src/ride/track_paint.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 14aa0ed53b..9057c83d3d 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -1118,20 +1118,19 @@ static void sub_88ABA4(uint8 direction, uint8 x_offset, uint8 y_offset, uint32 s RCT2_GLOBAL(0x0014281B8, uint32) = ride_type->vehicles[0].base_image_id; - uint32 ebx = 0xFFFFFFFF; if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK) { - if (ride->vehicles[0] != 0xFFFF && ride->vehicles[1] != 0xFFFF) { - rct_g1_element *sprite = &g1Elements[ride->vehicles[1]]; + if (ride->vehicles[0] != -1) { + rct_sprite *sprite = &g_sprite_list[ride->vehicles[0]]; RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_SPRITE; - RCT2_GLOBAL(0x9DE578, rct_g1_element *) = sprite; + RCT2_GLOBAL(0x9DE578, rct_sprite *) = sprite; } } uint32 image_id = (direction + ride_type->vehicles[0].base_image_id) | RCT2_GLOBAL(0x00F441A0, uint32); - rct_crooked_house_bound_box esi = crooked_house_data[segment]; - sub_98197C(image_id, x_offset, y_offset, esi.length_x, esi.length_y, 127, height + 3, esi.offset_x, esi.offset_y, height + 3, get_current_rotation()); + rct_crooked_house_bound_box boundBox = crooked_house_data[segment]; + sub_98197C(image_id, x_offset, y_offset, boundBox.length_x, boundBox.length_y, 127, height + 3, boundBox.offset_x, boundBox.offset_y, height + 3, get_current_rotation()); } static void crooked_house_paint_setup_889F08(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element *mapElement) {