[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.60,2.61 gfx.h,1.23,1.24 scumm.h,1.171,1.172 scummvm.cpp,2.112,2.113
Pawel Kolodziejski
aquadran at users.sourceforge.net
Tue Apr 29 22:49:05 CEST 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv8864
Modified Files:
gfx.cpp gfx.h scumm.h scummvm.cpp
Log Message:
added gfx bitmap and zbuffer codec for v2 games
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.60
retrieving revision 2.61
diff -u -d -r2.60 -r2.61
--- gfx.cpp 28 Apr 2003 18:35:26 -0000 2.60
+++ gfx.cpp 30 Apr 2003 05:48:54 -0000 2.61
@@ -848,6 +848,8 @@
assert(smap_ptr);
+ byte *roomptr = _vm->getResourceAddress(rtRoom, _vm->_roomResource);
+
zplane_list[0] = smap_ptr;
if (_disable_zbuffer)
@@ -941,8 +943,12 @@
_mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + (y * _numStrips + x);
if (_vm->_features & GF_SMALL_HEADER) {
- if (_vm->_features & GF_16COLOR) {
- useOrDecompress = decompressBitmap(bgbak_ptr, smap_ptr + READ_LE_UINT16(smap_ptr + stripnr * 2 + 2), h);
+ if (_vm->_features & GF_AFTER_V2) {
+ decodeStripOldEGA(bgbak_ptr, roomptr + _vm->_egaStripOffsets[stripnr], h, stripnr);
+ useOrDecompress = false;
+ } else if (_vm->_features & GF_16COLOR) {
+ decodeStripEGA(bgbak_ptr, smap_ptr + READ_LE_UINT16(smap_ptr + stripnr * 2 + 2), h);
+ useOrDecompress = false;
} else {
useOrDecompress = decompressBitmap(bgbak_ptr, smap_ptr + READ_LE_UINT32(smap_ptr + stripnr * 4 + 4), h);
}
@@ -1002,7 +1008,9 @@
if (!zplane_list[i])
continue;
- if (_vm->_features & GF_OLD_BUNDLE)
+ if (_vm->_features & GF_AFTER_V2)
+ offs = 0;
+ else if (_vm->_features & GF_OLD_BUNDLE)
offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2);
else if (_vm->_features & GF_OLD256)
offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 4);
@@ -1018,7 +1026,9 @@
if (offs) {
byte *z_plane_ptr = zplane_list[i] + offs;
- if (useOrDecompress && (flag & dbAllowMaskOr)) {
+ if (_vm->_features & GF_AFTER_V2)
+ decompressMaskImgOld(_mask_ptr_dest, roomptr + _vm->_egaStripZOffsets[stripnr], stripnr);
+ else if (useOrDecompress && (flag & dbAllowMaskOr)) {
decompressMaskImgOr(_mask_ptr_dest, z_plane_ptr, h);
} else {
decompressMaskImg(_mask_ptr_dest, z_plane_ptr, h);
@@ -1101,13 +1111,170 @@
}
}
-bool Gdi::decompressBitmap(byte *bgbak_ptr, byte *smap_ptr, int numLinesToProcess) {
- assert(numLinesToProcess);
+void Scumm::buildStripOffsets() {
+ byte *roomptr = getResourceAddress(rtRoom, _roomResource);
+ byte *bitmap = roomptr + READ_LE_UINT16(roomptr + 10);
+ byte *zplane = roomptr + READ_LE_UINT16(roomptr + 12);
+ int room_width = READ_LE_UINT16(roomptr + 4) >> 3;
+ byte color, data;
+ int x, y, length;
+ int run = 1;
- if (_vm->_features & GF_16COLOR) {
- decodeStripEGA(bgbak_ptr, smap_ptr, numLinesToProcess);
- return false;
+ for (x = 0 ; x < room_width << 3; x++) {
+
+ if ((x % 8) == 0) {
+ _egaStripRun[x >> 3] = run;
+ _egaStripColor[x >> 3] = color;
+ _egaStripOffsets[x >> 3] = bitmap - roomptr;
+ }
+
+ for (y = 0; y < 128; y++) {
+ if (--run == 0) {
+ data = *bitmap++;
+ if (data & 0x80) {
+ run = data & 0x7f;
+ } else {
+ run = data >> 4;
+ }
+ if (run == 0) {
+ run = *bitmap++;
+ }
+ color = data & 0x0f;
+ }
+ }
+ }
+
+ x = 0;
+ y = 128;
+
+ for (;;) {
+ length = *zplane++;
+ if (length & 0x80) {
+ length &= 0x7f;
+ data = *zplane++;
+ do {
+ if (y == 128) {
+ _egaStripZOffsets[x] = zplane - roomptr - 1;
+ _egaStripZRun[x] = length | 0x80;
+ }
+ if (--y == 0) {
+ if (--room_width == 0)
+ return;
+ x++;
+ y = 128;
+ }
+ } while (--length);
+ } else {
+ do {
+ data = *zplane++;
+ if (y == 128) {
+ _egaStripZOffsets[x] = zplane - roomptr - 1;
+ _egaStripZRun[x] = length;
+ }
+ if (--y == 0) {
+ if (--room_width == 0)
+ return;
+ x++;
+ y = 128;
+ }
+ } while (--length);
+ }
}
+}
+
+void Gdi::decodeStripOldEGA(byte *dst, byte *src, int height, int stripnr) {
+ byte color = _vm->_egaStripColor[stripnr];
+ int run = _vm->_egaStripRun[stripnr];
+ bool dither = false;
+ byte dither_table[128];
+ byte data;
+ int x = 4;
+ do {
+ byte *ptr_dither_table = dither_table;
+ int y = 128;
+ do {
+ if (--run == 0) {
+ data = *src++;
+ if (data & 0x80) {
+ run = data & 0x7f;
+ dither = true;
+ } else {
+ run = data >> 4;
+ dither = false;
+ }
+ if (run == 0) {
+ run = *src++;
+ }
+ color = _vm->_shadowPalette[data & 0x0f];
+ }
+ if (!dither) {
+ *ptr_dither_table = color;
+ }
+ *dst = *ptr_dither_table++;
+ dst += _vm->_realWidth;
+ } while (--y);
+ dst -= _vm->_realWidth * 128;
+ dst++;
+
+ ptr_dither_table = dither_table;
+ y = 128;
+ do {
+ if (--run == 0) {
+ data = *src++;
+ if (data & 0x80) {
+ run = data & 0x7f;
+ dither = true;
+ } else {
+ run = data >> 4;
+ dither = false;
+ }
+ if (run == 0) {
+ run = *src++;
+ }
+ color = _vm->_shadowPalette[data & 0x0f];
+ }
+ if (!dither) {
+ *ptr_dither_table = color;
+ }
+ *dst = *ptr_dither_table++;
+
+ dst += _vm->_realWidth;
+ } while (--y);
+ dst -= _vm->_realWidth * 128;
+ dst++;
+ } while (--x);
+}
+
+void Gdi::decompressMaskImgOld(byte *dst, byte *src, int stripnr) {
+ int run = _vm->_egaStripRun[stripnr];
+ int y = 128;
+ byte data;
+
+ for (;;) {
+ if (run & 0x80) {
+ run &= 0x7f;
+ data = *src++;
+ do {
+ *dst++ = data;
+ dst += _numStrips;
+ if (--y == 0)
+ return;
+ } while (--run);
+ } else {
+ do {
+ data = *src++;
+ *dst++ = data;
+ dst += _numStrips;
+ if (--y == 0)
+ return;
+ } while (--run);
+ }
+ run = *src++;
+ }
+}
+
+bool Gdi::decompressBitmap(byte *bgbak_ptr, byte *smap_ptr, int numLinesToProcess) {
+ assert(numLinesToProcess);
byte code = *smap_ptr++;
Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- gfx.h 9 Apr 2003 19:14:05 -0000 1.23
+++ gfx.h 30 Apr 2003 05:48:54 -0000 1.24
@@ -135,6 +135,8 @@
/* Bitmap decompressors */
bool decompressBitmap(byte *bgbak_ptr, byte *smap_ptr, int numLinesToProcess);
void decodeStripEGA(byte *dst, byte *src, int height);
+ void decodeStripOldEGA(byte *dst, byte *src, int height, int stripnr);
+ void decompressMaskImgOld(byte *dst, byte *src, int stripnr);
void unkDecodeA(byte *dst, byte *src, int height);
void unkDecodeA_trans(byte *dst, byte *src, int height);
void unkDecodeB(byte *dst, byte *src, int height);
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -d -r1.171 -r1.172
--- scumm.h 28 Apr 2003 13:16:16 -0000 1.171
+++ scumm.h 30 Apr 2003 05:48:55 -0000 1.172
@@ -749,6 +749,13 @@
uint32 _CLUT_offs;
uint32 _IM00_offs, _PALS_offs;
+ void buildStripOffsets();
+ int _egaStripOffsets[160];
+ int _egaStripRun[160];
+ byte _egaStripColor[160];
+ int _egaStripZOffsets[120];
+ int _egaStripZRun[120];
+
//ender: fullscreen
bool _fullRedraw, _BgNeedsRedraw, _verbRedraw;
bool _screenEffectFlag, _completeScreenRedraw;
Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.112
retrieving revision 2.113
diff -u -d -r2.112 -r2.113
--- scummvm.cpp 29 Apr 2003 08:39:16 -0000 2.112
+++ scummvm.cpp 30 Apr 2003 05:48:55 -0000 2.113
@@ -912,9 +912,10 @@
//
// Find the room image data
//
- if (_features & GF_OLD_BUNDLE)
+ if (_features & GF_OLD_BUNDLE) {
_IM00_offs = READ_LE_UINT16(roomptr + 0x0A);
- else if (_features & GF_SMALL_HEADER)
+ buildStripOffsets();
+ } else if (_features & GF_SMALL_HEADER)
_IM00_offs = findResourceData(MKID('IM00'), roomptr) - roomptr;
else if (_features & GF_AFTER_V8) {
ptr = findResource(MKID('IMAG'), roomptr);
More information about the Scummvm-git-logs
mailing list