home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
JUIN
/
SCALCHAR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-07
|
2KB
|
76 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 548 of 578
From : Sean Palmer 1:104/123.0 27 Jun 93 00:00
To : All
Subj : Scaling characters/fonts
────────────────────────────────────────────────────────────────────────────────
Been playing around again...
This demo shows the use of these routines to scale characters and
draw them in VGA 320x200x256 mode.
You can scale from any size to any other size. (but small ones look like
crap)
Could be easily enhanced to handle entire sets of characters...}
{by Sean Palmer}
{Public Domain}
procedure scaleChar(var src,dst;sw,sh,dw,dh:byte);
var s:array[0..65521]of byte absolute src;
var d:array[0..65521]of byte absolute dst;
var xpos:array[0..255]of word;
var i,j,ypos,sa,dp,db:word;
begin
dp:=0; db:=0;
fillchar(dst,(dw*dh+7)shr 3,0);
for i:=0 to dw-1 do begin
xpos[i]:=(longint(sw)*i+sw div 2)div dw;
end;
for j:=0 to dh-1 do begin
ypos:=((longint(sh)*j+sh div 2)div dh)*sw;
for i:=0 to dw-1 do begin
sa:=ypos+xpos[i];
if s[sa shr 3]and(1 shl (sa and 7))<>0 then
d[dp]:=d[dp]or 1 shl db;
db:=succ(db)and 7;
if db=0 then inc(dp);
end;
end;
end;
const color:byte=$F;
procedure drawChar(var c;w:word;h:byte;x,y:integer);assembler;asm
mov ax,$A000; mov es,ax; cld;
mov ax,320; mul y; add ax,x; mov bx,ax;
mov dl,$80; {force load of first byte}
mov dh,h; mov ah,color;
push ds;
lds si,c;
@L2: mov di,bx; mov cx,w;
@L: rol dl,1; jnc @NOLOD; lodsb; @NOLOD:
shr al,1; jnc @S; mov es:[di],ah; @S: inc di;
loop @L;
add bx,320; dec dh; jnz @L2;
pop ds;
end;
const c1:array[0..1]of longint=($D988A8A8,$88880278); {ugly shape}
var c2:array[0..32767]of byte;
var i,p:word;
begin
asm mov ax,$13; int $10; end;
p:=0;
for i:=1 to 22 do begin
scalechar(c1,c2,8,8,i,i);
drawChar(c2,i,i,p,p div 2);
inc(p,i+1);
end;
readln;
asm mov ax,3; int $10; end;
end.