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

npjg noreply at scummvm.org
Wed Jan 8 02:35:23 UTC 2025


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

Summary:
8bca0172d7 MEDIASTATION: Remove duplicate chunk count field
e6de46e25d MEDIASTATION: Implement branchToScreen script method
f6bec93688 MEDIASTATION: Make script routine callers use enums


Commit: 8bca0172d7c8308648fcaba534bb63f6a06d6c19
    https://github.com/scummvm/scummvm/commit/8bca0172d7c8308648fcaba534bb63f6a06d6c19
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-07T21:33:15-05:00

Commit Message:
MEDIASTATION: Remove duplicate chunk count field

Changed paths:
    engines/mediastation/assetheader.cpp
    engines/mediastation/assetheader.h


diff --git a/engines/mediastation/assetheader.cpp b/engines/mediastation/assetheader.cpp
index c4bf5f6e81a..a406c9f23be 100644
--- a/engines/mediastation/assetheader.cpp
+++ b/engines/mediastation/assetheader.cpp
@@ -193,7 +193,7 @@ void AssetHeader::readSection(AssetHeaderSectionType sectionType, Chunk& chunk)
 	}
 
 	case kAssetHeaderSoundInfo: {
-		_totalChunks = Datum(chunk).u.i;
+		_chunkCount = Datum(chunk).u.i;
 		_rate = Datum(chunk).u.i;
 		break;
 	}
diff --git a/engines/mediastation/assetheader.h b/engines/mediastation/assetheader.h
index eda5e5b4413..04f8ef7c18e 100644
--- a/engines/mediastation/assetheader.h
+++ b/engines/mediastation/assetheader.h
@@ -144,7 +144,6 @@ public:
 	uint32 _cursorResourceId = 0;
 	uint32 _frameRate = 10; // This is the default for sprites, which are the only ones that use this field.
 	uint32 _loadType = 0;
-	uint32 _totalChunks = 0;
 	uint32 _rate = 0;
 	bool _editable = 0;
 	Graphics::Palette *_palette = nullptr;


Commit: e6de46e25d906327d4c83974231a5198dafbfa9e
    https://github.com/scummvm/scummvm/commit/e6de46e25d906327d4c83974231a5198dafbfa9e
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-07T21:33:15-05:00

Commit Message:
MEDIASTATION: Implement branchToScreen script method

Changed paths:
    engines/mediastation/mediascript/codechunk.cpp
    engines/mediastation/mediastation.cpp
    engines/mediastation/mediastation.h


diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index a4b118d3dba..52c2201386a 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -326,10 +326,21 @@ Operand CodeChunk::callBuiltInFunction(uint32 id, Common::Array<Operand> &args)
 }
 
 Operand CodeChunk::callBuiltInMethod(uint32 id, Operand self, Common::Array<Operand> &args) {
-	Asset *selfAsset = self.getAsset();
-	assert(selfAsset != nullptr);
-	Operand returnValue = selfAsset->callMethod((BuiltInMethod)id, args);
-	return returnValue;
+	if (self.getAssetId() == 1) {
+		// This is a "document" method that we need to handle specially.
+		// The document (@doc) accepts engine-level methods like changing the
+		// active screen.
+		// HACK: This is so we don't have to implement a separate document class
+		// just to house these methods. Rather, we just call in the engine.
+		Operand returnValue = g_engine->callMethod((BuiltInMethod)id, args);
+		return returnValue;
+	} else {
+		// This is a regular asset that we can process directly.
+		Asset *selfAsset = self.getAsset();
+		assert(selfAsset != nullptr);
+		Operand returnValue = selfAsset->callMethod((BuiltInMethod)id, args);
+		return returnValue;
+	}
 }
 
 CodeChunk::~CodeChunk() {
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index 45ab63ce5a1..c931ec4293a 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -121,21 +121,7 @@ Common::Error MediaStationEngine::run() {
 		warning("MediaStation::run(): Title has no root context");
 	}
 
-	Context *activeScreen = loadContext(_boot->_entryContextId);
-	if (activeScreen->_screenAsset != nullptr) {
-		// GET THE PALETTE.
-		setPaletteFromHeader(activeScreen->_screenAsset);
-
-		// PROCESS THE OPENING EVENT HANDLER.
-		EventHandler *entryEvent = activeScreen->_screenAsset->_eventHandlers.getValOrDefault(MediaStation::kEntryEvent);
-		if (entryEvent != nullptr) {
-			debugC(5, kDebugScript, "Executing context entry event handler");
-			entryEvent->execute(activeScreen->_screenAsset->_id);
-		} else {
-			debugC(5, kDebugScript, "No context entry event handler");
-		}
-	}
-
+	branchToScreen(_boot->_entryContextId);
 	while (true) {
 		processEvents();
 		if (shouldQuit()) {
@@ -265,4 +251,37 @@ void MediaStationEngine::addPlayingAsset(Asset *assetToAdd) {
 	g_engine->_assetsPlaying.push_back(assetToAdd);
 }
 
+Operand MediaStationEngine::callMethod(BuiltInMethod methodId, Common::Array<Operand> &args) {
+	switch (methodId) {
+		case kBranchToScreenMethod: {
+			assert(args.size() == 1);
+			uint32 contextId = args[0].getAssetId();
+			branchToScreen(contextId);
+			return Operand();
+		}
+
+		default: {
+			error("MediaStationEngine::callMethod(): Got unimplemented method ID %d", static_cast<uint>(methodId));
+		}
+	}
+}
+
+void MediaStationEngine::branchToScreen(uint32 contextId) {
+	Context *context = loadContext(contextId);
+	if (context->_screenAsset != nullptr) {
+		setPaletteFromHeader(context->_screenAsset);
+		
+		// TODO: Make the screen an asset just like everything else so we can
+		// run event handlers with runEventHandlerIfExists.
+		EventHandler *entryEvent = context->_screenAsset->_eventHandlers.getValOrDefault(MediaStation::kEntryEvent);
+		if (entryEvent != nullptr) {
+			debugC(5, kDebugScript, "Executing context entry event handler");
+			entryEvent->execute(context->_screenAsset->_id);
+		} else {
+			debugC(5, kDebugScript, "No context entry event handler");
+		}
+	}
+	_currentContext = context;
+}
+
 } // End of namespace MediaStation
diff --git a/engines/mediastation/mediastation.h b/engines/mediastation/mediastation.h
index 05363cf822e..9b991454f20 100644
--- a/engines/mediastation/mediastation.h
+++ b/engines/mediastation/mediastation.h
@@ -76,10 +76,12 @@ public:
 	void setPalette(Asset *palette);
 	void addPlayingAsset(Asset *assetToAdd);
 
+    Operand callMethod(BuiltInMethod methodId, Common::Array<Operand> &args);
 	Common::HashMap<uint, Asset *> _assets;
 	Common::HashMap<uint, Function *> _functions;
 	Common::HashMap<uint32, Variable *> _variables;
 	Common::HashMap<uint, Asset *> _assetsByChunkReference;
+	Context *_currentContext = nullptr;
 	Graphics::Screen *_screen = nullptr;
 	Audio::Mixer *_mixer = nullptr;
 
@@ -101,6 +103,7 @@ private:
 
 	Context *loadContext(uint32 contextId);
 	void setPaletteFromHeader(AssetHeader *header);
+	void branchToScreen(uint32 contextId);
 };
 
 extern MediaStationEngine *g_engine;


Commit: f6bec93688666bb1f58c737ffb16d674af727b8d
    https://github.com/scummvm/scummvm/commit/f6bec93688666bb1f58c737ffb16d674af727b8d
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-07T21:33:15-05:00

Commit Message:
MEDIASTATION: Make script routine callers use enums

Rather than passing uints and casting at the last moment.

Changed paths:
    engines/mediastation/mediascript/codechunk.cpp
    engines/mediastation/mediascript/codechunk.h


diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 52c2201386a..cea7784b997 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -94,15 +94,16 @@ Operand CodeChunk::executeNextStatement() {
 			Operand returnValue;
 			Function *function = g_engine->_functions.getValOrDefault(functionId);
 			if (function != nullptr) {
+				// This is a title-defined function.
 				returnValue = function->execute(args);
 			} else {
-				returnValue = callBuiltInFunction(functionId, args);
+				returnValue = callBuiltInFunction(static_cast<BuiltInFunction>(functionId), args);
 			}
 			return returnValue;
 		}
 
 		case kOpcodeCallMethod: {
-			uint32 methodId = Datum(*_bytecode).u.i;
+			BuiltInMethod methodId = static_cast<BuiltInMethod>(Datum(*_bytecode).u.i);
 			uint32 parameterCount = Datum(*_bytecode).u.i;
 			Operand selfObject = executeNextStatement();
 			if (selfObject.getType() != kOperandTypeAssetId) {
@@ -288,8 +289,8 @@ void CodeChunk::putVariable(uint32 id, VariableScope scope, Operand value) {
 	}
 }
 
-Operand CodeChunk::callBuiltInFunction(uint32 id, Common::Array<Operand> &args) {
-	switch ((BuiltInFunction)id) {
+Operand CodeChunk::callBuiltInFunction(BuiltInFunction id, Common::Array<Operand> &args) {
+	switch (id) {
 	case kEffectTransitionFunction: {
 		switch (args.size()) {
 		// TODO: Discover and handle the different ways
@@ -325,20 +326,20 @@ Operand CodeChunk::callBuiltInFunction(uint32 id, Common::Array<Operand> &args)
 	}
 }
 
-Operand CodeChunk::callBuiltInMethod(uint32 id, Operand self, Common::Array<Operand> &args) {
+Operand CodeChunk::callBuiltInMethod(BuiltInMethod method, Operand self, Common::Array<Operand> &args) {
 	if (self.getAssetId() == 1) {
 		// This is a "document" method that we need to handle specially.
 		// The document (@doc) accepts engine-level methods like changing the
 		// active screen.
 		// HACK: This is so we don't have to implement a separate document class
 		// just to house these methods. Rather, we just call in the engine.
-		Operand returnValue = g_engine->callMethod((BuiltInMethod)id, args);
+		Operand returnValue = g_engine->callMethod(method, args);
 		return returnValue;
 	} else {
 		// This is a regular asset that we can process directly.
 		Asset *selfAsset = self.getAsset();
 		assert(selfAsset != nullptr);
-		Operand returnValue = selfAsset->callMethod((BuiltInMethod)id, args);
+		Operand returnValue = selfAsset->callMethod(method, args);
 		return returnValue;
 	}
 }
diff --git a/engines/mediastation/mediascript/codechunk.h b/engines/mediastation/mediascript/codechunk.h
index e5d29efd995..caa4fbe00e3 100644
--- a/engines/mediastation/mediascript/codechunk.h
+++ b/engines/mediastation/mediascript/codechunk.h
@@ -86,8 +86,8 @@ public:
 
 private:
 	Operand executeNextStatement();
-	Operand callBuiltInFunction(uint32 id, Common::Array<Operand> &args);
-	Operand callBuiltInMethod(uint32 id, Operand self, Common::Array<Operand> &args);
+	Operand callBuiltInFunction(BuiltInFunction id, Common::Array<Operand> &args);
+	Operand callBuiltInMethod(BuiltInMethod method, Operand self, Common::Array<Operand> &args);
 	Operand getVariable(uint32 id, VariableScope scope);
 	void putVariable(uint32 id, VariableScope scope, Operand value);
 




More information about the Scummvm-git-logs mailing list