dumpfont.c revision 1.6 1 /* $NetBSD: dumpfont.c,v 1.6 2002/01/26 13:21:11 aymeric Exp $ */
2
3 /*
4 * This is a *real* hack to dump the topaz80 kernel font. This one is
5 * ways nicer than the ugly Mach font, but we'll have to dump it from a
6 * running system to not run against Commodore copyrights. *NEVER* distribute
7 * the generated font with BSD, always regenerate!
8 */
9
10 #include <exec/types.h>
11 #include <exec/memory.h>
12 #include <dos/dos.h>
13 #include <graphics/gfx.h>
14 #include <graphics/rastport.h>
15 #include <graphics/text.h>
16
17 #include <inline/exec.h>
18 #include <inline/graphics.h>
19
20 #include <stdio.h>
21
22 int
23 main(void)
24 {
25 unsigned char str[256], *pp;
26 int i;
27 struct TextAttr ta = { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT };
28 struct RastPort rp;
29 struct BitMap bm = { 256, /* bytes per row */
30 8, /* rows */
31 0, /* flags */
32 1, /* depth */
33 0, /* pad */
34 0 }; /* planes */
35 struct TextFont *tf;
36
37 InitRastPort (& rp);
38 rp.BitMap = &bm;
39 bm.Planes[0] = pp = AllocRaster (256 * 8, 8);
40
41 if (!pp)
42 {
43 fprintf (stderr, "Can't allocate raster!\n");
44 exit (1);
45 }
46 bzero (pp, 256 * 8);
47
48 tf = OpenFont (& ta);
49 if (! tf)
50 {
51 fprintf (stderr, "can't open topaz font.\n");
52 exit (1);
53 }
54
55 SetFont (&rp, tf);
56
57 /* initialize string to be printed */
58 for (i = 32; i < 256; i++) str[i - 32] = i;
59
60 Move (&rp, 0, 6);
61
62 Text (&rp, str, 256 - 32);
63 {
64 int bin = open ("bitmap", 1);
65 if (bin >= 0)
66 {
67 write (bin, pp, 256*8);
68 close (bin);
69 }
70 }
71
72 /* dump them.. */
73 printf ("/* generated automatically by dumpfont.c. *DONT* distribute\n");
74 printf (" this file, it contains information Copyright by Commodore!\n");
75 printf ("\n");
76 printf (" This is the (new) topaz80 system font: */\n\n");
77
78 printf ("unsigned char kernel_font_width = 8;\n");
79 printf ("unsigned char kernel_font_height = 8;\n");
80 printf ("unsigned char kernel_font_lo = 32;\n");
81 printf ("unsigned char kernel_font_hi = 255;\n\n");
82
83 printf ("unsigned char kernel_cursor[] = {\n");
84 printf (" 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\n\n");
85 printf ("unsigned char kernel_font[] = {\n");
86
87 for (i = 0; i < 256 - 32; i++)
88 {
89 printf( "/* %c */ ", i + 32);
90 printf( "0x%02x, 0x%02x, 0x%02x, 0x%02x, "
91 "0x%02x, 0x%02x, 0x%02x, 0x%02x,\n",
92 pp[i+0*256], pp[i+1*256], pp[i+2*256], pp[i+3*256],
93 pp[i+4*256], pp[i+5*256], pp[i+6*256], pp[i+7*256]);
94 }
95 printf ("};\n");
96
97 CloseFont (tf);
98 FreeRaster (pp, 256 * 8, 8);
99 }
100