Merge pull request #3444 from marijnvdwerf/paint-setup/misc

Misc paint setup
This commit is contained in:
Duncan 2016-05-06 06:51:47 +01:00
commit a937a65b28
7 changed files with 220 additions and 51 deletions

View File

@ -16,12 +16,181 @@
#include "../../world/sprite.h"
#include "../../addresses.h"
#include "../../drawing/drawing.h"
#include "../../interface/viewport.h"
#include "../paint.h"
/** rct2: 0x0097EDA4 */
const sint8 money_wave[] = {
0, 1, 2, 2, 3, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -3, -2, -2, -1,
0, 1, 2, 2, 3, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -3, -2, -2, -1
};
/** rct2: 0x0097ED90 */
const uint32 vehicle_particle_base_sprites[] = {
22577, 22589, 22601, 22613, 22625
};
/**
*
* rct2: 0x00672AC9
* rct2: 0x00672AC9
*/
void misc_paint(rct_sprite *misc, int imageDirection)
{
RCT2_CALLPROC_X(0x00672AC9, misc->unknown.x, imageDirection, misc->unknown.y, misc->unknown.z, (int)misc, 0, 0);
}
rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo *);
switch (misc->steam_particle.misc_identifier) {
case SPRITE_MISC_STEAM_PARTICLE: // 0
{
uint32 imageId = 22637 + (misc->steam_particle.frame / 256);
sub_98196C(imageId, 0, 0, 1, 1, 0, misc->unknown.z, get_current_rotation());
break;
}
case SPRITE_MISC_MONEY_EFFECT: // 1
{
if (dpi->zoom_level != 0) {
return;
}
rct_money_effect moneyEffect = misc->money_effect;
money32 amount = moneyEffect.value;
uint16 stringId = 1388; // {OUTLINE}{GREEN}+ {CURRENCY}
if (amount < 0) {
amount = -amount;
stringId = 1389; // {OUTLINE}{RED}- {CURRENCY}
}
sub_685EBC(amount, stringId, moneyEffect.y, moneyEffect.z, &money_wave[moneyEffect.wiggle % 22], moneyEffect.offset_x, get_current_rotation());
break;
}
case SPRITE_MISC_CRASHED_VEHICLE_PARTICLE: // 2
{
if (dpi->zoom_level != 0) {
return;
}
rct_crashed_vehicle_particle particle = misc->crashed_vehicle_particle;
uint32 imageId = vehicle_particle_base_sprites[particle.var_2E] + particle.frame / 256;
imageId = imageId | (particle.colour[0] << 19) | (particle.colour[1] << 24) | 0xA0000000;
sub_98196C(imageId, 0, 0, 1, 1, 0, misc->unknown.z, get_current_rotation());
break;
}
case SPRITE_MISC_EXPLOSION_CLOUD: // 3
{
uint32 imageId = 22878 + (misc->unknown.frame / 256);
sub_98196C(imageId, 0, 0, 1, 1, 0, misc->unknown.z, get_current_rotation());
break;
}
case SPRITE_MISC_CRASH_SPLASH: // 4
{
rct_crash_splash crashSplash = misc->crash_splash;
uint32 imageId = 22927 + (crashSplash.frame / 256);
sub_98196C(imageId, 0, 0, 1, 1, 0, crashSplash.z, get_current_rotation());
break;
}
case SPRITE_MISC_EXPLOSION_FLARE: // 5
{
// Like a flare
uint32 imageId = 22896 + (misc->unknown.frame / 256);
sub_98196C(imageId, 0, 0, 1, 1, 0, misc->unknown.z, get_current_rotation());
break;
}
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER: // 6
case SPRITE_MISC_JUMPING_FOUNTAIN_SNOW: // 9
{
if (dpi->zoom_level != 0) {
return;
}
rct_jumping_fountain jumpingFountain = misc->jumping_fountain;
uint16 height = jumpingFountain.z + 6;
int ebx = imageDirection / 8;
uint8 al = (jumpingFountain.fountain_flags / 128) & 1;
uint8 ah = (jumpingFountain.sprite_direction / 16) & 1;
if (al == ah) {
al = ebx / 2;
} else {
al = ebx / 2;
al = al ^ 1;
}
uint32 baseImageId = (jumpingFountain.misc_identifier == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW) ? 23037 : 22973;
uint32 imageId = baseImageId + ebx * 16 + jumpingFountain.var_26b;
if (al & 1) {
switch (ebx) {
case 0:
sub_98197C(imageId, 0, 0, 32, 1, 3, height, -32, -3, height, get_current_rotation());
break;
case 1:
sub_98197C(imageId, 0, 0, 1, 32, 3, height, -3, 0, height, get_current_rotation());
break;
case 2:
sub_98197C(imageId, 0, 0, 32, 1, 3, height, 0, -3, height, get_current_rotation());
break;
case 3:
sub_98197C(imageId, 0, 0, 1, 32, 3, height, -3, -32, height, get_current_rotation());
break;
}
} else {
switch (ebx) {
case 0:
sub_98197C(imageId, 0, 0, 32, 1, 3, height, -32, 3, height, get_current_rotation());
break;
case 1:
sub_98197C(imageId, 0, 0, 1, 32, 3, height, 3, 0, height, get_current_rotation());
break;
case 2:
sub_98197C(imageId, 0, 0, 32, 1, 3, height, 0, 3, height, get_current_rotation());
break;
case 3:
sub_98197C(imageId, 0, 0, 1, 32, 3, height, 3, -32, height, get_current_rotation());
break;
}
}
break;
}
case SPRITE_MISC_BALLOON: // 7
{
rct_balloon balloon = misc->balloon;
uint32 imageId = 22651 + ((balloon.frame / 256) & 7);
if (balloon.popped != 0) {
imageId += 8;
}
imageId = imageId | (balloon.colour << 19) | 0x20000000;
sub_98196C(imageId, 0, 0, 1, 1, 0, balloon.z, get_current_rotation());
break;
}
case SPRITE_MISC_DUCK: // 8
{
if (dpi->zoom_level != 0) {
return;
}
rct_duck duck = misc->duck;
uint32 stateAddress = RCT2_ADDRESS(0x97F058, uint32)[duck.state];
uint8 imageOffset = RCT2_ADDRESS(stateAddress, uint8)[duck.var_26];
uint32 imageId = 23133 + (imageOffset * 4) + (imageDirection / 8);
sub_98196C(imageId, 0, 0, 1, 1, 0, duck.z, get_current_rotation());
break;
}
}
}

