From 13888147068c06121cb9c69b21b6ca239a354819 Mon Sep 17 00:00:00 2001 From: James Brown Date: Sun, 29 Sep 2002 15:20:02 +0000 Subject: Patch 616144: Sam and Max layering fix (drawMaskOnBoth rewrite) svn-id: r5036 --- scumm/gfx.cpp | 82 ++++++++++++++++++++++++++++++++++---------------------- scumm/gfx.h | 2 +- scumm/object.cpp | 2 +- 3 files changed, 52 insertions(+), 34 deletions(-) diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 1eaa1a9d48..11c7139f56 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -924,44 +924,62 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, int h, } } CHECK_HEAP; - if (flag & dbDrawMaskOnBoth) { - _z_plane_ptr = zplane_list[1] + READ_LE_UINT16(zplane_list[1] + stripnr * 2 + 8); - _mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * NUM_STRIPS + x; - if (_useOrDecompress && flag & dbAllowMaskOr) - decompressMaskImgOr(); - else - decompressMaskImg(); - } - for (i = 1; i < numzbuf; i++) { - uint16 offs; + // Sam & Max uses dbDrawMaskOnAll for things like the inventory + // box and the speech icons. While these objects only have one + // mask, it should be applied to all the Z-planes in the room, + // i.e. they should mask every actor. + // + // This flag used to be called dbDrawMaskOnBoth, and all it + // would do was to mask Z-plane 0. (Z-plane 1 would also be + // masked, because what is now the else-clause used to be run + // always.) While this seems to be the only way there is to + // mask Z-plane 0, this wasn't good enough since actors in + // Z-planes >= 2 would not be masked. + // + // The flag is also used by The Dig and Full Throttle, but I + // don't know what for. At the time of writing, these games + // are still too unstable for me to investigate. + + if (flag & dbDrawMaskOnAll) { + _z_plane_ptr = zplane_list[1] + READ_LE_UINT16(zplane_list[1] + stripnr * 2 + 8); + for (i = 0; i < numzbuf; i++) { + _mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * NUM_STRIPS + x + _imgBufOffs[i]; + if (_useOrDecompress && flag & dbAllowMaskOr) + decompressMaskImgOr(); + else + decompressMaskImg(); + } + } else { + for (i = 1; i < numzbuf; i++) { + uint16 offs; - if (!zplane_list[i]) - continue; + if (!zplane_list[i]) + continue; - if (_vm->_features & GF_SMALL_HEADER) - if (_vm->_features & GF_OLD256) - offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 4); - else - offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 2); - else - offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 8); + if (_vm->_features & GF_SMALL_HEADER) { + if (_vm->_features & GF_OLD256) + offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 4); + else + offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 2); + } else + offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 8); - _mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * NUM_STRIPS + x + _imgBufOffs[i]; + _mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * NUM_STRIPS + x + _imgBufOffs[i]; - if (offs) { - _z_plane_ptr = zplane_list[i] + offs; + if (offs) { + _z_plane_ptr = zplane_list[i] + offs; - if (_useOrDecompress && flag & dbAllowMaskOr) - decompressMaskImgOr(); - else - decompressMaskImg(); - } else { - if (_useOrDecompress && flag & dbAllowMaskOr); /* nothing */ - else - for (int h = 0; h < _numLinesToProcess; h++) - _mask_ptr_dest[h * NUM_STRIPS] = 0; - /* needs better abstraction, FIXME */ + if (_useOrDecompress && flag & dbAllowMaskOr) + decompressMaskImgOr(); + else + decompressMaskImg(); + } else { + if (!(_useOrDecompress && flag & dbAllowMaskOr)); + for (int h = 0; h < _numLinesToProcess; h++) + _mask_ptr_dest[h * NUM_STRIPS] = 0; + /* needs better abstraction, FIXME */ + } } } CHECK_HEAP; diff --git a/scumm/gfx.h b/scumm/gfx.h index 93eec1e64c..b1f605d193 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -184,7 +184,7 @@ struct Gdi { enum DrawBitmapFlags { dbAllowMaskOr = 1, - dbDrawMaskOnBoth = 2, + dbDrawMaskOnAll = 2, dbClear = 4 }; }; diff --git a/scumm/object.cpp b/scumm/object.cpp index e05a1e16ba..40896990a7 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -378,7 +378,7 @@ void Scumm::drawObject(int obj, int arg) // Sam & Max needs this to fix object-layering problems with // the inventory and conversation icons. if ((_features & GF_AFTER_V7 || _gameId == GID_SAMNMAX) && getClass(od->obj_nr, 22)) - flags |= Gdi::dbDrawMaskOnBoth; + flags |= Gdi::dbDrawMaskOnAll; gdi.drawBitmap(ptr, _curVirtScreen, x, ypos, height, x - xpos, numstrip, flags); } } -- cgit v1.2.3