Diff for /mkfont32/accessories/mkres.c between versions 1.1 and 1.3

version 1.1, 2004/06/06 15:33:09 version 1.3, 2004/06/10 03:11:46
Line 120  static void dump(const char *dstfile, co Line 120  static void dump(const char *dstfile, co
   
 // ----  // ----
   
 static void font8x8(const char *dstfile, const char *sym,  enum {
                                                                         const char *srcname, UINT sx, UINT sy) {          MKRES_SUCCESS           = 0,
           MKRES_ERRWIDTH          = 1,
         BMPRES  *res;          MKRES_ERRHEIGHT         = 2,
         UINT    size;          MKRES_ERRBMP            = 3,
         BYTE    *ptr;          MKRES_ERRMEMORY         = 4,
         BYTE    *p;  
         UINT    x;          MKRES_ERROR                     = 255
         UINT    y;  };
         UINT    i;  
   static char *getval(const char *ptr, int *pval) {
         res = bmpload(srcname);  
         if (res == NULL) {          int             val;
                 goto f_err1;          int             s;
         }          int             c;
         if ((res->width < (int)(sx * 8)) || (res->height < (int)(sy * 8))) {  
                 goto f_err2;          val = 0;
         }          s = 1;
         size = sx * sy * 8;  
         ptr = (BYTE *)_MALLOC(size, srcname);          c = *ptr;
         if (ptr == NULL) {          if (c == '+') {
                 goto f_err2;                  ptr++;
         }          }
         p = ptr;          else if (c == '-') {
         for (y=0; y<sy; y++) {                  ptr++;
                 for (x=0; x<sx; x++) {                  s = -1;
                         for (i=0; i<8; i++) {          }
                                 *p++ = res->ptr[x + (((y * 8) + i) * res->align)];          while(1) {
                         }                  c = *ptr;
                   c -= '0';
                   if ((unsigned)c < 10) {
                           val *= 10;
                           val += c;
                           ptr++;
                   }
                   else {
                           break;
                 }                  }
         }          }
         dump(dstfile, sym, ptr, size);          if (pval) {
                   *pval = val * s;
         _MFREE(ptr);          }
           return((char *)ptr);
 f_err2:  
         _MFREE(res);  
   
 f_err1:  
         return;  
 }  }
   
 static void font8x16(const char *dstfile, const char *sym,  static int mkres(const char *dstfile, const char *sym,
                                                                         const char *srcname, UINT sx, UINT sy) {                                                                          const char *srcname, UINT cx, UINT cy) {
   
           int             ret;
         BMPRES  *res;          BMPRES  *res;
           UINT    sx;
           UINT    sy;
         UINT    size;          UINT    size;
         BYTE    *ptr;          BYTE    *ptr;
         BYTE    *p;          BYTE    *p;
           BYTE    *q;
         UINT    x;          UINT    x;
         UINT    y;          UINT    y;
         UINT    i;          UINT    i;
           UINT    j;
   
         res = bmpload(srcname);          ret = MKRES_ERROR;
         if (res == NULL) {  
           if ((cx == 0) || ((cx & 7) != 0)) {
                   ret = MKRES_ERRWIDTH;
                 goto f_err1;                  goto f_err1;
         }          }
         if ((res->width < (int)(sx * 8)) || (res->height < (int)(sy * 16))) {          if (cy == 0) {
                 goto f_err2;                  ret = MKRES_ERRHEIGHT;
         }                  goto f_err1;
         size = sx * sy * 16;  
         ptr = (BYTE *)_MALLOC(size, srcname);  
         if (ptr == NULL) {  
                 goto f_err2;  
         }  
         p = ptr;  
         for (y=0; y<sy; y++) {  
                 for (x=0; x<sx; x++) {  
                         for (i=0; i<16; i++) {  
                                 *p++ = res->ptr[x + (((y * 16) + i) * res->align)];  
                         }  
                 }  
         }          }
         dump(dstfile, sym, ptr, size);  
   
         _MFREE(ptr);  
   
 f_err2:  
         _MFREE(res);  
   
 f_err1:  
         return;  
 }  
   
 static void font16x16(const char *dstfile, const char *sym,  
                                                                         const char *srcname, UINT sx, UINT sy) {  
   
         BMPRES  *res;  
         UINT    size;  
         BYTE    *ptr;  
         BYTE    *p;  
         UINT    x;  
         UINT    y;  
         UINT    i;  
   
         res = bmpload(srcname);          res = bmpload(srcname);
         if (res == NULL) {          if (res == NULL) {
                   ret = MKRES_ERRBMP;
                 goto f_err1;                  goto f_err1;
         }          }
         if ((res->width < (int)(sx * 16)) || (res->height < (int)(sy * 16))) {  
           sx = res->width / cx;
           if ((int)(sx * cx) != res->width) {
                   ret = MKRES_ERRWIDTH;
                   goto f_err2;
           }
           sy = res->height / cy;
           if ((int)(sy * cy) != res->height) {
                   ret = MKRES_ERRHEIGHT;
                 goto f_err2;                  goto f_err2;
         }          }
         size = sx * 2 * sy * 16;          cx >>= 3;
   
           size = sx * cx * sy * cy;
         ptr = (BYTE *)_MALLOC(size, srcname);          ptr = (BYTE *)_MALLOC(size, srcname);
         if (ptr == NULL) {          if (ptr == NULL) {
                   ret = MKRES_ERRMEMORY;
                 goto f_err2;                  goto f_err2;
         }          }
         p = ptr;          q = ptr;
         for (y=0; y<sy; y++) {          for (y=0; y<sy; y++) {
                 for (x=0; x<sx; x++) {                  for (x=0; x<sx; x++) {
                         for (i=0; i<16; i++) {                          p = res->ptr + (x * cx) + (y * cy * res->align);
                                 *p++ = res->ptr[(x * 2) + 0 + (((y * 16) + i) * res->align)];                          for (i=0; i<cy; i++) {
                                 *p++ = res->ptr[(x * 2) + 1 + (((y * 16) + i) * res->align)];                                  for (j=0; j<cx; j++) {
                                           q[j] = p[j];
                                   }
                                   p += res->align;
                                   q += j;
                         }                          }
                 }                  }
         }          }
Line 240  static void font16x16(const char *dstfil Line 233  static void font16x16(const char *dstfil
   
         _MFREE(ptr);          _MFREE(ptr);
   
           ret = MKRES_SUCCESS;
   
 f_err2:  f_err2:
         _MFREE(res);          _MFREE(res);
   
 f_err1:  f_err1:
         return;          return(ret);
 }  }
   
 int main(int argc, char **argv) {  int main(int argc, char **argv) {
   
         font8x8("..\\cmn_8.res", "cmn_8", "cmn_8.bmp", 0x20, 5);          char    *p;
         font8x8("..\\pc98_8.res", "pc98_8", "pc98_8.bmp", 0x20, 3);          int             cx;
         font8x16("..\\pc98_16.res", "pc98_16", "pc98_16.bmp", 0x20, 3);          int             cy;
         font16x16("..\\jis28xx.res", "jis28xx", "jis28xx.bmp", 0x20, 1);  
         font8x16("..\\jis29xx.res", "jis29xx", "jis29xx.bmp", 0x5e, 1);          if (argc < 5) {
         font8x16("..\\jis2axx.res", "jis2axx", "jis2axx.bmp", 0x5e, 1);                  puts("usage: mkres resfile symbol bmpfile width.height");
         font8x16("..\\jis2bxx.res", "jis2bxx", "jis2bxx.bmp", 0x5e, 1);                  return(255);
         font16x16("..\\jis2cxx.res", "jis2cxx", "jis2cxx.bmp", 0x4c, 1);          }
         return(0);          p = getval(argv[4], &cx);
           if (p[0]) {
                   p++;
           }
           p = getval(p, &cy);
           return(mkres(argv[1], argv[2], argv[3], cx, cy));
 }  }
   

Removed from v.1.1  
changed lines
  Added in v.1.3


RetroPC.NET-CVS <cvs@retropc.net>