home *** CD-ROM | disk | FTP | other *** search
/ HOT Scene Stuff / hotscenestuffzyklop1996.iso / demos / sunknown / vx.cpp < prev    next >
C/C++ Source or Header  |  1994-04-06  |  2KB  |  126 lines

  1. // VX.CPP ///////////////////////////////////////////////////////////////////
  2.  
  3. // Thomas H.
  4.  
  5. // INCLUDES /////////////////////////////////////////////////////////////////
  6.  
  7. #include <dos.h>
  8. #include <stdlib.h>
  9.  
  10. #include "vx.h"
  11.  
  12. // METHODS //////////////////////////////////////////////////////////////////
  13.  
  14. // FRAME
  15.  
  16. void vx_C::frame(void)
  17. {
  18.   while (inportb(0x3da)&8);
  19.   while (!(inportb(0x3da)&8));
  20. }
  21.  
  22. // WRITEPIXEL
  23.  
  24. void vx_C::writepixel(word pos,byte plane, byte color)
  25. {
  26.   asm mov cl,plane
  27.   asm mov ax,0x0100+MAP_MASK
  28.   asm shl ah,cl
  29.   asm mov dx,SC_INDEX
  30.   asm out dx,ax
  31.   asm mov di,pos
  32.   asm mov ax,0xa000
  33.   asm mov es,ax
  34.   asm mov al,color
  35.   asm mov es:[di],al
  36. }
  37.  
  38. // SETOFFSET
  39.  
  40. void vx_C::setoffset(word newoffset)
  41. {
  42.   if (offset==newoffset)
  43.     return;
  44.   if ((offset&255)==(newoffset&255))
  45.   {
  46.     asm mov ax,newoffset
  47.     asm mov al,0x0c
  48.     asm mov dx,CRTC_INDEX
  49.     asm out dx,ax
  50.   }
  51.   else
  52.   {
  53.     asm mov ax,newoffset
  54.     asm mov bh,al
  55.     asm mov ch,ah
  56.     asm mov bl,0x0d
  57.     asm mov cl,0x0c
  58.     asm mov dx,CRTC_INDEX
  59.     asm mov ax,bx
  60.     asm cli
  61.     asm out dx,ax
  62.     asm mov ax,cx
  63.     asm out dx,ax
  64.     asm sti
  65.   }
  66.   offset=newoffset;
  67. }
  68.  
  69. // SETRGB
  70.  
  71. void vx_C::setrgb(byte color, byte red,byte green,byte blue)
  72. {
  73.   outportb(0x3c8,color);
  74.   outportb(0x3c9,red);
  75.   outportb(0x3c9,green);
  76.   outportb(0x3c9,blue);
  77. }
  78.  
  79. byte vx_C::getpixel(word x,word y)
  80. {
  81.   word offset_2=offset;
  82.   asm mov ax,80
  83.   asm mul y
  84.   asm mov bx,x
  85.   asm mov cx,bx
  86.   asm shr bx,1
  87.   asm shr bx,1
  88.   asm add bx,offset_2
  89.   asm add bx,ax
  90.   asm mov ax,0xa000
  91.   asm mov es,ax
  92.   asm mov ah,cl
  93.   asm and ah,0x03
  94.   asm mov al,READ_MAP
  95.   asm mov dx,GC_INDEX
  96.   asm out dx,ax
  97.   asm mov al,es:[bx]
  98.   return _AL; // Return value already in AL
  99. }
  100.  
  101. // BLOCKFILL
  102.  
  103. void vx_C::blockfill(word start,word end,byte data)
  104. {
  105.     asm mov  dx,SC_INDEX
  106.     asm mov  al,MAP_MASK
  107.     asm out  dx,al
  108.     asm inc  dx
  109.  
  110.     asm mov  al,0x0f
  111.     asm out  dx,al
  112.  
  113.     asm mov ax,0xa000
  114.     asm mov es,ax
  115.     asm mov di,start
  116.     asm mov cx,end
  117.     asm sub cx,start
  118.     asm inc cx
  119.     asm mov al,data
  120.     asm rep stosb
  121.  
  122.     asm mov dx,GC_INDEX+1
  123.     asm mov al,0xff
  124.     asm out dx,al
  125. }
  126.