home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best Objectech Shareware Selections
/
UNTITLED.iso
/
boss
/
grap
/
util
/
006
/
whatvga.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-01-23
|
25KB
|
1,007 lines
uses dos,crt,supervga;
procedure setpix(x,y:word;col:longint);
const
msk:array[0..7] of byte=(128,64,32,16,8,4,2,1);
plane :array[0..1] of byte=(5,10);
plane4:array[0..3] of byte=(1,2,4,8);
mscga4:array[0..3] of byte=($3f,$cf,$f3,$fc);
shcga4:array[0..3] of byte=(6,4,2,0);
var l:longint;
m,z:word;
begin
case memmode of
_cga2:begin
z:=(y shr 1)*bytes+(x shr 3);
if odd(y) then inc(z,8192);
mem[$b800:z]:=(mem[$b800:z] and (255 xor msk[x and 7]))
or ((col and 1) shl (7-(x and 7)));
end;
_cga4:begin
z:=(y shr 1)*bytes+(x shr 2);
if odd(y) then inc(z,8192);
mem[$b800:z]:=(mem[$b800:z] and mscga4[x and 3])
or (col and 3) shl shcga4[x and 3];
end;
_pl2:begin
l:=y*bytes+(x shr 3);
wrinx($3ce,3,0);
wrinx($3ce,5,2);
wrinx($3c4,2,1);
wrinx($3ce,8,msk[x and 7]);
setbank(l shr 16);
z:=mem[vseg:word(l)];
mem[vseg:word(l)]:=col;
end;
_pl2e:begin
l:=y*128+(x shr 3);
modinx($3ce,5,3,0);
wrinx($3c4,2,15);
wrinx($3ce,0,col*3);
wrinx($3ce,1,3);
wrinx($3ce,8,msk[x and 7]);
z:=mem[vseg:word(l)];
mem[vseg:word(l)]:=0;
end;
_pl4:begin
l:=y*bytes+(x shr 4);
wrinx($3ce,3,0);
wrinx($3ce,5,2);
wrinx($3c4,2,plane[(x shr 3) and 1]);
wrinx($3ce,8,msk[x and 7]);
setbank(l shr 16);
z:=mem[vseg:word(l)];
mem[vseg:word(l)]:=col;
end;
_pk4:begin
l:=y*bytes+(x shr 2);
setbank(l shr 16);
z:=mem[vseg:word(l)] and mscga4[x and 3];
mem[vseg:word(l)]:=z or (col shl shcga4[x and 3]);
end;
_pl16:begin
l:=y*bytes+(x shr 3);
wrinx($3ce,3,0);
wrinx($3ce,5,2);
wrinx($3ce,8,msk[x and 7]);
setbank(l shr 16);
z:=mem[vseg:word(l)];
mem[vseg:word(l)]:=col;
end;
_pk16:begin
l:=y*bytes+(x shr 1);
setbank(l shr 16);
z:=mem[vseg:word(l)];
if odd(x) then z:=z and $f+(col shl 4)
else z:=z and $f0+col;
mem[vseg:word(l)]:=z;
end;
_p256:begin
l:=y*bytes+x;
setbank(l shr 16);
mem[vseg:word(l)]:=col;
end;
_p32k,_p64k:
begin
l:=y*bytes+(x shl 1);
setbank(l shr 16);
memw[vseg:word(l)]:=col;
end;
_p16m:begin
l:=y*bytes+(x*3);
z:=word(l);
m:=l shr 16;
setbank(m);
if z<$fffe then move(col,mem[vseg:z],3)
else begin
mem[vseg:z]:=lo(col);
if z=$ffff then setbank(m+1);
mem[vseg:z+1]:=lo(col shr 8);
if z=$fffe then setbank(m+1);
mem[vseg:z+2]:=col shr 16;
end;
end;
else ;
end;
end;
procedure setvstartxy(x,y:word);
var l:longint;
begin
l:=0;
case memmode of
_pl16:l:=(bytes*y+(x div 8))*4;
_p256:l:=bytes*y+x;
_p32k,_p64k:l:=bytes*y+x*2;
_p16m:l:=bytes*y+x*3;
end;
setvstart(l);
end;
function whitecol:longint;
var col:longint;
begin
case memmode of
_cga2,_pl2e,
_pl2:col:=1;
_cga4,_pk4
,_pl4:col:=3;
_pk16,_pl16,
_p256:col:=15;
_p32k:col:=$7fff;
_p64k:col:=$ffff;
_p16m:col:=$ffffff;
else
end;
whitecol:=col;
end;
procedure wrtext(x,y:word;txt:string); {write TXT to pos (X,Y)}
type
pchar=array[char] of array[0..15] of byte;
var
p:^pchar;
c:char;
i,j,z,b:integer;
ad,bk:word;
l,v,col:longint;
begin
rp.bh:=6;
vio($1130);
case memmode of
_cga2,_pl2e,
_pl2:col:=1;
_cga4,_pk4
,_pl4:col:=3;
_pk16,_pl16,
_p256:col:=15;
_p32k:col:=$7fff;
_p64k:col:=$ffff;
_p16m:col:=$ffffff;
else
end;
p:=ptr(rp.es,rp.bp);
for z:=1 to length(txt) do
begin
c:=txt[z];
for j:=0 to 15 do
begin
b:=p^[c][j];
for i:=0 to 7 do
begin
if (b and 128)<>0 then v:=col else v:=0;
setpix(x+i,y+j,v);
b:=b shl 1;
end;
end;
inc(x,8);
end;
end;
procedure drawtestpattern(nam:string);
{Draw Test pattern.}
var s:string;
l:longint;
x,y,yst:word;
white:longint;
function rgb(r,g,b:word):longint;
begin
r:=lo(r);g:=lo(g);b:=lo(b);
case colbits[memmode] of
1:rgb:=r and 1;
2:rgb:=r and 3;
4:rgb:=r and 15;
8:rgb:=r;
15:rgb:=((r shr 3) shl 5+(g shr 3)) shl 5+(b shr 3);
16:rgb:=((r shr 3) shl 6+(g shr 2)) shl 5+(b shr 3);
24:rgb:=(longint(r) shl 8+g) shl 8 +b;
end;
end;
procedure wline(stx,sty,ex,ey:integer);
var x,y,d,mx,my:integer;
l:longint;
begin
if sty>ey then
begin
x:=stx;stx:=ex;ex:=x;
x:=sty;sty:=ey;ey:=x;
end;
y:=0;
mx:=abs(ex-stx);
my:=ey-sty;
d:=0;
repeat
l:=rgb(y,y,y);
y:=(y+1) and 255;
setpix(stx,sty,l);
if abs(d+mx)<abs(d-my) then
begin
inc(sty);
d:=d+mx;
end
else begin
d:=d-my;
if ex>stx then inc(stx)
else dec(stx);
end;
until (stx=ex) and (sty=ey);
end;
begin
white:=whitecol;
wline(50,30,pixels-50,30);
wline(50,lins-30,pixels-50,lins-30);
wline(50,30,50,lins-30);
wline(pixels-50,30,pixels-50,lins-30);
wline(50,30,pixels-50,lins-30);
wline(pixels-50,30,50,lins-30);
if lins>200 then yst:=50 else yst:=10;
wrtext(10,yst,name+' with '+istr(mm)+' Kbytes.');
wrtext(10,yst+25,nam);
for x:=1 to (pixels-10) div 100 do
begin
for y:=1 to 10 do
setpix(x*100,y,white);
wrtext(x*100+3,1,istr(x));
end;
for x:=1 to (lins-10) div 100 do
begin
for y:=1 to 10 do
setpix(y,x*100,white);
wrtext(1,x*100+2,istr(x));
end;
case memmode of
_pk4,
_pl4:for x:=0 to 63 do
for y:=0 to 63 do
setpix(30+x,yst+y+50,y shr 3);
_pk16,
_pl16:for x:=0 to 127 do
if lins<250 then
for y:=0 to 63 do
setpix(30+x,yst+y+50,y shr 2)
else
for y:=0 to 127 do
setpix(30+x,yst+y+50,y shr 3);
_p256:for x:=0 to 127 do
if lins<250 then
for y:=0 to 63 do
setpix(30+x,yst+50+y,((y shl 2) and 240) +(x shr 3))
else
for y:=0 to 127 do
setpix(30+x,yst+50+y,((y shl 1) and 240)+(x shr 3));
_p32k,_p64k,_p16m:
if pixels<600 then
begin
for x:=0 to 63 do
begin
for y:=0 to 63 do
begin
setpix(30+x,100+y,rgb(x*4,y*4,0));
setpix(110+x,100+y,rgb(x*4,0,y*4));
setpix(190+x,100+y,rgb(0,x*4,y*4));
end;
end;
for x:=0 to 255 do
for y:=170 to 179 do
begin
setpix(x,y,rgb(x,0,0));
setpix(x,y+10,rgb(0,x,0));
setpix(x,y+20,rgb(0,0,x));
end;
end
else begin
for x:=0 to 127 do
for y:=0 to 127 do
begin
setpix(30+x,120+y,rgb(x*2,y*2,0));
setpix(200+x,120+y,rgb(x*2,0,y*2));
setpix(370+x,120+y,rgb(0,x*2,y*2));
end;
for x:=0 to 511 do
for y:=260 to 269 do
begin
setpix(x,y,rgb(x shr 1,0,0));
setpix(x,y+10,rgb(0,x shr 1,0));
setpix(x,y+20,rgb(0,0,x shr 1));
end;