home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TANK11.ZIP / SOURCE.ZIP / GR.H < prev    next >
C/C++ Source or Header  |  1993-01-16  |  7KB  |  190 lines

  1. /**********************************************************************
  2. * gr.h
  3. *
  4. * Support routines for graphics mode.
  5. **********************************************************************
  6.                     This file is part of
  7.  
  8.           STK -- The sprite toolkit -- version 1.0
  9.  
  10.               Copyright (C) Jari Karjala 1990
  11.  
  12. The sprite toolkit (STK) is a FreeWare toolkit for creating high
  13. resolution sprite graphics with PCompatible hardware. This toolkit 
  14. is provided as is without any warranty or such thing. See the file
  15. COPYING for further information.
  16.  
  17. **********************************************************************
  18. **********************************************************************/
  19.  
  20. #if     !defined(__GR_H_)
  21. #define __GR_H_
  22.  
  23.  
  24. #define GR_TYPE_ANY 0   /* Any mode will do */
  25. #define GR_TYPE_SPR 1   /* The best possible mode for the sprite toolkit */
  26.  
  27. /**********************************************************************
  28. * Detect the graphics card and mode of the system.
  29. * The type parameter can be used to specify special requests (see above).
  30. *
  31. * graphdriver and graphmode parameters are returned. These values can 
  32. * be used with the gr_start function. They contain the value -1
  33. * if some error occured (cannot find requested mode, etc)
  34. **********************************************************************/
  35. void gr_detect(int type, int *graphdriver, int *graphmode);
  36.  
  37. /***************************************************************************
  38. * Initializes the graphics system. 
  39. * Search BGI drivers from the path defined in the enviroment variable BGIDIR
  40. * or current directory. 
  41. * Set videomode into the BIOS to fool mouse drivers with Hercules graphics.
  42. * Set gr_end at exit and ctrl-C signals.
  43. * Terminate with error message if initialization fails.
  44. *
  45. * graphdriver   pointer to the driver ID (or DETECT)
  46. * graphmode     pointer to the mode ID
  47. ***************************************************************************/
  48. void gr_start(int *graphdriver, int *graphmode);
  49.  
  50. /***************************************************************************
  51. * Returns to the text mode
  52. ***************************************************************************/
  53. void gr_end(void);
  54.  
  55.  
  56. /**********************************************************************
  57. * gr_putch, gr_puts, gr_printf work as the as in text modes.
  58. * '\n', '\r' are handled as in standard text modes. 
  59. * Scrolling or backspacing not implemented.
  60. **********************************************************************/
  61. void gr_putch(char ch);
  62. void gr_puts(char *s);
  63. void gr_printf(char *s,...);
  64. #define gr_gotoxy(x, y) moveto(x*8, y*8)
  65.  
  66. /**********************************************************************
  67. * printf at the given position. (x and y in pixels) 
  68. **********************************************************************/
  69. void gr_xy_printf(int x, int y, char *s,...);
  70.  
  71. /**********************************************************************
  72. * printf into both graphics pages at the given position.
  73. * (x and y in pixels) Page 0 is left active.
  74. **********************************************************************/
  75. void gr_dual_xy_printf(int x, int y, char *s,...);
  76.  
  77. /**********************************************************************
  78. * Return a keypress if one pending, otherwise 0.
  79. * Extended codes contain 0 in the low byte.
  80. *
  81. * Automatic key repeat disabled by setting kbd buffer head and tail
  82. * equal. 
  83. **********************************************************************/
  84. int gr_inkey(void);
  85.  
  86. /**********************************************************************
  87. * Read a string from screen in graphics mode.
  88. * The result is placed into cpdest, at most max_len characters are
  89. * read (max_len must be less than 80). Return cpdest of NULL
  90. * Backspace deletes characters, Esc returns a NULL pointer.
  91. **********************************************************************/
  92. char *gr_gets(char *cpdest, int max_len);
  93.  
  94. /**********************************************************************
  95. * The maximum coordinate values for current graphics adapter.
  96. * (It is faster to use variables instead of getmaxx() and getmaxy());
  97. **********************************************************************/
  98. extern int gr_max_x;
  99. extern int gr_max_y;
  100.  
  101. /**********************************************************************
  102. * This variable defines the text writing mode (default GR_MODE_CLEAR)
  103. * (See the defines below)
  104. **********************************************************************/
  105. extern int gr_text_mode;
  106.  
  107. #define GR_MODE_OR      (1<<0)      /* OR the text over previous graphics */
  108. #define GR_MODE_CLEAR   (1<<1)      /* Clear the backgroud before print  */
  109.  
  110.  
  111. /**********************************************************************
  112. * Array of booleans for each key of the keyboard (indexed by the scan
  113. * code value). Non-zero if key pressed, zero otherwise.
  114. * The array is updated during the kbd_grab, see the function 
  115. * gr_start_kbd_grab below.
  116. **********************************************************************/
  117. extern char gr_keys[128];
  118.  
  119.  
  120. /**********************************************************************
  121. * Set a new handler for the keyboard. This handler sets and resets
  122. * the gr_keys array values for each scancode received, then flushes the 
  123. * keyboard buffer, and after that calls the old handler.
  124. **********************************************************************/
  125. void gr_start_kbd_grab(void);
  126.  
  127. /**********************************************************************
  128. * End the kbd grab, ie restore the original keyboard handler
  129. **********************************************************************/
  130. void gr_end_kbd_grab(void);
  131.  
  132. /**********************************************************************
  133. * Defines for the scan codes of some keys. See others from
  134. * some book, for example Peter Norton's Programmers guide or
  135. * write a program to try them out...
  136. **********************************************************************/
  137.  
  138. #define GR_KEY_ESC  1
  139. #define GR_KEY_1    2
  140. #define GR_KEY_2    3
  141. #define GR_KEY_3    4
  142. #define GR_KEY_4    5
  143. #define GR_KEY_5    6
  144. #define GR_KEY_6    7
  145. #define GR_KEY_7    8
  146. #define GR_KEY_8    9
  147. #define GR_KEY_9    10
  148. #define GR_KEY_0    11
  149.  
  150. #define GR_KEY_TAB  15
  151. #define GR_KEY_Q    16
  152. #define GR_KEY_W    17
  153. #define GR_KEY_E    18
  154. #define GR_KEY_R    19 
  155. #define GR_KEY_T    20
  156. #define GR_KEY_Y    21
  157. #define GR_KEY_U    22
  158. #define GR_KEY_I    23
  159. #define GR_KEY_O    24
  160. #define GR_KEY_P    25
  161.  
  162. #define GR_KEY_A    30
  163. #define GR_KEY_S    31
  164. #define GR_KEY_D    32
  165. #define GR_KEY_F    33
  166. #define GR_KEY_G    34
  167. #define GR_KEY_H    35
  168. #define GR_KEY_J    36
  169. #define GR_KEY_K    37
  170. #define GR_KEY_L    38
  171.  
  172. #define GR_KEY_Z    44
  173. #define GR_KEY_X    45 
  174. #define GR_KEY_C    46
  175. #define GR_KEY_V    47
  176. #define GR_KEY_B    48
  177. #define GR_KEY_N    49
  178. #define GR_KEY_M    50
  179. #define GR_KEY_COMMA    51
  180. #define GR_KEY_DOT      52
  181.  
  182. #define GR_KEY_SPACE    57
  183.  
  184. #define GR_KEY_ARROW_UP     72
  185. #define GR_KEY_ARROW_DOWN   80
  186. #define GR_KEY_ARROW_LEFT   75
  187. #define GR_KEY_ARROW_RIGHT  77
  188.  
  189. #endif
  190.