home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / QF2.ZIP / DEFS.H < prev    next >
Text File  |  1995-04-10  |  8KB  |  266 lines

  1. /**********************************************************************\
  2. *                                                                      *
  3. *  DEFS.H: declarations, definitions, etc. for Quickfire               *
  4. *                                                                      *
  5. *  Copyright 1993, 1995 Diana Gruber. All Rights Reserved.             *
  6. *  Last modified: April 10, 1995                                       *
  7. *                                                                      *
  8. *  This source code is provided "as is" without any warranties, etc.   *
  9. *                                                                      *
  10. \**********************************************************************/
  11.  
  12. #include <fastgraf.h>
  13. #include <conio.h>
  14. #include <ctype.h>
  15. #include <string.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <dos.h>
  19. #include <io.h>
  20. #include <malloc.h>
  21.  
  22. /* variables are only declared in one file, are external to all
  23.    other source code files */
  24. #ifndef loadgame
  25.     #define DECLARE extern
  26. #else
  27.     #define DECLARE
  28. #endif
  29.  
  30. /* uncomment this line to make the program run in Mode X and
  31. real mode. Otherwise, the program requires Mode 13h and protected
  32. mode. */
  33.  
  34. //#define ModeX
  35.  
  36. #ifndef ModeX
  37. /********************  virtual buffers  *************************/
  38.  
  39. DECLARE char *virtbuff1;   // buffer for storage virtual buffer
  40. DECLARE int  workvb;       // handle for workspace virtual buffer
  41. #endif
  42.  
  43. /********************  map declarations *************************/
  44.  
  45. /* coordinates of the physical page wrt world space */
  46. DECLARE int tile_orgx;
  47. DECLARE int tile_orgy;
  48.  
  49. /* coordinates of the visible screen wrt the physical page */
  50. DECLARE int screen_orgx;
  51. DECLARE int screen_orgy;
  52. DECLARE int screen_xmax;
  53. DECLARE int screen_ymax;
  54.  
  55. DECLARE int world_x;
  56. DECLARE int world_y;
  57. DECLARE int world_maxx;
  58. DECLARE int world_maxy;
  59.  
  60. /* visual page Y offset and hidden page Y offset */
  61. DECLARE int vpo,vpb;
  62. DECLARE int hpo,hpb;
  63.  
  64. /* tile page offset */
  65. DECLARE int tpo;
  66.  
  67. DECLARE short ncols;
  68. DECLARE short nrows;
  69.  
  70. /* maximum number of rows & cols in world space */
  71. #define MAXROWS 60
  72. #define MAXCOLS 280
  73.  
  74. /* tile array for level */
  75. DECLARE unsigned char far backtile[MAXCOLS][MAXROWS];
  76. DECLARE char layout[2][22][15];
  77.  
  78. /********************  sprite declarations *************************/
  79.  
  80. DECLARE short nsprites;
  81. typedef struct sprt
  82. {
  83.     char *bitmap;
  84.     short width;
  85.     short height;
  86.    short xoffset;
  87.    short yoffset;
  88.  
  89. }  SPRITE;
  90.  
  91. DECLARE SPRITE *sprite[40];
  92.  
  93. /* forward declarations */
  94. DECLARE struct OBJstruct;
  95. typedef struct OBJstruct OBJ, near *OBJp;
  96.  
  97. /* pointer to object action function */
  98. typedef void near ACTION (OBJp objp);
  99. typedef ACTION *ACTIONp; 
  100.  
  101. /* data structure for objects */
  102. typedef struct OBJstruct 
  103. {
  104.   OBJp  next; 
  105.   OBJp  prev; 
  106.   short x;
  107.   short y;
  108.   short xspeed;
  109.   short max_xspeed;
  110.   short yspeed;
  111.   short direction;
  112.   short frame;
  113.   short tile_xmin;
  114.   short tile_xmax;
  115.   short tile_ymin;
  116.   short tile_ymax;
  117.  
  118.   SPRITE *image;
  119.   ACTIONp action; 
  120.   OBJp attached_sprite;
  121. };
  122.  
  123. #define MAXENEMIES 5
  124. DECLARE OBJp player;
  125. DECLARE OBJp top_node, bottom_node;
  126. DECLARE OBJp enemy[MAXENEMIES];
  127. DECLARE OBJp score;
  128.  
  129. DECLARE SPRITE *fighter[8];
  130. DECLARE SPRITE *explosion[11];
  131.  
  132. /*********************  key declarations *************************/
  133.  
  134. #define KB_CTRL  29
  135. #define KB_ESC    1
  136. #define KB_LEFT  75
  137. #define KB_RIGHT 77
  138. #define KB_UP    72
  139. #define KB_DOWN  80
  140.  
  141. #define LEFT   0
  142. #define RIGHT  1
  143. #define UP     2
  144. #define DOWN   3
  145.  
  146. #define OK     1
  147.  
  148. /********************  file handles *************************/
  149.  
  150. DECLARE FILE *tstream;
  151. DECLARE FILE *dstream;
  152.  
  153. /******************* miscellaneous defines ******************/
  154.  
  155. #define BETWEEN(x,a,b) ((x >= a) && (x <= b))
  156. #define MAX(x,y) ((x) > (y)) ? (x) : (y)
  157. #define MIN(x,y) ((x) < (y)) ? (x) : (y)
  158.  
  159. #define FALSE 0
  160. #define TRUE  1
  161.  
  162. /******************* miscellaneous variables ****************/
  163.  
  164. DECLARE char abort_string[50];
  165.  
  166. DECLARE short clockspeed;
  167. DECLARE short stall_time;
  168. DECLARE int   hidden;
  169. DECLARE int   visual;
  170. DECLARE short seed;
  171.  
  172. DECLARE int nbullets;
  173. DECLARE int nenemies;
  174. DECLARE int nenemy_bullets;
  175. DECLARE short random_number;
  176.  
  177. DECLARE int scrolled;
  178.  
  179. DECLARE int frame_count;
  180. DECLARE int framerate;
  181. DECLARE int frame_factor;
  182. DECLARE int bullet_count;
  183.  
  184. DECLARE long player_timer;
  185. DECLARE long player_time_target;
  186.  
  187. DECLARE int nhits;
  188. DECLARE int hit_value;
  189.  
  190. DECLARE int up,down,left,right,ctrl;
  191. DECLARE int autopilot;
  192.  
  193. DECLARE long player_score;
  194. DECLARE unsigned long frames;
  195.  
  196. #ifdef loadgame
  197.    unsigned char launch_palette[] = {
  198.     9, 0, 0, 12, 0, 0, 16, 0, 0, 19, 0, 0, 23, 0, 0, 27, 0, 0, 30, 0, 0,
  199.    34, 0, 0, 37, 0, 0, 41, 0, 0, 45, 0, 0, 48, 0, 0, 52, 0, 0, 55, 0, 0,
  200.    59, 0, 0, 63, 0, 0, 63, 2, 2, 63, 6, 6, 63, 9, 9, 63,13,13, 63,16,16,
  201.    63,20,20, 63,24,24, 63,27,27, 63,31,31, 63,34,34, 63,38,38, 63,41,41,
  202.    63,45,45, 63,48,48, 63,52,52, 63,56,56,  9, 0, 0, 12, 0, 0, 16, 0, 0,
  203.    19, 0, 0, 23, 0, 0, 27, 0, 0, 30, 0, 0, 34, 0, 0, 37, 0, 0, 41, 0, 0,
  204.    45, 0, 0, 48, 0, 0, 52, 0, 0, 55, 0, 0, 59, 0, 0, 63, 0, 0, 63, 2, 2,
  205.    63, 6, 6, 63, 9, 9, 63,13,13, 63,16,16, 63,20,20, 63,24,24, 63,27,27,
  206.    63,31,31, 63,34,34, 63,38,38, 63,41,41, 63,45,45, 63,48,48, 63,52,52,
  207.    63,56,56
  208.    };
  209. #else
  210.    extern unsigned char launch_palette[];
  211. #endif
  212.  
  213. /******************** function declarations *****************/
  214. /* qf.c */
  215. void  main();
  216. void  _near activate_level(void);
  217. void  _near adjust_layout_down(void);
  218. void  _near adjust_layout_right(void);
  219. void  _near adjust_layout_up(void);
  220. void  _near apply_sprite(struct OBJstruct _near *objp);
  221. void  _near bullet_go(struct OBJstruct _near *objp);
  222. void  _near do_explosion(struct OBJstruct _near *objp);
  223. void  _near do_player_explosion(struct OBJstruct _near *objp);
  224. void  _near enemy_bullet_go(struct OBJstruct _near *objp);
  225. void  _near enemy_go(struct OBJstruct _near *objp);
  226. void  _near kill_bullet(struct OBJstruct _near *objp);
  227. void  _near kill_enemy(struct OBJstruct _near *objp);
  228. void  _near kill_enemy_bullet(struct OBJstruct _near *objp);
  229. void  _near kill_object(struct OBJstruct _near *objp);
  230. void  _near kill_player_explosion(struct OBJstruct _near *objp);
  231. void  _near launch_sequence(void);
  232. void  _near new_score(struct OBJstruct _near *objp);
  233. void  _near page_copy(void);
  234. void  _near player_go(void);
  235. void  _near put_sprite(struct sprt *frame,short world_x,short world_y);
  236. void  put_tile(short i,short j);
  237. void  _near rebuild_hidden(void);
  238. void  _near put_score(struct OBJstruct _near *objp);
  239. int   scroll_right(short npixels);
  240. int   scroll_right_down(short scroll_y);
  241. int   scroll_right_up(short scroll_x,short scroll_y);
  242. void  _near start_bullet(void);
  243. void  _near start_enemy_bullet(struct OBJstruct _near *objp);
  244. void  _near start_enemy(void);
  245. void  _near start_explosion(struct OBJstruct _near *objp);
  246. void  _near start_player_explosion(struct OBJstruct _near *objp);
  247. void  _near swap(void);
  248. void  _near warp(short x,short y);
  249.  
  250. /* loadgame.c */
  251. void  clear_layout(void);
  252. void  exit_screen(void);
  253. void  fcopy_array(char _far *s,char *t,short nchar);
  254. void  getseed(void);
  255. void  init_globals(void);
  256. void  init_graphics(void);
  257. void  intro_screens(void);
  258. int   irandom(short min,short max);
  259. void  load_level(void);
  260. void  load_music(void);
  261. void  load_sprite(void);
  262. int   put_bstring(char *string,short nchar,short ix,short iy);
  263. void  terminate_game(void);
  264.  
  265.  
  266.