diff --git a/src_rebuild/Game/C/debris.c b/src_rebuild/Game/C/debris.c index 0cb43153..bb4efb47 100644 --- a/src_rebuild/Game/C/debris.c +++ b/src_rebuild/Game/C/debris.c @@ -24,6 +24,98 @@ #include "ASM/rndrasm.h" +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; +}; + TEXTURE_DETAILS digit_texture; TRI_POINT debris_rot1[32]; // offset 0xC0A60 diff --git a/src_rebuild/Game/C/debris.h b/src_rebuild/Game/C/debris.h index fd765d75..9d4f6231 100644 --- a/src_rebuild/Game/C/debris.h +++ b/src_rebuild/Game/C/debris.h @@ -1,6 +1,15 @@ #ifndef DEBRIS_H #define DEBRIS_H +struct SMASHABLE_OBJECT +{ + int modelIdx; + char* name; + int sound; + int volume; + int pitch; +}; + #define SMOKE_BLACK 1 #define SMOKE_WHITE 2 #define SMOKE_BROWN 3 @@ -40,6 +49,8 @@ extern int main_cop_light_pos; extern int groundDebrisIndex; extern CELL_OBJECT ground_debris[16]; +extern SMASHABLE_OBJECT smashable[]; + extern void InitDebrisNames(); // 0x000337AC extern void InitDebris(); // 0x00033B9C extern void InitThunder(); // 0x0003A0BC diff --git a/src_rebuild/Game/C/drivinggames.c b/src_rebuild/Game/C/drivinggames.c index 945e6b98..30137dd2 100644 --- a/src_rebuild/Game/C/drivinggames.c +++ b/src_rebuild/Game/C/drivinggames.c @@ -19,6 +19,21 @@ #include "ASM/rndrasm.h" +struct TRAILBLAZER_DATA +{ + int x, z; + short y, rot; +}; + +struct SMASHED_CONE +{ + char cone; + u_char active : 7; + u_char side : 1; + short rot_speed; + VECTOR velocity; +}; + MODEL* gTrailblazerConeModel; SMASHED_CONE smashed_cones[MAX_SMASHED_CONES]; diff --git a/src_rebuild/Game/C/objanim.c b/src_rebuild/Game/C/objanim.c index 915bdf18..6af18340 100644 --- a/src_rebuild/Game/C/objanim.c +++ b/src_rebuild/Game/C/objanim.c @@ -15,6 +15,24 @@ #include "system.h" #include "pause.h" +struct ANIMATED_OBJECT +{ + int internal_id; + int model_num; + char* name; + char LitPoly; +}; + +struct GARAGE_DOOR +{ + CELL_OBJECT* cop; + VECTOR_NOPAD old_pos; + VECTOR_NOPAD pos; + short rotation; + char yang; +}; + + CYCLE_OBJECT Lev0[2] = { { "REDRVR", 0, 0, 6, 10, 2, 11, 15, 2 }, diff --git a/src_rebuild/Game/C/objanim.h b/src_rebuild/Game/C/objanim.h index 84df1bd6..1a4d48d6 100644 --- a/src_rebuild/Game/C/objanim.h +++ b/src_rebuild/Game/C/objanim.h @@ -1,8 +1,6 @@ #ifndef OBJANIM_H #define OBJANIM_H -extern SMASHABLE_OBJECT smashable[]; - extern void InitCyclingPals(); // 0x000149B4 extern void ColourCycle(); // 0x00013980 diff --git a/src_rebuild/Game/dr2types.h b/src_rebuild/Game/dr2types.h index 599afd4a..bcc1fe87 100644 --- a/src_rebuild/Game/dr2types.h +++ b/src_rebuild/Game/dr2types.h @@ -4,7 +4,9 @@ // Platform types #include -// Driver 2 system types +//--------------------------------------------------------------------------------------- +// simple types + typedef short SHORTVECTOR4[4]; typedef long LONGVECTOR3[3]; @@ -12,9 +14,6 @@ typedef long LONGVECTOR4[4]; typedef long LONGQUATERNION[4]; -//--------------------------------------------------------------------------------------- -// TODO: math types - struct VECTOR2 { int vx; @@ -79,133 +78,30 @@ struct XYPAIR struct SXYPAIR { - short x; - short y; + short x, y; }; struct XZPAIR { - int x; - int z; + int x, z; }; struct XYWH { - short x; - short y; - short w; - short h; -}; - -//--------------------------------------------------------------------------------------- -// TODO: image types - -struct TIMHDR -{ - int magic; - int flags; -}; - -struct TIMIMAGEHDR -{ - int len; - short origin_x; - short origin_y; - short width; - short height; -}; - -//--------------------------------------------------------------------------------------- -// TODO: DR2TYPES - -struct BOX -{ - float xmin; - float ymin; - float zmin; - float xmax; - float ymax; - float zmax; -}; - -struct BSPHERE -{ - VECTOR bounding_sphere_mid; - float bounding_sphere; -}; - -struct RGB // almost same as CVECTOR -{ - u_char r; - u_char g; - u_char b; - u_char pad; -}; - -struct PADRECORD -{ - u_char pad; - u_char analogue; - u_char run; + short x, y, w, h; }; +// might be old frustum data struct ARC_ENTRY { short offset; short length; }; -//--------------------------------------------------------------------------------------- -// TODO: TEXTURES.H - -struct UV_INFO -{ - u_char u; - u_char v; -}; - -struct UV -{ - u_char u0; - u_char v0; - u_char u1; - u_char v1; - u_char u2; - u_char v2; - u_char u3; - u_char v3; -}; - -struct TEXTURE_DETAILS -{ - UV coords; - u_short tpageid; - u_short clutid; - char texture_number; - char texture_page; -}; - -struct TP -{ - u_int flags; - u_int offset; -}; - -struct TEXINF -{ - u_short id; - u_short nameoffset; - u_char x; - u_char y; - u_char width; - u_char height; -}; - -struct TPAN -{ - u_char texture_page; - u_char texture_number; -}; +#include "engine/cell.h" +#include "engine/mdl.h" +#include "engine/tim.h" +#include "engine/tset.h" //--------------------------------------------------------------------------------------- // TODO: ROADS.H @@ -301,337 +197,6 @@ struct ROAD_MAP_LUMP_DATA int unitZMid; }; -//--------------------------------------------------------------------------------------- -// TODO: DR2LEVEL.H - -struct CELL_OBJECT -{ - VECTOR_NOPAD pos; - u_char pad; - u_char yang; - u_short type; -}; - -struct CELL_DATA -{ - u_short num; -}; - -struct PACKED_CELL_OBJECT -{ - USVECTOR_NOPAD pos; - u_short value; -}; - -struct CELL_ITERATOR -{ - CELL_DATA* pcd; - PACKED_CELL_OBJECT* ppco; - XZPAIR nearCell; - int use_computed; -}; - -struct OUT_CELL_FILE_HEADER -{ - int cells_across; - int cells_down; - int cell_size; - int num_regions; - int region_size; - int num_cell_objects; - int num_cell_data; - int ambient_light_level; - VECTOR_NOPAD light_source; -}; - -//--------------------------------------------------------------------------------------- -// TODO: MDL.H - -enum ModelShapeFlags -{ - SHAPE_FLAG_LITPOLY = 0x1, - SHAPE_FLAG_BSPDATA = 0x2, - SHAPE_FLAG_TRANS = 0x8, - SHAPE_FLAG_NOCOLLIDE = 0x10, - SHAPE_FLAG_WATER = 0x80, // model is water - SHAPE_FLAG_AMBIENT2 = 0x100, // Ambient sound 2 associated - maybe used in D1 - SHAPE_FLAG_AMBIENT1 = 0x200, // Ambient sound 1 associated - maybe used in D1 - SHAPE_FLAG_TILE = 0x400, // treat as road - SHAPE_FLAG_SHADOW = 0x800, // D1 leftover flag - SHAPE_FLAG_ALPHA = 0x1000, // alpha tested object - SHAPE_FLAG_ROAD = 0x2000, // section of road - SHAPE_FLAG_SPRITE = 0x4000, -}; - -enum ModelFlags2 -{ - MODEL_FLAG_ANIMOBJ = 0x1, // CUSTOM FLAG! - - MODEL_FLAG_MEDIAN = 0x20, // Hmmmm... - MODEL_FLAG_JUNC = 0x40, - MODEL_FLAG_ALLEY = 0x80, // alley tile - MODEL_FLAG_INDOORS = 0x100, - MODEL_FLAG_CHAIR = 0x200, - MODEL_FLAG_BARRIER = 0x400, - MODEL_FLAG_SMASHABLE = 0x800, - MODEL_FLAG_LAMP = 0x1000, - MODEL_FLAG_TREE = 0x2000, - MODEL_FLAG_GRASS = 0x4000, - MODEL_FLAG_PATH = 0x8000, -}; - -#define COLLISION_BOX 0 -#define COLLISION_CYLINDER 1 -#define COLLISION_CONE 2 -#define COLLISION_SPHERE 3 -#define COLLISION_INDOORS 4 - -struct COLLISION_PACKET -{ - short type; - short xpos, ypos, zpos; - short flags; - short yang; - short empty; - short xsize, ysize, zsize; -}; - -struct POLYFT4 -{ - u_char id; - u_char texture_set; - u_char texture_id; - u_char spare; - u_char v0, v1, v2, v3; - UV_INFO uv0, uv1, uv2, uv3; - RGB color; -}; - -struct POLYGT4 -{ - u_char id; - u_char texture_set; - u_char texture_id; - u_char spare; - u_char v0, v1, v2, v3; - u_char n0, n1, n2, n3; - UV_INFO uv0, uv1, uv2, uv3; - RGB color; -}; - -struct PL_POLYFT4 -{ - u_char id; - u_char texture_set; - u_char texture_id; - u_char th; - u_char v0, v1, v2, v3; - UV_INFO uv0, uv1, uv2, uv3; -}; - - -struct POLYFT3 -{ - u_char id; - u_char texture_set; - u_char texture_id; - u_char spare; - u_char v0, v1, v2, pad; - UV_INFO uv0, uv1, uv2, pad2; - RGB color; -}; - -struct POLYGT3 -{ - u_char id; - u_char texture_set; - u_char texture_id; - u_char spare; - u_char v0, v1, v2, pad; - u_char n0, n1, n2, pad2; - UV_INFO uv0, uv1, uv2, pad3; - RGB color; -}; - -struct MODEL -{ - u_short shape_flags; - u_short flags2; - short instance_number; - u_char tri_verts; - unsigned char zBias; - short bounding_sphere; - u_short num_point_normals; - u_short num_vertices; - u_short num_polys; - int vertices; - int poly_block; - int normals; - int point_normals; - int collision_block; - - SVECTOR* pVertex(int i) const - { - return (SVECTOR *)(((u_char *)this) + vertices) + i; - } - - SVECTOR* pNormal(int i) const - { - return (SVECTOR *)(((u_char *)this) + point_normals) + i; - } - - COLLISION_PACKET* pCollisionPacket(int i) const - { - return (COLLISION_PACKET *)(((u_char *)this) + collision_block) + i; - } - - char* pPolyAt(int ofs) const - { - return (char *)(((u_char *)this) + poly_block + ofs); - } -}; - -//--------------------------------------------------------------------------------------- -// TODO: DEBRIS.H - -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 ANIMATED_OBJECT -{ - int internal_id; - int model_num; - char* name; - char LitPoly; -}; - -struct SMASHABLE_OBJECT -{ - int modelIdx; - char* name; - int sound; - int volume; - int pitch; -}; - -struct GARAGE_DOOR -{ - CELL_OBJECT* cop; - VECTOR_NOPAD old_pos; - VECTOR_NOPAD pos; - short rotation; - char yang; -}; - -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; -}; - -//--------------------------------------------------------------------------------------- -// TODO: DRIVINGGAMES.H - -struct TRAILBLAZER_DATA -{ - int x; - int z; - short y; - short rot; -}; - -struct SMASHED_CONE -{ - char cone; - u_char active : 7; - u_char side : 1; - short rot_speed; - VECTOR velocity; -}; - //--------------------------------------------------------------------------------------- // TODO: DR2COSMETICS.H @@ -1786,6 +1351,13 @@ struct REPLAY_STREAM_HEADER int Length; }; +struct PADRECORD +{ + u_char pad; + u_char analogue; + u_char run; +}; + struct REPLAY_STREAM { STREAM_SOURCE SourceType; diff --git a/src_rebuild/Game/engine/cell.h b/src_rebuild/Game/engine/cell.h new file mode 100644 index 00000000..07d7f59d --- /dev/null +++ b/src_rebuild/Game/engine/cell.h @@ -0,0 +1,45 @@ +#ifndef ENGINE_CELL_H +#define ENGINE_CELL_H + +struct CELL_OBJECT +{ + VECTOR_NOPAD pos; + u_char pad; + u_char yang; + u_short type; +}; + +struct CELL_DATA +{ + u_short num; +}; + +struct PACKED_CELL_OBJECT +{ + USVECTOR_NOPAD pos; + u_short value; +}; + +struct CELL_ITERATOR +{ + CELL_DATA* pcd; + PACKED_CELL_OBJECT* ppco; + XZPAIR nearCell; + int use_computed; +}; + +struct OUT_CELL_FILE_HEADER +{ + int cells_across; + int cells_down; + int cell_size; + int num_regions; + int region_size; + int num_cell_objects; + int num_cell_data; + int ambient_light_level; + VECTOR_NOPAD light_source; +}; + + +#endif // ENGINE_CELL_H \ No newline at end of file diff --git a/src_rebuild/Game/engine/mdl.h b/src_rebuild/Game/engine/mdl.h new file mode 100644 index 00000000..fa3ce1a0 --- /dev/null +++ b/src_rebuild/Game/engine/mdl.h @@ -0,0 +1,174 @@ +#ifndef MDL_H +#define MDL_H + + +enum ModelShapeFlags +{ + SHAPE_FLAG_LITPOLY = 0x1, + SHAPE_FLAG_BSPDATA = 0x2, + SHAPE_FLAG_TRANS = 0x8, + SHAPE_FLAG_NOCOLLIDE = 0x10, + SHAPE_FLAG_WATER = 0x80, // model is water + SHAPE_FLAG_AMBIENT2 = 0x100, // Ambient sound 2 associated - maybe used in D1 + SHAPE_FLAG_AMBIENT1 = 0x200, // Ambient sound 1 associated - maybe used in D1 + SHAPE_FLAG_TILE = 0x400, // treat as road + SHAPE_FLAG_SHADOW = 0x800, // D1 leftover flag + SHAPE_FLAG_ALPHA = 0x1000, // alpha tested object + SHAPE_FLAG_ROAD = 0x2000, // section of road + SHAPE_FLAG_SPRITE = 0x4000, +}; + +enum ModelFlags2 +{ + MODEL_FLAG_ANIMOBJ = 0x1, // CUSTOM FLAG! + + MODEL_FLAG_MEDIAN = 0x20, // Hmmmm... + MODEL_FLAG_JUNC = 0x40, + MODEL_FLAG_ALLEY = 0x80, // alley tile + MODEL_FLAG_INDOORS = 0x100, + MODEL_FLAG_CHAIR = 0x200, + MODEL_FLAG_BARRIER = 0x400, + MODEL_FLAG_SMASHABLE = 0x800, + MODEL_FLAG_LAMP = 0x1000, + MODEL_FLAG_TREE = 0x2000, + MODEL_FLAG_GRASS = 0x4000, + MODEL_FLAG_PATH = 0x8000, +}; + +#define COLLISION_BOX 0 +#define COLLISION_CYLINDER 1 +#define COLLISION_CONE 2 +#define COLLISION_SPHERE 3 +#define COLLISION_INDOORS 4 + +struct BOX +{ + float xmin, ymin, zmin, xmax, ymax, zmax; +}; + +struct BSPHERE +{ + VECTOR bounding_sphere_mid; + float bounding_sphere; +}; + +struct COLLISION_PACKET +{ + short type; + short xpos, ypos, zpos; + short flags; + short yang; + short empty; + short xsize, ysize, zsize; +}; + +struct RGB // almost same as CVECTOR +{ + u_char r; + u_char g; + u_char b; + u_char pad; +}; + +struct UV_INFO +{ + u_char u, v; +}; + +struct POLYFT4 +{ + u_char id; + u_char texture_set; + u_char texture_id; + u_char spare; + u_char v0, v1, v2, v3; + UV_INFO uv0, uv1, uv2, uv3; + RGB color; +}; + +struct POLYGT4 +{ + u_char id; + u_char texture_set; + u_char texture_id; + u_char spare; + u_char v0, v1, v2, v3; + u_char n0, n1, n2, n3; + UV_INFO uv0, uv1, uv2, uv3; + RGB color; +}; + +struct PL_POLYFT4 +{ + u_char id; + u_char texture_set; + u_char texture_id; + u_char th; + u_char v0, v1, v2, v3; + UV_INFO uv0, uv1, uv2, uv3; +}; + + +struct POLYFT3 +{ + u_char id; + u_char texture_set; + u_char texture_id; + u_char spare; + u_char v0, v1, v2, pad; + UV_INFO uv0, uv1, uv2, pad2; + RGB color; +}; + +struct POLYGT3 +{ + u_char id; + u_char texture_set; + u_char texture_id; + u_char spare; + u_char v0, v1, v2, pad; + u_char n0, n1, n2, pad2; + UV_INFO uv0, uv1, uv2, pad3; + RGB color; +}; + +struct MODEL +{ + u_short shape_flags; + u_short flags2; + short instance_number; + u_char tri_verts; + unsigned char zBias; + short bounding_sphere; + u_short num_point_normals; + u_short num_vertices; + u_short num_polys; + int vertices; + int poly_block; + int normals; + int point_normals; + int collision_block; + + SVECTOR* pVertex(int i) const + { + return (SVECTOR *)(((u_char *)this) + vertices) + i; + } + + SVECTOR* pNormal(int i) const + { + return (SVECTOR *)(((u_char *)this) + point_normals) + i; + } + + COLLISION_PACKET* pCollisionPacket(int i) const + { + return (COLLISION_PACKET *)(((u_char *)this) + collision_block) + i; + } + + char* pPolyAt(int ofs) const + { + return (char *)(((u_char *)this) + poly_block + ofs); + } +}; + + +#endif // MDL_H \ No newline at end of file diff --git a/src_rebuild/Game/engine/tim.h b/src_rebuild/Game/engine/tim.h new file mode 100644 index 00000000..dbdb0b0b --- /dev/null +++ b/src_rebuild/Game/engine/tim.h @@ -0,0 +1,19 @@ +#ifndef TIM_H +#define TIM_H + +struct TIMHDR +{ + int magic; + int flags; +}; + +struct TIMIMAGEHDR +{ + int len; + short origin_x; + short origin_y; + short width; + short height; +}; + +#endif // TIM_H \ No newline at end of file diff --git a/src_rebuild/Game/engine/tset.h b/src_rebuild/Game/engine/tset.h new file mode 100644 index 00000000..fd7677e9 --- /dev/null +++ b/src_rebuild/Game/engine/tset.h @@ -0,0 +1,42 @@ +#ifndef TSET_H +#define TSET_H + +// Texture Set definitions + +struct UV +{ + u_char u0, v0; + u_char u1, v1; + u_char u2, v2; + u_char u3, v3; +}; + +struct TEXTURE_DETAILS +{ + UV coords; + u_short tpageid; + u_short clutid; + char texture_number; + char texture_page; +}; + +struct TP +{ + u_int flags; + u_int offset; +}; + +struct TEXINF +{ + u_short id; + u_short nameoffset; + u_char x, y, width, height; +}; + +struct TPAN +{ + u_char texture_page; + u_char texture_number; +}; + +#endif // TSET_H \ No newline at end of file