home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / graphx11 / graphics.hsz < prev    next >
Text File  |  1993-10-23  |  12KB  |  404 lines

  1. /*****************************************************************************/
  2. /*      File    : GRAPHICS.H                                                 */
  3. /*                                                                           */
  4. /*      Purpose : definitions for Turbo C v2.0 compatible graphics library.  */
  5. /*                This header file is to be used to compile the Sozobon C    */
  6. /*                v1.0, v1.33i & v2.0 graphics library                       */
  7. /*                                                                           */
  8. /*      Author  : Kenneth W. Hartlen                                         */
  9. /*      Address : Box 37, Site 6, RR#3                                       */
  10. /*                Armdale, Nova Scotia                                       */
  11. /*                B3L 4J3 Canada                                             */
  12. /*                                                                           */
  13. /*                Copyright (c) 1992                                         */
  14. /*                                                                           */
  15. /*      Note:   Turbo C v2.0 is a copyrighted product and trademark of       */
  16. /*      ====    Borland International Inc.                                   */
  17. /*                                                                           */
  18. /*****************************************************************************/
  19.  
  20. #ifndef __GRAPHX_DEF_                   /* prevent multiple inclusions */
  21. #define __GRAPHX_DEF_
  22.  
  23. #define    far
  24. #define    huge
  25.  
  26. /*---------------------------------------------------------------------------*/
  27. /*      Access to Atari ST VDI and AES work areas                            */
  28. #include <gemfast.h>
  29.  
  30. extern
  31. short   contrl[],                       /* default of 12 */
  32.         intin[],                        /* default of 128 */
  33.         ptsin[],                        /* default of 128 */
  34.         intout[],                       /* default of 128 */
  35.         ptsout[];                       /* default of 128 */
  36.  
  37. extern
  38. short   handle;                         /* workstation handle */
  39.  
  40. extern
  41. short   work_in[],                      /* default of 12 */
  42.         work_out[];                     /* default of 57 */
  43.  
  44. /*---------------------------------------------------------------------------*/
  45. /*      Remainder of header file provides a degree of compatiblity with      */
  46. /*      Borland's Turbo C v2.0 graphics library                              */
  47.  
  48. enum graphics_errors {          /* graphresult(); error return codes */
  49.         grOk               =   0,
  50.         grNoInitGraph      =  -1,
  51.         grNotDetected      =  -2,
  52.         grFileNotFound     =  -3,
  53.         grInvalidDriver    =  -4,
  54.         grNoLoadMem        =  -5,
  55.         grNoScanMem        =  -6,
  56.         grNoFloodMem       =  -7,
  57.         grFontNotFound     =  -8,
  58.         grNoFontMem        =  -9,
  59.         grInvalidMode      = -10,
  60.         grError            = -11,       /* general error */
  61.         grIOerror          = -12,
  62.         grInvalidFont      = -13,
  63.         grInvalidFontNum   = -14,
  64.         grInvalidDeviceNum = -15,
  65.         grInvalidFontSize  = -16,
  66.         grNotImplemented   = -17,
  67.         grInvalidVersion   = -18
  68. };
  69.  
  70. enum graphics_drivers {         /* define graphics drivers */
  71.         CURRENT_DRIVER = -1,
  72.         DETECT = 0,                                     /* autodetection */
  73.         CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514,        /*  1 -  6 */
  74.         HERCMONO, ATT400, VGA, PC3270,                  /*  7 - 10 */
  75.         SC1224, SM124,                    /* 11 - 12 */
  76.     TTC1434, TTM194,                /* 13 - 14 */
  77.     UNKNOWN_DRIVER                    /* 15 */
  78. };
  79.  
  80. enum graphics_modes {           /* graphics modes for each driver */
  81.     CGAC0 = 0, CGAC1, CGAC2, CGAC3, CGAHI,
  82.     MCGAC0 = 0, MCGAC1, MCGAC2, MCGAC3, MCGAMED, MCGAHI,
  83.     EGALO = 0, EGAHI,
  84.     EGA64LO = 0, EGA64HI,
  85.     EGAMONOHI = 0,
  86.     IBM8514LO = 0, IBM8514HI,
  87.     HERCMONOHI = 0,
  88.     ATT400C0 = 0, ATT400C1, ATT400C2, ATT400C3, ATT400MED, ATT400HI,
  89.     VGALO = 0, VGAMED, VGAHI,
  90.     PC3270HI = 0,
  91.     SC1224LO = 0, SC1224MED,
  92.     SM124HI = 0,
  93.     TTC1434STLO = 0, TTC1434STMED, TTC1434STHI, TTC1434LO, TTC1434MED,
  94.     TTM194HI = 0,
  95.     UNKNOWN_MODE = 0
  96. };
  97.  
  98. /* undefine GEM colour definitions that conflict with Turbo C */
  99. #undef    BLACK
  100. #undef    BLUE
  101. #undef    GREEN
  102. #undef    CYAN
  103. #undef    RED
  104. #undef    MAGENTA
  105. #undef    YELLOW
  106. #undef    WHITE
  107.  
  108. #define SOLID        1
  109. #define DOTTED        3
  110. #define DASHDOT        4
  111. #define DASHED        5
  112. #define USERLINE    7
  113.  
  114. #define FIS_HOLLOW      0
  115. #define FIS_SOLID       1
  116. #define FIS_PATTERN     2
  117. #define FIS_HATCH       3
  118. #define FIS_USER        4
  119.  
  120. #ifndef __COLORS            /* prevent multiple inclusions */
  121. #define __COLORS
  122. enum COLORS {
  123.     BLACK,
  124.     BLUE,
  125.     GREEN,
  126.     CYAN,
  127.     RED,
  128.     MAGENTA,
  129.     BROWN,
  130.     LIGHTGRAY,
  131.     DARKGRAY,
  132.     LIGHTBLUE,
  133.     LIGHTGREEN,
  134.     LIGHTCYAN,
  135.     LIGHTRED,
  136.     LIGHTMAGENTA,
  137.     YELLOW,
  138.     WHITE
  139. };
  140. #endif    /* __COLORS */
  141.  
  142. enum CGA_COLORS {
  143.         CGA_LIGHTGREEN          = 1,
  144.         CGA_LIGHTRED            = 2,
  145.         CGA_YELLOW              = 3,
  146.  
  147.         CGA_LIGHTCYAN           = 1,
  148.         CGA_LIGHTMAGENTA        = 2,
  149.         CGA_WHITE               = 3,
  150.  
  151.         CGA_GREEN               = 1,
  152.         CGA_RED                 = 2,
  153.         CGA_BROWN               = 3,
  154.  
  155.         CGA_CYAN                = 1,
  156.         CGA_MAGENTA             = 2,
  157.         CGA_LIGHTGRAY           = 3
  158. };
  159.  
  160. enum EGA_COLORS {
  161.     EGA_BLACK        =  0,
  162.     EGA_BLUE        =  1,
  163.     EGA_GREEN        =  2,
  164.     EGA_CYAN        =  3,
  165.     EGA_RED             =  4,
  166.     EGA_MAGENTA          =  5,
  167.     EGA_BROWN        =  BROWN,
  168.     EGA_LIGHTGRAY         =  7,
  169.     EGA_DARKGRAY         =  DARKGRAY,
  170.     EGA_LIGHTBLUE         =  LIGHTBLUE,
  171.     EGA_LIGHTGREEN         =  LIGHTGREEN,
  172.     EGA_LIGHTCYAN         =  LIGHTCYAN,
  173.     EGA_LIGHTRED         =  LIGHTRED,
  174.     EGA_LIGHTMAGENTA    =  LIGHTMAGENTA,
  175.     EGA_YELLOW        =  YELLOW,
  176.     EGA_WHITE        =  WHITE
  177. };
  178.  
  179. enum line_styles {              /* line styles for get/setlinestyle */
  180.     SOLID_LINE   = 0,
  181.     DOTTED_LINE  = 1,
  182.     CENTER_LINE  = 2,
  183.     DASHED_LINE  = 3,
  184.     USERBIT_LINE = 4    /* user defined line style */
  185. };
  186.  
  187. enum line_widths {              /* line widths for get/setlinestyle */
  188.         NORM_WIDTH  = 1,
  189.         THICK_WIDTH = 3
  190. };
  191.  
  192. enum font_names {
  193.         DEFAULT_FONT    = 0,    /* system font */
  194.         TRIPLEX_FONT    = 1,    
  195.         SMALL_FONT      = 2,
  196.         SANS_SERIF_FONT = 3,
  197.         GOTHIC_FONT     = 4    
  198. };
  199.  
  200. #define HORIZ_DIR    0       /* text left to right,   0 degrees */
  201. #define VERT_DIR        1       /* text bottom to top,  90 degrees */
  202.  
  203. #define USER_CHAR_SIZE  0       /* user-defined char size */
  204.  
  205. enum fill_patterns {        /* fill patterns for get/setfillstyle */
  206.     EMPTY_FILL,        /* fills area in background color */
  207.     SOLID_FILL,        /* fills area in solid fill color */
  208.     LINE_FILL,        /* --- fill */
  209.     LTSLASH_FILL,        /* /// fill */
  210.     SLASH_FILL,        /* /// fill with thick lines */
  211.     BKSLASH_FILL,        /* \\\ fill with thick lines */
  212.     LTBKSLASH_FILL,     /* \\\ fill */
  213.     HATCH_FILL,        /* light hatch fill */
  214.     XHATCH_FILL,        /* heavy cross hatch fill */
  215.     INTERLEAVE_FILL,    /* interleaving line fill */
  216.     WIDE_DOT_FILL,        /* Widely spaced dot fill */
  217.     CLOSE_DOT_FILL,     /* Closely spaced dot fill */
  218.     USER_FILL        /* user defined fill */
  219. };
  220.  
  221. enum putimage_ops {             /* BitBlt operators for putimage */
  222.     COPY_PUT,        /* MOV */
  223.     XOR_PUT,        /* XOR */
  224.     OR_PUT,         /* OR  */
  225.     AND_PUT,        /* AND */
  226.     NOT_PUT         /* NOT */
  227. };
  228.  
  229. enum text_just {        /* horizontal and vertical justification
  230.                    for settextjustify */
  231.     LEFT_TEXT    = 0,
  232.     CENTER_TEXT    = 1,
  233.     RIGHT_TEXT    = 2,
  234.  
  235.     BOTTOM_TEXT    = 0,
  236.      /* CENTER_TEXT    = 1,    already defined above */
  237.     TOP_TEXT    = 2
  238. };
  239.  
  240. #define MAXCOLORS 15            /* number of pens */
  241.  
  242. struct palettetype {
  243.         unsigned char size;
  244.     char colors[MAXCOLORS+1];
  245. };
  246.  
  247. struct linesettingstype {
  248.         int linestyle;
  249.         unsigned upattern;
  250.         int thickness;
  251. };
  252.  
  253. struct textsettingstype {
  254.         int font;
  255.         int direction;
  256.         int charsize;
  257.         int horiz;
  258.         int vert;
  259. };
  260.  
  261. struct fillsettingstype {
  262.         int pattern;
  263.         int color;
  264. };
  265.  
  266. struct pointtype {
  267.         int x, y;
  268. };
  269.  
  270. struct viewporttype {
  271.         int left, top, right, bottom;
  272.         int clip;
  273. };
  274.  
  275. struct arccoordstype {
  276.         int x, y;
  277.         int xstart, ystart, xend, yend;
  278. };
  279.  
  280. /*****************************************************************************/
  281. /*    Due to the 8 character identifier limit the following #defines will  */
  282. /*    ensure unique function names are handled by the linker, ld         */
  283. /*****************************************************************************/
  284.  
  285. #define    getfillpattern        a_getfillpattern
  286. #define    getfillsettings        b_getfillsettings
  287.  
  288. #define    getmodename        a_getmodename
  289. #define    getmoderange        b_getmoderange
  290.  
  291. #define    getpalette        a_getpalette
  292. #define    getpalettesize        b_getpalettesize
  293.  
  294. #define    outtext            a_outtext
  295. #define    outtextxy        b_outtextxy
  296.  
  297. #define    setfillpattern        a_setfillpattern
  298. #define    setfillstyle        b_setfillstyle
  299.  
  300. #define    setgraphmode        a_setgraphmode
  301. #define    setgraphbufsize        b_setgraphbufsize
  302.  
  303. #define    settextjustify        a_settextjustify
  304. #define    settextstyle        b_settextstyle
  305.  
  306. #define    installuserdriver    a_installuserdriver
  307. #define    installuserfont        b_installuserfont
  308.  
  309. #define    registerbgidriver    a_registerbgidriver
  310. #define    registerfarbgidriver    b_registerfarbgidriver
  311. #define    registerbgifont        c_registerbgifont
  312. #define    registerfarbgifont    d_registerfarbgifont
  313.  
  314. #endif    /* __GRAPHX_DEF_ */
  315.  
  316. /*****************************************************************************/
  317. /*      The following functions should only be included with the source file */
  318. /*      that contains your main() function. To do this simply put            */
  319. /*      #define __MAIN_SRC__ before #include <graphics.h>                    */
  320.  
  321. #ifdef __MAIN_SRC__
  322.  
  323. #include <stdio.h>
  324. #include <string.h>
  325.  
  326. /*****************************************************************************/
  327. /*    Returns the palette definition structure                 */
  328. struct palettetype * far  getdefaultpalette( )
  329. {
  330. extern  int     _grInit, _grErrorNum;
  331. extern  struct palettetype _defaultpalette;
  332.  
  333.     if (_grInit==1) {
  334.     _grErrorNum = grOk;
  335.     return(&_defaultpalette);
  336.     }
  337.     else
  338.         terminateprg();
  339. }
  340.  
  341. /*****************************************************************************/
  342. /*    Returns a pointer to a string containing the name of the current     */
  343. /*    graphics driver                                 */
  344. char *    far  getdrivername( )
  345. {
  346. extern  int     _grdriver, _grInit, _grErrorNum;
  347. extern  char    *_grDriverName[];
  348.  
  349.     if (_grInit==1) {
  350.     _grErrorNum = grOk;
  351.     return (_grDriverName[_grdriver]);
  352.     }
  353.     else
  354.         terminateprg();
  355. }
  356.  
  357. /*****************************************************************************/
  358. /*    Returns a pointer to a string containing the name of a specified     */
  359. /*    graphics mode                                 */
  360. char *    far  getmodename(mode_number)
  361. int    mode_number;
  362. {
  363. extern  int     _grdriver, _grInit, _grErrorNum;
  364. extern  char    *_grModeName[][6];
  365.  
  366.     if (_grInit==1) {
  367.         if ( (mode_number < 0) || (mode_number > 5) ||
  368.          (strcmp("",_grModeName[_grdriver][mode_number]) == 0) ) {
  369.         _grErrorNum = grError;
  370.         return (NULL);
  371.     }
  372.     else {
  373.         _grErrorNum = grOk;
  374.         return (_grModeName[_grdriver][mode_number]);
  375.     }
  376.     }
  377.     else
  378.         terminateprg();
  379. }
  380.  
  381. /*****************************************************************************/
  382. /*    Returns a pointer to an error message string                 */
  383. char *    far  grapherrormsg(errorcode)
  384. int    errorcode;
  385. {
  386. extern  int     _grdriver, _grInit, _grErrorNum;
  387. extern  char    *_grErrMsgs[];
  388.  
  389.     if (_grInit==1) {
  390.     if ( (errorcode >= grInvalidVersion) && (errorcode <= grOk) ) {
  391.         _grErrorNum = grOk;
  392.         return (_grErrMsgs[-errorcode]);
  393.     }
  394.     else {
  395.         _grErrorNum = grError;
  396.         return (NULL);
  397.     }
  398.     }
  399.     else
  400.         terminateprg();
  401. }
  402.  
  403. #endif    /* __MAIN_SRC__ */
  404.