home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / FACETV.ZIP / GRAFXSCR.H < prev    next >
C/C++ Source or Header  |  1993-10-08  |  9KB  |  298 lines

  1. /************************************************************************
  2. **
  3. ** @(#)grafxscr.h    10/08/93    Chris Ahlstrom
  4. **
  5. **    The Screen structure describes everything about the status
  6. ** of a text screen.
  7. **
  8. **    This module is self-contained -- it does not refer to any
  9. ** other structures or data types.  Hence, any program can use it,
  10. ** without the need for a seemingly endless list of secondary
  11. ** include files.
  12. **
  13. **    See bios_vid.h for more information.
  14. **
  15. *************************************************************************/
  16.  
  17.  
  18. #ifndef GRAFXSCR_h                    /* { GRAFXSCR_h    */
  19. #define GRAFXSCR_h
  20.  
  21. #include <graphics.h>
  22.  
  23. #include "bios_vid.h"
  24.  
  25.  
  26. /************************************************************************
  27. ** -----------------------------------------------------
  28. ** Fundamental Data Types that differ between compilers
  29. ** -----------------------------------------------------
  30. **
  31. ** ---------------
  32. ** GraphicsDriver
  33. ** ---------------
  34. **
  35. **    Basically, this is a code number related to the kind of video
  36. ** the routines are to handle.  For the Borland compiler, this type
  37. ** will be equivalent to the following enumeration:
  38. **
  39. **    DETECT        = 0    (requests autodetection)
  40. **    CGA
  41. **    MCGA
  42. **    EGA
  43. **    EGA64
  44. **    EGAMONO
  45. **    IBM8514
  46. **    HERCMONO
  47. **    ATT400
  48. **    VGA
  49. **    PC3270
  50. **    CURRENT_DRIVER = -1
  51. **
  52. ** For the Microsoft compiler, this type will be a simpler enumeration,
  53. ** as can be seen below.
  54. **
  55. ** ---------------
  56. ** GraphicsDriver
  57. ** ---------------
  58. **
  59. **    Basically, this is a code number related to the kind of video
  60. ** mode to be applied to the current GraphicsDriver.  For the Borland
  61. ** compiler, this type will be equivalent to the following enumeration:
  62. **
  63. **    CGAC0        = 0    320x200 palette 0; 1 page
  64. **    CGAC1        = 1    320x200 palette 1; 1 page
  65. **    CGAC2        = 2    320x200 palette 2: 1 page
  66. **    CGAC3        = 3    320x200 palette 3; 1 page
  67. **    CGAHI        = 4    640x200 1 page
  68. **    MCGAC0        = 0    320x200 palette 0; 1 page
  69. **    MCGAC1        = 1    320x200 palette 1; 1 page
  70. **    MCGAC2        = 2    320x200 palette 2; 1 page
  71. **    MCGAC3        = 3    320x200 palette 3; 1 page
  72. **    MCGAMED        = 4    640x200 1 page
  73. **    MCGAHI        = 5    640x480 1 page
  74. **    EGALO        = 0    640x200 16 color 4 pages
  75. **    EGAHI        = 1    640x350 16 color 2 pages
  76. **    EGA64LO        = 0    640x200 16 color 1 page
  77. **    EGA64HI        = 1    640x350 4 color  1 page
  78. **    EGAMONOHI    = 0    640x350 64K card, 1 page, 256K card, 4 pages
  79. **    HERCMONOHI    = 0    720x348 2 pages
  80. **    ATT400C0    = 0    320x200 palette 0; 1 page
  81. **    ATT400C1    = 1    320x200 palette 1; 1 page
  82. **    ATT400C2    = 2    320x200 palette 2; 1 page
  83. **    ATT400C3    = 3    320x200 palette 3; 1 page
  84. **    ATT400MED    = 4    640x200 1 page
  85. **    ATT400HI    = 5    640x400 1 page
  86. **    VGALO        = 0    640x200 16 color 4 pages
  87. **    VGAMED        = 1    640x350 16 color 2 pages
  88. **    VGAHI        = 2    640x480 16 color 1 page
  89. **    PC3270HI    = 0    720x350 1 page
  90. **    IBM8514LO    = 0    640x480 256 colors
  91. **    IBM8514HI    = 1    1024x768 256 colors
  92. **
  93. ** For the Microsoft compiler, this will be int (that might change!),
  94. ** and we will specifically define VGALO, VGAMED, and VGAHI,
  95. ** although only the first two of these have universally applicable
  96. ** values.
  97. **
  98. ** ---------------
  99. ** GraphicsError
  100. ** ---------------
  101. **
  102. **    Basically, this is a code number related to the kind of video
  103. ** error status.  For the Borland compiler, this type will be
  104. ** equivalent to the following enumeration:
  105. **
  106. **    grOk            =   0,
  107. **    grNoInitGraph        =  -1,
  108. **    grNotDetected        =  -2,
  109. **    grFileNotFound        =  -3,
  110. **    grInvalidDriver        =  -4,
  111. **    grNoLoadMem        =  -5,
  112. **    grNoScanMem        =  -6,
  113. **    grNoFloodMem        =  -7,
  114. **    grFontNotFound        =  -8,
  115. **    grNoFontMem        =  -9,
  116. **    grInvalidMode        = -10,
  117. **    grError            = -11,   // generic error
  118. **    grIOerror        = -12,
  119. **    grInvalidFont        = -13,
  120. **    grInvalidFontNum    = -14,
  121. **    grInvalidVersion    = -18
  122. **
  123. ** For the Microsoft compiler, this will be int, with only grOk
  124. ** specifically defined.
  125. **
  126. *************************************************************************/
  127.  
  128. #ifdef __TURBOC__                /* { __TURBOC__        */
  129.  
  130. typedef enum graphics_drivers GraphicsDriver;
  131. typedef enum graphics_modes GraphicsMode;
  132. typedef enum graphics_errors GraphicsError;
  133. typedef struct palettetype Palette;
  134.  
  135. #else                        /* }{ __TURBOC__    */
  136.  
  137. #define ADAPTER                    /* override bios_vid.h    */
  138. typedef enum                    /* minimal drivers    */
  139. {
  140.     DETECT        = 0,
  141.     CGA            = 1,
  142.     CGA_DISPLAY        = 1,
  143.     EGA            = 2,
  144.     EGA_DISPLAY        = 2,
  145.     VGA            = 3,
  146.     VGA_DISPLAY        = 3,
  147.     SUPER_VGA_DISPLAY,
  148.     UNKNOWN_DISPLAY
  149.  
  150. } GraphicsDriver;
  151.  
  152. #define VGALO        0            /* minimal graphic mode    */
  153. #define VGAMED        1
  154. #define VGAHI        2
  155. typedef int GraphicsMode;
  156.  
  157. #define grOk        0            /* minimal error code    */
  158. typedef int GraphicsError;
  159.  
  160. #define MAXCOLORS 15                /* same as Borland    */
  161. typedef struct palettetype
  162. {
  163.     unsigned char size;
  164.     signed char colors[MAXCOLORS+1];
  165. } Palette;
  166.  
  167. #endif                        /* } __TURBOC__        */
  168.  
  169.  
  170. /************************************************************************
  171. ** --------------------------------------------------
  172. ** Fundamental Data Types the same between compilers
  173. ** --------------------------------------------------
  174. **
  175. ** -------------
  176. ** AdapterSelect
  177. ** -------------
  178. **
  179. **    0 is the main adapter, and 1 is the alternate adapter.
  180. ** The library attempts to keep the handling of each adapter well
  181. ** separate.
  182. **
  183. ** ------
  184. ** Screen
  185. ** ------
  186. **
  187. **    Attempts to hold all possible information about the current
  188. ** screen configuration.
  189. **
  190. *************************************************************************/
  191.  
  192. typedef enum
  193. {
  194.     ADAPTER_MAIN,
  195.     ADAPTER_ALT,
  196.     ADAPTER_INACTIVE
  197.  
  198. } AdapterSelect;
  199.  
  200. typedef struct
  201. {
  202.     AdapterSelect adapter;        /* active adapter for this one    */
  203.     GraphicsMode screen_type;        /* see enum in bios_vid.h    */
  204.     GraphicsDriver screen_driver;    /* type of driver card        */
  205.     int screen_mode;            /* current video mode        */
  206.     int screen_page;            /* current video page        */
  207.     int screen_attribute;        /* foreground DOS screen color    */
  208.     int screen_backattribute;        /* background DOS screen color    */
  209.     int screen_rows;            /* number of rows on the screen    */
  210.     int screen_columns;            /* number of columns on screen    */
  211.     int screen_gmax_y;            /* maximum y-axis pixel offset    */
  212.     int screen_gmax_x;            /* maximum x-axis pixel offset    */
  213.     int screen_rasters;            /* # of rasters lines supported    */
  214.     int screen_charsets;        /* # ofcharacter sets supported    */
  215.     int screen_chardefs;        /* # of character definitions    */
  216.     int cursor_row;            /* location of cursor, y    */
  217.     int cursor_column;            /* location of cursor, x    */
  218.     int cursor_start_line;        /* starting line of cursor icon    */
  219.     int cursor_end_line;        /* ending line of cursor "icon"    */
  220.     int screen_colors;            /* maximum colors specified    */
  221.     double screen_aspect;        /* aspect ratio            */
  222.     Palette palette;            /* 17-byte palette structure    */
  223.     int error_code;            /* last error for this screen    */
  224.     char *screen_driver_name;        /* name of the screen driver    */
  225.  
  226. } Screen;
  227.  
  228.  
  229. /************************************************************************
  230. ** Functions defined in GRAFXSCR.C
  231. *************************************************************************/
  232.  
  233. extern GraphicsError graphicsScreen
  234. (
  235.     Screen *s
  236. );
  237. extern int setscreen
  238. (
  239.     int mode,
  240.     int page,
  241.     int attribute,
  242.     int backattribute,
  243.     int rows,
  244.     int columns,
  245.     int currow,
  246.     int curcolumn,
  247.     int curstart,
  248.     int curend
  249. );
  250. extern Screen *getScreenStructure (void);
  251. extern void freeScreenStructure
  252. (
  253.     Screen *s
  254. );
  255. extern void initScreens
  256. (
  257.     Screen *main,
  258.     Screen *alt
  259. );
  260. extern int initBGI
  261. (
  262.     Screen *s,                /* all screen parameters    */
  263.     int alt_adapter,            /* adapter to use (0 or 1)    */
  264.     int adapter_type            /* kind of adapter        */
  265. );
  266. extern int fontinit
  267. (
  268.     Screen *s
  269. );
  270. extern int changetextstyle
  271. (
  272.     Screen *s,
  273.     int font,
  274.     int direction,
  275.     int charsize
  276. );
  277. extern void video_main (void);
  278. extern void video_alternate (void);
  279. extern void tomain (void);
  280. extern void toalternate (void);
  281. extern int init1
  282. (
  283.     Screen *s,
  284.     char *basefont
  285. );
  286.  
  287.  
  288. /************************************************************************
  289. ** Stuff privy to GRAFXSCR.C
  290. *************************************************************************/
  291.  
  292. #define    ERR_SCREEN_BAD                            \
  293.         "Screen structure was not obtained by legitimate means.\n"    \
  294.         "Therefore, I cannot allow you access to the BGI.\n"    \
  295.         "You must call getScreenStructure() to get a Screen.\n"
  296.  
  297. #endif                            /* } GRAFXSCR_h    */
  298.