home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Homebrewer's Handbook / vr.iso / vr386 / f3dkitd.h < prev    next >
C/C++ Source or Header  |  1996-03-19  |  7KB  |  166 lines

  1. /* Prototypes for low-level graphics routines */
  2.  
  3. // ALL ROUTINES BY DAVE STAMPE
  4. // These serve for both loadable and linked video drivers
  5.  
  6. /*
  7.  This code is part of the VR-386 project, created by Dave Stampe.
  8.  VR-386 is a desendent of REND386, created by Dave Stampe and
  9.  Bernie Roehl.  Almost all the code has been rewritten by Dave
  10.  Stampre for VR-386.
  11.  
  12.  Copyright (c) 1994 by Dave Stampe:
  13.  May be freely used to write software for release into the public domain
  14.  or for educational use; all commercial endeavours MUST contact Dave Stampe
  15.  (dstampe@psych.toronto.edu) for permission to incorporate any part of
  16.  this software or source code into their products!  Usually there is no
  17.  charge for under 50-100 items for low-cost or shareware products, and terms
  18.  are reasonable.  Any royalties are used for development, so equipment is
  19.  often acceptable payment.
  20.  
  21.  ATTRIBUTION:  If you use any part of this source code or the libraries
  22.  in your projects, you must give attribution to VR-386 and Dave Stampe,
  23.  and any other authors in your documentation, source code, and at startup
  24.  of your program.  Let's keep the freeware ball rolling!
  25.  
  26.  DEVELOPMENT: VR-386 is a effort to develop the process started by
  27.  REND386, improving programmer access by rewriting the code and supplying
  28.  a standard API.  If you write improvements, add new functions rather
  29.  than rewriting current functions.  This will make it possible to
  30.  include you improved code in the next API release.  YOU can help advance
  31.  VR-386.  Comments on the API are welcome.
  32.  
  33.  CONTACT: dstampe@psych.toronto.edu
  34. */
  35.  
  36.  
  37.  
  38. #define MAIN_VGA  1  /* for multi-VGA only */
  39. #define LEFT_VGA  2
  40. #define RIGHT_VGA 4
  41. #define ALL_VGA   7
  42.  
  43. extern void far VGA_select(int card);    // select in multiVGA card
  44.  
  45. extern void *far screen_data(void);    // returns pointer to driver data
  46.  
  47. extern void far vsync(void);            /* pause till vert. retrace */
  48.  
  49. extern void far set_vpage(int page);    /* set video page thru BIOS */
  50.  
  51.  
  52. #define PUT 0        /* defines of VGA write modes */
  53. #define AND 1           /* for use with setup_hdwe()  */
  54. #define OR  2           /* only 0 supported for most drivers */
  55. #define XOR 3
  56.  
  57. extern void far setup_hdwe(int mode);  /* setup VGA for bunch of line */
  58.                        /* or poly draws: once per set */
  59.  
  60. extern void far reset_hdwe(void);  /* reset VGA to BIOS state after drawing */
  61.  
  62.              /* clear video page to solid color: 10 mS */
  63.              /* returns -1 if bad page #         */
  64. extern int far clr_page(int page, int color);
  65.  
  66.             /* copy one page to another for use as */
  67.             /* background: 21 mS per call          */
  68.             /* returns -1 if bad page #            */
  69. extern int far copy_page(int source, int dest);
  70.  
  71.             /* fast VGA line draw: about 15600 24-pixel */
  72.             /* vectors/sec (horizontal much faster)     */
  73. extern void far vgaline(int x1, int y1, int x2, int y2, int color);
  74.  
  75.             /* VGA point set; no clipping */
  76. extern void far vgapoint(int x, int y, int color);
  77.  
  78.             /* does C-S clipping and draws line   */
  79. extern void far clipline(int x1, int y1, int x2, int y2, int color);
  80.  
  81. extern void far set_gmode(int mode);  /* enters graphics mode
  82.         //  (some drivers accept argument), clears screen */
  83.  
  84. extern void far exit_gmode(void);     /* exits to text mode */
  85.  
  86. extern void far set_vpage(int page);   /* set page for display */
  87.  
  88. extern int far set_drawpage(int page);    /* set page for drawing on */
  89.  
  90.             /* N_SIDED POLY DRAW for up to 20-sided  */
  91.             /* convex polygons.  Pass pointer to int */
  92.             /* array with X, Y coords in that order  */
  93.             /* and count.  No clipping, CCW order    */
  94.  
  95. extern void far fastpoly(int count, int far *pcoords, int color);
  96.  
  97.             /* same as fastpoly() but with color cycling */
  98.             /* and masking (halftone).  Color cycles in  */
  99.             /* its lowest 4 bits, up then down.  Bit 8   */
  100.             /* has been added as a "sign" bit for the    */
  101.             /* initial cycle direction. 0000000SHHHHCCC  */
  102.             /* the mask is XOR'ed with the toggle every  */
  103.             /* line for 2x8 halftone patterns            */
  104. extern void far m_fastpoly(int count, int far *pcoords, int color, int gmask, int toggle);
  105.  
  106.             /* print text in foreground only-- */
  107.             /* reversed = 1 for right-to-left  */
  108.             /* with x now right side of text   */
  109. extern void far printxyr(int x, int y, int color, char far *pstring, int reversed);
  110.  
  111.             /* draw "+" cursor on screen      */
  112.             /* save s screen under cursor       */
  113.             /* if "color" is negative, draws double cursor */
  114.             /* "savebuff" is page number      */
  115. extern void far draw_cursor(int x, int y, int color, int savebuff);
  116.  
  117.                  /* restores 8x8 area saved when   */
  118.                  /* cursor was drawn               */
  119. extern void far erase_cursor(int savebuff);
  120.  
  121.             /* copy any byte-aligned rectangle  */
  122.             /* this is evey 4 pixels for Y mode */
  123.             /* but every 8 for 16-color mode    */
  124.             /* x coords (left) are truncated to */
  125.             /* left byte boundary: x size is    */
  126.             /* bumped up to next full byte count */
  127. extern int far copy_block(int spage, int sx, int sy,  /* source */
  128.               int dpage, int dx, int dy,  /* dest   */
  129.               int xs, int ys);            /* # lines, pixels */
  130.  
  131.             /* clear any byte-aligned block       */
  132.             /* 15-30% slower than full page clear */
  133.             /* left edge rounded down, right edge */
  134.             /* rounded up to nearest byte boundary */
  135. extern int far clr_block(int left, int top, int right, int bottom,
  136.                int page, int color);
  137.  
  138.             /* 3 entries each for n colors: RGB, 0->63 */
  139.             /* load always starts with slot 0          */
  140.             /* set pal=NULL for default (still give n) */
  141.             /* bw=1 will transform palette into B&W    */
  142.             /* first is what entry to start with       */
  143. extern void far load_DAC_colors(char far *pal, int n, int bw, int first);
  144.  
  145. extern void far read_DAC_colors(char far *pal, int n, int first);
  146.  
  147.             // sets the video segment: might be useful
  148.             // for protected mode versions
  149. extern void far set_video_segment(unsigned seg);
  150.  
  151.             // reads a screen line to a buffer
  152.             // as a sequence of byte pixel-values
  153.             // Returns buffer size: pass NULL buffer
  154.             // to get the size.  Older drivers do not support it
  155. extern unsigned far read_video_line(char far *buff, unsigned line);
  156.  
  157.             // writes a screen line to a buffer
  158.             // as a sequence of byte pixel-values
  159.             // Returns buffer size: pass NULL buffer
  160.             // to get the size.  Older drivers do not support it
  161. extern unsigned far write_video_line(char far *buff, unsigned line);
  162.  
  163.  
  164.  
  165. /* End of f3dkitd.h */
  166.