-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfontc.c
79 lines (76 loc) · 1.87 KB
/
fontc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*** M2000: Portable P2000 emulator *****************************************/
/*** ***/
/*** fontc.c ***/
/*** ***/
/*** This file contains the font compiler ***/
/*** ***/
/*** Copyright (C) Marcel de Kogel 1996,1997 ***/
/*** You are not allowed to distribute this software commercially ***/
/*** Please, notify me, if you make any changes to this file ***/
/****************************************************************************/
#include <stdio.h>
#include <string.h>
int main (int argc,char *argv[])
{
FILE *infile,*outfile;
int a,count,shift;
char buf[256],*p;
char putbuf[10];
printf ("fontc: Teletext font compiler\n"
"Copyright (C) Marcel de Kogel 1996\n");
if (argc!=3)
{
printf ("Usage: fontc <infile> <outfile>\n");
return 1;
}
infile=fopen (argv[1],"rt");
if (!infile)
{
printf ("Cannot open %s\n",argv[1]);
return 2;
}
outfile=fopen (argv[2],"wb");
if (!outfile)
{
printf ("Cannot open %s\n",argv[2]);
return 3;
}
count=0;
while (fgets(buf,256,infile))
{
if (buf[0]=='-' || buf[0]=='+')
{
p=strchr (buf,' ');
if (p) *p='\0';
p=strchr (buf,'\n');
if (p) *p='\0';
p=buf+strlen(buf)-1;
a=0; shift=0;
while (p>=buf)
{
if (*p=='+') a|=(1<<shift);
shift++;
p--;
}
putbuf[count++]=a;
if (count==10)
{
fwrite (putbuf,1,10,outfile);
count=0;
}
}
else
{
if (count)
{
for (a=count;a;a=(a+1)%10)
fputc (0,outfile);
fwrite (putbuf,1,count,outfile);
count=0;
}
}
}
fclose (outfile);
fclose (infile);
return 1;
}