[Scummvm-cvs-logs] SF.net SVN: scummvm:[54792] scummvm/trunk/engines/mohawk

fuzzie at users.sourceforge.net fuzzie at users.sourceforge.net
Sun Dec 5 23:10:51 CET 2010


Revision: 54792
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54792&view=rev
Author:   fuzzie
Date:     2010-12-05 22:10:50 +0000 (Sun, 05 Dec 2010)

Log Message:
-----------
MOHAWK: handle LB 2/3 kLBNotifyChangeMode, kLBActionNotified matching

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/livingbooks.cpp
    scummvm/trunk/engines/mohawk/livingbooks.h

Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-12-05 22:10:20 UTC (rev 54791)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-12-05 22:10:50 UTC (rev 54792)
@@ -1036,10 +1036,14 @@
 		nextPage();
 		break;
 
-	case kLBNotifyQuit:
-		debug(2, "kLBNotifyQuit: %d", event.param);
-
-		quitGame();
+	case kLBNotifyChangeMode:
+		if (getGameType() == GType_LIVINGBOOKSV1) {
+			debug(2, "kLBNotifyChangeMode: %d", event.param);
+			quitGame();
+		} else {
+			// FIXME
+			warning("ignoring V2/V3 kLBNotifyChangeMode");
+		}
 		break;
 
 	case kLBNotifyCursorChange:
@@ -1635,26 +1639,25 @@
 				size -= (2 + entry->argc * 4);
 			}
 
-			if (type == kLBNotifyScript && entry->opcode == kLBNotifyQuit) {
+			if (type == kLBNotifyScript && entry->opcode == kLBNotifyChangeMode && _vm->getGameType() != GType_LIVINGBOOKSV1) {
 				if (size < 8) {
-					error("%d unknown bytes in notify entry 0x%04x", size, entry->opcode);
+					error("%d unknown bytes in notify entry kLBNotifyChangeMode", size);
 				}
-				uint16 opcodeId = stream->readUint16();
-				uint16 modeId = stream->readUint16();
-				uint16 pageId = stream->readUint16();
-				uint16 subPageId = stream->readUint16();
-				// FIXME
-				warning("unknown notify: opcode %04x, mode %d, page %d.%d", opcodeId, modeId, pageId, subPageId);
+				entry->newUnknown = stream->readUint16();
+				entry->newMode = stream->readUint16();
+				entry->newPage = stream->readUint16();
+				entry->newSubpage = stream->readUint16();
+				debug(4, "kLBNotifyChangeMode: unknown %04x, mode %d, page %d.%d",
+					entry->newUnknown, entry->newMode, entry->newPage, entry->newSubpage);
 				size -= 8;
 			}
-			if (entry->action == 7) {
+			// FIXME: what is 0x1d?
+			if (entry->action == kLBActionNotified || entry->opcode == 0x1d) {
 				if (size < 4)
-					error("not enough bytes (%d) in action 7, opcode 0x%04x", size, entry->opcode);
-				// FIXME: meh
+					error("not enough bytes (%d) in action %d, opcode 0x%04x", size, entry->action, entry->opcode);
+				entry->matchFrom = stream->readUint16();
+				entry->matchNotify = stream->readUint16();
 				size -= 4;
-				uint16 itemId = stream->readUint16();
-				uint16 unknown = stream->readUint16();
-				warning("ignoring id %d, unknown 0x%04x in script entry (type 0x%04x, action 0x%04x, opcode 0x%04x)", itemId, unknown, entry->type, entry->action, entry->opcode);
 			}
 			if (entry->opcode == 0xffff) {
 				if (size < 4)
@@ -2009,25 +2012,28 @@
 }
 
 void LBItem::notify(uint16 data, uint16 from) {
-	if (_timingMode != 4)
-		return;
+	if (_timingMode == 4) {
+		// TODO: is this correct?
+		if (_periodMin == from && _periodMax == data) {
+			debug(2, "Handling notify 0x%04x (from %d)", data, from);
+			setNextTime(0, 0);
+		}
+	}
 
-	// TODO: is this correct?
-	if (_periodMin != from)
-		return;
-	if (_periodMax != data)
-		return;
-
-	debug(2, "Handling notify 0x%04x (from %d)", data, from);
-	setNextTime(0, 0);
+	runScript(kLBActionNotified, data, from);
 }
 
-void LBItem::runScript(uint id) {
+void LBItem::runScript(uint id, uint16 data, uint16 from) {
 	for (uint i = 0; i < _scriptEntries.size(); i++) {
 		LBScriptEntry *entry = _scriptEntries[i];
 		if (entry->action != id)
 			continue;
 
+		if (id == kLBActionNotified) {
+			if (entry->matchFrom != from || entry->matchNotify != data)
+				continue;
+		}
+
 		bool conditionsMatch = true;
 		for (uint n = 0; n < entry->conditions.size(); n++) {
 			if (!checkCondition(entry->conditions[n])) {

Modified: scummvm/trunk/engines/mohawk/livingbooks.h
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.h	2010-12-05 22:10:20 UTC (rev 54791)
+++ scummvm/trunk/engines/mohawk/livingbooks.h	2010-12-05 22:10:50 UTC (rev 54792)
@@ -134,7 +134,7 @@
 	kLBNotifyGoToControls = 2,
 	kLBNotifyChangePage = 3,
 	kLBNotifyIntroDone = 5,
-	kLBNotifyQuit = 6,
+	kLBNotifyChangeMode = 6,
 	kLBNotifyCursorChange = 7
 };
 
@@ -150,10 +150,21 @@
 	uint16 action;
 	uint16 opcode;
 	uint16 param;
+
 	uint16 argc;
 	uint16 *argvParam;
 	uint16 *argvTarget;
 
+	// kLBNotifyChangeMode
+	uint16 newUnknown;
+	uint16 newMode;
+	uint16 newPage;
+	uint16 newSubpage;
+
+	// kLBActionNotified
+	uint16 matchFrom;
+	uint16 matchNotify;
+
 	Common::String command;
 	Common::Array<Common::String> conditions;
 };
@@ -300,7 +311,7 @@
 	bool _isAmbient;
 
 	Common::Array<LBScriptEntry *> _scriptEntries;
-	void runScript(uint id);
+	void runScript(uint id, uint16 data = 0, uint16 from = 0);
 
 	LBValue parseValue(const Common::String &command, uint &pos);
 	void runCommand(const Common::String &command);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list