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

elasota noreply at scummvm.org
Fri Jun 9 05:07:42 UTC 2023


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:
cfae4f935e MTROPOLIS: Fix paletted mToon color keying not working.  Replicate mTropolis 1.0 bug to fix MTI piano buttons playing 2 
a4856ca1ba MTROPOLIS: Show object RTID in debug info


Commit: cfae4f935e54970fbca61fd286e2d18203cedb67
    https://github.com/scummvm/scummvm/commit/cfae4f935e54970fbca61fd286e2d18203cedb67
Author: elasota (ejlasota at gmail.com)
Date: 2023-06-09T01:03:05-04:00

Commit Message:
MTROPOLIS: Fix paletted mToon color keying not working.  Replicate mTropolis 1.0 bug to fix MTI piano buttons playing 2 hints at once.

Changed paths:
    engines/mtropolis/elements.cpp
    engines/mtropolis/elements.h
    engines/mtropolis/runtime.cpp
    engines/mtropolis/runtime.h


diff --git a/engines/mtropolis/elements.cpp b/engines/mtropolis/elements.cpp
index 90d8701be5b..1e1c53d3318 100644
--- a/engines/mtropolis/elements.cpp
+++ b/engines/mtropolis/elements.cpp
@@ -1223,7 +1223,7 @@ MiniscriptInstructionOutcome ImageElement::scriptSetFlushPriority(MiniscriptThre
 
 MToonElement::MToonElement()
 	: _cacheBitmap(false), _maintainRate(false), _assetID(0), _rateTimes100000(0), _flushPriority(0), _celStartTimeMSec(0),
-	  _isPlaying(false), _renderedFrame(0), _playRange(IntRange(1, 1)), _cel(1) {
+	  _isPlaying(false), _renderedFrame(0), _playRange(IntRange(1, 1)), _cel(1), _hasIssuedRenderWarning(false) {
 }
 
 MToonElement::~MToonElement() {
@@ -1308,9 +1308,15 @@ VThreadState MToonElement::consumeCommand(Runtime *runtime, const Common::Shared
 		return kVThreadReturn;
 	}
 	if (Event(EventIDs::kStop, 0).respondsTo(msg->getEvent())) {
-		ChangeFlagTaskData *becomeVisibleTaskData = runtime->getVThread().pushTask("MToonElement::changeVisibilityTask", static_cast<VisualElement *>(this), &MToonElement::changeVisibilityTask);
-		becomeVisibleTaskData->desiredFlag = false;
-		becomeVisibleTaskData->runtime = runtime;
+		// mTropolis 1.0 will not fire a Hidden event when an mToon is stopped even though it is hidden in the process.
+		// MTI depends on this, otherwise 2 hints will play at once when clicking a song button on the piano.
+		// This same bug does NOT apply to the "Shown" event firing on Play (as happens above).
+		if (runtime->getProject()->guessVersion() >= MTropolisVersions::kMTropolisVersion1_1) {
+			ChangeFlagTaskData *hideTaskData = runtime->getVThread().pushTask("MToonElement::changeVisibilityTask", static_cast<VisualElement *>(this), &MToonElement::changeVisibilityTask);
+			hideTaskData->desiredFlag = false;
+			hideTaskData->runtime = runtime;
+		} else
+			setVisible(runtime, false);
 
 		StopPlayingTaskData *stopPlayingTaskData = runtime->getVThread().pushTask("MToonElement::stopPlayingTask", this, &MToonElement::stopPlayingTask);
 		stopPlayingTaskData->runtime = runtime;
@@ -1366,8 +1372,9 @@ void MToonElement::render(Window *window) {
 
 		_cachedMToon->getOrRenderFrame(_renderedFrame, frame, _renderSurface);
 
+		const Palette *palette = nullptr;
 		if (_renderSurface->format.bytesPerPixel == 1) {
-			const Palette *palette = getPalette().get();
+			palette = getPalette().get();
 			if (!palette)
 				palette = &getRuntime()->getGlobalPalette();
 
@@ -1402,7 +1409,30 @@ void MToonElement::render(Window *window) {
 
 			if (inkMode == VisualElementRenderProperties::kInkModeBackgroundMatte || inkMode == VisualElementRenderProperties::kInkModeBackgroundTransparent) {
 				ColorRGB8 transColorRGB8 = _renderProps.getBackColor();
-				uint32 transColor = _renderSurface->format.ARGBToColor(255, transColorRGB8.r, transColorRGB8.g, transColorRGB8.b);
+				uint32 transColor = 0;
+
+				if (_renderSurface->format.bytesPerPixel == 1) {
+					assert(palette);
+
+					const byte *paletteData = palette->getPalette();
+					bool foundColor = false;
+					for (uint i = 0; i < Palette::kNumColors; i++) {
+						if (transColorRGB8 == ColorRGB8(paletteData[i * 3 + 0], paletteData[i * 3 + 1], paletteData[i * 3 + 2])) {
+							if (foundColor) {
+								warning("mToon is rendered color key but has multiple palette entries matching the transparent color, this may not render correctly");
+								_hasIssuedRenderWarning = true;
+								break;
+							} else {
+								foundColor = true;
+								transColor = i;
+
+								if (_hasIssuedRenderWarning)
+									break;
+							}
+						}
+					}
+				} else
+					_renderSurface->format.ARGBToColor(255, transColorRGB8.r, transColorRGB8.g, transColorRGB8.b);
 
 				window->getSurface()->transBlitFrom(*_renderSurface, srcRect, destRect, transColor);
 			} else if (inkMode == VisualElementRenderProperties::kInkModeCopy || inkMode == VisualElementRenderProperties::kInkModeDefault) {
diff --git a/engines/mtropolis/elements.h b/engines/mtropolis/elements.h
index 92a4ab90395..6ba6d4f6edb 100644
--- a/engines/mtropolis/elements.h
+++ b/engines/mtropolis/elements.h
@@ -294,6 +294,8 @@ private:
 	// NOTE: To produce proper behavior, these are not sanitized until playMedia.  render must tolerate invalid values without changing them.
 	IntRange _playRange;
 	int32 _cel;
+
+	bool _hasIssuedRenderWarning;
 };
 
 class TextLabelElement : public VisualElement {
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index b37c2bb06e1..9afa3f68d70 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -6888,7 +6888,7 @@ Project::AssetDesc::AssetDesc() : typeCode(0), id(0), streamID(0), filePosition(
 Project::Project(Runtime *runtime)
 	: Structural(runtime), _projectFormat(Data::kProjectFormatUnknown), _isBigEndian(false),
 	  _haveGlobalObjectInfo(false), _haveProjectStructuralDef(false), _playMediaSignaller(new PlayMediaSignaller()),
-	  _keyboardEventSignaller(new KeyboardEventSignaller()) {
+	  _keyboardEventSignaller(new KeyboardEventSignaller()), _guessedVersion(MTropolisVersions::kMTropolisVersion1_0) {
 }
 
 Project::~Project() {
@@ -7405,6 +7405,10 @@ const SubtitleTables &Project::getSubtitles() const {
 	return _subtitles;
 }
 
+MTropolisVersions::MTropolisVersion Project::guessVersion() const {
+	return _guessedVersion;
+}
+
 void Project::loadPresentationSettings(const Data::PresentationSettings &presentationSettings) {
 	_presentationSettings.bitsPerPixel = presentationSettings.bitsPerPixel;
 	if (_presentationSettings.bitsPerPixel != 8 && _presentationSettings.bitsPerPixel != 16) {
@@ -7455,6 +7459,14 @@ void Project::loadAssetCatalog(const Data::AssetCatalog &assetCatalog) {
 				_assetNameToID[assetDesc.name] = assetDesc.id;
 		}
 	}
+
+	if (assetCatalog.getRevision() <= 2)
+		_guessedVersion = MTropolisVersions::kMTropolisVersion1_0;
+	else if (assetCatalog.getRevision() <= 4)
+		_guessedVersion = MTropolisVersions::kMTropolisVersion1_1;
+	else
+		_guessedVersion = MTropolisVersions::kMTropolisVersion2_0;
+
 }
 
 void Project::loadGlobalObjectInfo(ChildLoaderStack &loaderStack, const Data::GlobalObjectInfo& globalObjectInfo) {
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index 508c47ad685..efbb305f5ae 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -327,6 +327,16 @@ bool isCommand(EventID eventID);
 
 } // End of namespace EventIDs
 
+namespace MTropolisVersions {
+
+enum MTropolisVersion {
+	kMTropolisVersion1_0,
+	kMTropolisVersion1_1,
+	kMTropolisVersion2_0,
+};
+
+} // End of namespace MTropolisVersions
+
 MiniscriptInstructionOutcome pointWriteRefAttrib(Common::Point &point, MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib);
 Common::String pointToString(const Common::Point &point);
 
@@ -1559,8 +1569,10 @@ public:
 
 	const byte *getPalette() const;
 
+	static const uint kNumColors = 256;
+
 private:
-	byte _colors[256 * 3];
+	byte _colors[kNumColors * 3];
 };
 
 class Runtime {
@@ -2415,6 +2427,8 @@ public:
 
 	const SubtitleTables &getSubtitles() const;
 
+	MTropolisVersions::MTropolisVersion guessVersion() const;
+
 #ifdef MTROPOLIS_DEBUG_ENABLE
 	const char *debugGetTypeName() const override { return "Project"; }
 #endif
@@ -2527,6 +2541,8 @@ private:
 	Common::SharedPtr<KeyboardEventSignaller> _keyboardEventSignaller;
 
 	SubtitleTables _subtitles;
+
+	MTropolisVersions::MTropolisVersion _guessedVersion;
 };
 
 class Section : public Structural {


Commit: a4856ca1ba978ab7a0bfb8064269ff3526457a80
    https://github.com/scummvm/scummvm/commit/a4856ca1ba978ab7a0bfb8064269ff3526457a80
Author: elasota (ejlasota at gmail.com)
Date: 2023-06-09T01:03:33-04:00

Commit Message:
MTROPOLIS: Show object RTID in debug info

Changed paths:
    engines/mtropolis/plugin/standard.cpp


diff --git a/engines/mtropolis/plugin/standard.cpp b/engines/mtropolis/plugin/standard.cpp
index cef9d5aa2fd..4389a306035 100644
--- a/engines/mtropolis/plugin/standard.cpp
+++ b/engines/mtropolis/plugin/standard.cpp
@@ -3017,9 +3017,14 @@ void ListVariableModifier::debugInspect(IDebugInspectionReport *report) const {
 		case DynamicValueTypes::kList:
 			report->declareLoose(Common::String::format("[%i] = List", cardinal));
 			break;
-		case DynamicValueTypes::kObject:
-			report->declareLoose(Common::String::format("[%i] = Object?", cardinal));
-			break;
+		case DynamicValueTypes::kObject: {
+				RuntimeObject *obj = storage->_list->getObjectReference()[i].object.lock().get();
+
+				if (obj)
+					report->declareLoose(Common::String::format("[%i] = Object %x", cardinal, static_cast<uint>(obj->getRuntimeGUID())));
+				else
+					report->declareLoose(Common::String::format("[%i] = Object (Invalid)", cardinal));
+			} break;
 		default:
 			report->declareLoose(Common::String::format("[%i] = <BAD TYPE>", cardinal));
 			break;




More information about the Scummvm-git-logs mailing list