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