[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.15,2.16 gfx.h,1.19,1.20 saveload.cpp,1.40,1.41 scummvm.cpp,2.26,2.27 string.cpp,1.77,1.78

Max Horn fingolfin at users.sourceforge.net
Tue Dec 31 07:00:02 CET 2002


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

Modified Files:
	gfx.cpp gfx.h saveload.cpp scummvm.cpp string.cpp 
Log Message:
more cleanup

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.15
retrieving revision 2.16
diff -u -d -r2.15 -r2.16
--- gfx.cpp	31 Dec 2002 04:59:23 -0000	2.15
+++ gfx.cpp	31 Dec 2002 14:59:04 -0000	2.16
@@ -470,7 +470,6 @@
 
 	if (_features & GF_AFTER_V7) {
 		initVirtScreen(0, 0, virtscr[0].topline, _realWidth, height, 1, 1);
-
 	}
 
 	room = getResourceAddress(rtRoom, _roomResource);
@@ -499,7 +498,7 @@
 	assert(gdi._numZBuffer >= 1 && gdi._numZBuffer <= 8);
 
 	if (_features & GF_AFTER_V7)
-		itemsize = _scrHeight * gdi._numStrips + gdi._numStrips * 10;
+		itemsize = (_scrHeight + 10) * gdi._numStrips;
 	else
 		itemsize = (_scrHeight + 4) * gdi._numStrips;
 
@@ -790,6 +789,7 @@
 	int numzbuf;
 	int sx;
 	bool lightsOn;
+	bool useOrDecompress;
 
 	// Check whether lights are turned on or not
 	lightsOn = (_vm->_features & GF_AFTER_V6) || (vs->number != 0) || (_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_screen);
@@ -835,7 +835,7 @@
 		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 {
@@ -886,9 +886,9 @@
 		_mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + (y * _numStrips + x);
 
 		if (_vm->_features & GF_SMALL_HEADER)
-			decompressBitmap(bgbak_ptr, smap_ptr + READ_LE_UINT32(smap_ptr + stripnr * 4 + 4), h);
+			useOrDecompress = decompressBitmap(bgbak_ptr, smap_ptr + READ_LE_UINT32(smap_ptr + stripnr * 4 + 4), h);
 		else
-			decompressBitmap(bgbak_ptr, smap_ptr + READ_LE_UINT32(smap_ptr + stripnr * 4 + 8), h);
+			useOrDecompress = decompressBitmap(bgbak_ptr, smap_ptr + READ_LE_UINT32(smap_ptr + stripnr * 4 + 8), h);
 
 		CHECK_HEAP;
 		if (vs->alloctwobuffers) {
@@ -930,7 +930,7 @@
 				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)
+				if (useOrDecompress && (flag & dbAllowMaskOr))
 					decompressMaskImgOr(_mask_ptr_dest, z_plane_ptr, h);
 				else
 					decompressMaskImg(_mask_ptr_dest, z_plane_ptr, h);
@@ -956,13 +956,13 @@
 				if (offs) {
 					byte *z_plane_ptr = zplane_list[i] + offs;
 
-					if (_useOrDecompress && flag & dbAllowMaskOr) {
+					if (useOrDecompress && (flag & dbAllowMaskOr)) {
 						decompressMaskImgOr(_mask_ptr_dest, z_plane_ptr, h);
 					} else {
 						decompressMaskImg(_mask_ptr_dest, z_plane_ptr, h);
 					}
 				} else {
-					if (!(_useOrDecompress && flag & dbAllowMaskOr))
+					if (!(useOrDecompress && (flag & dbAllowMaskOr)))
 						for (int height = 0; height < h; height++)
 							_mask_ptr_dest[height * _numStrips] = 0;
 					/* needs better abstraction, FIXME */
@@ -978,7 +978,7 @@
 }
 
 
-void Gdi::decompressBitmap(byte *bgbak_ptr, byte *smap_ptr, int numLinesToProcess)
+bool Gdi::decompressBitmap(byte *bgbak_ptr, byte *smap_ptr, int numLinesToProcess)
 {
 	byte code = *smap_ptr++;
 	assert(numLinesToProcess);
@@ -988,16 +988,10 @@
 	else
 		_palette_mod = 0;
 
-	_useOrDecompress = false;
+	bool useOrDecompress = false;
 	_decomp_shr = code % 10;
 	_decomp_mask = 0xFF >> (8 - _decomp_shr);
 	
-	// Note that some of the decoders exist in pairs: one honors _transparency, the other not.
-	// The pairs are:
-	// unkDecode1 <-> unkDecode3
-	// unkDecode2 <-> unkDecode5
-	// unkDecode4 <-> unkDecode6
-
 	switch (code) {
 	case 1:
 		unkDecode7(bgbak_ptr, smap_ptr, numLinesToProcess);
@@ -1024,7 +1018,7 @@
 	case 16:
 	case 17:
 	case 18:
-		unkDecode6(bgbak_ptr, smap_ptr, numLinesToProcess);
+		unkDecodeC(bgbak_ptr, smap_ptr, numLinesToProcess);
 		break;
 
 	case 24:
@@ -1032,7 +1026,7 @@
 	case 26:
 	case 27:
 	case 28:
-		unkDecode5(bgbak_ptr, smap_ptr, numLinesToProcess);
+		unkDecodeB(bgbak_ptr, smap_ptr, numLinesToProcess);
 		break;
 
 	case 34:
@@ -1040,8 +1034,8 @@
 	case 36:
 	case 37:
 	case 38:
-		_useOrDecompress = true;
-		unkDecode4(bgbak_ptr, smap_ptr, numLinesToProcess);
+		useOrDecompress = true;
+		unkDecodeC_trans(bgbak_ptr, smap_ptr, numLinesToProcess);
 		break;
 
 	case 44:
@@ -1049,8 +1043,8 @@
 	case 46:
 	case 47:
 	case 48:
-		_useOrDecompress = true;
-		unkDecode2(bgbak_ptr, smap_ptr, numLinesToProcess);
+		useOrDecompress = true;
+		unkDecodeB_trans(bgbak_ptr, smap_ptr, numLinesToProcess);
 		break;
 
 	case 64:
@@ -1063,7 +1057,7 @@
 	case 106:
 	case 107:
 	case 108:
-		unkDecode1(bgbak_ptr, smap_ptr, numLinesToProcess);
+		unkDecodeA(bgbak_ptr, smap_ptr, numLinesToProcess);
 		break;
 
 	case 84:
@@ -1076,13 +1070,15 @@
 	case 126:
 	case 127:
 	case 128:
-		_useOrDecompress = true;
-		unkDecode3(bgbak_ptr, smap_ptr, numLinesToProcess);
+		useOrDecompress = true;
+		unkDecodeA_trans(bgbak_ptr, smap_ptr, numLinesToProcess);
 		break;
 
 	default:
 		error("Gdi::decompressBitmap: default case %d", code);
 	}
+	
+	return useOrDecompress;
 }
 
 void Gdi::draw8ColWithMasking(byte *dst, byte *src, int height, byte *mask)
@@ -1244,7 +1240,7 @@
 #define READ_BIT (cl--, bit = bits&1, bits>>=1,bit)
 #define FILL_BITS do { if (cl <= 8) { bits |= (*src++ << cl); cl += 8; }  } while (0)
 
-void Gdi::unkDecode1(byte *dst, byte *src, int height)
+void Gdi::unkDecodeA(byte *dst, byte *src, int height)
 {
 	byte color = *src++;
 	uint bits = *src++;
@@ -1293,40 +1289,7 @@
 	} while (--height);
 }
 
-void Gdi::unkDecode2(byte *dst, byte *src, int height)
-{
-	byte color = *src++;
-	uint bits = *src++;
-	byte cl = 8;
-	byte bit;
-	int8 inc = -1;
-
-	do {
-		int x = 8;
-		do {
-			FILL_BITS;
-			if (color != _transparency)
-				*dst = color + _palette_mod;
-			dst++;
-			if (!READ_BIT) {
-			} else if (!READ_BIT) {
-				FILL_BITS;
-				color = bits & _decomp_mask;
-				bits >>= _decomp_shr;
-				cl -= _decomp_shr;
-				inc = -1;
-			} else if (!READ_BIT) {
-				color += inc;
-			} else {
-				inc = -inc;
-				color += inc;
-			}
-		} while (--x);
-		dst += _vm->_realWidth - 8;
-	} while (--height);
-}
-
-void Gdi::unkDecode3(byte *dst, byte *src, int height)
+void Gdi::unkDecodeA_trans(byte *dst, byte *src, int height)
 {
 	byte color = *src++;
 	uint bits = *src++;
@@ -1338,7 +1301,7 @@
 		int x = 8;
 		do {
 			FILL_BITS;
-			if (color != _transparency)
+			if (color != _transparentColor)
 				*dst = color + _palette_mod;
 			dst++;
 
@@ -1365,7 +1328,7 @@
 							if (!--height)
 								return;
 						}
-						if (color != _transparency)
+						if (color != _transparentColor)
 							*dst = color + _palette_mod;
 						dst++;
 					} while (--reps);
@@ -1379,7 +1342,7 @@
 	} while (--height);
 }
 
