[Scummvm-git-logs] scummvm master -> cca4010fc91ef9b2885402f6e40ae06e9cab881d
sev-
noreply at scummvm.org
Tue Nov 24 19:42:27 UTC 2026
This automated email contains information about 18 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
0dff238279 NGI: Added fullpipe-android detection
fdd19f9386 NGI: Loading Full Pipe Android archives
fd1558f9fb NGI: Load the Full Pipe Android project XML
3a9089e5aa NGI: Resolve Android scene IDs from obj.h
96a0d4acc8 NGI: Load and render Android scenes with existing scene objects
a01766f335 NGI: Load Android movement phases from XML
9e6a996940 NGI: Play Android intro sleep movement
8669c3b5d7 NGI: Reuse movement playback for the Android intro
2d97d70cc9 NGI: Fade in the Android intro before starting its animation
12df1848dc NGI: Run Android intro command queues and phase sound cues
e10034ad9b NGI: Play the Android intro across both rooms
a38a2eb386 NGI: Preserve Android texture dimensions when image files are missing
878a04cd64 NGI: Show the first Android chapter dialog after the intro
820089314e NGI: Play the first Android room entrance after the intro
edc11ffc50 NGI: Play Android scene ambience and music from XML
85d7675b67 NGI: Run Android idle movements and queues from scene XML
5366932e92 NGI: Load Android scene motion graphs
cca4010fc9 NGI: Catalogued all PIPE Studio games
Commit: 0dff23827989844830f06faa82836540636fe25a
https://github.com/scummvm/scummvm/commit/0dff23827989844830f06faa82836540636fe25a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:37+01:00
Commit Message:
NGI: Added fullpipe-android detection
Changed paths:
engines/ngi/detection.cpp
engines/ngi/metaengine.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/detection.cpp b/engines/ngi/detection.cpp
index def697905c9..0762b956c36 100644
--- a/engines/ngi/detection.cpp
+++ b/engines/ngi/detection.cpp
@@ -194,6 +194,21 @@ static const NGIGameDescription gameDescriptions[] = {
GID_FULLPIPE
},
+ // Full Pipe Android version
+ {
+ {
+ "fullpipe",
+ nullptr,
+ AD_ENTRY2s("Full-Pipe-v1-0-0.apk", "71f99c6d83f68169695aa30f055d2bab", 48598381,
+ "main.7.com.absolutist.fullpipepremium.obb", "e5570f4162cd1bbbe457eadc5875bcf2", 162825463),
+ Common::UNK_LANG,
+ Common::kPlatformAndroid,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GID_FULLPIPE
+ },
+
{ AD_TABLE_END_MARKER, 0 }
};
diff --git a/engines/ngi/metaengine.cpp b/engines/ngi/metaengine.cpp
index 2b0a57ef97e..0ffbeba46dc 100644
--- a/engines/ngi/metaengine.cpp
+++ b/engines/ngi/metaengine.cpp
@@ -51,6 +51,10 @@ Common::Language NGIEngine::getLanguage() const {
return _gameDescription->desc.language;
}
+Common::Platform NGIEngine::getPlatform() const {
+ return _gameDescription->desc.platform;
+}
+
const char *NGIEngine::getGameId() const {
return _gameDescription->desc.gameId;
}
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 021485c420b..2ce06c69374 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -144,6 +144,7 @@ public:
uint32 getFeatures() const;
bool isDemo();
Common::Language getLanguage() const;
+ Common::Platform getPlatform() const;
const char *getGameId() const;
int getGameGID() const;
Commit: fdd19f93862a338609ca3c4e14d3fab3e7f33b79
https://github.com/scummvm/scummvm/commit/fdd19f93862a338609ca3c4e14d3fab3e7f33b79
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Loading Full Pipe Android archives
Changed paths:
engines/ngi/ngi.cpp
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 179f525cad8..f2cb6639304 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -22,6 +22,7 @@
#include "base/plugins.h"
#include "common/archive.h"
+#include "common/compression/unzip.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "audio/mixer.h"
@@ -240,6 +241,19 @@ Common::String NGIEngine::getSaveStateName(int slot) const {
}
Common::Error NGIEngine::run() {
+ if (getPlatform() == Common::kPlatformAndroid) {
+ const auto &files = _gameDescription->desc.filesDescriptions;
+ const Common::FSNode gameDirectory(ConfMan.getPath("path"));
+ Common::ScopedPtr<Common::Archive> apk(Common::makeZipArchive(gameDirectory.getChild(files[0].fileName)));
+ Common::ScopedPtr<Common::Archive> obb(Common::makeZipArchive(gameDirectory.getChild(files[1].fileName)));
+ if (!apk || !obb)
+ return Common::Error(Common::kNoGameDataFoundError, "Could not open the Full Pipe APK and OBB archives");
+
+ SearchMan.add("ngi-android-obb", obb.release());
+ SearchMan.add("ngi-android-apk", apk.release());
+ return Common::Error(Common::kUnsupportedGameidError, "Full Pipe Android project loading is not implemented");
+ }
+
// Initialize backend
initGraphics(800, 600, nullptr);
Commit: fd1558f9fbcf0c1f90dd116614d09a4828067fee
https://github.com/scummvm/scummvm/commit/fd1558f9fbcf0c1f90dd116614d09a4828067fee
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Load the Full Pipe Android project XML
Changed paths:
engines/ngi/ngi.cpp
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index f2cb6639304..c0a867109af 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -25,6 +25,7 @@
#include "common/compression/unzip.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
+#include "common/formats/xmlparser.h"
#include "audio/mixer.h"
#include "engines/metaengine.h"
@@ -46,6 +47,62 @@
#include "ngi/constants.h"
namespace NGI {
+namespace {
+
+class XMLProjectParser : public Common::XMLParser {
+public:
+ Common::String startSceneFile() const {
+ return _scenes.getValOrDefault(_startScene);
+ }
+
+private:
+ Common::String _startScene;
+ Common::StringMap _scenes;
+
+ CUSTOM_XML_PARSER(XMLProjectParser) {
+ XML_KEY(PROJECT)
+ XML_PROP(title, false)
+ XML_PROP(width, false)
+ XML_PROP(height, false)
+ XML_PROP(screenWidth, false)
+ XML_PROP(screenHeight, false)
+ XML_PROP(dbg_font, false)
+ XML_PROP(start, true)
+ XML_PROP(fullscreen, false)
+ XML_PROP(adjust, false)
+ XML_PROP(create_inv, false)
+ XML_KEY(SCENE)
+ XML_PROP(id, true)
+ XML_PROP(file, true)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_PROJECT(ParserNode *node) {
+ _startScene = node->values["start"];
+ return true;
+ }
+
+ bool parserCallback_SCENE(ParserNode *node) {
+ _scenes[node->values["id"]] = node->values["file"];
+ return true;
+ }
+
+ bool handleUnknownKey(ParserNode *node) override {
+ const auto *parent = getParentNode(node);
+ if (!parent)
+ return false;
+ if (!parent->ignore && (parent->name != "PROJECT" ||
+ (node->name != "DIALOGCONTROLLER" && node->name != "CURSORCONTROLLER")))
+ return false;
+ node->layout = _XMLkeys;
+ node->ignore = true;
+ return true;
+ }
+};
+
+} // End of anonymous namespace
+
NGIEngine *g_nmi = nullptr;
Vars *g_vars = nullptr;
@@ -251,7 +308,19 @@ Common::Error NGIEngine::run() {
SearchMan.add("ngi-android-obb", obb.release());
SearchMan.add("ngi-android-apk", apk.release());
- return Common::Error(Common::kUnsupportedGameidError, "Full Pipe Android project loading is not implemented");
+
+ const Common::Path projectPath("data/FullPipe.xml");
+ XMLProjectParser project;
+ if (!project.loadStream(SearchMan.createReadStreamForMember(projectPath), projectPath.toString()) || !project.parse())
+ return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android project");
+
+ const Common::String startSceneFile = project.startSceneFile();
+ if (startSceneFile.empty() || !SearchMan.hasFile(Common::Path("data/res").join(startSceneFile)))
+ return Common::Error(Common::kNoGameDataFoundError, "Could not find the Full Pipe Android start scene");
+
+ debugC(1, kDebugXML, "Loaded Full Pipe Android project, start scene %s", startSceneFile.c_str());
+ return Common::Error(Common::kUnsupportedGameidError,
+ Common::String::format("Full Pipe Android scene loading is not implemented (%s)", startSceneFile.c_str()));
}
// Initialize backend
Commit: 3a9089e5aa33b2d4ad488b5a30f0823c9b4c6d3d
https://github.com/scummvm/scummvm/commit/3a9089e5aa33b2d4ad488b5a30f0823c9b4c6d3d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Resolve Android scene IDs from obj.h
Changed paths:
engines/ngi/ngi.cpp
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index c0a867109af..cb457e41275 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -25,6 +25,7 @@
#include "common/compression/unzip.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
+#include "common/file.h"
#include "common/formats/xmlparser.h"
#include "audio/mixer.h"
@@ -51,6 +52,8 @@ namespace {
class XMLProjectParser : public Common::XMLParser {
public:
+ const Common::String &startScene() const { return _startScene; }
+
Common::String startSceneFile() const {
return _scenes.getValOrDefault(_startScene);
}
@@ -101,6 +104,46 @@ private:
}
};
+class ObjectIdList {
+public:
+ bool load(const Common::Path &path) {
+ Common::File file;
+ if (!file.open(path))
+ return false;
+
+ while (!file.eos() && !file.err()) {
+ const Common::String line = file.readLine();
+ if (!line.hasPrefix("#define"))
+ continue;
+
+ const char *name = line.c_str() + 7;
+ while (*name == ' ' || *name == '\t')
+ ++name;
+ const char *value = name;
+ while (*value && *value != ' ' && *value != '\t')
+ ++value;
+ if (name == value || !*value)
+ continue;
+
+ const Common::String symbol(name, value);
+ if (!_ids.contains(symbol))
+ _ids[symbol] = strtoul(value, nullptr, 10);
+ }
+ return !file.err();
+ }
+
+ bool findId(const Common::String &symbol, uint32 &id) const {
+ const auto entry = _ids.find(symbol);
+ if (entry == _ids.end())
+ return false;
+ id = entry->_value;
+ return true;
+ }
+
+private:
+ Common::HashMap<Common::String, uint32> _ids;
+};
+
} // End of anonymous namespace
NGIEngine *g_nmi = nullptr;
@@ -314,11 +357,17 @@ Common::Error NGIEngine::run() {
if (!project.loadStream(SearchMan.createReadStreamForMember(projectPath), projectPath.toString()) || !project.parse())
return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android project");
+ ObjectIdList ids;
+ if (!ids.load("data/obj.h"))
+ return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android object IDs");
+
const Common::String startSceneFile = project.startSceneFile();
- if (startSceneFile.empty() || !SearchMan.hasFile(Common::Path("data/res").join(startSceneFile)))
+ uint32 startSceneId;
+ if (!ids.findId(project.startScene(), startSceneId) || startSceneFile.empty() ||
+ !SearchMan.hasFile(Common::Path("data/res").join(startSceneFile)))
return Common::Error(Common::kNoGameDataFoundError, "Could not find the Full Pipe Android start scene");
- debugC(1, kDebugXML, "Loaded Full Pipe Android project, start scene %s", startSceneFile.c_str());
+ debugC(1, kDebugXML, "Loaded Full Pipe Android project, start scene %s (%u)", startSceneFile.c_str(), startSceneId);
return Common::Error(Common::kUnsupportedGameidError,
Common::String::format("Full Pipe Android scene loading is not implemented (%s)", startSceneFile.c_str()));
}
Commit: 96a0d4acc87dbca571654f85e737e586aab22728
https://github.com/scummvm/scummvm/commit/96a0d4acc87dbca571654f85e737e586aab22728
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Load and render Android scenes with existing scene objects
Changed paths:
A engines/ngi/android.cpp
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
new file mode 100644
index 00000000000..e02eb7a62db
--- /dev/null
+++ b/engines/ngi/android.cpp
@@ -0,0 +1,439 @@
+/* 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 "common/algorithm.h"
+#include "common/archive.h"
+#include "common/compression/unzip.h"
+#include "common/config-manager.h"
+#include "common/debug-channels.h"
+#include "common/events.h"
+#include "common/file.h"
+#include "common/formats/xmlparser.h"
+
+#include "engines/util.h"
+#include "ngi/ngi.h"
+#include "ngi/detection.h"
+#include "ngi/messages.h"
+#include "ngi/utils.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/anihandler.h"
+
+namespace NGI {
+
+namespace {
+
+class XMLProjectParser : public Common::XMLParser {
+public:
+ const Common::String &startScene() const { return _startScene; }
+ int width() const { return _width; }
+ int height() const { return _height; }
+
+ Common::String startSceneFile() const {
+ return _scenes.getValOrDefault(_startScene);
+ }
+
+private:
+ Common::String _startScene;
+ Common::StringMap _scenes;
+ int _width = 800;
+ int _height = 600;
+
+ CUSTOM_XML_PARSER(XMLProjectParser) {
+ XML_KEY(PROJECT)
+ XML_PROP(title, false)
+ XML_PROP(width, false)
+ XML_PROP(height, false)
+ XML_PROP(screenWidth, false)
+ XML_PROP(screenHeight, false)
+ XML_PROP(dbg_font, false)
+ XML_PROP(start, true)
+ XML_PROP(fullscreen, false)
+ XML_PROP(adjust, false)
+ XML_PROP(create_inv, false)
+ XML_KEY(SCENE)
+ XML_PROP(id, true)
+ XML_PROP(file, true)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_PROJECT(ParserNode *node) {
+ _startScene = node->values["start"];
+ if (node->values.contains("width"))
+ _width = atoi(node->values["width"].c_str());
+ if (node->values.contains("height"))
+ _height = atoi(node->values["height"].c_str());
+ if (_width <= 0 || _width > 32767 || _height <= 0 || _height > 32767)
+ return parserError("Invalid project dimensions");
+ return true;
+ }
+
+ bool parserCallback_SCENE(ParserNode *node) {
+ _scenes[node->values["id"]] = node->values["file"];
+ return true;
+ }
+
+ bool handleUnknownKey(ParserNode *node) override {
+ const auto *parent = getParentNode(node);
+ if (!parent)
+ return false;
+ if (!parent->ignore && (parent->name != "PROJECT" ||
+ (node->name != "DIALOGCONTROLLER" && node->name != "CURSORCONTROLLER")))
+ return false;
+ node->layout = _XMLkeys;
+ node->ignore = true;
+ return true;
+ }
+};
+
+class ObjectIdList {
+public:
+ bool load(const Common::Path &path) {
+ Common::File file;
+ if (!file.open(path))
+ return false;
+
+ while (!file.eos() && !file.err()) {
+ const Common::String line = file.readLine();
+ if (!line.hasPrefix("#define"))
+ continue;
+
+ const char *name = line.c_str() + 7;
+ while (*name == ' ' || *name == '\t')
+ ++name;
+ const char *value = name;
+ while (*value && *value != ' ' && *value != '\t')
+ ++value;
+ if (name == value || !*value)
+ continue;
+
+ const Common::String symbol(name, value);
+ if (!_ids.contains(symbol))
+ _ids[symbol] = strtoul(value, nullptr, 10);
+ }
+ return !file.err();
+ }
+
+ bool findId(const Common::String &symbol, uint32 &id) const {
+ const auto entry = _ids.find(symbol);
+ if (entry == _ids.end())
+ return false;
+ id = entry->_value;
+ return true;
+ }
+
+private:
+ Common::HashMap<Common::String, uint32> _ids;
+};
+
+static const char *getResourceLocale(Common::Language language) {
+ switch (language) {
+ case Common::DE_DEU:
+ return "de";
+ case Common::RU_RUS:
+ return "ru";
+ default:
+ return "en";
+ }
+}
+
+class XMLSceneParser : public Common::XMLParser {
+public:
+ XMLSceneParser(const ObjectIdList &ids, Scene &scene, const char *locale)
+ : _ids(ids), _scene(scene), _locale(locale) {
+ setAllowText();
+ }
+
+private:
+ const ObjectIdList &_ids;
+ Scene &_scene;
+ const char *_locale;
+ uint _objectOrder = 0;
+ bool _hasInitialStatics = false;
+ int16 _initialStaticsId = 0;
+
+ bool loadTexture(Texture &texture, const Common::String &resource, bool localized) {
+ const Common::String directory = localized ? Common::String::format("data/res_%s", _locale) : "data/res";
+ const Common::Path path = Common::Path(directory).join(resource + ".png");
+ Common::File file;
+ if (!file.open(path) || !texture.loadPNG(file))
+ return parserError("Could not load scene texture " + path.toString());
+
+ const Dims dimensions = texture.getDimensions();
+ debugC(2, kDebugLoading, "Loaded scene texture %s (%d x %d)", path.toString().c_str(), dimensions.x, dimensions.y);
+ return true;
+ }
+
+ CUSTOM_XML_PARSER(XMLSceneParser) {
+ XML_KEY(SCENE)
+ XML_PROP(id, true)
+ XML_PROP(title, false)
+ XML_PROP(width, false)
+ XML_PROP(height, false)
+ XML_PROP(hero, false)
+ XML_PROP(drawOffset, false)
+ XML_PROP(serializable, false)
+ XML_PROP(waitscreen, false)
+ XML_PROP(putPrev, false)
+ XML_PROP(scrollX, false)
+ XML_PROP(scrollY, false)
+ XML_KEY(PICTURE)
+ XML_PROP(id, true)
+ XML_PROP(title, false)
+ XML_PROP(x, false)
+ XML_PROP(y, false)
+ XML_PROP(z, false)
+ XML_PROP(flags, false)
+ XML_PROP(locale, false)
+ KEY_END()
+ XML_KEY(OLDANI)
+ XML_PROP(id, true)
+ XML_PROP(title, false)
+ XML_PROP(x, false)
+ XML_PROP(y, false)
+ XML_PROP(z, false)
+ XML_PROP(flags, false)
+ XML_PROP(locale, false)
+ XML_PROP(static, false)
+ XML_KEY(STATICS)
+ XML_PROP(id, true)
+ XML_PROP(title, false)
+ XML_PROP(x, false)
+ XML_PROP(y, false)
+ XML_PROP(locale, false)
+ KEY_END()
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_SCENE(ParserNode *node) {
+ int16 id;
+ if (!readId(node->values["id"], id) || id != _scene._sceneId)
+ return parserError("Scene ID does not match the project");
+ _scene._sceneName = node->values.getValOrDefault("title");
+ _scene._x = strtod(node->values.getValOrDefault("scrollX").c_str(), nullptr);
+ _scene._y = strtod(node->values.getValOrDefault("scrollY").c_str(), nullptr);
+ return true;
+ }
+
+ bool parserCallback_PICTURE(ParserNode *node) {
+ Common::ScopedPtr<PictureObject> picture(new PictureObject());
+ if (!parseObject(*picture, *node))
+ return false;
+
+ picture->_picture = new Texture();
+ const Common::String resource = Common::String::format("%08hu/%08hu",
+ static_cast<uint16>(_scene._sceneId), static_cast<uint16>(picture->_id));
+ if (!loadTexture(*picture->_picture, resource, isLocalized(*node)))
+ return false;
+ picture->setOXY2();
+ _scene.addPicture(picture.release());
+ return true;
+ }
+
+ bool parserCallback_OLDANI(ParserNode *node) {
+ Common::ScopedPtr<AniObject> animation(new AniObject());
+ if (!parseObject(*animation, *node))
+ return false;
+
+ const Common::String &statics = node->values.getValOrDefault("static");
+ _hasInitialStatics = !statics.empty();
+ if (_hasInitialStatics && !readId(statics, _initialStaticsId))
+ return parserError("Unknown initial statics ID '" + statics + "'");
+
+ animation->_sceneId = _scene._sceneId;
+ // The binary loader clears flags when adding renderables. Keep the XML flags and order.
+ const int16 flags = animation->_flags;
+ const uint order = animation->_cnum;
+ AniObject *object = animation.release();
+ _scene.addAni(object, true);
+ object->_flags = flags;
+ object->_cnum = order;
+ return true;
+ }
+
+ bool parseObject(GameObject &object, ParserNode &node) {
+ if (!readId(node.values["id"], object._id))
+ return parserError("Unknown scene object ID '" + node.values["id"] + "'");
+
+ object._title = node.values.getValOrDefault("title");
+ object._x = strtod(node.values.getValOrDefault("x").c_str(), nullptr);
+ object._y = strtod(node.values.getValOrDefault("y").c_str(), nullptr);
+ object._z = strtod(node.values.getValOrDefault("z").c_str(), nullptr);
+ object._flags = strtoul(node.values.getValOrDefault("flags").c_str(), nullptr, 10);
+ object._cnum = _objectOrder++;
+ return true;
+ }
+
+ bool parserCallback_STATICS(ParserNode *node) {
+ Common::ScopedPtr<Statics> pose(new Statics());
+ if (!readId(node->values["id"], pose->_staticsId))
+ return parserError("Unknown statics ID '" + node->values["id"] + "'");
+
+ pose->_staticsName = node->values.getValOrDefault("title");
+ // AniObject subtracts the anchor when drawing a pose. XML stores the texture offset.
+ pose->_someX = -strtod(node->values.getValOrDefault("x").c_str(), nullptr);
+ pose->_someY = -strtod(node->values.getValOrDefault("y").c_str(), nullptr);
+ AniObject &object = *_scene._aniObjects.back();
+ const Common::String resource = Common::String::format("%08hu/%08hu/%08hu",
+ static_cast<uint16>(_scene._sceneId), static_cast<uint16>(object._id), static_cast<uint16>(pose->_staticsId));
+ if (!loadTexture(*pose, resource, isLocalized(*node)))
+ return false;
+
+ if (_hasInitialStatics ? pose->_staticsId == _initialStaticsId :
+ (!object._statics || static_cast<uint16>(pose->_staticsId) < static_cast<uint16>(object._statics->_staticsId)))
+ object._statics = pose.get();
+ object._staticsList.push_back(pose.release());
+ return true;
+ }
+
+ bool closedKeyCallback(ParserNode *node) override {
+ if (node->name == "OLDANI" && !_scene._aniObjects.back()->_statics)
+ return parserError("Missing initial statics for Android animation");
+ return true;
+ }
+
+ bool readId(const Common::String &name, int16 &id) const {
+ uint32 value;
+ if (!_ids.findId(name, value) || value > 0xffff)
+ return false;
+ id = static_cast<int16>(value);
+ return true;
+ }
+
+ static bool isLocalized(const ParserNode &node) {
+ const Common::String &locale = node.values.getValOrDefault("locale");
+ return locale == "true" || locale == "1";
+ }
+
+ bool handleUnknownKey(ParserNode *node) override {
+ if (!getParentNode(node))
+ return false;
+ // Scene nodes outside the supported object types are ignored for now.
+ node->ignore = true;
+ node->layout = _XMLkeys;
+ return true;
+ }
+
+ bool textCallback(const Common::String &text) override { return true; }
+};
+
+static void drawAndroidScene(const Scene &scene, Graphics::ManagedSurface &target) {
+ Common::Array<const GameObject *> visibleObjects;
+ for (const PictureObject *picture : scene._pictureObjects) {
+ if (picture->_flags & 1)
+ visibleObjects.push_back(picture);
+ }
+ for (const AniObject *animation : scene._renderableAnis) {
+ if (animation->_flags & 1)
+ visibleObjects.push_back(animation);
+ }
+
+ // The Android renderer draws higher z values first and preserves XML order at equal z.
+ Common::sort(visibleObjects.begin(), visibleObjects.end(), [](const GameObject *left, const GameObject *right) {
+ if (left->_z == right->_z)
+ return left->_cnum < right->_cnum;
+ return left->_z > right->_z;
+ });
+
+ for (const GameObject *object : visibleObjects) {
+ Common::Point position(object->_x - scene._x, object->_y - scene._y);
+ if (object->_objtype == kObjTypePictureObject) {
+ static_cast<const PictureObject *>(object)->_picture->blitTo(target, position);
+ } else {
+ const Statics *pose = static_cast<const AniObject *>(object)->_statics;
+ pose->blitTo(target, position - pose->getSomeXY());
+ }
+ }
+}
+
+} // End of anonymous namespace
+
+Common::Error NGIEngine::runAndroid() {
+ const auto &files = _gameDescription->desc.filesDescriptions;
+ const Common::FSNode gameDirectory(ConfMan.getPath("path"));
+ Common::ScopedPtr<Common::Archive> apk(Common::makeZipArchive(gameDirectory.getChild(files[0].fileName)));
+ Common::ScopedPtr<Common::Archive> obb(Common::makeZipArchive(gameDirectory.getChild(files[1].fileName)));
+ if (!apk || !obb)
+ return Common::Error(Common::kNoGameDataFoundError, "Could not open the Full Pipe APK and OBB archives");
+
+ SearchMan.add("ngi-android-obb", obb.release());
+ SearchMan.add("ngi-android-apk", apk.release());
+
+ const Common::Path projectPath("data/FullPipe.xml");
+ XMLProjectParser project;
+ if (!project.loadStream(SearchMan.createReadStreamForMember(projectPath), projectPath.toString()) || !project.parse())
+ return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android project");
+
+ ObjectIdList ids;
+ if (!ids.load("data/obj.h"))
+ return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android object IDs");
+
+ const Common::String startSceneFile = project.startSceneFile();
+ uint32 startSceneId;
+ if (!ids.findId(project.startScene(), startSceneId) || startSceneId > 0xffff || startSceneFile.empty())
+ return Common::Error(Common::kNoGameDataFoundError, "Could not find the Full Pipe Android start scene");
+
+ debugC(1, kDebugXML, "Loaded Full Pipe Android project, start scene %s (%u)", startSceneFile.c_str(), startSceneId);
+
+ Common::Language language = Common::parseLanguage(ConfMan.get("language"));
+ if (language == Common::UNK_LANG)
+ language = Common::parseLanguageFromLocale(_system->getSystemLanguage().c_str());
+
+ _aniHandler.reset(new AniHandler());
+ Scene scene;
+ scene._sceneId = static_cast<int16>(startSceneId);
+ const Common::Path scenePath = Common::Path("data/res").join(startSceneFile);
+ XMLSceneParser sceneParser(ids, scene, getResourceLocale(language));
+ if (!sceneParser.loadStream(SearchMan.createReadStreamForMember(scenePath), scenePath.toString()) || !sceneParser.parse())
+ return Common::Error(Common::kNoGameDataFoundError, "Could not load the Full Pipe Android start scene");
+
+ debugC(1, kDebugXML, "Loaded Full Pipe Android scene %s with %u pictures and %u animations",
+ startSceneFile.c_str(), scene._pictureObjects.size(), scene._aniObjects.size());
+
+ _isSaveAllowed = false;
+ initGraphics(project.width(), project.height(), nullptr);
+ const Graphics::PixelFormat format = _system->getScreenFormat();
+ if (format.isCLUT8())
+ return Common::kUnsupportedColorMode;
+
+ Graphics::ManagedSurface frame(project.width(), project.height(), format);
+ frame.clear(format.RGBToColor(0, 0, 0));
+ drawAndroidScene(scene, frame);
+ _system->copyRectToScreen(frame.getPixels(), frame.pitch, 0, 0, frame.w, frame.h);
+ _system->updateScreen();
+ debugC(1, kDebugDrawing, "Presented first Full Pipe Android frame for %s", startSceneFile.c_str());
+
+ Common::Event event;
+ Common::EventManager *eventManager = _system->getEventManager();
+ while (!shouldQuit()) {
+ while (eventManager->pollEvent(event)) {
+ if (event.type == Common::EVENT_SCREEN_CHANGED)
+ _system->copyRectToScreen(frame.getPixels(), frame.pitch, 0, 0, frame.w, frame.h);
+ }
+ _system->updateScreen();
+ _system->delayMillis(10);
+ }
+ return Common::kNoError;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 4be2b9874a1..f15db9ae1b9 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -31,6 +31,8 @@
#include "common/memstream.h"
#include "graphics/managed_surface.h"
+#include "image/png.h"
+
namespace NGI {
Background::Background() {
@@ -416,6 +418,33 @@ Texture::~Texture() {
freePicture();
}
+bool Texture::loadPNG(Common::SeekableReadStream &stream) {
+ Image::PNGDecoder png;
+ if (!png.loadStream(stream))
+ return false;
+
+ freePicture();
+ const Graphics::Surface &source = *png.getSurface();
+ _width = source.w;
+ _height = source.h;
+ _bitmap.reset(new Bitmap());
+ _bitmap->_width = _width;
+ _bitmap->_height = _height;
+ _bitmap->_surface = new Graphics::ManagedSurface();
+ _bitmap->_surface->copyFrom(source);
+ const Graphics::Palette &palette = png.getPalette();
+ if (!palette.empty())
+ _bitmap->_surface->setPalette(palette.data(), 0, palette.size());
+ if (png.hasTransparentColor())
+ _bitmap->_surface->setTransparentColor(png.getTransparentColor());
+ return true;
+}
+
+void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &position) const {
+ if (_bitmap && _bitmap->_surface)
+ target.blitFrom(*_bitmap->_surface, position);
+}
+
void Texture::freePicture() {
debugC(5, kDebugMemory, "Texture::freePicture(): file: %s", _memfilename.toString().c_str());
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index ffbd7433bbb..50db7286d9b 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -89,6 +89,8 @@ public:
void unload();
bool load(MfcArchive &file) override;
+ bool loadPNG(Common::SeekableReadStream &stream);
+ void blitTo(Graphics::ManagedSurface &target, const Common::Point &position) const;
void setAOIDs();
virtual void init();
void getDibInfo();
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index a9707c2d811..a00b37470ee 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -1,6 +1,7 @@
MODULE := engines/ngi
MODULE_OBJS = \
+ android.o \
anihandler.o \
behavior.o \
console.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index cb457e41275..05ab50ee614 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -22,11 +22,8 @@
#include "base/plugins.h"
#include "common/archive.h"
-#include "common/compression/unzip.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
-#include "common/file.h"
-#include "common/formats/xmlparser.h"
#include "audio/mixer.h"
#include "engines/metaengine.h"
@@ -48,104 +45,6 @@
#include "ngi/constants.h"
namespace NGI {
-namespace {
-
-class XMLProjectParser : public Common::XMLParser {
-public:
- const Common::String &startScene() const { return _startScene; }
-
- Common::String startSceneFile() const {
- return _scenes.getValOrDefault(_startScene);
- }
-
-private:
- Common::String _startScene;
- Common::StringMap _scenes;
-
- CUSTOM_XML_PARSER(XMLProjectParser) {
- XML_KEY(PROJECT)
- XML_PROP(title, false)
- XML_PROP(width, false)
- XML_PROP(height, false)
- XML_PROP(screenWidth, false)
- XML_PROP(screenHeight, false)
- XML_PROP(dbg_font, false)
- XML_PROP(start, true)
- XML_PROP(fullscreen, false)
- XML_PROP(adjust, false)
- XML_PROP(create_inv, false)
- XML_KEY(SCENE)
- XML_PROP(id, true)
- XML_PROP(file, true)
- KEY_END()
- KEY_END()
- } PARSER_END()
-
- bool parserCallback_PROJECT(ParserNode *node) {
- _startScene = node->values["start"];
- return true;
- }
-
- bool parserCallback_SCENE(ParserNode *node) {
- _scenes[node->values["id"]] = node->values["file"];
- return true;
- }
-
- bool handleUnknownKey(ParserNode *node) override {
- const auto *parent = getParentNode(node);
- if (!parent)
- return false;
- if (!parent->ignore && (parent->name != "PROJECT" ||
- (node->name != "DIALOGCONTROLLER" && node->name != "CURSORCONTROLLER")))
- return false;
- node->layout = _XMLkeys;
- node->ignore = true;
- return true;
- }
-};
-
-class ObjectIdList {
-public:
- bool load(const Common::Path &path) {
- Common::File file;
- if (!file.open(path))
- return false;
-
- while (!file.eos() && !file.err()) {
- const Common::String line = file.readLine();
- if (!line.hasPrefix("#define"))
- continue;
-
- const char *name = line.c_str() + 7;
- while (*name == ' ' || *name == '\t')
- ++name;
- const char *value = name;
- while (*value && *value != ' ' && *value != '\t')
- ++value;
- if (name == value || !*value)
- continue;
-
- const Common::String symbol(name, value);
- if (!_ids.contains(symbol))
- _ids[symbol] = strtoul(value, nullptr, 10);
- }
- return !file.err();
- }
-
- bool findId(const Common::String &symbol, uint32 &id) const {
- const auto entry = _ids.find(symbol);
- if (entry == _ids.end())
- return false;
- id = entry->_value;
- return true;
- }
-
-private:
- Common::HashMap<Common::String, uint32> _ids;
-};
-
-} // End of anonymous namespace
-
NGIEngine *g_nmi = nullptr;
Vars *g_vars = nullptr;
@@ -341,36 +240,8 @@ Common::String NGIEngine::getSaveStateName(int slot) const {
}
Common::Error NGIEngine::run() {
- if (getPlatform() == Common::kPlatformAndroid) {
- const auto &files = _gameDescription->desc.filesDescriptions;
- const Common::FSNode gameDirectory(ConfMan.getPath("path"));
- Common::ScopedPtr<Common::Archive> apk(Common::makeZipArchive(gameDirectory.getChild(files[0].fileName)));
- Common::ScopedPtr<Common::Archive> obb(Common::makeZipArchive(gameDirectory.getChild(files[1].fileName)));
- if (!apk || !obb)
- return Common::Error(Common::kNoGameDataFoundError, "Could not open the Full Pipe APK and OBB archives");
-
- SearchMan.add("ngi-android-obb", obb.release());
- SearchMan.add("ngi-android-apk", apk.release());
-
- const Common::Path projectPath("data/FullPipe.xml");
- XMLProjectParser project;
- if (!project.loadStream(SearchMan.createReadStreamForMember(projectPath), projectPath.toString()) || !project.parse())
- return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android project");
-
- ObjectIdList ids;
- if (!ids.load("data/obj.h"))
- return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android object IDs");
-
- const Common::String startSceneFile = project.startSceneFile();
- uint32 startSceneId;
- if (!ids.findId(project.startScene(), startSceneId) || startSceneFile.empty() ||
- !SearchMan.hasFile(Common::Path("data/res").join(startSceneFile)))
- return Common::Error(Common::kNoGameDataFoundError, "Could not find the Full Pipe Android start scene");
-
- debugC(1, kDebugXML, "Loaded Full Pipe Android project, start scene %s (%u)", startSceneFile.c_str(), startSceneId);
- return Common::Error(Common::kUnsupportedGameidError,
- Common::String::format("Full Pipe Android scene loading is not implemented (%s)", startSceneFile.c_str()));
- }
+ if (getPlatform() == Common::kPlatformAndroid)
+ return runAndroid();
// Initialize backend
initGraphics(800, 600, nullptr);
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 2ce06c69374..b4cb16121d0 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -128,6 +128,7 @@ class NGIEngine : public ::Engine {
protected:
Common::Error run() override;
+ Common::Error runAndroid();
public:
NGIEngine(OSystem *syst, const NGIGameDescription *gameDesc);
@@ -386,7 +387,7 @@ public:
Common::Error saveGameState(int slot, const Common::String &description, bool isAutosave = false) override;
Common::String getSaveStateName(int slot) const override;
- bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return true; }
+ bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return getPlatform() != Common::kPlatformAndroid; }
bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
bool hasFeature(EngineFeature f) const override;
Commit: a01766f3359ff15f5fde115317b2098fff8e415d
https://github.com/scummvm/scummvm/commit/a01766f3359ff15f5fde115317b2098fff8e415d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Load Android movement phases from XML
Changed paths:
engines/ngi/android.cpp
engines/ngi/statics.cpp
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index e02eb7a62db..06a43619b10 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -221,6 +221,32 @@ private:
XML_PROP(y, false)
XML_PROP(locale, false)
KEY_END()
+ XML_KEY(MOVEMENT)
+ XML_PROP(id, true)
+ XML_PROP(title, false)
+ XML_PROP(x, false)
+ XML_PROP(y, false)
+ XML_PROP(z, false)
+ XML_PROP(flags, false)
+ XML_PROP(locale, false)
+ XML_PROP(nIdPrev, true)
+ XML_PROP(nIdNext, true)
+ XML_PROP(nPrevStepX, false)
+ XML_PROP(nPrevStepY, false)
+ XML_PROP(nNextStepX, false)
+ XML_PROP(nNextStepY, false)
+ XML_PROP(dwLoopDelay, false)
+ XML_PROP(link, false)
+ XML_KEY(PHASE)
+ XML_PROP(x, false)
+ XML_PROP(y, false)
+ XML_PROP(flags, false)
+ XML_PROP(delay, false)
+ XML_PROP(delayRelative, false)
+ XML_PROP(sound, false)
+ XML_PROP(cycled, false)
+ KEY_END()
+ KEY_END()
KEY_END()
KEY_END()
} PARSER_END()
@@ -306,6 +332,59 @@ private:
return true;
}
+ bool parserCallback_MOVEMENT(ParserNode *node) {
+ AniObject &object = *_scene._aniObjects.back();
+ int16 prevId;
+ int16 nextId;
+ if (!readId(node->values["nIdPrev"], prevId) || !readId(node->values["nIdNext"], nextId))
+ return parserError("Unknown statics ID in movement '" + node->values["id"] + "'");
+
+ Statics *previous = object.getStatic(prevId);
+ Statics *next = object.getStatic(nextId);
+ if (!previous || !next)
+ return parserError("Missing statics for movement '" + node->values["id"] + "'");
+
+ Common::ScopedPtr<Movement> movement(new Movement());
+ if (!parseObject(*movement, *node))
+ return false;
+
+ movement->_prevStatic = previous;
+ movement->_nextStatic = next;
+ movement->_prevStepX = atoi(node->values.getValOrDefault("nPrevStepX").c_str());
+ movement->_prevStepY = atoi(node->values.getValOrDefault("nPrevStepY").c_str());
+ movement->_nextStepX = atoi(node->values.getValOrDefault("nNextStepX").c_str());
+ movement->_nextStepY = atoi(node->values.getValOrDefault("nNextStepY").c_str());
+ movement->_loopDelay = atoi(node->values.getValOrDefault("dwLoopDelay", "42").c_str());
+ const Common::String &link = node->values.getValOrDefault("link");
+ movement->_link = link.empty() || link == "true" || link == "1";
+
+ // Movement owns its phases except for the terminal statics shared with the animation.
+ movement->_phases.push_back(next);
+ movement->_framePosOffsets.push_back(Common::Point(movement->_nextStepX, movement->_nextStepY));
+ object._movements.push_back(movement.release());
+ return true;
+ }
+
+ bool parserCallback_PHASE(ParserNode *node) {
+ AniObject &animation = *_scene._aniObjects.back();
+ Movement &movement = *animation._movements.back();
+ const uint index = movement._phases.size() - 1;
+ const uint16 movementId = static_cast<uint16>(movement._id);
+ const Common::String resource = Common::String::format("%08hu/%08hu/%08hu/%08hu.%03u",
+ static_cast<uint16>(_scene._sceneId), static_cast<uint16>(animation._id), movementId, movementId, index);
+ Common::ScopedPtr<Phase> phase(new Phase());
+ phase->_flags = atoi(node->values.getValOrDefault("flags").c_str());
+ phase->_delay = atoi(node->values.getValOrDefault("delay").c_str());
+ phase->_x = atoi(node->values.getValOrDefault("x").c_str());
+ phase->_y = atoi(node->values.getValOrDefault("y").c_str());
+ if (!loadTexture(*phase, resource, isLocalized(*getParentNode(node))))
+ return false;
+
+ movement._framePosOffsets.insert_at(index, Common::Point(phase->_x, phase->_y));
+ movement._phases.insert_at(index, phase.release());
+ return true;
+ }
+
bool closedKeyCallback(ParserNode *node) override {
if (node->name == "OLDANI" && !_scene._aniObjects.back()->_statics)
return parserError("Missing initial statics for Android animation");
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 53178d961b1..3cec4a1e492 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -1438,7 +1438,7 @@ Movement::~Movement() {
}
// FIXME: At this point, the last entry in _phases is invalid
- for (uint i = 0; i < _phases.size() - 1; i++) {
+ for (uint i = 0; i + 1 < _phases.size(); i++) {
Phase *phase = _phases[i];
if (phase != _prevStatic && phase != _nextStatic)
delete phase;
Commit: 9e6a996940a679b82bf8a71fcc3347957e4bd956
https://github.com/scummvm/scummvm/commit/9e6a996940a679b82bf8a71fcc3347957e4bd956
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Play Android intro sleep movement
Changed paths:
engines/ngi/android.cpp
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/scenes.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index 06a43619b10..03946361ad5 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -30,12 +30,14 @@
#include "engines/util.h"
#include "ngi/ngi.h"
+#include "ngi/constants.h"
#include "ngi/detection.h"
#include "ngi/messages.h"
#include "ngi/utils.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/anihandler.h"
+#include "ngi/scenes.h"
namespace NGI {
@@ -375,6 +377,7 @@ private:
Common::ScopedPtr<Phase> phase(new Phase());
phase->_flags = atoi(node->values.getValOrDefault("flags").c_str());
phase->_delay = atoi(node->values.getValOrDefault("delay").c_str());
+ phase->_delayRelative = atoi(node->values.getValOrDefault("delayRelative").c_str());
phase->_x = atoi(node->values.getValOrDefault("x").c_str());
phase->_y = atoi(node->values.getValOrDefault("y").c_str());
if (!loadTexture(*phase, resource, isLocalized(*getParentNode(node))))
@@ -439,8 +442,14 @@ static void drawAndroidScene(const Scene &scene, Graphics::ManagedSurface &targe
if (object->_objtype == kObjTypePictureObject) {
static_cast<const PictureObject *>(object)->_picture->blitTo(target, position);
} else {
- const Statics *pose = static_cast<const AniObject *>(object)->_statics;
- pose->blitTo(target, position - pose->getSomeXY());
+ const AniObject &animation = *static_cast<const AniObject *>(object);
+ if (animation._movement) {
+ const Movement &movement = *animation._movement;
+ movement._curPhase->blitTo(target, movement._somePoint - Common::Point(scene._x, scene._y));
+ } else {
+ const Statics &pose = *animation._statics;
+ pose.blitTo(target, position - pose.getSomeXY());
+ }
}
}
}
@@ -504,11 +513,31 @@ Common::Error NGIEngine::runAndroid() {
Common::Event event;
Common::EventManager *eventManager = _system->getEventManager();
+ uint32 lastUpdate = _system->getMillis();
while (!shouldQuit()) {
+ bool screenChanged = false;
while (eventManager->pollEvent(event)) {
if (event.type == Common::EVENT_SCREEN_CHANGED)
- _system->copyRectToScreen(frame.getPixels(), frame.pitch, 0, 0, frame.w, frame.h);
+ screenChanged = true;
}
+ if (shouldQuit())
+ break;
+
+ const uint32 now = _system->getMillis();
+ const uint32 elapsed = now - lastUpdate;
+ lastUpdate = now;
+ bool redraw = false;
+ for (AniObject *animation : scene._renderableAnis)
+ redraw |= animation->advanceAndroidMovement(elapsed);
+ if (scene._sceneId == SC_INTRO1)
+ redraw |= sceneIntro_updateAndroid(scene);
+
+ if (redraw) {
+ frame.clear(format.RGBToColor(0, 0, 0));
+ drawAndroidScene(scene, frame);
+ }
+ if (redraw || screenChanged)
+ _system->copyRectToScreen(frame.getPixels(), frame.pitch, 0, 0, frame.w, frame.h);
_system->updateScreen();
_system->delayMillis(10);
}
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index 4684677ef3b..6880510a109 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -30,6 +30,12 @@
namespace NGI {
+bool sceneIntro_updateAndroid(Scene &scene) {
+ AniObject *sleeper = scene.findAniObjectById(ANI_IN1MAN, -1);
+ return sleeper && !sleeper->_movement && sleeper->_statics &&
+ sleeper->_statics->_staticsId == ST_IN1MAN_SLEEP && sleeper->startAndroidMovement(MV_IN1MAN_SLEEP);
+}
+
int sceneIntro_updateCursor() {
g_nmi->_cursorId = 0;
diff --git a/engines/ngi/scenes.h b/engines/ngi/scenes.h
index 19f6fd196a1..ac62547b3a5 100644
--- a/engines/ngi/scenes.h
+++ b/engines/ngi/scenes.h
@@ -38,6 +38,7 @@ int defaultUpdateCursor();
int sceneIntro_updateCursor();
void sceneIntro_initScene(Scene *sc);
+bool sceneIntro_updateAndroid(Scene &scene);
int sceneHandlerIntro(Command *cmd);
int sceneIntroDemo_updateCursor();
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 3cec4a1e492..de04732667a 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -205,6 +205,52 @@ bool AniObject::load(MfcArchive &file) {
return true;
}
+bool AniObject::startAndroidMovement(int id) {
+ Movement *movement = getMovement(id);
+ if (_movement || !movement || movement->_phases.size() <= 1)
+ return false;
+
+ _statics = movement->_prevStatic;
+ _movement = movement;
+ movement->_curFrame = 0;
+ movement->_curPhase = movement->_phases.front();
+ movement->_counter = 0;
+ movement->_somePoint = Common::Point(_x, _y) - _statics->getSomeXY()
+ + Common::Point(movement->_prevStepX, movement->_prevStepY) + movement->_framePosOffsets.front();
+ debugC(2, kDebugAnimation, "Started Android movement %u on object %u",
+ static_cast<uint16>(movement->_id), static_cast<uint16>(_id));
+ return true;
+}
+
+bool AniObject::advanceAndroidMovement(uint32 elapsed) {
+ if (!_movement)
+ return false;
+
+ Movement &movement = *_movement;
+ const Phase &phase = *movement._curPhase;
+ const int delay = movement._loopDelay * (1 + phase._delayRelative) + phase._delay;
+ movement._counter += elapsed;
+ if (movement._counter <= delay)
+ return false;
+
+ movement._counter = 0;
+ ++movement._curFrame;
+ movement._somePoint += movement._framePosOffsets[movement._curFrame];
+ if (static_cast<uint>(movement._curFrame + 1) == movement._phases.size()) {
+ _statics = movement._nextStatic;
+ const Common::Point anchor = movement._somePoint + _statics->getSomeXY();
+ _x = anchor.x;
+ _y = anchor.y;
+ _movement = nullptr;
+ movement._curPhase = nullptr;
+ debugC(2, kDebugAnimation, "Finished Android movement %u on object %u",
+ static_cast<uint16>(movement._id), static_cast<uint16>(_id));
+ } else {
+ movement._curPhase = movement._phases[movement._curFrame];
+ }
+ return true;
+}
+
void AniObject::setPos(int x, int y) {
_x = x;
_y = y;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 40d8b298006..41927049a5f 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -68,6 +68,7 @@ class Phase : public StaticPhase {
public:
int _someX;
int _someY;
+ int _delayRelative = 0;
Common::Rect _rect;
int16 _field_7C;
int16 _field_7E;
@@ -206,6 +207,8 @@ public:
Statics *getStatic(int id);
Statics *getStaticsByName(const Common::String &name);
Movement *getMovement(int id);
+ bool startAndroidMovement(int id);
+ bool advanceAndroidMovement(uint32 elapsed);
int getMovementIdById(int itemId) const;
Movement *getMovementByName(const Common::String &name);
Common::Point getFullSize() const;
Commit: 8669c3b5d78c5937481e87d73a189b2c7dfec00c
https://github.com/scummvm/scummvm/commit/8669c3b5d78c5937481e87d73a189b2c7dfec00c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Reuse movement playback for the Android intro
Changed paths:
engines/ngi/android.cpp
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/ngi.cpp
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index 03946361ad5..d636a43f1a0 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -279,7 +279,9 @@ private:
}
bool parserCallback_OLDANI(ParserNode *node) {
- Common::ScopedPtr<AniObject> animation(new AniObject());
+ AniObject *animation = new AniObject();
+ // addAni resets visibility and draw order, so read the XML fields afterwards.
+ _scene.addAni(animation, true);
if (!parseObject(*animation, *node))
return false;
@@ -289,13 +291,6 @@ private:
return parserError("Unknown initial statics ID '" + statics + "'");
animation->_sceneId = _scene._sceneId;
- // The binary loader clears flags when adding renderables. Keep the XML flags and order.
- const int16 flags = animation->_flags;
- const uint order = animation->_cnum;
- AniObject *object = animation.release();
- _scene.addAni(object, true);
- object->_flags = flags;
- object->_cnum = order;
return true;
}
@@ -307,7 +302,9 @@ private:
object._x = strtod(node.values.getValOrDefault("x").c_str(), nullptr);
object._y = strtod(node.values.getValOrDefault("y").c_str(), nullptr);
object._z = strtod(node.values.getValOrDefault("z").c_str(), nullptr);
- object._flags = strtoul(node.values.getValOrDefault("flags").c_str(), nullptr, 10);
+ object._objectFlags = strtoul(node.values.getValOrDefault("flags").c_str(), nullptr, 10);
+ // XML bit 0 and NGI runtime bit 2 both mean visible.
+ object._flags = (object._objectFlags & 1) ? 4 : 0;
object._cnum = _objectOrder++;
return true;
}
@@ -376,7 +373,7 @@ private:
static_cast<uint16>(_scene._sceneId), static_cast<uint16>(animation._id), movementId, movementId, index);
Common::ScopedPtr<Phase> phase(new Phase());
phase->_flags = atoi(node->values.getValOrDefault("flags").c_str());
- phase->_delay = atoi(node->values.getValOrDefault("delay").c_str());
+ phase->_delayMs = atoi(node->values.getValOrDefault("delay").c_str());
phase->_delayRelative = atoi(node->values.getValOrDefault("delayRelative").c_str());
phase->_x = atoi(node->values.getValOrDefault("x").c_str());
phase->_y = atoi(node->values.getValOrDefault("y").c_str());
@@ -389,6 +386,8 @@ private:
}
bool closedKeyCallback(ParserNode *node) override {
+ if (node->name == "MOVEMENT")
+ _scene._aniObjects.back()->_movements.back()->updateCurrDynamicPhase();
if (node->name == "OLDANI" && !_scene._aniObjects.back()->_statics)
return parserError("Missing initial statics for Android animation");
return true;
@@ -422,11 +421,11 @@ private:
static void drawAndroidScene(const Scene &scene, Graphics::ManagedSurface &target) {
Common::Array<const GameObject *> visibleObjects;
for (const PictureObject *picture : scene._pictureObjects) {
- if (picture->_flags & 1)
+ if (picture->_flags & 4)
visibleObjects.push_back(picture);
}
for (const AniObject *animation : scene._renderableAnis) {
- if (animation->_flags & 1)
+ if (animation->_flags & 4)
visibleObjects.push_back(animation);
}
@@ -443,13 +442,8 @@ static void drawAndroidScene(const Scene &scene, Graphics::ManagedSurface &targe
static_cast<const PictureObject *>(object)->_picture->blitTo(target, position);
} else {
const AniObject &animation = *static_cast<const AniObject *>(object);
- if (animation._movement) {
- const Movement &movement = *animation._movement;
- movement._curPhase->blitTo(target, movement._somePoint - Common::Point(scene._x, scene._y));
- } else {
- const Statics &pose = *animation._statics;
- pose.blitTo(target, position - pose.getSomeXY());
- }
+ const Phase *phase = animation._movement ? animation._movement->_curPhase : animation._statics;
+ phase->blitTo(target, position - animation.getSomeXY());
}
}
}
@@ -487,7 +481,6 @@ Common::Error NGIEngine::runAndroid() {
if (language == Common::UNK_LANG)
language = Common::parseLanguageFromLocale(_system->getSystemLanguage().c_str());
- _aniHandler.reset(new AniHandler());
Scene scene;
scene._sceneId = static_cast<int16>(startSceneId);
const Common::Path scenePath = Common::Path("data/res").join(startSceneFile);
@@ -526,11 +519,10 @@ Common::Error NGIEngine::runAndroid() {
const uint32 now = _system->getMillis();
const uint32 elapsed = now - lastUpdate;
lastUpdate = now;
- bool redraw = false;
- for (AniObject *animation : scene._renderableAnis)
- redraw |= animation->advanceAndroidMovement(elapsed);
+ bool redraw = scene.update(elapsed);
if (scene._sceneId == SC_INTRO1)
redraw |= sceneIntro_updateAndroid(scene);
+ processMessages();
if (redraw) {
frame.clear(format.RGBToColor(0, 0, 0));
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index 6880510a109..dba7a1b1cf3 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -30,10 +30,15 @@
namespace NGI {
+static bool sceneIntro_playSleep(AniObject *sleeper) {
+ if (!sleeper || sleeper->_movement || !sleeper->_statics || sleeper->_statics->_staticsId != ST_IN1MAN_SLEEP)
+ return false;
+
+ return sleeper->startMovement(MV_IN1MAN_SLEEP, 0, -1);
+}
+
bool sceneIntro_updateAndroid(Scene &scene) {
- AniObject *sleeper = scene.findAniObjectById(ANI_IN1MAN, -1);
- return sleeper && !sleeper->_movement && sleeper->_statics &&
- sleeper->_statics->_staticsId == ST_IN1MAN_SLEEP && sleeper->startAndroidMovement(MV_IN1MAN_SLEEP);
+ return sceneIntro_playSleep(scene.findAniObjectById(ANI_IN1MAN, -1));
}
int sceneIntro_updateCursor() {
@@ -98,8 +103,7 @@ int sceneHandlerIntro(Command *ex) {
}
if (g_vars->sceneIntro_needSleep) {
- if (!g_vars->sceneIntro_aniin1man->_movement && g_vars->sceneIntro_aniin1man->_statics->_staticsId == ST_IN1MAN_SLEEP)
- g_vars->sceneIntro_aniin1man->startMovement(MV_IN1MAN_SLEEP, 0, -1);
+ sceneIntro_playSleep(g_vars->sceneIntro_aniin1man);
} else if (g_vars->sceneIntro_needGetup && !g_vars->sceneIntro_aniin1man->_movement &&
g_vars->sceneIntro_aniin1man->_statics->_staticsId == ST_IN1MAN_SLEEP) {
g_vars->sceneIntro_needGetup = 0;
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 05ab50ee614..6956d625dbd 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -240,6 +240,9 @@ Common::String NGIEngine::getSaveStateName(int slot) const {
}
Common::Error NGIEngine::run() {
+ _globalMessageQueueList.reset(new GlobalMessageQueueList);
+ _aniHandler.reset(new AniHandler);
+
if (getPlatform() == Common::kPlatformAndroid)
return runAndroid();
@@ -252,7 +255,6 @@ Common::Error NGIEngine::run() {
_backgroundSurface.create(800, 600, format);
- _globalMessageQueueList.reset(new GlobalMessageQueueList);
_behaviorManager.reset(new BehaviorController);
_sceneRect.left = 0;
@@ -261,7 +263,6 @@ Common::Error NGIEngine::run() {
_sceneRect.bottom = 599;
_floaters.reset(new FlyPack);
- _aniHandler.reset(new AniHandler);
_globalPalette = &_defaultPalette;
_isSaveAllowed = false;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index c479f74e68e..40b2434e176 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -649,11 +649,13 @@ int Scene::getPictureObjectIdAtPos(int x, int y) {
return res;
}
-void Scene::update(int counterdiff) {
+bool Scene::update(int counterdiff) {
debugC(6, kDebugDrawing, "Scene::update(%d)", counterdiff);
+ bool changed = false;
for (uint i = 0; i < _renderableAnis.size(); i++)
- _renderableAnis[i]->update(counterdiff);
+ changed |= _renderableAnis[i]->update(counterdiff);
+ return changed;
}
void Scene::drawContent(int minPri, int maxPri, bool drawBg) {
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 926d724ac2e..ad7e1acfdad 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -57,7 +57,8 @@ class Scene : public Background {
void updateScrolling();
void updateScrolling2();
- void update(int counterdiff);
+ /** Returns true if the scene may need redrawing. */
+ bool update(int counterdiff);
AniObject *getAniMan();
AniObject *findAniObjectById(int obj, int a3);
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index de04732667a..405c7ce53af 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -205,52 +205,6 @@ bool AniObject::load(MfcArchive &file) {
return true;
}
-bool AniObject::startAndroidMovement(int id) {
- Movement *movement = getMovement(id);
- if (_movement || !movement || movement->_phases.size() <= 1)
- return false;
-
- _statics = movement->_prevStatic;
- _movement = movement;
- movement->_curFrame = 0;
- movement->_curPhase = movement->_phases.front();
- movement->_counter = 0;
- movement->_somePoint = Common::Point(_x, _y) - _statics->getSomeXY()
- + Common::Point(movement->_prevStepX, movement->_prevStepY) + movement->_framePosOffsets.front();
- debugC(2, kDebugAnimation, "Started Android movement %u on object %u",
- static_cast<uint16>(movement->_id), static_cast<uint16>(_id));
- return true;
-}
-
-bool AniObject::advanceAndroidMovement(uint32 elapsed) {
- if (!_movement)
- return false;
-
- Movement &movement = *_movement;
- const Phase &phase = *movement._curPhase;
- const int delay = movement._loopDelay * (1 + phase._delayRelative) + phase._delay;
- movement._counter += elapsed;
- if (movement._counter <= delay)
- return false;
-
- movement._counter = 0;
- ++movement._curFrame;
- movement._somePoint += movement._framePosOffsets[movement._curFrame];
- if (static_cast<uint>(movement._curFrame + 1) == movement._phases.size()) {
- _statics = movement._nextStatic;
- const Common::Point anchor = movement._somePoint + _statics->getSomeXY();
- _x = anchor.x;
- _y = anchor.y;
- _movement = nullptr;
- movement._curPhase = nullptr;
- debugC(2, kDebugAnimation, "Finished Android movement %u on object %u",
- static_cast<uint16>(movement._id), static_cast<uint16>(_id));
- } else {
- movement._curPhase = movement._phases[movement._curFrame];
- }
- return true;
-}
-
void AniObject::setPos(int x, int y) {
_x = x;
_y = y;
@@ -767,7 +721,7 @@ Common::Point AniObject::getSomeXY() const {
error("No someXY found");
}
-void AniObject::update(int counterdiff) {
+bool AniObject::update(int counterdiff) {
int mqid;
debugC(6, kDebugAnimation, "AniObject::update() (%s) [%d] [%d, %d] fl: %x", transCyrillic(_title), _id, _x, _y, _flags);
@@ -775,14 +729,14 @@ void AniObject::update(int counterdiff) {
if (_flags & 2) {
_messageNum--;
if (_messageNum)
- return;
+ return false;
mqid = _messageQueueId;
_messageQueueId = 0;
_flags ^= 2;
updateGlobalMessageQueue(mqid, _id);
- return;
+ return true;
}
Command *ex, *newex;
@@ -790,8 +744,15 @@ void AniObject::update(int counterdiff) {
if (_movement) {
_movement->_counter += counterdiff;
- if (_movement->_counter < _movement->_loopDelay)
- return;
+ const bool android = g_nmi->getPlatform() == Common::kPlatformAndroid;
+ if (android) {
+ const Phase &phase = *_movement->_curPhase;
+ const int delay = _movement->_loopDelay * (1 + phase._delayRelative) + phase._delayMs;
+ if (_movement->_counter <= delay)
+ return false;
+ } else if (_movement->_counter < _movement->_loopDelay) {
+ return false;
+ }
_movement->_counter = 0;
@@ -799,7 +760,7 @@ void AniObject::update(int counterdiff) {
if (_counter) {
_counter--;
- return;
+ return false;
}
Phase *dyn = _movement->_curPhase;
@@ -816,7 +777,7 @@ void AniObject::update(int counterdiff) {
newex->sendMessage();
if (!_movement)
- return;
+ return true;
}
}
@@ -827,10 +788,11 @@ void AniObject::update(int counterdiff) {
newex->sendMessage();
if (!_movement)
- return;
+ return true;
}
- if (!_movement->setNext(_callback1, _callback2)) {
+ // Android ends the movement as soon as the next statics takes over.
+ if (!_movement->setNext(_callback1, _callback2) || (android && _movement->_curPhase == _movement->_nextStatic)) {
stopMovement();
} else {
setPos(_movement->_x, _movement->_y);
@@ -848,7 +810,7 @@ void AniObject::update(int counterdiff) {
}
}
if (!_movement)
- return;
+ return true;
const Common::Point point = _stepArray.getCurrPoint();
setPos(point.x + _x, point.y + _y);
@@ -866,19 +828,20 @@ void AniObject::update(int counterdiff) {
_movement->setPos(_x + point.x + _movement->_prevStepX - pointS.x,
_y + point.y + _movement->_prevStepY - pointS.y);
}
- } else {
- if (_statics) {
- if (_messageQueueId) {
- if (_statics->_countdown) {
- _statics->_countdown--;
- return;
- }
- mqid = _messageQueueId;
- _messageQueueId = 0;
- updateGlobalMessageQueue(mqid, _id);
- }
+ return true;
+ }
+
+ if (_statics && _messageQueueId) {
+ if (_statics->_countdown) {
+ _statics->_countdown--;
+ return false;
}
+ mqid = _messageQueueId;
+ _messageQueueId = 0;
+ updateGlobalMessageQueue(mqid, _id);
+ return true;
}
+ return false;
}
void AniObject::updateStepPos() {
@@ -1277,16 +1240,10 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
return false;
}
- Movement *mov = nullptr;
-
- for (uint i = 0; i < _movements.size(); i++) {
- if (_movements[i]->_id == movementId) {
- mov = _movements[i];
- break;
- }
- }
-
- if (!mov) {
+ const bool android = g_nmi->getPlatform() == Common::kPlatformAndroid;
+ Movement *mov = getMovement(movementId);
+ // An XML movement without any PHASE elements contains only its end pose.
+ if (!mov || (android && !mov->getPhase(1))) {
updateGlobalMessageQueue(messageQueueId, _id);
return false;
}
@@ -1302,6 +1259,9 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
int newy = _y;
Common::Point point;
+ if (android && !_movement)
+ _statics = mov->_prevStatic;
+
if (_movement) {
point = _movement->getCurrDynamicPhaseXY();
@@ -2176,6 +2136,8 @@ Phase::Phase(Phase *src, bool reverse) {
_command.reset();
_delay = src->_delay;
+ _delayMs = src->_delayMs;
+ _delayRelative = src->_delayRelative;
_field_6A = src->_field_6A;
_flags = src->_flags;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 41927049a5f..e3049a79a6e 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -48,7 +48,7 @@ class StepArray : public CObject {
class StaticPhase : public Texture {
public:
- int16 _delay;
+ int16 _delay; // Extra animation ticks in binary projects.
int16 _countdown;
int16 _messageNum;
int16 _field_6A;
@@ -68,6 +68,8 @@ class Phase : public StaticPhase {
public:
int _someX;
int _someY;
+ // XML phases can add both milliseconds and multiples of the movement's loop delay.
+ int _delayMs = 0;
int _delayRelative = 0;
Common::Rect _rect;
int16 _field_7C;
@@ -207,8 +209,6 @@ public:
Statics *getStatic(int id);
Statics *getStaticsByName(const Common::String &name);
Movement *getMovement(int id);
- bool startAndroidMovement(int id);
- bool advanceAndroidMovement(uint32 elapsed);
int getMovementIdById(int itemId) const;
Movement *getMovementByName(const Common::String &name);
Common::Point getFullSize() const;
@@ -243,7 +243,7 @@ public:
void show1(int x, int y, int movementId, int mqId);
void show2(int x, int y, int movementId, int mqId);
void playIdle();
- void update(int counterdiff);
+ bool update(int counterdiff);
Statics *addReverseStatics(Statics *ani);
void render();
Commit: 2d97d70cc93d3ed7eaeee65d130f10bd77a8bf62
https://github.com/scummvm/scummvm/commit/2d97d70cc93d3ed7eaeee65d130f10bd77a8bf62
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Fade in the Android intro before starting its animation
Changed paths:
engines/ngi/android.cpp
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/scenes.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index d636a43f1a0..da4024f4614 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -497,9 +497,12 @@ Common::Error NGIEngine::runAndroid() {
if (format.isCLUT8())
return Common::kUnsupportedColorMode;
- Graphics::ManagedSurface frame(project.width(), project.height(), format);
+ Graphics::ManagedSurface &frame = _backgroundSurface;
+ frame.create(project.width(), project.height(), format);
+ byte brightness = scene._sceneId == SC_INTRO1 ? 0 : 255;
frame.clear(format.RGBToColor(0, 0, 0));
- drawAndroidScene(scene, frame);
+ if (brightness)
+ drawAndroidScene(scene, frame);
_system->copyRectToScreen(frame.getPixels(), frame.pitch, 0, 0, frame.w, frame.h);
_system->updateScreen();
debugC(1, kDebugDrawing, "Presented first Full Pipe Android frame for %s", startSceneFile.c_str());
@@ -521,12 +524,14 @@ Common::Error NGIEngine::runAndroid() {
lastUpdate = now;
bool redraw = scene.update(elapsed);
if (scene._sceneId == SC_INTRO1)
- redraw |= sceneIntro_updateAndroid(scene);
+ redraw |= sceneIntro_updateAndroid(scene, elapsed, brightness);
processMessages();
if (redraw) {
frame.clear(format.RGBToColor(0, 0, 0));
drawAndroidScene(scene, frame);
+ if (brightness < 255)
+ drawAlphaRectangle(0, 0, frame.w, frame.h, brightness);
}
if (redraw || screenChanged)
_system->copyRectToScreen(frame.getPixels(), frame.pitch, 0, 0, frame.w, frame.h);
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index dba7a1b1cf3..1733c7cf9f6 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -37,7 +37,18 @@ static bool sceneIntro_playSleep(AniObject *sleeper) {
return sleeper->startMovement(MV_IN1MAN_SLEEP, 0, -1);
}
-bool sceneIntro_updateAndroid(Scene &scene) {
+bool sceneIntro_updateAndroid(Scene &scene, uint32 elapsed, byte &brightness) {
+ const uint32 fadeDuration = 1025;
+ const uint32 previous = g_vars->sceneIntro_fadeElapsed;
+ if (previous < fadeDuration) {
+ g_vars->sceneIntro_fadeElapsed += MIN(elapsed, fadeDuration - previous);
+ // CFader samples the alpha before advancing its timer and clears it at the end.
+ const byte next = g_vars->sceneIntro_fadeElapsed == fadeDuration ? 255 : previous * 255 / fadeDuration;
+ const bool changed = brightness != next;
+ brightness = next;
+ return changed;
+ }
+
return sceneIntro_playSleep(scene.findAniObjectById(ANI_IN1MAN, -1));
}
diff --git a/engines/ngi/scenes.h b/engines/ngi/scenes.h
index ac62547b3a5..87c0511b85c 100644
--- a/engines/ngi/scenes.h
+++ b/engines/ngi/scenes.h
@@ -38,7 +38,7 @@ int defaultUpdateCursor();
int sceneIntro_updateCursor();
void sceneIntro_initScene(Scene *sc);
-bool sceneIntro_updateAndroid(Scene &scene);
+bool sceneIntro_updateAndroid(Scene &scene, uint32 elapsed, byte &brightness);
int sceneHandlerIntro(Command *cmd);
int sceneIntroDemo_updateCursor();
@@ -224,6 +224,7 @@ public:
AniObject *sceneIntro_aniin1man;
bool sceneIntro_needSleep;
+ uint32 sceneIntro_fadeElapsed = 0;
bool sceneIntro_needGetup;
bool sceneIntro_skipIntro;
bool sceneIntro_playing;
Commit: 12df1848dcc938f5522109b08cc8f0a9ec059472
https://github.com/scummvm/scummvm/commit/12df1848dcc938f5522109b08cc8f0a9ec059472
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Run Android intro command queues and phase sound cues
Changed paths:
engines/ngi/android.cpp
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/messagehandlers.cpp
engines/ngi/messages.cpp
engines/ngi/messages.h
engines/ngi/ngi.h
engines/ngi/scenes.h
engines/ngi/sound.cpp
engines/ngi/sound.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index da4024f4614..eebf8724b68 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -33,6 +33,7 @@
#include "ngi/constants.h"
#include "ngi/detection.h"
#include "ngi/messages.h"
+#include "ngi/ngiarchive.h"
#include "ngi/utils.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
@@ -186,6 +187,7 @@ private:
}
CUSTOM_XML_PARSER(XMLSceneParser) {
+ XMLKeyLayout *commandLayout;
XML_KEY(SCENE)
XML_PROP(id, true)
XML_PROP(title, false)
@@ -198,6 +200,30 @@ private:
XML_PROP(putPrev, false)
XML_PROP(scrollX, false)
XML_PROP(scrollY, false)
+ XML_KEY(SOUND)
+ XML_PROP(id, true)
+ XML_PROP(file, true)
+ XML_PROP(title, false)
+ XML_PROP(flags, false)
+ KEY_END()
+ XML_KEY(QUEUE)
+ XML_PROP(id, true)
+ XML_PROP(title, false)
+ XML_KEY(COMMAND)
+ commandLayout = layout.top();
+ XML_PROP(cmd, true)
+ XML_PROP(wait, false)
+ XML_PROP(id, false)
+ XML_PROP(ani, false)
+ XML_PROP(mov, false)
+ XML_PROP(vis, false)
+ XML_PROP(copy, false)
+ XML_PROP(msg, false)
+ XML_PROP(cycled, false)
+ XML_PROP(stop, false)
+ XML_PROP(delay, false)
+ KEY_END()
+ KEY_END()
XML_KEY(PICTURE)
XML_PROP(id, true)
XML_PROP(title, false)
@@ -240,6 +266,7 @@ private:
XML_PROP(dwLoopDelay, false)
XML_PROP(link, false)
XML_KEY(PHASE)
+ layout.top()->children["COMMAND"] = commandLayout;
XML_PROP(x, false)
XML_PROP(y, false)
XML_PROP(flags, false)
@@ -278,6 +305,94 @@ private:
return true;
}
+ bool parserCallback_SOUND(ParserNode *node) {
+ int16 id;
+ if (!readId(node->values["id"], id))
+ return parserError("Unknown sound ID " + node->values["id"]);
+ const bool speech = atoi(node->values.getValOrDefault("flags").c_str()) & 1;
+ Common::Path path(speech ? Common::String::format("data/res_%s", _locale) : "data/res");
+ path = path.join(Common::String::format("Sounds/%08hu", static_cast<uint16>(_scene._sceneId)));
+ if (speech)
+ path = path.join("Talks");
+ path = path.join(node->values["file"]);
+ if (!SearchMan.hasFile(path))
+ path = Common::Path("assets").join(path);
+ if (!_scene._soundList)
+ _scene._soundList.reset(new SoundList());
+ _scene._soundList->addSound(id, path);
+ return true;
+ }
+
+ bool parserCallback_QUEUE(ParserNode *node) {
+ Common::ScopedPtr<MessageQueue> queue(new MessageQueue());
+ if (!readId(node->values["id"], queue->_queueId))
+ return parserError("Unknown queue ID " + node->values["id"]);
+ queue->_title = node->values.getValOrDefault("title");
+ _scene._messageQueues.push_back(queue.release());
+ return true;
+ }
+
+ static bool boolProperty(const ParserNode &node, const char *name) {
+ const Common::String &value = node.values.getValOrDefault(name);
+ return value == "1" || value == "true" || value == "yes";
+ }
+
+ bool parserCallback_COMMAND(ParserNode *node) {
+ Common::ScopedPtr<Command> cmd(new Command());
+ Common::String kind = node->values["cmd"];
+ kind.toUppercase();
+ cmd->_excFlags = 2;
+ cmd->_wait = boolProperty(*node, "wait");
+ cmd->_param = atoi(node->values.getValOrDefault("copy").c_str());
+
+ const char *idProperty = nullptr;
+ if (kind == "START_MOVEMENT" || kind == "3") {
+ cmd->_cmd = 1;
+ if (!readId(node->values.getValOrDefault("ani"), cmd->_parentId))
+ return parserError("Unknown animation in START_MOVEMENT");
+ idProperty = "mov";
+ } else if (kind == "HIDE" || kind == "2") {
+ cmd->_cmd = 6;
+ cmd->_wait = 0;
+ if (!readId(node->values.getValOrDefault("vis"), cmd->_parentId))
+ return parserError("Unknown object in HIDE");
+ } else if (kind == "QUEUE" || kind == "24") {
+ cmd->_cmd = 18;
+ idProperty = "id";
+ } else if (kind == "SOUND" || kind == "7") {
+ if (cmd->_wait)
+ return parserError("Waiting for an XML sound is not implemented");
+ cmd->_cmd = 35;
+ cmd->_param = boolProperty(*node, "cycled");
+ cmd->_z = boolProperty(*node, "stop") ? 2 : 1;
+ idProperty = "id";
+ } else if (kind == "MESSAGE" || kind == "5") {
+ cmd->_cmd = 17;
+ cmd->_messageName = node->values.getValOrDefault("msg");
+ uint32 id;
+ if (_ids.findId(cmd->_messageName, id))
+ cmd->_messageNum = id;
+ } else if (kind == "PAUSE" || kind == "22") {
+ cmd->_cmd = Command::kCmdPause;
+ cmd->_messageNum = MAX(0, atoi(node->values.getValOrDefault("delay").c_str()));
+ } else {
+ return parserError("Unsupported XML command " + kind);
+ }
+ if (idProperty) {
+ int16 id;
+ if (!readId(node->values.getValOrDefault(idProperty), id))
+ return parserError("Unknown " + Common::String(idProperty) + " in " + kind);
+ cmd->_messageNum = id;
+ }
+ if (getParentNode(node)->name == "QUEUE") {
+ _scene._messageQueues.back()->addCommandToEnd(cmd.release());
+ } else {
+ Movement &movement = *_scene._aniObjects.back()->_movements.back();
+ movement._phases[movement._phases.size() - 2]->_command.reset(cmd.release());
+ }
+ return true;
+ }
+
bool parserCallback_OLDANI(ParserNode *node) {
AniObject *animation = new AniObject();
// addAni resets visibility and draw order, so read the XML fields afterwards.
@@ -354,8 +469,7 @@ private:
movement->_nextStepX = atoi(node->values.getValOrDefault("nNextStepX").c_str());
movement->_nextStepY = atoi(node->values.getValOrDefault("nNextStepY").c_str());
movement->_loopDelay = atoi(node->values.getValOrDefault("dwLoopDelay", "42").c_str());
- const Common::String &link = node->values.getValOrDefault("link");
- movement->_link = link.empty() || link == "true" || link == "1";
+ movement->_link = !node->values.contains("link") || boolProperty(*node, "link");
// Movement owns its phases except for the terminal statics shared with the animation.
movement->_phases.push_back(next);
@@ -372,6 +486,9 @@ private:
const Common::String resource = Common::String::format("%08hu/%08hu/%08hu/%08hu.%03u",
static_cast<uint16>(_scene._sceneId), static_cast<uint16>(animation._id), movementId, movementId, index);
Common::ScopedPtr<Phase> phase(new Phase());
+ if (node->values.contains("sound") && !readId(node->values["sound"], phase->_soundId))
+ return parserError("Unknown phase sound " + node->values["sound"]);
+ phase->_loopSound = boolProperty(*node, "cycled");
phase->_flags = atoi(node->values.getValOrDefault("flags").c_str());
phase->_delayMs = atoi(node->values.getValOrDefault("delay").c_str());
phase->_delayRelative = atoi(node->values.getValOrDefault("delayRelative").c_str());
@@ -402,8 +519,7 @@ private:
}
static bool isLocalized(const ParserNode &node) {
- const Common::String &locale = node.values.getValOrDefault("locale");
- return locale == "true" || locale == "1";
+ return boolProperty(node, "locale");
}
bool handleUnknownKey(ParserNode *node) override {
@@ -497,6 +613,15 @@ Common::Error NGIEngine::runAndroid() {
if (format.isCLUT8())
return Common::kUnsupportedColorMode;
+ _currentScene = &scene;
+ addMessageHandlerByIndex(global_messageHandler4, 0, 4);
+ if (scene._sceneId == SC_INTRO1) {
+ sceneIntro_initMan(scene);
+ addMessageHandler(sceneHandlerIntro, 2);
+ }
+ if (scene._soundList)
+ _currSoundList1[_currSoundListCount++] = scene._soundList.get();
+
Graphics::ManagedSurface &frame = _backgroundSurface;
frame.create(project.width(), project.height(), format);
byte brightness = scene._sceneId == SC_INTRO1 ? 0 : 255;
@@ -522,9 +647,13 @@ Common::Error NGIEngine::runAndroid() {
const uint32 now = _system->getMillis();
const uint32 elapsed = now - lastUpdate;
lastUpdate = now;
- bool redraw = scene.update(elapsed);
+ bool redraw = false;
+ for (MessageQueue *queue : *_globalMessageQueueList)
+ redraw |= queue->updatePause(elapsed);
+ processMessages();
+ redraw |= scene.update(elapsed);
if (scene._sceneId == SC_INTRO1)
- redraw |= sceneIntro_updateAndroid(scene, elapsed, brightness);
+ redraw |= sceneIntro_updateAndroid(elapsed, brightness);
processMessages();
if (redraw) {
@@ -538,6 +667,13 @@ Common::Error NGIEngine::runAndroid() {
_system->updateScreen();
_system->delayMillis(10);
}
+ clearMessages();
+ clearGlobalMessageQueueList();
+ clearMessageHandlers();
+ _currSoundListCount = 0;
+ _currSoundList1[0] = nullptr;
+ g_vars->sceneIntro_aniin1man = nullptr;
+ _currentScene = nullptr;
return Common::kNoError;
}
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index 1733c7cf9f6..8478224840b 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -30,14 +30,28 @@
namespace NGI {
-static bool sceneIntro_playSleep(AniObject *sleeper) {
- if (!sleeper || sleeper->_movement || !sleeper->_statics || sleeper->_statics->_staticsId != ST_IN1MAN_SLEEP)
+void sceneIntro_initMan(Scene &scene) {
+ g_vars->sceneIntro_aniin1man = scene.findAniObjectById(ANI_IN1MAN, -1);
+ g_vars->sceneIntro_needSleep = true;
+ g_vars->sceneIntro_needGetup = false;
+ g_vars->sceneIntro_fadeElapsed = 0;
+}
+
+static bool sceneIntro_updateMan() {
+ AniObject *man = g_vars->sceneIntro_aniin1man;
+ if (!man || man->_movement || !man->_statics || man->_statics->_staticsId != ST_IN1MAN_SLEEP)
return false;
- return sleeper->startMovement(MV_IN1MAN_SLEEP, 0, -1);
+ if (g_vars->sceneIntro_needSleep)
+ return man->startMovement(MV_IN1MAN_SLEEP, 0, -1);
+ if (g_vars->sceneIntro_needGetup) {
+ g_vars->sceneIntro_needGetup = false;
+ return runQueue(QU_INTR_GETUPMAN, 0);
+ }
+ return false;
}
-bool sceneIntro_updateAndroid(Scene &scene, uint32 elapsed, byte &brightness) {
+bool sceneIntro_updateAndroid(uint32 elapsed, byte &brightness) {
const uint32 fadeDuration = 1025;
const uint32 previous = g_vars->sceneIntro_fadeElapsed;
if (previous < fadeDuration) {
@@ -46,10 +60,12 @@ bool sceneIntro_updateAndroid(Scene &scene, uint32 elapsed, byte &brightness) {
const byte next = g_vars->sceneIntro_fadeElapsed == fadeDuration ? 255 : previous * 255 / fadeDuration;
const bool changed = brightness != next;
brightness = next;
+ if (g_vars->sceneIntro_fadeElapsed == fadeDuration)
+ runQueue(QU_INTR_STARTINTRO, 0);
return changed;
}
- return sceneIntro_playSleep(scene.findAniObjectById(ANI_IN1MAN, -1));
+ return sceneIntro_updateMan();
}
int sceneIntro_updateCursor() {
@@ -61,9 +77,7 @@ int sceneIntro_updateCursor() {
void sceneIntro_initScene(Scene *sc) {
g_nmi->_gameLoader->loadScene(SC_INTRO2);
- g_vars->sceneIntro_aniin1man = sc->findAniObjectById(ANI_IN1MAN, -1);
- g_vars->sceneIntro_needSleep = true;
- g_vars->sceneIntro_needGetup = false;
+ sceneIntro_initMan(*sc);
g_vars->sceneIntro_playing = true;
g_vars->sceneIntro_needBlackout = false;
@@ -87,6 +101,15 @@ int sceneHandlerIntro(Command *ex) {
if (ex->_cmd != 17)
return 0;
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid && !ex->_messageName.empty()) {
+ debugC(3, kDebugEvents, "Android intro message %s", ex->_messageName.c_str());
+ if (ex->_messageNum == MSG_INTR_SWITCHTO2 || ex->_messageNum == MSG_INTR_SWITCHTO1 ||
+ ex->_messageNum == MSG_INTR_ENDINTRO || ex->_messageName == "MSG_ENABLE_BHV_SOUND") {
+ warning("Android intro message %s not implemented", ex->_messageName.c_str());
+ return 0;
+ }
+ }
+
switch (ex->_messageNum) {
case MSG_INTR_ENDINTRO:
g_vars->sceneIntro_playing = 0;
@@ -113,14 +136,7 @@ int sceneHandlerIntro(Command *ex) {
return 0;
}
- if (g_vars->sceneIntro_needSleep) {
- sceneIntro_playSleep(g_vars->sceneIntro_aniin1man);
- } else if (g_vars->sceneIntro_needGetup && !g_vars->sceneIntro_aniin1man->_movement &&
- g_vars->sceneIntro_aniin1man->_statics->_staticsId == ST_IN1MAN_SLEEP) {
- g_vars->sceneIntro_needGetup = 0;
-
- runQueue(QU_INTR_GETUPMAN, 0);
- }
+ sceneIntro_updateMan();
g_nmi->startSceneTrack();
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 4efeecba38c..41afee1f600 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -523,7 +523,17 @@ int global_messageHandler4(Command *cmd) {
switch (cmd->_cmd) {
case 18: {
- MessageQueue *mq = new MessageQueue(g_nmi->_currentScene->findMessageQueue(cmd->_messageNum), cmd->_parId, 0);
+ MessageQueue *source = g_nmi->_currentScene ? g_nmi->_currentScene->findMessageQueue(cmd->_messageNum) : nullptr;
+ if (!source) {
+ warning("Could not find message queue %d", cmd->_messageNum);
+ if (!(cmd->_excFlags & 1))
+ updateGlobalMessageQueue(cmd->_parId, 0);
+ break;
+ }
+ int parent = cmd->_parId;
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid && !cmd->_wait)
+ parent = 0;
+ MessageQueue *mq = new MessageQueue(source, parent, 0);
if (cmd->_excFlags & 1)
mq->_flag1 = 1;
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 4dd17ab6e6e..f8c783c671e 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -37,6 +37,7 @@ Command::Command() {
}
Command::Command(Command *src) : Message(*src) {
+ _messageName = src->_messageName;
_field_3C = 1;
_messageNum = src->_messageNum;
_excFlags = src->_excFlags;
@@ -454,13 +455,29 @@ void MessageQueue::next() {
ex->_excFlags |= (ex->_wait == 0 ? 1 : 0) | (ex->_field_3C != 0 ? 2 : 0);
_flags |= 4;
- ex->sendMessage();
+ if (ex->_cmd == Command::kCmdPause && ex->_wait && g_nmi->getPlatform() == Common::kPlatformAndroid)
+ _pauseCommand.reset(ex);
+ else
+ ex->sendMessage();
} else if (_counter <= 0) {
_isFinished = 1;
finish();
}
}
+bool MessageQueue::updatePause(uint32 elapsed) {
+ if (!_pauseCommand)
+ return false;
+
+ if (elapsed < (uint32)_pauseCommand->_messageNum) {
+ _pauseCommand->_messageNum -= elapsed;
+ return false;
+ }
+ _pauseCommand->_excFlags |= 1;
+ _pauseCommand.release()->postMessage();
+ return true;
+}
+
bool MessageQueue::checkGlobalExCommandList1() {
Command *ex, *ex1;
@@ -697,8 +714,9 @@ void GlobalMessageQueueList::clear() {
// queue if it thinks it is in the global queue, which will break the
// iteration over the list
(*it)->_flags &= ~kInGlobalQueue;
- delete *it;
+ (*it)->_parId = 0;
}
+ Common::for_each(begin(), end(), Common::DefaultDeleter<MessageQueue>());
Common::Array<MessageQueue *>::clear();
}
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index 7dcbeef7123..a05bc73a12c 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -58,6 +58,8 @@ class Message : public CObject {
class Command : public Message {
public:
+ enum { kCmdPause = 64 }; // Timed pause in XML queues.
+ Common::String _messageName;
int _messageNum;
int _field_3C;
int _excFlags;
@@ -120,6 +122,7 @@ class MessageQueue : public CObject {
private:
Common::List<Command *> _commands;
+ Common::ScopedPtr<Command> _pauseCommand;
public:
MessageQueue();
@@ -148,6 +151,7 @@ class MessageQueue : public CObject {
bool run(AniObject *ani);
void update();
void next();
+ bool updatePause(uint32 elapsed);
void finish();
void messageQueueCallback1(int par);
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index b4cb16121d0..b3ba0fd14fe 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -216,7 +216,7 @@ public:
void stopAllSounds();
void toggleMute();
- void playSound(int id, int flag);
+ void playSound(int id, int flag, int creator = 0);
void playTrack(GameVar *sceneVar, const char *name, bool delayed);
int getSceneTrack();
void updateTrackDelay();
diff --git a/engines/ngi/scenes.h b/engines/ngi/scenes.h
index 87c0511b85c..d18549b5df5 100644
--- a/engines/ngi/scenes.h
+++ b/engines/ngi/scenes.h
@@ -38,7 +38,8 @@ int defaultUpdateCursor();
int sceneIntro_updateCursor();
void sceneIntro_initScene(Scene *sc);
-bool sceneIntro_updateAndroid(Scene &scene, uint32 elapsed, byte &brightness);
+void sceneIntro_initMan(Scene &scene);
+bool sceneIntro_updateAndroid(uint32 elapsed, byte &brightness);
int sceneHandlerIntro(Command *cmd);
int sceneIntroDemo_updateCursor();
diff --git a/engines/ngi/sound.cpp b/engines/ngi/sound.cpp
index 74f75667d89..2e0a47fbeae 100644
--- a/engines/ngi/sound.cpp
+++ b/engines/ngi/sound.cpp
@@ -50,7 +50,8 @@ bool SoundList::load(MfcArchive &file, const Common::Path &fname) {
}
for (uint i = 0; i < count; i++) {
- _soundItems[i].load(file, _libHandle.get());
+ _soundItems[i].reset(new Sound());
+ _soundItems[i]->load(file, _libHandle.get());
}
return true;
@@ -69,8 +70,8 @@ bool SoundList::loadFile(const Common::Path &fname, const Common::Path &libname)
Sound *SoundList::getSound(int id) {
for (uint i = 0; i < _soundItems.size(); ++i) {
- if (_soundItems[i].getId() == id)
- return &_soundItems[i];
+ if (_soundItems[i]->getId() == id)
+ return _soundItems[i].get();
}
return nullptr;
}
@@ -81,6 +82,22 @@ Sound::Sound() :
_handle(new Audio::SoundHandle()),
_objectId(0) {}
+Sound::Sound(int id, const Common::Path &path) : Sound() {
+ _id = id;
+ _memfilename = path;
+}
+
+void SoundList::addSound(int id, const Common::Path &path) {
+ _soundItems.emplace_back(new Sound(id, path));
+}
+
+void SoundList::stopByCreator(int objectId) {
+ for (const auto &sound : _soundItems) {
+ if (sound->_objectId == objectId)
+ sound->stop();
+ }
+}
+
Sound::~Sound() {
unload();
delete _handle;
@@ -192,19 +209,42 @@ void Sound::attenuate(int vol, int pan) {
g_nmi->_mixer->setChannelBalance(*_handle, CLIP(pan / 78, -127, 127)); // -10000..10000
}
-void Sound::play(int loop) {
+void Sound::play(int loop, int creator) {
Audio::SoundHandle *handle = getHandle();
- if (g_nmi->_mixer->isSoundHandleActive(*handle)) { // We need to restart the music
+ Audio::RewindableAudioStream *stream = nullptr;
+ const bool android = g_nmi->getPlatform() == Common::kPlatformAndroid;
+ if (android) {
+#ifdef USE_VORBIS
+ Common::SeekableReadStream *data = SearchMan.createReadStreamForMember(_memfilename);
+ if (data)
+ stream = Audio::makeVorbisStream(data, DisposeAfterUse::YES);
+#endif
+ } else {
+ byte *soundData = loadData();
+ Common::MemoryReadStream *data = new Common::MemoryReadStream(soundData, getDataSize());
+ stream = Audio::makeWAVStream(data, DisposeAfterUse::YES);
+ }
+ if (!stream) {
+ warning("Could not play sound %d (%s)", _id, _memfilename.toString().c_str());
+ return;
+ }
+ Audio::AudioStream *audioStream = new Audio::LoopingAudioStream(stream, (loop == 1) ? 0 : 1);
+
+ if (android) {
+ // The last creator stops all instances of a non-looping phase sound.
+ _objectId = loop ? 0 : creator;
+ for (uint i = _overlappingHandles.size(); i > 0; --i) {
+ if (!g_nmi->_mixer->isSoundHandleActive(_overlappingHandles[i - 1]))
+ _overlappingHandles.remove_at(i - 1);
+ }
+ if (g_nmi->_mixer->isSoundHandleActive(*handle))
+ _overlappingHandles.push_back(*handle);
+ } else {
g_nmi->_mixer->stopHandle(*handle);
}
-
- byte *soundData = loadData();
- Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(soundData, getDataSize());
- Audio::RewindableAudioStream *wav = Audio::makeWAVStream(dataStream, DisposeAfterUse::YES);
- Audio::AudioStream *audioStream = new Audio::LoopingAudioStream(wav, (loop == 1) ? 0 : 1);
-
g_nmi->_mixer->playStream(Audio::Mixer::kSFXSoundType, handle, audioStream);
+ debugC(3, kDebugEvents, "Playing sound %d (%s), loop %d", _id, _memfilename.toString().c_str(), loop);
}
void Sound::unload() {
@@ -219,6 +259,9 @@ int Sound::getVolume() {
void Sound::stop() {
g_nmi->_mixer->stopHandle(*_handle);
+ for (const Audio::SoundHandle &handle : _overlappingHandles)
+ g_nmi->_mixer->stopHandle(handle);
+ _overlappingHandles.clear();
}
void NGIEngine::setSceneMusicParameters(GameVar *gvar) {
@@ -376,7 +419,7 @@ void NGIEngine::toggleMute() {
}
}
-void NGIEngine::playSound(int id, int flag) {
+void NGIEngine::playSound(int id, int flag, int creator) {
Sound *sound = nullptr;
for (int i = 0; i < _currSoundListCount; i++) {
@@ -391,7 +434,7 @@ void NGIEngine::playSound(int id, int flag) {
return;
}
- sound->play(flag);
+ sound->play(flag, creator);
}
void NGIEngine::playTrack(GameVar *sceneVar, const char *name, bool delayed) {
@@ -467,6 +510,10 @@ void global_messageHandler_handleSound(Command *cmd) {
return;
if (cmd->_z & 1) {
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid) {
+ snd->play(cmd->_param);
+ return;
+ }
if (!g_nmi->_flgSoundList && (cmd->_z & 4))
snd->unload();
diff --git a/engines/ngi/sound.h b/engines/ngi/sound.h
index 73f50aa8165..114163e6424 100644
--- a/engines/ngi/sound.h
+++ b/engines/ngi/sound.h
@@ -24,10 +24,7 @@
#include "common/array.h"
#include "common/ptr.h"
-
-namespace Audio {
-class SoundHandle;
-}
+#include "audio/mixer.h"
namespace NGI {
@@ -35,12 +32,14 @@ class Sound : public MemoryObject {
int _id;
byte *_soundData;
Audio::SoundHandle *_handle;
+ Common::Array<Audio::SoundHandle> _overlappingHandles;
public:
int16 _objectId;
public:
Sound();
+ Sound(int id, const Common::Path &path);
~Sound() override;
virtual bool load(MfcArchive &file, NGIArchive *archive);
@@ -49,7 +48,7 @@ public:
int getId() const { return _id; }
Audio::SoundHandle *getHandle() const { return _handle; }
- void play(int loop);
+ void play(int loop, int creator = 0);
void unload();
int getVolume();
void stop();
@@ -59,7 +58,7 @@ public:
};
class SoundList : public CObject {
- Common::Array<Sound> _soundItems;
+ Common::Array<Common::ScopedPtr<Sound>> _soundItems;
Common::ScopedPtr<NGIArchive> _libHandle;
public:
@@ -68,7 +67,9 @@ class SoundList : public CObject {
bool loadFile(const Common::Path &fname, const Common::Path &libname);
int getCount() { return _soundItems.size(); }
- Sound &getSoundByIndex(int idx) { return _soundItems[idx]; }
+ Sound &getSoundByIndex(int idx) { return *_soundItems[idx]; }
+ void addSound(int id, const Common::Path &path);
+ void stopByCreator(int objectId);
Sound *getSound(int id);
};
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 405c7ce53af..8c060693053 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -764,7 +764,7 @@ bool AniObject::update(int counterdiff) {
}
Phase *dyn = _movement->_curPhase;
- if (dyn->_delay == dyn->_countdown) {
+ if (!android && dyn->_delay == dyn->_countdown) {
ex = dyn->getCommand();
if (ex && ex->_cmd != 35) {
@@ -798,7 +798,9 @@ bool AniObject::update(int counterdiff) {
setPos(_movement->_x, _movement->_y);
_counter = _initialCounter;
- if (dyn->_delay == dyn->_countdown) {
+ if (android) {
+ _movement->_curPhase->enter(_id);
+ } else if (dyn->_delay == dyn->_countdown) {
ex = dyn->getCommand();
if (ex) {
if (ex->_cmd == 35) {
@@ -951,6 +953,8 @@ L12:
_statics->_y = _y - point.y;
oid = _movement->_id;
_movement = nullptr;
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid && g_nmi->_currentScene && g_nmi->_currentScene->_soundList)
+ g_nmi->_currentScene->_soundList->stopByCreator(_id);
Command *ex = new Command(_id, 17, 24, 0, 0, 0, 1, 0, 0, 0);
ex->_param = _copyId;
@@ -1293,7 +1297,7 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
_stepArray.gotoNextPoint();
Command *ex = _movement->_curPhase->getCommand();
- if (ex) {
+ if (ex && !android) {
if (ex->_cmd == 35) {
Command *newex = ex->createClone();
newex->_excFlags |= 2;
@@ -1329,6 +1333,9 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
newex->postMessage();
+ if (android)
+ mov->_curPhase->enter(_id);
+
return true;
}
@@ -2138,6 +2145,8 @@ Phase::Phase(Phase *src, bool reverse) {
_delay = src->_delay;
_delayMs = src->_delayMs;
_delayRelative = src->_delayRelative;
+ _soundId = src->_soundId;
+ _loopSound = src->_loopSound;
_field_6A = src->_field_6A;
_flags = src->_flags;
@@ -2154,6 +2163,16 @@ Common::String Phase::toXML() {
StaticPhase::toXML().c_str());
}
+void Phase::enter(int objectId) {
+ if (_soundId && g_nmi->_soundEnabled)
+ g_nmi->playSound(_soundId, _loopSound, objectId);
+ if (_command) {
+ Command *cmd = _command->createClone();
+ cmd->_excFlags |= 2;
+ cmd->sendMessage();
+ }
+}
+
bool Phase::load(MfcArchive &file) {
debugC(5, kDebugLoading, "Phase::load()");
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index e3049a79a6e..5f56d3a60ff 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -71,6 +71,8 @@ class Phase : public StaticPhase {
// XML phases can add both milliseconds and multiples of the movement's loop delay.
int _delayMs = 0;
int _delayRelative = 0;
+ int16 _soundId = 0;
+ bool _loopSound = false;
Common::Rect _rect;
int16 _field_7C;
int16 _field_7E;
@@ -79,6 +81,7 @@ class Phase : public StaticPhase {
public:
Phase();
Phase(Phase *src, bool reverse);
+ void enter(int objectId);
bool load(MfcArchive &file) override;
Commit: e10034ad9b80fbd07df0f2b629e5d7edc4bd6146
https://github.com/scummvm/scummvm/commit/e10034ad9b80fbd07df0f2b629e5d7edc4bd6146
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:41+01:00
Commit Message:
NGI: Play the Android intro across both rooms
Changed paths:
engines/ngi/android.cpp
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/ngi.h
engines/ngi/objects.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/sound.cpp
engines/ngi/sound.h
engines/ngi/statics.cpp
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index eebf8724b68..288774a424c 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -34,6 +34,7 @@
#include "ngi/detection.h"
#include "ngi/messages.h"
#include "ngi/ngiarchive.h"
+#include "ngi/objects.h"
#include "ngi/utils.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
@@ -42,21 +43,56 @@
namespace NGI {
+bool ObjectIdList::load(const Common::Path &path) {
+ Common::File file;
+ if (!file.open(path))
+ return false;
+
+ while (!file.eos() && !file.err()) {
+ const Common::String line = file.readLine();
+ if (!line.hasPrefix("#define"))
+ continue;
+
+ const char *name = line.c_str() + 7;
+ while (*name == ' ' || *name == '\t')
+ ++name;
+ const char *value = name;
+ while (*value && *value != ' ' && *value != '\t')
+ ++value;
+ if (name == value || !*value)
+ continue;
+
+ const Common::String symbol(name, value);
+ if (!_ids.contains(symbol))
+ _ids[symbol] = strtoul(value, nullptr, 10);
+ }
+ return !file.err();
+}
+
+bool ObjectIdList::findId(const Common::String &symbol, uint32 &id) const {
+ const auto entry = _ids.find(symbol);
+ if (entry == _ids.end())
+ return false;
+ id = entry->_value;
+ return true;
+}
+
namespace {
class XMLProjectParser : public Common::XMLParser {
public:
- const Common::String &startScene() const { return _startScene; }
+ explicit XMLProjectParser(GameProject &project) : _project(project) {
+ _project._sceneTagList.reset(new SceneTagList());
+ }
+
+ const SceneTag *startScene() const { return _startScene; }
int width() const { return _width; }
int height() const { return _height; }
- Common::String startSceneFile() const {
- return _scenes.getValOrDefault(_startScene);
- }
-
private:
- Common::String _startScene;
- Common::StringMap _scenes;
+ GameProject &_project;
+ Common::String _startName;
+ SceneTag *_startScene = nullptr;
int _width = 800;
int _height = 600;
@@ -80,7 +116,7 @@ private:
} PARSER_END()
bool parserCallback_PROJECT(ParserNode *node) {
- _startScene = node->values["start"];
+ _startName = node->values["start"];
if (node->values.contains("width"))
_width = atoi(node->values["width"].c_str());
if (node->values.contains("height"))
@@ -91,7 +127,16 @@ private:
}
bool parserCallback_SCENE(ParserNode *node) {
- _scenes[node->values["id"]] = node->values["file"];
+ const Common::String &name = node->values["id"];
+ uint32 id;
+ if (!_project._objectIds.findId(name, id) || id > 0xffff)
+ return parserError("Unknown project scene ID '" + name + "'");
+ _project._sceneTagList->emplace_back();
+ SceneTag &tag = _project._sceneTagList->back();
+ tag._sceneId = static_cast<int16>(id);
+ tag._tag = node->values["file"];
+ if (name == _startName)
+ _startScene = &tag;
return true;
}
@@ -108,46 +153,6 @@ private:
}
};
-class ObjectIdList {
-public:
- bool load(const Common::Path &path) {
- Common::File file;
- if (!file.open(path))
- return false;
-
- while (!file.eos() && !file.err()) {
- const Common::String line = file.readLine();
- if (!line.hasPrefix("#define"))
- continue;
-
- const char *name = line.c_str() + 7;
- while (*name == ' ' || *name == '\t')
- ++name;
- const char *value = name;
- while (*value && *value != ' ' && *value != '\t')
- ++value;
- if (name == value || !*value)
- continue;
-
- const Common::String symbol(name, value);
- if (!_ids.contains(symbol))
- _ids[symbol] = strtoul(value, nullptr, 10);
- }
- return !file.err();
- }
-
- bool findId(const Common::String &symbol, uint32 &id) const {
- const auto entry = _ids.find(symbol);
- if (entry == _ids.end())
- return false;
- id = entry->_value;
- return true;
- }
-
-private:
- Common::HashMap<Common::String, uint32> _ids;
-};
-
static const char *getResourceLocale(Common::Language language) {
switch (language) {
case Common::DE_DEU:
@@ -309,7 +314,8 @@ private:
int16 id;
if (!readId(node->values["id"], id))
return parserError("Unknown sound ID " + node->values["id"]);
- const bool speech = atoi(node->values.getValOrDefault("flags").c_str()) & 1;
+ const int flags = atoi(node->values.getValOrDefault("flags").c_str());
+ const bool speech = flags & Sound::kSpeech;
Common::Path path(speech ? Common::String::format("data/res_%s", _locale) : "data/res");
path = path.join(Common::String::format("Sounds/%08hu", static_cast<uint16>(_scene._sceneId)));
if (speech)
@@ -319,7 +325,7 @@ private:
path = Common::Path("assets").join(path);
if (!_scene._soundList)
_scene._soundList.reset(new SoundList());
- _scene._soundList->addSound(id, path);
+ _scene._soundList->addSound(id, path, flags);
return true;
}
@@ -566,6 +572,26 @@ static void drawAndroidScene(const Scene &scene, Graphics::ManagedSurface &targe
} // End of anonymous namespace
+void SceneTag::loadSceneXML(const ObjectIdList &ids) {
+ Common::Language language = Common::parseLanguage(ConfMan.get("language"));
+ if (language == Common::UNK_LANG)
+ language = Common::parseLanguageFromLocale(g_system->getSystemLanguage().c_str());
+
+ Common::ScopedPtr<Scene> scene(new Scene());
+ scene->_sceneId = _sceneId;
+ const Common::Path path = Common::Path("data/res").join(_tag);
+ XMLSceneParser parser(ids, *scene, getResourceLocale(language));
+ if (!parser.loadStream(SearchMan.createReadStreamForMember(path), path.toString()) || !parser.parse()) {
+ warning("Could not load Full Pipe Android scene %s", _tag.c_str());
+ return;
+ }
+
+ debugC(1, kDebugXML, "Loaded Full Pipe Android scene %s with %u pictures and %u animations",
+ _tag.c_str(), scene->_pictureObjects.size(), scene->_aniObjects.size());
+ delete _scene;
+ _scene = scene.release();
+}
+
Common::Error NGIEngine::runAndroid() {
const auto &files = _gameDescription->desc.filesDescriptions;
const Common::FSNode gameDirectory(ConfMan.getPath("path"));
@@ -577,60 +603,56 @@ Common::Error NGIEngine::runAndroid() {
SearchMan.add("ngi-android-obb", obb.release());
SearchMan.add("ngi-android-apk", apk.release());
+ GameProject project;
+ if (!project._objectIds.load("data/obj.h"))
+ return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android object IDs");
+
const Common::Path projectPath("data/FullPipe.xml");
- XMLProjectParser project;
- if (!project.loadStream(SearchMan.createReadStreamForMember(projectPath), projectPath.toString()) || !project.parse())
+ XMLProjectParser parser(project);
+ if (!parser.loadStream(SearchMan.createReadStreamForMember(projectPath), projectPath.toString()) || !parser.parse())
return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android project");
- ObjectIdList ids;
- if (!ids.load("data/obj.h"))
- return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android object IDs");
-
- const Common::String startSceneFile = project.startSceneFile();
- uint32 startSceneId;
- if (!ids.findId(project.startScene(), startSceneId) || startSceneId > 0xffff || startSceneFile.empty())
+ const SceneTag *start = parser.startScene();
+ if (!start)
return Common::Error(Common::kNoGameDataFoundError, "Could not find the Full Pipe Android start scene");
-
- debugC(1, kDebugXML, "Loaded Full Pipe Android project, start scene %s (%u)", startSceneFile.c_str(), startSceneId);
-
- Common::Language language = Common::parseLanguage(ConfMan.get("language"));
- if (language == Common::UNK_LANG)
- language = Common::parseLanguageFromLocale(_system->getSystemLanguage().c_str());
-
- Scene scene;
- scene._sceneId = static_cast<int16>(startSceneId);
- const Common::Path scenePath = Common::Path("data/res").join(startSceneFile);
- XMLSceneParser sceneParser(ids, scene, getResourceLocale(language));
- if (!sceneParser.loadStream(SearchMan.createReadStreamForMember(scenePath), scenePath.toString()) || !sceneParser.parse())
+ debugC(1, kDebugXML, "Loaded Full Pipe Android project, start scene %s (%hu)",
+ start->_tag.c_str(), static_cast<uint16>(start->_sceneId));
+ Scene *startScene = project.findScene(start->_sceneId);
+ if (!startScene)
return Common::Error(Common::kNoGameDataFoundError, "Could not load the Full Pipe Android start scene");
- debugC(1, kDebugXML, "Loaded Full Pipe Android scene %s with %u pictures and %u animations",
- startSceneFile.c_str(), scene._pictureObjects.size(), scene._aniObjects.size());
+ const bool intro = start->_sceneId == SC_INTRO1;
+ Scene *intro2 = intro ? project.findScene(SC_INTRO2) : nullptr;
+ if (intro && !intro2)
+ return Common::Error(Common::kNoGameDataFoundError, "Could not load the second Full Pipe Android intro scene");
_isSaveAllowed = false;
- initGraphics(project.width(), project.height(), nullptr);
+ initGraphics(parser.width(), parser.height(), nullptr);
const Graphics::PixelFormat format = _system->getScreenFormat();
if (format.isCLUT8())
return Common::kUnsupportedColorMode;
- _currentScene = &scene;
+ _gameProject = &project;
+ _currentScene = startScene;
addMessageHandlerByIndex(global_messageHandler4, 0, 4);
- if (scene._sceneId == SC_INTRO1) {
- sceneIntro_initMan(scene);
+ if (intro) {
+ sceneIntro_initMan(*startScene);
addMessageHandler(sceneHandlerIntro, 2);
}
- if (scene._soundList)
- _currSoundList1[_currSoundListCount++] = scene._soundList.get();
+ if (startScene->_soundList)
+ _currSoundList1[_currSoundListCount++] = startScene->_soundList.get();
+ if (intro2 && intro2->_soundList)
+ _currSoundList1[_currSoundListCount++] = intro2->_soundList.get();
Graphics::ManagedSurface &frame = _backgroundSurface;
- frame.create(project.width(), project.height(), format);
- byte brightness = scene._sceneId == SC_INTRO1 ? 0 : 255;
+ frame.create(parser.width(), parser.height(), format);
+ byte brightness = intro ? 0 : 255;
frame.clear(format.RGBToColor(0, 0, 0));
if (brightness)
- drawAndroidScene(scene, frame);
+ drawAndroidScene(*_currentScene, frame);
_system->copyRectToScreen(frame.getPixels(), frame.pitch, 0, 0, frame.w, frame.h);
_system->updateScreen();
- debugC(1, kDebugDrawing, "Presented first Full Pipe Android frame for %s", startSceneFile.c_str());
+ debugC(1, kDebugDrawing, "Presented first Full Pipe Android frame for %s", start->_tag.c_str());
Common::Event event;
Common::EventManager *eventManager = _system->getEventManager();
@@ -648,17 +670,25 @@ Common::Error NGIEngine::runAndroid() {
const uint32 elapsed = now - lastUpdate;
lastUpdate = now;
bool redraw = false;
+ Scene *scene = _currentScene;
for (MessageQueue *queue : *_globalMessageQueueList)
redraw |= queue->updatePause(elapsed);
processMessages();
- redraw |= scene.update(elapsed);
- if (scene._sceneId == SC_INTRO1)
+ if (scene == _currentScene)
+ redraw |= scene->update(elapsed);
+ if (scene == _currentScene && scene->_sceneId == SC_INTRO1)
redraw |= sceneIntro_updateAndroid(elapsed, brightness);
processMessages();
+ if (scene != _currentScene) {
+ stopAllSounds(Sound::kSpeech);
+ stopAllSounds(Sound::kEffect);
+ debugC(2, kDebugDrawing, "Switched Android scene from %d to %d", scene->_sceneId, _currentScene->_sceneId);
+ redraw = true;
+ }
if (redraw) {
frame.clear(format.RGBToColor(0, 0, 0));
- drawAndroidScene(scene, frame);
+ drawAndroidScene(*_currentScene, frame);
if (brightness < 255)
drawAlphaRectangle(0, 0, frame.w, frame.h, brightness);
}
@@ -670,10 +700,11 @@ Common::Error NGIEngine::runAndroid() {
clearMessages();
clearGlobalMessageQueueList();
clearMessageHandlers();
- _currSoundListCount = 0;
- _currSoundList1[0] = nullptr;
+ while (_currSoundListCount)
+ _currSoundList1[--_currSoundListCount] = nullptr;
g_vars->sceneIntro_aniin1man = nullptr;
_currentScene = nullptr;
+ _gameProject = nullptr;
return Common::kNoError;
}
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index 8478224840b..fb4ce6230eb 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -103,8 +103,7 @@ int sceneHandlerIntro(Command *ex) {
if (g_nmi->getPlatform() == Common::kPlatformAndroid && !ex->_messageName.empty()) {
debugC(3, kDebugEvents, "Android intro message %s", ex->_messageName.c_str());
- if (ex->_messageNum == MSG_INTR_SWITCHTO2 || ex->_messageNum == MSG_INTR_SWITCHTO1 ||
- ex->_messageNum == MSG_INTR_ENDINTRO || ex->_messageName == "MSG_ENABLE_BHV_SOUND") {
+ if (ex->_messageNum == MSG_INTR_ENDINTRO || ex->_messageName == "MSG_ENABLE_BHV_SOUND") {
warning("Android intro message %s not implemented", ex->_messageName.c_str());
return 0;
}
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index b3ba0fd14fe..d2e67a70f53 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -214,7 +214,7 @@ public:
Common::Path _sceneTracksCurrentTrack;
bool _sceneTrackIsPlaying;
- void stopAllSounds();
+ void stopAllSounds(int flags = -1);
void toggleMute();
void playSound(int id, int flag, int creator = 0);
void playTrack(GameVar *sceneVar, const char *name, bool delayed);
diff --git a/engines/ngi/objects.h b/engines/ngi/objects.h
index d03a12d2493..b0a11284d52 100644
--- a/engines/ngi/objects.h
+++ b/engines/ngi/objects.h
@@ -22,24 +22,37 @@
#ifndef NGI_OBJECTS_H
#define NGI_OBJECTS_H
+#include "common/hashmap.h"
#include "common/ptr.h"
#include "ngi/utils.h"
namespace NGI {
class MessageQueue;
+class Scene;
class SceneTagList;
+class ObjectIdList {
+public:
+ bool load(const Common::Path &path);
+ bool findId(const Common::String &symbol, uint32 &id) const;
+
+private:
+ Common::HashMap<Common::String, uint32> _ids;
+};
+
class GameProject : public CObject {
public:
int _field_4;
Common::String _headerFilename;
Common::ScopedPtr<SceneTagList> _sceneTagList;
+ ObjectIdList _objectIds;
int _field_10;
public:
GameProject();
bool load(MfcArchive &file) override;
+ Scene *findScene(int sceneId);
};
struct PicAniInfo {
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 40b2434e176..c73d968f91f 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -35,23 +35,22 @@
namespace NGI {
Scene *NGIEngine::findScene(int sceneId) {
- SceneTag *t = nullptr;
+ return _gameProject->findScene(sceneId);
+}
- for (SceneTagList::iterator s = _gameProject->_sceneTagList->begin(); s != _gameProject->_sceneTagList->end(); ++s) {
- if (s->_sceneId == sceneId) {
- t = &(*s);
- break;
+Scene *GameProject::findScene(int sceneId) {
+ for (SceneTag &tag : *_sceneTagList) {
+ if (tag._sceneId != sceneId)
+ continue;
+ if (!tag._scene) {
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid)
+ tag.loadSceneXML(_objectIds);
+ else
+ tag.loadScene();
}
+ return tag._scene;
}
-
- if (!t)
- return nullptr;
-
- if (!t->_scene) {
- t->loadScene();
- }
-
- return t->_scene;
+ return nullptr;
}
bool SceneTagList::load(MfcArchive &file) {
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index ad7e1acfdad..06806d69080 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -28,6 +28,7 @@
namespace NGI {
class MessageQueue;
+class ObjectIdList;
class Scene : public Background {
public:
@@ -108,6 +109,7 @@ class SceneTag : public CObject {
bool load(MfcArchive &file) override;
void loadScene();
+ void loadSceneXML(const ObjectIdList &ids);
};
class SceneTagList : public Common::List<SceneTag>, public CObject {
diff --git a/engines/ngi/sound.cpp b/engines/ngi/sound.cpp
index 2e0a47fbeae..8498e50e47a 100644
--- a/engines/ngi/sound.cpp
+++ b/engines/ngi/sound.cpp
@@ -82,13 +82,14 @@ Sound::Sound() :
_handle(new Audio::SoundHandle()),
_objectId(0) {}
-Sound::Sound(int id, const Common::Path &path) : Sound() {
+Sound::Sound(int id, const Common::Path &path, int flags) : Sound() {
_id = id;
+ _flags = flags;
_memfilename = path;
}
-void SoundList::addSound(int id, const Common::Path &path) {
- _soundItems.emplace_back(new Sound(id, path));
+void SoundList::addSound(int id, const Common::Path &path, int flags) {
+ _soundItems.emplace_back(new Sound(id, path, flags));
}
void SoundList::stopByCreator(int objectId) {
@@ -404,10 +405,12 @@ void NGIEngine::playOggSound(const Common::Path &trackName, Audio::SoundHandle &
#endif
}
-void NGIEngine::stopAllSounds() {
+void NGIEngine::stopAllSounds(int flags) {
for (int i = 0; i < _currSoundListCount; i++)
for (int j = 0; j < _currSoundList1[i]->getCount(); j++) {
- _currSoundList1[i]->getSoundByIndex(j).stop();
+ Sound &sound = _currSoundList1[i]->getSoundByIndex(j);
+ if (flags == -1 || sound.getFlags() == flags)
+ sound.stop();
}
}
diff --git a/engines/ngi/sound.h b/engines/ngi/sound.h
index 114163e6424..514a1acbd9e 100644
--- a/engines/ngi/sound.h
+++ b/engines/ngi/sound.h
@@ -30,22 +30,24 @@ namespace NGI {
class Sound : public MemoryObject {
int _id;
+ int _flags = 0;
byte *_soundData;
Audio::SoundHandle *_handle;
Common::Array<Audio::SoundHandle> _overlappingHandles;
public:
+ enum { kEffect = 0, kSpeech = 1 };
int16 _objectId;
-public:
Sound();
- Sound(int id, const Common::Path &path);
+ Sound(int id, const Common::Path &path, int flags);
~Sound() override;
virtual bool load(MfcArchive &file, NGIArchive *archive);
bool load(MfcArchive &file) override { assert(0); return false; } // Disable base class
void updateVolume();
int getId() const { return _id; }
+ int getFlags() const { return _flags; }
Audio::SoundHandle *getHandle() const { return _handle; }
void play(int loop, int creator = 0);
@@ -68,7 +70,7 @@ class SoundList : public CObject {
int getCount() { return _soundItems.size(); }
Sound &getSoundByIndex(int idx) { return *_soundItems[idx]; }
- void addSound(int id, const Common::Path &path);
+ void addSound(int id, const Common::Path &path, int flags);
void stopByCreator(int objectId);
Sound *getSound(int id);
};
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 8c060693053..72a9208a851 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -953,8 +953,10 @@ L12:
_statics->_y = _y - point.y;
oid = _movement->_id;
_movement = nullptr;
- if (g_nmi->getPlatform() == Common::kPlatformAndroid && g_nmi->_currentScene && g_nmi->_currentScene->_soundList)
- g_nmi->_currentScene->_soundList->stopByCreator(_id);
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid) {
+ for (int i = 0; i < g_nmi->_currSoundListCount; ++i)
+ g_nmi->_currSoundList1[i]->stopByCreator(_id);
+ }
Command *ex = new Command(_id, 17, 24, 0, 0, 0, 1, 0, 0, 0);
ex->_param = _copyId;
Commit: a38a2eb386917c5ebd27584c59da55bf2bac9914
https://github.com/scummvm/scummvm/commit/a38a2eb386917c5ebd27584c59da55bf2bac9914
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:42+01:00
Commit Message:
NGI: Preserve Android texture dimensions when image files are missing
Changed paths:
engines/ngi/android.cpp
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/objects.h
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index 288774a424c..4fd71442366 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -164,31 +164,79 @@ static const char *getResourceLocale(Common::Language language) {
}
}
+class XMLTextureSizeParser : public Common::XMLParser {
+public:
+ explicit XMLTextureSizeParser(GameProject &project) : _project(project) {}
+
+ void loadSizes() {
+ if (!read("tex_data_main.xml"))
+ return;
+ Common::Array<Common::Path> files;
+ files.swap(_files);
+ for (const Common::Path &path : files)
+ read(path);
+ }
+
+private:
+ GameProject &_project;
+ Common::Array<Common::Path> _files;
+
+ bool read(const Common::Path &name) {
+ const Common::Path path = Common::Path("data").join(name);
+ close();
+ return loadFile(path) && parse();
+ }
+
+ CUSTOM_XML_PARSER(XMLTextureSizeParser) {
+ XML_KEY(FILES)
+ XML_KEY(FLIE)
+ XML_PROP(path, true)
+ KEY_END()
+ KEY_END()
+ XML_KEY(TEX_DATA)
+ XML_KEY(DATA)
+ XML_PROP(path, true)
+ XML_PROP(w, true)
+ XML_PROP(h, true)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_FILES(ParserNode *) { return true; }
+ bool parserCallback_TEX_DATA(ParserNode *) { return true; }
+
+ bool parserCallback_FLIE(ParserNode *node) {
+ _files.push_back(Common::Path(node->values["path"], '\\'));
+ return true;
+ }
+
+ bool parserCallback_DATA(ParserNode *node) {
+ const Common::Path path = Common::Path("data").join(Common::Path(node->values["path"], '\\'));
+ if (!_project._textureSizes.contains(path))
+ _project._textureSizes[path] = Dims(atoi(node->values["w"].c_str()), atoi(node->values["h"].c_str()));
+ return true;
+ }
+};
+
class XMLSceneParser : public Common::XMLParser {
public:
- XMLSceneParser(const ObjectIdList &ids, Scene &scene, const char *locale)
- : _ids(ids), _scene(scene), _locale(locale) {
+ XMLSceneParser(const GameProject &project, Scene &scene, const char *locale)
+ : _project(project), _scene(scene), _locale(locale) {
setAllowText();
}
private:
- const ObjectIdList &_ids;
+ const GameProject &_project;
Scene &_scene;
const char *_locale;
uint _objectOrder = 0;
bool _hasInitialStatics = false;
int16 _initialStaticsId = 0;
- bool loadTexture(Texture &texture, const Common::String &resource, bool localized) {
+ void loadTexture(Texture &texture, const Common::String &resource, bool localized) {
const Common::String directory = localized ? Common::String::format("data/res_%s", _locale) : "data/res";
const Common::Path path = Common::Path(directory).join(resource + ".png");
- Common::File file;
- if (!file.open(path) || !texture.loadPNG(file))
- return parserError("Could not load scene texture " + path.toString());
-
- const Dims dimensions = texture.getDimensions();
- debugC(2, kDebugLoading, "Loaded scene texture %s (%d x %d)", path.toString().c_str(), dimensions.x, dimensions.y);
- return true;
+ texture.loadPNG(path, _project._textureSizes.getValOrDefault(path));
}
CUSTOM_XML_PARSER(XMLSceneParser) {
@@ -303,8 +351,7 @@ private:
picture->_picture = new Texture();
const Common::String resource = Common::String::format("%08hu/%08hu",
static_cast<uint16>(_scene._sceneId), static_cast<uint16>(picture->_id));
- if (!loadTexture(*picture->_picture, resource, isLocalized(*node)))
- return false;
+ loadTexture(*picture->_picture, resource, isLocalized(*node));
picture->setOXY2();
_scene.addPicture(picture.release());
return true;
@@ -376,7 +423,7 @@ private:
cmd->_cmd = 17;
cmd->_messageName = node->values.getValOrDefault("msg");
uint32 id;
- if (_ids.findId(cmd->_messageName, id))
+ if (_project._objectIds.findId(cmd->_messageName, id))
cmd->_messageNum = id;
} else if (kind == "PAUSE" || kind == "22") {
cmd->_cmd = Command::kCmdPause;
@@ -442,8 +489,7 @@ private:
AniObject &object = *_scene._aniObjects.back();
const Common::String resource = Common::String::format("%08hu/%08hu/%08hu",
static_cast<uint16>(_scene._sceneId), static_cast<uint16>(object._id), static_cast<uint16>(pose->_staticsId));
- if (!loadTexture(*pose, resource, isLocalized(*node)))
- return false;
+ loadTexture(*pose, resource, isLocalized(*node));
if (_hasInitialStatics ? pose->_staticsId == _initialStaticsId :
(!object._statics || static_cast<uint16>(pose->_staticsId) < static_cast<uint16>(object._statics->_staticsId)))
@@ -500,8 +546,7 @@ private:
phase->_delayRelative = atoi(node->values.getValOrDefault("delayRelative").c_str());
phase->_x = atoi(node->values.getValOrDefault("x").c_str());
phase->_y = atoi(node->values.getValOrDefault("y").c_str());
- if (!loadTexture(*phase, resource, isLocalized(*getParentNode(node))))
- return false;
+ loadTexture(*phase, resource, isLocalized(*getParentNode(node)));
movement._framePosOffsets.insert_at(index, Common::Point(phase->_x, phase->_y));
movement._phases.insert_at(index, phase.release());
@@ -518,7 +563,7 @@ private:
bool readId(const Common::String &name, int16 &id) const {
uint32 value;
- if (!_ids.findId(name, value) || value > 0xffff)
+ if (!_project._objectIds.findId(name, value) || value > 0xffff)
return false;
id = static_cast<int16>(value);
return true;
@@ -572,7 +617,7 @@ static void drawAndroidScene(const Scene &scene, Graphics::ManagedSurface &targe
} // End of anonymous namespace
-void SceneTag::loadSceneXML(const ObjectIdList &ids) {
+void SceneTag::loadSceneXML(const GameProject &project) {
Common::Language language = Common::parseLanguage(ConfMan.get("language"));
if (language == Common::UNK_LANG)
language = Common::parseLanguageFromLocale(g_system->getSystemLanguage().c_str());
@@ -580,7 +625,7 @@ void SceneTag::loadSceneXML(const ObjectIdList &ids) {
Common::ScopedPtr<Scene> scene(new Scene());
scene->_sceneId = _sceneId;
const Common::Path path = Common::Path("data/res").join(_tag);
- XMLSceneParser parser(ids, *scene, getResourceLocale(language));
+ XMLSceneParser parser(project, *scene, getResourceLocale(language));
if (!parser.loadStream(SearchMan.createReadStreamForMember(path), path.toString()) || !parser.parse()) {
warning("Could not load Full Pipe Android scene %s", _tag.c_str());
return;
@@ -604,6 +649,7 @@ Common::Error NGIEngine::runAndroid() {
SearchMan.add("ngi-android-apk", apk.release());
GameProject project;
+ XMLTextureSizeParser(project).loadSizes();
if (!project._objectIds.load("data/obj.h"))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe Android object IDs");
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index f15db9ae1b9..5a3f45949fc 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -28,6 +28,7 @@
#include "ngi/interaction.h"
#include "ngi/gameloader.h"
+#include "common/file.h"
#include "common/memstream.h"
#include "graphics/managed_surface.h"
@@ -418,12 +419,17 @@ Texture::~Texture() {
freePicture();
}
-bool Texture::loadPNG(Common::SeekableReadStream &stream) {
+void Texture::loadPNG(const Common::Path &path, const Dims &sizeHint) {
+ freePicture();
+ _width = sizeHint.x;
+ _height = sizeHint.y;
+ Common::File file;
Image::PNGDecoder png;
- if (!png.loadStream(stream))
- return false;
+ if (!file.open(path) || !png.loadStream(file)) {
+ warning("Could not load scene texture %s (%d x %d)", path.toString().c_str(), _width, _height);
+ return;
+ }
- freePicture();
const Graphics::Surface &source = *png.getSurface();
_width = source.w;
_height = source.h;
@@ -437,7 +443,7 @@ bool Texture::loadPNG(Common::SeekableReadStream &stream) {
_bitmap->_surface->setPalette(palette.data(), 0, palette.size());
if (png.hasTransparentColor())
_bitmap->_surface->setTransparentColor(png.getTransparentColor());
- return true;
+ debugC(2, kDebugLoading, "Loaded scene texture %s (%d x %d)", path.toString().c_str(), _width, _height);
}
void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &position) const {
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index 50db7286d9b..9dbf931d775 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -89,7 +89,7 @@ public:
void unload();
bool load(MfcArchive &file) override;
- bool loadPNG(Common::SeekableReadStream &stream);
+ void loadPNG(const Common::Path &path, const Dims &sizeHint);
void blitTo(Graphics::ManagedSurface &target, const Common::Point &position) const;
void setAOIDs();
virtual void init();
diff --git a/engines/ngi/objects.h b/engines/ngi/objects.h
index b0a11284d52..7605fbb7f0a 100644
--- a/engines/ngi/objects.h
+++ b/engines/ngi/objects.h
@@ -47,6 +47,7 @@ class GameProject : public CObject {
Common::String _headerFilename;
Common::ScopedPtr<SceneTagList> _sceneTagList;
ObjectIdList _objectIds;
+ Common::HashMap<Common::Path, Common::Point, Common::Path::Hash> _textureSizes;
int _field_10;
public:
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index c73d968f91f..7b15e4cbc3a 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -44,7 +44,7 @@ Scene *GameProject::findScene(int sceneId) {
continue;
if (!tag._scene) {
if (g_nmi->getPlatform() == Common::kPlatformAndroid)
- tag.loadSceneXML(_objectIds);
+ tag.loadSceneXML(*this);
else
tag.loadScene();
}
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 06806d69080..71b0d02ea55 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -28,7 +28,7 @@
namespace NGI {
class MessageQueue;
-class ObjectIdList;
+class GameProject;
class Scene : public Background {
public:
@@ -109,7 +109,7 @@ class SceneTag : public CObject {
bool load(MfcArchive &file) override;
void loadScene();
- void loadSceneXML(const ObjectIdList &ids);
+ void loadSceneXML(const GameProject &project);
};
class SceneTagList : public Common::List<SceneTag>, public CObject {
Commit: 878a04cd649d01522aec841202e30ffa7f5f065b
https://github.com/scummvm/scummvm/commit/878a04cd649d01522aec841202e30ffa7f5f065b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:42+01:00
Commit Message:
NGI: Show the first Android chapter dialog after the intro
Changed paths:
A engines/ngi/font.cpp
A engines/ngi/font.h
A engines/ngi/fullpipe/sceneChapter.cpp
engines/ngi/android.cpp
engines/ngi/constants.h
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/module.mk
engines/ngi/ngi.h
engines/ngi/scene.h
engines/ngi/scenes.cpp
engines/ngi/scenes.h
engines/ngi/sound.cpp
engines/ngi/sound.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index 4fd71442366..310c1810ad7 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -28,11 +28,13 @@
#include "common/file.h"
#include "common/formats/xmlparser.h"
+#include "backends/keymapper/keymapper.h"
#include "engines/util.h"
#include "ngi/ngi.h"
#include "ngi/constants.h"
#include "ngi/detection.h"
#include "ngi/messages.h"
+#include "ngi/modal.h"
#include "ngi/ngiarchive.h"
#include "ngi/objects.h"
#include "ngi/utils.h"
@@ -153,17 +155,6 @@ private:
}
};
-static const char *getResourceLocale(Common::Language language) {
- switch (language) {
- case Common::DE_DEU:
- return "de";
- case Common::RU_RUS:
- return "ru";
- default:
- return "en";
- }
-}
-
class XMLTextureSizeParser : public Common::XMLParser {
public:
explicit XMLTextureSizeParser(GameProject &project) : _project(project) {}
@@ -585,13 +576,15 @@ private:
bool textCallback(const Common::String &text) override { return true; }
};
-static void drawAndroidScene(const Scene &scene, Graphics::ManagedSurface &target) {
+} // End of anonymous namespace
+
+void Scene::drawAndroid(Graphics::ManagedSurface &target) const {
Common::Array<const GameObject *> visibleObjects;
- for (const PictureObject *picture : scene._pictureObjects) {
+ for (const PictureObject *picture : _pictureObjects) {
if (picture->_flags & 4)
visibleObjects.push_back(picture);
}
- for (const AniObject *animation : scene._renderableAnis) {
+ for (const AniObject *animation : _renderableAnis) {
if (animation->_flags & 4)
visibleObjects.push_back(animation);
}
@@ -604,7 +597,7 @@ static void drawAndroidScene(const Scene &scene, Graphics::ManagedSurface &targe
});
for (const GameObject *object : visibleObjects) {
- Common::Point position(object->_x - scene._x, object->_y - scene._y);
+ Common::Point position(object->_x - _x, object->_y - _y);
if (object->_objtype == kObjTypePictureObject) {
static_cast<const PictureObject *>(object)->_picture->blitTo(target, position);
} else {
@@ -615,17 +608,26 @@ static void drawAndroidScene(const Scene &scene, Graphics::ManagedSurface &targe
}
}
-} // End of anonymous namespace
-
-void SceneTag::loadSceneXML(const GameProject &project) {
+const char *NGIEngine::getAndroidResourceLocale() const {
Common::Language language = Common::parseLanguage(ConfMan.get("language"));
if (language == Common::UNK_LANG)
language = Common::parseLanguageFromLocale(g_system->getSystemLanguage().c_str());
+ switch (language) {
+ case Common::DE_DEU:
+ return "de";
+ case Common::RU_RUS:
+ return "ru";
+ default:
+ return "en";
+ }
+}
+
+void SceneTag::loadSceneXML(const GameProject &project) {
Common::ScopedPtr<Scene> scene(new Scene());
scene->_sceneId = _sceneId;
const Common::Path path = Common::Path("data/res").join(_tag);
- XMLSceneParser parser(project, *scene, getResourceLocale(language));
+ XMLSceneParser parser(project, *scene, g_nmi->getAndroidResourceLocale());
if (!parser.loadStream(SearchMan.createReadStreamForMember(path), path.toString()) || !parser.parse()) {
warning("Could not load Full Pipe Android scene %s", _tag.c_str());
return;
@@ -678,6 +680,9 @@ Common::Error NGIEngine::runAndroid() {
if (format.isCLUT8())
return Common::kUnsupportedColorMode;
+ Common::Keymapper *mapper = _system->getEventManager()->getKeymapper();
+ mapper->disableAllGameKeymaps();
+ mapper->setGameKeymapState("ngi-default", true);
_gameProject = &project;
_currentScene = startScene;
addMessageHandlerByIndex(global_messageHandler4, 0, 4);
@@ -695,7 +700,7 @@ Common::Error NGIEngine::runAndroid() {
byte brightness = intro ? 0 : 255;
frame.clear(format.RGBToColor(0, 0, 0));
if (brightness)
- drawAndroidScene(*_currentScene, frame);
+ _currentScene->drawAndroid(frame);
_system->copyRectToScreen(frame.getPixels(), frame.pitch, 0, 0, frame.w, frame.h);
_system->updateScreen();
debugC(1, kDebugDrawing, "Presented first Full Pipe Android frame for %s", start->_tag.c_str());
@@ -706,8 +711,20 @@ Common::Error NGIEngine::runAndroid() {
while (!shouldQuit()) {
bool screenChanged = false;
while (eventManager->pollEvent(event)) {
- if (event.type == Common::EVENT_SCREEN_CHANGED)
+ if (event.type == Common::EVENT_SCREEN_CHANGED) {
screenChanged = true;
+ } else if (_modalObject) {
+ const bool back = (event.type == Common::EVENT_KEYUP &&
+ (event.kbd.keycode == Common::KEYCODE_ESCAPE || event.kbd.keycode == Common::KEYCODE_AC_BACK)) ||
+ (event.type == Common::EVENT_CUSTOM_ENGINE_ACTION_END && event.customType == kActionCloseDialog);
+ if (event.type == Common::EVENT_LBUTTONUP || back) {
+ Command cmd;
+ cmd._cmd = 17;
+ cmd._messageNum = back ? 37 : 30;
+ cmd._param = back ? kActionCloseDialog : 0;
+ _modalObject->handleMessage(&cmd);
+ }
+ }
}
if (shouldQuit())
break;
@@ -717,14 +734,24 @@ Common::Error NGIEngine::runAndroid() {
lastUpdate = now;
bool redraw = false;
Scene *scene = _currentScene;
- for (MessageQueue *queue : *_globalMessageQueueList)
- redraw |= queue->updatePause(elapsed);
- processMessages();
- if (scene == _currentScene)
- redraw |= scene->update(elapsed);
- if (scene == _currentScene && scene->_sceneId == SC_INTRO1)
- redraw |= sceneIntro_updateAndroid(elapsed, brightness);
- processMessages();
+ if (_modalObject) {
+ if (!_modalObject->init(elapsed)) {
+ deleteModalObject();
+ if (!_modalObject && scene->_sceneId == SC_INTRO1 && !g_vars->sceneIntro_playing)
+ warning("Android scene 1 entrance TrubaLeft not implemented");
+ }
+ redraw = true;
+ } else {
+ for (MessageQueue *queue : *_globalMessageQueueList)
+ redraw |= queue->updatePause(elapsed);
+ processMessages();
+ if (!_modalObject && scene == _currentScene)
+ redraw |= scene->update(elapsed);
+ if (!_modalObject && scene == _currentScene && scene->_sceneId == SC_INTRO1)
+ redraw |= sceneIntro_updateAndroid(elapsed, brightness);
+ processMessages();
+ redraw |= _modalObject != nullptr;
+ }
if (scene != _currentScene) {
stopAllSounds(Sound::kSpeech);
@@ -734,15 +761,20 @@ Common::Error NGIEngine::runAndroid() {
}
if (redraw) {
frame.clear(format.RGBToColor(0, 0, 0));
- drawAndroidScene(*_currentScene, frame);
- if (brightness < 255)
- drawAlphaRectangle(0, 0, frame.w, frame.h, brightness);
+ if (_modalObject) {
+ _modalObject->update();
+ } else {
+ _currentScene->drawAndroid(frame);
+ if (brightness < 255)
+ drawAlphaRectangle(0, 0, frame.w, frame.h, brightness);
+ }
}
if (redraw || screenChanged)
_system->copyRectToScreen(frame.getPixels(), frame.pitch, 0, 0, frame.w, frame.h);
_system->updateScreen();
_system->delayMillis(10);
}
+ deleteModalObject();
clearMessages();
clearGlobalMessageQueueList();
clearMessageHandlers();
diff --git a/engines/ngi/constants.h b/engines/ngi/constants.h
index a7c86beff2d..9f2ea3bce88 100644
--- a/engines/ngi/constants.h
+++ b/engines/ngi/constants.h
@@ -240,6 +240,7 @@ namespace NGI {
#define SC_36 2070
#define SC_37 2071
#define SC_38 2072
+#define SC_CHAPTER 10006
#define SC_COMMON 321
#define SC_DBGMENU 726
#define SC_FINAL1 4999
@@ -373,6 +374,9 @@ namespace NGI {
#define PIC_POST_BUTTON 5398
#define SND_CMN_069 4969
+// Chapter dialog
+#define SND_CHAPTER_DLG 23272
+
// Intro
#define ANI_IN1MAN 5110
#define MSG_INTR_ENDINTRO 5139
diff --git a/engines/ngi/font.cpp b/engines/ngi/font.cpp
new file mode 100644
index 00000000000..110b24ed7c9
--- /dev/null
+++ b/engines/ngi/font.cpp
@@ -0,0 +1,251 @@
+/* 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 "ngi/ngi.h"
+#include "ngi/font.h"
+#include "ngi/objects.h"
+#include "ngi/gfx.h"
+#include "common/formats/xmlparser.h"
+
+namespace NGI {
+
+class BitmapFont::Loader : public Common::XMLParser {
+public:
+ Loader(BitmapFont &font, const Common::Path &path) : _font(font), _directory(path.getParent()) {}
+
+private:
+ BitmapFont &_font;
+ Common::Path _directory;
+
+ CUSTOM_XML_PARSER(Loader) {
+ XML_KEY(font)
+ XML_KEY(info)
+ XML_PROP(face, false)
+ XML_PROP(size, false)
+ XML_PROP(bold, false)
+ XML_PROP(italic, false)
+ XML_PROP(charset, false)
+ XML_PROP(unicode, false)
+ XML_PROP(stretchH, false)
+ XML_PROP(smooth, false)
+ XML_PROP(aa, false)
+ XML_PROP(padding, false)
+ XML_PROP(spacing, false)
+ XML_PROP(outline, false)
+ XML_PROP(add_spacing, false)
+ XML_PROP(noScale, false)
+ KEY_END()
+ XML_KEY(common)
+ XML_PROP(lineHeight, false)
+ XML_PROP(base, false)
+ XML_PROP(scaleW, false)
+ XML_PROP(scaleH, false)
+ XML_PROP(pages, false)
+ XML_PROP(packed, false)
+ XML_PROP(alphaChnl, false)
+ XML_PROP(redChnl, false)
+ XML_PROP(greenChnl, false)
+ XML_PROP(blueChnl, false)
+ KEY_END()
+ XML_KEY(pages)
+ XML_KEY(page)
+ XML_PROP(id, true)
+ XML_PROP(file, true)
+ KEY_END()
+ KEY_END()
+ XML_KEY(chars)
+ XML_PROP(count, false)
+ XML_KEY(char)
+ XML_PROP(id, true)
+ XML_PROP(x, true)
+ XML_PROP(y, true)
+ XML_PROP(width, true)
+ XML_PROP(height, true)
+ XML_PROP(xoffset, true)
+ XML_PROP(yoffset, true)
+ XML_PROP(xadvance, true)
+ XML_PROP(page, true)
+ XML_PROP(chnl, false)
+ KEY_END()
+ KEY_END()
+ XML_KEY(kernings)
+ XML_PROP(count, false)
+ XML_KEY(kerning)
+ XML_PROP(first, true)
+ XML_PROP(second, true)
+ XML_PROP(amount, true)
+ KEY_END()
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_font(ParserNode *) { return true; }
+ bool parserCallback_pages(ParserNode *) { return true; }
+ bool parserCallback_chars(ParserNode *) { return true; }
+ bool parserCallback_kernings(ParserNode *) { return true; }
+
+ bool parserCallback_info(ParserNode *node) {
+ _font._outline = atoi(node->values.getValOrDefault("outline").c_str());
+ _font._extraLineSpacing = atoi(node->values.getValOrDefault("add_spacing").c_str());
+ int x = 0, y = 0;
+ if (node->values.contains("spacing") && !parseIntegerKey(node->values["spacing"], 2, &x, &y))
+ return parserError("Invalid bitmap font spacing");
+ _font._spacing = Common::Point(x, y);
+ return true;
+ }
+
+ bool parserCallback_common(ParserNode *node) {
+ _font._lineHeight = atoi(node->values.getValOrDefault("lineHeight").c_str());
+ return true;
+ }
+
+ bool parserCallback_page(ParserNode *node) {
+ if (atoi(node->values["id"].c_str()) != (int)_font._pages.size())
+ return parserError("Invalid bitmap font page index");
+ Common::SharedPtr<Texture> page(new Texture());
+ page->loadPNG(_directory.join(node->values["file"]), Dims());
+ if (page->getDimensions().x == 0)
+ return parserError("Missing bitmap font page");
+ _font._pages.push_back(page);
+ return true;
+ }
+
+ bool parserCallback_char(ParserNode *node) {
+ const int id = atoi(node->values["id"].c_str());
+ if (_font._glyphs.contains(id))
+ return true;
+
+ Glyph &g = _font._glyphs[id];
+ g.page = atoi(node->values["page"].c_str());
+ if (g.page < 0 || (uint)g.page >= _font._pages.size())
+ return parserError("Unknown bitmap font page");
+ const Dims size = _font._pages[g.page]->getDimensions();
+ int x = atoi(node->values["x"].c_str()), y = atoi(node->values["y"].c_str());
+ int w = atoi(node->values["width"].c_str()), h = atoi(node->values["height"].c_str());
+ if (x < 0 || y < 0 || w < 0 || h < 0 || x > size.x - w || y > size.y - h)
+ return parserError("Glyph outside bitmap font page");
+ g.source = Common::Rect(x, y, x + w, y + h);
+ g.offset = Common::Point(atoi(node->values["xoffset"].c_str()), atoi(node->values["yoffset"].c_str()));
+ g.advance = atoi(node->values["xadvance"].c_str());
+ if (!g.advance)
+ g.advance = w;
+ _font._maxWidth = MAX(_font._maxWidth, _font.getCharWidth(id));
+ return true;
+ }
+
+ bool parserCallback_kerning(ParserNode *node) {
+ const byte first = atoi(node->values["first"].c_str());
+ const byte second = atoi(node->values["second"].c_str());
+ _font._kerning[first * 256 + second] = atoi(node->values["amount"].c_str());
+ return true;
+ }
+};
+
+bool BitmapFont::load(const Common::Path &path) {
+ BitmapFont font;
+ Loader loader(font, path);
+ if (!loader.loadFile(path) || !loader.parse() || font._glyphs.empty()) {
+ warning("Could not load bitmap font %s", path.toString().c_str());
+ return false;
+ }
+ *this = Common::move(font);
+ return true;
+}
+
+const BitmapFont::Glyph &BitmapFont::glyph(uint32 chr) const {
+ return _glyphs.getValOrDefault(chr, _glyphs.getValOrDefault('*'));
+}
+
+int BitmapFont::getCharWidth(uint32 chr) const {
+ const Glyph &g = glyph(chr);
+ return g.advance + g.offset.x + 2 * _outline + _spacing.x;
+}
+
+int BitmapFont::getKerningOffset(uint32 left, uint32 right) const {
+ return _kerning.getValOrDefault(left * 256 + right);
+}
+
+Common::Rect BitmapFont::getBoundingBox(uint32 chr) const {
+ const Glyph &g = glyph(chr);
+ return Common::Rect(g.offset, g.source.width(), g.source.height());
+}
+
+void BitmapFont::drawChar(Graphics::Surface *target, uint32 chr, int x, int y, uint32 color) const {
+ Graphics::ManagedSurface view;
+ view.surfacePtr()->init(target->w, target->h, target->pitch, target->getPixels(), target->format);
+ drawChar(&view, chr, x, y, color);
+}
+
+void BitmapFont::drawChar(Graphics::ManagedSurface *target, uint32 chr, int x, int y, uint32 color) const {
+ const Glyph &g = glyph(chr);
+ if (!g.source.isEmpty())
+ _pages[g.page]->blitTo(*target, g.source, Common::Point(x, y) + g.offset);
+}
+
+int BitmapFont::lineHeight(const Common::String &line) const {
+ int height = 0;
+ for (const char c : line)
+ height = MAX<int>(height, getBoundingBox((byte)c).bottom + 2 * _outline + _spacing.y);
+ return height;
+}
+
+void BitmapFont::drawCentered(Graphics::ManagedSurface &target, const Common::Rect &bounds, const Common::String &text) const {
+ Common::Array<Common::String> lines;
+ uint start = 0;
+ int width = 0;
+ for (uint i = 0; i < text.size(); ++i) {
+ if (text[i] == '%' && i + 1 < text.size() && text[i + 1] == 'n') {
+ lines.push_back(text.substr(start, i - start));
+ ++i;
+ start = i + 1;
+ width = 0;
+ continue;
+ }
+ width += getCharWidth((byte)text[i]);
+ if (width >= bounds.width()) {
+ // DivideString breaks at a preceding space and resumes measuring after the next letter.
+ for (uint j = i; j > start; --j) {
+ if (text[j - 1] == ' ' && text[j] != 'n') {
+ lines.push_back(text.substr(start, j - 1 - start));
+ start = j;
+ i = j;
+ width = 0;
+ break;
+ }
+ }
+ }
+ }
+ lines.push_back(text.substr(start));
+ int totalHeight = 0;
+ for (const Common::String &line : lines)
+ totalHeight += lineHeight(line);
+ float y = bounds.top + (bounds.height() - totalHeight) * 0.5f;
+ for (const Common::String &line : lines) {
+ const int x = (int)roundf(bounds.left + (bounds.width() - getStringWidth(line)) * 0.5f);
+ const int top = (int)roundf(y - lineHeight(line) * 0.5f);
+ drawString(&target, line, x, top, target.w - x, 0, Graphics::kTextAlignLeft, 0, false, true);
+ y += (float)totalHeight / lines.size();
+ if (line == " ")
+ y += _extraLineSpacing;
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/font.h b/engines/ngi/font.h
new file mode 100644
index 00000000000..990dd14b563
--- /dev/null
+++ b/engines/ngi/font.h
@@ -0,0 +1,70 @@
+/* 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 NGI_FONT_H
+#define NGI_FONT_H
+
+#include "common/array.h"
+#include "common/hashmap.h"
+#include "common/path.h"
+#include "common/ptr.h"
+#include "graphics/font.h"
+
+namespace NGI {
+
+class Texture;
+
+class BitmapFont : public Graphics::Font {
+public:
+ bool load(const Common::Path &path);
+ void drawCentered(Graphics::ManagedSurface &target, const Common::Rect &bounds, const Common::String &text) const;
+
+ int getFontHeight() const override { return _lineHeight; }
+ int getMaxCharWidth() const override { return _maxWidth; }
+ int getCharWidth(uint32 chr) const override;
+ int getKerningOffset(uint32 left, uint32 right) const override;
+ Common::Rect getBoundingBox(uint32 chr) const override;
+ void drawChar(Graphics::Surface *target, uint32 chr, int x, int y, uint32 color) const override;
+ void drawChar(Graphics::ManagedSurface *target, uint32 chr, int x, int y, uint32 color) const override;
+
+private:
+ class Loader;
+ struct Glyph {
+ Common::Rect source;
+ Common::Point offset;
+ int advance = 0;
+ int page = 0;
+ };
+ const Glyph &glyph(uint32 chr) const;
+ int lineHeight(const Common::String &line) const;
+ Common::HashMap<int, Glyph> _glyphs;
+ Common::HashMap<int, int> _kerning;
+ Common::Array<Common::SharedPtr<Texture>> _pages;
+ Common::Point _spacing;
+ int _outline = 0;
+ int _extraLineSpacing = 0;
+ int _lineHeight = 0;
+ int _maxWidth = 0;
+};
+
+} // End of namespace NGI
+
+#endif
diff --git a/engines/ngi/fullpipe/sceneChapter.cpp b/engines/ngi/fullpipe/sceneChapter.cpp
new file mode 100644
index 00000000000..abf151d0f81
--- /dev/null
+++ b/engines/ngi/fullpipe/sceneChapter.cpp
@@ -0,0 +1,288 @@
+/* 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 "ngi/ngi.h"
+#include "ngi/constants.h"
+#include "ngi/font.h"
+#include "ngi/gameloader.h"
+#include "ngi/modal.h"
+#include "ngi/anihandler.h"
+#include "backends/keymapper/keymapper.h"
+#include "ngi/scenes.h"
+#include "common/file.h"
+#include "common/formats/xmlparser.h"
+
+namespace NGI {
+
+namespace {
+
+class ChapterSettings : public Common::XMLParser {
+public:
+ explicit ChapterSettings(const char *id) : _id(id) {}
+
+ bool load(const Common::Path &directory) {
+ if (!loadFile("data/chapter.xml") || !parse() || !_number || _textId.empty())
+ return false;
+ close();
+
+ Common::File encoding, texts;
+ if (!encoding.open(directory.join("enc.dat")) || encoding.size() < 2 || (encoding.size() & 1) ||
+ !texts.open(directory.join("texts.xml")) || texts.readUint16LE() != 0xfeff)
+ return false;
+
+ Common::HashMap<uint16, byte> codes;
+ for (int i = 128; encoding.pos() + 2 < encoding.size(); ++i) {
+ const uint16 c = encoding.readUint16LE();
+ if (!codes.contains(c))
+ codes[c] = i;
+ }
+ const uint16 first = encoding.readUint16LE();
+ const int base = codes.size() + 1 - 128 - first;
+ // The UTF-16 resource starts with a code page line and ends with </TEXTCONTAINER>.
+ const int64 size = texts.size();
+ while (texts.pos() + 2 <= size) {
+ if (texts.readUint16LE() == '\n')
+ break;
+ }
+ Common::String xml("<?xml version=\"1.0\"?><TEXTCONTAINER>");
+ while (texts.pos() + 2 <= size) {
+ const uint16 c = texts.readUint16LE();
+ xml += c < 128 ? (byte)c : codes.getValOrDefault(c, (byte)(base + c));
+ }
+ if (!loadBuffer((const byte *)xml.c_str(), xml.size()) || !parse())
+ return false;
+ close();
+ if (_title.empty() || _text.empty())
+ return false;
+ _title += Common::String::format("%d", _number);
+ return true;
+ }
+
+ Common::String _title, _text;
+ int _fadeIn = 1025, _fadeOut = 1025, _soundDelay = 4500, _charDelay = 123;
+ bool _textAppearance = false;
+ int _countShow = 0;
+
+private:
+ Common::String _id, _textId;
+ int _chapterIndex = 0, _number = 0;
+
+ CUSTOM_XML_PARSER(ChapterSettings) {
+ XML_KEY(CHAPTERS)
+ XML_KEY(CHAPTER)
+ XML_PROP(id, true)
+ XML_PROP(countShow, false)
+ XML_KEY(START)
+ XML_PROP(text_id, true)
+ KEY_END()
+ KEY_END()
+ KEY_END()
+ XML_KEY(CHAPTER_CONTROLLER)
+ XML_PROP(text_appearance, false)
+ XML_PROP(char_delay, false)
+ XML_PROP(fadein_delay, false)
+ XML_PROP(fadeout_delay, false)
+ XML_PROP(sound_delay, false)
+ KEY_END()
+ XML_KEY(TEXTCONTAINER)
+ XML_KEY(TEXT)
+ XML_PROP(id, true)
+ XML_PROP(text, true)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_CHAPTERS(ParserNode *) { return true; }
+ bool parserCallback_TEXTCONTAINER(ParserNode *) { return true; }
+
+ bool parserCallback_CHAPTER(ParserNode *node) {
+ ++_chapterIndex;
+ if (node->values["id"] == _id) {
+ _number = _chapterIndex;
+ _countShow = atoi(node->values.getValOrDefault("countShow").c_str());
+ }
+ return true;
+ }
+
+ bool parserCallback_START(ParserNode *node) {
+ if (_number == _chapterIndex)
+ _textId = node->values["text_id"];
+ return true;
+ }
+
+ static int delay(ParserNode *node, const char *key, int defaultValue) {
+ if (!node->values.contains(key))
+ return defaultValue;
+ return MAX(0, atoi(node->values[key].c_str()));
+ }
+
+ bool parserCallback_CHAPTER_CONTROLLER(ParserNode *node) {
+ const Common::String &appearance = node->values.getValOrDefault("text_appearance");
+ _textAppearance = appearance.equalsIgnoreCase("true") || appearance == "1";
+ _charDelay = delay(node, "char_delay", _charDelay);
+ _soundDelay = delay(node, "sound_delay", _soundDelay);
+ _fadeIn = delay(node, "fadein_delay", _fadeIn);
+ _fadeOut = delay(node, "fadeout_delay", _fadeOut);
+ return true;
+ }
+
+ bool parserCallback_TEXT(ParserNode *node) {
+ const Common::String &id = node->values["id"];
+ if (id == "STR_CHAPTER")
+ _title = node->values["text"];
+ if (id == _textId)
+ _text = node->values["text"];
+ return true;
+ }
+
+ bool handleUnknownKey(ParserNode *node) override {
+ if (!getParentNode(node))
+ return false;
+ node->layout = _XMLkeys;
+ node->ignore = true;
+ return true;
+ }
+};
+
+class ModalChapter : public BaseModalObject {
+public:
+ ModalChapter(Scene &scene, const char *id) : _scene(scene), _settings(id) {}
+
+ ~ModalChapter() override {
+ if (_shown) {
+ if (_scene._soundList)
+ _scene.stopAllSounds();
+ setModal(false);
+ }
+ }
+
+ bool open() {
+ const Common::String locale = g_nmi->getAndroidResourceLocale();
+ const Common::Path directory("data/res_" + locale);
+ const Common::Path fonts = directory.join("Fonts");
+ if (!_settings.load(directory)) {
+ warning("Could not read Android chapter settings or text for %s", locale.c_str());
+ return false;
+ }
+ if (_settings._countShow == 1)
+ return false;
+ if (!_font.load(fonts.join("task_dlg_30.fnt")))
+ return false;
+ if (locale == "ru") {
+ _titleFont.reset(new BitmapFont());
+ if (!_titleFont->load(fonts.join("task_dlg_38.fnt")))
+ return false;
+ }
+
+ const uint length = _settings._title.size() + _settings._text.size();
+ _visibleChars = _settings._textAppearance ? 0 : length;
+ const int64 soundTime = (int64)_settings._soundDelay - _settings._fadeIn - _settings._fadeOut;
+ const int64 textTime = (int64)length * _settings._charDelay;
+ const uint32 hold = MIN<int64>(UINT32_MAX, MAX(soundTime, textTime));
+ _shown = true;
+ setModal(true);
+ _fader.start(_settings._fadeIn, hold, _settings._fadeOut);
+ if (_scene._soundList) {
+ Sound *sound = _scene._soundList->getSound(SND_CHAPTER_DLG);
+ if (sound)
+ sound->play(0);
+ }
+ debugC(2, kDebugSceneLogic, "Opened Android chapter dialog (%s, %u ms hold)", locale.c_str(), hold);
+ return true;
+ }
+
+ bool pollEvent() override { return true; }
+ void saveload() override {}
+
+ bool handleMessage(Command *message) override {
+ if (message->_cmd != 17 || (message->_messageNum != 30 &&
+ !(message->_messageNum == 37 && message->_param == kActionCloseDialog)))
+ return false;
+ _visibleChars = _settings._title.size() + _settings._text.size();
+ _fader.fadeOut();
+ return true;
+ }
+
+ bool init(int elapsed) override {
+ _fader.update(elapsed);
+ if (!_fader.active()) {
+ debugC(2, kDebugSceneLogic, "Closed Android chapter dialog");
+ return false;
+ }
+ if (_visibleChars < _settings._title.size() + _settings._text.size()) {
+ _charElapsed += elapsed;
+ if (_charElapsed >= (uint)_settings._charDelay) {
+ ++_visibleChars;
+ _charElapsed = 0;
+ }
+ }
+ return true;
+ }
+
+ void update() override {
+ Graphics::ManagedSurface &frame = g_nmi->_backgroundSurface;
+ _scene.drawAndroid(frame);
+ if (_fader.brightness() < 255)
+ g_nmi->drawAlphaRectangle(0, 0, frame.w, frame.h, _fader.brightness());
+ const BitmapFont &titleFont = _titleFont ? *_titleFont : _font;
+ titleFont.drawCentered(frame, Common::Rect(130, 300, 360, _titleFont ? 385 : 405),
+ _settings._title.substr(0, _visibleChars));
+ if (_visibleChars > _settings._title.size())
+ _font.drawCentered(frame, Common::Rect(440, 180, 685, _titleFont ? 495 : 505),
+ _settings._text.substr(0, _visibleChars - _settings._title.size()));
+ }
+
+private:
+ void setModal(bool active) {
+ Common::Keymapper *mapper = g_system->getEventManager()->getKeymapper();
+ mapper->setGameKeymapState("ngi-default", !active);
+ mapper->setGameKeymapState("dialog", active);
+ SoundList *sounds = g_nmi->_currentScene->_soundList.get();
+ if (sounds) {
+ for (int i = 0; i < sounds->getCount(); ++i)
+ sounds->getSoundByIndex(i).pause(active);
+ }
+ }
+
+ bool _shown = false;
+ Scene &_scene;
+ ChapterSettings _settings;
+ BitmapFont _font;
+ Common::ScopedPtr<BitmapFont> _titleFont;
+ Fader _fader;
+ uint _visibleChars = 0;
+ uint32 _charElapsed = 0;
+};
+
+} // End of anonymous namespace
+
+void sceneChapter_show(const char *chapterId) {
+ Scene *scene = g_nmi->findScene(SC_CHAPTER);
+ if (!scene)
+ return;
+ Common::ScopedPtr<ModalChapter> dialog(new ModalChapter(*scene, chapterId));
+ if (dialog->open()) {
+ dialog->_parentObj = g_nmi->_modalObject;
+ g_nmi->_modalObject = dialog.release();
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index fb4ce6230eb..3f868d97dfa 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -34,7 +34,8 @@ void sceneIntro_initMan(Scene &scene) {
g_vars->sceneIntro_aniin1man = scene.findAniObjectById(ANI_IN1MAN, -1);
g_vars->sceneIntro_needSleep = true;
g_vars->sceneIntro_needGetup = false;
- g_vars->sceneIntro_fadeElapsed = 0;
+ g_vars->sceneIntro_playing = true;
+ g_vars->sceneIntro_fader.start(1025, 0, 0);
}
static bool sceneIntro_updateMan() {
@@ -52,15 +53,15 @@ static bool sceneIntro_updateMan() {
}
bool sceneIntro_updateAndroid(uint32 elapsed, byte &brightness) {
- const uint32 fadeDuration = 1025;
- const uint32 previous = g_vars->sceneIntro_fadeElapsed;
- if (previous < fadeDuration) {
- g_vars->sceneIntro_fadeElapsed += MIN(elapsed, fadeDuration - previous);
- // CFader samples the alpha before advancing its timer and clears it at the end.
- const byte next = g_vars->sceneIntro_fadeElapsed == fadeDuration ? 255 : previous * 255 / fadeDuration;
- const bool changed = brightness != next;
- brightness = next;
- if (g_vars->sceneIntro_fadeElapsed == fadeDuration)
+ if (!g_vars->sceneIntro_playing)
+ return false;
+
+ Fader &fader = g_vars->sceneIntro_fader;
+ if (fader.active()) {
+ fader.update(elapsed);
+ const bool changed = brightness != fader.brightness();
+ brightness = fader.brightness();
+ if (!fader.active())
runQueue(QU_INTR_STARTINTRO, 0);
return changed;
}
@@ -78,7 +79,6 @@ void sceneIntro_initScene(Scene *sc) {
g_nmi->_gameLoader->loadScene(SC_INTRO2);
sceneIntro_initMan(*sc);
- g_vars->sceneIntro_playing = true;
g_vars->sceneIntro_needBlackout = false;
if (g_nmi->_recordEvents || g_nmi->_inputArFlag)
@@ -103,7 +103,7 @@ int sceneHandlerIntro(Command *ex) {
if (g_nmi->getPlatform() == Common::kPlatformAndroid && !ex->_messageName.empty()) {
debugC(3, kDebugEvents, "Android intro message %s", ex->_messageName.c_str());
- if (ex->_messageNum == MSG_INTR_ENDINTRO || ex->_messageName == "MSG_ENABLE_BHV_SOUND") {
+ if (ex->_messageName == "MSG_ENABLE_BHV_SOUND") {
warning("Android intro message %s not implemented", ex->_messageName.c_str());
return 0;
}
@@ -111,6 +111,8 @@ int sceneHandlerIntro(Command *ex) {
switch (ex->_messageNum) {
case MSG_INTR_ENDINTRO:
+ if (g_vars->sceneIntro_playing && g_nmi->getPlatform() == Common::kPlatformAndroid)
+ sceneChapter_show("CHAPTER_1");
g_vars->sceneIntro_playing = 0;
return 0;
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 5a3f45949fc..0604a906985 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -529,6 +529,11 @@ void Texture::setAOIDs() {
}
}
+void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Rect &source, const Common::Point &position) const {
+ if (_bitmap && _bitmap->_surface)
+ target.blitFrom(*_bitmap->_surface, source, position);
+}
+
void Texture::init() {
debugC(5, kDebugLoading, "Texture::init(), %s", _memfilename.toString().c_str());
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index 9dbf931d775..c9f3e60434a 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -91,6 +91,7 @@ public:
bool load(MfcArchive &file) override;
void loadPNG(const Common::Path &path, const Dims &sizeHint);
void blitTo(Graphics::ManagedSurface &target, const Common::Point &position) const;
+ void blitTo(Graphics::ManagedSurface &target, const Common::Rect &source, const Common::Point &position) const;
void setAOIDs();
virtual void init();
void getDibInfo();
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index a00b37470ee..cc897ee9e74 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS = \
behavior.o \
console.o \
floaters.o \
+ font.o \
gameloader.o \
gfx.o \
init.o \
@@ -27,6 +28,7 @@ MODULE_OBJS = \
statesaver.o \
statics.o \
utils.o \
+ fullpipe/sceneChapter.o \
fullpipe/sceneIntro.o \
fullpipe/sceneIntroDemo.o \
fullpipe/scene01.o \
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index d2e67a70f53..43bc7ad28cb 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -145,6 +145,7 @@ public:
uint32 getFeatures() const;
bool isDemo();
Common::Language getLanguage() const;
+ const char *getAndroidResourceLocale() const;
Common::Platform getPlatform() const;
const char *getGameId() const;
int getGameGID() const;
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 71b0d02ea55..919198649aa 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -54,6 +54,7 @@ class Scene : public Background {
void initStaticANIObjects();
void init();
void render();
+ void drawAndroid(Graphics::ManagedSurface &target) const;
void drawContent(int minPri, int maxPri, bool drawBG);
void updateScrolling();
void updateScrolling2();
diff --git a/engines/ngi/scenes.cpp b/engines/ngi/scenes.cpp
index 602ad339e18..80c0c106565 100644
--- a/engines/ngi/scenes.cpp
+++ b/engines/ngi/scenes.cpp
@@ -36,6 +36,43 @@
namespace NGI {
+void Fader::start(uint32 fadeIn, uint32 hold, uint32 fadeOut) {
+ _durations[kFadeIn] = fadeIn;
+ _durations[kHold] = hold;
+ _durations[kFadeOut] = fadeOut;
+ _stage = kFadeIn;
+ _elapsed = 0;
+ _brightness = 0;
+}
+
+void Fader::fadeOut() {
+ if (active() && _stage != kFadeOut) {
+ _stage = kFadeOut;
+ _elapsed = 0;
+ }
+}
+
+void Fader::update(uint32 elapsed) {
+ if (!active())
+ return;
+ const uint32 duration = _durations[_stage];
+ if (elapsed < duration - _elapsed) {
+ // CFader samples the current alpha before advancing its timer.
+ if (_stage != kHold) {
+ const byte level = (uint64)_elapsed * 255 / duration;
+ _brightness = _stage == kFadeIn ? level : 255 - level;
+ }
+ _elapsed += elapsed;
+ return;
+ }
+
+ _brightness = _stage == kFadeOut ? 0 : 255;
+ _elapsed = 0;
+ do {
+ _stage = (Stage)(_stage + 1);
+ } while (active() && !_durations[_stage]);
+}
+
Vars::Vars() {
sceneIntro_aniin1man = nullptr;
sceneIntro_needSleep = true;
diff --git a/engines/ngi/scenes.h b/engines/ngi/scenes.h
index d18549b5df5..fad097273dc 100644
--- a/engines/ngi/scenes.h
+++ b/engines/ngi/scenes.h
@@ -34,7 +34,24 @@ class AniObject;
struct Swinger;
struct WalkingBearder;
+class Fader {
+public:
+ void start(uint32 fadeIn, uint32 hold, uint32 fadeOut);
+ void update(uint32 elapsed);
+ void fadeOut();
+ bool active() const { return _stage != kDone; }
+ byte brightness() const { return _brightness; }
+
+private:
+ enum Stage { kFadeIn, kHold, kFadeOut, kDone };
+ Stage _stage = kDone;
+ uint32 _durations[3] = {};
+ uint32 _elapsed = 0;
+ byte _brightness = 255;
+};
+
int defaultUpdateCursor();
+void sceneChapter_show(const char *chapterId);
int sceneIntro_updateCursor();
void sceneIntro_initScene(Scene *sc);
@@ -225,7 +242,7 @@ public:
AniObject *sceneIntro_aniin1man;
bool sceneIntro_needSleep;
- uint32 sceneIntro_fadeElapsed = 0;
+ Fader sceneIntro_fader;
bool sceneIntro_needGetup;
bool sceneIntro_skipIntro;
bool sceneIntro_playing;
diff --git a/engines/ngi/sound.cpp b/engines/ngi/sound.cpp
index 8498e50e47a..dce26fc21cc 100644
--- a/engines/ngi/sound.cpp
+++ b/engines/ngi/sound.cpp
@@ -258,6 +258,12 @@ int Sound::getVolume() {
return g_nmi->_mixer->getChannelVolume(*_handle) * 39; // 0..10000
}
+void Sound::pause(bool paused) {
+ g_nmi->_mixer->pauseHandle(*_handle, paused);
+ for (const Audio::SoundHandle &handle : _overlappingHandles)
+ g_nmi->_mixer->pauseHandle(handle, paused);
+}
+
void Sound::stop() {
g_nmi->_mixer->stopHandle(*_handle);
for (const Audio::SoundHandle &handle : _overlappingHandles)
diff --git a/engines/ngi/sound.h b/engines/ngi/sound.h
index 514a1acbd9e..1ecd0257bd5 100644
--- a/engines/ngi/sound.h
+++ b/engines/ngi/sound.h
@@ -54,6 +54,7 @@ public:
void unload();
int getVolume();
void stop();
+ void pause(bool paused);
void setPanAndVolumeByStaticAni();
void attenuate(int vol, int pan);
Commit: 820089314e5dee94073a03b7bbd1db71c10de9db
https://github.com/scummvm/scummvm/commit/820089314e5dee94073a03b7bbd1db71c10de9db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:42+01:00
Commit Message:
NGI: Play the first Android room entrance after the intro
Changed paths:
engines/ngi/android.cpp
engines/ngi/fullpipe/scene01.cpp
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/messagehandlers.cpp
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/scenes.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index 310c1810ad7..d5a86c79859 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -224,9 +224,13 @@ private:
bool _hasInitialStatics = false;
int16 _initialStaticsId = 0;
- void loadTexture(Texture &texture, const Common::String &resource, bool localized) {
+ Common::Path texturePath(const Common::String &resource, bool localized) const {
const Common::String directory = localized ? Common::String::format("data/res_%s", _locale) : "data/res";
- const Common::Path path = Common::Path(directory).join(resource + ".png");
+ return Common::Path(directory).join(resource + ".png");
+ }
+
+ void loadTexture(Texture &texture, const Common::String &resource, bool localized) {
+ const Common::Path path = texturePath(resource, localized);
texture.loadPNG(path, _project._textureSizes.getValOrDefault(path));
}
@@ -244,6 +248,16 @@ private:
XML_PROP(putPrev, false)
XML_PROP(scrollX, false)
XML_PROP(scrollY, false)
+ XML_KEY(ADDANI)
+ XML_PROP(id, true)
+ XML_PROP(scene, true)
+ XML_PROP(copy, false)
+ KEY_END()
+ XML_KEY(ENTRANCE)
+ XML_PROP(id, true)
+ XML_PROP(scene, true)
+ XML_PROP(queue, true)
+ KEY_END()
XML_KEY(SOUND)
XML_PROP(id, true)
XML_PROP(file, true)
@@ -266,9 +280,21 @@ private:
XML_PROP(cycled, false)
XML_PROP(stop, false)
XML_PROP(delay, false)
+ XML_PROP(x, false)
+ XML_PROP(y, false)
+ XML_PROP(z, false)
+ XML_PROP(mirror, false)
+ XML_PROP(static, false)
+ XML_PROP(stat, false)
+ XML_PROP(type, false)
+ XML_PROP(state, false)
+ XML_PROP(picId, false)
+ XML_PROP(title, false)
KEY_END()
KEY_END()
XML_KEY(PICTURE)
+ XML_PROP(filter, false)
+ XML_PROP(serializable, false)
XML_PROP(id, true)
XML_PROP(title, false)
XML_PROP(x, false)
@@ -278,6 +304,8 @@ private:
XML_PROP(locale, false)
KEY_END()
XML_KEY(OLDANI)
+ XML_PROP(mirror, false)
+ XML_PROP(serializable, false)
XML_PROP(id, true)
XML_PROP(title, false)
XML_PROP(x, false)
@@ -294,6 +322,8 @@ private:
XML_PROP(locale, false)
KEY_END()
XML_KEY(MOVEMENT)
+ XML_PROP(mirrorPrev, false)
+ XML_PROP(mirrorNext, false)
XML_PROP(id, true)
XML_PROP(title, false)
XML_PROP(x, false)
@@ -328,12 +358,33 @@ private:
int16 id;
if (!readId(node->values["id"], id) || id != _scene._sceneId)
return parserError("Scene ID does not match the project");
+ if (node->values.contains("hero") && !node->values["hero"].empty() && !readId(node->values["hero"], _scene._heroId))
+ return parserError("Unknown scene hero");
_scene._sceneName = node->values.getValOrDefault("title");
_scene._x = strtod(node->values.getValOrDefault("scrollX").c_str(), nullptr);
_scene._y = strtod(node->values.getValOrDefault("scrollY").c_str(), nullptr);
return true;
}
+ bool parserCallback_ADDANI(ParserNode *node) {
+ PicAniInfo ref;
+ if (!readId(node->values["id"], ref.objectId) || !readId(node->values["scene"], ref.sceneId))
+ return parserError("Unknown roaming animation or scene");
+ ref.copyId = atoi(node->values.getValOrDefault("copy").c_str());
+ _scene._roamingObjects.push_back(ref);
+ return true;
+ }
+
+ bool parserCallback_ENTRANCE(ParserNode *node) {
+ uint32 id, scene, queue;
+ if (!_project._objectIds.findId(node->values["id"], id) ||
+ !_project._objectIds.findId(node->values["scene"], scene) ||
+ !_project._objectIds.findId(node->values["queue"], queue))
+ return parserError("Unknown ID in scene entrance");
+ _scene._entrances.push_back(Entrance{(int32)scene, (int32)id, (int32)queue, 0});
+ return true;
+ }
+
bool parserCallback_PICTURE(ParserNode *node) {
Common::ScopedPtr<PictureObject> picture(new PictureObject());
if (!parseObject(*picture, *node))
@@ -390,7 +441,23 @@ private:
cmd->_param = atoi(node->values.getValOrDefault("copy").c_str());
const char *idProperty = nullptr;
- if (kind == "START_MOVEMENT" || kind == "3") {
+ if (kind == "SHOW" || kind == "1") {
+ cmd->_cmd = 5;
+ cmd->_wait = 0;
+ if (!readId(node->values.getValOrDefault("ani"), cmd->_parentId))
+ return parserError("Unknown animation in SHOW");
+ cmd->_messageNum = -1;
+ if (!node->values.getValOrDefault("mov").empty())
+ idProperty = "mov";
+ cmd->_x = atoi(node->values.getValOrDefault("x", "-1").c_str());
+ cmd->_y = atoi(node->values.getValOrDefault("y", "-1").c_str());
+ cmd->_z = atoi(node->values.getValOrDefault("z", "-1").c_str());
+ cmd->_auxParam = node->values.contains("mirror") ? (int)boolProperty(*node, "mirror") : -1;
+ } else if (kind == "USER" || kind == "12" || kind == "SET_STATIC" || kind == "25") {
+ cmd->_cmd = 63;
+ cmd->_messageName = node->values.getValOrDefault("type", kind);
+ cmd->_wait = 0;
+ } else if (kind == "START_MOVEMENT" || kind == "3") {
cmd->_cmd = 1;
if (!readId(node->values.getValOrDefault("ani"), cmd->_parentId))
return parserError("Unknown animation in START_MOVEMENT");
@@ -449,6 +516,8 @@ private:
if (_hasInitialStatics && !readId(statics, _initialStaticsId))
return parserError("Unknown initial statics ID '" + statics + "'");
+ if (boolProperty(*node, "mirror"))
+ animation->_flags |= 8;
animation->_sceneId = _scene._sceneId;
return true;
}
@@ -537,7 +606,8 @@ private:
phase->_delayRelative = atoi(node->values.getValOrDefault("delayRelative").c_str());
phase->_x = atoi(node->values.getValOrDefault("x").c_str());
phase->_y = atoi(node->values.getValOrDefault("y").c_str());
- loadTexture(*phase, resource, isLocalized(*getParentNode(node)));
+ const Common::Path path = texturePath(resource, isLocalized(*getParentNode(node)));
+ phase->setPNG(path, _project._textureSizes.getValOrDefault(path));
movement._framePosOffsets.insert_at(index, Common::Point(phase->_x, phase->_y));
movement._phases.insert_at(index, phase.release());
@@ -603,7 +673,11 @@ void Scene::drawAndroid(Graphics::ManagedSurface &target) const {
} else {
const AniObject &animation = *static_cast<const AniObject *>(object);
const Phase *phase = animation._movement ? animation._movement->_curPhase : animation._statics;
- phase->blitTo(target, position - animation.getSomeXY());
+ Common::Point anchor = animation.getSomeXY();
+ const bool mirror = (animation._flags & 8) != 0;
+ if (mirror)
+ anchor.x = phase->getDimensions().x - anchor.x;
+ phase->blitTo(target, position - anchor, mirror);
}
}
}
@@ -639,6 +713,47 @@ void SceneTag::loadSceneXML(const GameProject &project) {
_scene = scene.release();
}
+Common::Error NGIEngine::enterAndroidScene1() {
+ Scene *room = findScene(SC_1);
+ Scene *common = findScene(SC_COMMON);
+ if (!room || !common)
+ return Common::Error(Common::kNoGameDataFoundError, "Could not load the first Full Pipe Android room");
+ for (const PicAniInfo &ref : room->_roamingObjects) {
+ Scene *source = findScene(ref.sceneId);
+ AniObject *actor = source ? source->findAniObjectById(ref.objectId, ref.copyId) : nullptr;
+ if (!actor)
+ return Common::Error(Common::kNoGameDataFoundError, "Missing roaming animation for the first Android room");
+ if (!room->findAniObjectById(ref.objectId, ref.copyId))
+ room->_renderableAnis.push_back(actor);
+ }
+ _aniMan = room->findAniObjectById(room->_heroId, 0);
+ _aniMan2 = _aniMan;
+ if (!_aniMan)
+ return Common::Error(Common::kNoGameDataFoundError, "Missing hero for the first Android room");
+
+ clearGlobalMessageQueueList1();
+ clearMessageHandlers();
+ stopAllSounds(-1);
+ _currSoundListCount = 0;
+ if (room->_soundList)
+ _currSoundList1[_currSoundListCount++] = room->_soundList.get();
+ if (common->_soundList)
+ _currSoundList1[_currSoundListCount++] = common->_soundList.get();
+
+ _currentScene = room;
+ addMessageHandlerByIndex(global_messageHandler4, 0, 4);
+ addMessageHandler(sceneHandler01, 2);
+ // CStateManager::SetStartStates starts a new game with the egg uncracked.
+ scene01_initObjects(room, TrubaLeft, true);
+ for (const Entrance &entrance : room->_entrances) {
+ if (entrance._id == TrubaLeft && entrance._sceneId == room->_sceneId && runQueue(entrance._queueId, 0)) {
+ debugC(1, kDebugSceneLogic, "Entered Android scene %d through entrance %d, queue %d", room->_sceneId, entrance._id, entrance._queueId);
+ return Common::kNoError;
+ }
+ }
+ return Common::Error(Common::kNoGameDataFoundError, "Could not start the TrubaLeft entrance queue");
+}
+
Common::Error NGIEngine::runAndroid() {
const auto &files = _gameDescription->desc.filesDescriptions;
const Common::FSNode gameDirectory(ConfMan.getPath("path"));
@@ -707,6 +822,7 @@ Common::Error NGIEngine::runAndroid() {
Common::Event event;
Common::EventManager *eventManager = _system->getEventManager();
+ Common::Error result = Common::kNoError;
uint32 lastUpdate = _system->getMillis();
while (!shouldQuit()) {
bool screenChanged = false;
@@ -735,11 +851,8 @@ Common::Error NGIEngine::runAndroid() {
bool redraw = false;
Scene *scene = _currentScene;
if (_modalObject) {
- if (!_modalObject->init(elapsed)) {
+ if (!_modalObject->init(elapsed))
deleteModalObject();
- if (!_modalObject && scene->_sceneId == SC_INTRO1 && !g_vars->sceneIntro_playing)
- warning("Android scene 1 entrance TrubaLeft not implemented");
- }
redraw = true;
} else {
for (MessageQueue *queue : *_globalMessageQueueList)
@@ -759,6 +872,14 @@ Common::Error NGIEngine::runAndroid() {
debugC(2, kDebugDrawing, "Switched Android scene from %d to %d", scene->_sceneId, _currentScene->_sceneId);
redraw = true;
}
+ if (!_modalObject && _currentScene->_sceneId == SC_INTRO1 && !g_vars->sceneIntro_playing) {
+ result = enterAndroidScene1();
+ if (result.getCode() != Common::kNoError)
+ break;
+ lastUpdate = _system->getMillis();
+ brightness = 255;
+ redraw = true;
+ }
if (redraw) {
frame.clear(format.RGBToColor(0, 0, 0));
if (_modalObject) {
@@ -781,9 +902,12 @@ Common::Error NGIEngine::runAndroid() {
while (_currSoundListCount)
_currSoundList1[--_currSoundListCount] = nullptr;
g_vars->sceneIntro_aniin1man = nullptr;
+ g_vars->scene01_picSc01Osk = nullptr;
+ g_vars->scene01_picSc01Osk2 = nullptr;
+ _aniMan = _aniMan2 = nullptr;
_currentScene = nullptr;
_gameProject = nullptr;
- return Common::kNoError;
+ return result;
}
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index ca0c2dc7e82..f6e02c96d9a 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -41,14 +41,14 @@ void scene01_fixEntrance() {
var->setSubVarAsInt("Entrance", TrubaRight);
}
-void scene01_initScene(Scene *sc, int entrance) {
+void scene01_initObjects(Scene *sc, int entrance, bool eggUncracked) {
g_vars->scene01_picSc01Osk = sc->findPictureObjectById(PIC_SC1_OSK, 0);
g_vars->scene01_picSc01Osk->_flags &= 0xFFFB;
g_vars->scene01_picSc01Osk2 = sc->findPictureObjectById(PIC_SC1_OSK2, 0);
g_vars->scene01_picSc01Osk2->_flags &= 0xFFFB;
- if (g_nmi->getStateId(sO_EggCracker) == g_nmi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg)) {
+ if (eggUncracked) {
PictureObject *pic = sc->findPictureObjectById(PIC_SC1_KUCHKA, 0);
if (pic)
pic->_flags &= 0xFFFB;
@@ -59,7 +59,10 @@ void scene01_initScene(Scene *sc, int entrance) {
if (bootAnim)
bootAnim->_flags &= ~0x04;
}
+}
+void scene01_initScene(Scene *sc, int entrance) {
+ scene01_initObjects(sc, entrance, g_nmi->getStateId(sO_EggCracker) == g_nmi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg));
g_nmi->lift_setButton(sO_Level2, ST_LBN_2N);
}
@@ -69,6 +72,11 @@ int sceneHandler01(Command *cmd) {
if (cmd->_cmd != 17)
return 0;
+ if (!cmd->_messageNum && !cmd->_messageName.empty()) {
+ warning("Android scene 1 message %s not implemented", cmd->_messageName.c_str());
+ return 0;
+ }
+
if (cmd->_messageNum > MSG_SC1_SHOWOSK) {
if (cmd->_messageNum == MSG_SC1_UTRUBACLICK)
handleObjectInteraction(g_nmi->_aniMan, g_nmi->_currentScene->findPictureObjectById(PIC_SC1_LADDER, 0), 0);
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 0604a906985..3b71eb7b1b7 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -446,8 +446,12 @@ void Texture::loadPNG(const Common::Path &path, const Dims &sizeHint) {
debugC(2, kDebugLoading, "Loaded scene texture %s (%d x %d)", path.toString().c_str(), _width, _height);
}
-void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &position) const {
- if (_bitmap && _bitmap->_surface)
+void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &position, bool mirror) const {
+ if (!_bitmap || !_bitmap->_surface)
+ return;
+ if (mirror)
+ target.simpleBlitFrom(*_bitmap->_surface, position, Graphics::FLIP_H, true);
+ else
target.blitFrom(*_bitmap->_surface, position);
}
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index c9f3e60434a..c2a415050df 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -90,7 +90,7 @@ public:
bool load(MfcArchive &file) override;
void loadPNG(const Common::Path &path, const Dims &sizeHint);
- void blitTo(Graphics::ManagedSurface &target, const Common::Point &position) const;
+ void blitTo(Graphics::ManagedSurface &target, const Common::Point &position, bool mirror = false) const;
void blitTo(Graphics::ManagedSurface &target, const Common::Rect &source, const Common::Point &position) const;
void setAOIDs();
virtual void init();
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 41afee1f600..9dbdd58cb9f 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -689,7 +689,13 @@ int global_messageHandler4(Command *cmd) {
if (cmd->_z >= 0)
ani->_z = cmd->_z;
- ani->show1(cmd->_x, cmd->_y, cmd->_messageNum, cmd->_parId);
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid) {
+ const bool mirror = cmd->_auxParam < 0 ? (ani->_flags & 8) != 0 : cmd->_auxParam != 0;
+ ani->show1(cmd->_x == -1 ? ani->_x : cmd->_x, cmd->_y == -1 ? ani->_y : cmd->_y, cmd->_messageNum, 0);
+ ani->_flags = (ani->_flags & ~8) | (mirror ? 8 : 0);
+ } else {
+ ani->show1(cmd->_x, cmd->_y, cmd->_messageNum, cmd->_parId);
+ }
break;
case 10:
@@ -746,6 +752,12 @@ int global_messageHandler4(Command *cmd) {
global_messageHandler_handleSound(cmd);
break;
+ case 63:
+ if (g_nmi->getPlatform() != Common::kPlatformAndroid)
+ return 0;
+ warning("Android command %s not implemented", cmd->_messageName.c_str());
+ break;
+
case 11:
case 12:
break;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 43bc7ad28cb..cb3d2e5d0fd 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -129,6 +129,7 @@ protected:
Common::Error run() override;
Common::Error runAndroid();
+ Common::Error enterAndroidScene1();
public:
NGIEngine(OSystem *syst, const NGIGameDescription *gameDesc);
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 7b15e4cbc3a..bbf579ed6c2 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -274,11 +274,11 @@ AniObject *Scene::getAniMan() {
}
AniObject *Scene::findAniObjectById(int obj, int a3) {
- for (uint i = 0; i < _aniObjects.size(); i++) {
- if (_aniObjects[i]->_id == obj && (a3 == -1 || _aniObjects[i]->_copyId == a3))
- return _aniObjects[i];
+ const auto &objects = _roamingObjects.empty() ? _aniObjects : _renderableAnis;
+ for (AniObject *ani : objects) {
+ if (ani->_id == obj && (a3 == -1 || ani->_copyId == a3))
+ return ani;
}
-
return nullptr;
}
@@ -335,7 +335,7 @@ void Scene::stopAllSounds() {
}
PictureObject *Scene::findPictureObjectById(int objId, int flags) {
- for (uint i = 1; i < _pictureObjects.size(); i++) {
+ for (uint i = g_nmi->getPlatform() == Common::kPlatformAndroid ? 0 : 1; i < _pictureObjects.size(); i++) {
if (_pictureObjects[i]->_id == objId && _pictureObjects[i]->_copyId == flags)
return _pictureObjects[i];
}
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 919198649aa..b281a112edb 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -23,7 +23,9 @@
#define NGI_SCENE_H
#include "common/ptr.h"
+#include "ngi/objects.h"
#include "ngi/gfx.h"
+#include "ngi/interaction.h"
namespace NGI {
@@ -35,7 +37,11 @@ class Scene : public Background {
/** list items are owned */
Common::Array<AniObject *> _aniObjects;
+ // Includes non-owning references to roaming XML actors from other scenes.
Common::Array<AniObject *> _renderableAnis;
+ PicAniInfoList _roamingObjects;
+ Common::Array<Entrance> _entrances;
+ int16 _heroId = 0;
Common::Array<MessageQueue *> _messageQueues;
// PtrList _faObjectList; // not used
Common::ScopedPtr<Shadows> _shadows;
diff --git a/engines/ngi/scenes.h b/engines/ngi/scenes.h
index fad097273dc..a40f58e1374 100644
--- a/engines/ngi/scenes.h
+++ b/engines/ngi/scenes.h
@@ -65,6 +65,7 @@ int sceneHandlerIntroDemo(Command *cmd);
void scene01_fixEntrance();
void scene01_initScene(Scene *sc, int entrance);
+void scene01_initObjects(Scene *sc, int entrance, bool eggUncracked);
int sceneHandler01(Command *cmd);
void scene02_initScene(Scene *sc);
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 72a9208a851..69d4426873c 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -952,11 +952,12 @@ L12:
_statics->_x = _x - point.x;
_statics->_y = _y - point.y;
oid = _movement->_id;
- _movement = nullptr;
if (g_nmi->getPlatform() == Common::kPlatformAndroid) {
+ _movement->unload();
for (int i = 0; i < g_nmi->_currSoundListCount; ++i)
g_nmi->_currSoundList1[i]->stopByCreator(_id);
}
+ _movement = nullptr;
Command *ex = new Command(_id, 17, 24, 0, 0, 0, 1, 0, 0, 0);
ex->_param = _copyId;
@@ -1312,7 +1313,7 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
point = _movement->getCurrDynamicPhaseXY();
setPos(point.x + newx, point.y + newy);
- if (_movement->_nextStatic->_staticsId & 0x4000)
+ if (!android && (_movement->_nextStatic->_staticsId & 0x4000))
_flags |= 8;
else
_flags &= 0xFFF7;
@@ -1858,6 +1859,12 @@ void Movement::load() {
}
void Movement::unload() {
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid) {
+ // XML movements borrow their last phase from the actor's statics.
+ for (uint i = 0; i + 1 < _phases.size(); ++i)
+ _phases[i]->unload();
+ return;
+ }
if (!_currMovement)
for (uint i = 0; i < _phases.size(); i++)
_phases[i]->unload();
@@ -2165,7 +2172,15 @@ Common::String Phase::toXML() {
StaticPhase::toXML().c_str());
}
+void Phase::setPNG(const Common::Path &path, const Dims &size) {
+ _memfilename = path;
+ _width = size.x;
+ _height = size.y;
+}
+
void Phase::enter(int objectId) {
+ if (!_bitmap && !_memfilename.empty())
+ loadPNG(_memfilename, getDimensions());
if (_soundId && g_nmi->_soundEnabled)
g_nmi->playSound(_soundId, _loopSound, objectId);
if (_command) {
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 5f56d3a60ff..ff130f27e34 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -81,6 +81,7 @@ class Phase : public StaticPhase {
public:
Phase();
Phase(Phase *src, bool reverse);
+ void setPNG(const Common::Path &path, const Dims &size);
void enter(int objectId);
bool load(MfcArchive &file) override;
Commit: edc11ffc50694b7d5b8c40547086d1f3fa5cd342
https://github.com/scummvm/scummvm/commit/edc11ffc50694b7d5b8c40547086d1f3fa5cd342
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:42+01:00
Commit Message:
NGI: Play Android scene ambience and music from XML
Changed paths:
engines/ngi/android.cpp
engines/ngi/behavior.cpp
engines/ngi/behavior.h
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/sceneChapter.cpp
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/sound.cpp
engines/ngi/sound.h
engines/ngi/statics.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index d5a86c79859..549b4d1521d 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -31,6 +31,7 @@
#include "backends/keymapper/keymapper.h"
#include "engines/util.h"
#include "ngi/ngi.h"
+#include "ngi/behavior.h"
#include "ngi/constants.h"
#include "ngi/detection.h"
#include "ngi/messages.h"
@@ -264,6 +265,16 @@ private:
XML_PROP(title, false)
XML_PROP(flags, false)
KEY_END()
+ XML_KEY(BEHAVIORCONTROLLER)
+ XML_KEY(BHVR_SOUND)
+ XML_PROP(id, true)
+ XML_PROP(delay, false)
+ XML_PROP(percent, false)
+ XML_PROP(flags, false)
+ XML_PROP(enable, false)
+ KEY_END()
+ layout.top()->children["BHVR_MUSIC"] = layout.top()->children["BHVR_SOUND"];
+ KEY_END()
XML_KEY(QUEUE)
XML_PROP(id, true)
XML_PROP(title, false)
@@ -400,7 +411,7 @@ private:
}
bool parserCallback_SOUND(ParserNode *node) {
- int16 id;
+ uint16 id;
if (!readId(node->values["id"], id))
return parserError("Unknown sound ID " + node->values["id"]);
const int flags = atoi(node->values.getValOrDefault("flags").c_str());
@@ -427,6 +438,23 @@ private:
return true;
}
+ bool parserCallback_BEHAVIORCONTROLLER(ParserNode *) {
+ _scene._behaviorController.reset(new BehaviorController());
+ return true;
+ }
+
+ bool parserCallback_BHVR_SOUND(ParserNode *node) {
+ BehaviorSound sound = {};
+ if (!readId(node->values["id"], sound._soundId))
+ return parserError("Unknown behavior sound " + node->values["id"]);
+ sound._delay = strtoul(node->values.getValOrDefault("delay").c_str(), nullptr, 10);
+ sound._percent = strtoul(node->values.getValOrDefault("percent").c_str(), nullptr, 10);
+ sound._loop = atoi(node->values.getValOrDefault("flags").c_str()) != 0;
+ sound._enabled = !node->values.contains("enable") || boolProperty(*node, "enable");
+ _scene._behaviorController->addSound(sound, node->name == "BHVR_MUSIC");
+ return true;
+ }
+
static bool boolProperty(const ParserNode &node, const char *name) {
const Common::String &value = node.values.getValOrDefault(name);
return value == "1" || value == "true" || value == "yes";
@@ -476,7 +504,8 @@ private:
cmd->_cmd = 35;
cmd->_param = boolProperty(*node, "cycled");
cmd->_z = boolProperty(*node, "stop") ? 2 : 1;
- idProperty = "id";
+ if (!readId(node->values.getValOrDefault("id"), cmd->_messageNum))
+ return parserError("Unknown sound in SOUND");
} else if (kind == "MESSAGE" || kind == "5") {
cmd->_cmd = 17;
cmd->_messageName = node->values.getValOrDefault("msg");
@@ -622,11 +651,12 @@ private:
return true;
}
- bool readId(const Common::String &name, int16 &id) const {
+ template<typename T>
+ bool readId(const Common::String &name, T &id) const {
uint32 value;
if (!_project._objectIds.findId(name, value) || value > 0xffff)
return false;
- id = static_cast<int16>(value);
+ id = static_cast<T>(value);
return true;
}
@@ -733,7 +763,10 @@ Common::Error NGIEngine::enterAndroidScene1() {
clearGlobalMessageQueueList1();
clearMessageHandlers();
- stopAllSounds(-1);
+ stopAllSounds(Sound::kSpeech);
+ stopAllSounds(Sound::kEffect);
+ if (room->_behaviorController)
+ room->_behaviorController->onShow();
_currSoundListCount = 0;
if (room->_soundList)
_currSoundList1[_currSoundListCount++] = room->_soundList.get();
@@ -788,6 +821,9 @@ Common::Error NGIEngine::runAndroid() {
Scene *intro2 = intro ? project.findScene(SC_INTRO2) : nullptr;
if (intro && !intro2)
return Common::Error(Common::kNoGameDataFoundError, "Could not load the second Full Pipe Android intro scene");
+ Scene *common = intro ? project.findScene(SC_COMMON) : nullptr;
+ if (intro && !common)
+ return Common::Error(Common::kNoGameDataFoundError, "Could not load the shared Full Pipe Android resources");
_isSaveAllowed = false;
initGraphics(parser.width(), parser.height(), nullptr);
@@ -809,6 +845,8 @@ Common::Error NGIEngine::runAndroid() {
_currSoundList1[_currSoundListCount++] = startScene->_soundList.get();
if (intro2 && intro2->_soundList)
_currSoundList1[_currSoundListCount++] = intro2->_soundList.get();
+ if (common && common->_soundList)
+ _currSoundList1[_currSoundListCount++] = common->_soundList.get();
Graphics::ManagedSurface &frame = _backgroundSurface;
frame.create(parser.width(), parser.height(), format);
@@ -855,6 +893,8 @@ Common::Error NGIEngine::runAndroid() {
deleteModalObject();
redraw = true;
} else {
+ if (scene->_behaviorController)
+ scene->_behaviorController->updateSounds(elapsed);
for (MessageQueue *queue : *_globalMessageQueueList)
redraw |= queue->updatePause(elapsed);
processMessages();
@@ -869,6 +909,8 @@ Common::Error NGIEngine::runAndroid() {
if (scene != _currentScene) {
stopAllSounds(Sound::kSpeech);
stopAllSounds(Sound::kEffect);
+ if (_currentScene->_behaviorController)
+ _currentScene->_behaviorController->onShow();
debugC(2, kDebugDrawing, "Switched Android scene from %d to %d", scene->_sceneId, _currentScene->_sceneId);
redraw = true;
}
diff --git a/engines/ngi/behavior.cpp b/engines/ngi/behavior.cpp
index 7511c1ef338..0dedf138525 100644
--- a/engines/ngi/behavior.cpp
+++ b/engines/ngi/behavior.cpp
@@ -39,6 +39,68 @@ BehaviorController::~BehaviorController() {
void BehaviorController::clear() {
_behaviors.clear();
+ _sounds.clear();
+ _music.clear();
+}
+
+void BehaviorController::addSound(const BehaviorSound &sound, bool music) {
+ (music ? _music : _sounds).push_back(sound);
+}
+
+void BehaviorController::enableAllMusic() {
+ for (BehaviorSound &track : _music)
+ track._enabled = true;
+}
+
+void BehaviorController::onShow() {
+ for (int i = 0; i < g_nmi->_currSoundListCount; ++i) {
+ SoundList &list = *g_nmi->_currSoundList1[i];
+ for (int j = 0; j < list.getCount(); ++j) {
+ Sound &sound = list.getSoundByIndex(j);
+ if (sound.getFlags() != Sound::kMusic || !sound.isPlaying())
+ continue;
+ for (const BehaviorSound &track : _music)
+ if (track._soundId == sound.getId() && track._enabled)
+ return;
+ sound.stop();
+ return;
+ }
+ }
+}
+
+bool BehaviorSound::update(uint32 elapsed) {
+ Sound *sound = g_nmi->findSound(_soundId);
+ if (!sound)
+ return false;
+ if (sound->isPlaying())
+ return true;
+ _elapsed += elapsed;
+ // The original roll is inclusive, so zero still matches one roll out of 100.
+ if (!_enabled || _elapsed < _delay || g_nmi->_rnd.getRandomNumber(99) > _percent)
+ return false;
+ _elapsed = 0;
+ sound->play(_loop);
+ return sound->isPlaying();
+}
+
+void BehaviorController::updateSounds(uint32 elapsed) {
+ for (BehaviorSound &sound : _sounds)
+ sound.update(elapsed);
+
+ bool musicPlaying = false;
+ for (const BehaviorSound &track : _music) {
+ Sound *sound = g_nmi->findSound(track._soundId);
+ if (sound && sound->isPlaying()) {
+ musicPlaying = true;
+ break;
+ }
+ }
+ for (BehaviorSound &track : _music) {
+ if (musicPlaying)
+ track._elapsed = 0;
+ else
+ musicPlaying = track.update(elapsed);
+ }
}
void BehaviorController::initBehavior(Scene *sc, GameVar *var) {
diff --git a/engines/ngi/behavior.h b/engines/ngi/behavior.h
index f2dd9d977a1..45451ec9c3f 100644
--- a/engines/ngi/behavior.h
+++ b/engines/ngi/behavior.h
@@ -22,8 +22,15 @@
#ifndef NGI_BEHAVIOR_H
#define NGI_BEHAVIOR_H
+#include "ngi/utils.h"
+
namespace NGI {
+class AniObject;
+class GameVar;
+class MessageQueue;
+class Scene;
+
struct BehaviorMove {
MessageQueue *_messageQueue;
int _delay;
@@ -59,8 +66,22 @@ struct BehaviorAni {
void initObjectBehavior(GameVar *var, Scene *sc, AniObject *ani);
};
+// A scene can schedule the same shared sound with different delays and chances.
+struct BehaviorSound {
+ uint16 _soundId;
+ uint32 _delay;
+ uint32 _percent;
+ uint32 _elapsed;
+ bool _loop;
+ bool _enabled;
+
+ bool update(uint32 elapsed);
+};
+
class BehaviorController : public CObject {
Common::Array<BehaviorAni> _behaviors;
+ Common::Array<BehaviorSound> _sounds;
+ Common::Array<BehaviorSound> _music;
Scene *_scene;
bool _isActive;
@@ -73,6 +94,10 @@ class BehaviorController : public CObject {
void initBehavior(Scene *scene, GameVar *var);
void update();
+ void addSound(const BehaviorSound &sound, bool music);
+ void enableAllMusic();
+ void onShow();
+ void updateSounds(uint32 elapsed);
void updateBehavior(BehaviorAni &behaviorInfo, BehaviorAnim &entry);
void updateStaticAniBehavior(AniObject &ani, int delay, const BehaviorAnim &beh);
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index f6e02c96d9a..908829b9305 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -73,6 +73,11 @@ int sceneHandler01(Command *cmd) {
return 0;
if (!cmd->_messageNum && !cmd->_messageName.empty()) {
+ if (cmd->_messageName == "MSG_ENABLE_BHV_SOUND") {
+ if (g_nmi->_currentScene->_behaviorController)
+ g_nmi->_currentScene->_behaviorController->enableAllMusic();
+ return 0;
+ }
warning("Android scene 1 message %s not implemented", cmd->_messageName.c_str());
return 0;
}
diff --git a/engines/ngi/fullpipe/sceneChapter.cpp b/engines/ngi/fullpipe/sceneChapter.cpp
index abf151d0f81..222532cd1b1 100644
--- a/engines/ngi/fullpipe/sceneChapter.cpp
+++ b/engines/ngi/fullpipe/sceneChapter.cpp
@@ -255,10 +255,10 @@ private:
Common::Keymapper *mapper = g_system->getEventManager()->getKeymapper();
mapper->setGameKeymapState("ngi-default", !active);
mapper->setGameKeymapState("dialog", active);
- SoundList *sounds = g_nmi->_currentScene->_soundList.get();
- if (sounds) {
- for (int i = 0; i < sounds->getCount(); ++i)
- sounds->getSoundByIndex(i).pause(active);
+ for (int i = 0; i < g_nmi->_currSoundListCount; ++i) {
+ SoundList &sounds = *g_nmi->_currSoundList1[i];
+ for (int j = 0; j < sounds.getCount(); ++j)
+ sounds.getSoundByIndex(j).pause(active);
}
}
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index 3f868d97dfa..8b32673b9d4 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -22,6 +22,7 @@
#include "ngi/ngi.h"
#include "ngi/constants.h"
+#include "ngi/behavior.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
#include "ngi/scenes.h"
@@ -104,7 +105,8 @@ int sceneHandlerIntro(Command *ex) {
if (g_nmi->getPlatform() == Common::kPlatformAndroid && !ex->_messageName.empty()) {
debugC(3, kDebugEvents, "Android intro message %s", ex->_messageName.c_str());
if (ex->_messageName == "MSG_ENABLE_BHV_SOUND") {
- warning("Android intro message %s not implemented", ex->_messageName.c_str());
+ if (g_nmi->_currentScene->_behaviorController)
+ g_nmi->_currentScene->_behaviorController->enableAllMusic();
return 0;
}
}
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index cb3d2e5d0fd..303ec532599 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -94,6 +94,7 @@ class NGIArchive;
class PictureObject;
struct PreloadItem;
class Scene;
+class Sound;
class SoundList;
class AniObject;
class Vars;
@@ -218,6 +219,7 @@ public:
void stopAllSounds(int flags = -1);
void toggleMute();
+ Sound *findSound(int id) const;
void playSound(int id, int flag, int creator = 0);
void playTrack(GameVar *sceneVar, const char *name, bool delayed);
int getSceneTrack();
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index bbf579ed6c2..84ad388c460 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -22,6 +22,7 @@
#include "ngi/ngi.h"
#include "ngi/objects.h"
+#include "ngi/behavior.h"
#include "ngi/ngiarchive.h"
#include "ngi/statics.h"
#include "ngi/messages.h"
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index b281a112edb..b9cf2fb4f30 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -31,6 +31,7 @@ namespace NGI {
class MessageQueue;
class GameProject;
+class BehaviorController;
class Scene : public Background {
public:
@@ -46,6 +47,7 @@ class Scene : public Background {
// PtrList _faObjectList; // not used
Common::ScopedPtr<Shadows> _shadows;
Common::ScopedPtr<SoundList> _soundList;
+ Common::ScopedPtr<BehaviorController> _behaviorController;
int16 _sceneId;
Common::String _sceneName;
int _field_BC;
diff --git a/engines/ngi/sound.cpp b/engines/ngi/sound.cpp
index dce26fc21cc..fe08e564ab5 100644
--- a/engines/ngi/sound.cpp
+++ b/engines/ngi/sound.cpp
@@ -244,10 +244,15 @@ void Sound::play(int loop, int creator) {
} else {
g_nmi->_mixer->stopHandle(*handle);
}
- g_nmi->_mixer->playStream(Audio::Mixer::kSFXSoundType, handle, audioStream);
+ const Audio::Mixer::SoundType type = android && _flags == kMusic ? Audio::Mixer::kMusicSoundType : Audio::Mixer::kSFXSoundType;
+ g_nmi->_mixer->playStream(type, handle, audioStream);
debugC(3, kDebugEvents, "Playing sound %d (%s), loop %d", _id, _memfilename.toString().c_str(), loop);
}
+bool Sound::isPlaying() const {
+ return g_nmi->_mixer->isSoundHandleActive(*_handle);
+}
+
void Sound::unload() {
stop();
@@ -428,16 +433,17 @@ void NGIEngine::toggleMute() {
}
}
-void NGIEngine::playSound(int id, int flag, int creator) {
- Sound *sound = nullptr;
-
+Sound *NGIEngine::findSound(int id) const {
for (int i = 0; i < _currSoundListCount; i++) {
- sound = _currSoundList1[i]->getSound(id);
-
+ Sound *sound = _currSoundList1[i]->getSound(id);
if (sound)
- break;
+ return sound;
}
+ return nullptr;
+}
+void NGIEngine::playSound(int id, int flag, int creator) {
+ Sound *sound = findSound(id);
if (!sound) {
warning("playSound: Can't find sound with ID %d", id);
return;
@@ -509,12 +515,7 @@ void global_messageHandler_handleSound(Command *cmd) {
if (!g_nmi->_soundEnabled)
return;
- Sound *snd = nullptr;
-
- for (int i = 0; i < g_nmi->_currSoundListCount; i++)
- if ((snd = g_nmi->_currSoundList1[i]->getSound(cmd->_messageNum)) != nullptr)
- break;
-
+ Sound *snd = g_nmi->findSound(cmd->_messageNum);
if (!snd)
return;
diff --git a/engines/ngi/sound.h b/engines/ngi/sound.h
index 1ecd0257bd5..78a6ad75c99 100644
--- a/engines/ngi/sound.h
+++ b/engines/ngi/sound.h
@@ -36,7 +36,7 @@ class Sound : public MemoryObject {
Common::Array<Audio::SoundHandle> _overlappingHandles;
public:
- enum { kEffect = 0, kSpeech = 1 };
+ enum { kEffect = 0, kSpeech = 1, kMusic = 2 };
int16 _objectId;
Sound();
@@ -49,6 +49,7 @@ public:
int getId() const { return _id; }
int getFlags() const { return _flags; }
Audio::SoundHandle *getHandle() const { return _handle; }
+ bool isPlaying() const;
void play(int loop, int creator = 0);
void unload();
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index ff130f27e34..a63021333bd 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -71,7 +71,7 @@ class Phase : public StaticPhase {
// XML phases can add both milliseconds and multiples of the movement's loop delay.
int _delayMs = 0;
int _delayRelative = 0;
- int16 _soundId = 0;
+ uint16 _soundId = 0;
bool _loopSound = false;
Common::Rect _rect;
int16 _field_7C;
Commit: 85d7675b67726a70b10d25803e55c2ba9e85e4b5
https://github.com/scummvm/scummvm/commit/85d7675b67726a70b10d25803e55c2ba9e85e4b5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:42+01:00
Commit Message:
NGI: Run Android idle movements and queues from scene XML
Changed paths:
engines/ngi/android.cpp
engines/ngi/behavior.cpp
engines/ngi/behavior.h
engines/ngi/messagehandlers.cpp
engines/ngi/messages.cpp
engines/ngi/messages.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index 549b4d1521d..6d9c83fe1df 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -224,6 +224,7 @@ private:
uint _objectOrder = 0;
bool _hasInitialStatics = false;
int16 _initialStaticsId = 0;
+ BehaviorAni *_behaviorAni = nullptr;
Common::Path texturePath(const Common::String &resource, bool localized) const {
const Common::String directory = localized ? Common::String::format("data/res_%s", _locale) : "data/res";
@@ -266,6 +267,21 @@ private:
XML_PROP(flags, false)
KEY_END()
XML_KEY(BEHAVIORCONTROLLER)
+ XML_KEY(BHVR_ANI)
+ XML_PROP(id, true)
+ XML_PROP(scene, false)
+ XML_PROP(flags, false)
+ XML_KEY(BHVR_MOVE)
+ XML_PROP(static, true)
+ XML_PROP(id, false)
+ XML_PROP(queue, false)
+ XML_PROP(delay, false)
+ XML_PROP(percent, false)
+ XML_PROP(mirror, false)
+ XML_PROP(enable, false)
+ XML_PROP(reverse, false)
+ KEY_END()
+ KEY_END()
XML_KEY(BHVR_SOUND)
XML_PROP(id, true)
XML_PROP(delay, false)
@@ -455,6 +471,32 @@ private:
return true;
}
+ bool parserCallback_BHVR_ANI(ParserNode *node) {
+ int16 actorId;
+ int16 sceneId = _scene._sceneId;
+ if (!readId(node->values["id"], actorId) ||
+ (node->values.contains("scene") && !readId(node->values["scene"], sceneId)))
+ return parserError("Unknown actor or scene in BHVR_ANI");
+ _behaviorAni = &_scene._behaviorController->addAni(actorId, sceneId, atoi(node->values.getValOrDefault("flags").c_str()));
+ return true;
+ }
+
+ bool parserCallback_BHVR_MOVE(ParserNode *node) {
+ int16 staticsId;
+ if (!readId(node->values["static"], staticsId))
+ return parserError("Unknown statics in BHVR_MOVE");
+ BehaviorMove &move = _behaviorAni->addMove(staticsId);
+ if ((node->values.contains("id") && !readId(node->values["id"], move._movementId)) ||
+ (node->values.contains("queue") && !readId(node->values["queue"], move._queueId)))
+ return parserError("Unknown movement or queue in BHVR_MOVE");
+ move._delay = atoi(node->values.getValOrDefault("delay").c_str());
+ move._percent = atoi(node->values.getValOrDefault("percent").c_str());
+ move._mirror = boolProperty(*node, "mirror");
+ if (node->values.contains("enable") && !boolProperty(*node, "enable"))
+ move._flags |= 1;
+ return true;
+ }
+
static bool boolProperty(const ParserNode &node, const char *name) {
const Common::String &value = node.values.getValOrDefault(name);
return value == "1" || value == "true" || value == "yes";
@@ -487,6 +529,7 @@ private:
cmd->_wait = 0;
} else if (kind == "START_MOVEMENT" || kind == "3") {
cmd->_cmd = 1;
+ cmd->_mirror = boolProperty(*node, "mirror");
if (!readId(node->values.getValOrDefault("ani"), cmd->_parentId))
return parserError("Unknown animation in START_MOVEMENT");
idProperty = "mov";
@@ -605,6 +648,8 @@ private:
movement->_prevStatic = previous;
movement->_nextStatic = next;
+ movement->_mirrorPrev = boolProperty(*node, "mirrorPrev");
+ movement->_mirrorNext = boolProperty(*node, "mirrorNext");
movement->_prevStepX = atoi(node->values.getValOrDefault("nPrevStepX").c_str());
movement->_prevStepY = atoi(node->values.getValOrDefault("nPrevStepY").c_str());
movement->_nextStepX = atoi(node->values.getValOrDefault("nNextStepX").c_str());
@@ -748,6 +793,7 @@ Common::Error NGIEngine::enterAndroidScene1() {
Scene *common = findScene(SC_COMMON);
if (!room || !common)
return Common::Error(Common::kNoGameDataFoundError, "Could not load the first Full Pipe Android room");
+ room->_commonQueueScene = common;
for (const PicAniInfo &ref : room->_roamingObjects) {
Scene *source = findScene(ref.sceneId);
AniObject *actor = source ? source->findAniObjectById(ref.objectId, ref.copyId) : nullptr;
@@ -766,7 +812,7 @@ Common::Error NGIEngine::enterAndroidScene1() {
stopAllSounds(Sound::kSpeech);
stopAllSounds(Sound::kEffect);
if (room->_behaviorController)
- room->_behaviorController->onShow();
+ room->_behaviorController->onShow(*room);
_currSoundListCount = 0;
if (room->_soundList)
_currSoundList1[_currSoundListCount++] = room->_soundList.get();
@@ -836,6 +882,8 @@ Common::Error NGIEngine::runAndroid() {
mapper->setGameKeymapState("ngi-default", true);
_gameProject = &project;
_currentScene = startScene;
+ if (startScene->_behaviorController)
+ startScene->_behaviorController->onShow(*startScene);
addMessageHandlerByIndex(global_messageHandler4, 0, 4);
if (intro) {
sceneIntro_initMan(*startScene);
@@ -894,7 +942,7 @@ Common::Error NGIEngine::runAndroid() {
redraw = true;
} else {
if (scene->_behaviorController)
- scene->_behaviorController->updateSounds(elapsed);
+ redraw |= scene->_behaviorController->update(elapsed);
for (MessageQueue *queue : *_globalMessageQueueList)
redraw |= queue->updatePause(elapsed);
processMessages();
@@ -910,7 +958,7 @@ Common::Error NGIEngine::runAndroid() {
stopAllSounds(Sound::kSpeech);
stopAllSounds(Sound::kEffect);
if (_currentScene->_behaviorController)
- _currentScene->_behaviorController->onShow();
+ _currentScene->_behaviorController->onShow(*_currentScene);
debugC(2, kDebugDrawing, "Switched Android scene from %d to %d", scene->_sceneId, _currentScene->_sceneId);
redraw = true;
}
diff --git a/engines/ngi/behavior.cpp b/engines/ngi/behavior.cpp
index 0dedf138525..48e11472f01 100644
--- a/engines/ngi/behavior.cpp
+++ b/engines/ngi/behavior.cpp
@@ -52,7 +52,37 @@ void BehaviorController::enableAllMusic() {
track._enabled = true;
}
-void BehaviorController::onShow() {
+BehaviorAni &BehaviorController::addAni(int16 objectId, int16 sceneId, int flags) {
+ _behaviors.push_back(BehaviorAni());
+ BehaviorAni &behavior = _behaviors.back();
+ behavior._objectId = objectId;
+ behavior._sourceSceneId = sceneId;
+ behavior._flags = flags;
+ return behavior;
+}
+
+BehaviorMove &BehaviorAni::addMove(int16 staticsId) {
+ // Keep XML order, including repeated groups for the same pose.
+ if (_behaviorAnims.empty() || _behaviorAnims.back()._staticsId != staticsId) {
+ _behaviorAnims.push_back(BehaviorAnim());
+ _behaviorAnims.back()._staticsId = staticsId;
+ }
+ Common::Array<BehaviorMove> &moves = _behaviorAnims.back()._behaviorMoves;
+ moves.push_back(BehaviorMove());
+ return moves.back();
+}
+
+void BehaviorController::onShow(Scene &scene) {
+ for (BehaviorAni &behavior : _behaviors) {
+ AniObject *ani = scene.findAniObjectById(behavior._objectId, 0);
+ if (ani && ani->_sceneId != behavior._sourceSceneId)
+ ani = nullptr;
+ if (behavior._ani != ani) {
+ behavior._ani = ani;
+ behavior._activeMove = nullptr;
+ behavior._elapsed = 0;
+ }
+ }
for (int i = 0; i < g_nmi->_currSoundListCount; ++i) {
SoundList &list = *g_nmi->_currSoundList1[i];
for (int j = 0; j < list.getCount(); ++j) {
@@ -68,6 +98,57 @@ void BehaviorController::onShow() {
}
}
+bool BehaviorAni::updateIdle(uint32 elapsed) {
+ if (!_ani)
+ return false;
+ if (_activeMove) {
+ if (_activeMove->_movementId) {
+ if (_ani->_movement && _ani->_movement->_id == _activeMove->_movementId)
+ return false;
+ } else {
+ for (const MessageQueue *queue : *g_nmi->_globalMessageQueueList)
+ if (queue->_queueId == _activeMove->_queueId && !queue->_isFinished)
+ return false;
+ }
+ _activeMove = nullptr;
+ return false;
+ }
+ if (_ani->_movement || !_ani->_statics || !(_ani->_flags & 4) || _ani->_messageQueueId)
+ return false;
+ if (_flags & 1) {
+ for (const MessageQueue *queue : *g_nmi->_globalMessageQueueList)
+ if (!queue->_isFinished && !(queue->_flags & kBehaviorQueue))
+ return false;
+ }
+
+ _elapsed += elapsed;
+ for (const BehaviorAnim &anim : _behaviorAnims) {
+ if (anim._staticsId != _ani->_statics->_staticsId)
+ continue;
+ for (const BehaviorMove &move : anim._behaviorMoves) {
+ if ((move._flags & 1) || move._mirror != ((_ani->_flags & 8) != 0) ||
+ _elapsed < (uint32)move._delay || !move._percent || g_nmi->_rnd.getRandomNumber(99) > move._percent)
+ continue;
+ const bool started = move._movementId ? _ani->startMovement(move._movementId, 0, -1) :
+ runQueueByIdWithAni(_ani, move._queueId, kBehaviorQueue);
+ if (started) {
+ _elapsed = 0;
+ _activeMove = &move;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool BehaviorController::update(uint32 elapsed) {
+ bool changed = false;
+ for (BehaviorAni &behavior : _behaviors)
+ changed |= behavior.updateIdle(elapsed);
+ updateSounds(elapsed);
+ return changed;
+}
+
bool BehaviorSound::update(uint32 elapsed) {
Sound *sound = g_nmi->findSound(_soundId);
if (!sound)
@@ -273,8 +354,9 @@ BehaviorMove *BehaviorController::getAniQueue(AniObject *ani, int id1, int id2)
for (uint j = 0; j < _behaviors[i]._behaviorAnims.size(); j++) {
if (_behaviors[i]._behaviorAnims[j]._staticsId == id1) {
for (uint k = 0; k < _behaviors[i]._behaviorAnims[j]._behaviorMoves.size(); k++) {
- if (_behaviors[i]._behaviorAnims[j]._behaviorMoves[k]._messageQueue->_queueId == id2)
- return &_behaviors[i]._behaviorAnims[j]._behaviorMoves[k];
+ BehaviorMove &move = _behaviors[i]._behaviorAnims[j]._behaviorMoves[k];
+ if (move._queueId && move._queueId == id2)
+ return &move;
}
}
}
@@ -292,6 +374,8 @@ void BehaviorAni::clear() {
_flags = 0;
_subIndex = 0;
_animsCount = 0;
+ _elapsed = 0;
+ _activeMove = nullptr;
_behaviorAnims.clear();
}
@@ -389,11 +473,9 @@ BehaviorAnim::BehaviorAnim(GameVar *var, Scene *sc, AniObject *ani, int *minDela
}
BehaviorMove::BehaviorMove(GameVar *subvar, Scene *sc, int *delay) {
- _messageQueue = nullptr;
- _delay = 0;
- _percent = 0;
- _flags = 0;
_messageQueue = sc->getMessageQueueByName(subvar->_varName);
+ if (_messageQueue)
+ _queueId = _messageQueue->_queueId;
GameVar *vart = subvar->getSubVarByName("dwDelay");
if (vart)
diff --git a/engines/ngi/behavior.h b/engines/ngi/behavior.h
index 45451ec9c3f..44fdd32af21 100644
--- a/engines/ngi/behavior.h
+++ b/engines/ngi/behavior.h
@@ -32,11 +32,15 @@ class MessageQueue;
class Scene;
struct BehaviorMove {
- MessageQueue *_messageQueue;
- int _delay;
- uint32 _percent;
- int _flags;
-
+ MessageQueue *_messageQueue = nullptr;
+ int _delay = 0;
+ uint32 _percent = 0;
+ int _flags = 0;
+ int16 _movementId = 0;
+ int16 _queueId = 0;
+ bool _mirror = false;
+
+ BehaviorMove() = default;
BehaviorMove(GameVar *subvar, Scene *sc, int *delay);
};
@@ -58,10 +62,16 @@ struct BehaviorAni {
int _subIndex;
int _animsCount;
Common::Array<BehaviorAnim> _behaviorAnims;
+ int16 _objectId = 0;
+ int16 _sourceSceneId = 0;
+ uint32 _elapsed = 0;
+ const BehaviorMove *_activeMove = nullptr;
BehaviorAni() { clear(); }
void clear();
+ BehaviorMove &addMove(int16 staticsId);
+ bool updateIdle(uint32 elapsed);
void initAmbientBehavior(GameVar *var, Scene *sc);
void initObjectBehavior(GameVar *var, Scene *sc, AniObject *ani);
};
@@ -84,6 +94,7 @@ class BehaviorController : public CObject {
Common::Array<BehaviorSound> _music;
Scene *_scene;
bool _isActive;
+ void updateSounds(uint32 elapsed);
public:
BehaviorController();
@@ -96,8 +107,9 @@ class BehaviorController : public CObject {
void update();
void addSound(const BehaviorSound &sound, bool music);
void enableAllMusic();
- void onShow();
- void updateSounds(uint32 elapsed);
+ BehaviorAni &addAni(int16 objectId, int16 sceneId, int flags);
+ void onShow(Scene &scene);
+ bool update(uint32 elapsed);
void updateBehavior(BehaviorAni &behaviorInfo, BehaviorAnim &entry);
void updateStaticAniBehavior(AniObject &ani, int delay, const BehaviorAnim &beh);
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 9dbdd58cb9f..6433cbb66d2 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -566,10 +566,7 @@ int global_messageHandler4(Command *cmd) {
if (flags <= 0)
flags = -1;
- if (cmd->_excFlags & 1)
- ani->startMovement(cmd->_messageNum, 0, flags);
- else
- ani->startMovement(cmd->_messageNum, cmd->_parId, flags);
+ ani->startMovement(cmd->_messageNum, (cmd->_excFlags & 1) ? 0 : cmd->_parId, flags, cmd->_mirror);
break;
}
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index f8c783c671e..e6dd95a7539 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -38,6 +38,7 @@ Command::Command() {
Command::Command(Command *src) : Message(*src) {
_messageName = src->_messageName;
+ _mirror = src->_mirror;
_field_3C = 1;
_messageNum = src->_messageNum;
_excFlags = src->_excFlags;
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index a05bc73a12c..d01fa6e197d 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -31,7 +31,8 @@
namespace NGI {
enum QueueFlags {
- kInGlobalQueue = 2
+ kInGlobalQueue = 2,
+ kBehaviorQueue = 8
};
class Message : public CObject {
@@ -60,6 +61,7 @@ class Command : public Message {
public:
enum { kCmdPause = 64 }; // Timed pause in XML queues.
Common::String _messageName;
+ bool _mirror = false;
int _messageNum;
int _field_3C;
int _excFlags;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 84ad388c460..b06fd993883 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -369,7 +369,7 @@ MessageQueue *Scene::findMessageQueue(int messageId) {
if (_messageQueues[i]->_queueId == messageId)
return _messageQueues[i];
- return nullptr;
+ return _commonQueueScene ? _commonQueueScene->findMessageQueue(messageId) : nullptr;
}
MessageQueue *Scene::getMessageQueueByName(const Common::String &name) {
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index b9cf2fb4f30..d84c96f236b 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -44,6 +44,8 @@ class Scene : public Background {
Common::Array<Entrance> _entrances;
int16 _heroId = 0;
Common::Array<MessageQueue *> _messageQueues;
+ // XML queue templates are cloned when run and can be shared between scenes.
+ Scene *_commonQueueScene = nullptr;
// PtrList _faObjectList; // not used
Common::ScopedPtr<Shadows> _shadows;
Common::ScopedPtr<SoundList> _soundList;
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 69d4426873c..c433807e60c 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -792,7 +792,7 @@ bool AniObject::update(int counterdiff) {
}
// Android ends the movement as soon as the next statics takes over.
- if (!_movement->setNext(_callback1, _callback2) || (android && _movement->_curPhase == _movement->_nextStatic)) {
+ if (!_movement->setNext(_callback1, _callback2, android && (_flags & 8)) || (android && _movement->_curPhase == _movement->_nextStatic)) {
stopMovement();
} else {
setPos(_movement->_x, _movement->_y);
@@ -946,6 +946,8 @@ L8:
}
L11:
_statics = _movement->_nextStatic;
+ if (_movement->_mirrorNext)
+ _flags ^= 8;
L12:
point = _statics->getSomeXY();
@@ -1236,7 +1238,7 @@ bool AniObject::startAnimEx(int movid, int parId, int flag1, int flag2) {
return res;
}
-bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseIdx) {
+bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror) {
if (_flags & 0x80)
return false;
@@ -1266,8 +1268,17 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
int newy = _y;
Common::Point point;
- if (android && !_movement)
+ if (android && !_movement) {
+ // SetStatic reflects a change of facing about the old texture's center.
+ const bool prevMirror = mirror != mov->_mirrorPrev;
+ if (_statics && prevMirror != ((_flags & 8) != 0)) {
+ const int shift = _statics->getDimensions().x - 2 * _statics->_someX;
+ newx += prevMirror ? shift : -shift;
+ }
_statics = mov->_prevStatic;
+ }
+ if (mirror)
+ newx = -newx;
if (_movement) {
point = _movement->getCurrDynamicPhaseXY();
@@ -1277,6 +1288,8 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
} else if (_statics) {
point = _statics->getSomeXY();
+ if (mov->_mirrorPrev)
+ point.x = _statics->getDimensions().x - point.x;
newx -= point.x;
newy -= point.y;
@@ -1311,9 +1324,10 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
}
point = _movement->getCurrDynamicPhaseXY();
- setPos(point.x + newx, point.y + newy);
+ newx += point.x;
+ setPos(mirror ? -newx : newx, point.y + newy);
- if (!android && (_movement->_nextStatic->_staticsId & 0x4000))
+ if (mirror || (!android && (_movement->_nextStatic->_staticsId & 0x4000)))
_flags |= 8;
else
_flags &= 0xFFF7;
@@ -1465,6 +1479,8 @@ Movement::~Movement() {
}
Movement::Movement(Movement *src, AniObject *ani) {
+ _mirrorPrev = src->_mirrorPrev;
+ _mirrorNext = src->_mirrorNext;
_lastFrameSpecialFlag = 0;
_flipFlag = src->_flipFlag;
_updateFlag1 = src->_updateFlag1;
@@ -1499,6 +1515,8 @@ Movement::Movement(Movement *src, AniObject *ani) {
}
Movement::Movement(Movement *src, int *oldIdxs, int newSize, AniObject *ani) : GameObject(src) {
+ _mirrorPrev = src->_mirrorPrev;
+ _mirrorNext = src->_mirrorNext;
_lastFrameSpecialFlag = 0;
_updateFlag1 = 1;
_prevStatic = nullptr;
@@ -1677,6 +1695,8 @@ bool Movement::load(MfcArchive &file, AniObject *ani) {
}
Common::Point Movement::getCurrDynamicPhaseXY() const {
+ if (_mirrorNext && _curPhase == _nextStatic)
+ return Common::Point(_curPhase->getDimensions().x - _curPhase->_someX, _curPhase->_someY);
return Common::Point(_curPhase->_someX, _curPhase->_someY);
}
@@ -1893,7 +1913,7 @@ void Movement::removeFirstPhase() {
_updateFlag1 = 0;
}
-bool Movement::setNext(void (*callback1)(int, Common::Point *point, int, int), void (*callback2)(int *)) {
+bool Movement::setNext(void (*callback1)(int, Common::Point *point, int, int), void (*callback2)(int *), bool mirror) {
debugC(8, kDebugAnimation, "Movement::setNext()");
if (!callback2) {
@@ -1913,6 +1933,7 @@ bool Movement::setNext(void (*callback1)(int, Common::Point *point, int, int), v
return true;
}
+ const int oldX = _x;
Common::Point point = getCurrDynamicPhaseXY();
_x -= point.x;
_y -= point.y;
@@ -2007,6 +2028,8 @@ bool Movement::setNext(void (*callback1)(int, Common::Point *point, int, int), v
_x += point.x;
_y += point.y;
+ if (mirror)
+ _x = oldX - (_x - oldX);
_curPhase->_countdown = _curPhase->_delay;
return result;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index a63021333bd..46abfe79e15 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -119,6 +119,8 @@ class Movement : public GameObject {
int _updateFlag1;
Statics *_prevStatic;
Statics *_nextStatic;
+ bool _mirrorPrev = false;
+ bool _mirrorNext = false;
int _prevStepX;
int _prevStepY;
int _nextStepX;
@@ -165,7 +167,7 @@ class Movement : public GameObject {
int countPhasesWithFlag(int maxidx, int flag);
void removeFirstPhase();
- bool setNext(void (*_callback1)(int, Common::Point *point, int, int), void (*callback2)(int *));
+ bool setNext(void (*_callback1)(int, Common::Point *point, int, int), void (*callback2)(int *), bool mirror = false);
bool gotoPrevFrame();
void gotoFirstFrame();
void setLast();
@@ -239,7 +241,7 @@ public:
void setTargetFrame(int val) { _targetFrame = val; }
void adjustSomeXY();
- bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx);
+ bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror = false);
bool startAnimEx(int movid, int parId, int flag1, int flag2);
void startSliding(int movementId, int messageQueueId, int x, int y, const PointList &points, int someDynamicPhaseIndex);
Commit: 5366932e9232366f6bf320bc333475e745eea1d8
https://github.com/scummvm/scummvm/commit/5366932e9232366f6bf320bc333475e745eea1d8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:42+01:00
Commit Message:
NGI: Load Android scene motion graphs
Changed paths:
engines/ngi/android.cpp
engines/ngi/gameloader.cpp
engines/ngi/motion.cpp
engines/ngi/motion.h
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/android.cpp b/engines/ngi/android.cpp
index 6d9c83fe1df..091bb68be0d 100644
--- a/engines/ngi/android.cpp
+++ b/engines/ngi/android.cpp
@@ -36,6 +36,7 @@
#include "ngi/detection.h"
#include "ngi/messages.h"
#include "ngi/modal.h"
+#include "ngi/motion.h"
#include "ngi/ngiarchive.h"
#include "ngi/objects.h"
#include "ngi/utils.h"
@@ -225,6 +226,9 @@ private:
bool _hasInitialStatics = false;
int16 _initialStaticsId = 0;
BehaviorAni *_behaviorAni = nullptr;
+ MctlItem *_motionItem = nullptr;
+ MctlGraph *_graph = nullptr;
+ Common::Array<Common::Pair<int, int> > _linkEndpoints;
Common::Path texturePath(const Common::String &resource, bool localized) const {
const Common::String directory = localized ? Common::String::format("data/res_%s", _locale) : "data/res";
@@ -238,6 +242,7 @@ private:
CUSTOM_XML_PARSER(XMLSceneParser) {
XMLKeyLayout *commandLayout;
+ XMLKeyLayout *polygonLayout, *parallelLayout;
XML_KEY(SCENE)
XML_PROP(id, true)
XML_PROP(title, false)
@@ -250,6 +255,56 @@ private:
XML_PROP(putPrev, false)
XML_PROP(scrollX, false)
XML_PROP(scrollY, false)
+ XML_KEY(MCTL_COMPOUND)
+ XML_KEY(MCTL_ITEM)
+ XML_PROP(ofsX, false)
+ XML_PROP(ofsY, false)
+ XML_PROP(ofsZ, false)
+ XML_KEY(REACT_POLYGONAL)
+ polygonLayout = layout.top();
+ XML_PROP(centerX, false)
+ XML_PROP(centerY, false)
+ XML_KEY(REACT_POINT)
+ XML_PROP(x, false)
+ XML_PROP(y, false)
+ KEY_END()
+ KEY_END()
+ XML_KEY(REACT_PARALLEL)
+ parallelLayout = layout.top();
+ XML_PROP(x1, false)
+ XML_PROP(y1, false)
+ XML_PROP(x2, false)
+ XML_PROP(y2, false)
+ XML_PROP(left, false)
+ XML_PROP(right, false)
+ KEY_END()
+ XML_KEY(MCTL_GRAPH)
+ XML_KEY(GRAPH_NODE)
+ XML_PROP(id, true)
+ XML_PROP(x, false)
+ XML_PROP(y, false)
+ XML_PROP(z, false)
+ XML_PROP(flags, false)
+ KEY_END()
+ XMLKeyLayout *nodeLayout = layout.top()->children["GRAPH_NODE"];
+ XML_KEY(GRAPH_LINK)
+ XML_PROP(flags, false)
+ XML_PROP(length, false)
+ XML_PROP(angle, false)
+ XML_PROP(title, false)
+ XML_KEY(MOVE)
+ XML_PROP(id, true)
+ XML_PROP(mirror, false)
+ KEY_END()
+ layout.top()->children["STAT"] = layout.top()->children["MOVE"];
+ layout.top()->children["GRAPH_SRC"] = nodeLayout;
+ layout.top()->children["GRAPH_DST"] = nodeLayout;
+ layout.top()->children["REACT_PARALLEL"] = parallelLayout;
+ layout.top()->children["REACT_POLYGONAL"] = polygonLayout;
+ KEY_END()
+ KEY_END()
+ KEY_END()
+ KEY_END()
XML_KEY(ADDANI)
XML_PROP(id, true)
XML_PROP(scene, true)
@@ -412,6 +467,101 @@ private:
return true;
}
+ static int intProperty(const ParserNode &node, const char *key) {
+ return atoi(node.values.getValOrDefault(key).c_str());
+ }
+
+ bool parserCallback_MCTL_COMPOUND(ParserNode *) {
+ _scene._motionController.reset(new MctlCompound());
+ return true;
+ }
+
+ bool parserCallback_MCTL_ITEM(ParserNode *node) {
+ _motionItem = new MctlItem();
+ _scene._motionController->_motionControllers.push_back(_motionItem);
+ _motionItem->_ofsX = intProperty(*node, "ofsX");
+ _motionItem->_ofsY = intProperty(*node, "ofsY");
+ _motionItem->_ofsZ = intProperty(*node, "ofsZ");
+ return true;
+ }
+
+ bool parserCallback_MCTL_GRAPH(ParserNode *) {
+ _graph = new MctlGraph();
+ _motionItem->_motionControllerObj.reset(_graph);
+ _linkEndpoints.clear();
+ return true;
+ }
+
+ bool parserCallback_GRAPH_NODE(ParserNode *node) {
+ const int id = intProperty(*node, "id");
+ if (node->name == "GRAPH_SRC") {
+ _linkEndpoints.back().first = id;
+ } else if (node->name == "GRAPH_DST") {
+ _linkEndpoints.back().second = id;
+ } else {
+ MovGraphNode *point = new MovGraphNode();
+ _graph->_nodes.push_back(point);
+ point->_id = id;
+ point->_x = intProperty(*node, "x");
+ point->_y = intProperty(*node, "y");
+ point->_z = intProperty(*node, "z");
+ point->_flags = intProperty(*node, "flags");
+ }
+ return true;
+ }
+
+ bool parserCallback_GRAPH_LINK(ParserNode *node) {
+ MovGraphLink *link = new MovGraphLink();
+ _graph->_links.push_back(link);
+ _linkEndpoints.emplace_back(-1, -1);
+ if (node->values.contains("flags"))
+ link->_flags = intProperty(*node, "flags");
+ link->_length = strtof(node->values.getValOrDefault("length").c_str(), nullptr);
+ link->_angle = strtof(node->values.getValOrDefault("angle").c_str(), nullptr);
+ link->_title = node->values.getValOrDefault("title");
+ return true;
+ }
+
+ bool parserCallback_MOVE(ParserNode *node) {
+ uint32 id;
+ if (!readId(node->values["id"], id))
+ return parserError("Unknown ID on motion graph link: " + node->values["id"]);
+ MovGraphLink *link = _graph->_links.back();
+ const bool move = node->name == "MOVE";
+ (move ? link->_movementIds : link->_staticsIds).push_back(id);
+ (move ? link->_movementMirrors : link->_staticsMirrors).push_back(boolProperty(*node, "mirror"));
+ return true;
+ }
+
+ bool parserCallback_REACT_PARALLEL(ParserNode *node) {
+ ReactParallel *region = new ReactParallel(intProperty(*node, "left"), intProperty(*node, "right"));
+ region->setAnchorPoints(intProperty(*node, "x1"), intProperty(*node, "y1"), intProperty(*node, "x2"), intProperty(*node, "y2"));
+ region->create();
+ return setGraphRegion(node, region);
+ }
+
+ bool parserCallback_REACT_POLYGONAL(ParserNode *node) {
+ return setGraphRegion(node, new ReactPolygonal(intProperty(*node, "centerX"), intProperty(*node, "centerY")));
+ }
+
+ bool setGraphRegion(ParserNode *node, MovGraphReact *region) {
+ if (getParentNode(node)->name == "GRAPH_LINK") {
+ MovGraphLink *link = _graph->_links.back();
+ delete link->_movGraphReact;
+ link->_movGraphReact = region;
+ } else {
+ _motionItem->_movGraphReactObj.reset(region);
+ }
+ return true;
+ }
+
+ bool parserCallback_REACT_POINT(ParserNode *node) {
+ MovGraphReact *region = getParentNode(getParentNode(node))->name == "GRAPH_LINK" ?
+ _graph->_links.back()->_movGraphReact : _motionItem->_movGraphReactObj.get();
+ region->_points.push_back(Common::Point(intProperty(*node, "x"), intProperty(*node, "y")));
+ return true;
+ }
+
bool parserCallback_PICTURE(ParserNode *node) {
Common::ScopedPtr<PictureObject> picture(new PictureObject());
if (!parseObject(*picture, *node))
@@ -689,6 +839,19 @@ private:
}
bool closedKeyCallback(ParserNode *node) override {
+ if (node->name == "MCTL_GRAPH") {
+ // Links can precede their nodes. Only GRAPH_NODE defines the coordinates.
+ uint i = 0;
+ for (MovGraphLink *link : _graph->_links) {
+ const auto &ids = _linkEndpoints[i++];
+ link->_graphSrc = _graph->getNodeById(ids.first);
+ link->_graphDst = _graph->getNodeById(ids.second);
+ if (!link->_graphSrc || !link->_graphDst || !link->_movGraphReact)
+ return parserError("Incomplete Android motion graph link");
+ }
+ }
+ if (node->name == "MCTL_ITEM" && !_motionItem->_motionControllerObj)
+ return parserError("Missing Android motion graph");
if (node->name == "MOVEMENT")
_scene._aniObjects.back()->_movements.back()->updateCurrDynamicPhase();
if (node->name == "OLDANI" && !_scene._aniObjects.back()->_statics)
diff --git a/engines/ngi/gameloader.cpp b/engines/ngi/gameloader.cpp
index 7d99de08690..711681eee3b 100644
--- a/engines/ngi/gameloader.cpp
+++ b/engines/ngi/gameloader.cpp
@@ -38,6 +38,10 @@ Inventory *getGameLoaderInventory() {
}
static MotionController *getMotionControllerBySceneId(int16 sceneId) {
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid) {
+ Scene *scene = g_nmi->findScene(sceneId);
+ return scene ? scene->_motionController.get() : nullptr;
+ }
for (uint i = 0; i < g_nmi->_gameLoader->_sc2array.size(); i++) {
if (g_nmi->_gameLoader->_sc2array[i]._sceneId == sceneId) {
return g_nmi->_gameLoader->_sc2array[i]._motionController;
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index ef5eec97953..f75074baf3e 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -108,6 +108,14 @@ MctlCompound::~MctlCompound() {
Common::for_each(_motionControllers.begin(), _motionControllers.end(), Common::DefaultDeleter<MctlItem>());
}
+bool MctlCompound::checkPoint(int x, int y) {
+ for (MctlItem *item : _motionControllers) {
+ if (item->_movGraphReactObj && item->_movGraphReactObj->hitTest(x, y))
+ return item->_motionControllerObj->checkPoint(x, y);
+ }
+ return false;
+}
+
bool MctlCompound::load(MfcArchive &file) {
debugC(5, kDebugLoading, "MctlCompound::load()");
@@ -781,7 +789,8 @@ GrPathDesc *getPreferredPath(AniObject *ani, Common::Array<PathDesc *> *items, s
MovGraph::MovGraph() {
_selFunc = getPreferredPath;
_linkItemOffset = 0;
- insertMessageHandler(MovGraph::messageHandler, getMessageHandlersCount() - 1, 129);
+ if (g_nmi->getPlatform() != Common::kPlatformAndroid)
+ insertMessageHandler(MovGraph::messageHandler, getMessageHandlersCount() - 1, 129);
_objtype = kObjTypeMovGraph;
}
@@ -796,6 +805,14 @@ MovGraph::~MovGraph() {
detachAllObjects();
}
+MovGraphNode *MovGraph::getNodeById(int id) const {
+ for (MovGraphNode *node : _nodes) {
+ if (node->_id == id)
+ return node;
+ }
+ return nullptr;
+}
+
bool MovGraph::load(MfcArchive &file) {
debugC(5, kDebugLoading, "MovGraph::load()");
@@ -2390,6 +2407,10 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
return mq;
}
+bool MctlGraph::checkPoint(int x, int y) {
+ return getHitNode(x, y, 0) || getHitLink(x, y, -1, 0);
+}
+
MovGraphNode *MctlGraph::getHitNode(int x, int y, int strictMatch) {
for (NodeList::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
assert((*i)->_objtype == kObjTypeMovGraphNode);
@@ -2906,7 +2927,7 @@ void MovGraphLink::recalcLength() {
bool MovGraphNode::load(MfcArchive &file) {
debugC(5, kDebugLoading, "MovGraphNode::load()");
- _field_14 = file.readUint32LE();
+ _flags = file.readUint32LE();
_x = file.readSint32LE();
_y = file.readSint32LE();
_z = file.readSint32LE();
@@ -2914,11 +2935,11 @@ bool MovGraphNode::load(MfcArchive &file) {
return true;
}
-ReactParallel::ReactParallel() {
+ReactParallel::ReactParallel(int left, int right) {
_x1 = 0;
_x2 = 0;
- _right = 0;
- _left = 0;
+ _right = right;
+ _left = left;
_y1 = 0;
_y2 = 0;
}
@@ -2941,21 +2962,25 @@ bool ReactParallel::load(MfcArchive &file) {
void ReactParallel::create() {
_points.resize(4);
- double at = atan2((double)(_y1 - _y2), (double)(_x1 - _x2)) + 1.570796; // pi/2
+ const bool android = g_nmi->getPlatform() == Common::kPlatformAndroid;
+ double angle = android ? atan2f(_y1 - _y2, _x1 - _x2) : atan2((double)(_y1 - _y2), (double)(_x1 - _x2));
+ double at = angle + 1.570796; // pi/2
double sn = sin(at);
double cs = cos(at);
+ double lx = _left * cs, ly = _left * sn;
+ double rx = _right * cs, ry = _right * sn;
+ if (android) {
+ // The XML engine truncates the offsets before adding them to each endpoint.
+ lx = (int)lx;
+ ly = (int)ly;
+ rx = (int)rx;
+ ry = (int)ry;
+ }
- _points[0].x = _x1 - _left * cs;
- _points[0].y = _y1 - _left * sn;
-
- _points[1].x = _x2 - _left * cs;
- _points[1].y = _y2 - _left * sn;
-
- _points[2].x = _x2 + _right * cs;
- _points[2].y = _y2 + _right * sn;
-
- _points[3].x = _x1 + _right * cs;
- _points[3].y = _y1 + _right * sn;
+ _points[0] = Common::Point(_x1 - lx, _y1 - ly);
+ _points[1] = Common::Point(_x2 - lx, _y2 - ly);
+ _points[2] = Common::Point(_x2 + rx, _y2 + ry);
+ _points[3] = Common::Point(_x1 + rx, _y1 + ry);
// GdiObject::Attach(_rgn, CreatePolygonRgn(_points, 4, 2);
}
@@ -2967,13 +2992,13 @@ void ReactParallel::setAnchorPoints(int x1, int y1, int x2, int y2) {
_y2 = y2;
}
-ReactPolygonal::ReactPolygonal() {
+ReactPolygonal::ReactPolygonal(int centerX, int centerY) {
// hack for using isValid to avoid creating another state variable for
// getBBox
_bbox.right = -1;
- _centerX = 0;
- _centerY = 0;
+ _centerX = centerX;
+ _centerY = centerY;
}
bool ReactPolygonal::load(MfcArchive &file) {
@@ -3043,6 +3068,21 @@ Common::Rect ReactPolygonal::getBBox() {
bool MovGraphReact::hitTest(int x, int y) {
+ if (g_nmi->getPlatform() == Common::kPlatformAndroid) {
+ if (_points.size() <= 1)
+ return !_points.empty() && _points[0] == Common::Point(x, y);
+ bool inside = false;
+ Common::Point prev = _points.back();
+ for (const Common::Point &cur : _points) {
+ if ((cur.y < y) != (prev.y < y)) {
+ const int64 cross = (int64)(prev.x - x) * (cur.y - prev.y) - (int64)(prev.y - y) * (cur.x - prev.x);
+ if (cur.y < y ? cross > 0 : cross < 0)
+ inside = !inside;
+ }
+ prev = cur;
+ }
+ return inside;
+ }
if (_points.size() < 3) {
return false;
}
diff --git a/engines/ngi/motion.h b/engines/ngi/motion.h
index fc7753b3594..923642e23e8 100644
--- a/engines/ngi/motion.h
+++ b/engines/ngi/motion.h
@@ -60,6 +60,7 @@ public:
virtual bool resetPosition(AniObject *ani, int flag) { return 0; }
virtual int checkCurrentPath() { return 0; }
virtual bool canDropInventory(AniObject *ani, int x, int y) { return false; }
+ virtual bool checkPoint(int x, int y) { return false; }
virtual int getStopStatics() { return -1; }
virtual MessageQueue *makeQueue(AniObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { return 0; }
@@ -100,6 +101,7 @@ public:
~MctlCompound() override;
bool load(MfcArchive &file) override;
+ bool checkPoint(int x, int y) override;
void attachObject(AniObject *obj) override;
int detachObject(AniObject *obj) override;
@@ -163,14 +165,15 @@ private:
class MovGraphNode : public CObject {
public:
+ int _id = 0;
int _x;
int _y;
int _z;
int16 _field_10;
- int _field_14;
+ int _flags;
public:
- MovGraphNode() : _x(0), _y(0), _z(0), _field_10(0), _field_14(0) { _objtype = kObjTypeMovGraphNode; }
+ MovGraphNode() : _x(0), _y(0), _z(0), _field_10(0), _flags(0) { _objtype = kObjTypeMovGraphNode; }
bool load(MfcArchive &file) override;
};
@@ -184,7 +187,7 @@ class ReactParallel : public MovGraphReact {
int _right;
public:
- ReactParallel();
+ ReactParallel(int left = 0, int right = 0);
bool load(MfcArchive &file) override;
void setAnchorPoints(int x1, int y1, int x2, int y2) override;
@@ -197,7 +200,7 @@ class ReactPolygonal : public MovGraphReact {
int _centerY;
public:
- ReactPolygonal();
+ ReactPolygonal(int centerX = 0, int centerY = 0);
bool load(MfcArchive &file) override;
@@ -213,6 +216,9 @@ class MovGraphLink : public CObject {
MovGraphNode *_graphDst;
DWordArray _movementIds;
DWordArray _staticsIds;
+ // XML stores the facing separately from the movement or statics ID.
+ Common::Array<bool> _movementMirrors;
+ Common::Array<bool> _staticsMirrors;
uint32 _flags;
int _field_38;
int _field_3C;
@@ -271,11 +277,13 @@ class MovGraph : public MotionController {
friend class MctlCompound;
friend class MctlGraph;
friend class MotionController;
-private:
+public:
typedef ObList<MovGraphNode> NodeList;
typedef ObList<MovGraphLink> LinkList;
NodeList _nodes;
LinkList _links;
+
+private:
int _linkItemOffset;
Common::Array<NavDatum> _items;
GrPathDesc *(*_selFunc)(AniObject *ani, Common::Array<PathDesc *> *items, signed int counter);
@@ -305,6 +313,7 @@ public:
void recalcLinkParams();
bool getNearestPoint(int unusedArg, Common::Point *p, GrPathDesc *movarr);
MovGraphNode *findNearestNode(int ox, int oy);
+ MovGraphNode *getNodeById(int id) const;
int getObjectIndex(AniObject *ani);
Common::Array<GrPathDesc *> *getHitPoints(int x, int y, int *arrSize, int flag1, int flag2);
void findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, MovGraphLinkList &tempObList1, MovGraphLinkList &tempObList2);
@@ -371,6 +380,7 @@ public:
Common::Array<GmctlAni> _aniData;
public:
+ bool checkPoint(int x, int y) override;
void attachObject(AniObject *obj) override;
int detachObject(AniObject *obj) override;
void detachAllObjects() override;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index b06fd993883..068b31a0805 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -26,6 +26,7 @@
#include "ngi/ngiarchive.h"
#include "ngi/statics.h"
#include "ngi/messages.h"
+#include "ngi/motion.h"
#include "ngi/gameloader.h"
#include "ngi/constants.h"
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index d84c96f236b..8b03d82bfaa 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -32,6 +32,7 @@ namespace NGI {
class MessageQueue;
class GameProject;
class BehaviorController;
+class MctlCompound;
class Scene : public Background {
public:
@@ -50,6 +51,7 @@ class Scene : public Background {
Common::ScopedPtr<Shadows> _shadows;
Common::ScopedPtr<SoundList> _soundList;
Common::ScopedPtr<BehaviorController> _behaviorController;
+ Common::ScopedPtr<MctlCompound> _motionController;
int16 _sceneId;
Common::String _sceneName;
int _field_BC;
Commit: cca4010fc91ef9b2885402f6e40ae06e9cab881d
https://github.com/scummvm/scummvm/commit/cca4010fc91ef9b2885402f6e40ae06e9cab881d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-11-24T20:41:52+01:00
Commit Message:
NGI: Catalogued all PIPE Studio games
Changed paths:
engines/ngi/detection.cpp
diff --git a/engines/ngi/detection.cpp b/engines/ngi/detection.cpp
index 0762b956c36..d7fb1e89a8f 100644
--- a/engines/ngi/detection.cpp
+++ b/engines/ngi/detection.cpp
@@ -44,13 +44,72 @@ static const DebugChannelDef debugFlagList[] = {
static const PlainGameDescriptor ngiGames[] = {
{"ngi", "Nikita Game Interface game"},
- {"fullpipe", "Full Pipe"},
{"mdream", "Magic Dream"},
+
+ {"fullpipe", "Full Pipe"}, // ÐÐ¾Ð»Ð½Ð°Ñ ÑÑÑба
+
+ // qdEngine
+ // "Pilot Brothers. The Other Side of the Earth", // ÐÑаÑÑÑ ÐилоÑÑ. ÐбÑаÑÐ½Ð°Ñ ÑÑоÑона Ðемли
+
+ {"pilot7", "Pilot Brothers. The Olympiad"}, // ÐÑаÑÑÑ ÐилоÑÑ. Ðлимпиада
+ {"popovich", "The Three Bogatyrs: Alesha Popovich and Tugarin the Serpent"}, // 3 богаÑÑÑÑ. ÐлеÑа ÐÐ¾Ð¿Ð¾Ð²Ð¸Ñ Ð¸ ТÑгаÑин Ðмей
+ {"lostpilots", "Pilot Brothers. The Mystery of Atlantic Herring"}, // ÐÑаÑÑÑ ÐилоÑÑ. Ðагадка аÑланÑиÑеÑкой ÑелÑди
+ {"dobrynya", "The Three Bogatyrs: Dobrynia Nikitich and the Serpent Gorynych"}, // 3 богаÑÑÑÑ. ÐобÑÑÐ½Ñ ÐикиÑÐ¸Ñ Ð¸ Ðмей ÐоÑÑнÑÑ
+ {"vladimir", "Prince Vladimir"}, // ÐнÑÐ·Ñ ÐладимиÑ
+ {"luntik", "Moonzy. Getting Ready for School"}, // ÐÑнÑик. ÐодгоÑовка к Ñколе
+ {"luntik2", "Moonzy. Mathematics for Kids"}, // ÐÑнÑик. ÐаÑемаÑика Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ {"luntik3", "Moonzy. Russian for Kids"}, // ÐÑнÑик. Ð ÑÑÑкий ÑзÑк Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ {"luntik4", "Moonzy. English for Kids"}, // ÐÑнÑик. ÐнглийÑкий ÑзÑк Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ {"38_parrots", "38 Parrots. Getting Ready for School"}, // 38 попÑгаев. ÐодгоÑовка к Ñколе
+ {"luntik5", "Moonzy. Education Games for Kids"}, // ÐÑнÑик. РазвиваÑÑие Ð·Ð°Ð´Ð°Ð½Ð¸Ñ Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ {"38_parrots2", "38 Parrots. Mathematics"}, // 38 попÑгаев. ÐаÑемаÑика
+ {"fullkatya", "UmaNetto. Hullo There!"}, // UmaNetto. ÐолнÑй пÑевед!
+ {"muromets", "The Three Bogatyrs: Ilya Muromets and the Nightingale-Robber"}, // 3 богаÑÑÑÑ. ÐлÑÑ ÐÑÑÐ¾Ð¼ÐµÑ Ð¸ Соловей-Ñазбойник
+ {"luntik6", "Moonzy Learns Letters"}, // ÐÑнÑик ÑÑÐ¸Ñ Ð±ÑквÑ
+ {"luntik7", "Moonzy Learns Numbers"}, // ÐÑнÑик ÑÑÐ¸Ñ ÑиÑÑÑ
+
+ // OGRE engine
+ // "Ranetki", // РанеÑки
+
+ // LithTech engine by Monolith Inc.
+ // "Ghosts from Bookland or A Book Adventure", // ÐÑÐ¸Ð²Ð¸Ð´ÐµÐ½Ð¸Ñ Ð¸Ð· ÐÑкленда или книжное пÑиклÑÑение
+
+ {"luntik8", "Moonzy Explores the World"}, // ÐÑнÑик Ð¿Ð¾Ð·Ð½Ð°ÐµÑ Ð¼Ð¸Ñ
+ {"luntik9", "Moonzy Learns to Draw"}, // ÐÑнÑик ÑÑиÑÑÑ ÑиÑоваÑÑ
+ {"luntik10", "Moonzy Studies Rules"}, // ÐÑнÑик ÑÑÐ¸Ñ Ð¿Ñавила
+ {"masterbook", "The Book Of Masters"}, // Ðнига маÑÑеÑов
+ {"38_parrots3", "38 Parrots. Starship Troopers"}, // 38 попÑгаев. ÐвезднÑй деÑанÑ
+ {"luntik11", "Moonzy. Want to Know"}, // ÐÑнÑик. ХоÑÑ Ð²ÑÑ Ð·Ð½Ð°ÑÑ
+ {"luntik12", "Moonzy. Training Memory and Attention"}, // ÐÑнÑик. ТÑениÑÑем памÑÑÑ Ð¸ внимание
+ {"luntik13", "Moonzy. Geography for Kids"}, // ÐÑнÑик. ÐеогÑаÑÐ¸Ñ Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ {"winx2", "Winx Club 2. Stella's Date"}, // Winx Club. Свидание СÑеллÑ
+ {"mm_school_training", "Masha and The Bear. Getting Ready for School"}, // ÐаÑа и медведÑ. ÐодгоÑовка к Ñколе
+ {"trybog", "The Three Bogatyrs and the Shamakhan Queen"}, // 3 богаÑÑÑÑ Ð¸ ШамаÑ
анÑÐºÐ°Ñ ÑаÑиÑа
+ {"winx4", "Winx Club 4. Bloom's Birthday"}, // Winx Club. ÐÐµÐ½Ñ ÑÐ¾Ð¶Ð´ÐµÐ½Ð¸Ñ ÐлÑм
+ {"masha02", "Masha and The Bear. Education Activities for Kids"}, // ÐаÑа и медведÑ. РазвиваÑÑие Ð·Ð°Ð´Ð°Ð½Ð¸Ñ Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ {"winx_pets", "Winx Club 6. Flora's Pets"}, // Winx Club. ФлоÑа и ее пиÑомÑÑ
+ {"winx_turmoil", "Winx Club 7. Turmoil in the Virtuality"}, // Winx Club. ÐеÑеполоÑ
в виÑÑÑалÑноÑÑи
+ {"winx_party", "Winx Club 8. The Party"}, // Winx Club. ÐеÑеÑинка
+ {"vasilisa", "Ivan Tsarevich and the Gray Wolf"}, // Ðван ЦаÑÐµÐ²Ð¸Ñ Ð¸ ÑеÑÑй волк
+ {"vasilisa2", "Ivan Tsarevich. Vasilisa's Wedding"}, // Ðван ЦаÑевиÑ. СвадÑба ÐаÑилиÑÑ
+ {"barboskins_1", "Barboskiny. First Exposure"}, // ÐаÑбоÑкинÑ. ÐеÑвое знакомÑÑво
+ {"masha03", "Masha and The Bear. Hide-and-seek"}, // ÐаÑа и медведÑ. ÐÑÑÑки
+ {"barboskins_2", "Barboskiny. Burying the Truth"}, // ÐаÑбоÑкинÑ. ÐамеÑÐ°Ñ ÑледÑ
+ {"masha04", "Masha and The Bear. Let's Be Friends"}, // ÐаÑа и медведÑ. ÐавайÑе дÑÑжиÑÑ
+ {"phineasferb", "Phineas and Ferb. New Inventions"}, // Ð¤Ð¸Ð½ÐµÑ Ð¸ ФеÑб. ÐовÑе изобÑеÑениÑ
+ {"masha05", "Masha and The Bear. Active Games"}, // ÐаÑа и ÐедведÑ. ÐкÑивнÑе игÑÑ
{nullptr, nullptr}
};
namespace NGI {
+// Catalog placeholders until detection signatures are available.
+#define NGI_STUB(id) { \
+ { id, nullptr, AD_ENTRY1s(id "stub.gam, "00000000000000000000000000000000", 0), \
+ Common::RU_RUS, Common::kPlatformWindows, ADGF_UNSUPPORTED | ADGF_DROPPLATFORM, GUIO1(GUIO_NOMIDI) }, \
+ 0 \
+}
+
static const NGIGameDescription gameDescriptions[] = {
// Magic Dream Russian version
@@ -68,6 +127,8 @@ static const NGIGameDescription gameDescriptions[] = {
},
// Full Pipe Russian version
+ // ÐÐ¾Ð»Ð½Ð°Ñ ÑÑÑба
+ // 2003/11. Pipe Studio
{
{
"fullpipe",
@@ -209,9 +270,183 @@ static const NGIGameDescription gameDescriptions[] = {
GID_FULLPIPE
},
+ // ÐÑаÑÑÑ ÐилоÑÑ. ÐбÑаÑÐ½Ð°Ñ ÑÑоÑона Ðемли
+ // 2004/06. Pipe Studio
+ // qdengine:pilots3
+
+ // ÐÑаÑÑÑ ÐилоÑÑ. Ðлимпиада
+ // 2004/08. Pipe Studio
+ NGI_STUB("pilot7"),
+
+ // 3 богаÑÑÑÑ. ÐлеÑа ÐÐ¾Ð¿Ð¾Ð²Ð¸Ñ Ð¸ ТÑгаÑин Ðмей
+ // 2005/02. Pipe Studio
+ NGI_STUB("popovich"),
+
+ // ÐÑаÑÑÑ ÐилоÑÑ. Ðагадка аÑланÑиÑеÑкой ÑелÑди
+ // 2006/01. Pipe Studio
+ NGI_STUB("lostpilots"),
+
+ // 3 богаÑÑÑÑ. ÐобÑÑÐ½Ñ ÐикиÑÐ¸Ñ Ð¸ Ðмей ÐоÑÑнÑÑ
+ // 2006/03. Pipe Studio
+ NGI_STUB("dobrynya"),
+
+ // ÐнÑÐ·Ñ ÐладимиÑ
+ // 2006/05. Pipe Studio
+ NGI_STUB("vladimir"),
+
+ // ÐÑнÑик. ÐодгоÑовка к Ñколе
+ // 2006/11. Pipe Studio
+ NGI_STUB("luntik"),
+
+ // ÐÑнÑик. ÐаÑемаÑика Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ // 2007/03. Pipe Studio
+ NGI_STUB("luntik2"),
+
+ // ÐÑнÑик. Ð ÑÑÑкий ÑзÑк Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ // 2007/06. Pipe Studio
+ NGI_STUB("luntik3"),
+
+ // ÐÑнÑик. ÐнглийÑкий ÑзÑк Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ // 2007/09. Pipe Studio
+ NGI_STUB("luntik4"),
+
+ // 38 попÑгаев. ÐодгоÑовка к Ñколе
+ // 2007/09. Pipe Studio
+ NGI_STUB("38_parrots"),
+
+ // ÐÑнÑик. РазвиваÑÑие Ð·Ð°Ð´Ð°Ð½Ð¸Ñ Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ // 2007/10. Pipe Studio
+ NGI_STUB("luntik5"),
+
+ // 38 попÑгаев. ÐаÑемаÑика
+ // 2007/11. Pipe Studio
+ NGI_STUB("38_parrots2"),
+
+ // UmaNetto. ÐолнÑй пÑевед!
+ // 2007/12. Pipe Studio
+ NGI_STUB("fullkatya"),
+
+ // 3 богаÑÑÑÑ. ÐлÑÑ ÐÑÑÐ¾Ð¼ÐµÑ Ð¸ Соловей-Ñазбойник
+ // 2007/12. Pipe Studio
+ NGI_STUB("muromets"),
+
+ // ÐÑнÑик ÑÑÐ¸Ñ Ð±ÑквÑ
+ // 2008/08. Pipe Studio
+ NGI_STUB("luntik6"),
+
+ // ÐÑнÑик ÑÑÐ¸Ñ ÑиÑÑÑ
+ // 2008/10. Pipe Studio
+ NGI_STUB("luntik7"),
+
+ // РанеÑки
+ // 2008/11. Pipe Studio
+ // OGRE engine, 3D
+
+ // ÐÑÐ¸Ð²Ð¸Ð´ÐµÐ½Ð¸Ñ Ð¸Ð· ÐÑкленда или книжное пÑиклÑÑение
+ // 2008/12. Pipe Studio
+ // LithTech engine by Monolith Inc.
+
+ // ÐÑнÑик Ð¿Ð¾Ð·Ð½Ð°ÐµÑ Ð¼Ð¸Ñ
+ // 2009/01. Pipe Studio
+ NGI_STUB("luntik8"),
+
+ // ÐÑнÑик ÑÑиÑÑÑ ÑиÑоваÑÑ
+ // 2009/04. Pipe Studio
+ NGI_STUB("luntik9"),
+
+ // ÐÑнÑик ÑÑÐ¸Ñ Ð¿Ñавила
+ // 2009/08. Pipe Studio
+ NGI_STUB("luntik10"),
+
+ // Ðнига маÑÑеÑов
+ // 2009/10. Pipe Studio
+ NGI_STUB("masterbook"),
+
+ // 38 попÑгаев. ÐвезднÑй деÑанÑ
+ // 2009/11. Pipe Studio
+ NGI_STUB("38_parrots3"),
+
+ // ÐÑнÑик. ХоÑÑ Ð²ÑÑ Ð·Ð½Ð°ÑÑ
+ // 2010/02. Pipe Studio
+ NGI_STUB("luntik11"),
+
+ // ÐÑнÑик. ТÑениÑÑем памÑÑÑ Ð¸ внимание
+ // 2010/04. Pipe Studio
+ NGI_STUB("luntik12"),
+
+ // ÐÑнÑик. ÐеогÑаÑÐ¸Ñ Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ // 2010/08. Pipe Studio
+ NGI_STUB("luntik13"),
+
+ // Winx Club. Свидание СÑеллÑ
+ // 2010/11. Pipe Studio
+ NGI_STUB("winx2"),
+
+ // ÐаÑа и медведÑ. ÐодгоÑовка к Ñколе
+ // 2010/12. Pipe Studio
+ NGI_STUB("mm_school_training"),
+
+ // 3 богаÑÑÑÑ Ð¸ ШамаÑ
анÑÐºÐ°Ñ ÑаÑиÑа
+ // 2010/12. Pipe Studio
+ NGI_STUB("trybog"),
+
+ // Winx Club. ÐÐµÐ½Ñ ÑÐ¾Ð¶Ð´ÐµÐ½Ð¸Ñ ÐлÑм
+ // 2011/03. Pipe Studio
+ NGI_STUB("winx4"),
+
+ // ÐаÑа и медведÑ. РазвиваÑÑие Ð·Ð°Ð´Ð°Ð½Ð¸Ñ Ð´Ð»Ñ Ð¼Ð°Ð»ÑÑей
+ // 2011/04. Pipe Studio
+ NGI_STUB("masha02"),
+
+ // Winx Club. ФлоÑа и ее пиÑомÑÑ
+ // 2011/08. Pipe Studio
+ NGI_STUB("winx_pets"),
+
+ // Winx Club. ÐеÑеполоÑ
в виÑÑÑалÑноÑÑи
+ // 2011/10. Pipe Studio
+ NGI_STUB("winx_turmoil"),
+
+ // Winx Club. ÐеÑеÑинка
+ // 2011/10. Pipe Studio
+ NGI_STUB("winx_party"),
+
+ // Ðван ЦаÑÐµÐ²Ð¸Ñ Ð¸ ÑеÑÑй волк
+ // 2011/12. Pipe Studio
+ NGI_STUB("vasilisa"),
+
+ // Ðван ЦаÑевиÑ. СвадÑба ÐаÑилиÑÑ
+ // 2011/12. Pipe Studio
+ NGI_STUB("vasilisa2"),
+
+ // ÐаÑбоÑкинÑ. ÐеÑвое знакомÑÑво
+ // 2012/05. Pipe Studio
+ NGI_STUB("barboskins_1"),
+
+ // ÐаÑа и медведÑ. ÐÑÑÑки
+ // 2012/08. Pipe Studio
+ NGI_STUB("masha03"),
+
+ // ÐаÑбоÑкинÑ. ÐамеÑÐ°Ñ ÑледÑ
+ // 2012/10. Pipe Studio
+ NGI_STUB("barboskins_2"),
+
+ // ÐаÑа и медведÑ. ÐавайÑе дÑÑжиÑÑ
+ // 2012/12. Pipe Studio
+ NGI_STUB("masha04"),
+
+ // Ð¤Ð¸Ð½ÐµÑ Ð¸ ФеÑб. ÐовÑе изобÑеÑениÑ
+ // 2012/12. Pipe Studio
+ NGI_STUB("phineasferb"),
+
+ // ÐаÑа и ÐедведÑ. ÐкÑивнÑе игÑÑ
+ // 2013/04. Pipe Studio
+ NGI_STUB("masha05"),
+
{ AD_TABLE_END_MARKER, 0 }
};
+#undef NGI_STUB
+
} // End of namespace NGI
class NGIMetaEngineDetection : public AdvancedMetaEngineDetection<NGI::NGIGameDescription> {
More information about the Scummvm-git-logs
mailing list