From 2df54c60d0fd16b18018ce0ad47e33fc9950515b Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 1 Nov 2015 13:12:43 +0000 Subject: [PATCH] implement more sub_6DAB4C --- src/ride/ride_data.c | 4 ++- src/ride/vehicle.c | 72 +++++++++++++++++++++++++++++++++++++++++--- src/ride/vehicle.h | 7 +++-- 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/ride/ride_data.c b/src/ride/ride_data.c index a41ceda1c4..bd289aed0c 100644 --- a/src/ride/ride_data.c +++ b/src/ride/ride_data.c @@ -1289,7 +1289,9 @@ const rct_ride_type_vehicle CableLiftVehicle = { .no_seating_rows = 0, .spinning_inertia = 0, .spinning_friction = 255, - .pad_57 = { 0,0,0 }, + .pad_57 = 0, + .var_58 = 0, + .pad_59 = 0, .var_5A = 0, .powered_acceleration = 0, .powered_max_speed = 0, diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 41747f1dfd..ae7f47c742 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -777,7 +777,8 @@ static void sub_6DAB4C_chunk_3(rct_vehicle *vehicle) */ static void sub_6D6776(rct_vehicle *vehicle) { - RCT2_CALLPROC_X(0x006D6776, 0, 0, 0, 0, (int)vehicle, 0, 0); + rct_ride_type_vehicle *vehicleEntry = vehicle_get_vehicle_entry(vehicle); + RCT2_CALLPROC_X(0x006D6776, 0, 0, 0, 0, (int)vehicle, (int)vehicleEntry, 0); } /** @@ -808,8 +809,8 @@ int sub_6DAB4C(rct_vehicle *vehicle, int *outStation) rct_ride *ride = GET_RIDE(vehicle->ride); rct_ride_type *rideEntry = GET_RIDE_ENTRY(vehicle->ride_subtype); - rct_ride_type_vehicle *vehicleEntry = &rideEntry->vehicles[vehicle->vehicle_type]; - + rct_ride_type_vehicle *vehicleEntry = vehicle_get_vehicle_entry(vehicle); + // esi = vehicle // eax = rideEntry // edi = vehicleEntry @@ -854,8 +855,71 @@ loc_6DAE27: invalidate_sprite_2((rct_sprite*)vehicle); loc_6DAEB9: + regs.edi = vehicle->track_type; + regs.cx = vehicle->track_type >> 2; + + int trackType = vehicle->track_type >> 2; + if (trackType == 197 || trackType == 198) { + if (vehicle->var_34 == 80) { + vehicle->vehicle_type ^= 1; + vehicleEntry = vehicle_get_vehicle_entry(vehicle); + } + if (RCT2_GLOBAL(0x00F64E08, sint32) >= 0x40000) { + vehicle->var_2C = -RCT2_GLOBAL(0x00F64E08, sint32) * 8; + } else if (RCT2_GLOBAL(0x00F64E08, sint32) < 0x20000) { + vehicle->var_2C = 0x50000; + } + } else if (trackType == TRACK_ELEM_BRAKES) { + if (!( + ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN && + ride->breakdown_reason_pending != BREAKDOWN_BRAKES_FAILURE && + ride->mechanic_status == RIDE_MECHANIC_STATUS_4 + )) { + regs.eax = vehicle->var_CF << 16; + if (regs.eax < RCT2_GLOBAL(0x00F64E08, sint32)) { + vehicle->var_2C = -RCT2_GLOBAL(0x00F64E08, sint32) * 16; + } else if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 0x0F)) { + if (RCT2_GLOBAL(0x00F64E2C, uint8) == 0) { + RCT2_GLOBAL(0x00F64E2C, uint8)++; + sound_play_panned(SOUND_51, 0x8001, vehicle->x, vehicle->y, vehicle->z); + } + } + } + } + + if ((trackType == TRACK_ELEM_FLAT && ride->type == RIDE_TYPE_REVERSE_FREEFALL_COASTER) || + (trackType == TRACK_ELEM_POWERED_LIFT) + ) { + vehicle->var_2C = RCT2_GLOBAL(0x0097CF40 + (ride->type * 8) + 7, uint8) << 10; + } + if (trackType == TRACK_ELEM_BRAKE_FOR_DROP) { + if (!vehicle->is_child) { + if (!(vehicle->update_flags & VEHICLE_UPDATE_FLAG_10)) { + if (vehicle->var_34 >= 8) { + vehicle->var_2C = -RCT2_GLOBAL(0x00F64E08, sint32) * 16; + if (vehicle->var_34 >= 24) { + vehicle->update_flags |= VEHICLE_UPDATE_FLAG_10; + vehicle->var_D2 = 90; + } + } + } + } + } + if (trackType == TRACK_ELEM_LOG_FLUME_REVERSER) { + if (vehicle->var_34 != 16 || vehicle->velocity < 0x40000) { + if (vehicle->var_34 == 32) { + vehicle->vehicle_type = vehicleEntry->var_58; + vehicleEntry = vehicle_get_vehicle_entry(vehicle); + } + } else { + vehicle->var_34 += 17; + } + } + +loc_6DB06B: regs.esi = vehicle; - RCT2_CALLFUNC_Y(0x006DAEB9, ®s); + regs.edi = vehicle->track_type; + RCT2_CALLFUNC_Y(0x006DB06B, ®s); goto end; loc_6DBA13: diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index 1f8f175f8b..07f4b00691 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -67,7 +67,9 @@ typedef struct { uint8 no_seating_rows; // 0x54 , 0x6E uint8 spinning_inertia; // 0x55 , 0x6F uint8 spinning_friction; // 0x56 , 0x70 - uint8 pad_57[0x3]; + uint8 pad_57; // 0x57 , 0x71 + uint8 var_58; // 0x58 , 0x72 + uint8 pad_59; // 0x59 , 0x73 uint8 var_5A; // 0x5A , 0x74 uint8 powered_acceleration; // 0x5B , 0x75 uint8 powered_max_speed; // 0x5C , 0x76 @@ -162,7 +164,8 @@ typedef struct { uint8 var_CE; uint8 num_laps; // 0xCE }; - uint8 pad_CF[0x03]; + uint8 var_CF; + uint8 pad_D0[0x02]; sint8 var_D2; uint8 var_D3; uint8 var_D4;