[Scummvm-git-logs] scummvm master -> c4c13ba8f7a977600975128e078d3b17f71f651b
sev-
noreply at scummvm.org
Sat Apr 29 11:01:43 UTC 2023
This automated email contains information about 75 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0c4190679f BUILD: Add support for flagging opengl_game_classic as an engine dep.
4781fca07a WATCHMAKER: Add initial engine harness
ccf209a001 WATCHMAKER: Add all files after initial cleanup.
7a8b38d118 WATCHMAKER: Fix the OpenGL includes to avoid direct includes
93511e6ef1 WATCHMAKER: Call the old Watchmaker main() from run()
47ee7caf3f WATCHMAKER: Drop ./ prefix before opening files.
b223d51ea9 WATCHMAKER: Fix LoadExternalText
f163edc585 WATCHMAKER: Make openFile return a SharedPtr
36a57b7e57 WATCHMAKER: Fix mistake in WorkDirs::join()
35ee83f68d WATCHMAKER: Fix substream support for handling fastfiles.
d52d67482d WATCHMAKER: Drop \n from calls to warning(
752d35a8a9 WATCHMAKER: Start working on textures
86ba5e2f4b WATCHMAKER: Make t3dGetFileDate just check that the file exists.
183baca702 WATCHMAKER: Fix check for empty string.
cc5dd711fc WATCHMAKER: Fix initializing struct that is no longer POD.
eb276dece4 WATCHMAKER: Start refactoring t3dFACE.
d93eb81837 WATCHMAKER: Clear some warnings
55730a1055 WATCHMAKER: Improve some initialization issues.
7ab6257e67 WATCHMAKER: Various refactors to attempt to improve the face rendering
b51a5c463b WATCHMAKER: Apply color key when loading 2D bitmaps
90f4baa744 WATCHMAKER: Fix wrong argument order to seek()
6e1977690f WATCHMAKER: Basic event fixes for OSystem-support.
a4ab7467ef WATCHMAKER: Correct texture loading.
b72acdbcc3 WATCHMAKER: Stub lights and halos
d511a6f39b WATCHMAKER: Start adding movie logic.
4bc0952421 WATCHMAKER: Fix rCreateMaterialList
f4fdda4485 WATCHMAKER: Convert Keyboard-logic to OSystem
cfeb74a842 WATCHMAKER: Refactor textures and implement movies
29f690682d WATCHMAKER: Implement font loading.
6cbc4fff2d WATCHMAKER: Fix slash-handling in file loading.
babafef502 WATCHMAKER: Refactor/Implement viewport matrix handling.
4457ede6f9 WATCHMAKER: Implement "blitting" by keeping track of blits to the back buffer
ad47f12c1f WATCHMAKER: Unstub ME_CONTINUEEFFECT
349bf36149 WATCHMAKER: Apply astyle formatting to code base.
4119ee5b1a WATCHMAKER: Fix an unintentional if due to missing braces
1a23491270 WATCHMAKER: Clear out some warnings
55cd5c8f20 WATCHMAKER: Improve some const usage (to avoid casting away constness)
6f7a9362e5 WATCHMAKER: Refactor BitmapList to no longer be global
5844a03e49 WATCHMAKER: Fix some further warnings, and clean out some #if 0-ed code.
ae7f5ed841 WATCHMAKER: Remove unused logo-code.
b8ead2dea2 WATCHMAKER: Move the GameRects to a class, instead of globals
f1107b4eea WATCHMAKER: Refactor rCopyMaterial to instead use rCopyMaterialList
a0191f939f WATCHMAKER: Unstub UpdateRoomVisibility
4fac22a1b7 WATCHMAKER: Move INV VARS into Init, to reduce the number of global constructors.
70b0a45344 WACTHMAKER: Fix mistake in t3dFinalizeMaterialList
6caa7b59aa WATCHMAKER: Remove most system includes from engine
cf4a76efa0 WATCHMAKER: Pad Mesh name buffer by 1.
468f592d7d WATCHMAKER: Populate Portal Lists
2b3ef5e360 WATCHMAKER: Resize the KeyTable to fit any KeyCode
6ece7cfbc4 WATCHMAKER: Optimize t3dGetFileDate slightly
d9baf157ac WATCHMAKER: Guard against -1 in doDialog.
634c448cb4 WATCHMAKER: Drop unused arg to t3dLoadCharacter
b3ffa5de09 WATCHMAKER: Use Common::String in t3dLoadAnimation
cdc48ff2c8 WATCHMAKER: Use t3dV3F's constructor instead of explicit assignment.
7d0fe48aed WATCHMAKER: Move scheduler global variables into a class.
d2a7afba15 WATCHMAKER: Movie mesh modifiers into a class.
cf8e6d668d WATCHMAKER: Refactor Event to be MessageSystem::doEvent
439b210bcf WATCHMAKER: Move WaitingMsgs into MessageSystem
7b38c8f7c7 WATCHMAKER: Refactor Add2DStuff logic to avoid global constructors
be9dba7ee0 WATCHMAKER: Avoid global constructors in CheckExtraLocalizationStrings
acaca3e1b1 WATCHMAKER: Make t3dV3F's constructor constexpr to reduce global constructors
f6665b5d76 WATCHMAKER: Make SString's constructor constexpr to avoid global constructors.
ce932f8b68 WATCHMAKER: zero-initialize WaterBuffer.
16137c5cf7 WATCHMAKER: Add some missing namespaces
6ea8aefa7b WATCHMAKER: Reduce the use of t3dFree
ca12fc10ab WATCHMAKER: Move room loading to RoomManager.
e9ea877133 WATCHMAKER: Add constexpr constructors for t3dV3F and t3dNORMAL
a63b887082 WATCHMAKER: Drop empty surface.h header
e973308d64 WATCHMAKER: Fix setDirectoryAndName to split on the last \, not the first.
6e705c0665 WATCHMAKER: Fix missing break on EVENT_QUIT-handling
8747a1c620 WATCHMAKER: Adjust the DIALOG sizes to match the retail expectations.
823932c9e1 WATCHMAKER: Remove hack for skipping intro
76707bbac8 WATCHMAKER: Move GL Texture logic to its own file
962bac59b7 WATCHMAKER: Optimize file loading by a lot (by not iterating over SearchMan)
c4c13ba8f7 WATCHMAKER: Silence some warnings.
Commit: 0c4190679f79e757158e020848d90f1ef747e26b
https://github.com/scummvm/scummvm/commit/0c4190679f79e757158e020848d90f1ef747e26b
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
BUILD: Add support for flagging opengl_game_classic as an engine dep.
Changed paths:
configure
devtools/create_project/create_project.cpp
diff --git a/configure b/configure
index e9e3abe6493..edf022f580d 100755
--- a/configure
+++ b/configure
@@ -280,6 +280,7 @@ add_feature highres "high resolution" "_highres"
add_feature mad "MAD" "_mad"
add_feature jpeg "JPEG" "_jpeg"
add_feature mpeg2 "mpeg2" "_mpeg2"
+add_feature opengl_game_classic "OpenGL (classic)" "_opengl_game_classic"
add_feature opengl_game_shaders "OpenGL with shaders" "_opengl_game_shaders"
add_feature png "PNG" "_png"
add_feature gif "GIF" "_gif"
diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp
index ede6358647e..dff5a645fb4 100644
--- a/devtools/create_project/create_project.cpp
+++ b/devtools/create_project/create_project.cpp
@@ -335,7 +335,7 @@ int main(int argc, char *argv[]) {
// HACK: These features depend on OpenGL
if (!getFeatureBuildState("opengl", setup.features)) {
- setFeatureBuildState("opengl_game", setup.features, false);
+ setFeatureBuildState("opengl_game_classic", setup.features, false);
setFeatureBuildState("opengl_shaders", setup.features, false);
}
@@ -1082,35 +1082,35 @@ const Feature s_features[] = {
{ "retrowave", "USE_RETROWAVE", true, false, "RetroWave OPL3 support" },
// Feature flags
- { "bink", "USE_BINK", false, true, "Bink video support" },
- { "scalers", "USE_SCALERS", false, true, "Scalers" },
- { "hqscalers", "USE_HQ_SCALERS", false, true, "HQ scalers" },
- { "edgescalers", "USE_EDGE_SCALERS", false, true, "Edge scalers" },
- { "aspect", "USE_ASPECT", false, true, "Aspect ratio correction" },
- { "16bit", "USE_RGB_COLOR", false, true, "16bit color support" },
- { "highres", "USE_HIGHRES", false, true, "high resolution" },
- { "mt32emu", "USE_MT32EMU", false, true, "integrated MT-32 emulator" },
- { "lua", "USE_LUA", false, true, "lua" },
- { "nasm", "USE_NASM", false, true, "IA-32 assembly support" }, // This feature is special in the regard, that it needs additional handling.
- { "tinygl", "USE_TINYGL", false, true, "TinyGL support" },
- { "opengl", "USE_OPENGL", false, true, "OpenGL support" },
- { "opengl_game", "USE_OPENGL_GAME", false, true, "OpenGL support (classic) in 3d games" },
- { "opengl_shaders", "USE_OPENGL_SHADERS", false, true, "OpenGL support (shaders) in 3d games" },
- { "taskbar", "USE_TASKBAR", false, true, "Taskbar integration support" },
- { "cloud", "USE_CLOUD", false, true, "Cloud integration support" },
- { "enet", "USE_ENET", false, true, "ENet networking support" },
- { "translation", "USE_TRANSLATION", false, true, "Translation support" },
- { "vkeybd", "ENABLE_VKEYBD", false, false, "Virtual keyboard support"},
- { "eventrecorder", "ENABLE_EVENTRECORDER", false, false, "Event recorder support"},
- { "updates", "USE_UPDATES", false, false, "Updates support"},
- { "dialogs", "USE_SYSDIALOGS", false, true, "System dialogs support"},
- { "langdetect", "USE_DETECTLANG", false, true, "System language detection support" }, // This feature actually depends on "translation", there
+ { "bink", "USE_BINK", false, true, "Bink video support" },
+ { "scalers", "USE_SCALERS", false, true, "Scalers" },
+ { "hqscalers", "USE_HQ_SCALERS", false, true, "HQ scalers" },
+ { "edgescalers", "USE_EDGE_SCALERS", false, true, "Edge scalers" },
+ { "aspect", "USE_ASPECT", false, true, "Aspect ratio correction" },
+ { "16bit", "USE_RGB_COLOR", false, true, "16bit color support" },
+ { "highres", "USE_HIGHRES", false, true, "high resolution" },
+ { "mt32emu", "USE_MT32EMU", false, true, "integrated MT-32 emulator" },
+ { "lua", "USE_LUA", false, true, "lua" },
+ { "nasm", "USE_NASM", false, true, "IA-32 assembly support" }, // This feature is special in the regard, that it needs additional handling.
+ { "tinygl", "USE_TINYGL", false, true, "TinyGL support" },
+ { "opengl", "USE_OPENGL", false, true, "OpenGL support" },
+ {"opengl_game_classic", "USE_OPENGL_GAME", false, true, "OpenGL support (classic) in 3d games" },
+ { "opengl_shaders", "USE_OPENGL_SHADERS", false, true, "OpenGL support (shaders) in 3d games" },
+ { "taskbar", "USE_TASKBAR", false, true, "Taskbar integration support" },
+ { "cloud", "USE_CLOUD", false, true, "Cloud integration support" },
+ { "enet", "USE_ENET", false, true, "ENet networking support" },
+ { "translation", "USE_TRANSLATION", false, true, "Translation support" },
+ { "vkeybd", "ENABLE_VKEYBD", false, false, "Virtual keyboard support"},
+ { "eventrecorder", "ENABLE_EVENTRECORDER", false, false, "Event recorder support"},
+ { "updates", "USE_UPDATES", false, false, "Updates support"},
+ { "dialogs", "USE_SYSDIALOGS", false, true, "System dialogs support"},
+ { "langdetect", "USE_DETECTLANG", false, true, "System language detection support" }, // This feature actually depends on "translation", there
// is just no current way of properly detecting this...
- { "text-console", "USE_TEXT_CONSOLE_FOR_DEBUGGER", false, false, "Text console debugger" }, // This feature is always applied in xcode projects
- { "tts", "USE_TTS", false, true, "Text to speech support"},
- {"builtin-resources", "BUILTIN_RESOURCES", false, true, "include resources (e.g. engine data, fonts) into the binary"},
- { "detection-full", "DETECTION_FULL", false, true, "Include detection objects for all engines" },
- { "detection-static", "USE_DETECTION_FEATURES_STATIC", false, true, "Static linking of detection objects for engines."},
+ { "text-console", "USE_TEXT_CONSOLE_FOR_DEBUGGER", false, false, "Text console debugger" }, // This feature is always applied in xcode projects
+ { "tts", "USE_TTS", false, true, "Text to speech support"},
+ { "builtin-resources", "BUILTIN_RESOURCES", false, true, "include resources (e.g. engine data, fonts) into the binary"},
+ { "detection-full", "DETECTION_FULL", false, true, "Include detection objects for all engines" },
+ { "detection-static", "USE_DETECTION_FEATURES_STATIC", false, true, "Static linking of detection objects for engines."},
};
const Tool s_tools[] = {
Commit: 4781fca07abb595135e6d0c2dee6657206f0f337
https://github.com/scummvm/scummvm/commit/4781fca07abb595135e6d0c2dee6657206f0f337
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Add initial engine harness
All this can do for now, is detect The Watchmaker
Changed paths:
A engines/watchmaker/configure.engine
A engines/watchmaker/console.cpp
A engines/watchmaker/console.h
A engines/watchmaker/credits.pl
A engines/watchmaker/detection.cpp
A engines/watchmaker/metaengine.cpp
A engines/watchmaker/module.mk
A engines/watchmaker/watchmaker.cpp
A engines/watchmaker/watchmaker.h
diff --git a/engines/watchmaker/configure.engine b/engines/watchmaker/configure.engine
new file mode 100644
index 00000000000..b2060e1636c
--- /dev/null
+++ b/engines/watchmaker/configure.engine
@@ -0,0 +1,3 @@
+# This file is included from the main "configure" script
+# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
+add_engine watchmaker "The Watchmaker" yes "" "" "highres 16bit opengl_game_classic"
diff --git a/engines/watchmaker/console.cpp b/engines/watchmaker/console.cpp
new file mode 100644
index 00000000000..1a10d8d9771
--- /dev/null
+++ b/engines/watchmaker/console.cpp
@@ -0,0 +1,29 @@
+/* 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 "watchmaker/console.h"
+
+namespace Watchmaker {
+
+Console::Console() {
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/console.h b/engines/watchmaker/console.h
new file mode 100644
index 00000000000..17812885148
--- /dev/null
+++ b/engines/watchmaker/console.h
@@ -0,0 +1,37 @@
+/* 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 WATCHMAKER_CONSOLE_H
+#define WATCHMAKER_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Watchmaker {
+
+class Console : public GUI::Debugger {
+public:
+ explicit Console();
+ ~Console(void) override {}
+};
+
+} // End of namespace Watchmaker
+
+#endif
diff --git a/engines/watchmaker/credits.pl b/engines/watchmaker/credits.pl
new file mode 100644
index 00000000000..43aab98b5e4
--- /dev/null
+++ b/engines/watchmaker/credits.pl
@@ -0,0 +1,3 @@
+begin_section("Watchmaker");
+ add_person("Einar Johan Troan Somaen;", "somaen", "");
+end_section();
diff --git a/engines/watchmaker/detection.cpp b/engines/watchmaker/detection.cpp
new file mode 100644
index 00000000000..fe5157651c3
--- /dev/null
+++ b/engines/watchmaker/detection.cpp
@@ -0,0 +1,80 @@
+/* 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 "base/plugins.h"
+
+#include "engines/advancedDetector.h"
+#include "engines/game.h"
+
+#include "watchmaker/watchmaker.h"
+
+static const PlainGameDescriptor watchmakerGames[] = {
+ {"watchmaker", "The Watchmaker"},
+ {nullptr, nullptr}
+};
+
+static const DebugChannelDef debugFlagList[] = {
+ {Watchmaker::kDebugGeneral, "general", "General debug level"},
+ DEBUG_CHANNEL_END
+};
+
+namespace Watchmaker {
+
+static const ADGameDescription gameDescriptions[] = {
+ // The Watchmaker English Retail
+ {
+ "watchmaker",
+ nullptr,
+ AD_ENTRY1s("Data.wm", "a1675e8fd32c2c1eaed88e292a0d153c", 6017156),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+
+ AD_TABLE_END_MARKER
+};
+
+} // End of namespace Watchmaker
+
+class WatchmakerMetaEngineDetection : public AdvancedMetaEngineDetection {
+public:
+ WatchmakerMetaEngineDetection() : AdvancedMetaEngineDetection(Watchmaker::gameDescriptions, sizeof(ADGameDescription), watchmakerGames) {
+ }
+
+ const char *getName() const override {
+ return "watchmaker";
+ }
+
+ const char *getEngineName() const override {
+ return "The Watchmaker";
+ }
+
+ const char *getOriginalCopyright() const override {
+ return "The Watchmaker (C) 2002 Trecision SpA.";
+ }
+
+ const DebugChannelDef *getDebugChannels() const override {
+ return debugFlagList;
+ }
+};
+
+REGISTER_PLUGIN_STATIC(WATCHMAKER_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, WatchmakerMetaEngineDetection);
diff --git a/engines/watchmaker/metaengine.cpp b/engines/watchmaker/metaengine.cpp
new file mode 100644
index 00000000000..be0d054c18a
--- /dev/null
+++ b/engines/watchmaker/metaengine.cpp
@@ -0,0 +1,55 @@
+/* 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 "base/plugins.h"
+
+#include "engines/advancedDetector.h"
+
+#include "watchmaker/watchmaker.h"
+
+namespace Watchmaker {
+const char *WatchmakerGame::getGameId() const { return _gameDescription->gameId; }
+Common::Platform WatchmakerGame::getPlatform() const { return _gameDescription->platform; }
+} // End of namespace Watchmaker
+
+class WatchmakerMetaEngine : public AdvancedMetaEngine {
+ const char *getName() const override {
+ return "watchmaker";
+ }
+
+ Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
+ bool hasFeature(MetaEngineFeature f) const override;
+};
+
+Common::Error WatchmakerMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ *engine = new Watchmaker::WatchmakerGame(syst, desc);
+ return Common::kNoError;
+}
+
+bool WatchmakerMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return false;
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(WATCHMAKER)
+ REGISTER_PLUGIN_DYNAMIC(WATCHMAKER, PLUGIN_TYPE_ENGINE, WatchmakerMetaEngine);
+#else
+ REGISTER_PLUGIN_STATIC(WATCHMAKER, PLUGIN_TYPE_ENGINE, WatchmakerMetaEngine);
+#endif
diff --git a/engines/watchmaker/module.mk b/engines/watchmaker/module.mk
new file mode 100644
index 00000000000..253a4a9ecc5
--- /dev/null
+++ b/engines/watchmaker/module.mk
@@ -0,0 +1,17 @@
+MODULE := engines/watchmaker
+
+MODULE_OBJS = \
+ watchmaker.o \
+ console.o \
+ metaengine.o
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_WATCHMAKER), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
+
+# Detection objects
+DETECT_OBJS += $(MODULE)/detection.o
diff --git a/engines/watchmaker/watchmaker.cpp b/engines/watchmaker/watchmaker.cpp
new file mode 100644
index 00000000000..89c476180a6
--- /dev/null
+++ b/engines/watchmaker/watchmaker.cpp
@@ -0,0 +1,40 @@
+/* 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 "watchmaker/watchmaker.h"
+#include "watchmaker/console.h"
+
+namespace Watchmaker {
+
+WatchmakerGame::WatchmakerGame(OSystem *syst, const ADGameDescription *gameDesc) :
+ Engine(syst), _gameDescription(gameDesc), _console(nullptr) {
+}
+
+WatchmakerGame::~WatchmakerGame() {
+ //_console is deleted by Engine
+}
+
+Common::Error WatchmakerGame::run() {
+ error("TODO: Implement engine");
+ return Common::kNoError;
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/watchmaker.h b/engines/watchmaker/watchmaker.h
new file mode 100644
index 00000000000..90aac741d95
--- /dev/null
+++ b/engines/watchmaker/watchmaker.h
@@ -0,0 +1,60 @@
+/* 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 WATCHMAKER_WATCHMAKER_H
+#define WATCHMAKER_WATCHMAKER_H
+
+#include "engines/engine.h"
+
+#include "common/platform.h"
+#include "common/queue.h"
+#include "common/rect.h"
+#include "common/str.h"
+
+#include "audio/mixer.h"
+
+struct ADGameDescription;
+
+namespace Watchmaker {
+
+class Console;
+
+enum WatchmakerDebugChannels {
+ kDebugGeneral = 1 << 0
+};
+
+class WatchmakerGame : public Engine {
+public:
+ WatchmakerGame(OSystem *syst, const ADGameDescription *gameDesc);
+ ~WatchmakerGame() override;
+
+ Common::Error run() override;
+
+ // Detection related functions
+ const ADGameDescription *_gameDescription;
+ const char *getGameId() const;
+ Common::Platform getPlatform() const;
+private:
+ Console *_console;
+};
+} // End of namespace Watchmaker
+
+#endif
Commit: ccf209a001855137bc2a0701738514cac8794eb3
https://github.com/scummvm/scummvm/commit/ccf209a001855137bc2a0701738514cac8794eb3
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Add all files after initial cleanup.
Changed paths:
A engines/watchmaker/3d/animation.cpp
A engines/watchmaker/3d/animation.h
A engines/watchmaker/3d/geometry.cpp
A engines/watchmaker/3d/geometry.h
A engines/watchmaker/3d/light.cpp
A engines/watchmaker/3d/light.h
A engines/watchmaker/3d/loader.cpp
A engines/watchmaker/3d/loader.h
A engines/watchmaker/3d/material.cpp
A engines/watchmaker/3d/material.h
A engines/watchmaker/3d/math/Matrix4x4.cpp
A engines/watchmaker/3d/math/Matrix4x4.h
A engines/watchmaker/3d/math/llmath.cpp
A engines/watchmaker/3d/math/llmath.h
A engines/watchmaker/3d/mem_management.cpp
A engines/watchmaker/3d/mem_management.h
A engines/watchmaker/3d/movie.cpp
A engines/watchmaker/3d/movie.h
A engines/watchmaker/3d/render/opengl.cpp
A engines/watchmaker/3d/render/opengl.h
A engines/watchmaker/3d/render/opengl_2d.cpp
A engines/watchmaker/3d/render/opengl_2d.h
A engines/watchmaker/3d/render/opengl_3d.cpp
A engines/watchmaker/3d/render/opengl_3d.h
A engines/watchmaker/3d/render/opengl_renderer.cpp
A engines/watchmaker/3d/render/opengl_renderer.h
A engines/watchmaker/3d/render/render.cpp
A engines/watchmaker/3d/render/render.h
A engines/watchmaker/3d/render/shadows.cpp
A engines/watchmaker/3d/render/shadows.h
A engines/watchmaker/3d/t3d_body.cpp
A engines/watchmaker/3d/t3d_body.h
A engines/watchmaker/3d/t3d_mesh.cpp
A engines/watchmaker/3d/t3d_mesh.h
A engines/watchmaker/3d/texture.cpp
A engines/watchmaker/3d/texture.h
A engines/watchmaker/3d/types3d.cpp
A engines/watchmaker/3d/types3d.h
A engines/watchmaker/3d/vertex.cpp
A engines/watchmaker/3d/vertex.h
A engines/watchmaker/classes/do_action.cpp
A engines/watchmaker/classes/do_action.h
A engines/watchmaker/classes/do_anim.cpp
A engines/watchmaker/classes/do_anim.h
A engines/watchmaker/classes/do_camera.cpp
A engines/watchmaker/classes/do_camera.h
A engines/watchmaker/classes/do_dialog.cpp
A engines/watchmaker/classes/do_dialog.h
A engines/watchmaker/classes/do_inv.cpp
A engines/watchmaker/classes/do_inv.h
A engines/watchmaker/classes/do_inv_inv.cpp
A engines/watchmaker/classes/do_inv_inv.h
A engines/watchmaker/classes/do_inv_scr.cpp
A engines/watchmaker/classes/do_inv_scr.h
A engines/watchmaker/classes/do_keyboard.cpp
A engines/watchmaker/classes/do_keyboard.h
A engines/watchmaker/classes/do_mouse.cpp
A engines/watchmaker/classes/do_mouse.h
A engines/watchmaker/classes/do_operate.cpp
A engines/watchmaker/classes/do_operate.h
A engines/watchmaker/classes/do_player.cpp
A engines/watchmaker/classes/do_player.h
A engines/watchmaker/classes/do_scr_scr.cpp
A engines/watchmaker/classes/do_scr_scr.h
A engines/watchmaker/classes/do_sound.cpp
A engines/watchmaker/classes/do_sound.h
A engines/watchmaker/classes/do_string.cpp
A engines/watchmaker/classes/do_string.h
A engines/watchmaker/classes/do_system.cpp
A engines/watchmaker/classes/do_system.h
A engines/watchmaker/define.h
A engines/watchmaker/extraLS.cpp
A engines/watchmaker/extraLS.h
A engines/watchmaker/game.cpp
A engines/watchmaker/game.h
A engines/watchmaker/game_options.cpp
A engines/watchmaker/game_options.h
A engines/watchmaker/globvar.cpp
A engines/watchmaker/globvar.h
A engines/watchmaker/init/nl_init.cpp
A engines/watchmaker/init/nl_init.h
A engines/watchmaker/init/nl_parse.cpp
A engines/watchmaker/init/nl_parse.h
A engines/watchmaker/ll/ll_anim.cpp
A engines/watchmaker/ll/ll_anim.h
A engines/watchmaker/ll/ll_diary.cpp
A engines/watchmaker/ll/ll_diary.h
A engines/watchmaker/ll/ll_ffile.cpp
A engines/watchmaker/ll/ll_ffile.h
A engines/watchmaker/ll/ll_mesh.cpp
A engines/watchmaker/ll/ll_mesh.h
A engines/watchmaker/ll/ll_mouse.cpp
A engines/watchmaker/ll/ll_mouse.h
A engines/watchmaker/ll/ll_regen.cpp
A engines/watchmaker/ll/ll_regen.h
A engines/watchmaker/ll/ll_sound.cpp
A engines/watchmaker/ll/ll_sound.h
A engines/watchmaker/ll/ll_string.cpp
A engines/watchmaker/ll/ll_string.h
A engines/watchmaker/ll/ll_system.cpp
A engines/watchmaker/ll/ll_system.h
A engines/watchmaker/ll/ll_util.cpp
A engines/watchmaker/ll/ll_util.h
A engines/watchmaker/main.cpp
A engines/watchmaker/main.h
A engines/watchmaker/message.h
A engines/watchmaker/rect.cpp
A engines/watchmaker/rect.h
A engines/watchmaker/render.cpp
A engines/watchmaker/render.h
A engines/watchmaker/renderer.cpp
A engines/watchmaker/renderer.h
A engines/watchmaker/saveload.cpp
A engines/watchmaker/saveload.h
A engines/watchmaker/schedule.cpp
A engines/watchmaker/schedule.h
A engines/watchmaker/sdl_wrapper.cpp
A engines/watchmaker/sdl_wrapper.h
A engines/watchmaker/struct.h
A engines/watchmaker/surface.h
A engines/watchmaker/sysdef.h
A engines/watchmaker/t2d/expr.cpp
A engines/watchmaker/t2d/expr.h
A engines/watchmaker/t2d/t2d.cpp
A engines/watchmaker/t2d/t2d.h
A engines/watchmaker/t2d/t2d_internal.h
A engines/watchmaker/t3d.h
A engines/watchmaker/tga_util.cpp
A engines/watchmaker/tga_util.h
A engines/watchmaker/types.h
A engines/watchmaker/utils.h
A engines/watchmaker/walk/act.cpp
A engines/watchmaker/walk/act.h
A engines/watchmaker/walk/ball.cpp
A engines/watchmaker/walk/ball.h
A engines/watchmaker/walk/walk.cpp
A engines/watchmaker/walk/walk.h
A engines/watchmaker/walk/walkutil.cpp
A engines/watchmaker/walk/walkutil.h
A engines/watchmaker/windows_hacks.cpp
A engines/watchmaker/windows_hacks.h
A engines/watchmaker/work_dirs.cpp
A engines/watchmaker/work_dirs.h
engines/watchmaker/metaengine.cpp
engines/watchmaker/module.mk
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
new file mode 100644
index 00000000000..a4122b9cf2b
--- /dev/null
+++ b/engines/watchmaker/3d/animation.cpp
@@ -0,0 +1,744 @@
+/* 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/>.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_EXCEPTION_strcat
+#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
+
+#include "watchmaker/3d/animation.h"
+#include "watchmaker/3d/geometry.h"
+#include "watchmaker/t3d.h"
+#include "watchmaker/types.h"
+#include "watchmaker/3d/t3d_body.h"
+#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/t3d.h"
+#include "watchmaker/types.h"
+#include "watchmaker/3d/loader.h"
+#include "watchmaker/3d/math/llmath.h"
+#include "watchmaker/ll/ll_system.h"
+#include "watchmaker/utils.h"
+#include "watchmaker/windows_hacks.h"
+#include "watchmaker/game.h"
+
+/* -----------------16/12/98 10.32-------------------
+ * PRELOADEDANIMS
+ * --------------------------------------------------*/
+#define MAX_BONES 40
+#define MAX_PRELOADED_ANIMS 8
+#define A3DFILEVERSION 5
+#define SCALE_DEFAULT_ANIM 1
+#define SCALE_ANIM 3
+
+namespace Watchmaker {
+
+struct t3dLOADBONE {
+ t3dV3F *Trasl;
+ t3dV3F *Euler;
+ uint32 NumBone;
+};
+
+struct t3dLOADANIM {
+ Common::String name;
+ uint32 NumFrames, NumBones, HiBone, LastTime;
+ t3dF32 *Dist;
+ t3dLOADBONE Bone[MAX_BONES];
+};
+
+t3dLOADANIM PreloadedAnim[MAX_PRELOADED_ANIMS];
+
+/* -----------------30/12/98 10.56-------------------
+ * t3dMatRotXYZ
+ * --------------------------------------------------*/
+void t3dMatRotXYZ(t3dM3X3F *dest, t3dF32 x, t3dF32 y, t3dF32 z) {
+ t3dM3X3F matrix, matrix_x, matrix_y, matrix_z;
+
+ t3dMatIdentity(&matrix_x);
+ t3dMatIdentity(&matrix_y);
+ t3dMatIdentity(&matrix_z);
+
+ matrix_x.M[4] = (float)cos(x);
+ matrix_x.M[5] = (float)sin(x);
+ matrix_x.M[7] = -(float)sin(x);
+ matrix_x.M[8] = (float)cos(x);
+
+ matrix_y.M[0] = (float)cos(y);
+ matrix_y.M[2] = -(float)sin(y);
+ matrix_y.M[6] = (float)sin(y);
+ matrix_y.M[8] = (float)cos(y);
+
+ matrix_z.M[0] = (float)cos(z);
+ matrix_z.M[1] = (float)sin(z);
+ matrix_z.M[3] = -(float)sin(z);
+ matrix_z.M[4] = (float)cos(z);
+
+ t3dMatMul(&matrix, &matrix_x, &matrix_y);
+ t3dMatMul(&matrix, &matrix, &matrix_z);
+
+ dest->M[0] = matrix.M[0];
+ dest->M[2] = matrix.M[1];
+ dest->M[1] = matrix.M[2];
+ dest->M[6] = matrix.M[3];
+ dest->M[8] = matrix.M[4];
+ dest->M[7] = matrix.M[5];
+ dest->M[3] = matrix.M[6];
+ dest->M[5] = matrix.M[7];
+ dest->M[4] = matrix.M[8];
+}
+
+Common::Array<t3dPLIGHT> t3dBODY::getPositionalLight(uint8 pos) {
+ Common::Array<t3dPLIGHT> result;
+ for (auto light : PosLightTable) {
+ if (light.Num == pos) {
+ result.push_back(light);
+ }
+ }
+ return result;
+}
+
+/* -----------------04/07/98 15.52-------------------
+ * GetLightPosition
+ * --------------------------------------------------*/
+uint8 GetLightPosition(t3dV3F *dest, uint8 pos) {
+ if (!pos) return 0;
+
+ auto pLights = t3dCurRoom->getPositionalLight(pos);
+ dest->y = CurFloorY;
+ for (auto light: pLights) {
+ if (light.Pos.x && light.Pos.z) {
+ dest->x = light.Pos.x;
+ dest->z = light.Pos.z;
+ return pos;
+ }
+ }
+ if (pos != 99)
+ warning("Can't find lpos %d in %s", pos, t3dCurRoom->name.c_str());
+ return 0;
+}
+
+/* -----------------04/07/98 15.52-------------------
+ * GetLightPosition
+ * --------------------------------------------------*/
+uint8 GetLightDirection(t3dV3F *dest, uint8 pos) {
+ if (!pos) return 0;
+
+ auto pLights = t3dCurRoom->getPositionalLight(pos);
+ dest->y = CurFloorY;
+ for (auto light: pLights) {
+ if (light.Dir.x && light.Dir.z) {
+ dest->x = light.Dir.x;
+ dest->z = light.Dir.x;
+ return pos;
+ }
+ }
+ if (pos != 99)
+ warning("Can't find ldir %d in %s", pos, t3dCurRoom->name.c_str());
+ return 0;
+}
+
+
+/* -----------------15/12/98 16.26-------------------
+ * t3dLoadAnimation
+ * --------------------------------------------------*/
+int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag) {
+ uint32 nf, nb, i, j, k, h, older, len, ScaleAnim, CurPreloadedAnim;
+ t3dLOADANIM *p;
+ t3dLOADBONE *bone;
+ t3dBONEANIM *db;
+ t3dBONE *b;
+ t3dV3F t;
+ t3dF32 c;
+ char name[100];
+
+// Prova a vedere se l'ho gia' precaricata
+ for (CurPreloadedAnim = 0; CurPreloadedAnim < MAX_PRELOADED_ANIMS; CurPreloadedAnim++)
+ if (PreloadedAnim[CurPreloadedAnim].NumFrames)
+ if (PreloadedAnim[CurPreloadedAnim].name.equalsIgnoreCase(s))
+ break;
+// Se la devo precaricare, cerco quella piu' vecchia e la scarico
+ if (CurPreloadedAnim >= MAX_PRELOADED_ANIMS) {
+ older = 0;
+// Prima cerco se ci sono ancora degli slot liberi
+ for (CurPreloadedAnim = 0; CurPreloadedAnim < MAX_PRELOADED_ANIMS; CurPreloadedAnim++) {
+ if (!PreloadedAnim[CurPreloadedAnim].NumFrames)
+ break;
+ else if (!(older) || (older > PreloadedAnim[CurPreloadedAnim].LastTime))
+ older = PreloadedAnim[j = CurPreloadedAnim].LastTime;
+ }
+// Se non c'erano slot liberi, rilascia vecchia animazione precaricata
+ if (CurPreloadedAnim >= MAX_PRELOADED_ANIMS) {
+ CurPreloadedAnim = j;
+//t DebugFile( "Precarico animazione %s nello slot %d occupato da %s", s, CurPreloadedAnim, PreloadedAnim[j].Name );
+// Disalloca tutto
+ for (i = 0; i < MAX_BONES; i++) {
+ t3dFree(PreloadedAnim[j].Bone[i].Trasl);
+ t3dFree(PreloadedAnim[j].Bone[i].Euler);
+ }
+ t3dFree(PreloadedAnim[j].Dist);
+ memset(&PreloadedAnim[j], 0, sizeof(t3dLOADANIM));
+ }
+//t else
+//t DebugFile( "Precarico animazione %s nello slot libero %d", s, CurPreloadedAnim );
+
+ p = &PreloadedAnim[CurPreloadedAnim];
+ p->name = s;
+
+// Carica la nuova animazione
+ memset(name, 0, sizeof(name));
+ strcpy(&name[0], game.workDirs._a3dDir.c_str());
+ strcat(&name[0], &s[0]);
+ len = strlen(name);
+ name[len - 3] = 'a';
+ name[len - 2] = '3';
+ name[len - 1] = 'd';
+
+ {
+ auto stream = game.resolveFile(name);
+ if (!stream) {
+ warning("File %s not found\n", name);
+ return -1;
+ }
+
+ if ((i = stream->readByte()) != A3DFILEVERSION) {
+ warning("%s file incompatible: current version: %d.\tFile version: %d", name, A3DFILEVERSION, i);
+ return -1;
+ }
+
+ nb = stream->readSint16LE();
+ nf = stream->readSint16LE();
+ if (nf == 0) {
+ warning("%s has N0 frames!", name);
+ return -1;
+ }
+ if (nb >= MAX_BONES) {
+ warning("%s has too many bones (%d, MAX is %d)!", name, j, MAX_BONES);
+ return -1;
+ }
+ p->NumBones = nb;
+ p->NumFrames = nf;
+
+ for (i = 0; i < nb; i++) {
+ j = (uint32)(stream->readByte());
+ if (!(p->HiBone) || (p->HiBone < j))
+ p->HiBone = j;
+
+ bone = &p->Bone[i];
+ bone->NumBone = j;
+ bone->Euler = t3dCalloc<t3dV3F>(nf);
+ bone->Trasl = t3dCalloc<t3dV3F>(nf);
+
+ for (k = 0; k < nf; k++) {
+ bone->Euler[k].x = stream->readFloatLE();
+ bone->Euler[k].y = stream->readFloatLE();
+ bone->Euler[k].z = stream->readFloatLE();
+ }
+
+ for (k = 0; k < nf; k++) {
+ bone->Trasl[k].x = stream->readFloatLE();
+ bone->Trasl[k].y = stream->readFloatLE();
+ bone->Trasl[k].z = stream->readFloatLE();
+ }
+ }
+ if (stream->readByte()) {
+ p->Dist = (t3dF32 *) t3dMalloc(nf * sizeof(t3dF32));
+ for (k = 0; k < nf; k++)
+ p->Dist[k] = stream->readFloatLE();
+ }
+ } // Close file
+ }
+//t else
+//t DebugFile( "Animazione %s gia' precaricata nello slot %d", s, CurPreloadedAnim );
+
+ p = &PreloadedAnim[CurPreloadedAnim];
+// Scrive l'ultima volta che l'ho usata
+ p->LastTime = t3dReadTime();
+
+// Finalmente copia l'animazione precaricata nella mesh
+ if (Flag & T3D_MESH_DEFAULTANIM) {
+ db = &mesh->DefaultAnim;
+ mesh->Flags |= T3D_MESH_DEFAULTANIM;
+ if (db) mesh->releaseAnim(T3D_MESH_DEFAULTANIM);
+ if (db) mesh->releaseAnim(0);
+ ScaleAnim = SCALE_DEFAULT_ANIM;
+ db->NumFrames = p->NumFrames;
+ } else {
+ db = &mesh->Anim;
+ mesh->Flags &= ~T3D_MESH_DEFAULTANIM;
+ if (db) mesh->releaseAnim(0);
+ ScaleAnim = SCALE_ANIM;
+ db->NumFrames = (p->NumFrames - 2) * ScaleAnim + 2;
+ }
+ if (db->BoneTable) mesh->releaseAnim(0);
+ mesh->NumNormals = 0;
+ db->NumBones = 0;
+ db->BoneTable = nullptr;
+ db->BoneTable = t3dCalloc<t3dBONE>(p->HiBone + 1);
+ db->NumBones = p->HiBone + 1;
+
+ c = 1.0f / (t3dF32)(ScaleAnim);
+ for (i = 0; i < p->NumBones; i++) {
+ bone = &p->Bone[i];
+ b = &db->BoneTable[bone->NumBone];
+
+ b->Matrix = t3dCalloc<t3dM3X3F>(db->NumFrames);
+ b->Trasl = t3dCalloc<t3dV3F>(db->NumFrames);
+
+ for (k = 0; k < db->NumFrames; k++) {
+ j = ((k - 1) / ScaleAnim) + 1;
+ h = ((k - 1) % ScaleAnim);
+
+ if ((!h) || (k < 1)) {
+ if (k < 1)
+ j = k;
+ t3dMatRotXYZ(&b->Matrix[k], bone->Euler[j].x, bone->Euler[j].y, bone->Euler[j].z);
+ memcpy(&b->Trasl[k], &bone->Trasl[j], sizeof(t3dV3F));
+ } else {
+ t3dVectSub(&t, &bone->Euler[j + 1], &bone->Euler[j]);
+ if ((t.x < T3D_2PI) && (t.x > T3D_PI)) t.x = t.x - T3D_2PI;
+ if ((t.x > -T3D_2PI) && (t.x < -T3D_PI)) t.x = t.x + T3D_2PI;
+ if ((t.y < T3D_2PI) && (t.y > T3D_PI)) t.y = t.y - T3D_2PI;
+ if ((t.y > -T3D_2PI) && (t.y < -T3D_PI)) t.y = t.y + T3D_2PI;
+ if ((t.z < T3D_2PI) && (t.z > T3D_PI)) t.z = t.z - T3D_2PI;
+ if ((t.z > -T3D_2PI) && (t.z < -T3D_PI)) t.z = t.z + T3D_2PI;
+ t *= (c * (t3dF32)(h));
+ t3dVectAdd(&t, &bone->Euler[j], &t);
+ t3dMatRotXYZ(&b->Matrix[k], t.x, t.y, t.z);
+
+ t3dVectSub(&t, &bone->Trasl[j + 1], &bone->Trasl[j]);
+ t *= (c * (t3dF32)(h));
+ t3dVectAdd(&b->Trasl[k], &bone->Trasl[j], &t);
+ }
+
+ /* if(!(mesh->Flags&T3D_MESH_CHARACTER))
+ DebugFile("%3d;%3d;%9f;%9f;%9f;%9f;%9f;%9f;%9f;%9f;%9f;%9f;%9f;%9f;",k,i,
+ (bone->Euler[j].x)*180.0f/T3D_PI,(bone->Euler[j].y)*180.0f/T3D_PI,(bone->Euler[j].z)*180.0f/T3D_PI,
+ b->Matrix[k].M[0],b->Matrix[k].M[1],b->Matrix[k].M[2],
+ b->Matrix[k].M[3],b->Matrix[k].M[4],b->Matrix[k].M[5],
+ b->Matrix[k].M[6],b->Matrix[k].M[7],b->Matrix[k].M[8] );
+ */
+ }
+
+ b->ModVertices.clear();
+// Poi inserisce tutti i vertici modificati nell'array gia' alloocato della dimensione giusta
+ for (auto &modVertices : mesh->ModVertices) {
+ if (modVertices.NumBone == bone->NumBone) {
+ b->ModVertices.push_back(modVertices.NumVert);
+ }
+ }
+ }
+ if (p->Dist) {
+ db->Dist = (t3dF32 *)t3dMalloc(db->NumFrames * sizeof(t3dF32));
+ for (k = 0; k < db->NumFrames; k++)
+ db->Dist[k] = p->Dist[k];
+ }
+ return 1;
+}
+
+/* -----------------30/12/98 11.27-------------------
+ * FixupAnim
+ * --------------------------------------------------*/
+void FixupAnim(t3dMESH *mesh, uint8 pos, const char *room) {
+ t3dBONEANIM *db;
+ t3dBONE *bone, *bone0;
+ t3dV3F lp, ld, Frame0Trasl, cc, tmp, tmp1, tmp2, zero;
+ t3dM3X3F lm, mx, BoneInitMatrix;
+ uint32 i, k, frame;
+ t3dBODY *OldCurRoom = t3dCurRoom;
+
+ if (mesh->Flags & T3D_MESH_DEFAULTANIM) {
+ db = &mesh->DefaultAnim;
+ pos = 0;
+ } else {
+ db = &mesh->Anim;
+ if (pos) {
+ if (room && (room[0] != '\0')) {
+ for (i = 0; i < NumLoadedFiles; i++)
+ if ((LoadedFiles[i].b != nullptr) && LoadedFiles[i].b->name.equalsIgnoreCase(room))
+ t3dCurRoom = LoadedFiles[i].b;
+ }
+ if (!GetLightPosition(&lp, pos) || (lp.x == 0.0f) || (lp.z == 0.0f)) pos = 0;
+ if (!GetLightDirection(&ld, pos) || (ld.x == 0.0f) || (ld.z == 0.0f)) pos = 0;
+ t3dCurRoom = OldCurRoom;
+
+ t3dVectSub(&ld, &ld, &lp);
+ ld.z = -ld.z;
+ t3dVectAdd(&ld, &ld, &lp);
+ t3dMatView(&lm, &lp, &ld);
+
+ if ((!pos) || (mesh->Flags & (T3D_MESH_ABS_ANIM | T3D_MESH_CHARACTER))) {
+ t3dVectCopy(&lp, &mesh->Trasl);
+ t3dMatCopy(&lm, &mesh->Matrix);
+ pos = 99;
+ }
+
+ if (mesh->Flags & T3D_MESH_ABS_ANIM)
+ t3dVectTransform(&cc, &CharCorrection, &lm);
+ }
+ }
+// Ora sistema tutte le altre bones 1..32 (mesh) e 33/34 (camera)
+ for (i = 1; i < db->NumBones; i++) {
+ if (!(bone = &db->BoneTable[i]) || !(bone->Trasl) || !(bone->Matrix)) continue;
+// Salva la prima matrice di ogni bone
+ t3dMatCopy(&BoneInitMatrix, &bone->Matrix[0]);
+// Calcola scostamento iniziale bone per azioni assolute personaggi
+ if (i == 1) t3dVectSub(&Frame0Trasl, &bone->Trasl[1], &bone->Trasl[0]);
+
+ for (k = 0; k < db->NumFrames; k++) {
+// Tutte le matrici diventano relative al frame 0
+ t3dMatMulInv(&bone->Matrix[k], &bone->Matrix[k], &BoneInitMatrix);
+// Aggiunge la correzione a:
+// - Azioni di default (tutti frames personaggi)
+// - Azioni relative (tutti frames, personaggi e oggetti)
+// - Azioni assolute (personaggi frame 0)
+ if ((mesh->Flags & T3D_MESH_DEFAULTANIM) || !(mesh->Flags & T3D_MESH_ABS_ANIM) ||
+ ((!k) && (mesh->Flags & T3D_MESH_ABS_ANIM) && (mesh->Flags & T3D_MESH_CHARACTER)))
+ t3dVectAdd(&bone->Trasl[k], &CharCorrection, &bone->Trasl[k]);
+
+ if (pos) {
+// Oggetti relativi
+ if (!(mesh->Flags & T3D_MESH_CHARACTER) && !(mesh->Flags & T3D_MESH_ABS_ANIM)) {
+ t3dVectTransform(&ld, &bone->Trasl[k], &lm);
+ t3dVectAdd(&bone->Trasl[k], &ld, &lp);
+ }
+// Personaggi assoluti
+ else if ((mesh->Flags & T3D_MESH_ABS_ANIM) && (mesh->Flags & T3D_MESH_CHARACTER) && (k)) {
+ t3dVectSub(&bone->Trasl[k], &bone->Trasl[k], &Frame0Trasl);
+ t3dVectTransformInv(&bone->Trasl[k], &bone->Trasl[k], &lm);
+ t3dVectAdd(&bone->Trasl[k], &bone->Trasl[k], &CharCorrection);
+
+ t3dMatMul(&bone->Matrix[k], &bone->Matrix[k], &lm);
+ }
+ }
+ /* if(!(mesh->Flags&T3D_MESH_CHARACTER))
+ DebugFile("%3d;%3d;%9f;%9f;%9f;%9f;%9f;%9f;%9f;%9f;%9f;",k,i,
+ bone->Matrix[k].M[0],bone->Matrix[k].M[1],bone->Matrix[k].M[2],
+ bone->Matrix[k].M[3],bone->Matrix[k].M[4],bone->Matrix[k].M[5],
+ bone->Matrix[k].M[6],bone->Matrix[k].M[7],bone->Matrix[k].M[8] );
+ */
+ }
+ }
+
+ if (db->Dist)
+ for (k = 0; k < db->NumFrames; k++)
+ if ((mesh->Flags & T3D_MESH_CHARACTER) && ((!k) || (mesh->Flags & T3D_MESH_DEFAULTANIM)))
+ db->Dist[k] -= CharCorrection.z;
+
+ if (!(bone0 = &db->BoneTable[0]) || !(bone0->Trasl) || !(bone0->Matrix)) {
+ bone0->Matrix = t3dCalloc<t3dM3X3F>(db->NumFrames);
+ bone0->Trasl = t3dCalloc<t3dV3F>(db->NumFrames);
+ } else
+ warning("Guarda che il bone0 e' gia' stato allocato nella mesh %s", mesh->name.c_str());
+
+ for (k = 0; k < db->NumFrames; k++) {
+ t3dVectCopy(&bone0->Trasl[k], &mesh->Trasl);
+ t3dMatCopy(&bone0->Matrix[k], &mesh->Matrix);
+ }
+
+ if ((mesh->Flags & T3D_MESH_CHARACTER) && !(mesh->Flags & T3D_MESH_DEFAULTANIM)) {
+ if (!(bone = &db->BoneTable[1]) || !(bone->Trasl) || !(bone->Matrix))
+ return ;
+
+ t3dVectInit(&tmp1, bone->Trasl[1].x, 0.0f, bone->Trasl[1].z);
+ t3dVectInit(&tmp, 0.0f, 0.0f, 1.0f);
+ t3dVectTransform(&tmp, &tmp, &bone->Matrix[1]);
+ tmp.y = 0;
+ t3dVectFill(&zero, 0.0f);
+ t3dMatView(&mx, &zero, &tmp);
+ t3dVectTransform(&cc, &CharCorrection, &mx);
+ t3dVectSub(&tmp1, &tmp1, &cc);
+
+ for (frame = 0; frame < db->NumFrames; frame++) {
+ t3dVectInit(&tmp2, bone->Trasl[frame].x, 0.0f, bone->Trasl[frame].z);
+ t3dVectInit(&tmp, 0.0f, 0.0f, 1.0f);
+ t3dVectTransform(&tmp, &tmp, &bone->Matrix[frame]);
+ tmp.y = 0;
+ t3dVectFill(&zero, 0.0f);
+ t3dMatView(&mx, &zero, &tmp);
+ t3dVectTransform(&cc, &CharCorrection, &mx);
+ t3dVectSub(&tmp2, &tmp2, &cc);
+
+ t3dVectSub(&tmp, &tmp2, &tmp1);
+// t3dVectTransform( &tmp, &tmp, &mesh->Matrix );
+
+ tmp.x += bone->Trasl[1].x - bone->Trasl[0].x;
+ tmp.z += bone->Trasl[1].z - bone->Trasl[0].z;
+
+ t3dVectCopy(&bone0->Trasl[frame], &tmp);
+ t3dVectInit(&tmp, 0.0f, 0.0f, -1.0f);
+ t3dVectTransform(&tmp, &tmp, &bone->Matrix[frame]);
+ tmp.z = -tmp.z;
+ tmp.y = 0;
+ t3dVectFill(&zero, 0.0f);
+ t3dMatView(&bone0->Matrix[frame], &zero, &tmp);
+ }
+
+ for (i = 1; i < db->NumBones; i++) {
+ if (!(bone = &db->BoneTable[i]) || !(bone->Trasl) || !(bone->Matrix))
+ continue;
+
+ for (k = 0; k < db->NumFrames; k++) {
+ t3dVectSub(&bone->Trasl[k], &bone->Trasl[k], &bone0->Trasl[k]);
+ t3dVectTransform(&bone->Trasl[k], &bone->Trasl[k], &bone0->Matrix[k]);
+ t3dMatMulInv(&bone->Matrix[k], &bone->Matrix[k], &bone0->Matrix[k]);
+ }
+ }
+
+ for (k = 0; k < db->NumFrames; k++) {
+ t3dMatMulInv(&bone0->Matrix[k], &mesh->Matrix, &bone0->Matrix[k]);
+ t3dVectTransform(&tmp, &bone0->Trasl[k], &mesh->Matrix);
+ t3dVectAdd(&bone0->Trasl[k], &mesh->Trasl, &tmp);
+ }
+ }
+}
+
+/* -----------------13/04/99 14.57-------------------
+ * LoadShadowMeshes
+ * --------------------------------------------------*/
+t3dBODY *LoadShadowMeshes(WGame &game, const char *pname, t3dBODY *Body) {
+ uint16 ref;
+ char Name[255];
+ t3dBODY *shadow = new t3dBODY();
+ gVertex *Original = Body->MeshTable[0].VertexBuffer;
+ t3dF32 dist, rez;
+
+ strcpy(Name, pname);
+ strncpy(&Name[strlen(pname) - 4], "_Shadow.t3d\0", 12);
+ uint16 numBodys = 0;
+ shadow = t3dLoadRoom(game, Name, shadow, &numBodys, (T3D_NOLIGHTMAPS | T3D_NORECURSION | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_NOBOUNDS | T3D_STATIC_SET0 | T3D_STATIC_SET1));
+ if (!shadow) return nullptr;
+
+ for (uint16 i = 0; i < shadow->NumMeshes(); i++) {
+ t3dMESH &m = shadow->MeshTable[i];
+ m.VBptr = m.VertexBuffer;
+ for (uint16 j = 0; j < m.NumFaces(); j++) {
+ t3dFACE &f = m.FList[j];
+ for (uint16 n = 0; n < 3; n++) {
+ t3dV3F pnt;
+ pnt.x = m.VBptr[f.VertexIndex[n]].x;
+ pnt.y = m.VBptr[f.VertexIndex[n]].y;
+ pnt.z = m.VBptr[f.VertexIndex[n]].z;
+
+ ref = 0;
+ dist = 999999999.0f;
+ for (uint16 k = 0; k < Body->MeshTable[0].NumVerts; k++) {
+ t3dV3F tpnt;
+ tpnt.x = Original[k].x;
+ tpnt.y = Original[k].y;
+ tpnt.z = Original[k].z;
+ if ((rez = t3dVectDistance(&pnt, &tpnt)) < dist) {
+ dist = rez;
+ ref = k;
+ }
+ }
+ f.VertexIndex[n] = ref;
+ }
+ }
+ m.VBptr = nullptr;
+ delete[] m.VertexBuffer;
+ m.VertexBuffer = nullptr;
+ delete[] m.OldVertexBuffer;
+ m.OldVertexBuffer = nullptr;
+ delete[] m.SavedVertexBuffer;
+ m.SavedVertexBuffer = nullptr;
+
+ m.VertexBuffer = Body->MeshTable[0].VertexBuffer;
+ m.NumVerts = Body->MeshTable[0].NumVerts;
+ m.Flags |= T3D_MESH_CHARACTER; //this is a character
+ }
+ return shadow;
+}
+
+
+/* -----------------30/12/98 11.27-------------------
+ * t3dLoadCharacter
+ * --------------------------------------------------*/
+t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, t3dCHARACTER *b, uint16 num) {
+ warning("LoadCharacter(%s)\n", pname);
+ uint8 Mirror = 1;
+ uint16 n = 0, f, i;
+ t3dV3F tmp;
+ // gVertex *v;
+
+ b = new t3dCHARACTER[1] {};
+ b->Body = nullptr;
+ b->Body = t3dLoadRoom(game, pname, b->Body, &n, (T3D_NOLIGHTMAPS | T3D_NORECURSION | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_STATIC_SET0 | T3D_STATIC_SET1));
+ if (!b->Body) return nullptr;
+ b->Mesh = &b->Body->MeshTable[0];
+ b->CurRoom = t3dCurRoom;
+ b->Flags = T3D_CHARACTER_HIDE | T3D_CHARACTER_REALTIMELIGHTING;
+ if (num >= 2) b->Flags |= T3D_CHARACTER_BNDHIDE;
+ //Try to load animation
+ if (t3dLoadAnimation(game, pname, b->Mesh, T3D_MESH_DEFAULTANIM) == -1) {
+ warning("t3dLoadCharacter: Error loading %s\n", pname);
+ return nullptr;
+ }
+ FixupAnim(b->Mesh, 0, "");
+
+ // Zero's all the Normals vars, 'cause I recalc all the normals runtime...
+ b->Body->NumNormals = 0;
+ b->Body->NumVerticesNormals = 0;
+
+ for (uint16 n = 0; n < b->Body->NumMeshes(); n++) {
+ t3dMESH &mesh = b->Body->MeshTable[n];
+ for (f = 0; f < mesh.NumFaces(); f++) {
+ mesh.FList[f].n = nullptr;
+ }
+//sb
+//sb mesh->Flags|=T3D_MESH_CASTREALTIMESHADOWS;
+//sb
+ }
+ b->Body->NList.clear();
+//sb
+//sb b->Flags|=T3D_CHARACTER_CASTREALTIMESHADOWS;
+//sb
+// Per gli specchi
+ if (Mirror) { // Ogni personaggio potrebbe apparire in uno specchio
+ b->Body->MirrorMatTable.resize(b->Body->NumMaterials());
+
+ for (i = 0; i < b->Body->NumMaterials(); i++) {
+ rCopyMaterial(b->Body->MirrorMatTable[i], b->Body->MatTable[i]);
+ }
+ }
+
+// Per le ombre, altezza e raggio del cilindro
+ b->Height = (t3dF32)sqrt(b->Mesh->BBox[0].p.x * b->Mesh->BBox[0].p.x + b->Mesh->BBox[0].p.z * b->Mesh->BBox[0].p.z);
+ b->Radius = (t3dF32)sqrt(b->Mesh->BBox[5].p.x * b->Mesh->BBox[5].p.x + b->Mesh->BBox[5].p.z * b->Mesh->BBox[5].p.z);
+ if (b->Radius < b->Height) b->Radius = b->Height;
+ b->Height = (b->Mesh->BBox[0].p.y - b->Mesh->BBox[2].p.y) * 1.2f;
+
+ // No bounding box detection
+ /* t3dVectFill(&b->Mesh->BBox[0].p,0.0f);
+ t3dVectFill(&b->Mesh->BBox[1].p,0.0f);
+ t3dVectFill(&b->Mesh->BBox[2].p,0.0f);
+ t3dVectFill(&b->Mesh->BBox[3].p,0.0f);
+ t3dVectFill(&b->Mesh->BBox[4].p,0.0f);
+ t3dVectFill(&b->Mesh->BBox[5].p,0.0f);
+ t3dVectFill(&b->Mesh->BBox[6].p,0.0f);
+ t3dVectFill(&b->Mesh->BBox[7].p,0.0f);
+ b->Mesh->Flags|=T3D_MESH_NOBOUNDBOX;
+ */
+ for (uint16 n = 0; n < b->Body->NumMeshes(); n++) {
+ b->Body->MeshTable[n].Flags |= T3D_MESH_CHARACTER;
+ b->Body->MeshTable[n].Flags &= ~T3D_MESH_MIRROR;
+ }
+
+ t3dVectFill(&b->Pos, 0.0f);
+ t3dVectInit(&tmp, 0.0f, 0.0f, -1.0f);
+ t3dVectAdd(&tmp, &b->Pos, &tmp);
+ t3dMatView(&b->Mesh->Matrix, &b->Pos, &tmp);
+
+ b->Mesh->Matrix.Flags &= ~T3D_MATRIX_IDENTITY;
+ b->Mesh->CurFrame = 4;
+ b->Mesh->LastFrame = 0;
+ b->Mesh->BlendPercent = 255;
+
+ b->Walk.OldPanel = -1;
+ b->Walk.CurPanel = -1;
+ b->Walk.NumPathNodes = -1;
+
+ t3dVectInit(&b->Dir, 0.0f, 0.0f, -1.0f);
+ t3dVectTransform(&b->Dir, &b->Dir, &b->Mesh->Matrix); //rotate by Character angle
+
+//sb
+ if (num < 2)
+ b->Shadow = LoadShadowMeshes(game, pname, b->Body);
+ else
+ b->Shadow = nullptr;
+//sb
+ return b;
+}
+
+/* -----------------25/09/98 16.07-------------------
+ * GetFullLightPosition
+ * --------------------------------------------------*/
+uint8 GetFullLightDirection(t3dV3F *dest, uint8 pos) {
+ uint8 a;
+
+ if (!pos) return 0;
+
+ auto pLights = t3dCurRoom->getPositionalLight(pos);
+ for (auto light: pLights) {
+ if (light.Dir.x && light.Dir.z) {
+ *dest = light.Dir;
+ return pos;
+ }
+ }
+
+ if (pos != 99)
+ DebugLogFile("Can't find fldir %d in %s", pos, t3dCurRoom->name.c_str());
+ return 0;
+}
+
+/* -----------------21/12/98 16.40-------------------
+ * ReleasePreloadedAnims
+ * --------------------------------------------------*/
+void ReleasePreloadedAnims() {
+ int32 i, j;
+
+ for (j = 0; j < MAX_PRELOADED_ANIMS; j++) {
+// Disalloca tutto
+ for (i = 0; i < MAX_BONES; i++) {
+ t3dFree(PreloadedAnim[j].Bone[i].Trasl);
+ t3dFree(PreloadedAnim[j].Bone[i].Euler);
+ }
+ t3dFree(PreloadedAnim[j].Dist);
+ memset(&PreloadedAnim[j], 0, sizeof(t3dLOADANIM));
+ }
+}
+
+/* -----------------02/05/00 9.30--------------------
+ * CompareLightPosition
+ * --------------------------------------------------*/
+uint8 CompareLightPosition(char *roomname, uint8 pos1, t3dV3F *pos2, t3dF32 acceptable_dist) {
+ t3dV3F p1;
+ uint8 a;
+ t3dBODY *t;
+ int32 i;
+
+ if ((pos1 <= 0) || (pos2 == nullptr)) return FALSE;
+
+// cerco la stanza
+ t = nullptr;
+ if (roomname && (roomname[0] != '\0')) {
+ for (i = 0; i < NumLoadedFiles; i++)
+ if ((LoadedFiles[i].b != nullptr) && LoadedFiles[i].b->name.equalsIgnoreCase(roomname))
+ t = LoadedFiles[i].b;
+ } else t = t3dCurRoom;
+
+ if (!t) return FALSE;
+
+ auto pLights = t->getPositionalLight(pos1);
+ bool foundLight = false;
+ for (auto light: pLights) {
+ if (light.Pos.x && light.Pos.z) {
+ p1.x = light.Pos.x;
+ p1.y = light.Pos.y;
+ p1.z = light.Pos.z;
+ foundLight = true;
+ break;
+ }
+ }
+ if (!foundLight) return FALSE;
+
+ if (t3dVectSquaredDistance(&p1, pos2) <= acceptable_dist) return TRUE;
+
+ return FALSE;
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/animation.h b/engines/watchmaker/3d/animation.h
new file mode 100644
index 00000000000..4ee1af4973b
--- /dev/null
+++ b/engines/watchmaker/3d/animation.h
@@ -0,0 +1,44 @@
+/* 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 WATCHMAKER_ANIMATION_H
+#define WATCHMAKER_ANIMATION_H
+
+#include "watchmaker/t3d.h"
+#include "watchmaker/3d/t3d_body.h"
+#include "watchmaker/work_dirs.h"
+
+namespace Watchmaker {
+
+uint8 GetLightDirection(t3dV3F *dest, uint8 pos);
+unsigned char GetLightPosition(t3dV3F *dest, unsigned char pos);
+uint8 GetFullLightDirection(t3dV3F *dest, uint8 pos);
+
+void FixupAnim(t3dMESH *mesh, unsigned char pos, const char *room);
+t3dBODY *LoadShadowMeshes(WGame &game, const char *pname, t3dBODY *Body);
+int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag);
+t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, t3dCHARACTER *b, uint16 num);
+void ReleasePreloadedAnims();
+uint8 CompareLightPosition(char *roomname, uint8 pos1, t3dV3F *pos2, t3dF32 acceptable_dist);
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_ANIMATION_H
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
new file mode 100644
index 00000000000..370290e7e16
--- /dev/null
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -0,0 +1,3512 @@
+/* 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 "watchmaker/t3d.h"
+#include "watchmaker/3d/geometry.h"
+#include "watchmaker/3d/light.h"
+#include "watchmaker/3d/mem_management.h"
+#include "watchmaker/3d/math/llmath.h"
+#include "watchmaker/3d/t3d_body.h"
+#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/ll/ll_system.h"
+#include "watchmaker/render.h"
+#include "watchmaker/utils.h"
+#include "watchmaker/3d/loader.h"
+#include "watchmaker/windows_hacks.h"
+#include "watchmaker/globvar.h"
+#include "watchmaker/renderer.h"
+
+#define SKY_SPEED 0.00005f
+#define EXPRESSION_SET_LEN 14
+
+namespace Watchmaker {
+
+t3dCAMERA Camera;
+t3dCAMERA *t3dCurCamera = &Camera;
+t3dBODY *t3dCurRoom, *t3dOrigRoom;
+t3dBODY *PortalCrossed = nullptr;
+t3dCHARACTER *t3dCurCharacter;
+
+t3dM3X3F t3dCurViewMatrix;
+t3dV3F t3dCurTranslation;
+int16 t3dCurUserViewMatrix, t3dOldUserViewMatrix, t3dOrigUserViewMatrix;
+
+uint32 t3dStartIndex, t3dNumVertices;
+
+uint8 FloorHit;
+t3dV3F FloorHitCoords;
+
+t3dV3F t3d3dMousePos;
+
+t3dBODY *t3dRxt = nullptr;
+t3dBODY *t3dSky = nullptr;
+//s t3dBODY *t3dSun= nullptr;
+
+uint32 t3d_NumMeshesVisible;
+t3dMESH *t3d_VisibleMeshes[255];
+
+#define LEFTCLIP 0
+#define RIGHTCLIP 1
+#define TOPCLIP 2
+#define BOTTOMCLIP 3
+#define NUMCLIPPLANES 4
+
+t3dNORMAL ClipPlanes[NUMCLIPPLANES];
+
+t3dMESH *t3dPortalList[MAX_RECURSION_LEVEL];
+uint32 t3dNumPortals;
+uint8 bOrigRoom;
+uint8 bPortalRoom;
+uint8 bViewOnlyPortal;
+uint8 bDisableMirrors;
+uint8 bNoLightmapsCalc;
+uint8 LastFlaresVisible;
+t3dMESH *t3dGlobalMirrorList[MAX_MIRRORS];
+uint32 t3dNumGlobalMirrors;
+
+uint32 StatNumTris, StatNumVerts;
+
+int32 MaxSetDimX, MaxSetDimY;
+
+uint32 skyval1, skyval2;
+gTexture *SkySurface;
+gTexture *SmokeSurface, *NoiseSmokeSurface;
+
+#define T3D_PARTICLE_ACTIVE (1<<0)
+#define T3D_PARTICLE_REGEN (1<<1)
+
+struct Particle {
+ t3dV3F Pos;
+ t3dF32 Size;
+ uint32 Flags;
+ t3dV3F Color;
+};
+
+struct _PARTICLESTRUCT {
+ Particle *ParticlePos;
+ uint32 NumParticles;
+ uint32 FirstParticleRendered;
+ gMaterial Material;
+ int8 RandTable[16];
+ uint8 ParticleWait;
+} Particles[MAX_PARTICLES];
+uint32 t3dNumParticles = 0;
+
+#define MAX_MATERIAL_LISTS 50
+
+struct _MaterialList {
+ MaterialTable *mat_list; // This is brittle, as there is no ownership flagging.
+ unsigned int num_mat;
+ signed short int matrix;
+} t3dMaterialList[MAX_MATERIAL_LISTS];
+
+uint32 t3dNumMaterialLists = 0;
+
+/* -----------------10/06/99 15.45-------------------
+ * t3dCheckBoundSphere
+ * --------------------------------------------------*/
+uint8 t3dCheckBoundSphere(t3dMESH &mesh) {
+ t3dV3F pos;
+ t3dF32 d1;
+
+ if (mesh.Flags & T3D_MESH_ALWAYSVISIBLE)
+ return 1;
+
+ t3dVectAdd(&pos, &mesh.Pos, &mesh.Trasl);
+ t3dVectSub(&pos, &pos, &t3dCurCamera->Source);
+ t3dVectTransform(&pos, &pos, &t3dCurViewMatrix); // rotate by the mesh matrix
+
+ if ((pos.z < 0) && (pos.z < -mesh.Radius))
+ return 0;
+
+ d1 = t3dVectDot(&pos, &ClipPlanes[RIGHTCLIP].n) + ClipPlanes[RIGHTCLIP].dist;
+ if ((d1 > 0) || (mesh.Radius > (-d1))) {
+ d1 = ClipPlanes[LEFTCLIP].dist + t3dVectDot(&pos, &ClipPlanes[LEFTCLIP].n);
+ if ((d1 > 0) || (mesh.Radius > (-d1))) {
+ d1 = ClipPlanes[TOPCLIP].dist + t3dVectDot(&pos, &ClipPlanes[TOPCLIP].n);
+ if ((d1 > 0) || (mesh.Radius > (-d1))) {
+ d1 = ClipPlanes[BOTTOMCLIP].dist + t3dVectDot(&pos, &ClipPlanes[BOTTOMCLIP].n);
+ if ((d1 > 0) || (mesh.Radius > (-d1))) {
+ return 1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+
+/* -----------------10/06/99 15.45-------------------
+ * t3dCheckBoundBox
+ * --------------------------------------------------*/
+uint8 t3dCheckBoundBox(t3dMESH &mesh) {
+ t3dV3F TBBox[8], inter;
+ t3dF32 d1;
+ uint32 in = 0, i;
+
+ if (mesh.Flags & T3D_MESH_ALWAYSVISIBLE)
+ return 1;
+
+ for (i = 0; i < 8; i++) {
+ t3dVectAdd(&TBBox[i], &mesh.BBox[i].p, &mesh.Trasl);
+ t3dVectSub(&TBBox[i], &TBBox[i], &t3dCurCamera->Source);
+ t3dVectTransform(&TBBox[i], &TBBox[i], &t3dCurViewMatrix); // rotate by the mesh matrix
+ }
+
+ for (i = 0; i < 8; i++)
+ if ((d1 = t3dVectDot(&TBBox[i], &ClipPlanes[RIGHTCLIP].n) + ClipPlanes[RIGHTCLIP].dist) > 0)
+ if ((d1 = ClipPlanes[LEFTCLIP].dist + t3dVectDot(&TBBox[i], &ClipPlanes[LEFTCLIP].n)) > 0)
+ if ((d1 = ClipPlanes[TOPCLIP].dist + t3dVectDot(&TBBox[i], &ClipPlanes[TOPCLIP].n)) > 0)
+ if ((d1 = ClipPlanes[BOTTOMCLIP].dist + t3dVectDot(&TBBox[i], &ClipPlanes[BOTTOMCLIP].n)) > 0)
+ in++;
+
+ if (in) return 1;
+
+ for (i = 0; i < NUMCLIPPLANES; i++) {
+ if (t3dVectPlaneIntersection(&inter, TBBox[0], TBBox[1], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[1], TBBox[5], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[5], TBBox[4], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[4], TBBox[0], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[2], TBBox[3], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[3], TBBox[7], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[7], TBBox[6], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[6], TBBox[2], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[0], TBBox[2], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[1], TBBox[3], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[5], TBBox[7], ClipPlanes[i])) return 1;
+ if (t3dVectPlaneIntersection(&inter, TBBox[4], TBBox[6], ClipPlanes[i])) return 1;
+ }
+
+ return 0;
+}
+
+/* -----------------11/06/99 12.23-------------------
+ * t3dCheckBlockMesh
+ * --------------------------------------------------*/
+void t3dCheckBlockMesh(Common::Array<t3dMESH> &mt, uint32 NumMeshes, t3dMESH *blockmesh) {
+ t3dF32 xa, za, xb, zb, xc, zc, xd, zd;
+ t3dF32 r, s, divisor;
+ t3dMESH *mesh;
+
+ uint32 i, j;
+ uint8 ref[4] = {2, 3, 6, 7};
+
+ if (!blockmesh || mt.empty() || !blockmesh->VertexBuffer) return;
+
+ xc = t3dCurCamera->Source.x;
+ zc = t3dCurCamera->Source.z;
+
+ xa = za = 9999999.9f;
+ xb = zb = -9999999.9f;
+ blockmesh->VBptr = blockmesh->VertexBuffer;
+ for (uint32 j = 0; j < blockmesh->NumFaces(); j++) {
+ t3dFACE &f = blockmesh->FList[j];
+ if (!f.n) continue;
+
+ for (i = 0; i < 3; i++) {
+ if (blockmesh->VBptr[f.VertexIndex[i]].x < xa) {
+ xa = blockmesh->VBptr[f.VertexIndex[i]].x;
+ za = blockmesh->VBptr[f.VertexIndex[i]].z;
+ }
+ if (blockmesh->VBptr[f.VertexIndex[i]].x > xb) {
+ xb = blockmesh->VBptr[f.VertexIndex[i]].x;
+ zb = blockmesh->VBptr[f.VertexIndex[i]].z;
+ }
+ }
+ }
+ blockmesh->VBptr = nullptr;
+
+ for (i = 0; i < NumMeshes; i++) {
+ t3dMESH &mesh = mt[i];
+ if ((mesh.Flags & T3D_MESH_HIDDEN) || (mesh.Flags & T3D_MESH_INVISIBLEFROMSECT))
+ continue;
+
+ for (j = 0; j < 4; j++) {
+ xd = mesh.Trasl.x + mesh.BBox[ref[j]].p.x;
+ zd = mesh.Trasl.z + mesh.BBox[ref[j]].p.z;
+
+ divisor = (t3dF32)((xb - xa) * (zd - zc) - (zb - za) * (xd - xc));
+ if (!divisor) divisor = 0.000001f;
+ r = (t3dF32)((za - zc) * (xd - xc) - (xa - xc) * (zd - zc)) / divisor;
+ s = (t3dF32)((za - zc) * (xb - xa) - (xa - xc) * (zb - za)) / divisor;
+
+ if ((r < 0.0f) || (r > (1.0f)) || (s < 0.0f) || (s > (1.0f)))
+ break;
+ }
+ if (j >= 4) mesh.Flags |= T3D_MESH_INVISIBLEFROMSECT;
+ }
+}
+
+
+/* -----------------10/06/99 15.53-------------------
+ * t3dCalcRejectedMeshFromPortal
+ * --------------------------------------------------*/
+void t3dCalcRejectedMeshFromPortal(t3dBODY *body) {
+ t3dV3F appo, c0;
+ t3dV3F ppv1, ppv2, ppv3, ppv4, Source, Target;
+ uint32 p;
+ t3dNORMAL OldClipPlanes[NUMCLIPPLANES];
+ t3dF32 minx, miny, minz, maxx, maxy, maxz;
+
+ for (uint32 i = 0; i < body->NumMeshes(); i++) {
+ t3dMESH &mesh = body->MeshTable[i];
+ if ((mesh.Flags & T3D_MESH_PREPROCESSPORTAL) && (!(mesh.Flags & T3D_MESH_NOPORTALCHECK)) &&
+ (mesh.PortalList) && (mesh.RejectedMeshes.empty())) {
+ mesh.VBptr = mesh.VertexBuffer;
+ ppv1.x = mesh.VBptr[mesh.FList[0].VertexIndex[0]].x;
+ ppv1.y = mesh.VBptr[mesh.FList[0].VertexIndex[0]].y;
+ ppv1.z = mesh.VBptr[mesh.FList[0].VertexIndex[0]].z;
+ ppv2.x = mesh.VBptr[mesh.FList[0].VertexIndex[1]].x;
+ ppv2.y = mesh.VBptr[mesh.FList[0].VertexIndex[1]].y;
+ ppv2.z = mesh.VBptr[mesh.FList[0].VertexIndex[1]].z;
+ ppv3.x = mesh.VBptr[mesh.FList[0].VertexIndex[2]].x;
+ ppv3.y = mesh.VBptr[mesh.FList[0].VertexIndex[2]].y;
+ ppv3.z = mesh.VBptr[mesh.FList[0].VertexIndex[2]].z;
+
+ for (p = 0; p < 3; p++) {
+ appo.x = mesh.VBptr[mesh.FList[1].VertexIndex[p]].x;
+ appo.y = mesh.VBptr[mesh.FList[1].VertexIndex[p]].y;
+ appo.z = mesh.VBptr[mesh.FList[1].VertexIndex[p]].z;
+
+ if ((ppv1 != appo) && (ppv2 != appo) && (ppv3 != appo))
+ memcpy(&ppv4, &appo, sizeof(t3dV3F));
+ }
+
+ memcpy(OldClipPlanes, ClipPlanes, sizeof(t3dNORMAL)*NUMCLIPPLANES);
+
+ minx = miny = minz = 9999999.9f;
+ maxx = maxy = maxz = -9999999.9f;
+ if (ppv1.x < minx) minx = ppv1.x;
+ if (ppv1.y < miny) miny = ppv1.y;
+ if (ppv1.z < minz) minz = ppv1.z;
+ if (ppv1.x > maxx) maxx = ppv1.x;
+ if (ppv1.y > maxy) maxy = ppv1.y;
+ if (ppv1.z > maxz) maxz = ppv1.z;
+
+ if (ppv2.x < minx) minx = ppv2.x;
+ if (ppv2.y < miny) miny = ppv2.y;
+ if (ppv2.z < minz) minz = ppv2.z;
+ if (ppv2.x > maxx) maxx = ppv2.x;
+ if (ppv2.y > maxy) maxy = ppv2.y;
+ if (ppv2.z > maxz) maxz = ppv2.z;
+
+ if (ppv3.x < minx) minx = ppv3.x;
+ if (ppv3.y < miny) miny = ppv3.y;
+ if (ppv3.z < minz) minz = ppv3.z;
+ if (ppv3.x > maxx) maxx = ppv3.x;
+ if (ppv3.y > maxy) maxy = ppv3.y;
+ if (ppv3.z > maxz) maxz = ppv3.z;
+
+ if (ppv4.x < minx) minx = ppv4.x;
+ if (ppv4.y < miny) miny = ppv4.y;
+ if (ppv4.z < minz) minz = ppv4.z;
+ if (ppv4.x > maxx) maxx = ppv4.x;
+ if (ppv4.y > maxy) maxy = ppv4.y;
+ if (ppv4.z > maxz) maxz = ppv4.z;
+
+ Source.x = minx + ((maxx - minx) / 2.0f) + mesh.NList[0]->n.x * 100;
+ Source.y = miny + ((maxy - miny) / 2.0f) + mesh.NList[0]->n.y * 100;
+ Source.z = minz + ((maxz - minz) / 2.0f) + mesh.NList[0]->n.z * 100;
+ Target.x = minx + ((maxx - minx) / 2.0f);
+ Target.y = miny + ((maxy - miny) / 2.0f);
+ Target.z = minz + ((maxz - minz) / 2.0f);
+
+ t3dMatView(&t3dCurViewMatrix, &Source, &Target);
+
+
+ t3dVectSub(&ppv4, &ppv4, &Source);
+ t3dVectSub(&ppv3, &ppv3, &Source);
+ t3dVectSub(&ppv2, &ppv2, &Source);
+ t3dVectSub(&ppv1, &ppv1, &Source);
+ t3dVectTransform(&ppv1, &ppv1, &t3dCurViewMatrix);
+ t3dVectTransform(&ppv2, &ppv2, &t3dCurViewMatrix);
+ t3dVectTransform(&ppv3, &ppv3, &t3dCurViewMatrix);
+ t3dVectTransform(&ppv4, &ppv4, &t3dCurViewMatrix);
+ t3dVectFill(&c0, 0.0f);
+
+ // t3dVectCopy(&c0,&cam->Source);
+
+ t3dPlaneNormal(&ClipPlanes[RIGHTCLIP], &c0, &ppv3, &ppv4);
+ t3dPlaneNormal(&ClipPlanes[LEFTCLIP], &c0, &ppv1, &ppv2);
+ t3dPlaneNormal(&ClipPlanes[TOPCLIP], &c0, &ppv4, &ppv1);
+ t3dPlaneNormal(&ClipPlanes[BOTTOMCLIP], &c0, &ppv2, &ppv3);
+
+ mesh.VBptr = nullptr;
+
+ t3dVectCopy(&t3dCurCamera->Source, &Source);
+ t3dVectCopy(&t3dCurCamera->Target, &Target);
+
+ for (uint32 j = 0; j < mesh.PortalList->NumMeshes(); j++) {
+ t3dMESH *m = &mesh.PortalList->MeshTable[j];
+ if (!t3dCheckBoundSphere(*m)) {
+ mesh.RejectedMeshes.push_back(m);
+ }
+ }
+ }
+ }
+}
+
+/* -----------------10/06/99 15.39-------------------
+ * t3dReleaseBody
+ * --------------------------------------------------*/
+void t3dReleaseBody(t3dBODY *b) {
+ uint16 i;
+
+ if (!b) return;
+
+ for (auto &mesh : b->MeshTable) {
+ mesh.release();
+ }
+ b->MeshTable.clear();
+
+ if (!b->MatTable.empty())
+ rRemoveMaterials(b->MatTable);
+ b->MatTable.clear();
+
+ if (b->LightmapTable.size() > 0)
+ rRemoveMaterials(b->LightmapTable);
+ b->LightmapTable.clear();
+
+ if (b->MirrorMatTable.size() > 0) {
+ for (i = 0; i < b->NumMirrorMaterials(); i++)
+ b->MirrorMatTable[i]->Movie = nullptr;
+ rRemoveMaterials(b->MirrorMatTable);
+ }
+ b->MirrorMatTable.clear();
+
+
+ b->clearVBTable();
+
+ for (int i = 0; i < T3D_MAX_LEVELS; i++) {
+ t3dFree(b->Panel[i]);
+ b->Panel[i] = nullptr;
+ }
+
+ // Not at all necessary
+ b->CameraGrid.Grid.clear();
+ b->CameraPath.clear();
+ b->CameraTable.clear();
+ b->LightTable.clear();
+ b->PosLightTable.clear();
+ b->NList.clear();
+ b->VolumetricLights.reset();
+ for (int i = 0; i < T3D_MAX_BLOCK_MESHES; i++)
+ b->BlockMeshes[i] = nullptr;
+ t3dFree(b);
+}
+
+
+/* -----------------10/06/99 15.40-------------------
+ * t3dReleaseCharacter
+ * --------------------------------------------------*/
+void t3dReleaseCharacter(t3dCHARACTER *b) {
+ warning("STUBBED: t3dReleaseCharacter\n");
+#if 0
+ t3dU32 i, j;
+
+ if (!b)
+ return;
+
+// if ( b->Body )
+// t3dReleaseBody(b->Body);
+ b->Body = nullptr;
+
+ if (b->Shadow) {
+ for (i = 0; i < b->Shadow->NumMeshes; i++)
+ b->Shadow->MeshTable[i].VertexBuffer = nullptr;
+//m t3dReleaseBody(b->Shadow);
+ }
+ b->Shadow = nullptr;
+
+ for (i = 0; i < T3D_MAX_SHADOWBOX_PER_CHAR; i++) {
+ if (b->ShadowBox[i]) {
+ for (j = 0; j < MAX_SHADOWS_PER_LIGHT; j++) {
+ rDeleteVertexBuffer(b->ShadowBox[i]->ShadowsList[j].VB);
+ b->ShadowBox[i]->ShadowsList[j].VB = nullptr;
+ rDeleteVertexBuffer(b->ShadowBox[i]->ShadowsList[j].ProjVertsVB);
+ b->ShadowBox[i]->ShadowsList[j].ProjVertsVB = nullptr;
+
+ if (b->ShadowBox[i]->ShadowsList[j].pwShadVolIndices != b->ShadowBox[i]->ShadowsList[j].pwShadVolSideIndices)
+ t3dFree(b->ShadowBox[i]->ShadowsList[j].pwShadVolIndices);
+ b->ShadowBox[i]->ShadowsList[j].pwShadVolIndices = nullptr;
+ t3dFree(b->ShadowBox[i]->ShadowsList[j].pwShadVolSideIndices);
+ b->ShadowBox[i]->ShadowsList[j].pwShadVolSideIndices = nullptr;
+
+ t3dFree(b->ShadowBox[i]->ShadowsList[j].pwShadVolCapIndices);
+ b->ShadowBox[i]->ShadowsList[j].pwShadVolCapIndices = nullptr;
+ }
+ rDeleteVertexBuffer(b->ShadowBox[i]->VB);
+ b->ShadowBox[i]->VB = nullptr;
+ t3dFree(b->ShadowBox[i]->pwIndices);
+ b->ShadowBox[i]->pwIndices = nullptr;
+ t3dFree(b->ShadowBox[i]);
+ b->ShadowBox[i] = nullptr;
+ }
+ }
+
+ t3dFree(b);
+ b = nullptr;
+#endif
+}
+
+/* -----------------10/06/99 15.40-------------------
+ * t3dBackfaceCulling
+ * --------------------------------------------------*/
+uint16 t3dBackfaceCulling(NormalList &normals, uint32 NumNormals, t3dV3F *eye) {
+ uint32 NumVisiNorm = 0;
+ // Attiva solo le normali che si vedono
+ for (uint32 i = 0; i < NumNormals; i++) {
+ auto n = normals[i];
+ n->tras_n = n->dist - t3dVectDot(&n->n, eye);
+ if (n->tras_n > 0)
+ n->flag = T3D_NORMAL_INVISIBLE;
+ else
+ n->flag = T3D_NORMAL_VISIBLE;
+ }
+
+ return NumVisiNorm;
+}
+
+/* -----------------10/06/99 15.50-------------------
+ * t3dCalc2dTo3dPos
+ * --------------------------------------------------*/
+void t3dCalc2dTo3dPos(t3dV3F *pos, t3dF32 posx, t3dF32 posy) {
+ rScreenSpaceToCameraSpace(&pos->x, &pos->y, &pos->z, posx, posy);
+}
+
+/* -----------------10/06/99 15.41-------------------
+ * t3dSetViewport
+ * --------------------------------------------------*/
+void t3dSetViewport(t3dCAMERA *cam, uint32 cx, uint32 cy, uint32 sx, uint32 sy, t3dF32 fov, uint8 sup) {
+ t3dV3F v1, v2, v3, v4, c0;
+ t3dF32 SuperView = 50.0f * (sup ^ 1);
+ t3dF32 fx = (t3dF32)sx, fy = (t3dF32)sy, asp;
+ asp = (fy * fy) / (fx * fx);
+
+// fov=((fov/2.0f)/180.0f)*T3D_PI;
+
+// cam->Focus=90;
+// cam->Factor.x = ((fx/2.0f) / (t3dF32)tan(fov));
+// cam->Factor.y = -( cam->Factor.x * asp);
+
+
+ cam->Center.x = (t3dF32)(cx);
+ cam->Center.y = (t3dF32)(cy);
+
+
+
+ cam->NearClipPlane = fov;
+ cam->FarClipPlane = 89000.0f;
+ rSetProjectionMatrix((float)(sx),
+ (float)(sy),
+ fov,
+ 10.0f + SuperView, 90000.0f);
+
+ //Set Clipplanes
+ t3dVectFill(&c0, 0.0f);
+ t3dCalc2dTo3dPos(&v1, 0.0f, 0.0f);
+ t3dCalc2dTo3dPos(&v2, (t3dF32)sx, 0.0f);
+ t3dCalc2dTo3dPos(&v3, 0.0f, (t3dF32)sy);
+ t3dCalc2dTo3dPos(&v4, (t3dF32)sx, (t3dF32)sy);
+
+ t3dPlaneNormal(&ClipPlanes[LEFTCLIP], &c0, &v1, &v3);
+ t3dPlaneNormal(&ClipPlanes[RIGHTCLIP], &c0, &v4, &v2);
+ t3dPlaneNormal(&ClipPlanes[TOPCLIP], &c0, &v2, &v1);
+ t3dPlaneNormal(&ClipPlanes[BOTTOMCLIP], &c0, &v3, &v4);
+
+}
+
+void t3dSetViewport(t3dCAMERA *cam, WindowInfo &info, t3dF32 fov, uint8 sup) {
+ t3dSetViewport(t3dCurCamera, info.width / 2, info.height / 2, info.width, info.height, fov, sup);
+}
+
+/* -----------------10/06/99 15.55-------------------
+ * ssqrt
+ * --------------------------------------------------*/
+inline long ssqrt(long i) {
+ error("TODO: ssqrt");
+#if 0
+ long r = rand(), rnew = 1, rold = r;
+
+ do {
+ rold = r;
+ r = rnew;
+ rnew = (r + (i / r));
+ rnew >>= 1;
+ } while (rold != rnew);
+ return rnew;
+#endif
+}
+
+/* -----------------10/06/99 15.55-------------------
+ * isprime
+ * --------------------------------------------------*/
+inline int isprime(long i) {
+ long si, j;
+
+ if (i == 0)
+ return 0;
+
+ si = ssqrt(i);
+
+ for (j = 2; (j <= si); j++) {
+ if (i % j == 0)
+ return 0;
+ }
+
+ return 1;
+
+}
+
+/* -----------------10/06/99 15.55-------------------
+ * Cosine_Interpolate
+ * --------------------------------------------------*/
+t3dF32 Cosine_Interpolate(t3dF32 a, t3dF32 b, t3dF32 x) {
+ t3dF32 ft = x * T3D_PI;
+ t3dF32 f = (1.0f - (t3dF32)cos(ft)) * 0.5f;
+ return a * (1.0f - f) + b * f;
+
+//return a*(1.0f-x) + b*x;
+}
+
+/* -----------------10/06/99 15.55-------------------
+ * SelectRandomNumbers
+ * --------------------------------------------------*/
+void SelectRandomNumbers(void) {
+ error("TODO: SelectRandomNumbers");
+#if 0
+ while (!isprime(skyval1 = (uint32)rand() % 100));
+ while (!isprime(skyval2 = (uint32)(skyval1 - rand() % 100) % 15));
+#endif
+}
+
+/* -----------------10/06/99 15.56-------------------
+ * Noise1
+ * --------------------------------------------------*/
+t3dF32 Noise1(int32 x, int32 y) {
+ int32 n;
+ t3dF32 f;
+
+ /* n = x + y * 57;
+ n = (n<<13)^n;
+ f=(t3dF32)((n * (n * n * 15731 + 789221) + 1 376 312 589) & 0x7fffffff);
+ return ( 1.0f - f / 1 073 741 824.0f);
+ */
+ skyval1 = 13;
+ skyval2 = 131;
+ n = x + y * skyval1;
+ n = (n << skyval2)^n;
+ f = (t3dF32)((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
+ return (1.0f - f / 1073741824.0f);
+// f=(t3dF32)((n * (n * n * skyval3 + skyval4) + skyval5) & 0x7fffffff);
+ //return ( 1.0f - f / (t3dF32)skyval6);
+}
+
+/* -----------------10/06/99 15.56-------------------
+ * SmoothNoise_1
+ * --------------------------------------------------*/
+t3dF32 SmoothNoise_1(int32 x, int32 y) {
+ t3dF32 corners = (Noise1(x - 1, y - 1) + Noise1(x + 1, y - 1) + Noise1(x - 1, y + 1) + Noise1(x + 1, y + 1)) / 16;
+ t3dF32 sides = (Noise1(x - 1, y) + Noise1(x + 1, y) + Noise1(x, y - 1) + Noise1(x, y + 1)) / 8;
+ t3dF32 center = Noise1(x, y) / 4;
+ return corners + sides + center;
+
+// return ((Noise1(x-1, y-1)+Noise1(x+1, y-1)+Noise1(x-1, y+1)+Noise1(x+1, y+1))+( Noise1(x-1, y) +Noise1(x+1, y) +Noise1(x, y-1) +Noise1(x, y+1) )+Noise1(x, y))/9.0f;
+}
+
+/* -----------------10/06/99 15.56-------------------
+ * InterpolatedNoise_1
+ * --------------------------------------------------*/
+t3dF32 InterpolatedNoise_1(t3dF32 x, t3dF32 y) {
+ int32 integer_X = (int32)(x);
+ t3dF32 fractional_X = x - (t3dF32)integer_X;
+
+ int32 integer_Y = (int32)(y);
+ t3dF32 fractional_Y = y - (t3dF32)integer_Y;
+
+ t3dF32 v1 = SmoothNoise_1(integer_X, integer_Y);
+ t3dF32 v2 = SmoothNoise_1(integer_X + 1, integer_Y);
+ t3dF32 v3 = SmoothNoise_1(integer_X, integer_Y + 1);
+ t3dF32 v4 = SmoothNoise_1(integer_X + 1, integer_Y + 1);
+
+ t3dF32 i1 = Cosine_Interpolate(v1, v2, fractional_X);
+ t3dF32 i2 = Cosine_Interpolate(v3, v4, fractional_X);
+
+ return Cosine_Interpolate(i1, i2, fractional_Y);
+}
+
+/* -----------------10/06/99 15.56-------------------
+ * CloudExpCurve
+ * --------------------------------------------------*/
+t3dF32 CloudExpCurve(t3dF32 v, t3dF32 CloudCover, t3dF32 CloudSharpness) {
+ t3dF32 c = v - CloudCover;
+ if (c < 0.0f)
+ c = 0;
+
+ return (255 - ((t3dF32)pow(CloudSharpness, c) * 255));
+}
+
+/* -----------------10/06/99 15.57-------------------
+ * PerlinNoise_2D
+ * --------------------------------------------------*/
+t3dF32 PerlinNoise_2D(t3dF32 x, t3dF32 y, t3dF32 persistence, uint32 NumberOfOctaves) {
+ uint32 i;
+ t3dF32 total = 0.0f;
+ t3dF32 frequency;
+ t3dF32 amplitude = 1;
+
+ for (i = 0; i < NumberOfOctaves; i++) {
+ frequency = /*1.0f*/(t3dF32)pow(2, i);
+ amplitude = /*1.0f*/((t3dF32)pow(persistence, i));
+
+ total += InterpolatedNoise_1((x * frequency), (y * frequency)) * amplitude;
+ }
+// DebugFile("perl: %f",(total));
+ return total;
+}
+
+/* -----------------10/06/99 15.57-------------------
+ * t3dCreateProceduralSky
+ * --------------------------------------------------*/
+void t3dCreateProceduralSky(void) {
+ unsigned short *p;
+ int32 i, j, pitch;
+ t3dF32 f, x, y, xstep, ystep;
+ uint32 cr, cb, cg;
+ t3dF32 CloudCover[4] = { 2.0f, 5.0f, 2.0f, 1.0f };
+ t3dF32 CloudSharpness[4] = { 0.98f, 0.95f, 0.98f, 0.98f };
+ t3dF32 CloudR[4] = { 143.0f, 131.0f, 145.0f, 45.0f };
+ t3dF32 CloudG[4] = { 155.0f, 129.0f, 130.0f, 49.0f };
+ t3dF32 CloudB[4] = { 174.0f, 100.0f, 148.0f, 50.0f };
+ uint32 Refr[4] = {88, 110, 110, 36 };
+ uint32 Refg[4] = {106, 150, 106, 35 };
+ uint32 Refb[4] = {164, 240, 134, 42 };
+ uint8 *tab;
+ uint32 MARGIN;
+
+ if (t3dSky == nullptr) return;
+ if ((t3dCurOliSet < 0) || (t3dCurOliSet > 3)) t3dCurOliSet = 0;
+
+ //set a random seed
+ error("TODO:t3dCreateProceduralSky");
+#if 0
+ srand((unsigned)t3dReadTime());
+ SelectRandomNumbers();
+#endif
+ MaxSetDimX = MaxSetDimY = 256;
+ MARGIN = MaxSetDimX / 2;
+ tab = (uint8 *)t3dMalloc(MaxSetDimX * MaxSetDimY * 3);
+
+ if (!SkySurface) // rReleaseBitmapDirect( SkySurface );
+ SkySurface = (gTexture *)rCreateSurface(256, 256, rTEXTURESURFACE);
+
+ p = (unsigned short *)rLockSurfaceDirect(SkySurface, (unsigned int *)&pitch);
+ pitch /= 2;
+
+ x = y = 0;
+ ystep = xstep = (1.0f / (256.0f));
+ for (j = 0; j < MaxSetDimY; j++, y += ystep) {
+ x = 0.0f;
+ for (i = 0; i < MaxSetDimX; i++, x += xstep) {
+ f = (PerlinNoise_2D(x * 2.0f, y * 4.0f, 0.65f, 8));
+ if (f < 0.0f)
+ f = -f;
+
+ cr = (uint32)CloudExpCurve(f * CloudR[t3dCurOliSet], CloudCover[t3dCurOliSet], CloudSharpness[t3dCurOliSet]);
+ cg = (uint32)CloudExpCurve(f * CloudG[t3dCurOliSet], CloudCover[t3dCurOliSet], CloudSharpness[t3dCurOliSet]);
+ cb = (uint32)CloudExpCurve(f * CloudB[t3dCurOliSet], CloudCover[t3dCurOliSet], CloudSharpness[t3dCurOliSet]);
+
+ if (cr < Refr[t3dCurOliSet]) {
+ cr += Refr[t3dCurOliSet];
+ cr /= 2;
+ }
+ if (cg < Refg[t3dCurOliSet]) {
+ cg += Refg[t3dCurOliSet];
+ cg /= 2;
+ }
+ if (cb < Refb[t3dCurOliSet]) {
+ cb += Refb[t3dCurOliSet];
+ cb /= 2;
+ }
+ if (cr > 255)
+ cr = 255 - (cr - 255);
+ if (cg > 255)
+ cg = 255 - (cg - 255);
+ if (cb > 255)
+ cb = 255 - (cb - 255);
+
+ if (cr > 255)
+ cr = 255;
+ if (cg > 255)
+ cg = 255;
+ if (cb > 255)
+ cb = 255;
+
+ tab[i * 3 + 0 + j * 3 * MaxSetDimX] = cr;
+ tab[i * 3 + 1 + j * 3 * MaxSetDimX] = cg;
+ tab[i * 3 + 2 + j * 3 * MaxSetDimX] = cb;
+ }
+ }
+
+ ystep = 1.0f / MARGIN;
+ y = 1.0f;
+ for (j = 0; j < (int32)MARGIN; j++, y -= ystep) {
+ for (i = 0; i < MaxSetDimX; i++) {
+ cr = (uint32)Cosine_Interpolate(tab[i * 3 + 0 + j * 3 * MaxSetDimX], tab[i * 3 + 0 + (255 - j) * 3 * MaxSetDimX], y);
+ cg = (uint32)Cosine_Interpolate(tab[i * 3 + 1 + j * 3 * MaxSetDimX], tab[i * 3 + 1 + (255 - j) * 3 * MaxSetDimX], y);
+ cb = (uint32)Cosine_Interpolate(tab[i * 3 + 2 + j * 3 * MaxSetDimX], tab[i * 3 + 2 + (255 - j) * 3 * MaxSetDimX], y);
+ if (cr > 255)
+ cr = 255;
+ if (cg > 255)
+ cg = 255;
+ if (cb > 255)
+ cb = 255;
+ tab[i * 3 + 0 + j * 3 * MaxSetDimX] = cr;
+ tab[i * 3 + 1 + j * 3 * MaxSetDimX] = cg;
+ tab[i * 3 + 2 + j * 3 * MaxSetDimX] = cb;
+ }
+ }
+ xstep = 1.0f / MARGIN;
+ x = 1.0f;
+ for (j = 0; j < MaxSetDimY; j++) {
+ x = 1.0f;
+ for (i = 0; i < (int32)MARGIN; i++, x -= xstep) {
+ cr = (uint32)Cosine_Interpolate(tab[i * 3 + 0 + j * 3 * MaxSetDimX], tab[(255 - i) * 3 + 0 + (j) * 3 * MaxSetDimX], x);
+ cg = (uint32)Cosine_Interpolate(tab[i * 3 + 1 + j * 3 * MaxSetDimX], tab[(255 - i) * 3 + 1 + (j) * 3 * MaxSetDimX], x);
+ cb = (uint32)Cosine_Interpolate(tab[i * 3 + 2 + j * 3 * MaxSetDimX], tab[(255 - i) * 3 + 2 + (j) * 3 * MaxSetDimX], x);
+ if (cr > 255)
+ cr = 255;
+ if (cg > 255)
+ cg = 255;
+ if (cb > 255)
+ cb = 255;
+ tab[i * 3 + 0 + j * 3 * MaxSetDimX] = cr;
+ tab[i * 3 + 1 + j * 3 * MaxSetDimX] = cg;
+ tab[i * 3 + 2 + j * 3 * MaxSetDimX] = cb;
+ }
+ }
+
+
+ for (j = 0; j < MaxSetDimY; j++) {
+ for (i = 0; i < MaxSetDimX; i++) {
+ cr = tab[i * 3 + 0 + j * 3 * MaxSetDimX];
+ cg = tab[i * 3 + 1 + j * 3 * MaxSetDimX];
+ cb = tab[i * 3 + 2 + j * 3 * MaxSetDimX];
+ p[i + j * pitch] = (short)rRGBAToTextureFormat(cr, cg, cb, 255);
+ }
+ }
+
+ rUnlockSurfaceDirect(SkySurface);
+ t3dFree(tab);
+
+ if (t3dSky && t3dSky->MatTable.size() >= 2)
+ t3dSky->MatTable[1]->Texture = (SkySurface);
+}
+
+/* -----------------10/06/99 15.57-------------------
+ * t3dCreateSmokeParticle
+ * --------------------------------------------------*/
+uint8 t3dCreateSmokeParticle(uint32 Num, uint8 Type, uint32 Opacity) {
+ t3dF32 v1, v2;
+ int32 i, j, pitch, color;
+ unsigned short *p;
+ error("TODO: t3dCreateSmokeParticle");
+#if 0
+ Particles[t3dNumParticles].Material = gMaterial();
+
+ if ((SmokeSurface == nullptr) && (Type == 1)) {
+ SmokeSurface = (gTexture *)rCreateSurface(16, 16, rTEXTURESURFACE);
+
+ p = (unsigned short *)rLockSurfaceDirect(SmokeSurface, (unsigned int *)&pitch);
+ pitch /= 2;
+
+ for (j = 0; j < 16; j++) {
+ for (i = 0; i < 16; i++) {
+ v1 = (t3dF32)fabs(sin(DEGREE_TO_RADIANS(360 * i / 32)));
+ v2 = (t3dF32)fabs(sin(DEGREE_TO_RADIANS(360 * j / 32)));
+ color = (uint32)(v1 * v2 * Opacity);
+// color-=(rand()%(color+1)/2);
+ if (color <= 3)
+ p[i + j * pitch] = (short)rRGBAToTextureFormat(color, color, color, 0);
+ else
+ p[i + j * pitch] = (short)rRGBAToTextureFormat(color, color, color, 255);
+ }
+ }
+
+ rUnlockSurfaceDirect(SmokeSurface);
+ } else if ((NoiseSmokeSurface == nullptr) && (Type == 2)) {
+ NoiseSmokeSurface = (gTexture *)rCreateSurface(16, 16, rTEXTURESURFACE);
+
+ p = (unsigned short *)rLockSurfaceDirect(NoiseSmokeSurface, (unsigned int *)&pitch);
+ pitch /= 2;
+
+ for (j = 0; j < 16; j++) {
+ for (i = 0; i < 16; i++) {
+ v1 = (t3dF32)fabs(sin(DEGREE_TO_RADIANS(360 * i / 32)));
+ v2 = (t3dF32)fabs(sin(DEGREE_TO_RADIANS(360 * j / 32)));
+ color = (uint32)(v1 * v2 * Opacity);
+ color -= (rand() % (color + 1) / 2);
+ if (color <= 3)
+ p[i + j * pitch] = (short)rRGBAToTextureFormat(color, color, color, 0);
+ else
+ p[i + j * pitch] = (short)rRGBAToTextureFormat(color, color, color, 255);
+ }
+ }
+
+ rUnlockSurfaceDirect(NoiseSmokeSurface);
+ }
+
+ warning("Partially stubbed t3dCreateSmokeParticle");
+#if 0
+ if (Type == 1)
+ Particles[t3dNumParticles].Material.Texture = (SmokeSurface);
+ else
+ Particles[t3dNumParticles].Material.Texture = (NoiseSmokeSurface);
+ Particles[t3dNumParticles].Material.VB = rGetUserVertexBuffer();
+#endif
+ for (i = 0; i < 16; i++)
+ Particles[t3dNumParticles].RandTable[i] = rand() % 3 - 1;
+
+ Particles[t3dNumParticles].Material.addNumFaces(Num);
+ Particles[t3dNumParticles].Material.addProperty(T3D_MATERIAL_SMOKE | T3D_MATERIAL_NOLIGHTMAP);
+ Particles[t3dNumParticles].ParticlePos = (Particle *)t3dMalloc(sizeof(Particle) * Num);
+ memset(Particles[t3dNumParticles].ParticlePos, 0, sizeof(Particle)*Num);
+ Particles[t3dNumParticles].NumParticles = Num / 3;
+ t3dNumParticles++;
+
+#endif
+ return t3dNumParticles - 1;
+}
+
+/* -----------------10/06/99 15.44-------------------
+ * t3dCalcVertsInterpolants
+ * --------------------------------------------------*/
+void t3dCalcVertsInterpolants(gVertex *oldptr, gVertex *newptr, t3dV3F *VI, uint32 num) {
+#define NUMINTERPOLANTS (1.0f/255.0f)
+ uint32 i;
+
+ if (!oldptr || !newptr || !VI)
+ return ;
+
+ for (i = 0; i < num; i++, oldptr++, newptr++, VI++) {
+ VI->x = (newptr->x - oldptr->x) * NUMINTERPOLANTS;
+ VI->y = (newptr->y - oldptr->y) * NUMINTERPOLANTS;
+ VI->z = (newptr->z - oldptr->z) * NUMINTERPOLANTS;
+// newptr->diffuse=oldptr->diffuse;
+ }
+}
+
+/* -----------------10/06/99 15.45-------------------
+ * t3dAddExpression
+ * --------------------------------------------------*/
+void t3dAddExpression(t3dMESH *mesh, uint32 Frame, gVertex *v) {
+ if (Frame >= mesh->MorphFrames.size()) {
+ if (!mesh->MorphFrames.empty())
+ warning("t3dAddExpression() mesh %s frame %d mesh->NumMorphFrames %d", mesh->name.c_str(), Frame, mesh->MorphFrames.size());
+
+ Frame = 0;
+ return;
+ }
+
+ mesh->LastExpressionFrame = mesh->ExpressionFrame;
+
+ for (auto &mv : mesh->MorphFrames[Frame]._morphModVertices) {
+ gVertex *ap = &v[mv._index];
+ ap->x = mv._v.x;
+ ap->y = mv._v.y;
+ ap->z = mv._v.z;
+ }
+}
+
+/* -----------------10/06/99 15.45-------------------
+ * CalcBones
+ * --------------------------------------------------*/
+void CalcBones(t3dMESH *mesh, t3dBONEANIM *Anim, int32 Frame) {
+ t3dBONE *bone;
+ t3dM3X3F *Matrix;
+ t3dV3F *Trasl, Appov;
+ int32 i, cv, *pmodvert;
+ gVertex *Newptr;
+ uint8 *Average/*,first=0*/;
+ uint32 memalloc = 0;
+ t3dF32 InvAvg;
+ gVertex *gv;
+ gVertex *v;
+// t3dF32 x,y,z;
+
+ if (Frame > Anim->NumFrames - 1)
+ return;
+
+ memalloc = (sizeof(uint8) * mesh->NumVerts);
+ Average = (uint8 *)t3dAlloc(memalloc);
+ memset(Average, 0, memalloc);
+
+ if (!(Newptr = mesh->SavedVertexBuffer))
+ return ;
+
+ t3dAddExpression(mesh, mesh->ExpressionFrame, Newptr);
+
+ //Search first valid vertex
+ cv = 99999999;
+ bone = Anim->BoneTable;
+ for (i = 0; i < Anim->NumBones; i++, bone++) {
+ if (!bone->Trasl || !bone->Matrix || (bone->ModVertices.size() > mesh->NumVerts)) continue;
+
+ for (auto &modVertex : bone ->ModVertices) {
+ if (modVertex < cv) {
+ cv = modVertex;
+ }
+ }
+ }
+ if (cv == 99999999) {
+ warning("Questa animazione non modifica vertici in %s", mesh->name.c_str());
+ t3dDealloc(memalloc);
+ return ;
+ }
+
+ /* for ( i=0; i<mesh->NumVerts; i++ )
+ {
+ memcpy(&Newptr[i],&mesh->VBptr[cv+i].p,sizeof(t3dV3F));
+ }*/
+
+ bone = Anim->BoneTable;
+// DebugFile("\nFrame %d",Frame);
+ for (i = 0; i < Anim->NumBones; i++, bone++) {
+ if (!bone->Trasl || !bone->Matrix || (bone->ModVertices.size() > mesh->NumVerts)) continue;
+
+// DebugFile("Bone %d",i);
+ Matrix = &bone->Matrix[Frame];
+ Trasl = &bone->Trasl[Frame];
+
+
+ for (auto &modVertex : bone->ModVertices) {
+// DebugFile("%d",bone->ModVertices[k].Vertex);
+ gv = &mesh->VBptr[modVertex];
+
+// t3dVectCopy(&Appov,&Newptr[bone->ModVertices[k].Vertex-cv]);
+// t3dVectSub(&Appov, &Appov, &bone->Trasl[0]);
+
+ Appov.x = Newptr[modVertex - cv].x - bone->Trasl[0].x;
+ Appov.y = Newptr[modVertex - cv].y - bone->Trasl[0].y;
+ Appov.z = Newptr[modVertex - cv].z - bone->Trasl[0].z;
+ t3dVectTransformInv(&Appov, &Appov, Matrix);
+
+ if (Average[modVertex - cv] == 0) {
+ gv->x = Appov.x + Trasl->x;
+ gv->y = Appov.y + Trasl->y;
+ gv->z = Appov.z + Trasl->z;
+ } else {
+ gv->x += Appov.x + Trasl->x;
+ gv->y += Appov.y + Trasl->y;
+ gv->z += Appov.z + Trasl->z;
+ }
+ Average[modVertex - cv] ++;
+ }
+ }
+
+
+
+ v = &mesh->VBptr[0];
+ for (i = 0; i < mesh->NumVerts; i++, v++, Average++, Newptr++) {
+ if (!(mesh->Flags & T3D_MESH_CHARACTER))
+ v->diffuse = Newptr->diffuse;
+// v->diffuse=RGBA_MAKE(255,255,255,255);
+ if ((*Average) <= 1)
+ continue;
+
+ InvAvg = 1.0f / (*Average);
+
+ v->x *= InvAvg;
+ v->y *= InvAvg;
+ v->z *= InvAvg;
+ }
+
+ /* v=&mesh->VBptr[0];
+ for (i=0; i<mesh->NumVerts; i++, v++, Average++)
+ {
+ x = (v->x * mesh->Matrix.M[0]) + (v->y * mesh->Matrix.M[1]) + (v->z * mesh->Matrix.M[2]);
+ y = (v->x * mesh->Matrix.M[3]) + (v->y * mesh->Matrix.M[4]) + (v->z * mesh->Matrix.M[5]);
+ z = (v->x * mesh->Matrix.M[6]) + (v->y * mesh->Matrix.M[7]) + (v->z * mesh->Matrix.M[8]);
+ v->x=x;
+ v->y=y;
+ v->z=z;
+ }*/
+
+ t3dDealloc(memalloc);
+
+ t3dCalcVertsInterpolants(mesh->OldVertexBuffer, mesh->VBptr, mesh->VertsInterpolants, mesh->NumVerts);
+}
+
+/* -----------------10/06/99 15.46-------------------
+ * t3dAddBlend
+ * --------------------------------------------------*/
+void t3dAddBlend(t3dF32 AddPercent, t3dMESH *mesh) {
+ gVertex *gv;
+ t3dV3F *VI;
+ uint32 i;
+
+ if (!mesh->VBptr)
+ return;
+
+ gv = mesh->VBptr;
+ VI = mesh->VertsInterpolants;
+ for (i = 0; i < mesh->NumVerts; i++, gv++, VI++) {
+ gv->x += VI->x * AddPercent;
+ gv->y += VI->y * AddPercent;
+ gv->z += VI->z * AddPercent;
+ }
+}
+
+/* -----------------10/06/99 15.46-------------------
+ * t3dCalcMeshBones
+ * --------------------------------------------------*/
+void t3dCalcMeshBones(t3dMESH *mesh, int32 last) {
+ int16 TempFrame;
+ if (!mesh) return;
+
+ if (last) {
+ TempFrame = mesh->CurFrame;
+ if (mesh->Flags & T3D_MESH_DEFAULTANIM)
+ mesh->CurFrame = mesh->DefaultAnim.NumFrames - 1;
+ else
+ mesh->CurFrame = mesh->Anim.NumFrames - 1;
+ }
+
+ if ((mesh->CurFrame > 0) || (mesh->ExpressionFrame != mesh->LastExpressionFrame)) {
+ if ((mesh->LastFrame != mesh->CurFrame) || (mesh->ExpressionFrame != mesh->LastExpressionFrame) ||
+ ((mesh->Flags & T3D_MESH_LAST_DEFAULTANIM) && !(mesh->Flags & T3D_MESH_DEFAULTANIM)) ||
+ (!(mesh->Flags & T3D_MESH_LAST_DEFAULTANIM) && (mesh->Flags & T3D_MESH_DEFAULTANIM))) {
+ if (mesh->LastFrame != mesh->CurFrame)
+ mesh->LastFrame = mesh->CurFrame;
+
+ if (!(mesh->VBptr = mesh->VertexBuffer) || !mesh->OldVertexBuffer)
+ return;
+
+ memcpy(mesh->OldVertexBuffer, mesh->VertexBuffer, mesh->NumVerts * sizeof(gVertex));
+
+ mesh->Flags |= T3D_MESH_UPDATEVB;
+ if (mesh->Flags & T3D_MESH_DEFAULTANIM) {
+ mesh->Flags |= T3D_MESH_LAST_DEFAULTANIM;
+ CalcBones(mesh, &mesh->DefaultAnim, mesh->CurFrame);
+ if (mesh->CurFrame > mesh->DefaultAnim.NumFrames - 1)
+ mesh->CurFrame = 0;
+ } else {
+ mesh->Flags &= ~T3D_MESH_LAST_DEFAULTANIM;
+ CalcBones(mesh, &mesh->Anim, mesh->CurFrame);
+ if (mesh->CurFrame > mesh->Anim.NumFrames - 1)
+ mesh->CurFrame = 0;
+ }
+
+ mesh->LastBlendPercent = 255;
+ mesh->VBptr = nullptr;
+ }
+
+ if (mesh->LastBlendPercent != mesh->BlendPercent) {
+ if (!(mesh->VBptr = mesh->VertexBuffer))
+ return;
+
+ mesh->Flags |= T3D_MESH_UPDATEVB;
+ if (!mesh->BlendPercent) {
+ gVertex *OldVBptr;
+ if (!(OldVBptr = mesh->OldVertexBuffer))
+ return ;
+ memcpy(mesh->VBptr, OldVBptr, sizeof(gVertex)*mesh->NumVerts);
+ } else
+ t3dAddBlend((t3dF32)(mesh->BlendPercent - mesh->LastBlendPercent), mesh);
+
+ mesh->LastBlendPercent = mesh->BlendPercent;
+ mesh->VBptr = nullptr;
+ }
+ }
+
+ if (last) mesh->CurFrame = TempFrame;
+}
+
+/* -----------------10/06/99 15.49-------------------
+ * t3dRotateMoveCamera
+ * --------------------------------------------------*/
+void t3dRotateMoveCamera(t3dCAMERA *cam, t3dF32 AngleX, t3dF32 AngleY, t3dF32 AngleSpeed) {
+ t3dV3F dir, sdir, tmp;
+// t3dF32 /*angley,angle*/;
+ t3dM3X3F mx;
+
+ if ((AngleX == 0.0f) && (AngleY == 0.0f) && (!AngleSpeed)) return;
+ /*
+ t3dVectSub(&dir,&cam->Target,&cam->Source);
+ angle=(t3dF32)sqrt(dir.x*dir.x+dir.z*dir.z);
+
+ cam->Target.y = cam->Source.y + dir.y*(t3dF32)cos(-AngleX) + angle*(t3dF32)sin(-AngleX);
+ // cam->Target.x = cam->Source.x - dir.y*(t3dF32)sin(-AngleX) + angle*(t3dF32)cos(-AngleX);
+ // cam->Target.z = cam->Source.z - dir.y*(t3dF32)sin(-AngleX) + angle*(t3dF32)cos(-AngleX);
+
+ cam->Target.x = cam->Source.x + dir.x*(t3dF32)cos(AngleY) + dir.z*(t3dF32)sin(AngleY);
+ cam->Target.z = cam->Source.z - dir.x*(t3dF32)sin(AngleY) + dir.z*(t3dF32)cos(AngleY);
+ */
+
+ t3dMatView(&cam->Matrix, &cam->Source, &cam->Target);
+ t3dMatRot(&mx, AngleX, AngleY, 0);
+ t3dVectSub(&dir, &cam->Target, &cam->Source);
+ t3dVectTransform(&sdir, &dir, &cam->Matrix);
+ t3dVectTransform(&sdir, &sdir, &mx);
+ t3dVectTransformInv(&sdir, &sdir, &cam->Matrix);
+ t3dVectNormalize(&sdir);
+ t3dVectCopy(&tmp, &sdir);
+ sdir *= AngleSpeed;
+ t3dVectAdd(&cam->Source, &cam->Source, &sdir);
+ t3dVectAdd(&cam->Target, &cam->Source, &tmp);
+}
+
+/* -----------------10/06/99 15.49-------------------
+ * t3dResetPipeline
+ * --------------------------------------------------*/
+void t3dResetPipeline() {
+ t3dMESH *m;
+ uint32 i, j;
+
+ rResetPipeline();
+ t3dStartIndex = t3dNumVertices = 0;
+ t3d_NumMeshesVisible = 0;
+ t3dNumGlobalMirrors = 0;
+ t3dNumMaterialLists = 0;
+ StatNumTris = 0;
+ StatNumVerts = 0;
+
+ for (i = 0; i < t3dNumPortals; i++) {
+ if ((!t3dPortalList[i]) || (!t3dPortalList[i]->PortalList)) continue;
+
+ for (j = 0, m = &t3dPortalList[i]->PortalList->MeshTable[0]; j < t3dPortalList[i]->PortalList->NumMeshes(); j++, m++)
+ m->Flags &= ~T3D_MESH_PORTALPROCESSED;
+ }
+
+ t3dNumPortals = 0;
+ if (PortalCrossed) {
+ t3dCurRoom = PortalCrossed;
+ PortalCrossed = nullptr;
+ }
+}
+
+
+/* -----------------10/06/99 15.58-------------------
+ * t3dReleaseParticles
+ * --------------------------------------------------*/
+void t3dReleaseParticles(void) {
+ for (int i = 0; i < MAX_PARTICLES; i++) {
+ t3dFree(Particles[i].ParticlePos);
+ Particles[i].Material.clear();
+ }
+}
+
+/* -----------------10/06/99 15.46-------------------
+ * t3dResetMesh
+ * --------------------------------------------------*/
+void t3dResetMesh(t3dMESH *mesh) {
+ if (!mesh->VertexBuffer || !mesh->OldVertexBuffer || !mesh->SavedVertexBuffer)
+ return ;
+
+ memcpy(mesh->VertexBuffer, mesh->SavedVertexBuffer, sizeof(gVertex)*mesh->NumVerts);
+ memcpy(mesh->OldVertexBuffer, mesh->SavedVertexBuffer, sizeof(gVertex)*mesh->NumVerts);
+ mesh->Flags |= T3D_MESH_UPDATEVB;
+}
+
+/* -----------------10/06/99 15.49-------------------
+ * CheckAndClip
+ * --------------------------------------------------*/
+uint8 CheckAndClip(t3dV3F *start, t3dV3F *end, t3dNORMAL *n) {
+ t3dF32 divi;
+ t3dF32 d1 = t3dVectDot(start, &n->n) - n->dist;
+ t3dF32 d2 = t3dVectDot(end, &n->n) - n->dist;
+
+ if ((d1 < 0) && (d2 < 0))
+ return 0;
+ else if ((d1 >= 0) && (d2 >= 0))
+ return 1;
+
+
+ if ((d1 < 0) && (d2 >= 0)) {
+ d2 = d2 - d1;
+ divi = -d1 / d2;
+ start->x = start->x + divi * (end->x - start->x);
+ start->y = start->y + divi * (end->y - start->y);
+ start->z = start->z + divi * (end->z - start->z);
+ return 1;
+ } else {
+ d1 = d1 - d2;
+ divi = -d2 / d1;
+ end->x = end->x + divi * (start->x - end->x);
+ end->y = end->y + divi * (start->y - end->y);
+ end->z = end->z + divi * (start->z - end->z);
+ return 2;
+ }
+}
+
+/* -----------------10/06/99 15.50-------------------
+ * t3dCheckWithFloor
+ * --------------------------------------------------*/
+t3dF32 t3dCheckWithFloor(void) {
+ extern t3dF32 CurFloorY;
+ t3dVERTEX a, b, c;
+ t3dNORMAL bbn;
+ t3dV3F StartDir, EndDir, Sight, pos, en, st;
+ t3dF32 MaxX, AverageZ = -99999999999.9f;
+
+ a.p.x = -10;
+ a.p.y = CurFloorY + 15;
+ a.p.z = 10;
+ b.p.x = 10;
+ b.p.y = CurFloorY + 15;
+ b.p.z = 10;
+ c.p.x = 10;
+ c.p.y = CurFloorY + 15;
+ c.p.z = -10;
+ t3dPlaneNormal(&bbn, &a.p, &b.p, &c.p); //floor
+
+ t3dVectCopy(&StartDir, &t3dCurCamera->Source);
+ t3dVectTransformInv(&EndDir, &t3d3dMousePos, &t3dCurViewMatrix);
+ t3dVectAdd(&EndDir, &EndDir, &t3dCurCamera->Source);
+// t3dVectSub(&EndDir,&EndDir,&mesh->Pos);
+
+ t3dVectSub(&Sight, &EndDir, &StartDir);
+ t3dVectNormalize(&Sight);
+ Sight *= 2000000.0f;
+ t3dVectAdd(&EndDir, &StartDir, &Sight);
+
+
+ if (CheckAndClip(&StartDir, &EndDir, &bbn)) {
+ pos.x = - t3dCurCamera->Source.x; // posizione centro mesh dalla camera
+ pos.y = - t3dCurCamera->Source.y;
+ pos.z = - t3dCurCamera->Source.z;
+ t3dVectTransform(&pos, &pos, &t3dCurViewMatrix); // rotate by the mesh matrix
+
+// t3dVectTransform(&StartDir,&StartDir,&t3dCurCamera->Matrix);
+// t3dVectTransform(&EndDir,&EndDir,&t3dCurCamera->Matrix);
+
+ t3dVectCopy(&st, &StartDir);
+ t3dVectCopy(&en, &EndDir);
+ t3dVectTransform(&StartDir, &StartDir, &t3dCurViewMatrix);
+ t3dVectTransform(&EndDir, &EndDir, &t3dCurViewMatrix);
+ t3dVectAdd(&StartDir, &StartDir, &pos);
+ t3dVectAdd(&EndDir, &EndDir, &pos);
+
+ if ((MaxX = t3dPointSquaredDistance(&StartDir)) > AverageZ) {
+ t3dVectCopy(&FloorHitCoords, &st);
+ AverageZ = MaxX;
+ }
+ if ((MaxX = t3dPointSquaredDistance(&EndDir)) > AverageZ) {
+ t3dVectCopy(&FloorHitCoords, &en);
+ AverageZ = MaxX;
+ }
+
+ return AverageZ;
+ }
+
+ return 999999999999.9f;
+}
+
+/* -----------------10/06/99 15.43-------------------
+ * t3dProcessMirror
+ * --------------------------------------------------*/
+void t3dProcessMirror(t3dMESH *mesh, t3dCAMERA *cam) {
+ warning("STUBBED: t3dProcessMirror\n");
+#if 0
+// t3dBODY *NewBody=NULL;
+ t3dV3F appo, c0;
+ t3dV3F ppv1, ppv2, ppv3, ppv4/*,eye,pos,oldtrasl,oldpos*/;
+ t3dU32 p/*,k*/;
+ t3dNORMAL OldClipPlanes[NUMCLIPPLANES];
+ t3dM3X3F ReflMatrix;
+ t3dV3F mirrorpos;
+// t3dMESH *m;
+ t3dM3X3F OldViewMatrix;
+ t3dCAMERA OldCurCamera;
+ gMaterial *OldMaterialTable;
+
+ if (!mesh->VertexBuffer)
+ return ;
+
+ mesh->VBptr = mesh->VertexBuffer;
+ ppv1.x = mesh->VBptr[mesh->FList[0].VertexIndex[0]].x;
+ ppv1.y = mesh->VBptr[mesh->FList[0].VertexIndex[0]].y;
+ ppv1.z = mesh->VBptr[mesh->FList[0].VertexIndex[0]].z;
+ ppv2.x = mesh->VBptr[mesh->FList[0].VertexIndex[1]].x;
+ ppv2.y = mesh->VBptr[mesh->FList[0].VertexIndex[1]].y;
+ ppv2.z = mesh->VBptr[mesh->FList[0].VertexIndex[1]].z;
+ ppv3.x = mesh->VBptr[mesh->FList[0].VertexIndex[2]].x;
+ ppv3.y = mesh->VBptr[mesh->FList[0].VertexIndex[2]].y;
+ ppv3.z = mesh->VBptr[mesh->FList[0].VertexIndex[2]].z;
+
+ for (p = 0; p < 3; p++) {
+ appo.x = mesh->VBptr[mesh->FList[1].VertexIndex[p]].x;
+ appo.y = mesh->VBptr[mesh->FList[1].VertexIndex[p]].y;
+ appo.z = mesh->VBptr[mesh->FList[1].VertexIndex[p]].z;
+
+ if ((!t3dVectCmp(&ppv1, &appo)) &&
+ (!t3dVectCmp(&ppv2, &appo)) &&
+ (!t3dVectCmp(&ppv3, &appo)))
+ memcpy(&ppv4, &appo, sizeof(t3dV3F));
+ }
+
+ memcpy(OldClipPlanes, ClipPlanes, sizeof(t3dNORMAL)*NUMCLIPPLANES);
+
+ t3dVectSub(&ppv4, &ppv4, &cam->Source);
+ t3dVectSub(&ppv3, &ppv3, &cam->Source);
+ t3dVectSub(&ppv2, &ppv2, &cam->Source);
+ t3dVectSub(&ppv1, &ppv1, &cam->Source);
+ t3dVectTransform(&ppv1, &ppv1, &t3dCurViewMatrix);
+ t3dVectTransform(&ppv2, &ppv2, &t3dCurViewMatrix);
+ t3dVectTransform(&ppv3, &ppv3, &t3dCurViewMatrix);
+ t3dVectTransform(&ppv4, &ppv4, &t3dCurViewMatrix);
+ t3dVectFill(&c0, 0.0f);
+
+// t3dVectCopy(&c0,&cam->Source);
+
+ t3dPlaneNormal(&ClipPlanes[RIGHTCLIP], &c0, &ppv3, &ppv4);
+ t3dPlaneNormal(&ClipPlanes[LEFTCLIP], &c0, &ppv1, &ppv2);
+ t3dPlaneNormal(&ClipPlanes[TOPCLIP], &c0, &ppv4, &ppv1);
+ t3dPlaneNormal(&ClipPlanes[BOTTOMCLIP], &c0, &ppv2, &ppv3);
+
+ mesh->VBptr = NULL;
+
+ t3dMatReflect(&ReflMatrix, &mirrorpos, mesh->FList[0].n);
+// t3dVectAdd(&mirrorpos,&mirrorpos,&mesh->Pos);
+
+ bDisableMirrors = 1;
+ t3dMatCopy(&OldViewMatrix, &t3dCurViewMatrix);
+ memcpy(&OldCurCamera, t3dCurCamera, sizeof(t3dCAMERA));
+ {
+ t3dU32 i, j;
+ t3dMESH *m;
+ t3dFACE *f;
+ for (i = 0, m = t3dCurRoom->MeshTable; i < t3dCurRoom->NumMeshes; i++, m++)
+ for (j = 0, f = m->FList; j < m->NumFaces; j++, f++)
+ if (f->mat)
+ f->mat = (gMaterial *)((t3dU8 *)f->mat - (t3dU8 *)t3dCurRoom->MatTable + (t3dU8 *)t3dCurRoom->MirrorMatTable);
+ OldMaterialTable = t3dCurRoom->MatTable;
+ t3dCurRoom->MatTable = t3dCurRoom->MirrorMatTable;
+ }
+
+ t3dVectAdd(&t3dCurCamera->Source, &t3dCurCamera->Source, &mirrorpos);
+ t3dVectTransform(&t3dCurCamera->Source, &t3dCurCamera->Source, &ReflMatrix);
+ t3dVectAdd(&t3dCurCamera->Target, &t3dCurCamera->Target, &mirrorpos);
+ t3dVectTransform(&t3dCurCamera->Target, &t3dCurCamera->Target, &ReflMatrix);
+
+ t3dMatMul(&t3dCurViewMatrix, &t3dCurViewMatrix, &ReflMatrix);
+
+
+ if (!t3dTransformBody(t3dCurRoom)) {
+ DebugLogWindow("Can't transform %s", mesh->PortalList->Name);
+ }
+
+ bDisableMirrors = 0;
+ t3dMatCopy(&t3dCurViewMatrix, &OldViewMatrix);
+ memcpy(ClipPlanes, OldClipPlanes, sizeof(t3dNORMAL)*NUMCLIPPLANES);
+ {
+ t3dU32 i, j;
+ t3dMESH *m;
+ t3dFACE *f;
+ t3dCurRoom->MatTable = OldMaterialTable;
+ for (i = 0, m = t3dCurRoom->MeshTable; i < t3dCurRoom->NumMeshes; i++, m++)
+ for (j = 0, f = m->FList; j < m->NumFaces; j++, f++)
+ if (f->mat)
+ f->mat = (gMaterial *)((t3dU8 *)f->mat - (t3dU8 *)t3dCurRoom->MirrorMatTable + (t3dU8 *)t3dCurRoom->MatTable);
+ }
+ memcpy(t3dCurCamera, &OldCurCamera, sizeof(t3dCAMERA));
+#endif
+}
+
+/* -----------------10/06/99 15.51-------------------
+ * t3dProcessMirrors
+ * --------------------------------------------------*/
+void t3dProcessMirrors(t3dMESH **MirrorList, uint32 NumMirrors) {
+ uint32 i;
+
+ for (i = 0; i < NumMirrors; i++)
+ t3dProcessMirror(MirrorList[i], t3dCurCamera);
+}
+
+#define _ADDLINES(x) *ptr=num+x; ptr++; rAddLinesArray()
+/* -----------------02/06/99 16.53-------------------
+ * t3dShowBoundingBox
+ * --------------------------------------------------*/
+void t3dShowBoundingBox(t3dBODY *b) {
+ t3dV3F tmp;
+ uint16 *ptr;
+ uint16 num;
+
+ gVertex *VertPointer = (gVertex *)rLockPointArray();
+
+ ptr = rGetLinesArrayPtr();
+ num = rGetNumPointArray();
+
+ tmp.x = -t3dCurCamera->Source.x;
+ tmp.y = -t3dCurCamera->Source.y;
+ tmp.z = -t3dCurCamera->Source.z;
+ t3dVectTransform(&tmp, &tmp, &t3dCurViewMatrix);
+ rBuildLinesViewMatrix(t3dCurViewMatrix, tmp);
+
+ for (uint32 i = 0; i < b->NumMeshes(); i++) {
+ t3dMESH &mesh = b->MeshTable[i];
+ if (mesh.Flags & (T3D_MESH_PORTAL | T3D_MESH_HIDDEN)) {
+ continue;
+ }
+
+ for (uint32 j = 0; j < 8; j++) {
+ VertPointer->x = mesh.BBox[j].p.x + mesh.Trasl.x;
+ VertPointer->y = mesh.BBox[j].p.y + mesh.Trasl.y;
+ VertPointer->z = mesh.BBox[j].p.z + mesh.Trasl.z;
+ VertPointer->diffuse = RGBA_MAKE(0, 0, 255, 255);
+ rAddPointArray();
+ VertPointer++;
+// t3dNumVertices++;
+ }
+
+ _ADDLINES(0);
+ _ADDLINES(1);
+
+ _ADDLINES(1);
+ _ADDLINES(3);
+
+ _ADDLINES(3);
+ _ADDLINES(2);
+
+ _ADDLINES(2);
+ _ADDLINES(0);
+
+ _ADDLINES(4);
+ _ADDLINES(5);
+
+ _ADDLINES(5);
+ _ADDLINES(7);
+
+ _ADDLINES(7);
+ _ADDLINES(6);
+
+ _ADDLINES(6);
+ _ADDLINES(4);
+
+ _ADDLINES(4);
+ _ADDLINES(0);
+
+ _ADDLINES(6);
+ _ADDLINES(2);
+
+ _ADDLINES(7);
+ _ADDLINES(3);
+
+ _ADDLINES(5);
+ _ADDLINES(1);
+
+ num += 8;
+ }
+
+ rUnlockPointArray();
+}
+
+/* -----------------02/06/99 16.54-------------------
+ * t3dShowBounds
+ * --------------------------------------------------*/
+void t3dShowBounds(t3dPAN *p, uint32 numpan) {
+ t3dV3F tmp;
+ uint32 j;
+ uint16 *ptr;
+ uint16 num;
+ gVertex *VertPointer = (gVertex *)rLockPointArray();
+ ptr = rGetLinesArrayPtr();
+ num = rGetNumPointArray();
+
+ tmp.x = -t3dCurCamera->Source.x;
+ tmp.y = -t3dCurCamera->Source.y;
+ tmp.z = -t3dCurCamera->Source.z;
+ t3dVectTransform(&tmp, &tmp, &t3dCurViewMatrix);
+ rBuildLinesViewMatrix(t3dCurViewMatrix, tmp);
+
+ for (j = 0; j < numpan; j++) {
+ VertPointer->x = p[j].x1;
+ VertPointer->y = CurFloorY + 1.0f;
+ VertPointer->z = p[j].z1;
+ VertPointer->diffuse = RGBA_MAKE(250, 0, 0, 255);
+ rAddPointArray();
+ VertPointer++;
+// t3dNumVertices++;
+
+ VertPointer->x = p[j].x2;
+ VertPointer->y = CurFloorY + 1.0f;
+ VertPointer->z = p[j].z2;
+ VertPointer->diffuse = RGBA_MAKE(250, 0, 0, 255);
+ rAddPointArray();
+ VertPointer++;
+// t3dNumVertices++;
+
+ VertPointer->x = p[j].bx1;
+ VertPointer->y = CurFloorY + 1.0f;
+ VertPointer->z = p[j].bz1;
+ VertPointer->diffuse = RGBA_MAKE(250, 0, 0, 255);
+ rAddPointArray();
+ VertPointer++;
+// t3dNumVertices++;
+
+ VertPointer->x = p[j].bx2;
+ VertPointer->y = CurFloorY + 1.0f;
+ VertPointer->z = p[j].bz2;
+ VertPointer->diffuse = RGBA_MAKE(250, 0, 0, 255);
+ rAddPointArray();
+ VertPointer++;
+// t3dNumVertices++;
+
+ _ADDLINES(0);
+ _ADDLINES(1);
+
+ _ADDLINES(0);
+ _ADDLINES(2);
+
+ _ADDLINES(1);
+ _ADDLINES(3);
+
+ num += 4;
+
+ }
+
+ rUnlockPointArray();
+}
+
+/* -----------------10/06/99 15.51-------------------
+ * t3dCalcVolumetricLights
+ * --------------------------------------------------*/
+void t3dCalcVolumetricLights(t3dMESH *m, t3dBODY *body) {
+ uint32 i;
+ t3dF32 invcellssize;
+ int32 x, y, z;
+ uint8 val;
+// t3dS32 val1,val2,val3,tval;
+ int32 xcells;
+ int32 ycells;
+ int32 zcells;
+ t3dF32 xcells_rest, ycells_rest, zcells_rest;
+ gVertex *gv;
+ uint8 r, g, b;
+ t3dV3F vect, sco;
+
+ if (!body->VolumetricLights) return;
+ if (!(gv = m->VBptr)) return;
+
+ invcellssize = 1.0f / body->VolumetricLights->CellsSize;
+ xcells = body->VolumetricLights->xcells;
+ ycells = body->VolumetricLights->ycells;
+ zcells = body->VolumetricLights->zcells;
+ t3dVectSub(&sco, &m->Trasl, &body->MinPos);
+
+ for (i = 0; i < m->NumVerts; i++, gv++) {
+ t3dVectInit(&vect, gv->x, gv->y, gv->z);
+ t3dVectTransform(&vect, &vect, &m->Matrix);
+ t3dVectAdd(&vect, &vect, &sco);
+
+ x = (int32)(xcells_rest = (vect.x * invcellssize));
+ y = (int32)(ycells_rest = (vect.y * invcellssize));
+ z = (int32)(zcells_rest = (vect.z * invcellssize));
+
+ if ((x < 0) || (y < 0) || (z < 0) || (x > xcells) || (y > ycells) || (z > zcells)) {
+ gv->diffuse = RGBA_MAKE(128, 128, 128, 255);
+ continue;
+ }
+
+ val = body->VolumetricLights->VolMap[x + (z * xcells) + (y * xcells * zcells)];
+
+ r = (uint8)(((RGBA_GETRED(gv->diffuse) * val) >> 8) & 0xFF);
+ g = (uint8)(((RGBA_GETGREEN(gv->diffuse) * val) >> 8) & 0xFF);
+ b = (uint8)(((RGBA_GETBLUE(gv->diffuse) * val) >> 8) & 0xFF);
+
+ gv->diffuse = RGBA_MAKE(r, g, b, RGBA_GETALPHA(gv->diffuse));
+ }
+}
+
+
+/* -----------------10/06/99 15.53-------------------
+ * t3dLightCharacter
+ * --------------------------------------------------*/
+void t3dLightCharacter(t3dCHARACTER *Ch) {
+ t3dMESH *mesh;
+ uint32 i, j;
+ t3dV3F l;
+ t3dF32 dist, far_range, near_range, AttenIntensity;
+ t3dF32 ang, half_hotspot, half_falloff, SpotIntensity;
+ t3dF32 nlight, Intensity;
+ t3dV3F ppos;
+ t3dV3F *normal, dir;
+ int32 rr, gg, bb, arr, agg, abb;
+ gVertex *gv;
+ DWORD amb;
+
+ mesh = Ch->Mesh;
+
+ if (!mesh || !mesh->VertexBuffer)
+ return ;
+
+ gv = mesh->VBptr = mesh->VertexBuffer;
+ mesh->Flags |= T3D_MESH_UPDATEVB;
+
+ arr = (uint32)(Ch->Body->AmbientLight.x + t3dCurRoom->AmbientLight.x);
+ agg = (uint32)(Ch->Body->AmbientLight.y + t3dCurRoom->AmbientLight.y);
+ abb = (uint32)(Ch->Body->AmbientLight.z + t3dCurRoom->AmbientLight.z);
+ if (arr > 255) arr = 255;
+ if (agg > 255) agg = 255;
+ if (abb > 255) abb = 255;
+ amb = RGBA_MAKE(arr, agg, abb, 255);
+ for (j = 0; j < mesh->NumVerts; j++, gv++)
+ gv->diffuse = amb;
+
+ auto light = Ch->CurRoom->LightTable[0];
+ if (light.Type & T3D_LIGHT_ALLLIGHTSOFF) {
+ mesh->VBptr = nullptr;
+ return;
+ }
+ t3dVectAdd(&ppos, &mesh->Trasl, &mesh->Pos);
+
+ //for (i = 0; i < Ch->CurRoom->NumLights(); i++, lt++) {
+ for (auto < : Ch->CurRoom->LightTable) {
+ if (!(lt.Type & T3D_LIGHT_LIGHTON)) continue;
+ if (!(lt.Type & T3D_LIGHT_REALTIME)) continue;
+ if ((lt.Type & T3D_LIGHT_FLARE)) continue;
+
+ AttenIntensity = 1.0f;
+ if (lt.Type & T3D_LIGHT_ATTENUATION) {
+ near_range = lt.NearRange;
+ far_range = lt.FarRange;
+
+ dist = t3dVectDistance(<.Source, &ppos);
+ if (dist > far_range)
+ continue;
+ else if (dist > near_range)
+ AttenIntensity = (1.0f - ((dist - near_range) / (far_range - near_range)));
+ }
+ SpotIntensity = 1.0f;
+ if (lt.Type & T3D_LIGHT_SPOTLIGHT) {
+ half_hotspot = DEGREE_TO_RADIANS(lt.HotSpot) * 0.5f;
+ half_falloff = DEGREE_TO_RADIANS(lt.FallOff) * 0.5f;
+
+ t3dVectSub(&l, &ppos, <.Source);
+ t3dVectNormalize(&l);
+ t3dVectSub(&dir, <.Target, <.Source);
+ t3dVectNormalize(&dir);
+
+ ang = (t3dF32)acos(t3dVectDot(&dir, &l));
+ if (ang > half_falloff)
+ continue;
+ else if (ang > half_hotspot)
+ SpotIntensity = (1.0f - ((ang - half_hotspot) / (half_falloff - half_hotspot)));
+ }
+
+ t3dVectSub(&l, <.Source, &ppos);
+ t3dVectTransformInv(&l, &l, &mesh->Matrix);
+ t3dVectNormalize(&l);
+
+ Intensity = AttenIntensity * SpotIntensity;
+ gv = mesh->VBptr;
+ for (j = 0; j < mesh->NumVerts; j++, gv++) {
+ normal = &mesh->NList[j]->n;
+ if ((nlight = t3dVectDot(normal, &l)) >= 0) {
+ nlight *= Intensity;
+ rr = t3dFloatToInt(lt.Color.x * nlight) + RGBA_GETRED(gv->diffuse);
+ gg = t3dFloatToInt(lt.Color.y * nlight) + RGBA_GETGREEN(gv->diffuse);
+ bb = t3dFloatToInt(lt.Color.z * nlight) + RGBA_GETBLUE(gv->diffuse);
+ if (rr > 255) rr = 255;
+ if (gg > 255) gg = 255;
+ if (bb > 255) bb = 255;
+ gv->diffuse = RGBA_MAKE(rr, gg, bb, 255);
+ }
+ }
+ }
+
+ if (Ch->Flags & T3D_CHARACTER_VOLUMETRICLIGHTING)
+ t3dCalcVolumetricLights(mesh, Ch->CurRoom);
+
+ mesh->VBptr = nullptr;
+}
+
+/* -----------------10/06/99 15.50-------------------
+ * CheckInBoundBox
+ * --------------------------------------------------*/
+uint8 CheckInBoundBox(t3dV3F *start, t3dV3F *end, t3dVERTEX *bbv, t3dNORMAL *bbn) {
+ if (!CheckAndClip(start, end, &bbn[0])) return 0;
+ if (!CheckAndClip(start, end, &bbn[1])) return 0;
+ if (!CheckAndClip(start, end, &bbn[2])) return 0;
+ if (!CheckAndClip(start, end, &bbn[3])) return 0;
+ if (!CheckAndClip(start, end, &bbn[4])) return 0;
+ if (!CheckAndClip(start, end, &bbn[5])) return 0;
+
+ return 1;
+}
+
+/* -----------------10/06/99 15.50-------------------
+ * t3dDetectObj
+ * --------------------------------------------------*/
+uint8 t3dDetectObj(t3dCAMERA *cam, t3dMESH *mesh, t3dM3X3F *matrix) {
+ t3dV3F StartDir, EndDir, Sight, pos;
+ t3dF32 MaxX;
+
+ if (mesh->Flags & T3D_MESH_NOBOUNDBOX)
+ return 0;
+
+ t3dVectTransformInv(&EndDir, &t3d3dMousePos, &t3dCurViewMatrix);
+ t3dVectAdd(&EndDir, &EndDir, &cam->Source);
+
+ t3dVectCopy(&StartDir, &cam->Source);
+ t3dVectSub(&Sight, &EndDir, &StartDir);
+ t3dVectNormalize(&Sight);
+ Sight *= 2000000.0f;
+ t3dVectAdd(&EndDir, &StartDir, &Sight);
+ mesh->BBoxAverageZ = 9999999999.9f;
+
+ t3dVectInit(&pos, 0.0f, 0.0f, 0.0f);
+ if (mesh->Flags & T3D_MESH_CHARACTER) {
+ t3dVectInit(&pos, mesh->Trasl.x, CurFloorY, mesh->Trasl.z);
+ t3dVectSub(&StartDir, &StartDir, &pos);
+ t3dVectSub(&EndDir, &EndDir, &pos);
+ }
+
+ if (CheckInBoundBox(&StartDir, &EndDir, &mesh->BBox[0], &mesh->BBoxNormal[0]) && (t3d_NumMeshesVisible < 255)) {
+ t3dV3F st, en;
+
+ pos.x -= cam->Source.x; // posizione centro mesh dalla camera
+ pos.y -= cam->Source.y;
+ pos.z -= cam->Source.z;
+ t3dVectTransform(&pos, &pos, &t3dCurViewMatrix); // rotate by the mesh matrix
+
+ t3dVectCopy(&st, &StartDir);
+ t3dVectCopy(&en, &EndDir);
+ t3dVectTransform(&StartDir, &StartDir, &t3dCurViewMatrix);
+ t3dVectTransform(&EndDir, &EndDir, &t3dCurViewMatrix);
+ t3dVectAdd(&StartDir, &StartDir, &pos);
+ t3dVectAdd(&EndDir, &EndDir, &pos);
+ MaxX = t3dPointSquaredDistance(&StartDir);
+ if ((MaxX) < mesh->BBoxAverageZ) {
+ mesh->BBoxAverageZ = MaxX;
+ t3dVectCopy(&mesh->Intersection, &st);
+ }
+ MaxX = t3dPointSquaredDistance(&EndDir);
+ if ((MaxX) < mesh->BBoxAverageZ) {
+ mesh->BBoxAverageZ = MaxX;
+ t3dVectCopy(&mesh->Intersection, &en);
+ }
+
+ t3d_NumMeshesVisible++;
+ t3d_VisibleMeshes[t3d_NumMeshesVisible - 1] = mesh;
+
+ return 1;
+ } else
+ return 0;
+}
+
+/* -----------------10/06/99 15.42-------------------
+ * t3dSetVisibileVertex
+ * --------------------------------------------------*/
+void t3dSetVisibileVertex(t3dMESH &mesh) {
+// if (mesh->Flags&T3D_MESH_PORTAL)
+// return ;
+
+ for (uint32 i = 0; i < mesh.NumFaces() ; i++) {
+ t3dFACE &f = mesh.FList[i];
+ if ((/*(!(f->flags&T3D_MATERIAL_OPACITY)) &&*/ (!(f.flags & T3D_MATERIAL_CLIPMAP)) &&
+ (!(f.flags & T3D_MATERIAL_ADDITIVE))) &&
+ (!(f.flags & T3D_MATERIAL_GLASS))) {
+ if (f.isVisible())
+ f.flags |= T3D_FACE_VISIBLE;
+ else
+ f.flags &= ~(T3D_FACE_VISIBLE); // continue
+ /* if ((f->flags&T3D_MATERIAL_PORTAL))
+ if (f->flags&T3D_FACE_VISIBLE)
+ f->flags&=~T3D_FACE_VISIBLE;
+ else
+ f->flags|=T3D_FACE_VISIBLE;*/
+ } else
+ f.flags |= T3D_FACE_VISIBLE;
+ }
+}
+
+/* -----------------18/06/99 10.46-------------------
+ * t3dAddTextureBufferShadow
+ * --------------------------------------------------*/
+void t3dAddTextureBufferShadow(t3dCHARACTER *c, uint32 CurShadowBox, t3dLIGHT *light) {
+ SHADOWBOX *sb = c->ShadowBox[CurShadowBox];
+ SHADOW *shad = &sb->ShadowsList[0];
+ uint32 i, k, ff, kkk, StartVert;
+ uint8 *ProjectedPolys, *pp;
+ t3dMESH *cm = c->Mesh;
+ t3dBODY *cr = t3dCurRoom; //c->CurRoom;
+ pVert tempv, *pv;
+ WORD *ptr = nullptr;
+ gVertex *gv, *pc;
+ t3dV3F v, tmp, MinSco, MaxSco, Aspect, BBox[8], dir;
+
+ warning("TODO: t3dAddTextureBufferShadow\n");
+ return;
+#if 0
+ if (!cm || !cm->VertexBuffer)
+ return ;
+//tb
+ t3dMatView(&t3dCurViewMatrix, &light->Source, &cm->Trasl, 0.0f); // punta la luce ai piedi
+ t3dVectSub(&t3dCurTranslation, &cr->MeshTable[0].Trasl, &light->Source);
+ t3dVectTransform(&t3dCurTranslation, &t3dCurTranslation, &t3dCurViewMatrix); // rotate by the camera matrix
+
+ t3dBackfaceCulling(cr->NList, cr->NumNormals, &light->Source); // setta le normali che sono backface la luce
+
+ if (shad->totalverts < cr->NumTotVerts) {
+ rDeleteVertexBuffer(shad->ProjVertsVB);
+ if (shad->pwShadVolCapIndices) t3dFree(shad->pwShadVolCapIndices);
+ shad->ProjVertsVB = rCreateVertexBuffer(cr->NumTotVerts);
+ shad->pwShadVolCapIndices = t3dCalloc<WORD>(cr->NumTotVerts * 3);
+ shad->totalverts = cr->NumTotVerts;
+ } else {
+ if (!shad->ProjVertsVB) shad->ProjVertsVB = rCreateVertexBuffer(cr->NumTotVerts);
+ if (!shad->pwShadVolCapIndices) shad->pwShadVolCapIndices = t3dCalloc<WORD>(cr->NumTotVerts * 3);
+ shad->totalverts = cr->NumTotVerts;
+ }
+ ProjectedPolys = (t3dU8 *)t3dAlloc(sizeof(t3dU8) * cr->NumTotVerts);
+ rMakeProjectiveShadow(sb, nullptr, cm->NumVerts);
+ StartVert = 0;
+
+ for (i = 0; i < 8; i++) t3dVectCopy(&BBox[i], &cm->Trasl);
+ for (i = 0; i < 4; i++) BBox[i + 4].y += c->Height;
+ t3dVectSub(&tmp, &cm->Trasl, &light->Source);
+ tmp.y = 0.0f;
+ t3dVectNormalize(&tmp);
+ t3dVectScale(&tmp, &tmp, c->Radius * 2.0f);
+
+ t3dVectAdd(&BBox[0], &BBox[0], &tmp);
+ t3dVectAdd(&BBox[4], &BBox[4], &tmp);
+ t3dVectSub(&BBox[1], &BBox[1], &tmp);
+ t3dVectSub(&BBox[5], &BBox[5], &tmp);
+ tmp.y = tmp.x;
+ tmp.x = -tmp.z;
+ tmp.z = tmp.y;
+ tmp.y = 0.0f;
+ t3dVectAdd(&BBox[2], &BBox[2], &tmp);
+ t3dVectAdd(&BBox[6], &BBox[6], &tmp);
+ t3dVectSub(&BBox[3], &BBox[3], &tmp);
+ t3dVectSub(&BBox[7], &BBox[7], &tmp);
+
+ t3dVectFill(&MinSco, 9999999.9f);
+ t3dVectFill(&MaxSco, -9999999.9f);
+ for (i = 0; i < 8; i++) {
+ t3dVectTransform(&v, &BBox[i], &t3dCurViewMatrix);
+ t3dVectAdd(&v, &v, &t3dCurTranslation);
+ v.x /= v.z;
+ v.y = -v.y / v.z;
+ if (v.x < MinSco.x) MinSco.x = v.x;
+ if (v.y < MinSco.y) MinSco.y = v.y;
+ if (v.z < MinSco.z) MinSco.z = v.z;
+ if (v.x > MaxSco.x) MaxSco.x = v.x;
+ if (v.y > MaxSco.y) MaxSco.y = v.y;
+ if (v.z > MaxSco.z) MaxSco.z = v.z;
+ }
+ Aspect.x = 1.0f / (MaxSco.x - MinSco.x);
+ Aspect.y = 1.0f / (MaxSco.y - MinSco.y);
+ t3dVectSub(&dir, &cm->Trasl, &light->Source);
+ t3dVectNormalize(&dir);
+// Aspect.x *= (1.0-0.1f*fabs(dir.x));
+// Aspect.y *= (1.0-0.1f*fabs(dir.y));
+ tempv.rhw = 1.0f / t3dVectDistance(&light->Source, &cm->Trasl);
+
+ pc = rLockVertexPtr(shad->ProjVertsVB, rVBLOCK_NOSYSLOCK);
+
+ for (k = 0; k < cr->NumMeshes(); k++) { // scorre tutte le mesh della stanza
+ t3dMESH &mm = cr->MeshTable[k];
+ if (!(mm.Flags & T3D_MESH_VISIBLE) || (mm.Flags & T3D_MESH_HIDDEN)) continue; // salta se e' nascosta o se non e' visibile
+ if ((mm.Flags & T3D_MESH_MIRROR) || (mm.Flags & T3D_MESH_PORTAL)) continue; // salta se e' un portale o uno specchio
+
+ t3dSetVisibileVertex(mm); // segna le facce che sono backface la luce
+
+ gv = mm.VertexBuffer;
+ pp = &ProjectedPolys[StartVert];
+
+ for (i = 0; i < mm.NumVerts; i++, pp++, gv++, pc++) {
+ memcpy(pc, gv, sizeof(gVertex));
+ pc->diffuse = 0xFFFFFFFF;
+
+ t3dVectInit(&v, gv->x, gv->y, gv->z);
+ t3dVectTransform(&v, &v, &t3dCurViewMatrix);
+ t3dVectAdd(&v, &v, &t3dCurTranslation);
+
+// tempv.rhw = 1.0f/MinSco.z;
+ tempv.x = v.x * tempv.rhw;
+ tempv.y = -v.y * tempv.rhw;
+ tempv.z = v.z;
+ pc->u1 = (tempv.x - MinSco.x) * Aspect.x;
+ pc->v1 = (tempv.y - MinSco.y) * Aspect.y;
+
+ *pp = 0;
+ if (tempv.x < MinSco.x * 4.0f) *pp |= (1 << 1);
+ if (tempv.x > MaxSco.x * 4.0f) *pp |= (1 << 2);
+ if (tempv.y < MinSco.y * 4.0f) *pp |= (1 << 3);
+ if (tempv.y > MaxSco.y * 4.0f) *pp |= (1 << 4);
+ if (tempv.z < MinSco.z) *pp |= (1 << 5);
+ }
+
+ pp = &ProjectedPolys[StartVert];
+ ptr = &shad->pwShadVolCapIndices[shad->num_cap_indices];
+ for (t3dU32 ff = 0; ff < mm.NumFaces(); ff++) {
+ t3dFACE &face = mm.FList[ff];
+ if (!(face.flags & T3D_FACE_VISIBLE))
+ continue;
+
+ if ((pp[face.VertexIndex[0]]) && (pp[face.VertexIndex[1]]) && (pp[face.VertexIndex[2]]))
+ continue;
+
+ *(ptr++) = face.VertexIndex[0] + StartVert;
+ *(ptr++) = face.VertexIndex[1] + StartVert;
+ *(ptr++) = face.VertexIndex[2] + StartVert;
+ shad->num_cap_indices += 3;
+ }
+
+ StartVert += mm.NumVerts;
+ }
+ t3dDealloc(sizeof(t3dU8)*cr->NumTotVerts);
+ rUnlockVertexPtr(shad->ProjVertsVB);
+ pc = nullptr;
+
+ t3dVectSub(&t3dCurTranslation, &cm->Trasl, &light->Source); // punta la luce sull'omino
+ t3dVectTransform(&t3dCurTranslation, &t3dCurTranslation, &t3dCurViewMatrix);
+ t3dMatMul(&t3dCurViewMatrix, &t3dCurViewMatrix, &cm->Matrix);
+
+ if (shad->pwShadVolSideIndices) {
+ kkk = 0;
+ for (i = 0; i < c->Shadow->NumMeshes(); i++) {
+ t3dMESH &mm = c->Shadow->MeshTable[i];
+ for (k = 0; k < mm.NumFaces(); k++) {
+ shad->pwShadVolSideIndices[kkk++] = mm.FList[k].VertexIndex[0];
+ shad->pwShadVolSideIndices[kkk++] = mm.FList[k].VertexIndex[1];
+ shad->pwShadVolSideIndices[kkk++] = mm.FList[k].VertexIndex[2];
+ }
+ }
+ /*f for( k=0; k<cm->NumFaces; k++ )
+ {
+ shad->pwShadVolSideIndices[kkk++] = cm->FList[k].VertexIndex[0];
+ shad->pwShadVolSideIndices[kkk++] = cm->FList[k].VertexIndex[1];
+ shad->pwShadVolSideIndices[kkk++] = cm->FList[k].VertexIndex[2];
+ }f*/
+ shad->num_side_indices = kkk;
+ }
+
+ if (shad->VB) {
+ gv = cm->VertexBuffer;
+ pv = (pVert *)rLockVertexPtr(shad->VB, rVBLOCK_NOSYSLOCK);
+
+ for (i = 0; i < cm->NumVerts; i++, pv++, gv++) {
+ t3dVectInit(&v, gv->x, gv->y, gv->z);
+//f if ( v.y < 60.0f ) v.y -= 60.0f;
+ t3dVectTransform(&v, &v, &t3dCurViewMatrix);
+ t3dVectAdd(&v, &v, &t3dCurTranslation);
+
+ pv->rhw = 1.0f / v.z;
+ pv->x = (v.x * pv->rhw - MinSco.x) * Aspect.x * 256.0f;
+ pv->y = (-v.y * pv->rhw - MinSco.y) * Aspect.y * 256.0f;
+ pv->z = v.z * (1.0f / 30000.0f);
+// pv->diffuse = RGBA_MAKE(1,1,1,sb->Intensity);
+ assert(false);
+#if 0
+ pv->diffuse = RGB_MAKE(255 - sb->Intensity, 255 - sb->Intensity, 255 - sb->Intensity);
+#endif
+// pv->diffuse = RGB_MAKE(128,128,128);
+ }
+ rUnlockVertexPtr(shad->VB);
+ }
+//tb
+#endif
+}
+
+/* -----------------18/06/99 10.47-------------------
+ * t3dAddStencilBufferShadow
+ * --------------------------------------------------*/
+void t3dAddStencilBufferShadow(t3dCHARACTER *c, uint32 CurShadowBox, t3dLIGHT *light) {
+ SHADOWBOX *sb = c->ShadowBox[CurShadowBox];
+ uint32 i, j, k, f, NumVerts;
+ t3dMESH *cm = c->Mesh;
+ t3dV3F tmp, NormLight;
+ t3dM3X3F lm;
+
+ if (!cm || !cm->VertexBuffer)
+ return ;
+//sb
+ t3dVectSub(&NormLight, &cm->Trasl, &light->Source);
+ t3dVectNormalize(&NormLight);
+ t3dVectTransformInv(&NormLight, &NormLight, &cm->Matrix);
+ NormLight.y = - NormLight.y;
+ NormLight.z = - NormLight.z;
+ NormLight.x = - NormLight.x;
+
+ t3dVectSub(&tmp, &cm->Trasl, &t3dCurCamera->Source);
+ tmp.y = 0.0f;
+ t3dVectNormalize(&tmp);
+
+ tmp = tmp * 2.0f;
+ tmp *= c->Radius * 2.0f;
+ t3dVectTransformInv(&tmp, &tmp, &cm->Matrix);
+
+ if (rMakeShadowBox(sb, tmp.x, c->Height, tmp.z, sb->Intensity))
+ return ;
+
+ gVertex *VBptr = cm->VertexBuffer;
+ for (i = 0; i < c->Shadow->NumMeshes(); i++) {
+ t3dMESH &mm = c->Shadow->MeshTable[i];
+ uint32 *FaceList = (uint32 *)t3dAlloc(sizeof(uint32) * mm.NumFaces() * 3);
+ gVertex *VertList = (gVertex *)t3dAlloc(sizeof(gVertex) * mm.NumFaces() * 3);
+ NumVerts = 0;
+ for (k = 0; k < mm.NumFaces(); k++) {
+ for (f = 0; f < 3; f++) {
+ FaceList[NumVerts] = mm.FList[k].VertexIndex[f];
+ for (j = 0; j < NumVerts; j++)
+ if (FaceList[j] == FaceList[NumVerts]) break;
+ if (j >= NumVerts) NumVerts++;
+ }
+ }
+ for (j = 0; j < NumVerts; j++)
+ VertList[j] = VBptr[FaceList[j]];
+
+ t3dVectFill(&tmp, 0.0f);
+ t3dMatView(&lm, &tmp, &NormLight);
+ rMakeShadowVolume(sb, VertList, NumVerts, lm.M);
+
+ t3dDealloc(sizeof(gVertex)*mm.NumFaces() * 3);
+ t3dDealloc(sizeof(uint32) * mm.NumFaces() * 3);
+ }
+//sb
+}
+
+
+/* -----------------10/06/99 15.49-------------------
+ * t3dTransformCharacter
+ * --------------------------------------------------*/
+bool t3dTransformCharacter(t3dCHARACTER *c) {
+ uint32 OldMeshFlags, l, CurShadowBox;
+ t3dV3F tmp, SavedTrasl;
+ t3dBODY *OldCurRoom;
+ t3dM3X3F SavedMat;
+ t3dVERTEX vv;
+ int16 intens;
+
+ if (!c || !c->Body || !c->Mesh) return FALSE;
+ if (c->Flags & T3D_CHARACTER_HIDE)
+ goto enabledinmirror;
+
+ c->CurRoom = t3dCurRoom;
+ if (c->Flags & T3D_CHARACTER_REALTIMELIGHTING)
+ t3dLightCharacter(c);
+
+ bDisableMirrors = 1;
+ if (c->Mesh->ExpressionFrame >= EXPRESSION_SET_LEN) {
+ DebugLogWindow("Errore Espressione");
+ c->Mesh->ExpressionFrame = 0;
+ }
+ c->Mesh->ExpressionFrame += c->CurExpressionSet * EXPRESSION_SET_LEN;
+ if (!t3dTransformBody(c->Body))
+ DebugLogWindow("Can't transform %s", c->Body->name.c_str());
+ c->Mesh->ExpressionFrame -= c->CurExpressionSet * EXPRESSION_SET_LEN;
+ if (c->Mesh) t3dDetectObj(t3dCurCamera, c->Mesh, &t3dCurViewMatrix);
+ bDisableMirrors = 0;
+
+ if ((c->Flags & T3D_CHARACTER_CASTREALTIMESHADOWS) && !bDisableMirrors && (!(LoaderFlags & T3D_NOSHADOWS))) {
+ CurShadowBox = 0;
+ t3dOldUserViewMatrix = t3dCurUserViewMatrix;
+ rSaveViewMatrix();
+
+ t3dVectCopy(&SavedTrasl, &t3dCurTranslation);
+ t3dMatCopy(&SavedMat, &t3dCurViewMatrix);
+ for (l = 0; l < t3dCurRoom->NumLights(); l++) {
+ if (CurShadowBox > 1) continue;
+ if (!(t3dCurRoom->LightTable[l].Type & T3D_LIGHT_REALTIME)) continue;
+ if (!(t3dCurRoom->LightTable[l].Type & T3D_LIGHT_CASTSHADOWS)) continue;
+ if (!(t3dCurRoom->LightTable[l].Type & T3D_LIGHT_LIGHTON)) continue;
+ if ((t3dCurRoom->LightTable[l].Type & T3D_LIGHT_FLARE)) continue;
+
+ t3dVectAdd(&tmp, &c->Body->MeshTable[0].Trasl, &c->Body->MeshTable[0].Pos);
+ if (t3dCurRoom->LightTable[l].Source.y < tmp.y) continue;
+ if (!LightVertex(&vv, &tmp, &t3dCurRoom->LightTable[l])) continue;
+ if ((vv.r + vv.g + vv.b) < 30) continue;
+
+ if (c->ShadowBox[CurShadowBox] == nullptr)
+ c->ShadowBox[CurShadowBox] = t3dCalloc<SHADOWBOX>(1);
+ c->ShadowBox[CurShadowBox]->NumShadowsList = 0;
+ intens = (int16)(vv.r + vv.g + vv.b /*- t3dCurRoom->AmbientLight.x - t3dCurRoom->AmbientLight.y - t3dCurRoom->AmbientLight.z*/) / 4;
+ if (intens < 0) intens = 0;
+ if (intens > 255) intens = 255;
+ c->ShadowBox[CurShadowBox]->Intensity = intens;
+
+ if (!rGetStencilBitDepth()) {
+ c->ShadowBox[CurShadowBox]->ViewMatrixNum = t3dOrigUserViewMatrix;
+ t3dAddTextureBufferShadow(c, CurShadowBox++, &t3dCurRoom->LightTable[l]);
+ } else {
+ c->ShadowBox[CurShadowBox]->ViewMatrixNum = t3dCurUserViewMatrix;
+ t3dAddStencilBufferShadow(c, CurShadowBox++, &t3dCurRoom->LightTable[l]);
+ }
+ }
+ t3dMatCopy(&t3dCurViewMatrix, &SavedMat);
+ t3dVectCopy(&t3dCurTranslation, &SavedTrasl);
+ rRestoreViewMatrix();
+ t3dCurUserViewMatrix = t3dOldUserViewMatrix;
+ }
+
+enabledinmirror:
+ if ((c->Flags & T3D_CHARACTER_ENABLEDINMIRROR) || !(c->Flags & T3D_CHARACTER_HIDE)) {
+ OldMeshFlags = c->Flags;
+ c->Flags &= ~T3D_CHARACTER_HIDE;
+
+ OldCurRoom = t3dCurRoom;
+ t3dCurRoom = c->Body;
+ t3dProcessMirrors(t3dGlobalMirrorList, t3dNumGlobalMirrors);
+ t3dCurRoom = OldCurRoom;
+
+ c->Flags = OldMeshFlags;
+ }
+
+ return TRUE;
+}
+
+/* -----------------10/06/99 15.58-------------------
+ * ProcessWater
+ * --------------------------------------------------*/
+void ProcessWater(t3dMESH &mesh, int32 CurPass, int32 MaxPass) {
+ MaterialPtr mat = mesh.FList[0].mat;
+ uint32 dimx = mat->Texture->DimX;
+ uint32 dimy = mat->Texture->DimY;
+ int32 *dest = mesh.WaterBuffer2 + dimx * 2, *source = mesh.WaterBuffer1 + dimx * 2;
+ uint32 i;
+
+ for (i = dimx; i < (dimx * dimy) - dimx; i++, dest++, source++) {
+ if (((int32)i % MaxPass) != CurPass) continue; // divide il renderig in piu' passi
+
+ *dest = (((*(source - 1) +
+ * (source + 1) +
+ * (source - dimx) +
+ * (source + dimx)) >> 1)) - (*dest);
+ *dest -= ((*dest) >> 10);
+ }
+}
+
+/* -----------------10/06/99 15.58-------------------
+ * t3dRenderWater
+ * --------------------------------------------------*/
+void t3dRenderWater(t3dMESH &mesh, uint32 Type) {
+ MaterialPtr &mat = mesh.FList[0].mat;
+ int32 pitch, Xoffset, Yoffset;
+ int32 dimx = (int32)mat->Texture->DimX;
+ int32 dimy = (int32)mat->Texture->DimY;
+ uint16 *texturesource, *texturedest, *textsource;
+ int32 *WaterBuffer = mesh.WaterBuffer2 + dimx, *AppoWaterBuffer;
+ static int32 WaterPass = 0;
+ int32 R, G, B, A;
+
+//w
+ return ;
+//w
+ if (mat->AddictionalMaterial.empty() || !mat->AddictionalMaterial[0]->Texture)
+ return;
+
+ if (--WaterPass < 0)
+ WaterPass = 4;
+ else {
+ ProcessWater(mesh, WaterPass, 4);
+ return ;
+ }
+
+ textsource = texturesource = (uint16 *)rLockSurfaceDirect(mat->AddictionalMaterial[0]->Texture, (unsigned int *)&pitch);
+ texturedest = (uint16 *)rLockSurfaceDirect(mat->Texture, (unsigned int *)&pitch);
+
+ pitch /= 2;
+ /* for (i=0; i<(dimx*dimy); i++, texturedest+=2,texturesource+=2, WaterBuffer++)
+ {
+ Xoffset=(*(WaterBuffer-1))-(*(WaterBuffer+1));
+ Yoffset=(*(WaterBuffer-dimx))-(*(WaterBuffer+dimx));
+ *texturedest=*(texturesource+((Xoffset*2+Yoffset*pitch)&(dimy*dimy*2-1)));
+ }*/
+
+ for (uint32 j = 0; j < (dimy); j++)
+ for (uint32 i = 0; i < (dimx); i++, texturedest++, WaterBuffer++, textsource++) {
+ if (Type & T3D_MESH_POOLWATER) {
+ Xoffset = ((*(WaterBuffer - 1)) - (*(WaterBuffer + 1))) >> 16;
+ Yoffset = ((*(WaterBuffer - dimx)) - (*(WaterBuffer + dimx))) >> 16;
+ *texturedest = (texturesource[((i + Xoffset) & (dimx - 1)) + (((j + Yoffset) & (dimy - 1)) * pitch)]);
+ } else if (Type & T3D_MESH_RECEIVERIPPLES) {
+ R = ((*textsource) & 0x1f);
+ G = ((*textsource) >> 5) & 0x1f;
+ B = ((*textsource) >> 10) & 0x1f;
+ A = ((*textsource) >> 15) & 1;
+ // if(*WaterBuffer>0)
+ {
+ R += ((*WaterBuffer) >> 16);
+ G += ((*WaterBuffer) >> 16);
+ B += ((*WaterBuffer) >> 16);
+ if (R > 30) R = 30;
+ if (G > 30) G = 30;
+ if (B > 30) B = 30;
+ }
+
+ *texturedest = (R & 0x1f) | ((G & 0x1f) << 5) | ((B & 0x1f) << 10) | (A << 15);
+ }
+ }
+
+
+ rUnlockSurfaceDirect(mat->AddictionalMaterial[0]->Texture);
+ rUnlockSurfaceDirect(mat->Texture);
+
+ AppoWaterBuffer = mesh.WaterBuffer1;
+ mesh.WaterBuffer1 = mesh.WaterBuffer2;
+ mesh.WaterBuffer2 = AppoWaterBuffer;
+
+// DebugLogWindow("--------");
+
+ /* for every pixel (x,y) in the buffer
+ Xoffset = buffer(x-1, y) - buffer(x+1, y)
+ Yoffset = buffer(x, y-1) - buffer(x, y+1)
+ Shading = Xoffset
+ t = texture(x+Xoffset, y+Yoffset)
+ p = t + Shading
+ plot pixel at (x,y) from texture(x+Xoffset, y+Yoffset)
+ end loop*/
+}
+
+/* -----------------10/06/99 15.58-------------------
+ * t3dRenderWaves
+ * --------------------------------------------------*/
+void t3dRenderWaves(gVertex *gv, uint32 NumVerts, t3dF32 mul, t3dF32 Y) {
+ static uint16 Posit = 0;
+ uint32 i;
+ t3dF32 v1, v2, y;
+// gVertex *ogv=gv;
+
+ /* mul=0.00009f;
+ for (i=0; i<NumVerts; i++, ogv++)
+ {
+ if (ogv->u1>2.0f || ogv->v1>2.0f)
+ mul=0.005f;
+ }
+ */
+ for (i = 0; i < NumVerts; i++, gv++) {
+ if (i & 0x1) {
+ v1 = (t3dF32)sin(DEGREE_TO_RADIANS(Posit)) * mul;
+ v2 = (t3dF32)cos(DEGREE_TO_RADIANS(Posit)) * mul;
+ y = (t3dF32)sin(DEGREE_TO_RADIANS(Posit)) * Y;
+ } else {
+ v1 = (t3dF32)cos(DEGREE_TO_RADIANS(Posit)) * mul;
+ v2 = (t3dF32)sin(DEGREE_TO_RADIANS(Posit)) * mul;
+ y = (t3dF32)cos(DEGREE_TO_RADIANS(Posit)) * Y;
+ }
+
+
+ gv->v1 += v1;
+ gv->v2 += v2;
+ gv->u1 += v1;
+ gv->u2 += v2;
+ gv->y += y;
+ }
+
+ Posit++;
+ if (Posit > 360)
+ Posit -= 360;
+
+// Posit=Posit>360 ? 0 : Posit++;
+}
+
+/* -----------------10/06/99 15.58-------------------
+ * t3dMoveTexture
+ * --------------------------------------------------*/
+void t3dMoveTexture(gVertex *gv, uint32 NumVerts, t3dF32 XInc, t3dF32 YInc) {
+ uint32 i;
+
+ for (i = 0; i < NumVerts; i++, gv++) {
+ gv->u1 += XInc;
+ gv->v1 += YInc;
+ }
+}
+
+/* -----------------10/06/99 15.44-------------------
+ * t3dSetFaceVisibility
+ * --------------------------------------------------*/
+void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
+ uint32 pl;
+ int32 j, *nf;
+ int16 LastT1, LastT2, T1, T2;
+ uint32 F1, F2;
+ MaterialPtr Material;
+
+ if (mesh->Flags & T3D_MESH_PORTAL) { // se e' un portale
+ if (bOrigRoom && !bDisableMirrors && (!(mesh->Flags & T3D_MESH_NOPORTALCHECK)) && (mesh->PortalList)) {
+ for (pl = 0; pl < t3dNumPortals; pl++)
+ if (t3dPortalList[pl] == mesh)
+ return;
+ t3dPortalList[t3dNumPortals++] = mesh; // aggiunge a lista portali
+ }
+ return ; // ed esce
+ }
+
+ if (mesh->Flags & T3D_MESH_MIRROR) { // se e' uno specchio
+ if (bOrigRoom && !bDisableMirrors)
+ if ((t3dNumGlobalMirrors + 1) < MAX_MIRRORS)
+ t3dGlobalMirrorList[t3dNumGlobalMirrors++] = mesh; // aggiunge alla lista
+ return; // ed esce
+ }
+
+ LastT1 = LastT2 = -2;
+ T1 = T2 = -1;
+ F1 = F2 = 0;
+ Material = nullptr;
+ Common::Array<uint16> *target = nullptr;
+ int targetIndex = 0;
+ for (uint32 i = 0; i < mesh->NumFaces(); i++) {
+ t3dFACE &f = mesh->FList[i];
+ if (!f.mat || !(f.flags & T3D_FACE_VISIBLE))
+ continue;
+
+ Material = f.mat;
+ T1 = Material->Texture->ID;
+ F1 = Material->Flags;
+
+ if (!bNoLightmapsCalc && f.lightmap) {
+ T2 = f.lightmap->Texture->ID;
+ F2 = f.lightmap->Flags;
+ } else
+ T2 = -1;
+
+ if (Material->Flags & T3D_MATERIAL_ENVIROMENT) { // se ha l'enviroment
+ t3dV3F v;
+ t3dV3F *n;
+ gVertex *gv;
+ t3dM3X3F m;
+
+ t3dMatMul(&m, &mesh->Matrix, &t3dCurViewMatrix);
+
+ if (!(mesh->VBptr = mesh->VertexBuffer))
+ continue;
+
+ gv = &mesh->VBptr[f.VertexIndex[0]];
+ n = &mesh->NList[f.VertexIndex[0]]->n;
+ t3dVectTransform(&v, n, &m);
+ gv->u1 = (v.x);
+ gv->v1 = (v.y);
+ gv = &mesh->VBptr[f.VertexIndex[1]];
+ n = &mesh->NList[f.VertexIndex[1]]->n;
+ t3dVectTransform(&v, n, &m);
+ gv->u1 = (v.x);
+ gv->v1 = (v.y);
+ gv = &mesh->VBptr[f.VertexIndex[2]];
+ n = &mesh->NList[f.VertexIndex[2]]->n;
+ t3dVectTransform(&v, n, &m);
+ gv->u1 = (v.x);
+ gv->v1 = (v.y);
+ mesh->VBptr = nullptr;
+ mesh->Flags |= T3D_MESH_UPDATEVB;
+ }
+
+ if ((T1 != LastT1) || (T2 != LastT2) || !target) {
+ if (T2 > 0) {
+ if (!Material->NumAddictionalMaterial)
+ DebugLogWindow("Error no Sub Material found in %s!", mesh->name.c_str());
+ for (j = 0; j < Material->NumAddictionalMaterial; j++)
+ if (Material->AddictionalMaterial[j]->Texture->ID == T2)
+ break;
+
+ if (j == Material->NumAddictionalMaterial) {
+ DebugLogWindow("Sub Material not found in %s!", mesh->name.c_str());
+ DebugLogWindow("%d %d | %d", Material->NumAddictionalMaterial, T2, f.lightmap->Texture->ID);
+ for (j = 0; j < Material->NumAddictionalMaterial; j++)
+ DebugLogWindow("%d", Material->AddictionalMaterial[j]->Texture->ID);
+ continue;
+
+ }
+ nf = &(Material->AddictionalMaterial[j]->NumFaces);
+ target = &Material->AddictionalMaterial[j]->FacesList;
+ } else {
+ nf = &(Material->NumFaces);
+ target = &Material->FacesList;
+ }
+ LastT1 = T1;
+ LastT2 = T2;
+ }
+
+ // Something is wrong here, as the original game seems to be just writing to NumFaces + 0,1,2, as if there
+ // was space allocated there.
+#if 0
+ target->at(*nf + 0) = f.MatVertexIndex[0];
+ target->at(*nf + 1) = f.MatVertexIndex[1];
+ target->at(*nf + 2) = f.MatVertexIndex[2];
+#endif
+
+ if (*nf + 3 >= target->size()) {
+ // TODO: Why is this hack necessary?
+ warning("NumFaces: %d, Size: %d\n", *nf, target->size());
+/* static bool warned = false;
+ if (!warned) {
+ warned = true;*/
+ warning("Dropping face\n");
+// }
+ target->resize(*nf + 4);
+ //continue;
+ }
+ //warning("LOOK INTO WHY THIS IS BROKEN");
+ (*target)[(*nf + 0)] = f.MatVertexIndex[0];
+ (*target)[(*nf + 1)] = f.MatVertexIndex[1];
+ (*target)[(*nf + 2)] = f.MatVertexIndex[2];
+ *nf += 3;
+
+ StatNumTris++;
+ }
+}
+
+
+/* -----------------10/06/99 15.46-------------------
+ * t3dTransformMesh
+ * --------------------------------------------------*/
+void t3dTransformMesh(t3dMESH &mesh) {
+ if ((mesh.Flags & (T3D_MESH_HIDDEN)) &&
+ ((mesh.Flags & T3D_MESH_CHARACTER)))
+ return;
+
+ if ((bDisableMirrors == 0) && (bViewOnlyPortal == 0)) {
+ t3dDetectObj(t3dCurCamera, &mesh, &t3dCurViewMatrix);
+
+//s if (t3dSun)
+//s t3dCheckIfFlaresRayVisible(t3dCurCamera->Source,t3dSun->LightTable[0].Source, mesh);
+ }
+
+ t3dSetVisibileVertex(mesh); // setta tutti i vertici visibili della mesh
+ t3dCalcMeshBones(&mesh, 0); // calcola eventuali bones
+
+ //setup indices array, texture mapping and materials states
+ if ((!(mesh.Flags & T3D_MESH_HIDDEN)))
+ t3dSetFaceVisibility(&mesh, t3dCurCamera);
+
+ if (bOrigRoom && !bDisableMirrors) { // Solo se e' nella stanza principale
+ if (mesh.Flags & T3D_MESH_RECEIVERIPPLES)
+ t3dRenderWater(mesh, T3D_MESH_RECEIVERIPPLES);
+ else if (mesh.Flags & T3D_MESH_POOLWATER)
+ t3dRenderWater(mesh, T3D_MESH_POOLWATER);
+
+ if (mesh.Flags & T3D_MESH_WAVESTEXTURE || (mesh.XInc) || (mesh.YInc)) {
+ if (!(mesh.VBptr = mesh.VertexBuffer))
+ return;
+
+ if (mesh.Flags & T3D_MESH_WAVESTEXTURE)
+ t3dRenderWaves(mesh.VBptr, mesh.NumVerts, mesh.WavesSpeed, mesh.YSpeed);
+
+ if ((mesh.XInc) || (mesh.YInc))
+ t3dMoveTexture(mesh.VBptr, mesh.NumVerts, mesh.XInc, mesh.YInc);
+
+ mesh.Flags |= T3D_MESH_UPDATEVB;
+ mesh.VBptr = nullptr;
+ }
+ }
+}
+
+void t3dCAMERA::normalizedSight() {
+ t3dV3F normalizedSightOfView = this->Target - this->Source;
+ t3dVectNormalize(&normalizedSightOfView);
+ this->NormalizedDir = normalizedSightOfView;
+}
+
+/* -----------------10/06/99 15.48-------------------
+ * t3dCalcHalos
+ * --------------------------------------------------*/
+void t3dCalcHalos(t3dBODY *b) {
+ gMaterial *Material;
+ int16 T1;
+ uint32 F1, uvbc;
+ uint32 i;
+ gVertex *gv;
+ t3dF32 size;
+ //uint16 *fp;
+ t3dV3F v0, v1, v2, v3, tmp;
+
+ for (i = 0; i < b->NumLights(); i++) {
+ t3dLIGHT &l = b->LightTable[i];
+ if (!(l.Type & T3D_LIGHT_LIGHTON)) continue;
+
+ if (l.Type & T3D_LIGHT_FLARE)
+ break;
+ }
+ if (i >= b->NumLights()) return ;
+
+ t3dOldUserViewMatrix = t3dCurUserViewMatrix;
+ rSaveViewMatrix();
+ tmp.x = -t3dCurCamera->Source.x;
+ tmp.y = -t3dCurCamera->Source.y;
+ tmp.z = -t3dCurCamera->Source.z;
+ t3dVectTransform(&tmp, &tmp, &t3dCurViewMatrix);
+ rSetViewMatrix(t3dCurViewMatrix, tmp);
+ t3dCurUserViewMatrix = rAddUserViewMatrix(t3dCurViewMatrix, tmp);
+
+ uvbc = rGetUserVertexBufferCounter();
+ gv = rLockVertexPtr(rGetUserVertexBuffer(), rVBLOCK_NOSYSLOCK);
+ gv += uvbc;
+
+ for (i = 0; i < b->NumLights(); i++) {
+ t3dLIGHT &l = b->LightTable[i];
+ if (!(l.Type & T3D_LIGHT_LIGHTON)) continue;
+
+ if (l.Type & T3D_LIGHT_FLARE) {
+ Material = &l.Material[0];
+ T1 = Material->Texture->ID;
+ F1 = Material->Flags;
+
+ size = l.FlareSize;
+
+ v0.x = -size;
+ v0.y = size;
+ v0.z = 0.0f;
+ t3dVectTransformInv(&v0, &v0, &t3dCurViewMatrix);
+
+ v1.x = size;
+ v1.y = size;
+ v1.z = 0.0f;
+ t3dVectTransformInv(&v1, &v1, &t3dCurViewMatrix);
+
+ v2.x = -size;
+ v2.y = -size;
+ v2.z = 0.0f;
+ t3dVectTransformInv(&v2, &v2, &t3dCurViewMatrix);
+
+ v3.x = size;
+ v3.y = -size;
+ v3.z = 0.0f;
+ t3dVectTransformInv(&v3, &v3, &t3dCurViewMatrix);
+
+ uint16 &fp = Material->FacesList[Material->NumFaces];
+ Material->FacesList[Material->NumFaces + 0] = 0 + uvbc;
+ Material->FacesList[Material->NumFaces + 1] = 1 + uvbc;
+ Material->FacesList[Material->NumFaces + 2] = 2 + uvbc;
+ StatNumTris++;
+ Material->NumFaces += 3;
+
+ Material->FacesList[Material->NumFaces + 3] = 2 + uvbc;
+ Material->FacesList[Material->NumFaces + 4] = 3 + uvbc;
+ Material->FacesList[Material->NumFaces + 5] = 1 + uvbc;
+ StatNumTris++;
+ Material->NumFaces += 3;
+
+ gv[0].x = v0.x + l.Source.x;
+ gv[0].y = v0.y + l.Source.y;
+ gv[0].z = v0.z + l.Source.z;
+ gv[0].u2 = gv[0].u1 = 0.0f;
+ gv[0].v2 = gv[0].v1 = 0.0f;
+ gv[1].x = v1.x + l.Source.x;
+ gv[1].y = v1.y + l.Source.y;
+ gv[1].z = v1.z + l.Source.z;
+ gv[1].u2 = gv[1].u1 = 1.0f;
+ gv[1].v2 = gv[1].v1 = 0.0f;
+ gv[2].x = v2.x + l.Source.x;
+ gv[2].y = v2.y + l.Source.y;
+ gv[2].z = v2.z + l.Source.z;
+ gv[2].u2 = gv[2].u1 = 0.0f;
+ gv[2].v2 = gv[2].v1 = 1.0f;
+ gv[3].x = v3.x + l.Source.x;
+ gv[3].y = v3.y + l.Source.y;
+ gv[3].z = v3.z + l.Source.z;
+ gv[3].u2 = gv[3].u1 = 1.0f;
+ gv[3].v2 = gv[3].v1 = 1.0f;
+
+ gv[0].diffuse = gv[1].diffuse = gv[2].diffuse = gv[3].diffuse = RGBA_MAKE((uint32)l.Color.x, (uint32)l.Color.y, (uint32)l.Color.z, 255);
+
+// rProcessVertices(rGetUserVertexBuffer(), t3dStartIndex,4);
+ t3dStartIndex += 4;
+ StatNumVerts += 4;
+ uvbc += 4;
+ gv += 4;
+
+ rAddToMaterialList(l.Material[0], t3dCurUserViewMatrix);
+ }
+ }
+ rUnlockVertexPtr(rGetUserVertexBuffer());
+ rSetUserVertexBufferCounter(uvbc);
+
+ rRestoreViewMatrix();
+ t3dCurUserViewMatrix = t3dOldUserViewMatrix;
+}
+
+/* -----------------10/06/99 15.53-------------------
+ * t3dAddParticle
+ * --------------------------------------------------*/
+void t3dAddParticle(gMaterial *Material, t3dV3F *Source, t3dF32 size, t3dV3F Color, uint32 num) {
+ int16 T1;
+ uint32 F1, uvbc;
+ gVertex *gv;
+ t3dV3F v0, v1, v2, v3;
+ uint32 rr, gg, bl, i;
+
+ warning("TODO: t3dAddParticle\n");
+ return;
+#if 0
+ uvbc = rGetUserVertexBufferCounter();
+ gv = rLockVertexPtr(rGetUserVertexBuffer(), rVBLOCK_NOSYSLOCK);
+ gv += uvbc;
+
+ T1 = Material->Texture->ID;
+ F1 = Material->Flags;
+
+ uint32 faceOffset = Material->NumFaces;
+
+ for (i = 0; i < num; i++, gv += 4) {
+ v0.x = -size;
+ v0.y = size;
+ v0.z = 0.0f;
+ t3dVectTransformInv(&v0, &v0, &t3dCurViewMatrix);
+
+ v1.x = size;
+ v1.y = size;
+ v1.z = 0.0f;
+ t3dVectTransformInv(&v1, &v1, &t3dCurViewMatrix);
+
+ v2.x = -size;
+ v2.y = -size;
+ v2.z = 0.0f;
+ t3dVectTransformInv(&v2, &v2, &t3dCurViewMatrix);
+
+ v3.x = size;
+ v3.y = -size;
+ v3.z = 0.0f;
+ t3dVectTransformInv(&v3, &v3, &t3dCurViewMatrix);
+
+ Material->FacesList[faceOffset++] = 0 + uvbc;
+ Material->FacesList[faceOffset++] = 1 + uvbc;
+ Material->FacesList[faceOffset++] = 2 + uvbc;
+ StatNumTris++;
+ Material->NumFaces += 3;
+
+ Material->FacesList[faceOffset++] = 2 + uvbc;
+ Material->FacesList[faceOffset++] = 3 + uvbc;
+ Material->FacesList[faceOffset++] = 1 + uvbc;
+ StatNumTris++;
+ Material->NumFaces += 3;
+
+ gv[0].x = v0.x + Source->x;
+ gv[0].y = v0.y + Source->y;
+ gv[0].z = v0.z + Source->z;
+ gv[0].u2 = gv[0].u1 = 0.0f;
+ gv[0].v2 = gv[0].v1 = 0.0f;
+ gv[1].x = v1.x + Source->x;
+ gv[1].y = v1.y + Source->y;
+ gv[1].z = v1.z + Source->z;
+ gv[1].u2 = gv[1].u1 = 1.0f;
+ gv[1].v2 = gv[1].v1 = 0.0f;
+ gv[2].x = v2.x + Source->x;
+ gv[2].y = v2.y + Source->y;
+ gv[2].z = v2.z + Source->z;
+ gv[2].u2 = gv[2].u1 = 0.0f;
+ gv[2].v2 = gv[2].v1 = 1.0f;
+ gv[3].x = v3.x + Source->x;
+ gv[3].y = v3.y + Source->y;
+ gv[3].z = v3.z + Source->z;
+ gv[3].u2 = gv[3].u1 = 1.0f;
+ gv[3].v2 = gv[3].v1 = 1.0f;
+
+ rr = (uint32)(Color.x);
+ gg = (uint32)(Color.y);
+ bl = (uint32)(Color.z);
+
+ gv[0].diffuse = gv[1].diffuse = gv[2].diffuse = gv[3].diffuse = RGBA_MAKE((uint32)rr, gg, bl, rand() % 255);
+
+ StatNumVerts += 4;
+ uvbc += 4;
+ }
+
+// rProcessVertices(rGetUserVertexBuffer(), t3dStartIndex,num*4);
+ t3dStartIndex += num * 4;
+
+ rUnlockVertexPtr(rGetUserVertexBuffer());
+ rSetUserVertexBufferCounter(uvbc);
+#endif
+}
+
+/* -----------------10/06/99 15.57-------------------
+ * t3dRaiseSmoke
+ * --------------------------------------------------*/
+void t3dRaiseSmoke(t3dV3F *pos, t3dParticle *p) {
+ uint32 i, j = p->ParticleIndex;
+ Particle *pPos;
+// t3dV3F Color;
+
+// if (Particles[j].NumParticles<NumParticles)
+// Particles[j].NumParticles++;
+
+// if (j==0)
+// return ;//Particles[j].NumParticles=0;
+ pPos = &Particles[j].ParticlePos[Particles[j].FirstParticleRendered];
+ for (i = Particles[j].FirstParticleRendered; i < Particles[j].NumParticles; i++, pPos++) {
+ if (pPos->Flags & T3D_PARTICLE_ACTIVE)
+ t3dAddParticle(&Particles[j].Material, &pPos->Pos, pPos->Size, pPos->Color, 1);
+ }
+ pPos = Particles[j].ParticlePos;
+ for (i = 0; i < Particles[j].FirstParticleRendered; i++, pPos++) {
+ if (pPos->Flags & T3D_PARTICLE_ACTIVE)
+ t3dAddParticle(&Particles[j].Material, &pPos->Pos, pPos->Size, pPos->Color, 1);
+ }
+
+ pPos = Particles[j].ParticlePos;
+ for (i = 0; i < Particles[j].NumParticles; i++, pPos++) {
+ if (pPos->Flags & T3D_PARTICLE_ACTIVE) {
+// t3dAddParticle(&Particles[j].Material, &pPos->Pos, pPos->Size, pPos->Color, 1);
+ pPos->Pos.y += p->Speed;
+ if (pPos->Pos.y < pos->y + p->Seg1) {
+ pPos->Size += p->Dim1;
+ pPos->Pos.x += p->Caos1 * Particles[j].RandTable[(uint32)pPos->Pos.y & 0xf];
+ if ((pPos->Color.x += p->R2) > 255.0f) pPos->Color.x = 255.0f;
+ if ((pPos->Color.y += p->G2) > 255.0f) pPos->Color.y = 255.0f;
+ if ((pPos->Color.z += p->B2) > 255.0f) pPos->Color.z = 255.0f;
+ } else {
+ if ((pPos->Color.x += p->R3) > 255.0f) pPos->Color.x = 255.0f;
+ if ((pPos->Color.y += p->G3) > 255.0f) pPos->Color.y = 255.0f;
+ if ((pPos->Color.z += p->B3) > 255.0f) pPos->Color.z = 255.0f;
+ pPos->Pos.x += p->Caos2 * Particles[j].RandTable[(uint32)pPos->Pos.y & 0xf];
+ if (pPos->Pos.y > pos->y + p->Seg2)
+ pPos->Size -= p->Dim2;
+ else
+ pPos->Size += p->Dim2;
+ }
+ if (pPos->Pos.y > pos->y + p->Lung) {
+ pPos->Flags &= ~T3D_PARTICLE_ACTIVE;
+ pPos->Flags |= T3D_PARTICLE_REGEN;
+
+ if (Particles[j].FirstParticleRendered <= Particles[j].NumParticles - 1)
+ Particles[j].FirstParticleRendered++;
+ else
+ Particles[j].FirstParticleRendered = 0;
+ }
+ } else {
+ if ((!(Particles[j].ParticleWait) || (pPos->Flags & T3D_PARTICLE_REGEN))) {
+ error("TODO: Complete particle support");
+#if 0
+ pPos->Flags &= ~T3D_PARTICLE_REGEN;
+ pPos->Flags |= T3D_PARTICLE_ACTIVE;
+ pPos->Pos.x = pos->x;
+ pPos->Pos.y = pos->y;
+ pPos->Pos.z = pos->z;
+ pPos->Size = p->Size;
+ pPos->Color.x = p->R1;
+ pPos->Color.y = p->G1;
+ pPos->Color.z = p->B1;
+ Particles[j].RandTable[i & 0xf] = rand() % 3 - 1;
+ Particles[j].ParticleWait = p->Delay;
+#endif
+ }
+ }
+ }
+
+ Particles[j].ParticleWait--;
+
+ rAddToMaterialList(Particles[j].Material, t3dCurUserViewMatrix);
+}
+
+/* -----------------10/06/99 15.48-------------------
+ * t3dAnimLights
+ * --------------------------------------------------*/
+void t3dAnimLights(t3dBODY *b) {
+// t3dU8 exist=0;
+ gVertex **vlist, *vv;
+ int32 rr, gg, bb, aa;
+ uint8 bProcessLights;
+
+ if (b->LightTable.empty())
+ return;
+
+ if (b->LightTable[0].Type & T3D_LIGHT_ALLLIGHTSOFF)
+ return;
+
+ t3dCalcHalos(b); //Calculate flare/halos for lights
+
+ int i = 0;
+ bProcessLights = 0;
+ while ((i < b->NumLights())) {
+ t3dLIGHT &l = b->LightTable[i];
+ if (l.Type & T3D_LIGHT_CANDLESMOKE)
+ t3dRaiseSmoke(&l.Source, l.Particle.get());
+ else if (l.Type & T3D_LIGHT_PULSE) {
+ error("TODO: Pulsing lights");
+#if 0
+ bProcessLights = 1;
+ l.LightRandomizer = -rand() % ((int32)(l.Color.x + l.Color.y + l.Color.z) / 12);
+#endif
+ }
+ i++;
+ }
+
+ if (bProcessLights) {
+ //lock all vertexbuffers
+ for (int i = 0; i < b->NumMeshes(); i++) {
+ t3dMESH &m = b->MeshTable[i];
+ m.VBptr = m.VertexBuffer;
+ m.Flags |= T3D_MESH_UPDATEVB;
+ }
+
+ for (auto &l : b->LightTable) {
+ if (!(l.Type & T3D_LIGHT_PULSE) || !(l.Type & T3D_LIGHT_LIGHTON)) continue;
+
+ if (l.FlickerDelay > (l.Flicker)) {
+ l.FlickerDelay = 0;
+ for (int j = 0; j < l.AnimLight.NumVisVerts(); j++) {
+ vv = l.AnimLight.VisVerts[j];
+ rr = RGBA_GETRED(vv->diffuse);
+ gg = RGBA_GETGREEN(vv->diffuse);
+ bb = RGBA_GETBLUE(vv->diffuse);
+ aa = RGBA_GETALPHA(vv->diffuse);
+ rr += l.AnimLight.LastRandomizer + l.LightRandomizer;
+ gg += l.AnimLight.LastRandomizer + l.LightRandomizer;
+ bb += l.AnimLight.LastRandomizer + l.LightRandomizer;
+ if (rr < 0) rr = 0;
+ if (gg < 0) gg = 0;
+ if (bb < 0) bb = 0;
+ if (rr > 255) rr = 255;
+ if (gg > 255) gg = 255;
+ if (bb > 255) bb = 255;
+
+ vv->diffuse = RGBA_MAKE(rr, gg, bb, aa);
+ }
+ l.AnimLight.LastRandomizer = -l.LightRandomizer;
+ }
+ l.FlickerDelay++;
+ }
+ //lock all vertexbuffers
+ for (i = 0; i < b->NumMeshes(); i++) {
+ b->MeshTable[i].VBptr = nullptr;
+ }
+ }
+}
+
+/* -----------------29/07/99 16.13-------------------
+ * t3dCheckMaterialVB
+ * --------------------------------------------------*/
+void t3dCheckMaterialVB(MaterialPtr mat) {
+ if (!mat || (mat->NumAllocatedVerts < 3))
+ return ;
+
+ int i;
+ for (i = 0; i < mat->NumAllocatedMesh; i++)
+ if (*(mat->FlagsList[i]) & T3D_MESH_UPDATEVB)
+ break;
+
+ if (i >= mat->NumAllocatedMesh)
+ return ;
+
+ //warning("TODO: Implement t3dCheckMaterialVB\n");
+// gv = rLockVertexPtr(mat->VB, DDLOCK_WRITEONLY | DDLOCK_NOSYSLOCK);
+ mat->VBO->_buffer.clear();
+ for (int i = 0; i < mat->NumAllocatedVerts; i++) {
+ auto vert = *mat->VertsList[i];
+ mat->VBO->_buffer.push_back(vert);
+ //memcpy(gv, mat->VertsList[i], sizeof(gVertex));
+ }
+
+// rUnlockVertexPtr(mat->VB);
+
+}
+
+/* -----------------10/06/99 15.49-------------------
+ * t3dTransformBody
+ * --------------------------------------------------*/
+bool t3dTransformBody(t3dBODY *b) {
+ if (b == nullptr) return false;
+
+ if ((t3dOrigRoom == b) && !(bDisableMirrors)) // If I'm in the main room
+ bOrigRoom = 1;
+ else
+ bOrigRoom = 0;
+
+ //Normalize view (normalized too many times; can be optimized)
+ t3dCurCamera->normalizedSight();
+
+ //Check if all light are turned off
+ bNoLightmapsCalc = 0;
+ if (!b->LightTable.empty() && b->LightTable[0].Type & T3D_LIGHT_ALLLIGHTSOFF)
+ bNoLightmapsCalc = 1;
+
+ //Do primary backface culling
+//f
+ t3dV3F Sight;
+ t3dVectTransformInv(&Sight, &t3dCurCamera->Source, &b->MeshTable[0].Matrix);
+#if 0
+ t3dBackfaceCulling(b->NList, b->NumNormals/*+b->NumVerticesNormals*/, &Sight);
+#endif
+// t3dBackfaceCulling(b->NList, b->NumNormals/*+b->NumVerticesNormals*/, &t3dCurCamera->Source);
+//f
+ //Setting up transformation matrices. Mesh-Translation for moved/moveable objects
+ t3dCurTranslation = -t3dCurCamera->Source + b->MeshTable[0].Trasl;
+ t3dVectTransform(&t3dCurTranslation, &t3dCurTranslation, &t3dCurViewMatrix); // rotate by the camera matrix
+//f
+ t3dM3X3F LastViewMatrix;
+ t3dMatCopy(&LastViewMatrix, &t3dCurViewMatrix); // Save original view-matrix
+ t3dMatMul(&t3dCurViewMatrix, &t3dCurViewMatrix, &b->MeshTable[0].Matrix);
+//f
+ rSetViewMatrix(t3dCurViewMatrix, t3dCurTranslation);
+ t3dCurUserViewMatrix = rAddUserViewMatrix(t3dCurViewMatrix, t3dCurTranslation);
+ if (bOrigRoom)
+ t3dOrigUserViewMatrix = t3dCurUserViewMatrix;
+
+ //Lights Animations (flicker, pulse etc etc)
+ t3dAnimLights(b);
+//f
+ t3dMatCopy(&t3dCurViewMatrix, &LastViewMatrix); // Restore original matrix
+//f
+
+ // Remove the meshes that remain behind BlockMesh
+ if (bOrigRoom)
+ for (uint32 j = 0; j < T3D_MAX_BLOCK_MESHES; j++)
+ t3dCheckBlockMesh(b->MeshTable, b->NumMeshes(), b->BlockMeshes[j]);
+
+ //Main loop through the meshes
+ for (uint32 i = 0; i < b->NumMeshes(); i++) {
+ t3dMESH &m = b->MeshTable[i];
+ if ((!(m.Flags & (T3D_MESH_HIDDEN | T3D_MESH_INVISIBLEFROMSECT | T3D_MESH_PORTALPROCESSED))) && // hidden or invisible
+ (bDisableMirrors || !(m.Flags & T3D_MESH_ONLYINMIRRORS)) && // only in mirrors
+ (t3dCheckBoundSphere(m)) && // check bound-sphere
+ !((m.NumFaces() > 16) && !t3dCheckBoundBox(m))) { // check bound-box
+ // Set visible
+ m.Flags |= T3D_MESH_VISIBLE;
+ // If viewed from a portal, mark it as processed to avoid double rendering
+ if (bPortalRoom) m.Flags |= T3D_MESH_PORTALPROCESSED;
+ // Transform mesh. This function also apply bones deformation and other mesh modifications
+ t3dTransformMesh(m);
+
+ // Now send vertices to render.dll for transformations
+ if ((!(m.Flags & T3D_MESH_HIDDEN) && (!(m.Flags & T3D_MESH_MIRROR)) && (!(m.Flags & T3D_MESH_PORTAL)))) {
+ t3dStartIndex += m.NumVerts;
+ StatNumVerts += m.NumVerts;
+ }
+ } else
+ m.Flags &= ~(T3D_MESH_VISIBLE | T3D_MESH_INVISIBLEFROMSECT); //Mesh is invisible
+ }
+
+ //Now build up the material lists. Check also if lightmaps are active;if active process lightmaps
+ for (auto &mat : b->MatTable) {
+ if (!mat) continue;
+
+ t3dCheckMaterialVB(mat);
+
+ for (auto &cm : mat->AddictionalMaterial) {
+ t3dCheckMaterialVB(cm);
+ }
+//f rAddToMaterialList( mat, t3dCurUserViewMatrix );
+ }
+ QueueMaterialList(b->MatTable, b->NumMaterials(), t3dCurUserViewMatrix);
+
+ for (uint32 i = 0; i < b->NumMeshes(); i++) {
+ b->MeshTable[i].Flags &= ~T3D_MESH_UPDATEVB;
+ }
+
+ //if there are mirrors in the body is now time to process them...
+ if (!bDisableMirrors && bOrigRoom)
+ t3dProcessMirrors(t3dGlobalMirrorList, t3dNumGlobalMirrors);
+
+ bOrigRoom = 0;
+ return true;
+}
+
+/* -----------------10/06/99 15.53-------------------
+ * t3dAddLensFlare
+ * --------------------------------------------------*/
+void t3dAddLensFlare(gMaterial *Material, t3dV3F *Source, t3dF32 size, t3dF32 perc2, t3dV3F Color) {
+ uint32 uvbc;
+ gVertex *gv;
+ t3dV3F v0, v1, v2, v3;
+ int32 rr, gg, bb;
+
+ warning("TODO: t3dAddLensFlare\n");
+ return;
+#if 0
+ uvbc = rGetUserVertexBufferCounter();
+ gv = rLockVertexPtr(rGetUserVertexBuffer(), rVBLOCK_NOSYSLOCK);
+ gv += uvbc;
+
+// for (i=0; i<num; i++)
+ {
+
+
+ v0.x = -size;
+ v0.y = size;
+ v0.z = 0.0f;
+ t3dVectTransformInv(&v0, &v0, &t3dCurViewMatrix);
+
+ v1.x = size;
+ v1.y = size;
+ v1.z = 0.0f;
+ t3dVectTransformInv(&v1, &v1, &t3dCurViewMatrix);
+
+ v2.x = -size;
+ v2.y = -size;
+ v2.z = 0.0f;
+ t3dVectTransformInv(&v2, &v2, &t3dCurViewMatrix);
+
+ v3.x = size;
+ v3.y = -size;
+ v3.z = 0.0f;
+ t3dVectTransformInv(&v3, &v3, &t3dCurViewMatrix);
+
+ int faceIndex = Material->NumFaces;
+ Material->FacesList[faceIndex++] = 0 + uvbc;
+ Material->FacesList[faceIndex++] = 1 + uvbc;
+ Material->FacesList[faceIndex++] = 2 + uvbc;
+ StatNumTris++;
+ Material->NumFaces += 3;
+
+ Material->FacesList[faceIndex++] = 2 + uvbc;
+ Material->FacesList[faceIndex++] = 3 + uvbc;
+ Material->FacesList[faceIndex++] = 1 + uvbc;
+ StatNumTris++;
+ Material->NumFaces += 3;
+
+ gv[0].x = v0.x + Source->x;
+ gv[0].y = v0.y + Source->y;
+ gv[0].z = v0.z + Source->z;
+ gv[0].u2 = gv[0].u1 = 0.0f;
+ gv[0].v2 = gv[0].v1 = 0.0f;
+ gv[1].x = v1.x + Source->x;
+ gv[1].y = v1.y + Source->y;
+ gv[1].z = v1.z + Source->z;
+ gv[1].u2 = gv[1].u1 = 1.0f;
+ gv[1].v2 = gv[1].v1 = 0.0f;
+ gv[2].x = v2.x + Source->x;
+ gv[2].y = v2.y + Source->y;
+ gv[2].z = v2.z + Source->z;
+ gv[2].u2 = gv[2].u1 = 0.0f;
+ gv[2].v2 = gv[2].v1 = 1.0f;
+ gv[3].x = v3.x + Source->x;
+ gv[3].y = v3.y + Source->y;
+ gv[3].z = v3.z + Source->z;
+ gv[3].u2 = gv[3].u1 = 1.0f;
+ gv[3].v2 = gv[3].v1 = 1.0f;
+
+ rr = (uint32)(Color.x - perc2);
+ gg = (uint32)(Color.y - perc2);
+ bb = (uint32)(Color.z - perc2);
+ if (rr < 0) rr = 0;
+ if (gg < 0) gg = 0;
+ if (bb < 0) bb = 0;
+ if (rr > 255) rr = 255;
+ if (gg > 255) gg = 255;
+ if (bb > 255) bb = 255;
+
+ gv[0].diffuse = gv[1].diffuse = gv[2].diffuse = gv[3].diffuse = RGBA_MAKE((uint32)rr, gg, bb, rand() % 255);
+
+// rProcessVertices(rGetUserVertexBuffer(), t3dStartIndex,4);
+ t3dStartIndex += 4;
+ StatNumVerts += 4;
+ uvbc += 4;
+ }
+
+ rUnlockVertexPtr(rGetUserVertexBuffer());
+ rSetUserVertexBufferCounter(uvbc);
+#endif
+}
+
+/* -----------------10/06/99 15.54-------------------
+ *
+ * --------------------------------------------------*/
+uint8 t3dPointInFrustum(t3dV3F pos) {
+ t3dF32 d1;
+
+ t3dVectSub(&pos, &pos, &t3dCurCamera->Source);
+ t3dVectTransform(&pos, &pos, &t3dCurViewMatrix); // rotate by the mesh matrix
+
+ d1 = t3dVectDot(&pos, &ClipPlanes[RIGHTCLIP].n) + ClipPlanes[RIGHTCLIP].dist;
+ if ((d1 > 0)) {
+ d1 = ClipPlanes[LEFTCLIP].dist + t3dVectDot(&pos, &ClipPlanes[LEFTCLIP].n);
+ if ((d1 > 0)) {
+ d1 = ClipPlanes[TOPCLIP].dist + t3dVectDot(&pos, &ClipPlanes[TOPCLIP].n);
+ if ((d1 > 0)) {
+ d1 = ClipPlanes[BOTTOMCLIP].dist + t3dVectDot(&pos, &ClipPlanes[BOTTOMCLIP].n);
+ if ((d1 > 0)) {
+ return 1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+
+/*
+ * -----------------10/06/99 15.54-------------------
+ * t3dTransformSky
+ * --------------------------------------------------*/
+void t3dTransformSky(void) {
+ gVertex *gv;
+ t3dBODY *sky = t3dSky;
+ t3dBODY *sun = nullptr; //s t3dSun;
+ t3dV3F SunDir, color, inc, pos, tmp;
+ t3dF32 perc;
+ static t3dV3F OldSunPosition;
+// static t3dU32 value;
+
+ if (sky) {
+ for (uint32 i = 0; i < sky->NumMeshes(); i++) {
+ t3dVectCopy(&sky->MeshTable[i].Trasl, &t3dCurCamera->Source);
+ }
+ if (!t3dTransformBody(sky)) {
+ DebugLogWindow("Can't transform %s", t3dSky->name.c_str());
+ }
+
+ gv = t3dSky->MeshTable[0].VertexBuffer;
+ for (uint32 i = 0; i < t3dSky->MeshTable[0].NumVerts; i++, gv++) {
+ gv->u1 += SKY_SPEED;
+ gv->v1 += SKY_SPEED;
+ }
+ t3dSky->MeshTable[0].Flags |= T3D_MESH_UPDATEVB;
+ }
+
+ if (sun) {
+ t3dF32 size;
+// t3dV3F v1;
+// unsigned short *p;
+// t3dS32 pitch;
+ t3dF32 perc2;
+ uint32 rr = 50, gg = 50, bb = 50/*,aa*/;
+
+ /* p=(unsigned short*)rLockSurface(SkySurface, &pitch);
+ pitch/=2;
+
+ v1.x=SunPositionInTexture.x;
+ v1.y=SunPositionInTexture.y;
+ if ((v1.x<0.0f) || (v1.y<0.0f) || (v1.x>1.0f) || (v1.x>1.0f))
+ return;
+ rSurfaceFormatToRGBA((WORD)p[(t3dU32)(v1.x*256.0f)+(t3dU32)(v1.y*256.0f)*pitch],
+ &rr,&gg,&bb,&aa);
+ // p[(t3dU32)(v1.x*256.0f)+(t3dU32)(v1.y*256.0f)*pitch]=(short)rRGBAToSurfaceFormat(rand(),rand(),rand(),255);
+ // p[(t3dU32)(0.5f*256.0f)+(t3dU32)(0.5f*256.0f)*pitch]=(short)rRGBAToSurfaceFormat(rand(),rand(),rand(),aa);
+ rUnlockSurface(SkySurface);
+ */
+
+ t3dSky->MatTable[1]->Texture = (SkySurface);
+
+
+ perc2 = ((((rr + gg + bb) * (1.0f / 3.0f))));
+
+ t3dOldUserViewMatrix = t3dCurUserViewMatrix;
+ rSaveViewMatrix();
+ tmp = -t3dCurCamera->Source;
+ t3dVectTransform(&tmp, &tmp, &t3dCurViewMatrix);
+
+ rSetViewMatrix(t3dCurViewMatrix, tmp);
+ t3dCurUserViewMatrix = rAddUserViewMatrix(t3dCurViewMatrix, tmp);
+
+ auto &l = sun->LightTable[0];
+
+ t3dVectSub(&SunDir, &l.Source, &t3dCurCamera->Source);
+ t3dVectNormalize(&SunDir);
+ perc = t3dVectDot(&SunDir, &t3dCurCamera->NormalizedDir);
+
+ if ((l.Type & T3D_LIGHT_FLARE) && (perc > 0)) {
+ t3dV3F appo, appo2;
+
+ size = (perc * perc2) * 180; //f era: 500
+
+ t3dVectSub(&appo, &t3dCurCamera->Source, &OldSunPosition);
+ t3dVectCopy(&OldSunPosition, &t3dCurCamera->Source);
+ appo2.x = l.Source.x + appo.x;
+ appo2.y = 8000; //f era: 7000
+ appo2.z = l.Source.z + appo.z;
+
+ if (t3dPointInFrustum(appo2) && (LastFlaresVisible)) {
+ //Draw Lensflares
+ l.Source.y = 8000; //f era: 7000
+
+ t3dVectCopy(&pos, &t3dCurCamera->Source);
+ t3dVectCopy(&inc, &t3dCurCamera->NormalizedDir);
+ inc *= 2200.0f;
+ t3dVectAdd(&pos, &pos, &inc);
+ t3dVectSub(&SunDir, &l.Source, &pos);
+ inc.x = (SunDir.x / 3);
+ inc.y = (SunDir.y / 3);
+ inc.z = (SunDir.z / 3);
+
+ perc = 1.0f - ((1.0f - perc) / 0.15f);
+
+ t3dVectCopy(&pos, &l.Source);
+
+ color.x = 0 * perc;
+ color.y = 155 * perc;
+ color.z = 155 * perc;
+ t3dVectSub(&pos, &pos, &inc);
+ t3dAddLensFlare(&l.Material[1], &pos, 500, 0, color);
+
+ color.x = 0 * perc;
+ color.y = 155 * perc;
+ color.z = 200 * perc;
+ t3dVectSub(&pos, &pos, &inc);
+ t3dAddLensFlare(&l.Material[1], &pos, 400, 0, color);
+
+ color.x = 0 * perc;
+ color.y = 55 * perc;
+ color.z = 155 * perc;
+ inc *= 0.8f;
+ t3dVectSub(&pos, &pos, &inc);
+ t3dAddLensFlare(&l.Material[1], &pos, 100, 0, color);
+
+ color.x = 255 * (perc);
+ color.y = 222 * (perc);
+ color.z = 2 * (perc);
+ inc *= 0.5f;
+ t3dVectSub(&pos, &pos, &inc);
+ t3dAddLensFlare(&l.Material[1], &pos, 200, 0, color);
+
+ rAddToMaterialList(l.Material[1], t3dCurUserViewMatrix);
+ }
+
+ LastFlaresVisible = 1;
+
+ //Draw Sun
+ t3dAddLensFlare(&l.Material[0], &l.Source, size, perc2, l.Color);
+ rAddToMaterialList(l.Material[0], t3dCurUserViewMatrix);
+ }
+ rRestoreViewMatrix();
+ t3dCurUserViewMatrix = t3dOldUserViewMatrix;
+ }
+}
+
+
+/* -----------------10/06/99 15.43-------------------
+ * t3dCheckPortalCrossed
+ * --------------------------------------------------*/
+t3dBODY *t3dCheckPortalCrossed(t3dV3F *a) {
+ NormalPtr n;
+ uint32 i;
+ t3dMESH *mesh;
+ t3dV3F line, inter, scale, v0, v1, v2;
+ t3dF32 d;
+
+ for (i = 0; i < t3dNumPortals; i++) {
+ mesh = t3dPortalList[i];
+
+ if (mesh->Flags & T3D_MESH_VIEWONLYPORTAL) continue;
+
+ n = mesh->FList[0].n;
+ d = n->dist - (t3dVectDot(a, &n->n));
+ if (d > -1.0f) {
+ if (!(mesh->VBptr = mesh->VertexBuffer))
+ return nullptr;
+
+ t3dVectCopy(&line, a);
+ line.y += 10;
+ t3dVectCopy(&scale, &n->n);
+ scale *= 20000.0f;
+ t3dVectAdd(&line, &line, &scale);
+
+ v0.x = mesh->VBptr[mesh->FList[0].VertexIndex[0]].x;
+ v0.y = mesh->VBptr[mesh->FList[0].VertexIndex[0]].y;
+ v0.z = mesh->VBptr[mesh->FList[0].VertexIndex[0]].z;
+ v1.x = mesh->VBptr[mesh->FList[0].VertexIndex[1]].x;
+ v1.y = mesh->VBptr[mesh->FList[0].VertexIndex[1]].y;
+ v1.z = mesh->VBptr[mesh->FList[0].VertexIndex[1]].z;
+ v2.x = mesh->VBptr[mesh->FList[0].VertexIndex[2]].x;
+ v2.y = mesh->VBptr[mesh->FList[0].VertexIndex[2]].y;
+ v2.z = mesh->VBptr[mesh->FList[0].VertexIndex[2]].z;
+
+ if (t3dVectTriangleIntersection(&inter, line, *a, v0, v1, v2, *n)) { //return 1 if the vector from start to end pass trought the triangle v1,v2,v3
+ mesh->VBptr = nullptr;
+ return mesh->PortalList;
+ }
+ v0.x = mesh->VBptr[mesh->FList[1].VertexIndex[0]].x;
+ v0.y = mesh->VBptr[mesh->FList[1].VertexIndex[0]].y;
+ v0.z = mesh->VBptr[mesh->FList[1].VertexIndex[0]].z;
+ v1.x = mesh->VBptr[mesh->FList[1].VertexIndex[1]].x;
+ v1.y = mesh->VBptr[mesh->FList[1].VertexIndex[1]].y;
+ v1.z = mesh->VBptr[mesh->FList[1].VertexIndex[1]].z;
+ v2.x = mesh->VBptr[mesh->FList[1].VertexIndex[2]].x;
+ v2.y = mesh->VBptr[mesh->FList[1].VertexIndex[2]].y;
+ v2.z = mesh->VBptr[mesh->FList[1].VertexIndex[2]].z;
+
+ if (t3dVectTriangleIntersection(&inter, line, *a, v0, v1, v2, *n)) { //return 1 if the vector from start to end pass trought the triangle v1,v2,v3
+ mesh->VBptr = nullptr;
+ return mesh->PortalList;
+ }
+ mesh->VBptr = nullptr;
+ }
+ }
+
+ return nullptr;
+}
+
+/* -----------------08/03/2000 15.08-----------------
+ * QueueMaterialList
+ * --------------------------------------------------*/
+void QueueMaterialList(MaterialTable &MatList, unsigned int NumMat, signed short int ViewMatrixNum) {
+ uint32 i;
+
+ if (!NumMat) return;
+
+ for (i = 0; i < t3dNumMaterialLists; i++)
+ if (t3dMaterialList[i].mat_list == &MatList)
+ break;
+
+ if ((i >= t3dNumMaterialLists) || (t3dMaterialList[i].num_mat != NumMat) || (t3dMaterialList[i].matrix != ViewMatrixNum)) {
+ if ((t3dNumMaterialLists + 1) >= MAX_MATERIAL_LISTS) {
+ DebugLogWindow("Too mach material lists! %d MAX is %d", t3dNumMaterialLists + 1, MAX_MATERIAL_LISTS);
+ return ;
+ }
+
+ t3dMaterialList[t3dNumMaterialLists].mat_list = &MatList;
+ t3dMaterialList[t3dNumMaterialLists].num_mat = NumMat;
+ t3dMaterialList[t3dNumMaterialLists].matrix = ViewMatrixNum;
+ t3dNumMaterialLists ++;
+ }
+}
+
+/* -----------------08/03/2000 15.13-----------------
+ * ProcessMaterialList
+ * --------------------------------------------------*/
+void ProcessMaterialList(void) {
+ for (uint32 i = 0; i < t3dNumMaterialLists; i++) {
+ rBuildMaterialList(*t3dMaterialList[i].mat_list, t3dMaterialList[i].num_mat, t3dMaterialList[i].matrix);
+ }
+}
+
+/* -----------------10/06/99 15.50-------------------
+ * SortMesh
+ * --------------------------------------------------*/
+static int SortMesh(const void *element1, const void *element2) {
+ t3dMESH **mm1, **mm2;
+ t3dMESH *m1, *m2;
+
+ mm1 = (t3dMESH **)(element1);
+ mm2 = (t3dMESH **)(element2);
+
+ m1 = *mm1;
+ m2 = *mm2;
+
+ /* DebugLogWindow("%s",m1->Name);
+ DebugLogWindow("%s",m2->Name);
+ DebugLogWindow("----------------");*/
+ if (m1->BBoxAverageZ > m2->BBoxAverageZ)
+ return 1;
+ else if (m1->BBoxAverageZ < m2->BBoxAverageZ)
+ return -1;
+ else
+ return 0;
+}
+
+/* -----------------10/06/99 15.51-------------------
+ * t3dSortMeshes
+ * --------------------------------------------------*/
+void t3dSortMeshes(void) {
+ qsort((void *)&t3d_VisibleMeshes[0], (size_t)t3d_NumMeshesVisible, sizeof(t3dMESH *),
+ SortMesh);
+}
+
+/* -----------------10/06/99 15.43-------------------
+ * t3dProcessPortal
+ * --------------------------------------------------*/
+void t3dProcessPortal(t3dMESH *mesh, t3dCAMERA *cam) {
+ t3dV3F appo, c0;
+ t3dV3F ppv1, ppv2, ppv3, ppv4;
+ uint32 p;
+ t3dNORMAL OldClipPlanes[NUMCLIPPLANES];
+
+ if (!mesh->VertexBuffer)
+ return ;
+
+ mesh->VBptr = mesh->VertexBuffer;
+ ppv1.x = mesh->VBptr[mesh->FList[0].VertexIndex[0]].x;
+ ppv1.y = mesh->VBptr[mesh->FList[0].VertexIndex[0]].y;
+ ppv1.z = mesh->VBptr[mesh->FList[0].VertexIndex[0]].z;
+ ppv2.x = mesh->VBptr[mesh->FList[0].VertexIndex[1]].x;
+ ppv2.y = mesh->VBptr[mesh->FList[0].VertexIndex[1]].y;
+ ppv2.z = mesh->VBptr[mesh->FList[0].VertexIndex[1]].z;
+ ppv3.x = mesh->VBptr[mesh->FList[0].VertexIndex[2]].x;
+ ppv3.y = mesh->VBptr[mesh->FList[0].VertexIndex[2]].y;
+ ppv3.z = mesh->VBptr[mesh->FList[0].VertexIndex[2]].z;
+
+ for (p = 0; p < 3; p++) {
+ appo.x = mesh->VBptr[mesh->FList[1].VertexIndex[p]].x;
+ appo.y = mesh->VBptr[mesh->FList[1].VertexIndex[p]].y;
+ appo.z = mesh->VBptr[mesh->FList[1].VertexIndex[p]].z;
+
+ if ((ppv1 != appo) && (ppv2 != appo) && (ppv3 != appo))
+ memcpy(&ppv4, &appo, sizeof(t3dV3F));
+ }
+
+ memcpy(OldClipPlanes, ClipPlanes, sizeof(t3dNORMAL)*NUMCLIPPLANES);
+
+ t3dVectSub(&ppv4, &ppv4, &cam->Source);
+ t3dVectSub(&ppv3, &ppv3, &cam->Source);
+ t3dVectSub(&ppv2, &ppv2, &cam->Source);
+ t3dVectSub(&ppv1, &ppv1, &cam->Source);
+ t3dVectTransform(&ppv1, &ppv1, &t3dCurViewMatrix);
+ t3dVectTransform(&ppv2, &ppv2, &t3dCurViewMatrix);
+ t3dVectTransform(&ppv3, &ppv3, &t3dCurViewMatrix);
+ t3dVectTransform(&ppv4, &ppv4, &t3dCurViewMatrix);
+ t3dVectFill(&c0, 0.0f);
+
+// t3dVectCopy(&c0,&cam->Source);
+
+ t3dPlaneNormal(&ClipPlanes[RIGHTCLIP], &c0, &ppv3, &ppv4);
+ t3dPlaneNormal(&ClipPlanes[LEFTCLIP], &c0, &ppv1, &ppv2);
+ t3dPlaneNormal(&ClipPlanes[TOPCLIP], &c0, &ppv4, &ppv1);
+ t3dPlaneNormal(&ClipPlanes[BOTTOMCLIP], &c0, &ppv2, &ppv3);
+
+ mesh->VBptr = nullptr;
+
+ for (auto &rejectedMesh : mesh->RejectedMeshes) {
+ rejectedMesh->Flags |= T3D_MESH_INVISIBLEFROMSECT;
+ }
+
+ if (mesh->Flags & T3D_MESH_VIEWONLYPORTAL) bViewOnlyPortal = TRUE;
+ if (!t3dTransformBody(mesh->PortalList)) {
+ DebugLogWindow("Can't transform %s", mesh->PortalList->name.c_str());
+ }
+ bViewOnlyPortal = FALSE;
+
+ for (auto &rejectedMesh : mesh->RejectedMeshes) {
+ rejectedMesh->Flags &= ~T3D_MESH_INVISIBLEFROMSECT;
+ }
+
+ memcpy(ClipPlanes, OldClipPlanes, sizeof(t3dNORMAL)*NUMCLIPPLANES);
+}
+
+
+/* -----------------10/06/99 15.51-------------------
+ * t3dProcessPortals
+ * --------------------------------------------------*/
+void t3dProcessPortals(void) {
+ uint32 i;
+
+ if (t3dNumPortals > 5)
+ DebugLogWindow("Current numportals: %d", t3dNumPortals);
+
+ bPortalRoom = TRUE;
+ for (i = 0; i < t3dNumPortals; i++)
+ t3dProcessPortal(t3dPortalList[i], t3dCurCamera);
+ bPortalRoom = FALSE;
+}
+
+/* -----------------10/06/99 15.47-------------------
+ * t3dAddTriangle
+ * --------------------------------------------------*/
+void t3dAddTriangle(t3dF32 x1, t3dF32 y1, t3dF32 x2, t3dF32 y2, t3dF32 x3, t3dF32 y3,
+ int32 r, int32 g, int32 b, int32 a) {
+ rAddTrianglesArray(x1, y1, r, g, b, a);
+ rAddTrianglesArray(x2, y2, r, g, b, a);
+ rAddTrianglesArray(x3, y3, r, g, b, a);
+}
+
+/* -----------------10/06/99 15.47-------------------
+ * t3dAddQuad
+ * --------------------------------------------------*/
+void t3dAddQuad(t3dF32 x1, t3dF32 y1, t3dF32 x2, t3dF32 y2, t3dF32 x3, t3dF32 y3, t3dF32 x4, t3dF32 y4,
+ int32 r, int32 g, int32 b, int32 a) {
+ t3dAddTriangle(x1, y1, x2, y2, x3, y3, r, g, b, a);
+ t3dAddTriangle(x2, y2, x4, y4, x3, y3, r, g, b, a);
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/geometry.h b/engines/watchmaker/3d/geometry.h
new file mode 100644
index 00000000000..e984d24f3a7
--- /dev/null
+++ b/engines/watchmaker/3d/geometry.h
@@ -0,0 +1,83 @@
+/* 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 WATCHMAKER_GEOMETRY_H
+#define WATCHMAKER_GEOMETRY_H
+
+#include "watchmaker/t3d.h"
+
+#define MAX_RECURSION_LEVEL 10
+
+#define MAX_PARTICLES 10
+
+namespace Watchmaker {
+
+extern t3dBODY *t3dCurRoom, *t3dOrigRoom;
+extern t3dCAMERA *t3dCurCamera;
+extern t3dM3X3F t3dCurViewMatrix;
+extern t3dBODY *PortalCrossed;
+extern t3dCHARACTER *t3dCurCharacter;
+extern uint32 t3d_NumMeshesVisible;
+extern t3dMESH *t3d_VisibleMeshes[];
+
+extern t3dBODY *t3dRxt;
+extern t3dBODY *t3dSky;
+//s extern t3dBODY *t3dSun;
+
+extern uint8 FloorHit;
+extern t3dV3F t3d3dMousePos;
+extern t3dV3F FloorHitCoords;
+extern uint32 StatNumTris, StatNumVerts;
+
+struct WindowInfo;
+
+uint16 t3dBackfaceCulling(NormalList &normals, uint32 NumNormals, t3dV3F *eye);
+
+void t3dReleaseBody(t3dBODY *b);
+void t3dReleaseCharacter(t3dCHARACTER *b);
+unsigned char t3dCreateSmokeParticle(unsigned int Num, unsigned char Type, unsigned int Opacity);
+void t3dCalcRejectedMeshFromPortal(t3dBODY *body);
+void t3dSetViewport(t3dCAMERA *cam, WindowInfo &info, t3dF32 fov, uint8 sup);
+t3dF32 t3dCheckWithFloor();
+void t3dCreateProceduralSky();
+void t3dCalc2dTo3dPos(t3dV3F *pos, t3dF32 posx, t3dF32 posy);
+void t3dCalcMeshBones(t3dMESH *mesh, int32 last);
+void t3dResetPipeline();
+void t3dRotateMoveCamera(t3dCAMERA *cam, t3dF32 AngleX, t3dF32 AngleY, t3dF32 AngleSpeed);
+void t3dReleaseParticles();
+void t3dResetMesh(t3dMESH *mesh);
+void t3dShowBoundingBox(t3dBODY *b);
+void t3dShowBounds(t3dPAN *p, uint32 numpan);
+bool t3dTransformBody(t3dBODY *b);
+void t3dTransformSky();
+bool t3dTransformCharacter(t3dCHARACTER *c);
+void t3dProcessPortals();
+t3dBODY *t3dCheckPortalCrossed(t3dV3F *a);
+void t3dSortMeshes();
+void QueueMaterialList(MaterialTable &MatList, unsigned int NumMat, signed short int ViewMatrixNum);
+void ProcessMaterialList();
+void t3dAddTriangle(t3dF32 x1, t3dF32 y1, t3dF32 x2, t3dF32 y2, t3dF32 x3, t3dF32 y3,
+ int32 r, int32 g, int32 b, int32 a);
+void t3dAddQuad(t3dF32 x1, t3dF32 y1, t3dF32 x2, t3dF32 y2, t3dF32 x3, t3dF32 y3, t3dF32 x4, t3dF32 y4,
+ int32 r, int32 g, int32 b, int32 a);
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_GEOMETRY_H
diff --git a/engines/watchmaker/3d/light.cpp b/engines/watchmaker/3d/light.cpp
new file mode 100644
index 00000000000..69ac842355d
--- /dev/null
+++ b/engines/watchmaker/3d/light.cpp
@@ -0,0 +1,466 @@
+/* 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/>.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_EXCEPTION_strcat
+#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
+
+#include "watchmaker/3d/light.h"
+#include "watchmaker/3d/loader.h"
+#include "watchmaker/types.h"
+#include "watchmaker/t3d.h"
+#include "watchmaker/3d/geometry.h"
+#include "watchmaker/3d/t3d_body.h"
+#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/3d/math/llmath.h"
+#include "watchmaker/ll/ll_system.h"
+#include "watchmaker/utils.h"
+
+namespace Watchmaker {
+
+/* -----------------29/05/99 11.41-------------------
+ * Illumina un t3dVERTEX (per WmGen)
+ * --------------------------------------------------*/
+uint8 LightVertex(t3dVERTEX *vv, t3dV3F *v, t3dLIGHT *light) {
+ t3dF32 dist, direction, ang, deg, Intensity1 = 1.0f, Intensity2 = 1.0f;
+ t3dV3F vdist, dir, finallight;
+ t3dF32 half_hotspot = DEGREE_TO_RADIANS(light->HotSpot) * 0.5f,
+ half_falloff = DEGREE_TO_RADIANS(light->FallOff) * 0.5f;
+
+ t3dVectSub(&vdist, v, &light->Source);
+ dist = t3dVectMod(&vdist);
+
+ t3dVectFill(&finallight, 0.0f);
+
+ if ((light->Type & T3D_LIGHT_SPOTLIGHT)) {
+ t3dVectSub(&dir, &light->Target, &light->Source); // Serve per Spot
+ direction = t3dVectMod(&dir);
+
+ ang = (float)acos(t3dVectDot(&vdist, &dir) / (direction * dist));
+ if ((ang > (half_hotspot))) {
+ if (ang > (half_falloff)) {
+ Intensity2 = 0.0f;
+ Intensity1 = 0.0f;
+ } else {
+ Intensity1 = 1.0;
+ deg = half_hotspot + (ang - half_hotspot);
+ Intensity2 = (half_falloff - deg) / (half_falloff - half_hotspot);
+ }
+ } else {
+ Intensity1 = 1.0;
+ Intensity2 = 1.0;
+ }
+
+ if ((light->Type & T3D_LIGHT_ATTENUATION)) {
+ if ((dist > light->NearRange)) {
+ if (dist > light->FarRange) {
+ Intensity1 = 0.0f;
+ Intensity2 = 0.0f;
+ } else {
+ dist = light->NearRange + (dist - light->NearRange);
+ Intensity2 *= (light->FarRange - dist) / (light->FarRange - light->NearRange);
+ Intensity1 *= 1.0f;
+ }
+ } else {
+ Intensity1 *= 1.0f;
+ Intensity2 *= 1.0f;
+ }
+ }
+ } else {
+ if ((light->Type & T3D_LIGHT_ATTENUATION)) {
+ if ((dist < light->NearRange)) {
+ Intensity1 = 1.0f;
+ Intensity2 = 1.0f;
+ } else {
+ Intensity1 = 1.0f;
+
+ if (dist > light->FarRange)
+ Intensity2 = 0.0f;
+ else {
+ dist = light->NearRange + (dist - light->NearRange);
+ Intensity2 *= (light->FarRange - dist) / (light->FarRange - light->NearRange);
+ Intensity1 *= 1.0f;
+ }
+ }
+ } else {
+ Intensity1 = 1.0;
+ Intensity2 = 1.0;
+ }
+ }
+
+ if ((Intensity1 == 0.0f) || (Intensity2 == 0.0f)) {
+ return 0;
+ }
+
+ finallight = light->Color * (Intensity1 * Intensity2 * light->Multiplier);
+
+ if (finallight.x > 255.0f) finallight.x = 255.0f;
+ if (finallight.y > 255.0f) finallight.y = 255.0f;
+ if (finallight.z > 255.0f) finallight.z = 255.0f;
+ vv->r = (uint8)finallight.x;
+ vv->g = (uint8)finallight.y;
+ vv->b = (uint8)finallight.z;
+
+ return 1;
+}
+
+/* -----------------29/05/99 11.41-------------------
+ * Illumina un gVertex (per game)
+ * --------------------------------------------------*/
+uint8 LightgVertex(gVertex *v, t3dLIGHT *light) {
+ t3dVERTEX vv;
+ t3dV3F vt;
+
+ vt.x = v->x;
+ vt.y = v->y;
+ vt.z = v->z;
+
+ if (LightVertex(&vv, &vt, light))
+ return true;
+ else
+ return false;
+}
+
+/* -----------------29/05/99 11.55-------------------
+ * setDirectoryAndName
+ * --------------------------------------------------*/
+Common::String setDirectoryAndName(const Common::String &path, const Common::String &name) {
+ int32 len = name.size();
+
+ auto backSlashPos = name.findFirstOf("\\");
+
+ return path + name.substr(backSlashPos + 1, name.size() - (backSlashPos + 1));
+}
+
+/* -----------------29/05/99 12.03-------------------
+ * LoadVolumetricMap
+ * --------------------------------------------------*/
+void LoadVolumetricMap(WorkDirs &workDirs, const char *pname, t3dBODY *b) {
+ uint32 i, j, k;
+
+ auto stream = workDirs.resolveFile(pname);
+ if (!(stream)) {
+//t DebugLogWindow("File %s not found: assuming no volumetriclights informations",pname);
+ return ;
+ }
+
+ if ((i = stream->readSint32LE()) != VOLLIGHTFILEVERSION) {
+ warning("Invalid File version: %s file version is: %d\t You need the version: %d", pname, i, VOLLIGHTFILEVERSION);
+ return ;
+ }
+
+ b->VolumetricLights = Common::SharedPtr<t3dVolLights>(new t3dVolLights());
+ b->VolumetricLights->CellsSize = stream->readFloatLE();
+ b->VolumetricLights->xcells = stream->readSint32LE();
+ b->VolumetricLights->ycells = stream->readSint32LE();
+ b->VolumetricLights->zcells = stream->readSint32LE();
+
+ b->VolumetricLights->VolMap.resize(b->VolumetricLights->ycells * b->VolumetricLights->xcells * b->VolumetricLights->zcells);
+ for (i = 0; i < b->VolumetricLights->ycells - 1; i++) {
+ for (j = 0; j < b->VolumetricLights->zcells - 1; j++) {
+ for (k = 0; k < b->VolumetricLights->xcells - 1; k++) {
+ b->VolumetricLights->VolMap[(k) + ((j)*b->VolumetricLights->xcells) + ((i)*b->VolumetricLights->xcells * b->VolumetricLights->zcells)] = stream->readByte();
+ }
+ }
+ }
+}
+
+/* -----------------29/05/99 12.04-------------------
+ * t3dLoadOutdoorLights
+ * --------------------------------------------------*/
+void t3dLoadOutdoorLights(const char *pname, t3dBODY *b, int32 ora) {
+ warning("STUBBED, t3dLoadOutdoorLights\n");
+#if 0
+ t3dU32 i, j, k;
+ t3dMESH *m;
+ gVertex *gv;
+ t3dU32 nverts;
+ char Name[T3D_NAMELEN];
+ t3dU32 len;
+ DWORD *Buf, *t;
+ t3dLIGHT *l;
+
+ if (!pname || !b) return;
+
+ i = 0;
+ if (ora >= 1130) i++;
+ if ((ora >= 1300) && (ora <= 1310)) i++;
+ if (ora >= 1800) i++;
+ if (ora >= 2030) i++;
+
+ if (i == (t3dU32)t3dCurOliSet) return;
+
+ len = strlen(pname);
+ memset(Name, 0, sizeof(Name));
+ strncpy(Name, pname, len - 4);
+ strcat(Name, ".oli");
+
+ if (!(t3dOpenFile(Name))) {
+ DebugLogWindow("Unable to open OLI file %s", Name);
+ return ;
+ }
+
+ if ((i = t3dRead32()) != OUTDOORLIGHTSFILEVERSION) {
+ DebugLogWindow("Invalid File version: %s file version is: %d\t You need the version: %d", pname, i, VOLLIGHTFILEVERSION);
+ return ;
+ }
+
+ if ((nverts = t3dRead32()) != b->NumTotVerts) {
+ DebugLogWindow("Old OLI File %s!", pname);
+ t3dCurOliSet = i;
+ t3dCreateProceduralSky();
+ return ;
+ }
+
+ Buf = t = (DWORD *)t3dMalloc(nverts * sizeof(DWORD));
+
+ t3dCurOliSet = 0;
+ t3dCurTime = ora;
+ if (ora >= 1130) {
+ t3dReadData(Buf, nverts * sizeof(DWORD));
+ t3dCurOliSet++;
+ }
+ if ((ora >= 1300) && (ora <= 1310)) {
+ t3dReadData(Buf, nverts * sizeof(DWORD));
+ t3dCurOliSet++;
+ }
+ if (ora >= 1800) {
+ t3dReadData(Buf, nverts * sizeof(DWORD));
+ t3dCurOliSet++;
+ }
+ if (ora >= 2030) {
+ t3dReadData(Buf, nverts * sizeof(DWORD));
+ t3dCurOliSet++;
+ }
+
+ t3dReadData(Buf, nverts * sizeof(DWORD));
+ t3dCloseFile();
+
+ for (i = 0, m = b->MeshTable; i < b->NumMeshes; i++, m++) {
+#ifndef WMGEN
+ m->VBptr = m->VertexBuffer;
+#endif
+ for (j = 0, gv = m->VBptr; j < m->NumVerts; j++, gv++, t++) {
+ gv->diffuse = *t;
+ }
+ m->Flags |= T3D_MESH_UPDATEVB;
+#ifndef WMGEN
+ m->VBptr = nullptr;
+#endif
+ }
+ t3dFree(Buf);
+
+ t3dVectCopy(&b->AmbientLight, &OliAmbient[t3dCurOliSet]);
+
+ l = b->LightTable;
+ for (k = 0; k < b->NumLights; k++, l++) {
+ if (l->Type & T3D_LIGHT_SOLARVARIATION) {
+ if (l->Type & T3D_LIGHT_SUN)
+ t3dVectCopy(&l->Source, &l->SolarPos[t3dCurOliSet]);
+ t3dVectCopy(&l->Color, &l->SolarColor[t3dCurOliSet]);
+
+ l->Type |= T3D_LIGHT_LIGHTON;
+ if ((t3dCurOliSet == 0) && (l->Type & T3D_LIGHT_OFF_MORNING)) l->Type &= ~T3D_LIGHT_LIGHTON;
+ if ((t3dCurOliSet == 1) && (l->Type & T3D_LIGHT_OFF_AFTERNOON)) l->Type &= ~T3D_LIGHT_LIGHTON;
+ if ((t3dCurOliSet == 2) && (l->Type & T3D_LIGHT_OFF_EVENING)) l->Type &= ~T3D_LIGHT_LIGHTON;
+ if ((t3dCurOliSet == 3) && (l->Type & T3D_LIGHT_OFF_NIGHT)) l->Type &= ~T3D_LIGHT_LIGHTON;
+
+ if (l->Color.x > 255.0f) l->Color.x = 255.0f;
+ if (l->Color.y > 255.0f) l->Color.y = 255.0f;
+ if (l->Color.z > 255.0f) l->Color.z = 255.0f;
+ if (l->Color.x < 0.0f) l->Color.x = 0.0f;
+ if (l->Color.y < 0.0f) l->Color.y = 0.0f;
+ if (l->Color.z < 0.0f) l->Color.z = 0.0f;
+ }
+ }
+
+ t3dCreateProceduralSky();
+#endif
+}
+
+/* -----------------29/05/99 12.01-------------------
+ * GetBoundaries
+ * --------------------------------------------------*/
+void GetBoundaries(t3dBODY *b, t3dF32 *minx, t3dF32 *miny, t3dF32 *minz, t3dF32 *maxx, t3dF32 *maxy, t3dF32 *maxz) {
+ gVertex *gv;
+
+ *minx = *miny = *minz = 999999999.9f;
+ *maxx = *maxy = *maxz = -999999999.9f;
+
+ for (uint32 i = 0; i < b->NumMeshes(); i++) {
+#ifndef WMGEN
+ gv = b->MeshTable[i].VertexBuffer;
+#else
+ gv = (gVertex *)(m->VBptr);
+#endif
+
+ for (uint32 j = 0; j < b->MeshTable[i].NumVerts; j++, gv++) {
+ if (gv->x < *minx) *minx = gv->x;
+ if (gv->y < *miny) *miny = gv->y;
+ if (gv->z < *minz) *minz = gv->z;
+
+ if (gv->x > *maxx) *maxx = gv->x;
+ if (gv->y > *maxy) *maxy = gv->y;
+ if (gv->z > *maxz) *maxz = gv->z;
+ }
+
+ }
+}
+
+t3dLIGHT::t3dLIGHT(t3dBODY *b, WorkDirs &workDirs, Common::SeekableReadStream &stream) {
+ Type = stream.readUint32LE(); // Legge tipo
+ // DebugFile("%d: SPOT %X ATTEN %X SHAD %X",light,Light[light].Type&T3D_LIGHT_SPOTLIGHT,Light[light].Type&T3D_LIGHT_ATTENUATION,Light[light].Type&T3D_LIGHT_CASTSHADOWS);
+ Source = t3dV3F(stream) * SCALEFACTOR; // Legge Source
+ Target = t3dV3F(stream) * SCALEFACTOR; // Legge Target
+
+ HotSpot = stream.readFloatLE() * SCALEFACTOR;
+ FallOff = stream.readFloatLE() * SCALEFACTOR;
+
+ Color = t3dV3F(stream); // Legge Color
+
+ NearRange = stream.readFloatLE() * SCALEFACTOR;
+ FarRange = stream.readFloatLE() * SCALEFACTOR;
+
+ Multiplier = stream.readFloatLE();
+ Flicker = stream.readByte();
+
+ t3dBackfaceCulling(b->NList, (uint16)(b->NumNormals + b->NumVerticesNormals), &Source); // Setta le facce che sono backface
+//f t3dPreLigthVertices(b->NList, b->VList, (t3dU16)b->NumVerts, &Light[light]); // Illumina facce che non sono backface
+
+
+ if (Flicker) { // Aggiorna Vertici visibili per flicker
+ Type |= T3D_LIGHT_PULSE;
+ setupVisibleVerticesFromLight(b);
+ AnimLight.LastRandomizer = 0;
+ }
+
+ if (Type & T3D_LIGHT_FLARE) { // Se ha una flare
+ char Name[T3D_NAMELEN], Appo[T3D_NAMELEN];
+#ifndef WMGEN
+ int len;
+#endif
+//f Light[light].Type&=~T3D_LIGHT_LIGHTON; // La spegne
+ FlareSize = stream.readFloatLE() * SCALEFACTOR; // Legge il size della flare
+
+ for (int i = 0; i < T3D_NAMELEN; i++) { // Legge nome dellaq texture
+ Name[i] = stream.readByte();
+ }
+
+#ifndef WMGEN
+ len = strlen(Name);
+ if (((Name[len - 1] == 'i') || (Name[len - 1] == 'I')) &&
+ ((Name[len - 2] == 'v') || (Name[len - 2] == 'V')) &&
+ ((Name[len - 3] == 'a') || (Name[len - 3] == 'A'))) {
+ strcpy(Appo, workDirs._moviesDir.c_str()); // altrimenti prende quello di default
+ } else {
+ strcpy(Appo, workDirs._mapsDir.c_str()); // altrimenti prende quello di default
+ }
+ strcat(Appo, Name); // Attacca nome Immagine
+#else
+ strcpy(Appo, WmMapsDir);
+ strcat(Appo, Name);
+#endif
+
+#ifndef WMGEN
+ if (!(rAddMaterial(Material[0], Appo, 15, 0))) { // Aggiunge il materiale
+ warning("File %s not found", Appo);
+ Material[0].Texture = nullptr;
+ assert(false);
+ }
+//f rAddNumFacesMaterial(&Light[light].Material[0], /*f2*/7); // Aggiunge 7 facce ???
+ Material[0].addProperty(T3D_MATERIAL_FLARE); // Assegna al materiale la prop flare
+ warning("TODO!, Implement the user vertex buffer");
+#if 0
+ Light[light].Material[0].VB = rGetUserVertexBuffer();
+#endif
+ Material[0].NumAllocatedVerts += 45;
+#endif
+ }
+
+ Particle = nullptr;
+ if (Type & T3D_LIGHT_CANDLESMOKE) { // Se ha una smoke-particle
+ Particle = Common::SharedPtr<t3dParticle>(new t3dParticle(stream)); // Legge data
+ }
+ if (Type & T3D_LIGHT_SOLARVARIATION) { // Se ha una variazione in base al sole
+ if (!(Type & T3D_LIGHT_OFF_MORNING)) {
+ SolarPos[0] = t3dV3F(stream);
+ SolarColor[0] = t3dV3F::fromStreamAsBytes(stream);
+ }
+ if (!(Type & T3D_LIGHT_OFF_AFTERNOON)) {
+ t3dVectCopy(&SolarPos[1], &Source);
+ t3dVectCopy(&SolarColor[1], &Color);
+ }
+ if (!(Type & T3D_LIGHT_OFF_EVENING)) {
+ SolarPos[2] = t3dV3F(stream);
+ SolarColor[2] = t3dV3F::fromStreamAsBytes(stream);
+ }
+ if (!(Type & T3D_LIGHT_OFF_NIGHT)) {
+ SolarPos[3] = t3dV3F(stream);
+ SolarColor[3] = t3dV3F::fromStreamAsBytes(stream);
+ }
+ }
+}
+
+
+/* -----------------10/06/99 16.02-------------------
+ * SetVisibleFromLight
+ * --------------------------------------------------*/
+void t3dLIGHT::SetVisibleFromLight(gVertex *v) {
+ AnimLight.VisVerts.push_back(v);
+}
+
+
+/* -----------------10/06/99 16.02-------------------
+ * setupVisibleVerticesFromLight
+ * --------------------------------------------------*/
+void t3dLIGHT::setupVisibleVerticesFromLight(t3dBODY *b) {
+ gVertex *gv;
+ for (int k = 0; k < b->NumMeshes(); k++) {
+ t3dMESH &m = b->MeshTable[k];
+#ifndef WMGEN
+ m.VBptr = m.VertexBuffer;
+ gv = m.VBptr;
+#else
+ gv = m->VBptr;
+#endif
+ for (int j = 0; j < m.NumVerts; j++, gv++)
+ if (LightgVertex(gv, this))
+ SetVisibleFromLight(gv);
+
+#ifndef WMGEN
+ gv = nullptr;
+ m.VBptr = nullptr;
+#endif
+ }
+}
+
+t3dPLIGHT::t3dPLIGHT(Common::SeekableReadStream &stream) {
+ Num = stream.readByte(); // Legge numero pos
+
+ Pos.x = stream.readFloatLE(); // Legge Pos
+ Pos.y = stream.readFloatLE();
+ Pos.z = stream.readFloatLE();
+
+ Dir.x = stream.readFloatLE(); // Legge Dir
+ Dir.y = stream.readFloatLE();
+ Dir.z = stream.readFloatLE();
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/light.h b/engines/watchmaker/3d/light.h
new file mode 100644
index 00000000000..0f013167e35
--- /dev/null
+++ b/engines/watchmaker/3d/light.h
@@ -0,0 +1,46 @@
+/* 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 WATCHMAKER_LIGHT_H
+#define WATCHMAKER_LIGHT_H
+
+#include "watchmaker/t3d.h"
+
+#define LIGHT_MAPVERSION 1
+#define VOLLIGHTFILEVERSION 1
+#define OUTDOORLIGHTSFILEVERSION 2
+
+#define LIGHT_COORDS (1<<0)
+#define LIGHT_LIGHTMAPS (1<<1)
+#define LIGHT_SHADOWMAPS (1<<2)
+
+namespace Watchmaker {
+
+void GetBoundaries(t3dBODY *b, float *minx, float *miny, float *minz, float *maxx, float *maxy, float *maxz);
+unsigned char LightgVertex(gVertex *v, t3dLIGHT *light);
+void t3dLoadOutdoorLights(const char *pname, t3dBODY *b, int32 ora);
+void LoadVolumetricMap(WorkDirs &workDirs, const char *pname, t3dBODY *b);
+Common::String setDirectoryAndName(const Common::String &path, const Common::String &name);
+uint8 LightVertex(t3dVERTEX *vv, t3dV3F *v, t3dLIGHT *light);
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_LIGHT_H
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
new file mode 100644
index 00000000000..b49fb8eed9e
--- /dev/null
+++ b/engines/watchmaker/3d/loader.cpp
@@ -0,0 +1,566 @@
+/* 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 "watchmaker/3d/loader.h"
+#include "watchmaker/3d/math/llmath.h"
+#include "watchmaker/t3d.h"
+#include "watchmaker/3d/t3d_body.h"
+#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/types.h"
+#include "common/stream.h"
+#include "watchmaker/utils.h"
+#include "watchmaker/ll/ll_system.h"
+#include "watchmaker/work_dirs.h"
+#include "watchmaker/3d/geometry.h"
+#include "watchmaker/3d/light.h"
+#include "watchmaker/windows_hacks.h"
+#include "watchmaker/game.h"
+#include "watchmaker/renderer.h"
+#include "watchmaker/work_dirs.h"
+
+namespace Watchmaker {
+
+#define T3DFILEVERSION 11
+
+// TODO: Globals
+#define MAX_LOADED_FILES 100
+RecStruct LoadedFiles[MAX_LOADED_FILES];
+uint16 NumLoadedFiles = 0;
+
+t3dV3F CharCorrection;
+t3dF32 CurFloorY;
+int32 t3dCurTime = 900, t3dCurOliSet = 0;
+
+// LoadRoom vars
+#define MAX_T3D_LOADLIST_ITEMS 50
+struct _t3dLOADLIST {
+ Common::String pname = {};
+ uint32 LoaderFlags = 0;
+ t3dMESH *m = nullptr;
+} t3dLoadList[MAX_T3D_LOADLIST_ITEMS] = {};
+
+/* -----------------10/06/99 16.03-------------------
+ * AddToLoadList
+ * --------------------------------------------------*/
+void AddToLoadList(t3dMESH *m, const Common::String &pname, uint32 LoaderFlags) {
+ int32 a;
+
+ if (!pname.empty()) {
+ for (a = 0; a < MAX_T3D_LOADLIST_ITEMS; a++) {
+ if (t3dLoadList[a].pname.empty()) {
+ t3dLoadList[a].LoaderFlags = LoaderFlags;
+ t3dLoadList[a].m = m;
+ t3dLoadList[a].pname = pname;
+ break;
+ }
+ }
+
+ if (a >= MAX_T3D_LOADLIST_ITEMS)
+ warning("Cannot add %s to LoadList", pname.c_str());
+ } else {
+ warning("Invalid parameters invoking AddToLoadList()");
+ warning("Mesh (%s), pname %s", m->name.c_str(), pname.c_str());
+ }
+}
+
+/* -----------------10/06/99 16.04-------------------
+ * GetFromLoadList
+ * --------------------------------------------------*/
+struct _t3dLOADLIST *GetFromLoadList(void) {
+ int32 a;
+
+ for (a = 0; a < MAX_T3D_LOADLIST_ITEMS; a++) {
+ if (t3dLoadList[a].pname[0])
+ return &t3dLoadList[a];
+ }
+
+ return nullptr;
+}
+
+t3dPathCamera::t3dPathCamera(Common::SeekableReadStream &stream) {
+ NumCamera = stream.readByte();
+ PathIndex = stream.readByte();
+ Direction = stream.readByte();
+}
+
+t3dCAMERA::t3dCAMERA(Common::SeekableReadStream &stream) {
+ Index = stream.readByte();
+
+ Source = t3dV3F(stream) * SCALEFACTOR;
+ Target = t3dV3F(stream) * SCALEFACTOR;
+
+ t3dVectCopy(&MaxTarget, &Target);
+
+// Camera[camera].Fov=t3dReadReal();
+ Fov = RADIANS_TO_DEGREE(stream.readFloatLE()); //FOV
+ NearClipPlane = stream.readFloatLE() * SCALEFACTOR;
+ FarClipPlane = stream.readFloatLE() * SCALEFACTOR;
+
+ int numPaths = stream.readByte();
+ CameraPaths.reserve(numPaths);
+ for (int i = 0; i < numPaths; i++) {
+ CameraPaths.push_back(t3dPathCamera(stream));
+ }
+}
+
+t3dCAMERAPATH::t3dCAMERAPATH(Common::SeekableReadStream &stream) {
+ int numPoints = stream.readSint16LE();
+ CarrelloDist = stream.readSint32LE();
+
+ PList.reserve(numPoints);
+ for (int j = 0; j < numPoints; j++) {
+ PList[j].x = stream.readFloatLE() * SCALEFACTOR;
+ PList[j].y = stream.readFloatLE() * SCALEFACTOR;
+ PList[j].z = stream.readFloatLE() * SCALEFACTOR;
+ }
+}
+void decodeLoaderFlags(uint32 flags) {
+ warning("%d: T3D_GENERATESHADOWMAPS\n", flags & T3D_GENERATESHADOWMAPS);
+ warning("%d: T3D_NOLIGHTMAPS\n", flags & T3D_NOLIGHTMAPS);
+ warning("%d: T3D_NORECURSION\n", flags & T3D_NORECURSION);
+ warning("%d: T3D_HALFTEXTURESIZE\n", flags & T3D_HALFTEXTURESIZE);
+ warning("%d: T3D_FULLSCREEN\n", flags & T3D_FULLSCREEN);
+ warning("%d: T3D_FASTRENDERING\n", flags & T3D_FASTRENDERING);
+ warning("%d: T3D_OUTDOORLIGHTS\n", flags & T3D_OUTDOORLIGHTS);
+ warning("%d: T3D_NOVOLUMETRICLIGHTS\n", flags & T3D_NOVOLUMETRICLIGHTS);
+ warning("%d: T3D_NOBOUNDS\n", flags & T3D_NOBOUNDS);
+ warning("%d: T3D_NOCAMERAS\n", flags & T3D_NOCAMERAS);
+ warning("%d: T3D_NONEXCLUSIVEMOUSE\n", flags & T3D_NONEXCLUSIVEMOUSE);
+ warning("%d: T3D_RECURSIONLEVEL1\n", flags & T3D_RECURSIONLEVEL1);
+ warning("%d: T3D_SKY\n", flags & T3D_SKY);
+ warning("%d: T3D_PRELOAD_RXT\n", flags & T3D_PRELOAD_RXT);
+ warning("%d: T3D_STATIC_SET0\n", flags & T3D_STATIC_SET0);
+ warning("%d: T3D_STATIC_SET1\n", flags & T3D_STATIC_SET1);
+ warning("%d: T3D_NOSHADOWS\n", flags & T3D_NOSHADOWS);
+ warning("%d: T3D_NOICONS\n", flags & T3D_NOICONS);
+ warning("%d: T3D_NOSOUND\n", flags & T3D_NOSOUND);
+ warning("%d: T3D_PRELOADBASE\n", flags & T3D_PRELOADBASE);
+ warning("%d: T3D_NOMUSIC\n", flags & T3D_NOMUSIC);
+ warning("%d: T3D_DEBUGMODE\n", flags & T3D_DEBUGMODE);
+ warning("%d: T3D_FASTFILE\n", flags & T3D_FASTFILE);
+ warning("%d: T3D_HIPOLYPLAYERS\n", flags & T3D_HIPOLYPLAYERS);
+ warning("%d: T3D_HIPOLYCHARACTERS\n", flags & T3D_HIPOLYCHARACTERS);
+}
+
+/* -----------------10/06/99 16.04-------------------
+ * CheckIfAlreadyLoaded
+ * --------------------------------------------------*/
+t3dBODY *CheckIfAlreadyLoaded(const Common::String &Name) {
+ if (Name.empty()) return nullptr;
+
+ for (uint16 i = 0; i < NumLoadedFiles; i++) {
+ if ((LoadedFiles[i].b != nullptr) && /*(LoadedFiles[i].Name != nullptr) &&*/ (!LoadedFiles[i].name.empty()))
+ if (LoadedFiles[i].name.equalsIgnoreCase(Name))
+ return LoadedFiles[i].b;
+ }
+
+ return nullptr;
+}
+
+Common::String constructPath(const Common::String &prefix, const Common::String &filename, const char *suffix) {
+ Common::String Name = prefix + filename;
+ uint16 len = Name.size();
+ if (suffix != nullptr) {
+ uint16 suffixLen = strlen(suffix);
+ Name = Name.substr(0, len - suffixLen) + suffix;
+ assert(suffixLen == 3);
+ }
+ return Common::String(Name);
+}
+
+/* -----------------10/06/99 16.04-------------------
+ * t3dLoadSingleRoom
+ * --------------------------------------------------*/
+t3dBODY *t3dLoadSingleRoom(WGame &game, const Common::String &_pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags) {
+ //warning("t3dLoadSingleRoom(workDirs, %s, b, %d, %d)\n", _pname, *NumBody, LoaderFlags);
+ //decodeLoaderFlags(LoaderFlags);
+ Common::String pname(_pname);
+
+ uint16 light;
+ t3dPLIGHT *PLight;
+ t3dF32 minx, miny, minz, maxx, maxy, maxz;
+
+ WorkDirs &workdirs = game.workDirs;
+
+ if (pname.equalsIgnoreCase("r1c.t3d"))
+ if (((t3dCurTime >= 1300) && (t3dCurTime <= 1310)) || (t3dCurTime >= 1800)) //se viene cambiato l'orario cambiarlo anche in UpdateRoomVis...
+ pname = "r1c-notte.t3d";
+ if (pname.equalsIgnoreCase("r15.t3d"))
+ if (((t3dCurTime >= 1300) && (t3dCurTime <= 1310)) || (t3dCurTime >= 1800))
+ pname = "r15-notte.t3d";
+
+ auto name = constructPath(workdirs._t3dDir, pname);
+
+ //warning("t3dLoadSingleRoom opening(%s)\n", name.c_str());
+ auto stream = openFile(name);
+ if (!(stream)) { // Apre file
+ warning("t3dLoadSingleRoom: Failed to open(%s)\n", name.c_str());
+ return nullptr;
+ }
+
+ if (*NumBody == 0) { // Se e' il primo body, alloca
+ b = new t3dBODY;
+ (*NumBody)++;
+ } else
+ b = (t3dBODY *)t3dRealloc((uint32 *)b, sizeof(t3dBODY) * (++(*NumBody))); // Altrimenti, ridimensiona
+
+ //warning("Loading %s ...\n", name.c_str());
+ *b = t3dBODY(); // Azzera Body
+
+ uint16 fileVersion = stream->readByte();
+ if (fileVersion != T3DFILEVERSION) { // Controlla la versione del file
+ warning("%s file incompatible: current version: %d.\tFile version: %d", name.c_str(), T3DFILEVERSION, fileVersion);
+ return nullptr;
+ }
+
+ {
+ uint16 j = 1;
+ while (LoadedFiles[j].b != nullptr) j++;
+ if (j > MAX_LOADED_FILES) {
+ warning("Too many t3d files loaded!");
+ return nullptr;
+ }
+ if ((j + 1) > NumLoadedFiles) NumLoadedFiles = j + 1;
+
+ LoadedFiles[j].name = _pname; // Aggiunge il file alla lista
+ LoadedFiles[j].Flags = LoaderFlags; // Aggiunge Flags alla lista
+ LoadedFiles[j].b = b; // Aggiunge Body alla lista
+ j = 0;
+ }
+ b->loadFromStream(game, pname, *stream, LoaderFlags);
+
+ return b;
+}
+
+/* -----------------10/06/99 16.04-------------------
+ * t3dLoadRoom
+ * --------------------------------------------------*/
+t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags) {
+ warning("t3dLoadRoom(%s, b, %d, %d)\n", pname.c_str(), *NumBody, LoaderFlags);
+ struct _t3dLOADLIST *l;
+ t3dBODY *r, *rez;
+ t3dBODY *body;
+ uint16 num, i;
+
+// azzera tutto quello che c'era prima nella load list
+ for (int i = 0; i < MAX_T3D_LOADLIST_ITEMS; i++) {
+ t3dLoadList[i] = _t3dLOADLIST();
+ }
+
+// Aggiunge la stanza base alla lista di caricamenti
+ AddToLoadList(nullptr, pname, LoaderFlags);
+
+ while ((l = GetFromLoadList())) {
+ num = 0;
+ if (l->m) {
+ if ((rez = CheckIfAlreadyLoaded(l->pname)))
+ body = l->m->PortalList = rez;
+ else {
+// if (l->m->Flags&T3D_MESH_PREPROCESSPORTAL)
+// body=l->m->PortalList = t3dLoadSingleRoom( l->pname, l->m->PortalList, &num, (l->LoaderFlags|T3D_HALFTEXTURESIZE) );
+// else
+ body = l->m->PortalList = t3dLoadSingleRoom(game, l->pname, l->m->PortalList, &num, l->LoaderFlags);
+ }
+ } else
+ body = r = t3dLoadSingleRoom(game, l->pname, b, NumBody, l->LoaderFlags);
+
+ memset(l, 0, sizeof(struct _t3dLOADLIST));
+ }
+
+ if (!(LoaderFlags & T3D_NORECURSION)) {
+ for (i = 0; i < NumLoadedFiles; i++)
+ if (LoadedFiles[i].b)
+ t3dCalcRejectedMeshFromPortal(LoadedFiles[i].b);
+ }
+
+ warning("Room loaded\n");
+ return r;
+}
+
+t3dParticle::t3dParticle(Common::SeekableReadStream &stream) {
+ t3dF32 difR1, difG1, difB1;
+ t3dF32 difR2, difG2, difB2;
+ Num = (uint32)stream.readFloatLE();
+ Lung = stream.readFloatLE();
+ Size = stream.readFloatLE();
+ Seg1 = stream.readFloatLE();
+ Seg2 = stream.readFloatLE();
+ Dim1 = stream.readFloatLE() / 1000.0f;
+ Dim2 = stream.readFloatLE() / 1000.0f;
+ Speed = stream.readFloatLE() / 10.0f;
+ Speed1 = stream.readFloatLE() / 10.0f;
+ Speed2 = stream.readFloatLE() / 10.0f;
+ Caos = stream.readFloatLE() / 10;
+ Caos1 = stream.readFloatLE() / 10;
+ Caos2 = stream.readFloatLE() / 10;
+ Delay = (uint32)stream.readFloatLE();
+ OR1 = (uint8)stream.readSint32LE();
+ R1 = (uint8)stream.readSint32LE();
+ G1 = (uint8)stream.readSint32LE();
+ B1 = (uint8)stream.readSint32LE();
+ R2 = (uint8)stream.readSint32LE();
+ G2 = (uint8)stream.readSint32LE();
+ B2 = (uint8)stream.readSint32LE();
+ R3 = (uint8)stream.readSint32LE();
+ G3 = (uint8)stream.readSint32LE();
+ B3 = (uint8)stream.readSint32LE();
+ Type = (uint8)stream.readSint32LE();
+
+#ifndef WMGEN
+ ParticleIndex = t3dCreateSmokeParticle(Num,
+ Type,
+ OR1);
+#endif
+ difR1 = (R2 - R1) / (Seg1 / Speed1);
+ difG1 = (G2 - G1) / (Seg1 / Speed1);
+ difB1 = (B2 - B1) / (Seg1 / Speed1);
+ difR2 = (R3 - R2) / (Seg2 / Speed2);
+ difG2 = (G3 - G2) / (Seg2 / Speed2);
+ difB2 = (B3 - B2) / (Seg2 / Speed2);
+ R2 = difR1;
+ G2 = difG1;
+ B2 = difB1;
+ R3 = difR2;
+ G3 = difG2;
+ B3 = difB2;
+}
+
+/* -----------------24/05/00 10.24-------------------
+ * t3dPrecalcLight
+ * --------------------------------------------------*/
+void t3dPrecalcLight(t3dBODY *b, uint8 *sun) {
+ t3dV3F tmp, l, *normal;
+ t3dVERTEX vv;
+ t3dF32 nlight;
+ int32 k, aa, rr, gg, bb;
+ uint32 i, j, cv;
+
+ for (i = 0, cv = 0; i < b->NumMeshes(); i++) { // Si ripassa tutte le mesh
+ t3dMESH &Mesh = b->MeshTable[i];
+#ifndef WMGEN
+ Mesh.VBptr = Mesh.VertexBuffer;
+#endif
+ for (j = 0; j < Mesh.NumVerts; j++, cv++) { // Si passa tutti i vertici
+ rr = RGBA_GETRED(Mesh.VBptr[j].diffuse);
+ gg = RGBA_GETGREEN(Mesh.VBptr[j].diffuse);
+ bb = RGBA_GETBLUE(Mesh.VBptr[j].diffuse);
+ aa = RGBA_GETALPHA(Mesh.VBptr[j].diffuse);
+ tmp.x = Mesh.VBptr[j].x;
+ tmp.y = Mesh.VBptr[j].y;
+ tmp.z = Mesh.VBptr[j].z;
+ for (k = 0; k < (int)b->NumLights(); k++) { // Si passa tutte le luci
+ if ((b->LightTable[k].Type & T3D_LIGHT_REALTIME) || (b->LightTable[k].Type & T3D_LIGHT_FLARE) || !(b->LightTable[k].Type & T3D_LIGHT_LIGHTON)) continue;
+
+ t3dVectSub(&l, &b->LightTable[k].Source, &tmp); // Calcola vettore luce->vertice
+ t3dVectNormalize(&l); // lo normalizza
+
+ normal = &Mesh.NList[j]->n; // Calcola normale
+ if ((nlight = t3dVectDot(normal, &l)) >= 0) {
+ if (LightVertex(&vv, &tmp, &b->LightTable[k])) {
+ if ((sun) && (!sun[cv]) && (b->LightTable[k].Type & T3D_LIGHT_SUN)) {
+ rr += t3dFloatToInt(vv.r * nlight * 0.50f);
+ gg += t3dFloatToInt(vv.g * nlight * 0.35f);
+ bb += t3dFloatToInt(vv.b * nlight * 0.27f);
+ } else {
+ rr += t3dFloatToInt(vv.r * nlight);
+ gg += t3dFloatToInt(vv.g * nlight);
+ bb += t3dFloatToInt(vv.b * nlight);
+ }
+ }
+ }
+ }
+ if (rr < 0) rr = 0;
+ if (gg < 0) gg = 0;
+ if (bb < 0) bb = 0;
+ if (rr > 255) rr = 255;
+ if (gg > 255) gg = 255;
+ if (bb > 255) bb = 255;
+
+ Mesh.VBptr[j].diffuse = RGBA_MAKE(rr, gg, bb, aa);
+ }
+#ifndef WMGEN
+ Mesh.VBptr = nullptr;
+#endif
+ }
+}
+
+
+/* -----------------10/06/99 16.06-------------------
+ * t3dLoadSky
+ * --------------------------------------------------*/
+void t3dLoadSky(WGame &game, t3dBODY * /*body*/) {
+ t3dF32 Skyminx, Skyminy, Skyminz, Skymaxx, Skymaxy, Skymaxz;
+ uint16 n = 0, i;
+ gVertex *gv;
+// t3dF32 Tile=1.5f;
+ t3dF32 div;
+
+ if (!(t3dSky = t3dLoadRoom(game, "sky.t3d", t3dSky, &n, T3D_NORECURSION | T3D_NOLIGHTMAPS | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_NOBOUNDS | T3D_STATIC_SET0))) {
+ warning("Error during t3dLoadRoom: Sky not loaded");
+ }
+
+ GetBoundaries(t3dSky, &Skyminx, &Skyminy, &Skyminz, &Skymaxx, &Skymaxy, &Skymaxz);
+
+ for (i = 0; i < t3dSky->NumMeshes(); i++) {
+ gv = t3dSky->MeshTable[i].VertexBuffer;
+ for (n = 0; n < t3dSky->MeshTable[i].NumVerts; n++, gv++) {
+ gv->x -= Skyminx + ((Skymaxx - Skyminx) / 2.0f);
+ gv->y -= Skyminy + ((Skymaxy - Skyminy) / 2.0f);
+ gv->z -= Skyminz + ((Skymaxz - Skyminz) / 2.0f);
+ div = (t3dF32)sqrt(gv->x * gv->x + gv->y * gv->y + gv->z * gv->z);
+ gv->x /= div;
+ gv->y /= div;
+ gv->z /= div;
+
+ gv->x *= 15000;
+ gv->y *= 500;
+ gv->z *= 15000;
+
+ gv->u1 *= 1.0f;
+ gv->v1 *= 1.0f;
+ }
+
+ t3dSky->MeshTable[0].Radius = 15000.0f * 2;
+ }
+
+ for (n = 0; n < t3dSky->NumNormals; n++) {
+ t3dSky->NList[n]->dist *= 15000.0f;
+ }
+
+ for (n = 0; n < t3dSky->NumMaterials(); n++) {
+ t3dSky->MatTable[n]->Flags |= T3D_MATERIAL_SKY | T3D_MATERIAL_NOLIGHTMAP;
+ }
+}
+
+/* -----------------02/08/99 15.40-------------------
+ * t3dAddVertexBuffer
+ * --------------------------------------------------*/
+Common::SharedPtr<VertexBuffer> t3dAddVertexBuffer(t3dBODY *b, uint32 numv) {
+ return b->addVertexBuffer();
+}
+
+/* -----------------10/06/99 16.03-------------------
+ * t3dOptimizeMaterialList
+ * --------------------------------------------------*/
+void t3dOptimizeMaterialList(t3dBODY *b) {
+ for (int i = 0; i < b->NumMaterials(); i++) { // Scorre tutti materilai di un body
+ MaterialPtr Mat = b->MatTable[i];
+ if ((Mat == nullptr) || /*(!Mat->Texture->Name) ||*/ (Mat->Movie) || (Mat->Flags & T3D_MATERIAL_MOVIE)) // Se non esiste o non ha texture
+ continue; // esce
+
+ for (int j = 0; j < b->NumMaterials(); j++) { // Cerca materiali uguali
+ MaterialPtr CurMat = b->MatTable[j];
+ if (Mat == CurMat)
+ continue;
+
+ if (CurMat == nullptr /*|| (!CurMat->Texture->Name)*/)
+ continue;
+
+ if (Mat->Texture->name.equalsIgnoreCase(CurMat->Texture->name)) { // Se ha lo setsso nome di texture
+ //warning("TODO: Implement Material-merging");
+#if 0
+ // This is currently broken.
+ Mat = rMergeMaterial(Mat, CurMat); // Unisce i due materiali
+
+ t3dMESH *m = b->MeshTable;
+ for (int k = 0; k < b->NumMeshes; k++, m++) { // Aggiorna in tutte le mesh id materiale
+ t3dFACE *f = m->FList;
+ for (int q = 0; q < m->NumFaces; q++, f++) {
+ if (f->mat == CurMat)
+ f->mat = Mat;
+ }
+ }
+#endif
+ }
+ }
+ }
+}
+
+/* -----------------30/07/99 10.55-------------------
+ * t3dFinalizeMaterialList
+ * --------------------------------------------------*/
+void t3dFinalizeMaterialList(t3dBODY *b) {
+ for (uint32 i = 0; i < b->NumMeshes(); i++) {
+ t3dMESH &Mesh = b->MeshTable[i];
+#ifndef WMGEN
+ Mesh.VBptr = Mesh.VertexBuffer;
+#endif
+ for (uint32 j = 0; j < Mesh.NumFaces(); j++) {
+ t3dFACE &Face = Mesh.FList[j];
+ MaterialPtr Mat = Face.mat;
+ if (Face.lightmap) {
+ Mat = nullptr;
+ for (auto material : Face.mat->AddictionalMaterial) {
+ if (Mat->Texture->ID == Face.lightmap->Texture->ID) {
+ Mat = material;
+ break;
+ }
+ }
+ if (Mat == nullptr) {
+ warning("%s: Can't find Lightmap Sub-Material!", Mesh.name.c_str());
+ warning("%d %d", Face.mat->NumAddictionalMaterial, Face.lightmap->Texture->ID);
+ for (auto material : Face.mat->AddictionalMaterial) {
+ warning("%d", material->Texture->ID);
+ }
+ continue;
+ }
+ }
+
+ uint32 k = 0;
+ for (k = 0; k < (uint32)Mat->NumAllocatedMesh; k++)
+ if (Mat->FlagsList[k] == &Mesh.Flags)
+ break;
+
+ if (k >= (uint32)Mat->NumAllocatedMesh) {
+ Mat->FlagsList.push_back(&Mesh.Flags);
+ Mat->NumAllocatedMesh++;
+ Mesh.Flags |= T3D_MESH_UPDATEVB;
+ }
+ Mesh.Flags |= T3D_MESH_UPDATEVB;
+
+ for (uint32 h = 0; h < 3; h++) {
+ for (k = 0; k < (uint32)Mat->NumAllocatedVerts; k++)
+ if (Mat->VertsList[k] == &Mesh.VBptr[Face.VertexIndex[h]])
+ break;
+
+ if (k >= (uint32)Mat->NumAllocatedVerts) {
+ Mat->VertsList = (gVertex **)t3dRealloc(Mat->VertsList, sizeof(gVertex *));
+ Mat->VertsList[Mat->NumAllocatedVerts++] = &Mesh.VBptr[Face.VertexIndex[h]];
+ }
+ Face.MatVertexIndex[h] = (int16)k;
+ }
+ }
+#ifndef WMGEN
+ Mesh.VBptr = nullptr;
+#endif
+ }
+
+ warning("Partially stubbed t3dFinalizeMaterialList");
+
+ for (int i = 0; i < b->NumMaterials(); i++) {
+ auto &Mat = b->MatTable[i];
+ Mat->VBO = b->addVertexBuffer(); // t3dAddVertexBuffer(b, Mat->NumAllocatedVerts);
+ for (int j = 0; j < (uint32)Mat->NumAddictionalMaterial; j++)
+ Mat->AddictionalMaterial[j]->VBO = t3dAddVertexBuffer(b, Mat->AddictionalMaterial[j]->NumAllocatedVerts);
+ }
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/loader.h b/engines/watchmaker/3d/loader.h
new file mode 100644
index 00000000000..32e3b68eb9d
--- /dev/null
+++ b/engines/watchmaker/3d/loader.h
@@ -0,0 +1,88 @@
+/* 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 WATCHMAKER_LOADER_H
+#define WATCHMAKER_LOADER_H
+
+#include "watchmaker/t3d.h"
+#include "watchmaker/types.h"
+#include "watchmaker/work_dirs.h"
+
+namespace Watchmaker {
+
+#define SCALEFACTOR 1.0f//(1.0f/7.0f)
+
+#define MAX_MIRRORS 10
+
+#define T3D_GENERATESHADOWMAPS (1<<0) //Generate shadow maps
+#define T3D_NOLIGHTMAPS (1<<1) //view without lightmaps
+#define T3D_NORECURSION (1<<2) //do not recurse sub-rooms mirrors, reflections
+#define T3D_HALFTEXTURESIZE (1<<3) //Half the texture dimension when load .t3d texture
+#define T3D_FULLSCREEN (1<<4) //run in fullscreen
+#define T3D_FASTRENDERING (1<<5) //render shadow/light maps with minimum dimension
+#define T3D_OUTDOORLIGHTS (1<<6) //load .oli files for outdoor lights informations
+#define T3D_NOVOLUMETRICLIGHTS (1<<7) //do not load .vol file
+#define T3D_NOBOUNDS (1<<8) //do not load .vol file
+#define T3D_NOCAMERAS (1<<9) //do not load .vol file
+#define T3D_NONEXCLUSIVEMOUSE (1<<10) // mouse is not in exclusive mode
+#define T3D_RECURSIONLEVEL1 (1<<12) // one recursion level only
+#define T3D_SKY (1<<13) // if the sky is visible
+#define T3D_PRELOAD_RXT (1<<14) // preload extern
+#define T3D_STATIC_SET0 (1<<15) // static loaded elements
+#define T3D_STATIC_SET1 (1<<16) // static loaded elements
+#define T3D_NOSHADOWS (1<<17) // do not calc shadows
+#define T3D_NOICONS (1<<18) // do not load icons
+#define T3D_NOSOUND (1<<19) // do not use sound system
+#define T3D_PRELOADBASE (1<<20) // preload basic elements
+#define T3D_NOMUSIC (1<<21) // do not use music system
+#define T3D_DEBUGMODE (1<<22) // debug mode
+#define T3D_FASTFILE (1<<23) // fastfile
+#define T3D_HIPOLYPLAYERS (1<<24) // hipoly players (darrell e victoria hipoly)
+#define T3D_HIPOLYCHARACTERS (1<<25) // hipoly characters (gli abitanti del castello hipoly)
+
+// TODO: Unglobalize
+extern t3dV3F CharCorrection;
+extern t3dF32 CurFloorY;
+extern int32 t3dCurTime, t3dCurOliSet;
+
+struct RecStruct {
+ Common::String name;
+ t3dBODY *b = nullptr;
+ uint32 Flags = 0;
+};
+
+extern RecStruct LoadedFiles[];
+extern uint16 NumLoadedFiles;
+
+t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, unsigned short *NumBody, unsigned int LoaderFlags);
+t3dBODY *t3dLoadSingleRoom(WGame &game, const char *_pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags);
+void t3dOptimizeMaterialList(t3dBODY *b);
+void t3dFinalizeMaterialList(t3dBODY *b);
+void t3dPrecalcLight(t3dBODY *b, unsigned char *sun);
+void t3dLoadSky(WGame &game, t3dBODY *b);
+
+t3dBODY *CheckIfAlreadyLoaded(const Common::String &Name);
+void AddToLoadList(t3dMESH *m, const Common::String &pname, uint32 LoaderFlags);
+Common::String constructPath(const Common::String &prefix, const Common::String &filename, const char *suffix = nullptr);
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_LOADER_H
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
new file mode 100644
index 00000000000..93a9d0c7d37
--- /dev/null
+++ b/engines/watchmaker/3d/material.cpp
@@ -0,0 +1,322 @@
+/* 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/util.h"
+#include "watchmaker/3d/material.h"
+#include "watchmaker/render.h"
+
+namespace Watchmaker {
+
+MaterialPtr rAddMaterial(gMaterial &Material, const Common::String &TextName, int NumFaces, unsigned int LoaderFlags) {
+ // TODO: This is duplicated in opengl_3d.cpp
+ warning("TODO: Fix rAddMaterial\n");
+#if 0
+ bool AlreadyLoaded=FALSE;
+ int len=strlen(TextName);
+
+ if (((TextName[len-1-0]=='i')|| (TextName[len-1-0]=='I')) &&
+ ((TextName[len-1-1]=='v')|| (TextName[len-1-1]=='V')) &&
+ ((TextName[len-1-2]=='a')|| (TextName[len-1-2]=='A')) )
+ {
+ if( (Material.Movie=gLoadMovie(TextName)) == NULL )
+ return NULL;
+ if( (Material.Texture=gUserTexture( 64,
+ 128)) == NULL )
+// if( (Material->Texture=gUserTexture( Material->Movie->g_psiStreamInfo.rcFrame.right,
+// Material->Movie->g_psiStreamInfo.rcFrame.bottom)) == NULL )
+ return NULL;
+ Material.Flags|=T3D_MATERIAL_MOVIE;
+ }
+ else
+ {
+ if( (Material.Texture=gLoadTexture(TextName,LoaderFlags)) == NULL )
+ return NULL;
+ }
+
+//f
+//f Material->FacesList=(WORD *)t3dRealloc(Material->FacesList,sizeof(WORD)*3*NumFaces+1);
+//f Material->NumAllocatedFaces+=3*NumFaces+1;
+ Material.FacesList.resize(Material.FacesList.size() + NumFaces * 3 );
+ Material.NumAllocatedFaces+=NumFaces*3;
+//f
+ Material.Flags|=T3D_MATERIAL_NOLIGHTMAP;
+ return Material;
+#endif
+ return nullptr;
+}
+
+MaterialPtr rAddMaterial(MaterialTable &MList, const Common::String &TextName, int NumFaces, unsigned int LoaderFlags) {
+ MaterialPtr &Material=MList[0];
+ rAddMaterial(*Material, TextName, NumFaces, LoaderFlags);
+}
+
+void gMaterial::addProperty(int flag) {
+ this->Flags |= flag;
+}
+
+
+void gMaterial::addColor(unsigned char r_add, unsigned char g_add, unsigned char b_add) {
+ int rr, gg, bb;
+
+ rr = this->r;
+ gg = this->g;
+ bb = this->b;
+
+ rr += r;
+ gg += g;
+ bb += b;
+
+ rr = MIN(MAX(rr, 0), 255);
+ gg = MIN(MAX(gg, 0), 255);
+ bb = MIN(MAX(bb, 0), 255);
+
+ this->r = (unsigned char)rr;
+ this->g = (unsigned char)gg;
+ this->b = (unsigned char)bb;
+}
+
+bool gMaterial::addNumFacesAdditionalMaterial(MaterialPtr am, unsigned int num) {
+ if( !num || !am )
+ return false;
+
+ Common::SharedPtr<gMaterial> cm;
+ int i;
+ for ( i=0; i<this->NumAddictionalMaterial; i++ ) {
+ cm = this->AddictionalMaterial[i];
+ if (cm->Texture->ID == am->Texture->ID)
+ break;
+ }
+
+ if( i == this->NumAddictionalMaterial )
+ {
+ this->AddictionalMaterial.push_back(Common::SharedPtr<gMaterial>(new gMaterial(*am)));
+ cm = this->AddictionalMaterial.back();
+ cm->NumAllocatedFaces=0;
+ cm->FacesList.clear();
+ this->NumAddictionalMaterial++;
+ }
+
+ cm->FacesList.resize(cm->FacesList.size() + num*3);
+ cm->NumAllocatedFaces+=num*3;
+ return true;
+}
+
+bool gMaterial::addNumFaces(unsigned int num) {
+ if (num == 0)
+ return false;
+
+ FacesList.resize(FacesList.size() + num * 3);
+ NumAllocatedFaces += num * 3;
+ return true;
+}
+
+
+MaterialPtr rMergeMaterial(MaterialPtr Mat1, MaterialPtr Mat2) {
+ if ( !Mat1 || !Mat2 )
+ return nullptr;
+
+ for ( int i=0; i<Mat2->NumAddictionalMaterial; i++ ) {
+ Mat1->addNumFacesAdditionalMaterial(Mat2->AddictionalMaterial[i],
+ Mat2->AddictionalMaterial[i]->NumAllocatedFaces);
+ }
+ Mat1->addNumFaces(Mat2->NumAllocatedFaces);
+
+ //reset mat2
+ rRemoveMaterial(Mat2);
+ *Mat2 = gMaterial();
+
+ return Mat1;
+}
+
+void rRemoveMaterials(Common::Array<Common::SharedPtr<gMaterial>> &m) {
+ for (auto &material : m) {
+ m.clear();
+ }
+}
+
+Common::SharedPtr<gMaterial> rCopyMaterial(Common::SharedPtr<gMaterial> Mat1, Common::SharedPtr<gMaterial> Mat2) {
+ int i;
+
+ if (!Mat1 || !Mat2)
+ return nullptr;
+
+ Mat1->FacesList.clear();
+ Mat1->AddictionalMaterial.clear();
+ Mat1->FacesList.clear();
+ delete[] Mat1->VertsList;
+ Mat1->VertsList = nullptr;
+ //t3dFree(Mat1->FlagsList);
+ *Mat1 = gMaterial();
+
+ if (Mat2->NumAllocatedFaces) {
+ Mat1->addNumFaces(Mat2->NumAllocatedFaces);
+ for (int i = 0; i < Mat2->NumAllocatedFaces; i++) {
+ Mat1->FacesList.push_back(Mat2->FacesList[i]);
+ }
+ }
+ if (Mat2->NumAllocatedVerts) {
+ Mat1->VertsList = new gVertex*[Mat2->NumAllocatedVerts]{};
+ memcpy(Mat1->VertsList, Mat2->VertsList, sizeof(gVertex *)*Mat2->NumAllocatedVerts);
+ }
+ if (Mat2->NumAllocatedMesh) {
+ Mat1->FlagsList = Mat2->FlagsList;
+ }
+
+ Mat1->Texture = Mat2->Texture;
+ Mat1->Movie = Mat2->Movie;
+ Mat1->Flags = Mat2->Flags;
+ Mat1->NumFaces = Mat2->NumFaces;
+ Mat1->NumAllocatedFaces = Mat2->NumAllocatedFaces;
+ Mat1->NumAllocatedVerts = Mat2->NumAllocatedVerts;
+ Mat1->VBO = Mat2->VBO;
+ Mat1->NumAllocatedMesh = Mat2->NumAllocatedMesh;
+ Mat1->r = Mat2->r;
+ Mat1->g = Mat2->g;
+ Mat1->b = Mat2->b;
+ Mat1->NumAddictionalMaterial = Mat2->NumAddictionalMaterial;
+
+ if (Mat2->NumAddictionalMaterial)
+ Mat1->AddictionalMaterial.resize(Mat2->NumAddictionalMaterial); // TODO: Does this mean that we don't copy any extras?
+
+ for (i = 0; i < Mat2->NumAddictionalMaterial; i++)
+ rCopyMaterial(Mat1->AddictionalMaterial[i], Mat2->AddictionalMaterial[i]);
+
+ return Mat1;
+}
+
+void gMaterial::clear() {
+ if (Movie)
+ {
+ Movie = nullptr;
+ }
+ FacesList.clear();
+ delete[] VertsList;
+ VertsList=nullptr;
+ FlagsList.clear();
+// rDeleteVertexBuffer(m->VB);
+ VBO=0;
+
+ for ( int j=0; j<NumAddictionalMaterial; j++)
+ {
+ Common::SharedPtr<gMaterial> cm = AddictionalMaterial[j];
+ cm->FacesList.clear();
+ delete[] cm->VertsList;
+ cm->VertsList=nullptr;
+ cm->FlagsList.clear();
+// rDeleteVertexBuffer(cm->VB);
+ cm->VBO=0;
+ }
+ AddictionalMaterial.clear();
+}
+
+
+void rRemoveMaterial(Common::SharedPtr<gMaterial> &m) {
+ m->clear();
+}
+
+
+/* -----------------29/07/99 15.53-------------------
+ * Aggiunge un materiale alla MaterialList
+ * --------------------------------------------------*/
+void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
+ //warning("Stubbed: rAddToMaterialList\n");
+ //D3DVERTEXBUFFERDESC VBDesc;
+ gMaterial *cm;
+ gBatchBlock *bb;
+ int j;
+#if 0
+ if (!mat)
+ return;
+
+ if ((mat.Flags & T3D_MATERIAL_MOVIE))
+ gUpdateMovie(mat);
+#endif
+ if ((mat.NumFaces >= 3) && (mat.VBO)) {
+ bb = rNewBatchBlock(mat.Texture->ID, mat.Flags, 0, 0);
+ bb->ViewMatrixNum = ViewMatrixNum;
+ bb->NumFaces = (unsigned short int) mat.NumFaces;
+ bb->FacesList = mat.FacesList;
+ bb->VBO = mat.VBO;
+ bb->NumVerts = (unsigned short int) mat.NumAllocatedVerts;
+ mat.NumFaces = 0;
+// if ( bb->VB == g_lpD3DUserVertexBuffer )
+// DebugLogFile("User VB %s with %d verts",mat->Texture->Name,bb->NumVerts);
+#if 0
+ if ((bb->NumVerts == 0) && (bb->VBO)) {
+ if (bb->VB->GetVertexBufferDesc(&VBDesc) != D3D_OK)
+ DebugLogFile("Can't get VB information for %s", mat->Texture->Name);
+ else
+ bb->NumVerts = (unsigned short int) VBDesc.dwNumVertices;
+// DebugLogFile("Saving VB %s with %d verts",mat->Texture->Name,bb->NumVerts);
+ }
+#endif
+ }
+
+ for (auto &cm : mat.AddictionalMaterial) {
+ if (cm->NumFaces < 3) continue;
+ if (cm->VBO == NULL) continue;
+ bb = rNewBatchBlock(mat.Texture->ID, mat.Flags, cm->Texture->ID, cm->Flags);
+ bb->ViewMatrixNum = ViewMatrixNum;
+ bb->NumFaces = (unsigned short int) cm->NumFaces;
+ bb->FacesList = cm->FacesList;
+ bb->VBO = cm->VBO;
+ bb->NumVerts = (unsigned short int) cm->NumAllocatedVerts;
+ cm->NumFaces = 0;
+ if (bb->NumVerts == 0) {
+#if 0
+ if (bb->VBO->GetVertexBufferDesc(&VBDesc) != D3D_OK)
+ DebugLogFile("Can't get VB information for %s", mat->Texture->Name);
+ else
+ bb->NumVerts = (unsigned short int) VBDesc.dwNumVertices;
+// DebugLogFile("Saving VB %s with %d verts",mat->Texture->Name,bb->NumVerts);
+#endif
+ }
+ }
+}
+
+void rAddToMaterialList(MaterialPtr mat, signed short int ViewMatrixNum) {
+ if (mat) {
+ rAddToMaterialList(*mat, ViewMatrixNum);
+ }
+}
+
+/* -----------------31/05/99 10.07-------------------
+ * Costruisce la lista dei materiali ordinata
+ * --------------------------------------------------*/
+void rBuildMaterialList(MaterialTable &MatList, unsigned int NumMat, signed short int ViewMatrixNum) {
+ if (NumMat == 0)
+ return;
+
+ for (auto &mat: MatList) {
+ rAddToMaterialList(mat, ViewMatrixNum);
+ }
+}
+
+MaterialTable rCreateMaterialList(int num) {
+ MaterialTable list;
+ list.reserve(num);
+ for (int i = 0; i < num; i++) {
+ list.push_back(Common::SharedPtr<gMaterial>(new gMaterial()));
+ }
+ return list;
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/material.h b/engines/watchmaker/3d/material.h
new file mode 100644
index 00000000000..dd675f644d9
--- /dev/null
+++ b/engines/watchmaker/3d/material.h
@@ -0,0 +1,77 @@
+/* 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 WATCHMAKER_MATERIAL_H
+#define WATCHMAKER_MATERIAL_H
+
+#include "common/array.h"
+#include "common/ptr.h"
+#include "watchmaker/3d/texture.h"
+#include "watchmaker/3d/movie.h"
+#include "watchmaker/3d/vertex.h"
+
+namespace Watchmaker {
+
+struct gMaterial;
+typedef Common::SharedPtr<gMaterial> MaterialPtr;
+typedef Common::Array<MaterialPtr> MaterialTable;
+
+struct VertexBuffer;
+// Material definition
+struct gMaterial {
+ gTexture *Texture = nullptr; // pointer to texture struct
+ Common::SharedPtr<gMovie> Movie; // pointer to movie struct
+ unsigned int Flags = 0; // material flags
+ int NumFaces = 0; // current number of faces to be processed
+ int NumAllocatedFaces = 0; // maximum number of faces
+ Common::Array<uint16> FacesList; // list of verts indices
+ int NumAllocatedVerts = 0; // number of allocated vertex in mat VB
+ gVertex **VertsList = nullptr; // pointers to pointers to verts
+ Common::SharedPtr<VertexBuffer> VBO = nullptr;
+// LPDIRECT3DVERTEXBUFFER7 VB; // mat VB struct
+ int NumAllocatedMesh = 0; // num mesh to check for modifications
+ Common::Array<unsigned int *> FlagsList; // vector of pointer to mesh flags
+ unsigned char r, g, b; // default material color
+ int NumAddictionalMaterial = 0; // number of addictional material (lightmaps)
+ MaterialTable AddictionalMaterial; // pointer to addictional material struct
+public:
+ gMaterial() : r(0), g(0), b(0) {
+
+ }
+ void addColor(unsigned char r, unsigned char g, unsigned char b);
+ void addProperty(int flag);
+ bool addNumFaces(unsigned int num);
+ bool addNumFacesAdditionalMaterial(MaterialPtr am, unsigned int num);
+ void clear();
+};
+
+MaterialPtr rAddMaterial(MaterialTable &MList, const Common::String &TextName, int NumFaces, unsigned int LoaderFlags);
+MaterialPtr rAddMaterial(gMaterial &Material, const Common::String &TextName, int NumFaces, unsigned int LoaderFlags);
+void rRemoveMaterial(MaterialPtr &m);
+void rRemoveMaterials(MaterialTable &m);
+MaterialPtr rCopyMaterial(MaterialPtr Mat1, MaterialPtr Mat2);
+MaterialPtr rMergeMaterial(MaterialPtr Mat1, MaterialPtr Mat2);
+void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum);
+
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_MATERIAL_H
diff --git a/engines/watchmaker/3d/math/Matrix4x4.cpp b/engines/watchmaker/3d/math/Matrix4x4.cpp
new file mode 100644
index 00000000000..b295e5882de
--- /dev/null
+++ b/engines/watchmaker/3d/math/Matrix4x4.cpp
@@ -0,0 +1,26 @@
+/* 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 "watchmaker/3d/math/Matrix4x4.h"
+
+namespace Watchmaker {
+
+} // End of namespace Watchmaker
\ No newline at end of file
diff --git a/engines/watchmaker/3d/math/Matrix4x4.h b/engines/watchmaker/3d/math/Matrix4x4.h
new file mode 100644
index 00000000000..9e03d900481
--- /dev/null
+++ b/engines/watchmaker/3d/math/Matrix4x4.h
@@ -0,0 +1,69 @@
+/* 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 WATCHMAKER_MATRIX4X4_H
+#define WATCHMAKER_MATRIX4X4_H
+
+#include "common/scummsys.h"
+#include "common/textconsole.h"
+
+namespace Watchmaker {
+
+struct Matrix4x4 {
+ float data[16] = {};
+
+ void setIdentity() {
+ setValue(1, 1, 1.0f);
+ setValue(2, 2, 1.0f);
+ setValue(3, 3, 1.0f);
+ setValue(4, 4, 1.0f);
+ }
+
+ void setValue(int row, int col, float value) {
+ data[(col - 1) * 4 + (row - 1)] = value;
+ }
+ float getValue(int row, int col) const {
+ return data[(col - 1) * 4 + (row - 1)];
+ }
+ void print() const {
+ for (int row = 1; row <= 4; row++) {
+ for (int col = 1; col <= 4; col++) {
+ warning("%f ", getValue(row, col));
+ }
+ warning("\n");
+ }
+ }
+ bool operator==(const Matrix4x4 &rhs) const {
+ for (int row = 1; row <= 4; row++) {
+ for (int col = 1; col <= 4; col++) {
+ if (getValue(row, col) != rhs.getValue(row, col)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+};
+
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_MATRIX4X4_H
diff --git a/engines/watchmaker/3d/math/llmath.cpp b/engines/watchmaker/3d/math/llmath.cpp
new file mode 100644
index 00000000000..3e168594132
--- /dev/null
+++ b/engines/watchmaker/3d/math/llmath.cpp
@@ -0,0 +1,427 @@
+/* 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 "watchmaker/3d/math/llmath.h"
+#include "watchmaker/utils.h"
+
+namespace Watchmaker {
+
+int32 t3dFloatToInt(t3dF32 nfloat) {
+ int32 sint = nfloat;
+ // warning("STUBBED: t3dFloatToInt\n");
+ /*
+ __asm
+ {
+ fld nfloat
+ fistp sint
+ }*/
+ return sint;
+}
+
+void t3dMatIdentity(t3dM3X3F *d) {
+ d->M[1] = d->M[2] = d->M[3] = d->M[5] = d->M[6] = d->M[7] = 0.0;
+ d->M[0] = d->M[4] = d->M[8] = 1.0;
+
+ d->Flags |= T3D_MATRIX_IDENTITY;
+}
+
+void t3dMatMul(t3dM3X3F *Dest, t3dM3X3F *a, t3dM3X3F *b) {
+ t3dM3X3F Tmp, *d = &Tmp;
+ /* t3dM3X3F Tmp,*d=&Tmp;
+ int r,c;
+
+ if (Dest == a || Dest == b)
+ d=&Tmp;
+ else
+ d=Dest;
+
+ for (r=0; r<3; r++)
+ for (c=0; c<3; c++)
+ d->M[r][c]=a->M[r][0]*b->M[0][c]+a->M[r][1]*b->M[1][c]+a->M[r][2]*b->M[2][c];*/
+
+ d->M[0] = (a->M[0] * b->M[0] + a->M[1] * b->M[3] + a->M[2] * b->M[6]);
+ d->M[1] = (a->M[0] * b->M[1] + a->M[1] * b->M[4] + a->M[2] * b->M[7]);
+ d->M[2] = (a->M[0] * b->M[2] + a->M[1] * b->M[5] + a->M[2] * b->M[8]);
+
+ d->M[3] = (a->M[3] * b->M[0] + a->M[4] * b->M[3] + a->M[5] * b->M[6]);
+ d->M[4] = (a->M[3] * b->M[1] + a->M[4] * b->M[4] + a->M[5] * b->M[7]);
+ d->M[5] = (a->M[3] * b->M[2] + a->M[4] * b->M[5] + a->M[5] * b->M[8]);
+
+ d->M[6] = (a->M[6] * b->M[0] + a->M[7] * b->M[3] + a->M[8] * b->M[6]);
+ d->M[7] = (a->M[6] * b->M[1] + a->M[7] * b->M[4] + a->M[8] * b->M[7]);
+ d->M[8] = (a->M[6] * b->M[2] + a->M[7] * b->M[5] + a->M[8] * b->M[8]);
+
+ if (d != Dest)
+ t3dMatCopy(Dest, &Tmp);
+
+}
+
+void t3dMatCopy(t3dM3X3F *d, t3dM3X3F *s) {
+ d->M[0] = s->M[0];
+ d->M[1] = s->M[1];
+ d->M[2] = s->M[2];
+ d->M[3] = s->M[3];
+ d->M[4] = s->M[4];
+ d->M[5] = s->M[5];
+ d->M[6] = s->M[6];
+ d->M[7] = s->M[7];
+ d->M[8] = s->M[8];
+ d->Flags = 0;
+}
+
+void t3dMatView(t3dM3X3F *dest, t3dV3F *eye, t3dV3F *center) {
+ t3dM3X3F *fm = dest;
+ t3dM3X3F fmat;
+
+// D3DVECTOR from,at,up;
+
+ if ((!eye) || (!dest)) return;
+
+ // F
+ t3dF32 dx = (t3dF32)(center->x - eye->x);
+ t3dF32 dy = (t3dF32)(center->y - eye->y);
+ t3dF32 dz = (t3dF32)(center->z - eye->z);
+
+ t3dF32 dd = (dx * dx + dy * dy + dz * dz);
+ if (dd == 0.0)dd = 1.0;
+ dd = (float)sqrt((t3dF64)dd); // dd = ||F||
+
+ t3dF32 d2 = (dz * dz + dx * dx);
+ if (d2 == 0.0)d2 = 1.0;
+ d2 = (float)sqrt((t3dF64)d2); // |s|
+
+ t3dF32 fcosa = (dz / d2);
+ t3dF32 fsina = (dx / d2);
+ fm->M[0] = fcosa;
+ fm->M[1] = 0;
+ fm->M[2] = -fsina;
+ fm->M[3] = 0;
+ fm->M[4] = 1;
+ fm->M[5] = 0;
+ fm->M[6] = fsina;
+ fm->M[7] = 0;
+ fm->M[8] = fcosa;
+
+ fcosa = (d2 / dd);
+ fsina = (dy / dd);
+ fmat.M[0] = 1;
+ fmat.M[1] = 0;
+ fmat.M[2] = 0;
+ fmat.M[3] = 0;
+ fmat.M[4] = fcosa;
+ fmat.M[5] = -fsina;
+ fmat.M[6] = 0;
+ fmat.M[7] = fsina;
+ fmat.M[8] = fcosa;
+ t3dMatMul(dest, &fmat, dest);
+
+ const float roll = 0.0f;
+ fcosa = (t3dF32)cos((-roll) / 180.0f * T3D_PI);
+ fsina = (t3dF32)sin((-roll) / 180.0f * T3D_PI);
+ fmat.M[0] = fcosa;
+ fmat.M[1] = fsina;
+ fmat.M[2] = 0;
+ fmat.M[3] = -fsina;
+ fmat.M[4] = fcosa;
+ fmat.M[5] = 0;
+ fmat.M[6] = 0;
+ fmat.M[7] = 0;
+ fmat.M[8] = 1;
+ t3dMatMul(dest, &fmat, dest);
+
+ dest->Flags &= ~T3D_MATRIX_IDENTITY;
+}
+
+void t3dVectTransform(t3dV3F *d, t3dV3F *s, t3dM3X3F *mat) {
+ t3dV3F Tmp;
+ Tmp.x = (s->x * mat->M[0]) + (s->y * mat->M[1]) + (s->z * mat->M[2]);
+ Tmp.y = (s->x * mat->M[3]) + (s->y * mat->M[4]) + (s->z * mat->M[5]);
+ Tmp.z = (s->x * mat->M[6]) + (s->y * mat->M[7]) + (s->z * mat->M[8]);
+ d->x = Tmp.x;
+ d->y = Tmp.y;
+ d->z = Tmp.z;
+}
+
+void t3dVectTransformInv(t3dV3F *d, t3dV3F *s, t3dM3X3F *mat) {
+ t3dV3F Tmp;
+ Tmp.x = (s->x * mat->M[0]) + (s->y * mat->M[3]) + (s->z * mat->M[6]);
+ Tmp.y = (s->x * mat->M[1]) + (s->y * mat->M[4]) + (s->z * mat->M[7]);
+ Tmp.z = (s->x * mat->M[2]) + (s->y * mat->M[5]) + (s->z * mat->M[8]);
+ d->x = Tmp.x;
+ d->y = Tmp.y;
+ d->z = Tmp.z;
+}
+
+void t3dVectCross(t3dV3F *d, t3dV3F *v2, t3dV3F *v3) {
+ t3dV3F Tmp;
+ Tmp.x = (v2->y * v3->z) - (v2->z * v3->y);
+ Tmp.y = (v2->z * v3->x) - (v2->x * v3->z);
+ Tmp.z = (v2->x * v3->y) - (v2->y * v3->x);
+ d->x = Tmp.x;
+ d->y = Tmp.y;
+ d->z = Tmp.z;
+}
+
+void t3dVectSub(t3dV3F *d, t3dV3F *a, t3dV3F *b) { // d = a - b
+ d->x = a->x - b->x;
+ d->y = a->y - b->y;
+ d->z = a->z - b->z;
+}
+
+void t3dVectAdd(t3dV3F *d, t3dV3F *a, t3dV3F *b) { // d = a - b
+ d->x = a->x + b->x;
+ d->y = a->y + b->y;
+ d->z = a->z + b->z;
+}
+
+void t3dVectFill(t3dV3F *d, t3dF32 a) {
+ d->x = a;
+ d->y = a;
+ d->z = a;
+}
+
+void t3dVectInit(t3dV3F *d, t3dF32 a1, t3dF32 a2, t3dF32 a3) {
+ d->x = a1;
+ d->y = a2;
+ d->z = a3;
+}
+
+void t3dVectCopy(t3dV3F *d, t3dV3F *s) {
+ memcpy(d, s, sizeof(t3dV3F));
+}
+
+
+t3dF32 t3dVectMod(t3dV3F *c) {
+ t3dF32 mod = (c->x * c->x + c->y * c->y + c->z * c->z);
+ if (mod)
+ return (float)sqrt((double)mod);
+ else
+ return 0.0f;
+}
+
+t3dF32 t3dVectDistance(t3dV3F *a, t3dV3F *b) {
+ t3dF32 mod;
+ t3dV3F c;
+ c.x = b->x - a->x;
+ c.y = b->y - a->y;
+ c.z = b->z - a->z;
+ mod = (c.x * c.x + c.y * c.y + c.z * c.z);
+
+ if (mod)
+ return ((float)sqrt((double)mod));
+ else
+ return 0.0f;
+}
+
+t3dF32 t3dVectDot(t3dV3F *a, t3dV3F *b) {
+ return (t3dF32)(a->x * b->x + a->y * b->y + a->z * b->z);
+}
+
+void t3dMatMulInv(t3dM3X3F *Dest, t3dM3X3F *a, t3dM3X3F *b) {
+ t3dM3X3F Tmp, *d = &Tmp;
+
+ d->M[0] = (a->M[0] * b->M[0] + a->M[1] * b->M[1] + a->M[2] * b->M[2]);
+ d->M[1] = (a->M[0] * b->M[3] + a->M[1] * b->M[4] + a->M[2] * b->M[5]);
+ d->M[2] = (a->M[0] * b->M[6] + a->M[1] * b->M[7] + a->M[2] * b->M[8]);
+
+ d->M[3] = (a->M[3] * b->M[0] + a->M[4] * b->M[1] + a->M[5] * b->M[2]);
+ d->M[4] = (a->M[3] * b->M[3] + a->M[4] * b->M[4] + a->M[5] * b->M[5]);
+ d->M[5] = (a->M[3] * b->M[6] + a->M[4] * b->M[7] + a->M[5] * b->M[8]);
+
+ d->M[6] = (a->M[6] * b->M[0] + a->M[7] * b->M[1] + a->M[8] * b->M[2]);
+ d->M[7] = (a->M[6] * b->M[3] + a->M[7] * b->M[4] + a->M[8] * b->M[5]);
+ d->M[8] = (a->M[6] * b->M[6] + a->M[7] * b->M[7] + a->M[8] * b->M[8]);
+
+ if (d != Dest)
+ t3dMatCopy(Dest, &Tmp);
+}
+
+void t3dPlaneNormal(t3dNORMAL *n, t3dV3F *p0, t3dV3F *p1, t3dV3F *p2) {
+ t3dV3F a, b;
+
+ t3dVectSub(&a, p1, p0);
+ t3dVectSub(&b, p2, p0);
+ t3dVectCross(&n->n, &a, &b);
+ t3dVectNormalize(&n->n);
+
+ n->dist = t3dVectDot(&n->n, p0);
+}
+
+void t3dVectNormalize(t3dV3F *c) {
+ t3dF32 mod = (float)sqrt((double)(c->x * c->x + c->y * c->y + c->z * c->z));
+ if (!mod)return;
+ mod = 1.0f / mod;
+ c->x = c->x * mod;
+ c->y = c->y * mod;
+ c->z = c->z * mod;
+}
+
+void t3dMatRot(t3dM3X3F *matrix, t3dF32 x, t3dF32 y, t3dF32 z) {
+ /* t3dF32 cx, cy, cz, sx, sy, sz,sxsy,szsy,szcy,czcy;
+
+ sx = sin(x);cx = cos(x); // qui ci vorrebbe una FSINCOS in asm
+ sy = sin(y);cy = cos(y);
+ sz = sin(z);cz = cos(z);
+ sxsy=sx*sy;szsy=sz*sy;szcy=sz*cy;czcy=cz*cy;
+ matrix->M[0] = czcy + sx*szsy ;
+ matrix->M[1] = -szcy + sxsy*cz ;
+ matrix->M[2] = cx*sy;
+ matrix->M[3] = cx*sz;
+ matrix->M[4] = cx*cz;
+ matrix->M[5] = -sx;
+ matrix->M[6] = -cz*sy + sx*szcy;
+ matrix->M[7] = szsy + sx*czcy;
+ matrix->M[8] = cx*cy ;*/
+
+
+ t3dM3X3F matrix_x, matrix_y, matrix_z;
+
+ t3dMatIdentity(&matrix_x);
+ t3dMatIdentity(&matrix_y);
+ t3dMatIdentity(&matrix_z);
+
+ /* | 1 0 0 0 | x' = x
+ | 0 cos � -sin � 0 | y' = (cos �) * y - (sin �) * z
+ | 0 sin � cos � 0 | z' = (sin �) * y + (cos �) * z
+ | 0 0 0 1 |*/
+
+ matrix_x.M[4] = (float)cos(x);
+ matrix_x.M[5] = -(float)sin(x);
+ matrix_x.M[7] = (float)sin(x);
+ matrix_x.M[8] = (float)cos(x);
+
+ /* | cos � 0 sin � 0 | x' = (cos �) * x + (sin �) * z
+ | 0 1 0 0 | y' = y
+ | -sin � 0 cos � 0 | z' = -(sin �) * x + (cos �) * z
+ | 0 0 0 1 |*/
+
+ matrix_y.M[0] = (float)cos(y);
+ matrix_y.M[2] = (float)sin(y);
+ matrix_y.M[6] = -(float)sin(y);
+ matrix_y.M[8] = (float)cos(y);
+
+ /* | cos � -sin � 0 0 | x' = (cos �) * x - (sin �) * y
+ | sin � cos � 0 0 | y' = (sin �) * x + (cos �) * y
+ | 0 0 1 0 | z' = z
+ | 0 0 0 1 |*/
+
+ matrix_z.M[0] = (float)cos(z);
+ matrix_z.M[1] = -(float)sin(z);
+ matrix_z.M[3] = (float)sin(z);
+ matrix_z.M[4] = (float)cos(z);
+
+ t3dMatMul(matrix, &matrix_x, &matrix_y);
+ t3dMatMul(matrix, matrix, &matrix_z);
+}
+
+t3dF32 t3dVectPlaneDistance(t3dV3F start, t3dNORMAL n) {
+ return t3dVectDot(&start, &n.n) - n.dist;
+}
+
+uint8 t3dVectPlaneIntersection(t3dV3F *inter, t3dV3F start, t3dV3F end, t3dNORMAL n) {
+ t3dF32 divi;
+ t3dF32 d1 = t3dVectPlaneDistance(start, n);
+ t3dF32 d2 = t3dVectPlaneDistance(end, n);
+
+ if ((d1 < 0) && (d2 < 0))
+ return 0;
+ else if ((d1 >= 0) && (d2 >= 0))
+ return 1;
+
+
+ if ((d1 < 0) && (d2 >= 0)) {
+ d2 = d2 - d1;
+ divi = -d1 / d2;
+ inter->x = start.x + divi * (end.x - start.x);
+ inter->y = start.y + divi * (end.y - start.y);
+ inter->z = start.z + divi * (end.z - start.z);
+ return 2;
+ } else {
+ d1 = d1 - d2;
+ divi = -d2 / d1;
+ inter->x = end.x + divi * (start.x - end.x);
+ inter->y = end.y + divi * (start.y - end.y);
+ inter->z = end.z + divi * (start.z - end.z);
+ return 3;
+ }
+}
+
+uint8 t3dVectTriangleIntersection(t3dV3F *inter, t3dV3F start, t3dV3F end,
+ t3dV3F v1, t3dV3F v2, t3dV3F v3, t3dNORMAL n) {
+ t3dV3F appo;
+ t3dNORMAL normal;
+
+ if (t3dVectPlaneIntersection(inter, start, end, n) <= 1)
+ return 0;
+
+ t3dVectAdd(&appo, &n.n, &v1);
+ t3dPlaneNormal(&normal, &appo, &v1, &v2);
+
+ if (t3dVectPlaneDistance(*inter, normal) >= 0.0f) {
+ t3dVectAdd(&appo, &n.n, &v2);
+ t3dPlaneNormal(&normal, &appo, &v2, &v3);
+ if (t3dVectPlaneDistance(*inter, normal) >= 0.0f) {
+ t3dVectAdd(&appo, &n.n, &v3);
+ t3dPlaneNormal(&normal, &appo, &v3, &v1);
+ if (t3dVectPlaneDistance(*inter, normal) >= 0.0f)
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+t3dF32 t3dVectSquaredDistance(t3dV3F *a, t3dV3F *b) {
+ t3dV3F c;
+ c.x = b->x - a->x;
+ c.y = b->y - a->y;
+ c.z = b->z - a->z;
+
+ return (c.x * c.x + c.y * c.y + c.z * c.z);
+}
+
+t3dF32 t3dPointSquaredDistance(t3dV3F *c) {
+ return (c->x * c->x + c->y * c->y + c->z * c->z);
+}
+
+void t3dMatReflect(t3dM3X3F *Matrix, t3dV3F *mirrorpos, t3dNORMAL *n) {
+ // | 1-2*nx*nx -2*nx*ny -2*nx*nz -2*nx*k |
+ // | -2*ny*nx 1-2*ny*ny -2*ny*nz -2*ny*k |
+ // | -2*nz*nx -2*nz*ny 1-2*nz*nz -2*nz*k |
+ // | 0 0 0 1 |
+
+ Matrix->M[0] = 1 - 2 * n->n.x * n->n.x;
+ Matrix->M[1] = -2 * n->n.x * n->n.y;
+ Matrix->M[2] = -2 * n->n.x * n->n.z;
+ Matrix->M[3] = -2 * n->n.y * n->n.x;
+ Matrix->M[4] = 1 - 2 * n->n.y * n->n.y;
+ Matrix->M[5] = -2 * n->n.y * n->n.z;
+ Matrix->M[6] = -2 * n->n.z * n->n.x;
+ Matrix->M[7] = -2 * n->n.z * n->n.y;
+ Matrix->M[8] = 1 - 2 * n->n.z * n->n.z;
+
+ mirrorpos->x = -2 * n->n.x * n->dist;
+ mirrorpos->y = -2 * n->n.y * n->dist;
+ mirrorpos->z = -2 * n->n.z * n->dist;
+
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/math/llmath.h b/engines/watchmaker/3d/math/llmath.h
new file mode 100644
index 00000000000..b4877c98316
--- /dev/null
+++ b/engines/watchmaker/3d/math/llmath.h
@@ -0,0 +1,68 @@
+/* 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 WATCHMAKER_LLMATH_H
+#define WATCHMAKER_LLMATH_H
+
+#include "watchmaker/t3d.h"
+
+namespace Watchmaker {
+
+void t3dMatCopy(t3dM3X3F *d, t3dM3X3F *s);
+void t3dMatIdentity(t3dM3X3F *d);
+void t3dMatSet(t3dM3X3F *d,
+ t3dF32 _m11, t3dF32 _m12, t3dF32 _m13,
+ t3dF32 _m21, t3dF32 _m22, t3dF32 _m23,
+ t3dF32 _m31, t3dF32 _m32, t3dF32 _m33);
+void t3dMatMul(t3dM3X3F *Dest, t3dM3X3F *a, t3dM3X3F *b);
+void t3dMatRotAxis(t3dM3X3F *m, t3dF32 x, t3dF32 y, t3dF32 z, t3dF32 rad);
+void t3dMatRot(t3dM3X3F *matrix, t3dF32 x, t3dF32 y, t3dF32 z);
+void t3dMatReflect(t3dM3X3F *Matrix, t3dV3F *mirrorpos, t3dNORMAL *n);
+void t3dMatCopy(t3dM3X3F *d, t3dM3X3F *s);
+void t3dMatView(t3dM3X3F *dest, t3dV3F *eye, t3dV3F *center);
+void t3dVectTransform(t3dV3F *d, t3dV3F *s, t3dM3X3F *mat);
+void t3dVectTransformInv(t3dV3F *d, t3dV3F *s, t3dM3X3F *mat);
+void t3dVectInit(t3dV3F *a, t3dF32 x, t3dF32 y, t3dF32 z);
+void t3dVectCross(t3dV3F *d, t3dV3F *v2, t3dV3F *v3);
+void t3dVectSub(t3dV3F *d, t3dV3F *a, t3dV3F *b); // d = a - b
+void t3dVectAdd(t3dV3F *d, t3dV3F *a, t3dV3F *b); // d = a - b
+void t3dVectFill(t3dV3F *d, t3dF32 a);
+void t3dVectInit(t3dV3F *d, t3dF32 a1, t3dF32 a2, t3dF32 a3);
+void t3dVectCopy(t3dV3F *d, t3dV3F *s);
+t3dF32 t3dVectMod(t3dV3F *c);
+t3dF32 t3dVectDistance(t3dV3F *a, t3dV3F *b);
+t3dF32 t3dVectSquaredDistance(t3dV3F *a, t3dV3F *b);
+t3dF32 t3dPointSquaredDistance(t3dV3F *c);
+void t3dVectNormalize(t3dV3F *c);
+t3dF32 t3dVectDot(t3dV3F *a, t3dV3F *b);
+void t3dMatMulInv(t3dM3X3F *Dest, t3dM3X3F *a, t3dM3X3F *b);
+void t3dVectReflection(t3dV3F *r, t3dV3F *p1, t3dNORMAL *plane, t3dF32 dist);
+void t3dMatInv(t3dM3X3F *d, t3dM3X3F *s);
+void t3dPlaneNormal(t3dNORMAL *n, t3dV3F *p0, t3dV3F *p1, t3dV3F *p2);
+void t3dVector2dTo3d(t3dV3F *end, t3dV2F *start);
+int32 t3dFloatToInt(t3dF32 nfloat);
+t3dF32 t3dVectPlaneDistance(t3dV3F start, t3dNORMAL n); //return the distance of start from plane normal n
+uint8 t3dVectPlaneIntersection(t3dV3F *inter, t3dV3F start, t3dV3F end, t3dNORMAL n); //if return value !=0 inter contains the intersection point
+uint8 t3dVectTriangleIntersection(t3dV3F *inter, t3dV3F start, t3dV3F end, t3dV3F v1, t3dV3F v2, t3dV3F v3, t3dNORMAL n); //return 1 if the vector from start to end pass trought the triangle v1,v2,v3
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_LLMATH_H
diff --git a/engines/watchmaker/3d/mem_management.cpp b/engines/watchmaker/3d/mem_management.cpp
new file mode 100644
index 00000000000..a6fabb7268d
--- /dev/null
+++ b/engines/watchmaker/3d/mem_management.cpp
@@ -0,0 +1,90 @@
+/* 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 "watchmaker/3d/mem_management.h"
+#include "watchmaker/types.h"
+#include "watchmaker/ll/ll_system.h"
+
+namespace Watchmaker {
+
+static int8 *MemoryPool = nullptr;
+static uint32 MemoryPoolPointer = 0;
+static uint32 MaxAllocatedMem = 0;
+
+// Memory Managment
+// Only linear (non dynamic) stack allocations
+
+
+/* -----------------10/06/99 16.06-------------------
+ * t3dAllocMemoryPool
+ * --------------------------------------------------*/
+uint8 t3dAllocMemoryPool(uint32 pool) {
+ uint8 allocated = 0;
+
+ MemoryPoolPointer = 0;
+ while ((allocated == 0) && (pool > 0)) {
+ if (!(MemoryPool = t3dCalloc<int8>(pool)))
+ pool -= 10000;
+ else
+ allocated = 1;
+ }
+
+ if (allocated == 0)
+ return 0;
+ else {
+ MaxAllocatedMem = pool;
+ return 1;
+ }
+}
+
+/* -----------------10/06/99 16.07-------------------
+ * t3dDeallocMemoryPool
+ * --------------------------------------------------*/
+void t3dDeallocMemoryPool() {
+ if (MemoryPool == nullptr) return;
+ t3dFree(MemoryPool);
+ MemoryPool = nullptr;
+ MaxAllocatedMem = 0;
+}
+
+/* -----------------10/06/99 16.07-------------------
+ * t3dAlloc
+ * --------------------------------------------------*/
+void *t3dAlloc(uint32 size) {
+ if (MemoryPool == nullptr) return nullptr;
+ MemoryPoolPointer += size;
+ if (MemoryPoolPointer > MaxAllocatedMem) {
+ return nullptr;
+ }
+
+ return &MemoryPool[MemoryPoolPointer - size];
+}
+
+/* -----------------10/06/99 16.07-------------------
+ * t3dDealloc
+ * --------------------------------------------------*/
+void *t3dDealloc(uint32 size) {
+ if (MemoryPool == nullptr) return nullptr;
+ MemoryPoolPointer -= size;
+ return &MemoryPool[MemoryPoolPointer];
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/mem_management.h b/engines/watchmaker/3d/mem_management.h
new file mode 100644
index 00000000000..53e4df387da
--- /dev/null
+++ b/engines/watchmaker/3d/mem_management.h
@@ -0,0 +1,34 @@
+/* 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 WATCHMAKER_MEM_MANAGEMENT_H
+#define WATCHMAKER_MEM_MANAGEMENT_H
+
+namespace Watchmaker {
+
+unsigned char t3dAllocMemoryPool(unsigned int pool);
+void t3dDeallocMemoryPool();
+void *t3dAlloc(unsigned int size);
+void *t3dDealloc(unsigned int size);
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_MEM_MANAGEMENT_H
diff --git a/engines/watchmaker/3d/movie.cpp b/engines/watchmaker/3d/movie.cpp
new file mode 100644
index 00000000000..5f015df6cec
--- /dev/null
+++ b/engines/watchmaker/3d/movie.cpp
@@ -0,0 +1,26 @@
+/* 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 "watchmaker/3d/movie.h"
+
+namespace Watchmaker {
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/movie.h b/engines/watchmaker/3d/movie.h
new file mode 100644
index 00000000000..378ca88112b
--- /dev/null
+++ b/engines/watchmaker/3d/movie.h
@@ -0,0 +1,52 @@
+/* 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 WATCHMAKER_MOVIE_H
+#define WATCHMAKER_MOVIE_H
+
+#include "watchmaker/types.h"
+#include "watchmaker/utils.h"
+
+namespace Watchmaker {
+
+struct gMovie {
+ Common::SharedPtr<Common::SeekableReadStream> stream;
+ uint16 numFrames;
+ uint16 curFrame;
+ uint16 width;
+ uint16 height;
+ uint16 numBlocks;
+ uint32 startTime;
+ uint8 keyFrame;
+ uint8 frameRate;
+
+ uint32 *frameOffsets;
+ uint8 *buffer;
+ // TODO
+
+ ~gMovie() {
+ //warning("TODO: Clean up gMovie properly\n");
+ }
+};
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_MOVIE_H
diff --git a/engines/watchmaker/3d/render/opengl.cpp b/engines/watchmaker/3d/render/opengl.cpp
new file mode 100644
index 00000000000..be91e9dc737
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl.cpp
@@ -0,0 +1,36 @@
+/* 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 "watchmaker/3d/render/opengl.h"
+#include "watchmaker/utils.h"
+
+namespace Watchmaker {
+
+//*********************************************************************************************
+bool rGetStencilBitDepth() {
+#if 0
+ return gStencilBitDepth;
+#endif
+ //warning("TODO: Implement rGetStencilBitDepth\n");
+ return false;
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/render/opengl.h b/engines/watchmaker/3d/render/opengl.h
new file mode 100644
index 00000000000..88ab27ff583
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl.h
@@ -0,0 +1,29 @@
+/* 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 WATCHMAKER_OPENGL_H
+#define WATCHMAKER_OPENGL_H
+
+namespace Watchmaker {
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_OPENGL_H
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
new file mode 100644
index 00000000000..47a078c8af9
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -0,0 +1,348 @@
+/* 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 "watchmaker/game.h"
+
+#include "watchmaker/3d/render/opengl_2d.h"
+#include "watchmaker/utils.h"
+#include "watchmaker/render.h"
+#include "watchmaker/tga_util.h"
+#include "watchmaker/rect.h"
+#include "watchmaker/work_dirs.h"
+#include "watchmaker/game.h"
+#include "watchmaker/renderer.h"
+#include "watchmaker/sdl_wrapper.h"
+
+#ifdef USE_OPENGL_GAME
+#include "graphics/opengl/system_headers.h"
+#endif
+
+namespace Watchmaker {
+
+// Bitmap list
+unsigned int gNumBitmapList = 0;
+uint16 *gFonts[10];
+unsigned int gNumFonts = 0;
+gTexture gBitmapList[MAX_BITMAP_LIST];
+Rect gBlitterExtends;
+int gStencilBitDepth;
+
+gLogo Logos[10];
+gMaterial LogosMaterials[10];
+int NumLogosMaterials = 0, GlobalLogosDelay = 60 * 3;
+
+unsigned int CurLoaderFlags;
+
+//*********************************************************************************************
+unsigned int gGetBitmapListPosition() {
+ unsigned int pos = 1;
+
+ while (gBitmapList[pos].surface != nullptr) {
+ pos++;
+ }
+
+ if (pos > MAX_BITMAP_LIST)
+ return 0;
+
+ if (pos > gNumBitmapList)
+ gNumBitmapList = pos;
+
+ return pos;
+}
+
+unsigned int rGetBitmapDimX(unsigned int id) {
+ return gBitmapList[id].DimX;
+}
+
+//************************************************************************************************************************
+unsigned int rGetBitmapDimY(unsigned int id) {
+ return gBitmapList[id].DimY;
+}
+
+unsigned int rGetBitmapRealDimX(unsigned int id) {
+ return gBitmapList[id].RealDimX;
+}
+
+unsigned int rGetBitmapRealDimY(unsigned int id) {
+ return gBitmapList[id].RealDimY;
+}
+
+//************************************************************************************************************************
+void rUpdateExtends(int x1, int y1, int x2, int y2) {
+ //Update extends
+ if (x1 < gBlitterExtends.left)
+ gBlitterExtends.left = x1;
+ if (y1 < gBlitterExtends.top)
+ gBlitterExtends.top = y1;
+ if (x2 > gBlitterExtends.right)
+ gBlitterExtends.right = x2;
+ if (y2 > gBlitterExtends.bottom)
+ gBlitterExtends.bottom = y2;
+}
+
+//************************************************************************************************************************
+void rGetExtends(int *x1, int *y1, int *x2, int *y2) {
+ *x1 = gBlitterExtends.left;
+ *y1 = gBlitterExtends.top;
+ *x2 = gBlitterExtends.right;
+ *y2 = gBlitterExtends.bottom;
+}
+
+//************************************************************************************************************************
+void rResetExtends(void) {
+ gBlitterExtends.left = 99999999;
+ gBlitterExtends.top = 99999999;
+ gBlitterExtends.right = -99999999;
+ gBlitterExtends.bottom = -99999999;
+}
+
+#ifdef USE_OPENGL_GAME
+
+//************************************************************************************************************************
+void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
+ int sposx, int sposy, int sdimx, int sdimy) {
+ // TODO: This currently gets called a bit too much.
+ //warning("TODO: Stubbed rBlitter(%s, %d, %d, %d, %d, %d, %d, %d, %d)\n", gBitmapList[src].Name, dst, src, dposx, dposy, sposx, sposy, sdimx, sdimy);
+ auto &bitmap = gBitmapList[src];
+
+ checkGlError("rBlitter Start");
+
+ glEnable(GL_TEXTURE_2D);
+ glDisable(GL_ALPHA_TEST);
+ int dwWidth, dwHeight;
+
+ dwWidth = game._renderer->_viewport.width();
+ dwHeight = game._renderer->_viewport.height();;
+
+ if ((sdimx <= 0)) {
+ sdimx = gBitmapList[src].DimX;
+ }
+ if ((sdimy <= 0)) {
+ sdimy = gBitmapList[src].DimY;
+ }
+
+ if ((dposx >= dwWidth) || (dposy >= dwHeight) || (sposx >= dwWidth) || (sposy >= dwHeight) ||
+ ((dposx + sdimx) <= 0) || ((dposy + sdimy) <= 0) || ((sposx + sdimx) <= 0) || ((sposy + sdimy) <= 0))
+ return;
+
+ if (dst == 0) {
+#if 0
+ if (!gClipToBlitterViewport(&sposx, &sposy, &sdimx, &sdimy, &dposx, &dposy)) {
+// DebugLogFile("gClipToBlitterViewport report an error");
+ return;
+ }
+ d = gScreenBuffer.lpDDSurface;
+#endif
+ rUpdateExtends(dposx, dposy, dposx + sdimx, dposy + sdimy);
+#if 0
+ /* //Update extends
+ if (dposx<gBlitterExtends.left)
+ gBlitterExtends.left=dposx;
+ if (dposy<gBlitterExtends.top)
+ gBlitterExtends.top=dposy;
+ if ((dposx+sdimx)>gBlitterExtends.right)
+ gBlitterExtends.right=dposx+sdimx;
+ if ((dposy+sdimy)>gBlitterExtends.bottom)
+ gBlitterExtends.bottom=dposy+sdimy;*/
+ } else
+ d = gBitmapList[dst].lpDDSurface;
+
+ if (src == 0) {
+ DebugLogFile("rBlitter error: src is an invalid surface");
+ return;
+ } else
+ s = gBitmapList[src].lpDDSurface;
+#endif
+ }
+ if ((sdimx == 0) && (sdimy == 0)) {
+ sdimx = gBitmapList[src].DimX;
+ sdimy = gBitmapList[src].DimY;
+ }
+
+ {
+ Rect srcRect;
+ // Source rect
+ srcRect.top=sposy;
+ srcRect.left=sposx;
+ srcRect.right= sposx + sdimx;
+ srcRect.bottom= sposy + sdimy;
+
+ Rect dstRect;
+ // Destination rect
+ // Convention in dpos is that 0,0 is upper left hand corner, increasing down the y-axis.
+ dstRect.top=dposy;
+ dstRect.left=dposx;
+ dstRect.right= dposx + sdimx;
+ dstRect.bottom= dposy + sdimy;
+ if(((dstRect.bottom - dstRect.top) <= 0) || ((dstRect.right - dstRect.left ) <= 0) || ((srcRect.bottom - srcRect.top) <= 0) || ((srcRect.right - srcRect.left ) <= 0) ||
+ (dstRect.right <= 0) || (srcRect.right <= 0) || (dstRect.bottom < 0) || (srcRect.bottom < 0) )
+ {
+// DebugLogWindow("gBlitter: blit not needed: dimx:%d dimy:%d", ( sr.top-sr.bottom ),( sr.left-sr.right ));
+ return;
+ }
+ glClearColor(0,0,1,0);
+ glEnable(GL_TEXTURE_2D);
+ glDisable(GL_ALPHA_TEST);
+ glDisable(GL_BLEND);
+ error("TODO: Replace SDL textures");
+#if 0
+ SDL_GL_BindTexture(bitmap.texture, nullptr, nullptr);
+#endif
+ //glBindTexture(GL_TEXTURE_2D, bitmap.texId);
+ glLoadIdentity();
+ glTranslatef(0, 0, -1.0);
+ //glTranslatef((2.0 / dposx) - 1.0, (2.0 / dposy) - 1.0, 0.0f);
+
+ //glClear(GL_COLOR_BUFFER_BIT);
+
+
+ float bottomSrc = ((float)srcRect.bottom) / bitmap.RealDimY;
+ float topSrc = ((float)srcRect.top) / bitmap.RealDimY;
+ float leftSrc = ((float)srcRect.left) / bitmap.RealDimX;
+ float rightSrc = ((float)srcRect.right) / bitmap.RealDimX;
+
+ Rect viewport = game._renderer->_viewport;
+ float bottomDst = 1.0 - ((dstRect.bottom == 0 ? 0 : ((double)dstRect.bottom) / viewport.height()) * 2.0);
+ float topDst = 1.0 - ((dstRect.top == 0 ? 0 : ((double)dstRect.top) / viewport.height()) * 2.0);
+ float leftDst = ((dstRect.left == 0 ? 0 : ((double)dstRect.left) / viewport.width()) * 2.0) - 1.0;
+ float rightDst = ((dstRect.right == 0 ? 0 : ((double)dstRect.right) / viewport.width()) * 2.0) - 1.0;
+
+ glBegin(GL_QUADS);
+ glColor3f(1.0, 1.0, 1.0);
+
+ glTexCoord2f(leftSrc, bottomSrc); // Bottom Left
+ glVertex3f(leftDst, bottomDst, 0.0f);
+
+ glTexCoord2f(rightSrc, bottomSrc); // Bottom Right
+ glVertex3f(rightDst, bottomDst, 0.0f);
+
+ glTexCoord2f(rightSrc, topSrc); // Top Right
+ glVertex3f(rightDst, topDst, 0.0f);
+
+ glTexCoord2f(leftSrc, topSrc); // Top Left
+ glVertex3f(leftDst, topDst, 0.0f);
+
+ glEnd();
+ glFlush();
+ }
+ checkGlError("rBlitter End");
+
+// DebugLogFile("gBlitter(%d %d)",dst,src);
+ //gBlitter(d, s, sposx, sposy, sdimx, sdimy, dposx, dposy, 0);
+//#endif
+}
+
+// TODO: Deduplicate against the opengl_3d.cpp version
+int createTextureFromSurface2(Surface &surface, int texFormat) {
+ unsigned int texId = 0;
+ glGenTextures(1, &texId);
+
+ glBindTexture(GL_TEXTURE_2D, texId);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+
+ bool compressed = false;
+ switch (texFormat) {
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ compressed = true;
+ break;
+ case GL_RGBA:
+ case GL_RGB:
+ compressed = false;
+ break;
+ default:
+ warning("Texture format not handled: %d\n", texFormat);
+ }
+
+ if (compressed) {
+ glCompressedTexImage2D(GL_TEXTURE_2D, 0, texFormat, surface.width, surface.height, 0, surface.dataSize, surface.data);
+ } else {
+ glTexImage2D(GL_TEXTURE_2D, 0, texFormat, surface.width, surface.height / 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface.data);
+ }
+
+ return texId;
+}
+
+int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
+ WorkDirs &workDirs = game.workDirs;
+ if (flags & rTEXTURESURFACE) {
+ warning("TODO: support texture surface loading\n");
+ // return ((int) gLoadTexture(TextName, flags));
+ }
+
+ assert(TextName);
+ auto stream = workDirs.resolveFile(TextName);
+ if (!stream) {
+ warning("gLoadBitmapImage: Cannot find %s.\n", TextName);
+ return -1;
+ }
+
+ PixelFormat RGBA8888(4, 8, 8, 8, 8, 24, 16, 8, 0);
+
+ unsigned int pos = gGetBitmapListPosition();
+ if (pos == 0) {
+ warning("rLoadBitmap: Can't create more bitmaps\n");
+ return -1;
+ }
+ gTexture *Texture = &gBitmapList[pos];
+ *Texture = gTexture();
+ Texture->Flags = CurLoaderFlags;
+ Texture->surface = ReadTgaImage(TextName, stream.get(), RGBA8888, Texture->Flags);
+
+ error("TODO: textures in OSystem");
+#if 0
+ Texture->texture = SDL_CreateTextureFromSurface(game.sdl->renderer, Texture->surface->sdl_surface);
+#endif
+ //Texture->texId = createTextureFromSurface2(*Texture->surface, GL_RGBA);
+
+ Texture->name = TextName;
+
+ if (flags & rSURFACESTRETCH) { // Also rSURFACEFLIP
+ static bool warned = false;
+ if (!warned) {
+ warning("TODO: rSURFACESTRETCH\n");
+ warned = true;
+ }
+ // HACK: Just set a dimension at all:
+ Texture->DimX = Texture->surface->width;
+ Texture->DimY = Texture->surface->height;
+ } else {
+ Texture->DimX = Texture->surface->width;
+ Texture->DimY = Texture->surface->height;
+ }
+
+ Texture->RealDimX = Texture->surface->width;
+ Texture->RealDimY = Texture->surface->height;
+ // TODO: Colour-keying
+ return pos;
+}
+
+void rSetLoaderFlags(unsigned int NewLoaderFlags) {
+ CurLoaderFlags = NewLoaderFlags;
+}
+
+#endif // USE_OPENGL_GAME
+
+} // End of namespace Watchmaker
\ No newline at end of file
diff --git a/engines/watchmaker/3d/render/opengl_2d.h b/engines/watchmaker/3d/render/opengl_2d.h
new file mode 100644
index 00000000000..dd7b52f6876
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl_2d.h
@@ -0,0 +1,48 @@
+/* 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 WATCHMAKER_OPENGL2D_H
+#define WATCHMAKER_OPENGL2D_H
+
+#include "watchmaker/render.h"
+#include "watchmaker/3d/render/opengl_3d.h"
+
+#define MAX_BITMAP_LIST 1024
+
+namespace Watchmaker {
+
+extern int gStencilBitDepth;
+
+struct gLogo {
+ gMaterial *Material;
+ Vertex Verts[4];
+ int Delay;
+};
+
+extern gLogo Logos[];
+extern gMaterial LogosMaterials[];
+extern int NumLogosMaterials;
+
+extern unsigned int CurLoaderFlags;
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_OPENGL2D_H
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
new file mode 100644
index 00000000000..ea10b79e13f
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -0,0 +1,967 @@
+/* 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/>.
+*
+*/
+
+#define FORBIDDEN_SYMBOL_EXCEPTION_strcat
+#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
+
+#include "watchmaker/3d/render/opengl_3d.h"
+#include "watchmaker/windows_hacks.h"
+#include "watchmaker/t3d.h"
+#include "watchmaker/3d/math/Matrix4x4.h"
+#include "watchmaker/3d/render/opengl_renderer.h"
+#include "watchmaker/ll/ll_system.h"
+#include "watchmaker/3d/render/opengl_2d.h"
+#include "watchmaker/renderer.h"
+#include "watchmaker/globvar.h"
+#include "watchmaker/work_dirs.h"
+
+#ifdef USE_OPENGL_GAME
+
+#include "graphics/opengl/system_headers.h"
+
+#define MAXTEXTURES 2000
+
+namespace Watchmaker {
+
+// temp pixel format conversion info
+struct {
+ float RedScale;
+ float GreenScale;
+ float BlueScale;
+ float AlphaScale;
+ unsigned int RedShift;
+ unsigned int GreenShift;
+ unsigned int BlueShift;
+ unsigned int AlphaShift;
+ unsigned int RedMask;
+ unsigned int GreenMask;
+ unsigned int BlueMask;
+ unsigned int AlphaMask;
+} gTexturePixelConversion;
+
+#define T3D_FASTFILE (1<<23) // fastfile
+
+// Tecture formats
+int NumAvailableFormats = 0;
+gAvailFormat AvailableFormats[50];
+gAvailFormat *gCurrentFormat;
+
+// Point VB
+int g_lpD3DPointsBuffer;
+unsigned int gNumPointsBuffer;
+
+// Tecture list
+gTexture gTextureList[MAXTEXTURES];
+unsigned int gNumTextureList = 0;
+
+// {ines array
+uint16 gLinesArray[MAX_LINES];
+unsigned int gNumLinesArray = 0;
+
+// screen traingles
+Vertex gTriangles[100];
+unsigned int gNumTrianglesArray = 0;
+
+// camera info
+Matrix4x4 rWorldMatrix;
+Matrix4x4 rProjectionMatrix;
+float gNearPlane, gFarPlane;
+
+// saved matrix
+Matrix4x4 rLinesViewMatrix;
+
+// user matrix
+#define MAX_USER_VIEW_MATRICES 2000 // TODO: Why do we get so many of them?
+Matrix4x4 rUserViewMatrix[MAX_USER_VIEW_MATRICES];
+unsigned int rNumUserViewMatrices = 0;
+
+// user vertext buffer
+void *g_lpD3DUserVertexBuffer = nullptr;
+unsigned int g_dwD3DUserVertexBufferCounter = 0;
+
+//***********************************************************************************************
+uint16 *rGetLinesArrayPtr() {
+ return &gLinesArray[gNumLinesArray];
+}
+
+//***********************************************************************************************
+void rAddLinesArray() {
+ gNumLinesArray++;
+}
+
+//***********************************************************************************************
+void *rLockPointArray() {
+ warning("TODO: Implement rLockPointArray\n");
+#if 0
+ HRESULT hResult;
+ LPVOID v;
+
+ if ((hResult = g_lpD3DPointsBuffer->Lock(DDLOCK_SURFACEMEMORYPTR, &v, NULL)) != D3D_OK) {
+ char str[255];
+ GetDDErrorString(hResult, str, 1);
+ DebugLogFile("rLockPointArray: Unable to lock points vertexbuffer:\r\n%s", str);
+ return NULL;
+ }
+
+ gVertex *gv = (gVertex *)v;
+ return &gv[rGetNumPointArray()];
+#endif
+ return nullptr;
+}
+
+void rAddTrianglesArray(float x, float y, int r, int g, int b, int a) {
+ gTriangles[gNumTrianglesArray].sx = x;
+ gTriangles[gNumTrianglesArray].sy = y;
+ gTriangles[gNumTrianglesArray].sz = 1.0f;
+ gTriangles[gNumTrianglesArray].color = RGBA_MAKE(r, g, b, a);
+ gNumTrianglesArray++;
+}
+
+
+//***********************************************************************************************
+void rUnlockPointArray() {
+ warning("TODO: Implement rUnlockPointArray\n");
+#if 0
+ g_lpD3DPointsBuffer->Unlock();
+#endif
+}
+
+//***********************************************************************************************
+unsigned int rGetNumPointArray() {
+ return gNumPointsBuffer;
+}
+
+//***********************************************************************************************
+void rAddPointArray() {
+ gNumPointsBuffer++;
+}
+
+//***********************************************************************************************
+bool rSetViewMatrix(float _00, float _01, float _02,
+ float _03, float _04, float _05,
+ float _06, float _07, float _08,
+ float _tx, float _ty, float _tz) {
+ Matrix4x4 rViewMatrix;
+ rViewMatrix.setIdentity();
+
+ rViewMatrix.setValue(1, 1, _00);
+ rViewMatrix.setValue(1, 2, _01);
+ rViewMatrix.setValue(1, 3, _02);
+ rViewMatrix.setValue(1, 4, _tx);
+
+ rViewMatrix.setValue(2, 1, _03);
+ rViewMatrix.setValue(2, 2, _04);
+ rViewMatrix.setValue(2, 3, _05);
+ rViewMatrix.setValue(2, 4, _ty);
+
+ rViewMatrix.setValue(3, 1, -_06);
+ rViewMatrix.setValue(3, 2, -_07);
+ rViewMatrix.setValue(3, 3, -_08);
+ rViewMatrix.setValue(3, 4, _tz);
+
+ rViewMatrix.setValue(4, 1, 0.0f);
+ rViewMatrix.setValue(4, 2, 0.0f);
+ rViewMatrix.setValue(4, 3, 0.0f);
+ rViewMatrix.setValue(4, 4, 1.0f);
+
+ g_renderer->setTransformMatrix(TransformMatrix::VIEW, rViewMatrix);
+
+ return true;
+}
+
+void rSetViewMatrix(const t3dM3X3F &viewMatrix, const t3dV3F &translation) {
+ rSetViewMatrix(viewMatrix.M[0], viewMatrix.M[1], viewMatrix.M[2],
+ viewMatrix.M[3], viewMatrix.M[4], viewMatrix.M[5],
+ viewMatrix.M[6], viewMatrix.M[7], viewMatrix.M[8],
+ translation.x, translation.y, -translation.z);
+}
+
+void rSaveViewMatrix() {
+ g_renderer->pushModelView();
+}
+
+//***********************************************************************************************
+void rRestoreViewMatrix() {
+ g_renderer->popModelView();
+}
+
+//***********************************************************************************************
+bool rBuildLinesViewMatrix(float _00, float _01, float _02,
+ float _03, float _04, float _05,
+ float _06, float _07, float _08,
+ float _tx, float _ty, float _tz) {
+ rLinesViewMatrix.setIdentity();
+
+ rLinesViewMatrix.setValue(1, 1, _00);
+ rLinesViewMatrix.setValue(1, 2, _01);
+ rLinesViewMatrix.setValue(1, 3, _02);
+ rLinesViewMatrix.setValue(1, 4, _tx);
+
+ rLinesViewMatrix.setValue(2, 1, _03);
+ rLinesViewMatrix.setValue(2, 2, _04);
+ rLinesViewMatrix.setValue(2, 3, _05);
+ rLinesViewMatrix.setValue(2, 4, _ty);
+
+ rLinesViewMatrix.setValue(3, 1, -_06);
+ rLinesViewMatrix.setValue(3, 2, -_07);
+ rLinesViewMatrix.setValue(3, 3, -_08);
+ rLinesViewMatrix.setValue(3, 4, -_tz);
+
+ rLinesViewMatrix.setValue(4, 1, 0.0f);
+ rLinesViewMatrix.setValue(4, 2, 0.0f);
+ rLinesViewMatrix.setValue(4, 3, 0.0f);
+ rLinesViewMatrix.setValue(4, 4, 1.0f);
+
+ return true;
+}
+
+int rBuildLinesViewMatrix(const t3dM3X3F &viewMatrix, const t3dV3F &translation) {
+ return rBuildLinesViewMatrix(viewMatrix.M[0], viewMatrix.M[1], viewMatrix.M[2],
+ viewMatrix.M[3], viewMatrix.M[4], viewMatrix.M[5],
+ viewMatrix.M[6], viewMatrix.M[7], viewMatrix.M[8],
+ translation.x, translation.y, translation.z);
+}
+
+//***********************************************************************************************
+int rAddUserViewMatrix(float _00, float _01, float _02,
+ float _03, float _04, float _05,
+ float _06, float _07, float _08,
+ float _tx, float _ty, float _tz) {
+ Matrix4x4 rTempViewMatrix;
+ Matrix4x4 *um;
+ unsigned int i;
+
+ rTempViewMatrix.setIdentity();
+
+ rTempViewMatrix.setValue(1, 1, _00);
+ rTempViewMatrix.setValue(1, 2, _01);
+ rTempViewMatrix.setValue(1, 3, _02);
+ rTempViewMatrix.setValue(1, 4, _tx);
+
+ rTempViewMatrix.setValue(2, 1, _03);
+ rTempViewMatrix.setValue(2, 2, _04);
+ rTempViewMatrix.setValue(2, 3, _05);
+ rTempViewMatrix.setValue(2, 4, _ty);
+
+ rTempViewMatrix.setValue(3, 1, -_06);
+ rTempViewMatrix.setValue(3, 2, -_07);
+ rTempViewMatrix.setValue(3, 3, -_08);
+ rTempViewMatrix.setValue(3, 4, -_tz);
+
+ rTempViewMatrix.setValue(4, 1, 0.0f);
+ rTempViewMatrix.setValue(4, 2, 0.0f);
+ rTempViewMatrix.setValue(4, 3, 0.0f);
+ rTempViewMatrix.setValue(4, 4, 1.0f);
+
+ auto &tmp = rTempViewMatrix;
+ //warning("Adding: \n");
+ //tmp.print();
+ for (i = 0, um = &rUserViewMatrix[0]; i < rNumUserViewMatrices; i++, um++) {
+ //warning("Comparing %d\n", i);
+ //um->print();
+ if (*um == tmp) {
+ return i;
+ }
+ }
+
+ if (i >= MAX_USER_VIEW_MATRICES) {
+ DebugLogFile("Too many UserViewMatrix %d (MAX is %d)\n", i, MAX_USER_VIEW_MATRICES);
+ return -1;
+ }
+
+ *um = tmp;
+
+ rNumUserViewMatrices ++;
+ return rNumUserViewMatrices - 1;
+}
+
+int rAddUserViewMatrix(const t3dM3X3F &viewMatrix, const t3dV3F &translation) {
+ return rAddUserViewMatrix(viewMatrix.M[0], viewMatrix.M[1], viewMatrix.M[2],
+ viewMatrix.M[3], viewMatrix.M[4], viewMatrix.M[5],
+ viewMatrix.M[6], viewMatrix.M[7], viewMatrix.M[8],
+ translation.x, translation.y, translation.z);
+}
+
+//*********************************************************************************************
+void *rGetUserVertexBuffer() {
+ return g_lpD3DUserVertexBuffer;
+}
+
+//*********************************************************************************************
+unsigned int rGetUserVertexBufferCounter() {
+ return g_dwD3DUserVertexBufferCounter;
+}
+
+//*********************************************************************************************
+void rSetUserVertexBufferCounter(unsigned int uvbc) {
+ g_dwD3DUserVertexBufferCounter = uvbc;
+}
+
+gVertex *rLockVertexPtr(void *vb, int flags) {
+ warning("TODO: Implement rLockVertexPtr");
+#if 0
+ LPVOID v;
+ DWORD dim, lock_flags;
+ HRESULT hResult;
+
+ LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuffer1 = (LPDIRECT3DVERTEXBUFFER7)vb;
+
+ lock_flags = DDLOCK_SURFACEMEMORYPTR;
+ if (flags & rVBLOCK_READONLY)
+ lock_flags |= DDLOCK_READONLY;
+ else if (flags & rVBLOCK_WRITEONLY)
+ lock_flags |= DDLOCK_WRITEONLY;
+ if (flags & rVBLOCK_NOSYSLOCK)
+ lock_flags |= DDLOCK_NOSYSLOCK;
+
+ if ((hResult = lpD3DVertexBuffer1->Lock(lock_flags, &v, &dim)) != D3D_OK) {
+ char str[255];
+ GetDDErrorString(hResult, str, 1);
+ DebugLogFile("Unable to lock vertexbuffer:\r\n%s", str);
+ return NULL;
+ }
+ return (gVertex *)v;
+#endif
+ return nullptr;
+}
+
+Surface *gCreateSurface(int width, int height, void *ptr) {
+ auto surface = new Surface();
+ surface->data = ptr;
+ surface->width = width;
+ surface->height = height;
+ return surface;
+}
+
+//***********************************************************************************************
+bool rUnlockVertexPtr(void *vb) {
+ warning("Implement rUnlockVertexPtr");
+#if 0
+ LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuffer1 = (LPDIRECT3DVERTEXBUFFER7)vb;
+
+ if (lpD3DVertexBuffer1->Unlock() != D3D_OK) {
+ DebugLogFile("VertexBuffer Unlock error");
+ return FALSE;
+ }
+#endif
+ return TRUE;
+}
+
+
+//***********************************************************************************************
+void rSetLinesViewMatrix() {
+ g_renderer->setTransformMatrix(TransformMatrix::VIEW, rLinesViewMatrix);
+}
+
+//***********************************************************************************************
+void rSetUserViewMatrix(int num) {
+ auto &matrix = rUserViewMatrix[num];
+
+ g_renderer->setTransformMatrix(TransformMatrix::VIEW, matrix);
+}
+
+
+//*********************************************************************************************
+unsigned int gGetTextureListPosition() {
+ unsigned int pos = 1;
+
+ while (!gTextureList[pos].isEmpty()) { // TODO: Do we need the surface?
+ pos++;
+ }
+
+ if (pos > MAXTEXTURES)
+ return 0;
+
+ if (pos > gNumTextureList)
+ gNumTextureList = pos;
+
+ return pos;
+}
+
+//*********************************************************************************************
+void gBuildAlternateName(char *AltName, const char *Name) {
+ int len, i, j;
+
+ if (!Name || !AltName) return;
+
+ len = strlen(Name);
+ memset(AltName, 0, len + 4);
+ memcpy(AltName, Name, len);
+
+ for (i = len - 1; i >= 0; i--) {
+ if ((AltName[i] == '.') && (i < (len - 3))) {
+ AltName[i + 1] = 'd';
+ AltName[i + 2] = 'd';
+ AltName[i + 3] = 's';
+ }
+ if (AltName[i] == '\\' || AltName[i] == '/') {
+ for (j = len; j >= i; j--)
+ AltName[j + 3] = AltName[j];
+
+ AltName[i + 0] = 'D';
+ AltName[i + 1] = 'D';
+ AltName[i + 2] = 'S';
+ break;
+ }
+ }
+
+ //warning("Build alternate name %s -> %s\n", Name, AltName);
+}
+
+//*********************************************************************************************
+void gBuildAlternateName(char *AltName, char *Name) {
+ int len, i, j;
+
+ if (!Name || !AltName) return;
+
+ len = strlen(Name);
+ memset(AltName, 0, len + 4);
+ memcpy(AltName, Name, len);
+
+ for (i = len - 1; i >= 0; i--) {
+ if ((AltName[i] == '.') && (i < (len - 3))) {
+ AltName[i + 1] = 'd';
+ AltName[i + 2] = 'd';
+ AltName[i + 3] = 's';
+ }
+ if (AltName[i] == '\\') {
+ for (j = len; j >= i; j--)
+ AltName[j + 3] = AltName[j];
+
+ AltName[i + 0] = 'D';
+ AltName[i + 1] = 'D';
+ AltName[i + 2] = 'S';
+ break;
+ }
+ }
+}
+
+//*********************************************************************************************
+gTexture *gUserTexture(unsigned int dimx, unsigned int dimy) {
+ bool AlreadyLoaded = FALSE, bAlpha = FALSE;
+ gTexture *Texture;
+ int pos;
+ //DDSURFACEDESC2 DDSurfDesc;
+
+ pos = gGetTextureListPosition();
+ if (pos == 0) {
+ DebugLogFile("gUserTexture: Can't create more textures");
+ return nullptr;
+ }
+ Texture = &gTextureList[pos];
+ memset(Texture, 0, sizeof(gTexture));
+ Texture->Flags = CurLoaderFlags;
+
+ {
+#if 0
+ memset(&DDSurfDesc, 0, sizeof(DDSURFACEDESC2));
+ memcpy(&DDSurfDesc.ddpfPixelFormat, &gCurrentFormat->SurfaceDesc, sizeof(DDPIXELFORMAT));
+ DDSurfDesc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
+ if (gRenderFlags & gAGPSUPPORTED) {
+ //Alloc texture in AGP
+ DDSurfDesc.ddsCaps.dwCaps = DDSCAPS_NONLOCALVIDMEM | DDSCAPS_VIDEOMEMORY |
+ DDSCAPS_TEXTURE;
+ } else {
+ //No AGP support; alloc in sysmem
+ DDSurfDesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
+ DDSurfDesc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
+ }
+#endif
+ if (dimx > 8)
+ if (dimx > 16)
+ if (dimx > 32)
+ if (dimx > 64)
+ if (dimx > 128)
+ dimx = 256;
+ else
+ dimx = 128;
+ else
+ dimx = 64;
+ else
+ dimx = 32;
+ else
+ dimx = 16;
+ if (dimy > 8)
+ if (dimy > 16)
+ if (dimy > 32)
+ if (dimy > 64)
+ if (dimy > 128)
+ dimy = 256;
+ else
+ dimy = 128;
+ else
+ dimy = 64;
+ else
+ dimy = 32;
+ else
+ dimy = 16;
+
+ Texture->surface = gCreateSurface(dimx, dimy, nullptr);
+#if 0
+ DDSurfDesc.dwWidth = dimx;
+ DDSurfDesc.dwHeight = dimy;
+
+ if (!(Texture->lpDDSurface = gCreateSurface(&DDSurfDesc, Texture->lpDDSurface))) {
+ DebugLogFile("gCreateSurface FAILED: Can't create surface");
+ return NULL;
+ }
+ strcpy(Texture->Name, "UserTexture");
+ gClear(Texture->lpDDSurface, 0, 0, dimx, dimy, 0, 0, 0);
+#endif
+ Texture->ID = pos;
+
+ Texture->DimX = dimx;
+ Texture->DimY = dimy;
+#if 0
+ DDCOLORKEY ddck;
+ ddck.dwColorSpaceLowValue = 0;
+ ddck.dwColorSpaceHighValue = 0;
+ Texture->lpDDSurface->SetColorKey(DDCKEY_SRCBLT, &ddck);
+#endif
+ }
+
+ return Texture;
+}
+
+int createTextureFromSurface(Surface &surface, int texFormat) {
+ unsigned int texId = 0;
+ glGenTextures(1, &texId);
+
+ glBindTexture(GL_TEXTURE_2D, texId);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+
+ bool compressed = false;
+ error("TODO: Compressed textures");
+#if 0
+ switch (texFormat) {
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ compressed = true;
+ break;
+ default:
+ warning("Texture format not handled: %d\n", texFormat);
+ }
+#endif
+ if (compressed) {
+ glCompressedTexImage2D(GL_TEXTURE_2D, 0, texFormat, surface.width, surface.height, 0, surface.dataSize, surface.data);
+ } else {
+ glTexImage2D(GL_TEXTURE_2D, 0, texFormat, surface.width, surface.height, 0, surface.dataSize, GL_UNSIGNED_BYTE, surface.data);
+ }
+
+ return texId;
+}
+
+struct DDSHeader {
+ int height = 0;
+ int width = 0;
+};
+
+DDSHeader parseDDSHeader(Common::SeekableReadStream &stream) {
+ DDSHeader header;
+ //warning("TODO: Implement DDS Header parsing\n");
+ uint32 retv = ' SDD'; //MAKEFOURCC( 'D','D','S',' ' );
+ uint32 magic = stream.readUint32LE();
+ if (magic != retv) {
+ error("parseDDSHeader: Wrong Magic, expected %08X, got %08X\n", retv, magic);
+ }
+ uint32 size = stream.readUint32LE();
+ uint32 flags = stream.readUint32LE();
+ header.height = stream.readUint32LE();
+ header.width = stream.readUint32LE();
+ stream.seek(SEEK_SET, size + 4);
+ return header;
+}
+
+Surface *parseDDS(Common::SeekableReadStream &stream) {
+ DDSHeader header = parseDDSHeader(stream);
+ auto dataSize = stream.size() - stream.pos();
+ auto data = new unsigned char[dataSize]();
+ stream.read(data, dataSize);
+ auto result = gCreateSurface(header.width, header.height, data);
+ result->dataSize = dataSize;
+ return result;
+}
+
+//*********************************************************************************************
+Common::SharedPtr<gMovie> gLoadMovie(WorkDirs &workDirs, const char *TextName) {
+ bool AlreadyLoaded = FALSE, bAlpha = FALSE;
+ uint32 i;
+ char finalName[MAX_PATH];
+
+ auto Movie = Common::SharedPtr<gMovie>(new gMovie());
+ if (!Movie) {
+ DebugLogFile("gLoadMovie FAILED: Can't alloc Movie struct");
+ return nullptr;
+ }
+ *Movie = gMovie();
+
+ //convert .avi name in .wmm
+ strcpy(finalName, TextName);
+ {
+ int i = strlen(finalName) - 1;
+ while (i > 0) {
+ if (finalName[i] == '.') {
+ finalName[i] = '\0';
+ break;
+ }
+ i--;
+ }
+ strcat(finalName, ".wmm");
+ }
+
+
+ //load movie file
+ Movie->stream = workDirs.resolveFile(finalName);
+// Movie->fp=fopen("c:\\wm\\TMaps2DDS\\fiammata.wmm","rb");
+// Movie->fp=fopen("c:\\wm\\TMaps2DDS\\medicalshow.wmm","rb");
+ if (!Movie->stream) {
+ DebugLogFile("gLoadMovie FAILED: Can't find movie file\n");
+ return nullptr;
+ }
+
+ Movie->numFrames = Movie->stream->readUint16LE();
+ Movie->width = Movie->stream->readUint16LE();
+ Movie->height = Movie->stream->readUint16LE();
+ Movie->keyFrame = Movie->stream->readByte();
+ Movie->frameRate = Movie->stream->readByte();
+ //uint32 readMagic = Movie->stream->readUint32LE();
+
+ DDSHeader header = parseDDSHeader(*Movie->stream);
+ Movie->numBlocks = Movie->width * Movie->height / 16;
+ Movie->curFrame = 0xFFFF;
+
+ Movie->frameOffsets = (uint32 *)t3dMalloc(sizeof(uint32) * Movie->numFrames);
+ if (!Movie->frameOffsets) {
+ DebugLogFile("gLoadMovie FAILED: Can't alloc Movie->frameOffsets struct");
+ return nullptr;
+ }
+
+ uint16 maxlen = (Movie->numBlocks / 8) + 8 * Movie->numBlocks; //bit array + max different blocks
+ Movie->buffer = (uint8 *)t3dMalloc(maxlen);
+ if (!Movie->buffer) {
+ DebugLogFile("gLoadMovie FAILED: Can't alloc Movie->buffer struct");
+ return nullptr;
+ }
+
+ //read frame offsets
+ for (i = 0; i < Movie->numFrames; i++) {
+ Movie->frameOffsets[i] = Movie->stream->readUint32LE();
+ }
+
+ //check if the files are ok
+
+ {
+ //create surface
+ //warning("TODO: Create compressed surface\n");
+#if 0
+ DDSURFACEDESC2 ddsd2;
+
+ //create compressed surface
+ memcpy(&ddsd2, &Movie->surfDesc, sizeof(DDSURFACEDESC2));
+
+ ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
+
+ if (!(Movie->surf = gCreateSurface(&ddsd2, Movie->surf))) {
+ DebugLogFile("gLoadMovie: gCreateSurface FAILED: Can't create surface DDS");
+ return NULL;
+ }
+#endif
+ }
+
+// Movie->frameRate=240;
+ return Movie;
+}
+
+//*********************************************************************************************
+gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int LoaderFlags) {
+ bool bAlpha = FALSE, bUseAlternate = FALSE;
+ gTexture *Texture = nullptr;
+ int32 pos = 0;
+ char AlternateName[500] {};
+ uint32 date1 = 0, date2 = 0, time1 = 0, time2 = 0;
+ //uint32 magic,retv;
+ unsigned long dwWidth = 0, dwHeight = 0;
+ //DDSURFACEDESC2 DDSurfDesc;
+ Surface *lpSSource = nullptr;
+
+ if (!TextName) return nullptr;
+ lpSSource = nullptr;
+
+ //warning("gLoadTexture(%s)\n", TextName);
+// Check if already loaded
+ for (uint32 i = 0; i < gNumTextureList; i++) {
+ if (gTextureList[i].name.equalsIgnoreCase(TextName)) {
+ //Texture already loaded; just assign pointers
+ Texture = &gTextureList[i];
+ Texture->ID = i;
+ return Texture;
+ }
+ }
+
+ /* VERSIONE ORIGINALE by FAB
+ gBuildAlternateName( AlternateName, TextName );
+ if( ( CurLoaderFlags & T3D_FASTFILE ) || ( !t3dGetFileDate( &date1, &time1, TextName ) ) )
+ bUseAlternate = TRUE;
+ if( !t3dGetFileDate( &date2, &time2, AlternateName ) )
+ {
+ if( bUseAlternate == TRUE )
+ {
+ DebugLogFile("gAddMaterial:gLoadTexture: Cannot find %s and alternate %s.\n", TextName, AlternateName );
+ return NULL;
+ }
+ }
+ else if( bUseAlternate == FALSE )
+ {
+ if( ( date2 > date1 ) || ( ( date2 == date1 ) && ( time2 >= time1 ) ) )
+ bUseAlternate = TRUE;
+ }
+ */
+
+ gBuildAlternateName(AlternateName, TextName);
+
+ if (!t3dGetFileDate(&date1, &time1, TextName)) // if it doesn't find the .tga texture, try the dds
+ bUseAlternate = TRUE;
+
+ if (!t3dGetFileDate(&date2, &time2, AlternateName)) { //se non trova la texture .dds
+ if (bUseAlternate == TRUE) { // does not find the .dds texture and furthermore the .tga does not exist
+ DebugLogFile("gAddMaterial:gLoadTexture: Cannot find %s and alternate %s.\n", TextName, AlternateName);
+ return nullptr;
+ }
+ } else if (bUseAlternate == FALSE) { // if there is the .dds and there is also the .tga see which is newer
+ if ((date2 > date1) || ((date2 == date1) && (time2 >= time1)))
+ bUseAlternate = TRUE;
+ }
+
+
+ if ((pos = gGetTextureListPosition()) == 0) {
+ DebugLogFile("gLoadTexture: Can't create more textures");
+ return nullptr;
+ }
+ Texture = &gTextureList[pos];
+ *Texture = gTexture();
+
+ if (bUseAlternate) {
+ auto stream = workDirs.resolveFile(AlternateName);
+ if (!stream) {
+ DebugLogFile("gAddMaterial:gLoadTexture: Cannot find %s.\n", AlternateName);
+ return nullptr;
+ }
+ lpSSource = parseDDS(*stream);
+ dwWidth = lpSSource->width;
+ dwHeight = lpSSource->height;
+ error("TODO");
+#if 0
+ Texture->texId = createTextureFromSurface(*lpSSource, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
+#endif
+ delete lpSSource;
+ lpSSource = nullptr;
+#if 0
+ if (gRenderFlags & gDXT1SUPPORTED) {
+ /* if( gRenderFlags & gAGPSUPPORTED )
+ { // Alloc texture in AGP
+ DDSurfDesc.ddsCaps.dwCaps= DDSCAPS_NONLOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_TEXTURE;
+ }
+ else
+ */ { //No AGP support; alloc in sysmem
+ DDSurfDesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
+ DDSurfDesc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
+ }
+ lpSSource = Texture->lpDDSurface;
+ } else
+ DDSurfDesc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
+ if (!(lpSSource = gCreateSurface(&DDSurfDesc, lpSSource))) {
+ DebugLogFile("gLoadTexture: gCreateSurface FAILED: Can't create surface DDS");
+ return NULL;
+ }
+
+ if ((lpSSource->Lock(NULL, &DDSurfDesc, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL))) { // Lock and fill with the dds
+ DebugLogFile("gLoadTexture: Can't lock surface DDS");
+ return NULL;
+ }
+
+ t3dReadData(DDSurfDesc.lpSurface, DDSurfDesc.dwLinearSize);
+
+ if ((lpSSource->Unlock(NULL))) {
+ DebugLogFile("gLoadTexture: Can't unlock surface DDS");
+ return NULL;
+ }
+#endif
+ stream = nullptr;
+ } else { // TGA
+ //warning("TODO: Handle TGA");
+#if 0
+ if (!t3dOpenFile(TextName)) {
+ DebugLogFile("gAddMaterial:gLoadTexture: Cannot find %s.\n", TextName);
+ return NULL;
+ }
+// Parse the PPM header
+ if (!loadTGAHeader(&dwWidth, &dwHeight)) {
+ t3dCloseFile();
+ DebugLogFile("gAddMaterial: gLoadTexture: Could not load or parse TGA header in %s.\n", TextName);
+ return NULL;
+ }
+#endif
+ }
+#if 0 // Replaced by createTextureFromSurface
+ if (!(gRenderFlags & gDXT1SUPPORTED) || (bUseAlternate == FALSE)) {
+ memset(&DDSurfDesc, 0, sizeof(DDSURFACEDESC2));
+ memcpy(&DDSurfDesc.ddpfPixelFormat, &gCurrentFormat->SurfaceDesc, sizeof(DDPIXELFORMAT));
+ DDSurfDesc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
+ /* if (gRenderFlags&gAGPSUPPORTED)
+ { //Alloc texture in AGP
+ DDSurfDesc.ddsCaps.dwCaps= DDSCAPS_NONLOCALVIDMEM | DDSCAPS_VIDEOMEMORY |
+ DDSCAPS_TEXTURE;
+ }
+ else
+ */ { //No AGP support; alloc in sysmem
+ DDSurfDesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
+ DDSurfDesc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
+ }
+ DDSurfDesc.dwWidth = dwWidth;
+ DDSurfDesc.dwHeight = dwHeight;
+ if (!(Texture->lpDDSurface = gCreateSurface(&DDSurfDesc, Texture->lpDDSurface))) {
+ DebugLogFile("gLoadTexture: gCreateSurface FAILED: Can't create surface");
+ return NULL;
+ }
+ }
+#endif
+ Texture->name = TextName;
+
+ if (bUseAlternate) {
+#if 0
+ // DebugFile( "Carico |%s|", AlternateName );
+ if (!(gRenderFlags & gDXT1SUPPORTED)) {
+ if (Texture->lpDDSurface->Blt(NULL, lpSSource, NULL, DDBLT_WAIT, NULL) != DD_OK) {
+ DebugLogFile("gLoadTexture: Can't Blit DDS texture");
+ return NULL;
+ }
+ lpSSource->Release();
+ } else
+ Texture->lpDDSurface = lpSSource;
+#endif
+ } else {
+#if 0
+ // DebugFile( "Carico |%s|", TextName );
+ Texture->lpDDSurface->Lock(NULL, &DDSurfDesc, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL); //Lock and fill with the tga
+ if (gCurrentFormat->abits)
+ bAlpha = TRUE;
+
+ if (!ReadTgaImage(TextName, &DDSurfDesc, bAlpha)) {
+ DebugLogFile("gLoadTexture: Error reading TGA file");
+ return NULL;
+ }
+ Texture->lpDDSurface->Unlock(NULL);
+#endif
+ }
+ Texture->RealDimX = dwWidth;
+ Texture->RealDimY = dwHeight;
+
+ if (LoaderFlags & rSURFACEHALF) {
+ warning("Half-res loading not implemented");
+#if 0
+ LPDIRECTDRAWSURFACE7 surf;
+ HRESULT err;
+
+ dwWidth /= 2;
+ dwHeight /= 2;
+
+ memset(&DDSurfDesc, 0, sizeof(DDSURFACEDESC2));
+ memcpy(&DDSurfDesc.ddpfPixelFormat, &gCurrentFormat->SurfaceDesc, sizeof(DDPIXELFORMAT));
+ DDSurfDesc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
+ /* if (gRenderFlags&gAGPSUPPORTED)
+ { //Alloc texture in AGP
+ DDSurfDesc.ddsCaps.dwCaps= DDSCAPS_NONLOCALVIDMEM | DDSCAPS_VIDEOMEMORY |
+ DDSCAPS_TEXTURE;
+ }
+ else
+ */ { //No AGP support; alloc in sysmem
+ DDSurfDesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
+ DDSurfDesc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
+ }
+ surf = NULL;
+ DDSurfDesc.dwWidth = dwWidth;
+ DDSurfDesc.dwHeight = dwHeight;
+ if (!(surf = gCreateSurface(&DDSurfDesc, surf))) {
+ DebugLogFile("gLoadTexture (rSURFACEHALF) FAILED: Can't create surface");
+ return NULL;
+ }
+ if ((err = surf->Blt(NULL, Texture->lpDDSurface, NULL, 0, NULL)) != DD_OK) {
+ char str[255];
+ GetDDErrorString(err, str, 1);
+ DebugLogFile("gLoadTexture: BltStretch failed.\n%s", str);
+ }
+
+ //Release old texture
+ Texture->lpDDSurface->Release();
+ //Assign the newone
+ Texture->lpDDSurface = surf;
+#endif
+ }
+
+ Texture->ID = pos;
+
+ Texture->Flags = CurLoaderFlags;
+ Texture->DimX = dwWidth;
+ Texture->DimY = dwHeight;
+
+ return Texture;
+}
+
+
+MaterialPtr Renderer::addMaterial(MaterialPtr MList, const Common::String &name, int NumFaces, unsigned int LoaderFlags) {
+ MaterialPtr Material = MList;
+ bool AlreadyLoaded = FALSE;
+ int len = name.size();
+
+ //warning("AddMaterial(%s)\n", name.c_str());
+ if (((name[len - 1 - 0] == 'i') || (name[len - 1 - 0] == 'I')) &&
+ ((name[len - 1 - 1] == 'v') || (name[len - 1 - 1] == 'V')) &&
+ ((name[len - 1 - 2] == 'a') || (name[len - 1 - 2] == 'A'))) {
+ if ((Material->Movie = gLoadMovie(*_workDirs, name.c_str())) == nullptr)
+ return nullptr;
+ if ((Material->Texture = gUserTexture(64,
+ 128)) == nullptr)
+// if( (Material->Texture=gUserTexture( Material->Movie->g_psiStreamInfo.rcFrame.right,
+// Material->Movie->g_psiStreamInfo.rcFrame.bottom)) == NULL )
+ return nullptr;
+ Material->Flags |= T3D_MATERIAL_MOVIE;
+ } else {
+ if ((Material->Texture = gLoadTexture(*_workDirs, name.c_str(), LoaderFlags)) == nullptr)
+ return nullptr;
+ }
+
+//f
+//f Material->FacesList=(WORD *)t3dRealloc(Material->FacesList,sizeof(WORD)*3*NumFaces+1);
+//f Material->NumAllocatedFaces+=3*NumFaces+1;
+ Material->FacesList.resize(Material->FacesList.size() + NumFaces * 3 );
+ Material->NumAllocatedFaces += NumFaces * 3;
+//f
+ Material->Flags |= T3D_MATERIAL_NOLIGHTMAP;
+ return Material;
+}
+
+} // End of namespace Watchmaker
+
+#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/3d/render/opengl_3d.h b/engines/watchmaker/3d/render/opengl_3d.h
new file mode 100644
index 00000000000..44a57602201
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl_3d.h
@@ -0,0 +1,67 @@
+/* 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 WATCHMAKER_OPENGL_3D_H
+#define WATCHMAKER_OPENGL_3D_H
+
+#include "watchmaker/windows_hacks.h"
+#include "watchmaker/render.h"
+
+#define MAXTEXTURES 2000
+
+namespace Watchmaker {
+
+struct gAvailFormat {
+ //DDPIXELFORMAT SurfaceDesc;
+ char rbits;
+ char gbits;
+ char bbits;
+ char abits;
+};
+
+struct Vertex {
+ float sx, sy, sz, rhw;
+ uint32 color;
+};
+
+extern unsigned int gNumTrianglesArray;
+extern unsigned int gNumLinesArray;
+
+extern gAvailFormat *gCurrentFormat;
+extern int NumAvailableFormats;
+extern gAvailFormat AvailableFormats[];
+
+extern gTexture gTextureList[];
+extern unsigned int gNumTextureList;
+
+extern uint16 gLinesArray[];
+extern unsigned int gNumLinesArray;
+extern unsigned int gNumTrianglesArray;
+extern Vertex gTriangles[];
+extern int g_lpD3DPointsBuffer;
+extern void *g_lpD3DUserVertexBuffer;
+extern unsigned int g_dwD3DUserVertexBufferCounter;
+extern unsigned int gNumPointsBuffer;
+
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_OPENGL_3D_H
diff --git a/engines/watchmaker/3d/render/opengl_renderer.cpp b/engines/watchmaker/3d/render/opengl_renderer.cpp
new file mode 100644
index 00000000000..b68bb8f8d84
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl_renderer.cpp
@@ -0,0 +1,201 @@
+/* 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 "watchmaker/3d/render/opengl_renderer.h"
+#include "watchmaker/t3d.h"
+
+#ifdef USE_OPENGL_GAME
+#include "graphics/opengl/system_headers.h"
+
+#include "math/glmath.h"
+
+namespace Watchmaker {
+
+OpenGLRenderer *g_renderer = nullptr;
+
+void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, Common::SharedPtr<VertexBuffer> VBO, int firstVertex, int numVertices, Common::Array<uint16> faces, uint32 numFaces) {
+ assert(numFaces <= faces.size());
+
+ assert(primitiveType == PrimitiveType::TRIANGLE);
+
+ float fNearPlane = 1.0f;//5000.0f;
+ float fFarPlane = 15000.0f;
+ float width = 1024;
+ float height = 768;
+
+ glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+
+ float fAspect = 60.0f;//curCamera->FovRad;
+ auto perspectiveMatrix = Math::makePerspectiveMatrix(fAspect, width / height, fNearPlane, fFarPlane);
+ glLoadMatrixf(perspectiveMatrix.getData());
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+
+ glEnable(GL_TEXTURE_2D);
+
+ glBegin(GL_TRIANGLES);
+ for (int i = 0; i < numFaces; i++) {
+ int index = faces[i];
+ auto &vertex = VBO->_buffer[index];
+ //warning("%d/%d %d: [%f, %f, %f], [%f, %f], [%f, %f]\n", i, numFaces, index, vertex.x, vertex.y, vertex.z, vertex.u1, vertex.v1, vertex.u2, vertex.v2);
+ //glColor3f((float)i/numFaces, 1.0, 0.0);
+ glColor3f(1.0f, 1.0f, 1.0f);
+ glTexCoord2f(vertex.u1, vertex.v1);
+ glVertex3f(vertex.x, vertex.y, -vertex.z);
+ }
+ glEnd();
+
+ glFlush();
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+}
+
+void OpenGLRenderer::drawPrimitives(PrimitiveType primitiveType, Vertex *vertices, int numPrimitives) {
+ assert(primitiveType == PrimitiveType::TRIANGLE);
+ glBegin(GL_TRIANGLES);
+ for (int i = 0; i < numPrimitives; i++) {
+ auto &vertex = vertices[i];
+ glColor3f(1.0, 1.0, 1.0);
+ glVertex3f(vertex.sx, vertex.sy, -vertex.sz);
+ }
+ glEnd();
+ glFlush();
+}
+void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, int VBO, int firstVertex, int numVertices, uint16 *faces, uint32 numFaces) {
+ //warning("TODO: Implement drawIndexedPrimitivesVBO\n");
+}
+
+
+void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, gBatchBlock &bb) {
+ drawIndexedPrimitivesVBO(primitiveType,
+ bb.VBO, 0, bb.NumVerts,
+ bb.FacesList,
+ bb.NumFaces/*, 0x0*/
+ );
+}
+
+void OpenGLRenderer::setTransformMatrix(TransformMatrix which, const Matrix4x4 &matrix) {
+ GLint oldMatrixMode;
+ glGetIntegerv(GL_MATRIX_MODE, &oldMatrixMode);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadMatrixf(matrix.data);
+ glScalef(1.0f, 1.0f, -1.0f);
+ glMatrixMode(oldMatrixMode);
+};
+
+void OpenGLRenderer::pushModelView() {
+ GLint oldMatrixMode;
+ glGetIntegerv(GL_MATRIX_MODE, &oldMatrixMode);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glMatrixMode(oldMatrixMode);
+}
+
+void OpenGLRenderer::popModelView() {
+ GLint oldMatrixMode;
+ glGetIntegerv(GL_MATRIX_MODE, &oldMatrixMode);
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(oldMatrixMode);
+}
+
+void OpenGLRenderer::setTextureWrapMode(int index, TextureWrapMode mode) {
+ GLint openGlWrapMode = 0;
+ switch (mode) {
+ case TextureWrapMode::WRAP:
+ openGlWrapMode = GL_REPEAT;
+ break;
+ case TextureWrapMode::CLAMP:
+ openGlWrapMode = GL_CLAMP;
+ break;
+ default:
+ assert(0);
+ }
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, openGlWrapMode);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, openGlWrapMode);
+}
+
+void OpenGLRenderer::setTexture(int stage, void *texture) {
+ if (texture == nullptr) {
+ glBindTexture(GL_TEXTURE_2D, 0);
+ } else {
+ assert(0);
+ }
+}
+void OpenGLRenderer::setTexture(int stage, const gTexture &texture) {
+ glBindTexture(GL_TEXTURE_2D, texture.texId);
+}
+
+void setGlFeature(GLint feature, bool state) {
+ if (state) {
+ glEnable(feature);
+ } else {
+ glDisable(feature);
+ }
+}
+
+void OpenGLRenderer::setRenderState(RenderState state, int value) {
+ switch (state) {
+ case RenderState::ZENABLE: {
+ glDepthFunc(GL_LEQUAL);
+ setGlFeature(GL_DEPTH_TEST, value);
+ break;
+ }
+ case RenderState::ALPHAREF: { // ALPHA-func is never changed.
+ glAlphaFunc(GL_ALWAYS, value);
+ }
+ case RenderState::ALPHABLEND: setGlFeature(GL_BLEND, value); break; // TODO
+
+ }
+ //warning("TODO: Implement setRenderState\n");
+}
+
+GLenum translateBlendFactorToGL(BlendFactor factor) {
+ switch (factor) {
+ case BlendFactor::ONE: return GL_ONE;
+ case BlendFactor::ZERO: return GL_ZERO;
+ case BlendFactor::SRCALPHA: return GL_SRC_ALPHA;
+ case BlendFactor::INVSRCALPHA: return GL_ONE_MINUS_SRC_ALPHA;
+ case BlendFactor::INVSRCCOLOR: return GL_ONE_MINUS_SRC_COLOR;
+ case BlendFactor::SRCCOLOR: return GL_SRC_COLOR;
+ case BlendFactor::DESTCOLOR: return GL_DST_COLOR;
+ case BlendFactor::INVDESTCOLOR: return GL_ONE_MINUS_DST_COLOR;
+ default:
+ assert(false);
+ }
+}
+
+void OpenGLRenderer::setBlendFunc(BlendFactor src, BlendFactor dst) {
+ glBlendFunc(translateBlendFactorToGL(src), translateBlendFactorToGL(dst));
+}
+
+} // End of namespace Watchmaker
+
+#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/3d/render/opengl_renderer.h b/engines/watchmaker/3d/render/opengl_renderer.h
new file mode 100644
index 00000000000..fc8bf6bc80a
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl_renderer.h
@@ -0,0 +1,104 @@
+/* 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 WATCHMAKER_OPENGL_RENDERER_H
+#define WATCHMAKER_OPENGL_RENDERER_H
+
+
+#include "watchmaker/3d/math/Matrix4x4.h"
+#include "watchmaker/utils.h"
+#include "watchmaker/render.h"
+#include "watchmaker/3d/render/opengl_3d.h"
+
+namespace Watchmaker {
+
+enum class TransformMatrix {
+ PROJECTION,
+ VIEW
+};
+
+enum class RenderState {
+ LIGHT,
+ CLIP,
+ EXTENT,
+ ALPHABLEND,
+ ALPHAREF, // TODO
+ ZENABLE, // TODO
+ ZWRITE_ENABLE, // TODO
+ TEXTUREFACTOR // TODO
+};
+
+enum class BlendFactor {
+ ONE,
+ ZERO,
+ SRCALPHA,
+ INVSRCALPHA,
+ INVSRCCOLOR,
+ SRCCOLOR,
+ DESTCOLOR,
+ INVDESTCOLOR
+};
+
+enum class TextureWrapMode {
+ WRAP,
+ CLAMP
+};
+
+enum class PrimitiveType {
+ LINE,
+ TRIANGLE
+};
+
+class OpenGLRenderer {
+public:
+ void pushModelView();
+ void popModelView();
+ void setTransformMatrix(TransformMatrix which, const Matrix4x4 &matrix);
+ // TODO: This should be split.
+ void setRenderState(RenderState state, int value);
+ void setBlendFunc(BlendFactor src, BlendFactor dst);
+ bool error() const {
+ //warning("TODO: Implement error\n");
+ return false;
+ }
+ Common::String getErrorString() {
+ warning("TODO: Implement getErrorString\n");
+ return "";
+ }
+ // TODO: This just maps to the D3D way to setting textures
+ void setTexture(int stage, void *texture);
+ void setTexture(int stage, const gTexture &texture);
+ void setTextureWrapMode(int index, TextureWrapMode mode);
+
+ void drawPrimitives(PrimitiveType primitiveType, Vertex *vertices, int numPrimitives);
+ void drawIndexedPrimitivesVBO(PrimitiveType primitiveType, int VBO, int firstVertex, int numVertices, uint16 *faces, uint32 numFaces);
+ void drawIndexedPrimitivesVBO(PrimitiveType primitiveType, Common::SharedPtr<VertexBuffer> VBO, int firstVertex, int numVertices, Common::Array<uint16> faces, uint32 numFaces);
+ void drawIndexedPrimitivesVBO(PrimitiveType primitiveType, gBatchBlock &bb);
+ bool supportsMultiTexturing() const { // TODO
+ return false;
+ }
+};
+
+extern OpenGLRenderer *g_renderer;
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_OPENGL_RENDERER_H
diff --git a/engines/watchmaker/3d/render/render.cpp b/engines/watchmaker/3d/render/render.cpp
new file mode 100644
index 00000000000..95a8a381944
--- /dev/null
+++ b/engines/watchmaker/3d/render/render.cpp
@@ -0,0 +1,693 @@
+/* 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 "watchmaker/render.h"
+#include "watchmaker/windows_hacks.h"
+#include "watchmaker/3d/render/opengl_3d.h"
+#include "watchmaker/render.h"
+#include "watchmaker/3d/render/opengl_renderer.h"
+#include "watchmaker/3d/render/opengl_2d.h"
+#include "watchmaker/3d/render/shadows.h"
+#include "watchmaker/ll/ll_regen.h"
+
+namespace Watchmaker {
+
+unsigned int bLightmaps = FALSE; // if lightmaps are activated
+unsigned int bDisableShadows = FALSE; // if shadows should be disabled
+unsigned int bDisableMultiTexturing = FALSE; // if multitexturing should be disabled
+
+gBatchBlock BatchBlockList[MAX_BATCH_BLOCKS];
+gBatchBlock BatchBlockListSpecial[MAX_BATCH_BLOCKS_SPECIAL];
+//gBatchBlock BatchBlockListLightmaps[MAX_BATCH_BLOCKS_LIGHTMAPS];
+gBatchBlock BatchBlockListSky[MAX_BATCH_BLOCKS_SKY];
+
+unsigned int NumBatchBlocks = 0;
+unsigned int NumBatchBlocksSpecial = 0;
+//unsigned int NumBatchBlocksLightmaps=0;
+unsigned int NumBatchBlocksSky = 0;
+
+/* -----------------13/08/99 10.34-------------------
+ * Comparazione per BB
+ * --------------------------------------------------*/
+int cmpbb(const void *a, const void *b) {
+ gBatchBlock *v1 = (gBatchBlock *)a;
+ gBatchBlock *v2 = (gBatchBlock *)b;
+
+ if (v1->Texture2 < v2->Texture2) return -1;
+ else if (v1->Texture2 > v2->Texture2) return 1;
+ else if (v1->Texture1 < v2->Texture1) return -1;
+ else if (v1->Texture1 > v2->Texture1) return 1;
+ else return 0;
+}
+
+/* -----------------31/05/99 10.12-------------------
+ * Attiva o disattiva lo ZBuffer
+ * --------------------------------------------------*/
+bool rSetZBufferState(bool state) {
+ g_renderer->setRenderState(RenderState::ZENABLE, state);
+ g_renderer->setRenderState(RenderState::ZWRITE_ENABLE, state);
+
+ return !g_renderer->error();
+}
+
+
+/* -----------------25/06/99 11.14-------------------
+ * Renderizza il cielo senza considerare lo zbuffer
+ * --------------------------------------------------*/
+void RenderSky(void) {
+ unsigned int i;
+ bool hres;
+ gBatchBlock *bb;
+
+ if (!NumBatchBlocksSky)
+ return;
+
+ if (!rSetZBufferState(false)) {
+ DebugLogFile("Can't rSetZBufferState FALSE");
+ return ;
+ }
+
+ g_renderer->setRenderState(RenderState::ALPHABLEND, TRUE);
+ g_renderer->setRenderState(RenderState::ALPHAREF, 0x00000055);
+ g_renderer->setBlendFunc(BlendFactor::ONE, BlendFactor::INVSRCALPHA);
+ if (g_renderer->error()) {
+ return;
+ }
+
+ bb = &BatchBlockListSky[0];
+ for (i = 0; i < NumBatchBlocksSky; i++, bb++) {
+ if (bb->Texture1 < 0) continue;
+ rSetUserViewMatrix(bb->ViewMatrixNum);
+
+ if (bb->Texture1)
+ g_renderer->setTexture(0, gTextureList[bb->Texture1]);
+ else
+ g_renderer->setTexture(0, nullptr);
+
+ g_renderer->drawIndexedPrimitivesVBO(PrimitiveType::TRIANGLE, *bb);
+ hres = !g_renderer->error();
+ if (!hres) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("DrawIndexedPrimitiveVB ERROR:\n\r%s", str.c_str());
+ }
+ bb->Texture1 = -3;
+ bb->Texture2 = -3;
+ }
+
+ if (!rSetZBufferState(true)) {
+ DebugLogFile("Can't rSetZBufferState TRUE");
+ return ;
+ }
+}
+
+
+/* -----------------31/05/99 10.19-------------------
+ * Renderizza la Geometria
+ * --------------------------------------------------*/
+void RenderGeometry(void) {
+ signed short int LastViewMatrixNum, LastTexture1, LastTexture2;
+ gBatchBlock *bb;
+ bool hres = false;
+
+ RenderSky();
+ //warning("TODO: Texture configuration\n");
+#if 0
+ g_renderer->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
+ g_renderer->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
+ g_renderer->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ g_renderer->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+#endif
+ g_renderer->setTextureWrapMode(1, TextureWrapMode::CLAMP);
+
+ g_renderer->setRenderState(RenderState::TEXTUREFACTOR, 0xFFFFFFFF);
+ g_renderer->setRenderState(RenderState::ALPHAREF, 0x00000000);
+
+ g_renderer->setRenderState(RenderState::ALPHABLEND, FALSE);
+ if (g_renderer->error()) {
+ return;
+ }
+
+ LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
+ bb = &BatchBlockList[0];
+ qsort(bb, NumBatchBlocks, sizeof(gBatchBlock), cmpbb);
+ for (int i = 0; i < NumBatchBlocks; i++, bb++) {
+ if (bb->Texture1 < 0) continue;
+
+ if (bb->ViewMatrixNum != LastViewMatrixNum) {
+ rSetUserViewMatrix(bb->ViewMatrixNum);
+ LastViewMatrixNum = bb->ViewMatrixNum;
+ }
+ if (bb->Texture1 != LastTexture1) {
+ if (bb->Texture1)
+ g_renderer->setTexture(0, gTextureList[bb->Texture1]);
+ else
+ g_renderer->setTexture(0, nullptr);
+ LastTexture1 = bb->Texture1;
+ }
+ if ((g_renderer->supportsMultiTexturing()) && (bb->Texture2 != LastTexture2)) {
+ if (bb->Texture2 > 0) {
+ if (LastTexture2 <= 0) {
+ //warning("TODO: Texture configuration\n");
+#if 0
+ g_renderer->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
+ g_renderer->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+ g_renderer->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
+ g_renderer->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2);
+ g_renderer->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
+#endif
+ g_renderer->setTextureWrapMode(1, TextureWrapMode::CLAMP);
+ }
+ g_renderer->setTexture(1, gTextureList[bb->Texture2]);
+ } else if (LastTexture2 > 0) {
+ //warning("TODO: Texture configuration\n");
+#if 0
+ g_renderer->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ g_renderer->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+#endif
+ g_renderer->setTexture(1, nullptr);
+ }
+ LastTexture2 = bb->Texture2;
+ }
+
+ g_renderer->drawIndexedPrimitivesVBO(PrimitiveType::TRIANGLE, *bb);
+
+ hres = !g_renderer->error();
+ if (!hres) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("DrawIndexedPrimitiveVB ERROR:\n\r%s", str.c_str());
+ }
+ bb->Texture1 = -3;
+ }
+ //warning("TODO: Texture configuration\n");
+#if 0
+ g_renderer->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+ g_renderer->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+#endif
+
+// 2nd pass: lightmaps, if device doesn't support multi-texturing
+ if ((!g_renderer->supportsMultiTexturing()) && (bLightmaps)) {
+ g_renderer->setRenderState(RenderState::ZWRITE_ENABLE, FALSE);
+
+#if 0 // TODO
+ g_renderer->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 1); // use mapping coordinates set 1
+#endif
+ g_renderer->setBlendFunc(BlendFactor::ZERO, BlendFactor::SRCCOLOR);
+ g_renderer->setRenderState(RenderState::ALPHABLEND, true);
+ if (g_renderer->error()) {
+ return;
+ }
+
+ LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
+ bb = &BatchBlockList[0];
+ for (int i = 0; i < NumBatchBlocks; i++, bb++) {
+ if (bb->Texture2 <= 0) continue;
+
+ if (bb->ViewMatrixNum != LastViewMatrixNum) {
+ rSetUserViewMatrix(bb->ViewMatrixNum);
+ LastViewMatrixNum = bb->ViewMatrixNum;
+ }
+ if (bb->Texture2 != LastTexture2) {
+ g_renderer->setTexture(0, gTextureList[bb->Texture2]);
+ LastTexture2 = bb->Texture2;
+ }
+
+ g_renderer->drawIndexedPrimitivesVBO(PrimitiveType::TRIANGLE, *bb);
+ hres = !g_renderer->error();
+ if (!hres) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("DrawIndexedPrimitiveVB ERROR:\n\r%s", str.c_str());
+ }
+ }
+
+ g_renderer->setRenderState(RenderState::ZWRITE_ENABLE, TRUE);
+#if 0 // TODO
+ g_renderer->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); // mapping coordinates back to set 0
+#endif
+ }
+
+// Clipmaps
+ g_renderer->setRenderState(RenderState::ALPHABLEND, TRUE);
+ g_renderer->setRenderState(RenderState::ALPHAREF, 0x00000055);
+
+ g_renderer->setBlendFunc(BlendFactor::ONE, BlendFactor::INVSRCALPHA);
+ if (g_renderer->error()) {
+ return;
+ }
+
+ LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
+ bb = &BatchBlockListSpecial[0];
+ qsort(bb, NumBatchBlocksSpecial, sizeof(gBatchBlock), cmpbb);
+ for (int i = 0; i < NumBatchBlocksSpecial; i++, bb++) {
+ if (bb->Texture1 < 0) continue;
+ if (!(bb->Flags1 & T3D_MATERIAL_CLIPMAP) ||
+ (bb->Flags1 & T3D_MATERIAL_FLARE) ||
+ (bb->Flags1 & T3D_MATERIAL_SMOKE))
+ continue;
+
+ if (bb->ViewMatrixNum != LastViewMatrixNum) {
+ rSetUserViewMatrix(bb->ViewMatrixNum);
+ LastViewMatrixNum = bb->ViewMatrixNum;
+ }
+ if (bb->Texture1 != LastTexture1) {
+ if (bb->Texture1)
+ g_renderer->setTexture(0, gTextureList[bb->Texture1]);
+ else
+ g_renderer->setTexture(0, nullptr);
+ LastTexture1 = bb->Texture1;
+ }
+
+ g_renderer->drawIndexedPrimitivesVBO(PrimitiveType::TRIANGLE, *bb);
+ hres = !g_renderer->error();
+ if (!hres) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("DrawIndexedPrimitiveVB ERROR:\n\r%s", str.c_str());
+ }
+ bb->Texture1 = -3;
+ bb->Texture2 = -3;
+ }
+
+// Render Smoke or Flare materials
+ g_renderer->setRenderState(RenderState::ALPHAREF, 0x00000055);
+ g_renderer->setRenderState(RenderState::ZWRITE_ENABLE, FALSE);
+ if (g_renderer->error()) {
+ return;
+ }
+
+ LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
+ bb = &BatchBlockListSpecial[0];
+ for (int i = 0; i < NumBatchBlocksSpecial; i++, bb++) {
+ if (bb->Texture1 < 0) continue;
+ if (!(bb->Flags1 & T3D_MATERIAL_FLARE) &&
+ !(bb->Flags1 & T3D_MATERIAL_SMOKE))
+ continue;
+
+ if (bb->Flags1 & T3D_MATERIAL_FLARE_SUN) {
+ g_renderer->setBlendFunc(BlendFactor::ONE, BlendFactor::INVSRCCOLOR);
+ } else if (bb->Flags1 & T3D_MATERIAL_FLARESOFT) {
+ g_renderer->setRenderState(RenderState::ZENABLE, FALSE);
+ g_renderer->setBlendFunc(BlendFactor::DESTCOLOR, BlendFactor::ONE);
+ } else if (bb->Flags1 & T3D_MATERIAL_SMOKE) {
+ g_renderer->setBlendFunc(BlendFactor::SRCALPHA, BlendFactor::ONE);
+ } else {
+ g_renderer->setBlendFunc(BlendFactor::SRCCOLOR, BlendFactor::ONE);
+ }
+ if (g_renderer->error()) {
+ return;
+ }
+
+ if (bb->ViewMatrixNum != LastViewMatrixNum) {
+ rSetUserViewMatrix(bb->ViewMatrixNum);
+ LastViewMatrixNum = bb->ViewMatrixNum;
+ }
+ if (bb->Texture1 != LastTexture1) {
+ if (bb->Texture1)
+ g_renderer->setTexture(0, gTextureList[bb->Texture1]);
+ else
+ g_renderer->setTexture(0, nullptr);
+ LastTexture1 = bb->Texture1;
+ }
+
+ g_renderer->drawIndexedPrimitivesVBO(PrimitiveType::TRIANGLE, *bb);
+ if (!hres) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("DrawIndexedPrimitiveVB ERROR:\n\r%s", str.c_str());
+ }
+ bb->Texture1 = -3;
+ bb->Texture2 = -3;
+ }
+ g_renderer->setRenderState(RenderState::ZWRITE_ENABLE, TRUE);
+ hres = !g_renderer->error();
+ if (!hres) {
+ return;
+ }
+
+// Print transparent/translucent materials
+ g_renderer->setRenderState(RenderState::ALPHAREF, 0x0000002);
+
+ LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
+ bb = &BatchBlockListSpecial[0];
+ for (int i = 0; i < NumBatchBlocksSpecial; i++, bb++) {
+ if (bb->Texture1 < 0) continue;
+ if ((bb->Flags1 & T3D_MATERIAL_FLARE) ||
+ (bb->Flags1 & T3D_MATERIAL_SMOKE))
+ continue;
+
+ if (bb->Flags1 & T3D_MATERIAL_GLASS) {
+ g_renderer->setBlendFunc(BlendFactor::DESTCOLOR, BlendFactor::ZERO);
+ return;
+ } else if (bb->Flags1 & T3D_MATERIAL_OPACITY) {
+ g_renderer->setBlendFunc(BlendFactor::ONE, BlendFactor::SRCCOLOR);
+ } else if (bb->Flags1 & T3D_MATERIAL_BOTTLE) {
+ g_renderer->setBlendFunc(BlendFactor::ONE, BlendFactor::INVDESTCOLOR);
+ } else if (bb->Flags1 & T3D_MATERIAL_ADDITIVE) {
+ g_renderer->setBlendFunc(BlendFactor::DESTCOLOR, BlendFactor::ONE);
+ } else {
+ continue;
+ }
+ if (g_renderer->error()) {
+ return;
+ }
+
+ if (bb->ViewMatrixNum != LastViewMatrixNum) {
+ rSetUserViewMatrix(bb->ViewMatrixNum);
+ LastViewMatrixNum = bb->ViewMatrixNum;
+ }
+ if (bb->Texture1 != LastTexture1) {
+ if (bb->Texture1)
+ g_renderer->setTexture(0, gTextureList[bb->Texture1]);
+ else
+ g_renderer->setTexture(0, nullptr);
+ LastTexture1 = bb->Texture1;
+ }
+
+ g_renderer->drawIndexedPrimitivesVBO(PrimitiveType::TRIANGLE, *bb);
+ hres = !g_renderer->error();
+ if (!hres) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("DrawIndexedPrimitiveVB ERROR:\n\r%s", str.c_str());
+ }
+ bb->Texture1 = -3;
+ bb->Texture2 = -3;
+ }
+
+// Render blank materials
+// ???
+}
+
+/* -----------------31/05/99 10.55-------------------
+ * Renderizza la scena
+ * --------------------------------------------------*/
+bool rRenderScene(void) {
+ unsigned int i, j;
+ bool hres;
+ static int Logostops = 0;
+ static unsigned int dwFrameCount = 0;
+
+ g_renderer->setRenderState(RenderState::LIGHT, false);
+ g_renderer->setRenderState(RenderState::CLIP, true);
+ g_renderer->setRenderState(RenderState::EXTENT, false);
+
+ // Added:
+ ResetScreenBuffer();
+
+ if (!gStencilBitDepth && !bDisableShadows) {
+//tb
+ //Render Projected shadow into shadow surface
+ for (j = 0; j < gNumShadowBoxesList; j++) {
+ SHADOWBOX *sb = ShadowBoxesList[j];
+ rSetUserViewMatrix(sb->ViewMatrixNum);
+ if (bDisableShadows) break;
+ warning("TODO: Shadows\n");
+#if 0
+ for (i = 0; i < sb->NumShadowsList; i++) {
+ if (!(hres = RenderProjectiveShadow(&sb->ShadowsList[i]))) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogFile("Unable to RenderProjectiveShadow into a texture: %s | %d %d | %d", str.c_str(), S_OK, DD_OK, hres);
+ bDisableShadows = TRUE;
+ break;
+ }
+
+ if (sb->ShadowsList[i].ProjectiveTexture.lpDDSurface) {
+ if (hres = sb->ShadowsList[i].ProjectiveTexture.lpDDSurface->BltFast(0, 0, g_pddsShadowBuffer, NULL, DDBLTFAST_NOCOLORKEY) != S_OK) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("Unable to blitfast Shadowbuffer into a texture: %s", str.c_str());
+ bDisableShadows = TRUE;
+ break;
+ }
+
+ }
+ /* if (g_pddsBackBuffer && !j)
+ {
+ RECT rect;
+ rect.left=rect.top=0;
+ rect.right=rect.bottom=256;
+
+ if (FAILED(hres=g_pddsBackBuffer->BltFast(0,0,sb->ShadowsList[i].ProjectiveTexture.lpDDSurface,&rect,DDBLTFAST_NOCOLORKEY)))
+ {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("Unable to blit projective texture: %s",str);
+ bDisableShadows=TRUE;
+ break;
+ }
+ }*/
+ }
+#endif
+ }
+//tb
+ }
+
+ // Begin the scene.
+#if 0
+ if (FAILED(g_pd3dDevice->BeginScene()))
+ goto closescene;
+#endif
+ RenderGeometry();
+
+ if (gStencilBitDepth && !bDisableShadows) {
+//sb
+ rSaveViewMatrix();
+ g_renderer->setRenderState(RenderState::ALPHAREF, 0x00000002);
+ hres = !g_renderer->error();
+ if (!hres) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("Unable to SetRenderState for Shadowbuffer: %s", str.c_str());
+ bDisableShadows = TRUE;
+ }
+
+ //Render Shadows volumes
+ for (j = 0; j < gNumShadowBoxesList; j++) {
+ SHADOWBOX *sb = ShadowBoxesList[j];
+ rSetUserViewMatrix(sb->ViewMatrixNum);
+ for (i = 0; i < sb->NumShadowsList; i++)
+ RenderShadow(&sb->ShadowsList[i], sb->ShadowsList[i].VB);
+
+ if (i) {
+ RenderShadowBox(sb, sb->VBO);
+
+ unsigned int width, height, bpp;
+ rGetScreenInfos(&width, &height, &bpp);
+ DrawShadow(0, 0, width, height, sb->Intensity);
+ }
+ }
+ rRestoreViewMatrix();
+//sb
+ } else if (!bDisableShadows) {
+//tb
+ for (j = 0; j < gNumShadowBoxesList; j++) {
+ SHADOWBOX *sb = ShadowBoxesList[j];
+ rSetUserViewMatrix(sb->ViewMatrixNum);
+ for (i = 0; i < sb->NumShadowsList; i++)
+ if (!(hres = DrawProjectiveShadow(&sb->ShadowsList[i]))) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogFile("Unable to DrawProjectiveShadow: %s", str.c_str());
+ bDisableShadows = TRUE;
+ }
+ }
+//tb
+ }
+
+ // Display logos if exists
+ if ((NumLogosMaterials) && (NumLogosMaterials != Logostops)) {
+ gLogo *lpLogos = Logos;
+ WORD Array[2 * 3];
+
+ Logostops = 0;
+
+ Array[0] = 0;
+ Array[1] = 1;
+ Array[2] = 2;
+ Array[3] = 3;
+ Array[4] = 2;
+ Array[5] = 1;
+
+ g_renderer->setTextureWrapMode(0, TextureWrapMode::CLAMP);
+
+ g_renderer->setRenderState(RenderState::ALPHABLEND, false);
+ g_renderer->setBlendFunc(BlendFactor::ONE, BlendFactor::ZERO);
+ if (g_renderer->error()) {
+ goto closescene;
+ }
+
+ rSetZBufferState(FALSE);
+
+ for (i = 0; i < (unsigned int)NumLogosMaterials; i++, lpLogos++) {
+ if (lpLogos->Verts[0].sy == lpLogos->Verts[2].sy) {
+ Logostops++;
+ continue;
+ }
+
+ if (lpLogos->Material->Texture)
+ g_renderer->setTexture(0, lpLogos->Material->Texture);
+
+#if 0 // TODO!
+ hres = g_renderer->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
+ D3DFVF_TLVERTEX,
+ lpLogos->Verts, 4,
+ Array, 6, 0x0);
+#endif
+ lpLogos->Delay--;
+ if (lpLogos->Delay < 0) {
+ lpLogos->Verts[0].sx += 0.5f;
+ lpLogos->Verts[0].sy += 1.0f;
+ lpLogos->Verts[0].sz += 0.008f;
+ lpLogos->Verts[0].rhw = 1.0f / lpLogos->Verts[0].sz;
+ lpLogos->Verts[1].sx -= 0.5f;
+ lpLogos->Verts[1].sy += 1.0f;
+ lpLogos->Verts[1].sz += 0.008f;
+ lpLogos->Verts[1].rhw = 1.0f / lpLogos->Verts[1].sz;
+ lpLogos->Verts[2].sx -= 0.5f;
+ lpLogos->Verts[2].sy -= 1.0f;
+ lpLogos->Verts[2].sz -= 0.008f;
+ lpLogos->Verts[2].rhw = 1.0f / lpLogos->Verts[2].sz;
+ lpLogos->Verts[3].sx += 0.5f;
+ lpLogos->Verts[3].sy -= 1.0f;
+ lpLogos->Verts[3].sz -= 0.008f;
+ lpLogos->Verts[3].rhw = 1.0f / lpLogos->Verts[3].sz;
+ }
+ }
+
+ rSetZBufferState(TRUE);
+ g_renderer->setTextureWrapMode(0, TextureWrapMode::WRAP);
+ }
+
+ if (gNumLinesArray && gNumPointsBuffer) {
+ rSaveViewMatrix();
+ rSetLinesViewMatrix();
+
+ g_renderer->setBlendFunc(BlendFactor::ONE, BlendFactor::ZERO);
+ g_renderer->setRenderState(RenderState::ALPHABLEND, false);
+ if (g_renderer->error()) {
+ goto closescene;
+ }
+
+ g_renderer->setTexture(0, nullptr);
+ /*
+ hres=g_pd3dDevice->DrawIndexedPrimitiveVB( D3DPT_LINELIST,
+ g_lpD3DPointsBuffer,0,gNumPointsBuffer,
+ gLinesArray, gNumLinesArray,0);
+ */
+ g_renderer->drawIndexedPrimitivesVBO(PrimitiveType::LINE, g_lpD3DPointsBuffer, 0, gNumPointsBuffer, gLinesArray, gNumLinesArray/*, 0*/);
+ hres = g_renderer->error();
+ if (!hres) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("DrawIndexedPrimitiveVB ERROR:\n\r%s", str.c_str());
+ }
+ rRestoreViewMatrix();
+ gNumLinesArray = 0;
+ }
+
+
+ if (gNumTrianglesArray) {
+ rSetZBufferState(FALSE);
+
+ g_renderer->setRenderState(RenderState::ALPHAREF, 0x0000000);
+ g_renderer->setBlendFunc(BlendFactor::ONE, BlendFactor::SRCALPHA);
+ g_renderer->setRenderState(RenderState::ALPHABLEND, true);
+ if (g_renderer->error()) {
+ goto closescene;
+ }
+
+ g_renderer->setTexture(0, nullptr);
+ g_renderer->drawPrimitives(PrimitiveType::TRIANGLE,
+ /*D3DFVF_TLVERTEX,*/ gTriangles,
+ gNumTrianglesArray/*, 0x0*/);
+ hres = !g_renderer->error();
+ if (!hres) {
+ Common::String str = g_renderer->getErrorString();
+ DebugLogWindow("DrawIndexedPrimitiveVB ERROR:\n\r%s", str.c_str());
+ }
+ gNumTrianglesArray = 0;
+ rSetZBufferState(TRUE);
+ }
+#if 0
+ g_pd3dDevice->EndScene();
+#endif
+ NumBatchBlocks = 0;
+ NumBatchBlocksSpecial = 0;
+// NumBatchBlocksLightmaps=0;
+ NumBatchBlocksSky = 0;
+
+ dwFrameCount++;
+
+ return TRUE;
+ // End the scene.
+
+closescene:
+#if 0
+ g_pd3dDevice->EndScene();
+#endif
+ DebugLogFile("Error during renderscene");
+ return FALSE;
+}
+
+
+/* -----------------13/08/99 10.34-------------------
+ * Aggiunge un nuovo BatchBlock
+ * --------------------------------------------------*/
+gBatchBlock *rNewBatchBlock(signed short int T1, unsigned int F1, signed short int T2, unsigned int F2) {
+ gBatchBlock *bb;
+
+ bb = nullptr;
+ if ((F1 & T3D_MATERIAL_GLASS) ||
+ (F1 & T3D_MATERIAL_OPACITY) ||
+ (F1 & T3D_MATERIAL_CLIPMAP) ||
+ (F1 & T3D_MATERIAL_SMOKE) ||
+ (F1 & T3D_MATERIAL_BOTTLE) ||
+ (F1 & T3D_MATERIAL_FLARE) ||
+ (F1 & T3D_MATERIAL_ADDITIVE)) {
+ if ((NumBatchBlocksSpecial + 1) < MAX_BATCH_BLOCKS_SPECIAL)
+ bb = &BatchBlockListSpecial[NumBatchBlocksSpecial++];
+ else
+ DebugLogFile("Too many BB Special: %d (MAX is %d)!", NumBatchBlocksSpecial, MAX_BATCH_BLOCKS_SPECIAL);
+ }
+// else if( (T2>0) )
+// {
+// if( (NumBatchBlocksLightmaps+1) < MAX_BATCH_BLOCKS_LIGHTMAPS )
+// bb=&BatchBlockList[NumBatchBlocksLightmaps++];
+// else
+// DebugLogFile("Too many BB LightMaps: %d (MAX is %d)!",NumBatchBlocksLightmaps,MAX_BATCH_BLOCKS_LIGHTMAPS);
+// }
+ else if ((F1 & T3D_MATERIAL_SKY)) {
+ if ((NumBatchBlocksSky + 1) < MAX_BATCH_BLOCKS_SKY)
+ bb = &BatchBlockListSky[NumBatchBlocksSky++];
+ else
+ DebugLogFile("Too many BB Sky: %d (MAX is %d)!", NumBatchBlocksSky, MAX_BATCH_BLOCKS_SKY);
+ } else {
+ if ((NumBatchBlocks + 1) < MAX_BATCH_BLOCKS)
+ bb = &BatchBlockList[NumBatchBlocks++];
+ else
+ DebugLogFile("Too many BB: %d (MAX is %d)!", NumBatchBlocks, MAX_BATCH_BLOCKS);
+ }
+
+ if (!bb) return nullptr;
+
+ *bb = gBatchBlock();
+ bb->Texture1 = T1;
+ bb->Texture2 = T2;
+ bb->Flags1 = F1;
+ bb->Flags2 = F2;
+ bb->NumFaces = 0;
+ bb->NumVerts = 0;
+ bb->FacesList.clear();
+ return bb;
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/render/render.h b/engines/watchmaker/3d/render/render.h
new file mode 100644
index 00000000000..813ec8af3d2
--- /dev/null
+++ b/engines/watchmaker/3d/render/render.h
@@ -0,0 +1,29 @@
+/* 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 WATCHMAKER_3D_RENDER_H
+#define WATCHMAKER_3D_RENDER_H
+
+namespace Watchmaker {
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_3D_RENDER_H
diff --git a/engines/watchmaker/3d/render/shadows.cpp b/engines/watchmaker/3d/render/shadows.cpp
new file mode 100644
index 00000000000..3a9a387ee5a
--- /dev/null
+++ b/engines/watchmaker/3d/render/shadows.cpp
@@ -0,0 +1,945 @@
+/* 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 "watchmaker/3d/render/shadows.h"
+#include "watchmaker/3d/math/Matrix4x4.h"
+
+
+#define MAX_SHADOW_BOXES 20 // max shadows
+
+namespace Watchmaker {
+
+SHADOWBOX *ShadowBoxesList[MAX_SHADOW_BOXES];
+unsigned int gNumShadowBoxesList = 0;
+
+unsigned int gGetTextureListPosition();
+extern unsigned int CurLoaderFlags;
+#if 0
+#pragma pack(1)
+struct COLORVERTEX { // vertex structures
+ D3DVECTOR p;
+ D3DCOLOR c;
+};
+
+struct TRANSCOLORVERTEX { // transformed vertex
+ D3DVECTOR p;
+ D3DVALUE rhw;
+ D3DCOLOR c;
+};
+#pragma pack()
+#endif
+#define MAX_SHADOW_BOXES 20 // max shadows
+
+bool g_bUseOneBitStencil = FALSE; // if Stencil buffer if 1 bit deep only
+DWORD g_max_StencilVal = 255; // maximum value the stencil buffer will hold
+#if 0
+D3DSTENCILOP g_StencDecOp, g_StencIncOp; // increment e decrement functions
+
+LPDIRECTDRAWSURFACE7 g_pddsShadowBuffer = NULL;
+LPDIRECTDRAWSURFACE7 g_pddsShadowZBuffer = NULL;
+#endif
+//************************************************************************************************
+inline void SetIdentityMatrix(Matrix4x4 &m) { // set D3D matrix to identity
+ m.setIdentity();
+}
+
+#if 0
+//************************************************************************************************
+int ccw(COLORVERTEX *P[], int i, int j, int k) { // for convex-hull
+ double a = P[i]->p.x - P[j]->p.x,
+ b = P[i]->p.y - P[j]->p.y,
+ c = P[k]->p.x - P[j]->p.x,
+ d = P[k]->p.y - P[j]->p.y;
+ return a * d - b * c <= 0; // true if points i, j, k counterclockwise
+}
+
+//*********************************************************************************************
+int cmpl(const void *a, const void *b) { // for convex-hull
+ float v;
+ COLORVERTEX **av, **bv;
+
+ av = (COLORVERTEX **)a;
+ bv = (COLORVERTEX **)b;
+
+ v = (*av)->p.x - (*bv)->p.x;
+
+ if (v > 0) return 1;
+ if (v < 0) return -1;
+
+ v = (*bv)->p.y - (*av)->p.y;
+
+ if (v > 0) return 1;
+ if (v < 0) return -1;
+
+ return 0;
+}
+
+//*********************************************************************************************
+int cmph(const void *a, const void *b) {
+ return cmpl(b, a); // for convex-hull
+}
+
+//*********************************************************************************************
+int make_chain(COLORVERTEX *V[], int n, int (*cmp)(const void *, const void *)) { // for convex-hull
+ int i, j, s = 1;
+ COLORVERTEX *t;
+
+ qsort(V, n, sizeof(COLORVERTEX *), cmp);
+ for (i = 2; i < n; i++) {
+ for (j = s; j >= 1 && ccw(V, i, j, j - 1); j--)
+ {}
+ s = j + 1;
+ t = V[s];
+ V[s] = V[i];
+ V[i] = t;
+ }
+ return s;
+}
+
+//*********************************************************************************************
+int ch2d(COLORVERTEX *P[], int n) { // for convex-hull
+ int u = make_chain(P, n, cmpl); // make lower hull
+ if (!n) return 0;
+ P[n] = P[0];
+ return u + make_chain(P + u, n - u + 1, cmph); // make upper hull
+}
+
+//************************************************************************************************
+void Find2DConvexHull(DWORD nverts, COLORVERTEX *pntptr, DWORD *cNumOutIdxs, WORD **OutHullIdxs) { // find a convex hull
+ COLORVERTEX **PntPtrs;
+ DWORD i;
+
+ *cNumOutIdxs = 0; //max space needed is n+1 indices
+ *OutHullIdxs = (WORD *)malloc((nverts + 1) * (sizeof(DWORD) + sizeof(COLORVERTEX *)));
+
+ PntPtrs = (COLORVERTEX **) & (*OutHullIdxs)[nverts + 1];
+
+ // alg requires array of ptrs to verts (for qsort) instead of array of verts, so do the conversion
+ for (i = 0; i < nverts; i++) {
+ PntPtrs[i] = &pntptr[i];
+ }
+
+ *cNumOutIdxs = ch2d(PntPtrs, nverts);
+
+ // convert back to array of idxs
+ for (i = 0; i < *cNumOutIdxs; i++) {
+ (*OutHullIdxs)[i] = (WORD)(PntPtrs[i] - &pntptr[0]);
+ }
+}
+
+#endif
+
+/* -----------------25/08/1999 16.41-----------------
+ * find 2D convex hull for the object
+ * --------------------------------------------------*/
+bool rMakeShadowVolume(SHADOWBOX *sb, gVertex *InVerts, DWORD nverts, float lightm[9]) {
+ warning("Stubbed: rMakeShadowVolume\n");
+#if 0
+ Matrix4x4 matWorld, matView, matProj, IDmat;
+ DWORD i;
+ HRESULT hr;
+ LPDIRECT3DDEVICE7 pd3dDevice = g_pd3dDevice;
+ unsigned int AlphaVal = 98;
+ SHADOW *shad = &sb->ShadowsList[sb->NumShadowsList++];
+
+ // Get a ptr to the ID3D object to create materials and/or lights. Note:
+ // the Release() call just serves to decrease the ref count.
+ LPDIRECT3D7 pD3D;
+ pd3dDevice->GetDirect3D(&pD3D);
+ pD3D->Release();
+
+ LPDIRECT3DVERTEXBUFFER7 VB_Proj;
+ D3DVERTEXBUFFERDESC vbDesc;
+ vbDesc.dwSize = sizeof(D3DVERTEXBUFFERDESC);
+ vbDesc.dwCaps = D3DVBCAPS_SYSTEMMEMORY;
+ vbDesc.dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
+ // xyz+color so we can render them in showshadvol mode
+
+ // Create vertex buffer to hold shadow volumes verts
+ if (shad->VB == NULL) {
+ // now form array of indices that will make the tris
+ ZeroMemory(shad, sizeof(SHADOW));
+ shad->num_objverts = nverts;
+ vbDesc.dwNumVertices = nverts * 2; // *2 to hold top of shadvol for infin light source
+
+ if (FAILED(hr = pD3D->CreateVertexBuffer(&vbDesc, &shad->VB, 0)))
+ return hr;
+
+ // alloc enough to hold largest-case shadvol (max # of verts in c-hull is nverts)
+ // (nverts+1)*2 for tri mesh to hold shadvol sides + nverts to hold tri-fan
+ shad->pwShadVolIndices = (WORD *)t3dCalloc(sizeof(WORD) * (nverts + 1) * 2);
+ }
+
+ // create VB_Proj vertex buffer as a target for the vertex-projection operation used to compute
+ // the silhouette
+ vbDesc.dwNumVertices = nverts;
+ vbDesc.dwFVF = D3DFVF_XYZRHW;
+ // even though RHW not used, must specify it or ProcessVerts will not consider this as a valid
+ // target to xform verts into
+
+ if (FAILED(hr = pD3D->CreateVertexBuffer(&vbDesc, &VB_Proj, NULL)))
+ return hr;
+
+ // must lock VB, then copy verts into its space.
+ COLORVERTEX *VBvertptr;
+
+ shad->VB->Lock(DDLOCK_NOSYSLOCK | DDLOCK_WRITEONLY | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
+ (VOID **) &VBvertptr, NULL);
+
+ // have to copy verts into VB memory. I reformat into COLORVERTEX to do this.
+ // could prevent reformat and do a straight memcpy if Find2DConvexHull used D3DVERTEX tho.
+ COLORVERTEX *cvptr = VBvertptr;
+ gVertex *d3dvptr = InVerts;
+
+ // reformat D3DVERTEX array to COLORVERTEX array
+ for (i = 0; i < nverts; i++) {
+ cvptr->p.x = d3dvptr->x;
+ cvptr->p.y = d3dvptr->y;
+ cvptr->p.z = d3dvptr->z;
+ cvptr->c = RGBA_MAKE(0xff, 0x0, 0x0, 0xff); // shadvol is semi-transparent black
+ cvptr++;
+ d3dvptr++;
+ }
+
+ shad->VB->Unlock();
+
+ // save cur matrices so we can use xform pipeln to project verts supafast
+ pd3dDevice->GetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld);
+ pd3dDevice->GetTransform(D3DTRANSFORMSTATE_VIEW, &matView);
+ pd3dDevice->GetTransform(D3DTRANSFORMSTATE_PROJECTION, &matProj);
+
+ SetIdentityMatrix(IDmat);
+
+ pd3dDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &IDmat);
+ pd3dDevice->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &IDmat);
+
+ // for view matrix, all we want is anything that projects the verts onto a plane
+ // perp to light direction. so any eyepoint is OK (try to make obj near origin though,
+ // so look at one of the verts). dont care what direction is view up vector (y).
+ rSetViewMatrix(lightm[0], lightm[1], lightm[2],
+ lightm[3], lightm[4], lightm[5],
+ lightm[6], lightm[7], lightm[8],
+ 0.0f, 0.0f, 0.0f);
+
+ // do the planar projection
+ VB_Proj->ProcessVertices(D3DVOP_TRANSFORM,
+ 0, // write new verts at idx 0
+ nverts,
+ shad->VB,
+ 0, // read src verts from idx 0
+ pd3dDevice,
+ 0x0); // no flags
+
+ pd3dDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld);
+ pd3dDevice->SetTransform(D3DTRANSFORMSTATE_VIEW, &matView);
+ pd3dDevice->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &matProj);
+
+ COLORVERTEX *pntptr;
+
+ VB_Proj->Lock(DDLOCK_NOSYSLOCK | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
+ (void **) &pntptr, NULL);
+
+ WORD *OutHullIdxs;
+ DWORD n_idxs;
+
+ Find2DConvexHull(nverts, pntptr, &n_idxs, &OutHullIdxs); // This is the function supplied with dx6
+
+ VB_Proj->Unlock();
+ VB_Proj->Release(); // just needed the indices of hull
+
+ shad->VB->Lock(DDLOCK_NOSYSLOCK | DDLOCK_WRITEONLY | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
+ (void **) &VBvertptr, NULL);
+
+ // make shadow volume by taking hull verts and project them along light dir far enough
+ // to be offscreen
+
+ // add verts to end of VB
+ for (i = 0; i < n_idxs; i++) {
+ VBvertptr[nverts + i].p.x = VBvertptr[OutHullIdxs[i]].p.x - (2000.0f * lightm[6]); // scale factor of 10 should be enough
+ VBvertptr[nverts + i].p.y = VBvertptr[OutHullIdxs[i]].p.y - (2000.0f * lightm[7]); // scale factor of 10 should be enough
+ VBvertptr[nverts + i].p.z = VBvertptr[OutHullIdxs[i]].p.z - (2000.0f * lightm[8]); // scale factor of 10 should be enough
+ VBvertptr[nverts + i].c = RGBA_MAKE(0x0, 0xff, 0x0, 0xff);
+ }
+
+ shad->totalverts = nverts + n_idxs;
+
+ // now form array of indices that will make the tris
+ // shad vol will have n_idxs square sides
+
+ shad->num_side_indices = (n_idxs + 1) * 2;
+
+ // if shadvol is not capped, shadow may be drawn in place where a backfacing cap is missing even
+ // though no geometry is there
+
+//f shad->num_cap_indices=n_idxs;
+ shad->num_cap_indices = 0;
+
+ WORD *idxptr;
+
+ idxptr = shad->pwShadVolSideIndices = shad->pwShadVolIndices;
+
+ // tris for all facets but final one
+ for (i = 0; i < n_idxs; i++) {
+ // outhullidx[i] is the index of the ith vertex of the n_idx convex hull verts
+ // nverts+i is the index of the projected vert corresponding to the OutHullIdx[i] vertex
+ *idxptr++ = OutHullIdxs[i];
+ *idxptr++ = (WORD)(nverts + i);
+ }
+ // add tris for final facet (i==n_idxs)
+ *idxptr++ = OutHullIdxs[0];
+ *idxptr++ = (WORD)(nverts + 0);
+
+//m shad->pwShadVolCapIndices=idxptr;
+
+ free(OutHullIdxs); // allocated by Find2DConvexHull
+ shad->VB->Unlock();
+#endif
+ return true;
+}
+
+/* -----------------25/08/1999 16.41-----------------
+ * makes a shadow box to avoid stenciled shadows over the object
+ * --------------------------------------------------*/
+bool rMakeShadowBox(SHADOWBOX *sb, float BoxX, float BoxY, float BoxZ, WORD intens) {
+ warning("Stubbed: rMakeShadowBox\n");
+#if 0
+ bool hr;
+ LPDIRECT3DDEVICE7 pd3dDevice = g_pd3dDevice;
+
+ // Get a ptr to the ID3D object to create materials and/or lights. Note:
+ // the Release() call just serves to decrease the ref count.
+ LPDIRECT3D7 pD3D;
+ pd3dDevice->GetDirect3D(&pD3D);
+ pD3D->Release();
+
+ D3DVERTEXBUFFERDESC vbDesc;
+ vbDesc.dwSize = sizeof(D3DVERTEXBUFFERDESC);
+ vbDesc.dwCaps = D3DVBCAPS_SYSTEMMEMORY;
+ vbDesc.dwFVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;
+ // xyz+color so we can render them in showshadvol mode
+
+ // Create vertex buffer to hold shadow volumes verts
+ if (sb->VB == NULL) {
+ sb->NumVerts = 16;
+ sb->NumIndices = 12 * 3;
+ vbDesc.dwNumVertices = sb->NumVerts;
+ if (FAILED(hr = pD3D->CreateVertexBuffer(&vbDesc, &sb->VB, 0)))
+ return hr;
+
+ // alloc enough to hold largest-case shadvol (max # of verts in c-hull is nverts)
+ // (nverts+1)*2 for tri mesh to hold shadvol sides + nverts to hold tri-fan
+ sb->pwIndices = (WORD *)t3dCalloc(sizeof(WORD) * sb->NumIndices);
+
+ WORD *curind = sb->pwIndices;
+ *curind++ = 0;
+ *curind++ = 1;
+ *curind++ = 2; // Base scura
+ *curind++ = 2;
+ *curind++ = 1;
+ *curind++ = 3;
+ *curind++ = 0;
+ *curind++ = 4;
+ *curind++ = 1; // Bordo sinistro scuro
+ *curind++ = 1;
+ *curind++ = 4;
+ *curind++ = 5;
+ *curind++ = 2;
+ *curind++ = 6;
+ *curind++ = 0; // Bordo destro scuro
+ *curind++ = 0;
+ *curind++ = 6;
+ *curind++ = 4;
+ *curind++ = 12;
+ *curind++ = 13;
+ *curind++ = 14; // Testa chiara
+ *curind++ = 14;
+ *curind++ = 13;
+ *curind++ = 15;
+ *curind++ = 11;
+ *curind++ = 15;
+ *curind++ = 9; // Bordo sinistro chiaro
+ *curind++ = 9;
+ *curind++ = 15;
+ *curind++ = 13;
+ *curind++ = 10;
+ *curind++ = 14;
+ *curind++ = 11; // Bordo destro chiaro
+ *curind++ = 11;
+ *curind++ = 14;
+ *curind++ = 15;
+ }
+ sb->NumShadowsList = 0;
+ sb->Intensity = intens;
+
+ // must lock VB, then copy verts into its space.
+ COLORVERTEX *VBvertptr;
+ sb->VB->Lock(DDLOCK_NOSYSLOCK | DDLOCK_WRITEONLY | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
+ (VOID **) &VBvertptr, NULL);
+
+ // have to copy verts into VB memory. I reformat into COLORVERTEX to do this.
+ // could prevent reformat and do a straight memcpy if Find2DConvexHull used D3DVERTEX tho.
+ COLORVERTEX *cvptr = VBvertptr;
+ D3DCOLOR cshadow = RGBA_MAKE(0x0, 0x0, 0x0, intens);
+ D3DCOLOR clight = RGBA_MAKE(0x0, 0x0, 0x0, 0);
+
+// 0: Base Piu' distante scuro
+ cvptr->p.x = BoxX;
+ cvptr->p.y = 5.0f;
+ cvptr->p.z = BoxZ;
+ cvptr->c = cshadow;
+ cvptr ++;
+// 1: Base Sinistra scuro
+ cvptr->p.x = -BoxZ;
+ cvptr->p.y = 5.0f;
+ cvptr->p.z = BoxX;
+ cvptr->c = cshadow;
+ cvptr ++;
+// 2: Base Destra scuro
+ cvptr->p.x = BoxZ;
+ cvptr->p.y = 5.0f;
+ cvptr->p.z = -BoxX;
+ cvptr->c = cshadow;
+ cvptr ++;
+// 3: Base Piu' vicino scuro
+ cvptr->p.x = -BoxX;
+ cvptr->p.y = 5.0f;
+ cvptr->p.z = -BoxZ;
+ cvptr->c = cshadow;
+ cvptr ++;
+// 4: Testa Piu' distante scura
+ cvptr->p.x = BoxX;
+ cvptr->p.y = BoxY;
+ cvptr->p.z = BoxZ;
+ cvptr->c = cshadow;
+ cvptr ++;
+// 5: Testa Sinistra scuro
+ cvptr->p.x = -BoxZ;
+ cvptr->p.y = BoxY;
+ cvptr->p.z = BoxX;
+ cvptr->c = cshadow;
+ cvptr ++;
+// 6: Testa Destra scuro
+ cvptr->p.x = BoxZ;
+ cvptr->p.y = BoxY;
+ cvptr->p.z = -BoxX;
+ cvptr->c = cshadow;
+ cvptr ++;
+// 7: Testa Piu' vicino scuro
+ cvptr->p.x = -BoxX;
+ cvptr->p.y = BoxY;
+ cvptr->p.z = -BoxZ;
+ cvptr->c = cshadow;
+ cvptr ++;
+// 8: Base Piu' distante chiaro
+ cvptr->p.x = BoxX;
+ cvptr->p.y = 5.0f;
+ cvptr->p.z = BoxZ;
+ cvptr->c = clight;
+ cvptr ++;
+// 9: Base Sinistra chiaro
+ cvptr->p.x = -BoxZ;
+ cvptr->p.y = 5.0f;
+ cvptr->p.z = BoxX;
+ cvptr->c = clight;
+ cvptr ++;
+// 10: Base Destra chiaro
+ cvptr->p.x = BoxZ;
+ cvptr->p.y = 5.0f;
+ cvptr->p.z = -BoxX;
+ cvptr->c = clight;
+ cvptr ++;
+// 11: Base Piu' vicino chiaro
+ cvptr->p.x = -BoxX;
+ cvptr->p.y = 5.0f;
+ cvptr->p.z = -BoxZ;
+ cvptr->c = clight;
+ cvptr ++;
+// 12: Testa Piu' distante chiaro
+ cvptr->p.x = BoxX;
+ cvptr->p.y = BoxY;
+ cvptr->p.z = BoxZ;
+ cvptr->c = clight;
+ cvptr ++;
+// 13: Testa Sinistra chiaro
+ cvptr->p.x = -BoxZ;
+ cvptr->p.y = BoxY;
+ cvptr->p.z = BoxX;
+ cvptr->c = clight;
+ cvptr ++;
+// 14: Testa Destra chiaro
+ cvptr->p.x = BoxZ;
+ cvptr->p.y = BoxY;
+ cvptr->p.z = -BoxX;
+ cvptr->c = clight;
+ cvptr ++;
+// 15: Testa Piu' vicino chiaro
+ cvptr->p.x = -BoxX;
+ cvptr->p.y = BoxY;
+ cvptr->p.z = -BoxZ;
+ cvptr->c = clight;
+ cvptr ++;
+
+ sb->VB->Unlock();
+
+ ShadowBoxesList[gNumShadowBoxesList++] = sb;
+#endif
+ return true;
+}
+
+/* -----------------25/08/1999 17.24-----------------
+ * renders a stenciled convex hull
+ * --------------------------------------------------*/
+bool RenderShadow(SHADOW *pShad,
+ void *lpVBuf) {
+ warning("TODO: Stubbed RenderShadow\n");
+#if 0
+ LPDIRECT3DDEVICE7 pd3dDevice = g_pd3dDevice;
+
+ pd3dDevice->SetTexture(0, NULL);
+
+ // Turn depth buffer off, and stencil buffer on
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILENABLE, TRUE);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, D3DSHADE_FLAT); // dont want to bother interpolating color
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW);
+
+ // Set up stencil compare fuction, reference value, and masks
+ // Stencil test passes if ((ref & mask) cmpfn (stencil & mask)) is true
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILFUNC, D3DCMP_ALWAYS);
+
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILZFAIL, D3DSTENCILOP_KEEP);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILFAIL, D3DSTENCILOP_KEEP);
+
+ if (g_bUseOneBitStencil) {
+ // If ztest passes, write !(g_bInvertStencilBufferSense) into stencil buffer
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILREF, 0x1);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILMASK, 0x1);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILWRITEMASK, 0x1);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILPASS, D3DSTENCILOP_REPLACE);
+ } else {
+ // If ztest passes, inc/decrement stencil buffer value
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILREF, 0x1);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILMASK, 0xffffffff);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILWRITEMASK, 0xffffffff);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILPASS, g_StencIncOp);
+ }
+
+ // Since destcolor=SRCBLEND * SRC_COLOR + DESTBLEND * DEST_COLOR,
+ // this should result in the tri color being completely dropped
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO);
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
+
+ // draw front-side of shadow volume in stencil/z only
+ pd3dDevice->DrawIndexedPrimitiveVB(D3DPT_TRIANGLESTRIP, lpVBuf, 0, pShad->totalverts,
+ pShad->pwShadVolSideIndices,
+ pShad->num_side_indices, 0x0);
+
+ // Now reverse cull order so back sides of shadow volume are written.
+ if (g_bUseOneBitStencil) {
+ // write 0's/1's into stencil buffer to erase pixels beyond back of shadow
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILREF, 0x0);
+ } else {
+ // increment stencil buffer value
+ pd3dDevice->SetRenderState(D3DRENDERSTATE_STENCILPASS, g_StencDecOp);
Commit: 7a8b38d118684d7cb8ac8cc282f9a1d738f7d248
https://github.com/scummvm/scummvm/commit/7a8b38d118684d7cb8ac8cc282f9a1d738f7d248
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix the OpenGL includes to avoid direct includes
Changed paths:
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_renderer.cpp
engines/watchmaker/render.cpp
engines/watchmaker/renderer.cpp
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 47a078c8af9..5ed7772824f 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -21,6 +21,8 @@
#include "watchmaker/game.h"
+#if defined(USE_OPENGL_GAME)
+
#include "watchmaker/3d/render/opengl_2d.h"
#include "watchmaker/utils.h"
#include "watchmaker/render.h"
@@ -31,9 +33,7 @@
#include "watchmaker/renderer.h"
#include "watchmaker/sdl_wrapper.h"
-#ifdef USE_OPENGL_GAME
#include "graphics/opengl/system_headers.h"
-#endif
namespace Watchmaker {
@@ -114,8 +114,6 @@ void rResetExtends(void) {
gBlitterExtends.bottom = -99999999;
}
-#ifdef USE_OPENGL_GAME
-
//************************************************************************************************************************
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
int sposx, int sposy, int sdimx, int sdimy) {
@@ -261,6 +259,8 @@ int createTextureFromSurface2(Surface &surface, int texFormat) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ error("TODO: compressed textures");
+#if 0
bool compressed = false;
switch (texFormat) {
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
@@ -281,7 +281,7 @@ int createTextureFromSurface2(Surface &surface, int texFormat) {
} else {
glTexImage2D(GL_TEXTURE_2D, 0, texFormat, surface.width, surface.height / 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface.data);
}
-
+#endif
return texId;
}
@@ -343,6 +343,6 @@ void rSetLoaderFlags(unsigned int NewLoaderFlags) {
CurLoaderFlags = NewLoaderFlags;
}
-#endif // USE_OPENGL_GAME
+} // End of namespace Watchmaker
-} // End of namespace Watchmaker
\ No newline at end of file
+#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/3d/render/opengl_renderer.cpp b/engines/watchmaker/3d/render/opengl_renderer.cpp
index b68bb8f8d84..e01bab07de1 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.cpp
+++ b/engines/watchmaker/3d/render/opengl_renderer.cpp
@@ -22,8 +22,10 @@
#include "watchmaker/3d/render/opengl_renderer.h"
#include "watchmaker/t3d.h"
-#ifdef USE_OPENGL_GAME
+#if defined(USE_OPENGL_GAME)
+
#include "graphics/opengl/system_headers.h"
+#include "math/glmath.h"
#include "math/glmath.h"
diff --git a/engines/watchmaker/render.cpp b/engines/watchmaker/render.cpp
index 8a5ee37bba4..505a697ab94 100644
--- a/engines/watchmaker/render.cpp
+++ b/engines/watchmaker/render.cpp
@@ -19,7 +19,6 @@
*
*/
-#include <SDL_opengl.h>
#include "watchmaker/sdl_wrapper.h"
#include "watchmaker/render.h"
#include "watchmaker/utils.h"
@@ -30,18 +29,10 @@
#include "watchmaker/rect.h"
#include "watchmaker/renderer.h"
-#ifdef __APPLE__
-#define GL_SILENCE_DEPRECATION
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#include <OpenGL/glext.h>
-//#include <unistd.h>
-
-#else
-#include <GL/gl.h>
-#include <GL/glu.h>
-#include <GL/glext.h>
-#endif
+#if defined(USE_OPENGL_GAME)
+
+#include "graphics/opengl/system_headers.h"
+#include "math/glmath.h"
#define MAXTEXTURES 2000
#define MAX_BITMAP_LIST 1024
@@ -157,7 +148,8 @@ bool rSetProjectionMatrix(float width, float height, float fAspect,
float fNearPlane, float fFarPlane) {
// Not sure if fAspect is Y here though
glMatrixMode(GL_PROJECTION);
- gluPerspective(fAspect, width / height, fNearPlane, fFarPlane);
+ auto perspectiveMatrix = Math::makePerspectiveMatrix(fAspect, width / height, fNearPlane, fFarPlane);
+ glLoadMatrixf(perspectiveMatrix.getData());
glMatrixMode(GL_MODELVIEW);
return false;
@@ -335,3 +327,5 @@ bool gUpdateMovie(gMaterial *mat) {
}
} // End of namespace Watchmaker
+
+#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/renderer.cpp b/engines/watchmaker/renderer.cpp
index d6592fe2249..bc26a81952a 100644
--- a/engines/watchmaker/renderer.cpp
+++ b/engines/watchmaker/renderer.cpp
@@ -19,28 +19,19 @@
*
*/
-#include <SDL_opengl.h>
-#include "SDL.h"
-
-#ifdef __APPLE__
-#define GL_SILENCE_DEPRECATION
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#include <OpenGL/glext.h>
-#include <unistd.h>
-
-#else
-#include <GL/gl.h>
-#include <GL/glu.h>
-#include <GL/glext.h>
-#endif
+#include "common/scummsys.h"
+
+#if defined(USE_OPENGL_GAME)
+
+#include "graphics/opengl/system_headers.h"
-#include "watchmaker/renderer.h"
-#include "watchmaker/render.h"
-#include "watchmaker/windows_hacks.h"
#include "watchmaker/globvar.h"
#include "watchmaker/ll/ll_system.h"
+#include "math/glmath.h"
#include "watchmaker/rect.h"
+#include "watchmaker/renderer.h"
+#include "watchmaker/render.h"
+#include "watchmaker/windows_hacks.h"
namespace Watchmaker {
@@ -69,7 +60,8 @@ void Renderer::initGL() {
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- gluPerspective(60.0, ratio, 1.0, 1024.0);
+ auto perspectiveMatrix = Math::makePerspectiveMatrix(60.0, ratio, 1.0, 1024.0);;
+ glLoadMatrixf(perspectiveMatrix.getData());
}
void Renderer::setVirtualScreen(unsigned int dimX, unsigned int dimY) {
@@ -144,3 +136,5 @@ int Renderer::rInvFitY(int y) {
}
} // End of namespace Watchmaker
+
+#endif // USE_OPENGL_GAME
Commit: 93511e6ef1bf4a6b3a1ea7e2bad64be809bf0f67
https://github.com/scummvm/scummvm/commit/93511e6ef1bf4a6b3a1ea7e2bad64be809bf0f67
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Call the old Watchmaker main() from run()
Changed paths:
engines/watchmaker/watchmaker.cpp
diff --git a/engines/watchmaker/watchmaker.cpp b/engines/watchmaker/watchmaker.cpp
index 89c476180a6..583d4c60166 100644
--- a/engines/watchmaker/watchmaker.cpp
+++ b/engines/watchmaker/watchmaker.cpp
@@ -32,8 +32,11 @@ WatchmakerGame::~WatchmakerGame() {
//_console is deleted by Engine
}
+// TODO: We should be moving most of the WMakerMain() stuff here:
+int WMakerMain();
+
Common::Error WatchmakerGame::run() {
- error("TODO: Implement engine");
+ WMakerMain();
return Common::kNoError;
}
Commit: 47ee7caf3f4c50498c682b219a52a05f97b64e58
https://github.com/scummvm/scummvm/commit/47ee7caf3f4c50498c682b219a52a05f97b64e58
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Drop ./ prefix before opening files.
Changed paths:
engines/watchmaker/ll/ll_system.cpp
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index 7952c405853..6414c94782e 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -175,13 +175,19 @@ bool t3dGetFileDate(uint32 *date, uint32 *time, const char *name) {
}
Common::SeekableReadStream *openFile(const Common::String &filename) {
+ Common::String adjustedPath;
+ if (filename.hasPrefix("./")) {
+ adjustedPath = filename.substr(2, filename.size());
+ } else {
+ adjustedPath = filename;
+ }
Common::SeekableReadStream *file = nullptr;
// Try directly from SearchMan first
Common::ArchiveMemberList files;
- SearchMan.listMatchingMembers(files, filename);
+ SearchMan.listMatchingMembers(files, adjustedPath);
for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) {
- if ((*it)->getName().equalsIgnoreCase(lastPathComponent(filename,'/'))) {
+ if ((*it)->getName().equalsIgnoreCase(lastPathComponent(adjustedPath,'/'))) {
file = (*it)->createReadStream();
break;
}
Commit: b223d51ea93f4be8fefcf06064f0df11b56cc765
https://github.com/scummvm/scummvm/commit/b223d51ea93f4be8fefcf06064f0df11b56cc765
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix LoadExternalText
Changed paths:
engines/watchmaker/init/nl_init.cpp
diff --git a/engines/watchmaker/init/nl_init.cpp b/engines/watchmaker/init/nl_init.cpp
index 4f32b9fcb76..53e18bbe50f 100644
--- a/engines/watchmaker/init/nl_init.cpp
+++ b/engines/watchmaker/init/nl_init.cpp
@@ -24,11 +24,11 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
+#include "watchmaker/init/nl_parse.h"
+#include "watchmaker/extraLS.h"
+#include "watchmaker/globvar.h"
#include "watchmaker/ll/ll_system.h"
#include "watchmaker/types.h"
-#include "watchmaker/globvar.h"
-#include "watchmaker/extraLS.h"
-#include "watchmaker/init/nl_parse.h"
namespace Watchmaker {
@@ -46,21 +46,19 @@ uint16 Credits_numNames = 0;
int LoadExternalText(Init *init, char *et) {
char line[1000];
int len, num;
- error("TODO: LoadExternalText");
-#if 0
- FILE *ff;
if (!et) return false;
if (et[0] == '\0') return true;
- if ((ff = fopen(et, "rt")) == nullptr)
+ auto stream = openFile(et);
+ if (!stream)
return false;
CurText = TextBucket;
memset(TextBucket, 0, TEXT_BUCKET_SIZE);
SentenceNum = SysSentNum = TooltipSentNum = ObjNameNum = ExtraLSNum = 1;
- while ((fgets(line, 1000, ff)) != nullptr) {
+ while (stream->readLine(line, 1000) != nullptr) {
if ((line[0] == '/') && (line[1] == '/')) continue;
if ((len = strlen(line)) > 260)
@@ -119,8 +117,8 @@ int LoadExternalText(Init *init, char *et) {
}
}
- fclose(ff);
-#endif
+ delete stream;
+
return true;
}
Commit: f163edc585f7bed23f63c8081cdc888df56e7f41
https://github.com/scummvm/scummvm/commit/f163edc585f7bed23f63c8081cdc888df56e7f41
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Make openFile return a SharedPtr
Changed paths:
engines/watchmaker/init/nl_init.cpp
engines/watchmaker/ll/ll_system.cpp
engines/watchmaker/ll/ll_system.h
engines/watchmaker/work_dirs.cpp
diff --git a/engines/watchmaker/init/nl_init.cpp b/engines/watchmaker/init/nl_init.cpp
index 53e18bbe50f..126f2289d18 100644
--- a/engines/watchmaker/init/nl_init.cpp
+++ b/engines/watchmaker/init/nl_init.cpp
@@ -117,8 +117,6 @@ int LoadExternalText(Init *init, char *et) {
}
}
- delete stream;
-
return true;
}
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index 6414c94782e..a3969b83f30 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -174,7 +174,7 @@ bool t3dGetFileDate(uint32 *date, uint32 *time, const char *name) {
return false;
}
-Common::SeekableReadStream *openFile(const Common::String &filename) {
+Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename) {
Common::String adjustedPath;
if (filename.hasPrefix("./")) {
adjustedPath = filename.substr(2, filename.size());
@@ -192,7 +192,7 @@ Common::SeekableReadStream *openFile(const Common::String &filename) {
break;
}
}
- return file;
+ return Common::SharedPtr<Common::SeekableReadStream>(file);
}
} // End of namespace Watchmaker
\ No newline at end of file
diff --git a/engines/watchmaker/ll/ll_system.h b/engines/watchmaker/ll/ll_system.h
index 907d87523a9..f87a0dc2249 100644
--- a/engines/watchmaker/ll/ll_system.h
+++ b/engines/watchmaker/ll/ll_system.h
@@ -24,6 +24,7 @@
#include "watchmaker/types.h"
#include "common/stream.h"
+#include "common/ptr.h"
namespace Watchmaker {
@@ -58,7 +59,7 @@ void t3dForceNOFastFile(char valore);
int t3dAccessFile(char *name);
bool t3dGetFileDate(uint32 *date, uint32 *time, const char *name);
Common::SeekableReadStream *resolveFile(const char *path);
-Common::SeekableReadStream *openFile(const Common::String &filename);
+Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename);
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/work_dirs.cpp b/engines/watchmaker/work_dirs.cpp
index 5f024828823..48062e31e50 100644
--- a/engines/watchmaker/work_dirs.cpp
+++ b/engines/watchmaker/work_dirs.cpp
@@ -70,7 +70,7 @@ static bool readKeyValuePair(Common::SeekableReadStream &stream, Common::String
WorkDirs::WorkDirs(const Common::String &filename) {
_fastFile = Common::SharedPtr<FastFile>(new FastFile(WmGameDataPak_FilePath));
- auto *fcfg = openFile(filename.c_str());
+ auto fcfg = openFile(filename.c_str());
if (fcfg) {
Common::String key, value;
Commit: 36a57b7e5724939381a7d029372800b1aa298b39
https://github.com/scummvm/scummvm/commit/36a57b7e5724939381a7d029372800b1aa298b39
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix mistake in WorkDirs::join()
Changed paths:
engines/watchmaker/work_dirs.h
diff --git a/engines/watchmaker/work_dirs.h b/engines/watchmaker/work_dirs.h
index 34dc9f312bf..22c536e08a2 100644
--- a/engines/watchmaker/work_dirs.h
+++ b/engines/watchmaker/work_dirs.h
@@ -54,7 +54,7 @@ public:
Common::String result = first + second;
// Hacky, and assumes the extensions are the same length.
- return result.substr(0, extReplacement.size()) + extReplacement;;
+ return result.substr(0, result.size() - extReplacement.size()) + extReplacement;;
}
Common::String unwindowsify(const Common::String &str) const {
Commit: 35ee83f68d3a62e12f0a51611e6e0f1768516272
https://github.com/scummvm/scummvm/commit/35ee83f68d3a62e12f0a51611e6e0f1768516272
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix substream support for handling fastfiles.
(As a temporary solution until we get a Common::Archive subclass
implemented)
Changed paths:
engines/watchmaker/ll/ll_ffile.cpp
engines/watchmaker/ll/ll_system.cpp
engines/watchmaker/ll/ll_system.h
diff --git a/engines/watchmaker/ll/ll_ffile.cpp b/engines/watchmaker/ll/ll_ffile.cpp
index 8669c36be1b..810aa52b423 100644
--- a/engines/watchmaker/ll/ll_ffile.cpp
+++ b/engines/watchmaker/ll/ll_ffile.cpp
@@ -20,8 +20,8 @@
*/
#include "watchmaker/ll/ll_ffile.h"
-#include "ll_system.h"
-#include <cstring>
+#include "common/substream.h"
+#include "watchmaker/ll/ll_system.h"
namespace Watchmaker {
@@ -79,14 +79,8 @@ Common::SharedPtr<Common::SeekableReadStream> FastFile::resolve(const char *file
} else {
size = _files[index + 1].offset - entry.offset;
}
- auto stream = openFile(_path);
+ auto stream = openFile(_path, entry.offset, size);
assert(stream);
- stream->seek(SEEK_SET, entry.offset);
- error("TODO: Substream-logic");
-#if 0
- stream->setSize(size);
- stream->setStart(entry.offset);
-#endif
return Common::SharedPtr<Common::SeekableReadStream>(stream);
}
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index a3969b83f30..2e5fc897957 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -30,6 +30,7 @@
#define MALLOC_SIZE _msize
#endif
#endif
+#include "common/substream.h"
#include "common/archive.h"
#include "watchmaker/ll/ll_system.h"
#include "watchmaker/types.h"
@@ -174,7 +175,7 @@ bool t3dGetFileDate(uint32 *date, uint32 *time, const char *name) {
return false;
}
-Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename) {
+Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename, int offset, int size) {
Common::String adjustedPath;
if (filename.hasPrefix("./")) {
adjustedPath = filename.substr(2, filename.size());
@@ -192,6 +193,15 @@ Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &fil
break;
}
}
+
+ if (offset != 0 || size != -1) {
+ if (size == -1) {
+ size = file->size();
+ }
+ assert(size <= file->size());
+ assert(offset >= 0 && offset <= file->size());
+ file = new Common::SeekableSubReadStream(file, offset, offset + size, DisposeAfterUse::YES);
+ }
return Common::SharedPtr<Common::SeekableReadStream>(file);
}
diff --git a/engines/watchmaker/ll/ll_system.h b/engines/watchmaker/ll/ll_system.h
index f87a0dc2249..01ee7577dfc 100644
--- a/engines/watchmaker/ll/ll_system.h
+++ b/engines/watchmaker/ll/ll_system.h
@@ -59,7 +59,7 @@ void t3dForceNOFastFile(char valore);
int t3dAccessFile(char *name);
bool t3dGetFileDate(uint32 *date, uint32 *time, const char *name);
Common::SeekableReadStream *resolveFile(const char *path);
-Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename);
+Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename, int offset = 0, int size = -1);
} // End of namespace Watchmaker
Commit: d52d67482da49a0945ea37dbcf7610dfb6394b2f
https://github.com/scummvm/scummvm/commit/d52d67482da49a0945ea37dbcf7610dfb6394b2f
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Drop \n from calls to warning(
Changed paths:
engines/watchmaker/3d/animation.cpp
engines/watchmaker/3d/geometry.cpp
engines/watchmaker/3d/light.cpp
engines/watchmaker/3d/loader.cpp
engines/watchmaker/3d/material.cpp
engines/watchmaker/3d/math/Matrix4x4.h
engines/watchmaker/3d/math/llmath.cpp
engines/watchmaker/3d/movie.h
engines/watchmaker/3d/render/opengl.cpp
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/render/opengl_renderer.cpp
engines/watchmaker/3d/render/opengl_renderer.h
engines/watchmaker/3d/render/render.cpp
engines/watchmaker/3d/render/shadows.cpp
engines/watchmaker/3d/t3d_body.cpp
engines/watchmaker/3d/t3d_mesh.cpp
engines/watchmaker/classes/do_keyboard.cpp
engines/watchmaker/classes/do_player.cpp
engines/watchmaker/classes/do_sound.cpp
engines/watchmaker/classes/do_system.cpp
engines/watchmaker/game.cpp
engines/watchmaker/game_options.h
engines/watchmaker/globvar.h
engines/watchmaker/ll/ll_mouse.cpp
engines/watchmaker/ll/ll_regen.cpp
engines/watchmaker/ll/ll_sound.cpp
engines/watchmaker/ll/ll_system.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/main.cpp
engines/watchmaker/render.cpp
engines/watchmaker/renderer.cpp
engines/watchmaker/saveload.cpp
engines/watchmaker/schedule.cpp
engines/watchmaker/sdl_wrapper.cpp
engines/watchmaker/t2d/t2d.cpp
engines/watchmaker/tga_util.cpp
engines/watchmaker/walk/ball.cpp
engines/watchmaker/windows_hacks.cpp
engines/watchmaker/work_dirs.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index a4122b9cf2b..92ab745bfea 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -211,7 +211,7 @@ int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag) {
{
auto stream = game.resolveFile(name);
if (!stream) {
- warning("File %s not found\n", name);
+ warning("File %s not found", name);
return -1;
}
@@ -569,7 +569,7 @@ t3dBODY *LoadShadowMeshes(WGame &game, const char *pname, t3dBODY *Body) {
* t3dLoadCharacter
* --------------------------------------------------*/
t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, t3dCHARACTER *b, uint16 num) {
- warning("LoadCharacter(%s)\n", pname);
+ warning("LoadCharacter(%s)", pname);
uint8 Mirror = 1;
uint16 n = 0, f, i;
t3dV3F tmp;
@@ -585,7 +585,7 @@ t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, t3dCHARACTER *b,
if (num >= 2) b->Flags |= T3D_CHARACTER_BNDHIDE;
//Try to load animation
if (t3dLoadAnimation(game, pname, b->Mesh, T3D_MESH_DEFAULTANIM) == -1) {
- warning("t3dLoadCharacter: Error loading %s\n", pname);
+ warning("t3dLoadCharacter: Error loading %s", pname);
return nullptr;
}
FixupAnim(b->Mesh, 0, "");
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index 370290e7e16..7279202ed9e 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -419,7 +419,7 @@ void t3dReleaseBody(t3dBODY *b) {
* t3dReleaseCharacter
* --------------------------------------------------*/
void t3dReleaseCharacter(t3dCHARACTER *b) {
- warning("STUBBED: t3dReleaseCharacter\n");
+ warning("STUBBED: t3dReleaseCharacter");
#if 0
t3dU32 i, j;
@@ -1325,7 +1325,7 @@ t3dF32 t3dCheckWithFloor(void) {
* t3dProcessMirror
* --------------------------------------------------*/
void t3dProcessMirror(t3dMESH *mesh, t3dCAMERA *cam) {
- warning("STUBBED: t3dProcessMirror\n");
+ warning("STUBBED: t3dProcessMirror");
#if 0
// t3dBODY *NewBody=NULL;
t3dV3F appo, c0;
@@ -1855,7 +1855,7 @@ void t3dAddTextureBufferShadow(t3dCHARACTER *c, uint32 CurShadowBox, t3dLIGHT *l
gVertex *gv, *pc;
t3dV3F v, tmp, MinSco, MaxSco, Aspect, BBox[8], dir;
- warning("TODO: t3dAddTextureBufferShadow\n");
+ warning("TODO: t3dAddTextureBufferShadow");
return;
#if 0
if (!cm || !cm->VertexBuffer)
@@ -2449,11 +2449,11 @@ void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
if (*nf + 3 >= target->size()) {
// TODO: Why is this hack necessary?
- warning("NumFaces: %d, Size: %d\n", *nf, target->size());
+ warning("NumFaces: %d, Size: %d", *nf, target->size());
/* static bool warned = false;
if (!warned) {
warned = true;*/
- warning("Dropping face\n");
+ warning("Dropping face");
// }
target->resize(*nf + 4);
//continue;
@@ -2647,7 +2647,7 @@ void t3dAddParticle(gMaterial *Material, t3dV3F *Source, t3dF32 size, t3dV3F Col
t3dV3F v0, v1, v2, v3;
uint32 rr, gg, bl, i;
- warning("TODO: t3dAddParticle\n");
+ warning("TODO: t3dAddParticle");
return;
#if 0
uvbc = rGetUserVertexBufferCounter();
@@ -2900,7 +2900,7 @@ void t3dCheckMaterialVB(MaterialPtr mat) {
if (i >= mat->NumAllocatedMesh)
return ;
- //warning("TODO: Implement t3dCheckMaterialVB\n");
+ //warning("TODO: Implement t3dCheckMaterialVB");
// gv = rLockVertexPtr(mat->VB, DDLOCK_WRITEONLY | DDLOCK_NOSYSLOCK);
mat->VBO->_buffer.clear();
for (int i = 0; i < mat->NumAllocatedVerts; i++) {
@@ -3022,7 +3022,7 @@ void t3dAddLensFlare(gMaterial *Material, t3dV3F *Source, t3dF32 size, t3dF32 pe
t3dV3F v0, v1, v2, v3;
int32 rr, gg, bb;
- warning("TODO: t3dAddLensFlare\n");
+ warning("TODO: t3dAddLensFlare");
return;
#if 0
uvbc = rGetUserVertexBufferCounter();
diff --git a/engines/watchmaker/3d/light.cpp b/engines/watchmaker/3d/light.cpp
index 69ac842355d..f457137f6a5 100644
--- a/engines/watchmaker/3d/light.cpp
+++ b/engines/watchmaker/3d/light.cpp
@@ -186,7 +186,7 @@ void LoadVolumetricMap(WorkDirs &workDirs, const char *pname, t3dBODY *b) {
* t3dLoadOutdoorLights
* --------------------------------------------------*/
void t3dLoadOutdoorLights(const char *pname, t3dBODY *b, int32 ora) {
- warning("STUBBED, t3dLoadOutdoorLights\n");
+ warning("STUBBED, t3dLoadOutdoorLights");
#if 0
t3dU32 i, j, k;
t3dMESH *m;
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index b49fb8eed9e..bc39229367b 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -133,31 +133,31 @@ t3dCAMERAPATH::t3dCAMERAPATH(Common::SeekableReadStream &stream) {
}
}
void decodeLoaderFlags(uint32 flags) {
- warning("%d: T3D_GENERATESHADOWMAPS\n", flags & T3D_GENERATESHADOWMAPS);
- warning("%d: T3D_NOLIGHTMAPS\n", flags & T3D_NOLIGHTMAPS);
- warning("%d: T3D_NORECURSION\n", flags & T3D_NORECURSION);
- warning("%d: T3D_HALFTEXTURESIZE\n", flags & T3D_HALFTEXTURESIZE);
- warning("%d: T3D_FULLSCREEN\n", flags & T3D_FULLSCREEN);
- warning("%d: T3D_FASTRENDERING\n", flags & T3D_FASTRENDERING);
- warning("%d: T3D_OUTDOORLIGHTS\n", flags & T3D_OUTDOORLIGHTS);
- warning("%d: T3D_NOVOLUMETRICLIGHTS\n", flags & T3D_NOVOLUMETRICLIGHTS);
- warning("%d: T3D_NOBOUNDS\n", flags & T3D_NOBOUNDS);
- warning("%d: T3D_NOCAMERAS\n", flags & T3D_NOCAMERAS);
- warning("%d: T3D_NONEXCLUSIVEMOUSE\n", flags & T3D_NONEXCLUSIVEMOUSE);
- warning("%d: T3D_RECURSIONLEVEL1\n", flags & T3D_RECURSIONLEVEL1);
- warning("%d: T3D_SKY\n", flags & T3D_SKY);
- warning("%d: T3D_PRELOAD_RXT\n", flags & T3D_PRELOAD_RXT);
- warning("%d: T3D_STATIC_SET0\n", flags & T3D_STATIC_SET0);
- warning("%d: T3D_STATIC_SET1\n", flags & T3D_STATIC_SET1);
- warning("%d: T3D_NOSHADOWS\n", flags & T3D_NOSHADOWS);
- warning("%d: T3D_NOICONS\n", flags & T3D_NOICONS);
- warning("%d: T3D_NOSOUND\n", flags & T3D_NOSOUND);
- warning("%d: T3D_PRELOADBASE\n", flags & T3D_PRELOADBASE);
- warning("%d: T3D_NOMUSIC\n", flags & T3D_NOMUSIC);
- warning("%d: T3D_DEBUGMODE\n", flags & T3D_DEBUGMODE);
- warning("%d: T3D_FASTFILE\n", flags & T3D_FASTFILE);
- warning("%d: T3D_HIPOLYPLAYERS\n", flags & T3D_HIPOLYPLAYERS);
- warning("%d: T3D_HIPOLYCHARACTERS\n", flags & T3D_HIPOLYCHARACTERS);
+ warning("%d: T3D_GENERATESHADOWMAPS", flags & T3D_GENERATESHADOWMAPS);
+ warning("%d: T3D_NOLIGHTMAPS", flags & T3D_NOLIGHTMAPS);
+ warning("%d: T3D_NORECURSION", flags & T3D_NORECURSION);
+ warning("%d: T3D_HALFTEXTURESIZE", flags & T3D_HALFTEXTURESIZE);
+ warning("%d: T3D_FULLSCREEN", flags & T3D_FULLSCREEN);
+ warning("%d: T3D_FASTRENDERING", flags & T3D_FASTRENDERING);
+ warning("%d: T3D_OUTDOORLIGHTS", flags & T3D_OUTDOORLIGHTS);
+ warning("%d: T3D_NOVOLUMETRICLIGHTS", flags & T3D_NOVOLUMETRICLIGHTS);
+ warning("%d: T3D_NOBOUNDS", flags & T3D_NOBOUNDS);
+ warning("%d: T3D_NOCAMERAS", flags & T3D_NOCAMERAS);
+ warning("%d: T3D_NONEXCLUSIVEMOUSE", flags & T3D_NONEXCLUSIVEMOUSE);
+ warning("%d: T3D_RECURSIONLEVEL1", flags & T3D_RECURSIONLEVEL1);
+ warning("%d: T3D_SKY", flags & T3D_SKY);
+ warning("%d: T3D_PRELOAD_RXT", flags & T3D_PRELOAD_RXT);
+ warning("%d: T3D_STATIC_SET0", flags & T3D_STATIC_SET0);
+ warning("%d: T3D_STATIC_SET1", flags & T3D_STATIC_SET1);
+ warning("%d: T3D_NOSHADOWS", flags & T3D_NOSHADOWS);
+ warning("%d: T3D_NOICONS", flags & T3D_NOICONS);
+ warning("%d: T3D_NOSOUND", flags & T3D_NOSOUND);
+ warning("%d: T3D_PRELOADBASE", flags & T3D_PRELOADBASE);
+ warning("%d: T3D_NOMUSIC", flags & T3D_NOMUSIC);
+ warning("%d: T3D_DEBUGMODE", flags & T3D_DEBUGMODE);
+ warning("%d: T3D_FASTFILE", flags & T3D_FASTFILE);
+ warning("%d: T3D_HIPOLYPLAYERS", flags & T3D_HIPOLYPLAYERS);
+ warning("%d: T3D_HIPOLYCHARACTERS", flags & T3D_HIPOLYCHARACTERS);
}
/* -----------------10/06/99 16.04-------------------
@@ -190,7 +190,7 @@ Common::String constructPath(const Common::String &prefix, const Common::String
* t3dLoadSingleRoom
* --------------------------------------------------*/
t3dBODY *t3dLoadSingleRoom(WGame &game, const Common::String &_pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags) {
- //warning("t3dLoadSingleRoom(workDirs, %s, b, %d, %d)\n", _pname, *NumBody, LoaderFlags);
+ //warning("t3dLoadSingleRoom(workDirs, %s, b, %d, %d)", _pname, *NumBody, LoaderFlags);
//decodeLoaderFlags(LoaderFlags);
Common::String pname(_pname);
@@ -209,10 +209,10 @@ t3dBODY *t3dLoadSingleRoom(WGame &game, const Common::String &_pname, t3dBODY *b
auto name = constructPath(workdirs._t3dDir, pname);
- //warning("t3dLoadSingleRoom opening(%s)\n", name.c_str());
+ //warning("t3dLoadSingleRoom opening(%s)", name.c_str());
auto stream = openFile(name);
if (!(stream)) { // Apre file
- warning("t3dLoadSingleRoom: Failed to open(%s)\n", name.c_str());
+ warning("t3dLoadSingleRoom: Failed to open(%s)", name.c_str());
return nullptr;
}
@@ -222,7 +222,7 @@ t3dBODY *t3dLoadSingleRoom(WGame &game, const Common::String &_pname, t3dBODY *b
} else
b = (t3dBODY *)t3dRealloc((uint32 *)b, sizeof(t3dBODY) * (++(*NumBody))); // Altrimenti, ridimensiona
- //warning("Loading %s ...\n", name.c_str());
+ //warning("Loading %s ...", name.c_str());
*b = t3dBODY(); // Azzera Body
uint16 fileVersion = stream->readByte();
@@ -254,7 +254,7 @@ t3dBODY *t3dLoadSingleRoom(WGame &game, const Common::String &_pname, t3dBODY *b
* t3dLoadRoom
* --------------------------------------------------*/
t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags) {
- warning("t3dLoadRoom(%s, b, %d, %d)\n", pname.c_str(), *NumBody, LoaderFlags);
+ warning("t3dLoadRoom(%s, b, %d, %d)", pname.c_str(), *NumBody, LoaderFlags);
struct _t3dLOADLIST *l;
t3dBODY *r, *rez;
t3dBODY *body;
@@ -291,7 +291,7 @@ t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, uint1
t3dCalcRejectedMeshFromPortal(LoadedFiles[i].b);
}
- warning("Room loaded\n");
+ warning("Room loaded");
return r;
}
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index 93a9d0c7d37..1284b965969 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -27,7 +27,7 @@ namespace Watchmaker {
MaterialPtr rAddMaterial(gMaterial &Material, const Common::String &TextName, int NumFaces, unsigned int LoaderFlags) {
// TODO: This is duplicated in opengl_3d.cpp
- warning("TODO: Fix rAddMaterial\n");
+ warning("TODO: Fix rAddMaterial");
#if 0
bool AlreadyLoaded=FALSE;
int len=strlen(TextName);
@@ -237,7 +237,7 @@ void rRemoveMaterial(Common::SharedPtr<gMaterial> &m) {
* Aggiunge un materiale alla MaterialList
* --------------------------------------------------*/
void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
- //warning("Stubbed: rAddToMaterialList\n");
+ //warning("Stubbed: rAddToMaterialList");
//D3DVERTEXBUFFERDESC VBDesc;
gMaterial *cm;
gBatchBlock *bb;
diff --git a/engines/watchmaker/3d/math/Matrix4x4.h b/engines/watchmaker/3d/math/Matrix4x4.h
index 9e03d900481..2a321ce262e 100644
--- a/engines/watchmaker/3d/math/Matrix4x4.h
+++ b/engines/watchmaker/3d/math/Matrix4x4.h
@@ -48,7 +48,7 @@ struct Matrix4x4 {
for (int col = 1; col <= 4; col++) {
warning("%f ", getValue(row, col));
}
- warning("\n");
+ warning("");
}
}
bool operator==(const Matrix4x4 &rhs) const {
diff --git a/engines/watchmaker/3d/math/llmath.cpp b/engines/watchmaker/3d/math/llmath.cpp
index 3e168594132..c5e915fb00f 100644
--- a/engines/watchmaker/3d/math/llmath.cpp
+++ b/engines/watchmaker/3d/math/llmath.cpp
@@ -26,7 +26,7 @@ namespace Watchmaker {
int32 t3dFloatToInt(t3dF32 nfloat) {
int32 sint = nfloat;
- // warning("STUBBED: t3dFloatToInt\n");
+ // warning("STUBBED: t3dFloatToInt");
/*
__asm
{
diff --git a/engines/watchmaker/3d/movie.h b/engines/watchmaker/3d/movie.h
index 378ca88112b..79f3ea36ee8 100644
--- a/engines/watchmaker/3d/movie.h
+++ b/engines/watchmaker/3d/movie.h
@@ -43,7 +43,7 @@ struct gMovie {
// TODO
~gMovie() {
- //warning("TODO: Clean up gMovie properly\n");
+ //warning("TODO: Clean up gMovie properly");
}
};
diff --git a/engines/watchmaker/3d/render/opengl.cpp b/engines/watchmaker/3d/render/opengl.cpp
index be91e9dc737..2ffd3a13fa9 100644
--- a/engines/watchmaker/3d/render/opengl.cpp
+++ b/engines/watchmaker/3d/render/opengl.cpp
@@ -29,7 +29,7 @@ bool rGetStencilBitDepth() {
#if 0
return gStencilBitDepth;
#endif
- //warning("TODO: Implement rGetStencilBitDepth\n");
+ //warning("TODO: Implement rGetStencilBitDepth");
return false;
}
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 5ed7772824f..7cf346cef74 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -118,7 +118,7 @@ void rResetExtends(void) {
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
int sposx, int sposy, int sdimx, int sdimy) {
// TODO: This currently gets called a bit too much.
- //warning("TODO: Stubbed rBlitter(%s, %d, %d, %d, %d, %d, %d, %d, %d)\n", gBitmapList[src].Name, dst, src, dposx, dposy, sposx, sposy, sdimx, sdimy);
+ //warning("TODO: Stubbed rBlitter(%s, %d, %d, %d, %d, %d, %d, %d, %d)", gBitmapList[src].Name, dst, src, dposx, dposy, sposx, sposy, sdimx, sdimy);
auto &bitmap = gBitmapList[src];
checkGlError("rBlitter Start");
@@ -273,7 +273,7 @@ int createTextureFromSurface2(Surface &surface, int texFormat) {
compressed = false;
break;
default:
- warning("Texture format not handled: %d\n", texFormat);
+ warning("Texture format not handled: %d", texFormat);
}
if (compressed) {
@@ -288,14 +288,14 @@ int createTextureFromSurface2(Surface &surface, int texFormat) {
int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
WorkDirs &workDirs = game.workDirs;
if (flags & rTEXTURESURFACE) {
- warning("TODO: support texture surface loading\n");
+ warning("TODO: support texture surface loading");
// return ((int) gLoadTexture(TextName, flags));
}
assert(TextName);
auto stream = workDirs.resolveFile(TextName);
if (!stream) {
- warning("gLoadBitmapImage: Cannot find %s.\n", TextName);
+ warning("gLoadBitmapImage: Cannot find %s.", TextName);
return -1;
}
@@ -303,7 +303,7 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
unsigned int pos = gGetBitmapListPosition();
if (pos == 0) {
- warning("rLoadBitmap: Can't create more bitmaps\n");
+ warning("rLoadBitmap: Can't create more bitmaps");
return -1;
}
gTexture *Texture = &gBitmapList[pos];
@@ -322,7 +322,7 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
if (flags & rSURFACESTRETCH) { // Also rSURFACEFLIP
static bool warned = false;
if (!warned) {
- warning("TODO: rSURFACESTRETCH\n");
+ warning("TODO: rSURFACESTRETCH");
warned = true;
}
// HACK: Just set a dimension at all:
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index ea10b79e13f..bea2bb709d3 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -109,7 +109,7 @@ void rAddLinesArray() {
//***********************************************************************************************
void *rLockPointArray() {
- warning("TODO: Implement rLockPointArray\n");
+ warning("TODO: Implement rLockPointArray");
#if 0
HRESULT hResult;
LPVOID v;
@@ -138,7 +138,7 @@ void rAddTrianglesArray(float x, float y, int r, int g, int b, int a) {
//***********************************************************************************************
void rUnlockPointArray() {
- warning("TODO: Implement rUnlockPointArray\n");
+ warning("TODO: Implement rUnlockPointArray");
#if 0
g_lpD3DPointsBuffer->Unlock();
#endif
@@ -272,10 +272,10 @@ int rAddUserViewMatrix(float _00, float _01, float _02,
rTempViewMatrix.setValue(4, 4, 1.0f);
auto &tmp = rTempViewMatrix;
- //warning("Adding: \n");
+ //warning("Adding: ");
//tmp.print();
for (i = 0, um = &rUserViewMatrix[0]; i < rNumUserViewMatrices; i++, um++) {
- //warning("Comparing %d\n", i);
+ //warning("Comparing %d", i);
//um->print();
if (*um == tmp) {
return i;
@@ -423,7 +423,7 @@ void gBuildAlternateName(char *AltName, const char *Name) {
}
}
- //warning("Build alternate name %s -> %s\n", Name, AltName);
+ //warning("Build alternate name %s -> %s", Name, AltName);
}
//*********************************************************************************************
@@ -561,7 +561,7 @@ int createTextureFromSurface(Surface &surface, int texFormat) {
compressed = true;
break;
default:
- warning("Texture format not handled: %d\n", texFormat);
+ warning("Texture format not handled: %d", texFormat);
}
#endif
if (compressed) {
@@ -580,7 +580,7 @@ struct DDSHeader {
DDSHeader parseDDSHeader(Common::SeekableReadStream &stream) {
DDSHeader header;
- //warning("TODO: Implement DDS Header parsing\n");
+ //warning("TODO: Implement DDS Header parsing");
uint32 retv = ' SDD'; //MAKEFOURCC( 'D','D','S',' ' );
uint32 magic = stream.readUint32LE();
if (magic != retv) {
@@ -674,7 +674,7 @@ Common::SharedPtr<gMovie> gLoadMovie(WorkDirs &workDirs, const char *TextName) {
{
//create surface
- //warning("TODO: Create compressed surface\n");
+ //warning("TODO: Create compressed surface");
#if 0
DDSURFACEDESC2 ddsd2;
@@ -709,7 +709,7 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
if (!TextName) return nullptr;
lpSSource = nullptr;
- //warning("gLoadTexture(%s)\n", TextName);
+ //warning("gLoadTexture(%s)", TextName);
// Check if already loaded
for (uint32 i = 0; i < gNumTextureList; i++) {
if (gTextureList[i].name.equalsIgnoreCase(TextName)) {
@@ -935,7 +935,7 @@ MaterialPtr Renderer::addMaterial(MaterialPtr MList, const Common::String &name,
bool AlreadyLoaded = FALSE;
int len = name.size();
- //warning("AddMaterial(%s)\n", name.c_str());
+ //warning("AddMaterial(%s)", name.c_str());
if (((name[len - 1 - 0] == 'i') || (name[len - 1 - 0] == 'I')) &&
((name[len - 1 - 1] == 'v') || (name[len - 1 - 1] == 'V')) &&
((name[len - 1 - 2] == 'a') || (name[len - 1 - 2] == 'A'))) {
diff --git a/engines/watchmaker/3d/render/opengl_renderer.cpp b/engines/watchmaker/3d/render/opengl_renderer.cpp
index e01bab07de1..cd45776d8a3 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.cpp
+++ b/engines/watchmaker/3d/render/opengl_renderer.cpp
@@ -64,7 +64,7 @@ void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, Commo
for (int i = 0; i < numFaces; i++) {
int index = faces[i];
auto &vertex = VBO->_buffer[index];
- //warning("%d/%d %d: [%f, %f, %f], [%f, %f], [%f, %f]\n", i, numFaces, index, vertex.x, vertex.y, vertex.z, vertex.u1, vertex.v1, vertex.u2, vertex.v2);
+ //warning("%d/%d %d: [%f, %f, %f], [%f, %f], [%f, %f]", i, numFaces, index, vertex.x, vertex.y, vertex.z, vertex.u1, vertex.v1, vertex.u2, vertex.v2);
//glColor3f((float)i/numFaces, 1.0, 0.0);
glColor3f(1.0f, 1.0f, 1.0f);
glTexCoord2f(vertex.u1, vertex.v1);
@@ -91,7 +91,7 @@ void OpenGLRenderer::drawPrimitives(PrimitiveType primitiveType, Vertex *vertice
glFlush();
}
void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, int VBO, int firstVertex, int numVertices, uint16 *faces, uint32 numFaces) {
- //warning("TODO: Implement drawIndexedPrimitivesVBO\n");
+ //warning("TODO: Implement drawIndexedPrimitivesVBO");
}
@@ -176,7 +176,7 @@ void OpenGLRenderer::setRenderState(RenderState state, int value) {
case RenderState::ALPHABLEND: setGlFeature(GL_BLEND, value); break; // TODO
}
- //warning("TODO: Implement setRenderState\n");
+ //warning("TODO: Implement setRenderState");
}
GLenum translateBlendFactorToGL(BlendFactor factor) {
diff --git a/engines/watchmaker/3d/render/opengl_renderer.h b/engines/watchmaker/3d/render/opengl_renderer.h
index fc8bf6bc80a..8478ffd9e47 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.h
+++ b/engines/watchmaker/3d/render/opengl_renderer.h
@@ -76,11 +76,11 @@ public:
void setRenderState(RenderState state, int value);
void setBlendFunc(BlendFactor src, BlendFactor dst);
bool error() const {
- //warning("TODO: Implement error\n");
+ //warning("TODO: Implement error");
return false;
}
Common::String getErrorString() {
- warning("TODO: Implement getErrorString\n");
+ warning("TODO: Implement getErrorString");
return "";
}
// TODO: This just maps to the D3D way to setting textures
diff --git a/engines/watchmaker/3d/render/render.cpp b/engines/watchmaker/3d/render/render.cpp
index 95a8a381944..4e923e37d78 100644
--- a/engines/watchmaker/3d/render/render.cpp
+++ b/engines/watchmaker/3d/render/render.cpp
@@ -128,7 +128,7 @@ void RenderGeometry(void) {
bool hres = false;
RenderSky();
- //warning("TODO: Texture configuration\n");
+ //warning("TODO: Texture configuration");
#if 0
g_renderer->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
g_renderer->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
@@ -165,7 +165,7 @@ void RenderGeometry(void) {
if ((g_renderer->supportsMultiTexturing()) && (bb->Texture2 != LastTexture2)) {
if (bb->Texture2 > 0) {
if (LastTexture2 <= 0) {
- //warning("TODO: Texture configuration\n");
+ //warning("TODO: Texture configuration");
#if 0
g_renderer->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
g_renderer->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
@@ -177,7 +177,7 @@ void RenderGeometry(void) {
}
g_renderer->setTexture(1, gTextureList[bb->Texture2]);
} else if (LastTexture2 > 0) {
- //warning("TODO: Texture configuration\n");
+ //warning("TODO: Texture configuration");
#if 0
g_renderer->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
g_renderer->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
@@ -196,7 +196,7 @@ void RenderGeometry(void) {
}
bb->Texture1 = -3;
}
- //warning("TODO: Texture configuration\n");
+ //warning("TODO: Texture configuration");
#if 0
g_renderer->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
g_renderer->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
@@ -415,7 +415,7 @@ bool rRenderScene(void) {
SHADOWBOX *sb = ShadowBoxesList[j];
rSetUserViewMatrix(sb->ViewMatrixNum);
if (bDisableShadows) break;
- warning("TODO: Shadows\n");
+ warning("TODO: Shadows");
#if 0
for (i = 0; i < sb->NumShadowsList; i++) {
if (!(hres = RenderProjectiveShadow(&sb->ShadowsList[i]))) {
diff --git a/engines/watchmaker/3d/render/shadows.cpp b/engines/watchmaker/3d/render/shadows.cpp
index 3a9a387ee5a..1674256049e 100644
--- a/engines/watchmaker/3d/render/shadows.cpp
+++ b/engines/watchmaker/3d/render/shadows.cpp
@@ -151,7 +151,7 @@ void Find2DConvexHull(DWORD nverts, COLORVERTEX *pntptr, DWORD *cNumOutIdxs, WOR
* find 2D convex hull for the object
* --------------------------------------------------*/
bool rMakeShadowVolume(SHADOWBOX *sb, gVertex *InVerts, DWORD nverts, float lightm[9]) {
- warning("Stubbed: rMakeShadowVolume\n");
+ warning("Stubbed: rMakeShadowVolume");
#if 0
Matrix4x4 matWorld, matView, matProj, IDmat;
DWORD i;
@@ -319,7 +319,7 @@ bool rMakeShadowVolume(SHADOWBOX *sb, gVertex *InVerts, DWORD nverts, float ligh
* makes a shadow box to avoid stenciled shadows over the object
* --------------------------------------------------*/
bool rMakeShadowBox(SHADOWBOX *sb, float BoxX, float BoxY, float BoxZ, WORD intens) {
- warning("Stubbed: rMakeShadowBox\n");
+ warning("Stubbed: rMakeShadowBox");
#if 0
bool hr;
LPDIRECT3DDEVICE7 pd3dDevice = g_pd3dDevice;
@@ -509,7 +509,7 @@ bool rMakeShadowBox(SHADOWBOX *sb, float BoxX, float BoxY, float BoxZ, WORD inte
* --------------------------------------------------*/
bool RenderShadow(SHADOW *pShad,
void *lpVBuf) {
- warning("TODO: Stubbed RenderShadow\n");
+ warning("TODO: Stubbed RenderShadow");
#if 0
LPDIRECT3DDEVICE7 pd3dDevice = g_pd3dDevice;
@@ -583,7 +583,7 @@ bool RenderShadow(SHADOW *pShad,
* --------------------------------------------------*/
bool RenderShadowBox(SHADOWBOX *pSB,
int lpVBuf) {
- warning("TODO: RenderShadowBox\n");
+ warning("TODO: RenderShadowBox");
#if 0
LPDIRECT3DDEVICE7 pd3dDevice = g_pd3dDevice;
@@ -628,7 +628,7 @@ bool RenderShadowBox(SHADOWBOX *pSB,
* of rendered 2D extent rect of all shadow vols.
* --------------------------------------------------*/
bool DrawShadow(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, WORD intens) {
- warning("Stubbed: DrawShadow\n");
+ warning("Stubbed: DrawShadow");
#if 0
LPDIRECT3DDEVICE7 pd3dDevice = g_pd3dDevice;
@@ -698,7 +698,7 @@ bool DrawShadow(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int
* prepare shadow for projection to a texture
* --------------------------------------------------*/
bool rMakeProjectiveShadow(SHADOWBOX *sb, void *InVerts, DWORD nverts) {
- warning("Stubbed. rMakeProjectiveShadow\n");
+ warning("Stubbed. rMakeProjectiveShadow");
#if 0
SHADOW *shad = &sb->ShadowsList[0];
D3DVERTEXBUFFERDESC vbDesc;
@@ -820,7 +820,7 @@ bool rMakeProjectiveShadow(SHADOWBOX *sb, void *InVerts, DWORD nverts) {
* renders shadow to a specific texture
* --------------------------------------------------*/
bool RenderProjectiveShadow(SHADOW *pShad) {
- warning("Stubbed. RenderPojectiveShadow\n");
+ warning("Stubbed. RenderPojectiveShadow");
#if 0
HRESULT hres;
LPDIRECT3DDEVICE7 pd3dDevice = g_pd3dDevice;
@@ -911,7 +911,7 @@ bool RenderProjectiveShadow(SHADOW *pShad) {
* draw projected shadow texture to the room
* --------------------------------------------------*/
bool DrawProjectiveShadow(SHADOW *pShad) {
- warning("Stubbed: DrawProjectiveShadow\n");
+ warning("Stubbed: DrawProjectiveShadow");
#if 0
bool hres;
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index aa022553f1f..8614c7e021c 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -81,7 +81,7 @@ void t3dLoadMaterials(WGame &game, t3dBODY *b, Common::SeekableReadStream &strea
if (LoaderFlags & T3D_HALFTEXTURESIZE) flag = rSURFACEHALF; // Se deve scalare le textures
else flag = 0;
MaterialPtr mat = b->MatTable[material];
- //warning("Loading material %d\n", material);
+ //warning("Loading material %d", material);
#ifndef WMGEN
if (!(game._renderer->addMaterial(mat, Appo,/*f1*/0, flag))) { // Carica e scala texture
warning("Material file %s not found, ", Appo); // Se non trova la texture
@@ -269,7 +269,7 @@ void LoadBounds(WorkDirs &workDirs, const char *pname, t3dBODY *b) {
}
b->NumLevels = nlev = stream->readSint16LE();
if (nlev > T3D_MAX_LEVELS) {
- warning("Too much Floor Levels in %s: %d instead of %d\n", pname, b->NumLevels, T3D_MAX_LEVELS);
+ warning("Too much Floor Levels in %s: %d instead of %d", pname, b->NumLevels, T3D_MAX_LEVELS);
b->NumLevels = nlev = T3D_MAX_LEVELS;
}
@@ -537,7 +537,7 @@ t3dBODY *t3dBODY::loadFromStream(WGame &game, const Common::String &pname, Commo
#endif
//----------------END OF VERTEX PRE-LIGHTING---------------------
- warning("LoaderFlags late = %08X\n", LoaderFlags);
+ warning("LoaderFlags late = %08X", LoaderFlags);
//decodeLoaderFlags(LoaderFlags);
if (!(LoaderFlags & T3D_NOBOUNDS)) { // Carica Bounds
auto bndName = workdirs.join(workdirs._bndDir, pname, "bnd");
diff --git a/engines/watchmaker/3d/t3d_mesh.cpp b/engines/watchmaker/3d/t3d_mesh.cpp
index 49cbca987dd..1f234088873 100644
--- a/engines/watchmaker/3d/t3d_mesh.cpp
+++ b/engines/watchmaker/3d/t3d_mesh.cpp
@@ -40,7 +40,7 @@ void t3dMESH::loadFaces(t3dBODY *b, Common::SeekableReadStream &stream) {
uint16 n = stream.readSint16LE(); // Legge indice materiale
if (n >= b->NumMaterials())
- warning("Material index wrong: current index: %d; Max material index %d\n", n, b->NumMaterials());
+ warning("Material index wrong: current index: %d; Max material index %d", n, b->NumMaterials());
else {
FList[face].mat = b->MatTable[n]; // Make the pointer to the material
if (b->MatTable[n]->addNumFaces(1/*f2*/) == false) // Add face space to the material
diff --git a/engines/watchmaker/classes/do_keyboard.cpp b/engines/watchmaker/classes/do_keyboard.cpp
index 7b39a36f3b9..1d3f7d2a118 100644
--- a/engines/watchmaker/classes/do_keyboard.cpp
+++ b/engines/watchmaker/classes/do_keyboard.cpp
@@ -248,7 +248,7 @@ void HandleFirstPersonView( void )
* --------------------------------------------------*/
void ProcessKeyboard(WGame &game) {
- //warning("STUBBED: ProcessKeyboard\n");
+ //warning("STUBBED: ProcessKeyboard");
// Hack: Skip intro:
if ((CurDialog == dR000) || (CurDialog == dR111) || (CurDialog == dR211)) {
diff --git a/engines/watchmaker/classes/do_player.cpp b/engines/watchmaker/classes/do_player.cpp
index c3b6699e404..13a132d5a7d 100644
--- a/engines/watchmaker/classes/do_player.cpp
+++ b/engines/watchmaker/classes/do_player.cpp
@@ -332,7 +332,7 @@ void UpdatePlayerStand(WGame &game, uint8 oc) {
mindist = dist;
na = b;
}
- warning("Found %d, dist %f, good %d\n", b, dist, na);
+ warning("Found %d, dist %f, good %d", b, dist, na);
panims[pc] = b ;
pc ++;
@@ -424,7 +424,7 @@ void ChangePlayer(WGame &game, uint8 oc) {
}
}
// Cambia stanza andandosi a leggere la posizione e l'animazione che aveva prima
- warning("Changing Room to |%s| pos: %d an: %d\n", PlayerStand[CurPlayer].roomName.c_str(), PlayerStand[CurPlayer].pos, PlayerStand[CurPlayer].an);
+ warning("Changing Room to |%s| pos: %d an: %d", PlayerStand[CurPlayer].roomName.c_str(), PlayerStand[CurPlayer].pos, PlayerStand[CurPlayer].an);
ChangeRoom(game, PlayerStand[CurPlayer].roomName, PlayerStand[CurPlayer].pos, 0);
if ((curRoom == r15) || (curRoom == r1F))
SetBndLevel(init, nullptr, PlayerStand[CurPlayer].bnd);
diff --git a/engines/watchmaker/classes/do_sound.cpp b/engines/watchmaker/classes/do_sound.cpp
index 02c411733e5..933db240e0b 100644
--- a/engines/watchmaker/classes/do_sound.cpp
+++ b/engines/watchmaker/classes/do_sound.cpp
@@ -51,7 +51,7 @@ namespace Watchmaker {
* InitMusic
* --------------------------------------------------*/
bool InitMusic() {
- warning("STUBBED InitMusic\n");
+ warning("STUBBED InitMusic");
#if 0
if (!mInitMusicSystem())
return false;
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index 80c61e51b86..a4c1ef8eeac 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -520,7 +520,7 @@ void PaintIntroText(Renderer &renderer) {
/* PROCESSTIME */
/*-------------------------------------------------------------------------*/
void ProcessTime(WGame &game) {
- // warning("STUBBED ProcessTime\n");
+ // warning("STUBBED ProcessTime");
// LARGE_INTEGER pf,pt;
int32 i;
@@ -665,7 +665,7 @@ void InitMain(WGame &game) {
Event(EventClass::MC_SYSTEM, ME_START, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
if (!rClearBuffers(rCLEARBACKBUFFER | rCLEARZBUFFER)) // Cancella buffers
- //warning("Unable to clear backbuffers\n");
+ //warning("Unable to clear backbuffers");
T1.tnum = T2.tnum = -1;
T1t = T2t = nullptr;
@@ -925,7 +925,7 @@ void doSystem(WGame &game) {
case ME_CONTINUEEFFECT:
TheMessage->wparam1 --;
if (TheMessage->wparam1 > 0) {
- warning("STUBBED: ME_CONTINUEEFFECT\n");
+ warning("STUBBED: ME_CONTINUEEFFECT");
#if 0
switch (TheMessage->bparam) {
case EFFECT_FADIN:
diff --git a/engines/watchmaker/game.cpp b/engines/watchmaker/game.cpp
index 43f90814ad9..1b15455be1c 100644
--- a/engines/watchmaker/game.cpp
+++ b/engines/watchmaker/game.cpp
@@ -114,7 +114,7 @@ const char *CharNameHI_Strings[] = {
* --------------------------------------------------*/
// Controllo che la giusta MoglieSupervisore sia caricata
bool WGame::CheckAndLoadMoglieSupervisoreModel(int32 c) {
- warning("CheckAndLoadMoglieSupervisoreModel(workDirs, %d)\n", c);
+ warning("CheckAndLoadMoglieSupervisoreModel(workDirs, %d)", c);
char RemoveName[128] = "";
char RemoveNameHI[128] = "";
int32 j;
@@ -289,7 +289,7 @@ int WGame::StartPlayingGame(const Common::String &LoaderName_override) {
bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
uint16 i = 0;
- warning("--=>> %s <<=--: LoaderFlags: %08X\n", name.c_str(), LoaderFlags);
+ warning("--=>> %s <<=--: LoaderFlags: %08X", name.c_str(), LoaderFlags);
t3dCurCamera = &t3dIconCamera;
auto windowInfo = _renderer->getScreenInfos();
@@ -318,7 +318,7 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
return false;
}
- warning("Reached loop: %02X\n", LoadChar);
+ warning("Reached loop: %02X", LoadChar);
for (i = 0; i < 32; i++) {
if (i >= ocCURPLAYER) continue;
@@ -341,7 +341,7 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
CharNameHI_Strings[i + 1] = "MoglieKimono.t3d";
}
}
- warning("About to load %s\n", CharName[i + 1]);
+ warning("About to load %s", CharName[i + 1]);
if (!(Character[i + 1] = t3dLoadCharacter(*this, CharName[i + 1], Character[i + 1], i))) {
warning("Error loading %s", CharName[i + 1]);
return false;
@@ -540,7 +540,7 @@ void WGame::UpdateAll() {
*
* --------------------------------------------------*/
void WGame::LoadMisc() {
- warning("LoadMisc\n");
+ warning("LoadMisc");
char str[20];
int32 i;
@@ -606,7 +606,7 @@ void WGame::LoadMisc() {
}
bMiscLoaded = 1;
- warning("LoadMisc Done\n");
+ warning("LoadMisc Done");
}
void WGame::GameLoop() {
@@ -637,7 +637,7 @@ void WGame::GameLoop() {
sdl->pollSDL();
done = sdl->shouldQuit;
if (g_bActive && g_bReady) {
- //warning("NextMessage\n");
+ //warning("NextMessage");
NextMessage(*this);
}
//}
@@ -649,7 +649,7 @@ void WGame::CleanUpAndPostQuit() {
extern char *TextBucket;
gameOptions.save(workDirs);
- warning("STUBBED CleanupAndPostQuit\n");
+ warning("STUBBED CleanupAndPostQuit");
#if 0
if (CreditsNames) t3dFree(CreditsNames);
if (CreditsRoles) t3dFree(CreditsRoles);
diff --git a/engines/watchmaker/game_options.h b/engines/watchmaker/game_options.h
index c1f91dcbae1..e99005649dc 100644
--- a/engines/watchmaker/game_options.h
+++ b/engines/watchmaker/game_options.h
@@ -55,7 +55,7 @@ public:
subtitles_on = stream->readByte();
bShowRoomDescriptions = stream->readByte();
bShowExtraLocalizationStrings = stream->readByte();
- warning("Done loading options\n");
+ warning("Done loading options");
#endif
return true;
}
diff --git a/engines/watchmaker/globvar.h b/engines/watchmaker/globvar.h
index bb06efd9d87..b9c699b68ba 100644
--- a/engines/watchmaker/globvar.h
+++ b/engines/watchmaker/globvar.h
@@ -48,7 +48,7 @@ struct Init : public SerializableAsset {
SerializableDynamicArray<SCreditsRole> _creditsRoles;
void loadFromStream(Common::SeekableReadStream &stream) {
- warning("Init\n");
+ warning("Init");
Room.loadFromStream(stream);
Obj.loadFromStream(stream);
InvObj.loadFromStream(stream);
diff --git a/engines/watchmaker/ll/ll_mouse.cpp b/engines/watchmaker/ll/ll_mouse.cpp
index 4bad9ed6dda..b41378d8cbc 100644
--- a/engines/watchmaker/ll/ll_mouse.cpp
+++ b/engines/watchmaker/ll/ll_mouse.cpp
@@ -153,7 +153,7 @@ void HandleMouseChanges()
bLPressed = buttonState & SDL_BUTTON_LMASK;
bRPressed = buttonState & SDL_BUTTON_RMASK;
- //warning("L: %d %d R: %d %d\n", bLPressed, bLPressedPrev, bRPressed, bRPressedPrev);
+ //warning("L: %d %d R: %d %d", bLPressed, bLPressedPrev, bRPressed, bRPressedPrev);
// Button 0 pressed or released
if( bLPressed != bLPressedPrev )
{
diff --git a/engines/watchmaker/ll/ll_regen.cpp b/engines/watchmaker/ll/ll_regen.cpp
index b5d84072564..95206e8eea9 100644
--- a/engines/watchmaker/ll/ll_regen.cpp
+++ b/engines/watchmaker/ll/ll_regen.cpp
@@ -239,7 +239,7 @@ void ResetScreenBuffer() {
memset(OldPaintRect, 0, sizeof(OldPaintRect));
if (!rClearBuffers(rCLEARSCREENBUFFER | rCLEARZBUFFER))
- warning("Unable to clear screenbuffer\n");
+ warning("Unable to clear screenbuffer");
}
/* -----------------30/10/98 16.18-------------------
@@ -262,7 +262,7 @@ void AddPaintRect(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx,
// ce ne sono troppe
if (a >= MAX_PAINT_RECTS) {
- warning("Too many PaintRects!\n");
+ warning("Too many PaintRects!");
return ;
}
diff --git a/engines/watchmaker/ll/ll_sound.cpp b/engines/watchmaker/ll/ll_sound.cpp
index a66271c37f6..5948770942d 100644
--- a/engines/watchmaker/ll/ll_sound.cpp
+++ b/engines/watchmaker/ll/ll_sound.cpp
@@ -25,77 +25,77 @@
namespace Watchmaker {
bool mInitMusicSystem(void) {
- warning("STUBBED: mInitMusicSystem\n");
+ warning("STUBBED: mInitMusicSystem");
return true;
}
bool mCloseMusicSystem(void) {
- warning("STUBBED: mCloseMusicSystem\n");
+ warning("STUBBED: mCloseMusicSystem");
return true;
}
bool mLoadMusic(const char *FileName) {
- warning("STUBBED: mLoadMusic\n");
+ warning("STUBBED: mLoadMusic");
return true;
}
bool mPlayMusic(const char *FileName) {
- warning("STUBBED: mPlayMusic\n");
+ warning("STUBBED: mPlayMusic");
return true;
}
bool mStopMusic(void) {
- warning("STUBBED: mStopMusic\n");
+ warning("STUBBED: mStopMusic");
return true;
}
bool mRestoreMixerVolume(void) {
- warning("STUBBED: mRestoreMixerVolume\n");
+ warning("STUBBED: mRestoreMixerVolume");
return true;
}
bool sSetListener(sListener *NewListener) {
- warning("STUBBED: sSetListener\n");
+ warning("STUBBED: sSetListener");
return true;
}
bool sStartSound(sSound *CurSound, bool Reload) {
- warning("STUBBED: sStartSound\n");
+ warning("STUBBED: sStartSound");
return true;
}
bool sStopSound(int32 index) {
- warning("STUBBED: sStopSound\n");
+ warning("STUBBED: sStopSound");
return true;
}
bool sStopAllSounds(void) {
- warning("STUBBED: sStopAllSounds\n");
+ warning("STUBBED: sStopAllSounds");
return true;
}
bool sIsPlaying(sS32 lIndex) {
- warning("STUBBED: sIsPlaying\n");
+ warning("STUBBED: sIsPlaying");
return true;
}
bool mSetAllVolume(unsigned char Volume) {
- warning("STUBBED: mSetAllVolume\n");
+ warning("STUBBED: mSetAllVolume");
return true;
}
bool sSetAllSoundsVolume(unsigned char Vol) {
- warning("STUBBED: sSetAllSoundsVolume\n");
+ warning("STUBBED: sSetAllSoundsVolume");
return true;
}
bool sSetAllSpeechVolume(unsigned char Vol) {
- warning("STUBBED: sSetAllSpeechVolume\n");
+ warning("STUBBED: sSetAllSpeechVolume");
return true;
}
bool sStartSoundDiffuse(sSound *CurSound) {
- warning("STUBBED: sStartSoundDiffuse\n");
+ warning("STUBBED: sStartSoundDiffuse");
return true;
}
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index 2e5fc897957..c3edb5c5697 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -89,7 +89,7 @@ void *t3dRealloc(void *pp, uint32 additionalBytes) {
t3dAllocatedMemory += additionalBytes;
//malloc_size()
pp = res;//realloc(pp, additionalBytes);
- //warning("t3dRealloc() size: %d, additionalBytes: %d, newSize = %d\n", size, additionalBytes, malloc_size(pp));
+ //warning("t3dRealloc() size: %d, additionalBytes: %d, newSize = %d", size, additionalBytes, malloc_size(pp));
return (pp);
}
@@ -106,7 +106,7 @@ void t3dFree(void *p) {
//..........................................................................
void t3dStartTime() {
- warning("STUBBED t3dStartTime\n");
+ warning("STUBBED t3dStartTime");
#if 0
timeGetDevCaps(&tc, sizeof(tc));
timeBeginPeriod(tc.wPeriodMin);
@@ -115,7 +115,7 @@ void t3dStartTime() {
}
void t3dEndTime() {
- warning("STUBBED t3dEndTime\n");
+ warning("STUBBED t3dEndTime");
#if 0
timeEndPeriod(tc.wPeriodMin);
#endif
@@ -129,7 +129,7 @@ uint32 t3dReadTime() {
//------------------------- File I/O Functions -----------------------------
bool t3dFastFileInit(const char *name) {
- warning("STUBBED t3dFastFileInit\n");
+ warning("STUBBED t3dFastFileInit");
#if 0
bUsingFastFile = FastFileInit(name);
return (BOOL)(bUsingFastFile);
@@ -165,7 +165,7 @@ int t3dAccessFile(char *name) {
bool t3dGetFileDate(uint32 *date, uint32 *time, const char *name) {
#if 0
FILE *f = fopen(name, "rb");
- //warning("STUBBED: t3dGetFileDate(%s)\n", name);
+ //warning("STUBBED: t3dGetFileDate(%s)", name);
if (f) {
fclose(f);
return true;
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index f58bcdceb75..188a7a3c539 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -253,7 +253,7 @@ int32 CreateTooltipBitmap(Renderer &renderer, char *tooltip, struct SFont *f, ui
* LoadFont
* --------------------------------------------------*/
void LoadFont(struct SFont *f, const char *n) {
- warning("STUBBED: LoadFont(%s)\n", n);
+ warning("STUBBED: LoadFont(%s)", n);
#if 0
char name[100], a;
@@ -288,7 +288,7 @@ int32 LoadDDBitmap(WGame &game, const char *n, uint8 flags) {
int rez = rLoadBitmapImage(game, name.c_str(), (uint8)(rBITMAPSURFACE | rSURFACEFLIP | flags));
if (rez <= 0) {
- warning("Failed to load %s. Quitting ...\n", name.c_str());
+ warning("Failed to load %s. Quitting ...", name.c_str());
CloseSys(game);
}
@@ -505,7 +505,7 @@ bool SetBndLevel(Init &init, const char *roomname, int32 lev) {
* PrintLoading
* --------------------------------------------------*/
void PrintLoading(void) {
- warning("STUBBED: PrintLoading\n");
+ warning("STUBBED: PrintLoading");
#if 0
// Stampa la scritta loading
@@ -654,7 +654,7 @@ void DisplayD3DTriangle(Renderer &renderer, int32 x1, int32 y1, int32 x2, int32
}
if (a >= MAX_D3D_TRIANGLES) {
- warning("Too many D3D Triangles!\n");
+ warning("Too many D3D Triangles!");
return ;
}
@@ -686,7 +686,7 @@ void DisplayD3DRect(Renderer &renderer, int32 px, int32 py, int32 dx, int32 dy,
}
if (a >= MAX_D3D_RECTS) {
- warning("Too many D3D Rects!\n");
+ warning("Too many D3D Rects!");
return ;
}
@@ -711,7 +711,7 @@ void DisplayDDBitmap(Renderer &renderer, int32 tnum, int32 px, int32 py, int32 o
break;
if (a >= MAX_DD_BITMAPS) {
- warning("Too many DD Bitmaps!\n");
+ warning("Too many DD Bitmaps!");
return ;
}
@@ -736,7 +736,7 @@ void DisplayDDBitmap_NoFit(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, i
break;
if (a >= MAX_DD_BITMAPS) {
- warning("Too many DD Bitmaps!\n");
+ warning("Too many DD Bitmaps!");
return ;
}
@@ -799,7 +799,7 @@ void DisplayDDText(Renderer &renderer, char *text, struct SFont *f, uint8 color,
break;
if (a >= MAX_DD_TEXTS) {
- warning("Too many DD Texts!\n");
+ warning("Too many DD Texts!");
return ;
}
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index 1dc5b710106..3aeb42ae92f 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -49,7 +49,7 @@ uint8 force_debug_window = 0;
void CleanUpAndPostQuit(WorkDirs &workDirs, GameOptions &gameOptions);
int WMakerMain() {
- warning("The Watchmaker\n");
+ warning("The Watchmaker");
//CreateWindow()
int loaderFlags = 0;
@@ -97,7 +97,7 @@ int WMakerMain() {
if (LoaderFlags & T3D_NOLIGHTMAPS) rSetLightmapRendering(0); // Disattiva le Lightmaps
else rSetLightmapRendering(1); // Attiva le Lightmaps
*/
- warning("init engine...\n");
+ warning("init engine...");
if (!(rInitialize3DEnvironment(*game,/*hWnd, */ WmCfgName))) { // Apre scheda 3D
game->CleanUpAndPostQuit();
return 1;
@@ -128,7 +128,7 @@ int WMakerMain() {
game->GameLoop();
- warning("FIN\n");
+ warning("FIN");
delete game;
return 0;
}
diff --git a/engines/watchmaker/render.cpp b/engines/watchmaker/render.cpp
index 505a697ab94..312de80568b 100644
--- a/engines/watchmaker/render.cpp
+++ b/engines/watchmaker/render.cpp
@@ -40,7 +40,7 @@
namespace Watchmaker {
bool rInitialize3DEnvironment(WGame &game, char *cfg) {
- warning("STUBBED: rInitialize3DEnvironment\n");
+ warning("STUBBED: rInitialize3DEnvironment");
game.sdl->initWindow();
game._renderer->initGL();
return true;
@@ -66,7 +66,7 @@ unsigned int gGetTextureListPosition() {
#endif
bool rSetRenderMode(int state) {
- warning("STUBBED: rSetRenderMode\n");
+ warning("STUBBED: rSetRenderMode");
}
bool checkGlError(const char *when) {
@@ -83,7 +83,7 @@ bool checkGlError(const char *when) {
case GL_STACK_OVERFLOW: explanation = "GL_STACK_OVERFLOW"; break;
default: break;
}
- warning("%s: GL raised error %d - %s\n", when, error, explanation.c_str());
+ warning("%s: GL raised error %d - %s", when, error, explanation.c_str());
return false;
}
return true;
@@ -103,41 +103,41 @@ bool rClearBuffers(char flags) {
}
unsigned char *rLockSurfaceDirect(gTexture *t, unsigned int *pitch) {
- warning("STUBBED: rLockSurfaceDirect\n");
+ warning("STUBBED: rLockSurfaceDirect");
return nullptr;
}
void rUnlockSurfaceDirect(gTexture *t) {
- warning("STUBBED: rUnlockSurfaceDirect\n");
+ warning("STUBBED: rUnlockSurfaceDirect");
}
uint16 rRGBAToTextureFormat(unsigned int r, unsigned int g, unsigned int b, unsigned int a) {
- warning("STUBBED: rRGBAToTextureFormat\n");
+ warning("STUBBED: rRGBAToTextureFormat");
return 0;
}
bool rSetMovieFrame(MaterialPtr mat, uint32 dwCurrFrame) {
- warning("STUBBED: rSetMovieFrame\n");
+ warning("STUBBED: rSetMovieFrame");
return false;
}
int rCreateSurface(unsigned int dimx, unsigned int dimy, unsigned char flags) {
- warning("STUBBED: rCreateSurface\n");
+ warning("STUBBED: rCreateSurface");
return 0;
}
VertexBuffer rCreateVertexBuffer(unsigned int num) {
- //warning("STUBBED: rCreateVertexBuffer\n");
+ //warning("STUBBED: rCreateVertexBuffer");
return VertexBuffer();
}
bool rDeleteVertexBuffer(VertexBuffer &vb) {
- warning("STUBBED: rDeleteVertexBuffer\n");
+ warning("STUBBED: rDeleteVertexBuffer");
return false;
}
void rGetScreenInfos(unsigned int *width, unsigned int *height, unsigned int *bpp) {
- warning("STUBBED: rGetScreenInfos\n");
+ warning("STUBBED: rGetScreenInfos");
*width = 800;
*height = 600;
*bpp = 32;
@@ -157,7 +157,7 @@ bool rSetProjectionMatrix(float width, float height, float fAspect,
void rScreenSpaceToCameraSpace(float *dx, float *dy, float *dz, float x, float y) {
- //warning("STUBBED: rScreenSpaceToCameraSpace\n");
+ //warning("STUBBED: rScreenSpaceToCameraSpace");
#if 0
D3DMATRIX m;
D3DVECTOR v, d;
@@ -179,64 +179,64 @@ void rScreenSpaceToCameraSpace(float *dx, float *dy, float *dz, float x, float y
}
gTexture *gLoadTexture(char *TextName, unsigned int LoaderFlags) {
- warning("STUBBED gLoadTexture\n");
+ warning("STUBBED gLoadTexture");
return nullptr;
}
bool rGrabVideo(const char *path, char flags) {
- warning("STUBBED: rGrabVideo\n");
+ warning("STUBBED: rGrabVideo");
return true;
}
void rReleaseAllBitmaps(unsigned int NotFlags) {
- warning("STUBBED: rReleaseAllBitmaps\n");
+ warning("STUBBED: rReleaseAllBitmaps");
return;
}
void rReleaseBitmap(int i) {
- warning("STUBBED: rReleaseBitmap\n");
+ warning("STUBBED: rReleaseBitmap");
return;
}
void rReleaseAllTextures(unsigned int NotFlags) {
- warning("STUBBED: rReleaseAllTextures\n");
+ warning("STUBBED: rReleaseAllTextures");
return;
}
void rSetBitmapName(unsigned int id, const char *s) {
- warning("STUBBED: rSetBitmapName\n");
+ warning("STUBBED: rSetBitmapName");
return;
}
uint32 rGetMovieFrame(MaterialPtr mat) {
- warning("STUBBED: rGetMovieFrame\n");
+ warning("STUBBED: rGetMovieFrame");
return 0;
}
void rPrintText(const char *s, unsigned int dst, unsigned int src, unsigned short *FontTable, unsigned short x, unsigned short y) {
- warning("STUBBED: rPrintText\n");
+ warning("STUBBED: rPrintText");
return;
}
void rGetTextDim(const char *s, unsigned short *FontTable, int *x, int *y) {
- warning("STUBBED: rGetTextDim\n");
+ warning("STUBBED: rGetTextDim");
return;
}
void rResetPipeline() {
- //warning("STUBBED: rResetPipeline\n");
+ //warning("STUBBED: rResetPipeline");
return;
}
void rClear(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b) {
- //warning("STUBBED: rClear(%d, %d, %d, %d, %d\n", dst, dposx, dposy, sdimx, sdimy);
+ //warning("STUBBED: rClear(%d, %d, %d, %d, %d", dst, dposx, dposy, sdimx, sdimy);
}
void rBlitScreenBuffer(void) { // Should probably go to opengl_2d
- //warning("STUBBED: rBlitScreenBuffer\n");
+ //warning("STUBBED: rBlitScreenBuffer");
}
bool gMovie_SetFrame(gMaterial *mat, WORD newFrame) {
diff --git a/engines/watchmaker/renderer.cpp b/engines/watchmaker/renderer.cpp
index bc26a81952a..b986a5d4cca 100644
--- a/engines/watchmaker/renderer.cpp
+++ b/engines/watchmaker/renderer.cpp
@@ -92,7 +92,7 @@ bool Renderer::createScreenBuffer() {
_viewport.left = _viewport.top = 0;
_viewport.right = 800;
_viewport.bottom = 600;
- warning("TODO: Implement createScreenBuffer\n");
+ warning("TODO: Implement createScreenBuffer");
return false;
}
diff --git a/engines/watchmaker/saveload.cpp b/engines/watchmaker/saveload.cpp
index 7da43656a49..970aa2f6089 100644
--- a/engines/watchmaker/saveload.cpp
+++ b/engines/watchmaker/saveload.cpp
@@ -119,7 +119,7 @@ void loadAll(WorkDirs &workDirs, Init &init) {
// NOTA: se slot==255 forza il save (salva senza controllare le condizioni)
bool DataSave(const char *SaveName, uint8 slot) {
char str[T3D_NAMELEN];
- warning("STUBBED: DataSave\n");
+ warning("STUBBED: DataSave");
#if 0
FILE *fhs;
int32 i, j;
diff --git a/engines/watchmaker/schedule.cpp b/engines/watchmaker/schedule.cpp
index 5cb4e1876a9..c746a399d7b 100644
--- a/engines/watchmaker/schedule.cpp
+++ b/engines/watchmaker/schedule.cpp
@@ -140,7 +140,7 @@ void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wp
pqueue *lq;
message *lm;
- warning("Event(%s, event=%d, flags=%d, wparam1=%d, wparam2=%d, bparam=%d\n", eventToString(classe), event, flags, wparam1, wparam2);
+ warning("Event(%s, event=%d, flags=%d, wparam1=%d, wparam2=%d, bparam=%d", eventToString(classe), event, flags, wparam1, wparam2);
if (classe == EventClass::MC_IDLE && !event)
return ;
@@ -168,9 +168,9 @@ void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wp
return;
} else {
for (a = 0; a < MAXWAITINGMSGS; a++)
- warning("%d: %d %d %d %d\n", a, WaitingMsg[a].classe, WaitingMsg[a].event, WaitingMsg[a].flags, WaitingMsg[a].lparam[1]);
+ warning("%d: %d %d %d %d", a, WaitingMsg[a].classe, WaitingMsg[a].event, WaitingMsg[a].flags, WaitingMsg[a].lparam[1]);
- warning("ERRORE! CODA WAITING PIENA! - messy %d %d MAX %d\n", classe, event, MAXWAITINGMSGS);
+ warning("ERRORE! CODA WAITING PIENA! - messy %d %d MAX %d", classe, event, MAXWAITINGMSGS);
return;
}
}
@@ -179,9 +179,9 @@ void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wp
uint8 pos;
for (pos = lq->head; pos != lq->tail; pos = (pos == MAX_MESSAGES - 1) ? 0 : pos + 1)
- warning("EVENT %d %d\n", lq->event[pos]->classe, lq->event[pos]->event);
+ warning("EVENT %d %d", lq->event[pos]->classe, lq->event[pos]->event);
- warning("ERRORE! CODA GAME PIENA! - messy %d %d MAX %d\n", classe, event, MAX_MESSAGES);
+ warning("ERRORE! CODA GAME PIENA! - messy %d %d MAX %d", classe, event, MAX_MESSAGES);
return;
}
@@ -224,7 +224,7 @@ void Scheduler() {
Counter = 0;
TheMessage = &idlemessage;
}
- //warning("Scheduler: %s %d\n", eventToString(TheMessage->classe), TheMessage->event);
+ //warning("Scheduler: %s %d", eventToString(TheMessage->classe), TheMessage->event);
}
/* -----------------08/02/99 10.11-------------------
@@ -232,7 +232,7 @@ void Scheduler() {
* --------------------------------------------------*/
void ProcessTheMessage(WGame &game) {
SUPEREVENT:
- //warning("Event: %s - %d\n", eventToString(TheMessage->classe), TheMessage->event);
+ //warning("Event: %s - %d", eventToString(TheMessage->classe), TheMessage->event);
switch (TheMessage->classe) {
case EventClass::MC_IDLE:
break;
diff --git a/engines/watchmaker/sdl_wrapper.cpp b/engines/watchmaker/sdl_wrapper.cpp
index 856ccd82016..b94a848a691 100644
--- a/engines/watchmaker/sdl_wrapper.cpp
+++ b/engines/watchmaker/sdl_wrapper.cpp
@@ -63,7 +63,7 @@ void sdl_wrapper::pollSDL() {
switch (event.button.button) {
case SDL_BUTTON_LEFT:
bLPressed = true;
- warning("LEFT PRESSED\n");
+ warning("LEFT PRESSED");
break;
case SDL_BUTTON_RIGHT:
bRPressed = true;
@@ -76,7 +76,7 @@ void sdl_wrapper::pollSDL() {
switch (event.button.button) {
case SDL_BUTTON_LEFT:
bLPressed = false;
- warning("LEFT RELEASED\n");
+ warning("LEFT RELEASED");
break;
case SDL_BUTTON_RIGHT:
bRPressed = false;
@@ -104,7 +104,7 @@ void sdl_wrapper::initWindow() {
window = SDL_CreateWindow("The Watchmaker", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_OPENGL);
if (window == nullptr) {
- warning("Couldn't create window: %s\n", SDL_GetError());
+ warning("Couldn't create window: %s", SDL_GetError());
assert(false);
}
int numRenderers = SDL_GetNumRenderDrivers();
@@ -112,7 +112,7 @@ void sdl_wrapper::initWindow() {
for (int i = 0; i < numRenderers; i++) {
SDL_RendererInfo info;
SDL_GetRenderDriverInfo(i, &info);
- warning("Renderer(%d): %s\n", i, info.name);
+ warning("Renderer(%d): %s", i, info.name);
if (strcmp(info.name, "opengl") == 0) {
renderIndex = i;
}
@@ -120,7 +120,7 @@ void sdl_wrapper::initWindow() {
renderer = SDL_CreateRenderer(window, renderIndex, SDL_RENDERER_ACCELERATED);
SDL_RendererInfo info;
SDL_GetRendererInfo(renderer, &info);
- warning("Renderer: %s\n", info.name);
+ warning("Renderer: %s", info.name);
IMG_Init(0);
#endif
}
diff --git a/engines/watchmaker/t2d/t2d.cpp b/engines/watchmaker/t2d/t2d.cpp
index 63733f0c911..921012d2d76 100644
--- a/engines/watchmaker/t2d/t2d.cpp
+++ b/engines/watchmaker/t2d/t2d.cpp
@@ -5448,7 +5448,7 @@ void CaricaSaves(WGame &game) {
char GfxFile[MAX_PATH];
char Temp[10];
char Data[T3D_NAMELEN + 8];
- warning("STUBBED: CaricaSaves\n");
+ warning("STUBBED: CaricaSaves");
#if 0
FILE *file;
@@ -5508,7 +5508,7 @@ void CaricaSaves(WGame &game) {
}
void SortSaves(void) {
- warning("STUBBED: SortSaves\n");
+ warning("STUBBED: SortSaves");
#if 0
qsort(Saves, NSaves, sizeof(SavesS), CompareSaves);
#endif
diff --git a/engines/watchmaker/tga_util.cpp b/engines/watchmaker/tga_util.cpp
index e4be41c648b..a8e4278f9f2 100644
--- a/engines/watchmaker/tga_util.cpp
+++ b/engines/watchmaker/tga_util.cpp
@@ -115,7 +115,7 @@ unsigned int TGAread(void *ptr, unsigned int size, unsigned int n, Common::Seeka
unsigned int len = size * n;
#if 0
if ((!ptr) || (!len) || (/*stream.pos() > stream.size()*/)) {
- warning("Overrun TGA parsing\n");
+ warning("Overrun TGA parsing");
return 0;
}
#endif
diff --git a/engines/watchmaker/walk/ball.cpp b/engines/watchmaker/walk/ball.cpp
index 3b58e776898..c3732e770dd 100644
--- a/engines/watchmaker/walk/ball.cpp
+++ b/engines/watchmaker/walk/ball.cpp
@@ -285,7 +285,7 @@ void UpdateBall(WGame &game, struct SPhys *p) {
* ProcessGopherKeyboard
* --------------------------------------------------*/
void ProcessGopherKeyboard() {
- warning("Stubbed: ProcessGopherKeyboard\n");
+ warning("Stubbed: ProcessGopherKeyboard");
#if 0
t3dF32 AngleX, AngleY, AngleSpeed;
t3dF32 TurnSpeed, Speed = 1.0f;
@@ -410,7 +410,7 @@ void ProcessGopherKeyboard() {
* UpdateArrow
* --------------------------------------------------*/
void UpdateArrow() {
- warning("Stubbed: UpdateArrow\n");
+ warning("Stubbed: UpdateArrow");
#if 0
t3dF32 AngleX, AngleY, AngleSpeed;
t3dM3X3F mx, mv;
diff --git a/engines/watchmaker/windows_hacks.cpp b/engines/watchmaker/windows_hacks.cpp
index b304ee9ac04..29206d0b7a4 100644
--- a/engines/watchmaker/windows_hacks.cpp
+++ b/engines/watchmaker/windows_hacks.cpp
@@ -26,7 +26,7 @@
namespace Watchmaker {
void ResetDIKbd(void) {
- warning("STUBBED ResetDIKbd\n");
+ warning("STUBBED ResetDIKbd");
}
uint32 timeGetTime() {
@@ -34,12 +34,12 @@ uint32 timeGetTime() {
}
void GetLocalTime(SYSTEMTIME *) {
- warning("STUBBED GetLocalTime\n");
+ warning("STUBBED GetLocalTime");
return;
}
void CopyFile(char *, char *, bool) {
- warning("STUBBED CopyFile\n");
+ warning("STUBBED CopyFile");
}
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/work_dirs.cpp b/engines/watchmaker/work_dirs.cpp
index 48062e31e50..6eb71931fcd 100644
--- a/engines/watchmaker/work_dirs.cpp
+++ b/engines/watchmaker/work_dirs.cpp
@@ -36,7 +36,7 @@ Common::SharedPtr<Common::SeekableReadStream> WorkDirs::resolveFile(const Common
}
Common::String converted = convertedFilename;
delete[] convertedFilename;
- //warning("Resolve: %s\n", path);
+ //warning("Resolve: %s", path);
Common::SharedPtr<Common::SeekableReadStream> stream = nullptr;
if (!noFastFile) {
stream = _fastFile->resolve(converted.c_str());
Commit: 752d35a8a97d8c27bccc2c97a29fac112d12a7ae
https://github.com/scummvm/scummvm/commit/752d35a8a97d8c27bccc2c97a29fac112d12a7ae
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Start working on textures
Changed paths:
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/render/opengl_renderer.h
engines/watchmaker/3d/texture.h
engines/watchmaker/surface.h
engines/watchmaker/tga_util.cpp
engines/watchmaker/tga_util.h
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 7cf346cef74..8f5582db89e 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -23,15 +23,17 @@
#if defined(USE_OPENGL_GAME)
+#include "graphics/pixelformat.h"
#include "watchmaker/3d/render/opengl_2d.h"
-#include "watchmaker/utils.h"
-#include "watchmaker/render.h"
-#include "watchmaker/tga_util.h"
-#include "watchmaker/rect.h"
-#include "watchmaker/work_dirs.h"
+#include "watchmaker/3d/render/opengl_renderer.h"
#include "watchmaker/game.h"
+#include "watchmaker/rect.h"
+#include "watchmaker/render.h"
#include "watchmaker/renderer.h"
#include "watchmaker/sdl_wrapper.h"
+#include "watchmaker/tga_util.h"
+#include "watchmaker/utils.h"
+#include "watchmaker/work_dirs.h"
#include "graphics/opengl/system_headers.h"
@@ -200,11 +202,7 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
glEnable(GL_TEXTURE_2D);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
- error("TODO: Replace SDL textures");
-#if 0
- SDL_GL_BindTexture(bitmap.texture, nullptr, nullptr);
-#endif
- //glBindTexture(GL_TEXTURE_2D, bitmap.texId);
+ glBindTexture(GL_TEXTURE_2D, bitmap.texId);
glLoadIdentity();
glTranslatef(0, 0, -1.0);
//glTranslatef((2.0 / dposx) - 1.0, (2.0 / dposy) - 1.0, 0.0f);
@@ -248,43 +246,6 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
//#endif
}
-// TODO: Deduplicate against the opengl_3d.cpp version
-int createTextureFromSurface2(Surface &surface, int texFormat) {
- unsigned int texId = 0;
- glGenTextures(1, &texId);
-
- glBindTexture(GL_TEXTURE_2D, texId);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-
- error("TODO: compressed textures");
-#if 0
- bool compressed = false;
- switch (texFormat) {
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- compressed = true;
- break;
- case GL_RGBA:
- case GL_RGB:
- compressed = false;
- break;
- default:
- warning("Texture format not handled: %d", texFormat);
- }
-
- if (compressed) {
- glCompressedTexImage2D(GL_TEXTURE_2D, 0, texFormat, surface.width, surface.height, 0, surface.dataSize, surface.data);
- } else {
- glTexImage2D(GL_TEXTURE_2D, 0, texFormat, surface.width, surface.height / 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface.data);
- }
-#endif
- return texId;
-}
-
int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
WorkDirs &workDirs = game.workDirs;
if (flags & rTEXTURESURFACE) {
@@ -299,7 +260,7 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
return -1;
}
- PixelFormat RGBA8888(4, 8, 8, 8, 8, 24, 16, 8, 0);
+ Graphics::PixelFormat RGBA8888(4, 8, 8, 8, 8, 24, 16, 8, 0);
unsigned int pos = gGetBitmapListPosition();
if (pos == 0) {
@@ -309,14 +270,8 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
gTexture *Texture = &gBitmapList[pos];
*Texture = gTexture();
Texture->Flags = CurLoaderFlags;
- Texture->surface = ReadTgaImage(TextName, stream.get(), RGBA8888, Texture->Flags);
-
- error("TODO: textures in OSystem");
-#if 0
- Texture->texture = SDL_CreateTextureFromSurface(game.sdl->renderer, Texture->surface->sdl_surface);
-#endif
- //Texture->texId = createTextureFromSurface2(*Texture->surface, GL_RGBA);
-
+ Texture->surface = ReadTgaImage(TextName, *stream, RGBA8888, Texture->Flags);
+ Texture->texId = createTextureFromSurface(*Texture->surface, GL_RGBA);
Texture->name = TextName;
if (flags & rSURFACESTRETCH) { // Also rSURFACEFLIP
@@ -326,15 +281,15 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
warned = true;
}
// HACK: Just set a dimension at all:
- Texture->DimX = Texture->surface->width;
- Texture->DimY = Texture->surface->height;
+ Texture->DimX = Texture->surface->w;
+ Texture->DimY = Texture->surface->h;
} else {
- Texture->DimX = Texture->surface->width;
- Texture->DimY = Texture->surface->height;
+ Texture->DimX = Texture->surface->w;
+ Texture->DimY = Texture->surface->h;
}
- Texture->RealDimX = Texture->surface->width;
- Texture->RealDimY = Texture->surface->height;
+ Texture->RealDimX = Texture->surface->w;
+ Texture->RealDimY = Texture->surface->h;
// TODO: Colour-keying
return pos;
}
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index bea2bb709d3..e8034e8e787 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -36,6 +36,7 @@
#ifdef USE_OPENGL_GAME
#include "graphics/opengl/system_headers.h"
+#include "watchmaker/tga_util.h"
#define MAXTEXTURES 2000
@@ -343,11 +344,12 @@ gVertex *rLockVertexPtr(void *vb, int flags) {
return nullptr;
}
-Surface *gCreateSurface(int width, int height, void *ptr) {
- auto surface = new Surface();
- surface->data = ptr;
- surface->width = width;
- surface->height = height;
+Graphics::Surface *gCreateSurface(int width, int height, void *ptr) {
+ auto surface = new Graphics::Surface();
+ surface->w = width;
+ surface->h = height;
+ surface->pitch = width * 4; // TODO
+ surface->setPixels(ptr);
return surface;
}
@@ -541,7 +543,7 @@ gTexture *gUserTexture(unsigned int dimx, unsigned int dimy) {
return Texture;
}
-int createTextureFromSurface(Surface &surface, int texFormat) {
+int createTextureFromData(int width, int height, int dataSize, void *data, int texFormat) {
unsigned int texId = 0;
glGenTextures(1, &texId);
@@ -552,22 +554,26 @@ int createTextureFromSurface(Surface &surface, int texFormat) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
bool compressed = false;
- error("TODO: Compressed textures");
-#if 0
+ // TODO: Check both compiletime and runtime for the existence of EXT_texture_compression_s3tc
+
switch (texFormat) {
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
compressed = true;
break;
+ case GL_RGBA:
+ case GL_RGB:
+ compressed = false;
+ break;
default:
warning("Texture format not handled: %d", texFormat);
}
-#endif
+
if (compressed) {
- glCompressedTexImage2D(GL_TEXTURE_2D, 0, texFormat, surface.width, surface.height, 0, surface.dataSize, surface.data);
+ glCompressedTexImage2D(GL_TEXTURE_2D, 0, texFormat, width, height, 0, dataSize, data);
} else {
- glTexImage2D(GL_TEXTURE_2D, 0, texFormat, surface.width, surface.height, 0, surface.dataSize, GL_UNSIGNED_BYTE, surface.data);
+ glTexImage2D(GL_TEXTURE_2D, 0, texFormat, width, height, 0, dataSize, GL_UNSIGNED_BYTE, data);
}
return texId;
@@ -590,20 +596,38 @@ DDSHeader parseDDSHeader(Common::SeekableReadStream &stream) {
uint32 flags = stream.readUint32LE();
header.height = stream.readUint32LE();
header.width = stream.readUint32LE();
- stream.seek(SEEK_SET, size + 4);
+ stream.seek(size + 4, SEEK_SET);
return header;
}
-Surface *parseDDS(Common::SeekableReadStream &stream) {
+struct DDSurface {
+ int width;
+ int height;
+ int dataSize;
+ void *data;
+};
+
+DDSurface *parseDDS(Common::SeekableReadStream &stream) {
DDSHeader header = parseDDSHeader(stream);
auto dataSize = stream.size() - stream.pos();
auto data = new unsigned char[dataSize]();
stream.read(data, dataSize);
- auto result = gCreateSurface(header.width, header.height, data);
+ DDSurface *result = new DDSurface;
+ result->width = header.width;
+ result->height = header.height;
+ result->data = data;
result->dataSize = dataSize;
return result;
}
+int createTextureFromSurface(Graphics::Surface &surface, int texFormat) {
+ return createTextureFromData(surface.w, surface.h, surface.pitch * surface.h, surface.getPixels(), texFormat);
+}
+
+int createCompressedTextureFromSurface(DDSurface &surface) {
+ return createTextureFromData(surface.width, surface.height, surface.dataSize, surface.data, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
+}
+
//*********************************************************************************************
Common::SharedPtr<gMovie> gLoadMovie(WorkDirs &workDirs, const char *TextName) {
bool AlreadyLoaded = FALSE, bAlpha = FALSE;
@@ -704,7 +728,7 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
//uint32 magic,retv;
unsigned long dwWidth = 0, dwHeight = 0;
//DDSURFACEDESC2 DDSurfDesc;
- Surface *lpSSource = nullptr;
+ Graphics::Surface *lpSSource = nullptr;
if (!TextName) return nullptr;
lpSSource = nullptr;
@@ -768,14 +792,11 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
DebugLogFile("gAddMaterial:gLoadTexture: Cannot find %s.\n", AlternateName);
return nullptr;
}
- lpSSource = parseDDS(*stream);
- dwWidth = lpSSource->width;
- dwHeight = lpSSource->height;
- error("TODO");
-#if 0
- Texture->texId = createTextureFromSurface(*lpSSource, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
-#endif
- delete lpSSource;
+ auto compressed = parseDDS(*stream);
+ dwWidth = compressed->width;
+ dwHeight = compressed->height;
+ Texture->texId = createCompressedTextureFromSurface(*compressed);
+ delete compressed;
lpSSource = nullptr;
#if 0
if (gRenderFlags & gDXT1SUPPORTED) {
@@ -810,8 +831,11 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
#endif
stream = nullptr;
} else { // TGA
- //warning("TODO: Handle TGA");
+ auto stream = workDirs.resolveFile(TextName);
+ auto image = ReadTgaImage(TextName, *stream, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), 0); // TODO Flags
+ createTextureFromSurface(*image, GL_RGBA);
#if 0
+ //warning("TODO: Handle TGA");
if (!t3dOpenFile(TextName)) {
DebugLogFile("gAddMaterial:gLoadTexture: Cannot find %s.\n", TextName);
return NULL;
diff --git a/engines/watchmaker/3d/render/opengl_renderer.h b/engines/watchmaker/3d/render/opengl_renderer.h
index 8478ffd9e47..1e5548b5f73 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.h
+++ b/engines/watchmaker/3d/render/opengl_renderer.h
@@ -67,6 +67,8 @@ enum class PrimitiveType {
TRIANGLE
};
+int createTextureFromSurface(Graphics::Surface &surface, int texFormat);
+
class OpenGLRenderer {
public:
void pushModelView();
diff --git a/engines/watchmaker/3d/texture.h b/engines/watchmaker/3d/texture.h
index 67bf3d52ac9..25d9271b267 100644
--- a/engines/watchmaker/3d/texture.h
+++ b/engines/watchmaker/3d/texture.h
@@ -23,6 +23,7 @@
#define WATCHMAKER_TEXTURE_H
#include "common/str.h"
+#include "graphics/surface.h"
#include "watchmaker/surface.h"
namespace Watchmaker {
@@ -31,9 +32,8 @@ struct SDL_Texture;
// Texture structs
struct gTexture {
Common::String name;
- Surface *surface = nullptr; // 2d surface
+ Graphics::Surface *surface = nullptr; // 2d surface
int texId = 0; // OpenGL tex id
- SDL_Texture *texture = nullptr;
int RealDimX = 0; // original dimensions
int RealDimY = 0; // original dimensions
int DimX = 0; // current dimensions
@@ -42,7 +42,7 @@ struct gTexture {
int Flags = 0; // Flags
bool isEmpty() {
- return texId == 0 && texture == nullptr;
+ return texId == 0;
}
};
diff --git a/engines/watchmaker/surface.h b/engines/watchmaker/surface.h
index b69fb571200..c313695669a 100644
--- a/engines/watchmaker/surface.h
+++ b/engines/watchmaker/surface.h
@@ -24,15 +24,6 @@
namespace Watchmaker {
-struct SDL_Surface;
-struct Surface {
- int width = 0;
- int height = 0;
- void *data = nullptr;
- int dataSize = 0;
- SDL_Surface *sdl_surface;
-};
-
} // End of namespace Watchmaker
#endif // WATCHMAKER_SURFACE_H
diff --git a/engines/watchmaker/tga_util.cpp b/engines/watchmaker/tga_util.cpp
index a8e4278f9f2..f842a129d2e 100644
--- a/engines/watchmaker/tga_util.cpp
+++ b/engines/watchmaker/tga_util.cpp
@@ -19,476 +19,28 @@
*
*/
-#include <cstring>
-#include <cstdlib>
-#include "SDL_image.h"
#include "watchmaker/tga_util.h"
+#include "image/tga.h"
#include "watchmaker/types.h"
#include "watchmaker/render.h"
#include "watchmaker/utils.h"
namespace Watchmaker {
-#pragma pack(1)
-struct STGAHeader {
- unsigned char idLength; // length of ID string
- unsigned char mapType; // color map type - pres/abs/grey/col
- unsigned char imageType; // image type code - u/c cm/bw/tc
- unsigned short mapOrigin; // starting index of map
- unsigned short mapLength; // length of map
- unsigned char mapWidth; // width of map in bits
- unsigned short xOrigin; // x-origin of image
- unsigned short yOrigin; // y-origin of image
- unsigned short imageWidth; // width of image
- unsigned short imageHeight; // height of image
- unsigned char pixelDepth; // bits per pixel
- unsigned char imageDesc; // image descriptor - alpha/ori/interleave
+const Graphics::PixelFormat RGBA8888(32, 8, 8, 8, 8, 24, 16, 8, 0);
- STGAHeader(Common::SeekableReadStream &stream) {
- idLength = stream.readByte();
- mapType = stream.readByte();
- imageType = stream.readByte();
- mapOrigin = stream.readUint16LE();
- mapLength = stream.readUint16LE();
- mapWidth = stream.readByte();
- xOrigin = stream.readUint16LE();
- yOrigin = stream.readUint16LE();
- imageWidth = stream.readUint16LE();
- imageHeight = stream.readUint16LE();
- pixelDepth = stream.readByte();
- imageDesc = stream.readByte();
- stream.seek(SEEK_CUR, idLength);
+Graphics::Surface *ReadTgaImage(const char *Name, Common::SeekableReadStream &stream, Graphics::PixelFormat format, unsigned int flag) {
+ Image::TGADecoder tgaDecoder;
+ if (!tgaDecoder.loadStream(stream)) {
+ error("Failed to load TGA: %s", Name);
}
-};
-#pragma pack()
-
-char TGAPal[768];//, *TGAFileMem;
-unsigned int TGAFileLen; //, CurTGAFilePointer;
-const PixelFormat RGBA8888(32, 8, 8, 8, 8, 24, 16, 8, 0);
-
-/* -----------------10/06/99 16.07-------------------
- * SaveTga
- * --------------------------------------------------*/
-unsigned char SaveTga(const char *s, unsigned char *image, unsigned short xdim, unsigned short ydim, unsigned char flag) {
-// 32-bit tga header
- uint8 TgaHeader[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x20, 0x00};
-#if 0
-// t3dU8 TgaHeader2[]={0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x18, 0x00};
- FILE *f;
- int16 i, j;
- uint8 r, g, b, a;
-
- if (!(f = fopen(s, "wb"))) // open destination file
- return 0;
-
- TgaHeader[12] = (uint8)(xdim & 0xff); // encode dimensions
- TgaHeader[13] = (uint8)(xdim >> 8) & 0xff;
- TgaHeader[14] = (uint8)(ydim & 0xff);
- TgaHeader[15] = (uint8)(ydim >> 8) & 0xff;
- fwrite(TgaHeader, 1, 18, f); // write patched header
-
- for (i = 0; i < ydim; i++) {
- for (j = 0; j < xdim; j++) {
- r = (uint8)image[i * xdim * 4 + j * 4 + 0]; // gets r,g,b components
- g = (uint8)image[i * xdim * 4 + j * 4 + 1];
- b = (uint8)image[i * xdim * 4 + j * 4 + 2];
- if (flag & TGA_READALPHABITS)
- a = (uint8)image[i * xdim * 4 + j * 4 + 3]; // gets alpha val
- else
- a = 0;
-
- fwrite(&r, 1, 1, f); // write r,g,b,a, components
- fwrite(&g, 1, 1, f);
- fwrite(&b, 1, 1, f);
- fwrite(&a, 1, 1, f);
- }
- }
- fclose(f);
-#endif
- return 1;
-}
-
-/* -----------------10/11/98 16.22-------------------
- * TGAread - reads from a preloaded file
- * --------------------------------------------------*/
-unsigned int TGAread(void *ptr, unsigned int size, unsigned int n, Common::SeekableReadStream &stream) {
- unsigned int len = size * n;
+ auto surface = tgaDecoder.getSurface();
+ return surface->convertTo(format);
#if 0
- if ((!ptr) || (!len) || (/*stream.pos() > stream.size()*/)) {
- warning("Overrun TGA parsing");
- return 0;
- }
-#endif
- stream.read(ptr, len);
-
- return n;
-}
-
-/* -----------------10/11/98 14.59-------------------
- * decode a TGA RLE line
- * --------------------------------------------------*/
-static int ReadRLERow(unsigned char *p, int n, int bpp, Common::SeekableReadStream &stream) {
-#define RLEBUFSIZ 512 // size of largest possible RLE packet
-
- int inRawPacket = 0; // flags processing state for RLE data
- int inRLEPacket = 0; // flags processing state for RLE data
- unsigned int packetSize = 0; // records current RLE packet size in bytes
- char rleBuf[RLEBUFSIZ] = {};
-
- unsigned int value = 0;
- int i = 0;
- static char *q;
-
- while (n > 0) {
- if (inRLEPacket) {
- if ((int)(packetSize * bpp) > n) {
- value = n / bpp; // calculate pixel count
- packetSize -= value;
- n = 0;
- } else {
- n -= packetSize * bpp;
- value = packetSize;
- packetSize = 0;
- inRLEPacket = 0;
- }
- while (value > 0) {
- *p++ = rleBuf[0];
- if (bpp > 1) *p++ = rleBuf[1];
- if (bpp > 2) *p++ = rleBuf[2];
- if (bpp > 3) *p++ = rleBuf[3];
- value--;
- }
- } else if (inRawPacket) {
- if ((int)(packetSize * bpp) > n) {
- value = n;
- packetSize -= n / bpp;
- n = 0;
- } else {
- value = packetSize * bpp; // calculate byte count
- n -= value;
- inRawPacket = 0;
- }
- for (i = 0; i < (int)value; ++i) *p++ = *q++;
- } else {
-// No accumulated data in buffers, so read from file
- TGAread(&packetSize, 1, 1, stream);
- if (packetSize & 0x80) {
- packetSize &= 0x7f;
- packetSize++;
- if ((int)(packetSize * bpp) > n) {
- value = n / bpp; // calculate pixel count
- packetSize -= value;
- inRLEPacket = 1;
- n = 0;
- } else {
- n -= packetSize * bpp;
- value = packetSize;
- }
- if (TGAread(rleBuf, 1, bpp, stream) != (size_t)bpp) return (-1);
- while (value > 0) {
- *p++ = rleBuf[0];
- if (bpp > 1) *p++ = rleBuf[1];
- if (bpp > 2) *p++ = rleBuf[2];
- if (bpp > 3) *p++ = rleBuf[3];
- value--;
- }
- } else {
- packetSize++;
-// Maximum for packetSize is 128 so as long as RLEBUFSIZ
-// is at least 512, and bpp is not greater than 4
-// we can read in the entire raw packet with one operation.
- if (TGAread(rleBuf, bpp, packetSize, stream) != packetSize)
- return (-1);
-// But is there enough room to copy them to our line buffer?
- if ((int)(packetSize) * bpp > n) {
- value = n; // number of bytes remaining
- packetSize -= n / bpp;
- inRawPacket = 1;
- n = 0;
- } else {
- value = packetSize * bpp; // calculate byte count
- n -= value;
- }
- for (i = 0, q = rleBuf; i < (int)value; ++i) *p++ = *q++;
- }
- }
- }
- return (0);
-}
-
-/* -----------------10/11/98 15.01-------------------
- * Loads and decode a TGA Row
- * --------------------------------------------------*/
-static bool loadTGARow(STGAHeader &th, unsigned char *buf, Common::SeekableReadStream &stream) {
- unsigned char tmp[4];
- int a, bpp, bpc;
-
- bpp = (th.pixelDepth + 7) >> 3;
- bpc = (th.mapWidth + 7) >> 3;
-
- if (buf == nullptr)
- return false;
-
-// if compressed
- if (th.imageType > 8)
- ReadRLERow(buf, th.imageWidth * bpp, bpp, stream);
-// if uncompressed
- else
- TGAread(buf, bpp, th.imageWidth, stream);
-
-// adjust pixel format
- for (a = (th.imageWidth - 1); a >= 0; a--) {
- switch (th.pixelDepth) {
- case 32:
- tmp[0] = buf[a * bpp + 3];
- tmp[1] = buf[a * bpp + 0];
- tmp[2] = buf[a * bpp + 1];
- tmp[3] = buf[a * bpp + 2];
- break;
-
- case 24:
- tmp[0] = 0;
- tmp[1] = buf[a * bpp + 0];
- tmp[2] = buf[a * bpp + 1];
- tmp[3] = buf[a * bpp + 2];
- break;
-
- case 16:
- case 15:
- tmp[0] = 0;
- tmp[1] = ((buf[a * bpp + 0] & 0x1F) << 3);
- tmp[2] = (((buf[a * bpp + 1] & 0x3) << 3) + ((buf[a * bpp + 0] & 0xE0) >> 5)) << 3;
- tmp[3] = ((buf[a * bpp + 1] & 0x7F) << 1);
- break;
-
- case 8:
- tmp[0] = 0;
- tmp[1] = TGAPal[ buf[a] * bpc + 0 ];
- tmp[2] = TGAPal[ buf[a] * bpc + 1 ];
- tmp[3] = TGAPal[ buf[a] * bpc + 2 ];
- break;
- }
-
-// stores values
- buf[a * 4 + 0] = tmp[0];
- buf[a * 4 + 1] = tmp[1];
- buf[a * 4 + 2] = tmp[2];
- buf[a * 4 + 3] = tmp[3];
- }
-
- return (true);
-}
-
-/* -----------------10/06/99 16.08-------------------
- * loads tga file using d3d puxel format
- * --------------------------------------------------*/
-Surface *ReadTgaImage(const char *Name, Common::SeekableReadStream *stream, PixelFormat &format, unsigned int flag) {
-#if 0
- uint8 *data = new uint8[stream->size()];
- stream->read(data, stream->size());
- auto rwops = SDL_RWFromConstMem(data, stream->size());
- auto loaded = IMG_LoadTGA_RW(rwops);
- Surface *surface = new Surface;
- surface->width = loaded->w;
- surface->height = loaded->h;
- surface->sdl_surface = loaded;
- surface->data = loaded->pixels;
- surface->dataSize = surface->width*surface->height*loaded->format->BytesPerPixel;
- free(rwops);
- delete[] data;
- return surface;
-
- //uint32 dwWidth, dwHeight;
- uint32 *lpLP;
- uint16 *lpSP;
- byte *lpCP;
- unsigned long m;
- int s = 0, i, j;
- int alpha_shift = 0, alpha_scale = 1;
- char bAlpha = 0, bFlip = 0;
- unsigned char *TGARow = nullptr;
-
if (flag & 1) // read alpa byte?
bAlpha = 1;
if (flag & rSURFACEFLIP) // flip tga orientation?
bFlip = 1;
-
- if (!stream->good())
- return nullptr;
-
- STGAHeader th(*stream);
-
- // TODO: Implement
- int rBitMask = (format.rBits() << 1) - 1;
- int gBitMask = (format.gBits() << 1) - 1;
- int bBitMask = (format.bBits() << 1) - 1;
- int aBitMask = (format.aBits() << 1) - 1;
- int rgbaMask = (rBitMask << format.rShift) |
- (gBitMask << format.gShift) |
- (bBitMask << format.bShift) |
- (aBitMask << format.aShift);
- // Determine the red, green and blue masks' shift and scale.
- /*
- for (s = 0, m = rBitMask; !(m & 1);
- s++, m >>= 1);
- int red_shift = s;
- int red_scale = 255 / (rBitMask >> s);
- for (s = 0, m = gBitMask; !(m & 1);
- s++, m >>= 1);
- int green_shift = s;
- int green_scale = 255 / (gBitMask >> s);
- for (s = 0, m = bBitMask; !(m & 1);
- s++, m >>= 1);
- int blue_shift = s;
- int blue_scale = 255 / (bBitMask >> s);
- if (bAlpha) {
- for (s = 0, m = rgbaMask; !(m & 1); s++, m >>= 1);
-
- alpha_shift = s;
- if ((rgbaMask >> s))
- alpha_scale = 255 / (rgbaMask >> s);
- else
- alpha_scale = 255;
-
- if (alpha_scale == 0)
- alpha_scale = 1;
- }
- */
- int red_scale = 0;
- int green_scale = 0;
- int blue_scale = 0;
-
-
- int rowWidth = format.bytesPerPixel * th.imageWidth;
- int dstHeight = th.imageHeight;
-
- Surface *dst = new Surface();
- dst->data = new byte[rowWidth * dstHeight] {};
- dst->width = rowWidth;
- dst->height = dstHeight;
- int pitch = rowWidth;
-
-// Each RGB bit count requires different pointers
- switch (format.bytesPerPixel * 8) {
- case 32 :
- TGARow = new byte[rowWidth] {};
- for (j = 0; j < th.imageHeight; j++) {
-// Point to next row in texture surface
- if (bFlip)
- lpLP = (uint32 *)(((char *)dst->data) + pitch * ((dstHeight - 1) - j));
- else
- lpLP = (uint32 *)(((char *)dst->data) + pitch * j);
- if (!loadTGARow(th, TGARow, *stream)) { // read a row
- DebugLogWindow("Error reading TGA row (loadTGARow).");
- return nullptr;
- }
- for (i = 0; i < th.imageWidth; i++) {
- unsigned int o_r, o_g, o_b;
- unsigned int r, g, b, a;
-
-// Read each value, scale it and shift it into position
- r = ((o_r = TGARow[i * 4 + 3]) / red_scale);
- g = ((o_g = TGARow[i * 4 + 2]) / green_scale);
- b = ((o_b = TGARow[i * 4 + 1]) / blue_scale);
- *lpLP = (r << format.rShift) | (g << format.gShift) | (b << format.bShift) ;//| (255 << format.aShift);
- if (bAlpha) {
- a = TGARow[i * 4 + 0] / alpha_scale;
- a = 0;
- if (r != 0 && g != 0 && b != 0)
- a = 255 / alpha_scale;
- else
- a = 0;
- *lpLP |= (a << format.aShift);
- }
- lpLP++;
- }
- }
- delete [] TGARow;
- break;
- case 16 :
- TGARow = new unsigned char[ th.imageWidth * 4]{};
- for (j = 0; j < (int)th.imageHeight; j++) {
- if (bFlip)
- lpSP = (unsigned short *)(((char *)dst->data) + pitch * ((dstHeight - 1) - j));
- else
- lpSP = (unsigned short *)(((char *)dst->data) + pitch * j);
- if (!loadTGARow(th, TGARow, *stream)) {
- DebugLogWindow("Error reading TGA row (loadTGARow).");
- return nullptr;
- }
-
- for (i = 0; i < (int)th.imageWidth; i++) {
- unsigned int o_r, o_g, o_b;
- unsigned int r, g, b, a;
-
-// Read each value, scale it and shift it into position
- r = ((o_r = TGARow[i * 4 + 3]) / red_scale);
- g = ((o_g = TGARow[i * 4 + 2]) / green_scale);
- b = ((o_b = TGARow[i * 4 + 1]) / blue_scale);
- a = 255;
- if (bAlpha) {
-// a = TGARow[i*4+0];
-// if (a==0)
- {
- a = ((o_r + o_g + o_b) / 3);
- if (a)
- a = 255;
- }
-// else
- {
-// a=a;
- }
- a /= alpha_scale;
-
- /* if (a==0)
- {
- r=255;
- g=b=0;
- }
- */
- }
- *lpSP = (unsigned short)((r << format.rShift) | (g << format.gShift) | (b << format.bShift));// | (a << format.aShift));
- lpSP++;
- }
- }
- delete[] TGARow;
- break;
- case 8:
- TGARow = new unsigned char[th.imageWidth * 4]{};
- for (j = 0; j < (int)th.imageHeight; j++) {
- if (bFlip)
- lpCP = (unsigned char *)(((char *)dst->data) + pitch * ((dstHeight - 1) - j));
- else
- lpCP = (unsigned char *)(((char *)dst->data) + pitch * j);
- if (!loadTGARow(th, TGARow, *stream)) {
- DebugLogWindow("Error reading TGA row (loadTGARow).");
- return nullptr;
- }
- for (i = 0; i < (int)th.imageWidth; i++) {
- unsigned int r, g, b, a;
- r = TGARow[i * 4 + 3] / red_scale;
- g = TGARow[i * 4 + 2] / green_scale;
- b = TGARow[i * 4 + 1] / blue_scale;
- *lpCP = (r << format.rShift) | (g << format.gShift) | (b << format.bShift);
- if (bAlpha) {
- a = TGARow[i * 4 + 0] / alpha_scale;
- a = 0;
- if (r != 0 && g != 0 && b != 0)
- a = 255 / alpha_scale;
- *lpCP |= (a << alpha_shift);
- }
- lpCP++;
- }
- }
- delete[] TGARow;
- break;
- default:
-// This wasn't a format I recognize
- warning("Unknown pixel format (loadtex).");
- return nullptr;
- }
-
- return dst;
#endif
}
diff --git a/engines/watchmaker/tga_util.h b/engines/watchmaker/tga_util.h
index dee4ab2eaf1..aad222d0643 100644
--- a/engines/watchmaker/tga_util.h
+++ b/engines/watchmaker/tga_util.h
@@ -23,100 +23,16 @@
#define WATCHMAKER_TGA_UTIL_H
#include "common/stream.h"
-#include "watchmaker/surface.h"
+#include "graphics/pixelformat.h"
+#include "graphics/surface.h"
#define TGA_READALPHABITS (1<<0)
#define TGA_WRITEALPHABITS (1<<1)
namespace Watchmaker {
-/*
-unsigned char SaveTga(const char *s,unsigned char *image,unsigned short xdim,unsigned short ydim,unsigned char flag);
-unsigned int TGAread(void *ptr,unsigned int size,unsigned int n);
-int loadTGAHeader(unsigned long *width,unsigned long *height);
- */
-//int preloadTGAHeader(unsigned long *width,unsigned long *height);
-/*
-void unloadTGAHeader();
-int ReadTgaImage(char *Name,struct _DDSURFACEDESC2 *format,unsigned int flag);
-*/
-
-struct PixelFormat {
- uint8 bytesPerPixel;
- uint8 rLoss, gLoss, bLoss, aLoss; /**< Precision loss of each color component. */
- uint8 rShift, gShift, bShift, aShift; /**< Binary left shift of each color component in the pixel value. */
-
- /** Default constructor that creates a null pixel format. */
- inline PixelFormat() {
- bytesPerPixel =
- rLoss = gLoss = bLoss = aLoss =
- rShift = gShift = bShift = aShift = 0;
- }
-
- /** Construct a pixel format based on the provided arguments.
- *
- * Examples:
- *
- * - RGBA8888:
- * @code
- * BytesPerPixel = 4, RBits = GBits = BBits = ABits = 8, RShift = 24, GShift = 16, BShift = 8, AShift = 0
- * @endcode
- * - ABGR8888:
- * @code
- * BytesPerPixel = 4, RBits = GBits = BBits = ABits = 8, RShift = 0, GShift = 8, BShift = 16, AShift = 24
- * @endcode
- * - RGB565:
- * @code
- * BytesPerPixel = 2, RBits = 5, GBits = 6, BBits = 5, ABits = 0, RShift = 11, GShift = 5, BShift = 0, AShift = 0
- * @endcode
- */
-
- inline PixelFormat(uint8 BytesPerPixel,
- uint8 RBits, uint8 GBits, uint8 BBits, uint8 ABits,
- uint8 RShift, uint8 GShift, uint8 BShift, uint8 AShift) {
- bytesPerPixel = BytesPerPixel;
- rLoss = 8 - RBits;
- gLoss = 8 - GBits;
- bLoss = 8 - BBits;
- aLoss = 8 - ABits;
- rShift = RShift;
- gShift = GShift;
- bShift = BShift;
- aShift = AShift;
- }
-
- /**
- * Return the number of red component bits.
- */
- inline uint8 rBits() const {
- return (8 - rLoss);
- }
-
- /**
- * Return the number of green component bits.
- */
- inline uint8 gBits() const {
- return (8 - gLoss);
- }
-
- /**
- * Return the number of blue component bits.
- */
- inline uint8 bBits() const {
- return (8 - bLoss);
- }
-
- /**
- * Return the number of alpha component bits.
- */
- inline uint8 aBits() const {
- return (8 - aLoss);
- }
-
-};
-
//const PixelFormat RGBA8888;
-Surface *ReadTgaImage(const char *Name, Common::SeekableReadStream *stream, PixelFormat &format, unsigned int flag);
+Graphics::Surface *ReadTgaImage(const char *Name, Common::SeekableReadStream &stream, Graphics::PixelFormat format, unsigned int flag);
} // End of namespace Watchmaker
Commit: 86ba5e2f4b0cfb5e65c2e538e90bc239ba3d8ad8
https://github.com/scummvm/scummvm/commit/86ba5e2f4b0cfb5e65c2e538e90bc239ba3d8ad8
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Make t3dGetFileDate just check that the file exists.
Although for now we do so in a very wasteful way.
Changed paths:
engines/watchmaker/ll/ll_system.cpp
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index c3edb5c5697..c6d6ecf85a3 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -163,15 +163,10 @@ int t3dAccessFile(char *name) {
}
bool t3dGetFileDate(uint32 *date, uint32 *time, const char *name) {
-#if 0
- FILE *f = fopen(name, "rb");
- //warning("STUBBED: t3dGetFileDate(%s)", name);
- if (f) {
- fclose(f);
+ auto stream = openFile(name);
+ warning("TODO: t3dGetFileDate is currently super-inefficient");
+ if (stream)
return true;
- }
-#endif
- error("TODO: t3dGetFileDate");
return false;
}
Commit: 183baca702742f6c0611cd3f401a50e7f2ded3ea
https://github.com/scummvm/scummvm/commit/183baca702742f6c0611cd3f401a50e7f2ded3ea
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix check for empty string.
Changed paths:
engines/watchmaker/3d/loader.cpp
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index bc39229367b..0b87c7f3450 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -88,7 +88,7 @@ struct _t3dLOADLIST *GetFromLoadList(void) {
int32 a;
for (a = 0; a < MAX_T3D_LOADLIST_ITEMS; a++) {
- if (t3dLoadList[a].pname[0])
+ if (!t3dLoadList[a].pname.empty())
return &t3dLoadList[a];
}
Commit: cc5dd711fc7ee209964d7421eb0ee1f5d7972b46
https://github.com/scummvm/scummvm/commit/cc5dd711fc7ee209964d7421eb0ee1f5d7972b46
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix initializing struct that is no longer POD.
Changed paths:
engines/watchmaker/3d/render/opengl_3d.cpp
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index e8034e8e787..7724142655b 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -469,7 +469,7 @@ gTexture *gUserTexture(unsigned int dimx, unsigned int dimy) {
return nullptr;
}
Texture = &gTextureList[pos];
- memset(Texture, 0, sizeof(gTexture));
+ *Texture = gTexture();
Texture->Flags = CurLoaderFlags;
{
Commit: eb276dece4aa59aad3bea6b3e595dcb31d6ea032
https://github.com/scummvm/scummvm/commit/eb276dece4aa59aad3bea6b3e595dcb31d6ea032
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Start refactoring t3dFACE.
Changed paths:
A engines/watchmaker/3d/t3d_face.cpp
A engines/watchmaker/3d/t3d_face.h
engines/watchmaker/3d/geometry.cpp
engines/watchmaker/3d/light.cpp
engines/watchmaker/3d/loader.cpp
engines/watchmaker/3d/material.cpp
engines/watchmaker/3d/material.h
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/t3d_body.cpp
engines/watchmaker/3d/t3d_mesh.cpp
engines/watchmaker/3d/t3d_mesh.h
engines/watchmaker/classes/do_operate.cpp
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/ll/ll_mesh.cpp
engines/watchmaker/ll/ll_mesh.h
engines/watchmaker/module.mk
engines/watchmaker/render.cpp
engines/watchmaker/t3d.h
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index 7279202ed9e..ca035bda4c7 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -19,20 +19,21 @@
*
*/
-#include "watchmaker/t3d.h"
+#include "watchmaker/3d/mem_management.h"
#include "watchmaker/3d/geometry.h"
#include "watchmaker/3d/light.h"
-#include "watchmaker/3d/mem_management.h"
+#include "watchmaker/3d/loader.h"
#include "watchmaker/3d/math/llmath.h"
+#include "watchmaker/3d/t3d_face.h"
#include "watchmaker/3d/t3d_body.h"
#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/globvar.h"
#include "watchmaker/ll/ll_system.h"
#include "watchmaker/render.h"
+#include "watchmaker/renderer.h"
+#include "watchmaker/t3d.h"
#include "watchmaker/utils.h"
-#include "watchmaker/3d/loader.h"
#include "watchmaker/windows_hacks.h"
-#include "watchmaker/globvar.h"
-#include "watchmaker/renderer.h"
#define SKY_SPEED 0.00005f
#define EXPRESSION_SET_LEN 14
@@ -2182,7 +2183,7 @@ enabledinmirror:
* ProcessWater
* --------------------------------------------------*/
void ProcessWater(t3dMESH &mesh, int32 CurPass, int32 MaxPass) {
- MaterialPtr mat = mesh.FList[0].mat;
+ MaterialPtr mat = mesh.FList[0].getMaterial();
uint32 dimx = mat->Texture->DimX;
uint32 dimy = mat->Texture->DimY;
int32 *dest = mesh.WaterBuffer2 + dimx * 2, *source = mesh.WaterBuffer1 + dimx * 2;
@@ -2203,7 +2204,7 @@ void ProcessWater(t3dMESH &mesh, int32 CurPass, int32 MaxPass) {
* t3dRenderWater
* --------------------------------------------------*/
void t3dRenderWater(t3dMESH &mesh, uint32 Type) {
- MaterialPtr &mat = mesh.FList[0].mat;
+ MaterialPtr mat = mesh.FList[0].getMaterial();
int32 pitch, Xoffset, Yoffset;
int32 dimx = (int32)mat->Texture->DimX;
int32 dimy = (int32)mat->Texture->DimY;
@@ -2340,10 +2341,8 @@ void t3dMoveTexture(gVertex *gv, uint32 NumVerts, t3dF32 XInc, t3dF32 YInc) {
* --------------------------------------------------*/
void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
uint32 pl;
- int32 j, *nf;
+ int32 j;
int16 LastT1, LastT2, T1, T2;
- uint32 F1, F2;
- MaterialPtr Material;
if (mesh->Flags & T3D_MESH_PORTAL) { // se e' un portale
if (bOrigRoom && !bDisableMirrors && (!(mesh->Flags & T3D_MESH_NOPORTALCHECK)) && (mesh->PortalList)) {
@@ -2364,26 +2363,23 @@ void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
LastT1 = LastT2 = -2;
T1 = T2 = -1;
- F1 = F2 = 0;
- Material = nullptr;
- Common::Array<uint16> *target = nullptr;
+
+ MaterialPtr target = nullptr;
int targetIndex = 0;
for (uint32 i = 0; i < mesh->NumFaces(); i++) {
t3dFACE &f = mesh->FList[i];
- if (!f.mat || !(f.flags & T3D_FACE_VISIBLE))
+ if (!f.getMaterial() || !(f.flags & T3D_FACE_VISIBLE))
continue;
- Material = f.mat;
+ MaterialPtr Material = f.getMaterial();
T1 = Material->Texture->ID;
- F1 = Material->Flags;
if (!bNoLightmapsCalc && f.lightmap) {
T2 = f.lightmap->Texture->ID;
- F2 = f.lightmap->Flags;
} else
T2 = -1;
- if (Material->Flags & T3D_MATERIAL_ENVIROMENT) { // se ha l'enviroment
+ if (Material->hasFlag(T3D_MATERIAL_ENVIROMENT)) { // se ha l'enviroment
t3dV3F v;
t3dV3F *n;
gVertex *gv;
@@ -2429,11 +2425,9 @@ void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
continue;
}
- nf = &(Material->AddictionalMaterial[j]->NumFaces);
- target = &Material->AddictionalMaterial[j]->FacesList;
+ target = Material->AddictionalMaterial[j];
} else {
- nf = &(Material->NumFaces);
- target = &Material->FacesList;
+ target = Material;
}
LastT1 = T1;
LastT2 = T2;
@@ -2441,28 +2435,9 @@ void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
// Something is wrong here, as the original game seems to be just writing to NumFaces + 0,1,2, as if there
// was space allocated there.
-#if 0
- target->at(*nf + 0) = f.MatVertexIndex[0];
- target->at(*nf + 1) = f.MatVertexIndex[1];
- target->at(*nf + 2) = f.MatVertexIndex[2];
-#endif
-
- if (*nf + 3 >= target->size()) {
- // TODO: Why is this hack necessary?
- warning("NumFaces: %d, Size: %d", *nf, target->size());
-/* static bool warned = false;
- if (!warned) {
- warned = true;*/
- warning("Dropping face");
-// }
- target->resize(*nf + 4);
- //continue;
+ for (int v = 0; v < 3; v++) {
+ target->addFace(f.MatVertexIndex[v]);
}
- //warning("LOOK INTO WHY THIS IS BROKEN");
- (*target)[(*nf + 0)] = f.MatVertexIndex[0];
- (*target)[(*nf + 1)] = f.MatVertexIndex[1];
- (*target)[(*nf + 2)] = f.MatVertexIndex[2];
- *nf += 3;
StatNumTris++;
}
@@ -2525,7 +2500,7 @@ void t3dCAMERA::normalizedSight() {
void t3dCalcHalos(t3dBODY *b) {
gMaterial *Material;
int16 T1;
- uint32 F1, uvbc;
+ uint32 uvbc;
uint32 i;
gVertex *gv;
t3dF32 size;
@@ -2561,7 +2536,6 @@ void t3dCalcHalos(t3dBODY *b) {
if (l.Type & T3D_LIGHT_FLARE) {
Material = &l.Material[0];
T1 = Material->Texture->ID;
- F1 = Material->Flags;
size = l.FlareSize;
@@ -2585,18 +2559,15 @@ void t3dCalcHalos(t3dBODY *b) {
v3.z = 0.0f;
t3dVectTransformInv(&v3, &v3, &t3dCurViewMatrix);
- uint16 &fp = Material->FacesList[Material->NumFaces];
- Material->FacesList[Material->NumFaces + 0] = 0 + uvbc;
- Material->FacesList[Material->NumFaces + 1] = 1 + uvbc;
- Material->FacesList[Material->NumFaces + 2] = 2 + uvbc;
+ for (int f = 0; f < 3; f++) {
+ Material->addFace(f + uvbc);
+ }
StatNumTris++;
- Material->NumFaces += 3;
- Material->FacesList[Material->NumFaces + 3] = 2 + uvbc;
- Material->FacesList[Material->NumFaces + 4] = 3 + uvbc;
- Material->FacesList[Material->NumFaces + 5] = 1 + uvbc;
+ Material->addFace(2 + uvbc);
+ Material->addFace(3 + uvbc);
+ Material->addFace(1 + uvbc);
StatNumTris++;
- Material->NumFaces += 3;
gv[0].x = v0.x + l.Source.x;
gv[0].y = v0.y + l.Source.y;
@@ -2642,7 +2613,7 @@ void t3dCalcHalos(t3dBODY *b) {
* --------------------------------------------------*/
void t3dAddParticle(gMaterial *Material, t3dV3F *Source, t3dF32 size, t3dV3F Color, uint32 num) {
int16 T1;
- uint32 F1, uvbc;
+ uint32 uvbc;
gVertex *gv;
t3dV3F v0, v1, v2, v3;
uint32 rr, gg, bl, i;
@@ -2655,7 +2626,6 @@ void t3dAddParticle(gMaterial *Material, t3dV3F *Source, t3dF32 size, t3dV3F Col
gv += uvbc;
T1 = Material->Texture->ID;
- F1 = Material->Flags;
uint32 faceOffset = Material->NumFaces;
@@ -2889,7 +2859,7 @@ void t3dAnimLights(t3dBODY *b) {
* t3dCheckMaterialVB
* --------------------------------------------------*/
void t3dCheckMaterialVB(MaterialPtr mat) {
- if (!mat || (mat->NumAllocatedVerts < 3))
+ if (!mat || (mat->NumAllocatedVerts() < 3))
return ;
int i;
@@ -2903,7 +2873,7 @@ void t3dCheckMaterialVB(MaterialPtr mat) {
//warning("TODO: Implement t3dCheckMaterialVB");
// gv = rLockVertexPtr(mat->VB, DDLOCK_WRITEONLY | DDLOCK_NOSYSLOCK);
mat->VBO->_buffer.clear();
- for (int i = 0; i < mat->NumAllocatedVerts; i++) {
+ for (int i = 0; i < mat->NumAllocatedVerts(); i++) {
auto vert = *mat->VertsList[i];
mat->VBO->_buffer.push_back(vert);
//memcpy(gv, mat->VertsList[i], sizeof(gVertex));
diff --git a/engines/watchmaker/3d/light.cpp b/engines/watchmaker/3d/light.cpp
index f457137f6a5..089de32e9f7 100644
--- a/engines/watchmaker/3d/light.cpp
+++ b/engines/watchmaker/3d/light.cpp
@@ -390,7 +390,8 @@ t3dLIGHT::t3dLIGHT(t3dBODY *b, WorkDirs &workDirs, Common::SeekableReadStream &s
#if 0
Light[light].Material[0].VB = rGetUserVertexBuffer();
#endif
- Material[0].NumAllocatedVerts += 45;
+ warning("TODO: Lights");
+ //Material[0].NumAllocatedVerts += 45;
#endif
}
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index 0b87c7f3450..fe57b12faee 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -125,7 +125,7 @@ t3dCAMERAPATH::t3dCAMERAPATH(Common::SeekableReadStream &stream) {
int numPoints = stream.readSint16LE();
CarrelloDist = stream.readSint32LE();
- PList.reserve(numPoints);
+ PList.resize(numPoints);
for (int j = 0; j < numPoints; j++) {
PList[j].x = stream.readFloatLE() * SCALEFACTOR;
PList[j].y = stream.readFloatLE() * SCALEFACTOR;
@@ -446,7 +446,8 @@ void t3dLoadSky(WGame &game, t3dBODY * /*body*/) {
}
for (n = 0; n < t3dSky->NumMaterials(); n++) {
- t3dSky->MatTable[n]->Flags |= T3D_MATERIAL_SKY | T3D_MATERIAL_NOLIGHTMAP;
+ t3dSky->MatTable[n]->addProperty(T3D_MATERIAL_SKY);
+ t3dSky->MatTable[n]->addProperty(T3D_MATERIAL_NOLIGHTMAP);
}
}
@@ -463,7 +464,7 @@ Common::SharedPtr<VertexBuffer> t3dAddVertexBuffer(t3dBODY *b, uint32 numv) {
void t3dOptimizeMaterialList(t3dBODY *b) {
for (int i = 0; i < b->NumMaterials(); i++) { // Scorre tutti materilai di un body
MaterialPtr Mat = b->MatTable[i];
- if ((Mat == nullptr) || /*(!Mat->Texture->Name) ||*/ (Mat->Movie) || (Mat->Flags & T3D_MATERIAL_MOVIE)) // Se non esiste o non ha texture
+ if ((Mat == nullptr) || /*(!Mat->Texture->Name) ||*/ (Mat->Movie) || (Mat->hasFlag(T3D_MATERIAL_MOVIE))) // Se non esiste o non ha texture
continue; // esce
for (int j = 0; j < b->NumMaterials(); j++) { // Cerca materiali uguali
@@ -505,10 +506,10 @@ void t3dFinalizeMaterialList(t3dBODY *b) {
#endif
for (uint32 j = 0; j < Mesh.NumFaces(); j++) {
t3dFACE &Face = Mesh.FList[j];
- MaterialPtr Mat = Face.mat;
+ MaterialPtr Mat = Face.getMaterial();
if (Face.lightmap) {
Mat = nullptr;
- for (auto material : Face.mat->AddictionalMaterial) {
+ for (auto material : Face.getMaterial()->AddictionalMaterial) {
if (Mat->Texture->ID == Face.lightmap->Texture->ID) {
Mat = material;
break;
@@ -516,8 +517,8 @@ void t3dFinalizeMaterialList(t3dBODY *b) {
}
if (Mat == nullptr) {
warning("%s: Can't find Lightmap Sub-Material!", Mesh.name.c_str());
- warning("%d %d", Face.mat->NumAddictionalMaterial, Face.lightmap->Texture->ID);
- for (auto material : Face.mat->AddictionalMaterial) {
+ warning("%d %d", Face.getMaterial()->NumAddictionalMaterial, Face.lightmap->Texture->ID);
+ for (auto material : Face.getMaterial()->AddictionalMaterial) {
warning("%d", material->Texture->ID);
}
continue;
@@ -537,16 +538,17 @@ void t3dFinalizeMaterialList(t3dBODY *b) {
Mesh.Flags |= T3D_MESH_UPDATEVB;
for (uint32 h = 0; h < 3; h++) {
- for (k = 0; k < (uint32)Mat->NumAllocatedVerts; k++)
+ for (k = 0; k < (uint32)Mat->NumAllocatedVerts(); k++)
if (Mat->VertsList[k] == &Mesh.VBptr[Face.VertexIndex[h]])
break;
- if (k >= (uint32)Mat->NumAllocatedVerts) {
- Mat->VertsList = (gVertex **)t3dRealloc(Mat->VertsList, sizeof(gVertex *));
- Mat->VertsList[Mat->NumAllocatedVerts++] = &Mesh.VBptr[Face.VertexIndex[h]];
+ if (k >= (uint32)Mat->NumAllocatedVerts()) {
+ Mat->VertsList.push_back(&Mesh.VBptr[Face.VertexIndex[h]]);
}
+ assert(k < Mat->VertsList.size());
Face.MatVertexIndex[h] = (int16)k;
}
+
}
#ifndef WMGEN
Mesh.VBptr = nullptr;
@@ -559,7 +561,7 @@ void t3dFinalizeMaterialList(t3dBODY *b) {
auto &Mat = b->MatTable[i];
Mat->VBO = b->addVertexBuffer(); // t3dAddVertexBuffer(b, Mat->NumAllocatedVerts);
for (int j = 0; j < (uint32)Mat->NumAddictionalMaterial; j++)
- Mat->AddictionalMaterial[j]->VBO = t3dAddVertexBuffer(b, Mat->AddictionalMaterial[j]->NumAllocatedVerts);
+ Mat->AddictionalMaterial[j]->VBO = t3dAddVertexBuffer(b, Mat->AddictionalMaterial[j]->NumAllocatedVerts());
}
}
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index 1284b965969..ffe0161c2a3 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -72,6 +72,13 @@ void gMaterial::addProperty(int flag) {
this->Flags |= flag;
}
+void gMaterial::clearFlag(int flag) {
+ this->Flags &= ~flag;
+}
+
+bool gMaterial::hasFlag(int flag) {
+ return this->Flags & flag;
+}
void gMaterial::addColor(unsigned char r_add, unsigned char g_add, unsigned char b_add) {
int rr, gg, bb;
@@ -109,22 +116,14 @@ bool gMaterial::addNumFacesAdditionalMaterial(MaterialPtr am, unsigned int num)
{
this->AddictionalMaterial.push_back(Common::SharedPtr<gMaterial>(new gMaterial(*am)));
cm = this->AddictionalMaterial.back();
- cm->NumAllocatedFaces=0;
- cm->FacesList.clear();
+ cm->FacesList.resize(0);
this->NumAddictionalMaterial++;
}
-
- cm->FacesList.resize(cm->FacesList.size() + num*3);
- cm->NumAllocatedFaces+=num*3;
return true;
}
bool gMaterial::addNumFaces(unsigned int num) {
- if (num == 0)
- return false;
-
- FacesList.resize(FacesList.size() + num * 3);
- NumAllocatedFaces += num * 3;
+ // TODO: Remove, as this is not necessary with a Common::Array
return true;
}
@@ -135,10 +134,8 @@ MaterialPtr rMergeMaterial(MaterialPtr Mat1, MaterialPtr Mat2) {
for ( int i=0; i<Mat2->NumAddictionalMaterial; i++ ) {
Mat1->addNumFacesAdditionalMaterial(Mat2->AddictionalMaterial[i],
- Mat2->AddictionalMaterial[i]->NumAllocatedFaces);
+ /*Mat2->AddictionalMaterial[i]->NumAllocatedFaces*/ Mat2->AddictionalMaterial[i]->NumFaces());
}
- Mat1->addNumFaces(Mat2->NumAllocatedFaces);
-
//reset mat2
rRemoveMaterial(Mat2);
*Mat2 = gMaterial();
@@ -158,23 +155,25 @@ Common::SharedPtr<gMaterial> rCopyMaterial(Common::SharedPtr<gMaterial> Mat1, Co
if (!Mat1 || !Mat2)
return nullptr;
- Mat1->FacesList.clear();
+ Mat1->clearFaceList();
Mat1->AddictionalMaterial.clear();
- Mat1->FacesList.clear();
- delete[] Mat1->VertsList;
- Mat1->VertsList = nullptr;
+ Mat1->clearFaceList();
+ Mat1->VertsList.clear();
//t3dFree(Mat1->FlagsList);
*Mat1 = gMaterial();
- if (Mat2->NumAllocatedFaces) {
- Mat1->addNumFaces(Mat2->NumAllocatedFaces);
- for (int i = 0; i < Mat2->NumAllocatedFaces; i++) {
- Mat1->FacesList.push_back(Mat2->FacesList[i]);
+ if (Mat2->NumFaces()) {
+ for (int i = 0; i < Mat2->NumFaces(); i++) {
+ Mat1->addFace(Mat2->getFace(i));
}
}
- if (Mat2->NumAllocatedVerts) {
- Mat1->VertsList = new gVertex*[Mat2->NumAllocatedVerts]{};
- memcpy(Mat1->VertsList, Mat2->VertsList, sizeof(gVertex *)*Mat2->NumAllocatedVerts);
+ for (int i = 0; i < Mat2->NumFaces(); i++) {
+ if (Mat2->getFace(i) >= Mat2->VertsList.size()) {
+ warning("TODO");
+ }
+ }
+ if (Mat2->NumAllocatedVerts()) {
+ Mat1->VertsList = Mat2->VertsList;
}
if (Mat2->NumAllocatedMesh) {
Mat1->FlagsList = Mat2->FlagsList;
@@ -183,9 +182,6 @@ Common::SharedPtr<gMaterial> rCopyMaterial(Common::SharedPtr<gMaterial> Mat1, Co
Mat1->Texture = Mat2->Texture;
Mat1->Movie = Mat2->Movie;
Mat1->Flags = Mat2->Flags;
- Mat1->NumFaces = Mat2->NumFaces;
- Mat1->NumAllocatedFaces = Mat2->NumAllocatedFaces;
- Mat1->NumAllocatedVerts = Mat2->NumAllocatedVerts;
Mat1->VBO = Mat2->VBO;
Mat1->NumAllocatedMesh = Mat2->NumAllocatedMesh;
Mat1->r = Mat2->r;
@@ -203,13 +199,15 @@ Common::SharedPtr<gMaterial> rCopyMaterial(Common::SharedPtr<gMaterial> Mat1, Co
}
void gMaterial::clear() {
+ // TODO: This flag clearing doesn't happen in the original, but shouldn't matter as the class is instantiated again when used in Particles.
+ Flags = 0;
+
if (Movie)
{
Movie = nullptr;
}
FacesList.clear();
- delete[] VertsList;
- VertsList=nullptr;
+ VertsList.clear();
FlagsList.clear();
// rDeleteVertexBuffer(m->VB);
VBO=0;
@@ -218,8 +216,7 @@ void gMaterial::clear() {
{
Common::SharedPtr<gMaterial> cm = AddictionalMaterial[j];
cm->FacesList.clear();
- delete[] cm->VertsList;
- cm->VertsList=nullptr;
+ cm->VertsList.clear();
cm->FlagsList.clear();
// rDeleteVertexBuffer(cm->VB);
cm->VBO=0;
@@ -249,14 +246,14 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
if ((mat.Flags & T3D_MATERIAL_MOVIE))
gUpdateMovie(mat);
#endif
- if ((mat.NumFaces >= 3) && (mat.VBO)) {
+ if ((mat.NumFaces() >= 3) && (mat.VBO)) {
bb = rNewBatchBlock(mat.Texture->ID, mat.Flags, 0, 0);
bb->ViewMatrixNum = ViewMatrixNum;
- bb->NumFaces = (unsigned short int) mat.NumFaces;
- bb->FacesList = mat.FacesList;
+ bb->NumFaces = (unsigned short int) mat.NumFaces();
+ bb->FacesList = mat.getFacesList();
bb->VBO = mat.VBO;
- bb->NumVerts = (unsigned short int) mat.NumAllocatedVerts;
- mat.NumFaces = 0;
+ bb->NumVerts = (unsigned short int) mat.NumAllocatedVerts();
+ mat.clearFaceList();
// if ( bb->VB == g_lpD3DUserVertexBuffer )
// DebugLogFile("User VB %s with %d verts",mat->Texture->Name,bb->NumVerts);
#if 0
@@ -271,15 +268,15 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
}
for (auto &cm : mat.AddictionalMaterial) {
- if (cm->NumFaces < 3) continue;
+ if (cm->NumFaces() < 3) continue;
if (cm->VBO == NULL) continue;
bb = rNewBatchBlock(mat.Texture->ID, mat.Flags, cm->Texture->ID, cm->Flags);
bb->ViewMatrixNum = ViewMatrixNum;
- bb->NumFaces = (unsigned short int) cm->NumFaces;
- bb->FacesList = cm->FacesList;
+ bb->NumFaces = (unsigned short int) cm->NumFaces();
+ bb->FacesList = cm->getFacesList();
bb->VBO = cm->VBO;
- bb->NumVerts = (unsigned short int) cm->NumAllocatedVerts;
- cm->NumFaces = 0;
+ bb->NumVerts = (unsigned short int) cm->NumAllocatedVerts();
+ cm->emptyFacesList();
if (bb->NumVerts == 0) {
#if 0
if (bb->VBO->GetVertexBufferDesc(&VBDesc) != D3D_OK)
diff --git a/engines/watchmaker/3d/material.h b/engines/watchmaker/3d/material.h
index dd675f644d9..fd8aab432b0 100644
--- a/engines/watchmaker/3d/material.h
+++ b/engines/watchmaker/3d/material.h
@@ -40,11 +40,19 @@ struct gMaterial {
gTexture *Texture = nullptr; // pointer to texture struct
Common::SharedPtr<gMovie> Movie; // pointer to movie struct
unsigned int Flags = 0; // material flags
- int NumFaces = 0; // current number of faces to be processed
- int NumAllocatedFaces = 0; // maximum number of faces
+ int NumFaces() { return FacesList.size(); }; // current number of faces to be processed
+ void addFace(uint16 face) {
+ FacesList.push_back(face);
+ }
+ uint16 getFace(int index) const { return FacesList[index]; }
+ void clearFaceList() { FacesList.clear(); }
+ void emptyFacesList() { FacesList.resize(0); }
+ Common::Array<uint16> getFacesList() { return FacesList; }
+private:
Common::Array<uint16> FacesList; // list of verts indices
- int NumAllocatedVerts = 0; // number of allocated vertex in mat VB
- gVertex **VertsList = nullptr; // pointers to pointers to verts
+public:
+ Common::Array<gVertex*> VertsList; // pointers to pointers to verts
+ int NumAllocatedVerts() { return this->VertsList.size(); }; // number of allocated vertex in mat VB
Common::SharedPtr<VertexBuffer> VBO = nullptr;
// LPDIRECT3DVERTEXBUFFER7 VB; // mat VB struct
int NumAllocatedMesh = 0; // num mesh to check for modifications
@@ -58,6 +66,8 @@ public:
}
void addColor(unsigned char r, unsigned char g, unsigned char b);
void addProperty(int flag);
+ bool hasFlag(int flag);
+ void clearFlag(int flag);
bool addNumFaces(unsigned int num);
bool addNumFacesAdditionalMaterial(MaterialPtr am, unsigned int num);
void clear();
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 7724142655b..29cdf4501a7 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -970,19 +970,14 @@ MaterialPtr Renderer::addMaterial(MaterialPtr MList, const Common::String &name,
// if( (Material->Texture=gUserTexture( Material->Movie->g_psiStreamInfo.rcFrame.right,
// Material->Movie->g_psiStreamInfo.rcFrame.bottom)) == NULL )
return nullptr;
- Material->Flags |= T3D_MATERIAL_MOVIE;
+ Material->addProperty(T3D_MATERIAL_MOVIE);
} else {
if ((Material->Texture = gLoadTexture(*_workDirs, name.c_str(), LoaderFlags)) == nullptr)
return nullptr;
}
//f
-//f Material->FacesList=(WORD *)t3dRealloc(Material->FacesList,sizeof(WORD)*3*NumFaces+1);
-//f Material->NumAllocatedFaces+=3*NumFaces+1;
- Material->FacesList.resize(Material->FacesList.size() + NumFaces * 3 );
- Material->NumAllocatedFaces += NumFaces * 3;
-//f
- Material->Flags |= T3D_MATERIAL_NOLIGHTMAP;
+ Material->addProperty(T3D_MATERIAL_NOLIGHTMAP);
return Material;
}
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index 8614c7e021c..04807f8b65d 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -25,13 +25,14 @@
#include "watchmaker/3d/t3d_body.h"
#include "common/stream.h"
-#include "watchmaker/3d/t3d_mesh.h"
-#include "watchmaker/3d/math/llmath.h"
+#include "watchmaker/3d/light.h"
#include "watchmaker/3d/loader.h"
-#include "watchmaker/ll/ll_system.h"
+#include "watchmaker/3d/math/llmath.h"
+#include "watchmaker/3d/t3d_face.h"
+#include "watchmaker/3d/t3d_mesh.h"
#include "watchmaker/game.h"
+#include "watchmaker/ll/ll_system.h"
#include "watchmaker/renderer.h"
-#include "watchmaker/3d/light.h"
namespace Watchmaker {
@@ -328,8 +329,7 @@ void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
if (rAddMaterial(*b->LightmapTable[i], Appo, 0, 0) == nullptr)
return;
- b->LightmapTable[i]->Flags = 0;
- b->LightmapTable[i]->NumFaces = 0;
+ b->LightmapTable[i]->clear();
}
for (uint32 i = 0; i < b->NumNormals; i++) {
@@ -364,11 +364,11 @@ void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
// gMaterial *newmat;
if (f.n == b->NList[i]) {
// f->mat->Texture=f->mat->Lightmap;
- if ((!(f.mat->Flags & T3D_MATERIAL_OPACITY)) &&
- (!(f.mat->Flags & T3D_MATERIAL_CLIPMAP)) &&
- (!(f.mat->Flags & T3D_MATERIAL_BOTTLE)) &&
- (!(f.mat->Flags & T3D_MATERIAL_ADDITIVE)) &&
- (!(f.mat->Flags & T3D_MATERIAL_GLASS))) {
+ if ((!(f.hasMaterialFlag(T3D_MATERIAL_OPACITY))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_CLIPMAP))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_BOTTLE))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_ADDITIVE))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_GLASS)))) {
alphaval1 = RGBA_GETALPHA(gv[f.VertexIndex[0]].diffuse);
alphaval2 = RGBA_GETALPHA(gv[f.VertexIndex[1]].diffuse);
alphaval3 = RGBA_GETALPHA(gv[f.VertexIndex[2]].diffuse);
@@ -376,12 +376,12 @@ void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
gv[f.VertexIndex[1]].diffuse = RGBA_MAKE(254, 254, 254, alphaval2);
gv[f.VertexIndex[2]].diffuse = RGBA_MAKE(254, 254, 254, alphaval3);
f.lightmap = b->LightmapTable[Map];
- f.mat->addNumFacesAdditionalMaterial(f.lightmap, 1);
- } else if (((f.mat->Flags & T3D_MATERIAL_OPACITY)) ||
- ((f.mat->Flags & T3D_MATERIAL_CLIPMAP)) ||
- ((f.mat->Flags & T3D_MATERIAL_BOTTLE)) ||
- ((f.mat->Flags & T3D_MATERIAL_ADDITIVE)) ||
- ((f.mat->Flags & T3D_MATERIAL_GLASS))) {
+ f.getMaterial()->addNumFacesAdditionalMaterial(f.lightmap, 1);
+ } else if (((f.hasMaterialFlag(T3D_MATERIAL_OPACITY))) ||
+ ((f.hasMaterialFlag(T3D_MATERIAL_CLIPMAP))) ||
+ ((f.hasMaterialFlag(T3D_MATERIAL_BOTTLE))) ||
+ ((f.hasMaterialFlag(T3D_MATERIAL_ADDITIVE))) ||
+ ((f.hasMaterialFlag(T3D_MATERIAL_GLASS)))) {
f.lightmap = nullptr;
}
@@ -420,11 +420,11 @@ void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
if (f.n == b->NList[i]) {
f.lightmap = nullptr;
// if (Map==-1)
- if ((!(f.mat->Flags & T3D_MATERIAL_OPACITY)) &&
- (!(f.mat->Flags & T3D_MATERIAL_CLIPMAP)) &&
- (!(f.mat->Flags & T3D_MATERIAL_BOTTLE)) &&
- (!(f.mat->Flags & T3D_MATERIAL_ADDITIVE)) &&
- (!(f.mat->Flags & T3D_MATERIAL_GLASS))) {
+ if ((!(f.hasMaterialFlag(T3D_MATERIAL_OPACITY))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_CLIPMAP))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_BOTTLE))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_ADDITIVE))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_GLASS)))) {
alphaval1 = RGBA_GETALPHA(gv[f.VertexIndex[0]].diffuse);
alphaval2 = RGBA_GETALPHA(gv[f.VertexIndex[1]].diffuse);
alphaval3 = RGBA_GETALPHA(gv[f.VertexIndex[2]].diffuse);
diff --git a/engines/watchmaker/3d/t3d_face.cpp b/engines/watchmaker/3d/t3d_face.cpp
new file mode 100644
index 00000000000..09113b25c3a
--- /dev/null
+++ b/engines/watchmaker/3d/t3d_face.cpp
@@ -0,0 +1,54 @@
+/* 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/stream.h"
+#include "watchmaker/3d/t3d_face.h"
+#include "watchmaker/3d/t3d_body.h"
+
+namespace Watchmaker {
+
+t3dFACE::t3dFACE(t3dBODY *b, Common::SeekableReadStream &stream) {
+ VertexIndex[0] = stream.readSint16LE(); // Legge VertexIndex0
+ VertexIndex[1] = stream.readSint16LE(); // Legge VertexIndex1
+ VertexIndex[2] = stream.readSint16LE(); // Legge VertexIndex2
+
+ this->n = b->NList[stream.readSint16LE()]; // Legge puntatore a normale
+
+ uint16 materialIndex = stream.readSint16LE(); // Legge indice materiale
+ if (materialIndex >= b->NumMaterials())
+ warning("Material index wrong: current index: %d; Max material index %d", materialIndex, b->NumMaterials());
+ else {
+ mat = b->MatTable[materialIndex]; // Make the pointer to the material
+ if (mat->addNumFaces(1/*f2*/) == false) // Add face space to the material
+ warning("Can't realloc material faces");
+ }
+}
+
+bool t3dFACE::isVisible() const {
+ if (!n)
+ return true;
+ else if (n->flag != T3D_NORMAL_VISIBLE)
+ return false;
+
+ return true;
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/t3d_face.h b/engines/watchmaker/3d/t3d_face.h
new file mode 100644
index 00000000000..0dba41212cb
--- /dev/null
+++ b/engines/watchmaker/3d/t3d_face.h
@@ -0,0 +1,59 @@
+/* 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 WATCHMAKER_T3D_FACE_H
+#define WATCHMAKER_T3D_FACE_H
+
+#include "watchmaker/3d/types3d.h"
+#include "watchmaker/3d/material.h"
+
+namespace Watchmaker {
+
+struct t3dBODY;
+struct t3dFACE {
+ uint32 flags = 0; // face status 4
+ NormalPtr n; // pointer to the face normal 4
+ int16 VertexIndex[3] = {}; // Vertices indices in mesh 6
+ int16 MatVertexIndex[3] = {}; // Vertices indices in material 6
+
+private:
+ MaterialPtr mat; // pointer to material 4
+public:
+ MaterialPtr lightmap; // pointer to lightmap (or 2nd material) 4
+
+ t3dFACE(t3dBODY *b, Common::SeekableReadStream &stream);
+
+ bool hasMaterialFlag(uint32 flag) { return mat->hasFlag(flag); }
+ MaterialPtr getMaterial() { return mat; }
+ const gMaterial* getMaterial() const { return mat.get(); }
+
+ void checkVertices() {
+ for (int i = 0; i < 3; i++) {
+ assert(mat->VertsList.size() > MatVertexIndex[i]);
+ }
+ }
+
+ bool isVisible() const;
+};
+
+} // End of namespace Watchmaker
+
+#endif // SCUMMVM_T3D_FACE_H
diff --git a/engines/watchmaker/3d/t3d_mesh.cpp b/engines/watchmaker/3d/t3d_mesh.cpp
index 1f234088873..b9d30907984 100644
--- a/engines/watchmaker/3d/t3d_mesh.cpp
+++ b/engines/watchmaker/3d/t3d_mesh.cpp
@@ -28,25 +28,12 @@
namespace Watchmaker {
-void t3dMESH::loadFaces(t3dBODY *b, Common::SeekableReadStream &stream) {
+void t3dMESH::loadFaces(t3dBODY *b, Common::SeekableReadStream &stream, int numFaces) {
//Mesh[mesh].FList = new t3dFACE[Mesh[mesh].NumFaces]{}; // Alloca facce
- for (uint16 face = 0; face < NumFaces(); face++) {
- FList[face].VertexIndex[0] = stream.readSint16LE(); // Legge VertexIndex0
- FList[face].VertexIndex[1] = stream.readSint16LE(); // Legge VertexIndex1
- FList[face].VertexIndex[2] = stream.readSint16LE(); // Legge VertexIndex2
-
- FList[face].n = b->NList[stream.readSint16LE()]; // Legge puntatore a normale
-
- uint16 n = stream.readSint16LE(); // Legge indice materiale
- if (n >= b->NumMaterials())
- warning("Material index wrong: current index: %d; Max material index %d", n, b->NumMaterials());
- else {
- FList[face].mat = b->MatTable[n]; // Make the pointer to the material
- if (b->MatTable[n]->addNumFaces(1/*f2*/) == false) // Add face space to the material
- warning("Can't realloc material faces");
- }
-
+ this->FList.reserve(numFaces); // Legge numero facce mesh
+ for (uint16 face = 0; face < numFaces; face++) {
+ FList.push_back(t3dFACE(b, stream));
}//__for_face
}
@@ -62,7 +49,7 @@ t3dMESH::t3dMESH(t3dBODY *b, Common::SeekableReadStream &stream, t3dMESH *&Recei
stream.read(stringBuffer, T3D_NAMELEN); // Legge nome portale
this->portalName = stringBuffer;
- this->FList.resize(stream.readSint16LE()); // Legge numero facce mesh
+ int numFaces = stream.readSint16LE(); // Legge numero facce mesh
t3dVectFill(&this->Trasl, 0.0f);
this->Pos = t3dV3F(stream) * SCALEFACTOR;
@@ -123,7 +110,7 @@ t3dMESH::t3dMESH(t3dBODY *b, Common::SeekableReadStream &stream, t3dMESH *&Recei
}
this->CurFrame = 0;
- this->loadFaces(b, stream);
+ this->loadFaces(b, stream, numFaces);
this->NumVerts = stream.readSint16LE(); // Rilegge numero vertici
b->NumTotVerts += this->NumVerts;
diff --git a/engines/watchmaker/3d/t3d_mesh.h b/engines/watchmaker/3d/t3d_mesh.h
index 722e809434c..4c79f99fc03 100644
--- a/engines/watchmaker/3d/t3d_mesh.h
+++ b/engines/watchmaker/3d/t3d_mesh.h
@@ -22,6 +22,7 @@
#ifndef WATCHMAKER_T3D_MESH_H
#define WATCHMAKER_T3D_MESH_H
+#include "watchmaker/3d/t3d_face.h"
#include "watchmaker/t3d.h"
namespace Watchmaker {
@@ -85,7 +86,7 @@ struct t3dMESH {
#endif
for (uint16 j = 0; j < this->NumFaces(); j++) { // Scorre le facce
t3dFACE &Face = this->FList[j];
- MaterialPtr Material = Face.mat;
+ MaterialPtr Material = Face.getMaterial();
uint32 alphaval = 2;
uint32 rr = 0, gg = 0, bb = 0;
@@ -93,7 +94,7 @@ struct t3dMESH {
gg = Material->g;
bb = Material->b;
- if (Material->Flags & T3D_MATERIAL_CLIPMAP) { // Se il materiale e' clipmap
+ if (Material->hasFlag(T3D_MATERIAL_CLIPMAP)) { // Se il materiale e' clipmap
alphaval = 0xfe;
Face.flags |= T3D_MATERIAL_CLIPMAP; // lo setta sulla faccia
/* Face->flags&=~T3D_MATERIAL_OPACITY;
@@ -102,22 +103,22 @@ struct t3dMESH {
Material->Flags&=~T3D_MATERIAL_GLASS;*/
// r=g=b=0;
}
- if (Material->Flags & T3D_MATERIAL_OPACITY) { // Se il materiale e' opacity
+ if (Material->hasFlag(T3D_MATERIAL_OPACITY)) { // Se il materiale e' opacity
Face.flags |= T3D_MATERIAL_OPACITY; // lo setta sulla faccia
alphaval = 0x88;
rr = gg = bb = 0;
}
- if (Material->Flags & T3D_MATERIAL_GLASS) { // Se e' un glass
+ if (Material->hasFlag(T3D_MATERIAL_GLASS)) { // Se e' un glass
Face.flags |= T3D_MATERIAL_GLASS; // lo setta sulla faccia
alphaval = 0xfe;
rr = gg = bb = 255;
}
- if (Material->Flags & T3D_MATERIAL_BOTTLE) { // Se e' un bottle
+ if (Material->hasFlag(T3D_MATERIAL_BOTTLE)) { // Se e' un bottle
Face.flags |= T3D_MATERIAL_BOTTLE; // sulla faccia
alphaval = 0x88;
rr = gg = bb = 255;
}
- if (Material->Flags & T3D_MATERIAL_ADDITIVE) { // Se e' un additivo
+ if (Material->hasFlag(T3D_MATERIAL_ADDITIVE)) { // Se e' un additivo
Face.flags |= T3D_MATERIAL_ADDITIVE; // sulla faccia
alphaval = 0x88;
rr = gg = bb = 255;
@@ -137,9 +138,24 @@ struct t3dMESH {
t3dMESH() = default;
t3dMESH(t3dBODY *b, Common::SeekableReadStream &stream, t3dMESH *&ReceiveRipples, uint8 &Mirror);
- void loadFaces(t3dBODY *b, Common::SeekableReadStream &stream);
+ void loadFaces(t3dBODY *b, Common::SeekableReadStream &stream, int numFaces);
void release();
void releaseAnim(uint8 flag);
+
+ bool hasFaceMaterial() const {
+ return !this->FList.empty() && (bool)(this->FList[0].getMaterial());
+ }
+
+ void setMovieFrame(uint32 dwCurrFrame) {
+ // TODO: Could just inline rSetMovieFrame?
+ if (!this->FList.empty() && this->FList[0].getMaterial()) {
+ rSetMovieFrame(this->FList[0].getMaterial(), dwCurrFrame);
+ }
+ }
+ uint32 getMovieFrame() {
+ assert(!this->FList.empty() && this->FList[0].getMaterial());
+ return rGetMovieFrame(this->FList[0].getMaterial());
+ }
};
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/classes/do_operate.cpp b/engines/watchmaker/classes/do_operate.cpp
index 5c77afcd30c..fc6223f02b8 100644
--- a/engines/watchmaker/classes/do_operate.cpp
+++ b/engines/watchmaker/classes/do_operate.cpp
@@ -95,50 +95,50 @@ void UpdateSpecial(WGame &game, int32 room) {
break;
case r1D:
- if ((m = LinkMeshToStr(init, "o1d-rotellina01")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb1D[0]) >= 0 ? (Comb1D[0]) : 0);
- if ((m = LinkMeshToStr(init, "o1d-rotellina02")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb1D[1]) >= 0 ? (Comb1D[1]) : 0);
- if ((m = LinkMeshToStr(init, "o1d-rotellina03")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb1D[2]) >= 0 ? (Comb1D[2]) : 0);
- if ((m = LinkMeshToStr(init, "o1d-rotellina04")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb1D[3]) >= 0 ? (Comb1D[3]) : 0);
- if ((m = LinkMeshToStr(init, "o1d-rotellina05")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb1D[4]) >= 0 ? (Comb1D[4]) : 0);
+ if ((m = LinkMeshToStr(init, "o1d-rotellina01")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb1D[0]) >= 0 ? (Comb1D[0]) : 0);
+ if ((m = LinkMeshToStr(init, "o1d-rotellina02")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb1D[1]) >= 0 ? (Comb1D[1]) : 0);
+ if ((m = LinkMeshToStr(init, "o1d-rotellina03")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb1D[2]) >= 0 ? (Comb1D[2]) : 0);
+ if ((m = LinkMeshToStr(init, "o1d-rotellina04")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb1D[3]) >= 0 ? (Comb1D[3]) : 0);
+ if ((m = LinkMeshToStr(init, "o1d-rotellina05")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb1D[4]) >= 0 ? (Comb1D[4]) : 0);
break;
case r25:
- if ((m = LinkMeshToStr(init, "o25-mikrondedisplayON")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Forno25) >= 0 ? (Forno25) : 0);
- if ((m = LinkMeshToStr(init, "o25-freezervask02")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Frigo25) >= 0 ? (Frigo25) : 0);
+ if ((m = LinkMeshToStr(init, "o25-mikrondedisplayON")) && m->hasFaceMaterial())
+ m->setMovieFrame((Forno25) >= 0 ? (Forno25) : 0);
+ if ((m = LinkMeshToStr(init, "o25-freezervask02")) && m->hasFaceMaterial())
+ m->setMovieFrame((Frigo25) >= 0 ? (Frigo25) : 0);
break;
case r2D:
- if ((m = LinkMeshToStr(init, "o2d-displayino01")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2D[0] - o2D0 + 1) >= 0 ? (Comb2D[0] - o2D0 + 1) : 0);
- if ((m = LinkMeshToStr(init, "o2d-displayino02")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2D[1] - o2D0 + 1) >= 0 ? (Comb2D[1] - o2D0 + 1) : 0);
- if ((m = LinkMeshToStr(init, "o2d-displayino03")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2D[2] - o2D0 + 1) >= 0 ? (Comb2D[2] - o2D0 + 1) : 0);
- if ((m = LinkMeshToStr(init, "o2d-displayino04")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2D[3] - o2D0 + 1) >= 0 ? (Comb2D[3] - o2D0 + 1) : 0);
- if ((m = LinkMeshToStr(init, "o2d-displayino05")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2D[4] - o2D0 + 1) >= 0 ? (Comb2D[4] - o2D0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2d-displayino01")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2D[0] - o2D0 + 1) >= 0 ? (Comb2D[0] - o2D0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2d-displayino02")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2D[1] - o2D0 + 1) >= 0 ? (Comb2D[1] - o2D0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2d-displayino03")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2D[2] - o2D0 + 1) >= 0 ? (Comb2D[2] - o2D0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2d-displayino04")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2D[3] - o2D0 + 1) >= 0 ? (Comb2D[3] - o2D0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2d-displayino05")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2D[4] - o2D0 + 1) >= 0 ? (Comb2D[4] - o2D0 + 1) : 0);
break;
case r2Q:
- if ((m = LinkMeshToStr(init, "o2q-displayino01")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2Q[0] - o2Q0 + 1) >= 0 ? (Comb2Q[0] - o2Q0 + 1) : 0);
- if ((m = LinkMeshToStr(init, "o2q-displayino02")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2Q[1] - o2Q0 + 1) >= 0 ? (Comb2Q[1] - o2Q0 + 1) : 0);
- if ((m = LinkMeshToStr(init, "o2q-displayino03")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2Q[2] - o2Q0 + 1) >= 0 ? (Comb2Q[2] - o2Q0 + 1) : 0);
- if ((m = LinkMeshToStr(init, "o2q-displayino04")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2Q[3] - o2Q0 + 1) >= 0 ? (Comb2Q[3] - o2Q0 + 1) : 0);
- if ((m = LinkMeshToStr(init, "o2q-displayino05")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb2Q[4] - o2Q0 + 1) >= 0 ? (Comb2Q[4] - o2Q0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2q-displayino01")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2Q[0] - o2Q0 + 1) >= 0 ? (Comb2Q[0] - o2Q0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2q-displayino02")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2Q[1] - o2Q0 + 1) >= 0 ? (Comb2Q[1] - o2Q0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2q-displayino03")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2Q[2] - o2Q0 + 1) >= 0 ? (Comb2Q[2] - o2Q0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2q-displayino04")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2Q[3] - o2Q0 + 1) >= 0 ? (Comb2Q[3] - o2Q0 + 1) : 0);
+ if ((m = LinkMeshToStr(init, "o2q-displayino05")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb2Q[4] - o2Q0 + 1) >= 0 ? (Comb2Q[4] - o2Q0 + 1) : 0);
break;
case r31:
@@ -170,16 +170,16 @@ void UpdateSpecial(WGame &game, int32 room) {
break;
case r45:
- if ((m = LinkMeshToStr(init, "o45-contatore01")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb45[0]) >= 0 ? (Comb45[0]) : 0);
- if ((m = LinkMeshToStr(init, "o45-contatore02")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb45[1]) >= 0 ? (Comb45[1]) : 0);
- if ((m = LinkMeshToStr(init, "o45-contatore03")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb45[2]) >= 0 ? (Comb45[2]) : 0);
- if ((m = LinkMeshToStr(init, "o45-contatore04")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb45[3]) >= 0 ? (Comb45[3]) : 0);
- if ((m = LinkMeshToStr(init, "o45-contatore05")) && !m->FList.empty() && m->FList[0].mat)
- rSetMovieFrame(m->FList[0].mat, (Comb45[4]) >= 0 ? (Comb45[4]) : 0);
+ if ((m = LinkMeshToStr(init, "o45-contatore01")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb45[0]) >= 0 ? (Comb45[0]) : 0);
+ if ((m = LinkMeshToStr(init, "o45-contatore02")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb45[1]) >= 0 ? (Comb45[1]) : 0);
+ if ((m = LinkMeshToStr(init, "o45-contatore03")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb45[2]) >= 0 ? (Comb45[2]) : 0);
+ if ((m = LinkMeshToStr(init, "o45-contatore04")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb45[3]) >= 0 ? (Comb45[3]) : 0);
+ if ((m = LinkMeshToStr(init, "o45-contatore05")) && m->hasFaceMaterial())
+ m->setMovieFrame((Comb45[4]) >= 0 ? (Comb45[4]) : 0);
break;
}
}
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index 278269a6304..5543185c35b 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -892,10 +892,10 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
SetMeshMaterialMovieFrame(h->sub[in - 1].ptr, -1, 1);
case ATFM_START_MOVIE:
SetMeshMaterialMovieFrame(h->sub[in - 1].ptr, 0, 1);
- ChangeMeshMaterialFlags(h->sub[in - 1].ptr, -1, T3D_MATERIAL_MOVIEPAUSED);
+ ChangeMeshMaterialFlag(h->sub[in - 1].ptr, -1, T3D_MATERIAL_MOVIEPAUSED);
break;
case ATFM_STOP_MOVIE:
- ChangeMeshMaterialFlags(h->sub[in - 1].ptr, +1, T3D_MATERIAL_MOVIEPAUSED);
+ ChangeMeshMaterialFlag(h->sub[in - 1].ptr, +1, T3D_MATERIAL_MOVIEPAUSED);
break;
case ATFH_ON:
ChangeHaloesStatus(nullptr, +1);
diff --git a/engines/watchmaker/ll/ll_mesh.cpp b/engines/watchmaker/ll/ll_mesh.cpp
index cf4ea1a3b8c..c8db3a6e04d 100644
--- a/engines/watchmaker/ll/ll_mesh.cpp
+++ b/engines/watchmaker/ll/ll_mesh.cpp
@@ -488,11 +488,11 @@ void ModifyMesh(WGame &game, t3dMESH *mesh) {
// Aggiorna Materiali
if (mm->Flags & MM_REMOVE_MAT_FLAGS)
- mesh->FList[0].mat->Flags &= ~mm->RemoveMatFlags;
+ mesh->FList[0].getMaterial()->Flags &= ~mm->RemoveMatFlags;
if (mm->Flags & MM_ADD_MAT_FLAGS)
- mesh->FList[0].mat->Flags |= mm->AddMatFlags;
+ mesh->FList[0].getMaterial()->Flags |= mm->AddMatFlags;
if (mm->Flags & MM_SET_MAT_FRAME)
- rSetMovieFrame(mesh->FList[0].mat, mm->MatFrame);
+ mesh->setMovieFrame(mm->MatFrame); // This did NOT check for existing face/material before setting before.
// Aggiorna Anim
if ((mm->Flags & MM_ANIM_BLOCK) && (!mm->animName.empty()) && (!mesh->CurFrame)) {
@@ -814,16 +814,16 @@ void UpdateObjMesh(Init &init, int32 in) {
* SetMeshMaterialMovieFrame
* --------------------------------------------------*/
void SetMeshMaterialMovieFrame(t3dMESH *m, int8 op, int32 newframe) {
- if (!m || m->FList.empty() || !m->FList[0].mat) return;
+ if (!m || m->FList.empty() || !m->FList[0].getMaterial()) return;
if (op == 0)
- rSetMovieFrame(m->FList[0].mat, newframe);
+ m->setMovieFrame(newframe);
else if (op > 0)
- rSetMovieFrame(m->FList[0].mat, rGetMovieFrame(m->FList[0].mat) + newframe);
+ m->setMovieFrame(m->getMovieFrame() + newframe);
else if (op < 0)
- rSetMovieFrame(m->FList[0].mat, rGetMovieFrame(m->FList[0].mat) - newframe);
+ m->setMovieFrame(m->getMovieFrame() - newframe);
- newframe = rGetMovieFrame(m->FList[0].mat);
+ newframe = m->getMovieFrame();
AddMeshModifier(m->name, MM_SET_MAT_FRAME, &newframe);
}
@@ -831,15 +831,15 @@ void SetMeshMaterialMovieFrame(t3dMESH *m, int8 op, int32 newframe) {
/* -----------------22/06/00 12.15-------------------
* ChangeMeshMaterialFlags
* --------------------------------------------------*/
-void ChangeMeshMaterialFlags(t3dMESH *m, int8 add, uint32 newflags) {
- if (!m || m->FList.empty() || !m->FList[0].mat) return;
+void ChangeMeshMaterialFlag(t3dMESH *m, int8 add, uint32 newflag) {
+ if (!m || m->hasFaceMaterial()) return;
if (add > 0) {
- m->FList[0].mat->Flags |= newflags;
- AddMeshModifier(m->name, MM_ADD_MAT_FLAGS, &newflags);
+ m->FList[0].getMaterial()->addProperty(newflag);
+ AddMeshModifier(m->name, MM_ADD_MAT_FLAGS, &newflag);
} else {
- m->FList[0].mat->Flags &= ~newflags;
- AddMeshModifier(m->name, MM_REMOVE_MAT_FLAGS, &newflags);
+ m->FList[0].getMaterial()->clearFlag(newflag);
+ AddMeshModifier(m->name, MM_REMOVE_MAT_FLAGS, &newflag);
}
}
diff --git a/engines/watchmaker/ll/ll_mesh.h b/engines/watchmaker/ll/ll_mesh.h
index 7d14043d32b..7f052f01d5b 100644
--- a/engines/watchmaker/ll/ll_mesh.h
+++ b/engines/watchmaker/ll/ll_mesh.h
@@ -41,7 +41,7 @@ void UpdateObjMesh(Init &init, int32 in);
void UpdateBoundingBox(t3dMESH *mesh);
void UpdateCharHead(int32 oc, t3dV3F *dir);
void SetMeshMaterialMovieFrame(t3dMESH *m, int8 op, int32 newframe);
-void ChangeMeshMaterialFlags(t3dMESH *m, int8 add, uint32 newflags);
+void ChangeMeshMaterialFlag(t3dMESH *m, int8 add, uint32 newflag);
void ChangeHaloesStatus(t3dBODY *b, int8 op);
uint8 t3dVectMeshInters(t3dMESH *m, t3dV3F start, t3dV3F end, t3dV3F *inters);
void t3dLightRoom(Init &init, t3dBODY *b, t3dV3F *p, t3dF32 NearRange, t3dF32 FarRange, t3dF32 IperRange);
diff --git a/engines/watchmaker/module.mk b/engines/watchmaker/module.mk
index 6f88a260c97..b036af05067 100644
--- a/engines/watchmaker/module.mk
+++ b/engines/watchmaker/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS = \
3d/render/render.o \
3d/render/shadows.o \
3d/t3d_body.o \
+ 3d/t3d_face.o \
3d/t3d_mesh.o \
3d/t3d_mesh.o \
3d/texture.o \
diff --git a/engines/watchmaker/render.cpp b/engines/watchmaker/render.cpp
index 312de80568b..4f08778671c 100644
--- a/engines/watchmaker/render.cpp
+++ b/engines/watchmaker/render.cpp
@@ -302,7 +302,7 @@ bool gUpdateMovie(gMaterial *mat) {
WORD newFrame = 0;
DWORD curTime;
- if (mat->Flags & T3D_MATERIAL_MOVIEPAUSED)
+ if (mat->hasFlag(T3D_MATERIAL_MOVIEPAUSED))
return TRUE;
Common::SharedPtr<gMovie> mv = mat->Movie;
diff --git a/engines/watchmaker/t3d.h b/engines/watchmaker/t3d.h
index 8baf8759cb3..75a508118db 100644
--- a/engines/watchmaker/t3d.h
+++ b/engines/watchmaker/t3d.h
@@ -113,25 +113,6 @@ namespace Watchmaker {
#define T3D_CHARACTER_BNDHIDE (1<<5) // don't use char BND
#define T3D_CHARACTER_DIARYDISABLE (1<<6) // diable diary
-struct t3dFACE {
- uint32 flags = 0; // face status 4
- NormalPtr n; // pointer to the face normal 4
- int16 VertexIndex[3] = {}; // Vertices indices in mesh 6
- int16 MatVertexIndex[3] = {}; // Vertices indices in material 6
- MaterialPtr mat; // pointer to material 4
- MaterialPtr lightmap; // pointer to lightmap (or 2nd material) 4
-
- bool isVisible() const {
- if (!n)
- return true;
- else if (n->flag != T3D_NORMAL_VISIBLE)
- return false;
-
- return true;
- }
-};
-
-
struct t3dM3X3F {
t3dF32 M[9] = {}; // Matrix 3 x 3
uint8 Flags = 0; // flags: if identity
Commit: d93eb81837059dc125b8d911cf40a6fa807fdecc
https://github.com/scummvm/scummvm/commit/d93eb81837059dc125b8d911cf40a6fa807fdecc
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Clear some warnings
Changed paths:
engines/watchmaker/3d/geometry.cpp
engines/watchmaker/3d/loader.cpp
engines/watchmaker/ll/ll_mesh.cpp
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index ca035bda4c7..d787e43836b 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -370,8 +370,6 @@ void t3dCalcRejectedMeshFromPortal(t3dBODY *body) {
* t3dReleaseBody
* --------------------------------------------------*/
void t3dReleaseBody(t3dBODY *b) {
- uint16 i;
-
if (!b) return;
for (auto &mesh : b->MeshTable) {
@@ -388,7 +386,7 @@ void t3dReleaseBody(t3dBODY *b) {
b->LightmapTable.clear();
if (b->MirrorMatTable.size() > 0) {
- for (i = 0; i < b->NumMirrorMaterials(); i++)
+ for (int i = 0; i < b->NumMirrorMaterials(); i++)
b->MirrorMatTable[i]->Movie = nullptr;
rRemoveMaterials(b->MirrorMatTable);
}
@@ -827,11 +825,12 @@ void t3dCreateProceduralSky(void) {
* t3dCreateSmokeParticle
* --------------------------------------------------*/
uint8 t3dCreateSmokeParticle(uint32 Num, uint8 Type, uint32 Opacity) {
+ error("TODO: t3dCreateSmokeParticle");
+#if 0
t3dF32 v1, v2;
int32 i, j, pitch, color;
unsigned short *p;
- error("TODO: t3dCreateSmokeParticle");
-#if 0
+
Particles[t3dNumParticles].Material = gMaterial();
if ((SmokeSurface == nullptr) && (Type == 1)) {
@@ -1845,6 +1844,9 @@ void t3dSetVisibileVertex(t3dMESH &mesh) {
* t3dAddTextureBufferShadow
* --------------------------------------------------*/
void t3dAddTextureBufferShadow(t3dCHARACTER *c, uint32 CurShadowBox, t3dLIGHT *light) {
+ warning("TODO: t3dAddTextureBufferShadow");
+ return;
+#if 0
SHADOWBOX *sb = c->ShadowBox[CurShadowBox];
SHADOW *shad = &sb->ShadowsList[0];
uint32 i, k, ff, kkk, StartVert;
@@ -1856,9 +1858,6 @@ void t3dAddTextureBufferShadow(t3dCHARACTER *c, uint32 CurShadowBox, t3dLIGHT *l
gVertex *gv, *pc;
t3dV3F v, tmp, MinSco, MaxSco, Aspect, BBox[8], dir;
- warning("TODO: t3dAddTextureBufferShadow");
- return;
-#if 0
if (!cm || !cm->VertexBuffer)
return ;
//tb
@@ -2612,15 +2611,15 @@ void t3dCalcHalos(t3dBODY *b) {
* t3dAddParticle
* --------------------------------------------------*/
void t3dAddParticle(gMaterial *Material, t3dV3F *Source, t3dF32 size, t3dV3F Color, uint32 num) {
+ warning("TODO: t3dAddParticle");
+ return;
+#if 0
int16 T1;
uint32 uvbc;
gVertex *gv;
t3dV3F v0, v1, v2, v3;
uint32 rr, gg, bl, i;
- warning("TODO: t3dAddParticle");
- return;
-#if 0
uvbc = rGetUserVertexBufferCounter();
gv = rLockVertexPtr(rGetUserVertexBuffer(), rVBLOCK_NOSYSLOCK);
gv += uvbc;
@@ -2987,14 +2986,14 @@ bool t3dTransformBody(t3dBODY *b) {
* t3dAddLensFlare
* --------------------------------------------------*/
void t3dAddLensFlare(gMaterial *Material, t3dV3F *Source, t3dF32 size, t3dF32 perc2, t3dV3F Color) {
+ warning("TODO: t3dAddLensFlare");
+ return;
+#if 0
uint32 uvbc;
gVertex *gv;
t3dV3F v0, v1, v2, v3;
int32 rr, gg, bb;
- warning("TODO: t3dAddLensFlare");
- return;
-#if 0
uvbc = rGetUserVertexBufferCounter();
gv = rLockVertexPtr(rGetUserVertexBuffer(), rVBLOCK_NOSYSLOCK);
gv += uvbc;
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index fe57b12faee..691a4cbada8 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -194,10 +194,6 @@ t3dBODY *t3dLoadSingleRoom(WGame &game, const Common::String &_pname, t3dBODY *b
//decodeLoaderFlags(LoaderFlags);
Common::String pname(_pname);
- uint16 light;
- t3dPLIGHT *PLight;
- t3dF32 minx, miny, minz, maxx, maxy, maxz;
-
WorkDirs &workdirs = game.workDirs;
if (pname.equalsIgnoreCase("r1c.t3d"))
diff --git a/engines/watchmaker/ll/ll_mesh.cpp b/engines/watchmaker/ll/ll_mesh.cpp
index c8db3a6e04d..79e6ef8e668 100644
--- a/engines/watchmaker/ll/ll_mesh.cpp
+++ b/engines/watchmaker/ll/ll_mesh.cpp
@@ -214,6 +214,7 @@ void t3dLightRoom(Init &init, t3dBODY *b, t3dV3F *p, t3dF32 NearRange, t3dF32 Fa
* t3dLightChar
* --------------------------------------------------*/
void t3dLightChar(t3dMESH *mesh, t3dV3F *p) {
+#if 0
int16 df;
uint32 j, rr, gg, bb, cr, cb, cg;
t3dF32 addr = 110 + 60;
@@ -225,7 +226,6 @@ void t3dLightChar(t3dMESH *mesh, t3dV3F *p) {
if (!mesh || !p) return;
-#if 0
t3dVectAdd(&ppos, &mesh->Trasl, &mesh->Pos);
gv = mesh->VBptr = mesh->VertexBuffer;
Commit: 55730a105578e06e7df2af9838301bed149d8659
https://github.com/scummvm/scummvm/commit/55730a105578e06e7df2af9838301bed149d8659
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Improve some initialization issues.
Changed paths:
A engines/watchmaker/file_utils.cpp
A engines/watchmaker/file_utils.h
engines/watchmaker/3d/animation.cpp
engines/watchmaker/3d/loader.cpp
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/walk/act.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index 92ab745bfea..f9f679cb5bc 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -56,9 +56,9 @@ struct t3dLOADBONE {
struct t3dLOADANIM {
Common::String name;
- uint32 NumFrames, NumBones, HiBone, LastTime;
- t3dF32 *Dist;
- t3dLOADBONE Bone[MAX_BONES];
+ uint32 NumFrames = 0, NumBones = 0, HiBone = 0, LastTime = 0;
+ t3dF32 *Dist = nullptr;
+ t3dLOADBONE Bone[MAX_BONES] = {};
};
t3dLOADANIM PreloadedAnim[MAX_PRELOADED_ANIMS];
@@ -191,7 +191,7 @@ int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag) {
t3dFree(PreloadedAnim[j].Bone[i].Euler);
}
t3dFree(PreloadedAnim[j].Dist);
- memset(&PreloadedAnim[j], 0, sizeof(t3dLOADANIM));
+ PreloadedAnim[j] = t3dLOADANIM();
}
//t else
//t DebugFile( "Precarico animazione %s nello slot libero %d", s, CurPreloadedAnim );
@@ -698,7 +698,7 @@ void ReleasePreloadedAnims() {
t3dFree(PreloadedAnim[j].Bone[i].Euler);
}
t3dFree(PreloadedAnim[j].Dist);
- memset(&PreloadedAnim[j], 0, sizeof(t3dLOADANIM));
+ PreloadedAnim[j] = t3dLOADANIM();
}
}
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index 691a4cbada8..f13f25d21a8 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -278,7 +278,7 @@ t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, uint1
} else
body = r = t3dLoadSingleRoom(game, l->pname, b, NumBody, l->LoaderFlags);
- memset(l, 0, sizeof(struct _t3dLOADLIST));
+ *l = _t3dLOADLIST();
}
if (!(LoaderFlags & T3D_NORECURSION)) {
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 8f5582db89e..6dbf790f2b9 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -260,7 +260,7 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
return -1;
}
- Graphics::PixelFormat RGBA8888(4, 8, 8, 8, 8, 24, 16, 8, 0);
+ Graphics::PixelFormat RGBA8888(4, 8, 8, 8, 8, 0, 8, 16, 24);
unsigned int pos = gGetBitmapListPosition();
if (pos == 0) {
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 29cdf4501a7..3b2c5d2bfd9 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -832,7 +832,7 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
stream = nullptr;
} else { // TGA
auto stream = workDirs.resolveFile(TextName);
- auto image = ReadTgaImage(TextName, *stream, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), 0); // TODO Flags
+ auto image = ReadTgaImage(TextName, *stream, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), 0); // TODO Flags
createTextureFromSurface(*image, GL_RGBA);
#if 0
//warning("TODO: Handle TGA");
diff --git a/engines/watchmaker/file_utils.cpp b/engines/watchmaker/file_utils.cpp
new file mode 100644
index 00000000000..7c20c015bef
--- /dev/null
+++ b/engines/watchmaker/file_utils.cpp
@@ -0,0 +1,40 @@
+/* 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 "watchmaker/file_utils.h"
+#include "watchmaker/t3d.h"
+
+Common::String readT3dString(Common::SeekableReadStream& stream) {
+ char strbuf[T3D_NAMELEN + 1] = {};
+ for (int i = 0; i < T3D_NAMELEN; i++) {
+ strbuf[i] = stream.readByte();
+ }
+ return Common::String(strbuf);
+}
+
+bool hasFileExtension(const Common::String &str, const Common::String &extension) {
+ return str.hasSuffixIgnoreCase("." + extension);
+}
+
+bool hasFileExtension(const char *str, Common::String extension) {
+ Common::String string(str);
+ return hasFileExtension(string, extension);
+}
diff --git a/engines/watchmaker/file_utils.h b/engines/watchmaker/file_utils.h
new file mode 100644
index 00000000000..3cc4ec4958d
--- /dev/null
+++ b/engines/watchmaker/file_utils.h
@@ -0,0 +1,32 @@
+/* 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 WATCHMAKER_FILE_UTILS_H
+#define WATCHMAKER_FILE_UTILS_H
+
+#include "common/stream.h"
+
+Common::String readT3dString(Common::SeekableReadStream& stream);
+// TODO: This can probably just be replaced with .hasSuffixIgnoreCase
+bool hasFileExtension(const Common::String &str, const Common::String &extension);
+bool hasFileExtension(const char *str, Common::String extension);
+
+#endif // WATCHMAKER_FILE_UTILS_H
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 188a7a3c539..07c6af6a5c8 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -571,7 +571,7 @@ void ChangeRoom(WGame &game, Common::String n, uint8 pos, int32 an) {
}
}
}
- memset(&Character[i]->Walk, 0, sizeof(Character[i]->Walk));
+ Character[i]->Walk = t3dWALK();
}
}
diff --git a/engines/watchmaker/walk/act.cpp b/engines/watchmaker/walk/act.cpp
index b97ce9a7798..6406fb30730 100644
--- a/engines/watchmaker/walk/act.cpp
+++ b/engines/watchmaker/walk/act.cpp
@@ -360,7 +360,10 @@ void BuildStepList(int32 oc, uint8 dp, uint8 back) {
if (!Ch || !w) return;
- memset(&w->WalkSteps[0], 0, T3D_MAX_WALKSTEPS * sizeof(t3dSTEPS));
+ for (int step = 0; step < T3D_MAX_WALKSTEPS; step++) {
+ w->WalkSteps[step] = t3dSTEPS();
+ }
+
if (w->NumPathNodes < 2) {
w->NumSteps = 0;
w->CurrentStep = 0;
Commit: 7ab6257e677100c12f8c85c2f8d25bbe7d65aa66
https://github.com/scummvm/scummvm/commit/7ab6257e677100c12f8c85c2f8d25bbe7d65aa66
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Various refactors to attempt to improve the face rendering
* Make faces a proper class
* Initialize batch blocks
* Start refactoring t3dSetFaceVisibility.
Also some further use of hasFileExtension
Changed paths:
engines/watchmaker/3d/geometry.cpp
engines/watchmaker/3d/light.cpp
engines/watchmaker/3d/loader.cpp
engines/watchmaker/3d/material.cpp
engines/watchmaker/3d/material.h
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/render/opengl_renderer.cpp
engines/watchmaker/3d/render/render.cpp
engines/watchmaker/3d/t3d_body.cpp
engines/watchmaker/3d/t3d_face.cpp
engines/watchmaker/3d/t3d_face.h
engines/watchmaker/module.mk
engines/watchmaker/render.h
engines/watchmaker/renderer.h
engines/watchmaker/t3d.h
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index d787e43836b..d456f829e9e 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -2335,31 +2335,34 @@ void t3dMoveTexture(gVertex *gv, uint32 NumVerts, t3dF32 XInc, t3dF32 YInc) {
}
}
+void t3dSetFaceVisibilityPortal(t3dMESH *mesh) {
+ if (bOrigRoom && !bDisableMirrors && (!(mesh->Flags & T3D_MESH_NOPORTALCHECK)) && (mesh->PortalList)) {
+ for (uint32 pl = 0; pl < t3dNumPortals; pl++)
+ if (t3dPortalList[pl] == mesh)
+ return;
+ t3dPortalList[t3dNumPortals++] = mesh; // aggiunge a lista portali
+ }
+}
+
+void t3dSetFaceVisibilityMirror(t3dMESH *mesh) {
+ if (bOrigRoom && !bDisableMirrors)
+ if ((t3dNumGlobalMirrors + 1) < MAX_MIRRORS)
+ t3dGlobalMirrorList[t3dNumGlobalMirrors++] = mesh; // aggiunge alla lista
+}
+
/* -----------------10/06/99 15.44-------------------
* t3dSetFaceVisibility
* --------------------------------------------------*/
void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
- uint32 pl;
- int32 j;
- int16 LastT1, LastT2, T1, T2;
-
if (mesh->Flags & T3D_MESH_PORTAL) { // se e' un portale
- if (bOrigRoom && !bDisableMirrors && (!(mesh->Flags & T3D_MESH_NOPORTALCHECK)) && (mesh->PortalList)) {
- for (pl = 0; pl < t3dNumPortals; pl++)
- if (t3dPortalList[pl] == mesh)
- return;
- t3dPortalList[t3dNumPortals++] = mesh; // aggiunge a lista portali
- }
- return ; // ed esce
- }
-
- if (mesh->Flags & T3D_MESH_MIRROR) { // se e' uno specchio
- if (bOrigRoom && !bDisableMirrors)
- if ((t3dNumGlobalMirrors + 1) < MAX_MIRRORS)
- t3dGlobalMirrorList[t3dNumGlobalMirrors++] = mesh; // aggiunge alla lista
+ t3dSetFaceVisibilityPortal(mesh);
+ return; // ed esce
+ } else if (mesh->Flags & T3D_MESH_MIRROR) { // se e' uno specchio
+ t3dSetFaceVisibilityMirror(mesh);
return; // ed esce
}
+ int16 LastT1, LastT2, T1, T2;
LastT1 = LastT2 = -2;
T1 = T2 = -1;
@@ -2367,9 +2370,11 @@ void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
int targetIndex = 0;
for (uint32 i = 0; i < mesh->NumFaces(); i++) {
t3dFACE &f = mesh->FList[i];
+
if (!f.getMaterial() || !(f.flags & T3D_FACE_VISIBLE))
continue;
+ f.checkVertices();
MaterialPtr Material = f.getMaterial();
T1 = Material->Texture->ID;
@@ -2379,31 +2384,21 @@ void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
T2 = -1;
if (Material->hasFlag(T3D_MATERIAL_ENVIROMENT)) { // se ha l'enviroment
- t3dV3F v;
- t3dV3F *n;
- gVertex *gv;
t3dM3X3F m;
-
t3dMatMul(&m, &mesh->Matrix, &t3dCurViewMatrix);
if (!(mesh->VBptr = mesh->VertexBuffer))
continue;
- gv = &mesh->VBptr[f.VertexIndex[0]];
- n = &mesh->NList[f.VertexIndex[0]]->n;
- t3dVectTransform(&v, n, &m);
- gv->u1 = (v.x);
- gv->v1 = (v.y);
- gv = &mesh->VBptr[f.VertexIndex[1]];
- n = &mesh->NList[f.VertexIndex[1]]->n;
- t3dVectTransform(&v, n, &m);
- gv->u1 = (v.x);
- gv->v1 = (v.y);
- gv = &mesh->VBptr[f.VertexIndex[2]];
- n = &mesh->NList[f.VertexIndex[2]]->n;
- t3dVectTransform(&v, n, &m);
- gv->u1 = (v.x);
- gv->v1 = (v.y);
+ for (int i = 0; i < 3; i++) {
+ t3dV3F v;
+ gVertex *gv = &mesh->VBptr[f.VertexIndex[i]];
+ t3dV3F *n = &mesh->NList[f.VertexIndex[i]]->n;
+ t3dVectTransform(&v, n, &m);
+ gv->u1 = (v.x);
+ gv->v1 = (v.y);
+ }
+
mesh->VBptr = nullptr;
mesh->Flags |= T3D_MESH_UPDATEVB;
}
@@ -2412,6 +2407,7 @@ void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
if (T2 > 0) {
if (!Material->NumAddictionalMaterial)
DebugLogWindow("Error no Sub Material found in %s!", mesh->name.c_str());
+ int32 j = -1;
for (j = 0; j < Material->NumAddictionalMaterial; j++)
if (Material->AddictionalMaterial[j]->Texture->ID == T2)
break;
@@ -2435,7 +2431,7 @@ void t3dSetFaceVisibility(t3dMESH *mesh, t3dCAMERA *cam) {
// Something is wrong here, as the original game seems to be just writing to NumFaces + 0,1,2, as if there
// was space allocated there.
for (int v = 0; v < 3; v++) {
- target->addFace(f.MatVertexIndex[v]);
+ target->addFace(f.getMatVertexIndex(v));
}
StatNumTris++;
diff --git a/engines/watchmaker/3d/light.cpp b/engines/watchmaker/3d/light.cpp
index 089de32e9f7..9af040a8a48 100644
--- a/engines/watchmaker/3d/light.cpp
+++ b/engines/watchmaker/3d/light.cpp
@@ -23,14 +23,17 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
#include "watchmaker/3d/light.h"
-#include "watchmaker/3d/loader.h"
-#include "watchmaker/types.h"
-#include "watchmaker/t3d.h"
#include "watchmaker/3d/geometry.h"
+#include "watchmaker/3d/loader.h"
+#include "watchmaker/3d/math/llmath.h"
#include "watchmaker/3d/t3d_body.h"
#include "watchmaker/3d/t3d_mesh.h"
-#include "watchmaker/3d/math/llmath.h"
+#include "watchmaker/file_utils.h"
+#include "watchmaker/game.h"
#include "watchmaker/ll/ll_system.h"
+#include "watchmaker/renderer.h"
+#include "watchmaker/t3d.h"
+#include "watchmaker/types.h"
#include "watchmaker/utils.h"
namespace Watchmaker {
@@ -324,7 +327,7 @@ void GetBoundaries(t3dBODY *b, t3dF32 *minx, t3dF32 *miny, t3dF32 *minz, t3dF32
}
}
-t3dLIGHT::t3dLIGHT(t3dBODY *b, WorkDirs &workDirs, Common::SeekableReadStream &stream) {
+t3dLIGHT::t3dLIGHT(WGame &game, t3dBODY *b, WorkDirs &workDirs, Common::SeekableReadStream &stream) {
Type = stream.readUint32LE(); // Legge tipo
// DebugFile("%d: SPOT %X ATTEN %X SHAD %X",light,Light[light].Type&T3D_LIGHT_SPOTLIGHT,Light[light].Type&T3D_LIGHT_ATTENUATION,Light[light].Type&T3D_LIGHT_CASTSHADOWS);
Source = t3dV3F(stream) * SCALEFACTOR; // Legge Source
@@ -352,35 +355,25 @@ t3dLIGHT::t3dLIGHT(t3dBODY *b, WorkDirs &workDirs, Common::SeekableReadStream &s
}
if (Type & T3D_LIGHT_FLARE) { // Se ha una flare
- char Name[T3D_NAMELEN], Appo[T3D_NAMELEN];
-#ifndef WMGEN
- int len;
-#endif
//f Light[light].Type&=~T3D_LIGHT_LIGHTON; // La spegne
FlareSize = stream.readFloatLE() * SCALEFACTOR; // Legge il size della flare
- for (int i = 0; i < T3D_NAMELEN; i++) { // Legge nome dellaq texture
- Name[i] = stream.readByte();
- }
-
+ Common::String name = readT3dString(stream); // Legge nome dellaq texture
+ Common::String appo;
#ifndef WMGEN
- len = strlen(Name);
- if (((Name[len - 1] == 'i') || (Name[len - 1] == 'I')) &&
- ((Name[len - 2] == 'v') || (Name[len - 2] == 'V')) &&
- ((Name[len - 3] == 'a') || (Name[len - 3] == 'A'))) {
- strcpy(Appo, workDirs._moviesDir.c_str()); // altrimenti prende quello di default
+ if (hasFileExtension(name, "avi")) {
+ appo = workDirs._moviesDir + name; // altrimenti prende quello di default
} else {
- strcpy(Appo, workDirs._mapsDir.c_str()); // altrimenti prende quello di default
+ appo = workDirs._mapsDir + name;; // altrimenti prende quello di default
}
- strcat(Appo, Name); // Attacca nome Immagine
#else
strcpy(Appo, WmMapsDir);
strcat(Appo, Name);
#endif
#ifndef WMGEN
- if (!(rAddMaterial(Material[0], Appo, 15, 0))) { // Aggiunge il materiale
- warning("File %s not found", Appo);
+ if (!(game._renderer->addMaterial(Material[0], appo, 15, 0))) { // Aggiunge il materiale
+ warning("File %s not found", appo.c_str());
Material[0].Texture = nullptr;
assert(false);
}
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index f13f25d21a8..3be0204d960 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -473,20 +473,41 @@ void t3dOptimizeMaterialList(t3dBODY *b) {
if (Mat->Texture->name.equalsIgnoreCase(CurMat->Texture->name)) { // Se ha lo setsso nome di texture
//warning("TODO: Implement Material-merging");
-#if 0
// This is currently broken.
+
Mat = rMergeMaterial(Mat, CurMat); // Unisce i due materiali
+ for (int k = 0; k < b->NumMeshes(); k++) { // Aggiorna in tutte le mesh id materiale
+ auto &m = b->MeshTable[k];
+ for (int q = 0; q < m.NumFaces(); q++) {
+ auto &f = m.FList[q];
+ if (f.getMaterialIndex() == j)
+ f.setMaterialIndex(i);
+ }
+ }
+ warning("Deduplicating: %s (%d v %d", Mat->Texture->name.c_str(), i, j);
+ b->MatTable[j] = nullptr; // TODO: This should probably happen in rMergeMaterial
+ }
+ }
+ }
- t3dMESH *m = b->MeshTable;
- for (int k = 0; k < b->NumMeshes; k++, m++) { // Aggiorna in tutte le mesh id materiale
- t3dFACE *f = m->FList;
- for (int q = 0; q < m->NumFaces; q++, f++) {
- if (f->mat == CurMat)
- f->mat = Mat;
+ // TODO: The optimization leaves a bunch of materials as nullptr, we need to update all the
+ // references to them. Currently we do this by subtracting 1 from all references that were above
+ // a removed material. This works, but isn't really optimal.
+ int subtract = 0;
+ for (int i = 0; i < b->NumMaterials(); i++) {
+ if (!b->MatTable[i]) {
+ b->MatTable.remove_at(i);
+ subtract++;
+ for (int k = 0; k < b->NumMeshes(); k++) {
+ auto &m = b->MeshTable[k];
+ for (int q = 0; q < m.NumFaces(); q++) {
+ auto &f = m.FList[q];
+ if (f.getMaterialIndex() >= i) {
+ f.setMaterialIndex(f.getMaterialIndex() - 1);
}
}
-#endif
}
+ i--;
}
}
}
@@ -542,7 +563,7 @@ void t3dFinalizeMaterialList(t3dBODY *b) {
Mat->VertsList.push_back(&Mesh.VBptr[Face.VertexIndex[h]]);
}
assert(k < Mat->VertsList.size());
- Face.MatVertexIndex[h] = (int16)k;
+ Face.setMatVertexIndex(h, k);
}
}
@@ -551,10 +572,11 @@ void t3dFinalizeMaterialList(t3dBODY *b) {
#endif
}
- warning("Partially stubbed t3dFinalizeMaterialList");
-
for (int i = 0; i < b->NumMaterials(); i++) {
auto &Mat = b->MatTable[i];
+ if (!Mat) {
+ warning("nullptr");
+ }
Mat->VBO = b->addVertexBuffer(); // t3dAddVertexBuffer(b, Mat->NumAllocatedVerts);
for (int j = 0; j < (uint32)Mat->NumAddictionalMaterial; j++)
Mat->AddictionalMaterial[j]->VBO = t3dAddVertexBuffer(b, Mat->AddictionalMaterial[j]->NumAllocatedVerts());
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index ffe0161c2a3..6b4382db471 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -249,11 +249,17 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
if ((mat.NumFaces() >= 3) && (mat.VBO)) {
bb = rNewBatchBlock(mat.Texture->ID, mat.Flags, 0, 0);
bb->ViewMatrixNum = ViewMatrixNum;
- bb->NumFaces = (unsigned short int) mat.NumFaces();
bb->FacesList = mat.getFacesList();
bb->VBO = mat.VBO;
- bb->NumVerts = (unsigned short int) mat.NumAllocatedVerts();
- mat.clearFaceList();
+ for (int f = 0; f < bb->FacesList.size(); f++) {
+ if (bb->FacesList[f] >= bb->VBO->_buffer.size()) {
+ for (int o = 0; o < bb->FacesList.size(); o++) {
+ warning("%d", bb->FacesList[o]);
+ }
+ warning("%d > %d (%d)", bb->FacesList[f],bb->VBO->_buffer.size(), bb->NumVerts());
+ }
+ }
+ mat.emptyFacesList(); // We may want to keep the reservation to avoid the extra reallocs here.
// if ( bb->VB == g_lpD3DUserVertexBuffer )
// DebugLogFile("User VB %s with %d verts",mat->Texture->Name,bb->NumVerts);
#if 0
@@ -272,20 +278,18 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
if (cm->VBO == NULL) continue;
bb = rNewBatchBlock(mat.Texture->ID, mat.Flags, cm->Texture->ID, cm->Flags);
bb->ViewMatrixNum = ViewMatrixNum;
- bb->NumFaces = (unsigned short int) cm->NumFaces();
bb->FacesList = cm->getFacesList();
bb->VBO = cm->VBO;
- bb->NumVerts = (unsigned short int) cm->NumAllocatedVerts();
cm->emptyFacesList();
- if (bb->NumVerts == 0) {
#if 0
+ if (bb->NumVerts == 0) {
if (bb->VBO->GetVertexBufferDesc(&VBDesc) != D3D_OK)
DebugLogFile("Can't get VB information for %s", mat->Texture->Name);
else
bb->NumVerts = (unsigned short int) VBDesc.dwNumVertices;
// DebugLogFile("Saving VB %s with %d verts",mat->Texture->Name,bb->NumVerts);
-#endif
}
+#endif
}
}
diff --git a/engines/watchmaker/3d/material.h b/engines/watchmaker/3d/material.h
index fd8aab432b0..dd741204260 100644
--- a/engines/watchmaker/3d/material.h
+++ b/engines/watchmaker/3d/material.h
@@ -52,7 +52,7 @@ private:
Common::Array<uint16> FacesList; // list of verts indices
public:
Common::Array<gVertex*> VertsList; // pointers to pointers to verts
- int NumAllocatedVerts() { return this->VertsList.size(); }; // number of allocated vertex in mat VB
+ int NumAllocatedVerts() { return this->VertsList.size(); }; // number of allocated vertex in mat VB
Common::SharedPtr<VertexBuffer> VBO = nullptr;
// LPDIRECT3DVERTEXBUFFER7 VB; // mat VB struct
int NumAllocatedMesh = 0; // num mesh to check for modifications
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 3b2c5d2bfd9..4141be96655 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -36,6 +36,7 @@
#ifdef USE_OPENGL_GAME
#include "graphics/opengl/system_headers.h"
+#include "watchmaker/file_utils.h"
#include "watchmaker/tga_util.h"
#define MAXTEXTURES 2000
@@ -954,31 +955,26 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
}
-MaterialPtr Renderer::addMaterial(MaterialPtr MList, const Common::String &name, int NumFaces, unsigned int LoaderFlags) {
- MaterialPtr Material = MList;
+bool Renderer::addMaterial(gMaterial &material, const Common::String &name, int NumFaces, unsigned int LoaderFlags) {
bool AlreadyLoaded = FALSE;
- int len = name.size();
-
//warning("AddMaterial(%s)", name.c_str());
- if (((name[len - 1 - 0] == 'i') || (name[len - 1 - 0] == 'I')) &&
- ((name[len - 1 - 1] == 'v') || (name[len - 1 - 1] == 'V')) &&
- ((name[len - 1 - 2] == 'a') || (name[len - 1 - 2] == 'A'))) {
- if ((Material->Movie = gLoadMovie(*_workDirs, name.c_str())) == nullptr)
- return nullptr;
- if ((Material->Texture = gUserTexture(64,
+ if (hasFileExtension(name, "avi")) {
+ if ((material.Movie = gLoadMovie(*_workDirs, name.c_str())) == nullptr)
+ return false;
+ if ((material.Texture = gUserTexture(64,
128)) == nullptr)
// if( (Material->Texture=gUserTexture( Material->Movie->g_psiStreamInfo.rcFrame.right,
// Material->Movie->g_psiStreamInfo.rcFrame.bottom)) == NULL )
- return nullptr;
- Material->addProperty(T3D_MATERIAL_MOVIE);
+ return false;
+ material.addProperty(T3D_MATERIAL_MOVIE);
} else {
- if ((Material->Texture = gLoadTexture(*_workDirs, name.c_str(), LoaderFlags)) == nullptr)
- return nullptr;
+ if ((material.Texture = gLoadTexture(*_workDirs, name.c_str(), LoaderFlags)) == nullptr)
+ return false;
}
//f
- Material->addProperty(T3D_MATERIAL_NOLIGHTMAP);
- return Material;
+ material.addProperty(T3D_MATERIAL_NOLIGHTMAP);
+ return true;
}
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/render/opengl_renderer.cpp b/engines/watchmaker/3d/render/opengl_renderer.cpp
index cd45776d8a3..70af3973557 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.cpp
+++ b/engines/watchmaker/3d/render/opengl_renderer.cpp
@@ -63,6 +63,7 @@ void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, Commo
glBegin(GL_TRIANGLES);
for (int i = 0; i < numFaces; i++) {
int index = faces[i];
+ assert(index <= VBO->_buffer.size());
auto &vertex = VBO->_buffer[index];
//warning("%d/%d %d: [%f, %f, %f], [%f, %f], [%f, %f]", i, numFaces, index, vertex.x, vertex.y, vertex.z, vertex.u1, vertex.v1, vertex.u2, vertex.v2);
//glColor3f((float)i/numFaces, 1.0, 0.0);
@@ -97,9 +98,9 @@ void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, int V
void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, gBatchBlock &bb) {
drawIndexedPrimitivesVBO(primitiveType,
- bb.VBO, 0, bb.NumVerts,
+ bb.VBO, 0, bb.NumVerts(),
bb.FacesList,
- bb.NumFaces/*, 0x0*/
+ bb.NumFaces()/*, 0x0*/
);
}
diff --git a/engines/watchmaker/3d/render/render.cpp b/engines/watchmaker/3d/render/render.cpp
index 4e923e37d78..936d89af4da 100644
--- a/engines/watchmaker/3d/render/render.cpp
+++ b/engines/watchmaker/3d/render/render.cpp
@@ -679,14 +679,7 @@ gBatchBlock *rNewBatchBlock(signed short int T1, unsigned int F1, signed short i
if (!bb) return nullptr;
- *bb = gBatchBlock();
- bb->Texture1 = T1;
- bb->Texture2 = T2;
- bb->Flags1 = F1;
- bb->Flags2 = F2;
- bb->NumFaces = 0;
- bb->NumVerts = 0;
- bb->FacesList.clear();
+ *bb = gBatchBlock(T1, T2, F1, F2);
return bb;
}
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index 04807f8b65d..921a0a3e446 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -39,10 +39,10 @@ namespace Watchmaker {
#define CAMFILEVERSION 2
#define BNDFILEVERSION 2
-void t3dLoadMaterials(WGame &game, t3dBODY *b, Common::SeekableReadStream &stream) {
+void t3dLoadMaterials(WGame &game, t3dBODY *b, Common::SeekableReadStream &stream, int numMaterials) {
int16 loader_numtextures = 0;
WorkDirs &workdirs = game.workDirs;
- for (uint16 material = 0; material < b->NumMaterials(); material++) { // Legge Materiali
+ for (uint16 material = 0; material < numMaterials; material++) { // Legge Materiali
char Name[100] = {}, Appo[100] = {};
unsigned int Flags = 0, flag = 0;
#ifndef WMGEN
@@ -81,10 +81,12 @@ void t3dLoadMaterials(WGame &game, t3dBODY *b, Common::SeekableReadStream &strea
if (LoaderFlags & T3D_HALFTEXTURESIZE) flag = rSURFACEHALF; // Se deve scalare le textures
else flag = 0;
- MaterialPtr mat = b->MatTable[material];
+ MaterialPtr mat(new gMaterial());
+ assert(b->MatTable.size() == material);
+ b->MatTable.push_back(mat);
//warning("Loading material %d", material);
#ifndef WMGEN
- if (!(game._renderer->addMaterial(mat, Appo,/*f1*/0, flag))) { // Carica e scala texture
+ if (!(game._renderer->addMaterial(*mat, Appo,/*f1*/0, flag))) { // Carica e scala texture
warning("Material file %s not found, ", Appo); // Se non trova la texture
mat->Texture = nullptr;
assert(0);
@@ -98,6 +100,7 @@ void t3dLoadMaterials(WGame &game, t3dBODY *b, Common::SeekableReadStream &strea
mat->addColor((uint8)b->AmbientLight.x, (uint8)b->AmbientLight.y, (uint8)b->AmbientLight.z);
loader_numtextures++;
}
+ assert(mat->Texture);
}//__for_material
}
@@ -507,11 +510,11 @@ t3dBODY *t3dBODY::loadFromStream(WGame &game, const Common::String &pname, Commo
this->initNormals(stream);
//-------------------LOADING MATERIALS--------------------------------------
- t3dLoadMaterials(game, this, stream);
+ t3dLoadMaterials(game, this, stream, numMaterials);
//-------------------LOADING LIGHTS--------------------------------------
this->LightTable.reserve(numLights); // Alloca spazio per le luci globali
for (light = 0; light < numLights; light++) {
- this->LightTable.push_back(t3dLIGHT(this, workdirs, stream)); // Azzera luce
+ this->LightTable.push_back(t3dLIGHT(game, this, workdirs, stream)); // Azzera luce
}//__for_light
//-------------------END OF LOADING LIGHTS-------------------------------
diff --git a/engines/watchmaker/3d/t3d_face.cpp b/engines/watchmaker/3d/t3d_face.cpp
index 09113b25c3a..7a6e0f37909 100644
--- a/engines/watchmaker/3d/t3d_face.cpp
+++ b/engines/watchmaker/3d/t3d_face.cpp
@@ -32,14 +32,8 @@ t3dFACE::t3dFACE(t3dBODY *b, Common::SeekableReadStream &stream) {
this->n = b->NList[stream.readSint16LE()]; // Legge puntatore a normale
- uint16 materialIndex = stream.readSint16LE(); // Legge indice materiale
- if (materialIndex >= b->NumMaterials())
- warning("Material index wrong: current index: %d; Max material index %d", materialIndex, b->NumMaterials());
- else {
- mat = b->MatTable[materialIndex]; // Make the pointer to the material
- if (mat->addNumFaces(1/*f2*/) == false) // Add face space to the material
- warning("Can't realloc material faces");
- }
+ _materialIndex = stream.readSint16LE(); // Legge indice materiale
+ _body = b;
}
bool t3dFACE::isVisible() const {
@@ -51,4 +45,22 @@ bool t3dFACE::isVisible() const {
return true;
}
+MaterialPtr t3dFACE::getMaterial() {
+ if (_mat) {
+ return _mat;
+ } else {
+ _mat = _body->MatTable[_materialIndex];
+ return _mat;
+ }
+}
+
+const gMaterial* t3dFACE::getMaterial() const {
+ if (_mat) {
+ return _mat.get();
+ } else {
+ assert(0);
+ }
+}
+
+
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/t3d_face.h b/engines/watchmaker/3d/t3d_face.h
index 0dba41212cb..9e1b37a05cd 100644
--- a/engines/watchmaker/3d/t3d_face.h
+++ b/engines/watchmaker/3d/t3d_face.h
@@ -31,23 +31,40 @@ struct t3dBODY;
struct t3dFACE {
uint32 flags = 0; // face status 4
NormalPtr n; // pointer to the face normal 4
- int16 VertexIndex[3] = {}; // Vertices indices in mesh 6
+private:
int16 MatVertexIndex[3] = {}; // Vertices indices in material 6
+ uint16 _materialIndex = 0;
+ MaterialPtr _mat = nullptr; // pointer to material 4
+ t3dBODY *_body = nullptr;
+public:
+ int16 VertexIndex[3] = {}; // Vertices indices in mesh 6
-private:
- MaterialPtr mat; // pointer to material 4
+ void setMatVertexIndex(int index, int16 value) {
+ MatVertexIndex[index] = value;
+ }
+ uint16 getMatVertexIndex(int index) {
+ return MatVertexIndex[index];
+ }
public:
MaterialPtr lightmap; // pointer to lightmap (or 2nd material) 4
t3dFACE(t3dBODY *b, Common::SeekableReadStream &stream);
- bool hasMaterialFlag(uint32 flag) { return mat->hasFlag(flag); }
- MaterialPtr getMaterial() { return mat; }
- const gMaterial* getMaterial() const { return mat.get(); }
+ bool hasMaterialFlag(uint32 flag) { return getMaterial()->hasFlag(flag); }
+ MaterialPtr getMaterial();
+ const gMaterial* getMaterial() const;
+ uint16 getMaterialIndex() const {
+ return _materialIndex;
+ }
+ void setMaterialIndex(uint32 index) {
+ _materialIndex = index;
+ _mat = nullptr;
+ getMaterial();
+ }
void checkVertices() {
for (int i = 0; i < 3; i++) {
- assert(mat->VertsList.size() > MatVertexIndex[i]);
+ assert(getMaterial()->VertsList.size() > MatVertexIndex[i]);
}
}
diff --git a/engines/watchmaker/module.mk b/engines/watchmaker/module.mk
index b036af05067..a7b1414e09d 100644
--- a/engines/watchmaker/module.mk
+++ b/engines/watchmaker/module.mk
@@ -64,6 +64,7 @@ MODULE_OBJS = \
\
console.o \
extraLS.o \
+ file_utils.o \
game.o \
game_options.o \
globvar.o \
diff --git a/engines/watchmaker/render.h b/engines/watchmaker/render.h
index 29bda2e3711..36e72475012 100644
--- a/engines/watchmaker/render.h
+++ b/engines/watchmaker/render.h
@@ -111,14 +111,17 @@ struct SHADOWBOX {
};
struct gBatchBlock {
- signed short int Texture1, Texture2; // texture ID
- unsigned int Flags1, Flags2; // flags
- signed short int ViewMatrixNum; // view matrix num
- unsigned short int NumFaces; // faces number
- unsigned short int NumVerts; // verts number
+ signed short int Texture1 = 0, Texture2 = 0; // texture ID
+ unsigned int Flags1 = 0, Flags2 = 0; // flags
+ signed short int ViewMatrixNum = 0; // view matrix num
+ unsigned short int NumFaces() { return FacesList.size(); } // faces number
+ unsigned short int NumVerts() { if (VBO) return VBO->_buffer.size(); else return 0; } // verts number
Common::Array<uint16> FacesList; // pointer to faces list
Common::SharedPtr<VertexBuffer> VBO = nullptr;
// LPDIRECT3DVERTEXBUFFER7 VB; // block VB
+
+ gBatchBlock() {}
+ gBatchBlock(signed short int texture1, signed short int texture2, unsigned int flags1, unsigned int flags2) : Texture1(texture1), Texture2(texture2), Flags1(flags1), Flags2(flags2) {}
};
class WorkDirs;
diff --git a/engines/watchmaker/renderer.h b/engines/watchmaker/renderer.h
index c2a039abf39..11cb17551a8 100644
--- a/engines/watchmaker/renderer.h
+++ b/engines/watchmaker/renderer.h
@@ -45,7 +45,7 @@ class Renderer {
public:
Rect _viewport;
Renderer(WorkDirs *workDirs, sdl_wrapper *wrapper) : sdl(wrapper), _workDirs(workDirs) {}
- MaterialPtr addMaterial(MaterialPtr MList, const Common::String &name, int NumFaces, unsigned int LoaderFlags);
+ bool addMaterial(gMaterial &material, const Common::String &name, int NumFaces, unsigned int LoaderFlags);
void initGL();
diff --git a/engines/watchmaker/t3d.h b/engines/watchmaker/t3d.h
index 75a508118db..f913ebbda0b 100644
--- a/engines/watchmaker/t3d.h
+++ b/engines/watchmaker/t3d.h
@@ -270,7 +270,7 @@ struct t3dLIGHT {
t3dV3F SolarColor[4]; // Ambient color value for solar movement
t3dV3F SolarPos[4]; // Position movements due to solar movement
public:
- t3dLIGHT(t3dBODY *b, WorkDirs &workDirs, Common::SeekableReadStream &stream);
+ t3dLIGHT(WGame &game, t3dBODY *b, WorkDirs &workDirs, Common::SeekableReadStream &stream);
private:
void setupVisibleVerticesFromLight(t3dBODY *b);
void SetVisibleFromLight(gVertex *v);
Commit: b51a5c463b9ef1fc66b115d7699b2ad70cec0a9f
https://github.com/scummvm/scummvm/commit/b51a5c463b9ef1fc66b115d7699b2ad70cec0a9f
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Apply color key when loading 2D bitmaps
For now by simply copying the function used in Wintermute.
Changed paths:
engines/watchmaker/3d/render/opengl_2d.cpp
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 6dbf790f2b9..3837583a740 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -126,7 +126,6 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
checkGlError("rBlitter Start");
glEnable(GL_TEXTURE_2D);
- glDisable(GL_ALPHA_TEST);
int dwWidth, dwHeight;
dwWidth = game._renderer->_viewport.width();
@@ -200,8 +199,9 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
}
glClearColor(0,0,1,0);
glEnable(GL_TEXTURE_2D);
- glDisable(GL_ALPHA_TEST);
- glDisable(GL_BLEND);
+ glEnable(GL_ALPHA_TEST);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, bitmap.texId);
glLoadIdentity();
glTranslatef(0, 0, -1.0);
@@ -246,6 +246,31 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
//#endif
}
+// Straight from Wintermute:
+void applyColorKey(Graphics::Surface &surf, byte ckRed, byte ckGreen, byte ckBlue, bool replaceAlpha) {
+ // this is taken from Graphics::TransparentSurface
+ // only difference is that we set the pixel
+ // color to transparent black, like D3DX,
+ // if it matches the color key
+ for (int y = 0; y < surf.h; y++) {
+ for (int x = 0; x < surf.w; x++) {
+ uint32 pix = ((uint32 *)surf.getPixels())[y * surf.w + x];
+ uint8 r, g, b, a;
+ surf.format.colorToARGB(pix, a, r, g, b);
+ if (r == ckRed && g == ckGreen && b == ckBlue) {
+ a = 0;
+ r = 0;
+ g = 0;
+ b = 0;
+ ((uint32 *)surf.getPixels())[y * surf.w + x] = surf.format.ARGBToColor(a, r, g, b);
+ } else if (replaceAlpha) {
+ a = 255;
+ ((uint32 *)surf.getPixels())[y * surf.w + x] = surf.format.ARGBToColor(a, r, g, b);
+ }
+ }
+ }
+}
+
int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
WorkDirs &workDirs = game.workDirs;
if (flags & rTEXTURESURFACE) {
@@ -271,6 +296,7 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
*Texture = gTexture();
Texture->Flags = CurLoaderFlags;
Texture->surface = ReadTgaImage(TextName, *stream, RGBA8888, Texture->Flags);
+ applyColorKey(*Texture->surface, 0, 0, 0, false);
Texture->texId = createTextureFromSurface(*Texture->surface, GL_RGBA);
Texture->name = TextName;
Commit: 90f4baa7440747fc919435bd4893c2a2d9bb389a
https://github.com/scummvm/scummvm/commit/90f4baa7440747fc919435bd4893c2a2d9bb389a
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix wrong argument order to seek()
Changed paths:
engines/watchmaker/saveload.cpp
diff --git a/engines/watchmaker/saveload.cpp b/engines/watchmaker/saveload.cpp
index 970aa2f6089..b46aba6ac35 100644
--- a/engines/watchmaker/saveload.cpp
+++ b/engines/watchmaker/saveload.cpp
@@ -405,7 +405,7 @@ bool DataLoad(WGame &game, const Common::String &FileName, uint8 slot) {
init.Obj[i].pos = stream->readByte();
}
// HACK? (Something is off between 0.92 and the saves in the retail, leading to a slight skew.
- stream->seek(SEEK_CUR, 92);
+ stream->seek(92, SEEK_CUR);
for (int i = 0; i < MAX_ICONS; i++) {
init.InvObj[i].name = stream->readUint16LE();
init.InvObj[i].examine.loadFromStream(*stream);
Commit: 6e1977690f3ca8d5ccbff2c22229e57590a144fa
https://github.com/scummvm/scummvm/commit/6e1977690f3ca8d5ccbff2c22229e57590a144fa
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Basic event fixes for OSystem-support.
Changed paths:
engines/watchmaker/ll/ll_mouse.cpp
engines/watchmaker/renderer.cpp
engines/watchmaker/sdl_wrapper.cpp
engines/watchmaker/watchmaker.cpp
engines/watchmaker/windows_hacks.cpp
diff --git a/engines/watchmaker/ll/ll_mouse.cpp b/engines/watchmaker/ll/ll_mouse.cpp
index b41378d8cbc..7b2bc6fe2db 100644
--- a/engines/watchmaker/ll/ll_mouse.cpp
+++ b/engines/watchmaker/ll/ll_mouse.cpp
@@ -19,7 +19,6 @@
*
*/
-#include <SDL_mouse.h>
#include "watchmaker/ll/ll_mouse.h"
#include "watchmaker/utils.h"
#include "watchmaker/message.h"
@@ -149,9 +148,6 @@ void HandleMouseChanges()
// Mouse movement will have been accumulated prior to calling this function.
// Button flags may also have been changed, this function then applies the button changes.
int curX, curY;
- Uint32 buttonState = SDL_GetMouseState(&curX, &curY);
- bLPressed = buttonState & SDL_BUTTON_LMASK;
- bRPressed = buttonState & SDL_BUTTON_RMASK;
//warning("L: %d %d R: %d %d", bLPressed, bLPressedPrev, bRPressed, bRPressedPrev);
// Button 0 pressed or released
diff --git a/engines/watchmaker/renderer.cpp b/engines/watchmaker/renderer.cpp
index b986a5d4cca..381df58f44b 100644
--- a/engines/watchmaker/renderer.cpp
+++ b/engines/watchmaker/renderer.cpp
@@ -25,6 +25,7 @@
#include "graphics/opengl/system_headers.h"
+#include "common/system.h"
#include "watchmaker/globvar.h"
#include "watchmaker/ll/ll_system.h"
#include "math/glmath.h"
@@ -116,10 +117,7 @@ void Renderer::setCurCameraViewport(t3dF32 fov, uint8 sup) {
}
void Renderer::showFrame() {
- error("TODO: showFrame");
-#if 0
- SDL_GL_SwapWindow(sdl->window);
-#endif
+ g_system->updateScreen();
}
int Renderer::rFitX(int x) {
diff --git a/engines/watchmaker/sdl_wrapper.cpp b/engines/watchmaker/sdl_wrapper.cpp
index b94a848a691..398bf94f67d 100644
--- a/engines/watchmaker/sdl_wrapper.cpp
+++ b/engines/watchmaker/sdl_wrapper.cpp
@@ -21,16 +21,14 @@
#include "watchmaker/sdl_wrapper.h"
#include "watchmaker/classes/do_keyboard.h"
+#include "common/events.h"
+#include "common/system.h"
namespace Watchmaker {
void sdl_wrapper::getWindowSize(unsigned int &width, unsigned int &height) {
-#if 0
- int w, h;
- SDL_GetWindowSize(window, &w, &h);
- width = w;
- height = h;
-#endif
+ width = g_system->getWidth();
+ height = g_system->getHeight();
}
int sdl_wrapper::getBitDepth() const {
@@ -44,6 +42,33 @@ int sdl_wrapper::getBitDepth() const {
}
void sdl_wrapper::pollSDL() {
+ // Process events
+ Common::Event event;
+ while (g_system->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_MOUSEMOVE:
+ mMove += abs(event.relMouse.x);
+ mMove += abs(event.relMouse.y);
+ mMoveX += event.relMouse.x;
+ mMoveY += event.relMouse.y;
+ mPosx = event.mouse.x;
+ mPosy = event.mouse.y;
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ bLPressed = true;
+ break;
+ case Common::EVENT_LBUTTONUP:
+ bLPressed = false;
+ break;
+ case Common::EVENT_KEYUP:
+ KeyTable[event.kbd.keycode] = 0x10;
+ break;
+ case Common::EVENT_QUIT:
+ shouldQuit = true;
+ default:
+ warning("Unhandled event: %d", event.type);
+ }
+ }
#if 0
SDL_Event event;
while (SDL_PollEvent(&event)) {
@@ -51,14 +76,6 @@ void sdl_wrapper::pollSDL() {
case SDL_QUIT:
shouldQuit = true;
break;
- case SDL_MOUSEMOTION:
- mMove += abs(event.motion.xrel);
- mMove += abs(event.motion.yrel);
- mMoveX += event.motion.xrel;
- mMoveY += event.motion.yrel;
- mPosx = event.motion.x;
- mPosy = event.motion.y;
- break;/*
case SDL_MOUSEBUTTONDOWN:
switch (event.button.button) {
case SDL_BUTTON_LEFT:
diff --git a/engines/watchmaker/watchmaker.cpp b/engines/watchmaker/watchmaker.cpp
index 583d4c60166..4ed47e565bd 100644
--- a/engines/watchmaker/watchmaker.cpp
+++ b/engines/watchmaker/watchmaker.cpp
@@ -21,6 +21,7 @@
#include "watchmaker/watchmaker.h"
#include "watchmaker/console.h"
+#include "engines/util.h"
namespace Watchmaker {
@@ -36,6 +37,7 @@ WatchmakerGame::~WatchmakerGame() {
int WMakerMain();
Common::Error WatchmakerGame::run() {
+ initGraphics3d(800, 600);
WMakerMain();
return Common::kNoError;
}
diff --git a/engines/watchmaker/windows_hacks.cpp b/engines/watchmaker/windows_hacks.cpp
index 29206d0b7a4..9e4c6e9eb75 100644
--- a/engines/watchmaker/windows_hacks.cpp
+++ b/engines/watchmaker/windows_hacks.cpp
@@ -19,8 +19,8 @@
*
*/
-#include <SDL_timer.h>
#include "watchmaker/windows_hacks.h"
+#include "common/system.h"
#include "watchmaker/types.h"
namespace Watchmaker {
@@ -30,7 +30,7 @@ void ResetDIKbd(void) {
}
uint32 timeGetTime() {
- return SDL_GetTicks();
+ return g_system->getMillis();
}
void GetLocalTime(SYSTEMTIME *) {
Commit: a4ab7467ef840476243aada41c0faeabe596f72a
https://github.com/scummvm/scummvm/commit/a4ab7467ef840476243aada41c0faeabe596f72a
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Correct texture loading.
Changed paths:
engines/watchmaker/3d/render/opengl_3d.cpp
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 4141be96655..632b0e95ee6 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -572,9 +572,18 @@ int createTextureFromData(int width, int height, int dataSize, void *data, int t
}
if (compressed) {
- glCompressedTexImage2D(GL_TEXTURE_2D, 0, texFormat, width, height, 0, dataSize, data);
+ glCompressedTexImage2D(GL_TEXTURE_2D, // target
+ 0, // level
+ texFormat, // internalFormat
+ width, // width
+ height, // height
+ 0, // border
+ dataSize,
+ data
+ );
+ checkGlError("glCompressedTexImage");
} else {
- glTexImage2D(GL_TEXTURE_2D, 0, texFormat, width, height, 0, dataSize, GL_UNSIGNED_BYTE, data);
+ glTexImage2D(GL_TEXTURE_2D, 0, texFormat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
return texId;
Commit: b72acdbcc39bb6f7dfb1bcfb27c5a1bcb6b99775
https://github.com/scummvm/scummvm/commit/b72acdbcc39bb6f7dfb1bcfb27c5a1bcb6b99775
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Stub lights and halos
Changed paths:
engines/watchmaker/3d/geometry.cpp
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index d456f829e9e..03c5766e85c 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -2502,6 +2502,10 @@ void t3dCalcHalos(t3dBODY *b) {
//uint16 *fp;
t3dV3F v0, v1, v2, v3, tmp;
+ // The userVertexBuffer stuff is not ready yet, giving us nullptr writes.
+ warning("TODO: t3dCalcHalos");
+ return;
+
for (i = 0; i < b->NumLights(); i++) {
t3dLIGHT &l = b->LightTable[i];
if (!(l.Type & T3D_LIGHT_LIGHTON)) continue;
Commit: d511a6f39ba6d38597102a39d97b14a29c9cd567
https://github.com/scummvm/scummvm/commit/d511a6f39ba6d38597102a39d97b14a29c9cd567
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Start adding movie logic.
Changed paths:
engines/watchmaker/3d/material.cpp
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_2d.h
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index 6b4382db471..557957a3f95 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -19,8 +19,9 @@
*
*/
-#include "common/util.h"
#include "watchmaker/3d/material.h"
+#include "common/util.h"
+#include "watchmaker/3d/render/opengl_2d.h"
#include "watchmaker/render.h"
namespace Watchmaker {
@@ -242,10 +243,10 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
#if 0
if (!mat)
return;
-
+#endif
if ((mat.Flags & T3D_MATERIAL_MOVIE))
gUpdateMovie(mat);
-#endif
+
if ((mat.NumFaces() >= 3) && (mat.VBO)) {
bb = rNewBatchBlock(mat.Texture->ID, mat.Flags, 0, 0);
bb->ViewMatrixNum = ViewMatrixNum;
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 3837583a740..8efcd1674b4 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -324,6 +324,37 @@ void rSetLoaderFlags(unsigned int NewLoaderFlags) {
CurLoaderFlags = NewLoaderFlags;
}
+bool gUpdateMovie(gMaterial &mat) {
+ WORD newFrame = 0;
+ DWORD curTime;
+
+ if (mat.Flags & T3D_MATERIAL_MOVIEPAUSED)
+ return TRUE;
+
+ auto mv = mat.Movie;
+
+ if ((mv->curFrame == 0xFFFF) || (!mv->startTime)) {
+ mv->startTime = timeGetTime();
+ newFrame = 0;
+ } else {
+ // Use the time to find which frame we should be drawing
+ curTime = timeGetTime();
+ DWORD elapsedTime = curTime - mv->startTime;
+ newFrame = (WORD)((float)elapsedTime / (1000.f / (float)mv->frameRate));
+
+ if (newFrame >= mv->numFrames) {
+ mv->startTime = curTime;
+ newFrame = 0;
+ }
+ }
+#if 0
+ bool retv=gMovie_SetFrame(mat,newFrame);
+
+ return(retv);
+#endif
+ return true;
+}
+
} // End of namespace Watchmaker
#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/3d/render/opengl_2d.h b/engines/watchmaker/3d/render/opengl_2d.h
index dd7b52f6876..84933806c58 100644
--- a/engines/watchmaker/3d/render/opengl_2d.h
+++ b/engines/watchmaker/3d/render/opengl_2d.h
@@ -43,6 +43,8 @@ extern int NumLogosMaterials;
extern unsigned int CurLoaderFlags;
+bool gUpdateMovie(gMaterial &mat);
+
} // End of namespace Watchmaker
#endif // WATCHMAKER_OPENGL2D_H
Commit: 4bc09524210f8112a0084ebe7ba38629d46e0423
https://github.com/scummvm/scummvm/commit/4bc09524210f8112a0084ebe7ba38629d46e0423
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix rCreateMaterialList
Changed paths:
engines/watchmaker/3d/material.cpp
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index 557957a3f95..8877c01a6a6 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -315,9 +315,6 @@ void rBuildMaterialList(MaterialTable &MatList, unsigned int NumMat, signed shor
MaterialTable rCreateMaterialList(int num) {
MaterialTable list;
list.reserve(num);
- for (int i = 0; i < num; i++) {
- list.push_back(Common::SharedPtr<gMaterial>(new gMaterial()));
- }
return list;
}
Commit: f4fdda44853a933484b96137ae879cdb474b21c9
https://github.com/scummvm/scummvm/commit/f4fdda44853a933484b96137ae879cdb474b21c9
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Convert Keyboard-logic to OSystem
Changed paths:
engines/watchmaker/classes/do_keyboard.cpp
diff --git a/engines/watchmaker/classes/do_keyboard.cpp b/engines/watchmaker/classes/do_keyboard.cpp
index 1d3f7d2a118..2730eeed293 100644
--- a/engines/watchmaker/classes/do_keyboard.cpp
+++ b/engines/watchmaker/classes/do_keyboard.cpp
@@ -19,29 +19,30 @@
*
*/
-#include "watchmaker/game.h"
#include "watchmaker/classes/do_keyboard.h"
-#include "watchmaker/globvar.h"
-#include "watchmaker/define.h"
+#include "common/keyboard.h"
+#include "watchmaker/3d/animation.h"
+#include "watchmaker/3d/geometry.h"
#include "watchmaker/3d/math/llmath.h"
#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/classes/do_camera.h"
+#include "watchmaker/classes/do_dialog.h"
+#include "watchmaker/classes/do_player.h"
+#include "watchmaker/define.h"
+#include "watchmaker/game.h"
+#include "watchmaker/globvar.h"
+#include "watchmaker/ll/ll_anim.h"
+#include "watchmaker/ll/ll_diary.h"
+#include "watchmaker/ll/ll_mesh.h"
+#include "watchmaker/ll/ll_mouse.h"
#include "watchmaker/ll/ll_util.h"
-#include "watchmaker/walk/act.h"
-#include "watchmaker/walk/walkutil.h"
-#include "watchmaker/utils.h"
-#include "watchmaker/3d/geometry.h"
+#include "watchmaker/main.h"
#include "watchmaker/schedule.h"
-#include "watchmaker/classes/do_dialog.h"
#include "watchmaker/t2d/t2d.h"
-#include "watchmaker/main.h"
-#include "watchmaker/ll/ll_diary.h"
-#include "watchmaker/ll/ll_anim.h"
-#include "watchmaker/classes/do_player.h"
-#include "watchmaker/classes/do_camera.h"
-#include "watchmaker/3d/animation.h"
+#include "watchmaker/utils.h"
+#include "watchmaker/walk/act.h"
#include "watchmaker/walk/walk.h"
-#include "watchmaker/ll/ll_mouse.h"
-#include "watchmaker/ll/ll_mesh.h"
+#include "watchmaker/walk/walkutil.h"
namespace Watchmaker {
@@ -143,11 +144,9 @@ void HandleFirstPersonView( void )
t3dF32 dist;
t3dV3F d,n;
- error("TODO: HandleFirstPersonView");
-#if 0
if( ( !Player ) || ( !t3dCurCamera ) || ( bLockCamera ) ) return;
- if( KeyDown(SDL_SCANCODE_A) ) // Alza testa
+ if( KeyDown(Common::KEYCODE_a) ) // Alza testa
{
if( ( dist = CurFloorY+MAX_HEIGHT - ( t3dCurCamera->Source.y + 10*SCALEFACTOR ) ) > 0 )
{
@@ -156,7 +155,7 @@ void HandleFirstPersonView( void )
t3dMoveAndCheck1stCamera( t3dCurRoom, t3dCurCamera, &d );
}
}
- else if( KeyDown(SDL_SCANCODE_Z) ) // Abbassa Testa
+ else if( KeyDown(Common::KEYCODE_z) ) // Abbassa Testa
{
if( ( dist = CurFloorY+KNEE_HEIGHT - ( t3dCurCamera->Source.y - 10*SCALEFACTOR ) ) < 0 )
{
@@ -167,16 +166,16 @@ void HandleFirstPersonView( void )
}
// Se tengo premuto lo shift o un tasto del mouse
- if( KeyDown(SDL_SCANCODE_LSHIFT) || KeyDown(SDL_SCANCODE_RSHIFT) || ( ( bLPressed || bRPressed ) && (mMove>10) ) )
+ if( KeyDown(Common::KEYCODE_LSHIFT) || KeyDown(Common::KEYCODE_RSHIFT) || ( ( bLPressed || bRPressed ) && (mMove>10) ) )
{
t3dVectSub( &d, &t3dCurCamera->Target, &t3dCurCamera->Source );d.y = 0.0f;
t3dVectNormalize( &d );
n.x = -d.z;n.y = 0.0f;n.z = d.x;
dist = (t3dF32)( (t3dF32)mMoveY / (t3dF32)( MainDy/2 ) )*100.0f;
- if( KeyDown(SDL_SCANCODE_UP) )
+ if( KeyDown(Common::KEYCODE_UP) )
d *= (5*SCALEFACTOR );
- else if( KeyDown(SDL_SCANCODE_DOWN) )
+ else if( KeyDown(Common::KEYCODE_DOWN) )
d *= (-5*SCALEFACTOR );
else if( ( (bLPressed) || (bRPressed) ) && (mMoveY) && !bClock33 )
d *= (-dist*SCALEFACTOR );
@@ -184,9 +183,9 @@ void HandleFirstPersonView( void )
t3dVectFill( &d, 0.0f );
dist = (t3dF32)( (t3dF32)mMoveX / (t3dF32)( MainDx/2 ) )*100.0f;
- if( KeyDown(SDL_SCANCODE_LEFT) )
+ if( KeyDown(Common::KEYCODE_LEFT) )
n *= (5*SCALEFACTOR );
- else if( KeyDown(SDL_SCANCODE_RIGHT) )
+ else if( KeyDown(Common::KEYCODE_RIGHT) )
n *= (-5*SCALEFACTOR );
else if( ( (bLPressed) || (bRPressed) ) && (mMoveX) && !bClock33 )
n *= (-dist*SCALEFACTOR );
@@ -202,13 +201,13 @@ void HandleFirstPersonView( void )
x = 0;
y = 0;
- if( KeyDown(SDL_SCANCODE_UP) )
+ if( KeyDown(Common::KEYCODE_UP) )
y = -10;
- else if( KeyDown(SDL_SCANCODE_DOWN) )
+ else if( KeyDown(Common::KEYCODE_DOWN) )
y = MainDy+10;
- if( KeyDown(SDL_SCANCODE_LEFT) )
+ if( KeyDown(Common::KEYCODE_LEFT) )
x = -10;
- else if( KeyDown(SDL_SCANCODE_RIGHT) )
+ else if( KeyDown(Common::KEYCODE_RIGHT) )
x = MainDx+10;
if( x || y )
@@ -239,7 +238,6 @@ void HandleFirstPersonView( void )
t3dVectAdd( &t3dCurCamera->Source, &t3dCurCamera->Source, &d );
t3dVectAdd( &t3dCurCamera->Target, &t3dCurCamera->Target, &d );
}
-#endif
}
@@ -273,9 +271,8 @@ void ProcessKeyboard(WGame &game) {
if (bIngnoreDIKeyboard)
return ;
- error("TODO: Convert to OSystem");
-#if 0
- if (KeyUp(SDL_SCANCODE_ESCAPE)) {
+
+ if (KeyUp(Common::KEYCODE_ESCAPE)) {
if (LoaderFlags & T3D_DEBUGMODE) {
CloseSys(game); // Quitta il gioco
} else {
@@ -297,12 +294,12 @@ void ProcessKeyboard(WGame &game) {
if (bTitoliCodaScrolling || bTitoliCodaStatic)
game.CleanUpAndPostQuit();
}
- }// SDL_SCANCODE_ESCAPE
+ }// Common::KEYCODE_ESCAPE
//se ci sono i crediti ritorna (controlla solo l'ESC)
if (bTitoliCodaStatic || bTitoliCodaScrolling) return;
- if (KeyDown(SDL_SCANCODE_LSHIFT) && KeyUp(SDL_SCANCODE_D))
+ if (KeyDown(Common::KEYCODE_LSHIFT) && KeyUp(Common::KEYCODE_d))
bForceDebug ^= 1;
/* if( KeyDown(SDL_SCANCODE_LSHIFT) ) // Bomba il gioco
@@ -312,10 +309,12 @@ void ProcessKeyboard(WGame &game) {
t3dFree(t3dCurRoom->CameraTable);
}
*/
- if (KeyUp(SDL_SCANCODE_I)) // Escono Informazioni
+ if (KeyUp(Common::KEYCODE_i)) // Escono Informazioni
bShowInfo ^= 1;
- if (KeyUp(SDL_SCANCODE_G)) {
+ if (KeyUp(Common::KEYCODE_g)) {
+ error("TODO: Screenshot support");
+#if 0
FILE *fh;
char str[32];
int i;
@@ -327,20 +326,21 @@ void ProcessKeyboard(WGame &game) {
fclose(fh);
}
rGrabVideo(str, 0);
+#endif
}
- if (KeyUp(SDL_SCANCODE_END)) {
+ if (KeyUp(Common::KEYCODE_END)) {
if (!bFirstPerson)
StartAnim(game, aGIRO);
}
if ((LoaderFlags & T3D_DEBUGMODE) || bForceDebug) {
- if (KeyUp(SDL_SCANCODE_F5))
+ if (KeyUp(Common::KEYCODE_F5))
DataSave("Prova Save", 0);
- if (KeyUp(SDL_SCANCODE_F6))
+ if (KeyUp(Common::KEYCODE_F6))
DataLoad(game, "", 0);
- if (KeyUp(SDL_SCANCODE_W)) { // Modalita' wireframe
+ if (KeyUp(Common::KEYCODE_w)) { // Modalita' wireframe
bForceWire ^= 1;
if (bForceWire)
rSetRenderMode(rWIREFRAMEMODE);
@@ -348,22 +348,22 @@ void ProcessKeyboard(WGame &game) {
rSetRenderMode(rSOLIDMODE);
}
- if (KeyUp(SDL_SCANCODE_B)) // Escono BoundingBox
+ if (KeyUp(Common::KEYCODE_b)) // Escono BoundingBox
bShowBoundingBox ^= 1;
- if (KeyUp(SDL_SCANCODE_BACKSPACE)) // Fa andare le animazioni piu' veloci
+ if (KeyUp(Common::KEYCODE_BACKSPACE)) // Fa andare le animazioni piu' veloci
bFastAnim ^= 1;
- if (KeyUp(SDL_SCANCODE_S))
+ if (KeyUp(Common::KEYCODE_s))
bSkipTalk = TRUE;
- if (KeyUp(SDL_SCANCODE_H))
+ if (KeyUp(Common::KEYCODE_h))
Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dPROVA, 0, 0, NULL, NULL, NULL);
- if (KeyUp(SDL_SCANCODE_E))
+ if (KeyUp(Common::KEYCODE_e))
StartAnim(game, aFOX);
- if (KeyUp(SDL_SCANCODE_J)) {
+ if (KeyUp(Common::KEYCODE_j)) {
if (Player && Player->Mesh) {
ct = Player->Dir * HALF_STEP * 5.0f;
t3dVectAdd(&Player->Mesh->Trasl, &Player->Mesh->Trasl, &ct);
@@ -371,8 +371,8 @@ void ProcessKeyboard(WGame &game) {
}
}
- if (KeyUp(SDL_SCANCODE_P)) {
- if (KeyDown(SDL_SCANCODE_LSHIFT) || KeyDown(SDL_SCANCODE_RSHIFT)) {
+ if (KeyUp(Common::KEYCODE_p)) {
+ if (KeyDown(Common::KEYCODE_LSHIFT) || KeyDown(Common::KEYCODE_RSHIFT)) {
if (++bnd_lev > 5) bnd_lev = 0;
SetBndLevel(game.init, NULL, bnd_lev);
DebugLogWindow("BndLev %d", bnd_lev);
@@ -382,71 +382,71 @@ void ProcessKeyboard(WGame &game) {
}
if (!tasti_per_sfx1) {
- if (KeyUp(SDL_SCANCODE_M)) {
- if (KeyDown(SDL_SCANCODE_LSHIFT))
+ if (KeyUp(Common::KEYCODE_m)) {
+ if (KeyDown(Common::KEYCODE_LSHIFT))
DInputNonExclusiveMouse();
- else if (KeyDown(SDL_SCANCODE_RSHIFT))
+ else if (KeyDown(Common::KEYCODE_RSHIFT))
DInputExclusiveMouse();
}
- if (KeyUp(SDL_SCANCODE_O))
+ if (KeyUp(Common::KEYCODE_o))
bShowExtraLocalizationStrings ^= 1;
} else {
- if (KeyUp(SDL_SCANCODE_K)) {
+ if (KeyUp(Common::KEYCODE_k)) {
PlayAnim --;
- if (KeyDown(SDL_SCANCODE_LCTRL) || KeyDown(SDL_SCANCODE_RCTRL))
+ if (KeyDown(Common::KEYCODE_LCTRL) || KeyDown(Common::KEYCODE_RCTRL))
PlayAnim -= 19;
- if (KeyDown(SDL_SCANCODE_LSHIFT) || KeyDown(SDL_SCANCODE_RSHIFT))
+ if (KeyDown(Common::KEYCODE_LSHIFT) || KeyDown(Common::KEYCODE_RSHIFT))
PlayAnim -= 30;
- printf("PlayAnim %d '%s'\n", PlayAnim, game.init.Anim[PlayAnim].name[0].rawArray()); // TODO DebugString
+ warning("PlayAnim %d '%s'\n", PlayAnim, game.init.Anim[PlayAnim].name[0].rawArray()); // TODO DebugString
}
- if (KeyUp(SDL_SCANCODE_L)) {
+ if (KeyUp(Common::KEYCODE_l)) {
PlayAnim ++;
- if (KeyDown(SDL_SCANCODE_LCTRL) || KeyDown(SDL_SCANCODE_RCTRL))
+ if (KeyDown(Common::KEYCODE_LCTRL) || KeyDown(Common::KEYCODE_RCTRL))
PlayAnim += 19;
- if (KeyDown(SDL_SCANCODE_LSHIFT) || KeyDown(SDL_SCANCODE_RSHIFT))
+ if (KeyDown(Common::KEYCODE_LSHIFT) || KeyDown(Common::KEYCODE_RSHIFT))
PlayAnim += 30;
- printf("PlayAnim %d '%s'\n", PlayAnim, game.init.Anim[PlayAnim].name[0].rawArray()); // TODO DebugString
+ warning("PlayAnim %d '%s'\n", PlayAnim, game.init.Anim[PlayAnim].name[0].rawArray()); // TODO DebugString
}
- if (KeyUp(SDL_SCANCODE_M))
+ if (KeyUp(Common::KEYCODE_m))
StartAnim(game, PlayAnim);
}
- if (KeyDown(SDL_SCANCODE_LSHIFT)) {
+ if (KeyDown(Common::KEYCODE_LSHIFT)) {
void t3dLoadOutdoorLights(const char *pname, t3dBODY * b, int32 ora);
- if (KeyUp(SDL_SCANCODE_F1)) t3dLoadOutdoorLights("c:\\wm\\LMaps\\rxt.t3d", t3dRxt, 1030);
- if (KeyUp(SDL_SCANCODE_F2)) t3dLoadOutdoorLights("c:\\wm\\LMaps\\rxt.t3d", t3dRxt, 1530);
- if (KeyUp(SDL_SCANCODE_F3)) t3dLoadOutdoorLights("c:\\wm\\LMaps\\rxt.t3d", t3dRxt, 1930);
- if (KeyUp(SDL_SCANCODE_F4)) t3dLoadOutdoorLights("c:\\wm\\LMaps\\rxt.t3d", t3dRxt, 2230);
+ if (KeyUp(Common::KEYCODE_F1)) t3dLoadOutdoorLights("c:\\wm\\LMaps\\rxt.t3d", t3dRxt, 1030);
+ if (KeyUp(Common::KEYCODE_F2)) t3dLoadOutdoorLights("c:\\wm\\LMaps\\rxt.t3d", t3dRxt, 1530);
+ if (KeyUp(Common::KEYCODE_F3)) t3dLoadOutdoorLights("c:\\wm\\LMaps\\rxt.t3d", t3dRxt, 1930);
+ if (KeyUp(Common::KEYCODE_F4)) t3dLoadOutdoorLights("c:\\wm\\LMaps\\rxt.t3d", t3dRxt, 2230);
}
- if (KeyUp(SDL_SCANCODE_F11)) IncCurTime(game, 5);
- if (KeyUp(SDL_SCANCODE_F12)) IncCurTime(game, 100);
-
- if (KeyUp(SDL_SCANCODE_1)) CharSetPosition(ocCURPLAYER, 1, NULL);
- if (KeyUp(SDL_SCANCODE_2)) CharSetPosition(ocCURPLAYER, 2, NULL);
- if (KeyUp(SDL_SCANCODE_3)) CharSetPosition(ocCURPLAYER, 3, NULL);
- if (KeyUp(SDL_SCANCODE_4)) CharSetPosition(ocCURPLAYER, 4, NULL);
- if (KeyUp(SDL_SCANCODE_5)) CharSetPosition(ocCURPLAYER, 5, NULL);
- if (KeyUp(SDL_SCANCODE_6)) CharSetPosition(ocCURPLAYER, 6, NULL);
- if (KeyUp(SDL_SCANCODE_7)) CharSetPosition(ocCURPLAYER, 7, NULL);
- if (KeyUp(SDL_SCANCODE_8)) CharSetPosition(ocCURPLAYER, 8, NULL);
- if (KeyUp(SDL_SCANCODE_9)) CharSetPosition(ocCURPLAYER, 9, NULL);
- if (KeyUp(SDL_SCANCODE_KP_0)) CharSetPosition(ocCURPLAYER, 10, NULL);
- if (KeyUp(SDL_SCANCODE_KP_1)) CharSetPosition(ocCURPLAYER, 11, NULL);
- if (KeyUp(SDL_SCANCODE_KP_2)) CharSetPosition(ocCURPLAYER, 12, NULL);
- if (KeyUp(SDL_SCANCODE_KP_3)) CharSetPosition(ocCURPLAYER, 13, NULL);
- if (KeyUp(SDL_SCANCODE_KP_4)) CharSetPosition(ocCURPLAYER, 14, NULL);
- if (KeyUp(SDL_SCANCODE_KP_5)) CharSetPosition(ocCURPLAYER, 15, NULL);
- if (KeyUp(SDL_SCANCODE_KP_6)) CharSetPosition(ocCURPLAYER, 16, NULL);
- if (KeyUp(SDL_SCANCODE_KP_7)) CharSetPosition(ocCURPLAYER, 17, NULL);
- if (KeyUp(SDL_SCANCODE_KP_8)) CharSetPosition(ocCURPLAYER, 18, NULL);
- if (KeyUp(SDL_SCANCODE_KP_9)) CharSetPosition(ocCURPLAYER, 19, NULL);
-
- if (KeyDown(SDL_SCANCODE_LSHIFT))
- if (KeyUp(SDL_SCANCODE_X)) {
+ if (KeyUp(Common::KEYCODE_F11)) IncCurTime(game, 5);
+ if (KeyUp(Common::KEYCODE_F12)) IncCurTime(game, 100);
+
+ if (KeyUp(Common::KEYCODE_1)) CharSetPosition(ocCURPLAYER, 1, NULL);
+ if (KeyUp(Common::KEYCODE_2)) CharSetPosition(ocCURPLAYER, 2, NULL);
+ if (KeyUp(Common::KEYCODE_3)) CharSetPosition(ocCURPLAYER, 3, NULL);
+ if (KeyUp(Common::KEYCODE_4)) CharSetPosition(ocCURPLAYER, 4, NULL);
+ if (KeyUp(Common::KEYCODE_5)) CharSetPosition(ocCURPLAYER, 5, NULL);
+ if (KeyUp(Common::KEYCODE_6)) CharSetPosition(ocCURPLAYER, 6, NULL);
+ if (KeyUp(Common::KEYCODE_7)) CharSetPosition(ocCURPLAYER, 7, NULL);
+ if (KeyUp(Common::KEYCODE_8)) CharSetPosition(ocCURPLAYER, 8, NULL);
+ if (KeyUp(Common::KEYCODE_9)) CharSetPosition(ocCURPLAYER, 9, NULL);
+ if (KeyUp(Common::KEYCODE_KP0)) CharSetPosition(ocCURPLAYER, 10, NULL);
+ if (KeyUp(Common::KEYCODE_KP1)) CharSetPosition(ocCURPLAYER, 11, NULL);
+ if (KeyUp(Common::KEYCODE_KP2)) CharSetPosition(ocCURPLAYER, 12, NULL);
+ if (KeyUp(Common::KEYCODE_KP3)) CharSetPosition(ocCURPLAYER, 13, NULL);
+ if (KeyUp(Common::KEYCODE_KP4)) CharSetPosition(ocCURPLAYER, 14, NULL);
+ if (KeyUp(Common::KEYCODE_KP5)) CharSetPosition(ocCURPLAYER, 15, NULL);
+ if (KeyUp(Common::KEYCODE_KP6)) CharSetPosition(ocCURPLAYER, 16, NULL);
+ if (KeyUp(Common::KEYCODE_KP7)) CharSetPosition(ocCURPLAYER, 17, NULL);
+ if (KeyUp(Common::KEYCODE_KP8)) CharSetPosition(ocCURPLAYER, 18, NULL);
+ if (KeyUp(Common::KEYCODE_KP9)) CharSetPosition(ocCURPLAYER, 19, NULL);
+
+ if (KeyDown(Common::KEYCODE_LSHIFT))
+ if (KeyUp(Common::KEYCODE_x)) {
tasti_per_sfx1 ^= 1;
}
@@ -540,20 +540,20 @@ void ProcessKeyboard(WGame &game) {
*/
}// fine tasti di debug
else {
- if (KeyUp(SDL_SCANCODE_D))
+ if (KeyUp(Common::KEYCODE_d))
bShowRoomDescriptions ^= 1;
- if (KeyUp(SDL_SCANCODE_E))
+ if (KeyUp(Common::KEYCODE_e))
bShowExtraLocalizationStrings ^= 1;
- if (KeyUp(SDL_SCANCODE_P))
+ if (KeyUp(Common::KEYCODE_p))
Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tPDA, NULL, NULL, NULL);
}
- if (KeyUp(SDL_SCANCODE_F8) && PlayerCanSwitch(game._gameVars, 1) && !(InvStatus & INV_ON))
+ if (KeyUp(Common::KEYCODE_F8) && PlayerCanSwitch(game._gameVars, 1) && !(InvStatus & INV_ON))
// && ( (InvStatus & (INV_ON|INV_MODE2)) != (INV_ON|INV_MODE2) ) )
{
- KeyClear(SDL_SCANCODE_F8);
+ KeyClear(Common::KEYCODE_F8);
if (CurPlayer == DARRELL) a = ocVICTORIA;
else a = ocDARRELL;
if (a == (ocDARRELL + CurPlayer)) return ;
@@ -565,35 +565,35 @@ void ProcessKeyboard(WGame &game) {
}
if ((bPlayerInAnim) || (bNotSkippableWalk) || (bDialogActive)) {
- KeyClear(SDL_SCANCODE_F1);
- KeyClear(SDL_SCANCODE_F2);
- KeyClear(SDL_SCANCODE_F3);
- KeyClear(SDL_SCANCODE_TAB);
- KeyClear(SDL_SCANCODE_SPACE);
- KeyClear(SDL_SCANCODE_LCTRL);
- KeyClear(SDL_SCANCODE_RCTRL);
- KeyClear(SDL_SCANCODE_END);
+ KeyClear(Common::KEYCODE_F1);
+ KeyClear(Common::KEYCODE_F2);
+ KeyClear(Common::KEYCODE_F3);
+ KeyClear(Common::KEYCODE_TAB);
+ KeyClear(Common::KEYCODE_SPACE);
+ KeyClear(Common::KEYCODE_LCTRL);
+ KeyClear(Common::KEYCODE_RCTRL);
+ KeyClear(Common::KEYCODE_END);
return;
}
- if (KeyUp(SDL_SCANCODE_F1) && !(InvStatus & INV_ON) && (bT2DActive == tNULL) && PlayerCanSave()) {
+ if (KeyUp(Common::KEYCODE_F1) && !(InvStatus & INV_ON) && (bT2DActive == tNULL) && PlayerCanSave()) {
rGrabVideo("temp.tmp", 1);
Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_SAVE, 0, tOPTIONS, NULL, NULL, NULL);
}
- if (KeyUp(SDL_SCANCODE_F2) && !(InvStatus & INV_ON) && (bT2DActive == tNULL)) {
+ if (KeyUp(Common::KEYCODE_F2) && !(InvStatus & INV_ON) && (bT2DActive == tNULL)) {
rGrabVideo("temp.tmp", 1);
Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_LOAD, 0, tOPTIONS, NULL, NULL, NULL);
}
- if (KeyUp(SDL_SCANCODE_F3) && !(InvStatus & INV_ON) && (bT2DActive == tNULL)) {
+ if (KeyUp(Common::KEYCODE_F3) && !(InvStatus & INV_ON) && (bT2DActive == tNULL)) {
rGrabVideo("temp.tmp", 1);
Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_OPTIONS, 0, tOPTIONS, NULL, NULL, NULL);
}
// Se Premo Control e sono vicino ad una porta o ad una scala
- if ((Player) && ((KeyUp(SDL_SCANCODE_LCTRL)) || (KeyUp(SDL_SCANCODE_RCTRL)))) {
- KeyClear(SDL_SCANCODE_LCTRL);
- KeyClear(SDL_SCANCODE_RCTRL);
+ if ((Player) && ((KeyUp(Common::KEYCODE_LCTRL)) || (KeyUp(Common::KEYCODE_RCTRL)))) {
+ KeyClear(Common::KEYCODE_LCTRL);
+ KeyClear(Common::KEYCODE_RCTRL);
if (bSomeOneSpeak) bSkipTalk = TRUE;
GetRealCharPos(game.init, &ct, ocCURPLAYER, 0);
@@ -616,7 +616,7 @@ void ProcessKeyboard(WGame &game) {
}
}
- if (KeyUp(SDL_SCANCODE_SPACE) && (!IsPlayerInPool())) { // Cambia tra 3a e 1a persona
+ if (KeyUp(Common::KEYCODE_SPACE) && (!IsPlayerInPool())) { // Cambia tra 3a e 1a persona
if (bSomeOneSpeak) bSkipTalk = TRUE;
if ((bFirstPerson == 0) && (!bMovingCamera) && (!bNoFirstPersonSwitch)/* && !( InvStatus & INV_ON )*/)
@@ -625,10 +625,10 @@ void ProcessKeyboard(WGame &game) {
Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
}
- if (KeyUp(SDL_SCANCODE_TAB) && !bLockCamera) // Fa uscire l'inventario
+ if (KeyUp(Common::KEYCODE_TAB) && !bLockCamera) // Fa uscire l'inventario
Event(EventClass::MC_INVENTORY, ME_INVSWITCH, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
- if (KeyDown(SDL_SCANCODE_LEFT) && !(InvStatus & INV_ON) && !(bFirstPerson)) { // Ruota a Destra
+ if (KeyDown(Common::KEYCODE_LEFT) && !(InvStatus & INV_ON) && !(bFirstPerson)) { // Ruota a Destra
AngleY = (-1) * TurnSpeed / 180.0f * T3D_PI;
if ((Player->Walk.CurAction <= aSTAND) || (Player->Walk.CurAction == aROT_DX)) {
PlayerGotoPos[CurPlayer + ocDARRELL] = 0;
@@ -644,7 +644,7 @@ void ProcessKeyboard(WGame &game) {
Player->Walk.CurFrame = ActionStart[Player->Walk.CurAction];
Player->Mesh->CurFrame = Player->Walk.CurFrame;
}
- } else if (KeyDown(SDL_SCANCODE_RIGHT) && !(InvStatus & INV_ON) && !(bFirstPerson)) { // Ruota a Sinistra
+ } else if (KeyDown(Common::KEYCODE_RIGHT) && !(InvStatus & INV_ON) && !(bFirstPerson)) { // Ruota a Sinistra
AngleY = TurnSpeed / 180.0f * T3D_PI;
if ((Player->Walk.CurAction <= aSTAND) || (Player->Walk.CurAction == aROT_SX)) {
PlayerGotoPos[CurPlayer + ocDARRELL] = 0;
@@ -662,13 +662,13 @@ void ProcessKeyboard(WGame &game) {
}
}
- if (KeyDown(SDL_SCANCODE_UP) && !(InvStatus & INV_ON) && !(bFirstPerson)) {
+ if (KeyDown(Common::KEYCODE_UP) && !(InvStatus & INV_ON) && !(bFirstPerson)) {
AngleSpeed = 20.0f;
- } else if (KeyDown(SDL_SCANCODE_DOWN) && !(InvStatus & INV_ON) && !(bFirstPerson)) {
+ } else if (KeyDown(Common::KEYCODE_DOWN) && !(InvStatus & INV_ON) && !(bFirstPerson)) {
AngleSpeed = -20.0f;
}
- if (KeyDown(SDL_SCANCODE_LSHIFT) || KeyDown(SDL_SCANCODE_RSHIFT)) // || (GetKeyState(SDL_SCANCODE_CAPSLOCK) & 0x1)) TODO: Allow for Caps-lock for fast walk
+ if (KeyDown(Common::KEYCODE_LSHIFT) || KeyDown(Common::KEYCODE_RSHIFT)) // || (GetKeyState(Common::KEYCODE_CAPSLOCK) & 0x1)) TODO: Allow for Caps-lock for fast walk
bFastWalk = TRUE;
else
bFastWalk = FALSE;
@@ -687,7 +687,6 @@ void ProcessKeyboard(WGame &game) {
UpdateChar(game, ocCURPLAYER, AngleSpeed * Speed, AngleY);
AngleX = AngleY = AngleSpeed = 0.0f;
}
-#endif
}
/* -----------------28/09/98 17.18-------------------
Commit: cfeb74a8428339397096968aba40cb3ac495e27a
https://github.com/scummvm/scummvm/commit/cfeb74a8428339397096968aba40cb3ac495e27a
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Refactor textures and implement movies
Changed paths:
A engines/watchmaker/3d/dds_header.cpp
A engines/watchmaker/3d/dds_header.h
engines/watchmaker/3d/geometry.cpp
engines/watchmaker/3d/material.cpp
engines/watchmaker/3d/movie.cpp
engines/watchmaker/3d/movie.h
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_2d.h
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/render/opengl_renderer.cpp
engines/watchmaker/3d/render/opengl_renderer.h
engines/watchmaker/3d/render/render.cpp
engines/watchmaker/3d/texture.h
engines/watchmaker/file_utils.cpp
engines/watchmaker/file_utils.h
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/module.mk
engines/watchmaker/render.cpp
engines/watchmaker/tga_util.cpp
diff --git a/engines/watchmaker/3d/dds_header.cpp b/engines/watchmaker/3d/dds_header.cpp
new file mode 100644
index 00000000000..7d5eb2ac965
--- /dev/null
+++ b/engines/watchmaker/3d/dds_header.cpp
@@ -0,0 +1,98 @@
+/* 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/textconsole.h"
+#include "common/ptr.h"
+#include "watchmaker/3d/dds_header.h"
+
+namespace Watchmaker {
+
+DDSHeader::DDSHeader(Common::SeekableReadStream &stream) {
+ //warning("TODO: Implement DDS Header parsing");
+ uint32 retv = MKTAG( ' ','S','D','D' );
+ uint32 magic = stream.readUint32LE();
+ if (magic != retv) {
+ error("parseDDSHeader: Wrong Magic, expected %08X, got %08X\n", retv, magic);
+ }
+ // The size counts the datastructure, which doesn't include the magic
+ int initialPos = stream.pos();
+ uint32 size = stream.readUint32LE();
+ uint32 flags = stream.readUint32LE();
+ this->height = stream.readUint32LE();
+ this->width = stream.readUint32LE();
+ uint32 dataSize = stream.readUint32LE();
+ stream.seek(13 * 4, SEEK_CUR);
+ stream.readUint32LE();
+ uint32 pfFlags = stream.readUint32LE();
+ assert(pfFlags & 0x4); // For now we assume compressed DDS only.
+ compression = (DxtCompression)stream.readUint32LE();
+ // Since we're ignoring a fair amount of header, we still need to position
+ // ourselves as if we read it.
+ stream.seek(initialPos + size, SEEK_SET);
+}
+
+uint32 blockSize(DxtCompression compression) {
+ switch(compression) {
+ case DxtCompression::DXT1:
+ return 8;
+ default:
+ return 16;
+ }
+}
+
+uint32 DDSHeader::dataSize() const {
+ int blockCount = ceil(width / 4.0) * ceil(height / 4.0);
+ return blockCount * blockSize(compression);
+}
+
+class DDSTextureData : public TextureData {
+private:
+ unsigned int _dataSize = 0;
+ byte *_data = nullptr;
+ DDSHeader _header;
+public:
+ DDSTextureData(byte *data, uint32 dataSize, DDSHeader header) : TextureData(header.compression),
+ _data(data),
+ _dataSize(dataSize),
+ _header(header) {}
+ ~DDSTextureData() override {
+ delete[] _data;
+ }
+ DxtCompression _compression;
+ int getWidth() const override { return _header.width; }
+ int getHeight() const override { return _header.height; }
+ int getDataSize() const override { return _dataSize; }
+ const void *getData() const override { return _data; }
+};
+
+Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream& stream) {
+ DDSHeader header(stream);
+ return loadDdsTexture(stream, header);
+}
+
+Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream& stream, DDSHeader &header) {
+ assert(header.width > 0);
+ unsigned char *data = new unsigned char[header.dataSize()]();
+ stream.read(data, header.dataSize());
+ return Common::SharedPtr<TextureData>(new DDSTextureData(data, header.dataSize(), header));
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/dds_header.h b/engines/watchmaker/3d/dds_header.h
new file mode 100644
index 00000000000..df7f215b984
--- /dev/null
+++ b/engines/watchmaker/3d/dds_header.h
@@ -0,0 +1,73 @@
+/* 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 WATCHMAKER_DDSHEADER_H
+#define WATCHMAKER_DDSHEADER_H
+
+#include "common/ptr.h"
+#include "common/stream.h"
+
+namespace Watchmaker {
+
+enum class DxtCompression : uint32 {
+ UNCOMPRESSED = 0,
+ DXT1 = MKTAG('1','T','X','D'),
+ DXT2 = MKTAG('2','T','X','D'),
+ DXT3 = MKTAG('3','T','X','D'),
+ DXT4 = MKTAG('4','T','X','D'),
+ DXT5 = MKTAG('5','T','X','D')
+};
+
+class TextureData {
+public:
+ DxtCompression _compression;
+ TextureData(DxtCompression compression) : _compression(compression) {}
+ virtual ~TextureData() {}
+ virtual int getWidth() const = 0;
+ virtual int getHeight() const = 0;
+ virtual int getDataSize() const = 0;
+ virtual const void *getData() const = 0;
+};
+
+class Texture {
+public:
+ virtual ~Texture() {}
+ virtual void assignData(const TextureData &data) = 0;
+ virtual void bind() = 0;
+};
+
+
+struct DDSHeader {
+ DDSHeader() {}
+ DDSHeader(Common::SeekableReadStream &stream);
+ int height = 0;
+ int width = 0;
+ uint32 dataSize() const;
+ DxtCompression compression = DxtCompression::UNCOMPRESSED;
+};
+
+//Common::SharedPtr<Texture> loadTgaTextureData(Common::SeekableReadStream &stream);
+Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream& stream, DDSHeader &header);
+Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream& stream);
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_DDSHEADER_H
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index 03c5766e85c..be5e447e5de 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -386,8 +386,6 @@ void t3dReleaseBody(t3dBODY *b) {
b->LightmapTable.clear();
if (b->MirrorMatTable.size() > 0) {
- for (int i = 0; i < b->NumMirrorMaterials(); i++)
- b->MirrorMatTable[i]->Movie = nullptr;
rRemoveMaterials(b->MirrorMatTable);
}
b->MirrorMatTable.clear();
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index 8877c01a6a6..a60893ec955 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -64,11 +64,6 @@ MaterialPtr rAddMaterial(gMaterial &Material, const Common::String &TextName, in
return nullptr;
}
-MaterialPtr rAddMaterial(MaterialTable &MList, const Common::String &TextName, int NumFaces, unsigned int LoaderFlags) {
- MaterialPtr &Material=MList[0];
- rAddMaterial(*Material, TextName, NumFaces, LoaderFlags);
-}
-
void gMaterial::addProperty(int flag) {
this->Flags |= flag;
}
@@ -245,7 +240,7 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
return;
#endif
if ((mat.Flags & T3D_MATERIAL_MOVIE))
- gUpdateMovie(mat);
+ mat.Movie->updateMovie();
if ((mat.NumFaces() >= 3) && (mat.VBO)) {
bb = rNewBatchBlock(mat.Texture->ID, mat.Flags, 0, 0);
diff --git a/engines/watchmaker/3d/movie.cpp b/engines/watchmaker/3d/movie.cpp
index 5f015df6cec..93b3be7cf51 100644
--- a/engines/watchmaker/3d/movie.cpp
+++ b/engines/watchmaker/3d/movie.cpp
@@ -20,7 +20,191 @@
*/
#include "watchmaker/3d/movie.h"
+#include "watchmaker/3d/dds_header.h"
+#include "watchmaker/file_utils.h"
+#include "watchmaker/windows_hacks.h"
+#include "watchmaker/work_dirs.h"
namespace Watchmaker {
+gMovie::gMovie(Common::SharedPtr<Common::SeekableReadStream> stream, Texture *texture, const Common::String &name) : _name(name), _stream(stream), _texture(texture) {
+ _numFrames = stream->readUint16LE();
+ _width = stream->readUint16LE();
+ _height = stream->readUint16LE();
+ _keyFrame = stream->readByte();
+ _frameRate = stream->readByte();
+
+ _header = DDSHeader(*stream);
+ _numBlocks = _width * _height / 16;
+ _curFrame = 0xFFFF;
+
+ _frameOffsets = new uint32[_numFrames]{};
+ if (!_frameOffsets) {
+ error("gLoadMovie FAILED: Can't alloc Movie->frameOffsets struct");
+ }
+
+ _buffer = new uint8[bufferSize()]{};
+ _surfaceBuffer = new uint8[_header.dataSize()]{};
+ _frameStream = new Common::MemoryReadStream(_surfaceBuffer, _header.dataSize(), DisposeAfterUse::NO);
+ if (!_buffer) {
+ error("gLoadMovie FAILED: Can't alloc Movie->buffer struct");
+ }
+
+ //read frame offsets
+ for (int i = 0; i < _numFrames; i++) {
+ _frameOffsets[i] = _stream->readUint32LE();
+ }
+}
+
+Common::SharedPtr<gMovie> gLoadMovie(WorkDirs &workDirs, const char *TextName, Texture *texture) {
+ //convert .avi name in .wmm
+ Common::String finalName = replaceExtension(TextName, "wmm");
+
+ auto stream = workDirs.resolveFile(finalName);
+ if (!stream) {
+ DebugLogFile("gLoadMovie FAILED: Can't find movie file\n");
+ return nullptr;
+ }
+ auto Movie = Common::SharedPtr<gMovie>(new gMovie(stream, texture, TextName));
+ Movie->_name = TextName;
+ if (!Movie) {
+ DebugLogFile("gLoadMovie FAILED: Can't alloc Movie struct");
+ return nullptr;
+ }
+
+ // Movie->frameRate=240;
+ return Movie;
+}
+
+void gMovie::loadThisFrameData(uint32 frame)
+{
+ _stream->seek(_frameOffsets[frame], SEEK_SET);
+ //read frame data
+ int size = 0;
+ if ((frame+1)==_numFrames) {
+ size = _stream->size() - _frameOffsets[frame];
+ } else {
+ size = _frameOffsets[frame+1] - _frameOffsets[frame];
+ }
+ assert(size <= bufferSize());
+ _stream->read(_buffer, size);
+}
+
+//build a new frame by difference from previous
+void gMovie::buildNewFrame(byte *surf, uint32 frame) {
+ loadThisFrameData(frame);
+
+ DWORD bitArraySize=_numBlocks>>3;
+ byte *buf=&_buffer[bitArraySize];
+ WORD curBlock=0;
+
+ for(int i=0; i<bitArraySize; i++) {
+ byte block = _buffer[i];
+ if(!block) {
+ curBlock += 8;
+ continue; //everything is equal
+ }
+
+ for(int j=0; j<8; j++, curBlock++) {
+ if(block & (1<<j) ) {
+ memcpy(&surf[curBlock<<3],buf,8); buf+=8;
+ }
+ }//for j
+ }//for
+}
+
+bool gMovie::setFrame(uint32 newFrame) {
+ warning("Set Frame: %d\t%s", newFrame, _name.c_str());
+ if (_curFrame == newFrame)
+ return true;
+
+ //do we have to replace the whole frame or do we have to built it?
+ bool rebuildFrame = true;
+ if (_curFrame == 0xFFFF) rebuildFrame = false;
+ else if (!(newFrame % _keyFrame)) rebuildFrame = false; //it's a keyframe
+
+ _header.dataSize();
+#if 0
+ DDSURFACEDESC2 ddsd2;
+ ddsd2.dwSize = sizeof(DDSURFACEDESC2);
+
+ if ((mv->surf->Lock(NULL, &ddsd2, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL))) { // Lock and fill with the dds
+ DebugLogFile("gMovie_SetFrame: Can't lock surface DDS");
+ return NULL;
+ }
+#endif
+ if (!rebuildFrame) {
+ loadThisFrameData(newFrame);
+ memcpy(_surfaceBuffer, _buffer, _header.dataSize());
+ } else {
+ if ((_curFrame + 1) != newFrame) { //we can't directly build this frame because the current frame is not his previous
+ WORD startFrame;
+ WORD prevKey = (newFrame / _keyFrame) * _keyFrame;
+
+ if ((_curFrame > newFrame) || (_curFrame < prevKey)) {
+ loadThisFrameData(prevKey);
+ memcpy(_surfaceBuffer, _buffer, _header.dataSize());
+ startFrame = prevKey + 1;
+ } else startFrame = _curFrame + 1;
+ for (WORD i = startFrame; i < newFrame; i++) {
+ buildNewFrame(_surfaceBuffer, i);
+ }
+ }
+ buildNewFrame(_surfaceBuffer, newFrame);
+ }
+
+ _frameStream->seek(0, SEEK_SET);
+ auto tex = loadDdsTexture(*_frameStream, _header);
+ _texture->assignData(*tex);
+#if 0
+ if (mat->Texture->lpDDSurface->Blt(NULL, mv->surf, NULL, DDBLT_WAIT, NULL) != DD_OK) {
+ DebugLogFile("gMovie_SetFrame: Can't Blit DDS texture");
+ return NULL;
+ }
+#endif
+ _curFrame = newFrame;
+
+ return true;
+}
+
+//*********************************************************************************************
+bool gMovie::updateMovie() {
+ int16 newFrame = 0;
+
+ if (_paused)
+ return TRUE;
+
+ warning("Update Movie: %s", _name.c_str());
+
+ if ((_curFrame == 0xFFFF) || (!_startTime)) {
+ _startTime = timeGetTime();
+ newFrame = 0;
+ } else {
+ // Use the time to find which frame we should be drawing
+ uint32 curTime = timeGetTime();
+ DWORD elapsedTime = curTime - _startTime;
+ newFrame = (WORD)((float)elapsedTime / (1000.f / (float)_frameRate));
+
+ if (newFrame >= _numFrames) {
+ _startTime = curTime;
+ newFrame = 0;
+ }
+ }
+
+ return setFrame(newFrame);
+}
+
+int gMovie::frameSize(int index) {
+ if ((index + 1) < _numFrames) {
+ return _frameOffsets[index + 1] - _frameOffsets[index];
+ } else {
+ return _stream->size() - _frameOffsets[index];
+ }
+}
+
+uint32 gMovie::bufferSize() const {
+ return (_numBlocks / 8) + 8 * _numBlocks; //bit array + max different blocks
+}
+
+
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/movie.h b/engines/watchmaker/3d/movie.h
index 79f3ea36ee8..86ade66cd3e 100644
--- a/engines/watchmaker/3d/movie.h
+++ b/engines/watchmaker/3d/movie.h
@@ -22,31 +22,56 @@
#ifndef WATCHMAKER_MOVIE_H
#define WATCHMAKER_MOVIE_H
+#include "common/memstream.h"
+#include "watchmaker/3d/dds_header.h"
#include "watchmaker/types.h"
#include "watchmaker/utils.h"
namespace Watchmaker {
struct gMovie {
- Common::SharedPtr<Common::SeekableReadStream> stream;
- uint16 numFrames;
- uint16 curFrame;
- uint16 width;
- uint16 height;
- uint16 numBlocks;
- uint32 startTime;
- uint8 keyFrame;
- uint8 frameRate;
-
- uint32 *frameOffsets;
- uint8 *buffer;
- // TODO
+private:
+ Common::MemoryReadStream *_frameStream = nullptr;
+public:
+ Common::String _name;
+ Common::SharedPtr<Common::SeekableReadStream> _stream;
+ uint16 _numFrames;
+ uint16 _curFrame;
+ uint16 _width;
+ uint16 _height;
+ uint16 _numBlocks;
+ uint32 _startTime;
+ uint8 _keyFrame;
+ uint8 _frameRate;
+
+ uint32 *_frameOffsets;
+ uint8 *_buffer;
+ uint8 *_surfaceBuffer;
+
+ DDSHeader _header;
+
+ Texture *_texture = nullptr;
+
+ bool _paused = false;
+
+ gMovie(Common::SharedPtr<Common::SeekableReadStream> stream, Texture *texture, const Common::String& name);
+
+ bool setFrame(uint32 newFrame);
+ void loadThisFrameData(uint32 frame);
+ void buildNewFrame(byte *surf, uint32 frame);
+ bool updateMovie();
~gMovie() {
//warning("TODO: Clean up gMovie properly");
}
+private:
+ int frameSize(int index);
+ uint32 bufferSize() const;
};
+class WorkDirs;
+Common::SharedPtr<gMovie> gLoadMovie(WorkDirs &workDirs, const char *TextName, Texture *texture);
+
} // End of namespace Watchmaker
#endif // WATCHMAKER_MOVIE_H
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 8efcd1674b4..5d329a87f98 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -57,7 +57,7 @@ unsigned int CurLoaderFlags;
unsigned int gGetBitmapListPosition() {
unsigned int pos = 1;
- while (gBitmapList[pos].surface != nullptr) {
+ while (!gBitmapList[pos].isEmpty()) {
pos++;
}
@@ -202,7 +202,7 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glBindTexture(GL_TEXTURE_2D, bitmap.texId);
+ bitmap.texture->bind();
glLoadIdentity();
glTranslatef(0, 0, -1.0);
//glTranslatef((2.0 / dposx) - 1.0, (2.0 / dposy) - 1.0, 0.0f);
@@ -295,9 +295,11 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
gTexture *Texture = &gBitmapList[pos];
*Texture = gTexture();
Texture->Flags = CurLoaderFlags;
- Texture->surface = ReadTgaImage(TextName, *stream, RGBA8888, Texture->Flags);
- applyColorKey(*Texture->surface, 0, 0, 0, false);
- Texture->texId = createTextureFromSurface(*Texture->surface, GL_RGBA);
+ auto surface = ReadTgaImage(TextName, *stream, RGBA8888, Texture->Flags);
+ applyColorKey(*surface, 0, 0, 0, false);
+ auto texData = createTextureFromSurface(*surface, GL_RGBA);
+ Texture->texture = createGLTexture();
+ Texture->texture->assignData(*texData);
Texture->name = TextName;
if (flags & rSURFACESTRETCH) { // Also rSURFACEFLIP
@@ -307,15 +309,15 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
warned = true;
}
// HACK: Just set a dimension at all:
- Texture->DimX = Texture->surface->w;
- Texture->DimY = Texture->surface->h;
+ Texture->DimX = surface->w;
+ Texture->DimY = surface->h;
} else {
- Texture->DimX = Texture->surface->w;
- Texture->DimY = Texture->surface->h;
+ Texture->DimX = surface->w;
+ Texture->DimY = surface->h;
}
- Texture->RealDimX = Texture->surface->w;
- Texture->RealDimY = Texture->surface->h;
+ Texture->RealDimX = surface->w;
+ Texture->RealDimY = surface->h;
// TODO: Colour-keying
return pos;
}
@@ -324,37 +326,6 @@ void rSetLoaderFlags(unsigned int NewLoaderFlags) {
CurLoaderFlags = NewLoaderFlags;
}
-bool gUpdateMovie(gMaterial &mat) {
- WORD newFrame = 0;
- DWORD curTime;
-
- if (mat.Flags & T3D_MATERIAL_MOVIEPAUSED)
- return TRUE;
-
- auto mv = mat.Movie;
-
- if ((mv->curFrame == 0xFFFF) || (!mv->startTime)) {
- mv->startTime = timeGetTime();
- newFrame = 0;
- } else {
- // Use the time to find which frame we should be drawing
- curTime = timeGetTime();
- DWORD elapsedTime = curTime - mv->startTime;
- newFrame = (WORD)((float)elapsedTime / (1000.f / (float)mv->frameRate));
-
- if (newFrame >= mv->numFrames) {
- mv->startTime = curTime;
- newFrame = 0;
- }
- }
-#if 0
- bool retv=gMovie_SetFrame(mat,newFrame);
-
- return(retv);
-#endif
- return true;
-}
-
} // End of namespace Watchmaker
#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/3d/render/opengl_2d.h b/engines/watchmaker/3d/render/opengl_2d.h
index 84933806c58..dd7b52f6876 100644
--- a/engines/watchmaker/3d/render/opengl_2d.h
+++ b/engines/watchmaker/3d/render/opengl_2d.h
@@ -43,8 +43,6 @@ extern int NumLogosMaterials;
extern unsigned int CurLoaderFlags;
-bool gUpdateMovie(gMaterial &mat);
-
} // End of namespace Watchmaker
#endif // WATCHMAKER_OPENGL2D_H
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 632b0e95ee6..c2ab7a21079 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -458,7 +458,7 @@ void gBuildAlternateName(char *AltName, char *Name) {
}
//*********************************************************************************************
-gTexture *gUserTexture(unsigned int dimx, unsigned int dimy) {
+gTexture *gUserTexture(Texture *texture, unsigned int dimx, unsigned int dimy) {
bool AlreadyLoaded = FALSE, bAlpha = FALSE;
gTexture *Texture;
int pos;
@@ -516,8 +516,6 @@ gTexture *gUserTexture(unsigned int dimx, unsigned int dimy) {
dimy = 32;
else
dimy = 16;
-
- Texture->surface = gCreateSurface(dimx, dimy, nullptr);
#if 0
DDSurfDesc.dwWidth = dimx;
DDSurfDesc.dwHeight = dimy;
@@ -541,197 +539,94 @@ gTexture *gUserTexture(unsigned int dimx, unsigned int dimy) {
#endif
}
+ Texture->texture = texture;
return Texture;
}
-int createTextureFromData(int width, int height, int dataSize, void *data, int texFormat) {
- unsigned int texId = 0;
- glGenTextures(1, &texId);
-
- glBindTexture(GL_TEXTURE_2D, texId);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-
- bool compressed = false;
- // TODO: Check both compiletime and runtime for the existence of EXT_texture_compression_s3tc
-
- switch (texFormat) {
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- compressed = true;
- break;
- case GL_RGBA:
- case GL_RGB:
- compressed = false;
- break;
- default:
- warning("Texture format not handled: %d", texFormat);
- }
-
- if (compressed) {
- glCompressedTexImage2D(GL_TEXTURE_2D, // target
- 0, // level
- texFormat, // internalFormat
- width, // width
- height, // height
- 0, // border
- dataSize,
- data
- );
- checkGlError("glCompressedTexImage");
- } else {
- glTexImage2D(GL_TEXTURE_2D, 0, texFormat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
- }
-
- return texId;
-}
-
-struct DDSHeader {
- int height = 0;
- int width = 0;
-};
-
-DDSHeader parseDDSHeader(Common::SeekableReadStream &stream) {
- DDSHeader header;
- //warning("TODO: Implement DDS Header parsing");
- uint32 retv = ' SDD'; //MAKEFOURCC( 'D','D','S',' ' );
- uint32 magic = stream.readUint32LE();
- if (magic != retv) {
- error("parseDDSHeader: Wrong Magic, expected %08X, got %08X\n", retv, magic);
+GLuint dxtCompressionToTextureFormat(DxtCompression compression) {
+ switch (compression) {
+ case DxtCompression::UNCOMPRESSED:
+ return GL_RGBA;
+ case DxtCompression::DXT1:
+ return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ case DxtCompression::DXT2:
+ error("DXT2 Support is not implemented");
+ case DxtCompression::DXT3:
+ return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
+ case DxtCompression::DXT4:
+ error("DXT4 Support is not implemented");
+ case DxtCompression::DXT5:
+ return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
}
- uint32 size = stream.readUint32LE();
- uint32 flags = stream.readUint32LE();
- header.height = stream.readUint32LE();
- header.width = stream.readUint32LE();
- stream.seek(size + 4, SEEK_SET);
- return header;
-}
-
-struct DDSurface {
- int width;
- int height;
- int dataSize;
- void *data;
-};
-
-DDSurface *parseDDS(Common::SeekableReadStream &stream) {
- DDSHeader header = parseDDSHeader(stream);
- auto dataSize = stream.size() - stream.pos();
- auto data = new unsigned char[dataSize]();
- stream.read(data, dataSize);
- DDSurface *result = new DDSurface;
- result->width = header.width;
- result->height = header.height;
- result->data = data;
- result->dataSize = dataSize;
- return result;
-}
-
-int createTextureFromSurface(Graphics::Surface &surface, int texFormat) {
- return createTextureFromData(surface.w, surface.h, surface.pitch * surface.h, surface.getPixels(), texFormat);
}
-int createCompressedTextureFromSurface(DDSurface &surface) {
- return createTextureFromData(surface.width, surface.height, surface.dataSize, surface.data, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
-}
-
-//*********************************************************************************************
-Common::SharedPtr<gMovie> gLoadMovie(WorkDirs &workDirs, const char *TextName) {
- bool AlreadyLoaded = FALSE, bAlpha = FALSE;
- uint32 i;
- char finalName[MAX_PATH];
-
- auto Movie = Common::SharedPtr<gMovie>(new gMovie());
- if (!Movie) {
- DebugLogFile("gLoadMovie FAILED: Can't alloc Movie struct");
- return nullptr;
+class OpenGLTexture : public Texture {
+public:
+ unsigned int _texId;
+ OpenGLTexture() {
+ glGenTextures(1, &_texId);
}
- *Movie = gMovie();
-
- //convert .avi name in .wmm
- strcpy(finalName, TextName);
- {
- int i = strlen(finalName) - 1;
- while (i > 0) {
- if (finalName[i] == '.') {
- finalName[i] = '\0';
- break;
- }
- i--;
+ OpenGLTexture(unsigned int texId) : _texId(texId) {}
+ void assignData(const TextureData &data) override {
+ glBindTexture(GL_TEXTURE_2D, _texId);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+
+ // TODO: Check both compiletime and runtime for the existence of EXT_texture_compression_s3tc
+ GLuint texFormat = dxtCompressionToTextureFormat(data._compression);
+ bool compressed = data._compression != DxtCompression::UNCOMPRESSED;
+
+ if (compressed) {
+ glCompressedTexImage2D(GL_TEXTURE_2D, // target
+ 0, // level
+ texFormat, // internalFormat
+ data.getWidth(), // width
+ data.getHeight(), // height
+ 0, // border
+ data.getDataSize(),
+ data.getData()
+ );
+ checkGlError("glCompressedTexImage");
+ } else {
+ glTexImage2D(GL_TEXTURE_2D, 0, texFormat, data.getWidth(), data.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data.getData());
}
- strcat(finalName, ".wmm");
- }
-
-
- //load movie file
- Movie->stream = workDirs.resolveFile(finalName);
-// Movie->fp=fopen("c:\\wm\\TMaps2DDS\\fiammata.wmm","rb");
-// Movie->fp=fopen("c:\\wm\\TMaps2DDS\\medicalshow.wmm","rb");
- if (!Movie->stream) {
- DebugLogFile("gLoadMovie FAILED: Can't find movie file\n");
- return nullptr;
}
+ void bind() override {
+ glBindTexture(GL_TEXTURE_2D, _texId);
+ };
+};
- Movie->numFrames = Movie->stream->readUint16LE();
- Movie->width = Movie->stream->readUint16LE();
- Movie->height = Movie->stream->readUint16LE();
- Movie->keyFrame = Movie->stream->readByte();
- Movie->frameRate = Movie->stream->readByte();
- //uint32 readMagic = Movie->stream->readUint32LE();
-
- DDSHeader header = parseDDSHeader(*Movie->stream);
- Movie->numBlocks = Movie->width * Movie->height / 16;
- Movie->curFrame = 0xFFFF;
-
- Movie->frameOffsets = (uint32 *)t3dMalloc(sizeof(uint32) * Movie->numFrames);
- if (!Movie->frameOffsets) {
- DebugLogFile("gLoadMovie FAILED: Can't alloc Movie->frameOffsets struct");
- return nullptr;
- }
-
- uint16 maxlen = (Movie->numBlocks / 8) + 8 * Movie->numBlocks; //bit array + max different blocks
- Movie->buffer = (uint8 *)t3dMalloc(maxlen);
- if (!Movie->buffer) {
- DebugLogFile("gLoadMovie FAILED: Can't alloc Movie->buffer struct");
- return nullptr;
- }
-
- //read frame offsets
- for (i = 0; i < Movie->numFrames; i++) {
- Movie->frameOffsets[i] = Movie->stream->readUint32LE();
- }
-
- //check if the files are ok
-
- {
- //create surface
- //warning("TODO: Create compressed surface");
-#if 0
- DDSURFACEDESC2 ddsd2;
-
- //create compressed surface
- memcpy(&ddsd2, &Movie->surfDesc, sizeof(DDSURFACEDESC2));
-
- ddsd2.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
-
- if (!(Movie->surf = gCreateSurface(&ddsd2, Movie->surf))) {
- DebugLogFile("gLoadMovie: gCreateSurface FAILED: Can't create surface DDS");
- return NULL;
+class SurfaceBackedTextureData : public TextureData {
+ bool _owned = true;
+public:
+ Graphics::Surface *_surface;
+ SurfaceBackedTextureData(Graphics::Surface *surface, bool owned = true) : TextureData(DxtCompression::UNCOMPRESSED), _surface(surface), _owned(owned) {}
+ ~SurfaceBackedTextureData() override {
+ if (_owned) {
+ _surface->free();
+ delete _surface;
}
-#endif
}
+ int getWidth() const override { return _surface->w; }
+ int getHeight() const override { return _surface->h; }
+ int getDataSize() const override { return _surface->w * _surface->h * _surface->format.bytesPerPixel; }
+ const void *getData() const override { return _surface->getPixels(); }
+};
-// Movie->frameRate=240;
- return Movie;
+Texture *createGLTexture() {
+ return new OpenGLTexture();
+}
+
+Common::SharedPtr<TextureData> createTextureFromSurface(Graphics::Surface &surface, int texFormat) {
+ return Common::SharedPtr<TextureData>(new SurfaceBackedTextureData(&surface, false));
}
//*********************************************************************************************
gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int LoaderFlags) {
bool bAlpha = FALSE, bUseAlternate = FALSE;
- gTexture *Texture = nullptr;
+ gTexture *texture = nullptr;
int32 pos = 0;
char AlternateName[500] {};
uint32 date1 = 0, date2 = 0, time1 = 0, time2 = 0;
@@ -748,9 +643,9 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
for (uint32 i = 0; i < gNumTextureList; i++) {
if (gTextureList[i].name.equalsIgnoreCase(TextName)) {
//Texture already loaded; just assign pointers
- Texture = &gTextureList[i];
- Texture->ID = i;
- return Texture;
+ texture = &gTextureList[i];
+ texture->ID = i;
+ return texture;
}
}
@@ -793,8 +688,9 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
DebugLogFile("gLoadTexture: Can't create more textures");
return nullptr;
}
- Texture = &gTextureList[pos];
- *Texture = gTexture();
+ texture = &gTextureList[pos];
+ *texture = gTexture();
+ texture->texture = new OpenGLTexture();
if (bUseAlternate) {
auto stream = workDirs.resolveFile(AlternateName);
@@ -802,11 +698,10 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
DebugLogFile("gAddMaterial:gLoadTexture: Cannot find %s.\n", AlternateName);
return nullptr;
}
- auto compressed = parseDDS(*stream);
- dwWidth = compressed->width;
- dwHeight = compressed->height;
- Texture->texId = createCompressedTextureFromSurface(*compressed);
- delete compressed;
+ auto ddsTextureData = loadDdsTexture(*stream);
+ texture->texture->assignData(*ddsTextureData);
+ dwWidth = ddsTextureData->getWidth();
+ dwHeight = ddsTextureData->getHeight();
lpSSource = nullptr;
#if 0
if (gRenderFlags & gDXT1SUPPORTED) {
@@ -843,7 +738,9 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
} else { // TGA
auto stream = workDirs.resolveFile(TextName);
auto image = ReadTgaImage(TextName, *stream, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), 0); // TODO Flags
- createTextureFromSurface(*image, GL_RGBA);
+ SurfaceBackedTextureData texData(image);
+
+ texture->texture->assignData(texData);
#if 0
//warning("TODO: Handle TGA");
if (!t3dOpenFile(TextName)) {
@@ -881,7 +778,7 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
}
}
#endif
- Texture->name = TextName;
+ texture->name = TextName;
if (bUseAlternate) {
#if 0
@@ -909,8 +806,8 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
Texture->lpDDSurface->Unlock(NULL);
#endif
}
- Texture->RealDimX = dwWidth;
- Texture->RealDimY = dwHeight;
+ texture->RealDimX = dwWidth;
+ texture->RealDimY = dwHeight;
if (LoaderFlags & rSURFACEHALF) {
warning("Half-res loading not implemented");
@@ -954,13 +851,13 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
#endif
}
- Texture->ID = pos;
+ texture->ID = pos;
- Texture->Flags = CurLoaderFlags;
- Texture->DimX = dwWidth;
- Texture->DimY = dwHeight;
+ texture->Flags = CurLoaderFlags;
+ texture->DimX = dwWidth;
+ texture->DimY = dwHeight;
- return Texture;
+ return texture;
}
@@ -968,10 +865,10 @@ bool Renderer::addMaterial(gMaterial &material, const Common::String &name, int
bool AlreadyLoaded = FALSE;
//warning("AddMaterial(%s)", name.c_str());
if (hasFileExtension(name, "avi")) {
- if ((material.Movie = gLoadMovie(*_workDirs, name.c_str())) == nullptr)
+ auto tex = createGLTexture();
+ if ((material.Movie = gLoadMovie(*_workDirs, name.c_str(), tex)) == nullptr)
return false;
- if ((material.Texture = gUserTexture(64,
- 128)) == nullptr)
+ if ((material.Texture = gUserTexture(tex, 64, 128)) == nullptr)
// if( (Material->Texture=gUserTexture( Material->Movie->g_psiStreamInfo.rcFrame.right,
// Material->Movie->g_psiStreamInfo.rcFrame.bottom)) == NULL )
return false;
diff --git a/engines/watchmaker/3d/render/opengl_renderer.cpp b/engines/watchmaker/3d/render/opengl_renderer.cpp
index 70af3973557..cd26a878533 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.cpp
+++ b/engines/watchmaker/3d/render/opengl_renderer.cpp
@@ -153,7 +153,7 @@ void OpenGLRenderer::setTexture(int stage, void *texture) {
}
}
void OpenGLRenderer::setTexture(int stage, const gTexture &texture) {
- glBindTexture(GL_TEXTURE_2D, texture.texId);
+ texture.texture->bind();
}
void setGlFeature(GLint feature, bool state) {
diff --git a/engines/watchmaker/3d/render/opengl_renderer.h b/engines/watchmaker/3d/render/opengl_renderer.h
index 1e5548b5f73..8e294e210e6 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.h
+++ b/engines/watchmaker/3d/render/opengl_renderer.h
@@ -67,7 +67,8 @@ enum class PrimitiveType {
TRIANGLE
};
-int createTextureFromSurface(Graphics::Surface &surface, int texFormat);
+Common::SharedPtr<TextureData> createTextureFromSurface(Graphics::Surface &surface, int texFormat);
+Texture *createGLTexture();
class OpenGLRenderer {
public:
diff --git a/engines/watchmaker/3d/render/render.cpp b/engines/watchmaker/3d/render/render.cpp
index 936d89af4da..87cd0e3cd11 100644
--- a/engines/watchmaker/3d/render/render.cpp
+++ b/engines/watchmaker/3d/render/render.cpp
@@ -534,9 +534,9 @@ bool rRenderScene(void) {
continue;
}
- if (lpLogos->Material->Texture)
+ if (lpLogos->Material->Texture) {
g_renderer->setTexture(0, lpLogos->Material->Texture);
-
+ }
#if 0 // TODO!
hres = g_renderer->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
D3DFVF_TLVERTEX,
diff --git a/engines/watchmaker/3d/texture.h b/engines/watchmaker/3d/texture.h
index 25d9271b267..dd3e4eac0a9 100644
--- a/engines/watchmaker/3d/texture.h
+++ b/engines/watchmaker/3d/texture.h
@@ -23,17 +23,17 @@
#define WATCHMAKER_TEXTURE_H
#include "common/str.h"
+#include "common/textconsole.h"
+#include "watchmaker/3d/dds_header.h"
#include "graphics/surface.h"
#include "watchmaker/surface.h"
namespace Watchmaker {
-struct SDL_Texture;
// Texture structs
struct gTexture {
Common::String name;
- Graphics::Surface *surface = nullptr; // 2d surface
- int texId = 0; // OpenGL tex id
+ Texture *texture = nullptr;
int RealDimX = 0; // original dimensions
int RealDimY = 0; // original dimensions
int DimX = 0; // current dimensions
@@ -42,7 +42,10 @@ struct gTexture {
int Flags = 0; // Flags
bool isEmpty() {
- return texId == 0;
+ return texture == nullptr;
+ }
+ void clear() {
+ error("TODO: Clear texture");
}
};
diff --git a/engines/watchmaker/file_utils.cpp b/engines/watchmaker/file_utils.cpp
index 7c20c015bef..8a24cf53cfd 100644
--- a/engines/watchmaker/file_utils.cpp
+++ b/engines/watchmaker/file_utils.cpp
@@ -38,3 +38,13 @@ bool hasFileExtension(const char *str, Common::String extension) {
Common::String string(str);
return hasFileExtension(string, extension);
}
+
+Common::String replaceExtension(const char *str, const Common::String &extension) {
+ Common::String baseStr(str);
+ auto separator = baseStr.findLastOf('.');
+ if (separator == Common::String::npos) {
+ return baseStr + "." + extension;
+ } else {
+ return baseStr.substr(0, separator + 1) + extension;
+ }
+}
\ No newline at end of file
diff --git a/engines/watchmaker/file_utils.h b/engines/watchmaker/file_utils.h
index 3cc4ec4958d..8cd13a88f10 100644
--- a/engines/watchmaker/file_utils.h
+++ b/engines/watchmaker/file_utils.h
@@ -28,5 +28,6 @@ Common::String readT3dString(Common::SeekableReadStream& stream);
// TODO: This can probably just be replaced with .hasSuffixIgnoreCase
bool hasFileExtension(const Common::String &str, const Common::String &extension);
bool hasFileExtension(const char *str, Common::String extension);
+Common::String replaceExtension(const char *str, const Common::String &extension);
#endif // WATCHMAKER_FILE_UTILS_H
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 07c6af6a5c8..0d3110233cc 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -567,7 +567,7 @@ void ChangeRoom(WGame &game, Common::String n, uint8 pos, int32 an) {
for (j = 0; j < T3D_MAX_SHADOWBOX_PER_CHAR; j++) {
if (Character[i]->ShadowBox[j]) {
for (k = 0; k < MAX_SHADOWS_PER_LIGHT; k++) {
- Character[i]->ShadowBox[j]->ShadowsList[k].ProjectiveTexture.surface = nullptr;
+ Character[i]->ShadowBox[j]->ShadowsList[k].ProjectiveTexture.clear();
}
}
}
diff --git a/engines/watchmaker/module.mk b/engines/watchmaker/module.mk
index a7b1414e09d..3375eadf8ec 100644
--- a/engines/watchmaker/module.mk
+++ b/engines/watchmaker/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/watchmaker
MODULE_OBJS = \
3d/animation.o \
+ 3d/dds_header.o \
3d/geometry.o \
3d/light.o \
3d/loader.o \
diff --git a/engines/watchmaker/render.cpp b/engines/watchmaker/render.cpp
index 4f08778671c..f3d5bad2ac9 100644
--- a/engines/watchmaker/render.cpp
+++ b/engines/watchmaker/render.cpp
@@ -239,93 +239,6 @@ void rBlitScreenBuffer(void) { // Should probably go to opengl_2d
//warning("STUBBED: rBlitScreenBuffer");
}
-bool gMovie_SetFrame(gMaterial *mat, WORD newFrame) {
- Common::SharedPtr<gMovie> mv = mat->Movie;
-
- if (mv->curFrame == newFrame) return TRUE;
-
- //do we have to replace the whole frame or do we have to built it?
- char rebuildFrame = 1;
- if (mv->curFrame == 0xFFFF) rebuildFrame = 0;
- else if (!(newFrame % mv->keyFrame)) rebuildFrame = 0; //it's a keyframe
-#if 0
- DDSURFACEDESC2 ddsd2;
- ddsd2.dwSize = sizeof(DDSURFACEDESC2);
-
- if ((mv->surf->Lock(NULL, &ddsd2, DDLOCK_NOSYSLOCK | DDLOCK_WAIT, NULL))) { // Lock and fill with the dds
- DebugLogFile("gMovie_SetFrame: Can't lock surface DDS");
- return NULL;
- }
-
- if (!rebuildFrame) {
- gMovie_LoadThisFrameData(mv, newFrame);
- memcpy(ddsd2.lpSurface, mv->buffer, ddsd2.dwLinearSize);
- } else {
- if ((mv->curFrame + 1) != newFrame) { //we can't directly build this frame because the current frame is not his previous
- WORD startFrame;
- WORD prevKey = (newFrame / mv->keyFrame) * mv->keyFrame;
-
- if ((mv->curFrame > newFrame) || (mv->curFrame < prevKey)) {
- gMovie_LoadThisFrameData(mv, prevKey);
- memcpy(ddsd2.lpSurface, mv->buffer, ddsd2.dwLinearSize);
- startFrame = prevKey + 1;
- } else startFrame = mv->curFrame + 1;
-
- for (WORD i = startFrame; i < newFrame; i++) {
- gMovie_BuildNewFrame((BYTE *)ddsd2.lpSurface, mv, i);
- }
-
- }
-
- gMovie_BuildNewFrame((BYTE *)ddsd2.lpSurface, mv, newFrame);
-
- }
-
- if ((mv->surf->Unlock(NULL))) {
- DebugLogFile("gMovie_SetFrame: Can't unlock surface DDS");
- return NULL;
- }
-
- if (mat->Texture->lpDDSurface->Blt(NULL, mv->surf, NULL, DDBLT_WAIT, NULL) != DD_OK) {
- DebugLogFile("gMovie_SetFrame: Can't Blit DDS texture");
- return NULL;
- }
-
- mv->curFrame = newFrame;
-
- return TRUE;
-#endif
-}
-
-//*********************************************************************************************
-bool gUpdateMovie(gMaterial *mat) {
- WORD newFrame = 0;
- DWORD curTime;
-
- if (mat->hasFlag(T3D_MATERIAL_MOVIEPAUSED))
- return TRUE;
-
- Common::SharedPtr<gMovie> mv = mat->Movie;
-
- if ((mv->curFrame == 0xFFFF) || (!mv->startTime)) {
- mv->startTime = timeGetTime();
- newFrame = 0;
- } else {
- // Use the time to find which frame we should be drawing
- curTime = timeGetTime();
- DWORD elapsedTime = curTime - mv->startTime;
- newFrame = (WORD)((float)elapsedTime / (1000.f / (float)mv->frameRate));
-
- if (newFrame >= mv->numFrames) {
- mv->startTime = curTime;
- newFrame = 0;
- }
- }
-
- bool retv = gMovie_SetFrame(mat, newFrame);
- return (retv);
-}
-
} // End of namespace Watchmaker
#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/tga_util.cpp b/engines/watchmaker/tga_util.cpp
index f842a129d2e..c0684ae4581 100644
--- a/engines/watchmaker/tga_util.cpp
+++ b/engines/watchmaker/tga_util.cpp
@@ -27,8 +27,6 @@
namespace Watchmaker {
-const Graphics::PixelFormat RGBA8888(32, 8, 8, 8, 8, 24, 16, 8, 0);
-
Graphics::Surface *ReadTgaImage(const char *Name, Common::SeekableReadStream &stream, Graphics::PixelFormat format, unsigned int flag) {
Image::TGADecoder tgaDecoder;
if (!tgaDecoder.loadStream(stream)) {
Commit: 29f690682d2b71ea66eb212b39c04f1533d37fd0
https://github.com/scummvm/scummvm/commit/29f690682d2b71ea66eb212b39c04f1533d37fd0
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Implement font loading.
Changed paths:
A engines/watchmaker/fonts.cpp
A engines/watchmaker/fonts.h
engines/watchmaker/classes/do_dialog.cpp
engines/watchmaker/classes/do_system.cpp
engines/watchmaker/extraLS.cpp
engines/watchmaker/game.cpp
engines/watchmaker/game.h
engines/watchmaker/globvar.cpp
engines/watchmaker/globvar.h
engines/watchmaker/ll/ll_string.cpp
engines/watchmaker/ll/ll_string.h
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/ll/ll_util.h
engines/watchmaker/module.mk
engines/watchmaker/render.h
engines/watchmaker/renderer.cpp
engines/watchmaker/renderer.h
engines/watchmaker/struct.h
engines/watchmaker/sysdef.h
engines/watchmaker/t2d/t2d.cpp
engines/watchmaker/t2d/t2d_internal.h
diff --git a/engines/watchmaker/classes/do_dialog.cpp b/engines/watchmaker/classes/do_dialog.cpp
index 58ed5c8726d..75336b3d5a0 100644
--- a/engines/watchmaker/classes/do_dialog.cpp
+++ b/engines/watchmaker/classes/do_dialog.cpp
@@ -494,7 +494,7 @@ void UpdateDialogMenu(WGame &game, int16 dmx, int16 dmy, uint8 db) {
void PaintDialog(WGame &game) {
int32 a, ca1, ca2;
int32 tx, ty;
- uint8 tc;
+ FontColor tc;
Init &init = game.init;
if ((bDialogActive == FALSE) || (CurDialog == dNULL) || (bDialogMenuActive == FALSE))
@@ -530,7 +530,7 @@ void PaintDialog(WGame &game) {
}
if (CurDlgItem == a) tc = RED_FONT;
- DisplayDDText(*game._renderer, Sentence[init.DlgMenu[a].titolo], &StandardFont, tc, tx, ty, 0, 0, 0, 0);
+ DisplayDDText(*game._renderer, Sentence[init.DlgMenu[a].titolo], FontKind::Standard, tc, tx, ty, 0, 0, 0, 0);
}
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index a4c1ef8eeac..5ed6a77bc3f 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -107,15 +107,13 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
int32 y_offs; //offset verticale dall'inizio dello schermo (praticamente l'altezza delle bande orizzontali sopra e sotto)
char visibile;
STitoliCoda *c;
- struct SFont *f;
+ FontKind f;
int32 width, height, bpp;
Init &init = game.init;
rGetScreenInfos((unsigned int *)&width, (unsigned int *)&height, (unsigned int *)&bpp);
-// f = &ComputerFont;
- f = &PDAFont;
-// f = &StandardFont;
+ f = FontKind::PDA;
y_offs = (width - (width * 74 / 100)) / 2; //circa 1.35:1
if (initialize) {
@@ -159,7 +157,7 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
game.CleanUpAndPostQuit();
}
- rGetTextDim("{", f->Table, &x, &y);
+ game._fonts.getTextDim("{", f, &x, &y);
text_y_inc = y;
additional_text_y_inc = (int32)((t3dF32)y * 50.f / 100.f);
empty_x_space = x * 2;
@@ -178,7 +176,7 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
if (init._creditsNames[j].flags & CF_IMG) {
c->s = init._creditsNames[j].name;
- rGetTextDim(c->s, f->Table, &c->dx, &c->dy);
+ game._fonts.getTextDim(c->s, f, &c->dx, &c->dy);
c->px = width / 2 + empty_x_space;
c->py = next_y + 32 - c->dy / 2;
c->tnum = -1;
@@ -219,7 +217,7 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
next_y += additional_text_y_inc;
c->s = init._creditsRoles[k].role;
- rGetTextDim(c->s, f->Table, &c->dx, &c->dy);
+ game._fonts.getTextDim(c->s, f, &c->dx, &c->dy);
c->px = width / 2 - c->dx - empty_x_space;
c->py = next_y;
c->tnum = -1;
@@ -227,7 +225,7 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
}
c->s = init._creditsNames[j].name;
- rGetTextDim(c->s, f->Table, &c->dx, &c->dy);
+ game._fonts.getTextDim(c->s, f, &c->dx, &c->dy);
c->px = width / 2 + empty_x_space;
c->py = next_y;
next_y += text_y_inc;
@@ -267,7 +265,7 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
rClear(c->tnum, 0, 0, c->dx, c->dy, 0, 0, 0);
//Renderizza la scritta nella surface
- rPrintText(c->s, c->tnum, f->Color[WHITE_FONT], f->Table, 0, 0);
+ game._renderer->printText(c->s, c->tnum, f, WHITE_FONT, 0, 0);
rSetBitmapName(c->tnum, "tit di coda");
if (TitoliCoda_End == c) {
@@ -355,7 +353,7 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
uint16 j, k;
int32 y_offs; //offset verticale dall'inizio dello schermo (praticamente l'altezza delle bande orizzontali sopra e sotto)
STitoliCoda *c;
- struct SFont *f;
+ FontKind f;
int32 width, height, bpp;
uint32 next_time;
uint32 cur_time;
@@ -364,8 +362,7 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
rGetScreenInfos((unsigned int *)&width, (unsigned int *)&height, (unsigned int *)&bpp);
-// f = &ComputerFont;
- f = &PDAFont;
+ f = FontKind::PDA;
y_offs = (width - (width * 74 / 100)) / 2; //circa 1.35:1
time_inc = 2500;
@@ -382,7 +379,7 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
game.CleanUpAndPostQuit();
}
- rGetTextDim("{", f->Table, &x, &y);
+ game._fonts.getTextDim("{", f, &x, &y);
text_y_inc = y;
additional_text_y_inc = (int32)((t3dF32)y * 40.f / 100.f);
@@ -399,7 +396,7 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
k = init._creditsNames[j].role;
c->s = init._creditsRoles[k].role;
- rGetTextDim(c->s, f->Table, &c->dx, &c->dy);
+ game._fonts.getTextDim(c->s, f, &c->dx, &c->dy);
c->px = (width - c->dx) / 2;
c->py = y_offs + ((height - y_offs * 2) - (c->dy * 4)) / 2; //4 numero di comodo
c->tnum = -1;
@@ -410,7 +407,7 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
}
c->s = init._creditsNames[j].name;
- rGetTextDim(c->s, f->Table, &c->dx, &c->dy);
+ game._fonts.getTextDim(c->s, f, &c->dx, &c->dy);
c->px = (width - c->dx) / 2;
c->py = next_y;
next_y += text_y_inc;
@@ -458,7 +455,7 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
rClear(c->tnum, 0, 0, c->dx, c->dy, 0, 0, 0);
//Renderizza la scritta nella surface
- rPrintText(c->s, c->tnum, f->Color[WHITE_FONT], f->Table, 0, 0);
+ game._renderer->printText(c->s, c->tnum, f, WHITE_FONT, 0, 0);
rSetBitmapName(c->tnum, "tit di coda");
DebugLogFile("tcStart %s", c->s);
@@ -508,11 +505,11 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
void PaintIntroText(Renderer &renderer) {
if (T1t) {
DisplayD3DRect(renderer, rT1.px, rT1.py, rT1.dx, rT1.dy, rT1.r, rT1.g, rT1.b, rT1.a);
- DisplayDDText(renderer, T1t, &ComputerFont, CYAN_FONT, T1.px, T1.py, 0, 0, 0, 0);
+ DisplayDDText(renderer, T1t, FontKind::Computer, CYAN_FONT, T1.px, T1.py, 0, 0, 0, 0);
}
if (T2t) {
DisplayD3DRect(renderer, rT2.px, rT2.py, rT2.dx, rT2.dy, rT2.r, rT2.g, rT2.b, rT2.a);
- DisplayDDText(renderer, T2t, &ComputerFont, CYAN_FONT, T2.px, T2.py, 0, 0, 0, 0);
+ DisplayDDText(renderer, T2t, FontKind::Computer, CYAN_FONT, T2.px, T2.py, 0, 0, 0, 0);
}
}
@@ -838,7 +835,7 @@ void doSystem(WGame &game) {
T1t = nullptr;
if (TheMessage->lparam[2] > 0) {
T1t = SysSent[TheMessage->lparam[2]];
- rGetTextDim(T1t, ComputerFont.Table, &T1.dx, &T1.dy);
+ game._fonts.getTextDim(T1t, FontKind::Computer, &T1.dx, &T1.dy);
rT1.dx = T1.dx + INTRO_TEXT_BORDER_X * 2;
rT1.dy = T1.dy + INTRO_TEXT_BORDER_Y * 2;
rT1.r = R_BASE;
@@ -855,7 +852,7 @@ void doSystem(WGame &game) {
T2t = nullptr;
if (TheMessage->lparam[2] > 0) {
T2t = SysSent[TheMessage->lparam[2]];
- rGetTextDim(T2t, ComputerFont.Table, &T2.dx, &T2.dy);
+ game._fonts.getTextDim(T2t, FontKind::Computer, &T2.dx, &T2.dy);
rT2.dx = T2.dx + INTRO_TEXT_BORDER_X * 2;
rT2.dy = T2.dy + INTRO_TEXT_BORDER_Y * 2;
rT2.r = R_BASE;
@@ -884,7 +881,7 @@ void doSystem(WGame &game) {
//RoomInfo.f = &StandardFont;
//RoomInfo.f = &ComputerFont;
- RoomInfo.f = &PDAFont;
+ RoomInfo.f = FontKind::PDA;
strcpy(RoomInfo.name, game.getCurRoom().desc);
@@ -897,7 +894,7 @@ void doSystem(WGame &game) {
}
rGetScreenInfos((unsigned int *)&width, (unsigned int *)&height, (unsigned int *)&bpp);
- rGetTextDim(RoomInfo.fullstring, RoomInfo.f->Table, &RoomInfo.dx, &RoomInfo.dy);
+ game._fonts.getTextDim(RoomInfo.fullstring, RoomInfo.f, &RoomInfo.dx, &RoomInfo.dy);
RoomInfo.tnum = rCreateSurface(RoomInfo.dx, RoomInfo.dy, rBITMAPSURFACE);
if ((!RoomInfo.tnum) || (RoomInfo.tnum == -1)) {
DebugLogWindow("EFFECT_ROOMINFO: can't create surface");
diff --git a/engines/watchmaker/extraLS.cpp b/engines/watchmaker/extraLS.cpp
index 6d4bcd9b53a..0af10a1d403 100644
--- a/engines/watchmaker/extraLS.cpp
+++ b/engines/watchmaker/extraLS.cpp
@@ -92,8 +92,8 @@ void CheckExtraLocalizationStrings(Renderer &renderer, uint32 id) {
if (newID) {
int x, y;
- rGetTextDim(ExtraLS[newID], StandardFont.Table, &x, &y);
- extraLS_BMP = CreateTooltipBitmap(renderer, ExtraLS[newID], &StandardFont, WHITE_FONT, EXTRALS_BKG_COLOR_R, EXTRALS_BKG_COLOR_G, EXTRALS_BKG_COLOR_B);
+ renderer._fonts->getTextDim(ExtraLS[newID], FontKind::Standard, &x, &y);
+ extraLS_BMP = CreateTooltipBitmap(renderer, ExtraLS[newID], WHITE_FONT, EXTRALS_BKG_COLOR_R, EXTRALS_BKG_COLOR_G, EXTRALS_BKG_COLOR_B);
extraLS_bmpPosX = (800 - x) / 2;
extraLS_bmpPosY = 600 - (y + 12);
}
diff --git a/engines/watchmaker/fonts.cpp b/engines/watchmaker/fonts.cpp
new file mode 100644
index 00000000000..1f1757b3b47
--- /dev/null
+++ b/engines/watchmaker/fonts.cpp
@@ -0,0 +1,112 @@
+/* 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 "watchmaker/fonts.h"
+#include "main.h"
+#include "watchmaker/game.h"
+
+namespace Watchmaker {
+
+Fonts::~Fonts() {
+ for (auto table : _tables) {
+ delete[] table;
+ }
+}
+
+uint16* Fonts::setupFontTable(Common::SeekableReadStream &stream) {
+ uint32 dim = stream.size();
+ uint16 *tab = new uint16[dim]{};
+
+ for (int i=0; i<dim/sizeof(uint16); i++) {
+ tab[i] = stream.readUint16LE();
+ }
+
+ _tables.push_back(tab);
+
+ return tab;
+}
+
+void Fonts::loadFont(WGame &game, struct SFont *f, const Common::String &n) {
+ Common::String name = constructPath(game.workDirs._miscDir, n, "fnt");
+ auto stream = game.workDirs.resolveFile(name);
+ if ((f->table = setupFontTable(*stream)) == nullptr) {
+ DebugLogFile("Failed to load Font. Quitting ...");
+ CloseSys(game);
+ }
+
+ Common::String basename = n.substr(0, n.findLastOf('.'));
+ for (char a = 0; a < MAX_FONT_COLORS; a++) {
+ Common::String tgaName = constructPath(game.workDirs._miscDir, basename + (a + '0')) + ".tga";
+ if ((f->color[a] = rLoadBitmapImage(game, tgaName.c_str(), rBITMAPSURFACE | rSURFACEFLIP)) <= 0) {
+ DebugLogFile("Failed to load Font2. Quitting ...");
+ CloseSys(game);
+ }
+ }
+}
+
+void Fonts::loadFonts(WGame &game, WindowInfo &windowInfo) {
+ if ((windowInfo.width >= 1024) || (windowInfo.height >= 768)) {
+ loadFont(game, &StandardFont, "1024NlFont.fnt");
+ loadFont(game, &ComputerFont, "1024ComputerFont.fnt");
+ loadFont(game, &PDAFont, "1024PDAFont.fnt");
+ } else if ((windowInfo.width >= 800) || (windowInfo.height >= 600)) {
+ loadFont(game, &StandardFont, "800NlFont.fnt");
+ loadFont(game, &ComputerFont, "800ComputerFont.fnt");
+ loadFont(game, &PDAFont, "800PDAFont.fnt");
+ } else if ((windowInfo.width >= 640) || (windowInfo.height >= 480)) {
+ loadFont(game, &StandardFont, "640NlFont.fnt");
+ loadFont(game, &ComputerFont, "640ComputerFont.fnt");
+ loadFont(game, &PDAFont, "640PDAFont.fnt");
+ }
+}
+
+SFont *Fonts::fontForKind(FontKind font) {
+ switch (font) {
+ case FontKind::Standard:
+ return &StandardFont;
+ case FontKind::Computer:
+ return &ComputerFont;
+ case FontKind::PDA:
+ return &PDAFont;
+ }
+}
+
+void Fonts::getTextDim(char *s, FontKind font, int *x, int *y) {
+ if (!s)
+ return;
+
+ SFont *fontTable = fontForKind(font);
+
+ int i = 0;
+ int nextx = 0, nexty = 0;
+ byte c = 0;
+ while ( (c=s[i]) != 0) {
+ i++;
+
+ nextx += fontTable->table[c * 4 + 2];
+ nexty = fontTable->table[c * 4 + 3];
+ }
+
+ *x = nextx;
+ *y = nexty;
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/fonts.h b/engines/watchmaker/fonts.h
new file mode 100644
index 00000000000..8fe6f1e3f2a
--- /dev/null
+++ b/engines/watchmaker/fonts.h
@@ -0,0 +1,61 @@
+/* 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 WATCHMAKER_FONTS_H
+#define WATCHMAKER_FONTS_H
+
+#include "common/stream.h"
+#include "watchmaker/renderer.h"
+#include "watchmaker/sysdef.h"
+
+namespace Watchmaker {
+
+enum class FontKind {
+ Standard,
+ Computer,
+ PDA
+};
+
+struct SFont {
+ uint16 *table = nullptr;
+ int32 color[MAX_FONT_COLORS] = {};
+};
+
+class WGame;
+class Fonts {
+ Common::Array<uint16*> _tables;
+ uint16 *setupFontTable(Common::SeekableReadStream &stream);
+ void loadFont(WGame &game, struct SFont *f, const Common::String &n);
+public:
+ SFont *fontForKind(FontKind);
+ SFont StandardFont;
+ SFont ComputerFont;
+ SFont PDAFont;
+ ~Fonts();
+
+ void loadFonts(WGame &game, WindowInfo &windowInfo);
+ void getTextDim(char *s, FontKind font, int *x, int *y);
+};
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_FONTS_H
+
diff --git a/engines/watchmaker/game.cpp b/engines/watchmaker/game.cpp
index 1b15455be1c..91d958fad62 100644
--- a/engines/watchmaker/game.cpp
+++ b/engines/watchmaker/game.cpp
@@ -206,7 +206,7 @@ WGame::WGame() : workDirs(WATCHMAKER_CFG_NAME) {
sdl = new sdl_wrapper();
- _renderer = new Renderer(&workDirs, sdl);
+ _renderer = new Renderer(this, sdl);
// Don't forget to register your random source
_rnd = new Common::RandomSource("Watchmaker");
@@ -554,19 +554,7 @@ void WGame::LoadMisc() {
rShowFrame();
*/
- if ((windowInfo.width >= 1024) || (windowInfo.height >= 768)) {
- LoadFont(&StandardFont, "1024NlFont.fnt");
- LoadFont(&ComputerFont, "1024ComputerFont.fnt");
- LoadFont(&PDAFont, "1024PDAFont.fnt");
- } else if ((windowInfo.width >= 800) || (windowInfo.height >= 600)) {
- LoadFont(&StandardFont, "800NlFont.fnt");
- LoadFont(&ComputerFont, "800ComputerFont.fnt");
- LoadFont(&PDAFont, "800PDAFont.fnt");
- } else if ((windowInfo.width >= 640) || (windowInfo.height >= 480)) {
- LoadFont(&StandardFont, "640NlFont.fnt");
- LoadFont(&ComputerFont, "640ComputerFont.fnt");
- LoadFont(&PDAFont, "640PDAFont.fnt");
- }
+ _fonts.loadFonts(*this, windowInfo);
Console1 = LoadDDBitmap(*this, "Console1.tga", rSURFACESTRETCH);
ConsoleFrecciaGiu = LoadDDBitmap(*this, "consoleFrecciaGiu.tga", rSURFACESTRETCH);
diff --git a/engines/watchmaker/game.h b/engines/watchmaker/game.h
index 1c8e45ccc0c..81d452d5884 100644
--- a/engines/watchmaker/game.h
+++ b/engines/watchmaker/game.h
@@ -23,6 +23,7 @@
#define WATCHMAKER_GAME_H
#include "common/random.h"
+#include "fonts.h"
#include "watchmaker/3d/loader.h"
#include "watchmaker/game_options.h"
#include "watchmaker/ll/ll_ffile.h"
@@ -61,6 +62,7 @@ public:
Init init;
sdl_wrapper *sdl;
GameVars _gameVars;
+ Fonts _fonts;
WGame();
~WGame();
diff --git a/engines/watchmaker/globvar.cpp b/engines/watchmaker/globvar.cpp
index 8db555d9349..d29c7fda521 100644
--- a/engines/watchmaker/globvar.cpp
+++ b/engines/watchmaker/globvar.cpp
@@ -57,9 +57,6 @@ int32 ConsoleD1, ConsoleD2, StartPic, EndPic, NewLogImage, LoadingImage;
int32 CurMousePointer, MousePointerDefault, MousePointerPlus, TrecLogo;
int32 GopherMap, GopherPos[MAX_GOPHERS], GopherBall;
struct SRect MousePointerLim;
-struct SFont StandardFont;
-struct SFont ComputerFont;
-struct SFont PDAFont;
// LOADER VARS
char LoaderName[T3D_NAMELEN] = "rxt.t3d";
diff --git a/engines/watchmaker/globvar.h b/engines/watchmaker/globvar.h
index b9c699b68ba..adf9bd3ffa6 100644
--- a/engines/watchmaker/globvar.h
+++ b/engines/watchmaker/globvar.h
@@ -119,9 +119,6 @@ extern int32 ConsoleD1, ConsoleD2, StartPic, EndPic, NewLogImage, LoadingImage;
extern int32 CurMousePointer, MousePointerDefault, MousePointerPlus, TrecLogo;
extern int32 GopherMap, GopherPos[], GopherBall;
extern struct SRect MousePointerLim;
-extern struct SFont StandardFont;
-extern struct SFont ComputerFont;
-extern struct SFont PDAFont;
// 3D INTERFACE
extern t3dF32 CurFloorY;
diff --git a/engines/watchmaker/ll/ll_string.cpp b/engines/watchmaker/ll/ll_string.cpp
index ee0b8d8ab1d..7de591bb174 100644
--- a/engines/watchmaker/ll/ll_string.cpp
+++ b/engines/watchmaker/ll/ll_string.cpp
@@ -67,7 +67,7 @@ void ClearText(void) {
/*-----------------17/02/95 09.53-------------------
TextLen - calcola lunghezza str dal car 0 a num
--------------------------------------------------*/
-uint16 TextLen(char *sign, uint16 num) {
+uint16 TextLen(Fonts &fonts, char *sign, uint16 num) {
uint16 Len, b, c;
b = 0;
@@ -80,15 +80,15 @@ uint16 TextLen(char *sign, uint16 num) {
Len = num;
for (c = 0; c < Len; c++)
- b += (StandardFont.Table[(uint16)((uint8)sign[c]) * 4 + 2]);
+ b += (fonts.StandardFont.table[(uint16)((uint8)sign[c]) * 4 + 2]);
return (b);
}
/*-----------------14/05/95 12.12-------------------
- CheckText - ritorna in quante righe scrivera'
+ CheckText - returns how many lines it will write
--------------------------------------------------*/
-uint16 CheckText(uint16 dx, char *sign) {
+uint16 CheckText(Fonts &fonts, uint16 dx, char *sign) {
uint16 a, b;
uint16 CurInit;
uint16 LastSpace;
@@ -104,7 +104,7 @@ uint16 CheckText(uint16 dx, char *sign) {
CurLine = 0;
// Caso piu' semplice: sta tutto su una riga
- if (TextLen(sign, 0) <= dx) {
+ if (TextLen(fonts, sign, 0) <= dx) {
strcpy((char *)TextLines[CurLine], sign);
return (1);
}
@@ -112,9 +112,9 @@ uint16 CheckText(uint16 dx, char *sign) {
while (a < strlen(sign)) {
a++;
if (sign[a] == ' ') {
- if (TextLen((char *)(sign + CurInit), (uint16)(a - CurInit)) <= dx)
+ if (TextLen(fonts, (char *)(sign + CurInit), (uint16)(a - CurInit)) <= dx)
LastSpace = a;
- else if (TextLen((char *)(sign + CurInit), (uint16)(LastSpace - CurInit)) <= dx) {
+ else if (TextLen(fonts, (char *)(sign + CurInit), (uint16)(LastSpace - CurInit)) <= dx) {
for (b = CurInit; b < LastSpace; b++)
TextLines[CurLine][b - CurInit] = sign[b];
@@ -125,7 +125,7 @@ uint16 CheckText(uint16 dx, char *sign) {
} else
return (0);
} else if (sign[a] == '\0') {
- if (TextLen((char *)(sign + CurInit), (uint16)(a - CurInit)) <= dx) {
+ if (TextLen(fonts, (char *)(sign + CurInit), (uint16)(a - CurInit)) <= dx) {
for (b = CurInit; b < a; b++)
TextLines[CurLine][b - CurInit] = sign[b];
TextLines[CurLine][b - CurInit] = '\0';
@@ -133,7 +133,7 @@ uint16 CheckText(uint16 dx, char *sign) {
CurLine++;
CurInit = a + 1;
return (CurLine);
- } else if (TextLen((char *)(sign + CurInit), (uint16)(LastSpace - CurInit)) <= dx) {
+ } else if (TextLen(fonts, (char *)(sign + CurInit), (uint16)(LastSpace - CurInit)) <= dx) {
for (b = CurInit; b < LastSpace; b++)
TextLines[CurLine][b - CurInit] = sign[b];
@@ -163,7 +163,7 @@ uint16 CheckText(uint16 dx, char *sign) {
void PaintText(WGame &game) {
uint16 lines, i;
int32 dx, obj;
- uint8 color;
+ FontColor color;
Init &init = game.init;
if (bTitoliCodaStatic || bTitoliCodaScrolling) return;
@@ -177,9 +177,9 @@ void PaintText(WGame &game) {
Character[obj]->Mesh->ExpressionFrame = VisemaTimeRecon(TheTime - LastTextTime);
}
- lines = (uint16)CheckText((uint16)game._renderer->rFitY((int32)TheString.dx), TheString.text);
+ lines = (uint16)CheckText(game._fonts, (uint16)game._renderer->rFitY((int32)TheString.dx), TheString.text);
for (i = 0; i < lines; i++) {
- dx = (TheString.dx - (TextLen(TextLines[i], 0) * SCREEN_RES_X) / game._renderer->rFitX(SCREEN_RES_X)) / 2;
+ dx = (TheString.dx - (TextLen(game._fonts, TextLines[i], 0) * SCREEN_RES_X) / game._renderer->rFitX(SCREEN_RES_X)) / 2;
obj = init.Anim[TimeAnim].obj;
color = WHITE_FONT;
if ((obj >= ocCUOCO) && (obj <= ocCURPLAYER)) {
@@ -226,7 +226,7 @@ void PaintText(WGame &game) {
break;
}
}
- DisplayDDText(*game._renderer, TextLines[i], &StandardFont, color, TheString.x + dx, TheString.y + i * 12, 0, 0, 0, 0);
+ DisplayDDText(*game._renderer, TextLines[i], FontKind::Standard, color, TheString.x + dx, TheString.y + i * 12, 0, 0, 0, 0);
}
}
}
@@ -293,9 +293,9 @@ void PaintInventory(WGame &game) {
for (a = 0; a < MAX_SHOWN_ICONS; a++) {
if (ci = Inv[CurPlayer][InvBase[CurPlayer] + a]) {
if (CurInvObj == ci)
- DisplayDDText(renderer, ObjName[init.InvObj[ci].name], &StandardFont, RED_FONT, INV_MARG_SX, INV_MARG_UP + ICON_DY * a, 0, 0, 0, 0);
+ DisplayDDText(renderer, ObjName[init.InvObj[ci].name], FontKind::Standard, RED_FONT, INV_MARG_SX, INV_MARG_UP + ICON_DY * a, 0, 0, 0, 0);
else
- DisplayDDText(renderer, ObjName[init.InvObj[ci].name], &StandardFont, WHITE_FONT, INV_MARG_SX, INV_MARG_UP + ICON_DY * a, 0, 0, 0, 0);
+ DisplayDDText(renderer, ObjName[init.InvObj[ci].name], FontKind::Standard, WHITE_FONT, INV_MARG_SX, INV_MARG_UP + ICON_DY * a, 0, 0, 0, 0);
}
}
}
diff --git a/engines/watchmaker/ll/ll_string.h b/engines/watchmaker/ll/ll_string.h
index e4fc2286f2f..acdad5641b6 100644
--- a/engines/watchmaker/ll/ll_string.h
+++ b/engines/watchmaker/ll/ll_string.h
@@ -31,7 +31,8 @@ class WGame;
void ClearText();
void Text(uint16 x, uint16 y, uint16 dx, char *text);
-uint16 TextLen(char *sign, uint16 num);
+class Fonts;
+uint16 TextLen(Fonts &fonts, char *sign, uint16 num);
void PaintInventory(WGame &game);
void PaintText(WGame &game);
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 0d3110233cc..09711cffc34 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -227,13 +227,14 @@ int16 getRoomFromStr(Init &init, const Common::String &s) {
/* -----------------19/01/99 11.03-------------------
* CreateTooltipBitmap
* --------------------------------------------------*/
-int32 CreateTooltipBitmap(Renderer &renderer, char *tooltip, struct SFont *f, uint8 color, uint8 r, uint8 g, uint8 b) {
+int32 CreateTooltipBitmap(Renderer &renderer, char *tooltip, FontColor color, uint8 r, uint8 g, uint8 b) {
int32 dimx, dimy, surf, enlarge = 5;
char info[100];
if (!tooltip || !strcmp(tooltip, "")) return -1;
+ FontKind font = FontKind::Standard;
- rGetTextDim(tooltip, f->Table, &dimx, &dimy);
+ renderer._fonts->getTextDim(tooltip, font, &dimx, &dimy);
dimx += renderer.rFitX(enlarge * 2);
dimy += renderer.rFitY(enlarge * 2);
@@ -245,40 +246,10 @@ int32 CreateTooltipBitmap(Renderer &renderer, char *tooltip, struct SFont *f, ui
rSetBitmapName(surf, info);
rClear(surf, 0, 0, dimx, dimy, 18, 18, 18); // Bordino nero
rClear(surf, 1, 1, dimx - 2, dimy - 2, r, g, b); // Sfondo colorato
- rPrintText(tooltip, surf, f->Color[color], f->Table, (uint16)renderer.rFitX(enlarge), (uint16)renderer.rFitY(enlarge));
+ renderer.printText(tooltip, surf, font, color, (uint16)renderer.rFitX(enlarge), (uint16)renderer.rFitY(enlarge));
return surf;
}
-/* -----------------27/10/98 15.33-------------------
- * LoadFont
- * --------------------------------------------------*/
-void LoadFont(struct SFont *f, const char *n) {
- warning("STUBBED: LoadFont(%s)", n);
-#if 0
- char name[100], a;
-
- memset(name, 0, 100);
- strcpy(name, WmMiscDir);
- strcat(name, n);
- if ((f->Table = rSetupFontTable(name)) == nullptr) {
- DebugLogFile("Failed to load Font. Quitting ...");
- CloseSys();
- }
-
- name[strlen(name) - 3] = '.';
- name[strlen(name) - 2] = 't';
- name[strlen(name) - 1] = 'g';
- name[strlen(name) - 0] = 'a';
- for (a = 0; a < MAX_FONT_COLORS; a++) {
- name[strlen(name) - 5] = a + '0';
- if ((f->Color[a] = rLoadBitmapImage(name, rBITMAPSURFACE | rSURFACEFLIP)) <= 0) {
- DebugLogFile("Failed to load Font2. Quitting ...");
- CloseSys();
- }
- }
-#endif
-}
-
/* -----------------27/10/98 15.31-------------------
* LoadDDBitmap
* --------------------------------------------------*/
@@ -754,7 +725,7 @@ void DisplayDDBitmap_NoFit(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, i
/* -----------------15/11/00 12.16-------------------
* RendDDText
* --------------------------------------------------*/
-int32 RendDDText(char *text, struct SFont *f, uint8 color) {
+int32 RendDDText(Renderer &renderer, char *text, FontKind font, FontColor color) {
struct SDDText *r;
int32 c, tdx, tdy;
char info[100];
@@ -763,22 +734,21 @@ int32 RendDDText(char *text, struct SFont *f, uint8 color) {
for (c = 0, r = &RendText[0]; c < MAX_REND_TEXTS; c++, r++) {
if (r->text[0]) continue;
-
// Prende dimesioni della scritta da renderizzare
- rGetTextDim(text, f->Table, &tdx, &tdy);
+ renderer._fonts->getTextDim(text, font, &tdx, &tdy);
// Crea una surface che la contenga
r->tnum = rCreateSurface(tdx, tdy, rBITMAPSURFACE);
rClear(r->tnum, 0, 0, tdx, tdy, 0, 0, 0);
// Renderizza la scritta nella surface
//DebugLogWindow("Creo testo %s | %d %d",text,tdx,tdy );
- rPrintText(text, r->tnum, f->Color[color], f->Table, 0, 0);
+ renderer.printText(text, r->tnum, font, color, 0, 0);
strcpy(info, "text: ");
strncat(info, text, 15);
//DebugLogWindow("Creato %s",info);
rSetBitmapName(r->tnum, info);
strcpy(r->text, text);
r->color = color;
- r->font = f;
+ r->font = font;
return r->tnum;
}
@@ -788,7 +758,7 @@ int32 RendDDText(char *text, struct SFont *f, uint8 color) {
/* -----------------24/04/98 10.33-------------------
* DisplayDDText
* --------------------------------------------------*/
-void DisplayDDText(Renderer &renderer, char *text, struct SFont *f, uint8 color, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
+void DisplayDDText(Renderer &renderer, char *text, FontKind font, FontColor color, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
struct SDDText *t, *r;
int32 a, c;
@@ -805,7 +775,7 @@ void DisplayDDText(Renderer &renderer, char *text, struct SFont *f, uint8 color,
strcpy(DDTextsList[a].text, text);
DDTextsList[a].tnum = -1;
- DDTextsList[a].font = f;
+ DDTextsList[a].font = font;
DDTextsList[a].color = color;
t = &DDTextsList[a];
@@ -825,7 +795,7 @@ void DisplayDDText(Renderer &renderer, char *text, struct SFont *f, uint8 color,
DisplayDDBitmap( r->tnum, px, py, ox, oy, dx, dy );*/
int32 tn;
- if ((tn = RendDDText(t->text, t->font, t->color)) > 0)
+ if ((tn = RendDDText(renderer, t->text, t->font, t->color)) > 0)
// Aggiunge il bitmap con la scritta pre-renderizzata da visualizzare
DisplayDDBitmap(renderer, tn, px, py, ox, oy, dx, dy);
}
@@ -860,7 +830,7 @@ void DebugVideo(Renderer &renderer, int32 px, int32 py, const char *format, ...)
vsprintf(str, format, args);
va_end(args);
- DisplayDDText(renderer, str, &StandardFont, WHITE_FONT, px, py, 0, 0, 0, 0);
+ DisplayDDText(renderer, str, FontKind::Standard, WHITE_FONT, px, py, 0, 0, 0, 0);
// rPrintText( str, 0, StandardFont.Color[WHITE_FONT], StandardFont.Table, px, py );
}
diff --git a/engines/watchmaker/ll/ll_util.h b/engines/watchmaker/ll/ll_util.h
index 950c7d709f6..855dafad750 100644
--- a/engines/watchmaker/ll/ll_util.h
+++ b/engines/watchmaker/ll/ll_util.h
@@ -31,7 +31,7 @@
namespace Watchmaker {
int32 LoadDDBitmap(WGame &game, const char *n, uint8 flags);
-void LoadFont(struct SFont *f, const char *n);
+void LoadFont(WGame &game, struct SFont *f, const char *n);
void UpdateRoomVisibility(Init &init);
t3dMESH *LinkMeshToStr(Init &init, const Common::String &str);
int16 getRoomFromStr(Init &init, const Common::String &s);
@@ -45,8 +45,8 @@ void UpdateRoomInfo(Init &init);
bool CheckRect(Renderer &renderer, struct SRect p, int32 cmx, int32 cmy);
void DisplayD3DTriangle(Renderer &, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r, uint8 g, uint8 b, uint8 al);
void DisplayD3DRect(Renderer &, int32 px, int32 py, int32 dx, int32 dy, uint8 r, uint8 g, uint8 b, uint8 al);
-void DisplayDDText(Renderer &, char *text, struct SFont *f, uint8 color, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
-int32 CreateTooltipBitmap(Renderer &renderer, char *tooltip, struct SFont *f, uint8 color, uint8 r, uint8 g, uint8 b);
+void DisplayDDText(Renderer &, char *text, FontKind font, FontColor color, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
+int32 CreateTooltipBitmap(Renderer &renderer, char *tooltip, FontColor color, uint8 r, uint8 g, uint8 b);
int32 WhatObj(WGame &game, int32 mx, int32 my, uint8 op);
void DebugVideo(Renderer &renderer, int32 px, int32 py, const char *format, ...);
diff --git a/engines/watchmaker/module.mk b/engines/watchmaker/module.mk
index 3375eadf8ec..b65ef08343a 100644
--- a/engines/watchmaker/module.mk
+++ b/engines/watchmaker/module.mk
@@ -66,6 +66,7 @@ MODULE_OBJS = \
console.o \
extraLS.o \
file_utils.o \
+ fonts.o \
game.o \
game_options.o \
globvar.o \
diff --git a/engines/watchmaker/render.h b/engines/watchmaker/render.h
index 36e72475012..03f503951ac 100644
--- a/engines/watchmaker/render.h
+++ b/engines/watchmaker/render.h
@@ -200,7 +200,6 @@ bool rSetRenderMode(int state);
bool rClearBuffers(char flags);
void rClear(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b);
void rGetScreenInfos(unsigned int *width, unsigned int *height, unsigned int *bpp);
-unsigned short *rSetupFontTable(char *s);
void rRelaseFontTable(unsigned short *ft);
void rRelaseAllFontTable();
void rGetBlitterViewport(unsigned int *left, unsigned int *top, unsigned int *right, unsigned int *bottom);
@@ -215,7 +214,6 @@ bool rGetStencilBitDepth();
void rBlitScreenBuffer();
void rPrintText(const char *s, unsigned int dst, unsigned int src, unsigned short *FontTable, unsigned short x, unsigned short y);
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy, int sposx, int sposy, int sdimx, int sdimy);
-void rGetTextDim(const char *s, unsigned short *FontTable, int *x, int *y);
//D3d specific geometry trasf. functions
bool rSetProjectionMatrix(float width, float height, float fAspect,
diff --git a/engines/watchmaker/renderer.cpp b/engines/watchmaker/renderer.cpp
index 381df58f44b..028faa34d65 100644
--- a/engines/watchmaker/renderer.cpp
+++ b/engines/watchmaker/renderer.cpp
@@ -26,16 +26,22 @@
#include "graphics/opengl/system_headers.h"
#include "common/system.h"
+#include "math/glmath.h"
+#include "watchmaker/fonts.h"
+#include "watchmaker/game.h"
#include "watchmaker/globvar.h"
#include "watchmaker/ll/ll_system.h"
-#include "math/glmath.h"
#include "watchmaker/rect.h"
-#include "watchmaker/renderer.h"
#include "watchmaker/render.h"
+#include "watchmaker/renderer.h"
#include "watchmaker/windows_hacks.h"
namespace Watchmaker {
+Renderer::Renderer(WGame *game, sdl_wrapper *wrapper) : sdl(wrapper), _game(game) {
+ _workDirs = &game->workDirs;
+}
+
// blitter info
Rect gBlitterViewport;
gTexture gScreenBuffer;
@@ -133,6 +139,37 @@ int Renderer::rInvFitY(int y) {
return (int)ceil(((float)(y)) * gInvAspectY);
}
+void gPrintText(WGame &game, const char *s, uint32 d, uint32 src, uint16 *FontTable, short x, short y) {
+ int16 i=0,nextx,nexty;
+ unsigned char c;
+
+ uint32 AddFlag=0,NumRetries=0;
+
+ nextx = nexty = 0;
+ while ( (c=s[i])!=0) {
+ i++;
+ int16 posx, posy, dimx, dimy;
+ posx = FontTable[c*4+0];
+ posy = FontTable[c*4+1];
+ dimx = FontTable[c*4+2];
+ dimy = FontTable[c*4+3];
+
+ rBlitter(game, d, src, x + nextx,y + nexty, posx, posy, dimx, dimy);
+
+ nextx += dimx;
+ }
+}
+
+void Renderer::printText(const char *s, unsigned int dst, FontKind font, FontColor color, uint16 x, uint16 y) {
+ auto f = _fonts->fontForKind(font);
+ uint32 src = f->color[color];
+
+ if (dst==0)
+ gPrintText(*_game, s, NULL, src, f->table, x, y);
+ else
+ gPrintText(*_game, s, dst, src, f->table, x, y);
+}
+
} // End of namespace Watchmaker
#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/renderer.h b/engines/watchmaker/renderer.h
index 11cb17551a8..4640b2d9861 100644
--- a/engines/watchmaker/renderer.h
+++ b/engines/watchmaker/renderer.h
@@ -40,11 +40,14 @@ struct WindowInfo {
unsigned int bpp;
};
+class Fonts;
class Renderer {
WorkDirs *_workDirs;
+ WGame *_game;
public:
+ Fonts *_fonts = nullptr;
Rect _viewport;
- Renderer(WorkDirs *workDirs, sdl_wrapper *wrapper) : sdl(wrapper), _workDirs(workDirs) {}
+ Renderer(WGame *game, sdl_wrapper *wrapper);
bool addMaterial(gMaterial &material, const Common::String &name, int NumFaces, unsigned int LoaderFlags);
void initGL();
@@ -60,6 +63,7 @@ public:
void setCurCameraViewport(t3dF32 fov, uint8 sup);
void renderBitmap(SDDBitmap &bitmap);
+ void printText(const char *s, unsigned int dst, FontKind font, FontColor color, uint16 x, uint16 y);
int rFitX(int x);
int rFitY(int y);
diff --git a/engines/watchmaker/struct.h b/engines/watchmaker/struct.h
index 2e67bd48572..2223c2da926 100644
--- a/engines/watchmaker/struct.h
+++ b/engines/watchmaker/struct.h
@@ -448,10 +448,6 @@ struct SRect {
SRect(int32 x1, int32 y1, int32 x2, int32 y2): x1(x1), y1(y1), x2(x2), y2(y2) {}
};
-struct SFont {
- uint16 *Table = nullptr;
- int32 Color[MAX_FONT_COLORS] = {};
-};
struct SD3DRect {
int32 px = 0, py = 0, dx = 0, dy = 0;
uint8 r = 0, g = 0, b = 0, a = 0;
@@ -469,10 +465,12 @@ struct SDDBitmap {
int32 tnum = 0;
int32 px = 0, py = 0, ox = 0, oy = 0, dx = 0, dy = 0;
};
+
+enum class FontKind;
struct SDDText {
char text[MAX_STRING_LEN] = {};
- struct SFont *font = nullptr;
- uint8 color = 0;
+ FontKind font; // TODO: Move elsewhere so we can initalize
+ FontColor color;
int32 tnum = 0;
};
@@ -556,7 +554,7 @@ struct SRoomInfo {
int32 tnum = 0; //bitmap
char *letter_ptr = nullptr; //puntatore alla lettera corrente
int16 t_next_letter = 0; //quando deve apparire la nuova lettera
- struct SFont *f = nullptr; //il font
+ FontKind f; //il font
};
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/sysdef.h b/engines/watchmaker/sysdef.h
index 7c34fce3c98..8185c413037 100644
--- a/engines/watchmaker/sysdef.h
+++ b/engines/watchmaker/sysdef.h
@@ -151,16 +151,18 @@ namespace Watchmaker {
#define CAMERA_FOV_1ST 74.0f
#define CAMERA_FOV_ICON 50.0f
// Colori predefiniti del font
-#define WHITE_FONT 0
-#define RED_FONT 1
-#define GREEN_FONT 2
-#define BLUE_FONT 3
-#define CYAN_FONT 4
-#define MAGENTA_FONT 5
-#define YELLOW_FONT 6
-#define GRAY_FONT 7
-#define BLACK_FONT 8
-#define MAX_FONT_COLORS 9
+enum FontColor {
+ WHITE_FONT = 0,
+ RED_FONT = 1,
+ GREEN_FONT = 2,
+ BLUE_FONT = 3,
+ CYAN_FONT = 4,
+ MAGENTA_FONT = 5,
+ YELLOW_FONT = 6,
+ GRAY_FONT = 7,
+ BLACK_FONT = 8,
+ MAX_FONT_COLORS = 9
+};
#define MAX_GOPHERS 3
diff --git a/engines/watchmaker/t2d/t2d.cpp b/engines/watchmaker/t2d/t2d.cpp
index 921012d2d76..b16a4fadb9b 100644
--- a/engines/watchmaker/t2d/t2d.cpp
+++ b/engines/watchmaker/t2d/t2d.cpp
@@ -729,12 +729,12 @@ void FormattaLogs(WGame &game) {
for (t = 0; t < MAX_PDA_INFO; t++) {
if (init.PDALog[PDALogSorted[i].PDALogInd].text[t] == 0) break;
- rGetTextDim(Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]], StandardFont.Table, &init.PDALog[PDALogSorted[i].PDALogInd].dx, &init.PDALog[PDALogSorted[i].PDALogInd].dy);
+ game._fonts.getTextDim(Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]], FontKind::Standard, &init.PDALog[PDALogSorted[i].PDALogInd].dx, &init.PDALog[PDALogSorted[i].PDALogInd].dy);
Dx = init.PDALog[PDALogSorted[i].PDALogInd].dx;
CurInit = 0;
while (Dx + PDALogSorted[i].IndentX > renderer.rFitX(T2D_PDA_LOG_TEXT_XF - T2D_PDA_LOG_TEXT_XI)) {
for (Dx = (signed)strlen((char *)(Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]])) - 1; Dx >= 0; Dx--) {
- if ((Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]][CurInit + Dx] == ' ') && (TextLen((char *)(Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]] + CurInit), (int16)Dx) + PDALogSorted[i].IndentX < renderer.rFitX(T2D_PDA_LOG_TEXT_XF - T2D_PDA_LOG_TEXT_XI))) {
+ if ((Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]][CurInit + Dx] == ' ') && (TextLen(game._fonts, (char *)(Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]] + CurInit), (int16)Dx) + PDALogSorted[i].IndentX < renderer.rFitX(T2D_PDA_LOG_TEXT_XF - T2D_PDA_LOG_TEXT_XI))) {
Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]][CurInit + Dx] = 0;
strcpy(init.PDALog[PDALogSorted[i].PDALogInd].formatted[j].c_str(), (char *)(Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]] + CurInit));
Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]][CurInit + Dx] = ' ';
@@ -744,7 +744,7 @@ void FormattaLogs(WGame &game) {
}
}
- rGetTextDim((char *)(Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]] + CurInit), StandardFont.Table, &Dx, &init.PDALog[PDALogSorted[i].PDALogInd].dy);
+ game._fonts.getTextDim((char *)(Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]] + CurInit), FontKind::Standard, &Dx, &init.PDALog[PDALogSorted[i].PDALogInd].dy);
}
strcpy(init.PDALog[PDALogSorted[i].PDALogInd].formatted[j].c_str(), (char *)(Sentence[init.PDALog[PDALogSorted[i].PDALogInd].text[t]] + CurInit));
@@ -2679,7 +2679,7 @@ void doT2DMouse(WGame &game) {
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_HELP_ON,
FALSE, nullptr, nullptr, nullptr);
//Setta e Apre finestra Help
- SetHelpWin(nullptr, 5, Sentence[init.Obj[oTONERHELP].text[0]],
+ SetHelpWin(game._fonts, nullptr, 5, Sentence[init.Obj[oTONERHELP].text[0]],
Sentence[init.Obj[oTONERHELP].text[1]], Sentence[init.Obj[oTONERHELP].text[2]],
Sentence[init.Obj[oTONERHELP].text[3]], Sentence[init.Obj[oTONERHELP].text[4]]);
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_HELP, 0, TRUE, nullptr, nullptr,
@@ -3344,28 +3344,28 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_COMPUTER_SCRITTE_1].py = 100;
w->bm[T2D_BM_COMPUTER_SCRITTE_1].tnum |= T2D_BM_OFF;
strcpy(w->text[T2D_TEXT_COMPUTER_SCRITTE_1].text, "");
- w->text[T2D_TEXT_COMPUTER_SCRITTE_1].font = &StandardFont;
+ w->text[T2D_TEXT_COMPUTER_SCRITTE_1].font = FontKind::Standard;
w->text[T2D_TEXT_COMPUTER_SCRITTE_1].color = WHITE_FONT;
w->bm[T2D_BM_COMPUTER_SCRITTE_2].tnum = (T2D_TEXT_COMPUTER_SCRITTE_2 << T2D_BM2TEXT_SHIFT);
w->bm[T2D_BM_COMPUTER_SCRITTE_2].px = 50;
w->bm[T2D_BM_COMPUTER_SCRITTE_2].py = 130;
w->bm[T2D_BM_COMPUTER_SCRITTE_2].tnum |= T2D_BM_OFF;
strcpy(w->text[T2D_TEXT_COMPUTER_SCRITTE_2].text, "");
- w->text[T2D_TEXT_COMPUTER_SCRITTE_2].font = &StandardFont;
+ w->text[T2D_TEXT_COMPUTER_SCRITTE_2].font = FontKind::Standard;
w->text[T2D_TEXT_COMPUTER_SCRITTE_2].color = WHITE_FONT;
w->bm[T2D_BM_COMPUTER_SCRITTE_3].tnum = (T2D_TEXT_COMPUTER_SCRITTE_3 << T2D_BM2TEXT_SHIFT);
w->bm[T2D_BM_COMPUTER_SCRITTE_3].px = 50;
w->bm[T2D_BM_COMPUTER_SCRITTE_3].py = 160;
w->bm[T2D_BM_COMPUTER_SCRITTE_3].tnum |= T2D_BM_OFF;
strcpy(w->text[T2D_TEXT_COMPUTER_SCRITTE_3].text, "");
- w->text[T2D_TEXT_COMPUTER_SCRITTE_3].font = &StandardFont;
+ w->text[T2D_TEXT_COMPUTER_SCRITTE_3].font = FontKind::Standard;
w->text[T2D_TEXT_COMPUTER_SCRITTE_3].color = WHITE_FONT;
w->bm[T2D_BM_COMPUTER_SCRITTE_4].tnum = (T2D_TEXT_COMPUTER_SCRITTE_4 << T2D_BM2TEXT_SHIFT);
w->bm[T2D_BM_COMPUTER_SCRITTE_4].px = 50;
w->bm[T2D_BM_COMPUTER_SCRITTE_4].py = 190;
w->bm[T2D_BM_COMPUTER_SCRITTE_4].tnum |= T2D_BM_OFF;
strcpy(w->text[T2D_TEXT_COMPUTER_SCRITTE_4].text, "");
- w->text[T2D_TEXT_COMPUTER_SCRITTE_4].font = &StandardFont;
+ w->text[T2D_TEXT_COMPUTER_SCRITTE_4].font = FontKind::Standard;
w->text[T2D_TEXT_COMPUTER_SCRITTE_4].color = WHITE_FONT;
//ExtraLS
@@ -3591,7 +3591,7 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_COMPUTER_DIALUP_NUMBER].px = 50;
w->bm[T2D_BM_COMPUTER_DIALUP_NUMBER].py = 76;
strcpy(w->text[T2D_TEXT_COMPUTER_DIALUP_NUMBER].text, "");
- w->text[T2D_TEXT_COMPUTER_DIALUP_NUMBER].font = &ComputerFont;
+ w->text[T2D_TEXT_COMPUTER_DIALUP_NUMBER].font = FontKind::Computer;
w->text[T2D_TEXT_COMPUTER_DIALUP_NUMBER].color = BLACK_FONT;
//Gestione variabili
@@ -3719,14 +3719,14 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_COMPUTER_SEARCH_NAME].px = 140;
w->bm[T2D_BM_COMPUTER_SEARCH_NAME].py = 154;
strcpy(w->text[T2D_TEXT_COMPUTER_SEARCH_NAME].text, "");
- w->text[T2D_TEXT_COMPUTER_SEARCH_NAME].font = &ComputerFont;
+ w->text[T2D_TEXT_COMPUTER_SEARCH_NAME].font = FontKind::Computer;
w->text[T2D_TEXT_COMPUTER_SEARCH_NAME].color = BLACK_FONT;
w->bm[T2D_BM_COMPUTER_SEARCH_SURNAME].tnum = (T2D_TEXT_COMPUTER_SEARCH_SURNAME << T2D_BM2TEXT_SHIFT);
w->bm[T2D_BM_COMPUTER_SEARCH_SURNAME].px = 420;
w->bm[T2D_BM_COMPUTER_SEARCH_SURNAME].py = 154;
strcpy(w->text[T2D_TEXT_COMPUTER_SEARCH_SURNAME].text, "");
- w->text[T2D_TEXT_COMPUTER_SEARCH_SURNAME].font = &ComputerFont;
+ w->text[T2D_TEXT_COMPUTER_SEARCH_SURNAME].font = FontKind::Computer;
w->text[T2D_TEXT_COMPUTER_SEARCH_SURNAME].color = BLACK_FONT;
w->bm[T2D_BM_COMPUTER_SEARCH_CASENAME].tnum = (T2D_TEXT_COMPUTER_SEARCH_CASENAME << T2D_BM2TEXT_SHIFT);
@@ -3734,7 +3734,7 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_COMPUTER_SEARCH_CASENAME].py = 154;
w->bm[T2D_BM_COMPUTER_SEARCH_CASENAME].tnum |= T2D_BM_OFF;
strcpy(w->text[T2D_TEXT_COMPUTER_SEARCH_CASENAME].text, "");
- w->text[T2D_TEXT_COMPUTER_SEARCH_CASENAME].font = &ComputerFont;
+ w->text[T2D_TEXT_COMPUTER_SEARCH_CASENAME].font = FontKind::Computer;
w->text[T2D_TEXT_COMPUTER_SEARCH_CASENAME].color = BLACK_FONT;
w->bm[T2D_BM_COMPUTER_SEARCH_YEAR].tnum = (T2D_TEXT_COMPUTER_SEARCH_YEAR << T2D_BM2TEXT_SHIFT);
@@ -3742,7 +3742,7 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_COMPUTER_SEARCH_YEAR].py = 154;
w->bm[T2D_BM_COMPUTER_SEARCH_YEAR].tnum |= T2D_BM_OFF;
strcpy(w->text[T2D_TEXT_COMPUTER_SEARCH_YEAR].text, "");
- w->text[T2D_TEXT_COMPUTER_SEARCH_YEAR].font = &ComputerFont;
+ w->text[T2D_TEXT_COMPUTER_SEARCH_YEAR].font = FontKind::Computer;
w->text[T2D_TEXT_COMPUTER_SEARCH_YEAR].color = BLACK_FONT;
//Gestione Variabili
@@ -3853,14 +3853,14 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_COMPUTER_EMAIL_TEXT_1].px = 150;
w->bm[T2D_BM_COMPUTER_EMAIL_TEXT_1].py = 125;
strcpy(w->text[T2D_TEXT_COMPUTER_EMAIL_1].text, Sentence[init.Obj[oCOMPUTEREMAIL1].text[0]]);
- w->text[T2D_TEXT_COMPUTER_EMAIL_1].font = &ComputerFont;
+ w->text[T2D_TEXT_COMPUTER_EMAIL_1].font = FontKind::Computer;
w->text[T2D_TEXT_COMPUTER_EMAIL_1].color = BLACK_FONT;
w->bm[T2D_BM_COMPUTER_EMAIL_TEXT_2].tnum = (T2D_TEXT_COMPUTER_EMAIL_2 << T2D_BM2TEXT_SHIFT);
w->bm[T2D_BM_COMPUTER_EMAIL_TEXT_2].px = 150;
w->bm[T2D_BM_COMPUTER_EMAIL_TEXT_2].py = 185;
strcpy(w->text[T2D_TEXT_COMPUTER_EMAIL_2].text, Sentence[init.Obj[oCOMPUTEREMAIL2].text[0]]);
- w->text[T2D_TEXT_COMPUTER_EMAIL_2].font = &ComputerFont;
+ w->text[T2D_TEXT_COMPUTER_EMAIL_2].font = FontKind::Computer;
w->text[T2D_TEXT_COMPUTER_EMAIL_2].color = BLACK_FONT;
//ExtraLS
@@ -4049,7 +4049,7 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_COMPUTER_DOCLIST_LINES_START + i].py = 65 + 20 * i;
strcpy(w->text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START + i].text, "");
- w->text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START + i].font = &PDAFont;
+ w->text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START + i].font = FontKind::PDA;
w->text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START + i].color = BLUE_FONT;
}
@@ -4410,7 +4410,7 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_PDA_MAIN_TIME].tnum |= ((T2D_TEXT_PDA_MAIN_TIME) << T2D_BM2TEXT_SHIFT);
w->bm[T2D_BM_PDA_MAIN_TIME].px = 690;
w->bm[T2D_BM_PDA_MAIN_TIME].py = 360;
- w->text[T2D_TEXT_PDA_MAIN_TIME].font = &PDAFont;
+ w->text[T2D_TEXT_PDA_MAIN_TIME].font = FontKind::PDA;
w->text[T2D_TEXT_PDA_MAIN_TIME].color = GREEN_FONT;
if (t3dCurTime >= 1300) {
sprintf(w->text[T2D_TEXT_PDA_MAIN_TIME].text, "%04d", t3dCurTime - 1200);
@@ -4490,7 +4490,7 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_PDA_LOG_DATA_START + i].px = T2D_PDA_LOG_DATA_XI;
w->bm[T2D_BM_PDA_LOG_DATA_START + i].py = 0;
strcpy(w->text[T2D_TEXT_PDA_LOG_DATA_START + i].text, "");
- w->text[T2D_TEXT_PDA_LOG_DATA_START + i].font = &PDAFont;
+ w->text[T2D_TEXT_PDA_LOG_DATA_START + i].font = FontKind::PDA;
w->text[T2D_TEXT_PDA_LOG_DATA_START + i].color = GRAY_FONT;
}
@@ -4500,7 +4500,7 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_PDA_LOG_TEXT_START + i].py = 0;
w->bm[T2D_BM_PDA_LOG_TEXT_START].tnum |= T2D_BM_OFF;
strcpy(w->text[T2D_TEXT_PDA_LOG_TEXT_START + i].text, "");
- w->text[T2D_TEXT_PDA_LOG_TEXT_START + i].font = &PDAFont;
+ w->text[T2D_TEXT_PDA_LOG_TEXT_START + i].font = FontKind::PDA;
}
//ExtraLS
@@ -4637,7 +4637,7 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_PDA_HELP_TEXT_START + i].py = T2D_PDA_HELP_TEXT_YI + 20 * i;
w->bm[T2D_BM_PDA_HELP_TEXT_START].tnum |= T2D_BM_OFF;
strcpy(w->text[T2D_TEXT_PDA_HELP_START + i].text, "");
- w->text[T2D_TEXT_PDA_HELP_START + i].font = &PDAFont;
+ w->text[T2D_TEXT_PDA_HELP_START + i].font = FontKind::PDA;
w->text[T2D_TEXT_PDA_HELP_START + i].color = GREEN_FONT;
}
@@ -4922,7 +4922,7 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_OPTIONS_TEXT_SAVE_START + j * 3 + i].py = w->bm[T2D_BM_OPTIONS_SAVE_START + j * 3 + i].py + 105;
w->bm[T2D_BM_OPTIONS_TEXT_SAVE_START + j * 3 + i].tnum |= T2D_BM_OFF;
strcpy(w->text[T2D_TEXT_OPTIONS_SAVE_START + j * 3 + i].text, "");
- w->text[T2D_TEXT_OPTIONS_SAVE_START + j * 3 + i].font = &StandardFont;
+ w->text[T2D_TEXT_OPTIONS_SAVE_START + j * 3 + i].font = FontKind::Standard;
w->text[T2D_TEXT_OPTIONS_SAVE_START + j * 3 + i].color = WHITE_FONT;
}
@@ -5356,7 +5356,7 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_PDA_TONE_PROCESS];
b->on = false;
- SetHelpWin(&PDA_Tone_Acquire_Help_Func, 2, Sentence[init.Obj[oTONERHELP].text[4]], " ");
+ SetHelpWin(game._fonts, &PDA_Tone_Acquire_Help_Func, 2, Sentence[init.Obj[oTONERHELP].text[4]], " ");
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, true, nullptr, nullptr, nullptr);
}
break;
@@ -5624,7 +5624,7 @@ void PDA_Tone_Acquire_Help_Func(void) {
// Event( EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_TONE, 0, FALSE, NULL, NULL, NULL );
}
-void SetHelpWin(void (*Func)(void), int NArg, ...) {
+void SetHelpWin(Fonts &fonts, void (*Func)(void), int NArg, ...) {
va_list vl;
char *Text = nullptr;
int i, Dx = 0, Dy = 0;
@@ -5637,7 +5637,7 @@ void SetHelpWin(void (*Func)(void), int NArg, ...) {
if (Text == nullptr) break;
- rGetTextDim(Text, StandardFont.Table, &Dx, &Dy);
+ fonts.getTextDim(Text, FontKind::Standard, &Dx, &Dy);
w->bm[T2D_BM_PDA_HELP_TEXT_START + i].px = T2D_PDA_HELP_TEXT_XI + (T2D_PDA_HELP_TEXT_XF - T2D_PDA_HELP_TEXT_XI - Dx) / 2;
w->bm[T2D_BM_PDA_HELP_TEXT_START + i].py = T2D_PDA_HELP_TEXT_YI + (Dy + 5) * i;
w->bm[T2D_BM_PDA_HELP_TEXT_START + i].tnum &= ~T2D_BM_OFF;
diff --git a/engines/watchmaker/t2d/t2d_internal.h b/engines/watchmaker/t2d/t2d_internal.h
index 25eba97548e..cc1de94faa5 100644
--- a/engines/watchmaker/t2d/t2d_internal.h
+++ b/engines/watchmaker/t2d/t2d_internal.h
@@ -532,7 +532,7 @@ struct SavesS {
void ChangeExclusiveMouseMode();
void PDA_Tone_Acquire_Help_Func();
-void SetHelpWin(void (*Func)(void), int NArg, ...);
+void SetHelpWin(Fonts &fonts, void (*Func)(void), int NArg, ...);
void CaricaSaves(WGame &game);
void SortSaves();
void RefreshSaveImg(WGame &game, int Pos, uint8 Type);
Commit: 6cbc4fff2d5961ebca7643279e7d5972431203f5
https://github.com/scummvm/scummvm/commit/6cbc4fff2d5961ebca7643279e7d5972431203f5
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix slash-handling in file loading.
Changed paths:
engines/watchmaker/ll/ll_ffile.cpp
engines/watchmaker/work_dirs.cpp
diff --git a/engines/watchmaker/ll/ll_ffile.cpp b/engines/watchmaker/ll/ll_ffile.cpp
index 810aa52b423..65b264654db 100644
--- a/engines/watchmaker/ll/ll_ffile.cpp
+++ b/engines/watchmaker/ll/ll_ffile.cpp
@@ -58,13 +58,14 @@ FastFile::FastFile(const char *path) : _path(path) {
}
Common::SharedPtr<Common::SeekableReadStream> FastFile::resolve(const char *filename) {
+ Common::String converted = filename;
int index = -1;
//HACK
- if (strlen(filename) >= 2 && filename[0] == '.' && filename[1] == '/') {
- filename = filename + 2;
+ if (converted.size() >= 2 && converted[0] == '.' && converted[1] == '/') {
+ converted = converted.substr(2, converted.size() - 2);
}
for (int i = 0; i < _numFiles; i++) {
- if (_files[i].name.equalsIgnoreCase(filename)) {
+ if (_files[i].name.equalsIgnoreCase(converted)) {
index = i;
break;
}
diff --git a/engines/watchmaker/work_dirs.cpp b/engines/watchmaker/work_dirs.cpp
index 6eb71931fcd..3d5807ead7e 100644
--- a/engines/watchmaker/work_dirs.cpp
+++ b/engines/watchmaker/work_dirs.cpp
@@ -27,16 +27,12 @@
namespace Watchmaker {
Common::SharedPtr<Common::SeekableReadStream> WorkDirs::resolveFile(const Common::String &path, bool noFastFile) {
- char *convertedFilename = new char[path.size() + 1]{};
- strcpy(convertedFilename, path.c_str());
+ Common::String converted = path;
for (int i = 0; i < path.size(); i++) {
- if (convertedFilename[i] == '\\') {
- convertedFilename[i] = '/';
+ if (converted[i] == '\\') {
+ converted.setChar('/', i);
}
}
- Common::String converted = convertedFilename;
- delete[] convertedFilename;
- //warning("Resolve: %s", path);
Common::SharedPtr<Common::SeekableReadStream> stream = nullptr;
if (!noFastFile) {
stream = _fastFile->resolve(converted.c_str());
Commit: babafef50222bf9229295bf8a8959add103f10ab
https://github.com/scummvm/scummvm/commit/babafef50222bf9229295bf8a8959add103f10ab
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Refactor/Implement viewport matrix handling.
Changed paths:
engines/watchmaker/3d/geometry.cpp
engines/watchmaker/3d/geometry.h
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/types3d.h
engines/watchmaker/main.cpp
engines/watchmaker/render.cpp
engines/watchmaker/render.h
engines/watchmaker/renderer.cpp
engines/watchmaker/renderer.h
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index be5e447e5de..27dfbb0aabd 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -64,12 +64,6 @@ t3dBODY *t3dSky = nullptr;
uint32 t3d_NumMeshesVisible;
t3dMESH *t3d_VisibleMeshes[255];
-#define LEFTCLIP 0
-#define RIGHTCLIP 1
-#define TOPCLIP 2
-#define BOTTOMCLIP 3
-#define NUMCLIPPLANES 4
-
t3dNORMAL ClipPlanes[NUMCLIPPLANES];
t3dMESH *t3dPortalList[MAX_RECURSION_LEVEL];
@@ -483,59 +477,6 @@ uint16 t3dBackfaceCulling(NormalList &normals, uint32 NumNormals, t3dV3F *eye)
return NumVisiNorm;
}
-/* -----------------10/06/99 15.50-------------------
- * t3dCalc2dTo3dPos
- * --------------------------------------------------*/
-void t3dCalc2dTo3dPos(t3dV3F *pos, t3dF32 posx, t3dF32 posy) {
- rScreenSpaceToCameraSpace(&pos->x, &pos->y, &pos->z, posx, posy);
-}
-
-/* -----------------10/06/99 15.41-------------------
- * t3dSetViewport
- * --------------------------------------------------*/
-void t3dSetViewport(t3dCAMERA *cam, uint32 cx, uint32 cy, uint32 sx, uint32 sy, t3dF32 fov, uint8 sup) {
- t3dV3F v1, v2, v3, v4, c0;
- t3dF32 SuperView = 50.0f * (sup ^ 1);
- t3dF32 fx = (t3dF32)sx, fy = (t3dF32)sy, asp;
- asp = (fy * fy) / (fx * fx);
-
-// fov=((fov/2.0f)/180.0f)*T3D_PI;
-
-// cam->Focus=90;
-// cam->Factor.x = ((fx/2.0f) / (t3dF32)tan(fov));
-// cam->Factor.y = -( cam->Factor.x * asp);
-
-
- cam->Center.x = (t3dF32)(cx);
- cam->Center.y = (t3dF32)(cy);
-
-
-
- cam->NearClipPlane = fov;
- cam->FarClipPlane = 89000.0f;
- rSetProjectionMatrix((float)(sx),
- (float)(sy),
- fov,
- 10.0f + SuperView, 90000.0f);
-
- //Set Clipplanes
- t3dVectFill(&c0, 0.0f);
- t3dCalc2dTo3dPos(&v1, 0.0f, 0.0f);
- t3dCalc2dTo3dPos(&v2, (t3dF32)sx, 0.0f);
- t3dCalc2dTo3dPos(&v3, 0.0f, (t3dF32)sy);
- t3dCalc2dTo3dPos(&v4, (t3dF32)sx, (t3dF32)sy);
-
- t3dPlaneNormal(&ClipPlanes[LEFTCLIP], &c0, &v1, &v3);
- t3dPlaneNormal(&ClipPlanes[RIGHTCLIP], &c0, &v4, &v2);
- t3dPlaneNormal(&ClipPlanes[TOPCLIP], &c0, &v2, &v1);
- t3dPlaneNormal(&ClipPlanes[BOTTOMCLIP], &c0, &v3, &v4);
-
-}
-
-void t3dSetViewport(t3dCAMERA *cam, WindowInfo &info, t3dF32 fov, uint8 sup) {
- t3dSetViewport(t3dCurCamera, info.width / 2, info.height / 2, info.width, info.height, fov, sup);
-}
-
/* -----------------10/06/99 15.55-------------------
* ssqrt
* --------------------------------------------------*/
diff --git a/engines/watchmaker/3d/geometry.h b/engines/watchmaker/3d/geometry.h
index e984d24f3a7..f75a36c5647 100644
--- a/engines/watchmaker/3d/geometry.h
+++ b/engines/watchmaker/3d/geometry.h
@@ -30,6 +30,14 @@
namespace Watchmaker {
+#define LEFTCLIP 0
+#define RIGHTCLIP 1
+#define TOPCLIP 2
+#define BOTTOMCLIP 3
+#define NUMCLIPPLANES 4
+
+extern t3dNORMAL ClipPlanes[NUMCLIPPLANES];
+
extern t3dBODY *t3dCurRoom, *t3dOrigRoom;
extern t3dCAMERA *t3dCurCamera;
extern t3dM3X3F t3dCurViewMatrix;
@@ -58,7 +66,6 @@ void t3dCalcRejectedMeshFromPortal(t3dBODY *body);
void t3dSetViewport(t3dCAMERA *cam, WindowInfo &info, t3dF32 fov, uint8 sup);
t3dF32 t3dCheckWithFloor();
void t3dCreateProceduralSky();
-void t3dCalc2dTo3dPos(t3dV3F *pos, t3dF32 posx, t3dF32 posy);
void t3dCalcMeshBones(t3dMESH *mesh, int32 last);
void t3dResetPipeline();
void t3dRotateMoveCamera(t3dCAMERA *cam, t3dF32 AngleX, t3dF32 AngleY, t3dF32 AngleSpeed);
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 5d329a87f98..e3751b73567 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -116,11 +116,51 @@ void rResetExtends(void) {
gBlitterExtends.bottom = -99999999;
}
+// TODO: Move this to Renderer
+extern Rect gBlitterViewport;
+bool gClipToBlitterViewport(int *sposx, int *sposy, int *sdimx, int *sdimy,
+ int *dposx, int *dposy )
+{
+ int dwWidth, dwHeight;
+
+ dwWidth=(gBlitterViewport.right-gBlitterViewport.left);
+ dwHeight=(gBlitterViewport.bottom-gBlitterViewport.top);
+
+ if ( ((*dposx)+(*sdimx))>dwWidth)
+ {
+ (*sdimx)=(*sdimx)-((*dposx)+(*sdimx)-dwWidth);
+ }
+ if ( ((*dposy)+(*sdimy))>dwHeight)
+ {
+ (*sdimy)=(*sdimy)-((*dposy)+(*sdimy)-dwHeight);
+ }
+
+ if ( (*dposx)<gBlitterViewport.left)
+ {
+ (*sposx)+=gBlitterViewport.left-(*dposx);
+ (*sdimx)-=gBlitterViewport.left-(*dposx);
+ (*dposx)=gBlitterViewport.left;
+ }
+ if ( (*dposy)<gBlitterViewport.top)
+ {
+ (*sposy)+=gBlitterViewport.top-(*dposy);
+ (*sdimy)-=gBlitterViewport.top-(*dposy);
+ (*dposy)=gBlitterViewport.top;
+ }
+
+ if(((*sdimx)<=0) || ((*sdimy)<=0))
+ {
+ return false;
+ }
+
+ return true;
+}
+
//************************************************************************************************************************
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
int sposx, int sposy, int sdimx, int sdimy) {
// TODO: This currently gets called a bit too much.
- //warning("TODO: Stubbed rBlitter(%s, %d, %d, %d, %d, %d, %d, %d, %d)", gBitmapList[src].Name, dst, src, dposx, dposy, sposx, sposy, sdimx, sdimy);
+ warning("TODO: Stubbed rBlitter(%s, %d, %d, %d, %d, %d, %d, %d, %d)", gBitmapList[src].name.c_str(), dst, src, dposx, dposy, sposx, sposy, sdimx, sdimy);
auto &bitmap = gBitmapList[src];
checkGlError("rBlitter Start");
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index c2ab7a21079..775495f54b5 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -36,6 +36,7 @@
#ifdef USE_OPENGL_GAME
#include "graphics/opengl/system_headers.h"
+#include "watchmaker/3d/render/shadows.h"
#include "watchmaker/file_utils.h"
#include "watchmaker/tga_util.h"
@@ -302,6 +303,15 @@ int rAddUserViewMatrix(const t3dM3X3F &viewMatrix, const t3dV3F &translation) {
translation.x, translation.y, translation.z);
}
+void rResetPipeline() {
+ gNumLinesArray = 0;
+ gNumPointsBuffer = 0;
+ gNumShadowBoxesList = 0;
+ rNumUserViewMatrices = 0;
+ g_dwD3DUserVertexBufferCounter = 0;
+ return;
+}
+
//*********************************************************************************************
void *rGetUserVertexBuffer() {
return g_lpD3DUserVertexBuffer;
diff --git a/engines/watchmaker/3d/types3d.h b/engines/watchmaker/3d/types3d.h
index 3af9be07e07..cdfa3c5407c 100644
--- a/engines/watchmaker/3d/types3d.h
+++ b/engines/watchmaker/3d/types3d.h
@@ -23,6 +23,7 @@
#define WATCHMAKER_TYPES3D_H
#include "common/stream.h"
+#include "math/vector3d.h"
#include "watchmaker/types.h"
namespace Watchmaker {
@@ -39,6 +40,11 @@ struct t3dV3F {
public:
t3dV3F() {}
t3dV3F(float x, float y, float z) : x(x), y(y), z(z) {}
+ t3dV3F(const Math::Vector3d &vector) {
+ x = vector.x();
+ y = vector.y();
+ z = vector.z();
+ }
t3dV3F(Common::SeekableReadStream &stream) {
x = stream.readFloatLE(); // Legge Pos
y = stream.readFloatLE();
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index 3aeb42ae92f..4310a2aa645 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -164,7 +164,7 @@ void Render3DEnvironment(WGame &game) {
// Update mouse coordinates and project them in 3D
HandleMouseChanges();
- t3dCalc2dTo3dPos(&t3d3dMousePos, (t3dF32)mPosx, (t3dF32)mPosy);
+ t3d3dMousePos = t3dV3F(game._renderer->screenSpaceToCameraSpace((t3dF32)mPosx, (t3dF32)mPosy));
if (bT2DActive /*&& ( bT2DActive != tOPTIONS )*/) {
} else if (((InvStatus & INV_MODE2) && (InvStatus & INV_ON)) /*|| ( bT2DActive == tOPTIONS )*/) { // Se sono nell'inventario
t3dCAMERA *tmp = t3dCurCamera; // Salvo camera attuale in tmp
@@ -173,7 +173,7 @@ void Render3DEnvironment(WGame &game) {
t3dCurCamera->Fov = CAMERA_FOV_ICON;
game._renderer->setCurCameraViewport(t3dCurCamera->Fov, bSuperView);
auto windowInfo = game._renderer->getScreenInfos();
- rSetProjectionMatrix((float)(windowInfo.width), (float)(windowInfo.height), t3dCurCamera->Fov, 5000.0f, 15000.0f);
+ game._renderer->setProjectionMatrix((float)(windowInfo.width), (float)(windowInfo.height), t3dCurCamera->Fov, 5000.0f, 15000.0f);
t3dVectInit(&t3dCurCamera->Source, 1000.0f, 0.0f, 10000.0f);
t3dVectInit(&t3dCurCamera->Target, 1000.0f, 0.0f, 0.0f);
t3dMatView(&t3dCurViewMatrix, &t3dCurCamera->Source, &t3dCurCamera->Target); // Creo matrice
diff --git a/engines/watchmaker/render.cpp b/engines/watchmaker/render.cpp
index f3d5bad2ac9..54c9ed494fd 100644
--- a/engines/watchmaker/render.cpp
+++ b/engines/watchmaker/render.cpp
@@ -143,41 +143,6 @@ void rGetScreenInfos(unsigned int *width, unsigned int *height, unsigned int *bp
*bpp = 32;
}
-//D3d specific geometry trasf. functions
-bool rSetProjectionMatrix(float width, float height, float fAspect,
- float fNearPlane, float fFarPlane) {
- // Not sure if fAspect is Y here though
- glMatrixMode(GL_PROJECTION);
- auto perspectiveMatrix = Math::makePerspectiveMatrix(fAspect, width / height, fNearPlane, fFarPlane);
- glLoadMatrixf(perspectiveMatrix.getData());
-
- glMatrixMode(GL_MODELVIEW);
- return false;
-}
-
-
-void rScreenSpaceToCameraSpace(float *dx, float *dy, float *dz, float x, float y) {
- //warning("STUBBED: rScreenSpaceToCameraSpace");
-#if 0
- D3DMATRIX m;
- D3DVECTOR v, d;
- unsigned int width, height, bpp;
-
- rGetScreenInfos(&width, &height, &bpp);
-
- D3DMath_MatrixInvert(m, rProjectionMatrix);
-
- v.x = (x - width / 2) / (width / 2);
- v.y = -(y - height / 2) / (height / 2);
- v.z = 1.0f;
- D3DMath_VectorMatrixMultiply(d, v, m);
-
- *dx = d.x;
- *dy = d.y;
- *dz = d.z - gNearPlane;
-#endif
-}
-
gTexture *gLoadTexture(char *TextName, unsigned int LoaderFlags) {
warning("STUBBED gLoadTexture");
return nullptr;
@@ -224,12 +189,6 @@ void rGetTextDim(const char *s, unsigned short *FontTable, int *x, int *y) {
return;
}
-
-void rResetPipeline() {
- //warning("STUBBED: rResetPipeline");
- return;
-}
-
void rClear(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b) {
//warning("STUBBED: rClear(%d, %d, %d, %d, %d", dst, dposx, dposy, sdimx, sdimy);
}
diff --git a/engines/watchmaker/render.h b/engines/watchmaker/render.h
index 03f503951ac..29ed9f1c94b 100644
--- a/engines/watchmaker/render.h
+++ b/engines/watchmaker/render.h
@@ -216,8 +216,6 @@ void rPrintText(const char *s, unsigned int dst, unsigned in
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy, int sposx, int sposy, int sdimx, int sdimy);
//D3d specific geometry trasf. functions
-bool rSetProjectionMatrix(float width, float height, float fAspect,
- float fNearPlane, float fFarPlane);
struct t3dM3X3F;
struct t3dV3F;
void rSetViewMatrix(const t3dM3X3F &viewMatrix, const t3dV3F &translation);
@@ -230,7 +228,6 @@ void rSetLinesViewMatrix();
bool checkGlError(const char *when = "");
-void rScreenSpaceToCameraSpace(float *dx, float *dy, float *dz, float x, float y);
} // End of namespace Watchmaker
#endif // WATCHMAKER_RENDER_H
diff --git a/engines/watchmaker/renderer.cpp b/engines/watchmaker/renderer.cpp
index 028faa34d65..e19e45445a1 100644
--- a/engines/watchmaker/renderer.cpp
+++ b/engines/watchmaker/renderer.cpp
@@ -27,6 +27,8 @@
#include "common/system.h"
#include "math/glmath.h"
+#include "watchmaker/3d/geometry.h"
+#include "watchmaker/3d/math/llmath.h"
#include "watchmaker/fonts.h"
#include "watchmaker/game.h"
#include "watchmaker/globvar.h"
@@ -119,7 +121,41 @@ bool Renderer::initBlitterViewPort() {
}
void Renderer::setCurCameraViewport(t3dF32 fov, uint8 sup) {
-
+ auto windowInfo = getScreenInfos();
+ int32 cx = windowInfo.width / 2;
+ int32 cy = windowInfo.height / 2;
+ int32 sx = windowInfo.width;
+ int32 sy = windowInfo.height;
+
+ t3dF32 SuperView = 50.0f * (sup^1);
+
+ t3dCurCamera->Center.x = (t3dF32)(cx);
+ t3dCurCamera->Center.y = (t3dF32)(cy);
+
+ t3dCurCamera->NearClipPlane = fov;
+ t3dCurCamera->FarClipPlane = 89000.0f;
+
+ warning("TODO: Set projection matrix");
+
+ setProjectionMatrix( (float)(sx),
+ (float)(sy),
+ fov,
+ 10.0f + SuperView, 90000.0f);
+
+ //Set Clipplanes
+ t3dV3F c0;
+ t3dVectFill(&c0,0.0f);
+ t3dV3F v1(screenSpaceToCameraSpace(0.0f, 0.0f));
+ t3dV3F v2(screenSpaceToCameraSpace((t3dF32)sx, 0.0f));
+ t3dV3F v3(screenSpaceToCameraSpace(0.0f, (t3dF32)sy));
+ t3dV3F v4(screenSpaceToCameraSpace((t3dF32)sx, (t3dF32)sy));
+
+#if 0
+ t3dPlaneNormal(&ClipPlanes[LEFTCLIP], &c0, &v1, &v3);
+ t3dPlaneNormal(&ClipPlanes[RIGHTCLIP], &c0, &v4, &v2);
+ t3dPlaneNormal(&ClipPlanes[TOPCLIP], &c0, &v2, &v1);
+ t3dPlaneNormal(&ClipPlanes[BOTTOMCLIP], &c0, &v3, &v4);
+#endif
}
void Renderer::showFrame() {
@@ -170,6 +206,46 @@ void Renderer::printText(const char *s, unsigned int dst, FontKind font, FontCol
gPrintText(*_game, s, dst, src, f->table, x, y);
}
+bool Renderer::setProjectionMatrix(float width, float height, float fAspect, float fNearPlane, float fFarPlane) {
+ // Not sure if fAspect is Y here though
+ glMatrixMode(GL_PROJECTION);
+ _nearPlane = fNearPlane;
+ _projectionMatrix = Math::makePerspectiveMatrix(fAspect, width / height, fNearPlane, fFarPlane);
+ glLoadMatrixf(_projectionMatrix.getData());
+
+ glMatrixMode(GL_MODELVIEW);
+ return false;
+}
+
+Math::Vector3d vector3Matrix4Mult(Math::Vector3d &vec, const Math::Matrix4 &m) {
+ // Since the query functions return a 4x4 Matrix, but we only really care
+ // about the 3D vector, we make our own version of the Vector-Matrix mult.
+ // In practice we could perhaps introduce an operator* in Vector4d, but
+ // since the w component is un-interesting that would be 4 unneccesary mults.
+ const float *d = m.getData();
+ return Math::Vector3d(vec.x() * d[0] + vec.y() * d[3] + vec.z() * d[6],
+ vec.x() * d[1] + vec.y() * d[4] + vec.z() * d[7],
+ vec.x() * d[2] + vec.y() * d[5] + vec.z() * d[8]);
+}
+
+Math::Vector3d Renderer::screenSpaceToCameraSpace(float x, float y) {
+ unsigned int width, height, bpp;
+
+ rGetScreenInfos(&width, &height, &bpp);
+
+ auto matrix = _projectionMatrix;
+ matrix.inverse();
+
+ Math::Vector3d v;
+ v.x() = (x - width / 2) / (width / 2);
+ v.y() = -(y - height / 2) / (height / 2);
+ v.z() = 1.0f;
+ Math::Vector3d d = vector3Matrix4Mult(v, matrix);
+
+ return Math::Vector3d(d.x(), d.y(), d.z() - _nearPlane);
+}
+
+
} // End of namespace Watchmaker
#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/renderer.h b/engines/watchmaker/renderer.h
index 4640b2d9861..ca1ab8820ca 100644
--- a/engines/watchmaker/renderer.h
+++ b/engines/watchmaker/renderer.h
@@ -22,6 +22,7 @@
#ifndef WATCHMAKER_RENDERER_H
#define WATCHMAKER_RENDERER_H
+#include "math/matrix4.h"
#include "watchmaker/utils.h"
#include "watchmaker/sdl_wrapper.h"
#include "watchmaker/types.h"
@@ -69,11 +70,16 @@ public:
int rFitY(int y);
int rInvFitX(int x);
int rInvFitY(int y);
+
+ bool setProjectionMatrix(float width, float height, float fAspect, float fNearPlane, float fFarPlane);
+ Math::Vector3d screenSpaceToCameraSpace(float x, float y);
private:
sdl_wrapper *sdl;
// aspect correction
float gAspectX = 1, gAspectY = 1;
float gInvAspectX = 1, gInvAspectY = 1;
+ float _nearPlane;
+ Math::Matrix4 _projectionMatrix;
};
Commit: 4457ede6f99119229ac56fbfec1b6daa611084d7
https://github.com/scummvm/scummvm/commit/4457ede6f99119229ac56fbfec1b6daa611084d7
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Implement "blitting" by keeping track of blits to the back buffer
Changed paths:
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/texture.h
engines/watchmaker/ll/ll_regen.cpp
engines/watchmaker/render.cpp
engines/watchmaker/render.h
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index e3751b73567..8f79d2a79a9 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -156,6 +156,92 @@ bool gClipToBlitterViewport(int *sposx, int *sposy, int *sdimx, int *sdimy,
return true;
}
+void enter2Dmode(WGame &game) {
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ checkGlError("Exiting enter2Dmode");
+}
+
+void exit2Dmode() {
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ checkGlError("exit2Dmode");
+}
+
+void renderTexture(WGame &game, gTexture &bitmap, Rect srcRect, Rect dstRect) {
+ checkGlError("Entering renderTexture");
+ glClearColor(0,0,1,0);
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_ALPHA_TEST);
+ glDisable(GL_DEPTH_TEST);
+ glDepthFunc(GL_ALWAYS);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ bitmap.texture->bind();
+ glLoadIdentity();
+ glTranslatef(0, 0, 0.0);
+
+ float bottomSrc = ((float)srcRect.bottom) / bitmap.RealDimY;
+ float topSrc = ((float)srcRect.top) / bitmap.RealDimY;
+ float leftSrc = ((float)srcRect.left) / bitmap.RealDimX;
+ float rightSrc = ((float)srcRect.right) / bitmap.RealDimX;
+
+ Rect viewport = game._renderer->_viewport;
+ float bottomDst = 1.0 - ((dstRect.bottom == 0 ? 0 : ((double)dstRect.bottom) / viewport.height()) * 2.0);
+ float topDst = 1.0 - ((dstRect.top == 0 ? 0 : ((double)dstRect.top) / viewport.height()) * 2.0);
+ float leftDst = ((dstRect.left == 0 ? 0 : ((double)dstRect.left) / viewport.width()) * 2.0) - 1.0;
+ float rightDst = ((dstRect.right == 0 ? 0 : ((double)dstRect.right) / viewport.width()) * 2.0) - 1.0;
+
+ glBegin(GL_QUADS);
+ glColor3f(1.0, 1.0, 1.0);
+
+ glTexCoord2f(leftSrc, bottomSrc); // Bottom Left
+ glVertex3f(leftDst, bottomDst, 0.0f);
+
+ glTexCoord2f(rightSrc, bottomSrc); // Bottom Right
+ glVertex3f(rightDst, bottomDst, 0.0f);
+
+ glTexCoord2f(rightSrc, topSrc); // Top Right
+ glVertex3f(rightDst, topDst, 0.0f);
+
+ glTexCoord2f(leftSrc, topSrc); // Top Left
+ glVertex3f(leftDst, topDst, 0.0f);
+
+ glEnd();
+ glFlush();
+ checkGlError("Exiting renderTexture");
+}
+
+void gTexture::render(WGame &game, Rect src, Rect dst) {
+ // Render self
+ if (texture) {
+ renderTexture(game, *this, src, dst);
+ }
+ for (int i = 0; i < _blitsOnTop.size(); i++) {
+ _blitsOnTop[i].texture->render(game, _blitsOnTop[i].src, _blitsOnTop[i].dst);
+ }
+}
+
+void rBlitScreenBuffer(WGame &game) { // Should probably go to opengl_2d
+ checkGlError("Entering rBlitScreenBuffer");
+ enter2Dmode(game);
+ gBitmapList[BACK_BUFFER].render(game, game._renderer->_viewport, game._renderer->_viewport);
+ exit2Dmode();
+ checkGlError("Exiting rBlitScreenBuffer");
+}
+
+void rClear(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b) {
+ warning("STUBBED: rClear(%d, %d, %d, %d, %d", dst, dposx, dposy, sdimx, sdimy);
+ gBitmapList[dst].clear();
+}
+
//************************************************************************************************************************
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
int sposx, int sposy, int sdimx, int sdimy) {
@@ -163,6 +249,9 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
warning("TODO: Stubbed rBlitter(%s, %d, %d, %d, %d, %d, %d, %d, %d)", gBitmapList[src].name.c_str(), dst, src, dposx, dposy, sposx, sposy, sdimx, sdimy);
auto &bitmap = gBitmapList[src];
+ assert(dst == 0);
+ auto &dstBitmap = gBitmapList[dst];
+
checkGlError("rBlitter Start");
glEnable(GL_TEXTURE_2D);
@@ -179,38 +268,19 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
}
if ((dposx >= dwWidth) || (dposy >= dwHeight) || (sposx >= dwWidth) || (sposy >= dwHeight) ||
- ((dposx + sdimx) <= 0) || ((dposy + sdimy) <= 0) || ((sposx + sdimx) <= 0) || ((sposy + sdimy) <= 0))
+ ((dposx + sdimx) <= 0) || ((dposy + sdimy) <= 0) || ((sposx + sdimx) <= 0) || ((sposy + sdimy) <= 0)) {
return;
+ }
if (dst == 0) {
-#if 0
if (!gClipToBlitterViewport(&sposx, &sposy, &sdimx, &sdimy, &dposx, &dposy)) {
-// DebugLogFile("gClipToBlitterViewport report an error");
+ error("gClipToBlitterViewport report an error");
return;
}
- d = gScreenBuffer.lpDDSurface;
-#endif
+
rUpdateExtends(dposx, dposy, dposx + sdimx, dposy + sdimy);
-#if 0
- /* //Update extends
- if (dposx<gBlitterExtends.left)
- gBlitterExtends.left=dposx;
- if (dposy<gBlitterExtends.top)
- gBlitterExtends.top=dposy;
- if ((dposx+sdimx)>gBlitterExtends.right)
- gBlitterExtends.right=dposx+sdimx;
- if ((dposy+sdimy)>gBlitterExtends.bottom)
- gBlitterExtends.bottom=dposy+sdimy;*/
- } else
- d = gBitmapList[dst].lpDDSurface;
-
- if (src == 0) {
- DebugLogFile("rBlitter error: src is an invalid surface");
- return;
- } else
- s = gBitmapList[src].lpDDSurface;
-#endif
}
+
if ((sdimx == 0) && (sdimy == 0)) {
sdimx = gBitmapList[src].DimX;
sdimy = gBitmapList[src].DimY;
@@ -237,47 +307,7 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
// DebugLogWindow("gBlitter: blit not needed: dimx:%d dimy:%d", ( sr.top-sr.bottom ),( sr.left-sr.right ));
return;
}
- glClearColor(0,0,1,0);
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_ALPHA_TEST);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- bitmap.texture->bind();
- glLoadIdentity();
- glTranslatef(0, 0, -1.0);
- //glTranslatef((2.0 / dposx) - 1.0, (2.0 / dposy) - 1.0, 0.0f);
-
- //glClear(GL_COLOR_BUFFER_BIT);
-
-
- float bottomSrc = ((float)srcRect.bottom) / bitmap.RealDimY;
- float topSrc = ((float)srcRect.top) / bitmap.RealDimY;
- float leftSrc = ((float)srcRect.left) / bitmap.RealDimX;
- float rightSrc = ((float)srcRect.right) / bitmap.RealDimX;
-
- Rect viewport = game._renderer->_viewport;
- float bottomDst = 1.0 - ((dstRect.bottom == 0 ? 0 : ((double)dstRect.bottom) / viewport.height()) * 2.0);
- float topDst = 1.0 - ((dstRect.top == 0 ? 0 : ((double)dstRect.top) / viewport.height()) * 2.0);
- float leftDst = ((dstRect.left == 0 ? 0 : ((double)dstRect.left) / viewport.width()) * 2.0) - 1.0;
- float rightDst = ((dstRect.right == 0 ? 0 : ((double)dstRect.right) / viewport.width()) * 2.0) - 1.0;
-
- glBegin(GL_QUADS);
- glColor3f(1.0, 1.0, 1.0);
-
- glTexCoord2f(leftSrc, bottomSrc); // Bottom Left
- glVertex3f(leftDst, bottomDst, 0.0f);
-
- glTexCoord2f(rightSrc, bottomSrc); // Bottom Right
- glVertex3f(rightDst, bottomDst, 0.0f);
-
- glTexCoord2f(rightSrc, topSrc); // Top Right
- glVertex3f(rightDst, topDst, 0.0f);
-
- glTexCoord2f(leftSrc, topSrc); // Top Left
- glVertex3f(leftDst, topDst, 0.0f);
-
- glEnd();
- glFlush();
+ dstBitmap.blitInto(&bitmap, srcRect, dstRect);
}
checkGlError("rBlitter End");
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 775495f54b5..66111ee93a1 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -601,10 +601,12 @@ public:
checkGlError("glCompressedTexImage");
} else {
glTexImage2D(GL_TEXTURE_2D, 0, texFormat, data.getWidth(), data.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data.getData());
+ checkGlError("glTexImage2D");
}
}
void bind() override {
glBindTexture(GL_TEXTURE_2D, _texId);
+ checkGlError("OpenGLTexture::bind");
};
};
diff --git a/engines/watchmaker/3d/texture.h b/engines/watchmaker/3d/texture.h
index dd3e4eac0a9..702d3a9e249 100644
--- a/engines/watchmaker/3d/texture.h
+++ b/engines/watchmaker/3d/texture.h
@@ -22,14 +22,17 @@
#ifndef WATCHMAKER_TEXTURE_H
#define WATCHMAKER_TEXTURE_H
+#include "common/array.h"
#include "common/str.h"
#include "common/textconsole.h"
#include "watchmaker/3d/dds_header.h"
#include "graphics/surface.h"
+#include "watchmaker/rect.h"
#include "watchmaker/surface.h"
namespace Watchmaker {
+class WGame;
// Texture structs
struct gTexture {
Common::String name;
@@ -45,8 +48,21 @@ struct gTexture {
return texture == nullptr;
}
void clear() {
- error("TODO: Clear texture");
+ // TODO: This will only work for the back-surface
+ warning("Clearing %d", _blitsOnTop.size());
+ _blitsOnTop.clear();
}
+ void render(WGame &game, Rect src, Rect dst);
+ void blitInto(gTexture *texture, Rect src, Rect dst) {
+ _blitsOnTop.push_back({texture, src, dst});
+ }
+private:
+ struct Blit {
+ gTexture *texture;
+ Rect src;
+ Rect dst;
+ };
+ Common::Array<Blit> _blitsOnTop;
};
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/ll/ll_regen.cpp b/engines/watchmaker/ll/ll_regen.cpp
index 95206e8eea9..b36d92c12de 100644
--- a/engines/watchmaker/ll/ll_regen.cpp
+++ b/engines/watchmaker/ll/ll_regen.cpp
@@ -223,7 +223,7 @@ void Regen(WGame &game) {
// DebugLogWindow( "Aggiorna video %d,%d %d,%d", ext.x1, ext.y1, ext.x2-ext.x1, ext.y2-ext.y1 );
#endif
rUpdateExtends(ext.x1, ext.y1, ext.x2, ext.y2);
- rBlitScreenBuffer();
+ rBlitScreenBuffer(game);
rResetExtends();
// 5 - Copy PaintRect to OldPaintRect
diff --git a/engines/watchmaker/render.cpp b/engines/watchmaker/render.cpp
index 54c9ed494fd..4e324f02ba5 100644
--- a/engines/watchmaker/render.cpp
+++ b/engines/watchmaker/render.cpp
@@ -90,6 +90,7 @@ bool checkGlError(const char *when) {
}
bool rClearBuffers(char flags) {
+ checkGlError("Entering rClearBuffers");
bool clearStencil = rGetStencilBitDepth() != 0;
bool clearDepth = flags & rCLEARZBUFFER;
bool clearBack = flags & rCLEARBACKBUFFER;
@@ -144,12 +145,12 @@ void rGetScreenInfos(unsigned int *width, unsigned int *height, unsigned int *bp
}
gTexture *gLoadTexture(char *TextName, unsigned int LoaderFlags) {
- warning("STUBBED gLoadTexture");
+ error("STUBBED gLoadTexture");
return nullptr;
}
bool rGrabVideo(const char *path, char flags) {
- warning("STUBBED: rGrabVideo");
+ error("STUBBED: rGrabVideo");
return true;
}
@@ -159,7 +160,7 @@ void rReleaseAllBitmaps(unsigned int NotFlags) {
}
void rReleaseBitmap(int i) {
- warning("STUBBED: rReleaseBitmap");
+ error("STUBBED: rReleaseBitmap");
return;
}
@@ -169,35 +170,26 @@ void rReleaseAllTextures(unsigned int NotFlags) {
}
void rSetBitmapName(unsigned int id, const char *s) {
- warning("STUBBED: rSetBitmapName");
+ error("STUBBED: rSetBitmapName");
return;
}
uint32 rGetMovieFrame(MaterialPtr mat) {
- warning("STUBBED: rGetMovieFrame");
+ error("STUBBED: rGetMovieFrame");
return 0;
}
void rPrintText(const char *s, unsigned int dst, unsigned int src, unsigned short *FontTable, unsigned short x, unsigned short y) {
- warning("STUBBED: rPrintText");
+ error("STUBBED: rPrintText");
return;
}
void rGetTextDim(const char *s, unsigned short *FontTable, int *x, int *y) {
- warning("STUBBED: rGetTextDim");
+ error("STUBBED: rGetTextDim");
return;
}
-void rClear(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b) {
- //warning("STUBBED: rClear(%d, %d, %d, %d, %d", dst, dposx, dposy, sdimx, sdimy);
-}
-
-
-void rBlitScreenBuffer(void) { // Should probably go to opengl_2d
- //warning("STUBBED: rBlitScreenBuffer");
-}
-
} // End of namespace Watchmaker
#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/render.h b/engines/watchmaker/render.h
index 29ed9f1c94b..8eb73ff5928 100644
--- a/engines/watchmaker/render.h
+++ b/engines/watchmaker/render.h
@@ -211,7 +211,7 @@ int DebugQuick(signed int StdPx, signed int StdPy, const cha
bool rGetStencilBitDepth();
//Misc functions
-void rBlitScreenBuffer();
+void rBlitScreenBuffer(WGame &game);
void rPrintText(const char *s, unsigned int dst, unsigned int src, unsigned short *FontTable, unsigned short x, unsigned short y);
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy, int sposx, int sposy, int sdimx, int sdimy);
Commit: ad47f12c1f613e8cf37edba54e4c6d58313bc3d8
https://github.com/scummvm/scummvm/commit/ad47f12c1f613e8cf37edba54e4c6d58313bc3d8
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Unstub ME_CONTINUEEFFECT
Changed paths:
engines/watchmaker/classes/do_system.cpp
engines/watchmaker/render.h
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index 5ed6a77bc3f..627cc0481b6 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -922,20 +922,18 @@ void doSystem(WGame &game) {
case ME_CONTINUEEFFECT:
TheMessage->wparam1 --;
if (TheMessage->wparam1 > 0) {
- warning("STUBBED: ME_CONTINUEEFFECT");
-#if 0
switch (TheMessage->bparam) {
case EFFECT_FADIN:
bDarkScreen = false;
- DisplayD3DRect(0, 0, SCREEN_RES_X, SCREEN_RES_Y, 1, 1, 1, (t3dU8)((255 * (TheMessage->lparam[1] - TheMessage->wparam1)) / TheMessage->lparam[1]));
+ DisplayD3DRect(*game._renderer, 0, 0, SCREEN_RES_X, SCREEN_RES_Y, 1, 1, 1, (byte)((255 * (TheMessage->lparam[1] - TheMessage->wparam1)) / TheMessage->lparam[1]));
break;
case EFFECT_FADOUT:
- DisplayD3DRect(0, 0, SCREEN_RES_X, SCREEN_RES_Y, 1, 1, 1, (t3dU8)((255 * (TheMessage->wparam1)) / TheMessage->lparam[1]));
+ DisplayD3DRect(*game._renderer, 0, 0, SCREEN_RES_X, SCREEN_RES_Y, 1, 1, 1, (byte)((255 * (TheMessage->wparam1)) / TheMessage->lparam[1]));
break;
case EFFECT_WAIT:
break;
case EFFECT_WAITDARK:
- DisplayD3DRect(0, 0, SCREEN_RES_X, SCREEN_RES_Y, 1, 1, 1, 1);
+ DisplayD3DRect(*game._renderer, 0, 0, SCREEN_RES_X, SCREEN_RES_Y, 1, 1, 1, 1);
break;
case EFFECT_ROOMINFO:
if ((RoomInfo.t_next_letter > TheMessage->wparam1) && ((*RoomInfo.letter_ptr) != '\0')) {
@@ -945,8 +943,8 @@ void doSystem(WGame &game) {
*(RoomInfo.letter_ptr + 1) = '\0';
rClear(RoomInfo.tnum, 0, 0, RoomInfo.dx, RoomInfo.dy, 0, 0, 0);
- rPrintText(RoomInfo.fullstring, RoomInfo.tnum, RoomInfo.f->Color[WHITE_FONT], RoomInfo.f->Table, 0, 0);
- rGetTextDim(RoomInfo.fullstring, RoomInfo.f->Table, &RoomInfo._dx, &RoomInfo._dy);
+ game._renderer->printText(RoomInfo.fullstring, RoomInfo.tnum, RoomInfo.f, FontColor::WHITE_FONT, 0, 0);
+ game._fonts.getTextDim(RoomInfo.fullstring, RoomInfo.f, &RoomInfo._dx, &RoomInfo._dy);
strcpy(RoomInfo.fullstring, name_backup);
@@ -967,11 +965,10 @@ void doSystem(WGame &game) {
UpdateIntroText(TheMessage->bparam, TheMessage->wparam1, TheMessage->lparam[1], TheMessage->lparam[0]);
break;
case EFFECT_DISPLAY_NEWLOGIMG:
- DisplayDDBitmap(NewLogImage, 800 - 60 - 8, 4, 0, 0, 0, 0);
+ DisplayDDBitmap(*game._renderer, NewLogImage, 800 - 60 - 8, 4, 0, 0, 0, 0);
break;
}
-#endif
TheMessage->flags |= MP_WAIT_RETRACE;
ReEvent();
} else if (TheMessage->wparam2) {
diff --git a/engines/watchmaker/render.h b/engines/watchmaker/render.h
index 8eb73ff5928..acbd24dc2df 100644
--- a/engines/watchmaker/render.h
+++ b/engines/watchmaker/render.h
@@ -212,7 +212,6 @@ bool rGetStencilBitDepth();
//Misc functions
void rBlitScreenBuffer(WGame &game);
-void rPrintText(const char *s, unsigned int dst, unsigned int src, unsigned short *FontTable, unsigned short x, unsigned short y);
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy, int sposx, int sposy, int sdimx, int sdimy);
//D3d specific geometry trasf. functions
Commit: 349bf36149684cf818b7b8a6b4e08b35bdf23ae6
https://github.com/scummvm/scummvm/commit/349bf36149684cf818b7b8a6b4e08b35bdf23ae6
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Apply astyle formatting to code base.
Changed paths:
engines/watchmaker/3d/animation.cpp
engines/watchmaker/3d/dds_header.cpp
engines/watchmaker/3d/dds_header.h
engines/watchmaker/3d/geometry.cpp
engines/watchmaker/3d/geometry.h
engines/watchmaker/3d/light.cpp
engines/watchmaker/3d/loader.cpp
engines/watchmaker/3d/material.cpp
engines/watchmaker/3d/material.h
engines/watchmaker/3d/math/llmath.cpp
engines/watchmaker/3d/movie.cpp
engines/watchmaker/3d/movie.h
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/render/opengl_renderer.cpp
engines/watchmaker/3d/t3d_body.cpp
engines/watchmaker/3d/t3d_body.h
engines/watchmaker/3d/t3d_face.cpp
engines/watchmaker/3d/t3d_face.h
engines/watchmaker/3d/t3d_mesh.cpp
engines/watchmaker/3d/t3d_mesh.h
engines/watchmaker/3d/texture.h
engines/watchmaker/3d/types3d.h
engines/watchmaker/classes/do_camera.cpp
engines/watchmaker/classes/do_keyboard.cpp
engines/watchmaker/classes/do_mouse.cpp
engines/watchmaker/classes/do_sound.cpp
engines/watchmaker/file_utils.cpp
engines/watchmaker/file_utils.h
engines/watchmaker/fonts.cpp
engines/watchmaker/fonts.h
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/ll/ll_mesh.cpp
engines/watchmaker/ll/ll_mesh.h
engines/watchmaker/ll/ll_mouse.cpp
engines/watchmaker/ll/ll_system.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/main.cpp
engines/watchmaker/metaengine.cpp
engines/watchmaker/render.h
engines/watchmaker/renderer.cpp
engines/watchmaker/saveload.cpp
engines/watchmaker/schedule.cpp
engines/watchmaker/schedule.h
engines/watchmaker/sdl_wrapper.cpp
engines/watchmaker/t2d/t2d.cpp
engines/watchmaker/t3d.h
engines/watchmaker/walk/act.cpp
engines/watchmaker/walk/act.h
engines/watchmaker/walk/ball.cpp
engines/watchmaker/watchmaker.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index f9f679cb5bc..8745988482e 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -120,7 +120,7 @@ uint8 GetLightPosition(t3dV3F *dest, uint8 pos) {
auto pLights = t3dCurRoom->getPositionalLight(pos);
dest->y = CurFloorY;
- for (auto light: pLights) {
+ for (auto light : pLights) {
if (light.Pos.x && light.Pos.z) {
dest->x = light.Pos.x;
dest->z = light.Pos.z;
@@ -140,7 +140,7 @@ uint8 GetLightDirection(t3dV3F *dest, uint8 pos) {
auto pLights = t3dCurRoom->getPositionalLight(pos);
dest->y = CurFloorY;
- for (auto light: pLights) {
+ for (auto light : pLights) {
if (light.Dir.x && light.Dir.z) {
dest->x = light.Dir.x;
dest->z = light.Dir.x;
@@ -673,7 +673,7 @@ uint8 GetFullLightDirection(t3dV3F *dest, uint8 pos) {
if (!pos) return 0;
auto pLights = t3dCurRoom->getPositionalLight(pos);
- for (auto light: pLights) {
+ for (auto light : pLights) {
if (light.Dir.x && light.Dir.z) {
*dest = light.Dir;
return pos;
@@ -725,7 +725,7 @@ uint8 CompareLightPosition(char *roomname, uint8 pos1, t3dV3F *pos2, t3dF32 acce
auto pLights = t->getPositionalLight(pos1);
bool foundLight = false;
- for (auto light: pLights) {
+ for (auto light : pLights) {
if (light.Pos.x && light.Pos.z) {
p1.x = light.Pos.x;
p1.y = light.Pos.y;
diff --git a/engines/watchmaker/3d/dds_header.cpp b/engines/watchmaker/3d/dds_header.cpp
index 7d5eb2ac965..dabf21f915f 100644
--- a/engines/watchmaker/3d/dds_header.cpp
+++ b/engines/watchmaker/3d/dds_header.cpp
@@ -27,7 +27,7 @@ namespace Watchmaker {
DDSHeader::DDSHeader(Common::SeekableReadStream &stream) {
//warning("TODO: Implement DDS Header parsing");
- uint32 retv = MKTAG( ' ','S','D','D' );
+ uint32 retv = MKTAG(' ', 'S', 'D', 'D');
uint32 magic = stream.readUint32LE();
if (magic != retv) {
error("parseDDSHeader: Wrong Magic, expected %08X, got %08X\n", retv, magic);
@@ -50,7 +50,7 @@ DDSHeader::DDSHeader(Common::SeekableReadStream &stream) {
}
uint32 blockSize(DxtCompression compression) {
- switch(compression) {
+ switch (compression) {
case DxtCompression::DXT1:
return 8;
default:
@@ -70,25 +70,33 @@ private:
DDSHeader _header;
public:
DDSTextureData(byte *data, uint32 dataSize, DDSHeader header) : TextureData(header.compression),
- _data(data),
- _dataSize(dataSize),
- _header(header) {}
+ _data(data),
+ _dataSize(dataSize),
+ _header(header) {}
~DDSTextureData() override {
delete[] _data;
}
DxtCompression _compression;
- int getWidth() const override { return _header.width; }
- int getHeight() const override { return _header.height; }
- int getDataSize() const override { return _dataSize; }
- const void *getData() const override { return _data; }
+ int getWidth() const override {
+ return _header.width;
+ }
+ int getHeight() const override {
+ return _header.height;
+ }
+ int getDataSize() const override {
+ return _dataSize;
+ }
+ const void *getData() const override {
+ return _data;
+ }
};
-Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream& stream) {
+Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream &stream) {
DDSHeader header(stream);
return loadDdsTexture(stream, header);
}
-Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream& stream, DDSHeader &header) {
+Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream &stream, DDSHeader &header) {
assert(header.width > 0);
unsigned char *data = new unsigned char[header.dataSize()]();
stream.read(data, header.dataSize());
diff --git a/engines/watchmaker/3d/dds_header.h b/engines/watchmaker/3d/dds_header.h
index df7f215b984..89c67b0c69c 100644
--- a/engines/watchmaker/3d/dds_header.h
+++ b/engines/watchmaker/3d/dds_header.h
@@ -29,11 +29,11 @@ namespace Watchmaker {
enum class DxtCompression : uint32 {
UNCOMPRESSED = 0,
- DXT1 = MKTAG('1','T','X','D'),
- DXT2 = MKTAG('2','T','X','D'),
- DXT3 = MKTAG('3','T','X','D'),
- DXT4 = MKTAG('4','T','X','D'),
- DXT5 = MKTAG('5','T','X','D')
+ DXT1 = MKTAG('1', 'T', 'X', 'D'),
+ DXT2 = MKTAG('2', 'T', 'X', 'D'),
+ DXT3 = MKTAG('3', 'T', 'X', 'D'),
+ DXT4 = MKTAG('4', 'T', 'X', 'D'),
+ DXT5 = MKTAG('5', 'T', 'X', 'D')
};
class TextureData {
@@ -65,8 +65,8 @@ struct DDSHeader {
};
//Common::SharedPtr<Texture> loadTgaTextureData(Common::SeekableReadStream &stream);
-Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream& stream, DDSHeader &header);
-Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream& stream);
+Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream &stream, DDSHeader &header);
+Common::SharedPtr<TextureData> loadDdsTexture(Common::SeekableReadStream &stream);
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index 27dfbb0aabd..efbe1cb6678 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -3402,7 +3402,7 @@ void t3dProcessPortals(void) {
* t3dAddTriangle
* --------------------------------------------------*/
void t3dAddTriangle(t3dF32 x1, t3dF32 y1, t3dF32 x2, t3dF32 y2, t3dF32 x3, t3dF32 y3,
- int32 r, int32 g, int32 b, int32 a) {
+ int32 r, int32 g, int32 b, int32 a) {
rAddTrianglesArray(x1, y1, r, g, b, a);
rAddTrianglesArray(x2, y2, r, g, b, a);
rAddTrianglesArray(x3, y3, r, g, b, a);
@@ -3412,7 +3412,7 @@ void t3dAddTriangle(t3dF32 x1, t3dF32 y1, t3dF32 x2, t3dF32 y2, t3dF32 x3, t3dF3
* t3dAddQuad
* --------------------------------------------------*/
void t3dAddQuad(t3dF32 x1, t3dF32 y1, t3dF32 x2, t3dF32 y2, t3dF32 x3, t3dF32 y3, t3dF32 x4, t3dF32 y4,
- int32 r, int32 g, int32 b, int32 a) {
+ int32 r, int32 g, int32 b, int32 a) {
t3dAddTriangle(x1, y1, x2, y2, x3, y3, r, g, b, a);
t3dAddTriangle(x2, y2, x4, y4, x3, y3, r, g, b, a);
}
diff --git a/engines/watchmaker/3d/geometry.h b/engines/watchmaker/3d/geometry.h
index f75a36c5647..651be1bbe7b 100644
--- a/engines/watchmaker/3d/geometry.h
+++ b/engines/watchmaker/3d/geometry.h
@@ -82,9 +82,9 @@ void t3dSortMeshes();
void QueueMaterialList(MaterialTable &MatList, unsigned int NumMat, signed short int ViewMatrixNum);
void ProcessMaterialList();
void t3dAddTriangle(t3dF32 x1, t3dF32 y1, t3dF32 x2, t3dF32 y2, t3dF32 x3, t3dF32 y3,
- int32 r, int32 g, int32 b, int32 a);
+ int32 r, int32 g, int32 b, int32 a);
void t3dAddQuad(t3dF32 x1, t3dF32 y1, t3dF32 x2, t3dF32 y2, t3dF32 x3, t3dF32 y3, t3dF32 x4, t3dF32 y4,
- int32 r, int32 g, int32 b, int32 a);
+ int32 r, int32 g, int32 b, int32 a);
} // End of namespace Watchmaker
#endif // WATCHMAKER_GEOMETRY_H
diff --git a/engines/watchmaker/3d/light.cpp b/engines/watchmaker/3d/light.cpp
index 9af040a8a48..a2386cad3d0 100644
--- a/engines/watchmaker/3d/light.cpp
+++ b/engines/watchmaker/3d/light.cpp
@@ -329,7 +329,7 @@ void GetBoundaries(t3dBODY *b, t3dF32 *minx, t3dF32 *miny, t3dF32 *minz, t3dF32
t3dLIGHT::t3dLIGHT(WGame &game, t3dBODY *b, WorkDirs &workDirs, Common::SeekableReadStream &stream) {
Type = stream.readUint32LE(); // Legge tipo
- // DebugFile("%d: SPOT %X ATTEN %X SHAD %X",light,Light[light].Type&T3D_LIGHT_SPOTLIGHT,Light[light].Type&T3D_LIGHT_ATTENUATION,Light[light].Type&T3D_LIGHT_CASTSHADOWS);
+ // DebugFile("%d: SPOT %X ATTEN %X SHAD %X",light,Light[light].Type&T3D_LIGHT_SPOTLIGHT,Light[light].Type&T3D_LIGHT_ATTENUATION,Light[light].Type&T3D_LIGHT_CASTSHADOWS);
Source = t3dV3F(stream) * SCALEFACTOR; // Legge Source
Target = t3dV3F(stream) * SCALEFACTOR; // Legge Target
@@ -368,7 +368,7 @@ t3dLIGHT::t3dLIGHT(WGame &game, t3dBODY *b, WorkDirs &workDirs, Common::Seekable
}
#else
strcpy(Appo, WmMapsDir);
- strcat(Appo, Name);
+ strcat(Appo, Name);
#endif
#ifndef WMGEN
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index 3be0204d960..35cc59bb0b2 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -219,7 +219,7 @@ t3dBODY *t3dLoadSingleRoom(WGame &game, const Common::String &_pname, t3dBODY *b
b = (t3dBODY *)t3dRealloc((uint32 *)b, sizeof(t3dBODY) * (++(*NumBody))); // Altrimenti, ridimensiona
//warning("Loading %s ...", name.c_str());
- *b = t3dBODY(); // Azzera Body
+ *b = t3dBODY(); // Azzera Body
uint16 fileVersion = stream->readByte();
if (fileVersion != T3DFILEVERSION) { // Controlla la versione del file
@@ -322,8 +322,8 @@ t3dParticle::t3dParticle(Common::SeekableReadStream &stream) {
#ifndef WMGEN
ParticleIndex = t3dCreateSmokeParticle(Num,
- Type,
- OR1);
+ Type,
+ OR1);
#endif
difR1 = (R2 - R1) / (Seg1 / Speed1);
difG1 = (G2 - G1) / (Seg1 / Speed1);
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index a60893ec955..73fc9907ce4 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -30,35 +30,32 @@ MaterialPtr rAddMaterial(gMaterial &Material, const Common::String &TextName, in
// TODO: This is duplicated in opengl_3d.cpp
warning("TODO: Fix rAddMaterial");
#if 0
- bool AlreadyLoaded=FALSE;
- int len=strlen(TextName);
-
- if (((TextName[len-1-0]=='i')|| (TextName[len-1-0]=='I')) &&
- ((TextName[len-1-1]=='v')|| (TextName[len-1-1]=='V')) &&
- ((TextName[len-1-2]=='a')|| (TextName[len-1-2]=='A')) )
- {
- if( (Material.Movie=gLoadMovie(TextName)) == NULL )
+ bool AlreadyLoaded = FALSE;
+ int len = strlen(TextName);
+
+ if (((TextName[len - 1 - 0] == 'i') || (TextName[len - 1 - 0] == 'I')) &&
+ ((TextName[len - 1 - 1] == 'v') || (TextName[len - 1 - 1] == 'V')) &&
+ ((TextName[len - 1 - 2] == 'a') || (TextName[len - 1 - 2] == 'A'))) {
+ if ((Material.Movie = gLoadMovie(TextName)) == NULL)
return NULL;
- if( (Material.Texture=gUserTexture( 64,
- 128)) == NULL )
-// if( (Material->Texture=gUserTexture( Material->Movie->g_psiStreamInfo.rcFrame.right,
+ if ((Material.Texture = gUserTexture(64,
+ 128)) == NULL)
+// if( (Material->Texture=gUserTexture( Material->Movie->g_psiStreamInfo.rcFrame.right,
// Material->Movie->g_psiStreamInfo.rcFrame.bottom)) == NULL )
return NULL;
- Material.Flags|=T3D_MATERIAL_MOVIE;
- }
- else
- {
- if( (Material.Texture=gLoadTexture(TextName,LoaderFlags)) == NULL )
+ Material.Flags |= T3D_MATERIAL_MOVIE;
+ } else {
+ if ((Material.Texture = gLoadTexture(TextName, LoaderFlags)) == NULL)
return NULL;
}
//f
-//f Material->FacesList=(WORD *)t3dRealloc(Material->FacesList,sizeof(WORD)*3*NumFaces+1);
-//f Material->NumAllocatedFaces+=3*NumFaces+1;
- Material.FacesList.resize(Material.FacesList.size() + NumFaces * 3 );
- Material.NumAllocatedFaces+=NumFaces*3;
+//f Material->FacesList=(WORD *)t3dRealloc(Material->FacesList,sizeof(WORD)*3*NumFaces+1);
+//f Material->NumAllocatedFaces+=3*NumFaces+1;
+ Material.FacesList.resize(Material.FacesList.size() + NumFaces * 3);
+ Material.NumAllocatedFaces += NumFaces * 3;
//f
- Material.Flags|=T3D_MATERIAL_NOLIGHTMAP;
+ Material.Flags |= T3D_MATERIAL_NOLIGHTMAP;
return Material;
#endif
return nullptr;
@@ -97,19 +94,18 @@ void gMaterial::addColor(unsigned char r_add, unsigned char g_add, unsigned char
}
bool gMaterial::addNumFacesAdditionalMaterial(MaterialPtr am, unsigned int num) {
- if( !num || !am )
+ if (!num || !am)
return false;
Common::SharedPtr<gMaterial> cm;
int i;
- for ( i=0; i<this->NumAddictionalMaterial; i++ ) {
+ for (i = 0; i < this->NumAddictionalMaterial; i++) {
cm = this->AddictionalMaterial[i];
if (cm->Texture->ID == am->Texture->ID)
break;
}
- if( i == this->NumAddictionalMaterial )
- {
+ if (i == this->NumAddictionalMaterial) {
this->AddictionalMaterial.push_back(Common::SharedPtr<gMaterial>(new gMaterial(*am)));
cm = this->AddictionalMaterial.back();
cm->FacesList.resize(0);
@@ -125,12 +121,12 @@ bool gMaterial::addNumFaces(unsigned int num) {
MaterialPtr rMergeMaterial(MaterialPtr Mat1, MaterialPtr Mat2) {
- if ( !Mat1 || !Mat2 )
+ if (!Mat1 || !Mat2)
return nullptr;
- for ( int i=0; i<Mat2->NumAddictionalMaterial; i++ ) {
+ for (int i = 0; i < Mat2->NumAddictionalMaterial; i++) {
Mat1->addNumFacesAdditionalMaterial(Mat2->AddictionalMaterial[i],
- /*Mat2->AddictionalMaterial[i]->NumAllocatedFaces*/ Mat2->AddictionalMaterial[i]->NumFaces());
+ /*Mat2->AddictionalMaterial[i]->NumAllocatedFaces*/ Mat2->AddictionalMaterial[i]->NumFaces());
}
//reset mat2
rRemoveMaterial(Mat2);
@@ -198,24 +194,22 @@ void gMaterial::clear() {
// TODO: This flag clearing doesn't happen in the original, but shouldn't matter as the class is instantiated again when used in Particles.
Flags = 0;
- if (Movie)
- {
+ if (Movie) {
Movie = nullptr;
}
FacesList.clear();
VertsList.clear();
FlagsList.clear();
-// rDeleteVertexBuffer(m->VB);
- VBO=0;
+// rDeleteVertexBuffer(m->VB);
+ VBO = 0;
- for ( int j=0; j<NumAddictionalMaterial; j++)
- {
+ for (int j = 0; j < NumAddictionalMaterial; j++) {
Common::SharedPtr<gMaterial> cm = AddictionalMaterial[j];
cm->FacesList.clear();
cm->VertsList.clear();
cm->FlagsList.clear();
-// rDeleteVertexBuffer(cm->VB);
- cm->VBO=0;
+// rDeleteVertexBuffer(cm->VB);
+ cm->VBO = 0;
}
AddictionalMaterial.clear();
}
@@ -252,7 +246,7 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
for (int o = 0; o < bb->FacesList.size(); o++) {
warning("%d", bb->FacesList[o]);
}
- warning("%d > %d (%d)", bb->FacesList[f],bb->VBO->_buffer.size(), bb->NumVerts());
+ warning("%d > %d (%d)", bb->FacesList[f], bb->VBO->_buffer.size(), bb->NumVerts());
}
}
mat.emptyFacesList(); // We may want to keep the reservation to avoid the extra reallocs here.
@@ -302,7 +296,7 @@ void rBuildMaterialList(MaterialTable &MatList, unsigned int NumMat, signed shor
if (NumMat == 0)
return;
- for (auto &mat: MatList) {
+ for (auto &mat : MatList) {
rAddToMaterialList(mat, ViewMatrixNum);
}
}
diff --git a/engines/watchmaker/3d/material.h b/engines/watchmaker/3d/material.h
index dd741204260..45b32e761b4 100644
--- a/engines/watchmaker/3d/material.h
+++ b/engines/watchmaker/3d/material.h
@@ -40,26 +40,38 @@ struct gMaterial {
gTexture *Texture = nullptr; // pointer to texture struct
Common::SharedPtr<gMovie> Movie; // pointer to movie struct
unsigned int Flags = 0; // material flags
- int NumFaces() { return FacesList.size(); }; // current number of faces to be processed
+ int NumFaces() {
+ return FacesList.size();
+ }; // current number of faces to be processed
void addFace(uint16 face) {
FacesList.push_back(face);
}
- uint16 getFace(int index) const { return FacesList[index]; }
- void clearFaceList() { FacesList.clear(); }
- void emptyFacesList() { FacesList.resize(0); }
- Common::Array<uint16> getFacesList() { return FacesList; }
+ uint16 getFace(int index) const {
+ return FacesList[index];
+ }
+ void clearFaceList() {
+ FacesList.clear();
+ }
+ void emptyFacesList() {
+ FacesList.resize(0);
+ }
+ Common::Array<uint16> getFacesList() {
+ return FacesList;
+ }
private:
Common::Array<uint16> FacesList; // list of verts indices
public:
- Common::Array<gVertex*> VertsList; // pointers to pointers to verts
- int NumAllocatedVerts() { return this->VertsList.size(); }; // number of allocated vertex in mat VB
+ Common::Array<gVertex *> VertsList; // pointers to pointers to verts
+ int NumAllocatedVerts() {
+ return this->VertsList.size();
+ }; // number of allocated vertex in mat VB
Common::SharedPtr<VertexBuffer> VBO = nullptr;
// LPDIRECT3DVERTEXBUFFER7 VB; // mat VB struct
int NumAllocatedMesh = 0; // num mesh to check for modifications
Common::Array<unsigned int *> FlagsList; // vector of pointer to mesh flags
unsigned char r, g, b; // default material color
int NumAddictionalMaterial = 0; // number of addictional material (lightmaps)
- MaterialTable AddictionalMaterial; // pointer to addictional material struct
+ MaterialTable AddictionalMaterial; // pointer to addictional material struct
public:
gMaterial() : r(0), g(0), b(0) {
diff --git a/engines/watchmaker/3d/math/llmath.cpp b/engines/watchmaker/3d/math/llmath.cpp
index c5e915fb00f..f0dab53bf2f 100644
--- a/engines/watchmaker/3d/math/llmath.cpp
+++ b/engines/watchmaker/3d/math/llmath.cpp
@@ -365,7 +365,7 @@ uint8 t3dVectPlaneIntersection(t3dV3F *inter, t3dV3F start, t3dV3F end, t3dNORMA
}
uint8 t3dVectTriangleIntersection(t3dV3F *inter, t3dV3F start, t3dV3F end,
- t3dV3F v1, t3dV3F v2, t3dV3F v3, t3dNORMAL n) {
+ t3dV3F v1, t3dV3F v2, t3dV3F v3, t3dNORMAL n) {
t3dV3F appo;
t3dNORMAL normal;
diff --git a/engines/watchmaker/3d/movie.cpp b/engines/watchmaker/3d/movie.cpp
index 93b3be7cf51..b551a495601 100644
--- a/engines/watchmaker/3d/movie.cpp
+++ b/engines/watchmaker/3d/movie.cpp
@@ -38,13 +38,13 @@ gMovie::gMovie(Common::SharedPtr<Common::SeekableReadStream> stream, Texture *te
_numBlocks = _width * _height / 16;
_curFrame = 0xFFFF;
- _frameOffsets = new uint32[_numFrames]{};
+ _frameOffsets = new uint32[_numFrames] {};
if (!_frameOffsets) {
error("gLoadMovie FAILED: Can't alloc Movie->frameOffsets struct");
}
- _buffer = new uint8[bufferSize()]{};
- _surfaceBuffer = new uint8[_header.dataSize()]{};
+ _buffer = new uint8[bufferSize()] {};
+ _surfaceBuffer = new uint8[_header.dataSize()] {};
_frameStream = new Common::MemoryReadStream(_surfaceBuffer, _header.dataSize(), DisposeAfterUse::NO);
if (!_buffer) {
error("gLoadMovie FAILED: Can't alloc Movie->buffer struct");
@@ -72,19 +72,18 @@ Common::SharedPtr<gMovie> gLoadMovie(WorkDirs &workDirs, const char *TextName, T
return nullptr;
}
- // Movie->frameRate=240;
+ // Movie->frameRate=240;
return Movie;
}
-void gMovie::loadThisFrameData(uint32 frame)
-{
+void gMovie::loadThisFrameData(uint32 frame) {
_stream->seek(_frameOffsets[frame], SEEK_SET);
//read frame data
int size = 0;
- if ((frame+1)==_numFrames) {
+ if ((frame + 1) == _numFrames) {
size = _stream->size() - _frameOffsets[frame];
} else {
- size = _frameOffsets[frame+1] - _frameOffsets[frame];
+ size = _frameOffsets[frame + 1] - _frameOffsets[frame];
}
assert(size <= bufferSize());
_stream->read(_buffer, size);
@@ -94,20 +93,21 @@ void gMovie::loadThisFrameData(uint32 frame)
void gMovie::buildNewFrame(byte *surf, uint32 frame) {
loadThisFrameData(frame);
- DWORD bitArraySize=_numBlocks>>3;
- byte *buf=&_buffer[bitArraySize];
- WORD curBlock=0;
+ DWORD bitArraySize = _numBlocks >> 3;
+ byte *buf = &_buffer[bitArraySize];
+ WORD curBlock = 0;
- for(int i=0; i<bitArraySize; i++) {
+ for (int i = 0; i < bitArraySize; i++) {
byte block = _buffer[i];
- if(!block) {
+ if (!block) {
curBlock += 8;
- continue; //everything is equal
+ continue; //everything is equal
}
- for(int j=0; j<8; j++, curBlock++) {
- if(block & (1<<j) ) {
- memcpy(&surf[curBlock<<3],buf,8); buf+=8;
+ for (int j = 0; j < 8; j++, curBlock++) {
+ if (block & (1 << j)) {
+ memcpy(&surf[curBlock << 3], buf, 8);
+ buf += 8;
}
}//for j
}//for
diff --git a/engines/watchmaker/3d/movie.h b/engines/watchmaker/3d/movie.h
index 86ade66cd3e..6cfa378d902 100644
--- a/engines/watchmaker/3d/movie.h
+++ b/engines/watchmaker/3d/movie.h
@@ -54,7 +54,7 @@ public:
bool _paused = false;
- gMovie(Common::SharedPtr<Common::SeekableReadStream> stream, Texture *texture, const Common::String& name);
+ gMovie(Common::SharedPtr<Common::SeekableReadStream> stream, Texture *texture, const Common::String &name);
bool setFrame(uint32 newFrame);
void loadThisFrameData(uint32 frame);
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 8f79d2a79a9..ce4644c080d 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -119,37 +119,31 @@ void rResetExtends(void) {
// TODO: Move this to Renderer
extern Rect gBlitterViewport;
bool gClipToBlitterViewport(int *sposx, int *sposy, int *sdimx, int *sdimy,
- int *dposx, int *dposy )
-{
+ int *dposx, int *dposy) {
int dwWidth, dwHeight;
- dwWidth=(gBlitterViewport.right-gBlitterViewport.left);
- dwHeight=(gBlitterViewport.bottom-gBlitterViewport.top);
+ dwWidth = (gBlitterViewport.right - gBlitterViewport.left);
+ dwHeight = (gBlitterViewport.bottom - gBlitterViewport.top);
- if ( ((*dposx)+(*sdimx))>dwWidth)
- {
- (*sdimx)=(*sdimx)-((*dposx)+(*sdimx)-dwWidth);
+ if (((*dposx) + (*sdimx)) > dwWidth) {
+ (*sdimx) = (*sdimx) - ((*dposx) + (*sdimx) - dwWidth);
}
- if ( ((*dposy)+(*sdimy))>dwHeight)
- {
- (*sdimy)=(*sdimy)-((*dposy)+(*sdimy)-dwHeight);
+ if (((*dposy) + (*sdimy)) > dwHeight) {
+ (*sdimy) = (*sdimy) - ((*dposy) + (*sdimy) - dwHeight);
}
- if ( (*dposx)<gBlitterViewport.left)
- {
- (*sposx)+=gBlitterViewport.left-(*dposx);
- (*sdimx)-=gBlitterViewport.left-(*dposx);
- (*dposx)=gBlitterViewport.left;
+ if ((*dposx) < gBlitterViewport.left) {
+ (*sposx) += gBlitterViewport.left - (*dposx);
+ (*sdimx) -= gBlitterViewport.left - (*dposx);
+ (*dposx) = gBlitterViewport.left;
}
- if ( (*dposy)<gBlitterViewport.top)
- {
- (*sposy)+=gBlitterViewport.top-(*dposy);
- (*sdimy)-=gBlitterViewport.top-(*dposy);
- (*dposy)=gBlitterViewport.top;
+ if ((*dposy) < gBlitterViewport.top) {
+ (*sposy) += gBlitterViewport.top - (*dposy);
+ (*sdimy) -= gBlitterViewport.top - (*dposy);
+ (*dposy) = gBlitterViewport.top;
}
- if(((*sdimx)<=0) || ((*sdimy)<=0))
- {
+ if (((*sdimx) <= 0) || ((*sdimy) <= 0)) {
return false;
}
@@ -176,7 +170,7 @@ void exit2Dmode() {
void renderTexture(WGame &game, gTexture &bitmap, Rect srcRect, Rect dstRect) {
checkGlError("Entering renderTexture");
- glClearColor(0,0,1,0);
+ glClearColor(0, 0, 1, 0);
glEnable(GL_TEXTURE_2D);
glEnable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
@@ -189,9 +183,9 @@ void renderTexture(WGame &game, gTexture &bitmap, Rect srcRect, Rect dstRect) {
glTranslatef(0, 0, 0.0);
float bottomSrc = ((float)srcRect.bottom) / bitmap.RealDimY;
- float topSrc = ((float)srcRect.top) / bitmap.RealDimY;
- float leftSrc = ((float)srcRect.left) / bitmap.RealDimX;
- float rightSrc = ((float)srcRect.right) / bitmap.RealDimX;
+ float topSrc = ((float)srcRect.top) / bitmap.RealDimY;
+ float leftSrc = ((float)srcRect.left) / bitmap.RealDimX;
+ float rightSrc = ((float)srcRect.right) / bitmap.RealDimX;
Rect viewport = game._renderer->_viewport;
float bottomDst = 1.0 - ((dstRect.bottom == 0 ? 0 : ((double)dstRect.bottom) / viewport.height()) * 2.0);
@@ -268,7 +262,7 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
}
if ((dposx >= dwWidth) || (dposy >= dwHeight) || (sposx >= dwWidth) || (sposy >= dwHeight) ||
- ((dposx + sdimx) <= 0) || ((dposy + sdimy) <= 0) || ((sposx + sdimx) <= 0) || ((sposy + sdimy) <= 0)) {
+ ((dposx + sdimx) <= 0) || ((dposy + sdimy) <= 0) || ((sposx + sdimx) <= 0) || ((sposy + sdimy) <= 0)) {
return;
}
@@ -289,22 +283,21 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
{
Rect srcRect;
// Source rect
- srcRect.top=sposy;
- srcRect.left=sposx;
- srcRect.right= sposx + sdimx;
- srcRect.bottom= sposy + sdimy;
+ srcRect.top = sposy;
+ srcRect.left = sposx;
+ srcRect.right = sposx + sdimx;
+ srcRect.bottom = sposy + sdimy;
Rect dstRect;
// Destination rect
// Convention in dpos is that 0,0 is upper left hand corner, increasing down the y-axis.
- dstRect.top=dposy;
- dstRect.left=dposx;
- dstRect.right= dposx + sdimx;
- dstRect.bottom= dposy + sdimy;
- if(((dstRect.bottom - dstRect.top) <= 0) || ((dstRect.right - dstRect.left ) <= 0) || ((srcRect.bottom - srcRect.top) <= 0) || ((srcRect.right - srcRect.left ) <= 0) ||
- (dstRect.right <= 0) || (srcRect.right <= 0) || (dstRect.bottom < 0) || (srcRect.bottom < 0) )
- {
-// DebugLogWindow("gBlitter: blit not needed: dimx:%d dimy:%d", ( sr.top-sr.bottom ),( sr.left-sr.right ));
+ dstRect.top = dposy;
+ dstRect.left = dposx;
+ dstRect.right = dposx + sdimx;
+ dstRect.bottom = dposy + sdimy;
+ if (((dstRect.bottom - dstRect.top) <= 0) || ((dstRect.right - dstRect.left) <= 0) || ((srcRect.bottom - srcRect.top) <= 0) || ((srcRect.right - srcRect.left) <= 0) ||
+ (dstRect.right <= 0) || (srcRect.right <= 0) || (dstRect.bottom < 0) || (srcRect.bottom < 0)) {
+// DebugLogWindow("gBlitter: blit not needed: dimx:%d dimy:%d", ( sr.top-sr.bottom ),( sr.left-sr.right ));
return;
}
dstBitmap.blitInto(&bitmap, srcRect, dstRect);
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 66111ee93a1..85ee05fd317 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -192,9 +192,9 @@ bool rSetViewMatrix(float _00, float _01, float _02,
void rSetViewMatrix(const t3dM3X3F &viewMatrix, const t3dV3F &translation) {
rSetViewMatrix(viewMatrix.M[0], viewMatrix.M[1], viewMatrix.M[2],
- viewMatrix.M[3], viewMatrix.M[4], viewMatrix.M[5],
- viewMatrix.M[6], viewMatrix.M[7], viewMatrix.M[8],
- translation.x, translation.y, -translation.z);
+ viewMatrix.M[3], viewMatrix.M[4], viewMatrix.M[5],
+ viewMatrix.M[6], viewMatrix.M[7], viewMatrix.M[8],
+ translation.x, translation.y, -translation.z);
}
void rSaveViewMatrix() {
@@ -238,9 +238,9 @@ bool rBuildLinesViewMatrix(float _00, float _01, float _02,
int rBuildLinesViewMatrix(const t3dM3X3F &viewMatrix, const t3dV3F &translation) {
return rBuildLinesViewMatrix(viewMatrix.M[0], viewMatrix.M[1], viewMatrix.M[2],
- viewMatrix.M[3], viewMatrix.M[4], viewMatrix.M[5],
- viewMatrix.M[6], viewMatrix.M[7], viewMatrix.M[8],
- translation.x, translation.y, translation.z);
+ viewMatrix.M[3], viewMatrix.M[4], viewMatrix.M[5],
+ viewMatrix.M[6], viewMatrix.M[7], viewMatrix.M[8],
+ translation.x, translation.y, translation.z);
}
//***********************************************************************************************
@@ -298,9 +298,9 @@ int rAddUserViewMatrix(float _00, float _01, float _02,
int rAddUserViewMatrix(const t3dM3X3F &viewMatrix, const t3dV3F &translation) {
return rAddUserViewMatrix(viewMatrix.M[0], viewMatrix.M[1], viewMatrix.M[2],
- viewMatrix.M[3], viewMatrix.M[4], viewMatrix.M[5],
- viewMatrix.M[6], viewMatrix.M[7], viewMatrix.M[8],
- translation.x, translation.y, translation.z);
+ viewMatrix.M[3], viewMatrix.M[4], viewMatrix.M[5],
+ viewMatrix.M[6], viewMatrix.M[7], viewMatrix.M[8],
+ translation.x, translation.y, translation.z);
}
void rResetPipeline() {
@@ -590,14 +590,14 @@ public:
if (compressed) {
glCompressedTexImage2D(GL_TEXTURE_2D, // target
- 0, // level
- texFormat, // internalFormat
- data.getWidth(), // width
- data.getHeight(), // height
- 0, // border
- data.getDataSize(),
- data.getData()
- );
+ 0, // level
+ texFormat, // internalFormat
+ data.getWidth(), // width
+ data.getHeight(), // height
+ 0, // border
+ data.getDataSize(),
+ data.getData()
+ );
checkGlError("glCompressedTexImage");
} else {
glTexImage2D(GL_TEXTURE_2D, 0, texFormat, data.getWidth(), data.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data.getData());
@@ -621,10 +621,18 @@ public:
delete _surface;
}
}
- int getWidth() const override { return _surface->w; }
- int getHeight() const override { return _surface->h; }
- int getDataSize() const override { return _surface->w * _surface->h * _surface->format.bytesPerPixel; }
- const void *getData() const override { return _surface->getPixels(); }
+ int getWidth() const override {
+ return _surface->w;
+ }
+ int getHeight() const override {
+ return _surface->h;
+ }
+ int getDataSize() const override {
+ return _surface->w * _surface->h * _surface->format.bytesPerPixel;
+ }
+ const void *getData() const override {
+ return _surface->getPixels();
+ }
};
Texture *createGLTexture() {
diff --git a/engines/watchmaker/3d/render/opengl_renderer.cpp b/engines/watchmaker/3d/render/opengl_renderer.cpp
index cd26a878533..2f795c07ec9 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.cpp
+++ b/engines/watchmaker/3d/render/opengl_renderer.cpp
@@ -98,10 +98,10 @@ void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, int V
void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, gBatchBlock &bb) {
drawIndexedPrimitivesVBO(primitiveType,
- bb.VBO, 0, bb.NumVerts(),
- bb.FacesList,
- bb.NumFaces()/*, 0x0*/
- );
+ bb.VBO, 0, bb.NumVerts(),
+ bb.FacesList,
+ bb.NumFaces()/*, 0x0*/
+ );
}
void OpenGLRenderer::setTransformMatrix(TransformMatrix which, const Matrix4x4 &matrix) {
@@ -132,14 +132,14 @@ void OpenGLRenderer::popModelView() {
void OpenGLRenderer::setTextureWrapMode(int index, TextureWrapMode mode) {
GLint openGlWrapMode = 0;
switch (mode) {
- case TextureWrapMode::WRAP:
- openGlWrapMode = GL_REPEAT;
- break;
- case TextureWrapMode::CLAMP:
- openGlWrapMode = GL_CLAMP;
- break;
- default:
- assert(0);
+ case TextureWrapMode::WRAP:
+ openGlWrapMode = GL_REPEAT;
+ break;
+ case TextureWrapMode::CLAMP:
+ openGlWrapMode = GL_CLAMP;
+ break;
+ default:
+ assert(0);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, openGlWrapMode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, openGlWrapMode);
@@ -166,15 +166,17 @@ void setGlFeature(GLint feature, bool state) {
void OpenGLRenderer::setRenderState(RenderState state, int value) {
switch (state) {
- case RenderState::ZENABLE: {
- glDepthFunc(GL_LEQUAL);
- setGlFeature(GL_DEPTH_TEST, value);
- break;
- }
- case RenderState::ALPHAREF: { // ALPHA-func is never changed.
- glAlphaFunc(GL_ALWAYS, value);
- }
- case RenderState::ALPHABLEND: setGlFeature(GL_BLEND, value); break; // TODO
+ case RenderState::ZENABLE: {
+ glDepthFunc(GL_LEQUAL);
+ setGlFeature(GL_DEPTH_TEST, value);
+ break;
+ }
+ case RenderState::ALPHAREF: { // ALPHA-func is never changed.
+ glAlphaFunc(GL_ALWAYS, value);
+ }
+ case RenderState::ALPHABLEND:
+ setGlFeature(GL_BLEND, value);
+ break; // TODO
}
//warning("TODO: Implement setRenderState");
@@ -182,16 +184,24 @@ void OpenGLRenderer::setRenderState(RenderState state, int value) {
GLenum translateBlendFactorToGL(BlendFactor factor) {
switch (factor) {
- case BlendFactor::ONE: return GL_ONE;
- case BlendFactor::ZERO: return GL_ZERO;
- case BlendFactor::SRCALPHA: return GL_SRC_ALPHA;
- case BlendFactor::INVSRCALPHA: return GL_ONE_MINUS_SRC_ALPHA;
- case BlendFactor::INVSRCCOLOR: return GL_ONE_MINUS_SRC_COLOR;
- case BlendFactor::SRCCOLOR: return GL_SRC_COLOR;
- case BlendFactor::DESTCOLOR: return GL_DST_COLOR;
- case BlendFactor::INVDESTCOLOR: return GL_ONE_MINUS_DST_COLOR;
- default:
- assert(false);
+ case BlendFactor::ONE:
+ return GL_ONE;
+ case BlendFactor::ZERO:
+ return GL_ZERO;
+ case BlendFactor::SRCALPHA:
+ return GL_SRC_ALPHA;
+ case BlendFactor::INVSRCALPHA:
+ return GL_ONE_MINUS_SRC_ALPHA;
+ case BlendFactor::INVSRCCOLOR:
+ return GL_ONE_MINUS_SRC_COLOR;
+ case BlendFactor::SRCCOLOR:
+ return GL_SRC_COLOR;
+ case BlendFactor::DESTCOLOR:
+ return GL_DST_COLOR;
+ case BlendFactor::INVDESTCOLOR:
+ return GL_ONE_MINUS_DST_COLOR;
+ default:
+ assert(false);
}
}
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index 921a0a3e446..5c7075348ab 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -61,8 +61,8 @@ void t3dLoadMaterials(WGame &game, t3dBODY *b, Common::SeekableReadStream &strea
#ifndef WMGEN
len = strlen(Name);
if (((Name[len - 1] == 'i') || (Name[len - 1] == 'I')) &&
- ((Name[len - 2] == 'v') || (Name[len - 2] == 'V')) &&
- ((Name[len - 3] == 'a') || (Name[len - 3] == 'A'))) {
+ ((Name[len - 2] == 'v') || (Name[len - 2] == 'V')) &&
+ ((Name[len - 3] == 'a') || (Name[len - 3] == 'A'))) {
strcpy(Appo, workdirs._moviesDir.c_str()); // altrimenti prende quello di default
} else {
strcpy(Appo, workdirs._mapsDir.c_str()); // altrimenti prende quello di default
@@ -368,10 +368,10 @@ void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
if (f.n == b->NList[i]) {
// f->mat->Texture=f->mat->Lightmap;
if ((!(f.hasMaterialFlag(T3D_MATERIAL_OPACITY))) &&
- (!(f.hasMaterialFlag(T3D_MATERIAL_CLIPMAP))) &&
- (!(f.hasMaterialFlag(T3D_MATERIAL_BOTTLE))) &&
- (!(f.hasMaterialFlag(T3D_MATERIAL_ADDITIVE))) &&
- (!(f.hasMaterialFlag(T3D_MATERIAL_GLASS)))) {
+ (!(f.hasMaterialFlag(T3D_MATERIAL_CLIPMAP))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_BOTTLE))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_ADDITIVE))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_GLASS)))) {
alphaval1 = RGBA_GETALPHA(gv[f.VertexIndex[0]].diffuse);
alphaval2 = RGBA_GETALPHA(gv[f.VertexIndex[1]].diffuse);
alphaval3 = RGBA_GETALPHA(gv[f.VertexIndex[2]].diffuse);
@@ -381,10 +381,10 @@ void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
f.lightmap = b->LightmapTable[Map];
f.getMaterial()->addNumFacesAdditionalMaterial(f.lightmap, 1);
} else if (((f.hasMaterialFlag(T3D_MATERIAL_OPACITY))) ||
- ((f.hasMaterialFlag(T3D_MATERIAL_CLIPMAP))) ||
- ((f.hasMaterialFlag(T3D_MATERIAL_BOTTLE))) ||
- ((f.hasMaterialFlag(T3D_MATERIAL_ADDITIVE))) ||
- ((f.hasMaterialFlag(T3D_MATERIAL_GLASS)))) {
+ ((f.hasMaterialFlag(T3D_MATERIAL_CLIPMAP))) ||
+ ((f.hasMaterialFlag(T3D_MATERIAL_BOTTLE))) ||
+ ((f.hasMaterialFlag(T3D_MATERIAL_ADDITIVE))) ||
+ ((f.hasMaterialFlag(T3D_MATERIAL_GLASS)))) {
f.lightmap = nullptr;
}
@@ -424,10 +424,10 @@ void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
f.lightmap = nullptr;
// if (Map==-1)
if ((!(f.hasMaterialFlag(T3D_MATERIAL_OPACITY))) &&
- (!(f.hasMaterialFlag(T3D_MATERIAL_CLIPMAP))) &&
- (!(f.hasMaterialFlag(T3D_MATERIAL_BOTTLE))) &&
- (!(f.hasMaterialFlag(T3D_MATERIAL_ADDITIVE))) &&
- (!(f.hasMaterialFlag(T3D_MATERIAL_GLASS)))) {
+ (!(f.hasMaterialFlag(T3D_MATERIAL_CLIPMAP))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_BOTTLE))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_ADDITIVE))) &&
+ (!(f.hasMaterialFlag(T3D_MATERIAL_GLASS)))) {
alphaval1 = RGBA_GETALPHA(gv[f.VertexIndex[0]].diffuse);
alphaval2 = RGBA_GETALPHA(gv[f.VertexIndex[1]].diffuse);
alphaval3 = RGBA_GETALPHA(gv[f.VertexIndex[2]].diffuse);
@@ -453,8 +453,8 @@ void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
t3dF32 v = stream->readFloatLE();
if ((RGBA_GETRED(gv[j].diffuse) == 254) &&
- (RGBA_GETGREEN(gv[j].diffuse) == 254) &&
- (RGBA_GETBLUE(gv[j].diffuse) == 254)) {
+ (RGBA_GETGREEN(gv[j].diffuse) == 254) &&
+ (RGBA_GETBLUE(gv[j].diffuse) == 254)) {
gv[j].u2 = u;
gv[j].v2 = v;
gv[j].diffuse = RGBA_MAKE(255, 255, 255, RGBA_GETALPHA(gv[j].diffuse));
@@ -505,7 +505,7 @@ t3dBODY *t3dBODY::loadFromStream(WGame &game, const Common::String &pname, Commo
//-------------------LOADING MESHES--------------------------------------
t3dMESH *ReceiveRipples = nullptr;
uint8 Mirror = 0;
- t3dLoadMeshes(this,numMeshes, ReceiveRipples, Mirror, stream); // TODO: We probably don't need to pass ReceiveRipples, Mirror
+ t3dLoadMeshes(this, numMeshes, ReceiveRipples, Mirror, stream); // TODO: We probably don't need to pass ReceiveRipples, Mirror
//-------------------END OF LOADING MESHES-------------------------------
this->initNormals(stream);
@@ -561,7 +561,7 @@ t3dBODY *t3dBODY::loadFromStream(WGame &game, const Common::String &pname, Commo
if (!(LoaderFlags & T3D_NOLIGHTMAPS)) { // Carica le Lightmaps
// TODO: This looks odd
if (!pname.equalsIgnoreCase("rxt.t3d") || !pname.equalsIgnoreCase("rxt-b.t3d") || !pname.equalsIgnoreCase("rxt-c.t3d") ||
- !pname.equalsIgnoreCase("rxt-d.t3d") || !pname.equalsIgnoreCase("rxt-e.t3d") || !pname.equalsIgnoreCase("rxt.t3d-f"))
+ !pname.equalsIgnoreCase("rxt-d.t3d") || !pname.equalsIgnoreCase("rxt-e.t3d") || !pname.equalsIgnoreCase("rxt.t3d-f"))
LoadLightmaps(workdirs, this);
}
if ((LoaderFlags & T3D_OUTDOORLIGHTS)) { // Carica le luci per l'esterno
diff --git a/engines/watchmaker/3d/t3d_body.h b/engines/watchmaker/3d/t3d_body.h
index 41f72aca395..d606c571878 100644
--- a/engines/watchmaker/3d/t3d_body.h
+++ b/engines/watchmaker/3d/t3d_body.h
@@ -30,26 +30,40 @@
namespace Watchmaker {
struct t3dBODY {
- Common::String name; // room name
- uint32 NumMeshes() { return MeshTable.size(); }; // num meshes
- uint32 NumCameras() const { return CameraTable.size(); } // num cameras
- uint16 NumPaths() const { return CameraPath.size(); } // num camera paths
- uint32 NumLights() const { return LightTable.size(); } // num lights
+ Common::String name; // room name
+ uint32 NumMeshes() {
+ return MeshTable.size();
+ }; // num meshes
+ uint32 NumCameras() const {
+ return CameraTable.size(); // num cameras
+ }
+ uint16 NumPaths() const {
+ return CameraPath.size(); // num camera paths
+ }
+ uint32 NumLights() const {
+ return LightTable.size(); // num lights
+ }
uint16 NumPanels[T3D_MAX_LEVELS] = {}; // num panels per level
uint16 NumNormals = 0; // num face normals
uint16 NumVerticesNormals = 0; // num vertex normals
- uint16 NumPosLights() const { return PosLightTable.size(); }; // num positional lights
+ uint16 NumPosLights() const {
+ return PosLightTable.size();
+ }; // num positional lights
uint16 NumLevels = 0; // num panel levels
uint16 CurLevel = 0; // current level
uint32 NumTotVerts = 0; // total number of verts in room
t3dV3F AmbientLight; // room ambient color
- Common::Array<t3dMESH> MeshTable; // meshes list
- MaterialTable MatTable; // materials list
- uint32 NumMaterials() const { return MatTable.size(); } // num materials
- MaterialTable LightmapTable; // lightmap material list
+ Common::Array<t3dMESH> MeshTable; // meshes list
+ MaterialTable MatTable; // materials list
+ uint32 NumMaterials() const {
+ return MatTable.size(); // num materials
+ }
+ MaterialTable LightmapTable; // lightmap material list
uint32 NumLightmaps = 0; // num lightmap materials
- MaterialTable MirrorMatTable; // material list (for mirrors)
- uint32 NumMirrorMaterials() const { return MirrorMatTable.size(); }; // num materials (for mirror)
+ MaterialTable MirrorMatTable; // material list (for mirrors)
+ uint32 NumMirrorMaterials() const {
+ return MirrorMatTable.size();
+ }; // num materials (for mirror)
private:
Common::Array<Common::SharedPtr<VertexBuffer>> VBTable; // metrial vertex buffers list
public:
@@ -63,19 +77,21 @@ public:
}
VBTable.clear();
}
- uint32 NumVB() { return VBTable.size(); }; // num vertex buffer
+ uint32 NumVB() {
+ return VBTable.size();
+ }; // num vertex buffer
public:
Common::Array<t3dCAMERA> CameraTable; // camera list
Common::Array<t3dLIGHT> LightTable; // light list
Common::Array<t3dPLIGHT> PosLightTable; // positional light list
- NormalList NList; // normal list
+ NormalList NList; // normal list
t3dCAMERAGRID CameraGrid; // camera grid
Common::Array<t3dCAMERAPATH> CameraPath; // camer paths list
- t3dPAN *Panel[T3D_MAX_LEVELS] = {}; // room panels for level
- t3dF32 PanelHeight[T3D_MAX_LEVELS] = {}; // panel height for levels
+ t3dPAN *Panel[T3D_MAX_LEVELS] = {}; // room panels for level
+ t3dF32 PanelHeight[T3D_MAX_LEVELS] = {}; // panel height for levels
Common::SharedPtr<t3dVolLights> VolumetricLights; // volumetric lights
- t3dMESH *BlockMeshes[T3D_MAX_BLOCK_MESHES] = {}; // block mesh (for external rooms)
- t3dV3F MinPos; // min room position
+ t3dMESH *BlockMeshes[T3D_MAX_BLOCK_MESHES] = {}; // block mesh (for external rooms)
+ t3dV3F MinPos; // min room position
private:
void allocateNormals();
void initNormals(Common::SeekableReadStream &stream);
diff --git a/engines/watchmaker/3d/t3d_face.cpp b/engines/watchmaker/3d/t3d_face.cpp
index 7a6e0f37909..9154f27e28d 100644
--- a/engines/watchmaker/3d/t3d_face.cpp
+++ b/engines/watchmaker/3d/t3d_face.cpp
@@ -54,7 +54,7 @@ MaterialPtr t3dFACE::getMaterial() {
}
}
-const gMaterial* t3dFACE::getMaterial() const {
+const gMaterial *t3dFACE::getMaterial() const {
if (_mat) {
return _mat.get();
} else {
diff --git a/engines/watchmaker/3d/t3d_face.h b/engines/watchmaker/3d/t3d_face.h
index 9e1b37a05cd..50ff417af8b 100644
--- a/engines/watchmaker/3d/t3d_face.h
+++ b/engines/watchmaker/3d/t3d_face.h
@@ -50,9 +50,11 @@ public:
t3dFACE(t3dBODY *b, Common::SeekableReadStream &stream);
- bool hasMaterialFlag(uint32 flag) { return getMaterial()->hasFlag(flag); }
+ bool hasMaterialFlag(uint32 flag) {
+ return getMaterial()->hasFlag(flag);
+ }
MaterialPtr getMaterial();
- const gMaterial* getMaterial() const;
+ const gMaterial *getMaterial() const;
uint16 getMaterialIndex() const {
return _materialIndex;
}
diff --git a/engines/watchmaker/3d/t3d_mesh.cpp b/engines/watchmaker/3d/t3d_mesh.cpp
index b9d30907984..9542f09b721 100644
--- a/engines/watchmaker/3d/t3d_mesh.cpp
+++ b/engines/watchmaker/3d/t3d_mesh.cpp
@@ -79,7 +79,7 @@ t3dMESH::t3dMESH(t3dBODY *b, Common::SeekableReadStream &stream, t3dMESH *&Recei
// if( this->Flags&T3D_MESH_PORTAL)
// this->Flags|=T3D_MESH_PORTAL;
if ((this->Flags & T3D_MESH_RECEIVERIPPLES) || // Aggiunge buffer per le onde
- (this->Flags & T3D_MESH_POOLWATER))
+ (this->Flags & T3D_MESH_POOLWATER))
ReceiveRipples = this;
if (this->Flags & T3D_MESH_WAVESTEXTURE) { // Legge informazioni sulle onde
this->WavesSpeed = (t3dF32)stream.readSint32LE() / 10000.0f;
@@ -155,9 +155,9 @@ t3dMESH::t3dMESH(t3dBODY *b, Common::SeekableReadStream &stream, t3dMESH *&Recei
this->BBox[normal].p = t3dV3F(stream) * SCALEFACTOR;
}//__for_normal
if ((this->BBox[0].p == this->BBox[4].p) && // Se non ha spessore
- (this->BBox[1].p == this->BBox[5].p) &&
- (this->BBox[2].p == this->BBox[6].p) &&
- (this->BBox[3].p == this->BBox[7].p)) {
+ (this->BBox[1].p == this->BBox[5].p) &&
+ (this->BBox[2].p == this->BBox[6].p) &&
+ (this->BBox[3].p == this->BBox[7].p)) {
t3dV3F sub;
sub.x = sub.y = sub.z = 5.0f;
t3dVectSub(&this->BBox[0].p, &this->BBox[0].p, &sub); // Aggiunge 5 di spessore
diff --git a/engines/watchmaker/3d/t3d_mesh.h b/engines/watchmaker/3d/t3d_mesh.h
index 4c79f99fc03..e48634e6b81 100644
--- a/engines/watchmaker/3d/t3d_mesh.h
+++ b/engines/watchmaker/3d/t3d_mesh.h
@@ -30,7 +30,9 @@ namespace Watchmaker {
struct t3dMESH {
Common::String name; // mesh name
Common::String portalName; // dest room name (if portal)
- uint16 NumFaces() { return FList.size(); }; // faces number
+ uint16 NumFaces() {
+ return FList.size();
+ }; // faces number
uint16 NumVerts = 0; // verts number
uint16 NumNormals = 0; // face normals number
uint16 NumVerticesNormals = 0; // verts normals number
@@ -69,7 +71,7 @@ struct t3dMESH {
uint32 Flags; // Flags
t3dBODY *PortalList; // Pointer to portal connected
- Common::Array<t3dMESH*> RejectedMeshes; // rejected mesh from portal
+ Common::Array<t3dMESH *> RejectedMeshes; // rejected mesh from portal
void saveVertexBuffer() { // Scorre le mesh
this->VBptr = this->VertexBuffer;
@@ -98,9 +100,9 @@ struct t3dMESH {
alphaval = 0xfe;
Face.flags |= T3D_MATERIAL_CLIPMAP; // lo setta sulla faccia
/* Face->flags&=~T3D_MATERIAL_OPACITY;
- Face->flags&=~T3D_MATERIAL_GLASS;
- Material->Flags&=~T3D_MATERIAL_OPACITY;
- Material->Flags&=~T3D_MATERIAL_GLASS;*/
+ Face->flags&=~T3D_MATERIAL_GLASS;
+ Material->Flags&=~T3D_MATERIAL_OPACITY;
+ Material->Flags&=~T3D_MATERIAL_GLASS;*/
// r=g=b=0;
}
if (Material->hasFlag(T3D_MATERIAL_OPACITY)) { // Se il materiale e' opacity
diff --git a/engines/watchmaker/3d/texture.h b/engines/watchmaker/3d/texture.h
index 702d3a9e249..95f98a13505 100644
--- a/engines/watchmaker/3d/texture.h
+++ b/engines/watchmaker/3d/texture.h
@@ -35,8 +35,8 @@ namespace Watchmaker {
class WGame;
// Texture structs
struct gTexture {
- Common::String name;
- Texture *texture = nullptr;
+ Common::String name;
+ Texture *texture = nullptr;
int RealDimX = 0; // original dimensions
int RealDimY = 0; // original dimensions
int DimX = 0; // current dimensions
diff --git a/engines/watchmaker/3d/types3d.h b/engines/watchmaker/3d/types3d.h
index cdfa3c5407c..416080139d1 100644
--- a/engines/watchmaker/3d/types3d.h
+++ b/engines/watchmaker/3d/types3d.h
@@ -59,32 +59,32 @@ public:
t3dV3F operator+(const t3dV3F &rhs) const {
return t3dV3F(
x + rhs.x,
- y + rhs.y,
- z + rhs.z
- );
+ y + rhs.y,
+ z + rhs.z
+ );
}
t3dV3F operator-(const t3dV3F &rhs) const {
return t3dV3F(
- x + rhs.x,
- y + rhs.y,
- z + rhs.z
+ x + rhs.x,
+ y + rhs.y,
+ z + rhs.z
);
}
t3dV3F operator-() const {
return t3dV3F(
- -x,
- -y,
- -z
+ -x,
+ -y,
+ -z
);
}
t3dV3F operator*(float scalar) const {
return t3dV3F(
- x * scalar,
- y * scalar,
- z * scalar
+ x * scalar,
+ y * scalar,
+ z * scalar
);
}
- t3dV3F& operator*=(float scalar) {
+ t3dV3F &operator*=(float scalar) {
this->x *= scalar;
this->y *= scalar;
this->z *= scalar;
diff --git a/engines/watchmaker/classes/do_camera.cpp b/engines/watchmaker/classes/do_camera.cpp
index 933cc45ce79..f0f6870ec10 100644
--- a/engines/watchmaker/classes/do_camera.cpp
+++ b/engines/watchmaker/classes/do_camera.cpp
@@ -652,8 +652,8 @@ void ProcessCamera(WGame &game) {
// Parte Morte Victoria se esce dalla r49 per andare nella r48 prima di aver attivato le leylines
if (
- (game._gameVars.getCurRoomId() == r48) && (foxOldRoom == r49)
- && (!(init.Dialog[dR491].flags & DIALOG_DONE))
+ (game._gameVars.getCurRoomId() == r48) && (foxOldRoom == r49)
+ && (!(init.Dialog[dR491].flags & DIALOG_DONE))
&& (!(LoaderFlags & T3D_DEBUGMODE))
&& (!bDialogActive)
) {
diff --git a/engines/watchmaker/classes/do_keyboard.cpp b/engines/watchmaker/classes/do_keyboard.cpp
index 2730eeed293..a0e3423ce48 100644
--- a/engines/watchmaker/classes/do_keyboard.cpp
+++ b/engines/watchmaker/classes/do_keyboard.cpp
@@ -46,20 +46,19 @@
namespace Watchmaker {
-t3dF32 AngleX,AngleY,AngleSpeed;
+t3dF32 AngleX, AngleY, AngleSpeed;
char bFastAnim = 0;
-int32 PlayAnim=351;
-char bBilinear=1;
-char bForceDebug=0;
+int32 PlayAnim = 351;
+char bBilinear = 1;
+char bForceDebug = 0;
unsigned char KeyTable[256];
uint16 bnd_lev;
-extern int16 NextDlg; //from doDialog.c
-extern uint8 tasti_per_sfx1; //from main.c
+extern int16 NextDlg; //from doDialog.c
+extern uint8 tasti_per_sfx1; //from main.c
-void ProcessKBInput()
-{
+void ProcessKBInput() {
// TODO: Currently we're polling this in the PollEvent flow.
return;
#if 0
@@ -70,11 +69,10 @@ void ProcessKBInput()
KeyTable[i] = keyState[i];
}
- for (int i=0; i<numKeys; i++ )
- {
- if( keyState[i] )
+ for (int i = 0; i < numKeys; i++) {
+ if (keyState[i])
KeyTable[i] = 0x80;
- else if( ( KeyTable[i] != 0 ) && ( !keyState[i] ) )
+ else if ((KeyTable[i] != 0) && (!keyState[i]))
KeyTable[i] = 0x10;
else
KeyTable[i] = 0x00;
@@ -82,37 +80,31 @@ void ProcessKBInput()
#endif
}
-bool KeyDown(unsigned char key)
-{
- if(KeyTable[(key)] & 0x80)
+bool KeyDown(unsigned char key) {
+ if (KeyTable[(key)] & 0x80)
return TRUE;
else
return FALSE;
}
-bool KeyUp(unsigned char key)
-{
- if(KeyTable[(key)] & 0x10)
- {
- KeyTable[(key)]=0;
+bool KeyUp(unsigned char key) {
+ if (KeyTable[(key)] & 0x10) {
+ KeyTable[(key)] = 0;
return TRUE;
- }
- else
+ } else
return FALSE;
}
-void KeyClear(unsigned char key)
-{
- KeyTable[(key)]=0;
+void KeyClear(unsigned char key) {
+ KeyTable[(key)] = 0;
}
-bool DInputExclusiveMouse()
-{
+bool DInputExclusiveMouse() {
#if 0
- HWND hwnd=GetForegroundWindow();
+ HWND hwnd = GetForegroundWindow();
g_pMouse->lpVtbl->Unacquire(g_pMouse);
- if( FAILED( g_pMouse->lpVtbl->SetCooperativeLevel( g_pMouse, hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND) ) )
+ if (FAILED(g_pMouse->lpVtbl->SetCooperativeLevel(g_pMouse, hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND)))
return FALSE;
g_pMouse->lpVtbl->Acquire(g_pMouse);
#endif
@@ -121,13 +113,12 @@ bool DInputExclusiveMouse()
return TRUE;
}
-bool DInputNonExclusiveMouse()
-{
+bool DInputNonExclusiveMouse() {
#if 0
- HWND hwnd=GetForegroundWindow();
+ HWND hwnd = GetForegroundWindow();
g_pMouse->lpVtbl->Unacquire(g_pMouse);
- if( FAILED( g_pMouse->lpVtbl->SetCooperativeLevel( g_pMouse, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) ) )
+ if (FAILED(g_pMouse->lpVtbl->SetCooperativeLevel(g_pMouse, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND)))
return FALSE;
g_pMouse->lpVtbl->Acquire(g_pMouse);
#endif
@@ -137,106 +128,99 @@ bool DInputNonExclusiveMouse()
}
/* -----------------25/08/98 10.42-------------------
- * HandleFirstPerson
+ * HandleFirstPerson
* --------------------------------------------------*/
-void HandleFirstPersonView( void )
-{
+void HandleFirstPersonView(void) {
t3dF32 dist;
- t3dV3F d,n;
+ t3dV3F d, n;
- if( ( !Player ) || ( !t3dCurCamera ) || ( bLockCamera ) ) return;
+ if ((!Player) || (!t3dCurCamera) || (bLockCamera)) return;
- if( KeyDown(Common::KEYCODE_a) ) // Alza testa
- {
- if( ( dist = CurFloorY+MAX_HEIGHT - ( t3dCurCamera->Source.y + 10*SCALEFACTOR ) ) > 0 )
- {
- if( dist > 10*SCALEFACTOR ) dist = 10*SCALEFACTOR;
- t3dVectInit( &d, 0.0f, dist, 0.0f );
- t3dMoveAndCheck1stCamera( t3dCurRoom, t3dCurCamera, &d );
+ if (KeyDown(Common::KEYCODE_a)) { // Alza testa
+ if ((dist = CurFloorY + MAX_HEIGHT - (t3dCurCamera->Source.y + 10 * SCALEFACTOR)) > 0) {
+ if (dist > 10 * SCALEFACTOR) dist = 10 * SCALEFACTOR;
+ t3dVectInit(&d, 0.0f, dist, 0.0f);
+ t3dMoveAndCheck1stCamera(t3dCurRoom, t3dCurCamera, &d);
}
- }
- else if( KeyDown(Common::KEYCODE_z) ) // Abbassa Testa
- {
- if( ( dist = CurFloorY+KNEE_HEIGHT - ( t3dCurCamera->Source.y - 10*SCALEFACTOR ) ) < 0 )
- {
- if( dist < -10*SCALEFACTOR ) dist = -10*SCALEFACTOR;
- t3dVectInit( &d, 0.0f, dist, 0.0f );
- t3dMoveAndCheck1stCamera( t3dCurRoom, t3dCurCamera, &d );
+ } else if (KeyDown(Common::KEYCODE_z)) { // Abbassa Testa
+ if ((dist = CurFloorY + KNEE_HEIGHT - (t3dCurCamera->Source.y - 10 * SCALEFACTOR)) < 0) {
+ if (dist < -10 * SCALEFACTOR) dist = -10 * SCALEFACTOR;
+ t3dVectInit(&d, 0.0f, dist, 0.0f);
+ t3dMoveAndCheck1stCamera(t3dCurRoom, t3dCurCamera, &d);
}
}
// Se tengo premuto lo shift o un tasto del mouse
- if( KeyDown(Common::KEYCODE_LSHIFT) || KeyDown(Common::KEYCODE_RSHIFT) || ( ( bLPressed || bRPressed ) && (mMove>10) ) )
- {
- t3dVectSub( &d, &t3dCurCamera->Target, &t3dCurCamera->Source );d.y = 0.0f;
- t3dVectNormalize( &d );
- n.x = -d.z;n.y = 0.0f;n.z = d.x;
-
- dist = (t3dF32)( (t3dF32)mMoveY / (t3dF32)( MainDy/2 ) )*100.0f;
- if( KeyDown(Common::KEYCODE_UP) )
- d *= (5*SCALEFACTOR );
- else if( KeyDown(Common::KEYCODE_DOWN) )
- d *= (-5*SCALEFACTOR );
- else if( ( (bLPressed) || (bRPressed) ) && (mMoveY) && !bClock33 )
- d *= (-dist*SCALEFACTOR );
+ if (KeyDown(Common::KEYCODE_LSHIFT) || KeyDown(Common::KEYCODE_RSHIFT) || ((bLPressed || bRPressed) && (mMove > 10))) {
+ t3dVectSub(&d, &t3dCurCamera->Target, &t3dCurCamera->Source);
+ d.y = 0.0f;
+ t3dVectNormalize(&d);
+ n.x = -d.z;
+ n.y = 0.0f;
+ n.z = d.x;
+
+ dist = (t3dF32)((t3dF32)mMoveY / (t3dF32)(MainDy / 2)) * 100.0f;
+ if (KeyDown(Common::KEYCODE_UP))
+ d *= (5 * SCALEFACTOR);
+ else if (KeyDown(Common::KEYCODE_DOWN))
+ d *= (-5 * SCALEFACTOR);
+ else if (((bLPressed) || (bRPressed)) && (mMoveY) && !bClock33)
+ d *= (-dist * SCALEFACTOR);
else
- t3dVectFill( &d, 0.0f );
-
- dist = (t3dF32)( (t3dF32)mMoveX / (t3dF32)( MainDx/2 ) )*100.0f;
- if( KeyDown(Common::KEYCODE_LEFT) )
- n *= (5*SCALEFACTOR );
- else if( KeyDown(Common::KEYCODE_RIGHT) )
- n *= (-5*SCALEFACTOR );
- else if( ( (bLPressed) || (bRPressed) ) && (mMoveX) && !bClock33 )
- n *= (-dist*SCALEFACTOR );
+ t3dVectFill(&d, 0.0f);
+
+ dist = (t3dF32)((t3dF32)mMoveX / (t3dF32)(MainDx / 2)) * 100.0f;
+ if (KeyDown(Common::KEYCODE_LEFT))
+ n *= (5 * SCALEFACTOR);
+ else if (KeyDown(Common::KEYCODE_RIGHT))
+ n *= (-5 * SCALEFACTOR);
+ else if (((bLPressed) || (bRPressed)) && (mMoveX) && !bClock33)
+ n *= (-dist * SCALEFACTOR);
else
- t3dVectFill( &n, 0.0f );
+ t3dVectFill(&n, 0.0f);
- t3dVectAdd( &d, &d, &n );
- t3dMoveAndCheck1stCamera( t3dCurRoom, t3dCurCamera, &d );
- }
- else
- {
- int32 x,y;
+ t3dVectAdd(&d, &d, &n);
+ t3dMoveAndCheck1stCamera(t3dCurRoom, t3dCurCamera, &d);
+ } else {
+ int32 x, y;
x = 0;
y = 0;
- if( KeyDown(Common::KEYCODE_UP) )
+ if (KeyDown(Common::KEYCODE_UP))
y = -10;
- else if( KeyDown(Common::KEYCODE_DOWN) )
- y = MainDy+10;
- if( KeyDown(Common::KEYCODE_LEFT) )
+ else if (KeyDown(Common::KEYCODE_DOWN))
+ y = MainDy + 10;
+ if (KeyDown(Common::KEYCODE_LEFT))
x = -10;
- else if( KeyDown(Common::KEYCODE_RIGHT) )
- x = MainDx+10;
+ else if (KeyDown(Common::KEYCODE_RIGHT))
+ x = MainDx + 10;
- if( x || y )
- {
- t3dF32 diffx,diffy;
+ if (x || y) {
+ t3dF32 diffx, diffy;
diffx = 0.f;
diffy = 0.f;
- if( x > MainDx ) diffx = (t3dF32)((t3dF32)( x-MainDx )/3.0f);
- else if( x < 0 ) diffx = (t3dF32)((t3dF32)x / 3.0f );
- if( y > MainDy ) diffy = (t3dF32)((t3dF32)( y-MainDy )/3.0f );
- else if( y < 0 ) diffy = (t3dF32)((t3dF32)y / 3.0f );
+ if (x > MainDx) diffx = (t3dF32)((t3dF32)(x - MainDx) / 3.0f);
+ else if (x < 0) diffx = (t3dF32)((t3dF32)x / 3.0f);
+ if (y > MainDy) diffy = (t3dF32)((t3dF32)(y - MainDy) / 3.0f);
+ else if (y < 0) diffy = (t3dF32)((t3dF32)y / 3.0f);
- MoveHeadAngles(diffx,diffy);
+ MoveHeadAngles(diffx, diffy);
}
}
// Corregge Camera
- t3dVectCopy( &d, &Player->Mesh->Trasl );
+ t3dVectCopy(&d, &Player->Mesh->Trasl);
d.y = t3dCurCamera->Source.y;
- dist = KNEE_HEIGHT - t3dVectDistance( &t3dCurCamera->Source, &d );
- if( dist < 0.0f )
- {
- t3dVectSub( &d, &t3dCurCamera->Source, &d );d.y = 0.0f;
- t3dVectNormalize( &d );
+ dist = KNEE_HEIGHT - t3dVectDistance(&t3dCurCamera->Source, &d);
+ if (dist < 0.0f) {
+ t3dVectSub(&d, &t3dCurCamera->Source, &d);
+ d.y = 0.0f;
+ t3dVectNormalize(&d);
d *= dist;
- t3dVectAdd( &t3dCurCamera->Source, &t3dCurCamera->Source, &d );
- t3dVectAdd( &t3dCurCamera->Target, &t3dCurCamera->Target, &d );
+ t3dVectAdd(&t3dCurCamera->Source, &t3dCurCamera->Source, &d);
+ t3dVectAdd(&t3dCurCamera->Target, &t3dCurCamera->Target, &d);
}
}
diff --git a/engines/watchmaker/classes/do_mouse.cpp b/engines/watchmaker/classes/do_mouse.cpp
index d6c909d698e..2450ed43756 100644
--- a/engines/watchmaker/classes/do_mouse.cpp
+++ b/engines/watchmaker/classes/do_mouse.cpp
@@ -186,7 +186,7 @@ void doMouseButton(WGame &game) {
CurObj = WhatObj(game, TheMessage->wparam1, TheMessage->wparam2, TheMessage->event);
// Se sono su albero e clicco fuori dal nido, simulo un cambio portale
if (bPlayerSuBasamento &&
- (CurObj != oXT14ALBERO) && (CurObj != oXT14BASAMENTO) && (CurObj != oXT14NIDO_da_sopra_il_basamento) && (CurObj != oXT14OCCHIALI)) {
+ (CurObj != oXT14ALBERO) && (CurObj != oXT14BASAMENTO) && (CurObj != oXT14NIDO_da_sopra_il_basamento) && (CurObj != oXT14OCCHIALI)) {
NextPortalObj = CurObj;
NextPortalAnim = a145;
}
@@ -283,7 +283,7 @@ void doMouseUpdate(WGame &game) {
if ((bLPressed) && (InvStatus & INV_MODE2)) {
t3dM3X3F t;
t3dMatRot(&t, ((t3dF32)(TheMessage->lparam[1]) / (t3dF32)(BigIconRect.y2 - BigIconRect.y1))*T3D_PI * 2.0f,
- ((t3dF32)(TheMessage->lparam[0]) / (t3dF32)(BigIconRect.x1 - BigIconRect.x2))*T3D_PI * 2.0f, 0.0f);
+ ((t3dF32)(TheMessage->lparam[0]) / (t3dF32)(BigIconRect.x1 - BigIconRect.x2))*T3D_PI * 2.0f, 0.0f);
t3dMatMul(&BigIconM, &t, &BigIconM);
CurInvObj = BigInvObj;
} else {
diff --git a/engines/watchmaker/classes/do_sound.cpp b/engines/watchmaker/classes/do_sound.cpp
index 933db240e0b..9b8d2e8c693 100644
--- a/engines/watchmaker/classes/do_sound.cpp
+++ b/engines/watchmaker/classes/do_sound.cpp
@@ -363,9 +363,8 @@ bool PlayMusic(int32 index, uint32 FadeOutTime, uint32 FadeInTime) {
return TRUE;
}
-bool StopSounds()
-{
- if( !sStopAllSounds() ) return false;
+bool StopSounds() {
+ if (!sStopAllSounds()) return false;
return true;
}
diff --git a/engines/watchmaker/file_utils.cpp b/engines/watchmaker/file_utils.cpp
index 8a24cf53cfd..46794b60d16 100644
--- a/engines/watchmaker/file_utils.cpp
+++ b/engines/watchmaker/file_utils.cpp
@@ -22,7 +22,7 @@
#include "watchmaker/file_utils.h"
#include "watchmaker/t3d.h"
-Common::String readT3dString(Common::SeekableReadStream& stream) {
+Common::String readT3dString(Common::SeekableReadStream &stream) {
char strbuf[T3D_NAMELEN + 1] = {};
for (int i = 0; i < T3D_NAMELEN; i++) {
strbuf[i] = stream.readByte();
diff --git a/engines/watchmaker/file_utils.h b/engines/watchmaker/file_utils.h
index 8cd13a88f10..3019946f3da 100644
--- a/engines/watchmaker/file_utils.h
+++ b/engines/watchmaker/file_utils.h
@@ -24,7 +24,7 @@
#include "common/stream.h"
-Common::String readT3dString(Common::SeekableReadStream& stream);
+Common::String readT3dString(Common::SeekableReadStream &stream);
// TODO: This can probably just be replaced with .hasSuffixIgnoreCase
bool hasFileExtension(const Common::String &str, const Common::String &extension);
bool hasFileExtension(const char *str, Common::String extension);
diff --git a/engines/watchmaker/fonts.cpp b/engines/watchmaker/fonts.cpp
index 1f1757b3b47..bddc0a2aaab 100644
--- a/engines/watchmaker/fonts.cpp
+++ b/engines/watchmaker/fonts.cpp
@@ -31,11 +31,11 @@ Fonts::~Fonts() {
}
}
-uint16* Fonts::setupFontTable(Common::SeekableReadStream &stream) {
+uint16 *Fonts::setupFontTable(Common::SeekableReadStream &stream) {
uint32 dim = stream.size();
- uint16 *tab = new uint16[dim]{};
+ uint16 *tab = new uint16[dim] {};
- for (int i=0; i<dim/sizeof(uint16); i++) {
+ for (int i = 0; i < dim / sizeof(uint16); i++) {
tab[i] = stream.readUint16LE();
}
@@ -98,7 +98,7 @@ void Fonts::getTextDim(char *s, FontKind font, int *x, int *y) {
int i = 0;
int nextx = 0, nexty = 0;
byte c = 0;
- while ( (c=s[i]) != 0) {
+ while ((c = s[i]) != 0) {
i++;
nextx += fontTable->table[c * 4 + 2];
diff --git a/engines/watchmaker/fonts.h b/engines/watchmaker/fonts.h
index 8fe6f1e3f2a..3fd38ee6fe9 100644
--- a/engines/watchmaker/fonts.h
+++ b/engines/watchmaker/fonts.h
@@ -35,13 +35,13 @@ enum class FontKind {
};
struct SFont {
- uint16 *table = nullptr;
- int32 color[MAX_FONT_COLORS] = {};
+ uint16 *table = nullptr;
+ int32 color[MAX_FONT_COLORS] = {};
};
class WGame;
class Fonts {
- Common::Array<uint16*> _tables;
+ Common::Array<uint16 *> _tables;
uint16 *setupFontTable(Common::SeekableReadStream &stream);
void loadFont(WGame &game, struct SFont *f, const Common::String &n);
public:
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index 5543185c35b..a29d50444b6 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -1698,8 +1698,8 @@ void StopObjAnim(WGame &game, int32 obj) {
// Se esiste gia' un'animazione sullo stesso oggetto base, la termina
for (int32 b = 0; b < MAX_ACTIVE_ANIMS; b++)
if ((ActiveAnim[b].index) && (ActiveAnim[b].CurFrame >= 0)/* && !( ActiveAnim[b].flags & ANIM_PAUSED )*/ &&
- ((Common::String((const char*)init.Anim[ActiveAnim[b].index].meshlink[0].rawArray()).equalsIgnoreCase((const char*)init.Obj[obj].meshlink[0])) || (ActiveAnim[b].obj == obj) ||
- ((CurPlayer == obj - ocDARRELL) && (Common::String((const char*)init.Anim[ActiveAnim[b].index].meshlink[0].rawArray()).equalsIgnoreCase((const char*)init.Obj[ocCURPLAYER].meshlink[0]))
+ ((Common::String((const char *)init.Anim[ActiveAnim[b].index].meshlink[0].rawArray()).equalsIgnoreCase((const char *)init.Obj[obj].meshlink[0])) || (ActiveAnim[b].obj == obj) ||
+ ((CurPlayer == obj - ocDARRELL) && (Common::String((const char *)init.Anim[ActiveAnim[b].index].meshlink[0].rawArray()).equalsIgnoreCase((const char *)init.Obj[ocCURPLAYER].meshlink[0]))
&& (ActiveAnim[b].sub[0].ptr) && Player && Player->Mesh && (ActiveAnim[b].sub[0].ptr == Player->Mesh))))
StopAnim(game, ActiveAnim[b].index);
}
diff --git a/engines/watchmaker/ll/ll_mesh.cpp b/engines/watchmaker/ll/ll_mesh.cpp
index 79e6ef8e668..8f3f5f84a8a 100644
--- a/engines/watchmaker/ll/ll_mesh.cpp
+++ b/engines/watchmaker/ll/ll_mesh.cpp
@@ -299,55 +299,48 @@ uint8 t3dVectMeshInters(t3dMESH *m, t3dV3F start, t3dV3F end, t3dV3F *inters) {
/* -----------------19/05/00 12.43-------------------
- * t3dMoveAndCheck1stCamera
+ * t3dMoveAndCheck1stCamera
* --------------------------------------------------*/
-bool t3dMoveAndCheck1stCamera( t3dBODY *rr, t3dCAMERA *cc, t3dV3F *mm )
-{
+bool t3dMoveAndCheck1stCamera(t3dBODY *rr, t3dCAMERA *cc, t3dV3F *mm) {
t3dWALK *w;
t3dV3F tmp;
- int32 i,j;
+ int32 i, j;
- if ( !Character[ocCURPLAYER] ) return FALSE;
- w=&Character[ocCURPLAYER]->Walk;
+ if (!Character[ocCURPLAYER]) return FALSE;
+ w = &Character[ocCURPLAYER]->Walk;
- t3dVectAdd( &tmp, &cc->Source, mm );
+ t3dVectAdd(&tmp, &cc->Source, mm);
// Controlla che non sia dentro un Bounding Box
- for ( i=0; i<(int32)rr->NumMeshes(); i++ )
- {
+ for (i = 0; i < (int32)rr->NumMeshes(); i++) {
t3dMESH &mesh = rr->MeshTable[i];
- if( !( mesh.Flags & T3D_MESH_HIDDEN ) )
- {
+ if (!(mesh.Flags & T3D_MESH_HIDDEN)) {
// Se il punto di destinazione e' dentro il bound box (allargato dell'altezza del ginocchio)
- for ( j=0; j<6; j++ )
- if( t3dVectPlaneDistance( tmp, mesh.BBoxNormal[j] ) < -KNEE_HEIGHT )
+ for (j = 0; j < 6; j++)
+ if (t3dVectPlaneDistance(tmp, mesh.BBoxNormal[j]) < -KNEE_HEIGHT)
break;
- if ( j >= 6 )
- {
+ if (j >= 6) {
// Prima controlla che non sia dentro i bounds
- for ( j=0; j<w->PanelNum; j++ )
- {
- if ( PointInside( ocCURPLAYER, j, (double)tmp.x, (double)tmp.z ) != 0 )
- {
- warning( "Inters %s", mesh.name.c_str() ); // TODO: Debug
+ for (j = 0; j < w->PanelNum; j++) {
+ if (PointInside(ocCURPLAYER, j, (double)tmp.x, (double)tmp.z) != 0) {
+ warning("Inters %s", mesh.name.c_str()); // TODO: Debug
return FALSE;
}
}
- warning( "Saved by bounds" ); // TODO: Debug
+ warning("Saved by bounds"); // TODO: Debug
}
}
}
// evito che si entri nell'altro personaggio giocante
i = (CurPlayer ^ 1);
- if ( Character[i+ocDARRELL] && Character[i+ocDARRELL]->Mesh && t3dCurRoom->name.equalsIgnoreCase(PlayerStand[i].roomName ) ) // Used to be stricmp
- {
- t3dF32 d=t3dVectDistance( &tmp, &Character[i+ocDARRELL]->Mesh->Trasl );
- if( d < 435.f ) return FALSE;
+ if (Character[i + ocDARRELL] && Character[i + ocDARRELL]->Mesh && t3dCurRoom->name.equalsIgnoreCase(PlayerStand[i].roomName)) { // Used to be stricmp
+ t3dF32 d = t3dVectDistance(&tmp, &Character[i + ocDARRELL]->Mesh->Trasl);
+ if (d < 435.f) return FALSE;
}
- t3dVectAdd( &cc->Source, &cc->Source, mm );
- t3dVectAdd( &cc->Target, &cc->Target, mm );
+ t3dVectAdd(&cc->Source, &cc->Source, mm);
+ t3dVectAdd(&cc->Target, &cc->Target, mm);
return TRUE;
}
@@ -726,7 +719,7 @@ void AddMeshModifier(const Common::String &name, int16 com, void *p) {
case MM_ANIM_BLOCK:
if (mm->animName.empty())
- mm->animName = (char*)p;
+ mm->animName = (char *)p;
else
mm->animName.clear();
break;
diff --git a/engines/watchmaker/ll/ll_mesh.h b/engines/watchmaker/ll/ll_mesh.h
index 7f052f01d5b..c943d982471 100644
--- a/engines/watchmaker/ll/ll_mesh.h
+++ b/engines/watchmaker/ll/ll_mesh.h
@@ -46,7 +46,7 @@ void ChangeHaloesStatus(t3dBODY *b, int8 op);
uint8 t3dVectMeshInters(t3dMESH *m, t3dV3F start, t3dV3F end, t3dV3F *inters);
void t3dLightRoom(Init &init, t3dBODY *b, t3dV3F *p, t3dF32 NearRange, t3dF32 FarRange, t3dF32 IperRange);
void t3dUpdateExplosion(t3dMESH *m, t3dF32 scale);
-bool t3dMoveAndCheck1stCamera( t3dBODY *rr, t3dCAMERA *cc, t3dV3F *mm );
+bool t3dMoveAndCheck1stCamera(t3dBODY *rr, t3dCAMERA *cc, t3dV3F *mm);
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/ll/ll_mouse.cpp b/engines/watchmaker/ll/ll_mouse.cpp
index 7b2bc6fe2db..4ca3c25f3a7 100644
--- a/engines/watchmaker/ll/ll_mouse.cpp
+++ b/engines/watchmaker/ll/ll_mouse.cpp
@@ -143,29 +143,28 @@ void ProcessMouse(WGame &game) {
/* -----------------19/10/98 15.18-------------------
* DInputMouseGetCoords
* --------------------------------------------------*/
-void HandleMouseChanges()
-{
+void HandleMouseChanges() {
// Mouse movement will have been accumulated prior to calling this function.
// Button flags may also have been changed, this function then applies the button changes.
int curX, curY;
//warning("L: %d %d R: %d %d", bLPressed, bLPressedPrev, bRPressed, bRPressedPrev);
// Button 0 pressed or released
- if( bLPressed != bLPressedPrev )
- {
+ if (bLPressed != bLPressedPrev) {
// se ha rilasciato e non ha mosso il mouse
- if( ( !bLPressed ) && ( !bSkipped ) && ( ( mMove < 10 ) || ( !( InvStatus & INV_MODE2 ) && !bFirstPerson && !bT2DActive ) ) )
- { Event(EventClass::MC_MOUSE, ME_MLEFT, MP_DEFAULT, (int16)mPosx, (int16)mPosy, bRPressed, NULL, NULL, NULL); bSkipped = FALSE; }
- else if( bLPressed && ( mMove >= 10 ) && ( InvStatus & INV_MODE2 ) && ( bSomeOneSpeak ) )
- { bSkipTalk = TRUE; bSkipped = TRUE; }
- else if( !bLPressed )
+ if ((!bLPressed) && (!bSkipped) && ((mMove < 10) || (!(InvStatus & INV_MODE2) && !bFirstPerson && !bT2DActive))) {
+ Event(EventClass::MC_MOUSE, ME_MLEFT, MP_DEFAULT, (int16)mPosx, (int16)mPosy, bRPressed, NULL, NULL, NULL);
+ bSkipped = FALSE;
+ } else if (bLPressed && (mMove >= 10) && (InvStatus & INV_MODE2) && (bSomeOneSpeak)) {
+ bSkipTalk = TRUE;
+ bSkipped = TRUE;
+ } else if (!bLPressed)
bSkipped = FALSE;
mMove = 0;
}
// Button 1 pressed or released
- if( bRPressed != bRPressedPrev )
- {
- if( ( !bRPressed ) && ( ( mMove < 10 ) || ( !bFirstPerson && !bT2DActive ) ) )
+ if (bRPressed != bRPressedPrev) {
+ if ((!bRPressed) && ((mMove < 10) || (!bFirstPerson && !bT2DActive)))
Event(EventClass::MC_MOUSE, ME_MRIGHT, MP_DEFAULT, (int16)mPosx, (int16)mPosy, bLPressed, NULL, NULL, NULL);
mMove = 0;
}
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index c6d6ecf85a3..5e60eaa61a5 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -183,7 +183,7 @@ Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &fil
SearchMan.listMatchingMembers(files, adjustedPath);
for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) {
- if ((*it)->getName().equalsIgnoreCase(lastPathComponent(adjustedPath,'/'))) {
+ if ((*it)->getName().equalsIgnoreCase(lastPathComponent(adjustedPath, '/'))) {
file = (*it)->createReadStream();
break;
}
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 09711cffc34..6ad4020df8a 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -218,7 +218,7 @@ int16 getRoomFromStr(Init &init, const Common::String &s) {
Common::String str = s.substr(start, end - start);
for (int a = 0; a < MAX_ROOMS; a++)
- if (str.equalsIgnoreCase((const char*)init.Room[a].name))
+ if (str.equalsIgnoreCase((const char *)init.Room[a].name))
return a;
return (0);
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index 4310a2aa645..a98485f84bf 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -159,7 +159,7 @@ void Render3DEnvironment(WGame &game) {
int32 i;
// Cancella buffers
//if (!rClearBuffers(0, rCLEARBACKBUFFER | rCLEARZBUFFER))
- // DebugLogWindow("Unable to clear backbuffers\n");
+ // DebugLogWindow("Unable to clear backbuffers\n");
t3dResetPipeline();
// Update mouse coordinates and project them in 3D
HandleMouseChanges();
diff --git a/engines/watchmaker/metaengine.cpp b/engines/watchmaker/metaengine.cpp
index 4c50134addd..4cfc7ca94b3 100644
--- a/engines/watchmaker/metaengine.cpp
+++ b/engines/watchmaker/metaengine.cpp
@@ -27,8 +27,12 @@
namespace Watchmaker {
-const char *WatchmakerGame::getGameId() const { return _gameDescription->gameId; }
-Common::Platform WatchmakerGame::getPlatform() const { return _gameDescription->platform; }
+const char *WatchmakerGame::getGameId() const {
+ return _gameDescription->gameId;
+}
+Common::Platform WatchmakerGame::getPlatform() const {
+ return _gameDescription->platform;
+}
} // End of namespace Watchmaker
class WatchmakerMetaEngine : public AdvancedMetaEngine {
diff --git a/engines/watchmaker/render.h b/engines/watchmaker/render.h
index acbd24dc2df..fbe0de75522 100644
--- a/engines/watchmaker/render.h
+++ b/engines/watchmaker/render.h
@@ -114,8 +114,13 @@ struct gBatchBlock {
signed short int Texture1 = 0, Texture2 = 0; // texture ID
unsigned int Flags1 = 0, Flags2 = 0; // flags
signed short int ViewMatrixNum = 0; // view matrix num
- unsigned short int NumFaces() { return FacesList.size(); } // faces number
- unsigned short int NumVerts() { if (VBO) return VBO->_buffer.size(); else return 0; } // verts number
+ unsigned short int NumFaces() {
+ return FacesList.size(); // faces number
+ }
+ unsigned short int NumVerts() {
+ if (VBO) return VBO->_buffer.size(); // verts number
+ else return 0;
+ }
Common::Array<uint16> FacesList; // pointer to faces list
Common::SharedPtr<VertexBuffer> VBO = nullptr;
// LPDIRECT3DVERTEXBUFFER7 VB; // block VB
diff --git a/engines/watchmaker/renderer.cpp b/engines/watchmaker/renderer.cpp
index e19e45445a1..45a66a2f866 100644
--- a/engines/watchmaker/renderer.cpp
+++ b/engines/watchmaker/renderer.cpp
@@ -127,7 +127,7 @@ void Renderer::setCurCameraViewport(t3dF32 fov, uint8 sup) {
int32 sx = windowInfo.width;
int32 sy = windowInfo.height;
- t3dF32 SuperView = 50.0f * (sup^1);
+ t3dF32 SuperView = 50.0f * (sup ^ 1);
t3dCurCamera->Center.x = (t3dF32)(cx);
t3dCurCamera->Center.y = (t3dF32)(cy);
@@ -137,24 +137,24 @@ void Renderer::setCurCameraViewport(t3dF32 fov, uint8 sup) {
warning("TODO: Set projection matrix");
- setProjectionMatrix( (float)(sx),
- (float)(sy),
- fov,
- 10.0f + SuperView, 90000.0f);
+ setProjectionMatrix((float)(sx),
+ (float)(sy),
+ fov,
+ 10.0f + SuperView, 90000.0f);
//Set Clipplanes
t3dV3F c0;
- t3dVectFill(&c0,0.0f);
+ t3dVectFill(&c0, 0.0f);
t3dV3F v1(screenSpaceToCameraSpace(0.0f, 0.0f));
t3dV3F v2(screenSpaceToCameraSpace((t3dF32)sx, 0.0f));
- t3dV3F v3(screenSpaceToCameraSpace(0.0f, (t3dF32)sy));
+ t3dV3F v3(screenSpaceToCameraSpace(0.0f, (t3dF32)sy));
t3dV3F v4(screenSpaceToCameraSpace((t3dF32)sx, (t3dF32)sy));
#if 0
- t3dPlaneNormal(&ClipPlanes[LEFTCLIP], &c0, &v1, &v3);
- t3dPlaneNormal(&ClipPlanes[RIGHTCLIP], &c0, &v4, &v2);
- t3dPlaneNormal(&ClipPlanes[TOPCLIP], &c0, &v2, &v1);
- t3dPlaneNormal(&ClipPlanes[BOTTOMCLIP], &c0, &v3, &v4);
+ t3dPlaneNormal(&ClipPlanes[LEFTCLIP], &c0, &v1, &v3);
+ t3dPlaneNormal(&ClipPlanes[RIGHTCLIP], &c0, &v4, &v2);
+ t3dPlaneNormal(&ClipPlanes[TOPCLIP], &c0, &v2, &v1);
+ t3dPlaneNormal(&ClipPlanes[BOTTOMCLIP], &c0, &v3, &v4);
#endif
}
@@ -176,21 +176,21 @@ int Renderer::rInvFitY(int y) {
}
void gPrintText(WGame &game, const char *s, uint32 d, uint32 src, uint16 *FontTable, short x, short y) {
- int16 i=0,nextx,nexty;
+ int16 i = 0, nextx, nexty;
unsigned char c;
- uint32 AddFlag=0,NumRetries=0;
+ uint32 AddFlag = 0, NumRetries = 0;
nextx = nexty = 0;
- while ( (c=s[i])!=0) {
+ while ((c = s[i]) != 0) {
i++;
int16 posx, posy, dimx, dimy;
- posx = FontTable[c*4+0];
- posy = FontTable[c*4+1];
- dimx = FontTable[c*4+2];
- dimy = FontTable[c*4+3];
+ posx = FontTable[c * 4 + 0];
+ posy = FontTable[c * 4 + 1];
+ dimx = FontTable[c * 4 + 2];
+ dimy = FontTable[c * 4 + 3];
- rBlitter(game, d, src, x + nextx,y + nexty, posx, posy, dimx, dimy);
+ rBlitter(game, d, src, x + nextx, y + nexty, posx, posy, dimx, dimy);
nextx += dimx;
}
@@ -200,7 +200,7 @@ void Renderer::printText(const char *s, unsigned int dst, FontKind font, FontCol
auto f = _fonts->fontForKind(font);
uint32 src = f->color[color];
- if (dst==0)
+ if (dst == 0)
gPrintText(*_game, s, NULL, src, f->table, x, y);
else
gPrintText(*_game, s, dst, src, f->table, x, y);
@@ -224,8 +224,8 @@ Math::Vector3d vector3Matrix4Mult(Math::Vector3d &vec, const Math::Matrix4 &m) {
// since the w component is un-interesting that would be 4 unneccesary mults.
const float *d = m.getData();
return Math::Vector3d(vec.x() * d[0] + vec.y() * d[3] + vec.z() * d[6],
- vec.x() * d[1] + vec.y() * d[4] + vec.z() * d[7],
- vec.x() * d[2] + vec.y() * d[5] + vec.z() * d[8]);
+ vec.x() * d[1] + vec.y() * d[4] + vec.z() * d[7],
+ vec.x() * d[2] + vec.y() * d[5] + vec.z() * d[8]);
}
Math::Vector3d Renderer::screenSpaceToCameraSpace(float x, float y) {
diff --git a/engines/watchmaker/saveload.cpp b/engines/watchmaker/saveload.cpp
index b46aba6ac35..bef03a76383 100644
--- a/engines/watchmaker/saveload.cpp
+++ b/engines/watchmaker/saveload.cpp
@@ -41,7 +41,7 @@
#include "watchmaker/windows_hacks.h"
#include <cstdlib>
-#define WM_SAVEFILE_VERSION 0x17 // Don't know what changed though.
+#define WM_SAVEFILE_VERSION 0x17 // Don't know what changed though.
namespace Watchmaker {
@@ -322,7 +322,7 @@ bool DataLoad(WGame &game, const Common::String &FileName, uint8 slot) {
if (!FileName.equalsIgnoreCase("WmStart.dat"))
if (
(bPlayerInAnim && (bT2DActive != tOPTIONS))
- || bUseWith || bDialogActive || bDialogMenuActive || bMovingCamera || bGolfActive || InvStatus
+ || bUseWith || bDialogActive || bDialogMenuActive || bMovingCamera || bGolfActive || InvStatus
)
return FALSE;
diff --git a/engines/watchmaker/schedule.cpp b/engines/watchmaker/schedule.cpp
index c746a399d7b..c44f416ad35 100644
--- a/engines/watchmaker/schedule.cpp
+++ b/engines/watchmaker/schedule.cpp
@@ -115,7 +115,7 @@ void InitMessageSystem() {
memset(&WaitingMsg[i], 0, sizeof(WaitingMsg[i]));
}
-const char* eventToString(EventClass classe) {
+const char *eventToString(EventClass classe) {
switch (classe) {
case EventClass::MC_IDLE: return "MC_IDLE";
@@ -136,7 +136,7 @@ const char* eventToString(EventClass classe) {
* Event
* --------------------------------------------------*/
void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wparam2,
- uint8 bparam, void *p0, void *p1, void *p2) {
+ uint8 bparam, void *p0, void *p1, void *p2) {
pqueue *lq;
message *lm;
diff --git a/engines/watchmaker/schedule.h b/engines/watchmaker/schedule.h
index 64dc2ad1e70..3ab8b66642b 100644
--- a/engines/watchmaker/schedule.h
+++ b/engines/watchmaker/schedule.h
@@ -30,7 +30,7 @@
namespace Watchmaker {
void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wparam2,
- uint8 bparam, void *p0, void *p1, void *p2);
+ uint8 bparam, void *p0, void *p1, void *p2);
void InitMessageSystem();
void Scheduler();
diff --git a/engines/watchmaker/sdl_wrapper.cpp b/engines/watchmaker/sdl_wrapper.cpp
index 398bf94f67d..26cc79f01d0 100644
--- a/engines/watchmaker/sdl_wrapper.cpp
+++ b/engines/watchmaker/sdl_wrapper.cpp
@@ -73,37 +73,38 @@ void sdl_wrapper::pollSDL() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
- case SDL_QUIT:
- shouldQuit = true;
+ case SDL_QUIT:
+ shouldQuit = true;
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ switch (event.button.button) {
+ case SDL_BUTTON_LEFT:
+ bLPressed = true;
+ warning("LEFT PRESSED");
break;
- case SDL_MOUSEBUTTONDOWN:
- switch (event.button.button) {
- case SDL_BUTTON_LEFT:
- bLPressed = true;
- warning("LEFT PRESSED");
- break;
- case SDL_BUTTON_RIGHT:
- bRPressed = true;
- break;
- default:
- break;
- }*/
- /*
- case SDL_MOUSEBUTTONUP:
- switch (event.button.button) {
- case SDL_BUTTON_LEFT:
- bLPressed = false;
- warning("LEFT RELEASED");
- break;
- case SDL_BUTTON_RIGHT:
- bRPressed = false;
- break;
- default:
- break;
- }*/
- case SDL_KEYUP:
- KeyTable[event.key.keysym.scancode] = 0x10;
+ case SDL_BUTTON_RIGHT:
+ bRPressed = true;
break;
+ default:
+ break;
+ }
+ * /
+ /*
+ case SDL_MOUSEBUTTONUP:
+ switch (event.button.button) {
+ case SDL_BUTTON_LEFT:
+ bLPressed = false;
+ warning("LEFT RELEASED");
+ break;
+ case SDL_BUTTON_RIGHT:
+ bRPressed = false;
+ break;
+ default:
+ break;
+ }*/
+ case SDL_KEYUP:
+ KeyTable[event.key.keysym.scancode] = 0x10;
+ break;
}
}
diff --git a/engines/watchmaker/t2d/t2d.cpp b/engines/watchmaker/t2d/t2d.cpp
index b16a4fadb9b..fb4a51b9d26 100644
--- a/engines/watchmaker/t2d/t2d.cpp
+++ b/engines/watchmaker/t2d/t2d.cpp
@@ -1236,7 +1236,7 @@ void doT2DMouseMainMenu(WGame &game, t2dWINDOW *w) {
} else {
//Inizia il gioco
Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_NEWGAME, 0, tMAINMENU,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
}
} else if (CurButton == T2D_BT_MAINMENU_LOAD) {
if (TheMessage->event == ME_MOUSEUPDATE) {
@@ -1246,7 +1246,7 @@ void doT2DMouseMainMenu(WGame &game, t2dWINDOW *w) {
//Va alla schermata di caricamento
LoadWindow_WhichBkg = 1;
Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_LOAD, 0, tMAINMENU, nullptr,
- nullptr, nullptr);
+ nullptr, nullptr);
}
} else if (CurButton == T2D_BT_MAINMENU_EXIT) {
@@ -1491,12 +1491,12 @@ void doT2DMouse(WGame &game) {
w->bm[T2D_BM_SCANNER_TOOLBAR_PREVIEW_ON].tnum &= ~T2D_BM_OFF;
// Aspetta 1 secondo
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_SCANNER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
// Riaccede tasto preview
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_PREVIEW_OFF, TRUE, nullptr, nullptr, nullptr);
+ T2D_BM_SCANNER_TOOLBAR_PREVIEW_OFF, TRUE, nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_PREVIEW_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_SCANNER_TOOLBAR_PREVIEW_ON, FALSE, nullptr, nullptr, nullptr);
// Spegne pic di preview
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_PIC_LOW].tnum |= T2D_BM_OFF;
// Spegne selzionatoredi area
@@ -1509,7 +1509,7 @@ void doT2DMouse(WGame &game) {
WinActive[2] = T2D_WIN_SCANNER_PROGRESSBAR;
// Attiva gestione progress bar
Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_WAITA, T2D_SCANNER_SCANNING_DELAY,
- T2D_SCANNER_SCANNING_STEPS, T2D_SCANNER_PREVIEWING, nullptr, nullptr, nullptr);
+ T2D_SCANNER_SCANNING_STEPS, T2D_SCANNER_PREVIEWING, nullptr, nullptr, nullptr);
// Spegne tutta la toolbar
w->bt[T2D_BT_SCANNER_TOOLBAR_MOVE].on = FALSE;
w->bt[T2D_BT_SCANNER_TOOLBAR_EXIT].on = FALSE;
@@ -1519,21 +1519,21 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wSCANPULSANTE);
} else if ((CurButton == T2D_BT_SCANNER_TOOLBAR_SELECTAREA_OFF) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ (TheMessage->event != ME_MOUSEUPDATE)) {
// Spegne per un attimo bottone di select area
b->on = FALSE;
w->bm[T2D_BM_SCANNER_TOOLBAR_SELECTAREA_OFF].tnum |= T2D_BM_OFF;
w->bm[T2D_BM_SCANNER_TOOLBAR_SELECTAREA_ON].tnum &= ~T2D_BM_OFF;
// Aspetta 1 secondo
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_SCANNER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
// Riaccede tasto di select area
Event(EventClass::MC_T2D, ME_T2DSETBUTTON, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BT_SCANNER_TOOLBAR_SELECTAREA_OFF, TRUE, nullptr, nullptr, nullptr);
+ T2D_BT_SCANNER_TOOLBAR_SELECTAREA_OFF, TRUE, nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_SELECTAREA_OFF, TRUE, nullptr, nullptr, nullptr);
+ T2D_BM_SCANNER_TOOLBAR_SELECTAREA_OFF, TRUE, nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_SELECTAREA_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_SCANNER_TOOLBAR_SELECTAREA_ON, FALSE, nullptr, nullptr, nullptr);
// Accende selezionatore di area
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_SELECTOR].tnum &= ~T2D_BM_OFF;
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bt[T2D_BT_SCANNER_BACKGROUND_SELECTOR].on = TRUE;
@@ -1551,11 +1551,11 @@ void doT2DMouse(WGame &game) {
w->bm[T2D_BM_SCANNER_TOOLBAR_SCAN_OFF].tnum |= T2D_BM_OFF;
w->bm[T2D_BM_SCANNER_TOOLBAR_SCAN_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_SCANNER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_SCAN_FREEZE, TRUE, nullptr, nullptr, nullptr);
+ T2D_BM_SCANNER_TOOLBAR_SCAN_FREEZE, TRUE, nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_SCAN_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_SCANNER_TOOLBAR_SCAN_ON, FALSE, nullptr, nullptr, nullptr);
w = &t2dWin[T2D_WIN_SCANNER_BACKGROUND];
d = &w->bm[T2D_BM_SCANNER_BACKGROUND_SELECTOR];
@@ -1563,9 +1563,9 @@ void doT2DMouse(WGame &game) {
d2 = &w->bm[T2D_BM_SCANNER_BACKGROUND_PIC_HI];
d2->ox = ((d->px - d1->px) * rGetBitmapRealDimX(d2->tnum & ~T2D_BM_OFF)) /
- rGetBitmapRealDimX(d1->tnum & ~T2D_BM_OFF);
+ rGetBitmapRealDimX(d1->tnum & ~T2D_BM_OFF);
d2->oy = ((d->py - d1->py) * rGetBitmapRealDimY(d2->tnum & ~T2D_BM_OFF)) /
- rGetBitmapRealDimY(d1->tnum & ~T2D_BM_OFF);
+ rGetBitmapRealDimY(d1->tnum & ~T2D_BM_OFF);
d2->dx = rGetBitmapRealDimX(d1->tnum & ~T2D_BM_OFF);
d2->px = d1->px - d2->ox;
d2->py = d1->py - d2->oy;
@@ -1580,7 +1580,7 @@ void doT2DMouse(WGame &game) {
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bt[T2D_BT_SCANNER_BACKGROUND_SELECTOR].on = FALSE;
// Attiva gestione progress bar
Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_DEFAULT, T2D_SCANNER_SCANNING_DELAY,
- T2D_SCANNER_SCANNING_STEPS, T2D_SCANNER_SCANNING, nullptr, nullptr, nullptr);
+ T2D_SCANNER_SCANNING_STEPS, T2D_SCANNER_SCANNING, nullptr, nullptr, nullptr);
// Spegne tutta la toolbar
w = &t2dWin[T2D_WIN_SCANNER_TOOLBAR];
w->bt[T2D_BT_SCANNER_TOOLBAR_MOVE].on = FALSE;
@@ -1615,7 +1615,7 @@ void doT2DMouse(WGame &game) {
StartSound(game, wCIAPULSANTE);
//Apre finestra EMail
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_EMAIL, 0, FALSE,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
//Resetta dati
computerCurrentEMail = -1;
} else {
@@ -1625,7 +1625,7 @@ void doT2DMouse(WGame &game) {
StartSound(game, wCIAPULSANTE);
//Chiude finestra EMail
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_EMAIL, 0, TRUE, nullptr,
- nullptr, nullptr);
+ nullptr, nullptr);
}
} else if ((CurButton == T2D_BT_COMPUTER_BACKGROUND_SEARCH) && (TheMessage->event != ME_MOUSEUPDATE)) {
if (!(w->bm[T2D_BM_COMPUTER_SEARCH_ON].tnum & T2D_BM_OFF)) {
@@ -1635,7 +1635,7 @@ void doT2DMouse(WGame &game) {
StartSound(game, wCIAPULSANTE);
//Apre finestra Search
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_SEARCH, 0, FALSE,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
//Riattiva DirectInput
//ResetDIKbd();
@@ -1660,7 +1660,7 @@ void doT2DMouse(WGame &game) {
StartSound(game, wCIAPULSANTE);
//Chiude finestra Search
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_SEARCH, 0, TRUE,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
}
} else if ((CurButton == T2D_BT_COMPUTER_BACKGROUND_QUIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
@@ -1669,9 +1669,9 @@ void doT2DMouse(WGame &game) {
StartSound(game, wCIAPULSANTE);
//Quitta
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_BACKGROUND,
- T2D_BM_COMPUTER_QUIT_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_QUIT_ON, FALSE, nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
}
@@ -1684,17 +1684,17 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_ERROR_DIALUP_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_ERROR_DIALUP_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_ERROR_DIALUP_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva finestra errore
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, FALSE, nullptr,
- nullptr, nullptr);
+ nullptr, nullptr);
//Attiva finestra DialUp
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, TRUE, nullptr,
- nullptr, nullptr);
+ nullptr, nullptr);
//Disattiva DirectInput
//bIngnoreDIKeyboard = TRUE;
//Azzera Numero Telefonico
@@ -1703,7 +1703,7 @@ void doT2DMouse(WGame &game) {
//Disattiva bitmap e pulsanti finestra errore
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_DIALERROR_WIN, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALERROR_WIN, FALSE, nullptr, nullptr, nullptr);
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_DIALUP].on = FALSE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_DIALQUIT].on = FALSE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_DialError_Win_TGA].on = FALSE;
@@ -1712,9 +1712,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_ERROR_DIALQUIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_ERROR_DIALQUIT_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_ERROR_DIALQUIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Spenge il computer
@@ -1723,9 +1723,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_ERROR_COMQUIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_ERROR_COMQUIT_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_ERROR_COMQUIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Spenge il computer
@@ -1734,18 +1734,18 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_ERROR_OK_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_ERROR_OK_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_ERROR_OK_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Distattiva finestra errore
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, FALSE, nullptr,
- nullptr, nullptr);
+ nullptr, nullptr);
//Distattiva bitmap e tasti finestra errore
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_SEARCHERROR_WIN, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_SEARCHERROR_WIN, FALSE, nullptr, nullptr, nullptr);
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_OK].on = FALSE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_SearchError_Win_TGA].on = FALSE;
t2dWin[T2D_WIN_COMPUTER_ERROR].sy = 3;
@@ -1760,9 +1760,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_1_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_1_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_1_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_2) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1770,9 +1770,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_2_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_2_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_2_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_3) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1780,9 +1780,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_3_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_3_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_3_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_4) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1790,9 +1790,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_4_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_4_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_4_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_5) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1800,9 +1800,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_5_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_5_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_5_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_6) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1810,9 +1810,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_6_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_6_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_6_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_7) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1820,9 +1820,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_7_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_7_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_7_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_8) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1830,9 +1830,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_8_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_8_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_8_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_9) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1840,9 +1840,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_9_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_9_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_9_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_0) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1850,9 +1850,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_0_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_0_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_0_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_ENTER) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -1860,30 +1860,30 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_ENTER_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_ENTER_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_ENTER_ON, FALSE, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_C) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput(VK_BACK);
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_C_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_C_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_C_ON, FALSE, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_OK) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput(VK_RETURN);
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_OK_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_OK_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DIALUP_OK_ON, FALSE, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
}
} else if (CurButtonWin == T2D_WIN_COMPUTER_SEARCH) {
@@ -1895,15 +1895,15 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_SEARCH_SEARCH_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_SEARCH,
- T2D_BM_COMPUTER_SEARCH_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_SEARCH_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
ComputerSearch(game);
} else if ((CurButton == T2D_BT_COMPUTER_SEARCH_ALPHABETICAL) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ (TheMessage->event != ME_MOUSEUPDATE)) {
//Suono
StartSound(game, wCIAPULSANTE);
//Setta parametri della finestra Search per visualizzare la parte Alphabetical
@@ -1967,7 +1967,7 @@ void doT2DMouse(WGame &game) {
strcpy(w->text[WhatText].text, "");
searchName = "";
} else if ((CurButton == T2D_BT_COMPUTER_SEARCH_SURNAME_TEXT) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ (TheMessage->event != ME_MOUSEUPDATE)) {
//Pone il cursore sulla casella testo Surname
ActivateCursor(FALSE, NULL);
WhatText = T2D_TEXT_COMPUTER_SEARCH_SURNAME;
@@ -1981,7 +1981,7 @@ void doT2DMouse(WGame &game) {
strcpy(w->text[WhatText].text, "");
searchSurName = "";
} else if ((CurButton == T2D_BT_COMPUTER_SEARCH_CASENAME_TEXT) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ (TheMessage->event != ME_MOUSEUPDATE)) {
//Pone il cursore sulla casella testo Casename
ActivateCursor(FALSE, NULL);
WhatText = T2D_TEXT_COMPUTER_SEARCH_CASENAME;
@@ -2011,18 +2011,18 @@ void doT2DMouse(WGame &game) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_SEARCH_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_SEARCH,
- T2D_BM_COMPUTER_SEARCH_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_SEARCH_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Elimina finestra search
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_SEARCH, 0, FALSE, nullptr,
- nullptr, nullptr);
+ nullptr, nullptr);
//Disattiva tasto search
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_BACKGROUND,
- T2D_BM_COMPUTER_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
}
} else if (CurButtonWin == T2D_WIN_COMPUTER_DOCLIST) {
if ((CurButton == T2D_BT_COMPUTER_DOCLIST_MOVE) && (bLPressed || bRPressed)) {
@@ -2033,23 +2033,23 @@ void doT2DMouse(WGame &game) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCLIST_SCROLLUP_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST,
- T2D_BM_COMPUTER_DOCLIST_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DOCLIST_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DOCLIST_SCROLLDOWN) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCLIST_SCROLLDOWN_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST,
- T2D_BM_COMPUTER_DOCLIST_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DOCLIST_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if (((CurButton >= T2D_BT_COMPUTER_DOCLIST_LINES_START) &&
- (CurButton <= T2D_BT_COMPUTER_DOCLIST_LINES_END)) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ (CurButton <= T2D_BT_COMPUTER_DOCLIST_LINES_END)) &&
+ (TheMessage->event != ME_MOUSEUPDATE)) {
StartY = computerCurrentDocument;
computerCurrentDocument = -1;
@@ -2089,20 +2089,20 @@ void doT2DMouse(WGame &game) {
}
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_DOCUMENT, 0, TRUE,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
}
} else if ((CurButton == T2D_BT_COMPUTER_DOCLIST_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCLIST_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST,
- T2D_BM_COMPUTER_DOCLIST_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DOCLIST_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva finestra doclist
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, FALSE, nullptr,
- nullptr, nullptr);
+ nullptr, nullptr);
}
} else if (CurButtonWin == T2D_WIN_COMPUTER_EMAIL) {
if ((CurButton == T2D_BT_COMPUTER_EMAIL_MOVE) && (bLPressed || bRPressed)) {
@@ -2117,8 +2117,8 @@ void doT2DMouse(WGame &game) {
//Scroll Down
w->sy += 10;
} else if (
- ((CurButton == T2D_BT_COMPUTER_EMAIL_ICON_1) || (CurButton == T2D_BT_COMPUTER_EMAIL_ICON_2)) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ ((CurButton == T2D_BT_COMPUTER_EMAIL_ICON_1) || (CurButton == T2D_BT_COMPUTER_EMAIL_ICON_2)) &&
+ (TheMessage->event != ME_MOUSEUPDATE)) {
//Disattiva vecchia email
if (computerCurrentEMail != -1)
t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].tnum |= T2D_BM_OFF;
@@ -2141,28 +2141,28 @@ void doT2DMouse(WGame &game) {
t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].dy = 0;
if (t.y2 - t.y1 > 182)
t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].dy = renderer.rInvFitY(182);
- //else t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].dy = rInvFitY(t.y2-t.y1);
+ //else t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].dy = rInvFitY(t.y2-t.y1);
else t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].dy = 0;
//Apre finestra EMail_Viewer
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_EMAIL_VIEWER, 0, TRUE,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_EMAIL_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_EMAIL_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL,
- T2D_BM_COMPUTER_EMAIL_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_EMAIL_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva finestra email
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_EMAIL, 0, FALSE, nullptr,
- nullptr, nullptr);
+ nullptr, nullptr);
//Disattiva tasto email
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_BACKGROUND,
- T2D_BM_COMPUTER_EMAIL_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_EMAIL_ON, FALSE, nullptr, nullptr, nullptr);
//ResetDIKbd();
//bIngnoreDIKeyboard = FALSE;
@@ -2181,9 +2181,9 @@ void doT2DMouse(WGame &game) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCUMENT_SCROLLUP_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
- T2D_BM_COMPUTER_DOCUMENT_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DOCUMENT_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -2199,13 +2199,13 @@ void doT2DMouse(WGame &game) {
}
}
} else if ((CurButton == T2D_BT_COMPUTER_DOCUMENT_SCROLLDOWN) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCUMENT_SCROLLDOWN_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
- T2D_BM_COMPUTER_DOCUMENT_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DOCUMENT_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -2213,14 +2213,14 @@ void doT2DMouse(WGame &game) {
if (t.y2 - t.y1 > 407) {
if (w->bm[computerCurrentDocument].oy + w->bm[computerCurrentDocument].dy +
- T2D_DOC_SCROLL_ADD >= renderer.rInvFitY(t.y2 - t.y1)) {
+ T2D_DOC_SCROLL_ADD >= renderer.rInvFitY(t.y2 - t.y1)) {
w->bm[computerCurrentDocument].oy =
- renderer.rInvFitY(t.y2 - t.y1) - w->bm[computerCurrentDocument].dy;
+ renderer.rInvFitY(t.y2 - t.y1) - w->bm[computerCurrentDocument].dy;
while (w->bm[computerCurrentDocument].oy + w->bm[computerCurrentDocument].dy >=
- renderer.rInvFitY(t.y2 - t.y1))
+ renderer.rInvFitY(t.y2 - t.y1))
w->bm[computerCurrentDocument].oy--;
w->bm[computerCurrentDocument].py =
- renderer.rInvFitY(66) - w->bm[computerCurrentDocument].oy;
+ renderer.rInvFitY(66) - w->bm[computerCurrentDocument].oy;
} else {
w->bm[computerCurrentDocument].oy += T2D_DOC_SCROLL_ADD;
w->bm[computerCurrentDocument].py -= T2D_DOC_SCROLL_ADD;
@@ -2231,17 +2231,17 @@ void doT2DMouse(WGame &game) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCUMENT_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
- T2D_BM_COMPUTER_DOCUMENT_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_DOCUMENT_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva documento
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
- (short) computerCurrentDocument, FALSE, nullptr, nullptr, nullptr);
+ (short) computerCurrentDocument, FALSE, nullptr, nullptr, nullptr);
//Disattiva finestra Document
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT, 0, FALSE, nullptr,
- nullptr, nullptr);
+ nullptr, nullptr);
computerCurrentDocument = -1;
}
@@ -2256,13 +2256,13 @@ void doT2DMouse(WGame &game) {
ScrollWithMouseX = mouse_x;
ScrollWithMouseY = mouse_y;
} else if ((CurButton == T2D_BT_COMPUTER_EMAIL_VIEWER_SCROLLUP) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLUP_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER,
- T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -2278,13 +2278,13 @@ void doT2DMouse(WGame &game) {
}
}
} else if ((CurButton == T2D_BT_COMPUTER_EMAIL_VIEWER_SCROLLDOWN) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLDOWN_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER,
- T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -2292,11 +2292,11 @@ void doT2DMouse(WGame &game) {
if (t.y2 - t.y1 > 182) {
if (w->bm[computerCurrentEMail].oy + w->bm[computerCurrentEMail].dy +
- T2D_DOC_SCROLL_ADD >= renderer.rInvFitY(t.y2 - t.y1)) {
+ T2D_DOC_SCROLL_ADD >= renderer.rInvFitY(t.y2 - t.y1)) {
w->bm[computerCurrentEMail].oy =
- renderer.rInvFitY(t.y2 - t.y1) - w->bm[computerCurrentEMail].dy;
+ renderer.rInvFitY(t.y2 - t.y1) - w->bm[computerCurrentEMail].dy;
while (w->bm[computerCurrentEMail].oy + w->bm[computerCurrentEMail].dy >=
- renderer.rInvFitY(t.y2 - t.y1))
+ renderer.rInvFitY(t.y2 - t.y1))
w->bm[computerCurrentEMail].oy--;
w->bm[computerCurrentEMail].py = renderer.rInvFitY(59) - w->bm[computerCurrentEMail].oy;
} else {
@@ -2309,14 +2309,14 @@ void doT2DMouse(WGame &game) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER,
- T2D_BM_COMPUTER_EMAIL_VIEWER_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_COMPUTER_EMAIL_VIEWER_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva finestra Email_Viewer
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER, 0, FALSE,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
}
}
break;
@@ -2326,30 +2326,30 @@ void doT2DMouse(WGame &game) {
//Azzera parti selezionate
if (TheMessage->event == ME_MOUSEUPDATE) {
switch (diarioCurrentPage) {
- case 1:
- for (i = T2D_BT_DIARIO_PAGE_1_TEXT_1; i <= T2D_BT_DIARIO_PAGE_1_TEXT_6; i++) {
- if (!(w->bm[i].tnum & T2D_BM_OFF))
- w->bm[i].tnum |= T2D_BM_OFF;
- }
- break;
- case 2:
- for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++) {
- if (!(w->bm[i].tnum & T2D_BM_OFF))
- w->bm[i].tnum |= T2D_BM_OFF;
- }
- break;
- case 3:
- for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++) {
- if (!(w->bm[i].tnum & T2D_BM_OFF))
- w->bm[i].tnum |= T2D_BM_OFF;
- }
- break;
- case 4:
- for (i = T2D_BT_DIARIO_PAGE_4_TEXT_1; i <= T2D_BT_DIARIO_PAGE_4_TEXT_12; i++) {
- if (!(w->bm[i].tnum & T2D_BM_OFF))
- w->bm[i].tnum |= T2D_BM_OFF;
- }
- break;
+ case 1:
+ for (i = T2D_BT_DIARIO_PAGE_1_TEXT_1; i <= T2D_BT_DIARIO_PAGE_1_TEXT_6; i++) {
+ if (!(w->bm[i].tnum & T2D_BM_OFF))
+ w->bm[i].tnum |= T2D_BM_OFF;
+ }
+ break;
+ case 2:
+ for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++) {
+ if (!(w->bm[i].tnum & T2D_BM_OFF))
+ w->bm[i].tnum |= T2D_BM_OFF;
+ }
+ break;
+ case 3:
+ for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++) {
+ if (!(w->bm[i].tnum & T2D_BM_OFF))
+ w->bm[i].tnum |= T2D_BM_OFF;
+ }
+ break;
+ case 4:
+ for (i = T2D_BT_DIARIO_PAGE_4_TEXT_1; i <= T2D_BT_DIARIO_PAGE_4_TEXT_12; i++) {
+ if (!(w->bm[i].tnum & T2D_BM_OFF))
+ w->bm[i].tnum |= T2D_BM_OFF;
+ }
+ break;
}
}
@@ -2364,138 +2364,138 @@ void doT2DMouse(WGame &game) {
//Pressione tasto
w->bm[T2D_BM_DIARIO_PAGE_LEFT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_LEFT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
switch (diarioCurrentPage) {
- case 1: //Pagina Iniziale, non puo andare a pagina precedente
- break;
- case 2:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_1,
- TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
- FALSE, nullptr, nullptr, nullptr);
- w->bt[T2D_BT_DIARIO_PAGE_LEFT].on = false;
- for (i = T2D_BT_DIARIO_PAGE_1_TEXT_1; i <= T2D_BT_DIARIO_PAGE_1_TEXT_6; i++)
- w->bt[i].on = TRUE;
- for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
- w->bt[i].on = false;
- diarioCurrentPage = 1;
- break;
- case 3:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
- TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
- FALSE, nullptr, nullptr, nullptr);
- for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
- w->bt[i].on = TRUE;
- for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
- w->bt[i].on = false;
- diarioCurrentPage = 2;
- break;
- case 4:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
- TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_4,
- FALSE, nullptr, nullptr, nullptr);
- w->bt[T2D_BT_DIARIO_PAGE_RIGHT].on = TRUE;
- for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
- w->bt[i].on = TRUE;
- for (i = T2D_BT_DIARIO_PAGE_4_TEXT_1; i <= T2D_BT_DIARIO_PAGE_4_TEXT_12; i++)
- w->bt[i].on = false;
- diarioCurrentPage = 3;
- break;
+ case 1: //Pagina Iniziale, non puo andare a pagina precedente
+ break;
+ case 2:
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_1,
+ TRUE, nullptr, nullptr, nullptr);
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
+ FALSE, nullptr, nullptr, nullptr);
+ w->bt[T2D_BT_DIARIO_PAGE_LEFT].on = false;
+ for (i = T2D_BT_DIARIO_PAGE_1_TEXT_1; i <= T2D_BT_DIARIO_PAGE_1_TEXT_6; i++)
+ w->bt[i].on = TRUE;
+ for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
+ w->bt[i].on = false;
+ diarioCurrentPage = 1;
+ break;
+ case 3:
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
+ TRUE, nullptr, nullptr, nullptr);
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
+ FALSE, nullptr, nullptr, nullptr);
+ for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
+ w->bt[i].on = TRUE;
+ for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
+ w->bt[i].on = false;
+ diarioCurrentPage = 2;
+ break;
+ case 4:
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
+ TRUE, nullptr, nullptr, nullptr);
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_4,
+ FALSE, nullptr, nullptr, nullptr);
+ w->bt[T2D_BT_DIARIO_PAGE_RIGHT].on = TRUE;
+ for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
+ w->bt[i].on = TRUE;
+ for (i = T2D_BT_DIARIO_PAGE_4_TEXT_1; i <= T2D_BT_DIARIO_PAGE_4_TEXT_12; i++)
+ w->bt[i].on = false;
+ diarioCurrentPage = 3;
+ break;
}
} else if ((CurButton == T2D_BT_DIARIO_PAGE_RIGHT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_DIARIO_PAGE_RIGHT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_RIGHT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
switch (diarioCurrentPage) {
- case 1:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_1,
- FALSE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
- TRUE, nullptr, nullptr, nullptr);
- w->bt[T2D_BT_DIARIO_PAGE_LEFT].on = TRUE;
- for (i = T2D_BT_DIARIO_PAGE_1_TEXT_1; i <= T2D_BT_DIARIO_PAGE_1_TEXT_6; i++)
- w->bt[i].on = false;
- for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
- w->bt[i].on = TRUE;
- diarioCurrentPage = 2;
- break;
- case 2:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
- FALSE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
- TRUE, nullptr, nullptr, nullptr);
- for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
- w->bt[i].on = false;
- for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
- w->bt[i].on = TRUE;
- diarioCurrentPage = 3;
- break;
- case 3:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
- FALSE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_4,
- TRUE, nullptr, nullptr, nullptr);
- w->bt[T2D_BT_DIARIO_PAGE_RIGHT].on = false;
- for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
- w->bt[i].on = false;
- for (i = T2D_BT_DIARIO_PAGE_4_TEXT_1; i <= T2D_BT_DIARIO_PAGE_4_TEXT_12; i++)
- w->bt[i].on = TRUE;
- diarioCurrentPage = 4;
- break;
- case 4: //Ultima Pagina
- break;
+ case 1:
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_1,
+ FALSE, nullptr, nullptr, nullptr);
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
+ TRUE, nullptr, nullptr, nullptr);
+ w->bt[T2D_BT_DIARIO_PAGE_LEFT].on = TRUE;
+ for (i = T2D_BT_DIARIO_PAGE_1_TEXT_1; i <= T2D_BT_DIARIO_PAGE_1_TEXT_6; i++)
+ w->bt[i].on = false;
+ for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
+ w->bt[i].on = TRUE;
+ diarioCurrentPage = 2;
+ break;
+ case 2:
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
+ FALSE, nullptr, nullptr, nullptr);
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
+ TRUE, nullptr, nullptr, nullptr);
+ for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
+ w->bt[i].on = false;
+ for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
+ w->bt[i].on = TRUE;
+ diarioCurrentPage = 3;
+ break;
+ case 3:
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
+ FALSE, nullptr, nullptr, nullptr);
+ Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_4,
+ TRUE, nullptr, nullptr, nullptr);
+ w->bt[T2D_BT_DIARIO_PAGE_RIGHT].on = false;
+ for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
+ w->bt[i].on = false;
+ for (i = T2D_BT_DIARIO_PAGE_4_TEXT_1; i <= T2D_BT_DIARIO_PAGE_4_TEXT_12; i++)
+ w->bt[i].on = TRUE;
+ diarioCurrentPage = 4;
+ break;
+ case 4: //Ultima Pagina
+ break;
}
} else if ((CurButton == T2D_BT_DIARIO_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_DIARIO_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_EXIT_ON, FALSE,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
//Uscita
Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tDIARIO, nullptr, nullptr, nullptr);
} else if ((CurButton >= T2D_BT_DIARIO_PAGE_1_TEXT_1) && (CurButton <= T2D_BT_DIARIO_PAGE_1_TEXT_6) &&
- (diarioCurrentPage == 1)) {
+ (diarioCurrentPage == 1)) {
if (TheMessage->event == ME_MOUSEUPDATE) {
w->bm[CurButton].tnum &= ~T2D_BM_OFF;
} else {
if (CurPlayer == DARRELL)
PlayerSpeak(game, init.Obj[o34DIARIOAP].action[CurPlayer]);
else PlayerSpeak(game, init.Obj[oDIARIOPAG1A +
- (CurButton - T2D_BT_DIARIO_PAGE_1_TEXT_1)].examine[CurPlayer]);
+ (CurButton - T2D_BT_DIARIO_PAGE_1_TEXT_1)].examine[CurPlayer]);
}
} else if ((CurButton >= T2D_BT_DIARIO_PAGE_2_TEXT_1) && (CurButton <= T2D_BT_DIARIO_PAGE_2_TEXT_6) &&
- (diarioCurrentPage == 2)) {
+ (diarioCurrentPage == 2)) {
if (TheMessage->event == ME_MOUSEUPDATE) {
w->bm[CurButton].tnum &= ~T2D_BM_OFF;
} else {
if (CurPlayer == DARRELL)
PlayerSpeak(game, init.Obj[o34DIARIOAP].action[CurPlayer]);
else PlayerSpeak(game, init.Obj[oDIARIOPAG2A +
- (CurButton - T2D_BT_DIARIO_PAGE_2_TEXT_1)].examine[CurPlayer]);
+ (CurButton - T2D_BT_DIARIO_PAGE_2_TEXT_1)].examine[CurPlayer]);
}
} else if ((CurButton >= T2D_BT_DIARIO_PAGE_3_TEXT_1) && (CurButton <= T2D_BT_DIARIO_PAGE_3_TEXT_4) &&
- (diarioCurrentPage == 3)) {
+ (diarioCurrentPage == 3)) {
if (TheMessage->event == ME_MOUSEUPDATE) {
w->bm[CurButton].tnum &= ~T2D_BM_OFF;
} else {
if (CurPlayer == DARRELL)
PlayerSpeak(game, init.Obj[o34DIARIOAP].action[CurPlayer]);
else PlayerSpeak(game, init.Obj[oDIARIOPAG3A +
- (CurButton - T2D_BT_DIARIO_PAGE_3_TEXT_1)].examine[CurPlayer]);
+ (CurButton - T2D_BT_DIARIO_PAGE_3_TEXT_1)].examine[CurPlayer]);
}
} else if ((CurButton >= T2D_BT_DIARIO_PAGE_4_TEXT_1) && (CurButton <= T2D_BT_DIARIO_PAGE_4_TEXT_12) &&
- (diarioCurrentPage == 4)) {
+ (diarioCurrentPage == 4)) {
if (TheMessage->event == ME_MOUSEUPDATE) {
w->bm[CurButton].tnum &= ~T2D_BM_OFF;
} else {
@@ -2503,10 +2503,10 @@ void doT2DMouse(WGame &game) {
PlayerSpeak(game, init.Obj[o34DIARIOAP].action[CurPlayer]);
else {
PlayerSpeak(game, init.Obj[oDIARIOPAG4A +
- (CurButton - T2D_BT_DIARIO_PAGE_4_TEXT_1)].examine[CurPlayer]);
+ (CurButton - T2D_BT_DIARIO_PAGE_4_TEXT_1)].examine[CurPlayer]);
Event(EventClass::MC_STRING, ME_PLAYERSPEAK, MP_WAIT_LINK,
- init.Obj[oDIARIOPAG4A + (CurButton - T2D_BT_DIARIO_PAGE_4_TEXT_1)].text[0], 0, 0,
- nullptr, nullptr, nullptr);
+ init.Obj[oDIARIOPAG4A + (CurButton - T2D_BT_DIARIO_PAGE_4_TEXT_1)].text[0], 0, 0,
+ nullptr, nullptr, nullptr);
}
}
}
@@ -2520,23 +2520,23 @@ void doT2DMouse(WGame &game) {
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_MAIN_TONE_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_MAIN, T2D_BM_PDA_MAIN_TONE_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Apre il Tone Sequencer
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_TONE, 0, TRUE, nullptr, nullptr,
- nullptr);
+ nullptr);
} else if ((CurButton == T2D_BT_PDA_MAIN_LOG) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_MAIN_LOG_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_MAIN, T2D_BM_PDA_MAIN_LOG_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Apre il Log Viewer
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_LOG, 0, TRUE, nullptr, nullptr,
- nullptr);
+ nullptr);
//Resetta variabili
RefreshLog(game, RESTARTALL);
RefreshLog(game, REFRESH);
@@ -2545,9 +2545,9 @@ void doT2DMouse(WGame &game) {
StartSound(game, wPDAOFF);
w->bm[T2D_BM_PDA_MAIN_QUIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_MAIN, T2D_BM_PDA_MAIN_QUIT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Esce dal PDA
Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tPDA, nullptr, nullptr, nullptr);
}
@@ -2573,9 +2573,9 @@ void doT2DMouse(WGame &game) {
break;
}
- StartY = (int) ((double) (mouse_y - w->bt[T2D_BT_PDA_LOG_SCROLL].lim.y1 - w->px) /
- ((double) (w->bt[T2D_BT_PDA_LOG_SCROLL].lim.y2 -
- w->bt[T2D_BT_PDA_LOG_SCROLL].lim.y1) / 20.0));
+ StartY = (int)((double)(mouse_y - w->bt[T2D_BT_PDA_LOG_SCROLL].lim.y1 - w->px) /
+ ((double)(w->bt[T2D_BT_PDA_LOG_SCROLL].lim.y2 -
+ w->bt[T2D_BT_PDA_LOG_SCROLL].lim.y1) / 20.0));
/*if (NumMenus>0) StartY-=NumMenus+2;
@@ -2612,9 +2612,9 @@ void doT2DMouse(WGame &game) {
//Gestione tasto
w->bm[T2D_BM_PDA_LOG_SCROLLUP_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_LOG, T2D_BM_PDA_LOG_SCROLLUP_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Riposiziona il log
RefreshLog(game, -1);
@@ -2622,9 +2622,9 @@ void doT2DMouse(WGame &game) {
//Gestione tasto
w->bm[T2D_BM_PDA_LOG_SCROLLDOWN_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_LOG, T2D_BM_PDA_LOG_SCROLLDOWN_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Riposiziona il log
RefreshLog(game, +1);
@@ -2659,15 +2659,15 @@ void doT2DMouse(WGame &game) {
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_LOG_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_LOG, T2D_BM_PDA_LOG_EXIT_ON, FALSE,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
//Chiude finestra help se aperta
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr,
- nullptr);
+ nullptr);
//Chiude finestra Log Viewer
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_LOG, 0, FALSE, nullptr, nullptr,
- nullptr);
+ nullptr);
}
} else if (CurButtonWin == T2D_WIN_PDA_TONE) {
if ((CurButton == T2D_BT_PDA_TONE_HELP) && (TheMessage->event != ME_MOUSEUPDATE)) {
@@ -2675,29 +2675,29 @@ void doT2DMouse(WGame &game) {
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_TONE_HELP_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_HELP_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Setta e Apre finestra Help
SetHelpWin(game._fonts, nullptr, 5, Sentence[init.Obj[oTONERHELP].text[0]],
- Sentence[init.Obj[oTONERHELP].text[1]], Sentence[init.Obj[oTONERHELP].text[2]],
- Sentence[init.Obj[oTONERHELP].text[3]], Sentence[init.Obj[oTONERHELP].text[4]]);
+ Sentence[init.Obj[oTONERHELP].text[1]], Sentence[init.Obj[oTONERHELP].text[2]],
+ Sentence[init.Obj[oTONERHELP].text[3]], Sentence[init.Obj[oTONERHELP].text[4]]);
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_HELP, 0, TRUE, nullptr, nullptr,
- nullptr);
+ nullptr);
} else if ((CurButton == T2D_BT_PDA_TONE_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_TONE_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_EXIT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Chiude finestra help
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr,
- nullptr);
+ nullptr);
//Chiude finestra Tone
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_TONE, 0, FALSE, nullptr, nullptr,
- nullptr);
+ nullptr);
} else if ((CurButton == T2D_BT_PDA_TONE_ACQUIRE) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Disattiva tasto
w->bt[T2D_BT_PDA_TONE_ACQUIRE].on = FALSE;
@@ -2705,12 +2705,12 @@ void doT2DMouse(WGame &game) {
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_TONE_ACQUIRE_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_ACQUIRE_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Fa partire sequenza di aquiring
Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_WAITA, 0, 0, T2D_PDA_TONE_AQUIRING, nullptr, nullptr,
- nullptr);
+ nullptr);
} else if ((CurButton == T2D_BT_PDA_TONE_PROCESS) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Disattiva tasto
w->bt[T2D_BT_PDA_TONE_PROCESS].on = FALSE;
@@ -2718,12 +2718,12 @@ void doT2DMouse(WGame &game) {
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_TONE_PROCESS_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_PROCESS_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Fa partire sequenza di processing
Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_WAITA, 0, 0, T2D_PDA_TONE_PROCESS, nullptr, nullptr,
- nullptr);
+ nullptr);
if (!(init.InvObj[i28WALKMANOK].flags & EXTRA2))
IncCurTime(game, 5);
init.InvObj[i28WALKMANOK].flags |= EXTRA2;
@@ -2739,12 +2739,12 @@ void doT2DMouse(WGame &game) {
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_HELP_EXIT_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_HELP, T2D_BM_PDA_HELP_EXIT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ FALSE, nullptr, nullptr, nullptr);
//Chiude finestra Tone
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr,
- nullptr);
+ nullptr);
if (HelpFunc != NULL) HelpFunc();
}
}
@@ -2757,110 +2757,110 @@ void doT2DMouse(WGame &game) {
if (optionsSaveDescriptActive) break;
if (CurButtonWin == T2D_WIN_OPTIONS_MAIN) {
if ((
- ((CurButton == T2D_BT_OPTIONS_SAVE) && PlayerCanSave()) ||
- (CurButton == T2D_BT_OPTIONS_LOAD) ||
- (CurButton == T2D_BT_OPTIONS_OPTIONS)
- ) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ ((CurButton == T2D_BT_OPTIONS_SAVE) && PlayerCanSave()) ||
+ (CurButton == T2D_BT_OPTIONS_LOAD) ||
+ (CurButton == T2D_BT_OPTIONS_OPTIONS)
+ ) &&
+ (TheMessage->event != ME_MOUSEUPDATE)) {
//Cambia finestra
if (optionsCurrent != CurButton) {
switch (optionsCurrent) {
- case T2D_BT_OPTIONS_SAVE:
- w->bm[T2D_BM_OPTIONS_CONTORNO].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SAVE].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_GRIGLIA].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_FRECCIA_SU_OFF].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_OFF].tnum |= T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_FRECCIA_SU].on = FALSE;
- w->bt[T2D_BT_OPTIONS_FRECCIA_GIU].on = FALSE;
- break;
- case T2D_BT_OPTIONS_LOAD:
- w->bm[T2D_BM_OPTIONS_CONTORNO].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_LOAD].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_GRIGLIA].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_FRECCIA_SU_OFF].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_OFF].tnum |= T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_FRECCIA_SU].on = FALSE;
- w->bt[T2D_BT_OPTIONS_FRECCIA_GIU].on = FALSE;
- break;
- case T2D_BT_OPTIONS_OPTIONS:
- w->bm[T2D_BM_OPTIONS_CONTORNO].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SOUND_ON].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_MUSIC_ON].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SPEECH_ON].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SUBTITLES_ON].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SOUND_OFF].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_MUSIC_OFF].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SPEECH_OFF].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SUBTITLES_OFF].tnum |= T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_SOUND].on = false;
- w->bt[T2D_BT_OPTIONS_MUSIC].on = false;
- w->bt[T2D_BT_OPTIONS_SPEECH].on = false;
- w->bt[T2D_BT_OPTIONS_SUBTITLES].on = false;
- w->bm[T2D_BM_OPTIONS_SOUND_BARRA].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SOUND_PIROLO].tnum |= T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_SOUND_BARRA].on = false;
- w->bm[T2D_BM_OPTIONS_MUSIC_BARRA].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_MUSIC_PIROLO].tnum |= T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_MUSIC_BARRA].on = false;
- w->bm[T2D_BM_OPTIONS_SPEECH_BARRA].tnum |= T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SPEECH_PIROLO].tnum |= T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_SPEECH_BARRA].on = false;
- break;
+ case T2D_BT_OPTIONS_SAVE:
+ w->bm[T2D_BM_OPTIONS_CONTORNO].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SAVE].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_GRIGLIA].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_FRECCIA_SU_OFF].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_OFF].tnum |= T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_FRECCIA_SU].on = FALSE;
+ w->bt[T2D_BT_OPTIONS_FRECCIA_GIU].on = FALSE;
+ break;
+ case T2D_BT_OPTIONS_LOAD:
+ w->bm[T2D_BM_OPTIONS_CONTORNO].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_LOAD].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_GRIGLIA].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_FRECCIA_SU_OFF].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_OFF].tnum |= T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_FRECCIA_SU].on = FALSE;
+ w->bt[T2D_BT_OPTIONS_FRECCIA_GIU].on = FALSE;
+ break;
+ case T2D_BT_OPTIONS_OPTIONS:
+ w->bm[T2D_BM_OPTIONS_CONTORNO].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SOUND_ON].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_MUSIC_ON].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SPEECH_ON].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SUBTITLES_ON].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SOUND_OFF].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_MUSIC_OFF].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SPEECH_OFF].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SUBTITLES_OFF].tnum |= T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_SOUND].on = false;
+ w->bt[T2D_BT_OPTIONS_MUSIC].on = false;
+ w->bt[T2D_BT_OPTIONS_SPEECH].on = false;
+ w->bt[T2D_BT_OPTIONS_SUBTITLES].on = false;
+ w->bm[T2D_BM_OPTIONS_SOUND_BARRA].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SOUND_PIROLO].tnum |= T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_SOUND_BARRA].on = false;
+ w->bm[T2D_BM_OPTIONS_MUSIC_BARRA].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_MUSIC_PIROLO].tnum |= T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_MUSIC_BARRA].on = false;
+ w->bm[T2D_BM_OPTIONS_SPEECH_BARRA].tnum |= T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SPEECH_PIROLO].tnum |= T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_SPEECH_BARRA].on = false;
+ break;
}
switch (CurButton) {
- case T2D_BT_OPTIONS_SAVE:
- w->bm[T2D_BM_OPTIONS_CONTORNO].tnum &= ~T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SAVE].tnum &= ~T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_GRIGLIA].tnum &= ~T2D_BM_OFF;
- RefreshSaveImg(game, 0, 0);
- break;
- case T2D_BT_OPTIONS_LOAD:
- w->bm[T2D_BM_OPTIONS_CONTORNO].tnum &= ~T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_LOAD].tnum &= ~T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_GRIGLIA].tnum &= ~T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_FRECCIA_SU_OFF].tnum &= ~T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_OFF].tnum &= ~T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_FRECCIA_SU].on = TRUE;
- w->bt[T2D_BT_OPTIONS_FRECCIA_GIU].on = TRUE;
- RefreshSaveImg(game, 0, 1);
- break;
- case T2D_BT_OPTIONS_OPTIONS:
- w->bm[T2D_BM_OPTIONS_CONTORNO].tnum &= ~T2D_BM_OFF;
- if (game.gameOptions.sound_on)
- w->bm[T2D_BM_OPTIONS_SOUND_ON].tnum &= ~T2D_BM_OFF;
- else w->bm[T2D_BM_OPTIONS_SOUND_OFF].tnum &= ~T2D_BM_OFF;
- if (game.gameOptions.music_on)
- w->bm[T2D_BM_OPTIONS_MUSIC_ON].tnum &= ~T2D_BM_OFF;
- else w->bm[T2D_BM_OPTIONS_MUSIC_OFF].tnum &= ~T2D_BM_OFF;
- if (game.gameOptions.speech_on)
- w->bm[T2D_BM_OPTIONS_SPEECH_ON].tnum &= ~T2D_BM_OFF;
- else w->bm[T2D_BM_OPTIONS_SPEECH_OFF].tnum &= ~T2D_BM_OFF;
- if (game.gameOptions.subtitles_on)
- w->bm[T2D_BM_OPTIONS_SUBTITLES_ON].tnum &= ~T2D_BM_OFF;
- else w->bm[T2D_BM_OPTIONS_SUBTITLES_OFF].tnum &= ~T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_SOUND].on = TRUE;
- w->bt[T2D_BT_OPTIONS_MUSIC].on = TRUE;
- w->bt[T2D_BT_OPTIONS_SPEECH].on = TRUE;
- w->bt[T2D_BT_OPTIONS_SUBTITLES].on = TRUE;
- w->bm[T2D_BM_OPTIONS_SOUND_BARRA].tnum &= ~T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SOUND_PIROLO].tnum &= ~T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_SOUND_BARRA].on = TRUE;
- w->bm[T2D_BM_OPTIONS_MUSIC_BARRA].tnum &= ~T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_MUSIC_PIROLO].tnum &= ~T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_MUSIC_BARRA].on = TRUE;
- w->bm[T2D_BM_OPTIONS_SPEECH_BARRA].tnum &= ~T2D_BM_OFF;
- w->bm[T2D_BM_OPTIONS_SPEECH_PIROLO].tnum &= ~T2D_BM_OFF;
- w->bt[T2D_BT_OPTIONS_SPEECH_BARRA].on = TRUE;
- GestioneBarra(&w->bm[T2D_BM_OPTIONS_SOUND_BARRA], &w->bm[T2D_BM_OPTIONS_SOUND_PIROLO],
- -1, game.gameOptions.sound_volume);
- GestioneBarra(&w->bm[T2D_BM_OPTIONS_MUSIC_BARRA], &w->bm[T2D_BM_OPTIONS_MUSIC_PIROLO],
- -1, game.gameOptions.music_volume);
- GestioneBarra(&w->bm[T2D_BM_OPTIONS_SPEECH_BARRA], &w->bm[T2D_BM_OPTIONS_SPEECH_PIROLO],
- -1, game.gameOptions.speech_volume);
- RefreshSaveImg(game, 0, 2);
- break;
+ case T2D_BT_OPTIONS_SAVE:
+ w->bm[T2D_BM_OPTIONS_CONTORNO].tnum &= ~T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SAVE].tnum &= ~T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_GRIGLIA].tnum &= ~T2D_BM_OFF;
+ RefreshSaveImg(game, 0, 0);
+ break;
+ case T2D_BT_OPTIONS_LOAD:
+ w->bm[T2D_BM_OPTIONS_CONTORNO].tnum &= ~T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_LOAD].tnum &= ~T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_GRIGLIA].tnum &= ~T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_FRECCIA_SU_OFF].tnum &= ~T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_OFF].tnum &= ~T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_FRECCIA_SU].on = TRUE;
+ w->bt[T2D_BT_OPTIONS_FRECCIA_GIU].on = TRUE;
+ RefreshSaveImg(game, 0, 1);
+ break;
+ case T2D_BT_OPTIONS_OPTIONS:
+ w->bm[T2D_BM_OPTIONS_CONTORNO].tnum &= ~T2D_BM_OFF;
+ if (game.gameOptions.sound_on)
+ w->bm[T2D_BM_OPTIONS_SOUND_ON].tnum &= ~T2D_BM_OFF;
+ else w->bm[T2D_BM_OPTIONS_SOUND_OFF].tnum &= ~T2D_BM_OFF;
+ if (game.gameOptions.music_on)
+ w->bm[T2D_BM_OPTIONS_MUSIC_ON].tnum &= ~T2D_BM_OFF;
+ else w->bm[T2D_BM_OPTIONS_MUSIC_OFF].tnum &= ~T2D_BM_OFF;
+ if (game.gameOptions.speech_on)
+ w->bm[T2D_BM_OPTIONS_SPEECH_ON].tnum &= ~T2D_BM_OFF;
+ else w->bm[T2D_BM_OPTIONS_SPEECH_OFF].tnum &= ~T2D_BM_OFF;
+ if (game.gameOptions.subtitles_on)
+ w->bm[T2D_BM_OPTIONS_SUBTITLES_ON].tnum &= ~T2D_BM_OFF;
+ else w->bm[T2D_BM_OPTIONS_SUBTITLES_OFF].tnum &= ~T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_SOUND].on = TRUE;
+ w->bt[T2D_BT_OPTIONS_MUSIC].on = TRUE;
+ w->bt[T2D_BT_OPTIONS_SPEECH].on = TRUE;
+ w->bt[T2D_BT_OPTIONS_SUBTITLES].on = TRUE;
+ w->bm[T2D_BM_OPTIONS_SOUND_BARRA].tnum &= ~T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SOUND_PIROLO].tnum &= ~T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_SOUND_BARRA].on = TRUE;
+ w->bm[T2D_BM_OPTIONS_MUSIC_BARRA].tnum &= ~T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_MUSIC_PIROLO].tnum &= ~T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_MUSIC_BARRA].on = TRUE;
+ w->bm[T2D_BM_OPTIONS_SPEECH_BARRA].tnum &= ~T2D_BM_OFF;
+ w->bm[T2D_BM_OPTIONS_SPEECH_PIROLO].tnum &= ~T2D_BM_OFF;
+ w->bt[T2D_BT_OPTIONS_SPEECH_BARRA].on = TRUE;
+ GestioneBarra(&w->bm[T2D_BM_OPTIONS_SOUND_BARRA], &w->bm[T2D_BM_OPTIONS_SOUND_PIROLO],
+ -1, game.gameOptions.sound_volume);
+ GestioneBarra(&w->bm[T2D_BM_OPTIONS_MUSIC_BARRA], &w->bm[T2D_BM_OPTIONS_MUSIC_PIROLO],
+ -1, game.gameOptions.music_volume);
+ GestioneBarra(&w->bm[T2D_BM_OPTIONS_SPEECH_BARRA], &w->bm[T2D_BM_OPTIONS_SPEECH_PIROLO],
+ -1, game.gameOptions.speech_volume);
+ RefreshSaveImg(game, 0, 2);
+ break;
}
if ((CurButton == T2D_BT_OPTIONS_SAVE) || (CurButton == T2D_BT_OPTIONS_LOAD)) {
@@ -2883,79 +2883,79 @@ void doT2DMouse(WGame &game) {
optionsCurrent = CurButton;
}
} else if ((CurButton >= T2D_BT_OPTIONS_SAVE_START) && (CurButton <= T2D_BT_OPTIONS_SAVE_END) &&
- (TheMessage->event != ME_MOUSEUPDATE)) {
+ (TheMessage->event != ME_MOUSEUPDATE)) {
optionsWhat = CurButton - T2D_BT_OPTIONS_SAVE_START;
if (optionsSaves[optionsWhat][0] == 0) break;
switch (optionsCurrent) {
- case T2D_BT_OPTIONS_SAVE:
- optionsSlot = -1;
+ case T2D_BT_OPTIONS_SAVE:
+ optionsSlot = -1;
- if (optionsCurPos + optionsWhat == 0) {
- for (i = 0; i < T2D_OPTIONS_MAX_SAVES; i++) {
- int afret;
+ if (optionsCurPos + optionsWhat == 0) {
+ for (i = 0; i < T2D_OPTIONS_MAX_SAVES; i++) {
+ int afret;
- sprintf(Name, "%sWm%02d.sav", game.workDirs._savesDir.c_str(), i + 1);
+ sprintf(Name, "%sWm%02d.sav", game.workDirs._savesDir.c_str(), i + 1);
- t3dForceNOFastFile(1);
- afret = t3dAccessFile(Name);
- t3dForceNOFastFile(0);
+ t3dForceNOFastFile(1);
+ afret = t3dAccessFile(Name);
+ t3dForceNOFastFile(0);
- if (!afret) {
- optionsSlot = i + 1;
- break;
- }
+ if (!afret) {
+ optionsSlot = i + 1;
+ break;
}
- } else optionsSlot = Saves[optionsCurPos + optionsWhat - 1].NFile;
+ }
+ } else optionsSlot = Saves[optionsCurPos + optionsWhat - 1].NFile;
- if (optionsSlot == -1) break; //Spazi finiti
+ if (optionsSlot == -1) break; //Spazi finiti
- GetLocalTime(&sysTime);
- sprintf(Text, "%02d:%02d.%02d %02d/%02d/%02d", sysTime.hour, sysTime.minutes,
- sysTime.seconds, sysTime.day, sysTime.month, sysTime.year);
- if (DataSave(Text, (uint8) optionsSlot)) {
- sprintf(Text, "%stemp.tmp", game.workDirs._gameDir.c_str());
- sprintf(Name, "%sWmSav%02d.tga", game.workDirs._savesDir.c_str(), optionsSlot);
- CopyFile(Text, Name, FALSE);
- } else {
- DebugLogFile("DataSave(slot %d) Failed. Quitting ...", optionsSlot);
- CloseSys(game);
- }
+ GetLocalTime(&sysTime);
+ sprintf(Text, "%02d:%02d.%02d %02d/%02d/%02d", sysTime.hour, sysTime.minutes,
+ sysTime.seconds, sysTime.day, sysTime.month, sysTime.year);
+ if (DataSave(Text, (uint8) optionsSlot)) {
+ sprintf(Text, "%stemp.tmp", game.workDirs._gameDir.c_str());
+ sprintf(Name, "%sWmSav%02d.tga", game.workDirs._savesDir.c_str(), optionsSlot);
+ CopyFile(Text, Name, FALSE);
+ } else {
+ DebugLogFile("DataSave(slot %d) Failed. Quitting ...", optionsSlot);
+ CloseSys(game);
+ }
- CaricaSaves(game);
- SortSaves();
- RefreshSaveImg(game, optionsCurPos, 0);
- break;
- case T2D_BT_OPTIONS_LOAD:
- bShowOnlyLoadWindow = 0;
- i = Saves[optionsCurPos + optionsWhat].NFile;
- sprintf(Name, "%sWm%02d.sav", game.workDirs._savesDir.c_str(), i);
- if (!DataLoad(game, "", (uint8) i)) {
- DebugLogFile("DataLoad(slot %d) Failed. Quitting ...", i);
- CloseSys(game);
- }
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tOPTIONS, nullptr, nullptr,
- nullptr);
- break;
+ CaricaSaves(game);
+ SortSaves();
+ RefreshSaveImg(game, optionsCurPos, 0);
+ break;
+ case T2D_BT_OPTIONS_LOAD:
+ bShowOnlyLoadWindow = 0;
+ i = Saves[optionsCurPos + optionsWhat].NFile;
+ sprintf(Name, "%sWm%02d.sav", game.workDirs._savesDir.c_str(), i);
+ if (!DataLoad(game, "", (uint8) i)) {
+ DebugLogFile("DataLoad(slot %d) Failed. Quitting ...", i);
+ CloseSys(game);
+ }
+ Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tOPTIONS, nullptr, nullptr,
+ nullptr);
+ break;
}
} else if ((CurButton == T2D_BT_OPTIONS_FRECCIA_SU) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_OPTIONS_FRECCIA_SU_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_OPTIONS_MAIN,
- T2D_BM_OPTIONS_FRECCIA_SU_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_OPTIONS_FRECCIA_SU_ON, FALSE, nullptr, nullptr, nullptr);
//Scrolling Up
if (optionsCurPos > 0) {
optionsCurPos -= 3;
if (optionsCurPos < 0) optionsCurPos = 0;
switch (optionsCurrent) {
- case T2D_BT_OPTIONS_SAVE:
- RefreshSaveImg(game, optionsCurPos, 0);
- break;
- case T2D_BT_OPTIONS_LOAD:
- RefreshSaveImg(game, optionsCurPos, 1);
- break;
+ case T2D_BT_OPTIONS_SAVE:
+ RefreshSaveImg(game, optionsCurPos, 0);
+ break;
+ case T2D_BT_OPTIONS_LOAD:
+ RefreshSaveImg(game, optionsCurPos, 1);
+ break;
}
}
@@ -2977,9 +2977,9 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_ON].tnum &= ~T2D_BM_OFF;
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_OPTIONS_MAIN,
- T2D_BM_OPTIONS_FRECCIA_GIU_ON, FALSE, nullptr, nullptr, nullptr);
+ T2D_BM_OPTIONS_FRECCIA_GIU_ON, FALSE, nullptr, nullptr, nullptr);
if (optionsCurPos + 6 > NSaves) break;
if (optionsCurPos + 3 >= T2D_OPTIONS_MAX_SAVES) break;
//Scrolling Down
@@ -2987,12 +2987,12 @@ void doT2DMouse(WGame &game) {
optionsCurPos += 2;
else optionsCurPos += 3;
switch (optionsCurrent) {
- case T2D_BT_OPTIONS_SAVE:
- RefreshSaveImg(game, optionsCurPos, 0);
- break;
- case T2D_BT_OPTIONS_LOAD:
- RefreshSaveImg(game, optionsCurPos, 1);
- break;
+ case T2D_BT_OPTIONS_SAVE:
+ RefreshSaveImg(game, optionsCurPos, 0);
+ break;
+ case T2D_BT_OPTIONS_LOAD:
+ RefreshSaveImg(game, optionsCurPos, 1);
+ break;
}
if (optionsCurPos > 0) {
@@ -3019,7 +3019,7 @@ void doT2DMouse(WGame &game) {
if (TheMessage->event != ME_MOUSEUPDATE) {
bShowOnlyLoadWindow = 0;
Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_MAINMENU, 0, tOPTIONS,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr);
} else {
w->bm[T2D_BM_OPTIONS_MAINMENU_OFF].tnum |= T2D_BM_OFF;
w->bm[T2D_BM_OPTIONS_MAINMENU_ON].tnum &= ~T2D_BM_OFF;
@@ -3032,7 +3032,7 @@ void doT2DMouse(WGame &game) {
if (init.Room[i].flags & ROOM_VISIBLE) {
for (a = 0; a < MAX_SOUNDS_IN_ROOM; a++)
if ((init.Room[i].sounds[a]) &&
- (init.Sound[init.Room[i].sounds[a]].flags & SOUND_ON))
+ (init.Sound[init.Room[i].sounds[a]].flags & SOUND_ON))
StartSound(game, init.Room[i].sounds[a]);
}
}
@@ -3084,7 +3084,7 @@ void doT2DMouse(WGame &game) {
}
} else if (CurButton == T2D_BT_OPTIONS_SOUND_BARRA) {
if (bLPressed || bRPressed || (TheMessage->event == ME_MLEFT) ||
- (TheMessage->event == ME_MRIGHT))
+ (TheMessage->event == ME_MRIGHT))
PiroloGrab = 1;
if (PiroloGrab == 1) {
game.gameOptions.sound_volume = GestioneBarra(&w->bm[T2D_BM_OPTIONS_SOUND_BARRA],
@@ -3093,16 +3093,16 @@ void doT2DMouse(WGame &game) {
}
} else if (CurButton == T2D_BT_OPTIONS_MUSIC_BARRA) {
if (bLPressed || bRPressed || (TheMessage->event == ME_MLEFT) ||
- (TheMessage->event == ME_MRIGHT))
+ (TheMessage->event == ME_MRIGHT))
PiroloGrab = 2;
if (PiroloGrab == 2) {
game.gameOptions.music_volume = GestioneBarra(&w->bm[T2D_BM_OPTIONS_MUSIC_BARRA],
- &w->bm[T2D_BM_OPTIONS_MUSIC_PIROLO], mouse_x, -1);
+ &w->bm[T2D_BM_OPTIONS_MUSIC_PIROLO], mouse_x, -1);
mSetAllVolume(game.gameOptions.music_volume);
}
} else if (CurButton == T2D_BT_OPTIONS_SPEECH_BARRA) {
if (bLPressed || bRPressed || (TheMessage->event == ME_MLEFT) ||
- (TheMessage->event == ME_MRIGHT))
+ (TheMessage->event == ME_MRIGHT))
PiroloGrab = 3;
if (PiroloGrab == 3) {
game.gameOptions.speech_volume = GestioneBarra(&w->bm[T2D_BM_OPTIONS_SPEECH_BARRA],
@@ -3122,7 +3122,7 @@ void doT2DMouse(WGame &game) {
if (timeGetTime() >= (GameOverWindow_StartTime + GAMEOVER_WINDOW_NUM_MSECONDS)) {
LoadWindow_WhichBkg = 2;
Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_LOAD, 0, tMAINMENU, nullptr, nullptr,
- nullptr);
+ nullptr);
}
break;
}
diff --git a/engines/watchmaker/t3d.h b/engines/watchmaker/t3d.h
index f913ebbda0b..7a0227b07f2 100644
--- a/engines/watchmaker/t3d.h
+++ b/engines/watchmaker/t3d.h
@@ -185,7 +185,9 @@ struct t3dCAMERAGRID {
};
struct t3dCAMERAPATH {
- uint16 NumPoints() { return PList.size(); } // num points in path
+ uint16 NumPoints() {
+ return PList.size(); // num points in path
+ }
Common::Array<t3dV3F> PList; // points list
uint32 CarrelloDist = 0; // if carrello: max distance from the target
public:
@@ -201,7 +203,9 @@ struct t3dCAMERA {
t3dV2F Center; // cam center
t3dM3X3F Matrix; // cam view matrix
t3dF32 NearClipPlane = 0.0f, FarClipPlane = 0.0f; // camera planes
- uint8 NumAvailablePaths() const { return CameraPaths.size(); } // num camera paths
+ uint8 NumAvailablePaths() const {
+ return CameraPaths.size(); // num camera paths
+ }
uint8 Index = 0; // cam index 9in room
Common::Array<t3dPathCamera> CameraPaths; // paths list
public:
@@ -246,8 +250,10 @@ public:
};
struct t3dAnimLight {
- Common::Array<gVertex*> VisVerts; // pointer to visible vertices from lights
- uint16 NumVisVerts() const { return VisVerts.size(); } // num visible vertices from lights
+ Common::Array<gVertex *> VisVerts; // pointer to visible vertices from lights
+ uint16 NumVisVerts() const {
+ return VisVerts.size(); // num visible vertices from lights
+ }
//t3dU32 *SavedLightColor; // pointer to original vartex illumination
int8 LastRandomizer; // randomizer for flicker effects
};
@@ -275,7 +281,7 @@ private:
void setupVisibleVerticesFromLight(t3dBODY *b);
void SetVisibleFromLight(gVertex *v);
};
-typedef t3dLIGHT* LightPtr;
+typedef t3dLIGHT *LightPtr;
struct t3dPLIGHT {
uint8 Num = 0; // index positional light in room
diff --git a/engines/watchmaker/walk/act.cpp b/engines/watchmaker/walk/act.cpp
index 6406fb30730..c5c6e8b72f6 100644
--- a/engines/watchmaker/walk/act.cpp
+++ b/engines/watchmaker/walk/act.cpp
@@ -43,19 +43,17 @@ int32 NumCurve;
void FixupCurAction(int32 oc);
/* -----------------28/04/98 17.51-------------------
- * SlideChar
+ * SlideChar
* --------------------------------------------------*/
-void SlideChar(int32 oc )
-{
- t3dCHARACTER *Ch=Character[oc];
- t3dWALK *w=&Ch->Walk;
- t3dF32 r,len,x1,x2,z1,z2;
+void SlideChar(int32 oc) {
+ t3dCHARACTER *Ch = Character[oc];
+ t3dWALK *w = &Ch->Walk;
+ t3dF32 r, len, x1, x2, z1, z2;
int16 nf;
t3dV3F v;
- if( /*!( w->Check & CLICKINTO ) &&*/ ( w->CurPanel < 0 ) )
- {
- CharStop( oc );
+ if (/*!( w->Check & CLICKINTO ) &&*/ (w->CurPanel < 0)) {
+ CharStop(oc);
return ;
}
@@ -67,46 +65,37 @@ void SlideChar(int32 oc )
z1 = w->Panel[w->CurPanel].z1;
x2 = w->Panel[w->CurPanel].x2;
z2 = w->Panel[w->CurPanel].z2;
- if( ( len = (x1-x2)*(x1-x2) + (z1-z2)*(z1-z2) ) == 0 )
- {
- CharStop( oc );
+ if ((len = (x1 - x2) * (x1 - x2) + (z1 - z2) * (z1 - z2)) == 0) {
+ CharStop(oc);
return ;
}
- r = ((z1-v.z)*(z1-z2)-(x1-v.x)*(x2-x1)) / len;
+ r = ((z1 - v.z) * (z1 - z2) - (x1 - v.x) * (x2 - x1)) / len;
- if( r>1.0f ) // a destra di 2
- {
+ if (r > 1.0f) { // a destra di 2
x1 = x2;
z1 = z2;
- }
- else if( r>0.0f ) // dentro 1..2
- {
- x1 += r*(x2-x1);
- z1 += r*(z2-z1);
+ } else if (r > 0.0f) { // dentro 1..2
+ x1 += r * (x2 - x1);
+ z1 += r * (z2 - z1);
}
- nf = w->CurFrame+1;
- if( ( w->CurAction == aWALK_START ) || ( w->CurAction == aWALK_LOOP ) || ( w->CurAction == aWALK_END ) )
- {
- if ( nf >= (ActionStart[aWALK_LOOP]+ActionLen[aWALK_LOOP]) )
+ nf = w->CurFrame + 1;
+ if ((w->CurAction == aWALK_START) || (w->CurAction == aWALK_LOOP) || (w->CurAction == aWALK_END)) {
+ if (nf >= (ActionStart[aWALK_LOOP] + ActionLen[aWALK_LOOP]))
nf = ActionStart[aWALK_LOOP];
- }
- else if( ( w->CurAction == aBACK_START ) || ( w->CurAction == aBACK_LOOP ) || ( w->CurAction == aBACK_END ) )
- {
- if ( nf >= (ActionStart[aBACK_LOOP]+ActionLen[aBACK_LOOP]) )
+ } else if ((w->CurAction == aBACK_START) || (w->CurAction == aBACK_LOOP) || (w->CurAction == aBACK_END)) {
+ if (nf >= (ActionStart[aBACK_LOOP] + ActionLen[aBACK_LOOP]))
nf = ActionStart[aBACK_LOOP];
- }
- else if( ( w->CurAction == aRUN_START ) || ( w->CurAction == aRUN_LOOP ) || ( w->CurAction == aRUN_END ) )
- {
- if ( nf >= (ActionStart[aRUN_LOOP]+ActionLen[aRUN_LOOP]) )
+ } else if ((w->CurAction == aRUN_START) || (w->CurAction == aRUN_LOOP) || (w->CurAction == aRUN_END)) {
+ if (nf >= (ActionStart[aRUN_LOOP] + ActionLen[aRUN_LOOP]))
nf = ActionStart[aRUN_LOOP];
}
w->NumPathNodes = w->CurrentStep = 0;
w->WalkSteps[0].curp = w->CurPanel;
- w->WalkSteps[0].Angle = SinCosAngle( Ch->Dir.x, Ch->Dir.z );
+ w->WalkSteps[0].Angle = SinCosAngle(Ch->Dir.x, Ch->Dir.z);
w->WalkSteps[0].Frame = nf;
w->WalkSteps[0].Pos.x = x1;
@@ -119,79 +108,72 @@ void SlideChar(int32 oc )
}
/* -----------------07/05/98 11.15-------------------
- * UpdateChar
+ * UpdateChar
* --------------------------------------------------*/
-void UpdateChar(WGame &game, int32 oc, t3dF32 Speed, t3dF32 Rot )
-{
- t3dCHARACTER *Char=Character[oc];
- t3dWALK *w=&Char->Walk;
- t3dV3F Pos,tmp;
+void UpdateChar(WGame &game, int32 oc, t3dF32 Speed, t3dF32 Rot) {
+ t3dCHARACTER *Char = Character[oc];
+ t3dWALK *w = &Char->Walk;
+ t3dV3F Pos, tmp;
t3dM3X3F mx;
- if( !Char ) return ;
+ if (!Char) return ;
- if( ( Speed == 0.0f ) && ( w->NumSteps == 0 ) && ( ( w->CurAction != aROT_DX && w->CurAction != aROT_SX ) || ( Rot == 0.0f ) ) )
- {
- if( ( Char->Mesh->Flags & T3D_MESH_DEFAULTANIM ) )
- CharStop( oc );
+ if ((Speed == 0.0f) && (w->NumSteps == 0) && ((w->CurAction != aROT_DX && w->CurAction != aROT_SX) || (Rot == 0.0f))) {
+ if ((Char->Mesh->Flags & T3D_MESH_DEFAULTANIM))
+ CharStop(oc);
return;
}
- Event(EventClass::MC_MOUSE,ME_MOUSEHIDE,MP_DEFAULT,0,0,0,NULL,NULL,NULL);
- if ( Char && Speed )
- CharNextFrame( game, oc );
+ Event(EventClass::MC_MOUSE, ME_MOUSEHIDE, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
+ if (Char && Speed)
+ CharNextFrame(game, oc);
// Ruota l'omino
- t3dVectCopy( &tmp, &Char->Dir );tmp.z = -tmp.z; tmp.y = 0.0f;
- t3dVectAdd( &tmp, &Char->Pos, &tmp );
+ t3dVectCopy(&tmp, &Char->Dir);
+ tmp.z = -tmp.z;
+ tmp.y = 0.0f;
+ t3dVectAdd(&tmp, &Char->Pos, &tmp);
t3dMatView(&Char->Mesh->Matrix, &Char->Pos, &tmp);
- t3dMatRot( &mx, 0.0f, Rot, 0.0f );
- t3dMatMul( &Char->Mesh->Matrix, &mx, &Char->Mesh->Matrix );
+ t3dMatRot(&mx, 0.0f, Rot, 0.0f);
+ t3dMatMul(&Char->Mesh->Matrix, &mx, &Char->Mesh->Matrix);
Char->Mesh->Matrix.Flags &= ~T3D_MATRIX_IDENTITY;
- t3dVectInit( &Char->Dir, 0.0f, 0.0f, -1.0f );
- t3dVectTransform( &Char->Dir, &Char->Dir, &Char->Mesh->Matrix ); //rotate by Character angle
+ t3dVectInit(&Char->Dir, 0.0f, 0.0f, -1.0f);
+ t3dVectTransform(&Char->Dir, &Char->Dir, &Char->Mesh->Matrix); //rotate by Character angle
- if( Speed )
- {
+ if (Speed) {
FloorHit = 1;
Pos.y = CurFloorY;
- if( Speed > 0.0f )
- {
- if ( bFastWalk )
- {
- if( ( w->CurFrame >= ActionStart[aRUN_END] ) || ( w->CurFrame < ActionStart[aRUN_START] ) )
+ if (Speed > 0.0f) {
+ if (bFastWalk) {
+ if ((w->CurFrame >= ActionStart[aRUN_END]) || (w->CurFrame < ActionStart[aRUN_START]))
w->CurFrame = ActionStart[aRUN_START];
- }
- else if( ( w->CurFrame >= ActionStart[aWALK_END] ) || ( w->CurFrame < ActionStart[aWALK_START] ) )
+ } else if ((w->CurFrame >= ActionStart[aWALK_END]) || (w->CurFrame < ActionStart[aWALK_START]))
w->CurFrame = ActionStart[aWALK_START];
- }
- else if( ( Speed < 0.0f ) && ( ( w->CurFrame >= ActionStart[aBACK_END] ) || ( w->CurFrame < ActionStart[aBACK_START] ) ) )
+ } else if ((Speed < 0.0f) && ((w->CurFrame >= ActionStart[aBACK_END]) || (w->CurFrame < ActionStart[aBACK_START])))
w->CurFrame = ActionStart[aBACK_START];
- Speed = - Char->Mesh->DefaultAnim.Dist[w->CurFrame+1] + Char->Mesh->DefaultAnim.Dist[w->CurFrame];
- FixupCurAction( ocCURPLAYER );
+ Speed = - Char->Mesh->DefaultAnim.Dist[w->CurFrame + 1] + Char->Mesh->DefaultAnim.Dist[w->CurFrame];
+ FixupCurAction(ocCURPLAYER);
tmp = Char->Dir * Speed;
- t3dVectAdd( &Pos, &Char->Pos, &tmp );
- PlayerPos[CurPlayer+ocDARRELL] = 0;
- PlayerGotoPos[CurPlayer+ocDARRELL] = 0;
- CheckCharacterWithBounds( game, oc, &Pos, 0, (uint8)((Speed < 0.0f ) ? 2 : (bFastWalk ? 1 : 0) ) );
- if( !( Char->Walk.Check & CLICKINTO ) && ( Char->Walk.NumSteps ) )
- {
-// fa solo 2 frames: il primo come l'attuale
- Char->Walk.WalkSteps[1].curp = Char->Walk.WalkSteps[Char->Walk.NumSteps-1].curp;
- Char->Walk.WalkSteps[0].curp = Char->Walk.WalkSteps[Char->Walk.NumSteps-1].curp;
+ t3dVectAdd(&Pos, &Char->Pos, &tmp);
+ PlayerPos[CurPlayer + ocDARRELL] = 0;
+ PlayerGotoPos[CurPlayer + ocDARRELL] = 0;
+ CheckCharacterWithBounds(game, oc, &Pos, 0, (uint8)((Speed < 0.0f) ? 2 : (bFastWalk ? 1 : 0)));
+ if (!(Char->Walk.Check & CLICKINTO) && (Char->Walk.NumSteps)) {
+// fa solo 2 frames: il primo come l'attuale
+ Char->Walk.WalkSteps[1].curp = Char->Walk.WalkSteps[Char->Walk.NumSteps - 1].curp;
+ Char->Walk.WalkSteps[0].curp = Char->Walk.WalkSteps[Char->Walk.NumSteps - 1].curp;
Char->Walk.WalkSteps[1].Angle = Char->Walk.WalkSteps[0].Angle;
Char->Walk.WalkSteps[0].Angle = Char->Walk.WalkSteps[0].Angle;
Char->Walk.WalkSteps[2].Act = 0;
Char->Walk.NumSteps = 2;
Char->Walk.CurrentStep = 0;
- }
- else
- SlideChar( oc );
+ } else
+ SlideChar(oc);
- RemoveEvent( &Game, EventClass::MC_PLAYER, ME_ALL );
- Event(EventClass::MC_PLAYER,ME_PLAYERGOTO,MP_DEFAULT,0,0,0,NULL,NULL,NULL);
+ RemoveEvent(&Game, EventClass::MC_PLAYER, ME_ALL);
+ Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
}
}
diff --git a/engines/watchmaker/walk/act.h b/engines/watchmaker/walk/act.h
index f3d53982adc..7f442988eaa 100644
--- a/engines/watchmaker/walk/act.h
+++ b/engines/watchmaker/walk/act.h
@@ -38,7 +38,7 @@ bool CharGotoPosition(WGame &game, int32 oc, uint8 pos, uint8 back, int32 anim);
void FixPos(int32 oc);
void UpdateLook(int32 oc);
void BuildStepList(int32 oc, uint8 dp, uint8 back);
-void UpdateChar(WGame &game, int32 oc, t3dF32 Speed, t3dF32 Rot );
+void UpdateChar(WGame &game, int32 oc, t3dF32 Speed, t3dF32 Rot);
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/walk/ball.cpp b/engines/watchmaker/walk/ball.cpp
index c3732e770dd..2fa90bc8713 100644
--- a/engines/watchmaker/walk/ball.cpp
+++ b/engines/watchmaker/walk/ball.cpp
@@ -247,12 +247,12 @@ void UpdateBall(WGame &game, struct SPhys *p) {
DisplayDDBitmap(*game._renderer, GopherMap, windowInfo.width - rGetBitmapRealDimX(GopherMap), 0, 0, 0, 0, 0);
for (i = 0; i < MAX_GOPHERS; i++)
DisplayDDBitmap(*game._renderer, GopherPos[i], windowInfo.width - rGetBitmapRealDimX(GopherMap) +
- 130 + (int32)(Character[i + 1]->Mesh->Trasl.x / 255.0f * 0.341f) - rGetBitmapRealDimX(GopherPos[i]) / 2,
- 146 - (int32)(Character[i + 1]->Mesh->Trasl.z / 255.0f * 0.341f) - rGetBitmapRealDimY(GopherPos[i]) / 2, 0, 0, 0, 0);
+ 130 + (int32)(Character[i + 1]->Mesh->Trasl.x / 255.0f * 0.341f) - rGetBitmapRealDimX(GopherPos[i]) / 2,
+ 146 - (int32)(Character[i + 1]->Mesh->Trasl.z / 255.0f * 0.341f) - rGetBitmapRealDimY(GopherPos[i]) / 2, 0, 0, 0, 0);
if (bGolfMode)
DisplayDDBitmap(*game._renderer, GopherBall, windowInfo.width - rGetBitmapRealDimX(GopherMap) +
- 130 + (int32)(Palla50->Mesh->Trasl.x / 255.0f * 0.341f) - rGetBitmapRealDimX(GopherBall) / 2,
- 146 - (int32)(Palla50->Mesh->Trasl.z / 255.0f * 0.341f) - rGetBitmapRealDimY(GopherBall) / 2, 0, 0, 0, 0);
+ 130 + (int32)(Palla50->Mesh->Trasl.x / 255.0f * 0.341f) - rGetBitmapRealDimX(GopherBall) / 2,
+ 146 - (int32)(Palla50->Mesh->Trasl.z / 255.0f * 0.341f) - rGetBitmapRealDimY(GopherBall) / 2, 0, 0, 0, 0);
if ((bGolfMode == 0) || (bGolfMode == 1)) {
DebugVideo(*game._renderer, 10, 32, "TimeLeft: %d", (int32)p->TimeLeft);
p->TimeLeft -= p->Td;
diff --git a/engines/watchmaker/watchmaker.cpp b/engines/watchmaker/watchmaker.cpp
index 4ed47e565bd..ef07764b2ff 100644
--- a/engines/watchmaker/watchmaker.cpp
+++ b/engines/watchmaker/watchmaker.cpp
@@ -26,7 +26,7 @@
namespace Watchmaker {
WatchmakerGame::WatchmakerGame(OSystem *syst, const ADGameDescription *gameDesc) :
- Engine(syst), _gameDescription(gameDesc), _console(nullptr) {
+ Engine(syst), _gameDescription(gameDesc), _console(nullptr) {
}
WatchmakerGame::~WatchmakerGame() {
Commit: 4119ee5b1a7b8dfe31282925c341265edfd23516
https://github.com/scummvm/scummvm/commit/4119ee5b1a7b8dfe31282925c341265edfd23516
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix an unintentional if due to missing braces
Changed paths:
engines/watchmaker/classes/do_system.cpp
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index 627cc0481b6..9f38d019c6a 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -662,7 +662,7 @@ void InitMain(WGame &game) {
Event(EventClass::MC_SYSTEM, ME_START, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
if (!rClearBuffers(rCLEARBACKBUFFER | rCLEARZBUFFER)) // Cancella buffers
- //warning("Unable to clear backbuffers");
+ warning("Unable to clear backbuffers");
T1.tnum = T2.tnum = -1;
T1t = T2t = nullptr;
Commit: 1a234912703fa728a84a51417d0c2a181659eb33
https://github.com/scummvm/scummvm/commit/1a234912703fa728a84a51417d0c2a181659eb33
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Clear out some warnings
Changed paths:
engines/watchmaker/3d/animation.cpp
engines/watchmaker/3d/dds_header.cpp
engines/watchmaker/3d/geometry.cpp
engines/watchmaker/3d/loader.cpp
engines/watchmaker/3d/material.cpp
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/render/opengl_renderer.cpp
engines/watchmaker/3d/texture.h
engines/watchmaker/main.cpp
engines/watchmaker/render.cpp
engines/watchmaker/render.h
engines/watchmaker/renderer.cpp
engines/watchmaker/renderer.h
engines/watchmaker/schedule.cpp
engines/watchmaker/sdl_wrapper.cpp
engines/watchmaker/sdl_wrapper.h
engines/watchmaker/walk/walkutil.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index 8745988482e..53595993cf8 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -707,7 +707,6 @@ void ReleasePreloadedAnims() {
* --------------------------------------------------*/
uint8 CompareLightPosition(char *roomname, uint8 pos1, t3dV3F *pos2, t3dF32 acceptable_dist) {
t3dV3F p1;
- uint8 a;
t3dBODY *t;
int32 i;
diff --git a/engines/watchmaker/3d/dds_header.cpp b/engines/watchmaker/3d/dds_header.cpp
index dabf21f915f..1598e3e7e24 100644
--- a/engines/watchmaker/3d/dds_header.cpp
+++ b/engines/watchmaker/3d/dds_header.cpp
@@ -35,10 +35,10 @@ DDSHeader::DDSHeader(Common::SeekableReadStream &stream) {
// The size counts the datastructure, which doesn't include the magic
int initialPos = stream.pos();
uint32 size = stream.readUint32LE();
- uint32 flags = stream.readUint32LE();
+ /*uint32 flags = */ stream.readUint32LE();
this->height = stream.readUint32LE();
this->width = stream.readUint32LE();
- uint32 dataSize = stream.readUint32LE();
+ /*uint32 dataSize = */ stream.readUint32LE();
stream.seek(13 * 4, SEEK_CUR);
stream.readUint32LE();
uint32 pfFlags = stream.readUint32LE();
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index efbe1cb6678..9f5f3f1222c 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -200,7 +200,6 @@ uint8 t3dCheckBoundBox(t3dMESH &mesh) {
void t3dCheckBlockMesh(Common::Array<t3dMESH> &mt, uint32 NumMeshes, t3dMESH *blockmesh) {
t3dF32 xa, za, xb, zb, xc, zc, xd, zd;
t3dF32 r, s, divisor;
- t3dMESH *mesh;
uint32 i, j;
uint8 ref[4] = {2, 3, 6, 7};
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index 35cc59bb0b2..e29fd733f26 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -253,7 +253,6 @@ t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, uint1
warning("t3dLoadRoom(%s, b, %d, %d)", pname.c_str(), *NumBody, LoaderFlags);
struct _t3dLOADLIST *l;
t3dBODY *r, *rez;
- t3dBODY *body;
uint16 num, i;
// azzera tutto quello che c'era prima nella load list
@@ -268,15 +267,15 @@ t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, uint1
num = 0;
if (l->m) {
if ((rez = CheckIfAlreadyLoaded(l->pname)))
- body = l->m->PortalList = rez;
+ l->m->PortalList = rez;
else {
// if (l->m->Flags&T3D_MESH_PREPROCESSPORTAL)
// body=l->m->PortalList = t3dLoadSingleRoom( l->pname, l->m->PortalList, &num, (l->LoaderFlags|T3D_HALFTEXTURESIZE) );
// else
- body = l->m->PortalList = t3dLoadSingleRoom(game, l->pname, l->m->PortalList, &num, l->LoaderFlags);
+ l->m->PortalList = t3dLoadSingleRoom(game, l->pname, l->m->PortalList, &num, l->LoaderFlags);
}
} else
- body = r = t3dLoadSingleRoom(game, l->pname, b, NumBody, l->LoaderFlags);
+ r = t3dLoadSingleRoom(game, l->pname, b, NumBody, l->LoaderFlags);
*l = _t3dLOADLIST();
}
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index 73fc9907ce4..ffa5789a9d7 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -142,8 +142,6 @@ void rRemoveMaterials(Common::Array<Common::SharedPtr<gMaterial>> &m) {
}
Common::SharedPtr<gMaterial> rCopyMaterial(Common::SharedPtr<gMaterial> Mat1, Common::SharedPtr<gMaterial> Mat2) {
- int i;
-
if (!Mat1 || !Mat2)
return nullptr;
@@ -184,7 +182,7 @@ Common::SharedPtr<gMaterial> rCopyMaterial(Common::SharedPtr<gMaterial> Mat1, Co
if (Mat2->NumAddictionalMaterial)
Mat1->AddictionalMaterial.resize(Mat2->NumAddictionalMaterial); // TODO: Does this mean that we don't copy any extras?
- for (i = 0; i < Mat2->NumAddictionalMaterial; i++)
+ for (int i = 0; i < Mat2->NumAddictionalMaterial; i++)
rCopyMaterial(Mat1->AddictionalMaterial[i], Mat2->AddictionalMaterial[i]);
return Mat1;
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index ce4644c080d..6a885989322 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -41,8 +41,6 @@ namespace Watchmaker {
// Bitmap list
unsigned int gNumBitmapList = 0;
-uint16 *gFonts[10];
-unsigned int gNumFonts = 0;
gTexture gBitmapList[MAX_BITMAP_LIST];
Rect gBlitterExtends;
int gStencilBitDepth;
@@ -178,7 +176,7 @@ void renderTexture(WGame &game, gTexture &bitmap, Rect srcRect, Rect dstRect) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- bitmap.texture->bind();
+ bitmap._texture->bind();
glLoadIdentity();
glTranslatef(0, 0, 0.0);
@@ -215,7 +213,7 @@ void renderTexture(WGame &game, gTexture &bitmap, Rect srcRect, Rect dstRect) {
void gTexture::render(WGame &game, Rect src, Rect dst) {
// Render self
- if (texture) {
+ if (_texture) {
renderTexture(game, *this, src, dst);
}
for (int i = 0; i < _blitsOnTop.size(); i++) {
@@ -361,8 +359,8 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
auto surface = ReadTgaImage(TextName, *stream, RGBA8888, Texture->Flags);
applyColorKey(*surface, 0, 0, 0, false);
auto texData = createTextureFromSurface(*surface, GL_RGBA);
- Texture->texture = createGLTexture();
- Texture->texture->assignData(*texData);
+ Texture->_texture = createGLTexture();
+ Texture->_texture->assignData(*texData);
Texture->name = TextName;
if (flags & rSURFACESTRETCH) { // Also rSURFACEFLIP
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 85ee05fd317..593aea594d7 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -549,7 +549,7 @@ gTexture *gUserTexture(Texture *texture, unsigned int dimx, unsigned int dimy) {
#endif
}
- Texture->texture = texture;
+ Texture->_texture = texture;
return Texture;
}
@@ -710,7 +710,7 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
}
texture = &gTextureList[pos];
*texture = gTexture();
- texture->texture = new OpenGLTexture();
+ texture->_texture = new OpenGLTexture();
if (bUseAlternate) {
auto stream = workDirs.resolveFile(AlternateName);
@@ -719,7 +719,7 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
return nullptr;
}
auto ddsTextureData = loadDdsTexture(*stream);
- texture->texture->assignData(*ddsTextureData);
+ texture->_texture->assignData(*ddsTextureData);
dwWidth = ddsTextureData->getWidth();
dwHeight = ddsTextureData->getHeight();
lpSSource = nullptr;
@@ -760,7 +760,7 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
auto image = ReadTgaImage(TextName, *stream, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), 0); // TODO Flags
SurfaceBackedTextureData texData(image);
- texture->texture->assignData(texData);
+ texture->_texture->assignData(texData);
#if 0
//warning("TODO: Handle TGA");
if (!t3dOpenFile(TextName)) {
diff --git a/engines/watchmaker/3d/render/opengl_renderer.cpp b/engines/watchmaker/3d/render/opengl_renderer.cpp
index 2f795c07ec9..55b82116bac 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.cpp
+++ b/engines/watchmaker/3d/render/opengl_renderer.cpp
@@ -153,7 +153,7 @@ void OpenGLRenderer::setTexture(int stage, void *texture) {
}
}
void OpenGLRenderer::setTexture(int stage, const gTexture &texture) {
- texture.texture->bind();
+ texture._texture->bind();
}
void setGlFeature(GLint feature, bool state) {
diff --git a/engines/watchmaker/3d/texture.h b/engines/watchmaker/3d/texture.h
index 95f98a13505..915021b1a18 100644
--- a/engines/watchmaker/3d/texture.h
+++ b/engines/watchmaker/3d/texture.h
@@ -36,7 +36,7 @@ class WGame;
// Texture structs
struct gTexture {
Common::String name;
- Texture *texture = nullptr;
+ Texture *_texture = nullptr;
int RealDimX = 0; // original dimensions
int RealDimY = 0; // original dimensions
int DimX = 0; // current dimensions
@@ -45,7 +45,7 @@ struct gTexture {
int Flags = 0; // Flags
bool isEmpty() {
- return texture == nullptr;
+ return _texture == nullptr;
}
void clear() {
// TODO: This will only work for the back-surface
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index a98485f84bf..b371bda2704 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -214,29 +214,29 @@ void Render3DEnvironment(WGame &game) {
for (i = 0; i < T3D_MAX_CHARACTERS; i++)
if (Character[i] && (i != ocBOTH) && (i != ocDARRELL))
if (!t3dTransformCharacter(Character[i])) // Proietta personaggi
- DebugLogWindow("Can't transform %s", Character[i]->Body);
+ DebugLogWindow("Can't transform %s", Character[i]->Body->name.c_str());
} else {
for (i = 0; i < T3D_MAX_CHARACTERS; i++)
if (Character[i] && (i != ocBOTH))
if (!t3dTransformCharacter(Character[i])) // Proietta personaggi
- DebugLogWindow("Can't transform %s", Character[i]->Body);
+ DebugLogWindow("Can't transform %s", Character[i]->Body->name.c_str());
}
if (game._gameVars.getCurRoomId() == r33) {
for (i = 0; i < 4; i++) // Proietta oggetti speciali
if (Lanc33[i] && !t3dTransformCharacter(Lanc33[i]))
- DebugLogWindow("Can't transform %s", Lanc33[i]->Body);
+ DebugLogWindow("Can't transform %s", Lanc33[i]->Body->name.c_str());
}
for (i = 0; i < MAX_GOPHERS; i++)
if (GopherMark[i] && !t3dTransformCharacter(GopherMark[i]))
- DebugLogWindow("Can't transform %s", GopherMark[i]->Body);
+ DebugLogWindow("Can't transform %s", GopherMark[i]->Body->name.c_str());
if (Freccia50 && !t3dTransformCharacter(Freccia50))
- DebugLogWindow("Can't transform %s", Freccia50->Body);
+ DebugLogWindow("Can't transform %s", Freccia50->Body->name.c_str());
if (Palla50 && !t3dTransformCharacter(Palla50))
- DebugLogWindow("Can't transform %s", Palla50->Body);
+ DebugLogWindow("Can't transform %s", Palla50->Body->name.c_str());
if (Explode50 && !t3dTransformCharacter(Explode50))
- DebugLogWindow("Can't transform %s", Explode50->Body);
+ DebugLogWindow("Can't transform %s", Explode50->Body->name.c_str());
t3dSortMeshes(); // Ordian le mesh
}
diff --git a/engines/watchmaker/render.cpp b/engines/watchmaker/render.cpp
index 4e324f02ba5..79eb1955f35 100644
--- a/engines/watchmaker/render.cpp
+++ b/engines/watchmaker/render.cpp
@@ -65,7 +65,7 @@ unsigned int gGetTextureListPosition() {
}
#endif
-bool rSetRenderMode(int state) {
+void rSetRenderMode(int state) {
warning("STUBBED: rSetRenderMode");
}
@@ -144,7 +144,7 @@ void rGetScreenInfos(unsigned int *width, unsigned int *height, unsigned int *bp
*bpp = 32;
}
-gTexture *gLoadTexture(char *TextName, unsigned int LoaderFlags) {
+gTexture *gLoadTexture(char *TextName, unsigned int loaderFlags) {
error("STUBBED gLoadTexture");
return nullptr;
}
diff --git a/engines/watchmaker/render.h b/engines/watchmaker/render.h
index fbe0de75522..b705eae7aba 100644
--- a/engines/watchmaker/render.h
+++ b/engines/watchmaker/render.h
@@ -201,7 +201,7 @@ bool rInitialize3DEnvironment(WGame &game, char *cfg);
char *rGetRenderDllDesc();
void rSetFlagsFullScreen();
bool rGetFlagsFullScreen();
-bool rSetRenderMode(int state);
+void rSetRenderMode(int state);
bool rClearBuffers(char flags);
void rClear(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b);
void rGetScreenInfos(unsigned int *width, unsigned int *height, unsigned int *bpp);
diff --git a/engines/watchmaker/renderer.cpp b/engines/watchmaker/renderer.cpp
index 45a66a2f866..a5a1f5f693e 100644
--- a/engines/watchmaker/renderer.cpp
+++ b/engines/watchmaker/renderer.cpp
@@ -74,10 +74,10 @@ void Renderer::initGL() {
}
void Renderer::setVirtualScreen(unsigned int dimX, unsigned int dimY) {
- unsigned int width, height, bpp;
+ unsigned int width, height;
//calculate aspect ratio
- getScreenInfos(width, height, bpp);
+ getScreenInfos(width, height);
gAspectX = 1.0f / ((float)dimX / (float)width);
gAspectY = 1.0f / ((float)dimY / (float)height);
@@ -85,14 +85,13 @@ void Renderer::setVirtualScreen(unsigned int dimX, unsigned int dimY) {
gInvAspectY = (float)dimY / (float)height;
}
-void Renderer::getScreenInfos(unsigned int &width, unsigned int &height, unsigned int &bpp) const {
+void Renderer::getScreenInfos(unsigned int &width, unsigned int &height) const {
sdl->getWindowSize(width, height);
- bpp = sdl->getBitDepth();
}
WindowInfo Renderer::getScreenInfos() const {
WindowInfo info;
- getScreenInfos(info.width, info.height, info.bpp);
+ getScreenInfos(info.width, info.height);
return info;
}
@@ -105,7 +104,7 @@ bool Renderer::createScreenBuffer() {
return false;
}
-bool Renderer::initBlitterViewPort() {
+void Renderer::initBlitterViewPort() {
auto info = getScreenInfos();
Rect viewport{0, 0, (int)info.width, (int)info.height};
@@ -179,8 +178,6 @@ void gPrintText(WGame &game, const char *s, uint32 d, uint32 src, uint16 *FontTa
int16 i = 0, nextx, nexty;
unsigned char c;
- uint32 AddFlag = 0, NumRetries = 0;
-
nextx = nexty = 0;
while ((c = s[i]) != 0) {
i++;
diff --git a/engines/watchmaker/renderer.h b/engines/watchmaker/renderer.h
index ca1ab8820ca..850e0440547 100644
--- a/engines/watchmaker/renderer.h
+++ b/engines/watchmaker/renderer.h
@@ -38,7 +38,6 @@ struct gMaterial;
struct WindowInfo {
unsigned int width;
unsigned int height;
- unsigned int bpp;
};
class Fonts;
@@ -56,10 +55,10 @@ public:
void showFrame();
void setVirtualScreen(unsigned int dimX, unsigned int dimY);
- void getScreenInfos(unsigned int &width, unsigned int &height, unsigned int &bpp) const;
+ void getScreenInfos(unsigned int &width, unsigned int &height) const;
WindowInfo getScreenInfos() const;
bool createScreenBuffer();
- bool initBlitterViewPort();
+ void initBlitterViewPort();
void setCurCameraViewport(t3dF32 fov, uint8 sup);
diff --git a/engines/watchmaker/schedule.cpp b/engines/watchmaker/schedule.cpp
index c44f416ad35..d3f3976d4b5 100644
--- a/engines/watchmaker/schedule.cpp
+++ b/engines/watchmaker/schedule.cpp
@@ -140,7 +140,7 @@ void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wp
pqueue *lq;
message *lm;
- warning("Event(%s, event=%d, flags=%d, wparam1=%d, wparam2=%d, bparam=%d", eventToString(classe), event, flags, wparam1, wparam2);
+ warning("Event(%s, event=%d, flags=%d, wparam1=%d, wparam2=%d, bparam=%d", eventToString(classe), event, flags, wparam1, wparam2, bparam);
if (classe == EventClass::MC_IDLE && !event)
return ;
diff --git a/engines/watchmaker/sdl_wrapper.cpp b/engines/watchmaker/sdl_wrapper.cpp
index 26cc79f01d0..b752d38ac2f 100644
--- a/engines/watchmaker/sdl_wrapper.cpp
+++ b/engines/watchmaker/sdl_wrapper.cpp
@@ -31,16 +31,6 @@ void sdl_wrapper::getWindowSize(unsigned int &width, unsigned int &height) {
height = g_system->getHeight();
}
-int sdl_wrapper::getBitDepth() const {
-#if 0
- int pixelFormat = SDL_GetWindowPixelFormat(window);
- int bpp;
- uint32 rMask, gMask, bMask, aMask;
- SDL_PixelFormatEnumToMasks(pixelFormat, &bpp, &rMask, &gMask, &bMask, &aMask);
- return bpp;
-#endif
-}
-
void sdl_wrapper::pollSDL() {
// Process events
Common::Event event;
diff --git a/engines/watchmaker/sdl_wrapper.h b/engines/watchmaker/sdl_wrapper.h
index cbbdeea39d8..ef5049d14a9 100644
--- a/engines/watchmaker/sdl_wrapper.h
+++ b/engines/watchmaker/sdl_wrapper.h
@@ -37,8 +37,6 @@ public:
void getWindowSize(unsigned int &width, unsigned int &height);
- int getBitDepth() const;
-
void initWindow();
void pollSDL();
diff --git a/engines/watchmaker/walk/walkutil.cpp b/engines/watchmaker/walk/walkutil.cpp
index d3f42ad9fe5..5ab25e62198 100644
--- a/engines/watchmaker/walk/walkutil.cpp
+++ b/engines/watchmaker/walk/walkutil.cpp
@@ -156,10 +156,10 @@ int IntersLineLine(float xa, float ya, float xb, float yb, float xc, float yc, f
Compara distanza percorso (qsort)
--------------------------------------------------*/
int PathCompare(const void *arg1, const void *arg2) {
- t3dPATHNODE *p1, *p2;
+ const t3dPATHNODE *p1, *p2;
- p1 = (t3dPATHNODE *)arg1;
- p2 = (t3dPATHNODE *)arg2;
+ p1 = (const t3dPATHNODE *)arg1;
+ p2 = (const t3dPATHNODE *)arg2;
if (p1->dist < p2->dist)
return -1;
Commit: 55cd5c8f207becfe20b9efddb876c84ec679b2d5
https://github.com/scummvm/scummvm/commit/55cd5c8f207becfe20b9efddb876c84ec679b2d5
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Improve some const usage (to avoid casting away constness)
Changed paths:
engines/watchmaker/fonts.cpp
engines/watchmaker/fonts.h
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/walk/act.cpp
engines/watchmaker/walk/act.h
diff --git a/engines/watchmaker/fonts.cpp b/engines/watchmaker/fonts.cpp
index bddc0a2aaab..0054dc141c1 100644
--- a/engines/watchmaker/fonts.cpp
+++ b/engines/watchmaker/fonts.cpp
@@ -89,7 +89,7 @@ SFont *Fonts::fontForKind(FontKind font) {
}
}
-void Fonts::getTextDim(char *s, FontKind font, int *x, int *y) {
+void Fonts::getTextDim(const char *s, FontKind font, int *x, int *y) {
if (!s)
return;
diff --git a/engines/watchmaker/fonts.h b/engines/watchmaker/fonts.h
index 3fd38ee6fe9..34202fa229c 100644
--- a/engines/watchmaker/fonts.h
+++ b/engines/watchmaker/fonts.h
@@ -52,7 +52,7 @@ public:
~Fonts();
void loadFonts(WGame &game, WindowInfo &windowInfo);
- void getTextDim(char *s, FontKind font, int *x, int *y);
+ void getTextDim(const char *s, FontKind font, int *x, int *y);
};
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index a29d50444b6..6383114e395 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -239,14 +239,14 @@ void ProcessATFDO(WGame &game, int32 in) {
case f23ENTRALIFT:
in = aTO1PERSON;
bLockCamera = true;
- CheckCharacterWithoutBounds(game, ocCURPLAYER, (uint8 *)"\055\000", 0);
+ CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\055\000", 0);
Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, &in, nullptr);
bNoFirstPersonSwitch = true;
bNoPlayerSwitch = true;
break;
case f23ESCELIFT:
bLockCamera = false;
- CheckCharacterWithoutBounds(game, ocCURPLAYER, (uint8 *)"\057\000", 0);
+ CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\057\000", 0);
Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
bNoFirstPersonSwitch = false;
bNoPlayerSwitch = false;
@@ -275,25 +275,25 @@ void ProcessATFDO(WGame &game, int32 in) {
case f2OENTRALIFT:
in = aTO1PERSON;
bLockCamera = true;
- CheckCharacterWithoutBounds(game, ocCURPLAYER, (uint8 *)"\051\052\000", 0);
+ CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\051\052\000", 0);
Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, &in, nullptr);
bNoFirstPersonSwitch = true;
bNoPlayerSwitch = true;
break;
case f2OESCELIFT:
bLockCamera = false;
- CheckCharacterWithoutBounds(game, ocCURPLAYER, (uint8 *)"\054\000", 0);
+ CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\054\000", 0);
Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
bNoFirstPersonSwitch = false;
bNoPlayerSwitch = false;
break;
case f2QENTRALAB:
- CheckCharacterWithoutBounds(game, ocCURPLAYER, (uint8 *)"\051\052\000", 0);
+ CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\051\052\000", 0);
Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
Event(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_PORTAL, a2Q14, 0, 0, nullptr, nullptr, nullptr);
break;
case f2QESCELAB:
- CheckCharacterWithoutBounds(game, ocCURPLAYER, (uint8 *)"\051\052\000", 0);
+ CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\051\052\000", 0);
Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
Event(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_PORTAL, a2Q14, 0, 0, nullptr, nullptr, nullptr);
break;
@@ -410,7 +410,7 @@ void ProcessATFDO(WGame &game, int32 in) {
break;
case f41WALK:
- CheckCharacterWithoutBounds(game, ocCURPLAYER, (uint8 *)"\064\000", 0);
+ CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\064\000", 0);
Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_ACT, dR411, 0, 0, nullptr, nullptr, nullptr);
break;
diff --git a/engines/watchmaker/walk/act.cpp b/engines/watchmaker/walk/act.cpp
index c5c6e8b72f6..8a392b6a195 100644
--- a/engines/watchmaker/walk/act.cpp
+++ b/engines/watchmaker/walk/act.cpp
@@ -252,7 +252,7 @@ void CharSetPosition(int32 oc, uint8 pos, const char *room) {
/* -----------------23/03/99 12.00-------------------
* CheckCharacterWithoutBounds
* --------------------------------------------------*/
-void CheckCharacterWithoutBounds(WGame &game, int32 oc, uint8 *dpl, uint8 back) {
+void CheckCharacterWithoutBounds(WGame &game, int32 oc, const uint8 *dpl, uint8 back) {
t3dCHARACTER *Char = Character[oc];
t3dWALK *w = &Char->Walk;
t3dV3F tmp;
diff --git a/engines/watchmaker/walk/act.h b/engines/watchmaker/walk/act.h
index 7f442988eaa..3141c9a05cf 100644
--- a/engines/watchmaker/walk/act.h
+++ b/engines/watchmaker/walk/act.h
@@ -29,7 +29,7 @@
namespace Watchmaker {
-void CheckCharacterWithoutBounds(WGame &game, int32 oc, uint8 *dpl, uint8 back);
+void CheckCharacterWithoutBounds(WGame &game, int32 oc, const uint8 *dpl, uint8 back);
bool CheckCharacterWithBounds(WGame &game, int32 oc, t3dV3F *Pos, uint8 dp, uint8 back);
void CharSetPosition(int32 oc, uint8 pos, const char *room);
void CharStop(int32 oc);
Commit: 6f7a9362e5923ca980e4d9ce1e36648d2fd0f4d1
https://github.com/scummvm/scummvm/commit/6f7a9362e5923ca980e4d9ce1e36648d2fd0f4d1
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Refactor BitmapList to no longer be global
Changed paths:
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_2d.h
engines/watchmaker/classes/do_system.cpp
engines/watchmaker/ll/ll_regen.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/ll/ll_util.h
engines/watchmaker/render.h
engines/watchmaker/renderer.h
engines/watchmaker/t2d/t2d.cpp
engines/watchmaker/walk/ball.cpp
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 6a885989322..8a7feac3e2b 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -39,9 +39,6 @@
namespace Watchmaker {
-// Bitmap list
-unsigned int gNumBitmapList = 0;
-gTexture gBitmapList[MAX_BITMAP_LIST];
Rect gBlitterExtends;
int gStencilBitDepth;
@@ -52,39 +49,39 @@ int NumLogosMaterials = 0, GlobalLogosDelay = 60 * 3;
unsigned int CurLoaderFlags;
//*********************************************************************************************
-unsigned int gGetBitmapListPosition() {
+unsigned int Renderer::BitmapList::acquirePosition() {
unsigned int pos = 1;
- while (!gBitmapList[pos].isEmpty()) {
+ while (!bitmaps[pos].isEmpty()) {
pos++;
}
if (pos > MAX_BITMAP_LIST)
return 0;
- if (pos > gNumBitmapList)
- gNumBitmapList = pos;
+ if (pos > _numBitmaps)
+ _numBitmaps = pos;
return pos;
}
-unsigned int rGetBitmapDimX(unsigned int id) {
- return gBitmapList[id].DimX;
+unsigned int Renderer::getBitmapDimX(int32 id) const {
+ return _bitmapList.bitmaps[id].DimX;
}
-//************************************************************************************************************************
-unsigned int rGetBitmapDimY(unsigned int id) {
- return gBitmapList[id].DimY;
+unsigned int Renderer::getBitmapDimY(int32 id) const {
+ return _bitmapList.bitmaps[id].DimY;
}
-unsigned int rGetBitmapRealDimX(unsigned int id) {
- return gBitmapList[id].RealDimX;
+unsigned int Renderer::getBitmapRealDimX(int32 id) const {
+ return _bitmapList.bitmaps[id].RealDimX;
}
-unsigned int rGetBitmapRealDimY(unsigned int id) {
- return gBitmapList[id].RealDimY;
+unsigned int Renderer::getBitmapRealDimY(int32 id) const {
+ return _bitmapList.bitmaps[id].RealDimY;
}
+
//************************************************************************************************************************
void rUpdateExtends(int x1, int y1, int x2, int y2) {
//Update extends
@@ -221,28 +218,30 @@ void gTexture::render(WGame &game, Rect src, Rect dst) {
}
}
-void rBlitScreenBuffer(WGame &game) { // Should probably go to opengl_2d
+void Renderer::blitScreenBuffer() {
checkGlError("Entering rBlitScreenBuffer");
- enter2Dmode(game);
- gBitmapList[BACK_BUFFER].render(game, game._renderer->_viewport, game._renderer->_viewport);
+ enter2Dmode(*_game);
+ _bitmapList.bitmaps[BACK_BUFFER].render(*_game, _game->_renderer->_viewport, _game->_renderer->_viewport);
exit2Dmode();
checkGlError("Exiting rBlitScreenBuffer");
}
-void rClear(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b) {
+void Renderer::clearBitmap(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b) {
warning("STUBBED: rClear(%d, %d, %d, %d, %d", dst, dposx, dposy, sdimx, sdimy);
- gBitmapList[dst].clear();
+ _bitmapList.bitmaps[dst].clear();
}
//************************************************************************************************************************
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
int sposx, int sposy, int sdimx, int sdimy) {
+ auto &bitmapList = game._renderer->_bitmapList.bitmaps;
// TODO: This currently gets called a bit too much.
- warning("TODO: Stubbed rBlitter(%s, %d, %d, %d, %d, %d, %d, %d, %d)", gBitmapList[src].name.c_str(), dst, src, dposx, dposy, sposx, sposy, sdimx, sdimy);
- auto &bitmap = gBitmapList[src];
+ warning("TODO: Stubbed rBlitter(%s, %d, %d, %d, %d, %d, %d, %d, %d)", bitmapList[src].name.c_str(), dst, src, dposx, dposy, sposx, sposy, sdimx, sdimy);
+
+ auto &bitmap = bitmapList[src];
assert(dst == 0);
- auto &dstBitmap = gBitmapList[dst];
+ auto &dstBitmap = bitmapList[dst];
checkGlError("rBlitter Start");
@@ -253,10 +252,10 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
dwHeight = game._renderer->_viewport.height();;
if ((sdimx <= 0)) {
- sdimx = gBitmapList[src].DimX;
+ sdimx = bitmapList[src].DimX;
}
if ((sdimy <= 0)) {
- sdimy = gBitmapList[src].DimY;
+ sdimy = bitmapList[src].DimY;
}
if ((dposx >= dwWidth) || (dposy >= dwHeight) || (sposx >= dwWidth) || (sposy >= dwHeight) ||
@@ -274,8 +273,8 @@ void rBlitter(WGame &game, int dst, int src, int dposx, int dposy,
}
if ((sdimx == 0) && (sdimy == 0)) {
- sdimx = gBitmapList[src].DimX;
- sdimy = gBitmapList[src].DimY;
+ sdimx = bitmapList[src].DimX;
+ sdimy = bitmapList[src].DimY;
}
{
@@ -348,12 +347,12 @@ int rLoadBitmapImage(WGame &game, const char *TextName, unsigned char flags) {
Graphics::PixelFormat RGBA8888(4, 8, 8, 8, 8, 0, 8, 16, 24);
- unsigned int pos = gGetBitmapListPosition();
+ unsigned int pos = game._renderer->_bitmapList.acquirePosition();
if (pos == 0) {
warning("rLoadBitmap: Can't create more bitmaps");
return -1;
}
- gTexture *Texture = &gBitmapList[pos];
+ gTexture *Texture = &game._renderer->_bitmapList.bitmaps[pos];
*Texture = gTexture();
Texture->Flags = CurLoaderFlags;
auto surface = ReadTgaImage(TextName, *stream, RGBA8888, Texture->Flags);
diff --git a/engines/watchmaker/3d/render/opengl_2d.h b/engines/watchmaker/3d/render/opengl_2d.h
index dd7b52f6876..3cd9551e295 100644
--- a/engines/watchmaker/3d/render/opengl_2d.h
+++ b/engines/watchmaker/3d/render/opengl_2d.h
@@ -25,8 +25,6 @@
#include "watchmaker/render.h"
#include "watchmaker/3d/render/opengl_3d.h"
-#define MAX_BITMAP_LIST 1024
-
namespace Watchmaker {
extern int gStencilBitDepth;
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index 9f38d019c6a..c57a7a32c4c 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -262,7 +262,7 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
if (visibile && (c->tnum == -1)) {
//Crea una surface che la contenga
c->tnum = rCreateSurface(c->dx, c->dy, rBITMAPSURFACE);
- rClear(c->tnum, 0, 0, c->dx, c->dy, 0, 0, 0);
+ game._renderer->clearBitmap(c->tnum, 0, 0, c->dx, c->dy, 0, 0, 0);
//Renderizza la scritta nella surface
game._renderer->printText(c->s, c->tnum, f, WHITE_FONT, 0, 0);
@@ -304,7 +304,7 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
ye = 0;
if ((c->py + c->dy) > end_y) ye = (c->py + c->dy) - end_y;
- DisplayDDBitmap_NoFit(c->tnum, c->px, c->py - TitoliCoda_Y, 0, ys, c->dx, c->dy - ys - ye);
+ DisplayDDBitmap_NoFit(*game._renderer, c->tnum, c->px, c->py - TitoliCoda_Y, 0, ys, c->dx, c->dy - ys - ye);
}
}//for
@@ -452,7 +452,7 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
) {
//Crea una surface che la contenga
c->tnum = rCreateSurface(c->dx, c->dy, rBITMAPSURFACE);
- rClear(c->tnum, 0, 0, c->dx, c->dy, 0, 0, 0);
+ game._renderer->clearBitmap(c->tnum, 0, 0, c->dx, c->dy, 0, 0, 0);
//Renderizza la scritta nella surface
game._renderer->printText(c->s, c->tnum, f, WHITE_FONT, 0, 0);
@@ -472,7 +472,7 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
}
if (c->tnum != -1)
- DisplayDDBitmap_NoFit(c->tnum, c->px, c->py, 0, 0, c->dx, c->dy);
+ DisplayDDBitmap_NoFit(*game._renderer, c->tnum, c->px, c->py, 0, 0, c->dx, c->dy);
}//for
if (TitoliCoda_NumDeleted == TitoliCoda_NumEntries) {
@@ -900,7 +900,7 @@ void doSystem(WGame &game) {
DebugLogWindow("EFFECT_ROOMINFO: can't create surface");
break;
}
- rClear(RoomInfo.tnum, 0, 0, RoomInfo.dx, RoomInfo.dy, 0, 0, 0);
+ game._renderer->clearBitmap(RoomInfo.tnum, 0, 0, RoomInfo.dx, RoomInfo.dy, 0, 0, 0);
rSetBitmapName(RoomInfo.tnum, "RoomInfo");
RoomInfo.letter_ptr = &RoomInfo.fullstring[0];
@@ -942,7 +942,7 @@ void doSystem(WGame &game) {
strcpy(name_backup, RoomInfo.fullstring);
*(RoomInfo.letter_ptr + 1) = '\0';
- rClear(RoomInfo.tnum, 0, 0, RoomInfo.dx, RoomInfo.dy, 0, 0, 0);
+ game._renderer->clearBitmap(RoomInfo.tnum, 0, 0, RoomInfo.dx, RoomInfo.dy, 0, 0, 0);
game._renderer->printText(RoomInfo.fullstring, RoomInfo.tnum, RoomInfo.f, FontColor::WHITE_FONT, 0, 0);
game._fonts.getTextDim(RoomInfo.fullstring, RoomInfo.f, &RoomInfo._dx, &RoomInfo._dy);
@@ -952,7 +952,7 @@ void doSystem(WGame &game) {
if (RoomInfo.t_next_letter < 0) RoomInfo.t_next_letter = 0;
RoomInfo.letter_ptr ++;
}
- DisplayDDBitmap_NoFit(RoomInfo.tnum, RoomInfo.px, RoomInfo.py, 0, 0, RoomInfo._dx, RoomInfo._dy);
+ DisplayDDBitmap_NoFit(*game._renderer, RoomInfo.tnum, RoomInfo.px, RoomInfo.py, 0, 0, RoomInfo._dx, RoomInfo._dy);
break;
case EFFECT_FADEIN_T1:
case EFFECT_FADEOUT_T1:
diff --git a/engines/watchmaker/ll/ll_regen.cpp b/engines/watchmaker/ll/ll_regen.cpp
index b36d92c12de..8cc14771914 100644
--- a/engines/watchmaker/ll/ll_regen.cpp
+++ b/engines/watchmaker/ll/ll_regen.cpp
@@ -159,7 +159,7 @@ void Regen(WGame &game) {
continue;
// Clear ScreenBuffer
- rClear(BACK_BUFFER, (p->x1), (p->y1), (p->x2 - p->x1), (p->y2 - p->y1), 0, 0, 0);
+ game._renderer->clearBitmap(BACK_BUFFER, (p->x1), (p->y1), (p->x2 - p->x1), (p->y2 - p->y1), 0, 0, 0);
}
for (a = 0; a < upn; a++) {
@@ -223,7 +223,7 @@ void Regen(WGame &game) {
// DebugLogWindow( "Aggiorna video %d,%d %d,%d", ext.x1, ext.y1, ext.x2-ext.x1, ext.y2-ext.y1 );
#endif
rUpdateExtends(ext.x1, ext.y1, ext.x2, ext.y2);
- rBlitScreenBuffer(game);
+ game._renderer->blitScreenBuffer();
rResetExtends();
// 5 - Copy PaintRect to OldPaintRect
@@ -283,6 +283,7 @@ void Add2DStuff(WGame &game) {
struct SDDText *t, *r;
int32 cmx, cmy;
int32 a, c;
+ Renderer &renderer = *game._renderer;
// Reset paint structure
memset(PaintRect, 0, sizeof(PaintRect));
@@ -318,7 +319,7 @@ void Add2DStuff(WGame &game) {
// Draw the current mouse pointer
if (CurMousePointer > 0)
- AddPaintRect(CurMousePointer, (cmx), (cmy), 0, 0, rGetBitmapDimX(CurMousePointer), rGetBitmapDimY(CurMousePointer));
+ AddPaintRect(CurMousePointer, (cmx), (cmy), 0, 0, renderer.getBitmapDimX(CurMousePointer), renderer.getBitmapDimY(CurMousePointer));
}
Regen(game);
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 6ad4020df8a..961202d2346 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -244,8 +244,8 @@ int32 CreateTooltipBitmap(Renderer &renderer, char *tooltip, FontColor color, ui
strcpy(info, "tooltip: ");
strncat(info, tooltip, 15);
rSetBitmapName(surf, info);
- rClear(surf, 0, 0, dimx, dimy, 18, 18, 18); // Bordino nero
- rClear(surf, 1, 1, dimx - 2, dimy - 2, r, g, b); // Sfondo colorato
+ renderer.clearBitmap(surf, 0, 0, dimx, dimy, 18, 18, 18); // Bordino nero
+ renderer.clearBitmap(surf, 1, 1, dimx - 2, dimy - 2, r, g, b); // Sfondo colorato
renderer.printText(tooltip, surf, font, color, (uint16)renderer.rFitX(enlarge), (uint16)renderer.rFitY(enlarge));
return surf;
}
@@ -693,14 +693,14 @@ void DisplayDDBitmap(Renderer &renderer, int32 tnum, int32 px, int32 py, int32 o
DDBitmapsList[a].oy = renderer.rFitY(py + oy) - renderer.rFitY(py);
DDBitmapsList[a].dx = renderer.rFitX(px + dx) - renderer.rFitX(px);
DDBitmapsList[a].dy = renderer.rFitY(py + dy) - renderer.rFitY(py);
- if (dx <= 0) DDBitmapsList[a].dx += rGetBitmapDimX(tnum) - DDBitmapsList[a].ox;
- if (dy <= 0) DDBitmapsList[a].dy += rGetBitmapDimY(tnum) - DDBitmapsList[a].oy;
+ if (dx <= 0) DDBitmapsList[a].dx += renderer.getBitmapDimX(tnum) - DDBitmapsList[a].ox;
+ if (dy <= 0) DDBitmapsList[a].dy += renderer.getBitmapDimY(tnum) - DDBitmapsList[a].oy;
}
/* -----------------22/11/00 12.15-------------------
* DisplayDDBitmap_NoFit
* --------------------------------------------------*/
-void DisplayDDBitmap_NoFit(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
+void DisplayDDBitmap_NoFit(Renderer &renderer, int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
int32 a;
for (a = 0; a < MAX_DD_BITMAPS; a++)
if (!DDBitmapsList[a].tnum)
@@ -718,8 +718,8 @@ void DisplayDDBitmap_NoFit(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, i
DDBitmapsList[a].oy = (py + oy) - (py);
DDBitmapsList[a].dx = (px + dx) - (px);
DDBitmapsList[a].dy = (py + dy) - (py);
- if (dx <= 0) DDBitmapsList[a].dx += rGetBitmapDimX(tnum) - DDBitmapsList[a].ox;
- if (dy <= 0) DDBitmapsList[a].dy += rGetBitmapDimY(tnum) - DDBitmapsList[a].oy;
+ if (dx <= 0) DDBitmapsList[a].dx += renderer.getBitmapDimX(tnum) - DDBitmapsList[a].ox;
+ if (dy <= 0) DDBitmapsList[a].dy += renderer.getBitmapDimY(tnum) - DDBitmapsList[a].oy;
}
/* -----------------15/11/00 12.16-------------------
@@ -738,7 +738,7 @@ int32 RendDDText(Renderer &renderer, char *text, FontKind font, FontColor color)
renderer._fonts->getTextDim(text, font, &tdx, &tdy);
// Crea una surface che la contenga
r->tnum = rCreateSurface(tdx, tdy, rBITMAPSURFACE);
- rClear(r->tnum, 0, 0, tdx, tdy, 0, 0, 0);
+ renderer.clearBitmap(r->tnum, 0, 0, tdx, tdy, 0, 0, 0);
// Renderizza la scritta nella surface
//DebugLogWindow("Creo testo %s | %d %d",text,tdx,tdy );
renderer.printText(text, r->tnum, font, color, 0, 0);
@@ -805,7 +805,7 @@ void DisplayDDText(Renderer &renderer, char *text, FontKind font, FontColor colo
/* -----------------15/01/99 18.15-------------------
* GetDDBitmapExtends
* --------------------------------------------------*/
-void GetDDBitmapExtends(struct SRect *r, struct SDDBitmap *b) {
+void GetDDBitmapExtends(Renderer &renderer, struct SRect *r, struct SDDBitmap *b) {
if (!r || !b) return ;
r->x1 = b->px;
r->y1 = b->py;
@@ -815,8 +815,8 @@ void GetDDBitmapExtends(struct SRect *r, struct SDDBitmap *b) {
// the upper bits for flagging. For now let's mask out
// the high-bit.
uint32 mask = T2D_BM_OFF ^ 0xFFFFFFFF;
- r->x2 = r->x1 + rGetBitmapRealDimX(b->tnum & mask);
- r->y2 = r->y1 + rGetBitmapRealDimY(b->tnum & mask);
+ r->x2 = r->x1 + renderer.getBitmapRealDimX(b->tnum & mask);
+ r->y2 = r->y1 + renderer.getBitmapRealDimY(b->tnum & mask);
}
/* -----------------05/11/98 10.36-------------------
diff --git a/engines/watchmaker/ll/ll_util.h b/engines/watchmaker/ll/ll_util.h
index 855dafad750..31876f11691 100644
--- a/engines/watchmaker/ll/ll_util.h
+++ b/engines/watchmaker/ll/ll_util.h
@@ -38,9 +38,9 @@ int16 getRoomFromStr(Init &init, const Common::String &s);
void ChangeRoom(WGame &game, Common::String n, uint8 pos, int32 an);
bool SetBndLevel(Init &init, const char *roomname, int32 lev);
int32 GetBndLevel(char *roomname);
-void GetDDBitmapExtends(struct SRect *r, struct SDDBitmap *b);
+void GetDDBitmapExtends(Renderer &renderer, struct SRect *r, struct SDDBitmap *b);
void DisplayDDBitmap(Renderer &, int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
-void DisplayDDBitmap_NoFit(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
+void DisplayDDBitmap_NoFit(Renderer &renderer, int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
void UpdateRoomInfo(Init &init);
bool CheckRect(Renderer &renderer, struct SRect p, int32 cmx, int32 cmy);
void DisplayD3DTriangle(Renderer &, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r, uint8 g, uint8 b, uint8 al);
diff --git a/engines/watchmaker/render.h b/engines/watchmaker/render.h
index b705eae7aba..d7a39f84309 100644
--- a/engines/watchmaker/render.h
+++ b/engines/watchmaker/render.h
@@ -153,12 +153,8 @@ void rReleaseBitmap(int i);
void rReleaseBitmapDirect(gTexture *b);
void rSetLoaderFlags(unsigned int NewLoaderFlags);
int rCreateSurface(unsigned int dimx, unsigned int dimy, unsigned char flags);
-unsigned int rGetBitmapDimX(unsigned int id);
-unsigned int rGetBitmapDimY(unsigned int id);
char *rGetBitmapName(unsigned int id);
void rSetBitmapName(unsigned int id, const char *s);
-unsigned int rGetBitmapRealDimX(unsigned int id);
-unsigned int rGetBitmapRealDimY(unsigned int id);
unsigned char *rLockSurface(int surf, unsigned int *pitch);
unsigned char *rLockSurfaceDirect(gTexture *t, unsigned int *pitch);
void rUnlockSurface(int surf);
@@ -203,7 +199,6 @@ void rSetFlagsFullScreen();
bool rGetFlagsFullScreen();
void rSetRenderMode(int state);
bool rClearBuffers(char flags);
-void rClear(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b);
void rGetScreenInfos(unsigned int *width, unsigned int *height, unsigned int *bpp);
void rRelaseFontTable(unsigned short *ft);
void rRelaseAllFontTable();
@@ -216,7 +211,6 @@ int DebugQuick(signed int StdPx, signed int StdPy, const cha
bool rGetStencilBitDepth();
//Misc functions
-void rBlitScreenBuffer(WGame &game);
void rBlitter(WGame &game, int dst, int src, int dposx, int dposy, int sposx, int sposy, int sdimx, int sdimy);
//D3d specific geometry trasf. functions
diff --git a/engines/watchmaker/renderer.h b/engines/watchmaker/renderer.h
index 850e0440547..d1c18d3dc58 100644
--- a/engines/watchmaker/renderer.h
+++ b/engines/watchmaker/renderer.h
@@ -70,6 +70,21 @@ public:
int rInvFitX(int x);
int rInvFitY(int y);
+ static const int MAX_BITMAP_LIST = 1024;
+ struct BitmapList {
+ unsigned int _numBitmaps = 0;
+ gTexture bitmaps[MAX_BITMAP_LIST];
+
+ unsigned int acquirePosition();
+ };
+ BitmapList _bitmapList;
+ void clearBitmap(int dst, int dposx, int dposy, int sdimx, int sdimy, unsigned char r, unsigned char g, unsigned char b);
+ void blitScreenBuffer();
+ unsigned int getBitmapDimX(int32 id) const;
+ unsigned int getBitmapDimY(int32 id) const;
+ unsigned int getBitmapRealDimX(int32 id) const;
+ unsigned int getBitmapRealDimY(int32 id) const;
+
bool setProjectionMatrix(float width, float height, float fAspect, float fNearPlane, float fFarPlane);
Math::Vector3d screenSpaceToCameraSpace(float x, float y);
private:
diff --git a/engines/watchmaker/t2d/t2d.cpp b/engines/watchmaker/t2d/t2d.cpp
index fb4a51b9d26..1f770101dfd 100644
--- a/engines/watchmaker/t2d/t2d.cpp
+++ b/engines/watchmaker/t2d/t2d.cpp
@@ -489,6 +489,7 @@ bool ComputerSearch(WGame &game) {
int OldDoc = computerCurrentDocument;
computerCurrentDocument = -1;
Init &init = game.init;
+ Renderer &renderer = *game._renderer;
Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, FALSE, nullptr, nullptr, nullptr);
@@ -639,7 +640,7 @@ bool ComputerSearch(WGame &game) {
game.init.Obj[o25FORNOAP].flags |= EXTRA2;
//Setta paramentri del nuovo documento
- GetDDBitmapExtends(&t, &t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument]);
+ GetDDBitmapExtends(renderer, &t, &t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument]);
t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument].px = game._renderer->rInvFitX(26);
t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument].py = game._renderer->rInvFitY(66);
t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument].ox = 0;
@@ -1305,10 +1306,10 @@ void doT2DMouse(WGame &game) {
d->py += (mouse_y - LinkWinY);
if (d->px < LinkLim.x1) d->px = LinkLim.x1;
if (d->py < LinkLim.y1) d->py = LinkLim.y1;
- GetDDBitmapExtends(&b->lim, &w->bm[LinkBmToMouse]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[LinkBmToMouse]);
if (b->lim.x2 >= LinkLim.x2) d->px = LinkLim.x2 - (b->lim.x2 - b->lim.x1);
if (b->lim.y2 >= LinkLim.y2) d->py = LinkLim.y2 - (b->lim.y2 - b->lim.y1);
- GetDDBitmapExtends(&b->lim, &w->bm[LinkBmToMouse]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[LinkBmToMouse]);
} else {
w->px += (mouse_x - LinkWinX);
w->py += (mouse_y - LinkWinY);
@@ -1356,7 +1357,7 @@ void doT2DMouse(WGame &game) {
if ((T2DActualWindow(nullptr) == T2D_WIN_COMPUTER_DOCUMENT) |
(T2DActualWindow(nullptr) == T2D_WIN_COMPUTER_EMAIL_VIEWER)) {
- GetDDBitmapExtends(&t, &w->bm[a]);
+ GetDDBitmapExtends(renderer, &t, &w->bm[a]);
if (t.y2 - t.y1 > DimY) {
if (w->bm[a].oy - renderer.rInvFitY(mouse_y - ScrollWithMouseY) < 0) {
@@ -1476,7 +1477,7 @@ void doT2DMouse(WGame &game) {
LinkWinX = mouse_x;
LinkWinY = mouse_y;
CurMousePointer = 0;
- GetDDBitmapExtends(&LinkLim, &w->bm[T2D_BM_SCANNER_BACKGROUND_PIC_LOW]);
+ GetDDBitmapExtends(renderer, &LinkLim, &w->bm[T2D_BM_SCANNER_BACKGROUND_PIC_LOW]);
}
} else if (CurButtonWin == T2D_WIN_SCANNER_TOOLBAR) {
if ((CurButton == T2D_BT_SCANNER_TOOLBAR_MOVE) && (bLPressed || bRPressed)) {
@@ -1562,11 +1563,11 @@ void doT2DMouse(WGame &game) {
d1 = &w->bm[T2D_BM_SCANNER_BACKGROUND_PIC_LOW];
d2 = &w->bm[T2D_BM_SCANNER_BACKGROUND_PIC_HI];
- d2->ox = ((d->px - d1->px) * rGetBitmapRealDimX(d2->tnum & ~T2D_BM_OFF)) /
- rGetBitmapRealDimX(d1->tnum & ~T2D_BM_OFF);
- d2->oy = ((d->py - d1->py) * rGetBitmapRealDimY(d2->tnum & ~T2D_BM_OFF)) /
- rGetBitmapRealDimY(d1->tnum & ~T2D_BM_OFF);
- d2->dx = rGetBitmapRealDimX(d1->tnum & ~T2D_BM_OFF);
+ d2->ox = ((d->px - d1->px) * renderer.getBitmapRealDimX(d2->tnum & ~T2D_BM_OFF)) /
+ renderer.getBitmapRealDimX(d1->tnum & ~T2D_BM_OFF);
+ d2->oy = ((d->py - d1->py) * renderer.getBitmapRealDimY(d2->tnum & ~T2D_BM_OFF)) /
+ renderer.getBitmapRealDimY(d1->tnum & ~T2D_BM_OFF);
+ d2->dx = renderer.getBitmapRealDimX(d1->tnum & ~T2D_BM_OFF);
d2->px = d1->px - d2->ox;
d2->py = d1->py - d2->oy;
d1->tnum |= T2D_BM_OFF;
@@ -1590,7 +1591,7 @@ void doT2DMouse(WGame &game) {
w->bt[T2D_BT_SCANNER_TOOLBAR_SCAN_OFF].on = FALSE;
//Controllo posizione selettore per quest
- GetDDBitmapExtends(&t, &t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_SELECTOR]);
+ GetDDBitmapExtends(renderer, &t, &t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_SELECTOR]);
t.x1 -= 108;
t.x2 -= 108;
t.y1 -= 118;
@@ -2074,7 +2075,7 @@ void doT2DMouse(WGame &game) {
0);
//Setta parametri nuovo documento
- GetDDBitmapExtends(&t, &t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument]);
+ GetDDBitmapExtends(renderer, &t, &t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument]);
t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument].px = renderer.rInvFitX(26);
t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument].py = renderer.rInvFitY(66);
t2dWin[T2D_WIN_COMPUTER_DOCUMENT].bm[computerCurrentDocument].ox = 0;
@@ -2132,7 +2133,7 @@ void doT2DMouse(WGame &game) {
t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].tnum &= ~T2D_BM_OFF;
//Setta parametri
- GetDDBitmapExtends(&t, &t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail]);
+ GetDDBitmapExtends(renderer, &t, &t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail]);
t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].px = renderer.rInvFitX(35);
t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].py = renderer.rInvFitY(59);
t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].ox = 0;
@@ -2187,7 +2188,7 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wCIAPULSANTE);
- GetDDBitmapExtends(&t, &w->bm[computerCurrentDocument]);
+ GetDDBitmapExtends(renderer, &t, &w->bm[computerCurrentDocument]);
if (t.y2 - t.y1 > 407) {
if (w->bm[computerCurrentDocument].oy - T2D_DOC_SCROLL_ADD < 0) {
@@ -2209,7 +2210,7 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wCIAPULSANTE);
- GetDDBitmapExtends(&t, &w->bm[computerCurrentDocument]);
+ GetDDBitmapExtends(renderer, &t, &w->bm[computerCurrentDocument]);
if (t.y2 - t.y1 > 407) {
if (w->bm[computerCurrentDocument].oy + w->bm[computerCurrentDocument].dy +
@@ -2266,7 +2267,7 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wCIAPULSANTE);
- GetDDBitmapExtends(&t, &w->bm[computerCurrentEMail]);
+ GetDDBitmapExtends(renderer, &t, &w->bm[computerCurrentEMail]);
if (t.y2 - t.y1 > 182) {
if (w->bm[computerCurrentEMail].oy - T2D_DOC_SCROLL_ADD < 0) {
@@ -2288,7 +2289,7 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wCIAPULSANTE);
- GetDDBitmapExtends(&t, &w->bm[computerCurrentEMail]);
+ GetDDBitmapExtends(renderer, &t, &w->bm[computerCurrentEMail]);
if (t.y2 - t.y1 > 182) {
if (w->bm[computerCurrentEMail].oy + w->bm[computerCurrentEMail].dy +
@@ -3198,10 +3199,10 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_SCANNER_BACKGROUND_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_SCANNER_BACKGROUND_EXIT]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_SCANNER_BACKGROUND_EXIT]);
b->tnum = EXTRALS_EXIT;
b = &w->bt[T2D_BT_SCANNER_BACKGROUND_SELECTOR];
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_SCANNER_BACKGROUND_SELECTOR]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_SCANNER_BACKGROUND_SELECTOR]);
w = &t2dWin[T2D_WIN_SCANNER_TOOLBAR];
w->NOTSTRETCHED = false;;
@@ -3249,22 +3250,22 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_SCANNER_TOOLBAR_MOVE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_WIN]);
b->lim.y2 = 29;
b->tnum = EXTRALS_SCANPROGRAM;
b = &w->bt[T2D_BT_SCANNER_TOOLBAR_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_EXIT]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_EXIT]);
b->tnum = EXTRALS_EXIT;
b = &w->bt[T2D_BT_SCANNER_TOOLBAR_PREVIEW_OFF];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_PREVIEW_OFF]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_PREVIEW_OFF]);
b->tnum = EXTRALS_PREVIEW;
b = &w->bt[T2D_BT_SCANNER_TOOLBAR_SELECTAREA_OFF];
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_SELECTAREA_OFF]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_SELECTAREA_OFF]);
b->tnum = EXTRALS_SELECTAREA;
b = &w->bt[T2D_BT_SCANNER_TOOLBAR_SCAN_OFF];
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_SCAN_OFF]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_SCANNER_TOOLBAR_SCAN_OFF]);
b->tnum = EXTRALS_SCAN;
w = &t2dWin[T2D_WIN_SCANNER_PROGRESSBAR];
@@ -3326,16 +3327,16 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_COMPUTER_QUIT_ON].tnum |= T2D_BM_OFF;
b = &w->bt[T2D_BT_COMPUTER_BACKGROUND_EMAIL];
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_ON]);
b->tnum = EXTRALS_NEWMAIL;
b = &w->bt[T2D_BT_COMPUTER_BACKGROUND_SEARCH];
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_ON]);
b->tnum = EXTRALS_SEARCH;
b = &w->bt[T2D_BT_COMPUTER_BACKGROUND_QUIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_QUIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_QUIT_ON]);
b->tnum = EXTRALS_QUIT;
//Gestione scritte
@@ -3428,22 +3429,22 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_COMPUTER_ERROR_WIN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_COMERROR_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_COMERROR_WIN]);
b = &w->bt[T2D_BT_COMPUTER_ERROR_MOVE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_COMERROR_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_COMERROR_WIN]);
b->lim.y2 = 30;
b = &w->bt[T2D_BT_COMPUTER_ERROR_COMQUIT];
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_ERROR_COMQUIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_ERROR_COMQUIT_ON]);
b->tnum = EXTRALS_QUIT;
b = &w->bt[T2D_BT_COMPUTER_ERROR_DIALQUIT];
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_ERROR_DIALQUIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_ERROR_DIALQUIT_ON]);
b->tnum = EXTRALS_QUIT;
b = &w->bt[T2D_BT_COMPUTER_ERROR_DIALUP];
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_ERROR_DIALUP_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_ERROR_DIALUP_ON]);
b->tnum = EXTRALS_DIAL;
b = &w->bt[T2D_BT_COMPUTER_ERROR_OK];
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_ERROR_OK_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_ERROR_OK_ON]);
b->tnum = EXTRALS_OK;
//ExtraLS
@@ -3536,48 +3537,48 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_COMPUTER_DIALUP_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_EXIT_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_1];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_1_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_1_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_2];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_2_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_2_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_3];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_3_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_3_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_4];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_4_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_4_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_5];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_5_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_5_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_6];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_6_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_6_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_7];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_7_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_7_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_8];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_8_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_8_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_9];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_9_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_9_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_0];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_0_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_0_ON]);
b = &w->bt[T2D_BT_COMPUTER_DIALUP_ENTER];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_ENTER_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_ENTER_ON]);
b->tnum = EXTRALS_CLEAR;
b = &w->bt[T2D_BT_COMPUTER_DIALUP_C];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_C_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_C_ON]);
b->tnum = EXTRALS_CANCEL;
b = &w->bt[T2D_BT_COMPUTER_DIALUP_OK];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_OK_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DIALUP_OK_ON]);
b->tnum = EXTRALS_OK;
b = &w->bt[T2D_BT_COMPUTER_DIALUP_MOVE];
b->on = true;
@@ -3663,14 +3664,14 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_COMPUTER_SEARCH_WIN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_ALPHABETICAL_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_ALPHABETICAL_WIN]);
b = &w->bt[T2D_BT_COMPUTER_SEARCH_MOVE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_ALPHABETICAL_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_ALPHABETICAL_WIN]);
b->lim.y2 = 30;
b = &w->bt[T2D_BT_COMPUTER_SEARCH_SEARCH];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_SEARCH_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_SEARCH_ON]);
b->tnum = EXTRALS_SEARCH;
b = &w->bt[T2D_BT_COMPUTER_SEARCH_ALPHABETICAL];
b->on = true;
@@ -3712,7 +3713,7 @@ void doT2D(WGame &game) {
b->lim.y2 = 172;
b = &w->bt[T2D_BT_COMPUTER_SEARCH_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_SEARCH_EXIT_ON]);
//Gestione Scritte
w->bm[T2D_BM_COMPUTER_SEARCH_NAME].tnum = (T2D_TEXT_COMPUTER_SEARCH_NAME << T2D_BM2TEXT_SHIFT);
@@ -3821,14 +3822,14 @@ void doT2D(WGame &game) {
//Gestione Tasti
b = &w->bt[T2D_BT_COMPUTER_EMAIL_WIN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_WIN]);
b = &w->bt[T2D_BT_COMPUTER_EMAIL_MOVE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_WIN]);
b->lim.y2 = 30;
b = &w->bt[T2D_BT_COMPUTER_EMAIL_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_EXIT_ON]);
b = &w->bt[T2D_BT_COMPUTER_EMAIL_SCROLLUP];
b->on = true;
b->lim.x1 = 612;
@@ -3843,10 +3844,10 @@ void doT2D(WGame &game) {
b->lim.y2 = 263;
b = &w->bt[T2D_BT_COMPUTER_EMAIL_ICON_1];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_ICON_1]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_ICON_1]);
b = &w->bt[T2D_BT_COMPUTER_EMAIL_ICON_2];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_ICON_2]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_ICON_2]);
//Gestione Scritte
w->bm[T2D_BM_COMPUTER_EMAIL_TEXT_1].tnum = (T2D_TEXT_COMPUTER_EMAIL_1 << T2D_BM2TEXT_SHIFT);
@@ -3966,10 +3967,10 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_COMPUTER_DOCUMENT_WIN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_WIN]);
b = &w->bt[T2D_BT_COMPUTER_DOCUMENT_MOVE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_WIN]);
b->lim.y2 = 30;
b = &w->bt[T2D_BT_COMPUTER_DOCUMENT_SCROLL];
b->on = true;
@@ -3979,13 +3980,13 @@ void doT2D(WGame &game) {
b->lim.y2 = renderer.rInvFitY(473);
b = &w->bt[T2D_BT_COMPUTER_DOCUMENT_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_EXIT_ON]);
b = &w->bt[T2D_BT_COMPUTER_DOCUMENT_SCROLLUP];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_SCROLLUP_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_SCROLLUP_ON]);
b = &w->bt[T2D_BT_COMPUTER_DOCUMENT_SCROLLDOWN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_SCROLLDOWN_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCUMENT_SCROLLDOWN_ON]);
//ExtraLS
b = &w->bt[T2D_BT_Document_Win_TGA];
@@ -4021,20 +4022,20 @@ void doT2D(WGame &game) {
//Tasti
b = &w->bt[T2D_BT_COMPUTER_DOCLIST_WIN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_WIN]);
b = &w->bt[T2D_BT_COMPUTER_DOCLIST_MOVE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_WIN]);
b->lim.y2 = 30;
b = &w->bt[T2D_BT_COMPUTER_DOCLIST_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_EXIT_ON]);
b = &w->bt[T2D_BT_COMPUTER_DOCLIST_SCROLLUP];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_SCROLLUP_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_SCROLLUP_ON]);
b = &w->bt[T2D_BT_COMPUTER_DOCLIST_SCROLLDOWN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_SCROLLDOWN_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_DOCLIST_SCROLLDOWN_ON]);
for (i = 0; i <= T2D_TEXT_COMPUTER_DOCLIST_LINES_END - T2D_TEXT_COMPUTER_DOCLIST_LINES_START; i++) {
b = &w->bt[T2D_BT_COMPUTER_DOCLIST_LINES_START + i];
@@ -4092,10 +4093,10 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_COMPUTER_EMAIL_VIEWER_WIN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_WIN]);
b = &w->bt[T2D_BT_COMPUTER_EMAIL_VIEWER_MOVE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_WIN]);
b->lim.y2 = 30;
b = &w->bt[T2D_BT_COMPUTER_EMAIL_VIEWER_SCROLL];
b->on = true;
@@ -4105,13 +4106,13 @@ void doT2D(WGame &game) {
b->lim.y2 = 240;
b = &w->bt[T2D_BT_COMPUTER_EMAIL_VIEWER_SCROLLUP];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLUP_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLUP_ON]);
b = &w->bt[T2D_BT_COMPUTER_EMAIL_VIEWER_SCROLLDOWN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLDOWN_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLDOWN_ON]);
b = &w->bt[T2D_BT_COMPUTER_EMAIL_VIEWER_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_EXIT_ON]);
//ExtraLS
b = &w->bt[T2D_BT_EMail_Viewer_Win_TGA];
@@ -4325,33 +4326,33 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_DIARIO_PAGE_LEFT];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_DIARIO_PAGE_LEFT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_DIARIO_PAGE_LEFT_ON]);
b = &w->bt[T2D_BT_DIARIO_PAGE_RIGHT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_DIARIO_PAGE_RIGHT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_DIARIO_PAGE_RIGHT_ON]);
b = &w->bt[T2D_BT_DIARIO_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_DIARIO_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_DIARIO_EXIT_ON]);
b->tnum = EXTRALS_EXIT;
for (i = T2D_BT_DIARIO_PAGE_1_TEXT_1; i <= T2D_BT_DIARIO_PAGE_1_TEXT_6; i++) {
b = &w->bt[i];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[i]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[i]);
}
for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++) {
b = &w->bt[i];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[i]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[i]);
}
for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++) {
b = &w->bt[i];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[i]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[i]);
}
for (i = T2D_BT_DIARIO_PAGE_4_TEXT_1; i <= T2D_BT_DIARIO_PAGE_4_TEXT_12; i++) {
b = &w->bt[i];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[i]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[i]);
}
PlayerSpeak(game, init.Obj[o34DIARIOAP].action[CurPlayer]);
@@ -4395,15 +4396,15 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_PDA_MAIN_TONE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_MAIN_TONE_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_MAIN_TONE_ON]);
b->tnum = EXTRALS_TONESEQUENCER;
b = &w->bt[T2D_BT_PDA_MAIN_LOG];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_MAIN_LOG_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_MAIN_LOG_ON]);
b->tnum = EXTRALS_LOG;
b = &w->bt[T2D_BT_PDA_MAIN_QUIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_MAIN_QUIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_MAIN_QUIT_ON]);
b->tnum = EXTRALS_QUIT;
@@ -4456,7 +4457,7 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_PDA_LOG_WIN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_LOG_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_LOG_WIN]);
b = &w->bt[T2D_BT_PDA_LOG_SCROLL];
b->on = true;
b->lim.x1 = 23;
@@ -4465,10 +4466,10 @@ void doT2D(WGame &game) {
b->lim.y2 = 345;
b = &w->bt[T2D_BT_PDA_LOG_SCROLLUP];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_LOG_SCROLLUP_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_LOG_SCROLLUP_ON]);
b = &w->bt[T2D_BT_PDA_LOG_SCROLLDOWN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_LOG_SCROLLDOWN_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_LOG_SCROLLDOWN_ON]);
b = &w->bt[T2D_BT_PDA_LOG_SB];
b->on = false;
b->lim.x1 = 696;
@@ -4483,7 +4484,7 @@ void doT2D(WGame &game) {
b->lim.y2 = 333;
b = &w->bt[T2D_BT_PDA_LOG_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_LOG_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_LOG_EXIT_ON]);
for (i = 0; i < T2D_BM_PDA_LOG_DATA_END - T2D_BM_PDA_LOG_DATA_START; i++) {
w->bm[T2D_BM_PDA_LOG_DATA_START + i].tnum = ((T2D_TEXT_PDA_LOG_DATA_START + i) << T2D_BM2TEXT_SHIFT);
@@ -4564,20 +4565,20 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_PDA_TONE_WIN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_TONE_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_TONE_WIN]);
b = &w->bt[T2D_BT_PDA_TONE_HELP];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_TONE_HELP_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_TONE_HELP_ON]);
b = &w->bt[T2D_BT_PDA_TONE_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_TONE_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_TONE_EXIT_ON]);
b = &w->bt[T2D_BT_PDA_TONE_ACQUIRE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_TONE_ACQUIRE_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_TONE_ACQUIRE_ON]);
b->tnum = EXTRALS_ACQUIRE;
b = &w->bt[T2D_BT_PDA_TONE_PROCESS];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_TONE_PROCESS_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_TONE_PROCESS_ON]);
b->tnum = EXTRALS_PROCESS;
//ExtraLS
@@ -4616,10 +4617,10 @@ void doT2D(WGame &game) {
b = &w->bt[T2D_BT_PDA_HELP_WIN];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_LOG_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_LOG_WIN]);
b = &w->bt[T2D_BT_PDA_HELP_MOVE];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_LOG_WIN]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_LOG_WIN]);
b->lim.y2 = 20;
b = &w->bt[T2D_BT_PDA_HELP_SCROLL];
b->on = true;
@@ -4629,7 +4630,7 @@ void doT2D(WGame &game) {
b->lim.y2 = 335;
b = &w->bt[T2D_BT_PDA_HELP_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_PDA_HELP_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_PDA_HELP_EXIT_ON]);
for (i = 0; i < T2D_BM_PDA_HELP_TEXT_END - T2D_BM_PDA_HELP_TEXT_START; i++) {
w->bm[T2D_BM_PDA_HELP_TEXT_START + i].tnum = ((T2D_TEXT_PDA_HELP_START + i) << T2D_BM2TEXT_SHIFT);
@@ -4832,7 +4833,7 @@ void doT2D(WGame &game) {
if (bShowOnlyLoadWindow) {
b = &w->bt[T2D_BT_OPTIONS_MAINMENU];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_MAINMENU_OFF]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_MAINMENU_OFF]);
b->tnum = EXTRALS_MAINMENU;
} else {
//Tasti
@@ -4874,10 +4875,10 @@ void doT2D(WGame &game) {
}
b = &w->bt[T2D_BT_OPTIONS_FRECCIA_SU];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_FRECCIA_SU_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_FRECCIA_SU_ON]);
b = &w->bt[T2D_BT_OPTIONS_FRECCIA_GIU];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_ON]);
for (j = 0; j < 3; j++)
for (i = 0; i < 3; i++) {
b = &w->bt[T2D_BT_OPTIONS_SAVE_START + j * 3 + i];
@@ -4889,30 +4890,30 @@ void doT2D(WGame &game) {
}
b = &w->bt[T2D_BT_OPTIONS_SOUND];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_SOUND_OFF]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_SOUND_OFF]);
b->tnum = EXTRALS_SOUND;
b = &w->bt[T2D_BT_OPTIONS_MUSIC];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_MUSIC_OFF]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_MUSIC_OFF]);
b->tnum = EXTRALS_MUSIC;
b = &w->bt[T2D_BT_OPTIONS_SPEECH];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_SPEECH_OFF]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_SPEECH_OFF]);
b->tnum = EXTRALS_SPEECH;
b = &w->bt[T2D_BT_OPTIONS_SUBTITLES];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_SUBTITLES_OFF]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_SUBTITLES_OFF]);
b->tnum = EXTRALS_SUBTITLES;
b = &w->bt[T2D_BT_OPTIONS_SOUND_BARRA];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_SOUND_BARRA]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_SOUND_BARRA]);
b = &w->bt[T2D_BT_OPTIONS_MUSIC_BARRA];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_MUSIC_BARRA]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_MUSIC_BARRA]);
b = &w->bt[T2D_BT_OPTIONS_SPEECH_BARRA];
b->on = false;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_OPTIONS_SPEECH_BARRA]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_OPTIONS_SPEECH_BARRA]);
//Gestione Scritte
for (j = 0; j < 3; j++)
@@ -4977,17 +4978,17 @@ void doT2D(WGame &game) {
w->bm[T2D_BM_MAINMENU_WIN].py = 0;
w->bm[T2D_BM_MAINMENU_WIN].tnum &= ~T2D_BM_OFF;
- GetDDBitmapExtends(&tmp_rect, &w->bm[T2D_BM_MAINMENU_PLAY_ON]);
+ GetDDBitmapExtends(renderer, &tmp_rect, &w->bm[T2D_BM_MAINMENU_PLAY_ON]);
w->bm[T2D_BM_MAINMENU_PLAY_ON].px = w->bm[T2D_BM_MAINMENU_PLAY_OFF].px = (800 - (tmp_rect.x2 - tmp_rect.x1)) / 2;
w->bm[T2D_BM_MAINMENU_PLAY_ON].py = w->bm[T2D_BM_MAINMENU_PLAY_OFF].py = 146;
w->bm[T2D_BM_MAINMENU_PLAY_ON].tnum |= T2D_BM_OFF;
- GetDDBitmapExtends(&tmp_rect, &w->bm[T2D_BM_MAINMENU_LOAD_ON]);
+ GetDDBitmapExtends(renderer, &tmp_rect, &w->bm[T2D_BM_MAINMENU_LOAD_ON]);
w->bm[T2D_BM_MAINMENU_LOAD_ON].px = w->bm[T2D_BM_MAINMENU_LOAD_OFF].px = (800 - (tmp_rect.x2 - tmp_rect.x1)) / 2;
w->bm[T2D_BM_MAINMENU_LOAD_ON].py = w->bm[T2D_BM_MAINMENU_LOAD_OFF].py = 278;
w->bm[T2D_BM_MAINMENU_LOAD_ON].tnum |= T2D_BM_OFF;
- GetDDBitmapExtends(&tmp_rect, &w->bm[T2D_BM_MAINMENU_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &tmp_rect, &w->bm[T2D_BM_MAINMENU_EXIT_ON]);
w->bm[T2D_BM_MAINMENU_EXIT_ON].px = w->bm[T2D_BM_MAINMENU_EXIT_OFF].px = (800 - (tmp_rect.x2 - tmp_rect.x1)) / 2;
w->bm[T2D_BM_MAINMENU_EXIT_ON].py = w->bm[T2D_BM_MAINMENU_EXIT_OFF].py = 414;
w->bm[T2D_BM_MAINMENU_EXIT_ON].tnum |= T2D_BM_OFF;
@@ -5013,15 +5014,15 @@ void doT2D(WGame &game) {
//Tasti
b = &w->bt[T2D_BT_MAINMENU_PLAY];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_MAINMENU_PLAY_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_MAINMENU_PLAY_ON]);
b->tnum = EXTRALS_PLAYTHEGAME;
b = &w->bt[T2D_BT_MAINMENU_LOAD];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_MAINMENU_LOAD_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_MAINMENU_LOAD_ON]);
b->tnum = EXTRALS_LOADAGAME;
b = &w->bt[T2D_BT_MAINMENU_EXIT];
b->on = true;
- GetDDBitmapExtends(&b->lim, &w->bm[T2D_BM_MAINMENU_EXIT_ON]);
+ GetDDBitmapExtends(renderer, &b->lim, &w->bm[T2D_BM_MAINMENU_EXIT_ON]);
b->tnum = EXTRALS_EXIT;
//Settaggi iniziali
@@ -5215,7 +5216,7 @@ void doT2D(WGame &game) {
if (TheMessage->wparam1-- <= 0) {
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_PIC_LOW].tnum |= T2D_BM_OFF;
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_PIC_HI].tnum |= T2D_BM_OFF;
- j = rGetBitmapRealDimY(t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_PIC_LOW].tnum);
+ j = renderer.getBitmapRealDimY(t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_PIC_LOW].tnum);
if (TheMessage->bparam == T2D_SCANNER_PREVIEWING)
d = &t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_PIC_LOW];
else
diff --git a/engines/watchmaker/walk/ball.cpp b/engines/watchmaker/walk/ball.cpp
index 2fa90bc8713..2957fe69390 100644
--- a/engines/watchmaker/walk/ball.cpp
+++ b/engines/watchmaker/walk/ball.cpp
@@ -170,6 +170,7 @@ void UpdateBall(WGame &game, struct SPhys *p) {
int32 i;
t3dMESH *m;
Init &init = game.init;
+ auto &renderer = *game._renderer;
auto windowInfo = game._renderer->getScreenInfos();
// Se ha finito il tempo, cambia talpa
@@ -233,7 +234,7 @@ void UpdateBall(WGame &game, struct SPhys *p) {
}
}
// Aggiorna il cono visivo
- p->ViewCone.x1 = 130 + (int32)(Player->Mesh->Trasl.x / 255.0f * 0.341f) + windowInfo.width - rGetBitmapRealDimX(GopherMap);
+ p->ViewCone.x1 = 130 + (int32)(Player->Mesh->Trasl.x / 255.0f * 0.341f) + windowInfo.width - renderer.getBitmapRealDimX(GopherMap);
p->ViewCone.y1 = 146 - (int32)(Player->Mesh->Trasl.z / 255.0f * 0.341f);
tmp = Player->Dir * 20.0f;
zero = Player->Dir * 10.0f;
@@ -244,15 +245,15 @@ void UpdateBall(WGame &game, struct SPhys *p) {
DisplayD3DTriangle(*game._renderer, p->ViewCone.x1, p->ViewCone.y1, p->ViewCone.x2, p->ViewCone.y2, p->ViewCone.x3, p->ViewCone.y3, 125, 125, 125, 125);
// Aggiorna la mappa e le scritte
- DisplayDDBitmap(*game._renderer, GopherMap, windowInfo.width - rGetBitmapRealDimX(GopherMap), 0, 0, 0, 0, 0);
+ DisplayDDBitmap(*game._renderer, GopherMap, windowInfo.width - renderer.getBitmapRealDimX(GopherMap), 0, 0, 0, 0, 0);
for (i = 0; i < MAX_GOPHERS; i++)
- DisplayDDBitmap(*game._renderer, GopherPos[i], windowInfo.width - rGetBitmapRealDimX(GopherMap) +
- 130 + (int32)(Character[i + 1]->Mesh->Trasl.x / 255.0f * 0.341f) - rGetBitmapRealDimX(GopherPos[i]) / 2,
- 146 - (int32)(Character[i + 1]->Mesh->Trasl.z / 255.0f * 0.341f) - rGetBitmapRealDimY(GopherPos[i]) / 2, 0, 0, 0, 0);
+ DisplayDDBitmap(*game._renderer, GopherPos[i], windowInfo.width - renderer.getBitmapRealDimX(GopherMap) +
+ 130 + (int32)(Character[i + 1]->Mesh->Trasl.x / 255.0f * 0.341f) - renderer.getBitmapRealDimX(GopherPos[i]) / 2,
+ 146 - (int32)(Character[i + 1]->Mesh->Trasl.z / 255.0f * 0.341f) - renderer.getBitmapRealDimY(GopherPos[i]) / 2, 0, 0, 0, 0);
if (bGolfMode)
- DisplayDDBitmap(*game._renderer, GopherBall, windowInfo.width - rGetBitmapRealDimX(GopherMap) +
- 130 + (int32)(Palla50->Mesh->Trasl.x / 255.0f * 0.341f) - rGetBitmapRealDimX(GopherBall) / 2,
- 146 - (int32)(Palla50->Mesh->Trasl.z / 255.0f * 0.341f) - rGetBitmapRealDimY(GopherBall) / 2, 0, 0, 0, 0);
+ DisplayDDBitmap(*game._renderer, GopherBall, windowInfo.width - renderer.getBitmapRealDimX(GopherMap) +
+ 130 + (int32)(Palla50->Mesh->Trasl.x / 255.0f * 0.341f) - renderer.getBitmapRealDimX(GopherBall) / 2,
+ 146 - (int32)(Palla50->Mesh->Trasl.z / 255.0f * 0.341f) - renderer.getBitmapRealDimY(GopherBall) / 2, 0, 0, 0, 0);
if ((bGolfMode == 0) || (bGolfMode == 1)) {
DebugVideo(*game._renderer, 10, 32, "TimeLeft: %d", (int32)p->TimeLeft);
p->TimeLeft -= p->Td;
@@ -263,7 +264,7 @@ void UpdateBall(WGame &game, struct SPhys *p) {
DebugVideo(*game._renderer, 10, 48, "Angle: %d %d", 45 - (int)(Ball[CurGopher].Angle.x * 180.0f / T3D_PI), (int)(Ball[CurGopher].Angle.y * 180.0f / T3D_PI));
DebugVideo(*game._renderer, 10, 64, "Power: %d", (int)Ball[CurGopher].Angle.z);
}
- DisplayDDBitmap(*game._renderer, EndPic, windowInfo.width - rGetBitmapRealDimX(EndPic) - 20, windowInfo.height - rGetBitmapRealDimY(EndPic) - 20, 0, 0, 0, 0);
+ DisplayDDBitmap(*game._renderer, EndPic, windowInfo.width - renderer.getBitmapRealDimX(EndPic) - 20, windowInfo.height - renderer.getBitmapRealDimY(EndPic) - 20, 0, 0, 0, 0);
// Aggiorna la camera
ProcessGopherCamera(game);
Commit: 5844a03e49463b32396cb4a1ab646dc017e3a0ee
https://github.com/scummvm/scummvm/commit/5844a03e49463b32396cb4a1ab646dc017e3a0ee
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix some further warnings, and clean out some #if 0-ed code.
Changed paths:
engines/watchmaker/3d/material.cpp
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index ffa5789a9d7..d499fd48082 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -137,8 +137,9 @@ MaterialPtr rMergeMaterial(MaterialPtr Mat1, MaterialPtr Mat2) {
void rRemoveMaterials(Common::Array<Common::SharedPtr<gMaterial>> &m) {
for (auto &material : m) {
- m.clear();
+ material->clear();
}
+ m.clear();
}
Common::SharedPtr<gMaterial> rCopyMaterial(Common::SharedPtr<gMaterial> Mat1, Common::SharedPtr<gMaterial> Mat2) {
@@ -222,19 +223,18 @@ void rRemoveMaterial(Common::SharedPtr<gMaterial> &m) {
* Aggiunge un materiale alla MaterialList
* --------------------------------------------------*/
void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
- //warning("Stubbed: rAddToMaterialList");
- //D3DVERTEXBUFFERDESC VBDesc;
- gMaterial *cm;
- gBatchBlock *bb;
- int j;
-#if 0
- if (!mat)
- return;
-#endif
- if ((mat.Flags & T3D_MATERIAL_MOVIE))
+ gBatchBlock *bb = nullptr;
+
+ if ((mat.Flags & T3D_MATERIAL_MOVIE)) {
+ warning("Movie: %s %d", mat.Movie->_name.c_str(), mat.Texture->ID);
mat.Movie->updateMovie();
+ }
if ((mat.NumFaces() >= 3) && (mat.VBO)) {
+ if (mat.Texture) {
+ // if (mat.Texture->name == "./TMaps/bianco.tga")
+ // return;
+ }
bb = rNewBatchBlock(mat.Texture->ID, mat.Flags, 0, 0);
bb->ViewMatrixNum = ViewMatrixNum;
bb->FacesList = mat.getFacesList();
@@ -248,17 +248,6 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
}
}
mat.emptyFacesList(); // We may want to keep the reservation to avoid the extra reallocs here.
-// if ( bb->VB == g_lpD3DUserVertexBuffer )
-// DebugLogFile("User VB %s with %d verts",mat->Texture->Name,bb->NumVerts);
-#if 0
- if ((bb->NumVerts == 0) && (bb->VBO)) {
- if (bb->VB->GetVertexBufferDesc(&VBDesc) != D3D_OK)
- DebugLogFile("Can't get VB information for %s", mat->Texture->Name);
- else
- bb->NumVerts = (unsigned short int) VBDesc.dwNumVertices;
-// DebugLogFile("Saving VB %s with %d verts",mat->Texture->Name,bb->NumVerts);
- }
-#endif
}
for (auto &cm : mat.AddictionalMaterial) {
@@ -269,15 +258,6 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
bb->FacesList = cm->getFacesList();
bb->VBO = cm->VBO;
cm->emptyFacesList();
-#if 0
- if (bb->NumVerts == 0) {
- if (bb->VBO->GetVertexBufferDesc(&VBDesc) != D3D_OK)
- DebugLogFile("Can't get VB information for %s", mat->Texture->Name);
- else
- bb->NumVerts = (unsigned short int) VBDesc.dwNumVertices;
-// DebugLogFile("Saving VB %s with %d verts",mat->Texture->Name,bb->NumVerts);
- }
-#endif
}
}
Commit: ae7f5ed8412f427707cd6dd78f50ff226db3e4c7
https://github.com/scummvm/scummvm/commit/ae7f5ed8412f427707cd6dd78f50ff226db3e4c7
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Remove unused logo-code.
Changed paths:
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_2d.h
engines/watchmaker/3d/render/render.cpp
engines/watchmaker/main.cpp
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 8a7feac3e2b..a1240524de1 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -39,12 +39,8 @@
namespace Watchmaker {
-Rect gBlitterExtends;
-int gStencilBitDepth;
-
-gLogo Logos[10];
-gMaterial LogosMaterials[10];
-int NumLogosMaterials = 0, GlobalLogosDelay = 60 * 3;
+Rect gBlitterExtends;
+int gStencilBitDepth;
unsigned int CurLoaderFlags;
diff --git a/engines/watchmaker/3d/render/opengl_2d.h b/engines/watchmaker/3d/render/opengl_2d.h
index 3cd9551e295..97a669e0d46 100644
--- a/engines/watchmaker/3d/render/opengl_2d.h
+++ b/engines/watchmaker/3d/render/opengl_2d.h
@@ -29,16 +29,6 @@ namespace Watchmaker {
extern int gStencilBitDepth;
-struct gLogo {
- gMaterial *Material;
- Vertex Verts[4];
- int Delay;
-};
-
-extern gLogo Logos[];
-extern gMaterial LogosMaterials[];
-extern int NumLogosMaterials;
-
extern unsigned int CurLoaderFlags;
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/3d/render/render.cpp b/engines/watchmaker/3d/render/render.cpp
index 87cd0e3cd11..521b1f3a26e 100644
--- a/engines/watchmaker/3d/render/render.cpp
+++ b/engines/watchmaker/3d/render/render.cpp
@@ -398,7 +398,6 @@ void RenderGeometry(void) {
bool rRenderScene(void) {
unsigned int i, j;
bool hres;
- static int Logostops = 0;
static unsigned int dwFrameCount = 0;
g_renderer->setRenderState(RenderState::LIGHT, false);
@@ -504,70 +503,6 @@ bool rRenderScene(void) {
//tb
}
- // Display logos if exists
- if ((NumLogosMaterials) && (NumLogosMaterials != Logostops)) {
- gLogo *lpLogos = Logos;
- WORD Array[2 * 3];
-
- Logostops = 0;
-
- Array[0] = 0;
- Array[1] = 1;
- Array[2] = 2;
- Array[3] = 3;
- Array[4] = 2;
- Array[5] = 1;
-
- g_renderer->setTextureWrapMode(0, TextureWrapMode::CLAMP);
-
- g_renderer->setRenderState(RenderState::ALPHABLEND, false);
- g_renderer->setBlendFunc(BlendFactor::ONE, BlendFactor::ZERO);
- if (g_renderer->error()) {
- goto closescene;
- }
-
- rSetZBufferState(FALSE);
-
- for (i = 0; i < (unsigned int)NumLogosMaterials; i++, lpLogos++) {
- if (lpLogos->Verts[0].sy == lpLogos->Verts[2].sy) {
- Logostops++;
- continue;
- }
-
- if (lpLogos->Material->Texture) {
- g_renderer->setTexture(0, lpLogos->Material->Texture);
- }
-#if 0 // TODO!
- hres = g_renderer->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
- D3DFVF_TLVERTEX,
- lpLogos->Verts, 4,
- Array, 6, 0x0);
-#endif
- lpLogos->Delay--;
- if (lpLogos->Delay < 0) {
- lpLogos->Verts[0].sx += 0.5f;
- lpLogos->Verts[0].sy += 1.0f;
- lpLogos->Verts[0].sz += 0.008f;
- lpLogos->Verts[0].rhw = 1.0f / lpLogos->Verts[0].sz;
- lpLogos->Verts[1].sx -= 0.5f;
- lpLogos->Verts[1].sy += 1.0f;
- lpLogos->Verts[1].sz += 0.008f;
- lpLogos->Verts[1].rhw = 1.0f / lpLogos->Verts[1].sz;
- lpLogos->Verts[2].sx -= 0.5f;
- lpLogos->Verts[2].sy -= 1.0f;
- lpLogos->Verts[2].sz -= 0.008f;
- lpLogos->Verts[2].rhw = 1.0f / lpLogos->Verts[2].sz;
- lpLogos->Verts[3].sx += 0.5f;
- lpLogos->Verts[3].sy -= 1.0f;
- lpLogos->Verts[3].sz -= 0.008f;
- lpLogos->Verts[3].rhw = 1.0f / lpLogos->Verts[3].sz;
- }
- }
-
- rSetZBufferState(TRUE);
- g_renderer->setTextureWrapMode(0, TextureWrapMode::WRAP);
- }
-
if (gNumLinesArray && gNumPointsBuffer) {
rSaveViewMatrix();
rSetLinesViewMatrix();
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index b371bda2704..87784f8a195 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -104,9 +104,6 @@ int WMakerMain() {
} /*else
g_bReady = true;*/
- // rShowLogos(WmMiscDir,(char)sCheckEAX()); // Mostra Loghi schede 3D
-// rShowTrecLogo(WmMiscDir,1); // Mostra Loghi schede 3D
-
t3dAllocMemoryPool(1000000); // Alloca memory-pool
InitMessageSystem();
Commit: b8ead2dea25486cb0799245101cfc99026e6ecae
https://github.com/scummvm/scummvm/commit/b8ead2dea25486cb0799245101cfc99026e6ecae
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Move the GameRects to a class, instead of globals
Changed paths:
engines/watchmaker/classes/do_dialog.cpp
engines/watchmaker/classes/do_mouse.cpp
engines/watchmaker/game.h
engines/watchmaker/globvar.cpp
engines/watchmaker/globvar.h
engines/watchmaker/ll/ll_string.cpp
diff --git a/engines/watchmaker/classes/do_dialog.cpp b/engines/watchmaker/classes/do_dialog.cpp
index 75336b3d5a0..f3b98d92f4b 100644
--- a/engines/watchmaker/classes/do_dialog.cpp
+++ b/engines/watchmaker/classes/do_dialog.cpp
@@ -480,9 +480,9 @@ void UpdateDialogMenu(WGame &game, int16 dmx, int16 dmy, uint8 db) {
CurDlgItem = -1;
if ((db == ME_MLEFT) || (db == ME_MRIGHT)) {
// Se si cambia la logica di incremento variarla anche in PaintDialog() nella gestione delle freccette
- if (CheckRect(renderer, Diag2Up, dmx, dmy))
+ if (CheckRect(renderer, game._gameRect._diag2Up, dmx, dmy))
Diag2Base = ((Diag2Base - 1) < 0) ? 0 : Diag2Base - 1;
- else if (CheckRect(renderer, Diag2Down, dmx, dmy))
+ else if (CheckRect(renderer, game._gameRect._diag2Down, dmx, dmy))
if ((Diag2Base + 1 + MAX_DIAG2_ITEMS) <= ca2)
Diag2Base ++;
}
diff --git a/engines/watchmaker/classes/do_mouse.cpp b/engines/watchmaker/classes/do_mouse.cpp
index 2450ed43756..a5caaf2131a 100644
--- a/engines/watchmaker/classes/do_mouse.cpp
+++ b/engines/watchmaker/classes/do_mouse.cpp
@@ -79,7 +79,7 @@ void doMouseButton(WGame &game) {
// se sono su inventario
if (InvStatus & INV_ON) {
if ((InvStatus & INV_ON) && (InvStatus & INV_MODE1) && PlayerCanCall(game._gameVars)) {
- if (CheckRect(renderer, CallOtherPlayerRect, TheMessage->wparam1, TheMessage->wparam2)) {
+ if (CheckRect(renderer, game._gameRect._callOtherPlayerRect, TheMessage->wparam1, TheMessage->wparam2)) {
Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dRCALLOTHERPLAYER, 0, 0, nullptr, nullptr, nullptr);
return;
}
@@ -87,17 +87,17 @@ void doMouseButton(WGame &game) {
CurInvObj = WhatIcon(*game._renderer, TheMessage->wparam1, TheMessage->wparam2);
- if ((CurInvObj == iNULL) && (InvStatus & INV_MODE2) && CheckRect(renderer, BigIconRect, TheMessage->wparam1, TheMessage->wparam2))
+ if ((CurInvObj == iNULL) && (InvStatus & INV_MODE2) && CheckRect(renderer, game._gameRect._bigIconRect, TheMessage->wparam1, TheMessage->wparam2))
CurInvObj = BigInvObj;
if (CurInvObj == iNULL) {
// se ho cliccato su icona grande
if (InvStatus & INV_MODE2) {
- if (CheckRect(renderer, Inv1Up, TheMessage->wparam1, TheMessage->wparam2))
+ if (CheckRect(renderer, game._gameRect._inv1Up, TheMessage->wparam1, TheMessage->wparam2))
InventoryUp();
- else if (CheckRect(renderer, Inv1Down, TheMessage->wparam1, TheMessage->wparam2))
+ else if (CheckRect(renderer, game._gameRect._inv1Down, TheMessage->wparam1, TheMessage->wparam2))
InventoryDown();
- else if (CheckRect(renderer, CloseInvRect, TheMessage->wparam1, TheMessage->wparam2)) {
+ else if (CheckRect(renderer, game._gameRect._closeInvRect, TheMessage->wparam1, TheMessage->wparam2)) {
if (InvStatus & INV_MODE4) {
CurPlayer ^= 1;
ChangePlayer(game, (uint8)((CurPlayer ^ 1) + ocDARRELL));
@@ -115,17 +115,17 @@ void doMouseButton(WGame &game) {
game._renderer->setCurCameraViewport(t3dCurCamera->Fov, bSuperView);
BigInvObj = iNULL;
- } else if (CheckRect(renderer, QuitGameRect, TheMessage->wparam1, TheMessage->wparam2))
+ } else if (CheckRect(renderer, game._gameRect._quitGameRect, TheMessage->wparam1, TheMessage->wparam2))
CloseSys(game);
- else if (CheckRect(renderer, InvSaveRect, TheMessage->wparam1, TheMessage->wparam2) && !(InvStatus & INV_MODE4) && PlayerCanSave())
+ else if (CheckRect(renderer, game._gameRect._invSaveRect, TheMessage->wparam1, TheMessage->wparam2) && !(InvStatus & INV_MODE4) && PlayerCanSave())
Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_SAVE, 0, tOPTIONS, nullptr, nullptr, nullptr);
- else if (CheckRect(renderer, InvLoadRect, TheMessage->wparam1, TheMessage->wparam2) && !(InvStatus & INV_MODE4))
+ else if (CheckRect(renderer, game._gameRect._invLoadRect, TheMessage->wparam1, TheMessage->wparam2) && !(InvStatus & INV_MODE4))
Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_LOAD, 0, tOPTIONS, nullptr, nullptr, nullptr);
- else if (CheckRect(renderer, InvOptionsRect, TheMessage->wparam1, TheMessage->wparam2) && !(InvStatus & INV_MODE4))
+ else if (CheckRect(renderer, game._gameRect._invOptionsRect, TheMessage->wparam1, TheMessage->wparam2) && !(InvStatus & INV_MODE4))
Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_OPTIONS, 0, tOPTIONS, nullptr, nullptr, nullptr);
else {
ClearUseWith();
- if ((CheckRect(renderer, PlayerInvRect, TheMessage->wparam1, TheMessage->wparam2)) || (InvStatus & INV_MODE4)) {
+ if ((CheckRect(renderer, game._gameRect._playerInvRect, TheMessage->wparam1, TheMessage->wparam2)) || (InvStatus & INV_MODE4)) {
if (PlayerCanSwitch(game._gameVars, 0)) {
InvStatus ^= INV_MODE4;
CurPlayer ^= VICTORIA;
@@ -134,9 +134,9 @@ void doMouseButton(WGame &game) {
}
}
}
- } else if (CheckRect(renderer, Inv1Up, TheMessage->wparam1, TheMessage->wparam2))
+ } else if (CheckRect(renderer, game._gameRect._inv1Up, TheMessage->wparam1, TheMessage->wparam2))
InventoryUp();
- else if (CheckRect(renderer, Inv1Down, TheMessage->wparam1, TheMessage->wparam2))
+ else if (CheckRect(renderer, game._gameRect._inv1Down, TheMessage->wparam1, TheMessage->wparam2))
InventoryDown();
else {
@@ -162,7 +162,7 @@ void doMouseButton(WGame &game) {
//CurInvObj = iNULL;
return;
- } else if ((bUseWith & UW_ON) && (bUseWith & UW_USEDI) && CheckRect(renderer, UseIconRect, TheMessage->wparam1, TheMessage->wparam2)) {
+ } else if ((bUseWith & UW_ON) && (bUseWith & UW_USEDI) && CheckRect(renderer, game._gameRect._useIconRect, TheMessage->wparam1, TheMessage->wparam2)) {
ClearUseWith();
ClearText();
return;
@@ -282,13 +282,13 @@ void doMouseUpdate(WGame &game) {
if (InvStatus & INV_ON) {
if ((bLPressed) && (InvStatus & INV_MODE2)) {
t3dM3X3F t;
- t3dMatRot(&t, ((t3dF32)(TheMessage->lparam[1]) / (t3dF32)(BigIconRect.y2 - BigIconRect.y1))*T3D_PI * 2.0f,
- ((t3dF32)(TheMessage->lparam[0]) / (t3dF32)(BigIconRect.x1 - BigIconRect.x2))*T3D_PI * 2.0f, 0.0f);
+ t3dMatRot(&t, ((t3dF32)(TheMessage->lparam[1]) / (t3dF32)(game._gameRect._bigIconRect.y2 - game._gameRect._bigIconRect.y1))*T3D_PI * 2.0f,
+ ((t3dF32)(TheMessage->lparam[0]) / (t3dF32)(game._gameRect._bigIconRect.x1 - game._gameRect._bigIconRect.x2))*T3D_PI * 2.0f, 0.0f);
t3dMatMul(&BigIconM, &t, &BigIconM);
CurInvObj = BigInvObj;
} else {
CurInvObj = WhatIcon(*game._renderer, TheMessage->wparam1, TheMessage->wparam2);
- if ((CurInvObj == iNULL) && CheckRect(renderer, BigIconRect, TheMessage->wparam1, TheMessage->wparam2))
+ if ((CurInvObj == iNULL) && CheckRect(renderer, game._gameRect._bigIconRect, TheMessage->wparam1, TheMessage->wparam2))
CurInvObj = BigInvObj;
ShowInvObjName(init, CurInvObj);
}
diff --git a/engines/watchmaker/game.h b/engines/watchmaker/game.h
index 81d452d5884..4f3414c8aa6 100644
--- a/engines/watchmaker/game.h
+++ b/engines/watchmaker/game.h
@@ -62,6 +62,7 @@ public:
Init init;
sdl_wrapper *sdl;
GameVars _gameVars;
+ GameRect _gameRect;
Fonts _fonts;
WGame();
~WGame();
diff --git a/engines/watchmaker/globvar.cpp b/engines/watchmaker/globvar.cpp
index d29c7fda521..7b22928d81e 100644
--- a/engines/watchmaker/globvar.cpp
+++ b/engines/watchmaker/globvar.cpp
@@ -29,19 +29,21 @@
namespace Watchmaker {
// GAME RECT
-struct SRect BigIconRect = { INV_MARG_DX + 30, INV_MARG_UP - 12, 775, 587/*INV_MARG_DOWN+10 */};
-struct SRect UseIconRect = { 720, 517, 787, 587 };
-struct SRect CloseInvRect = { 667, 13, 782, 73 };
-struct SRect QuitGameRect = { 563, 13, 667, 73 };
-struct SRect PlayerInvRect = { 22, 13, 200, 73 };
-struct SRect InvSaveRect = { 223, 13, 284, 73 };
-struct SRect InvLoadRect = { 332, 13, 401, 73 };
-struct SRect InvOptionsRect = { 437, 13, 523, 73 };
-struct SRect Inv1Up = { 3 + 16, 67 + 56, 3 + 28, 67 + 96 };
-struct SRect Inv1Down = { 3 + 205, 67 + 411, 3 + 224, 67 + 444 };
-struct SRect Diag2Up = { 768, 510, 797, 537 };
-struct SRect Diag2Down = { 768, 568, 797, 595 };
-struct SRect CallOtherPlayerRect = { 22, 13, 22 + 192, 13 + 60 };
+GameRect::GameRect() {
+ _bigIconRect = {INV_MARG_DX + 30, INV_MARG_UP - 12, 775, 587 /*INV_MARG_DOWN+10 */};
+ _useIconRect = {720, 517, 787, 587};
+ _closeInvRect = {667, 13, 782, 73};
+ _quitGameRect = {563, 13, 667, 73};
+ _playerInvRect = {22, 13, 200, 73};
+ _invSaveRect = {223, 13, 284, 73};
+ _invLoadRect = {332, 13, 401, 73};
+ _invOptionsRect = {437, 13, 523, 73};
+ _inv1Up = {3 + 16, 67 + 56, 3 + 28, 67 + 96};
+ _inv1Down = {3 + 205, 67 + 411, 3 + 224, 67 + 444};
+ _diag2Up = {768, 510, 797, 537};
+ _diag2Down = {768, 568, 797, 595};
+ _callOtherPlayerRect = {22, 13, 22 + 192, 13 + 60};
+}
struct SD3DRect D3DRectsList[MAX_D3D_RECTS];
struct SD3DTriangle D3DTrianglesList[MAX_D3D_TRIANGLES];
struct SD3DBitmap D3DBitmapsList[MAX_D3D_BITMAPS];
diff --git a/engines/watchmaker/globvar.h b/engines/watchmaker/globvar.h
index adf9bd3ffa6..2b3a88e07cd 100644
--- a/engines/watchmaker/globvar.h
+++ b/engines/watchmaker/globvar.h
@@ -91,19 +91,22 @@ private:
};
// GAME RECT
-extern struct SRect BigIconRect;
-extern struct SRect UseIconRect;
-extern struct SRect QuitGameRect;
-extern struct SRect CloseInvRect;
-extern struct SRect PlayerInvRect;
-extern struct SRect InvSaveRect;
-extern struct SRect InvLoadRect;
-extern struct SRect InvOptionsRect;
-extern struct SRect Inv1Up;
-extern struct SRect Inv1Down;
-extern struct SRect Diag2Up;
-extern struct SRect Diag2Down;
-extern struct SRect CallOtherPlayerRect;
+struct GameRect {
+ GameRect();
+ SRect _bigIconRect;
+ SRect _useIconRect;
+ SRect _quitGameRect;
+ SRect _closeInvRect;
+ SRect _playerInvRect;
+ SRect _invSaveRect;
+ SRect _invLoadRect;
+ SRect _invOptionsRect;
+ SRect _inv1Up;
+ SRect _inv1Down;
+ SRect _diag2Up;
+ SRect _diag2Down;
+ SRect _callOtherPlayerRect;
+};
extern struct SD3DRect D3DRectsList[];
extern struct SD3DTriangle D3DTrianglesList[];
extern struct SD3DBitmap D3DBitmapsList[];
diff --git a/engines/watchmaker/ll/ll_string.cpp b/engines/watchmaker/ll/ll_string.cpp
index 7de591bb174..b0224b53905 100644
--- a/engines/watchmaker/ll/ll_string.cpp
+++ b/engines/watchmaker/ll/ll_string.cpp
@@ -300,9 +300,9 @@ void PaintInventory(WGame &game) {
}
}
} else if ((bUseWith & UW_ON) && (bUseWith & UW_USEDI)) {
- DisplayD3DRect(renderer, UseIconRect.x1 + 3, UseIconRect.y1 + 3, 63, 63, 22, 31, 22, 75);
- DisplayDDBitmap(renderer, IconsPics[UseWith[USED]], UseIconRect.x1 + 3, UseIconRect.y1 + 3, 0, 0, 0, 0);
- DisplayDDBitmap(renderer, Console2, UseIconRect.x1, UseIconRect.y1, 0, 0, 0, 0);
+ DisplayD3DRect(renderer, game._gameRect._useIconRect.x1 + 3, game._gameRect._useIconRect.y1 + 3, 63, 63, 22, 31, 22, 75);
+ DisplayDDBitmap(renderer, IconsPics[UseWith[USED]], game._gameRect._useIconRect.x1 + 3, game._gameRect._useIconRect.y1 + 3, 0, 0, 0, 0);
+ DisplayDDBitmap(renderer, Console2, game._gameRect._useIconRect.x1, game._gameRect._useIconRect.y1, 0, 0, 0, 0);
}
PaintDialog(game);
}
Commit: f1107b4eead1aaaf2ca9c3e7b2b4309a73ce4cfc
https://github.com/scummvm/scummvm/commit/f1107b4eead1aaaf2ca9c3e7b2b4309a73ce4cfc
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Refactor rCopyMaterial to instead use rCopyMaterialList
The previous solution didn't guarantee that we were allocating all the
target entries, and since we had replaced the old C-Array with a list
of SharedPtr, we need to ensure that those SharedPtrs point somewhere.
Changed paths:
engines/watchmaker/3d/animation.cpp
engines/watchmaker/3d/material.cpp
engines/watchmaker/3d/material.h
engines/watchmaker/3d/t3d_body.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index 53595993cf8..da05c54fc10 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -611,9 +611,7 @@ t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, t3dCHARACTER *b,
if (Mirror) { // Ogni personaggio potrebbe apparire in uno specchio
b->Body->MirrorMatTable.resize(b->Body->NumMaterials());
- for (i = 0; i < b->Body->NumMaterials(); i++) {
- rCopyMaterial(b->Body->MirrorMatTable[i], b->Body->MatTable[i]);
- }
+ rCopyMaterialList(b->Body->MirrorMatTable, b->Body->MatTable, b->Body->NumMaterials());
}
// Per le ombre, altezza e raggio del cilindro
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index d499fd48082..3f553a288a1 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -180,15 +180,24 @@ Common::SharedPtr<gMaterial> rCopyMaterial(Common::SharedPtr<gMaterial> Mat1, Co
Mat1->b = Mat2->b;
Mat1->NumAddictionalMaterial = Mat2->NumAddictionalMaterial;
- if (Mat2->NumAddictionalMaterial)
- Mat1->AddictionalMaterial.resize(Mat2->NumAddictionalMaterial); // TODO: Does this mean that we don't copy any extras?
-
- for (int i = 0; i < Mat2->NumAddictionalMaterial; i++)
- rCopyMaterial(Mat1->AddictionalMaterial[i], Mat2->AddictionalMaterial[i]);
+ rCopyMaterialList(Mat1->AddictionalMaterial, Mat2->AddictionalMaterial, Mat2->NumAddictionalMaterial); // TODO: Does this mean that we don't copy any extras?
return Mat1;
}
+void rCopyMaterialList(MaterialTable &dst, MaterialTable &src, int count) {
+ dst.resize(count);
+ if (count > src.size()) {
+ error("Copying more materials than there are in the src");
+ }
+ for (int i = 0; i < count; i++) {
+ if (!dst[i]) {
+ dst[i] = Common::SharedPtr<gMaterial>(new gMaterial());
+ }
+ rCopyMaterial(dst[i], src[i]);
+ }
+}
+
void gMaterial::clear() {
// TODO: This flag clearing doesn't happen in the original, but shouldn't matter as the class is instantiated again when used in Particles.
Flags = 0;
@@ -281,6 +290,8 @@ void rBuildMaterialList(MaterialTable &MatList, unsigned int NumMat, signed shor
MaterialTable rCreateMaterialList(int num) {
MaterialTable list;
+ // We avoid actually allocating the gMaterial-objects, as we want the size() to
+ // represent the actually loaded elements.
list.reserve(num);
return list;
}
diff --git a/engines/watchmaker/3d/material.h b/engines/watchmaker/3d/material.h
index 45b32e761b4..51ade968fda 100644
--- a/engines/watchmaker/3d/material.h
+++ b/engines/watchmaker/3d/material.h
@@ -89,7 +89,7 @@ MaterialPtr rAddMaterial(MaterialTable &MList, const Common::String &TextName, i
MaterialPtr rAddMaterial(gMaterial &Material, const Common::String &TextName, int NumFaces, unsigned int LoaderFlags);
void rRemoveMaterial(MaterialPtr &m);
void rRemoveMaterials(MaterialTable &m);
-MaterialPtr rCopyMaterial(MaterialPtr Mat1, MaterialPtr Mat2);
+void rCopyMaterialList(MaterialTable &dst, MaterialTable &src, int count);
MaterialPtr rMergeMaterial(MaterialPtr Mat1, MaterialPtr Mat2);
void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum);
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index 5c7075348ab..f00a9606d40 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -592,12 +592,8 @@ t3dBODY *t3dBODY::loadFromStream(WGame &game, const Common::String &pname, Commo
#endif
if (Mirror) { // Se c'era uno specchio
- gMaterial *mat1, *mat2;
-
this->MirrorMatTable = rCreateMaterialList(this->NumMaterials());
-
- for (uint16 i = 0; i < this->NumMaterials(); i++, mat1++, mat2++) // Per ogni materiale allocato
- rCopyMaterial(this->MirrorMatTable[i], this->MatTable[i]);
+ rCopyMaterialList(this->MirrorMatTable, this->MatTable, this->NumMaterials());
}
Commit: a0191f939ff74923080585663f1b056bac79f61b
https://github.com/scummvm/scummvm/commit/a0191f939ff74923080585663f1b056bac79f61b
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Unstub UpdateRoomVisibility
While at it, also drop cstring/stdarg includes in ll_util.cpp
Changed paths:
engines/watchmaker/3d/t3d_body.cpp
engines/watchmaker/classes/do_camera.cpp
engines/watchmaker/classes/do_keyboard.cpp
engines/watchmaker/classes/do_operate.cpp
engines/watchmaker/classes/do_player.cpp
engines/watchmaker/game.cpp
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/ll/ll_diary.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/ll/ll_util.h
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index f00a9606d40..d4420da9707 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -30,6 +30,7 @@
#include "watchmaker/3d/math/llmath.h"
#include "watchmaker/3d/t3d_face.h"
#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/file_utils.h"
#include "watchmaker/game.h"
#include "watchmaker/ll/ll_system.h"
#include "watchmaker/renderer.h"
@@ -300,14 +301,15 @@ void LoadBounds(WorkDirs &workDirs, const char *pname, t3dBODY *b) {
/* -----------------10/06/99 16.03-------------------
* LoadLightmaps
* --------------------------------------------------*/
-void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
+void LoadLightmaps(WGame &game, t3dBODY *b) {
uint32 NumLightmaps;//, num;
gVertex *gv;
uint8 rr, gg, bb;
int32 Map, alphaval1, alphaval2, alphaval3;
+ WorkDirs &workDirs = game.workDirs;
Common::String Appo = setDirectoryAndName(workDirs._lightmapsDir, b->name);
- Appo = Appo.substr(0, Appo.size() - 3) + "map"; // TODO: Create util-functions for this lookup
+ Appo = replaceExtension(Appo.c_str(), "map");
auto stream = workDirs.resolveFile(Appo);
if (!stream) {
@@ -329,7 +331,10 @@ void LoadLightmaps(WorkDirs &workDirs, t3dBODY *b) {
Appo = Common::String::format("%s_%d.tga", root.c_str(), i);
/*num = */stream->readSint32LE();
- if (rAddMaterial(*b->LightmapTable[i], Appo, 0, 0) == nullptr)
+ MaterialPtr mat(new gMaterial());
+ assert(b->LightmapTable.size() == i);
+ b->LightmapTable.push_back(mat);
+ if (!game._renderer->addMaterial(*b->LightmapTable[i], Appo, 0, 0))
return;
b->LightmapTable[i]->clear();
@@ -562,7 +567,7 @@ t3dBODY *t3dBODY::loadFromStream(WGame &game, const Common::String &pname, Commo
// TODO: This looks odd
if (!pname.equalsIgnoreCase("rxt.t3d") || !pname.equalsIgnoreCase("rxt-b.t3d") || !pname.equalsIgnoreCase("rxt-c.t3d") ||
!pname.equalsIgnoreCase("rxt-d.t3d") || !pname.equalsIgnoreCase("rxt-e.t3d") || !pname.equalsIgnoreCase("rxt.t3d-f"))
- LoadLightmaps(workdirs, this);
+ LoadLightmaps(game, this);
}
if ((LoaderFlags & T3D_OUTDOORLIGHTS)) { // Carica le luci per l'esterno
if (pname.equalsIgnoreCase("rxt.t3d")) {
diff --git a/engines/watchmaker/classes/do_camera.cpp b/engines/watchmaker/classes/do_camera.cpp
index f0f6870ec10..44202cbc8e9 100644
--- a/engines/watchmaker/classes/do_camera.cpp
+++ b/engines/watchmaker/classes/do_camera.cpp
@@ -636,7 +636,7 @@ void ProcessCamera(WGame &game) {
game._gameVars.setCurRoomId(getRoomFromStr(init, croom->name));
t3dCurRoom = PortalCrossed;
PortalCrossed = nullptr;
- UpdateRoomVisibility(init);
+ UpdateRoomVisibility(game);
if (Player && t3dCurRoom) {
Player->Walk.Panel = t3dCurRoom->Panel[t3dCurRoom->CurLevel];
diff --git a/engines/watchmaker/classes/do_keyboard.cpp b/engines/watchmaker/classes/do_keyboard.cpp
index a0e3423ce48..18e3a2fd1b9 100644
--- a/engines/watchmaker/classes/do_keyboard.cpp
+++ b/engines/watchmaker/classes/do_keyboard.cpp
@@ -358,7 +358,7 @@ void ProcessKeyboard(WGame &game) {
if (KeyUp(Common::KEYCODE_p)) {
if (KeyDown(Common::KEYCODE_LSHIFT) || KeyDown(Common::KEYCODE_RSHIFT)) {
if (++bnd_lev > 5) bnd_lev = 0;
- SetBndLevel(game.init, NULL, bnd_lev);
+ SetBndLevel(game, NULL, bnd_lev);
DebugLogWindow("BndLev %d", bnd_lev);
} else
bShowPanels ^= 1; // Escono Pannelli
diff --git a/engines/watchmaker/classes/do_operate.cpp b/engines/watchmaker/classes/do_operate.cpp
index fc6223f02b8..e1734b7b0e2 100644
--- a/engines/watchmaker/classes/do_operate.cpp
+++ b/engines/watchmaker/classes/do_operate.cpp
@@ -951,8 +951,8 @@ void doOperate(WGame &game, int32 obj) {
init.Sound[wB451].flags &= ~SOUND_ON;
StopSound(wB451);
- SetBndLevel(init, nullptr, 1);
- SetBndLevel(init, "r47.t3d", 0);
+ SetBndLevel(game, nullptr, 1);
+ SetBndLevel(game, "r47.t3d", 0);
if (!(init.Obj[o45ALLOGGIAMENTO].flags & EXTRA)) {
IncCurTime(game, 15);
@@ -984,8 +984,8 @@ void doOperate(WGame &game, int32 obj) {
init.Sound[wB451].flags |= SOUND_ON;
StartSound(game, wB451);
- SetBndLevel(init, nullptr, 0);
- SetBndLevel(init, "r47.t3d", 1);
+ SetBndLevel(game, nullptr, 0);
+ SetBndLevel(game, "r47.t3d", 1);
RemoveEvent(&Game, EventClass::MC_PLAYER, ME_PLAYERTIMER);
if (init.Dialog[dR471].flags & DIALOG_DONE)
diff --git a/engines/watchmaker/classes/do_player.cpp b/engines/watchmaker/classes/do_player.cpp
index 13a132d5a7d..6a3544a360d 100644
--- a/engines/watchmaker/classes/do_player.cpp
+++ b/engines/watchmaker/classes/do_player.cpp
@@ -427,7 +427,7 @@ void ChangePlayer(WGame &game, uint8 oc) {
warning("Changing Room to |%s| pos: %d an: %d", PlayerStand[CurPlayer].roomName.c_str(), PlayerStand[CurPlayer].pos, PlayerStand[CurPlayer].an);
ChangeRoom(game, PlayerStand[CurPlayer].roomName, PlayerStand[CurPlayer].pos, 0);
if ((curRoom == r15) || (curRoom == r1F))
- SetBndLevel(init, nullptr, PlayerStand[CurPlayer].bnd);
+ SetBndLevel(game, nullptr, PlayerStand[CurPlayer].bnd);
CharStop(ocCURPLAYER);
Player->Mesh->Flags |= T3D_MESH_DEFAULTANIM;
diff --git a/engines/watchmaker/game.cpp b/engines/watchmaker/game.cpp
index 91d958fad62..a31e872a75b 100644
--- a/engines/watchmaker/game.cpp
+++ b/engines/watchmaker/game.cpp
@@ -499,7 +499,7 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
* --------------------------------------------------*/
void WGame::UpdateAll() {
int32 i;
- UpdateRoomVisibility(init);
+ UpdateRoomVisibility(*this);
for (i = 0; i < NumLoadedFiles; i++) {
if (LoadedFiles[i].b) {
HideRoomMeshes(init, LoadedFiles[i].b);
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index 6383114e395..b0b4ab4937e 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -440,7 +440,7 @@ void ProcessATFDO(WGame &game, int32 in) {
init.Obj[o43CANCELLO01].flags |= EXTRA2;
}
- SetBndLevel(init, "r43.t3d", 1);
+ SetBndLevel(game, "r43.t3d", 1);
StartSound(game, w428B);
}
break;
@@ -479,7 +479,7 @@ void ProcessATFDO(WGame &game, int32 in) {
break;
case f4ASETBND44:
- SetBndLevel(init, "r44.t3d", t3dCurRoom->CurLevel);
+ SetBndLevel(game, "r44.t3d", t3dCurRoom->CurLevel);
if (!(init.Obj[o4ALEVA].flags & EXTRA2)) {
IncCurTime(game, 15);
@@ -734,7 +734,7 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
ForcedCamera = in;
break;
case ATF_SET_BND_LEVEL:
- SetBndLevel(init, (char *) ha->RoomName.rawArray(), in);
+ SetBndLevel(game, (char *) ha->RoomName.rawArray(), in);
break;
case ATF_TO_1ST_SENT:
ToFirstPersonSent = (in >= TEXT1) ? init.Obj[obj].text[in - TEXT1] : init.Obj[obj].action[CurPlayer];
@@ -768,7 +768,7 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
break;
case ATF_SUB_MUSIC:
CurSubMusic = in;
- UpdateRoomVisibility(init);
+ UpdateRoomVisibility(game);
break;
case ATF_EXIT:
StopAnim(game, an);
@@ -853,11 +853,11 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
case ATFP_OFF:
ChangeMeshFlags(h->sub[in - 1].ptr, +1, T3D_MESH_NOPORTALCHECK);
- UpdateRoomVisibility(init);
+ UpdateRoomVisibility(game);
break;
case ATFP_ON:
ChangeMeshFlags(h->sub[in - 1].ptr, -1, T3D_MESH_NOPORTALCHECK);
- UpdateRoomVisibility(init);
+ UpdateRoomVisibility(game);
break;
case ATFM_OFF:
ChangeMeshFlags(h->sub[in - 1].ptr, +1, T3D_MESH_HIDDEN);
@@ -1110,7 +1110,7 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
bGolfMode = in;
break;
case ATF_VISIBILITY:
- UpdateRoomVisibility(init);
+ UpdateRoomVisibility(game);
break;
case ATF_INC_TIME:
diff --git a/engines/watchmaker/ll/ll_diary.cpp b/engines/watchmaker/ll/ll_diary.cpp
index fe31c5f9b90..df5eb125773 100644
--- a/engines/watchmaker/ll/ll_diary.cpp
+++ b/engines/watchmaker/ll/ll_diary.cpp
@@ -142,7 +142,7 @@ void StartDiary(WGame &game, int32 room, t3dV3F *pos) {
init.Anim[ca].flags |= ANIM_DIARY;
if ((d->item[d->cur].bnd < 255) && !(bPlayerSuBasamento && (d->room == rXT))) {
d->item[d->cur].saved_bnd = GetBndLevel((char *) init.Anim[ca].RoomName.rawArray());
- SetBndLevel(init, (char *)init.Anim[ca].RoomName.rawArray(), d->item[d->cur].bnd);
+ SetBndLevel(game, (char *)init.Anim[ca].RoomName.rawArray(), d->item[d->cur].bnd);
} else d->item[d->cur].saved_bnd = 255;
if (d->obj) CharSetPosition(d->obj, init.Anim[ca].pos, (char *)init.Anim[ca].RoomName.rawArray());
@@ -239,7 +239,7 @@ void StopDiary(WGame &game, int32 room, int32 obj, uint8 only_overtime) {
StopAnim(game, an);
if ((d->item[d->cur].saved_bnd < 255)) {
if (!(bPlayerSuBasamento && (d->room == rXT)))
- SetBndLevel(init, (char *)init.Anim[an].RoomName.rawArray(), d->item[d->cur].saved_bnd);
+ SetBndLevel(game, (char *)init.Anim[an].RoomName.rawArray(), d->item[d->cur].saved_bnd);
d->item[d->cur].saved_bnd = 255;
}
Character[d->obj]->Flags |= T3D_CHARACTER_HIDE;
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 961202d2346..56a7ebde93d 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -26,29 +26,30 @@
#include <cstring>
#include <stdarg.h>
#include "watchmaker/ll/ll_util.h"
-#include "watchmaker/types.h"
-#include "watchmaker/sysdef.h"
-#include "watchmaker/globvar.h"
-#include "watchmaker/windows_hacks.h"
-#include "watchmaker/utils.h"
-#include "watchmaker/3d/loader.h"
-#include "watchmaker/3d/geometry.h"
-#include "watchmaker/define.h"
-#include "watchmaker/message.h"
-#include "watchmaker/schedule.h"
-#include "watchmaker/walk/act.h"
-#include "watchmaker/classes/do_system.h"
#include "watchmaker/ll/ll_anim.h"
-#include "watchmaker/3d/t3d_mesh.h"
-#include "watchmaker/3d/math/llmath.h"
-#include "watchmaker/ll/ll_regen.h"
-#include "watchmaker/main.h"
-#include "watchmaker/classes/do_camera.h"
+#include "watchmaker/ll/ll_diary.h"
#include "watchmaker/ll/ll_mesh.h"
+#include "watchmaker/ll/ll_regen.h"
#include "watchmaker/3d/animation.h"
-#include "watchmaker/ll/ll_diary.h"
+#include "watchmaker/3d/geometry.h"
+#include "watchmaker/3d/loader.h"
+#include "watchmaker/3d/math/llmath.h"
+#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/classes/do_camera.h"
+#include "watchmaker/classes/do_operate.h"
+#include "watchmaker/classes/do_system.h"
+#include "watchmaker/define.h"
+#include "watchmaker/globvar.h"
+#include "watchmaker/main.h"
+#include "watchmaker/message.h"
#include "watchmaker/renderer.h"
+#include "watchmaker/schedule.h"
+#include "watchmaker/sysdef.h"
#include "watchmaker/t2d/t2d_internal.h"
+#include "watchmaker/types.h"
+#include "watchmaker/utils.h"
+#include "watchmaker/walk/act.h"
+#include "watchmaker/windows_hacks.h"
namespace Watchmaker {
@@ -314,12 +315,12 @@ void UpdateRoomInfo(Init &init) {
/* -----------------13/10/98 15.00-------------------
* UpdateRoomVisibility
* --------------------------------------------------*/
-void UpdateRoomVisibility(Init &init) {
- warning("Stubbed UpdateRoomVisibility");
-#if 0
- t3dU16 i, j;
+void UpdateRoomVisibility(WGame &game) {
+ uint32 i, j;
t3dBODY *pr;
- t3dU8 cr;
+ uint8 cr;
+
+ Init &init = game.init;
if (!t3dCurRoom) return;
@@ -331,11 +332,11 @@ void UpdateRoomVisibility(Init &init) {
}
// Aggiunge room attuale
- if (cr = (t3dU8)getRoomFromStr(t3dCurRoom->Name))
+ if (cr = (uint8)getRoomFromStr(init, t3dCurRoom->name))
init.Room[cr].flags |= ROOM_VISIBLE;
if (bShowRoomDescriptions)
- UpdateRoomInfo();
+ UpdateRoomInfo(init);
// if( !( Room[cr].flags & ROOM_OLDVISIBLE ) )
// Event( EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND*3, 0, EFFECT_ROOMINFO, NULL, NULL, NULL );
@@ -354,27 +355,29 @@ void UpdateRoomVisibility(Init &init) {
if ((cr == r48) && !(init.Room[cr].flags & ROOM_VISITED))
Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR481, 0, 0, NULL, NULL, NULL);
}
+#if 0
// Se ha cambiato stanza cambia anche l'environment
sSetEnvironment(init.Room[cr].env);
// Se ha cambiato stanza cambia anche la musica
if (!(LoaderFlags & T3D_NOMUSIC) && (init.Room[cr].music != nNULL))
PlayMusic(init.Room[cr].music, 3000, 3000);
+#endif
init.Room[cr].flags |= ROOM_VISITED;
// Aggiorna oggetti speciali
- UpdateSpecial(cr);
+ UpdateSpecial(game, cr);
// Cerca nelle stanze visbili con ricorsione 2
- for (i = 0; i < t3dCurRoom->NumMeshes; i++) {
+ for (i = 0; i < t3dCurRoom->NumMeshes(); i++) {
if (!(pr = t3dCurRoom->MeshTable[i].PortalList) || (t3dCurRoom->MeshTable[i].Flags & T3D_MESH_NOPORTALCHECK))
continue;
- if (cr = (t3dU8)getRoomFromStr(init, pr->Name))
+ if (cr = (uint8)getRoomFromStr(init, pr->name))
init.Room[cr].flags |= ROOM_VISIBLE;
- for (j = 0; j < pr->NumMeshes; j++)
+ for (j = 0; j < pr->NumMeshes(); j++)
if ((pr->MeshTable[j].PortalList) && !(pr->MeshTable[j].Flags & T3D_MESH_NOPORTALCHECK))
- if (cr = (t3dU8)getRoomFromStr(init, pr->MeshTable[j].PortalList->Name))
+ if (cr = (uint8)getRoomFromStr(init, pr->MeshTable[j].PortalList->name))
init.Room[cr].flags |= ROOM_VISIBLE;
}
@@ -392,8 +395,9 @@ void UpdateRoomVisibility(Init &init) {
if ((init.Room[i].sounds[j] == wFONTANA) &&
(((t3dCurTime >= 1300) && (t3dCurTime <= 1310)) || (t3dCurTime >= 1800))
) continue;
-
+#if 0
StartSound(init.Room[i].sounds[j]);
+#endif
}
// DebugFile("%d: %d %s",i,RoomVisibility[i],Room[RoomVisibility[i]].name);
@@ -402,39 +406,41 @@ void UpdateRoomVisibility(Init &init) {
if (!(init.Anim[init.Room[i].anims[j]].active)) {
if ((init.Anim[init.Room[i].anims[j]].obj != aNULL) && (Character[init.Anim[init.Room[i].anims[j]].obj])) {
Character[init.Anim[init.Room[i].anims[j]].obj]->Flags &= ~T3D_CHARACTER_HIDE;
- CharSetPosition(init.Anim[init.Room[i].anims[j]].obj, init.Anim[init.Room[i].anims[j]].pos, init.Anim[init.Room[i].anims[j]].RoomName);
+ CharSetPosition(init.Anim[init.Room[i].anims[j]].obj, init.Anim[init.Room[i].anims[j]].pos, (const char*)init.Anim[init.Room[i].anims[j]].RoomName.rawArray());
}
- DebugLogWindow("Staring Bkg Anim %d | Obj %d Pos %d", init.Room[i].anims[j], init.Anim[init.Room[i].anims[j]].obj, Anim[Room[i].anims[j]].pos);
- StartAnim(init.Room[i].anims[j]);
+ DebugLogWindow("Staring Bkg Anim %d | Obj %d Pos %d", init.Room[i].anims[j], init.Anim[init.Room[i].anims[j]].obj, init.Anim[init.Room[i].anims[j]].pos);
+ StartAnim(game, init.Room[i].anims[j]);
}
- StartDiary(i, NULL);
+ StartDiary(game, i, NULL);
}
// Spegne le animazioni delle stanze che non si vedono piu'
else if (init.Room[i].flags & ROOM_OLDVISIBLE) {
// Leva effetti di background
- for (j = 0; j < MAX_SOUNDS_IN_ROOM; j++)
+ for (j = 0; j < MAX_SOUNDS_IN_ROOM; j++) {
+#if 0
if ((init.Room[i].sounds[j]) && (init.Sound[init.Room[i].sounds[j]].flags & SOUND_ON))
StopSound(init.Room[i].sounds[j]);
+#endif
+ }
// Se non e' piu' in vista
for (j = 0; j < MAX_ANIMS_IN_ROOM; j++)
if ((init.Room[i].anims[j]) && (init.Anim[init.Room[i].anims[j]].flags & ANIM_ON)) {
if (Character[init.Anim[init.Room[i].anims[j]].obj]) Character[init.Anim[init.Room[i].anims[j]].obj]->Flags |= T3D_CHARACTER_HIDE;
- StopAnim(init.Room[i].anims[j]);
+ StopAnim(game, init.Room[i].anims[j]);
}
init.Room[i].flags &= ~ROOM_OLDVISIBLE;
StopDiary(game, i, 0, 0);
}
}
-#endif
}
/* -----------------12/06/00 10.12-------------------
* SetBndLevel
* --------------------------------------------------*/
-bool SetBndLevel(Init &init, const char *roomname, int32 lev) {
+bool SetBndLevel(WGame &game, const char *roomname, int32 lev) {
t3dBODY *t;
int32 i;
@@ -460,7 +466,7 @@ bool SetBndLevel(Init &init, const char *roomname, int32 lev) {
CurFloorY = t->PanelHeight[t->CurLevel];
AddMeshModifier(t->name, MM_SET_BND_LEVEL, &lev);
- UpdateRoomVisibility(init);
+ UpdateRoomVisibility(game);
DebugLogFile("SETBND: %s, %d", t->name.c_str(), lev);
diff --git a/engines/watchmaker/ll/ll_util.h b/engines/watchmaker/ll/ll_util.h
index 31876f11691..ca48385c284 100644
--- a/engines/watchmaker/ll/ll_util.h
+++ b/engines/watchmaker/ll/ll_util.h
@@ -32,11 +32,11 @@ namespace Watchmaker {
int32 LoadDDBitmap(WGame &game, const char *n, uint8 flags);
void LoadFont(WGame &game, struct SFont *f, const char *n);
-void UpdateRoomVisibility(Init &init);
+void UpdateRoomVisibility(WGame &game);
t3dMESH *LinkMeshToStr(Init &init, const Common::String &str);
int16 getRoomFromStr(Init &init, const Common::String &s);
void ChangeRoom(WGame &game, Common::String n, uint8 pos, int32 an);
-bool SetBndLevel(Init &init, const char *roomname, int32 lev);
+bool SetBndLevel(WGame &game, const char *roomname, int32 lev);
int32 GetBndLevel(char *roomname);
void GetDDBitmapExtends(Renderer &renderer, struct SRect *r, struct SDDBitmap *b);
void DisplayDDBitmap(Renderer &, int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
Commit: 4fac22a1b73295f60a3a056cbab59ef3df8cf7d2
https://github.com/scummvm/scummvm/commit/4fac22a1b73295f60a3a056cbab59ef3df8cf7d2
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Move INV VARS into Init, to reduce the number of global constructors.
Changed paths:
engines/watchmaker/classes/do_camera.cpp
engines/watchmaker/classes/do_mouse.cpp
engines/watchmaker/game.cpp
engines/watchmaker/globvar.cpp
engines/watchmaker/globvar.h
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/main.cpp
diff --git a/engines/watchmaker/classes/do_camera.cpp b/engines/watchmaker/classes/do_camera.cpp
index 44202cbc8e9..ff02d5334a0 100644
--- a/engines/watchmaker/classes/do_camera.cpp
+++ b/engines/watchmaker/classes/do_camera.cpp
@@ -254,11 +254,11 @@ void NextCameraStep(WGame &game) {
Init &init = game.init;
if (bMovingCamera == 2) {
- if ((CameraDummy.CurFrame >= 0) && (CameraDummy.Anim.BoneTable)) {
- if ((bone = &CameraDummy.Anim.BoneTable[33]) && (bone->Trasl))
- t3dVectCopy(&t3dCurCamera->Source, &bone->Trasl[CameraDummy.CurFrame]);
- if ((bone = &CameraDummy.Anim.BoneTable[34]) && (bone->Trasl))
- t3dVectCopy(&t3dCurCamera->Target, &bone->Trasl[CameraDummy.CurFrame]);
+ if ((game.init._globals._invVars.CameraDummy.CurFrame >= 0) && (game.init._globals._invVars.CameraDummy.Anim.BoneTable)) {
+ if ((bone = &game.init._globals._invVars.CameraDummy.Anim.BoneTable[33]) && (bone->Trasl))
+ t3dVectCopy(&t3dCurCamera->Source, &bone->Trasl[game.init._globals._invVars.CameraDummy.CurFrame]);
+ if ((bone = &game.init._globals._invVars.CameraDummy.Anim.BoneTable[34]) && (bone->Trasl))
+ t3dVectCopy(&t3dCurCamera->Target, &bone->Trasl[game.init._globals._invVars.CameraDummy.CurFrame]);
} else {
t3dCurCamera = DestCamera;
CurCameraSubStep = CurCameraStep = NumCameraSteps = 0;
diff --git a/engines/watchmaker/classes/do_mouse.cpp b/engines/watchmaker/classes/do_mouse.cpp
index a5caaf2131a..fef9af062fd 100644
--- a/engines/watchmaker/classes/do_mouse.cpp
+++ b/engines/watchmaker/classes/do_mouse.cpp
@@ -147,7 +147,7 @@ void doMouseButton(WGame &game) {
}
if ((BigInvObj != CurInvObj) && !(bUseWith & UW_ON)) {
- t3dMatIdentity(&BigIconM);
+ t3dMatIdentity(&game.init._globals._invVars.BigIconM);
BigInvObj = CurInvObj;
}
@@ -284,7 +284,7 @@ void doMouseUpdate(WGame &game) {
t3dM3X3F t;
t3dMatRot(&t, ((t3dF32)(TheMessage->lparam[1]) / (t3dF32)(game._gameRect._bigIconRect.y2 - game._gameRect._bigIconRect.y1))*T3D_PI * 2.0f,
((t3dF32)(TheMessage->lparam[0]) / (t3dF32)(game._gameRect._bigIconRect.x1 - game._gameRect._bigIconRect.x2))*T3D_PI * 2.0f, 0.0f);
- t3dMatMul(&BigIconM, &t, &BigIconM);
+ t3dMatMul(&game.init._globals._invVars.BigIconM, &t, &game.init._globals._invVars.BigIconM);
CurInvObj = BigInvObj;
} else {
CurInvObj = WhatIcon(*game._renderer, TheMessage->wparam1, TheMessage->wparam2);
diff --git a/engines/watchmaker/game.cpp b/engines/watchmaker/game.cpp
index a31e872a75b..81317ba3abe 100644
--- a/engines/watchmaker/game.cpp
+++ b/engines/watchmaker/game.cpp
@@ -290,7 +290,7 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
uint16 i = 0;
warning("--=>> %s <<=--: LoaderFlags: %08X", name.c_str(), LoaderFlags);
- t3dCurCamera = &t3dIconCamera;
+ t3dCurCamera = &init._globals._invVars.t3dIconCamera;
auto windowInfo = _renderer->getScreenInfos();
@@ -308,7 +308,7 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
// PrintLoading();
if (!(LoaderFlags & T3D_NOICONS))
- if (!(t3dIcons = t3dLoadRoom(*this, "Icons.t3d", t3dIcons, &i, (LoaderFlags | T3D_NORECURSION | T3D_NOLIGHTMAPS | T3D_NOBOUNDS | T3D_NOCAMERAS | T3D_STATIC_SET1)))) {
+ if (!(init._globals._invVars.t3dIcons = t3dLoadRoom(*this, "Icons.t3d", init._globals._invVars.t3dIcons, &i, (LoaderFlags | T3D_NORECURSION | T3D_NOLIGHTMAPS | T3D_NOBOUNDS | T3D_NOCAMERAS | T3D_STATIC_SET1)))) {
warning("Error loading Icons");
return false;
}
@@ -467,13 +467,14 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
CurFloorY = t3dCurRoom->PanelHeight[t3dCurRoom->CurLevel];
- t3dMatIdentity(&CameraDummy.Matrix);
+ t3dMatIdentity(&init._globals._invVars.CameraDummy.Matrix);
t3dStartTime();
if (!t3dCurRoom->CameraTable.empty())
if (!(t3dCurCamera = PickCamera(t3dCurRoom, 0)))
t3dCurCamera = &t3dCurRoom->CameraTable[0];
- if (t3dCurCamera) memcpy(&t3dIconCamera, t3dCurCamera, sizeof(t3dCAMERA));
+ if (t3dCurCamera)
+ init._globals._invVars.t3dIconCamera = *t3dCurCamera;
SetCurPlayerPosTo_9x(_gameVars, init);
diff --git a/engines/watchmaker/globvar.cpp b/engines/watchmaker/globvar.cpp
index 7b22928d81e..68dbc763722 100644
--- a/engines/watchmaker/globvar.cpp
+++ b/engines/watchmaker/globvar.cpp
@@ -168,12 +168,6 @@ uint16 AnimAutoPush;
int32 CameraTargetObj, CameraTargetBone;
int32 TimeWalk, TimeAnim;
-// INV VARS
-t3dBODY *t3dIcons;
-t3dMESH CameraDummy;
-t3dCAMERA t3dIconCamera;
-t3dM3X3F BigIconM;
-
// MOUSE VARS
char ObjectUnderCursor[MAX_STRING_LEN];
t3dV3F mPos;
diff --git a/engines/watchmaker/globvar.h b/engines/watchmaker/globvar.h
index 2b3a88e07cd..3787135120b 100644
--- a/engines/watchmaker/globvar.h
+++ b/engines/watchmaker/globvar.h
@@ -23,73 +23,12 @@
#define WATCHMAKER_GLOBVAR_H
#include "watchmaker/struct.h"
+#include "watchmaker/3d/t3d_mesh.h"
namespace Watchmaker {
#define MAX_PATH 256
-// INIT
-struct Init : public SerializableAsset {
- SerializableArray<SRoom, MAX_ROOMS> Room;
- SerializableArray<SObject, MAX_OBJS> Obj;
- SerializableArray<SInvObject, MAX_ICONS> InvObj;
- SerializableArray<SSound, MAX_SOUNDS> Sound;
- SerializableArray<SMusic, MAX_MUSICS> Music;
- SerializableArray<SAnim, MAX_ANIMS> Anim;
- SerializableArray<SDialog, MAX_DIALOGS> Dialog;
- SerializableArray<SDiary, MAX_DIARIES> Diary;
- SerializableArray<SDlgMenu, MAX_DLG_MENUS> DlgMenu;
- SerializableArray<SDlgItem, MAX_DLG_ITEMS> DlgItem;
-
- // Sentences?
- SerializableArray<SPDALog, MAX_PDALOGS> PDALog;
-
- SerializableDynamicArray<SCreditsName> _creditsNames;
- SerializableDynamicArray<SCreditsRole> _creditsRoles;
-
- void loadFromStream(Common::SeekableReadStream &stream) {
- warning("Init");
- Room.loadFromStream(stream);
- Obj.loadFromStream(stream);
- InvObj.loadFromStream(stream);
- Sound.loadFromStream(stream);
- Music.loadFromStream(stream);
- Anim.loadFromStream(stream);
- Dialog.loadFromStream(stream);
- Diary.loadFromStream(stream);
- DlgMenu.loadFromStream(stream);
- DlgItem.loadFromStream(stream);
-
- PDALog.loadFromStream(stream);
-
- uint16 numNames = stream.readUint16LE();
- uint16 numRoles = stream.readUint16LE();
- _creditsNames = SerializableDynamicArray<SCreditsName>(numNames);
- _creditsRoles = SerializableDynamicArray<SCreditsRole>(numRoles);
- _creditsNames.loadFromStream(stream);
- _creditsRoles.loadFromStream(stream);
-
- treatCredits();
- }
-private:
- void treatCredits() {
-
- for (int i = 0; i < _creditsNames.size(); i++) {
- char *c = _creditsNames[i].name;
- for (int k = 0; k < 32; k++, c++) {
- (*c) ^= 0xA0;
- }
- }
-
- for (int i = 0; i < _creditsRoles.size(); i++) {
- char *c = _creditsRoles[i].role;
- for (int k = 0; k < 48; k++, c++) {
- (*c) ^= 0xC4;
- }
- }
- }
-};
-
// GAME RECT
struct GameRect {
GameRect();
@@ -139,10 +78,12 @@ extern uint32 LoaderFlags;
extern char WmGameDataPak_FilePath[];
// INV VARS
-extern t3dBODY *t3dIcons;
-extern t3dMESH CameraDummy;
-extern t3dCAMERA t3dIconCamera;
-extern t3dM3X3F BigIconM;
+struct InvVars {
+ t3dBODY *t3dIcons;
+ t3dMESH CameraDummy;
+ t3dCAMERA t3dIconCamera;
+ t3dM3X3F BigIconM;
+};
// MOUSE VARS
extern char ObjectUnderCursor[];
@@ -260,6 +201,74 @@ extern uint8 bShowExtraLocalizationStrings;
// DIALOG VARS
extern uint8 UsedDlgMenu[MAX_PLAYERS][T3D_MAX_CHARACTERS][MAX_DLG_MENUS];
+struct Globals {
+ InvVars _invVars;
+};
+
+// INIT
+struct Init : public SerializableAsset {
+ SerializableArray<SRoom, MAX_ROOMS> Room;
+ SerializableArray<SObject, MAX_OBJS> Obj;
+ SerializableArray<SInvObject, MAX_ICONS> InvObj;
+ SerializableArray<SSound, MAX_SOUNDS> Sound;
+ SerializableArray<SMusic, MAX_MUSICS> Music;
+ SerializableArray<SAnim, MAX_ANIMS> Anim;
+ SerializableArray<SDialog, MAX_DIALOGS> Dialog;
+ SerializableArray<SDiary, MAX_DIARIES> Diary;
+ SerializableArray<SDlgMenu, MAX_DLG_MENUS> DlgMenu;
+ SerializableArray<SDlgItem, MAX_DLG_ITEMS> DlgItem;
+
+ // Sentences?
+ SerializableArray<SPDALog, MAX_PDALOGS> PDALog;
+
+ SerializableDynamicArray<SCreditsName> _creditsNames;
+ SerializableDynamicArray<SCreditsRole> _creditsRoles;
+
+ Globals _globals;
+
+ void loadFromStream(Common::SeekableReadStream &stream) {
+ warning("Init");
+ Room.loadFromStream(stream);
+ Obj.loadFromStream(stream);
+ InvObj.loadFromStream(stream);
+ Sound.loadFromStream(stream);
+ Music.loadFromStream(stream);
+ Anim.loadFromStream(stream);
+ Dialog.loadFromStream(stream);
+ Diary.loadFromStream(stream);
+ DlgMenu.loadFromStream(stream);
+ DlgItem.loadFromStream(stream);
+
+ PDALog.loadFromStream(stream);
+
+ uint16 numNames = stream.readUint16LE();
+ uint16 numRoles = stream.readUint16LE();
+ _creditsNames = SerializableDynamicArray<SCreditsName>(numNames);
+ _creditsRoles = SerializableDynamicArray<SCreditsRole>(numRoles);
+ _creditsNames.loadFromStream(stream);
+ _creditsRoles.loadFromStream(stream);
+
+ treatCredits();
+ }
+private:
+ void treatCredits() {
+
+ for (int i = 0; i < _creditsNames.size(); i++) {
+ char *c = _creditsNames[i].name;
+ for (int k = 0; k < 32; k++, c++) {
+ (*c) ^= 0xA0;
+ }
+ }
+
+ for (int i = 0; i < _creditsRoles.size(); i++) {
+ char *c = _creditsRoles[i].role;
+ for (int k = 0; k < 48; k++, c++) {
+ (*c) ^= 0xC4;
+ }
+ }
+ }
+};
+
} // End of namespace Watchmaker
#endif // WATCHMAKER_GLOBVAR_H
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index b0b4ab4937e..b991a1d9f57 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -1512,7 +1512,7 @@ void StartAnim(WGame &game, int32 an) {
h->sub[a].ptr->CurFrame = 0;
// Se e' un'animazione di una camera
- if (h->sub[a].ptr == &CameraDummy) StartAnimCamera(game);
+ if (h->sub[a].ptr == &game.init._globals._invVars.CameraDummy) StartAnimCamera(game);
}
if (AnimAutoPush) {
PushATF(AnimAutoPush);
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 56a7ebde93d..36388966ae4 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -275,7 +275,7 @@ t3dMESH *LinkMeshToStr(Init &init, const Common::String &str) {
// Cerca tra le camere
if (str.equalsIgnoreCase("camera"))
- return &CameraDummy;
+ return &init._globals._invVars.CameraDummy;
// Cerca tra i personaggi
for (uint16 i = 0; i < T3D_MAX_CHARACTERS; i++)
if ((Character[i]) && (str.equalsIgnoreCase((char *)init.Obj[i].meshlink[0])))
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index 87784f8a195..1c86e4ad7f2 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -166,7 +166,7 @@ void Render3DEnvironment(WGame &game) {
} else if (((InvStatus & INV_MODE2) && (InvStatus & INV_ON)) /*|| ( bT2DActive == tOPTIONS )*/) { // Se sono nell'inventario
t3dCAMERA *tmp = t3dCurCamera; // Salvo camera attuale in tmp
t3dMatIdentity(&t3dCurViewMatrix);
- t3dCurCamera = &t3dIconCamera; // Attivo camera per icone
+ t3dCurCamera = &game.init._globals._invVars.t3dIconCamera; // Attivo camera per icone
t3dCurCamera->Fov = CAMERA_FOV_ICON;
game._renderer->setCurCameraViewport(t3dCurCamera->Fov, bSuperView);
auto windowInfo = game._renderer->getScreenInfos();
@@ -175,17 +175,17 @@ void Render3DEnvironment(WGame &game) {
t3dVectInit(&t3dCurCamera->Target, 1000.0f, 0.0f, 0.0f);
t3dMatView(&t3dCurViewMatrix, &t3dCurCamera->Source, &t3dCurCamera->Target); // Creo matrice
- for (i = 0; i < (int32)t3dIcons->NumMeshes(); i++) {
- t3dIcons->MeshTable[i].Flags |= T3D_MESH_HIDDEN; // Disattivo tutte le icone
- t3dMatCopy(&t3dIcons->MeshTable[i].Matrix, &BigIconM);
+ for (i = 0; i < (int32)game.init._globals._invVars.t3dIcons->NumMeshes(); i++) {
+ game.init._globals._invVars.t3dIcons->MeshTable[i].Flags |= T3D_MESH_HIDDEN; // Disattivo tutte le icone
+ t3dMatCopy(&game.init._globals._invVars.t3dIcons->MeshTable[i].Matrix, &game.init._globals._invVars.BigIconM);
if (BigInvObj) {
- if (t3dIcons->MeshTable[i].name.equalsIgnoreCase((char *)game.init.InvObj[BigInvObj].meshlink.rawArray()))
- t3dIcons->MeshTable[i].Flags &= ~T3D_MESH_HIDDEN; // Fuorche' quella selezinata
+ if (game.init._globals._invVars.t3dIcons->MeshTable[i].name.equalsIgnoreCase((char *)game.init.InvObj[BigInvObj].meshlink.rawArray()))
+ game.init._globals._invVars.t3dIcons->MeshTable[i].Flags &= ~T3D_MESH_HIDDEN; // Fuorche' quella selezinata
}
}
- if (!t3dTransformBody(t3dIcons))
+ if (!t3dTransformBody(game.init._globals._invVars.t3dIcons))
DebugLogWindow("Can't transform Icons");
t3dCurCamera = tmp; // Rirpristino camera precedente
t3dSortMeshes(); // Ordina le mesh
Commit: 70b0a453445124e24d1211ab0996ad322adfa0a3
https://github.com/scummvm/scummvm/commit/70b0a453445124e24d1211ab0996ad322adfa0a3
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WACTHMAKER: Fix mistake in t3dFinalizeMaterialList
Changed paths:
engines/watchmaker/3d/loader.cpp
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index e29fd733f26..9896941d580 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -526,7 +526,7 @@ void t3dFinalizeMaterialList(t3dBODY *b) {
if (Face.lightmap) {
Mat = nullptr;
for (auto material : Face.getMaterial()->AddictionalMaterial) {
- if (Mat->Texture->ID == Face.lightmap->Texture->ID) {
+ if (material->Texture->ID == Face.lightmap->Texture->ID) {
Mat = material;
break;
}
Commit: 6caa7b59aa07f5a89028816bdbf4ebc653149915
https://github.com/scummvm/scummvm/commit/6caa7b59aa07f5a89028816bdbf4ebc653149915
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Remove most system includes from engine
Only leaving the malloc.h include, as that needs some further code changes.
Changed paths:
engines/watchmaker/classes/do_sound.cpp
engines/watchmaker/game.cpp
engines/watchmaker/init/nl_init.cpp
engines/watchmaker/init/nl_parse.cpp
engines/watchmaker/ll/ll_mesh.cpp
engines/watchmaker/ll/ll_regen.cpp
engines/watchmaker/ll/ll_system.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/main.cpp
engines/watchmaker/saveload.cpp
engines/watchmaker/t2d/expr.cpp
engines/watchmaker/t2d/t2d.cpp
engines/watchmaker/walk/act.cpp
engines/watchmaker/walk/ball.cpp
engines/watchmaker/walk/walk.cpp
engines/watchmaker/walk/walkutil.cpp
diff --git a/engines/watchmaker/classes/do_sound.cpp b/engines/watchmaker/classes/do_sound.cpp
index 9b8d2e8c693..664516edebb 100644
--- a/engines/watchmaker/classes/do_sound.cpp
+++ b/engines/watchmaker/classes/do_sound.cpp
@@ -21,7 +21,6 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_sprintf
-#include <cmath>
#include "watchmaker/classes/do_sound.h"
#include "watchmaker/utils.h"
#include "watchmaker/types.h"
diff --git a/engines/watchmaker/game.cpp b/engines/watchmaker/game.cpp
index 81317ba3abe..b1644daa14e 100644
--- a/engines/watchmaker/game.cpp
+++ b/engines/watchmaker/game.cpp
@@ -22,7 +22,6 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
#define FORBIDDEN_SYMBOL_EXCEPTION_sprintf
-#include <unistd.h>
#include "watchmaker/game.h"
#include "watchmaker/windows_hacks.h"
#include "watchmaker/classes/do_system.h"
diff --git a/engines/watchmaker/init/nl_init.cpp b/engines/watchmaker/init/nl_init.cpp
index 126f2289d18..ebbd7b838de 100644
--- a/engines/watchmaker/init/nl_init.cpp
+++ b/engines/watchmaker/init/nl_init.cpp
@@ -19,9 +19,6 @@
*
*/
-#include <cstring>
-#include <cstdio>
-
#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
#include "watchmaker/init/nl_parse.h"
diff --git a/engines/watchmaker/init/nl_parse.cpp b/engines/watchmaker/init/nl_parse.cpp
index 0f5e76d9cab..1cb0931049c 100644
--- a/engines/watchmaker/init/nl_parse.cpp
+++ b/engines/watchmaker/init/nl_parse.cpp
@@ -24,7 +24,6 @@
#include "watchmaker/init/nl_parse.h"
#include "common/stream.h"
#include "common/textconsole.h"
-#include <cstdarg>
namespace Watchmaker {
diff --git a/engines/watchmaker/ll/ll_mesh.cpp b/engines/watchmaker/ll/ll_mesh.cpp
index 8f3f5f84a8a..7f751c48296 100644
--- a/engines/watchmaker/ll/ll_mesh.cpp
+++ b/engines/watchmaker/ll/ll_mesh.cpp
@@ -19,7 +19,6 @@
*
*/
-#include <cmath>
#include "watchmaker/ll/ll_mesh.h"
#include "watchmaker/types.h"
#include "watchmaker/t3d.h"
diff --git a/engines/watchmaker/ll/ll_regen.cpp b/engines/watchmaker/ll/ll_regen.cpp
index 8cc14771914..85b6370dc38 100644
--- a/engines/watchmaker/ll/ll_regen.cpp
+++ b/engines/watchmaker/ll/ll_regen.cpp
@@ -19,7 +19,6 @@
*
*/
-#include <cstring>
#include "watchmaker/ll/ll_regen.h"
#include "watchmaker/render.h"
#include "watchmaker/struct.h"
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index 5e60eaa61a5..7f8b1d53a8c 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -36,7 +36,6 @@
#include "watchmaker/types.h"
#include "watchmaker/utils.h"
#include "watchmaker/windows_hacks.h"
-#include <cstdlib>
namespace Watchmaker {
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 36388966ae4..0b4165e7868 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -23,8 +23,6 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_sprintf
#define FORBIDDEN_SYMBOL_EXCEPTION_vsprintf
-#include <cstring>
-#include <stdarg.h>
#include "watchmaker/ll/ll_util.h"
#include "watchmaker/ll/ll_anim.h"
#include "watchmaker/ll/ll_diary.h"
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index 1c86e4ad7f2..f09baa7270b 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -1,6 +1,4 @@
-#include <cstdlib>
-#include <unistd.h>
#include "common/stream.h"
#include "watchmaker/3d/animation.h"
#include "watchmaker/3d/math/llmath.h"
diff --git a/engines/watchmaker/saveload.cpp b/engines/watchmaker/saveload.cpp
index bef03a76383..a6faf56bf7c 100644
--- a/engines/watchmaker/saveload.cpp
+++ b/engines/watchmaker/saveload.cpp
@@ -39,7 +39,6 @@
#include "watchmaker/walk/act.h"
#include "watchmaker/ll/ll_system.h"
#include "watchmaker/windows_hacks.h"
-#include <cstdlib>
#define WM_SAVEFILE_VERSION 0x17 // Don't know what changed though.
diff --git a/engines/watchmaker/t2d/expr.cpp b/engines/watchmaker/t2d/expr.cpp
index d0078ca1c23..b017f5cf966 100644
--- a/engines/watchmaker/t2d/expr.cpp
+++ b/engines/watchmaker/t2d/expr.cpp
@@ -21,9 +21,6 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
-#include <cstring>
-#include <cstdlib>
-#include <ctime>
#include "watchmaker/t2d/expr.h"
#include "watchmaker/windows_hacks.h"
#include "watchmaker/globvar.h"
diff --git a/engines/watchmaker/t2d/t2d.cpp b/engines/watchmaker/t2d/t2d.cpp
index 1f770101dfd..3f8127e0e3f 100644
--- a/engines/watchmaker/t2d/t2d.cpp
+++ b/engines/watchmaker/t2d/t2d.cpp
@@ -23,7 +23,6 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
#define FORBIDDEN_SYMBOL_EXCEPTION_sprintf
-#include <stdarg.h>
#include "watchmaker/t2d/t2d.h"
#include "watchmaker/globvar.h"
#include "watchmaker/message.h"
diff --git a/engines/watchmaker/walk/act.cpp b/engines/watchmaker/walk/act.cpp
index 8a392b6a195..d0c389fdd97 100644
--- a/engines/watchmaker/walk/act.cpp
+++ b/engines/watchmaker/walk/act.cpp
@@ -19,7 +19,6 @@
*
*/
-#include <cmath>
#include "watchmaker/walk/act.h"
#include "watchmaker/t3d.h"
#include "watchmaker/globvar.h"
diff --git a/engines/watchmaker/walk/ball.cpp b/engines/watchmaker/walk/ball.cpp
index 2957fe69390..6aaf6f6f2e9 100644
--- a/engines/watchmaker/walk/ball.cpp
+++ b/engines/watchmaker/walk/ball.cpp
@@ -19,7 +19,6 @@
*
*/
-#include <cmath>
#include "watchmaker/walk/ball.h"
#include "watchmaker/globvar.h"
#include "watchmaker/define.h"
diff --git a/engines/watchmaker/walk/walk.cpp b/engines/watchmaker/walk/walk.cpp
index 729a4e516e0..9118722daa5 100644
--- a/engines/watchmaker/walk/walk.cpp
+++ b/engines/watchmaker/walk/walk.cpp
@@ -19,7 +19,6 @@
*
*/
-#include <cmath>
#include "watchmaker/walk/walk.h"
#include "watchmaker/types.h"
#include "watchmaker/t3d.h"
diff --git a/engines/watchmaker/walk/walkutil.cpp b/engines/watchmaker/walk/walkutil.cpp
index 5ab25e62198..c45e6adae55 100644
--- a/engines/watchmaker/walk/walkutil.cpp
+++ b/engines/watchmaker/walk/walkutil.cpp
@@ -19,7 +19,6 @@
*
*/
-#include <cmath>
#include "watchmaker/walk/walkutil.h"
#include "watchmaker/types.h"
#include "watchmaker/t3d.h"
Commit: cf4a76efa07d6d1a4f4cc7b1ee3dc7eaca8bb7b5
https://github.com/scummvm/scummvm/commit/cf4a76efa07d6d1a4f4cc7b1ee3dc7eaca8bb7b5
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Pad Mesh name buffer by 1.
Some meshes have no trailing 0, which breaks a lot of C-String handling.
Changed paths:
engines/watchmaker/3d/t3d_mesh.cpp
diff --git a/engines/watchmaker/3d/t3d_mesh.cpp b/engines/watchmaker/3d/t3d_mesh.cpp
index 9542f09b721..30070a7b0cb 100644
--- a/engines/watchmaker/3d/t3d_mesh.cpp
+++ b/engines/watchmaker/3d/t3d_mesh.cpp
@@ -43,7 +43,7 @@ t3dMESH::t3dMESH(t3dBODY *b, Common::SeekableReadStream &stream, t3dMESH *&Recei
this->DefaultAnim.NumBones = this->DefaultAnim.NumFrames = 0;
this->Anim.NumBones = this->Anim.NumFrames = 0;
- char stringBuffer[T3D_NAMELEN] = {};
+ char stringBuffer[T3D_NAMELEN + 1] = {};
stream.read(stringBuffer, T3D_NAMELEN); // Legge nome mesh
this->name = stringBuffer;
stream.read(stringBuffer, T3D_NAMELEN); // Legge nome portale
Commit: 468f592d7debe4c2e6ca7cca37e36ed8a5cfc250
https://github.com/scummvm/scummvm/commit/468f592d7debe4c2e6ca7cca37e36ed8a5cfc250
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Populate Portal Lists
Changed paths:
engines/watchmaker/3d/t3d_body.cpp
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index d4420da9707..b97bc163a2a 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -545,6 +545,8 @@ t3dBODY *t3dBODY::loadFromStream(WGame &game, const Common::String &pname, Commo
#endif
//----------------END OF VERTEX PRE-LIGHTING---------------------
+ populatePortalLists();
+
warning("LoaderFlags late = %08X", LoaderFlags);
//decodeLoaderFlags(LoaderFlags);
if (!(LoaderFlags & T3D_NOBOUNDS)) { // Carica Bounds
Commit: 2b3ef5e36067f8ec2718278251fd3a380746f105
https://github.com/scummvm/scummvm/commit/2b3ef5e36067f8ec2718278251fd3a380746f105
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Resize the KeyTable to fit any KeyCode
Changed paths:
engines/watchmaker/classes/do_keyboard.cpp
engines/watchmaker/classes/do_keyboard.h
diff --git a/engines/watchmaker/classes/do_keyboard.cpp b/engines/watchmaker/classes/do_keyboard.cpp
index 18e3a2fd1b9..b5de513d267 100644
--- a/engines/watchmaker/classes/do_keyboard.cpp
+++ b/engines/watchmaker/classes/do_keyboard.cpp
@@ -51,7 +51,7 @@ char bFastAnim = 0;
int32 PlayAnim = 351;
char bBilinear = 1;
char bForceDebug = 0;
-unsigned char KeyTable[256];
+unsigned char KeyTable[Common::KEYCODE_LAST];
uint16 bnd_lev;
diff --git a/engines/watchmaker/classes/do_keyboard.h b/engines/watchmaker/classes/do_keyboard.h
index 3c51b45b744..1dcd86ec5a9 100644
--- a/engines/watchmaker/classes/do_keyboard.h
+++ b/engines/watchmaker/classes/do_keyboard.h
@@ -29,7 +29,7 @@ namespace Watchmaker {
void doClock33(WGame &game, int obj, struct t3dV3F *mp);
void ProcessKeyboard(WGame &game);
void ProcessKBInput();
-extern unsigned char KeyTable[256];
+extern unsigned char KeyTable[];
} // End of namespace Watchmaker
Commit: 6ece7cfbc41d582012bc989afff984ba5259b0bb
https://github.com/scummvm/scummvm/commit/6ece7cfbc41d582012bc989afff984ba5259b0bb
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Optimize t3dGetFileDate slightly
By avoiding opening the files just to check their existence.
Changed paths:
engines/watchmaker/ll/ll_system.cpp
engines/watchmaker/ll/ll_system.h
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index 7f8b1d53a8c..32b8fbe3221 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -162,20 +162,38 @@ int t3dAccessFile(char *name) {
}
bool t3dGetFileDate(uint32 *date, uint32 *time, const char *name) {
- auto stream = openFile(name);
- warning("TODO: t3dGetFileDate is currently super-inefficient");
- if (stream)
- return true;
- return false;
+ warning("TODO: t3dGetFileDate is currently super-inefficient: %s", name);
+ return checkFileExists(name);
}
-Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename, int offset, int size) {
+Common::String adjustPath(const Common::String &path) {
Common::String adjustedPath;
- if (filename.hasPrefix("./")) {
- adjustedPath = filename.substr(2, filename.size());
+ if (path.hasPrefix("./")) {
+ adjustedPath = path.substr(2, path.size());
} else {
- adjustedPath = filename;
+ adjustedPath = path;
+ }
+ return adjustedPath;
+}
+
+bool checkFileExists(const Common::String &filename) {
+ Common::String adjustedPath = adjustPath(filename);
+
+ Common::ArchiveMemberList files;
+ SearchMan.listMatchingMembers(files, adjustedPath);
+
+ for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) {
+ if ((*it)->getName().equalsIgnoreCase(lastPathComponent(adjustedPath, '/'))) {
+ return true;
+ }
}
+
+ return false;
+}
+
+Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename, int offset, int size) {
+ Common::String adjustedPath = adjustPath(filename);
+
Common::SeekableReadStream *file = nullptr;
// Try directly from SearchMan first
Common::ArchiveMemberList files;
diff --git a/engines/watchmaker/ll/ll_system.h b/engines/watchmaker/ll/ll_system.h
index 01ee7577dfc..3423c917284 100644
--- a/engines/watchmaker/ll/ll_system.h
+++ b/engines/watchmaker/ll/ll_system.h
@@ -58,6 +58,7 @@ bool t3dFastFileInit(const char *name);
void t3dForceNOFastFile(char valore);
int t3dAccessFile(char *name);
bool t3dGetFileDate(uint32 *date, uint32 *time, const char *name);
+bool checkFileExists(const Common::String &filename);
Common::SeekableReadStream *resolveFile(const char *path);
Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename, int offset = 0, int size = -1);
Commit: d9baf157ac1936dfef7a626ad0073e0743222f39
https://github.com/scummvm/scummvm/commit/d9baf157ac1936dfef7a626ad0073e0743222f39
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Guard against -1 in doDialog.
This should probably be an assertion, as something is likely wrong
here, but for now we'll just drop the call.
Changed paths:
engines/watchmaker/classes/do_dialog.cpp
diff --git a/engines/watchmaker/classes/do_dialog.cpp b/engines/watchmaker/classes/do_dialog.cpp
index f3b98d92f4b..eeac2321023 100644
--- a/engines/watchmaker/classes/do_dialog.cpp
+++ b/engines/watchmaker/classes/do_dialog.cpp
@@ -439,7 +439,7 @@ void UpdateDialogMenu(WGame &game, int16 dmx, int16 dmy, uint8 db) {
if ((db == ME_MLEFT) && (CurDlgItem) && (init.DlgMenu[CurDlgItem].parent == mMAIN)) {
CurMenu = CurDlgItem;
Diag2Base = 0;
- } else if ((db == ME_MLEFT) && (CurDlgItem)) {
+ } else if ((db == ME_MLEFT) && (CurDlgItem) && (CurDlgItem != -1)) { // TODO: The original didn't have a check for -1 here
Event(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, (int16)CurDlgItem, 0, nullptr, nullptr, nullptr);
UsedDlgMenu[CurPlayer][CurObj][CurDlgItem] = 1;
} else if ((db == ME_MRIGHT) && (CurMenu == mMAIN))
Commit: 634c448cb4f401873d03c0612c32e1613298fd01
https://github.com/scummvm/scummvm/commit/634c448cb4f401873d03c0612c32e1613298fd01
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Drop unused arg to t3dLoadCharacter
Changed paths:
engines/watchmaker/3d/animation.cpp
engines/watchmaker/3d/animation.h
engines/watchmaker/game.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index da05c54fc10..1abb0588fd7 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -568,15 +568,14 @@ t3dBODY *LoadShadowMeshes(WGame &game, const char *pname, t3dBODY *Body) {
/* -----------------30/12/98 11.27-------------------
* t3dLoadCharacter
* --------------------------------------------------*/
-t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, t3dCHARACTER *b, uint16 num) {
+t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, uint16 num) {
warning("LoadCharacter(%s)", pname);
uint8 Mirror = 1;
uint16 n = 0, f, i;
t3dV3F tmp;
// gVertex *v;
- b = new t3dCHARACTER[1] {};
- b->Body = nullptr;
+ t3dCHARACTER *b = new t3dCHARACTER[1] {};
b->Body = t3dLoadRoom(game, pname, b->Body, &n, (T3D_NOLIGHTMAPS | T3D_NORECURSION | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_STATIC_SET0 | T3D_STATIC_SET1));
if (!b->Body) return nullptr;
b->Mesh = &b->Body->MeshTable[0];
diff --git a/engines/watchmaker/3d/animation.h b/engines/watchmaker/3d/animation.h
index 4ee1af4973b..e1eb248ed52 100644
--- a/engines/watchmaker/3d/animation.h
+++ b/engines/watchmaker/3d/animation.h
@@ -35,7 +35,7 @@ uint8 GetFullLightDirection(t3dV3F *dest, uint8 pos);
void FixupAnim(t3dMESH *mesh, unsigned char pos, const char *room);
t3dBODY *LoadShadowMeshes(WGame &game, const char *pname, t3dBODY *Body);
int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag);
-t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, t3dCHARACTER *b, uint16 num);
+t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, uint16 num);
void ReleasePreloadedAnims();
uint8 CompareLightPosition(char *roomname, uint8 pos1, t3dV3F *pos2, t3dF32 acceptable_dist);
diff --git a/engines/watchmaker/game.cpp b/engines/watchmaker/game.cpp
index b1644daa14e..d0ceb9836e4 100644
--- a/engines/watchmaker/game.cpp
+++ b/engines/watchmaker/game.cpp
@@ -172,7 +172,7 @@ bool WGame::CheckAndLoadMoglieSupervisoreModel(int32 c) {
LoaderFlags |= T3D_STATIC_SET1;
LoaderFlags |= T3D_STATIC_SET0;
rSetLoaderFlags(LoaderFlags);
- if (!(Character[c] = t3dLoadCharacter(*this, CharName[c], Character[c], (uint16)c))) {
+ if (!(Character[c] = t3dLoadCharacter(*this, CharName[c], (uint16)c))) {
warning("Error loading %s", CharName[c]);
return false;
}
@@ -311,8 +311,8 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
warning("Error loading Icons");
return false;
}
- if (!(Lanc33[0] = t3dLoadCharacter(*this, "Lanc33a.t3d", Lanc33[0], 99)) || !(Lanc33[1] = t3dLoadCharacter(*this, "Lanc33b.t3d", Lanc33[1], 99)) ||
- !(Lanc33[2] = t3dLoadCharacter(*this, "Lanc33c.t3d", Lanc33[2], 99)) || !(Lanc33[3] = t3dLoadCharacter(*this, "Lanc33d.t3d", Lanc33[3], 99))) {
+ if (!(Lanc33[0] = t3dLoadCharacter(*this, "Lanc33a.t3d", 99)) || !(Lanc33[1] = t3dLoadCharacter(*this, "Lanc33b.t3d", 99)) ||
+ !(Lanc33[2] = t3dLoadCharacter(*this, "Lanc33c.t3d", 99)) || !(Lanc33[3] = t3dLoadCharacter(*this, "Lanc33d.t3d", 99))) {
warning("Error loading Lanc33");
return false;
}
@@ -341,7 +341,7 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
}
}
warning("About to load %s", CharName[i + 1]);
- if (!(Character[i + 1] = t3dLoadCharacter(*this, CharName[i + 1], Character[i + 1], i))) {
+ if (!(Character[i + 1] = t3dLoadCharacter(*this, CharName[i + 1], i))) {
warning("Error loading %s", CharName[i + 1]);
return false;
}
@@ -387,39 +387,39 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
if (bGolfActive) {
// extern t3dS32 SkySurface;
- if (!(Character[1] = t3dLoadCharacter(*this, "Gopher1.t3d", Character[1], 99))) {
+ if (!(Character[1] = t3dLoadCharacter(*this, "Gopher1.t3d", 99))) {
warning("Error loading Gopher1");
return false;
}
- if (!(Character[2] = t3dLoadCharacter(*this, "Gopher2.t3d", Character[2], 99))) {
+ if (!(Character[2] = t3dLoadCharacter(*this, "Gopher2.t3d", 99))) {
warning("Error loading Gopher2");
return false;
}
- if (!(Character[3] = t3dLoadCharacter(*this, "Gopher3.t3d", Character[3], 99))) {
+ if (!(Character[3] = t3dLoadCharacter(*this, "Gopher3.t3d", 99))) {
warning("Error loading Gopher3");
return false;
}
- if (!(GopherMark[0] = t3dLoadCharacter(*this, "Mark1.t3d", GopherMark[0], 99))) {
+ if (!(GopherMark[0] = t3dLoadCharacter(*this, "Mark1.t3d", 99))) {
warning("Error loading Mark1");
return false;
}
- if (!(GopherMark[1] = t3dLoadCharacter(*this, "Mark2.t3d", GopherMark[1], 99))) {
+ if (!(GopherMark[1] = t3dLoadCharacter(*this, "Mark2.t3d", 99))) {
warning("Error loading Mark2");
return false;
}
- if (!(GopherMark[2] = t3dLoadCharacter(*this, "Mark3.t3d", GopherMark[2], 99))) {
+ if (!(GopherMark[2] = t3dLoadCharacter(*this, "Mark3.t3d", 99))) {
warning("Error loading Mark3");
return false;
}
- if (!(Palla50 = t3dLoadCharacter(*this, "Palla.t3d", Palla50, 99))) {
+ if (!(Palla50 = t3dLoadCharacter(*this, "Palla.t3d", 99))) {
warning("Error loading Palla50");
return false;
}
- if (!(Freccia50 = t3dLoadCharacter(*this, "Freccia.t3d", Freccia50, 99))) {
+ if (!(Freccia50 = t3dLoadCharacter(*this, "Freccia.t3d", 99))) {
warning("Error loading Freccia50");
return false;
}
- if (!(Explode50 = t3dLoadCharacter(*this, "Explode.t3d", Explode50, 99))) {
+ if (!(Explode50 = t3dLoadCharacter(*this, "Explode.t3d", 99))) {
warning("Error loading Explode50");
return false;
}
Commit: b3ffa5de099efae8756640f1a9566984f846ba5f
https://github.com/scummvm/scummvm/commit/b3ffa5de099efae8756640f1a9566984f846ba5f
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Use Common::String in t3dLoadAnimation
Changed paths:
engines/watchmaker/3d/animation.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index 1abb0588fd7..29f2e3f0567 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -24,18 +24,17 @@
#include "watchmaker/3d/animation.h"
#include "watchmaker/3d/geometry.h"
-#include "watchmaker/t3d.h"
-#include "watchmaker/types.h"
+#include "watchmaker/3d/loader.h"
+#include "watchmaker/3d/math/llmath.h"
#include "watchmaker/3d/t3d_body.h"
#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/file_utils.h"
+#include "watchmaker/game.h"
+#include "watchmaker/ll/ll_system.h"
#include "watchmaker/t3d.h"
#include "watchmaker/types.h"
-#include "watchmaker/3d/loader.h"
-#include "watchmaker/3d/math/llmath.h"
-#include "watchmaker/ll/ll_system.h"
#include "watchmaker/utils.h"
#include "watchmaker/windows_hacks.h"
-#include "watchmaker/game.h"
/* -----------------16/12/98 10.32-------------------
* PRELOADEDANIMS
@@ -164,7 +163,6 @@ int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag) {
t3dBONE *b;
t3dV3F t;
t3dF32 c;
- char name[100];
// Prova a vedere se l'ho gia' precaricata
for (CurPreloadedAnim = 0; CurPreloadedAnim < MAX_PRELOADED_ANIMS; CurPreloadedAnim++)
@@ -200,34 +198,28 @@ int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag) {
p->name = s;
// Carica la nuova animazione
- memset(name, 0, sizeof(name));
- strcpy(&name[0], game.workDirs._a3dDir.c_str());
- strcat(&name[0], &s[0]);
- len = strlen(name);
- name[len - 3] = 'a';
- name[len - 2] = '3';
- name[len - 1] = 'd';
+ Common::String name = game.workDirs._a3dDir + replaceExtension(s, "a3d");
{
- auto stream = game.resolveFile(name);
+ auto stream = game.resolveFile(name.c_str());
if (!stream) {
- warning("File %s not found", name);
+ warning("File %s not found", name.c_str());
return -1;
}
if ((i = stream->readByte()) != A3DFILEVERSION) {
- warning("%s file incompatible: current version: %d.\tFile version: %d", name, A3DFILEVERSION, i);
+ warning("%s file incompatible: current version: %d.\tFile version: %d", name.c_str(), A3DFILEVERSION, i);
return -1;
}
nb = stream->readSint16LE();
nf = stream->readSint16LE();
if (nf == 0) {
- warning("%s has N0 frames!", name);
+ warning("%s has N0 frames!", name.c_str());
return -1;
}
if (nb >= MAX_BONES) {
- warning("%s has too many bones (%d, MAX is %d)!", name, j, MAX_BONES);
+ warning("%s has too many bones (%d, MAX is %d)!", name.c_str(), j, MAX_BONES);
return -1;
}
p->NumBones = nb;
Commit: cdc48ff2c8770433a92dac736d2dc05dcabe93ea
https://github.com/scummvm/scummvm/commit/cdc48ff2c8770433a92dac736d2dc05dcabe93ea
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Use t3dV3F's constructor instead of explicit assignment.
Changed paths:
engines/watchmaker/3d/animation.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index 29f2e3f0567..62912a23518 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -236,15 +236,11 @@ int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag) {
bone->Trasl = t3dCalloc<t3dV3F>(nf);
for (k = 0; k < nf; k++) {
- bone->Euler[k].x = stream->readFloatLE();
- bone->Euler[k].y = stream->readFloatLE();
- bone->Euler[k].z = stream->readFloatLE();
+ bone->Euler[k] = t3dV3F(*stream);
}
for (k = 0; k < nf; k++) {
- bone->Trasl[k].x = stream->readFloatLE();
- bone->Trasl[k].y = stream->readFloatLE();
- bone->Trasl[k].z = stream->readFloatLE();
+ bone->Trasl[k] = t3dV3F(*stream);
}
}
if (stream->readByte()) {
Commit: 7d0fe48aedc6ec473a65527e460be71897be36a4
https://github.com/scummvm/scummvm/commit/7d0fe48aedc6ec473a65527e460be71897be36a4
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Move scheduler global variables into a class.
To reduce the number of global constructors in play.
Changed paths:
engines/watchmaker/classes/do_camera.cpp
engines/watchmaker/classes/do_dialog.cpp
engines/watchmaker/classes/do_inv.cpp
engines/watchmaker/classes/do_mouse.cpp
engines/watchmaker/classes/do_operate.cpp
engines/watchmaker/classes/do_player.cpp
engines/watchmaker/classes/do_system.cpp
engines/watchmaker/game.cpp
engines/watchmaker/game.h
engines/watchmaker/globvar.cpp
engines/watchmaker/globvar.h
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/ll/ll_mouse.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/ll/ll_util.h
engines/watchmaker/main.cpp
engines/watchmaker/saveload.cpp
engines/watchmaker/schedule.cpp
engines/watchmaker/schedule.h
engines/watchmaker/walk/act.cpp
diff --git a/engines/watchmaker/classes/do_camera.cpp b/engines/watchmaker/classes/do_camera.cpp
index ff02d5334a0..4e1a6775213 100644
--- a/engines/watchmaker/classes/do_camera.cpp
+++ b/engines/watchmaker/classes/do_camera.cpp
@@ -344,7 +344,7 @@ void doCamera(WGame &game) {
bFirstPerson = true;
CharStop(ocCURPLAYER);
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_ALL);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
ClearText();
LastCamera = t3dCurCamera;
@@ -392,7 +392,7 @@ void doCamera(WGame &game) {
// Avanza al primo frame del percorso
NextCameraStep(game);
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_PLAYERIDLE);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_PLAYERIDLE);
// Sistema posizione del mouse e posizione della testa
{
diff --git a/engines/watchmaker/classes/do_dialog.cpp b/engines/watchmaker/classes/do_dialog.cpp
index eeac2321023..b4c09b40f20 100644
--- a/engines/watchmaker/classes/do_dialog.cpp
+++ b/engines/watchmaker/classes/do_dialog.cpp
@@ -81,7 +81,7 @@ void doDialog(WGame &game) {
if ((TheMessage->wparam1 == dR000) && bShowRoomDescriptions) {
t3dCurTime = 240;
strcpy(RoomInfo.name, "");
- UpdateRoomInfo(init);
+ UpdateRoomInfo(game);
}
// I make darrell disappear
@@ -311,7 +311,7 @@ void doDialog(WGame &game) {
CurDialog = TheMessage->wparam1;
CurDlgItem = TheMessage->wparam2;
- RemoveEvent(&Game, EventClass::MC_DIALOG, ME_ALL);
+ game._messageSystem.removeEvent(EventClass::MC_DIALOG, ME_ALL);
// Se c'e' un enddialog attivo
if ((CurDlgItem == mQUIT) && (init.Dialog[CurDialog].flags & (DIALOG_END1 | DIALOG_END2 | DIALOG_END3))) {
if (init.Dialog[CurDialog].flags & DIALOG_END_RAND)
diff --git a/engines/watchmaker/classes/do_inv.cpp b/engines/watchmaker/classes/do_inv.cpp
index e272c3edc33..b6097750e30 100644
--- a/engines/watchmaker/classes/do_inv.cpp
+++ b/engines/watchmaker/classes/do_inv.cpp
@@ -310,7 +310,7 @@ void doInventory(WGame &game) {
PlayerPos[CurPlayer + ocDARRELL] = 0;
PlayerGotoPos[CurPlayer + ocDARRELL] = 0;
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_ALL);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
CharStop(ocCURPLAYER);
if (TheMessage->event == ME_INVOFF)
diff --git a/engines/watchmaker/classes/do_mouse.cpp b/engines/watchmaker/classes/do_mouse.cpp
index fef9af062fd..7cb900ba352 100644
--- a/engines/watchmaker/classes/do_mouse.cpp
+++ b/engines/watchmaker/classes/do_mouse.cpp
@@ -243,7 +243,7 @@ void doMouseButton(WGame &game) {
//? CharStop( ocCURPLAYER );
}
// Rimuove tutti gli eventi del personaggio
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_ALL);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
if (CurObj) { // se ho cliccato su un oggetto valido
if (TheMessage->event == ME_MLEFT) // se ho cliccato con sinistro
Event(EventClass::MC_PLAYER, ME_PLAYERGOTOEXAMINE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, bFirstPerson, &CurObj, nullptr, nullptr);
diff --git a/engines/watchmaker/classes/do_operate.cpp b/engines/watchmaker/classes/do_operate.cpp
index e1734b7b0e2..bf94454d8db 100644
--- a/engines/watchmaker/classes/do_operate.cpp
+++ b/engines/watchmaker/classes/do_operate.cpp
@@ -986,7 +986,7 @@ void doOperate(WGame &game, int32 obj) {
StartSound(game, wB451);
SetBndLevel(game, nullptr, 0);
SetBndLevel(game, "r47.t3d", 1);
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_PLAYERTIMER);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_PLAYERTIMER);
if (init.Dialog[dR471].flags & DIALOG_DONE)
Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR451, 0, 0, nullptr, nullptr, nullptr);
diff --git a/engines/watchmaker/classes/do_player.cpp b/engines/watchmaker/classes/do_player.cpp
index 6a3544a360d..83d2e277fc9 100644
--- a/engines/watchmaker/classes/do_player.cpp
+++ b/engines/watchmaker/classes/do_player.cpp
@@ -339,7 +339,7 @@ void UpdatePlayerStand(WGame &game, uint8 oc) {
}
// Ferma il primo personaggio e salva le posizioni
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_ALL);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
// Salva informazioni
{
// DebugLogFile("NO");
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index c57a7a32c4c..2c6c87f6395 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -526,7 +526,7 @@ void ProcessTime(WGame &game) {
// QueryPerformanceFrequency(&pf);QueryPerformanceCounter(&pt);
// DebugFile("%d %d %d",pf.LowPart,pt.LowPart,TheTime);
- if ((TheTime >= NextRefresh) && ((Game.len < 1) || (NumTimes > 7))) {
+ if ((TheTime >= NextRefresh) && ((game._messageSystem.Game.len < 1) || (NumTimes > 7))) {
if (!bGolfActive) {
ProcessKeyboard(game);
ProcessMouse(game);
@@ -673,7 +673,7 @@ void InitMain(WGame &game) {
* --------------------------------------------------*/
void NextMessage(WGame &game) {
ProcessTime(game);
- Scheduler();
+ game._messageSystem.scheduler();
if (TheMessage) {
if ((TheMessage->classe == EventClass::MC_SYSTEM) && (TheMessage->event == ME_QUIT))
diff --git a/engines/watchmaker/game.cpp b/engines/watchmaker/game.cpp
index d0ceb9836e4..48c276d81bd 100644
--- a/engines/watchmaker/game.cpp
+++ b/engines/watchmaker/game.cpp
@@ -49,6 +49,8 @@ namespace Watchmaker {
const char *WATCHMAKER_CFG_NAME = "wm.cfg";
+WGame *_vm = nullptr;
+
// TODO: Unglobalize
const char *CharName_Strings[] = {
"",
@@ -188,6 +190,7 @@ bool WGame::CheckAndLoadMoglieSupervisoreModel(int32 c) {
// TODO: This needs some heavy refactoring.
WGame::WGame() : workDirs(WATCHMAKER_CFG_NAME) {
+ _vm = this;
configLoaderFlags(); // TODO: This should probably happen before the constructor
// if LoaderFlags & T3D_DEBUGMODE
@@ -214,6 +217,7 @@ WGame::WGame() : workDirs(WATCHMAKER_CFG_NAME) {
WGame::~WGame() {
delete _renderer;
delete sdl;
+ _vm = nullptr;
}
Common::SharedPtr<Common::SeekableReadStream> WGame::resolveFile(const char *path, bool noFastFile) {
diff --git a/engines/watchmaker/game.h b/engines/watchmaker/game.h
index 4f3414c8aa6..07dbfe9cdc7 100644
--- a/engines/watchmaker/game.h
+++ b/engines/watchmaker/game.h
@@ -23,7 +23,8 @@
#define WATCHMAKER_GAME_H
#include "common/random.h"
-#include "fonts.h"
+#include "watchmaker/fonts.h"
+#include "watchmaker/schedule.h"
#include "watchmaker/3d/loader.h"
#include "watchmaker/game_options.h"
#include "watchmaker/ll/ll_ffile.h"
@@ -64,6 +65,7 @@ public:
GameVars _gameVars;
GameRect _gameRect;
Fonts _fonts;
+ MessageSystem _messageSystem;
WGame();
~WGame();
@@ -99,6 +101,8 @@ public:
void GameLoop();
};
+extern WGame *_vm;
+
} // End of namespace Watchmaker
#endif // WATCHMAKER_GAME_H
diff --git a/engines/watchmaker/globvar.cpp b/engines/watchmaker/globvar.cpp
index 68dbc763722..50775a2dc37 100644
--- a/engines/watchmaker/globvar.cpp
+++ b/engines/watchmaker/globvar.cpp
@@ -76,13 +76,7 @@ char CurDebugString[MAX_STRING_LEN];
char TextLines[MAX_TEXT_LINES][MAX_TEXT_CHARS];
// MESSAGE SYSTEM
-message GameMessage[MAX_MESSAGES];
-pqueue Game;
message *TheMessage;
-message idlemessage = {EventClass::MC_IDLE, 0, MP_DEFAULT};
-message quitgamemessage = {EventClass::MC_SYSTEM, ME_QUIT, MP_DEFAULT};
-message supereventmessage;
-uint8 SuperEventActivate;
// GAME VARS
int32 CurObj;
diff --git a/engines/watchmaker/globvar.h b/engines/watchmaker/globvar.h
index 3787135120b..437889adea2 100644
--- a/engines/watchmaker/globvar.h
+++ b/engines/watchmaker/globvar.h
@@ -115,13 +115,7 @@ extern int32 Comb2D[], Comb2Q[], Comb19[], Comb1D[], Forno25, Frigo25, Comb31[],
extern uint8 bMoglieGym, bMoglieSangue, bNoPlayerSwitch;
// MESSAGE SYSTEM
-extern message GameMessage[];
-extern pqueue Game;
extern message *TheMessage;
-extern message idlemessage;
-extern message quitgamemessage;
-extern message supereventmessage;
-extern uint8 SuperEventActivate;
// GAME VARS
extern int32 CurObj;
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index b991a1d9f57..bc79ce7c5bf 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -451,7 +451,7 @@ void ProcessATFDO(WGame &game, int32 in) {
// Event( EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL ); //preferisco farlo rimanere in terza (ndFox)
break;
case f45STOPTIMER:
- RemoveEvent(&Game, EventClass::MC_SYSTEM, ME_PLAYERTIMER);
+ game._messageSystem.removeEvent(EventClass::MC_SYSTEM, ME_PLAYERTIMER);
break;
case f41STARTTIMER:
@@ -459,7 +459,7 @@ void ProcessATFDO(WGame &game, int32 in) {
Event(EventClass::MC_SYSTEM, ME_PLAYERTIMER, MP_WAIT_RETRACE, (int16)(CurPlayer + ocDARRELL), (int16)dR0010, 0, &i, nullptr, nullptr);
break;
case f41STOPTIMER:
- RemoveEvent(&Game, EventClass::MC_SYSTEM, ME_PLAYERTIMER);
+ game._messageSystem.removeEvent(EventClass::MC_SYSTEM, ME_PLAYERTIMER);
break;
case fDISABLESAVE:
@@ -1478,7 +1478,7 @@ void StartAnim(WGame &game, int32 an) {
// Copia la posizione iniziale della bone0 se e' l'omino
if (h->sub[a].ptr->Flags & T3D_MESH_CHARACTER) {
if (h->sub[a].ptr == Player->Mesh) {
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_ALL);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
CharSetPosition(ocCURPLAYER, cp, nullptr);
Player->Walk.NumPathNodes = Player->Walk.CurrentStep = Player->Walk.NumSteps = 0;
Player->Walk.CurAction = aNULL;
@@ -1821,7 +1821,7 @@ void StopPlayingGame(WGame &game) {
if (Character[i])
CharStop(i);
- InitMessageSystem();
+ game._messageSystem.init();
ClearUseWith();
ClearText();
//
diff --git a/engines/watchmaker/ll/ll_mouse.cpp b/engines/watchmaker/ll/ll_mouse.cpp
index 4ca3c25f3a7..e297dc3afc8 100644
--- a/engines/watchmaker/ll/ll_mouse.cpp
+++ b/engines/watchmaker/ll/ll_mouse.cpp
@@ -89,7 +89,7 @@ void ProcessMouse(WGame &game) {
if (mMoveX || mMoveY) {
mHide = 0;
mCounter = 0;
- RemoveEvent(&Game, EventClass::MC_MOUSE, ME_MOUSEUPDATE);
+ game._messageSystem.removeEvent(EventClass::MC_MOUSE, ME_MOUSEUPDATE);
Event(EventClass::MC_MOUSE, ME_MOUSEUPDATE, MP_DEFAULT, (int16)mPosx, (int16)mPosy, 0, &mMoveX, &mMoveY, NULL);
}
mMoveX = mMoveY = 0;
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 0b4165e7868..a0cb81efc00 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -293,19 +293,19 @@ t3dMESH *LinkMeshToStr(Init &init, const Common::String &str) {
/* -----------------18/12/00 18.02-------------------
* UpdateRoomInfo
* --------------------------------------------------*/
-void UpdateRoomInfo(Init &init) {
+void UpdateRoomInfo(WGame &game) {
uint8 cr;
if (!t3dCurRoom) return;
- cr = (uint8)getRoomFromStr(init, t3dCurRoom->name);
+ cr = (uint8)getRoomFromStr(game.init, t3dCurRoom->name);
if (!cr) return;
// se � diversa dalla precedente...
- if (strcmp(RoomInfo.name, init.Room[cr].desc)) {
- RemoveEvent_bparam(&Game, EventClass::MC_SYSTEM, ME_STARTEFFECT, EFFECT_ROOMINFO);
- RemoveEvent_bparam(&Game, EventClass::MC_SYSTEM, ME_CONTINUEEFFECT, EFFECT_ROOMINFO);
- RemoveEvent_bparam(&Game, EventClass::MC_SYSTEM, ME_STOPEFFECT, EFFECT_ROOMINFO);
+ if (strcmp(RoomInfo.name, game.init.Room[cr].desc)) {
+ game._messageSystem.removeEvent_bparam(EventClass::MC_SYSTEM, ME_STARTEFFECT, EFFECT_ROOMINFO);
+ game._messageSystem.removeEvent_bparam(EventClass::MC_SYSTEM, ME_CONTINUEEFFECT, EFFECT_ROOMINFO);
+ game._messageSystem.removeEvent_bparam(EventClass::MC_SYSTEM, ME_STOPEFFECT, EFFECT_ROOMINFO);
Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_ROOMINFO, nullptr, nullptr, nullptr);
}
}
@@ -334,7 +334,7 @@ void UpdateRoomVisibility(WGame &game) {
init.Room[cr].flags |= ROOM_VISIBLE;
if (bShowRoomDescriptions)
- UpdateRoomInfo(init);
+ UpdateRoomInfo(game);
// if( !( Room[cr].flags & ROOM_OLDVISIBLE ) )
// Event( EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND*3, 0, EFFECT_ROOMINFO, NULL, NULL, NULL );
diff --git a/engines/watchmaker/ll/ll_util.h b/engines/watchmaker/ll/ll_util.h
index ca48385c284..cc1e7469585 100644
--- a/engines/watchmaker/ll/ll_util.h
+++ b/engines/watchmaker/ll/ll_util.h
@@ -41,7 +41,7 @@ int32 GetBndLevel(char *roomname);
void GetDDBitmapExtends(Renderer &renderer, struct SRect *r, struct SDDBitmap *b);
void DisplayDDBitmap(Renderer &, int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
void DisplayDDBitmap_NoFit(Renderer &renderer, int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
-void UpdateRoomInfo(Init &init);
+void UpdateRoomInfo(WGame &game);
bool CheckRect(Renderer &renderer, struct SRect p, int32 cmx, int32 cmy);
void DisplayD3DTriangle(Renderer &, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r, uint8 g, uint8 b, uint8 al);
void DisplayD3DRect(Renderer &, int32 px, int32 py, int32 dx, int32 dy, uint8 r, uint8 g, uint8 b, uint8 al);
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index f09baa7270b..b3a2d4d0433 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -103,7 +103,7 @@ int WMakerMain() {
g_bReady = true;*/
t3dAllocMemoryPool(1000000); // Alloca memory-pool
- InitMessageSystem();
+ game->_messageSystem.init();
if (LoaderFlags & T3D_DEBUGMODE) {
if (!game->StartPlayingGame("")) {
diff --git a/engines/watchmaker/saveload.cpp b/engines/watchmaker/saveload.cpp
index a6faf56bf7c..7cbfeac41d1 100644
--- a/engines/watchmaker/saveload.cpp
+++ b/engines/watchmaker/saveload.cpp
@@ -148,7 +148,7 @@ bool DataSave(const char *SaveName, uint8 slot) {
PlayerPos[CurPlayer + ocDARRELL] = 0;
PlayerGotoPos[CurPlayer + ocDARRELL] = 0;
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_ALL);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
CharStop(ocCURPLAYER);
// nascondo l'altro giocatore, cos� quando riparte il gioco StartDiary() vede che e' nascosto e controlla se deve essere visualizzato
@@ -349,7 +349,7 @@ bool DataLoad(WGame &game, const Common::String &FileName, uint8 slot) {
if (Character[i])
CharStop(i);
- InitMessageSystem();
+ game._messageSystem.init();
ClearUseWith();
ClearText();
diff --git a/engines/watchmaker/schedule.cpp b/engines/watchmaker/schedule.cpp
index d3f3976d4b5..4d7db25dad2 100644
--- a/engines/watchmaker/schedule.cpp
+++ b/engines/watchmaker/schedule.cpp
@@ -65,11 +65,10 @@ void AddWaitingMsgs(uint16 flags) {
* DeleteWaitingMsgs
* --------------------------------------------------*/
void DeleteWaitingMsgs(uint16 flags) {
- int8 a;
- for (a = 0; a < MAXWAITINGMSGS; a++)
+ for (int a = 0; a < MAXWAITINGMSGS; a++)
WaitingMsg[a].flags &= ~flags;
- for (a = 0; a < MAXWAITINGMSGS; a++)
+ for (int a = 0; a < MAXWAITINGMSGS; a++)
if (WaitingMsg[a].classe != EventClass::MC_IDLE && (WaitingMsg[a].flags < MP_WAITA))
memset(&WaitingMsg[a], 0, sizeof(WaitingMsg[a]));
}
@@ -90,33 +89,25 @@ bool _GetMessage(pqueue *lq) {
return true;
}
-
-/* -----------------08/02/99 10.10-------------------
- * InitQueue
- * --------------------------------------------------*/
-void InitQueue(pqueue *lq) {
+void MessageSystem::initQueue(pqueue *lq) {
lq->head = 0;
lq->tail = 0;
lq->len = 0;
}
-/* -----------------08/02/99 10.10-------------------
- * InitMessageSystem
- * --------------------------------------------------*/
-void InitMessageSystem() {
- uint16 i;
-
+void MessageSystem::init() {
TheTime = 0;
- InitQueue(&Game);
- for (i = 0; i < MAX_MESSAGES; i++)
+ initQueue(&Game);
+ for (int i = 0; i < MAX_MESSAGES; i++) {
Game.event[i] = &GameMessage[i];
+ }
- for (i = 0; i < MAXWAITINGMSGS; i++)
+ for (int i = 0; i < MAXWAITINGMSGS; i++) {
memset(&WaitingMsg[i], 0, sizeof(WaitingMsg[i]));
+ }
}
const char *eventToString(EventClass classe) {
-
switch (classe) {
case EventClass::MC_IDLE: return "MC_IDLE";
case EventClass::MC_MOUSE: return "MC_MOUSE";
@@ -144,7 +135,7 @@ void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wp
if (classe == EventClass::MC_IDLE && !event)
return ;
- lq = &Game;
+ lq = &(_vm->_messageSystem.Game); // TODO: Instead refactor this to be doEvent, like in the trecision-engine.
// se deve andare in attesa
if (flags >= MP_WAITA) {
@@ -212,7 +203,7 @@ void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wp
/* -----------------08/02/99 10.11-------------------
* Scheduler
* --------------------------------------------------*/
-void Scheduler() {
+void MessageSystem::scheduler() {
static uint8 Counter;
TheMessage = nullptr;
@@ -278,8 +269,8 @@ SUPEREVENT:
break;
}
- if (SuperEventActivate) {
- SuperEventActivate = false;
+ if (game._messageSystem.SuperEventActivate) {
+ game._messageSystem.SuperEventActivate = false;
goto SUPEREVENT;
}
}
@@ -298,7 +289,8 @@ void ReEvent() {
/* -----------------08/02/99 10.11-------------------
* RemoveEvent
* --------------------------------------------------*/
-void RemoveEvent(pqueue *lq, EventClass classe, uint8 event) {
+void MessageSystem::removeEvent(EventClass classe, uint8 event) {
+ pqueue *lq = &Game;
uint8 pos, b, c;
for (pos = lq->head; pos != lq->tail; pos = (pos == MAX_MESSAGES - 1) ? 0 : pos + 1) {
@@ -323,8 +315,9 @@ void RemoveEvent(pqueue *lq, EventClass classe, uint8 event) {
* RemoveEvent_bparam
* --------------------------------------------------*/
//come RemoveEvent(), solo che controllo anche bparam
-void RemoveEvent_bparam(pqueue *lq, EventClass classe, uint8 event, uint8 bparam) {
+void MessageSystem::removeEvent_bparam(EventClass classe, uint8 event, uint8 bparam) {
uint8 pos, b, c;
+ pqueue *lq = &Game;
for (pos = lq->head; pos != lq->tail; pos = (pos == MAX_MESSAGES - 1) ? 0 : pos + 1) {
if ((lq->event[pos]->classe == classe) && ((event == ME_ALL) || (lq->event[pos]->event == event)) && (lq->event[pos]->bparam == bparam)) {
diff --git a/engines/watchmaker/schedule.h b/engines/watchmaker/schedule.h
index 3ab8b66642b..d0be7e658d8 100644
--- a/engines/watchmaker/schedule.h
+++ b/engines/watchmaker/schedule.h
@@ -24,7 +24,6 @@
#include "watchmaker/types.h"
#include "watchmaker/struct.h"
-#include "watchmaker/game.h"
#include "watchmaker/message.h"
namespace Watchmaker {
@@ -32,14 +31,25 @@ namespace Watchmaker {
void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wparam2,
uint8 bparam, void *p0, void *p1, void *p2);
-void InitMessageSystem();
-void Scheduler();
void ProcessTheMessage(WGame &game);
void ReEvent();
void DeleteWaitingMsgs(uint16 flags);
void AddWaitingMsgs(uint16 flags);
-void RemoveEvent(pqueue *lq, EventClass classe, uint8 event);
-void RemoveEvent_bparam(pqueue *lq, EventClass classe, uint8 event, uint8 bparam);
+
+class MessageSystem {
+public:
+ void init();
+ void removeEvent(EventClass classe, uint8 event);
+ void removeEvent_bparam(EventClass classe, uint8 event, uint8 bparam);
+ void scheduler(); // TODO: Rename
+ message GameMessage[MAX_MESSAGES];
+ pqueue Game;
+ // message *TheMessage; // TODO: Replace the global variable with this
+ message idlemessage = {EventClass::MC_IDLE, 0, MP_DEFAULT};
+ uint8 SuperEventActivate;
+private:
+ void initQueue(pqueue *lq);
+};
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/walk/act.cpp b/engines/watchmaker/walk/act.cpp
index d0c389fdd97..03a746b9aba 100644
--- a/engines/watchmaker/walk/act.cpp
+++ b/engines/watchmaker/walk/act.cpp
@@ -171,7 +171,7 @@ void UpdateChar(WGame &game, int32 oc, t3dF32 Speed, t3dF32 Rot) {
} else
SlideChar(oc);
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_ALL);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
}
}
@@ -660,7 +660,7 @@ bool CharGotoPosition(WGame &game, int32 oc, uint8 pos, uint8 back, int32 anim)
if ((oc == ocCURPLAYER) || (oc == ocDARRELL && !CurPlayer) || (oc == ocVICTORIA && CurPlayer)) {
if ((PlayerPos[CurPlayer + ocDARRELL] == pos) || (PlayerGotoPos[CurPlayer + ocDARRELL] == pos)) return FALSE;
if ((cp = PlayerGotoPos[CurPlayer + ocDARRELL] = GetLightPosition(&tmp, pos)) == 0) return FALSE;
- RemoveEvent(&Game, EventClass::MC_PLAYER, ME_ALL);
+ game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
if (bFirstPerson)
Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
Commit: d2a7afba1543fd5d61b652579fc56c9f53b3cc2f
https://github.com/scummvm/scummvm/commit/d2a7afba1543fd5d61b652579fc56c9f53b3cc2f
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Movie mesh modifiers into a class.
This reduces the number of global constructors called.
Changed paths:
engines/watchmaker/game.cpp
engines/watchmaker/game.h
engines/watchmaker/globvar.cpp
engines/watchmaker/globvar.h
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/ll/ll_mesh.cpp
engines/watchmaker/ll/ll_mesh.h
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/saveload.cpp
engines/watchmaker/struct.h
diff --git a/engines/watchmaker/game.cpp b/engines/watchmaker/game.cpp
index 48c276d81bd..503df75bc8c 100644
--- a/engines/watchmaker/game.cpp
+++ b/engines/watchmaker/game.cpp
@@ -191,6 +191,7 @@ bool WGame::CheckAndLoadMoglieSupervisoreModel(int32 c) {
// TODO: This needs some heavy refactoring.
WGame::WGame() : workDirs(WATCHMAKER_CFG_NAME) {
_vm = this;
+ _meshModifiers = new MeshModifiers();
configLoaderFlags(); // TODO: This should probably happen before the constructor
// if LoaderFlags & T3D_DEBUGMODE
@@ -217,6 +218,7 @@ WGame::WGame() : workDirs(WATCHMAKER_CFG_NAME) {
WGame::~WGame() {
delete _renderer;
delete sdl;
+ delete _meshModifiers;
_vm = nullptr;
}
@@ -507,7 +509,7 @@ void WGame::UpdateAll() {
for (i = 0; i < NumLoadedFiles; i++) {
if (LoadedFiles[i].b) {
HideRoomMeshes(init, LoadedFiles[i].b);
- ApplyAllMeshModifiers(*this, LoadedFiles[i].b);
+ _meshModifiers->applyAllMeshModifiers(*this, LoadedFiles[i].b);
}
}
UpdateAllClocks(*this);
@@ -694,4 +696,13 @@ void WGame::CleanUpAndPostQuit() {
#endif
}
+void WGame::addMeshModifier(const Common::String &name, int16 com, void *p) {
+ _meshModifiers->addMeshModifier(name, com, p);
+}
+
+void WGame::loadMeshModifiers(Common::SeekableReadStream &stream) {
+ delete _meshModifiers;
+ _meshModifiers = new MeshModifiers(stream);
+}
+
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/game.h b/engines/watchmaker/game.h
index 07dbfe9cdc7..b9133c483bb 100644
--- a/engines/watchmaker/game.h
+++ b/engines/watchmaker/game.h
@@ -49,11 +49,14 @@ public:
}
};
+class MeshModifiers;
+
class WGame {
bool g_bReady, g_bActive;
bool g_bSkipActive = false;
const char *CharName[32];
uint32 LoadChar;
+ MeshModifiers *_meshModifiers;
public:
Common::RandomSource *_rnd;
@@ -99,6 +102,10 @@ public:
bool CheckAndLoadMoglieSupervisoreModel(int32 c);
void GameLoop();
+
+ // TODO: These might belong elsewhere after some refactoring:
+ void addMeshModifier(const Common::String &name, int16 com, void *p);
+ void loadMeshModifiers(Common::SeekableReadStream &stream);
};
extern WGame *_vm;
diff --git a/engines/watchmaker/globvar.cpp b/engines/watchmaker/globvar.cpp
index 50775a2dc37..73c6d19e090 100644
--- a/engines/watchmaker/globvar.cpp
+++ b/engines/watchmaker/globvar.cpp
@@ -167,7 +167,6 @@ char ObjectUnderCursor[MAX_STRING_LEN];
t3dV3F mPos;
// 3D MESH MODIFIER
-struct SMeshModifier MMList[MAX_MODIFIED_MESH];
struct SPlayerStand PlayerStand[MAX_PLAYERS];
// CHARACTERS VARS
diff --git a/engines/watchmaker/globvar.h b/engines/watchmaker/globvar.h
index 437889adea2..5c98166517d 100644
--- a/engines/watchmaker/globvar.h
+++ b/engines/watchmaker/globvar.h
@@ -89,7 +89,6 @@ struct InvVars {
extern char ObjectUnderCursor[];
extern t3dV3F mPos;
-extern struct SMeshModifier MMList[];
extern struct SPlayerStand PlayerStand[];
// SENTENCES
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index bc79ce7c5bf..7bab66adbf5 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -1761,7 +1761,7 @@ void ProcessAnims(WGame &game) {
h->sub[a].ptr->CurFrame = CurFrame = LastFrame;
if (!(CurFlags & T3D_MESH_CHARACTER)) {
UpdateBoundingBox(h->sub[a].ptr);
- AddMeshModifier(h->sub[a].ptr->name, MM_ANIM_BLOCK, game.init.Anim[an].name[a].rawArray());
+ _vm->addMeshModifier(h->sub[a].ptr->name, MM_ANIM_BLOCK, game.init.Anim[an].name[a].rawArray());
}
} else
h->sub[a].ptr->CurFrame = -3;
diff --git a/engines/watchmaker/ll/ll_mesh.cpp b/engines/watchmaker/ll/ll_mesh.cpp
index 7f751c48296..182aaa324de 100644
--- a/engines/watchmaker/ll/ll_mesh.cpp
+++ b/engines/watchmaker/ll/ll_mesh.cpp
@@ -452,64 +452,168 @@ bool t3dSetSpecialAnimFrame(WGame &game, const char *name, t3dMESH *mesh, int32
return true;
}
-/* -----------------15/09/98 12.23-------------------
- * ModifyMesh
- * --------------------------------------------------*/
-void ModifyMesh(WGame &game, t3dMESH *mesh) {
+void MeshModifiers::modifyMesh(WGame &game, t3dMESH *mesh) {
struct SMeshModifier *mm;
int16 i;
- if (!mesh || (mesh->Flags & T3D_MESH_CHARACTER)) return;
+ if (!mesh || (mesh->Flags & T3D_MESH_CHARACTER))
+ return;
-// Cerca se esite un modificatore per questa mesh
+ // Check if there is a modifier for this mesh
mm = &MMList[0];
for (i = 0; i < MAX_MODIFIED_MESH; i++, mm++)
if ((!mm->meshName.empty()) && (mm->meshName.equalsIgnoreCase(mesh->name)))
break;
-// Se non ci sono modificatori per questa mesh o si rifericono a un body
- if ((i >= MAX_MODIFIED_MESH) || (mm->Flags & (MM_SET_BND_LEVEL | MM_SET_HALOES)))
- return ;
-
- warning("MM %s: addflags %X, removeflags %X, anim |%s|", mesh->name.c_str(), mm->AddFlags, mm->RemoveFlags, mm->animName.c_str());
-// Aggiorna Flags
- if (mm->Flags & MM_REMOVE_FLAGS)
- mesh->Flags &= ~mm->RemoveFlags;
- if (mm->Flags & MM_ADD_FLAGS)
- mesh->Flags |= mm->AddFlags;
-
-// Aggiorna Materiali
- if (mm->Flags & MM_REMOVE_MAT_FLAGS)
- mesh->FList[0].getMaterial()->Flags &= ~mm->RemoveMatFlags;
- if (mm->Flags & MM_ADD_MAT_FLAGS)
- mesh->FList[0].getMaterial()->Flags |= mm->AddMatFlags;
- if (mm->Flags & MM_SET_MAT_FRAME)
- mesh->setMovieFrame(mm->MatFrame); // This did NOT check for existing face/material before setting before.
-
-// Aggiorna Anim
- if ((mm->Flags & MM_ANIM_BLOCK) && (!mm->animName.empty()) && (!mesh->CurFrame)) {
- t3dSetSpecialAnimFrame(game, mm->animName.c_str(), mesh, -1);
+ // If there are no modifiers for this mesh or they refer to a body
+ if ((i >= MAX_MODIFIED_MESH) || (mm->getFlags() & (MM_SET_BND_LEVEL | MM_SET_HALOES)))
+ return;
+
+ mm->modifyMesh(game, mesh);
+}
+
+void SMeshModifier::modifyMesh(WGame &game, t3dMESH *mesh) {
+ warning("MM %s: addflags %X, removeflags %X, anim |%s|", mesh->name.c_str(), this->AddFlags, this->RemoveFlags, this->animName.c_str());
+ // Update Flags
+ if (this->Flags & MM_REMOVE_FLAGS)
+ mesh->Flags &= ~this->RemoveFlags;
+ if (this->Flags & MM_ADD_FLAGS)
+ mesh->Flags |= this->AddFlags;
+
+ // Update Materials
+ if (this->Flags & MM_REMOVE_MAT_FLAGS)
+ mesh->FList[0].getMaterial()->Flags &= ~this->RemoveMatFlags;
+ if (this->Flags & MM_ADD_MAT_FLAGS)
+ mesh->FList[0].getMaterial()->Flags |= this->AddMatFlags;
+ if (this->Flags & MM_SET_MAT_FRAME)
+ mesh->setMovieFrame(this->MatFrame); // This did NOT check for existing face/material before setting before.
+
+ // Update Anim
+ if ((this->Flags & MM_ANIM_BLOCK) && (!this->animName.empty()) && (!mesh->CurFrame)) {
+ t3dSetSpecialAnimFrame(game, this->animName.c_str(), mesh, -1);
t3dCalcMeshBones(mesh, 1);
UpdateBoundingBox(mesh);
}
}
-/* -----------------22/06/00 10.35-------------------
- * ApplyAllMeshModifiers
+/* -----------------15/09/98 12.04-------------------
+ * AddMeshModifier
* --------------------------------------------------*/
-void ApplyAllMeshModifiers(WGame &game, t3dBODY *b) {
-// Cerca se esite un modificatore per questo body
+void MeshModifiers::addMeshModifier(const Common::String &name, int16 com, void *p) {
+ struct SMeshModifier *mm;
+ uint32 Flags;
+ int16 i;
+
+ warning("Not sure this is right"); // Used to check for nullptr, not 0 length.
+ if (name.empty() || !p)
+ return;
+
+ // DebugLogFile("AddMM |%s| %d",name,com);
+
+ // Check if a modifier already exists for this mesh
+ mm = &MMList[0];
+ for (i = 0; i < MAX_MODIFIED_MESH; i++, mm++)
+ if ((!mm->meshName.empty()) && mm->meshName.equalsIgnoreCase(name))
+ break;
+
+ // If it's a new modifier look for a free place
+ if (i >= MAX_MODIFIED_MESH) {
+ mm = &MMList[0];
+ for (i = 0; i < MAX_MODIFIED_MESH; i++, mm++)
+ if (mm->meshName.empty())
+ break;
+ if (i >= MAX_MODIFIED_MESH) {
+ warning("Troppi Mesh modifier per %s: MAX %d", name.c_str(), MAX_MODIFIED_MESH);
+ return;
+ }
+
+ *mm = SMeshModifier(name.c_str(), com, p);
+ } else {
+ mm->configure(name.c_str(), com, p);
+ }
+}
+
+SMeshModifier::SMeshModifier(Common::SeekableReadStream &stream) {
+ char stringBuffer[T3D_NAMELEN] = {};
+ stream.read(stringBuffer, T3D_NAMELEN);
+ meshName = stringBuffer;
+ Flags = stream.readSint32LE();
+ AddFlags = stream.readUint32LE();
+ RemoveFlags = stream.readUint32LE();
+ AddMatFlags = stream.readUint32LE();
+ RemoveMatFlags = stream.readUint32LE();
+ MatFrame = stream.readSint32LE();
+ BndLevel = stream.readUint16LE();
+ HaloesStatus = stream.readByte(); // TODO: Signed.
+ stream.read(stringBuffer, T3D_NAMELEN);
+ animName = stringBuffer;
+}
+
+SMeshModifier::SMeshModifier(const char *name, int16 com, void *p) {
+ configure(name, com, p);
+}
+
+void SMeshModifier::configure(const char *name, int16 com, void *p) {
+ this->Flags |= com;
+ switch (com) {
+ case MM_ADD_FLAGS:
+ Flags = *((uint32 *)p);
+ this->RemoveFlags &= ~Flags;
+ this->AddFlags |= Flags;
+ break;
+
+ case MM_REMOVE_FLAGS:
+ Flags = *((uint32 *)p);
+ this->AddFlags &= ~Flags;
+ this->RemoveFlags |= Flags;
+ break;
+
+ case MM_ADD_MAT_FLAGS:
+ Flags = *((uint32 *)p);
+ this->RemoveMatFlags &= ~Flags;
+ this->AddMatFlags |= Flags;
+ break;
+
+ case MM_REMOVE_MAT_FLAGS:
+ Flags = *((uint32 *)p);
+ this->AddMatFlags &= ~Flags;
+ this->RemoveMatFlags |= Flags;
+ break;
+
+ case MM_SET_MAT_FRAME:
+ this->MatFrame = *((int32 *)p);
+ break;
+
+ case MM_ANIM_BLOCK:
+ if (this->animName.empty())
+ this->animName = (char *)p;
+ else
+ this->animName.clear();
+ break;
+
+ case MM_SET_BND_LEVEL:
+ this->BndLevel = *((uint16 *)p);
+ break;
+
+ case MM_SET_HALOES:
+ this->HaloesStatus = *((int8 *)p);
+ break;
+ }
+}
+
+void MeshModifiers::applyAllMeshModifiers(WGame &game, t3dBODY *b) {
+ // Check if there is a modifier for this body
struct SMeshModifier *mm = &MMList[0];
for (int32 j = 0; j < MAX_MODIFIED_MESH; j++, mm++)
if ((!mm->meshName.empty()) && b->name.equalsIgnoreCase(mm->meshName)) {
- if (mm->Flags & MM_SET_BND_LEVEL)
- b->CurLevel = mm->BndLevel;
+ if (mm->getFlags() & MM_SET_BND_LEVEL)
+ b->CurLevel = mm->getBndLevel();
- if (mm->Flags & MM_SET_HALOES) {
+ if (mm->getFlags() & MM_SET_HALOES) {
for (auto &l : b->LightTable) {
if (!(l.Type & T3D_LIGHT_FLARE)) continue;
- if (mm->HaloesStatus > 0)
+ if (mm->getHaloesStatus() > 0)
l.Type |= T3D_LIGHT_LIGHTON;
else
l.Type &= ~T3D_LIGHT_LIGHTON;
@@ -517,8 +621,9 @@ void ApplyAllMeshModifiers(WGame &game, t3dBODY *b) {
}
}
- for (int32 i = 0; i < (int32)b->NumMeshes(); i++)
- ModifyMesh(game, &b->MeshTable[i]);
+ for (int32 i = 0; i < (int32)b->NumMeshes(); i++) {
+ modifyMesh(game, &b->MeshTable[i]);
+ }
}
/* -----------------29/03/99 14.33-------------------
@@ -652,88 +757,6 @@ void UpdateCharHead(int32 oc, t3dV3F *dir) {
}
}
-
-/* -----------------15/09/98 12.04-------------------
- * AddMeshModifier
- * --------------------------------------------------*/
-void AddMeshModifier(const Common::String &name, int16 com, void *p) {
- struct SMeshModifier *mm;
- uint32 Flags;
- int16 i;
-
- warning("Not sure this is right"); // Used to check for nullptr, not 0 length.
- if (name.empty() || !p) return;
-
-// DebugLogFile("AddMM |%s| %d",name,com);
-
-// Cerca se esiste gia' un modificatore per questa mesh
- mm = &MMList[0];
- for (i = 0; i < MAX_MODIFIED_MESH; i++, mm++)
- if ((!mm->meshName.empty()) && mm->meshName.equalsIgnoreCase(name))
- break;
-
-// Se e' un nuovo modificatore cerca un posto libero
- if (i >= MAX_MODIFIED_MESH) {
- mm = &MMList[0];
- for (i = 0; i < MAX_MODIFIED_MESH; i++, mm++)
- if (mm->meshName.empty())
- break;
- if (i >= MAX_MODIFIED_MESH) {
- warning("Troppi Mesh modifier per %s: MAX %d", name.c_str(), MAX_MODIFIED_MESH);
- return ;
- }
-// memset( mm, 0, sizeof( struct SMeshModifier ) );
- mm->meshName = name;
- }
-
- mm->Flags |= com;
- switch (com) {
- case MM_ADD_FLAGS:
- Flags = *((uint32 *)p);
- mm->RemoveFlags &= ~Flags;
- mm->AddFlags |= Flags;
- break;
-
- case MM_REMOVE_FLAGS:
- Flags = *((uint32 *)p);
- mm->AddFlags &= ~Flags;
- mm->RemoveFlags |= Flags;
- break;
-
- case MM_ADD_MAT_FLAGS:
- Flags = *((uint32 *)p);
- mm->RemoveMatFlags &= ~Flags;
- mm->AddMatFlags |= Flags;
- break;
-
- case MM_REMOVE_MAT_FLAGS:
- Flags = *((uint32 *)p);
- mm->AddMatFlags &= ~Flags;
- mm->RemoveMatFlags |= Flags;
- break;
-
- case MM_SET_MAT_FRAME:
- mm->MatFrame = *((int32 *)p);
- break;
-
- case MM_ANIM_BLOCK:
- if (mm->animName.empty())
- mm->animName = (char *)p;
- else
- mm->animName.clear();
- break;
-
- case MM_SET_BND_LEVEL:
- mm->BndLevel = *((uint16 *)p);
- break;
-
- case MM_SET_HALOES:
- mm->HaloesStatus = *((int8 *)p);
- break;
- }
-}
-
-
/* -----------------22/06/00 12.15-------------------
* ChangeMeshFlags
* --------------------------------------------------*/
@@ -742,10 +765,10 @@ void ChangeMeshFlags(t3dMESH *m, int8 add, uint32 newflags) {
if (add > 0) {
m->Flags |= newflags;
- AddMeshModifier(m->name, MM_ADD_FLAGS, &newflags);
+ _vm->addMeshModifier(m->name, MM_ADD_FLAGS, &newflags);
} else {
m->Flags &= ~newflags;
- AddMeshModifier(m->name, MM_REMOVE_FLAGS, &newflags);
+ _vm->addMeshModifier(m->name, MM_REMOVE_FLAGS, &newflags);
}
}
@@ -765,7 +788,7 @@ void ChangeHaloesStatus(t3dBODY *b, int8 op) {
else
l.Type &= ~T3D_LIGHT_LIGHTON;
}
- AddMeshModifier(b->name.c_str(), MM_SET_HALOES, &op);
+ _vm->addMeshModifier(b->name.c_str(), MM_SET_HALOES, &op);
}
/* -----------------01/06/00 11.12-------------------
@@ -793,9 +816,9 @@ void UpdateObjMesh(Init &init, int32 in) {
newflags = T3D_MESH_HIDDEN;
if (init.Obj[in].meshlink[a][0] != '\0') {
if ((init.Obj[in].flags & ON) && !(init.Obj[in].flags & HIDE))
- AddMeshModifier((char *)init.Obj[in].meshlink[a], MM_REMOVE_FLAGS, &newflags);
+ _vm->addMeshModifier((char *)init.Obj[in].meshlink[a], MM_REMOVE_FLAGS, &newflags);
else
- AddMeshModifier((char *)init.Obj[in].meshlink[a], MM_ADD_FLAGS, &newflags);
+ _vm->addMeshModifier((char *)init.Obj[in].meshlink[a], MM_ADD_FLAGS, &newflags);
}
}
}//for
@@ -817,7 +840,7 @@ void SetMeshMaterialMovieFrame(t3dMESH *m, int8 op, int32 newframe) {
newframe = m->getMovieFrame();
- AddMeshModifier(m->name, MM_SET_MAT_FRAME, &newframe);
+ _vm->addMeshModifier(m->name, MM_SET_MAT_FRAME, &newframe);
}
/* -----------------22/06/00 12.15-------------------
@@ -828,10 +851,10 @@ void ChangeMeshMaterialFlag(t3dMESH *m, int8 add, uint32 newflag) {
if (add > 0) {
m->FList[0].getMaterial()->addProperty(newflag);
- AddMeshModifier(m->name, MM_ADD_MAT_FLAGS, &newflag);
+ _vm->addMeshModifier(m->name, MM_ADD_MAT_FLAGS, &newflag);
} else {
m->FList[0].getMaterial()->clearFlag(newflag);
- AddMeshModifier(m->name, MM_REMOVE_MAT_FLAGS, &newflag);
+ _vm->addMeshModifier(m->name, MM_REMOVE_MAT_FLAGS, &newflag);
}
}
diff --git a/engines/watchmaker/ll/ll_mesh.h b/engines/watchmaker/ll/ll_mesh.h
index c943d982471..2fbd180d512 100644
--- a/engines/watchmaker/ll/ll_mesh.h
+++ b/engines/watchmaker/ll/ll_mesh.h
@@ -31,12 +31,10 @@ namespace Watchmaker {
uint8 t3dClipToSurface(Init &init, t3dV3F *pt);
void t3dLightChar(t3dMESH *mesh, t3dV3F *p);
void t3dProcessGolfSky(t3dMESH *gs);
-void ApplyAllMeshModifiers(WGame &game, t3dBODY *b);
void HideRoomMeshes(Init &init, t3dBODY *body);
void t3dUpdateArrow(t3dMESH *m, t3dF32 len);
bool t3dSetSpecialAnimFrame(WGame &game, const char *name, t3dMESH *mesh, int32 nf);
void ChangeMeshFlags(t3dMESH *m, int8 add, uint32 newflags);
-void AddMeshModifier(const Common::String &name, int16 com, void *p);
void UpdateObjMesh(Init &init, int32 in);
void UpdateBoundingBox(t3dMESH *mesh);
void UpdateCharHead(int32 oc, t3dV3F *dir);
@@ -48,6 +46,44 @@ void t3dLightRoom(Init &init, t3dBODY *b, t3dV3F *p, t3dF32 NearRange, t3dF32 Fa
void t3dUpdateExplosion(t3dMESH *m, t3dF32 scale);
bool t3dMoveAndCheck1stCamera(t3dBODY *rr, t3dCAMERA *cc, t3dV3F *mm);
+// TODO: This could perhaps be PIMPLd, as we don't really need to expose the implementation.
+struct SMeshModifier {
+ Common::String meshName;
+private:
+ int32 Flags = 0;
+ uint32 AddFlags = 0;
+ uint32 RemoveFlags = 0;
+ uint32 AddMatFlags = 0;
+ uint32 RemoveMatFlags = 0;
+ int32 MatFrame = 0;
+ uint16 BndLevel = 0;
+ int8 HaloesStatus = 0;
+public:
+ Common::String animName;
+ SMeshModifier() = default;
+ SMeshModifier(const char *name, int16 com, void *p);
+ SMeshModifier(Common::SeekableReadStream &stream);
+ void configure(const char *name, int16 com, void *p);
+ void modifyMesh(WGame &game, t3dMESH *mesh);
+ uint16 getBndLevel() const { return BndLevel; }
+ int32 getFlags() const { return Flags; }
+ int8 getHaloesStatus() const { return HaloesStatus; }
+};
+
+class MeshModifiers {
+ SMeshModifier MMList[MAX_MODIFIED_MESH] = {};
+public:
+ MeshModifiers() = default;
+ MeshModifiers(Common::SeekableReadStream &stream) {
+ for (int i = 0; i < MAX_MODIFIED_MESH; i++) {
+ MMList[i] = SMeshModifier(stream);
+ }
+ }
+ void addMeshModifier(const Common::String &name, int16 com, void *p);
+ void applyAllMeshModifiers(WGame &game, t3dBODY *b);
+ void modifyMesh(WGame &game, t3dMESH *mesh);
+};
+
} // End of namespace Watchmaker
#endif // WATCHMAKER_LL_MESH_H
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index a0cb81efc00..7d25c911e59 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -463,7 +463,7 @@ bool SetBndLevel(WGame &game, const char *roomname, int32 lev) {
if (t == t3dCurRoom)
CurFloorY = t->PanelHeight[t->CurLevel];
- AddMeshModifier(t->name, MM_SET_BND_LEVEL, &lev);
+ _vm->addMeshModifier(t->name, MM_SET_BND_LEVEL, &lev);
UpdateRoomVisibility(game);
DebugLogFile("SETBND: %s, %d", t->name.c_str(), lev);
diff --git a/engines/watchmaker/saveload.cpp b/engines/watchmaker/saveload.cpp
index 7cbfeac41d1..29ccdc4c0cf 100644
--- a/engines/watchmaker/saveload.cpp
+++ b/engines/watchmaker/saveload.cpp
@@ -494,9 +494,8 @@ bool DataLoad(WGame &game, const Common::String &FileName, uint8 slot) {
bPorteEsternoBloccate = stream->readByte();
bSezioneLabirinto = stream->readByte();
- for (int i = 0; i < MAX_MODIFIED_MESH; i++) {
- MMList[i] = SMeshModifier(*stream);
- }
+ _vm->loadMeshModifiers(*stream);
+
for (int i = 0; i < MAX_PLAYERS; i++) {
PlayerStand[i] = SPlayerStand(*stream);
}
diff --git a/engines/watchmaker/struct.h b/engines/watchmaker/struct.h
index 2223c2da926..831ae7533b7 100644
--- a/engines/watchmaker/struct.h
+++ b/engines/watchmaker/struct.h
@@ -401,35 +401,6 @@ struct SPDALog : public SerializableAsset {
}
};
-struct SMeshModifier {
- Common::String meshName;
- int32 Flags = 0;
- uint32 AddFlags = 0;
- uint32 RemoveFlags = 0;
- uint32 AddMatFlags = 0;
- uint32 RemoveMatFlags = 0;
- int32 MatFrame = 0;
- uint16 BndLevel = 0;
- int8 HaloesStatus = 0;
- Common::String animName;
- SMeshModifier() = default;
- SMeshModifier(Common::SeekableReadStream &stream) {
- char stringBuffer[T3D_NAMELEN] = {};
- stream.read(stringBuffer, T3D_NAMELEN);
- meshName = stringBuffer;
- Flags = stream.readSint32LE();
- AddFlags = stream.readUint32LE();
- RemoveFlags = stream.readUint32LE();
- AddMatFlags = stream.readUint32LE();
- RemoveMatFlags = stream.readUint32LE();
- MatFrame = stream.readSint32LE();
- BndLevel = stream.readUint16LE();
- HaloesStatus = stream.readByte(); // TODO: Signed.
- stream.read(stringBuffer, T3D_NAMELEN);
- animName = stringBuffer;
- }
-};
-
struct SString {
char text[MAX_STRING_LEN] = {};
uint16 x = 0, y = 0, dx = 0;
Commit: cf8e6d668d11a1052050ceba147ca10673dd1166
https://github.com/scummvm/scummvm/commit/cf8e6d668d11a1052050ceba147ca10673dd1166
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Refactor Event to be MessageSystem::doEvent
Changed paths:
engines/watchmaker/classes/do_action.cpp
engines/watchmaker/classes/do_camera.cpp
engines/watchmaker/classes/do_dialog.cpp
engines/watchmaker/classes/do_inv.cpp
engines/watchmaker/classes/do_inv_inv.cpp
engines/watchmaker/classes/do_inv_scr.cpp
engines/watchmaker/classes/do_keyboard.cpp
engines/watchmaker/classes/do_mouse.cpp
engines/watchmaker/classes/do_operate.cpp
engines/watchmaker/classes/do_player.cpp
engines/watchmaker/classes/do_string.cpp
engines/watchmaker/classes/do_system.cpp
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/ll/ll_mouse.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/main.cpp
engines/watchmaker/schedule.cpp
engines/watchmaker/schedule.h
engines/watchmaker/t2d/t2d.cpp
engines/watchmaker/walk/act.cpp
diff --git a/engines/watchmaker/classes/do_action.cpp b/engines/watchmaker/classes/do_action.cpp
index 7d691ab67fc..b2247700f1c 100644
--- a/engines/watchmaker/classes/do_action.cpp
+++ b/engines/watchmaker/classes/do_action.cpp
@@ -43,13 +43,13 @@ bool CheckRoomPuzzle(WGame &game, uint8 ev) {
ClearText();
ClearUseWith();
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dGIARDINIERE_INTERRUPT2, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dGIARDINIERE_INTERRUPT2, 0, 0, nullptr, nullptr, nullptr);
return true;
} else if ((game._gameVars.getCurRoomId() == r2G) && (WhichRoomChar(game.init, ocCUSTODE) == r2G) && ((CurObj != o2Gp2H) && (CurObj != ocCUSTODE))) {
ClearText();
ClearUseWith();
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUSTODE_INTERRUPT5, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUSTODE_INTERRUPT5, 0, 0, nullptr, nullptr, nullptr);
return true;
}
return false;
@@ -167,7 +167,7 @@ void doExamine(WGame &game, int32 obj) {
if (!(init.PDALog[log_item].flags & PDA_ON)) {
init.PDALog[log_item].flags |= (PDA_ON | PDA_UPDATE);
init.PDALog[log_item].time = t3dCurTime;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
}
sent = TRUE;
}
@@ -222,10 +222,10 @@ void doAction(WGame &game) {
CurMousePointer = MousePointerPlus;
} else if (init.Obj[CurObj].flags & CHARACTER) {
if (bFirstPerson) {
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, init.Obj[CurObj].goroom, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, init.Obj[CurObj].goroom, 0, 0, nullptr, nullptr, nullptr);
} else
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, init.Obj[CurObj].goroom, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, init.Obj[CurObj].goroom, 0, 0, nullptr, nullptr, nullptr);
} else if (init.Obj[CurObj].flags & TAKE)
doTake(game, CurObj);
else if (init.Obj[CurObj].flags & ROOM)
diff --git a/engines/watchmaker/classes/do_camera.cpp b/engines/watchmaker/classes/do_camera.cpp
index 4e1a6775213..9281b47d595 100644
--- a/engines/watchmaker/classes/do_camera.cpp
+++ b/engines/watchmaker/classes/do_camera.cpp
@@ -616,7 +616,7 @@ void ProcessCamera(WGame &game) {
AddWaitingMsgs(MP_WAIT_CAMERA);
}
if (bFirstPerson)
- Event(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
// Fa partire animazione di link portali se l'ho attraversato con i tasti
for (i = 0; i < (int16)t3dCurRoom->NumMeshes(); i++) {
if (t3dCurRoom->MeshTable[i].PortalList == PortalCrossed) {
@@ -659,7 +659,7 @@ void ProcessCamera(WGame &game) {
) {
// DebugLogFile("BECCATO222");
CharStop(ocCURPLAYER);
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR48KRENNSPARA, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR48KRENNSPARA, 0, 0, nullptr, nullptr, nullptr);
}
// per sicurezza faccio sparire la bottiglia
diff --git a/engines/watchmaker/classes/do_dialog.cpp b/engines/watchmaker/classes/do_dialog.cpp
index b4c09b40f20..d60fbd62e5f 100644
--- a/engines/watchmaker/classes/do_dialog.cpp
+++ b/engines/watchmaker/classes/do_dialog.cpp
@@ -113,11 +113,11 @@ void doDialog(WGame &game) {
//DebugFile("DLG: StartDialog %d",CurDialog);
// Se sono in un fullmotion
if ((init.Dialog[CurDialog].flags & DIALOG_RTV2) && (init.Dialog[CurDialog].ItemIndex[mRTV2]))
- Event(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, mRTV2, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, mRTV2, 0, nullptr, nullptr, nullptr);
else if ((init.Dialog[CurDialog].flags & DIALOG_RTV3) && (init.Dialog[CurDialog].ItemIndex[mRTV3]))
- Event(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, mRTV3, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, mRTV3, 0, nullptr, nullptr, nullptr);
else if ((init.Dialog[CurDialog].flags & DIALOG_RTV) || (init.Dialog[CurDialog].ItemIndex[mRTV]))
- Event(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, mRTV, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, mRTV, 0, nullptr, nullptr, nullptr);
// Se c'e' un predialog attivo
else if (init.Dialog[CurDialog].flags & (DIALOG_PRE1 | DIALOG_PRE2 | DIALOG_PRE3 | DIALOG_PRE4)) {
if (init.Dialog[CurDialog].flags & DIALOG_PRE_RAND)
@@ -128,7 +128,7 @@ void doDialog(WGame &game) {
else r = 3;
if (init.Dialog[CurDialog].ItemIndex[mPREDIALOG1 + r])
- Event(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, (int16)(mPREDIALOG1 + r), 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, (int16)(mPREDIALOG1 + r), 0, nullptr, nullptr, nullptr);
else
bDialogMenuActive = true;
} else
@@ -148,7 +148,7 @@ void doDialog(WGame &game) {
// DebugLogFile("IC %d %d %d | %d %d %d",ic->com,ic->param1,ic->param2,CurDialog,CurDlgItem,TheMessage->lparam[0]);
switch (ic->com) {
case IC_NULL: // Esce dal dialogo
- Event(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
break;
case IC_SET_PLAYER: // non fa niente
break;
@@ -237,14 +237,16 @@ void doDialog(WGame &game) {
case IC_INTRO_TEXT1:
ic1 = ic->param1;
ic2 = ic->param2;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, FRAME_PER_SECOND, EFFECT_FADEOUT_T1, &ic1, nullptr, nullptr);
- if (ic2) Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_WAITA, FRAME_PER_SECOND, FRAME_PER_SECOND, EFFECT_MOVEIN_T1, &ic1, nullptr, &ic2);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, FRAME_PER_SECOND, EFFECT_FADEOUT_T1, &ic1, nullptr, nullptr);
+ if (ic2)
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_WAITA, FRAME_PER_SECOND, FRAME_PER_SECOND, EFFECT_MOVEIN_T1, &ic1, nullptr, &ic2);
break;
case IC_INTRO_TEXT2:
ic1 = ic->param1;
ic2 = ic->param2;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, FRAME_PER_SECOND, EFFECT_FADEOUT_T2, &ic1, nullptr, nullptr);
- if (ic2) Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_WAITA, FRAME_PER_SECOND, FRAME_PER_SECOND, EFFECT_MOVEIN_T2, &ic1, nullptr, &ic2);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, FRAME_PER_SECOND, EFFECT_FADEOUT_T2, &ic1, nullptr, nullptr);
+ if (ic2)
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_WAITA, FRAME_PER_SECOND, FRAME_PER_SECOND, EFFECT_MOVEIN_T2, &ic1, nullptr, &ic2);
break;
case IC_TIME_ANIM:
@@ -291,14 +293,14 @@ void doDialog(WGame &game) {
DebugSent = 0;
break;
case IC_TIME_FADOUT:
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, ic->param1, 1, EFFECT_FADOUT, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, ic->param1, 1, EFFECT_FADOUT, nullptr, nullptr, nullptr);
TheMessage->flags |= MP_WAITA;
ReEvent();
return ;
}
ic = &init.DlgItem[init.Dialog[CurDialog].ItemIndex[CurDlgItem]].item[CurPlayer][TheMessage->lparam[0]];
}
- Event(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, (int16)CurDlgItem, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, (int16)CurDlgItem, 0, nullptr, nullptr, nullptr);
break;
case ME_DIALOGEND:
@@ -321,7 +323,7 @@ void doDialog(WGame &game) {
else r = 2;
if (init.Dialog[CurDialog].ItemIndex[mENDDIALOG1 + r]) {
- Event(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)(CurDialog), (int16)(mENDDIALOG1 + r), 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)(CurDialog), (int16)(mENDDIALOG1 + r), 0, nullptr, nullptr, nullptr);
return ;
}
}
@@ -348,7 +350,7 @@ void doDialog(WGame &game) {
TimeAnim = aNULL;
bPlayerInAnim = false;
if (NextDlg != dNULL)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, NextDlg, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, NextDlg, 0, 0, nullptr, nullptr, nullptr);
else {
extern uint8 t3dLastCameraIndex;
@@ -440,10 +442,10 @@ void UpdateDialogMenu(WGame &game, int16 dmx, int16 dmy, uint8 db) {
CurMenu = CurDlgItem;
Diag2Base = 0;
} else if ((db == ME_MLEFT) && (CurDlgItem) && (CurDlgItem != -1)) { // TODO: The original didn't have a check for -1 here
- Event(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, (int16)CurDlgItem, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGCONTINUE, MP_DEFAULT, (int16)CurDialog, (int16)CurDlgItem, 0, nullptr, nullptr, nullptr);
UsedDlgMenu[CurPlayer][CurObj][CurDlgItem] = 1;
} else if ((db == ME_MRIGHT) && (CurMenu == mMAIN))
- Event(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, (int16)mQUIT, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, (int16)mQUIT, 0, nullptr, nullptr, nullptr);
else if (db == ME_MRIGHT) {
CurMenu = mMAIN;
Diag2Base = 0;
diff --git a/engines/watchmaker/classes/do_inv.cpp b/engines/watchmaker/classes/do_inv.cpp
index b6097750e30..3e800497f6b 100644
--- a/engines/watchmaker/classes/do_inv.cpp
+++ b/engines/watchmaker/classes/do_inv.cpp
@@ -225,7 +225,7 @@ void doInventory(WGame &game) {
ReplaceSaveLoadTexture(CurInvObj);
break;
} else if ((InvStatus & INV_MODE2) && ((CurInvObj == i00TELEFONO) || (CurInvObj == i00TELEFONOVIC))) {
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tPDA, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tPDA, nullptr, nullptr, nullptr);
break;
}
BigInvObj = CurInvObj;
@@ -264,7 +264,7 @@ void doInventory(WGame &game) {
CurMousePointer = MousePointerPlus;
} else if (CurInvObj) {
if (init.InvObj[CurInvObj].anim[CurPlayer]) {
- Event(EventClass::MC_INVENTORY, ME_INVOFF, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_INVENTORY, ME_INVOFF, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
StartAnim(game, init.InvObj[CurInvObj].anim[CurPlayer]);
break;
} else {
@@ -272,7 +272,7 @@ void doInventory(WGame &game) {
if (CurInvObj == i28WALKMANOK) {
if (init.InvObj[CurInvObj].flags & EXTRA) an = a289_noinctime;
else an = a289;
- Event(EventClass::MC_INVENTORY, ME_INVOFF, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_INVENTORY, ME_INVOFF, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
StartAnim(game, an);
}
}
diff --git a/engines/watchmaker/classes/do_inv_inv.cpp b/engines/watchmaker/classes/do_inv_inv.cpp
index 57f5cfdfac0..6606f4b1bba 100644
--- a/engines/watchmaker/classes/do_inv_inv.cpp
+++ b/engines/watchmaker/classes/do_inv_inv.cpp
@@ -43,7 +43,7 @@ void doInvInvUseWith(WGame &game) {
case i00TELEFONO:
case i00TELEFONOVIC:
if ((UseWith[WITH] == i28WALKMANOK) && (init.InvObj[i28WALKMANOK].flags & EXTRA)) {
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tPDA, &UseWith[WITH], nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tPDA, &UseWith[WITH], nullptr, nullptr);
sent = FALSE;
}
break;
diff --git a/engines/watchmaker/classes/do_inv_scr.cpp b/engines/watchmaker/classes/do_inv_scr.cpp
index 73df8d2a7a2..937b3e53a45 100644
--- a/engines/watchmaker/classes/do_inv_scr.cpp
+++ b/engines/watchmaker/classes/do_inv_scr.cpp
@@ -44,14 +44,14 @@ void doInvScrUseWith(WGame &game) {
//messo fuori perche' andava in conflitto con l'usacon dell'icona
if ((UseWith[USED] == i29FOTOPROGETTO) && (UseWith[WITH] == ocCUSTODE)) {
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR005, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR005, 0, 0, nullptr, nullptr, nullptr);
return;
}
//messo fuori perche' se non parte l'RTV deve dire la frase
if ((UseWith[USED] == i1cMEDAGLIONI2) && (UseWith[WITH] == o1CBOCCA)) {
if (init.Dialog[dR1A5].flags & DIALOG_DONE) {
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR1C3, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR1C3, 0, 0, nullptr, nullptr, nullptr);
return;
} else {
PlayerSpeak(game, init.InvObj[i1cMEDAGLIONI2].text[1]);
@@ -80,14 +80,14 @@ void doInvScrUseWith(WGame &game) {
switch (UseWith[USED]) {
case i41OGGETTO:
if (UseWith[WITH] == ocCUSTODE)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR002, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR002, 0, 0, nullptr, nullptr, nullptr);
else
sent = TRUE;
break;
case i14OCCHIALI:
if (UseWith[WITH] == ocCUSTODE)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR003, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR003, 0, 0, nullptr, nullptr, nullptr);
else
sent = TRUE;
break;
@@ -122,14 +122,14 @@ void doInvScrUseWith(WGame &game) {
case i25MEDAGLIONI4:
if (UseWith[WITH] == o1CBOCCA) {
sa = a1C2;
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_ANIM, dR1C1, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_ANIM, dR1C1, 0, 0, nullptr, nullptr, nullptr);
} else
sent = TRUE;
break;
case i1cMEDAGLIONI3:
if (UseWith[WITH] == o1CBOCCA) {
sa = a1C2;
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_ANIM, dR1C2, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_ANIM, dR1C2, 0, 0, nullptr, nullptr, nullptr);
} else
sent = TRUE;
break;
@@ -199,13 +199,13 @@ void doInvScrUseWith(WGame &game) {
init.Dialog[dR009].flags |= DIALOG_RTV3;
init.InvObj[i2lBOTTIGLIAVINO].flags |= EXTRA2;
}
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR009, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR009, 0, 0, nullptr, nullptr, nullptr);
}
break;
case i34LASTRE:
if (UseWith[WITH] == ocSUPERVISORE)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR007, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR007, 0, 0, nullptr, nullptr, nullptr);
else
sent = TRUE;
break;
@@ -214,7 +214,7 @@ void doInvScrUseWith(WGame &game) {
if (UseWith[WITH] == ocSERVETTA) {
if (CurPlayer == VICTORIA) {
// PlayerSpeak( init.InvObj[i22BRACCIALE].text[1] );
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR001, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR001, 0, 0, nullptr, nullptr, nullptr);
} else {
PlayerSpeak(game, init.InvObj[i22BRACCIALE].text[0]);
}
@@ -227,20 +227,20 @@ void doInvScrUseWith(WGame &game) {
PlayerSpeak(game, init.InvObj[i29FOTOJUDE1].text[0]);
if (CurPlayer == VICTORIA)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR291, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR291, 0, 0, nullptr, nullptr, nullptr);
} else sent = TRUE;
break;
case i29STAMPAINGRANAGGIO:
if (UseWith[WITH] == ocCUSTODE)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR006, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR006, 0, 0, nullptr, nullptr, nullptr);
else
sent = TRUE;
break;
case i31ANELLOBRONZO:
if (UseWith[WITH] == ocCUSTODE)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR004, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR004, 0, 0, nullptr, nullptr, nullptr);
else
sent = TRUE;
break;
@@ -248,14 +248,14 @@ void doInvScrUseWith(WGame &game) {
case i1aLUCCHETTO:
if (UseWith[WITH] == oXT1AFINESTRA) {
// morte Cacciatore
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR1A5, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR1A5, 0, 0, nullptr, nullptr, nullptr);
} else
sent = TRUE;
break;
case i48CHIAVIMANETTE:
if (UseWith[WITH] == o48MANETTE)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR483, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR483, 0, 0, nullptr, nullptr, nullptr);
else
sent = TRUE;
break;
diff --git a/engines/watchmaker/classes/do_keyboard.cpp b/engines/watchmaker/classes/do_keyboard.cpp
index b5de513d267..79447dfe444 100644
--- a/engines/watchmaker/classes/do_keyboard.cpp
+++ b/engines/watchmaker/classes/do_keyboard.cpp
@@ -235,11 +235,11 @@ void ProcessKeyboard(WGame &game) {
// Hack: Skip intro:
if ((CurDialog == dR000) || (CurDialog == dR111) || (CurDialog == dR211)) {
NextDlg = dNULL;
- Event(EventClass::MC_DIALOG, ME_DIALOGEND_SKIPINTRO, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND_SKIPINTRO, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
}
// Skip Loghi
if (CurDialog == dRLOGHI)
- Event(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
// End hack
t3dF32 TurnSpeed, Speed = 1.0f, dist;
@@ -263,16 +263,16 @@ void ProcessKeyboard(WGame &game) {
// Skip Intro
if ((CurDialog == dR000) || (CurDialog == dR111) || (CurDialog == dR211)) {
NextDlg = dNULL;
- Event(EventClass::MC_DIALOG, ME_DIALOGEND_SKIPINTRO, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND_SKIPINTRO, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
}
// Skip Loghi
if (CurDialog == dRLOGHI)
- Event(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
// Skip MorteWM
if (CurDialog == dR391)
- Event(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
// Skip durante i crediti, quitta
if (bTitoliCodaScrolling || bTitoliCodaStatic)
@@ -342,7 +342,7 @@ void ProcessKeyboard(WGame &game) {
bSkipTalk = TRUE;
if (KeyUp(Common::KEYCODE_h))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dPROVA, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dPROVA, 0, 0, NULL, NULL, NULL);
if (KeyUp(Common::KEYCODE_e))
StartAnim(game, aFOX);
@@ -531,7 +531,7 @@ void ProcessKeyboard(WGame &game) {
bShowExtraLocalizationStrings ^= 1;
if (KeyUp(Common::KEYCODE_p))
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tPDA, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tPDA, NULL, NULL, NULL);
}
if (KeyUp(Common::KEYCODE_F8) && PlayerCanSwitch(game._gameVars, 1) && !(InvStatus & INV_ON))
@@ -541,11 +541,11 @@ void ProcessKeyboard(WGame &game) {
if (CurPlayer == DARRELL) a = ocVICTORIA;
else a = ocDARRELL;
if (a == (ocDARRELL + CurPlayer)) return ;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND / 3, 0, EFFECT_FADOUT, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND / 3, 0, EFFECT_FADOUT, NULL, NULL, NULL);
if (bMovingCamera)
- Event(EventClass::MC_SYSTEM, ME_CHANGEPLAYER, MP_WAITA | MP_WAIT_CAMERA, (int16)a, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_CHANGEPLAYER, MP_WAITA | MP_WAIT_CAMERA, (int16)a, 0, 0, NULL, NULL, NULL);
else
- Event(EventClass::MC_SYSTEM, ME_CHANGEPLAYER, MP_WAITA, (int16)a, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_CHANGEPLAYER, MP_WAITA, (int16)a, 0, 0, NULL, NULL, NULL);
}
if ((bPlayerInAnim) || (bNotSkippableWalk) || (bDialogActive)) {
@@ -562,15 +562,15 @@ void ProcessKeyboard(WGame &game) {
if (KeyUp(Common::KEYCODE_F1) && !(InvStatus & INV_ON) && (bT2DActive == tNULL) && PlayerCanSave()) {
rGrabVideo("temp.tmp", 1);
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_SAVE, 0, tOPTIONS, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_SAVE, 0, tOPTIONS, NULL, NULL, NULL);
}
if (KeyUp(Common::KEYCODE_F2) && !(InvStatus & INV_ON) && (bT2DActive == tNULL)) {
rGrabVideo("temp.tmp", 1);
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_LOAD, 0, tOPTIONS, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_LOAD, 0, tOPTIONS, NULL, NULL, NULL);
}
if (KeyUp(Common::KEYCODE_F3) && !(InvStatus & INV_ON) && (bT2DActive == tNULL)) {
rGrabVideo("temp.tmp", 1);
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_OPTIONS, 0, tOPTIONS, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_OPTIONS, 0, tOPTIONS, NULL, NULL, NULL);
}
@@ -593,7 +593,7 @@ void ProcessKeyboard(WGame &game) {
dist = t3dVectAngle(&cd, &Player->Dir);
if ((dist < 60.0f) && (dist > -60.0f)) {
CurObj = b;
- Event(EventClass::MC_MOUSE, ME_MRIGHT, MP_DEFAULT, 0, 0, 0, &CurObj, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_MOUSE, ME_MRIGHT, MP_DEFAULT, 0, 0, 0, &CurObj, NULL, NULL);
}
}
}
@@ -604,13 +604,13 @@ void ProcessKeyboard(WGame &game) {
if (bSomeOneSpeak) bSkipTalk = TRUE;
if ((bFirstPerson == 0) && (!bMovingCamera) && (!bNoFirstPersonSwitch)/* && !( InvStatus & INV_ON )*/)
- Event(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
else if ((!bMovingCamera) && (!bNoFirstPersonSwitch)/* && !( InvStatus & INV_ON )*/)
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
}
if (KeyUp(Common::KEYCODE_TAB) && !bLockCamera) // Fa uscire l'inventario
- Event(EventClass::MC_INVENTORY, ME_INVSWITCH, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_INVENTORY, ME_INVSWITCH, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
if (KeyDown(Common::KEYCODE_LEFT) && !(InvStatus & INV_ON) && !(bFirstPerson)) { // Ruota a Destra
AngleY = (-1) * TurnSpeed / 180.0f * T3D_PI;
@@ -663,7 +663,7 @@ void ProcessKeyboard(WGame &game) {
HandleFirstPersonView();
if (bFirstPerson) {
- Event(EventClass::MC_MOUSE, ME_MOUSEUPDATE, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_MOUSE, ME_MOUSEUPDATE, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
AngleX = AngleY = AngleSpeed = 0.0f;
if (Player)
Player->Flags |= T3D_CHARACTER_HIDE;
diff --git a/engines/watchmaker/classes/do_mouse.cpp b/engines/watchmaker/classes/do_mouse.cpp
index 7cb900ba352..46e7ef2b30b 100644
--- a/engines/watchmaker/classes/do_mouse.cpp
+++ b/engines/watchmaker/classes/do_mouse.cpp
@@ -80,7 +80,7 @@ void doMouseButton(WGame &game) {
if (InvStatus & INV_ON) {
if ((InvStatus & INV_ON) && (InvStatus & INV_MODE1) && PlayerCanCall(game._gameVars)) {
if (CheckRect(renderer, game._gameRect._callOtherPlayerRect, TheMessage->wparam1, TheMessage->wparam2)) {
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dRCALLOTHERPLAYER, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dRCALLOTHERPLAYER, 0, 0, nullptr, nullptr, nullptr);
return;
}
}
@@ -118,11 +118,11 @@ void doMouseButton(WGame &game) {
} else if (CheckRect(renderer, game._gameRect._quitGameRect, TheMessage->wparam1, TheMessage->wparam2))
CloseSys(game);
else if (CheckRect(renderer, game._gameRect._invSaveRect, TheMessage->wparam1, TheMessage->wparam2) && !(InvStatus & INV_MODE4) && PlayerCanSave())
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_SAVE, 0, tOPTIONS, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_SAVE, 0, tOPTIONS, nullptr, nullptr, nullptr);
else if (CheckRect(renderer, game._gameRect._invLoadRect, TheMessage->wparam1, TheMessage->wparam2) && !(InvStatus & INV_MODE4))
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_LOAD, 0, tOPTIONS, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_LOAD, 0, tOPTIONS, nullptr, nullptr, nullptr);
else if (CheckRect(renderer, game._gameRect._invOptionsRect, TheMessage->wparam1, TheMessage->wparam2) && !(InvStatus & INV_MODE4))
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_OPTIONS, 0, tOPTIONS, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_OPTIONS, 0, tOPTIONS, nullptr, nullptr, nullptr);
else {
ClearUseWith();
if ((CheckRect(renderer, game._gameRect._playerInvRect, TheMessage->wparam1, TheMessage->wparam2)) || (InvStatus & INV_MODE4)) {
@@ -152,11 +152,11 @@ void doMouseButton(WGame &game) {
}
if (TheMessage->event == ME_MRIGHT)
- Event(EventClass::MC_INVENTORY, ME_OPERATEICON, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &CurInvObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_INVENTORY, ME_OPERATEICON, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &CurInvObj, nullptr, nullptr);
else if (bUseWith & UW_ON)
- Event(EventClass::MC_INVENTORY, ME_OPERATEICON, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &CurInvObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_INVENTORY, ME_OPERATEICON, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &CurInvObj, nullptr, nullptr);
else
- Event(EventClass::MC_INVENTORY, ME_EXAMINEICON, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &CurInvObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_INVENTORY, ME_EXAMINEICON, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &CurInvObj, nullptr, nullptr);
//if( ( InvStatus & INV_MODE2 ) && CheckRect(BigIconRect,TheMessage->wparam1,TheMessage->wparam2) )
//CurInvObj = iNULL;
@@ -232,13 +232,13 @@ void doMouseButton(WGame &game) {
// Se ho cliccato in un altro portale dice di contiunare la camminata
if ((NextPortalObj) && (NextPortalAnim))
- Event(EventClass::MC_MOUSE, TheMessage->event, MP_WAIT_ANIM, 0, 0, 0, &NextPortalObj, nullptr, &bFastWalk);
+ _vm->_messageSystem.doEvent(EventClass::MC_MOUSE, TheMessage->event, MP_WAIT_ANIM, 0, 0, 0, &NextPortalObj, nullptr, &bFastWalk);
else if (NextPortalObj)
- Event(EventClass::MC_MOUSE, TheMessage->event, MP_WAIT_PORTAL, 0, 0, 0, &NextPortalObj, nullptr, &bFastWalk);
+ _vm->_messageSystem.doEvent(EventClass::MC_MOUSE, TheMessage->event, MP_WAIT_PORTAL, 0, 0, 0, &NextPortalObj, nullptr, &bFastWalk);
// Se sono in prima torno in terza, a meno che l'oggetto non mi obblighi a restare in prima
if (bFirstPerson && !bNoFirstPersonSwitch && (!CurObj || (CurObj && (!(init.Obj[CurObj].flags & NOSWITCH) || (Player->Walk.Check & LONGPATH)))))
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
//? else if( bFirstPerson )
//? CharStop( ocCURPLAYER );
}
@@ -246,16 +246,16 @@ void doMouseButton(WGame &game) {
game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
if (CurObj) { // se ho cliccato su un oggetto valido
if (TheMessage->event == ME_MLEFT) // se ho cliccato con sinistro
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTOEXAMINE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, bFirstPerson, &CurObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTOEXAMINE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, bFirstPerson, &CurObj, nullptr, nullptr);
else if (TheMessage->event == ME_MRIGHT) { // se ho cliccato con destro
if ((init.Obj[CurObj].flags & USEWITH) && !(bUseWith)) { // se ho cliccato su un oggetto usacon
Player->Walk.NumSteps = 0; // Simula un PlayerStop
- Event(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, bFirstPerson, &CurObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, bFirstPerson, &CurObj, nullptr, nullptr);
} else
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTOACTION, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, bFirstPerson, &CurObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTOACTION, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, bFirstPerson, &CurObj, nullptr, nullptr);
}
} else // se non ho cliccato su niente
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, bFirstPerson, nullptr, &NextPortalAnim, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, bFirstPerson, nullptr, &NextPortalAnim, nullptr);
}
void doMouseUpdate(WGame &game) {
@@ -303,8 +303,8 @@ void doMouseUpdate(WGame &game) {
else {
if (bClock33) {
if ((Comb33[0] == 7) && (Comb33[1] == 2) && (Comb33[2] == 9) && (Comb33[3] == 11) && IconInInv(init, i19FOGLIO1)) {
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
- Event(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_CAMERA, a336, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_CAMERA, a336, 0, 0, nullptr, nullptr, nullptr);
if (!(init.Obj[o33LANCETTAHSX].flags & EXTRA2)) {
IncCurTime(game, 15);
diff --git a/engines/watchmaker/classes/do_operate.cpp b/engines/watchmaker/classes/do_operate.cpp
index bf94454d8db..ceaa3ca9855 100644
--- a/engines/watchmaker/classes/do_operate.cpp
+++ b/engines/watchmaker/classes/do_operate.cpp
@@ -240,7 +240,7 @@ void doOperate(WGame &game, int32 obj) {
case oXT14BASAMENTO:
if ((WhichAnimChar(init, ocGIARDINIERE) == aGIA141) || (WhichAnimChar(init, ocGIARDINIERE) == aGIA142))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dGIARDINIERE_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dGIARDINIERE_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -251,7 +251,7 @@ void doOperate(WGame &game, int32 obj) {
case o13MOBILE:
case o13CREDENZA:
if (WhichRoomChar(init, ocCUSTODE) == r13)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUSTODE_INTERRUPT3, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUSTODE_INTERRUPT3, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -260,7 +260,7 @@ void doOperate(WGame &game, int32 obj) {
case o13SCALPELLO:
if (WhichRoomChar(init, ocCUSTODE) == r13)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUSTODE_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUSTODE_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -341,16 +341,16 @@ void doOperate(WGame &game, int32 obj) {
Comb19[2] = obj;
if ((Comb19[1] == o19T22) && (Comb19[2] == o19T26) && !(init.Obj[o37BACHECA].flags & EXTRA)) {
Comb19[0] = Comb19[1] = Comb19[2] = 0;
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
- Event(EventClass::MC_STRING, ME_PLAYERSPEAK, MP_WAIT_CAMERA, init.Obj[o19SCACCHIERA].text[0], 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_STRING, ME_PLAYERSPEAK, MP_WAIT_CAMERA, init.Obj[o19SCACCHIERA].text[0], 0, 0, nullptr, nullptr, nullptr);
break;
}
if ((Comb19[0] == o19T22) && (Comb19[1] == o19T26) && (Comb19[2] == o19T40)) {
init.Obj[o19SCACCHIERA].anim[CurPlayer] = init.Obj[o19SCACCHIERA].anim[CurPlayer ^ 1] = a193;
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
CurObj = o19SCACCHIERA;
- Event(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_WAIT_CAMERA, 0, 0, bFirstPerson, &CurObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_WAIT_CAMERA, 0, 0, bFirstPerson, &CurObj, nullptr, nullptr);
}
break;
@@ -417,21 +417,24 @@ void doOperate(WGame &game, int32 obj) {
case o23CTASTO1:
bNoFirstPersonSwitch = FALSE;
ChangeRoom(game, "r21-a.t3d", 46, a2111);
- if (obj == o23ATASTO1) Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
+ if (obj == o23ATASTO1)
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
break;
case o23ATASTO2:
case o23BTASTO2:
case o23CTASTO2:
bNoFirstPersonSwitch = FALSE;
ChangeRoom(game, "r26-b.t3d", 46, a268);
- if (obj == o23BTASTO2) Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
+ if (obj == o23BTASTO2)
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
break;
case o23ATASTO3:
case o23BTASTO3:
case o23CTASTO3:
bNoFirstPersonSwitch = FALSE;
ChangeRoom(game, "r2c.t3d", 46, a2C10);
- if (obj == o23CTASTO3) Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
+ if (obj == o23CTASTO3)
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
break;
case o25TASTOPIUFORNO:
if (init.Obj[o25TASTOOFFFORNO].flags & ON) {
@@ -489,7 +492,7 @@ void doOperate(WGame &game, int32 obj) {
case o25FORNOCH:
case o25FORNOAP:
if (WhichRoomChar(init, ocCUOCO) == r25)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUOCO_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUOCO_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -498,7 +501,7 @@ void doOperate(WGame &game, int32 obj) {
case o25MOBILETTO:
if (WhichRoomChar(init, ocCUOCO) == r25)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUOCO_INTERRUPT2, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dCUOCO_INTERRUPT2, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -507,7 +510,7 @@ void doOperate(WGame &game, int32 obj) {
case o25SCAFFALEMAGAZZINO:
if (WhichRoomChar(init, ocDOMESTICA) == r25)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dDOMESTICA_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dDOMESTICA_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -519,7 +522,7 @@ void doOperate(WGame &game, int32 obj) {
case o28ANTEDXCH:
case o28ANTESXCH:
if (WhichRoomChar(init, ocDOMESTICA) == r28)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dDOMESTICA_INTERRUPT2, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dDOMESTICA_INTERRUPT2, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -528,10 +531,10 @@ void doOperate(WGame &game, int32 obj) {
case o29COMPUTER:
if (WhichRoomChar(init, ocSUPERVISORE) == r29)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dSUPERVISORE_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dSUPERVISORE_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
else {
if (init.Obj[obj].flags & EXTRA)
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tSCANNER, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tSCANNER, nullptr, nullptr, nullptr);
else
sent = TRUE;
}
@@ -541,7 +544,7 @@ void doOperate(WGame &game, int32 obj) {
case o29PORTAFOTOCONJUDE:
case o29SCANNER:
if (WhichRoomChar(init, ocSUPERVISORE) == r29)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dSUPERVISORE_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dSUPERVISORE_INTERRUPT1, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -550,7 +553,7 @@ void doOperate(WGame &game, int32 obj) {
case o29PORTA:
if (WhichRoomChar(init, ocSUPERVISORE) == r29)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dSUPERVISORE_INTERRUPT3, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dSUPERVISORE_INTERRUPT3, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -597,9 +600,9 @@ void doOperate(WGame &game, int32 obj) {
case o2DE:
if ((Comb2D[0] == o2D1) && (Comb2D[1] == o2D2) && (Comb2D[2] == o2D4) && (Comb2D[3] == o2D8) && (Comb2D[4] == o2D0)) {
init.Obj[o2DTASTIERINO].anim[CurPlayer] = init.Obj[o2DTASTIERINO].anim[CurPlayer ^ 1] = a2D11;
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
CurObj = o2DTASTIERINO;
- Event(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_WAIT_CAMERA, 0, 0, bFirstPerson, &CurObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_WAIT_CAMERA, 0, 0, bFirstPerson, &CurObj, nullptr, nullptr);
StartSound(game, w2D10);
} else
StartSound(game, w2D9B);
@@ -642,7 +645,8 @@ void doOperate(WGame &game, int32 obj) {
case o2OETASTOU:
bNoFirstPersonSwitch = FALSE;
ChangeRoom(game, "r2h.t3d", 43, a2H7);
- if (obj == o2OATASTOU) Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
+ if (obj == o2OATASTOU)
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
break;
case o2OATASTO0:
case o2OBTASTO0:
@@ -651,7 +655,8 @@ void doOperate(WGame &game, int32 obj) {
case o2OETASTO0:
bNoFirstPersonSwitch = FALSE;
ChangeRoom(game, "r2m-a.t3d", 43, a2M1);
- if (obj == o2OBTASTO0) Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
+ if (obj == o2OBTASTO0)
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
break;
case o2OATASTO1:
case o2OBTASTO1:
@@ -660,7 +665,8 @@ void doOperate(WGame &game, int32 obj) {
case o2OETASTO1:
bNoFirstPersonSwitch = FALSE;
ChangeRoom(game, "r2b-a.t3d", 43, a2B14);
- if (obj == o2OCTASTO1) Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
+ if (obj == o2OCTASTO1)
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
break;
case o2OATASTO2:
case o2OBTASTO2:
@@ -669,7 +675,8 @@ void doOperate(WGame &game, int32 obj) {
case o2OETASTO2:
bNoFirstPersonSwitch = FALSE;
ChangeRoom(game, "r2p.t3d", 43, a2P6);
- if (obj == o2ODTASTO2) Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
+ if (obj == o2ODTASTO2)
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
break;
case o2OATASTO3:
case o2OBTASTO3:
@@ -678,12 +685,13 @@ void doOperate(WGame &game, int32 obj) {
case o2OETASTO3:
bNoFirstPersonSwitch = FALSE;
ChangeRoom(game, "r2c.t3d", 43, a2C9);
- if (obj == o2OETASTO3) Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
+ if (obj == o2OETASTO3)
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, TRUE, nullptr, nullptr, nullptr);
break;
case o2Pp2D:
if ((init.Obj[o24BOCCIOLO].flags & EXTRA) && !(init.Dialog[dR2P1].flags & DIALOG_DONE))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR2P1, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR2P1, 0, 0, nullptr, nullptr, nullptr);
else if (init.Obj[obj].anim[CurPlayer])
sa = init.Obj[obj].anim[CurPlayer];
else
@@ -732,9 +740,9 @@ void doOperate(WGame &game, int32 obj) {
case o2QE:
if (IconInInv(init, i29FOTOJUDE1) && (Comb2Q[1] == o2Q9) && (Comb2Q[2] == o2Q7) && (Comb2Q[3] == o2Q9) && (Comb2Q[4] == o2Q5)) {
init.Obj[o2QTASTIERINO].anim[CurPlayer] = init.Obj[o2QTASTIERINO].anim[CurPlayer ^ 1] = a2Q11;
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
CurObj = o2QTASTIERINO;
- Event(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_WAIT_CAMERA, 0, 0, bFirstPerson, &CurObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_WAIT_CAMERA, 0, 0, bFirstPerson, &CurObj, nullptr, nullptr);
StartSound(game, w2Q10);
} else
StartSound(game, w2Q9B);
@@ -759,8 +767,8 @@ void doOperate(WGame &game, int32 obj) {
if (++Comb31[obj - o31LEVETTA1] > 7) Comb31[obj - o31LEVETTA1] = 0;
UpdateSpecial(game, r31);
if ((Comb31[0] == 1) && (Comb31[1] == 6) && (Comb31[2] == 3) && (Comb31[3] == 5) && (Comb31[4] == 7)) {
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
- Event(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_CAMERA, a319, 0, bFirstPerson, &CurObj, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_CAMERA, a319, 0, bFirstPerson, &CurObj, nullptr, nullptr);
}
} else
sa = a3110;
@@ -770,8 +778,10 @@ void doOperate(WGame &game, int32 obj) {
if (!t3dCurRoom->name.equalsIgnoreCase(PlayerStand[CurPlayer ^ 1].roomName))
sa = a323;
else {
- if (CurPlayer == DARRELL) Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR321_DAR, 0, 0, nullptr, nullptr, nullptr);
- if (CurPlayer == VICTORIA) Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR321_VIC, 0, 0, nullptr, nullptr, nullptr);
+ if (CurPlayer == DARRELL)
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR321_DAR, 0, 0, nullptr, nullptr, nullptr);
+ if (CurPlayer == VICTORIA)
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR321_VIC, 0, 0, nullptr, nullptr, nullptr);
sa = aNULL;
sent = FALSE;
}
@@ -861,14 +871,14 @@ void doOperate(WGame &game, int32 obj) {
if ((Comb42[0] == 0) && (Comb42[1] == 1) && (Comb42[2] == 0) && (Comb42[3] == 1) &&
(Comb42[4] == 1) && (Comb42[5] == 1) && (Comb42[6] == 1) && (Comb42[7] == 1) &&
(Comb42[8] == 0) && (Comb42[9] == 0) && (Comb42[10] == 1) && (Comb42[11] == 0) && IconInInv(init, i41OGGETTO)) {
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
if (!(init.Dialog[dR421_fine].flags & DIALOG_DONE)) {
if (CurPlayer == DARRELL)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR421_DAR, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR421_DAR, 0, 0, nullptr, nullptr, nullptr);
if (CurPlayer == VICTORIA)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR421_VIC, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR421_VIC, 0, 0, nullptr, nullptr, nullptr);
} else
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR42_porta, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR42_porta, 0, 0, nullptr, nullptr, nullptr);
}
break;
case o42TASTO01GIU:
@@ -892,22 +902,22 @@ void doOperate(WGame &game, int32 obj) {
if ((Comb42[0] == 0) && (Comb42[1] == 1) && (Comb42[2] == 0) && (Comb42[3] == 1) &&
(Comb42[4] == 1) && (Comb42[5] == 1) && (Comb42[6] == 1) && (Comb42[7] == 1) &&
(Comb42[8] == 0) && (Comb42[9] == 0) && (Comb42[10] == 1) && (Comb42[11] == 0) && IconInInv(init, i41OGGETTO)) {
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
if (!(init.Dialog[dR421_fine].flags & DIALOG_DONE)) {
if (CurPlayer == DARRELL)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR421_DAR, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR421_DAR, 0, 0, nullptr, nullptr, nullptr);
if (CurPlayer == VICTORIA)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR421_VIC, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR421_VIC, 0, 0, nullptr, nullptr, nullptr);
} else
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR42_porta, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_CAMERA, dR42_porta, 0, 0, nullptr, nullptr, nullptr);
}
break;
case o48KRENNSVENUTO:
if (!(init.Dialog[dR48_chiavi].flags & DIALOG_DONE))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR48_chiavi, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR48_chiavi, 0, 0, nullptr, nullptr, nullptr);
else
- Event(EventClass::MC_STRING, ME_PLAYERSPEAK, MP_DEFAULT, init.Obj[o48KRENNSVENUTO].examine[VICTORIA], 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_STRING, ME_PLAYERSPEAK, MP_DEFAULT, init.Obj[o48KRENNSVENUTO].examine[VICTORIA], 0, 0, nullptr, nullptr, nullptr);
break;
case o44LEVAORE:
@@ -929,7 +939,7 @@ void doOperate(WGame &game, int32 obj) {
UpdateSpecial(game, r45);
if ((Comb45[0] == 8) && (Comb45[1] == 1) && (Comb45[2] == 10) && (Comb45[3] == 5) && (Comb45[4] == 3)) {
StartSound(game, wB451);
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
SetMeshMaterialMovieFrame(LinkMeshToStr(init, "o45-ingranaggiBEK02"), 0, 1);
SetMeshMaterialMovieFrame(LinkMeshToStr(init, "o45-ingranaggiBEK03"), 0, 1);
SetMeshMaterialMovieFrame(LinkMeshToStr(init, "o45-ingranaggiBEK04"), 0, 1);
@@ -961,7 +971,7 @@ void doOperate(WGame &game, int32 obj) {
}
if ((Comb45[0] == 0) && (Comb45[1] == 0) && (Comb45[2] == 0) && (Comb45[3] == 0) && (Comb45[4] == 0)) {
StartSound(game, wB451);
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
SetMeshMaterialMovieFrame(LinkMeshToStr(init, "o45-ingranaggiBEK02"), 0, 0xFFFF);
SetMeshMaterialMovieFrame(LinkMeshToStr(init, "o45-ingranaggiBEK03"), 0, 0xFFFF);
SetMeshMaterialMovieFrame(LinkMeshToStr(init, "o45-ingranaggiBEK04"), 0, 0xFFFF);
@@ -989,7 +999,7 @@ void doOperate(WGame &game, int32 obj) {
game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_PLAYERTIMER);
if (init.Dialog[dR471].flags & DIALOG_DONE)
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR451, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR451, 0, 0, nullptr, nullptr, nullptr);
}
break;
diff --git a/engines/watchmaker/classes/do_player.cpp b/engines/watchmaker/classes/do_player.cpp
index 83d2e277fc9..73eac8ca97f 100644
--- a/engines/watchmaker/classes/do_player.cpp
+++ b/engines/watchmaker/classes/do_player.cpp
@@ -138,9 +138,9 @@ void doPlayer(WGame &game) {
AddWaitingMsgs(MP_WAIT_ACT);
if (TheMessage->event == ME_PLAYERGOTOEXAMINE)
- Event(EventClass::MC_ACTION, ME_MOUSEEXAMINE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &TheMessage->lparam[0], nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ACTION, ME_MOUSEEXAMINE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &TheMessage->lparam[0], nullptr, nullptr);
else if (TheMessage->event == ME_PLAYERGOTOACTION)
- Event(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &TheMessage->lparam[0], nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ACTION, ME_MOUSEOPERATE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &TheMessage->lparam[0], nullptr, nullptr);
else if ((TheMessage->event == ME_PLAYERGOTO) && (TheMessage->lparam[1]))
StartAnim(game, TheMessage->lparam[1]);
@@ -213,9 +213,9 @@ void ProcessCharacters(WGame &game) {
// controllo da che parte far partire l'RTV
if ((dist >= 0.0f) && (dist < 30.f))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dRUN_R1a1_RIGHT, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dRUN_R1a1_RIGHT, 0, 0, nullptr, nullptr, nullptr);
else
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dRUN_R1a1_CENTER, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dRUN_R1a1_CENTER, 0, 0, nullptr, nullptr, nullptr);
}
}
}
@@ -225,12 +225,12 @@ void ProcessCharacters(WGame &game) {
if (Player->Mesh->Trasl.x < CacciatoreXleft) {
bCacciatore = FALSE;
CharStop(ocCURPLAYER);
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR0014_left, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR0014_left, 0, 0, nullptr, nullptr, nullptr);
}
if ((Player->Mesh->Trasl.x > CacciatoreXright) && (Player->Mesh->Trasl.z > CacciatoreZright)) {
bCacciatore = FALSE;
CharStop(ocCURPLAYER);
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR0014_right, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR0014_right, 0, 0, nullptr, nullptr, nullptr);
}
}
@@ -243,7 +243,7 @@ void ProcessCharacters(WGame &game) {
&& (!bDialogActive)) {
if (Player->Mesh->Trasl.x > r47CoordX) {
CharStop(ocCURPLAYER);
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR482, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR482, 0, 0, nullptr, nullptr, nullptr);
}
}
@@ -277,7 +277,7 @@ void ProcessCharacters(WGame &game) {
if (beccato) {
// DebugLogFile("BECCATO");
CharStop(ocCURPLAYER);
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR48KRENNSPARA, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR48KRENNSPARA, 0, 0, nullptr, nullptr, nullptr);
}
}
@@ -440,7 +440,7 @@ void ChangePlayer(WGame &game, uint8 oc) {
// Inizia il Fade
// Event( EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND/3, 0, EFFECT_FADIN, NULL, NULL, NULL );
- Event(EventClass::MC_CAMERA, ME_CAMERAPLAYER, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERAPLAYER, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
}
/* -----------------30/10/00 18.26-------------------
diff --git a/engines/watchmaker/classes/do_string.cpp b/engines/watchmaker/classes/do_string.cpp
index 9a9b0fd71ef..2963dfceee9 100644
--- a/engines/watchmaker/classes/do_string.cpp
+++ b/engines/watchmaker/classes/do_string.cpp
@@ -153,9 +153,9 @@ bool PlayerSpeak(WGame &game, int32 n) {
bSkipTalk = FALSE;
if (speechn)
- Event(EventClass::MC_STRING, ME_PLAYERCONTINUESPEAK_WAITWAVE, MP_WAIT_RETRACE, 0, 0, 0, &speechn, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_STRING, ME_PLAYERCONTINUESPEAK_WAITWAVE, MP_WAIT_RETRACE, 0, 0, 0, &speechn, nullptr, nullptr);
else
- Event(EventClass::MC_STRING, ME_PLAYERCONTINUESPEAK, MP_WAIT_RETRACE, 0, 0, 0, &EndSpeakTime, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_STRING, ME_PLAYERCONTINUESPEAK, MP_WAIT_RETRACE, 0, 0, 0, &EndSpeakTime, nullptr, nullptr);
return TRUE;
}
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index 2c6c87f6395..73fd3c28cb5 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -659,7 +659,7 @@ void InitMain(WGame &game) {
// InitMessageSystem();
ProcessTime(game);
- Event(EventClass::MC_SYSTEM, ME_START, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_START, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
if (!rClearBuffers(rCLEARBACKBUFFER | rCLEARZBUFFER)) // Cancella buffers
warning("Unable to clear backbuffers");
@@ -1019,7 +1019,7 @@ void doSystem(WGame &game) {
if ((int32)TheTime > TheMessage->lparam[0]) {
StopObjAnim(game, TheMessage->wparam1);
CharStop(TheMessage->wparam1);
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, (int16)TheMessage->wparam2, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, (int16)TheMessage->wparam2, 0, 0, nullptr, nullptr, nullptr);
//DebugString("Idle %d at %d",TheMessage->wparam1,TheMessage->lparam[0]);
} else {
TheMessage->flags |= MP_WAIT_RETRACE;
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index 7bab66adbf5..dda73996bea 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -126,16 +126,16 @@ void ProcessATFDO(WGame &game, int32 in) {
switch (in) {
case fFADIN:
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, 0, EFFECT_FADIN, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, 0, EFFECT_FADIN, nullptr, nullptr, nullptr);
break;
case fFADOUT:
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, 0, EFFECT_FADOUT, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, 0, EFFECT_FADOUT, nullptr, nullptr, nullptr);
break;
case fFADOUTWAIT2:
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, FRAME_PER_SECOND * 2, EFFECT_FADOUT, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, FRAME_PER_SECOND * 2, EFFECT_FADOUT, nullptr, nullptr, nullptr);
break;
case fFADOUTWAIT5:
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, FRAME_PER_SECOND * 5, EFFECT_FADOUT, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND, FRAME_PER_SECOND * 5, EFFECT_FADOUT, nullptr, nullptr, nullptr);
break;
case fPUSH_ROOM:
strcpy(PushedRoomName, t3dCurRoom->name.c_str());
@@ -149,7 +149,7 @@ void ProcessATFDO(WGame &game, int32 in) {
case fPOP_ROOM_dR015:
ChangeRoom(game, PushedRoomName, PushedRoomPos, 0);
Character[CurPlayer + ocDARRELL]->Flags &= ~T3D_CHARACTER_HIDE;
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR015, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR015, 0, 0, nullptr, nullptr, nullptr);
break;
case fSET_MOGLIE_GYM:
i = ocMOGLIESUPERVISORE;
@@ -219,7 +219,7 @@ void ProcessATFDO(WGame &game, int32 in) {
break;
case fUSCITAPOZZO:
if (IconInInv(init, i1dAUDIOCASSETTA) || IconInInv(init, i28WALKMANNASTRO) || IconInInv(init, i28WALKMANOK))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR1a4, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR1a4, 0, 0, NULL, NULL, NULL);
break;
case f22STOPWAVES:
if ((m = LinkMeshToStr(init, "p22-water01"))) ChangeMeshFlags(m, -1, T3D_MESH_WAVESTEXTURE);
@@ -240,14 +240,14 @@ void ProcessATFDO(WGame &game, int32 in) {
in = aTO1PERSON;
bLockCamera = true;
CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\055\000", 0);
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, &in, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, &in, nullptr);
bNoFirstPersonSwitch = true;
bNoPlayerSwitch = true;
break;
case f23ESCELIFT:
bLockCamera = false;
CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\057\000", 0);
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
bNoFirstPersonSwitch = false;
bNoPlayerSwitch = false;
break;
@@ -276,26 +276,26 @@ void ProcessATFDO(WGame &game, int32 in) {
in = aTO1PERSON;
bLockCamera = true;
CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\051\052\000", 0);
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, &in, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, &in, nullptr);
bNoFirstPersonSwitch = true;
bNoPlayerSwitch = true;
break;
case f2OESCELIFT:
bLockCamera = false;
CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\054\000", 0);
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
bNoFirstPersonSwitch = false;
bNoPlayerSwitch = false;
break;
case f2QENTRALAB:
CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\051\052\000", 0);
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
- Event(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_PORTAL, a2Q14, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_PORTAL, a2Q14, 0, 0, nullptr, nullptr, nullptr);
break;
case f2QESCELAB:
CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\051\052\000", 0);
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
- Event(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_PORTAL, a2Q14, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_PORTAL, a2Q14, 0, 0, nullptr, nullptr, nullptr);
break;
case f36MSD:
@@ -360,7 +360,7 @@ void ProcessATFDO(WGame &game, int32 in) {
#if 0
StopPlayingGame(game);
#endif
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tMAINMENU, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tMAINMENU, nullptr, nullptr, nullptr);
}
break;
case f35LIGHTS: {
@@ -411,8 +411,8 @@ void ProcessATFDO(WGame &game, int32 in) {
case f41WALK:
CheckCharacterWithoutBounds(game, ocCURPLAYER, (const uint8 *)"\064\000", 0);
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_ACT, dR411, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_WAIT_ANIM, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_ACT, dR411, 0, 0, nullptr, nullptr, nullptr);
break;
break;
@@ -447,7 +447,7 @@ void ProcessATFDO(WGame &game, int32 in) {
case f45STARTTIMER:
i = TheTime + 1000 * 20;
- Event(EventClass::MC_SYSTEM, ME_PLAYERTIMER, MP_WAIT_RETRACE, (int16)(CurPlayer + ocDARRELL), (int16)dR452, 0, &i, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_PLAYERTIMER, MP_WAIT_RETRACE, (int16)(CurPlayer + ocDARRELL), (int16)dR452, 0, &i, nullptr, nullptr);
// Event( EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL ); //preferisco farlo rimanere in terza (ndFox)
break;
case f45STOPTIMER:
@@ -456,7 +456,7 @@ void ProcessATFDO(WGame &game, int32 in) {
case f41STARTTIMER:
i = TheTime + 1000 * 20;
- Event(EventClass::MC_SYSTEM, ME_PLAYERTIMER, MP_WAIT_RETRACE, (int16)(CurPlayer + ocDARRELL), (int16)dR0010, 0, &i, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_PLAYERTIMER, MP_WAIT_RETRACE, (int16)(CurPlayer + ocDARRELL), (int16)dR0010, 0, &i, nullptr, nullptr);
break;
case f41STOPTIMER:
game._messageSystem.removeEvent(EventClass::MC_SYSTEM, ME_PLAYERTIMER);
@@ -475,7 +475,7 @@ void ProcessATFDO(WGame &game, int32 in) {
case f49CHECK:
if ((init.Obj[o49AMPOLLAAZZURRO].anim[CurPlayer] == aNULL) && (init.Obj[o49AMPOLLAVERDE].anim[CurPlayer] == aNULL) && (init.Obj[o49AMPOLLAGIALLO].anim[CurPlayer] == aNULL))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR491, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR491, 0, 0, nullptr, nullptr, nullptr);
break;
case f4ASETBND44:
@@ -556,22 +556,22 @@ void ProcessATFDO(WGame &game, int32 in) {
if (!(init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM1].flags & PDA_ON)) {
init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM1].flags |= (PDA_ON | PDA_UPDATE);
init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM1].time = t3dCurTime;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
}
if (!(init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM2].flags & PDA_ON)) {
init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM2].flags |= (PDA_ON | PDA_UPDATE);
init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM2].time = t3dCurTime;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
}
if (!(init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM3].flags & PDA_ON)) {
init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM3].flags |= (PDA_ON | PDA_UPDATE);
init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM3].time = t3dCurTime;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
}
if (!(init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM4].flags & PDA_ON)) {
init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM4].flags |= (PDA_ON | PDA_UPDATE);
init.PDALog[lPDA3_MENU15_CONCLUSIONS_ITEM4].time = t3dCurTime;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
}
}
break;
@@ -814,10 +814,10 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
UpdateObjMesh(init, in);
break;
case ATFD_OFF:
- Event(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)in, mQUIT, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)in, mQUIT, 0, nullptr, nullptr, nullptr);
break;
case ATFD_ON:
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_ANIM, (int16)in, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_ANIM, (int16)in, 0, 0, nullptr, nullptr, nullptr);
break;
case ATFI_OFF:
KillIcon(init, (uint8)in);
@@ -1130,7 +1130,7 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
break;
case ATF_START_T2D:
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, (uint8)in, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, (uint8)in, nullptr, nullptr, nullptr);
break;
case ATFO_CANIMD:
@@ -1270,7 +1270,7 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
init.InvObj[obj].action[CurPlayer] = init.InvObj[obj].action[CurPlayer ^ 1] = (in >= TEXT1) ? init.InvObj[obj].text[in - TEXT1] : in;
break;
case ATFD_ON_DLG:
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, (int16)in, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, (int16)in, 0, 0, nullptr, nullptr, nullptr);
break;
case ATFS_PSX_STAIRS:
if (h->sub[in - 1].ptr) StartStepSound(game, &h->sub[in - 1].ptr->Trasl, SOUND_PSX | SOUND_STAIRS);
@@ -1295,7 +1295,7 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
if (!(init.PDALog[in].flags & PDA_ON)) {
init.PDALog[in].flags |= (PDA_ON | PDA_UPDATE);
init.PDALog[in].time = t3dCurTime;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
}
break;
case ATFC_ENABLE_SHADOWS:
@@ -1305,7 +1305,7 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
if (Character[in]) Character[in]->Flags &= ~T3D_CHARACTER_CASTREALTIMESHADOWS;
break;
case ATFD_ON_WAITTEXT:
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_LINK, (int16)in, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_WAIT_LINK, (int16)in, 0, 0, nullptr, nullptr, nullptr);
break;
case ATF_SET_NOSKIP:
bNotSkippableSent = in;
@@ -1389,19 +1389,19 @@ void StartAnim(WGame &game, int32 an) {
if ((an == aTO1PERSON) && (bFirstPerson == 0) && !(InvStatus & INV_ON)) {
if (bMovingCamera)
- Event(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_WAIT_CAMERA, 0, 0, init.Obj[CurObj].pos, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_WAIT_CAMERA, 0, 0, init.Obj[CurObj].pos, nullptr, nullptr, nullptr);
else
- Event(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, init.Obj[CurObj].pos, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, init.Obj[CurObj].pos, nullptr, nullptr, nullptr);
return;
} else if ((an == aTO3PERSON) && (bFirstPerson) && (!bMovingCamera) && !(InvStatus & INV_ON)) {
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_WAIT_CAMERA, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_WAIT_CAMERA, 0, 0, 0, nullptr, nullptr, nullptr);
return;
} else if (bFirstPerson && ((init.Anim[an].obj < ocDARRELL) || (init.Anim[an].obj > oCAMERAMAX))) {
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
- Event(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_CAMERA, (int16)an, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_CAMERA, (int16)an, 0, 0, nullptr, nullptr, nullptr);
return ;
} else if ((bMovingCamera) && (!bDialogActive) && ((init.Anim[an].obj < ocDARRELL) || (init.Anim[an].obj > oCAMERAMAX))) {
- Event(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_CAMERA, (int16)an, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_ANIM, ME_STARTANIM, MP_WAIT_CAMERA, (int16)an, 0, 0, nullptr, nullptr, nullptr);
return ;
}
@@ -1588,7 +1588,7 @@ void StopAnim(WGame &game, int32 an) {
h->sub[a].ptr->BlendPercent = 255;
t = TheTime + PLAYER_IDLE_TIME;
- Event(EventClass::MC_PLAYER, ME_PLAYERIDLE, MP_WAIT_RETRACE, (int16)(CurPlayer + ocDARRELL), 0, 0, &t, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERIDLE, MP_WAIT_RETRACE, (int16)(CurPlayer + ocDARRELL), 0, 0, &t, nullptr, nullptr);
bPlayerInAnim = false;
}
if (!(h->sub[a].flags & ANIM_BLOCK) && !(init.Anim[an].flags & ANIM_BLOCK) && !(init.Anim[an].flags & ANIM_BLOCK_PLAYER))
diff --git a/engines/watchmaker/ll/ll_mouse.cpp b/engines/watchmaker/ll/ll_mouse.cpp
index e297dc3afc8..2683e79b077 100644
--- a/engines/watchmaker/ll/ll_mouse.cpp
+++ b/engines/watchmaker/ll/ll_mouse.cpp
@@ -90,7 +90,7 @@ void ProcessMouse(WGame &game) {
mHide = 0;
mCounter = 0;
game._messageSystem.removeEvent(EventClass::MC_MOUSE, ME_MOUSEUPDATE);
- Event(EventClass::MC_MOUSE, ME_MOUSEUPDATE, MP_DEFAULT, (int16)mPosx, (int16)mPosy, 0, &mMoveX, &mMoveY, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_MOUSE, ME_MOUSEUPDATE, MP_DEFAULT, (int16)mPosx, (int16)mPosy, 0, &mMoveX, &mMoveY, NULL);
}
mMoveX = mMoveY = 0;
@@ -153,7 +153,7 @@ void HandleMouseChanges() {
if (bLPressed != bLPressedPrev) {
// se ha rilasciato e non ha mosso il mouse
if ((!bLPressed) && (!bSkipped) && ((mMove < 10) || (!(InvStatus & INV_MODE2) && !bFirstPerson && !bT2DActive))) {
- Event(EventClass::MC_MOUSE, ME_MLEFT, MP_DEFAULT, (int16)mPosx, (int16)mPosy, bRPressed, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_MOUSE, ME_MLEFT, MP_DEFAULT, (int16)mPosx, (int16)mPosy, bRPressed, NULL, NULL, NULL);
bSkipped = FALSE;
} else if (bLPressed && (mMove >= 10) && (InvStatus & INV_MODE2) && (bSomeOneSpeak)) {
bSkipTalk = TRUE;
@@ -165,7 +165,7 @@ void HandleMouseChanges() {
// Button 1 pressed or released
if (bRPressed != bRPressedPrev) {
if ((!bRPressed) && ((mMove < 10) || (!bFirstPerson && !bT2DActive)))
- Event(EventClass::MC_MOUSE, ME_MRIGHT, MP_DEFAULT, (int16)mPosx, (int16)mPosy, bLPressed, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_MOUSE, ME_MRIGHT, MP_DEFAULT, (int16)mPosx, (int16)mPosy, bLPressed, NULL, NULL, NULL);
mMove = 0;
}
bLPressedPrev = bLPressed;
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 7d25c911e59..a82cddbc411 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -306,7 +306,7 @@ void UpdateRoomInfo(WGame &game) {
game._messageSystem.removeEvent_bparam(EventClass::MC_SYSTEM, ME_STARTEFFECT, EFFECT_ROOMINFO);
game._messageSystem.removeEvent_bparam(EventClass::MC_SYSTEM, ME_CONTINUEEFFECT, EFFECT_ROOMINFO);
game._messageSystem.removeEvent_bparam(EventClass::MC_SYSTEM, ME_STOPEFFECT, EFFECT_ROOMINFO);
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_ROOMINFO, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_ROOMINFO, nullptr, nullptr, nullptr);
}
}
@@ -345,13 +345,13 @@ void UpdateRoomVisibility(WGame &game) {
if (!(LoaderFlags & T3D_DEBUGMODE)) {
// Prima volta che entra nella r46
if ((cr == r46) && !(init.Room[cr].flags & ROOM_VISITED))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR212, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR212, 0, 0, NULL, NULL, NULL);
// Prima volta che entra nella r47
if ((cr == r47) && !(init.Room[cr].flags & ROOM_VISITED))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR471, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR471, 0, 0, NULL, NULL, NULL);
// Prima volta che entra nella r48
if ((cr == r48) && !(init.Room[cr].flags & ROOM_VISITED))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR481, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR481, 0, 0, NULL, NULL, NULL);
}
#if 0
// Se ha cambiato stanza cambia anche l'environment
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index b3a2d4d0433..5b640b40399 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -114,7 +114,7 @@ int WMakerMain() {
return 1;
}
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dRLOGHI, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dRLOGHI, 0, 0, nullptr, nullptr, nullptr);
}
#if 0
ShowWindow(hWnd, SW_SHOWNORMAL);
diff --git a/engines/watchmaker/schedule.cpp b/engines/watchmaker/schedule.cpp
index 4d7db25dad2..69f46fb43fa 100644
--- a/engines/watchmaker/schedule.cpp
+++ b/engines/watchmaker/schedule.cpp
@@ -39,9 +39,7 @@
namespace Watchmaker {
-// locals
#define MAXWAITINGMSGS 30
-int maxmsg;
message WaitingMsg[MAXWAITINGMSGS];
/* -----------------18/03/98 16.41-------------------
@@ -54,9 +52,9 @@ void AddWaitingMsgs(uint16 flags) {
for (a = 0; a < MAXWAITINGMSGS; a++)
if (WaitingMsg[a].classe != EventClass::MC_IDLE && (WaitingMsg[a].flags < MP_WAITA)) {
- Event(WaitingMsg[a].classe, WaitingMsg[a].event, WaitingMsg[a].flags,
- WaitingMsg[a].wparam1, WaitingMsg[a].wparam2,
- WaitingMsg[a].bparam, &WaitingMsg[a].lparam[0], &WaitingMsg[a].lparam[1], &WaitingMsg[a].lparam[2]);
+ _vm->_messageSystem.doEvent(WaitingMsg[a].classe, WaitingMsg[a].event, WaitingMsg[a].flags,
+ WaitingMsg[a].wparam1, WaitingMsg[a].wparam2,
+ WaitingMsg[a].bparam, &WaitingMsg[a].lparam[0], &WaitingMsg[a].lparam[1], &WaitingMsg[a].lparam[2]);
memset(&WaitingMsg[a], 0, sizeof(WaitingMsg[a]));
}
}
@@ -123,10 +121,7 @@ const char *eventToString(EventClass classe) {
}
}
-/* -----------------08/02/99 10.10-------------------
- * Event
- * --------------------------------------------------*/
-void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wparam2,
+void MessageSystem::doEvent(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wparam2,
uint8 bparam, void *p0, void *p1, void *p2) {
pqueue *lq;
message *lm;
@@ -135,7 +130,7 @@ void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wp
if (classe == EventClass::MC_IDLE && !event)
return ;
- lq = &(_vm->_messageSystem.Game); // TODO: Instead refactor this to be doEvent, like in the trecision-engine.
+ lq = &Game;
// se deve andare in attesa
if (flags >= MP_WAITA) {
@@ -197,7 +192,8 @@ void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wp
if (lq->tail == MAX_MESSAGES) lq->tail = 0;
lq->len++;
- if (lq->len > maxmsg) maxmsg = lq->len;
+ if (lq->len > _maxmsg)
+ _maxmsg = lq->len;
}
/* -----------------08/02/99 10.11-------------------
@@ -223,7 +219,9 @@ void MessageSystem::scheduler() {
* --------------------------------------------------*/
void ProcessTheMessage(WGame &game) {
SUPEREVENT:
- //warning("Event: %s - %d", eventToString(TheMessage->classe), TheMessage->event);
+ if (TheMessage->classe != EventClass::MC_IDLE)
+ warning("doEvent: %s - %d", eventToString(TheMessage->classe), TheMessage->event);
+
switch (TheMessage->classe) {
case EventClass::MC_IDLE:
break;
@@ -282,8 +280,8 @@ void ReEvent() {
if (TheMessage == nullptr)
return ;
- Event(TheMessage->classe, TheMessage->event, TheMessage->flags, TheMessage->wparam1, TheMessage->wparam2,
- TheMessage->bparam, &TheMessage->lparam[0], &TheMessage->lparam[1], &TheMessage->lparam[2]);
+ _vm->_messageSystem.doEvent(TheMessage->classe, TheMessage->event, TheMessage->flags, TheMessage->wparam1, TheMessage->wparam2,
+ TheMessage->bparam, &TheMessage->lparam[0], &TheMessage->lparam[1], &TheMessage->lparam[2]);
}
/* -----------------08/02/99 10.11-------------------
diff --git a/engines/watchmaker/schedule.h b/engines/watchmaker/schedule.h
index d0be7e658d8..fc8c5280b7a 100644
--- a/engines/watchmaker/schedule.h
+++ b/engines/watchmaker/schedule.h
@@ -28,9 +28,6 @@
namespace Watchmaker {
-void Event(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wparam2,
- uint8 bparam, void *p0, void *p1, void *p2);
-
void ProcessTheMessage(WGame &game);
void ReEvent();
void DeleteWaitingMsgs(uint16 flags);
@@ -42,12 +39,14 @@ public:
void removeEvent(EventClass classe, uint8 event);
void removeEvent_bparam(EventClass classe, uint8 event, uint8 bparam);
void scheduler(); // TODO: Rename
+ void doEvent(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wparam2, uint8 bparam, void *p0, void *p1, void *p2);
message GameMessage[MAX_MESSAGES];
pqueue Game;
// message *TheMessage; // TODO: Replace the global variable with this
message idlemessage = {EventClass::MC_IDLE, 0, MP_DEFAULT};
uint8 SuperEventActivate;
private:
+ int _maxmsg = 0;
void initQueue(pqueue *lq);
};
diff --git a/engines/watchmaker/t2d/t2d.cpp b/engines/watchmaker/t2d/t2d.cpp
index 3f8127e0e3f..7031a26f0e0 100644
--- a/engines/watchmaker/t2d/t2d.cpp
+++ b/engines/watchmaker/t2d/t2d.cpp
@@ -490,7 +490,7 @@ bool ComputerSearch(WGame &game) {
Init &init = game.init;
Renderer &renderer = *game._renderer;
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, FALSE, nullptr, nullptr, nullptr);
//Elimina spazi finali
delSpaces(searchName);
@@ -508,7 +508,7 @@ bool ComputerSearch(WGame &game) {
SetPDALogItem(init, lPDA3_MENU11_CORONA_ITEM3);
} else if (searchName.equalsIgnoreCase("GREGOR") && searchSurName.equalsIgnoreCase("MOORE")) {
//Abilita finestra DOCLIST
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, TRUE, nullptr, nullptr, nullptr);
computerCurrentDocument = OldDoc;
strcpy(t2dWin[T2D_WIN_COMPUTER_DOCLIST].text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START].text, "Gregor Memorandum");
strcpy(t2dWin[T2D_WIN_COMPUTER_DOCLIST].text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START + 1].text, "Conv. Log: Confidence");
@@ -575,7 +575,7 @@ bool ComputerSearch(WGame &game) {
//Ricerca tramite caso
if (searchCaseName.equalsIgnoreCase("MERCURY") && searchYear.equalsIgnoreCase("1969")) {
//Abilita finestra DOCLIST
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, TRUE, nullptr, nullptr, nullptr);
computerCurrentDocument = OldDoc;
strcpy(t2dWin[T2D_WIN_COMPUTER_DOCLIST].text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START].text, "Mercury 1969-1");
strcpy(t2dWin[T2D_WIN_COMPUTER_DOCLIST].text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START + 1].text, "Mercury 1969-2");
@@ -599,7 +599,7 @@ bool ComputerSearch(WGame &game) {
computerCurrentDocument = T2D_BM_COMPUTER_DOCUMENT_MERCURY_1969_4;
} else if (searchCaseName.equalsIgnoreCase("CONFIDENCE") && searchYear.equalsIgnoreCase("1942")) {
//Abilita finestra DOCLIST
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, TRUE, nullptr, nullptr, nullptr);
computerCurrentDocument = OldDoc;
strcpy(t2dWin[T2D_WIN_COMPUTER_DOCLIST].text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START].text, "Confidence 1942-1");
strcpy(t2dWin[T2D_WIN_COMPUTER_DOCLIST].text[T2D_TEXT_COMPUTER_DOCLIST_LINES_START + 1].text, "Mercury 1942-2");
@@ -653,7 +653,7 @@ bool ComputerSearch(WGame &game) {
}
//Attiva la finestra Document
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT, 0, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT, 0, TRUE, nullptr, nullptr, nullptr);
return TRUE;
} else if (computerCurrentDocument != -2) {
//Search Error
@@ -661,7 +661,7 @@ bool ComputerSearch(WGame &game) {
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_OK].on = TRUE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_SearchError_Win_TGA].on = TRUE;
t2dWin[T2D_WIN_COMPUTER_ERROR].sy = 3;
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, TRUE, nullptr, nullptr, nullptr);
return FALSE;
}
@@ -951,7 +951,7 @@ void ActivateCursor(bool Active, char *String) {
CursorVisible = false;
CursorActive = Active;
- Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_DEFAULT, 0, 0, T2D_CURSOR, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DCONTINUE, MP_DEFAULT, 0, 0, T2D_CURSOR, nullptr, nullptr, nullptr);
}
@@ -1035,34 +1035,34 @@ void doT2DKeyboard(WGame &game) {
}
//Fa partire sequenza di connessione
StartSound(game, wMODEMFULL);
- Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_DEFAULT, 0, 0, T2D_COMPUTER_CONNECTING, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DCONTINUE, MP_DEFAULT, 0, 0, T2D_COMPUTER_CONNECTING, nullptr, nullptr, nullptr);
/*//Disattiva finestra Dialup
Event( EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, FALSE, NULL, NULL, NULL );
t2dWin[T2D_WIN_COMPUTER_BACKGROUND].bt[T2D_BT_COMPUTER_BACKGROUND_EMAIL].on=TRUE;
t2dWin[T2D_WIN_COMPUTER_BACKGROUND].bt[T2D_BT_COMPUTER_BACKGROUND_SEARCH].on=TRUE;*/
} else {
//Disattiva finestra DialUp
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, FALSE, nullptr, nullptr, nullptr);
//Dial Error
t2dWin[T2D_WIN_COMPUTER_ERROR].bm[T2D_BM_COMPUTER_DIALERROR_WIN].tnum &= ~T2D_BM_OFF;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_DIALUP].on = TRUE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_DIALQUIT].on = TRUE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_DialError_Win_TGA].on = TRUE;
t2dWin[T2D_WIN_COMPUTER_ERROR].sy = 2;
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, TRUE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAERRORE);
}
} else {
//Disattiva finestra DialUp
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, FALSE, nullptr, nullptr, nullptr);
//Com Error
t2dWin[T2D_WIN_COMPUTER_ERROR].bm[T2D_BM_COMPUTER_COMERROR_WIN].tnum &= ~T2D_BM_OFF;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_COMQUIT].on = TRUE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_ComError_Win_TGA].on = TRUE;
t2dWin[T2D_WIN_COMPUTER_ERROR].sy = 1;
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, TRUE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAERRORE);
}
@@ -1142,8 +1142,8 @@ void doT2DKeyboard(WGame &game) {
if (Key == VK_RETURN) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_SEARCH_SEARCH_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_SEARCH, T2D_BM_COMPUTER_SEARCH_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_SEARCH, T2D_BM_COMPUTER_SEARCH_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -1235,8 +1235,8 @@ void doT2DMouseMainMenu(WGame &game, t2dWINDOW *w) {
w->bm[T2D_BM_MAINMENU_PLAY_OFF].tnum |= T2D_BM_OFF;
} else {
//Inizia il gioco
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_NEWGAME, 0, tMAINMENU,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_NEWGAME, 0, tMAINMENU,
+ nullptr, nullptr, nullptr);
}
} else if (CurButton == T2D_BT_MAINMENU_LOAD) {
if (TheMessage->event == ME_MOUSEUPDATE) {
@@ -1245,8 +1245,8 @@ void doT2DMouseMainMenu(WGame &game, t2dWINDOW *w) {
} else {
//Va alla schermata di caricamento
LoadWindow_WhichBkg = 1;
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_LOAD, 0, tMAINMENU, nullptr,
- nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_LOAD, 0, tMAINMENU, nullptr,
+ nullptr, nullptr);
}
} else if (CurButton == T2D_BT_MAINMENU_EXIT) {
@@ -1468,7 +1468,7 @@ void doT2DMouse(WGame &game) {
case tSCANNER: {
if (CurButtonWin == T2D_WIN_SCANNER_BACKGROUND) {
if ((CurButton == T2D_BT_SCANNER_BACKGROUND_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tSCANNER, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tSCANNER, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_SCANNER_BACKGROUND_SELECTOR) && (bLPressed || bRPressed)) {
LinkWinToMouse = CurButtonWin;
LinkBtToMouse = T2D_BT_SCANNER_BACKGROUND_SELECTOR;
@@ -1484,19 +1484,19 @@ void doT2DMouse(WGame &game) {
LinkWinX = mouse_x;
LinkWinY = mouse_y;
} else if ((CurButton == T2D_BT_SCANNER_TOOLBAR_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tSCANNER, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tSCANNER, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_SCANNER_TOOLBAR_PREVIEW_OFF) && (TheMessage->event != ME_MOUSEUPDATE)) {
// Spegne per un attimo bottone di preview
w->bm[T2D_BM_SCANNER_TOOLBAR_PREVIEW_OFF].tnum |= T2D_BM_OFF;
w->bm[T2D_BM_SCANNER_TOOLBAR_PREVIEW_ON].tnum &= ~T2D_BM_OFF;
// Aspetta 1 secondo
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_SCANNER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_SCANNER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
// Riaccede tasto preview
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_PREVIEW_OFF, TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_PREVIEW_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
+ T2D_BM_SCANNER_TOOLBAR_PREVIEW_OFF, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
+ T2D_BM_SCANNER_TOOLBAR_PREVIEW_ON, FALSE, nullptr, nullptr, nullptr);
// Spegne pic di preview
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_PIC_LOW].tnum |= T2D_BM_OFF;
// Spegne selzionatoredi area
@@ -1508,8 +1508,8 @@ void doT2DMouse(WGame &game) {
// Accende finestra progress
WinActive[2] = T2D_WIN_SCANNER_PROGRESSBAR;
// Attiva gestione progress bar
- Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_WAITA, T2D_SCANNER_SCANNING_DELAY,
- T2D_SCANNER_SCANNING_STEPS, T2D_SCANNER_PREVIEWING, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DCONTINUE, MP_WAITA, T2D_SCANNER_SCANNING_DELAY,
+ T2D_SCANNER_SCANNING_STEPS, T2D_SCANNER_PREVIEWING, nullptr, nullptr, nullptr);
// Spegne tutta la toolbar
w->bt[T2D_BT_SCANNER_TOOLBAR_MOVE].on = FALSE;
w->bt[T2D_BT_SCANNER_TOOLBAR_EXIT].on = FALSE;
@@ -1525,15 +1525,15 @@ void doT2DMouse(WGame &game) {
w->bm[T2D_BM_SCANNER_TOOLBAR_SELECTAREA_OFF].tnum |= T2D_BM_OFF;
w->bm[T2D_BM_SCANNER_TOOLBAR_SELECTAREA_ON].tnum &= ~T2D_BM_OFF;
// Aspetta 1 secondo
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_SCANNER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_SCANNER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
// Riaccede tasto di select area
- Event(EventClass::MC_T2D, ME_T2DSETBUTTON, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BT_SCANNER_TOOLBAR_SELECTAREA_OFF, TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_SELECTAREA_OFF, TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_SELECTAREA_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBUTTON, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
+ T2D_BT_SCANNER_TOOLBAR_SELECTAREA_OFF, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
+ T2D_BM_SCANNER_TOOLBAR_SELECTAREA_OFF, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
+ T2D_BM_SCANNER_TOOLBAR_SELECTAREA_ON, FALSE, nullptr, nullptr, nullptr);
// Accende selezionatore di area
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_SELECTOR].tnum &= ~T2D_BM_OFF;
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bt[T2D_BT_SCANNER_BACKGROUND_SELECTOR].on = TRUE;
@@ -1550,12 +1550,12 @@ void doT2DMouse(WGame &game) {
w->bm[T2D_BM_SCANNER_TOOLBAR_SCAN_OFF].tnum |= T2D_BM_OFF;
w->bm[T2D_BM_SCANNER_TOOLBAR_SCAN_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_SCANNER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_SCAN_FREEZE, TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
- T2D_BM_SCANNER_TOOLBAR_SCAN_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_SCANNER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
+ T2D_BM_SCANNER_TOOLBAR_SCAN_FREEZE, TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_SCANNER_TOOLBAR,
+ T2D_BM_SCANNER_TOOLBAR_SCAN_ON, FALSE, nullptr, nullptr, nullptr);
w = &t2dWin[T2D_WIN_SCANNER_BACKGROUND];
d = &w->bm[T2D_BM_SCANNER_BACKGROUND_SELECTOR];
@@ -1579,8 +1579,8 @@ void doT2DMouse(WGame &game) {
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bm[T2D_BM_SCANNER_BACKGROUND_SELECTOR].tnum |= T2D_BM_OFF;
t2dWin[T2D_WIN_SCANNER_BACKGROUND].bt[T2D_BT_SCANNER_BACKGROUND_SELECTOR].on = FALSE;
// Attiva gestione progress bar
- Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_DEFAULT, T2D_SCANNER_SCANNING_DELAY,
- T2D_SCANNER_SCANNING_STEPS, T2D_SCANNER_SCANNING, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DCONTINUE, MP_DEFAULT, T2D_SCANNER_SCANNING_DELAY,
+ T2D_SCANNER_SCANNING_STEPS, T2D_SCANNER_SCANNING, nullptr, nullptr, nullptr);
// Spegne tutta la toolbar
w = &t2dWin[T2D_WIN_SCANNER_TOOLBAR];
w->bt[T2D_BT_SCANNER_TOOLBAR_MOVE].on = FALSE;
@@ -1614,8 +1614,8 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wCIAPULSANTE);
//Apre finestra EMail
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_EMAIL, 0, FALSE,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_EMAIL, 0, FALSE,
+ nullptr, nullptr, nullptr);
//Resetta dati
computerCurrentEMail = -1;
} else {
@@ -1624,8 +1624,8 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wCIAPULSANTE);
//Chiude finestra EMail
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_EMAIL, 0, TRUE, nullptr,
- nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_EMAIL, 0, TRUE, nullptr,
+ nullptr, nullptr);
}
} else if ((CurButton == T2D_BT_COMPUTER_BACKGROUND_SEARCH) && (TheMessage->event != ME_MOUSEUPDATE)) {
if (!(w->bm[T2D_BM_COMPUTER_SEARCH_ON].tnum & T2D_BM_OFF)) {
@@ -1634,8 +1634,8 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wCIAPULSANTE);
//Apre finestra Search
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_SEARCH, 0, FALSE,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_SEARCH, 0, FALSE,
+ nullptr, nullptr, nullptr);
//Riattiva DirectInput
//ResetDIKbd();
@@ -1659,8 +1659,8 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wCIAPULSANTE);
//Chiude finestra Search
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_SEARCH, 0, TRUE,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_SEARCH, 0, TRUE,
+ nullptr, nullptr, nullptr);
}
} else if ((CurButton == T2D_BT_COMPUTER_BACKGROUND_QUIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
@@ -1668,11 +1668,11 @@ void doT2DMouse(WGame &game) {
//Suono
StartSound(game, wCIAPULSANTE);
//Quitta
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_BACKGROUND,
- T2D_BM_COMPUTER_QUIT_ON, FALSE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_BACKGROUND,
+ T2D_BM_COMPUTER_QUIT_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
}
} else if (CurButtonWin == T2D_WIN_COMPUTER_ERROR) {
@@ -1683,18 +1683,18 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_COMPUTER_ERROR_DIALUP) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_ERROR_DIALUP_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_ERROR_DIALUP_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
+ T2D_BM_COMPUTER_ERROR_DIALUP_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva finestra errore
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, FALSE, nullptr,
- nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, FALSE, nullptr,
+ nullptr, nullptr);
//Attiva finestra DialUp
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, TRUE, nullptr,
- nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, TRUE, nullptr,
+ nullptr, nullptr);
//Disattiva DirectInput
//bIngnoreDIKeyboard = TRUE;
//Azzera Numero Telefonico
@@ -1702,8 +1702,8 @@ void doT2DMouse(WGame &game) {
strcpy(t2dWin[T2D_WIN_COMPUTER_DIALUP].text[T2D_TEXT_COMPUTER_DIALUP_NUMBER].text, "");
//Disattiva bitmap e pulsanti finestra errore
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_DIALERROR_WIN, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
+ T2D_BM_COMPUTER_DIALERROR_WIN, FALSE, nullptr, nullptr, nullptr);
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_DIALUP].on = FALSE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_DIALQUIT].on = FALSE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_DialError_Win_TGA].on = FALSE;
@@ -1711,41 +1711,41 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_COMPUTER_ERROR_DIALQUIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_ERROR_DIALQUIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_ERROR_DIALQUIT_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
+ T2D_BM_COMPUTER_ERROR_DIALQUIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Spenge il computer
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_ERROR_COMQUIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_ERROR_COMQUIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_ERROR_COMQUIT_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
+ T2D_BM_COMPUTER_ERROR_COMQUIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Spenge il computer
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_ERROR_OK) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_ERROR_OK_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_ERROR_OK_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
+ T2D_BM_COMPUTER_ERROR_OK_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Distattiva finestra errore
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, FALSE, nullptr,
- nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_ERROR, 0, FALSE, nullptr,
+ nullptr, nullptr);
//Distattiva bitmap e tasti finestra errore
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
- T2D_BM_COMPUTER_SEARCHERROR_WIN, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_ERROR,
+ T2D_BM_COMPUTER_SEARCHERROR_WIN, FALSE, nullptr, nullptr, nullptr);
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_COMPUTER_ERROR_OK].on = FALSE;
t2dWin[T2D_WIN_COMPUTER_ERROR].bt[T2D_BT_SearchError_Win_TGA].on = FALSE;
t2dWin[T2D_WIN_COMPUTER_ERROR].sy = 3;
@@ -1759,132 +1759,132 @@ void doT2DMouse(WGame &game) {
T2DAddKeyInput('1');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_1_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_1_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_1_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_2) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput('2');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_2_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_2_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_2_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_3) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput('3');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_3_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_3_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_3_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_4) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput('4');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_4_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_4_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_4_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_5) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput('5');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_5_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_5_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_5_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_6) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput('6');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_6_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_6_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_6_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_7) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput('7');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_7_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_7_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_7_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_8) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput('8');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_8_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_8_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_8_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_9) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput('9');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_9_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_9_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_9_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_0) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput('0');
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_0_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_0_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_0_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_ENTER) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput(VK_DELETE);
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_ENTER_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_ENTER_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_ENTER_ON, FALSE, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_C) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput(VK_BACK);
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_C_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_C_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_C_ON, FALSE, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_OK) && (TheMessage->event != ME_MOUSEUPDATE)) {
T2DAddKeyInput(VK_RETURN);
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_OK_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
- T2D_BM_COMPUTER_DIALUP_OK_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DIALUP,
+ T2D_BM_COMPUTER_DIALUP_OK_ON, FALSE, nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_DIALUP_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_DIALUP_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tCOMPUTER, nullptr, nullptr, nullptr);
}
} else if (CurButtonWin == T2D_WIN_COMPUTER_SEARCH) {
if ((CurButton == T2D_BT_COMPUTER_SEARCH_MOVE) && (bLPressed || bRPressed)) {
@@ -1894,10 +1894,10 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_COMPUTER_SEARCH_SEARCH) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_COMPUTER_SEARCH_SEARCH_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_SEARCH,
- T2D_BM_COMPUTER_SEARCH_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_SEARCH,
+ T2D_BM_COMPUTER_SEARCH_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -2010,19 +2010,19 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_COMPUTER_SEARCH_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_SEARCH_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_SEARCH,
- T2D_BM_COMPUTER_SEARCH_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_SEARCH,
+ T2D_BM_COMPUTER_SEARCH_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Elimina finestra search
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_SEARCH, 0, FALSE, nullptr,
- nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_SEARCH, 0, FALSE, nullptr,
+ nullptr, nullptr);
//Disattiva tasto search
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_BACKGROUND,
- T2D_BM_COMPUTER_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_BACKGROUND,
+ T2D_BM_COMPUTER_SEARCH_ON, FALSE, nullptr, nullptr, nullptr);
}
} else if (CurButtonWin == T2D_WIN_COMPUTER_DOCLIST) {
if ((CurButton == T2D_BT_COMPUTER_DOCLIST_MOVE) && (bLPressed || bRPressed)) {
@@ -2032,19 +2032,19 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_COMPUTER_DOCLIST_SCROLLUP) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCLIST_SCROLLUP_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST,
- T2D_BM_COMPUTER_DOCLIST_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST,
+ T2D_BM_COMPUTER_DOCLIST_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if ((CurButton == T2D_BT_COMPUTER_DOCLIST_SCROLLDOWN) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCLIST_SCROLLDOWN_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST,
- T2D_BM_COMPUTER_DOCLIST_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST,
+ T2D_BM_COMPUTER_DOCLIST_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
} else if (((CurButton >= T2D_BT_COMPUTER_DOCLIST_LINES_START) &&
@@ -2088,21 +2088,21 @@ void doT2DMouse(WGame &game) {
t.y2 - t.y1);
}
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_DOCUMENT, 0, TRUE,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_DOCUMENT, 0, TRUE,
+ nullptr, nullptr, nullptr);
}
} else if ((CurButton == T2D_BT_COMPUTER_DOCLIST_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCLIST_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST,
- T2D_BM_COMPUTER_DOCLIST_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST,
+ T2D_BM_COMPUTER_DOCLIST_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva finestra doclist
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, FALSE, nullptr,
- nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCLIST, 0, FALSE, nullptr,
+ nullptr, nullptr);
}
} else if (CurButtonWin == T2D_WIN_COMPUTER_EMAIL) {
if ((CurButton == T2D_BT_COMPUTER_EMAIL_MOVE) && (bLPressed || bRPressed)) {
@@ -2145,24 +2145,24 @@ void doT2DMouse(WGame &game) {
else t2dWin[T2D_WIN_COMPUTER_EMAIL_VIEWER].bm[computerCurrentEMail].dy = 0;
//Apre finestra EMail_Viewer
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_EMAIL_VIEWER, 0, TRUE,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_COMPUTER_EMAIL_VIEWER, 0, TRUE,
+ nullptr, nullptr, nullptr);
} else if ((CurButton == T2D_BT_COMPUTER_EMAIL_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_EMAIL_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL,
- T2D_BM_COMPUTER_EMAIL_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL,
+ T2D_BM_COMPUTER_EMAIL_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva finestra email
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_EMAIL, 0, FALSE, nullptr,
- nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_EMAIL, 0, FALSE, nullptr,
+ nullptr, nullptr);
//Disattiva tasto email
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_BACKGROUND,
- T2D_BM_COMPUTER_EMAIL_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_BACKGROUND,
+ T2D_BM_COMPUTER_EMAIL_ON, FALSE, nullptr, nullptr, nullptr);
//ResetDIKbd();
//bIngnoreDIKeyboard = FALSE;
@@ -2180,10 +2180,10 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_COMPUTER_DOCUMENT_SCROLLUP) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCUMENT_SCROLLUP_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
- T2D_BM_COMPUTER_DOCUMENT_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
+ T2D_BM_COMPUTER_DOCUMENT_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -2202,10 +2202,10 @@ void doT2DMouse(WGame &game) {
(TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCUMENT_SCROLLDOWN_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
- T2D_BM_COMPUTER_DOCUMENT_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
+ T2D_BM_COMPUTER_DOCUMENT_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -2230,18 +2230,18 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_COMPUTER_DOCUMENT_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_DOCUMENT_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
- T2D_BM_COMPUTER_DOCUMENT_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
+ T2D_BM_COMPUTER_DOCUMENT_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva documento
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
- (short) computerCurrentDocument, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT,
+ (short)computerCurrentDocument, FALSE, nullptr, nullptr, nullptr);
//Disattiva finestra Document
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT, 0, FALSE, nullptr,
- nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DOCUMENT, 0, FALSE, nullptr,
+ nullptr, nullptr);
computerCurrentDocument = -1;
}
@@ -2259,10 +2259,10 @@ void doT2DMouse(WGame &game) {
(TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLUP_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER,
- T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER,
+ T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLUP_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -2281,10 +2281,10 @@ void doT2DMouse(WGame &game) {
(TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLDOWN_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER,
- T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER,
+ T2D_BM_COMPUTER_EMAIL_VIEWER_SCROLLDOWN_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
@@ -2308,15 +2308,15 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_COMPUTER_EMAIL_VIEWER_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_COMPUTER_EMAIL_VIEWER_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER,
- T2D_BM_COMPUTER_EMAIL_VIEWER_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER,
+ T2D_BM_COMPUTER_EMAIL_VIEWER_EXIT_ON, FALSE, nullptr, nullptr, nullptr);
//Suono
StartSound(game, wCIAPULSANTE);
//Disattiva finestra Email_Viewer
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER, 0, FALSE,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_EMAIL_VIEWER, 0, FALSE,
+ nullptr, nullptr, nullptr);
}
}
break;
@@ -2363,19 +2363,19 @@ void doT2DMouse(WGame &game) {
if ((CurButton == T2D_BT_DIARIO_PAGE_LEFT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_DIARIO_PAGE_LEFT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_LEFT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_LEFT_ON,
+ FALSE, nullptr, nullptr, nullptr);
switch (diarioCurrentPage) {
case 1: //Pagina Iniziale, non puo andare a pagina precedente
break;
case 2:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_1,
- TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_1,
+ TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
+ FALSE, nullptr, nullptr, nullptr);
w->bt[T2D_BT_DIARIO_PAGE_LEFT].on = false;
for (i = T2D_BT_DIARIO_PAGE_1_TEXT_1; i <= T2D_BT_DIARIO_PAGE_1_TEXT_6; i++)
w->bt[i].on = TRUE;
@@ -2384,10 +2384,10 @@ void doT2DMouse(WGame &game) {
diarioCurrentPage = 1;
break;
case 3:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
- TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
+ TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
+ FALSE, nullptr, nullptr, nullptr);
for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
w->bt[i].on = TRUE;
for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
@@ -2395,10 +2395,10 @@ void doT2DMouse(WGame &game) {
diarioCurrentPage = 2;
break;
case 4:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
- TRUE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_4,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
+ TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_4,
+ FALSE, nullptr, nullptr, nullptr);
w->bt[T2D_BT_DIARIO_PAGE_RIGHT].on = TRUE;
for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
w->bt[i].on = TRUE;
@@ -2410,17 +2410,17 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_DIARIO_PAGE_RIGHT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_DIARIO_PAGE_RIGHT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_RIGHT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_RIGHT_ON,
+ FALSE, nullptr, nullptr, nullptr);
switch (diarioCurrentPage) {
case 1:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_1,
- FALSE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
- TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_1,
+ FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
+ TRUE, nullptr, nullptr, nullptr);
w->bt[T2D_BT_DIARIO_PAGE_LEFT].on = TRUE;
for (i = T2D_BT_DIARIO_PAGE_1_TEXT_1; i <= T2D_BT_DIARIO_PAGE_1_TEXT_6; i++)
w->bt[i].on = false;
@@ -2429,10 +2429,10 @@ void doT2DMouse(WGame &game) {
diarioCurrentPage = 2;
break;
case 2:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
- FALSE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
- TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_2,
+ FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
+ TRUE, nullptr, nullptr, nullptr);
for (i = T2D_BT_DIARIO_PAGE_2_TEXT_1; i <= T2D_BT_DIARIO_PAGE_2_TEXT_6; i++)
w->bt[i].on = false;
for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
@@ -2440,10 +2440,10 @@ void doT2DMouse(WGame &game) {
diarioCurrentPage = 3;
break;
case 3:
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
- FALSE, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_4,
- TRUE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_3,
+ FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_PAGE_4,
+ TRUE, nullptr, nullptr, nullptr);
w->bt[T2D_BT_DIARIO_PAGE_RIGHT].on = false;
for (i = T2D_BT_DIARIO_PAGE_3_TEXT_1; i <= T2D_BT_DIARIO_PAGE_3_TEXT_4; i++)
w->bt[i].on = false;
@@ -2457,13 +2457,13 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_DIARIO_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione tasto
w->bm[T2D_BM_DIARIO_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_EXIT_ON, FALSE,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_DIALUP_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_DIARIO, T2D_BM_DIARIO_EXIT_ON, FALSE,
+ nullptr, nullptr, nullptr);
//Uscita
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tDIARIO, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tDIARIO, nullptr, nullptr, nullptr);
} else if ((CurButton >= T2D_BT_DIARIO_PAGE_1_TEXT_1) && (CurButton <= T2D_BT_DIARIO_PAGE_1_TEXT_6) &&
(diarioCurrentPage == 1)) {
if (TheMessage->event == ME_MOUSEUPDATE) {
@@ -2504,9 +2504,9 @@ void doT2DMouse(WGame &game) {
else {
PlayerSpeak(game, init.Obj[oDIARIOPAG4A +
(CurButton - T2D_BT_DIARIO_PAGE_4_TEXT_1)].examine[CurPlayer]);
- Event(EventClass::MC_STRING, ME_PLAYERSPEAK, MP_WAIT_LINK,
- init.Obj[oDIARIOPAG4A + (CurButton - T2D_BT_DIARIO_PAGE_4_TEXT_1)].text[0], 0, 0,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_STRING, ME_PLAYERSPEAK, MP_WAIT_LINK,
+ init.Obj[oDIARIOPAG4A + (CurButton - T2D_BT_DIARIO_PAGE_4_TEXT_1)].text[0], 0, 0,
+ nullptr, nullptr, nullptr);
}
}
}
@@ -2519,24 +2519,24 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_MAIN_TONE_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_MAIN, T2D_BM_PDA_MAIN_TONE_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_MAIN, T2D_BM_PDA_MAIN_TONE_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Apre il Tone Sequencer
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_TONE, 0, TRUE, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_TONE, 0, TRUE, nullptr, nullptr,
+ nullptr);
} else if ((CurButton == T2D_BT_PDA_MAIN_LOG) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_MAIN_LOG_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_MAIN, T2D_BM_PDA_MAIN_LOG_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_MAIN, T2D_BM_PDA_MAIN_LOG_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Apre il Log Viewer
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_LOG, 0, TRUE, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_LOG, 0, TRUE, nullptr, nullptr,
+ nullptr);
//Resetta variabili
RefreshLog(game, RESTARTALL);
RefreshLog(game, REFRESH);
@@ -2544,12 +2544,12 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
StartSound(game, wPDAOFF);
w->bm[T2D_BM_PDA_MAIN_QUIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_MAIN, T2D_BM_PDA_MAIN_QUIT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_MAIN, T2D_BM_PDA_MAIN_QUIT_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Esce dal PDA
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tPDA, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_WAITA, 0, 0, tPDA, nullptr, nullptr, nullptr);
}
} else if (CurButtonWin == T2D_WIN_PDA_LOG) {
if ((CurButton == T2D_BT_PDA_LOG_SCROLL) && (bLPressed || bRPressed)) {
@@ -2611,20 +2611,20 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_PDA_LOG_SCROLLUP) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Gestione tasto
w->bm[T2D_BM_PDA_LOG_SCROLLUP_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_LOG, T2D_BM_PDA_LOG_SCROLLUP_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_LOG, T2D_BM_PDA_LOG_SCROLLUP_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Riposiziona il log
RefreshLog(game, -1);
} else if ((CurButton == T2D_BT_PDA_LOG_SCROLLDOWN) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Gestione tasto
w->bm[T2D_BM_PDA_LOG_SCROLLDOWN_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_LOG, T2D_BM_PDA_LOG_SCROLLDOWN_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_LOG, T2D_BM_PDA_LOG_SCROLLDOWN_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Riposiziona il log
RefreshLog(game, +1);
@@ -2658,72 +2658,72 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_LOG_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_LOG, T2D_BM_PDA_LOG_EXIT_ON, FALSE,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_LOG, T2D_BM_PDA_LOG_EXIT_ON, FALSE,
+ nullptr, nullptr, nullptr);
//Chiude finestra help se aperta
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr,
+ nullptr);
//Chiude finestra Log Viewer
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_LOG, 0, FALSE, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_LOG, 0, FALSE, nullptr, nullptr,
+ nullptr);
}
} else if (CurButtonWin == T2D_WIN_PDA_TONE) {
if ((CurButton == T2D_BT_PDA_TONE_HELP) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_TONE_HELP_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_HELP_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_HELP_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Setta e Apre finestra Help
SetHelpWin(game._fonts, nullptr, 5, Sentence[init.Obj[oTONERHELP].text[0]],
Sentence[init.Obj[oTONERHELP].text[1]], Sentence[init.Obj[oTONERHELP].text[2]],
Sentence[init.Obj[oTONERHELP].text[3]], Sentence[init.Obj[oTONERHELP].text[4]]);
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_HELP, 0, TRUE, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_HELP, 0, TRUE, nullptr, nullptr,
+ nullptr);
} else if ((CurButton == T2D_BT_PDA_TONE_EXIT) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_TONE_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_EXIT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_EXIT_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Chiude finestra help
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr,
+ nullptr);
//Chiude finestra Tone
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_TONE, 0, FALSE, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_TONE, 0, FALSE, nullptr, nullptr,
+ nullptr);
} else if ((CurButton == T2D_BT_PDA_TONE_ACQUIRE) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Disattiva tasto
w->bt[T2D_BT_PDA_TONE_ACQUIRE].on = FALSE;
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_TONE_ACQUIRE_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_ACQUIRE_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_ACQUIRE_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Fa partire sequenza di aquiring
- Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_WAITA, 0, 0, T2D_PDA_TONE_AQUIRING, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DCONTINUE, MP_WAITA, 0, 0, T2D_PDA_TONE_AQUIRING, nullptr, nullptr,
+ nullptr);
} else if ((CurButton == T2D_BT_PDA_TONE_PROCESS) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Disattiva tasto
w->bt[T2D_BT_PDA_TONE_PROCESS].on = FALSE;
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_TONE_PROCESS_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_PROCESS_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_TONE, T2D_BM_PDA_TONE_PROCESS_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Fa partire sequenza di processing
- Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_WAITA, 0, 0, T2D_PDA_TONE_PROCESS, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DCONTINUE, MP_WAITA, 0, 0, T2D_PDA_TONE_PROCESS, nullptr, nullptr,
+ nullptr);
if (!(init.InvObj[i28WALKMANOK].flags & EXTRA2))
IncCurTime(game, 5);
init.InvObj[i28WALKMANOK].flags |= EXTRA2;
@@ -2738,13 +2738,13 @@ void doT2DMouse(WGame &game) {
//Pressione Tasto
StartSound(game, wPDAPULSANTE);
w->bm[T2D_BM_PDA_HELP_EXIT_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_HELP, T2D_BM_PDA_HELP_EXIT_ON,
- FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_PDA_HELP, T2D_BM_PDA_HELP_EXIT_ON,
+ FALSE, nullptr, nullptr, nullptr);
//Chiude finestra Tone
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr,
+ nullptr);
if (HelpFunc != NULL) HelpFunc();
}
}
@@ -2934,17 +2934,17 @@ void doT2DMouse(WGame &game) {
DebugLogFile("DataLoad(slot %d) Failed. Quitting ...", i);
CloseSys(game);
}
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tOPTIONS, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tOPTIONS, nullptr, nullptr,
+ nullptr);
break;
}
} else if ((CurButton == T2D_BT_OPTIONS_FRECCIA_SU) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_OPTIONS_FRECCIA_SU_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_OPTIONS_MAIN,
- T2D_BM_OPTIONS_FRECCIA_SU_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_OPTIONS_MAIN,
+ T2D_BM_OPTIONS_FRECCIA_SU_ON, FALSE, nullptr, nullptr, nullptr);
//Scrolling Up
if (optionsCurPos > 0) {
optionsCurPos -= 3;
@@ -2976,10 +2976,10 @@ void doT2DMouse(WGame &game) {
} else if ((CurButton == T2D_BT_OPTIONS_FRECCIA_GIU) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Pressione Tasto
w->bm[T2D_BM_OPTIONS_FRECCIA_GIU_ON].tnum &= ~T2D_BM_OFF;
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
- nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_OPTIONS_MAIN,
- T2D_BM_OPTIONS_FRECCIA_GIU_ON, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT,
+ nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETBITMAP, MP_WAITA, T2D_WIN_OPTIONS_MAIN,
+ T2D_BM_OPTIONS_FRECCIA_GIU_ON, FALSE, nullptr, nullptr, nullptr);
if (optionsCurPos + 6 > NSaves) break;
if (optionsCurPos + 3 >= T2D_OPTIONS_MAX_SAVES) break;
//Scrolling Down
@@ -3014,12 +3014,12 @@ void doT2DMouse(WGame &game) {
CloseSys(game);
} else if ((CurButton == T2D_BT_OPTIONS_CLOSE) && (TheMessage->event != ME_MOUSEUPDATE)) {
//Esce dalle Opzioni
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tOPTIONS, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, 0, 0, tOPTIONS, nullptr, nullptr, nullptr);
} else if (CurButton == T2D_BT_OPTIONS_MAINMENU) {
if (TheMessage->event != ME_MOUSEUPDATE) {
bShowOnlyLoadWindow = 0;
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_MAINMENU, 0, tOPTIONS,
- nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_MAINMENU, 0, tOPTIONS,
+ nullptr, nullptr, nullptr);
} else {
w->bm[T2D_BM_OPTIONS_MAINMENU_OFF].tnum |= T2D_BM_OFF;
w->bm[T2D_BM_OPTIONS_MAINMENU_ON].tnum &= ~T2D_BM_OFF;
@@ -3121,8 +3121,8 @@ void doT2DMouse(WGame &game) {
case tGAMEOVER: {
if (timeGetTime() >= (GameOverWindow_StartTime + GAMEOVER_WINDOW_NUM_MSECONDS)) {
LoadWindow_WhichBkg = 2;
- Event(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_LOAD, 0, tMAINMENU, nullptr, nullptr,
- nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTOP, MP_DEFAULT, STOP_T2D__LAUNCH_LOAD, 0, tMAINMENU, nullptr, nullptr,
+ nullptr);
}
break;
}
@@ -3162,7 +3162,7 @@ void doT2D(WGame &game) {
bIngnoreDIKeyboard = true;
if (InvStatus & INV_ON)
- Event(EventClass::MC_INVENTORY, ME_INVSWITCH, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_INVENTORY, ME_INVSWITCH, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
StopDiary(game, 0, 0, 0);
ClearText();
@@ -4662,8 +4662,8 @@ void doT2D(WGame &game) {
ScrollWithMouse = 0;
StartAcquiring = TheMessage->lparam[0]; // i28WALKMANOK
if (StartAcquiring == i28WALKMANOK) {
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_TONE, 0, true, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DCONTINUE, MP_DEFAULT, 0, 0, T2D_PDA_TONE_AQUIRING, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_TONE, 0, true, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DCONTINUE, MP_DEFAULT, 0, 0, T2D_PDA_TONE_AQUIRING, nullptr, nullptr, nullptr);
}
//Cerca il MainTitle
@@ -5124,15 +5124,15 @@ void doT2D(WGame &game) {
// start intro
if (!(LoaderFlags & T3D_DEBUGMODE))
- Event(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR000, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGSTART, MP_DEFAULT, dR000, 0, 0, nullptr, nullptr, nullptr);
}
if (TheMessage->wparam1 == STOP_T2D__LAUNCH_LOAD) {
bShowOnlyLoadWindow = 1;
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_LOAD, 0, tOPTIONS, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, MPX_START_T2D_LOAD, 0, tOPTIONS, nullptr, nullptr, nullptr);
}
if (TheMessage->wparam1 == STOP_T2D__LAUNCH_MAINMENU) {
StopPlayingGame(game);
- Event(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tMAINMENU, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSTART, MP_DEFAULT, 0, 0, tMAINMENU, nullptr, nullptr, nullptr);
}
//Riabilita DInput
@@ -5141,7 +5141,7 @@ void doT2D(WGame &game) {
StartDiary(game, game._gameVars.getCurRoomId(), nullptr);
if (Settati_PDA_items_durante_t2d) {
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, FRAME_PER_SECOND * 3, 0, EFFECT_DISPLAY_NEWLOGIMG, nullptr, nullptr, nullptr);
Settati_PDA_items_durante_t2d = 0;
}
break;
@@ -5167,7 +5167,7 @@ void doT2D(WGame &game) {
if (j == -1) {
WinActive[i] = TheMessage->wparam1;
} else {
- Event(EventClass::MC_T2D, ME_T2DSWAPWINDOWS, MP_DEFAULT, WinActive[i - 1], WinActive[j], 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSWAPWINDOWS, MP_DEFAULT, WinActive[i - 1], WinActive[j], 0, nullptr, nullptr, nullptr);
}
break;
}
@@ -5270,7 +5270,7 @@ void doT2D(WGame &game) {
t2dWin[T2D_WIN_SCANNER_TOOLBAR].bt[T2D_BT_SCANNER_TOOLBAR_PREVIEW_OFF].on = true;
}
// Spegne finestra progress
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_SCANNER_PROGRESSBAR, 0, false, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_SCANNER_PROGRESSBAR, 0, false, nullptr, nullptr, nullptr);
}
}
TheMessage->flags |= MP_WAIT_RETRACE;
@@ -5295,8 +5295,8 @@ void doT2D(WGame &game) {
//Disattiva finestra Dialup
strcpy(computerConnectStr, Sentence[init.Obj[oCOMPUTERDIAL].text[1]]);
strcpy(t2dWin[T2D_WIN_COMPUTER_DIALUP].text[T2D_TEXT_COMPUTER_DIALUP_NUMBER].text, computerConnectStr);
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT, nullptr, nullptr, nullptr);
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, false, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_COMPUTER_BUTTON_DELAY, 0, EFFECT_WAIT, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_COMPUTER_DIALUP, 0, false, nullptr, nullptr, nullptr);
t2dWin[T2D_WIN_COMPUTER_BACKGROUND].bt[T2D_BT_COMPUTER_BACKGROUND_EMAIL].on = true;
t2dWin[T2D_WIN_COMPUTER_BACKGROUND].bt[T2D_BT_COMPUTER_BACKGROUND_SEARCH].on = true;
@@ -5357,7 +5357,7 @@ void doT2D(WGame &game) {
b->on = false;
SetHelpWin(game._fonts, &PDA_Tone_Acquire_Help_Func, 2, Sentence[init.Obj[oTONERHELP].text[4]], " ");
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, true, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, true, nullptr, nullptr, nullptr);
}
break;
}
@@ -5617,9 +5617,9 @@ void PDA_Tone_Acquire_Help_Func(void) {
w->bm[T2D_BM_PDA_TONE_BARRA_1].tnum |= T2D_BM_OFF;
//Delay
- Event(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_SYSTEM, ME_STARTEFFECT, MP_DEFAULT, T2D_PDA_BUTTON_DELAY, 0, EFFECT_WAIT, nullptr, nullptr, nullptr);
//Chiude finestra help
- Event(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_T2D, ME_T2DSETWINDOW, MP_DEFAULT, T2D_WIN_PDA_HELP, 0, FALSE, nullptr, nullptr, nullptr);
//Chiude finestra Tone
// Event( EventClass::MC_T2D, ME_T2DSETWINDOW, MP_WAITA, T2D_WIN_PDA_TONE, 0, FALSE, NULL, NULL, NULL );
}
diff --git a/engines/watchmaker/walk/act.cpp b/engines/watchmaker/walk/act.cpp
index 03a746b9aba..a80fb3989c9 100644
--- a/engines/watchmaker/walk/act.cpp
+++ b/engines/watchmaker/walk/act.cpp
@@ -123,7 +123,7 @@ void UpdateChar(WGame &game, int32 oc, t3dF32 Speed, t3dF32 Rot) {
return;
}
- Event(EventClass::MC_MOUSE, ME_MOUSEHIDE, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_MOUSE, ME_MOUSEHIDE, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
if (Char && Speed)
CharNextFrame(game, oc);
@@ -172,7 +172,7 @@ void UpdateChar(WGame &game, int32 oc, t3dF32 Speed, t3dF32 Rot) {
SlideChar(oc);
game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, 0, NULL, NULL, NULL);
}
}
@@ -663,8 +663,8 @@ bool CharGotoPosition(WGame &game, int32 oc, uint8 pos, uint8 back, int32 anim)
game._messageSystem.removeEvent(EventClass::MC_PLAYER, ME_ALL);
if (bFirstPerson)
- Event(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
- Event(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA1TO3, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERGOTO, MP_DEFAULT, 0, 0, bFirstPerson, nullptr, nullptr, nullptr);
} else if ((cp = PlayerGotoPos[oc] = GetLightPosition(&tmp, pos)) == 0) return FALSE;
FloorHit = 1;
@@ -735,7 +735,7 @@ uint8 CharNextFrame(WGame &game, int32 oc) {
} else {
if (Player == Char) {
an = TheTime + PLAYER_IDLE_TIME;
- Event(EventClass::MC_PLAYER, ME_PLAYERIDLE, MP_WAIT_RETRACE, (int16)(CurPlayer + ocDARRELL), 0, 0, &an, nullptr, nullptr);
+ _vm->_messageSystem.doEvent(EventClass::MC_PLAYER, ME_PLAYERIDLE, MP_WAIT_RETRACE, (int16)(CurPlayer + ocDARRELL), 0, 0, &an, nullptr, nullptr);
PlayerPos[CurPlayer + ocDARRELL] = PlayerGotoPos[CurPlayer + ocDARRELL];
PlayerGotoPos[CurPlayer + ocDARRELL] = 0;
}
Commit: 439b210bcf6576cb74ef73553d719b821e72ca16
https://github.com/scummvm/scummvm/commit/439b210bcf6576cb74ef73553d719b821e72ca16
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Move WaitingMsgs into MessageSystem
Changed paths:
engines/watchmaker/classes/do_camera.cpp
engines/watchmaker/classes/do_player.cpp
engines/watchmaker/classes/do_string.cpp
engines/watchmaker/classes/do_system.cpp
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/schedule.cpp
engines/watchmaker/schedule.h
engines/watchmaker/t2d/t2d.cpp
engines/watchmaker/walk/act.cpp
diff --git a/engines/watchmaker/classes/do_camera.cpp b/engines/watchmaker/classes/do_camera.cpp
index 9281b47d595..e574579f679 100644
--- a/engines/watchmaker/classes/do_camera.cpp
+++ b/engines/watchmaker/classes/do_camera.cpp
@@ -265,7 +265,7 @@ void NextCameraStep(WGame &game) {
bMovingCamera = false;
DestCamera = nullptr;
t3dVectFill(&OldCameraTarget, 0.0f);
-// AddWaitingMsgs( MP_WAIT_CAMERA );
+// _vm->_messageSystem.addWaitingMsgs( MP_WAIT_CAMERA );
GetCameraTarget(init, &t3dCurCamera->Target);
game._renderer->setCurCameraViewport(t3dCurCamera->Fov, bSuperView);
@@ -286,7 +286,7 @@ void NextCameraStep(WGame &game) {
CurCameraStep = NumCameraSteps = 0;
bMovingCamera = false;
DestCamera = nullptr;
- AddWaitingMsgs(MP_WAIT_CAMERA);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAIT_CAMERA);
// if( (bFirstPerson) && ( ( CurRoom == r32 ) && ( PlayerPos[CurPlayer+ocDARRELL] == 6 ) ) )
// PlayerSpeak( Obj[o32OROLOGIO].action[CurPlayer+ocDARRELL] );
@@ -606,14 +606,14 @@ void ProcessCamera(WGame &game) {
bForceDirectCamera = TRUE;
t3dCurCameraIndex = 255;
t3dLastCameraIndex = 255;
- AddWaitingMsgs(MP_WAIT_PORTAL);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAIT_PORTAL);
// DebugLogFile("PortalCrossed %s",PortalCrossed->Name);
// PortalCrossed = nullptr;
if (bMovingCamera) {
CurCameraStep = NumCameraSteps = 0;
bMovingCamera = FALSE;
DestCamera = nullptr;
- AddWaitingMsgs(MP_WAIT_CAMERA);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAIT_CAMERA);
}
if (bFirstPerson)
_vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);
diff --git a/engines/watchmaker/classes/do_player.cpp b/engines/watchmaker/classes/do_player.cpp
index 73eac8ca97f..cbe4c9d90c4 100644
--- a/engines/watchmaker/classes/do_player.cpp
+++ b/engines/watchmaker/classes/do_player.cpp
@@ -135,7 +135,7 @@ void doPlayer(WGame &game) {
Player->Walk.NumPathNodes = Player->Walk.CurrentStep = Player->Walk.NumSteps = bNotSkippableWalk = 0;
if ((!bDialogActive) || (TimeWalk == CurPlayer + ocDARRELL) || (TimeWalk == ocBOTH))
- AddWaitingMsgs(MP_WAIT_ACT);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAIT_ACT);
if (TheMessage->event == ME_PLAYERGOTOEXAMINE)
_vm->_messageSystem.doEvent(EventClass::MC_ACTION, ME_MOUSEEXAMINE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &TheMessage->lparam[0], nullptr, nullptr);
@@ -169,7 +169,7 @@ void ProcessCharacters(WGame &game) {
if (Character[i] && (Character[i] != Player) && (Character[i]->Walk.NumSteps))
if (!CharNextFrame(game, i))
if ((bDialogActive) && (TimeWalk == i))
- AddWaitingMsgs(MP_WAIT_ACT);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAIT_ACT);
for (i = 0; i < T3D_MAX_CHARACTERS; i++) {
c = Character[i];
diff --git a/engines/watchmaker/classes/do_string.cpp b/engines/watchmaker/classes/do_string.cpp
index 2963dfceee9..b2ff6873733 100644
--- a/engines/watchmaker/classes/do_string.cpp
+++ b/engines/watchmaker/classes/do_string.cpp
@@ -176,7 +176,7 @@ void doString(WGame &game) {
bSkipTalk = false;
bAnimWaitText = false;
ClearText();
- if (!bDialogActive) AddWaitingMsgs(MP_WAIT_LINK);
+ if (!bDialogActive) _vm->_messageSystem.addWaitingMsgs(MP_WAIT_LINK);
} else {
TheMessage->flags |= MP_WAIT_RETRACE;
ReEvent();
@@ -197,7 +197,7 @@ void doString(WGame &game) {
bSkipTalk = false;
bAnimWaitText = false;
ClearText();
- if (!bDialogActive) AddWaitingMsgs(MP_WAIT_LINK);
+ if (!bDialogActive) _vm->_messageSystem.addWaitingMsgs(MP_WAIT_LINK);
} else {
TheMessage->flags |= MP_WAIT_RETRACE;
ReEvent();
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index 73fd3c28cb5..bfc2e0ff2bf 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -542,7 +542,7 @@ void ProcessTime(WGame &game) {
ProcessGopherCamera(game);
}
// Aggiunge eventi che devo essere lanciati alla fine del frame
- AddWaitingMsgs(MP_WAIT_RETRACE);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAIT_RETRACE);
// Azzera il numero di eventi inviati tra un refresh e l'altro
NumTimes = 0;
@@ -821,14 +821,14 @@ void doSystem(WGame &game) {
TheMessage->lparam[0] = LastT1;
ReEvent();
} else
- AddWaitingMsgs(MP_WAITA);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAITA);
break;
case EFFECT_FADEOUT_T2:
if (T2t) {
TheMessage->lparam[0] = LastT2;
ReEvent();
} else
- AddWaitingMsgs(MP_WAITA);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAITA);
break;
case EFFECT_MOVEIN_T1:
@@ -846,7 +846,7 @@ void doSystem(WGame &game) {
ReEvent();
LastT1 = TheMessage->lparam[0];
} else
- DeleteWaitingMsgs(MP_WAITA);
+ _vm->_messageSystem.deleteWaitingMsgs(MP_WAITA);
break;
case EFFECT_MOVEIN_T2:
T2t = nullptr;
@@ -863,7 +863,7 @@ void doSystem(WGame &game) {
ReEvent();
LastT2 = TheMessage->lparam[0];
} else
- DeleteWaitingMsgs(MP_WAITA);
+ _vm->_messageSystem.deleteWaitingMsgs(MP_WAITA);
break;
case EFFECT_ROOMINFO: {
int32 width, height, bpp, time;
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index dda73996bea..713f4b514c2 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -777,7 +777,7 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
for (a = 0, obj = h->LoopMask; a < MAX_SUBANIMS; a++)
if (!bAnimWaitText && h->sub[a].ptr && (h->sub[a].ptr->CurFrame >= 0) && !(obj & (1 << a)))
if ((h->sub[a].ptr->Flags & T3D_MESH_CHARACTER) && (bDialogActive)) {
- AddWaitingMsgs(MP_WAIT_LINK);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAIT_LINK);
h->sub[a].ptr->CurFrame = h->LoopEnd;
h->sub[a].ptr->BlendPercent = 0;
h->CurFrame = h->LoopEnd;
@@ -1611,11 +1611,11 @@ void StopAnim(WGame &game, int32 an) {
// Se sono in un dialogo controlla che sia finita l'animazione di Time
else if (bDialogActive) {
if (an == TimeAnim)
- AddWaitingMsgs(MP_WAIT_ANIM);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAIT_ANIM);
}
// Altrimenti aggiungo tutte le anim
else
- AddWaitingMsgs(MP_WAIT_ANIM);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAIT_ANIM);
}
diff --git a/engines/watchmaker/schedule.cpp b/engines/watchmaker/schedule.cpp
index 69f46fb43fa..aec06b90df2 100644
--- a/engines/watchmaker/schedule.cpp
+++ b/engines/watchmaker/schedule.cpp
@@ -39,36 +39,31 @@
namespace Watchmaker {
-#define MAXWAITINGMSGS 30
-message WaitingMsg[MAXWAITINGMSGS];
+void MessageSystem::addWaitingMsgs(uint16 flags) {
+ for (int8 a = 0; a < MAXWAITINGMSGS; a++) {
+ _waitingMsg[a].flags &= ~flags;
+ }
-/* -----------------18/03/98 16.41-------------------
- * AddWaitingMsgs
- * --------------------------------------------------*/
-void AddWaitingMsgs(uint16 flags) {
- int8 a;
- for (a = 0; a < MAXWAITINGMSGS; a++)
- WaitingMsg[a].flags &= ~flags;
-
- for (a = 0; a < MAXWAITINGMSGS; a++)
- if (WaitingMsg[a].classe != EventClass::MC_IDLE && (WaitingMsg[a].flags < MP_WAITA)) {
- _vm->_messageSystem.doEvent(WaitingMsg[a].classe, WaitingMsg[a].event, WaitingMsg[a].flags,
- WaitingMsg[a].wparam1, WaitingMsg[a].wparam2,
- WaitingMsg[a].bparam, &WaitingMsg[a].lparam[0], &WaitingMsg[a].lparam[1], &WaitingMsg[a].lparam[2]);
- memset(&WaitingMsg[a], 0, sizeof(WaitingMsg[a]));
+ for (int8 a = 0; a < MAXWAITINGMSGS; a++) {
+ if (_waitingMsg[a].classe != EventClass::MC_IDLE && (_waitingMsg[a].flags < MP_WAITA)) {
+ _vm->_messageSystem.doEvent(_waitingMsg[a].classe, _waitingMsg[a].event, _waitingMsg[a].flags,
+ _waitingMsg[a].wparam1, _waitingMsg[a].wparam2,
+ _waitingMsg[a].bparam, &_waitingMsg[a].lparam[0], &_waitingMsg[a].lparam[1], &_waitingMsg[a].lparam[2]);
+ memset(&_waitingMsg[a], 0, sizeof(_waitingMsg[a]));
}
+ }
}
/* -----------------25/09/98 16.33-------------------
* DeleteWaitingMsgs
* --------------------------------------------------*/
-void DeleteWaitingMsgs(uint16 flags) {
+void MessageSystem::deleteWaitingMsgs(uint16 flags) {
for (int a = 0; a < MAXWAITINGMSGS; a++)
- WaitingMsg[a].flags &= ~flags;
+ _waitingMsg[a].flags &= ~flags;
for (int a = 0; a < MAXWAITINGMSGS; a++)
- if (WaitingMsg[a].classe != EventClass::MC_IDLE && (WaitingMsg[a].flags < MP_WAITA))
- memset(&WaitingMsg[a], 0, sizeof(WaitingMsg[a]));
+ if (_waitingMsg[a].classe != EventClass::MC_IDLE && (_waitingMsg[a].flags < MP_WAITA))
+ memset(&_waitingMsg[a], 0, sizeof(_waitingMsg[a]));
}
/* -----------------08/02/99 10.09-------------------
@@ -82,7 +77,7 @@ bool _GetMessage(pqueue *lq) {
lq->len--;
if (TheMessage->flags & MP_CLEARA)
- AddWaitingMsgs(MP_WAITA);
+ _vm->_messageSystem.addWaitingMsgs(MP_WAITA);
return true;
}
@@ -101,7 +96,7 @@ void MessageSystem::init() {
}
for (int i = 0; i < MAXWAITINGMSGS; i++) {
- memset(&WaitingMsg[i], 0, sizeof(WaitingMsg[i]));
+ memset(&_waitingMsg[i], 0, sizeof(_waitingMsg[i]));
}
}
@@ -136,25 +131,31 @@ void MessageSystem::doEvent(EventClass classe, uint8 event, uint16 flags, int16
if (flags >= MP_WAITA) {
int8 a;
for (a = 0; a < MAXWAITINGMSGS; a++)
- if (WaitingMsg[a].classe == EventClass::MC_IDLE)
+ if (_waitingMsg[a].classe == EventClass::MC_IDLE)
break;
if (a < MAXWAITINGMSGS) {
- WaitingMsg[a].classe = classe;
- WaitingMsg[a].event = event;
- WaitingMsg[a].flags = flags;
- WaitingMsg[a].wparam1 = wparam1;
- WaitingMsg[a].wparam2 = wparam2;
- WaitingMsg[a].bparam = bparam;
- if (p0 != nullptr) WaitingMsg[a].lparam[0] = *(int32 *)p0;
- else WaitingMsg[a].lparam[0] = 0;
- if (p1 != nullptr) WaitingMsg[a].lparam[1] = *(int32 *)p1;
- else WaitingMsg[a].lparam[1] = 0;
- if (p2 != nullptr) WaitingMsg[a].lparam[2] = *(int32 *)p2;
- else WaitingMsg[a].lparam[2] = 0;
+ _waitingMsg[a].classe = classe;
+ _waitingMsg[a].event = event;
+ _waitingMsg[a].flags = flags;
+ _waitingMsg[a].wparam1 = wparam1;
+ _waitingMsg[a].wparam2 = wparam2;
+ _waitingMsg[a].bparam = bparam;
+ if (p0 != nullptr)
+ _waitingMsg[a].lparam[0] = *(int32 *)p0;
+ else
+ _waitingMsg[a].lparam[0] = 0;
+ if (p1 != nullptr)
+ _waitingMsg[a].lparam[1] = *(int32 *)p1;
+ else
+ _waitingMsg[a].lparam[1] = 0;
+ if (p2 != nullptr)
+ _waitingMsg[a].lparam[2] = *(int32 *)p2;
+ else
+ _waitingMsg[a].lparam[2] = 0;
return;
} else {
for (a = 0; a < MAXWAITINGMSGS; a++)
- warning("%d: %d %d %d %d", a, WaitingMsg[a].classe, WaitingMsg[a].event, WaitingMsg[a].flags, WaitingMsg[a].lparam[1]);
+ warning("%d: %d %d %d %d", a, _waitingMsg[a].classe, _waitingMsg[a].event, _waitingMsg[a].flags, _waitingMsg[a].lparam[1]);
warning("ERRORE! CODA WAITING PIENA! - messy %d %d MAX %d", classe, event, MAXWAITINGMSGS);
return;
@@ -305,8 +306,8 @@ void MessageSystem::removeEvent(EventClass classe, uint8 event) {
}
for (b = 0; b < MAXWAITINGMSGS; b++)
- if ((WaitingMsg[b].classe == classe) && ((event == ME_ALL) || (WaitingMsg[b].event == event)))
- memset(&WaitingMsg[b], 0, sizeof(WaitingMsg[b]));
+ if ((_waitingMsg[b].classe == classe) && ((event == ME_ALL) || (_waitingMsg[b].event == event)))
+ memset(&_waitingMsg[b], 0, sizeof(_waitingMsg[b]));
}
/* -----------------18/12/00 16.32-------------------
@@ -331,8 +332,8 @@ void MessageSystem::removeEvent_bparam(EventClass classe, uint8 event, uint8 bpa
}
for (b = 0; b < MAXWAITINGMSGS; b++)
- if ((WaitingMsg[b].classe == classe) && ((event == ME_ALL) || (WaitingMsg[b].event == event)) && (WaitingMsg[b].bparam == bparam))
- memset(&WaitingMsg[b], 0, sizeof(WaitingMsg[b]));
+ if ((_waitingMsg[b].classe == classe) && ((event == ME_ALL) || (_waitingMsg[b].event == event)) && (_waitingMsg[b].bparam == bparam))
+ memset(&_waitingMsg[b], 0, sizeof(_waitingMsg[b]));
}
/* -----------------08/02/99 10.11-------------------
diff --git a/engines/watchmaker/schedule.h b/engines/watchmaker/schedule.h
index fc8c5280b7a..48eeb35893d 100644
--- a/engines/watchmaker/schedule.h
+++ b/engines/watchmaker/schedule.h
@@ -30,8 +30,10 @@ namespace Watchmaker {
void ProcessTheMessage(WGame &game);
void ReEvent();
-void DeleteWaitingMsgs(uint16 flags);
-void AddWaitingMsgs(uint16 flags);
+void deleteWaitingMsgs(uint16 flags);
+void addWaitingMsgs(uint16 flags);
+
+#define MAXWAITINGMSGS 30
class MessageSystem {
public:
@@ -39,7 +41,11 @@ public:
void removeEvent(EventClass classe, uint8 event);
void removeEvent_bparam(EventClass classe, uint8 event, uint8 bparam);
void scheduler(); // TODO: Rename
+
void doEvent(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wparam2, uint8 bparam, void *p0, void *p1, void *p2);
+ void addWaitingMsgs(uint16 flags);
+ void deleteWaitingMsgs(uint16 flags);
+
message GameMessage[MAX_MESSAGES];
pqueue Game;
// message *TheMessage; // TODO: Replace the global variable with this
@@ -47,6 +53,7 @@ public:
uint8 SuperEventActivate;
private:
int _maxmsg = 0;
+ message _waitingMsg[MAXWAITINGMSGS];
void initQueue(pqueue *lq);
};
diff --git a/engines/watchmaker/t2d/t2d.cpp b/engines/watchmaker/t2d/t2d.cpp
index 7031a26f0e0..bbf866a89af 100644
--- a/engines/watchmaker/t2d/t2d.cpp
+++ b/engines/watchmaker/t2d/t2d.cpp
@@ -2356,7 +2356,7 @@ void doT2DMouse(WGame &game) {
if ((bSomeOneSpeak) && ((TheMessage->event == ME_MLEFT) || (TheMessage->event == ME_MRIGHT))) {
bSkipTalk = TRUE;
ClearText();
- DeleteWaitingMsgs(MP_WAIT_LINK);
+ _vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_LINK);
return;
}
diff --git a/engines/watchmaker/walk/act.cpp b/engines/watchmaker/walk/act.cpp
index a80fb3989c9..ef5769ab9fe 100644
--- a/engines/watchmaker/walk/act.cpp
+++ b/engines/watchmaker/walk/act.cpp
@@ -297,9 +297,9 @@ void CheckCharacterWithoutBounds(WGame &game, int32 oc, const uint8 *dpl, uint8
}
bNotSkippableWalk = TRUE;
BuildStepList(oc, dp, back);
- DeleteWaitingMsgs(MP_WAIT_PORTAL);
- DeleteWaitingMsgs(MP_WAIT_ANIM);
- DeleteWaitingMsgs(MP_WAIT_ACT);
+ _vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_PORTAL);
+ _vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_ANIM);
+ _vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_ACT);
}
/* -----------------01/07/98 16.10-------------------
@@ -643,9 +643,9 @@ bool CheckCharacterWithBounds(WGame &game, int32 oc, t3dV3F *Pos, uint8 dp, uint
t3dVectCopy(&Char->Pos, &Char->Mesh->Trasl);
FindPath(oc, t3dCurCamera); // Calc path
if (CheckPathNodes(oc)) BuildStepList(oc, dp, back);
- DeleteWaitingMsgs(MP_WAIT_PORTAL);
- DeleteWaitingMsgs(MP_WAIT_ANIM);
- DeleteWaitingMsgs(MP_WAIT_ACT);
+ _vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_PORTAL);
+ _vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_ANIM);
+ _vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_ACT);
if (Char->Walk.NumSteps >= 2) return TRUE;
else return FALSE;
}
Commit: 7b38c8f7c70d192b7a4c87558feac747637853b4
https://github.com/scummvm/scummvm/commit/7b38c8f7c70d192b7a4c87558feac747637853b4
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Refactor Add2DStuff logic to avoid global constructors
Changed paths:
A engines/watchmaker/2d_stuff.cpp
A engines/watchmaker/2d_stuff.h
engines/watchmaker/classes/do_dialog.cpp
engines/watchmaker/classes/do_system.cpp
engines/watchmaker/extraLS.cpp
engines/watchmaker/globvar.cpp
engines/watchmaker/globvar.h
engines/watchmaker/ll/ll_regen.cpp
engines/watchmaker/ll/ll_regen.h
engines/watchmaker/ll/ll_string.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/ll/ll_util.h
engines/watchmaker/main.cpp
engines/watchmaker/module.mk
engines/watchmaker/renderer.cpp
engines/watchmaker/renderer.h
engines/watchmaker/struct.h
engines/watchmaker/t2d/t2d.cpp
engines/watchmaker/walk/ball.cpp
diff --git a/engines/watchmaker/2d_stuff.cpp b/engines/watchmaker/2d_stuff.cpp
new file mode 100644
index 00000000000..729e19df639
--- /dev/null
+++ b/engines/watchmaker/2d_stuff.cpp
@@ -0,0 +1,187 @@
+/* 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 "watchmaker/2d_stuff.h"
+#include "watchmaker/fonts.h"
+#include "watchmaker/renderer.h"
+
+namespace Watchmaker {
+
+void TwoDeeStuff::writeBitmapListTo(SDDBitmap* target) {
+ memcpy(target, DDBitmapsList, sizeof(struct SDDBitmap)*MAX_DD_BITMAPS);
+}
+
+void TwoDeeStuff::garbageCollectPreRenderedText() {
+ // Destroys pre-rendered writings that are no longer needed
+ SDDText *r, *t;
+ int32 c, a;
+ for (c = 0, r = &RendText[0]; c < MAX_REND_TEXTS; c++, r++) {
+ if (!r->text[0]) continue;
+
+ for (a = 0, t = &DDTextsList[0]; a < MAX_DD_TEXTS; a++, t++) {
+ if (!t->text[0]) continue;
+
+ if (!strcmp(t->text, r->text) && (t->color == r->color) && (t->font == r->font))
+ break;
+ }
+ // If it should no longer be displayed
+ if (a >= MAX_DD_TEXTS) {
+ rReleaseBitmap(r->tnum);
+ memset(r, 0, sizeof(struct SDDText));
+ }
+ }
+}
+
+void TwoDeeStuff::clearBitmapList() {
+ int32 a;
+ SDDBitmap *b;
+ for (a = 0, b = &DDBitmapsList[0]; a < MAX_DD_BITMAPS; a++, b++) {
+ b->tnum = b->px = b->py = b->ox = b->oy = b->dx = b->dy = 0;
+ }
+}
+
+void TwoDeeStuff::clearTextList() {
+ int32 a;
+ SDDText *t;
+ for (a = 0, t = &DDTextsList[0]; a < MAX_DD_TEXTS; a++, t++) {
+ memset(t->text, 0, sizeof(t->text));
+ t->tnum = 0;
+ }
+}
+
+int32 TwoDeeStuff::findFreeBitmap() {
+ int32 a = 0;
+ for (a = 0; a < MAX_DD_BITMAPS; a++)
+ if (!DDBitmapsList[a].tnum)
+ return a;
+
+ warning("Too many DD Bitmaps!");
+ return -1;
+}
+
+void TwoDeeStuff::displayDDBitmap(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
+ int32 a = findFreeBitmap();
+ if (a == -1) {
+ warning("Skipping draw");
+ return;
+ }
+
+ DDBitmapsList[a].tnum = tnum;
+ DDBitmapsList[a].px = _renderer->rFitX(px);
+ DDBitmapsList[a].py = _renderer->rFitY(py);
+ DDBitmapsList[a].ox = _renderer->rFitX(px + ox) - _renderer->rFitX(px);
+ DDBitmapsList[a].oy = _renderer->rFitY(py + oy) - _renderer->rFitY(py);
+ DDBitmapsList[a].dx = _renderer->rFitX(px + dx) - _renderer->rFitX(px);
+ DDBitmapsList[a].dy = _renderer->rFitY(py + dy) - _renderer->rFitY(py);
+ if (dx <= 0) DDBitmapsList[a].dx += _renderer->getBitmapDimX(tnum) - DDBitmapsList[a].ox;
+ if (dy <= 0) DDBitmapsList[a].dy += _renderer->getBitmapDimY(tnum) - DDBitmapsList[a].oy;
+}
+
+void TwoDeeStuff::displayDDBitmap_NoFit(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
+ int32 a = findFreeBitmap();
+ if (a == -1) {
+ warning("Skipping draw");
+ return;
+ }
+
+ DDBitmapsList[a].tnum = tnum;
+ DDBitmapsList[a].px = (px);
+ DDBitmapsList[a].py = (py);
+ DDBitmapsList[a].ox = (px + ox) - (px);
+ DDBitmapsList[a].oy = (py + oy) - (py);
+ DDBitmapsList[a].dx = (px + dx) - (px);
+ DDBitmapsList[a].dy = (py + dy) - (py);
+ if (dx <= 0) DDBitmapsList[a].dx += _renderer->getBitmapDimX(tnum) - DDBitmapsList[a].ox;
+ if (dy <= 0) DDBitmapsList[a].dy += _renderer->getBitmapDimY(tnum) - DDBitmapsList[a].oy;
+}
+
+int32 TwoDeeStuff::rendDDText(char *text, FontKind font, FontColor color) {
+ struct SDDText *r;
+ int32 c, tdx, tdy;
+ char info[100];
+
+ if ((!text) || (text[0] == '\0')) return -1;
+
+ for (c = 0, r = &RendText[0]; c < MAX_REND_TEXTS; c++, r++) {
+ if (r->text[0]) continue;
+ // Get the size of the text to render
+ _renderer->_fonts->getTextDim(text, font, &tdx, &tdy);
+ // Create a surface to contain it
+ r->tnum = rCreateSurface(tdx, tdy, rBITMAPSURFACE);
+ _renderer->clearBitmap(r->tnum, 0, 0, tdx, tdy, 0, 0, 0);
+ // Render the lettering on the surface
+ //DebugLogWindow("Creo testo %s | %d %d",text,tdx,tdy );
+ _renderer->printText(text, r->tnum, font, color, 0, 0);
+ Common::strlcpy(info, "text: ", sizeof(info));
+ strncat(info, text, 15);
+ //DebugLogWindow("Creato %s",info);
+ rSetBitmapName(r->tnum, info);
+ Common::strlcpy(r->text, text, sizeof(r->text));
+ r->color = color;
+ r->font = font;
+ return r->tnum;
+ }
+
+ return -1;
+}
+
+void TwoDeeStuff::displayDDText(char *text, FontKind font, FontColor color, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
+ struct SDDText *t, *r;
+ int32 a, c;
+
+ if ((!text) || (text[0] == '\0')) return;
+
+ for (a = 0; a < MAX_DD_TEXTS; a++)
+ if (!DDTextsList[a].text[0])
+ break;
+
+ if (a >= MAX_DD_TEXTS) {
+ warning("Too many DD Texts!");
+ return ;
+ }
+
+ DDTextsList[a] = SDDText(text, font, color, -1);
+
+ t = &DDTextsList[a];
+ // Try searching the pre-rendered scripts
+ for (c = 0, r = &RendText[0]; c < MAX_REND_TEXTS; c++, r++) {
+ if (!r->text[0]) continue;
+
+ if (!strcmp(t->text, r->text) && (t->color == r->color) && (t->font == r->font)) {
+ this->displayDDBitmap(r->tnum, px, py, ox, oy, dx, dy);
+ break;
+ }
+ }
+ // if I didn't prerender the script, I render it now
+ if (c >= MAX_REND_TEXTS) {
+ /* if( ( r->tnum = RendDDText( t->text, t->font, t->color ) ) > 0 )
+ // Add the bitmap with pre-rendered lettering to display
+ DisplayDDBitmap( r->tnum, px, py, ox, oy, dx, dy );*/
+
+ int32 tn;
+ if ((tn = rendDDText(t->text, t->font, t->color)) > 0)
+ // Add the bitmap with pre-rendered lettering to display
+ this->displayDDBitmap(tn, px, py, ox, oy, dx, dy);
+ }
+}
+
+
+} // End of namespace Watchmaker
\ No newline at end of file
diff --git a/engines/watchmaker/2d_stuff.h b/engines/watchmaker/2d_stuff.h
new file mode 100644
index 00000000000..c572f235743
--- /dev/null
+++ b/engines/watchmaker/2d_stuff.h
@@ -0,0 +1,59 @@
+/* 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 WATCHMAKER_2D_STUFF_H
+#define WATCHMAKER_2D_STUFF_H
+
+#include "watchmaker/sysdef.h"
+#include "watchmaker/t3d.h"
+#include "watchmaker/types.h"
+#include "watchmaker/struct.h"
+
+namespace Watchmaker {
+
+class Renderer;
+
+class TwoDeeStuff {
+ SDDBitmap DDBitmapsList[MAX_DD_BITMAPS];
+ SDDText DDTextsList[MAX_DD_TEXTS];
+ SDDText RendText[MAX_REND_TEXTS];
+
+ Renderer *_renderer;
+public:
+ TwoDeeStuff(Renderer *renderer) : _renderer(renderer) {}
+ void writeBitmapListTo(SDDBitmap* target);
+ void garbageCollectPreRenderedText();
+
+ void clearBitmapList();
+ void clearTextList();
+
+ int32 findFreeBitmap();
+
+ void displayDDBitmap(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
+ void displayDDBitmap_NoFit(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
+ void displayDDText(char *text, FontKind font, FontColor color, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
+private:
+ int32 rendDDText(char *text, FontKind font, FontColor color);
+};
+
+} // End of namespace Watchmaker
+
+#endif // SCUMMVM_2D_STUFF_H
diff --git a/engines/watchmaker/classes/do_dialog.cpp b/engines/watchmaker/classes/do_dialog.cpp
index d60fbd62e5f..575fff49dfd 100644
--- a/engines/watchmaker/classes/do_dialog.cpp
+++ b/engines/watchmaker/classes/do_dialog.cpp
@@ -502,9 +502,9 @@ void PaintDialog(WGame &game) {
if ((bDialogActive == FALSE) || (CurDialog == dNULL) || (bDialogMenuActive == FALSE))
return ;
- DisplayDDBitmap(*game._renderer, ConsoleD1, 7, 366, 0, 0, 0, 0);
+ game._renderer->_2dStuff.displayDDBitmap(ConsoleD1, 7, 366, 0, 0, 0, 0);
DisplayD3DRect(*game._renderer, 15, 373, 187, 211, 18, 25, 18, 128);
- DisplayDDBitmap(*game._renderer, ConsoleD2, 223, 515, 0, 0, 0, 0);
+ game._renderer->_2dStuff.displayDDBitmap(ConsoleD2, 223, 515, 0, 0, 0, 0);
DisplayD3DRect(*game._renderer, 223 + 6, 515 + 6, 536, 62, 18, 25, 18, 128);
DisplayD3DRect(*game._renderer, 223 + 546, 515 + 22, 16, 30, 18, 25, 18, 128);
DisplayD3DRect(*game._renderer, 223 + 542, 515 + 18, 4, 38, 18, 25, 18, 128);
@@ -532,16 +532,16 @@ void PaintDialog(WGame &game) {
}
if (CurDlgItem == a) tc = RED_FONT;
- DisplayDDText(*game._renderer, Sentence[init.DlgMenu[a].titolo], FontKind::Standard, tc, tx, ty, 0, 0, 0, 0);
+ game._renderer->_2dStuff.displayDDText(Sentence[init.DlgMenu[a].titolo], FontKind::Standard, tc, tx, ty, 0, 0, 0, 0);
}
// disegno le frecce
if (Diag2Base > 0)
- DisplayDDBitmap(*game._renderer, ConsoleFrecciaSu, 223 + 550, 515 + 0, 0, 0, 0, 0);
+ game._renderer->_2dStuff.displayDDBitmap(ConsoleFrecciaSu, 223 + 550, 515 + 0, 0, 0, 0, 0);
if ((Diag2Base + 1 + MAX_DIAG2_ITEMS) <= ca2)
- DisplayDDBitmap(*game._renderer, ConsoleFrecciaGiu, 223 + 550, 515 + 56, 0, 0, 0, 0);
+ game._renderer->_2dStuff.displayDDBitmap(ConsoleFrecciaGiu, 223 + 550, 515 + 56, 0, 0, 0, 0);
}
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index bfc2e0ff2bf..3e784f1cf4e 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -304,7 +304,7 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
ye = 0;
if ((c->py + c->dy) > end_y) ye = (c->py + c->dy) - end_y;
- DisplayDDBitmap_NoFit(*game._renderer, c->tnum, c->px, c->py - TitoliCoda_Y, 0, ys, c->dx, c->dy - ys - ye);
+ game._renderer->_2dStuff.displayDDBitmap_NoFit(c->tnum, c->px, c->py - TitoliCoda_Y, 0, ys, c->dx, c->dy - ys - ye);
}
}//for
@@ -472,7 +472,7 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
}
if (c->tnum != -1)
- DisplayDDBitmap_NoFit(*game._renderer, c->tnum, c->px, c->py, 0, 0, c->dx, c->dy);
+ game._renderer->_2dStuff.displayDDBitmap_NoFit(c->tnum, c->px, c->py, 0, 0, c->dx, c->dy);
}//for
if (TitoliCoda_NumDeleted == TitoliCoda_NumEntries) {
@@ -505,11 +505,11 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
void PaintIntroText(Renderer &renderer) {
if (T1t) {
DisplayD3DRect(renderer, rT1.px, rT1.py, rT1.dx, rT1.dy, rT1.r, rT1.g, rT1.b, rT1.a);
- DisplayDDText(renderer, T1t, FontKind::Computer, CYAN_FONT, T1.px, T1.py, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDText(T1t, FontKind::Computer, CYAN_FONT, T1.px, T1.py, 0, 0, 0, 0);
}
if (T2t) {
DisplayD3DRect(renderer, rT2.px, rT2.py, rT2.dx, rT2.dy, rT2.r, rT2.g, rT2.b, rT2.a);
- DisplayDDText(renderer, T2t, FontKind::Computer, CYAN_FONT, T2.px, T2.py, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDText(T2t, FontKind::Computer, CYAN_FONT, T2.px, T2.py, 0, 0, 0, 0);
}
}
@@ -952,7 +952,7 @@ void doSystem(WGame &game) {
if (RoomInfo.t_next_letter < 0) RoomInfo.t_next_letter = 0;
RoomInfo.letter_ptr ++;
}
- DisplayDDBitmap_NoFit(*game._renderer, RoomInfo.tnum, RoomInfo.px, RoomInfo.py, 0, 0, RoomInfo._dx, RoomInfo._dy);
+ game._renderer->_2dStuff.displayDDBitmap_NoFit(RoomInfo.tnum, RoomInfo.px, RoomInfo.py, 0, 0, RoomInfo._dx, RoomInfo._dy);
break;
case EFFECT_FADEIN_T1:
case EFFECT_FADEOUT_T1:
@@ -965,7 +965,7 @@ void doSystem(WGame &game) {
UpdateIntroText(TheMessage->bparam, TheMessage->wparam1, TheMessage->lparam[1], TheMessage->lparam[0]);
break;
case EFFECT_DISPLAY_NEWLOGIMG:
- DisplayDDBitmap(*game._renderer, NewLogImage, 800 - 60 - 8, 4, 0, 0, 0, 0);
+ game._renderer->_2dStuff.displayDDBitmap(NewLogImage, 800 - 60 - 8, 4, 0, 0, 0, 0);
break;
}
diff --git a/engines/watchmaker/extraLS.cpp b/engines/watchmaker/extraLS.cpp
index 0af10a1d403..50ecb73c095 100644
--- a/engines/watchmaker/extraLS.cpp
+++ b/engines/watchmaker/extraLS.cpp
@@ -101,7 +101,7 @@ void CheckExtraLocalizationStrings(Renderer &renderer, uint32 id) {
extraLS_currentID = newID;
}
- if (extraLS_BMP) DisplayDDBitmap(renderer, extraLS_BMP, extraLS_bmpPosX, extraLS_bmpPosY, 0, 0, 0, 0);
+ if (extraLS_BMP) renderer._2dStuff.displayDDBitmap(extraLS_BMP, extraLS_bmpPosX, extraLS_bmpPosY, 0, 0, 0, 0);
}
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/globvar.cpp b/engines/watchmaker/globvar.cpp
index 73c6d19e090..93fb42353f4 100644
--- a/engines/watchmaker/globvar.cpp
+++ b/engines/watchmaker/globvar.cpp
@@ -47,9 +47,6 @@ GameRect::GameRect() {
struct SD3DRect D3DRectsList[MAX_D3D_RECTS];
struct SD3DTriangle D3DTrianglesList[MAX_D3D_TRIANGLES];
struct SD3DBitmap D3DBitmapsList[MAX_D3D_BITMAPS];
-struct SDDBitmap DDBitmapsList[MAX_DD_BITMAPS];
-struct SDDText DDTextsList[MAX_DD_TEXTS];
-struct SDDText RendText[MAX_REND_TEXTS];
// 2D INTERFACE
int32 MainDx, MainDy, MainBpp;
diff --git a/engines/watchmaker/globvar.h b/engines/watchmaker/globvar.h
index 5c98166517d..447733776f3 100644
--- a/engines/watchmaker/globvar.h
+++ b/engines/watchmaker/globvar.h
@@ -49,9 +49,6 @@ struct GameRect {
extern struct SD3DRect D3DRectsList[];
extern struct SD3DTriangle D3DTrianglesList[];
extern struct SD3DBitmap D3DBitmapsList[];
-extern struct SDDBitmap DDBitmapsList[];
-extern struct SDDText DDTextsList[];
-extern struct SDDText RendText[];
// 2D INTERFACE
extern int32 MainDx, MainDy, MainBpp;
diff --git a/engines/watchmaker/ll/ll_regen.cpp b/engines/watchmaker/ll/ll_regen.cpp
index 85b6370dc38..f4038bc8f22 100644
--- a/engines/watchmaker/ll/ll_regen.cpp
+++ b/engines/watchmaker/ll/ll_regen.cpp
@@ -274,64 +274,39 @@ void AddPaintRect(int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx,
PaintRect[a].dy = (dy);
}
-/* -----------------27/10/98 17.14-------------------
- * Add2DStuff
- * --------------------------------------------------*/
-void Add2DStuff(WGame &game) {
- struct SDDBitmap *b;
- struct SDDText *t, *r;
- int32 cmx, cmy;
- int32 a, c;
- Renderer &renderer = *game._renderer;
-
- // Reset paint structure
- memset(PaintRect, 0, sizeof(PaintRect));
+void Renderer::add2DStuff() {
// Insert pre-calculated images and texts
- memcpy(PaintRect, DDBitmapsList, sizeof(struct SDDBitmap)*MAX_DD_BITMAPS);
-
- // Destroys pre-rendered writings that are no longer needed
- for (c = 0, r = &RendText[0]; c < MAX_REND_TEXTS; c++, r++) {
- if (!r->text[0]) continue;
+ _2dStuff.writeBitmapListTo(PaintRect);
- for (a = 0, t = &DDTextsList[0]; a < MAX_DD_TEXTS; a++, t++) {
- if (!t->text[0]) continue;
-
- if (!strcmp(t->text, r->text) && (t->color == r->color) && (t->font == r->font))
- break;
- }
- // If it should no longer be displayed
- if (a >= MAX_DD_TEXTS) {
- rReleaseBitmap(r->tnum);
- memset(r, 0, sizeof(struct SDDText));
- }
- }
+ _2dStuff.garbageCollectPreRenderedText();
// Put mouse over everything
if ((!mHide) && (CurDialog <= dSUPERVISORE) && (!bTitoliCodaStatic) && (!bTitoliCodaScrolling)) {
+ int32 cmx = mPosx - mHotspotX;
+ int32 cmy = mPosy - mHotspotY;
- cmx = mPosx - mHotspotX;
- cmy = mPosy - mHotspotY;
- if (cmx >= MousePointerLim.x2) cmx = MousePointerLim.x2 - 1;
- else if (cmx <= MousePointerLim.x1) cmx = MousePointerLim.x1 + 1;
- if (cmy >= MousePointerLim.y2) cmy = MousePointerLim.y2 - 1;
- else if (cmy <= MousePointerLim.y1) cmy = MousePointerLim.y1 + 1;
+ if (cmx >= MousePointerLim.x2)
+ cmx = MousePointerLim.x2 - 1;
+ else if (cmx <= MousePointerLim.x1)
+ cmx = MousePointerLim.x1 + 1;
+
+ if (cmy >= MousePointerLim.y2)
+ cmy = MousePointerLim.y2 - 1;
+ else if (cmy <= MousePointerLim.y1)
+ cmy = MousePointerLim.y1 + 1;
// Draw the current mouse pointer
if (CurMousePointer > 0)
- AddPaintRect(CurMousePointer, (cmx), (cmy), 0, 0, renderer.getBitmapDimX(CurMousePointer), renderer.getBitmapDimY(CurMousePointer));
+ AddPaintRect(CurMousePointer, (cmx), (cmy), 0, 0, this->getBitmapDimX(CurMousePointer), this->getBitmapDimY(CurMousePointer));
}
- Regen(game);
+ Regen(*_game);
- for (a = 0, b = &DDBitmapsList[0]; a < MAX_DD_BITMAPS; a++, b++)
- b->tnum = b->px = b->py = b->ox = b->oy = b->dx = b->dy = 0;
- for (a = 0, t = &DDTextsList[0]; a < MAX_DD_TEXTS; a++, t++) {
- memset(t->text, 0, sizeof(t->text));
- t->tnum = 0;
- }
+ _2dStuff.clearBitmapList();
+ _2dStuff.clearTextList();
//check
- CheckExtraLocalizationStrings(*game._renderer, 0);
+ CheckExtraLocalizationStrings(*this, 0);
}
/* -----------------27/10/98 17.14-------------------
diff --git a/engines/watchmaker/ll/ll_regen.h b/engines/watchmaker/ll/ll_regen.h
index ccd47ab5dbc..c6f69052586 100644
--- a/engines/watchmaker/ll/ll_regen.h
+++ b/engines/watchmaker/ll/ll_regen.h
@@ -28,7 +28,6 @@ class WGame;
void ResetScreenBuffer();
void AfterRender(WGame &game);
-void Add2DStuff(WGame &game);
void Add3DStuff(WGame &game);
} // End of namespace Watchmaker
diff --git a/engines/watchmaker/ll/ll_string.cpp b/engines/watchmaker/ll/ll_string.cpp
index b0224b53905..c2ca73b6a6a 100644
--- a/engines/watchmaker/ll/ll_string.cpp
+++ b/engines/watchmaker/ll/ll_string.cpp
@@ -226,7 +226,7 @@ void PaintText(WGame &game) {
break;
}
}
- DisplayDDText(*game._renderer, TextLines[i], FontKind::Standard, color, TheString.x + dx, TheString.y + i * 12, 0, 0, 0, 0);
+ game._renderer->_2dStuff.displayDDText(TextLines[i], FontKind::Standard, color, TheString.x + dx, TheString.y + i * 12, 0, 0, 0, 0);
}
}
}
@@ -244,22 +244,22 @@ void PaintInventory(WGame &game) {
DisplayD3DRect(renderer, 27, 77, 188, 490, 18, 25, 18, 128);
DisplayD3DRect(renderer, 13, 124, 14, 49, 18, 25, 18, 128);
DisplayD3DRect(renderer, 215, 472, 12, 50, 18, 25, 18, 128);
- DisplayDDBitmap(renderer, Console1, 3, 73, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(Console1, 3, 73, 0, 0, 0, 0);
if (InvLen[CurPlayer] > MAX_SHOWN_ICONS) {
if (InvBase[CurPlayer] > 0)
- DisplayDDBitmap(renderer, ConsoleFrecciaSu, 3 + 14, 73 + 66, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(ConsoleFrecciaSu, 3 + 14, 73 + 66, 0, 0, 0, 0);
if (InvBase[CurPlayer] < (InvLen[CurPlayer] - MAX_SHOWN_ICONS))
- DisplayDDBitmap(renderer, ConsoleFrecciaGiu, 3 + 206, 73 + 416, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(ConsoleFrecciaGiu, 3 + 206, 73 + 416, 0, 0, 0, 0);
}
}
if ((InvStatus & INV_MODE1) && PlayerCanCall(game._gameVars)) {
if (CurPlayer == VICTORIA)
- DisplayDDBitmap(renderer, Console5, 22, 13, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(Console5, 22, 13, 0, 0, 0, 0);
else
- DisplayDDBitmap(renderer, Console6, 22, 13, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(Console6, 22, 13, 0, 0, 0, 0);
}
if ((InvStatus & INV_MODE2) || (bT2DActive == tOPTIONS)) {
@@ -274,18 +274,18 @@ void PaintInventory(WGame &game) {
}
if (CurPlayer == DARRELL)
- DisplayDDBitmap(renderer, Console3, 22 + console_3_4_xoffs, 13, ox, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(Console3, 22 + console_3_4_xoffs, 13, ox, 0, 0, 0);
else
- DisplayDDBitmap(renderer, Console4, 22 + console_3_4_xoffs, 13, ox, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(Console4, 22 + console_3_4_xoffs, 13, ox, 0, 0, 0);
if (!PlayerCanSave())
- DisplayDDBitmap(renderer, ConsoleNoSave, 227 + 22 + console_3_4_xoffs, 13, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(ConsoleNoSave, 227 + 22 + console_3_4_xoffs, 13, 0, 0, 0, 0);
if ((bT2DActive != tOPTIONS) && (!PlayerCanSwitch(game._gameVars, 0))) {
if (CurPlayer == DARRELL)
- DisplayDDBitmap(renderer, ConsoleNoSwitchDar, 61 + 22 + console_3_4_xoffs, 13, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(ConsoleNoSwitchDar, 61 + 22 + console_3_4_xoffs, 13, 0, 0, 0, 0);
else
- DisplayDDBitmap(renderer, ConsoleNoSwitchVic, 61 + 22 + console_3_4_xoffs, 13, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(ConsoleNoSwitchVic, 61 + 22 + console_3_4_xoffs, 13, 0, 0, 0, 0);
}
}
@@ -293,16 +293,16 @@ void PaintInventory(WGame &game) {
for (a = 0; a < MAX_SHOWN_ICONS; a++) {
if (ci = Inv[CurPlayer][InvBase[CurPlayer] + a]) {
if (CurInvObj == ci)
- DisplayDDText(renderer, ObjName[init.InvObj[ci].name], FontKind::Standard, RED_FONT, INV_MARG_SX, INV_MARG_UP + ICON_DY * a, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDText(ObjName[init.InvObj[ci].name], FontKind::Standard, RED_FONT, INV_MARG_SX, INV_MARG_UP + ICON_DY * a, 0, 0, 0, 0);
else
- DisplayDDText(renderer, ObjName[init.InvObj[ci].name], FontKind::Standard, WHITE_FONT, INV_MARG_SX, INV_MARG_UP + ICON_DY * a, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDText(ObjName[init.InvObj[ci].name], FontKind::Standard, WHITE_FONT, INV_MARG_SX, INV_MARG_UP + ICON_DY * a, 0, 0, 0, 0);
}
}
}
} else if ((bUseWith & UW_ON) && (bUseWith & UW_USEDI)) {
DisplayD3DRect(renderer, game._gameRect._useIconRect.x1 + 3, game._gameRect._useIconRect.y1 + 3, 63, 63, 22, 31, 22, 75);
- DisplayDDBitmap(renderer, IconsPics[UseWith[USED]], game._gameRect._useIconRect.x1 + 3, game._gameRect._useIconRect.y1 + 3, 0, 0, 0, 0);
- DisplayDDBitmap(renderer, Console2, game._gameRect._useIconRect.x1, game._gameRect._useIconRect.y1, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(IconsPics[UseWith[USED]], game._gameRect._useIconRect.x1 + 3, game._gameRect._useIconRect.y1 + 3, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDBitmap(Console2, game._gameRect._useIconRect.x1, game._gameRect._useIconRect.y1, 0, 0, 0, 0);
}
PaintDialog(game);
}
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index a82cddbc411..3347c5140d2 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -676,136 +676,6 @@ void DisplayD3DRect(Renderer &renderer, int32 px, int32 py, int32 dx, int32 dy,
D3DRectsList[a].a = al;
}
-/* -----------------24/04/98 10.33-------------------
- * DisplayDDBitmap
- * --------------------------------------------------*/
-void DisplayDDBitmap(Renderer &renderer, int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
- int32 a;
- for (a = 0; a < MAX_DD_BITMAPS; a++)
- if (!DDBitmapsList[a].tnum)
- break;
-
- if (a >= MAX_DD_BITMAPS) {
- warning("Too many DD Bitmaps!");
- return ;
- }
-
- DDBitmapsList[a].tnum = tnum;
- DDBitmapsList[a].px = renderer.rFitX(px);
- DDBitmapsList[a].py = renderer.rFitY(py);
- DDBitmapsList[a].ox = renderer.rFitX(px + ox) - renderer.rFitX(px);
- DDBitmapsList[a].oy = renderer.rFitY(py + oy) - renderer.rFitY(py);
- DDBitmapsList[a].dx = renderer.rFitX(px + dx) - renderer.rFitX(px);
- DDBitmapsList[a].dy = renderer.rFitY(py + dy) - renderer.rFitY(py);
- if (dx <= 0) DDBitmapsList[a].dx += renderer.getBitmapDimX(tnum) - DDBitmapsList[a].ox;
- if (dy <= 0) DDBitmapsList[a].dy += renderer.getBitmapDimY(tnum) - DDBitmapsList[a].oy;
-}
-
-/* -----------------22/11/00 12.15-------------------
- * DisplayDDBitmap_NoFit
- * --------------------------------------------------*/
-void DisplayDDBitmap_NoFit(Renderer &renderer, int32 tnum, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
- int32 a;
- for (a = 0; a < MAX_DD_BITMAPS; a++)
- if (!DDBitmapsList[a].tnum)
- break;
-
- if (a >= MAX_DD_BITMAPS) {
- warning("Too many DD Bitmaps!");
- return ;
- }
-
- DDBitmapsList[a].tnum = tnum;
- DDBitmapsList[a].px = (px);
- DDBitmapsList[a].py = (py);
- DDBitmapsList[a].ox = (px + ox) - (px);
- DDBitmapsList[a].oy = (py + oy) - (py);
- DDBitmapsList[a].dx = (px + dx) - (px);
- DDBitmapsList[a].dy = (py + dy) - (py);
- if (dx <= 0) DDBitmapsList[a].dx += renderer.getBitmapDimX(tnum) - DDBitmapsList[a].ox;
- if (dy <= 0) DDBitmapsList[a].dy += renderer.getBitmapDimY(tnum) - DDBitmapsList[a].oy;
-}
-
-/* -----------------15/11/00 12.16-------------------
- * RendDDText
- * --------------------------------------------------*/
-int32 RendDDText(Renderer &renderer, char *text, FontKind font, FontColor color) {
- struct SDDText *r;
- int32 c, tdx, tdy;
- char info[100];
-
- if ((!text) || (text[0] == '\0')) return -1;
-
- for (c = 0, r = &RendText[0]; c < MAX_REND_TEXTS; c++, r++) {
- if (r->text[0]) continue;
-// Prende dimesioni della scritta da renderizzare
- renderer._fonts->getTextDim(text, font, &tdx, &tdy);
-// Crea una surface che la contenga
- r->tnum = rCreateSurface(tdx, tdy, rBITMAPSURFACE);
- renderer.clearBitmap(r->tnum, 0, 0, tdx, tdy, 0, 0, 0);
-// Renderizza la scritta nella surface
-//DebugLogWindow("Creo testo %s | %d %d",text,tdx,tdy );
- renderer.printText(text, r->tnum, font, color, 0, 0);
- strcpy(info, "text: ");
- strncat(info, text, 15);
-//DebugLogWindow("Creato %s",info);
- rSetBitmapName(r->tnum, info);
- strcpy(r->text, text);
- r->color = color;
- r->font = font;
- return r->tnum;
- }
-
- return -1;
-}
-
-/* -----------------24/04/98 10.33-------------------
- * DisplayDDText
- * --------------------------------------------------*/
-void DisplayDDText(Renderer &renderer, char *text, FontKind font, FontColor color, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy) {
- struct SDDText *t, *r;
- int32 a, c;
-
- if ((!text) || (text[0] == '\0')) return;
-
- for (a = 0; a < MAX_DD_TEXTS; a++)
- if (!DDTextsList[a].text[0])
- break;
-
- if (a >= MAX_DD_TEXTS) {
- warning("Too many DD Texts!");
- return ;
- }
-
- strcpy(DDTextsList[a].text, text);
- DDTextsList[a].tnum = -1;
- DDTextsList[a].font = font;
- DDTextsList[a].color = color;
-
- t = &DDTextsList[a];
-// Prova a cercare tra le scritte prenrenderizzate
- for (c = 0, r = &RendText[0]; c < MAX_REND_TEXTS; c++, r++) {
- if (!r->text[0]) continue;
-
- if (!strcmp(t->text, r->text) && (t->color == r->color) && (t->font == r->font)) {
- DisplayDDBitmap(renderer, r->tnum, px, py, ox, oy, dx, dy);
- break;
- }
- }
-// se non ho prerenderizzato la scritta, la renderizzo ora
- if (c >= MAX_REND_TEXTS) {
- /* if( ( r->tnum = RendDDText( t->text, t->font, t->color ) ) > 0 )
- // Aggiunge il bitmap con la scritta pre-renderizzata da visualizzare
- DisplayDDBitmap( r->tnum, px, py, ox, oy, dx, dy );*/
-
- int32 tn;
- if ((tn = RendDDText(renderer, t->text, t->font, t->color)) > 0)
-// Aggiunge il bitmap con la scritta pre-renderizzata da visualizzare
- DisplayDDBitmap(renderer, tn, px, py, ox, oy, dx, dy);
- }
-}
-
-
/* -----------------15/01/99 18.15-------------------
* GetDDBitmapExtends
* --------------------------------------------------*/
@@ -834,7 +704,7 @@ void DebugVideo(Renderer &renderer, int32 px, int32 py, const char *format, ...)
vsprintf(str, format, args);
va_end(args);
- DisplayDDText(renderer, str, FontKind::Standard, WHITE_FONT, px, py, 0, 0, 0, 0);
+ renderer._2dStuff.displayDDText(str, FontKind::Standard, WHITE_FONT, px, py, 0, 0, 0, 0);
// rPrintText( str, 0, StandardFont.Color[WHITE_FONT], StandardFont.Table, px, py );
}
diff --git a/engines/watchmaker/ll/ll_util.h b/engines/watchmaker/ll/ll_util.h
index cc1e7469585..2718890a16f 100644
--- a/engines/watchmaker/ll/ll_util.h
+++ b/engines/watchmaker/ll/ll_util.h
@@ -45,7 +45,6 @@ void UpdateRoomInfo(WGame &game);
bool CheckRect(Renderer &renderer, struct SRect p, int32 cmx, int32 cmy);
void DisplayD3DTriangle(Renderer &, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, uint8 r, uint8 g, uint8 b, uint8 al);
void DisplayD3DRect(Renderer &, int32 px, int32 py, int32 dx, int32 dy, uint8 r, uint8 g, uint8 b, uint8 al);
-void DisplayDDText(Renderer &, char *text, FontKind font, FontColor color, int32 px, int32 py, int32 ox, int32 oy, int32 dx, int32 dy);
int32 CreateTooltipBitmap(Renderer &renderer, char *tooltip, FontColor color, uint8 r, uint8 g, uint8 b);
int32 WhatObj(WGame &game, int32 mx, int32 my, uint8 op);
void DebugVideo(Renderer &renderer, int32 px, int32 py, const char *format, ...);
diff --git a/engines/watchmaker/main.cpp b/engines/watchmaker/main.cpp
index 5b640b40399..34d754e32b5 100644
--- a/engines/watchmaker/main.cpp
+++ b/engines/watchmaker/main.cpp
@@ -242,7 +242,7 @@ void Render3DEnvironment(WGame &game) {
rRenderScene(); // Stampa triangoli
- Add2DStuff(game); // Aggiunge layer 2D
+ game._renderer->add2DStuff(); // Aggiunge layer 2D
game._renderer->showFrame(); // Visualizza il frame
}
diff --git a/engines/watchmaker/module.mk b/engines/watchmaker/module.mk
index b65ef08343a..6bc8ca25795 100644
--- a/engines/watchmaker/module.mk
+++ b/engines/watchmaker/module.mk
@@ -63,6 +63,7 @@ MODULE_OBJS = \
walk/walk.o \
walk/walkutil.o \
\
+ 2d_stuff.o \
console.o \
extraLS.o \
file_utils.o \
diff --git a/engines/watchmaker/renderer.cpp b/engines/watchmaker/renderer.cpp
index a5a1f5f693e..028ac16a0ea 100644
--- a/engines/watchmaker/renderer.cpp
+++ b/engines/watchmaker/renderer.cpp
@@ -40,7 +40,7 @@
namespace Watchmaker {
-Renderer::Renderer(WGame *game, sdl_wrapper *wrapper) : sdl(wrapper), _game(game) {
+Renderer::Renderer(WGame *game, sdl_wrapper *wrapper) : _2dStuff(this), sdl(wrapper), _game(game) {
_workDirs = &game->workDirs;
}
diff --git a/engines/watchmaker/renderer.h b/engines/watchmaker/renderer.h
index d1c18d3dc58..ac5a33b68cd 100644
--- a/engines/watchmaker/renderer.h
+++ b/engines/watchmaker/renderer.h
@@ -23,12 +23,13 @@
#define WATCHMAKER_RENDERER_H
#include "math/matrix4.h"
-#include "watchmaker/utils.h"
+#include "watchmaker/2d_stuff.h"
+#include "watchmaker/rect.h"
#include "watchmaker/sdl_wrapper.h"
-#include "watchmaker/types.h"
#include "watchmaker/struct.h"
+#include "watchmaker/types.h"
+#include "watchmaker/utils.h"
#include "watchmaker/work_dirs.h"
-#include "watchmaker/rect.h"
namespace Watchmaker {
@@ -45,6 +46,8 @@ class Renderer {
WorkDirs *_workDirs;
WGame *_game;
public:
+ TwoDeeStuff _2dStuff;
+
Fonts *_fonts = nullptr;
Rect _viewport;
Renderer(WGame *game, sdl_wrapper *wrapper);
@@ -87,6 +90,8 @@ public:
bool setProjectionMatrix(float width, float height, float fAspect, float fNearPlane, float fFarPlane);
Math::Vector3d screenSpaceToCameraSpace(float x, float y);
+
+ void add2DStuff();
private:
sdl_wrapper *sdl;
// aspect correction
diff --git a/engines/watchmaker/struct.h b/engines/watchmaker/struct.h
index 831ae7533b7..fb0b7d034c2 100644
--- a/engines/watchmaker/struct.h
+++ b/engines/watchmaker/struct.h
@@ -439,6 +439,12 @@ struct SDDBitmap {
enum class FontKind;
struct SDDText {
+ SDDText() = default;
+ SDDText(const char *text, FontKind font, FontColor color, int32 tnum) : font(font),
+ color(color),
+ tnum(tnum) {
+ Common::strlcpy(this->text, text, sizeof(this->text));
+ }
char text[MAX_STRING_LEN] = {};
FontKind font; // TODO: Move elsewhere so we can initalize
FontColor color;
diff --git a/engines/watchmaker/t2d/t2d.cpp b/engines/watchmaker/t2d/t2d.cpp
index bbf866a89af..79d0903d0a4 100644
--- a/engines/watchmaker/t2d/t2d.cpp
+++ b/engines/watchmaker/t2d/t2d.cpp
@@ -837,10 +837,10 @@ void PaintT2D(Renderer &renderer) {
if (w->bm[i].tnum & T2D_BM2TEXT_MASK) {
j = ((w->bm[i].tnum & T2D_BM2TEXT_MASK) >> T2D_BM2TEXT_SHIFT);
- DisplayDDText(renderer, w->text[j].text, w->text[j].font, w->text[j].color,
+ renderer._2dStuff.displayDDText(w->text[j].text, w->text[j].font, w->text[j].color,
w->bm[i].px + w->px, w->bm[i].py + w->py, w->bm[i].ox, w->bm[i].oy, w->bm[i].dx, w->bm[i].dy);
} else
- DisplayDDBitmap(renderer, w->bm[i].tnum, w->bm[i].px + w->px, w->bm[i].py + w->py, w->bm[i].ox, w->bm[i].oy, w->bm[i].dx, w->bm[i].dy);
+ renderer._2dStuff.displayDDBitmap(w->bm[i].tnum, w->bm[i].px + w->px, w->bm[i].py + w->py, w->bm[i].ox, w->bm[i].oy, w->bm[i].dx, w->bm[i].dy);
}
}
diff --git a/engines/watchmaker/walk/ball.cpp b/engines/watchmaker/walk/ball.cpp
index 6aaf6f6f2e9..d707193e5fe 100644
--- a/engines/watchmaker/walk/ball.cpp
+++ b/engines/watchmaker/walk/ball.cpp
@@ -244,13 +244,13 @@ void UpdateBall(WGame &game, struct SPhys *p) {
DisplayD3DTriangle(*game._renderer, p->ViewCone.x1, p->ViewCone.y1, p->ViewCone.x2, p->ViewCone.y2, p->ViewCone.x3, p->ViewCone.y3, 125, 125, 125, 125);
// Aggiorna la mappa e le scritte
- DisplayDDBitmap(*game._renderer, GopherMap, windowInfo.width - renderer.getBitmapRealDimX(GopherMap), 0, 0, 0, 0, 0);
+ game._renderer->_2dStuff.displayDDBitmap(GopherMap, windowInfo.width - renderer.getBitmapRealDimX(GopherMap), 0, 0, 0, 0, 0);
for (i = 0; i < MAX_GOPHERS; i++)
- DisplayDDBitmap(*game._renderer, GopherPos[i], windowInfo.width - renderer.getBitmapRealDimX(GopherMap) +
+ game._renderer->_2dStuff.displayDDBitmap(GopherPos[i], windowInfo.width - renderer.getBitmapRealDimX(GopherMap) +
130 + (int32)(Character[i + 1]->Mesh->Trasl.x / 255.0f * 0.341f) - renderer.getBitmapRealDimX(GopherPos[i]) / 2,
146 - (int32)(Character[i + 1]->Mesh->Trasl.z / 255.0f * 0.341f) - renderer.getBitmapRealDimY(GopherPos[i]) / 2, 0, 0, 0, 0);
if (bGolfMode)
- DisplayDDBitmap(*game._renderer, GopherBall, windowInfo.width - renderer.getBitmapRealDimX(GopherMap) +
+ game._renderer->_2dStuff.displayDDBitmap(GopherBall, windowInfo.width - renderer.getBitmapRealDimX(GopherMap) +
130 + (int32)(Palla50->Mesh->Trasl.x / 255.0f * 0.341f) - renderer.getBitmapRealDimX(GopherBall) / 2,
146 - (int32)(Palla50->Mesh->Trasl.z / 255.0f * 0.341f) - renderer.getBitmapRealDimY(GopherBall) / 2, 0, 0, 0, 0);
if ((bGolfMode == 0) || (bGolfMode == 1)) {
@@ -263,7 +263,7 @@ void UpdateBall(WGame &game, struct SPhys *p) {
DebugVideo(*game._renderer, 10, 48, "Angle: %d %d", 45 - (int)(Ball[CurGopher].Angle.x * 180.0f / T3D_PI), (int)(Ball[CurGopher].Angle.y * 180.0f / T3D_PI));
DebugVideo(*game._renderer, 10, 64, "Power: %d", (int)Ball[CurGopher].Angle.z);
}
- DisplayDDBitmap(*game._renderer, EndPic, windowInfo.width - renderer.getBitmapRealDimX(EndPic) - 20, windowInfo.height - renderer.getBitmapRealDimY(EndPic) - 20, 0, 0, 0, 0);
+ game._renderer->_2dStuff.displayDDBitmap(EndPic, windowInfo.width - renderer.getBitmapRealDimX(EndPic) - 20, windowInfo.height - renderer.getBitmapRealDimY(EndPic) - 20, 0, 0, 0, 0);
// Aggiorna la camera
ProcessGopherCamera(game);
Commit: be9dba7ee02547b38bc13e6173660f53db4cc572
https://github.com/scummvm/scummvm/commit/be9dba7ee02547b38bc13e6173660f53db4cc572
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Avoid global constructors in CheckExtraLocalizationStrings
Changed paths:
engines/watchmaker/extraLS.cpp
engines/watchmaker/struct.h
diff --git a/engines/watchmaker/extraLS.cpp b/engines/watchmaker/extraLS.cpp
index 50ecb73c095..4d087f034c5 100644
--- a/engines/watchmaker/extraLS.cpp
+++ b/engines/watchmaker/extraLS.cpp
@@ -37,13 +37,13 @@ uint32 extraLS_currentID = 0;
int32 extraLS_bmpPosX = 0;
int32 extraLS_bmpPosY = 0;
-struct SRect Console3Save = { 228 + 22, 11 + 15, 277 + 22, 30 + 15 };
-struct SRect Console3Load = { 340 + 22, 11 + 15, 396 + 22, 30 + 15 };
-struct SRect Console3Options = { 444 + 22, 11 + 15, 527 + 22, 30 + 15 };
-struct SRect Console3Quit = { 565 + 22, 11 + 15, 613 + 22, 30 + 15 };
-struct SRect Console3Close = { 665 + 22, 11 + 15, 724 + 22, 30 + 15 };
-
void CheckExtraLocalizationStrings(Renderer &renderer, uint32 id) {
+ static constexpr SRect Console3Save = { 228 + 22, 11 + 15, 277 + 22, 30 + 15 };
+ static constexpr SRect Console3Load = { 340 + 22, 11 + 15, 396 + 22, 30 + 15 };
+ static constexpr SRect Console3Options = { 444 + 22, 11 + 15, 527 + 22, 30 + 15 };
+ static constexpr SRect Console3Quit = { 565 + 22, 11 + 15, 613 + 22, 30 + 15 };
+ static constexpr SRect Console3Close = { 665 + 22, 11 + 15, 724 + 22, 30 + 15 };
+
uint32 newID = 0;
if (!bShowExtraLocalizationStrings) {
diff --git a/engines/watchmaker/struct.h b/engines/watchmaker/struct.h
index fb0b7d034c2..3a4ebec4fe4 100644
--- a/engines/watchmaker/struct.h
+++ b/engines/watchmaker/struct.h
@@ -415,8 +415,8 @@ struct SString {
struct SRect {
int32 x1 = 0, y1 = 0, x2 = 0, y2 = 0;
- SRect() = default;
- SRect(int32 x1, int32 y1, int32 x2, int32 y2): x1(x1), y1(y1), x2(x2), y2(y2) {}
+ constexpr SRect() = default;
+ constexpr SRect(int32 x1, int32 y1, int32 x2, int32 y2): x1(x1), y1(y1), x2(x2), y2(y2) {}
};
struct SD3DRect {
Commit: acaca3e1b10c1c3042d67f0904d0cd695bfa5b5a
https://github.com/scummvm/scummvm/commit/acaca3e1b10c1c3042d67f0904d0cd695bfa5b5a
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Make t3dV3F's constructor constexpr to reduce global constructors
Changed paths:
engines/watchmaker/3d/types3d.h
diff --git a/engines/watchmaker/3d/types3d.h b/engines/watchmaker/3d/types3d.h
index 416080139d1..b6dbf22a30f 100644
--- a/engines/watchmaker/3d/types3d.h
+++ b/engines/watchmaker/3d/types3d.h
@@ -31,15 +31,15 @@ namespace Watchmaker {
struct t3dV2F {
t3dF32 x = 0.0f, y = 0.0f; // 2d Vector
public:
- t3dV2F() {}
- t3dV2F(float x, float y, float z) : x(x), y(y) {}
+ constexpr t3dV2F() = default;
+ constexpr t3dV2F(float x, float y, float z) : x(x), y(y) {}
};
struct t3dV3F {
t3dF32 x = 0.0f, y = 0.0f, z = 0.0f; // 3d vector
public:
- t3dV3F() {}
- t3dV3F(float x, float y, float z) : x(x), y(y), z(z) {}
+ constexpr t3dV3F() = default;
+ constexpr t3dV3F(float x, float y, float z) : x(x), y(y), z(z) {}
t3dV3F(const Math::Vector3d &vector) {
x = vector.x();
y = vector.y();
Commit: f6665b5d768991363ae360e3cc58a57d26ecc49e
https://github.com/scummvm/scummvm/commit/f6665b5d768991363ae360e3cc58a57d26ecc49e
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Make SString's constructor constexpr to avoid global constructors.
Changed paths:
engines/watchmaker/struct.h
diff --git a/engines/watchmaker/struct.h b/engines/watchmaker/struct.h
index 3a4ebec4fe4..c77a7d7df1f 100644
--- a/engines/watchmaker/struct.h
+++ b/engines/watchmaker/struct.h
@@ -405,7 +405,7 @@ struct SString {
char text[MAX_STRING_LEN] = {};
uint16 x = 0, y = 0, dx = 0;
- SString() = default;
+ constexpr SString() = default;
SString(const char *text, uint16 x = 0, uint16 y = 0, uint16 dx = 0) : x(x), y(y), dx(dx) {
if (text != nullptr) {
memcpy(this->text, text, strlen(text));
Commit: ce932f8b68e210574db0d879c7e157fd8f0debf9
https://github.com/scummvm/scummvm/commit/ce932f8b68e210574db0d879c7e157fd8f0debf9
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: zero-initialize WaterBuffer.
Currently the initialization of WaterBuffer is stubbed, so we get
a free() against an uninitialized pointer, which is dangerous.
Changed paths:
engines/watchmaker/3d/t3d_mesh.h
diff --git a/engines/watchmaker/3d/t3d_mesh.h b/engines/watchmaker/3d/t3d_mesh.h
index e48634e6b81..1ac0579a34a 100644
--- a/engines/watchmaker/3d/t3d_mesh.h
+++ b/engines/watchmaker/3d/t3d_mesh.h
@@ -62,7 +62,8 @@ struct t3dMESH {
uint8 LastBlendPercent = 0; // last blend animation percentage
uint32 ExpressionFrame = 0; // current expression frames
uint32 LastExpressionFrame = 0; // last expression frames
- int32 *WaterBuffer1, *WaterBuffer2; // pointers to ripple buffer
+ int32 *WaterBuffer1 = nullptr; // pointers to ripple buffer
+ int32 *WaterBuffer2 = nullptr; // pointers to ripple buffer
t3dF32 WavesSpeed; // waves speed
t3dF32 YSpeed; // waves y speed
t3dF32 XInc, YInc; // waves movements
Commit: 16137c5cf721938b86aba26baba252f37af6fb05
https://github.com/scummvm/scummvm/commit/16137c5cf721938b86aba26baba252f37af6fb05
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Add some missing namespaces
Changed paths:
engines/watchmaker/define.h
engines/watchmaker/file_utils.cpp
engines/watchmaker/file_utils.h
diff --git a/engines/watchmaker/define.h b/engines/watchmaker/define.h
index 80326f7d2c6..3abebddf168 100644
--- a/engines/watchmaker/define.h
+++ b/engines/watchmaker/define.h
@@ -22,6 +22,8 @@
#ifndef WATCHMAKER_DEFINE_H
#define WATCHMAKER_DEFINE_H
+namespace Watchmaker {
+
// Main Chars
#define DARRELL 0
#define VICTORIA 1
@@ -4748,4 +4750,6 @@
* END.
* --------------------------------------------------*/
+} // End of namespace Watchmaker
+
#endif // WATCHMAKER_DEFINE_H
diff --git a/engines/watchmaker/file_utils.cpp b/engines/watchmaker/file_utils.cpp
index 46794b60d16..fcf7b90a4c2 100644
--- a/engines/watchmaker/file_utils.cpp
+++ b/engines/watchmaker/file_utils.cpp
@@ -22,6 +22,8 @@
#include "watchmaker/file_utils.h"
#include "watchmaker/t3d.h"
+namespace Watchmaker {
+
Common::String readT3dString(Common::SeekableReadStream &stream) {
char strbuf[T3D_NAMELEN + 1] = {};
for (int i = 0; i < T3D_NAMELEN; i++) {
@@ -47,4 +49,6 @@ Common::String replaceExtension(const char *str, const Common::String &extension
} else {
return baseStr.substr(0, separator + 1) + extension;
}
-}
\ No newline at end of file
+}
+
+} // End of namespace Watchmaker
diff --git a/engines/watchmaker/file_utils.h b/engines/watchmaker/file_utils.h
index 3019946f3da..3842ac34692 100644
--- a/engines/watchmaker/file_utils.h
+++ b/engines/watchmaker/file_utils.h
@@ -24,10 +24,14 @@
#include "common/stream.h"
+namespace Watchmaker {
+
Common::String readT3dString(Common::SeekableReadStream &stream);
// TODO: This can probably just be replaced with .hasSuffixIgnoreCase
bool hasFileExtension(const Common::String &str, const Common::String &extension);
bool hasFileExtension(const char *str, Common::String extension);
Common::String replaceExtension(const char *str, const Common::String &extension);
+} // End of namespace Watchmaker
+
#endif // WATCHMAKER_FILE_UTILS_H
Commit: 6ea8aefa7bf407b22cda96662b5653423a811fa8
https://github.com/scummvm/scummvm/commit/6ea8aefa7bf407b22cda96662b5653423a811fa8
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Reduce the use of t3dFree
This does reduce the use of the linear allocator as well.
Changed paths:
engines/watchmaker/3d/animation.cpp
engines/watchmaker/3d/geometry.cpp
engines/watchmaker/3d/t3d_body.cpp
engines/watchmaker/3d/t3d_mesh.cpp
engines/watchmaker/classes/do_system.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index 62912a23518..82d10f0078c 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -188,7 +188,7 @@ int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag) {
t3dFree(PreloadedAnim[j].Bone[i].Trasl);
t3dFree(PreloadedAnim[j].Bone[i].Euler);
}
- t3dFree(PreloadedAnim[j].Dist);
+ delete[] PreloadedAnim[j].Dist;
PreloadedAnim[j] = t3dLOADANIM();
}
//t else
@@ -244,7 +244,7 @@ int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag) {
}
}
if (stream->readByte()) {
- p->Dist = (t3dF32 *) t3dMalloc(nf * sizeof(t3dF32));
+ p->Dist = new t3dF32[nf]{};
for (k = 0; k < nf; k++)
p->Dist[k] = stream->readFloatLE();
}
@@ -331,7 +331,7 @@ int8 t3dLoadAnimation(WGame &game, const char *s, t3dMESH *mesh, uint16 Flag) {
}
}
if (p->Dist) {
- db->Dist = (t3dF32 *)t3dMalloc(db->NumFrames * sizeof(t3dF32));
+ db->Dist = new t3dF32[db->NumFrames]{};
for (k = 0; k < db->NumFrames; k++)
db->Dist[k] = p->Dist[k];
}
@@ -682,7 +682,7 @@ void ReleasePreloadedAnims() {
t3dFree(PreloadedAnim[j].Bone[i].Trasl);
t3dFree(PreloadedAnim[j].Bone[i].Euler);
}
- t3dFree(PreloadedAnim[j].Dist);
+ delete[] PreloadedAnim[j].Dist;
PreloadedAnim[j] = t3dLOADANIM();
}
}
diff --git a/engines/watchmaker/3d/geometry.cpp b/engines/watchmaker/3d/geometry.cpp
index 9f5f3f1222c..c33e847328d 100644
--- a/engines/watchmaker/3d/geometry.cpp
+++ b/engines/watchmaker/3d/geometry.cpp
@@ -387,7 +387,7 @@ void t3dReleaseBody(t3dBODY *b) {
b->clearVBTable();
for (int i = 0; i < T3D_MAX_LEVELS; i++) {
- t3dFree(b->Panel[i]);
+ delete[] b->Panel[i];
b->Panel[i] = nullptr;
}
@@ -651,7 +651,7 @@ void t3dCreateProceduralSky(void) {
#endif
MaxSetDimX = MaxSetDimY = 256;
MARGIN = MaxSetDimX / 2;
- tab = (uint8 *)t3dMalloc(MaxSetDimX * MaxSetDimY * 3);
+ tab = new uint8[MaxSetDimX * MaxSetDimY * 3]{};
if (!SkySurface) // rReleaseBitmapDirect( SkySurface );
SkySurface = (gTexture *)rCreateSurface(256, 256, rTEXTURESURFACE);
@@ -753,7 +753,7 @@ void t3dCreateProceduralSky(void) {
}
rUnlockSurfaceDirect(SkySurface);
- t3dFree(tab);
+ delete[] tab;
if (t3dSky && t3dSky->MatTable.size() >= 2)
t3dSky->MatTable[1]->Texture = (SkySurface);
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index b97bc163a2a..3595ffb5c61 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -281,7 +281,7 @@ void LoadBounds(WorkDirs &workDirs, const char *pname, t3dBODY *b) {
for (j = 0; j < nlev; j++) {
b->NumPanels[j] = npan = stream->readSint16LE();
b->PanelHeight[j] = stream->readFloatLE() * SCALEFACTOR;
- b->Panel[j] = t3dMalloc<t3dPAN>(npan + 4 * T3D_MAX_CHARACTERS); // lascia anche un po' di spazio per eventuali aggiunte
+ b->Panel[j] = new t3dPAN[npan + 4 * T3D_MAX_CHARACTERS]; // lascia anche un po' di spazio per eventuali aggiunte
for (i = 0; i < npan; i++) {
b->Panel[j][i].x1 = stream->readFloatLE() * SCALEFACTOR;
diff --git a/engines/watchmaker/3d/t3d_mesh.cpp b/engines/watchmaker/3d/t3d_mesh.cpp
index 30070a7b0cb..c0217cc439f 100644
--- a/engines/watchmaker/3d/t3d_mesh.cpp
+++ b/engines/watchmaker/3d/t3d_mesh.cpp
@@ -214,7 +214,7 @@ void t3dMESH::releaseAnim(uint8 flag) {
t3dFree(ba->BoneTable);
ba->BoneTable = nullptr;
- t3dFree(ba->Dist);
+ delete[] ba->Dist;
ba->Dist = nullptr;
}
@@ -230,28 +230,22 @@ void t3dMESH::release() { // Will eventually be a destructor.
this->RejectedMeshes.clear();
this->PortalList = nullptr;
- if (this->WaterBuffer1)
- t3dFree(this->WaterBuffer1);
+ delete[] this->WaterBuffer1;
this->WaterBuffer1 = nullptr;
- if (this->WaterBuffer2)
- t3dFree(this->WaterBuffer2);
+ delete[] this->WaterBuffer2;
this->WaterBuffer2 = nullptr;
- if (this->VertexBuffer)
- t3dFree(this->VertexBuffer);
+ delete[] this->VertexBuffer;
this->VertexBuffer = nullptr;
- if (this->OldVertexBuffer)
- t3dFree(this->OldVertexBuffer);
+ delete[] this->OldVertexBuffer;
this->OldVertexBuffer = nullptr;
- if (this->SavedVertexBuffer)
- t3dFree(this->SavedVertexBuffer);
+ delete[] this->SavedVertexBuffer;
this->SavedVertexBuffer = nullptr;
- if (this->VertsInterpolants)
- t3dFree(this->VertsInterpolants);
+ delete[] this->VertsInterpolants;
this->VertsInterpolants = nullptr;
// if(mt->VBptr)
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index 3e784f1cf4e..78253597780 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -331,10 +331,8 @@ void TitoliCoda_ShowScrolling(WGame &game, char initialize) {
DebugLogFile("tcEnd %s", c->s);
}
- if (TitoliCoda) {
- t3dFree(TitoliCoda);
- TitoliCoda = nullptr;
- }
+ delete[] TitoliCoda;
+ TitoliCoda = nullptr;
bTitoliCodaScrolling = 0;
DebugLogFile("TITOLI CODA FINITI");
@@ -488,10 +486,8 @@ void TitoliCoda_ShowStatic(WGame &game, char initialize) {
DebugLogFile("tcEnd %s", c->s);
}
- if (TitoliCoda) {
- t3dFree(TitoliCoda);
- TitoliCoda = nullptr;
- }
+ delete[] TitoliCoda;
+ TitoliCoda = nullptr;
bTitoliCodaStatic = 0;
TitoliCoda_ShowScrolling(game, 1);
Commit: ca12fc10ab47c600e86762dee2a16d9bc098b0cf
https://github.com/scummvm/scummvm/commit/ca12fc10ab47c600e86762dee2a16d9bc098b0cf
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Move room loading to RoomManager.
This lets us remove the dependency on malloc.h.
The replacement logic is not 100% perfect, as the original logic will
resize arrays to load additional t3dBODY-structs, and those would then
be free-d alongside their parent. This logic is currently missing, so
we will use some more memory.
However, we won't leak, as all loads are tracked by the RoomManager, and
will be freed when closing/restarting the game.
Changed paths:
engines/watchmaker/3d/animation.cpp
engines/watchmaker/3d/loader.cpp
engines/watchmaker/3d/loader.h
engines/watchmaker/3d/t3d_body.cpp
engines/watchmaker/classes/do_system.cpp
engines/watchmaker/game.cpp
engines/watchmaker/game.h
engines/watchmaker/ll/ll_anim.cpp
engines/watchmaker/ll/ll_system.cpp
engines/watchmaker/ll/ll_util.cpp
engines/watchmaker/saveload.cpp
engines/watchmaker/walk/act.cpp
diff --git a/engines/watchmaker/3d/animation.cpp b/engines/watchmaker/3d/animation.cpp
index 82d10f0078c..80e773a8278 100644
--- a/engines/watchmaker/3d/animation.cpp
+++ b/engines/watchmaker/3d/animation.cpp
@@ -356,9 +356,10 @@ void FixupAnim(t3dMESH *mesh, uint8 pos, const char *room) {
db = &mesh->Anim;
if (pos) {
if (room && (room[0] != '\0')) {
- for (i = 0; i < NumLoadedFiles; i++)
- if ((LoadedFiles[i].b != nullptr) && LoadedFiles[i].b->name.equalsIgnoreCase(room))
- t3dCurRoom = LoadedFiles[i].b;
+ t3dBODY *roomPtr = _vm->_roomManager->getRoomIfLoaded(room);
+ if (room) {
+ t3dCurRoom = roomPtr;
+ }
}
if (!GetLightPosition(&lp, pos) || (lp.x == 0.0f) || (lp.z == 0.0f)) pos = 0;
if (!GetLightDirection(&ld, pos) || (ld.x == 0.0f) || (ld.z == 0.0f)) pos = 0;
@@ -508,7 +509,7 @@ t3dBODY *LoadShadowMeshes(WGame &game, const char *pname, t3dBODY *Body) {
strcpy(Name, pname);
strncpy(&Name[strlen(pname) - 4], "_Shadow.t3d\0", 12);
uint16 numBodys = 0;
- shadow = t3dLoadRoom(game, Name, shadow, &numBodys, (T3D_NOLIGHTMAPS | T3D_NORECURSION | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_NOBOUNDS | T3D_STATIC_SET0 | T3D_STATIC_SET1));
+ shadow = _vm->_roomManager->loadRoom(Name, shadow, &numBodys, (T3D_NOLIGHTMAPS | T3D_NORECURSION | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_NOBOUNDS | T3D_STATIC_SET0 | T3D_STATIC_SET1));
if (!shadow) return nullptr;
for (uint16 i = 0; i < shadow->NumMeshes(); i++) {
@@ -564,8 +565,11 @@ t3dCHARACTER *t3dLoadCharacter(WGame &game, const char *pname, uint16 num) {
// gVertex *v;
t3dCHARACTER *b = new t3dCHARACTER[1] {};
- b->Body = t3dLoadRoom(game, pname, b->Body, &n, (T3D_NOLIGHTMAPS | T3D_NORECURSION | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_STATIC_SET0 | T3D_STATIC_SET1));
- if (!b->Body) return nullptr;
+ b->Body = _vm->_roomManager->loadRoom(pname, b->Body, &n, (T3D_NOLIGHTMAPS | T3D_NORECURSION | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_STATIC_SET0 | T3D_STATIC_SET1));
+ if (!b->Body) {
+ delete b;
+ return nullptr;
+ }
b->Mesh = &b->Body->MeshTable[0];
b->CurRoom = t3dCurRoom;
b->Flags = T3D_CHARACTER_HIDE | T3D_CHARACTER_REALTIMELIGHTING;
@@ -700,9 +704,7 @@ uint8 CompareLightPosition(char *roomname, uint8 pos1, t3dV3F *pos2, t3dF32 acce
// cerco la stanza
t = nullptr;
if (roomname && (roomname[0] != '\0')) {
- for (i = 0; i < NumLoadedFiles; i++)
- if ((LoadedFiles[i].b != nullptr) && LoadedFiles[i].b->name.equalsIgnoreCase(roomname))
- t = LoadedFiles[i].b;
+ t = _vm->_roomManager->getRoomIfLoaded(roomname);
} else t = t3dCurRoom;
if (!t) return FALSE;
diff --git a/engines/watchmaker/3d/loader.cpp b/engines/watchmaker/3d/loader.cpp
index 9896941d580..4b57f29e19a 100644
--- a/engines/watchmaker/3d/loader.cpp
+++ b/engines/watchmaker/3d/loader.cpp
@@ -20,81 +20,30 @@
*/
#include "watchmaker/3d/loader.h"
+#include "common/stream.h"
+#include "watchmaker/3d/geometry.h"
+#include "watchmaker/3d/light.h"
#include "watchmaker/3d/math/llmath.h"
-#include "watchmaker/t3d.h"
#include "watchmaker/3d/t3d_body.h"
#include "watchmaker/3d/t3d_mesh.h"
+#include "watchmaker/game.h"
+#include "watchmaker/ll/ll_mesh.h"
+#include "watchmaker/ll/ll_system.h"
+#include "watchmaker/renderer.h"
+#include "watchmaker/t3d.h"
#include "watchmaker/types.h"
-#include "common/stream.h"
#include "watchmaker/utils.h"
-#include "watchmaker/ll/ll_system.h"
-#include "watchmaker/work_dirs.h"
-#include "watchmaker/3d/geometry.h"
-#include "watchmaker/3d/light.h"
#include "watchmaker/windows_hacks.h"
-#include "watchmaker/game.h"
-#include "watchmaker/renderer.h"
#include "watchmaker/work_dirs.h"
namespace Watchmaker {
#define T3DFILEVERSION 11
-// TODO: Globals
-#define MAX_LOADED_FILES 100
-RecStruct LoadedFiles[MAX_LOADED_FILES];
-uint16 NumLoadedFiles = 0;
-
t3dV3F CharCorrection;
t3dF32 CurFloorY;
int32 t3dCurTime = 900, t3dCurOliSet = 0;
-// LoadRoom vars
-#define MAX_T3D_LOADLIST_ITEMS 50
-struct _t3dLOADLIST {
- Common::String pname = {};
- uint32 LoaderFlags = 0;
- t3dMESH *m = nullptr;
-} t3dLoadList[MAX_T3D_LOADLIST_ITEMS] = {};
-
-/* -----------------10/06/99 16.03-------------------
- * AddToLoadList
- * --------------------------------------------------*/
-void AddToLoadList(t3dMESH *m, const Common::String &pname, uint32 LoaderFlags) {
- int32 a;
-
- if (!pname.empty()) {
- for (a = 0; a < MAX_T3D_LOADLIST_ITEMS; a++) {
- if (t3dLoadList[a].pname.empty()) {
- t3dLoadList[a].LoaderFlags = LoaderFlags;
- t3dLoadList[a].m = m;
- t3dLoadList[a].pname = pname;
- break;
- }
- }
-
- if (a >= MAX_T3D_LOADLIST_ITEMS)
- warning("Cannot add %s to LoadList", pname.c_str());
- } else {
- warning("Invalid parameters invoking AddToLoadList()");
- warning("Mesh (%s), pname %s", m->name.c_str(), pname.c_str());
- }
-}
-
-/* -----------------10/06/99 16.04-------------------
- * GetFromLoadList
- * --------------------------------------------------*/
-struct _t3dLOADLIST *GetFromLoadList(void) {
- int32 a;
-
- for (a = 0; a < MAX_T3D_LOADLIST_ITEMS; a++) {
- if (!t3dLoadList[a].pname.empty())
- return &t3dLoadList[a];
- }
-
- return nullptr;
-}
-
t3dPathCamera::t3dPathCamera(Common::SeekableReadStream &stream) {
NumCamera = stream.readByte();
PathIndex = stream.readByte();
@@ -160,21 +109,6 @@ void decodeLoaderFlags(uint32 flags) {
warning("%d: T3D_HIPOLYCHARACTERS", flags & T3D_HIPOLYCHARACTERS);
}
-/* -----------------10/06/99 16.04-------------------
- * CheckIfAlreadyLoaded
- * --------------------------------------------------*/
-t3dBODY *CheckIfAlreadyLoaded(const Common::String &Name) {
- if (Name.empty()) return nullptr;
-
- for (uint16 i = 0; i < NumLoadedFiles; i++) {
- if ((LoadedFiles[i].b != nullptr) && /*(LoadedFiles[i].Name != nullptr) &&*/ (!LoadedFiles[i].name.empty()))
- if (LoadedFiles[i].name.equalsIgnoreCase(Name))
- return LoadedFiles[i].b;
- }
-
- return nullptr;
-}
-
Common::String constructPath(const Common::String &prefix, const Common::String &filename, const char *suffix) {
Common::String Name = prefix + filename;
uint16 len = Name.size();
@@ -186,96 +120,168 @@ Common::String constructPath(const Common::String &prefix, const Common::String
return Common::String(Name);
}
-/* -----------------10/06/99 16.04-------------------
- * t3dLoadSingleRoom
- * --------------------------------------------------*/
-t3dBODY *t3dLoadSingleRoom(WGame &game, const Common::String &_pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags) {
- //warning("t3dLoadSingleRoom(workDirs, %s, b, %d, %d)", _pname, *NumBody, LoaderFlags);
- //decodeLoaderFlags(LoaderFlags);
- Common::String pname(_pname);
-
- WorkDirs &workdirs = game.workDirs;
+class RoomManagerImplementation : public RoomManager {
+ WGame *_game;
+ #define MAX_LOADED_FILES 100
+ RecStruct LoadedFiles[MAX_LOADED_FILES];
+ uint16 NumLoadedFiles = 0;
+public:
+ RoomManagerImplementation(WGame *game) : _game(game) {}
+ #define MAX_T3D_LOADLIST_ITEMS 50
+ struct _t3dLOADLIST {
+ Common::String pname = {};
+ uint32 LoaderFlags = 0;
+ t3dMESH *m = nullptr;
+ };
+ _t3dLOADLIST t3dLoadList[MAX_T3D_LOADLIST_ITEMS] = {};
+
+ void addToLoadList(t3dMESH *m, const Common::String &pname, uint32 LoaderFlags) {
+ if (!pname.empty()) {
+ int32 a;
+ for (a = 0; a < MAX_T3D_LOADLIST_ITEMS; a++) {
+ if (t3dLoadList[a].pname.empty()) {
+ t3dLoadList[a].LoaderFlags = LoaderFlags;
+ t3dLoadList[a].m = m;
+ t3dLoadList[a].pname = pname;
+ break;
+ }
+ }
- if (pname.equalsIgnoreCase("r1c.t3d"))
- if (((t3dCurTime >= 1300) && (t3dCurTime <= 1310)) || (t3dCurTime >= 1800)) //se viene cambiato l'orario cambiarlo anche in UpdateRoomVis...
- pname = "r1c-notte.t3d";
- if (pname.equalsIgnoreCase("r15.t3d"))
- if (((t3dCurTime >= 1300) && (t3dCurTime <= 1310)) || (t3dCurTime >= 1800))
- pname = "r15-notte.t3d";
+ if (a >= MAX_T3D_LOADLIST_ITEMS)
+ warning("Cannot add %s to LoadList", pname.c_str());
+ } else {
+ warning("Invalid parameters invoking AddToLoadList()");
+ warning("Mesh (%s), pname %s", m->name.c_str(), pname.c_str());
+ }
+ }
- auto name = constructPath(workdirs._t3dDir, pname);
+ _t3dLOADLIST* getFromLoadList(void) {
+ for (int a = 0; a < MAX_T3D_LOADLIST_ITEMS; a++) {
+ if (!t3dLoadList[a].pname.empty())
+ return &t3dLoadList[a];
+ }
- //warning("t3dLoadSingleRoom opening(%s)", name.c_str());
- auto stream = openFile(name);
- if (!(stream)) { // Apre file
- warning("t3dLoadSingleRoom: Failed to open(%s)", name.c_str());
return nullptr;
}
- if (*NumBody == 0) { // Se e' il primo body, alloca
- b = new t3dBODY;
- (*NumBody)++;
- } else
- b = (t3dBODY *)t3dRealloc((uint32 *)b, sizeof(t3dBODY) * (++(*NumBody))); // Altrimenti, ridimensiona
+ t3dBODY *getRoomIfLoaded(const Common::String &roomname) override {
+ t3dBODY *t = nullptr;
+ for (int i = 0; i < NumLoadedFiles; i++)
+ if ((LoadedFiles[i].b != nullptr) && LoadedFiles[i].b->name.equalsIgnoreCase(roomname))
+ t = LoadedFiles[i].b;
+ return t;
+ }
- //warning("Loading %s ...", name.c_str());
- *b = t3dBODY(); // Azzera Body
- uint16 fileVersion = stream->readByte();
- if (fileVersion != T3DFILEVERSION) { // Controlla la versione del file
- warning("%s file incompatible: current version: %d.\tFile version: %d", name.c_str(), T3DFILEVERSION, fileVersion);
+
+ t3dBODY* loadRoom(const Common::String &pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags) override;
+ t3dBODY* loadSingleRoom(const Common::String &pname, uint16 *NumBody, uint32 LoaderFlags);
+ void hideRoomMeshesMatching(const Common::String &pname) override {
+ for (int i = 0; i < NumLoadedFiles; i++)
+ if (LoadedFiles[i].b)
+ if (LoadedFiles[i].b->name.equalsIgnoreCase(pname)) {
+ HideRoomMeshes(_game->init, LoadedFiles[i].b);
+ }
+ }
+ Common::Array<t3dBODY*> getLoadedFiles() override {
+ // TODO: This won't need to be a copy if we maintain a Common::Array only containing the valid ones.
+ Common::Array<t3dBODY*> files;
+ for (int i = 0; i < NumLoadedFiles; i++)
+ if (LoadedFiles[i].b)
+ files.push_back(LoadedFiles[i].b);
+ return files;
+ }
+ t3dBODY *checkIfAlreadyLoaded(const Common::String &Name) override {
+ if (Name.empty()) return nullptr;
+
+ for (uint16 i = 0; i < NumLoadedFiles; i++) {
+ if ((LoadedFiles[i].b != nullptr) && /*(LoadedFiles[i].Name != nullptr) &&*/ (!LoadedFiles[i].name.empty()))
+ if (LoadedFiles[i].name.equalsIgnoreCase(Name))
+ return LoadedFiles[i].b;
+ }
+
return nullptr;
}
- {
- uint16 j = 1;
- while (LoadedFiles[j].b != nullptr) j++;
- if (j > MAX_LOADED_FILES) {
- warning("Too many t3d files loaded!");
- return nullptr;
+ t3dMESH *linkMeshToStr(Init &init, const Common::String &str) {
+ if (str.empty()) return nullptr;
+
+ // Cerca tra le camere
+ if (str.equalsIgnoreCase("camera"))
+ return &init._globals._invVars.CameraDummy;
+ // Cerca tra i personaggi
+ for (uint16 i = 0; i < T3D_MAX_CHARACTERS; i++)
+ if ((Character[i]) && (str.equalsIgnoreCase((char *)init.Obj[i].meshlink[0])))
+ return Character[i]->Mesh;
+ // Cerca nelle stanze caricate
+ for (uint16 i = 0; i < NumLoadedFiles; i++) {
+ if (LoadedFiles[i].b)
+ for (uint16 j = 0; j < LoadedFiles[i].b->NumMeshes(); j++) {
+ if (str.equalsIgnoreCase(LoadedFiles[i].b->MeshTable[j].name))
+ return &LoadedFiles[i].b->MeshTable[j];
+ }
}
- if ((j + 1) > NumLoadedFiles) NumLoadedFiles = j + 1;
- LoadedFiles[j].name = _pname; // Aggiunge il file alla lista
- LoadedFiles[j].Flags = LoaderFlags; // Aggiunge Flags alla lista
- LoadedFiles[j].b = b; // Aggiunge Body alla lista
- j = 0;
+ return nullptr;
+ }
+ void releaseBody(const Common::String &name, const Common::String &altName) override {
+ for (int j = 0; j < NumLoadedFiles; j++) {
+ if (LoadedFiles[j].name.equalsIgnoreCase(name) || LoadedFiles[j].name.equalsIgnoreCase(altName)) {
+ t3dReleaseBody(LoadedFiles[j].b);
+ LoadedFiles[j].b = nullptr;
+ break;
+ }
+ }
}
- b->loadFromStream(game, pname, *stream, LoaderFlags);
- return b;
+ void releaseLoadedFiles(uint32 exceptFlag) override {
+ for (int i = 0; i < NumLoadedFiles; i++) {
+ if (LoadedFiles[i].b && !(LoadedFiles[i].Flags & exceptFlag)) {
+ t3dReleaseBody(LoadedFiles[i].b);
+ LoadedFiles[i] = RecStruct(); // TODO: Deduplicate.
+ }
+ }
+ }
+private:
+ void loadFromList();
+};
+
+RoomManager *RoomManager::create(WGame *game) {
+ return new RoomManagerImplementation(game);
}
/* -----------------10/06/99 16.04-------------------
* t3dLoadRoom
* --------------------------------------------------*/
-t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags) {
+t3dBODY* RoomManagerImplementation::loadRoom(const Common::String &pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags) {
warning("t3dLoadRoom(%s, b, %d, %d)", pname.c_str(), *NumBody, LoaderFlags);
struct _t3dLOADLIST *l;
t3dBODY *r, *rez;
uint16 num, i;
-// azzera tutto quello che c'era prima nella load list
+ // reset everything that was previously in the load list
for (int i = 0; i < MAX_T3D_LOADLIST_ITEMS; i++) {
t3dLoadList[i] = _t3dLOADLIST();
}
-// Aggiunge la stanza base alla lista di caricamenti
- AddToLoadList(nullptr, pname, LoaderFlags);
+ // Add the base stanza to the upload list
+ addToLoadList(nullptr, pname, LoaderFlags);
- while ((l = GetFromLoadList())) {
+ while ((l = getFromLoadList())) {
num = 0;
if (l->m) {
- if ((rez = CheckIfAlreadyLoaded(l->pname)))
+ if ((rez = _vm->_roomManager->checkIfAlreadyLoaded(l->pname)))
l->m->PortalList = rez;
else {
// if (l->m->Flags&T3D_MESH_PREPROCESSPORTAL)
// body=l->m->PortalList = t3dLoadSingleRoom( l->pname, l->m->PortalList, &num, (l->LoaderFlags|T3D_HALFTEXTURESIZE) );
// else
- l->m->PortalList = t3dLoadSingleRoom(game, l->pname, l->m->PortalList, &num, l->LoaderFlags);
+ // TODO: This should increase some refcount on the PortalList
+ warning("TODO: Handle refcounts on PortalList");
+ l->m->PortalList = loadSingleRoom(l->pname, &num, l->LoaderFlags);
}
} else
- r = t3dLoadSingleRoom(game, l->pname, b, NumBody, l->LoaderFlags);
+ r = loadSingleRoom(l->pname, NumBody, l->LoaderFlags);
*l = _t3dLOADLIST();
}
@@ -290,6 +296,65 @@ t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, uint1
return r;
}
+t3dBODY* RoomManagerImplementation::loadSingleRoom(const Common::String &_pname, uint16 *NumBody, uint32 LoaderFlags) {
+ //warning("t3dLoadSingleRoom(workDirs, %s, b, %d, %d)", _pname, *NumBody, LoaderFlags);
+ //decodeLoaderFlags(LoaderFlags);
+ Common::String pname(_pname);
+
+ WorkDirs &workdirs = _game->workDirs;
+
+ if (pname.equalsIgnoreCase("r1c.t3d"))
+ if (((t3dCurTime >= 1300) && (t3dCurTime <= 1310)) || (t3dCurTime >= 1800)) //se viene cambiato l'orario cambiarlo anche in UpdateRoomVis...
+ pname = "r1c-notte.t3d";
+ if (pname.equalsIgnoreCase("r15.t3d"))
+ if (((t3dCurTime >= 1300) && (t3dCurTime <= 1310)) || (t3dCurTime >= 1800))
+ pname = "r15-notte.t3d";
+
+ auto name = constructPath(workdirs._t3dDir, pname);
+
+ //warning("t3dLoadSingleRoom opening(%s)", name.c_str());
+ auto stream = openFile(name);
+ if (!(stream)) { // Apre file
+ warning("t3dLoadSingleRoom: Failed to open(%s)", name.c_str());
+ return nullptr;
+ }
+
+ if (*NumBody != 0) {
+ // TODO: This currently means that we never free the dependant bodies.
+ warning("Loading a dependant body, should also be deleted alongside the base body");
+ }
+ t3dBODY *b = new t3dBODY();
+
+ //warning("Loading %s ...", name.c_str());
+ *b = t3dBODY(); // Azzera Body
+
+ uint16 fileVersion = stream->readByte();
+ if (fileVersion != T3DFILEVERSION) { // Controlla la versione del file
+ warning("%s file incompatible: current version: %d.\tFile version: %d", name.c_str(), T3DFILEVERSION, fileVersion);
+ return nullptr;
+ }
+
+ {
+ uint16 j = 1;
+ while (LoadedFiles[j].b != nullptr)
+ j++;
+ if (j > MAX_LOADED_FILES) {
+ warning("Too many t3d files loaded!");
+ return nullptr;
+ }
+ if ((j + 1) > NumLoadedFiles)
+ NumLoadedFiles = j + 1;
+
+ LoadedFiles[j].name = _pname; // Aggiunge il file alla lista
+ LoadedFiles[j].Flags = LoaderFlags; // Aggiunge Flags alla lista
+ LoadedFiles[j].b = b; // Aggiunge Body alla lista
+ j = 0;
+ }
+ b->loadFromStream(*_game, pname, *stream, LoaderFlags);
+
+ return b;
+}
+
t3dParticle::t3dParticle(Common::SeekableReadStream &stream) {
t3dF32 difR1, difG1, difB1;
t3dF32 difR2, difG2, difB2;
@@ -408,7 +473,7 @@ void t3dLoadSky(WGame &game, t3dBODY * /*body*/) {
// t3dF32 Tile=1.5f;
t3dF32 div;
- if (!(t3dSky = t3dLoadRoom(game, "sky.t3d", t3dSky, &n, T3D_NORECURSION | T3D_NOLIGHTMAPS | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_NOBOUNDS | T3D_STATIC_SET0))) {
+ if (!(t3dSky = _vm->_roomManager->loadRoom("sky.t3d", t3dSky, &n, T3D_NORECURSION | T3D_NOLIGHTMAPS | T3D_NOVOLUMETRICLIGHTS | T3D_NOCAMERAS | T3D_NOBOUNDS | T3D_STATIC_SET0))) {
warning("Error during t3dLoadRoom: Sky not loaded");
}
diff --git a/engines/watchmaker/3d/loader.h b/engines/watchmaker/3d/loader.h
index 32e3b68eb9d..65185ba62c3 100644
--- a/engines/watchmaker/3d/loader.h
+++ b/engines/watchmaker/3d/loader.h
@@ -69,20 +69,28 @@ struct RecStruct {
uint32 Flags = 0;
};
-extern RecStruct LoadedFiles[];
-extern uint16 NumLoadedFiles;
-
-t3dBODY *t3dLoadRoom(WGame &game, const Common::String &pname, t3dBODY *b, unsigned short *NumBody, unsigned int LoaderFlags);
-t3dBODY *t3dLoadSingleRoom(WGame &game, const char *_pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags);
void t3dOptimizeMaterialList(t3dBODY *b);
void t3dFinalizeMaterialList(t3dBODY *b);
void t3dPrecalcLight(t3dBODY *b, unsigned char *sun);
void t3dLoadSky(WGame &game, t3dBODY *b);
-t3dBODY *CheckIfAlreadyLoaded(const Common::String &Name);
-void AddToLoadList(t3dMESH *m, const Common::String &pname, uint32 LoaderFlags);
Common::String constructPath(const Common::String &prefix, const Common::String &filename, const char *suffix = nullptr);
+class RoomManager {
+public:
+ virtual ~RoomManager() {}
+ virtual void addToLoadList(t3dMESH *m, const Common::String &pname, uint32 LoaderFlags) = 0;
+ virtual t3dBODY* loadRoom(const Common::String &pname, t3dBODY *b, uint16 *NumBody, uint32 LoaderFlags) = 0;
+ static RoomManager *create(WGame *game);
+ virtual t3dBODY *getRoomIfLoaded(const Common::String &roomname) = 0;
+ virtual t3dMESH *linkMeshToStr(Init &init, const Common::String &str) = 0;
+ virtual void hideRoomMeshesMatching(const Common::String &pname) = 0;
+ virtual void releaseBody(const Common::String &name, const Common::String &altName) = 0;
+ virtual void releaseLoadedFiles(uint32 exceptFlag) = 0;
+ virtual t3dBODY *checkIfAlreadyLoaded(const Common::String &Name) = 0;
+ virtual Common::Array<t3dBODY*> getLoadedFiles() = 0;
+};
+
} // End of namespace Watchmaker
#endif // WATCHMAKER_LOADER_H
diff --git a/engines/watchmaker/3d/t3d_body.cpp b/engines/watchmaker/3d/t3d_body.cpp
index 3595ffb5c61..052668e0741 100644
--- a/engines/watchmaker/3d/t3d_body.cpp
+++ b/engines/watchmaker/3d/t3d_body.cpp
@@ -177,15 +177,15 @@ void t3dBODY::populatePortalLists() {
//#endif
// TODO: This should probably be upfactored.
t3dBODY *rez = nullptr;
- if (((rez = CheckIfAlreadyLoaded(Name)) == nullptr) && (!(LoaderFlags & T3D_NORECURSION))) { // Controlla se lo ha gia' caricato
+ if (((rez = _vm->_roomManager->checkIfAlreadyLoaded(Name)) == nullptr) && (!(LoaderFlags & T3D_NORECURSION))) { // Controlla se lo ha gia' caricato
if (Name.equalsIgnoreCase("rxt.t3d"))
- AddToLoadList(&Mesh[mesh], Name, (uint16)(LoaderFlags | T3D_NORECURSION & ~T3D_RECURSIONLEVEL1)); // aggiunge e leva la ricorsione
+ _vm->_roomManager->addToLoadList(&Mesh[mesh], Name, (uint16)(LoaderFlags | T3D_NORECURSION & ~T3D_RECURSIONLEVEL1)); // aggiunge e leva la ricorsione
// Mesh[mesh].Flags|=T3D_MESH_NOPORTALCHECK;
else {
if (LoaderFlags & T3D_RECURSIONLEVEL1)
- AddToLoadList(&Mesh[mesh], Name, (uint16)(LoaderFlags | T3D_NORECURSION & ~T3D_RECURSIONLEVEL1)); // aggiunge e leva la ricorsione
+ _vm->_roomManager->addToLoadList(&Mesh[mesh], Name, (uint16)(LoaderFlags | T3D_NORECURSION & ~T3D_RECURSIONLEVEL1)); // aggiunge e leva la ricorsione
else
- AddToLoadList(&Mesh[mesh], Name, (uint16)(LoaderFlags)); // altrimenti lo agggiunge alla lista
+ _vm->_roomManager->addToLoadList(&Mesh[mesh], Name, (uint16)(LoaderFlags)); // altrimenti lo agggiunge alla lista
}
} else
Mesh[mesh].PortalList = rez;
diff --git a/engines/watchmaker/classes/do_system.cpp b/engines/watchmaker/classes/do_system.cpp
index 78253597780..54bd244addf 100644
--- a/engines/watchmaker/classes/do_system.cpp
+++ b/engines/watchmaker/classes/do_system.cpp
@@ -562,10 +562,9 @@ void ProcessTime(WGame &game) {
//DebugLogFile("Updating Listener ");
UpdateListener = 20;
- for (i = 0; i < NumLoadedFiles; i++)
- if (LoadedFiles[i].b && t3dCurRoom)
- if (LoadedFiles[i].b->name.equalsIgnoreCase(t3dCurRoom->name))
- HideRoomMeshes(game.init, LoadedFiles[i].b);
+ if (t3dCurRoom) {
+ _vm->_roomManager->hideRoomMeshesMatching(t3dCurRoom->name);
+ }
}
}
//
diff --git a/engines/watchmaker/game.cpp b/engines/watchmaker/game.cpp
index 503df75bc8c..2a1123cdb42 100644
--- a/engines/watchmaker/game.cpp
+++ b/engines/watchmaker/game.cpp
@@ -162,13 +162,7 @@ bool WGame::CheckAndLoadMoglieSupervisoreModel(int32 c) {
t3dReleaseCharacter(Character[c]);
Character[c] = nullptr;
- for (j = 0; j < NumLoadedFiles; j++) {
- if (LoadedFiles[j].name.equalsIgnoreCase(RemoveName) || LoadedFiles[j].name.equalsIgnoreCase(RemoveNameHI)) {
- t3dReleaseBody(LoadedFiles[j].b);
- LoadedFiles[j].b = nullptr;
- break;
- }
- }
+ _vm->_roomManager->releaseBody(RemoveName, RemoveNameHI);
LoaderFlags |= T3D_PRELOADBASE;
LoaderFlags |= T3D_STATIC_SET1;
@@ -192,6 +186,7 @@ bool WGame::CheckAndLoadMoglieSupervisoreModel(int32 c) {
WGame::WGame() : workDirs(WATCHMAKER_CFG_NAME) {
_vm = this;
_meshModifiers = new MeshModifiers();
+ _roomManager = RoomManager::create(this);
configLoaderFlags(); // TODO: This should probably happen before the constructor
// if LoaderFlags & T3D_DEBUGMODE
@@ -219,6 +214,7 @@ WGame::~WGame() {
delete _renderer;
delete sdl;
delete _meshModifiers;
+ delete _roomManager;
_vm = nullptr;
}
@@ -313,7 +309,7 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
// PrintLoading();
if (!(LoaderFlags & T3D_NOICONS))
- if (!(init._globals._invVars.t3dIcons = t3dLoadRoom(*this, "Icons.t3d", init._globals._invVars.t3dIcons, &i, (LoaderFlags | T3D_NORECURSION | T3D_NOLIGHTMAPS | T3D_NOBOUNDS | T3D_NOCAMERAS | T3D_STATIC_SET1)))) {
+ if (!(init._globals._invVars.t3dIcons = _roomManager->loadRoom("Icons.t3d", init._globals._invVars.t3dIcons, &i, (LoaderFlags | T3D_NORECURSION | T3D_NOLIGHTMAPS | T3D_NOBOUNDS | T3D_NOCAMERAS | T3D_STATIC_SET1)))) {
warning("Error loading Icons");
return false;
}
@@ -361,7 +357,8 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
if (!lite) {
if (LoaderFlags & T3D_PRELOAD_RXT) {
t3dCurOliSet = -1;
- if (!(t3dRxt = t3dLoadRoom(*this, "rxt.t3d", t3dCurRoom, &i, LoaderFlags | T3D_NOLIGHTMAPS))) {
+ // TODO: Figure out how this i works out.
+ if (!(t3dRxt = _roomManager->loadRoom("rxt.t3d", t3dCurRoom, &i, LoaderFlags | T3D_NOLIGHTMAPS))) {
warning("Error loading room rxt.t3d");
return false;
}
@@ -379,7 +376,7 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
}
if (!((LoaderFlags & T3D_PRELOAD_RXT) && name.equalsIgnoreCase("rxt.t3d"))) {
- if (!(t3dCurRoom = t3dLoadRoom(*this, name, t3dCurRoom, &i, LoaderFlags))) {
+ if (!(t3dCurRoom = _roomManager->loadRoom(name, t3dCurRoom, &i, LoaderFlags))) {
warning("Error loading room %s", name.c_str());
return false;
}
@@ -506,12 +503,12 @@ bool WGame::LoadAndSetup(const Common::String &name, uint8 lite) {
void WGame::UpdateAll() {
int32 i;
UpdateRoomVisibility(*this);
- for (i = 0; i < NumLoadedFiles; i++) {
- if (LoadedFiles[i].b) {
- HideRoomMeshes(init, LoadedFiles[i].b);
- _meshModifiers->applyAllMeshModifiers(*this, LoadedFiles[i].b);
- }
+ auto bodies = _roomManager->getLoadedFiles();
+ for (auto loadedBody : bodies) {
+ HideRoomMeshes(init, loadedBody);
+ _meshModifiers->applyAllMeshModifiers(*this, loadedBody);
}
+
UpdateAllClocks(*this);
// Init for Clock33
diff --git a/engines/watchmaker/game.h b/engines/watchmaker/game.h
index b9133c483bb..dfc9c3c4866 100644
--- a/engines/watchmaker/game.h
+++ b/engines/watchmaker/game.h
@@ -50,6 +50,7 @@ public:
};
class MeshModifiers;
+class RoomManager;
class WGame {
bool g_bReady, g_bActive;
@@ -69,6 +70,7 @@ public:
GameRect _gameRect;
Fonts _fonts;
MessageSystem _messageSystem;
+ RoomManager *_roomManager;
WGame();
~WGame();
diff --git a/engines/watchmaker/ll/ll_anim.cpp b/engines/watchmaker/ll/ll_anim.cpp
index 713f4b514c2..fe432385f3b 100644
--- a/engines/watchmaker/ll/ll_anim.cpp
+++ b/engines/watchmaker/ll/ll_anim.cpp
@@ -1829,12 +1829,7 @@ void StopPlayingGame(WGame &game) {
StopAllAnims(init);
StopMusic();
t3dResetPipeline();
- for (i = 0; i < NumLoadedFiles; i++) {
- if (LoadedFiles[i].b && !(LoadedFiles[i].Flags & T3D_STATIC_SET1)) {
- t3dReleaseBody(LoadedFiles[i].b);
- LoadedFiles[i] = RecStruct(); // TODO: Deduplicate.
- }
- }
+ _vm->_roomManager->releaseLoadedFiles(T3D_STATIC_SET1);
t3dRxt = nullptr;
t3dSky = nullptr;
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index 32b8fbe3221..5d3d14d005d 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -71,27 +71,6 @@ void *t3dCalloc(uint32 n) {
return (res);
}
-void *t3dRealloc(void *pp, uint32 additionalBytes) {
-
-
- uint32 *res = (uint32 *)pp;
- uint32 size = 0;
- if (pp == nullptr) size = 0;
- else
- size = (uint32) MALLOC_SIZE(pp);
- //Reallocate and show new size:
- if ((res = (uint32 *)realloc(pp, (additionalBytes + size))) == nullptr) {
- warning("t3dRealloc: Memory allocation error: can't alloc %d bytes", additionalBytes + size);
- return res;
- }
-
- t3dAllocatedMemory += additionalBytes;
- //malloc_size()
- pp = res;//realloc(pp, additionalBytes);
- //warning("t3dRealloc() size: %d, additionalBytes: %d, newSize = %d", size, additionalBytes, malloc_size(pp));
- return (pp);
-}
-
void t3dFree(void *p) {
if (!p) return;
diff --git a/engines/watchmaker/ll/ll_util.cpp b/engines/watchmaker/ll/ll_util.cpp
index 3347c5140d2..319c631744f 100644
--- a/engines/watchmaker/ll/ll_util.cpp
+++ b/engines/watchmaker/ll/ll_util.cpp
@@ -269,25 +269,8 @@ int32 LoadDDBitmap(WGame &game, const char *n, uint8 flags) {
* LinkMeshToStr
* --------------------------------------------------*/
t3dMESH *LinkMeshToStr(Init &init, const Common::String &str) {
- if (str.empty()) return nullptr;
-
-// Cerca tra le camere
- if (str.equalsIgnoreCase("camera"))
- return &init._globals._invVars.CameraDummy;
-// Cerca tra i personaggi
- for (uint16 i = 0; i < T3D_MAX_CHARACTERS; i++)
- if ((Character[i]) && (str.equalsIgnoreCase((char *)init.Obj[i].meshlink[0])))
- return Character[i]->Mesh;
-// Cerca nelle stanze caricate
- for (uint16 i = 0; i < NumLoadedFiles; i++) {
- if (LoadedFiles[i].b)
- for (uint16 j = 0; j < LoadedFiles[i].b->NumMeshes(); j++) {
- if (str.equalsIgnoreCase(LoadedFiles[i].b->MeshTable[j].name))
- return &LoadedFiles[i].b->MeshTable[j];
- }
- }
-
- return nullptr;
+ // TODO: Refactor the callsites:
+ return _vm->_roomManager->linkMeshToStr(init, str);
}
/* -----------------18/12/00 18.02-------------------
@@ -444,9 +427,7 @@ bool SetBndLevel(WGame &game, const char *roomname, int32 lev) {
t = nullptr;
if (roomname && (roomname[0] != '\0')) {
- for (i = 0; i < NumLoadedFiles; i++)
- if ((LoadedFiles[i].b != nullptr) && LoadedFiles[i].b->name.equalsIgnoreCase(roomname))
- t = LoadedFiles[i].b;
+ _vm->_roomManager->getRoomIfLoaded(roomname);
} else t = t3dCurRoom;
if (!t) {
@@ -522,20 +503,13 @@ void ChangeRoom(WGame &game, Common::String n, uint8 pos, int32 an) {
// se esso aveva delle modifiche da fare al piano corrente le fa subito, e non dopo quando il piano non e' piu' disponibile
StopDiary(game, 0, 0, 0);
- t = nullptr;
// Prima lo cerca tra le stanze in memoria
- for (i = 0; i < NumLoadedFiles; i++)
- if ((LoadedFiles[i].b != nullptr) && LoadedFiles[i].b->name.equalsIgnoreCase(n))
- t = LoadedFiles[i].b;
+ t = _vm->_roomManager->getRoomIfLoaded(n);
+
// Se non lo trova tra le stanze in memoria
if (!t) {
t3dResetPipeline();
- for (i = 0; i < NumLoadedFiles; i++) {
- if (LoadedFiles[i].b && !(LoadedFiles[i].Flags & T3D_STATIC_SET0)) {
- t3dReleaseBody(LoadedFiles[i].b);
- LoadedFiles[i] = RecStruct(); // TODO: Deduplicate this
- }
- }
+ _vm->_roomManager->releaseLoadedFiles(T3D_STATIC_SET0);
for (i = 0; i < T3D_MAX_CHARACTERS; i++) {
if (Character[i]) {
@@ -597,9 +571,7 @@ int32 GetBndLevel(char *roomname) {
t = nullptr;
if (roomname && (roomname[0] != '\0')) {
- for (i = 0; i < NumLoadedFiles; i++)
- if ((LoadedFiles[i].b != nullptr) && LoadedFiles[i].b->name.equalsIgnoreCase(roomname))
- t = LoadedFiles[i].b;
+ t = _vm->_roomManager->getRoomIfLoaded(roomname);
} else t = t3dCurRoom;
if (!t) return FALSE;
diff --git a/engines/watchmaker/saveload.cpp b/engines/watchmaker/saveload.cpp
index 29ccdc4c0cf..5ac9d41a80b 100644
--- a/engines/watchmaker/saveload.cpp
+++ b/engines/watchmaker/saveload.cpp
@@ -545,12 +545,7 @@ bool DataLoad(WGame &game, const Common::String &FileName, uint8 slot) {
StopSounds();
StopMusic();
t3dResetPipeline();
- for (int i = 0; i < NumLoadedFiles; i++) {
- if (LoadedFiles[i].b && !(LoadedFiles[i].Flags & T3D_STATIC_SET1)) {
- t3dReleaseBody(LoadedFiles[i].b);
- LoadedFiles[i] = RecStruct();
- }
- }
+ _vm->_roomManager->releaseLoadedFiles(T3D_STATIC_SET1);
t3dRxt = nullptr;
t3dSky = nullptr;
rReleaseAllTextures(T3D_STATIC_SET0);
diff --git a/engines/watchmaker/walk/act.cpp b/engines/watchmaker/walk/act.cpp
index ef5769ab9fe..cdf6386f9c7 100644
--- a/engines/watchmaker/walk/act.cpp
+++ b/engines/watchmaker/walk/act.cpp
@@ -214,9 +214,10 @@ void CharSetPosition(int32 oc, uint8 pos, const char *room) {
CharStop(oc);
if (pos == 99) return;
if (room && (room[0] != '\0')) {
- for (i = 0; i < NumLoadedFiles; i++)
- if ((LoadedFiles[i].b != nullptr) && LoadedFiles[i].b->name.equalsIgnoreCase(room))
- t3dCurRoom = LoadedFiles[i].b;
+ t3dBODY *roomPtr = _vm->_roomManager->getRoomIfLoaded(room);
+ if (roomPtr) {
+ t3dCurRoom = roomPtr;
+ }
}
if (pos) {
Commit: e9ea8771336a79c3b9f37e0b6f794066d74218c7
https://github.com/scummvm/scummvm/commit/e9ea8771336a79c3b9f37e0b6f794066d74218c7
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Add constexpr constructors for t3dV3F and t3dNORMAL
Changed paths:
engines/watchmaker/3d/types3d.h
engines/watchmaker/t3d.h
diff --git a/engines/watchmaker/3d/types3d.h b/engines/watchmaker/3d/types3d.h
index b6dbf22a30f..7ec31ad30cd 100644
--- a/engines/watchmaker/3d/types3d.h
+++ b/engines/watchmaker/3d/types3d.h
@@ -105,7 +105,7 @@ struct t3dNORMAL {
t3dF32 tras_n = 0.0f; //transformed normal 4
uint8 flag = 0; //flags 1
public:
- t3dNORMAL() {}
+ constexpr t3dNORMAL() = default;
t3dNORMAL(Common::SeekableReadStream &stream) {
n = t3dV3F(stream); // Direzione
dist = -stream.readFloatLE(); // Distanza-Dot
diff --git a/engines/watchmaker/t3d.h b/engines/watchmaker/t3d.h
index 7a0227b07f2..ef72a11acc8 100644
--- a/engines/watchmaker/t3d.h
+++ b/engines/watchmaker/t3d.h
@@ -116,6 +116,7 @@ namespace Watchmaker {
struct t3dM3X3F {
t3dF32 M[9] = {}; // Matrix 3 x 3
uint8 Flags = 0; // flags: if identity
+ constexpr t3dM3X3F() = default;
};
struct t3dBONE {
Commit: a63b88708230d9d974c3302d318e8ac6c3fac99a
https://github.com/scummvm/scummvm/commit/a63b88708230d9d974c3302d318e8ac6c3fac99a
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Drop empty surface.h header
Changed paths:
R engines/watchmaker/surface.h
engines/watchmaker/3d/texture.h
engines/watchmaker/render.h
diff --git a/engines/watchmaker/3d/texture.h b/engines/watchmaker/3d/texture.h
index 915021b1a18..4c21a904350 100644
--- a/engines/watchmaker/3d/texture.h
+++ b/engines/watchmaker/3d/texture.h
@@ -28,7 +28,6 @@
#include "watchmaker/3d/dds_header.h"
#include "graphics/surface.h"
#include "watchmaker/rect.h"
-#include "watchmaker/surface.h"
namespace Watchmaker {
diff --git a/engines/watchmaker/render.h b/engines/watchmaker/render.h
index d7a39f84309..15bf9fda093 100644
--- a/engines/watchmaker/render.h
+++ b/engines/watchmaker/render.h
@@ -24,7 +24,6 @@
#include "common/array.h"
#include "watchmaker/types.h"
-#include "watchmaker/surface.h"
#include "watchmaker/windows_hacks.h"
#include "watchmaker/3d/texture.h"
#include "watchmaker/3d/material.h"
diff --git a/engines/watchmaker/surface.h b/engines/watchmaker/surface.h
deleted file mode 100644
index c313695669a..00000000000
--- a/engines/watchmaker/surface.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* 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 WATCHMAKER_SURFACE_H
-#define WATCHMAKER_SURFACE_H
-
-namespace Watchmaker {
-
-} // End of namespace Watchmaker
-
-#endif // WATCHMAKER_SURFACE_H
Commit: e973308d64a496d20c8199d42528c5979ca86ed9
https://github.com/scummvm/scummvm/commit/e973308d64a496d20c8199d42528c5979ca86ed9
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix setDirectoryAndName to split on the last \, not the first.
(Which is what the original did)
Changed paths:
engines/watchmaker/3d/light.cpp
diff --git a/engines/watchmaker/3d/light.cpp b/engines/watchmaker/3d/light.cpp
index a2386cad3d0..495bb7e1c89 100644
--- a/engines/watchmaker/3d/light.cpp
+++ b/engines/watchmaker/3d/light.cpp
@@ -147,9 +147,13 @@ uint8 LightgVertex(gVertex *v, t3dLIGHT *light) {
Common::String setDirectoryAndName(const Common::String &path, const Common::String &name) {
int32 len = name.size();
- auto backSlashPos = name.findFirstOf("\\");
+ auto backSlashPos = name.findLastOf("\\");
- return path + name.substr(backSlashPos + 1, name.size() - (backSlashPos + 1));
+ if (backSlashPos != Common::String::npos) {
+ len = backSlashPos;
+ }
+
+ return path + name.substr(0, len);
}
/* -----------------29/05/99 12.03-------------------
Commit: 6e705c0665bc27e003da7ce47c594c39783fddba
https://github.com/scummvm/scummvm/commit/6e705c0665bc27e003da7ce47c594c39783fddba
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Fix missing break on EVENT_QUIT-handling
Changed paths:
engines/watchmaker/sdl_wrapper.cpp
diff --git a/engines/watchmaker/sdl_wrapper.cpp b/engines/watchmaker/sdl_wrapper.cpp
index b752d38ac2f..e64a046c21a 100644
--- a/engines/watchmaker/sdl_wrapper.cpp
+++ b/engines/watchmaker/sdl_wrapper.cpp
@@ -55,6 +55,7 @@ void sdl_wrapper::pollSDL() {
break;
case Common::EVENT_QUIT:
shouldQuit = true;
+ break;
default:
warning("Unhandled event: %d", event.type);
}
Commit: 8747a1c620e2d8d6ac6b8f79ab8d89b3d647b512
https://github.com/scummvm/scummvm/commit/8747a1c620e2d8d6ac6b8f79ab8d89b3d647b512
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Adjust the DIALOG sizes to match the retail expectations.
Changed paths:
engines/watchmaker/sysdef.h
diff --git a/engines/watchmaker/sysdef.h b/engines/watchmaker/sysdef.h
index 8185c413037..97cb7735bc9 100644
--- a/engines/watchmaker/sysdef.h
+++ b/engines/watchmaker/sysdef.h
@@ -35,10 +35,10 @@ namespace Watchmaker {
#define MAX_ICONS 86 // oggetti d'inventario
#define MAX_SOUNDS 1120 // numero massimo di sample nel gioco
#define MAX_MUSICS 24 // numero massimo di musiche nel gioco
-#define MAX_DIALOGS 112 // numero dialoghi e full-motion
+#define MAX_DIALOGS 114 // numero dialoghi e full-motion
#define MAX_DIARIES 44 // numero di diari dei personaggi
#define MAX_DLG_MENUS 100 // numero di menu e sotto menu per i dialoghi
-#define MAX_DLG_ITEMS 339 // numero massimo item per dialoghi
+#define MAX_DLG_ITEMS 341 // numero massimo item per dialoghi
#define MAX_PLAYERS 2 // numero personaggi principali giocanti
#define MAX_ENVIRONMENTS 32 // numero massimo di environments presenti
#define MAX_MODIFIED_MESH 1536 // numero mesh modifiers
Commit: 823932c9e1bed2e509e0fe3c93cf1822804a4868
https://github.com/scummvm/scummvm/commit/823932c9e1bed2e509e0fe3c93cf1822804a4868
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Remove hack for skipping intro
Changed paths:
engines/watchmaker/classes/do_keyboard.cpp
diff --git a/engines/watchmaker/classes/do_keyboard.cpp b/engines/watchmaker/classes/do_keyboard.cpp
index 79447dfe444..04ae0a491e4 100644
--- a/engines/watchmaker/classes/do_keyboard.cpp
+++ b/engines/watchmaker/classes/do_keyboard.cpp
@@ -232,16 +232,6 @@ void HandleFirstPersonView(void) {
void ProcessKeyboard(WGame &game) {
//warning("STUBBED: ProcessKeyboard");
- // Hack: Skip intro:
- if ((CurDialog == dR000) || (CurDialog == dR111) || (CurDialog == dR211)) {
- NextDlg = dNULL;
- _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND_SKIPINTRO, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
- }
- // Skip Loghi
- if (CurDialog == dRLOGHI)
- _vm->_messageSystem.doEvent(EventClass::MC_DIALOG, ME_DIALOGEND, MP_DEFAULT, (int16)CurDialog, mQUIT, 0, NULL, NULL, NULL);
- // End hack
-
t3dF32 TurnSpeed, Speed = 1.0f, dist;
t3dV3F cp, cd, ct;
int32 a, b;
Commit: 76707bbac82f33ee2233956a6bf54def49a86b85
https://github.com/scummvm/scummvm/commit/76707bbac82f33ee2233956a6bf54def49a86b85
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Move GL Texture logic to its own file
Changed paths:
A engines/watchmaker/3d/render/opengl_texture.cpp
A engines/watchmaker/3d/render/opengl_texture.h
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_3d.cpp
engines/watchmaker/3d/render/opengl_renderer.cpp
engines/watchmaker/3d/render/opengl_renderer.h
engines/watchmaker/module.mk
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index a1240524de1..8d0b159c47d 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -141,24 +141,6 @@ bool gClipToBlitterViewport(int *sposx, int *sposy, int *sdimx, int *sdimy,
return true;
}
-void enter2Dmode(WGame &game) {
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
- checkGlError("Exiting enter2Dmode");
-}
-
-void exit2Dmode() {
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- checkGlError("exit2Dmode");
-}
-
void renderTexture(WGame &game, gTexture &bitmap, Rect srcRect, Rect dstRect) {
checkGlError("Entering renderTexture");
glClearColor(0, 0, 1, 0);
@@ -216,9 +198,9 @@ void gTexture::render(WGame &game, Rect src, Rect dst) {
void Renderer::blitScreenBuffer() {
checkGlError("Entering rBlitScreenBuffer");
- enter2Dmode(*_game);
+ g_renderer->enter2Dmode();
_bitmapList.bitmaps[BACK_BUFFER].render(*_game, _game->_renderer->_viewport, _game->_renderer->_viewport);
- exit2Dmode();
+ g_renderer->exit2Dmode();
checkGlError("Exiting rBlitScreenBuffer");
}
diff --git a/engines/watchmaker/3d/render/opengl_3d.cpp b/engines/watchmaker/3d/render/opengl_3d.cpp
index 593aea594d7..5898454e6e7 100644
--- a/engines/watchmaker/3d/render/opengl_3d.cpp
+++ b/engines/watchmaker/3d/render/opengl_3d.cpp
@@ -553,63 +553,6 @@ gTexture *gUserTexture(Texture *texture, unsigned int dimx, unsigned int dimy) {
return Texture;
}
-GLuint dxtCompressionToTextureFormat(DxtCompression compression) {
- switch (compression) {
- case DxtCompression::UNCOMPRESSED:
- return GL_RGBA;
- case DxtCompression::DXT1:
- return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- case DxtCompression::DXT2:
- error("DXT2 Support is not implemented");
- case DxtCompression::DXT3:
- return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
- case DxtCompression::DXT4:
- error("DXT4 Support is not implemented");
- case DxtCompression::DXT5:
- return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
- }
-}
-
-class OpenGLTexture : public Texture {
-public:
- unsigned int _texId;
- OpenGLTexture() {
- glGenTextures(1, &_texId);
- }
- OpenGLTexture(unsigned int texId) : _texId(texId) {}
- void assignData(const TextureData &data) override {
- glBindTexture(GL_TEXTURE_2D, _texId);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-
- // TODO: Check both compiletime and runtime for the existence of EXT_texture_compression_s3tc
- GLuint texFormat = dxtCompressionToTextureFormat(data._compression);
- bool compressed = data._compression != DxtCompression::UNCOMPRESSED;
-
- if (compressed) {
- glCompressedTexImage2D(GL_TEXTURE_2D, // target
- 0, // level
- texFormat, // internalFormat
- data.getWidth(), // width
- data.getHeight(), // height
- 0, // border
- data.getDataSize(),
- data.getData()
- );
- checkGlError("glCompressedTexImage");
- } else {
- glTexImage2D(GL_TEXTURE_2D, 0, texFormat, data.getWidth(), data.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data.getData());
- checkGlError("glTexImage2D");
- }
- }
- void bind() override {
- glBindTexture(GL_TEXTURE_2D, _texId);
- checkGlError("OpenGLTexture::bind");
- };
-};
-
class SurfaceBackedTextureData : public TextureData {
bool _owned = true;
public:
@@ -635,10 +578,6 @@ public:
}
};
-Texture *createGLTexture() {
- return new OpenGLTexture();
-}
-
Common::SharedPtr<TextureData> createTextureFromSurface(Graphics::Surface &surface, int texFormat) {
return Common::SharedPtr<TextureData>(new SurfaceBackedTextureData(&surface, false));
}
@@ -710,7 +649,7 @@ gTexture *gLoadTexture(WorkDirs &workDirs, const char *TextName, unsigned int Lo
}
texture = &gTextureList[pos];
*texture = gTexture();
- texture->_texture = new OpenGLTexture();
+ texture->_texture = createGLTexture();
if (bUseAlternate) {
auto stream = workDirs.resolveFile(AlternateName);
diff --git a/engines/watchmaker/3d/render/opengl_renderer.cpp b/engines/watchmaker/3d/render/opengl_renderer.cpp
index 55b82116bac..0608fb25a06 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.cpp
+++ b/engines/watchmaker/3d/render/opengl_renderer.cpp
@@ -209,6 +209,24 @@ void OpenGLRenderer::setBlendFunc(BlendFactor src, BlendFactor dst) {
glBlendFunc(translateBlendFactorToGL(src), translateBlendFactorToGL(dst));
}
+void OpenGLRenderer::enter2Dmode() {
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ checkGlError("Exiting enter2Dmode");
+}
+
+void OpenGLRenderer::exit2Dmode() {
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ checkGlError("exit2Dmode");
+}
+
} // End of namespace Watchmaker
#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/3d/render/opengl_renderer.h b/engines/watchmaker/3d/render/opengl_renderer.h
index 8e294e210e6..69d967cbe46 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.h
+++ b/engines/watchmaker/3d/render/opengl_renderer.h
@@ -72,6 +72,9 @@ Texture *createGLTexture();
class OpenGLRenderer {
public:
+ void enter2Dmode();
+ void exit2Dmode();
+
void pushModelView();
void popModelView();
void setTransformMatrix(TransformMatrix which, const Matrix4x4 &matrix);
diff --git a/engines/watchmaker/3d/render/opengl_texture.cpp b/engines/watchmaker/3d/render/opengl_texture.cpp
new file mode 100644
index 00000000000..d30ff3d7f27
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl_texture.cpp
@@ -0,0 +1,95 @@
+/* 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 "watchmaker/3d/render/opengl_texture.h"
+#include "common/textconsole.h"
+#include "graphics/opengl/system_headers.h"
+#include "watchmaker/3d/dds_header.h"
+#include "watchmaker/render.h"
+
+#ifdef USE_OPENGL_GAME
+
+namespace Watchmaker {
+
+GLuint dxtCompressionToTextureFormat(DxtCompression compression) {
+ switch (compression) {
+ case DxtCompression::UNCOMPRESSED:
+ return GL_RGBA;
+ case DxtCompression::DXT1:
+ return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ case DxtCompression::DXT2:
+ error("DXT2 Support is not implemented");
+ case DxtCompression::DXT3:
+ return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
+ case DxtCompression::DXT4:
+ error("DXT4 Support is not implemented");
+ case DxtCompression::DXT5:
+ return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
+ }
+}
+
+class OpenGLTexture : public Texture {
+public:
+ unsigned int _texId;
+ OpenGLTexture() {
+ glGenTextures(1, &_texId);
+ }
+ OpenGLTexture(unsigned int texId) : _texId(texId) {}
+ void assignData(const TextureData &data) override {
+ glBindTexture(GL_TEXTURE_2D, _texId);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+
+ // TODO: Check both compiletime and runtime for the existence of EXT_texture_compression_s3tc
+ GLuint texFormat = dxtCompressionToTextureFormat(data._compression);
+ bool compressed = data._compression != DxtCompression::UNCOMPRESSED;
+
+ if (compressed) {
+ glCompressedTexImage2D(GL_TEXTURE_2D, // target
+ 0, // level
+ texFormat, // internalFormat
+ data.getWidth(), // width
+ data.getHeight(), // height
+ 0, // border
+ data.getDataSize(),
+ data.getData()
+ );
+ checkGlError("glCompressedTexImage");
+ } else {
+ glTexImage2D(GL_TEXTURE_2D, 0, texFormat, data.getWidth(), data.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data.getData());
+ checkGlError("glTexImage2D");
+ }
+ }
+ void bind() override {
+ glBindTexture(GL_TEXTURE_2D, _texId);
+ checkGlError("OpenGLTexture::bind");
+ };
+};
+
+Texture *createGLTexture() {
+ return new OpenGLTexture();
+}
+
+} // End of namespace Watchmaker
+
+#endif // USE_OPENGL_GAME
diff --git a/engines/watchmaker/3d/render/opengl_texture.h b/engines/watchmaker/3d/render/opengl_texture.h
new file mode 100644
index 00000000000..8822b997026
--- /dev/null
+++ b/engines/watchmaker/3d/render/opengl_texture.h
@@ -0,0 +1,32 @@
+/* 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 WATCHMAKER_3D_OPENGL_TEXTURE_H
+#define WATCHMAKER_3D_OPENGL_TEXTURE_H
+
+namespace Watchmaker {
+
+class Texture;
+Texture *createGLTexture();
+
+} // End of namespace Watchmaker
+
+#endif // WATCHMAKER_3D_OPENGL_TEXTURE_H
diff --git a/engines/watchmaker/module.mk b/engines/watchmaker/module.mk
index 6bc8ca25795..e94b5eebc75 100644
--- a/engines/watchmaker/module.mk
+++ b/engines/watchmaker/module.mk
@@ -15,6 +15,7 @@ MODULE_OBJS = \
3d/render/opengl_2d.o \
3d/render/opengl_3d.o \
3d/render/opengl_renderer.o \
+ 3d/render/opengl_texture.o \
3d/render/render.o \
3d/render/shadows.o \
3d/t3d_body.o \
Commit: 962bac59b76cd6465b2c2681515a86a1af018cf2
https://github.com/scummvm/scummvm/commit/962bac59b76cd6465b2c2681515a86a1af018cf2
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Optimize file loading by a lot (by not iterating over SearchMan)
Changed paths:
engines/watchmaker/ll/ll_system.cpp
diff --git a/engines/watchmaker/ll/ll_system.cpp b/engines/watchmaker/ll/ll_system.cpp
index 5d3d14d005d..85f30f3e6d0 100644
--- a/engines/watchmaker/ll/ll_system.cpp
+++ b/engines/watchmaker/ll/ll_system.cpp
@@ -158,32 +158,13 @@ Common::String adjustPath(const Common::String &path) {
bool checkFileExists(const Common::String &filename) {
Common::String adjustedPath = adjustPath(filename);
- Common::ArchiveMemberList files;
- SearchMan.listMatchingMembers(files, adjustedPath);
-
- for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) {
- if ((*it)->getName().equalsIgnoreCase(lastPathComponent(adjustedPath, '/'))) {
- return true;
- }
- }
-
- return false;
+ return SearchMan.hasFile(adjustedPath);
}
Common::SharedPtr<Common::SeekableReadStream> openFile(const Common::String &filename, int offset, int size) {
Common::String adjustedPath = adjustPath(filename);
- Common::SeekableReadStream *file = nullptr;
- // Try directly from SearchMan first
- Common::ArchiveMemberList files;
- SearchMan.listMatchingMembers(files, adjustedPath);
-
- for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) {
- if ((*it)->getName().equalsIgnoreCase(lastPathComponent(adjustedPath, '/'))) {
- file = (*it)->createReadStream();
- break;
- }
- }
+ Common::SeekableReadStream *file = SearchMan.createReadStreamForMember(adjustedPath);
if (offset != 0 || size != -1) {
if (size == -1) {
Commit: c4c13ba8f7a977600975128e078d3b17f71f651b
https://github.com/scummvm/scummvm/commit/c4c13ba8f7a977600975128e078d3b17f71f651b
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:01:08+02:00
Commit Message:
WATCHMAKER: Silence some warnings.
Changed paths:
engines/watchmaker/3d/material.cpp
engines/watchmaker/3d/math/Matrix4x4.h
engines/watchmaker/3d/render/opengl_2d.cpp
engines/watchmaker/3d/render/opengl_renderer.cpp
engines/watchmaker/3d/render/render.cpp
engines/watchmaker/3d/t3d_face.h
engines/watchmaker/globvar.h
engines/watchmaker/schedule.cpp
engines/watchmaker/work_dirs.h
diff --git a/engines/watchmaker/3d/material.cpp b/engines/watchmaker/3d/material.cpp
index 3f553a288a1..28ab82e5999 100644
--- a/engines/watchmaker/3d/material.cpp
+++ b/engines/watchmaker/3d/material.cpp
@@ -248,9 +248,9 @@ void rAddToMaterialList(gMaterial &mat, signed short int ViewMatrixNum) {
bb->ViewMatrixNum = ViewMatrixNum;
bb->FacesList = mat.getFacesList();
bb->VBO = mat.VBO;
- for (int f = 0; f < bb->FacesList.size(); f++) {
+ for (uint f = 0; f < bb->FacesList.size(); f++) {
if (bb->FacesList[f] >= bb->VBO->_buffer.size()) {
- for (int o = 0; o < bb->FacesList.size(); o++) {
+ for (uint o = 0; o < bb->FacesList.size(); o++) {
warning("%d", bb->FacesList[o]);
}
warning("%d > %d (%d)", bb->FacesList[f], bb->VBO->_buffer.size(), bb->NumVerts());
diff --git a/engines/watchmaker/3d/math/Matrix4x4.h b/engines/watchmaker/3d/math/Matrix4x4.h
index 2a321ce262e..b2af09dbe81 100644
--- a/engines/watchmaker/3d/math/Matrix4x4.h
+++ b/engines/watchmaker/3d/math/Matrix4x4.h
@@ -48,7 +48,7 @@ struct Matrix4x4 {
for (int col = 1; col <= 4; col++) {
warning("%f ", getValue(row, col));
}
- warning("");
+ warning(" ");
}
}
bool operator==(const Matrix4x4 &rhs) const {
diff --git a/engines/watchmaker/3d/render/opengl_2d.cpp b/engines/watchmaker/3d/render/opengl_2d.cpp
index 8d0b159c47d..6dfdb343398 100644
--- a/engines/watchmaker/3d/render/opengl_2d.cpp
+++ b/engines/watchmaker/3d/render/opengl_2d.cpp
@@ -191,7 +191,7 @@ void gTexture::render(WGame &game, Rect src, Rect dst) {
if (_texture) {
renderTexture(game, *this, src, dst);
}
- for (int i = 0; i < _blitsOnTop.size(); i++) {
+ for (uint i = 0; i < _blitsOnTop.size(); i++) {
_blitsOnTop[i].texture->render(game, _blitsOnTop[i].src, _blitsOnTop[i].dst);
}
}
diff --git a/engines/watchmaker/3d/render/opengl_renderer.cpp b/engines/watchmaker/3d/render/opengl_renderer.cpp
index 0608fb25a06..8eaa5aaa5ba 100644
--- a/engines/watchmaker/3d/render/opengl_renderer.cpp
+++ b/engines/watchmaker/3d/render/opengl_renderer.cpp
@@ -61,8 +61,8 @@ void OpenGLRenderer::drawIndexedPrimitivesVBO(PrimitiveType primitiveType, Commo
glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLES);
- for (int i = 0; i < numFaces; i++) {
- int index = faces[i];
+ for (uint32 i = 0; i < numFaces; i++) {
+ uint16 index = faces[i];
assert(index <= VBO->_buffer.size());
auto &vertex = VBO->_buffer[index];
//warning("%d/%d %d: [%f, %f, %f], [%f, %f], [%f, %f]", i, numFaces, index, vertex.x, vertex.y, vertex.z, vertex.u1, vertex.v1, vertex.u2, vertex.v2);
diff --git a/engines/watchmaker/3d/render/render.cpp b/engines/watchmaker/3d/render/render.cpp
index 521b1f3a26e..f9b7a026805 100644
--- a/engines/watchmaker/3d/render/render.cpp
+++ b/engines/watchmaker/3d/render/render.cpp
@@ -148,7 +148,7 @@ void RenderGeometry(void) {
LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
bb = &BatchBlockList[0];
qsort(bb, NumBatchBlocks, sizeof(gBatchBlock), cmpbb);
- for (int i = 0; i < NumBatchBlocks; i++, bb++) {
+ for (uint i = 0; i < NumBatchBlocks; i++, bb++) {
if (bb->Texture1 < 0) continue;
if (bb->ViewMatrixNum != LastViewMatrixNum) {
@@ -217,7 +217,7 @@ void RenderGeometry(void) {
LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
bb = &BatchBlockList[0];
- for (int i = 0; i < NumBatchBlocks; i++, bb++) {
+ for (uint i = 0; i < NumBatchBlocks; i++, bb++) {
if (bb->Texture2 <= 0) continue;
if (bb->ViewMatrixNum != LastViewMatrixNum) {
@@ -255,7 +255,7 @@ void RenderGeometry(void) {
LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
bb = &BatchBlockListSpecial[0];
qsort(bb, NumBatchBlocksSpecial, sizeof(gBatchBlock), cmpbb);
- for (int i = 0; i < NumBatchBlocksSpecial; i++, bb++) {
+ for (uint i = 0; i < NumBatchBlocksSpecial; i++, bb++) {
if (bb->Texture1 < 0) continue;
if (!(bb->Flags1 & T3D_MATERIAL_CLIPMAP) ||
(bb->Flags1 & T3D_MATERIAL_FLARE) ||
@@ -293,7 +293,7 @@ void RenderGeometry(void) {
LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
bb = &BatchBlockListSpecial[0];
- for (int i = 0; i < NumBatchBlocksSpecial; i++, bb++) {
+ for (uint i = 0; i < NumBatchBlocksSpecial; i++, bb++) {
if (bb->Texture1 < 0) continue;
if (!(bb->Flags1 & T3D_MATERIAL_FLARE) &&
!(bb->Flags1 & T3D_MATERIAL_SMOKE))
@@ -344,7 +344,7 @@ void RenderGeometry(void) {
LastViewMatrixNum = LastTexture1 = LastTexture2 = -2;
bb = &BatchBlockListSpecial[0];
- for (int i = 0; i < NumBatchBlocksSpecial; i++, bb++) {
+ for (uint i = 0; i < NumBatchBlocksSpecial; i++, bb++) {
if (bb->Texture1 < 0) continue;
if ((bb->Flags1 & T3D_MATERIAL_FLARE) ||
(bb->Flags1 & T3D_MATERIAL_SMOKE))
diff --git a/engines/watchmaker/3d/t3d_face.h b/engines/watchmaker/3d/t3d_face.h
index 50ff417af8b..f070128b5fe 100644
--- a/engines/watchmaker/3d/t3d_face.h
+++ b/engines/watchmaker/3d/t3d_face.h
@@ -66,7 +66,7 @@ public:
void checkVertices() {
for (int i = 0; i < 3; i++) {
- assert(getMaterial()->VertsList.size() > MatVertexIndex[i]);
+ assert((int)getMaterial()->VertsList.size() > MatVertexIndex[i]);
}
}
diff --git a/engines/watchmaker/globvar.h b/engines/watchmaker/globvar.h
index 447733776f3..9e66d8cae16 100644
--- a/engines/watchmaker/globvar.h
+++ b/engines/watchmaker/globvar.h
@@ -174,7 +174,7 @@ extern uint8 bSaveDisabled;
extern uint8 bLockCamera;
extern uint8 bMiscLoaded;
extern uint8 bStartMenuActive;
-extern uint8 bShowOnlyLoadWindow;;
+extern uint8 bShowOnlyLoadWindow;
extern uint8 bSbCacciatorehowOnlyLoadWindow;
extern uint8 bNotSkippableSent;
extern uint8 bPorteEsternoBloccate;
@@ -242,15 +242,14 @@ struct Init : public SerializableAsset {
}
private:
void treatCredits() {
-
- for (int i = 0; i < _creditsNames.size(); i++) {
+ for (uint32 i = 0; i < _creditsNames.size(); i++) {
char *c = _creditsNames[i].name;
for (int k = 0; k < 32; k++, c++) {
(*c) ^= 0xA0;
}
}
- for (int i = 0; i < _creditsRoles.size(); i++) {
+ for (uint32 i = 0; i < _creditsRoles.size(); i++) {
char *c = _creditsRoles[i].role;
for (int k = 0; k < 48; k++, c++) {
(*c) ^= 0xC4;
diff --git a/engines/watchmaker/schedule.cpp b/engines/watchmaker/schedule.cpp
index aec06b90df2..8e16142f781 100644
--- a/engines/watchmaker/schedule.cpp
+++ b/engines/watchmaker/schedule.cpp
@@ -113,6 +113,8 @@ const char *eventToString(EventClass classe) {
case EventClass::MC_DIALOG: return "MC_DIALOG";
case EventClass::MC_ANIM: return "MC_ANIM";
case EventClass::MC_T2D: return "MC_T2D";
+ default:
+ error("Invalid EventClass %d", (int)classe);
}
}
diff --git a/engines/watchmaker/work_dirs.h b/engines/watchmaker/work_dirs.h
index 22c536e08a2..4e60ce3bb55 100644
--- a/engines/watchmaker/work_dirs.h
+++ b/engines/watchmaker/work_dirs.h
@@ -59,7 +59,7 @@ public:
Common::String unwindowsify(const Common::String &str) const {
Common::String result; // TODO Rewrite
- for (int i = 0; i < str.size(); i++) {
+ for (uint i = 0; i < str.size(); i++) {
if (str[i] != '\\') {
result += str[i];
} else {
More information about the Scummvm-git-logs
mailing list