View File

@ -409,8 +409,8 @@ static void sub_68F41A(rct_peep *peep, int index)
if (peep->peep_flags & PEEP_FLAGS_EXPLODE && peep->x != (sint16)0x8000){
audio_play_sound_at_location(SOUND_CRASH, peep->x, peep->y, peep->z);
sprite_misc_3_create(peep->x, peep->y, peep->z + 16);
sprite_misc_5_create(peep->x, peep->y, peep->z + 16);
sprite_misc_explosion_cloud_create(peep->x, peep->y, peep->z + 16);
sprite_misc_explosion_flare_create(peep->x, peep->y, peep->z + 16);
peep_remove(peep);
return;

View File

@ -2544,11 +2544,11 @@ static void vehicle_update_collision_setup(rct_vehicle* vehicle) {
train->z
);
sprite_misc_3_create(
sprite_misc_explosion_cloud_create(
train->x,
train->y,
train->z
);
);
for (int i = 0; i < 10; i++) {
crashed_vehicle_particle_create(
@ -4128,8 +4128,8 @@ static void vehicle_crash_on_land(rct_vehicle* vehicle) {
vehicle->sub_state = 2;
audio_play_sound_at_location(SOUND_CRASH, vehicle->x, vehicle->y, vehicle->z);
sprite_misc_3_create(vehicle->x, vehicle->y, vehicle->z);
sprite_misc_5_create(vehicle->x, vehicle->y, vehicle->z);
sprite_misc_explosion_cloud_create(vehicle->x, vehicle->y, vehicle->z);
sprite_misc_explosion_flare_create(vehicle->x, vehicle->y, vehicle->z);
uint8 numParticles = min(vehicle->sprite_width, 7);
@ -4214,11 +4214,11 @@ static void vehicle_update_crash(rct_vehicle *vehicle){
if (curVehicle->var_4E <= 96) {
curVehicle->var_4E++;
if ((scenario_rand() & 0xFFFF) <= 0x1555) {
sprite_misc_3_create(
sprite_misc_explosion_cloud_create(
curVehicle->x + ((scenario_rand() & 2) - 1),
curVehicle->y + ((scenario_rand() & 2) - 1),
curVehicle->z
);
);
}
}
if (curVehicle->var_C8 + 7281 > 0xFFFF) {
@ -6089,7 +6089,7 @@ static void steam_particle_create(sint16 x, sint16 y, sint16 z)
steam->sprite_height_positive = 16;
steam->sprite_identifier = SPRITE_IDENTIFIER_MISC;
steam->misc_identifier = SPRITE_MISC_STEAM_PARTICLE;
steam->var_26 = 256;
steam->frame = 256;
steam->var_24 = 0;
sprite_move(x, y, z, (rct_sprite*)steam);
}

View File

@ -33,7 +33,7 @@ void create_balloon(int x, int y, int z, int colour, uint8 bl)
sprite->balloon.sprite_identifier = SPRITE_IDENTIFIER_MISC;
sprite_move(x, y, z, sprite);
sprite->balloon.misc_identifier = SPRITE_MISC_BALLOON;
sprite->balloon.var_26 = 0;
sprite->balloon.frame = 0;
sprite->balloon.colour = colour;
sprite->balloon.popped = bl;
}
@ -42,7 +42,7 @@ void create_balloon(int x, int y, int z, int colour, uint8 bl)
void balloon_pop(rct_balloon *balloon)
{
balloon->popped = 1;
balloon->var_26 = 0;
balloon->frame = 0;
audio_play_sound_at_location(SOUND_BALLOON_POP, balloon->x, balloon->y, balloon->z);
}
@ -54,8 +54,8 @@ void balloon_update(rct_balloon *balloon)
{
invalidate_sprite_2((rct_sprite*)balloon);
if (balloon->popped == 1) {
balloon->var_26 += 256;
if (balloon->var_26 >= 1280)
balloon->frame += 256;
if (balloon->frame >= 1280)
sprite_remove((rct_sprite*)balloon);
return;

View File

@ -35,7 +35,7 @@ void crashed_vehicle_particle_create(rct_vehicle_colour colours, int x, int y, i
sprite_move(x, y, z, (rct_sprite*)sprite);
sprite->misc_identifier = SPRITE_MISC_CRASHED_VEHICLE_PARTICLE;
sprite->var_26 = (util_rand() & 0xFF) * 12;
sprite->frame = (util_rand() & 0xFF) * 12;
sprite->var_24 = (util_rand() & 0x7F) + 140;
sprite->var_2E = ((util_rand() & 0xFF) * 5) >> 8;
sprite->acceleration_x = ((sint16)(util_rand() & 0xFFFF)) * 4;
@ -102,9 +102,9 @@ void crashed_vehicle_particle_update(rct_crashed_vehicle_particle *particle)
sprite_move(x, y, z, (rct_sprite*)particle);
invalidate_sprite_0((rct_sprite*)particle);
particle->var_26 += 85;
if (particle->var_26 >= 3072) {
particle->var_26 = 0;
particle->frame += 85;
if (particle->frame >= 3072) {
particle->frame = 0;
}
}
@ -122,7 +122,7 @@ void crash_splash_create(int x, int y, int z)
sprite->sprite_identifier = SPRITE_IDENTIFIER_MISC;
sprite_move(x, y, z + 3, (rct_sprite*)sprite);
sprite->misc_identifier = SPRITE_MISC_CRASH_SPLASH;
sprite->var_26 = 0;
sprite->frame = 0;
}
}
@ -133,8 +133,8 @@ void crash_splash_create(int x, int y, int z)
void crash_splash_update(rct_crash_splash *splash)
{
invalidate_sprite_2((rct_sprite*)splash);
splash->var_26 += 85;
if (splash->var_26 >= 7168) {
splash->frame += 85;
if (splash->frame >= 7168) {
sprite_remove((rct_sprite*)splash);
}
}

View File

@ -288,8 +288,8 @@ static void sprite_steam_particle_update(rct_steam_particle *steam)
(rct_sprite*)steam
);
}
steam->var_26 += 64;
if (steam->var_26 >= (56 * 64)) {
steam->frame += 64;
if (steam->frame >= (56 * 64)) {
sprite_remove((rct_sprite*)steam);
}
}
@ -298,7 +298,7 @@ static void sprite_steam_particle_update(rct_steam_particle *steam)
*
* rct2: 0x0067363D
*/
void sprite_misc_3_create(int x, int y, int z)
void sprite_misc_explosion_cloud_create(int x, int y, int z)
{
rct_unk_sprite *sprite = (rct_unk_sprite*)create_sprite(2);
if (sprite != NULL) {
@ -307,8 +307,8 @@ void sprite_misc_3_create(int x, int y, int z)
sprite->sprite_height_positive = 34;
sprite->sprite_identifier = SPRITE_IDENTIFIER_MISC;
sprite_move(x, y, z + 4, (rct_sprite*)sprite);
sprite->misc_identifier = SPRITE_MISC_3;
sprite->var_26 = 0;
sprite->misc_identifier = SPRITE_MISC_EXPLOSION_CLOUD;
sprite->frame = 0;
}
}
@ -316,11 +316,11 @@ void sprite_misc_3_create(int x, int y, int z)
*
* rct2: 0x00673385
*/
static void sprite_misc_3_update(rct_sprite *sprite)
static void sprite_misc_explosion_cloud_update(rct_sprite * sprite)
{
invalidate_sprite_2(sprite);
sprite->unknown.var_26 += 128;
if (sprite->unknown.var_26 >= (36 * 128)) {
sprite->unknown.frame += 128;
if (sprite->unknown.frame >= (36 * 128)) {
sprite_remove(sprite);
}
}
@ -329,7 +329,7 @@ static void sprite_misc_3_update(rct_sprite *sprite)
*
* rct2: 0x0067366B
*/
void sprite_misc_5_create(int x, int y, int z)
void sprite_misc_explosion_flare_create(int x, int y, int z)
{
rct_unk_sprite *sprite = (rct_unk_sprite*)create_sprite(2);
if (sprite != NULL) {
@ -338,8 +338,8 @@ void sprite_misc_5_create(int x, int y, int z)
sprite->sprite_height_positive = 8;
sprite->sprite_identifier = SPRITE_IDENTIFIER_MISC;
sprite_move(x, y, z + 4, (rct_sprite*)sprite);
sprite->misc_identifier = SPRITE_MISC_5;
sprite->var_26 = 0;
sprite->misc_identifier = SPRITE_MISC_EXPLOSION_FLARE;
sprite->frame = 0;
}
}
@ -347,11 +347,11 @@ void sprite_misc_5_create(int x, int y, int z)
*
* rct2: 0x006733B4
*/
static void sprite_misc_5_update(rct_sprite *sprite)
static void sprite_misc_explosion_flare_update(rct_sprite * sprite)
{
invalidate_sprite_2(sprite);
sprite->unknown.var_26 += 64;
if (sprite->unknown.var_26 >= (124 * 64)) {
sprite->unknown.frame += 64;
if (sprite->unknown.frame >= (124 * 64)) {
sprite_remove(sprite);
}
}
@ -372,14 +372,14 @@ void sprite_misc_update(rct_sprite *sprite)
case SPRITE_MISC_CRASHED_VEHICLE_PARTICLE:
crashed_vehicle_particle_update((rct_crashed_vehicle_particle*)sprite);
break;
case SPRITE_MISC_3:
sprite_misc_3_update(sprite);
case SPRITE_MISC_EXPLOSION_CLOUD:
sprite_misc_explosion_cloud_update(sprite);
break;
case SPRITE_MISC_CRASH_SPLASH:
crash_splash_update((rct_crash_splash*)sprite);
break;
case SPRITE_MISC_5:
sprite_misc_5_update(sprite);
case SPRITE_MISC_EXPLOSION_FLARE:
sprite_misc_explosion_flare_update(sprite);
break;
case SPRITE_MISC_JUMPING_FOUNTAIN_WATER:
case SPRITE_MISC_JUMPING_FOUNTAIN_SNOW:

View File

@ -68,7 +68,7 @@ typedef struct {
uint8 pad_1F[3]; // 0x1f
uint16 name_string_idx; // 0x22
uint16 var_24;
uint16 var_26;
uint16 frame; // 0x26
uint8 var_28[3];
uint8 var_2B;
uint8 pad_2C[0x45];
@ -114,7 +114,7 @@ typedef struct {
uint8 pad_16[0xE];
uint16 popped; // 0x24
union {
uint16 var_26;
uint16 frame; // 0x26
struct {
uint8 var_26a;
uint8 var_26b;
@ -235,7 +235,7 @@ typedef struct {
uint8 pad_1F[3]; // 0x1f
uint16 name_string_idx; // 0x22
uint16 var_24;
uint16 var_26;
uint16 frame; // 0x26
uint8 var_28[3];
uint8 var_2B;
uint8 colour[2];
@ -277,7 +277,7 @@ typedef struct {
uint8 pad_1F[3]; // 0x1f
uint16 name_string_idx; // 0x22
uint16 var_24;
uint16 var_26;
uint16 frame; // 0x26
} rct_crash_splash;
typedef struct {
@ -306,7 +306,7 @@ typedef struct {
uint8 pad_1F[3]; // 0x1F
uint16 name_string_idx; // 0x22
uint16 var_24;
uint16 var_26;
uint16 frame; // 0x26
} rct_steam_particle;
/**
@ -349,9 +349,9 @@ enum {
SPRITE_MISC_STEAM_PARTICLE,
SPRITE_MISC_MONEY_EFFECT,
SPRITE_MISC_CRASHED_VEHICLE_PARTICLE,
SPRITE_MISC_3, // (related to vehicle crash, probably crash particles)
SPRITE_MISC_EXPLOSION_CLOUD,
SPRITE_MISC_CRASH_SPLASH,
SPRITE_MISC_5, // (related to vehicle crash, probably crash particles)
SPRITE_MISC_EXPLOSION_FLARE,
SPRITE_MISC_JUMPING_FOUNTAIN_WATER,
SPRITE_MISC_BALLOON,
SPRITE_MISC_DUCK,
@ -384,8 +384,8 @@ void invalidate_sprite_2(rct_sprite *sprite);
void sprite_remove(rct_sprite *sprite);
void litter_create(int x, int y, int z, int direction, int type);
void litter_remove_at(int x, int y, int z);
void sprite_misc_3_create(int x, int y, int z);
void sprite_misc_5_create(int x, int y, int z);
void sprite_misc_explosion_cloud_create(int x, int y, int z);
void sprite_misc_explosion_flare_create(int x, int y, int z);
uint16 sprite_get_first_in_quadrant(int x, int y);
///////////////////////////////////////////////////////////////