[Scummvm-cvs-logs] CVS: scummvm/scumm akos.cpp,1.3,1.4 imuse.cpp,1.35,1.36 script_v2.cpp,1.20,1.21 scumm.h,1.34,1.35 string.cpp,1.24,1.25

James Brown ender at users.sourceforge.net
Sat Oct 5 23:10:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory usw-pr-cvs1:/tmp/cvs-serv22224/scumm

Modified Files:
	akos.cpp imuse.cpp script_v2.cpp scumm.h string.cpp 
Log Message:
Full Throttle / The Dig fixes.

drawDescString (for Full Throttle object names, in the 'ring of fire') is
still somewhat broken. Feel free to fix ;)



Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- akos.cpp	21 Sep 2002 23:39:09 -0000	1.3
+++ akos.cpp	6 Oct 2002 06:09:32 -0000	1.4
@@ -860,60 +860,136 @@
 void AkosRenderer::codec5()
 {
 	VirtScreen *vs;
-	BompDrawData bdd;
 
-	int moveX;
-	int moveY;
-	int left;
-	int var_20;
-	int max_width;
+	int left, right, top, bottom;
 
-	int right;
-	int top;
-	int bottom;
+	byte *src, *dest;
+	int src_x, src_y;
+	uint dst_x, dst_y;
 
+	bool masking;
+	byte maskbit;
+	const byte *mask = NULL;
+
+	// I don't know if this is complete. It used to simply call drawBomp()
+	// to draw an unscaled image, but I don't know if that was because it
+	// will never have to scale, or if it's because until quite recently
+	// drawBomp() didn't know how to scale images.
+	//
+	// What I do know is that drawBomp() doesn't care about masking and
+	// shadows, and these are both needed for Full Throttle.
+	
 	vs = &_vm->virtscr[0];
-	//setBlastObjectMode(shadow_mode); // not implemented yet
-	moveX = move_x_cur;
-	moveY = move_y_cur;
 
 	if (!mirror) {
-		left = (x - moveX - width) + 1;
+		left = (x - move_x_cur - width) + 1;
 	} else {
-		left = x + moveX - 1;
+		left = x + move_x_cur - 1;
 	}
 
-	var_20 = 0;
-	max_width = outwidth;
-
-	right = left + width - 1;
-	top = y + moveY;
-	bottom = top + height;
+	right = left + width;
+	top = y + move_y_cur;
+	bottom = top + height + 1;
 
 	if (left < 0)
 		left = 0;
-	if (left > max_width)
-		left -= left - max_width;
+	if (left > (int) outwidth)
+		left -= left - outwidth;
 
-	// Yazoo: this is not correct, but fix a lots of bugs for the momment
+	if (top < draw_top)
+		draw_top = top;
+	if (bottom > draw_bottom)
+		draw_bottom = bottom;
 
-	draw_top = 0;
-	draw_bottom = vs->height;
+	_vm->updateDirtyRect(0, left, right, top, bottom, 1 << dirty_id);
 
-	_vm->updateDirtyRect(0, left, right + 1, top, bottom + 1, 1 << dirty_id);
+	masking = false;
+	if (clipping) {
+		masking = _vm->isMaskActiveAt(left, top, right, bottom,
+			_vm->getResourceAddress(rtBuffer, 9) +
+			_vm->gdi._imgBufOffs[clipping] +
+			_vm->_screenStartStrip) != 0;
+	}
 
-	bdd.dataptr = srcptr;
-	bdd.out = outptr;
-	bdd.outheight = outheight;
-	bdd.outwidth = outwidth;
-	bdd.scale_x = 0xFF;
-	bdd.scale_y = 0xFF;
-	bdd.srcheight = height;
-	bdd.srcwidth = width;
-	bdd.x = left + 1;
-	bdd.y = top;
+	v1.mask_ptr = NULL;
 
-	_vm->drawBomp(&bdd, 0, bdd.dataptr, 0, 0);
+	if (masking || charsetmask || shadow_mode) {
+		v1.mask_ptr = _vm->getResourceAddress(rtBuffer, 9) +
+			top * 40 + _vm->_screenStartStrip;
+		v1.imgbufoffs = _vm->gdi._imgBufOffs[clipping];
+		if (!charsetmask && masking) {
+			v1.mask_ptr += v1.imgbufoffs;
+			v1.imgbufoffs = 0;
+		}
+	}
+
+	src = srcptr;
+	dest = outptr + top * outwidth + left + 1;
+
+	for (src_y = 0, dst_y = top; src_y < height; src_y++) {
+		byte code, color;
+		uint len, num, i;
+		byte *d = dest;
+
+		if (dst_y < 0 || dst_y >= outheight) {
+			src += READ_LE_UINT16(src) + 2;
+			mask += 40;
+			continue;
+		}
+
+		len = width;
+		src_x = 0;
+		dst_x = left + 1;
+		src += 2;
+
+		while (src_x <width) {
+			code = *src++;
+			num = (code >> 1) + 1;
+			if (num > len)
+				num = len;
+			len -= num;
+			if (code & 1) {
+				color = *src++;
+				for (i = 0; i < num; i++) {
+					if (dst_x >= 0 && dst_x < outwidth) {
+						if (color != 255) {
+							if (v1.mask_ptr)
+								mask = v1.mask_ptr + (dst_x >> 3);
+							maskbit = revBitMask[dst_x & 7];
+							if (shadow_mode && color == 13)
+								color = shadow_table[*d];
+							if (!mask || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))
+								*d = color;
+						}
+					}
+					d++;
+					dst_x++;
+					src_x++;
+				}
+			} else {
+				for (i = 0; i < num; i++) {
+					color = src[i];
+					if (dst_x >= 0 && dst_x < outwidth) {
+						if (color != 255) {
+							if (v1.mask_ptr)
+								mask = v1.mask_ptr + (dst_x >> 3);
+							maskbit = revBitMask[dst_x & 7];
+							if (shadow_mode && color == 13)
+								color = shadow_table[*d];
+							if (!mask || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))
+								*d = color;
+						}
+					}
+					d++;
+					dst_x++;
+					src_x++;
+				}
+				src += num;
+			}
+		}
+		dest += outwidth;
+		dst_y++;
+	}
 }
 
 void AkosRenderer::codec16()

Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- imuse.cpp	5 Oct 2002 20:36:49 -0000	1.35
+++ imuse.cpp	6 Oct 2002 06:09:32 -0000	1.36
@@ -4855,7 +4855,7 @@
 
 void IMuseDigital::handler() {
 	bool new_mixer;
-	uint32 l, i, idx = 0;
+	uint32 l = 0, i = 0;
 
 	for (l = 0; l < MAX_DIGITAL_CHANNELS;l ++) {
 		if (_channel[l]._used) {
@@ -4901,6 +4901,11 @@
 			}
 
 			byte *buf = (byte*)malloc(mixer_size);
+			if (!buf) {
+				warning("DigitalMixer exploded: Blame Aquadran :)");
+				continue;
+			}
+			
 			memcpy(buf, _channel[l]._data + _channel[l]._offset, new_size);
 			if ((new_size != _channel[l]._mixerSize) && (_channel[l]._isJump == true)) {
 				memcpy(buf + new_size, _channel[l]._data + _channel[l]._jump[0]._dest, mixer_size - new_size);

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- script_v2.cpp	1 Oct 2002 21:19:08 -0000	1.20
+++ script_v2.cpp	6 Oct 2002 06:09:32 -0000	1.21
@@ -2535,9 +2535,16 @@
 	_messagePtr = _scriptPointer;
 
 	if ((_gameId == GID_DIG) && (_messagePtr[0] == '/')) {
-		_scriptPointer += strlen((char*)_scriptPointer) + 1;
+		char pointer[20];
+		int i, j;
+
+		_scriptPointer += resStrLen((char*)_scriptPointer)+ 1;
 		translateText((char*)_messagePtr, (char*)&transText);
-		char *pointer = strtok((char *)_messagePtr, "/");
+		for (i = 0, j = 0; (_messagePtr[i] != '/' || j == 0) && j < 19; i++) {
+			if (_messagePtr[i] != '/')
+				pointer[j++] = _messagePtr[i];
+		}
+		pointer[j] = 0;
 		_sound->playBundleSound(pointer);
 		_messagePtr = (byte*)&transText;
 		setStringVars(0);
@@ -2555,9 +2562,16 @@
 	_messagePtr = _scriptPointer;
 
 	if ((_gameId == GID_DIG) && (_messagePtr[0] == '/')) {
-		_scriptPointer += strlen((char*)_scriptPointer) + 1;
+		char pointer[20];
+		int i, j;
+
+		_scriptPointer += resStrLen((char*)_scriptPointer) + 1;
 		translateText((char*)_messagePtr, (char*)&transText);
-		char *pointer = strtok((char *)_messagePtr, "/");
+		for (i = 0, j = 0; (_messagePtr[i] != '/' || j == 0) && j < 19; i++) {
+			if (_messagePtr[i] != '/')
+				pointer[j++] = _messagePtr[i];
+		}
+		pointer[j] = 0;
 		_sound->playBundleSound(pointer);
 		_messagePtr = (byte*)&transText;
 		setStringVars(0);
@@ -2722,6 +2736,8 @@
 	 				speed = 71;
 				else
 					speed = 1000 / _insaneFlag;
+				if (args[1] == 1) printf("startSmush one is true\n");
+				if (args[2] == 1) printf("startSmush two is true\n");
 				ScummRenderer * sr = new ScummRenderer(this, speed);
  				SmushPlayer * sp = new SmushPlayer(sr);
  				sp->play((char*)getStringAddressVar(VAR_VIDEONAME), getGameDataPath());
@@ -2763,6 +2779,16 @@
 					strcpy((char*)&charset._buffer, (char*)&buf + 13);
 					description();
 				}
+			} else { 
+				setStringVars(0);
+
+                		_string[0].charset = args[1];
+                		_string[0].color = args[2];
+                		_string[0].xpos = args[3];
+                		_string[0].ypos = args[4];
+
+				addMessageToStack(getStringAddressVar(VAR_STRING2DRAW));
+				drawDescString();
 			}
 			break;
 		case 17:
@@ -3104,7 +3130,7 @@
 			if ((_messagePtr[0] == '/') && (_gameId == GID_DIG)) {
 				translateText((char*)_messagePtr, (char*)&transText);
 				_messagePtr = (byte*)&transText;
-				_scriptPointer += strlen((char*)_scriptPointer) + 1;
+				_scriptPointer += resStrLen((char*)_scriptPointer) + 1;
 				switch (m) {
 				case 0:
 					actorTalk();

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- scumm.h	1 Oct 2002 09:27:09 -0000	1.34
+++ scumm.h	6 Oct 2002 06:09:32 -0000	1.35
@@ -939,6 +939,7 @@
 	int hasCharsetMask(int x, int y, int x2, int y2);
 	void CHARSET_1();
 	void description();
+	void drawDescString();
 	byte *_msgPtrToAdd;
 	byte *addMessageToStack(byte *msg);
 	void addIntToStack(int var);

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- string.cpp	3 Oct 2002 07:38:03 -0000	1.24
+++ string.cpp	6 Oct 2002 06:09:32 -0000	1.25
@@ -504,6 +504,77 @@
 	gdi._mask_bottom = charset._strBottom;
 }
 
+void Scumm::drawDescString()
+{
+	byte byte1=0, chr, *buf, *charsetptr;
+	uint color, i;
+
+	buf = charset._buffer;
+	charset._bufPos = 0;
+
+	charset._left2 = charset._left = _string[0].xpos;
+	charset._top = _string[0].ypos;
+	charset._curId = _string[0].charset;
+	charset._center = _string[0].center;
+	charset._right = _string[0].right;
+	charset._color = _string[0].color;
+
+	charset._xpos2 = _string[0].xpos;
+	charset._ypos2 = _string[0].ypos;
+	charset._disableOffsX = charset._unk12 = 1;
+	_bkColor = 0;
+	_talkDelay = 1;
+
+	charset._left -= charset.getStringWidth(0, buf, 0) >> 1;
+
+	restoreCharsetBg();
+
+	// Read color mapping and height information
+	charsetptr = getResourceAddress(rtCharset, charset._curId);
+	assert(charsetptr);
+	charsetptr += 29;
+	for (i = 0; i < 4; i++)
+			charset._colorMap[i] = _charsetData[charset._curId][i];
+
+	byte1 = charsetptr[1]; // Character height
+
+	for (i = 0; (chr = buf[i++]) != 0;) {
+		if (chr == 254)
+			chr = 255;
+		if (chr == 255) {
+			chr = buf[i++];
+			switch (chr) {
+			case 9:
+			case 10:
+			case 13:
+			case 14:
+				i += 2;
+				break;
+			case 1:
+			case 8:
+				charset._left = charset._left2 - charset.getStringWidth(0, buf, i);
+				charset._top += byte1;
+				break;
+			case 12:
+				color = buf[i] + (buf[i + 1] << 8);
+				i += 2;
+				if (color == 0xFF)
+					charset._color = _string[0].color;
+				else
+					charset._color = color;
+				break;
+			}
+		} else {
+				charset.printChar(chr);
+		}
+	}
+
+	gdi._mask_left = charset._strLeft;
+	gdi._mask_right = charset._strRight;
+	gdi._mask_top = charset._strTop;
+	gdi._mask_bottom = charset._strBottom;
+}
+
 void Scumm::drawString(int a)
 {
 	byte buf[256];
@@ -559,6 +630,10 @@
 	if (charset._center) {
 		charset._left -= charset.getStringWidth(a, buf, 0) >> 1;
 	}
+
+	if (!_features & GF_AFTER_V7)
+		charset._ignoreCharsetMask = 1;
+
 
 	// Verb text should never time out.
 	if (a == 4)





More information about the Scummvm-git-logs mailing list