-void Gdi::unkDecode4(byte *dst, byte *src, int height)
+void Gdi::unkDecodeB(byte *dst, byte *src, int height)
 {
 	byte color = *src++;
 	uint bits = *src++;
@@ -1387,14 +1350,11 @@
 	byte bit;
 	int8 inc = -1;
 
-	int x = 8;
 	do {
-		int h = height;
+		int x = 8;
 		do {
 			FILL_BITS;
-			if (color != _transparency)
-				*dst = color + _palette_mod;
-			dst += _vm->_realWidth;
+			*dst++ = color + _palette_mod;
 			if (!READ_BIT) {
 			} else if (!READ_BIT) {
 				FILL_BITS;
@@ -1408,12 +1368,12 @@
 				inc = -inc;
 				color += inc;
 			}
-		} while (--h);
-		dst -= _vertStripNextInc;
-	} while (--x);
+		} while (--x);
+		dst += _vm->_realWidth - 8;
+	} while (--height);
 }
 
-void Gdi::unkDecode5(byte *dst, byte *src, int height)
+void Gdi::unkDecodeB_trans(byte *dst, byte *src, int height)
 {
 	byte color = *src++;
 	uint bits = *src++;
@@ -1425,7 +1385,9 @@
 		int x = 8;
 		do {
 			FILL_BITS;
-			*dst++ = color + _palette_mod;
+			if (color != _transparentColor)
+				*dst = color + _palette_mod;
+			dst++;
 			if (!READ_BIT) {
 			} else if (!READ_BIT) {
 				FILL_BITS;
@@ -1444,7 +1406,7 @@
 	} while (--height);
 }
 
-void Gdi::unkDecode6(byte *dst, byte *src, int height)
+void Gdi::unkDecodeC(byte *dst, byte *src, int height)
 {
 	byte color = *src++;
 	uint bits = *src++;
@@ -1477,6 +1439,44 @@
 	} while (--x);
 }
 
