#define	SP_FLAT		1
#define	SP_SCALE		2
#define	SP_RICOCHET	4
#define	SP_DEF		8
#define	SP_ROTATE		16
#define	SP_EXPLOSION	32
#define	SP_FX		64
#define	SP_ITEM		128
#define	SP_WIND		256
#define	SP_EXPDEF		512

#define	SD_EXPLOSION	1

#define	SEMITRANS		1
#define	COLADD		2
#define	COLSUB		3
#define	WEIRD		4

#define	LEFT_HAND		0
#define	RIGHT_HAND	1
#define	LARA_HIPS		2
#define	LARA_TORSO	3
#define	LARA_HEAD		4

#define	ROCKET_YOFF	180
#define	ROCKET_ZOFF	80
#define	SHOTGUN_YOFF	228
#define	SHOTGUN_ZOFF	32
#define	M16_YOFF		340
#define	M16_ZOFF		96
#define	PISTOLS_YOFF	128
#define	PISTOLS_ZOFF	40
#define	MAGNUMS_YOFF	160
#define	MAGNUMS_ZOFF	56
#define	UZIS_YOFF		140
#define	UZIS_ZOFF		48

#define	MAX_SPARKS	192
#define	MAX_SPLASHES	4
#define	MAX_RIPPLES	16
#define	MAX_BATS		32

#define	SPL_ON			1
#define	SPL_TRANS			2
#define	SPL_RIPPLEINNER	4
#define	SPL_RIPPLEMIDDLE	8
#define	SPL_MORETRANS		16
#define	SPL_BLOOD			32

#define	B_ON				1

typedef struct
{
	long		x,y,z;

	short	Xvel;
	short	Yvel;
	short	Zvel;
	short	Gravity;		// Y vel.

	short	RotAng;
	short	Flags;	// See SP_... defs above.

	unsigned char	sWidth;
	unsigned char	dWidth;
	unsigned char	sHeight;
	unsigned char	dHeight;

	unsigned char	Friction; 	// X & Z vels - (vels -= vels>>Friction)	// Top nibble = Yvel friction.
	unsigned char	Width;
	unsigned char	Height;
	unsigned char	Scalar;

	unsigned char	Def;
	signed char	RotAdd;
	signed char	MaxYvel;
	unsigned char	On;		// Used ?

	unsigned char	sR;		//
	unsigned char	sG;  	// Start RGB.
	unsigned char	sB;  	//
	unsigned char	dR;		//

	unsigned char	dG;  	// End RGB.
	unsigned char	dB;  	//
	unsigned char	R;		//
	unsigned char	G;  	// Current RGB.

	unsigned char	B;  	//
	unsigned char	ColFadeSpeed;	// Speed at which to fade to endcol in frames.
	unsigned char	FadeToBlack;	// When to start fading to black (life left). (0 = never).
	unsigned char	sLife;

	unsigned char 	Life;	// Start life, current life.
	unsigned char	TransType;	// 0 = Semi, 1 = Col add, 2 = Colsub, 3 = weird!
	unsigned char	extras;
	signed char	Dynamic;	// Which dynamic-light-controller to use. -1 = no dynamic.

	unsigned char	FxObj;	// Attached to Fx or Object number.
	unsigned char	pad[3];

} SPARKS;

typedef struct
{
	unsigned char	On;
	unsigned char	Falloff;	// 0 - 31. (1/4 block per value).
	unsigned char 	R;
	unsigned char 	G;
	unsigned char 	B;
	unsigned char	Flags;
	unsigned char	Pad[2];
} SP_DYNAMIC;

typedef struct
{
	short	wx;	//
	short	wy;  // XYZ offsets from origin.
	short	wz;  //

	short	xv;	//
	short	yv;  // XYZ velocities (8 bit fraction).
	short	zv;  //

	short	oxv;  //
	short	ozv;  //

	unsigned char	friction; //	XZ friction (bit shift).
	unsigned char	gravity;  //   Y gravity.



} SPLASH_VERTS;

typedef struct
{
	long		x;
	long		y;
	long		z;
	char		flags; 	// bit 0 = on/off;
	unsigned	char		life;	// dictates transparency level.
	char		pad[2];
	SPLASH_VERTS	sv[48];

} SPLASH_STRUCT;

typedef struct
{
	long		x;
	long		y;
	long		z;
	char		flags; 	// bit 0 = on/off;
	unsigned	char		life;	// dictates transparency level.
	unsigned	char		size;	// << 2
	unsigned	char		init;

} RIPPLE_STRUCT;

typedef struct
{
	long		x;	//
	long		y;	// XYZ origin.
	long		z;	//
	short	InnerXZoff;
	short	InnerXZsize;
	short	InnerYsize;
	short	InnerXZvel;
	short 	InnerYvel;
	short	InnerGravity;
	short	InnerFriction;
	short	MiddleXZoff;
	short	MiddleXZsize;
	short	MiddleYsize;
	short	MiddleXZvel;
	short 	MiddleYvel;
	short	MiddleGravity;
	short	MiddleFriction;
	short	OuterXZoff;
	short	OuterXZsize;
	short	OuterXZvel;
	short	OuterFriction;

} SPLASH_SETUP;

typedef	struct
{
	long		x,y,z;
	short	angle;
	short	speed;
	unsigned	char	WingYoff;	// Make the wings flap;
	unsigned	char	flags;  	// bit 0 = on/off.
	unsigned	char	life;
	unsigned	char	pad;
} BAT_STRUCT;

extern	RIPPLE_STRUCT	ripples[];
extern	SPLASH_STRUCT	splashes[];
extern	SPLASH_SETUP	splash_setup;
extern	BAT_STRUCT	bats[];

extern	SP_DYNAMIC	spark_dynamics[32];
extern	SPARKS		spark[MAX_SPARKS];
extern	ushort 	sincos_tbl[];
extern	long		wibble;
extern long SmokeCountL, SmokeCountR, SmokeWeapon, SmokeWind;
extern long SplashCount;

#ifdef PSX_VERSION
void S_DrawSparks();
#endif

long	GetFreeSpark();
void UpdateSparks();
void TriggerRicochetSpark(GAME_VECTOR *pos,long angle,long size);
void TriggerFlareSparks(long x, long y, long z,long xv,long yv,long zv, long smoke);
void TriggerExplosionSparks(long x, long y, long z,long extra_trigs, long dyn);
void TriggerExplosionSmokeEnd(long x, long y, long z);
void TriggerExplosionSmoke(long x, long y, long z);
void TriggerFireSmoke(long x, long y, long z, long body_part, long type);
void TriggerFireFlame(long x, long y, long z, long body_part, long type);
void TriggerStaticFlame(long x, long y, long z, long size);
void TriggerAlertLight(long x, long y, long z, long r, long g, long b, long angle, short room_no);
void DetatchSpark(long num, long type);
void ControlGunShell(short fx_number);
void TriggerGunShell(short leftright, long type, long weapon);
void TriggerGunSmoke(long x, long y, long z, long xv, long yv, long zv, long initial, long weapon, long count);

void BatEmitterControl(short item_number);
void TriggerBats(long x, long y, long z, long angle);


void SetupSplash(SPLASH_SETUP *spl);
void UpdateSplashes();
void S_DrawSplashes();
void SetupRipple(long x, long y, long z, long size, long moretrans);
