Upload
This commit is contained in:
commit
43352ff262
1291 changed files with 220976 additions and 0 deletions
6
GRAB/FONT/DOFONT.BAT
Normal file
6
GRAB/FONT/DOFONT.BAT
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
echo off
|
||||
font1 %1.lbm %1.tmp
|
||||
font2 %1.tmp %1.fnt
|
||||
del %1.tmp
|
||||
cls
|
||||
echo Fonttitiedosto: %1.fnt
|
||||
403
GRAB/FONT/FONT1.C
Normal file
403
GRAB/FONT/FONT1.C
Normal file
|
|
@ -0,0 +1,403 @@
|
|||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#include <string.h>
|
||||
#include <conio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int scan(void);
|
||||
int doblock(FILE *f1);
|
||||
int readlbm(FILE *f1);
|
||||
int showline(int y);
|
||||
|
||||
int bluecol=1;
|
||||
int backcol=15;
|
||||
|
||||
FILE *out;
|
||||
long f_off[256];
|
||||
char f_wid[256];
|
||||
char f_hig[256];
|
||||
char f_base[256];
|
||||
long averwid;
|
||||
int avercnt;
|
||||
|
||||
main(int argc,char *argv[])
|
||||
{
|
||||
int a;
|
||||
FILE *f1;
|
||||
if(argc==1)
|
||||
{
|
||||
printf("usage: FONT <srclbm> <desttmpfont>");
|
||||
return(0);
|
||||
}
|
||||
_setvideomode(_VRES16COLOR);
|
||||
for(a=0;a<256;a++)
|
||||
{
|
||||
f_off[a]=0;
|
||||
f_wid[a]=0;
|
||||
f_hig[a]=0;
|
||||
}
|
||||
avercnt=0; averwid=0;
|
||||
out=fopen(argv[2],"wb");
|
||||
fwrite(f_off,4,256,out);
|
||||
fwrite(f_wid,1,256,out);
|
||||
fwrite(f_hig,1,256,out);
|
||||
fwrite(f_base,1,256,out);
|
||||
f1=fopen(argv[1],"rb");
|
||||
readlbm(f1);
|
||||
scan();
|
||||
fclose(f1);
|
||||
fseek(out,0L,SEEK_SET);
|
||||
averwid/=avercnt;
|
||||
f_wid[32]=averwid;
|
||||
f_hig[32]=1;
|
||||
fwrite(f_off,4,256,out);
|
||||
fwrite(f_wid,1,256,out);
|
||||
fwrite(f_hig,1,256,out);
|
||||
fwrite(f_base,1,256,out);
|
||||
fclose(out);
|
||||
_setvideomode(_DEFAULTMODE);
|
||||
}
|
||||
|
||||
unsigned char linebuf[1024];
|
||||
unsigned char pal[768];
|
||||
|
||||
int showline(int y)
|
||||
{
|
||||
int x;
|
||||
for(x=0;x<640;x++)
|
||||
{
|
||||
_setcolor(linebuf[x]);
|
||||
_setpixel(x,y);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int cbits[8]={1,2,4,8,16,32,64,128};
|
||||
int lbmmode; /* 1=DPII, 2=DPIIe */
|
||||
char *errtxt;
|
||||
char lasttype[5];
|
||||
char type[5]={"----"};
|
||||
long len;
|
||||
int xsz,ysz,planes,stencil,colors,mode;
|
||||
char lbmtype[4];
|
||||
int checktype=0;
|
||||
|
||||
int eschit(void)
|
||||
{
|
||||
if(kbhit())
|
||||
{
|
||||
if(getch()==27) return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int getaw(FILE *f1)
|
||||
{
|
||||
unsigned int a;
|
||||
a=getc(f1)*256;
|
||||
a+=getc(f1);
|
||||
return(a);
|
||||
}
|
||||
|
||||
int readlbm(FILE *f1)
|
||||
{
|
||||
int x,y,a,b,c;
|
||||
long l;
|
||||
unsigned u;
|
||||
int firstone=1;
|
||||
errtxt=NULL;
|
||||
do
|
||||
{
|
||||
memcpy(lasttype,type,5);
|
||||
/* get header */
|
||||
do
|
||||
{
|
||||
type[0]=getc(f1);
|
||||
}
|
||||
while(type[0]==0 && !feof(f1));
|
||||
type[1]=getc(f1); type[2]=getc(f1); type[4]=0;
|
||||
type[3]=getc(f1); len=getc(f1)*256L*65536L;
|
||||
if(firstone && memcmp(type,"FORM",4)) return(2);
|
||||
firstone=0;
|
||||
len+=getc(f1)*65536L; len+=getc(f1)*256L; len+=getc(f1);
|
||||
/* process it */
|
||||
a=doblock(f1);
|
||||
if(errtxt!=NULL)
|
||||
{
|
||||
printf("%s\n",errtxt);
|
||||
return(1);
|
||||
}
|
||||
if(a==-1)
|
||||
{
|
||||
printf("Not a Deluxepaint file!");
|
||||
return(2);
|
||||
}
|
||||
if(a==2)
|
||||
{
|
||||
printf("OLD:<%s> NEW<%s>\n",lasttype,type);
|
||||
return(1);
|
||||
}
|
||||
else if(a==1) break;
|
||||
}
|
||||
while(!feof(f1));
|
||||
return(0);
|
||||
}
|
||||
|
||||
int doblock(FILE *f1)
|
||||
{ /* processes one block */
|
||||
long lastpos=ftell(f1);
|
||||
int a,b,c,d,e,f;
|
||||
if(!strcmp(type,"CMAP"))
|
||||
{
|
||||
/* color map */
|
||||
for(b=0;b<colors*3;b++)
|
||||
{
|
||||
a=getc(f1)/4;
|
||||
pal[b]=a;
|
||||
}
|
||||
/* load colors */
|
||||
for(a=0;a<16;a++) /* vga */
|
||||
{
|
||||
inp(0x3da);
|
||||
outp(0x3c0,a);
|
||||
outp(0x3c0,a);
|
||||
outp(0x3c8,a);
|
||||
outp(0x3c9,pal[a*3+0]);
|
||||
outp(0x3c9,pal[a*3+1]);
|
||||
outp(0x3c9,pal[a*3+2]);
|
||||
}
|
||||
inp(0x3da);
|
||||
outp(0x3c0,32);
|
||||
}
|
||||
else if(!strcmp(type,"FORM"))
|
||||
{ /* skip size of file, NO pointer movement */
|
||||
for(a=0;a<8;a++) lbmtype[a]=getc(f1);
|
||||
lbmtype[a]=0;
|
||||
/* LMDSBMHD - pakkaamaton formaatti */
|
||||
if(!memcmp(lbmtype,"ILBMBMHD",8))
|
||||
{
|
||||
lbmmode=1;
|
||||
}
|
||||
else if(!memcmp(lbmtype,"PBM BMHD",8))
|
||||
{
|
||||
lbmmode=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
errtxt="Unknown fileformat!";
|
||||
return(-1);
|
||||
}
|
||||
getaw(f1); /* headerin lopun pituus */
|
||||
getaw(f1); /* - */
|
||||
xsz=getaw(f1);
|
||||
ysz=getaw(f1);
|
||||
getaw(f1); /* ? */
|
||||
getaw(f1); /* ? */
|
||||
|
||||
planes=getc(f1);
|
||||
stencil=getc(f1);
|
||||
colors=getaw(f1);
|
||||
getaw(f1); /* ? */
|
||||
getaw(f1); /* ? */
|
||||
getaw(f1); /* screen-size-x */
|
||||
getaw(f1); /* screen-size-y */
|
||||
|
||||
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
|
||||
"Size: %i x %i (Colors:%i)\nPlanes:%i Stencil:%i\n",
|
||||
xsz,ysz,colors,planes,stencil);
|
||||
return(0);
|
||||
}
|
||||
else if(!strcmp(type,"CRNG"))
|
||||
{
|
||||
}
|
||||
else if(!strcmp(type,"DPPS"))
|
||||
{
|
||||
}
|
||||
else if(!strcmp(type,"DPPV"))
|
||||
{
|
||||
}
|
||||
else if(!strcmp(type,"TINY"))
|
||||
{ /* pikkukuva */
|
||||
}
|
||||
else if(!strcmp(type,"BODY") && lbmmode==2)
|
||||
{
|
||||
int lp,cbit,y=0;
|
||||
while(!eschit() && y<ysz)
|
||||
{
|
||||
memset(linebuf,0,xsz);
|
||||
{
|
||||
lp=0;
|
||||
while(lp<xsz)
|
||||
{
|
||||
a=getc(f1);
|
||||
if(a>127)
|
||||
{
|
||||
c=getc(f1);
|
||||
a=256-a;
|
||||
if(a==0) c=0;
|
||||
for(b=0;b<=a;b++) linebuf[lp++]=c;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(b=0;b<=a;b++)
|
||||
{
|
||||
c=getc(f1);
|
||||
linebuf[lp++]=c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
showline(y);
|
||||
y++;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
else if(!strcmp(type,"BODY") && lbmmode==1)
|
||||
{
|
||||
int lp,cbit,y=0;
|
||||
while(!eschit() && y<ysz)
|
||||
{
|
||||
memset(linebuf,0,xsz);
|
||||
for(d=0;d<planes;d++)
|
||||
{
|
||||
cbit=cbits[d];
|
||||
lp=0;
|
||||
while(lp<xsz)
|
||||
{
|
||||
a=getc(f1);
|
||||
if(a>127)
|
||||
{
|
||||
c=getc(f1);
|
||||
a=256-a;
|
||||
if(a==0) c=0;
|
||||
for(b=0;b<=a;b++)
|
||||
{
|
||||
linebuf[lp++]|=c&128?cbit:0;
|
||||
linebuf[lp++]|=c&64?cbit:0;
|
||||
linebuf[lp++]|=c&32?cbit:0;
|
||||
linebuf[lp++]|=c&16?cbit:0;
|
||||
linebuf[lp++]|=c&8?cbit:0;
|
||||
linebuf[lp++]|=c&4?cbit:0;
|
||||
linebuf[lp++]|=c&2?cbit:0;
|
||||
linebuf[lp++]|=c&1?cbit:0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(b=0;b<=a;b++)
|
||||
{
|
||||
c=getc(f1);
|
||||
linebuf[lp++]|=c&128?cbit:0;
|
||||
linebuf[lp++]|=c&64?cbit:0;
|
||||
linebuf[lp++]|=c&32?cbit:0;
|
||||
linebuf[lp++]|=c&16?cbit:0;
|
||||
linebuf[lp++]|=c&8?cbit:0;
|
||||
linebuf[lp++]|=c&4?cbit:0;
|
||||
linebuf[lp++]|=c&2?cbit:0;
|
||||
linebuf[lp++]|=c&1?cbit:0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(stencil) for(lp=0;lp<xsz;)
|
||||
{
|
||||
a=getc(f1);
|
||||
if(a>127)
|
||||
{
|
||||
c=getc(f1);
|
||||
a=256-a;
|
||||
lp+=a*8+8;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(b=0;b<=a;b++)
|
||||
{
|
||||
c=getc(f1);
|
||||
}
|
||||
lp+=a*8+8;
|
||||
}
|
||||
}
|
||||
showline(y);
|
||||
y++;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
else if(checktype)
|
||||
{
|
||||
return(2);
|
||||
}
|
||||
fseek(f1,lastpos+len,SEEK_SET);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int letter(int chr,int x,int y)
|
||||
{
|
||||
int basey;
|
||||
int x1,y1,x2,y2,a,c=1;
|
||||
x1=x2=x; y1=y2=y;
|
||||
/* expand box */
|
||||
while(c)
|
||||
{
|
||||
c=0;
|
||||
for(a=x1;a<=x2;a++)
|
||||
{
|
||||
if(y1>=0 && _getpixel(a,y1)!=backcol) { y1--; c=1; }
|
||||
if(y2<=479 && _getpixel(a,y2)!=backcol) { y2++; c=1; }
|
||||
}
|
||||
for(a=y1;a<=y2;a++)
|
||||
{
|
||||
if(x1>=0 && _getpixel(x1,a)!=backcol) { x1--; c=1; }
|
||||
if(x2<=639 && _getpixel(x2,a)!=backcol) { x2++; c=1; }
|
||||
}
|
||||
if(x1<=0 || y1<=0 || x2>=639 || y2>=479) exit(1);
|
||||
}
|
||||
basey=y-y1;
|
||||
/* erase blue */
|
||||
for(y=y1;y<=y2;y++)
|
||||
for(x=x1;x<=x2;x++)
|
||||
{
|
||||
if(_getpixel(x,y)==bluecol)
|
||||
{
|
||||
_setcolor(backcol);
|
||||
_setpixel(x,y);
|
||||
}
|
||||
}
|
||||
/* save font */
|
||||
{
|
||||
avercnt++;
|
||||
averwid+=x2-x1+1;
|
||||
f_wid[chr]=x2-x1+1;
|
||||
f_hig[chr]=y2-y1+1;
|
||||
f_base[chr]=basey;
|
||||
f_off[chr]=ftell(out);
|
||||
for(y=y1;y<=y2;y++)
|
||||
for(x=x1;x<=x2;x++)
|
||||
{
|
||||
if(_getpixel(x,y)!=backcol) putc(1,out);
|
||||
else putc(0,out);
|
||||
}
|
||||
}
|
||||
/* erase box */
|
||||
_setcolor(backcol);
|
||||
_rectangle(_GFILLINTERIOR,x1,y1,x2,y2);
|
||||
return(0);
|
||||
}
|
||||
|
||||
unsigned char order[256]={
|
||||
"!\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
||||
"`abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
"<EFBFBD>Ž™†„”"
|
||||
"àáâãäåæçèéêëìíîï"};
|
||||
int scan(void)
|
||||
{
|
||||
int y,x,a=0;
|
||||
for(y=0;y<480;y++) if((bluecol=_getpixel(0,y))!=backcol)
|
||||
{
|
||||
for(x=1;x<640;x++) if(_getpixel(x,y)!=backcol)
|
||||
{
|
||||
if(letter(order[a++],x,y)) return(1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
148
GRAB/FONT/FONT2.C
Normal file
148
GRAB/FONT/FONT2.C
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/* font converter */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
unsigned char wid[256];
|
||||
unsigned char hig[256];
|
||||
unsigned char basey[256];
|
||||
unsigned long off[256];
|
||||
|
||||
unsigned doff[256];
|
||||
unsigned dwid[256];
|
||||
|
||||
unsigned int base,min,max,ylen;
|
||||
|
||||
#define LY 100
|
||||
#define LX 100
|
||||
char fnt[LX*LY];
|
||||
unsigned char fntwid;
|
||||
char empty;
|
||||
|
||||
int readfont(FILE *f1,int a)
|
||||
{
|
||||
unsigned int x,y;
|
||||
fntwid=wid[a];
|
||||
memset(fnt,0,LX*LY);
|
||||
empty=1;
|
||||
if(!off[a]) return(0);
|
||||
empty=0;
|
||||
fseek(f1,off[a],SEEK_SET);
|
||||
for(y=0;y<hig[a];y++)
|
||||
{
|
||||
for(x=0;x<fntwid;x++)
|
||||
{
|
||||
fnt[x+(y+base-basey[a])*LX]=getc(f1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int printfont(void)
|
||||
{
|
||||
unsigned int x,y;
|
||||
for(y=0;y<ylen*8;y++)
|
||||
{
|
||||
for(x=0;x<fntwid;x++)
|
||||
{
|
||||
if(fnt[x+y*LX]) printf("Û");
|
||||
else printf(".");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
getch();
|
||||
return(0);
|
||||
}
|
||||
|
||||
int bits[8]={128,64,32,16,8,4,2,1};
|
||||
int convert(FILE *f2,int chr)
|
||||
{
|
||||
unsigned int x,y0,y;
|
||||
int a;
|
||||
dwid[chr]=fntwid;
|
||||
if(empty)
|
||||
{
|
||||
doff[chr]=0;
|
||||
return(0);
|
||||
}
|
||||
doff[chr]=(unsigned)ftell(f2);
|
||||
for(y0=0;y0<ylen;y0++)
|
||||
{
|
||||
for(x=0;x<fntwid;x++)
|
||||
{
|
||||
for(a=y=0;y<8;y++)
|
||||
{
|
||||
if(fnt[x+(y0*8+y)*LX]) a+=bits[y];
|
||||
}
|
||||
putc(a,f2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main(int argc,char *argv[])
|
||||
{
|
||||
long l;
|
||||
int a,c;
|
||||
unsigned int b;
|
||||
FILE *f1,*f2;
|
||||
if(argc==1)
|
||||
{
|
||||
printf("usage: <srctmp> <destprn>");
|
||||
return(0);
|
||||
}
|
||||
f1=fopen(argv[1],"rb");
|
||||
f2=fopen(argv[2],"wb");
|
||||
fread(off,4,256,f1);
|
||||
fread(wid,1,256,f1);
|
||||
fread(hig,1,256,f1);
|
||||
fread(basey,1,256,f1);
|
||||
for(min=max=a=0;a<256;a++) if(off[a])
|
||||
{
|
||||
b=hig[a]-basey[a];
|
||||
if(b>max) max=b;
|
||||
b=basey[a];
|
||||
if(b>min) min=b;
|
||||
}
|
||||
max--;
|
||||
ylen=(max+min+7)/8;
|
||||
base=(ylen*8-(max+min))/2+min;
|
||||
printf("Maximum heigth: %i\nBase up:%i\nBase down:%i\n",
|
||||
max+min,min,max);
|
||||
printf("Heigth in charachters: %i\nBase line in pixels: %i\n",
|
||||
ylen,base);
|
||||
fseek(f2,1024L+16L,SEEK_SET);
|
||||
for(a=0;a<256;a++)
|
||||
{
|
||||
printf("Processing charachter %i...\r",a);
|
||||
readfont(f1,a);
|
||||
convert(f2,a);
|
||||
}
|
||||
fseek(f2,0L,SEEK_SET);
|
||||
fprintf(f2,"BIGFONT\x01a");
|
||||
putw(ylen,f2);
|
||||
putw(0,f2);
|
||||
putw(0,f2);
|
||||
putw(0,f2);
|
||||
fwrite(doff,2,256,f2);
|
||||
fwrite(dwid,2,256,f2);
|
||||
fclose(f2);
|
||||
fclose(f1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
file format for destination font file:
|
||||
|
||||
text: "BIGFONT",0x1b
|
||||
word: charachter rows
|
||||
word: -
|
||||
word: -
|
||||
word: -
|
||||
256 times: word: offset (0 for letter not in file)
|
||||
256 times: word: width
|
||||
|
||||
*/
|
||||
BIN
GRAB/FONT/HELV.LBM
Normal file
BIN
GRAB/FONT/HELV.LBM
Normal file
Binary file not shown.
136
GRAB/FONT/PRINT.C
Normal file
136
GRAB/FONT/PRINT.C
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define LINEWIDTH 960 /* printterin rivill„ pisteit„ */
|
||||
#define MAXHEIGTH 8 /* maksimi korkeus merkeille */
|
||||
#define BUFFERSIZE 32000 /* tila fonttidatalle */
|
||||
#define HEADERLENGTH 0x410 /* alkutauluk. pituus ennen varsinaista dataa */
|
||||
|
||||
unsigned char fontdata[BUFFERSIZE]; /* file mahtuu varmasti */
|
||||
int heigth; /* korkeus merkeiss„ */
|
||||
int offset[256]; /* jokaisen fontin alkupaikka fileess„ */
|
||||
int width[256]; /* jokaisen fontin leveys (pixeleiss„) */
|
||||
int spacing=-1; /* lis„v„li merkkien v„liss„ */
|
||||
|
||||
unsigned char linebuf[MAXHEIGTH][LINEWIDTH];
|
||||
|
||||
int readfont(char *file)
|
||||
{
|
||||
int a;
|
||||
FILE *f1;
|
||||
f1=fopen(file,"rb"); /* read binary */
|
||||
/* onko headerin teksti ok? */
|
||||
if(fgetc(f1)!='B') return(1);
|
||||
if(fgetc(f1)!='I') return(1);
|
||||
if(fgetc(f1)!='G') return(1);
|
||||
if(fgetc(f1)!='F') return(1);
|
||||
if(fgetc(f1)!='O') return(1);
|
||||
if(fgetc(f1)!='N') return(1);
|
||||
if(fgetc(f1)!='T') return(1);
|
||||
getc(f1);
|
||||
/* on, korkeus? */
|
||||
heigth=getw(f1); /* word - korkeus */
|
||||
a=getw(f1); /* word - ylim. v„li */
|
||||
if(spacing==-1) spacing=a; /* aseta jos ei jo asetettu */
|
||||
getw(f1); /* unused */
|
||||
getw(f1); /* unused */
|
||||
/* lue offset/width taulukot */
|
||||
for(a=0;a<256;a++) offset[a]=getw(f1);
|
||||
for(a=0;a<256;a++) width[a]=getw(f1);
|
||||
/* lue data */
|
||||
fread(fontdata,1,BUFFERSIZE,f1);
|
||||
/* valmista tuli */
|
||||
fclose(f1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int printtext(unsigned char *txt)
|
||||
{
|
||||
FILE *prn;
|
||||
int a,b;
|
||||
int o,w;
|
||||
int x=0; /* pixelipaikka rivill„ */
|
||||
memset(linebuf,0,MAXHEIGTH*LINEWIDTH);
|
||||
while(*txt)
|
||||
{ /* niin kauan kuin merkkej„ riitt„„*/
|
||||
a=(unsigned)*txt; txt++; /* a=merkki, seuraava merkki valmiiksi */
|
||||
o=offset[a]; /* merkin osoite fileess„ */
|
||||
if(o==0) o=-1; /* merkill„ ei ole dataa (tyhj„„ t„ynn„) */
|
||||
else o-=HEADERLENGTH; /* osoite fontdatassa (joka alkaa
|
||||
filen kohdasta HEADERLENGTH) */
|
||||
w=width[a]; /* leveys */
|
||||
if(w+x>LINEWIDTH) break; /* rivi loppui, ulos whilesta */
|
||||
/* kopio merkki rivibufferiin (jos offset==-1, niin kirjain
|
||||
on tyhj„„ t„ynn„ (space etc.) */
|
||||
if(o!=-1) for(b=0;b<heigth;b++)
|
||||
{
|
||||
for(a=0;a<w;a++)
|
||||
{
|
||||
linebuf[b][x+a]=fontdata[o++];
|
||||
}
|
||||
}
|
||||
x+=w+spacing; /* "kursoria" eteenp„in, ja extraa v„liin */
|
||||
}
|
||||
printf("(%i pixels)...",x);
|
||||
/* printtaa linebufferi printterille (EPSON) */
|
||||
prn=fopen("prn","wb");
|
||||
/* riviv„li oikeaksi */
|
||||
putc(27,prn);
|
||||
putc(51,prn);
|
||||
putc(24,prn);
|
||||
for(b=0;b<heigth;b++)
|
||||
{
|
||||
/* grafiikkaheaderi */
|
||||
putc(27,prn);
|
||||
putc(42,prn);
|
||||
putc(1,prn); /* 960 pistett„ riville, 8 pinnin grafiikka */
|
||||
putc(x&255,prn); /* pixel count, low */
|
||||
putc(x/256,prn); /* pixel count, high */
|
||||
/* data */
|
||||
for(a=0;a<x;a++)
|
||||
{
|
||||
putc(linebuf[b][a],prn);
|
||||
}
|
||||
/* seuraava rivi */
|
||||
putc(10,prn);
|
||||
}
|
||||
fclose(prn);
|
||||
return(0);
|
||||
}
|
||||
|
||||
unsigned char txt[256]={"\0"};
|
||||
char *font="default.fnt";
|
||||
|
||||
main(int argc,char *argv[])
|
||||
{
|
||||
int a;
|
||||
if(argc==1)
|
||||
{
|
||||
printf("usage: PRINT [/F<fontfile>] [/S<spacing pixels>] \"text\"\n");
|
||||
return(0);
|
||||
}
|
||||
*txt=0;
|
||||
for(a=1;a<argc;a++) if(*argv[a]=='/') switch(*(argv[a]+1))
|
||||
{
|
||||
case 'F' :
|
||||
case 'f' :
|
||||
font=argv[a]+2;
|
||||
break;
|
||||
case 'S' :
|
||||
case 's' :
|
||||
spacing=atoi(argv[a]+2);
|
||||
break;
|
||||
default :
|
||||
printf("Error in command line.");
|
||||
return(1);
|
||||
}
|
||||
else strcat(txt,argv[a]);
|
||||
if(readfont(font))
|
||||
{
|
||||
printf("Font could not be loaded.");
|
||||
return(1);
|
||||
}
|
||||
printf("Printing \"%s\" ",txt);
|
||||
printtext(txt);
|
||||
}
|
||||
75
GRAB/FONT/README
Normal file
75
GRAB/FONT/README
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
Pikaohjeet fontintekoon:
|
||||
|
||||
* Pohjakuva tulee tehd„ DeluxePaintilla resoluutioon 640x480x16v„ri„.
|
||||
* V„ri 15 pit„„ ottaa taustaksi (sen kirkkautta kannattaa ehk„ v„h„n
|
||||
pienent„„ silmien s„„st„miseksi).
|
||||
* Fontit kirjoitetaan v„rill„ 0 siten ett„ jokaisen kirjaimen ymp„rill„
|
||||
on v„hint„„n 1 tyhj„ pikseli (yleens„ n„in on automaattisesti).
|
||||
* Merkkien j„rjestyksen tulee olla seuraava (alku on ASCII:n mukainen,
|
||||
ja alkaa merkist„ 33 (ei spacea luonnollisestikaan)):
|
||||
! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
|
||||
@ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _
|
||||
` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
|
||||
<20> Ž ™ † „ ”
|
||||
Jos viel„ t„m„n j„lkeen tulee merkkej„, ne asettuvat kreikkalaisten
|
||||
kirjainten p„„lle (ASCII 224..239).
|
||||
Koska Spacea ei voi m„„ritell„, olettaa konvertteri sen olevan tyhj„
|
||||
merkki ja asettaa sen leveydeksi kaikkien merkkien leveyden keskiarvon
|
||||
(toimii hyvin). T„t„ voi viritt„„ muuttamalla spacen leveytt„
|
||||
fonttitiedostosta (offset 16+256*2+32*2=592=250h).
|
||||
* Jokaisen kirjainrivin peruslinjan kohdalle (esim kirjainten
|
||||
alareuna) on ruudun vasempaan reunaan laitettava piste (v„ri
|
||||
joku muu kuin 0/15). T„m„ piste synkronisoi fontit samalle
|
||||
riville, esim 1 (* kyseist„ v„ri„):
|
||||
ESIM1....................... ...................ÛÛ............
|
||||
...........Û......Û......... .....ÛÛ**..**ÛÛ....ÛÛ............
|
||||
......ÛÛÛ..Û................ ........ÛÛÛÛ......ÛÛ.............
|
||||
.....Û...Û.ÛÛÛ....Û......... .......Û....Û......*.............
|
||||
.....ÛÛÛÛÛ.Û..Û...Û......... .......Û....Û......*.............
|
||||
*....Û...Û.ÛÛÛ....Û......... .......Û....Û......*.............
|
||||
................ÛÛ.......... ........ÛÛÛÛ.......*.............
|
||||
............................ ............................ESIM2
|
||||
* Jos kirjaimissa on irtaimia osia, tulee ne yhdist„„ samalla v„rill„
|
||||
jolla ruudun vasemman reunan piste piirrettiin. Esim 2 yl„puolella.
|
||||
* Kaikkien merkkien tulee my”s ulottua peruslinjalle asti. Jollei
|
||||
n„in ole, voidaan merkki„ 'jatkaa' yhdistysv„rill„ (esim 2).
|
||||
* Fonttia muunnettaessa yhdistysv„ri katoaa; se ei siis h„iritse
|
||||
tulostusta.
|
||||
|
||||
* Kun kuva on talletettu, kopioidaan se t„h„n hakemistoon ja ajetaan
|
||||
dofont: DOFONT <tiedostonnimi ilman .LBM:„„)
|
||||
esim: DOFONT fontti3
|
||||
Lopputulos on esimerkkitapauksessa FONTTI3.FNT, jota voi k„ytt„„
|
||||
PRINT ohjelmassa.
|
||||
|
||||
|
||||
|
||||
PRINT ohjelma - EPSON/IBM Graphics etc. yht. sop.
|
||||
|
||||
K„ytt”: PRINT "teksti"
|
||||
esim: PRINT "Testiteksti!"
|
||||
Lis„parametrit: /F<fontinnimi>
|
||||
/S<lis„tyhj„„ kirjainten v„liin n„in monta pixeli„>
|
||||
Oletukset: fontinnimi=DEFAULT.FNT
|
||||
lis„tyhj„=0
|
||||
Maksimit: fonttitiedoston koko 30000 tavua
|
||||
|
||||
|
||||
|
||||
|
||||
.FNT tiedoston formaatti:
|
||||
|
||||
8 bytes: "BIGFONT",1ah
|
||||
1 word: fontin korkeus merkeiss„ (1 merkki=8 pikseli„)
|
||||
1 word: lis„v„lityhj„n oletusarvo (nyky„„n aina 0lla)
|
||||
1 word: 0
|
||||
1 word: 0
|
||||
Seuraavissa taulukoissa indeksin„ k„ytet„„n fontin (ASCII) numeroa:
|
||||
256 words: merkin osoite tiedostossa (tavuja alusta)
|
||||
256 words: merkin leveys (pikseli„)
|
||||
bytes: merkkidata
|
||||
|
||||
|
||||
C-sorsien k„„nt„minen (%=sorsan nimi):
|
||||
cl /W3 /AL /qc %.c tai qcl /AL %.c
|
||||
BIN
GRAB/FONT/ST3LOGO.BIN
Normal file
BIN
GRAB/FONT/ST3LOGO.BIN
Normal file
Binary file not shown.
BIN
GRAB/FONT/TIMES.LBM
Normal file
BIN
GRAB/FONT/TIMES.LBM
Normal file
Binary file not shown.
BIN
GRAB/FONT/TMP
Normal file
BIN
GRAB/FONT/TMP
Normal file
Binary file not shown.
433
GRAB/FONT/TOBM.C
Normal file
433
GRAB/FONT/TOBM.C
Normal file
|
|
@ -0,0 +1,433 @@
|
|||
#include <stdio.h>
|
||||
#include <graph.h>
|
||||
#include <string.h>
|
||||
#include <conio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int scan(void);
|
||||
int doblock(FILE *f1);
|
||||
int readlbm(FILE *f1);
|
||||
int showline(int y);
|
||||
|
||||
int bluecol=1;
|
||||
int backcol=15;
|
||||
|
||||
char tablex[256];
|
||||
char tabley[256];
|
||||
int tablep=0;
|
||||
|
||||
FILE *out;
|
||||
long f_off[256];
|
||||
char f_wid[256];
|
||||
char f_hig[256];
|
||||
char f_base[256];
|
||||
long averwid;
|
||||
int avercnt;
|
||||
|
||||
main(int argc,char *argv[])
|
||||
{
|
||||
int a;
|
||||
FILE *f1;
|
||||
if(argc==1)
|
||||
{
|
||||
printf("usage: FONT <srclbm> <desttmpfont>");
|
||||
return(0);
|
||||
}
|
||||
_setvideomode(_VRES16COLOR);
|
||||
for(a=0;a<256;a++)
|
||||
{
|
||||
f_off[a]=0;
|
||||
f_wid[a]=0;
|
||||
f_hig[a]=0;
|
||||
}
|
||||
avercnt=0; averwid=0;
|
||||
out=fopen(argv[2],"wb");
|
||||
putw(0x1a1a,out);
|
||||
putw(tablep,out);
|
||||
fwrite(tablex,1,256,out);
|
||||
fwrite(tabley,1,256,out);
|
||||
f1=fopen(argv[1],"rb");
|
||||
readlbm(f1);
|
||||
{
|
||||
char buf[64];
|
||||
int x0,y0,x,y,a;
|
||||
for(y0=2;y0<7*8-2;y0+=8)
|
||||
for(x0=0;x0<56*8;x0+=8)
|
||||
{
|
||||
for(a=x=0;x<8;x++) for(y=0;y<8;y++)
|
||||
{
|
||||
if((buf[x+y*8]=_getpixel(x0+x,y0+y))==0) a=1;
|
||||
}
|
||||
if(a)
|
||||
{
|
||||
tablex[tablep]=x0/8;
|
||||
tabley[tablep++]=(y0-2)/8;
|
||||
for(y=0;y<8;y++)
|
||||
{
|
||||
for(a=x=0;x<8;x++)
|
||||
{
|
||||
if(!buf[x+y*8]) a+=128>>x;
|
||||
}
|
||||
putc(a,out);
|
||||
}
|
||||
_setcolor(15);
|
||||
}
|
||||
else _setcolor(8);
|
||||
_setpixel(x0,y0);
|
||||
}
|
||||
}
|
||||
getch();
|
||||
fclose(f1);
|
||||
fseek(out,0L,SEEK_SET);
|
||||
putw(0x1a1a,out);
|
||||
putw(tablep,out);
|
||||
fwrite(tablex,1,256,out);
|
||||
fwrite(tabley,1,256,out);
|
||||
fclose(out);
|
||||
_setvideomode(_DEFAULTMODE);
|
||||
printf("tablecount:%i",tablep);
|
||||
}
|
||||
|
||||
unsigned char linebuf[1024];
|
||||
unsigned char pal[768];
|
||||
|
||||
int showline(int y)
|
||||
{
|
||||
int x;
|
||||
for(x=0;x<640;x++)
|
||||
{
|
||||
_setcolor(linebuf[x]);
|
||||
_setpixel(x,y);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int cbits[8]={1,2,4,8,16,32,64,128};
|
||||
int lbmmode; /* 1=DPII, 2=DPIIe */
|
||||
char *errtxt;
|
||||
char lasttype[5];
|
||||
char type[5]={"----"};
|
||||
long len;
|
||||
int xsz,ysz,planes,stencil,colors,mode;
|
||||
char lbmtype[4];
|
||||
int checktype=0;
|
||||
|
||||
int eschit(void)
|
||||
{
|
||||
if(kbhit())
|
||||
{
|
||||
if(getch()==27) return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int getaw(FILE *f1)
|
||||
{
|
||||
unsigned int a;
|
||||
a=getc(f1)*256;
|
||||
a+=getc(f1);
|
||||
return(a);
|
||||
}
|
||||
|
||||
int readlbm(FILE *f1)
|
||||
{
|
||||
int x,y,a,b,c;
|
||||
long l;
|
||||
unsigned u;
|
||||
int firstone=1;
|
||||
errtxt=NULL;
|
||||
do
|
||||
{
|
||||
memcpy(lasttype,type,5);
|
||||
/* get header */
|
||||
do
|
||||
{
|
||||
type[0]=getc(f1);
|
||||
}
|
||||
while(type[0]==0 && !feof(f1));
|
||||
type[1]=getc(f1); type[2]=getc(f1); type[4]=0;
|
||||
type[3]=getc(f1); len=getc(f1)*256L*65536L;
|
||||
if(firstone && memcmp(type,"FORM",4)) return(2);
|
||||
firstone=0;
|
||||
len+=getc(f1)*65536L; len+=getc(f1)*256L; len+=getc(f1);
|
||||
/* process it */
|
||||
a=doblock(f1);
|
||||
if(errtxt!=NULL)
|
||||
{
|
||||
printf("%s\n",errtxt);
|
||||
return(1);
|
||||
}
|
||||
if(a==-1)
|
||||
{
|
||||
printf("Not a Deluxepaint file!");
|
||||
return(2);
|
||||
}
|
||||
if(a==2)
|
||||
{
|
||||
printf("OLD:<%s> NEW<%s>\n",lasttype,type);
|
||||
return(1);
|
||||
}
|
||||
else if(a==1) break;
|
||||
}
|
||||
while(!feof(f1));
|
||||
return(0);
|
||||
}
|
||||
|
||||
int doblock(FILE *f1)
|
||||
{ /* processes one block */
|
||||
long lastpos=ftell(f1);
|
||||
int a,b,c,d,e,f;
|
||||
if(!strcmp(type,"CMAP"))
|
||||
{
|
||||
/* color map */
|
||||
for(b=0;b<colors*3;b++)
|
||||
{
|
||||
a=getc(f1)/4;
|
||||
pal[b]=a;
|
||||
}
|
||||
/* load colors */
|
||||
for(a=0;a<16;a++) /* vga */
|
||||
{
|
||||
inp(0x3da);
|
||||
outp(0x3c0,a);
|
||||
outp(0x3c0,a);
|
||||
outp(0x3c8,a);
|
||||
outp(0x3c9,pal[a*3+0]);
|
||||
outp(0x3c9,pal[a*3+1]);
|
||||
outp(0x3c9,pal[a*3+2]);
|
||||
}
|
||||
inp(0x3da);
|
||||
outp(0x3c0,32);
|
||||
}
|
||||
else if(!strcmp(type,"FORM"))
|
||||
{ /* skip size of file, NO pointer movement */
|
||||
for(a=0;a<8;a++) lbmtype[a]=getc(f1);
|
||||
lbmtype[a]=0;
|
||||
/* LMDSBMHD - pakkaamaton formaatti */
|
||||
if(!memcmp(lbmtype,"ILBMBMHD",8))
|
||||
{
|
||||
lbmmode=1;
|
||||
}
|
||||
else if(!memcmp(lbmtype,"PBM BMHD",8))
|
||||
{
|
||||
lbmmode=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
errtxt="Unknown fileformat!";
|
||||
return(-1);
|
||||
}
|
||||
getaw(f1); /* headerin lopun pituus */
|
||||
getaw(f1); /* - */
|
||||
xsz=getaw(f1);
|
||||
ysz=getaw(f1);
|
||||
getaw(f1); /* ? */
|
||||
getaw(f1); /* ? */
|
||||
|
||||
planes=getc(f1);
|
||||
stencil=getc(f1);
|
||||
colors=getaw(f1);
|
||||
getaw(f1); /* ? */
|
||||
getaw(f1); /* ? */
|
||||
getaw(f1); /* screen-size-x */
|
||||
getaw(f1); /* screen-size-y */
|
||||
|
||||
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
|
||||
"Size: %i x %i (Colors:%i)\nPlanes:%i Stencil:%i\n",
|
||||
xsz,ysz,colors,planes,stencil);
|
||||
return(0);
|
||||
}
|
||||
else if(!strcmp(type,"CRNG"))
|
||||
{
|
||||
}
|
||||
else if(!strcmp(type,"DPPS"))
|
||||
{
|
||||
}
|
||||
else if(!strcmp(type,"DPPV"))
|
||||
{
|
||||
}
|
||||
else if(!strcmp(type,"TINY"))
|
||||
{ /* pikkukuva */
|
||||
}
|
||||
else if(!strcmp(type,"BODY") && lbmmode==2)
|
||||
{
|
||||
int lp,cbit,y=0;
|
||||
while(!eschit() && y<ysz)
|
||||
{
|
||||
memset(linebuf,0,xsz);
|
||||
{
|
||||
lp=0;
|
||||
while(lp<xsz)
|
||||
{
|
||||
a=getc(f1);
|
||||
if(a>127)
|
||||
{
|
||||
c=getc(f1);
|
||||
a=256-a;
|
||||
if(a==0) c=0;
|
||||
for(b=0;b<=a;b++) linebuf[lp++]=c;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(b=0;b<=a;b++)
|
||||
{
|
||||
c=getc(f1);
|
||||
linebuf[lp++]=c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
showline(y);
|
||||
y++;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
else if(!strcmp(type,"BODY") && lbmmode==1)
|
||||
{
|
||||
int lp,cbit,y=0;
|
||||
while(!eschit() && y<ysz)
|
||||
{
|
||||
memset(linebuf,0,xsz);
|
||||
for(d=0;d<planes;d++)
|
||||
{
|
||||
cbit=cbits[d];
|
||||
lp=0;
|
||||
while(lp<xsz)
|
||||
{
|
||||
a=getc(f1);
|
||||
if(a>127)
|
||||
{
|
||||
c=getc(f1);
|
||||
a=256-a;
|
||||
if(a==0) c=0;
|
||||
for(b=0;b<=a;b++)
|
||||
{
|
||||
linebuf[lp++]|=c&128?cbit:0;
|
||||
linebuf[lp++]|=c&64?cbit:0;
|
||||
linebuf[lp++]|=c&32?cbit:0;
|
||||
linebuf[lp++]|=c&16?cbit:0;
|
||||
linebuf[lp++]|=c&8?cbit:0;
|
||||
linebuf[lp++]|=c&4?cbit:0;
|
||||
linebuf[lp++]|=c&2?cbit:0;
|
||||
linebuf[lp++]|=c&1?cbit:0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(b=0;b<=a;b++)
|
||||
{
|
||||
c=getc(f1);
|
||||
linebuf[lp++]|=c&128?cbit:0;
|
||||
linebuf[lp++]|=c&64?cbit:0;
|
||||
linebuf[lp++]|=c&32?cbit:0;
|
||||
linebuf[lp++]|=c&16?cbit:0;
|
||||
linebuf[lp++]|=c&8?cbit:0;
|
||||
linebuf[lp++]|=c&4?cbit:0;
|
||||
linebuf[lp++]|=c&2?cbit:0;
|
||||
linebuf[lp++]|=c&1?cbit:0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(stencil) for(lp=0;lp<xsz;)
|
||||
{
|
||||
a=getc(f1);
|
||||
if(a>127)
|
||||
{
|
||||
c=getc(f1);
|
||||
a=256-a;
|
||||
lp+=a*8+8;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(b=0;b<=a;b++)
|
||||
{
|
||||
c=getc(f1);
|
||||
}
|
||||
lp+=a*8+8;
|
||||
}
|
||||
}
|
||||
showline(y);
|
||||
y++;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
else if(checktype)
|
||||
{
|
||||
return(2);
|
||||
}
|
||||
fseek(f1,lastpos+len,SEEK_SET);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int letter(int chr,int x,int y)
|
||||
{
|
||||
int basey;
|
||||
int x1,y1,x2,y2,a,c=1;
|
||||
x1=x2=x; y1=y2=y;
|
||||
/* expand box */
|
||||
while(c)
|
||||
{
|
||||
c=0;
|
||||
for(a=x1;a<=x2;a++)
|
||||
{
|
||||
if(y1>=0 && _getpixel(a,y1)!=backcol) { y1--; c=1; }
|
||||
if(y2<=479 && _getpixel(a,y2)!=backcol) { y2++; c=1; }
|
||||
}
|
||||
for(a=y1;a<=y2;a++)
|
||||
{
|
||||
if(x1>=0 && _getpixel(x1,a)!=backcol) { x1--; c=1; }
|
||||
if(x2<=639 && _getpixel(x2,a)!=backcol) { x2++; c=1; }
|
||||
}
|
||||
if(x1<=0 || y1<=0 || x2>=639 || y2>=479) exit(1);
|
||||
}
|
||||
basey=y-y1;
|
||||
/* erase blue */
|
||||
for(y=y1;y<=y2;y++)
|
||||
for(x=x1;x<=x2;x++)
|
||||
{
|
||||
if(_getpixel(x,y)==bluecol)
|
||||
{
|
||||
_setcolor(backcol);
|
||||
_setpixel(x,y);
|
||||
}
|
||||
}
|
||||
/* save font */
|
||||
{
|
||||
avercnt++;
|
||||
averwid+=x2-x1+1;
|
||||
f_wid[chr]=x2-x1+1;
|
||||
f_hig[chr]=y2-y1+1;
|
||||
f_base[chr]=basey;
|
||||
f_off[chr]=ftell(out);
|
||||
for(y=y1;y<=y2;y++)
|
||||
for(x=x1;x<=x2;x++)
|
||||
{
|
||||
if(_getpixel(x,y)!=backcol) putc(1,out);
|
||||
else putc(0,out);
|
||||
}
|
||||
}
|
||||
/* erase box */
|
||||
_setcolor(backcol);
|
||||
_rectangle(_GFILLINTERIOR,x1,y1,x2,y2);
|
||||
return(0);
|
||||
}
|
||||
|
||||
unsigned char order[256]={
|
||||
"!\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
||||
"`abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
"<EFBFBD>Ž™†„”"
|
||||
"àáâãäåæçèéêëìíîï"};
|
||||
int scan(void)
|
||||
{
|
||||
int y,x,a=0;
|
||||
for(y=0;y<480;y++) if((bluecol=_getpixel(0,y))!=backcol)
|
||||
{
|
||||
for(x=1;x<640;x++) if(_getpixel(x,y)!=backcol)
|
||||
{
|
||||
if(letter(order[a++],x,y)) return(1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
Loading…
Reference in a new issue