home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
FNTM2-11.ARK
/
FONTM_2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-09-27
|
13KB
|
565 lines
program FontMaker2;
{version 1.0 by Kalvis Duckmanton, 11th Feb., 1991}
const
z2=$f0f9;
max_menus = 3;
powers: array[0..7] of byte = (1,2,4,8,16,32,64,128);
menus: array[1..max_menus] of string[60] =('New|Open|Close|Quit',
'Copy|Paste|Clear',
'Set Width|Change character|Input new character');
mpos: array[1..max_menus] of integer = (1,7,13);
max_menu_items = 10;
credits = ' v1.1 by KRD 1992 ';
menu_bar = ' File Edit Font ';
type
letrec = record
width : integer;
pass1 : array[1..32] of byte;
pass2 : array[1..32] of byte;
pass3 : array[1..32] of byte;
pass4 : array[1..32] of byte;
end;
str14 = string[14];
str80 = string[80];
var
fontfile : file of letrec;
recvar,scratch : letrec;
const
runs: integer = 0;
wd: integer = 0;
scrn_x: integer = 0;
scrn_y: integer = 0;
screen_pointer : integer = 0;
scrn_attr : byte = 0;
scrn_color: byte = 8;
nlq : boolean = false;
use_pcg : boolean = false;
colour : boolean = false;
premium : boolean = false;
fontopen : boolean = false;
newfont : boolean = false;
var
screen_data:array[1..8192] of byte;
fontname : str80;
opt,i : integer;
ch,edchar : char;
{$Iscrh.inc}
{$Iwindows.inc}
{$Imenu.inc}
procedure initpcg;
var
iz:integer;
begin
for iz:=$f810 to $f81f do mem[iz]:=$28;
for iz:=$f820 to $f82f do mem[iz]:=0;
mem [$f825]:=$08; mem[$f824]:=$14; mem[$f826]:=$14;
mem [$f823]:=$22; mem[$f827]:=$22;
for iz:=$f830 to $f83f do mem[iz]:=255-mem[iz-16];
for iz:=$f840 to $f84f do mem[iz]:=0; mem[$f844]:=$ff; mem[$f846]:=$ff;
end;
function convert(y:integer):integer;
var
y2:integer;
begin
if nlq then
begin
y2:=(y div 2)+8*(y mod 2);
end
else y2:=y;
convert:=y2;
end;
function Point(x,y:integer):boolean;
var
i: byte;
j,k,iz: integer;
begin
with recvar do
begin
if (x>width) or (y>runs*8) then Point:=false
else
begin
iz:=convert(y);
k:=iz div 8; j:= iz mod 8;
case k of
0: i:=pass1[x];
1: i:=pass2[x];
2: i:=pass3[x];
3: i:=pass4[x];
end;
Point:=((i and powers[7-j])>0);
end;
end;
end;
procedure Setp(x,y:integer);
var
iz,jz,kz: integer;
begin
with recvar do
begin
if (x<width) and (y<runs*8) then
begin
x:=x+1;
iz:=convert(y);
kz:=iz div 8; jz:=iz mod 8;
case kz of
0: pass1[x]:=(pass1[x] or powers[7-jz]);
1: pass2[x]:=(pass2[x] or powers[7-jz]);
2: pass3[x]:=(pass3[x] or powers[7-jz]);
3: pass4[x]:=(pass4[x] or powers[7-jz]);
end;
end;
end;
end;
procedure ReSetp(x,y:integer);
var
iz,jz,kz: integer;
begin
with recvar do
begin
if (x<width) and (y<runs*8) then
begin
x:=x+1;
iz:=convert(y);
kz:=iz div 8; jz:=iz mod 8;
case kz of
0: pass1[x]:=pass1[x] and 255-powers[7-jz];
1: pass2[x]:=pass2[x] and 255-powers[7-jz];
2: pass3[x]:=pass3[x] and 255-powers[7-jz];
3: pass4[x]:=pass4[x] and 255-powers[7-jz];
end;
end;
end;
end;
procedure nukechar;
var
i:integer;
begin
with recvar do
begin
width:=1;
for i:=1 to 32 do
begin
pass1[i]:=0; pass2[i]:=0; pass3[i]:=0; pass4[i]:=0;
end;
end;
end;
procedure setwidth;
var
temp:str80;
iz:integer;
begin
window(30,12,35,3,'character width',true);
setcolor(3); putat(32,13); print('Width of '+edchar+' is:');
setcolor(11); str(recvar.width,temp); edit(temp,false);
val(temp,iz,i); if (iz>0) and (iz<32) then recvar.width:=iz;
popwind;
end;
procedure displaychar(start:integer);
var
iz,jz,z,y:integer;
res:boolean;
begin
setcolor(4);
for iz:=0 to 18 do
begin
z:=z2+iz*80;
setcolor(12); putchar(z,$81); setcolor(4);
for jz:=1 to 32 do
begin
res:=point(jz,iz+start);
if res then putchar(z+jz,$a0) else putchar(z+jz,$20);
end;
setcolor(12);
if iz+start=runs*8 then for jz:=1 to recvar.width do putchar(z+jz,$84);
putchar(z+recvar.width+1,$81); setcolor(4);
end;
end;
function getmenu(iz:integer): integer;
var
j: integer;
begin
j:=menu(mpos[iz],2,menus[iz]);
if j=0 then getmenu:=0 else getmenu:=max_menu_items*(iz-1)+j;
end;
function getfontchar: boolean;
var
chtxt:char;
chnum:integer;
begin
window(40,10,30,5,'Edit character',true);
putat(42,12); setcolor(3);
print ('Character to edit '); setcolor(11); setcursor(96); putcursor;
read (kbd,chtxt);
if (chtxt=^M) or (chtxt=^[) then getfontchar:=false
else
begin
print(chtxt); edchar:=chtxt; zapcursor;
chnum:=ord(chtxt)-32;
{$I-} seek(fontfile,chnum);
read(fontfile,recvar); {$i+}
if ioresult=0 then getfontchar:=true else getfontchar:=false;
end;
popwind;
end;
procedure editchar;
var
charst,xcurs,ycurs,z:integer;
opt:char;
procedure update;
begin
use ('P'); setcolor(11); putat(68,2);
print (' Editing ');
use('F'); putat (77,2); print (edchar); use('pf'); setcolor(3);
end;
procedure putedcurs;
begin
z:=z2+xcurs+1+80*(ycurs-charst);
if (z>=Z2) and (z<=z2+18*80+31) then
begin
if mem[z]=$a0 then mem[z]:=$83 else mem[z]:=$82;
end;
end;
procedure zapedcurs;
begin
z:=z2+xcurs+1+80*(ycurs-charst);
if (z>=Z2) and (z<=z2+18*80+31) then
begin
if mem[z]=$82 then mem[z]:=$20 else mem[z]:=$a0;
end;
end;
begin
charst:=0; xcurs:=0; ycurs:=0;
update;
displaychar(charst);
putedcurs;
repeat
begin
read(kbd,opt);
if opt in['1'..chr(48+max_menus)] then
begin
case getmenu(ord(opt)-48) of
23: begin
if getfontchar then
begin
use('F'); putat(56,1); print (' Already assigned ');
repeat read(kbd,opt) until opt=^[;
use('f'); putat(56,1); print (' ');
end
else
begin
nukechar;
update;
displaychar(charst);
putedcurs;
end;
end;
22: if not(newfont) then
begin
if getfontchar then
begin
update;
displaychar(charst);
putedcurs;
end;
end;
21: begin
setwidth;
displaychar(charst);
putedcurs;
end;
11: scratch:=recvar;
12: begin
recvar:=scratch;
displaychar(charst);
putedcurs;
end;
13: begin
nukechar;
displaychar(charst);
putedcurs;
end;
end; {case}
end
else
begin
case opt of
^R : begin
if charst>0 then
begin
charst:=charst-1; ycurs:=ycurs-1;
displaychar(charst);
putedcurs;
end;
end;
^C : begin
charst:=charst+1; ycurs:=ycurs+1;
displaychar(charst); putedcurs;
end;
^A : begin
if recvar.width>1 then recvar.width:=recvar.width-1;
displaychar(charst); putedcurs;
end;
^F : begin
if recvar.width<32 then recvar.width:=recvar.width+1;
displaychar(charst); putedcurs;
end;
^E : if ycurs>0 then
begin
zapedcurs;
ycurs:=ycurs-1;
putedcurs;
end;
^X : if ycurs<runs*8-1 then
begin
zapedcurs;
ycurs:=ycurs+1;
putedcurs;
end;
^S : if xcurs>0 then
begin
zapedcurs;
xcurs:=xcurs-1;
putedcurs;
end;
^D : if xcurs<recvar.width-1 then
begin
zapedcurs;
xcurs:=xcurs+1;
putedcurs;
end;
^G : begin
resetp(xcurs,ycurs);
displaychar(charst);
putedcurs;
end;
' ' : begin
setp(xcurs,ycurs);
displaychar(charst);
putedcurs;
end;
^T : begin
if point(xcurs+1,ycurs) then
resetp(xcurs,ycurs)
else
setp(xcurs,ycurs);
displaychar(charst);
putedcurs;
end;
end; {case}
end; {if}
end {repeat}
until (opt=^M) or (opt=^[);
if opt=^M then
begin
seek(fontfile,ord(edchar)-32);
write(fontfile,recvar);
end;
use('P'); putat(68,2); print (' '); use('p');
end;
procedure updatename;
var
iz:integer;
begin
use('P'); putat(1,2); setcolor(3); for iz:=1 to 80 do print(' ');
setcolor(11); putat(39-(length(fontname) div 2),2);
print (' '+fontname+' '); setcolor(3); use('p');
end;
procedure setruns;
var
work:str14;
pts:integer;
begin
nlq:=false;
work:=copy(fontname,length(fontname)-1,2);
val(work,pts,i);
case pts of
12: begin
runs:=2;
nlq:=true;
end;
16 : runs:=2;
24 : runs:=3;
32 : runs:=4;
end;
end;
procedure allcaps(var work:str80);
var
i:integer;
begin
if length(work)>0 then for i:=1 to length(work) do work[i]:=upcase(work[i]);
end;
procedure openfont;
var
ok:boolean;
temp:str80;
ch:char;
n:integer;
begin
window(20,6,40,5,'Open',true);
putat(22,8); setcolor(3); print ('Enter font name:');
repeat
begin
ok:=false;
setcolor(11); putat(39,8);
edit (fontname,false);
if fontname='' then ok:=true;
if not ok then
begin
{$i-} close(fontfile); {$i+}
allcaps(fontname);
fontopen:=false; newfont:=false;
assign(fontfile,fontname);
{$i-} reset (fontfile); {$i+}
if ioresult<>0 then write (^G) else
begin
ok:=true; fontopen:=true;
setruns;
updatename;
n:=filesize(fontfile);
if n<95 then
begin
putat(22,10); use('F');
str(n,temp);
insert(' '+fontname+' has only ',temp,1);
temp:=concat(temp,' records '); print (temp);
use('f'); read(kbd,ch);
end;
end;
end;
end
until ok;
popwind;
end;
procedure inputseries;
var
iz:integer;
ch: char;
begin
use('F'); setcolor(13); putat(66,1); print (' Input Series ');
use('f'); setcolor(3);
for iz:=32 to 126 do
begin
edchar:=chr(iz);
nukechar;
repeat
begin
editchar;
if filesize(fontfile)<>iz-31 then
begin
putat(50,1); setcolor(13); use('F'); print (' No, again! ');
read (kbd,ch); putat(50,1); setcolor(3); use('f');
print(' ');
end;
end
until iz-31=filesize(fontfile);
end;
putat(66,1); print (' ');
end;
procedure makefont;
var
ch: char;
begin
window(20,6,50,5,'New',true);
putat(22,8); setcolor(3); print ('Enter name of new font : ');
setcolor(11); edit (fontname,false);
popwind;
if fontname<>'' then
begin
allcaps(fontname);
close(fontfile); fontopen:=false; newfont:=false;
assign(fontfile,fontname);
{$I-} reset(fontfile); {$I+}
if ioresult=0 then
begin
window (20,8,10,3,'',true);
putat (21,9); setcolor(11); use('PF');
print (' Error '); use('fp'); setcolor(3);
read (kbd,ch);
popwind;
end
else
begin
rewrite(fontfile);
newfont:=true; fontopen:=true;
setruns;
updatename;
InputSeries;
end;
end;
end;
begin
determine;
initpcg;
fontopen:=false; newfont:=false;
fontname:=''; screen_pointer:=0;
setpcg(0); setcolor(3); use('fp'); cls;
window(1,2,80,23,fontname,false);
setcolor(11); putat(79-length(credits),24); print (credits);
putat(1,1); use('P'); print(menu_bar); use('p');
repeat
begin
repeat read(kbd,ch) until ch in['1'..chr(48+max_menus)];
i:=getmenu(ord(ch)-$30);
case i of
1: makefont;
2: openfont;
3: begin
if fontopen then close(fontfile);
fontopen:=false; newfont:=false; fontname:='';
updatename;
end;
22: begin
if (fontopen) and not(newfont) then
begin
if getfontchar then editchar;
end;
end;
23: if fontopen then
begin
if getfontchar then
begin
use('F'); putat(56,1); print (' Already assigned ');
repeat read(kbd,ch) until ch=^[;
use('f'); putat(56,1); print (' ');
end
else
begin
nukechar;
editchar;
end;
end;
end;
end
until i=4;
if fontopen then close(fontfile);
setcolor(3); cls;
end.