From c2c41ec11829f19202c1c93fd9006c944bea3746 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 20 Dec 2015 12:50:33 +0000 Subject: [PATCH] implement steam_particle_create --- src/ride/vehicle.c | 125 ++++++++++++++++++++++++--------------------- src/world/sprite.c | 27 ++++++---- src/world/sprite.h | 32 +++++++++++- 3 files changed, 115 insertions(+), 69 deletions(-) diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 38f53aab09..a42f3a445d 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -101,6 +101,57 @@ const uint8 DoorCloseSoundIds[] = { SOUND_62 }; +static const struct { sint8 x, y, z; } SteamParticleOffsets[] = { + { -11, 0, 22 }, + { -10, 4, 22 }, + { -8, 8, 22 }, + { -4, 10, 22 }, + { 0, 11, 22 }, + { 4, 10, 22 }, + { 8, 8, 22 }, + { 10, 4, 22 }, + { 11, 0, 22 }, + { 10, -4, 22 }, + { 8, -8, 22 }, + { 4, -10, 22 }, + { 0, -11, 22 }, + { -4, -10, 22 }, + { -8, -8, 22 }, + { -10, -4, 22 }, + { -9, 0, 27 }, + { -8, 4, 27 }, + { -6, 6, 27 }, + { -4, 8, 27 }, + { 0, 9, 27 }, + { 4, 8, 27 }, + { 6, 6, 27 }, + { 8, 4, 27 }, + { 9, 0, 27 }, + { 8, -4, 27 }, + { 6, -6, 27 }, + { 4, -8, 27 }, + { 0, -9, 27 }, + { -4, -8, 27 }, + { -6, -6, 27 }, + { -8, -4, 27 }, + { -13, 0, 18 }, + { -12, 4, 17 }, + { -9, 9, 17 }, + { -4, 8, 17 }, + { 0, 13, 18 }, + { 4, 8, 17 }, + { 6, 6, 17 }, + { 8, 4, 17 }, + { 13, 0, 18 }, + { 8, -4, 17 }, + { 6, -6, 17 }, + { 4, -8, 17 }, + { 0, -13, 18 }, + { -4, -8, 17 }, + { -6, -6, 17 }, + { -8, -4, 17 } +}; + void vehicle_invalidate(rct_vehicle *vehicle) { invalidate_sprite_2((rct_sprite*)vehicle); @@ -5214,62 +5265,22 @@ static void vehicle_update_spinning_car(rct_vehicle *vehicle) * * rct2: 0x006734B2 */ -static void sub_6734B2(sint16 x, sint16 y, sint16 z) +static void steam_particle_create(sint16 x, sint16 y, sint16 z) { - RCT2_CALLPROC_X(0x006734B2, x, 0, y, z, 0, 0, 0); + rct_map_element *mapElement = map_get_surface_element_at(x >> 5, y >> 5); + if (mapElement != NULL && z > mapElement->base_height * 8) { + rct_steam_particle *steam = (rct_steam_particle*)create_sprite(2); + steam->sprite_width = 20; + steam->sprite_height_negative = 18; + steam->sprite_height_positive = 16; + steam->sprite_identifier = SPRITE_IDENTIFIER_MISC; + steam->misc_identifier = SPRITE_MISC_STEAM_PARTICLE; + steam->var_26 = 256; + steam->var_24 = 0; + sprite_move(x, y, z, (rct_sprite*)steam); + } } -static const struct { sint8 x, y, z; } byte_9A3A20[] = { - { -11, 0, 22 }, - { -10, 4, 22 }, - { -8, 8, 22 }, - { -4, 10, 22 }, - { 0, 11, 22 }, - { 4, 10, 22 }, - { 8, 8, 22 }, - { 10, 4, 22 }, - { 11, 0, 22 }, - { 10, -4, 22 }, - { 8, -8, 22 }, - { 4, -10, 22 }, - { 0, -11, 22 }, - { -4, -10, 22 }, - { -8, -8, 22 }, - { -10, -4, 22 }, - { -9, 0, 27 }, - { -8, 4, 27 }, - { -6, 6, 27 }, - { -4, 8, 27 }, - { 0, 9, 27 }, - { 4, 8, 27 }, - { 6, 6, 27 }, - { 8, 4, 27 }, - { 9, 0, 27 }, - { 8, -4, 27 }, - { 6, -6, 27 }, - { 4, -8, 27 }, - { 0, -9, 27 }, - { -4, -8, 27 }, - { -6, -6, 27 }, - { -8, -4, 27 }, - { -13, 0, 18 }, - { -12, 4, 17 }, - { -9, 9, 17 }, - { -4, 8, 17 }, - { 0, 13, 18 }, - { 4, 8, 17 }, - { 6, 6, 17 }, - { 8, 4, 17 }, - { 13, 0, 18 }, - { 8, -4, 17 }, - { 6, -6, 17 }, - { 4, -8, 17 }, - { 0, -13, 18 }, - { -4, -8, 17 }, - { -6, -6, 17 }, - { -8, -4, 17 } -}; - /** * * rct2: 0x006D63D4 @@ -5304,10 +5315,10 @@ static void sub_6D63D4(rct_vehicle *vehicle) if (vehicle->var_1F == 6) { index += 32; } - sub_6734B2( - vehicle->x + byte_9A3A20[index].x, - vehicle->y + byte_9A3A20[index].y, - vehicle->z + byte_9A3A20[index].z + steam_particle_create( + vehicle->x + SteamParticleOffsets[index].x, + vehicle->y + SteamParticleOffsets[index].y, + vehicle->z + SteamParticleOffsets[index].z ); } } diff --git a/src/world/sprite.c b/src/world/sprite.c index 40ec76621a..cb9f5bdac9 100644 --- a/src/world/sprite.c +++ b/src/world/sprite.c @@ -273,18 +273,23 @@ void move_sprite_to_list(rct_sprite *sprite, uint8 cl) * * rct2: 0x00673200 */ -static void sprite_misc_0_update(rct_sprite *sprite) +static void sprite_steam_particle_update(rct_steam_particle *steam) { - invalidate_sprite_2(sprite); + invalidate_sprite_2((rct_sprite*)steam); - int original_var24 = sprite->unknown.var_24; - sprite->unknown.var_24 += 0x5555; - if (sprite->unknown.var_24 < 0x5555) { - sprite_move(sprite->unknown.x, sprite->unknown.y, sprite->unknown.z + 1, sprite); + int original_var24 = steam->var_24; + steam->var_24 += 0x5555; + if (steam->var_24 < 0x5555) { + sprite_move( + steam->x, + steam->y, + steam->z + 1, + (rct_sprite*)steam + ); } - sprite->unknown.var_26 += 64; - if (sprite->unknown.var_26 >= (56 * 64)) { - sprite_remove(sprite); + steam->var_26 += 64; + if (steam->var_26 >= (56 * 64)) { + sprite_remove((rct_sprite*)steam); } } @@ -357,8 +362,8 @@ static void sprite_misc_5_update(rct_sprite *sprite) void sprite_misc_update(rct_sprite *sprite) { switch (sprite->unknown.misc_identifier) { - case SPRITE_MISC_0: - sprite_misc_0_update(sprite); + case SPRITE_MISC_STEAM_PARTICLE: + sprite_steam_particle_update((rct_steam_particle*)sprite); break; case SPRITE_MISC_MONEY_EFFECT: money_effect_update(&sprite->money_effect); diff --git a/src/world/sprite.h b/src/world/sprite.h index 89fdb512d2..db1a20dce5 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -282,6 +282,35 @@ typedef struct { uint16 var_26; } rct_crash_splash; +typedef struct { + uint8 sprite_identifier; // 0x00 + uint8 misc_identifier; // 0x01 + uint16 next_in_quadrant; // 0x02 + uint16 next; // 0x04 + uint16 previous; // 0x06 + uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... + // Height from center of sprite to bottom + uint8 sprite_height_negative; // 0x09 + uint16 sprite_index; // 0x0A + uint16 var_0C; + sint16 x; // 0x0E + sint16 y; // 0x10 + sint16 z; // 0x12 + // Width from center of sprite to edge + uint8 sprite_width; // 0x14 + // Height from center of sprite to top + uint8 sprite_height_positive; // 0x15 + sint16 sprite_left; // 0x16 + sint16 sprite_top; // 0x18 + sint16 sprite_right; // 0x1A + sint16 sprite_bottom; // 0x1C + uint8 sprite_direction; // 0x1E + uint8 pad_1F[3]; // 0x1F + uint16 name_string_idx; // 0x22 + uint16 var_24; + uint16 var_26; +} rct_steam_particle; + /** * Sprite structure. * size: 0x0100 @@ -298,10 +327,11 @@ typedef union { rct_money_effect money_effect; rct_crashed_vehicle_particle crashed_vehicle_particle; rct_crash_splash crash_splash; + rct_steam_particle steam_particle; } rct_sprite; enum { - SPRITE_MISC_0, + SPRITE_MISC_STEAM_PARTICLE, SPRITE_MISC_MONEY_EFFECT, SPRITE_MISC_CRASHED_VEHICLE_PARTICLE, SPRITE_MISC_3, // (related to vehicle crash, probably crash particles)