[Scummvm-git-logs] scummvm master -> e0510db9f78dd5284fb9bbfbafdc38059a35adfa

Die4Ever noreply at scummvm.org
Sun Dec 5 17:59:56 UTC 2021


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a19ecd94ee GROOVIE: refactor input loop
e0510db9f7 GROOVIE: couldn't find resource warning


Commit: a19ecd94ee0fe81a9f030a2e025da039fb94d101
    https://github.com/scummvm/scummvm/commit/a19ecd94ee0fe81a9f030a2e025da039fb94d101
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2021-12-05T11:59:25-06:00

Commit Message:
GROOVIE: refactor input loop

Some scripts, such as the boat puzzle in Clandestiny, were clearing variables right before the o_inputloopend instruction, which was causing a crash because we were deferring our input actions until then. This change means hotspots execute their actions immediately instead of deferring, this is how the old Win95 exe does it.

Changed paths:
    engines/groovie/script.cpp
    engines/groovie/script.h


diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index 09fab52781..523f2cb907 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -230,7 +230,7 @@ void Script::directGameLoad(int slot) {
 		_savedCode = nullptr;
 	}
 
-	uint16 targetInstruction;
+	uint16 targetInstruction = 0;
 	const byte *midiInitScript = nullptr;
 	uint8 midiInitScriptSize = 0;
 
