[Scummvm-git-logs] scummvm master -> 93b5d8f5130fcf259000cc0c144f3648bc200145
elasota
noreply at scummvm.org
Wed Jun 14 05:57:06 UTC 2023
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:
baeff6a736 MTROPOLIS: Add hack to get MTI molasses wipe-off section working
9661324ee4 MTROPOLIS: Fix molasses hack to remove transparent strip on the right side of the screen
93b5d8f513 MTROPOLIS: Add simple motion modifier bounce behavior
Commit: baeff6a73609e22adcb27e18aa78bed5b12a308d
https://github.com/scummvm/scummvm/commit/baeff6a73609e22adcb27e18aa78bed5b12a308d
Author: elasota (ejlasota at gmail.com)
Date: 2023-06-14T01:56:36-04:00
Commit Message:
MTROPOLIS: Add hack to get MTI molasses wipe-off section working
Changed paths:
engines/mtropolis/elements.cpp
engines/mtropolis/hacks.cpp
engines/mtropolis/runtime.cpp
engines/mtropolis/runtime.h
diff --git a/engines/mtropolis/elements.cpp b/engines/mtropolis/elements.cpp
index b8e90754651..ffaeec4bf97 100644
--- a/engines/mtropolis/elements.cpp
+++ b/engines/mtropolis/elements.cpp
@@ -1584,7 +1584,7 @@ VThreadState MToonElement::stopPlayingTask(const StopPlayingTaskData &taskData)
}
if (_hooks)
- _hooks->onStopPlayingMToon(this, _visible, _isStopped);
+ _hooks->onStopPlayingMToon(this, _visible, _isStopped, _renderSurface.get());
return kVThreadReturn;
}
diff --git a/engines/mtropolis/hacks.cpp b/engines/mtropolis/hacks.cpp
index 382351f7f29..bed680d7d0b 100644
--- a/engines/mtropolis/hacks.cpp
+++ b/engines/mtropolis/hacks.cpp
@@ -1023,10 +1023,119 @@ void addObsidianSaveMechanism(const MTropolisGameDescription &desc, Hacks &hacks
hacks.addSaveLoadMechanismHooks(mechanism);
}
+class MTIMolassesHandler : public IPostEffect {
+public:
+ void setFullScreenSurface(const Graphics::ManagedSurface &srcSurf);
+ void wipeRect(const Common::Rect &rect);
+ void setInitialRect(const Common::Rect &rect);
+
+ void release();
+
+ void renderPostEffect(Graphics::ManagedSurface &surface) const override;
+
+private:
+ Graphics::ManagedSurface _surf;
+ Common::Rect _initialRect;
+};
+
+void MTIMolassesHandler::setFullScreenSurface(const Graphics::ManagedSurface &srcSurf) {
+ _surf.copyFrom(srcSurf);
+ wipeRect(_initialRect);
+}
+
+void MTIMolassesHandler::wipeRect(const Common::Rect &rect) {
+ _surf.fillRect(rect, 0);
+}
+
+void MTIMolassesHandler::setInitialRect(const Common::Rect &rect) {
+ _initialRect = rect;
+}
+
+void MTIMolassesHandler::release() {
+ _surf.free();
+}
+
+void MTIMolassesHandler::renderPostEffect(Graphics::ManagedSurface &surface) const {
+ surface.transBlitFrom(_surf, Common::Point(0, 0), 0);
+}
+
+class MTIMolassesFullscreenHooks : public StructuralHooks {
+public:
+ explicit MTIMolassesFullscreenHooks(const Common::SharedPtr<MTIMolassesHandler> &molassesHandler);
+
+ void onStopPlayingMToon(Structural *structural, bool &hide, bool &stopped, Graphics::ManagedSurface *lastSurf) override;
+
+private:
+ Common::SharedPtr<MTIMolassesHandler> _molassesHandler;
+};
+
+MTIMolassesFullscreenHooks::MTIMolassesFullscreenHooks(const Common::SharedPtr<MTIMolassesHandler> &molassesHandler) : _molassesHandler(molassesHandler) {
+}
+
+void MTIMolassesFullscreenHooks::onStopPlayingMToon(Structural *structural, bool &hide, bool &stopped, Graphics::ManagedSurface *lastSurf) {
+ _molassesHandler->setFullScreenSurface(*lastSurf);
+}
+
+class MTIMolassesSpongeHooks : public StructuralHooks {
+public:
+ explicit MTIMolassesSpongeHooks(const Common::SharedPtr<MTIMolassesHandler> &molassesHandler);
+
+ void onPostActivate(Structural *structural) override;
+ void onSetPosition(Runtime *runtime, Structural *structural, const Common::Point &oldPt, Common::Point &pt) override;
+
+private:
+ Common::SharedPtr<MTIMolassesHandler> _molassesHandler;
+};
+
+MTIMolassesSpongeHooks::MTIMolassesSpongeHooks(const Common::SharedPtr<MTIMolassesHandler> &molassesHandler) : _molassesHandler(molassesHandler) {
+}
+
+void MTIMolassesSpongeHooks::onPostActivate(Structural *structural) {
+ VisualElement *visual = static_cast<VisualElement *>(structural);
+
+ _molassesHandler->setInitialRect(visual->getRelativeRect());
+}
+
+void MTIMolassesSpongeHooks::onSetPosition(Runtime *runtime, Structural *structural, const Common::Point &oldPt, Common::Point &pt) {
+ const Common::Rect relRect = static_cast<VisualElement *>(structural)->getRelativeRect();
+
+ int16 w = relRect.width();
+ int16 h = relRect.height();
+
+ Common::Rect wipeRect = Common::Rect(pt.x, pt.y, pt.x + w, pt.y + h);
+
+ _molassesHandler->wipeRect(wipeRect);
+}
+
+class MTIMolassesSceneTransitionHooks : public SceneTransitionHooks {
+public:
+ explicit MTIMolassesSceneTransitionHooks(const Common::SharedPtr<MTIMolassesHandler> &molassesHandler);
+
+ void onSceneTransitionSetup(Runtime *runtime, const Common::WeakPtr<Structural> &oldScene, const Common::WeakPtr<Structural> &newScene) override;
+
+private:
+ Common::SharedPtr<MTIMolassesHandler> _molassesHandler;
+};
+
+MTIMolassesSceneTransitionHooks::MTIMolassesSceneTransitionHooks(const Common::SharedPtr<MTIMolassesHandler> &molassesHandler) : _molassesHandler(molassesHandler) {
+}
+
+void MTIMolassesSceneTransitionHooks::onSceneTransitionSetup(Runtime *runtime, const Common::WeakPtr<Structural> &oldScene, const Common::WeakPtr<Structural> &newScene) {
+ Structural *oldScenePtr = oldScene.lock().get();
+ Structural *newScenePtr = newScene.lock().get();
+
+ const char *molassesSceneName = "B01c: Molasses";
+
+ if (oldScenePtr && oldScenePtr->getName() == molassesSceneName)
+ runtime->removePostEffect(_molassesHandler.get());
+ else if (newScenePtr && newScenePtr->getName() == molassesSceneName)
+ runtime->addPostEffect(_molassesHandler.get());
+}
+
class MTIBuggyAnimationHooks : public StructuralHooks {
public:
void onSetPosition(Runtime *runtime, Structural *structural, const Common::Point &oldPt, Common::Point &pt) override;
- void onStopPlayingMToon(Structural *structural, bool &hide, bool &stopped) override;
+ void onStopPlayingMToon(Structural *structural, bool &hide, bool &stopped, Graphics::ManagedSurface *lastSurf) override;
void onHidden(Structural *structural, bool &visible) override;
};
@@ -1036,7 +1145,7 @@ void MTIBuggyAnimationHooks::onSetPosition(Runtime *runtime, Structural *structu
pt = oldPt;
}
-void MTIBuggyAnimationHooks::onStopPlayingMToon(Structural *structural, bool &visible, bool &stopped) {
+void MTIBuggyAnimationHooks::onStopPlayingMToon(Structural *structural, bool &visible, bool &stopped, Graphics::ManagedSurface *lastSurf) {
// Un-stop
visible = true;
stopped = false;
@@ -1049,9 +1158,17 @@ void MTIBuggyAnimationHooks::onHidden(Structural *structural, bool &visible) {
class MTIStructuralHooks : public StructuralHooks {
public:
+ explicit MTIStructuralHooks(const Common::SharedPtr<MTIMolassesHandler> &molassesHandler);
+
void onPostActivate(Structural *structural) override;
+
+private:
+ Common::SharedPtr<MTIMolassesHandler> _molassesHandler;
};
+MTIStructuralHooks::MTIStructuralHooks(const Common::SharedPtr<MTIMolassesHandler> &molassesHandler) : _molassesHandler(molassesHandler) {
+}
+
void MTIStructuralHooks::onPostActivate(Structural *structural) {
const Common::String &name = structural->getName();
@@ -1068,6 +1185,11 @@ void MTIStructuralHooks::onPostActivate(Structural *structural) {
// - Molasses when leaving Benbow (A08agp01.tun)
// - Long John Silver in the life boat when disembarking the Hispaniola (C01c0005.tun and C01c0005a.tun)
structural->setHooks(Common::SharedPtr<StructuralHooks>(new MTIBuggyAnimationHooks()));
+ } else if (name == "B01cgp01.tun") {
+ structural->setHooks(Common::SharedPtr<StructuralHooks>(new MTIMolassesFullscreenHooks(_molassesHandler)));
+ } else if (name == "B01c_newsponge.tun") {
+ structural->setHooks(Common::SharedPtr<StructuralHooks>(new MTIMolassesSpongeHooks(_molassesHandler)));
+ structural->getHooks()->onPostActivate(structural);
}
}
@@ -1108,7 +1230,10 @@ void addMTIQuirks(const MTropolisGameDescription &desc, Hacks &hacks) {
// which causes an integrity check failure when disembarking the Hispaniola.
hacks.mtiHispaniolaDamagedStringHack = true;
- hacks.defaultStructuralHooks.reset(new MTIStructuralHooks());
+ Common::SharedPtr<MTIMolassesHandler> molassesHandler(new MTIMolassesHandler());
+
+ hacks.defaultStructuralHooks.reset(new MTIStructuralHooks(molassesHandler));
+ hacks.addSceneTransitionHooks(Common::SharedPtr<SceneTransitionHooks>(new MTIMolassesSceneTransitionHooks(molassesHandler)));
}
} // End of namespace HackSuites
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 371f612cca4..b4b66a55c47 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -2982,7 +2982,7 @@ void StructuralHooks::onPostActivate(Structural *structural) {
void StructuralHooks::onSetPosition(Runtime *runtime, Structural *structural, const Common::Point &oldPt, Common::Point &pt) {
}
-void StructuralHooks::onStopPlayingMToon(Structural *structural, bool &visible, bool &stopped) {
+void StructuralHooks::onStopPlayingMToon(Structural *structural, bool &visible, bool &stopped, Graphics::ManagedSurface *lastSurf) {
}
void StructuralHooks::onHidden(Structural *structural, bool &visible) {
@@ -8447,6 +8447,9 @@ void VisualElement::handleDragMotion(Runtime *runtime, const Common::Point &init
if (targetPoint.y > maxY)
targetPoint.y = maxY;
+ if (_hooks)
+ _hooks->onSetPosition(runtime, this, Common::Point(_rect.left, _rect.top), targetPoint);
+
offsetTranslate(targetPoint.x - _rect.left, targetPoint.y - _rect.top, false);
}
}
@@ -9398,7 +9401,7 @@ void VariableModifier::debugInspect(IDebugInspectionReport *report) const {
Modifier::debugInspect(report);
if (report->declareStatic("storage"))
- report->declareStaticContents(Common::String::format("%p", (void *)_storage.get()));
+ report->declareStaticContents(Common::String::format("%p", static_cast<void *>(_storage.get())));
}
#endif
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index 32117380a6a..6129694b9e3 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -2128,7 +2128,7 @@ public:
virtual void onCreate(Structural *structural);
virtual void onPostActivate(Structural *structural);
virtual void onSetPosition(Runtime *runtime, Structural *structural, const Common::Point &oldPt, Common::Point &pt);
- virtual void onStopPlayingMToon(Structural *structural, bool &visible, bool &stopped);
+ virtual void onStopPlayingMToon(Structural *structural, bool &visible, bool &stopped, Graphics::ManagedSurface *lastSurf);
virtual void onHidden(Structural *structural, bool &visible);
};
Commit: 9661324ee4fb9e8ea8f6c22915f39d2a8300ea75
https://github.com/scummvm/scummvm/commit/9661324ee4fb9e8ea8f6c22915f39d2a8300ea75
Author: elasota (ejlasota at gmail.com)
Date: 2023-06-14T01:56:36-04:00
Commit Message:
MTROPOLIS: Fix molasses hack to remove transparent strip on the right side of the screen
Changed paths:
engines/mtropolis/hacks.cpp
diff --git a/engines/mtropolis/hacks.cpp b/engines/mtropolis/hacks.cpp
index bed680d7d0b..ef5a9badf01 100644
--- a/engines/mtropolis/hacks.cpp
+++ b/engines/mtropolis/hacks.cpp
@@ -1035,16 +1035,20 @@ public:
private:
Graphics::ManagedSurface _surf;
+ Graphics::ManagedSurface _mask;
Common::Rect _initialRect;
};
void MTIMolassesHandler::setFullScreenSurface(const Graphics::ManagedSurface &srcSurf) {
_surf.copyFrom(srcSurf);
+ _mask.create(srcSurf.w, srcSurf.h, Graphics::PixelFormat::createFormatCLUT8());
+ _mask.fillRect(Common::Rect(0, 0, srcSurf.w, srcSurf.h), 0xff);
+
wipeRect(_initialRect);
}
void MTIMolassesHandler::wipeRect(const Common::Rect &rect) {
- _surf.fillRect(rect, 0);
+ _mask.fillRect(rect, 0);
}
void MTIMolassesHandler::setInitialRect(const Common::Rect &rect) {
@@ -1053,10 +1057,11 @@ void MTIMolassesHandler::setInitialRect(const Common::Rect &rect) {
void MTIMolassesHandler::release() {
_surf.free();
+ _mask.free();
}
void MTIMolassesHandler::renderPostEffect(Graphics::ManagedSurface &surface) const {
- surface.transBlitFrom(_surf, Common::Point(0, 0), 0);
+ surface.transBlitFrom(_surf, Common::Point(0, 0), _mask);
}
class MTIMolassesFullscreenHooks : public StructuralHooks {
Commit: 93b5d8f5130fcf259000cc0c144f3648bc200145
https://github.com/scummvm/scummvm/commit/93b5d8f5130fcf259000cc0c144f3648bc200145
Author: elasota (ejlasota at gmail.com)
Date: 2023-06-14T01:56:37-04:00
Commit Message:
MTROPOLIS: Add simple motion modifier bounce behavior
Changed paths:
engines/mtropolis/modifiers.cpp
engines/mtropolis/modifiers.h
diff --git a/engines/mtropolis/modifiers.cpp b/engines/mtropolis/modifiers.cpp
index bf156a209ea..c9304542daf 100644
--- a/engines/mtropolis/modifiers.cpp
+++ b/engines/mtropolis/modifiers.cpp
@@ -20,6 +20,7 @@
*/
#include "common/memstream.h"
+#include "common/random.h"
#include "graphics/managed_surface.h"
#include "graphics/palette.h"
@@ -1162,7 +1163,14 @@ const char *PathMotionModifier::getDefaultName() const {
return "Path Motion Modifier";
}
-SimpleMotionModifier::SimpleMotionModifier() : _motionType(kMotionTypeIntoScene), _directionFlags(0), _steps(0)/*, _delayMSecTimes4800(0)*/ {
+SimpleMotionModifier::SimpleMotionModifier() : _motionType(kMotionTypeIntoScene), _directionFlags(0), _steps(0), _delayMSecTimes4800(0), _lastTickTime(0) {
+}
+
+SimpleMotionModifier::~SimpleMotionModifier() {
+ if (_scheduledEvent) {
+ _scheduledEvent->cancel();
+ _scheduledEvent.reset();
+ }
}
bool SimpleMotionModifier::load(ModifierLoaderContext &context, const Data::SimpleMotionModifier &data) {
@@ -1175,6 +1183,7 @@ bool SimpleMotionModifier::load(ModifierLoaderContext &context, const Data::Simp
_directionFlags = data.directionFlags;
_steps = data.steps;
_motionType = static_cast<MotionType>(data.motionType);
+ _delayMSecTimes4800 = data.delayMSecTimes4800;
return true;
}
@@ -1185,23 +1194,109 @@ bool SimpleMotionModifier::respondsToEvent(const Event &evt) const {
VThreadState SimpleMotionModifier::consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) {
if (_executeWhen.respondsTo(msg->getEvent())) {
+ if (!_scheduledEvent) {
+ if (_motionType == kMotionTypeRandomBounce)
+ startRandomBounce(runtime);
+ else {
#ifdef MTROPOLIS_DEBUG_ENABLE
- if (Debugger *debugger = runtime->debugGetDebugger())
- debugger->notify(kDebugSeverityError, "Simple Motion Modifier was supposed to execute, but is not implemented");
+ if (Debugger *debugger = runtime->debugGetDebugger())
+ debugger->notifyFmt(kDebugSeverityError, "Simple motion modifier was activated with an unsupported motion type");
#endif
+ }
+ }
return kVThreadReturn;
}
if (_terminateWhen.respondsTo(msg->getEvent())) {
-#ifdef MTROPOLIS_DEBUG_ENABLE
- if (Debugger *debugger = runtime->debugGetDebugger())
- debugger->notify(kDebugSeverityError, "Simple Motion Modifier was supposed to terminate, but is not implemented");
-#endif
+ disable(runtime);
return kVThreadReturn;
}
return kVThreadReturn;
}
void SimpleMotionModifier::disable(Runtime *runtime) {
+ if (_scheduledEvent) {
+ _scheduledEvent->cancel();
+ _scheduledEvent.reset();
+ }
+}
+
+void SimpleMotionModifier::startRandomBounce(Runtime *runtime) {
+ _velocity = Common::Point(24, 24); // Seems to be static
+ _lastTickTime = runtime->getPlayTime();
+
+ _scheduledEvent = runtime->getScheduler().scheduleMethod<SimpleMotionModifier, &SimpleMotionModifier::runRandomBounce>(_lastTickTime + 1, this);
+}
+
+void SimpleMotionModifier::runRandomBounce(Runtime *runtime) {
+ uint numTicks = 100;
+
+ uint64 currentTime = runtime->getPlayTime();
+
+ if (_delayMSecTimes4800 > 0) {
+ uint64 ticksToExecute = (currentTime - _lastTickTime) * 4800u / _delayMSecTimes4800;
+
+ if (ticksToExecute < 100) {
+ numTicks = static_cast<uint>(ticksToExecute);
+ _lastTickTime += (static_cast<uint64>(numTicks) * _delayMSecTimes4800 / 4800u);
+ } else {
+ _lastTickTime = currentTime;
+ }
+ }
+
+ if (numTicks > 0) {
+ Structural *structural = this->findStructuralOwner();
+ if (structural && structural->isElement() && static_cast<Element *>(structural)->isVisual()) {
+ VisualElement *visual = static_cast<VisualElement *>(structural);
+
+ const Common::Point initialPosition = visual->getGlobalPosition();
+ Common::Point newPosition = initialPosition;
+
+ Common::Rect relRect = visual->getRelativeRect();
+
+ int32 w = relRect.width();
+ int32 h = relRect.height();
+
+ Window *mainWindow = runtime->getMainWindow().lock().get();
+ if (mainWindow) {
+ int32 windowWidth = mainWindow->getWidth();
+ int32 windowHeight = mainWindow->getHeight();
+
+ for (uint tick = 0; tick < numTicks; tick++) {
+ Common::Rect newRect(newPosition.x + _velocity.x, newPosition.y + _velocity.y, newPosition.x + _velocity.x + w, newPosition.y + _velocity.y + h);
+
+ if (newRect.left < 0) {
+ newRect.translate(-newRect.left, 0);
+ _velocity.x = runtime->getRandom()->getRandomNumber(31) + 1;
+ } else if (newRect.right > windowWidth) {
+ newRect.translate(windowWidth - newRect.right, 0);
+ _velocity.x = -1 - static_cast<int32>(runtime->getRandom()->getRandomNumber(31));
+ }
+
+ if (newRect.top < 0) {
+ newRect.translate(0, -newRect.top);
+ _velocity.y = runtime->getRandom()->getRandomNumber(31) + 1;
+ } else if (newRect.bottom > windowHeight) {
+ newRect.translate(windowHeight - newRect.bottom, 0);
+ _velocity.y = -1 - static_cast<int32>(runtime->getRandom()->getRandomNumber(31));
+ }
+
+ newPosition = Common::Point(newRect.left, newRect.top);
+ _velocity.y++;
+ }
+ }
+
+ if (visual->getHooks())
+ visual->getHooks()->onSetPosition(runtime, visual, initialPosition, newPosition);
+
+ if (newPosition != initialPosition) {
+ VisualElement::OffsetTranslateTaskData *taskData = runtime->getVThread().pushTask("VisualElement::offsetTranslateTask", visual, &VisualElement::offsetTranslateTask);
+ taskData->dx = newPosition.x - initialPosition.x;
+ taskData->dy = newPosition.y - initialPosition.y;
+ }
+ }
+ }
+
+ _scheduledEvent = runtime->getScheduler().scheduleMethod<SimpleMotionModifier, &SimpleMotionModifier::runRandomBounce>(currentTime + 1, this);
}
Common::SharedPtr<Modifier> SimpleMotionModifier::shallowClone() const {
diff --git a/engines/mtropolis/modifiers.h b/engines/mtropolis/modifiers.h
index bc4c5fbc860..56dd9e82474 100644
--- a/engines/mtropolis/modifiers.h
+++ b/engines/mtropolis/modifiers.h
@@ -476,6 +476,7 @@ private:
class SimpleMotionModifier : public Modifier {
public:
SimpleMotionModifier();
+ ~SimpleMotionModifier();
bool load(ModifierLoaderContext &context, const Data::SimpleMotionModifier &data);
@@ -502,6 +503,9 @@ private:
kDirectionFlagLeft = 8,
};
+ void startRandomBounce(Runtime *runtime);
+ void runRandomBounce(Runtime *runtime);
+
Common::SharedPtr<Modifier> shallowClone() const override;
const char *getDefaultName() const override;
@@ -511,7 +515,13 @@ private:
MotionType _motionType;
uint16 _directionFlags;
uint16 _steps;
- //uint32 _delayMSecTimes4800;
+ uint32 _delayMSecTimes4800;
+
+ uint64 _lastTickTime;
+
+ Common::Point _velocity;
+
+ Common::SharedPtr<ScheduledEvent> _scheduledEvent;
};
class DragMotionModifier : public Modifier {
More information about the Scummvm-git-logs
mailing list