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