home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / cbgi111 / src / bgi.h next >
Encoding:
C/C++ Source or Header  |  1990-05-28  |  10.5 KB  |  295 lines

  1. /********************************** BGI.H *******************************/
  2. /*    BGI driver header file.  Contains defines and prototypes     */
  3. /* specific to driver development.                    */
  4. /*                                    */
  5. /*    V 1.00 20/05/90 Robert Adsett Release version.  Clean up     */
  6. /*                comments.                */
  7. /*    V 1.10 27/05/90 Robert Adsett Add Extended memory functions for    */
  8. /*                use with AT class computers with video    */
  9. /*                card memory mapped above the 1M mark.    */
  10. /************************************************************************/
  11.  
  12. #define OUT_OF_RANGE -1            /* Error in clip.        */
  13.  
  14. #define COPY        0        /* Drawing modes.        */
  15. #define XOR        1
  16. #define OR        2
  17. #define AND        3
  18. #define NEGATE        4
  19.  
  20. #define NORMAL_PATH    0        /* Character paths.        */
  21. #define VERT_PATH    1
  22. #define DOWN_PATH    2        /* O.K. But what do they mean     */ 
  23.                     /*   by down?            */
  24.  
  25. #define SOLID_LINE    0              /* Solid Line Style.        */
  26. #define DOTTED_LINE    1        /* Dotted Line.            */
  27. #define CENTRE_LINE    2        /* Centre Line.            */
  28. #define DASHED_LINE    3        /* Dashed line.            */
  29. #define USER_LINE    4        /* User-defined line style.    */
  30.  
  31.         /*   These are equivalent to the Borland srrors of the    */
  32.         /* same name.                        */
  33. #define    grOk              0
  34. #define    grNoInitGraph         -1
  35. #define    grNotDetected         -2
  36. #define    grFileNotFound         -3
  37. #define    grInvalidDriver      -4
  38. #define    grNoLoadMem         -5
  39. #define    grNoScanMem         -6
  40. #define    grNoFloodMem         -7
  41. #define    grFontNotFound         -8
  42. #define    grNoFontMem         -9
  43. #define    grInvalidMode        -10
  44. #define    grError         -11       /* Generic error.        */
  45. #define    grIOerror        -12
  46. #define    grInvalidFont        -13
  47. #define    grInvalidFontNum    -14
  48. #define    grInvalidVersion    -18
  49.  
  50. typedef void far (*FRFPTR)( void );    /* Pointer to Void/Void Funct    */
  51. typedef void  (*NRFPTR)( void );    /* Pointer to Void/Void Funct    */
  52.  
  53. /*                                    */
  54. /*    The following C structure defines a Device Status Block.    */
  55. /*                                    */
  56.  
  57. typedef struct {
  58.   char   stat;                /* Current device status.    */
  59.   unsigned char   devtype;        /* Device Type Identifier.    */
  60.   unsigned int      xres;            /* Device Full Resolution in X    */
  61.   unsigned int      yres;            /* Device Full Resolution in Y    */
  62.   unsigned int      xefres;        /* Device Effective X Resolution*/
  63.   unsigned int      yefres;        /* Device Effective Y Resolution*/
  64.   unsigned int      xinch;        /* Device X Size in inches*1000 */
  65.   unsigned int      yinch;        /* Device Y Size in inches*1000 */
  66.   unsigned int      aspec;        /* Aspect Ratio * 10000        */
  67.   unsigned char   chsizx;        /* Standard char size X        */
  68.   unsigned char   chsizy;        /* Standard char size Y        */
  69.   unsigned char   fcolors;        /* Number of foreground colors    */
  70.   unsigned char   bcolors;        /* Number of background colors    */
  71. } STATUS;
  72.  
  73. /*                                    */
  74. /*    The following structure defines a palette record.        */
  75. /*                                    */
  76.  
  77. typedef struct {
  78.   unsigned char length;            /* # of color entries in palette*/
  79.   unsigned char color[16];        /* Up to 16 color entries    */
  80.   } PALETTE;
  81.  
  82. /*                                    */
  83. /*    The following structure defines a utility function table.    */
  84. /*                                    */
  85.  
  86. typedef struct {
  87.   NRFPTR  goto_graph;            /* Enter graphics mode function */
  88.   NRFPTR  exit_graph;            /* Leave graphics mode function */
  89.   NRFPTR  putpix;            /* Write a pixel function    */
  90.   NRFPTR  getpix;            /* Read a pixel function    */
  91.   NRFPTR  bits_per_pixel;        /* Bits per pixel value        */
  92.   NRFPTR  set_page;            /* Set the active drawing page    */
  93.   NRFPTR  set_visual;            /* Set the active display page    */
  94.   NRFPTR  write_mode;            /* Set the current write mode    */
  95.   } UTILITIES;
  96.  
  97. /*                                    */
  98. /*    Device information table structure.                */
  99. /*                                    */
  100.  
  101. struct DIT {
  102.     unsigned char    background;
  103.     unsigned char   init;
  104.     char dummy[64];
  105.     };
  106.  
  107. /*  Bitmap characters definition format.                */
  108. typedef struct { unsigned char row[8]; } CHAR_TABLE_ENTRY;
  109.  
  110. /*  Fillpattern definition format.                    */
  111. typedef struct { unsigned char row[8]; } FILLPATTERN;
  112.  
  113. extern int MAXY, MAXX, MINY, MINX;    /* Clipping limits.        */
  114. extern unsigned int CP_X, CP_Y;        /* Current position.        */
  115. extern unsigned int char_size, char_path; /* Character size & path.    */
  116. extern unsigned char current_colour,     /* Current draw,        */
  117.              fill_colour,     /* fill, and            */
  118.              background_colour;    /* background colours.        */
  119. extern unsigned int current_line_style;    /* Current line style.        */
  120. extern int current_line_width;        /* Current line width.        */
  121. extern const unsigned int line_style_mask[16];    /* Bit mask for line    */
  122.                         /*  style.        */
  123. extern int current_write_mode;        /* Current draw mode.        */
  124. extern const CHAR_TABLE_ENTRY far * const char_def;
  125.                     /* Pointer to Char defs in ROM.    */
  126. extern const FILLPATTERN def_patterns[12];   /* Standard fill patterns.    */
  127.  
  128. /* Function prototype for the driver functions.  Required functions.    */
  129.  
  130. long install(             /* Install, but do not init device.    */
  131.     unsigned int mode,     /* Mode to operate in/guery name of.    */
  132.     char command         /* Subcommand (Install, query, name).    */
  133.     );            /* Return varies with subcommand.    */
  134.  
  135. void init(             /* Init (maybe) the device.        */
  136.     unsigned int dit_offset,/* Address of Device Information Table.    */
  137.     unsigned int dit_segment
  138.     );
  139. void clear( void );        /* Clear screen.             */
  140. void post( void );        /* Back to test mode.            */
  141. void move(            /* Move to new current position (CP).    */ 
  142.     int x,             /* Coordinates of new position.        */
  143.     int y
  144.     );
  145. void draw(            /* Draw a line from CP to a new CP.    */
  146.     int x,            /* Coordinates to draw to, becomes new     */
  147.     int y            /*   CP.                */
  148.     );
  149. void vect(            /* Draw a line.                */
  150.     int x1,            /* Starting point.            */
  151.     int y1,
  152.     int x2,            /* Ending point.            */
  153.     int y2
  154.     );
  155. void patbar(            /* Draw but don't outline area.  Use    */
  156.     int x1,            /* current pattern.            */
  157.     int y1,            /* Upper left corner.            */
  158.     int x2,            /* Lower right corner.            */
  159.     int y2
  160.     );
  161. void palette( int flag_index, int red_colour,  int blue, int green);
  162. void allpalette( unsigned int pptr_offset, unsigned int pptr_segment);
  163. void color(            /* Set new drawing colours.        */
  164.     char new_fill_colour,    /* Colour to fill with.            */
  165.     char new_draw_colour    /* Colour to draw with.            */
  166.     );
  167. void fillstyle(            /* Set current fillstyle.        */
  168.     unsigned char pattern,    /* Pattern, 0xff -> user defined.    */
  169.     unsigned int pptr_offset,    /* Address of user defined    */
  170.     unsigned int pptr_segment    /* pattern.            */
  171.     );
  172. void linestyle(            /* Set current linestyle.        */
  173.     char style,        /* Line pattern.            */
  174.     int pattern,        /* User defined pattern.        */
  175.     int width        /* Line width (1, 3).            */
  176.     );
  177. long textstyle(            /* Set text style.            */
  178.     char number,        /* Font number.                */
  179.     char path,        /* Drawing path.            */
  180.     int xsize,        /* Requested X size.            */
  181.     int ysize        /* Requested Y size.            */
  182.     );            /* Returns actual x/y size in         */
  183.                 /*  upper/lower int of a long.        */
  184. void text(            /* Draw text.                */
  185.     int length,        /* Number of characters.        */
  186.     unsigned int offset,    /* Pointer to string.            */
  187.     unsigned int segment
  188.     );
  189. void floodfill(            /* Flood fill an area.            */
  190.     int x,            /* Seed point.                */
  191.     int y,
  192.     unsigned char boundary    /* Colour of the boundary.        */
  193.     );
  194. void *bitmaputil( void );    /* Return a pointer to the bit map    */
  195.                 /*  utility table.            */
  196. void restorebitmap(        /* Restore a bit map.            */
  197.     char mode,        /* Write mode.                */
  198.     unsigned int segment,    /* Bitmap buffer address.        */
  199.     unsigned int offset,
  200.     int x1,            /* Where to put it.            */
  201.     int y1,
  202.     int x2,
  203.     int y2
  204.     );
  205. void savebitmap(        /* Save a bitmap.            */
  206.     unsigned int buff_segment,    /* Bitmap buffer address.    */
  207.     unsigned int buff_offset,
  208.     int x1,            /* Where to get it from.        */
  209.     int y1,
  210.     int x2,
  211.     int y2
  212.     );
  213. void setclip(            /* Set a clipping area.            */
  214.     int x1,            /* Corners to clip to.            */
  215.     int y1,
  216.     int x2,
  217.     int y2
  218.     );
  219. char get_pixel(            /* Get the colour of the pixel.        */
  220.     int x,            /* At...                */
  221.     int y
  222.     );            /* Returns the colour.            */
  223. void set_pixel(            /* Set the colour of a pixel.        */
  224.     int x,            /* At...                */
  225.     int y,
  226.     char colour        /* Colour to set it to.            */
  227.     );
  228. long textsiz(            /* Get the (pixel) length of a string.    */
  229.     int length,        /* Number of characters in the string.    */
  230.     unsigned int offset,    /* Address of the string.        */
  231.     unsigned int segment
  232.     );
  233. long color_query(        /* Get colour info.            */
  234.     char command_type    /* Type of info wanted.            */
  235.     );            /* Returns the pointer to the default     */
  236.                 /*   palette or the palette size.    */
  237.  
  238. int line( int X, int Y, int X1, int Y1);
  239. /************************************************************************/
  240. /*  Bit map utility functions.                        */
  241. /************************************************************************/
  242. void enter_graphics( void );    /* Enter pixel graphics mode.        */
  243. void leave_graphics( void );    /* Leave pixel graphics mode.        */
  244. int  bits_per_pixel( void );    /* Return the number of bits per pixel. */
  245. void putpix(            /* Draw a pixel.            */
  246.     int x,            /* At ..                */
  247.     int y,
  248.     char colour        /* Colour of the pixel.            */
  249.     );
  250. char getpix(            /* Read a pixel at a point.        */
  251.     int x,            /* Here...                */
  252.     int y
  253.     );            /* Returns colour of the pixel.        */
  254. void set_page( char page);    /* Set the active drawing page.        */
  255. void set_visual( char page);    /* Set the active display page.        */
  256. void set_write_mode( int mode);    /* Set the current writeing mode.    */
  257. /************************************************************************/
  258. /*  End bit map utility functions.                    */
  259. /************************************************************************/
  260.  
  261. /*    These are shell functions.  These are actually    */
  262. /*    far functions.  We are labelling as near for    */
  263. /*    convienence in setting up vectors in the bitmap    */
  264. /*    utility table.                    */
  265.  
  266. void dispatch_enter_graphics( void);
  267. void dispatch_leave_graphics( void);
  268. void dispatch_putpix( void);
  269. void dispatch_getpix( void);
  270. void dispatch_set_page( void);
  271. void dispatch_set_visual( void);
  272. void dispatch_set_write_mode( void);
  273. void dispatch_bits_per_pixel( void);
  274.  
  275. /* Utility functions.  Available for your use.                */
  276.  
  277. void xor_mem( void far *, int, void far *, int);
  278. void or_mem( void far *, int, void far *, int);
  279. void and_mem( void far *, int, void far *, int);
  280. void neg_mem( void far *, int, void far *, int);
  281. void copy_mem( void far *, int, void far *, int);
  282. void set_mem( void far *, unsigned, unsigned);
  283.  
  284. int copy_from_extended(     /* Copy from extended to regular memory.*/
  285.         void far *destination,     /* Destination address.            */
  286.     unsigned long source,    /* Source address, absolute form.    */
  287.     int words        /* Number of words to transfer.        */
  288.     );
  289.  
  290. int copy_to_extended(         /* Copy from regular to extended memory.*/
  291.         unsigned long destination,  /* Destination address, absolute form.*/
  292.     void far *source,     /* Source address.            */
  293.     int words        /* Number of words to transfer.        */
  294.     );
  295.