Diff for /np2/embed/vramhdl.c between versions 1.1 and 1.2

version 1.1, 2003/11/21 06:51:10 version 1.2, 2005/02/11 21:17:21
Line 47  VRAMHDL vram_create(int width, int heigh Line 47  VRAMHDL vram_create(int width, int heigh
                 ret->bpp = bpp;                  ret->bpp = bpp;
                 ret->scrnsize = size;                  ret->scrnsize = size;
                 if (alpha) {                  if (alpha) {
                         ret->alpha = (BYTE *)(ret + 1);                          ret->alpha = (UINT8 *)(ret + 1);
                         ret->ptr = ret->alpha + alphasize;                          ret->ptr = ret->alpha + alphasize;
                 }                  }
                 else {                  else {
                         ret->ptr = (BYTE *)(ret + 1);                          ret->ptr = (UINT8 *)(ret + 1);
                 }                  }
         }          }
         return(ret);          return(ret);
Line 60  VRAMHDL vram_create(int width, int heigh Line 60  VRAMHDL vram_create(int width, int heigh
 void vram_destroy(VRAMHDL hdl) {  void vram_destroy(VRAMHDL hdl) {
   
         if (hdl) {          if (hdl) {
                 if ((hdl->alpha) && (hdl->alpha != (BYTE *)(hdl + 1))) {                  if ((hdl->alpha) && (hdl->alpha != (UINT8 *)(hdl + 1))) {
                         _MFREE(hdl->alpha);                          _MFREE(hdl->alpha);
                 }                  }
                 _MFREE(hdl);                  _MFREE(hdl);
         }          }
 }  }
   
 BOOL vram_allocalpha(VRAMHDL hdl) {  BRESULT vram_allocalpha(VRAMHDL hdl) {
   
         if (hdl == NULL) {          if (hdl == NULL) {
                 return(FAILURE);                  return(FAILURE);
         }          }
         if (hdl->alpha == NULL) {          if (hdl->alpha == NULL) {
                 hdl->alpha = (BYTE *)_MALLOC(hdl->scrnsize, "alpha plane");                  hdl->alpha = (UINT8 *)_MALLOC(hdl->scrnsize, "alpha plane");
                 if (hdl->alpha == NULL) {                  if (hdl->alpha == NULL) {
                         return(FAILURE);                          return(FAILURE);
                 }                  }
Line 89  void vram_zerofill(VRAMHDL hdl, const RE Line 89  void vram_zerofill(VRAMHDL hdl, const RE
         int             height;          int             height;
         int             pos;          int             pos;
         int             remain;          int             remain;
         BYTE    *p;          UINT8   *p;
   
         if (hdl) {          if (hdl) {
                 if (rect == NULL) {                  if (rect == NULL) {
Line 127  void vram_zerofill(VRAMHDL hdl, const RE Line 127  void vram_zerofill(VRAMHDL hdl, const RE
         }          }
 }  }
   
 void vram_fill(VRAMHDL hdl, const RECT_T *rect, UINT32 color, BYTE alpha) {  void vram_fill(VRAMHDL hdl, const RECT_T *rect, UINT32 color, UINT8 alpha) {
   
         int             ptr;          int             ptr;
         int             width;          int             width;
         int             height;          int             height;
         int             pos;          int             pos;
         int             remain;          int             remain;
         BYTE    *p;          UINT8   *p;
 #ifdef SUPPORT_16BPP  #ifdef SUPPORT_16BPP
         UINT    c16;          UINT    c16;
 #endif  #endif
 #ifdef SUPPORT_24BPP  #ifdef SUPPORT_24BPP
         BYTE    c24[3];          UINT8   c24[3];
 #endif  #endif
   
         if (hdl == NULL) {          if (hdl == NULL) {
Line 151  void vram_fill(VRAMHDL hdl, const RECT_T Line 151  void vram_fill(VRAMHDL hdl, const RECT_T
                 switch(hdl->bpp) {                  switch(hdl->bpp) {
                         case 8:                          case 8:
                                 do {                                  do {
                                         *p++ = (BYTE)color;                                          *p++ = (UINT8)color;
                                 } while(--remain);                                  } while(--remain);
                                 break;                                  break;
 #ifdef SUPPORT_16BPP  #ifdef SUPPORT_16BPP
Line 165  void vram_fill(VRAMHDL hdl, const RECT_T Line 165  void vram_fill(VRAMHDL hdl, const RECT_T
 #endif  #endif
 #ifdef SUPPORT_24BPP  #ifdef SUPPORT_24BPP
                         case 24:                          case 24:
                                 c24[0] = (BYTE)color;                                  c24[0] = (UINT8)color;
                                 c24[1] = (BYTE)(color >> 8);                                  c24[1] = (UINT8)(color >> 8);
                                 c24[2] = (BYTE)(color >> 16);                                  c24[2] = (UINT8)(color >> 16);
                                 do {                                  do {
                                         p[0] = c24[0];                                          p[0] = c24[0];
                                         p[1] = c24[1];                                          p[1] = c24[1];
Line 200  void vram_fill(VRAMHDL hdl, const RECT_T Line 200  void vram_fill(VRAMHDL hdl, const RECT_T
                                         do {                                          do {
                                                 int r = width;                                                  int r = width;
                                                 do {                                                  do {
                                                         *p++ = (BYTE)color;                                                          *p++ = (UINT8)color;
                                                 } while(--r);                                                  } while(--r);
                                                 p += hdl->yalign - width;                                                  p += hdl->yalign - width;
                                         } while(--remain);                                          } while(--remain);
Line 221  void vram_fill(VRAMHDL hdl, const RECT_T Line 221  void vram_fill(VRAMHDL hdl, const RECT_T
 #endif  #endif
 #ifdef SUPPORT_24BPP  #ifdef SUPPORT_24BPP
                                 case 24:                                  case 24:
                                         c24[0] = (BYTE)color;                                          c24[0] = (UINT8)color;
                                         c24[1] = (BYTE)(color >> 8);                                          c24[1] = (UINT8)(color >> 8);
                                         c24[2] = (BYTE)(color >> 16);                                          c24[2] = (UINT8)(color >> 16);
                                         remain = height;                                          remain = height;
                                         do {                                          do {
                                                 int r = width;                                                  int r = width;
Line 260  void vram_filldat(VRAMHDL hdl, const REC Line 260  void vram_filldat(VRAMHDL hdl, const REC
         int             height;          int             height;
         int             pos;          int             pos;
         int             remain;          int             remain;
         BYTE    *p;          UINT8   *p;
 #ifdef SUPPORT_16BPP  #ifdef SUPPORT_16BPP
         UINT    c16;          UINT    c16;
 #endif  #endif
 #ifdef SUPPORT_24BPP  #ifdef SUPPORT_24BPP
         BYTE    c24[3];          UINT8   c24[3];
 #endif  #endif
   
         if (hdl == NULL) {          if (hdl == NULL) {
Line 277  void vram_filldat(VRAMHDL hdl, const REC Line 277  void vram_filldat(VRAMHDL hdl, const REC
                 switch(hdl->bpp) {                  switch(hdl->bpp) {
                         case 8:                          case 8:
                                 do {                                  do {
                                         *p++ = (BYTE)color;                                          *p++ = (UINT8)color;
                                 } while(--remain);                                  } while(--remain);
                                 break;                                  break;
 #ifdef SUPPORT_16BPP  #ifdef SUPPORT_16BPP
Line 291  void vram_filldat(VRAMHDL hdl, const REC Line 291  void vram_filldat(VRAMHDL hdl, const REC
 #endif  #endif
 #ifdef SUPPORT_24BPP  #ifdef SUPPORT_24BPP
                         case 24:                          case 24:
                                 c24[0] = (BYTE)color;                                  c24[0] = (UINT8)color;
                                 c24[1] = (BYTE)(color >> 8);                                  c24[1] = (UINT8)(color >> 8);
                                 c24[2] = (BYTE)(color >> 16);                                  c24[2] = (UINT8)(color >> 16);
                                 do {                                  do {
                                         p[0] = c24[0];                                          p[0] = c24[0];
                                         p[1] = c24[1];                                          p[1] = c24[1];
Line 323  void vram_filldat(VRAMHDL hdl, const REC Line 323  void vram_filldat(VRAMHDL hdl, const REC
                                         do {                                          do {
                                                 int r = width;                                                  int r = width;
                                                 do {                                                  do {
                                                         *p++ = (BYTE)color;                                                          *p++ = (UINT8)color;
                                                 } while(--r);                                                  } while(--r);
                                                 p += hdl->yalign - width;                                                  p += hdl->yalign - width;
                                         } while(--remain);                                          } while(--remain);
Line 344  void vram_filldat(VRAMHDL hdl, const REC Line 344  void vram_filldat(VRAMHDL hdl, const REC
 #endif  #endif
 #ifdef SUPPORT_24BPP  #ifdef SUPPORT_24BPP
                                 case 24:                                  case 24:
                                         c24[0] = (BYTE)color;                                          c24[0] = (UINT8)color;
                                         c24[1] = (BYTE)(color >> 8);                                          c24[1] = (UINT8)(color >> 8);
                                         c24[2] = (BYTE)(color >> 16);                                          c24[2] = (UINT8)(color >> 16);
                                         remain = height;                                          remain = height;
                                         do {                                          do {
                                                 int r = width;                                                  int r = width;
Line 368  void vram_filldat(VRAMHDL hdl, const REC Line 368  void vram_filldat(VRAMHDL hdl, const REC
         }          }
 }  }
   
 void vram_fillalpha(VRAMHDL hdl, const RECT_T *rect, BYTE alpha) {  void vram_fillalpha(VRAMHDL hdl, const RECT_T *rect, UINT8 alpha) {
   
         int             ptr;          int             ptr;
         int             width;          int             width;
         int             height;          int             height;
         int             pos;          int             pos;
         int             remain;          int             remain;
         BYTE    *p;          UINT8   *p;
   
         if ((hdl == NULL) || (hdl->alpha == NULL)) {          if ((hdl == NULL) || (hdl->alpha == NULL)) {
                 return;                  return;
Line 403  void vram_fillalpha(VRAMHDL hdl, const R Line 403  void vram_fillalpha(VRAMHDL hdl, const R
         }          }
 }  }
   
 void vram_fillex(VRAMHDL hdl, const RECT_T *rect, UINT32 color, BYTE alpha) {  void vram_fillex(VRAMHDL hdl, const RECT_T *rect, UINT32 color, UINT8 alpha) {
   
         int             ptr;          int             ptr;
         int             width;          int             width;
         int             height;          int             height;
         int             pos;          int             pos;
         int             remain;          int             remain;
         BYTE    *p;          UINT8   *p;
 #ifdef SUPPORT_16BPP  #ifdef SUPPORT_16BPP
         int             tmp;          int             tmp;
         int             c16[3];          int             c16[3];
Line 450  void vram_fillex(VRAMHDL hdl, const RECT Line 450  void vram_fillex(VRAMHDL hdl, const RECT
                                 c24[1] = (color >> 8) & 0xff;                                  c24[1] = (color >> 8) & 0xff;
                                 c24[2] = (color >> 16) & 0xff;                                  c24[2] = (color >> 16) & 0xff;
                                 do {                                  do {
                                         p[0] = (BYTE)MAKEALPHA24(p[0], c24[0], alpha, 6);                                          p[0] = (UINT8)MAKEALPHA24(p[0], c24[0], alpha, 6);
                                         p[1] = (BYTE)MAKEALPHA24(p[1], c24[1], alpha, 6);                                          p[1] = (UINT8)MAKEALPHA24(p[1], c24[1], alpha, 6);
                                         p[2] = (BYTE)MAKEALPHA24(p[2], c24[2], alpha, 6);                                          p[2] = (UINT8)MAKEALPHA24(p[2], c24[2], alpha, 6);
                                         p += 3;                                          p += 3;
                                 } while(--remain);                                  } while(--remain);
                                 break;                                  break;
Line 505  void vram_fillex(VRAMHDL hdl, const RECT Line 505  void vram_fillex(VRAMHDL hdl, const RECT
                                         do {                                          do {
                                                 int r = width;                                                  int r = width;
                                                 do {                                                  do {
                                                         p[0] = (BYTE)MAKEALPHA24(p[0], c24[0], alpha, 6);                                                          p[0] = (UINT8)MAKEALPHA24(p[0], c24[0], alpha, 6);
                                                         p[1] = (BYTE)MAKEALPHA24(p[1], c24[1], alpha, 6);                                                          p[1] = (UINT8)MAKEALPHA24(p[1], c24[1], alpha, 6);
                                                         p[2] = (BYTE)MAKEALPHA24(p[2], c24[2], alpha, 6);                                                          p[2] = (UINT8)MAKEALPHA24(p[2], c24[2], alpha, 6);
                                                         p += 3;                                                          p += 3;
                                                 } while(--r);                                                  } while(--r);
                                                 p += hdl->yalign - (width * 3);                                                  p += hdl->yalign - (width * 3);
Line 589  VRAMHDL vram_dupe(const VRAMHDL hdl) { Line 589  VRAMHDL vram_dupe(const VRAMHDL hdl) {
         }          }
         *ret = *hdl;          *ret = *hdl;
         if (hdl->alpha) {          if (hdl->alpha) {
                 ret->alpha = (BYTE *)(ret + 1);                  ret->alpha = (UINT8 *)(ret + 1);
                 CopyMemory(ret->alpha, hdl->alpha, hdl->scrnsize);                  CopyMemory(ret->alpha, hdl->alpha, hdl->scrnsize);
                 ret->ptr = ret->alpha + hdl->scrnsize;                  ret->ptr = ret->alpha + hdl->scrnsize;
         }          }
         else {          else {
                 ret->ptr = (BYTE *)(ret + 1);                  ret->ptr = (UINT8 *)(ret + 1);
         }          }
         CopyMemory(ret->ptr, hdl->ptr, datsize);          CopyMemory(ret->ptr, hdl->ptr, datsize);
   
Line 602  vd_exit: Line 602  vd_exit:
         return(ret);          return(ret);
 }  }
   
 BOOL vram_cliprect(RECT_T *clip, const VRAMHDL vram, const RECT_T *rct) {  BRESULT vram_cliprect(RECT_T *clip, const VRAMHDL vram, const RECT_T *rct) {
   
         if (vram == NULL) {          if (vram == NULL) {
                 return(FAILURE);                  return(FAILURE);
Line 628  BOOL vram_cliprect(RECT_T *clip, const V Line 628  BOOL vram_cliprect(RECT_T *clip, const V
         return(SUCCESS);          return(SUCCESS);
 }  }
   
 BOOL vram_cliprectex(RECT_T *clip, const VRAMHDL vram, const RECT_T *rct) {  BRESULT vram_cliprectex(RECT_T *clip, const VRAMHDL vram, const RECT_T *rct) {
   
         if ((vram == NULL) || (clip == NULL)) {          if ((vram == NULL) || (clip == NULL)) {
                 return(FAILURE);                  return(FAILURE);

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


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