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

elasota noreply at scummvm.org
Sun Oct 9 04:25:05 UTC 2022


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:
45062f7fd6 MTROPOLIS: Use 8-bit 640x480 for MTI
f2269e33db MTROPOLIS: Add color table modifier


Commit: 45062f7fd66238be3062856e2a835c48f43bfbf8
    https://github.com/scummvm/scummvm/commit/45062f7fd66238be3062856e2a835c48f43bfbf8
Author: elasota (ejlasota at gmail.com)
Date: 2022-10-09T00:24:12-04:00

Commit Message:
MTROPOLIS: Use 8-bit 640x480 for MTI

Changed paths:
    engines/mtropolis/mtropolis.cpp


diff --git a/engines/mtropolis/mtropolis.cpp b/engines/mtropolis/mtropolis.cpp
index b8a4544759a..4973757a4b1 100644
--- a/engines/mtropolis/mtropolis.cpp
+++ b/engines/mtropolis/mtropolis.cpp
@@ -33,6 +33,7 @@
 
 #include "graphics/cursorman.h"
 #include "graphics/maccursor.h"
+#include "graphics/palette.h"
 #include "graphics/surface.h"
 #include "graphics/pixelformat.h"
 #include "graphics/wincursor.h"
@@ -137,6 +138,12 @@ Common::Error MTropolisEngine::run() {
 		}
 	}
 
+	if (_gameDescription->gameID == GID_MTI) {
+		preferredWidth = 640;
+		preferredHeight = 480;
+		preferredColorDepthMode = kColorDepthMode8Bit;
+	}
+
 	if (ConfMan.getBool("mtropolis_mod_minimum_transition_duration"))
 		_runtime->getHacks().minTransitionDuration = 75;
 


Commit: f2269e33db5cbf29d2773ba17c6e0266bb7f2207
    https://github.com/scummvm/scummvm/commit/f2269e33db5cbf29d2773ba17c6e0266bb7f2207
Author: elasota (ejlasota at gmail.com)
Date: 2022-10-09T00:24:13-04:00

Commit Message:
MTROPOLIS: Add color table modifier

Changed paths:
    engines/mtropolis/assets.cpp
    engines/mtropolis/assets.h
    engines/mtropolis/modifiers.cpp
    engines/mtropolis/runtime.cpp


diff --git a/engines/mtropolis/assets.cpp b/engines/mtropolis/assets.cpp
index 3e3221cfc25..82cb9217718 100644
--- a/engines/mtropolis/assets.cpp
+++ b/engines/mtropolis/assets.cpp
@@ -64,6 +64,9 @@ AssetType ColorTableAsset::getAssetType() const {
 	return kAssetTypeColorTable;
 }
 
+const ColorRGB8 *ColorTableAsset::getColors() const {
+	return _colors;
+}
 
 CachedAudio::CachedAudio() {
 }
diff --git a/engines/mtropolis/assets.h b/engines/mtropolis/assets.h
index c41f674393d..8c3c8d5f69c 100644
--- a/engines/mtropolis/assets.h
+++ b/engines/mtropolis/assets.h
@@ -38,6 +38,8 @@ public:
 	bool load(AssetLoaderContext &context, const Data::ColorTableAsset &data);
 	AssetType getAssetType() const override;
 
+	const ColorRGB8 *getColors() const;
+
 private:
 	ColorRGB8 _colors[256];
 };
diff --git a/engines/mtropolis/modifiers.cpp b/engines/mtropolis/modifiers.cpp
index 3af088eb7a3..8824dc8844f 100644
--- a/engines/mtropolis/modifiers.cpp
+++ b/engines/mtropolis/modifiers.cpp
@@ -22,6 +22,7 @@
 #include "common/memstream.h"
 
 #include "graphics/managed_surface.h"
+#include "graphics/palette.h"
 
 #include "mtropolis/assets.h"
 #include "mtropolis/audio_player.h"
@@ -277,6 +278,32 @@ bool ColorTableModifier::respondsToEvent(const Event &evt) const {
 }
 
 VThreadState ColorTableModifier::consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) {
+	if (_applyWhen.respondsTo(msg->getEvent())) {
+		Common::SharedPtr<Asset> ctabAsset = runtime->getProject()->getAssetByID(_assetID).lock();
+		if (ctabAsset) {
+			if (ctabAsset->getAssetType() == kAssetTypeColorTable) {
+				const ColorRGB8 *colors = static_cast<ColorTableAsset *>(ctabAsset.get())->getColors();
+
+				byte palette[256 * 3];
+				for (int i = 0; i < 256; i++) {
+					byte *paletteColor = palette + i * 3;
+					const ColorRGB8 &clr = colors[i];
+					paletteColor[0] = clr.r;
+					paletteColor[1] = clr.g;
+					paletteColor[2] = clr.b;
+				}
+
+				g_system->getPaletteManager()->setPalette(palette, 0, 256);
+			} else {
+				error("Color table modifier applied an asset that wasn't a color table");
+			}
+		} else {
+			warning("Failed to apply color table, asset %u wasn't found", _assetID);
+		}
+
+		return kVThreadReturn;
+	}
+
 	return kVThreadReturn;
 }
 
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 3f627ae735d..27fa0202705 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -4743,10 +4743,15 @@ void Runtime::loadScene(const Common::SharedPtr<Structural>& scene) {
 
 	Subsection *subsection = static_cast<Subsection *>(scene->getParent());
 
-	_project->loadSceneFromStream(scene, streamID, getHacks());
-	debug(1, "Scene loaded OK, materializing objects...");
-	scene->materializeDescendents(this, subsection->getSceneLoadMaterializeScope());
-	debug(1, "Scene materialized OK");
+	if (streamID == 0) {
+		debug(1, "Scene is empty");
+	} else {
+		_project->loadSceneFromStream(scene, streamID, getHacks());
+		debug(1, "Scene loaded OK, materializing objects...");
+		scene->materializeDescendents(this, subsection->getSceneLoadMaterializeScope());
+		debug(1, "Scene materialized OK");
+	}
+
 	recursiveActivateStructural(scene.get());
 	debug(1, "Structural elements activated OK");
 




More information about the Scummvm-git-logs mailing list