@@ -384,6 +384,7 @@ uint8 Script::readScriptChar(bool allow7C, bool limitVal, bool limitVar) {
 		parta = readScriptChar(false, false, false);
 		partb = readScriptChar(false, true, true);
 		result = _variables[0x0A * parta + partb + 0x19];
+		debugC(7, kDebugScript, "readScriptChar got | for var %d with value %d", (int)(0x0A * parta + partb + 0x19), (int)result);
 	} else if (data == kVarTypeArray) {
 		// Index an array
 		data = readScript8bits();
@@ -391,20 +392,27 @@ uint8 Script::readScriptChar(bool allow7C, bool limitVal, bool limitVar) {
 			data &= 0x7F;
 		}
 		result = _variables[data - 0x61];
+		debugC(7, kDebugScript, "readScriptChar got # for var %d with value %d", (int)(data - 0x61), (int)result);
 	} else {
 		// Immediate value
 		result = data - 0x30;
+		debugC(7, kDebugScript, "readScriptChar got %d", (int)result);
 	}
 	return result;
 }
 
 void Script::readScriptString(Common::String &str) {
 	byte c;
+	Common::String orig;
+
+	debugC(5, kDebugScript, "readScriptString start");
 
 	while ((c = readScript8bits())) {
+		orig += c;
 		switch (c) {
 		case kVarTypeArray:
 			c = readScript8bits();
+			orig += Common::String::format("%d", (int)(c - 0x61));
 			c = _variables[c - 0x61] + 0x30;
 			if (_version == kGroovieT7G) {
 				if (c >= 0x41 && c <= 0x5A) {
@@ -416,6 +424,7 @@ void Script::readScriptString(Common::String &str) {
 			uint8 parta, partb;
 			parta = readScriptChar(false, false, false);
 			partb = readScriptChar(false, false, false);
+			orig += Common::String::format("%d", (int)(0x0A * parta + partb + 0x19));
 			c = _variables[0x0A * parta + partb + 0x19] + 0x30;
 			break;
 		default:
@@ -428,6 +437,8 @@ void Script::readScriptString(Common::String &str) {
 		// Append the current character at the end of the string
 		str += c;
 	}
+
+	debugC(5, kDebugScript, "readScriptString orig: %s, ret: %s", orig.c_str(), str.c_str());
 }
 
 uint32 Script::getVideoRefString(Common::String &resName) {
@@ -435,7 +446,7 @@ uint32 Script::getVideoRefString(Common::String &resName) {
 	readScriptString(resName);
 
 	// Add a trailing dot
-	resName += 0x2E;
+	resName += '.';
 
 	debugCN(0, kDebugScript, "%s", resName.c_str());
 
@@ -443,6 +454,20 @@ uint32 Script::getVideoRefString(Common::String &resName) {
 	return _vm->_resMan->getRef(resName);
 }
 
+void Script::executeInputAction(uint16 address) {
+	debugC(1, kDebugScript, "Groovie::Script: executeInputAction 0x%04X", (uint)address);
+
+	// Jump to the planned address
+	_currentInstruction = address;
+
+	// Exit the input loop
+	_inputLoopAddress = 0;
+
+	// Force immediate hiding of the mouse cursor (required when the next video just contains audio)
+	_vm->_grvCursorMan->show(false);
+	_vm->_graphicsMan->change();
+}
+
 bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) {
 	// Test if the current mouse position is contained in the specified rectangle
 	Common::Point mousepos = _vm->_system->getEventManager()->getMousePos();
@@ -458,11 +483,6 @@ bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) {
 		_vm->_system->updateScreen();
 	}
 
-	// If there's an already planned action, do nothing
-	if (_inputAction != -1) {
-		return false;
-	}
-
 	if (contained) {
 		// Change the mouse cursor
 		if (_newCursorStyle == 5) {
@@ -472,7 +492,7 @@ bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) {
 		// If clicked with the mouse, jump to the specified address
 		if (_mouseClicked) {
 			_lastCursor = cursor;
-			_inputAction = address;
+			executeInputAction(address);
 		}
 	}
 
@@ -927,8 +947,7 @@ void Script::o_inputloopstart() {	//0x0B
 #endif
 	}
 
-	// Reset the input action and the mouse cursor
-	_inputAction = -1;
+	// Reset the mouse cursor
 	_newCursorStyle = 5;
 
 	// Save the input loop address
@@ -947,21 +966,11 @@ void Script::o_keyboardaction() {
 	uint8 val = readScript8bits();
 	uint16 address = readScript16bits();
 
-	// If there's an already planned action, do nothing
-	if (_inputAction != -1) {
-		debugC(5, kDebugScript, "Groovie::Script: Test key == 0x%02X @0x%04X - skipped", val, address);
-		return;
-	}
-
 	// Check the typed key
 	if (_kbdChar == val) {
 		debugC(5, kDebugScript, "Groovie::Script: Test key == 0x%02X @0x%04X - match", val, address);
 
-		// Exit the input loop
-		_inputLoopAddress = 0;
-
-		// Save the action address
-		_inputAction = address;
+		executeInputAction(address);
 	} else {
 		debugC(5, kDebugScript, "Groovie::Script: Test key == 0x%02X @0x%04X", val, address);
 	}
@@ -1054,20 +1063,6 @@ void Script::o_inputloopend() {
 		hotspot(rect, _hotspotLeftAction, 1);
 	}
 
-	// Actually execute the planned action
-	if (_inputAction != -1) {
-		// Jump to the planned address
-		_currentInstruction = _inputAction;
-
-		// Exit the input loop
-		_inputLoopAddress = 0;
-		_vm->_grvCursorMan->show(false);
-
-		// Force immediate hiding of the mouse cursor (required when the next
-		// video just contains audio)
-		_vm->_graphicsMan->change();
-	}
-
 	// Nothing to do
 	if (_inputLoopAddress) {
 		if (_newCursorStyle != _vm->_grvCursorMan->getStyle()) {
diff --git a/engines/groovie/script.h b/engines/groovie/script.h
index 5a00531fa5..98f3312605 100644
--- a/engines/groovie/script.h
+++ b/engines/groovie/script.h
@@ -119,7 +119,6 @@ private:
 	uint8 _kbdChar;
 	uint8 _eventKbdChar;
 	uint16 _inputLoopAddress;
-	int16 _inputAction;
 	uint8 _newCursorStyle;
 	uint16 _hotspotTopAction;
 	uint16 _hotspotTopCursor;
@@ -155,6 +154,7 @@ private:
 	uint8 readScriptVar();
 	uint32 getVideoRefString(Common::String &resName);
 
+	void executeInputAction(uint16 address);
 	bool hotspot(Common::Rect rect, uint16 addr, uint8 cursor);
 
 	void loadgame(uint slot);


Commit: e0510db9f78dd5284fb9bbfbafdc38059a35adfa
    https://github.com/scummvm/scummvm/commit/e0510db9f78dd5284fb9bbfbafdc38059a35adfa
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2021-12-05T11:59:30-06:00

Commit Message:
GROOVIE: couldn't find resource warning

The 11th Hour has bugged scripts that sometimes don't set the variables for the GameBook thumbnails correctly, which causes even the original Win95 exe to crash. This happens occasionallyafter watching an end of chapter cutscene. Changing this to a warning means you don't crash, and the missing thumbnail is a minor compromise.

Changed paths:
    engines/groovie/resource.cpp
    engines/groovie/script.cpp


diff --git a/engines/groovie/resource.cpp b/engines/groovie/resource.cpp
index 5a3447d54d..cbec4b30d2 100644
--- a/engines/groovie/resource.cpp
+++ b/engines/groovie/resource.cpp
@@ -293,7 +293,7 @@ uint32 ResMan_v2::getRef(Common::String name) {
 
 	// Verify we really found the resource
 	if (!found) {
-		error("Groovie::Resource: Couldn't find resource %s", name.c_str());
+		warning("Groovie::Resource: Couldn't find resource %s", name.c_str());
 		return (uint32)-1;
 	}
 
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index 523f2cb907..5d4d55056a 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -825,6 +825,9 @@ bool Script::playvideofromref(uint32 fileref, bool loopUntilAudioDone) {
 			delete _videoFile;
 		}
 
+		if (fileref == UINT_MAX)
+			return true;
+
 		// Try to open the new file
 		ResInfo resInfo;
 		if (!_vm->_resMan->getResInfo(fileref, resInfo)) {




More information about the Scummvm-git-logs mailing list