2 Copyright (C) 1998 BJ Eirich (aka vecna)
\r
3 This program is free software; you can redistribute it and/or
\r
4 modify it under the terms of the GNU General Public License
\r
5 as published by the Free Software Foundation; either version 2
\r
6 of the License, or (at your option) any later version.
\r
7 This program is distributed in the hope that it will be useful,
\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\r
10 See the GNU General Public Lic
\r
11 See the GNU General Public License for more details.
\r
12 You should have received a copy of the GNU General Public License
\r
13 along with this program; if not, write to the Free Software
\r
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
20 char fname1[100], fname2[100];
\r
25 char manufacturer; // pcx header
\r
28 char bits_per_pixel;
\r
29 short int xmin,ymin;
\r
30 short int xmax,ymax;
\r
36 short int bytes_per_line;
\r
37 short int palette_type;
\r
39 unsigned char pal[768];
\r
41 unsigned short int width,depth;
\r
42 unsigned short int bytes;
\r
43 unsigned char c, run, ss=0;
\r
44 unsigned int vidoffset, n=0;
\r
46 void ReadPCXLine(unsigned char *dest)
\r
52 c=fgetc(pcxf) & 0xff;
\r
53 if ((c & 0xc0)==0xc0) {
\r
56 for (j=0; j<run; j++)
\r
57 dest[vidoffset+n+j]=c;
\r
59 else { dest[vidoffset+n]=c;
\r
64 void LoadPCXHeader()
\r
66 fread(&manufacturer,1,1,pcxf);
\r
67 fread(&version,1,1,pcxf);
\r
68 fread(&encoding,1,1,pcxf);
\r
69 fread(&bits_per_pixel,1,1,pcxf);
\r
70 fread(&xmin,1,2,pcxf);
\r
71 fread(&ymin,1,2,pcxf);
\r
72 fread(&xmax,1,2,pcxf);
\r
73 fread(&ymax,1,2,pcxf);
\r
74 fread(&hres,1,2,pcxf);
\r
75 fread(&vres,1,2,pcxf);
\r
76 fread(&palette,1,48,pcxf);
\r
77 fread(&reserved,1,1,pcxf);
\r
78 fread(&color_planes,1,1,pcxf);
\r
79 fread(&bytes_per_line,1,2,pcxf);
\r
80 fread(&palette_type,1,2,pcxf);
\r
81 fread(&filler,1,58,pcxf);
\r
82 fseek(pcxf,-768L,SEEK_END);
\r
83 fread(&pal,1,768,pcxf);
\r
84 fseek(pcxf,128L,SEEK_SET);
\r
87 bytes=bytes_per_line;
\r
90 void dumpframe(int x, int y)
\r
94 for (i=y; i<y+ys; i++)
\r
95 for (j=x; j<x+xs; j++)
\r
97 c=virscr[(i*width)+j];
\r
98 fwrite(&c, 1, 1, fnt);
\r
106 printf("PCX2FNT v.3.00 Copyright (C)1998 BJ Eirich \n");
\r
107 printf("PCX filename: "); fflush(stdout);
\r
108 scanf("%s",fname1);
\r
109 pcxf=fopen(fname1,"rb");
\r
110 printf("FNT filename: "); fflush(stdout);
\r
111 scanf("%s",fname2);
\r
112 fnt=fopen(fname2, "wb");
\r
113 printf("Width of font: "); fflush(stdout);
\r
115 printf("Height of font: "); fflush(stdout);
\r
117 printf("Number of subsets: "); fflush(stdout);
\r
121 fwrite(&version, 1, 1, fnt);
\r
122 fwrite(&xs, 1, 2, fnt);
\r
123 fwrite(&ys, 1, 2, fnt);
\r
124 fwrite(&ns, 1, 2, fnt);
\r
127 virscr=(char *) malloc(width*depth);
\r
128 for (i=0; i<depth; i++)
\r
131 ReadPCXLine(virscr);
\r
134 for (z=0; z<ns; z++)
\r
135 for (i=0; i<5; i++)
\r
136 for (j=0; j<20; j++)
\r
137 if ((i*20)+j<96) dumpframe((j*(xs+1))+1,(i*(ys+1))+(1+(ys+1)*(z*5)));
\r
139 // for (i=0; i<5; i++)
\r
140 // for (j=0; j<20; j++)
\r
141 // if ((i*20)+j<96) dumpframe((j*(xs+1))+1,(i*(ys+1))+(1+(ys+1)*5));
\r