aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/costume.cpp16
-rw-r--r--scumm/gfx.cpp11
-rw-r--r--scumm/gfx.h2
-rw-r--r--scumm/script_v2.cpp2
4 files changed, 17 insertions, 14 deletions
diff --git a/scumm/costume.cpp b/scumm/costume.cpp
index b9cc3773fb..80c7880342 100644
--- a/scumm/costume.cpp
+++ b/scumm/costume.cpp
@@ -670,6 +670,8 @@ void CostumeRenderer::drawNESCostume(const Actor *a, int limb) {
const CostumeData &cost = a->_cost;
int anim = cost.frame[limb];
int frameNum = cost.curpos[limb];
+ byte *bgTransBuf = _vm->getMaskBuffer(0, 0, 0);
+ byte *gfxMaskBuf = _vm->getMaskBuffer(0, 0, 1);
src = _loaded._dataOffsets;
@@ -692,7 +694,6 @@ void CostumeRenderer::drawNESCostume(const Actor *a, int limb) {
numSprites = numSpritesTab[frame] + 1;
int left = 239, right = 0, top = 239, bottom = 0;
- byte *gfxMaskBuf = _vm->getMaskBuffer(0, 0, 1);
for (int spr = 0; spr < numSprites; spr++) {
byte mask = (ptr[0] & 0x80) ? 0x01 : 0x80;
@@ -713,28 +714,27 @@ void CostumeRenderer::drawNESCostume(const Actor *a, int limb) {
if ((_actorY + y < 0) || (_actorY + y + 8 >= _out.h))
continue;
-
+ bool doMask = (_zbuf && gfxMaskBuf[(_actorY + y) * _numStrips + (_actorX + x + 4) / 8 - 2]);
+
for (int ty = 0; ty < 8; ty++) {
byte c1 = _vm->_NESPatTable[0][tile * 16 + ty];
byte c2 = _vm->_NESPatTable[0][tile * 16 + ty + 8];
- byte gfxMask = gfxMaskBuf[(_actorY + y + ty) * _numStrips + (_actorX + x) / 8 - 2];
for (int tx = 0; tx < 8; tx++) {
unsigned char c = ((c1 & mask) ? 1 : 0) | ((c2 & mask) ? 2 : 0) | palette;
- bool draw = ((gfxMask & mask) == 0);
if (mask == 0x01) {
c1 >>= 1;
c2 >>= 1;
- gfxMask >>= 1;
} else {
c1 <<= 1;
c2 <<= 1;
- gfxMask <<= 1;
}
if (!(c & 3))
continue;
- if (draw)
- *((byte *)_out.pixels + (_actorY + y + ty) * _out.pitch + (_actorX + x + tx)) = _vm->_NESPalette[1][c];
+ int my = _actorY + y + ty;
+ int mx = _actorX + x + tx;
+ if (!doMask || !(bgTransBuf[my * _numStrips + mx / 8] & (0x80 >> (mx & 7))))
+ *((byte *)_out.pixels + my * _out.pitch + mx) = _vm->_NESPalette[1][c];
}
}
if (left > _actorX + x)
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index 3ab4d6f05a..89a93fb93c 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -1399,8 +1399,10 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi
dstPtr = (byte *)vs->pixels + y * vs->pitch + x * 8;
if (_vm->_version == 1) {
- if (_vm->_features & GF_NES)
- drawStripNES(dstPtr, vs->pitch, stripnr, y, height);
+ if (_vm->_features & GF_NES) {
+ mask_ptr = getMaskBuffer(x, y, 0);
+ drawStripNES(dstPtr, mask_ptr, vs->pitch, stripnr, y, height);
+ }
else if (_objectMode)
drawStripC64Object(dstPtr, vs->pitch, stripnr, width, height);
else
@@ -2037,8 +2039,7 @@ 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) {
-// printf("drawStripNES, pitch=%i, strip=%i, height=%i\n",dstPitch,stripnr,height);
+void Gdi::drawStripNES(byte *dst, byte *mask, int dstPitch, int stripnr, int top, int height) {
top /= 8;
height /= 8;
int x = stripnr + 2; // NES version has a 2 tile gap on each edge
@@ -2059,6 +2060,8 @@ void Gdi::drawStripNES(byte *dst, int dstPitch, int stripnr, int top, int height
for (int j = 0; j < 8; j++)
dst[j] = _vm->_NESPalette[0][((c0 >> (7 - j)) & 1) | (((c1 >> (7 - j)) & 1) << 1) | (palette << 2)];
dst += dstPitch;
+ *mask = c0 | c1;
+ mask += _numStrips;
}
}
}
diff --git a/scumm/gfx.h b/scumm/gfx.h
index b5805cd0b3..feb7bacc52 100644
--- a/scumm/gfx.h
+++ b/scumm/gfx.h
@@ -248,7 +248,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);
+ void drawStripNES(byte *dst, byte *mask, 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;
diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp
index c53cf03c78..dcbc1e8429 100644
--- a/scumm/script_v2.cpp
+++ b/scumm/script_v2.cpp
@@ -991,7 +991,7 @@ void ScummEngine_v2::o2_drawSentence() {
// For V1 games, the engine must compute the preposition.
// In all other Scumm versions, this is done by the sentence script.
- if ((_gameId == GID_MANIAC && _version == 1) && (VAR(VAR_SENTENCE_PREPOSITION) == 0)) {
+ if ((_gameId == GID_MANIAC && _version == 1 && !(_features & GF_NES)) && (VAR(VAR_SENTENCE_PREPOSITION) == 0)) {
if (_verbs[slot].prep == 0xFF) {
byte *ptr = getOBCDFromObject(VAR(VAR_SENTENCE_OBJECT1));
assert(ptr);