[Scummvm-git-logs] scummvm master -> 3641caa67eae91b0db58e0a01d8506d0b367dbce
aquadran
noreply at scummvm.org
Sat Aug 9 20:20:22 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
3641caa67e WINTERMUTE: Added displacement plugin
Commit: 3641caa67eae91b0db58e0a01d8506d0b367dbce
https://github.com/scummvm/scummvm/commit/3641caa67eae91b0db58e0a01d8506d0b367dbce
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2025-08-09T22:20:14+02:00
Commit Message:
WINTERMUTE: Added displacement plugin
Changed paths:
A engines/wintermute/ext/wme_displacement.cpp
A engines/wintermute/ext/wme_displacement.h
engines/wintermute/ext/plugins.h
engines/wintermute/module.mk
engines/wintermute/persistent.cpp
diff --git a/engines/wintermute/ext/plugins.h b/engines/wintermute/ext/plugins.h
index 9d1c222ca01..ca232e53154 100644
--- a/engines/wintermute/ext/plugins.h
+++ b/engines/wintermute/ext/plugins.h
@@ -43,6 +43,7 @@ BaseScriptable *makeSXSample(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXVlink(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXBlackAndWhite(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXShadowManager(BaseGame *inGame, ScStack *stack);
+BaseScriptable *makeSXDisplacement(BaseGame *inGame, ScStack *stack);
bool EmulatePluginCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, char *name) {
ScValue *thisObj;
@@ -107,6 +108,18 @@ bool EmulatePluginCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, cha
return STATUS_OK;
}
+ //////////////////////////////////////////////////////////////////////////
+ // Displacement plugin (from wme_displacement.dll for "Beyond the Threshold" game)
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "Displacement") == 0) {
+ thisObj = thisStack->getTop();
+
+ thisObj->setNative(makeSXDisplacement(inGame, stack));
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
//////////////////////////////////////////////////////////////////////////
// BinkVideo player (from wme_vlink.dll of "Sunrise" game)
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/ext/wme_displacement.cpp b/engines/wintermute/ext/wme_displacement.cpp
new file mode 100644
index 00000000000..2ebd75686d9
--- /dev/null
+++ b/engines/wintermute/ext/wme_displacement.cpp
@@ -0,0 +1,243 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "engines/metaengine.h"
+#include "engines/wintermute/wintermute.h"
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_engine.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/ext/wme_displacement.h"
+
+namespace Wintermute {
+
+IMPLEMENT_PERSISTENT(SXDisplacement, false)
+
+BaseScriptable *makeSXDisplacement(BaseGame *inGame, ScStack *stack) {
+ return new SXDisplacement(inGame, stack);
+}
+
+//////////////////////////////////////////////////////////////////////////
+SXDisplacement::SXDisplacement(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
+ stack->correctParams(5);
+
+ _subFrameSrc = static_cast<BaseSubFrame *>(stack->pop()->getNative());
+ _subFrameDst = static_cast<BaseSubFrame *>(stack->pop()->getNative());
+ _forceX = stack->pop()->getInt();
+ _forceY = stack->pop()->getInt();
+ _speed = stack->pop()->getInt();
+ _animIndex = 0;
+
+ for (int32 i = 0; i < 1024; i++) {
+ _tableX[i] = sin(i * 6.283 / 128.0);
+ _tableY[i] = cos(i * 6.283 / 128.0);
+ }
+
+ int32 width = _subFrameSrc->getWidth();
+ int32 height = _subFrameSrc->getHeight();
+
+ _subFrameSrc->startPixelOperations();
+ _subFrameDst->startPixelOperations();
+
+ for (int32 y = 0; y < height; y++) {
+ for (int32 x = 0; x < width; x++) {
+ uint32 pixel = _subFrameSrc->getPixel(x, y);
+ _subFrameDst->putPixel(x, y, pixel);
+ }
+ }
+
+ _subFrameSrc->endPixelOperations();
+ _subFrameDst->endPixelOperations();
+}
+
+//////////////////////////////////////////////////////////////////////////
+SXDisplacement::~SXDisplacement() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+const char *SXDisplacement::scToString() {
+ return "[displacement object]";
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool SXDisplacement::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
+ //////////////////////////////////////////////////////////////////////////
+ // SetMe()
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "SetMe") == 0) {
+ stack->correctParams(2);
+
+ _subFrameSrc = static_cast<BaseSubFrame *>(stack->pop()->getNative());
+ _subFrameDst = static_cast<BaseSubFrame *>(stack->pop()->getNative());
+
+ stack->pushBool(false);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Setforces()
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "Setforces") == 0) {
+ stack->correctParams(3);
+
+ _forceX = stack->pop()->getInt();
+ _forceY = stack->pop()->getInt();
+ _speed = stack->pop()->getInt();
+
+ stack->pushBool(false);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Animate()
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "Animate") == 0) {
+ stack->correctParams(0);
+
+ if (_subFrameSrc) {
+ int32 width = _subFrameSrc->getWidth();
+ int32 height = _subFrameSrc->getHeight();
+
+ _subFrameSrc->startPixelOperations();
+ _subFrameDst->startPixelOperations();
+
+ for (int32 y = 0; y < height; y++) {
+ for (int32 x = 0; x < width; x++) {
+ uint32 pixel = _subFrameSrc->getPixel(x, y);
+ _subFrameDst->putPixel(x, y, pixel);
+ }
+ }
+
+ _animIndex += _speed;
+ if (_animIndex > 128)
+ _animIndex = 0;
+
+ for (int32 y = 0; y < height; y++) {
+ for (int32 x = 0; x < width; x++) {
+ uint32 pixel = _subFrameSrc->getPixel(x, y);
+ int32 offsetX = (int32)(_forceX * _tableX[_animIndex + x]);
+ int32 offsetY = (int32)(_forceY * _tableY[_animIndex + y]);
+ if (width > (x + offsetX) &&
+ height > (y + offsetY) &&
+ (x + offsetX) >= 0 &&
+ (y + offsetY) >= 0) {
+ _subFrameDst->putPixel(x + offsetX, y + offsetY, pixel);
+ }
+ }
+ }
+
+ _subFrameSrc->endPixelOperations();
+ _subFrameDst->endPixelOperations();
+
+ stack->pushBool(true);
+ return STATUS_OK;
+ } else {
+ stack->pushBool(false);
+ }
+ }
+
+ return STATUS_FAILED;
+}
+
+//////////////////////////////////////////////////////////////////////////
+ScValue *SXDisplacement::scGetProperty(const Common::String &name) {
+ _scValue->setNULL();
+
+ //////////////////////////////////////////////////////////////////////////
+ // ForceX
+ //////////////////////////////////////////////////////////////////////////
+ if (name == "ForceX") {
+ _scValue->setInt(_forceX);
+ return _scValue;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // ForceY
+ //////////////////////////////////////////////////////////////////////////
+ if (name == "ForceY") {
+ _scValue->setInt(_forceY);
+ return _scValue;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Speed
+ //////////////////////////////////////////////////////////////////////////
+ if (name == "Speed") {
+ _scValue->setInt(_speed);
+ return _scValue;
+ }
+
+ else {
+ return _scValue;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool SXDisplacement::scSetProperty(const char *name, ScValue *value) {
+ //////////////////////////////////////////////////////////////////////////
+ // ForceX
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "ForceX") == 0) {
+ _forceX = _scValue->getInt();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // ForceY
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "ForceY") == 0) {
+ _forceY = _scValue->getInt();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Speed
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "Speed") == 0) {
+ _speed = _scValue->getInt();
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool SXDisplacement::persist(BasePersistenceManager *persistMgr) {
+ BaseScriptable::persist(persistMgr);
+
+ persistMgr->transferPtr(TMEMBER_PTR(_subFrameSrc));
+ persistMgr->transferPtr(TMEMBER_PTR(_subFrameDst));
+ persistMgr->transferSint32(TMEMBER(_forceX));
+ persistMgr->transferSint32(TMEMBER(_forceY));
+ persistMgr->transferSint32(TMEMBER(_speed));
+ persistMgr->transferSint32(TMEMBER(_animIndex));
+
+ if (!persistMgr->getIsSaving()) {
+ for (int32 i = 0; i < 1024; i++) {
+ _tableX[i] = sin(i * 6.283 / 128.0);
+ _tableY[i] = cos(i * 6.283 / 128.0);
+ }
+ }
+
+ return STATUS_OK;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/wme_displacement.h b/engines/wintermute/ext/wme_displacement.h
new file mode 100644
index 00000000000..a085612dda8
--- /dev/null
+++ b/engines/wintermute/ext/wme_displacement.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef WINTERMUTE_DISPLACEMENT_H
+#define WINTERMUTE_DISPLACEMENT_H
+
+#include "common/str.h"
+#include "engines/wintermute/base/base_scriptable.h"
+#include "engines/wintermute/base/base_sub_frame.h"
+
+namespace Wintermute {
+
+class SXDisplacement : public BaseScriptable {
+public:
+ DECLARE_PERSISTENT(SXDisplacement, BaseScriptable)
+ ScValue *scGetProperty(const Common::String &name) override;
+ bool scSetProperty(const char *name, ScValue *value) override;
+ bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
+ const char *scToString() override;
+ SXDisplacement(BaseGame *inGame, ScStack *stack);
+ ~SXDisplacement() override;
+private:
+ BaseSubFrame *_subFrameSrc;
+ BaseSubFrame *_subFrameDst;
+ int32 _forceX;
+ int32 _forceY;
+ int32 _speed;
+ int32 _animIndex;
+ double _tableX[1024];
+ double _tableY[1024];
+};
+
+} // End of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index 58f2783fe2b..71080bf5891 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -105,6 +105,7 @@ MODULE_OBJS := \
ext/scene_achievements.o \
ext/wme_3fstatistics.o \
ext/wme_commandlinehelper.o \
+ ext/wme_displacement.o \
ext/wme_galaxy.o \
ext/wme_steam.o \
ext/wme_windowmode.o \
diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp
index 394dba95369..be87fc95c37 100644
--- a/engines/wintermute/persistent.cpp
+++ b/engines/wintermute/persistent.cpp
@@ -82,6 +82,7 @@
#include "engines/wintermute/base/scriptables/script_ext_string.h"
#include "engines/wintermute/ext/wme_3fstatistics.h"
#include "engines/wintermute/ext/wme_commandlinehelper.h"
+#include "engines/wintermute/ext/wme_displacement.h"
#include "engines/wintermute/ext/wme_steam.h"
#include "engines/wintermute/ext/wme_galaxy.h"
#include "engines/wintermute/ext/wme_vlink.h"
@@ -177,6 +178,7 @@ void SystemClassRegistry::registerClasses() {
REGISTER_CLASS(SXSteamAPI, false)
REGISTER_CLASS(SXWMEGalaxyAPI, false)
REGISTER_CLASS(SXCommandLineHelper, false)
+ REGISTER_CLASS(SXDisplacement, false)
REGISTER_CLASS(UIButton, false)
REGISTER_CLASS(UIEdit, false)
More information about the Scummvm-git-logs
mailing list