+void Gdi::unkDecodeC_trans(byte *dst, byte *src, int height)
+{
+	byte color = *src++;
+	uint bits = *src++;
+	byte cl = 8;
+	byte bit;
+	int8 inc = -1;
+
+	int x = 8;
+	do {
+		int h = height;
+		do {
+			FILL_BITS;
+			if (color != _transparentColor)
+				*dst = color + _palette_mod;
+			dst += _vm->_realWidth;
+			if (!READ_BIT) {
+			} else if (!READ_BIT) {
+				FILL_BITS;
+				color = bits & _decomp_mask;
+				bits >>= _decomp_shr;
+				cl -= _decomp_shr;
+				inc = -1;
+			} else if (!READ_BIT) {
+				color += inc;
+			} else {
+				inc = -inc;
+				color += inc;
+			}
+		} while (--h);
+		dst -= _vertStripNextInc;
+	} while (--x);
+}
+
+#undef READ_BIT
+#undef FILL_BITS
+
+
 /* Ender - Zak256/Indy256 decoders */
 #define READ_256BIT \
  if ((mask <<= 1) == 256) {buffer = *src++;  mask = 1;}     \
@@ -1655,8 +1655,6 @@
 
 #undef NEXT_ROW
 #undef READ_256BIT
-#undef READ_BIT
-#undef FILL_BITS
 
 
 #pragma mark -
