[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.451,2.452 gfx.h,1.118,1.119 costume.cpp,1.182,1.183 object.cpp,1.241,1.242
Eugene Sandulenko
sev at users.sourceforge.net
Wed May 18 16:18:22 CEST 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32018
Modified Files:
gfx.cpp gfx.h costume.cpp object.cpp
Log Message:
Patch from Quietust for MM NES:
o Fix all actor mask bugs
o Simplify masking considerably
o Moved the decodesNESObject call from object.cpp into gfx.cpp
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.451
retrieving revision 2.452
diff -u -d -r2.451 -r2.452
--- gfx.cpp 18 May 2005 20:40:50 -0000 2.451
+++ gfx.cpp 18 May 2005 23:17:00 -0000 2.452
@@ -1367,7 +1367,7 @@
if (_objectMode && _vm->_version == 1) {
if (_vm->_platform == Common::kPlatformNES) {
- // TODO: Maybe call decodeNESObject here?
+ decodeNESObject(ptr, x, y, width, height);
} else {
decodeC64Gfx(ptr, _C64.objectMap, (width / 8) * (height / 8) * 3);
}
@@ -1442,7 +1442,7 @@
if (_vm->_version == 1) {
if (_vm->_platform == Common::kPlatformNES) {
- mask_ptr = getMaskBuffer(x + k, y, 0);
+ mask_ptr = getMaskBuffer(x + k, y, 1);
drawStripNES(dstPtr, mask_ptr, vs->pitch, stripnr, y, height);
}
else if (_objectMode)
@@ -1494,7 +1494,7 @@
if (_vm->_version == 1) {
mask_ptr = getMaskBuffer(x + k, y, 1);
if (_vm->_platform == Common::kPlatformNES) {
- drawStripNESMask(mask_ptr, stripnr, height);
+ drawStripNESMask(mask_ptr, stripnr, y, height);
} else {
drawStripC64Mask(mask_ptr, stripnr, width, height);
}
@@ -1971,7 +1971,7 @@
}
_NES.nametable[i][width+2] = _NES.nametable[i][width+3] = 0;
}
- memcpy(_NES.nametableObj,_NES.nametable, 16 * 64);
+ memcpy(_NES.nametableObj,_NES.nametable, 16*64);
const byte *adata = room + READ_LE_UINT16(room + 0x0C);
for (n = 0; n < 64;) {
@@ -2005,7 +2005,7 @@
mdata++;
}
}
- memcpy(_NES.masktableObj, _NES.masktable, 16 * 8);
+ memcpy(_NES.masktableObj, _NES.masktable, 16*8);
}
void Gdi::decodeNESObject(const byte *ptr, int xpos, int ypos, int width, int height) {
@@ -2014,8 +2014,10 @@
_NES.objX = xpos;
// decode tile update data
+ width /= 8;
ypos /= 8;
height /= 8;
+
for (y = ypos; y < ypos + height; y++) {
x = xpos;
while (x < xpos + width) {
@@ -2073,12 +2075,14 @@
y = 0;
do {
byte *dest = &_NES.masktableObj[y + ypos][mx];
- *dest++ = (*dest & lmask) | *ptr++;
+ *dest = (*dest & lmask) | *ptr++;
+ dest++;
for (x = 1; x < mwidth; x++) {
if (x + 1 == mwidth)
- *dest++ = (*dest & rmask) | *ptr++;
+ *dest = (*dest & rmask) | *ptr++;
else
- *dest++ = *ptr++;
+ *dest = *ptr++;
+ dest++;
}
y++;
} while (y < height);
@@ -2111,11 +2115,12 @@
}
}
-void Gdi::drawStripNESMask(byte *dst, int stripnr, int height) const {
+void Gdi::drawStripNESMask(byte *dst, int stripnr, int top, int height) const {
if (!_NES.hasmask)
return;
+ top /= 8;
height /= 8;
- int x = stripnr + 2;
+ int x = stripnr; // masks, unlike room graphics, should NOT be adjusted
if (_objectMode)
x += _NES.objX; // for objects, need to start at the left edge of the object, not the screen
@@ -2123,10 +2128,10 @@
debug(0,"NES tried to mask invalid strip %i",stripnr);
return;
}
- for (int y = 0; y < height; y++) {
+ for (int y = top; y < top + height; y++) {
byte c = (((_objectMode ? _NES.masktableObj : _NES.masktable)[y][x >> 3] >> (x & 7)) & 1) ? 0xFF : 0x00;
for (int i = 0; i < 8; i++) {
- *dst = c;
+ *dst &= c;
dst += _numStrips;
}
}
Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- gfx.h 11 May 2005 13:02:39 -0000 1.118
+++ gfx.h 18 May 2005 23:17:04 -0000 1.119
@@ -255,7 +255,7 @@
/* Mask decompressors */
void drawStripC64Mask(byte *dst, int stripnr, int width, int height) const;
- void drawStripNESMask(byte *dst, int stripnr, int height) const;
+ void drawStripNESMask(byte *dst, int stripnr, int top, int height) const;
void decompressMaskImgOr(byte *dst, const byte *src, int height) const;
void decompressMaskImg(byte *dst, const byte *src, int height) const;
Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/costume.cpp,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -d -r1.182 -r1.183
--- costume.cpp 15 May 2005 10:40:27 -0000 1.182
+++ costume.cpp 18 May 2005 23:17:04 -0000 1.183
@@ -656,8 +656,7 @@
bool flipped = (newDirToOldDir(a->getFacing()) == 1);
int left = 239, right = 0, top = 239, bottom = 0;
- byte *bgTransBuf = _vm->getMaskBuffer(0, 0, 0);
- byte *gfxMaskBuf = _vm->getMaskBuffer(0, 0, 1);
+ byte *maskBuf = _vm->getMaskBuffer(0, 0, 1);
for (int spr = 0; spr < numSprites; spr++) {
byte mask, tile, sprpal;
@@ -685,8 +684,6 @@
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];
@@ -704,7 +701,7 @@
continue;
int my = _actorY + y + ty;
int mx = _actorX + x + tx;
- if (!doMask || !(bgTransBuf[my * _numStrips + mx / 8] & revBitMask(mx & 7)))
+ if (!(_zbuf && (maskBuf[my * _numStrips + mx / 8] & revBitMask(mx & 7))))
*((byte *)_out.pixels + my * _out.pitch + mx) = palette[c];
}
}
Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.241
retrieving revision 1.242
diff -u -d -r1.241 -r1.242
--- object.cpp 18 May 2005 15:30:30 -0000 1.241
+++ object.cpp 18 May 2005 23:17:04 -0000 1.242
@@ -484,11 +484,6 @@
if (numstrip != 0) {
byte flags = od.flags | Gdi::dbObjectMode;
- if (_version == 1) {
- if (_platform == Common::kPlatformNES) {
- gdi.decodeNESObject(ptr, xpos, ypos, width, height);
- }
- }
// Sam & Max needs this to fix object-layering problems with
// the inventory and conversation icons.
if ((_version >= 7 || _gameId == GID_SAMNMAX) && getClass(od.obj_nr, kObjectClassIgnoreBoxes))
More information about the Scummvm-git-logs
mailing list