home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* File : GRAPHICS.H */
- /* */
- /* Purpose : definitions for Turbo C v2.0 compatible graphics library. */
- /* This header file is to be used to compile the Sozobon C */
- /* v1.0, v1.33i & v2.0 graphics library */
- /* */
- /* Author : Kenneth W. Hartlen */
- /* Address : Box 37, Site 6, RR#3 */
- /* Armdale, Nova Scotia */
- /* B3L 4J3 Canada */
- /* */
- /* Copyright (c) 1992 */
- /* */
- /* Note: Turbo C v2.0 is a copyrighted product and trademark of */
- /* ==== Borland International Inc. */
- /* */
- /*****************************************************************************/
-
- #ifndef __GRAPHX_DEF_ /* prevent multiple inclusions */
- #define __GRAPHX_DEF_
-
- #define far
- #define huge
-
- /*---------------------------------------------------------------------------*/
- /* Access to Atari ST VDI and AES work areas */
- #include <gemfast.h>
-
- extern
- short contrl[], /* default of 12 */
- intin[], /* default of 128 */
- ptsin[], /* default of 128 */
- intout[], /* default of 128 */
- ptsout[]; /* default of 128 */
-
- extern
- short handle; /* workstation handle */
-
- extern
- short work_in[], /* default of 12 */
- work_out[]; /* default of 57 */
-
- /*---------------------------------------------------------------------------*/
- /* Remainder of header file provides a degree of compatiblity with */
- /* Borland's Turbo C v2.0 graphics library */
-
- enum graphics_errors { /* graphresult(); error return codes */
- grOk = 0,
- grNoInitGraph = -1,
- grNotDetected = -2,
- grFileNotFound = -3,
- grInvalidDriver = -4,
- grNoLoadMem = -5,
- grNoScanMem = -6,
- grNoFloodMem = -7,
- grFontNotFound = -8,
- grNoFontMem = -9,
- grInvalidMode = -10,
- grError = -11, /* general error */
- grIOerror = -12,
- grInvalidFont = -13,
- grInvalidFontNum = -14,
- grInvalidDeviceNum = -15,
- grInvalidFontSize = -16,
- grNotImplemented = -17,
- grInvalidVersion = -18
- };
-
- enum graphics_drivers { /* define graphics drivers */
- CURRENT_DRIVER = -1,
- DETECT = 0, /* autodetection */
- CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514, /* 1 - 6 */
- HERCMONO, ATT400, VGA, PC3270, /* 7 - 10 */
- SC1224, SM124, /* 11 - 12 */
- TTC1434, TTM194, /* 13 - 14 */
- UNKNOWN_DRIVER /* 15 */
- };
-
- enum graphics_modes { /* graphics modes for each driver */
- CGAC0 = 0, CGAC1, CGAC2, CGAC3, CGAHI,
- MCGAC0 = 0, MCGAC1, MCGAC2, MCGAC3, MCGAMED, MCGAHI,
- EGALO = 0, EGAHI,
- EGA64LO = 0, EGA64HI,
- EGAMONOHI = 0,
- IBM8514LO = 0, IBM8514HI,
- HERCMONOHI = 0,
- ATT400C0 = 0, ATT400C1, ATT400C2, ATT400C3, ATT400MED, ATT400HI,
- VGALO = 0, VGAMED, VGAHI,
- PC3270HI = 0,
- SC1224LO = 0, SC1224MED,
- SM124HI = 0,
- TTC1434STLO = 0, TTC1434STMED, TTC1434STHI, TTC1434LO, TTC1434MED,
- TTM194HI = 0,
- UNKNOWN_MODE = 0
- };
-
- /* undefine GEM colour definitions that conflict with Turbo C */
- #undef BLACK
- #undef BLUE
- #undef GREEN
- #undef CYAN
- #undef RED
- #undef MAGENTA
- #undef YELLOW
- #undef WHITE
-
- #define SOLID 1
- #define DOTTED 3
- #define DASHDOT 4
- #define DASHED 5
- #define USERLINE 7
-
- #define FIS_HOLLOW 0
- #define FIS_SOLID 1
- #define FIS_PATTERN 2
- #define FIS_HATCH 3
- #define FIS_USER 4
-
- #ifndef __COLORS /* prevent multiple inclusions */
- #define __COLORS
- enum COLORS {
- BLACK,
- BLUE,
- GREEN,
- CYAN,
- RED,
- MAGENTA,
- BROWN,
- LIGHTGRAY,
- DARKGRAY,
- LIGHTBLUE,
- LIGHTGREEN,
- LIGHTCYAN,
- LIGHTRED,
- LIGHTMAGENTA,
- YELLOW,
- WHITE
- };
- #endif /* __COLORS */
-
- enum CGA_COLORS {
- CGA_LIGHTGREEN = 1,
- CGA_LIGHTRED = 2,
- CGA_YELLOW = 3,
-
- CGA_LIGHTCYAN = 1,
- CGA_LIGHTMAGENTA = 2,
- CGA_WHITE = 3,
-
- CGA_GREEN = 1,
- CGA_RED = 2,
- CGA_BROWN = 3,
-
- CGA_CYAN = 1,
- CGA_MAGENTA = 2,
- CGA_LIGHTGRAY = 3
- };
-
- enum EGA_COLORS {
- EGA_BLACK = 0,
- EGA_BLUE = 1,
- EGA_GREEN = 2,
- EGA_CYAN = 3,
- EGA_RED = 4,
- EGA_MAGENTA = 5,
- EGA_BROWN = BROWN,
- EGA_LIGHTGRAY = 7,
- EGA_DARKGRAY = DARKGRAY,
- EGA_LIGHTBLUE = LIGHTBLUE,
- EGA_LIGHTGREEN = LIGHTGREEN,
- EGA_LIGHTCYAN = LIGHTCYAN,
- EGA_LIGHTRED = LIGHTRED,
- EGA_LIGHTMAGENTA = LIGHTMAGENTA,
- EGA_YELLOW = YELLOW,
- EGA_WHITE = WHITE
- };
-
- enum line_styles { /* line styles for get/setlinestyle */
- SOLID_LINE = 0,
- DOTTED_LINE = 1,
- CENTER_LINE = 2,
- DASHED_LINE = 3,
- USERBIT_LINE = 4 /* user defined line style */
- };
-
- enum line_widths { /* line widths for get/setlinestyle */
- NORM_WIDTH = 1,
- THICK_WIDTH = 3
- };
-
- enum font_names {
- DEFAULT_FONT = 0, /* system font */
- TRIPLEX_FONT = 1,
- SMALL_FONT = 2,
- SANS_SERIF_FONT = 3,
- GOTHIC_FONT = 4
- };
-
- #define HORIZ_DIR 0 /* text left to right, 0 degrees */
- #define VERT_DIR 1 /* text bottom to top, 90 degrees */
-
- #define USER_CHAR_SIZE 0 /* user-defined char size */
-
- enum fill_patterns { /* fill patterns for get/setfillstyle */
- EMPTY_FILL, /* fills area in background color */
- SOLID_FILL, /* fills area in solid fill color */
- LINE_FILL, /* --- fill */
- LTSLASH_FILL, /* /// fill */
- SLASH_FILL, /* /// fill with thick lines */
- BKSLASH_FILL, /* \\\ fill with thick lines */
- LTBKSLASH_FILL, /* \\\ fill */
- HATCH_FILL, /* light hatch fill */
- XHATCH_FILL, /* heavy cross hatch fill */
- INTERLEAVE_FILL, /* interleaving line fill */
- WIDE_DOT_FILL, /* Widely spaced dot fill */
- CLOSE_DOT_FILL, /* Closely spaced dot fill */
- USER_FILL /* user defined fill */
- };
-
- enum putimage_ops { /* BitBlt operators for putimage */
- COPY_PUT, /* MOV */
- XOR_PUT, /* XOR */
- OR_PUT, /* OR */
- AND_PUT, /* AND */
- NOT_PUT /* NOT */
- };
-
- enum text_just { /* horizontal and vertical justification
- for settextjustify */
- LEFT_TEXT = 0,
- CENTER_TEXT = 1,
- RIGHT_TEXT = 2,
-
- BOTTOM_TEXT = 0,
- /* CENTER_TEXT = 1, already defined above */
- TOP_TEXT = 2
- };
-
- #define MAXCOLORS 15 /* number of pens */
-
- struct palettetype {
- unsigned char size;
- char colors[MAXCOLORS+1];
- };
-
- struct linesettingstype {
- int linestyle;
- unsigned upattern;
- int thickness;
- };
-
- struct textsettingstype {
- int font;
- int direction;
- int charsize;
- int horiz;
- int vert;
- };
-
- struct fillsettingstype {
- int pattern;
- int color;
- };
-
- struct pointtype {
- int x, y;
- };
-
- struct viewporttype {
- int left, top, right, bottom;
- int clip;
- };
-
- struct arccoordstype {
- int x, y;
- int xstart, ystart, xend, yend;
- };
-
- /*****************************************************************************/
- /* Due to the 8 character identifier limit the following #defines will */
- /* ensure unique function names are handled by the linker, ld */
- /*****************************************************************************/
-
- #define getfillpattern a_getfillpattern
- #define getfillsettings b_getfillsettings
-
- #define getmodename a_getmodename
- #define getmoderange b_getmoderange
-
- #define getpalette a_getpalette
- #define getpalettesize b_getpalettesize
-
- #define outtext a_outtext
- #define outtextxy b_outtextxy
-
- #define setfillpattern a_setfillpattern
- #define setfillstyle b_setfillstyle
-
- #define setgraphmode a_setgraphmode
- #define setgraphbufsize b_setgraphbufsize
-
- #define settextjustify a_settextjustify
- #define settextstyle b_settextstyle
-
- #define installuserdriver a_installuserdriver
- #define installuserfont b_installuserfont
-
- #define registerbgidriver a_registerbgidriver
- #define registerfarbgidriver b_registerfarbgidriver
- #define registerbgifont c_registerbgifont
- #define registerfarbgifont d_registerfarbgifont
-
- #endif /* __GRAPHX_DEF_ */
-
- /*****************************************************************************/
- /* The following functions should only be included with the source file */
- /* that contains your main() function. To do this simply put */
- /* #define __MAIN_SRC__ before #include <graphics.h> */
-
- #ifdef __MAIN_SRC__
-
- #include <stdio.h>
- #include <string.h>
-
- /*****************************************************************************/
- /* Returns the palette definition structure */
- struct palettetype * far getdefaultpalette( )
- {
- extern int _grInit, _grErrorNum;
- extern struct palettetype _defaultpalette;
-
- if (_grInit==1) {
- _grErrorNum = grOk;
- return(&_defaultpalette);
- }
- else
- terminateprg();
- }
-
- /*****************************************************************************/
- /* Returns a pointer to a string containing the name of the current */
- /* graphics driver */
- char * far getdrivername( )
- {
- extern int _grdriver, _grInit, _grErrorNum;
- extern char *_grDriverName[];
-
- if (_grInit==1) {
- _grErrorNum = grOk;
- return (_grDriverName[_grdriver]);
- }
- else
- terminateprg();
- }
-
- /*****************************************************************************/
- /* Returns a pointer to a string containing the name of a specified */
- /* graphics mode */
- char * far getmodename(mode_number)
- int mode_number;
- {
- extern int _grdriver, _grInit, _grErrorNum;
- extern char *_grModeName[][6];
-
- if (_grInit==1) {
- if ( (mode_number < 0) || (mode_number > 5) ||
- (strcmp("",_grModeName[_grdriver][mode_number]) == 0) ) {
- _grErrorNum = grError;
- return (NULL);
- }
- else {
- _grErrorNum = grOk;
- return (_grModeName[_grdriver][mode_number]);
- }
- }
- else
- terminateprg();
- }
-
- /*****************************************************************************/
- /* Returns a pointer to an error message string */
- char * far grapherrormsg(errorcode)
- int errorcode;
- {
- extern int _grdriver, _grInit, _grErrorNum;
- extern char *_grErrMsgs[];
-
- if (_grInit==1) {
- if ( (errorcode >= grInvalidVersion) && (errorcode <= grOk) ) {
- _grErrorNum = grOk;
- return (_grErrMsgs[-errorcode]);
- }
- else {
- _grErrorNum = grError;
- return (NULL);
- }
- }
- else
- terminateprg();
- }
-
- #endif /* __MAIN_SRC__ */
-