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