PCRLIB.H 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /* The Catacomb Source Code
  2. * Copyright (C) 1993-2014 Flat Rock Software
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include <dos.h>
  19. #include <mem.h>
  20. #include <sys\stat.h>
  21. #include <fcntl.h>
  22. #include <alloc.h>
  23. #include <io.h>
  24. #include <alloc.h>
  25. #include <string.h>
  26. typedef enum {false,true} boolean;
  27. typedef unsigned char byte;
  28. typedef unsigned int word;
  29. char extern ch,str[80];
  30. /*=========================================================================*/
  31. /*
  32. ** Sound routines
  33. ** Tied into INT 8, with a speeded up timer!
  34. */
  35. typedef enum {off,spkr,sdlib} soundtype;
  36. typedef struct {word start;
  37. byte priority;
  38. byte samplerate;
  39. char name[12];} spksndtype;
  40. typedef struct {char id[4];
  41. word filelength;
  42. word filler[5];
  43. spksndtype sounds[63];
  44. word freqdata[];} SPKRtable;
  45. soundtype extern soundmode;
  46. char extern huge *SoundData;
  47. int extern _dontplay;
  48. void StartupSound (void);
  49. void ShutdownSound (void);
  50. void PlaySound (int sound);
  51. void PauseSound (void);
  52. void ContinueSound (void);
  53. void StopSound (void);
  54. void WaitEndSound (void);
  55. /*=========================================================================*/
  56. /*
  57. ** Control routines
  58. ** Ties into INT 9 to intercept all key presses, but passes on to BIOS
  59. ** The control panel handles all this stuff!
  60. */
  61. typedef enum {north,east,south,west,northeast,southeast,southwest,
  62. northwest,nodir} dirtype;
  63. typedef struct {dirtype dir;
  64. boolean button1,button2;} ControlStruct;
  65. typedef enum {keyboard,mouse,joystick1,joystick2,demo} inputtype;
  66. inputtype extern playermode[3];
  67. boolean extern keydown[128];
  68. int extern JoyXlow[3], JoyXhigh[3], JoyYlow [3], JoyYhigh [3]; // 1&2 are used
  69. int extern MouseSensitivity;
  70. char extern key[8], keyB1, keyB2;
  71. enum demoenum {notdemo,demoplay,recording};
  72. enum demoenum extern indemo;
  73. void extern interrupt (*oldint9) ();
  74. void SetupKBD ();
  75. void interrupt Int9ISR ();
  76. void ShutdownKBD ();
  77. void ReadJoystick (int joynum,int *xcount,int *ycount);
  78. ControlStruct ControlKBD ();
  79. ControlStruct ControlMouse ();
  80. ControlStruct ControlJoystick (int joynum);
  81. ControlStruct ControlPlayer (int player);
  82. void LoadDemo (int demonum);
  83. void SaveDemo (int demonum);
  84. /*========================================================================*/
  85. /*
  86. ** Miscellaneous library routines
  87. */
  88. void extern far *lastparalloc;
  89. void huge *paralloc (long size);
  90. long unsigned int LoadFile(char *filename,char huge *buffer);
  91. void SaveFile(char *filename,char huge *buffer, long size);
  92. void huge *bloadin (char *filename);
  93. void huge *bloadinLZW (char *filename);
  94. long RLEcompress (void far *source, long length, void far *dest);
  95. void initrndt (boolean randomize);
  96. int rndt (void);
  97. void clearkeys (void);
  98. unsigned extern timecall,timeax,timebx,timecx,timedx,timesi,timedi,timebp,timees;
  99. int timesub (int ticks);
  100. int _MouseInit(void);
  101. void _MouseHide(void);
  102. void _MouseShow(void);
  103. int _MouseButton(void);
  104. void _MouseCoords(int *x,int *y);
  105. long _Verify(char *filename);
  106. void _printhexb(unsigned char value);
  107. void _printhex(unsigned value);
  108. void _printbin(unsigned value);
  109. /*========================================================================*/
  110. /*
  111. ** Graphic routines
  112. */
  113. #define SCindex 0x3C4
  114. #define SCmapmask 2
  115. #define GCindex 0x3CE
  116. #define GCmode 5
  117. #define CRTCLINECOMPARE 0x18
  118. #define CRTCOVERFLOW 0x7
  119. #define CRTCMAXSCANLINE 0x9
  120. #define CRTCSTARTL 0xd
  121. #define CRTCSTARTH 0xc
  122. typedef enum {text,CGAgr,EGAgr,VGAgr} grtype;
  123. typedef enum {NOcard,MDAcard,CGAcard,EGAcard,MCGAcard,VGAcard,
  124. HGCcard=0x80,HGCPcard,HICcard} cardtype;
  125. grtype extern grmode;
  126. cardtype extern _videocard;
  127. int extern sx,sy,leftedge,xormask; // stuff for screen text output
  128. word extern CGAylookup [200],EGAylookup[200],VGAylookup[200];
  129. unsigned extern crtcaddr;
  130. void setscreenmode (grtype mode);
  131. void WaitVBL (void);
  132. void EGAplane (int plane);
  133. void EGAlatch (void);
  134. void EGAsplitscreen (int linenum);
  135. void crtcstart (unsigned start);
  136. cardtype VideoID (void);
  137. /*=========================================================================*/
  138. /*
  139. ** PC-Arcade graphic file format stuff
  140. */
  141. #define NUMPICS 64
  142. #define NUMSPRITES 10
  143. unsigned extern EGADATASTART;
  144. typedef struct {
  145. int width;
  146. int height;
  147. void far *shapeptr; // reletive to spriteptr
  148. void far *maskptr;
  149. int xl,yl,xh,yh; // death box pixel offsets
  150. char name[12];
  151. } spritetype;
  152. typedef struct {
  153. int width;
  154. int height;
  155. void far *shapeptr;
  156. char name[8];
  157. } pictype;
  158. int extern numchars,numtiles,numpics,numsprites;
  159. spritetype extern image, spritetable[NUMSPRITES]; // grfile headers
  160. pictype extern pictable[NUMPICS];
  161. void extern huge *charptr; // 8*8 tileset
  162. void extern huge *tileptr; // 16*16 tileset
  163. void extern huge *picptr; // any size picture set
  164. void extern huge *spriteptr; // any size masked and hit rect sprites
  165. void extern huge *egaspriteptr[4]; // spriteptr for each plane
  166. unsigned extern screenseg; // loaded into ES in the draw routines
  167. // should be adjusted after grmode
  168. // switches, page flipping, and scrolls
  169. void moveega (void);
  170. void installgrfile (char *filename,int unpack,void huge *inmem);
  171. void drawchar (int x, int y, int charnum);
  172. void drawtile (int x, int y, int picnum);
  173. void drawpic (int x, int y, int picnum);
  174. /*=========================================================================*/
  175. /*
  176. ** higher level graphic routines
  177. */
  178. int extern screencenterx ,screencentery, _yshift;
  179. void controlpanel (void);
  180. int get (void);
  181. int _input(char *string,int max);
  182. unsigned _inputint(void);
  183. void print (const char *str);
  184. void _printc(char *string);
  185. void _printhexb(unsigned char value);
  186. void _printhex(unsigned value);
  187. void printint (int val);
  188. void printlong (long val);
  189. void drawwindow (int xl, int yl, int xh, int yh);
  190. void erasewindow (void);
  191. void bar (int xl,int yl, int xh, int yh, int ch);
  192. void centerwindow (int width, int height);
  193. void expwin (int width, int height);
  194. void expwinh (int width, int height);
  195. void expwinv (int width, int height);
  196. /*=========================================================================*/
  197. /*
  198. ** necessary routiones
  199. */
  200. void loadgrfiles (void); // call installgrfile + any other files
  201. void repaintscreen (void); // do any screen wierdness and redraw all
  202. /*========================================================================*/
  203. /*
  204. ** game level routines
  205. */
  206. long extern score;
  207. int extern level;
  208. typedef struct { int width;
  209. int height;
  210. int planes;
  211. int screenx;
  212. int screeny;
  213. int screenw;
  214. int screenh;
  215. unsigned planesize;
  216. } LevelDef;
  217. int extern _numlevels, _maxplayers;
  218. boolean extern _cgaok, _egaok, _vgaok;
  219. char extern *_extension;
  220. struct scores {
  221. long score;
  222. int level;
  223. char initials[4];
  224. };
  225. struct scores extern scoreswap, highscores[5];
  226. void _loadctrls (void);
  227. void _savectrls (void);
  228. void _loadhighscores (void);
  229. void _savehighscores (void);
  230. void _showhighscores (void);
  231. void _checkhighscore (void);
  232. void _setupgame (void);
  233. void _quit (char *); // shuts everything down
  234. /*=========================================================================*/
  235. unsigned int extern RLECompress
  236. (char far *source, long sourcelen, char far *dest);
  237. void extern RLEExpand
  238. (char far *source, char far *dest, long origlen);
  239. //NOLAN ADDED
  240. extern boolean GODMODE;