//*********************************************************** // // TANX2.0a by Stuart Macdonald // Codewarrior Version // header.h 1.0b // //*********************************************************** #include //#include "pad.h" #include "Joypad.h" #include "commondef.h" #include "addrs.h" #include "fsnap1_0.h" //*********************************************************** // defines //*********************************************************** #define ORDERING_TABLE_LENGTH (10) #define PACKETMAX (8192) #define PACKETMAX2 (PACKETMAX*24) #define MAX_NO_PACKETS (248000) #define SCREEN_WIDTH (512) #define SCREEN_HEIGHT (256) #define MAX_X (32) #define MAX_Z (32) #define MAX_WORLD_OBJECTS (121) #define SEPERATION (1200) #define SNAP_ADDRESS (0x800f0000) #define NO_OF_BOTS (2) #define MOVING (1) #define ROTATING (2) #define WAITING (0) #define VH_ADDR (0x80090000) #define VB_ADDR (0x80090C20) //#define SEQ_ADDR (0x80110000) #define MAIN_VOL (127) //#define SEQ_VOL (127) #define MAX_NO_OF_OBJECTS (120) #define MAX_NO_OF_SPRITES (21) #define MAX_NO_OF_LINES (1) #define MAX_NO_OF_BOXES (5) //#define MAX_NO_OF_POWERUPS (20) //*********************************************************** // object IDs //*********************************************************** #define EMPTY (0) #define TANK (1) #define TURRET (2) #define MISSILE (3) #define SHELL (4) #define EXPLOSION (5) #define AIRSHIP (6) #define FLAG (7) #define SHIELD (8) #define SMOKE (9) #define MINE (10) #define RAIL_RING (11) #define LASER_BOLT (12) #define BEAM (13) #define FLAME (14) #define MINIMAP (15) #define HEALTHBAR (16) #define TELEPORT (17) #define EMP_SHOCK (18) #define INVISIBILITY (19) #define STATIC1 (20) #define STATIC2 (21) #define SHOCK (22) #define LIGHTNING (23) #define LG_RING (24) #define SM_RING (25) #define TRAIL (26) #define SHRAPNEL (27) #define SCORES (28) #define SPEEDUP (29) #define KILLTXT (30) #define PERFECT (31) #define BILLBOARD (99) // Turret types #define CANNON (1) #define RAILGUN (2) #define LASER_CANNON (3) #define FLAMETHROWER (4) #define TAZER_CANNON (5) #define MISSILE_LAUNCHER (6) //Chassis types #define WHEELED (2) #define HOVERCRAFT (3) //*********************************************************** // Macros //*********************************************************** #define FINDRANGE(a, b, c, d) ( ((a-c)*(a-c))+((b-d)*(b-d)) ) #define LIMIT(a, b, c) ( ((a)<(b)) ? (b) : ((a)>(c) ? (c) : (a)) ) #define MAX(a, b) ( (a) = ((a) < (b)) ? (b) : (a) ) #define MIN(a, b) ( (a) = ((a) > (b)) ? (b) : (a) ) //*********************************************************** // sound stuff //*********************************************************** typedef struct { short vabid; short program; short tone; short note; //short fine; short vol_l; short vol_r; }voice_data, *voice_ptr; //*********************************************************** // structures //*********************************************************** typedef struct { GsSPRITE sprite; int id; int depth; int display; } SpriteStructType0; typedef struct { GsBOXF gsBoxHandler; int id; int depth; int display; } BoxStructType0; typedef struct { GsLINE gsLineHandler; int id; int depth; } LineStructType0; typedef struct { int id; int display; int depth; int size; SVECTOR rotation; GsDOBJ2 gsObjectHandler; GsCOORDINATE2 gsObjectCoord; unsigned long *lModelPointer; int tileposz; int tileposx; unsigned char collision; int dx; int dy; int dz; int sx; int sz; int armour; int maxarmour; int speed; int subtype; int lifespan; unsigned char alive; int allegance; int shotPower; int reloadTime; int frame; int startposx; int startposz; int restart; /* // active powerup ints int powerup[3];// counters int poweruptype[3];// type holders //stored powerup ints int poweruplist[3];// queue of powerups held int powerupcounter;// points to next available free space int powerupdelay;// provides delay between powerup keypresses */ int flag; int drop; int score; int dir; int damage; int damagedBy; } ObjectStructType0; typedef struct { // active powerup ints int powerup[3];// counters int poweruptype[3];// type holders //stored powerup ints int poweruplist[3];// queue of powerups held int powerupcounter;// points to next available free space int powerupdelay;// provides delay between powerup keypresses } PowerupHandlerType0; typedef struct { // A variable to track the total number of models in the world int nTotalModels; // We need one of each of the following two data structures for each // object in the world thus we have arrays of them SVECTOR rotation[MAX_WORLD_OBJECTS]; GsDOBJ2 gsObjectHandler[MAX_WORLD_OBJECTS]; GsCOORDINATE2 gsObjectCoord[MAX_WORLD_OBJECTS]; // We also need an array of pointers to tmds in memory unsigned long *lObjectPointer[MAX_WORLD_OBJECTS]; int drawflag[MAX_WORLD_OBJECTS]; } WorldStructType0; //*********************************************************** // Function prototypes //*********************************************************** // display.c void InitialiseGraphics (void); void AddModelToWorld (WorldStructType0 *theWorld, int nX, int nY, int nZ, unsigned long *lModelAddress); int LoadTexture (long addr); void InitialiseAllTextures (void); void InitialiseSprite (unsigned long timaddr, GsSPRITE *loadsprite, int px, int py); void InitialiseLight (GsF_LIGHT *flLight, int nLight, int nX, int nY, int nZ, int nRed, int nGreen, int nBlue); void InitialiseAllLights (void); void RenderWorld (void); void DrawObject (ObjectStructType0 *theObject, GsOT *othWorld, int depth); void DrawTanks (GsOT *othWorld, int display); void DrawAllObjects (GsOT *othWorld, int screen); void DrawWorld (WorldStructType0 *theWorld, GsOT *othWorld, int depth); void DrawBuildings (WorldStructType0 *theWorld, GsOT *othWorld, int depth); void DrawSprite (SpriteStructType0 *theSprite, GsOT *othWorld, int depth); void DrawAllSprites (GsOT *othWorld, int display); void DrawAllLines (GsOT *othWorld); void DrawAllBoxes (GsOT *othWorld, int display); void DrawLine (LineStructType0 *theLine, GsOT *othWorld, int depth); void DrawBox (BoxStructType0 *theBox, GsOT *othWorld, int depth); void InitialiseView (GsRVIEW2 *view, int nProjDist, int nRZ, int nVPX, int nVPY, int nVPZ, int nVRX, int nVRY, int nVRZ); void InitialiseTurretView (GsRVIEW2 *view, int n); void updateScores ( void ); void LoadNumber (SpriteStructType0 *theSprite,int num, int posx, int posy, int display, int depth, int id); void GreyScreen (BoxStructType0 *theBox, int display, int depth); void InitialiseIntroScreen ( void ); void SetupIntro ( int which ); void SetupOptions ( int which ); int ReadOptionsPad (int option, int max); // objects.c void UpdateAllObjects (void); void DropItemOnMap (int tilex, int tilez); int FindFreeObject (void); void InitialiseAllObjects (void); void InitialiseObject (ObjectStructType0 *theObject,int id, int display, int depth, int size, int speed, int armour, int maxarmour, int subtype, int lifespan, int allegance, int shotpower, int reloadtime); void FindTilePosition (ObjectStructType0 *theObject); int CreateObject (int type, int flag, int flag2); void SetupShot (int num, int flag, unsigned long *modeltype); void AddModelToObject (ObjectStructType0 *thePlayer, int nX, int nY, int nZ,unsigned long *lModelAddress); void ResetMatrix (short m[3][3]); void RotateModel (GsCOORDINATE2 *gsObjectCoord,SVECTOR *rotateVector , int nRX, int nRY, int nRZ ); void AdvanceModel (ObjectStructType0 *theObject, GsCOORDINATE2 *gsObjectCoord, SVECTOR *rotateVector,int speed); void SetShotDirection (GsCOORDINATE2 *gsObjectCoord, SVECTOR *rotateVector,int speed, int n); void RestartPlayer (ObjectStructType0 *thePlayer,ObjectStructType0 *thePlayersTurret); void FindFreeTilePos (ObjectStructType0 *theObject); void UpdatePlayer (ObjectStructType0 *thePlayer,ObjectStructType0 *thePlayersTurret); void CheckAwardText (SpriteStructType0 *theSprite); void FireBullet (int creator); void MakeSemiTrans (ObjectStructType0 *theObject); void TestObjectCollision (ObjectStructType0 *theObject); unsigned char CheckInRange (int Range,int TargetRange, int ObjectRange); unsigned char CheckBuildingCollision (ObjectStructType0 *theObject, char BuildingType, int Range, int ObjectRange); void SetTurretType (ObjectStructType0 *theObject,int type); void SetChassisType (ObjectStructType0 *theObject,int type); void SetHealthbar(BoxStructType0 *theBox, int length); void AddPowerup(ObjectStructType0 *theObject, int type); void UsePowerup(ObjectStructType0 *theObject); void UpdatePowerup(ObjectStructType0 *theObject); // world.c void InitialiseWorld (void); void InitialiseBldgs (void); void SetupScreenLuminance (void); void ResetLuminance (void); void IncreaseLight (int tx, int ty, int max); void MakeLightPool (int tx, int ty); void LoadLevel (int level); void SetMinimap (void); // main.c void ProcessUserInput (void); int main (void);