[Scummvm-cvs-logs] scummvm master -> e82e5e32ff750adc2f1454cba0949ce89d9e04cd

clone2727 clone2727 at gmail.com
Wed Mar 23 01:35:30 CET 2011


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

Summary:
f40b74d496 MOHAWK: Handle launcher load fails more gracefully
a730d30f0c MOHAWK: Cleanup installer handling
4d6c020cf4 MOHAWK: Remove the Riven 'restart' console command
1ca6781859 MOHAWK: Minor cursor call cleanup
e82e5e32ff MOHAWK: Begin to implement Riven opcode 38


Commit: f40b74d496f53c2864ab9573b175498a978d0e0e
    https://github.com/scummvm/scummvm/commit/f40b74d496f53c2864ab9573b175498a978d0e0e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-03-22T16:54:58-07:00

Commit Message:
MOHAWK: Handle launcher load fails more gracefully

Changed paths:
    engines/mohawk/riven.cpp



diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 1d47d45..6393206 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -171,7 +171,12 @@ Common::Error MohawkEngine_Riven::run() {
 		Common::StringArray savedGamesList = _saveLoad->generateSaveGameList();
 		if (gameToLoad > savedGamesList.size())
 			error ("Could not find saved game");
-		_saveLoad->loadGame(savedGamesList[gameToLoad]);
+
+		// Attempt to load the game. On failure, just send us to the main menu.
+		if (!_saveLoad->loadGame(savedGamesList[gameToLoad])) {
+			changeToStack(aspit);
+			changeToCard(1);
+		}
 	} else {
 		// Otherwise, start us off at aspit's card 1 (the main menu)
         changeToStack(aspit);


Commit: a730d30f0cf4ae0752635d2ab0b515c17ebf64b1
    https://github.com/scummvm/scummvm/commit/a730d30f0cf4ae0752635d2ab0b515c17ebf64b1
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-03-22T16:54:59-07:00

Commit Message:
MOHAWK: Cleanup installer handling

Changed paths:
    engines/mohawk/installer_archive.cpp



diff --git a/engines/mohawk/installer_archive.cpp b/engines/mohawk/installer_archive.cpp
index 560d99e..4ea742d 100644
--- a/engines/mohawk/installer_archive.cpp
+++ b/engines/mohawk/installer_archive.cpp
@@ -40,11 +40,6 @@ InstallerArchive::~InstallerArchive() {
 	close();
 }
 
-struct DirectoryEntry {
-	uint16 fileCount;
-	Common::String name;
-};
-
 bool InstallerArchive::open(const Common::String &filename) {
 	close();
 
@@ -60,68 +55,55 @@ bool InstallerArchive::open(const Common::String &filename) {
 		return false;
 	}
 
-	// Let's move to the directory
+	// Let's pull some relevant data from the header
 	_stream->seek(41);
-	uint32 offset = _stream->readUint32LE();
-	_stream->seek(offset);
+	uint32 directoryTableOffset = _stream->readUint32LE();
+	/* uint32 directoryTableSize = */ _stream->readUint32LE();
+	uint16 directoryCount = _stream->readUint16LE();
+	uint32 fileTableOffset = _stream->readUint32LE();
+	/* uint32 fileTableSize = */ _stream->readUint32LE();
+
+	// We need to have at least one directory in order for the archive to be valid
+	if (directoryCount == 0) {
+		close();
+		return false;
+	}
 
-	// Now read in each file from the directory
+	// TODO: Currently, we only support getting files from the first directory
+	// To that end, get the number of files from that entry
+	_stream->seek(directoryTableOffset);
 	uint16 fileCount = _stream->readUint16LE();
 	debug(2, "File count = %d", fileCount);
 
-	_stream->skip(9);
-
-	Common::Array<DirectoryEntry> directories;
-
-	for (uint16 i = 0; i < fileCount;) {
-		uint16 dirFileCount = _stream->readUint16LE();
+	// Following the directory table is the file table with files stored recursively
+	// by directory. Since we're only using the first directory, we can just go
+	// right to that one.
+	_stream->seek(fileTableOffset);
 
-		if (dirFileCount == 0) {
-			// We've found a file
-			FileEntry entry;
+	for (uint16 i = 0; i < fileCount; i++) {
+		FileEntry entry;
 
-			_stream->skip(1); // Unknown
+		_stream->skip(3); // Unknown
 
-			entry.uncompressedSize = _stream->readUint32LE();
-			entry.compressedSize = _stream->readUint32LE();
-			entry.offset = _stream->readUint32LE();
+		entry.uncompressedSize = _stream->readUint32LE();
+		entry.compressedSize = _stream->readUint32LE();
+		entry.offset = _stream->readUint32LE();
 
-			_stream->skip(14); // Unknown
+		_stream->skip(14); // Unknown
 
-			byte nameLength = _stream->readByte();
-			Common::String name;
-			while (nameLength--)
-				name += _stream->readByte();
+		byte nameLength = _stream->readByte();
+		Common::String name;
+		while (nameLength--)
+			name += _stream->readByte();
 
-			_stream->skip(13); // Unknown
+		_stream->skip(13); // Unknown
 
-			_map[name] = entry;
-			i++;
+		_map[name] = entry;
 
-			debug(3, "Found file '%s' at 0x%08x (Comp: 0x%08x, Uncomp: 0x%08x)", name.c_str(),
-					entry.offset, entry.compressedSize, entry.uncompressedSize);
-		} else {
-			// We've found a directory
-			DirectoryEntry dirEntry;
-
-			dirEntry.fileCount = dirFileCount;
-			/* uint16 entrySize = */ _stream->readUint16LE();
-
-			uint16 nameLength = _stream->readUint16LE();
-			while (nameLength--)
-				dirEntry.name += _stream->readByte();
-
-			directories.push_back(dirEntry);
-
-			_stream->skip(5);  // Unknown
-
-			debug(3, "Ignoring directory '%s'", dirEntry.name.c_str());
-		}
+		debug(3, "Found file '%s' at 0x%08x (Comp: 0x%08x, Uncomp: 0x%08x)", name.c_str(),
+				entry.offset, entry.compressedSize, entry.uncompressedSize);
 	}
 
-	// TODO: Handle files in directories
-	// Per directory found follows DirectoryEntry::fileCount files
-
 	return true;
 }
 


Commit: 4d6c020cf4c3f6c5acc5d025bbf9d5b4e879e129
    https://github.com/scummvm/scummvm/commit/4d6c020cf4c3f6c5acc5d025bbf9d5b4e879e129
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-03-22T17:04:46-07:00

Commit Message:
MOHAWK: Remove the Riven 'restart' console command

This ancient console function has no purpose any longer and is half-broken anyway.

Changed paths:
    engines/mohawk/console.cpp
    engines/mohawk/console.h



diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 64e4030..6f2a92e 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -316,7 +316,6 @@ RivenConsole::RivenConsole(MohawkEngine_Riven *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("stopSound",		WRAP_METHOD(RivenConsole, Cmd_StopSound));
 	DCmd_Register("curStack",		WRAP_METHOD(RivenConsole, Cmd_CurStack));
 	DCmd_Register("changeStack",	WRAP_METHOD(RivenConsole, Cmd_ChangeStack));
-	DCmd_Register("restart",		WRAP_METHOD(RivenConsole, Cmd_Restart));
 	DCmd_Register("hotspots",		WRAP_METHOD(RivenConsole, Cmd_Hotspots));
 	DCmd_Register("zipMode",		WRAP_METHOD(RivenConsole, Cmd_ZipMode));
 	DCmd_Register("dumpScript",     WRAP_METHOD(RivenConsole, Cmd_DumpScript));
@@ -446,14 +445,6 @@ bool RivenConsole::Cmd_ChangeStack(int argc, const char **argv) {
 	return false;
 }
 
-bool RivenConsole::Cmd_Restart(int argc, const char **argv) {
-	_vm->initVars();
-	_vm->changeToStack(aspit);
-	_vm->changeToCard(1);
-
-	return false;
-}
-
 bool RivenConsole::Cmd_Hotspots(int argc, const char **argv) {
 	DebugPrintf("Current card (%d) has %d hotspots:\n", _vm->getCurCard(), _vm->getHotspotCount());
 
diff --git a/engines/mohawk/console.h b/engines/mohawk/console.h
index 1dfd0bd..b7b6b25 100644
--- a/engines/mohawk/console.h
+++ b/engines/mohawk/console.h
@@ -75,7 +75,6 @@ private:
 	bool Cmd_StopSound(int argc, const char **argv);
 	bool Cmd_CurStack(int argc, const char **argv);
 	bool Cmd_ChangeStack(int argc, const char **argv);
-	bool Cmd_Restart(int argc, const char **argv);
 	bool Cmd_Hotspots(int argc, const char **argv);
 	bool Cmd_ZipMode(int argc, const char **argv);
 	bool Cmd_RunAllBlocks(int argc, const char **argv);


Commit: 1ca67818594a9fb3ca5acfa3d7bb8f5e6c6c98c7
    https://github.com/scummvm/scummvm/commit/1ca67818594a9fb3ca5acfa3d7bb8f5e6c6c98c7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-03-22T17:13:01-07:00

Commit Message:
MOHAWK: Minor cursor call cleanup

Changed paths:
    engines/mohawk/riven_scripts.cpp



diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index 98452e1..f8aa56e 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -32,7 +32,6 @@
 #include "mohawk/video.h"
 
 #include "common/stream.h"
-#include "graphics/cursorman.h"
 
 namespace Mohawk {
 
@@ -513,9 +512,9 @@ void RivenScript::enableMovie(uint16 op, uint16 argc, uint16 *argv) {
 
 // Command 32: play foreground movie - blocking (movie_id)
 void RivenScript::playMovieBlocking(uint16 op, uint16 argc, uint16 *argv) {
-	CursorMan.showMouse(false); // Hide the cursor before playing the video
+	_vm->_cursor->hideCursor();
 	_vm->_video->playMovieBlockingRiven(argv[0]);
-	CursorMan.showMouse(true); // Show the cursor again when we're done ;)
+	_vm->_cursor->showCursor();
 }
 
 // Command 33: play background movie - nonblocking (movie_id)


Commit: e82e5e32ff750adc2f1454cba0949ce89d9e04cd
    https://github.com/scummvm/scummvm/commit/e82e5e32ff750adc2f1454cba0949ce89d9e04cd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-03-22T17:33:38-07:00

Commit Message:
MOHAWK: Begin to implement Riven opcode 38

Also, renamed it to better reflect its purpose

Changed paths:
    engines/mohawk/riven_scripts.cpp
    engines/mohawk/riven_scripts.h



diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp
index f8aa56e..2db4a3d 100644
--- a/engines/mohawk/riven_scripts.cpp
+++ b/engines/mohawk/riven_scripts.cpp
@@ -31,6 +31,7 @@
 #include "mohawk/sound.h"
 #include "mohawk/video.h"
 
+#include "common/memstream.h"
 #include "common/stream.h"
 
 namespace Mohawk {
@@ -138,7 +139,7 @@ void RivenScript::setupOpcodes() {
 		// 0x24 (36 decimal)
 		OPCODE(unk_36),						// Unknown
 		OPCODE(fadeAmbientSounds),
-		OPCODE(complexPlayMovie),
+		OPCODE(storeMovieOpcode),
 		OPCODE(activatePLST),
 		// 0x28 (40 decimal)
 		OPCODE(activateSLST),
@@ -475,7 +476,7 @@ void RivenScript::incrementVariable(uint16 op, uint16 argc, uint16 *argv) {
 	debug(2, "Incrementing variable %d by %d, variable now is equal to %d", argv[0], argv[1], *localVar);
 }
 
-// Command 27: go to stack (stack_name code_hi code_lo)
+// Command 27: go to stack (stack name, code high, code low)
 void RivenScript::changeStack(uint16 op, uint16 argc, uint16 *argv) {
 	Common::String stackName = _vm->getName(StackNames, argv[0]);
 	int8 index = -1;
@@ -538,18 +539,41 @@ void RivenScript::fadeAmbientSounds(uint16 op, uint16 argc, uint16 *argv) {
 	_vm->_sound->stopAllSLST(true);
 }
 
-// Command 38: Play a movie with extra parameters (movie id, delay high, delay low, record type, record id)
-void RivenScript::complexPlayMovie(uint16 op, uint16 argc, uint16 *argv) {
-	warning("STUB: complexPlayMovie");
-	debugN("\tMovie ID = %d\n", argv[0]);
-	debugN("\tDelay = %d\n", (argv[1] << 16) + argv[2]);
+// Command 38: Store an opcode for use when playing a movie (movie id, time high, time low, opcode, arguments...)
+void RivenScript::storeMovieOpcode(uint16 op, uint16 argc, uint16 *argv) {
+	uint32 scriptSize = 6 + (argc - 4) * 2;
 
-	if (argv[3] == 0)
-		debugN("\tDraw PLST %d\n", argv[4]);
-	else if (argv[3] == 40)
-		debugN("\tPlay SLST %d\n", argv[4]);
-	else
-		error("Unknown complexPlayMovie record type %d", argv[3]);
+	// Create our dummy script
+	byte *scriptBuf = (byte *)malloc(scriptSize);
+	WRITE_BE_UINT16(scriptBuf, 1);            // One command
+	WRITE_BE_UINT16(scriptBuf + 2, argv[3]);  // One opcode
+	WRITE_BE_UINT16(scriptBuf + 4, argc - 4); // argc - 4 args      
+
+	for (int i = 0; i < argc - 4; i++)
+		WRITE_BE_UINT16(scriptBuf + 6 + (i * 2), argv[i + 4]);
+
+	// Build a script out of 'er
+	Common::SeekableReadStream *scriptStream = new Common::MemoryReadStream(scriptBuf, scriptSize, DisposeAfterUse::YES);
+	RivenScript *script = new RivenScript(_vm, scriptStream, kStoredOpcodeScript, getParentStack(), getParentCard());
+
+	uint32 delayTime = (argv[1] << 16) + argv[2];
+
+	if (delayTime > 0) {
+		// Store the script
+		RivenScriptManager::StoredMovieOpcode storedOp;
+		storedOp.script = script;
+		storedOp.time = delayTime + _vm->getTotalPlayTime();
+		storedOp.id = argv[0];
+
+		// TODO: Actually store the movie and call it in our movie loop
+		// For now, just delete the script and move on
+		//_vm->_scriptMan->setStoredMovieOpcode(storedOp);
+		delete script;
+	} else {
+		// Run immediately if we have no delay
+		script->runScript();
+		delete script;
+	}
 }
 
 // Command 39: activate PLST record (card picture lists)
@@ -640,11 +664,16 @@ void RivenScript::activateMLST(uint16 op, uint16 argc, uint16 *argv) {
 
 RivenScriptManager::RivenScriptManager(MohawkEngine_Riven *vm) {
 	_vm = vm;
+	_storedMovieOpcode.script = 0;
+	_storedMovieOpcode.time = 0;
+	_storedMovieOpcode.id = 0;
 }
 
 RivenScriptManager::~RivenScriptManager() {
 	for (uint32 i = 0; i < _currentScripts.size(); i++)
 		delete _currentScripts[i];
+
+	clearStoredMovieOpcode();
 }
 
 RivenScriptList RivenScriptManager::readScripts(Common::SeekableReadStream *stream, bool garbageCollect) {
@@ -685,4 +714,33 @@ void RivenScriptManager::unloadUnusedScripts() {
 	}
 }
 
+void RivenScriptManager::setStoredMovieOpcode(const StoredMovieOpcode &op) {
+	clearStoredMovieOpcode();
+	_storedMovieOpcode.script = op.script;
+	_storedMovieOpcode.id = op.id;
+	_storedMovieOpcode.time = op.time;
+}
+
+void RivenScriptManager::runStoredMovieOpcode(uint16 id) {
+	if (_storedMovieOpcode.script) {
+		if (_storedMovieOpcode.id == id) {
+			// If we've passed the time, run our script
+			if (_vm->getTotalPlayTime() >= _storedMovieOpcode.time) {
+				_storedMovieOpcode.script->runScript();
+				clearStoredMovieOpcode();
+			}
+		} else {
+			// We're on a completely different video, kill off any remaining opcode
+			clearStoredMovieOpcode();
+		}
+	}
+}
+
+void RivenScriptManager::clearStoredMovieOpcode() {
+	delete _storedMovieOpcode.script;
+	_storedMovieOpcode.script = 0;
+	_storedMovieOpcode.time = 0;
+	_storedMovieOpcode.id = 0;
+}
+
 } // End of namespace Mohawk
diff --git a/engines/mohawk/riven_scripts.h b/engines/mohawk/riven_scripts.h
index 89e5ff0..46cd965 100644
--- a/engines/mohawk/riven_scripts.h
+++ b/engines/mohawk/riven_scripts.h
@@ -34,6 +34,7 @@ class MohawkEngine_Riven;
 #define DECLARE_OPCODE(x) void x(uint16 op, uint16 argc, uint16 *argv)
 
 namespace Mohawk {
+
 // Script Types
 enum {
 	kMouseDownScript = 0,
@@ -46,7 +47,9 @@ enum {
 	kCardLoadScript = 6,
 	kCardLeaveScript = 7,
 	kCardOpenScript = 9,
-	kCardUpdateScript = 10
+	kCardUpdateScript = 10,
+
+	kStoredOpcodeScript // This is ScummVM-only to denote the script from a storeMovieOpcode() call
 };
 
 class RivenScript;
@@ -114,7 +117,7 @@ private:
 	DECLARE_OPCODE(stopMovie);
 	DECLARE_OPCODE(unk_36);
 	DECLARE_OPCODE(fadeAmbientSounds);
-	DECLARE_OPCODE(complexPlayMovie);
+	DECLARE_OPCODE(storeMovieOpcode);
 	DECLARE_OPCODE(activatePLST);
 	DECLARE_OPCODE(activateSLST);
 	DECLARE_OPCODE(activateMLSTAndPlay);
@@ -134,10 +137,22 @@ public:
 	RivenScriptList readScripts(Common::SeekableReadStream *stream, bool garbageCollect = true);
 	void stopAllScripts();
 
+	struct StoredMovieOpcode {
+		RivenScript *script;
+		uint32 time;
+		uint16 id;
+	};
+
+	void setStoredMovieOpcode(const StoredMovieOpcode &op);
+	void runStoredMovieOpcode(uint16 id);
+	void clearStoredMovieOpcode();
+
 private:
 	void unloadUnusedScripts();
 	RivenScriptList _currentScripts;
 	MohawkEngine_Riven *_vm;
+
+	StoredMovieOpcode _storedMovieOpcode;
 };
 
 } // End of namespace Mohawk






More information about the Scummvm-git-logs mailing list