[Scummvm-cvs-logs] CVS: scummvm/scumm scumm.h,1.232,1.233 bomp.cpp,2.4,2.5 akos.cpp,1.74,1.75 object.cpp,1.114,1.115 bomp.h,2.2,2.3 akos.h,1.21,1.22

Max Horn fingolfin at users.sourceforge.net
Sun Jun 1 06:10:09 CEST 2003


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

Modified Files:
	scumm.h bomp.cpp akos.cpp object.cpp bomp.h akos.h 
Log Message:
cleanup / added comments / code unification

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.232
retrieving revision 1.233
diff -u -d -r1.232 -r1.233
--- scumm.h	31 May 2003 12:17:57 -0000	1.232
+++ scumm.h	1 Jun 2003 13:09:28 -0000	1.233
@@ -897,7 +897,7 @@
 	// bomp
 public:
 	byte *_bompActorPalettePtr;
-	void drawBomp(const BompDrawData &bd, int decode_mode, int mask);
+	void drawBomp(const BompDrawData &bd, bool mirror);
 
 protected:
 	bool _shakeEnabled;

Index: bomp.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/bomp.cpp,v
retrieving revision 2.4
retrieving revision 2.5
diff -u -d -r2.4 -r2.5
--- bomp.cpp	1 Jun 2003 02:07:23 -0000	2.4
+++ bomp.cpp	1 Jun 2003 13:09:29 -0000	2.5
@@ -28,7 +28,6 @@
 
 static void bompDecodeLineReverse(byte *dst, const byte *src, int size);
 
-static void bompApplyMask(byte *line_buffer, byte *mask_out, byte maskbit, int32 size);
 static void bompApplyShadow0(const byte *line_buffer, byte *dst, int32 size, byte transparency);
 static void bompApplyShadow1(const byte *shadowPalette, const byte *line_buffer, byte *dst, int32 size, byte transparency);
 static void bompApplyShadow3(const byte *shadowPalette, const byte *line_buffer, byte *dst, int32 size, byte transparency);
@@ -97,13 +96,13 @@
 	}
 }
 