@@ -3209,7 +3207,7 @@
 			}
 			line_buffer++;
 			bits >>= 1;
-		} while	(bits != 0);
+		} while	(bits);
 		bits = 128;
 	}
 }
@@ -3324,7 +3322,7 @@
 void Scumm::drawBomp(BompDrawData * bd, int decode_mode, int mask) {
 	byte skip_y = 128;
 	byte skip_y_new = 0;
-	byte bits = 0;
+	byte bits;
 	byte *mask_out = 0;
 	byte *charset_mask;
 	byte tmp;
@@ -3423,31 +3421,32 @@
 			}
 		}
 
-		if (clip_top-- > 0)
-			goto labelBompSkip;
-
-		if (mask == 1) {
-			bompApplyMask(line_ptr, mask_out, bits, clip_right);
-		}
-
-		bompApplyMask(line_ptr, charset_mask, bits, clip_right);
-		bompApplyActorPalette(line_ptr, clip_right);
+		if (clip_top > 0) {
+			clip_top--;
+		} else {
 
-		switch(bd->shadowMode) {
-		case 0:
-			bompApplyShadow0(line_ptr, dst, clip_right);
-			break;
-		case 1:
-			bompApplyShadow1(line_ptr, dst, clip_right);
-			break;
-		case 3:
-			bompApplyShadow3(line_ptr, dst, clip_right);
-			break;
-		default:
-			error("Unknown bomp shadowMode %d", bd->shadowMode);
+			if (mask == 1) {
+				bompApplyMask(line_ptr, mask_out, bits, clip_right);
+			}
+	
+			bompApplyMask(line_ptr, charset_mask, bits, clip_right);
+			bompApplyActorPalette(line_ptr, clip_right);
+	
+			switch(bd->shadowMode) {
+			case 0:
+				bompApplyShadow0(line_ptr, dst, clip_right);
+				break;
+			case 1:
+				bompApplyShadow1(line_ptr, dst, clip_right);
+				break;
+			case 3:
+				bompApplyShadow3(line_ptr, dst, clip_right);
+				break;
+			default:
+				error("Unknown bomp shadowMode %d", bd->shadowMode);
+			}
 		}
 
-labelBompSkip:
 		mask_out += mask_pitch;
 		charset_mask += mask_pitch;
 		pos_y++;

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- gfx.h	31 Dec 2002 04:45:21 -0000	1.19
+++ gfx.h	31 Dec 2002 14:59:05 -0000	1.20
@@ -131,17 +131,18 @@
 
 	byte _palette_mod;
 	byte _decomp_shr, _decomp_mask;
-	byte _transparency;
+	byte _transparentColor;
 	uint32 _vertStripNextInc;
 
 	/* Bitmap decompressors */
-	void decompressBitmap(byte *bgbak_ptr, byte *smap_ptr, int numLinesToProcess);
-	void unkDecode1(byte *dst, byte *src, int height);
-	void unkDecode2(byte *dst, byte *src, int height);
-	void unkDecode3(byte *dst, byte *src, int height);
-	void unkDecode4(byte *dst, byte *src, int height);
-	void unkDecode5(byte *dst, byte *src, int height);
-	void unkDecode6(byte *dst, byte *src, int height);
+	bool decompressBitmap(byte *bgbak_ptr, byte *smap_ptr, int numLinesToProcess);
+	void unkDecodeA(byte *dst, byte *src, int height);
+	void unkDecodeA_trans(byte *dst, byte *src, int height);
+	void unkDecodeB(byte *dst, byte *src, int height);
+	void unkDecodeB_trans(byte *dst, byte *src, int height);
+	void unkDecodeC(byte *dst, byte *src, int height);
+	void unkDecodeC_trans(byte *dst, byte *src, int height);
+
 	void unkDecode7(byte *dst, byte *src, int height);
 	void unkDecode8(byte *dst, byte *src, int height);
 	void unkDecode9(byte *dst, byte *src, int height);

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- saveload.cpp	26 Dec 2002 20:37:48 -0000	1.40
+++ saveload.cpp	31 Dec 2002 14:59:05 -0000	1.41
@@ -425,7 +425,7 @@
 		MKARRAY_OLD(Scumm, gfxUsageBits[0], sleUint32, 200, VER_V8, VER_V9),
 		MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 410, VER_V10),
 
