home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / graf / fract5.zip / YOURVID.C < prev   
C/C++ Source or Header  |  1989-10-16  |  4KB  |  110 lines

  1. /*
  2.  
  3.     Roll-Your-Own video mode (DOTMODE 19) routines.
  4.     
  5. Even if you don't have an assembler, you can add your own video-mode
  6. routines to FRACTINT by using the "FRACTINT BATCH=CONFIG" option to add
  7. a video mode of the appropriate resolution that uses dotmode 19 (which
  8. calls these routines to perform all the dirty work) and modifying
  9. these routines accordingly.  The four routines are:
  10.  
  11.  startvideo()    Do whatever you have to do to throw your adapter into
  12.                  the appropriate video mode (in case it can't be accomplished
  13.                  the "normal" way, with INT 10H and the AX/BX/CX/DX values
  14.                  available via FRACTINT.CFG or FARVIDEO.ASM).  This routine
  15.                  will typically be empty (in which case the AX/BX/CX/DX values
  16.                  in FRACTINT.CFG or FARVIDEO.ASM must be encoded appropriately
  17.                  to accomplish the task), but some adapters like the 8514/A
  18.                  and TARGA need special handling which would go here.
  19.                  If you DO have to put something here, you should encode
  20.                  AX = 0xFF so as to effectively convert the regular
  21.                  video-switching code inside VIDEO.ASM to use 
  22.                  an invalid INT 10H call - "do-nothing" logic. 
  23.  
  24.  endvideo()      do whatever you have to do to get it out of that
  25.                  special video mode (in case 'setvideo(3,0,0,0)'
  26.                  won't do it) - this routine will typically be empty,
  27.                  but some adapters like the 8514/A and TARGA need
  28.                  special handling which would go here.
  29.  
  30.  writevideo(int x, int y, int color)  write a pixel using color number
  31.                  'color' at screen coordinates x,y (where 0,0 is the
  32.                  top left corner, and xdots,0 is the top right corner)
  33.  
  34.  int readvideo(int x, int y)  return the color number of pixel x,y
  35.                  using the same coordinate logic as 'writevideo()'
  36.  
  37.  
  38. Finally, note that, although these example routines are written in "C",
  39. they could just as easily (or maybe more easily!) have been written
  40. in assembler.
  41.  
  42. */
  43.  
  44. /* external variables (set in the FRACTINT.CFG file, but findable here */
  45.  
  46. extern    int    dotmode;        /* video access method (= 19)      */
  47. extern    int    oktoprint;        /* set to 0 if printf() won't work */
  48. extern    int    xdots, ydots;        /* total # of dots on the screen   */
  49. extern    int    colors;            /* maximum colors available        */
  50.  
  51. /* for demo purposes, these routines use VGA mode 13h - 320x200x256 */
  52.  
  53. #include <dos.h>
  54.  
  55. int startvideo()
  56. {
  57.  
  58. /* assume that the encoded values in FRACTINT.CFG or FARVIDEO.ASM
  59.    have been set to accomplish this (AX = 0x13, BX = CX = DX = 0)  */
  60.  
  61. return(0);                /* set flag: video started */
  62.  
  63. /*   or, we could have done this instead and encoded AX = 0xFF
  64.      in FRACTINT.CFG/FARVIDEO.ASM: 
  65.  
  66. union REGS regs;
  67.  
  68. regs.x.ax = 0x13;
  69. int86(0x10,®s,®s);
  70.  
  71. */
  72.  
  73. }
  74.  
  75. int endvideo()
  76. {
  77.  
  78. return(0);                /* set flag: video ended */
  79.  
  80. }
  81.  
  82. void writevideo(int x, int y, int color)
  83. {
  84.  
  85. union REGS regs;
  86.  
  87. regs.h.ah = 0x0c;            /* invoke INT 10H with AH = 0CH */
  88. regs.h.al = color;
  89. regs.x.bx = 0;
  90. regs.x.cx = x;
  91. regs.x.dx = y;
  92. int86(0x10,®s,®s);
  93.  
  94. }
  95.  
  96. unsigned int readvideo(int x, int y)
  97. {
  98.  
  99. union REGS regs;
  100.  
  101. regs.x.ax = 0x0d00;            /* invoke INT 10H with AH = 0DH */
  102. regs.x.bx = 0;
  103. regs.x.cx = x;
  104. regs.x.dx = y;
  105. int86(0x10,®s,®s);
  106.  
  107. return((unsigned int)regs.h.al);    /* return pixel color */
  108.  
  109. }
  110.