2020-12-28 09:51:40 +01:00
|
|
|
#include "driver2.h"
|
|
|
|
#include "debris.h"
|
|
|
|
#include "motion_c.h"
|
|
|
|
#include "texture.h"
|
|
|
|
#include "pres.h"
|
|
|
|
#include "director.h"
|
|
|
|
#include "pause.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "cars.h"
|
|
|
|
#include "camera.h"
|
|
|
|
#include "dr2roads.h"
|
|
|
|
#include "convert.h"
|
|
|
|
#include "map.h"
|
|
|
|
#include "mission.h"
|
|
|
|
#include "draw.h"
|
|
|
|
#include "models.h"
|
|
|
|
#include "players.h"
|
|
|
|
#include "shadow.h"
|
|
|
|
#include "cosmetic.h"
|
|
|
|
#include "denting.h"
|
|
|
|
#include "gamesnd.h"
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-12-28 09:51:40 +01:00
|
|
|
#include "ASM/rndrasm.h"
|
2020-04-29 17:03:13 +02:00
|
|
|
|
2021-05-10 11:34:38 +02:00
|
|
|
struct DAMAGED_LAMP
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
char damage;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DAMAGED_OBJECT
|
|
|
|
{
|
|
|
|
CELL_OBJECT cop;
|
|
|
|
char active;
|
|
|
|
char damage;
|
|
|
|
int rot_speed;
|
|
|
|
SVECTOR velocity;
|
|
|
|
int vx;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SMOKE
|
|
|
|
{
|
|
|
|
UnpaddedHackVector position;
|
|
|
|
UnpaddedCharVector drift;
|
|
|
|
UnpaddedCharVector drift_change;
|
|
|
|
UnpaddedHackVector final_tail_pos;
|
|
|
|
u_char step;
|
|
|
|
u_char pos;
|
|
|
|
short start_w;
|
|
|
|
short final_w;
|
|
|
|
char life;
|
|
|
|
char halflife;
|
|
|
|
u_short flags;
|
|
|
|
u_char num;
|
|
|
|
u_char t_step;
|
|
|
|
short transparency;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DEBRIS
|
|
|
|
{
|
|
|
|
VECTOR position;
|
|
|
|
SVECTOR direction;
|
|
|
|
u_short life;
|
|
|
|
u_short flags;
|
|
|
|
u_short num;
|
|
|
|
u_short pos;
|
|
|
|
RGB rgb;
|
|
|
|
char step;
|
|
|
|
char type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LEAF
|
|
|
|
{
|
|
|
|
VECTOR position;
|
|
|
|
SVECTOR direction;
|
|
|
|
u_short life;
|
|
|
|
u_short flags;
|
|
|
|
u_short num;
|
|
|
|
u_short pos;
|
|
|
|
RGB rgb;
|
|
|
|
char step;
|
|
|
|
char type;
|
|
|
|
short sin_index1;
|
|
|
|
short sin_index2;
|
|
|
|
char sin_addition1;
|
|
|
|
char sin_addition2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TRI_POINT
|
|
|
|
{
|
|
|
|
BVECTOR v0;
|
|
|
|
BVECTOR v1;
|
|
|
|
BVECTOR v2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TRI_POINT_LONG
|
|
|
|
{
|
|
|
|
VECTOR_NOPAD v0;
|
|
|
|
VECTOR_NOPAD v1;
|
|
|
|
VECTOR_NOPAD v2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RAIN_TYPE
|
|
|
|
{
|
|
|
|
VECTOR_NOPAD position;
|
|
|
|
SVECTOR oldposition;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LAMP_STREAK
|
|
|
|
{
|
|
|
|
SXYPAIR light_trails[4];
|
|
|
|
int id;
|
|
|
|
short clock;
|
|
|
|
char set;
|
|
|
|
};
|
|
|
|
|
2020-04-19 12:11:33 +02:00
|
|
|
TEXTURE_DETAILS digit_texture;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
|
|
|
TRI_POINT debris_rot1[32]; // offset 0xC0A60
|
|
|
|
TRI_POINT debris_rot2[32]; // offset 0xC0BE0
|
|
|
|
TRI_POINT debris_rot3[32]; // offset 0xC0D60
|
|
|
|
TRI_POINT leaf_rot[32]; // offset 0xC1DC0
|
|
|
|
TRI_POINT litter_rot[32]; // offset 0xC08D0
|
|
|
|
|
|
|
|
TRI_POINT* debris_rot_table[5] = {
|
|
|
|
debris_rot1,
|
|
|
|
leaf_rot,
|
|
|
|
litter_rot,
|
|
|
|
debris_rot2,
|
|
|
|
debris_rot3,
|
|
|
|
};
|
|
|
|
|
2020-07-07 13:21:00 +02:00
|
|
|
CVECTOR debris_colour[4][31] =
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-07-07 13:21:00 +02:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
{ 100, 100, 100, 0 },
|
|
|
|
{ 214, 214, 244, 0 },
|
|
|
|
{ 195, 79, 65, 0 },
|
|
|
|
{ 83, 83, 101, 0 },
|
|
|
|
{ 197, 142, 80, 0 },
|
|
|
|
{ 222, 204, 196, 0 },
|
|
|
|
{ 189, 168, 114, 0 },
|
|
|
|
{ 203, 180, 121, 0 },
|
|
|
|
{ 132, 145, 103, 0 },
|
|
|
|
{ 168, 143, 122, 0 },
|
|
|
|
{ 107, 107, 107, 0 },
|
|
|
|
{ 192, 110, 110, 0 },
|
|
|
|
{ 130, 130, 130, 0 },
|
|
|
|
{ 101, 129, 145, 0 },
|
|
|
|
{ 130, 130, 130, 0 },
|
|
|
|
{ 181, 88, 88, 0 },
|
|
|
|
{ 130, 105, 83, 0 },
|
|
|
|
{ 164, 164, 164, 0 },
|
|
|
|
{ 126, 143, 108, 0 },
|
|
|
|
{ 140, 163, 181, 0 },
|
|
|
|
{ 143, 129, 152, 0 },
|
|
|
|
{ 156, 138, 118, 0 },
|
|
|
|
{ 190, 190, 190, 0 },
|
|
|
|
{ 203, 112, 112, 0 },
|
|
|
|
{ 255, 242, 201, 0 },
|
|
|
|
{ 167, 145, 90, 0 },
|
|
|
|
{ 190, 190, 190, 0 },
|
|
|
|
{ 150, 164, 184, 0 },
|
|
|
|
{ 102, 102, 102, 0 },
|
|
|
|
{ 140, 114, 99, 0 },
|
|
|
|
{ 75, 63, 134, 0 },
|
2020-07-07 13:21:00 +02:00
|
|
|
}, {
|
2020-11-06 20:47:33 +01:00
|
|
|
{ 100, 100, 100, 0 },
|
|
|
|
{ 83, 82, 97, 0 },
|
|
|
|
{ 138, 179, 201, 0 },
|
|
|
|
{ 114, 159, 183, 0 },
|
|
|
|
{ 107, 61, 46, 0 },
|
|
|
|
{ 162, 120, 76, 0 },
|
|
|
|
{ 235, 227, 214, 0 },
|
|
|
|
{ 197, 138, 121, 0 },
|
|
|
|
{ 159, 169, 131, 0 },
|
|
|
|
{ 146, 178, 195, 0 },
|
|
|
|
{ 181, 151, 101, 0 },
|
|
|
|
{ 230, 191, 139, 0 },
|
|
|
|
{ 147, 147, 151, 0 },
|
|
|
|
{ 182, 127, 138, 0 },
|
|
|
|
{ 160, 165, 127, 0 },
|
|
|
|
{ 175, 203, 225, 0 },
|
|
|
|
{ 211, 175, 117, 0 },
|
|
|
|
{ 209, 167, 118, 0 },
|
|
|
|
{ 157, 147, 140, 0 },
|
|
|
|
{ 210, 191, 145, 0 },
|
|
|
|
{ 155, 185, 148, 0 },
|
|
|
|
{ 158, 210, 254, 0 },
|
|
|
|
{ 206, 176, 134, 0 },
|
|
|
|
{ 236, 173, 117, 0 },
|
|
|
|
{ 146, 146, 146, 0 },
|
|
|
|
{ 88, 103, 128, 0 },
|
|
|
|
{ 96, 96, 96, 0 },
|
|
|
|
{ 125, 92, 92, 0 },
|
|
|
|
{ 184, 174, 155, 0 },
|
|
|
|
{ 42, 42, 42, 0 },
|
|
|
|
{ 219, 37, 130, 0 },
|
2020-07-07 13:21:00 +02:00
|
|
|
}, {
|
2020-11-06 20:47:33 +01:00
|
|
|
{ 100, 100, 100, 0 },
|
|
|
|
{ 112, 110, 112, 0 },
|
|
|
|
{ 230, 212, 214, 0 },
|
|
|
|
{ 178, 181, 175, 0 },
|
|
|
|
{ 120, 120, 120, 0 },
|
|
|
|
{ 102, 101, 115, 0 },
|
|
|
|
{ 70, 83, 100, 0 },
|
|
|
|
{ 206, 108, 88, 0 },
|
|
|
|
{ 220, 136, 107, 0 },
|
|
|
|
{ 97, 97, 97, 0 },
|
|
|
|
{ 139, 116, 150, 0 },
|
|
|
|
{ 173, 173, 173, 0 },
|
|
|
|
{ 104, 133, 173, 0 },
|
|
|
|
{ 224, 196, 139, 0 },
|
|
|
|
{ 108, 146, 141, 0 },
|
|
|
|
{ 82, 82, 82, 0 },
|
|
|
|
{ 123, 123, 123, 0 },
|
|
|
|
{ 140, 67, 67, 0 },
|
|
|
|
{ 103, 92, 121, 0 },
|
|
|
|
{ 219, 192, 148, 0 },
|
|
|
|
{ 160, 185, 195, 0 },
|
|
|
|
{ 158, 173, 130, 0 },
|
|
|
|
{ 183, 183, 183, 0 },
|
|
|
|
{ 126, 98, 84, 0 },
|
|
|
|
{ 126, 125, 156, 0 },
|
|
|
|
{ 36, 74, 203, 0 },
|
|
|
|
{ 105, 105, 105, 0 },
|
|
|
|
{ 162, 179, 183, 0 },
|
|
|
|
{ 102, 130, 162, 0 },
|
|
|
|
{ 149, 88, 88, 0 },
|
|
|
|
{ 119, 145, 129, 0 },
|
2020-07-07 13:21:00 +02:00
|
|
|
}, {
|
2020-11-06 20:47:33 +01:00
|
|
|
{ 100, 100, 100, 0 },
|
|
|
|
{ 153, 149, 150, 0 },
|
|
|
|
{ 118, 110, 131, 0 },
|
|
|
|
{ 135, 110, 89, 0 },
|
|
|
|
{ 191, 102, 66, 0 },
|
|
|
|
{ 95, 90, 101, 0 },
|
|
|
|
{ 157, 171, 186, 0 },
|
|
|
|
{ 203, 184, 132, 0 },
|
|
|
|
{ 221, 100, 100, 0 },
|
|
|
|
{ 149, 149, 149, 0 },
|
|
|
|
{ 100, 118, 145, 0 },
|
|
|
|
{ 78, 78, 78, 0 },
|
|
|
|
{ 105, 128, 107, 0 },
|
|
|
|
{ 203, 94, 94, 0 },
|
|
|
|
{ 163, 178, 152, 0 },
|
|
|
|
{ 167, 119, 117, 0 },
|
|
|
|
{ 117, 139, 142, 0 },
|
|
|
|
{ 160, 160, 160, 0 },
|
|
|
|
{ 92, 92, 92, 0 },
|
|
|
|
{ 229, 144, 136, 0 },
|
|
|
|
{ 145, 167, 149, 0 },
|
|
|
|
{ 198, 173, 173, 0 },
|
|
|
|
{ 137, 163, 175, 0 },
|
|
|
|
{ 173, 173, 173, 0 },
|
|
|
|
{ 143, 143, 143, 0 },
|
|
|
|
{ 218, 198, 154, 0 },
|
|
|
|
{ 104, 134, 78, 0 },
|
|
|
|
{ 172, 116, 86, 0 },
|
|
|
|
{ 155, 170, 185, 0 },
|
|
|
|
{ 122, 142, 147, 0 },
|
|
|
|
{ 193, 193, 193, 0 }
|
2020-07-07 13:21:00 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
};
|
|
|
|
|
2021-04-25 22:47:53 +02:00
|
|
|
u_char grassColour[4][3] = {
|
2020-10-17 09:26:57 +02:00
|
|
|
{110, 115, 67},
|
|
|
|
{64, 55, 49},
|
|
|
|
{91, 104, 56},
|
|
|
|
{118, 108, 89}
|
2020-03-27 21:47:29 +01:00
|
|
|
};
|
|
|
|
|
2020-06-05 09:20:26 +02:00
|
|
|
|
|
|
|
TRI_POINT_LONG debris1_vert =
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
{-16,0,0},
|
|
|
|
{0,-16,0},
|
|
|
|
{16,16,0}
|
2020-06-05 09:20:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
TRI_POINT_LONG debris2_vert =
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
{-4,4,0},
|
|
|
|
{0,-4,0},
|
|
|
|
{4,4,0}
|
2020-06-05 09:20:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
TRI_POINT_LONG debris3_vert =
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
{-80,0,15},
|
|
|
|
{0, 0,15},
|
|
|
|
{80,0,-15}
|
2020-06-05 09:20:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
TRI_POINT_LONG leaf_vert =
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
{-30,5,7},
|
|
|
|
{0,0,10},
|
|
|
|
{0,0,-7}
|
2020-06-05 09:20:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
TRI_POINT_LONG litter_vert =
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
{-25,0,25},
|
|
|
|
{25,0,25},
|
|
|
|
{-25,0,-25}
|
2020-06-05 09:20:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
TRI_POINT_LONG* debris_data[5] = {
|
|
|
|
&debris1_vert,
|
|
|
|
&leaf_vert,
|
|
|
|
&litter_vert,
|
|
|
|
&debris2_vert,
|
|
|
|
&debris3_vert,
|
|
|
|
};
|
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
VECTOR dummy = { 0 };
|
|
|
|
|
2020-04-05 00:53:41 +02:00
|
|
|
int gNight = 0;
|
2021-04-09 18:00:28 +02:00
|
|
|
u_char gRainCount = 30;
|
2020-04-05 00:53:41 +02:00
|
|
|
int gEffectsTimer = 41;
|
|
|
|
|
2020-05-06 06:02:48 +02:00
|
|
|
int NextDamagedPmeter = 0;
|
|
|
|
int SmashablesHit = 0;
|
2020-10-17 09:26:57 +02:00
|
|
|
DAMAGED_OBJECT damaged_object[MAX_SMASHED_OBJECTS];
|
2020-05-06 06:02:48 +02:00
|
|
|
|
2020-05-27 14:24:08 +02:00
|
|
|
int next_debris = 0;
|
2020-10-17 09:26:57 +02:00
|
|
|
short debris_alloc[MAX_DEBRIS];
|
2020-05-27 14:24:08 +02:00
|
|
|
|
|
|
|
int next_leaf = 0;
|
2020-10-17 09:26:57 +02:00
|
|
|
short leaf_alloc[MAX_LEAVES];
|
2020-05-27 14:24:08 +02:00
|
|
|
|
|
|
|
int next_smoke = 0;
|
2020-10-17 09:26:57 +02:00
|
|
|
short smoke_alloc[MAX_SMOKE];
|
2020-05-27 14:24:08 +02:00
|
|
|
|
|
|
|
int gNextRainDrop = 0;
|
2020-10-17 09:26:57 +02:00
|
|
|
short gRainAlloc[MAX_RAIN_DROPS];
|
2020-05-27 14:24:08 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
RAIN_TYPE gRain[MAX_RAIN_DROPS];
|
2020-05-27 14:24:08 +02:00
|
|
|
|
2020-05-31 16:16:47 +02:00
|
|
|
char PoolPrimData[16] = {
|
|
|
|
|
|
|
|
0x0, 0x8, 0x2, 0x9,
|
|
|
|
0x8, 0x1, 0x9, 0x3,
|
|
|
|
0x4, 0xA, 0x6, 0xB,
|
|
|
|
0xA, 0x5, 0xB, 0x7
|
|
|
|
};
|
|
|
|
|
|
|
|
int LightSortCorrect = 0;
|
|
|
|
|
|
|
|
TEXTURE_DETAILS smoke_texture;
|
|
|
|
TEXTURE_DETAILS debris_texture;
|
|
|
|
TEXTURE_DETAILS litter_texture;
|
|
|
|
TEXTURE_DETAILS cop_texture;
|
|
|
|
TEXTURE_DETAILS light_texture;
|
|
|
|
TEXTURE_DETAILS gTyreTexture;
|
|
|
|
TEXTURE_DETAILS flare_texture;
|
|
|
|
TEXTURE_DETAILS sea_texture;
|
|
|
|
TEXTURE_DETAILS bird_texture1;
|
|
|
|
TEXTURE_DETAILS bird_texture2;
|
|
|
|
TEXTURE_DETAILS lensflare_texture;
|
|
|
|
TEXTURE_DETAILS sun_texture;
|
|
|
|
TEXTURE_DETAILS moon_texture;
|
|
|
|
TEXTURE_DETAILS drop_texture;
|
|
|
|
TEXTURE_DETAILS collon_texture;
|
|
|
|
|
|
|
|
TEXTURE_DETAILS texturePedHead;
|
|
|
|
TEXTURE_DETAILS tannerShadow_texture;
|
|
|
|
|
|
|
|
TEXTURE_DETAILS lightref_texture;
|
|
|
|
TEXTURE_DETAILS light_pool_texture;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
LAMP_STREAK Known_Lamps[MAX_LAMP_STREAKS];
|
|
|
|
int NewLamp[MAX_LAMP_STREAKS];
|
2020-06-05 09:20:26 +02:00
|
|
|
int LightIndex = 0;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-07-05 20:33:14 +02:00
|
|
|
int variable_weather = 0;
|
|
|
|
|
2020-08-08 16:15:29 +02:00
|
|
|
int gDoLeaves = 1;
|
|
|
|
|
|
|
|
SMOKE* smoke_table;
|
2020-10-17 09:26:57 +02:00
|
|
|
SMOKE smoke[MAX_SMOKE];
|
2020-08-08 16:15:29 +02:00
|
|
|
|
|
|
|
SVECTOR leaf_rotvec;
|
2020-10-17 09:26:57 +02:00
|
|
|
LEAF leaf[MAX_LEAVES];
|
2020-08-08 16:15:29 +02:00
|
|
|
|
|
|
|
SVECTOR debris_rotvec;
|
2020-10-17 09:26:57 +02:00
|
|
|
DEBRIS debris[MAX_DEBRIS];
|
2020-08-08 16:15:29 +02:00
|
|
|
|
|
|
|
int StreakCount1 = 0;
|
|
|
|
int main_cop_light_pos = 0;
|
|
|
|
int NextDamagedLamp = 0;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
CELL_OBJECT ground_debris[MAX_GROUND_DEBRIS];
|
2020-08-08 16:15:29 +02:00
|
|
|
int groundDebrisIndex = 0;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
DAMAGED_LAMP damaged_lamp[MAX_DAMAGED_LAMPS];
|
2020-08-08 16:15:29 +02:00
|
|
|
|
|
|
|
MATRIX debris_mat;
|
|
|
|
MATRIX leaf_mat;
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
void PlacePoolForCar(CAR_DATA *cp, CVECTOR *col, int front, int in_car)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
short brightness;
|
2020-05-31 16:16:47 +02:00
|
|
|
POLY_FT4 *poly;
|
2020-11-06 20:47:33 +01:00
|
|
|
int i;
|
2020-05-31 16:16:47 +02:00
|
|
|
SVECTOR s[27];
|
|
|
|
SVECTOR sout[27];
|
|
|
|
VECTOR s1[12];
|
|
|
|
VECTOR mid_position;
|
|
|
|
VECTOR toss;
|
2020-11-06 20:47:33 +01:00
|
|
|
VECTOR *pos;
|
|
|
|
CAR_COSMETICS* car_cos;
|
2021-03-10 12:06:34 +01:00
|
|
|
CVECTOR color;
|
2020-11-06 20:47:33 +01:00
|
|
|
int Z;
|
|
|
|
int sub_level;
|
|
|
|
int car_road_height;
|
|
|
|
int count;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
pos = (VECTOR*)cp->hd.where.t;
|
|
|
|
car_cos = &car_cosmetics[cp->ap.model];
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
// [A] there was check that prevented in_car lights in game, but it was working in quick replays...
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (front)
|
2020-05-31 16:16:47 +02:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
s1[3].vz = -(car_cos->colBox.vz + 50);
|
|
|
|
s1[8].vz = s1[3].vz - 1160;
|
2020-05-31 16:16:47 +02:00
|
|
|
s1[6].vz = s1[3].vz;
|
|
|
|
s1[7].vz = s1[3].vz;
|
|
|
|
|
2020-06-05 09:20:26 +02:00
|
|
|
if (in_car)
|
2020-05-31 16:16:47 +02:00
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
// slightly shifted vertices to make it look more beautiful
|
2020-05-31 16:16:47 +02:00
|
|
|
s1[1].vz = s1[8].vz + 600;
|
2020-11-06 20:47:33 +01:00
|
|
|
s1[0].vx = 136;
|
|
|
|
s1[1].vx = -344;
|
|
|
|
s1[2].vx = -21;
|
|
|
|
s1[3].vx = -143;
|
|
|
|
s1[4].vx = 344;
|
|
|
|
s1[5].vx = -136;
|
|
|
|
s1[6].vx = 143;
|
|
|
|
s1[7].vx = 21;
|
|
|
|
s1[8].vz = s1[8].vz - 400;
|
2020-05-31 16:16:47 +02:00
|
|
|
s1[9].vz = s1[3].vz + 10;
|
2020-11-06 20:47:33 +01:00
|
|
|
s1[8].vx = -82;
|
|
|
|
s1[10].vx = 82;
|
|
|
|
s1[9].vx = -82;
|
|
|
|
s1[11].vx = 82;
|
2020-05-31 16:16:47 +02:00
|
|
|
s1[4].vz = s1[1].vz;
|
|
|
|
s1[5].vz = s1[1].vz;
|
|
|
|
s1[10].vz = s1[8].vz;
|
|
|
|
s1[11].vz = s1[9].vz;
|
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
LightSortCorrect = -800;
|
2020-11-06 20:47:33 +01:00
|
|
|
|
|
|
|
sub_level = 3;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-05-31 16:16:47 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
s1[1].vz = s1[8].vz + 100;
|
2020-11-06 20:47:33 +01:00
|
|
|
s1[0].vx = 136;
|
|
|
|
s1[1].vx = -344;
|
|
|
|
s1[2].vx = -21;
|
|
|
|
s1[3].vx = -143;
|
|
|
|
s1[4].vx = 344;
|
|
|
|
s1[5].vx = -136;
|
|
|
|
s1[6].vx = 143;
|
|
|
|
s1[7].vx = 21;
|
|
|
|
s1[10].vx = 82;
|
|
|
|
s1[11].vx = 82;
|
|
|
|
s1[8].vx = -82;
|
|
|
|
s1[9].vx = -82;
|
2020-05-31 16:16:47 +02:00
|
|
|
s1[4].vz = s1[1].vz;
|
|
|
|
s1[5].vz = s1[1].vz;
|
|
|
|
s1[9].vz = s1[3].vz;
|
|
|
|
s1[10].vz = s1[8].vz;
|
|
|
|
s1[11].vz = s1[3].vz;
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
sub_level = 3;
|
2020-06-06 13:34:53 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (player[CurrentPlayerView].cameraView == 2 && cp == &car_data[player[CurrentPlayerView].playerCarId])
|
|
|
|
LightSortCorrect = -320;
|
|
|
|
else
|
|
|
|
LightSortCorrect = -200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
// back light
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
s1[0].vx = -204;
|
|
|
|
s1[1].vx = 204;
|
|
|
|
s1[2].vx = -204;
|
|
|
|
s1[3].vx = 204;
|
|
|
|
s1[3].vz = (car_cos->colBox.vz - 10);
|
|
|
|
s1[1].vz = s1[3].vz + 204;
|
|
|
|
|
|
|
|
sub_level = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-05-31 16:16:47 +02:00
|
|
|
|
|
|
|
s1[0].vz = s1[1].vz;
|
|
|
|
s1[2].vz = s1[3].vz;
|
|
|
|
|
|
|
|
SetRotMatrix(&cp->hd.drawCarMat);
|
|
|
|
|
|
|
|
mid_position.vx = 0;
|
|
|
|
mid_position.vy = 0;
|
|
|
|
mid_position.vz = -500;
|
|
|
|
|
|
|
|
_MatrixRotate(&mid_position);
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
mid_position.vx += pos->vx;
|
|
|
|
mid_position.vy += pos->vy;
|
|
|
|
mid_position.vz += pos->vz;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
car_road_height = MapHeight(&mid_position);
|
|
|
|
|
|
|
|
if (sub_level == 3)
|
|
|
|
count = 12;
|
|
|
|
else
|
|
|
|
count = 4;
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
// adjust height and poisition for each vertex
|
2020-11-06 20:47:33 +01:00
|
|
|
for(i = 0; i < count; i++)
|
2020-05-31 16:16:47 +02:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
int temp_y;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
s1[i].vy = 0;
|
|
|
|
_MatrixRotate(&s1[i]);
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
toss.vx = s1[i].vx + pos->vx;
|
|
|
|
toss.vy = s1[i].vy + pos->vy;
|
|
|
|
toss.vz = s1[i].vz + pos->vz;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
s[i].vx = toss.vx - camera_position.vx;
|
|
|
|
s[i].vz = toss.vz - camera_position.vz;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
temp_y = MapHeight(&toss);
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (ABS(-temp_y + car_road_height) > 500)
|
|
|
|
s[i].vy = -car_road_height - camera_position.vy;
|
|
|
|
else
|
|
|
|
s[i].vy = -temp_y - camera_position.vy;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (FIXEDH(s[0].vy * s[1].vz - s[0].vz * s[1].vy) * s[2].vx +
|
|
|
|
FIXEDH(s[0].vz * s[1].vx - s[0].vx * s[1].vz) * s[2].vy +
|
|
|
|
FIXEDH(s[0].vx * s[1].vy - s[0].vy * s[1].vx) * s[2].vz >= 0)
|
2020-05-31 16:16:47 +02:00
|
|
|
{
|
|
|
|
gte_SetRotMatrix(&inv_camera_matrix);
|
|
|
|
gte_SetTransVector(&dummy);
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (sub_level == 0)
|
2020-05-31 16:16:47 +02:00
|
|
|
{
|
|
|
|
gte_ldv3(&s[0], &s[1], &s[2]);
|
|
|
|
gte_rtpt();
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
gte_stszotz(&Z);
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (Z > 40)
|
|
|
|
Z -= 40;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (Z > 49)
|
2020-05-31 16:16:47 +02:00
|
|
|
{
|
|
|
|
poly = (POLY_FT4 *)current->primptr;
|
|
|
|
|
|
|
|
// [A] Emit poly only after ot z checked
|
|
|
|
setPolyFT4(poly);
|
|
|
|
setSemiTrans(poly, 1);
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
*(ushort*)&poly->u0 = *(ushort*)&light_pool_texture.coords.u0;
|
|
|
|
*(ushort*)&poly->u1 = *(ushort*)&light_pool_texture.coords.u1;
|
|
|
|
*(ushort*)&poly->u2 = *(ushort*)&light_pool_texture.coords.u2;
|
|
|
|
*(ushort*)&poly->u3 = *(ushort*)&light_pool_texture.coords.u3;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
poly->r0 = col->r / 2;
|
2021-03-10 12:06:34 +01:00
|
|
|
poly->g0 = col->g / 2;
|
|
|
|
poly->b0 = col->b / 2;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
|
|
|
|
poly->tpage = light_pool_texture.tpageid | 0x20;
|
|
|
|
poly->clut = light_pool_texture.clutid;
|
|
|
|
|
|
|
|
gte_ldv0(&s[3]);
|
|
|
|
gte_rtps();
|
|
|
|
gte_stsxy(&poly->x3);
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
addPrim(current->ot + (Z >> 1), poly);
|
2020-05-31 16:16:47 +02:00
|
|
|
current->primptr += sizeof(POLY_FT4);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-11-06 20:47:33 +01:00
|
|
|
else if (sub_level == 3)
|
2020-05-31 16:16:47 +02:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
for(i = 0; i < 12; i++)
|
|
|
|
{
|
|
|
|
gte_ldv0(&s[i]);
|
2020-10-17 09:26:57 +02:00
|
|
|
gte_rtv0tr();
|
2020-11-06 20:47:33 +01:00
|
|
|
gte_stsv(&sout[i]);
|
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
// draw front light quads
|
2020-11-06 20:47:33 +01:00
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
char* VertIdx;
|
|
|
|
|
|
|
|
VertIdx = PoolPrimData + i * 4;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
gte_SetRotMatrix(&identity);
|
2020-10-17 09:26:57 +02:00
|
|
|
gte_SetTransVector(&dummy);
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (i & 2)
|
|
|
|
brightness = LeftLight + LeftLight * 4;
|
|
|
|
else
|
|
|
|
brightness = RightLight + RightLight * 4;
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (brightness)
|
2020-10-17 09:26:57 +02:00
|
|
|
{
|
2021-03-10 12:06:34 +01:00
|
|
|
int test = col->r * brightness;
|
|
|
|
|
|
|
|
color.r = MIN(255, col->r * brightness >> 4);
|
|
|
|
color.g = MIN(255, col->g * brightness >> 4);
|
|
|
|
color.b = MIN(255, col->b * brightness >> 4);
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (i & 1)
|
2020-05-31 16:16:47 +02:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
sQuad(sout + VertIdx[0],
|
|
|
|
sout + VertIdx[2],
|
|
|
|
sout + VertIdx[3],
|
2021-03-10 12:06:34 +01:00
|
|
|
sout + VertIdx[1], &color, LightSortCorrect);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-10-17 09:26:57 +02:00
|
|
|
else
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
sQuad(sout + VertIdx[1],
|
|
|
|
sout + VertIdx[3],
|
|
|
|
sout + VertIdx[2],
|
2021-03-10 12:06:34 +01:00
|
|
|
sout + VertIdx[0], &color, LightSortCorrect);
|
2020-10-17 09:26:57 +02:00
|
|
|
}
|
|
|
|
}
|
2020-11-06 20:47:33 +01:00
|
|
|
}
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-05-31 16:16:47 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
LightSortCorrect = -10;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int AllocateLeaf(void)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
if (next_leaf < MAX_LEAVES)
|
|
|
|
return leaf_alloc[next_leaf++];
|
2020-05-27 14:24:08 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
return -1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void ReleaseLeaf(short num)
|
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
leaf_alloc[--next_leaf] = num;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void AddLeaf(VECTOR *Position, int num_leaves, int Type)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-11-07 12:45:04 +01:00
|
|
|
int num;
|
2020-11-06 20:47:33 +01:00
|
|
|
int temprand;
|
|
|
|
int i;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-08-08 16:15:29 +02:00
|
|
|
if (gDoLeaves == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Position->vy = -Position->vy;
|
|
|
|
Position->pad = MapHeight(Position);
|
2020-11-06 20:47:33 +01:00
|
|
|
for (i = 0; i < num_leaves; i++)
|
2020-08-08 16:15:29 +02:00
|
|
|
{
|
2020-11-07 12:45:04 +01:00
|
|
|
num = AllocateLeaf();
|
2020-10-17 09:26:57 +02:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
if (num == -1)
|
2020-08-08 16:15:29 +02:00
|
|
|
return;
|
2020-11-06 20:47:33 +01:00
|
|
|
|
2020-11-07 12:45:04 +01:00
|
|
|
LEAF* myleaf = &leaf[num];
|
2020-11-06 20:47:33 +01:00
|
|
|
|
|
|
|
temprand = rand();
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
myleaf->position.vx = Position->vx + (temprand & 0xfe);
|
|
|
|
myleaf->position.vz = Position->vz + (temprand >> 8 & 0xfe);
|
2020-08-08 16:15:29 +02:00
|
|
|
|
|
|
|
if (Type == 1)
|
2020-11-06 20:47:33 +01:00
|
|
|
myleaf->position.vy = -Position->vy;
|
2020-08-08 16:15:29 +02:00
|
|
|
else
|
2020-11-06 20:47:33 +01:00
|
|
|
myleaf->position.vy = -Position->pad;
|
|
|
|
|
|
|
|
myleaf->position.pad = Position->pad;
|
2020-08-08 16:15:29 +02:00
|
|
|
|
|
|
|
myleaf->life = 600;
|
2021-03-01 21:10:38 +01:00
|
|
|
myleaf->flags = 0x2;
|
2020-11-06 20:47:33 +01:00
|
|
|
|
2020-08-08 16:15:29 +02:00
|
|
|
myleaf->direction.vx = 0;
|
|
|
|
myleaf->direction.vy = 0;
|
|
|
|
myleaf->direction.vz = 0;
|
2020-11-06 20:47:33 +01:00
|
|
|
|
|
|
|
myleaf->pos = (temprand >> 7) & 0xff;
|
|
|
|
myleaf->step = (temprand & 7) + 1;
|
2020-08-08 16:15:29 +02:00
|
|
|
|
|
|
|
if (Type == 1)
|
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
// tree leaves
|
2020-11-06 20:47:33 +01:00
|
|
|
if ((temprand & 3) == 0)
|
2020-08-08 16:15:29 +02:00
|
|
|
{
|
2020-08-10 17:42:11 +02:00
|
|
|
myleaf->rgb.r = 110;
|
|
|
|
myleaf->rgb.g = 112;
|
2020-11-06 20:47:33 +01:00
|
|
|
myleaf->rgb.b = 15;
|
2020-08-08 16:15:29 +02:00
|
|
|
}
|
2020-11-06 20:47:33 +01:00
|
|
|
else if ((temprand & 3) == 1)
|
|
|
|
{
|
|
|
|
myleaf->rgb.r = 20;
|
|
|
|
myleaf->rgb.g = 44;
|
|
|
|
myleaf->rgb.b = 0;
|
|
|
|
}
|
|
|
|
else
|
2020-08-08 16:15:29 +02:00
|
|
|
{
|
|
|
|
myleaf->rgb.r = 60;
|
|
|
|
myleaf->rgb.g = 50;
|
2020-11-06 20:47:33 +01:00
|
|
|
myleaf->rgb.b = 30;
|
2020-08-08 16:15:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
// news, papers etc
|
2020-11-06 20:47:33 +01:00
|
|
|
myleaf->rgb.r = myleaf->rgb.g = myleaf->rgb.b = temprand & 0x1f;
|
2020-08-08 16:15:29 +02:00
|
|
|
}
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
// apply colors
|
2020-08-08 16:15:29 +02:00
|
|
|
if (gTimeOfDay == 3)
|
|
|
|
{
|
2021-04-04 21:33:43 +02:00
|
|
|
*(u_int*)&myleaf->rgb = *(u_int*)&myleaf->rgb >> 2 & 0x3f3f3f3f;
|
2020-08-08 16:15:29 +02:00
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
else if (gWeather == 1 || gWeather == 2)
|
2020-08-08 16:15:29 +02:00
|
|
|
{
|
2021-04-04 21:33:43 +02:00
|
|
|
*(u_int*)&myleaf->rgb = *(u_int*)&myleaf->rgb >> 1 & 0x7f7f7f7f;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
myleaf->sin_index1 = temprand & 0xfff;
|
|
|
|
myleaf->sin_index2 = temprand >> 4 & 0xfff;
|
|
|
|
myleaf->sin_addition2 = -(temprand >> 8 & 7);
|
|
|
|
myleaf->sin_addition1 = -(temprand & 3);
|
|
|
|
|
2020-08-08 16:15:29 +02:00
|
|
|
myleaf->type = Type;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
void SwirlLeaves(CAR_DATA *cp)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-08-08 16:15:29 +02:00
|
|
|
int XDiff;
|
|
|
|
int ZDiff;
|
|
|
|
LEAF *lpLeaf;
|
|
|
|
int count;
|
2020-11-06 20:47:33 +01:00
|
|
|
VECTOR plpos;
|
2020-11-07 10:54:15 +01:00
|
|
|
|
2020-08-08 16:15:29 +02:00
|
|
|
lpLeaf = leaf;
|
2020-11-06 20:47:33 +01:00
|
|
|
plpos.vx = cp->hd.where.t[0];
|
|
|
|
plpos.vy = cp->hd.where.t[1];
|
|
|
|
plpos.vz = cp->hd.where.t[2];
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (cp->hd.wheel_speed + 39999U <= 0x1d4be || gDoLeaves == 0 || pauseflag != 0)
|
|
|
|
return;
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
for (count = 0; count < MAX_LEAVES; count++)
|
|
|
|
{
|
|
|
|
XDiff = plpos.vx - lpLeaf->position.vx;
|
|
|
|
ZDiff = plpos.vz - lpLeaf->position.vz;
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
if ((lpLeaf->flags & 0x2) &&
|
2020-11-06 20:47:33 +01:00
|
|
|
lpLeaf->position.vy + plpos.vy > -180 &&
|
|
|
|
XDiff > -360 && XDiff < 360 && ZDiff > -360 && ZDiff < 360)
|
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
// set lifting direction
|
2020-11-06 20:47:33 +01:00
|
|
|
lpLeaf->direction.vy = -25 - (rand() & 0x1f);
|
2020-11-07 10:54:15 +01:00
|
|
|
lpLeaf->position.vy -= 1;
|
2020-11-06 20:47:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
lpLeaf++;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void InitDebrisNames(void)
|
|
|
|
{
|
2020-04-19 12:11:33 +02:00
|
|
|
GetTextureDetails("SMOKE", &smoke_texture);
|
|
|
|
GetTextureDetails("DEBRIS", &debris_texture);
|
|
|
|
GetTextureDetails("LITTER", &litter_texture);
|
|
|
|
GetTextureDetails("COPLIGHT", &cop_texture);
|
|
|
|
GetTextureDetails("LIGHT", &light_texture);
|
|
|
|
GetTextureDetails("SKID", &gTyreTexture);
|
|
|
|
GetTextureDetails("FLARE", &flare_texture);
|
|
|
|
GetTextureDetails("SPLASH", &sea_texture);
|
|
|
|
GetTextureDetails("SWBIRD1", &bird_texture1);
|
|
|
|
GetTextureDetails("SWBIRD2", &bird_texture2);
|
|
|
|
GetTextureDetails("LENSFLR", &lensflare_texture);
|
|
|
|
GetTextureDetails("SKYSUN", &sun_texture);
|
|
|
|
GetTextureDetails("SKYMOON", &moon_texture);
|
|
|
|
GetTextureDetails("DROP", &drop_texture);
|
|
|
|
|
|
|
|
GetTextureDetails("DIGIT", &digit_texture);
|
|
|
|
SetCLUT16Flags(digit_texture.clutid, 6, 0);
|
|
|
|
|
|
|
|
GetTextureDetails("COLLON", &collon_texture);
|
|
|
|
GetTextureDetails("JEANS1", &jeans_texture);
|
|
|
|
GetTextureDetails("ARM1", &arm1_texture);
|
|
|
|
GetTextureDetails("FOREARM1", &forearm1_texture);
|
|
|
|
GetTextureDetails("CHEST1", &chest1_texture);
|
|
|
|
GetTextureDetails("LOWHEAD", &head1_texture);
|
|
|
|
GetTextureDetails("ADDCAM", &addcam);
|
|
|
|
GetTextureDetails("FRAMEADV", &frameadv);
|
|
|
|
GetTextureDetails("AUTO", &autocam);
|
|
|
|
GetTextureDetails("CHASEC", &chasecar);
|
|
|
|
GetTextureDetails("CHOOSECA", &choosecar);
|
|
|
|
GetTextureDetails("CLOCK", &clock);
|
|
|
|
GetTextureDetails("DELCAM", &delcam);
|
|
|
|
GetTextureDetails("EDITCAM", &editcam);
|
|
|
|
GetTextureDetails("FIXEDCA", &fixedcam);
|
|
|
|
GetTextureDetails("INCAR", &incar);
|
|
|
|
GetTextureDetails("LENSCHA", &lenschan);
|
|
|
|
GetTextureDetails("LOOKCAR", &lookcar);
|
|
|
|
GetTextureDetails("MOVECMP", &movecam);
|
|
|
|
GetTextureDetails("MOVECAM", &movecampos);
|
|
|
|
GetTextureDetails("OK", &ok);
|
|
|
|
GetTextureDetails("PAUSE", &pause);
|
|
|
|
GetTextureDetails("PLAYCAM", &playcam);
|
|
|
|
GetTextureDetails("PLAYPAU", &playpause);
|
|
|
|
GetTextureDetails("SAVE2CA", &save2card);
|
|
|
|
GetTextureDetails("RESTREP", &restart);
|
|
|
|
GetTextureDetails("HEAD1", &texturePedHead);
|
|
|
|
GetTextureDetails("TSHADOW", &tannerShadow_texture);
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
head1_texture.coords.u1 = head1_texture.coords.u0 + 8;
|
2020-04-04 06:49:28 +02:00
|
|
|
head1_texture.coords.u3 = head1_texture.coords.u1;
|
2020-04-19 12:11:33 +02:00
|
|
|
|
|
|
|
GetTextureDetails("LIGHTREF", &lightref_texture);
|
|
|
|
GetTextureDetails("LIGHT", &light_pool_texture);
|
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
InitButtonTextures();
|
|
|
|
InitTannerShadow();
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void InitDebris(void)
|
|
|
|
{
|
2020-06-05 09:20:26 +02:00
|
|
|
int i, j;
|
|
|
|
TRI_POINT_LONG temptri;
|
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
StreakCount1 = 0;
|
|
|
|
next_debris = 0;
|
2020-06-05 09:20:26 +02:00
|
|
|
next_smoke = 0;
|
|
|
|
next_leaf = 0;
|
|
|
|
NextDamagedLamp = 0;
|
|
|
|
smoke_table = NULL;
|
|
|
|
|
|
|
|
main_cop_light_pos = rand() % 7;
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
gDoLeaves = (NumPlayers == 1); // [A] disable in multiplayer (temporarily) due to their flicker
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
for (i = 0; i < MAX_LAMP_STREAKS; i++)
|
|
|
|
{
|
2020-06-05 09:20:26 +02:00
|
|
|
Known_Lamps[i].set = 0;
|
2020-10-17 09:26:57 +02:00
|
|
|
}
|
2020-06-05 09:20:26 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
for (i = 0; i < MAX_DEBRIS; i++)
|
|
|
|
{
|
2020-06-05 09:20:26 +02:00
|
|
|
debris_alloc[i] = i;
|
|
|
|
|
|
|
|
debris[i].pos = 0;
|
2020-11-07 12:45:04 +01:00
|
|
|
debris[i].flags = 0;
|
2020-06-05 09:20:26 +02:00
|
|
|
debris[i].num = i;
|
2020-10-17 09:26:57 +02:00
|
|
|
}
|
2020-06-05 09:20:26 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
for (i = 0; i < MAX_GROUND_DEBRIS; i++)
|
|
|
|
{
|
2020-06-05 09:20:26 +02:00
|
|
|
ground_debris[i].type = 0xffff;
|
2020-11-07 10:54:15 +01:00
|
|
|
}
|
2020-06-05 09:20:26 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
groundDebrisIndex = 0;
|
2020-06-05 09:20:26 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
debris_rotvec.vz = 0;
|
|
|
|
debris_rotvec.vy = 0;
|
|
|
|
debris_rotvec.vx = 0;
|
2020-06-05 09:20:26 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
leaf_rotvec.vz = 0;
|
|
|
|
leaf_rotvec.vy = 0;
|
|
|
|
leaf_rotvec.vx = 0;
|
2020-06-05 09:20:26 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
{
|
2020-04-04 06:49:28 +02:00
|
|
|
RotMatrixXYZ(&debris_mat, &debris_rotvec);
|
|
|
|
RotMatrixXYZ(&leaf_mat, &leaf_rotvec);
|
2020-06-05 09:20:26 +02:00
|
|
|
|
|
|
|
debris_rotvec.vx += 128;
|
|
|
|
debris_rotvec.vy += 256;
|
|
|
|
debris_rotvec.vz += 128;
|
|
|
|
leaf_rotvec.vy += 128;
|
|
|
|
|
|
|
|
for (j = 0; j < 5; j++)
|
|
|
|
{
|
|
|
|
if (j == 1)
|
2020-04-04 06:49:28 +02:00
|
|
|
SetRotMatrix(&leaf_mat);
|
2020-06-05 09:20:26 +02:00
|
|
|
else
|
2020-04-04 06:49:28 +02:00
|
|
|
SetRotMatrix(&debris_mat);
|
2020-06-05 09:20:26 +02:00
|
|
|
|
|
|
|
temptri = *debris_data[j];
|
|
|
|
|
|
|
|
_MatrixRotate((VECTOR *)&temptri.v0);
|
|
|
|
_MatrixRotate((VECTOR *)&temptri.v1);
|
|
|
|
_MatrixRotate((VECTOR *)&temptri.v2);
|
|
|
|
|
|
|
|
debris_rot_table[j][i].v0.vx = temptri.v0.vx;
|
|
|
|
debris_rot_table[j][i].v0.vy = temptri.v0.vy;
|
|
|
|
debris_rot_table[j][i].v0.vz = temptri.v0.vz;
|
|
|
|
|
|
|
|
debris_rot_table[j][i].v1.vx = temptri.v1.vx;
|
|
|
|
debris_rot_table[j][i].v1.vy = temptri.v1.vy;
|
|
|
|
debris_rot_table[j][i].v1.vz = temptri.v1.vz;
|
|
|
|
|
|
|
|
debris_rot_table[j][i].v2.vx = temptri.v2.vx;
|
|
|
|
debris_rot_table[j][i].v2.vy = temptri.v2.vy;
|
|
|
|
debris_rot_table[j][i].v2.vz = temptri.v2.vz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
for (i = 0; i < MAX_SMOKE; i++)
|
2020-06-05 09:20:26 +02:00
|
|
|
{
|
|
|
|
smoke_alloc[i] = i;
|
|
|
|
|
|
|
|
smoke[i].pos = 0;
|
|
|
|
smoke[i].flags = 0;
|
|
|
|
smoke[i].num = i;
|
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
for (i = 0; i < MAX_LEAVES; i++)
|
2020-06-05 09:20:26 +02:00
|
|
|
{
|
|
|
|
leaf_alloc[i] = i;
|
|
|
|
|
|
|
|
leaf[i].pos = 0;
|
2020-11-07 12:45:04 +01:00
|
|
|
leaf[i].flags = 0;
|
2020-06-05 09:20:26 +02:00
|
|
|
leaf[i].num = i;
|
|
|
|
}
|
|
|
|
|
2020-11-07 12:09:06 +01:00
|
|
|
ClearMem((char*)&damaged_lamp, sizeof(damaged_lamp));
|
2020-06-05 09:20:26 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
for (i = 0; i < MAX_SMASHED_OBJECTS; i++)
|
2020-06-05 09:20:26 +02:00
|
|
|
damaged_object[i].active = 0;
|
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
LightSortCorrect = -10;
|
|
|
|
SmashablesHit = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int AllocateDebris(void)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
if (next_debris < MAX_DEBRIS)
|
|
|
|
return debris_alloc[next_debris++];
|
2020-05-27 14:24:08 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
return -1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void ReleaseDebris(short num)
|
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
debris_alloc[--next_debris] = num;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int AllocateSmoke(void)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
if (next_smoke < MAX_SMOKE)
|
|
|
|
return smoke_alloc[next_smoke++];
|
2020-05-27 14:24:08 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
return -1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void ReleaseSmoke(short num)
|
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
smoke_alloc[--next_smoke] = num;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void AddGroundDebris(void)
|
|
|
|
{
|
2020-08-10 17:42:11 +02:00
|
|
|
int seed;
|
|
|
|
int number;
|
|
|
|
int zbound;
|
|
|
|
int xbound;
|
|
|
|
int type;
|
2020-08-08 16:15:29 +02:00
|
|
|
CELL_OBJECT *cop;
|
|
|
|
MODEL *model;
|
2020-08-10 17:42:11 +02:00
|
|
|
int count;
|
2020-08-08 16:15:29 +02:00
|
|
|
VECTOR Position;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
if (car_data[0].hd.wheel_speed + 99999U <= 0x30d3e)
|
|
|
|
return;
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
count = 0;
|
|
|
|
cop = ground_debris;
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
do {
|
|
|
|
if (cop->type != 0xffff)
|
|
|
|
{
|
|
|
|
model = modelpointers[cop->type];
|
2020-08-10 17:42:11 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
xbound = ABS(cop->pos.vx - camera_position.vx);
|
|
|
|
zbound = ABS(cop->pos.vz - camera_position.vz);
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2020-11-07 12:45:04 +01:00
|
|
|
if (xbound <= 9000 && zbound <= 9000 && (xbound > 7000 || zbound > 7000))
|
2020-11-07 10:54:15 +01:00
|
|
|
{
|
2020-11-07 12:45:04 +01:00
|
|
|
if (next_leaf >= MAX_LEAVES)
|
2020-11-07 10:54:15 +01:00
|
|
|
return;
|
2020-08-10 17:42:11 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
seed = rand();
|
2020-08-10 17:42:11 +02:00
|
|
|
|
2021-07-06 12:13:03 +02:00
|
|
|
Position.vy = cop->pos.vy - 45;
|
2020-11-07 10:54:15 +01:00
|
|
|
Position.vx = cop->pos.vx + ((seed & 0x3ff) - 512);
|
|
|
|
Position.vz = cop->pos.vz + ((rand() & 0x3ff) - 512);
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
number = seed & 7;
|
2020-08-08 16:15:29 +02:00
|
|
|
|
2020-12-11 11:20:48 +01:00
|
|
|
if (model->flags2 & MODEL_FLAG_TREE)
|
2020-11-07 10:54:15 +01:00
|
|
|
{
|
2020-12-11 11:20:48 +01:00
|
|
|
type = 1; // ground leaves
|
2020-11-07 10:54:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-12-11 11:20:48 +01:00
|
|
|
number = seed & 3;
|
|
|
|
type = 2; // paper
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
AddLeaf(&Position, number + 1, type);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
}
|
2020-08-10 17:42:11 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
count++;
|
|
|
|
cop++;
|
|
|
|
} while (count < MAX_GROUND_DEBRIS);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T] [A]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DrawSmashable_sprites(void)
|
|
|
|
{
|
2020-05-06 06:02:48 +02:00
|
|
|
DAMAGED_OBJECT *dam;
|
2020-04-04 06:49:28 +02:00
|
|
|
MODEL *model;
|
2020-05-06 06:20:21 +02:00
|
|
|
int count;
|
2020-05-06 06:02:48 +02:00
|
|
|
VECTOR pos;
|
|
|
|
MATRIX object_matrix;
|
|
|
|
|
|
|
|
dam = damaged_object;
|
2020-10-17 09:26:57 +02:00
|
|
|
count = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
do {
|
2020-11-07 10:54:15 +01:00
|
|
|
if (dam->active)
|
2020-05-06 06:02:48 +02:00
|
|
|
{
|
|
|
|
model = modelpointers[dam->cop.type];
|
|
|
|
|
2021-05-15 21:58:23 +02:00
|
|
|
InitMatrix(object_matrix);
|
2020-05-06 06:02:48 +02:00
|
|
|
|
2021-05-09 20:56:18 +02:00
|
|
|
if ((model->shape_flags & SHAPE_FLAG_SPRITE) == 0)
|
2020-05-06 06:02:48 +02:00
|
|
|
RotMatrixY(dam->rot_speed * dam->damage * 3 & 0xfff, &object_matrix);
|
|
|
|
|
|
|
|
RotMatrixZ(dam->rot_speed * dam->damage & 0xfff, &object_matrix);
|
|
|
|
|
|
|
|
pos.vx = dam->vx - camera_position.vx;
|
2020-05-06 06:20:21 +02:00
|
|
|
pos.vy = dam->cop.pos.vy - camera_position.vy;
|
|
|
|
pos.vz = dam->cop.pos.vz - camera_position.vz;
|
2020-05-06 06:02:48 +02:00
|
|
|
|
|
|
|
Apply_Inv_CameraMatrix(&pos);
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&object_matrix);
|
|
|
|
gte_SetTransVector(&pos);
|
|
|
|
|
|
|
|
pos.vx = dam->vx;
|
2020-05-06 06:20:21 +02:00
|
|
|
pos.vy = dam->cop.pos.vy;
|
|
|
|
pos.vz = dam->cop.pos.vz;
|
2020-05-06 06:02:48 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
SetFrustrumMatrix();
|
2020-05-06 06:02:48 +02:00
|
|
|
|
2020-05-06 06:20:21 +02:00
|
|
|
if (FrustrumCheck(&pos, model->bounding_sphere) != -1)
|
2020-05-06 06:02:48 +02:00
|
|
|
{
|
2021-05-09 20:56:18 +02:00
|
|
|
if (model->shape_flags & SHAPE_FLAG_SPRITE)
|
2020-05-06 06:02:48 +02:00
|
|
|
{
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (gWeather - 1U < 2 || gTimeOfDay == 3)
|
2020-05-06 06:02:48 +02:00
|
|
|
{
|
|
|
|
plotContext.colour = NightAmbient << 0x10 | NightAmbient << 8 | NightAmbient | 0x2c000000;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-05-06 06:02:48 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
plotContext.colour = 0x2c808080;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-05-06 06:02:48 +02:00
|
|
|
|
|
|
|
// [A]
|
2020-11-06 20:47:33 +01:00
|
|
|
// TODO:
|
2020-05-06 06:02:48 +02:00
|
|
|
//current->primptr = Asm_PlotSprite(model, current->primptr, current->ot, 0);
|
2020-11-06 20:47:33 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlotMDL_less_than_128(model);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-06 20:47:33 +01:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
count++;
|
2020-05-06 06:02:48 +02:00
|
|
|
dam++;
|
2020-10-17 09:26:57 +02:00
|
|
|
} while (count < MAX_SMASHED_OBJECTS);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int MoveSmashable_object(void)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
DAMAGED_OBJECT *dam;
|
|
|
|
int count;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
dam = damaged_object;
|
|
|
|
count = 0;
|
2020-05-06 06:02:48 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
do {
|
2020-11-07 10:54:15 +01:00
|
|
|
if (dam->active)
|
2020-05-06 06:02:48 +02:00
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
if (dam->cop.pos.vy < 50 - player[0].pos[1])
|
2020-05-06 06:02:48 +02:00
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
dam->vx += dam->velocity.vx;
|
|
|
|
|
|
|
|
dam->cop.pos.vy += dam->velocity.vy;
|
|
|
|
dam->cop.pos.vz += dam->velocity.vz;
|
2020-11-07 10:54:15 +01:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
dam->velocity.vy += 10;
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
dam->damage++;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-05-06 06:02:48 +02:00
|
|
|
else
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
dam->active = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-05-06 06:02:48 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-10-17 09:26:57 +02:00
|
|
|
count++;
|
|
|
|
dam++;
|
|
|
|
} while (count < MAX_SMASHED_OBJECTS);
|
|
|
|
|
2020-05-06 06:02:48 +02:00
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
// [D] [T]
|
|
|
|
void DisplayLightReflections(VECTOR* v1, CVECTOR* col, short size, TEXTURE_DETAILS* texture)
|
|
|
|
{
|
|
|
|
POLY_FT4* poly;
|
|
|
|
SVECTOR vert[4];
|
|
|
|
CVECTOR thiscol;
|
|
|
|
int z;
|
|
|
|
|
|
|
|
if (wetness > 9 && v1->vy > camera_position.vy)
|
|
|
|
{
|
2021-03-27 22:19:59 +01:00
|
|
|
thiscol.r = col->r * wetness >> 16;
|
|
|
|
thiscol.g = col->g * wetness >> 16;
|
|
|
|
thiscol.b = col->b * wetness >> 16;
|
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
gte_SetTransVector(v1);
|
|
|
|
|
|
|
|
Apply_Inv_CameraMatrix(v1);
|
|
|
|
|
|
|
|
gte_SetTransVector(v1);
|
|
|
|
gte_SetRotMatrix(&face_camera);
|
|
|
|
|
|
|
|
vert[0].vx = -size;
|
|
|
|
vert[2].vx = -size;
|
|
|
|
vert[1].vx = size;
|
|
|
|
vert[3].vx = size;
|
|
|
|
|
|
|
|
vert[0].vy = 0;
|
|
|
|
vert[0].vz = 0;
|
|
|
|
vert[1].vy = 0;
|
|
|
|
vert[1].vz = 0;
|
|
|
|
vert[2].vy = 0;
|
|
|
|
vert[2].vz = 0;
|
|
|
|
vert[3].vy = 0;
|
|
|
|
vert[3].vz = 0;
|
|
|
|
|
|
|
|
gte_ldv0(&vert[0]);
|
|
|
|
|
|
|
|
gte_rtps();
|
|
|
|
|
|
|
|
gte_stsz(&z);
|
|
|
|
|
|
|
|
if (z >= 150)
|
|
|
|
{
|
|
|
|
poly = (POLY_FT4*)current->primptr;
|
|
|
|
setPolyFT4(poly);
|
|
|
|
setSemiTrans(poly, 1);
|
|
|
|
|
|
|
|
gte_stsxy(&poly->x0);
|
|
|
|
|
|
|
|
vert[2].vy = (z >> 3) + 0xfa;
|
|
|
|
vert[3].vy = (z >> 3) + 0xfa;
|
|
|
|
|
|
|
|
gte_ldv3(&vert[1], &vert[2], &vert[3]);
|
|
|
|
|
|
|
|
gte_rtpt();
|
|
|
|
|
|
|
|
gte_stsxy3(&poly->x1, &poly->x2, &poly->x3);
|
|
|
|
|
|
|
|
poly->u0 = texture->coords.u0;
|
|
|
|
poly->v0 = texture->coords.v0;
|
|
|
|
poly->u1 = texture->coords.u1;
|
|
|
|
poly->v1 = texture->coords.v1;
|
|
|
|
poly->u2 = texture->coords.u2;
|
|
|
|
poly->v2 = texture->coords.v2;
|
|
|
|
poly->u3 = texture->coords.u3;
|
|
|
|
poly->v3 = texture->coords.v3;
|
|
|
|
|
|
|
|
poly->tpage = texture->tpageid | 0x20;
|
|
|
|
poly->clut = texture->clutid;
|
|
|
|
|
|
|
|
poly->r0 = thiscol.r;
|
|
|
|
poly->g0 = thiscol.g;
|
|
|
|
poly->b0 = thiscol.b;
|
|
|
|
|
|
|
|
addPrim(current->ot + (z >> 4), poly);
|
|
|
|
current->primptr += sizeof(POLY_FT4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [D] [T]
|
|
|
|
int find_lamp_streak(int LampId)
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
|
|
|
for (count = 0; count < MAX_LAMP_STREAKS; count++)
|
|
|
|
{
|
|
|
|
if (Known_Lamps[count].id == LampId)
|
|
|
|
{
|
|
|
|
Known_Lamps[count].set = 1;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// allocate new streak
|
|
|
|
if (StreakCount1 < MAX_LAMP_STREAKS)
|
|
|
|
{
|
|
|
|
NewLamp[StreakCount1++] = LampId;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void AddSmallStreetLight(CELL_OBJECT *cop, int x, int y, int z, int type)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-08-20 14:14:06 +02:00
|
|
|
int count;
|
|
|
|
DAMAGED_LAMP* dam;
|
|
|
|
int halo_size;
|
2020-04-04 06:49:28 +02:00
|
|
|
short size;
|
2020-08-20 14:14:06 +02:00
|
|
|
short angle;
|
|
|
|
VECTOR v1;
|
|
|
|
VECTOR v2;
|
|
|
|
VECTOR v3;
|
|
|
|
SVECTOR pos;
|
|
|
|
CVECTOR col;
|
|
|
|
CVECTOR col1;
|
2020-11-06 20:47:33 +01:00
|
|
|
SVECTOR dpos;
|
2020-08-20 14:14:06 +02:00
|
|
|
|
|
|
|
dam = damaged_lamp;
|
2020-10-17 09:26:57 +02:00
|
|
|
col = {140, 140, 140};
|
|
|
|
col1 = {45, 45, 45};
|
2020-08-20 14:14:06 +02:00
|
|
|
|
|
|
|
angle = cop->yang;
|
|
|
|
|
|
|
|
if (type == 0)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
halo_size = 25;
|
|
|
|
size = 150;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 14:14:06 +02:00
|
|
|
else if (type == 1)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
halo_size = 50;
|
|
|
|
size = 150;
|
2020-08-20 14:14:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
halo_size = 100;
|
|
|
|
size = 300;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 14:14:06 +02:00
|
|
|
|
|
|
|
count = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
do {
|
2020-11-07 12:09:06 +01:00
|
|
|
if (dam->index == cop->pos.vx + cop->pos.vz)
|
2020-08-20 14:14:06 +02:00
|
|
|
{
|
|
|
|
if (dam->damage > 2)
|
2020-04-04 06:49:28 +02:00
|
|
|
return;
|
2020-08-20 14:14:06 +02:00
|
|
|
|
2020-11-07 12:09:06 +01:00
|
|
|
// do flicker
|
2020-08-20 14:14:06 +02:00
|
|
|
col.r = col.g = col.b = (rand() & 0x3f) - (dam->damage * 32 - 90);
|
2020-10-17 09:26:57 +02:00
|
|
|
col1.r = col1.g = col1.b = col.r / 2;
|
2020-08-20 14:14:06 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-08-20 14:14:06 +02:00
|
|
|
|
|
|
|
count++;
|
|
|
|
dam++;
|
|
|
|
} while (count < 4);
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
dpos.vx = cop->pos.vx - camera_position.vx;
|
|
|
|
dpos.vy = cop->pos.vy - camera_position.vy;
|
|
|
|
dpos.vz = cop->pos.vz - camera_position.vz;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (angle & 0xf)
|
|
|
|
{
|
|
|
|
pos.vx = x;
|
|
|
|
pos.vy = y;
|
|
|
|
pos.vz = z;
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&matrixtable[angle]);
|
|
|
|
gte_ldv0(&pos);
|
|
|
|
|
|
|
|
gte_rtv0();
|
|
|
|
|
|
|
|
gte_stsv(&pos);
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx + pos.vx;
|
|
|
|
v1.vy = dpos.vy + pos.vy;
|
|
|
|
v1.vz = dpos.vz + pos.vz;
|
2020-10-17 09:26:57 +02:00
|
|
|
}
|
|
|
|
else
|
2020-08-20 14:14:06 +02:00
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
angle >>= 4;
|
2020-08-20 14:14:06 +02:00
|
|
|
|
|
|
|
if (angle == 0)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx + x;
|
|
|
|
v1.vz = dpos.vz + z;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 14:14:06 +02:00
|
|
|
else if (angle == 1)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx + z;
|
|
|
|
v1.vz = dpos.vz - x;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 14:14:06 +02:00
|
|
|
else if (angle == 2)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx - x;
|
|
|
|
v1.vz = dpos.vz - z;
|
2020-08-20 14:14:06 +02:00
|
|
|
}
|
|
|
|
else if (angle == 3)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx - z;
|
|
|
|
v1.vz = dpos.vz + x;
|
2020-08-20 14:14:06 +02:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vy = dpos.vy + y;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 14:14:06 +02:00
|
|
|
|
|
|
|
v2.vx = v1.vx;
|
|
|
|
v2.vz = v1.vz;
|
2020-11-06 20:47:33 +01:00
|
|
|
v2.vy = -camera_position.vy - MapHeight((VECTOR*)&cop->pos);
|
2020-08-20 14:14:06 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
LightSortCorrect = -30;
|
2020-08-20 14:14:06 +02:00
|
|
|
col.cd = 0;
|
|
|
|
|
|
|
|
v3 = v1;
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
LightIndex = find_lamp_streak(cop->pos.vx + cop->pos.vz + x); // [A] was pointer.
|
2020-08-20 14:14:06 +02:00
|
|
|
|
|
|
|
if (LightIndex > -1)
|
2020-11-06 20:47:33 +01:00
|
|
|
col.cd = 0x60;
|
|
|
|
|
2020-08-20 14:14:06 +02:00
|
|
|
ShowLight(&v3, &col, halo_size, &light_texture);
|
|
|
|
ShowLight1(&v3, &col1, size, &light_texture);
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
DisplayLightReflections(&v2, &col1, halo_size * 2, &lightref_texture);
|
2020-08-20 14:14:06 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
LightSortCorrect = -10;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void AddLightEffect(CELL_OBJECT *cop, int x, int y, int z, int type, int colour)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-08-20 15:09:28 +02:00
|
|
|
short yang;
|
|
|
|
int angle;
|
|
|
|
int size;
|
|
|
|
VECTOR v1;
|
|
|
|
VECTOR v2;
|
2020-11-06 20:47:33 +01:00
|
|
|
VECTOR dpos;
|
2020-08-20 15:09:28 +02:00
|
|
|
SVECTOR pos;
|
|
|
|
CVECTOR col;
|
|
|
|
|
|
|
|
yang = cop->yang;
|
|
|
|
angle = yang;
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
dpos.vx = cop->pos.vx - camera_position.vx;
|
|
|
|
dpos.vy = cop->pos.vy - camera_position.vy;
|
|
|
|
dpos.vz = cop->pos.vz - camera_position.vz;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (yang & 0xf)
|
2020-08-20 15:09:28 +02:00
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
pos.vx = x;
|
|
|
|
pos.vy = y;
|
|
|
|
pos.vz = z;
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&matrixtable[angle]);
|
|
|
|
gte_ldv0(&pos);
|
|
|
|
|
|
|
|
gte_rtv0();
|
|
|
|
|
|
|
|
gte_stsv(&pos);
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx + pos.vx;
|
|
|
|
v1.vy = dpos.vy + pos.vy;
|
|
|
|
v1.vz = dpos.vz + pos.vz;
|
2020-10-17 09:26:57 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yang >>= 4;
|
2020-08-20 15:09:28 +02:00
|
|
|
|
|
|
|
if (yang == 0)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx + x;
|
|
|
|
v1.vz = dpos.vz + z;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 15:09:28 +02:00
|
|
|
else if (yang == 1)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx + z;
|
|
|
|
v1.vz = dpos.vz - x;
|
2020-08-20 15:09:28 +02:00
|
|
|
}
|
|
|
|
else if (yang == 2)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx - x;
|
|
|
|
v1.vz = dpos.vz - z;
|
2020-08-20 15:09:28 +02:00
|
|
|
}
|
|
|
|
else if (yang == 3)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vx = dpos.vx - z;
|
|
|
|
v1.vz = dpos.vz + x;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 15:09:28 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
v1.vy = dpos.vy + y;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 15:09:28 +02:00
|
|
|
|
|
|
|
if (colour == 0)
|
|
|
|
{
|
|
|
|
col.r = 40;
|
|
|
|
col.g = 10;
|
|
|
|
col.b = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 15:09:28 +02:00
|
|
|
else if (colour == 1)
|
|
|
|
{
|
|
|
|
col.r = 0;
|
|
|
|
col.g = 40;
|
|
|
|
col.b = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 15:09:28 +02:00
|
|
|
else if (colour == 2)
|
|
|
|
{
|
|
|
|
col.g = 70;
|
|
|
|
col.r = 85;
|
|
|
|
col.b = 5;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 15:09:28 +02:00
|
|
|
else if (colour == 3)
|
|
|
|
{
|
|
|
|
col.g = 40;
|
|
|
|
col.b = 35;
|
|
|
|
col.r = 40;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == 0)
|
|
|
|
{
|
|
|
|
size = 400;
|
|
|
|
}
|
|
|
|
else if (type == 1)
|
|
|
|
{
|
|
|
|
size = 300;
|
|
|
|
}
|
|
|
|
else if (type == 2)
|
|
|
|
{
|
|
|
|
size = 200;
|
|
|
|
}
|
|
|
|
else if (type == 3)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
size = 150;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 15:09:28 +02:00
|
|
|
|
|
|
|
v2.vx = v1.vx;
|
|
|
|
v2.vz = v1.vz;
|
2020-11-06 20:47:33 +01:00
|
|
|
v2.vy = -camera_position.vy - MapHeight((VECTOR*)&cop->pos);
|
2020-08-20 15:09:28 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
LightSortCorrect = -10;
|
2020-08-20 15:09:28 +02:00
|
|
|
col.cd = 0;
|
|
|
|
|
|
|
|
Apply_Inv_CameraMatrix(&v1);
|
|
|
|
|
2020-10-05 22:02:41 +02:00
|
|
|
gte_SetRotMatrix(&identity);
|
2020-08-20 15:09:28 +02:00
|
|
|
gte_SetTransVector(&v1);
|
|
|
|
|
|
|
|
ShowLight1(&v1, &col, size, &light_texture);
|
|
|
|
DisplayLightReflections(&v2, &col, (size << 0xd) >> 0x10, &lightref_texture);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void PreLampStreak(void)
|
|
|
|
{
|
2020-06-05 09:29:35 +02:00
|
|
|
int count;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
for (count = 0; count < MAX_LAMP_STREAKS && StreakCount1 > 0; count++)
|
2020-06-05 09:29:35 +02:00
|
|
|
{
|
|
|
|
if (Known_Lamps[count].set == 0)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
Known_Lamps[count].id = NewLamp[--StreakCount1];
|
2020-06-05 09:29:35 +02:00
|
|
|
Known_Lamps[count].clock = FrameCnt - 2;
|
|
|
|
}
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-06-05 09:29:35 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
for (count = 0; count < MAX_LAMP_STREAKS; count++)
|
2020-06-05 09:29:35 +02:00
|
|
|
{
|
|
|
|
Known_Lamps[count].set = 0;
|
|
|
|
NewLamp[count] = 0;
|
|
|
|
}
|
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
StreakCount1 = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int damage_lamp(CELL_OBJECT *cop)
|
|
|
|
{
|
2020-08-20 15:09:16 +02:00
|
|
|
int old_damage;
|
|
|
|
int count;
|
|
|
|
DAMAGED_LAMP *dam;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
dam = damaged_lamp;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
|
|
|
do {
|
2020-11-07 12:09:06 +01:00
|
|
|
|
|
|
|
// [A] slow but works
|
|
|
|
if (dam->index == cop->pos.vx + cop->pos.vz)
|
2020-08-20 15:09:16 +02:00
|
|
|
{
|
|
|
|
old_damage = dam->damage;
|
|
|
|
dam->damage++;
|
|
|
|
|
|
|
|
if (old_damage < 3)
|
|
|
|
return ((old_damage + 1) < 3) ^ 1;
|
|
|
|
|
|
|
|
return 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 20:47:33 +01:00
|
|
|
|
2020-08-20 15:09:16 +02:00
|
|
|
dam++;
|
2020-11-06 20:47:33 +01:00
|
|
|
count++;
|
2020-10-17 09:26:57 +02:00
|
|
|
} while (count < MAX_DAMAGED_LAMPS);
|
2020-08-20 15:09:16 +02:00
|
|
|
|
|
|
|
// store new cell object
|
2020-11-07 12:09:06 +01:00
|
|
|
dam = &damaged_lamp[NextDamagedLamp];
|
|
|
|
dam->damage = 0;
|
|
|
|
dam->index = cop->pos.vx + cop->pos.vz; // copy
|
2020-08-20 15:09:16 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (++NextDamagedLamp > MAX_DAMAGED_LAMPS)
|
2020-04-04 06:49:28 +02:00
|
|
|
NextDamagedLamp = 0;
|
2020-08-20 15:09:16 +02:00
|
|
|
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
int damage_object(CELL_OBJECT *cop, VECTOR *velocity)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-06 06:02:48 +02:00
|
|
|
DAMAGED_OBJECT *dam;
|
|
|
|
PACKED_CELL_OBJECT *pcop;
|
|
|
|
|
|
|
|
dam = &damaged_object[NextDamagedPmeter];
|
|
|
|
SmashablesHit++;
|
2020-10-17 11:27:44 +02:00
|
|
|
|
|
|
|
if (NextDamagedPmeter < MAX_SMASHED_OBJECTS-1)
|
|
|
|
NextDamagedPmeter++;
|
|
|
|
else
|
|
|
|
NextDamagedPmeter = 0;
|
2020-05-06 06:02:48 +02:00
|
|
|
|
|
|
|
dam->active = 1;
|
|
|
|
dam->damage = 0;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
|
|
|
dam->cop = *cop; // copy
|
2020-05-06 06:02:48 +02:00
|
|
|
|
|
|
|
dam->vx = cop->pos.vx;
|
|
|
|
|
2020-11-06 15:56:50 +01:00
|
|
|
dam->velocity.vx = velocity->vx >> 10;
|
|
|
|
dam->velocity.vz = velocity->vz >> 10;
|
2020-05-06 06:02:48 +02:00
|
|
|
|
|
|
|
pcop = pcoplist[cop->pad];
|
|
|
|
pcop->value = 0xffff;
|
|
|
|
pcop->pos.vy = 1;
|
|
|
|
|
|
|
|
if (dam->velocity.vx < 0)
|
|
|
|
dam->velocity.vy = velocity->vx;
|
|
|
|
else
|
|
|
|
dam->velocity.vy = -velocity->vx;
|
|
|
|
|
|
|
|
if (dam->velocity.vz < 0)
|
|
|
|
dam->velocity.vy += velocity->vz;
|
|
|
|
else
|
|
|
|
dam->velocity.vy -= velocity->vz;
|
|
|
|
|
|
|
|
dam->velocity.vy /= 2;
|
|
|
|
|
|
|
|
if ((rand() & 1) == 0)
|
|
|
|
dam->rot_speed = -dam->velocity.vy;
|
|
|
|
else
|
|
|
|
dam->rot_speed = dam->velocity.vy;
|
|
|
|
|
|
|
|
if (dam->velocity.vy < -67)
|
|
|
|
dam->velocity.vy = -67;
|
|
|
|
|
2021-06-23 08:36:30 +02:00
|
|
|
cop->pos.vx = OBJECT_SMASHED_MARK;
|
2020-05-06 06:02:48 +02:00
|
|
|
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2020-12-08 20:20:53 +01:00
|
|
|
void ShowFlare(VECTOR* v1, CVECTOR* col, short size, int rotation)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-12-08 20:20:53 +01:00
|
|
|
POLY_FT4* poly;
|
|
|
|
SVECTOR vert[4];
|
|
|
|
SVECTOR direction;
|
|
|
|
MATRIX temp_matrix;
|
|
|
|
int z;
|
|
|
|
|
|
|
|
gte_SetTransVector(v1);
|
|
|
|
|
|
|
|
direction.vy = 0;
|
|
|
|
direction.vx = 0;
|
|
|
|
direction.vz = rotation;
|
|
|
|
|
|
|
|
RotMatrixXYZ(&temp_matrix, &direction);
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&temp_matrix);
|
|
|
|
|
|
|
|
vert[0].vx = -size;
|
|
|
|
vert[0].vy = -size;
|
|
|
|
vert[0].vz = 0;
|
|
|
|
|
|
|
|
vert[1].vx = -size;
|
|
|
|
vert[1].vy = size;
|
|
|
|
vert[1].vz = 0;
|
|
|
|
|
|
|
|
vert[2].vx = size;
|
|
|
|
vert[2].vy = -size;
|
|
|
|
vert[2].vz = 0;
|
|
|
|
|
|
|
|
vert[3].vx = size;
|
|
|
|
vert[3].vy = size;
|
|
|
|
vert[3].vz = 0;
|
|
|
|
|
|
|
|
gte_ldv3(&vert[0], &vert[1], &vert[2]);
|
|
|
|
|
|
|
|
gte_rtpt();
|
|
|
|
|
|
|
|
poly = (POLY_FT4*)current->primptr;
|
|
|
|
|
|
|
|
poly->u0 = flare_texture.coords.u0;
|
|
|
|
poly->v0 = flare_texture.coords.v0;
|
|
|
|
poly->u1 = flare_texture.coords.u1;
|
|
|
|
poly->v1 = flare_texture.coords.v1;
|
|
|
|
poly->u2 = flare_texture.coords.u2;
|
|
|
|
poly->v2 = flare_texture.coords.v2 - 1;
|
|
|
|
poly->u3 = flare_texture.coords.u3;
|
|
|
|
poly->v3 = flare_texture.coords.v3 - 1;
|
|
|
|
|
|
|
|
setPolyFT4(poly);
|
|
|
|
setSemiTrans(poly, 1);
|
|
|
|
|
|
|
|
poly->r0 = col->r >> 1;
|
|
|
|
poly->g0 = col->g >> 1;
|
|
|
|
poly->b0 = col->b >> 1;
|
|
|
|
|
|
|
|
gte_stsz(&z);
|
|
|
|
|
|
|
|
if (z >> 3 > 39)
|
|
|
|
{
|
|
|
|
z = (z >> 3) + LightSortCorrect;
|
|
|
|
|
|
|
|
if (z < 1)
|
|
|
|
z = 1;
|
|
|
|
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
gte_ldv0(&vert[3]);
|
|
|
|
|
|
|
|
gte_rtps();
|
|
|
|
gte_stsxy(&poly->x3);
|
|
|
|
|
|
|
|
poly->tpage = flare_texture.tpageid | 0x20;
|
|
|
|
poly->clut = flare_texture.clutid;
|
|
|
|
|
|
|
|
addPrim(current->ot + z, poly);
|
|
|
|
|
|
|
|
current->primptr += sizeof(POLY_FT4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [D] [T]
|
|
|
|
void AddTrafficLight(CELL_OBJECT *cop, int x, int y, int z, int flag, int yang)
|
|
|
|
{
|
|
|
|
int tempfade;
|
2021-06-20 17:13:54 +02:00
|
|
|
int lDiffAnglesX, lDiffAnglesY;
|
|
|
|
int AbsX, AbsY;
|
|
|
|
CVECTOR a, c;
|
|
|
|
VECTOR v1, v2;
|
2020-08-20 14:25:54 +02:00
|
|
|
|
|
|
|
v1.vy = (cop->pos.vy - camera_position.vy) + y;
|
2021-06-20 17:13:54 +02:00
|
|
|
v1.vx = (cop->pos.vx - camera_position.vx) + FIXEDH(RCOS(yang) * x + RSIN(yang) * z);
|
|
|
|
v1.vz = (cop->pos.vz - camera_position.vz) + FIXEDH(RCOS(yang) * z - RSIN(yang) * x);
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
a.cd = 0;
|
|
|
|
|
|
|
|
if (flag & 0x200)
|
2020-08-20 14:25:54 +02:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
a.r = 255;
|
|
|
|
a.g = 25;
|
|
|
|
a.b = 25;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 20:47:33 +01:00
|
|
|
else if (flag & 0x400)
|
2020-08-20 14:25:54 +02:00
|
|
|
{
|
|
|
|
a.r = 255;
|
2020-11-06 20:47:33 +01:00
|
|
|
a.g = 100;
|
|
|
|
a.b = 35;
|
|
|
|
}
|
|
|
|
else if (flag & 0x800)
|
|
|
|
{
|
|
|
|
a.r = 25;
|
|
|
|
a.g = 255;
|
|
|
|
a.b = 25;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2022-01-21 19:01:00 +01:00
|
|
|
lDiffAnglesX = DIFF_ANGLES(0, camera_angle.vx);// (camera_angle.vx + 2048) & 0xfff) - 2048;
|
2020-11-06 20:47:33 +01:00
|
|
|
AbsX = ABS(lDiffAnglesX);
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2021-05-30 21:09:18 +02:00
|
|
|
lDiffAnglesY = DIFF_ANGLES(yang, -camera_angle.vy & 4095); //((-camera_angle.vy & 0xfffU) - yang + 2048 & 0xfff) - 2048;
|
2020-11-06 20:47:33 +01:00
|
|
|
AbsY = ABS(lDiffAnglesY);
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
c.r = a.r >> 3;
|
|
|
|
c.b = a.b >> 3;
|
|
|
|
c.g = a.g >> 3;
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
v2.vx = v1.vx;
|
|
|
|
v2.vz = v1.vz;
|
|
|
|
v2.vy = -camera_position.vy - MapHeight((VECTOR*)&cop->pos);
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
if (gNight)
|
|
|
|
ShowGroundLight(&v2, &c, 300);
|
|
|
|
|
|
|
|
if (AbsY < 1000)
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
if (AbsX + AbsY < 1000)
|
2020-08-20 14:25:54 +02:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
tempfade = 1000 - (AbsX + AbsY);
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (tempfade < 0)
|
|
|
|
tempfade = 0;
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
a.r = (a.r * tempfade) >> 10;
|
|
|
|
a.b = (a.b * tempfade) >> 10;
|
|
|
|
a.g = (a.g * tempfade) >> 10;
|
2020-08-20 14:25:54 +02:00
|
|
|
|
|
|
|
LightSortCorrect = -140;
|
2020-11-07 10:54:15 +01:00
|
|
|
LightIndex = find_lamp_streak(cop->pos.vx + cop->pos.vz + x + y); // [A] was pointer.
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (LightIndex < 0)
|
2020-08-20 14:25:54 +02:00
|
|
|
a.cd = 0;
|
2020-11-06 20:47:33 +01:00
|
|
|
else
|
|
|
|
a.cd = 0x20;
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
ShowLight(&v1, &a, 30, &light_texture);
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
a.r >>= 1;
|
|
|
|
a.b >>= 1;
|
|
|
|
a.g >>= 1;
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
if (gNight)
|
2020-11-06 20:47:33 +01:00
|
|
|
ShowFlare(&v1, &a, 150, lDiffAnglesX + lDiffAnglesY + v1.vx + v1.vz >> 3 & 0x1ffe);
|
2020-11-07 18:02:32 +01:00
|
|
|
|
|
|
|
DisplayLightReflections(&v2, &a, 50, &lightref_texture);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-08-20 14:25:54 +02:00
|
|
|
|
2020-11-07 18:02:32 +01:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
LightSortCorrect = -10;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
void InitFXPos(VECTOR *vec, SVECTOR *svec, CAR_DATA *cp)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-04-29 18:01:27 +02:00
|
|
|
SVECTOR svectmp;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-04-29 18:01:27 +02:00
|
|
|
gte_SetRotMatrix(&cp->hd.drawCarMat);
|
|
|
|
gte_SetTransVector(vec);
|
|
|
|
|
|
|
|
gte_ldv0(svec);
|
|
|
|
|
2020-09-03 07:31:49 +02:00
|
|
|
gte_rtv0tr();
|
2020-04-29 18:01:27 +02:00
|
|
|
|
2020-05-22 10:51:20 +02:00
|
|
|
gte_stlvnl(vec);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 17:03:13 +02:00
|
|
|
int CarLightFadeBack = 0;
|
|
|
|
int CarLightFadeFront = 0;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void FindCarLightFade(MATRIX *carToCamera)
|
|
|
|
{
|
2020-04-29 17:03:13 +02:00
|
|
|
int zz;
|
2020-10-17 09:26:57 +02:00
|
|
|
|
|
|
|
zz = carToCamera->m[2][2] / 4;
|
|
|
|
|
2020-04-29 17:03:13 +02:00
|
|
|
CarLightFadeFront = zz - 124;
|
|
|
|
CarLightFadeBack = -124 - zz;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2021-03-10 11:19:47 +01:00
|
|
|
void ShowCarlight(SVECTOR *v1, CAR_DATA *cp, CVECTOR *col, short size, short flare_size, TEXTURE_DETAILS *texture,int flag)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
int CarLightFade;
|
2020-04-29 17:03:13 +02:00
|
|
|
VECTOR v1t;
|
|
|
|
VECTOR v1l;
|
|
|
|
CVECTOR flareCol;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
CarLightFade = 255;
|
2020-04-29 17:03:13 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (flag != 0xFF)
|
2020-04-29 17:03:13 +02:00
|
|
|
{
|
2021-03-10 11:19:47 +01:00
|
|
|
if (flag & 1)
|
2020-10-17 09:26:57 +02:00
|
|
|
CarLightFade = CarLightFadeFront;
|
2021-03-10 11:19:47 +01:00
|
|
|
else
|
|
|
|
CarLightFade = CarLightFadeBack;
|
2020-04-29 17:03:13 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (CarLightFade < 0)
|
2020-04-04 06:49:28 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-10-17 09:26:57 +02:00
|
|
|
else
|
|
|
|
flag = 0;
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
flareCol.r = (col->r * CarLightFade) >> 10;
|
|
|
|
flareCol.b = (col->b * CarLightFade) >> 10;
|
|
|
|
flareCol.g = (col->g * CarLightFade) >> 10;
|
|
|
|
flareCol.cd = flag;
|
2020-04-29 17:03:13 +02:00
|
|
|
|
|
|
|
gte_SetRotMatrix(&cp->hd.drawCarMat);
|
|
|
|
|
2020-04-30 17:35:07 +02:00
|
|
|
v1l.vx = cp->hd.where.t[0] - camera_position.vx;
|
|
|
|
v1l.vz = cp->hd.where.t[2] - camera_position.vz;
|
2020-11-06 20:47:33 +01:00
|
|
|
v1l.vy = -camera_position.vy - cp->hd.where.t[1];
|
2020-04-29 17:03:13 +02:00
|
|
|
|
|
|
|
InitFXPos(&v1l, v1, cp);
|
|
|
|
|
2020-06-04 23:11:48 +02:00
|
|
|
if (wetness > 9)
|
2020-04-29 17:03:13 +02:00
|
|
|
{
|
|
|
|
v1t.vx = v1l.vx;
|
|
|
|
v1t.vz = v1l.vz;
|
2020-06-04 23:11:48 +02:00
|
|
|
v1t.vy = -camera_position.vy - MapHeight((VECTOR *)cp->hd.where.t);
|
2020-11-06 20:47:33 +01:00
|
|
|
|
2021-03-10 11:19:47 +01:00
|
|
|
DisplayLightReflections(&v1t, &flareCol, flare_size / 2, &lightref_texture);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-04-29 17:03:13 +02:00
|
|
|
|
|
|
|
col->cd = flag;
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
ShowLight(&v1l, &flareCol, size, texture);
|
2020-04-29 17:03:13 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
flareCol.r /= 2;
|
|
|
|
flareCol.g /= 2;
|
|
|
|
flareCol.b /= 2;
|
2020-04-29 17:03:13 +02:00
|
|
|
|
2021-03-10 11:19:47 +01:00
|
|
|
ShowFlare(&v1l, &flareCol, flare_size, (v1->vx + v1->vz) / 4 + (cp->hd.direction - camera_angle.vy) * 2);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void ShowLight1(VECTOR *v1, CVECTOR *col, short size, TEXTURE_DETAILS *texture)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-08-20 14:14:06 +02:00
|
|
|
POLY_FT4* poly;
|
|
|
|
SVECTOR vert[4];
|
|
|
|
int z;
|
|
|
|
|
|
|
|
poly = (POLY_FT4*)current->primptr;
|
|
|
|
|
|
|
|
vert[0].vz = 0;
|
|
|
|
vert[1].vz = 0;
|
|
|
|
vert[2].vz = 0;
|
|
|
|
vert[3].vz = 0;
|
|
|
|
|
|
|
|
vert[0].vx = -size;
|
|
|
|
vert[0].vy = -size;
|
|
|
|
|
|
|
|
vert[1].vx = size;
|
|
|
|
vert[1].vy = -size;
|
|
|
|
|
|
|
|
vert[2].vx = -size;
|
|
|
|
vert[2].vy = size;
|
|
|
|
|
|
|
|
vert[3].vx = size;
|
|
|
|
vert[3].vy = size;
|
|
|
|
|
|
|
|
gte_ldv3(&vert[0], &vert[1], &vert[2]);
|
|
|
|
|
2020-09-03 07:31:49 +02:00
|
|
|
gte_rtpt();
|
2020-08-20 14:14:06 +02:00
|
|
|
|
|
|
|
poly->u0 = (texture->coords).u0;
|
|
|
|
poly->v0 = (texture->coords).v0;
|
|
|
|
poly->u1 = (texture->coords).u1;
|
|
|
|
poly->v1 = (texture->coords).v1;
|
|
|
|
poly->u2 = (texture->coords).u2;
|
|
|
|
poly->v2 = (texture->coords).v2;
|
|
|
|
poly->u3 = (texture->coords).u3;
|
|
|
|
poly->v3 = (texture->coords).v3;;
|
|
|
|
|
|
|
|
setPolyFT4(poly);
|
|
|
|
SetSemiTrans(poly, 1);
|
|
|
|
|
|
|
|
poly->r0 = col->r;
|
|
|
|
poly->g0 = col->g;
|
|
|
|
poly->b0 = col->b;
|
|
|
|
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
|
|
|
|
gte_stsz(&z);
|
|
|
|
|
|
|
|
if (z > 39)
|
|
|
|
{
|
|
|
|
gte_ldv0(&vert[3]);
|
|
|
|
|
2020-09-03 07:31:49 +02:00
|
|
|
gte_rtps();
|
2020-08-20 14:14:06 +02:00
|
|
|
|
|
|
|
poly->tpage = texture->tpageid | 0x20;
|
|
|
|
poly->clut = texture->clutid;
|
|
|
|
|
|
|
|
z = (z >> 3) + LightSortCorrect;
|
|
|
|
|
|
|
|
if (z < 0)
|
|
|
|
z = 0;
|
|
|
|
|
|
|
|
gte_stsxy(&poly->x3);
|
|
|
|
|
|
|
|
addPrim(current->ot + z, poly);
|
|
|
|
|
|
|
|
current->primptr += sizeof(POLY_FT4);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void ShowLight(VECTOR *v1, CVECTOR *col, short size, TEXTURE_DETAILS *texture)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
int x, y;
|
2020-06-05 11:13:23 +02:00
|
|
|
POLY_FT3 *null;
|
2020-11-06 20:47:33 +01:00
|
|
|
POLY_G4 *trail;
|
2020-06-05 09:20:26 +02:00
|
|
|
POLY_FT4 *poly;
|
2020-11-06 20:47:33 +01:00
|
|
|
int i;
|
2020-06-05 11:13:23 +02:00
|
|
|
SVECTOR vert[4];
|
2020-06-05 09:20:26 +02:00
|
|
|
int z;
|
2020-06-06 13:34:53 +02:00
|
|
|
int index;
|
2020-11-06 20:47:33 +01:00
|
|
|
SXYPAIR* trails;
|
|
|
|
short* clock;
|
|
|
|
int tail_width;
|
2020-06-05 09:20:26 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
// apply transform
|
2020-06-05 09:20:26 +02:00
|
|
|
Apply_Inv_CameraMatrix(v1);
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-10-05 22:02:41 +02:00
|
|
|
gte_SetRotMatrix(&identity);
|
2020-06-05 11:13:23 +02:00
|
|
|
gte_SetTransVector(v1);
|
|
|
|
|
|
|
|
vert[0].vz = 0;
|
|
|
|
vert[1].vz = 0;
|
|
|
|
vert[2].vz = 0;
|
|
|
|
vert[3].vz = 0;
|
|
|
|
|
|
|
|
vert[0].vx = -size;
|
|
|
|
vert[0].vy = -size;
|
|
|
|
|
|
|
|
vert[1].vx = size;
|
|
|
|
vert[1].vy = -size;
|
|
|
|
|
|
|
|
vert[2].vx = -size;
|
|
|
|
vert[2].vy = size;
|
|
|
|
|
|
|
|
vert[3].vx = size;
|
|
|
|
vert[3].vy = size;
|
|
|
|
|
|
|
|
gte_ldv3(&vert[0], &vert[1], &vert[2]);
|
|
|
|
gte_rtpt();
|
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
gte_stsz(&z);
|
2020-06-05 11:13:23 +02:00
|
|
|
|
|
|
|
// discard if too close
|
2020-11-06 23:34:41 +01:00
|
|
|
if (z < 38)
|
2020-06-05 11:13:23 +02:00
|
|
|
return;
|
|
|
|
|
2020-06-05 09:20:26 +02:00
|
|
|
poly = (POLY_FT4 *)current->primptr;
|
2020-06-05 11:13:23 +02:00
|
|
|
setPolyFT4(poly);
|
|
|
|
setSemiTrans(poly, 1);
|
|
|
|
|
|
|
|
poly->u0 = texture->coords.u0;
|
|
|
|
poly->v0 = texture->coords.v0;
|
|
|
|
poly->u1 = texture->coords.u1;
|
|
|
|
poly->v1 = texture->coords.v1;
|
|
|
|
poly->u2 = texture->coords.u2;
|
|
|
|
poly->v2 = texture->coords.v2;
|
|
|
|
poly->u3 = texture->coords.u3;
|
|
|
|
poly->v3 = texture->coords.v3;
|
|
|
|
|
2020-06-05 09:20:26 +02:00
|
|
|
poly->r0 = col->r;
|
|
|
|
poly->g0 = col->g;
|
|
|
|
poly->b0 = col->b;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
|
|
|
|
gte_ldv0(&vert[3]);
|
|
|
|
gte_rtps();
|
|
|
|
|
|
|
|
gte_stsxy(&poly->x3);
|
|
|
|
|
|
|
|
poly->tpage = texture->tpageid | 0x20;
|
|
|
|
poly->clut = texture->clutid;
|
2020-11-06 20:47:33 +01:00
|
|
|
|
|
|
|
z = (z >> 3) + LightSortCorrect;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
|
|
|
if (z < 0)
|
|
|
|
z = 0;
|
|
|
|
|
|
|
|
if (z < 10000)
|
2020-11-06 20:47:33 +01:00
|
|
|
tail_width = (10000 - z) >> 0xd;
|
2020-06-05 11:13:23 +02:00
|
|
|
else
|
2020-11-06 20:47:33 +01:00
|
|
|
tail_width = 0;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
|
|
|
addPrim(current->ot + z, poly);
|
|
|
|
current->primptr += sizeof(POLY_FT4);
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
if (CameraCnt <= 4 || NumPlayers > 1) // [A] don't draw trails in multiplayer
|
2020-11-06 20:47:33 +01:00
|
|
|
return;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if ((col->cd & 0x20) && gLightsOn)
|
|
|
|
{
|
|
|
|
trails = Known_Lamps[LightIndex].light_trails;
|
|
|
|
clock = &Known_Lamps[LightIndex].clock;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
// get light index by flag
|
|
|
|
if (col->cd & 0x2)
|
2020-11-06 20:47:33 +01:00
|
|
|
index = 0;
|
2020-11-07 10:54:15 +01:00
|
|
|
else if (col->cd & 0x4)
|
2020-11-06 20:47:33 +01:00
|
|
|
index = 1;
|
2020-11-07 10:54:15 +01:00
|
|
|
else if (col->cd & 0x8)
|
2020-11-06 20:47:33 +01:00
|
|
|
index = 2;
|
|
|
|
else if (col->cd & 0x10)
|
|
|
|
index = 3;
|
|
|
|
else
|
|
|
|
index = -1;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (index == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
trails = car_data[gcar_num].ap.light_trails[index];
|
|
|
|
clock = &car_data[gcar_num].ap.old_clock[index];
|
|
|
|
}
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
#ifndef PSX
|
|
|
|
x = (poly->x0 + poly->x3) / 2.0f;
|
|
|
|
y = (poly->y0 + poly->y3) / 2.0f;
|
|
|
|
#else
|
|
|
|
x = (poly->x0 + poly->x3) / 2;
|
|
|
|
y = (poly->y0 + poly->y3) / 2;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// unified drawing both for car and lamps
|
|
|
|
if (CameraChanged == 0 && *clock == (FrameCnt & 0xffffU)-1)
|
|
|
|
{
|
|
|
|
int old_x, old_y;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
old_x = trails[FrameCnt - 3U & 3].x;
|
|
|
|
old_y = trails[FrameCnt - 3U & 3].y;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
trails[FrameCnt & 3].x = x;
|
|
|
|
trails[FrameCnt & 3].y = y;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (size > 1 && ABS(old_x - x) + ABS(old_y - y) > 1)
|
|
|
|
{
|
|
|
|
int angle, width;
|
|
|
|
VERTTYPE dx, dy;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
trail = (POLY_G4 *)current->primptr;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
setPolyG4(trail);
|
|
|
|
setSemiTrans(trail, 1);
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
angle = -ratan2(old_x - x,old_y - y) & 0xfff;
|
|
|
|
width = ABS(poly->x0 - poly->x3);
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
#ifdef PSX
|
2021-06-20 17:13:54 +02:00
|
|
|
dx = RCOS(angle) * width * 3;
|
|
|
|
dy = RSIN(angle) * width * 3;
|
2020-11-06 20:47:33 +01:00
|
|
|
|
|
|
|
if (col->cd & 0x40)
|
|
|
|
{
|
|
|
|
dx >>= 0x10;
|
|
|
|
dy >>= 0x10;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-06-05 11:13:23 +02:00
|
|
|
else
|
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
dx >>= 0xf;
|
|
|
|
dy >>= 0xf;
|
2020-06-05 11:13:23 +02:00
|
|
|
}
|
2020-11-06 20:47:33 +01:00
|
|
|
|
|
|
|
trail->x0 = x + dx * tail_width;
|
|
|
|
trail->y0 = y + dy * tail_width;
|
|
|
|
|
|
|
|
trail->x1 = x - dx * tail_width;
|
|
|
|
trail->y1 = y - dy * tail_width;
|
|
|
|
|
|
|
|
trail->x2 = old_x + dx;
|
|
|
|
trail->y2 = old_y + dy;
|
|
|
|
|
|
|
|
trail->x3 = old_x - dx;
|
|
|
|
trail->y3 = old_y - dy;
|
|
|
|
#else
|
2021-06-20 17:13:54 +02:00
|
|
|
// [A] slightly bigger light trail
|
|
|
|
dx = RCOS(angle);
|
|
|
|
dy = RSIN(angle);
|
2020-11-06 20:47:33 +01:00
|
|
|
|
|
|
|
if (col->cd & 0x40)
|
2020-06-05 11:13:23 +02:00
|
|
|
{
|
2021-06-20 17:13:54 +02:00
|
|
|
dx = dx / 40000.0f;
|
2020-11-06 20:47:33 +01:00
|
|
|
dy = dy / 40000.0f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dx = dx / 32768.0f;
|
|
|
|
dy = dy / 32768.0f;
|
|
|
|
}
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
trail->x0 = x + dx * width * 3 * tail_width;
|
|
|
|
trail->y0 = y + dy * width * 3 * tail_width;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
trail->x1 = x - dx * width * 3 * tail_width;
|
|
|
|
trail->y1 = y - dy * width * 3 * tail_width;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
trail->x2 = old_x + dx * width * 3;
|
|
|
|
trail->y2 = old_y + dy * width * 3;
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
trail->x3 = old_x - dx * width * 3;
|
|
|
|
trail->y3 = old_y - dy * width * 3;
|
|
|
|
#endif
|
2020-06-05 11:13:23 +02:00
|
|
|
|
2020-11-06 20:47:33 +01:00
|
|
|
if (col->cd & 0x18)
|
|
|
|
{
|
|
|
|
trail->r0 = trail->r1 = col->r / 2;
|
|
|
|
trail->g0 = trail->g1 = col->g / 2;
|
|
|
|
trail->b0 = trail->b1 = col->b / 2;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 20:47:33 +01:00
|
|
|
else
|
2020-06-06 13:34:53 +02:00
|
|
|
{
|
2020-11-06 20:47:33 +01:00
|
|
|
trail->r0 = trail->r1 = col->r;
|
|
|
|
trail->g0 = trail->g1 = col->g;
|
|
|
|
trail->b0 = trail->b1 = col->b;
|
|
|
|
}
|
|
|
|
|
|
|
|
trail->r2 = trail->r3 = 0;
|
|
|
|
trail->g2 = trail->g3 = 0;
|
|
|
|
trail->b2 = trail->b3 = 0;
|
|
|
|
|
|
|
|
addPrim(current->ot + z, trail);
|
|
|
|
current->primptr += sizeof(POLY_G4);
|
|
|
|
|
|
|
|
null = (POLY_FT3 *)current->primptr;
|
|
|
|
|
|
|
|
setPolyFT3(null);
|
|
|
|
null->x0 = -1;
|
|
|
|
null->y0 = -1;
|
|
|
|
null->x1 = -1;
|
|
|
|
null->y1 = -1;
|
|
|
|
null->x2 = -1;
|
|
|
|
null->y2 = -1;
|
|
|
|
null->tpage = 0x20;
|
|
|
|
|
|
|
|
addPrim(current->ot + z, null);
|
|
|
|
current->primptr += sizeof(POLY_FT3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
trails[i].x = x;
|
|
|
|
trails[i].y = y;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-06-05 11:13:23 +02:00
|
|
|
}
|
2020-11-06 20:47:33 +01:00
|
|
|
|
|
|
|
*clock = FrameCnt;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void ShowGroundLight(VECTOR *v1, CVECTOR *col, short size)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-06-05 15:28:43 +02:00
|
|
|
POLY_FT4 *poly;
|
|
|
|
SVECTOR vert[4];
|
|
|
|
int z;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
#ifndef PSX
|
|
|
|
// [A] limit drawing distance to avoid artifacts
|
|
|
|
if (ABS(v1->vx) > 32000 || ABS(v1->vz) > 32000)
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
2020-06-05 15:28:43 +02:00
|
|
|
gte_SetRotMatrix(&inv_camera_matrix);
|
|
|
|
gte_SetTransVector(&dummy);
|
|
|
|
|
|
|
|
// [A] might be incorrect
|
|
|
|
vert[0].vx = v1->vx - size;
|
|
|
|
vert[0].vy = v1->vy;
|
|
|
|
vert[0].vz = v1->vz + size;
|
|
|
|
|
|
|
|
vert[1].vx = v1->vx + size;
|
|
|
|
vert[1].vy = v1->vy;
|
|
|
|
vert[1].vz = v1->vz + size;
|
|
|
|
|
|
|
|
vert[2].vx = v1->vx - size;
|
|
|
|
vert[2].vy = v1->vy;
|
|
|
|
vert[2].vz = v1->vz - size;
|
|
|
|
|
|
|
|
vert[3].vx = v1->vx + size;
|
|
|
|
vert[3].vy = v1->vy;
|
|
|
|
vert[3].vz = v1->vz - size;
|
|
|
|
|
|
|
|
gte_ldv3(&vert[0], &vert[1], &vert[2]);
|
|
|
|
|
|
|
|
gte_rtpt();
|
|
|
|
|
|
|
|
gte_stsz(&z);
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
if (z - 150 < 9851)
|
2020-06-05 15:28:43 +02:00
|
|
|
{
|
|
|
|
poly = (POLY_FT4 *)current->primptr;
|
|
|
|
|
|
|
|
setPolyFT4(poly);
|
|
|
|
setSemiTrans(poly, 1);
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
*(ushort*)&poly->u0 = *(ushort*)&light_texture.coords.u0;
|
|
|
|
*(ushort*)&poly->u1 = *(ushort*)&light_texture.coords.u1;
|
|
|
|
*(ushort*)&poly->u2 = *(ushort*)&light_texture.coords.u2;
|
|
|
|
*(ushort*)&poly->u3 = *(ushort*)&light_texture.coords.u3;
|
2020-06-05 15:28:43 +02:00
|
|
|
|
|
|
|
poly->tpage = light_texture.tpageid | 0x20;
|
|
|
|
poly->clut = light_texture.clutid;;
|
|
|
|
|
|
|
|
poly->r0 = col->r;
|
|
|
|
poly->g0 = col->g;
|
|
|
|
poly->b0 = col->b;
|
|
|
|
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
|
|
|
|
gte_ldv0(&vert[3]);
|
|
|
|
|
|
|
|
gte_rtps();
|
|
|
|
gte_stsxy(&poly->x3);
|
|
|
|
|
|
|
|
addPrim(current->ot + (z >> 3), poly);
|
|
|
|
current->primptr += sizeof(POLY_FT4);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void RoundShadow(VECTOR *v1, CVECTOR *col, short size)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-08-20 15:09:16 +02:00
|
|
|
POLY_FT4* poly;
|
|
|
|
SVECTOR vert[4];
|
|
|
|
int z;
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&inv_camera_matrix);
|
|
|
|
gte_SetTransVector(&dummy);
|
|
|
|
|
|
|
|
vert[0].vz = 0;
|
|
|
|
vert[1].vz = 0;
|
|
|
|
vert[2].vz = 0;
|
|
|
|
vert[3].vz = 0;
|
|
|
|
|
|
|
|
vert[0].vx = v1->vx - size;
|
|
|
|
vert[0].vy = v1->vy;
|
|
|
|
vert[0].vz = size + v1->vz;
|
|
|
|
|
|
|
|
vert[1].vx = size + v1->vx;
|
|
|
|
vert[1].vy = v1->vy;
|
|
|
|
vert[1].vz = size + v1->vz;
|
|
|
|
|
|
|
|
vert[2].vx = v1->vx - size;
|
|
|
|
vert[2].vy = v1->vy;
|
|
|
|
vert[2].vz = v1->vz - size;
|
|
|
|
|
|
|
|
vert[3].vx = size + v1->vx;
|
|
|
|
vert[3].vy = v1->vy;
|
|
|
|
vert[3].vz = v1->vz - size;
|
|
|
|
|
|
|
|
gte_ldv3(&vert[0], &vert[1], &vert[2]);
|
|
|
|
|
2020-09-03 07:31:49 +02:00
|
|
|
gte_rtpt();
|
2020-08-20 15:09:16 +02:00
|
|
|
|
|
|
|
poly = (POLY_FT4*)current->primptr;
|
|
|
|
|
|
|
|
poly->u0 = light_texture.coords.u0;
|
|
|
|
poly->v0 = light_texture.coords.v0;
|
|
|
|
poly->u1 = light_texture.coords.u1;
|
|
|
|
poly->v1 = light_texture.coords.v1;
|
|
|
|
poly->u2 = light_texture.coords.u2;
|
|
|
|
poly->v2 = light_texture.coords.v2;
|
|
|
|
poly->u3 = light_texture.coords.u3;
|
|
|
|
poly->v3 = light_texture.coords.v3;
|
|
|
|
|
|
|
|
poly->tpage = light_texture.tpageid | 0x40;
|
|
|
|
poly->clut = light_texture.clutid;
|
|
|
|
|
|
|
|
setPolyFT4(poly);
|
|
|
|
setSemiTrans(poly, 1);
|
|
|
|
|
|
|
|
poly->r0 = col->r;
|
|
|
|
poly->g0 = col->g;
|
|
|
|
poly->b0 = col->b;
|
|
|
|
|
|
|
|
gte_stsz(&z);
|
|
|
|
|
|
|
|
if (z - 150 < 9851)
|
|
|
|
{
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
|
|
|
|
gte_ldv0(&vert[3]);
|
|
|
|
|
2020-09-03 07:31:49 +02:00
|
|
|
gte_rtps();
|
2020-08-20 15:09:16 +02:00
|
|
|
|
|
|
|
gte_stsxy(&poly->x3);
|
|
|
|
|
|
|
|
addPrim(current->ot + (z >> 3), poly);
|
|
|
|
current->primptr += sizeof(POLY_FT4);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T weird and unused]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DisplayWater(SMOKE *smoke)
|
|
|
|
{
|
2020-08-26 17:24:59 +02:00
|
|
|
POLY_FT4* poly;
|
|
|
|
VECTOR v;
|
|
|
|
SVECTOR vert[4];
|
|
|
|
|
|
|
|
int size;
|
|
|
|
int z;
|
|
|
|
int z1;
|
|
|
|
int z2;
|
|
|
|
int z3;
|
|
|
|
int z4;
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&inv_camera_matrix);
|
|
|
|
gte_SetTransVector(&dummy);
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
size = smoke->start_w;
|
|
|
|
|
|
|
|
vert[0].vx = (smoke->position.vx - size) - camera_position.vx;
|
2020-08-26 17:24:59 +02:00
|
|
|
vert[0].vy = 50 - camera_position.vy;
|
2020-10-17 09:26:57 +02:00
|
|
|
vert[0].vz = (smoke->position.vz + size) - camera_position.vz;
|
2020-08-26 17:24:59 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
vert[1].vx = (smoke->position.vx + size) - camera_position.vx;
|
2020-08-26 17:24:59 +02:00
|
|
|
vert[1].vy = 50 - camera_position.vy;
|
2020-10-17 09:26:57 +02:00
|
|
|
vert[1].vz = (smoke->position.vz + size) - camera_position.vz;
|
2020-08-26 17:24:59 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
vert[2].vx = (smoke->position.vx - size) - camera_position.vx;
|
2020-08-26 17:24:59 +02:00
|
|
|
vert[2].vy = 50 - camera_position.vy;
|
2020-10-17 09:26:57 +02:00
|
|
|
vert[2].vz = (smoke->position.vz - size) - camera_position.vz;
|
2020-08-26 17:24:59 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
vert[3].vx = (smoke->position.vx + size) - camera_position.vx;
|
2020-08-26 17:24:59 +02:00
|
|
|
vert[3].vy = 50 - camera_position.vy;
|
2020-10-17 09:26:57 +02:00
|
|
|
vert[3].vz = (smoke->position.vz - size) - camera_position.vz;
|
2020-08-26 17:24:59 +02:00
|
|
|
|
|
|
|
poly = (POLY_FT4*)current->primptr;
|
|
|
|
|
|
|
|
gte_ldv3(&vert[0], &vert[1], &vert[2]);
|
|
|
|
|
2020-09-03 07:31:49 +02:00
|
|
|
gte_rtpt();
|
2020-08-26 17:24:59 +02:00
|
|
|
|
|
|
|
setPolyFT4(poly);
|
|
|
|
|
|
|
|
poly->r0 = NightAmbient;
|
|
|
|
poly->g0 = NightAmbient;
|
|
|
|
poly->b0 = NightAmbient;
|
|
|
|
poly->tpage = sea_texture.tpageid;
|
|
|
|
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
|
|
|
|
gte_stsz3(&z1, &z2, &z3);
|
|
|
|
|
|
|
|
gte_ldv0(&vert[3]);
|
|
|
|
|
2020-09-03 07:31:49 +02:00
|
|
|
gte_rtps();
|
2020-08-26 17:24:59 +02:00
|
|
|
|
|
|
|
gte_stsxy(&poly->x3);
|
|
|
|
|
|
|
|
poly->u0 = sea_texture.coords.u0;
|
|
|
|
poly->v0 = sea_texture.coords.v0;
|
|
|
|
poly->u1 = sea_texture.coords.u1;
|
|
|
|
poly->v1 = sea_texture.coords.v1;
|
|
|
|
poly->u2 = sea_texture.coords.u2;
|
|
|
|
poly->v2 = sea_texture.coords.v2;
|
|
|
|
poly->u3 = sea_texture.coords.u3;
|
|
|
|
poly->v3 = sea_texture.coords.v3;
|
|
|
|
poly->clut = sea_texture.clutid;
|
|
|
|
|
|
|
|
gte_stsz(&z4);
|
|
|
|
|
|
|
|
z = z1 + z2 + z3 + z4 >> 5;
|
|
|
|
|
|
|
|
if (z < 9)
|
|
|
|
z = 9;
|
|
|
|
|
|
|
|
addPrim(current->ot + z, poly);
|
|
|
|
|
|
|
|
current->primptr += sizeof(POLY_FT4);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DisplaySpark(SMOKE *spark)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
int colorind;
|
2020-07-07 12:57:23 +02:00
|
|
|
POLY_G3 *poly;
|
|
|
|
SVECTOR v[3];
|
|
|
|
SVECTOR TrailPos;
|
|
|
|
int z;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
TrailPos.vx = spark->position.vx - camera_position.vx;
|
|
|
|
TrailPos.vy = spark->position.vy - camera_position.vy;
|
|
|
|
TrailPos.vz = spark->position.vz - camera_position.vz;
|
|
|
|
|
2020-07-07 12:57:23 +02:00
|
|
|
gte_SetRotMatrix(&inv_camera_matrix);
|
|
|
|
gte_SetTransVector(&dummy);
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
v[0].vx = TrailPos.vx;
|
|
|
|
v[0].vy = TrailPos.vy;
|
|
|
|
v[0].vz = TrailPos.vz;
|
|
|
|
|
|
|
|
v[1].vx = TrailPos.vx + 5;
|
|
|
|
v[1].vy = TrailPos.vy;
|
|
|
|
v[1].vz = TrailPos.vz + 5;
|
|
|
|
|
2020-07-07 12:57:23 +02:00
|
|
|
v[2].vx = spark->final_tail_pos.vx - camera_position.vx;
|
|
|
|
v[2].vy = spark->final_tail_pos.vy - camera_position.vy;
|
|
|
|
v[2].vz = spark->final_tail_pos.vz - camera_position.vz;
|
|
|
|
|
|
|
|
poly = (POLY_G3 *)current->primptr;
|
|
|
|
|
|
|
|
gte_ldv3(&v[0], &v[1], &v[2]);
|
|
|
|
gte_rtpt();
|
|
|
|
|
|
|
|
setPolyG3(poly);
|
|
|
|
|
|
|
|
if (spark->start_w == 2)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
colorind = spark->drift.vy * 3 & 3;
|
2020-07-07 12:57:23 +02:00
|
|
|
|
|
|
|
if (gTimeOfDay == 1)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
poly->r0 = grassColour[colorind][0];
|
|
|
|
poly->g0 = grassColour[colorind][1];
|
|
|
|
poly->b0 = grassColour[colorind][2];
|
|
|
|
|
|
|
|
poly->r1 = grassColour[colorind][0];
|
|
|
|
poly->g1 = grassColour[colorind][1];
|
|
|
|
poly->b1 = grassColour[colorind][2];
|
|
|
|
|
|
|
|
colorind = (spark->drift.vy + 2U) * 3 & 3;
|
|
|
|
poly->r2 = grassColour[colorind][0];
|
|
|
|
poly->g2 = grassColour[colorind][1];
|
|
|
|
poly->b2 = grassColour[colorind][2];
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-07-07 12:57:23 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
poly->r0 = 0;
|
|
|
|
poly->g0 = (spark->transparency >> 3);
|
|
|
|
poly->r1 = 0;
|
|
|
|
poly->b0 = (spark->transparency >> 4);
|
|
|
|
poly->g1 = (spark->transparency >> 3);
|
|
|
|
poly->r2 = 12;
|
|
|
|
poly->g2 = 4;
|
|
|
|
poly->b2 = 4;
|
|
|
|
poly->b1 = (spark->transparency >> 4);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-07 12:57:23 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
poly->r0 = spark->transparency;
|
|
|
|
poly->g0 = spark->transparency;
|
|
|
|
poly->b0 = spark->transparency / 2;
|
|
|
|
poly->r1 = spark->transparency;
|
|
|
|
poly->g1 = spark->transparency;
|
|
|
|
poly->b1 = spark->transparency / 2;
|
|
|
|
poly->r2 = spark->transparency;
|
|
|
|
poly->g2 = 0;
|
|
|
|
poly->b2 = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-07-07 12:57:23 +02:00
|
|
|
|
|
|
|
gte_stsz(&z);
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (z > 50)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
|
|
|
if (z >> 3 < 9)
|
|
|
|
z = 72;
|
|
|
|
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
addPrim(current->ot + (z >> 3), poly);
|
|
|
|
|
|
|
|
current->primptr += sizeof(POLY_G3);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-07-05 20:33:14 +02:00
|
|
|
int SmokeCnt = 0;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void GetSmokeDrift(VECTOR *Wind)
|
|
|
|
{
|
2020-07-05 20:33:14 +02:00
|
|
|
static int SinTabIndex1 = 10;
|
|
|
|
static int SinTabIndex2 = 0;
|
|
|
|
static int SinTabIndex3 = 5;
|
|
|
|
static int SinX = 0;
|
|
|
|
static int CosX = 0;
|
|
|
|
static int WindMagnitude = 0;
|
|
|
|
|
|
|
|
if (SmokeCnt != CameraCnt)
|
|
|
|
{
|
2020-04-04 06:49:28 +02:00
|
|
|
SmokeCnt = CameraCnt;
|
2020-07-05 20:33:14 +02:00
|
|
|
|
|
|
|
SinTabIndex1 = SinTabIndex1 + 3 & 0xfff;
|
|
|
|
SinTabIndex2 = SinTabIndex2 + 5 & 0xfff;
|
|
|
|
SinTabIndex3 = SinTabIndex3 + 7 & 0xfff;
|
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
SinX = isin(SinTabIndex1) + isin(SinTabIndex2);
|
|
|
|
CosX = icos(SinTabIndex1) + icos(SinTabIndex2);
|
|
|
|
WindMagnitude = isin(SinTabIndex3) >> 0xb;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-07-05 20:33:14 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
Wind->vy = 0;
|
2020-09-11 11:30:58 +02:00
|
|
|
Wind->vx = FIXEDH(WindMagnitude * CosX);
|
|
|
|
Wind->vz = FIXEDH(-WindMagnitude * SinX);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void Setup_Debris(VECTOR *ipos, VECTOR *ispeed, int num_debris, int type)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
int num;
|
|
|
|
int seed;
|
|
|
|
int col;
|
|
|
|
int i;
|
2020-07-07 12:57:23 +02:00
|
|
|
DEBRIS *mydebris;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
col = type >> 0x10;
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
for (i = 0; i < num_debris; i++)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
num = AllocateDebris();
|
|
|
|
if (num == -1)
|
2020-07-07 13:21:00 +02:00
|
|
|
return;
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
mydebris = &debris[num];
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-07-07 13:21:00 +02:00
|
|
|
mydebris->position.vx = ipos->vx;
|
|
|
|
mydebris->position.vy = ipos->vy;
|
|
|
|
mydebris->position.vz = ipos->vz;
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-07-07 13:21:00 +02:00
|
|
|
if ((type & 0xffffU) < 8)
|
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
seed = rand();
|
|
|
|
|
|
|
|
mydebris->step = seed;
|
|
|
|
mydebris->rgb.r = debris_colour[GameLevel][col].r;
|
|
|
|
mydebris->rgb.g = debris_colour[GameLevel][col].g;
|
|
|
|
mydebris->rgb.b = debris_colour[GameLevel][col].b;
|
2020-07-07 13:21:00 +02:00
|
|
|
|
|
|
|
if (gTimeOfDay == 3)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
mydebris->rgb.r >>= 1;
|
|
|
|
mydebris->rgb.g >>= 1;
|
|
|
|
mydebris->rgb.b >>= 1;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
|
|
|
|
mydebris->direction.vx = FIXED((ispeed->vx + ((seed & 0x7f) - 64) * num_debris) * 1024);
|
|
|
|
mydebris->direction.vy = -FIXED((seed & 0x7f00) * num_debris * 2);
|
|
|
|
mydebris->direction.vz = FIXED(ispeed->vz + ((rand() & 0x7fff) - 16384) * num_debris * 2);
|
2020-07-07 13:21:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mydebris->step = 2;
|
2020-11-06 23:34:41 +01:00
|
|
|
|
2020-07-07 13:21:00 +02:00
|
|
|
mydebris->rgb.b = 60;
|
|
|
|
mydebris->rgb.g = 60;
|
|
|
|
mydebris->rgb.r = 60;
|
2020-11-06 23:34:41 +01:00
|
|
|
|
|
|
|
mydebris->direction.vx = FIXED(ispeed->vx);
|
|
|
|
mydebris->direction.vy = -FIXED(ispeed->vy);
|
|
|
|
mydebris->direction.vz = FIXED(ispeed->vz);
|
2020-07-07 13:21:00 +02:00
|
|
|
}
|
2020-11-20 18:26:28 +01:00
|
|
|
|
2020-07-07 13:21:00 +02:00
|
|
|
mydebris->type = type & 7;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
mydebris->life = 128;
|
2021-03-01 21:10:38 +01:00
|
|
|
mydebris->flags = 0x2;
|
2020-11-06 23:34:41 +01:00
|
|
|
mydebris->pos = i & 0x1f;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void Setup_Smoke(VECTOR *ipos, int start_w, int end_w, int SmokeType, int WheelSpeed, VECTOR *Drift, int Exhaust)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
int num;
|
2020-07-07 12:57:23 +02:00
|
|
|
SMOKE *mysmoke;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
num = AllocateSmoke();
|
|
|
|
if (num == -1)
|
2020-04-04 06:49:28 +02:00
|
|
|
return;
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
mysmoke = &smoke[num];
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
if (SmokeType == SMOKE_FIRE)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
2020-07-07 16:39:12 +02:00
|
|
|
mysmoke->position.vx = ipos->vx;
|
2020-07-07 12:57:23 +02:00
|
|
|
mysmoke->position.vy = ipos->vy;
|
2020-07-07 16:39:12 +02:00
|
|
|
mysmoke->start_w = start_w;
|
|
|
|
mysmoke->final_w = end_w;
|
|
|
|
mysmoke->position.vz = ipos->vz;
|
2020-11-06 23:34:41 +01:00
|
|
|
mysmoke->step = end_w - start_w >> 7 << 2;
|
2021-03-01 21:10:38 +01:00
|
|
|
mysmoke->flags = 0x1000 | 0x4 | 0x2;
|
2020-07-07 12:57:23 +02:00
|
|
|
mysmoke->life = 20;
|
|
|
|
mysmoke->halflife = 10;
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
if (WheelSpeed > 200000)
|
|
|
|
mysmoke->transparency = (800000 - WheelSpeed >> 0xb);
|
2020-07-07 12:57:23 +02:00
|
|
|
else
|
2020-11-06 23:34:41 +01:00
|
|
|
mysmoke->transparency = 0xff;
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
mysmoke->t_step = end_w - start_w >> 2;
|
2020-07-07 12:57:23 +02:00
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
else if (SmokeType == SMOKE_BLACK)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
if (Exhaust)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
2020-07-07 16:39:26 +02:00
|
|
|
mysmoke->position.vx = ipos->vx + (rand() & 9);
|
2020-07-07 12:57:23 +02:00
|
|
|
mysmoke->position.vy = ipos->vy;
|
2020-07-07 16:39:26 +02:00
|
|
|
mysmoke->position.vz = ipos->vz + (rand() & 9);
|
2020-11-06 23:34:41 +01:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
mysmoke->flags = 0x2000 | 0x4 | 0x2;
|
2020-10-17 09:26:57 +02:00
|
|
|
mysmoke->transparency = 140;
|
2020-07-07 19:43:45 +02:00
|
|
|
mysmoke->t_step = 5;
|
2020-07-07 16:39:26 +02:00
|
|
|
mysmoke->step = 1;
|
2020-07-07 12:57:23 +02:00
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
mysmoke->position.vx = ipos->vx;
|
|
|
|
mysmoke->position.vy = ipos->vy;
|
|
|
|
mysmoke->position.vz = ipos->vz;
|
|
|
|
|
|
|
|
if (WheelSpeed > 200000)
|
|
|
|
mysmoke->transparency = (800000 - WheelSpeed >> 0xb);
|
|
|
|
else
|
|
|
|
mysmoke->transparency = 255;
|
|
|
|
|
|
|
|
mysmoke->t_step = end_w - start_w >> 5;
|
|
|
|
mysmoke->step = (end_w - start_w) / 128 * 4;
|
|
|
|
}
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-07-07 16:39:12 +02:00
|
|
|
mysmoke->start_w = start_w;
|
|
|
|
mysmoke->final_w = end_w;
|
2020-07-07 16:39:26 +02:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
mysmoke->flags = 0x2000 | 0x4 | 0x2;
|
2020-07-07 12:57:23 +02:00
|
|
|
mysmoke->life = 40;
|
2020-10-17 09:26:57 +02:00
|
|
|
mysmoke->halflife = 20;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
else if (SmokeType == SMOKE_WHITE || SmokeType == 5)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
if (Exhaust)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
mysmoke->position.vx = ipos->vx + (rand() & 7);
|
|
|
|
mysmoke->position.vy = ipos->vy;
|
|
|
|
mysmoke->position.vz = ipos->vz + (rand() & 7);
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
mysmoke->flags = 0x4000 | 0x4 | 0x2;
|
2020-11-07 10:54:15 +01:00
|
|
|
mysmoke->transparency = 55;
|
|
|
|
mysmoke->t_step = 2;
|
|
|
|
mysmoke->step = 1;
|
|
|
|
mysmoke->life = 24;
|
2020-07-07 12:57:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
mysmoke->position.vx = ipos->vx + (rand() & 0x3f);
|
|
|
|
mysmoke->position.vy = ipos->vy;
|
|
|
|
mysmoke->position.vz = ipos->vz + (rand() & 0x3f);
|
2021-03-01 21:10:38 +01:00
|
|
|
mysmoke->flags = 0x10 | 0x4 | 0x2;
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
if (SmokeType == 5) // UNUSED
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
mysmoke->life = 32;
|
|
|
|
mysmoke->step = end_w >> 5 << 2;
|
|
|
|
mysmoke->t_step = end_w - start_w >> 5;
|
|
|
|
mysmoke->transparency = WheelSpeed;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
mysmoke->life = 128;
|
2020-11-07 10:54:15 +01:00
|
|
|
mysmoke->step = (end_w - start_w) / 128 * 8;
|
|
|
|
mysmoke->t_step = (end_w - start_w >> 6);
|
|
|
|
mysmoke->transparency = 80;
|
2020-11-06 23:34:41 +01:00
|
|
|
}
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
mysmoke->start_w = start_w;
|
|
|
|
mysmoke->final_w = end_w;
|
|
|
|
mysmoke->halflife = 64;
|
|
|
|
}
|
|
|
|
else if (SmokeType == 6) // UNUSED
|
|
|
|
{
|
|
|
|
mysmoke->position.vx = ipos->vx;
|
|
|
|
mysmoke->position.vy = ipos->vy;
|
|
|
|
mysmoke->position.vz = ipos->vz;
|
2021-03-01 21:10:38 +01:00
|
|
|
mysmoke->flags = 0x40 | 0x4 | 0x2;
|
2020-11-07 10:54:15 +01:00
|
|
|
mysmoke->transparency = 160;
|
|
|
|
mysmoke->step = 20;
|
|
|
|
mysmoke->t_step = 5;
|
|
|
|
mysmoke->start_w = start_w;
|
|
|
|
mysmoke->final_w = end_w;
|
|
|
|
mysmoke->life = 78;
|
|
|
|
mysmoke->halflife = 32;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mysmoke->position.vx = ipos->vx + (rand() & 0x3f);
|
|
|
|
mysmoke->position.vy = ipos->vy;
|
2021-03-01 21:10:38 +01:00
|
|
|
mysmoke->flags = 0x20 | 0x4 | 0x2;
|
2020-11-07 10:54:15 +01:00
|
|
|
mysmoke->transparency = 60;
|
|
|
|
mysmoke->t_step = 5;
|
|
|
|
mysmoke->start_w = start_w;
|
|
|
|
mysmoke->final_w = end_w;
|
|
|
|
mysmoke->position.vz = ipos->vz + (rand() & 0x3f);
|
|
|
|
|
|
|
|
mysmoke->step = (end_w / 128) * 8;
|
|
|
|
mysmoke->life = 128;
|
|
|
|
mysmoke->halflife = 64;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
if (Exhaust != 0)
|
|
|
|
{
|
|
|
|
mysmoke->drift.vx = Drift->vx;
|
|
|
|
mysmoke->drift.vy = Drift->vy;
|
|
|
|
mysmoke->drift.vz = Drift->vz;
|
|
|
|
|
|
|
|
mysmoke->drift_change.vx = 0;
|
|
|
|
mysmoke->drift_change.vy = 0;
|
|
|
|
mysmoke->drift_change.vz = 0;
|
|
|
|
}
|
|
|
|
else
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
|
|
|
mysmoke->drift.vx = 0;
|
|
|
|
mysmoke->drift.vy = 0;
|
|
|
|
mysmoke->drift.vz = 0;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (mysmoke->life < 40 || SmokeType == 4)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
|
|
|
mysmoke->drift_change.vx = 0;
|
|
|
|
mysmoke->drift_change.vy = 1;
|
|
|
|
mysmoke->drift_change.vz = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-07-07 12:57:23 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
mysmoke->drift_change.vx = Drift->vx;
|
|
|
|
mysmoke->drift_change.vy = Drift->vy;
|
|
|
|
mysmoke->drift_change.vz = Drift->vz;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void Setup_Sparks(VECTOR *ipos, VECTOR *ispeed, int num_sparks, char SparkType)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
int num;
|
|
|
|
int seed;
|
|
|
|
int vz;
|
|
|
|
int vy;
|
|
|
|
int vx;
|
|
|
|
int i;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-07-07 12:57:23 +02:00
|
|
|
SMOKE *mysmoke;
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
if (pauseflag != 0 || 0 >= num_sparks)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < num_sparks; i++)
|
2020-07-07 12:57:23 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
num = AllocateSmoke();
|
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
if (num == -1)
|
2020-11-06 23:34:41 +01:00
|
|
|
return;
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
mysmoke = &smoke[num];
|
2020-07-07 12:57:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
seed = rand();
|
|
|
|
|
|
|
|
mysmoke->position.vx = mysmoke->final_tail_pos.vx = ipos->vx;
|
|
|
|
mysmoke->position.vy = mysmoke->final_tail_pos.vy = ipos->vy;
|
|
|
|
mysmoke->position.vz = mysmoke->final_tail_pos.vz = ipos->vz;
|
|
|
|
|
|
|
|
mysmoke->pos = (i << 2);
|
|
|
|
mysmoke->step = seed & 0x3f;
|
|
|
|
|
|
|
|
mysmoke->drift.vx = 2;
|
2021-03-01 21:10:38 +01:00
|
|
|
mysmoke->flags = 0x8 | 0x2;
|
2020-11-06 23:34:41 +01:00
|
|
|
|
|
|
|
vx = ispeed->vx;
|
|
|
|
vy = ispeed->vy;
|
|
|
|
vz = ispeed->vz;
|
|
|
|
|
|
|
|
mysmoke->drift_change.vx = FIXED((vx - 16384 + (seed & 0x7f00)) * 4);
|
|
|
|
mysmoke->drift_change.vy = -FIXED((vy + (seed & 0x7f)) * 1024);
|
|
|
|
mysmoke->drift_change.vz = FIXED(vz - 64 + (rand() & 0x7f) >> 2);
|
|
|
|
|
|
|
|
if (SparkType == 1)
|
|
|
|
{
|
|
|
|
mysmoke->life = 10;
|
|
|
|
mysmoke->transparency = 200;
|
|
|
|
mysmoke->t_step = 2;
|
|
|
|
mysmoke->start_w = 0;
|
|
|
|
}
|
|
|
|
else if (SparkType == 2)
|
|
|
|
{
|
|
|
|
mysmoke->life = 10;
|
|
|
|
mysmoke->transparency = 0xff;
|
|
|
|
mysmoke->t_step = 10;
|
|
|
|
mysmoke->start_w = 2;
|
|
|
|
mysmoke->drift.vy = rand() & 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mysmoke->life = 40;
|
|
|
|
mysmoke->transparency = 0xff;
|
|
|
|
mysmoke->t_step = 10;
|
|
|
|
mysmoke->start_w = 1;
|
|
|
|
}
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void DisplayDebris(DEBRIS *debris, char type)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-07-07 13:21:00 +02:00
|
|
|
int uVar3;
|
|
|
|
TRI_POINT* tv;
|
|
|
|
POLY_GT4 *poly1;
|
|
|
|
POLY_FT3 *poly;
|
|
|
|
SVECTOR v[4];
|
|
|
|
VECTOR debrisvec;
|
|
|
|
int z;
|
|
|
|
|
|
|
|
debrisvec.vx = debris->position.vx - camera_position.vx;
|
|
|
|
debrisvec.vy = debris->position.vy - camera_position.vy;
|
|
|
|
debrisvec.vz = debris->position.vz - camera_position.vz;
|
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
if (debrisvec.vx >= -10000 &&
|
|
|
|
debrisvec.vz >= -10000 &&
|
|
|
|
debrisvec.vx <= 10000 &&
|
|
|
|
debrisvec.vz <= 10000)
|
2020-07-07 13:21:00 +02:00
|
|
|
{
|
2020-11-20 18:26:28 +01:00
|
|
|
tv = debris_rot_table[debris->type & 7] + (debris->pos >> 3 & 0x1fU);
|
2020-07-07 13:21:00 +02:00
|
|
|
|
|
|
|
v[0].vx = tv->v0.vx + debrisvec.vx;
|
|
|
|
v[0].vy = tv->v0.vy + debrisvec.vy;
|
|
|
|
v[0].vz = tv->v0.vz + debrisvec.vz;
|
|
|
|
|
|
|
|
v[1].vx = tv->v1.vx + debrisvec.vx;
|
|
|
|
v[1].vy = tv->v1.vy + debrisvec.vy;
|
|
|
|
v[1].vz = tv->v1.vz + debrisvec.vz;
|
|
|
|
|
|
|
|
v[2].vx = tv->v2.vx + debrisvec.vx;
|
|
|
|
v[2].vy = tv->v2.vy + debrisvec.vy;
|
|
|
|
v[2].vz = tv->v2.vz + debrisvec.vz;
|
|
|
|
|
|
|
|
gte_ldv3(&v[0], &v[1], &v[2]);
|
|
|
|
gte_rtpt();
|
|
|
|
|
2020-11-19 18:01:33 +01:00
|
|
|
if (type - 1U < 2)
|
2020-07-07 13:21:00 +02:00
|
|
|
{
|
|
|
|
poly1 = (POLY_GT4 *)current->primptr;
|
|
|
|
|
|
|
|
gte_stsxy3(&poly1->x0, &poly1->x1, &poly1->x2);
|
|
|
|
gte_stsz(&z);
|
|
|
|
|
|
|
|
if (z > 223)
|
|
|
|
{
|
2020-08-10 17:08:57 +02:00
|
|
|
*(ushort*)&poly1->u0 = *(ushort*)&litter_texture.coords.u0;
|
|
|
|
*(ushort*)&poly1->u1 = *(ushort*)&litter_texture.coords.u1;
|
|
|
|
*(ushort*)&poly1->u2 = *(ushort*)&litter_texture.coords.u2;
|
|
|
|
*(ushort*)&poly1->u3 = *(ushort*)&litter_texture.coords.u3;
|
|
|
|
|
|
|
|
poly1->clut = litter_texture.clutid;
|
|
|
|
poly1->tpage = litter_texture.tpageid;
|
|
|
|
|
|
|
|
v[3].vx = debrisvec.vx - tv->v0.vx;
|
|
|
|
v[3].vy = debrisvec.vy - tv->v0.vy;
|
|
|
|
v[3].vz = debrisvec.vz - tv->v0.vz;
|
|
|
|
|
2020-07-07 13:21:00 +02:00
|
|
|
gte_ldv0(&v[3]);
|
|
|
|
gte_rtps();
|
|
|
|
|
|
|
|
gte_stsxy(&poly1->x3);
|
|
|
|
|
|
|
|
if (type == 2)
|
|
|
|
uVar3 = (debris->rgb.b + combointensity) * 0x10000 | (debris->rgb.g + combointensity) * 0x100 | 0x3c000000 | debris->rgb.r + combointensity;
|
|
|
|
else
|
|
|
|
uVar3 = debris->rgb.b << 0x10 | debris->rgb.g << 8 | 0x3c000000 | debris->rgb.r;
|
|
|
|
|
2021-04-04 21:33:43 +02:00
|
|
|
*(u_int *)&poly1->r0 = uVar3;
|
|
|
|
*(u_int *)&poly1->r2 = uVar3;
|
|
|
|
*(u_int *)&poly1->r1 = uVar3 + 0x202020;
|
|
|
|
*(u_int *)&poly1->r3 = uVar3 + 0x303030;
|
2020-07-07 13:21:00 +02:00
|
|
|
|
|
|
|
setPolyGT4(poly1);
|
|
|
|
addPrim(current->ot + (z >> 3), poly1);
|
|
|
|
current->primptr += sizeof(POLY_GT4);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-07 13:21:00 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
poly = (POLY_FT3 *)current->primptr;
|
|
|
|
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
gte_stsz(&z);
|
|
|
|
|
|
|
|
if (z > 223)
|
|
|
|
{
|
2020-08-10 17:08:57 +02:00
|
|
|
*(ushort*)&poly->u0 = *(ushort*)&debris_texture.coords.u0;
|
|
|
|
*(ushort*)&poly->u1 = *(ushort*)&debris_texture.coords.u1;
|
|
|
|
*(ushort*)&poly->u2 = *(ushort*)&debris_texture.coords.u2;
|
|
|
|
|
|
|
|
poly->r0 = debris->rgb.r;
|
|
|
|
poly->g0 = debris->rgb.g;
|
|
|
|
poly->b0 = debris->rgb.b;
|
|
|
|
|
|
|
|
poly->tpage = debris_texture.tpageid;
|
|
|
|
poly->clut = debris_texture.clutid;
|
|
|
|
|
|
|
|
setPolyFT3(poly);
|
2020-07-07 13:21:00 +02:00
|
|
|
addPrim(current->ot + (z >> 3), poly);
|
|
|
|
current->primptr += sizeof(POLY_FT3);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 09:26:57 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
debris->life = 1;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
// [D] [T]
|
|
|
|
void DisplaySmoke(SMOKE* smoke)
|
|
|
|
{
|
|
|
|
int Z;
|
|
|
|
int tmode;
|
|
|
|
POLY_FT4* poly;
|
|
|
|
VECTOR v;
|
|
|
|
SVECTOR smokemesh[4];
|
|
|
|
int smoke_z_offset;
|
|
|
|
|
|
|
|
smoke_z_offset = 0;
|
|
|
|
|
|
|
|
v.vx = smoke->position.vx - camera_position.vx;
|
|
|
|
v.vy = smoke->position.vy - camera_position.vy;
|
|
|
|
v.vz = smoke->position.vz - camera_position.vz;
|
|
|
|
|
2021-02-23 09:04:05 +01:00
|
|
|
if (ABS(v.vx) > 20480 || ABS(v.vz) > 20480)
|
2020-12-08 20:20:53 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
Apply_Inv_CameraMatrix(&v);
|
|
|
|
|
|
|
|
gte_SetTransVector(&v);
|
|
|
|
gte_SetRotMatrix(&identity);
|
|
|
|
|
|
|
|
smokemesh[0].vx = -smoke->start_w;
|
|
|
|
smokemesh[0].vy = -smoke->start_w;
|
|
|
|
smokemesh[0].vz = 0;
|
|
|
|
|
|
|
|
smokemesh[1].vx = smoke->start_w;
|
|
|
|
smokemesh[1].vy = -smoke->start_w;
|
|
|
|
smokemesh[1].vz = 0;
|
|
|
|
|
|
|
|
smokemesh[2].vx = -smoke->start_w;
|
|
|
|
smokemesh[2].vy = smoke->start_w;
|
|
|
|
smokemesh[2].vz = 0;
|
|
|
|
|
|
|
|
smokemesh[3].vx = smoke->start_w;
|
|
|
|
smokemesh[3].vy = smoke->start_w;
|
|
|
|
smokemesh[3].vz = 0;
|
|
|
|
|
|
|
|
poly = (POLY_FT4*)current->primptr;
|
|
|
|
|
|
|
|
gte_ldv3(&smokemesh[0], &smokemesh[1], &smokemesh[2]);
|
|
|
|
gte_rtpt();
|
|
|
|
|
|
|
|
tmode = 0x20;
|
|
|
|
|
|
|
|
if (smoke->flags & 0x4000)
|
|
|
|
{
|
|
|
|
poly->r0 = smoke->transparency;
|
|
|
|
poly->g0 = smoke->transparency;
|
|
|
|
poly->b0 = smoke->transparency;
|
|
|
|
}
|
|
|
|
else if (smoke->flags & 0x2000)
|
|
|
|
{
|
|
|
|
if (gNight)
|
|
|
|
{
|
|
|
|
poly->r0 = smoke->transparency / 2;
|
|
|
|
poly->g0 = smoke->transparency / 2;
|
|
|
|
poly->b0 = smoke->transparency / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
poly->r0 = smoke->transparency >> 2;
|
|
|
|
poly->g0 = smoke->transparency >> 2;
|
|
|
|
poly->b0 = smoke->transparency >> 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmode = 0x40;
|
|
|
|
smoke_z_offset = 17;
|
|
|
|
}
|
|
|
|
else if (smoke->flags & 0x1000)
|
|
|
|
{
|
|
|
|
if ((smoke->transparency >> 3) + 50 & 0xff < 60)
|
|
|
|
poly->g0 = (smoke->transparency >> 3);
|
|
|
|
else
|
|
|
|
poly->g0 = smoke->transparency >> 2;
|
|
|
|
|
|
|
|
smoke_z_offset = 18;
|
|
|
|
|
|
|
|
poly->r0 = smoke->transparency;
|
|
|
|
poly->b0 = smoke->transparency >> 3;
|
|
|
|
}
|
|
|
|
else if (smoke->flags & 0x20)
|
|
|
|
{
|
|
|
|
poly->r0 = smoke->transparency >> 1;
|
|
|
|
poly->g0 = smoke->transparency;
|
|
|
|
poly->b0 = smoke->transparency + 10;
|
|
|
|
|
|
|
|
tmode = 0x40;
|
|
|
|
}
|
|
|
|
else if (smoke->flags & 0x40)
|
|
|
|
{
|
|
|
|
if (gNight == 0)
|
|
|
|
{
|
|
|
|
poly->r0 = smoke->transparency >> 2;
|
|
|
|
poly->g0 = smoke->transparency >> 2;
|
|
|
|
poly->b0 = smoke->transparency >> 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
poly->r0 = smoke->transparency >> 3;
|
|
|
|
poly->g0 = smoke->transparency >> 3;
|
|
|
|
poly->b0 = smoke->transparency + 10 >> 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gNight == 0)
|
|
|
|
{
|
|
|
|
poly->r0 = smoke->transparency;
|
|
|
|
poly->g0 = smoke->transparency;
|
|
|
|
poly->b0 = smoke->transparency + 10;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
poly->r0 = smoke->transparency / 2;
|
|
|
|
poly->g0 = smoke->transparency / 2;
|
|
|
|
poly->b0 = smoke->transparency + 10 >> 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
smoke_z_offset = 25;
|
|
|
|
}
|
|
|
|
|
|
|
|
gte_stsxy3(&poly->x0, &poly->x1, &poly->x2);
|
|
|
|
|
|
|
|
gte_stsz(&Z);
|
|
|
|
|
|
|
|
gte_ldv0(&smokemesh[3]);
|
|
|
|
gte_rtps();
|
|
|
|
|
|
|
|
poly->u0 = smoke_texture.coords.u0;
|
|
|
|
poly->v0 = smoke_texture.coords.v0;
|
|
|
|
poly->u1 = smoke_texture.coords.u1;
|
|
|
|
poly->v1 = smoke_texture.coords.v1;
|
|
|
|
poly->u2 = smoke_texture.coords.u2;
|
|
|
|
poly->v2 = smoke_texture.coords.v2 - 4; // [A] ???
|
|
|
|
poly->u3 = smoke_texture.coords.u3;
|
|
|
|
poly->v3 = smoke_texture.coords.v3 - 4; // [A] ???
|
|
|
|
|
|
|
|
poly->tpage = smoke_texture.tpageid | tmode;
|
|
|
|
poly->clut = smoke_texture.clutid;
|
|
|
|
|
|
|
|
setPolyFT4(poly);
|
|
|
|
setSemiTrans(poly, 1);
|
|
|
|
|
|
|
|
if (Z >> 3 > 0)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
smoke_z_offset = (Z >> 3) - smoke_z_offset;
|
|
|
|
|
|
|
|
if (smoke_z_offset < 9)
|
|
|
|
smoke_z_offset = 9;
|
|
|
|
|
|
|
|
gte_stsxy(&poly->x3);
|
|
|
|
addPrim(current->ot + smoke_z_offset, poly);
|
|
|
|
|
|
|
|
// reduce size?
|
|
|
|
if ((poly->x1 - poly->x0) / 2 > 100)
|
|
|
|
{
|
|
|
|
x = (poly->x0 + poly->x3) / 2;
|
|
|
|
y = (poly->y0 + poly->y3) / 2;
|
|
|
|
|
|
|
|
// FIXME: * 0x10000 is needed because clipping issue
|
|
|
|
poly->x0 = (y - 50) << 0x10;
|
|
|
|
poly->y0 = x - 50;
|
|
|
|
|
|
|
|
poly->x1 = (y - 50) << 0x10;
|
|
|
|
poly->y1 = x + 50;
|
|
|
|
|
|
|
|
poly->x2 = (y + 50) << 0x10;
|
|
|
|
poly->y2 = x - 50;
|
|
|
|
|
|
|
|
poly->x3 = (y + 50) << 0x10;
|
|
|
|
poly->y3 = x + 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
current->primptr += sizeof(POLY_FT4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-05 22:00:23 +02:00
|
|
|
int NoRainIndoors = 0;
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void HandleDebris(void)
|
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
int Height;
|
2020-07-05 20:33:14 +02:00
|
|
|
SMOKE *sm;
|
|
|
|
DEBRIS *db;
|
|
|
|
LEAF *lf;
|
2020-11-06 23:34:41 +01:00
|
|
|
int i;
|
2020-07-05 20:33:14 +02:00
|
|
|
VECTOR Drift;
|
2020-11-06 23:34:41 +01:00
|
|
|
|
2020-07-05 20:33:14 +02:00
|
|
|
GetSmokeDrift(&Drift);
|
2020-07-07 15:29:37 +02:00
|
|
|
|
2020-09-19 08:26:50 +02:00
|
|
|
MoveHubcap();
|
2020-07-07 15:29:37 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
SetRotMatrix(&inv_camera_matrix);
|
2020-07-05 20:33:14 +02:00
|
|
|
|
|
|
|
gte_SetTransVector(&dummy);
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
db = debris;
|
|
|
|
i = next_debris;
|
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
while (i > 0)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
if (db->flags & 0x2)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
DisplayDebris(db, 0);
|
|
|
|
|
|
|
|
if (pauseflag == 0)
|
|
|
|
{
|
|
|
|
if (--db->life == 0 || db->position.vy > 0)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
db->flags = 0;
|
|
|
|
ReleaseDebris(db->num);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
else
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
db->position.vx += db->direction.vx;
|
|
|
|
db->position.vy += db->direction.vy;
|
|
|
|
db->position.vz += db->direction.vz;
|
|
|
|
db->pos += db->step;
|
|
|
|
|
|
|
|
if (db->type == 3)
|
|
|
|
db->direction.vy += 1;
|
|
|
|
else
|
|
|
|
db->direction.vy += 6;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
}
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
db++;
|
|
|
|
i--;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-07-05 20:33:14 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
lf = leaf;
|
|
|
|
i = next_leaf;
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
// Move leaves
|
2021-03-01 21:10:38 +01:00
|
|
|
while (i > 0)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
if (lf->flags & 0x2)
|
2020-11-06 23:34:41 +01:00
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
DisplayDebris((DEBRIS *)lf, lf->type);
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
if (pauseflag == 0)
|
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
if (lf->life == 1)
|
2020-11-06 23:34:41 +01:00
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
lf->flags = 0;
|
|
|
|
ReleaseLeaf(lf->num);
|
2020-11-07 10:54:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
int sn1, sn2, cs1, cs2;
|
|
|
|
|
|
|
|
GetSmokeDrift(&Drift);
|
|
|
|
|
|
|
|
Height = -(lf->position.pad + 20);
|
|
|
|
|
|
|
|
// first we move debris
|
|
|
|
// SwirlLeaves basically changed direction vector
|
|
|
|
// in order to lift leaf from ground fast
|
|
|
|
if (lf->position.vy < Height)
|
|
|
|
{
|
|
|
|
lf->position.vx += lf->direction.vx + Drift.vx;
|
|
|
|
lf->position.vy += lf->direction.vy + Drift.vy;
|
|
|
|
lf->position.vz += lf->direction.vz + Drift.vz;
|
|
|
|
|
|
|
|
lf->pos += lf->step;
|
|
|
|
lf->pos &= 0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lf->position.vy = Height;
|
|
|
|
}
|
|
|
|
|
|
|
|
lf->sin_index1 += lf->sin_addition1;
|
|
|
|
lf->sin_index2 += lf->sin_addition2;
|
|
|
|
lf->sin_index1 &= 0xfff;
|
|
|
|
lf->sin_index2 &= 0xfff;
|
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
sn1 = RSIN(lf->sin_index1);
|
|
|
|
sn2 = RSIN(lf->sin_index2);
|
2021-03-01 21:10:38 +01:00
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
cs1 = RCOS(lf->sin_index1);
|
|
|
|
cs2 = RCOS(lf->sin_index2);
|
2021-03-01 21:10:38 +01:00
|
|
|
|
|
|
|
// then we compute completely new direction
|
|
|
|
lf->direction.vy = ((sn1 + sn2) >> 0xb) + 4;
|
|
|
|
lf->direction.vx = ((sn1 + sn2) * 5 >> 0xb);
|
|
|
|
lf->direction.vz = ((cs1 + cs2) * 5 >> 0xb);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
}
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
lf++;
|
2021-03-01 21:10:38 +01:00
|
|
|
i--;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-07-05 20:33:14 +02:00
|
|
|
|
2020-11-14 22:36:17 +01:00
|
|
|
for (i = 0; i < MAX_SMOKE; i++)
|
|
|
|
{
|
|
|
|
sm = &smoke[i];
|
2020-07-05 20:33:14 +02:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
if (sm->flags & 0x2)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
if (sm->flags & 0x8)
|
|
|
|
{
|
|
|
|
DisplaySpark(sm); // yup, smoke particles are sparks too
|
|
|
|
}
|
|
|
|
else if (sm->flags & 0x4)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
if (sm->flags & 0x8000)
|
2020-11-07 10:54:15 +01:00
|
|
|
DisplayWater(sm); // Really obsolete, water was only a thing in Driver 1
|
2021-03-01 21:10:38 +01:00
|
|
|
else
|
2020-11-06 23:34:41 +01:00
|
|
|
DisplaySmoke(sm);
|
2021-03-01 21:10:38 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
if (sm->flags & 0x2 && pauseflag == 0)
|
|
|
|
{
|
|
|
|
if (sm->flags & 0x8000)
|
|
|
|
{
|
|
|
|
// OBSOLETE DRIVER 1 CODE
|
|
|
|
/*
|
|
|
|
ROUTE_DATA routeData;
|
|
|
|
ROADS_GetRouteData(sm->position.vx - sm->start_w, sm->position.vz - sm->start_w, &routeData);
|
|
|
|
ROADS_GetRouteData(sm->position.vx + sm->start_w, sm->position.vz + sm->start_w, &routeData);
|
|
|
|
|
|
|
|
if (sm->start_w < 800 && (modelpointers[routeData.type]->shape_flags & MODEL_FLAG_ALLEY))
|
|
|
|
sm->start_w += sm->step;
|
|
|
|
else*/
|
|
|
|
sm->start_w -= sm->step;
|
|
|
|
}
|
|
|
|
else if (sm->flags & 0x8)
|
|
|
|
{
|
|
|
|
sm->position.vx += sm->drift_change.vx;
|
|
|
|
sm->position.vy += sm->drift_change.vy;
|
|
|
|
sm->position.vz += sm->drift_change.vz;
|
|
|
|
sm->drift_change.vy += 6;
|
|
|
|
|
|
|
|
if (sm->drift.vx == 0)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
sm->final_tail_pos.vx += sm->drift_change.vx;
|
|
|
|
sm->final_tail_pos.vy += sm->drift_change.vy - 12;
|
|
|
|
sm->final_tail_pos.vz += sm->drift_change.vz;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sm->drift.vx -= 1;
|
|
|
|
}
|
2020-07-05 20:33:14 +02:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
if (sm->position.vy > 0)
|
|
|
|
{
|
|
|
|
sm->flags = 0;
|
|
|
|
ReleaseSmoke(sm->num);
|
|
|
|
continue;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2021-03-01 21:10:38 +01:00
|
|
|
else
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
if (sm->start_w < 800)
|
|
|
|
sm->start_w += sm->step;
|
2020-07-05 20:33:14 +02:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
sm->position.vx += sm->drift.vx;
|
|
|
|
sm->position.vy += sm->drift.vy;
|
|
|
|
sm->position.vz += sm->drift.vz;
|
|
|
|
|
|
|
|
if (sm->halflife < sm->life)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2021-03-01 21:10:38 +01:00
|
|
|
sm->drift.vx -= sm->drift_change.vx;
|
|
|
|
sm->drift.vy -= sm->drift_change.vy;
|
|
|
|
sm->drift.vz -= sm->drift_change.vz;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2021-03-01 21:10:38 +01:00
|
|
|
|
|
|
|
if (sm->flags & 0x900C)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
sm->transparency -= sm->t_step;
|
|
|
|
|
|
|
|
if (sm->transparency < 1)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
|
|
|
sm->transparency = 0;
|
|
|
|
sm->life = 1;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-06 23:34:41 +01:00
|
|
|
|
2021-03-01 21:10:38 +01:00
|
|
|
if (--sm->life == 0)
|
2020-07-05 20:33:14 +02:00
|
|
|
{
|
|
|
|
sm->flags = 0;
|
2020-07-05 22:21:33 +02:00
|
|
|
ReleaseSmoke(sm->num);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-14 22:36:17 +01:00
|
|
|
}
|
2020-07-05 20:33:14 +02:00
|
|
|
|
|
|
|
if (pauseflag == 0)
|
2020-11-06 23:34:41 +01:00
|
|
|
{
|
|
|
|
main_cop_light_pos++;
|
|
|
|
main_cop_light_pos &= 7;
|
2020-07-05 20:33:14 +02:00
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
variable_weather = 1;
|
2020-07-05 20:33:14 +02:00
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
if (variable_weather != 0)
|
|
|
|
{
|
|
|
|
static int weather_level = 0;
|
|
|
|
|
|
|
|
weather_level = RSIN(CameraCnt) + RSIN(CameraCnt / 4);
|
|
|
|
|
|
|
|
if (weather_level < 1)
|
|
|
|
gRainCount = -weather_level >> 8;
|
|
|
|
else
|
|
|
|
gRainCount = weather_level >> 8;
|
2020-07-05 20:33:14 +02:00
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
if (gRainCount > MAX_RAIN_DROPS)
|
|
|
|
gRainCount = MAX_RAIN_DROPS;
|
|
|
|
}
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-04-04 06:49:28 +02:00
|
|
|
void add_haze(int top_col, int bot_col, short ot_pos)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-04-29 14:53:02 +02:00
|
|
|
TILE *polys;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (top_col > 9 && FastForward == 0)
|
2020-04-29 14:53:02 +02:00
|
|
|
{
|
|
|
|
polys = (TILE *)current->primptr;
|
|
|
|
|
|
|
|
setTile(polys);
|
|
|
|
|
|
|
|
polys->r0 = top_col;
|
|
|
|
polys->g0 = top_col;
|
|
|
|
polys->b0 = top_col;
|
|
|
|
|
|
|
|
setSemiTrans(polys, 1);
|
2020-09-03 09:17:39 +02:00
|
|
|
#ifdef PSX
|
2020-04-29 14:53:02 +02:00
|
|
|
polys->x0 = 0;
|
2020-09-03 09:17:39 +02:00
|
|
|
polys->w = 320;
|
|
|
|
#else
|
|
|
|
polys->x0 = -500;
|
|
|
|
polys->w = 1200;
|
|
|
|
#endif
|
2020-04-29 14:53:02 +02:00
|
|
|
polys->y0 = 0;
|
|
|
|
polys->h = 256;
|
|
|
|
addPrim(current->ot + ot_pos, polys);
|
|
|
|
|
|
|
|
current->primptr += sizeof(TILE);
|
|
|
|
|
|
|
|
POLY_FT3* null = (POLY_FT3*)current->primptr;
|
|
|
|
setPolyFT3(null);
|
|
|
|
|
|
|
|
null->x0 = -1;
|
|
|
|
null->y0 = -1;
|
|
|
|
null->x1 = -1;
|
|
|
|
null->y1 = -1;
|
|
|
|
null->x2 = -1;
|
|
|
|
null->y2 = -1;
|
|
|
|
null->tpage = 0x20;
|
|
|
|
addPrim(current->ot + ot_pos, null);
|
|
|
|
|
|
|
|
current->primptr += sizeof(POLY_FT3);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void SetupRain(void)
|
|
|
|
{
|
2020-04-04 06:49:28 +02:00
|
|
|
gNextRainDrop = 0;
|
2020-05-27 14:24:08 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
do {
|
2020-05-27 14:24:08 +02:00
|
|
|
|
|
|
|
gRainAlloc[gNextRainDrop] = gNextRainDrop;
|
|
|
|
gRain[gNextRainDrop].oldposition.pad = gNextRainDrop;
|
|
|
|
|
|
|
|
gNextRainDrop++;
|
2020-10-17 09:26:57 +02:00
|
|
|
} while (gNextRainDrop < MAX_RAIN_DROPS);
|
2020-05-27 14:24:08 +02:00
|
|
|
|
2020-04-04 06:49:28 +02:00
|
|
|
gNextRainDrop = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int AllocateRainDrop(void)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
if (gNextRainDrop < MAX_RAIN_DROPS)
|
|
|
|
return gRainAlloc[gNextRainDrop++];
|
2020-05-27 14:24:08 +02:00
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [D] [T]
|
|
|
|
void ReleaseRainDrop(int RainIndex)
|
|
|
|
{
|
|
|
|
gNextRainDrop--;
|
|
|
|
gRainAlloc[gNextRainDrop] = RainIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [D] [T]
|
|
|
|
void DisplaySplashes(void)
|
|
|
|
{
|
|
|
|
static u_int rand;
|
|
|
|
|
|
|
|
int d1;
|
|
|
|
int d2;
|
|
|
|
VECTOR CamGnd;
|
|
|
|
VECTOR Gnd1;
|
|
|
|
VECTOR Gnd2;
|
|
|
|
VECTOR Position;
|
|
|
|
CVECTOR col = { 25, 25, 25 };
|
|
|
|
int ang;
|
|
|
|
int SplashNo, SplashFrac;
|
|
|
|
|
|
|
|
if (pauseflag != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (gRainCount >> 2 > 30)
|
|
|
|
SplashNo = 30;
|
|
|
|
else
|
|
|
|
SplashNo = (gRainCount >> 2);
|
|
|
|
|
|
|
|
SplashFrac = FIXEDH(SplashNo * FrAng * 3);
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&identity); // [A] norot
|
|
|
|
|
|
|
|
CamGnd.vx = camera_position.vx;
|
|
|
|
CamGnd.vz = camera_position.vz;
|
|
|
|
CamGnd.vy = -camera_position.vy - MapHeight(&CamGnd);
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
ang = FrAng - camera_angle.vy;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
Gnd1.vx = RSIN(ang) + camera_position.vx;
|
|
|
|
Gnd1.vz = RCOS(ang) + camera_position.vz;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
Gnd1.vx = Gnd1.vx - CamGnd.vx;
|
|
|
|
Gnd1.vy = -camera_position.vy - MapHeight(&Gnd1) - CamGnd.vy;
|
|
|
|
Gnd1.vz = Gnd1.vz - CamGnd.vz;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2021-06-20 17:13:54 +02:00
|
|
|
ang = -FrAng - camera_angle.vy;
|
|
|
|
|
|
|
|
Gnd2.vx = RSIN(ang) + camera_position.vx;
|
|
|
|
Gnd2.vz = RCOS(ang) + camera_position.vz;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
Gnd2.vx = Gnd2.vx - CamGnd.vx;
|
|
|
|
Gnd2.vy = (-camera_position.vy - MapHeight(&Gnd2)) - CamGnd.vy;
|
|
|
|
Gnd2.vz = Gnd2.vz - CamGnd.vz;
|
|
|
|
|
|
|
|
while (--SplashFrac >= 0)
|
|
|
|
{
|
|
|
|
d2 = rand * 0x19660d + 0x3c6ef35f;
|
|
|
|
d1 = d2 >> 4 & 0xfff;
|
|
|
|
rand = d2 * 0x19660d + 0x3c6ef35f;
|
|
|
|
d2 = rand >> 0xe & 0xfff;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
Position.vx = FIXEDH(Gnd1.vx * d1 + Gnd2.vx * d2);
|
|
|
|
Position.vy = FIXEDH(Gnd1.vy * d1 + Gnd2.vy * d2) + CamGnd.vy;
|
|
|
|
Position.vz = FIXEDH(Gnd1.vz * d1 + Gnd2.vz * d2);
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
ShowLight(&Position, &col, 12, &drop_texture);
|
|
|
|
}
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
#define RAIN_DROP_SPEED 30 // [A] was 20
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DrawRainDrops(void)
|
|
|
|
{
|
2020-07-05 22:00:23 +02:00
|
|
|
int z;
|
2020-10-17 09:26:57 +02:00
|
|
|
int Count;
|
2020-07-05 22:00:23 +02:00
|
|
|
POLY_GT3 *poly;
|
|
|
|
RAIN_TYPE *RainPtr;
|
|
|
|
int col;
|
2020-10-17 09:26:57 +02:00
|
|
|
int bright;
|
2020-07-05 22:00:23 +02:00
|
|
|
SVECTOR v;
|
|
|
|
VECTOR drift;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-07-05 22:00:23 +02:00
|
|
|
if (gNextRainDrop == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GetSmokeDrift(&drift);
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
bright = 70;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (bright < 50)
|
|
|
|
bright = 50;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
|
|
|
if (gNight != 0)
|
2020-10-17 09:26:57 +02:00
|
|
|
bright -= -15;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
col = bright >> 1 | (bright >> 1) << 8;
|
|
|
|
col |= col | col << 0x10;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-07-05 22:21:33 +02:00
|
|
|
DisplaySplashes();
|
2020-07-05 22:00:23 +02:00
|
|
|
|
|
|
|
gte_SetRotMatrix(&inv_camera_matrix);
|
|
|
|
gte_SetTransVector(&dummy);
|
|
|
|
|
|
|
|
RainPtr = gRain;
|
2020-10-17 09:26:57 +02:00
|
|
|
Count = gNextRainDrop-1;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
poly = (POLY_GT3 *)current->primptr;
|
|
|
|
|
|
|
|
while (Count > 0)
|
2020-07-05 22:00:23 +02:00
|
|
|
{
|
|
|
|
v.vx = RainPtr->position.vx - camera_position.vx;
|
|
|
|
v.vy = RainPtr->position.vy - camera_position.vy;
|
|
|
|
v.vz = RainPtr->position.vz - camera_position.vz;
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
if (pauseflag)
|
|
|
|
{
|
|
|
|
// [A] old position imitation
|
|
|
|
// works effectively when player not moving
|
|
|
|
gte_ldv0(&v);
|
|
|
|
gte_rtps();
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
gte_stsxy(&poly->x0);
|
|
|
|
|
|
|
|
v.vy += RAIN_DROP_SPEED;
|
|
|
|
v.vx -= drift.vx * 2;
|
|
|
|
v.vz -= drift.vz * 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RainPtr->position.vy += RAIN_DROP_SPEED;
|
|
|
|
RainPtr->position.vx -= drift.vx * 2;
|
|
|
|
RainPtr->position.vz -= drift.vz * 2;
|
|
|
|
|
2021-04-04 21:33:43 +02:00
|
|
|
*(u_int *)&poly->x0 = *(u_int *)&RainPtr->oldposition;
|
2020-11-07 10:54:15 +01:00
|
|
|
}
|
2020-07-05 22:00:23 +02:00
|
|
|
|
|
|
|
gte_ldv0(&v);
|
|
|
|
gte_rtps();
|
|
|
|
|
2021-04-04 21:33:43 +02:00
|
|
|
*(u_int *)&poly->r2 = col;
|
|
|
|
*(u_int *)&poly->r1 = col;
|
|
|
|
*(u_int *)&poly->r0 = 0;
|
2020-11-07 10:54:15 +01:00
|
|
|
|
2020-07-05 22:00:23 +02:00
|
|
|
setPolyGT3(poly);
|
|
|
|
setSemiTrans(poly, 1);
|
2020-11-07 10:54:15 +01:00
|
|
|
|
2020-07-05 22:00:23 +02:00
|
|
|
gte_stsxy(&poly->x2);
|
2020-11-07 10:54:15 +01:00
|
|
|
|
2020-07-05 22:00:23 +02:00
|
|
|
gte_stsz(&z);
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
if (z - 151U < 2000 &&
|
|
|
|
poly->x2 > -101 && poly->x2 < 421 &&
|
|
|
|
poly->y2 > -51 && poly->y2 < 257)
|
2020-07-05 22:00:23 +02:00
|
|
|
{
|
2021-04-04 21:33:43 +02:00
|
|
|
if (*(u_int *)&RainPtr->oldposition != 0)
|
2020-11-07 10:54:15 +01:00
|
|
|
{
|
2020-07-05 22:00:23 +02:00
|
|
|
poly->x1 = poly->x2 - ((z >> 10) - 1);
|
|
|
|
poly->x2 = poly->x2 + ((z >> 10) - 1);
|
|
|
|
poly->y1 = poly->y2;
|
|
|
|
|
2021-04-04 21:33:43 +02:00
|
|
|
*(u_int *)&RainPtr->oldposition = *(u_int *)&poly->x2;
|
2020-11-07 10:54:15 +01:00
|
|
|
|
2020-07-05 22:00:23 +02:00
|
|
|
poly->clut = light_texture.clutid;
|
|
|
|
poly->tpage = light_texture.tpageid | 0x20;
|
|
|
|
|
|
|
|
*(ushort *)&poly->u0 = *(ushort *)&light_texture.coords.u0;
|
|
|
|
*(ushort *)&poly->u1 = *(ushort *)&light_texture.coords.u1;
|
|
|
|
*(ushort *)&poly->u2 = *(ushort *)&light_texture.coords.u2;
|
|
|
|
|
2020-11-07 10:54:15 +01:00
|
|
|
addPrim(current->ot + (z >> 1), poly);
|
|
|
|
poly++;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
else
|
2021-04-04 21:33:43 +02:00
|
|
|
*(u_int *)&RainPtr->oldposition = *(u_int *)&poly->x2;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-07-05 22:00:23 +02:00
|
|
|
else
|
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
if(pauseflag == 0)
|
|
|
|
ReleaseRainDrop(RainPtr->oldposition.pad);
|
2020-07-05 22:00:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RainPtr++;
|
2020-10-17 09:26:57 +02:00
|
|
|
Count--;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
current->primptr = (char*)poly;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void AddRainDrops(void)
|
|
|
|
{
|
2020-12-08 17:45:14 +01:00
|
|
|
static u_int rand;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
int first;
|
2020-04-04 06:49:28 +02:00
|
|
|
int RainIndex;
|
2020-11-06 23:34:41 +01:00
|
|
|
int tmp;
|
|
|
|
int i;
|
2020-07-05 22:00:23 +02:00
|
|
|
SVECTOR v;
|
|
|
|
ROUTE_DATA routeData;
|
2020-11-06 23:34:41 +01:00
|
|
|
int count;
|
|
|
|
RAIN_TYPE* rt;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
count = gRainCount;
|
|
|
|
first = 1;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-07-05 22:21:33 +02:00
|
|
|
if (pauseflag != 0 || NoRainIndoors != 0)
|
2020-07-05 22:00:23 +02:00
|
|
|
return;
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
wetness += count / 6;
|
|
|
|
|
2020-07-05 22:00:23 +02:00
|
|
|
if (wetness > 7000)
|
|
|
|
wetness = 7000;
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&camera_matrix);
|
|
|
|
gte_SetTransVector(&camera_position);
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
i = 0;
|
|
|
|
while (i < count)
|
2020-07-05 22:00:23 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
i++;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
|
|
|
RainIndex = AllocateRainDrop();
|
|
|
|
|
|
|
|
if (RainIndex < 0)
|
|
|
|
return;
|
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
tmp = rand * 0x19660d + 0x3c6ef35f;
|
|
|
|
v.vz = (tmp >> 0x14 & 0x1ffU) + 400;
|
|
|
|
|
|
|
|
tmp = tmp * 0x19660d + 0x3c6ef35f;
|
|
|
|
v.vy = -((tmp >> 0x14) & 0x1ff);
|
|
|
|
|
|
|
|
rand = tmp * 0x19660d + 0x3c6ef35f;
|
|
|
|
v.vx = ((rand >> 0x14) & 0x1ff) - 256;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
if (v.vz > 512)
|
2020-07-05 22:00:23 +02:00
|
|
|
{
|
2020-11-06 23:34:41 +01:00
|
|
|
int depth;
|
|
|
|
depth = (v.vz >> 8) + 1;
|
|
|
|
|
|
|
|
v.vx *= depth;
|
|
|
|
v.vy *= depth;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-07-05 22:00:23 +02:00
|
|
|
|
|
|
|
gte_ldv0(&v);
|
2020-09-03 07:31:49 +02:00
|
|
|
gte_rtv0tr();
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
rt = &gRain[RainIndex];
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
rt->oldposition.vx = 0;
|
|
|
|
rt->oldposition.vy = 0;
|
|
|
|
rt->oldposition.vz = 0;
|
|
|
|
rt->oldposition.pad = RainIndex;
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-12-28 11:07:24 +01:00
|
|
|
gte_stlvnl(&rt->position);
|
2020-11-06 23:34:41 +01:00
|
|
|
|
2020-12-11 11:52:27 +01:00
|
|
|
// OBSOLETE DRIVER 1 CODE
|
|
|
|
/*
|
2020-12-11 11:20:48 +01:00
|
|
|
if(first)
|
|
|
|
{
|
|
|
|
ROADS_GetRouteData(rt->position.vx, rt->position.vz, &routeData);
|
|
|
|
|
2021-05-09 20:56:18 +02:00
|
|
|
if (modelpointers[routeData.type]->flags2 & MODEL_FLAG_INDOORS)
|
2020-12-11 11:20:48 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-12-11 11:52:27 +01:00
|
|
|
*/
|
2020-07-05 22:00:23 +02:00
|
|
|
|
2020-11-06 23:34:41 +01:00
|
|
|
first = 0;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 14:53:02 +02:00
|
|
|
int lightning = 0;
|
|
|
|
int LightningTimer = 10;
|
|
|
|
int ThunderTimer = 0;
|
|
|
|
static int ThunderDistance = 0;
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DoLightning(void)
|
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
if (pauseflag != 0)
|
|
|
|
return;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (LightningTimer < -10)
|
|
|
|
LightningTimer = rand() & 0xff;
|
|
|
|
else
|
|
|
|
LightningTimer--;
|
2020-04-29 14:53:02 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (LightningTimer < 0 && (rand() & 1) == 0)
|
|
|
|
{
|
|
|
|
RequestThunder();
|
2020-04-29 14:53:02 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if ((rand() & 1) == 0)
|
|
|
|
{
|
|
|
|
NightAmbient = NightAmbient << 1;
|
2020-04-29 14:53:02 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (NightAmbient > 128)
|
|
|
|
NightAmbient = 128;
|
2020-04-29 14:53:02 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
lightning = 2;
|
|
|
|
return;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-04-29 14:53:02 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
add_haze(50, 0, 4222);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-10-17 09:26:57 +02:00
|
|
|
|
|
|
|
lightning = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void InitThunder(void)
|
|
|
|
{
|
2020-04-04 06:49:28 +02:00
|
|
|
ThunderTimer = -1;
|
2020-04-29 14:53:02 +02:00
|
|
|
ThunderDistance = rand() % 5000;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void RequestThunder(void)
|
|
|
|
{
|
2020-04-04 06:49:28 +02:00
|
|
|
ThunderTimer = ThunderDistance >> 8;
|
2020-04-29 14:53:02 +02:00
|
|
|
|
|
|
|
if (ThunderTimer < 1)
|
2020-04-04 06:49:28 +02:00
|
|
|
ThunderTimer = 1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DoThunder(void)
|
|
|
|
{
|
2020-05-27 14:24:08 +02:00
|
|
|
if (pauseflag)
|
|
|
|
return;
|
2020-04-29 14:53:02 +02:00
|
|
|
|
2020-05-27 14:24:08 +02:00
|
|
|
ThunderDistance = (ThunderDistance + 40) - rand() % 80;
|
2020-04-29 14:53:02 +02:00
|
|
|
|
2020-05-27 14:24:08 +02:00
|
|
|
if (ThunderDistance < 250)
|
|
|
|
ThunderDistance = 250;
|
2020-04-29 14:53:02 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (ThunderDistance > 5000)
|
2020-05-27 14:24:08 +02:00
|
|
|
ThunderDistance = 5000;
|
2020-04-29 14:53:02 +02:00
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
if (ThunderTimer > -1)
|
2020-05-27 14:24:08 +02:00
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
ThunderTimer--;
|
|
|
|
|
|
|
|
if(ThunderTimer == 0)
|
2021-04-07 19:27:01 +02:00
|
|
|
StartSound(-1, SOUND_BANK_SFX, 8, -ThunderDistance, (rand() % 2048) + 3072);
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DoWeather(int weather)
|
|
|
|
{
|
2020-11-07 10:54:15 +01:00
|
|
|
if (weather != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(pauseflag == 0)
|
2020-05-27 14:24:08 +02:00
|
|
|
{
|
2020-10-17 09:26:57 +02:00
|
|
|
if (gEffectsTimer < 41)
|
2020-05-27 14:24:08 +02:00
|
|
|
{
|
|
|
|
if ((FrameCnt & 7U) == 0)
|
|
|
|
gEffectsTimer++;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
2020-05-27 14:24:08 +02:00
|
|
|
else
|
|
|
|
{
|
2020-04-04 06:49:28 +02:00
|
|
|
AddRainDrops();
|
2020-05-27 14:24:08 +02:00
|
|
|
|
|
|
|
if ((FrameCnt & 7U) == 0)
|
2020-10-17 09:26:57 +02:00
|
|
|
gRainCount++;
|
2020-05-27 14:24:08 +02:00
|
|
|
|
|
|
|
if (gRainCount > 35)
|
|
|
|
gRainCount = 35;
|
2020-04-04 06:49:28 +02:00
|
|
|
}
|
|
|
|
}
|
2020-11-07 10:54:15 +01:00
|
|
|
|
|
|
|
DrawRainDrops();
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-17 09:26:57 +02:00
|
|
|
// [D] [T]
|
2020-10-31 01:11:58 +01:00
|
|
|
int GetDebrisColour(CAR_DATA *cp)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-27 14:24:08 +02:00
|
|
|
int car_model;
|
2020-04-04 06:49:28 +02:00
|
|
|
|
2020-05-27 14:24:08 +02:00
|
|
|
car_model = MissionHeader->residentModels[cp->ap.model];
|
|
|
|
|
|
|
|
if (car_model == 0)
|
2020-04-04 06:49:28 +02:00
|
|
|
return 1;
|
2020-05-27 14:24:08 +02:00
|
|
|
|
|
|
|
if(car_model < 8)
|
|
|
|
return (car_model-1) * 6 + cp->ap.palette + 7;
|
|
|
|
|
|
|
|
return car_model - 6;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|