From f43c7f6ac1bec522d63f4bd6856e5a9121d72f2f Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Fri, 7 Aug 2015 02:47:57 +0100 Subject: [PATCH] implement viewport_vehicle_paint_setup --- src/interface/viewport.c | 53 +++++++++++++++++++++++++++++++++++++++- src/ride/vehicle.h | 6 +++-- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 8a1dc70934..1eb1ce114e 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -877,7 +877,58 @@ int sub_98197C(sint8 al, sint8 ah, int image_id, sint8 cl, int edx, sint16 si, s */ void viewport_vehicle_paint_setup(rct_vehicle *vehicle, int imageDirection) { - RCT2_CALLPROC_X(0x006D4244, vehicle->x, imageDirection, vehicle->y, vehicle->z, (int)vehicle, 0, 0); + rct_ride_type *rideEntry; + rct_ride_type_vehicle *vehicleEntry; + + int x = vehicle->x; + int y = vehicle->y; + int z = vehicle->z; + + if (vehicle->var_0C & 0x80) { + uint32 ebx = 22965 + vehicle->var_C5; + RCT2_GLOBAL(0x9DEA52, uint16) = 0; + RCT2_GLOBAL(0x9DEA54, uint16) = 0; + RCT2_GLOBAL(0x9DEA56, uint16) = z + 2; + switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) { + case 0: RCT2_CALLPROC_X(0x00686806, 0, ebx, 0, z, 1, 1, 0); break; + case 1: RCT2_CALLPROC_X(0x006869B2, 0, ebx, 0, z, 1, 1, 0); break; + case 2: RCT2_CALLPROC_X(0x00686B6F, 0, ebx, 0, z, 1, 1, 0); break; + case 3: RCT2_CALLPROC_X(0x00686D31, 0, ebx, 0, z, 1, 1, 0); break; + } + } + + if (vehicle->ride_subtype == 0xFF) { + vehicleEntry = (rct_ride_type_vehicle*)0x009DE232; + } else { + rideEntry = GET_RIDE_ENTRY(vehicle->ride_subtype); + vehicleEntry = &rideEntry->vehicles[vehicle->vehicle_type]; + + if (vehicle->var_48 & 0x800) { + vehicleEntry++; + z += 16; + } + } + + uint32 rct2VehiclePtrFormat = ((uint32)vehicleEntry) - offsetof(rct_ride_type, vehicles); + RCT2_GLOBAL(0x00F64DFC, uint32) = rct2VehiclePtrFormat; + switch (vehicleEntry->var_5D) { + case 0: RCT2_CALLPROC_X(0x006D45F8, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 2: RCT2_CALLPROC_X(0x006D5FAB, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 3: RCT2_CALLPROC_X(0x006D6258, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 4: RCT2_CALLPROC_X(0x006D5889, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 5: RCT2_CALLPROC_X(0x006D42F0, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 6: RCT2_CALLPROC_X(0x006D43C6, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 7: RCT2_CALLPROC_X(0x006D4453, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 8: RCT2_CALLPROC_X(0x006D4295, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 9: RCT2_CALLPROC_X(0x006D5DA9, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 10: RCT2_CALLPROC_X(0x006D5600, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 11: RCT2_CALLPROC_X(0x006D5696, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 12: RCT2_CALLPROC_X(0x006D57EE, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 13: RCT2_CALLPROC_X(0x006D5783, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 14: RCT2_CALLPROC_X(0x006D5701, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 15: RCT2_CALLPROC_X(0x006D5B48, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + case 16: RCT2_CALLPROC_X(0x006D44D5, x, imageDirection, y, z, (int)vehicle, rct2VehiclePtrFormat, 0); break; + } } /** diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index 8c5b270101..b2c95e4f7d 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -39,7 +39,7 @@ typedef struct { // Height from center of sprite to bottom uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint8 pad_0C[2]; + uint16 var_0C; sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -91,7 +91,9 @@ typedef struct { sint8 var_BF; uint8 pad_C0[0x02]; uint8 speed; // 0xC2 - uint8 pad_C3[0x09]; + uint8 pad_C3[2]; + uint8 var_C5; + uint8 pad_C6[6]; uint8 var_CC; uint8 var_CD; union {