Source code for /engineering/2XTILE/MSKFONT8.COriginal file MSKFONT8.C
   1 /*
   2 
   3  MSKFONT8 utility for the XTile graphics manager
   4 
   5  COPYRIGHT (C) 1993  Erich P Gatejen   All Rights Reserved
   6 
   7 
   8  File: MSKFONT8.C    	Written for the Turbo C compiler
   9 
  10 
  11  Will create a mask set for a 8-pixel .FNT font.
  12 
  13 
  14 */
  15 
  16 #define   CHARSIZE		80	/* size in bytes of each character */ 
  17 #define   Psize		20   /* size in bytes of each plane	*/
  18 
  19 #include<stdio.h>
  20 #include<conio.h>
  21 #include<alloc.h>
  22 
  23 
  24 FILE 	*in,		*out;
  25 
  26 char		File_NameI[13];          /* Input file name	*/
  27 char		File_NameO[13];          /* Output file name */
  28 
  29 unsigned char		*inbuf,        /* Buffer to hold char picture	*/
  30 				*base,         /* Pointer into inbuf			*/
  31 				*current;		/* Current position in inbuf		*/
  32 
  33 unsigned char		Hold;          /* Mask generator				*/
  34 
  35 unsigned int		Number;        /* Number of characters			*/
  36 
  37 
  38 
  39 int		step, step2, mainloop;	/* Looping vars	*/
  40 
  41 void main () {
  42 
  43 	printf ("File name : ");
  44 	scanf("%8s", File_NameI );	/* Get file name from user	*/
  45 
  46 	printf ("Number of characters : ");
  47 	scanf("%d", &Number );	    	/* Get number of characters   */
  48 
  49 	do {
  50           File_NameO[ step ] = File_NameI[ step ];
  51 		step++;
  52 
  53 	   } while (File_NameI[ step ] != 0);    /* Pack the file name	*/
  54 
  55 	File_NameI[ step ] = '.';
  56 	File_NameO[ step ] = '.';
  57 	File_NameI[step+1] = 'F';
  58 	File_NameO[step+1] = 'M';
  59 	File_NameI[step+2] = 'N';
  60 	File_NameO[step+2] = 'S';
  61 	File_NameI[step+3] = 'T';
  62 	File_NameO[step+3] = 'F';
  63 	File_NameI[step+4] = 0;
  64 	File_NameO[step+4] = 0;    	/* Add extensions to file names	*/
  65 
  66 	in  = fopen( File_NameI, "rb" );
  67 	out = fopen( File_NameO, "wb" );	/* Open files		*/
  68 
  69 	inbuf = farmalloc( CHARSIZE );     /* Allocate memory for each char */
  70 
  71 	if (( in == 0 ) || ( out == 0 ) || ( inbuf == NULL)) {
  72 		printf(" ERROR \n");
  73 		exit(1);
  74 		};
  75 
  76 	/* Loop through number of characters	   */
  77 	for ( mainloop = 0; mainloop < Number; mainloop++ ) {
  78 
  79 	   if ( feof( in ) ) break;	/* See if we have emptied input file  */
  80 
  81 	   fread( inbuf, sizeof(char), CHARSIZE, in );   /* Get picture */
  82 
  83 	   base = inbuf;
  84 	   current = base;
  85 
  86 	   /* Loop through each line and make the mask		*/
  87 	   /* If byte is 0, then mask it's bit				*/
  88 	   for ( step = 0; step < 10; step = step + 1 ) {
  89 
  90 		Hold = 0;    	/* Clear mask holding var		*/
  91 
  92 		/* Do low nibble of mask */
  93 		if (*current != 0) Hold = Hold + 1; /* Plane 0 */
  94 
  95 		current = current + Psize;
  96 		if (*current != 0) Hold = Hold + 2; /* Plane 1 */
  97 
  98 		current = current + Psize;
  99 		if (*current != 0) Hold = Hold + 4; /* Plane 2 */
 100 
 101 		current = current + Psize;
 102 		if (*current != 0) Hold = Hold + 8; /* Plane 3 */
 103 
 104 		current = base;
 105 		current++;          /* Adjust to look for low nibble */
 106 
 107 		/* Do high nibble of mask */
 108 		if (*current != 0) Hold = Hold + 16; /* Plane 0 */
 109 
 110 		current = current + Psize;
 111 		if (*current != 0) Hold = Hold + 32; /* Plane 1 */
 112 
 113 		current = current + Psize;
 114 		if (*current != 0) Hold = Hold + 64; /* Plane 2 */
 115 
 116 		current = current + Psize;
 117 		if (*current != 0) Hold = Hold + 128; /* Plane 3 */
 118 
 119 		base++;
 120 		base++; 	/* Goto next line  */
 121 
 122 		current = base;	
 123 
 124 		fputc( Hold, out );  	/* Write mask to the file	*/
 125 
 126 
 127 	   };
 128 
 129 	};
 130 
 131 	fclose( in  );
 132 	fclose( out );	/* Close files and done	*/
 133 
 134 };