home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / digmid / real / doscalls.h < prev    next >
Text File  |  1994-01-03  |  12KB  |  218 lines

  1. /******************************************************************************/
  2. /* DOSCALLS.ASM, DOSCALLS.H                              */
  3. /* Written by John W. Ratcliff, December 1991.                      */
  4. /******************************************************************************/
  5. /* DOSCALLS is a linkable object module that provides many of the functions   */
  6. /* available through the standard C libraries.    There are number of reasons to*/
  7. /* use DOSCALLS.OBJ rather than C library function calls.              */
  8. /*                                          */
  9. /*     1. Portability: These functions work the same regardless of what     */
  10. /*             C compiler you are using.                  */
  11. /*                                          */
  12. /*     2. Size:     These functions are extremely small compared to      */
  13. /*             equivalent C library functions. The C library          */
  14. /*             functions are general while the DOSCALLS          */
  15. /*             function calls are very specific.  Accessing C       */
  16. /*             library function calls causes large amounts of       */
  17. /*             library code to get drug in that you probably          */
  18. /*             don't want.                                          */
  19. /*                                          */
  20. /*     3. TSR capability: If you program TSR's you will find that           */
  21. /*             dragging in C library functions will kill you          */
  22. /*             for a whole number of reasons.  Using              */
  23. /*             DOSCALLS.OBJ you have no DGROUP dependencies and     */
  24. /*             you can easily write single segment TSR's and        */
  25. /*             even write both COM modules and DOS device          */
  26. /*             drivers.                          */
  27. /*                                          */
  28. /*     4. Assembly language:    If you don't program in C and need basic      */
  29. /*             DOS support functions, you can just use DOSCALLS     */
  30. /*             for this purpose.                      */
  31. /*                                          */
  32. /*     5. Simplicity:  DOSCALLS don't ignore the fact that you are programming*/
  33. /*             on an MS-DOS machine.    They in fact simply provide   */
  34. /*             C callable access to INT 21h calls.  Because of this */
  35. /*             they are all easy to use.                  */
  36. /******************************************************************************/
  37. #define NEW_FILE 0 // MFOPEN file types, 0 open as a new file for read/write
  38. #define OLD_FILE 1 // file type 1, open as an old file for read/write access
  39. #define FILE_NOT_FOUND 0 // file handle of zero, is file not found.
  40.  
  41. int  far cdecl mfopen(char far *filename,long int far *size,int type);
  42. int  far cdecl mpfopen(char far *filename,long int far *size,int type);
  43. /******************************************************************************/
  44. /* mfopen -> Does a DOS file open.  Returns a DOS file handle, which is simply*/
  45. /*         an integer.  You can open a file as a new file or as an old file */
  46. /*         by specifying the file type.  A return code of zero means that   */
  47. /*         the file couldn't be opened.  You pass the address of a long int */
  48. /*         who's contents will be filled with the total length of the file. */
  49. /*         If you pass a null address then the size will not be reported.   */
  50. /*         After a file open, the file pointer will always be sitting at    */
  51. /*         byte position zero.                          */
  52. /******************************************************************************/
  53.  
  54. int  far cdecl mfclose(int fhand);
  55. int  far cdecl mpfclose(int fhand);
  56. /******************************************************************************/
  57. /* mfclose -> Close a file that was opened with mfopen.               */
  58. /******************************************************************************/
  59.  
  60. long int    far cdecl mfpos(int fhand);
  61. /******************************************************************************/
  62. /* mfpos -> report current file position of this file.                  */
  63. /******************************************************************************/
  64.  
  65. long int far cdecl mfseek(int fhand,long int fpos);
  66. /******************************************************************************/
  67. /* mfseek -> seek file to this position passed.  Return code is actual file   */
  68. /*         seek position achieved. (In case request went past end of file.) */
  69. /******************************************************************************/
  70.  
  71. int  far cdecl mfread(void far *address,long int size,int fhand);
  72. /******************************************************************************/
  73. /* mfread -> read from file, into address, for length of size, from fhand.    */
  74. /*         return code of 1, successful file read, return code of zero,     */
  75. /*         file read failed.                              */
  76. /******************************************************************************/
  77.  
  78. int  far cdecl mfwrite(void far *address,long int size,int fhand);
  79. /******************************************************************************/
  80. /* mfwrite -> write data to file, from address, for length of size, to fhand. */
  81. /*          return code of 1, success, return code of zero, write failed.   */
  82. /******************************************************************************/
  83.  
  84. char far * far cdecl fload(char far *name,long int far *siz);
  85. char far * far cdecl fpload(char far *name,long int far *siz);
  86. /******************************************************************************/
  87. /* fload -> allocate memory, and read entire file in.  Uses name as filename  */
  88. /*        and returns the length read in, in siz.  If siz is null then siz  */
  89. /*        not set.  If return code is NULL then was unable to load file.    */
  90. /*        Either the file wasn't found, or there wasn't enough memory to    */
  91. /*        read it in.  Otherwise return code is the address of the file     */
  92. /*        read in at.  Uses MEMALLOC (provided by application program) to   */
  93. /*        allocate memory, and caller must do MEMFREE when finished with    */
  94. /*        this memory.                              */
  95. /******************************************************************************/
  96.  
  97. char far * far cdecl floadpara(char far *name,long int far *siz,int far *segment);
  98. /******************************************************************************/
  99. /* floadpara -> a special version of fload, that reads in the file into       */
  100. /*        allocated memory, but forces it at a paragraph boundary.      */
  101. /*        The return code is still the address of allocated memory for  */
  102. /*        the file read, but the variable segment is loaded with the    */
  103. /*        actual segment boundary that the file was read in at.  This   */
  104. /*        is used by digplay's LoadDriver call, which loads a binary    */
  105. /*        image into memory, that must fall on a paragraph boundary.    */
  106. /******************************************************************************/
  107.  
  108. int  far cdecl keystat(void);
  109. /******************************************************************************/
  110. /* keystat-> report DOS key status.  Zero, no key pending, 1, key pending.    */
  111. /******************************************************************************/
  112.  
  113. int  far cdecl getkey(void);
  114. /******************************************************************************/
  115. /* getkey -> DOS getkey function. Returns keypress pending.  Automatically    */
  116. /*         handles extended key codes, by adding 256 to them.           */
  117. /******************************************************************************/
  118.  
  119. void far cdecl farcop(char far *dest,char far *source);
  120. /******************************************************************************/
  121. /* farcop -> string copy routine, but uses far pointers.              */
  122. /******************************************************************************/
  123.  
  124. void far cdecl farcat(char far *dest,char far *source);
  125. /******************************************************************************/
  126. /* farcat -> string concatenate routine, but with far pointers.           */
  127. /******************************************************************************/
  128.  
  129. int far cdecl farlen(char far *string); // Return length of string.
  130.  
  131. int far cdecl farcompare(char far *source,char far *dest); // String compare.
  132.  
  133. void far cdecl ucase(char far *string); // Upper case a string.
  134.  
  135. char far * far cdecl fmalloc(long int size);
  136. /******************************************************************************/
  137. /* fmalloc -> DOS memory allocation.  Works fine by itself but conflicts with */
  138. /*          C compiler's far memory allocation.  DOS likes memory to be     */
  139. /*          de-allocated in the order that it was originally allocated, in  */
  140. /*          order for it to cleanly defragment memory pools.    These function*/
  141. /*          calls are valid if you are writing a TSR or must do DOS memory  */
  142. /*          allocation exclusively.                          */
  143. /******************************************************************************/
  144.  
  145. void far cdecl ffree(char far *tmp);
  146. /******************************************************************************/
  147. /* ffree -> free dos allocated memory.                          */
  148. /******************************************************************************/
  149.  
  150. void far cdecl writeln(char far *string);
  151. /******************************************************************************/
  152. /* writeln -> echo a string to the console.  Avoids dragging all of the printf*/
  153. /*          library code, which is HUGE!                      */
  154. /******************************************************************************/
  155.  
  156. void far * far cdecl GetTimerInterruptVector(void);
  157. /******************************************************************************/
  158. /* GetTimerInterruptVector -> reports the current far address of the timer    */
  159. /*        interrupt vector.  This function call is used to report the       */
  160. /*        original address of the timer interrupt vector, should your       */
  161. /*        application choose to change it.  These services are provided     */
  162. /*        because some of the sound drivers use the Timer interrupt to play */
  163. /*        back sound.  (Use AudioCapabilities to find out which ones.)  Even*/
  164. /*        though the sound drivers all still service the original 18.2 timer*/
  165. /*        interrupt, some application software may have already modified    */
  166. /*        the timer for it's own purposes.  In these cases you will         */
  167. /*        want to disable that timer while digitized sound playback is      */
  168. /*        occuring, and then put it back when sound playback has completed. */
  169. /*        If your application doesn't reprogram the timer interrupt vector  */
  170. /*        rate, you needn't worry about any of this stuff.                  */
  171. /******************************************************************************/
  172.  
  173. void far cdecl SetTimerInterruptVector(void far *address,unsigned int divisor);
  174. /******************************************************************************/
  175. /* SetTimerInterruptVector -> set the timer interupt vector to a new address  */
  176. /*         and specify a new interupt rate.                      */
  177. /******************************************************************************/
  178.  
  179. int far cdecl mdelete(char far *fname); // Delete a file by filename.
  180. int far cdecl ifexists(char far *fname);    // Does this file exist? 1 yes, 0 no.
  181.  
  182.  
  183. #define BLACK 0
  184. #define BLUE 1
  185. #define GREEN 2
  186. #define CYAN 3
  187. #define RED 4
  188. #define MAGENTA 5
  189. #define BROWN 6
  190. #define GRAY 7
  191. #define GREY 7
  192. #define DARK_GREY 8
  193. #define DARK_GRAY 8
  194. #define LIGHT_BLUE 9
  195. #define LIGHT_GREEN 10
  196. #define LIGHT_CYAN 11
  197. #define LIGHT_RED 12
  198. #define LIGHT_MAGENTA 13
  199. #define YELLOW 14
  200. #define WHITE 15
  201.  
  202. #define BEHIND << 4 |
  203.  
  204. void far cdecl tprint(int x,int y,int len,char far *string,int color);
  205. void far cdecl tcolor(int x,int y,int len,int color);  // Change text background color.
  206. void far cdecl TextCursor(int xloc,int yloc);
  207.  
  208. void far cdecl farmov(char far *dest,char far *source,int length);
  209.  
  210. void far cdecl MemStosb(char far *dest,int value,int length);
  211.  
  212. int far cdecl scale(int a,int b,int c);
  213.  
  214. void far * far cdecl MakeFP(int offset,int segment);
  215. int far cdecl MakeSeg(char far *address);
  216.  
  217. void far cdecl DBUG(long int value,int xloc,int yloc);
  218.