home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / hacking / phreak_utils_pc / vgagraph.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-04-01  |  1.8 KB  |  110 lines

  1. unit vgagraph;
  2.  
  3. interface
  4. uses dos;
  5. type vgascreen = array[0..63999] of byte;
  6. const on  = FALSE;
  7.       off = TRUE;
  8.  
  9. procedure Enter256ColorMode;
  10. procedure vsync;
  11. procedure CloseGraph;
  12. procedure putpixel(x,y:word;color:byte);
  13. function  getpixel(x,y:word):word;
  14. procedure setrgbpalette(dac,r,g,b:byte);
  15. procedure getrgbpalette(dac:word;var r,g,b:word);
  16. procedure Bildaufbau(onoff:boolean);
  17. procedure Cleardevice;
  18. procedure go80x50;
  19.  
  20. implementation
  21.  
  22. Procedure Enter256ColorMode;
  23. begin
  24.   asm
  25.     mov ax,0013h
  26.     int 10h
  27.   end;
  28. end;
  29.  
  30. procedure vsync;
  31. begin
  32.   Repeat Until (Port[$3DA] And $08) = 0;
  33.   Repeat Until (Port[$3DA] And $08) <> 0;
  34. end;
  35.  
  36. procedure closegraph;
  37. begin
  38.   asm
  39.     mov ax,0003h
  40.     int 10h
  41.   end;
  42. end;
  43.  
  44. procedure putpixel(x,y:word;color:byte);
  45. begin
  46.   if (x<320) and (x>=0) and (y<200) and (y>=0) then
  47.     mem[$A000:y*320+x]:=color;
  48. end;
  49.  
  50. function getpixel(x,y:word):word;
  51. begin
  52.   getpixel:=mem[$A000:y*320+x];
  53. end;
  54.  
  55. procedure setrgbpalette(dac,r,g,b:byte); assembler;
  56. asm
  57.   mov  dx,$3C8
  58.   mov  al,dac
  59.   out  dx,al
  60.   inc  dx
  61.   mov  al,r
  62.   out  dx,al
  63.   mov  al,g
  64.   out  dx,al
  65.   mov  al,b
  66.   out  dx,al
  67. end;
  68.  
  69. procedure getrgbpalette(dac:word;var r,g,b:word);
  70. var reg:registers;
  71. begin
  72.   reg.ah:=$10;
  73.   reg.al:=$15;
  74.   reg.bx:=dac;
  75.   intr($10,reg);
  76.   r:=reg.dh;
  77.   g:=reg.ch;
  78.   b:=reg.cl;
  79. end;
  80.  
  81. procedure Bildaufbau(onoff:boolean);
  82. begin
  83.   asm
  84.     mov ah,12h
  85.     mov bl,36h
  86.     mov al,onoff
  87.     int 10h
  88.   end;
  89. end;
  90.  
  91. procedure Cleardevice;
  92. begin Enter256ColorMode; end;
  93.  
  94. procedure go80x50;
  95. begin
  96.   asm
  97.     mov ax,1112h
  98.     xor bl,bl
  99.     int 10h
  100.   end;
  101. end;
  102.  
  103. begin
  104.   if paramstr(1)='/(C)' then begin
  105.     writeln('VGAGRAPH.PAS - v2.5 - (C) 1993 by Onkel Dittmeyer / S.L.A.M.');
  106.     writeln('             Generic VGA I/O routines');
  107.     readln;
  108.   end;
  109. end.
  110.