home *** CD-ROM | disk | FTP | other *** search
/ MegaDoom Adventures / PMWMEGADOOM.iso / doom / creators / deu52gcc / src / contrib / bcc2grx / include / bccgrx.h next >
Text File  |  1993-07-24  |  18KB  |  571 lines

  1. /*
  2.  *  BCC2GRX  -  Interfacing Borland based graphics programs to LIBGRX
  3.  *  Copyright (C) 1993  Hartmut Schirmer
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *
  20.  *  Contact :                Hartmut Schirmer
  21.  *                           Feldstrasse 118
  22.  *                    D-2300 Kiel 1
  23.  *                           Germany
  24.  *
  25.  *                    No telephone calls please !
  26.  *
  27.  *           NOTE : Please use ZIP 24105 after July 1 1993 !!
  28.  *
  29.  */
  30. #ifndef __BCCGRX_H
  31. #define __BCCGRX_H
  32.  
  33. #ifndef TRUE
  34. #  define TRUE (1==1)
  35. #endif
  36. #ifndef FALSE
  37. #  define FALSE (1==0)
  38. #endif
  39.  
  40. #define grOk                0
  41. #define grNoInitGraph      -1
  42. #define grNotDetected      -2
  43. #define grFileNotFound     -3
  44. #define grInvalidDriver    -4
  45. #define grNoLoadMem        -5
  46. #define grNoScanMem        -6
  47. #define grNoFloodMem       -7
  48. #define grFontNotFound     -8
  49. #define grNoFontMem        -9
  50. #define grInvalidMode      -10
  51. #define grError            -11
  52. #define grIOerror          -12
  53. #define grInvalidFont      -13
  54. #define grInvalidFontNum   -14
  55. #define grInvalidVersion   -18
  56.  
  57. #define DETECT             (-2)
  58. #define NATIVE_GRX         (-3)
  59. #define CURRENT_DRIVER     (-1)
  60. #define VGA                GR_VGA
  61. #define EGA                GR_EGA
  62. #define IBM8514            GR_8514A
  63. #define HERCMONO           GR_HERC
  64.  
  65. #define EGA64              10
  66. #define EGAMONO            11
  67. #define CGA                12
  68. #define MCGA               13
  69. #define ATT400             14
  70. #define PC3270             15
  71.  
  72. #define VGALO              0
  73. #define VGAMED             1
  74. #define VGAHI              2
  75. #define IBM8514LO          0
  76. #define IBM8514HI          1
  77. #define HERCMONOHI         0
  78. #define CGAC0              0
  79. #define CGAC1              1
  80. #define CGAC2              2
  81. #define CGAC3              3
  82. #define CGAHI              4
  83. #define MCGAC0             CGAC0
  84. #define MCGAC1             CGAC1
  85. #define MCGAC2             CGAC2
  86. #define MCGAC3             CGAC3
  87. #define MCGAMED            CGAHI
  88. #define MCGAHI             5
  89. #define ATT400C0           MCGAC0
  90. #define ATT400C1           MCGAC1
  91. #define ATT400C2           MCGAC2
  92. #define ATT400C3           MCGAC3
  93. #define ATT400MED          MCGAMED
  94. #define ATT400HI           MCGAHI
  95. #define EGA64LO            0
  96. #define EGA64HI            1
  97. #define EGALO              0
  98. #define EGAHI              1
  99. #define EGAMONOHI          0
  100. #define PC3270HI           0
  101.  
  102. /* NATIVE_GRX modes : */
  103. #define GRX_DEFAULT_GRAPHICS                0
  104. #define GRX_BIGGEST_NONINTERLACED_GRAPHICS  1
  105. #define GRX_BIGGEST_GRAPHICS                2
  106. #define GRX_BGI_EMULATION                   3
  107. #define __FIRST_DRIVER_SPECIFIC_MODE        4
  108.  
  109.  
  110. #ifndef LIGHTMAGENTA
  111. #define BLACK         GrBlack()
  112. #define BLUE          1
  113. #define GREEN         2
  114. #define CYAN          3
  115. #define RED           4
  116. #define MAGENTA       5
  117. #define BROWN         6
  118. #define LIGHTGRAY     7
  119. #define DARKGRAY      8
  120. #define LIGHTBLUE     9
  121. #define LIGHTGREEN   10
  122. #define LIGHTCYAN    11
  123. #define LIGHTRED     12
  124. #define LIGHTMAGENTA 13
  125. #define YELLOW       14
  126. #define WHITE        GrWhite()
  127. #endif
  128.  
  129. #define EGA_BLACK 0
  130. #define EGA_BLUE 1
  131. #define EGA_GREEN 2
  132. #define EGA_CYAN 3
  133. #define EGA_RED 4
  134. #define EGA_MAGENTA 5
  135. #define EGA_BROWN 20
  136. #define EGA_LIGHTGRAY 7
  137. #define EGA_DARKGRAY 56
  138. #define EGA_LIGHTBLUE 57
  139. #define EGA_LIGHTGREEN 58
  140. #define EGA_LIGHTCYAN 59
  141. #define EGA_LIGHTRED 60
  142. #define EGA_LIGHTMAGENTA 61
  143. #define EGA_YELLOW 62
  144. #define EGA_WHITE 63
  145.  
  146. #define SOLID_LINE   0
  147. #define DOTTED_LINE  1
  148. #define CENTER_LINE  2
  149. #define DASHED_LINE  3
  150. #define USERBIT_LINE 4
  151.  
  152. #define NORM_WIDTH   1
  153. #define THICK_WIDTH  3
  154.  
  155. #define DEFAULT_FONT      0    /* 8x8 bit mapped font */
  156. #define TRIPLEX_FONT      1
  157. #define SMALL_FONT        2
  158. #define SANS_SERIF_FONT   3
  159. #define GOTHIC_FONT       4
  160. #define SCRIPT_FONT       5
  161. #define SIMPLEX_FONT      6
  162. #define TRIPLEX_SCR_FONT  7
  163. #define COMPLEX_FONT      8
  164. #define EUROPEAN_FONT     9
  165. #define BOLD_FONT         10
  166.  
  167. #define HORIZ_DIR   0       /* left to right */
  168. #define VERT_DIR    1       /* bottom to top */
  169.  
  170. #define USER_CHAR_SIZE  0   /* user-defined char size */
  171.  
  172. enum fill_patterns {        /* Fill patterns for get/setfillstyle */
  173.     EMPTY_FILL,     /* fills area in background color */
  174.     SOLID_FILL,     /* fills area in solid fill color */
  175.     LINE_FILL,      /* --- fill */
  176.     LTSLASH_FILL,       /* /// fill */
  177.     SLASH_FILL,     /* /// fill with thick lines */
  178.     BKSLASH_FILL,       /* \\\ fill with thick lines */
  179.     LTBKSLASH_FILL,     /* \\\ fill */
  180.     HATCH_FILL,     /* light hatch fill */
  181.     XHATCH_FILL,        /* heavy cross hatch fill */
  182.     INTERLEAVE_FILL,    /* interleaving line fill */
  183.     WIDE_DOT_FILL,      /* Widely spaced dot fill */
  184.     CLOSE_DOT_FILL,     /* Closely spaced dot fill */
  185.     USER_FILL       /* user defined fill */
  186. };
  187.  
  188. #define COPY_PUT GrWRITE
  189. #define XOR_PUT  GrXOR
  190. #define OR_PUT   GrOR
  191. #define AND_PUT  GrAND
  192. /*      NOT_PUT  not available */
  193.  
  194. #define LEFT_TEXT   0
  195. #define CENTER_TEXT 1
  196. #define RIGHT_TEXT  2
  197. #define BOTTOM_TEXT 0
  198. #define TOP_TEXT    2
  199.  
  200. #define MAXCOLORS 15
  201.  
  202. struct palettetype {
  203.     unsigned char size;
  204.       signed char colors[MAXCOLORS+1];
  205. };
  206.  
  207. struct linesettingstype {
  208.     int            linestyle;
  209.     unsigned short upattern;    /* Note : BCC defines unsigned ! */
  210.     int            thickness;
  211. };
  212.  
  213. struct textsettingstype {
  214.     int font;
  215.     int direction;
  216.     int charsize;
  217.     int horiz;
  218.     int vert;
  219. };
  220.  
  221. struct fillsettingstype {
  222.     int pattern;
  223.     int color;
  224. };
  225.  
  226. /* This definition is compatible with the grx
  227.    definition 'int pts[][2]' used to define polygons */
  228. struct pointtype {
  229.     int x, y;
  230. };
  231.  
  232. struct viewporttype {
  233.     int left, top, right, bottom;
  234.     int clip;
  235. };
  236.  
  237. struct arccoordstype {
  238.     int x, y;
  239.     int xstart, ystart, xend, yend;
  240. };
  241.  
  242.  
  243. extern int           __gr_Mode;
  244. extern int           __gr_INIT;
  245. extern int           __gr_MaxMode;
  246. extern int           __gr_Result;
  247. extern int           __gr_X, __gr_Y;            /* graphics cursor pos */
  248. extern int           __gr_vpl, __gr_vpt,        /* actual viewport     */
  249.              __gr_vpr, __gr_vpb;
  250. extern int           __gr_color;                /* drawing color       */
  251. extern int           __gr_colorbg;              /* background color    */
  252. extern int           __gr_colorfill;            /* fill color          */
  253. extern int           __gr_WR;                   /* Write mode          */
  254. extern int           __gr_Xasp;                 /* Aspect ratio        */
  255. extern int           __gr_Yasp;
  256. extern GrPattern     __gr_fillpattern;
  257. extern int           __gr_fpatno;
  258. extern int           __gr_lstyle;
  259. extern int           __gr_clip;                 /* actual clipping state    */
  260. extern int           __gr_ADAPTER;              /* Adapter used             */
  261. extern char          __gr_fpatterns[][8];
  262. extern struct palettetype __gr_EGAdef;
  263. extern int           __gr_BGI_w;                /* Width, height and color  */
  264. extern int           __gr_BGI_h;                /* used in                  */
  265. extern int           __gr_BGI_c;                /* GRX_BGI_EMULATION mode   */
  266. extern int           _bold_font, _euro_font,    /* Linkable font files      */
  267.              _goth_font, _lcom_font,
  268.              _litt_font, _sans_font,
  269.              _scri_font, _simp_font,
  270.              _trip_font, _tscr_font;
  271.  
  272. #ifdef __cplusplus
  273. extern "C" {
  274. #endif
  275.  
  276. void     __gr_set_up_modes(void);
  277. void     __gr_drawpoly(int numpoints, void *polypoints, int close);
  278. void     set_BGI_mode(int *graphdriver, int *graphmode);
  279.  
  280. void     detectgraph(int *graphdriver,int *graphmode);
  281. void     initgraph(int *graphdriver, int *graphmode, char *pathtodriver);
  282. void     setgraphmode(int mode);
  283. char    *getmodename( int mode_number );
  284. void     graphdefaults(void);
  285. char    *getdrivername( void );
  286. char    *grapherrormsg(int errorcode);
  287. void     getviewsettings(struct viewporttype  *viewport);
  288. void     setviewport(int left, int top, int right, int bottom, int clip);
  289. void     getlinesettings(struct linesettingstype  *lineinfo);
  290. void     setlinestyle(int linestyle, unsigned upattern, int thickness);
  291. void     clearviewport(void);
  292. void     bar(int left, int top, int right, int bottom);
  293. void     bar3d(int left,int top,int right,int bottom,int depth, int topflag);
  294. void     rectangle(int left, int top, int right, int bottom);
  295. void     fillpoly(int numpoints, void *polypoints);
  296. void     sector(int x,int y,int stangle,int endangle,int xradius,int yradius);
  297. void     circle(int x, int y, int radius);
  298. void     ellipse(int x,int y,int stangle,int endangle,int xradius,int yradius);
  299. void     fillellipse( int x, int y, int xradius, int yradius );
  300. void     getarccoords(struct arccoordstype  *arccoords);
  301. void     floodfill(int x, int y, int border);
  302. void     line(int x1, int y1, int x2, int y2);
  303. void     setfillpattern( char  *upattern, int color);
  304. void     setfillstyle(int pattern, int color);
  305. void     getimage(int left, int top, int right, int bottom, void  *bitmap);
  306. void     putimage(int left, int top,  void  *bitmap, int op);
  307. unsigned imagesize(int left, int top, int right, int bottom);
  308. void     gettextsettings(struct textsettingstype  *texttypeinfo);
  309. void     settextjustify(int horiz, int vert);
  310. void     settextstyle(int font, int direction, int charsize);
  311. void     setrgbpalette(int color, int red, int green, int blue);
  312. void     setusercharsize(int multx, int divx, int multy, int divy);
  313. void     outtext(char *textstring);
  314. void     outtextxy(int x, int y, char *textstring);
  315. int      textheight( char *textstring);
  316. int      textwidth( char  *textstring);
  317.  
  318. int      registerbgifont(void *font);
  319. int      installuserfont(char *name);
  320.  
  321. void     getpalette(struct palettetype  *palette);
  322. void     setallpalette( struct palettetype  *palette);
  323. void     setpalette(int colornum, int color);
  324.  
  325. #ifdef __cplusplus
  326. }
  327. #endif
  328.  
  329. #define __ABS(a) (a<0 ? -a : a)
  330. #define __INL__ __inline__ static
  331. #define YR(r)  ((r)*__gr_Xasp/__gr_Yasp)
  332. #define XR(r)  (r)
  333.  
  334. /* ----------------------------------------------------------------- */
  335. __INL__ void restorecrtmode(void)
  336. {
  337.   GrSetMode(GR_default_text);
  338. }
  339.  
  340. /* ----------------------------------------------------------------- */
  341. __INL__ void closegraph(void)
  342. {
  343.   restorecrtmode();
  344.   __gr_INIT = FALSE;
  345. }
  346.  
  347. /* ----------------------------------------------------------------- */
  348. __INL__ int getgraphmode(void)
  349. {
  350.   return (__gr_INIT ? __gr_Mode : (__gr_Result=grNoInitGraph));
  351. }
  352.  
  353. /* ----------------------------------------------------------------- */
  354. __INL__ int getmaxmode(void)
  355. {
  356.   __gr_set_up_modes();
  357.   return __gr_MaxMode;
  358. }
  359.  
  360. /* ----------------------------------------------------------------- */
  361. __INL__ void getmoderange(int gd, int *lomode, int *himode)
  362. {
  363.   *lomode = 0;
  364.   *himode = getmaxmode();
  365. }
  366.  
  367. /* ----------------------------------------------------------------- */
  368. __INL__ int graphresult(void) {
  369.   int res = (__gr_INIT ? __gr_Result : grNoInitGraph);
  370.   __gr_Result = grOk;
  371.   return res;
  372. }
  373.  
  374. /* ----------------------------------------------------------------- */
  375. __INL__ void moveto(int x, int y) {
  376.   __gr_X = x; __gr_Y = y;
  377. }
  378.  
  379. /* ----------------------------------------------------------------- */
  380. __INL__ void moverel(int dx, int dy) {
  381.   moveto( __gr_X + dx, __gr_Y + dy);
  382. }
  383.  
  384. /* ----------------------------------------------------------------- */
  385. __INL__ void cleardevice(void) {
  386.   if (__gr_INIT) {
  387.     GrClearScreen(__gr_colorbg);
  388.     moveto( 0, 0);
  389.   } else
  390.     __gr_Result = grNoInitGraph;
  391. }
  392.  
  393. /* ----------------------------------------------------------------- */
  394. __INL__ int getmaxcolor(void) {
  395.   if (__gr_INIT) return GrNumColors()-1;
  396.   __gr_Result = grNoInitGraph;
  397.   return 0;
  398. }
  399.  
  400. /* ----------------------------------------------------------------- */
  401. __INL__ int getbkcolor(void) {
  402.   return __gr_colorbg;
  403. }
  404.  
  405. /* ----------------------------------------------------------------- */
  406. __INL__ int getcolor(void) {
  407.   return __gr_color;
  408. }
  409.  
  410. /* ----------------------------------------------------------------- */
  411. __INL__ void setbkcolor(int color) {
  412.   __gr_colorbg= color;
  413. }
  414.  
  415. /* ----------------------------------------------------------------- */
  416. __INL__ void setcolor(int color) {
  417.   __gr_color= color;
  418. }
  419.  
  420. /* ----------------------------------------------------------------- */
  421. __INL__ void setwritemode( int mode ) {
  422.   __gr_WR = (mode & (GrXOR | GrOR | GrAND));
  423. }
  424.  
  425. /* ----------------------------------------------------------------- */
  426. __INL__ int getx(void) {
  427.   return __gr_X;
  428. }
  429.  
  430. /* ----------------------------------------------------------------- */
  431. __INL__ int gety(void) {
  432.   return __gr_Y;
  433. }
  434.  
  435. /* ----------------------------------------------------------------- */
  436. __INL__ int getmaxx(void) {
  437.   return GrScreenX()-1;
  438. }
  439.  
  440. /* ----------------------------------------------------------------- */
  441. __INL__ int getmaxy(void) {
  442.   return GrScreenY()-1;
  443. }
  444.  
  445. /* ----------------------------------------------------------------- */
  446. __INL__ unsigned getpixel(int x, int y) {
  447.   if (__gr_INIT) return GrPixel(__gr_vpl+x,__gr_vpt+y);
  448.   __gr_Result = grNoInitGraph;
  449.   return 0;
  450. }
  451.  
  452. /* ----------------------------------------------------------------- */
  453. __INL__ void putpixel(int x, int y, int color) {
  454.   if (__gr_INIT) GrPlot( __gr_vpl+x, __gr_vpt+y, color);
  455.         else __gr_Result = grNoInitGraph;
  456. }
  457.  
  458. /* ----------------------------------------------------------------- */
  459. __INL__ void linerel(int dx, int dy) {
  460.   line(__gr_X, __gr_Y, __gr_X+dx, __gr_Y+dy);
  461. }
  462.  
  463. /* ----------------------------------------------------------------- */
  464. __INL__ void lineto(int x, int y) {
  465.   line( __gr_X, __gr_Y, x, y);
  466. }
  467.  
  468. /* ----------------------------------------------------------------- */
  469. __INL__ void  drawpoly(int numpoints, void *polypoints) {
  470.   __gr_drawpoly(numpoints, polypoints, FALSE);
  471. }
  472.  
  473. /* ----------------------------------------------------------------- */
  474. __INL__ void  arc(int x, int y, int stangle, int endangle, int radius) {
  475.   ellipse(x,y,stangle,endangle,radius,radius);
  476. }
  477.  
  478. /* ----------------------------------------------------------------- */
  479. #ifdef _TP2BCC_
  480. #  define getaspectratio(xa,ya) ({*(xa)=__gr_Xasp; *(ya)=__gr_Yasp; })
  481. #else
  482. __INL__ void getaspectratio(int *xasp, int *yasp) {
  483.    *xasp = __gr_Xasp; *yasp = __gr_Yasp;
  484. }
  485. #endif
  486.  
  487. /* ----------------------------------------------------------------- */
  488. __INL__ void setaspectratio( int xasp, int yasp ) {
  489.   __gr_Xasp = xasp; __gr_Yasp = yasp;
  490. }
  491.  
  492. /* ----------------------------------------------------------------- */
  493. __INL__ void getfillsettings(struct fillsettingstype  *fillinfo) {
  494.   fillinfo->pattern = __gr_fpatno;
  495.   fillinfo->color   = __gr_colorfill;
  496. }
  497.  
  498. /* ----------------------------------------------------------------- */
  499. __INL__ void getfillpattern(char *pattern) {
  500.   memcpy(pattern, &__gr_fpatterns[USER_FILL], 8);
  501. }
  502.  
  503. /* ----------------------------------------------------------------- */
  504. __INL__ void pieslice(int x, int y, int stangle, int endangle, int radius) {
  505.   sector(x,y,stangle,endangle,radius,radius);
  506. }
  507.  
  508. /* ----------------------------------------------------------------- */
  509. __INL__ unsigned setgraphbufsize(unsigned bufsize) {
  510.   return 4096; /* BCC default value */
  511. }
  512.  
  513. /* ----------------------------------------------------------------- */
  514. __INL__ struct palettetype *getdefaultpalette(void) {
  515.   return &__gr_EGAdef;
  516. }
  517.  
  518. /* ----------------------------------------------------------------- */
  519. __INL__ int getpalettesize(void) {
  520.   __gr_set_up_modes();
  521.   if (__gr_ADAPTER == GR_HERC) return 0;
  522.               else return 16;
  523. }
  524.  
  525.  
  526. /* ----------------------------------------------------------------- */
  527. __INL__ int installbgidriver(char *name, void *detect)
  528. {
  529.   return grError;
  530. }
  531.  
  532. /* ----------------------------------------------------------------- */
  533. __INL__ int registerfarbgidriver(void *driver)
  534. {
  535.   return grError;
  536. }
  537.  
  538. /* ----------------------------------------------------------------- */
  539. __INL__ int registerfarbgifont(void *font)
  540. {
  541.   return registerbgifont( font);
  542. }
  543.  
  544. /* ----------------------------------------------------------------- */
  545. __INL__ void setactivepage(int page) { ; }
  546.  
  547. /* ----------------------------------------------------------------- */
  548. __INL__ void setvisualpage(int page) { ; }
  549.  
  550. /* ----------------------------------------------------------------- */
  551. __INL__ void set_BGI_mode_whc(int *gd, int *gm,
  552.                   int width, int height, int colors) {
  553.   __gr_BGI_w = width;
  554.   __gr_BGI_h = height;
  555.   __gr_BGI_c = colors;
  556.   *gd        = NATIVE_GRX;
  557.   *gm        = GRX_BGI_EMULATION;
  558. }
  559.  
  560. /* ----------------------------------------------------------------- */
  561.  
  562. #ifndef HOLD_GR_DEFS
  563. #  undef __ABS
  564. #  undef __INL__
  565. #  undef YR
  566. #  undef XR
  567. #endif
  568.  
  569. #endif
  570. 
  571.