2013-07-06 04:37:13 +00:00
|
|
|
/*
|
2013-06-11 07:08:15 +00:00
|
|
|
* Apple // emulator for Linux: Font compiler
|
|
|
|
*
|
|
|
|
* Copyright 1994 Alexander Jean-Claude Bottema
|
|
|
|
* Copyright 1995 Stephen Lee
|
|
|
|
* Copyright 1997, 1998 Aaron Culliney
|
|
|
|
* Copyright 1998, 1999, 2000 Michael Deutschmann
|
|
|
|
*
|
|
|
|
* This software package is subject to the GNU General Public License
|
2013-07-06 04:37:13 +00:00
|
|
|
* version 2 or later (your choice) as published by the Free Software
|
2013-06-11 07:08:15 +00:00
|
|
|
* Foundation.
|
|
|
|
*
|
2013-07-06 04:37:13 +00:00
|
|
|
* THERE ARE NO WARRANTIES WHATSOEVER.
|
2013-06-11 07:08:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
|
|
|
|
|
|
|
|
/* I'm not sure if this is the correct way to detect libc 5/4. I long
|
|
|
|
* since removed it from my system.
|
|
|
|
*/
|
2013-07-06 04:37:13 +00:00
|
|
|
#ifdef __GLIBC__
|
2013-06-11 07:08:15 +00:00
|
|
|
#if __GLIBC__ == 1
|
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
/* Older Linux C libraries had getline removed (to humor programs that
|
2013-06-11 07:08:15 +00:00
|
|
|
* used that name for their own functions), but kept getdelim */
|
|
|
|
#define getline(l,s,f) getdelim(l,s,'\n',f)
|
|
|
|
|
|
|
|
#endif /* __GLIBC__ == 1 */
|
|
|
|
#endif /* __GLIBC__ */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
unsigned char byte;
|
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
char *line = 0;
|
2013-06-11 07:08:15 +00:00
|
|
|
size_t line_size = 0;
|
|
|
|
|
2013-06-19 07:07:41 +00:00
|
|
|
int i,mx=0;
|
2013-06-11 07:08:15 +00:00
|
|
|
|
|
|
|
printf("/* Apple II text font data\n"
|
2014-06-21 19:17:59 +00:00
|
|
|
" *\n"
|
2013-06-11 07:08:15 +00:00
|
|
|
" * THIS FILE IS AUTOMATICALLY GENERATED --- DO NOT EDIT\n"
|
|
|
|
" */\n");
|
2013-07-06 04:37:13 +00:00
|
|
|
|
2013-06-11 07:08:15 +00:00
|
|
|
i = 0x100;
|
|
|
|
|
|
|
|
while (getline(&line,&line_size,stdin) != -1)
|
|
|
|
{
|
2013-07-06 04:37:13 +00:00
|
|
|
if (line[0] == ';')
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2013-06-11 07:08:15 +00:00
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
if (line[0] == '=')
|
2013-06-11 07:08:15 +00:00
|
|
|
{
|
|
|
|
char *name,*size;
|
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
name = line + 1;
|
|
|
|
while (isspace(*name))
|
|
|
|
{
|
|
|
|
name++;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = strchr(name,',');
|
2013-06-11 07:08:15 +00:00
|
|
|
*size++ = 0;
|
2013-07-06 04:37:13 +00:00
|
|
|
mx = i = strtol(size,0,0);
|
2013-06-11 07:08:15 +00:00
|
|
|
|
|
|
|
printf("\nconst unsigned char %s[%d] =\n{\n ",name,i*8);
|
2013-07-06 04:37:13 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-06-11 07:08:15 +00:00
|
|
|
i--;
|
|
|
|
|
|
|
|
if (line[0] == ':')
|
|
|
|
{
|
|
|
|
int j = 8;
|
|
|
|
|
|
|
|
while (j--)
|
|
|
|
{
|
|
|
|
int k;
|
|
|
|
|
2013-07-06 04:37:13 +00:00
|
|
|
if (getline(&line,&line_size,stdin) == -1)
|
|
|
|
{
|
2013-06-19 07:07:41 +00:00
|
|
|
// ERROR ...
|
|
|
|
}
|
2013-07-06 04:37:13 +00:00
|
|
|
|
2013-06-11 07:08:15 +00:00
|
|
|
k = 8;
|
|
|
|
byte = 0;
|
|
|
|
while (k--)
|
|
|
|
{
|
|
|
|
byte <<= 1;
|
|
|
|
byte += (line[k] == '#');
|
|
|
|
}
|
2013-07-06 04:37:13 +00:00
|
|
|
|
|
|
|
if (j)
|
|
|
|
{
|
|
|
|
printf("0x%02x, ",byte);
|
|
|
|
}
|
2014-01-23 04:42:34 +00:00
|
|
|
else if (i)
|
2013-07-06 04:37:13 +00:00
|
|
|
{
|
|
|
|
printf("0x%02x,\n ",byte); /* last byte in glyph */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("0x%02x\n};\n",byte); /* last item in array */
|
|
|
|
}
|
2013-06-11 07:08:15 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-06 04:37:13 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2013-06-11 07:08:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (i)
|
2013-07-06 04:37:13 +00:00
|
|
|
{
|
2013-06-11 07:08:15 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"Trouble with font file at character 0x%02x\n",
|
|
|
|
mx-i-1);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
|
|
|
}
|
|
|
|
|