Source code for /engineering/rendsite/test/source/2XTILE/MSKFONT4.COriginal file MSKFONT4.C
   1 /*
   2 
   3  MSKFONT4 utility for the XTile graphics manager
   4 
   5  COPYRIGHT (C) 1993  Erich P Gatejen   All Rights Reserved
   6 
   7 
   8  File: MSKFONT4.C    	Written for the Turbo C compiler
   9 
  10 
  11  Will create a mask set for a 4-pixel .FNT font.
  12 
  13 
  14 */
  15 
  16 #define   CHARSIZE		24	/* size in bytes of each character */ 
  17 #define   Psize		6    /* 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 XBlock set and make the mask	*/
  87 	   /* If byte is 0, then mask it's bit				*/
  88 	   for ( step = 0; step < 3; ++step ) {
  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 + 1;          /* Adjust to look for high nibble */
 105 
 106 		/* Do low nibble of mask */
 107 		if (*current != 0) Hold = Hold + 16; /* Plane 0 */
 108 
 109 		current = current + Psize;
 110 		if (*current != 0) Hold = Hold + 32; /* Plane 1 */
 111 
 112 		current = current + Psize;
 113 		if (*current != 0) Hold = Hold + 64; /* Plane 2 */
 114 
 115 		current = current + Psize;
 116 		if (*current != 0) Hold = Hold + 128; /* Plane 3 */
 117 
 118 		base++;
 119 		base++; 	/* Goto next set */
 120 
 121 		current = base;
 122 
 123 		fputc( Hold, out );  	/* Write mask to the file	*/
 124 
 125 
 126 	   };
 127 
 128 	};
 129 
 130 	fclose( in  );
 131 	fclose( out );	/* Close files and done	*/
 132 
 133 };