diff options
author | Max Horn | 2005-03-25 00:56:03 +0000 |
---|---|---|
committer | Max Horn | 2005-03-25 00:56:03 +0000 |
commit | 7ed1c19f6c46d46cd0fae4a505887675e8338e49 (patch) | |
tree | c81b4c7b54931126882a82a7d4094ac4c6b9e0d8 | |
parent | 88cf4e3c293a228d9778fa5ecda61c33f9b07613 (diff) | |
download | scummvm-rg350-7ed1c19f6c46d46cd0fae4a505887675e8338e49.tar.gz scummvm-rg350-7ed1c19f6c46d46cd0fae4a505887675e8338e49.tar.bz2 scummvm-rg350-7ed1c19f6c46d46cd0fae4a505887675e8338e49.zip |
Cleanup: collect the C64 specific render data into a struct inside class Gdi
svn-id: r17224
-rw-r--r-- | scumm/gfx.cpp | 62 | ||||
-rw-r--r-- | scumm/gfx.h | 17 | ||||
-rw-r--r-- | scumm/object.cpp | 4 | ||||
-rw-r--r-- | scumm/saveload.cpp | 14 | ||||
-rw-r--r-- | scumm/scumm.cpp | 14 | ||||
-rw-r--r-- | scumm/verbs.cpp | 4 |
6 files changed, 60 insertions, 55 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index b9927a7e14..7525518622 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -811,7 +811,7 @@ void ScummEngine::redrawBGStrip(int start, int num) { setGfxUsageBit(s + i, USAGE_BIT_DIRTY); if (_version == 1) { - gdi._C64ObjectMode = false; + gdi._objectMode = false; } if (_heversion >= 70) room = getResourceAddress(rtRoomImage, _roomResource); @@ -1404,8 +1404,8 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi if (_vm->_version == 1) { if (_vm->_features & GF_NES) - drawStripNES(dstPtr, vs->pitch, stripnr, y, height, _C64ObjectMode); - else if (_C64ObjectMode) + drawStripNES(dstPtr, vs->pitch, stripnr, y, height); + else if (_objectMode) drawStripC64Object(dstPtr, vs->pitch, stripnr, width, height); else drawStripC64Background(dstPtr, vs->pitch, stripnr, height); @@ -1454,7 +1454,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi if (_vm->_version == 1) { mask_ptr = getMaskBuffer(x, y, 1); if (_vm->_features & GF_NES) { - drawStripNESMask(mask_ptr, stripnr, height, _C64ObjectMode); + drawStripNESMask(mask_ptr, stripnr, height); } else { drawStripC64Mask(mask_ptr, stripnr, width, height); } @@ -2041,21 +2041,21 @@ void Gdi::decodeNESObject(const byte *ptr, int xpos, int ypos, int width, int he } while (y < height); } -void Gdi::drawStripNES(byte *dst, int dstPitch, int stripnr, int top, int height, bool isObject) { +void Gdi::drawStripNES(byte *dst, int dstPitch, int stripnr, int top, int height) { // printf("drawStripNES, pitch=%i, strip=%i, height=%i\n",dstPitch,stripnr,height); top /= 8; height /= 8; int x = stripnr + 2; // NES version has a 2 tile gap on each edge - if (isObject) + if (_objectMode) x += _NESObj_x; // for objects, need to start at the left edge of the object, not the screen if (x > 63) { debug(0,"NES tried to render invalid strip %i",stripnr); return; } for (int y = top; y < top + height; y++) { - int palette = ((isObject ? _NESAttributesObj : _NESAttributes)[((y << 2) & 0x30) | ((x >> 2) & 0xF)] >> (((y & 2) << 1) | (x & 2))) & 0x3; - int tile = (isObject ? _NESNametableObj : _NESNametable)[y][x]; + int palette = ((_objectMode ? _NESAttributesObj : _NESAttributes)[((y << 2) & 0x30) | ((x >> 2) & 0xF)] >> (((y & 2) << 1) | (x & 2))) & 0x3; + int tile = (_objectMode ? _NESNametableObj : _NESNametable)[y][x]; for (int i = 0; i < 8; i++) { byte c0 = _vm->_NESPatTable[1][tile * 16 + i]; @@ -2067,13 +2067,13 @@ void Gdi::drawStripNES(byte *dst, int dstPitch, int stripnr, int top, int height } } -void Gdi::drawStripNESMask(byte *dst, int stripnr, int height, bool isObject) const { +void Gdi::drawStripNESMask(byte *dst, int stripnr, int height) const { if (!_NEShasmask) return; height /= 8; int x = stripnr + 2; - if (isObject) + if (_objectMode) x += _NESObj_x; // for objects, need to start at the left edge of the object, not the screen if (x > 63) { debug(0,"NES tried to mask invalid strip %i",stripnr); @@ -2081,7 +2081,7 @@ void Gdi::drawStripNESMask(byte *dst, int stripnr, int height, bool isObject) co } for (int y = 0; y < height; y++) { // the ? 0xFF : 0x00 here might be backwards - '1' bits indicate that sprites can get hidden - byte c = (((isObject ? _NESMasktableObj : _NESMasktable)[y][x >> 3] >> (x & 7)) & 1) ? 0xFF : 0x00; + byte c = (((_objectMode ? _NESMasktableObj : _NESMasktable)[y][x >> 3] >> (x & 7)) & 1) ? 0xFF : 0x00; for (int i = 0; i < 8; i++) { *dst = c; dst += _numStrips; @@ -2093,20 +2093,20 @@ void Gdi::drawStripC64Background(byte *dst, int dstPitch, int stripnr, int heigh int charIdx; height /= 8; for (int y = 0; y < height; y++) { - _C64Colors[3] = (_C64ColorMap[y + stripnr * height] & 7); + _C64.colors[3] = (_C64.colorMap[y + stripnr * height] & 7); // Check for room color change in V1 zak if (_roomPalette[0] == 255) { - _C64Colors[2] = _roomPalette[2]; - _C64Colors[1] = _roomPalette[1]; + _C64.colors[2] = _roomPalette[2]; + _C64.colors[1] = _roomPalette[1]; } - charIdx = _C64PicMap[y + stripnr * height] * 8; + charIdx = _C64.picMap[y + stripnr * height] * 8; for (int i = 0; i < 8; i++) { - byte c = _C64CharMap[charIdx + i]; - dst[0] = dst[1] = _C64Colors[(c >> 6) & 3]; - dst[2] = dst[3] = _C64Colors[(c >> 4) & 3]; - dst[4] = dst[5] = _C64Colors[(c >> 2) & 3]; - dst[6] = dst[7] = _C64Colors[(c >> 0) & 3]; + byte c = _C64.charMap[charIdx + i]; + dst[0] = dst[1] = _C64.colors[(c >> 6) & 3]; + dst[2] = dst[3] = _C64.colors[(c >> 4) & 3]; + dst[4] = dst[5] = _C64.colors[(c >> 2) & 3]; + dst[6] = dst[7] = _C64.colors[(c >> 0) & 3]; dst += dstPitch; } } @@ -2117,14 +2117,14 @@ void Gdi::drawStripC64Object(byte *dst, int dstPitch, int stripnr, int width, in height /= 8; width /= 8; for (int y = 0; y < height; y++) { - _C64Colors[3] = (_C64ObjectMap[(y + height) * width + stripnr] & 7); - charIdx = _C64ObjectMap[y * width + stripnr] * 8; + _C64.colors[3] = (_C64.objectMap[(y + height) * width + stripnr] & 7); + charIdx = _C64.objectMap[y * width + stripnr] * 8; for (int i = 0; i < 8; i++) { - byte c = _C64CharMap[charIdx + i]; - dst[0] = dst[1] = _C64Colors[(c >> 6) & 3]; - dst[2] = dst[3] = _C64Colors[(c >> 4) & 3]; - dst[4] = dst[5] = _C64Colors[(c >> 2) & 3]; - dst[6] = dst[7] = _C64Colors[(c >> 0) & 3]; + byte c = _C64.charMap[charIdx + i]; + dst[0] = dst[1] = _C64.colors[(c >> 6) & 3]; + dst[2] = dst[3] = _C64.colors[(c >> 4) & 3]; + dst[4] = dst[5] = _C64.colors[(c >> 2) & 3]; + dst[6] = dst[7] = _C64.colors[(c >> 0) & 3]; dst += dstPitch; } } @@ -2135,12 +2135,12 @@ void Gdi::drawStripC64Mask(byte *dst, int stripnr, int width, int height) const height /= 8; width /= 8; for (int y = 0; y < height; y++) { - if (_C64ObjectMode) - maskIdx = _C64ObjectMap[(y + 2 * height) * width + stripnr] * 8; + if (_objectMode) + maskIdx = _C64.objectMap[(y + 2 * height) * width + stripnr] * 8; else - maskIdx = _C64MaskMap[y + stripnr * height] * 8; + maskIdx = _C64.maskMap[y + stripnr * height] * 8; for (int i = 0; i < 8; i++) { - byte c = _C64MaskChar[maskIdx + i]; + byte c = _C64.maskChar[maskIdx + i]; // V1/C64 masks are inverted compared to what ScummVM expects *dst = c ^ 0xFF; diff --git a/scumm/gfx.h b/scumm/gfx.h index abeb73b0a6..6d031545dd 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -208,7 +208,6 @@ public: int _numZBuffer; int _imgBufOffs[8]; int32 _numStrips; - byte _C64Colors[4]; Gdi(ScummEngine *vm); @@ -225,9 +224,15 @@ protected: bool _zbufferDisabled; - byte _C64CharMap[2048], _C64ObjectMap[2048], _C64PicMap[4096], _C64ColorMap[4096]; - byte _C64MaskMap[4096], _C64MaskChar[4096]; - bool _C64ObjectMode; + /** Flag which is true when an object is being rendered, false otherwise. */ + bool _objectMode; + + /** Render settings which are specific to the C64 graphic decoders. */ + struct { + byte colors[4]; + byte charMap[2048], objectMap[2048], picMap[4096], colorMap[4096]; + byte maskMap[4096], maskChar[4096]; + } _C64; byte _NESBaseTiles; byte _NESNametable[16][64], _NESNametableObj[16][64]; @@ -242,7 +247,7 @@ protected: void drawStripEGA(byte *dst, int dstPitch, const byte *src, int height) const; void drawStripC64Object(byte *dst, int dstPitch, int stripnr, int width, int height); void drawStripC64Background(byte *dst, int dstPitch, int stripnr, int height); - void drawStripNES(byte *dst, int dstPitch, int stripnr, int top, int height, bool isObject); + void drawStripNES(byte *dst, int dstPitch, int stripnr, int top, int height); void drawStripComplex(byte *dst, int dstPitch, const byte *src, int height, const bool transpCheck) const; void drawStripBasicH(byte *dst, int dstPitch, const byte *src, int height, const bool transpCheck) const; @@ -259,7 +264,7 @@ protected: /* Mask decompressors */ void drawStripC64Mask(byte *dst, int stripnr, int width, int height) const; - void drawStripNESMask(byte *dst, int stripnr, int height, bool isObject) const; + void drawStripNESMask(byte *dst, int stripnr, int height) const; void decompressMaskImgOr(byte *dst, const byte *src, int height) const; void decompressMaskImg(byte *dst, const byte *src, int height) const; diff --git a/scumm/object.cpp b/scumm/object.cpp index b535709a9e..c360e9de4e 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -481,11 +481,11 @@ void ScummEngine::drawObject(int obj, int arg) { byte flags = od.flags; if (_version == 1) { - gdi._C64ObjectMode = true; + gdi._objectMode = true; if (_features & GF_NES) { gdi.decodeNESObject(ptr, xpos, ypos, width, height); } else { - gdi.decodeC64Gfx(ptr, gdi._C64ObjectMap, width * (height / 8) * 3); + gdi.decodeC64Gfx(ptr, gdi._C64.objectMap, width * (height / 8) * 3); } } // Sam & Max needs this to fix object-layering problems with diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 32b9828816..5d0a5daccb 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -288,14 +288,14 @@ bool ScummEngine::loadState(int slot, bool compat) { roomptr = getResourceAddress(rtRoom, _roomResource); _IM00_offs = 0; for (i = 0; i < 4; i++){ - gdi._C64Colors[i] = roomptr[6 + i]; + gdi._C64.colors[i] = roomptr[6 + i]; } - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 10), gdi._C64CharMap, 2048); - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 12), gdi._C64PicMap, roomptr[4] * roomptr[5]); - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 14), gdi._C64ColorMap, roomptr[4] * roomptr[5]); - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 16), gdi._C64MaskMap, roomptr[4] * roomptr[5]); - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 18) + 2, gdi._C64MaskChar, READ_LE_UINT16(roomptr + READ_LE_UINT16(roomptr + 18))); - gdi._C64ObjectMode = true; + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 10), gdi._C64.charMap, 2048); + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 12), gdi._C64.picMap, roomptr[4] * roomptr[5]); + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 14), gdi._C64.colorMap, roomptr[4] * roomptr[5]); + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 16), gdi._C64.maskMap, roomptr[4] * roomptr[5]); + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 18) + 2, gdi._C64.maskChar, READ_LE_UINT16(roomptr + READ_LE_UINT16(roomptr + 18))); + gdi._objectMode = true; } else if (_version == 2) { _roomStrips = gdi.generateStripTable(getResourceAddress(rtRoom, _roomResource) + _IM00_offs, _roomWidth, _roomHeight, _roomStrips); diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index b64594d029..f96a3e9ac6 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -2307,14 +2307,14 @@ void ScummEngine::initRoomSubBlocks() { } else { _IM00_offs = 0; for (i = 0; i < 4; i++){ - gdi._C64Colors[i] = roomptr[6 + i]; + gdi._C64.colors[i] = roomptr[6 + i]; } - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 10), gdi._C64CharMap, 2048); - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 12), gdi._C64PicMap, roomptr[4] * roomptr[5]); - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 14), gdi._C64ColorMap, roomptr[4] * roomptr[5]); - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 16), gdi._C64MaskMap, roomptr[4] * roomptr[5]); - gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 18) + 2, gdi._C64MaskChar, READ_LE_UINT16(roomptr + READ_LE_UINT16(roomptr + 18))); - gdi._C64ObjectMode = true; + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 10), gdi._C64.charMap, 2048); + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 12), gdi._C64.picMap, roomptr[4] * roomptr[5]); + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 14), gdi._C64.colorMap, roomptr[4] * roomptr[5]); + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 16), gdi._C64.maskMap, roomptr[4] * roomptr[5]); + gdi.decodeC64Gfx(roomptr + READ_LE_UINT16(roomptr + 18) + 2, gdi._C64.maskChar, READ_LE_UINT16(roomptr + READ_LE_UINT16(roomptr + 18))); + gdi._objectMode = true; } } else if (_features & GF_OLD_BUNDLE) { _IM00_offs = READ_LE_UINT16(roomptr + 0x0A); diff --git a/scumm/verbs.cpp b/scumm/verbs.cpp index 6956ba6837..154e6d9093 100644 --- a/scumm/verbs.cpp +++ b/scumm/verbs.cpp @@ -579,8 +579,8 @@ void ScummEngine::drawVerbBitmap(int verb, int x, int y) { } assert(imptr); if (_version == 1) { - gdi._C64ObjectMode = true; - gdi.decodeC64Gfx(imptr, gdi._C64ObjectMap, imgw * imgh * 3); + gdi._objectMode = true; + gdi.decodeC64Gfx(imptr, gdi._C64.objectMap, imgw * imgh * 3); } for (i = 0; i < imgw; i++) { tmp = xstrip + i; |