[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,1.97,1.98

Max Horn fingolfin at users.sourceforge.net
Mon Dec 30 05:16:02 CET 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv15765

Modified Files:
	gfx.cpp 
Log Message:
load z-planes correctly for V8; however, there is still something slightly broken (visible at the cannon which is only drawn partly)

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- gfx.cpp	27 Dec 2002 14:04:25 -0000	1.97
+++ gfx.cpp	30 Dec 2002 13:15:08 -0000	1.98
@@ -810,9 +810,6 @@
 
 	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 @@
 		} 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 @@
 		// 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 @@
 						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 @@
 				&& _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;





More information about the Scummvm-git-logs mailing list