/* ----------------------------------------------- GTASC - GTA adaptation for TI Calculators ----------------------------------------------- Programmed by : Olivier SANGALA Version : 1.2 License : Free under GNU General Public License ( see "gpl.txt" ) Release Date : 05/01/2007 Platform : TI89/TI92+/V200 Website : http://olivier.sangala.free.fr Email : olivier_sangala@hotmail.com ---------- License ---------- Copyright (C) 2002-2007 Olivier SANGALA This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ //----------------------------------------------------------------------------- //-------------------------------------------------------------------------- /* Contains all definitions : macros enum types structure functions prototypes */ //-------------------------------------------------------------------------- // FAST SHIFT OPERATIONS //-------------------------------------------------------------------------- #define MUL2(V) ((V)<<1) #define MUL4(V) ((V)<<2) #define MUL8(V) ((V)<<3) #define MUL16(V) ((V)<<4) #define MUL32(V) ((V)<<5) #define MUL64(V) ((V)<<6) #define MUL128(V) ((V)<<7) #define MUL256(V) ((V)<<8) #define QUOT2(V) ((V)>>1) #define QUOT4(V) ((V)>>2) #define QUOT8(V) ((V)>>3) #define QUOT16(V) ((V)>>4) #define QUOT32(V) ((V)>>5) #define QUOT64(V) ((V)>>6) #define QUOT128(V) ((V)>>7) #define QUOT256(V) ((V)>>8) #define REM2(V) ((V)&1) #define REM4(V) ((V)&3) #define REM8(V) ((V)&7) #define REM16(V) ((V)&15) #define REM32(V) ((V)&31) #define REM64(V) ((V)&63) #define REM128(V) ((V)&127) #define REM256(V) ((V)&255) //-------------------------------------------------------------------------- #define MUL512(V) ((V)<<9) #define MUL1024(V) ((V)<<10) #define QUOT512(V) ((V)>>9) //-------------------------------------------------------------------------- // number of objects // WARNING : influences performance #define PED_COUNT (5) #define BULLET_COUNT (PED_COUNT) // one bullet for each ped #define VEH_COUNT (5) //-------------------------------------------------------------------------- #define GANG_COUNT (4) #define MISS_COUNT (10) // SPEED_LCD = lcd speed for motion // object with speed=(n*SPEED_LCD) will move n pixels each frame tick #define SPEED_LCD (128) //--------------------------------------------------------------------------- // PEDS #define PED_HEALTH_INIT (5) #define MAINPED_HEALTH_INIT (10) //-------------------------------------------------------------------------- // VEHS #define VEH_SKINS_COUNT (17) #define VEH_HEALTH (20) // minimum speed for veh to be damaged #define VEH_SPEED_DAMAGE (2*SPEED_LCD) // VEH SKINS INDEX #define VEH_SKIN_COP (3) #define VEH_SKIN_L (4) #define VEH_SKIN_S (8) #define VEH_SKIN_Y (9) #define VEH_SKIN_Z (16) // not used #define VEH_SKIN_K (13) #define VEH_SKIN_M (2) #define VEH_SKIN_R (11) //-------------------------------------------------------------------------- // TILE POSITIONS // garages #define GARAGE1_SPRAY 210,76 #define GARAGE1_CRUSHER 166,45 #define GARAGE1_VEHPARK 142,12 #define GARAGE2_SPRAY 39,153 #define GARAGE2_CRUSHER 47,143 #define GARAGE2_VEHPARK 92,244 #define GARAGE2_BOMB 231,233 #define GARAGE2_VEHPARK2 135,197 // phone boxes #define PHONEBOX1_N1 71,51 #define PHONEBOX1_N2 207,57 #define PHONEBOX2_N1 20,196 #define PHONEBOX2_N2 48,154 #define PHONEBOX2_N3 208,155 #define PHONEBOX2_N4 245,237 //-------------------------------------------------------------------------- // tiles types #define TILE_CROSSROADS (0x08) #define ISTILE_STREET(t) ((t)<=0x09) #define ISTILE_WATER(t) ((t)>=0x0A && (t)<=0x0B) #define ISTILE_SIDEWALK(t) ((t)>=0x10 && (t)<=0x19) #define ISTILE_PAVING(t) ((t)>=0x1A && (t)<=0x1D) #define ISTILE_GRASS(t) ((t)>=0x1E && (t)<=0x1F) #define ISTILE_BUILDING(t) ((t)>=0x20) //--------------------------------------------------------------------------- // objects tile moving capabilities #define ISTILEMOVE_VEH(t) (ISTILE_STREET(t) || ISTILE_SIDEWALK(t) || ISTILE_PAVING(t) || ISTILE_GRASS(t)) #define ISTILEMOVE_PED(t) (ISTILE_STREET(t) || ISTILE_SIDEWALK(t) || ISTILE_PAVING(t) || ISTILE_GRASS(t)) #define ISTILEMOVE_Bullet(t) (ISTILE_STREET(t) || ISTILE_SIDEWALK(t) || ISTILE_PAVING(t) || ISTILE_GRASS(t)) #define ISTILEMOVE_CC_PED(t) (ISTILE_SIDEWALK(t) || ISTILE_PAVING(t)) #define ISTILEMOVE_CC_VEH(t) (ISTILE_STREET(t)) #define ISTILEMOVE_OBSTACLE(t) (ISTILE_WATER(t) || ISTILE_BUILDING(t)) //--------------------------------------------------------------------------- // ped skin enum { PED_SKIN_CIV, PED_SKIN_COP, PED_SKIN_L, PED_SKIN_S, PED_SKIN_Y, PED_SKIN_Z, }; // Motion Type enum {MT_PED,MT_VEH}; // Behaviour enum { BH_Veh_None, BH_Veh_Computer, BH_Veh_HurtChase, BH_Ped_None, BH_Ped_Computer, BH_Ped_BustChase, BH_Ped_ShootStand, BH_Ped_ShootChase, }; // speed_way (veh/ped) enum { SPEED_FW, SPEED_BW, }; // target type enum { TT_PLACE, TT_VEH, }; // flip types enum { FLIP_PED, FLIP_VEH, }; //-------------------------------------------------------------------------- // DEFINES typedef unsigned char byte; typedef unsigned short word; //--------------------------------------------------------------------------- typedef struct { byte y; byte x; } TPoint8; typedef struct { int y; int x; } TPoint; // motion data for all moving objects typedef struct { // entry values TPoint Pos; int speed; int speed_way; int angle; int dx,dy; // angle slope value int speed2; // speed TickLCD int speed3; // speed TickLCD -> for axis X/Y int slope_counter; int speed_counter; } TMotionData; // tile collision structure typedef struct { TPoint P; int type; unsigned char*src8; // not used unsigned short*src16; // internal int xx,yy; byte tn[4]; } TTileCollData; //--------------------------------------------------------------------------- // OBJECTS typedef struct { int enable; // Motion TMotionData MD; TMotionData MD2; int turn_ease; int flag_stepback; int flag_runover; int flag_collideCC; int flag_bullet; // AI int CC_behaviour; int CC_flag_stopdelay; // flip int once_appeared; int invisible_counter; // features int health; int bullets; int dead_disappear_counter; // skin int skin; // TileData unsigned char *TileData; // Mission Flags int mission_used; } TPed; typedef struct { int enable; // Motion TMotionData MD; TMotionData MD2; int turn_ease; int flag_stepback; int flag_damage; int flag_collideCC; int flag_bullet; int flag_explode; // AI int CC_behaviour; int CC_flag_stopdelay; int CC_angle_turn; // flip int once_appeared; int invisible_counter; // skin int skin; // status int health; int blow_timer; // TileData unsigned short *TileData; unsigned short TileData2[16]; // Mission Flags int mission_used; } TVeh; typedef struct { int enable; // Motion TMotionData MD; int flag_hit; // Ped Shooter - for collision TPed*Shooter; } TBullet; //--------------------------------------------------------------------------- // mission status structure typedef struct { // steps int step; int step2; // target int target_enable; int target_type; TVeh * target_V; TPoint target_PP; // timer int timer_enable; int timer_value; int timer_visible; // flags int flag_begin; int flag_placestop_ped; int flag_placeover_ped; int flag_placestop_veh; int flag_placeover_veh; int flag_timer; int flag_vehinto; int flag_crushed; int flag_respray; int flag_vehblownup; int flag_pedkilled; // ped/veh used for mission TPed*P; TVeh*V; // objects relatives to flags TVeh*IntoVeh; TVeh*ResprayVeh; TVeh*CrushedVeh; TVeh*BlownUpVeh; TPed*KilledPed; } TMission; //--------------------------------------------------------------------------- typedef struct { // progress int progress_story; int progress_races; int progress_secrets; int cash; // stats int wasted_counter; int busted_counter; int playing_time; int fugitive_factor; int vehs_hijacked; int vehs_blown; int vehs_crushed; int vehs_resprayed; int peds_killed; int gates_open; int game_finished; // options int white_streets; int white_paving; } TSave; //--------------------------------------------------------------------------- typedef struct { // Save Data TSave Save; // OBJECTS TVeh Vehs[VEH_COUNT]; TPed Peds[PED_COUNT]; TBullet Bullets[BULLET_COUNT]; // MISSION DATA TMission Miss; // secrets int flag_secret; // races int flag_race; int race_cpindex; // check points index int race_timer; int race_timer_visible; // motion_type int motion_type; TPed * MainPed; TVeh * MainVeh; // null if not in veh TVeh * MainVeh2; // veh to be hijacked // MISC int exit_game; int TimeCounter; // flips // x -> 11 + 2 = 13 // y -> 8 + 2 = 10 TPoint8 FlipPosList[130]; int flag_shake; int bShakeCamera; // TileMap Size int TMSizeY; int TMSizeX; // debug int viewer_active; int viewer_x; int viewer_y; // external variable pointers unsigned short * VP_TileData; unsigned char * VP_TileMap1; unsigned char * VP_Ped; unsigned short * VP_Veh; // ff = fugitive factor // ff increase int ff_blownveh; int ff_killedped; } TGame; //--------------------------------------------------------------------------- // ***** flips ****** void Flip_Objects(void); void Flip_Try_Disable_Ped(TPed*P); void Flip_Try_Disable_Veh(TVeh*V); void Flip_Try_Disable_Bullet(TBullet*B); void Flip_Try_Enable_Ped(TPed*P); void Flip_Try_Enable_Veh(TVeh*V); int Flip_Test(byte tn, int type); int Flip_FindTile(TPoint8*FindTilePos, int type); //--------------------------------------------------------------------------- // ***** main ****** char* Var_GetPtr(char*str) ; char* Var_Create(char*str,int size); void NewGame(void); void MainPed_Init(void); void DrawRoof(byte y,byte x,byte tn00,byte tn01,byte tn10,byte tn11); void ShakeCamera(void); void KB_ProcessMisc(void); void KB_ProcessGame(void); void KeysForVeh(void); void KeysForPed(void); void ShowStats(void); void Menu_Options(void); void Menu_Pause(void); void ShowMsg(char*str); void Game_Save(void); void Game_Load(void); void SelectVehicle(void); void ShowGroups(void); char* CharGetData(char ch); int GetFastAngle16(TPoint Point1, TPoint Point2); int GetTurnAngleWay(int angle1, int angle2); byte GET_TN(byte x,byte y); byte* GET_PTR(byte x,byte y); void OnTimer(void); int Check_Wasted(void); int Check_Busted(void); //--------------------------------------------------------------------------- // ***** misscode ****** void Miss_GarageOut(void); void Miss_ShowBrief(char*str); void Miss_Lose(void); void Miss_SetPlace(byte y, byte x); void Miss_SetTimer(int value, int visible); void Miss_SetTargetVeh(TVeh*V); void Miss_RemoveMU(void); void Miss_Code(void); //-------------------------------------------------------------------------- // ***** motion ****** void Motion_Tick(void); void OBJ_ProcessFlags(void); void MD_TickLCD (TMotionData *MD); void MD_MoveOnePixel (TMotionData *MD); void MD_GetSPEED23(TMotionData *MD); void MD_OnNewAngle(TMotionData *MD); //--------------------------------------------------------------------------- // ***** peds ****** void Ped_Init(TPed*P); void Ped_CC(TPed*P); void Ped_CC_Computer(TPed*P); void Ped_OnNewAngle(TPed*P); void Ped_LoadTD(TPed*P) ; void Ped_Shoot(TPed*P); void Ped_Hurt(TPed*P); void Ped_Kill(TPed*P); int Ped_IsIntoVeh(TPed*P); //--------------------------------------------------------------------------- // ***** testcoll ****** void TC_TestALL(void); void TC_StepBack(void); int TC_Gates2(void); void TC_Ped_ALL(void); int TC_Ped_Flip(TPed*P); int TC_Ped_Edges2(TPed*P); int TC_Ped_Tiles2(TPed*P); int TC_Ped_VehOut(TPed*P); void TC_Veh_ALL(void); int TC_Veh_Flip(TVeh*V); int TC_Veh_Edges2(TVeh*V); int TC_Veh_Tiles2(TVeh*V); int TC_Veh_Veh2(TVeh*V1,TVeh*V2); int TC_Veh_Ped2(TVeh*V,TPed*P); void TC_Bullet_ALL(void); int TC_Bullet_Edges2(TBullet*B); int TC_Bullet_Tiles2(TBullet*B); int TC_Bullet_Veh2(TBullet*B,TVeh*V); int TC_Bullet_Ped2(TBullet*B,TPed*P); void TC_Secret(void); void TC_Target(void); int TC_Tiles(void); int TC_Tiles2(int num); int TestCollide16P(TPoint P1,TPoint P2,unsigned short*src0,unsigned short*src1); //-------------------------------------------------------------------------- // ***** vehs ****** void Veh_Init(TVeh*V); void Veh_CC(TVeh*V); void Veh_CC_Computer(TVeh*V); void Veh_OnNewAngle(TVeh*V); void Veh_LoadTD(TVeh*V); void Veh_GoInto(void); void Veh_GetOut(void); int VehWay_IsDeadEnd(byte x, byte y, int way); int VehInGarage(byte y, byte x); void Veh_Hurt(TVeh*V, int damage); void Veh_Blow(TVeh*V); //---------------------------------------------------------------------------