[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.306,2.307 gfx.h,1.69,1.70
Max Horn
fingolfin at users.sourceforge.net
Sat Sep 18 14:41:04 CEST 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm string.cpp,1.251,1.252 scumm.h,1.483,1.484 script_v5.cpp,1.261,1.262 script_v6.cpp,1.402,1.403 script_v6he.cpp,2.118,2.119 script_v72he.cpp,2.104,2.105 script_v8.cpp,2.271,2.272
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v90he.cpp,2.41,2.42
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23690
Modified Files:
gfx.cpp gfx.h
Log Message:
GFX codec cleanup: renamed some of the Gdi::unkDecode methods; simplified and/or cleaned up some of the codecs; added some relevant TODO/FIXME comments
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.306
retrieving revision 2.307
diff -u -d -r2.306 -r2.307
--- gfx.cpp 18 Sep 2004 06:29:07 -0000 2.306
+++ gfx.cpp 18 Sep 2004 21:40:07 -0000 2.307
@@ -571,7 +571,7 @@
byte *room = getResourceAddress(rtRoomImage, _roomResource) + _IM00_offs;
if (findResource(MKID('BMAP'), room) != NULL) {
if (_fullRedraw) {
- _BgNeedsRedraw = 0;
+ _BgNeedsRedraw = false;
gdi.drawBMAPBg(room, &virtscr[0], _screenStartStrip, _screenWidth);
}
cont = false;
@@ -746,6 +746,7 @@
#pragma mark -
static void blit(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h) {
+ assert(w > 0);
assert(h > 0);
assert(src != NULL);
assert(dst != NULL);
@@ -1183,7 +1184,7 @@
drawStripC64Background(bgbak_ptr, stripnr, height);
} else if (_vm->_version > 2) {
if (_vm->_features & GF_16COLOR) {
- decodeStripEGA(bgbak_ptr, smap_ptr + READ_LE_UINT16(smap_ptr + stripnr * 2 + 2), height);
+ drawStripEGA(bgbak_ptr, smap_ptr + READ_LE_UINT16(smap_ptr + stripnr * 2 + 2), height);
} else if (_vm->_features & GF_SMALL_HEADER) {
useOrDecompress = decompressBitmap(bgbak_ptr, smap_ptr + READ_LE_UINT32(smap_ptr + stripnr * 4 + 4), height);
} else {
@@ -1301,7 +1302,7 @@
/**
* Draw a bitmap onto a virtual screen. This is main drawing method for room backgrounds
- * and objects, used throughout in 7.2+ HE versions
+ * used throughout in 7.2+ HE versions
*/
void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip, int width) {
assert(ptr);
@@ -1395,55 +1396,6 @@
}
}
-void Gdi::decompressBMAPbg(byte *dst, int screenwidth, int w, int height, const byte *src, int shr, int mask) {
- uint32 color, dataBit, data, shift;
- int32 iteration;
-
- color = *src;
- src++;
- data = READ_LE_UINT24(src);
- src += 3;
- shift = 24;
-
- while (height) {
- for (iteration = 0; iteration < w; iteration++) {
- *dst++ = color;
- if (shift <= 16) {
- data |= *src << shift;
- src++;
- shift += 8;
- data |= *src << shift;
- src++;
- shift += 8;
- }
-
- dataBit = data & 1;
- shift--;
- data >>= 1;
- if (dataBit) {
- dataBit = data & 1;
- shift--;
- data >>= 1;
- if (!dataBit) {
- color = mask & data;
- shift -= shr;
- data >>= shr;
- } else {
- dataBit = data & 7;
- shift -= 3;
- data >>= 3;
- if (dataBit >= 4)
- color += dataBit - 3;
- else
- color += dataBit - 4;
- }
- }
- }
- dst += screenwidth - w;
- height--;
- }
-}
-
void Gdi::copyWizImage(uint8 *dst, const uint8 *src, int dst_w, int dst_h, int src_x, int src_y, int src_w, int src_h, Common::Rect *rect) {
Common::Rect r1(0, 0, src_w, src_h), r2(src_x, src_y, src_x + src_w, src_y + src_h);
Common::Rect r3;
@@ -1730,7 +1682,9 @@
src = (byte *)_vm->virtscr[0].backBuf + (_vm->_screenStartStrip + rect.top * _numStrips) * 8 + rect.left;
dst = (byte *)_vm->virtscr[0].pixels + (_vm->_screenStartStrip + rect.top * _numStrips) * 8 + rect.left;
- copyBufferBox(dst, src, rw, rh);
+ assert(rw <= _vm->_screenWidth && rw > 0);
+ assert(rh <= _vm->_screenHeight && rh > 0);
+ blit(dst, _vm->_screenWidth, src, _vm->_screenWidth, rw, rh);
_vm->markRectAsDirty(kMainVirtScreen, rect.left, rect.right, rect.top, rect.bottom, 0);
}
@@ -1933,7 +1887,7 @@
}
}
-void Gdi::decodeStripEGA(byte *dst, const byte *src, int height) {
+void Gdi::drawStripEGA(byte *dst, const byte *src, int height) {
byte color = 0;
int run = 0, x = 0, y = 0, z;
@@ -2023,16 +1977,16 @@
// 8/9 used in 3do version of puttputt joins the parade maybe others
case 8:
useOrDecompress = true;
- decodeStrip3DO(bgbak_ptr, src, numLinesToProcess, true);
+ drawStrip3DO(bgbak_ptr, src, numLinesToProcess, true);
break;
case 9:
- decodeStrip3DO(bgbak_ptr, src, numLinesToProcess, false);
+ drawStrip3DO(bgbak_ptr, src, numLinesToProcess, false);
break;
// used in amiga version of Monkey Island
case 10:
- decodeStripEGA(bgbak_ptr, src, numLinesToProcess);
+ drawStripEGA(bgbak_ptr, src, numLinesToProcess);
break;
default:
@@ -2048,21 +2002,21 @@
// FIXME: Ugly workaround for bug #901462
if (_vm->_version == 8)
useOrDecompress = true;
- unkDecodeC(bgbak_ptr, src, numLinesToProcess);
+ drawStripBasicV(bgbak_ptr, src, numLinesToProcess);
break;
case 2:
- unkDecodeB(bgbak_ptr, src, numLinesToProcess);
+ drawStripBasicH(bgbak_ptr, src, numLinesToProcess);
break;
case 3:
useOrDecompress = true;
- unkDecodeC_trans(bgbak_ptr, src, numLinesToProcess);
+ drawStripBasicV_trans(bgbak_ptr, src, numLinesToProcess);
break;
case 4:
useOrDecompress = true;
- unkDecodeB_trans(bgbak_ptr, src, numLinesToProcess);
+ drawStripBasicH_trans(bgbak_ptr, src, numLinesToProcess);
break;
case 6:
@@ -2070,22 +2024,22 @@
// FIXME: Ugly workaround for bug #901462
if (_vm->_version == 8 && code == 10)
useOrDecompress = true;
- unkDecodeA(bgbak_ptr, src, numLinesToProcess);
+ drawStripComplex(bgbak_ptr, src, numLinesToProcess);
break;
case 8:
case 12:
useOrDecompress = true;
- unkDecodeA_trans(bgbak_ptr, src, numLinesToProcess);
+ drawStripComplex_trans(bgbak_ptr, src, numLinesToProcess);
break;
case 13:
- decodeStripHE(bgbak_ptr, src, numLinesToProcess, false);
+ drawStripHE(bgbak_ptr, src, numLinesToProcess, false);
break;
case 14:
useOrDecompress = true;
- decodeStripHE(bgbak_ptr, src, numLinesToProcess, true);
+ drawStripHE(bgbak_ptr, src, numLinesToProcess, true);
break;
default:
@@ -2096,22 +2050,6 @@
return useOrDecompress;
}
-void Gdi::copyBufferBox(byte *dst, const byte *src, int width, int height) {
- assert(width <= _vm->_screenWidth && width > 0);
- assert(height <= _vm->_screenHeight && height > 0);
-
- do {
-#if defined(SCUMM_NEED_ALIGNMENT)
- memcpy(dst, src, width);
-#else
- for(int i = 0; i < width; i++)
- dst[i] = src[i];
-#endif
- dst += _vm->_screenWidth;
- src += _vm->_screenWidth;
- } while (--height);
-}
-
void Gdi::draw8Col(byte *dst, const byte *src, int height) {
do {
#if defined(SCUMM_NEED_ALIGNMENT)
@@ -2188,6 +2126,158 @@
}
}
+#define READ_BIT (shift--, dataBit = data & 1, data >>= 1, dataBit)
+#define FILL_BITS do { \
+ if (shift <= 16) { \
+ data |= READ_LE_UINT16(src) << shift; \
+ src += 2; \
+ shift += 16; \
+ } \
+ } while (0)
+
+
+// NOTE: decompressBMAPbg is actually very similar to drawStripComplex
+void Gdi::decompressBMAPbg(byte *dst, int screenwidth, int w, int height, const byte *src, int shr, int mask) {
+ uint32 dataBit, data, shift;
+ byte color;
+ int32 iteration;
+
+ color = *src;
+ src++;
+ data = READ_LE_UINT24(src);
+ src += 3;
+ shift = 24;
+
+ while (height) {
+ for (iteration = 0; iteration < w; iteration++) {
+ FILL_BITS;
+ *dst++ = color;
+
+ if (READ_BIT) {
+ if (!READ_BIT) {
+ color = data & mask;
+ shift -= shr;
+ data >>= shr;
+ } else {
+ dataBit = data & 7;
+ shift -= 3;
+ data >>= 3;
+ // map (0, 1, 2, 3, 4, 5, 6, 7) to (-4, -3, -2, -1, 1, 2, 3, 4)
+ if (dataBit >= 4)
+ color += dataBit - 3;
+ else
+ color += dataBit - 4;
+ }
+ }
+ }
+ dst += screenwidth - w;
+ height--;
+ }
+}
+
+// FIXME/TODO: drawStripHE and decompressBMAPbg are essentially identical!
+void Gdi::drawStripHE(byte *dst, const byte *src, int height, const bool transpCheck) {
+ uint32 dataBit, data, shift, iteration;
+ byte color;
+
+ color = *src;
+ src++;
+ data = READ_LE_UINT24(src);
+ src += 3;
+ shift = 24;
+
+ while (height) {
+ for (iteration = 0; iteration < 8; iteration++) {
+ if (!transpCheck || color != _transparentColor)
+ *dst = _roomPalette[color];
+ dst++;
+ FILL_BITS;
+
+ if (READ_BIT) {
+ if (!READ_BIT) {
+ color = _decomp_mask & data;
+ shift -= _decomp_shr;
+ data >>= _decomp_shr;
+ } else {
+ dataBit = data & 7;
+ shift -= 3;
+ data >>= 3;
+ if (dataBit >= 4)
+ color += dataBit - 3;
+ else
+ color += dataBit - 4;
+ }
+ }
+ }
+ dst += _vm->_screenWidth - 8;
+ height--;
+ }
+}
+
+#undef READ_BIT
+#undef FILL_BITS
+
+
+void Gdi::drawStrip3DO(byte *dst, const byte *src, int height, const bool transpCheck) {
+ int destbytes, olddestbytes2, olddestbytes1;
+ byte color;
+
+ uint32 dataBit, data;
+
+ olddestbytes1 = 0;
+
+ destbytes = height << 3;
+
+ if (!height)
+ return;
+
+ // FIXME/TODO: This is a simple RLE encoding; the code could be made
+ // clearer by renaming some vars and/or rearranginge the code.
+
+ do {
+ data = *src++;
+
+ dataBit = data & 1;
+ data >>= 1;
+ data++;
+
+ destbytes -= data;
+
+ // Clip!
+ if (destbytes < 0)
+ data += destbytes;
+
+ olddestbytes2 = destbytes;
+ destbytes = olddestbytes1;
+
+ if (!dataBit) {
+ for (; data > 0; data--, src++, dst++) {
+ if (!transpCheck || *src != _transparentColor)
+ *dst = _roomPalette[*src];
+
+ destbytes++;
+ if (!(destbytes & 7))
+ dst += _vm->_screenWidth - 8; // Next row
+ }
+ } else {
+ color = *src;
+ src++;
+
+ for (; data > 0; data--, dst++) {
+ if (!transpCheck || color != _transparentColor)
+ *dst = _roomPalette[color];
+ destbytes++;
+ if (!(destbytes & 7))
+ dst += _vm->_screenWidth - 8; // Next row
+ }
+ }
+
+ olddestbytes1 = destbytes;
+ destbytes = olddestbytes2;
+ } while (olddestbytes2 > 0);
+}
+
+
#define READ_BIT (cl--, bit = bits & 1, bits >>= 1, bit)
#define FILL_BITS do { \
if (cl <= 8) { \
@@ -2196,7 +2286,7 @@
} \
} while (0)
-void Gdi::unkDecodeA(byte *dst, const byte *src, int height) {
+void Gdi::drawStripComplex(byte *dst, const byte *src, int height) {
byte color = *src++;
uint bits = *src++;
byte cl = 8;
@@ -2244,7 +2334,7 @@
} while (--height);
}
-void Gdi::unkDecodeA_trans(byte *dst, const byte *src, int height) {
+void Gdi::drawStripComplex_trans(byte *dst, const byte *src, int height) {
byte color = *src++;
uint bits = *src++;
byte cl = 8;
@@ -2296,7 +2386,7 @@
} while (--height);
}
-void Gdi::unkDecodeB(byte *dst, const byte *src, int height) {
+void Gdi::drawStripBasicH(byte *dst, const byte *src, int height) {
byte color = *src++;
uint bits = *src++;
byte cl = 8;
@@ -2326,7 +2416,7 @@
} while (--height);
}
-void Gdi::unkDecodeB_trans(byte *dst, const byte *src, int height) {
+void Gdi::drawStripBasicH_trans(byte *dst, const byte *src, int height) {
byte color = *src++;
uint bits = *src++;
byte cl = 8;
@@ -2358,7 +2448,7 @@
} while (--height);
}
-void Gdi::unkDecodeC(byte *dst, const byte *src, int height) {
+void Gdi::drawStripBasicV(byte *dst, const byte *src, int height) {
byte color = *src++;
uint bits = *src++;
byte cl = 8;
@@ -2390,7 +2480,7 @@
} while (--x);
}
-void Gdi::unkDecodeC_trans(byte *dst, const byte *src, int height) {
+void Gdi::drawStripBasicV_trans(byte *dst, const byte *src, int height) {
byte color = *src++;
uint bits = *src++;
byte cl = 8;
@@ -2427,7 +2517,7 @@
#undef FILL_BITS
/* Ender - Zak256/Indy256 decoders */
-#define READ_256BIT \
+#define READ_BIT_256 \
do { \
if ((mask <<= 1) == 256) { \
buffer = *src++; \
@@ -2436,6 +2526,15 @@
bits = ((buffer & mask) != 0); \
} while (0)
+#define READ_N_BITS(n, c) \
+ do { \
+ c = 0; \
+ for (int b = 0; b < n; b++) { \
+ READ_BIT_256; \
+ c += (bits << b); \
+ } \
+ } while (0)
+
#define NEXT_ROW \
do { \
dst += _vm->_screenWidth; \
@@ -2448,9 +2547,9 @@
} while (0)
void Gdi::unkDecode7(byte *dst, const byte *src, int height) {
- uint h = height;
if (_vm->_features & GF_OLD256) {
+ uint h = height;
int x = 8;
for (;;) {
*dst = *src++;
@@ -2487,27 +2586,19 @@
}
void Gdi::unkDecode9(byte *dst, const byte *src, int height) {
- unsigned char c, bits, color, run;
- int i, j;
+ byte c, bits, color, run;
+ int i;
uint buffer = 0, mask = 128;
int h = height;
- i = j = run = 0;
+ i = run = 0;
int x = 8;
for (;;) {
- c = 0;
- for (i = 0; i < 4; i++) {
- READ_256BIT;
- c += (bits << i);
- }
+ READ_N_BITS(4, c);
switch (c >> 2) {
case 0:
- color = 0;
- for (i = 0; i < 4; i++) {
- READ_256BIT;
- color += bits << i;
- }
+ READ_N_BITS(4, color);
for (i = 0; i < ((c & 3) + 2); i++) {
*dst = _roomPalette[run * 16 + color];
NEXT_ROW;
@@ -2516,22 +2607,14 @@
case 1:
for (i = 0; i < ((c & 3) + 1); i++) {
- color = 0;
- for (j = 0; j < 4; j++) {
- READ_256BIT;
- color += bits << j;
- }
+ READ_N_BITS(4, color);
*dst = _roomPalette[run * 16 + color];
NEXT_ROW;
}
break;
case 2:
- run = 0;
- for (i = 0; i < 4; i++) {
- READ_256BIT;
- run += bits << i;
- }
+ READ_N_BITS(4, run);
break;
}
}
@@ -2539,7 +2622,7 @@
void Gdi::unkDecode10(byte *dst, const byte *src, int height) {
int i;
- unsigned char local_palette[256], numcolors = *src++;
+ byte local_palette[256], numcolors = *src++;
uint h = height;
for (i = 0; i < numcolors; i++)
@@ -2567,7 +2650,7 @@
void Gdi::unkDecode11(byte *dst, const byte *src, int height) {
int bits, i;
uint buffer = 0, mask = 128;
- unsigned char inc = 1, color = *src++;
+ byte inc = 1, color = *src++;
int x = 8;
do {
@@ -2576,7 +2659,7 @@
*dst = _roomPalette[color];
dst += _vm->_screenWidth;
for (i = 0; i < 3; i++) {
- READ_256BIT;
+ READ_BIT_256;
if (!bits)
break;
}
@@ -2591,12 +2674,8 @@
break;
case 3:
- color = 0;
inc = 1;
- for (i = 0; i < 8; i++) {
- READ_256BIT;
- color += bits << i;
- }
+ READ_N_BITS(8, color);
break;
}
} while (--h);
@@ -2605,126 +2684,8 @@
}
-void Gdi::decodeStrip3DO(byte *dst, const byte *src, int height, byte transpCheck) {
- int destbytes, olddestbytes2, olddestbytes1;
- byte color;
- int data;
-
- olddestbytes1 = 0;
-
- destbytes = height << 3;
-
- if (!height)
- return;
-
- do {
- data = *src;
- src++;
-
- if (!(data & 1)) {
- data >>= 1;
- data++;
- destbytes -= data;
- if (destbytes < 0)
- data += destbytes;
-
- olddestbytes2 = destbytes;
- destbytes = olddestbytes1;
-
- for (; data > 0; data--, src++, dst++) {
- if (*src != _transparentColor || !transpCheck)
- *dst = _roomPalette[*src];
-
- destbytes++;
- if (!(destbytes & 7))
- dst += 312;
- }
-
- olddestbytes1 = destbytes;
- if (olddestbytes2 > 0) {
- destbytes = olddestbytes2;
- }
- } else {
- data >>= 1;
- color = *src;
- src++;
-
- data++;
- destbytes -= data;
- if (destbytes < 0)
- data += destbytes;
-
- olddestbytes2 = destbytes;
- destbytes = olddestbytes1;
-
- for (; data > 0; data--, dst++) {
- if (color != _transparentColor || !transpCheck)
- *dst = _roomPalette[color];
- destbytes++;
- if (!(destbytes & 7))
- dst += 312;
- }
- olddestbytes1 = destbytes;
- if (olddestbytes2 > 0) {
- destbytes = olddestbytes2;
- }
- }
- } while (olddestbytes2 > 0);
-}
-
-
-void Gdi::decodeStripHE(byte *dst, const byte *src, int height, byte transpCheck) {
- uint32 color, dataBit, data, shift, iteration;
-
- color = *src;
- src++;
- data = READ_LE_UINT24(src);
- src += 3;
- shift = 24;
-
- while (height) {
- for (iteration = 0; iteration < 8; iteration++) {
- if (color != _transparentColor || !transpCheck)
- *dst = _roomPalette[color];
- dst++;
- if (shift <= 16) {
- data |= *src << shift;
- src++;
- shift += 8;
- data |= *src << shift;
- src++;
- shift += 8;
- }
-
- dataBit = data & 1;
- shift--;
- data >>= 1;
- if (dataBit) {
- dataBit = data & 1;
- shift--;
- data >>= 1;
- if (!dataBit) {
- color = _decomp_mask & data;
- shift -= _decomp_shr;
- data >>= _decomp_shr;
- } else {
- dataBit = data & 7;
- shift -= 3;
- data >>= 3;
- if (dataBit >= 4)
- color += dataBit - 3;
- else
- color += dataBit - 4;
- }
- }
- }
- dst += _vm->_screenWidth - 8;;
- height--;
- }
-}
-
#undef NEXT_ROW
-#undef READ_256BIT
+#undef READ_BIT_256
#pragma mark -
#pragma mark --- Transition effects ---
Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- gfx.h 18 Sep 2004 00:36:16 -0000 1.69
+++ gfx.h 18 Sep 2004 21:40:07 -0000 1.70
@@ -232,27 +232,27 @@
/* Bitmap decompressors */
bool decompressBitmap(byte *bgbak_ptr, const byte *src, int numLinesToProcess);
- void decodeStripEGA(byte *dst, const byte *src, int height);
+ void drawStripEGA(byte *dst, const byte *src, int height);
void decodeC64Gfx(const byte *src, byte *dst, int size);
void drawStripC64Object(byte *dst, int stripnr, int width, int height);
void drawStripC64Background(byte *dst, int stripnr, int height);
void drawStripC64Mask(byte *dst, int stripnr, int width, int height);
- void unkDecodeA(byte *dst, const byte *src, int height);
- void unkDecodeA_trans(byte *dst, const byte *src, int height);
- void unkDecodeB(byte *dst, const byte *src, int height);
- void unkDecodeB_trans(byte *dst, const byte *src, int height);
- void unkDecodeC(byte *dst, const byte *src, int height);
- void unkDecodeC_trans(byte *dst, const byte *src, int height);
+
+ void drawStripComplex(byte *dst, const byte *src, int height);
+ void drawStripComplex_trans(byte *dst, const byte *src, int height);
+ void drawStripBasicH(byte *dst, const byte *src, int height);
+ void drawStripBasicH_trans(byte *dst, const byte *src, int height);
+ void drawStripBasicV(byte *dst, const byte *src, int height);
+ void drawStripBasicV_trans(byte *dst, const byte *src, int height);
void unkDecode7(byte *dst, const byte *src, int height);
void unkDecode8(byte *dst, const byte *src, int height);
void unkDecode9(byte *dst, const byte *src, int height);
void unkDecode10(byte *dst, const byte *src, int height);
void unkDecode11(byte *dst, const byte *src, int height);
- void decodeStrip3DO(byte *dst, const byte *src, int height, byte transpCheck);
- void decodeStripHE(byte *dst, const byte *src, int height, byte transpCheck);
+ void drawStrip3DO(byte *dst, const byte *src, int height, const bool transpCheck);
+ void drawStripHE(byte *dst, const byte *src, int height, const bool transpCheck);
- void copyBufferBox(byte *dst, const byte *src, int width, int height);
void draw8Col(byte *dst, const byte *src, int height);
void clear8Col(byte *dst, int height);
void decompressMaskImgOr(byte *dst, const byte *src, int height);
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm string.cpp,1.251,1.252 scumm.h,1.483,1.484 script_v5.cpp,1.261,1.262 script_v6.cpp,1.402,1.403 script_v6he.cpp,2.118,2.119 script_v72he.cpp,2.104,2.105 script_v8.cpp,2.271,2.272
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v90he.cpp,2.41,2.42
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list