-		MKLINE(Scumm, gdi._transparency, sleByte, VER_V8),
+		MKLINE(Scumm, gdi._transparentColor, sleByte, VER_V8),
 		MKARRAY(Scumm, _currentPalette[0], sleByte, 768, VER_V8),
 
 		MKARRAY(Scumm, _proc_special_palette[0], sleByte, 256, VER_V8),

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.26
retrieving revision 2.27
diff -u -d -r2.26 -r2.27
--- scummvm.cpp	31 Dec 2002 04:19:10 -0000	2.26
+++ scummvm.cpp	31 Dec 2002 14:59:05 -0000	2.27
@@ -934,11 +934,11 @@
 
 	ptr = findResourceData(MKID('TRNS'), roomptr);
 	if (ptr)
-		gdi._transparency = ptr[0];
+		gdi._transparentColor = ptr[0];
 	else if (_features & GF_AFTER_V8)
-		gdi._transparency = 5;	// FIXME
+		gdi._transparentColor = 5;	// FIXME
 	else
-		gdi._transparency = 255;
+		gdi._transparentColor = 255;
 
 	initBGBuffers(_scrHeight);
 

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- string.cpp	29 Dec 2002 19:51:27 -0000	1.77
+++ string.cpp	31 Dec 2002 14:59:06 -0000	1.78
@@ -348,11 +348,11 @@
 void Scumm::description()
 {
 	int c;
-	byte *buffer;
+	byte *buf;
 
-	buffer = _charsetBuffer;
+	buf = _charsetBuffer;
 	_string[0].ypos = camera._cur.y + 88;
-	_string[0].xpos = (_realWidth / 2) - (_charset->getStringWidth(0, buffer) >> 1);
+	_string[0].xpos = (_realWidth / 2) - (_charset->getStringWidth(0, buf) >> 1);
 	if (_string[0].xpos < 0)
 		_string[0].xpos = 0;
 
@@ -373,7 +373,7 @@
 	restoreCharsetBg();
 
 	do {
-		c = *buffer++;
+		c = *buf++;
 		if (c == 0) {
 			_haveMsg = 1;
 			break;
@@ -554,7 +554,7 @@
 
 	if (_features & GF_AFTER_V7) {
 		_charset->_hasMask = true;
-		// FIXME - hos is supposed to ever work, since gdi._mask_left is by default set
+		// FIXME - how is this supposed to ever work, since gdi._mask_left is by default set
 		// to -1 to mark it as invalid. Hence this comparision will always leave it at -1,
 		// which implies that if the mask was marked invalid, it will always stay so. 
 		// That seems odd and not at all to be the intended thing... or is it?





More information about the Scummvm-git-logs mailing list