Diff for /np2/generic/cmndraw.c between versions 1.2 and 1.5

version 1.2, 2004/03/09 23:39:19 version 1.5, 2004/03/25 08:51:23
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
   #include        "bmpdata.h"
 #include        "scrnmng.h"  #include        "scrnmng.h"
   #include        "cpucore.h"
   #include        "font.h"
 #include        "cmndraw.h"  #include        "cmndraw.h"
   #include        "minifont.res"
   
   
 void cmndraw_getpals(CMNPALFN *fn, CMNPAL *pal, UINT pals) {  void cmndraw_getpals(CMNPALFN *fn, CMNPALS *pal, UINT pals) {
   
         UINT    i;          UINT    i;
   
Line 424  const BYTE *p; Line 428  const BYTE *p;
   
 // ----  // ----
   
 void cmddraw_fill(CMNVRAM *vram, int x, int y, int cx, int cy, CMNPAL *pal) {  void cmddraw_fill(CMNVRAM *vram, int x, int y, int cx, int cy, CMNPALS *pal) {
   
         if ((vram == NULL) || (pal == NULL)) {          if ((vram == NULL) || (pal == NULL)) {
                 return;                  return;
Line 453  void cmddraw_fill(CMNVRAM *vram, int x,  Line 457  void cmddraw_fill(CMNVRAM *vram, int x, 
         }          }
 }  }
   
   void cmddraw_text8(CMNVRAM *vram, int x, int y, const char *str, CMNPALS *pal) {
   
           UINT    s;
   const BYTE      *ptr;
           BYTE    src[10];
   
           if ((vram == NULL) || (str == NULL) || (pal == NULL)) {
                   return;
           }
           src[0] = 0;
           src[1] = 7;
           while(*str) {
                   s = (UINT)(*str++);
                   ptr = NULL;
                   if ((s >= 0x20) && (s < 0x80)) {
                           ptr = minifont + (s - 0x20) * 8;
                   }
                   else if ((s >= 0xa0) && (s < 0xe0)) {
                           ptr = minifont + (s - 0xa0 + 0x60) * 8;
                   }
                   if (ptr == NULL) {
                           continue;
                   }
                   src[0] = ptr[0];
                   CopyMemory(src + 2, ptr + 1, 7);
                   switch(vram->bpp) {
   #if defined(SUPPORT_8BPP)
                           case 8:
                                   cmndraw8_setfg(vram, src, x, y, pal->pal8);
                                   break;
   #endif
   #if defined(SUPPORT_16BPP)
                           case 16:
                                   cmndraw16_setfg(vram, src, x, y, pal->pal16);
                                   break;
   #endif
   #if defined(SUPPORT_24BPP)
                           case 24:
                                   cmndraw24_setfg(vram, src, x, y, pal->pal32);
                                   break;
   #endif
   #if defined(SUPPORT_32BPP)
                           case 32:
                                   cmndraw32_setfg(vram, src, x, y, pal->pal32);
                                   break;
   #endif
                   }
                   x += ptr[0] + 1;
           }
   }
   
   
   // ---- bmp
   
   void cmddraw_bmp16(CMNVRAM *vram, const void *bmp, CMNPALCNV cnv) {
   
   const BMPFILE   *bf;
   const BMPINFO   *bi;
   const BYTE              *palptr;
           BMPDATA         inf;
           BYTE            *src;
           int                     bmpalign;
           UINT            pals;
           UINT            c;
           RGB32           paltbl[16];
           CMNPAL          pal[16];
           BYTE            *dst;
           int                     yalign;
           int                     x;
           int                     y;
   
           if ((vram == NULL) || (bmp == NULL) || (cnv == NULL)) {
                   return;
           }
           bf = (BMPFILE *)bmp;
           bi = (BMPINFO *)(bf + 1);
           palptr = (BYTE *)(bi + 1);
           if (((bf->bfType[0] != 'B') && (bf->bfType[1] != 'M')) ||
                   (bmpdata_getinfo(bi, &inf) != SUCCESS) || (inf.bpp != 4)) {
                   return;
           }
           src = (BYTE *)bf + (LOADINTELDWORD(bf->bfOffBits));
           bmpalign = bmpdata_getalign(bi);
           if (inf.height > 0) {
                   src += (inf.height - 1) * bmpalign;
                   bmpalign *= -1;
           }
           else {
                   inf.height *= -1;
           }
           if ((vram->width < inf.width) || (vram->height < inf.height)) {
                   return;
           }
           pals = LOADINTELDWORD(bi->biClrUsed);
           pals = min(pals, 16);
           ZeroMemory(paltbl, sizeof(paltbl));
           for (c=0; c<pals; c++) {
                   paltbl[c].p.b = palptr[c*4+0];
                   paltbl[c].p.g = palptr[c*4+1];
                   paltbl[c].p.r = palptr[c*4+2];
           }
           (*cnv)(pal, paltbl, pals, vram->bpp);
           dst = vram->ptr;
   #if 0
           dst += ((vram->width - inf.width) / 2) * vram->xalign;
           dst += ((vram->height - inf.height) / 2) * vram->yalign;
   #endif
           yalign = vram->yalign - (inf.width * vram->xalign);
           switch(vram->bpp) {
   #if defined(SUPPORT_16BPP)
                   case 16:
                           for (y=0; y<inf.height; y++) {
                                   for (x=0; x<inf.width; x++) {
                                           if (!(x & 1)) {
                                                   c = src[x >> 1] >> 4;
                                           }
                                           else {
                                                   c = src[x >> 1] & 15;
                                           }
                                           *(UINT16 *)dst = pal[c].pal16;
                                           dst += vram->xalign;
                                   }
                                   src += bmpalign;
                                   dst += yalign;
                           }
                           break;
   #endif
   #if defined(SUPPORT_32BPP)
                   case 32:
                           for (y=0; y<inf.height; y++) {
                                   for (x=0; x<inf.width; x++) {
                                           if (!(x & 1)) {
                                                   c = src[x >> 1] >> 4;
                                           }
                                           else {
                                                   c = src[x >> 1] & 15;
                                           }
                                           *(UINT32 *)dst = pal[c].pal32.d;
                                           dst += vram->xalign;
                                   }
                                   src += bmpalign;
                                   dst += yalign;
                           }
                           break;
   #endif
           }
   }
   

Removed from v.1.2  
changed lines
  Added in v.1.5


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