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