-void bompApplyMask(byte *line_buffer, byte *mask, byte maskbit, int32 size) {
+void bompApplyMask(byte *line_buffer, byte *mask, byte maskbit, int32 size, byte transparency) {
 	while(1) {
 		do {
 			if (size-- == 0) 
 				return;
 			if (*mask & maskbit) {
-				*line_buffer = 255;
+				*line_buffer = transparency;
 			}
 			line_buffer++;
 			maskbit >>= 1;
@@ -176,35 +175,37 @@
 }
 
 void bompScaleFuncX(byte *line_buffer, byte *scaling_x_ptr, byte skip, int32 size) {
-	byte * line_ptr1 = line_buffer;
-	byte * line_ptr2 = line_buffer;
+	byte *line_ptr1 = line_buffer;
+	byte *line_ptr2 = line_buffer;
 
-	byte tmp = *(scaling_x_ptr++);
+	byte tmp = *scaling_x_ptr++;
 
 	while (size--) {
 		if ((skip & tmp) == 0) {
-			*(line_ptr1++) = *(line_ptr2);
+			*line_ptr1++ = *line_ptr2;
 		}
 		line_ptr2++;
 		skip >>= 1;
 		if (skip == 0) {
 			skip = 128;
-			tmp = *(scaling_x_ptr++);
+			tmp = *scaling_x_ptr++;
 		}
 	}
 }
 
-void Scumm::drawBomp(const BompDrawData &bd, int decode_mode, int mask) {
-	byte skip_y = 128;
-	byte skip_y_new = 0;
-	byte maskbit;
-	byte *mask_out = 0;
-	byte *charset_mask;
-	byte tmp;
+void Scumm::drawBomp(const BompDrawData &bd, bool mirror) {
 	const byte *src;
 	byte *dst;
-	int32 clip_left, clip_right, clip_top, clip_bottom, tmp_x, tmp_y, mask_offset;
+	byte maskbit;
+	byte *mask = 0;
+	int mask_offset;
+	byte *charset_mask;
+	int clip_left, clip_right, clip_top, clip_bottom;
 	byte *scalingYPtr = bd.scalingYPtr;
+	byte skip_y_bits = 0x80;
+	byte skip_y_new = 0;
+	byte tmp;
+
 
 	if (bd.x < 0) {
 		clip_left = -bd.x;
@@ -219,44 +220,50 @@
 	}
 
 	clip_right = bd.srcwidth;
-	tmp_x = bd.x + bd.srcwidth;
-	if (tmp_x > bd.outwidth) {
-		clip_right -= tmp_x - bd.outwidth;
+	if (clip_right > bd.outwidth - bd.x) {
+		clip_right = bd.outwidth - bd.x;
 	}
 
 	clip_bottom = bd.srcheight;
-	tmp_y = bd.y + bd.srcheight;
-	if (tmp_y > bd.outheight) {
-		clip_bottom -= tmp_y - bd.outheight;
+	if (clip_bottom > bd.outheight - bd.y) {
+		clip_bottom = bd.outheight - bd.y;
 	}
 
 	src = bd.dataptr;
 	dst = bd.out + bd.y * bd.outwidth + bd.x + clip_left;
 
 	mask_offset = _screenStartStrip + (bd.y * gdi._numStrips) + ((bd.x + clip_left) >> 3);
+	maskbit = revBitMask[(bd.x + clip_left) & 7];
 
+	// Always mask against the charset mask
 	charset_mask = getResourceAddress(rtBuffer, 9) + mask_offset;
-	maskbit = revBitMask[(bd.x + clip_left) & 7];
 
-	if (mask == 1) {
-		mask_out = bd.maskPtr + mask_offset;
+	// Also mask against any additionally imposed mask
+	if (bd.maskPtr) {
+		mask = bd.maskPtr + mask_offset;
 	}
 
-	if (mask == 3) {
-		if (scalingYPtr != NULL) {
-			skip_y_new = *(scalingYPtr++);
-		}
+	// Setup vertical scaling
+	if (bd.scale_y != 255) {
+		assert(scalingYPtr);
 
-		if (clip_right > bd.scaleRight) {
-			clip_right = bd.scaleRight;
-		}
+		skip_y_new = *scalingYPtr++;
+		skip_y_bits = 0x80;
 
 		if (clip_bottom > bd.scaleBottom) {
 			clip_bottom = bd.scaleBottom;
 		}
 	}
 
-	int width = clip_right - clip_left;
+	// Setup horizontal scaling
+	if (bd.scale_x != 255) {
+		assert(bd.scalingXPtr);
+		if (clip_right > bd.scaleRight) {
+			clip_right = bd.scaleRight;
+		}
+	}
+
+	const int width = clip_right - clip_left;
 
 	if (width <= 0)
 		return;
@@ -266,58 +273,59 @@
 
 	byte *line_ptr = line_buffer + clip_left;
 
+	// Loop over all lines
 	while (pos_y < clip_bottom) {
-		switch(decode_mode) {
-		case 0:
-			memcpy(line_buffer, src, bd.srcwidth);
-			src += bd.srcwidth;
-			break;
-		case 1:
-			bompDecodeLine(line_buffer, src + 2, bd.srcwidth);
-			src += READ_LE_UINT16(src) + 2;
-			break;
-		case 3:
+		// Decode a single (bomp encoded) line, reversed if we are in mirror mode
+		if (mirror)
 			bompDecodeLineReverse(line_buffer, src + 2, bd.srcwidth);
-			src += READ_LE_UINT16(src) + 2;
-			break;
-		default:
-			error("Unknown bomp decode_mode %d", decode_mode);
-		}
-
-		if (mask == 3) {
-			if (bd.scale_y != 255) {
-				tmp = skip_y_new & skip_y;
-				skip_y >>= 1;
-				if (skip_y == 0) {
-					skip_y = 128;
-					skip_y_new = *(scalingYPtr++);
-				}
+		else
+			bompDecodeLine(line_buffer, src + 2, bd.srcwidth);
+		src += READ_LE_UINT16(src) + 2;
 
-				if (tmp != 0) 
-					continue;
+		// If vertical scaling is enabled, do it
+		if (bd.scale_y != 255) {
+			// A bit set means we should skip this line...
+			tmp = skip_y_new & skip_y_bits;
+			
+			// Advance the scale-skip bit mask, if it's 0, get the next scale-skip byte
+			skip_y_bits >>= 1;
+			if (skip_y_bits == 0) {
+				skip_y_bits = 0x80;
+				skip_y_new = *scalingYPtr++;
 			}
 
-			if (bd.scale_x != 255) {
-				bompScaleFuncX(line_buffer, bd.scalingXPtr, 128, bd.srcwidth);
-			}
+			// Skip the current line if the above check tells us to
+			if (tmp != 0) 
+				continue;
 		}
 
+		// Perform horizontal scaling
+		if (bd.scale_x != 255) {
+			bompScaleFuncX(line_buffer, bd.scalingXPtr, 0x80, bd.srcwidth);
+		}
+
+		// The first clip_top lines are to be clipped, i.e. not drawn
 		if (clip_top > 0) {
 			clip_top--;
 		} else {
-
-			if (mask == 1) {
-				bompApplyMask(line_ptr, mask_out, maskbit, width);
-			}
+			// Replace the parts of the line which are masked with the transparency color
+			if (bd.maskPtr)
+				bompApplyMask(line_ptr, mask, maskbit, width, 255);
+			bompApplyMask(line_ptr, charset_mask, maskbit, width, 255);
 	
-			bompApplyMask(line_ptr, charset_mask, maskbit, width);
-			bompApplyActorPalette(_bompActorPalettePtr, line_ptr, width);
+			// Apply custom color map, if available
+			if (_bompActorPalettePtr)
+				bompApplyActorPalette(_bompActorPalettePtr, line_ptr, width);
+			
+			// Finally, draw the decoded, scaled, masked and recolored line onto
+			// the target surface, using the specified shadow mode
 			bompApplyShadow(bd.shadowMode, _shadowPalette, line_ptr, dst, width, 255);
 		}
 
-		mask_out += gdi._numStrips;
-		charset_mask += gdi._numStrips;
+		// Advance to the next line
 		pos_y++;
+		mask += gdi._numStrips;
+		charset_mask += gdi._numStrips;
 		dst += bd.outwidth;
 	}
 }

Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- akos.cpp	1 Jun 2003 01:00:44 -0000	1.74
+++ akos.cpp	1 Jun 2003 13:09:29 -0000	1.75
@@ -769,23 +769,18 @@
 	bdd.scaleRight = 0;
 	bdd.scaleBottom = 0;
 
-	int decode_mode;
-
 	if (!_mirror) {
 		bdd.x = (_actorX - xmoveCur - _width) + 1;
-		decode_mode = 3;
 	} else {
 		bdd.x = _actorX + xmoveCur;
-		decode_mode = 1;
 	}
-
 	bdd.y = _actorY + ymoveCur;
 
 	if (_zbuf != 0) {
 		bdd.maskPtr = _vm->getResourceAddress(rtBuffer, 9) + _vm->gdi._imgBufOffs[_zbuf];
-		_vm->drawBomp(bdd, decode_mode, 1);
+		_vm->drawBomp(bdd, !_mirror);
 	} else {
-		_vm->drawBomp(bdd, decode_mode, 0);
+		_vm->drawBomp(bdd, !_mirror);
 	}
 
 	_vm->_bompActorPalettePtr = NULL;
@@ -862,28 +857,6 @@
 	}
 }
 
-void AkosRenderer::akos16ApplyMask(byte *dest, byte *maskptr, byte bits, int32 count, byte fillwith) {
-	byte bitpos = 1 << (7 - bits);
-
-	if (count <= 0)
-		return;
-
-	while(1) {
-		byte tmp = *(maskptr++);
-		do {
-			if (tmp & bitpos) {
-				*(dest) = fillwith;
-			}
-			dest++;
-
-			if (--count == 0)
-				return;
-		} while ((bitpos>>=1) != 0);
-
-		bitpos = 0x80;
-	}
-}
-
 void AkosRenderer::akos16Decompress(byte *dest, int32 pitch, const byte *src, int32 t_width, int32 t_height, int32 dir, int32 numskip_before, int32 numskip_after, byte transparency) {
 	byte *tmp_buf = akos16.buffer;
 
@@ -932,7 +905,7 @@
 	assert(t_width > 0);
 	while (t_height--) {
 		akos16DecodeLine(tmp_buf, t_width, dir);
-		akos16ApplyMask(akos16.buffer, maskptr, (byte)bitpos_start, t_width, transparency);
+		bompApplyMask(akos16.buffer, maskptr, (byte)bitpos_start, t_width, transparency);
 		bompApplyShadow(_shadow_mode, _shadow_table, akos16.buffer, dest, t_width, transparency);
 
 		if (numskip_after != 0)	{

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- object.cpp	31 May 2003 12:17:57 -0000	1.114
+++ object.cpp	1 Jun 2003 13:09:30 -0000	1.115
@@ -1505,10 +1505,14 @@
 		bdd.scaleRight = setupBompScale(bomp_scaling_x, bdd.srcwidth, bdd.scale_x);
 		bdd.scaleBottom = setupBompScale(bomp_scaling_y, bdd.srcheight, bdd.scale_y);
 		bdd.shadowMode = 0;
-		drawBomp(bdd, 1, 3);
+		drawBomp(bdd, false);
 	} else {
+		bdd.scalingXPtr = NULL;
+		bdd.scalingYPtr = NULL;
+		bdd.scaleRight = 0;
+		bdd.scaleBottom = 0;
 		bdd.shadowMode = eo->mode;
-		drawBomp(bdd, 1, 0);
+		drawBomp(bdd, false);
 	}
 
 	updateDirtyRect(vs->number, bdd.x, bdd.x + bdd.srcwidth, bdd.y, bdd.y + bdd.srcheight, 0);

Index: bomp.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/bomp.h,v
retrieving revision 2.2
retrieving revision 2.3
diff -u -d -r2.2 -r2.3
--- bomp.h	30 May 2003 20:13:27 -0000	2.2
+++ bomp.h	1 Jun 2003 13:09:30 -0000	2.3
@@ -23,7 +23,10 @@
 #define BOMP_H
 
 int32 setupBompScale(byte *scaling, int32 size, byte scale);
+
+void bompApplyMask(byte *line_buffer, byte *mask, byte maskbit, int32 size, byte transparency);
 void bompApplyShadow(int shadowMode, const byte *shadowPalette, const byte *line_buffer, byte *dst, int32 size, byte transparency);
+
 void decompressBomp(byte *dst, const byte *src, int w, int h);
 void bompDecodeLine(byte *dst, const byte *src, int size);
 

Index: akos.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- akos.h	30 May 2003 17:52:16 -0000	1.21
+++ akos.h	1 Jun 2003 13:09:30 -0000	1.22
@@ -83,7 +83,6 @@
 	void akos16SetupBitReader(const byte *src);
 	void akos16SkipData(int32 numskip);
 	void akos16DecodeLine(byte *buf, int32 numbytes, int32 dir);
-	void akos16ApplyMask(byte *dest, byte *maskptr, byte bits, int32 count, byte fillwith);
 	void akos16Decompress(byte *dest, int32 pitch, const byte *src, int32 t_width, int32 t_height, int32 dir, int32 numskip_before, int32 numskip_after, byte transparency);
 	void akos16DecompressMask(byte *dest, int32 pitch, const byte *src, int32 t_width, int32 t_height, int32 dir, int32 numskip_before, int32 numskip_after, byte transparency, byte *maskptr, int32 bitpos_start);
 };





More information about the Scummvm-git-logs mailing list