[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.150,2.151 script_v7he.cpp,2.5,2.6

Eugene Sandulenko sev at users.sourceforge.net
Mon Mar 1 20:32:03 CET 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26176

Modified Files:
	intern.h script_v7he.cpp 
Log Message:
Implemented more HE opcode stringLen and added stub for opcode F4


Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.150
retrieving revision 2.151
diff -u -d -r2.150 -r2.151
--- intern.h	2 Mar 2004 01:20:18 -0000	2.150
+++ intern.h	2 Mar 2004 04:11:57 -0000	2.151
@@ -616,6 +616,8 @@
 
 	virtual void decodeParseString(int a, int b);
 
+	byte stringLen(byte *);
+
 	/* Version 7 script opcodes */
 	void o7_objectX();
 	void o7_objectY();

Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.5
retrieving revision 2.6
diff -u -d -r2.5 -r2.6
--- script_v7he.cpp	2 Mar 2004 01:20:18 -0000	2.5
+++ script_v7he.cpp	2 Mar 2004 04:11:57 -0000	2.6
@@ -408,34 +408,118 @@
 
 void ScummEngine_v7he::o7_stringLen() {
 	int a, len;
+	byte *addr;
+
+	if (!(_features & GF_WINDOWS)) {
+		o6_invalid();
+		return;
+	}
 
 	a = pop();
 
+	addr = getStringAddress(a);
+	if (!addr) {
+		// FIXME: should be error here
+		warning("ScummEngine_v7he::o7_stringLen: Reference to zeroed array pointer (%d)", a);
+		push(0);
+		return;
+	}
+
 	if (_gameId == GID_FREDDEMO) {
 		len = strlen((char *)getStringAddress(a));
-	} else {
-		len = 0; // TODO: implement
+	} else { // FREDDI.w32, PUTTMOON.w32
+		len = stringLen(addr);
 	}
 	push(len);
 }
 
+byte ScummEngine_v7he::stringLen(byte *ptr) {
+	byte len;
+	byte c;
+	if (!ptr) {
+		//ptr = _someGlobalPtr;
+		error("ScummEngine_v7he::stringLen(): zero ptr. Undimplemented behaviour");
+		return 1;
+	}
+
+	len = 0;
+	c = *ptr++;
+
+	if (len == c)
+		return 1;
+
+	do {
+		len++;
+		if (c == 0xff) {
+			ptr += 3;
+			len += 3;
+		}
+		c = *ptr++;
+	} while (c);
+
+	return len+1;
+}
+
 void ScummEngine_v7he::o7_unknownF4() {
-	byte b;
-	int len;
-	b = fetchScriptByte();
+	if (!(_features & GF_WINDOWS)) {
+		o6_invalid();
+		return;
+	}
 
-	switch (b) {
-	case 6:
-		pop();
-		len = resStrLen(_scriptPointer);
-		_scriptPointer += len + 1;
-		break;
-	case 7:
-		len = resStrLen(_scriptPointer);
-		_scriptPointer += len + 1;
-		len = resStrLen(_scriptPointer);
-		_scriptPointer += len + 1;
-		break;
+	if (_gameId == GID_FREDDEMO) {
+		byte b;
+		int len;
+		b = fetchScriptByte();
+
+		switch (b) {
+		case 6:
+			pop();
+			len = resStrLen(_scriptPointer);
+			_scriptPointer += len + 1;
+			break;
+		case 7:
+			len = resStrLen(_scriptPointer);
+			_scriptPointer += len + 1;
+			len = resStrLen(_scriptPointer);
+			_scriptPointer += len + 1;
+			break;
+		}
+	} else { // FREDDI.w32, PUTTMOON.w32
+		int a, b;
+		byte filename1[256], filename2[256];
+		int len;
+
+		
+		b = pop();
+		a = pop();
+
+		switch (b) {
+		case 1:
+			_msgPtrToAdd = filename1;
+			_messagePtr = _scriptPointer;
+			addMessageToStack(_messagePtr);
+
+			len = resStrLen(_scriptPointer);
+			_scriptPointer += len + 1;
+			debug(0, "unknownF4(%d, %d, \"%s\")", a, b, _messagePtr);
+			break;
+		case 2:
+			_msgPtrToAdd = filename1;
+			_messagePtr = _scriptPointer;
+			addMessageToStack(_messagePtr);
+
+			len = resStrLen(_scriptPointer);
+			_scriptPointer += len + 1;
+
+			_msgPtrToAdd = filename2;
+			_messagePtr = _scriptPointer;
+			addMessageToStack(_messagePtr);
+
+			len = resStrLen(_scriptPointer);
+			_scriptPointer += len + 1;
+			debug(0, "unknownF4(%d, %d, \"%s\", \"%s\")", a, b, filename1, filename2);
+			break;
+		}
 	}
 	warning("o7_unknownF4 stub");
 }





More information about the Scummvm-git-logs mailing list