diff options
author | Max Horn | 2002-12-30 13:15:08 +0000 |
---|---|---|
committer | Max Horn | 2002-12-30 13:15:08 +0000 |
commit | f5b8b9adcf837874a0109c685a4bb09978677f13 (patch) | |
tree | 4edcb5ab024be246293128ef98e9bd2e1405512b | |
parent | d51b4438141e21fcc76556f88985b805fc9ba67a (diff) | |
download | scummvm-rg350-f5b8b9adcf837874a0109c685a4bb09978677f13.tar.gz scummvm-rg350-f5b8b9adcf837874a0109c685a4bb09978677f13.tar.bz2 scummvm-rg350-f5b8b9adcf837874a0109c685a4bb09978677f13.zip |
load z-planes correctly for V8; however, there is still something slightly broken (visible at the cannon which is only drawn partly)
svn-id: r6275
-rw-r--r-- | scumm/gfx.cpp | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 908cd3ea65..fb596f9cd5 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -810,9 +810,6 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, const int h, assert(smap_ptr); - if (_vm->_features & GF_AFTER_V8) - smap_ptr += 24; - numzbuf = _disable_zbuffer ? 0 : _numZBuffer; if (_vm->_features & GF_SMALL_HEADER) { @@ -834,14 +831,31 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, const int h, } else { zplane_list[1] = 0; } + } else if (_vm->_features & GF_AFTER_V8) { + // Find the OFFS chunk of the ZPLN chunk + byte *zplnOffsChunkStart = smap_ptr + READ_BE_UINT32(smap_ptr + 12) + 24; + + // Each ZPLN contains a WRAP chunk, which has (as always) an OFFS subchunk pointing + // at ZSTR chunks. These once more contain a WRAP chunk which contains nothing but + // and OFFS chunk. The content of this OFFS chunk contains the offsets to the + // Z-planes. + // We do not directly make use of this, but rather hard code offsets (like we do + // for all other Scumm-versions, too). Clearly this is a bit hackish, but works + // well enough, and there is no reason to assume that there are any cases where it + // might fail. Still, doing this properly would have the advantage of catching + // invalid/damaged data files, and allow us to exit gracefully instead of segfaulting. + for (i = 1; i < numzbuf; i++) { + zplane_list[i] = zplnOffsChunkStart + READ_LE_UINT32(zplnOffsChunkStart + 4 + i*4) + 12; + } + + // A small hack to skip to the BSTR->WRAP->OFFS chunk + smap_ptr += 24; } else { for (i = 1; i < numzbuf; i++) { zplane_list[i] = findResource(zplane_tags[i], ptr); } } - - bottom = y + h; if (bottom > vs->height) { warning("Gdi::drawBitmap, strip drawn to %d below window bottom %d", bottom, vs->height); @@ -913,7 +927,11 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, const int h, // are still too unstable for me to investigate. if (flag & dbDrawMaskOnAll) { - byte *z_plane_ptr = zplane_list[1] + READ_LE_UINT16(zplane_list[1] + stripnr * 2 + 8); + byte *z_plane_ptr; + if (_vm->_features & GF_AFTER_V8) + z_plane_ptr = zplane_list[1] + READ_LE_UINT32(zplane_list[1] + stripnr * 4 + 8); + else + 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 * _numStrips + x + _imgBufOffs[i]; if (_useOrDecompress && flag & dbAllowMaskOr) @@ -933,7 +951,9 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, const int h, offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 4); else offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 2); - } else + } else if (_vm->_features & GF_AFTER_V8) + offs = READ_LE_UINT32(zplane_list[i] + stripnr * 4 + 8); + else offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 8); _mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y * _numStrips + x + _imgBufOffs[i]; @@ -1711,10 +1731,7 @@ void Scumm::setCameraAt(int pos_x, int pos_y) && _vars[VAR_SCROLL_SCRIPT]) { _vars[VAR_CAMERA_POS_X] = camera._cur.x; _vars[VAR_CAMERA_POS_Y] = camera._cur.y; - // FIXME - HACK - for now disable scroll script in V8, until we figure out - // what value VAR_SCROLL_SCRIPT has. - if (!(_features & GF_AFTER_V8)) - runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0); + runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0); } } else { int t; |