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