Cleanup: collect the C64 specific render data into a struct inside class Gdi

svn-id: r17224
This commit is contained in:
Max Horn 2005-03-25 00:56:03 +00:00
parent 88cf4e3c29
commit 7ed1c19f6c
6 changed files with 60 additions and 55 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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);

View file

@ -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);

View file

@ -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;