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