diff options
author | Max Horn | 2011-05-11 14:02:21 +0200 |
---|---|---|
committer | Max Horn | 2011-05-13 11:47:07 +0200 |
commit | 068b4a5351a5574dbfac6acff5776a0071f3f2dd (patch) | |
tree | b7f0cf1b0a946f84a34558eb44779e7551e662d9 /engines/scumm | |
parent | c9cef5e9711a33c5e8a0a442b336175df5ebb3c2 (diff) | |
download | scummvm-rg350-068b4a5351a5574dbfac6acff5776a0071f3f2dd.tar.gz scummvm-rg350-068b4a5351a5574dbfac6acff5776a0071f3f2dd.tar.bz2 scummvm-rg350-068b4a5351a5574dbfac6acff5776a0071f3f2dd.zip |
SCUMM: Move tmsk code into its own Gdi subclass
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/gfx.cpp | 74 | ||||
-rw-r--r-- | engines/scumm/gfx.h | 29 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 4 |
3 files changed, 84 insertions, 23 deletions
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 287fd1e09b..08ae9fdd96 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -218,6 +218,10 @@ Gdi::Gdi(ScummEngine *vm) : _vm(vm) { Gdi::~Gdi() { } +GdiHE::GdiHE(ScummEngine *vm) : Gdi(vm), _tmskPtr(0) { +} + + GdiNES::GdiNES(ScummEngine *vm) : Gdi(vm) { memset(&_NES, 0, sizeof(_NES)); } @@ -1500,6 +1504,15 @@ void Gdi::prepareDrawBitmap(const byte *ptr, VirtScreen *vs, // Do nothing by default } +void GdiHE::prepareDrawBitmap(const byte *ptr, VirtScreen *vs, + const int x, const int y, const int width, const int height, + int stripnr, int numstrip) { + if (_vm->_game.heversion >= 72) { + _tmskPtr = _vm->findResource(MKTAG('T','M','S','K'), ptr); + } else + _tmskPtr = 0; +} + void GdiV1::prepareDrawBitmap(const byte *ptr, VirtScreen *vs, const int x, const int y, const int width, const int height, int stripnr, int numstrip) { @@ -1745,11 +1758,6 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const numzbuf = getZPlanes(ptr, zplane_list, false); - const byte *tmsk_ptr = NULL; - if (_vm->_game.heversion >= 72) { - tmsk_ptr = _vm->findResource(MKTAG('T','M','S','K'), ptr); - } - if (y + height > vs->h) { warning("Gdi::drawBitmap, strip drawn to %d below window bottom %d", y + height, vs->h); } @@ -1812,7 +1820,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const clear8Col(frontBuf, vs->pitch, height, vs->format.bytesPerPixel); } - decodeMask(x, y, width, height, stripnr, numzbuf, zplane_list, transpStrip, flag, tmsk_ptr); + decodeMask(x, y, width, height, stripnr, numzbuf, zplane_list, transpStrip, flag); #if 0 // HACK: blit mask(s) onto normal screen. Useful to debug masking @@ -1901,7 +1909,7 @@ bool GdiV2::drawStrip(byte *dstPtr, VirtScreen *vs, int x, int y, const int widt void Gdi::decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr) { + bool transpStrip, byte flag) { int i; byte *mask_ptr; const byte *z_plane_ptr; @@ -1957,10 +1965,7 @@ void Gdi::decodeMask(int x, int y, const int width, const int height, if (offs) { z_plane_ptr = zplane_list[i] + offs; - if (tmsk_ptr) { - const byte *tmsk = tmsk_ptr + READ_LE_UINT16(tmsk_ptr + stripnr * 2 + 8); - decompressTMSK(mask_ptr, tmsk, z_plane_ptr, height); - } else if (transpStrip && (flag & dbAllowMaskOr)) { + if (transpStrip && (flag & dbAllowMaskOr)) { decompressMaskImgOr(mask_ptr, z_plane_ptr, height); } else { decompressMaskImg(mask_ptr, z_plane_ptr, height); @@ -1975,9 +1980,46 @@ void Gdi::decodeMask(int x, int y, const int width, const int height, } } +void GdiHE::decodeMask(int x, int y, const int width, const int height, + int stripnr, int numzbuf, const byte *zplane_list[9], + bool transpStrip, byte flag) { + int i; + byte *mask_ptr; + const byte *z_plane_ptr; + + for (i = 1; i < numzbuf; i++) { + uint32 offs; + + if (!zplane_list[i]) + continue; + + offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 8); + + mask_ptr = getMaskBuffer(x, y, i); + + if (offs) { + z_plane_ptr = zplane_list[i] + offs; + + if (_tmskPtr) { + const byte *tmsk = _tmskPtr + READ_LE_UINT16(_tmskPtr + stripnr * 2 + 8); + decompressTMSK(mask_ptr, tmsk, z_plane_ptr, height); + } else if (transpStrip && (flag & dbAllowMaskOr)) { + decompressMaskImgOr(mask_ptr, z_plane_ptr, height); + } else { + decompressMaskImg(mask_ptr, z_plane_ptr, height); + } + + } else { + if (!(transpStrip && (flag & dbAllowMaskOr))) + for (int h = 0; h < height; h++) + mask_ptr[h * _numStrips] = 0; + } + } +} + void GdiNES::decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr) { + bool transpStrip, byte flag) { byte *mask_ptr = getMaskBuffer(x, y, 1); drawStripNESMask(mask_ptr, stripnr, y, height); } @@ -1985,7 +2027,7 @@ void GdiNES::decodeMask(int x, int y, const int width, const int height, #ifdef USE_RGB_COLOR void GdiPCEngine::decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr) { + bool transpStrip, byte flag) { byte *mask_ptr = getMaskBuffer(x, y, 1); drawStripPCEngineMask(mask_ptr, stripnr, y, height); } @@ -1993,14 +2035,14 @@ void GdiPCEngine::decodeMask(int x, int y, const int width, const int height, void GdiV1::decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr) { + bool transpStrip, byte flag) { byte *mask_ptr = getMaskBuffer(x, y, 1); drawStripC64Mask(mask_ptr, stripnr, width, height); } void GdiV2::decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr) { + bool transpStrip, byte flag) { // Do nothing here for V2 games - zplane was already handled. } @@ -2368,7 +2410,7 @@ void Gdi::decompressMaskImg(byte *dst, const byte *src, int height) const { } } -void Gdi::decompressTMSK(byte *dst, const byte *tmsk, const byte *src, int height) const { +void GdiHE::decompressTMSK(byte *dst, const byte *tmsk, const byte *src, int height) const { byte srcbits = 0; byte srcFlag = 0; byte maskFlag = 0; diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h index 45ff8ce97a..6da07efd18 100644 --- a/engines/scumm/gfx.h +++ b/engines/scumm/gfx.h @@ -221,7 +221,6 @@ protected: virtual void writeRoomColor(byte *dst, byte color) const; /* Mask decompressors */ - void decompressTMSK(byte *dst, const byte *tmsk, const byte *src, int height) const; void decompressMaskImgOr(byte *dst, const byte *src, int height) const; void decompressMaskImg(byte *dst, const byte *src, int height) const; @@ -234,7 +233,7 @@ protected: virtual void decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr); + bool transpStrip, byte flag); virtual void prepareDrawBitmap(const byte *ptr, VirtScreen *vs, const int x, const int y, const int width, const int height, @@ -270,6 +269,24 @@ public: }; }; +class GdiHE : public Gdi { +protected: + const byte *_tmskPtr; + +protected: + void decompressTMSK(byte *dst, const byte *tmsk, const byte *src, int height) const; + + virtual void decodeMask(int x, int y, const int width, const int height, + int stripnr, int numzbuf, const byte *zplane_list[9], + bool transpStrip, byte flag); + + virtual void prepareDrawBitmap(const byte *ptr, VirtScreen *vs, + const int x, const int y, const int width, const int height, + int stripnr, int numstrip); +public: + GdiHE(ScummEngine *vm); +}; + class GdiNES : public Gdi { protected: struct { @@ -293,7 +310,7 @@ protected: virtual void decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr); + bool transpStrip, byte flag); virtual void prepareDrawBitmap(const byte *ptr, VirtScreen *vs, const int x, const int y, const int width, const int height, @@ -336,7 +353,7 @@ protected: virtual void decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr); + bool transpStrip, byte flag); virtual void prepareDrawBitmap(const byte *ptr, VirtScreen *vs, const int x, const int y, const int width, const int height, @@ -373,7 +390,7 @@ protected: virtual void decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr); + bool transpStrip, byte flag); virtual void prepareDrawBitmap(const byte *ptr, VirtScreen *vs, const int x, const int y, const int width, const int height, @@ -399,7 +416,7 @@ protected: virtual void decodeMask(int x, int y, const int width, const int height, int stripnr, int numzbuf, const byte *zplane_list[9], - bool transpStrip, byte flag, const byte *tmsk_ptr); + bool transpStrip, byte flag); virtual void prepareDrawBitmap(const byte *ptr, VirtScreen *vs, const int x, const int y, const int width, const int height, diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index b1198247d3..f5187546a1 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -112,7 +112,9 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _currentScript(0xFF), // Let debug() work on init stage _messageDialog(0), _pauseDialog(0), _versionDialog(0) { - if (_game.platform == Common::kPlatformNES) { + if (_game.heversion > 0) { + _gdi = new GdiHE(this); + } else if (_game.platform == Common::kPlatformNES) { _gdi = new GdiNES(this); #ifdef USE_RGB_COLOR } else if (_game.features & GF_16BIT_COLOR) { |