[Scummvm-git-logs] scummvm master -> 3e03257b2b96600219d3c014d02ee7236ee2358e
sev-
noreply at scummvm.org
Thu Apr 10 20:50:51 UTC 2025
This automated email contains information about 10 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
7e9dc7a2e0 ALG: Initial version
1ea02c3bbd ALG: fix MSVC errors and warnings
c6740e1c36 ALG: formatting, code style, implement feedback
a8205c964d ALG: Graphics: fix unnecessary copying of surfaces on load
7f7446f145 ALG: moved game-specific files to logic sub-folder
a009324785 ALG: fix a few memory leaks (hopefully)
ec6926052e ALG: Refactoring, feedback implemented, bug fixes
8537d9913f ALG: Implement some fixes from review
a6366061c3 ALG: refactoring from PR feedback
3e03257b2b ALG: Video and graphics refactoring
Commit: 7e9dc7a2e05244c4985181fd35d9d141492ae82d
https://github.com/scummvm/scummvm/commit/7e9dc7a2e05244c4985181fd35d9d141492ae82d
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: Initial version
Changed paths:
A engines/alg/alg.cpp
A engines/alg/alg.h
A engines/alg/configure.engine
A engines/alg/detection.cpp
A engines/alg/detection_tables.h
A engines/alg/game.cpp
A engines/alg/game.h
A engines/alg/game_bountyhunter.cpp
A engines/alg/game_bountyhunter.h
A engines/alg/game_crimepatrol.cpp
A engines/alg/game_crimepatrol.h
A engines/alg/game_drugwars.cpp
A engines/alg/game_drugwars.h
A engines/alg/game_johnnyrock.cpp
A engines/alg/game_johnnyrock.h
A engines/alg/game_maddog.cpp
A engines/alg/game_maddog.h
A engines/alg/game_maddog2.cpp
A engines/alg/game_maddog2.h
A engines/alg/game_spacepirates.cpp
A engines/alg/game_spacepirates.h
A engines/alg/graphics.cpp
A engines/alg/graphics.h
A engines/alg/metaengine.cpp
A engines/alg/module.mk
A engines/alg/scene.cpp
A engines/alg/scene.h
A engines/alg/video.cpp
A engines/alg/video.h
diff --git a/engines/alg/alg.cpp b/engines/alg/alg.cpp
new file mode 100644
index 00000000000..71f8d4e2a16
--- /dev/null
+++ b/engines/alg/alg.cpp
@@ -0,0 +1,85 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "engines/util.h"
+
+#include "alg/alg.h"
+#include "alg/game.h"
+#include "alg/game_bountyhunter.h"
+#include "alg/game_crimepatrol.h"
+#include "alg/game_drugwars.h"
+#include "alg/game_johnnyrock.h"
+#include "alg/game_maddog.h"
+#include "alg/game_maddog2.h"
+#include "alg/game_spacepirates.h"
+
+namespace Alg {
+
+AlgEngine::AlgEngine(OSystem *syst, const ADGameDescription *desc)
+ : Engine(syst) {
+ if (scumm_stricmp(desc->gameId, "cpatrols") == 0 || scumm_stricmp(desc->gameId, "cpatrold") == 0 || scumm_stricmp(desc->gameId, "cpatroldemo") == 0) {
+ GameCrimePatrol *game = new GameCrimePatrol(this, desc);
+ _debugger = new DebuggerCrimePatrol(game);
+ _game = game;
+ } else if (scumm_stricmp(desc->gameId, "dwarss") == 0 || scumm_stricmp(desc->gameId, "dwarsd") == 0 || scumm_stricmp(desc->gameId, "dwarsdemo") == 0) {
+ GameDrugWars *game = new GameDrugWars(this, desc);
+ _debugger = new DebuggerDrugWars(game);
+ _game = game;
+ } else if (scumm_stricmp(desc->gameId, "johnrocs") == 0 || scumm_stricmp(desc->gameId, "johnrocd") == 0) {
+ GameJohnnyRock *game = new GameJohnnyRock(this, desc);
+ _debugger = new DebuggerJohnnyRock(game);
+ _game = game;
+ } else if (scumm_stricmp(desc->gameId, "lbhunter") == 0 || scumm_stricmp(desc->gameId, "lbhunterdemo") == 0) {
+ GameBountyHunter *game = new GameBountyHunter(this, desc);
+ _debugger = new DebuggerBountyHunter(game);
+ _game = game;
+ } else if (scumm_stricmp(desc->gameId, "maddog") == 0) {
+ GameMaddog *game = new GameMaddog(this, desc);
+ _debugger = new DebuggerMaddog(game);
+ _game = game;
+ } else if (scumm_stricmp(desc->gameId, "maddog2s") == 0 || scumm_stricmp(desc->gameId, "maddog2d") == 0) {
+ GameMaddog2 *game = new GameMaddog2(this, desc);
+ _debugger = new DebuggerMaddog2(game);
+ _game = game;
+ } else if (scumm_stricmp(desc->gameId, "spiratess") == 0 || scumm_stricmp(desc->gameId, "spiratesd") == 0 || scumm_stricmp(desc->gameId, "spiratesdemo") == 0) {
+ GameSpacePirates *game = new GameSpacePirates(this, desc);
+ _debugger = new DebuggerSpacePirates(game);
+ _game = game;
+ }
+}
+
+AlgEngine::~AlgEngine() {
+ delete _game;
+}
+
+Common::Error AlgEngine::run() {
+ initGraphics(320, 200);
+ setDebugger(_debugger);
+ return _game->run();
+}
+
+bool AlgEngine::hasFeature(EngineFeature f) const {
+ return (f == kSupportsReturnToLauncher) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
+}
+
+} // End of namespace Alg
diff --git a/engines/alg/alg.h b/engines/alg/alg.h
new file mode 100644
index 00000000000..f1bb02b15c9
--- /dev/null
+++ b/engines/alg/alg.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 ALG_ALG_H
+#define ALG_ALG_H
+
+#include "engines/advancedDetector.h"
+#include "gui/debugger.h"
+
+namespace Alg {
+
+class Game;
+class GameBountyHunter;
+class GameCrimePatrol;
+class GameDrugWars;
+class GameJohnnyRock;
+class GameMaddog;
+class GameMaddog2;
+class GameSpacePirates;
+
+enum {
+ kAlgDebugGeneral = 1 << 0,
+ kAlgDebugGraphics = 1 << 1
+};
+
+class AlgEngine : public Engine {
+public:
+ AlgEngine(OSystem *syst, const ADGameDescription *desc);
+ ~AlgEngine();
+
+ Common::Error run();
+
+ bool hasFeature(EngineFeature f) const;
+
+private:
+ Game *_game;
+ GUI::Debugger *_debugger;
+};
+
+class Console : public GUI::Debugger {
+public:
+ Console(AlgEngine *vm) {
+ }
+ virtual ~Console(void) {
+ }
+};
+
+} // End of namespace Alg
+
+#endif
diff --git a/engines/alg/configure.engine b/engines/alg/configure.engine
new file mode 100644
index 00000000000..18b80705aed
--- /dev/null
+++ b/engines/alg/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 alg "American Laser Games" no
diff --git a/engines/alg/detection.cpp b/engines/alg/detection.cpp
new file mode 100644
index 00000000000..b2d395fc2ad
--- /dev/null
+++ b/engines/alg/detection.cpp
@@ -0,0 +1,78 @@
+/* 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 "alg/detection_tables.h"
+#include "alg/alg.h"
+
+static const PlainGameDescriptor algGame[] = {
+ { "cpatrols", "Crime Patrol (lower video quality)" },
+ { "cpatrold", "Crime Patrol" },
+ { "cpatroldemo", "Crime Patrol Demo" },
+ { "dwarss", "Drug Wars (lower video quality)" },
+ { "dwarsd", "Drug Wars" },
+ { "dwarsdemo", "Drug Wars Demo" },
+ { "johnrocs", "Who Shot Johnny Rock? (lower video quality)" },
+ { "johnrocd", "Who Shot Johnny Rock?" },
+ { "lbhunter", "The Last Bounty Hunter" },
+ { "lbhunterdemo", "The Last Bounty Hunter Demo" },
+ { "maddog", "Mad Dog McCree" },
+ { "maddog2s", "Mad Dog II: The Lost Gold (lower video quality)" },
+ { "maddog2d", "Mad Dog II: The Lost Gold" },
+ { "spiratess", "Space Pirates (lower video quality)" },
+ { "spiratesd", "Space Pirates" },
+ { "spiratesdemo", "Space Pirates Demo" },
+ { nullptr, nullptr }
+};
+
+static const DebugChannelDef debugFlagList[] = {
+ { Alg::kAlgDebugGeneral, "general", "General" },
+ { Alg::kAlgDebugGraphics, "graphics", "Graphics" },
+ DEBUG_CHANNEL_END
+};
+
+class AlgMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDescription> {
+public:
+ AlgMetaEngineDetection() : AdvancedMetaEngineDetection(Alg::gameDescriptions, algGame) {
+ _guiOptions = GUIO1(GUIO_NOMIDI);
+ _maxScanDepth = 1;
+ }
+
+ const char *getName() const override {
+ return "alg";
+ }
+
+ const char *getEngineName() const override {
+ return "American Laser Games";
+ }
+
+ const char *getOriginalCopyright() const override {
+ return "Copyright (C) American Laser Games";
+ }
+
+ const DebugChannelDef *getDebugChannels() const override {
+ return debugFlagList;
+ }
+};
+
+REGISTER_PLUGIN_STATIC(ALG_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, AlgMetaEngineDetection);
diff --git a/engines/alg/detection_tables.h b/engines/alg/detection_tables.h
new file mode 100644
index 00000000000..313b702fca2
--- /dev/null
+++ b/engines/alg/detection_tables.h
@@ -0,0 +1,189 @@
+/* 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/>.
+ *
+ */
+
+namespace Alg {
+
+static const ADGameDescription gameDescriptions[] = {
+ {
+ // Crime Patrol (v1.00) (Single Speed CD-ROM Version)
+ "cpatrols",
+ "",
+ AD_ENTRY1s("CPSS.LIB", "feddb53975c9832c0f54055c15350389", 193353403),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Crime Patrol (v1.00) (Double Speed CD-ROM Version)
+ "cpatrold",
+ "",
+ AD_ENTRY1s("CPDS.LIB", "43579f72207298f154f6fb2b1a24e193", 303710700),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Crime Patrol Demo
+ "cpatroldemo",
+ "",
+ AD_ENTRY1s("CP.LIB", "0621e198afb7be96279beec770cd8461", 16859660),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Drug Wars (v1.00) (Single Speed CD-ROM Version)
+ "dwarss",
+ "",
+ AD_ENTRY1s("DWSS.LIB", "f041a2b106d3ba27b03b5695e5263172", 191903386),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Drug Wars (v1.00) (Double Speed CD-ROM Version)
+ "dwarsd",
+ "",
+ AD_ENTRY1s("DWDS.LIB", "f00bc0d980eac72b6bbfa691808b62ae", 320739868),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Drug Wars Demo
+ "dwarsdemo",
+ "",
+ AD_ENTRY1s("DWDEMO.LIB", "1f0cf57c8aeb326c37777c4ad82e7889", 24435449),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Who Shot Johnny Rock? (v1.00) (Single Speed CD-ROM Version)
+ "johnrocs",
+ "",
+ AD_ENTRY1s("JOHNROC.LIB", "3cbf7843ef2fdf23716301dceaa2eb10", 141833752),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Who Shot Johnny Rock? (v1.00) (Double Speed CD-ROM Version)
+ "johnrocd",
+ "",
+ AD_ENTRY1s("JOHNROCD.LIB", "93c38b5fc7d1ae6e9dccf4f7a1c313a8", 326535618),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // The Last Bounty Hunter (v1.00)
+ "lbhunter",
+ "",
+ AD_ENTRY1s("BHDS.LIB", "6fad52a6a72830ab3373cbe3e0a3a779", 281473503),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // The Last Bounty Hunter Demo
+ "lbhunterdemo",
+ "",
+ AD_ENTRY1s("BHDEMO.LIB", "af5fbbd5e18d96225077eb6bf2cac680", 28368775),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Mad Dog McCree (v1.03a)
+ "maddog",
+ "",
+ AD_ENTRY1s("MADDOG.LIB", "df27e760531dba600cb3ebc23a2d98d1", 114633310),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Mad Dog II: The Lost Gold (v1.00) (Single Speed CD-ROM Version)
+ "maddog2s",
+ "",
+ AD_ENTRY1s("MADDOG2.LIB", "7b54bca3932b28d8776eaed16a9f43b5", 185708043),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Mad Dog II: The Lost Gold (v1.00) (Double Speed CD-ROM Version)
+ "maddog2d",
+ "",
+ AD_ENTRY1s("MADDOG2D.LIB", "1660b1728573481483c50206ad92a0ca", 291119013),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Space Pirates (v1.00) (Single Speed CD-ROM Version)
+ "spiratess",
+ "",
+ AD_ENTRY1s("SPSS.LIB", "c006d9f85fd86024b57d69875f23c473", 175141152),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Space Pirates (v1.00) (Double Speed CD-ROM Version)
+ "spiratesd",
+ "",
+ AD_ENTRY1s("SPDS.LIB", "223d3a339d542905c437a6a63cf6dbd8", 273506701),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ {
+ // Space Pirates Demo
+ "spiratesdemo",
+ "",
+ AD_ENTRY1s("SP.LIB", "a1a1b7c9ed28ff2484ab8362825c3973", 14556553),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+
+ AD_TABLE_END_MARKER
+};
+
+} // End of namespace Alg
diff --git a/engines/alg/game.cpp b/engines/alg/game.cpp
new file mode 100644
index 00000000000..6fec0298210
--- /dev/null
+++ b/engines/alg/game.cpp
@@ -0,0 +1,533 @@
+/* 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 "audio/audiostream.h"
+#include "audio/decoders/raw.h"
+#include "common/events.h"
+#include "common/substream.h"
+#include "common/timer.h"
+#include "graphics/paletteman.h"
+
+#include "alg/graphics.h"
+#include "alg/scene.h"
+
+#include "alg/game.h"
+
+namespace Alg {
+
+Game::Game(AlgEngine *vm) {
+ _vm = vm;
+ _inMenu = false;
+ _palette = new uint8[257 * 3]();
+ // blue for rect display
+ _palette[5] = 0xFF;
+ _paletteDirty = true;
+ _screen = new Graphics::Surface();
+ _rnd = new Common::RandomSource("alg");
+ _screen->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
+ _videoDecoder = new AlgVideoDecoder();
+ _videoDecoder->setPalette(_palette);
+ _sceneInfo = new SceneInfo();
+}
+
+Game::~Game() {
+ _libFile.close();
+ _libFileEntries.clear();
+ delete _rnd;
+ delete[] _palette;
+ delete _screen;
+ delete _background;
+ delete _videoDecoder;
+ delete _sceneInfo;
+}
+
+Common::Error Game::run() {
+ return Common::kNoError;
+}
+
+bool Game::pollEvents() {
+ Common::Event event;
+ bool hasEvents = false;
+ while (g_system->getEventManager()->pollEvent(event)) {
+ if (event.type == Common::EVENT_MOUSEMOVE) {
+ _mousePos = event.mouse;
+ } else if (event.type == Common::EVENT_LBUTTONDOWN) {
+ _leftDown = true;
+ _mousePos = event.mouse;
+ } else if (event.type == Common::EVENT_RBUTTONDOWN) {
+ _rightDown = true;
+ _mousePos = event.mouse;
+ } else if (event.type == Common::EVENT_LBUTTONUP) {
+ _leftDown = false;
+ _mousePos = event.mouse;
+ } else if (event.type == Common::EVENT_RBUTTONUP) {
+ _rightDown = false;
+ _mousePos = event.mouse;
+ }
+ hasEvents = true;
+ }
+ return hasEvents;
+}
+
+void Game::loadLibArchive(const Common::Path &path) {
+ debug("loading lib archive: %s", path.toString().c_str());
+ if (!_libFile.open(path)) {
+ error("Can't open library file '%s'", path.toString().c_str());
+ }
+ uint16 magicBytes = _libFile.readSint16LE();
+ uint32 indexOffset = _libFile.readSint32LE();
+ assert(magicBytes == 1020);
+ _libFile.seek(indexOffset);
+ uint16 indexSize = _libFile.readSint16LE();
+ assert(indexSize > 0);
+ while (true) {
+ uint32 entryOffset = _libFile.readSint32LE();
+ Common::String entryName = _libFile.readStream(13)->readString();
+ if (entryName.empty()) {
+ break;
+ }
+ entryName.toLowercase();
+ _libFileEntries[entryName] = entryOffset;
+ }
+ _libFile.seek(0);
+ _videoDecoder->setStream(_libFile.readStream(_libFile.size()));
+}
+
+bool Game::loadScene(Scene *scene) {
+ Common::String sceneFileName = Common::String::format("%s.mm", scene->name.c_str());
+ Common::HashMap<Common::String, uint32>::iterator it = _libFileEntries.find(sceneFileName);
+ if (it != _libFileEntries.end()) {
+ debug("loaded scene %s", scene->name.c_str());
+ _videoDecoder->loadVideoFromStream(it->_value);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void Game::updateScreen() {
+ if (!_inMenu) {
+ Graphics::Surface *frame = _videoDecoder->getVideoFrame();
+ _screen->copyRectToSurface(frame->getPixels(), frame->pitch, _videoPosX, _videoPosY, frame->w, frame->h);
+ }
+ debug_drawZoneRects();
+ if (_paletteDirty || _videoDecoder->isPaletteDirty()) {
+ g_system->getPaletteManager()->setPalette(_palette, 0, 256);
+ _paletteDirty = false;
+ }
+ g_system->copyRectToScreen(_screen->getPixels(), _screen->pitch, 0, 0, _screen->w, _screen->h);
+ g_system->updateScreen();
+}
+
+uint32 Game::_GetMsTime() {
+ return g_system->getMillis();
+}
+
+bool Game::__Fired(Common::Point *point) {
+ _fired = false;
+ pollEvents();
+ if (_leftDown == true) {
+ if (_buttonDown) {
+ return false;
+ }
+ _fired = true;
+ point->x = _mousePos.x;
+ point->y = _mousePos.y;
+ _buttonDown = true;
+ return true;
+ } else {
+ _buttonDown = false;
+ return false;
+ }
+}
+
+Rect *Game::_CheckZone(Zone *zone, Common::Point *point) {
+ Common::Array<Rect>::iterator rect;
+ for (rect = zone->rects.begin(); rect != zone->rects.end(); ++rect) {
+ if (point->x >= rect->left &&
+ point->x <= rect->right &&
+ point->y >= rect->top &&
+ point->y <= rect->bottom) {
+ return rect;
+ }
+ }
+ return nullptr;
+}
+
+// This is used by earlier games
+Zone *Game::_CheckZonesV1(Scene *scene, Rect *&hitRect, Common::Point *point) {
+ Common::Array<Zone *>::iterator zone;
+ for (zone = scene->zones.begin(); zone != scene->zones.end(); ++zone) {
+ unsigned long startFrame = (*zone)->startFrame - _videoFrameSkip + 1;
+ unsigned long endFrame = (*zone)->endFrame + _videoFrameSkip - 1;
+ if (_currentFrame >= startFrame && _currentFrame <= endFrame) {
+ hitRect = _CheckZone(*zone, point);
+ if (hitRect != nullptr) {
+ return *zone;
+ }
+ }
+ }
+ return nullptr;
+}
+
+// This is used by later games
+Zone *Game::_CheckZonesV2(Scene *scene, Rect *&hitRect, Common::Point *point) {
+ Common::Array<Zone *>::iterator zone;
+ for (zone = scene->zones.begin(); zone != scene->zones.end(); ++zone) {
+ unsigned long startFrame = (*zone)->startFrame - (_videoFrameSkip + 1) + ((_difficulty - 1) * _videoFrameSkip);
+ unsigned long endFrame = (*zone)->endFrame + (_videoFrameSkip - 1) - ((_difficulty - 1) * _videoFrameSkip);
+ if (_currentFrame >= startFrame && _currentFrame <= endFrame) {
+ hitRect = _CheckZone(*zone, point);
+ if (hitRect != nullptr) {
+ return *zone;
+ }
+ }
+ }
+ return nullptr;
+}
+
+// only used by earlier games
+void Game::_AdjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty) {
+ Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
+ for (size_t i = 0; i < scenes->size(); i++) {
+ Scene *scene = (*scenes)[i];
+ if (!(scene->diff & 0x01)) {
+ if (scene->preop == "PAUSE" || scene->preop == "PAUSFI" || scene->preop == "PAUSPR") {
+ scene->dataParam1 = (scene->dataParam1 * _pausdifscal[newDifficulty - 1]) / _pausdifscal[oldDifficulty - 1];
+ }
+ }
+ for (size_t j = 0; j < scene->zones.size(); j++) {
+ Zone *zone = scene->zones[j];
+ for (size_t k = 0; k < zone->rects.size(); k++) {
+ Rect *rect = &zone->rects[k];
+ if (!(scene->diff & 0x02)) {
+ int16 cx = (rect->left + rect->right) / 2;
+ int16 cy = (rect->top + rect->bottom) / 2;
+ int32 w = (rect->width() * _rectdifscal[newDifficulty - 1]) / _rectdifscal[oldDifficulty - 1];
+ int32 h = (rect->height() * _rectdifscal[newDifficulty - 1]) / _rectdifscal[oldDifficulty - 1];
+ rect->center(cx, cy, w, h);
+ }
+ }
+ }
+ }
+}
+
+void Game::_RestoreCursor() {
+}
+
+uint32 Game::_GetFrame(Scene *scene) {
+ if (_videoDecoder->getCurrentFrame() == 0) {
+ return scene->startFrame;
+ }
+ return scene->startFrame + (_videoDecoder->getCurrentFrame() * _videoFrameSkip) - _videoFrameSkip;
+}
+
+void Game::_SetFrame() {
+}
+
+int8 Game::_SkipToNewScene(Scene *scene) {
+ if (!_gameInProgress || _sceneSkipped) {
+ return 0;
+ }
+ if (scene->dataParam2 == -1) {
+ _sceneSkipped = true;
+ return -1;
+ } else if (scene->dataParam2 > 0) {
+ uint32 startFrame = scene->dataParam3;
+ if (startFrame == 0) {
+ startFrame = scene->startFrame + 15;
+ }
+ uint32 endFrame = scene->dataParam4;
+ if (_currentFrame < endFrame && _currentFrame > startFrame) {
+ _sceneSkipped = true;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+// Sound
+Audio::SeekableAudioStream *Game::_LoadSoundFile(const Common::Path &path) {
+ Common::File *file = new Common::File();
+ if (!file->open(path)) {
+ warning("Can't open sound file '%s'", path.toString().c_str());
+ delete file;
+ return nullptr;
+ }
+ return Audio::makeRawStream(new Common::SeekableSubReadStream(file, 0, file->size(), DisposeAfterUse::NO), 8000, Audio::FLAG_UNSIGNED, DisposeAfterUse::NO);
+}
+
+void Game::_PlaySound(Audio::SeekableAudioStream *stream) {
+ if (stream != nullptr) {
+ stream->rewind();
+ g_system->getMixer()->stopHandle(_sfxAudioHandle);
+ g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &_sfxAudioHandle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ }
+}
+
+void Game::_DoDiffSound(uint8 difficulty) {
+ switch (difficulty) {
+ case 1:
+ return _PlaySound(_easySound);
+ case 2:
+ return _PlaySound(_avgSound);
+ case 3:
+ return _PlaySound(_hardSound);
+ }
+}
+
+void Game::_DoSaveSound() {
+ _PlaySound(_saveSound);
+}
+
+void Game::_DoLoadSound() {
+ _PlaySound(_loadSound);
+}
+
+void Game::_DoSkullSound() {
+ _PlaySound(_skullSound);
+}
+
+void Game::_DoShot() {
+ _PlaySound(_shotSound);
+}
+
+// Timer
+static void _cursorTimer(void *refCon) {
+ Game *game = static_cast<Game *>(refCon);
+ game->runCursorTimer();
+}
+
+void Game::_SetupCursorTimer() {
+ g_system->getTimerManager()->installTimerProc(&_cursorTimer, 1000000 / 50, (void *)this, "newtimer");
+}
+
+void Game::_RemoveCursorTimer() {
+ g_system->getTimerManager()->removeTimerProc(&_cursorTimer);
+}
+
+void Game::runCursorTimer() {
+ if (_gameTimer & 1) {
+ _gameTimer++;
+ } else {
+ _gameTimer += 3;
+ }
+ _thisGameTimer += 2;
+ if (_whichGun == 9) {
+ if (_emptyCount > 0) {
+ _emptyCount--;
+ } else {
+ _whichGun = 0;
+ }
+ } else {
+ if (_shotFired) {
+ _whichGun++;
+ if (_whichGun > 5) {
+ _whichGun = 0;
+ _shotFired = false;
+ }
+ } else {
+ if (_inHolster > 0) {
+ _inHolster--;
+ if (_inHolster == 0 && _whichGun == 7) {
+ _whichGun = 6;
+ }
+ }
+ }
+ }
+}
+
+// Script functions: Zone
+void Game::_zone_globalhit(Common::Point *point) {
+ // do nothing
+}
+
+// Script functions: RectHit
+void Game::_rect_hit_donothing(Rect *rect) {
+ // do nothing
+}
+
+void Game::_rect_newscene(Rect *rect) {
+ _score += rect->score;
+ if (!rect->scene.empty()) {
+ _cur_scene = rect->scene;
+ }
+}
+
+void Game::_rect_easy(Rect *rect) {
+ _DoDiffSound(1);
+ _difficulty = 1;
+}
+
+void Game::_rect_average(Rect *rect) {
+ _DoDiffSound(2);
+ _difficulty = 2;
+}
+
+void Game::_rect_hard(Rect *rect) {
+ _DoDiffSound(3);
+ _difficulty = 3;
+}
+
+void Game::_rect_exit(Rect *rect) {
+ _vm->quitGame();
+}
+
+// Script functions: Scene PreOps
+void Game::_scene_pso_drawrct(Scene *scene) {
+}
+
+void Game::_scene_pso_pause(Scene *scene) {
+ _hadPause = false;
+ _pauseTime = 0;
+}
+
+void Game::_scene_pso_drawrct_fadein(Scene *scene) {
+ _scene_pso_drawrct(scene);
+ _scene_pso_fadein(scene);
+}
+
+void Game::_scene_pso_fadein(Scene *scene) {
+ // do nothing
+}
+
+void Game::_scene_pso_pause_fadein(Scene *scene) {
+ _scene_pso_pause(scene);
+ _scene_pso_fadein(scene);
+}
+
+void Game::_scene_pso_preread(Scene *scene) {
+ // do nothing
+}
+
+void Game::_scene_pso_pause_preread(Scene *scene) {
+ _scene_pso_pause(scene);
+ _scene_pso_preread(scene);
+}
+
+// Script functions: Scene Scene InsOps
+void Game::_scene_iso_donothing(Scene *scene) {
+ // do nothing
+}
+
+void Game::_scene_iso_startgame(Scene *scene) {
+ _startscene = scene->insopParam;
+}
+
+void Game::_scene_iso_pause(Scene *scene) {
+ bool checkPause = true;
+ if (_hadPause) {
+ checkPause = false;
+ }
+ if (_currentFrame > scene->endFrame) {
+ checkPause = false;
+ }
+ if (scene->dataParam1 <= 0) {
+ checkPause = false;
+ }
+ if (checkPause) {
+ unsigned long pauseStart = atoi(scene->insopParam.c_str());
+ unsigned long pauseEnd = atoi(scene->insopParam.c_str()) + _videoFrameSkip + 1;
+ if (_currentFrame >= pauseStart && _currentFrame < pauseEnd && !_hadPause) {
+ _gameTimer = 0;
+ unsigned long pauseDuration = scene->dataParam1 * 0x90FF / 1000;
+ _pauseTime = pauseDuration;
+ _nextFrameTime += pauseDuration;
+ _pauseTime += _GetMsTime();
+ _hadPause = true;
+ }
+ }
+ if (_pauseTime != 0) {
+ if (_GetMsTime() > _pauseTime) {
+ _pauseTime = 0;
+ }
+ }
+}
+
+// Script functions: Scene NxtScn
+void Game::_scene_nxtscn_donothing(Scene *scene) {
+ // do nothing
+}
+
+void Game::_scene_default_nxtscn(Scene *scene) {
+ _cur_scene = scene->next;
+}
+
+// Script functions: ShowMsg
+void Game::_scene_sm_donothing(Scene *scene) {
+ // do nothing
+}
+
+// Script functions: ScnScr
+void Game::_scene_default_score(Scene *scene) {
+ if (scene->scnscrParam > 0) {
+ _score += scene->scnscrParam;
+ }
+}
+
+// Script functions: ScnNxtFrm
+void Game::_scene_nxtfrm(Scene *scene) {
+}
+
+// debug methods
+void Game::debug_drawZoneRects() {
+ if (_debug_drawRects || debugChannelSet(1, Alg::kAlgDebugGraphics)) {
+ if (_inMenu) {
+ for (uint8 i = 0; i < _submenzone->rects.size(); i++) {
+ Rect rect = _submenzone->rects[i];
+ _screen->drawLine(rect.left, rect.top, rect.right, rect.top, 1);
+ _screen->drawLine(rect.left, rect.top, rect.left, rect.bottom, 1);
+ _screen->drawLine(rect.right, rect.bottom, rect.right, rect.top, 1);
+ _screen->drawLine(rect.right, rect.bottom, rect.left, rect.bottom, 1);
+ }
+ } else if (_cur_scene != "") {
+ Scene *targetScene = _sceneInfo->findScene(_cur_scene);
+ for (uint8 i = 0; i < targetScene->zones.size(); i++) {
+ Zone *zone = targetScene->zones[i];
+ for (uint8 j = 0; j < zone->rects.size(); j++) {
+ Rect rect = zone->rects[j];
+ _screen->drawLine(rect.left, rect.top, rect.right, rect.top, 1);
+ _screen->drawLine(rect.left, rect.top, rect.left, rect.bottom, 1);
+ _screen->drawLine(rect.right, rect.bottom, rect.right, rect.top, 1);
+ _screen->drawLine(rect.right, rect.bottom, rect.left, rect.bottom, 1);
+ }
+ }
+ }
+ }
+}
+
+bool Game::debug_dumpLibFile() {
+ Common::DumpFile dumpFile;
+ Common::HashMap<Common::String, uint32>::iterator entry;
+ for (entry = _libFileEntries.begin(); entry != _libFileEntries.end(); ++entry) {
+ _libFile.seek(entry->_value, SEEK_SET);
+ uint32 size = _libFile.readUint32LE();
+ Common::Path dumpFileName(Common::String::format("libDump/%s", entry->_key.c_str()));
+ dumpFile.open(dumpFileName, true);
+ assert(dumpFile.isOpen());
+ dumpFile.writeStream(_libFile.readStream(size));
+ dumpFile.flush();
+ dumpFile.close();
+ }
+ return true;
+}
+
+} // End of namespace Alg
diff --git a/engines/alg/game.h b/engines/alg/game.h
new file mode 100644
index 00000000000..ac2bdb11670
--- /dev/null
+++ b/engines/alg/game.h
@@ -0,0 +1,190 @@
+/* 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 ALG_GAME_H
+#define ALG_GAME_H
+
+#include "common/random.h"
+
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+
+#include "alg/alg.h"
+#include "alg/scene.h"
+#include "alg/video.h"
+
+namespace Alg {
+
+class Game {
+
+public:
+ Game(AlgEngine *vm);
+ virtual ~Game();
+ virtual Common::Error run();
+ bool _debug_drawRects = false;
+ bool _debug_godMode = false;
+ bool _debug_unlimitedAmmo = false;
+ bool debug_dumpLibFile();
+ void runCursorTimer();
+
+protected:
+ virtual void init() = 0;
+
+ AlgEngine *_vm;
+ AlgVideoDecoder *_videoDecoder;
+ SceneInfo *_sceneInfo;
+ Common::RandomSource *_rnd;
+
+ Common::Path _libFileName;
+ Common::File _libFile;
+ Common::HashMap<Common::String, uint32> _libFileEntries;
+
+ uint8 *_palette;
+ bool _paletteDirty;
+
+ Graphics::Surface *_background;
+ Graphics::Surface *_screen;
+ Common::Array<Graphics::Surface> *_gun;
+ Common::Array<Graphics::Surface> *_numbers;
+
+ Audio::SeekableAudioStream *_saveSound = nullptr;
+ Audio::SeekableAudioStream *_loadSound = nullptr;
+ Audio::SeekableAudioStream *_easySound = nullptr;
+ Audio::SeekableAudioStream *_avgSound = nullptr;
+ Audio::SeekableAudioStream *_hardSound = nullptr;
+ Audio::SeekableAudioStream *_skullSound = nullptr;
+ Audio::SeekableAudioStream *_shotSound = nullptr;
+ Audio::SeekableAudioStream *_emptySound = nullptr;
+
+ Audio::SoundHandle _sfxAudioHandle;
+ Audio::SoundHandle _sceneAudioHandle;
+
+ Zone *_menuzone;
+ Zone *_submenzone;
+
+ bool _leftDown;
+ bool _rightDown;
+ Common::Point _mousePos;
+
+ const uint32 _pausdifscal[3] = {0x10000, 0x8000, 0x4000};
+ const uint32 _rectdifscal[3] = {0x10000, 0x0C000, 0x8000};
+
+ bool pollEvents();
+ void loadLibArchive(const Common::Path &path);
+ Audio::SeekableAudioStream *_LoadSoundFile(const Common::Path &path);
+ void _PlaySound(Audio::SeekableAudioStream *stream);
+ bool loadScene(Scene *scene);
+ void updateScreen();
+ uint32 _GetMsTime();
+ bool __Fired(Common::Point *point);
+ Rect *_CheckZone(Zone *zone, Common::Point *point);
+ Zone *_CheckZonesV1(Scene *scene, Rect *&hitRect, Common::Point *point);
+ Zone *_CheckZonesV2(Scene *scene, Rect *&hitRect, Common::Point *point);
+ uint32 _GetFrame(Scene *scene);
+ void _AdjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty);
+ void _RestoreCursor();
+ void _SetFrame();
+ int8 _SkipToNewScene(Scene *scene);
+ void debug_drawZoneRects();
+
+ // Sounds
+ void _DoDiffSound(uint8 difficulty);
+ void _DoSaveSound();
+ void _DoLoadSound();
+ void _DoSkullSound();
+ void _DoShot();
+
+ // Timer
+ void _SetupCursorTimer();
+ void _RemoveCursorTimer();
+
+ // Script functions: Zone
+ void _zone_globalhit(Common::Point *point);
+ // Script functions: RectHit
+ void _rect_hit_donothing(Rect *rect);
+ void _rect_newscene(Rect *rect);
+ void _rect_exit(Rect *rect);
+ void _rect_easy(Rect *rect);
+ void _rect_average(Rect *rect);
+ void _rect_hard(Rect *rect);
+ // Script functions: Scene PreOps
+ void _scene_pso_drawrct(Scene *scene);
+ void _scene_pso_pause(Scene *scene);
+ void _scene_pso_drawrct_fadein(Scene *scene);
+ void _scene_pso_fadein(Scene *scene);
+ void _scene_pso_pause_fadein(Scene *scene);
+ void _scene_pso_preread(Scene *scene);
+ void _scene_pso_pause_preread(Scene *scene);
+ // Script functions: Scene Scene InsOps
+ void _scene_iso_donothing(Scene *scene);
+ void _scene_iso_startgame(Scene *scene);
+ void _scene_iso_pause(Scene *scene);
+ // Script functions: Scene Scene NxtScn
+ void _scene_nxtscn_donothing(Scene *scene);
+ void _scene_default_nxtscn(Scene *scene);
+ // Script functions: ShowMsg
+ void _scene_sm_donothing(Scene *scene);
+ // Script functions: ScnScr
+ void _scene_default_score(Scene *scene);
+ // Script functions: ScnNxtFrm
+ void _scene_nxtfrm(Scene *scene);
+
+ bool _buttonDown = false;
+ uint8 _difficulty = 1;
+ uint8 _emptyCount = 0;
+ bool _fired = 0;
+ uint32 _currentFrame;
+ bool _gameInProgress = false;
+ uint32 _gameTimer = 0;
+ uint32 _thisGameTimer = 0;
+ bool _hadPause = false;
+ bool _holster = false;
+ bool _inMenu = false;
+ uint8 _inHolster = 0;
+ int8 _lives = 0;
+ long int _minF;
+ long int _maxF;
+ uint8 _oldWhichGun = 0xFF;
+ uint8 _oldDifficulty = 1;
+ int8 _oldLives = 0;
+ int32 _oldScore = -1;
+ uint8 _oldShots = 0;
+ uint32 _pauseTime = 0;
+ bool _sceneSkipped = false;
+ int32 _score = 0;
+ bool _shotFired = false;
+ uint16 _shots = 0;
+ uint32 _videoFrameSkip = 3;
+ uint32 _nextFrameTime = 0;
+ uint16 _videoPosX;
+ uint16 _videoPosY;
+ uint8 _whichGun = 0;
+
+ Common::String _cur_scene;
+ Common::String _sub_scene;
+ Common::String _ret_scene;
+ Common::String _last_scene;
+ Common::String _startscene;
+};
+
+} // End of namespace Alg
+
+#endif
diff --git a/engines/alg/game_bountyhunter.cpp b/engines/alg/game_bountyhunter.cpp
new file mode 100644
index 00000000000..57e16ae3500
--- /dev/null
+++ b/engines/alg/game_bountyhunter.cpp
@@ -0,0 +1,1343 @@
+/* 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/debug.h"
+#include "common/rect.h"
+#include "common/savefile.h"
+#include "common/system.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/pixelformat.h"
+
+#include "alg/game_bountyhunter.h"
+#include "alg/graphics.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+GameBountyHunter::GameBountyHunter(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
+ if (scumm_stricmp(desc->gameId, "lbhunter") == 0) {
+ _libFileName = "bhds.lib";
+ } else if (scumm_stricmp(desc->gameId, "lbhunterdemo") == 0) {
+ _libFileName = "bhdemo.lib";
+ _isDemo = true;
+ }
+}
+
+GameBountyHunter::~GameBountyHunter() {
+}
+
+void GameBountyHunter::init() {
+ _videoPosX = 0;
+ _videoPosY = 0;
+
+ loadLibArchive(_libFileName);
+ _sceneInfo->loadScnFile("bh.scn");
+ _startscene = _sceneInfo->getStartScene();
+
+ registerScriptFunctions();
+ verifyScriptFunctions();
+
+ _menuzone = new Zone();
+ _menuzone->name = "MainMenu";
+ _menuzone->ptrfb = "GLOBALHIT";
+
+ _menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
+
+ _submenzone = new Zone();
+ _submenzone->name = "SubMenu";
+ _submenzone->ptrfb = "GLOBALHIT";
+
+ _submenzone->addRect(0, 0, 0x78, 0x3C, nullptr, 0, "STARTMENU", "0");
+ _submenzone->addRect(0xC8, 0, 0x0140, 0x3C, nullptr, 0, "RECTLOAD", "0");
+ _submenzone->addRect(0xC8, 0x3C, 0x0140, 0x78, nullptr, 0, "RECTSAVE", "0");
+ _submenzone->addRect(0, 0x3C, 0x78, 0x78, nullptr, 0, "CONTMENU", "0");
+ _submenzone->addRect(0, 0x78, 0x78, 0xB4, nullptr, 0, "EXITMENU", "0");
+ _submenzone->addRect(0xC8, 0x78, 0x0140, 0xB4, nullptr, 0, "TOGGLEPLAYERS", "0");
+
+ _shotSound = _LoadSoundFile("blow.8b");
+ _emptySound = _LoadSoundFile("empty.8b");
+ _saveSound = _LoadSoundFile("saved.8b");
+ _loadSound = _LoadSoundFile("loaded.8b");
+ _skullSound = _LoadSoundFile("skull.8b");
+ _shotgunSound = _LoadSoundFile("shotgun.8b");
+
+ _gun = AlgGraphics::loadScreenCoordAniImage("bh_gun.ani", _palette);
+ _shotgun = AlgGraphics::loadScreenCoordAniImage("bh_buck.ani", _palette);
+ _numbers = AlgGraphics::loadAniImage("bh_num.ani", _palette);
+ Common::Array<Graphics::Surface> *bullets = AlgGraphics::loadAniImage("bh_ammo.ani", _palette);
+ _shotIcon = (*bullets)[0];
+ _emptyIcon = (*bullets)[1];
+ Common::Array<Graphics::Surface> *lives = AlgGraphics::loadAniImage("bh_life.ani", _palette);
+ _liveIcon = (*lives)[0];
+ _deadIcon = (*lives)[1];
+ Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("bh_hole.ani", _palette);
+ _bulletholeIcon = (*hole)[0];
+ Common::Array<Graphics::Surface> *players = AlgGraphics::loadAniImage("bh_plyr.ani", _palette);
+ _playersIcon1 = (*players)[0];
+ _playersIcon2 = (*players)[1];
+ Common::Array<Graphics::Surface> *text = AlgGraphics::loadAniImage("bh_text.ani", _palette);
+ _textScoreIcon = (*text)[0];
+ _textMenuIcon = (*text)[1];
+ _textBlackBarIcon = (*text)[2];
+ _bagsIcons = AlgGraphics::loadScreenCoordAniImage("bh_bags.ani", _palette);
+
+ _background = AlgGraphics::loadVgaBackground("bh_menu.vga", _palette);
+ _screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
+
+ _MoveMouse();
+}
+
+void GameBountyHunter::registerScriptFunctions() {
+#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new BHScriptFunctionRect(this, &GameBountyHunter::func);
+ RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
+ RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
+ RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
+ RECT_HIT_FUNCTION("STARTMENU", _rect_start);
+ RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
+ RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
+ RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
+ RECT_HIT_FUNCTION("TOGGLEPLAYERS", _rect_toggle_players);
+ RECT_HIT_FUNCTION("JUG", _rect_hit_icon_jug);
+ RECT_HIT_FUNCTION("LANTERN", _rect_hit_icon_lantern);
+ RECT_HIT_FUNCTION("SKULL", _rect_hit_icon_skull);
+ RECT_HIT_FUNCTION("WHEEL", _rect_hit_icon_wheel);
+ RECT_HIT_FUNCTION("HARRY", _rect_hit_select_harry);
+ RECT_HIT_FUNCTION("DAN", _rect_hit_select_dan);
+ RECT_HIT_FUNCTION("LOCO", _rect_hit_select_loco);
+ RECT_HIT_FUNCTION("KID", _rect_hit_select_kid);
+ RECT_HIT_FUNCTION("KILLMAN", _rect_hit_kill_man);
+ RECT_HIT_FUNCTION("KILLWOMAN", _rect_hit_kill_man);
+ RECT_HIT_FUNCTION("KILLMAIN", _rect_hit_donothing);
+ RECT_HIT_FUNCTION("WNDMAIN", _rect_hit_donothing);
+ RECT_HIT_FUNCTION("SHOTGUN", _rect_hit_give_shotgun);
+ RECT_HIT_FUNCTION("SHOOT3", _rect_hit_kill3);
+ RECT_HIT_FUNCTION("KILL3", _rect_hit_kill3);
+ RECT_HIT_FUNCTION("GOTOBAD", _rect_hit_donothing);
+ RECT_HIT_FUNCTION("GOTOTGT", _rect_hit_donothing);
+ RECT_HIT_FUNCTION("GOTOGUN", _rect_hit_donothing);
+ RECT_HIT_FUNCTION("CHKSHOT", _rect_hit_check_shotgun);
+ RECT_HIT_FUNCTION("CHEATER", _rect_hit_cheater);
+#undef RECT_HIT_FUNCTION
+
+#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new BHScriptFunctionScene(this, &GameBountyHunter::func);
+ PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("DRAW_RECT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
+ PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
+ PRE_OPS_FUNCTION("PAUSE_FADEIN", _scene_pso_pause_fadein);
+ PRE_OPS_FUNCTION("DRAW_RECT_THEN_FADEIN", _scene_pso_drawrct_fadein);
+ PRE_OPS_FUNCTION("SHOOTOUT", _scene_pso_shootout);
+ PRE_OPS_FUNCTION("WNDMAIN", _scene_pso_wounded_main);
+ PRE_OPS_FUNCTION("GUNFIGHT", _scene_pso_gunfight_setup);
+ PRE_OPS_FUNCTION("REFEREED", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("LOSELIFE", _scene_pso_lose_a_life);
+ PRE_OPS_FUNCTION("L1ASETUP", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("L1DSETUP", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("L2ASETUP", _scene_pso_setup_ndrandom1);
+ PRE_OPS_FUNCTION("L2BSETUP", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("L4A1SETUP", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("L4A2SETUP", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("SETUPL3A", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("SET3SHOT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("L3BSETUP", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("SETBADGUY", _scene_pso_set_current_scene);
+ PRE_OPS_FUNCTION("CLRKILL3", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("DPAUSE", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("DEMO", _scene_pso_drawrct);
+#undef PRE_OPS_FUNCTION
+
+#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new BHScriptFunctionScene(this, &GameBountyHunter::func);
+ INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
+ INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
+ INS_OPS_FUNCTION("SHOOTOUT", _scene_iso_shootout);
+ INS_OPS_FUNCTION("LEFTDIE", _scene_iso_donothing);
+ INS_OPS_FUNCTION("SHOOTPAST", _scene_iso_donothing);
+ INS_OPS_FUNCTION("GUNFIGHT", _scene_iso_shootout);
+ INS_OPS_FUNCTION("REFEREED", _scene_iso_donothing);
+ INS_OPS_FUNCTION("CHECK3SHOT", _scene_iso_donothing);
+ INS_OPS_FUNCTION("SHOWHI", _scene_iso_donothing);
+ INS_OPS_FUNCTION("STARTGAME", _scene_iso_donothing);
+ INS_OPS_FUNCTION("GIVEMONEY", _scene_iso_givemoney);
+ INS_OPS_FUNCTION("GETHI", _scene_iso_donothing);
+ INS_OPS_FUNCTION("DPAUSE", _scene_iso_donothing);
+ INS_OPS_FUNCTION("DEMO", _scene_iso_donothing);
+ INS_OPS_FUNCTION("RELOAD", _scene_iso_donothing);
+ INS_OPS_FUNCTION("RPAUSE", _scene_iso_donothing);
+#undef INS_OPS_FUNCTION
+
+#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new BHScriptFunctionScene(this, &GameBountyHunter::func);
+ NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
+ NXT_SCN_FUNCTION("DIED", _scene_nxtscn_lose_a_life);
+ NXT_SCN_FUNCTION("LOSE_A_LIFE", _scene_nxtscn_lose_a_life);
+ NXT_SCN_FUNCTION("CONTINUE_GAME", _scene_nxtscn_continue_game);
+ NXT_SCN_FUNCTION("DID_NOT_CONTINUE", _scene_nxtscn_did_not_continue);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_MAN", _scene_nxtscn_kill_innocent_man);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_WOMAN", _scene_nxtscn_kill_innocent_woman);
+ NXT_SCN_FUNCTION("AFTER_DIE", _scene_nxtscn_after_die);
+ NXT_SCN_FUNCTION("CHECKNEXT", _scene_nxtscn_goto_level_select);
+ NXT_SCN_FUNCTION("CONTINUE_RANDOM", _scene_nxtscn_continue_random);
+ NXT_SCN_FUNCTION("POPUP", _scene_nxtscn_continue_random);
+ NXT_SCN_FUNCTION("L1ASETUP", _scene_nxtscn_init_random_harry1);
+ NXT_SCN_FUNCTION("L1DSETUP", _scene_nxtscn_init_random_harry2);
+ NXT_SCN_FUNCTION("L2ASETUP", _scene_nxtscn_init_random_dan1);
+ NXT_SCN_FUNCTION("L2BSETUP", _scene_nxtscn_init_random_dan2);
+ NXT_SCN_FUNCTION("L3ASETUP", _scene_nxtscn_init_random_loco1);
+ NXT_SCN_FUNCTION("L3BSETUP", _scene_nxtscn_init_random_loco2);
+ NXT_SCN_FUNCTION("L4A1SETUP", _scene_nxtscn_init_random_kid1);
+ NXT_SCN_FUNCTION("L4A2SETUP", _scene_nxtscn_init_random_kid2);
+ NXT_SCN_FUNCTION("NEXTSUB", _scene_nxtscn_next_sub_level);
+ NXT_SCN_FUNCTION("GOTOBAD", _scene_nxtscn_goto_bad_guy);
+ NXT_SCN_FUNCTION("AUTOSEL", _scene_nxtscn_auto_select_level);
+ NXT_SCN_FUNCTION("SELECT_SCENARIO", _scene_nxtscn_select_scenario);
+ NXT_SCN_FUNCTION("FINISH_SCENARIO", _scene_nxtscn_finish_scenario);
+ NXT_SCN_FUNCTION("GAME_WON", _scene_nxtscn_game_won);
+ NXT_SCN_FUNCTION("KILLMAN", _scene_nxtscn_kill_innocent_man);
+ NXT_SCN_FUNCTION("KILLWOMAN", _scene_nxtscn_kill_innocent_woman);
+ NXT_SCN_FUNCTION("BOTHDIE", _scene_nxtscn_lose_a_life);
+ NXT_SCN_FUNCTION("RIGHTDIE", _scene_nxtscn_lose_a_life);
+ NXT_SCN_FUNCTION("LEFTDIES", _scene_nxtscn_lose_a_life);
+ NXT_SCN_FUNCTION("KILLMAIN", _scene_nxtscn_killed_main);
+ NXT_SCN_FUNCTION("WNDMAIN", _scene_nxtscn_wounded_main);
+ NXT_SCN_FUNCTION("ENDLEVEL", _scene_nxtscn_end_level);
+ NXT_SCN_FUNCTION("ENDOGAME", _scene_nxtscn_end_game);
+ NXT_SCN_FUNCTION("CLRHI", _scene_nxtscn_donothing);
+ NXT_SCN_FUNCTION("TGTPRACT", _scene_nxtscn_donothing);
+ NXT_SCN_FUNCTION("CREDITS", _scene_nxtscn_donothing);
+ NXT_SCN_FUNCTION("DOMAIN", _scene_nxtscn_do_breakout_mains);
+ NXT_SCN_FUNCTION("RDIED", _scene_nxtscn_died_refed);
+ NXT_SCN_FUNCTION("GIVESHOT", _scene_nxtscn_give_shotgun);
+ NXT_SCN_FUNCTION("CHK2P", _scene_nxtscn_check_2players);
+ NXT_SCN_FUNCTION("SHOTSND", _scene_nxtscn_donothing);
+ NXT_SCN_FUNCTION("XITCONT", _scene_nxtscn_donothing);
+#undef NXT_SCN_FUNCTION
+
+#define WEP_DWN_FUNCTION(name, func) _sceneWepDwn[name] = new BHScriptFunctionScene(this, &GameBountyHunter::func);
+ WEP_DWN_FUNCTION("DEFAULT", _scene_default_wepdwn);
+ WEP_DWN_FUNCTION("GUNFIGHT", _scene_default_wepdwn);
+ WEP_DWN_FUNCTION("LOADALL", _scene_default_wepdwn);
+#undef NXT_SCN_FUNCTION
+
+ _sceneShowMsg["DEFAULT"] = new BHScriptFunctionScene(this, &GameBountyHunter::_scene_sm_donothing);
+ _sceneScnScr["DEFAULT"] = new BHScriptFunctionScene(this, &GameBountyHunter::_scene_default_score);
+ _sceneNxtFrm["DEFAULT"] = new BHScriptFunctionScene(this, &GameBountyHunter::_scene_nxtfrm);
+}
+
+void GameBountyHunter::verifyScriptFunctions() {
+ Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
+ for (size_t i = 0; i < scenes->size(); i++) {
+ Scene *scene = (*scenes)[i];
+ getScriptFunctionScene(PREOP, scene->preop);
+ getScriptFunctionScene(SHOWMSG, scene->scnmsg);
+ getScriptFunctionScene(INSOP, scene->insop);
+ getScriptFunctionScene(WEPDWN, scene->wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->scnscr);
+ getScriptFunctionScene(NXTFRM, scene->nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->nxtscn);
+ for (size_t j = 0; j < scene->zones.size(); j++) {
+ Zone *zone = scene->zones[j];
+ for (size_t k = 0; k < zone->rects.size(); k++) {
+ getScriptFunctionRectHit(zone->rects[k].rectHit);
+ }
+ }
+ }
+}
+
+BHScriptFunctionRect GameBountyHunter::getScriptFunctionRectHit(Common::String name) {
+ BHScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ if (it != _rectHitFuncs.end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find rectHit function: %s", name.c_str());
+ }
+}
+
+BHScriptFunctionScene GameBountyHunter::getScriptFunctionScene(SceneFuncType type, Common::String name) {
+ BHScriptFunctionSceneMap *functionMap;
+ switch (type) {
+ case PREOP:
+ functionMap = &_scenePreOps;
+ break;
+ case SHOWMSG:
+ functionMap = &_sceneShowMsg;
+ break;
+ case INSOP:
+ functionMap = &_sceneInsOps;
+ break;
+ case WEPDWN:
+ functionMap = &_sceneWepDwn;
+ break;
+ case SCNSCR:
+ functionMap = &_sceneScnScr;
+ break;
+ case NXTFRM:
+ functionMap = &_sceneNxtFrm;
+ break;
+ case NXTSCN:
+ functionMap = &_sceneNxtScn;
+ break;
+ default:
+ error("Unkown scene script type: %u", type);
+ break;
+ }
+ BHScriptFunctionSceneMap::iterator it;
+ it = functionMap->find(name);
+ if (it != functionMap->end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find scene type %u function: %s", type, name.c_str());
+ }
+}
+
+void GameBountyHunter::callScriptFunctionRectHit(Common::String name, Rect *rect) {
+ BHScriptFunctionRect function = getScriptFunctionRectHit(name);
+ function(rect);
+}
+
+void GameBountyHunter::callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene) {
+ BHScriptFunctionScene function = getScriptFunctionScene(type, name);
+ function(scene);
+}
+
+Common::Error GameBountyHunter::run() {
+ init();
+ _NewGame();
+ _cur_scene = _startscene;
+ Common::String oldscene;
+ while (!_vm->shouldQuit()) {
+ oldscene = _cur_scene;
+ _SetFrame();
+ _fired = false;
+ Scene *scene = _sceneInfo->findScene(_cur_scene);
+ if (!loadScene(scene)) {
+ error("Cannot find scene %s in libfile", scene->name.c_str());
+ }
+ _sceneSkipped = false;
+ Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
+ g_system->getMixer()->stopHandle(_sceneAudioHandle);
+ g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ _paletteDirty = true;
+ _nextFrameTime = _GetMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->preop, scene);
+ _currentFrame = _GetFrame(scene);
+ while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
+ _UpdateMouse();
+ callScriptFunctionScene(SHOWMSG, scene->scnmsg, scene);
+ callScriptFunctionScene(INSOP, scene->insop, scene);
+ _holster = _WeaponDown();
+ if (_holster) {
+ callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ }
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ if (!_holster) {
+ Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ if (hitGlobalRect != nullptr) {
+ callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
+ } else {
+ if (_playerShots[_player] > 0) {
+ if (!_debug_unlimitedAmmo) {
+ _playerShots[_player]--;
+ }
+ _DisplayShotFiredImage(&firedCoords);
+ _DoShot();
+ Rect *hitRect = nullptr;
+ Zone *hitSceneZone = _CheckZonesV2(scene, hitRect, &firedCoords);
+ if (hitSceneZone != nullptr) {
+ callScriptFunctionRectHit(hitRect->rectHit, hitRect);
+ } else {
+ int8 skip = _SkipToNewScene(scene);
+ if (skip == -1) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ } else if (skip == 1) {
+ if (scene->dataParam4 > 0) {
+ uint32 framesToSkip = (scene->dataParam4 - _currentFrame) / _videoFrameSkip;
+ _videoDecoder->skipNumberOfFrames(framesToSkip);
+ } else {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ }
+ }
+ } else {
+ _PlaySound(_emptySound);
+ }
+ }
+ }
+ }
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ }
+ _DisplayLivesLeft(0);
+ _DisplayScores(0);
+ _DisplayShotsLeft(0);
+ _MoveMouse();
+ if (_pauseTime > 0) {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ } else {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ }
+ if (_videoDecoder->getCurrentFrame() == 0) {
+ _videoDecoder->getNextFrame();
+ }
+ int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ if (remainingMillis < 10) {
+ if (_videoDecoder->getCurrentFrame() > 0) {
+ _videoDecoder->getNextFrame();
+ }
+ remainingMillis = _nextFrameTime - _GetMsTime();
+ _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ }
+ if (remainingMillis > 0) {
+ if (remainingMillis > 15) {
+ remainingMillis = 15;
+ }
+ g_system->delayMillis(remainingMillis);
+ }
+ _currentFrame = _GetFrame(scene);
+ updateScreen();
+ }
+ // frame limit reached or scene changed, prepare for next scene
+ _hadPause = false;
+ _pauseTime = 0;
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ if (_cur_scene == "") {
+ _vm->quitGame();
+ }
+ }
+ return Common::kNoError;
+}
+
+void GameBountyHunter::_NewGame() {
+ _playerLives[0] = _playerLives[1] = 3;
+ _playerShots[0] = _playerShots[1] = 6;
+ _playerGun[0] = _playerGun[1] = 1;
+ _playerScore[0] = _playerScore[1] = 0;
+ _currentSubLevelSceneId = 0x017B;
+ _holster = false;
+}
+
+void GameBountyHunter::_DoMenu() {
+ uint32 startTime = _GetMsTime();
+ _RestoreCursor();
+ _DoCursor();
+ _inMenu = true;
+ _MoveMouse();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+ while (_inMenu && !_vm->shouldQuit()) {
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ Rect *hitMenuRect = _CheckZone(_submenzone, &firedCoords);
+ if (hitMenuRect != nullptr) {
+ callScriptFunctionRectHit(hitMenuRect->rectHit, hitMenuRect);
+ }
+ }
+ g_system->delayMillis(15);
+ updateScreen();
+ }
+ _RestoreCursor();
+ _DoCursor();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ if (_hadPause) {
+ unsigned long endTime = _GetMsTime();
+ unsigned long timeDiff = endTime - startTime;
+ _pauseTime += timeDiff;
+ _nextFrameTime += timeDiff;
+ }
+}
+
+void GameBountyHunter::_DoCursor() {
+ _UpdateMouse();
+}
+
+void GameBountyHunter::_UpdateMouse() {
+ if (_oldWhichGun != _whichGun) {
+ Graphics::PixelFormat pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
+ Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ if (_playerGun[0] == 2 && _whichGun < 2) {
+ cursor = &(*_shotgun)[_whichGun];
+ }
+ CursorMan.popAllCursors();
+ uint16 hotspotX = (cursor->w / 2) + 8;
+ uint16 hotspotY = (cursor->h / 2) + 8;
+ if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
+ cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
+ cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
+ }
+ CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0, false, &pixelFormat);
+ CursorMan.showMouse(true);
+ _oldWhichGun = _whichGun;
+ }
+}
+
+void GameBountyHunter::_MoveMouse() {
+ if (_inMenu) {
+ _whichGun = 3; // in menu cursor
+ } else {
+ // disabled for now, because glitchy
+ /*
+ uint16 x = _mousePos.x;
+ uint16 y = _mousePos.y;
+ if (x < 13) {x = 13;}
+ if (x > 286) {x = 286;}
+ if (y < 3) {y = 3;}
+ if (y > 166) {y = 166;}
+ if (_mousePos.x != x || _mousePos.y != y) {
+ _mousePos.x = x;
+ _mousePos.y = y;
+ g_system->warpMouse(x, y);
+ }
+ */
+ if (_mousePos.y >= 0xA3 && _mousePos.x >= 0xF0) {
+ _whichGun = 1; // holster
+ } else if (_mousePos.y >= 0xA3 && _mousePos.x <= 0x43) {
+ _whichGun = 2; // menu button cursor
+ } else {
+ _whichGun = 0; // regular gun
+ }
+ }
+ _UpdateMouse();
+}
+
+void GameBountyHunter::_DisplayLivesLeft(uint8 player) {
+ if (_lives == _oldLives) {
+ return;
+ }
+ int posY = 0x67;
+ for (uint8 i = 0; i < 3; i++) {
+ AlgGraphics::drawImage(_screen, &_deadIcon, 0x12F, posY);
+ posY += 0xE;
+ }
+ posY = 0x67;
+ for (uint8 i = 0; i < _lives; i++) {
+ AlgGraphics::drawImage(_screen, &_liveIcon, 0x12F, posY);
+ posY += 0xE;
+ }
+ _oldLives = _lives;
+}
+
+void GameBountyHunter::_DisplayScores(uint8 player) {
+ if (_score == _oldScore) {
+ return;
+ }
+ Common::String scoreString = Common::String::format("%05d", _score);
+ int posX = 0x9B;
+ for (int i = 0; i < 5; i++) {
+ uint8 digit = scoreString[i] - '0';
+ AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xBF);
+ posX += 7;
+ }
+ _oldScore = _score;
+}
+
+void GameBountyHunter::_DisplayShotsLeft(uint8 player) {
+ if (_shots == _oldShots) {
+ return;
+ }
+ uint16 posX = 0xEE;
+ for (uint8 i = 0; i < 10; i++) {
+ AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBE);
+ posX += 5;
+ }
+ posX = 0xEE;
+ for (uint8 i = 0; i < _shots; i++) {
+ AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBE);
+ posX += 5;
+ }
+ _oldShots = _shots;
+}
+
+bool GameBountyHunter::_WeaponDown() {
+ if (_rightDown && _mousePos.y >= 0xAA && _mousePos.x >= 0x113) {
+ return true;
+ }
+ return false;
+}
+
+bool GameBountyHunter::_SaveState() {
+ Common::OutSaveFile *outSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(outSaveFile = g_system->getSavefileManager()->openForSaving(saveFileName))) {
+ warning("Can't create file '%s', game not saved", saveFileName.c_str());
+ return false;
+ }
+ uint16 currentSceneNum = atoi(_cur_scene.c_str());
+ outSaveFile->writeUint32BE(MKTAG('A', 'L', 'G', 'S')); // header
+ outSaveFile->writeByte(0); // version, unused for now
+ outSaveFile->writeByte(_currentLevel);
+ outSaveFile->writeUint16LE(_currentSubLevelSceneId);
+ outSaveFile->writeByte(_continuesUsed);
+ outSaveFile->writeUint16LE(currentSceneNum);
+ for (uint8 i = 0; i < 2; i++) {
+ outSaveFile->writeByte(_playerLives[i]);
+ outSaveFile->writeByte(_playerShots[i]);
+ outSaveFile->writeUint32LE(_playerScore[i]);
+ }
+ outSaveFile->writeByte(_unk_2ADA6);
+ outSaveFile->writeByte(_numPlayers);
+ outSaveFile->finalize();
+ delete outSaveFile;
+ return true;
+}
+
+bool GameBountyHunter::_LoadState() {
+ Common::InSaveFile *inSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(inSaveFile = g_system->getSavefileManager()->openForLoading(saveFileName))) {
+ debug("Can't load file '%s', game not loaded", saveFileName.c_str());
+ return false;
+ }
+ uint32 header = inSaveFile->readUint32BE();
+ if (header != MKTAG('A', 'L', 'G', 'S')) {
+ warning("Unkown save file, header: %d", header);
+ return false;
+ }
+ inSaveFile->skip(1); // version, unused for now
+ _currentLevel = inSaveFile->readByte();
+ _currentSubLevelSceneId = inSaveFile->readUint16LE();
+ _continuesUsed = inSaveFile->readByte();
+ _restartScene = inSaveFile->readUint16LE();
+ for (uint8 i = 0; i < 2; i++) {
+ _playerLives[i] = inSaveFile->readByte();
+ _playerShots[i] = inSaveFile->readByte();
+ _playerScore[i] = inSaveFile->readUint32LE();
+ }
+ _unk_2ADA6 = inSaveFile->readByte();
+ _numPlayers = inSaveFile->readByte();
+ delete inSaveFile;
+ _gameInProgress = true;
+ return true;
+}
+
+// misc game functions
+void GameBountyHunter::_SetNextScene(uint16 sceneId) {
+ _cur_scene = Common::String::format("%d", sceneId);
+}
+
+void GameBountyHunter::_DisplayShotFiredImage(Common::Point *point) {
+ if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
+ uint16 targetX = point->x - _videoPosX;
+ uint16 targetY = point->y - _videoPosY;
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ }
+}
+
+void GameBountyHunter::_EnableVideoFadeIn() {
+ // TODO implement
+}
+
+void GameBountyHunter::_IconShotgun() {
+ // TODO implement
+}
+
+void GameBountyHunter::_IconReset() {
+ // TODO implement
+}
+
+uint16 GameBountyHunter::_BeginLevel(uint8 levelNumber) {
+ _currentLevel = levelNumber;
+ _numSubLevelsDone = 0;
+ int index = (levelNumber * 24) + (_numLevelsDone * 6) + _numSubLevelsDone;
+ uint8 subLevel = _subLevelOrder[index];
+ uint16 sceneIndex = (_currentLevel * 5) + subLevel;
+ uint16 sceneNum = _subLevelSceneIds[sceneIndex];
+ _currentSubLevelSceneId = sceneNum;
+ return sceneNum;
+}
+
+uint16 GameBountyHunter::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
+ if (max == 1) {
+ return 0;
+ }
+ // reset mask if full
+ uint16 fullMask = 0xFFFF >> (16 - max);
+ if (*mask == fullMask) {
+ *mask = 0;
+ }
+ uint16 random;
+ // find an unused random number
+ while (1) {
+ random = _rnd->getRandomNumber(max - 1);
+ // check if bit is already used
+ unsigned int bit = 1 << random;
+ if (!((*mask & bit) || random == exclude)) {
+ // set the bit in mask
+ *mask |= bit;
+ break;
+ }
+ }
+ return random;
+}
+
+uint16 GameBountyHunter::_PickRandomScene(const uint16 *sceneList, uint8 max) {
+ if (max == 0) {
+ return 0;
+ }
+ _random_scene_list = const_cast<uint16 *>(sceneList);
+ _random_max = max;
+ _random_mask = 0;
+ _random_picked = -1;
+ _random_scene_count = 0;
+ while (_random_scene_list[_random_scene_count] != 0) {
+ _random_scene_count++;
+ }
+ unsigned short count = _random_max--;
+ if (count > 0) {
+ _random_picked = _RandomUnusedInt(_random_scene_count, &_random_mask, _random_picked);
+ return _random_scene_list[_random_picked];
+ }
+ return 0;
+}
+
+uint16 GameBountyHunter::_PickGunfightScene() {
+ if (!_gunfight_initialized) {
+ _gunfight_initialized = true;
+ _gunfight_mask = 0;
+ _gunfight_picked = -1;
+ _gunfight_scene_count = 0;
+ while (_gunfightScenarios[_gunfight_scene_count] != 0) {
+ _gunfight_scene_count++;
+ }
+ }
+ _random_picked = _RandomUnusedInt(_gunfight_scene_count, &_gunfight_mask, _random_picked);
+ return _gunfightScenarios[_random_picked];
+}
+
+uint16 GameBountyHunter::_PickInnocentScene() {
+ if (!_innocent_initialized) {
+ _innocent_initialized = true;
+ _innocent_mask = 0;
+ _innocent_picked = -1;
+ _innocent_scene_count = 0;
+ while (_innocentScenarios[_innocent_scene_count] != 0) {
+ _innocent_scene_count++;
+ }
+ }
+ _innocent_picked = _RandomUnusedInt(_innocent_scene_count, &_innocent_mask, _innocent_picked);
+ return _innocentScenarios[_innocent_picked];
+}
+
+uint16 GameBountyHunter::_PickDeathScene() {
+ if (!_death_initialized) {
+ _death_initialized = true;
+ _death_mask = 0;
+ _death_picked = -1;
+ _death_scene_count = 0;
+ while (_deathScenarios[_death_scene_count] != 0) {
+ _death_scene_count++;
+ }
+ }
+ _death_picked = _RandomUnusedInt(_death_scene_count, &_death_mask, _death_picked);
+ return _deathScenarios[_death_picked];
+}
+
+uint16 GameBountyHunter::_TimeForGunfight() {
+ uint16 picked = 0;
+ if (--_gunfightCount <= 0) {
+ int index = (_unk_2ADA6 * 5) + (_numLevelsDone);
+ _gunfightCount = _gunfightCountDown[index];
+ picked = _PickGunfightScene();
+ }
+ return picked;
+}
+
+void GameBountyHunter::_WaitingForShootout(uint32 drawFrame) {
+ if (drawFrame != 0) {
+ for (uint8 i = 0; i < _numPlayers; i++) {
+ _firstDrawFrame = drawFrame;
+ _playerShots[i] = 0;
+ _playerGun[i] = 0;
+ _DisplayShotsLeft(i);
+ }
+ }
+ // TODO investigate & fix
+ if (_currentFrame > _firstDrawFrame) {
+ // player1 = 1;
+ // player2 = 1;
+ }
+ /*
+ if (shotsPlayer1 <= 0 && shotsPlayer2 <= 0) {
+ return false;
+ }
+ return true;
+ */
+}
+
+void GameBountyHunter::_DoShotgunSound() {
+ _PlaySound(_shotgunSound);
+}
+
+// Script functions: RectHit
+void GameBountyHunter::_rect_shotmenu(Rect *rect) {
+ _DoMenu();
+}
+
+void GameBountyHunter::_rect_save(Rect *rect) {
+ if (_SaveState()) {
+ _DoSaveSound();
+ }
+}
+
+void GameBountyHunter::_rect_load(Rect *rect) {
+ if (_LoadState()) {
+ _DoLoadSound();
+ }
+ _SetNextScene(_restartScene);
+ _restartScene = 0;
+}
+
+void GameBountyHunter::_rect_continue(Rect *rect) {
+ _inMenu = false;
+ _fired = false;
+ if (_gameInProgress) {
+ bool canContinue = (_playerLives[0] > 0 && _playerLives[1] > 0);
+ if (!canContinue) {
+ int playerIndex = (_playerLives[0] > 0) ? 0 : 1;
+ _continuesUsed++;
+ if (_continuesUsed <= 2) {
+ _playerLives[playerIndex] = 3;
+ _playerScore[playerIndex] *= 0.75;
+ } else {
+ _scene_nxtscn_did_not_continue(nullptr);
+ }
+ }
+ }
+}
+
+void GameBountyHunter::_rect_start(Rect *rect) {
+ _inMenu = false;
+ _fired = false;
+ _gameInProgress = true;
+ _restartScene = 0;
+ if (_isDemo) {
+ _SetNextScene(0x45); // TODO fix
+ } else {
+ _SetNextScene(0x45);
+ }
+ _NewGame();
+}
+
+void GameBountyHunter::_rect_toggle_players(Rect *rect) {
+ if (_numPlayers == 1) {
+ _numPlayers = 2;
+ AlgGraphics::drawImage(_screen, &_playersIcon2, 0xCE, 0x95);
+ AlgGraphics::drawImage(_screen, &_textBlackBarIcon, 0x78, 0xBF);
+ AlgGraphics::drawImage(_screen, &_textBlackBarIcon, 0x0C, 0xBF);
+ _DisplayShotsLeft(1);
+ _DisplayLivesLeft(1);
+ } else {
+ _numPlayers = 1;
+ AlgGraphics::drawImage(_screen, &_playersIcon1, 0xCE, 0x95);
+ AlgGraphics::drawImage(_screen, &_textScoreIcon, 0x78, 0xBF);
+ AlgGraphics::drawImage(_screen, &_textMenuIcon, 0x0C, 0xBF);
+ AlgGraphics::drawImage(_screen, &_textBlackBarIcon, 0x50, 0xBE);
+ }
+ _DoSkullSound();
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+}
+
+void GameBountyHunter::_rect_hit_icon_jug(Rect *rect) {
+ // TODO fix
+ // Icon.funcs[1](param);
+ // PlaySound(4);
+ // Icon.hitCount++;
+}
+
+void GameBountyHunter::_rect_hit_icon_lantern(Rect *rect) {
+ // TODO fix
+ // Icon.funcs[3](param);
+ // PlaySound(4);
+ // Icon.hitCount++;
+}
+
+void GameBountyHunter::_rect_hit_icon_skull(Rect *rect) {
+ // TODO fix
+ // Icon.funcs[0](param);
+ // PlaySound(4);
+ // Icon.hitCount++;
+}
+
+void GameBountyHunter::_rect_hit_icon_wheel(Rect *rect) {
+ // TODO fix
+ // Icon.funcs[2](param);
+ // PlaySound(4);
+ // Icon.hitCount++;
+}
+
+void GameBountyHunter::_rect_hit_select_harry(Rect *rect) {
+ if (!(_levelDoneMask & 2)) {
+ uint16 picked = _BeginLevel(0);
+ _SetNextScene(picked);
+ }
+}
+
+void GameBountyHunter::_rect_hit_select_dan(Rect *rect) {
+ if (!(_levelDoneMask & 4)) {
+ uint16 picked = _BeginLevel(1);
+ _SetNextScene(picked);
+ }
+}
+
+void GameBountyHunter::_rect_hit_select_loco(Rect *rect) {
+ if (!(_levelDoneMask & 8)) {
+ uint16 picked = _BeginLevel(2);
+ _SetNextScene(picked);
+ }
+}
+
+void GameBountyHunter::_rect_hit_select_kid(Rect *rect) {
+ if (!(_levelDoneMask & 0x10)) {
+ uint16 picked = _BeginLevel(3);
+ _SetNextScene(picked);
+ }
+}
+
+void GameBountyHunter::_rect_hit_kill_man(Rect *rect) {
+ // do nothing
+}
+
+void GameBountyHunter::_rect_hit_give_shotgun(Rect *rect) {
+ _IconShotgun();
+}
+
+void GameBountyHunter::_rect_hit_kill3(Rect *rect) {
+ _count++;
+ if (_count == 3) {
+ _count = 0;
+ _rect_newscene(rect);
+ // TODO verify
+ // _RHONewScene(param1, param2);
+ }
+}
+
+void GameBountyHunter::_rect_hit_check_shotgun(Rect *rect) {
+ if (_playerGun[_player] == 2) {
+ _rect_newscene(rect);
+ }
+}
+
+void GameBountyHunter::_rect_hit_cheater(Rect *rect) {
+ _SetNextScene(0x011A);
+}
+
+// Script functions: Scene PreOps
+void GameBountyHunter::_scene_pso_shootout(Scene *scene) {
+ _WaitingForShootout(atoi(scene->preopParam.c_str()));
+}
+
+void GameBountyHunter::_scene_pso_wounded_main(Scene *scene) {
+ _wounded = true;
+ _currentSubLevelSceneId = _moneyScenes[_currentLevel];
+}
+
+void GameBountyHunter::_scene_pso_gunfight_setup(Scene *scene) {
+ _WaitingForShootout(atoi(scene->preopParam.c_str()));
+}
+
+void GameBountyHunter::_scene_pso_lose_a_life(Scene *scene) {
+ _scene_nxtscn_lose_a_life(scene);
+}
+
+void GameBountyHunter::_scene_pso_setup_ndrandom1(Scene *scene) {
+ _numSubLevelsDone++;
+}
+
+void GameBountyHunter::_scene_pso_set_current_scene(Scene *scene) {
+ int sceneId = atoi(scene->preopParam.c_str());
+ _currentSubLevelSceneId = sceneId;
+ if (sceneId == 0) {
+ uint8 index = (_currentLevel * 24) + (_numLevelsDone * 6) + _numSubLevelsDone;
+ uint8 subLevel = _subLevelOrder[index];
+ uint16 picked = (_currentLevel * 20) + (subLevel * 4);
+ _currentSubLevelSceneId = 0x0D32 + picked;
+ }
+}
+
+// Script functions: Scene InsOps
+void GameBountyHunter::_scene_iso_shootout(Scene *scene) {
+ _WaitingForShootout(0);
+}
+
+void GameBountyHunter::_scene_iso_givemoney(Scene *scene) {
+ const int moneyFrames[] = {0x1E8F, 0x3BB4, 0x7814, 0xA287};
+ const int woundBits[] = {2, 4, 8, 0x10};
+ for (uint8 i = 0; i < _numPlayers; i++) {
+ if (_currentLevel <= 3) {
+ unsigned long moneyFrame = moneyFrames[_currentLevel];
+ // TODO investigate
+ if (moneyFrame == _currentFrame && !_given) {
+ if (_wounded) {
+ _mainWounds |= woundBits[_currentLevel];
+ int bonus = (2 ^ _numLevelsDone) * 200;
+ _playerScore[i] += bonus;
+ } else {
+ int bonus = (2 ^ _numLevelsDone) * 100;
+ _playerScore[i] += bonus;
+ }
+ _wounded = 0;
+ _given = 1;
+ } else if (moneyFrame != _currentFrame) {
+ _given = 0;
+ }
+ }
+ _DisplayScores(i);
+ }
+}
+
+// Script functions: Scene NxtScn
+void GameBountyHunter::_scene_nxtscn_lose_a_life(Scene *scene) {
+ uint16 picked = 0;
+ int deadPlayerCount = 0;
+ for (int i = 0; i < _numPlayers; i++) {
+ _playerLives[i]--;
+ _DisplayLivesLeft(i);
+ if (_playerLives[i] <= 0) {
+ _playerScore[i] = (_playerScore[i] * 6) / 10;
+ deadPlayerCount++;
+ }
+ }
+ if (deadPlayerCount == 1 && _numPlayers == 2) {
+ picked = _onePlayerOfTwoDead[_numSubLevelsDone & 1];
+ } else if (deadPlayerCount > 0) {
+ picked = _allPlayersDead;
+ } else {
+ picked = _PickDeathScene();
+ }
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_continue_game(Scene *scene) {
+ if (_continuesUsed < 2) {
+ _SetNextScene(0x01B6);
+ } else {
+ _scene_nxtscn_did_not_continue(scene);
+ }
+}
+
+void GameBountyHunter::_scene_nxtscn_did_not_continue(Scene *scene) {
+ _gameInProgress = false;
+ _cur_scene = _startscene;
+}
+
+void GameBountyHunter::_scene_nxtscn_kill_innocent_man(Scene *scene) {
+ uint16 picked = 0;
+ _playerLives[_player]--;
+ if (_playerLives[_player]) {
+ picked = _PickInnocentScene();
+ } else {
+ if (_numPlayers == 2) {
+ picked = _onePlayerOfTwoDead[_numSubLevelsDone & 1];
+ } else {
+ picked = _allPlayersDead;
+ }
+ }
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_kill_innocent_woman(Scene *scene) {
+ _scene_nxtscn_kill_innocent_man(scene);
+}
+
+void GameBountyHunter::_scene_nxtscn_after_die(Scene *scene) {
+ for (uint8 i = 0; i < _numPlayers; i++) {
+ if (_playerLives[i] <= 0) {
+ _playerLives[i] = 3;
+ _DisplayLivesLeft(i);
+ }
+ }
+ _SetNextScene(_currentSubLevelSceneId);
+}
+
+void GameBountyHunter::_scene_nxtscn_goto_level_select(Scene *scene) {
+ _IconReset();
+ uint16 picked = 0;
+ if ((_levelDoneMask & 0x1E) != 0x1E) {
+ picked = 0x17B;
+ } else if (!(_levelDoneMask & 0x80)) {
+ picked = 0x66;
+ } else {
+ picked = 0x61;
+ }
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_continue_random(Scene *scene) {
+ // TODO verify
+ _scene_nxtscn_next_sub_level(scene);
+ /*
+ uint16 picked = _PickRandomScene(0, 0);
+ if (picked == 0) {
+ _scene_nxtscn_next_sub_level(scene);
+ return;
+ }
+ _SetNextScene(picked);
+ */
+}
+
+void GameBountyHunter::_scene_nxtscn_init_random_harry1(Scene *scene) {
+ uint16 picked = _PickRandomScene(_randomScenes[0], _randomScenesPicks[0]);
+ _currentSubLevelSceneId = picked;
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_init_random_harry2(Scene *scene) {
+ uint16 picked = _PickRandomScene(_randomScenes[1], _randomScenesPicks[1]);
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_init_random_dan1(Scene *scene) {
+ uint16 picked = 0;
+ uint8 picks = _randomScenesPicks[2] + _numPlayers;
+ if (_numPlayers == 2) {
+ picked = _PickRandomScene(_randomDan1TwoPlayer, picks);
+ } else {
+ picked = _PickRandomScene(_randomScenes[2], picks);
+ }
+ _currentSubLevelSceneId = 0x0174;
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_init_random_dan2(Scene *scene) {
+ uint16 picked = _PickRandomScene(_randomScenes[3], _randomScenesPicks[3]);
+ _currentSubLevelSceneId = picked;
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_init_random_loco1(Scene *scene) {
+ uint16 picked = _PickRandomScene(_randomScenes[4], _randomScenesPicks[4]);
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_init_random_loco2(Scene *scene) {
+ uint16 picked = _PickRandomScene(_randomScenes[5], _randomScenesPicks[5]);
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_init_random_kid1(Scene *scene) {
+ uint16 picked = _PickRandomScene(_randomScenes[6], _randomScenesPicks[6]);
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_init_random_kid2(Scene *scene) {
+ uint16 picked = _PickRandomScene(_randomScenes[7], _randomScenesPicks[7]);
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_next_sub_level(Scene *scene) {
+ _IconReset();
+ _numSubLevelsDone++;
+ int index = (_currentLevel * 24) + (_numLevelsDone * 6) + _numSubLevelsDone;
+ uint8 subLevel = _subLevelOrder[index];
+ uint16 sceneIndex = (_currentLevel * 5) + subLevel;
+ uint16 picked = _subLevelSceneIds[sceneIndex];
+ _currentSubLevelSceneId = picked;
+ uint16 gunfightScene = _TimeForGunfight();
+ if (gunfightScene != 0) {
+ _SetNextScene(gunfightScene);
+ }
+ if (subLevel == 2) {
+ if (_currentLevel == 0) {
+ _SetNextScene(picked);
+ return;
+ }
+ picked = _clueLevels[_currentLevel];
+ }
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_goto_bad_guy(Scene *scene) {
+ _IconReset();
+ uint8 index = (_currentLevel * 24) + (_numLevelsDone * 6) + _numSubLevelsDone;
+ uint8 subLevel = _subLevelOrder[index];
+ uint16 sceneIndex = (_currentLevel * 5) + subLevel;
+ uint16 picked = _subLevelSceneIds[sceneIndex];
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_auto_select_level(Scene *scene) {
+ _IconReset();
+ uint8 i;
+ for (i = 0; i < 4; i++) {
+ if (!(_levelDoneMask & _mainLevelMasks[i])) {
+ break;
+ }
+ }
+ uint16 picked = _BeginLevel(i);
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_select_scenario(Scene *scene) {
+ _SetNextScene(_currentLevel);
+}
+
+void GameBountyHunter::_scene_nxtscn_finish_scenario(Scene *scene) {
+ // do nothing
+}
+
+void GameBountyHunter::_scene_nxtscn_game_won(Scene *scene) {
+ _gameInProgress = false;
+ _cur_scene = _startscene;
+}
+
+void GameBountyHunter::_scene_nxtscn_killed_main(Scene *scene) {
+ _wounded = false;
+ _sub_scene = "scene379";
+}
+
+void GameBountyHunter::_scene_nxtscn_wounded_main(Scene *scene) {
+ _wounded = true;
+ _sub_scene = "scene379";
+}
+
+void GameBountyHunter::_scene_nxtscn_end_level(Scene *scene) {
+ switch (_currentLevel) {
+ case 0:
+ _levelDoneMask |= 0x02;
+ break;
+ case 1:
+ _levelDoneMask |= 0x04;
+ break;
+ case 2:
+ _levelDoneMask |= 0x08;
+ break;
+ case 3:
+ _levelDoneMask |= 0x10;
+ break;
+ default:
+ return;
+ }
+ _numLevelsDone++;
+ if (_numLevelsDone > 1 && _unk_2ADA6 < 2) {
+ _unk_2ADA6++;
+ }
+ _numSubLevelsDone = 0;
+ _currentSubLevelSceneId = 0;
+ if (_numLevelsDone == 4) {
+ _SetNextScene(0x66);
+ return;
+ }
+ _SetNextScene(0x017B);
+}
+
+void GameBountyHunter::_scene_nxtscn_end_game(Scene *scene) {
+ _gameInProgress = false;
+ _cur_scene = _startscene;
+}
+
+void GameBountyHunter::_scene_nxtscn_do_breakout_mains(Scene *scene) {
+ uint16 picked = 0;
+ if (_mainWounds & 2) {
+ _mainWounds &= 0xFFFD;
+ picked = 0x53;
+ } else if (_mainWounds & 4) {
+ _mainWounds &= 0xFFFB;
+ picked = 0x50;
+ } else if (_mainWounds & 8) {
+ _mainWounds &= 0xFFF7;
+ picked = 0x4D;
+ } else if (_mainWounds & 0x10) {
+ _mainWounds &= 0xFFEF;
+ picked = 0x4B;
+ } else {
+ picked = 0x61;
+ }
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_died_refed(Scene *scene) {
+ uint16 picked = 0;
+ uint8 deadCount = 0;
+ for (int i = 0; i < _numPlayers; i++) {
+ _playerLives[i]--;
+ _DisplayLivesLeft(i);
+ if (_playerLives[i] <= 0) {
+ deadCount++;
+ }
+ }
+ if (deadCount == 1 && _numPlayers == 2) {
+ picked = _onePlayerOfTwoDead[_numSubLevelsDone & 1];
+ } else if (deadCount > 0) {
+ picked = _allPlayersDead;
+ } else {
+ picked = 0x114;
+ }
+ _SetNextScene(picked);
+}
+
+void GameBountyHunter::_scene_nxtscn_give_shotgun(Scene *scene) {
+ for (uint8 i = 0; i < _numPlayers; i++) {
+ _playerShots[i] = 5;
+ _playerGun[i] = 2;
+ _DisplayShotsLeft(i);
+ }
+}
+
+void GameBountyHunter::_scene_nxtscn_check_2players(Scene *scene) {
+ if (_numPlayers == 2) {
+ _SetNextScene(0x98);
+ return;
+ }
+ _SetNextScene(0x99);
+}
+
+// Script functions: WepDwn
+void GameBountyHunter::_scene_default_wepdwn(Scene *scene) {
+ if (_playerGun[_player] == 2 && _playerShots[_player] < 3) {
+ _playerGun[_player] = 1;
+ }
+ if (_playerGun[_player] == 1 && _playerShots[_player] < 6) {
+ _playerShots[_player] = 6;
+ }
+}
+
+// Debug methods
+void GameBountyHunter::debug_warpTo(int val) {
+ // TODO implement
+}
+
+// Debugger methods
+DebuggerBountyHunter::DebuggerBountyHunter(GameBountyHunter *game) : GUI::Debugger() {
+ _game = game;
+ registerVar("drawRects", &game->_debug_drawRects);
+ registerVar("godMode", &game->_debug_godMode);
+ registerVar("unlimitedAmmo", &game->_debug_unlimitedAmmo);
+ registerCmd("warpTo", WRAP_METHOD(DebuggerBountyHunter, cmdWarpTo));
+ registerCmd("dumpLib", WRAP_METHOD(DebuggerBountyHunter, cmdDumpLib));
+}
+
+bool DebuggerBountyHunter::cmdWarpTo(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: warp <int>");
+ return true;
+ } else {
+ int val = atoi(argv[1]);
+ _game->debug_warpTo(val);
+ return false;
+ }
+}
+
+bool DebuggerBountyHunter::cmdDumpLib(int argc, const char **argv) {
+ return _game->debug_dumpLibFile();
+}
+
+} // End of namespace Alg
diff --git a/engines/alg/game_bountyhunter.h b/engines/alg/game_bountyhunter.h
new file mode 100644
index 00000000000..da252f60bb9
--- /dev/null
+++ b/engines/alg/game_bountyhunter.h
@@ -0,0 +1,290 @@
+/* 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 ALG_GAME_BOUNTYHUNTER_H
+#define ALG_GAME_BOUNTYHUNTER_H
+
+#include "common/hashmap.h"
+#include "common/rect.h"
+
+#include "gui/debugger.h"
+
+#include "alg/game.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+typedef Common::Functor1Mem<Scene *, void, GameBountyHunter> BHScriptFunctionScene;
+typedef Common::Functor1Mem<Rect *, void, GameBountyHunter> BHScriptFunctionRect;
+typedef Common::Functor1Mem<Common::Point *, void, GameJohnnyRock> BHScriptFunctionPoint;
+typedef Common::HashMap<Common::String, BHScriptFunctionScene *> BHScriptFunctionSceneMap;
+typedef Common::HashMap<Common::String, BHScriptFunctionRect *> BHScriptFunctionRectMap;
+typedef Common::HashMap<Common::String, BHScriptFunctionPoint *> BHScriptFunctionPointMap;
+
+class GameBountyHunter : public Game {
+
+ enum SceneFuncType {
+ PREOP = 1,
+ SHOWMSG = 2,
+ INSOP = 3,
+ WEPDWN = 4,
+ SCNSCR = 5,
+ NXTFRM = 6,
+ NXTSCN = 7
+ };
+
+public:
+ GameBountyHunter(AlgEngine *vm, const ADGameDescription *desc);
+ ~GameBountyHunter();
+ Common::Error run();
+ void debug_warpTo(int val);
+
+private:
+ void init();
+ void registerScriptFunctions();
+ void verifyScriptFunctions();
+ BHScriptFunctionRect getScriptFunctionRectHit(Common::String name);
+ BHScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
+ void callScriptFunctionRectHit(Common::String name, Rect *rect);
+ void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
+
+ BHScriptFunctionRectMap _rectHitFuncs;
+ BHScriptFunctionSceneMap _scenePreOps;
+ BHScriptFunctionSceneMap _sceneShowMsg;
+ BHScriptFunctionSceneMap _sceneInsOps;
+ BHScriptFunctionSceneMap _sceneWepDwn;
+ BHScriptFunctionSceneMap _sceneScnScr;
+ BHScriptFunctionSceneMap _sceneNxtFrm;
+ BHScriptFunctionSceneMap _sceneNxtScn;
+
+ // images
+ Graphics::Surface _shotIcon;
+ Graphics::Surface _emptyIcon;
+ Graphics::Surface _liveIcon;
+ Graphics::Surface _deadIcon;
+ Graphics::Surface _diffIcon;
+ Graphics::Surface _bulletholeIcon;
+ Graphics::Surface _playersIcon1;
+ Graphics::Surface _playersIcon2;
+ Graphics::Surface _textScoreIcon;
+ Graphics::Surface _textMenuIcon;
+ Graphics::Surface _textBlackBarIcon;
+ Common::Array<Graphics::Surface> *_bagsIcons;
+ Common::Array<Graphics::Surface> *_shotgun;
+
+ // sounds
+ Audio::SeekableAudioStream *_shotgunSound = nullptr;
+
+ // constants
+ const uint16 _randomHarry1[7] = {0x01B9, 0x01B7, 0x01B5, 0x01B3, 0x01AF, 0x01AD, 0};
+ const uint16 _randomHarry2[6] = {0x0194, 0x0190, 0x018E, 0x018C, 0};
+ const uint16 _randomDan1[5] = {0x0173, 0x0171, 0x016F, 0x016D, 0};
+ const uint16 _randomDan1TwoPlayer[6] = {0x0173, 0x0171, 0x016F, 0x016D, 0x016B, 0};
+ const uint16 _randomDan2[7] = {0x0165, 0x0163, 0x0161, 0x015F, 0x015D, 0x015B, 0};
+ const uint16 _randomLoco1[4] = {0xF7, 0xF5, 0xF3, 0};
+ const uint16 _randomLoco2[3] = {0xED, 0xEB, 0};
+ const uint16 _randomKid1[4] = {0xBA, 0xB7, 0xB5, 0};
+ const uint16 _randomKid2[4] = {0xB1, 0xAE, 0xAC, 0};
+
+ const uint16 *_randomScenes[8] = {_randomHarry1, _randomHarry2, _randomDan1, _randomDan2, _randomLoco1, _randomLoco2, _randomKid1, _randomKid2};
+ const uint8 _randomScenesPicks[8] = {6, 6, 4, 7, 3, 2, 5, 5};
+
+ const uint8 _subLevelOrder[96] = {0, 1, 2, 4, 0, 0, 0, 1, 3, 4, 0, 0, 0, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4, 0,
+ 0, 1, 2, 4, 0, 0, 0, 1, 3, 4, 0, 0, 0, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4, 0,
+ 0, 1, 3, 4, 0, 0, 0, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4, 0,
+ 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0};
+ const uint16 _subLevelSceneIds[20] = {0x01BE, 0x017A, 0x01A2, 0x0198, 0x0183, 0x0178, 0x0167, 0x0159, 0x014B, 0x0147,
+ 0xF1, 0xE1, 0xFF, 0xD8, 0xD0, 0x9B, 0xA8, 0x86, 0xBF, 0x74};
+
+ const uint16 _clueLevels[4] = {0x017A, 0x013B, 0xC2, 0x68};
+ const uint8 _mainLevelMasks[5] = {2, 4, 8, 0x10, 0x80};
+ const uint8 _gunfightCountDown[15] = {5, 4, 3, 3, 3, 4, 3, 3, 2, 1, 3, 2, 2, 2, 1};
+
+ const uint16 _firstSceneInScenario[4] = {4, 0x36, 0x36, 0x66};
+ const uint16 _moneyScenes[4] = {0x017D, 0x013C, 0xC3, 0x69};
+ const uint16 _gunfightScenarios[18] = {0x0116, 0x0118, 0x011B, 0x011D, 0x011F, 0x0121, 0x0123, 0x0125, 0x0127,
+ 0x0129, 0x012B, 0x012D, 0x012F, 0x0131, 0x0133, 0x0135, 0x0137, 0x0139};
+ const uint16 _innocentScenarios[5] = {0x0110, 0x010F, 0x010C, 0x010B, 0};
+ const uint16 _deathScenarios[9] = {0x0100, 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0};
+ const uint16 _onePlayerOfTwoDead[2] = {0x0109, 0x010A};
+ const uint16 _allPlayersDead = 0x108;
+
+ bool _isDemo = 0;
+
+ // gamestate
+ uint16 _restartScene = 0;
+ uint8 _numPlayers = 1;
+ uint8 _player = 0;
+ uint8 _playerLives[2] = {0, 0};
+ uint8 _playerGun[2] = {1, 1};
+ uint8 _playerShots[2] = {0, 0};
+ uint32 _playerScore[2] = {0, 0};
+
+ uint8 _currentLevel = 0;
+ uint16 _currentSubLevelSceneId = 0;
+ uint8 _numLevelsDone = 0;
+ uint8 _levelDoneMask = 0;
+ uint8 _numSubLevelsDone = 0;
+
+ uint16 usedScenes = 0;
+ int16 lastPick = -1;
+ int16 initted = 0;
+ int16 sceneCount = 0;
+
+ uint16 *_random_scene_list;
+ uint8 _random_max = 0;
+ uint16 _random_mask = 0;
+ int16 _random_picked = 0;
+ uint8 _random_scene_count = 0;
+ bool _gunfight_initialized = false;
+ uint16 _gunfight_mask = 0;
+ int16 _gunfight_picked = 0;
+ uint8 _gunfight_scene_count = 0;
+ bool _innocent_initialized = false;
+ uint16 _innocent_mask = 0;
+ int16 _innocent_picked = 0;
+ uint8 _innocent_scene_count = 0;
+ bool _death_initialized = false;
+ uint16 _death_mask = 0;
+ int16 _death_picked = 0;
+ uint8 _death_scene_count = 0;
+
+ uint8 _continuesUsed = 0;
+ bool _wounded = false;
+ uint16 _mainWounds = 0;
+ int8 _gunfightCount = 0;
+ bool _given = false;
+ uint32 _firstDrawFrame = 0;
+ uint8 _count = 0;
+
+ uint8 _unk_2ADA6 = 0;
+
+ // base functions
+ void _NewGame();
+ void _DoMenu();
+ void _DoCursor();
+ void _UpdateMouse();
+ void _MoveMouse();
+ void _DisplayLivesLeft(uint8 player);
+ void _DisplayScores(uint8 player);
+ void _DisplayShotsLeft(uint8 player);
+ bool _WeaponDown();
+ bool _SaveState();
+ bool _LoadState();
+
+ // misc game functions
+ void _SetNextScene(uint16 sceneId);
+ void _DisplayShotFiredImage(Common::Point *point);
+ void _EnableVideoFadeIn();
+ void _IconShotgun();
+ void _IconReset();
+ uint16 _BeginLevel(uint8 levelNumber);
+ uint16 _RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
+ uint16 _PickRandomScene(const uint16 *sceneList, uint8 max);
+ uint16 _PickGunfightScene();
+ uint16 _PickInnocentScene();
+ uint16 _PickDeathScene();
+ uint16 _TimeForGunfight();
+ void _WaitingForShootout(uint32 drawFrame);
+ void _DoShotgunSound();
+
+ // Script functions: RectHit
+ void _rect_shotmenu(Rect *rect);
+ void _rect_save(Rect *rect);
+ void _rect_load(Rect *rect);
+ void _rect_continue(Rect *rect);
+ void _rect_start(Rect *rect);
+ void _rect_toggle_players(Rect *rect);
+ void _rect_hit_icon_jug(Rect *rect);
+ void _rect_hit_icon_lantern(Rect *rect);
+ void _rect_hit_icon_skull(Rect *rect);
+ void _rect_hit_icon_wheel(Rect *rect);
+ void _rect_hit_select_harry(Rect *rect);
+ void _rect_hit_select_dan(Rect *rect);
+ void _rect_hit_select_loco(Rect *rect);
+ void _rect_hit_select_kid(Rect *rect);
+ void _rect_hit_kill_man(Rect *rect);
+ void _rect_hit_give_shotgun(Rect *rect);
+ void _rect_hit_kill3(Rect *rect);
+ void _rect_hit_check_shotgun(Rect *rect);
+ void _rect_hit_cheater(Rect *rect);
+
+ // Script functions: Scene PreOps
+ void _scene_pso_shootout(Scene *scene);
+ void _scene_pso_wounded_main(Scene *scene);
+ void _scene_pso_gunfight_setup(Scene *scene);
+ void _scene_pso_lose_a_life(Scene *scene);
+ void _scene_pso_setup_ndrandom1(Scene *scene);
+ void _scene_pso_set_current_scene(Scene *scene);
+
+ // Script functions: Scene InsOps
+ void _scene_iso_shootout(Scene *scene);
+ void _scene_iso_givemoney(Scene *scene);
+
+ // Script functions: Scene NxtScn
+ void _scene_nxtscn_lose_a_life(Scene *scene);
+ void _scene_nxtscn_continue_game(Scene *scene);
+ void _scene_nxtscn_did_not_continue(Scene *scene);
+ void _scene_nxtscn_kill_innocent_man(Scene *scene);
+ void _scene_nxtscn_kill_innocent_woman(Scene *scene);
+ void _scene_nxtscn_after_die(Scene *scene);
+ void _scene_nxtscn_goto_level_select(Scene *scene);
+ void _scene_nxtscn_continue_random(Scene *scene);
+ void _scene_nxtscn_init_random_harry1(Scene *scene);
+ void _scene_nxtscn_init_random_harry2(Scene *scene);
+ void _scene_nxtscn_init_random_dan1(Scene *scene);
+ void _scene_nxtscn_init_random_dan2(Scene *scene);
+ void _scene_nxtscn_init_random_loco1(Scene *scene);
+ void _scene_nxtscn_init_random_loco2(Scene *scene);
+ void _scene_nxtscn_init_random_kid1(Scene *scene);
+ void _scene_nxtscn_init_random_kid2(Scene *scene);
+ void _scene_nxtscn_next_sub_level(Scene *scene);
+ void _scene_nxtscn_goto_bad_guy(Scene *scene);
+ void _scene_nxtscn_auto_select_level(Scene *scene);
+ void _scene_nxtscn_select_scenario(Scene *scene);
+ void _scene_nxtscn_finish_scenario(Scene *scene);
+ void _scene_nxtscn_game_won(Scene *scene);
+ void _scene_nxtscn_killed_main(Scene *scene);
+ void _scene_nxtscn_wounded_main(Scene *scene);
+ void _scene_nxtscn_end_level(Scene *scene);
+ void _scene_nxtscn_end_game(Scene *scene);
+ void _scene_nxtscn_do_breakout_mains(Scene *scene);
+ void _scene_nxtscn_died_refed(Scene *scene);
+ void _scene_nxtscn_give_shotgun(Scene *scene);
+ void _scene_nxtscn_check_2players(Scene *scene);
+
+ // Script functions: Scene WepDwn
+ void _scene_default_wepdwn(Scene *scene);
+};
+
+class DebuggerBountyHunter : public GUI::Debugger {
+public:
+ DebuggerBountyHunter(GameBountyHunter *game);
+ bool cmdWarpTo(int argc, const char **argv);
+ bool cmdDumpLib(int argc, const char **argv);
+
+private:
+ GameBountyHunter *_game;
+};
+
+} // End of namespace Alg
+
+#endif
diff --git a/engines/alg/game_crimepatrol.cpp b/engines/alg/game_crimepatrol.cpp
new file mode 100644
index 00000000000..ee20d1a302b
--- /dev/null
+++ b/engines/alg/game_crimepatrol.cpp
@@ -0,0 +1,1352 @@
+/* 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/debug.h"
+#include "common/rect.h"
+#include "common/savefile.h"
+#include "common/system.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/pixelformat.h"
+
+#include "alg/game_crimepatrol.h"
+#include "alg/graphics.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+GameCrimePatrol::GameCrimePatrol(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
+ if (scumm_stricmp(desc->gameId, "cpatrols") == 0) {
+ _libFileName = "cpss.lib";
+ } else if (scumm_stricmp(desc->gameId, "cpatrold") == 0) {
+ _libFileName = "cpds.lib";
+ } else if (scumm_stricmp(desc->gameId, "cpatroldemo") == 0) {
+ _libFileName = "cp.lib";
+ _isDemo = true;
+ }
+}
+
+GameCrimePatrol::~GameCrimePatrol() {
+}
+
+void GameCrimePatrol::init() {
+ _videoPosX = 11;
+ _videoPosY = 2;
+
+ loadLibArchive(_libFileName);
+ _sceneInfo->loadScnFile("cp.scn");
+ _startscene = _sceneInfo->getStartScene();
+
+ registerScriptFunctions();
+ verifyScriptFunctions();
+
+ _menuzone = new Zone();
+ _menuzone->name = "MainMenu";
+ _menuzone->ptrfb = "GLOBALHIT";
+
+ _menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
+
+ _submenzone = new Zone();
+ _submenzone->name = "SubMenu";
+ _submenzone->ptrfb = "GLOBALHIT";
+
+ _submenzone->addRect(0x1C, 0x11, 0x5D, 0x20, nullptr, 0, "STARTMENU", "0");
+ _submenzone->addRect(0x1C, 0x31, 0x5D, 0x40, nullptr, 0, "RECTLOAD", "0");
+ _submenzone->addRect(0x1C, 0x51, 0x5D, 0x60, nullptr, 0, "RECTSAVE", "0");
+ _submenzone->addRect(0x1C, 0x71, 0x5D, 0x80, nullptr, 0, "CONTMENU", "0");
+ _submenzone->addRect(0x1C, 0x91, 0x5D, 0xA0, nullptr, 0, "EXITMENU", "0");
+ _submenzone->addRect(0xDD, 0x3C, 0x010A, 0x4B, nullptr, 0, "RECTEASY", "0");
+ _submenzone->addRect(0xDD, 0x5C, 0x010A, 0x6B, nullptr, 0, "RECTAVG", "0");
+ _submenzone->addRect(0xDD, 0x7C, 0x010A, 0x8B, nullptr, 0, "RECTHARD", "0");
+
+ _shotSound = _LoadSoundFile("blow.8b");
+ _emptySound = _LoadSoundFile("empty.8b");
+ _saveSound = _LoadSoundFile("saved.8b");
+ _loadSound = _LoadSoundFile("loaded.8b");
+ _skullSound = _LoadSoundFile("skull.8b");
+
+ _gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
+ _numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
+ Common::Array<Graphics::Surface> *bullets = AlgGraphics::loadAniImage("bullets.ani", _palette);
+ _shotIcon = (*bullets)[0];
+ _emptyIcon = (*bullets)[1];
+ Common::Array<Graphics::Surface> *lives = AlgGraphics::loadAniImage("lives.ani", _palette);
+ _liveIcon = (*lives)[0];
+ _deadIcon = (*lives)[1];
+ Common::Array<Graphics::Surface> *difficlt = AlgGraphics::loadScreenCoordAniImage("difficlt.ani", _palette);
+ _difficultyIcon = (*difficlt)[0];
+ Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
+ _bulletholeIcon = (*hole)[0];
+
+ _background = AlgGraphics::loadVgaBackground("cp_menu.vga", _palette);
+ _screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
+
+ _MoveMouse();
+}
+
+void GameCrimePatrol::registerScriptFunctions() {
+#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new CPScriptFunctionRect(this, &GameCrimePatrol::func);
+ RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
+ RECT_HIT_FUNCTION("NEWSCENE", _rect_newscene);
+ RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
+ RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
+ RECT_HIT_FUNCTION("STARTMENU", _rect_start);
+ RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
+ RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
+ RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
+ RECT_HIT_FUNCTION("RECTEASY", _rect_easy);
+ RECT_HIT_FUNCTION("RECTAVG", _rect_average);
+ RECT_HIT_FUNCTION("RECTHARD", _rect_hard);
+ RECT_HIT_FUNCTION("TARGET_PRACTICE", _rect_target_practice);
+ RECT_HIT_FUNCTION("SELECT_TARGET_PRACTICE", _rect_select_target_practice);
+ RECT_HIT_FUNCTION("SELECT_GANG_FIGHT", _rect_select_gang_fight);
+ RECT_HIT_FUNCTION("SELECT_WAREHOUSE", _rect_select_warehouse);
+ RECT_HIT_FUNCTION("SELECT_WESTCOAST_SOUND", _rect_select_westcoast_sound);
+ RECT_HIT_FUNCTION("SELECT_DRUG_DEAL", _rect_select_drug_deal);
+ RECT_HIT_FUNCTION("SELECT_CAR_RING", _rect_select_car_ring);
+ RECT_HIT_FUNCTION("SELECT_BAR", _rect_select_bar);
+ RECT_HIT_FUNCTION("SELECT_BANK", _rect_select_bank);
+ RECT_HIT_FUNCTION("SELECT_CRACK_HOUSE", _rect_select_crack_house);
+ RECT_HIT_FUNCTION("SELECT_METH_LAB", _rect_select_meth_lab);
+ RECT_HIT_FUNCTION("SELECT_AIRPLANE", _rect_select_airplane);
+ RECT_HIT_FUNCTION("SELECT_NUKE_TRANSPORT", _rect_select_nuke_transport);
+ RECT_HIT_FUNCTION("SELECT_AIRPORT", _rect_select_airport);
+ RECT_HIT_FUNCTION("KILL_INNOCENT_MAN", _rect_kill_innocent_man);
+#undef RECT_HIT_FUNCTION
+
+#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new CPScriptFunctionScene(this, &GameCrimePatrol::func);
+ PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
+ PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
+ PRE_OPS_FUNCTION("PAUSE_FADEIN", _scene_pso_pause_fadein);
+ PRE_OPS_FUNCTION("WAREHOUSE_GOT_TO", _scene_pso_warehouse_got_to);
+ PRE_OPS_FUNCTION("GANG_FIGHT_GOT_TO", _scene_pso_gang_fight_got_to);
+ PRE_OPS_FUNCTION("WESTCOAST_SOUND_GOT_TO", _scene_pso_westcoast_sound_got_to);
+ PRE_OPS_FUNCTION("DRUG_DEAL_GOT_TO", _scene_pso_drug_deal_got_to);
+ PRE_OPS_FUNCTION("CAR_RING_GOT_TO", _scene_pso_car_ring_got_to);
+ PRE_OPS_FUNCTION("BANK_GOT_TO", _scene_pso_bank_got_to);
+ PRE_OPS_FUNCTION("CRACK_HOUSE_GOT_TO", _scene_pso_crack_house_got_to);
+ PRE_OPS_FUNCTION("METH_LAB_GOT_TO", _scene_pso_meth_lab_got_to);
+ PRE_OPS_FUNCTION("AIRPLANE_GOT_TO", _scene_pso_airplane_got_to);
+ PRE_OPS_FUNCTION("AIRPORT_GOT_TO", _scene_pso_airport_got_to);
+ PRE_OPS_FUNCTION("NUKE_TRANSPORT_GOT_TO", _scene_pso_nuke_transport_got_to);
+ PRE_OPS_FUNCTION("POWER_PLANT_GOT_TO", _scene_pso_power_plant_got_to);
+#undef PRE_OPS_FUNCTION
+
+#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new CPScriptFunctionScene(this, &GameCrimePatrol::func);
+ INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
+ INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
+#undef INS_OPS_FUNCTION
+
+#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new CPScriptFunctionScene(this, &GameCrimePatrol::func);
+ NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
+ NXT_SCN_FUNCTION("GAME_WON", _scene_nxtscn_game_won);
+ NXT_SCN_FUNCTION("LOSE_A_LIFE", _scene_nxtscn_lose_a_life);
+ NXT_SCN_FUNCTION("DID_NOT_CONTINUE", _scene_nxtscn_did_not_continue);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_MAN", _scene_nxtscn_kill_innocent_man);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_WOMAN", _scene_nxtscn_kill_innocent_woman);
+ NXT_SCN_FUNCTION("AFTER_DIE", _scene_nxtscn_after_die);
+ NXT_SCN_FUNCTION("SELECT_LANGUAGE_1", _scene_nxtscn_select_language_1);
+ NXT_SCN_FUNCTION("SELECT_LANGUAGE_2", _scene_nxtscn_select_language_2);
+ NXT_SCN_FUNCTION("INIT_RANDOM_TARGET_PRACTICE", _scene_nxtscn_init_random_target_practice);
+ NXT_SCN_FUNCTION("CONTINUE_TARGET_PRACTICE", _scene_nxtscn_continue_target_practice);
+ NXT_SCN_FUNCTION("SELECT_ROOKIE_SCENARIO", _scene_nxtscn_select_rookie_scenario);
+ NXT_SCN_FUNCTION("FINISH_GANG_FIGHT", _scene_nxtscn_finish_gang_fight);
+ NXT_SCN_FUNCTION("FINISH_WESTCOAST_SOUND", _scene_nxtscn_finish_westcoast_sound);
+ NXT_SCN_FUNCTION("FINISH_WAREHOUSE", _scene_nxtscn_finish_warehouse);
+ NXT_SCN_FUNCTION("INIT_RANDOM_WAREHOUSE", _scene_nxtscn_init_random_warehouse);
+ NXT_SCN_FUNCTION("CONTINUE_WAREHOUSE", _scene_nxtscn_continue_warehouse);
+ NXT_SCN_FUNCTION("SELECT_UNDERCOVER_SCENARIO", _scene_nxtscn_select_undercover_scenario);
+ NXT_SCN_FUNCTION("FINISH_DRUG_DEAL", _scene_nxtscn_finish_drug_deal);
+ NXT_SCN_FUNCTION("INIT_RANDOM_CAR_RING_LEADER", _scene_nxtscn_init_random_car_ring_leader);
+ NXT_SCN_FUNCTION("CONTINUE_CAR_RING_LEADER_1", _scene_nxtscn_continue_car_ring_leader_1);
+ NXT_SCN_FUNCTION("CONTINUE_CAR_RING_LEADER_2", _scene_nxtscn_continue_car_ring_leader_2);
+ NXT_SCN_FUNCTION("INIT_RANDOM_CAR_RING", _scene_nxtscn_init_random_car_ring);
+ NXT_SCN_FUNCTION("CONTINUE_CAR_RING", _scene_nxtscn_continue_car_ring);
+ NXT_SCN_FUNCTION("FINISH_CAR_RING", _scene_nxtscn_finish_car_ring);
+ NXT_SCN_FUNCTION("FINISH_BAR", _scene_nxtscn_finish_bar);
+ NXT_SCN_FUNCTION("FINISH_BANK", _scene_nxtscn_finish_bank);
+ NXT_SCN_FUNCTION("FINISH_CRACK_HOUSE", _scene_nxtscn_finish_crack_house);
+ NXT_SCN_FUNCTION("FINISH_METH_LAB", _scene_nxtscn_finish_meth_lab);
+ NXT_SCN_FUNCTION("FINISH_AIRPLANE", _scene_nxtscn_finish_airplane);
+ NXT_SCN_FUNCTION("FINISH_AIRPORT", _scene_nxtscn_finish_airport);
+ NXT_SCN_FUNCTION("FINISH_NUKE_TRANSPORT", _scene_nxtscn_finish_nuke_transport);
+ NXT_SCN_FUNCTION("INIT_RANDOM_BAR", _scene_nxtscn_init_random_bar);
+ NXT_SCN_FUNCTION("CONTINUE_BAR", _scene_nxtscn_continue_bar);
+ NXT_SCN_FUNCTION("SELECT_SWAT_SCENARIO", _scene_nxtscn_select_swat_scenario);
+ NXT_SCN_FUNCTION("INIT_RANDOM_BANK", _scene_nxtscn_init_random_bank);
+ NXT_SCN_FUNCTION("CONTINUE_BANK", _scene_nxtscn_continue_bank);
+ NXT_SCN_FUNCTION("INIT_RANDOM_METH_LAB", _scene_nxtscn_init_random_meth_lab);
+ NXT_SCN_FUNCTION("CONTINUE_METH_LAB", _scene_nxtscn_continue_meth_lab);
+ NXT_SCN_FUNCTION("SELECT_DELTA_SCENARIO", _scene_nxtscn_select_delta_scenario);
+ NXT_SCN_FUNCTION("PICK_RANDOM_RAPPELLER", _scene_nxtscn_pick_random_rapeller);
+ NXT_SCN_FUNCTION("INIT_RANDOM_AIRPLANE", _scene_nxtscn_init_random_airplane);
+ NXT_SCN_FUNCTION("CONTINUE_AIRPLANE", _scene_nxtscn_continue_airplane);
+ NXT_SCN_FUNCTION("PICK_RANDOM_AIRPLANE_FRONT", _scene_nxtscn_pick_random_airplane_front);
+ NXT_SCN_FUNCTION("INIT_RANDOM_AIRPORT", _scene_nxtscn_init_random_airport);
+ NXT_SCN_FUNCTION("CONTINUE_AIRPORT", _scene_nxtscn_continue_airport);
+ NXT_SCN_FUNCTION("INIT_RANDOM_NUKE_TRANSPORT", _scene_nxtscn_init_random_nuke_transport);
+ NXT_SCN_FUNCTION("CONTINUE_NUKE_TRANSPORT", _scene_nxtscn_continue_nuke_transport);
+ NXT_SCN_FUNCTION("INIT_RANDOM_POWERPLANT", _scene_nxtscn_init_random_powerplant);
+ NXT_SCN_FUNCTION("CONTINUE_POWERPLANT", _scene_nxtscn_continue_powerplant);
+#undef NXT_SCN_FUNCTION
+
+ _sceneShowMsg["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::_scene_sm_donothing);
+ _sceneWepDwn["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::_scene_default_wepdwn);
+ _sceneScnScr["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::_scene_default_score);
+ _sceneNxtFrm["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::_scene_nxtfrm);
+}
+
+void GameCrimePatrol::verifyScriptFunctions() {
+ Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
+ for (size_t i = 0; i < scenes->size(); i++) {
+ Scene *scene = (*scenes)[i];
+ getScriptFunctionScene(PREOP, scene->preop);
+ getScriptFunctionScene(SHOWMSG, scene->scnmsg);
+ getScriptFunctionScene(INSOP, scene->insop);
+ getScriptFunctionScene(WEPDWN, scene->wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->scnscr);
+ getScriptFunctionScene(NXTFRM, scene->nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->nxtscn);
+ for (size_t j = 0; j < scene->zones.size(); j++) {
+ Zone *zone = scene->zones[j];
+ for (size_t k = 0; k < zone->rects.size(); k++) {
+ getScriptFunctionRectHit(zone->rects[k].rectHit);
+ }
+ }
+ }
+}
+
+CPScriptFunctionRect GameCrimePatrol::getScriptFunctionRectHit(Common::String name) {
+ CPScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ if (it != _rectHitFuncs.end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find rectHit function: %s", name.c_str());
+ }
+}
+
+CPScriptFunctionScene GameCrimePatrol::getScriptFunctionScene(SceneFuncType type, Common::String name) {
+ CPScriptFunctionSceneMap *functionMap;
+ switch (type) {
+ case PREOP:
+ functionMap = &_scenePreOps;
+ break;
+ case SHOWMSG:
+ functionMap = &_sceneShowMsg;
+ break;
+ case INSOP:
+ functionMap = &_sceneInsOps;
+ break;
+ case WEPDWN:
+ functionMap = &_sceneWepDwn;
+ break;
+ case SCNSCR:
+ functionMap = &_sceneScnScr;
+ break;
+ case NXTFRM:
+ functionMap = &_sceneNxtFrm;
+ break;
+ case NXTSCN:
+ functionMap = &_sceneNxtScn;
+ break;
+ default:
+ error("Unkown scene script type: %u", type);
+ break;
+ }
+ CPScriptFunctionSceneMap::iterator it;
+ it = functionMap->find(name);
+ if (it != functionMap->end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find scene type %u function: %s", type, name.c_str());
+ }
+}
+
+void GameCrimePatrol::callScriptFunctionRectHit(Common::String name, Rect *rect) {
+ CPScriptFunctionRect function = getScriptFunctionRectHit(name);
+ function(rect);
+}
+
+void GameCrimePatrol::callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene) {
+ CPScriptFunctionScene function = getScriptFunctionScene(type, name);
+ function(scene);
+}
+
+Common::Error GameCrimePatrol::run() {
+ init();
+ _NewGame();
+ _cur_scene = _startscene;
+ Common::String oldscene;
+ while (!_vm->shouldQuit()) {
+ oldscene = _cur_scene;
+ _SetFrame();
+ _fired = false;
+ Scene *scene = _sceneInfo->findScene(_cur_scene);
+ if (!loadScene(scene)) {
+ if (scene->nxtscn == "CONTINUE_TARGET_PRACTICE") {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ } else {
+ error("Cannot find scene %s in libfile", scene->name.c_str());
+ }
+ }
+ _sceneSkipped = false;
+ Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
+ g_system->getMixer()->stopHandle(_sceneAudioHandle);
+ g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ _paletteDirty = true;
+ _nextFrameTime = _GetMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->preop, scene);
+ _currentFrame = _GetFrame(scene);
+ while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
+ _UpdateMouse();
+ callScriptFunctionScene(SHOWMSG, scene->scnmsg, scene);
+ callScriptFunctionScene(INSOP, scene->insop, scene);
+ _holster = _WeaponDown();
+ if (_holster) {
+ callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ }
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ if (!_holster) {
+ Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ if (hitGlobalRect != nullptr) {
+ callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
+ } else {
+ if (_shots > 0) {
+ if (!_debug_unlimitedAmmo) {
+ _shots--;
+ }
+ _DisplayShotFiredImage(&firedCoords);
+ _DoShot();
+ Rect *hitRect = nullptr;
+ Zone *hitSceneZone = _CheckZonesV2(scene, hitRect, &firedCoords);
+ if (hitSceneZone != nullptr) {
+ callScriptFunctionRectHit(hitRect->rectHit, hitRect);
+ } else {
+ int8 skip = _SkipToNewScene(scene);
+ if (skip == -1) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ } else if (skip == 1) {
+ if (scene->dataParam4 > 0) {
+ uint32 framesToSkip = (scene->dataParam4 - _currentFrame) / _videoFrameSkip;
+ _videoDecoder->skipNumberOfFrames(framesToSkip);
+ } else {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ }
+ }
+ } else {
+ _PlaySound(_emptySound);
+ }
+ }
+ }
+ }
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ }
+ _DisplayLivesLeft();
+ _DisplayScores();
+ _DisplayShotsLeft();
+ _MoveMouse();
+ if (_pauseTime > 0) {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ } else {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ }
+ if (_videoDecoder->getCurrentFrame() == 0) {
+ _videoDecoder->getNextFrame();
+ }
+ int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ if (remainingMillis < 10) {
+ if (_videoDecoder->getCurrentFrame() > 0) {
+ _videoDecoder->getNextFrame();
+ }
+ remainingMillis = _nextFrameTime - _GetMsTime();
+ _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ }
+ if (remainingMillis > 0) {
+ if (remainingMillis > 15) {
+ remainingMillis = 15;
+ }
+ g_system->delayMillis(remainingMillis);
+ }
+ _currentFrame = _GetFrame(scene);
+ debug_drawPracticeRects();
+ updateScreen();
+ }
+ // frame limit reached or scene changed, prepare for next scene
+ _hadPause = false;
+ _pauseTime = 0;
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ if (_cur_scene == "") {
+ _vm->quitGame();
+ }
+ }
+ return Common::kNoError;
+}
+
+void GameCrimePatrol::_NewGame() {
+ _shots = 10;
+ _lives = 3;
+ _holster = false;
+}
+
+void GameCrimePatrol::_ResetParams() {
+ // fill _got_to with start scenes
+ // 0 in _got_to array means the level is finished
+ for (uint8 i = 0; i < 15; i++) {
+ _got_to[i] = _level_scenes[i][0];
+ }
+}
+
+void GameCrimePatrol::_DoMenu() {
+ uint32 startTime = _GetMsTime();
+ _RestoreCursor();
+ _DoCursor();
+ _inMenu = true;
+ _MoveMouse();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+ _ShowDifficulty(_difficulty, false);
+ while (_inMenu && !_vm->shouldQuit()) {
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ Rect *hitMenuRect = _CheckZone(_submenzone, &firedCoords);
+ if (hitMenuRect != nullptr) {
+ callScriptFunctionRectHit(hitMenuRect->rectHit, hitMenuRect);
+ }
+ }
+ if (_difficulty != _oldDifficulty) {
+ _ChangeDifficulty(_difficulty);
+ }
+ g_system->delayMillis(15);
+ updateScreen();
+ }
+ _RestoreCursor();
+ _DoCursor();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ if (_hadPause) {
+ unsigned long endTime = _GetMsTime();
+ unsigned long timeDiff = endTime - startTime;
+ _pauseTime += timeDiff;
+ _nextFrameTime += timeDiff;
+ }
+}
+
+void GameCrimePatrol::_ChangeDifficulty(uint8 newDifficulty) {
+ if (newDifficulty == _oldDifficulty) {
+ return;
+ }
+ _ShowDifficulty(newDifficulty, true);
+ _oldDifficulty = newDifficulty;
+ _difficulty = newDifficulty;
+}
+
+void GameCrimePatrol::_ShowDifficulty(uint8 newDifficulty, bool updateCursor) {
+ // reset menu screen
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+ uint16 posY = 0x45 + ((newDifficulty - 1) * 0x21);
+ AlgGraphics::drawImageCentered(_screen, &_difficultyIcon, 0x0115, posY);
+ if (updateCursor) {
+ _DoCursor();
+ }
+}
+
+void GameCrimePatrol::_DoCursor() {
+ _UpdateMouse();
+}
+
+void GameCrimePatrol::_UpdateMouse() {
+ if (_oldWhichGun != _whichGun) {
+ Graphics::PixelFormat pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
+ Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ CursorMan.popAllCursors();
+ uint16 hotspotX = (cursor->w / 2) + 3;
+ uint16 hotspotY = (cursor->h / 2) + 3;
+ if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
+ cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
+ cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
+ }
+ CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0, false, &pixelFormat);
+ CursorMan.showMouse(true);
+ _oldWhichGun = _whichGun;
+ }
+}
+
+void GameCrimePatrol::_MoveMouse() {
+ if (_inMenu) {
+ _whichGun = 3; // in menu cursor
+ } else {
+ // disabled for now, because glitchy
+ /*
+ uint16 x = _mousePos.x;
+ uint16 y = _mousePos.y;
+ if (x < 13) {x = 13;}
+ if (x > 286) {x = 286;}
+ if (y < 3) {y = 3;}
+ if (y > 166) {y = 166;}
+ if (_mousePos.x != x || _mousePos.y != y) {
+ _mousePos.x = x;
+ _mousePos.y = y;
+ g_system->warpMouse(x, y);
+ }
+ */
+ if (_mousePos.y >= 0xA3 && _mousePos.x >= 0xF0) {
+ _whichGun = 1; // holster
+ } else if (_mousePos.y >= 0xA3 && _mousePos.x <= 0x43) {
+ _whichGun = 2; // menu button cursor
+ } else {
+ _whichGun = 0; // regular gun
+ }
+ }
+ _UpdateMouse();
+}
+
+void GameCrimePatrol::_DisplayLivesLeft() {
+ if (_lives == _oldLives) {
+ return;
+ }
+ int posY = 0x67;
+ for (uint8 i = 0; i < 3; i++) {
+ AlgGraphics::drawImage(_screen, &_deadIcon, 0x12F, posY);
+ posY += 0xE;
+ }
+ posY = 0x67;
+ for (uint8 i = 0; i < _lives; i++) {
+ AlgGraphics::drawImage(_screen, &_liveIcon, 0x12F, posY);
+ posY += 0xE;
+ }
+ _oldLives = _lives;
+}
+
+void GameCrimePatrol::_DisplayScores() {
+ if (_score == _oldScore) {
+ return;
+ }
+ Common::String scoreString = Common::String::format("%05d", _score);
+ int posX = 0x9B;
+ for (int i = 0; i < 5; i++) {
+ uint8 digit = scoreString[i] - '0';
+ AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xBF);
+ posX += 7;
+ }
+ _oldScore = _score;
+}
+
+void GameCrimePatrol::_DisplayShotsLeft() {
+ if (_shots == _oldShots) {
+ return;
+ }
+ uint16 posX = 0xEE;
+ for (uint8 i = 0; i < 10; i++) {
+ AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBE);
+ posX += 5;
+ }
+ posX = 0xEE;
+ for (uint8 i = 0; i < _shots; i++) {
+ AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBE);
+ posX += 5;
+ }
+ _oldShots = _shots;
+}
+
+bool GameCrimePatrol::_WeaponDown() {
+ if (_rightDown && _mousePos.y >= 0xAA && _mousePos.x >= 0x113) {
+ return true;
+ }
+ return false;
+}
+
+bool GameCrimePatrol::_SaveState() {
+ Common::OutSaveFile *outSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(outSaveFile = g_system->getSavefileManager()->openForSaving(saveFileName))) {
+ warning("Can't create file '%s', game not saved", saveFileName.c_str());
+ return false;
+ }
+ outSaveFile->writeUint32BE(MKTAG('A', 'L', 'G', 'S')); // header
+ outSaveFile->writeByte(0); // version, unused for now
+ outSaveFile->writeSByte(_stage);
+ for (uint8 i = 0; i < 15; i++) {
+ outSaveFile->writeUint16LE(_got_to[i]);
+ }
+ outSaveFile->writeSint32LE(_score);
+ outSaveFile->writeUint16LE(_shots);
+ outSaveFile->writeSByte(_lives);
+ outSaveFile->finalize();
+ delete outSaveFile;
+ return true;
+}
+
+bool GameCrimePatrol::_LoadState() {
+ Common::InSaveFile *inSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(inSaveFile = g_system->getSavefileManager()->openForLoading(saveFileName))) {
+ debug("Can't load file '%s', game not loaded", saveFileName.c_str());
+ return false;
+ }
+ uint32 header = inSaveFile->readUint32BE();
+ if (header != MKTAG('A', 'L', 'G', 'S')) {
+ warning("Unkown save file, header: %d", header);
+ return false;
+ }
+ inSaveFile->skip(1); // version, unused for now
+ _stage = inSaveFile->readSByte();
+ for (uint8 i = 0; i < 15; i++) {
+ _got_to[i] = inSaveFile->readUint16LE();
+ }
+ _score = inSaveFile->readSint32LE();
+ _shots = inSaveFile->readUint16LE();
+ _lives = inSaveFile->readSByte();
+ delete inSaveFile;
+ _gameInProgress = true;
+ _scene_nxtscn_generic(_stage);
+ return true;
+}
+
+// misc game functions
+void GameCrimePatrol::_DisplayShotFiredImage(Common::Point *point) {
+ if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
+ uint16 targetX = point->x - _videoPosX;
+ uint16 targetY = point->y - _videoPosY;
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ }
+}
+
+void GameCrimePatrol::_EnableVideoFadeIn() {
+ // TODO implement
+}
+
+uint16 GameCrimePatrol::_SceneToNumber(Scene *scene) {
+ return atoi(scene->name.substr(5).c_str());
+}
+
+uint16 GameCrimePatrol::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
+ if (max == 1) {
+ return 0;
+ }
+ // reset mask if full
+ uint16 fullMask = 0xFFFF >> (16 - max);
+ if (*mask == fullMask) {
+ *mask = 0;
+ }
+ uint16 random;
+ // find an unused random number
+ while (1) {
+ random = _rnd->getRandomNumber(max - 1);
+ // check if bit is already used
+ unsigned int bit = 1 << random;
+ if (!((*mask & bit) || random == exclude)) {
+ // set the bit in mask
+ *mask |= bit;
+ break;
+ }
+ }
+ return random;
+}
+
+uint16 GameCrimePatrol::_PickRandomScene(uint8 index, uint8 max) {
+ if (max != 0) {
+ _random_max = max;
+ _random_mask = 0;
+ _random_picked = -1;
+ _random_scene_count = 0;
+ while (_level_scenes[index][_random_scene_count] != 0) {
+ _random_scene_count++;
+ }
+ }
+ unsigned short count = _random_max--;
+ if (count > 0) {
+ _random_picked = _RandomUnusedInt(_random_scene_count, &_random_mask, _random_picked);
+ return _level_scenes[index][_random_picked];
+ }
+ return 0;
+}
+
+uint16 GameCrimePatrol::_PickDeathScene() {
+ if (_stage != _old_stage) {
+ _old_stage = _stage;
+ _death_mask = 0;
+ _death_picked = -1;
+ _death_scene_count = 0;
+ while (_died_scenes_by_stage[_stage][_death_scene_count] != 0) {
+ _death_scene_count++;
+ }
+ }
+ _death_picked = _RandomUnusedInt(_death_scene_count, &_death_mask, _death_picked);
+ return _died_scenes_by_stage[_stage][_death_picked];
+}
+
+void GameCrimePatrol::_scene_nxtscn_generic(uint8 index) {
+ uint16 nextSceneId = 0;
+ _got_to[index] = 0;
+ if (_got_to[0] || _got_to[1] || _got_to[3] || _got_to[2]) {
+ nextSceneId = _stage_start_scenes[0];
+ } else if (_got_to[4] || _got_to[5] || _got_to[6]) {
+ if (_stage == 1) {
+ nextSceneId = _stage_start_scenes[1];
+ } else {
+ _stage = 1;
+ nextSceneId = 0x50;
+ }
+ } else if (_got_to[7] || _got_to[8] || _got_to[9]) {
+ if (_stage == 2) {
+ nextSceneId = _stage_start_scenes[2];
+ } else {
+ _stage = 2;
+ nextSceneId = 0x81;
+ }
+ } else if (_got_to[10] || _got_to[11] || _got_to[12]) {
+ if (_stage == 3) {
+ nextSceneId = _stage_start_scenes[3];
+ } else {
+ _stage = 3;
+ nextSceneId = 0x014B;
+ }
+ } else if (_got_to[13]) {
+ _stage = 4;
+ nextSceneId = 0x018F;
+ } else {
+ nextSceneId = 0x21;
+ }
+ _cur_scene = Common::String::format("scene%d", nextSceneId);
+}
+
+void GameCrimePatrol::_rect_select_generic(uint8 index) {
+ if (_got_to[index] > 0) {
+ _cur_scene = Common::String::format("scene%d", _got_to[index]);
+ }
+}
+
+void GameCrimePatrol::_scene_iso_got_to_generic(uint8 index, uint16 sceneId) {
+ _got_to[index] = sceneId;
+}
+
+// Script functions: RectHit
+void GameCrimePatrol::_rect_shotmenu(Rect *rect) {
+ _DoMenu();
+}
+
+void GameCrimePatrol::_rect_save(Rect *rect) {
+ if(_SaveState()) {
+ _DoSaveSound();
+ }
+}
+
+void GameCrimePatrol::_rect_load(Rect *rect) {
+ if(_LoadState()) {
+ _DoLoadSound();
+ }
+}
+
+void GameCrimePatrol::_rect_continue(Rect *rect) {
+ _inMenu = false;
+ _fired = false;
+ if (_lives <= 0) {
+ _score = (int32)(_score * 0.7f);
+ uint16 returnScene = _stage_start_scenes[_stage];
+ _cur_scene = Common::String::format("scene%d", returnScene);
+ _NewGame();
+ }
+}
+
+void GameCrimePatrol::_rect_start(Rect *rect) {
+ _inMenu = false;
+ _fired = false;
+ _gameInProgress = true;
+ if (_isDemo) {
+ _cur_scene = "scene39";
+ _got_to[1] = 39;
+ } else {
+ _cur_scene = Common::String::format("scene%d", _stage_start_scenes[0]);
+ }
+ _ResetParams();
+ _NewGame();
+}
+
+void GameCrimePatrol::_rect_target_practice(Rect *rect) {
+ uint16 nextScene = 0;
+ Scene *scene = _sceneInfo->findScene(_cur_scene);
+ if (_level_scenes[0][0] == _SceneToNumber(scene)) {
+ _practice_mask = 0x1F;
+ }
+ if (_practice_mask == 0) {
+ _practice_mask = 0x1F;
+ }
+ for (uint8 i = 0; i < 5; i++) {
+ if (_mousePos.x <= _practice_target_left[i] || _mousePos.x >= _practice_target_right[i] ||
+ _mousePos.y <= _practice_target_top[i] || _mousePos.y >= _practice_target_bottom[i]) {
+ // did not hit target
+ continue;
+ }
+ uint8 mask = 1 << i;
+ if (!(_practice_mask & mask)) {
+ // target was already hit before
+ continue;
+ }
+ // did hit target
+ _score += scene->scnscrParam == 0 ? 50 : scene->scnscrParam;
+ _practice_mask ^= mask;
+ uint8 inverted = _practice_mask ^ 0x1F;
+ if (_practice_mask == 0) {
+ nextScene = 432;
+ } else {
+ nextScene = 401 + inverted;
+ }
+ break;
+ }
+ if (nextScene != 0) {
+ _cur_scene = Common::String::format("scene%d", nextScene);
+ }
+}
+
+void GameCrimePatrol::_rect_select_target_practice(Rect *rect) {
+ _rect_select_generic(0);
+ _got_to[0] = 0;
+}
+
+void GameCrimePatrol::_rect_select_gang_fight(Rect *rect) {
+ _got_to[0] = 0;
+ _rect_select_generic(1);
+}
+
+void GameCrimePatrol::_rect_select_warehouse(Rect *rect) {
+ _got_to[0] = 0;
+ _rect_select_generic(2);
+}
+
+void GameCrimePatrol::_rect_select_westcoast_sound(Rect *rect) {
+ _got_to[0] = 0;
+ _rect_select_generic(3);
+}
+
+void GameCrimePatrol::_rect_select_drug_deal(Rect *rect) {
+ _rect_select_generic(4);
+}
+void GameCrimePatrol::_rect_select_car_ring(Rect *rect) {
+ _rect_select_generic(5);
+}
+void GameCrimePatrol::_rect_select_bar(Rect *rect) {
+ _rect_select_generic(6);
+}
+void GameCrimePatrol::_rect_select_bank(Rect *rect) {
+ _rect_select_generic(7);
+}
+void GameCrimePatrol::_rect_select_crack_house(Rect *rect) {
+ _rect_select_generic(9);
+}
+
+void GameCrimePatrol::_rect_select_meth_lab(Rect *rect) {
+ _rect_select_generic(8);
+}
+
+void GameCrimePatrol::_rect_select_airplane(Rect *rect) {
+ _rect_select_generic(10);
+}
+
+void GameCrimePatrol::_rect_select_nuke_transport(Rect *rect) {
+ _rect_select_generic(11);
+}
+
+void GameCrimePatrol::_rect_select_airport(Rect *rect) {
+ _rect_select_generic(12);
+}
+
+void GameCrimePatrol::_rect_kill_innocent_man(Rect *rect) {
+}
+
+// Script functions: Scene PreOps
+void GameCrimePatrol::_scene_pso_warehouse_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(2, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_gang_fight_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(1, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_westcoast_sound_got_to(Scene *scene) {
+ _scene_iso_got_to_generic(3, 456);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_drug_deal_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(4, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_car_ring_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(5, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_bank_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(7, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_crack_house_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(9, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_meth_lab_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(8, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_airplane_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(10, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_airport_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(12, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_nuke_transport_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(11, sceneId);
+ _EnableVideoFadeIn();
+}
+
+void GameCrimePatrol::_scene_pso_power_plant_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _scene_iso_got_to_generic(13, sceneId);
+ _final_stage_scene = sceneId;
+ _EnableVideoFadeIn();
+}
+
+// Script functions: Scene NxtScn
+void GameCrimePatrol::_scene_nxtscn_lose_a_life(Scene *scene) {
+ uint16 picked = 0;
+ if (!_debug_godMode) {
+ _lives--;
+ }
+ if (_isDemo) {
+ _cur_scene = "scene39";
+ return;
+ } else if (_lives > 0) {
+ _DisplayLivesLeft();
+ picked = _PickDeathScene();
+ } else {
+ picked = _dead_scenes[_stage];
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_game_won(Scene *scene) {
+ _gameInProgress = false;
+ _cur_scene = _startscene;
+}
+
+void GameCrimePatrol::_scene_nxtscn_did_not_continue(Scene *scene) {
+ _gameInProgress = false;
+ _cur_scene = _startscene;
+}
+
+void GameCrimePatrol::_scene_nxtscn_kill_innocent_man(Scene *scene) {
+ uint16 picked = 0;
+ if (!_debug_godMode) {
+ _lives--;
+ }
+ if (_lives > 0) {
+ picked = _stage_start_scenes[_stage];
+ } else {
+ picked = _dead_scenes[_stage];
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_kill_innocent_woman(Scene *scene) {
+ uint16 picked = 0;
+ if (!_debug_godMode) {
+ _lives--;
+ }
+ if (_lives > 0) {
+ picked = _stage_start_scenes[_stage];
+ } else {
+ picked = _dead_scenes[_stage];
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_after_die(Scene *scene) {
+ uint16 picked = _stage_start_scenes[_stage];
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_select_language_1(Scene *scene) {
+ // do nothing
+}
+
+void GameCrimePatrol::_scene_nxtscn_select_language_2(Scene *scene) {
+ // do nothing
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_target_practice(Scene *scene) {
+ uint16 picked = _PickRandomScene(14, 6);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_target_practice(Scene *scene) {
+ uint16 picked = _PickRandomScene(14, 0);
+ if (picked == 0) {
+ _scene_iso_got_to_generic(0, 1);
+ _scene_nxtscn_generic(0);
+ } else {
+ _cur_scene = Common::String::format("scene%d", picked);
+ }
+}
+
+void GameCrimePatrol::_scene_nxtscn_select_rookie_scenario(Scene *scene) {
+ uint16 picked = 0;
+ if (_got_to[0] > 0) {
+ picked = _got_to[0];
+ _got_to[0] = 0;
+ } else if (_got_to[3] > 0) {
+ picked = _got_to[3];
+ } else if (_got_to[1] > 0) {
+ picked = _got_to[1];
+ } else if (_got_to[2] > 0) {
+ picked = _got_to[2];
+ } else {
+ picked = _stage_start_scenes[1];
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_select_undercover_scenario(Scene *scene) {
+ uint16 picked = 0;
+ if (_got_to[4] > 0) {
+ picked = _got_to[4];
+ } else if (_got_to[5] > 0) {
+ picked = _got_to[5];
+ } else if (_got_to[6] > 0) {
+ picked = _got_to[6];
+ } else {
+ picked = _stage_start_scenes[2];
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_select_swat_scenario(Scene *scene) {
+ uint16 picked = 0;
+ if (_got_to[8] > 0) {
+ picked = _got_to[8];
+ } else if (_got_to[7] > 0) {
+ picked = _got_to[7];
+ } else if (_got_to[9] > 0) {
+ picked = _got_to[9];
+ } else {
+ picked = _stage_start_scenes[3];
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_select_delta_scenario(Scene *scene) {
+ uint16 picked = 0;
+ if (_got_to[10] > 0) {
+ picked = _got_to[10];
+ } else if (_got_to[11] > 0) {
+ picked = _got_to[11];
+ } else if (_got_to[12] > 0) {
+ picked = _got_to[12];
+ } else {
+ picked = _final_stage_scene;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_gang_fight(Scene *scene) {
+ if (_isDemo) {
+ _cur_scene = _startscene;
+ return;
+ }
+ _scene_nxtscn_generic(1);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_westcoast_sound(Scene *scene) {
+ _scene_nxtscn_generic(3);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_warehouse(Scene *scene) {
+ _scene_nxtscn_generic(2);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_warehouse(Scene *scene) {
+ uint16 picked = _PickRandomScene(15, (_difficulty * 2) + 5);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_warehouse(Scene *scene) {
+ uint16 picked = _PickRandomScene(15, 0);
+ if (picked == 0) {
+ picked = 0x43;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_drug_deal(Scene *scene) {
+ _scene_nxtscn_generic(4);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_car_ring_leader(Scene *scene) {
+ uint16 picked = _PickRandomScene(16, 2);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_car_ring_leader_1(Scene *scene) {
+ uint16 picked = _PickRandomScene(16, 0);
+ if (picked == 0) {
+ picked = 0x67;
+ } else {
+ picked = 0x63;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_car_ring_leader_2(Scene *scene) {
+ uint16 picked = _PickRandomScene(16, 0);
+ if (picked == 0) {
+ picked = 0x67;
+ } else {
+ picked = 0x66;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_car_ring(Scene *scene) {
+ uint16 picked = _PickRandomScene(17, (_difficulty * 2) + 8);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_car_ring(Scene *scene) {
+ uint16 picked = _PickRandomScene(17, 0);
+ if (picked == 0) {
+ picked = 0x74;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_car_ring(Scene *scene) {
+ _scene_nxtscn_generic(5);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_bar(Scene *scene) {
+ _scene_nxtscn_generic(6);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_bank(Scene *scene) {
+ _scene_nxtscn_generic(7);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_crack_house(Scene *scene) {
+ _scene_nxtscn_generic(9);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_meth_lab(Scene *scene) {
+ _scene_nxtscn_generic(8);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_airplane(Scene *scene) {
+ _scene_nxtscn_generic(10);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_airport(Scene *scene) {
+ _scene_nxtscn_generic(12);
+}
+
+void GameCrimePatrol::_scene_nxtscn_finish_nuke_transport(Scene *scene) {
+ _scene_nxtscn_generic(11);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_bar(Scene *scene) {
+ uint16 picked = _PickRandomScene(18, (_difficulty * 2) + 9);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_bar(Scene *scene) {
+ uint16 picked = _PickRandomScene(18, 0);
+ if (picked == 0) {
+ picked = 0x92;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_bank(Scene *scene) {
+ uint16 picked = _PickRandomScene(19, (_difficulty * 2) + 8);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_bank(Scene *scene) {
+ uint16 picked = _PickRandomScene(19, 0);
+ if (picked == 0) {
+ picked = 0xA8;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_meth_lab(Scene *scene) {
+ uint16 picked = _PickRandomScene(20, (_difficulty * 2) + 8);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_meth_lab(Scene *scene) {
+ uint16 picked = _PickRandomScene(20, 0);
+ if (picked == 0) {
+ picked = 0xD0;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_pick_random_rapeller(Scene *scene) {
+ uint16 picked = _PickRandomScene(21, 1);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_airplane(Scene *scene) {
+ uint16 picked = _PickRandomScene(22, (_difficulty * 2) + 8);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_airplane(Scene *scene) {
+ uint16 picked = _PickRandomScene(22, 0);
+ if (picked == 0) {
+ picked = 0x108;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_pick_random_airplane_front(Scene *scene) {
+ uint16 picked = _PickRandomScene(23, 1);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_airport(Scene *scene) {
+ uint16 picked = _PickRandomScene(24, (_difficulty * 2) + 8);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_airport(Scene *scene) {
+ uint16 picked = _PickRandomScene(24, 0);
+ if (picked == 0) {
+ picked = 0x12D;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_nuke_transport(Scene *scene) {
+ uint16 picked = _PickRandomScene(25, (_difficulty * 2) + 8);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_nuke_transport(Scene *scene) {
+ uint16 picked = _PickRandomScene(25, 0);
+ if (picked == 0) {
+ picked = 0x147;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_init_random_powerplant(Scene *scene) {
+ uint16 picked = _PickRandomScene(26, (_difficulty * 2) + 8);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameCrimePatrol::_scene_nxtscn_continue_powerplant(Scene *scene) {
+ uint16 picked = _PickRandomScene(26, 0);
+ if (picked == 0) {
+ picked = 0x169;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+// Script functions: WepDwn
+void GameCrimePatrol::_scene_default_wepdwn(Scene *scene) {
+ _shots = 10;
+}
+
+// Debug methods
+void GameCrimePatrol::debug_warpTo(int val) {
+ // TODO implement
+}
+
+void GameCrimePatrol::debug_drawPracticeRects() {
+ if (_debug_drawRects || debugChannelSet(1, Alg::kAlgDebugGraphics)) {
+ Scene *scene = _sceneInfo->findScene(_cur_scene);
+ if (scene->zones.size() > 0) {
+ if (scene->zones[0]->name == "zone283") {
+ for (uint8 i = 0; i < 5; i++) {
+ uint16 left = _practice_target_left[i] - _videoPosX;
+ uint16 right = _practice_target_right[i] - _videoPosX;
+ uint16 top = _practice_target_top[i] - _videoPosY;
+ uint16 bottom = _practice_target_bottom[i] - _videoPosY;
+ _videoDecoder->getVideoFrame()->drawLine(left, top, right, top, 1);
+ _videoDecoder->getVideoFrame()->drawLine(left, top, left, bottom, 1);
+ _videoDecoder->getVideoFrame()->drawLine(right, bottom, right, top, 1);
+ _videoDecoder->getVideoFrame()->drawLine(right, bottom, left, bottom, 1);
+ }
+ }
+ }
+ }
+}
+
+// Debugger methods
+DebuggerCrimePatrol::DebuggerCrimePatrol(GameCrimePatrol *game) : GUI::Debugger() {
+ _game = game;
+ registerVar("drawRects", &game->_debug_drawRects);
+ registerVar("godMode", &game->_debug_godMode);
+ registerVar("unlimitedAmmo", &game->_debug_unlimitedAmmo);
+ registerCmd("warpTo", WRAP_METHOD(DebuggerCrimePatrol, cmdWarpTo));
+ registerCmd("dumpLib", WRAP_METHOD(DebuggerCrimePatrol, cmdDumpLib));
+}
+
+bool DebuggerCrimePatrol::cmdWarpTo(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: warp <int>");
+ return true;
+ } else {
+ int val = atoi(argv[1]);
+ _game->debug_warpTo(val);
+ return false;
+ }
+}
+
+bool DebuggerCrimePatrol::cmdDumpLib(int argc, const char **argv) {
+ return _game->debug_dumpLibFile();
+}
+
+} // End of namespace Alg
diff --git a/engines/alg/game_crimepatrol.h b/engines/alg/game_crimepatrol.h
new file mode 100644
index 00000000000..a85389cc3b8
--- /dev/null
+++ b/engines/alg/game_crimepatrol.h
@@ -0,0 +1,282 @@
+/* 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 ALG_GAME_CRIMEPATROL_H
+#define ALG_GAME_CRIMEPATROL_H
+
+#include "common/hashmap.h"
+#include "common/rect.h"
+
+#include "gui/debugger.h"
+
+#include "alg/game.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+typedef Common::Functor1Mem<Scene *, void, GameCrimePatrol> CPScriptFunctionScene;
+typedef Common::Functor1Mem<Rect *, void, GameCrimePatrol> CPScriptFunctionRect;
+typedef Common::HashMap<Common::String, CPScriptFunctionScene *> CPScriptFunctionSceneMap;
+typedef Common::HashMap<Common::String, CPScriptFunctionRect *> CPScriptFunctionRectMap;
+
+class GameCrimePatrol : public Game {
+
+ enum SceneFuncType {
+ PREOP = 1,
+ SHOWMSG = 2,
+ INSOP = 3,
+ WEPDWN = 4,
+ SCNSCR = 5,
+ NXTFRM = 6,
+ NXTSCN = 7
+ };
+
+public:
+ GameCrimePatrol(AlgEngine *vm, const ADGameDescription *desc);
+ ~GameCrimePatrol();
+ Common::Error run();
+ void debug_warpTo(int val);
+
+private:
+ void init();
+ void registerScriptFunctions();
+ void verifyScriptFunctions();
+ CPScriptFunctionRect getScriptFunctionRectHit(Common::String name);
+ CPScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
+ void callScriptFunctionRectHit(Common::String name, Rect *rect);
+ void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
+
+ CPScriptFunctionRectMap _rectHitFuncs;
+ CPScriptFunctionSceneMap _scenePreOps;
+ CPScriptFunctionSceneMap _sceneShowMsg;
+ CPScriptFunctionSceneMap _sceneInsOps;
+ CPScriptFunctionSceneMap _sceneWepDwn;
+ CPScriptFunctionSceneMap _sceneScnScr;
+ CPScriptFunctionSceneMap _sceneNxtFrm;
+ CPScriptFunctionSceneMap _sceneNxtScn;
+
+ // images
+ Graphics::Surface _shotIcon;
+ Graphics::Surface _emptyIcon;
+ Graphics::Surface _liveIcon;
+ Graphics::Surface _deadIcon;
+ Graphics::Surface _difficultyIcon;
+ Graphics::Surface _bulletholeIcon;
+
+ // constants
+ const int16 _scenes_level0[2] = {0x0191, 0};
+ const int16 _scenes_level1[3] = {0x27, 0x01B7, 0};
+ const int16 _scenes_level2[4] = {0x33, 0x01C7, 0x01B8, 0};
+ const int16 _scenes_level3[3] = {0x48, 0x01C8, 0};
+ const int16 _scenes_level4[2] = {0x53, 0};
+ const int16 _scenes_level5[2] = {0x60, 0};
+ const int16 _scenes_level6[2] = {0x82, 0};
+ const int16 _scenes_level7[2] = {0x9B, 0};
+ const int16 _scenes_level8[2] = {0xC7, 0};
+ const int16 _scenes_level9[2] = {0xB6, 0};
+ const int16 _scenes_level10[6] = {0xE0, 0x01BF, 0x01C0, 0x01C1, 0x01C2, 0};
+ const int16 _scenes_level11[3] = {0x0136, 0x01C3, 0};
+ const int16 _scenes_level12[4] = {0x0119, 0x01C5, 0x0131, 0};
+ const int16 _scenes_level13[2] = {0x014C, 0};
+ const int16 _scenes_level14[13] = {0x01B1, 0x01B2, 0x01B3, 0x01B4, 0x01B5, 0x01B6, 0};
+ const int16 _scenes_level15[5] = {0x3B, 0x3C, 0x3F, 0x41, 0};
+ const int16 _scenes_level16[3] = {0x61, 0x65, 0};
+ const int16 _scenes_level17[7] = {0x68, 0x6A, 0x6C, 0x6E, 0x70, 0x72, 0};
+ const int16 _scenes_level18[8] = {0x83, 0x85, 0x87, 0x8A, 0x8C, 0x8F, 0x90, 0};
+ const int16 _scenes_level19[7] = {0x9C, 0x9E, 0xA0, 0xA2, 0xA4, 0xA6, 0};
+ const int16 _scenes_level20[5] = {0xC8, 0xCA, 0xCC, 0xCE, 0};
+ const int16 _scenes_level21[3] = {0xE8, 0xE9, 0};
+ const int16 _scenes_level22[11] = {0xF4, 0xF6, 0xF8, 0xFA, 0xFC, 0xFE, 0x0100, 0x0102, 0x0104, 0x0106, 0};
+ const int16 _scenes_level23[3] = {0x010E, 0x0113, 0};
+ const int16 _scenes_level24[8] = {0x011D, 0x011F, 0x0121, 0x0123, 0x0125, 0x0127, 0x0129, 0};
+ const int16 _scenes_level25[6] = {0x013D, 0x013F, 0x0141, 0x0143, 0x0145, 0};
+ const int16 _scenes_level26[10] = {0x0157, 0x0159, 0x015B, 0x015D, 0x015F, 0x0161, 0x0163, 0x0165, 0x0167, 0};
+
+ const int16 *_level_scenes[27] = {_scenes_level0, _scenes_level1, _scenes_level2, _scenes_level3, _scenes_level4, _scenes_level5, _scenes_level6,
+ _scenes_level7, _scenes_level8, _scenes_level9, _scenes_level10, _scenes_level11, _scenes_level12, _scenes_level13,
+ _scenes_level14, _scenes_level15, _scenes_level16, _scenes_level17, _scenes_level18, _scenes_level19, _scenes_level20,
+ _scenes_level21, _scenes_level22, _scenes_level23, _scenes_level24, _scenes_level25, _scenes_level26};
+
+ const int16 _died_scenes_stage0[5] = {0x30, 0x31, 0x47, 0x51, 0};
+ const int16 _died_scenes_stage1[7] = {0x5E, 0x5F, 0x7E, 0x7F, 0x98, 0x99, 0};
+ const int16 _died_scenes_stage2[4] = {0xB2, 0xC5, 0xDB, 0};
+ const int16 _died_scenes_stage3[7] = {0x0115, 0x0116, 0x0135, 0x014A, 0x0175, 0x0190, 0};
+ const int16 _died_scenes_stage4[7] = {0x0115, 0x0116, 0x0135, 0x014A, 0x0175, 0x0190, 0};
+
+ const int16 *_died_scenes_by_stage[5] = {_died_scenes_stage0, _died_scenes_stage1, _died_scenes_stage2, _died_scenes_stage3, _died_scenes_stage4};
+
+ const uint16 _dead_scenes[5] = {0x32, 0x80, 0xDC, 0x018D, 0x018D};
+
+ const uint16 _stage_start_scenes[5] = {0x26, 0x52, 0x9A, 0xDF, 0x014C};
+
+ const int16 _practice_target_left[5] = {0xE1, 0x45, 0xA8, 0x73, 0xE1};
+ const int16 _practice_target_top[5] = {0x0A, 0x3E, 0x41, 0x6E, 0x6E};
+ const int16 _practice_target_right[5] = {0x0104, 0x6D, 0xCB, 0x95, 0x0104};
+ const int16 _practice_target_bottom[5] = {0x3D, 0x79, 0x7B, 0xA1, 0xA1};
+
+ bool _isDemo = 0;
+
+ // gamestate
+ uint16 _got_to[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ int8 _stage = 0;
+ int8 _old_stage = -1;
+ uint8 _random_scene_count = 0;
+ uint8 _random_max = 0;
+ uint16 _random_mask = 0;
+ uint16 _random_picked = 0;
+ uint16 _death_mask = 0;
+ int16 _death_picked = 0;
+ uint8 _death_scene_count = 0;
+ uint8 _practice_mask = 0;
+ uint16 _final_stage_scene = _stage_start_scenes[4];
+
+ // base functions
+ void _NewGame();
+ void _ResetParams();
+ void _DoMenu();
+ void _ChangeDifficulty(uint8 newDifficulty);
+ void _ShowDifficulty(uint8 newDifficulty, bool updateCursor);
+ void _DoCursor();
+ void _UpdateMouse();
+ void _MoveMouse();
+ void _DisplayLivesLeft();
+ void _DisplayScores();
+ void _DisplayShotsLeft();
+ bool _WeaponDown();
+ bool _SaveState();
+ bool _LoadState();
+
+ // misc game functions
+ void _DisplayShotFiredImage(Common::Point *point);
+ void _EnableVideoFadeIn();
+ uint16 _SceneToNumber(Scene *scene);
+ uint16 _RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
+ uint16 _PickRandomScene(uint8 index, uint8 max);
+ uint16 _PickDeathScene();
+ void _scene_nxtscn_generic(uint8 index);
+ void _rect_select_generic(uint8 index);
+ void _scene_iso_got_to_generic(uint8 index, uint16 sceneId);
+
+ // Script functions: RectHit
+ void _rect_shotmenu(Rect *rect);
+ void _rect_save(Rect *rect);
+ void _rect_load(Rect *rect);
+ void _rect_continue(Rect *rect);
+ void _rect_start(Rect *rect);
+ void _rect_target_practice(Rect *rect);
+ void _rect_select_target_practice(Rect *rect);
+ void _rect_select_gang_fight(Rect *rect);
+ void _rect_select_warehouse(Rect *rect);
+ void _rect_select_westcoast_sound(Rect *rect);
+ void _rect_select_drug_deal(Rect *rect);
+ void _rect_select_car_ring(Rect *rect);
+ void _rect_select_bar(Rect *rect);
+ void _rect_select_bank(Rect *rect);
+ void _rect_select_crack_house(Rect *rect);
+ void _rect_select_meth_lab(Rect *rect);
+ void _rect_select_airplane(Rect *rect);
+ void _rect_select_nuke_transport(Rect *rect);
+ void _rect_select_airport(Rect *rect);
+ void _rect_kill_innocent_man(Rect *rect);
+
+ // Script functions: Scene PreOps
+ void _scene_pso_warehouse_got_to(Scene *scene);
+ void _scene_pso_gang_fight_got_to(Scene *scene);
+ void _scene_pso_westcoast_sound_got_to(Scene *scene);
+ void _scene_pso_drug_deal_got_to(Scene *scene);
+ void _scene_pso_car_ring_got_to(Scene *scene);
+ void _scene_pso_bank_got_to(Scene *scene);
+ void _scene_pso_crack_house_got_to(Scene *scene);
+ void _scene_pso_meth_lab_got_to(Scene *scene);
+ void _scene_pso_airplane_got_to(Scene *scene);
+ void _scene_pso_airport_got_to(Scene *scene);
+ void _scene_pso_nuke_transport_got_to(Scene *scene);
+ void _scene_pso_power_plant_got_to(Scene *scene);
+
+ // Script functions: Scene NxtScn
+ void _scene_nxtscn_game_won(Scene *scene);
+ void _scene_nxtscn_lose_a_life(Scene *scene);
+ void _scene_nxtscn_did_not_continue(Scene *scene);
+ void _scene_nxtscn_kill_innocent_man(Scene *scene);
+ void _scene_nxtscn_kill_innocent_woman(Scene *scene);
+ void _scene_nxtscn_after_die(Scene *scene);
+ void _scene_nxtscn_select_language_1(Scene *scene);
+ void _scene_nxtscn_select_language_2(Scene *scene);
+ void _scene_nxtscn_select_rookie_scenario(Scene *scene);
+ void _scene_nxtscn_select_undercover_scenario(Scene *scene);
+ void _scene_nxtscn_select_swat_scenario(Scene *scene);
+ void _scene_nxtscn_select_delta_scenario(Scene *scene);
+ void _scene_nxtscn_init_random_target_practice(Scene *scene);
+ void _scene_nxtscn_continue_target_practice(Scene *scene);
+ void _scene_nxtscn_finish_gang_fight(Scene *scene);
+ void _scene_nxtscn_finish_westcoast_sound(Scene *scene);
+ void _scene_nxtscn_finish_warehouse(Scene *scene);
+ void _scene_nxtscn_init_random_warehouse(Scene *scene);
+ void _scene_nxtscn_continue_warehouse(Scene *scene);
+ void _scene_nxtscn_finish_drug_deal(Scene *scene);
+ void _scene_nxtscn_init_random_car_ring_leader(Scene *scene);
+ void _scene_nxtscn_continue_car_ring_leader_1(Scene *scene);
+ void _scene_nxtscn_continue_car_ring_leader_2(Scene *scene);
+ void _scene_nxtscn_init_random_car_ring(Scene *scene);
+ void _scene_nxtscn_continue_car_ring(Scene *scene);
+ void _scene_nxtscn_finish_car_ring(Scene *scene);
+ void _scene_nxtscn_finish_bar(Scene *scene);
+ void _scene_nxtscn_finish_bank(Scene *scene);
+ void _scene_nxtscn_finish_crack_house(Scene *scene);
+ void _scene_nxtscn_finish_meth_lab(Scene *scene);
+ void _scene_nxtscn_finish_airplane(Scene *scene);
+ void _scene_nxtscn_finish_airport(Scene *scene);
+ void _scene_nxtscn_finish_nuke_transport(Scene *scene);
+ void _scene_nxtscn_init_random_bar(Scene *scene);
+ void _scene_nxtscn_continue_bar(Scene *scene);
+ void _scene_nxtscn_init_random_bank(Scene *scene);
+ void _scene_nxtscn_continue_bank(Scene *scene);
+ void _scene_nxtscn_init_random_meth_lab(Scene *scene);
+ void _scene_nxtscn_continue_meth_lab(Scene *scene);
+ void _scene_nxtscn_pick_random_rapeller(Scene *scene);
+ void _scene_nxtscn_init_random_airplane(Scene *scene);
+ void _scene_nxtscn_continue_airplane(Scene *scene);
+ void _scene_nxtscn_pick_random_airplane_front(Scene *scene);
+ void _scene_nxtscn_init_random_airport(Scene *scene);
+ void _scene_nxtscn_continue_airport(Scene *scene);
+ void _scene_nxtscn_init_random_nuke_transport(Scene *scene);
+ void _scene_nxtscn_continue_nuke_transport(Scene *scene);
+ void _scene_nxtscn_init_random_powerplant(Scene *scene);
+ void _scene_nxtscn_continue_powerplant(Scene *scene);
+
+ // Script functions: Scene WepDwn
+ void _scene_default_wepdwn(Scene *scene);
+ void debug_drawPracticeRects();
+};
+
+class DebuggerCrimePatrol : public GUI::Debugger {
+public:
+ DebuggerCrimePatrol(GameCrimePatrol *game);
+ bool cmdWarpTo(int argc, const char **argv);
+ bool cmdDumpLib(int argc, const char **argv);
+
+private:
+ GameCrimePatrol *_game;
+};
+
+} // End of namespace Alg
+
+#endif
diff --git a/engines/alg/game_drugwars.cpp b/engines/alg/game_drugwars.cpp
new file mode 100644
index 00000000000..da78a0044b2
--- /dev/null
+++ b/engines/alg/game_drugwars.cpp
@@ -0,0 +1,1029 @@
+/* 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/debug.h"
+#include "common/rect.h"
+#include "common/savefile.h"
+#include "common/system.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/pixelformat.h"
+
+#include "alg/game_drugwars.h"
+#include "alg/graphics.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+GameDrugWars::GameDrugWars(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
+ if (scumm_stricmp(desc->gameId, "dwarss") == 0) {
+ _libFileName = "dwss.lib";
+ } else if (scumm_stricmp(desc->gameId, "dwarsd") == 0) {
+ _libFileName = "dwds.lib";
+ } else if (scumm_stricmp(desc->gameId, "dwarsdemo") == 0) {
+ _libFileName = "dwdemo.lib";
+ _isDemo = true;
+ }
+}
+
+GameDrugWars::~GameDrugWars() {
+}
+
+void GameDrugWars::init() {
+ _videoPosX = 11;
+ _videoPosY = 2;
+
+ loadLibArchive(_libFileName);
+ _sceneInfo->loadScnFile("dw.scn");
+ _startscene = _sceneInfo->getStartScene();
+
+ registerScriptFunctions();
+ verifyScriptFunctions();
+
+ _menuzone = new Zone();
+ _menuzone->name = "MainMenu";
+ _menuzone->ptrfb = "GLOBALHIT";
+
+ _menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
+
+ _submenzone = new Zone();
+ _submenzone->name = "SubMenu";
+ _submenzone->ptrfb = "GLOBALHIT";
+
+ _submenzone->addRect(0x1C, 0x13, 0x5D, 0x22, nullptr, 0, "STARTMENU", "0");
+ _submenzone->addRect(0x1C, 0x33, 0x5D, 0x42, nullptr, 0, "RECTLOAD", "0");
+ _submenzone->addRect(0x1C, 0x53, 0x5D, 0x62, nullptr, 0, "RECTSAVE", "0");
+ _submenzone->addRect(0x1C, 0x73, 0x5D, 0x82, nullptr, 0, "CONTMENU", "0");
+ _submenzone->addRect(0x1C, 0x93, 0x5D, 0xA2, nullptr, 0, "EXITMENU", "0");
+ _submenzone->addRect(0xDD, 0x34, 0x10A, 0x43, nullptr, 0, "RECTEASY", "0");
+ _submenzone->addRect(0xDD, 0x55, 0x10A, 0x64, nullptr, 0, "RECTAVG", "0");
+ _submenzone->addRect(0xDD, 0x75, 0x10A, 0x84, nullptr, 0, "RECTHARD", "0");
+
+ _shotSound = _LoadSoundFile("blow.8b");
+ _emptySound = _LoadSoundFile("empty.8b");
+ _saveSound = _LoadSoundFile("saved.8b");
+ _loadSound = _LoadSoundFile("loaded.8b");
+ _skullSound = _LoadSoundFile("skull.8b");
+
+ _gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
+ _numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
+ Common::Array<Graphics::Surface> *bullets = AlgGraphics::loadAniImage("bullets.ani", _palette);
+ _shotIcon = (*bullets)[0];
+ _emptyIcon = (*bullets)[1];
+ Common::Array<Graphics::Surface> *lives = AlgGraphics::loadAniImage("lives.ani", _palette);
+ _liveIcon = (*lives)[0];
+ _deadIcon = (*lives)[1];
+ Common::Array<Graphics::Surface> *difficlt = AlgGraphics::loadScreenCoordAniImage("difficlt.ani", _palette);
+ _difficultyIcon = (*difficlt)[0];
+ Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
+ _bulletholeIcon = (*hole)[0];
+
+ _background = AlgGraphics::loadVgaBackground("dw_menu.vga", _palette);
+ _screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
+
+ _MoveMouse();
+}
+
+void GameDrugWars::registerScriptFunctions() {
+#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new DWScriptFunctionRect(this, &GameDrugWars::func);
+ RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
+ RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
+ RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
+ RECT_HIT_FUNCTION("STARTMENU", _rect_start);
+ RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
+ RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
+ RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
+ RECT_HIT_FUNCTION("RECTEASY", _rect_easy);
+ RECT_HIT_FUNCTION("RECTAVG", _rect_average);
+ RECT_HIT_FUNCTION("RECTHARD", _rect_hard);
+ RECT_HIT_FUNCTION("SELECT_TARGET_PRACTICE", _rect_select_target_practice);
+ RECT_HIT_FUNCTION("SELECT_BAR", _rect_select_bar);
+ RECT_HIT_FUNCTION("SELECT_CAR_CHASE", _rect_select_car_chase);
+ RECT_HIT_FUNCTION("SELECT_DRUG_HOUSE", _rect_select_drug_house);
+ RECT_HIT_FUNCTION("SELECT_OFFICE", _rect_select_office);
+ RECT_HIT_FUNCTION("SELECT_COURT", _rect_select_court);
+ RECT_HIT_FUNCTION("SELECT_BUS", _rect_select_bus);
+ RECT_HIT_FUNCTION("SELECT_DOCKS", _rect_select_docks);
+ RECT_HIT_FUNCTION("SELECT_HOUSE_BOAT", _rect_select_house_boat);
+ RECT_HIT_FUNCTION("SELECT_PARTY", _rect_select_party);
+ RECT_HIT_FUNCTION("SELECT_AIRPORT", _rect_select_airport);
+ RECT_HIT_FUNCTION("SELECT_MANSION", _rect_select_mansion);
+ RECT_HIT_FUNCTION("SELECT_VILLAGE", _rect_select_village);
+#undef RECT_HIT_FUNCTION
+
+#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new DWScriptFunctionScene(this, &GameDrugWars::func);
+ PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
+ PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
+ PRE_OPS_FUNCTION("PAUSE_FADEIN", _scene_pso_pause_fadein);
+ PRE_OPS_FUNCTION("GOT_TO", _scene_pso_got_to);
+#undef PRE_OPS_FUNCTION
+
+#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new DWScriptFunctionScene(this, &GameDrugWars::func);
+ INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
+ INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
+#undef INS_OPS_FUNCTION
+
+#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new DWScriptFunctionScene(this, &GameDrugWars::func);
+ NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
+ NXT_SCN_FUNCTION("GAME_WON", _scene_nxtscn_game_won);
+ NXT_SCN_FUNCTION("LOSE_A_LIFE", _scene_nxtscn_lose_a_life);
+ NXT_SCN_FUNCTION("CONTINUE_GAME", _scene_nxtscn_continue_game);
+ NXT_SCN_FUNCTION("DID_NOT_CONTINUE", _scene_nxtscn_did_not_continue);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_MAN", _scene_nxtscn_kill_innocent_man);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_WOMAN", _scene_nxtscn_kill_innocent_woman);
+ NXT_SCN_FUNCTION("AFTER_DIE", _scene_nxtscn_after_die);
+ NXT_SCN_FUNCTION("INIT_RANDOM", _scene_nxtscn_init_random);
+ NXT_SCN_FUNCTION("CONTINUE_RANDOM", _scene_nxtscn_continue_random);
+ NXT_SCN_FUNCTION("SELECT_SCENARIO", _scene_nxtscn_select_scenario);
+ NXT_SCN_FUNCTION("FINISH_SCENARIO", _scene_nxtscn_finish_scenario);
+#undef NXT_SCN_FUNCTION
+
+ _sceneShowMsg["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::_scene_sm_donothing);
+ _sceneWepDwn["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::_scene_default_wepdwn);
+ _sceneScnScr["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::_scene_default_score);
+ _sceneNxtFrm["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::_scene_nxtfrm);
+}
+
+void GameDrugWars::verifyScriptFunctions() {
+ Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
+ for (size_t i = 0; i < scenes->size(); i++) {
+ Scene *scene = (*scenes)[i];
+ getScriptFunctionScene(PREOP, scene->preop);
+ getScriptFunctionScene(SHOWMSG, scene->scnmsg);
+ getScriptFunctionScene(INSOP, scene->insop);
+ getScriptFunctionScene(WEPDWN, scene->wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->scnscr);
+ getScriptFunctionScene(NXTFRM, scene->nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->nxtscn);
+ for (size_t j = 0; j < scene->zones.size(); j++) {
+ Zone *zone = scene->zones[j];
+ for (size_t k = 0; k < zone->rects.size(); k++) {
+ getScriptFunctionRectHit(zone->rects[k].rectHit);
+ }
+ }
+ }
+}
+
+DWScriptFunctionRect GameDrugWars::getScriptFunctionRectHit(Common::String name) {
+ DWScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ if (it != _rectHitFuncs.end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find rectHit function: %s", name.c_str());
+ }
+}
+
+DWScriptFunctionScene GameDrugWars::getScriptFunctionScene(SceneFuncType type, Common::String name) {
+ DWScriptFunctionSceneMap *functionMap;
+ switch (type) {
+ case PREOP:
+ functionMap = &_scenePreOps;
+ break;
+ case SHOWMSG:
+ functionMap = &_sceneShowMsg;
+ break;
+ case INSOP:
+ functionMap = &_sceneInsOps;
+ break;
+ case WEPDWN:
+ functionMap = &_sceneWepDwn;
+ break;
+ case SCNSCR:
+ functionMap = &_sceneScnScr;
+ break;
+ case NXTFRM:
+ functionMap = &_sceneNxtFrm;
+ break;
+ case NXTSCN:
+ functionMap = &_sceneNxtScn;
+ break;
+ default:
+ error("Unkown scene script type: %u", type);
+ break;
+ }
+ DWScriptFunctionSceneMap::iterator it;
+ it = functionMap->find(name);
+ if (it != functionMap->end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find scene type %u function: %s", type, name.c_str());
+ }
+}
+
+void GameDrugWars::callScriptFunctionRectHit(Common::String name, Rect *rect) {
+ DWScriptFunctionRect function = getScriptFunctionRectHit(name);
+ function(rect);
+}
+
+void GameDrugWars::callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene) {
+ DWScriptFunctionScene function = getScriptFunctionScene(type, name);
+ function(scene);
+}
+
+Common::Error GameDrugWars::run() {
+ init();
+ _NewGame();
+ _cur_scene = _startscene;
+ Common::String oldscene;
+ while (!_vm->shouldQuit()) {
+ oldscene = _cur_scene;
+ _SetFrame();
+ _fired = false;
+ Scene *scene = _sceneInfo->findScene(_cur_scene);
+ if (!loadScene(scene)) {
+ error("Cannot find scene %s in libfile", scene->name.c_str());
+ }
+ _sceneSkipped = false;
+ Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
+ g_system->getMixer()->stopHandle(_sceneAudioHandle);
+ g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ _paletteDirty = true;
+ _nextFrameTime = _GetMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->preop, scene);
+ _currentFrame = _GetFrame(scene);
+ while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
+ _UpdateMouse();
+ callScriptFunctionScene(SHOWMSG, scene->scnmsg, scene);
+ callScriptFunctionScene(INSOP, scene->insop, scene);
+ _holster = _WeaponDown();
+ if (_holster) {
+ callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ }
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ if (!_holster) {
+ Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ if (hitGlobalRect != nullptr) {
+ callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
+ } else {
+ if (_shots > 0) {
+ if (!_debug_unlimitedAmmo) {
+ _shots--;
+ }
+ _DisplayShotFiredImage(&firedCoords);
+ _DoShot();
+ Rect *hitRect = nullptr;
+ Zone *hitSceneZone = _CheckZonesV2(scene, hitRect, &firedCoords);
+ if (hitSceneZone != nullptr) {
+ callScriptFunctionRectHit(hitRect->rectHit, hitRect);
+ } else {
+ int8 skip = _SkipToNewScene(scene);
+ if (skip == -1) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ } else if (skip == 1) {
+ if (scene->dataParam4 > 0) {
+ uint32 framesToSkip = (scene->dataParam4 - _currentFrame) / _videoFrameSkip;
+ _videoDecoder->skipNumberOfFrames(framesToSkip);
+ } else {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ }
+ }
+ } else {
+ _PlaySound(_emptySound);
+ }
+ }
+ }
+ }
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ }
+ _DisplayLivesLeft();
+ _DisplayScores();
+ _DisplayShotsLeft();
+ _MoveMouse();
+ if (_pauseTime > 0) {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ } else {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ }
+ if (_videoDecoder->getCurrentFrame() == 0) {
+ _videoDecoder->getNextFrame();
+ }
+ int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ if (remainingMillis < 10) {
+ if (_videoDecoder->getCurrentFrame() > 0) {
+ _videoDecoder->getNextFrame();
+ }
+ remainingMillis = _nextFrameTime - _GetMsTime();
+ _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ }
+ if (remainingMillis > 0) {
+ if (remainingMillis > 15) {
+ remainingMillis = 15;
+ }
+ g_system->delayMillis(remainingMillis);
+ }
+ _currentFrame = _GetFrame(scene);
+ updateScreen();
+ }
+ // frame limit reached or scene changed, prepare for next scene
+ _hadPause = false;
+ _pauseTime = 0;
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ if (_cur_scene == "") {
+ _vm->quitGame();
+ }
+ }
+ return Common::kNoError;
+}
+
+void GameDrugWars::_NewGame() {
+ _shots = 10;
+ _lives = 3;
+ _holster = false;
+}
+
+void GameDrugWars::_ResetParams() {
+ // fill _got_to with scenario start scenes
+ // 0 in _got_to array means the scenario is finished
+ for (uint8 i = 0; i < 14; i++) {
+ _got_to[i] = _scenario_start_scenes[i];
+ }
+}
+
+void GameDrugWars::_DoMenu() {
+ uint32 startTime = _GetMsTime();
+ _RestoreCursor();
+ _DoCursor();
+ _inMenu = true;
+ _MoveMouse();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+ _ShowDifficulty(_difficulty, false);
+ while (_inMenu && !_vm->shouldQuit()) {
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ Rect *hitMenuRect = _CheckZone(_submenzone, &firedCoords);
+ if (hitMenuRect != nullptr) {
+ callScriptFunctionRectHit(hitMenuRect->rectHit, hitMenuRect);
+ }
+ }
+ if (_difficulty != _oldDifficulty) {
+ _ChangeDifficulty(_difficulty);
+ }
+ g_system->delayMillis(15);
+ updateScreen();
+ }
+ _RestoreCursor();
+ _DoCursor();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ if (_hadPause) {
+ unsigned long endTime = _GetMsTime();
+ unsigned long timeDiff = endTime - startTime;
+ _pauseTime += timeDiff;
+ _nextFrameTime += timeDiff;
+ }
+}
+
+void GameDrugWars::_ChangeDifficulty(uint8 newDifficulty) {
+ if (newDifficulty == _oldDifficulty) {
+ return;
+ }
+ _ShowDifficulty(newDifficulty, true);
+ _oldDifficulty = newDifficulty;
+ _difficulty = newDifficulty;
+}
+
+void GameDrugWars::_ShowDifficulty(uint8 newDifficulty, bool updateCursor) {
+ // reset menu screen
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+ uint16 posY = 0x3C + ((newDifficulty - 1) * 0x21);
+ AlgGraphics::drawImageCentered(_screen, &_difficultyIcon, 0x0115, posY);
+ if (updateCursor) {
+ _DoCursor();
+ }
+}
+
+void GameDrugWars::_DoCursor() {
+ _UpdateMouse();
+}
+
+void GameDrugWars::_UpdateMouse() {
+ if (_oldWhichGun != _whichGun) {
+ Graphics::PixelFormat pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
+ Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ CursorMan.popAllCursors();
+ uint16 hotspotX = (cursor->w / 2) + 3;
+ uint16 hotspotY = (cursor->h / 2) + 3;
+ if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
+ cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
+ cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
+ }
+ CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0, false, &pixelFormat);
+ CursorMan.showMouse(true);
+ _oldWhichGun = _whichGun;
+ }
+}
+
+void GameDrugWars::_MoveMouse() {
+ if (_inMenu) {
+ _whichGun = 3; // in menu cursor
+ } else {
+ // disabled for now, because glitchy
+ /*
+ uint16 x = _mousePos.x;
+ uint16 y = _mousePos.y;
+ if (x < 13) {x = 13;}
+ if (x > 286) {x = 286;}
+ if (y < 3) {y = 3;}
+ if (y > 166) {y = 166;}
+ if (_mousePos.x != x || _mousePos.y != y) {
+ _mousePos.x = x;
+ _mousePos.y = y;
+ g_system->warpMouse(x, y);
+ }
+ */
+ if (_mousePos.y >= 0xA3 && _mousePos.x >= 0xF0) {
+ _whichGun = 1; // holster
+ } else if (_mousePos.y >= 0xA3 && _mousePos.x <= 0x43) {
+ _whichGun = 2; // menu button cursor
+ } else {
+ _whichGun = 0; // regular gun
+ }
+ }
+ _UpdateMouse();
+}
+
+void GameDrugWars::_DisplayLivesLeft() {
+ if (_lives == _oldLives) {
+ return;
+ }
+ int posY = 0x67;
+ for (uint8 i = 0; i < 3; i++) {
+ AlgGraphics::drawImage(_screen, &_deadIcon, 0x12F, posY);
+ posY += 0xE;
+ }
+ posY = 0x67;
+ for (uint8 i = 0; i < _lives; i++) {
+ AlgGraphics::drawImage(_screen, &_liveIcon, 0x12F, posY);
+ posY += 0xE;
+ }
+ _oldLives = _lives;
+}
+
+void GameDrugWars::_DisplayScores() {
+ if (_score == _oldScore) {
+ return;
+ }
+ Common::String scoreString = Common::String::format("%05d", _score);
+ int posX = 0x9B;
+ for (int i = 0; i < 5; i++) {
+ uint8 digit = scoreString[i] - '0';
+ AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xBF);
+ posX += 7;
+ }
+ _oldScore = _score;
+}
+
+void GameDrugWars::_DisplayShotsLeft() {
+ if (_shots == _oldShots) {
+ return;
+ }
+ uint16 posX = 0xEE;
+ for (uint8 i = 0; i < 10; i++) {
+ AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBE);
+ posX += 5;
+ }
+ posX = 0xEE;
+ for (uint8 i = 0; i < _shots; i++) {
+ AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBE);
+ posX += 5;
+ }
+ _oldShots = _shots;
+}
+
+bool GameDrugWars::_WeaponDown() {
+ if (_rightDown && _mousePos.y >= 0xAA && _mousePos.x >= 0x113) {
+ return true;
+ }
+ return false;
+}
+
+bool GameDrugWars::_SaveState() {
+ Common::OutSaveFile *outSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(outSaveFile = g_system->getSavefileManager()->openForSaving(saveFileName))) {
+ warning("Can't create file '%s', game not saved", saveFileName.c_str());
+ return false;
+ }
+ outSaveFile->writeUint32BE(MKTAG('A', 'L', 'G', 'S')); // header
+ outSaveFile->writeByte(0); // version, unused for now
+ outSaveFile->writeSByte(_stage);
+ outSaveFile->writeByte(_continues);
+ outSaveFile->writeSByte(_got_to_index);
+ for (uint8 i = 0; i < 14; i++) {
+ outSaveFile->writeUint16LE(_got_to[i]);
+ }
+ outSaveFile->writeSByte(_lives);
+ outSaveFile->writeUint16LE(_shots);
+ outSaveFile->writeSint32LE(_score);
+ outSaveFile->writeByte(_difficulty);
+ outSaveFile->writeString(_cur_scene);
+ outSaveFile->writeByte(0);
+ outSaveFile->finalize();
+ delete outSaveFile;
+ return true;
+}
+
+bool GameDrugWars::_LoadState() {
+ Common::InSaveFile *inSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(inSaveFile = g_system->getSavefileManager()->openForLoading(saveFileName))) {
+ debug("Can't load file '%s', game not loaded", saveFileName.c_str());
+ return false;
+ }
+ uint32 header = inSaveFile->readUint32BE();
+ if (header != MKTAG('A', 'L', 'G', 'S')) {
+ warning("Unkown save file, header: %d", header);
+ return false;
+ }
+ inSaveFile->skip(1); // version, unused for now
+ _stage = inSaveFile->readSByte();
+ _continues = inSaveFile->readByte();
+ _got_to_index = inSaveFile->readSByte();
+ for (uint8 i = 0; i < 14; i++) {
+ _got_to[i] = inSaveFile->readUint16LE();
+ }
+ _lives = inSaveFile->readSByte();
+ _shots = inSaveFile->readUint16LE();
+ _score = inSaveFile->readSint32LE();
+ _difficulty = inSaveFile->readByte();
+ _cur_scene = inSaveFile->readString();
+ delete inSaveFile;
+ _gameInProgress = true;
+ _ChangeDifficulty(_difficulty);
+ return true;
+}
+
+// misc game functions
+void GameDrugWars::_DisplayShotFiredImage(Common::Point *point) {
+ if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
+ uint16 targetX = point->x - _videoPosX;
+ uint16 targetY = point->y - _videoPosY;
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ }
+}
+
+void GameDrugWars::_EnableVideoFadeIn() {
+ // TODO implement
+}
+
+uint16 GameDrugWars::_SceneToNumber(Scene *scene) {
+ return atoi(scene->name.substr(5).c_str());
+}
+
+uint16 GameDrugWars::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
+ if (max == 1) {
+ return 0;
+ }
+ // reset mask if full
+ uint16 fullMask = 0xFFFF >> (16 - max);
+ if (*mask == fullMask) {
+ *mask = 0;
+ }
+ uint16 random;
+ // find an unused random number
+ while (1) {
+ random = _rnd->getRandomNumber(max - 1);
+ // check if bit is already used
+ unsigned int bit = 1 << random;
+ if (!((*mask & bit) || random == exclude)) {
+ // set the bit in mask
+ *mask |= bit;
+ break;
+ }
+ }
+ return random;
+}
+
+uint16 GameDrugWars::_PickRandomScene(uint8 index, uint8 max) {
+ if (_random_scenes[index] == nullptr) {
+ error("_PickRandomScene called with illegal index: %d", index);
+ }
+ if (max != 0) {
+ _random_max = max;
+ _random_mask = 0;
+ _random_picked = -1;
+ _random_scene_count = 0;
+ while (_random_scenes[index][_random_scene_count] != 0) {
+ _random_scene_count++;
+ }
+ }
+ unsigned short count = _random_max--;
+ if (count > 0) {
+ _random_picked = _RandomUnusedInt(_random_scene_count, &_random_mask, _random_picked);
+ return _random_scenes[index][_random_picked];
+ }
+ return 0;
+}
+
+uint16 GameDrugWars::_PickDeathScene() {
+ if (_stage != _old_stage) {
+ _old_stage = _stage;
+ _death_mask = 0;
+ _death_picked = -1;
+ _death_scene_count = 0;
+ while (_died_scenes_by_stage[_stage][_death_scene_count] != 0) {
+ _death_scene_count++;
+ }
+ }
+ _death_picked = _RandomUnusedInt(_death_scene_count, &_death_mask, _death_picked);
+ return _died_scenes_by_stage[_stage][_death_picked];
+}
+
+void GameDrugWars::_scene_nxtscn_generic(uint8 index) {
+ uint16 nextSceneId = 0;
+ _got_to[index] = 0;
+ if (_got_to[0] || _got_to[1] || _got_to[3] || _got_to[2]) {
+ nextSceneId = 0x26;
+ } else if (_got_to[4] || _got_to[5] || _got_to[6]) {
+ if (_stage == 1) {
+ nextSceneId = 0x52;
+ } else {
+ _stage = 1;
+ nextSceneId = 0x50;
+ }
+ } else if (_got_to[7] || _got_to[8] || _got_to[9]) {
+ if (_stage == 2) {
+ nextSceneId = 0x9A;
+ } else {
+ _stage = 2;
+ nextSceneId = 0x81;
+ }
+ } else if (_got_to[10] || _got_to[11] || _got_to[12]) {
+ if (_stage == 3) {
+ nextSceneId = 0xDF;
+ } else {
+ _stage = 3;
+ nextSceneId = 0x14B;
+ }
+ } else if (_got_to[13]) {
+ _stage = 4;
+ nextSceneId = 0x18F;
+ } else {
+ nextSceneId = 0x21;
+ }
+ _cur_scene = Common::String::format("scene%d", nextSceneId);
+}
+
+void GameDrugWars::_rect_select_generic(uint8 index) {
+ if (_got_to[index] > 0) {
+ _cur_scene = Common::String::format("scene%d", _got_to[index]);
+ _got_to_index = index;
+ }
+}
+
+// Script functions: RectHit
+void GameDrugWars::_rect_shotmenu(Rect *rect) {
+ _DoMenu();
+}
+
+void GameDrugWars::_rect_save(Rect *rect) {
+ if(_SaveState()) {
+ _DoSaveSound();
+ }
+}
+
+void GameDrugWars::_rect_load(Rect *rect) {
+ if(_LoadState()) {
+ _DoLoadSound();
+ }
+}
+
+void GameDrugWars::_rect_continue(Rect *rect) {
+ _inMenu = false;
+ _fired = false;
+ if (_lives <= 0) {
+ _score = (int32)(_score * 0.7f);
+ uint16 returnScene = _stage_start_scenes[_stage];
+ _cur_scene = Common::String::format("scene%d", returnScene);
+ _NewGame();
+ }
+}
+
+void GameDrugWars::_rect_start(Rect *rect) {
+ _inMenu = false;
+ _fired = false;
+ _gameInProgress = true;
+ if (_isDemo) {
+ _cur_scene = "scene54";
+ _got_to_index = 1;
+ _got_to[_got_to_index] = 54;
+ } else {
+ _cur_scene = "scene53";
+ }
+ _ResetParams();
+ _NewGame();
+}
+
+void GameDrugWars::_rect_select_target_practice(Rect *rect) {
+ _rect_select_generic(0);
+ _got_to[0] = 0;
+}
+
+void GameDrugWars::_rect_select_bar(Rect *rect) {
+ _got_to[0] = 0;
+ _rect_select_generic(1);
+}
+
+void GameDrugWars::_rect_select_car_chase(Rect *rect) {
+ _got_to[0] = 0;
+ _rect_select_generic(2);
+}
+
+void GameDrugWars::_rect_select_drug_house(Rect *rect) {
+ _got_to[0] = 0;
+ _rect_select_generic(3);
+}
+
+void GameDrugWars::_rect_select_office(Rect *rect) {
+ _rect_select_generic(4);
+}
+
+void GameDrugWars::_rect_select_court(Rect *rect) {
+ _rect_select_generic(5);
+}
+
+void GameDrugWars::_rect_select_bus(Rect *rect) {
+ _rect_select_generic(6);
+}
+
+void GameDrugWars::_rect_select_docks(Rect *rect) {
+ _rect_select_generic(7);
+}
+
+void GameDrugWars::_rect_select_house_boat(Rect *rect) {
+ _rect_select_generic(9);
+}
+
+void GameDrugWars::_rect_select_party(Rect *rect) {
+ _rect_select_generic(8);
+}
+
+void GameDrugWars::_rect_select_airport(Rect *rect) {
+ _rect_select_generic(10);
+}
+
+void GameDrugWars::_rect_select_mansion(Rect *rect) {
+ _rect_select_generic(11);
+}
+
+void GameDrugWars::_rect_select_village(Rect *rect) {
+ _rect_select_generic(12);
+}
+
+// Script functions: Scene PreOps
+void GameDrugWars::_scene_pso_got_to(Scene *scene) {
+ uint16 sceneId = _SceneToNumber(scene);
+ _got_to[_got_to_index] = sceneId;
+ if (_got_to_index == 13) {
+ _final_stage_scene = _SceneToNumber(scene);
+ }
+ _EnableVideoFadeIn();
+}
+
+// Script functions: Scene NxtScn
+void GameDrugWars::_scene_nxtscn_game_won(Scene *scene) {
+ _gameInProgress = false;
+ _cur_scene = _startscene;
+}
+
+void GameDrugWars::_scene_nxtscn_did_not_continue(Scene *scene) {
+ _gameInProgress = false;
+ _cur_scene = _startscene;
+}
+
+void GameDrugWars::_scene_nxtscn_lose_a_life(Scene *scene) {
+ uint16 picked = 0;
+ if (!_debug_godMode) {
+ _lives--;
+ }
+ if (_isDemo) {
+ _cur_scene = "scene83";
+ return;
+ } else if (_lives > 0) {
+ _DisplayLivesLeft();
+ picked = _PickDeathScene();
+ } else {
+ picked = _dead_scenes[_stage];
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameDrugWars::_scene_nxtscn_continue_game(Scene *scene) {
+ if (_continues < 2) {
+ _cur_scene = "scene438";
+ } else {
+ _scene_nxtscn_did_not_continue(scene);
+ }
+}
+
+void GameDrugWars::_scene_nxtscn_kill_innocent_man(Scene *scene) {
+ uint16 picked = 0;
+ if (!_debug_godMode) {
+ _lives--;
+ }
+ if (_isDemo) {
+ _scene_nxtscn_after_die(scene);
+ return;
+ } else if (_lives > 0) {
+ picked = _stage_start_scenes[_stage];
+ } else {
+ picked = _dead_scenes[_stage];
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameDrugWars::_scene_nxtscn_kill_innocent_woman(Scene *scene) {
+ _scene_nxtscn_kill_innocent_man(scene);
+}
+
+void GameDrugWars::_scene_nxtscn_after_die(Scene *scene) {
+ if (_isDemo) {
+ if (_got_to[_got_to_index] > 54) {
+ _cur_scene = "scene67";
+ } else {
+ _cur_scene = "scene54";
+ }
+ } else {
+ uint16 picked = _stage_start_scenes[_stage];
+ _cur_scene = Common::String::format("scene%d", picked);
+ }
+}
+
+void GameDrugWars::_scene_nxtscn_init_random(Scene *scene) {
+ int totalRandom = (_difficulty * 2) + _random_scenes_difficulty[_got_to_index] + 2;
+ uint16 picked = _PickRandomScene(_got_to_index, totalRandom);
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameDrugWars::_scene_nxtscn_continue_random(Scene *scene) {
+ uint16 picked = _PickRandomScene(_got_to_index, 0);
+ if (picked == 0) {
+ picked = _random_scenes_continue[_got_to_index];
+ if (picked == 0) {
+ error("_scene_nxtscn_continue_random called with illegal _got_to_index: %d", _got_to_index);
+ }
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+void GameDrugWars::_scene_nxtscn_select_scenario(Scene *scene) {
+ uint16 picked = 0;
+ switch (_stage) {
+ case 0:
+ if (_got_to[0] > 0) {
+ _rect_select_generic(0);
+ _got_to[0] = 0;
+ } else if (_got_to[1] > 0) {
+ _rect_select_generic(1);
+ } else if (_got_to[2] > 0) {
+ _rect_select_generic(2);
+ } else if (_got_to[3] > 0) {
+ _rect_select_generic(3);
+ } else {
+ picked = 0x83;
+ _stage = 1;
+ }
+ break;
+ case 1:
+ if (_got_to[4] > 0) {
+ _rect_select_generic(4);
+ } else if (_got_to[5] > 0) {
+ _rect_select_generic(5);
+ } else if (_got_to[6] > 0) {
+ _rect_select_generic(6);
+ } else {
+ picked = 0xEE;
+ _stage = 2;
+ }
+ break;
+ case 2:
+ if (_got_to[7] > 0) {
+ _rect_select_generic(7);
+ } else if (_got_to[8] > 0) {
+ _rect_select_generic(8);
+ } else if (_got_to[9] > 0) {
+ _rect_select_generic(9);
+ } else {
+ picked = 0x0132;
+ _stage = 3;
+ }
+ break;
+ case 3:
+ if (_got_to[10] > 0) {
+ _rect_select_generic(10);
+ } else if (_got_to[11] > 0) {
+ _rect_select_generic(11);
+ } else if (_got_to[12] > 0) {
+ _rect_select_generic(12);
+ } else {
+ picked = _final_stage_scene;
+ _got_to_index = 13;
+ _stage = 4;
+ }
+ break;
+ }
+ if (picked != 0) {
+ _cur_scene = Common::String::format("scene%d", picked);
+ }
+}
+
+void GameDrugWars::_scene_nxtscn_finish_scenario(Scene *scene) {
+ uint16 picked = 0;
+ _got_to[_got_to_index] = 0;
+ if (_isDemo) {
+ _cur_scene = _startscene;
+ return;
+ }
+ if (_got_to[0] || _got_to[1] || _got_to[3] || _got_to[2]) {
+ picked = 0x51;
+ } else if (_got_to[4] || _got_to[5] || _got_to[6]) {
+ if (_stage == 1) {
+ picked = 0x83;
+ } else {
+ _stage = 1;
+ picked = 0x6B;
+ }
+ } else if (_got_to[7] || _got_to[8] || _got_to[9]) {
+ if (_stage == 2) {
+ picked = 0xEE;
+ } else {
+ _stage = 2;
+ picked = 0xB6;
+ }
+ } else if (_got_to[10] || _got_to[11] || _got_to[12]) {
+ if (_stage == 3) {
+ picked = 0x0132;
+ } else {
+ _stage = 3;
+ picked = 0x0109;
+ }
+ } else if (_got_to[13] != 0) {
+ _stage = 13;
+ _stage = 4;
+ picked = 0x017F;
+ } else {
+ picked = 0x21;
+ }
+ _cur_scene = Common::String::format("scene%d", picked);
+}
+
+// Script functions: WepDwn
+void GameDrugWars::_scene_default_wepdwn(Scene *scene) {
+ _shots = 10;
+}
+
+// Debug methods
+void GameDrugWars::debug_warpTo(int val) {
+ // TODO implement
+}
+
+// Debugger methods
+DebuggerDrugWars::DebuggerDrugWars(GameDrugWars *game) : GUI::Debugger() {
+ _game = game;
+ registerVar("drawRects", &game->_debug_drawRects);
+ registerVar("godMode", &game->_debug_godMode);
+ registerVar("unlimitedAmmo", &game->_debug_unlimitedAmmo);
+ registerCmd("warpTo", WRAP_METHOD(DebuggerDrugWars, cmdWarpTo));
+ registerCmd("dumpLib", WRAP_METHOD(DebuggerDrugWars, cmdDumpLib));
+}
+
+bool DebuggerDrugWars::cmdWarpTo(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: warp <int>");
+ return true;
+ } else {
+ int val = atoi(argv[1]);
+ _game->debug_warpTo(val);
+ return false;
+ }
+}
+
+bool DebuggerDrugWars::cmdDumpLib(int argc, const char **argv) {
+ return _game->debug_dumpLibFile();
+}
+
+} // End of namespace Alg
diff --git a/engines/alg/game_drugwars.h b/engines/alg/game_drugwars.h
new file mode 100644
index 00000000000..f74e3f79f53
--- /dev/null
+++ b/engines/alg/game_drugwars.h
@@ -0,0 +1,208 @@
+/* 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 ALG_GAME_DRUGWARS_H
+#define ALG_GAME_DRUGWARS_H
+
+#include "common/hashmap.h"
+#include "common/rect.h"
+
+#include "gui/debugger.h"
+
+#include "alg/game.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+typedef Common::Functor1Mem<Scene *, void, GameDrugWars> DWScriptFunctionScene;
+typedef Common::Functor1Mem<Rect *, void, GameDrugWars> DWScriptFunctionRect;
+typedef Common::HashMap<Common::String, DWScriptFunctionScene *> DWScriptFunctionSceneMap;
+typedef Common::HashMap<Common::String, DWScriptFunctionRect *> DWScriptFunctionRectMap;
+
+class GameDrugWars : public Game {
+
+ enum SceneFuncType {
+ PREOP = 1,
+ SHOWMSG = 2,
+ INSOP = 3,
+ WEPDWN = 4,
+ SCNSCR = 5,
+ NXTFRM = 6,
+ NXTSCN = 7
+ };
+
+public:
+ GameDrugWars(AlgEngine *vm, const ADGameDescription *desc);
+ ~GameDrugWars();
+ Common::Error run();
+ void debug_warpTo(int val);
+
+private:
+ void init();
+ void registerScriptFunctions();
+ void verifyScriptFunctions();
+ DWScriptFunctionRect getScriptFunctionRectHit(Common::String name);
+ DWScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
+ void callScriptFunctionRectHit(Common::String name, Rect *rect);
+ void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
+
+ DWScriptFunctionRectMap _rectHitFuncs;
+ DWScriptFunctionSceneMap _scenePreOps;
+ DWScriptFunctionSceneMap _sceneShowMsg;
+ DWScriptFunctionSceneMap _sceneInsOps;
+ DWScriptFunctionSceneMap _sceneWepDwn;
+ DWScriptFunctionSceneMap _sceneScnScr;
+ DWScriptFunctionSceneMap _sceneNxtFrm;
+ DWScriptFunctionSceneMap _sceneNxtScn;
+
+ // images
+ Graphics::Surface _shotIcon;
+ Graphics::Surface _emptyIcon;
+ Graphics::Surface _liveIcon;
+ Graphics::Surface _deadIcon;
+ Graphics::Surface _difficultyIcon;
+ Graphics::Surface _bulletholeIcon;
+
+ // constants
+ const int16 _random_scenes0[7] = {0x29, 0x2B, 0x2D, 0x2F, 0x31, 0x33, 0};
+ const int16 _random_scenes1[6] = {0x37, 0x39, 0x3B, 0x3D, 0x3F, 0};
+ const int16 _random_scenes4[8] = {0xA8, 0xAA, 0xAC, 0xAE, 0xB0, 0xB2, 0xB4, 0};
+ const int16 _random_scenes8[8] = {0xC0, 0xC2, 0xC4, 0xC6, 0xC8, 0xCA, 0xCC, 0};
+ const int16 _random_scenes9[6] = {0xFE, 0x0100, 0x0102, 0x01A3, 0x0105, 0};
+ const int16 _random_scenes10[8] = {0x0161, 0x0163, 0x0165, 0x0167, 0x016A, 0x016C, 0x016E, 0};
+ const int16 _random_scenes11[9] = {0x010B, 0x010D, 0x010F, 0x0111, 0x0113, 0x0115, 0x0117, 0x0119, 0};
+ const int16 _random_scenes12[10] = {0x014C, 0x014E, 0x0150, 0x0152, 0x0154, 0x0156, 0x0158, 0x015A, 0x015C, 0};
+
+ const int16 *_random_scenes[14] = {_random_scenes0, _random_scenes1, nullptr, nullptr, _random_scenes4, nullptr, nullptr, nullptr,
+ _random_scenes8, _random_scenes9, _random_scenes10, _random_scenes11, _random_scenes12, nullptr};
+ const uint8 _random_scenes_difficulty[14] = {6, 4, 0, 0, 6, 0, 0, 0, 5, 6, 7, 8, 8, 0};
+ const uint16 _random_scenes_continue[14] = {0x51, 0x41, 0, 0, 0x01B5, 0, 0, 0, 0xCE, 0x0107, 0x0170, 0x011B, 0x015E, 0};
+
+ const int16 _died_scenes_stage0[4] = {0x52, 0x53, 0x54, 0};
+ const int16 _died_scenes_stage1[5] = {0x85, 0x86, 0x88, 0x89, 0};
+ const int16 _died_scenes_stage2[3] = {0xEF, 0xF0, 0};
+ const int16 _died_scenes_stage3[3] = {0x0135, 0x0136, 0};
+ const int16 _died_scenes_stage4[3] = {0x0135, 0x0136, 0};
+
+ const int16 *_died_scenes_by_stage[5] = {_died_scenes_stage0, _died_scenes_stage1, _died_scenes_stage2, _died_scenes_stage3, _died_scenes_stage4};
+
+ uint16 _dead_scenes[5] = {0x56, 0x8A, 0xF2, 0x0134, 0x0134};
+
+ const uint16 _stage_start_scenes[5] = {0x51, 0x83, 0xEE, 0x0132, 0x017F};
+
+ const uint16 _scenario_start_scenes[14] = {0x27, 0x36, 0x4A, 0x57, 0x9D, 0x8B, 0x74, 0xD8, 0xBF, 0xB8, 0x0160, 0x010A, 0x0137, 0x017F};
+
+ bool _isDemo = 0;
+
+ // gamestate
+ uint8 _continues = 0;
+ uint16 _got_to[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ int8 _got_to_index = 0;
+ int8 _stage = 0;
+ int8 _old_stage = -1;
+ uint8 _random_scene_count = 0;
+ uint8 _random_max = 0;
+ uint16 _random_mask = 0;
+ uint16 _random_picked = 0;
+ uint16 _death_mask = 0;
+ int16 _death_picked = 0;
+ uint8 _death_scene_count = 0;
+ uint16 _final_stage_scene = _stage_start_scenes[4];
+
+ // base functions
+ void _NewGame();
+ void _ResetParams();
+ void _DoMenu();
+ void _ChangeDifficulty(uint8 newDifficulty);
+ void _ShowDifficulty(uint8 newDifficulty, bool updateCursor);
+ void _DoCursor();
+ void _UpdateMouse();
+ void _MoveMouse();
+ void _DisplayLivesLeft();
+ void _DisplayScores();
+ void _DisplayShotsLeft();
+ bool _WeaponDown();
+ bool _SaveState();
+ bool _LoadState();
+
+ // misc game functions
+ void _DisplayShotFiredImage(Common::Point *point);
+ void _EnableVideoFadeIn();
+ uint16 _SceneToNumber(Scene *scene);
+ uint16 _RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
+ uint16 _PickRandomScene(uint8 index, uint8 max);
+ uint16 _PickDeathScene();
+ void _scene_nxtscn_generic(uint8 index);
+ void _rect_select_generic(uint8 index);
+
+ // Script functions: RectHit
+ void _rect_shotmenu(Rect *rect);
+ void _rect_save(Rect *rect);
+ void _rect_load(Rect *rect);
+ void _rect_continue(Rect *rect);
+ void _rect_start(Rect *rect);
+ void _rect_select_target_practice(Rect *rect);
+ void _rect_select_bar(Rect *rect);
+ void _rect_select_car_chase(Rect *rect);
+ void _rect_select_drug_house(Rect *rect);
+ void _rect_select_office(Rect *rect);
+ void _rect_select_court(Rect *rect);
+ void _rect_select_bus(Rect *rect);
+ void _rect_select_docks(Rect *rect);
+ void _rect_select_house_boat(Rect *rect);
+ void _rect_select_party(Rect *rect);
+ void _rect_select_airport(Rect *rect);
+ void _rect_select_mansion(Rect *rect);
+ void _rect_select_village(Rect *rect);
+
+ // Script functions: Scene PreOps
+ void _scene_pso_got_to(Scene *scene);
+
+ // Script functions: Scene NxtScn
+ void _scene_nxtscn_game_won(Scene *scene);
+ void _scene_nxtscn_lose_a_life(Scene *scene);
+ void _scene_nxtscn_continue_game(Scene *scene);
+ void _scene_nxtscn_did_not_continue(Scene *scene);
+ void _scene_nxtscn_kill_innocent_man(Scene *scene);
+ void _scene_nxtscn_kill_innocent_woman(Scene *scene);
+ void _scene_nxtscn_after_die(Scene *scene);
+ void _scene_nxtscn_init_random(Scene *scene);
+ void _scene_nxtscn_continue_random(Scene *scene);
+ void _scene_nxtscn_select_scenario(Scene *scene);
+ void _scene_nxtscn_finish_scenario(Scene *scene);
+
+ // Script functions: Scene WepDwn
+ void _scene_default_wepdwn(Scene *scene);
+};
+
+class DebuggerDrugWars : public GUI::Debugger {
+public:
+ DebuggerDrugWars(GameDrugWars *game);
+ bool cmdWarpTo(int argc, const char **argv);
+ bool cmdDumpLib(int argc, const char **argv);
+
+private:
+ GameDrugWars *_game;
+};
+
+} // End of namespace Alg
+
+#endif
diff --git a/engines/alg/game_johnnyrock.cpp b/engines/alg/game_johnnyrock.cpp
new file mode 100644
index 00000000000..5193bcfa127
--- /dev/null
+++ b/engines/alg/game_johnnyrock.cpp
@@ -0,0 +1,1764 @@
+/* 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/debug.h"
+#include "common/rect.h"
+#include "common/savefile.h"
+#include "common/system.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/pixelformat.h"
+
+#include "alg/game_johnnyrock.h"
+#include "alg/graphics.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+GameJohnnyRock::GameJohnnyRock(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
+ if (scumm_stricmp(desc->gameId, "johnrocs") == 0) {
+ _libFileName = "johnroc.lib";
+ } else if (scumm_stricmp(desc->gameId, "johnrocd") == 0) {
+ _libFileName = "johnrocd.lib";
+ }
+}
+
+GameJohnnyRock::~GameJohnnyRock() {
+}
+
+void GameJohnnyRock::init() {
+ _videoPosX = 11;
+ _videoPosY = 2;
+
+ _SetupCursorTimer();
+
+ loadLibArchive(_libFileName);
+ _sceneInfo->loadScnFile("johnroc.scn");
+ _startscene = _sceneInfo->getStartScene();
+
+ registerScriptFunctions();
+ verifyScriptFunctions();
+
+ _menuzone = new Zone();
+ _menuzone->name = "MainMenu";
+ _menuzone->ptrfb = "GLOBALHIT";
+
+ _menuzone->addRect(0x0C, 0xBB, 0x3C, 0xC7, nullptr, 0, "SHOTMENU", "0");
+
+ _submenzone = new Zone();
+ _submenzone->name = "SubMenu";
+ _submenzone->ptrfb = "GLOBALHIT";
+
+ _submenzone->addRect(0x10, 0x0F, 0x78, 0x34, nullptr, 0, "STARTMENU", "0");
+ _submenzone->addRect(0x10, 0x8E, 0x8A, 0xAF, nullptr, 0, "CONTMENU", "0");
+ _submenzone->addRect(0x10, 0x3A, 0x6A, 0x5C, nullptr, 0, "RECTSAVE", "0");
+ _submenzone->addRect(0x10, 0x64, 0x84, 0x99, nullptr, 0, "RECTLOAD", "0");
+ _submenzone->addRect(0xD2, 0x8D, 0x12F, 0xB0, nullptr, 0, "EXITMENU", "0");
+ _submenzone->addRect(0xD0, 0x35, 0x123, 0x51, nullptr, 0, "RECTEASY", "0");
+ _submenzone->addRect(0xD2, 0x50, 0x125, 0x6B, nullptr, 0, "RECTAVG", "0");
+ _submenzone->addRect(0xD2, 0x6D, 0x122, 0x86, nullptr, 0, "RECTHARD", "0");
+
+ _shotSound = _LoadSoundFile("blow.8b");
+ _emptySound = _LoadSoundFile("empty.8b");
+ _saveSound = _LoadSoundFile("saved.8b");
+ _loadSound = _LoadSoundFile("loaded.8b");
+ _skullSound = _LoadSoundFile("money.8b");
+
+ _gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
+ _numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
+ _difficultyIcon = AlgGraphics::loadAniImage("diff.ani", _palette);
+ Common::Array<Graphics::Surface> *level = AlgGraphics::loadScreenCoordAniImage("level.ani", _palette);
+ _levelIcon = (*level)[0];
+ Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
+ _bulletholeIcon = (*hole)[0];
+
+ _background = AlgGraphics::loadVgaBackground("backgrnd.vga", _palette);
+ _screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
+
+ _MoveMouse();
+}
+
+void GameJohnnyRock::registerScriptFunctions() {
+#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new JRScriptFunctionRect(this, &GameJohnnyRock::func);
+ RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
+ RECT_HIT_FUNCTION("NEWSCENE", _rect_newscene);
+ RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
+ RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
+ RECT_HIT_FUNCTION("STARTMENU", _rect_start);
+ RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
+ RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
+ RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
+ RECT_HIT_FUNCTION("RECTEASY", _rect_easy);
+ RECT_HIT_FUNCTION("RECTAVG", _rect_average);
+ RECT_HIT_FUNCTION("RECTHARD", _rect_hard);
+ RECT_HIT_FUNCTION("KILLINNOCENT", _rect_killinnocent);
+ RECT_HIT_FUNCTION("SELCASINO", _rect_selectcasino);
+ RECT_HIT_FUNCTION("SELPOOLH", _rect_selectpoolhall);
+ RECT_HIT_FUNCTION("SELWAREHSE", _rect_selectwarehouse);
+ RECT_HIT_FUNCTION("SELGARAGE", _rect_selectgarage);
+ RECT_HIT_FUNCTION("SELMANSION", _rect_selectmansion);
+ RECT_HIT_FUNCTION("SELAMMO", _rect_selectammo);
+ RECT_HIT_FUNCTION("SELOFFICE", _rect_selectoffice);
+ RECT_HIT_FUNCTION("MANBUST", _rect_shotmanbust);
+ RECT_HIT_FUNCTION("WOMANBUST", _rect_shotwomanbust);
+ RECT_HIT_FUNCTION("BLUEVASE", _rect_shotbluevase);
+ RECT_HIT_FUNCTION("CAT", _rect_shotcat);
+ RECT_HIT_FUNCTION("INDIAN", _rect_shotindian);
+ RECT_HIT_FUNCTION("PLATE", _rect_shotplate);
+ RECT_HIT_FUNCTION("BLUEDRESSPIC", _rect_shotbluedresspic);
+ RECT_HIT_FUNCTION("MODERNPIC", _rect_shotmodernpic);
+ RECT_HIT_FUNCTION("MONALISA", _rect_shotmonalisa);
+ RECT_HIT_FUNCTION("GWASHINGTON", _rect_shotgwashington);
+ RECT_HIT_FUNCTION("BOYINREDPIC", _rect_shotboyinredpic);
+ RECT_HIT_FUNCTION("COATOFARMS", _rect_shotcoatofarms);
+ RECT_HIT_FUNCTION("COMBNOA0", _rect_shotcombinationA0);
+ RECT_HIT_FUNCTION("COMBNOA1", _rect_shotcombinationA1);
+ RECT_HIT_FUNCTION("COMBNOA2", _rect_shotcombinationA2);
+ RECT_HIT_FUNCTION("COMBNOA3", _rect_shotcombinationA3);
+ RECT_HIT_FUNCTION("COMBNOA4", _rect_shotcombinationA4);
+ RECT_HIT_FUNCTION("COMBNOA5", _rect_shotcombinationA5);
+ RECT_HIT_FUNCTION("COMBNOB0", _rect_shotcombinationB0);
+ RECT_HIT_FUNCTION("COMBNOB1", _rect_shotcombinationB1);
+ RECT_HIT_FUNCTION("COMBNOB2", _rect_shotcombinationB2);
+ RECT_HIT_FUNCTION("COMBNOB3", _rect_shotcombinationB3);
+ RECT_HIT_FUNCTION("COMBNOB4", _rect_shotcombinationB4);
+ RECT_HIT_FUNCTION("COMBNOB5", _rect_shotcombinationB5);
+ RECT_HIT_FUNCTION("LUCKNO0", _rect_shotluckynum0);
+ RECT_HIT_FUNCTION("LUCKNO1", _rect_shotluckynum1);
+ RECT_HIT_FUNCTION("LUCKNO2", _rect_shotluckynum2);
+ RECT_HIT_FUNCTION("LUCKNO3", _rect_shotluckynum3);
+ RECT_HIT_FUNCTION("LUCKNO4", _rect_shotluckynum4);
+ RECT_HIT_FUNCTION("LUCKNO5", _rect_shotluckynum5);
+#undef RECT_HIT_FUNCTION
+
+#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new JRScriptFunctionScene(this, &GameJohnnyRock::func);
+ PRE_OPS_FUNCTION("DRAWRCT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
+ PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
+ PRE_OPS_FUNCTION("PAUSFI", _scene_pso_pause_fadein);
+ PRE_OPS_FUNCTION("PREREAD", _scene_pso_preread);
+ PRE_OPS_FUNCTION("PAUSPR", _scene_pso_pause_preread);
+ PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("DRAWRCTFDI", _scene_pso_drawrct_fadein);
+#undef PRE_OPS_FUNCTION
+
+#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new JRScriptFunctionScene(this, &GameJohnnyRock::func);
+ INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
+ INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
+ INS_OPS_FUNCTION("SPAUSE", _scene_iso_spause);
+ INS_OPS_FUNCTION("STARTGAME", _scene_iso_startgame);
+ INS_OPS_FUNCTION("SHOOTPAST", _scene_iso_shootpast);
+ INS_OPS_FUNCTION("GOTTOCASINO", _scene_iso_gotocasino);
+ INS_OPS_FUNCTION("GOTTOPOOLH", _scene_iso_gotopoolh);
+ INS_OPS_FUNCTION("GOTTOWAREHSE", _scene_iso_gotowarehse);
+ INS_OPS_FUNCTION("INWAREHSE2", _scene_iso_inwarehse2);
+ INS_OPS_FUNCTION("INWAREHSE3", _scene_iso_inwarehse3);
+ INS_OPS_FUNCTION("GOTOGARAGE", _scene_iso_gotogarage);
+ INS_OPS_FUNCTION("GOTOMANSION", _scene_iso_gotomansion);
+ INS_OPS_FUNCTION("INMANSION1", _scene_iso_inmansion1);
+#undef INS_OPS_FUNCTION
+
+#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new JRScriptFunctionScene(this, &GameJohnnyRock::func);
+ NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
+ NXT_SCN_FUNCTION("DRAWGUN", _scene_default_nxtscn);
+ NXT_SCN_FUNCTION("DIED", _scene_nxtscn_died);
+ NXT_SCN_FUNCTION("BOMBDEAD", _scene_nxtscn_bombdead);
+ NXT_SCN_FUNCTION("PIKUNDRTAKR", _scene_nxtscn_pikundrtakr);
+ NXT_SCN_FUNCTION("CALLATTRACT", _scene_nxtscn_callattract);
+ NXT_SCN_FUNCTION("PICKLUCKNO", _scene_nxtscn_pikluckno);
+ NXT_SCN_FUNCTION("PICKMAP", _scene_nxtscn_pickmap);
+ NXT_SCN_FUNCTION("PICKCLUE", _scene_nxtscn_pickclue);
+ NXT_SCN_FUNCTION("MAPTIMEOUT", _scene_nxtscn_maptimeout);
+ NXT_SCN_FUNCTION("ENTCASINO", _scene_nxtscn_entcasino);
+ NXT_SCN_FUNCTION("CASINOWHAT?", _scene_nxtscn_casinowhat);
+ NXT_SCN_FUNCTION("ENTPOOLH", _scene_nxtscn_entpoolhall);
+ NXT_SCN_FUNCTION("POOLHCLUE", _scene_nxtscn_poolhclue);
+ NXT_SCN_FUNCTION("ENTWAREHSE", _scene_nxtscn_entwarehse);
+ NXT_SCN_FUNCTION("WAREHSECLUE", _scene_nxtscn_warehseclue);
+ NXT_SCN_FUNCTION("ENTGARAGE", _scene_nxtscn_entgarage);
+ NXT_SCN_FUNCTION("GARAGECLUE", _scene_nxtscn_garageclue);
+ NXT_SCN_FUNCTION("ENTMANSION", _scene_nxtscn_entmansion);
+ NXT_SCN_FUNCTION("GIVECLUE", _scene_nxtscn_giveclue);
+ NXT_SCN_FUNCTION("PICKFLOWERMAN", _scene_nxtscn_pikflwrman);
+ NXT_SCN_FUNCTION("RANDOMSCENE", _scene_nxtscn_randomscene);
+ NXT_SCN_FUNCTION("ENDRANDSCENE", _scene_nxtscn_endrandscene);
+ NXT_SCN_FUNCTION("SCN_KILLINNOCENT", _scene_nxtscn_killinnocent);
+#undef NXT_SCN_FUNCTION
+
+ _zonePtrFb["DEFAULT"] = new JRScriptFunctionPoint(this, &GameJohnnyRock::_zone_bullethole);
+ _sceneShowMsg["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::_scene_sm_donothing);
+ _sceneWepDwn["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::_scene_default_wepdwn);
+ _sceneScnScr["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::_scene_default_score);
+ _sceneNxtFrm["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::_scene_nxtfrm);
+}
+
+void GameJohnnyRock::verifyScriptFunctions() {
+ Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
+ for (size_t i = 0; i < scenes->size(); i++) {
+ Scene *scene = (*scenes)[i];
+ getScriptFunctionScene(PREOP, scene->preop);
+ // TODO: SHOWMSG
+ getScriptFunctionScene(INSOP, scene->insop);
+ getScriptFunctionScene(WEPDWN, scene->wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->scnscr);
+ getScriptFunctionScene(NXTFRM, scene->nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->nxtscn);
+ for (size_t j = 0; j < scene->zones.size(); j++) {
+ Zone *zone = scene->zones[j];
+ getScriptFunctionZonePtrFb(zone->ptrfb);
+ for (size_t k = 0; k < zone->rects.size(); k++) {
+ getScriptFunctionRectHit(zone->rects[k].rectHit);
+ }
+ }
+ }
+}
+
+JRScriptFunctionPoint GameJohnnyRock::getScriptFunctionZonePtrFb(Common::String name) {
+ JRScriptFunctionPointMap::iterator it = _zonePtrFb.find(name);
+ if (it != _zonePtrFb.end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find zonePtrFb function: %s", name.c_str());
+ }
+}
+
+JRScriptFunctionRect GameJohnnyRock::getScriptFunctionRectHit(Common::String name) {
+ JRScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ if (it != _rectHitFuncs.end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find rectHit function: %s", name.c_str());
+ }
+}
+
+JRScriptFunctionScene GameJohnnyRock::getScriptFunctionScene(SceneFuncType type, Common::String name) {
+ JRScriptFunctionSceneMap *functionMap;
+ switch (type) {
+ case PREOP:
+ functionMap = &_scenePreOps;
+ break;
+ case SHOWMSG:
+ functionMap = &_sceneShowMsg;
+ break;
+ case INSOP:
+ functionMap = &_sceneInsOps;
+ break;
+ case WEPDWN:
+ functionMap = &_sceneWepDwn;
+ break;
+ case SCNSCR:
+ functionMap = &_sceneScnScr;
+ break;
+ case NXTFRM:
+ functionMap = &_sceneNxtFrm;
+ break;
+ case NXTSCN:
+ functionMap = &_sceneNxtScn;
+ break;
+ default:
+ error("Unkown scene script type: %u", type);
+ break;
+ }
+ JRScriptFunctionSceneMap::iterator it;
+ it = functionMap->find(name);
+ if (it != functionMap->end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find scene type %u function: %s", type, name.c_str());
+ }
+}
+
+void GameJohnnyRock::callScriptFunctionZonePtrFb(Common::String name, Common::Point *point) {
+ JRScriptFunctionPoint function = getScriptFunctionZonePtrFb(name);
+ function(point);
+}
+
+void GameJohnnyRock::callScriptFunctionRectHit(Common::String name, Rect *rect) {
+ JRScriptFunctionRect function = getScriptFunctionRectHit(name);
+ function(rect);
+}
+
+void GameJohnnyRock::callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene) {
+ JRScriptFunctionScene function = getScriptFunctionScene(type, name);
+ function(scene);
+}
+
+Common::Error GameJohnnyRock::run() {
+ init();
+ _NewGame();
+ _cur_scene = _startscene;
+ Common::String oldscene;
+ while (!_vm->shouldQuit()) {
+ _leftDown = false;
+ oldscene = _cur_scene;
+ _SetFrame();
+ _fired = false;
+ Scene *scene = _sceneInfo->findScene(_cur_scene);
+ if (!loadScene(scene)) {
+ error("Cannot find scene %s in libfile", scene->name.c_str());
+ }
+ Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
+ g_system->getMixer()->stopHandle(_sceneAudioHandle);
+ g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ _paletteDirty = true;
+ _nextFrameTime = _GetMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->preop, scene);
+ _currentFrame = _GetFrame(scene);
+ while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
+ _UpdateMouse();
+ // TODO: call scene->messageFunc
+ callScriptFunctionScene(INSOP, scene->insop, scene);
+ _holster = _WeaponDown();
+ if (_holster) {
+ callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ }
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ if (!_holster) {
+ Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ if (hitGlobalRect != nullptr) {
+ callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
+ } else {
+ if (_shots > 0) {
+ if (!_debug_unlimitedAmmo) {
+ _shots--;
+ }
+ _UpdateStat();
+ Rect *hitRect = nullptr;
+ Zone *hitSceneZone = _CheckZonesV1(scene, hitRect, &firedCoords);
+ if (hitSceneZone != nullptr) {
+ callScriptFunctionZonePtrFb(hitSceneZone->ptrfb, &firedCoords);
+ callScriptFunctionRectHit(hitRect->rectHit, hitRect);
+ } else {
+ _default_bullethole(&firedCoords);
+ }
+ } else {
+ _PlaySound(_emptySound);
+ _whichGun = 9;
+ }
+ }
+ }
+ }
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ }
+ _DisplayScore();
+ _MoveMouse();
+ if (_pauseTime > 0) {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ } else {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ }
+ if (_videoDecoder->getCurrentFrame() == 0) {
+ _videoDecoder->getNextFrame();
+ }
+ int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ if (remainingMillis < 10) {
+ if (_videoDecoder->getCurrentFrame() > 0) {
+ _videoDecoder->getNextFrame();
+ }
+ remainingMillis = _nextFrameTime - _GetMsTime();
+ _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ }
+ if (remainingMillis > 0) {
+ if (remainingMillis > 15) {
+ remainingMillis = 15;
+ }
+ g_system->delayMillis(remainingMillis);
+ }
+ _currentFrame = _GetFrame(scene);
+ updateScreen();
+ }
+ // frame limit reached or scene changed, prepare for next scene
+ _hadPause = false;
+ _pauseTime = 0;
+ if (_ret_scene != "") {
+ _cur_scene = _ret_scene;
+ _ret_scene = "";
+ }
+ if (_sub_scene != "") {
+ _ret_scene = _sub_scene;
+ _sub_scene = "";
+ }
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ if (_cur_scene == "") {
+ _vm->quitGame();
+ }
+ }
+ _RemoveCursorTimer();
+ return Common::kNoError;
+}
+
+bool GameJohnnyRock::__Fired(Common::Point *point) {
+ pollEvents();
+ _fired = false;
+ if (!_leftDown) {
+ _buttonDown = false;
+ return false;
+ }
+ if (_leftDown && !_inMenu) {
+ _leftDown = true;
+ }
+ if (_buttonDown) {
+ if (_thisGameTimer - _mach_gun_timer > 3) {
+ _buttonDown = false;
+ _mgun_cnt++;
+ if (_mgun_cnt > 5) {
+ _mgun_cnt = 0;
+ _leftDown = false;
+ }
+ }
+ return false;
+ }
+ _fired = true;
+ point->x = _mousePos.x;
+ point->y = _mousePos.y;
+ _mach_gun_timer = _thisGameTimer;
+ _buttonDown = true;
+ return true;
+}
+
+void GameJohnnyRock::_NewGame() {
+ _game_money = 2000;
+ _shots = 400;
+ _score = 0;
+ _holster = false;
+ _UpdateStat();
+ _ret_scene = "";
+ _sub_scene = "";
+}
+
+void GameJohnnyRock::_ResetParams() {
+ _sub_scene = "";
+ _money_scene = "";
+ _this_map = _rnd->getRandomNumber(2);
+ _clues = 0;
+ _got_this_number = 0;
+ _got_this_clue = 0;
+ _this_clue = 0;
+ _office = 0;
+ _casino = 0;
+ _pool_hall = 0;
+ _warehouse = 0;
+ _garage = 0;
+ _mansion = 0;
+ _did_continue = 0;
+ _this_difficulty = _difficulty - 1;
+ _casino_type = _rnd->getRandomNumber(1);
+ _pool_hall_type = _rnd->getRandomNumber(2);
+ _warehouse_type = _rnd->getRandomNumber(2);
+ _garage_type = _rnd->getRandomNumber(1);
+ _map_timeout = 0;
+ _ammo_again = 0;
+ _combinations[0] = _rnd->getRandomNumber(5);
+ _combinations[1] = _rnd->getRandomNumber(5);
+ _combinations[2] = _rnd->getRandomNumber(5);
+ _combinations[3] = _rnd->getRandomNumber(5);
+ _who_did_it = _rnd->getRandomNumber(3);
+ _in_warehouse = 0;
+ _office_count = 0;
+ _had_go_to_mansion = 0;
+ _random_place_bits = 0;
+ for (uint8 i = 0; i < 5; i++) {
+ // this assigns places from _random_places
+ uint16 picked = _pick_bits(&_random_place_bits, 6);
+ _entrance_index[i] = picked;
+ }
+ _random_place_bits = 0;
+ for (uint8 i = 5; i < 19; i++) {
+ // this assigns places from _random_places_mr
+ uint16 picked = _pick_bits(&_random_place_bits, 8);
+ _entrance_index[i] = picked;
+ }
+ _max_repeat = _this_difficulty + 4;
+ _repeat_random_place = 0;
+ _got_to = 0;
+ _UpdateStat();
+}
+
+void GameJohnnyRock::_OutShots() {
+ _shots = 400;
+ _score = 0;
+ _holster = false;
+ _UpdateStat();
+}
+
+void GameJohnnyRock::_DoMenu() {
+ uint32 startTime = _GetMsTime();
+ _RestoreCursor();
+ _DoCursor();
+ _inMenu = true;
+ _MoveMouse();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+ _ShowDifficulty(_difficulty, false);
+ while (_inMenu && !_vm->shouldQuit()) {
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ Rect *hitMenuRect = _CheckZone(_submenzone, &firedCoords);
+ if (hitMenuRect != nullptr) {
+ callScriptFunctionRectHit(hitMenuRect->rectHit, hitMenuRect);
+ }
+ }
+ _leftDown = false;
+ if (_difficulty != _oldDifficulty) {
+ _ChangeDifficulty(_difficulty);
+ }
+ g_system->delayMillis(15);
+ updateScreen();
+ }
+ _RestoreCursor();
+ _DoCursor();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ if (_hadPause) {
+ unsigned long endTime = _GetMsTime();
+ unsigned long timeDiff = endTime - startTime;
+ _pauseTime += timeDiff;
+ _nextFrameTime += timeDiff;
+ }
+}
+
+void GameJohnnyRock::_UpdateStat() {
+ if (_score != _oldScore) {
+ _oldScore = _score;
+ Common::String buffer = Common::String::format("%05d", _score);
+ for (uint8 i = 0; i < 5; i++) {
+ uint8 digit = buffer[i] - '0';
+ AlgGraphics::drawImage(_screen, &(*_numbers)[digit], (i * 7) + 0x7D, 0xBE);
+ }
+ }
+ if (_game_money != _oldgame_money) {
+ _oldgame_money = _game_money;
+ Common::String buffer = Common::String::format("%04d", _game_money < 0 ? 0 : _game_money);
+ for (uint8 i = 0; i < 4; i++) {
+ uint8 digit = buffer[i] - '0';
+ AlgGraphics::drawImage(_screen, &(*_numbers)[digit], (i * 7) + 0x43, 0xBE);
+ }
+ }
+ if (_shots != _oldShots) {
+ _oldShots = _shots;
+ Common::String buffer = Common::String::format("%04d", _shots);
+ for (uint8 i = 0; i < 4; i++) {
+ uint8 digit = buffer[i] - '0';
+ AlgGraphics::drawImage(_screen, &(*_numbers)[digit], (i * 7) + 0x10A, 0xBE);
+ }
+ }
+ AlgGraphics::drawImage(_screen, &(*_difficultyIcon)[_difficulty - 1], 0xBA, 0xBE);
+}
+
+void GameJohnnyRock::_DisplayScore() {
+ _UpdateStat();
+}
+
+void GameJohnnyRock::_ShowDifficulty(uint8 newDifficulty, bool updateCursor) {
+ // reset menu screen
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+ AlgGraphics::drawImageCentered(_screen, &_levelIcon, _diffpos[newDifficulty][0], _diffpos[newDifficulty][1]);
+ if (updateCursor) {
+ _DoCursor();
+ }
+}
+
+void GameJohnnyRock::_ChangeDifficulty(uint8 newDifficulty) {
+ if (newDifficulty == _oldDifficulty) {
+ return;
+ }
+ _ShowDifficulty(newDifficulty, true);
+ Game::_AdjustDifficulty(newDifficulty, _oldDifficulty);
+ _oldDifficulty = newDifficulty;
+ _difficulty = newDifficulty;
+}
+
+void GameJohnnyRock::_DoCursor() {
+ _oldWhichGun = _whichGun;
+}
+
+void GameJohnnyRock::_UpdateMouse() {
+ if (_oldWhichGun != _whichGun) {
+ Graphics::PixelFormat pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
+ Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ CursorMan.popAllCursors();
+ uint16 hotspotX = (cursor->w / 2);
+ uint16 hotspotY = (cursor->h / 2);
+ if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
+ cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
+ cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
+ }
+ CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0, false, &pixelFormat);
+ CursorMan.showMouse(true);
+ _oldWhichGun = _whichGun;
+ }
+}
+
+void GameJohnnyRock::_MoveMouse() {
+ if (_inMenu) {
+ if (_mousePos.y > 0xB7) {
+ _mousePos.y = 0xB7;
+ }
+ _whichGun = 8;
+ } else {
+ if (_mousePos.y > 0xBC) {
+ _whichGun = 6;
+ } else if (_whichGun > 5) {
+ _whichGun = 0;
+ }
+ }
+ _UpdateMouse();
+}
+
+bool GameJohnnyRock::_WeaponDown() {
+ if (_rightDown && _mousePos.y >= 0xBC && _mousePos.x >= 0x37) {
+ return true;
+ }
+ return false;
+}
+
+bool GameJohnnyRock::_SaveState() {
+ Common::OutSaveFile *outSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(outSaveFile = g_system->getSavefileManager()->openForSaving(saveFileName))) {
+ warning("Can't create file '%s', game not saved", saveFileName.c_str());
+ return false;
+ }
+ outSaveFile->writeUint32BE(MKTAG('A', 'L', 'G', 'S')); // header
+ outSaveFile->writeByte(0); // version, unused for now
+ outSaveFile->writeUint16LE(_total_dies);
+ outSaveFile->writeSint16LE(_game_money);
+ outSaveFile->writeUint16LE(_ammo_again);
+ outSaveFile->writeUint16LE(_map_timeout);
+ outSaveFile->writeByte(_lucky_number);
+ outSaveFile->writeByte(_this_map);
+ outSaveFile->writeUint16LE(_clues);
+ outSaveFile->writeUint16LE(_place_bits);
+ outSaveFile->writeByte(_random_count);
+ outSaveFile->writeUint16LE(_doctor_bits);
+ outSaveFile->writeUint16LE(_undertaker_bits);
+ for (uint8 i = 0; i < 4; i++) {
+ outSaveFile->writeByte(_clue_table[i]);
+ }
+ outSaveFile->writeUint16LE(_this_clue);
+ outSaveFile->writeByte(_got_this_number);
+ outSaveFile->writeByte(_casino);
+ outSaveFile->writeByte(_pool_hall);
+ outSaveFile->writeByte(_warehouse);
+ outSaveFile->writeByte(_garage);
+ outSaveFile->writeByte(_office);
+ outSaveFile->writeByte(_casino_type);
+ outSaveFile->writeByte(_pool_hall_type);
+ outSaveFile->writeByte(_warehouse_type);
+ outSaveFile->writeByte(_garage_type);
+ outSaveFile->writeByte(_mansion);
+ outSaveFile->writeByte(_in_warehouse);
+ outSaveFile->writeByte(_in_office);
+ outSaveFile->writeUint16LE(_got_to);
+ for (uint8 i = 0; i < 20; i++) {
+ outSaveFile->writeUint16LE(_entrance_index[i]);
+ }
+ for (uint8 i = 0; i < 10; i++) {
+ outSaveFile->writeUint16LE(_random_scenes_index[i]);
+ }
+ for (uint8 i = 0; i < 4; i++) {
+ outSaveFile->writeByte(_combinations[i]);
+ }
+ outSaveFile->writeByte(_who_did_it);
+ outSaveFile->writeByte(_had_go_to_mansion);
+ outSaveFile->writeUint16LE(_office_count);
+ outSaveFile->writeUint16LE(_random_place_bits);
+ outSaveFile->writeByte(_max_random_count);
+ outSaveFile->writeUint16LE(_goto_after_random);
+ outSaveFile->writeUint16LE(_repeat_random_place);
+ outSaveFile->writeUint16LE(_max_repeat);
+ outSaveFile->writeUint16LE(_got_this_clue);
+ outSaveFile->writeUint16LE(_did_continue);
+ outSaveFile->writeUint16LE(_this_game_time);
+ outSaveFile->writeUint16LE(_shots);
+ outSaveFile->writeSint32LE(_score);
+ outSaveFile->writeByte(_holster);
+ outSaveFile->writeByte(_difficulty);
+ outSaveFile->writeByte(_this_difficulty);
+ outSaveFile->writeString(_money_scene);
+ outSaveFile->writeByte(0);
+ outSaveFile->writeString(_cur_scene);
+ outSaveFile->writeByte(0);
+ outSaveFile->writeString(_sub_scene);
+ outSaveFile->writeByte(0);
+ outSaveFile->writeString(_ret_scene);
+ outSaveFile->writeByte(0);
+ outSaveFile->writeByte(_random_scenes_savestate_index);
+ outSaveFile->finalize();
+ delete outSaveFile;
+ return true;
+}
+
+bool GameJohnnyRock::_LoadState() {
+ Common::InSaveFile *inSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(inSaveFile = g_system->getSavefileManager()->openForLoading(saveFileName))) {
+ debug("Can't load file '%s', game not loaded", saveFileName.c_str());
+ return false;
+ }
+ uint32 header = inSaveFile->readUint32BE();
+ if (header != MKTAG('A', 'L', 'G', 'S')) {
+ warning("Unkown save file, header: %d", header);
+ return false;
+ }
+ inSaveFile->skip(1); // version, unused for now
+ _total_dies = inSaveFile->readUint16LE();
+ _game_money = inSaveFile->readSint16LE();
+ _ammo_again = inSaveFile->readUint16LE();
+ _map_timeout = inSaveFile->readUint16LE();
+ _lucky_number = inSaveFile->readByte();
+ _this_map = inSaveFile->readByte();
+ _clues = inSaveFile->readUint16LE();
+ _place_bits = inSaveFile->readUint16LE();
+ _random_count = inSaveFile->readByte();
+ _doctor_bits = inSaveFile->readUint16LE();
+ _undertaker_bits = inSaveFile->readUint16LE();
+ for (uint8 i = 0; i < 4; i++) {
+ _clue_table[i] = inSaveFile->readByte();
+ }
+ _this_clue = inSaveFile->readUint16LE();
+ _got_this_number = inSaveFile->readByte();
+ _casino = inSaveFile->readByte();
+ _pool_hall = inSaveFile->readByte();
+ _warehouse = inSaveFile->readByte();
+ _garage = inSaveFile->readByte();
+ _office = inSaveFile->readByte();
+ _casino_type = inSaveFile->readByte();
+ _pool_hall_type = inSaveFile->readByte();
+ _warehouse_type = inSaveFile->readByte();
+ _garage_type = inSaveFile->readByte();
+ _mansion = inSaveFile->readByte();
+ _in_warehouse = inSaveFile->readByte();
+ _in_office = inSaveFile->readByte();
+ _got_to = inSaveFile->readUint16LE();
+ for (uint8 i = 0; i < 20; i++) {
+ _entrance_index[i] = inSaveFile->readUint16LE();
+ }
+ for (uint8 i = 0; i < 10; i++) {
+ _random_scenes_index[i] = inSaveFile->readUint16LE();
+ }
+ for (uint8 i = 0; i < 4; i++) {
+ _combinations[i] = inSaveFile->readByte();
+ }
+ _who_did_it = inSaveFile->readByte();
+ _had_go_to_mansion = inSaveFile->readByte();
+ _office_count = inSaveFile->readUint16LE();
+ _random_place_bits = inSaveFile->readUint16LE();
+ _max_random_count = inSaveFile->readByte();
+ _goto_after_random = inSaveFile->readUint16LE();
+ _repeat_random_place = inSaveFile->readUint16LE();
+ _max_repeat = inSaveFile->readUint16LE();
+ _got_this_clue = inSaveFile->readUint16LE();
+ _did_continue = inSaveFile->readUint16LE();
+ _this_game_time = inSaveFile->readUint16LE();
+ _shots = inSaveFile->readUint16LE();
+ _score = inSaveFile->readSint32LE();
+ _holster = inSaveFile->readByte();
+ _difficulty = inSaveFile->readByte();
+ _this_difficulty = inSaveFile->readByte();
+ _money_scene = inSaveFile->readString();
+ _cur_scene = inSaveFile->readString();
+ _sub_scene = inSaveFile->readString();
+ _ret_scene = inSaveFile->readString();
+ _random_scenes_savestate_index = inSaveFile->readByte();
+ delete inSaveFile;
+ // find out where _random_scenes should point
+ uint16 placeIndex = _entrance_index[_random_scenes_savestate_index];
+ if (_random_scenes_savestate_index < 5) {
+ _random_scenes = _random_places[placeIndex];
+ } else {
+ _random_scenes = _random_places_mr[placeIndex];
+ }
+ _ChangeDifficulty(_difficulty);
+ debug("lucky number: %d", (_lucky_number + 1));
+ return true;
+}
+
+void GameJohnnyRock::_DoMoneySound() {
+ _PlaySound(_skullSound);
+}
+
+// Misc game functions
+Common::String GameJohnnyRock::_NumtoScene(int n) {
+ switch (n) {
+ case 1:
+ return "scene1a";
+ case 10:
+ return "scene10a";
+ case 12:
+ return "scene12a";
+ case 14:
+ return "scene14a";
+ case 18:
+ return "scene18a";
+ case 63:
+ return "scene63a";
+ case 71:
+ return "scene71a";
+ case 120:
+ return "scn120a";
+ case 137:
+ return "scn137a";
+ default:
+ return Common::String::format("scene%d", n);
+ }
+}
+
+uint16 GameJohnnyRock::_ScenetoNum(Common::String sceneName) {
+ Common::String temp;
+ uint16 index = 4;
+ if (sceneName[index] == 'e') {
+ index++;
+ }
+ while (sceneName[index] != 'a' && sceneName[index] != 'b' && sceneName[index] != 'c' && sceneName[index] != '\0') {
+ temp += sceneName[index];
+ index++;
+ if (index >= sceneName.size()) {
+ break;
+ }
+ }
+ return atoi(temp.c_str());
+}
+
+void GameJohnnyRock::_default_bullethole(Common::Point *point) {
+ if (point->x >= 14 && point->x <= 306 && point->y >= 5 && point->y <= 169) {
+ _RestoreCursor();
+ uint16 targetX = point->x - _videoPosX;
+ uint16 targetY = point->y - _videoPosY;
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ _DoCursor();
+ _shotFired = true;
+ _DoShot();
+ }
+}
+
+uint16 GameJohnnyRock::_pick_bits(uint16 *bits, uint8 max) {
+ // reset bits if full
+ if (*bits == (0xFFFF >> (16 - max))) {
+ *bits = 0;
+ }
+ uint8 random = _rnd->getRandomNumber(max - 1);
+ // find first unused bit position
+ while (*bits & (1 << random)) {
+ random++;
+ if (random >= max) {
+ random = 0;
+ }
+ }
+ *bits |= (1 << random);
+ return random;
+}
+
+uint16 GameJohnnyRock::_pick_random_place(uint8 place) {
+ _random_scenes_savestate_index = place;
+ uint16 placeIndex = _entrance_index[place];
+ if (place < 5) {
+ _random_scenes = _random_places[placeIndex];
+ } else {
+ _random_scenes = _random_places_mr[placeIndex];
+ }
+ _place_bits = 0;
+ _random_count = 0;
+ memset(&_random_scenes_index, 0, (10 * sizeof(uint16)));
+ for (uint8 i = 0; i < (_random_scenes[0] + 4); i++) {
+ _random_scenes_index[i] = _random_scenes[i];
+ }
+ if (_random_scenes[1] < 0) {
+ _max_random_count = (_this_difficulty * 2) - _random_scenes[1];
+ } else {
+ _max_random_count = _random_scenes[1];
+ }
+ uint16 index = _pick_bits(&_place_bits, _random_scenes[0]);
+ return _random_scenes[index + 4];
+}
+
+void GameJohnnyRock::_show_combination() {
+ uint16 offset = (_got_this_clue * 6) + _combinations[_got_this_clue];
+ _got_this_clue++;
+ if (_got_this_clue == 4) {
+ _mansion = 3;
+ }
+ _cur_scene = _NumtoScene(offset + 0xDB);
+}
+
+// Script functions: Zone
+void GameJohnnyRock::_zone_bullethole(Common::Point *point) {
+ _default_bullethole(point);
+}
+
+void GameJohnnyRock::_rect_shotmenu(Rect *rect) {
+ _DoMenu();
+}
+
+void GameJohnnyRock::_rect_save(Rect *rect) {
+ if(_SaveState()) {
+ _DoSaveSound();
+ }
+}
+
+void GameJohnnyRock::_rect_load(Rect *rect) {
+ if(_LoadState()) {
+ _DoLoadSound();
+ }
+}
+
+void GameJohnnyRock::_rect_continue(Rect *rect) {
+ _inMenu = 0;
+ _fired = 0;
+ if (_game_money < 0) {
+ _NewGame();
+ _ret_scene = "";
+ _sub_scene = "";
+ if (_in_office) {
+ _cur_scene = _NumtoScene(_in_office);
+ } else {
+ _cur_scene = _NumtoScene(_this_map + 174);
+ }
+ _did_continue++;
+ }
+ if (_shots <= 0) {
+ _OutShots();
+ _did_continue++;
+ }
+}
+
+void GameJohnnyRock::_rect_start(Rect *rect) {
+ _inMenu = 0;
+ _fired = 0;
+ _this_difficulty = 0;
+ Scene *scene = _sceneInfo->findScene(_startscene);
+ if (scene->nxtscn == "DRAWGUN") {
+ callScriptFunctionScene(NXTSCN, "DRAWGUN", scene);
+ }
+ _cur_scene = _startscene;
+ _ResetParams();
+ _NewGame();
+ _UpdateStat();
+}
+
+void GameJohnnyRock::_rect_killinnocent(Rect *rect) {
+ _in_office = _ScenetoNum(_cur_scene);
+ if (_in_office >= 0x13) {
+ _in_office = 0;
+ }
+ if (!_debug_godMode) {
+ _game_money -= 400;
+ }
+ if (_game_money < 0) {
+ _sub_scene = "scene358";
+ _ret_scene = "";
+ _cur_scene = "scene151";
+ } else {
+ switch (_rnd->getRandomNumber(2)) {
+ case 0:
+ _cur_scene = "scene151";
+ break;
+ case 1:
+ _cur_scene = "scene152";
+ break;
+ case 2:
+ _cur_scene = "scene153";
+ break;
+ }
+ }
+}
+
+void GameJohnnyRock::_rect_selectcasino(Rect *rect) {
+ _ret_scene = "";
+ if (_mansion == 5 && _who_did_it == 1) {
+ _repeat_random_place = _max_repeat;
+ _goto_after_random = 0xF5;
+ _cur_scene = _NumtoScene(_pick_random_place(_max_repeat + 5));
+ } else if (_casino == 0) {
+ if (_got_to & 1) {
+ _cur_scene = "scene19";
+ } else {
+ _goto_after_random = 0x13;
+ _cur_scene = _NumtoScene(_pick_random_place(0));
+ }
+ } else if (_casino == 1 || _casino == 3) {
+ _cur_scene = "scene44";
+ } else {
+ _casino = 3;
+ if (_rnd->getRandomBit()) { // original: (_this_game_time & 1) == 0
+ _cur_scene = "scene64";
+ } else {
+ _cur_scene = "scene65";
+ }
+ }
+}
+
+void GameJohnnyRock::_rect_selectpoolhall(Rect *rect) {
+ _ret_scene = "";
+ if (_mansion == 5 && _who_did_it == 0) {
+ _repeat_random_place = _max_repeat;
+ _goto_after_random = 0xF7;
+ _cur_scene = _NumtoScene(_pick_random_place(_max_repeat + 5));
+ } else if (_pool_hall == 0) {
+ if (_got_to & 2) {
+ _cur_scene = "scene66";
+ } else {
+ _goto_after_random = 0x42;
+ _cur_scene = _NumtoScene(_pick_random_place(1));
+ }
+ } else if (_pool_hall == 1 || _pool_hall == 3) {
+ _cur_scene = "scene82";
+ } else {
+ _pool_hall = 3;
+ _cur_scene = "scene89";
+ }
+}
+
+void GameJohnnyRock::_rect_selectwarehouse(Rect *rect) {
+ _ret_scene = "";
+ if (_mansion == 5 && _who_did_it == 2) {
+ _repeat_random_place = _max_repeat;
+ _goto_after_random = 0xF9;
+ _cur_scene = _NumtoScene(_pick_random_place(_max_repeat + 5));
+ } else if (_warehouse == 0) {
+ if (_in_warehouse < 2) {
+ if (_got_to & 4) {
+ _cur_scene = "scene90";
+ } else {
+ _in_warehouse = 1;
+ _goto_after_random = 0x5A;
+ _cur_scene = _NumtoScene(_pick_random_place(2));
+ }
+ } else if (_in_warehouse == 2) {
+ _cur_scene = "scene93";
+ } else if (_in_warehouse == 3) {
+ _cur_scene = "scene119";
+ }
+ } else if (_warehouse == 1 || _warehouse == 3) {
+ _cur_scene = "scene122";
+ } else {
+ _warehouse = 3;
+ _cur_scene = "scene121";
+ }
+}
+
+void GameJohnnyRock::_rect_selectgarage(Rect *rect) {
+ _ret_scene = "";
+ if (_mansion == 5 && _who_did_it == 3) {
+ _repeat_random_place = _max_repeat;
+ _goto_after_random = 0xFB;
+ _cur_scene = _NumtoScene(_pick_random_place(_max_repeat + 5));
+ } else if (_garage == 0) {
+ if (_got_to & 8) {
+ _cur_scene = "scene123";
+ } else {
+ _goto_after_random = 0x7B;
+ _cur_scene = _NumtoScene(_pick_random_place(3));
+ }
+ } else if (_garage == 1 || _garage == 3) {
+ _cur_scene = "scene138";
+ } else {
+ _garage = 3;
+ _cur_scene = "scene139";
+ }
+}
+
+void GameJohnnyRock::_rect_selectmansion(Rect *rect) {
+ _place_bits = 0;
+ _random_count = 1;
+ _ret_scene = "";
+ if (_mansion == 1) {
+ uint16 picked = _pick_bits(&_place_bits, 5);
+ _cur_scene = _NumtoScene(0xB8 + (picked * 2));
+ } else if (_mansion == 2) {
+ _cur_scene = "scene194";
+ } else if (_mansion == 3) {
+ _cur_scene = "scene207";
+ } else if (_mansion == 4) {
+ _got_this_number = 0;
+ _cur_scene = "scene212";
+ } else if (_mansion == 5) {
+ _cur_scene = "scene243";
+ } else {
+ if (_garage == 0 || _casino == 0 || _pool_hall == 0 || _warehouse == 0) {
+ _cur_scene = "scene243";
+ } else if (_got_to & 0x10) {
+ _cur_scene = "scene180";
+ } else {
+ _goto_after_random = 0xB4;
+ _cur_scene = _NumtoScene(_pick_random_place(4));
+ }
+ }
+}
+
+void GameJohnnyRock::_rect_selectammo(Rect *rect) {
+ _ret_scene = "";
+ if (_game_money >= 100) {
+ if (!_debug_godMode) {
+ _game_money -= 100;
+ }
+ _shots += 200;
+ _ammo_again = 0;
+ _DoMoneySound();
+ _cur_scene = "scene178";
+ } else {
+ _ammo_again++;
+ if (_ammo_again >= 2) {
+ _cur_scene = "scene243";
+ } else {
+ _cur_scene = "scene179";
+ }
+ }
+}
+
+void GameJohnnyRock::_rect_selectoffice(Rect *rect) {
+ _ret_scene = "";
+ if (!_office) {
+ _office = 1;
+ _cur_scene = "scene168";
+ } else {
+ if (_rnd->getRandomBit()) { // original: _this_game_time & 1
+ _cur_scene = "scene243";
+ } else {
+ _cur_scene = "scene262";
+ }
+ }
+}
+
+void GameJohnnyRock::_shotclue(uint8 clue) {
+ if (_clue_table[_got_this_clue] == clue) {
+ _show_combination();
+ } else {
+ _got_this_clue = 0;
+ _cur_scene = "scene374";
+ }
+}
+
+void GameJohnnyRock::_rect_shotmanbust(Rect *rect) {
+ _shotclue(0);
+}
+
+void GameJohnnyRock::_rect_shotwomanbust(Rect *rect) {
+ _shotclue(1);
+}
+
+void GameJohnnyRock::_rect_shotbluevase(Rect *rect) {
+ _shotclue(2);
+}
+
+void GameJohnnyRock::_rect_shotcat(Rect *rect) {
+ _shotclue(3);
+}
+
+void GameJohnnyRock::_rect_shotindian(Rect *rect) {
+ _shotclue(4);
+}
+
+void GameJohnnyRock::_rect_shotplate(Rect *rect) {
+ _shotclue(5);
+}
+
+void GameJohnnyRock::_rect_shotbluedresspic(Rect *rect) {
+ _shotclue(6);
+}
+
+void GameJohnnyRock::_rect_shotmodernpic(Rect *rect) {
+ _shotclue(7);
+}
+
+void GameJohnnyRock::_rect_shotmonalisa(Rect *rect) {
+ _shotclue(8);
+}
+
+void GameJohnnyRock::_rect_shotgwashington(Rect *rect) {
+ _shotclue(9);
+}
+
+void GameJohnnyRock::_rect_shotboyinredpic(Rect *rect) {
+ _shotclue(10);
+}
+
+void GameJohnnyRock::_rect_shotcoatofarms(Rect *rect) {
+ _shotclue(11);
+}
+
+void GameJohnnyRock::_shotcombination(uint8 combination, bool combinationB) {
+ if (_combinations[_got_this_number] == combination) {
+ _got_this_number++;
+ if (_got_this_number >= 4) {
+ _mansion = 5;
+ _cur_scene = _NumtoScene(_who_did_it + 0xD7);
+ } else {
+ if (combinationB) {
+ _cur_scene = "scene213";
+ } else {
+ _cur_scene = "scene214";
+ }
+ }
+ } else {
+ _got_this_number = 0;
+ _cur_scene = "scene376";
+ }
+}
+
+void GameJohnnyRock::_rect_shotcombinationA0(Rect *rect) {
+ _shotcombination(0, false);
+}
+
+void GameJohnnyRock::_rect_shotcombinationA1(Rect *rect) {
+ _shotcombination(1, false);
+}
+
+void GameJohnnyRock::_rect_shotcombinationA2(Rect *rect) {
+ _shotcombination(2, false);
+}
+
+void GameJohnnyRock::_rect_shotcombinationA3(Rect *rect) {
+ _shotcombination(3, false);
+}
+
+void GameJohnnyRock::_rect_shotcombinationA4(Rect *rect) {
+ _shotcombination(4, false);
+}
+
+void GameJohnnyRock::_rect_shotcombinationA5(Rect *rect) {
+ _shotcombination(5, false);
+}
+
+void GameJohnnyRock::_rect_shotcombinationB0(Rect *rect) {
+ _shotcombination(0, true);
+}
+
+void GameJohnnyRock::_rect_shotcombinationB1(Rect *rect) {
+ _shotcombination(1, true);
+}
+
+void GameJohnnyRock::_rect_shotcombinationB2(Rect *rect) {
+ _shotcombination(2, true);
+}
+
+void GameJohnnyRock::_rect_shotcombinationB3(Rect *rect) {
+ _shotcombination(3, true);
+}
+
+void GameJohnnyRock::_rect_shotcombinationB4(Rect *rect) {
+ _shotcombination(4, true);
+}
+
+void GameJohnnyRock::_rect_shotcombinationB5(Rect *rect) {
+ _shotcombination(5, true);
+}
+
+void GameJohnnyRock::_shotluckynumber(uint8 number) {
+ if (_lucky_number != number || _cur_scene == _money_scene) {
+ return;
+ }
+ _DoMoneySound();
+ _game_money += 100;
+ _score += 500;
+ _money_scene = _cur_scene;
+}
+
+void GameJohnnyRock::_rect_shotluckynum0(Rect *rect) {
+ _shotluckynumber(0);
+}
+
+void GameJohnnyRock::_rect_shotluckynum1(Rect *rect) {
+ _shotluckynumber(1);
+}
+
+void GameJohnnyRock::_rect_shotluckynum2(Rect *rect) {
+ _shotluckynumber(2);
+}
+
+void GameJohnnyRock::_rect_shotluckynum3(Rect *rect) {
+ _shotluckynumber(3);
+}
+
+void GameJohnnyRock::_rect_shotluckynum4(Rect *rect) {
+ _shotluckynumber(4);
+}
+
+void GameJohnnyRock::_rect_shotluckynum5(Rect *rect) {
+ _shotluckynumber(5);
+}
+
+// Script functions: Scene PreOps
+
+// Script functions: Scene Scene InsOps
+void GameJohnnyRock::_scene_iso_shootpast(Scene *scene) {
+ if (_fired) {
+ if (_ret_scene != "") {
+ _cur_scene = _ret_scene;
+ _ret_scene = "";
+ } else if (_sub_scene != "") {
+ _cur_scene = _sub_scene;
+ _sub_scene = "";
+ } else {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ }
+}
+
+void GameJohnnyRock::_scene_iso_spause(Scene *scene) {
+ _scene_iso_shootpast(scene);
+ _scene_iso_pause(scene);
+}
+
+void GameJohnnyRock::_scene_iso_gotocasino(Scene *scene) {
+ _got_to |= 1;
+ _scene_iso_shootpast(scene);
+}
+
+void GameJohnnyRock::_scene_iso_gotopoolh(Scene *scene) {
+ _got_to |= 2;
+ _scene_iso_shootpast(scene);
+}
+
+void GameJohnnyRock::_scene_iso_gotowarehse(Scene *scene) {
+ _got_to |= 4;
+}
+
+void GameJohnnyRock::_scene_iso_inwarehse2(Scene *scene) {
+ _in_warehouse = 2;
+ _scene_iso_shootpast(scene);
+}
+
+void GameJohnnyRock::_scene_iso_inwarehse3(Scene *scene) {
+ _in_warehouse = 3;
+ _scene_iso_shootpast(scene);
+}
+
+void GameJohnnyRock::_scene_iso_gotogarage(Scene *scene) {
+ _got_to |= 8;
+ _scene_iso_shootpast(scene);
+}
+
+void GameJohnnyRock::_scene_iso_gotomansion(Scene *scene) {
+ _got_to |= 0x10;
+}
+
+void GameJohnnyRock::_scene_iso_inmansion1(Scene *scene) {
+ _mansion = 1;
+}
+
+// Script functions: Scene NxtScn
+void GameJohnnyRock::_scene_nxtscn_died(Scene *scene) {
+ uint16 sceneNum = _ScenetoNum(_cur_scene);
+ _in_office = sceneNum;
+ if (sceneNum >= 0x13) {
+ _in_office = 0;
+ }
+ _total_dies++;
+ if (!_debug_godMode) {
+ _game_money -= 400;
+ }
+ if (_game_money < 0) {
+ switch (_rnd->getRandomNumber(2)) {
+ case 0:
+ _cur_scene = "scene148";
+ break;
+ case 1:
+ _cur_scene = "scene149";
+ break;
+ case 2:
+ _cur_scene = "scene150";
+ break;
+ }
+ } else {
+ switch (_pick_bits(&_doctor_bits, 8)) {
+ case 0:
+ _cur_scene = "scene140";
+ break;
+ case 1:
+ _cur_scene = "scene141";
+ break;
+ case 2:
+ _cur_scene = "scene142";
+ break;
+ case 3:
+ _cur_scene = "scene143";
+ break;
+ case 4:
+ _cur_scene = "scene144";
+ break;
+ case 5:
+ _cur_scene = "scene145";
+ break;
+ case 6:
+ _cur_scene = "scene146";
+ break;
+ case 7:
+ _cur_scene = "scene147";
+ break;
+ }
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_bombdead(Scene *scene) {
+ uint16 sceneNum = _ScenetoNum(_cur_scene);
+ _in_office = sceneNum;
+ if (sceneNum >= 0x13) {
+ _in_office = 0;
+ }
+ _total_dies++;
+ if (!_debug_godMode) {
+ _game_money -= 400;
+ }
+ if (_game_money < 0) {
+ switch (_rnd->getRandomNumber(2)) {
+ case 0:
+ _cur_scene = "scene148";
+ break;
+ case 1:
+ _cur_scene = "scene149";
+ break;
+ case 2:
+ _cur_scene = "scene150";
+ break;
+ }
+ } else {
+ _cur_scene = "scene142";
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_pikundrtakr(Scene *scene) {
+ switch (_pick_bits(&_undertaker_bits, 3)) {
+ case 0:
+ _cur_scene = "scene154";
+ break;
+ case 1:
+ _cur_scene = "scene155";
+ break;
+ case 2:
+ _cur_scene = "scene156";
+ break;
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_callattract(Scene *scene) {
+ _ResetParams();
+ _NewGame();
+ _cur_scene = "scn354aa";
+}
+
+void GameJohnnyRock::_scene_nxtscn_pikluckno(Scene *scene) {
+ _lucky_number = _rnd->getRandomNumber(5);
+ debug("lucky number: %d", (_lucky_number + 1));
+ _cur_scene = Common::String::format("scene%d", _lucky_number + 3);
+}
+
+void GameJohnnyRock::_scene_nxtscn_pickmap(Scene *scene) {
+ Common::String nextScene;
+ if (_game_money < 0) {
+ switch (_rnd->getRandomNumber(2)) {
+ case 0:
+ _cur_scene = "scene148";
+ break;
+ case 1:
+ _cur_scene = "scene149";
+ break;
+ case 2:
+ _cur_scene = "scene150";
+ break;
+ }
+ return;
+ }
+ uint16 sceneNum = _ScenetoNum(_cur_scene);
+ if (sceneNum == 18) {
+ _in_office = 0;
+ }
+ if (_in_office) {
+ nextScene = _NumtoScene(_in_office);
+ } else if (_office_count < 10) {
+ if ((_office_count % 3) == 0) {
+ uint16 sceneNume = _office_table[_office_count / 3];
+ nextScene = _NumtoScene(sceneNume);
+ }
+ _office_count++;
+ } else if (_this_clue == 2 && !_had_go_to_mansion) {
+ if (!_did_continue) {
+ _this_difficulty++;
+ if (_this_difficulty > 7)
+ _this_difficulty = 7;
+ }
+ _had_go_to_mansion = 1;
+ if (_pool_hall) {
+ _pool_hall = 2;
+ nextScene = "scene162";
+ } else if (_casino) {
+ _casino = 2;
+ nextScene = "scene163";
+ } else if (_warehouse) {
+ _warehouse = 2;
+ nextScene = "scene165";
+ }
+ } else if (_this_clue == 3 && _had_go_to_mansion == 1) {
+ if (_total_dies < 4) {
+ _this_difficulty++;
+ if (_this_difficulty > 7)
+ _this_difficulty = 7;
+ }
+ _had_go_to_mansion = 2;
+ if (_pool_hall == 1) {
+ _pool_hall = 2;
+ nextScene = "scene162";
+ } else if (_casino == 1) {
+ _casino = 2;
+ nextScene = "scene163";
+ } else if (_warehouse == 1) {
+ _warehouse = 2;
+ nextScene = "scene165";
+ }
+ } else if (_had_go_to_mansion == 2 && _garage && _casino && _pool_hall && _warehouse) {
+ if (_total_dies < 5 || _did_continue <= 1) {
+ _this_difficulty++;
+ if (_this_difficulty > 7)
+ _this_difficulty = 7;
+ }
+ _had_go_to_mansion = 3;
+ nextScene = "scene166";
+ }
+ if(nextScene.size() > 0) {
+ _cur_scene = nextScene;
+ } else {
+ _cur_scene = _NumtoScene(_this_map + 174);
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_pickclue(Scene *scene) {
+ uint16 picked = _pick_bits(&_clues, 12);
+ _clue_table[_this_clue] = picked;
+ _this_clue++;
+ _cur_scene = _NumtoScene(picked + 0xC3);
+}
+
+void GameJohnnyRock::_scene_nxtscn_maptimeout(Scene *scene) {
+ _map_timeout++;
+ if (_map_timeout < 3) {
+ _cur_scene = "scene360";
+ } else {
+ _cur_scene = "scene262";
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_entcasino(Scene *scene) {
+ _place_bits = 0;
+ _random_count = 0;
+ uint16 sceneNum;
+ if (_casino_type != 0) {
+ sceneNum = (_pick_bits(&_place_bits, 12) * 2) + 0x14;
+ } else {
+ sceneNum = (_pick_bits(&_place_bits, 8) * 2) + 0x2D;
+ }
+ _cur_scene = _NumtoScene(sceneNum);
+}
+
+void GameJohnnyRock::_scene_nxtscn_casinowhat(Scene *scene) {
+ _random_count++;
+ uint16 maxRandom = ((_this_difficulty * 3) + 6);
+ if (_random_count > maxRandom) {
+ _casino = 1;
+ _cur_scene = "scene63a";
+ } else {
+ uint16 sceneNum;
+ if (_casino_type != 0) {
+ sceneNum = (_pick_bits(&_place_bits, 12) * 2) + 0x14;
+ } else {
+ sceneNum = (_pick_bits(&_place_bits, 8) * 2) + 0x2D;
+ }
+ _cur_scene = _NumtoScene(sceneNum);
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_entpoolhall(Scene *scene) {
+ if (_pool_hall_type == 0) {
+ _cur_scene = "scene67";
+ } else if (_pool_hall_type == 1) {
+ _cur_scene = "scene73";
+ } else {
+ _cur_scene = "scene78";
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_poolhclue(Scene *scene) {
+ _pool_hall = 1;
+ uint16 clue = _pick_bits(&_clues, 12);
+ _clue_table[_this_clue] = clue;
+ _this_clue++;
+ _cur_scene = _NumtoScene(clue + 0xC3);
+}
+
+void GameJohnnyRock::_scene_nxtscn_entwarehse(Scene *scene) {
+ if (_warehouse_type == 0) {
+ _cur_scene = "scene94";
+ } else if (_warehouse_type == 1) {
+ _cur_scene = "scene102";
+ } else {
+ _cur_scene = "scene110";
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_warehseclue(Scene *scene) {
+ _warehouse = 1;
+ uint16 clue = _pick_bits(&_clues, 12);
+ _clue_table[_this_clue] = clue;
+ _this_clue++;
+ _cur_scene = _NumtoScene(clue + 0xC3);
+}
+
+void GameJohnnyRock::_scene_nxtscn_entgarage(Scene *scene) {
+ if (_garage_type != 0) {
+ _cur_scene = "scene124";
+ } else {
+ _cur_scene = "scene131";
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_garageclue(Scene *scene) {
+ _garage = 1;
+ uint16 clue = _pick_bits(&_clues, 12);
+ _clue_table[_this_clue] = clue;
+ _this_clue++;
+ _cur_scene = _NumtoScene(clue + 0xC3);
+}
+
+void GameJohnnyRock::_scene_nxtscn_entmansion(Scene *scene) {
+ _mansion = 1;
+ _random_count++;
+ uint16 maxRandom = ((_this_difficulty * 2) + 7);
+ if (_random_count <= maxRandom) {
+ uint16 picked = _pick_bits(&_place_bits, 5);
+ _cur_scene = _NumtoScene((picked * 2) + 0xB8);
+ } else {
+ _mansion = 2;
+ _cur_scene = "scene194";
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_giveclue(Scene *scene) {
+ _score += 1000;
+ _game_money += 50;
+ _scene_nxtscn_pickmap(scene);
+}
+
+void GameJohnnyRock::_scene_nxtscn_pikflwrman(Scene *scene) {
+ if (_rnd->getRandomBit()) {
+ _cur_scene = "scene10a";
+ } else {
+ _cur_scene = "scene12a";
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_randomscene(Scene *scene) {
+ _random_count++;
+ if (_random_count <= _max_random_count) {
+ _place_bits = _pick_bits(&_place_bits, _random_scenes[0]);
+ _cur_scene = _NumtoScene(_random_scenes[_place_bits + 4]);
+ } else {
+ if (_random_scenes[2] != 0) {
+ _cur_scene = _NumtoScene(_random_scenes[2]);
+ } else if (_repeat_random_place > 0) {
+ _repeat_random_place--;
+ _max_repeat--;
+ uint16 picked = _pick_random_place(_repeat_random_place + 5);
+ _cur_scene = _NumtoScene(picked);
+ } else {
+ _cur_scene = _NumtoScene(_goto_after_random);
+ _goto_after_random = 0;
+ _place_bits = 0;
+ _random_count = 1;
+ }
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_endrandscene(Scene *scene) {
+ if (_repeat_random_place > 0) {
+ _repeat_random_place--;
+ _max_repeat--;
+ uint16 picked = _pick_random_place(_repeat_random_place + 5);
+ _cur_scene = _NumtoScene(picked);
+ } else {
+ _cur_scene = _NumtoScene(_goto_after_random);
+ _goto_after_random = 0;
+ _place_bits = 0;
+ _random_count = 1;
+ }
+}
+
+void GameJohnnyRock::_scene_nxtscn_killinnocent(Scene *scene) {
+ if (!_debug_godMode) {
+ _game_money -= 400;
+ }
+ if (_game_money < 0) {
+ _ret_scene = "scene358";
+ _cur_scene = "scene151";
+ } else {
+ switch (_rnd->getRandomNumber(2)) {
+ case 0:
+ _cur_scene = "scene151";
+ break;
+ case 1:
+ _cur_scene = "scene152";
+ break;
+ case 2:
+ _cur_scene = "scene153";
+ break;
+ }
+ }
+}
+
+// Script functions: WepDwn
+void GameJohnnyRock::_scene_default_wepdwn(Scene *scene) {
+ _inHolster = 9;
+ _whichGun = 7;
+ _UpdateMouse();
+}
+
+// Debug methods
+void GameJohnnyRock::debug_warpTo(int val) {
+ // TODO implement
+}
+
+// Debugger methods
+DebuggerJohnnyRock::DebuggerJohnnyRock(GameJohnnyRock *game) : GUI::Debugger() {
+ _game = game;
+ registerVar("drawRects", &game->_debug_drawRects);
+ registerVar("godMode", &game->_debug_godMode);
+ registerVar("unlimitedAmmo", &game->_debug_unlimitedAmmo);
+ registerCmd("warpTo", WRAP_METHOD(DebuggerJohnnyRock, cmdWarpTo));
+ registerCmd("dumpLib", WRAP_METHOD(DebuggerJohnnyRock, cmdDumpLib));
+}
+
+bool DebuggerJohnnyRock::cmdWarpTo(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: warp <int>");
+ return true;
+ } else {
+ int val = atoi(argv[1]);
+ _game->debug_warpTo(val);
+ return false;
+ }
+}
+
+bool DebuggerJohnnyRock::cmdDumpLib(int argc, const char **argv) {
+ return _game->debug_dumpLibFile();
+}
+
+} // End of namespace Alg
diff --git a/engines/alg/game_johnnyrock.h b/engines/alg/game_johnnyrock.h
new file mode 100644
index 00000000000..6c11b14454d
--- /dev/null
+++ b/engines/alg/game_johnnyrock.h
@@ -0,0 +1,288 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef ALG_GAME_JOHNNYROCK_H
+#define ALG_GAME_JOHNNYROCK_H
+
+#include "common/hashmap.h"
+#include "common/rect.h"
+
+#include "gui/debugger.h"
+
+#include "alg/game.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+typedef Common::Functor1Mem<Scene *, void, GameJohnnyRock> JRScriptFunctionScene;
+typedef Common::Functor1Mem<Rect *, void, GameJohnnyRock> JRScriptFunctionRect;
+typedef Common::Functor1Mem<Common::Point *, void, GameJohnnyRock> JRScriptFunctionPoint;
+typedef Common::HashMap<Common::String, JRScriptFunctionScene *> JRScriptFunctionSceneMap;
+typedef Common::HashMap<Common::String, JRScriptFunctionRect *> JRScriptFunctionRectMap;
+typedef Common::HashMap<Common::String, JRScriptFunctionPoint *> JRScriptFunctionPointMap;
+
+class GameJohnnyRock : public Game {
+
+ enum SceneFuncType {
+ PREOP = 1,
+ SHOWMSG = 2,
+ INSOP = 3,
+ WEPDWN = 4,
+ SCNSCR = 5,
+ NXTFRM = 6,
+ NXTSCN = 7
+ };
+
+public:
+ GameJohnnyRock(AlgEngine *vm, const ADGameDescription *desc);
+ ~GameJohnnyRock();
+ Common::Error run();
+ void debug_warpTo(int val);
+
+private:
+ void init();
+ void registerScriptFunctions();
+ void verifyScriptFunctions();
+ JRScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
+ JRScriptFunctionRect getScriptFunctionRectHit(Common::String name);
+ JRScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
+ void callScriptFunctionZonePtrFb(Common::String name, Common::Point *point);
+ void callScriptFunctionRectHit(Common::String name, Rect *rect);
+ void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
+
+ JRScriptFunctionPointMap _zonePtrFb;
+ JRScriptFunctionRectMap _rectHitFuncs;
+ JRScriptFunctionSceneMap _scenePreOps;
+ JRScriptFunctionSceneMap _sceneShowMsg;
+ JRScriptFunctionSceneMap _sceneInsOps;
+ JRScriptFunctionSceneMap _sceneWepDwn;
+ JRScriptFunctionSceneMap _sceneScnScr;
+ JRScriptFunctionSceneMap _sceneNxtFrm;
+ JRScriptFunctionSceneMap _sceneNxtScn;
+
+ // images
+ Common::Array<Graphics::Surface> *_difficultyIcon;
+ Graphics::Surface _levelIcon;
+ Graphics::Surface _bulletholeIcon;
+
+ // constants
+ const int16 _random_rooftop[6] = {2, -4, 0x104, 0x1E, 0x100, 0x102};
+ const int16 _random_theater[9] = {5, -5, 0x111, 0x1E, 0x107, 0x109, 0x10B, 0x10D, 0x10F};
+ const int16 _random_alley[10] = {6, -4, 0, 0x1E, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D};
+ const int16 _random_funeral[10] = {6, -5, 0, 0x1E, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129};
+ const int16 _random_funeral_mr[10] = {6, -5, 0x12B, 0x1E, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129};
+ const int16 _random_book[7] = {3, 5, 0, 0x1E, 0x12E, 0x130, 0x132};
+ const int16 _random_book_mr[8] = {4, 0x5, 0, 0x1E, 0x12E, 0x130, 0x132, 0x134};
+ const int16 _random_stairway[8] = {4, -3, 0, 0x1E, 0x139, 0x13B, 0x13D, 0x13F};
+ const int16 _random_hall[8] = {4, -5, 0, 0x1E, 0x141, 0x143, 0x145, 0x146};
+ const int16 _random_windows[10] = {6, -3, 0, 0x1E, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E};
+ const int16 _random_car[5] = {1, 1, 0, 0, 0x0FE};
+ const int16 _random_hall1[5] = {1, 1, 0, 0x1E, 0x148};
+ const int16 _random_elevator[5] = {1, 1, 0, 0, 0x14C};
+ const int16 _random_elevator_mr[5] = {1, 1, 0, 0, 0x151};
+ const int16 _random_baby[5] = {1, 1, 0, 0, 0x160};
+ const int16 *_random_places[6] = {_random_windows, _random_stairway, _random_car, _random_hall1, _random_elevator, _random_baby};
+ const int16 *_random_places_mr[8] = {_random_book_mr, _random_funeral_mr, _random_alley, _random_theater, _random_hall, _random_windows, _random_hall1, _random_rooftop};
+
+ const int16 _office_table[5] = {0xA7, 0x9F, 0x9E, 0x0A0, 0x0AD};
+
+ const uint16 _diffpos[4][2] = {{0, 0}, {0xCD, 0x35}, {0xD2, 0x53}, {0xD2, 0x6E}};
+
+ // gamestate
+ uint16 _total_dies = 0;
+ int16 _game_money = 0;
+ int16 _oldgame_money = 0;
+ uint16 _ammo_again = 0;
+ uint16 _map_timeout = 0;
+ uint8 _lucky_number = 0;
+ uint8 _this_map = 0;
+ uint16 _clues = 0;
+ uint16 _place_bits = 0;
+ uint8 _random_count = 0;
+ uint16 _doctor_bits = 0;
+ uint16 _undertaker_bits = 0;
+ uint16 _this_clue = 0;
+ uint8 _got_this_number = 0;
+ uint8 _casino = 0;
+ uint8 _pool_hall = 0;
+ uint8 _warehouse = 0;
+ uint8 _garage = 0;
+ uint8 _office = 0;
+ uint8 _casino_type = 0;
+ uint8 _pool_hall_type = 0;
+ uint8 _warehouse_type = 0;
+ uint8 _garage_type = 0;
+ uint8 _mansion = 0;
+ uint8 _in_warehouse = 0;
+ uint8 _in_office = 0;
+ uint16 _got_to = 0;
+ uint8 _who_did_it = 0;
+ uint8 _had_go_to_mansion = 0;
+ uint16 _office_count = 0;
+ uint16 _random_place_bits = 0;
+ uint8 _max_random_count = 0;
+ uint16 _goto_after_random = 0;
+ uint16 _repeat_random_place = 0;
+ uint16 _max_repeat = 0;
+ uint16 _got_this_clue = 0;
+ uint16 _did_continue = 0;
+ uint16 _this_game_time = 0;
+ uint8 _this_difficulty = 0;
+ uint8 _clue_table[4];
+ uint8 _combinations[4];
+ uint16 _entrance_index[20];
+ const int16 *_random_scenes = nullptr;
+ uint8 _random_scenes_savestate_index = 0;
+ uint16 _random_scenes_index[10];
+ Common::String _money_scene = "";
+ uint8 _mgun_cnt = 0;
+ uint32 _mach_gun_timer = 0;
+
+ // base functions
+ bool __Fired(Common::Point *point);
+ void _NewGame();
+ void _ResetParams();
+ void _OutShots();
+ void _DoMenu();
+ void _UpdateStat();
+ void _DisplayScore();
+ void _ShowDifficulty(uint8 newDifficulty, bool updateCursor);
+ void _ChangeDifficulty(uint8 newDifficulty);
+ void _DoCursor();
+ void _UpdateMouse();
+ void _MoveMouse();
+ bool _WeaponDown();
+ bool _SaveState();
+ bool _LoadState();
+ void _DoMoneySound();
+
+ // misc game functions
+ Common::String _NumtoScene(int n);
+ uint16 _ScenetoNum(Common::String sceneName);
+ void _default_bullethole(Common::Point *point);
+ uint16 _pick_bits(uint16 *bits, uint8 max);
+ uint16 _pick_random_place(uint8 place);
+ void _show_combination();
+ void _shotclue(uint8 clue);
+ void _shotcombination(uint8 combination, bool combinationB);
+ void _shotluckynumber(uint8 number);
+
+ // Script functions: Zone
+ void _zone_bullethole(Common::Point *point);
+
+ // Script functions: RectHit
+ void _rect_shotmenu(Rect *rect);
+ void _rect_save(Rect *rect);
+ void _rect_load(Rect *rect);
+ void _rect_continue(Rect *rect);
+ void _rect_start(Rect *rect);
+ void _rect_killinnocent(Rect *rect);
+ void _rect_selectcasino(Rect *rect);
+ void _rect_selectpoolhall(Rect *rect);
+ void _rect_selectwarehouse(Rect *rect);
+ void _rect_selectgarage(Rect *rect);
+ void _rect_selectmansion(Rect *rect);
+ void _rect_selectammo(Rect *rect);
+ void _rect_selectoffice(Rect *rect);
+ void _rect_shotmanbust(Rect *rect);
+ void _rect_shotwomanbust(Rect *rect);
+ void _rect_shotbluevase(Rect *rect);
+ void _rect_shotcat(Rect *rect);
+ void _rect_shotindian(Rect *rect);
+ void _rect_shotplate(Rect *rect);
+ void _rect_shotbluedresspic(Rect *rect);
+ void _rect_shotmodernpic(Rect *rect);
+ void _rect_shotmonalisa(Rect *rect);
+ void _rect_shotgwashington(Rect *rect);
+ void _rect_shotboyinredpic(Rect *rect);
+ void _rect_shotcoatofarms(Rect *rect);
+ void _rect_shotcombinationA0(Rect *rect);
+ void _rect_shotcombinationA1(Rect *rect);
+ void _rect_shotcombinationA2(Rect *rect);
+ void _rect_shotcombinationA3(Rect *rect);
+ void _rect_shotcombinationA4(Rect *rect);
+ void _rect_shotcombinationA5(Rect *rect);
+ void _rect_shotcombinationB0(Rect *rect);
+ void _rect_shotcombinationB1(Rect *rect);
+ void _rect_shotcombinationB2(Rect *rect);
+ void _rect_shotcombinationB3(Rect *rect);
+ void _rect_shotcombinationB4(Rect *rect);
+ void _rect_shotcombinationB5(Rect *rect);
+ void _rect_shotluckynum0(Rect *rect);
+ void _rect_shotluckynum1(Rect *rect);
+ void _rect_shotluckynum2(Rect *rect);
+ void _rect_shotluckynum3(Rect *rect);
+ void _rect_shotluckynum4(Rect *rect);
+ void _rect_shotluckynum5(Rect *rect);
+
+ // Script functions: Scene InsOps
+ void _scene_iso_shootpast(Scene *scene);
+ void _scene_iso_spause(Scene *scene);
+ void _scene_iso_gotocasino(Scene *scene);
+ void _scene_iso_gotopoolh(Scene *scene);
+ void _scene_iso_gotowarehse(Scene *scene);
+ void _scene_iso_inwarehse2(Scene *scene);
+ void _scene_iso_inwarehse3(Scene *scene);
+ void _scene_iso_gotogarage(Scene *scene);
+ void _scene_iso_gotomansion(Scene *scene);
+ void _scene_iso_inmansion1(Scene *scene);
+
+ // Script functions: Scene NxtScn
+ void _scene_nxtscn_died(Scene *scene);
+ void _scene_nxtscn_bombdead(Scene *scene);
+ void _scene_nxtscn_pikundrtakr(Scene *scene);
+ void _scene_nxtscn_callattract(Scene *scene);
+ void _scene_nxtscn_pikluckno(Scene *scene);
+ void _scene_nxtscn_pickmap(Scene *scene);
+ void _scene_nxtscn_pickclue(Scene *scene);
+ void _scene_nxtscn_maptimeout(Scene *scene);
+ void _scene_nxtscn_entcasino(Scene *scene);
+ void _scene_nxtscn_casinowhat(Scene *scene);
+ void _scene_nxtscn_entpoolhall(Scene *scene);
+ void _scene_nxtscn_poolhclue(Scene *scene);
+ void _scene_nxtscn_entwarehse(Scene *scene);
+ void _scene_nxtscn_warehseclue(Scene *scene);
+ void _scene_nxtscn_entgarage(Scene *scene);
+ void _scene_nxtscn_garageclue(Scene *scene);
+ void _scene_nxtscn_entmansion(Scene *scene);
+ void _scene_nxtscn_giveclue(Scene *scene);
+ void _scene_nxtscn_pikflwrman(Scene *scene);
+ void _scene_nxtscn_randomscene(Scene *scene);
+ void _scene_nxtscn_endrandscene(Scene *scene);
+ void _scene_nxtscn_killinnocent(Scene *scene);
+
+ // Script functions: Scene WepDwn
+ void _scene_default_wepdwn(Scene *scene);
+};
+
+class DebuggerJohnnyRock : public GUI::Debugger {
+public:
+ DebuggerJohnnyRock(GameJohnnyRock *game);
+ bool cmdWarpTo(int argc, const char **argv);
+ bool cmdDumpLib(int argc, const char **argv);
+
+private:
+ GameJohnnyRock *_game;
+};
+
+} // End of namespace Alg
+
+#endif
diff --git a/engines/alg/game_maddog.cpp b/engines/alg/game_maddog.cpp
new file mode 100644
index 00000000000..dd2766a151c
--- /dev/null
+++ b/engines/alg/game_maddog.cpp
@@ -0,0 +1,1541 @@
+/* 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/debug.h"
+#include "common/rect.h"
+#include "common/savefile.h"
+#include "common/system.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/pixelformat.h"
+
+#include "alg/game_maddog.h"
+#include "alg/graphics.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+GameMaddog::GameMaddog(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
+ _libFileName = "maddog.lib";
+}
+
+GameMaddog::~GameMaddog() {
+}
+
+void GameMaddog::init() {
+ _videoPosX = 56;
+ _videoPosY = 8;
+
+ _SetupCursorTimer();
+
+ loadLibArchive(_libFileName);
+ _sceneInfo->loadScnFile("maddog.scn");
+ _startscene = _sceneInfo->getStartScene();
+
+ registerScriptFunctions();
+ verifyScriptFunctions();
+
+ _menuzone = new Zone();
+ _menuzone->name = "MainMenu";
+ _menuzone->ptrfb = "GLOBALHIT";
+ _menuzone->addRect(0x0C, 0xAC, 0x3D, 0xBF, nullptr, 0, "SHOTMENU", "0");
+ _menuzone->addRect(0x00, 0xA6, 0x013F, 0xC7, nullptr, 0, "DEFAULT", "0"); // _mm_bott
+ _menuzone->addRect(0x00, 0x00, 0x3B, 0xC7, nullptr, 0, "DEFAULT", "0"); // _mm_left
+
+ _submenzone = new Zone();
+ _submenzone->name = "SubMenu";
+ _submenzone->ptrfb = "GLOBALHIT";
+ _submenzone->addRect(0x8A, 0x3B, 0xC2, 0x48, nullptr, 0, "STARTBOT", "0");
+ _submenzone->addRect(0x8A, 0x4E, 0xC2, 0x59, nullptr, 0, "STARTMENU", "0");
+ _submenzone->addRect(0x8A, 0x60, 0xC2, 0x6B, nullptr, 0, "CONTMENU", "0");
+ _submenzone->addRect(0xE3, 0x3B, 0x011B, 0x48, nullptr, 0, "RECTSAVE", "0");
+ _submenzone->addRect(0xE3, 0x4E, 0x011B, 0x59, nullptr, 0, "RECTLOAD", "0");
+ _submenzone->addRect(0xE3, 0x60, 0x011B, 0x6B, nullptr, 0, "EXITMENU", "0");
+ _submenzone->addRect(0x42, 0x34, 0x5C, 0x4E, nullptr, 0, "RECTEASY", "0");
+ _submenzone->addRect(0x42, 0x53, 0x5C, 0x70, nullptr, 0, "RECTAVG", "0");
+ _submenzone->addRect(0x42, 0x72, 0x62, 0x8A, nullptr, 0, "RECTHARD", "0");
+
+ _shotSound = _LoadSoundFile("blow.8b");
+ _emptySound = _LoadSoundFile("empty.8b");
+ _saveSound = _LoadSoundFile("saved.8b");
+ _loadSound = _LoadSoundFile("loaded.8b");
+ _skullSound = _LoadSoundFile("skull.8b");
+ _easySound = _LoadSoundFile("deputy.8b");
+ _avgSound = _LoadSoundFile("sheriff.8b");
+ _hardSound = _LoadSoundFile("marshall.8b");
+
+ _gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
+ _numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
+ Common::Array<Graphics::Surface> *bullet = AlgGraphics::loadAniImage("bullet.ani", _palette);
+ _shotIcon = (*bullet)[0];
+ _emptyIcon = (*bullet)[1];
+ Common::Array<Graphics::Surface> *hat = AlgGraphics::loadAniImage("hat.ani", _palette);
+ _liveIcon = (*hat)[0];
+ _deadIcon = (*hat)[1];
+ Common::Array<Graphics::Surface> *shootout = AlgGraphics::loadAniImage("shootout.ani", _palette);
+ _reloadIcon = (*shootout)[0];
+ _drawIcon = (*shootout)[1];
+ Common::Array<Graphics::Surface> *knife = AlgGraphics::loadScreenCoordAniImage("knife.ani", _palette);
+ _knifeIcon = (*knife)[0];
+ Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
+ _bulletholeIcon = (*hole)[0];
+
+ _background = AlgGraphics::loadVgaBackground("backgrnd.vga", _palette);
+ _screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
+
+ _MoveMouse();
+}
+
+void GameMaddog::registerScriptFunctions() {
+#define ZONE_PTRFB_FUNCTION(name, func) _zonePtrFb[name] = new MDScriptFunctionPoint(this, &GameMaddog::func);
+ ZONE_PTRFB_FUNCTION("DEFAULT", _zone_bullethole);
+ ZONE_PTRFB_FUNCTION("GLOBALHIT", _zone_globalhit);
+ ZONE_PTRFB_FUNCTION("BULLETHOLE", _zone_bullethole);
+ ZONE_PTRFB_FUNCTION("SKULL", _zone_skullhole);
+#undef ZONE_PTRFB_FUNCTION
+
+#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new MDScriptFunctionRect(this, &GameMaddog::func);
+ RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
+ RECT_HIT_FUNCTION("STARTMENU", _rect_start);
+ RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
+ RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
+ RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
+ RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
+ RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
+ RECT_HIT_FUNCTION("RECTEASY", _rect_easy);
+ RECT_HIT_FUNCTION("RECTAVG", _rect_average);
+ RECT_HIT_FUNCTION("RECTHARD", _rect_hard);
+ RECT_HIT_FUNCTION("STARTBOT", _rect_startbottles);
+ RECT_HIT_FUNCTION("HIDEFRONT", _rect_hidefront);
+ RECT_HIT_FUNCTION("HIDEREAR", _rect_hiderear);
+ RECT_HIT_FUNCTION("NEWSCENE", _rect_newscene);
+ RECT_HIT_FUNCTION("MENUSELECT", _rect_menuselect);
+ RECT_HIT_FUNCTION("SKULL", _rect_skull);
+ RECT_HIT_FUNCTION("KILLMAN", _rect_killman);
+ RECT_HIT_FUNCTION("KILLWOMAN", _rect_killwoman);
+ RECT_HIT_FUNCTION("PROSPSIGN", _rect_prospsign);
+ RECT_HIT_FUNCTION("MINESIGN", _rect_minesign);
+ RECT_HIT_FUNCTION("MINEITEM1", _rect_mineitem1);
+ RECT_HIT_FUNCTION("MINEITEM2", _rect_mineitem2);
+ RECT_HIT_FUNCTION("MINEITEM3", _rect_mineitem3);
+ RECT_HIT_FUNCTION("MINELANTERN", _rect_minelantern);
+ RECT_HIT_FUNCTION("SHOTHIDEOUT", _rect_shothideout);
+ RECT_HIT_FUNCTION("SHOTRIGHT", _rect_shotright);
+ RECT_HIT_FUNCTION("SHOTLEFT", _rect_shotleft);
+#undef RECT_HIT_FUNCTION
+
+#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new MDScriptFunctionScene(this, &GameMaddog::func);
+ PRE_OPS_FUNCTION("DRAWRCT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
+ PRE_OPS_FUNCTION("PRESHOOTOUT", _scene_pso_shootout);
+ PRE_OPS_FUNCTION("MDSHOOTOUT", _scene_pso_mdshootout);
+ PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
+ PRE_OPS_FUNCTION("PAUSFI", _scene_pso_pause_fadein);
+ PRE_OPS_FUNCTION("PREREAD", _scene_pso_preread);
+ PRE_OPS_FUNCTION("PAUSPR", _scene_pso_pause_preread);
+ PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
+#undef PRE_OPS_FUNCTION
+
+#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new MDScriptFunctionScene(this, &GameMaddog::func);
+ INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
+ INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
+ INS_OPS_FUNCTION("SPAUSE", _scene_iso_spause);
+ INS_OPS_FUNCTION("STARTGAME", _scene_iso_startgame);
+ INS_OPS_FUNCTION("SHOOTPAST", _scene_iso_shootpast);
+ INS_OPS_FUNCTION("SKIPSALOON", _scene_iso_skipsaloon);
+ INS_OPS_FUNCTION("SKIPSALOON2", _scene_iso_skipsaloon2);
+ INS_OPS_FUNCTION("CHECKSALOON", _scene_iso_checksaloon);
+ INS_OPS_FUNCTION("INTOSTABLE", _scene_iso_intostable);
+ INS_OPS_FUNCTION("INTOFFICE", _scene_iso_intoffice);
+ INS_OPS_FUNCTION("INTOBANK_SP", _scene_iso_intobank);
+ INS_OPS_FUNCTION("CHKBARTNDR", _scene_iso_chkbartndr);
+ INS_OPS_FUNCTION("DIDHIDEOUT", _scene_iso_didhideout);
+ INS_OPS_FUNCTION("DIDSIGNPOST", _scene_iso_didsignpost);
+ INS_OPS_FUNCTION("DOSHOOTOUT", _scene_iso_doshootout);
+ INS_OPS_FUNCTION("MDSHOOTOUT", _scene_iso_mdshootout);
+ INS_OPS_FUNCTION("SHOTINTO24", _scene_iso_donothing);
+ INS_OPS_FUNCTION("SHOTINTO116", _scene_iso_shotinto116);
+#undef INS_OPS_FUNCTION
+
+#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new MDScriptFunctionScene(this, &GameMaddog::func);
+ NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
+ NXT_SCN_FUNCTION("DRAWGUN", _scene_default_nxtscn);
+ NXT_SCN_FUNCTION("PICKBOTTLE", _scene_nxtscn_pickbottle);
+ NXT_SCN_FUNCTION("DIED", _scene_nxtscn_died);
+ NXT_SCN_FUNCTION("AUTOSEL", _scene_nxtscn_autosel);
+ NXT_SCN_FUNCTION("FINSALOON", _scene_nxtscn_finsaloon);
+ NXT_SCN_FUNCTION("FINOFFICE", _scene_nxtscn_finoffice);
+ NXT_SCN_FUNCTION("FINSTABLE", _scene_nxtscn_finstable);
+ NXT_SCN_FUNCTION("FINBANK", _scene_nxtscn_finbank);
+ NXT_SCN_FUNCTION("PICSALOON", _scene_nxtscn_picsaloon);
+ NXT_SCN_FUNCTION("KILLMAN", _scene_nxtscn_killman);
+ NXT_SCN_FUNCTION("KILLWOMAN", _scene_nxtscn_killwoman);
+ NXT_SCN_FUNCTION("BANK", _scene_nxtscn_bank);
+ NXT_SCN_FUNCTION("STABLE", _scene_nxtscn_stable);
+ NXT_SCN_FUNCTION("SAVPROSP", _scene_nxtscn_savprosp);
+ NXT_SCN_FUNCTION("PICKTOSS", _scene_nxtscn_picktoss);
+ NXT_SCN_FUNCTION("HITTOSS", _scene_nxtscn_hittoss);
+ NXT_SCN_FUNCTION("MISSTOSS", _scene_nxtscn_misstoss);
+ NXT_SCN_FUNCTION("PICKSIGN", _scene_nxtscn_picksign);
+ NXT_SCN_FUNCTION("BROCKMAN", _scene_nxtscn_brockman);
+ NXT_SCN_FUNCTION("LROCKMAN", _scene_nxtscn_lrockman);
+ NXT_SCN_FUNCTION("HOTELMEN", _scene_nxtscn_hotelmen);
+#undef NXT_SCN_FUNCTION
+
+ _sceneShowMsg["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::_scene_sm_donothing);
+ _sceneWepDwn["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::_scene_default_wepdwn);
+ _sceneScnScr["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::_scene_default_score);
+ _sceneNxtFrm["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::_scene_nxtfrm);
+}
+
+void GameMaddog::verifyScriptFunctions() {
+ Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
+ for (size_t i = 0; i < scenes->size(); i++) {
+ Scene *scene = (*scenes)[i];
+ getScriptFunctionScene(PREOP, scene->preop);
+ // TODO: SHOWMSG
+ getScriptFunctionScene(INSOP, scene->insop);
+ getScriptFunctionScene(WEPDWN, scene->wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->scnscr);
+ getScriptFunctionScene(NXTFRM, scene->nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->nxtscn);
+ for (size_t j = 0; j < scene->zones.size(); j++) {
+ Zone *zone = scene->zones[j];
+ getScriptFunctionZonePtrFb(zone->ptrfb);
+ for (size_t k = 0; k < zone->rects.size(); k++) {
+ getScriptFunctionRectHit(zone->rects[k].rectHit);
+ }
+ }
+ }
+}
+
+MDScriptFunctionPoint GameMaddog::getScriptFunctionZonePtrFb(Common::String name) {
+ MDScriptFunctionPointMap::iterator it = _zonePtrFb.find(name);
+ if (it != _zonePtrFb.end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find zonePtrFb function: %s", name.c_str());
+ }
+}
+
+MDScriptFunctionRect GameMaddog::getScriptFunctionRectHit(Common::String name) {
+ MDScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ if (it != _rectHitFuncs.end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find rectHit function: %s", name.c_str());
+ }
+}
+
+MDScriptFunctionScene GameMaddog::getScriptFunctionScene(SceneFuncType type, Common::String name) {
+ MDScriptFunctionSceneMap *functionMap;
+ switch (type) {
+ case PREOP:
+ functionMap = &_scenePreOps;
+ break;
+ case SHOWMSG:
+ functionMap = &_sceneShowMsg;
+ break;
+ case INSOP:
+ functionMap = &_sceneInsOps;
+ break;
+ case WEPDWN:
+ functionMap = &_sceneWepDwn;
+ break;
+ case SCNSCR:
+ functionMap = &_sceneScnScr;
+ break;
+ case NXTFRM:
+ functionMap = &_sceneNxtFrm;
+ break;
+ case NXTSCN:
+ functionMap = &_sceneNxtScn;
+ break;
+ default:
+ error("Unkown scene script type: %u", type);
+ break;
+ }
+ MDScriptFunctionSceneMap::iterator it;
+ it = functionMap->find(name);
+ if (it != functionMap->end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find scene type %u function: %s", type, name.c_str());
+ }
+}
+
+void GameMaddog::callScriptFunctionZonePtrFb(Common::String name, Common::Point *point) {
+ MDScriptFunctionPoint function = getScriptFunctionZonePtrFb(name);
+ function(point);
+}
+
+void GameMaddog::callScriptFunctionRectHit(Common::String name, Rect *rect) {
+ MDScriptFunctionRect function = getScriptFunctionRectHit(name);
+ function(rect);
+}
+
+void GameMaddog::callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene) {
+ MDScriptFunctionScene function = getScriptFunctionScene(type, name);
+ function(scene);
+}
+
+Common::Error GameMaddog::run() {
+ init();
+ _NewGame();
+ _cur_scene = _startscene;
+ Common::String oldscene;
+ Rect *hitRect = nullptr;
+ while (!_vm->shouldQuit()) {
+ oldscene = _cur_scene;
+ _SetFrame();
+ _fired = false;
+ if (_cur_scene == "scene28") {
+ _cur_scene = _pick_town();
+ }
+ Scene *scene = _sceneInfo->findScene(_cur_scene);
+ if (!loadScene(scene)) {
+ error("Cannot find scene %s in libfile", scene->name.c_str());
+ }
+ Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
+ g_system->getMixer()->stopHandle(_sceneAudioHandle);
+ g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ _nextFrameTime = _GetMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->preop, scene);
+ _currentFrame = _GetFrame(scene);
+ while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
+ _UpdateMouse();
+ // TODO: call scene->messageFunc
+ callScriptFunctionScene(INSOP, scene->insop, scene);
+ _holster = _WeaponDown();
+ if (_holster) {
+ callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ }
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ if (!_holster) {
+ Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ if (hitGlobalRect != nullptr) {
+ callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
+ } else {
+ if (_shots > 0) {
+ if (!_debug_unlimitedAmmo) {
+ _shots--;
+ }
+ _UpdateStat();
+ hitRect = nullptr;
+ Zone *hitSceneZone = _CheckZonesV1(scene, hitRect, &firedCoords);
+ if (hitSceneZone != nullptr) {
+ callScriptFunctionZonePtrFb(hitSceneZone->ptrfb, &firedCoords);
+ callScriptFunctionRectHit(hitRect->rectHit, hitRect);
+ } else {
+ _default_bullethole(&firedCoords);
+ }
+ } else {
+ _PlaySound(_emptySound);
+ _emptyCount = 3;
+ _whichGun = 9;
+ }
+ }
+ }
+ }
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ }
+ _DisplayScore();
+ _MoveMouse();
+ if (_pauseTime > 0) {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ } else {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ }
+ if (_videoDecoder->getCurrentFrame() == 0) {
+ _videoDecoder->getNextFrame();
+ }
+ int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ if (remainingMillis < 10) {
+ if (_videoDecoder->getCurrentFrame() > 0) {
+ _videoDecoder->getNextFrame();
+ }
+ remainingMillis = _nextFrameTime - _GetMsTime();
+ _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ }
+ if (remainingMillis > 0) {
+ if (remainingMillis > 15) {
+ remainingMillis = 15;
+ }
+ g_system->delayMillis(remainingMillis);
+ }
+ _currentFrame = _GetFrame(scene);
+ updateScreen();
+ }
+ // frame limit reached or scene changed, prepare for next scene
+ _hadPause = false;
+ _pauseTime = 0;
+ if (_ret_scene != "") {
+ _cur_scene = _ret_scene;
+ _ret_scene = "";
+ }
+ if (_sub_scene != "") {
+ _ret_scene = _sub_scene;
+ _sub_scene = "";
+ }
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ if (_cur_scene == "") {
+ _vm->quitGame();
+ }
+ }
+ _RemoveCursorTimer();
+ return Common::kNoError;
+}
+
+void GameMaddog::_NewGame() {
+ _shots = 6;
+ _lives = 3;
+ _score = 0;
+ _holster = false;
+ _UpdateStat();
+ _sub_scene = "";
+}
+
+void GameMaddog::_ResetParams() {
+ _been_to = 0;
+ _bottles = 0;
+ _botmask = 0;
+ _got_into = 0;
+ _had_skull = false;
+ _bad_men = 0;
+ _bad_men_bits = 0;
+ _people_killed = 0;
+ _hide_out_front = false;
+ _difficulty = 1;
+ _gun_time = 0;
+ _pro_clue = 0;
+ _got_clue = false;
+ _had_lantern = false;
+ _map_pos = 0;
+ _shoot_out_cnt = 0;
+ _max_map_pos = 0;
+ _sheriff_cnt = 0;
+ _in_shootout = false;
+ _ret_scene = "";
+ _sub_scene = "";
+}
+
+void GameMaddog::_DoMenu() {
+ uint32 startTime = _GetMsTime();
+ _RestoreCursor();
+ _DoCursor();
+ _inMenu = true;
+ _MoveMouse();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+ _ShowDifficulty(_difficulty, false);
+ while (_inMenu && !_vm->shouldQuit()) {
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ Rect *hitMenuRect = _CheckZone(_submenzone, &firedCoords);
+ if (hitMenuRect != nullptr) {
+ callScriptFunctionRectHit(hitMenuRect->rectHit, hitMenuRect);
+ }
+ }
+ if (_difficulty != _oldDifficulty) {
+ _ChangeDifficulty(_difficulty);
+ }
+ g_system->delayMillis(15);
+ updateScreen();
+ }
+ _RestoreCursor();
+ _DoCursor();
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ if (_hadPause) {
+ unsigned long endTime = _GetMsTime();
+ unsigned long timeDiff = endTime - startTime;
+ _pauseTime += timeDiff;
+ _nextFrameTime += timeDiff;
+ }
+}
+
+void GameMaddog::_UpdateStat() {
+ if (_lives != _oldLives) {
+ if (_lives > _oldLives) {
+ for (uint8 i = _oldLives; i < _lives; i++) {
+ AlgGraphics::drawImage(_screen, &_liveIcon, _livepos[i][0], _livepos[i][1]);
+ }
+ } else {
+ for (uint8 i = _lives; i < _oldLives; i++) {
+ AlgGraphics::drawImage(_screen, &_deadIcon, _livepos[i][0], _livepos[i][1]);
+ }
+ }
+ _oldLives = _lives;
+ }
+ if (_shots != _oldShots) {
+ if (_shots > _oldShots) {
+ for (uint8 i = _oldShots; i < _shots; i++) {
+ AlgGraphics::drawImage(_screen, &_shotIcon, _shotpos[i][0], _shotpos[i][1]);
+ }
+ } else {
+ for (uint8 i = _shots; i < _oldShots; i++) {
+ AlgGraphics::drawImage(_screen, &_emptyIcon, _shotpos[i][0], _shotpos[i][1]);
+ }
+ }
+ _oldShots = _shots;
+ }
+}
+
+void GameMaddog::_ChangeDifficulty(uint8 newDifficulty) {
+ if (newDifficulty == _oldDifficulty) {
+ return;
+ }
+ _ShowDifficulty(newDifficulty, true);
+ Game::_AdjustDifficulty(newDifficulty, _oldDifficulty);
+ _oldDifficulty = newDifficulty;
+ _difficulty = newDifficulty;
+}
+
+void GameMaddog::_ShowDifficulty(uint8 newDifficulty, bool updateCursor) {
+ // reset menu screen
+ _screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
+ AlgGraphics::drawImageCentered(_screen, &_knifeIcon, _diffpos[newDifficulty][0], _diffpos[newDifficulty][1]);
+ if (updateCursor) {
+ _DoCursor();
+ }
+}
+
+void GameMaddog::_DoCursor() {
+ _UpdateMouse();
+}
+
+void GameMaddog::_UpdateMouse() {
+ if (_oldWhichGun != _whichGun) {
+ Graphics::PixelFormat pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
+ Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ CursorMan.popAllCursors();
+ uint16 hotspotX = (cursor->w / 2);
+ uint16 hotspotY = (cursor->h / 2);
+ if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
+ cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
+ cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
+ }
+ CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0, false, &pixelFormat);
+ CursorMan.showMouse(true);
+ _oldWhichGun = _whichGun;
+ }
+}
+
+void GameMaddog::_MoveMouse() {
+ if (_mousePos.x < 59 || _inMenu) {
+ _whichGun = 8;
+ } else if (_mousePos.y > 166) {
+ if (_inHolster == 0)
+ _whichGun = 6;
+ else
+ _whichGun = 7;
+ } else if (_whichGun > 5) {
+ _whichGun = 0;
+ }
+ _UpdateMouse();
+}
+
+void GameMaddog::_DisplayScore() {
+ if (_score == _oldScore) {
+ return;
+ }
+ _oldScore = _score;
+ Common::String scoreString = Common::String::format("%05d", _score);
+ int posX = 0xDC;
+ for (int i = 0; i < 5; i++) {
+ int digit;
+ if (scoreString[i] == '0') {
+ digit = 9;
+ } else {
+ digit = scoreString[i] - '0' - 1;
+ }
+ AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xAD);
+ posX += 10;
+ }
+}
+
+bool GameMaddog::_WeaponDown() {
+ if (_rightDown && _mousePos.y > 168) {
+ return true;
+ }
+ return false;
+}
+
+bool GameMaddog::_SaveState() {
+ Common::OutSaveFile *outSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(outSaveFile = g_system->getSavefileManager()->openForSaving(saveFileName))) {
+ warning("Can't create file '%s', game not saved", saveFileName.c_str());
+ return false;
+ }
+ outSaveFile->writeUint32BE(MKTAG('A', 'L', 'G', 'S')); // header
+ outSaveFile->writeByte(0); // version, unused for now
+ outSaveFile->writeUint16LE(_been_to);
+ outSaveFile->writeUint16LE(_got_into);
+ outSaveFile->writeByte(_had_skull);
+ outSaveFile->writeByte(_bad_men);
+ outSaveFile->writeByte(_bad_men_bits);
+ outSaveFile->writeByte(_people_killed);
+ outSaveFile->writeByte(_hide_out_front);
+ outSaveFile->writeByte(_difficulty);
+ outSaveFile->writeByte(_pro_clue);
+ outSaveFile->writeByte(_got_clue);
+ outSaveFile->writeByte(_had_lantern);
+ outSaveFile->writeByte(_map_pos);
+ outSaveFile->writeByte(_shoot_out_cnt);
+ outSaveFile->writeSByte(_map0);
+ outSaveFile->writeSByte(_map1);
+ outSaveFile->writeSByte(_map2);
+ outSaveFile->writeByte(_max_map_pos);
+ outSaveFile->writeByte(_bartender_alive);
+ outSaveFile->writeByte(_sheriff_cnt);
+ outSaveFile->writeByte(_in_shootout);
+ outSaveFile->writeString(_cur_scene);
+ outSaveFile->writeByte(0);
+ outSaveFile->writeString(_ret_scene);
+ outSaveFile->writeByte(0);
+ outSaveFile->writeString(_sub_scene);
+ outSaveFile->writeByte(0);
+ outSaveFile->finalize();
+ delete outSaveFile;
+ return true;
+}
+
+bool GameMaddog::_LoadState() {
+ Common::InSaveFile *inSaveFile;
+ Common::String saveFileName = _vm->getSaveStateName(0);
+ if (!(inSaveFile = g_system->getSavefileManager()->openForLoading(saveFileName))) {
+ debug("Can't load file '%s', game not loaded", saveFileName.c_str());
+ return false;
+ }
+ uint32 header = inSaveFile->readUint32BE();
+ if (header != MKTAG('A', 'L', 'G', 'S')) {
+ warning("Unkown save file, header: %d", header);
+ return false;
+ }
+ inSaveFile->skip(1); // version, unused for now
+ _been_to = inSaveFile->readUint16LE();
+ _got_into = inSaveFile->readUint16LE();
+ _had_skull = inSaveFile->readByte();
+ _bad_men = inSaveFile->readByte();
+ _bad_men_bits = inSaveFile->readByte();
+ _people_killed = inSaveFile->readByte();
+ _hide_out_front = inSaveFile->readByte();
+ _difficulty = inSaveFile->readByte();
+ _pro_clue = inSaveFile->readByte();
+ _got_clue = inSaveFile->readByte();
+ _had_lantern = inSaveFile->readByte();
+ _map_pos = inSaveFile->readByte();
+ _shoot_out_cnt = inSaveFile->readByte();
+ _map0 = inSaveFile->readSByte();
+ _map1 = inSaveFile->readSByte();
+ _map2 = inSaveFile->readSByte();
+ _max_map_pos = inSaveFile->readByte();
+ _bartender_alive = inSaveFile->readByte();
+ _sheriff_cnt = inSaveFile->readByte();
+ _in_shootout = inSaveFile->readByte();
+ _cur_scene = inSaveFile->readString();
+ _ret_scene = inSaveFile->readString();
+ _sub_scene = inSaveFile->readString();
+ delete inSaveFile;
+ _ChangeDifficulty(_difficulty);
+ return true;
+}
+
+// misc game functions
+void GameMaddog::_default_bullethole(Common::Point *point) {
+ if (point->x >= 59 && point->y <= 166) {
+ _RestoreCursor();
+ uint16 targetX = point->x - _videoPosX;
+ uint16 targetY = point->y - _videoPosY;
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ _DoCursor();
+ _shotFired = true;
+ _DoShot();
+ }
+}
+
+void GameMaddog::_die() {
+ Common::String newScene;
+ _UpdateStat();
+ switch (_lives) {
+ case 2:
+ newScene = "scene150";
+ break;
+ case 1:
+ newScene = "scene152";
+ break;
+ case 0:
+ newScene = "scene153";
+ break;
+ default:
+ int nextSceneNum = (_rnd->getRandomNumber(1)) + 148;
+ newScene = Common::String::format("scene%d", nextSceneNum);
+ break;
+ }
+ _cur_scene = newScene;
+}
+
+uint8 GameMaddog::_pick_rand(uint8 *bits, uint8 max) {
+ uint8 random, mask;
+ // reset bits if full
+ if (*bits == (0xFF >> (8 - max))) {
+ *bits = 0;
+ }
+ do {
+ random = _rnd->getRandomNumber(max - 1);
+ mask = 1 << random;
+ } while (*bits & mask);
+ *bits |= mask;
+ return random * 2;
+}
+
+uint8 GameMaddog::_pick_bad(uint8 max) {
+ return _pick_rand(&_bad_men_bits, max);
+}
+
+Common::String GameMaddog::_pick_town() {
+ _had_skull = false;
+ _map_pos = 0;
+ _bad_men_bits = 0;
+ _shoot_out_cnt++;
+ if (_shoot_out_cnt % 5 == 0) {
+ if (_shoot_out_cnt > 15 || _shoot_out_cnt == 0) {
+ _shoot_out_cnt = 5;
+ }
+ // surprise showdown!
+ int pickedSceneNum = (_shoot_out_cnt / 5) + 106;
+ return Common::String::format("scene%d", pickedSceneNum);
+ } else if (_been_to == 0) {
+ return "scene28";
+ } else if (_been_to & 0x100) {
+ return "scene250";
+ } else if (_been_to & 0x80) {
+ return "scene76";
+ } else if (_been_to & 0x40) {
+ return "scene214";
+ } else if (_been_to >= 15) {
+ return "scene186";
+ } else {
+ return Common::String::format("scene%d", _been_to + 29);
+ }
+}
+
+Common::String GameMaddog::_pick_map() {
+ _been_to |= 0x20;
+ uint32 random = _rnd->getRandomNumber(5);
+ switch (random) {
+ case 0:
+ _map0 = 1;
+ _map1 = 1;
+ _map2 = 0;
+ return "scene164";
+ case 1:
+ _map0 = 1;
+ _map1 = -1;
+ _map2 = 0;
+ return "scene165";
+ case 2:
+ _map0 = -1;
+ _map1 = 1;
+ _map2 = 1;
+ return "scene166";
+ case 3:
+ _map0 = -1;
+ _map1 = 1;
+ _map2 = -1;
+ return "scene167";
+ case 4:
+ _map0 = -1;
+ _map1 = -1;
+ _map2 = 1;
+ return "scene168";
+ case 5:
+ default:
+ _map0 = -1;
+ _map1 = -1;
+ _map2 = -1;
+ return "scene169";
+ }
+}
+
+Common::String GameMaddog::_pick_sign() {
+ int8 _mapArray[3] = {_map0, _map1, _map2};
+ _map_pos++;
+ if (_map_pos > _max_map_pos) {
+ _max_map_pos = _map_pos;
+ }
+ if (_map_pos <= 2 && _mapArray[_map_pos] != 0) {
+ return Common::String::format("scene%d", _map_pos + 187);
+ } else {
+ return "scene210";
+ }
+}
+
+Common::String GameMaddog::_map_right() {
+ int8 _mapArray[3] = {_map0, _map1, _map2};
+ if (_mapArray[_map_pos] == -1) {
+ if (_map_pos >= _max_map_pos) {
+ return Common::String::format("scene%d", _fight[_map_pos]);
+ } else {
+ return _pick_sign();
+ }
+ } else if (_mapArray[_map_pos] == 0) {
+ if (_map_pos >= _max_map_pos) {
+ return Common::String::format("scene%d", _fight[_map_pos]);
+ } else {
+ return _pick_sign();
+ }
+ } else {
+ return Common::String::format("scene%d", _ambush[_map_pos]);
+ }
+}
+
+Common::String GameMaddog::_map_left() {
+ int8 _mapArray[3] = {_map0, _map1, _map2};
+ if (_mapArray[_map_pos] == 1) {
+ if (_map_pos >= _max_map_pos) {
+ return Common::String::format("scene%d", _fight[_map_pos]);
+ } else {
+ return _pick_sign();
+ }
+ } else if (_mapArray[_map_pos] == -1) {
+ return Common::String::format("scene%d", _ambush[_map_pos]);
+ } else {
+ if (_map_pos >= _max_map_pos) {
+ return Common::String::format("scene%d", _fight[_map_pos]);
+ } else {
+ return _pick_sign();
+ }
+ }
+}
+
+// Script functions: Zone
+void GameMaddog::_zone_bullethole(Common::Point *point) {
+ _default_bullethole(point);
+}
+
+void GameMaddog::_zone_skullhole(Common::Point *point) {
+ if (point->x >= 59 && point->y <= 166) {
+ uint16 targetX = point->x - _videoPosX;
+ uint16 targetY = point->y - _videoPosY;
+ _RestoreCursor();
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ _DoCursor();
+ _shotFired = true;
+
+ if (_had_skull) {
+ _DoShot();
+ } else {
+ _DoSkullSound();
+ }
+ }
+}
+
+// Script functions: RectHit
+void GameMaddog::_rect_hidefront(Rect *rect) {
+ if (_hide_out_front) {
+ _cur_scene = "scene214";
+ } else {
+ _cur_scene = "scene211";
+ }
+}
+
+void GameMaddog::_rect_hiderear(Rect *rect) {
+ if (!_hide_out_front) {
+ _cur_scene = "scene214";
+ } else {
+ _cur_scene = "scene211";
+ }
+}
+
+void GameMaddog::_rect_menuselect(Rect *rect) {
+ Common::String newScene;
+ int cursorX = _mousePos.x;
+ int cursorY = _mousePos.y;
+ if (cursorX < 184) {
+ if (cursorY < 88) {
+ if (_been_to & 2)
+ return;
+ if (_got_into & 2) {
+ newScene = "scene130";
+ } else {
+ newScene = "scene122";
+ }
+ } else {
+ if (_been_to & 8)
+ return;
+ if (_got_into & 8) {
+ if (_been_to & 1) {
+ newScene = "scene118";
+ } else {
+ newScene = "scene119";
+ }
+ } else {
+ newScene = "scene114";
+ }
+ }
+ } else {
+ if (cursorY < 88) {
+ if (_been_to & 1)
+ return;
+ if (_got_into & 1) {
+ newScene = "scene69b";
+ } else {
+ newScene = "scene67";
+ }
+ } else {
+ if (_been_to & 4)
+ return;
+ if (_got_into & 4) {
+ _scene_nxtscn_bank(nullptr);
+ return;
+ } else {
+ newScene = "scene45";
+ }
+ }
+ }
+
+ _cur_scene = newScene;
+}
+
+void GameMaddog::_rect_skull(Rect *rect) {
+ if (_had_skull) {
+ return;
+ }
+ _had_skull = true;
+ if (_been_to < 15) {
+ _shots = 9;
+ } else {
+ _shots = 12;
+ }
+ _UpdateStat();
+}
+
+void GameMaddog::_rect_killman(Rect *rect) {
+ _scene_nxtscn_killman(nullptr);
+}
+
+void GameMaddog::_rect_killwoman(Rect *rect) {
+ _scene_nxtscn_killwoman(nullptr);
+}
+
+void GameMaddog::_rect_prospsign(Rect *rect) {
+ if (_been_to & 0x10) {
+ return;
+ }
+ _gun_time = 1;
+ _cur_scene = rect->scene;
+}
+
+void GameMaddog::_rect_minesign(Rect *rect) {
+ if (_been_to & 0x20) {
+ return;
+ }
+ _gun_time = 1;
+ _cur_scene = rect->scene;
+}
+
+void GameMaddog::_rect_mineitem1(Rect *rect) {
+ if (_pro_clue != 0) {
+ _pauseTime = 0;
+ return;
+ }
+
+ if (_had_lantern) {
+ _cur_scene = _pick_map();
+ } else {
+ _got_clue = true;
+ }
+}
+
+void GameMaddog::_rect_mineitem2(Rect *rect) {
+ if (_pro_clue != 2) {
+ _pauseTime = 0;
+ return;
+ }
+
+ if (_had_lantern) {
+ _cur_scene = _pick_map();
+ } else {
+ _got_clue = true;
+ }
+}
+
+void GameMaddog::_rect_mineitem3(Rect *rect) {
+ if (_pro_clue != 1) {
+ _pauseTime = 0;
+ return;
+ }
+
+ if (_had_lantern) {
+ _cur_scene = _pick_map();
+ } else {
+ _got_clue = true;
+ }
+}
+
+void GameMaddog::_rect_minelantern(Rect *rect) {
+ _had_lantern = true;
+
+ if (!_got_clue) {
+ return;
+ }
+
+ _cur_scene = _pick_map();
+}
+
+void GameMaddog::_rect_shothideout(Rect *rect) {
+ _cur_scene = _pick_sign();
+}
+
+void GameMaddog::_rect_shotright(Rect *rect) {
+ _cur_scene = _map_right();
+}
+
+void GameMaddog::_rect_shotleft(Rect *rect) {
+ _cur_scene = _map_left();
+}
+
+void GameMaddog::_rect_shotmenu(Rect *rect) {
+ _DoMenu();
+}
+
+void GameMaddog::_rect_continue(Rect *rect) {
+ _inMenu = false;
+ _fired = false;
+ if (_lives == 0) {
+ _NewGame();
+ _ret_scene = "";
+ _cur_scene = _pick_town();
+ }
+}
+
+void GameMaddog::_rect_save(Rect *rect) {
+ if(_SaveState()) {
+ _DoSaveSound();
+ }
+}
+
+void GameMaddog::_rect_load(Rect *rect) {
+ if(_LoadState()) {
+ _DoLoadSound();
+ }
+}
+
+void GameMaddog::_rect_start(Rect *rect) {
+ _inMenu = false;
+ _fired = false;
+ Scene *scene = _sceneInfo->findScene(_startscene);
+ if (scene->nxtscn == "DRAWGUN") {
+ callScriptFunctionScene(NXTSCN, "DRAWGUN", scene);
+ }
+ _cur_scene = _startscene;
+ _ResetParams();
+ _NewGame();
+ _UpdateStat();
+}
+
+void GameMaddog::_rect_startbottles(Rect *rect) {
+ _inMenu = false;
+ _fired = false;
+ _cur_scene = "scene7";
+ _ResetParams();
+ _NewGame();
+ _UpdateStat();
+}
+
+// Script functions: Scene PreOps
+void GameMaddog::_scene_pso_shootout(Scene *scene) {
+ sscanf(scene->preopParam.c_str(), "#%ldto%ld", &_minF, &_maxF);
+ if (!_debug_unlimitedAmmo) {
+ _shots = 0;
+ }
+ _in_shootout = true;
+ _UpdateStat();
+ _RestoreCursor();
+ AlgGraphics::drawImage(_screen, &_reloadIcon, 0x40, 0xB0);
+ _DoCursor();
+}
+
+void GameMaddog::_scene_pso_mdshootout(Scene *scene) {
+ sscanf(scene->preopParam.c_str(), "#%ldto%ld", &_minF, &_maxF);
+ if (!_debug_unlimitedAmmo) {
+ _shots = 0;
+ }
+ _in_shootout = true;
+ _UpdateStat();
+ _RestoreCursor();
+ AlgGraphics::drawImage(_screen, &_reloadIcon, 0x40, 0xB0);
+ _DoCursor();
+}
+
+// Script functions: Scene Scene InsOps
+void GameMaddog::_scene_iso_shootpast(Scene *scene) {
+ if (_fired) {
+ if (_ret_scene != "") {
+ _cur_scene = _ret_scene;
+ _ret_scene = "";
+ } else if (_sub_scene != "") {
+ _cur_scene = _sub_scene;
+ _sub_scene = "";
+ } else {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ }
+}
+
+void GameMaddog::_scene_iso_spause(Scene *scene) {
+ _scene_iso_shootpast(scene);
+ _scene_iso_pause(scene);
+}
+
+void GameMaddog::_scene_iso_skipsaloon(Scene *scene) {
+ if (_got_into & 1) {
+ if (_currentFrame < 7561) {
+ _cur_scene = scene->insopParam;
+ _pauseTime = 0;
+ return;
+ }
+ }
+ if (_currentFrame > 7561) {
+ _got_into |= 1;
+ }
+ if (_fired && _currentFrame > 7165 && _currentFrame < 7817) {
+ _cur_scene = scene->insopParam;
+ }
+}
+
+void GameMaddog::_scene_iso_skipsaloon2(Scene *scene) {
+ Common::String insopParamTemp = scene->insopParam;
+ scene->insopParam = Common::String::format("%u", scene->dataParam2);
+ _scene_iso_pause(scene);
+ scene->insopParam = insopParamTemp;
+ _scene_iso_skipsaloon(scene);
+}
+
+void GameMaddog::_scene_iso_checksaloon(Scene *scene) {
+ _got_into |= 1;
+ if (_currentFrame > 7909) {
+ _bartender_alive = false;
+ } else {
+ _bartender_alive = true;
+ }
+}
+
+void GameMaddog::_scene_iso_intostable(Scene *scene) {
+ _got_into |= 2;
+}
+
+void GameMaddog::_scene_iso_intoffice(Scene *scene) {
+ _got_into |= 8;
+}
+
+void GameMaddog::_scene_iso_intobank(Scene *scene) {
+ _got_into |= 4;
+ _scene_iso_shootpast(scene);
+}
+
+void GameMaddog::_scene_iso_chkbartndr(Scene *scene) {
+ if (!_bartender_alive) {
+ if (scene->dataParam1 <= (int32)_currentFrame) {
+ _cur_scene = scene->insopParam;
+ }
+ }
+ if (_fired) {
+ if (scene->dataParam2 < (int32)_currentFrame) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ }
+}
+
+void GameMaddog::_scene_iso_didhideout(Scene *scene) {
+ _been_to |= 0x80;
+}
+
+void GameMaddog::_scene_iso_didsignpost(Scene *scene) {
+ _been_to |= 0x40;
+}
+
+void GameMaddog::_scene_iso_doshootout(Scene *scene) {
+ if (_currentFrame > (uint32)_minF) {
+ if (_in_shootout) {
+ _RestoreCursor();
+ AlgGraphics::drawImage(_screen, &_drawIcon, 0x40, 0xB0);
+ _DoCursor();
+ }
+ _in_shootout = false;
+ if (_shots > 0) {
+ if (_currentFrame < (uint32)_maxF) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ }
+ }
+}
+
+void GameMaddog::_scene_iso_mdshootout(Scene *scene) {
+ _been_to |= 0x100;
+ _scene_iso_doshootout(scene);
+}
+
+void GameMaddog::_scene_iso_shotinto116(Scene *scene) {
+ uint32 targetFrame = atoi(scene->insopParam.c_str());
+ if (_fired) {
+ if (_currentFrame > targetFrame) {
+ callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ }
+ }
+}
+
+// Script functions: Scene NxtScn
+void GameMaddog::_scene_default_nxtscn(Scene *scene) {
+ // wipe background drawing from shootout
+ _screen->copyRectToSurface(_background->getBasePtr(0x40, 0xB0), _background->pitch, 0x40, 0xB0, _reloadIcon.w, _reloadIcon.h);
+ _DoCursor();
+ Game::_scene_default_nxtscn(scene);
+}
+
+void GameMaddog::_scene_nxtscn_pickbottle(Scene *scene) {
+ _bottles++;
+ if (_bottles < 4) {
+ int rand = _pick_rand(&_botmask, 6);
+ _cur_scene = Common::String::format("scene%d", rand + 11);
+ } else {
+ _cur_scene = "scene253";
+ }
+}
+
+void GameMaddog::_scene_nxtscn_died(Scene *scene) {
+ _had_skull = false;
+ _bad_men_bits = 0;
+ _bad_men = 0;
+ _got_clue = false;
+ _had_lantern = false;
+ if (!_debug_godMode) {
+ _lives--;
+ }
+ if (_lives <= 0) {
+ _lives = 0;
+ _sub_scene = "scene255";
+ _die();
+ return;
+ }
+ _ret_scene = scene->next;
+ _die();
+}
+
+void GameMaddog::_scene_nxtscn_autosel(Scene *scene) {
+ Common::String newScene;
+ if (!(_been_to & 2)) {
+ newScene = "scene122";
+ } else if (!(_been_to & 8)) {
+ newScene = "scene114";
+ } else if (!(_been_to & 1)) {
+ if (_got_into & 1) {
+ newScene = "scene69";
+ } else {
+ newScene = "scene67";
+ }
+ } else if (!(_been_to & 4)) {
+ newScene = "scene45";
+ } else {
+ newScene = "scene186";
+ }
+ _cur_scene = newScene;
+}
+
+void GameMaddog::_scene_nxtscn_finsaloon(Scene *scene) {
+ _been_to |= 1;
+ _cur_scene = _pick_town();
+}
+
+void GameMaddog::_scene_nxtscn_finoffice(Scene *scene) {
+ _been_to |= 8;
+ _cur_scene = _pick_town();
+}
+
+void GameMaddog::_scene_nxtscn_finstable(Scene *scene) {
+ _been_to |= 2;
+ _cur_scene = _pick_town();
+}
+
+void GameMaddog::_scene_nxtscn_finbank(Scene *scene) {
+ _been_to |= 4;
+ _cur_scene = _pick_town();
+}
+
+void GameMaddog::_scene_nxtscn_picsaloon(Scene *scene) {
+ if (_been_to & 1) {
+ _cur_scene = "scene118";
+ } else {
+ _cur_scene = "scene119";
+ }
+}
+
+void GameMaddog::_scene_nxtscn_killman(Scene *scene) {
+ if (!_debug_godMode) {
+ _lives--;
+ }
+ if (_lives <= 0) {
+ _lives = 0;
+ _sub_scene = "scene212";
+ } else {
+ _sub_scene = _pick_town();
+ }
+ _UpdateStat();
+ _bad_men_bits = 0;
+ _bad_men = 0;
+ _people_killed++;
+ if (_people_killed == 1) {
+ _cur_scene = "scene155";
+ } else {
+ _cur_scene = Common::String::format("scene%d", 156 + (_people_killed & 1));
+ }
+}
+
+void GameMaddog::_scene_nxtscn_killwoman(Scene *scene) {
+ if (!_debug_godMode) {
+ _lives--;
+ }
+ if (_lives <= 0) {
+ _lives = 0;
+ _sub_scene = "scene212";
+ } else {
+ _sub_scene = _pick_town();
+ }
+ _UpdateStat();
+ _bad_men_bits = 0;
+ _bad_men = 0;
+ _people_killed++;
+ if (_people_killed == 1) {
+ _cur_scene = "scene154";
+ } else {
+ _cur_scene = Common::String::format("scene%d", 156 + (_people_killed & 1));
+ }
+}
+
+void GameMaddog::_scene_nxtscn_bank(Scene *scene) {
+ Common::String newScene;
+ uint8 totalBadmen = (_difficulty * 2) + 6;
+ _bad_men++;
+ if (_bad_men > totalBadmen) {
+ if (_bad_men > totalBadmen + 2) {
+ _been_to |= 4;
+ _bad_men_bits = 0;
+ _bad_men = 0;
+ if (_rnd->getRandomBit()) {
+ _hide_out_front = true;
+ newScene = "scene49";
+ } else {
+ _hide_out_front = false;
+ newScene = "scene48";
+ }
+ } else {
+ newScene = "scene65";
+ }
+ } else {
+ int nextSceneNum = _pick_bad(6) + 51;
+ newScene = Common::String::format("scene%d", nextSceneNum);
+ }
+ _cur_scene = newScene;
+}
+
+void GameMaddog::_scene_nxtscn_stable(Scene *scene) {
+ Common::String newScene;
+ uint16 totalBadMen = (_difficulty * 2) + 6;
+ totalBadMen -= (_been_to & 8) ? 2 : 0;
+ _bad_men++;
+ if (_bad_men > totalBadMen) {
+ _bad_men_bits = 0;
+ _bad_men = 0;
+ newScene = "scene143";
+ } else {
+ int nextSceneNum = _pick_bad(6) + 131;
+ newScene = Common::String::format("scene%d", nextSceneNum);
+ }
+ _cur_scene = newScene;
+}
+
+void GameMaddog::_scene_nxtscn_savprosp(Scene *scene) {
+ _gun_time = 1;
+ _oldScore = -1;
+ _pro_clue = _rnd->getRandomNumber(2);
+ _been_to |= 0x10;
+ _cur_scene = Common::String::format("scene%d", _pro_clue + 160);
+}
+
+void GameMaddog::_scene_nxtscn_picktoss(Scene *scene) {
+ int index = _pick_bad(7);
+ _cur_scene = Common::String::format("scene%d", _bottle_toss[index]);
+}
+
+void GameMaddog::_scene_nxtscn_hittoss(Scene *scene) {
+ if (_lives > 0) {
+ _score += 100;
+ }
+ _scene_nxtscn_misstoss(scene);
+}
+
+void GameMaddog::_scene_nxtscn_misstoss(Scene *scene) {
+ _bad_men++;
+ if (_bad_men <= 2) {
+ _cur_scene = scene->next;
+ } else {
+ _bad_men_bits = 0;
+ _bad_men = 0;
+ _been_to |= 0x200;
+ _cur_scene = "scene185";
+ }
+}
+
+void GameMaddog::_scene_nxtscn_picksign(Scene *scene) {
+ _cur_scene = _pick_sign();
+}
+
+void GameMaddog::_scene_nxtscn_brockman(Scene *scene) {
+ long totalBadMen = (_difficulty * 2) + 9;
+ _bad_men++;
+ if (_bad_men > totalBadMen) {
+ _bad_men_bits = 0;
+ _bad_men = 0;
+ _cur_scene = _pick_sign();
+ } else {
+ int nextBad = _pick_bad(7);
+ _cur_scene = Common::String::format("scene%d", nextBad + 229);
+ }
+}
+
+void GameMaddog::_scene_nxtscn_lrockman(Scene *scene) {
+ long totalBadMen = (_difficulty * 2) + 4;
+ _bad_men++;
+ if (_bad_men > totalBadMen) {
+ _bad_men_bits = 0;
+ _bad_men = 0;
+ _cur_scene = _pick_sign();
+ } else {
+ int nextBad = _pick_bad(3);
+ _cur_scene = Common::String::format("scene%d", nextBad + 244);
+ }
+}
+
+void GameMaddog::_scene_nxtscn_hotelmen(Scene *scene) {
+ long totalBadMen = (_difficulty * 2) + 9;
+ if (_bad_men >= totalBadMen) {
+ _bad_men_bits = 0;
+ _bad_men = 0;
+ _been_to |= 0x100;
+ _cur_scene = "scene250";
+ } else {
+ _bad_men++;
+ uint32 index = _pick_bad(5);
+ _cur_scene = Common::String::format("scene%d", _hotel_scenes[index]);
+ }
+}
+
+// Script functions: WepDwn
+void GameMaddog::_scene_default_wepdwn(Scene *scene) {
+ _inHolster = 9;
+ _whichGun = 7;
+ _UpdateMouse();
+ if (_in_shootout == 0) {
+ if (_been_to >= 15) {
+ if (_shots < 12) {
+ _shots = 12;
+ }
+ } else {
+ if (_shots < 6) {
+ _shots = 6;
+ }
+ }
+ _UpdateStat();
+ }
+}
+
+// Debug methods
+void GameMaddog::debug_warpTo(int val) {
+ switch (val) {
+ case 0:
+ _been_to = 0;
+ _cur_scene = "scene28";
+ break;
+ case 1:
+ _been_to = 1;
+ _cur_scene = _pick_town();
+ break;
+ case 2:
+ _been_to = 15;
+ _cur_scene = _pick_town();
+ break;
+ case 3:
+ _been_to = 575;
+ // always go right
+ _map0 = -1;
+ _map1 = -1;
+ _map2 = -1;
+ _cur_scene = _pick_town();
+ break;
+ case 4:
+ _been_to = 575;
+ _hide_out_front = true; // go to front
+ _cur_scene = "scene210";
+ break;
+ case 5:
+ _been_to = 639;
+ _cur_scene = "scene227";
+ break;
+ case 6:
+ _been_to = 1023;
+ _cur_scene = "scene250";
+ break;
+ default:
+ break;
+ }
+}
+
+// Debugger methods
+DebuggerMaddog::DebuggerMaddog(GameMaddog *game) : GUI::Debugger() {
+ _game = game;
+ registerVar("drawRects", &game->_debug_drawRects);
+ registerVar("godMode", &game->_debug_godMode);
+ registerVar("unlimitedAmmo", &game->_debug_unlimitedAmmo);
+ registerCmd("warpTo", WRAP_METHOD(DebuggerMaddog, cmdWarpTo));
+ registerCmd("dumpLib", WRAP_METHOD(DebuggerMaddog, cmdDumpLib));
+}
+
+bool DebuggerMaddog::cmdWarpTo(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: warp <int>");
+ return true;
+ } else {
+ int val = atoi(argv[1]);
+ _game->debug_warpTo(val);
+ return false;
+ }
+}
+
+bool DebuggerMaddog::cmdDumpLib(int argc, const char **argv) {
+ return _game->debug_dumpLibFile();
+}
+
+} // End of namespace Alg
diff --git a/engines/alg/game_maddog.h b/engines/alg/game_maddog.h
new file mode 100644
index 00000000000..8f93822ace3
--- /dev/null
+++ b/engines/alg/game_maddog.h
@@ -0,0 +1,237 @@
+/* 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 ALG_GAME_MADDOG_H
+#define ALG_GAME_MADDOG_H
+
+#include "common/hashmap.h"
+#include "common/rect.h"
+
+#include "gui/debugger.h"
+
+#include "alg/game.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+typedef Common::Functor1Mem<Scene *, void, GameMaddog> MDScriptFunctionScene;
+typedef Common::Functor1Mem<Rect *, void, GameMaddog> MDScriptFunctionRect;
+typedef Common::Functor1Mem<Common::Point *, void, GameMaddog> MDScriptFunctionPoint;
+typedef Common::HashMap<Common::String, MDScriptFunctionScene *> MDScriptFunctionSceneMap;
+typedef Common::HashMap<Common::String, MDScriptFunctionRect *> MDScriptFunctionRectMap;
+typedef Common::HashMap<Common::String, MDScriptFunctionPoint *> MDScriptFunctionPointMap;
+
+class GameMaddog : public Game {
+
+ enum SceneFuncType {
+ PREOP = 1,
+ SHOWMSG = 2,
+ INSOP = 3,
+ WEPDWN = 4,
+ SCNSCR = 5,
+ NXTFRM = 6,
+ NXTSCN = 7
+ };
+
+public:
+ GameMaddog(AlgEngine *vm, const ADGameDescription *desc);
+ ~GameMaddog() override;
+ Common::Error run() override;
+ void debug_warpTo(int val);
+
+private:
+ void init();
+ void registerScriptFunctions();
+ void verifyScriptFunctions();
+ MDScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
+ MDScriptFunctionRect getScriptFunctionRectHit(Common::String name);
+ MDScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
+ void callScriptFunctionZonePtrFb(Common::String name, Common::Point *point);
+ void callScriptFunctionRectHit(Common::String name, Rect *rect);
+ void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
+
+ MDScriptFunctionPointMap _zonePtrFb;
+ MDScriptFunctionRectMap _rectHitFuncs;
+ MDScriptFunctionSceneMap _scenePreOps;
+ MDScriptFunctionSceneMap _sceneShowMsg;
+ MDScriptFunctionSceneMap _sceneInsOps;
+ MDScriptFunctionSceneMap _sceneWepDwn;
+ MDScriptFunctionSceneMap _sceneScnScr;
+ MDScriptFunctionSceneMap _sceneNxtFrm;
+ MDScriptFunctionSceneMap _sceneNxtScn;
+
+ // images
+ Graphics::Surface _shotIcon;
+ Graphics::Surface _emptyIcon;
+ Graphics::Surface _liveIcon;
+ Graphics::Surface _deadIcon;
+ Graphics::Surface _reloadIcon;
+ Graphics::Surface _drawIcon;
+ Graphics::Surface _knifeIcon;
+ Graphics::Surface _bulletholeIcon;
+
+ // constants
+ const uint16 _fight[3] = {208, 228, 243};
+ const uint16 _ambush[3] = {192, 193, 192};
+ const uint16 _hotel_scenes[10] = {77, 77, 87, 87, 89, 89, 97, 97, 105, 105};
+ const uint16 _bottle_toss[14] = {171, 171, 174, 174, 175, 175, 178, 178, 179, 179, 182, 182, 183, 183};
+
+ const uint16 _diffpos[4][2] = {{0, 0}, {0x4D, 0x43}, {0x4E, 0x66}, {0x4F, 0x80}};
+ const uint16 _livepos[3][2] = {{0x03, 0x5E}, {0x03, 0x76}, {0x03, 0x8E}};
+ const uint16 _shotpos[12][2] = {{0x3, 0x5}, {0x0D, 0x5}, {0x17, 0x5}, {0x21, 0x5}, {0x3, 0x21}, {0x0D, 0x21}, {0x17, 0x21}, {0x21, 0x21}, {0x3, 0x3D}, {0x0D, 0x3D}, {0x17, 0x3D}, {0x21, 0x3D}};
+
+ // gamestate
+ uint8 _bad_men = 0;
+ uint8 _bad_men_bits = 0;
+ bool _bartender_alive = 0;
+ uint16 _been_to = 0;
+ uint8 _bottles = 0;
+ uint8 _botmask = 0;
+ bool _got_clue = false;
+ uint16 _got_into = 0;
+ uint8 _gun_time = 0;
+ bool _had_skull = 0;
+ bool _had_lantern = 0;
+ bool _hide_out_front = 0;
+ bool _in_shootout = 0;
+ int8 _map0 = 0;
+ int8 _map1 = 0;
+ int8 _map2 = 0;
+ uint8 _map_pos = 0;
+ uint8 _max_map_pos = 0;
+ uint8 _people_killed = 0;
+ uint8 _pro_clue = 0;
+ uint8 _sheriff_cnt = 0; // unused
+ uint8 _shoot_out_cnt = 0;
+
+ // base functions
+ void _NewGame();
+ void _ResetParams();
+ void _DoMenu();
+ void _UpdateStat();
+ void _ChangeDifficulty(uint8 newDifficulty);
+ void _ShowDifficulty(uint8 newDifficulty, bool updateCursor);
+ void _DoCursor();
+ void _UpdateMouse();
+ void _MoveMouse();
+ void _DisplayScore();
+ bool _WeaponDown();
+ bool _SaveState();
+ bool _LoadState();
+
+ // misc game functions
+ void _default_bullethole(Common::Point *point);
+ void _die();
+ uint8 _pick_rand(uint8 *bits, uint8 max);
+ uint8 _pick_bad(uint8 max);
+ Common::String _pick_town();
+ Common::String _pick_map();
+ Common::String _pick_sign();
+ Common::String _map_right();
+ Common::String _map_left();
+
+ // Script functions: Zone
+ void _zone_bullethole(Common::Point *point);
+ void _zone_skullhole(Common::Point *point);
+
+ // Script functions: RectHit
+ void _rect_shotmenu(Rect *rect);
+ void _rect_continue(Rect *rect);
+ void _rect_save(Rect *rect);
+ void _rect_load(Rect *rect);
+ void _rect_start(Rect *rect);
+ void _rect_startbottles(Rect *rect);
+ void _rect_hidefront(Rect *rect);
+ void _rect_hiderear(Rect *rect);
+ void _rect_menuselect(Rect *rect);
+ void _rect_skull(Rect *rect);
+ void _rect_killman(Rect *rect);
+ void _rect_killwoman(Rect *rect);
+ void _rect_prospsign(Rect *rect);
+ void _rect_minesign(Rect *rect);
+ void _rect_mineitem1(Rect *rect);
+ void _rect_mineitem2(Rect *rect);
+ void _rect_mineitem3(Rect *rect);
+ void _rect_minelantern(Rect *rect);
+ void _rect_shothideout(Rect *rect);
+ void _rect_shotright(Rect *rect);
+ void _rect_shotleft(Rect *rect);
+
+ // Script functions: Scene PreOps
+ void _scene_pso_shootout(Scene *scene);
+ void _scene_pso_mdshootout(Scene *scene);
+
+ // Script functions: Scene InsOps
+ void _scene_iso_shootpast(Scene *scene);
+ void _scene_iso_spause(Scene *scene);
+ void _scene_iso_skipsaloon(Scene *scene);
+ void _scene_iso_skipsaloon2(Scene *scene);
+ void _scene_iso_checksaloon(Scene *scene);
+ void _scene_iso_intostable(Scene *scene);
+ void _scene_iso_intoffice(Scene *scene);
+ void _scene_iso_intobank(Scene *scene);
+ void _scene_iso_chkbartndr(Scene *scene);
+ void _scene_iso_didhideout(Scene *scene);
+ void _scene_iso_didsignpost(Scene *scene);
+ void _scene_iso_doshootout(Scene *scene);
+ void _scene_iso_mdshootout(Scene *scene);
+ void _scene_iso_shotinto116(Scene *scene);
+
+ // Script functions: Scene NxtScn
+ void _scene_default_nxtscn(Scene *scene);
+ void _scene_nxtscn_pickbottle(Scene *scene);
+ void _scene_nxtscn_died(Scene *scene);
+ void _scene_nxtscn_autosel(Scene *scene);
+ void _scene_nxtscn_finsaloon(Scene *scene);
+ void _scene_nxtscn_finoffice(Scene *scene);
+ void _scene_nxtscn_finstable(Scene *scene);
+ void _scene_nxtscn_finbank(Scene *scene);
+ void _scene_nxtscn_picsaloon(Scene *scene);
+ void _scene_nxtscn_killman(Scene *scene);
+ void _scene_nxtscn_killwoman(Scene *scene);
+ void _scene_nxtscn_bank(Scene *scene);
+ void _scene_nxtscn_stable(Scene *scene);
+ void _scene_nxtscn_savprosp(Scene *scene);
+ void _scene_nxtscn_picktoss(Scene *scene);
+ void _scene_nxtscn_hittoss(Scene *scene);
+ void _scene_nxtscn_misstoss(Scene *scene);
+ void _scene_nxtscn_picksign(Scene *scene);
+ void _scene_nxtscn_brockman(Scene *scene);
+ void _scene_nxtscn_lrockman(Scene *scene);
+ void _scene_nxtscn_hotelmen(Scene *scene);
+
+ // Script functions: Scene WepDwn
+ void _scene_default_wepdwn(Scene *scene);
+};
+
+class DebuggerMaddog : public GUI::Debugger {
+public:
+ DebuggerMaddog(GameMaddog *game);
+ bool cmdWarpTo(int argc, const char **argv);
+ bool cmdDumpLib(int argc, const char **argv);
+
+private:
+ GameMaddog *_game;
+};
+
+} // End of namespace Alg
+
+#endif
diff --git a/engines/alg/game_maddog2.cpp b/engines/alg/game_maddog2.cpp
new file mode 100644
index 00000000000..aceb8303b0a
--- /dev/null
+++ b/engines/alg/game_maddog2.cpp
@@ -0,0 +1,1726 @@
+/* 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/debug.h"
+#include "common/rect.h"
+#include "common/savefile.h"
+#include "common/system.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/pixelformat.h"
+
+#include "alg/game_maddog2.h"
+#include "alg/graphics.h"
+#include "alg/scene.h"
+
+namespace Alg {
+
+GameMaddog2::GameMaddog2(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
+ if (scumm_stricmp(desc->gameId, "maddog2s") == 0) {
+ _libFileName = "maddog2.lib";
+ } else if (scumm_stricmp(desc->gameId, "maddog2d") == 0) {
+ _libFileName = "maddog2d.lib";
+ }
+}
+
+GameMaddog2::~GameMaddog2() {
+}
+
+void GameMaddog2::init() {
+ _videoPosX = 11;
+ _videoPosY = 2;
+
+ _SetupCursorTimer();
+
+ loadLibArchive(_libFileName);
+ _sceneInfo->loadScnFile("maddog2.scn");
+ _startscene = _sceneInfo->getStartScene();
+
+ registerScriptFunctions();
+ verifyScriptFunctions();
+
+ _menuzone = new Zone();
+ _menuzone->name = "MainMenu";
+ _menuzone->ptrfb = "GLOBALHIT";
+
+ _menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
+ _menuzone->addRect(0x08, 0xA9, 0x013C, 0xC7, nullptr, 0, "DEFAULT", "0"); // _mm_bott
+
+ _submenzone = new Zone();
+ _submenzone->name = "SubMenu";
+ _submenzone->ptrfb = "GLOBALHIT";
+
+ _submenzone->addRect(0x2F, 0x16, 0x64, 0x2B, nullptr, 0, "STARTMENU", "0");
+ _submenzone->addRect(0x2F, 0xA0, 0x8D, 0xC7, nullptr, 0, "CONTMENU", "0");
+ _submenzone->addRect(0x2F, 0x40, 0x64, 0x54, nullptr, 0, "RECTSAVE", "0");
+ _submenzone->addRect(0x2F, 0x6E, 0x7B, 0x86, nullptr, 0, "RECTLOAD", "0");
+ _submenzone->addRect(0xEC, 0x15, 0x0122, 0x2C, nullptr, 0, "EXITMENU", "0");
+ _submenzone->addRect(0xAD, 0x58, 0xF2, 0x70, nullptr, 0, "RECTEASY", "0");
+ _submenzone->addRect(0xBC, 0x78, 0xF2, 0x93, nullptr, 0, "RECTAVG", "0");
+ _submenzone->addRect(0xB8, 0x9D, 0xF2, 0xC7, nullptr, 0, "RECTHARD", "0");
+
+ _shotSound = _LoadSoundFile("blow.8b");
+ _emptySound = _LoadSoundFile("empty.8b");
+ _saveSound = _LoadSoundFile("saved.8b");
+ _loadSound = _LoadSoundFile("loaded.8b");
+ _skullSound = _LoadSoundFile("skull.8b");
+
+ _gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
+ _numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
+ Common::Array<Graphics::Surface> *bullet = AlgGraphics::loadAniImage("bullet.ani", _palette);
+ _shotIcon = (*bullet)[0];
+ _emptyIcon = (*bullet)[1];
+ Common::Array<Graphics::Surface> *hat = AlgGraphics::loadAniImage("hat.ani", _palette);
+ _liveIcon = (*hat)[0];
+ _deadIcon = (*hat)[1];
+ Common::Array<Graphics::Surface> *shootout = AlgGraphics::loadAniImage("shootout.ani", _palette);
+ _reloadIcon = (*shootout)[0];
+ _drawIcon = (*shootout)[1];
+ Common::Array<Graphics::Surface> *knife = AlgGraphics::loadScreenCoordAniImage("knife.ani", _palette);
+ _knifeIcon = (*knife)[0];
+ Common::Array<Graphics::Surface> *hole = AlgGraphics::loadAniImage("hole.ani", _palette);
+ _bulletholeIcon = (*hole)[0];
+
+ _background = AlgGraphics::loadVgaBackground("backgrnd.vga", _palette);
+ _screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
+
+ _MoveMouse();
+}
+
+void GameMaddog2::registerScriptFunctions() {
+#define ZONE_PTRFB_FUNCTION(name, func) _zonePtrFb[name] = new MD2ScriptFunctionPoint(this, &GameMaddog2::func);
+ ZONE_PTRFB_FUNCTION("DEFAULT", _zone_bullethole);
+ ZONE_PTRFB_FUNCTION("BULLETHOLE", _zone_bullethole);
+ ZONE_PTRFB_FUNCTION("SKULL", _zone_skullhole);
+#undef ZONE_PTRFB_FUNCTION
+
+#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new MD2ScriptFunctionRect(this, &GameMaddog2::func);
+ RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
+ RECT_HIT_FUNCTION("NEWSCENE", _rect_newscene);
+ RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
+ RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
+ RECT_HIT_FUNCTION("STARTMENU", _rect_start);
+ RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
+ RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
+ RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
+ RECT_HIT_FUNCTION("RECTEASY", _rect_easy);
+ RECT_HIT_FUNCTION("RECTAVG", _rect_average);
+ RECT_HIT_FUNCTION("RECTHARD", _rect_hard);
+ RECT_HIT_FUNCTION("SKULL", _rect_skull);
+ RECT_HIT_FUNCTION("KILLINNOCENTMAN", _rect_killinnocentman);
+ RECT_HIT_FUNCTION("KILLINNOCENTWOMAN", _rect_killinnocentwoman);
+ RECT_HIT_FUNCTION("SELECTBEAVER", _rect_selectbeaver);
+ RECT_HIT_FUNCTION("SELECTBONNIE", _rect_selectbonnie);
+ RECT_HIT_FUNCTION("SELECTPROFESSOR", _rect_selectprofessor);
+ RECT_HIT_FUNCTION("SHOTAMMO", _rect_shotammo);
+ RECT_HIT_FUNCTION("SHOTGIN", _rect_shotgin);
+ RECT_HIT_FUNCTION("SHOTLANTERN", _rect_shotlantern);
+ RECT_HIT_FUNCTION("SHOOTSKULL", _rect_shootskull);
+
+#undef RECT_HIT_FUNCTION
+
+#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new MD2ScriptFunctionScene(this, &GameMaddog2::func);
+ PRE_OPS_FUNCTION("DRAWRCT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
+ PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
+ PRE_OPS_FUNCTION("PAUSFI", _scene_pso_pause_fadein);
+ PRE_OPS_FUNCTION("PREREAD", _scene_pso_preread);
+ PRE_OPS_FUNCTION("PAUSPR", _scene_pso_pause_preread);
+ PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("DRAWRCTFDI", _scene_pso_drawrct_fadein);
+ PRE_OPS_FUNCTION("PRESHOOTOUT", _scene_pso_shootout);
+ PRE_OPS_FUNCTION("PREMDSHOOTOUT", _scene_pso_mdshootout);
+#undef PRE_OPS_FUNCTION
+
+#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new MD2ScriptFunctionScene(this, &GameMaddog2::func);
+ INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
+ INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
+ INS_OPS_FUNCTION("SPAUSE", _scene_iso_spause);
+ INS_OPS_FUNCTION("STARTGAME", _scene_iso_startgame);
+ INS_OPS_FUNCTION("SHOOTPAST", _scene_iso_shootpast);
+ INS_OPS_FUNCTION("STAGECOACH", _scene_iso_stagecoach);
+ INS_OPS_FUNCTION("DIFFERENTPADRES", _scene_iso_differentpadres);
+ INS_OPS_FUNCTION("DIFFERENTPADRESPAS", _scene_iso_differentpadrespas);
+ INS_OPS_FUNCTION("DONTPOPNEXT", _scene_iso_dontpopnext);
+ INS_OPS_FUNCTION("GETINTOROCK", _scene_iso_getintorock);
+ INS_OPS_FUNCTION("BENATCAVE", _scene_iso_benatcave);
+ INS_OPS_FUNCTION("SKULLATCAVE", _scene_iso_skullatcave);
+ INS_OPS_FUNCTION("STARTOFTRAIN", _scene_iso_startoftrain);
+ INS_OPS_FUNCTION("MISSION", _scene_iso_mission);
+ INS_OPS_FUNCTION("MDSHOOTOUT", _scene_iso_mdshootout);
+ INS_OPS_FUNCTION("STARTOFBOARDINGHOUSE", _scene_iso_startofboardinghouse);
+ INS_OPS_FUNCTION("DONTCONTINUE", _scene_iso_dontcontinue);
+ INS_OPS_FUNCTION("DOSHOOTOUT", _scene_iso_doshootout);
+#undef INS_OPS_FUNCTION
+
+#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new MD2ScriptFunctionScene(this, &GameMaddog2::func);
+ NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
+ NXT_SCN_FUNCTION("DIED", _scene_nxtscn_died);
+ NXT_SCN_FUNCTION("KILLINNOCENTMAN", _scene_nxtscn_killinnocentman);
+ NXT_SCN_FUNCTION("KILLINNOCENTWOMAN", _scene_nxtscn_killinnocentwoman);
+ NXT_SCN_FUNCTION("KILLGUIDE", _scene_nxtscn_killguide);
+ NXT_SCN_FUNCTION("SCN_SHOOTSKULL", _scene_nxtscn_shootskull);
+ NXT_SCN_FUNCTION("CALLATTRACT", _scene_nxtscn_callattract);
+ NXT_SCN_FUNCTION("PICKUNDERTAKER", _scene_nxtscn_pickundertaker);
+ NXT_SCN_FUNCTION("CHOOSEPADRE", _scene_nxtscn_choosepadre);
+ NXT_SCN_FUNCTION("SELECTGUIDE", _scene_nxtscn_selectguide);
+ NXT_SCN_FUNCTION("SAVEBONNIE", _scene_nxtscn_savebonnie);
+ NXT_SCN_FUNCTION("FINISHBONNIE", _scene_nxtscn_finishbonnie);
+ NXT_SCN_FUNCTION("SHOWGGCLUE", _scene_nxtscn_showggclue);
+ NXT_SCN_FUNCTION("BBAFTERCLUE", _scene_nxtscn_bbafterclue);
+ NXT_SCN_FUNCTION("ASFARSHEGOES", _scene_nxtscn_asfarshegoes);
+ NXT_SCN_FUNCTION("SAVEBEAVER", _scene_nxtscn_savebeaver);
+ NXT_SCN_FUNCTION("FINISHBEAVER", _scene_nxtscn_finishbeaver);
+ NXT_SCN_FUNCTION("TOGATLINGUNSBCLUE", _scene_nxtscn_togatlingunsbclue);
+ NXT_SCN_FUNCTION("TOGUIDEAFTERCLUE", _scene_nxtscn_toguideafterclue);
+ NXT_SCN_FUNCTION("TOGUIDECAVE", _scene_nxtscn_toguidecave);
+ NXT_SCN_FUNCTION("INITRANDOMVILLAGE", _scene_nxtscn_initrandomvillage);
+ NXT_SCN_FUNCTION("PICKVILLAGESCENES", _scene_nxtscn_pickvillagescenes);
+ NXT_SCN_FUNCTION("SAVEPROFESSOR", _scene_nxtscn_saveprofessor);
+ NXT_SCN_FUNCTION("FINISHPROFESSOR", _scene_nxtscn_finishprofessor);
+ NXT_SCN_FUNCTION("TOGATLINGUNTPCLUE", _scene_nxtscn_togatlinguntpclue);
+ NXT_SCN_FUNCTION("TPAFTERCLUE", _scene_nxtscn_tpafterclue);
+ NXT_SCN_FUNCTION("FINISHGATLINGUN1", _scene_nxtscn_finishgatlingun1);
+ NXT_SCN_FUNCTION("FINISHGUYATGG", _scene_nxtscn_finishguyatgg);
+ NXT_SCN_FUNCTION("FINISHGATLINGUN2", _scene_nxtscn_finishgatlingun2);
+ NXT_SCN_FUNCTION("HOWWEDID", _scene_nxtscn_howwedid);
+ NXT_SCN_FUNCTION("PLAYERWON", _scene_nxtscn_playerwon);
+ NXT_SCN_FUNCTION("BACKTONXTGUIDE", _scene_nxtscn_backtonxtguide);
+ NXT_SCN_FUNCTION("FINISHGENERICSCENE", _scene_nxtscn_finishgenericscene);
+ NXT_SCN_FUNCTION("INITRANDOMCOWBOYS", _scene_nxtscn_initrandomcowboys);
+ NXT_SCN_FUNCTION("TOCOWBOYSCENES", _scene_nxtscn_tocowboyscenes);
+ NXT_SCN_FUNCTION("INITRANDOMFARMYARD", _scene_nxtscn_initrandomfarmyard);
+ NXT_SCN_FUNCTION("TOFARMYARDSCENES", _scene_nxtscn_tofarmyardscenes);
+ NXT_SCN_FUNCTION("INITRANDOMCAVE", _scene_nxtscn_initrandomcave);
+ NXT_SCN_FUNCTION("TOCAVESCENES", _scene_nxtscn_tocavescenes);
+ NXT_SCN_FUNCTION("PICKSKULLATCAVE", _scene_nxtscn_pickskullatcave);
+ NXT_SCN_FUNCTION("DRAWGUN", _scene_nxtscn_drawgun);
+#undef NXT_SCN_FUNCTION
+
+ _sceneShowMsg["DEFAULT"] = new MD2ScriptFunctionScene(this, &GameMaddog2::_scene_sm_donothing);
+ _sceneWepDwn["DEFAULT"] = new MD2ScriptFunctionScene(this, &GameMaddog2::_scene_default_wepdwn);
+ _sceneScnScr["DEFAULT"] = new MD2ScriptFunctionScene(this, &GameMaddog2::_scene_default_score);
+ _sceneNxtFrm["DEFAULT"] = new MD2ScriptFunctionScene(this, &GameMaddog2::_scene_nxtfrm);
+}
+
+void GameMaddog2::verifyScriptFunctions() {
+ Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
+ for (size_t i = 0; i < scenes->size(); i++) {
+ Scene *scene = (*scenes)[i];
+ getScriptFunctionScene(PREOP, scene->preop);
+ // TODO: SHOWMSG
+ getScriptFunctionScene(INSOP, scene->insop);
+ getScriptFunctionScene(WEPDWN, scene->wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->scnscr);
+ getScriptFunctionScene(NXTFRM, scene->nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->nxtscn);
+ for (size_t j = 0; j < scene->zones.size(); j++) {
+ Zone *zone = scene->zones[j];
+ getScriptFunctionZonePtrFb(zone->ptrfb);
+ for (size_t k = 0; k < zone->rects.size(); k++) {
+ getScriptFunctionRectHit(zone->rects[k].rectHit);
+ }
+ }
+ }
+}
+
+MD2ScriptFunctionPoint GameMaddog2::getScriptFunctionZonePtrFb(Common::String name) {
+ MD2ScriptFunctionPointMap::iterator it = _zonePtrFb.find(name);
+ if (it != _zonePtrFb.end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find zonePtrFb function: %s", name.c_str());
+ }
+}
+
+MD2ScriptFunctionRect GameMaddog2::getScriptFunctionRectHit(Common::String name) {
+ MD2ScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ if (it != _rectHitFuncs.end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find rectHit function: %s", name.c_str());
+ }
+}
+
+MD2ScriptFunctionScene GameMaddog2::getScriptFunctionScene(SceneFuncType type, Common::String name) {
+ MD2ScriptFunctionSceneMap *functionMap;
+ switch (type) {
+ case PREOP:
+ functionMap = &_scenePreOps;
+ break;
+ case SHOWMSG:
+ functionMap = &_sceneShowMsg;
+ break;
+ case INSOP:
+ functionMap = &_sceneInsOps;
+ break;
+ case WEPDWN:
+ functionMap = &_sceneWepDwn;
+ break;
+ case SCNSCR:
+ functionMap = &_sceneScnScr;
+ break;
+ case NXTFRM:
+ functionMap = &_sceneNxtFrm;
+ break;
+ case NXTSCN:
+ functionMap = &_sceneNxtScn;
+ break;
+ default:
+ error("Unkown scene script type: %u", type);
+ break;
+ }
+ MD2ScriptFunctionSceneMap::iterator it;
+ it = functionMap->find(name);
+ if (it != functionMap->end()) {
+ return (*(*it)._value);
+ } else {
+ error("Could not find scene type %u function: %s", type, name.c_str());
+ }
+}
+
+void GameMaddog2::callScriptFunctionZonePtrFb(Common::String name, Common::Point *point) {
+ MD2ScriptFunctionPoint function = getScriptFunctionZonePtrFb(name);
+ function(point);
+}
+
+void GameMaddog2::callScriptFunctionRectHit(Common::String name, Rect *rect) {
+ MD2ScriptFunctionRect function = getScriptFunctionRectHit(name);
+ function(rect);
+}
+
+void GameMaddog2::callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene) {
+ MD2ScriptFunctionScene function = getScriptFunctionScene(type, name);
+ function(scene);
+}
+
+Common::Error GameMaddog2::run() {
+ init();
+ _NewGame();
+ _cur_scene = _startscene;
+ Common::String oldscene;
+ while (!_vm->shouldQuit()) {
+ oldscene = _cur_scene;
+ _SetFrame();
+ _fired = false;
+ Scene *scene = _sceneInfo->findScene(_cur_scene);
+ if (!loadScene(scene)) {
+ error("Cannot find scene %s in libfile", scene->name.c_str());
+ }
+ Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
+ g_system->getMixer()->stopHandle(_sceneAudioHandle);
+ g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
+ _paletteDirty = true;
+ _nextFrameTime = _GetMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->preop, scene);
+ _currentFrame = _GetFrame(scene);
+ while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
+ _UpdateMouse();
+ // TODO: call scene->messageFunc
+ callScriptFunctionScene(INSOP, scene->insop, scene);
+ _holster = _WeaponDown();
+ if (_holster) {
+ callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ }
+ Common::Point firedCoords;
+ if (__Fired(&firedCoords)) {
+ if (!_holster) {
+ Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ if (hitGlobalRect != nullptr) {
+ callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
+ } else {
+ if (_shots > 0) {
+ if (!_debug_unlimitedAmmo) {
+ _shots--;
+ }
+ _UpdateStat();
+ Rect *hitRect = nullptr;
+ Zone *hitSceneZone = _CheckZonesV1(scene, hitRect, &firedCoords);
+ if (hitSceneZone != nullptr) {
+ callScriptFunctionZonePtrFb(hitSceneZone->ptrfb, &firedCoords);
+ callScriptFunctionRectHit(hitRect->rectHit, hitRect);
+ } else {
+ _default_bullethole(&firedCoords);
+ }
+ } else {
+ _PlaySound(_emptySound);
+ _emptyCount = 3;
+ _whichGun = 9;
+ }
+ }
+ }
+ }
+ if (_cur_scene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ }
+ _DisplayScore();
+ _MoveMouse();
+ if (_pauseTime > 0) {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ } else {
+ g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ }
+ if (_videoDecoder->getCurrentFrame() == 0) {
+ _videoDecoder->getNextFrame();
+ }
+ int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ if (remainingMillis < 10) {
+ if (_videoDecoder->getCurrentFrame() > 0) {
+ _videoDecoder->getNextFrame();
+ }
+ remainingMillis = _nextFrameTime - _GetMsTime();
+ _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ }
+ if (remainingMillis > 0) {
+ if (remainingMillis > 15) {
+ remainingMillis = 15;
+ }
+ g_system->delayMillis(remainingMillis);
+ }
+ _currentFrame = _GetFrame(scene);
+ updateScreen();
+ }
+ // frame limit reached or scene changed, prepare for next scene
+ _hadPause = false;
+ _pauseTime = 0;
+ if (_ret_scene != "") {
+ _cur_scene = _ret_scene;
+ _ret_scene = "";
+ }
+ if (_sub_scene != "") {
+ _ret_scene = _sub_scene;
+ _sub_scene = "";
+ }
+ if (_cur_scene == oldscene) {
Commit: 1ea02c3bbd529a7c8e9c4728c2d74824fafc4ab2
https://github.com/scummvm/scummvm/commit/1ea02c3bbd529a7c8e9c4728c2d74824fafc4ab2
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: fix MSVC errors and warnings
Changed paths:
engines/alg/game_bountyhunter.cpp
engines/alg/game_crimepatrol.cpp
engines/alg/game_drugwars.cpp
engines/alg/game_spacepirates.cpp
engines/alg/graphics.cpp
diff --git a/engines/alg/game_bountyhunter.cpp b/engines/alg/game_bountyhunter.cpp
index 57e16ae3500..686000ae25c 100644
--- a/engines/alg/game_bountyhunter.cpp
+++ b/engines/alg/game_bountyhunter.cpp
@@ -674,7 +674,7 @@ uint16 GameBountyHunter::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclud
if (*mask == fullMask) {
*mask = 0;
}
- uint16 random;
+ uint16 random = 0;
// find an unused random number
while (1) {
random = _rnd->getRandomNumber(max - 1);
diff --git a/engines/alg/game_crimepatrol.cpp b/engines/alg/game_crimepatrol.cpp
index ee20d1a302b..f335bcf85b0 100644
--- a/engines/alg/game_crimepatrol.cpp
+++ b/engines/alg/game_crimepatrol.cpp
@@ -651,7 +651,7 @@ uint16 GameCrimePatrol::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude
if (*mask == fullMask) {
*mask = 0;
}
- uint16 random;
+ uint16 random = 0;
// find an unused random number
while (1) {
random = _rnd->getRandomNumber(max - 1);
@@ -670,7 +670,7 @@ uint16 GameCrimePatrol::_PickRandomScene(uint8 index, uint8 max) {
if (max != 0) {
_random_max = max;
_random_mask = 0;
- _random_picked = -1;
+ _random_picked = 0;
_random_scene_count = 0;
while (_level_scenes[index][_random_scene_count] != 0) {
_random_scene_count++;
diff --git a/engines/alg/game_drugwars.cpp b/engines/alg/game_drugwars.cpp
index da78a0044b2..740024c4c49 100644
--- a/engines/alg/game_drugwars.cpp
+++ b/engines/alg/game_drugwars.cpp
@@ -603,7 +603,7 @@ uint16 GameDrugWars::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
if (*mask == fullMask) {
*mask = 0;
}
- uint16 random;
+ uint16 random = 0;
// find an unused random number
while (1) {
random = _rnd->getRandomNumber(max - 1);
@@ -625,7 +625,7 @@ uint16 GameDrugWars::_PickRandomScene(uint8 index, uint8 max) {
if (max != 0) {
_random_max = max;
_random_mask = 0;
- _random_picked = -1;
+ _random_picked = 0;
_random_scene_count = 0;
while (_random_scenes[index][_random_scene_count] != 0) {
_random_scene_count++;
diff --git a/engines/alg/game_spacepirates.cpp b/engines/alg/game_spacepirates.cpp
index 58152e9d6ff..5cc62d2f2fd 100644
--- a/engines/alg/game_spacepirates.cpp
+++ b/engines/alg/game_spacepirates.cpp
@@ -760,7 +760,7 @@ void GameSpacePirates::_DisplayShotLine(uint16 startX, uint16 startY, uint16 end
int16 deltaX = endX - startX;
int16 deltaY = endY - startY;
int16 stepX, stepY;
- int16 steep, accum, error;
+ int16 steep = 0, accum = 0, error = 0;
if (deltaX > 0)
stepX = 1;
else if (deltaX == 0)
@@ -810,7 +810,7 @@ uint16 GameSpacePirates::_SceneToNumber(Scene *scene) {
uint16 GameSpacePirates::_RandomUnusedScene(uint8 max) {
bool found = 0;
- uint8 random;
+ uint8 random = 0;
for (uint8 i = 0; i < max && !found; i++) {
random = _rnd->getRandomNumber(max - 1);
if (_random_scenes_used[random] == 0) {
diff --git a/engines/alg/graphics.cpp b/engines/alg/graphics.cpp
index fa1054a32dc..0605da13872 100644
--- a/engines/alg/graphics.cpp
+++ b/engines/alg/graphics.cpp
@@ -42,7 +42,7 @@ Graphics::Surface *AlgGraphics::loadVgaBackground(const Common::Path &path, uint
assert(width >= 317 && width <= 320);
assert(height == 200);
assert(paletteStart == 0x10);
- for (uint32 i = paletteStart * 3; i < (paletteStart + paletteEntries) * 3; i += 3) {
+ for (uint32 i = paletteStart * 3; i < (paletteStart + paletteEntries) * 3U; i += 3) {
palette[i] = vgaFile.readByte();
palette[i + 1] = vgaFile.readByte();
palette[i + 2] = vgaFile.readByte();
@@ -67,7 +67,7 @@ Common::Array<Graphics::Surface> *AlgGraphics::loadAniImage(const Common::Path &
}
uint8 paletteEntries = aniFile.readByte();
uint8 paletteStart = aniFile.readByte();
- for (uint32 i = paletteStart * 3; i < (paletteStart + paletteEntries) * 3; i += 3) {
+ for (uint32 i = paletteStart * 3; i < (paletteStart + paletteEntries) * 3U; i += 3) {
palette[i] = aniFile.readByte();
palette[i + 1] = aniFile.readByte();
palette[i + 2] = aniFile.readByte();
@@ -113,7 +113,7 @@ Common::Array<Graphics::Surface> *AlgGraphics::loadScreenCoordAniImage(const Com
}
uint8 paletteEntries = aniFile.readByte();
uint8 paletteStart = aniFile.readByte();
- for (uint32 i = paletteStart * 3; i < (paletteStart + paletteEntries) * 3; i += 3) {
+ for (uint32 i = paletteStart * 3; i < (paletteStart + paletteEntries) * 3U; i += 3) {
palette[i] = aniFile.readByte();
palette[i + 1] = aniFile.readByte();
palette[i + 2] = aniFile.readByte();
Commit: c6740e1c3668181204b0e766c3d8c9634dca5d0e
https://github.com/scummvm/scummvm/commit/c6740e1c3668181204b0e766c3d8c9634dca5d0e
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: formatting, code style, implement feedback
Changed paths:
A engines/alg/detection.h
engines/alg/alg.cpp
engines/alg/alg.h
engines/alg/configure.engine
engines/alg/detection.cpp
engines/alg/detection_tables.h
engines/alg/game.cpp
engines/alg/game.h
engines/alg/game_bountyhunter.cpp
engines/alg/game_bountyhunter.h
engines/alg/game_crimepatrol.cpp
engines/alg/game_crimepatrol.h
engines/alg/game_drugwars.cpp
engines/alg/game_drugwars.h
engines/alg/game_johnnyrock.cpp
engines/alg/game_johnnyrock.h
engines/alg/game_maddog.cpp
engines/alg/game_maddog.h
engines/alg/game_maddog2.cpp
engines/alg/game_maddog2.h
engines/alg/game_spacepirates.cpp
engines/alg/game_spacepirates.h
engines/alg/graphics.cpp
engines/alg/metaengine.cpp
engines/alg/module.mk
engines/alg/scene.cpp
engines/alg/scene.h
engines/alg/video.cpp
diff --git a/engines/alg/alg.cpp b/engines/alg/alg.cpp
index 71f8d4e2a16..18368c8e90a 100644
--- a/engines/alg/alg.cpp
+++ b/engines/alg/alg.cpp
@@ -22,6 +22,7 @@
#include "engines/util.h"
#include "alg/alg.h"
+#include "alg/detection.h"
#include "alg/game.h"
#include "alg/game_bountyhunter.h"
#include "alg/game_crimepatrol.h"
@@ -33,36 +34,60 @@
namespace Alg {
-AlgEngine::AlgEngine(OSystem *syst, const ADGameDescription *desc)
+AlgEngine::AlgEngine(OSystem *syst, const AlgGameDescription *gd)
: Engine(syst) {
- if (scumm_stricmp(desc->gameId, "cpatrols") == 0 || scumm_stricmp(desc->gameId, "cpatrold") == 0 || scumm_stricmp(desc->gameId, "cpatroldemo") == 0) {
- GameCrimePatrol *game = new GameCrimePatrol(this, desc);
+ switch (gd->gameType) {
+ case Alg::GType_CPATROL_SS_DOS:
+ case Alg::GType_CPATROL_DS_DOS:
+ case Alg::GType_CPATROL_DEMO_DOS: {
+ GameCrimePatrol *game = new GameCrimePatrol(this, gd);
_debugger = new DebuggerCrimePatrol(game);
_game = game;
- } else if (scumm_stricmp(desc->gameId, "dwarss") == 0 || scumm_stricmp(desc->gameId, "dwarsd") == 0 || scumm_stricmp(desc->gameId, "dwarsdemo") == 0) {
- GameDrugWars *game = new GameDrugWars(this, desc);
+ break;
+ }
+ case Alg::GType_DWARS_SS_DOS:
+ case Alg::GType_DWARS_DS_DOS:
+ case Alg::GType_DWARS_DEMO_DOS: {
+ GameDrugWars *game = new GameDrugWars(this, gd);
_debugger = new DebuggerDrugWars(game);
_game = game;
- } else if (scumm_stricmp(desc->gameId, "johnrocs") == 0 || scumm_stricmp(desc->gameId, "johnrocd") == 0) {
- GameJohnnyRock *game = new GameJohnnyRock(this, desc);
+ break;
+ }
+ case Alg::GType_JOHNROC_SS_DOS:
+ case Alg::GType_JOHNROC_DS_DOS: {
+ GameJohnnyRock *game = new GameJohnnyRock(this, gd);
_debugger = new DebuggerJohnnyRock(game);
_game = game;
- } else if (scumm_stricmp(desc->gameId, "lbhunter") == 0 || scumm_stricmp(desc->gameId, "lbhunterdemo") == 0) {
- GameBountyHunter *game = new GameBountyHunter(this, desc);
+ break;
+ }
+ case Alg::GType_LBHUNTER_DOS:
+ case Alg::GType_LBHUNTER_DEMO_DOS: {
+ GameBountyHunter *game = new GameBountyHunter(this, gd);
_debugger = new DebuggerBountyHunter(game);
_game = game;
- } else if (scumm_stricmp(desc->gameId, "maddog") == 0) {
- GameMaddog *game = new GameMaddog(this, desc);
+ break;
+ }
+ case Alg::GType_MADDOG_DOS: {
+ GameMaddog *game = new GameMaddog(this, gd);
_debugger = new DebuggerMaddog(game);
_game = game;
- } else if (scumm_stricmp(desc->gameId, "maddog2s") == 0 || scumm_stricmp(desc->gameId, "maddog2d") == 0) {
- GameMaddog2 *game = new GameMaddog2(this, desc);
+ break;
+ }
+ case Alg::GType_MADDOG2_SS_DOS:
+ case Alg::GType_MADDOG2_DS_DOS: {
+ GameMaddog2 *game = new GameMaddog2(this, gd);
_debugger = new DebuggerMaddog2(game);
_game = game;
- } else if (scumm_stricmp(desc->gameId, "spiratess") == 0 || scumm_stricmp(desc->gameId, "spiratesd") == 0 || scumm_stricmp(desc->gameId, "spiratesdemo") == 0) {
- GameSpacePirates *game = new GameSpacePirates(this, desc);
+ break;
+ }
+ case Alg::GType_SPIRATES_SS_DOS:
+ case Alg::GType_SPIRATES_DS_DOS:
+ case Alg::GType_SPIRATES_DEMO_DOS: {
+ GameSpacePirates *game = new GameSpacePirates(this, gd);
_debugger = new DebuggerSpacePirates(game);
_game = game;
+ break;
+ }
}
}
diff --git a/engines/alg/alg.h b/engines/alg/alg.h
index f1bb02b15c9..fe7ea27e6a1 100644
--- a/engines/alg/alg.h
+++ b/engines/alg/alg.h
@@ -19,12 +19,14 @@
*
*/
-#ifndef ALG_ALG_H
-#define ALG_ALG_H
+#ifndef ALG_H
+#define ALG_H
#include "engines/advancedDetector.h"
#include "gui/debugger.h"
+#include "alg/detection.h"
+
namespace Alg {
class Game;
@@ -37,13 +39,13 @@ class GameMaddog2;
class GameSpacePirates;
enum {
- kAlgDebugGeneral = 1 << 0,
- kAlgDebugGraphics = 1 << 1
+ kAlgDebugGeneral = 1,
+ kAlgDebugGraphics
};
class AlgEngine : public Engine {
public:
- AlgEngine(OSystem *syst, const ADGameDescription *desc);
+ AlgEngine(OSystem *syst, const AlgGameDescription *desc);
~AlgEngine();
Common::Error run();
diff --git a/engines/alg/configure.engine b/engines/alg/configure.engine
index 18b80705aed..a9e02e7404c 100644
--- a/engines/alg/configure.engine
+++ b/engines/alg/configure.engine
@@ -1,3 +1,3 @@
# This file is included from the main "configure" script
-# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
+# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] [components]
add_engine alg "American Laser Games" no
diff --git a/engines/alg/detection.cpp b/engines/alg/detection.cpp
index b2d395fc2ad..126592e7327 100644
--- a/engines/alg/detection.cpp
+++ b/engines/alg/detection.cpp
@@ -22,8 +22,9 @@
#include "base/plugins.h"
#include "engines/advancedDetector.h"
-#include "alg/detection_tables.h"
#include "alg/alg.h"
+#include "alg/detection.h"
+#include "alg/detection_tables.h"
static const PlainGameDescriptor algGame[] = {
{ "cpatrols", "Crime Patrol (lower video quality)" },
@@ -51,7 +52,7 @@ static const DebugChannelDef debugFlagList[] = {
DEBUG_CHANNEL_END
};
-class AlgMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDescription> {
+class AlgMetaEngineDetection : public AdvancedMetaEngineDetection<Alg::AlgGameDescription> {
public:
AlgMetaEngineDetection() : AdvancedMetaEngineDetection(Alg::gameDescriptions, algGame) {
_guiOptions = GUIO1(GUIO_NOMIDI);
diff --git a/engines/alg/detection.h b/engines/alg/detection.h
new file mode 100644
index 00000000000..b2ab0660070
--- /dev/null
+++ b/engines/alg/detection.h
@@ -0,0 +1,63 @@
+/* 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 ALG_DETECTION_H
+#define ALG_DETECTION_H
+
+#include "engines/advancedDetector.h"
+
+namespace Alg {
+
+enum AlgGameType {
+ GType_CPATROL_SS_DOS,
+ GType_CPATROL_DS_DOS,
+ GType_CPATROL_DEMO_DOS,
+ GType_DWARS_SS_DOS,
+ GType_DWARS_DS_DOS,
+ GType_DWARS_DEMO_DOS,
+ GType_JOHNROC_SS_DOS,
+ GType_JOHNROC_DS_DOS,
+ GType_LBHUNTER_DOS,
+ GType_LBHUNTER_DEMO_DOS,
+ GType_MADDOG_DOS,
+ GType_MADDOG2_SS_DOS,
+ GType_MADDOG2_DS_DOS,
+ GType_SPIRATES_SS_DOS,
+ GType_SPIRATES_DS_DOS,
+ GType_SPIRATES_DEMO_DOS,
+};
+
+struct AlgGameDescription {
+ ADGameDescription desc;
+ uint8 gameType;
+
+ uint32 sizeBuffer() const {
+ return desc.sizeBuffer();
+ }
+
+ void *toBuffer(void *buffer) {
+ return desc.toBuffer(buffer);
+ }
+};
+
+} // End of namespace Alg
+
+#endif // ALG_DETECTION_H
diff --git a/engines/alg/detection_tables.h b/engines/alg/detection_tables.h
index 313b702fca2..c349a906a13 100644
--- a/engines/alg/detection_tables.h
+++ b/engines/alg/detection_tables.h
@@ -21,169 +21,217 @@
namespace Alg {
-static const ADGameDescription gameDescriptions[] = {
+static const AlgGameDescription gameDescriptions[] = {
{
// Crime Patrol (v1.00) (Single Speed CD-ROM Version)
- "cpatrols",
- "",
- AD_ENTRY1s("CPSS.LIB", "feddb53975c9832c0f54055c15350389", 193353403),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "cpatrols",
+ "",
+ AD_ENTRY1s("CPSS.LIB", "feddb53975c9832c0f54055c15350389", 193353403),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_CPATROL_SS_DOS,
},
{
// Crime Patrol (v1.00) (Double Speed CD-ROM Version)
- "cpatrold",
- "",
- AD_ENTRY1s("CPDS.LIB", "43579f72207298f154f6fb2b1a24e193", 303710700),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "cpatrold",
+ "",
+ AD_ENTRY1s("CPDS.LIB", "43579f72207298f154f6fb2b1a24e193", 303710700),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_CPATROL_DS_DOS,
},
{
// Crime Patrol Demo
- "cpatroldemo",
- "",
- AD_ENTRY1s("CP.LIB", "0621e198afb7be96279beec770cd8461", 16859660),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "cpatroldemo",
+ "",
+ AD_ENTRY1s("CP.LIB", "0621e198afb7be96279beec770cd8461", 16859660),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_CPATROL_DEMO_DOS,
},
{
// Drug Wars (v1.00) (Single Speed CD-ROM Version)
- "dwarss",
- "",
- AD_ENTRY1s("DWSS.LIB", "f041a2b106d3ba27b03b5695e5263172", 191903386),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "dwarss",
+ "",
+ AD_ENTRY1s("DWSS.LIB", "f041a2b106d3ba27b03b5695e5263172", 191903386),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_DWARS_SS_DOS,
},
{
// Drug Wars (v1.00) (Double Speed CD-ROM Version)
- "dwarsd",
- "",
- AD_ENTRY1s("DWDS.LIB", "f00bc0d980eac72b6bbfa691808b62ae", 320739868),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "dwarsd",
+ "",
+ AD_ENTRY1s("DWDS.LIB", "f00bc0d980eac72b6bbfa691808b62ae", 320739868),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_DWARS_DS_DOS,
},
{
// Drug Wars Demo
- "dwarsdemo",
- "",
- AD_ENTRY1s("DWDEMO.LIB", "1f0cf57c8aeb326c37777c4ad82e7889", 24435449),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "dwarsdemo",
+ "",
+ AD_ENTRY1s("DWDEMO.LIB", "1f0cf57c8aeb326c37777c4ad82e7889", 24435449),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_DWARS_DEMO_DOS,
},
{
// Who Shot Johnny Rock? (v1.00) (Single Speed CD-ROM Version)
- "johnrocs",
- "",
- AD_ENTRY1s("JOHNROC.LIB", "3cbf7843ef2fdf23716301dceaa2eb10", 141833752),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "johnrocs",
+ "",
+ AD_ENTRY1s("JOHNROC.LIB", "3cbf7843ef2fdf23716301dceaa2eb10", 141833752),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_JOHNROC_SS_DOS,
},
{
// Who Shot Johnny Rock? (v1.00) (Double Speed CD-ROM Version)
- "johnrocd",
- "",
- AD_ENTRY1s("JOHNROCD.LIB", "93c38b5fc7d1ae6e9dccf4f7a1c313a8", 326535618),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "johnrocd",
+ "",
+ AD_ENTRY1s("JOHNROCD.LIB", "93c38b5fc7d1ae6e9dccf4f7a1c313a8", 326535618),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_JOHNROC_DS_DOS,
},
{
// The Last Bounty Hunter (v1.00)
- "lbhunter",
- "",
- AD_ENTRY1s("BHDS.LIB", "6fad52a6a72830ab3373cbe3e0a3a779", 281473503),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "lbhunter",
+ "",
+ AD_ENTRY1s("BHDS.LIB", "6fad52a6a72830ab3373cbe3e0a3a779", 281473503),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_LBHUNTER_DOS,
},
{
// The Last Bounty Hunter Demo
- "lbhunterdemo",
- "",
- AD_ENTRY1s("BHDEMO.LIB", "af5fbbd5e18d96225077eb6bf2cac680", 28368775),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "lbhunterdemo",
+ "",
+ AD_ENTRY1s("BHDEMO.LIB", "af5fbbd5e18d96225077eb6bf2cac680", 28368775),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_LBHUNTER_DEMO_DOS,
},
{
// Mad Dog McCree (v1.03a)
- "maddog",
- "",
- AD_ENTRY1s("MADDOG.LIB", "df27e760531dba600cb3ebc23a2d98d1", 114633310),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "maddog",
+ "",
+ AD_ENTRY1s("MADDOG.LIB", "df27e760531dba600cb3ebc23a2d98d1", 114633310),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_MADDOG_DOS,
},
{
// Mad Dog II: The Lost Gold (v1.00) (Single Speed CD-ROM Version)
- "maddog2s",
- "",
- AD_ENTRY1s("MADDOG2.LIB", "7b54bca3932b28d8776eaed16a9f43b5", 185708043),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "maddog2s",
+ "",
+ AD_ENTRY1s("MADDOG2.LIB", "7b54bca3932b28d8776eaed16a9f43b5", 185708043),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_MADDOG2_SS_DOS,
},
{
// Mad Dog II: The Lost Gold (v1.00) (Double Speed CD-ROM Version)
- "maddog2d",
- "",
- AD_ENTRY1s("MADDOG2D.LIB", "1660b1728573481483c50206ad92a0ca", 291119013),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "maddog2d",
+ "",
+ AD_ENTRY1s("MADDOG2D.LIB", "1660b1728573481483c50206ad92a0ca", 291119013),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_MADDOG2_DS_DOS,
},
{
// Space Pirates (v1.00) (Single Speed CD-ROM Version)
- "spiratess",
- "",
- AD_ENTRY1s("SPSS.LIB", "c006d9f85fd86024b57d69875f23c473", 175141152),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "spiratess",
+ "",
+ AD_ENTRY1s("SPSS.LIB", "c006d9f85fd86024b57d69875f23c473", 175141152),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_SPIRATES_SS_DOS,
},
{
// Space Pirates (v1.00) (Double Speed CD-ROM Version)
- "spiratesd",
- "",
- AD_ENTRY1s("SPDS.LIB", "223d3a339d542905c437a6a63cf6dbd8", 273506701),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "spiratesd",
+ "",
+ AD_ENTRY1s("SPDS.LIB", "223d3a339d542905c437a6a63cf6dbd8", 273506701),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_SPIRATES_DS_DOS,
},
{
// Space Pirates Demo
- "spiratesdemo",
- "",
- AD_ENTRY1s("SP.LIB", "a1a1b7c9ed28ff2484ab8362825c3973", 14556553),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ {
+ "spiratesdemo",
+ "",
+ AD_ENTRY1s("SP.LIB", "a1a1b7c9ed28ff2484ab8362825c3973", 14556553),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NOMIDI)
+ },
+ GType_SPIRATES_DEMO_DOS,
},
- AD_TABLE_END_MARKER
+ { AD_TABLE_END_MARKER, 0 }
};
} // End of namespace Alg
diff --git a/engines/alg/game.cpp b/engines/alg/game.cpp
index 6fec0298210..137109948a5 100644
--- a/engines/alg/game.cpp
+++ b/engines/alg/game.cpp
@@ -35,17 +35,6 @@ namespace Alg {
Game::Game(AlgEngine *vm) {
_vm = vm;
- _inMenu = false;
- _palette = new uint8[257 * 3]();
- // blue for rect display
- _palette[5] = 0xFF;
- _paletteDirty = true;
- _screen = new Graphics::Surface();
- _rnd = new Common::RandomSource("alg");
- _screen->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
- _videoDecoder = new AlgVideoDecoder();
- _videoDecoder->setPalette(_palette);
- _sceneInfo = new SceneInfo();
}
Game::~Game() {
@@ -59,6 +48,20 @@ Game::~Game() {
delete _sceneInfo;
}
+void Game::init() {
+ _inMenu = false;
+ _palette = new uint8[257 * 3]();
+ // blue for rect display
+ _palette[5] = 0xFF;
+ _paletteDirty = true;
+ _screen = new Graphics::Surface();
+ _rnd = new Common::RandomSource("alg");
+ _screen->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
+ _videoDecoder = new AlgVideoDecoder();
+ _videoDecoder->setPalette(_palette);
+ _sceneInfo = new SceneInfo();
+}
+
Common::Error Game::run() {
return Common::kNoError;
}
@@ -90,7 +93,7 @@ bool Game::pollEvents() {
void Game::loadLibArchive(const Common::Path &path) {
debug("loading lib archive: %s", path.toString().c_str());
if (!_libFile.open(path)) {
- error("Can't open library file '%s'", path.toString().c_str());
+ error("Game::loadLibArchive(): Can't open library file '%s'", path.toString().c_str());
}
uint16 magicBytes = _libFile.readSint16LE();
uint32 indexOffset = _libFile.readSint32LE();
@@ -112,10 +115,10 @@ void Game::loadLibArchive(const Common::Path &path) {
}
bool Game::loadScene(Scene *scene) {
- Common::String sceneFileName = Common::String::format("%s.mm", scene->name.c_str());
- Common::HashMap<Common::String, uint32>::iterator it = _libFileEntries.find(sceneFileName);
+ Common::String sceneFileName = Common::String::format("%s.mm", scene->_name.c_str());
+ auto it = _libFileEntries.find(sceneFileName);
if (it != _libFileEntries.end()) {
- debug("loaded scene %s", scene->name.c_str());
+ debug("loaded scene %s", scene->_name.c_str());
_videoDecoder->loadVideoFromStream(it->_value);
return true;
} else {
@@ -137,11 +140,11 @@ void Game::updateScreen() {
g_system->updateScreen();
}
-uint32 Game::_GetMsTime() {
+uint32 Game::getMsTime() {
return g_system->getMillis();
}
-bool Game::__Fired(Common::Point *point) {
+bool Game::fired(Common::Point *point) {
_fired = false;
pollEvents();
if (_leftDown == true) {
@@ -159,29 +162,27 @@ bool Game::__Fired(Common::Point *point) {
}
}
-Rect *Game::_CheckZone(Zone *zone, Common::Point *point) {
- Common::Array<Rect>::iterator rect;
- for (rect = zone->rects.begin(); rect != zone->rects.end(); ++rect) {
- if (point->x >= rect->left &&
- point->x <= rect->right &&
- point->y >= rect->top &&
- point->y <= rect->bottom) {
- return rect;
+Rect *Game::checkZone(Zone *zone, Common::Point *point) {
+ for (auto &rect : zone->_rects) {
+ if (point->x >= rect.left &&
+ point->x <= rect.right &&
+ point->y >= rect.top &&
+ point->y <= rect.bottom) {
+ return ▭
}
}
return nullptr;
}
// This is used by earlier games
-Zone *Game::_CheckZonesV1(Scene *scene, Rect *&hitRect, Common::Point *point) {
- Common::Array<Zone *>::iterator zone;
- for (zone = scene->zones.begin(); zone != scene->zones.end(); ++zone) {
- unsigned long startFrame = (*zone)->startFrame - _videoFrameSkip + 1;
- unsigned long endFrame = (*zone)->endFrame + _videoFrameSkip - 1;
+Zone *Game::checkZonesV1(Scene *scene, Rect *&hitRect, Common::Point *point) {
+ for (auto &zone : scene->_zones) {
+ uint32 startFrame = zone->_startFrame - _videoFrameSkip + 1;
+ uint32 endFrame = zone->_endFrame + _videoFrameSkip - 1;
if (_currentFrame >= startFrame && _currentFrame <= endFrame) {
- hitRect = _CheckZone(*zone, point);
+ hitRect = checkZone(zone, point);
if (hitRect != nullptr) {
- return *zone;
+ return zone;
}
}
}
@@ -189,15 +190,14 @@ Zone *Game::_CheckZonesV1(Scene *scene, Rect *&hitRect, Common::Point *point) {
}
// This is used by later games
-Zone *Game::_CheckZonesV2(Scene *scene, Rect *&hitRect, Common::Point *point) {
- Common::Array<Zone *>::iterator zone;
- for (zone = scene->zones.begin(); zone != scene->zones.end(); ++zone) {
- unsigned long startFrame = (*zone)->startFrame - (_videoFrameSkip + 1) + ((_difficulty - 1) * _videoFrameSkip);
- unsigned long endFrame = (*zone)->endFrame + (_videoFrameSkip - 1) - ((_difficulty - 1) * _videoFrameSkip);
+Zone *Game::checkZonesV2(Scene *scene, Rect *&hitRect, Common::Point *point) {
+ for (auto &zone : scene->_zones) {
+ uint32 startFrame = zone->_startFrame - (_videoFrameSkip + 1) + ((_difficulty - 1) * _videoFrameSkip);
+ uint32 endFrame = zone->_endFrame + (_videoFrameSkip - 1) - ((_difficulty - 1) * _videoFrameSkip);
if (_currentFrame >= startFrame && _currentFrame <= endFrame) {
- hitRect = _CheckZone(*zone, point);
+ hitRect = checkZone(zone, point);
if (hitRect != nullptr) {
- return *zone;
+ return zone;
}
}
}
@@ -205,24 +205,24 @@ Zone *Game::_CheckZonesV2(Scene *scene, Rect *&hitRect, Common::Point *point) {
}
// only used by earlier games
-void Game::_AdjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty) {
+void Game::adjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty) {
Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
for (size_t i = 0; i < scenes->size(); i++) {
Scene *scene = (*scenes)[i];
- if (!(scene->diff & 0x01)) {
- if (scene->preop == "PAUSE" || scene->preop == "PAUSFI" || scene->preop == "PAUSPR") {
- scene->dataParam1 = (scene->dataParam1 * _pausdifscal[newDifficulty - 1]) / _pausdifscal[oldDifficulty - 1];
+ if (!(scene->_diff & 0x01)) {
+ if (scene->_preop == "PAUSE" || scene->_preop == "PAUSFI" || scene->_preop == "PAUSPR") {
+ scene->_dataParam1 = (scene->_dataParam1 * _pauseDiffScale[newDifficulty - 1]) / _pauseDiffScale[oldDifficulty - 1];
}
}
- for (size_t j = 0; j < scene->zones.size(); j++) {
- Zone *zone = scene->zones[j];
- for (size_t k = 0; k < zone->rects.size(); k++) {
- Rect *rect = &zone->rects[k];
- if (!(scene->diff & 0x02)) {
+ for (size_t j = 0; j < scene->_zones.size(); j++) {
+ Zone *zone = scene->_zones[j];
+ for (size_t k = 0; k < zone->_rects.size(); k++) {
+ Rect *rect = &zone->_rects[k];
+ if (!(scene->_diff & 0x02)) {
int16 cx = (rect->left + rect->right) / 2;
int16 cy = (rect->top + rect->bottom) / 2;
- int32 w = (rect->width() * _rectdifscal[newDifficulty - 1]) / _rectdifscal[oldDifficulty - 1];
- int32 h = (rect->height() * _rectdifscal[newDifficulty - 1]) / _rectdifscal[oldDifficulty - 1];
+ int32 w = (rect->width() * _rectDiffScale[newDifficulty - 1]) / _rectDiffScale[oldDifficulty - 1];
+ int32 h = (rect->height() * _rectDiffScale[newDifficulty - 1]) / _rectDiffScale[oldDifficulty - 1];
rect->center(cx, cy, w, h);
}
}
@@ -230,52 +230,46 @@ void Game::_AdjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty) {
}
}
-void Game::_RestoreCursor() {
-}
-
-uint32 Game::_GetFrame(Scene *scene) {
+uint32 Game::getFrame(Scene *scene) {
if (_videoDecoder->getCurrentFrame() == 0) {
- return scene->startFrame;
+ return scene->_startFrame;
}
- return scene->startFrame + (_videoDecoder->getCurrentFrame() * _videoFrameSkip) - _videoFrameSkip;
-}
-
-void Game::_SetFrame() {
+ return scene->_startFrame + (_videoDecoder->getCurrentFrame() * _videoFrameSkip) - _videoFrameSkip;
}
-int8 Game::_SkipToNewScene(Scene *scene) {
+int8 Game::skipToNewScene(Scene *scene) {
if (!_gameInProgress || _sceneSkipped) {
return 0;
}
- if (scene->dataParam2 == -1) {
+ if (scene->_dataParam2 == -1) {
_sceneSkipped = true;
return -1;
- } else if (scene->dataParam2 > 0) {
- uint32 startFrame = scene->dataParam3;
- if (startFrame == 0) {
- startFrame = scene->startFrame + 15;
- }
- uint32 endFrame = scene->dataParam4;
- if (_currentFrame < endFrame && _currentFrame > startFrame) {
+ } else if (scene->_dataParam2 > 0) {
+ uint32 startFrame = scene->_dataParam3;
+ if (startFrame == 0) {
+ startFrame = scene->_startFrame + 15;
+ }
+ uint32 endFrame = scene->_dataParam4;
+ if (_currentFrame < endFrame && _currentFrame > startFrame) {
_sceneSkipped = true;
- return 1;
- }
- }
+ return 1;
+ }
+ }
return 0;
}
// Sound
-Audio::SeekableAudioStream *Game::_LoadSoundFile(const Common::Path &path) {
+Audio::SeekableAudioStream *Game::loadSoundFile(const Common::Path &path) {
Common::File *file = new Common::File();
if (!file->open(path)) {
- warning("Can't open sound file '%s'", path.toString().c_str());
+ warning("Game::loadSoundFile(): Can't open sound file '%s'", path.toString().c_str());
delete file;
return nullptr;
}
return Audio::makeRawStream(new Common::SeekableSubReadStream(file, 0, file->size(), DisposeAfterUse::NO), 8000, Audio::FLAG_UNSIGNED, DisposeAfterUse::NO);
}
-void Game::_PlaySound(Audio::SeekableAudioStream *stream) {
+void Game::playSound(Audio::SeekableAudioStream *stream) {
if (stream != nullptr) {
stream->rewind();
g_system->getMixer()->stopHandle(_sfxAudioHandle);
@@ -283,45 +277,45 @@ void Game::_PlaySound(Audio::SeekableAudioStream *stream) {
}
}
-void Game::_DoDiffSound(uint8 difficulty) {
+void Game::doDiffSound(uint8 difficulty) {
switch (difficulty) {
case 1:
- return _PlaySound(_easySound);
+ return playSound(_easySound);
case 2:
- return _PlaySound(_avgSound);
+ return playSound(_avgSound);
case 3:
- return _PlaySound(_hardSound);
+ return playSound(_hardSound);
}
}
-void Game::_DoSaveSound() {
- _PlaySound(_saveSound);
+void Game::doSaveSound() {
+ playSound(_saveSound);
}
-void Game::_DoLoadSound() {
- _PlaySound(_loadSound);
+void Game::doLoadSound() {
+ playSound(_loadSound);
}
-void Game::_DoSkullSound() {
- _PlaySound(_skullSound);
+void Game::doSkullSound() {
+ playSound(_skullSound);
}
-void Game::_DoShot() {
- _PlaySound(_shotSound);
+void Game::doShot() {
+ playSound(_shotSound);
}
// Timer
-static void _cursorTimer(void *refCon) {
+static void cursorTimerCallback(void *refCon) {
Game *game = static_cast<Game *>(refCon);
game->runCursorTimer();
}
-void Game::_SetupCursorTimer() {
- g_system->getTimerManager()->installTimerProc(&_cursorTimer, 1000000 / 50, (void *)this, "newtimer");
+void Game::setupCursorTimer() {
+ g_system->getTimerManager()->installTimerProc(&cursorTimerCallback, 1000000 / 50, (void *)this, "newtimer");
}
-void Game::_RemoveCursorTimer() {
- g_system->getTimerManager()->removeTimerProc(&_cursorTimer);
+void Game::removeCursorTimer() {
+ g_system->getTimerManager()->removeTimerProc(&cursorTimerCallback);
}
void Game::runCursorTimer() {
@@ -356,154 +350,151 @@ void Game::runCursorTimer() {
}
// Script functions: Zone
-void Game::_zone_globalhit(Common::Point *point) {
+void Game::zoneGlobalHit(Common::Point *point) {
// do nothing
}
// Script functions: RectHit
-void Game::_rect_hit_donothing(Rect *rect) {
+void Game::rectHitDoNothing(Rect *rect) {
// do nothing
}
-void Game::_rect_newscene(Rect *rect) {
- _score += rect->score;
- if (!rect->scene.empty()) {
- _cur_scene = rect->scene;
+void Game::rectNewScene(Rect *rect) {
+ _score += rect->_score;
+ if (!rect->_scene.empty()) {
+ _curScene = rect->_scene;
}
}
-void Game::_rect_easy(Rect *rect) {
- _DoDiffSound(1);
+void Game::rectEasy(Rect *rect) {
+ doDiffSound(1);
_difficulty = 1;
}
-void Game::_rect_average(Rect *rect) {
- _DoDiffSound(2);
+void Game::rectAverage(Rect *rect) {
+ doDiffSound(2);
_difficulty = 2;
}
-void Game::_rect_hard(Rect *rect) {
- _DoDiffSound(3);
+void Game::rectHard(Rect *rect) {
+ doDiffSound(3);
_difficulty = 3;
}
-void Game::_rect_exit(Rect *rect) {
+void Game::rectExit(Rect *rect) {
_vm->quitGame();
}
// Script functions: Scene PreOps
-void Game::_scene_pso_drawrct(Scene *scene) {
+void Game::scenePsoDrawRct(Scene *scene) {
}
-void Game::_scene_pso_pause(Scene *scene) {
+void Game::scenePsoPause(Scene *scene) {
_hadPause = false;
_pauseTime = 0;
}
-void Game::_scene_pso_drawrct_fadein(Scene *scene) {
- _scene_pso_drawrct(scene);
- _scene_pso_fadein(scene);
+void Game::scenePsoDrawRctFadeIn(Scene *scene) {
+ scenePsoDrawRct(scene);
+ scenePsoFadeIn(scene);
}
-void Game::_scene_pso_fadein(Scene *scene) {
+void Game::scenePsoFadeIn(Scene *scene) {
// do nothing
}
-void Game::_scene_pso_pause_fadein(Scene *scene) {
- _scene_pso_pause(scene);
- _scene_pso_fadein(scene);
+void Game::scenePsoPauseFadeIn(Scene *scene) {
+ scenePsoPause(scene);
+ scenePsoFadeIn(scene);
}
-void Game::_scene_pso_preread(Scene *scene) {
+void Game::scenePsoPreRead(Scene *scene) {
// do nothing
}
-void Game::_scene_pso_pause_preread(Scene *scene) {
- _scene_pso_pause(scene);
- _scene_pso_preread(scene);
+void Game::scenePsoPausePreRead(Scene *scene) {
+ scenePsoPause(scene);
+ scenePsoPreRead(scene);
}
// Script functions: Scene Scene InsOps
-void Game::_scene_iso_donothing(Scene *scene) {
+void Game::sceneIsoDoNothing(Scene *scene) {
// do nothing
}
-void Game::_scene_iso_startgame(Scene *scene) {
- _startscene = scene->insopParam;
+void Game::sceneIsoStartGame(Scene *scene) {
+ _startScene = scene->_insopParam;
}
-void Game::_scene_iso_pause(Scene *scene) {
+void Game::sceneIsoPause(Scene *scene) {
bool checkPause = true;
if (_hadPause) {
checkPause = false;
}
- if (_currentFrame > scene->endFrame) {
+ if (_currentFrame > scene->_endFrame) {
checkPause = false;
}
- if (scene->dataParam1 <= 0) {
+ if (scene->_dataParam1 <= 0) {
checkPause = false;
}
if (checkPause) {
- unsigned long pauseStart = atoi(scene->insopParam.c_str());
- unsigned long pauseEnd = atoi(scene->insopParam.c_str()) + _videoFrameSkip + 1;
+ uint32 pauseStart = atoi(scene->_insopParam.c_str());
+ uint32 pauseEnd = atoi(scene->_insopParam.c_str()) + _videoFrameSkip + 1;
if (_currentFrame >= pauseStart && _currentFrame < pauseEnd && !_hadPause) {
_gameTimer = 0;
- unsigned long pauseDuration = scene->dataParam1 * 0x90FF / 1000;
+ uint32 pauseDuration = scene->_dataParam1 * 0x90FF / 1000;
_pauseTime = pauseDuration;
_nextFrameTime += pauseDuration;
- _pauseTime += _GetMsTime();
+ _pauseTime += getMsTime();
_hadPause = true;
}
}
if (_pauseTime != 0) {
- if (_GetMsTime() > _pauseTime) {
+ if (getMsTime() > _pauseTime) {
_pauseTime = 0;
}
}
}
// Script functions: Scene NxtScn
-void Game::_scene_nxtscn_donothing(Scene *scene) {
+void Game::sceneNxtscnDoNothing(Scene *scene) {
// do nothing
}
-void Game::_scene_default_nxtscn(Scene *scene) {
- _cur_scene = scene->next;
+void Game::sceneDefaultNxtscn(Scene *scene) {
+ _curScene = scene->_next;
}
// Script functions: ShowMsg
-void Game::_scene_sm_donothing(Scene *scene) {
+void Game::sceneSmDonothing(Scene *scene) {
// do nothing
}
// Script functions: ScnScr
-void Game::_scene_default_score(Scene *scene) {
- if (scene->scnscrParam > 0) {
- _score += scene->scnscrParam;
+void Game::sceneDefaultScore(Scene *scene) {
+ if (scene->_scnscrParam > 0) {
+ _score += scene->_scnscrParam;
}
}
// Script functions: ScnNxtFrm
-void Game::_scene_nxtfrm(Scene *scene) {
+void Game::sceneNxtfrm(Scene *scene) {
}
// debug methods
void Game::debug_drawZoneRects() {
if (_debug_drawRects || debugChannelSet(1, Alg::kAlgDebugGraphics)) {
if (_inMenu) {
- for (uint8 i = 0; i < _submenzone->rects.size(); i++) {
- Rect rect = _submenzone->rects[i];
+ for (auto &rect : _submenzone->_rects) {
_screen->drawLine(rect.left, rect.top, rect.right, rect.top, 1);
_screen->drawLine(rect.left, rect.top, rect.left, rect.bottom, 1);
_screen->drawLine(rect.right, rect.bottom, rect.right, rect.top, 1);
_screen->drawLine(rect.right, rect.bottom, rect.left, rect.bottom, 1);
}
- } else if (_cur_scene != "") {
- Scene *targetScene = _sceneInfo->findScene(_cur_scene);
- for (uint8 i = 0; i < targetScene->zones.size(); i++) {
- Zone *zone = targetScene->zones[i];
- for (uint8 j = 0; j < zone->rects.size(); j++) {
- Rect rect = zone->rects[j];
+ } else if (_curScene != "") {
+ Scene *targetScene = _sceneInfo->findScene(_curScene);
+ for (auto &zone : targetScene->_zones) {
+ for (Rect &rect : zone->_rects) {
_screen->drawLine(rect.left, rect.top, rect.right, rect.top, 1);
_screen->drawLine(rect.left, rect.top, rect.left, rect.bottom, 1);
_screen->drawLine(rect.right, rect.bottom, rect.right, rect.top, 1);
@@ -516,11 +507,10 @@ void Game::debug_drawZoneRects() {
bool Game::debug_dumpLibFile() {
Common::DumpFile dumpFile;
- Common::HashMap<Common::String, uint32>::iterator entry;
- for (entry = _libFileEntries.begin(); entry != _libFileEntries.end(); ++entry) {
- _libFile.seek(entry->_value, SEEK_SET);
+ for (auto &entry : _libFileEntries) {
+ _libFile.seek(entry._value, SEEK_SET);
uint32 size = _libFile.readUint32LE();
- Common::Path dumpFileName(Common::String::format("libDump/%s", entry->_key.c_str()));
+ Common::Path dumpFileName(Common::String::format("libDump/%s", entry._key.c_str()));
dumpFile.open(dumpFileName, true);
assert(dumpFile.isOpen());
dumpFile.writeStream(_libFile.readStream(size));
diff --git a/engines/alg/game.h b/engines/alg/game.h
index ac2bdb11670..eb28d1ba82f 100644
--- a/engines/alg/game.h
+++ b/engines/alg/game.h
@@ -38,16 +38,15 @@ class Game {
public:
Game(AlgEngine *vm);
virtual ~Game();
+ virtual void init();
virtual Common::Error run();
+ bool debug_dumpLibFile();
+ void runCursorTimer();
bool _debug_drawRects = false;
bool _debug_godMode = false;
bool _debug_unlimitedAmmo = false;
- bool debug_dumpLibFile();
- void runCursorTimer();
protected:
- virtual void init() = 0;
-
AlgEngine *_vm;
AlgVideoDecoder *_videoDecoder;
SceneInfo *_sceneInfo;
@@ -84,68 +83,66 @@ protected:
bool _rightDown;
Common::Point _mousePos;
- const uint32 _pausdifscal[3] = {0x10000, 0x8000, 0x4000};
- const uint32 _rectdifscal[3] = {0x10000, 0x0C000, 0x8000};
+ const uint32 _pauseDiffScale[3] = {0x10000, 0x8000, 0x4000};
+ const uint32 _rectDiffScale[3] = {0x10000, 0x0C000, 0x8000};
bool pollEvents();
void loadLibArchive(const Common::Path &path);
- Audio::SeekableAudioStream *_LoadSoundFile(const Common::Path &path);
- void _PlaySound(Audio::SeekableAudioStream *stream);
+ Audio::SeekableAudioStream *loadSoundFile(const Common::Path &path);
+ void playSound(Audio::SeekableAudioStream *stream);
bool loadScene(Scene *scene);
void updateScreen();
- uint32 _GetMsTime();
- bool __Fired(Common::Point *point);
- Rect *_CheckZone(Zone *zone, Common::Point *point);
- Zone *_CheckZonesV1(Scene *scene, Rect *&hitRect, Common::Point *point);
- Zone *_CheckZonesV2(Scene *scene, Rect *&hitRect, Common::Point *point);
- uint32 _GetFrame(Scene *scene);
- void _AdjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty);
- void _RestoreCursor();
- void _SetFrame();
- int8 _SkipToNewScene(Scene *scene);
+ uint32 getMsTime();
+ bool fired(Common::Point *point);
+ Rect *checkZone(Zone *zone, Common::Point *point);
+ Zone *checkZonesV1(Scene *scene, Rect *&hitRect, Common::Point *point);
+ Zone *checkZonesV2(Scene *scene, Rect *&hitRect, Common::Point *point);
+ uint32 getFrame(Scene *scene);
+ void adjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty);
+ int8 skipToNewScene(Scene *scene);
void debug_drawZoneRects();
// Sounds
- void _DoDiffSound(uint8 difficulty);
- void _DoSaveSound();
- void _DoLoadSound();
- void _DoSkullSound();
- void _DoShot();
+ void doDiffSound(uint8 difficulty);
+ void doSaveSound();
+ void doLoadSound();
+ void doSkullSound();
+ void doShot();
// Timer
- void _SetupCursorTimer();
- void _RemoveCursorTimer();
+ void setupCursorTimer();
+ void removeCursorTimer();
// Script functions: Zone
- void _zone_globalhit(Common::Point *point);
+ void zoneGlobalHit(Common::Point *point);
// Script functions: RectHit
- void _rect_hit_donothing(Rect *rect);
- void _rect_newscene(Rect *rect);
- void _rect_exit(Rect *rect);
- void _rect_easy(Rect *rect);
- void _rect_average(Rect *rect);
- void _rect_hard(Rect *rect);
+ void rectHitDoNothing(Rect *rect);
+ void rectNewScene(Rect *rect);
+ void rectExit(Rect *rect);
+ void rectEasy(Rect *rect);
+ void rectAverage(Rect *rect);
+ void rectHard(Rect *rect);
// Script functions: Scene PreOps
- void _scene_pso_drawrct(Scene *scene);
- void _scene_pso_pause(Scene *scene);
- void _scene_pso_drawrct_fadein(Scene *scene);
- void _scene_pso_fadein(Scene *scene);
- void _scene_pso_pause_fadein(Scene *scene);
- void _scene_pso_preread(Scene *scene);
- void _scene_pso_pause_preread(Scene *scene);
+ void scenePsoDrawRct(Scene *scene);
+ void scenePsoPause(Scene *scene);
+ void scenePsoDrawRctFadeIn(Scene *scene);
+ void scenePsoFadeIn(Scene *scene);
+ void scenePsoPauseFadeIn(Scene *scene);
+ void scenePsoPreRead(Scene *scene);
+ void scenePsoPausePreRead(Scene *scene);
// Script functions: Scene Scene InsOps
- void _scene_iso_donothing(Scene *scene);
- void _scene_iso_startgame(Scene *scene);
- void _scene_iso_pause(Scene *scene);
+ void sceneIsoDoNothing(Scene *scene);
+ void sceneIsoStartGame(Scene *scene);
+ void sceneIsoPause(Scene *scene);
// Script functions: Scene Scene NxtScn
- void _scene_nxtscn_donothing(Scene *scene);
- void _scene_default_nxtscn(Scene *scene);
+ void sceneNxtscnDoNothing(Scene *scene);
+ void sceneDefaultNxtscn(Scene *scene);
// Script functions: ShowMsg
- void _scene_sm_donothing(Scene *scene);
+ void sceneSmDonothing(Scene *scene);
// Script functions: ScnScr
- void _scene_default_score(Scene *scene);
+ void sceneDefaultScore(Scene *scene);
// Script functions: ScnNxtFrm
- void _scene_nxtfrm(Scene *scene);
+ void sceneNxtfrm(Scene *scene);
bool _buttonDown = false;
uint8 _difficulty = 1;
@@ -178,11 +175,11 @@ protected:
uint16 _videoPosY;
uint8 _whichGun = 0;
- Common::String _cur_scene;
- Common::String _sub_scene;
- Common::String _ret_scene;
- Common::String _last_scene;
- Common::String _startscene;
+ Common::String _curScene;
+ Common::String _subScene;
+ Common::String _retScene;
+ Common::String _lastScene;
+ Common::String _startScene;
};
} // End of namespace Alg
diff --git a/engines/alg/game_bountyhunter.cpp b/engines/alg/game_bountyhunter.cpp
index 686000ae25c..6c765f470e8 100644
--- a/engines/alg/game_bountyhunter.cpp
+++ b/engines/alg/game_bountyhunter.cpp
@@ -25,7 +25,6 @@
#include "common/system.h"
#include "graphics/cursorman.h"
-#include "graphics/pixelformat.h"
#include "alg/game_bountyhunter.h"
#include "alg/graphics.h"
@@ -33,10 +32,10 @@
namespace Alg {
-GameBountyHunter::GameBountyHunter(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
- if (scumm_stricmp(desc->gameId, "lbhunter") == 0) {
+GameBountyHunter::GameBountyHunter(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
+ if (gd->gameType == GType_LBHUNTER_DOS) {
_libFileName = "bhds.lib";
- } else if (scumm_stricmp(desc->gameId, "lbhunterdemo") == 0) {
+ } else if (gd->gameType == GType_LBHUNTER_DEMO_DOS) {
_libFileName = "bhdemo.lib";
_isDemo = true;
}
@@ -46,25 +45,27 @@ GameBountyHunter::~GameBountyHunter() {
}
void GameBountyHunter::init() {
+ Game::init();
+
_videoPosX = 0;
_videoPosY = 0;
loadLibArchive(_libFileName);
_sceneInfo->loadScnFile("bh.scn");
- _startscene = _sceneInfo->getStartScene();
+ _startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
_menuzone = new Zone();
- _menuzone->name = "MainMenu";
- _menuzone->ptrfb = "GLOBALHIT";
+ _menuzone->_name = "MainMenu";
+ _menuzone->_ptrfb = "GLOBALHIT";
_menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
_submenzone = new Zone();
- _submenzone->name = "SubMenu";
- _submenzone->ptrfb = "GLOBALHIT";
+ _submenzone->_name = "SubMenu";
+ _submenzone->_ptrfb = "GLOBALHIT";
_submenzone->addRect(0, 0, 0x78, 0x3C, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0xC8, 0, 0x0140, 0x3C, nullptr, 0, "RECTLOAD", "0");
@@ -73,12 +74,12 @@ void GameBountyHunter::init() {
_submenzone->addRect(0, 0x78, 0x78, 0xB4, nullptr, 0, "EXITMENU", "0");
_submenzone->addRect(0xC8, 0x78, 0x0140, 0xB4, nullptr, 0, "TOGGLEPLAYERS", "0");
- _shotSound = _LoadSoundFile("blow.8b");
- _emptySound = _LoadSoundFile("empty.8b");
- _saveSound = _LoadSoundFile("saved.8b");
- _loadSound = _LoadSoundFile("loaded.8b");
- _skullSound = _LoadSoundFile("skull.8b");
- _shotgunSound = _LoadSoundFile("shotgun.8b");
+ _shotSound = loadSoundFile("blow.8b");
+ _emptySound = loadSoundFile("empty.8b");
+ _saveSound = loadSoundFile("saved.8b");
+ _loadSound = loadSoundFile("loaded.8b");
+ _skullSound = loadSoundFile("skull.8b");
+ _shotgunSound = loadSoundFile("shotgun.8b");
_gun = AlgGraphics::loadScreenCoordAniImage("bh_gun.ani", _palette);
_shotgun = AlgGraphics::loadScreenCoordAniImage("bh_buck.ani", _palette);
@@ -103,170 +104,170 @@ void GameBountyHunter::init() {
_background = AlgGraphics::loadVgaBackground("bh_menu.vga", _palette);
_screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
- _MoveMouse();
+ moveMouse();
}
void GameBountyHunter::registerScriptFunctions() {
#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new BHScriptFunctionRect(this, &GameBountyHunter::func);
- RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
- RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
- RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
- RECT_HIT_FUNCTION("STARTMENU", _rect_start);
- RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
- RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
- RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
- RECT_HIT_FUNCTION("TOGGLEPLAYERS", _rect_toggle_players);
- RECT_HIT_FUNCTION("JUG", _rect_hit_icon_jug);
- RECT_HIT_FUNCTION("LANTERN", _rect_hit_icon_lantern);
- RECT_HIT_FUNCTION("SKULL", _rect_hit_icon_skull);
- RECT_HIT_FUNCTION("WHEEL", _rect_hit_icon_wheel);
- RECT_HIT_FUNCTION("HARRY", _rect_hit_select_harry);
- RECT_HIT_FUNCTION("DAN", _rect_hit_select_dan);
- RECT_HIT_FUNCTION("LOCO", _rect_hit_select_loco);
- RECT_HIT_FUNCTION("KID", _rect_hit_select_kid);
- RECT_HIT_FUNCTION("KILLMAN", _rect_hit_kill_man);
- RECT_HIT_FUNCTION("KILLWOMAN", _rect_hit_kill_man);
- RECT_HIT_FUNCTION("KILLMAIN", _rect_hit_donothing);
- RECT_HIT_FUNCTION("WNDMAIN", _rect_hit_donothing);
- RECT_HIT_FUNCTION("SHOTGUN", _rect_hit_give_shotgun);
- RECT_HIT_FUNCTION("SHOOT3", _rect_hit_kill3);
- RECT_HIT_FUNCTION("KILL3", _rect_hit_kill3);
- RECT_HIT_FUNCTION("GOTOBAD", _rect_hit_donothing);
- RECT_HIT_FUNCTION("GOTOTGT", _rect_hit_donothing);
- RECT_HIT_FUNCTION("GOTOGUN", _rect_hit_donothing);
- RECT_HIT_FUNCTION("CHKSHOT", _rect_hit_check_shotgun);
- RECT_HIT_FUNCTION("CHEATER", _rect_hit_cheater);
+ RECT_HIT_FUNCTION("DEFAULT", rectNewScene);
+ RECT_HIT_FUNCTION("EXITMENU", rectExit);
+ RECT_HIT_FUNCTION("CONTMENU", rectContinue);
+ RECT_HIT_FUNCTION("STARTMENU", rectStart);
+ RECT_HIT_FUNCTION("SHOTMENU", rectShotMenu);
+ RECT_HIT_FUNCTION("RECTSAVE", rectSave);
+ RECT_HIT_FUNCTION("RECTLOAD", rectLoad);
+ RECT_HIT_FUNCTION("TOGGLEPLAYERS", rectTogglePlayers);
+ RECT_HIT_FUNCTION("JUG", rectHitIconJug);
+ RECT_HIT_FUNCTION("LANTERN", rectHitIconLantern);
+ RECT_HIT_FUNCTION("SKULL", rectHitIconSkull);
+ RECT_HIT_FUNCTION("WHEEL", rectHitIconWheel);
+ RECT_HIT_FUNCTION("HARRY", rectHitSelectHarry);
+ RECT_HIT_FUNCTION("DAN", rectHitSelectDan);
+ RECT_HIT_FUNCTION("LOCO", rectHitSelectLoco);
+ RECT_HIT_FUNCTION("KID", rectHitSelectKid);
+ RECT_HIT_FUNCTION("KILLMAN", rectHitKillMan);
+ RECT_HIT_FUNCTION("KILLWOMAN", rectHitKillMan);
+ RECT_HIT_FUNCTION("KILLMAIN", rectHitDoNothing);
+ RECT_HIT_FUNCTION("WNDMAIN", rectHitDoNothing);
+ RECT_HIT_FUNCTION("SHOTGUN", rectHitGiveShotgun);
+ RECT_HIT_FUNCTION("SHOOT3", rectHitKill3);
+ RECT_HIT_FUNCTION("KILL3", rectHitKill3);
+ RECT_HIT_FUNCTION("GOTOBAD", rectHitDoNothing);
+ RECT_HIT_FUNCTION("GOTOTGT", rectHitDoNothing);
+ RECT_HIT_FUNCTION("GOTOGUN", rectHitDoNothing);
+ RECT_HIT_FUNCTION("CHKSHOT", rectHitCheckShotgun);
+ RECT_HIT_FUNCTION("CHEATER", rectHitCheater);
#undef RECT_HIT_FUNCTION
#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new BHScriptFunctionScene(this, &GameBountyHunter::func);
- PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("DRAW_RECT", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
- PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
- PRE_OPS_FUNCTION("PAUSE_FADEIN", _scene_pso_pause_fadein);
- PRE_OPS_FUNCTION("DRAW_RECT_THEN_FADEIN", _scene_pso_drawrct_fadein);
- PRE_OPS_FUNCTION("SHOOTOUT", _scene_pso_shootout);
- PRE_OPS_FUNCTION("WNDMAIN", _scene_pso_wounded_main);
- PRE_OPS_FUNCTION("GUNFIGHT", _scene_pso_gunfight_setup);
- PRE_OPS_FUNCTION("REFEREED", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("LOSELIFE", _scene_pso_lose_a_life);
- PRE_OPS_FUNCTION("L1ASETUP", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("L1DSETUP", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("L2ASETUP", _scene_pso_setup_ndrandom1);
- PRE_OPS_FUNCTION("L2BSETUP", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("L4A1SETUP", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("L4A2SETUP", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("SETUPL3A", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("SET3SHOT", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("L3BSETUP", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("SETBADGUY", _scene_pso_set_current_scene);
- PRE_OPS_FUNCTION("CLRKILL3", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("DPAUSE", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("DEMO", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("DEFAULT", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("DRAW_RECT", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("FADEIN", scenePsoFadeIn);
+ PRE_OPS_FUNCTION("PAUSE", scenePsoPause);
+ PRE_OPS_FUNCTION("PAUSE_FADEIN", scenePsoPauseFadeIn);
+ PRE_OPS_FUNCTION("DRAW_RECT_THEN_FADEIN", scenePsoDrawRctFadeIn);
+ PRE_OPS_FUNCTION("SHOOTOUT", scenePsoShootout);
+ PRE_OPS_FUNCTION("WNDMAIN", scenePsoWoundedMain);
+ PRE_OPS_FUNCTION("GUNFIGHT", scenePsoGunfightSetup);
+ PRE_OPS_FUNCTION("REFEREED", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("LOSELIFE", scenePsoLoseALife);
+ PRE_OPS_FUNCTION("L1ASETUP", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("L1DSETUP", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("L2ASETUP", scenePsoSetupNdRandom1);
+ PRE_OPS_FUNCTION("L2BSETUP", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("L4A1SETUP", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("L4A2SETUP", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("SETUPL3A", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("SET3SHOT", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("L3BSETUP", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("SETBADGUY", scenePsoSetCurrentScene);
+ PRE_OPS_FUNCTION("CLRKILL3", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("DPAUSE", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("DEMO", scenePsoDrawRct);
#undef PRE_OPS_FUNCTION
#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new BHScriptFunctionScene(this, &GameBountyHunter::func);
- INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
- INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
- INS_OPS_FUNCTION("SHOOTOUT", _scene_iso_shootout);
- INS_OPS_FUNCTION("LEFTDIE", _scene_iso_donothing);
- INS_OPS_FUNCTION("SHOOTPAST", _scene_iso_donothing);
- INS_OPS_FUNCTION("GUNFIGHT", _scene_iso_shootout);
- INS_OPS_FUNCTION("REFEREED", _scene_iso_donothing);
- INS_OPS_FUNCTION("CHECK3SHOT", _scene_iso_donothing);
- INS_OPS_FUNCTION("SHOWHI", _scene_iso_donothing);
- INS_OPS_FUNCTION("STARTGAME", _scene_iso_donothing);
- INS_OPS_FUNCTION("GIVEMONEY", _scene_iso_givemoney);
- INS_OPS_FUNCTION("GETHI", _scene_iso_donothing);
- INS_OPS_FUNCTION("DPAUSE", _scene_iso_donothing);
- INS_OPS_FUNCTION("DEMO", _scene_iso_donothing);
- INS_OPS_FUNCTION("RELOAD", _scene_iso_donothing);
- INS_OPS_FUNCTION("RPAUSE", _scene_iso_donothing);
+ INS_OPS_FUNCTION("DEFAULT", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("PAUSE", sceneIsoPause);
+ INS_OPS_FUNCTION("SHOOTOUT", sceneIsoShootout);
+ INS_OPS_FUNCTION("LEFTDIE", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("SHOOTPAST", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("GUNFIGHT", sceneIsoShootout);
+ INS_OPS_FUNCTION("REFEREED", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("CHECK3SHOT", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("SHOWHI", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("STARTGAME", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("GIVEMONEY", sceneIsoGivemoney);
+ INS_OPS_FUNCTION("GETHI", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("DPAUSE", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("DEMO", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("RELOAD", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("RPAUSE", sceneIsoDoNothing);
#undef INS_OPS_FUNCTION
#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new BHScriptFunctionScene(this, &GameBountyHunter::func);
- NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
- NXT_SCN_FUNCTION("DIED", _scene_nxtscn_lose_a_life);
- NXT_SCN_FUNCTION("LOSE_A_LIFE", _scene_nxtscn_lose_a_life);
- NXT_SCN_FUNCTION("CONTINUE_GAME", _scene_nxtscn_continue_game);
- NXT_SCN_FUNCTION("DID_NOT_CONTINUE", _scene_nxtscn_did_not_continue);
- NXT_SCN_FUNCTION("KILL_INNOCENT_MAN", _scene_nxtscn_kill_innocent_man);
- NXT_SCN_FUNCTION("KILL_INNOCENT_WOMAN", _scene_nxtscn_kill_innocent_woman);
- NXT_SCN_FUNCTION("AFTER_DIE", _scene_nxtscn_after_die);
- NXT_SCN_FUNCTION("CHECKNEXT", _scene_nxtscn_goto_level_select);
- NXT_SCN_FUNCTION("CONTINUE_RANDOM", _scene_nxtscn_continue_random);
- NXT_SCN_FUNCTION("POPUP", _scene_nxtscn_continue_random);
- NXT_SCN_FUNCTION("L1ASETUP", _scene_nxtscn_init_random_harry1);
- NXT_SCN_FUNCTION("L1DSETUP", _scene_nxtscn_init_random_harry2);
- NXT_SCN_FUNCTION("L2ASETUP", _scene_nxtscn_init_random_dan1);
- NXT_SCN_FUNCTION("L2BSETUP", _scene_nxtscn_init_random_dan2);
- NXT_SCN_FUNCTION("L3ASETUP", _scene_nxtscn_init_random_loco1);
- NXT_SCN_FUNCTION("L3BSETUP", _scene_nxtscn_init_random_loco2);
- NXT_SCN_FUNCTION("L4A1SETUP", _scene_nxtscn_init_random_kid1);
- NXT_SCN_FUNCTION("L4A2SETUP", _scene_nxtscn_init_random_kid2);
- NXT_SCN_FUNCTION("NEXTSUB", _scene_nxtscn_next_sub_level);
- NXT_SCN_FUNCTION("GOTOBAD", _scene_nxtscn_goto_bad_guy);
- NXT_SCN_FUNCTION("AUTOSEL", _scene_nxtscn_auto_select_level);
- NXT_SCN_FUNCTION("SELECT_SCENARIO", _scene_nxtscn_select_scenario);
- NXT_SCN_FUNCTION("FINISH_SCENARIO", _scene_nxtscn_finish_scenario);
- NXT_SCN_FUNCTION("GAME_WON", _scene_nxtscn_game_won);
- NXT_SCN_FUNCTION("KILLMAN", _scene_nxtscn_kill_innocent_man);
- NXT_SCN_FUNCTION("KILLWOMAN", _scene_nxtscn_kill_innocent_woman);
- NXT_SCN_FUNCTION("BOTHDIE", _scene_nxtscn_lose_a_life);
- NXT_SCN_FUNCTION("RIGHTDIE", _scene_nxtscn_lose_a_life);
- NXT_SCN_FUNCTION("LEFTDIES", _scene_nxtscn_lose_a_life);
- NXT_SCN_FUNCTION("KILLMAIN", _scene_nxtscn_killed_main);
- NXT_SCN_FUNCTION("WNDMAIN", _scene_nxtscn_wounded_main);
- NXT_SCN_FUNCTION("ENDLEVEL", _scene_nxtscn_end_level);
- NXT_SCN_FUNCTION("ENDOGAME", _scene_nxtscn_end_game);
- NXT_SCN_FUNCTION("CLRHI", _scene_nxtscn_donothing);
- NXT_SCN_FUNCTION("TGTPRACT", _scene_nxtscn_donothing);
- NXT_SCN_FUNCTION("CREDITS", _scene_nxtscn_donothing);
- NXT_SCN_FUNCTION("DOMAIN", _scene_nxtscn_do_breakout_mains);
- NXT_SCN_FUNCTION("RDIED", _scene_nxtscn_died_refed);
- NXT_SCN_FUNCTION("GIVESHOT", _scene_nxtscn_give_shotgun);
- NXT_SCN_FUNCTION("CHK2P", _scene_nxtscn_check_2players);
- NXT_SCN_FUNCTION("SHOTSND", _scene_nxtscn_donothing);
- NXT_SCN_FUNCTION("XITCONT", _scene_nxtscn_donothing);
+ NXT_SCN_FUNCTION("DEFAULT", sceneDefaultNxtscn);
+ NXT_SCN_FUNCTION("DIED", sceneNxtscnLoseALife);
+ NXT_SCN_FUNCTION("LOSE_A_LIFE", sceneNxtscnLoseALife);
+ NXT_SCN_FUNCTION("CONTINUE_GAME", sceneNxtscnContinueGame);
+ NXT_SCN_FUNCTION("DID_NOT_CONTINUE", sceneNxtscnDidNotContinue);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_MAN", sceneNxtscnKillInnocentMan);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_WOMAN", sceneNxtscnKillInnocentWoman);
+ NXT_SCN_FUNCTION("AFTER_DIE", sceneNxtscnAfterDie);
+ NXT_SCN_FUNCTION("CHECKNEXT", sceneNxtscnGotoLevelSelect);
+ NXT_SCN_FUNCTION("CONTINUE_RANDOM", sceneNxtscnContinueRandom);
+ NXT_SCN_FUNCTION("POPUP", sceneNxtscnContinueRandom);
+ NXT_SCN_FUNCTION("L1ASETUP", sceneNxtscnInitRandomHarry1);
+ NXT_SCN_FUNCTION("L1DSETUP", sceneNxtscnInitRandomHarry2);
+ NXT_SCN_FUNCTION("L2ASETUP", sceneNxtscnInitRandomDan1);
+ NXT_SCN_FUNCTION("L2BSETUP", sceneNxtscnInitRandomDan2);
+ NXT_SCN_FUNCTION("L3ASETUP", sceneNxtscnInitRandomLoco1);
+ NXT_SCN_FUNCTION("L3BSETUP", sceneNxtscnInitRandomLoco2);
+ NXT_SCN_FUNCTION("L4A1SETUP", sceneNxtscnInitRandomKid1);
+ NXT_SCN_FUNCTION("L4A2SETUP", sceneNxtscnInitRandomKid2);
+ NXT_SCN_FUNCTION("NEXTSUB", sceneNxtscnNextSubLevel);
+ NXT_SCN_FUNCTION("GOTOBAD", sceneNxtscnGotoBadGuy);
+ NXT_SCN_FUNCTION("AUTOSEL", sceneNxtscnAutoSelectLevel);
+ NXT_SCN_FUNCTION("SELECT_SCENARIO", sceneNxtscnSelectScenario);
+ NXT_SCN_FUNCTION("FINISH_SCENARIO", sceneNxtscnFinishScenario);
+ NXT_SCN_FUNCTION("GAME_WON", sceneNxtscnGameWon);
+ NXT_SCN_FUNCTION("KILLMAN", sceneNxtscnKillInnocentMan);
+ NXT_SCN_FUNCTION("KILLWOMAN", sceneNxtscnKillInnocentWoman);
+ NXT_SCN_FUNCTION("BOTHDIE", sceneNxtscnLoseALife);
+ NXT_SCN_FUNCTION("RIGHTDIE", sceneNxtscnLoseALife);
+ NXT_SCN_FUNCTION("LEFTDIES", sceneNxtscnLoseALife);
+ NXT_SCN_FUNCTION("KILLMAIN", sceneNxtscnKilledMain);
+ NXT_SCN_FUNCTION("WNDMAIN", sceneNxtscnWoundedMain);
+ NXT_SCN_FUNCTION("ENDLEVEL", sceneNxtscnEndLevel);
+ NXT_SCN_FUNCTION("ENDOGAME", sceneNxtscnEndGame);
+ NXT_SCN_FUNCTION("CLRHI", sceneNxtscnDoNothing);
+ NXT_SCN_FUNCTION("TGTPRACT", sceneNxtscnDoNothing);
+ NXT_SCN_FUNCTION("CREDITS", sceneNxtscnDoNothing);
+ NXT_SCN_FUNCTION("DOMAIN", sceneNxtscnDoBreakoutMains);
+ NXT_SCN_FUNCTION("RDIED", sceneNxtscnDiedRefed);
+ NXT_SCN_FUNCTION("GIVESHOT", sceneNxtscnGiveShotgun);
+ NXT_SCN_FUNCTION("CHK2P", sceneNxtscnCheck2Players);
+ NXT_SCN_FUNCTION("SHOTSND", sceneNxtscnDoNothing);
+ NXT_SCN_FUNCTION("XITCONT", sceneNxtscnDoNothing);
#undef NXT_SCN_FUNCTION
#define WEP_DWN_FUNCTION(name, func) _sceneWepDwn[name] = new BHScriptFunctionScene(this, &GameBountyHunter::func);
- WEP_DWN_FUNCTION("DEFAULT", _scene_default_wepdwn);
- WEP_DWN_FUNCTION("GUNFIGHT", _scene_default_wepdwn);
- WEP_DWN_FUNCTION("LOADALL", _scene_default_wepdwn);
+ WEP_DWN_FUNCTION("DEFAULT", sceneDefaultWepdwn);
+ WEP_DWN_FUNCTION("GUNFIGHT", sceneDefaultWepdwn);
+ WEP_DWN_FUNCTION("LOADALL", sceneDefaultWepdwn);
#undef NXT_SCN_FUNCTION
- _sceneShowMsg["DEFAULT"] = new BHScriptFunctionScene(this, &GameBountyHunter::_scene_sm_donothing);
- _sceneScnScr["DEFAULT"] = new BHScriptFunctionScene(this, &GameBountyHunter::_scene_default_score);
- _sceneNxtFrm["DEFAULT"] = new BHScriptFunctionScene(this, &GameBountyHunter::_scene_nxtfrm);
+ _sceneShowMsg["DEFAULT"] = new BHScriptFunctionScene(this, &GameBountyHunter::sceneSmDonothing);
+ _sceneScnScr["DEFAULT"] = new BHScriptFunctionScene(this, &GameBountyHunter::sceneDefaultScore);
+ _sceneNxtFrm["DEFAULT"] = new BHScriptFunctionScene(this, &GameBountyHunter::sceneNxtfrm);
}
void GameBountyHunter::verifyScriptFunctions() {
Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
for (size_t i = 0; i < scenes->size(); i++) {
Scene *scene = (*scenes)[i];
- getScriptFunctionScene(PREOP, scene->preop);
- getScriptFunctionScene(SHOWMSG, scene->scnmsg);
- getScriptFunctionScene(INSOP, scene->insop);
- getScriptFunctionScene(WEPDWN, scene->wepdwn);
- getScriptFunctionScene(SCNSCR, scene->scnscr);
- getScriptFunctionScene(NXTFRM, scene->nxtfrm);
- getScriptFunctionScene(NXTSCN, scene->nxtscn);
- for (size_t j = 0; j < scene->zones.size(); j++) {
- Zone *zone = scene->zones[j];
- for (size_t k = 0; k < zone->rects.size(); k++) {
- getScriptFunctionRectHit(zone->rects[k].rectHit);
+ getScriptFunctionScene(PREOP, scene->_preop);
+ getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
+ getScriptFunctionScene(INSOP, scene->_insop);
+ getScriptFunctionScene(WEPDWN, scene->_wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->_scnscr);
+ getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->_nxtscn);
+ for (size_t j = 0; j < scene->_zones.size(); j++) {
+ Zone *zone = scene->_zones[j];
+ for (size_t k = 0; k < zone->_rects.size(); k++) {
+ getScriptFunctionRectHit(zone->_rects[k]._rectHit);
}
}
}
}
BHScriptFunctionRect GameBountyHunter::getScriptFunctionRectHit(Common::String name) {
- BHScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ auto it = _rectHitFuncs.find(name);
if (it != _rectHitFuncs.end()) {
return (*(*it)._value);
} else {
- error("Could not find rectHit function: %s", name.c_str());
+ error("GameBountyHunter::getScriptFunctionRectHit(): Could not find rectHit function: %s", name.c_str());
}
}
@@ -295,7 +296,7 @@ BHScriptFunctionScene GameBountyHunter::getScriptFunctionScene(SceneFuncType typ
functionMap = &_sceneNxtScn;
break;
default:
- error("Unkown scene script type: %u", type);
+ error("GameBountyHunter::getScriptFunctionScene(): Unkown scene script type: %u", type);
break;
}
BHScriptFunctionSceneMap::iterator it;
@@ -303,7 +304,7 @@ BHScriptFunctionScene GameBountyHunter::getScriptFunctionScene(SceneFuncType typ
if (it != functionMap->end()) {
return (*(*it)._value);
} else {
- error("Could not find scene type %u function: %s", type, name.c_str());
+ error("GameBountyHunter::getScriptFunctionScene(): Could not find scene type %u function: %s", type, name.c_str());
}
}
@@ -319,76 +320,75 @@ void GameBountyHunter::callScriptFunctionScene(SceneFuncType type, Common::Strin
Common::Error GameBountyHunter::run() {
init();
- _NewGame();
- _cur_scene = _startscene;
+ newGame();
+ _curScene = _startScene;
Common::String oldscene;
while (!_vm->shouldQuit()) {
- oldscene = _cur_scene;
- _SetFrame();
+ oldscene = _curScene;
_fired = false;
- Scene *scene = _sceneInfo->findScene(_cur_scene);
+ Scene *scene = _sceneInfo->findScene(_curScene);
if (!loadScene(scene)) {
- error("Cannot find scene %s in libfile", scene->name.c_str());
+ error("GameBountyHunter::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
_sceneSkipped = false;
Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
g_system->getMixer()->stopHandle(_sceneAudioHandle);
g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
- _nextFrameTime = _GetMsTime() + 100;
- callScriptFunctionScene(PREOP, scene->preop, scene);
- _currentFrame = _GetFrame(scene);
- while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
- _UpdateMouse();
- callScriptFunctionScene(SHOWMSG, scene->scnmsg, scene);
- callScriptFunctionScene(INSOP, scene->insop, scene);
- _holster = _WeaponDown();
+ _nextFrameTime = getMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->_preop, scene);
+ _currentFrame = getFrame(scene);
+ while (_currentFrame <= scene->_endFrame && _curScene == oldscene && !_vm->shouldQuit()) {
+ updateMouse();
+ callScriptFunctionScene(SHOWMSG, scene->_scnmsg, scene);
+ callScriptFunctionScene(INSOP, scene->_insop, scene);
+ _holster = weaponDown();
if (_holster) {
- callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ callScriptFunctionScene(WEPDWN, scene->_wepdwn, scene);
}
Common::Point firedCoords;
- if (__Fired(&firedCoords)) {
+ if (fired(&firedCoords)) {
if (!_holster) {
- Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ Rect *hitGlobalRect = checkZone(_menuzone, &firedCoords);
if (hitGlobalRect != nullptr) {
- callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
+ callScriptFunctionRectHit(hitGlobalRect->_rectHit, hitGlobalRect);
} else {
if (_playerShots[_player] > 0) {
if (!_debug_unlimitedAmmo) {
_playerShots[_player]--;
}
- _DisplayShotFiredImage(&firedCoords);
- _DoShot();
+ displayShotFiredImage(&firedCoords);
+ doShot();
Rect *hitRect = nullptr;
- Zone *hitSceneZone = _CheckZonesV2(scene, hitRect, &firedCoords);
+ Zone *hitSceneZone = checkZonesV2(scene, hitRect, &firedCoords);
if (hitSceneZone != nullptr) {
- callScriptFunctionRectHit(hitRect->rectHit, hitRect);
+ callScriptFunctionRectHit(hitRect->_rectHit, hitRect);
} else {
- int8 skip = _SkipToNewScene(scene);
+ int8 skip = skipToNewScene(scene);
if (skip == -1) {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
} else if (skip == 1) {
- if (scene->dataParam4 > 0) {
- uint32 framesToSkip = (scene->dataParam4 - _currentFrame) / _videoFrameSkip;
+ if (scene->_dataParam4 > 0) {
+ uint32 framesToSkip = (scene->_dataParam4 - _currentFrame) / _videoFrameSkip;
_videoDecoder->skipNumberOfFrames(framesToSkip);
} else {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
}
}
} else {
- _PlaySound(_emptySound);
+ playSound(_emptySound);
}
}
}
}
- if (_cur_scene == oldscene) {
- callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ if (_curScene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->_nxtfrm, scene);
}
- _DisplayLivesLeft(0);
- _DisplayScores(0);
- _DisplayShotsLeft(0);
- _MoveMouse();
+ displayLivesLeft(0);
+ displayScores(0);
+ displayShotsLeft(0);
+ moveMouse();
if (_pauseTime > 0) {
g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
} else {
@@ -397,13 +397,14 @@ Common::Error GameBountyHunter::run() {
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
}
- int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ updateScreen();
+ int32 remainingMillis = _nextFrameTime - getMsTime();
if (remainingMillis < 10) {
if (_videoDecoder->getCurrentFrame() > 0) {
_videoDecoder->getNextFrame();
}
- remainingMillis = _nextFrameTime - _GetMsTime();
- _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ remainingMillis = _nextFrameTime - getMsTime();
+ _nextFrameTime = getMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
}
if (remainingMillis > 0) {
if (remainingMillis > 15) {
@@ -411,23 +412,22 @@ Common::Error GameBountyHunter::run() {
}
g_system->delayMillis(remainingMillis);
}
- _currentFrame = _GetFrame(scene);
- updateScreen();
+ _currentFrame = getFrame(scene);
}
// frame limit reached or scene changed, prepare for next scene
_hadPause = false;
_pauseTime = 0;
- if (_cur_scene == oldscene) {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ if (_curScene == oldscene) {
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
- if (_cur_scene == "") {
+ if (_curScene == "") {
_vm->quitGame();
}
}
return Common::kNoError;
}
-void GameBountyHunter::_NewGame() {
+void GameBountyHunter::newGame() {
_playerLives[0] = _playerLives[1] = 3;
_playerShots[0] = _playerShots[1] = 6;
_playerGun[0] = _playerGun[1] = 1;
@@ -436,43 +436,40 @@ void GameBountyHunter::_NewGame() {
_holster = false;
}
-void GameBountyHunter::_DoMenu() {
- uint32 startTime = _GetMsTime();
- _RestoreCursor();
- _DoCursor();
+void GameBountyHunter::doMenu() {
+ uint32 startTime = getMsTime();
+ updateCursor();
_inMenu = true;
- _MoveMouse();
+ moveMouse();
g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
while (_inMenu && !_vm->shouldQuit()) {
Common::Point firedCoords;
- if (__Fired(&firedCoords)) {
- Rect *hitMenuRect = _CheckZone(_submenzone, &firedCoords);
+ if (fired(&firedCoords)) {
+ Rect *hitMenuRect = checkZone(_submenzone, &firedCoords);
if (hitMenuRect != nullptr) {
- callScriptFunctionRectHit(hitMenuRect->rectHit, hitMenuRect);
+ callScriptFunctionRectHit(hitMenuRect->_rectHit, hitMenuRect);
}
}
- g_system->delayMillis(15);
updateScreen();
+ g_system->delayMillis(15);
}
- _RestoreCursor();
- _DoCursor();
+ updateCursor();
g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
if (_hadPause) {
- unsigned long endTime = _GetMsTime();
- unsigned long timeDiff = endTime - startTime;
+ uint32 endTime = getMsTime();
+ uint32 timeDiff = endTime - startTime;
_pauseTime += timeDiff;
_nextFrameTime += timeDiff;
}
}
-void GameBountyHunter::_DoCursor() {
- _UpdateMouse();
+void GameBountyHunter::updateCursor() {
+ updateMouse();
}
-void GameBountyHunter::_UpdateMouse() {
+void GameBountyHunter::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::PixelFormat pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
Graphics::Surface *cursor = &(*_gun)[_whichGun];
if (_playerGun[0] == 2 && _whichGun < 2) {
cursor = &(*_shotgun)[_whichGun];
@@ -484,13 +481,13 @@ void GameBountyHunter::_UpdateMouse() {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0, false, &pixelFormat);
+ CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
}
-void GameBountyHunter::_MoveMouse() {
+void GameBountyHunter::moveMouse() {
if (_inMenu) {
_whichGun = 3; // in menu cursor
} else {
@@ -516,27 +513,27 @@ void GameBountyHunter::_MoveMouse() {
_whichGun = 0; // regular gun
}
}
- _UpdateMouse();
+ updateMouse();
}
-void GameBountyHunter::_DisplayLivesLeft(uint8 player) {
+void GameBountyHunter::displayLivesLeft(uint8 player) {
if (_lives == _oldLives) {
return;
}
int posY = 0x67;
- for (uint8 i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
AlgGraphics::drawImage(_screen, &_deadIcon, 0x12F, posY);
posY += 0xE;
}
posY = 0x67;
- for (uint8 i = 0; i < _lives; i++) {
+ for (int i = 0; i < _lives; i++) {
AlgGraphics::drawImage(_screen, &_liveIcon, 0x12F, posY);
posY += 0xE;
}
_oldLives = _lives;
}
-void GameBountyHunter::_DisplayScores(uint8 player) {
+void GameBountyHunter::displayScores(uint8 player) {
if (_score == _oldScore) {
return;
}
@@ -550,45 +547,45 @@ void GameBountyHunter::_DisplayScores(uint8 player) {
_oldScore = _score;
}
-void GameBountyHunter::_DisplayShotsLeft(uint8 player) {
+void GameBountyHunter::displayShotsLeft(uint8 player) {
if (_shots == _oldShots) {
return;
}
uint16 posX = 0xEE;
- for (uint8 i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBE);
posX += 5;
}
posX = 0xEE;
- for (uint8 i = 0; i < _shots; i++) {
+ for (int i = 0; i < _shots; i++) {
AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBE);
posX += 5;
}
_oldShots = _shots;
}
-bool GameBountyHunter::_WeaponDown() {
+bool GameBountyHunter::weaponDown() {
if (_rightDown && _mousePos.y >= 0xAA && _mousePos.x >= 0x113) {
return true;
}
return false;
}
-bool GameBountyHunter::_SaveState() {
+bool GameBountyHunter::saveState() {
Common::OutSaveFile *outSaveFile;
Common::String saveFileName = _vm->getSaveStateName(0);
if (!(outSaveFile = g_system->getSavefileManager()->openForSaving(saveFileName))) {
- warning("Can't create file '%s', game not saved", saveFileName.c_str());
+ warning("GameBountyHunter::saveState(): Can't create file '%s', game not saved", saveFileName.c_str());
return false;
}
- uint16 currentSceneNum = atoi(_cur_scene.c_str());
+ uint16 currentSceneNum = atoi(_curScene.c_str());
outSaveFile->writeUint32BE(MKTAG('A', 'L', 'G', 'S')); // header
outSaveFile->writeByte(0); // version, unused for now
outSaveFile->writeByte(_currentLevel);
outSaveFile->writeUint16LE(_currentSubLevelSceneId);
outSaveFile->writeByte(_continuesUsed);
outSaveFile->writeUint16LE(currentSceneNum);
- for (uint8 i = 0; i < 2; i++) {
+ for (int i = 0; i < 2; i++) {
outSaveFile->writeByte(_playerLives[i]);
outSaveFile->writeByte(_playerShots[i]);
outSaveFile->writeUint32LE(_playerScore[i]);
@@ -600,16 +597,16 @@ bool GameBountyHunter::_SaveState() {
return true;
}
-bool GameBountyHunter::_LoadState() {
+bool GameBountyHunter::loadState() {
Common::InSaveFile *inSaveFile;
Common::String saveFileName = _vm->getSaveStateName(0);
if (!(inSaveFile = g_system->getSavefileManager()->openForLoading(saveFileName))) {
- debug("Can't load file '%s', game not loaded", saveFileName.c_str());
+ debug("GameBountyHunter::loadState(): Can't load file '%s', game not loaded", saveFileName.c_str());
return false;
}
uint32 header = inSaveFile->readUint32BE();
if (header != MKTAG('A', 'L', 'G', 'S')) {
- warning("Unkown save file, header: %d", header);
+ warning("GameBountyHunter::loadState(): Unkown save file, header: %s", tag2str(header));
return false;
}
inSaveFile->skip(1); // version, unused for now
@@ -617,7 +614,7 @@ bool GameBountyHunter::_LoadState() {
_currentSubLevelSceneId = inSaveFile->readUint16LE();
_continuesUsed = inSaveFile->readByte();
_restartScene = inSaveFile->readUint16LE();
- for (uint8 i = 0; i < 2; i++) {
+ for (int i = 0; i < 2; i++) {
_playerLives[i] = inSaveFile->readByte();
_playerShots[i] = inSaveFile->readByte();
_playerScore[i] = inSaveFile->readUint32LE();
@@ -630,11 +627,11 @@ bool GameBountyHunter::_LoadState() {
}
// misc game functions
-void GameBountyHunter::_SetNextScene(uint16 sceneId) {
- _cur_scene = Common::String::format("%d", sceneId);
+void GameBountyHunter::setNextScene(uint16 sceneId) {
+ _curScene = Common::String::format("%d", sceneId);
}
-void GameBountyHunter::_DisplayShotFiredImage(Common::Point *point) {
+void GameBountyHunter::displayShotFiredImage(Common::Point *point) {
if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
@@ -642,19 +639,19 @@ void GameBountyHunter::_DisplayShotFiredImage(Common::Point *point) {
}
}
-void GameBountyHunter::_EnableVideoFadeIn() {
+void GameBountyHunter::enableVideoFadeIn() {
// TODO implement
}
-void GameBountyHunter::_IconShotgun() {
+void GameBountyHunter::iconShotgun() {
// TODO implement
}
-void GameBountyHunter::_IconReset() {
+void GameBountyHunter::iconReset() {
// TODO implement
}
-uint16 GameBountyHunter::_BeginLevel(uint8 levelNumber) {
+uint16 GameBountyHunter::beginLevel(uint8 levelNumber) {
_currentLevel = levelNumber;
_numSubLevelsDone = 0;
int index = (levelNumber * 24) + (_numLevelsDone * 6) + _numSubLevelsDone;
@@ -665,7 +662,7 @@ uint16 GameBountyHunter::_BeginLevel(uint8 levelNumber) {
return sceneNum;
}
-uint16 GameBountyHunter::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
+uint16 GameBountyHunter::randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
if (max == 1) {
return 0;
}
@@ -674,100 +671,100 @@ uint16 GameBountyHunter::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclud
if (*mask == fullMask) {
*mask = 0;
}
- uint16 random = 0;
+ uint16 randomNum = 0;
// find an unused random number
while (1) {
- random = _rnd->getRandomNumber(max - 1);
+ randomNum = _rnd->getRandomNumber(max - 1);
// check if bit is already used
- unsigned int bit = 1 << random;
- if (!((*mask & bit) || random == exclude)) {
+ uint16 bit = 1 << randomNum;
+ if (!((*mask & bit) || randomNum == exclude)) {
// set the bit in mask
*mask |= bit;
break;
}
}
- return random;
+ return randomNum;
}
-uint16 GameBountyHunter::_PickRandomScene(const uint16 *sceneList, uint8 max) {
+uint16 GameBountyHunter::pickRandomScene(uint16 *sceneList, uint8 max) {
if (max == 0) {
return 0;
}
- _random_scene_list = const_cast<uint16 *>(sceneList);
- _random_max = max;
- _random_mask = 0;
- _random_picked = -1;
- _random_scene_count = 0;
- while (_random_scene_list[_random_scene_count] != 0) {
- _random_scene_count++;
+ _randomSceneList = sceneList;
+ _randomMax = max;
+ _randomMask = 0;
+ _randomPicked = -1;
+ _randomSceneCount = 0;
+ while (_randomSceneList[_randomSceneCount] != 0) {
+ _randomSceneCount++;
}
- unsigned short count = _random_max--;
+ uint16 count = _randomMax--;
if (count > 0) {
- _random_picked = _RandomUnusedInt(_random_scene_count, &_random_mask, _random_picked);
- return _random_scene_list[_random_picked];
+ _randomPicked = randomUnusedInt(_randomSceneCount, &_randomMask, _randomPicked);
+ return _randomSceneList[_randomPicked];
}
return 0;
}
-uint16 GameBountyHunter::_PickGunfightScene() {
- if (!_gunfight_initialized) {
- _gunfight_initialized = true;
- _gunfight_mask = 0;
- _gunfight_picked = -1;
- _gunfight_scene_count = 0;
- while (_gunfightScenarios[_gunfight_scene_count] != 0) {
- _gunfight_scene_count++;
+uint16 GameBountyHunter::pickGunfightScene() {
+ if (!_gunfightInitialized) {
+ _gunfightInitialized = true;
+ _gunfightMask = 0;
+ _gunfightPicked = -1;
+ _gunfightSceneCount = 0;
+ while (_gunfightScenarios[_gunfightSceneCount] != 0) {
+ _gunfightSceneCount++;
}
}
- _random_picked = _RandomUnusedInt(_gunfight_scene_count, &_gunfight_mask, _random_picked);
- return _gunfightScenarios[_random_picked];
+ _randomPicked = randomUnusedInt(_gunfightSceneCount, &_gunfightMask, _randomPicked);
+ return _gunfightScenarios[_randomPicked];
}
-uint16 GameBountyHunter::_PickInnocentScene() {
- if (!_innocent_initialized) {
- _innocent_initialized = true;
- _innocent_mask = 0;
- _innocent_picked = -1;
- _innocent_scene_count = 0;
- while (_innocentScenarios[_innocent_scene_count] != 0) {
- _innocent_scene_count++;
+uint16 GameBountyHunter::pickInnocentScene() {
+ if (!_innocentInitialized) {
+ _innocentInitialized = true;
+ _innocentMask = 0;
+ _innocentPicked = -1;
+ _innocentSceneCount = 0;
+ while (_innocentScenarios[_innocentSceneCount] != 0) {
+ _innocentSceneCount++;
}
}
- _innocent_picked = _RandomUnusedInt(_innocent_scene_count, &_innocent_mask, _innocent_picked);
- return _innocentScenarios[_innocent_picked];
+ _innocentPicked = randomUnusedInt(_innocentSceneCount, &_innocentMask, _innocentPicked);
+ return _innocentScenarios[_innocentPicked];
}
-uint16 GameBountyHunter::_PickDeathScene() {
- if (!_death_initialized) {
- _death_initialized = true;
- _death_mask = 0;
- _death_picked = -1;
- _death_scene_count = 0;
- while (_deathScenarios[_death_scene_count] != 0) {
- _death_scene_count++;
+uint16 GameBountyHunter::pickDeathScene() {
+ if (!_deathInitialized) {
+ _deathInitialized = true;
+ _deathMask = 0;
+ _deathPicked = -1;
+ _deathSceneCount = 0;
+ while (_deathScenarios[_deathSceneCount] != 0) {
+ _deathSceneCount++;
}
}
- _death_picked = _RandomUnusedInt(_death_scene_count, &_death_mask, _death_picked);
- return _deathScenarios[_death_picked];
+ _deathPicked = randomUnusedInt(_deathSceneCount, &_deathMask, _deathPicked);
+ return _deathScenarios[_deathPicked];
}
-uint16 GameBountyHunter::_TimeForGunfight() {
+uint16 GameBountyHunter::timeForGunfight() {
uint16 picked = 0;
if (--_gunfightCount <= 0) {
int index = (_unk_2ADA6 * 5) + (_numLevelsDone);
_gunfightCount = _gunfightCountDown[index];
- picked = _PickGunfightScene();
+ picked = pickGunfightScene();
}
return picked;
}
-void GameBountyHunter::_WaitingForShootout(uint32 drawFrame) {
+void GameBountyHunter::waitingForShootout(uint32 drawFrame) {
if (drawFrame != 0) {
- for (uint8 i = 0; i < _numPlayers; i++) {
+ for (int i = 0; i < _numPlayers; i++) {
_firstDrawFrame = drawFrame;
_playerShots[i] = 0;
_playerGun[i] = 0;
- _DisplayShotsLeft(i);
+ displayShotsLeft(i);
}
}
// TODO investigate & fix
@@ -783,30 +780,30 @@ void GameBountyHunter::_WaitingForShootout(uint32 drawFrame) {
*/
}
-void GameBountyHunter::_DoShotgunSound() {
- _PlaySound(_shotgunSound);
+void GameBountyHunter::doShotgunSound() {
+ playSound(_shotgunSound);
}
// Script functions: RectHit
-void GameBountyHunter::_rect_shotmenu(Rect *rect) {
- _DoMenu();
+void GameBountyHunter::rectShotMenu(Rect *rect) {
+ doMenu();
}
-void GameBountyHunter::_rect_save(Rect *rect) {
- if (_SaveState()) {
- _DoSaveSound();
+void GameBountyHunter::rectSave(Rect *rect) {
+ if (saveState()) {
+ doSaveSound();
}
}
-void GameBountyHunter::_rect_load(Rect *rect) {
- if (_LoadState()) {
- _DoLoadSound();
+void GameBountyHunter::rectLoad(Rect *rect) {
+ if (loadState()) {
+ doLoadSound();
}
- _SetNextScene(_restartScene);
+ setNextScene(_restartScene);
_restartScene = 0;
}
-void GameBountyHunter::_rect_continue(Rect *rect) {
+void GameBountyHunter::rectContinue(Rect *rect) {
_inMenu = false;
_fired = false;
if (_gameInProgress) {
@@ -818,33 +815,33 @@ void GameBountyHunter::_rect_continue(Rect *rect) {
_playerLives[playerIndex] = 3;
_playerScore[playerIndex] *= 0.75;
} else {
- _scene_nxtscn_did_not_continue(nullptr);
+ sceneNxtscnDidNotContinue(nullptr);
}
}
}
}
-void GameBountyHunter::_rect_start(Rect *rect) {
+void GameBountyHunter::rectStart(Rect *rect) {
_inMenu = false;
_fired = false;
_gameInProgress = true;
_restartScene = 0;
if (_isDemo) {
- _SetNextScene(0x45); // TODO fix
+ setNextScene(0x45); // TODO fix
} else {
- _SetNextScene(0x45);
+ setNextScene(0x45);
}
- _NewGame();
+ newGame();
}
-void GameBountyHunter::_rect_toggle_players(Rect *rect) {
+void GameBountyHunter::rectTogglePlayers(Rect *rect) {
if (_numPlayers == 1) {
_numPlayers = 2;
AlgGraphics::drawImage(_screen, &_playersIcon2, 0xCE, 0x95);
AlgGraphics::drawImage(_screen, &_textBlackBarIcon, 0x78, 0xBF);
AlgGraphics::drawImage(_screen, &_textBlackBarIcon, 0x0C, 0xBF);
- _DisplayShotsLeft(1);
- _DisplayLivesLeft(1);
+ displayShotsLeft(1);
+ displayLivesLeft(1);
} else {
_numPlayers = 1;
AlgGraphics::drawImage(_screen, &_playersIcon1, 0xCE, 0x95);
@@ -852,118 +849,118 @@ void GameBountyHunter::_rect_toggle_players(Rect *rect) {
AlgGraphics::drawImage(_screen, &_textMenuIcon, 0x0C, 0xBF);
AlgGraphics::drawImage(_screen, &_textBlackBarIcon, 0x50, 0xBE);
}
- _DoSkullSound();
+ doSkullSound();
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
}
-void GameBountyHunter::_rect_hit_icon_jug(Rect *rect) {
+void GameBountyHunter::rectHitIconJug(Rect *rect) {
// TODO fix
// Icon.funcs[1](param);
// PlaySound(4);
// Icon.hitCount++;
}
-void GameBountyHunter::_rect_hit_icon_lantern(Rect *rect) {
+void GameBountyHunter::rectHitIconLantern(Rect *rect) {
// TODO fix
// Icon.funcs[3](param);
// PlaySound(4);
// Icon.hitCount++;
}
-void GameBountyHunter::_rect_hit_icon_skull(Rect *rect) {
+void GameBountyHunter::rectHitIconSkull(Rect *rect) {
// TODO fix
// Icon.funcs[0](param);
// PlaySound(4);
// Icon.hitCount++;
}
-void GameBountyHunter::_rect_hit_icon_wheel(Rect *rect) {
+void GameBountyHunter::rectHitIconWheel(Rect *rect) {
// TODO fix
// Icon.funcs[2](param);
// PlaySound(4);
// Icon.hitCount++;
}
-void GameBountyHunter::_rect_hit_select_harry(Rect *rect) {
+void GameBountyHunter::rectHitSelectHarry(Rect *rect) {
if (!(_levelDoneMask & 2)) {
- uint16 picked = _BeginLevel(0);
- _SetNextScene(picked);
+ uint16 picked = beginLevel(0);
+ setNextScene(picked);
}
}
-void GameBountyHunter::_rect_hit_select_dan(Rect *rect) {
+void GameBountyHunter::rectHitSelectDan(Rect *rect) {
if (!(_levelDoneMask & 4)) {
- uint16 picked = _BeginLevel(1);
- _SetNextScene(picked);
+ uint16 picked = beginLevel(1);
+ setNextScene(picked);
}
}
-void GameBountyHunter::_rect_hit_select_loco(Rect *rect) {
+void GameBountyHunter::rectHitSelectLoco(Rect *rect) {
if (!(_levelDoneMask & 8)) {
- uint16 picked = _BeginLevel(2);
- _SetNextScene(picked);
+ uint16 picked = beginLevel(2);
+ setNextScene(picked);
}
}
-void GameBountyHunter::_rect_hit_select_kid(Rect *rect) {
+void GameBountyHunter::rectHitSelectKid(Rect *rect) {
if (!(_levelDoneMask & 0x10)) {
- uint16 picked = _BeginLevel(3);
- _SetNextScene(picked);
+ uint16 picked = beginLevel(3);
+ setNextScene(picked);
}
}
-void GameBountyHunter::_rect_hit_kill_man(Rect *rect) {
+void GameBountyHunter::rectHitKillMan(Rect *rect) {
// do nothing
}
-void GameBountyHunter::_rect_hit_give_shotgun(Rect *rect) {
- _IconShotgun();
+void GameBountyHunter::rectHitGiveShotgun(Rect *rect) {
+ iconShotgun();
}
-void GameBountyHunter::_rect_hit_kill3(Rect *rect) {
+void GameBountyHunter::rectHitKill3(Rect *rect) {
_count++;
if (_count == 3) {
_count = 0;
- _rect_newscene(rect);
+ rectNewScene(rect);
// TODO verify
// _RHONewScene(param1, param2);
}
}
-void GameBountyHunter::_rect_hit_check_shotgun(Rect *rect) {
+void GameBountyHunter::rectHitCheckShotgun(Rect *rect) {
if (_playerGun[_player] == 2) {
- _rect_newscene(rect);
+ rectNewScene(rect);
}
}
-void GameBountyHunter::_rect_hit_cheater(Rect *rect) {
- _SetNextScene(0x011A);
+void GameBountyHunter::rectHitCheater(Rect *rect) {
+ setNextScene(0x011A);
}
// Script functions: Scene PreOps
-void GameBountyHunter::_scene_pso_shootout(Scene *scene) {
- _WaitingForShootout(atoi(scene->preopParam.c_str()));
+void GameBountyHunter::scenePsoShootout(Scene *scene) {
+ waitingForShootout(atoi(scene->_preopParam.c_str()));
}
-void GameBountyHunter::_scene_pso_wounded_main(Scene *scene) {
+void GameBountyHunter::scenePsoWoundedMain(Scene *scene) {
_wounded = true;
_currentSubLevelSceneId = _moneyScenes[_currentLevel];
}
-void GameBountyHunter::_scene_pso_gunfight_setup(Scene *scene) {
- _WaitingForShootout(atoi(scene->preopParam.c_str()));
+void GameBountyHunter::scenePsoGunfightSetup(Scene *scene) {
+ waitingForShootout(atoi(scene->_preopParam.c_str()));
}
-void GameBountyHunter::_scene_pso_lose_a_life(Scene *scene) {
- _scene_nxtscn_lose_a_life(scene);
+void GameBountyHunter::scenePsoLoseALife(Scene *scene) {
+ sceneNxtscnLoseALife(scene);
}
-void GameBountyHunter::_scene_pso_setup_ndrandom1(Scene *scene) {
+void GameBountyHunter::scenePsoSetupNdRandom1(Scene *scene) {
_numSubLevelsDone++;
}
-void GameBountyHunter::_scene_pso_set_current_scene(Scene *scene) {
- int sceneId = atoi(scene->preopParam.c_str());
+void GameBountyHunter::scenePsoSetCurrentScene(Scene *scene) {
+ int sceneId = atoi(scene->_preopParam.c_str());
_currentSubLevelSceneId = sceneId;
if (sceneId == 0) {
uint8 index = (_currentLevel * 24) + (_numLevelsDone * 6) + _numSubLevelsDone;
@@ -974,16 +971,16 @@ void GameBountyHunter::_scene_pso_set_current_scene(Scene *scene) {
}
// Script functions: Scene InsOps
-void GameBountyHunter::_scene_iso_shootout(Scene *scene) {
- _WaitingForShootout(0);
+void GameBountyHunter::sceneIsoShootout(Scene *scene) {
+ waitingForShootout(0);
}
-void GameBountyHunter::_scene_iso_givemoney(Scene *scene) {
+void GameBountyHunter::sceneIsoGivemoney(Scene *scene) {
const int moneyFrames[] = {0x1E8F, 0x3BB4, 0x7814, 0xA287};
const int woundBits[] = {2, 4, 8, 0x10};
- for (uint8 i = 0; i < _numPlayers; i++) {
+ for (int i = 0; i < _numPlayers; i++) {
if (_currentLevel <= 3) {
- unsigned long moneyFrame = moneyFrames[_currentLevel];
+ uint32 moneyFrame = moneyFrames[_currentLevel];
// TODO investigate
if (moneyFrame == _currentFrame && !_given) {
if (_wounded) {
@@ -1000,17 +997,17 @@ void GameBountyHunter::_scene_iso_givemoney(Scene *scene) {
_given = 0;
}
}
- _DisplayScores(i);
+ displayScores(i);
}
}
// Script functions: Scene NxtScn
-void GameBountyHunter::_scene_nxtscn_lose_a_life(Scene *scene) {
+void GameBountyHunter::sceneNxtscnLoseALife(Scene *scene) {
uint16 picked = 0;
int deadPlayerCount = 0;
for (int i = 0; i < _numPlayers; i++) {
_playerLives[i]--;
- _DisplayLivesLeft(i);
+ displayLivesLeft(i);
if (_playerLives[i] <= 0) {
_playerScore[i] = (_playerScore[i] * 6) / 10;
deadPlayerCount++;
@@ -1021,29 +1018,29 @@ void GameBountyHunter::_scene_nxtscn_lose_a_life(Scene *scene) {
} else if (deadPlayerCount > 0) {
picked = _allPlayersDead;
} else {
- picked = _PickDeathScene();
+ picked = pickDeathScene();
}
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_continue_game(Scene *scene) {
+void GameBountyHunter::sceneNxtscnContinueGame(Scene *scene) {
if (_continuesUsed < 2) {
- _SetNextScene(0x01B6);
+ setNextScene(0x01B6);
} else {
- _scene_nxtscn_did_not_continue(scene);
+ sceneNxtscnDidNotContinue(scene);
}
}
-void GameBountyHunter::_scene_nxtscn_did_not_continue(Scene *scene) {
+void GameBountyHunter::sceneNxtscnDidNotContinue(Scene *scene) {
_gameInProgress = false;
- _cur_scene = _startscene;
+ _curScene = _startScene;
}
-void GameBountyHunter::_scene_nxtscn_kill_innocent_man(Scene *scene) {
+void GameBountyHunter::sceneNxtscnKillInnocentMan(Scene *scene) {
uint16 picked = 0;
_playerLives[_player]--;
if (_playerLives[_player]) {
- picked = _PickInnocentScene();
+ picked = pickInnocentScene();
} else {
if (_numPlayers == 2) {
picked = _onePlayerOfTwoDead[_numSubLevelsDone & 1];
@@ -1051,25 +1048,25 @@ void GameBountyHunter::_scene_nxtscn_kill_innocent_man(Scene *scene) {
picked = _allPlayersDead;
}
}
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_kill_innocent_woman(Scene *scene) {
- _scene_nxtscn_kill_innocent_man(scene);
+void GameBountyHunter::sceneNxtscnKillInnocentWoman(Scene *scene) {
+ sceneNxtscnKillInnocentMan(scene);
}
-void GameBountyHunter::_scene_nxtscn_after_die(Scene *scene) {
- for (uint8 i = 0; i < _numPlayers; i++) {
+void GameBountyHunter::sceneNxtscnAfterDie(Scene *scene) {
+ for (int i = 0; i < _numPlayers; i++) {
if (_playerLives[i] <= 0) {
_playerLives[i] = 3;
- _DisplayLivesLeft(i);
+ displayLivesLeft(i);
}
}
- _SetNextScene(_currentSubLevelSceneId);
+ setNextScene(_currentSubLevelSceneId);
}
-void GameBountyHunter::_scene_nxtscn_goto_level_select(Scene *scene) {
- _IconReset();
+void GameBountyHunter::sceneNxtscnGotoLevelSelect(Scene *scene) {
+ iconReset();
uint16 picked = 0;
if ((_levelDoneMask & 0x1E) != 0x1E) {
picked = 0x17B;
@@ -1078,12 +1075,12 @@ void GameBountyHunter::_scene_nxtscn_goto_level_select(Scene *scene) {
} else {
picked = 0x61;
}
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_continue_random(Scene *scene) {
+void GameBountyHunter::sceneNxtscnContinueRandom(Scene *scene) {
// TODO verify
- _scene_nxtscn_next_sub_level(scene);
+ sceneNxtscnNextSubLevel(scene);
/*
uint16 picked = _PickRandomScene(0, 0);
if (picked == 0) {
@@ -1094,122 +1091,122 @@ void GameBountyHunter::_scene_nxtscn_continue_random(Scene *scene) {
*/
}
-void GameBountyHunter::_scene_nxtscn_init_random_harry1(Scene *scene) {
- uint16 picked = _PickRandomScene(_randomScenes[0], _randomScenesPicks[0]);
+void GameBountyHunter::sceneNxtscnInitRandomHarry1(Scene *scene) {
+ uint16 picked = pickRandomScene(_randomScenes[0], _randomScenesPicks[0]);
_currentSubLevelSceneId = picked;
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_init_random_harry2(Scene *scene) {
- uint16 picked = _PickRandomScene(_randomScenes[1], _randomScenesPicks[1]);
- _SetNextScene(picked);
+void GameBountyHunter::sceneNxtscnInitRandomHarry2(Scene *scene) {
+ uint16 picked = pickRandomScene(_randomScenes[1], _randomScenesPicks[1]);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_init_random_dan1(Scene *scene) {
+void GameBountyHunter::sceneNxtscnInitRandomDan1(Scene *scene) {
uint16 picked = 0;
uint8 picks = _randomScenesPicks[2] + _numPlayers;
if (_numPlayers == 2) {
- picked = _PickRandomScene(_randomDan1TwoPlayer, picks);
+ picked = pickRandomScene(_randomDan1TwoPlayer, picks);
} else {
- picked = _PickRandomScene(_randomScenes[2], picks);
+ picked = pickRandomScene(_randomScenes[2], picks);
}
_currentSubLevelSceneId = 0x0174;
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_init_random_dan2(Scene *scene) {
- uint16 picked = _PickRandomScene(_randomScenes[3], _randomScenesPicks[3]);
+void GameBountyHunter::sceneNxtscnInitRandomDan2(Scene *scene) {
+ uint16 picked = pickRandomScene(_randomScenes[3], _randomScenesPicks[3]);
_currentSubLevelSceneId = picked;
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_init_random_loco1(Scene *scene) {
- uint16 picked = _PickRandomScene(_randomScenes[4], _randomScenesPicks[4]);
- _SetNextScene(picked);
+void GameBountyHunter::sceneNxtscnInitRandomLoco1(Scene *scene) {
+ uint16 picked = pickRandomScene(_randomScenes[4], _randomScenesPicks[4]);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_init_random_loco2(Scene *scene) {
- uint16 picked = _PickRandomScene(_randomScenes[5], _randomScenesPicks[5]);
- _SetNextScene(picked);
+void GameBountyHunter::sceneNxtscnInitRandomLoco2(Scene *scene) {
+ uint16 picked = pickRandomScene(_randomScenes[5], _randomScenesPicks[5]);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_init_random_kid1(Scene *scene) {
- uint16 picked = _PickRandomScene(_randomScenes[6], _randomScenesPicks[6]);
- _SetNextScene(picked);
+void GameBountyHunter::sceneNxtscnInitRandomKid1(Scene *scene) {
+ uint16 picked = pickRandomScene(_randomScenes[6], _randomScenesPicks[6]);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_init_random_kid2(Scene *scene) {
- uint16 picked = _PickRandomScene(_randomScenes[7], _randomScenesPicks[7]);
- _SetNextScene(picked);
+void GameBountyHunter::sceneNxtscnInitRandomKid2(Scene *scene) {
+ uint16 picked = pickRandomScene(_randomScenes[7], _randomScenesPicks[7]);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_next_sub_level(Scene *scene) {
- _IconReset();
+void GameBountyHunter::sceneNxtscnNextSubLevel(Scene *scene) {
+ iconReset();
_numSubLevelsDone++;
int index = (_currentLevel * 24) + (_numLevelsDone * 6) + _numSubLevelsDone;
uint8 subLevel = _subLevelOrder[index];
uint16 sceneIndex = (_currentLevel * 5) + subLevel;
uint16 picked = _subLevelSceneIds[sceneIndex];
_currentSubLevelSceneId = picked;
- uint16 gunfightScene = _TimeForGunfight();
+ uint16 gunfightScene = timeForGunfight();
if (gunfightScene != 0) {
- _SetNextScene(gunfightScene);
+ setNextScene(gunfightScene);
}
if (subLevel == 2) {
if (_currentLevel == 0) {
- _SetNextScene(picked);
+ setNextScene(picked);
return;
}
picked = _clueLevels[_currentLevel];
}
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_goto_bad_guy(Scene *scene) {
- _IconReset();
+void GameBountyHunter::sceneNxtscnGotoBadGuy(Scene *scene) {
+ iconReset();
uint8 index = (_currentLevel * 24) + (_numLevelsDone * 6) + _numSubLevelsDone;
uint8 subLevel = _subLevelOrder[index];
uint16 sceneIndex = (_currentLevel * 5) + subLevel;
uint16 picked = _subLevelSceneIds[sceneIndex];
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_auto_select_level(Scene *scene) {
- _IconReset();
+void GameBountyHunter::sceneNxtscnAutoSelectLevel(Scene *scene) {
+ iconReset();
uint8 i;
for (i = 0; i < 4; i++) {
if (!(_levelDoneMask & _mainLevelMasks[i])) {
break;
}
}
- uint16 picked = _BeginLevel(i);
- _SetNextScene(picked);
+ uint16 picked = beginLevel(i);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_select_scenario(Scene *scene) {
- _SetNextScene(_currentLevel);
+void GameBountyHunter::sceneNxtscnSelectScenario(Scene *scene) {
+ setNextScene(_currentLevel);
}
-void GameBountyHunter::_scene_nxtscn_finish_scenario(Scene *scene) {
+void GameBountyHunter::sceneNxtscnFinishScenario(Scene *scene) {
// do nothing
}
-void GameBountyHunter::_scene_nxtscn_game_won(Scene *scene) {
+void GameBountyHunter::sceneNxtscnGameWon(Scene *scene) {
_gameInProgress = false;
- _cur_scene = _startscene;
+ _curScene = _startScene;
}
-void GameBountyHunter::_scene_nxtscn_killed_main(Scene *scene) {
+void GameBountyHunter::sceneNxtscnKilledMain(Scene *scene) {
_wounded = false;
- _sub_scene = "scene379";
+ _subScene = "scene379";
}
-void GameBountyHunter::_scene_nxtscn_wounded_main(Scene *scene) {
+void GameBountyHunter::sceneNxtscnWoundedMain(Scene *scene) {
_wounded = true;
- _sub_scene = "scene379";
+ _subScene = "scene379";
}
-void GameBountyHunter::_scene_nxtscn_end_level(Scene *scene) {
+void GameBountyHunter::sceneNxtscnEndLevel(Scene *scene) {
switch (_currentLevel) {
case 0:
_levelDoneMask |= 0x02;
@@ -1233,18 +1230,18 @@ void GameBountyHunter::_scene_nxtscn_end_level(Scene *scene) {
_numSubLevelsDone = 0;
_currentSubLevelSceneId = 0;
if (_numLevelsDone == 4) {
- _SetNextScene(0x66);
+ setNextScene(0x66);
return;
}
- _SetNextScene(0x017B);
+ setNextScene(0x017B);
}
-void GameBountyHunter::_scene_nxtscn_end_game(Scene *scene) {
+void GameBountyHunter::sceneNxtscnEndGame(Scene *scene) {
_gameInProgress = false;
- _cur_scene = _startscene;
+ _curScene = _startScene;
}
-void GameBountyHunter::_scene_nxtscn_do_breakout_mains(Scene *scene) {
+void GameBountyHunter::sceneNxtscnDoBreakoutMains(Scene *scene) {
uint16 picked = 0;
if (_mainWounds & 2) {
_mainWounds &= 0xFFFD;
@@ -1261,15 +1258,15 @@ void GameBountyHunter::_scene_nxtscn_do_breakout_mains(Scene *scene) {
} else {
picked = 0x61;
}
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_died_refed(Scene *scene) {
+void GameBountyHunter::sceneNxtscnDiedRefed(Scene *scene) {
uint16 picked = 0;
uint8 deadCount = 0;
for (int i = 0; i < _numPlayers; i++) {
_playerLives[i]--;
- _DisplayLivesLeft(i);
+ displayLivesLeft(i);
if (_playerLives[i] <= 0) {
deadCount++;
}
@@ -1281,27 +1278,27 @@ void GameBountyHunter::_scene_nxtscn_died_refed(Scene *scene) {
} else {
picked = 0x114;
}
- _SetNextScene(picked);
+ setNextScene(picked);
}
-void GameBountyHunter::_scene_nxtscn_give_shotgun(Scene *scene) {
- for (uint8 i = 0; i < _numPlayers; i++) {
+void GameBountyHunter::sceneNxtscnGiveShotgun(Scene *scene) {
+ for (int i = 0; i < _numPlayers; i++) {
_playerShots[i] = 5;
_playerGun[i] = 2;
- _DisplayShotsLeft(i);
+ displayShotsLeft(i);
}
}
-void GameBountyHunter::_scene_nxtscn_check_2players(Scene *scene) {
+void GameBountyHunter::sceneNxtscnCheck2Players(Scene *scene) {
if (_numPlayers == 2) {
- _SetNextScene(0x98);
+ setNextScene(0x98);
return;
}
- _SetNextScene(0x99);
+ setNextScene(0x99);
}
// Script functions: WepDwn
-void GameBountyHunter::_scene_default_wepdwn(Scene *scene) {
+void GameBountyHunter::sceneDefaultWepdwn(Scene *scene) {
if (_playerGun[_player] == 2 && _playerShots[_player] < 3) {
_playerGun[_player] = 1;
}
@@ -1311,7 +1308,7 @@ void GameBountyHunter::_scene_default_wepdwn(Scene *scene) {
}
// Debug methods
-void GameBountyHunter::debug_warpTo(int val) {
+void GameBountyHunter::debugWarpTo(int val) {
// TODO implement
}
@@ -1331,7 +1328,7 @@ bool DebuggerBountyHunter::cmdWarpTo(int argc, const char **argv) {
return true;
} else {
int val = atoi(argv[1]);
- _game->debug_warpTo(val);
+ _game->debugWarpTo(val);
return false;
}
}
diff --git a/engines/alg/game_bountyhunter.h b/engines/alg/game_bountyhunter.h
index da252f60bb9..708a223b2da 100644
--- a/engines/alg/game_bountyhunter.h
+++ b/engines/alg/game_bountyhunter.h
@@ -52,10 +52,10 @@ class GameBountyHunter : public Game {
};
public:
- GameBountyHunter(AlgEngine *vm, const ADGameDescription *desc);
+ GameBountyHunter(AlgEngine *vm, const AlgGameDescription *gd);
~GameBountyHunter();
Common::Error run();
- void debug_warpTo(int val);
+ void debugWarpTo(int val);
private:
void init();
@@ -94,17 +94,17 @@ private:
Audio::SeekableAudioStream *_shotgunSound = nullptr;
// constants
- const uint16 _randomHarry1[7] = {0x01B9, 0x01B7, 0x01B5, 0x01B3, 0x01AF, 0x01AD, 0};
- const uint16 _randomHarry2[6] = {0x0194, 0x0190, 0x018E, 0x018C, 0};
- const uint16 _randomDan1[5] = {0x0173, 0x0171, 0x016F, 0x016D, 0};
- const uint16 _randomDan1TwoPlayer[6] = {0x0173, 0x0171, 0x016F, 0x016D, 0x016B, 0};
- const uint16 _randomDan2[7] = {0x0165, 0x0163, 0x0161, 0x015F, 0x015D, 0x015B, 0};
- const uint16 _randomLoco1[4] = {0xF7, 0xF5, 0xF3, 0};
- const uint16 _randomLoco2[3] = {0xED, 0xEB, 0};
- const uint16 _randomKid1[4] = {0xBA, 0xB7, 0xB5, 0};
- const uint16 _randomKid2[4] = {0xB1, 0xAE, 0xAC, 0};
-
- const uint16 *_randomScenes[8] = {_randomHarry1, _randomHarry2, _randomDan1, _randomDan2, _randomLoco1, _randomLoco2, _randomKid1, _randomKid2};
+ uint16 _randomHarry1[7] = {0x01B9, 0x01B7, 0x01B5, 0x01B3, 0x01AF, 0x01AD, 0};
+ uint16 _randomHarry2[6] = {0x0194, 0x0190, 0x018E, 0x018C, 0};
+ uint16 _randomDan1[5] = {0x0173, 0x0171, 0x016F, 0x016D, 0};
+ uint16 _randomDan1TwoPlayer[6] = {0x0173, 0x0171, 0x016F, 0x016D, 0x016B, 0};
+ uint16 _randomDan2[7] = {0x0165, 0x0163, 0x0161, 0x015F, 0x015D, 0x015B, 0};
+ uint16 _randomLoco1[4] = {0xF7, 0xF5, 0xF3, 0};
+ uint16 _randomLoco2[3] = {0xED, 0xEB, 0};
+ uint16 _randomKid1[4] = {0xBA, 0xB7, 0xB5, 0};
+ uint16 _randomKid2[4] = {0xB1, 0xAE, 0xAC, 0};
+
+ uint16 *_randomScenes[8] = {_randomHarry1, _randomHarry2, _randomDan1, _randomDan2, _randomLoco1, _randomLoco2, _randomKid1, _randomKid2};
const uint8 _randomScenesPicks[8] = {6, 6, 4, 7, 3, 2, 5, 5};
const uint8 _subLevelOrder[96] = {0, 1, 2, 4, 0, 0, 0, 1, 3, 4, 0, 0, 0, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4, 0,
@@ -112,7 +112,7 @@ private:
0, 1, 3, 4, 0, 0, 0, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4, 0,
0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0};
const uint16 _subLevelSceneIds[20] = {0x01BE, 0x017A, 0x01A2, 0x0198, 0x0183, 0x0178, 0x0167, 0x0159, 0x014B, 0x0147,
- 0xF1, 0xE1, 0xFF, 0xD8, 0xD0, 0x9B, 0xA8, 0x86, 0xBF, 0x74};
+ 0xF1, 0xE1, 0xFF, 0xD8, 0xD0, 0x9B, 0xA8, 0x86, 0xBF, 0x74};
const uint16 _clueLevels[4] = {0x017A, 0x013B, 0xC2, 0x68};
const uint8 _mainLevelMasks[5] = {2, 4, 8, 0x10, 0x80};
@@ -121,7 +121,7 @@ private:
const uint16 _firstSceneInScenario[4] = {4, 0x36, 0x36, 0x66};
const uint16 _moneyScenes[4] = {0x017D, 0x013C, 0xC3, 0x69};
const uint16 _gunfightScenarios[18] = {0x0116, 0x0118, 0x011B, 0x011D, 0x011F, 0x0121, 0x0123, 0x0125, 0x0127,
- 0x0129, 0x012B, 0x012D, 0x012F, 0x0131, 0x0133, 0x0135, 0x0137, 0x0139};
+ 0x0129, 0x012B, 0x012D, 0x012F, 0x0131, 0x0133, 0x0135, 0x0137, 0x0139};
const uint16 _innocentScenarios[5] = {0x0110, 0x010F, 0x010C, 0x010B, 0};
const uint16 _deathScenarios[9] = {0x0100, 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0};
const uint16 _onePlayerOfTwoDead[2] = {0x0109, 0x010A};
@@ -144,28 +144,28 @@ private:
uint8 _levelDoneMask = 0;
uint8 _numSubLevelsDone = 0;
- uint16 usedScenes = 0;
- int16 lastPick = -1;
- int16 initted = 0;
- int16 sceneCount = 0;
-
- uint16 *_random_scene_list;
- uint8 _random_max = 0;
- uint16 _random_mask = 0;
- int16 _random_picked = 0;
- uint8 _random_scene_count = 0;
- bool _gunfight_initialized = false;
- uint16 _gunfight_mask = 0;
- int16 _gunfight_picked = 0;
- uint8 _gunfight_scene_count = 0;
- bool _innocent_initialized = false;
- uint16 _innocent_mask = 0;
- int16 _innocent_picked = 0;
- uint8 _innocent_scene_count = 0;
- bool _death_initialized = false;
- uint16 _death_mask = 0;
- int16 _death_picked = 0;
- uint8 _death_scene_count = 0;
+ uint16 _usedScenes = 0;
+ int16 _lastPick = -1;
+ int16 _initted = 0;
+ int16 _sceneCount = 0;
+
+ uint16 *_randomSceneList;
+ uint8 _randomMax = 0;
+ uint16 _randomMask = 0;
+ int16 _randomPicked = 0;
+ uint8 _randomSceneCount = 0;
+ bool _gunfightInitialized = false;
+ uint16 _gunfightMask = 0;
+ int16 _gunfightPicked = 0;
+ uint8 _gunfightSceneCount = 0;
+ bool _innocentInitialized = false;
+ uint16 _innocentMask = 0;
+ int16 _innocentPicked = 0;
+ uint8 _innocentSceneCount = 0;
+ bool _deathInitialized = false;
+ uint16 _deathMask = 0;
+ int16 _deathPicked = 0;
+ uint8 _deathSceneCount = 0;
uint8 _continuesUsed = 0;
bool _wounded = false;
@@ -178,101 +178,101 @@ private:
uint8 _unk_2ADA6 = 0;
// base functions
- void _NewGame();
- void _DoMenu();
- void _DoCursor();
- void _UpdateMouse();
- void _MoveMouse();
- void _DisplayLivesLeft(uint8 player);
- void _DisplayScores(uint8 player);
- void _DisplayShotsLeft(uint8 player);
- bool _WeaponDown();
- bool _SaveState();
- bool _LoadState();
+ void newGame();
+ void doMenu();
+ void updateCursor();
+ void updateMouse();
+ void moveMouse();
+ void displayLivesLeft(uint8 player);
+ void displayScores(uint8 player);
+ void displayShotsLeft(uint8 player);
+ bool weaponDown();
+ bool saveState();
+ bool loadState();
// misc game functions
- void _SetNextScene(uint16 sceneId);
- void _DisplayShotFiredImage(Common::Point *point);
- void _EnableVideoFadeIn();
- void _IconShotgun();
- void _IconReset();
- uint16 _BeginLevel(uint8 levelNumber);
- uint16 _RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
- uint16 _PickRandomScene(const uint16 *sceneList, uint8 max);
- uint16 _PickGunfightScene();
- uint16 _PickInnocentScene();
- uint16 _PickDeathScene();
- uint16 _TimeForGunfight();
- void _WaitingForShootout(uint32 drawFrame);
- void _DoShotgunSound();
+ void setNextScene(uint16 sceneId);
+ void displayShotFiredImage(Common::Point *point);
+ void enableVideoFadeIn();
+ void iconShotgun();
+ void iconReset();
+ uint16 beginLevel(uint8 levelNumber);
+ uint16 randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
+ uint16 pickRandomScene(uint16 *sceneList, uint8 max);
+ uint16 pickGunfightScene();
+ uint16 pickInnocentScene();
+ uint16 pickDeathScene();
+ uint16 timeForGunfight();
+ void waitingForShootout(uint32 drawFrame);
+ void doShotgunSound();
// Script functions: RectHit
- void _rect_shotmenu(Rect *rect);
- void _rect_save(Rect *rect);
- void _rect_load(Rect *rect);
- void _rect_continue(Rect *rect);
- void _rect_start(Rect *rect);
- void _rect_toggle_players(Rect *rect);
- void _rect_hit_icon_jug(Rect *rect);
- void _rect_hit_icon_lantern(Rect *rect);
- void _rect_hit_icon_skull(Rect *rect);
- void _rect_hit_icon_wheel(Rect *rect);
- void _rect_hit_select_harry(Rect *rect);
- void _rect_hit_select_dan(Rect *rect);
- void _rect_hit_select_loco(Rect *rect);
- void _rect_hit_select_kid(Rect *rect);
- void _rect_hit_kill_man(Rect *rect);
- void _rect_hit_give_shotgun(Rect *rect);
- void _rect_hit_kill3(Rect *rect);
- void _rect_hit_check_shotgun(Rect *rect);
- void _rect_hit_cheater(Rect *rect);
+ void rectShotMenu(Rect *rect);
+ void rectSave(Rect *rect);
+ void rectLoad(Rect *rect);
+ void rectContinue(Rect *rect);
+ void rectStart(Rect *rect);
+ void rectTogglePlayers(Rect *rect);
+ void rectHitIconJug(Rect *rect);
+ void rectHitIconLantern(Rect *rect);
+ void rectHitIconSkull(Rect *rect);
+ void rectHitIconWheel(Rect *rect);
+ void rectHitSelectHarry(Rect *rect);
+ void rectHitSelectDan(Rect *rect);
+ void rectHitSelectLoco(Rect *rect);
+ void rectHitSelectKid(Rect *rect);
+ void rectHitKillMan(Rect *rect);
+ void rectHitGiveShotgun(Rect *rect);
+ void rectHitKill3(Rect *rect);
+ void rectHitCheckShotgun(Rect *rect);
+ void rectHitCheater(Rect *rect);
// Script functions: Scene PreOps
- void _scene_pso_shootout(Scene *scene);
- void _scene_pso_wounded_main(Scene *scene);
- void _scene_pso_gunfight_setup(Scene *scene);
- void _scene_pso_lose_a_life(Scene *scene);
- void _scene_pso_setup_ndrandom1(Scene *scene);
- void _scene_pso_set_current_scene(Scene *scene);
+ void scenePsoShootout(Scene *scene);
+ void scenePsoWoundedMain(Scene *scene);
+ void scenePsoGunfightSetup(Scene *scene);
+ void scenePsoLoseALife(Scene *scene);
+ void scenePsoSetupNdRandom1(Scene *scene);
+ void scenePsoSetCurrentScene(Scene *scene);
// Script functions: Scene InsOps
- void _scene_iso_shootout(Scene *scene);
- void _scene_iso_givemoney(Scene *scene);
+ void sceneIsoShootout(Scene *scene);
+ void sceneIsoGivemoney(Scene *scene);
// Script functions: Scene NxtScn
- void _scene_nxtscn_lose_a_life(Scene *scene);
- void _scene_nxtscn_continue_game(Scene *scene);
- void _scene_nxtscn_did_not_continue(Scene *scene);
- void _scene_nxtscn_kill_innocent_man(Scene *scene);
- void _scene_nxtscn_kill_innocent_woman(Scene *scene);
- void _scene_nxtscn_after_die(Scene *scene);
- void _scene_nxtscn_goto_level_select(Scene *scene);
- void _scene_nxtscn_continue_random(Scene *scene);
- void _scene_nxtscn_init_random_harry1(Scene *scene);
- void _scene_nxtscn_init_random_harry2(Scene *scene);
- void _scene_nxtscn_init_random_dan1(Scene *scene);
- void _scene_nxtscn_init_random_dan2(Scene *scene);
- void _scene_nxtscn_init_random_loco1(Scene *scene);
- void _scene_nxtscn_init_random_loco2(Scene *scene);
- void _scene_nxtscn_init_random_kid1(Scene *scene);
- void _scene_nxtscn_init_random_kid2(Scene *scene);
- void _scene_nxtscn_next_sub_level(Scene *scene);
- void _scene_nxtscn_goto_bad_guy(Scene *scene);
- void _scene_nxtscn_auto_select_level(Scene *scene);
- void _scene_nxtscn_select_scenario(Scene *scene);
- void _scene_nxtscn_finish_scenario(Scene *scene);
- void _scene_nxtscn_game_won(Scene *scene);
- void _scene_nxtscn_killed_main(Scene *scene);
- void _scene_nxtscn_wounded_main(Scene *scene);
- void _scene_nxtscn_end_level(Scene *scene);
- void _scene_nxtscn_end_game(Scene *scene);
- void _scene_nxtscn_do_breakout_mains(Scene *scene);
- void _scene_nxtscn_died_refed(Scene *scene);
- void _scene_nxtscn_give_shotgun(Scene *scene);
- void _scene_nxtscn_check_2players(Scene *scene);
+ void sceneNxtscnLoseALife(Scene *scene);
+ void sceneNxtscnContinueGame(Scene *scene);
+ void sceneNxtscnDidNotContinue(Scene *scene);
+ void sceneNxtscnKillInnocentMan(Scene *scene);
+ void sceneNxtscnKillInnocentWoman(Scene *scene);
+ void sceneNxtscnAfterDie(Scene *scene);
+ void sceneNxtscnGotoLevelSelect(Scene *scene);
+ void sceneNxtscnContinueRandom(Scene *scene);
+ void sceneNxtscnInitRandomHarry1(Scene *scene);
+ void sceneNxtscnInitRandomHarry2(Scene *scene);
+ void sceneNxtscnInitRandomDan1(Scene *scene);
+ void sceneNxtscnInitRandomDan2(Scene *scene);
+ void sceneNxtscnInitRandomLoco1(Scene *scene);
+ void sceneNxtscnInitRandomLoco2(Scene *scene);
+ void sceneNxtscnInitRandomKid1(Scene *scene);
+ void sceneNxtscnInitRandomKid2(Scene *scene);
+ void sceneNxtscnNextSubLevel(Scene *scene);
+ void sceneNxtscnGotoBadGuy(Scene *scene);
+ void sceneNxtscnAutoSelectLevel(Scene *scene);
+ void sceneNxtscnSelectScenario(Scene *scene);
+ void sceneNxtscnFinishScenario(Scene *scene);
+ void sceneNxtscnGameWon(Scene *scene);
+ void sceneNxtscnKilledMain(Scene *scene);
+ void sceneNxtscnWoundedMain(Scene *scene);
+ void sceneNxtscnEndLevel(Scene *scene);
+ void sceneNxtscnEndGame(Scene *scene);
+ void sceneNxtscnDoBreakoutMains(Scene *scene);
+ void sceneNxtscnDiedRefed(Scene *scene);
+ void sceneNxtscnGiveShotgun(Scene *scene);
+ void sceneNxtscnCheck2Players(Scene *scene);
// Script functions: Scene WepDwn
- void _scene_default_wepdwn(Scene *scene);
+ void sceneDefaultWepdwn(Scene *scene);
};
class DebuggerBountyHunter : public GUI::Debugger {
diff --git a/engines/alg/game_crimepatrol.cpp b/engines/alg/game_crimepatrol.cpp
index f335bcf85b0..73ef87eb0a8 100644
--- a/engines/alg/game_crimepatrol.cpp
+++ b/engines/alg/game_crimepatrol.cpp
@@ -25,7 +25,6 @@
#include "common/system.h"
#include "graphics/cursorman.h"
-#include "graphics/pixelformat.h"
#include "alg/game_crimepatrol.h"
#include "alg/graphics.h"
@@ -33,12 +32,12 @@
namespace Alg {
-GameCrimePatrol::GameCrimePatrol(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
- if (scumm_stricmp(desc->gameId, "cpatrols") == 0) {
+GameCrimePatrol::GameCrimePatrol(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
+ if (gd->gameType == GType_CPATROL_SS_DOS) {
_libFileName = "cpss.lib";
- } else if (scumm_stricmp(desc->gameId, "cpatrold") == 0) {
+ } else if (gd->gameType == GType_CPATROL_DS_DOS) {
_libFileName = "cpds.lib";
- } else if (scumm_stricmp(desc->gameId, "cpatroldemo") == 0) {
+ } else if (gd->gameType == GType_CPATROL_DEMO_DOS) {
_libFileName = "cp.lib";
_isDemo = true;
}
@@ -48,25 +47,27 @@ GameCrimePatrol::~GameCrimePatrol() {
}
void GameCrimePatrol::init() {
+ Game::init();
+
_videoPosX = 11;
_videoPosY = 2;
loadLibArchive(_libFileName);
_sceneInfo->loadScnFile("cp.scn");
- _startscene = _sceneInfo->getStartScene();
+ _startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
_menuzone = new Zone();
- _menuzone->name = "MainMenu";
- _menuzone->ptrfb = "GLOBALHIT";
+ _menuzone->_name = "MainMenu";
+ _menuzone->_ptrfb = "GLOBALHIT";
_menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
_submenzone = new Zone();
- _submenzone->name = "SubMenu";
- _submenzone->ptrfb = "GLOBALHIT";
+ _submenzone->_name = "SubMenu";
+ _submenzone->_ptrfb = "GLOBALHIT";
_submenzone->addRect(0x1C, 0x11, 0x5D, 0x20, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x1C, 0x31, 0x5D, 0x40, nullptr, 0, "RECTLOAD", "0");
@@ -77,11 +78,11 @@ void GameCrimePatrol::init() {
_submenzone->addRect(0xDD, 0x5C, 0x010A, 0x6B, nullptr, 0, "RECTAVG", "0");
_submenzone->addRect(0xDD, 0x7C, 0x010A, 0x8B, nullptr, 0, "RECTHARD", "0");
- _shotSound = _LoadSoundFile("blow.8b");
- _emptySound = _LoadSoundFile("empty.8b");
- _saveSound = _LoadSoundFile("saved.8b");
- _loadSound = _LoadSoundFile("loaded.8b");
- _skullSound = _LoadSoundFile("skull.8b");
+ _shotSound = loadSoundFile("blow.8b");
+ _emptySound = loadSoundFile("empty.8b");
+ _saveSound = loadSoundFile("saved.8b");
+ _loadSound = loadSoundFile("loaded.8b");
+ _skullSound = loadSoundFile("skull.8b");
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
@@ -99,148 +100,148 @@ void GameCrimePatrol::init() {
_background = AlgGraphics::loadVgaBackground("cp_menu.vga", _palette);
_screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
- _MoveMouse();
+ moveMouse();
}
void GameCrimePatrol::registerScriptFunctions() {
#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new CPScriptFunctionRect(this, &GameCrimePatrol::func);
- RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
- RECT_HIT_FUNCTION("NEWSCENE", _rect_newscene);
- RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
- RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
- RECT_HIT_FUNCTION("STARTMENU", _rect_start);
- RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
- RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
- RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
- RECT_HIT_FUNCTION("RECTEASY", _rect_easy);
- RECT_HIT_FUNCTION("RECTAVG", _rect_average);
- RECT_HIT_FUNCTION("RECTHARD", _rect_hard);
- RECT_HIT_FUNCTION("TARGET_PRACTICE", _rect_target_practice);
- RECT_HIT_FUNCTION("SELECT_TARGET_PRACTICE", _rect_select_target_practice);
- RECT_HIT_FUNCTION("SELECT_GANG_FIGHT", _rect_select_gang_fight);
- RECT_HIT_FUNCTION("SELECT_WAREHOUSE", _rect_select_warehouse);
- RECT_HIT_FUNCTION("SELECT_WESTCOAST_SOUND", _rect_select_westcoast_sound);
- RECT_HIT_FUNCTION("SELECT_DRUG_DEAL", _rect_select_drug_deal);
- RECT_HIT_FUNCTION("SELECT_CAR_RING", _rect_select_car_ring);
- RECT_HIT_FUNCTION("SELECT_BAR", _rect_select_bar);
- RECT_HIT_FUNCTION("SELECT_BANK", _rect_select_bank);
- RECT_HIT_FUNCTION("SELECT_CRACK_HOUSE", _rect_select_crack_house);
- RECT_HIT_FUNCTION("SELECT_METH_LAB", _rect_select_meth_lab);
- RECT_HIT_FUNCTION("SELECT_AIRPLANE", _rect_select_airplane);
- RECT_HIT_FUNCTION("SELECT_NUKE_TRANSPORT", _rect_select_nuke_transport);
- RECT_HIT_FUNCTION("SELECT_AIRPORT", _rect_select_airport);
- RECT_HIT_FUNCTION("KILL_INNOCENT_MAN", _rect_kill_innocent_man);
+ RECT_HIT_FUNCTION("DEFAULT", rectNewScene);
+ RECT_HIT_FUNCTION("NEWSCENE", rectNewScene);
+ RECT_HIT_FUNCTION("EXITMENU", rectExit);
+ RECT_HIT_FUNCTION("CONTMENU", rectContinue);
+ RECT_HIT_FUNCTION("STARTMENU", rectStart);
+ RECT_HIT_FUNCTION("SHOTMENU", rectShotMenu);
+ RECT_HIT_FUNCTION("RECTSAVE", rectSave);
+ RECT_HIT_FUNCTION("RECTLOAD", rectLoad);
+ RECT_HIT_FUNCTION("RECTEASY", rectEasy);
+ RECT_HIT_FUNCTION("RECTAVG", rectAverage);
+ RECT_HIT_FUNCTION("RECTHARD", rectHard);
+ RECT_HIT_FUNCTION("TARGET_PRACTICE", rectTargetPractice);
+ RECT_HIT_FUNCTION("SELECT_TARGET_PRACTICE", rectSelectTargetPractice);
+ RECT_HIT_FUNCTION("SELECT_GANG_FIGHT", rectSelectGangFight);
+ RECT_HIT_FUNCTION("SELECT_WAREHOUSE", rectSelectWarehouse);
+ RECT_HIT_FUNCTION("SELECT_WESTCOAST_SOUND", rectSelectWestcoastSound);
+ RECT_HIT_FUNCTION("SELECT_DRUG_DEAL", rectSelectDrugDeal);
+ RECT_HIT_FUNCTION("SELECT_CAR_RING", rectSelectCarRing);
+ RECT_HIT_FUNCTION("SELECT_BAR", rectSelectBar);
+ RECT_HIT_FUNCTION("SELECT_BANK", rectSelectBank);
+ RECT_HIT_FUNCTION("SELECT_CRACK_HOUSE", rectSelectCrackHouse);
+ RECT_HIT_FUNCTION("SELECT_METH_LAB", rectSelectMethLab);
+ RECT_HIT_FUNCTION("SELECT_AIRPLANE", rectSelectAirplane);
+ RECT_HIT_FUNCTION("SELECT_NUKE_TRANSPORT", rectSelectNukeTransport);
+ RECT_HIT_FUNCTION("SELECT_AIRPORT", rectSelectAirport);
+ RECT_HIT_FUNCTION("KILL_INNOCENT_MAN", rectKillInnocentMan);
#undef RECT_HIT_FUNCTION
#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new CPScriptFunctionScene(this, &GameCrimePatrol::func);
- PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
- PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
- PRE_OPS_FUNCTION("PAUSE_FADEIN", _scene_pso_pause_fadein);
- PRE_OPS_FUNCTION("WAREHOUSE_GOT_TO", _scene_pso_warehouse_got_to);
- PRE_OPS_FUNCTION("GANG_FIGHT_GOT_TO", _scene_pso_gang_fight_got_to);
- PRE_OPS_FUNCTION("WESTCOAST_SOUND_GOT_TO", _scene_pso_westcoast_sound_got_to);
- PRE_OPS_FUNCTION("DRUG_DEAL_GOT_TO", _scene_pso_drug_deal_got_to);
- PRE_OPS_FUNCTION("CAR_RING_GOT_TO", _scene_pso_car_ring_got_to);
- PRE_OPS_FUNCTION("BANK_GOT_TO", _scene_pso_bank_got_to);
- PRE_OPS_FUNCTION("CRACK_HOUSE_GOT_TO", _scene_pso_crack_house_got_to);
- PRE_OPS_FUNCTION("METH_LAB_GOT_TO", _scene_pso_meth_lab_got_to);
- PRE_OPS_FUNCTION("AIRPLANE_GOT_TO", _scene_pso_airplane_got_to);
- PRE_OPS_FUNCTION("AIRPORT_GOT_TO", _scene_pso_airport_got_to);
- PRE_OPS_FUNCTION("NUKE_TRANSPORT_GOT_TO", _scene_pso_nuke_transport_got_to);
- PRE_OPS_FUNCTION("POWER_PLANT_GOT_TO", _scene_pso_power_plant_got_to);
+ PRE_OPS_FUNCTION("DEFAULT", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("PAUSE", scenePsoPause);
+ PRE_OPS_FUNCTION("FADEIN", scenePsoFadeIn);
+ PRE_OPS_FUNCTION("PAUSE_FADEIN", scenePsoPauseFadeIn);
+ PRE_OPS_FUNCTION("WAREHOUSE_GOT_TO", scenePsoWarehouseGotTo);
+ PRE_OPS_FUNCTION("GANG_FIGHT_GOT_TO", scenePsoGangFightGotTo);
+ PRE_OPS_FUNCTION("WESTCOAST_SOUND_GOT_TO", scenePsoWestcoastSoundGotTo);
+ PRE_OPS_FUNCTION("DRUG_DEAL_GOT_TO", scenePsoDrugDealGotTo);
+ PRE_OPS_FUNCTION("CAR_RING_GOT_TO", scenePsoCarRingGotTo);
+ PRE_OPS_FUNCTION("BANK_GOT_TO", scenePsoBankGotTo);
+ PRE_OPS_FUNCTION("CRACK_HOUSE_GOT_TO", scenePsoCrackHouseGotTo);
+ PRE_OPS_FUNCTION("METH_LAB_GOT_TO", scenePsoMethLabGotTo);
+ PRE_OPS_FUNCTION("AIRPLANE_GOT_TO", scenePsoAirplaneGotTo);
+ PRE_OPS_FUNCTION("AIRPORT_GOT_TO", scenePsoAirportGotTo);
+ PRE_OPS_FUNCTION("NUKE_TRANSPORT_GOT_TO", scenePsoNukeTransportGotTo);
+ PRE_OPS_FUNCTION("POWER_PLANT_GOT_TO", scenePsoPowerPlantGotTo);
#undef PRE_OPS_FUNCTION
#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new CPScriptFunctionScene(this, &GameCrimePatrol::func);
- INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
- INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
+ INS_OPS_FUNCTION("DEFAULT", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("PAUSE", sceneIsoPause);
#undef INS_OPS_FUNCTION
#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new CPScriptFunctionScene(this, &GameCrimePatrol::func);
- NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
- NXT_SCN_FUNCTION("GAME_WON", _scene_nxtscn_game_won);
- NXT_SCN_FUNCTION("LOSE_A_LIFE", _scene_nxtscn_lose_a_life);
- NXT_SCN_FUNCTION("DID_NOT_CONTINUE", _scene_nxtscn_did_not_continue);
- NXT_SCN_FUNCTION("KILL_INNOCENT_MAN", _scene_nxtscn_kill_innocent_man);
- NXT_SCN_FUNCTION("KILL_INNOCENT_WOMAN", _scene_nxtscn_kill_innocent_woman);
- NXT_SCN_FUNCTION("AFTER_DIE", _scene_nxtscn_after_die);
- NXT_SCN_FUNCTION("SELECT_LANGUAGE_1", _scene_nxtscn_select_language_1);
- NXT_SCN_FUNCTION("SELECT_LANGUAGE_2", _scene_nxtscn_select_language_2);
- NXT_SCN_FUNCTION("INIT_RANDOM_TARGET_PRACTICE", _scene_nxtscn_init_random_target_practice);
- NXT_SCN_FUNCTION("CONTINUE_TARGET_PRACTICE", _scene_nxtscn_continue_target_practice);
- NXT_SCN_FUNCTION("SELECT_ROOKIE_SCENARIO", _scene_nxtscn_select_rookie_scenario);
- NXT_SCN_FUNCTION("FINISH_GANG_FIGHT", _scene_nxtscn_finish_gang_fight);
- NXT_SCN_FUNCTION("FINISH_WESTCOAST_SOUND", _scene_nxtscn_finish_westcoast_sound);
- NXT_SCN_FUNCTION("FINISH_WAREHOUSE", _scene_nxtscn_finish_warehouse);
- NXT_SCN_FUNCTION("INIT_RANDOM_WAREHOUSE", _scene_nxtscn_init_random_warehouse);
- NXT_SCN_FUNCTION("CONTINUE_WAREHOUSE", _scene_nxtscn_continue_warehouse);
- NXT_SCN_FUNCTION("SELECT_UNDERCOVER_SCENARIO", _scene_nxtscn_select_undercover_scenario);
- NXT_SCN_FUNCTION("FINISH_DRUG_DEAL", _scene_nxtscn_finish_drug_deal);
- NXT_SCN_FUNCTION("INIT_RANDOM_CAR_RING_LEADER", _scene_nxtscn_init_random_car_ring_leader);
- NXT_SCN_FUNCTION("CONTINUE_CAR_RING_LEADER_1", _scene_nxtscn_continue_car_ring_leader_1);
- NXT_SCN_FUNCTION("CONTINUE_CAR_RING_LEADER_2", _scene_nxtscn_continue_car_ring_leader_2);
- NXT_SCN_FUNCTION("INIT_RANDOM_CAR_RING", _scene_nxtscn_init_random_car_ring);
- NXT_SCN_FUNCTION("CONTINUE_CAR_RING", _scene_nxtscn_continue_car_ring);
- NXT_SCN_FUNCTION("FINISH_CAR_RING", _scene_nxtscn_finish_car_ring);
- NXT_SCN_FUNCTION("FINISH_BAR", _scene_nxtscn_finish_bar);
- NXT_SCN_FUNCTION("FINISH_BANK", _scene_nxtscn_finish_bank);
- NXT_SCN_FUNCTION("FINISH_CRACK_HOUSE", _scene_nxtscn_finish_crack_house);
- NXT_SCN_FUNCTION("FINISH_METH_LAB", _scene_nxtscn_finish_meth_lab);
- NXT_SCN_FUNCTION("FINISH_AIRPLANE", _scene_nxtscn_finish_airplane);
- NXT_SCN_FUNCTION("FINISH_AIRPORT", _scene_nxtscn_finish_airport);
- NXT_SCN_FUNCTION("FINISH_NUKE_TRANSPORT", _scene_nxtscn_finish_nuke_transport);
- NXT_SCN_FUNCTION("INIT_RANDOM_BAR", _scene_nxtscn_init_random_bar);
- NXT_SCN_FUNCTION("CONTINUE_BAR", _scene_nxtscn_continue_bar);
- NXT_SCN_FUNCTION("SELECT_SWAT_SCENARIO", _scene_nxtscn_select_swat_scenario);
- NXT_SCN_FUNCTION("INIT_RANDOM_BANK", _scene_nxtscn_init_random_bank);
- NXT_SCN_FUNCTION("CONTINUE_BANK", _scene_nxtscn_continue_bank);
- NXT_SCN_FUNCTION("INIT_RANDOM_METH_LAB", _scene_nxtscn_init_random_meth_lab);
- NXT_SCN_FUNCTION("CONTINUE_METH_LAB", _scene_nxtscn_continue_meth_lab);
- NXT_SCN_FUNCTION("SELECT_DELTA_SCENARIO", _scene_nxtscn_select_delta_scenario);
- NXT_SCN_FUNCTION("PICK_RANDOM_RAPPELLER", _scene_nxtscn_pick_random_rapeller);
- NXT_SCN_FUNCTION("INIT_RANDOM_AIRPLANE", _scene_nxtscn_init_random_airplane);
- NXT_SCN_FUNCTION("CONTINUE_AIRPLANE", _scene_nxtscn_continue_airplane);
- NXT_SCN_FUNCTION("PICK_RANDOM_AIRPLANE_FRONT", _scene_nxtscn_pick_random_airplane_front);
- NXT_SCN_FUNCTION("INIT_RANDOM_AIRPORT", _scene_nxtscn_init_random_airport);
- NXT_SCN_FUNCTION("CONTINUE_AIRPORT", _scene_nxtscn_continue_airport);
- NXT_SCN_FUNCTION("INIT_RANDOM_NUKE_TRANSPORT", _scene_nxtscn_init_random_nuke_transport);
- NXT_SCN_FUNCTION("CONTINUE_NUKE_TRANSPORT", _scene_nxtscn_continue_nuke_transport);
- NXT_SCN_FUNCTION("INIT_RANDOM_POWERPLANT", _scene_nxtscn_init_random_powerplant);
- NXT_SCN_FUNCTION("CONTINUE_POWERPLANT", _scene_nxtscn_continue_powerplant);
+ NXT_SCN_FUNCTION("DEFAULT", sceneDefaultNxtscn);
+ NXT_SCN_FUNCTION("GAME_WON", sceneNxtscnGameWon);
+ NXT_SCN_FUNCTION("LOSE_A_LIFE", sceneNxtscnLoseALife);
+ NXT_SCN_FUNCTION("DID_NOT_CONTINUE", sceneNxtscnDidNotContinue);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_MAN", sceneNxtscnKillInnocentMan);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_WOMAN", sceneNxtscnKillInnocentWoman);
+ NXT_SCN_FUNCTION("AFTER_DIE", sceneNxtscnAfterDie);
+ NXT_SCN_FUNCTION("SELECT_LANGUAGE_1", sceneNxtscnSelectLanguage1);
+ NXT_SCN_FUNCTION("SELECT_LANGUAGE_2", sceneNxtscnSelectLanguage2);
+ NXT_SCN_FUNCTION("INIT_RANDOM_TARGET_PRACTICE", sceneNxtscnInitRandomTargetPractice);
+ NXT_SCN_FUNCTION("CONTINUE_TARGET_PRACTICE", sceneNxtscnContinueTargetPractice);
+ NXT_SCN_FUNCTION("SELECT_ROOKIE_SCENARIO", sceneNxtscnSelectRookieScenario);
+ NXT_SCN_FUNCTION("FINISH_GANG_FIGHT", sceneNxtscnFinishGangFight);
+ NXT_SCN_FUNCTION("FINISH_WESTCOAST_SOUND", sceneNxtscnFinishWestcoastSound);
+ NXT_SCN_FUNCTION("FINISH_WAREHOUSE", sceneNxtscnFinishWarehouse);
+ NXT_SCN_FUNCTION("INIT_RANDOM_WAREHOUSE", sceneNxtscnInitRandomWarehouse);
+ NXT_SCN_FUNCTION("CONTINUE_WAREHOUSE", sceneNxtscnContinueWarehouse);
+ NXT_SCN_FUNCTION("SELECT_UNDERCOVER_SCENARIO", sceneNxtscnSelectUndercoverScenario);
+ NXT_SCN_FUNCTION("FINISH_DRUG_DEAL", sceneNxtscnFinishDrugDeal);
+ NXT_SCN_FUNCTION("INIT_RANDOM_CAR_RING_LEADER", sceneNxtscnInitRandomCarRingLeader);
+ NXT_SCN_FUNCTION("CONTINUE_CAR_RING_LEADER_1", sceneNxtscnContinueCarRingLeader1);
+ NXT_SCN_FUNCTION("CONTINUE_CAR_RING_LEADER_2", sceneNxtscnContinueCarRingLeader2);
+ NXT_SCN_FUNCTION("INIT_RANDOM_CAR_RING", sceneNxtscnInitRandomCarRing);
+ NXT_SCN_FUNCTION("CONTINUE_CAR_RING", sceneNxtscnContinueCarRing);
+ NXT_SCN_FUNCTION("FINISH_CAR_RING", sceneNxtscnFinishCarRing);
+ NXT_SCN_FUNCTION("FINISH_BAR", sceneNxtscnFinishBar);
+ NXT_SCN_FUNCTION("FINISH_BANK", sceneNxtscnFinishBank);
+ NXT_SCN_FUNCTION("FINISH_CRACK_HOUSE", sceneNxtscnFinishCrackHouse);
+ NXT_SCN_FUNCTION("FINISH_METH_LAB", sceneNxtscnFinishMethLab);
+ NXT_SCN_FUNCTION("FINISH_AIRPLANE", sceneNxtscnFinishAirplane);
+ NXT_SCN_FUNCTION("FINISH_AIRPORT", sceneNxtscnFinishAirport);
+ NXT_SCN_FUNCTION("FINISH_NUKE_TRANSPORT", sceneNxtscnFinishNukeTransport);
+ NXT_SCN_FUNCTION("INIT_RANDOM_BAR", sceneNxtscnInitRandomBar);
+ NXT_SCN_FUNCTION("CONTINUE_BAR", sceneNxtscnContinueBar);
+ NXT_SCN_FUNCTION("SELECT_SWAT_SCENARIO", sceneNxtscnSelectSwatScenario);
+ NXT_SCN_FUNCTION("INIT_RANDOM_BANK", sceneNxtscnInitRandomBank);
+ NXT_SCN_FUNCTION("CONTINUE_BANK", sceneNxtscnContinueBank);
+ NXT_SCN_FUNCTION("INIT_RANDOM_METH_LAB", sceneNxtscnInitRandomMethLab);
+ NXT_SCN_FUNCTION("CONTINUE_METH_LAB", sceneNxtscnContinueMethLab);
+ NXT_SCN_FUNCTION("SELECT_DELTA_SCENARIO", sceneNxtscnSelectDeltaScenario);
+ NXT_SCN_FUNCTION("PICK_RANDOM_RAPPELLER", sceneNxtscnPickRandomRapeller);
+ NXT_SCN_FUNCTION("INIT_RANDOM_AIRPLANE", sceneNxtscnInitRandomAirplane);
+ NXT_SCN_FUNCTION("CONTINUE_AIRPLANE", sceneNxtscnContinueAirplane);
+ NXT_SCN_FUNCTION("PICK_RANDOM_AIRPLANE_FRONT", sceneNxtscnPickRandomAirplaneFront);
+ NXT_SCN_FUNCTION("INIT_RANDOM_AIRPORT", sceneNxtscnInitRandomAirport);
+ NXT_SCN_FUNCTION("CONTINUE_AIRPORT", sceneNxtscnContinueAirport);
+ NXT_SCN_FUNCTION("INIT_RANDOM_NUKE_TRANSPORT", sceneNxtscnInitRandomNukeTransport);
+ NXT_SCN_FUNCTION("CONTINUE_NUKE_TRANSPORT", sceneNxtscnContinueNukeTransport);
+ NXT_SCN_FUNCTION("INIT_RANDOM_POWERPLANT", sceneNxtscnInitRandomPowerplant);
+ NXT_SCN_FUNCTION("CONTINUE_POWERPLANT", sceneNxtscnContinuePowerplant);
#undef NXT_SCN_FUNCTION
- _sceneShowMsg["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::_scene_sm_donothing);
- _sceneWepDwn["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::_scene_default_wepdwn);
- _sceneScnScr["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::_scene_default_score);
- _sceneNxtFrm["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::_scene_nxtfrm);
+ _sceneShowMsg["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::sceneSmDonothing);
+ _sceneWepDwn["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::sceneDefaultWepdwn);
+ _sceneScnScr["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::sceneDefaultScore);
+ _sceneNxtFrm["DEFAULT"] = new CPScriptFunctionScene(this, &GameCrimePatrol::sceneNxtfrm);
}
void GameCrimePatrol::verifyScriptFunctions() {
Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
for (size_t i = 0; i < scenes->size(); i++) {
Scene *scene = (*scenes)[i];
- getScriptFunctionScene(PREOP, scene->preop);
- getScriptFunctionScene(SHOWMSG, scene->scnmsg);
- getScriptFunctionScene(INSOP, scene->insop);
- getScriptFunctionScene(WEPDWN, scene->wepdwn);
- getScriptFunctionScene(SCNSCR, scene->scnscr);
- getScriptFunctionScene(NXTFRM, scene->nxtfrm);
- getScriptFunctionScene(NXTSCN, scene->nxtscn);
- for (size_t j = 0; j < scene->zones.size(); j++) {
- Zone *zone = scene->zones[j];
- for (size_t k = 0; k < zone->rects.size(); k++) {
- getScriptFunctionRectHit(zone->rects[k].rectHit);
+ getScriptFunctionScene(PREOP, scene->_preop);
+ getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
+ getScriptFunctionScene(INSOP, scene->_insop);
+ getScriptFunctionScene(WEPDWN, scene->_wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->_scnscr);
+ getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->_nxtscn);
+ for (size_t j = 0; j < scene->_zones.size(); j++) {
+ Zone *zone = scene->_zones[j];
+ for (size_t k = 0; k < zone->_rects.size(); k++) {
+ getScriptFunctionRectHit(zone->_rects[k]._rectHit);
}
}
}
}
CPScriptFunctionRect GameCrimePatrol::getScriptFunctionRectHit(Common::String name) {
- CPScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ auto it = _rectHitFuncs.find(name);
if (it != _rectHitFuncs.end()) {
return (*(*it)._value);
} else {
- error("Could not find rectHit function: %s", name.c_str());
+ error("GameCrimePatrol::getScriptFunctionRectHit(): Could not find rectHit function: %s", name.c_str());
}
}
@@ -269,7 +270,7 @@ CPScriptFunctionScene GameCrimePatrol::getScriptFunctionScene(SceneFuncType type
functionMap = &_sceneNxtScn;
break;
default:
- error("Unkown scene script type: %u", type);
+ error("GameCrimePatrol::getScriptFunctionScene(): Unkown scene script type: %u", type);
break;
}
CPScriptFunctionSceneMap::iterator it;
@@ -277,7 +278,7 @@ CPScriptFunctionScene GameCrimePatrol::getScriptFunctionScene(SceneFuncType type
if (it != functionMap->end()) {
return (*(*it)._value);
} else {
- error("Could not find scene type %u function: %s", type, name.c_str());
+ error("GameCrimePatrol::getScriptFunctionScene(): Could not find scene type %u function: %s", type, name.c_str());
}
}
@@ -293,19 +294,18 @@ void GameCrimePatrol::callScriptFunctionScene(SceneFuncType type, Common::String
Common::Error GameCrimePatrol::run() {
init();
- _NewGame();
- _cur_scene = _startscene;
+ newGame();
+ _curScene = _startScene;
Common::String oldscene;
while (!_vm->shouldQuit()) {
- oldscene = _cur_scene;
- _SetFrame();
+ oldscene = _curScene;
_fired = false;
- Scene *scene = _sceneInfo->findScene(_cur_scene);
+ Scene *scene = _sceneInfo->findScene(_curScene);
if (!loadScene(scene)) {
- if (scene->nxtscn == "CONTINUE_TARGET_PRACTICE") {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ if (scene->_nxtscn == "CONTINUE_TARGET_PRACTICE") {
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
} else {
- error("Cannot find scene %s in libfile", scene->name.c_str());
+ error("GameCrimePatrol::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
}
_sceneSkipped = false;
@@ -313,60 +313,58 @@ Common::Error GameCrimePatrol::run() {
g_system->getMixer()->stopHandle(_sceneAudioHandle);
g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
- _nextFrameTime = _GetMsTime() + 100;
- callScriptFunctionScene(PREOP, scene->preop, scene);
- _currentFrame = _GetFrame(scene);
- while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
- _UpdateMouse();
- callScriptFunctionScene(SHOWMSG, scene->scnmsg, scene);
- callScriptFunctionScene(INSOP, scene->insop, scene);
- _holster = _WeaponDown();
+ _nextFrameTime = getMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->_preop, scene);
+ _currentFrame = getFrame(scene);
+ while (_currentFrame <= scene->_endFrame && _curScene == oldscene && !_vm->shouldQuit()) {
+ updateMouse();
+ callScriptFunctionScene(SHOWMSG, scene->_scnmsg, scene);
+ callScriptFunctionScene(INSOP, scene->_insop, scene);
+ _holster = weaponDown();
if (_holster) {
- callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ callScriptFunctionScene(WEPDWN, scene->_wepdwn, scene);
}
Common::Point firedCoords;
- if (__Fired(&firedCoords)) {
+ if (fired(&firedCoords)) {
if (!_holster) {
- Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ Rect *hitGlobalRect = checkZone(_menuzone, &firedCoords);
if (hitGlobalRect != nullptr) {
- callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
- } else {
- if (_shots > 0) {
- if (!_debug_unlimitedAmmo) {
- _shots--;
- }
- _DisplayShotFiredImage(&firedCoords);
- _DoShot();
- Rect *hitRect = nullptr;
- Zone *hitSceneZone = _CheckZonesV2(scene, hitRect, &firedCoords);
- if (hitSceneZone != nullptr) {
- callScriptFunctionRectHit(hitRect->rectHit, hitRect);
- } else {
- int8 skip = _SkipToNewScene(scene);
- if (skip == -1) {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
- } else if (skip == 1) {
- if (scene->dataParam4 > 0) {
- uint32 framesToSkip = (scene->dataParam4 - _currentFrame) / _videoFrameSkip;
- _videoDecoder->skipNumberOfFrames(framesToSkip);
- } else {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
- }
+ callScriptFunctionRectHit(hitGlobalRect->_rectHit, hitGlobalRect);
+ } else if (_shots > 0) {
+ if (!_debug_unlimitedAmmo) {
+ _shots--;
+ }
+ displayShotFiredImage(&firedCoords);
+ doShot();
+ Rect *hitRect = nullptr;
+ Zone *hitSceneZone = checkZonesV2(scene, hitRect, &firedCoords);
+ if (hitSceneZone != nullptr) {
+ callScriptFunctionRectHit(hitRect->_rectHit, hitRect);
+ } else {
+ int8 skip = skipToNewScene(scene);
+ if (skip == -1) {
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
+ } else if (skip == 1) {
+ if (scene->_dataParam4 > 0) {
+ uint32 framesToSkip = (scene->_dataParam4 - _currentFrame) / _videoFrameSkip;
+ _videoDecoder->skipNumberOfFrames(framesToSkip);
+ } else {
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
}
- } else {
- _PlaySound(_emptySound);
}
+ } else {
+ playSound(_emptySound);
}
}
}
- if (_cur_scene == oldscene) {
- callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ if (_curScene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->_nxtfrm, scene);
}
- _DisplayLivesLeft();
- _DisplayScores();
- _DisplayShotsLeft();
- _MoveMouse();
+ displayLivesLeft();
+ displayScores();
+ displayShotsLeft();
+ moveMouse();
if (_pauseTime > 0) {
g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
} else {
@@ -375,13 +373,14 @@ Common::Error GameCrimePatrol::run() {
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
}
- int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ updateScreen();
+ int32 remainingMillis = _nextFrameTime - getMsTime();
if (remainingMillis < 10) {
if (_videoDecoder->getCurrentFrame() > 0) {
_videoDecoder->getNextFrame();
}
- remainingMillis = _nextFrameTime - _GetMsTime();
- _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ remainingMillis = _nextFrameTime - getMsTime();
+ _nextFrameTime = getMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
}
if (remainingMillis > 0) {
if (remainingMillis > 15) {
@@ -389,97 +388,93 @@ Common::Error GameCrimePatrol::run() {
}
g_system->delayMillis(remainingMillis);
}
- _currentFrame = _GetFrame(scene);
- debug_drawPracticeRects();
- updateScreen();
+ _currentFrame = getFrame(scene);
+ debugDrawPracticeRects();
}
// frame limit reached or scene changed, prepare for next scene
_hadPause = false;
_pauseTime = 0;
- if (_cur_scene == oldscene) {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ if (_curScene == oldscene) {
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
- if (_cur_scene == "") {
+ if (_curScene == "") {
_vm->quitGame();
}
}
return Common::kNoError;
}
-void GameCrimePatrol::_NewGame() {
+void GameCrimePatrol::newGame() {
_shots = 10;
_lives = 3;
_holster = false;
}
-void GameCrimePatrol::_ResetParams() {
- // fill _got_to with start scenes
- // 0 in _got_to array means the level is finished
- for (uint8 i = 0; i < 15; i++) {
- _got_to[i] = _level_scenes[i][0];
+void GameCrimePatrol::resetParams() {
+ // fill _gotTo with start scenes
+ // 0 in _gotTo array means the level is finished
+ for (int i = 0; i < 15; i++) {
+ _gotTo[i] = _levelScenes[i][0];
}
}
-void GameCrimePatrol::_DoMenu() {
- uint32 startTime = _GetMsTime();
- _RestoreCursor();
- _DoCursor();
+void GameCrimePatrol::doMenu() {
+ uint32 startTime = getMsTime();
+ updateCursor();
_inMenu = true;
- _MoveMouse();
+ moveMouse();
g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
- _ShowDifficulty(_difficulty, false);
+ showDifficulty(_difficulty, false);
while (_inMenu && !_vm->shouldQuit()) {
Common::Point firedCoords;
- if (__Fired(&firedCoords)) {
- Rect *hitMenuRect = _CheckZone(_submenzone, &firedCoords);
+ if (fired(&firedCoords)) {
+ Rect *hitMenuRect = checkZone(_submenzone, &firedCoords);
if (hitMenuRect != nullptr) {
- callScriptFunctionRectHit(hitMenuRect->rectHit, hitMenuRect);
+ callScriptFunctionRectHit(hitMenuRect->_rectHit, hitMenuRect);
}
}
if (_difficulty != _oldDifficulty) {
- _ChangeDifficulty(_difficulty);
+ changeDifficulty(_difficulty);
}
- g_system->delayMillis(15);
updateScreen();
+ g_system->delayMillis(15);
}
- _RestoreCursor();
- _DoCursor();
+ updateCursor();
g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
if (_hadPause) {
- unsigned long endTime = _GetMsTime();
- unsigned long timeDiff = endTime - startTime;
+ uint32 endTime = getMsTime();
+ uint32 timeDiff = endTime - startTime;
_pauseTime += timeDiff;
_nextFrameTime += timeDiff;
}
}
-void GameCrimePatrol::_ChangeDifficulty(uint8 newDifficulty) {
+void GameCrimePatrol::changeDifficulty(uint8 newDifficulty) {
if (newDifficulty == _oldDifficulty) {
return;
}
- _ShowDifficulty(newDifficulty, true);
+ showDifficulty(newDifficulty, true);
_oldDifficulty = newDifficulty;
_difficulty = newDifficulty;
}
-void GameCrimePatrol::_ShowDifficulty(uint8 newDifficulty, bool updateCursor) {
+void GameCrimePatrol::showDifficulty(uint8 newDifficulty, bool cursor) {
// reset menu screen
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
uint16 posY = 0x45 + ((newDifficulty - 1) * 0x21);
AlgGraphics::drawImageCentered(_screen, &_difficultyIcon, 0x0115, posY);
- if (updateCursor) {
- _DoCursor();
+ if (cursor) {
+ updateCursor();
}
}
-void GameCrimePatrol::_DoCursor() {
- _UpdateMouse();
+void GameCrimePatrol::updateCursor() {
+ updateMouse();
}
-void GameCrimePatrol::_UpdateMouse() {
+void GameCrimePatrol::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::PixelFormat pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
Graphics::Surface *cursor = &(*_gun)[_whichGun];
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 3;
@@ -488,13 +483,13 @@ void GameCrimePatrol::_UpdateMouse() {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0, false, &pixelFormat);
+ CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
}
-void GameCrimePatrol::_MoveMouse() {
+void GameCrimePatrol::moveMouse() {
if (_inMenu) {
_whichGun = 3; // in menu cursor
} else {
@@ -520,27 +515,27 @@ void GameCrimePatrol::_MoveMouse() {
_whichGun = 0; // regular gun
}
}
- _UpdateMouse();
+ updateMouse();
}
-void GameCrimePatrol::_DisplayLivesLeft() {
+void GameCrimePatrol::displayLivesLeft() {
if (_lives == _oldLives) {
return;
}
int posY = 0x67;
- for (uint8 i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
AlgGraphics::drawImage(_screen, &_deadIcon, 0x12F, posY);
posY += 0xE;
}
posY = 0x67;
- for (uint8 i = 0; i < _lives; i++) {
+ for (int i = 0; i < _lives; i++) {
AlgGraphics::drawImage(_screen, &_liveIcon, 0x12F, posY);
posY += 0xE;
}
_oldLives = _lives;
}
-void GameCrimePatrol::_DisplayScores() {
+void GameCrimePatrol::displayScores() {
if (_score == _oldScore) {
return;
}
@@ -554,42 +549,42 @@ void GameCrimePatrol::_DisplayScores() {
_oldScore = _score;
}
-void GameCrimePatrol::_DisplayShotsLeft() {
+void GameCrimePatrol::displayShotsLeft() {
if (_shots == _oldShots) {
return;
}
uint16 posX = 0xEE;
- for (uint8 i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBE);
posX += 5;
}
posX = 0xEE;
- for (uint8 i = 0; i < _shots; i++) {
+ for (int i = 0; i < _shots; i++) {
AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBE);
posX += 5;
}
_oldShots = _shots;
}
-bool GameCrimePatrol::_WeaponDown() {
+bool GameCrimePatrol::weaponDown() {
if (_rightDown && _mousePos.y >= 0xAA && _mousePos.x >= 0x113) {
return true;
}
return false;
}
-bool GameCrimePatrol::_SaveState() {
+bool GameCrimePatrol::saveState() {
Common::OutSaveFile *outSaveFile;
Common::String saveFileName = _vm->getSaveStateName(0);
if (!(outSaveFile = g_system->getSavefileManager()->openForSaving(saveFileName))) {
- warning("Can't create file '%s', game not saved", saveFileName.c_str());
+ warning("GameCrimePatrol::saveState(): Can't create file '%s', game not saved", saveFileName.c_str());
return false;
}
outSaveFile->writeUint32BE(MKTAG('A', 'L', 'G', 'S')); // header
outSaveFile->writeByte(0); // version, unused for now
outSaveFile->writeSByte(_stage);
- for (uint8 i = 0; i < 15; i++) {
- outSaveFile->writeUint16LE(_got_to[i]);
+ for (int i = 0; i < 15; i++) {
+ outSaveFile->writeUint16LE(_gotTo[i]);
}
outSaveFile->writeSint32LE(_score);
outSaveFile->writeUint16LE(_shots);
@@ -599,34 +594,34 @@ bool GameCrimePatrol::_SaveState() {
return true;
}
-bool GameCrimePatrol::_LoadState() {
+bool GameCrimePatrol::loadState() {
Common::InSaveFile *inSaveFile;
Common::String saveFileName = _vm->getSaveStateName(0);
if (!(inSaveFile = g_system->getSavefileManager()->openForLoading(saveFileName))) {
- debug("Can't load file '%s', game not loaded", saveFileName.c_str());
+ debug("GameCrimePatrol::loadState(): Can't load file '%s', game not loaded", saveFileName.c_str());
return false;
}
uint32 header = inSaveFile->readUint32BE();
if (header != MKTAG('A', 'L', 'G', 'S')) {
- warning("Unkown save file, header: %d", header);
+ warning("GameCrimePatrol::loadState(): Unkown save file, header: %s", tag2str(header));
return false;
}
inSaveFile->skip(1); // version, unused for now
_stage = inSaveFile->readSByte();
- for (uint8 i = 0; i < 15; i++) {
- _got_to[i] = inSaveFile->readUint16LE();
+ for (int i = 0; i < 15; i++) {
+ _gotTo[i] = inSaveFile->readUint16LE();
}
_score = inSaveFile->readSint32LE();
_shots = inSaveFile->readUint16LE();
_lives = inSaveFile->readSByte();
delete inSaveFile;
_gameInProgress = true;
- _scene_nxtscn_generic(_stage);
+ sceneNxtscnGeneric(_stage);
return true;
}
// misc game functions
-void GameCrimePatrol::_DisplayShotFiredImage(Common::Point *point) {
+void GameCrimePatrol::displayShotFiredImage(Common::Point *point) {
if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
@@ -634,15 +629,15 @@ void GameCrimePatrol::_DisplayShotFiredImage(Common::Point *point) {
}
}
-void GameCrimePatrol::_EnableVideoFadeIn() {
+void GameCrimePatrol::enableVideoFadeIn() {
// TODO implement
}
-uint16 GameCrimePatrol::_SceneToNumber(Scene *scene) {
- return atoi(scene->name.substr(5).c_str());
+uint16 GameCrimePatrol::sceneToNumber(Scene *scene) {
+ return atoi(scene->_name.substr(5).c_str());
}
-uint16 GameCrimePatrol::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
+uint16 GameCrimePatrol::randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
if (max == 1) {
return 0;
}
@@ -651,165 +646,165 @@ uint16 GameCrimePatrol::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude
if (*mask == fullMask) {
*mask = 0;
}
- uint16 random = 0;
+ uint16 randomNum = 0;
// find an unused random number
while (1) {
- random = _rnd->getRandomNumber(max - 1);
+ randomNum = _rnd->getRandomNumber(max - 1);
// check if bit is already used
- unsigned int bit = 1 << random;
- if (!((*mask & bit) || random == exclude)) {
+ uint16 bit = 1 << randomNum;
+ if (!((*mask & bit) || randomNum == exclude)) {
// set the bit in mask
*mask |= bit;
break;
}
}
- return random;
+ return randomNum;
}
-uint16 GameCrimePatrol::_PickRandomScene(uint8 index, uint8 max) {
+uint16 GameCrimePatrol::pickRandomScene(uint8 index, uint8 max) {
if (max != 0) {
- _random_max = max;
- _random_mask = 0;
- _random_picked = 0;
- _random_scene_count = 0;
- while (_level_scenes[index][_random_scene_count] != 0) {
- _random_scene_count++;
+ _randomMax = max;
+ _randomMask = 0;
+ _randomPicked = 0;
+ _randomSceneCount = 0;
+ while (_levelScenes[index][_randomSceneCount] != 0) {
+ _randomSceneCount++;
}
}
- unsigned short count = _random_max--;
+ uint16 count = _randomMax--;
if (count > 0) {
- _random_picked = _RandomUnusedInt(_random_scene_count, &_random_mask, _random_picked);
- return _level_scenes[index][_random_picked];
+ _randomPicked = randomUnusedInt(_randomSceneCount, &_randomMask, _randomPicked);
+ return _levelScenes[index][_randomPicked];
}
return 0;
}
-uint16 GameCrimePatrol::_PickDeathScene() {
- if (_stage != _old_stage) {
- _old_stage = _stage;
- _death_mask = 0;
- _death_picked = -1;
- _death_scene_count = 0;
- while (_died_scenes_by_stage[_stage][_death_scene_count] != 0) {
- _death_scene_count++;
+uint16 GameCrimePatrol::pickDeathScene() {
+ if (_stage != _oldStage) {
+ _oldStage = _stage;
+ _deathMask = 0;
+ _deathPicked = -1;
+ _deathSceneCount = 0;
+ while (_diedScenesByStage[_stage][_deathSceneCount] != 0) {
+ _deathSceneCount++;
}
}
- _death_picked = _RandomUnusedInt(_death_scene_count, &_death_mask, _death_picked);
- return _died_scenes_by_stage[_stage][_death_picked];
+ _deathPicked = randomUnusedInt(_deathSceneCount, &_deathMask, _deathPicked);
+ return _diedScenesByStage[_stage][_deathPicked];
}
-void GameCrimePatrol::_scene_nxtscn_generic(uint8 index) {
+void GameCrimePatrol::sceneNxtscnGeneric(uint8 index) {
uint16 nextSceneId = 0;
- _got_to[index] = 0;
- if (_got_to[0] || _got_to[1] || _got_to[3] || _got_to[2]) {
- nextSceneId = _stage_start_scenes[0];
- } else if (_got_to[4] || _got_to[5] || _got_to[6]) {
+ _gotTo[index] = 0;
+ if (_gotTo[0] || _gotTo[1] || _gotTo[3] || _gotTo[2]) {
+ nextSceneId = _stageStartScenes[0];
+ } else if (_gotTo[4] || _gotTo[5] || _gotTo[6]) {
if (_stage == 1) {
- nextSceneId = _stage_start_scenes[1];
+ nextSceneId = _stageStartScenes[1];
} else {
_stage = 1;
nextSceneId = 0x50;
}
- } else if (_got_to[7] || _got_to[8] || _got_to[9]) {
+ } else if (_gotTo[7] || _gotTo[8] || _gotTo[9]) {
if (_stage == 2) {
- nextSceneId = _stage_start_scenes[2];
+ nextSceneId = _stageStartScenes[2];
} else {
_stage = 2;
nextSceneId = 0x81;
}
- } else if (_got_to[10] || _got_to[11] || _got_to[12]) {
+ } else if (_gotTo[10] || _gotTo[11] || _gotTo[12]) {
if (_stage == 3) {
- nextSceneId = _stage_start_scenes[3];
+ nextSceneId = _stageStartScenes[3];
} else {
_stage = 3;
nextSceneId = 0x014B;
}
- } else if (_got_to[13]) {
+ } else if (_gotTo[13]) {
_stage = 4;
nextSceneId = 0x018F;
} else {
nextSceneId = 0x21;
}
- _cur_scene = Common::String::format("scene%d", nextSceneId);
+ _curScene = Common::String::format("scene%d", nextSceneId);
}
-void GameCrimePatrol::_rect_select_generic(uint8 index) {
- if (_got_to[index] > 0) {
- _cur_scene = Common::String::format("scene%d", _got_to[index]);
+void GameCrimePatrol::rectSelectGeneric(uint8 index) {
+ if (_gotTo[index] > 0) {
+ _curScene = Common::String::format("scene%d", _gotTo[index]);
}
}
-void GameCrimePatrol::_scene_iso_got_to_generic(uint8 index, uint16 sceneId) {
- _got_to[index] = sceneId;
+void GameCrimePatrol::sceneIsoGotToGeneric(uint8 index, uint16 sceneId) {
+ _gotTo[index] = sceneId;
}
// Script functions: RectHit
-void GameCrimePatrol::_rect_shotmenu(Rect *rect) {
- _DoMenu();
+void GameCrimePatrol::rectShotMenu(Rect *rect) {
+ doMenu();
}
-void GameCrimePatrol::_rect_save(Rect *rect) {
- if(_SaveState()) {
- _DoSaveSound();
+void GameCrimePatrol::rectSave(Rect *rect) {
+ if (saveState()) {
+ doSaveSound();
}
}
-void GameCrimePatrol::_rect_load(Rect *rect) {
- if(_LoadState()) {
- _DoLoadSound();
+void GameCrimePatrol::rectLoad(Rect *rect) {
+ if (loadState()) {
+ doLoadSound();
}
}
-void GameCrimePatrol::_rect_continue(Rect *rect) {
+void GameCrimePatrol::rectContinue(Rect *rect) {
_inMenu = false;
_fired = false;
if (_lives <= 0) {
_score = (int32)(_score * 0.7f);
- uint16 returnScene = _stage_start_scenes[_stage];
- _cur_scene = Common::String::format("scene%d", returnScene);
- _NewGame();
+ uint16 returnScene = _stageStartScenes[_stage];
+ _curScene = Common::String::format("scene%d", returnScene);
+ newGame();
}
}
-void GameCrimePatrol::_rect_start(Rect *rect) {
+void GameCrimePatrol::rectStart(Rect *rect) {
_inMenu = false;
_fired = false;
_gameInProgress = true;
if (_isDemo) {
- _cur_scene = "scene39";
- _got_to[1] = 39;
+ _curScene = "scene39";
+ _gotTo[1] = 39;
} else {
- _cur_scene = Common::String::format("scene%d", _stage_start_scenes[0]);
+ _curScene = Common::String::format("scene%d", _stageStartScenes[0]);
}
- _ResetParams();
- _NewGame();
+ resetParams();
+ newGame();
}
-void GameCrimePatrol::_rect_target_practice(Rect *rect) {
+void GameCrimePatrol::rectTargetPractice(Rect *rect) {
uint16 nextScene = 0;
- Scene *scene = _sceneInfo->findScene(_cur_scene);
- if (_level_scenes[0][0] == _SceneToNumber(scene)) {
- _practice_mask = 0x1F;
+ Scene *scene = _sceneInfo->findScene(_curScene);
+ if (_levelScenes[0][0] == sceneToNumber(scene)) {
+ _practiceMask = 0x1F;
}
- if (_practice_mask == 0) {
- _practice_mask = 0x1F;
+ if (_practiceMask == 0) {
+ _practiceMask = 0x1F;
}
- for (uint8 i = 0; i < 5; i++) {
- if (_mousePos.x <= _practice_target_left[i] || _mousePos.x >= _practice_target_right[i] ||
- _mousePos.y <= _practice_target_top[i] || _mousePos.y >= _practice_target_bottom[i]) {
+ for (int i = 0; i < 5; i++) {
+ if (_mousePos.x <= _practiceTargetLeft[i] || _mousePos.x >= _practiceTargetRight[i] ||
+ _mousePos.y <= _practiceTargetTop[i] || _mousePos.y >= _practiceTargetBottom[i]) {
// did not hit target
continue;
}
uint8 mask = 1 << i;
- if (!(_practice_mask & mask)) {
+ if (!(_practiceMask & mask)) {
// target was already hit before
continue;
}
// did hit target
- _score += scene->scnscrParam == 0 ? 50 : scene->scnscrParam;
- _practice_mask ^= mask;
- uint8 inverted = _practice_mask ^ 0x1F;
- if (_practice_mask == 0) {
+ _score += scene->_scnscrParam == 0 ? 50 : scene->_scnscrParam;
+ _practiceMask ^= mask;
+ uint8 inverted = _practiceMask ^ 0x1F;
+ if (_practiceMask == 0) {
nextScene = 432;
} else {
nextScene = 401 + inverted;
@@ -817,503 +812,503 @@ void GameCrimePatrol::_rect_target_practice(Rect *rect) {
break;
}
if (nextScene != 0) {
- _cur_scene = Common::String::format("scene%d", nextScene);
+ _curScene = Common::String::format("scene%d", nextScene);
}
}
-void GameCrimePatrol::_rect_select_target_practice(Rect *rect) {
- _rect_select_generic(0);
- _got_to[0] = 0;
+void GameCrimePatrol::rectSelectTargetPractice(Rect *rect) {
+ rectSelectGeneric(0);
+ _gotTo[0] = 0;
}
-void GameCrimePatrol::_rect_select_gang_fight(Rect *rect) {
- _got_to[0] = 0;
- _rect_select_generic(1);
+void GameCrimePatrol::rectSelectGangFight(Rect *rect) {
+ _gotTo[0] = 0;
+ rectSelectGeneric(1);
}
-void GameCrimePatrol::_rect_select_warehouse(Rect *rect) {
- _got_to[0] = 0;
- _rect_select_generic(2);
+void GameCrimePatrol::rectSelectWarehouse(Rect *rect) {
+ _gotTo[0] = 0;
+ rectSelectGeneric(2);
}
-void GameCrimePatrol::_rect_select_westcoast_sound(Rect *rect) {
- _got_to[0] = 0;
- _rect_select_generic(3);
+void GameCrimePatrol::rectSelectWestcoastSound(Rect *rect) {
+ _gotTo[0] = 0;
+ rectSelectGeneric(3);
}
-void GameCrimePatrol::_rect_select_drug_deal(Rect *rect) {
- _rect_select_generic(4);
+void GameCrimePatrol::rectSelectDrugDeal(Rect *rect) {
+ rectSelectGeneric(4);
}
-void GameCrimePatrol::_rect_select_car_ring(Rect *rect) {
- _rect_select_generic(5);
+void GameCrimePatrol::rectSelectCarRing(Rect *rect) {
+ rectSelectGeneric(5);
}
-void GameCrimePatrol::_rect_select_bar(Rect *rect) {
- _rect_select_generic(6);
+void GameCrimePatrol::rectSelectBar(Rect *rect) {
+ rectSelectGeneric(6);
}
-void GameCrimePatrol::_rect_select_bank(Rect *rect) {
- _rect_select_generic(7);
+void GameCrimePatrol::rectSelectBank(Rect *rect) {
+ rectSelectGeneric(7);
}
-void GameCrimePatrol::_rect_select_crack_house(Rect *rect) {
- _rect_select_generic(9);
+void GameCrimePatrol::rectSelectCrackHouse(Rect *rect) {
+ rectSelectGeneric(9);
}
-void GameCrimePatrol::_rect_select_meth_lab(Rect *rect) {
- _rect_select_generic(8);
+void GameCrimePatrol::rectSelectMethLab(Rect *rect) {
+ rectSelectGeneric(8);
}
-void GameCrimePatrol::_rect_select_airplane(Rect *rect) {
- _rect_select_generic(10);
+void GameCrimePatrol::rectSelectAirplane(Rect *rect) {
+ rectSelectGeneric(10);
}
-void GameCrimePatrol::_rect_select_nuke_transport(Rect *rect) {
- _rect_select_generic(11);
+void GameCrimePatrol::rectSelectNukeTransport(Rect *rect) {
+ rectSelectGeneric(11);
}
-void GameCrimePatrol::_rect_select_airport(Rect *rect) {
- _rect_select_generic(12);
+void GameCrimePatrol::rectSelectAirport(Rect *rect) {
+ rectSelectGeneric(12);
}
-void GameCrimePatrol::_rect_kill_innocent_man(Rect *rect) {
+void GameCrimePatrol::rectKillInnocentMan(Rect *rect) {
}
// Script functions: Scene PreOps
-void GameCrimePatrol::_scene_pso_warehouse_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(2, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoWarehouseGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(2, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_gang_fight_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(1, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoGangFightGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(1, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_westcoast_sound_got_to(Scene *scene) {
- _scene_iso_got_to_generic(3, 456);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoWestcoastSoundGotTo(Scene *scene) {
+ sceneIsoGotToGeneric(3, 456);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_drug_deal_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(4, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoDrugDealGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(4, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_car_ring_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(5, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoCarRingGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(5, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_bank_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(7, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoBankGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(7, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_crack_house_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(9, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoCrackHouseGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(9, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_meth_lab_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(8, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoMethLabGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(8, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_airplane_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(10, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoAirplaneGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(10, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_airport_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(12, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoAirportGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(12, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_nuke_transport_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(11, sceneId);
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoNukeTransportGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(11, sceneId);
+ enableVideoFadeIn();
}
-void GameCrimePatrol::_scene_pso_power_plant_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _scene_iso_got_to_generic(13, sceneId);
- _final_stage_scene = sceneId;
- _EnableVideoFadeIn();
+void GameCrimePatrol::scenePsoPowerPlantGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ sceneIsoGotToGeneric(13, sceneId);
+ _finalStageScene = sceneId;
+ enableVideoFadeIn();
}
// Script functions: Scene NxtScn
-void GameCrimePatrol::_scene_nxtscn_lose_a_life(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnLoseALife(Scene *scene) {
uint16 picked = 0;
if (!_debug_godMode) {
_lives--;
}
if (_isDemo) {
- _cur_scene = "scene39";
+ _curScene = "scene39";
return;
} else if (_lives > 0) {
- _DisplayLivesLeft();
- picked = _PickDeathScene();
+ displayLivesLeft();
+ picked = pickDeathScene();
} else {
- picked = _dead_scenes[_stage];
+ picked = _deadScenes[_stage];
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_game_won(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnGameWon(Scene *scene) {
_gameInProgress = false;
- _cur_scene = _startscene;
+ _curScene = _startScene;
}
-void GameCrimePatrol::_scene_nxtscn_did_not_continue(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnDidNotContinue(Scene *scene) {
_gameInProgress = false;
- _cur_scene = _startscene;
+ _curScene = _startScene;
}
-void GameCrimePatrol::_scene_nxtscn_kill_innocent_man(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnKillInnocentMan(Scene *scene) {
uint16 picked = 0;
if (!_debug_godMode) {
_lives--;
}
if (_lives > 0) {
- picked = _stage_start_scenes[_stage];
+ picked = _stageStartScenes[_stage];
} else {
- picked = _dead_scenes[_stage];
+ picked = _deadScenes[_stage];
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_kill_innocent_woman(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnKillInnocentWoman(Scene *scene) {
uint16 picked = 0;
if (!_debug_godMode) {
_lives--;
}
if (_lives > 0) {
- picked = _stage_start_scenes[_stage];
+ picked = _stageStartScenes[_stage];
} else {
- picked = _dead_scenes[_stage];
+ picked = _deadScenes[_stage];
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_after_die(Scene *scene) {
- uint16 picked = _stage_start_scenes[_stage];
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnAfterDie(Scene *scene) {
+ uint16 picked = _stageStartScenes[_stage];
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_select_language_1(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnSelectLanguage1(Scene *scene) {
// do nothing
}
-void GameCrimePatrol::_scene_nxtscn_select_language_2(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnSelectLanguage2(Scene *scene) {
// do nothing
}
-void GameCrimePatrol::_scene_nxtscn_init_random_target_practice(Scene *scene) {
- uint16 picked = _PickRandomScene(14, 6);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomTargetPractice(Scene *scene) {
+ uint16 picked = pickRandomScene(14, 6);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_target_practice(Scene *scene) {
- uint16 picked = _PickRandomScene(14, 0);
+void GameCrimePatrol::sceneNxtscnContinueTargetPractice(Scene *scene) {
+ uint16 picked = pickRandomScene(14, 0);
if (picked == 0) {
- _scene_iso_got_to_generic(0, 1);
- _scene_nxtscn_generic(0);
+ sceneIsoGotToGeneric(0, 1);
+ sceneNxtscnGeneric(0);
} else {
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
}
-void GameCrimePatrol::_scene_nxtscn_select_rookie_scenario(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnSelectRookieScenario(Scene *scene) {
uint16 picked = 0;
- if (_got_to[0] > 0) {
- picked = _got_to[0];
- _got_to[0] = 0;
- } else if (_got_to[3] > 0) {
- picked = _got_to[3];
- } else if (_got_to[1] > 0) {
- picked = _got_to[1];
- } else if (_got_to[2] > 0) {
- picked = _got_to[2];
+ if (_gotTo[0] > 0) {
+ picked = _gotTo[0];
+ _gotTo[0] = 0;
+ } else if (_gotTo[3] > 0) {
+ picked = _gotTo[3];
+ } else if (_gotTo[1] > 0) {
+ picked = _gotTo[1];
+ } else if (_gotTo[2] > 0) {
+ picked = _gotTo[2];
} else {
- picked = _stage_start_scenes[1];
+ picked = _stageStartScenes[1];
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_select_undercover_scenario(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnSelectUndercoverScenario(Scene *scene) {
uint16 picked = 0;
- if (_got_to[4] > 0) {
- picked = _got_to[4];
- } else if (_got_to[5] > 0) {
- picked = _got_to[5];
- } else if (_got_to[6] > 0) {
- picked = _got_to[6];
+ if (_gotTo[4] > 0) {
+ picked = _gotTo[4];
+ } else if (_gotTo[5] > 0) {
+ picked = _gotTo[5];
+ } else if (_gotTo[6] > 0) {
+ picked = _gotTo[6];
} else {
- picked = _stage_start_scenes[2];
+ picked = _stageStartScenes[2];
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_select_swat_scenario(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnSelectSwatScenario(Scene *scene) {
uint16 picked = 0;
- if (_got_to[8] > 0) {
- picked = _got_to[8];
- } else if (_got_to[7] > 0) {
- picked = _got_to[7];
- } else if (_got_to[9] > 0) {
- picked = _got_to[9];
+ if (_gotTo[8] > 0) {
+ picked = _gotTo[8];
+ } else if (_gotTo[7] > 0) {
+ picked = _gotTo[7];
+ } else if (_gotTo[9] > 0) {
+ picked = _gotTo[9];
} else {
- picked = _stage_start_scenes[3];
+ picked = _stageStartScenes[3];
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_select_delta_scenario(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnSelectDeltaScenario(Scene *scene) {
uint16 picked = 0;
- if (_got_to[10] > 0) {
- picked = _got_to[10];
- } else if (_got_to[11] > 0) {
- picked = _got_to[11];
- } else if (_got_to[12] > 0) {
- picked = _got_to[12];
+ if (_gotTo[10] > 0) {
+ picked = _gotTo[10];
+ } else if (_gotTo[11] > 0) {
+ picked = _gotTo[11];
+ } else if (_gotTo[12] > 0) {
+ picked = _gotTo[12];
} else {
- picked = _final_stage_scene;
+ picked = _finalStageScene;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_finish_gang_fight(Scene *scene) {
+void GameCrimePatrol::sceneNxtscnFinishGangFight(Scene *scene) {
if (_isDemo) {
- _cur_scene = _startscene;
+ _curScene = _startScene;
return;
}
- _scene_nxtscn_generic(1);
+ sceneNxtscnGeneric(1);
}
-void GameCrimePatrol::_scene_nxtscn_finish_westcoast_sound(Scene *scene) {
- _scene_nxtscn_generic(3);
+void GameCrimePatrol::sceneNxtscnFinishWestcoastSound(Scene *scene) {
+ sceneNxtscnGeneric(3);
}
-void GameCrimePatrol::_scene_nxtscn_finish_warehouse(Scene *scene) {
- _scene_nxtscn_generic(2);
+void GameCrimePatrol::sceneNxtscnFinishWarehouse(Scene *scene) {
+ sceneNxtscnGeneric(2);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_warehouse(Scene *scene) {
- uint16 picked = _PickRandomScene(15, (_difficulty * 2) + 5);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomWarehouse(Scene *scene) {
+ uint16 picked = pickRandomScene(15, (_difficulty * 2) + 5);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_warehouse(Scene *scene) {
- uint16 picked = _PickRandomScene(15, 0);
+void GameCrimePatrol::sceneNxtscnContinueWarehouse(Scene *scene) {
+ uint16 picked = pickRandomScene(15, 0);
if (picked == 0) {
picked = 0x43;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_finish_drug_deal(Scene *scene) {
- _scene_nxtscn_generic(4);
+void GameCrimePatrol::sceneNxtscnFinishDrugDeal(Scene *scene) {
+ sceneNxtscnGeneric(4);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_car_ring_leader(Scene *scene) {
- uint16 picked = _PickRandomScene(16, 2);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomCarRingLeader(Scene *scene) {
+ uint16 picked = pickRandomScene(16, 2);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_car_ring_leader_1(Scene *scene) {
- uint16 picked = _PickRandomScene(16, 0);
+void GameCrimePatrol::sceneNxtscnContinueCarRingLeader1(Scene *scene) {
+ uint16 picked = pickRandomScene(16, 0);
if (picked == 0) {
picked = 0x67;
} else {
picked = 0x63;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_car_ring_leader_2(Scene *scene) {
- uint16 picked = _PickRandomScene(16, 0);
+void GameCrimePatrol::sceneNxtscnContinueCarRingLeader2(Scene *scene) {
+ uint16 picked = pickRandomScene(16, 0);
if (picked == 0) {
picked = 0x67;
} else {
picked = 0x66;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_car_ring(Scene *scene) {
- uint16 picked = _PickRandomScene(17, (_difficulty * 2) + 8);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomCarRing(Scene *scene) {
+ uint16 picked = pickRandomScene(17, (_difficulty * 2) + 8);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_car_ring(Scene *scene) {
- uint16 picked = _PickRandomScene(17, 0);
+void GameCrimePatrol::sceneNxtscnContinueCarRing(Scene *scene) {
+ uint16 picked = pickRandomScene(17, 0);
if (picked == 0) {
picked = 0x74;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_finish_car_ring(Scene *scene) {
- _scene_nxtscn_generic(5);
+void GameCrimePatrol::sceneNxtscnFinishCarRing(Scene *scene) {
+ sceneNxtscnGeneric(5);
}
-void GameCrimePatrol::_scene_nxtscn_finish_bar(Scene *scene) {
- _scene_nxtscn_generic(6);
+void GameCrimePatrol::sceneNxtscnFinishBar(Scene *scene) {
+ sceneNxtscnGeneric(6);
}
-void GameCrimePatrol::_scene_nxtscn_finish_bank(Scene *scene) {
- _scene_nxtscn_generic(7);
+void GameCrimePatrol::sceneNxtscnFinishBank(Scene *scene) {
+ sceneNxtscnGeneric(7);
}
-void GameCrimePatrol::_scene_nxtscn_finish_crack_house(Scene *scene) {
- _scene_nxtscn_generic(9);
+void GameCrimePatrol::sceneNxtscnFinishCrackHouse(Scene *scene) {
+ sceneNxtscnGeneric(9);
}
-void GameCrimePatrol::_scene_nxtscn_finish_meth_lab(Scene *scene) {
- _scene_nxtscn_generic(8);
+void GameCrimePatrol::sceneNxtscnFinishMethLab(Scene *scene) {
+ sceneNxtscnGeneric(8);
}
-void GameCrimePatrol::_scene_nxtscn_finish_airplane(Scene *scene) {
- _scene_nxtscn_generic(10);
+void GameCrimePatrol::sceneNxtscnFinishAirplane(Scene *scene) {
+ sceneNxtscnGeneric(10);
}
-void GameCrimePatrol::_scene_nxtscn_finish_airport(Scene *scene) {
- _scene_nxtscn_generic(12);
+void GameCrimePatrol::sceneNxtscnFinishAirport(Scene *scene) {
+ sceneNxtscnGeneric(12);
}
-void GameCrimePatrol::_scene_nxtscn_finish_nuke_transport(Scene *scene) {
- _scene_nxtscn_generic(11);
+void GameCrimePatrol::sceneNxtscnFinishNukeTransport(Scene *scene) {
+ sceneNxtscnGeneric(11);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_bar(Scene *scene) {
- uint16 picked = _PickRandomScene(18, (_difficulty * 2) + 9);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomBar(Scene *scene) {
+ uint16 picked = pickRandomScene(18, (_difficulty * 2) + 9);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_bar(Scene *scene) {
- uint16 picked = _PickRandomScene(18, 0);
+void GameCrimePatrol::sceneNxtscnContinueBar(Scene *scene) {
+ uint16 picked = pickRandomScene(18, 0);
if (picked == 0) {
picked = 0x92;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_bank(Scene *scene) {
- uint16 picked = _PickRandomScene(19, (_difficulty * 2) + 8);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomBank(Scene *scene) {
+ uint16 picked = pickRandomScene(19, (_difficulty * 2) + 8);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_bank(Scene *scene) {
- uint16 picked = _PickRandomScene(19, 0);
+void GameCrimePatrol::sceneNxtscnContinueBank(Scene *scene) {
+ uint16 picked = pickRandomScene(19, 0);
if (picked == 0) {
picked = 0xA8;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_meth_lab(Scene *scene) {
- uint16 picked = _PickRandomScene(20, (_difficulty * 2) + 8);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomMethLab(Scene *scene) {
+ uint16 picked = pickRandomScene(20, (_difficulty * 2) + 8);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_meth_lab(Scene *scene) {
- uint16 picked = _PickRandomScene(20, 0);
+void GameCrimePatrol::sceneNxtscnContinueMethLab(Scene *scene) {
+ uint16 picked = pickRandomScene(20, 0);
if (picked == 0) {
picked = 0xD0;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_pick_random_rapeller(Scene *scene) {
- uint16 picked = _PickRandomScene(21, 1);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnPickRandomRapeller(Scene *scene) {
+ uint16 picked = pickRandomScene(21, 1);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_airplane(Scene *scene) {
- uint16 picked = _PickRandomScene(22, (_difficulty * 2) + 8);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomAirplane(Scene *scene) {
+ uint16 picked = pickRandomScene(22, (_difficulty * 2) + 8);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_airplane(Scene *scene) {
- uint16 picked = _PickRandomScene(22, 0);
+void GameCrimePatrol::sceneNxtscnContinueAirplane(Scene *scene) {
+ uint16 picked = pickRandomScene(22, 0);
if (picked == 0) {
picked = 0x108;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_pick_random_airplane_front(Scene *scene) {
- uint16 picked = _PickRandomScene(23, 1);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnPickRandomAirplaneFront(Scene *scene) {
+ uint16 picked = pickRandomScene(23, 1);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_airport(Scene *scene) {
- uint16 picked = _PickRandomScene(24, (_difficulty * 2) + 8);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomAirport(Scene *scene) {
+ uint16 picked = pickRandomScene(24, (_difficulty * 2) + 8);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_airport(Scene *scene) {
- uint16 picked = _PickRandomScene(24, 0);
+void GameCrimePatrol::sceneNxtscnContinueAirport(Scene *scene) {
+ uint16 picked = pickRandomScene(24, 0);
if (picked == 0) {
picked = 0x12D;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_nuke_transport(Scene *scene) {
- uint16 picked = _PickRandomScene(25, (_difficulty * 2) + 8);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomNukeTransport(Scene *scene) {
+ uint16 picked = pickRandomScene(25, (_difficulty * 2) + 8);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_nuke_transport(Scene *scene) {
- uint16 picked = _PickRandomScene(25, 0);
+void GameCrimePatrol::sceneNxtscnContinueNukeTransport(Scene *scene) {
+ uint16 picked = pickRandomScene(25, 0);
if (picked == 0) {
picked = 0x147;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_init_random_powerplant(Scene *scene) {
- uint16 picked = _PickRandomScene(26, (_difficulty * 2) + 8);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameCrimePatrol::sceneNxtscnInitRandomPowerplant(Scene *scene) {
+ uint16 picked = pickRandomScene(26, (_difficulty * 2) + 8);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameCrimePatrol::_scene_nxtscn_continue_powerplant(Scene *scene) {
- uint16 picked = _PickRandomScene(26, 0);
+void GameCrimePatrol::sceneNxtscnContinuePowerplant(Scene *scene) {
+ uint16 picked = pickRandomScene(26, 0);
if (picked == 0) {
picked = 0x169;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
// Script functions: WepDwn
-void GameCrimePatrol::_scene_default_wepdwn(Scene *scene) {
+void GameCrimePatrol::sceneDefaultWepdwn(Scene *scene) {
_shots = 10;
}
// Debug methods
-void GameCrimePatrol::debug_warpTo(int val) {
+void GameCrimePatrol::debugWarpTo(int val) {
// TODO implement
}
-void GameCrimePatrol::debug_drawPracticeRects() {
+void GameCrimePatrol::debugDrawPracticeRects() {
if (_debug_drawRects || debugChannelSet(1, Alg::kAlgDebugGraphics)) {
- Scene *scene = _sceneInfo->findScene(_cur_scene);
- if (scene->zones.size() > 0) {
- if (scene->zones[0]->name == "zone283") {
- for (uint8 i = 0; i < 5; i++) {
- uint16 left = _practice_target_left[i] - _videoPosX;
- uint16 right = _practice_target_right[i] - _videoPosX;
- uint16 top = _practice_target_top[i] - _videoPosY;
- uint16 bottom = _practice_target_bottom[i] - _videoPosY;
+ Scene *scene = _sceneInfo->findScene(_curScene);
+ if (scene->_zones.size() > 0) {
+ if (scene->_zones[0]->_name == "zone283") {
+ for (int i = 0; i < 5; i++) {
+ uint16 left = _practiceTargetLeft[i] - _videoPosX;
+ uint16 right = _practiceTargetRight[i] - _videoPosX;
+ uint16 top = _practiceTargetTop[i] - _videoPosY;
+ uint16 bottom = _practiceTargetBottom[i] - _videoPosY;
_videoDecoder->getVideoFrame()->drawLine(left, top, right, top, 1);
_videoDecoder->getVideoFrame()->drawLine(left, top, left, bottom, 1);
_videoDecoder->getVideoFrame()->drawLine(right, bottom, right, top, 1);
@@ -1340,7 +1335,7 @@ bool DebuggerCrimePatrol::cmdWarpTo(int argc, const char **argv) {
return true;
} else {
int val = atoi(argv[1]);
- _game->debug_warpTo(val);
+ _game->debugWarpTo(val);
return false;
}
}
diff --git a/engines/alg/game_crimepatrol.h b/engines/alg/game_crimepatrol.h
index a85389cc3b8..119cf2477ac 100644
--- a/engines/alg/game_crimepatrol.h
+++ b/engines/alg/game_crimepatrol.h
@@ -50,10 +50,10 @@ class GameCrimePatrol : public Game {
};
public:
- GameCrimePatrol(AlgEngine *vm, const ADGameDescription *desc);
+ GameCrimePatrol(AlgEngine *vm, const AlgGameDescription *gd);
~GameCrimePatrol();
Common::Error run();
- void debug_warpTo(int val);
+ void debugWarpTo(int val);
private:
void init();
@@ -82,189 +82,189 @@ private:
Graphics::Surface _bulletholeIcon;
// constants
- const int16 _scenes_level0[2] = {0x0191, 0};
- const int16 _scenes_level1[3] = {0x27, 0x01B7, 0};
- const int16 _scenes_level2[4] = {0x33, 0x01C7, 0x01B8, 0};
- const int16 _scenes_level3[3] = {0x48, 0x01C8, 0};
- const int16 _scenes_level4[2] = {0x53, 0};
- const int16 _scenes_level5[2] = {0x60, 0};
- const int16 _scenes_level6[2] = {0x82, 0};
- const int16 _scenes_level7[2] = {0x9B, 0};
- const int16 _scenes_level8[2] = {0xC7, 0};
- const int16 _scenes_level9[2] = {0xB6, 0};
- const int16 _scenes_level10[6] = {0xE0, 0x01BF, 0x01C0, 0x01C1, 0x01C2, 0};
- const int16 _scenes_level11[3] = {0x0136, 0x01C3, 0};
- const int16 _scenes_level12[4] = {0x0119, 0x01C5, 0x0131, 0};
- const int16 _scenes_level13[2] = {0x014C, 0};
- const int16 _scenes_level14[13] = {0x01B1, 0x01B2, 0x01B3, 0x01B4, 0x01B5, 0x01B6, 0};
- const int16 _scenes_level15[5] = {0x3B, 0x3C, 0x3F, 0x41, 0};
- const int16 _scenes_level16[3] = {0x61, 0x65, 0};
- const int16 _scenes_level17[7] = {0x68, 0x6A, 0x6C, 0x6E, 0x70, 0x72, 0};
- const int16 _scenes_level18[8] = {0x83, 0x85, 0x87, 0x8A, 0x8C, 0x8F, 0x90, 0};
- const int16 _scenes_level19[7] = {0x9C, 0x9E, 0xA0, 0xA2, 0xA4, 0xA6, 0};
- const int16 _scenes_level20[5] = {0xC8, 0xCA, 0xCC, 0xCE, 0};
- const int16 _scenes_level21[3] = {0xE8, 0xE9, 0};
- const int16 _scenes_level22[11] = {0xF4, 0xF6, 0xF8, 0xFA, 0xFC, 0xFE, 0x0100, 0x0102, 0x0104, 0x0106, 0};
- const int16 _scenes_level23[3] = {0x010E, 0x0113, 0};
- const int16 _scenes_level24[8] = {0x011D, 0x011F, 0x0121, 0x0123, 0x0125, 0x0127, 0x0129, 0};
- const int16 _scenes_level25[6] = {0x013D, 0x013F, 0x0141, 0x0143, 0x0145, 0};
- const int16 _scenes_level26[10] = {0x0157, 0x0159, 0x015B, 0x015D, 0x015F, 0x0161, 0x0163, 0x0165, 0x0167, 0};
+ const int16 _scenesLevel0[2] = {0x0191, 0};
+ const int16 _scenesLevel1[3] = {0x27, 0x01B7, 0};
+ const int16 _scenesLevel2[4] = {0x33, 0x01C7, 0x01B8, 0};
+ const int16 _scenesLevel3[3] = {0x48, 0x01C8, 0};
+ const int16 _scenesLevel4[2] = {0x53, 0};
+ const int16 _scenesLevel5[2] = {0x60, 0};
+ const int16 _scenesLevel6[2] = {0x82, 0};
+ const int16 _scenesLevel7[2] = {0x9B, 0};
+ const int16 _scenesLevel8[2] = {0xC7, 0};
+ const int16 _scenesLevel9[2] = {0xB6, 0};
+ const int16 _scenesLevel10[6] = {0xE0, 0x01BF, 0x01C0, 0x01C1, 0x01C2, 0};
+ const int16 _scenesLevel11[3] = {0x0136, 0x01C3, 0};
+ const int16 _scenesLevel12[4] = {0x0119, 0x01C5, 0x0131, 0};
+ const int16 _scenesLevel13[2] = {0x014C, 0};
+ const int16 _scenesLevel14[13] = {0x01B1, 0x01B2, 0x01B3, 0x01B4, 0x01B5, 0x01B6, 0};
+ const int16 _scenesLevel15[5] = {0x3B, 0x3C, 0x3F, 0x41, 0};
+ const int16 _scenesLevel16[3] = {0x61, 0x65, 0};
+ const int16 _scenesLevel17[7] = {0x68, 0x6A, 0x6C, 0x6E, 0x70, 0x72, 0};
+ const int16 _scenesLevel18[8] = {0x83, 0x85, 0x87, 0x8A, 0x8C, 0x8F, 0x90, 0};
+ const int16 _scenesLevel19[7] = {0x9C, 0x9E, 0xA0, 0xA2, 0xA4, 0xA6, 0};
+ const int16 _scenesLevel20[5] = {0xC8, 0xCA, 0xCC, 0xCE, 0};
+ const int16 _scenesLevel21[3] = {0xE8, 0xE9, 0};
+ const int16 _scenesLevel22[11] = {0xF4, 0xF6, 0xF8, 0xFA, 0xFC, 0xFE, 0x0100, 0x0102, 0x0104, 0x0106, 0};
+ const int16 _scenesLevel23[3] = {0x010E, 0x0113, 0};
+ const int16 _scenesLevel24[8] = {0x011D, 0x011F, 0x0121, 0x0123, 0x0125, 0x0127, 0x0129, 0};
+ const int16 _scenesLevel25[6] = {0x013D, 0x013F, 0x0141, 0x0143, 0x0145, 0};
+ const int16 _scenesLevel26[10] = {0x0157, 0x0159, 0x015B, 0x015D, 0x015F, 0x0161, 0x0163, 0x0165, 0x0167, 0};
- const int16 *_level_scenes[27] = {_scenes_level0, _scenes_level1, _scenes_level2, _scenes_level3, _scenes_level4, _scenes_level5, _scenes_level6,
- _scenes_level7, _scenes_level8, _scenes_level9, _scenes_level10, _scenes_level11, _scenes_level12, _scenes_level13,
- _scenes_level14, _scenes_level15, _scenes_level16, _scenes_level17, _scenes_level18, _scenes_level19, _scenes_level20,
- _scenes_level21, _scenes_level22, _scenes_level23, _scenes_level24, _scenes_level25, _scenes_level26};
+ const int16 *_levelScenes[27] = {_scenesLevel0, _scenesLevel1, _scenesLevel2, _scenesLevel3, _scenesLevel4, _scenesLevel5, _scenesLevel6,
+ _scenesLevel7, _scenesLevel8, _scenesLevel9, _scenesLevel10, _scenesLevel11, _scenesLevel12, _scenesLevel13,
+ _scenesLevel14, _scenesLevel15, _scenesLevel16, _scenesLevel17, _scenesLevel18, _scenesLevel19, _scenesLevel20,
+ _scenesLevel21, _scenesLevel22, _scenesLevel23, _scenesLevel24, _scenesLevel25, _scenesLevel26};
- const int16 _died_scenes_stage0[5] = {0x30, 0x31, 0x47, 0x51, 0};
- const int16 _died_scenes_stage1[7] = {0x5E, 0x5F, 0x7E, 0x7F, 0x98, 0x99, 0};
- const int16 _died_scenes_stage2[4] = {0xB2, 0xC5, 0xDB, 0};
- const int16 _died_scenes_stage3[7] = {0x0115, 0x0116, 0x0135, 0x014A, 0x0175, 0x0190, 0};
- const int16 _died_scenes_stage4[7] = {0x0115, 0x0116, 0x0135, 0x014A, 0x0175, 0x0190, 0};
+ const int16 _diedScenesStage0[5] = {0x30, 0x31, 0x47, 0x51, 0};
+ const int16 _diedScenesStage1[7] = {0x5E, 0x5F, 0x7E, 0x7F, 0x98, 0x99, 0};
+ const int16 _diedScenesStage2[4] = {0xB2, 0xC5, 0xDB, 0};
+ const int16 _diedScenesStage3[7] = {0x0115, 0x0116, 0x0135, 0x014A, 0x0175, 0x0190, 0};
+ const int16 _diedScenesStage4[7] = {0x0115, 0x0116, 0x0135, 0x014A, 0x0175, 0x0190, 0};
- const int16 *_died_scenes_by_stage[5] = {_died_scenes_stage0, _died_scenes_stage1, _died_scenes_stage2, _died_scenes_stage3, _died_scenes_stage4};
+ const int16 *_diedScenesByStage[5] = {_diedScenesStage0, _diedScenesStage1, _diedScenesStage2, _diedScenesStage3, _diedScenesStage4};
- const uint16 _dead_scenes[5] = {0x32, 0x80, 0xDC, 0x018D, 0x018D};
+ const uint16 _deadScenes[5] = {0x32, 0x80, 0xDC, 0x018D, 0x018D};
- const uint16 _stage_start_scenes[5] = {0x26, 0x52, 0x9A, 0xDF, 0x014C};
+ const uint16 _stageStartScenes[5] = {0x26, 0x52, 0x9A, 0xDF, 0x014C};
- const int16 _practice_target_left[5] = {0xE1, 0x45, 0xA8, 0x73, 0xE1};
- const int16 _practice_target_top[5] = {0x0A, 0x3E, 0x41, 0x6E, 0x6E};
- const int16 _practice_target_right[5] = {0x0104, 0x6D, 0xCB, 0x95, 0x0104};
- const int16 _practice_target_bottom[5] = {0x3D, 0x79, 0x7B, 0xA1, 0xA1};
+ const int16 _practiceTargetLeft[5] = {0xE1, 0x45, 0xA8, 0x73, 0xE1};
+ const int16 _practiceTargetTop[5] = {0x0A, 0x3E, 0x41, 0x6E, 0x6E};
+ const int16 _practiceTargetRight[5] = {0x0104, 0x6D, 0xCB, 0x95, 0x0104};
+ const int16 _practiceTargetBottom[5] = {0x3D, 0x79, 0x7B, 0xA1, 0xA1};
bool _isDemo = 0;
// gamestate
- uint16 _got_to[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ uint16 _gotTo[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int8 _stage = 0;
- int8 _old_stage = -1;
- uint8 _random_scene_count = 0;
- uint8 _random_max = 0;
- uint16 _random_mask = 0;
- uint16 _random_picked = 0;
- uint16 _death_mask = 0;
- int16 _death_picked = 0;
- uint8 _death_scene_count = 0;
- uint8 _practice_mask = 0;
- uint16 _final_stage_scene = _stage_start_scenes[4];
+ int8 _oldStage = -1;
+ uint8 _randomSceneCount = 0;
+ uint8 _randomMax = 0;
+ uint16 _randomMask = 0;
+ uint16 _randomPicked = 0;
+ uint16 _deathMask = 0;
+ int16 _deathPicked = 0;
+ uint8 _deathSceneCount = 0;
+ uint8 _practiceMask = 0;
+ uint16 _finalStageScene = _stageStartScenes[4];
// base functions
- void _NewGame();
- void _ResetParams();
- void _DoMenu();
- void _ChangeDifficulty(uint8 newDifficulty);
- void _ShowDifficulty(uint8 newDifficulty, bool updateCursor);
- void _DoCursor();
- void _UpdateMouse();
- void _MoveMouse();
- void _DisplayLivesLeft();
- void _DisplayScores();
- void _DisplayShotsLeft();
- bool _WeaponDown();
- bool _SaveState();
- bool _LoadState();
+ void newGame();
+ void resetParams();
+ void doMenu();
+ void changeDifficulty(uint8 newDifficulty);
+ void showDifficulty(uint8 newDifficulty, bool updateCursor);
+ void updateCursor();
+ void updateMouse();
+ void moveMouse();
+ void displayLivesLeft();
+ void displayScores();
+ void displayShotsLeft();
+ bool weaponDown();
+ bool saveState();
+ bool loadState();
// misc game functions
- void _DisplayShotFiredImage(Common::Point *point);
- void _EnableVideoFadeIn();
- uint16 _SceneToNumber(Scene *scene);
- uint16 _RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
- uint16 _PickRandomScene(uint8 index, uint8 max);
- uint16 _PickDeathScene();
- void _scene_nxtscn_generic(uint8 index);
- void _rect_select_generic(uint8 index);
- void _scene_iso_got_to_generic(uint8 index, uint16 sceneId);
+ void displayShotFiredImage(Common::Point *point);
+ void enableVideoFadeIn();
+ uint16 sceneToNumber(Scene *scene);
+ uint16 randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
+ uint16 pickRandomScene(uint8 index, uint8 max);
+ uint16 pickDeathScene();
+ void sceneNxtscnGeneric(uint8 index);
+ void rectSelectGeneric(uint8 index);
+ void sceneIsoGotToGeneric(uint8 index, uint16 sceneId);
// Script functions: RectHit
- void _rect_shotmenu(Rect *rect);
- void _rect_save(Rect *rect);
- void _rect_load(Rect *rect);
- void _rect_continue(Rect *rect);
- void _rect_start(Rect *rect);
- void _rect_target_practice(Rect *rect);
- void _rect_select_target_practice(Rect *rect);
- void _rect_select_gang_fight(Rect *rect);
- void _rect_select_warehouse(Rect *rect);
- void _rect_select_westcoast_sound(Rect *rect);
- void _rect_select_drug_deal(Rect *rect);
- void _rect_select_car_ring(Rect *rect);
- void _rect_select_bar(Rect *rect);
- void _rect_select_bank(Rect *rect);
- void _rect_select_crack_house(Rect *rect);
- void _rect_select_meth_lab(Rect *rect);
- void _rect_select_airplane(Rect *rect);
- void _rect_select_nuke_transport(Rect *rect);
- void _rect_select_airport(Rect *rect);
- void _rect_kill_innocent_man(Rect *rect);
+ void rectShotMenu(Rect *rect);
+ void rectSave(Rect *rect);
+ void rectLoad(Rect *rect);
+ void rectContinue(Rect *rect);
+ void rectStart(Rect *rect);
+ void rectTargetPractice(Rect *rect);
+ void rectSelectTargetPractice(Rect *rect);
+ void rectSelectGangFight(Rect *rect);
+ void rectSelectWarehouse(Rect *rect);
+ void rectSelectWestcoastSound(Rect *rect);
+ void rectSelectDrugDeal(Rect *rect);
+ void rectSelectCarRing(Rect *rect);
+ void rectSelectBar(Rect *rect);
+ void rectSelectBank(Rect *rect);
+ void rectSelectCrackHouse(Rect *rect);
+ void rectSelectMethLab(Rect *rect);
+ void rectSelectAirplane(Rect *rect);
+ void rectSelectNukeTransport(Rect *rect);
+ void rectSelectAirport(Rect *rect);
+ void rectKillInnocentMan(Rect *rect);
// Script functions: Scene PreOps
- void _scene_pso_warehouse_got_to(Scene *scene);
- void _scene_pso_gang_fight_got_to(Scene *scene);
- void _scene_pso_westcoast_sound_got_to(Scene *scene);
- void _scene_pso_drug_deal_got_to(Scene *scene);
- void _scene_pso_car_ring_got_to(Scene *scene);
- void _scene_pso_bank_got_to(Scene *scene);
- void _scene_pso_crack_house_got_to(Scene *scene);
- void _scene_pso_meth_lab_got_to(Scene *scene);
- void _scene_pso_airplane_got_to(Scene *scene);
- void _scene_pso_airport_got_to(Scene *scene);
- void _scene_pso_nuke_transport_got_to(Scene *scene);
- void _scene_pso_power_plant_got_to(Scene *scene);
+ void scenePsoWarehouseGotTo(Scene *scene);
+ void scenePsoGangFightGotTo(Scene *scene);
+ void scenePsoWestcoastSoundGotTo(Scene *scene);
+ void scenePsoDrugDealGotTo(Scene *scene);
+ void scenePsoCarRingGotTo(Scene *scene);
+ void scenePsoBankGotTo(Scene *scene);
+ void scenePsoCrackHouseGotTo(Scene *scene);
+ void scenePsoMethLabGotTo(Scene *scene);
+ void scenePsoAirplaneGotTo(Scene *scene);
+ void scenePsoAirportGotTo(Scene *scene);
+ void scenePsoNukeTransportGotTo(Scene *scene);
+ void scenePsoPowerPlantGotTo(Scene *scene);
// Script functions: Scene NxtScn
- void _scene_nxtscn_game_won(Scene *scene);
- void _scene_nxtscn_lose_a_life(Scene *scene);
- void _scene_nxtscn_did_not_continue(Scene *scene);
- void _scene_nxtscn_kill_innocent_man(Scene *scene);
- void _scene_nxtscn_kill_innocent_woman(Scene *scene);
- void _scene_nxtscn_after_die(Scene *scene);
- void _scene_nxtscn_select_language_1(Scene *scene);
- void _scene_nxtscn_select_language_2(Scene *scene);
- void _scene_nxtscn_select_rookie_scenario(Scene *scene);
- void _scene_nxtscn_select_undercover_scenario(Scene *scene);
- void _scene_nxtscn_select_swat_scenario(Scene *scene);
- void _scene_nxtscn_select_delta_scenario(Scene *scene);
- void _scene_nxtscn_init_random_target_practice(Scene *scene);
- void _scene_nxtscn_continue_target_practice(Scene *scene);
- void _scene_nxtscn_finish_gang_fight(Scene *scene);
- void _scene_nxtscn_finish_westcoast_sound(Scene *scene);
- void _scene_nxtscn_finish_warehouse(Scene *scene);
- void _scene_nxtscn_init_random_warehouse(Scene *scene);
- void _scene_nxtscn_continue_warehouse(Scene *scene);
- void _scene_nxtscn_finish_drug_deal(Scene *scene);
- void _scene_nxtscn_init_random_car_ring_leader(Scene *scene);
- void _scene_nxtscn_continue_car_ring_leader_1(Scene *scene);
- void _scene_nxtscn_continue_car_ring_leader_2(Scene *scene);
- void _scene_nxtscn_init_random_car_ring(Scene *scene);
- void _scene_nxtscn_continue_car_ring(Scene *scene);
- void _scene_nxtscn_finish_car_ring(Scene *scene);
- void _scene_nxtscn_finish_bar(Scene *scene);
- void _scene_nxtscn_finish_bank(Scene *scene);
- void _scene_nxtscn_finish_crack_house(Scene *scene);
- void _scene_nxtscn_finish_meth_lab(Scene *scene);
- void _scene_nxtscn_finish_airplane(Scene *scene);
- void _scene_nxtscn_finish_airport(Scene *scene);
- void _scene_nxtscn_finish_nuke_transport(Scene *scene);
- void _scene_nxtscn_init_random_bar(Scene *scene);
- void _scene_nxtscn_continue_bar(Scene *scene);
- void _scene_nxtscn_init_random_bank(Scene *scene);
- void _scene_nxtscn_continue_bank(Scene *scene);
- void _scene_nxtscn_init_random_meth_lab(Scene *scene);
- void _scene_nxtscn_continue_meth_lab(Scene *scene);
- void _scene_nxtscn_pick_random_rapeller(Scene *scene);
- void _scene_nxtscn_init_random_airplane(Scene *scene);
- void _scene_nxtscn_continue_airplane(Scene *scene);
- void _scene_nxtscn_pick_random_airplane_front(Scene *scene);
- void _scene_nxtscn_init_random_airport(Scene *scene);
- void _scene_nxtscn_continue_airport(Scene *scene);
- void _scene_nxtscn_init_random_nuke_transport(Scene *scene);
- void _scene_nxtscn_continue_nuke_transport(Scene *scene);
- void _scene_nxtscn_init_random_powerplant(Scene *scene);
- void _scene_nxtscn_continue_powerplant(Scene *scene);
+ void sceneNxtscnGameWon(Scene *scene);
+ void sceneNxtscnLoseALife(Scene *scene);
+ void sceneNxtscnDidNotContinue(Scene *scene);
+ void sceneNxtscnKillInnocentMan(Scene *scene);
+ void sceneNxtscnKillInnocentWoman(Scene *scene);
+ void sceneNxtscnAfterDie(Scene *scene);
+ void sceneNxtscnSelectLanguage1(Scene *scene);
+ void sceneNxtscnSelectLanguage2(Scene *scene);
+ void sceneNxtscnSelectRookieScenario(Scene *scene);
+ void sceneNxtscnSelectUndercoverScenario(Scene *scene);
+ void sceneNxtscnSelectSwatScenario(Scene *scene);
+ void sceneNxtscnSelectDeltaScenario(Scene *scene);
+ void sceneNxtscnInitRandomTargetPractice(Scene *scene);
+ void sceneNxtscnContinueTargetPractice(Scene *scene);
+ void sceneNxtscnFinishGangFight(Scene *scene);
+ void sceneNxtscnFinishWestcoastSound(Scene *scene);
+ void sceneNxtscnFinishWarehouse(Scene *scene);
+ void sceneNxtscnInitRandomWarehouse(Scene *scene);
+ void sceneNxtscnContinueWarehouse(Scene *scene);
+ void sceneNxtscnFinishDrugDeal(Scene *scene);
+ void sceneNxtscnInitRandomCarRingLeader(Scene *scene);
+ void sceneNxtscnContinueCarRingLeader1(Scene *scene);
+ void sceneNxtscnContinueCarRingLeader2(Scene *scene);
+ void sceneNxtscnInitRandomCarRing(Scene *scene);
+ void sceneNxtscnContinueCarRing(Scene *scene);
+ void sceneNxtscnFinishCarRing(Scene *scene);
+ void sceneNxtscnFinishBar(Scene *scene);
+ void sceneNxtscnFinishBank(Scene *scene);
+ void sceneNxtscnFinishCrackHouse(Scene *scene);
+ void sceneNxtscnFinishMethLab(Scene *scene);
+ void sceneNxtscnFinishAirplane(Scene *scene);
+ void sceneNxtscnFinishAirport(Scene *scene);
+ void sceneNxtscnFinishNukeTransport(Scene *scene);
+ void sceneNxtscnInitRandomBar(Scene *scene);
+ void sceneNxtscnContinueBar(Scene *scene);
+ void sceneNxtscnInitRandomBank(Scene *scene);
+ void sceneNxtscnContinueBank(Scene *scene);
+ void sceneNxtscnInitRandomMethLab(Scene *scene);
+ void sceneNxtscnContinueMethLab(Scene *scene);
+ void sceneNxtscnPickRandomRapeller(Scene *scene);
+ void sceneNxtscnInitRandomAirplane(Scene *scene);
+ void sceneNxtscnContinueAirplane(Scene *scene);
+ void sceneNxtscnPickRandomAirplaneFront(Scene *scene);
+ void sceneNxtscnInitRandomAirport(Scene *scene);
+ void sceneNxtscnContinueAirport(Scene *scene);
+ void sceneNxtscnInitRandomNukeTransport(Scene *scene);
+ void sceneNxtscnContinueNukeTransport(Scene *scene);
+ void sceneNxtscnInitRandomPowerplant(Scene *scene);
+ void sceneNxtscnContinuePowerplant(Scene *scene);
// Script functions: Scene WepDwn
- void _scene_default_wepdwn(Scene *scene);
- void debug_drawPracticeRects();
+ void sceneDefaultWepdwn(Scene *scene);
+ void debugDrawPracticeRects();
};
class DebuggerCrimePatrol : public GUI::Debugger {
diff --git a/engines/alg/game_drugwars.cpp b/engines/alg/game_drugwars.cpp
index 740024c4c49..7830bf832ec 100644
--- a/engines/alg/game_drugwars.cpp
+++ b/engines/alg/game_drugwars.cpp
@@ -25,7 +25,6 @@
#include "common/system.h"
#include "graphics/cursorman.h"
-#include "graphics/pixelformat.h"
#include "alg/game_drugwars.h"
#include "alg/graphics.h"
@@ -33,12 +32,12 @@
namespace Alg {
-GameDrugWars::GameDrugWars(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
- if (scumm_stricmp(desc->gameId, "dwarss") == 0) {
+GameDrugWars::GameDrugWars(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
+ if (gd->gameType == GType_DWARS_SS_DOS) {
_libFileName = "dwss.lib";
- } else if (scumm_stricmp(desc->gameId, "dwarsd") == 0) {
+ } else if (gd->gameType == GType_DWARS_DS_DOS) {
_libFileName = "dwds.lib";
- } else if (scumm_stricmp(desc->gameId, "dwarsdemo") == 0) {
+ } else if (gd->gameType == GType_DWARS_DEMO_DOS) {
_libFileName = "dwdemo.lib";
_isDemo = true;
}
@@ -48,25 +47,27 @@ GameDrugWars::~GameDrugWars() {
}
void GameDrugWars::init() {
+ Game::init();
+
_videoPosX = 11;
_videoPosY = 2;
loadLibArchive(_libFileName);
_sceneInfo->loadScnFile("dw.scn");
- _startscene = _sceneInfo->getStartScene();
+ _startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
_menuzone = new Zone();
- _menuzone->name = "MainMenu";
- _menuzone->ptrfb = "GLOBALHIT";
+ _menuzone->_name = "MainMenu";
+ _menuzone->_ptrfb = "GLOBALHIT";
_menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
_submenzone = new Zone();
- _submenzone->name = "SubMenu";
- _submenzone->ptrfb = "GLOBALHIT";
+ _submenzone->_name = "SubMenu";
+ _submenzone->_ptrfb = "GLOBALHIT";
_submenzone->addRect(0x1C, 0x13, 0x5D, 0x22, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x1C, 0x33, 0x5D, 0x42, nullptr, 0, "RECTLOAD", "0");
@@ -77,11 +78,11 @@ void GameDrugWars::init() {
_submenzone->addRect(0xDD, 0x55, 0x10A, 0x64, nullptr, 0, "RECTAVG", "0");
_submenzone->addRect(0xDD, 0x75, 0x10A, 0x84, nullptr, 0, "RECTHARD", "0");
- _shotSound = _LoadSoundFile("blow.8b");
- _emptySound = _LoadSoundFile("empty.8b");
- _saveSound = _LoadSoundFile("saved.8b");
- _loadSound = _LoadSoundFile("loaded.8b");
- _skullSound = _LoadSoundFile("skull.8b");
+ _shotSound = loadSoundFile("blow.8b");
+ _emptySound = loadSoundFile("empty.8b");
+ _saveSound = loadSoundFile("saved.8b");
+ _loadSound = loadSoundFile("loaded.8b");
+ _skullSound = loadSoundFile("skull.8b");
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
@@ -99,96 +100,96 @@ void GameDrugWars::init() {
_background = AlgGraphics::loadVgaBackground("dw_menu.vga", _palette);
_screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
- _MoveMouse();
+ moveMouse();
}
void GameDrugWars::registerScriptFunctions() {
#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new DWScriptFunctionRect(this, &GameDrugWars::func);
- RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
- RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
- RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
- RECT_HIT_FUNCTION("STARTMENU", _rect_start);
- RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
- RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
- RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
- RECT_HIT_FUNCTION("RECTEASY", _rect_easy);
- RECT_HIT_FUNCTION("RECTAVG", _rect_average);
- RECT_HIT_FUNCTION("RECTHARD", _rect_hard);
- RECT_HIT_FUNCTION("SELECT_TARGET_PRACTICE", _rect_select_target_practice);
- RECT_HIT_FUNCTION("SELECT_BAR", _rect_select_bar);
- RECT_HIT_FUNCTION("SELECT_CAR_CHASE", _rect_select_car_chase);
- RECT_HIT_FUNCTION("SELECT_DRUG_HOUSE", _rect_select_drug_house);
- RECT_HIT_FUNCTION("SELECT_OFFICE", _rect_select_office);
- RECT_HIT_FUNCTION("SELECT_COURT", _rect_select_court);
- RECT_HIT_FUNCTION("SELECT_BUS", _rect_select_bus);
- RECT_HIT_FUNCTION("SELECT_DOCKS", _rect_select_docks);
- RECT_HIT_FUNCTION("SELECT_HOUSE_BOAT", _rect_select_house_boat);
- RECT_HIT_FUNCTION("SELECT_PARTY", _rect_select_party);
- RECT_HIT_FUNCTION("SELECT_AIRPORT", _rect_select_airport);
- RECT_HIT_FUNCTION("SELECT_MANSION", _rect_select_mansion);
- RECT_HIT_FUNCTION("SELECT_VILLAGE", _rect_select_village);
+ RECT_HIT_FUNCTION("DEFAULT", rectNewScene);
+ RECT_HIT_FUNCTION("EXITMENU", rectExit);
+ RECT_HIT_FUNCTION("CONTMENU", rectContinue);
+ RECT_HIT_FUNCTION("STARTMENU", rectStart);
+ RECT_HIT_FUNCTION("SHOTMENU", rectShotMenu);
+ RECT_HIT_FUNCTION("RECTSAVE", rectSave);
+ RECT_HIT_FUNCTION("RECTLOAD", rectLoad);
+ RECT_HIT_FUNCTION("RECTEASY", rectEasy);
+ RECT_HIT_FUNCTION("RECTAVG", rectAverage);
+ RECT_HIT_FUNCTION("RECTHARD", rectHard);
+ RECT_HIT_FUNCTION("SELECT_TARGET_PRACTICE", rectSelectTargetPractice);
+ RECT_HIT_FUNCTION("SELECT_BAR", rectSelectBar);
+ RECT_HIT_FUNCTION("SELECT_CAR_CHASE", rectSelectCarChase);
+ RECT_HIT_FUNCTION("SELECT_DRUG_HOUSE", rectSelectDrugHouse);
+ RECT_HIT_FUNCTION("SELECT_OFFICE", rectSelectOffice);
+ RECT_HIT_FUNCTION("SELECT_COURT", rectSelectCourt);
+ RECT_HIT_FUNCTION("SELECT_BUS", rectSelectBus);
+ RECT_HIT_FUNCTION("SELECT_DOCKS", rectSelectDocks);
+ RECT_HIT_FUNCTION("SELECT_HOUSE_BOAT", rectSelectHouseBoat);
+ RECT_HIT_FUNCTION("SELECT_PARTY", rectSelectParty);
+ RECT_HIT_FUNCTION("SELECT_AIRPORT", rectSelectAirport);
+ RECT_HIT_FUNCTION("SELECT_MANSION", rectSelectMansion);
+ RECT_HIT_FUNCTION("SELECT_VILLAGE", rectSelectVillage);
#undef RECT_HIT_FUNCTION
#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new DWScriptFunctionScene(this, &GameDrugWars::func);
- PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
- PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
- PRE_OPS_FUNCTION("PAUSE_FADEIN", _scene_pso_pause_fadein);
- PRE_OPS_FUNCTION("GOT_TO", _scene_pso_got_to);
+ PRE_OPS_FUNCTION("DEFAULT", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("FADEIN", scenePsoFadeIn);
+ PRE_OPS_FUNCTION("PAUSE", scenePsoPause);
+ PRE_OPS_FUNCTION("PAUSE_FADEIN", scenePsoPauseFadeIn);
+ PRE_OPS_FUNCTION("GOT_TO", scenePsoGotTo);
#undef PRE_OPS_FUNCTION
#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new DWScriptFunctionScene(this, &GameDrugWars::func);
- INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
- INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
+ INS_OPS_FUNCTION("DEFAULT", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("PAUSE", sceneIsoPause);
#undef INS_OPS_FUNCTION
#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new DWScriptFunctionScene(this, &GameDrugWars::func);
- NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
- NXT_SCN_FUNCTION("GAME_WON", _scene_nxtscn_game_won);
- NXT_SCN_FUNCTION("LOSE_A_LIFE", _scene_nxtscn_lose_a_life);
- NXT_SCN_FUNCTION("CONTINUE_GAME", _scene_nxtscn_continue_game);
- NXT_SCN_FUNCTION("DID_NOT_CONTINUE", _scene_nxtscn_did_not_continue);
- NXT_SCN_FUNCTION("KILL_INNOCENT_MAN", _scene_nxtscn_kill_innocent_man);
- NXT_SCN_FUNCTION("KILL_INNOCENT_WOMAN", _scene_nxtscn_kill_innocent_woman);
- NXT_SCN_FUNCTION("AFTER_DIE", _scene_nxtscn_after_die);
- NXT_SCN_FUNCTION("INIT_RANDOM", _scene_nxtscn_init_random);
- NXT_SCN_FUNCTION("CONTINUE_RANDOM", _scene_nxtscn_continue_random);
- NXT_SCN_FUNCTION("SELECT_SCENARIO", _scene_nxtscn_select_scenario);
- NXT_SCN_FUNCTION("FINISH_SCENARIO", _scene_nxtscn_finish_scenario);
+ NXT_SCN_FUNCTION("DEFAULT", sceneDefaultNxtscn);
+ NXT_SCN_FUNCTION("GAME_WON", sceneNxtscnGameWon);
+ NXT_SCN_FUNCTION("LOSE_A_LIFE", sceneNxtscnLoseALife);
+ NXT_SCN_FUNCTION("CONTINUE_GAME", sceneNxtscnContinueGame);
+ NXT_SCN_FUNCTION("DID_NOT_CONTINUE", sceneNxtscnDidNotContinue);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_MAN", sceneNxtscnKillInnocentMan);
+ NXT_SCN_FUNCTION("KILL_INNOCENT_WOMAN", sceneNxtscnKillInnocentWoman);
+ NXT_SCN_FUNCTION("AFTER_DIE", sceneNxtscnAfterDie);
+ NXT_SCN_FUNCTION("INIT_RANDOM", sceneNxtscnInitRandom);
+ NXT_SCN_FUNCTION("CONTINUE_RANDOM", sceneNxtscnContinueRandom);
+ NXT_SCN_FUNCTION("SELECT_SCENARIO", sceneNxtscnSelectScenario);
+ NXT_SCN_FUNCTION("FINISH_SCENARIO", sceneNxtscnFinishScenario);
#undef NXT_SCN_FUNCTION
- _sceneShowMsg["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::_scene_sm_donothing);
- _sceneWepDwn["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::_scene_default_wepdwn);
- _sceneScnScr["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::_scene_default_score);
- _sceneNxtFrm["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::_scene_nxtfrm);
+ _sceneShowMsg["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::sceneSmDonothing);
+ _sceneWepDwn["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::sceneDefaultWepdwn);
+ _sceneScnScr["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::sceneDefaultScore);
+ _sceneNxtFrm["DEFAULT"] = new DWScriptFunctionScene(this, &GameDrugWars::sceneNxtfrm);
}
void GameDrugWars::verifyScriptFunctions() {
Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
for (size_t i = 0; i < scenes->size(); i++) {
Scene *scene = (*scenes)[i];
- getScriptFunctionScene(PREOP, scene->preop);
- getScriptFunctionScene(SHOWMSG, scene->scnmsg);
- getScriptFunctionScene(INSOP, scene->insop);
- getScriptFunctionScene(WEPDWN, scene->wepdwn);
- getScriptFunctionScene(SCNSCR, scene->scnscr);
- getScriptFunctionScene(NXTFRM, scene->nxtfrm);
- getScriptFunctionScene(NXTSCN, scene->nxtscn);
- for (size_t j = 0; j < scene->zones.size(); j++) {
- Zone *zone = scene->zones[j];
- for (size_t k = 0; k < zone->rects.size(); k++) {
- getScriptFunctionRectHit(zone->rects[k].rectHit);
+ getScriptFunctionScene(PREOP, scene->_preop);
+ getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
+ getScriptFunctionScene(INSOP, scene->_insop);
+ getScriptFunctionScene(WEPDWN, scene->_wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->_scnscr);
+ getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->_nxtscn);
+ for (size_t j = 0; j < scene->_zones.size(); j++) {
+ Zone *zone = scene->_zones[j];
+ for (size_t k = 0; k < zone->_rects.size(); k++) {
+ getScriptFunctionRectHit(zone->_rects[k]._rectHit);
}
}
}
}
DWScriptFunctionRect GameDrugWars::getScriptFunctionRectHit(Common::String name) {
- DWScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ auto it = _rectHitFuncs.find(name);
if (it != _rectHitFuncs.end()) {
return (*(*it)._value);
} else {
- error("Could not find rectHit function: %s", name.c_str());
+ error("GameDrugWars::getScriptFunctionRectHit(): Could not find rectHit function: %s", name.c_str());
}
}
@@ -217,7 +218,7 @@ DWScriptFunctionScene GameDrugWars::getScriptFunctionScene(SceneFuncType type, C
functionMap = &_sceneNxtScn;
break;
default:
- error("Unkown scene script type: %u", type);
+ error("GameDrugWars::getScriptFunctionScene(): Unkown scene script type: %u", type);
break;
}
DWScriptFunctionSceneMap::iterator it;
@@ -225,7 +226,7 @@ DWScriptFunctionScene GameDrugWars::getScriptFunctionScene(SceneFuncType type, C
if (it != functionMap->end()) {
return (*(*it)._value);
} else {
- error("Could not find scene type %u function: %s", type, name.c_str());
+ error("GameDrugWars::getScriptFunctionScene(): Could not find scene type %u function: %s", type, name.c_str());
}
}
@@ -241,76 +242,73 @@ void GameDrugWars::callScriptFunctionScene(SceneFuncType type, Common::String na
Common::Error GameDrugWars::run() {
init();
- _NewGame();
- _cur_scene = _startscene;
+ newGame();
+ _curScene = _startScene;
Common::String oldscene;
while (!_vm->shouldQuit()) {
- oldscene = _cur_scene;
- _SetFrame();
+ oldscene = _curScene;
_fired = false;
- Scene *scene = _sceneInfo->findScene(_cur_scene);
+ Scene *scene = _sceneInfo->findScene(_curScene);
if (!loadScene(scene)) {
- error("Cannot find scene %s in libfile", scene->name.c_str());
+ error("GameDrugWars::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
_sceneSkipped = false;
Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
g_system->getMixer()->stopHandle(_sceneAudioHandle);
g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
- _nextFrameTime = _GetMsTime() + 100;
- callScriptFunctionScene(PREOP, scene->preop, scene);
- _currentFrame = _GetFrame(scene);
- while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
- _UpdateMouse();
- callScriptFunctionScene(SHOWMSG, scene->scnmsg, scene);
- callScriptFunctionScene(INSOP, scene->insop, scene);
- _holster = _WeaponDown();
+ _nextFrameTime = getMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->_preop, scene);
+ _currentFrame = getFrame(scene);
+ while (_currentFrame <= scene->_endFrame && _curScene == oldscene && !_vm->shouldQuit()) {
+ updateMouse();
+ callScriptFunctionScene(SHOWMSG, scene->_scnmsg, scene);
+ callScriptFunctionScene(INSOP, scene->_insop, scene);
+ _holster = weaponDown();
if (_holster) {
- callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ callScriptFunctionScene(WEPDWN, scene->_wepdwn, scene);
}
Common::Point firedCoords;
- if (__Fired(&firedCoords)) {
+ if (fired(&firedCoords)) {
if (!_holster) {
- Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ Rect *hitGlobalRect = checkZone(_menuzone, &firedCoords);
if (hitGlobalRect != nullptr) {
- callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
- } else {
- if (_shots > 0) {
- if (!_debug_unlimitedAmmo) {
- _shots--;
- }
- _DisplayShotFiredImage(&firedCoords);
- _DoShot();
- Rect *hitRect = nullptr;
- Zone *hitSceneZone = _CheckZonesV2(scene, hitRect, &firedCoords);
- if (hitSceneZone != nullptr) {
- callScriptFunctionRectHit(hitRect->rectHit, hitRect);
- } else {
- int8 skip = _SkipToNewScene(scene);
- if (skip == -1) {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
- } else if (skip == 1) {
- if (scene->dataParam4 > 0) {
- uint32 framesToSkip = (scene->dataParam4 - _currentFrame) / _videoFrameSkip;
- _videoDecoder->skipNumberOfFrames(framesToSkip);
- } else {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
- }
+ callScriptFunctionRectHit(hitGlobalRect->_rectHit, hitGlobalRect);
+ } else if (_shots > 0) {
+ if (!_debug_unlimitedAmmo) {
+ _shots--;
+ }
+ displayShotFiredImage(&firedCoords);
+ doShot();
+ Rect *hitRect = nullptr;
+ Zone *hitSceneZone = checkZonesV2(scene, hitRect, &firedCoords);
+ if (hitSceneZone != nullptr) {
+ callScriptFunctionRectHit(hitRect->_rectHit, hitRect);
+ } else {
+ int8 skip = skipToNewScene(scene);
+ if (skip == -1) {
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
+ } else if (skip == 1) {
+ if (scene->_dataParam4 > 0) {
+ uint32 framesToSkip = (scene->_dataParam4 - _currentFrame) / _videoFrameSkip;
+ _videoDecoder->skipNumberOfFrames(framesToSkip);
+ } else {
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
}
- } else {
- _PlaySound(_emptySound);
}
+ } else {
+ playSound(_emptySound);
}
}
}
- if (_cur_scene == oldscene) {
- callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ if (_curScene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->_nxtfrm, scene);
}
- _DisplayLivesLeft();
- _DisplayScores();
- _DisplayShotsLeft();
- _MoveMouse();
+ displayLivesLeft();
+ displayScores();
+ displayShotsLeft();
+ moveMouse();
if (_pauseTime > 0) {
g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
} else {
@@ -319,13 +317,14 @@ Common::Error GameDrugWars::run() {
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
}
- int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ updateScreen();
+ int32 remainingMillis = _nextFrameTime - getMsTime();
if (remainingMillis < 10) {
if (_videoDecoder->getCurrentFrame() > 0) {
_videoDecoder->getNextFrame();
}
- remainingMillis = _nextFrameTime - _GetMsTime();
- _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ remainingMillis = _nextFrameTime - getMsTime();
+ _nextFrameTime = getMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
}
if (remainingMillis > 0) {
if (remainingMillis > 15) {
@@ -333,96 +332,92 @@ Common::Error GameDrugWars::run() {
}
g_system->delayMillis(remainingMillis);
}
- _currentFrame = _GetFrame(scene);
- updateScreen();
+ _currentFrame = getFrame(scene);
}
// frame limit reached or scene changed, prepare for next scene
_hadPause = false;
_pauseTime = 0;
- if (_cur_scene == oldscene) {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ if (_curScene == oldscene) {
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
- if (_cur_scene == "") {
+ if (_curScene == "") {
_vm->quitGame();
}
}
return Common::kNoError;
}
-void GameDrugWars::_NewGame() {
+void GameDrugWars::newGame() {
_shots = 10;
_lives = 3;
_holster = false;
}
-void GameDrugWars::_ResetParams() {
- // fill _got_to with scenario start scenes
- // 0 in _got_to array means the scenario is finished
- for (uint8 i = 0; i < 14; i++) {
- _got_to[i] = _scenario_start_scenes[i];
+void GameDrugWars::resetParams() {
+ // fill _gotTo with scenario start scenes
+ // 0 in _gotTo array means the scenario is finished
+ for (int i = 0; i < 14; i++) {
+ _gotTo[i] = _scenarioStartScenes[i];
}
}
-void GameDrugWars::_DoMenu() {
- uint32 startTime = _GetMsTime();
- _RestoreCursor();
- _DoCursor();
+void GameDrugWars::doMenu() {
+ uint32 startTime = getMsTime();
+ updateCursor();
_inMenu = true;
- _MoveMouse();
+ moveMouse();
g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
- _ShowDifficulty(_difficulty, false);
+ showDifficulty(_difficulty, false);
while (_inMenu && !_vm->shouldQuit()) {
Common::Point firedCoords;
- if (__Fired(&firedCoords)) {
- Rect *hitMenuRect = _CheckZone(_submenzone, &firedCoords);
+ if (fired(&firedCoords)) {
+ Rect *hitMenuRect = checkZone(_submenzone, &firedCoords);
if (hitMenuRect != nullptr) {
- callScriptFunctionRectHit(hitMenuRect->rectHit, hitMenuRect);
+ callScriptFunctionRectHit(hitMenuRect->_rectHit, hitMenuRect);
}
}
if (_difficulty != _oldDifficulty) {
- _ChangeDifficulty(_difficulty);
+ changeDifficulty(_difficulty);
}
- g_system->delayMillis(15);
updateScreen();
+ g_system->delayMillis(15);
}
- _RestoreCursor();
- _DoCursor();
+ updateCursor();
g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
if (_hadPause) {
- unsigned long endTime = _GetMsTime();
- unsigned long timeDiff = endTime - startTime;
+ uint32 endTime = getMsTime();
+ uint32 timeDiff = endTime - startTime;
_pauseTime += timeDiff;
_nextFrameTime += timeDiff;
}
}
-void GameDrugWars::_ChangeDifficulty(uint8 newDifficulty) {
+void GameDrugWars::changeDifficulty(uint8 newDifficulty) {
if (newDifficulty == _oldDifficulty) {
return;
}
- _ShowDifficulty(newDifficulty, true);
+ showDifficulty(newDifficulty, true);
_oldDifficulty = newDifficulty;
_difficulty = newDifficulty;
}
-void GameDrugWars::_ShowDifficulty(uint8 newDifficulty, bool updateCursor) {
+void GameDrugWars::showDifficulty(uint8 newDifficulty, bool cursor) {
// reset menu screen
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
uint16 posY = 0x3C + ((newDifficulty - 1) * 0x21);
AlgGraphics::drawImageCentered(_screen, &_difficultyIcon, 0x0115, posY);
- if (updateCursor) {
- _DoCursor();
+ if (cursor) {
+ updateCursor();
}
}
-void GameDrugWars::_DoCursor() {
- _UpdateMouse();
+void GameDrugWars::updateCursor() {
+ updateMouse();
}
-void GameDrugWars::_UpdateMouse() {
+void GameDrugWars::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::PixelFormat pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
Graphics::Surface *cursor = &(*_gun)[_whichGun];
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 3;
@@ -431,13 +426,13 @@ void GameDrugWars::_UpdateMouse() {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0, false, &pixelFormat);
+ CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
}
-void GameDrugWars::_MoveMouse() {
+void GameDrugWars::moveMouse() {
if (_inMenu) {
_whichGun = 3; // in menu cursor
} else {
@@ -463,27 +458,27 @@ void GameDrugWars::_MoveMouse() {
_whichGun = 0; // regular gun
}
}
- _UpdateMouse();
+ updateMouse();
}
-void GameDrugWars::_DisplayLivesLeft() {
+void GameDrugWars::displayLivesLeft() {
if (_lives == _oldLives) {
return;
}
int posY = 0x67;
- for (uint8 i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
AlgGraphics::drawImage(_screen, &_deadIcon, 0x12F, posY);
posY += 0xE;
}
posY = 0x67;
- for (uint8 i = 0; i < _lives; i++) {
+ for (int i = 0; i < _lives; i++) {
AlgGraphics::drawImage(_screen, &_liveIcon, 0x12F, posY);
posY += 0xE;
}
_oldLives = _lives;
}
-void GameDrugWars::_DisplayScores() {
+void GameDrugWars::displayScores() {
if (_score == _oldScore) {
return;
}
@@ -497,88 +492,88 @@ void GameDrugWars::_DisplayScores() {
_oldScore = _score;
}
-void GameDrugWars::_DisplayShotsLeft() {
+void GameDrugWars::displayShotsLeft() {
if (_shots == _oldShots) {
return;
}
uint16 posX = 0xEE;
- for (uint8 i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBE);
posX += 5;
}
posX = 0xEE;
- for (uint8 i = 0; i < _shots; i++) {
+ for (int i = 0; i < _shots; i++) {
AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBE);
posX += 5;
}
_oldShots = _shots;
}
-bool GameDrugWars::_WeaponDown() {
+bool GameDrugWars::weaponDown() {
if (_rightDown && _mousePos.y >= 0xAA && _mousePos.x >= 0x113) {
return true;
}
return false;
}
-bool GameDrugWars::_SaveState() {
+bool GameDrugWars::saveState() {
Common::OutSaveFile *outSaveFile;
Common::String saveFileName = _vm->getSaveStateName(0);
if (!(outSaveFile = g_system->getSavefileManager()->openForSaving(saveFileName))) {
- warning("Can't create file '%s', game not saved", saveFileName.c_str());
+ warning("GameDrugWars::saveState(): Can't create file '%s', game not saved", saveFileName.c_str());
return false;
}
outSaveFile->writeUint32BE(MKTAG('A', 'L', 'G', 'S')); // header
outSaveFile->writeByte(0); // version, unused for now
outSaveFile->writeSByte(_stage);
outSaveFile->writeByte(_continues);
- outSaveFile->writeSByte(_got_to_index);
- for (uint8 i = 0; i < 14; i++) {
- outSaveFile->writeUint16LE(_got_to[i]);
+ outSaveFile->writeSByte(_gotToIndex);
+ for (int i = 0; i < 14; i++) {
+ outSaveFile->writeUint16LE(_gotTo[i]);
}
outSaveFile->writeSByte(_lives);
outSaveFile->writeUint16LE(_shots);
outSaveFile->writeSint32LE(_score);
outSaveFile->writeByte(_difficulty);
- outSaveFile->writeString(_cur_scene);
+ outSaveFile->writeString(_curScene);
outSaveFile->writeByte(0);
outSaveFile->finalize();
delete outSaveFile;
return true;
}
-bool GameDrugWars::_LoadState() {
+bool GameDrugWars::loadState() {
Common::InSaveFile *inSaveFile;
Common::String saveFileName = _vm->getSaveStateName(0);
if (!(inSaveFile = g_system->getSavefileManager()->openForLoading(saveFileName))) {
- debug("Can't load file '%s', game not loaded", saveFileName.c_str());
+ debug("GameDrugWars::loadState(): Can't load file '%s', game not loaded", saveFileName.c_str());
return false;
}
uint32 header = inSaveFile->readUint32BE();
if (header != MKTAG('A', 'L', 'G', 'S')) {
- warning("Unkown save file, header: %d", header);
+ warning("GameDrugWars::loadState(): Unkown save file, header: %s", tag2str(header));
return false;
}
inSaveFile->skip(1); // version, unused for now
_stage = inSaveFile->readSByte();
_continues = inSaveFile->readByte();
- _got_to_index = inSaveFile->readSByte();
- for (uint8 i = 0; i < 14; i++) {
- _got_to[i] = inSaveFile->readUint16LE();
+ _gotToIndex = inSaveFile->readSByte();
+ for (int i = 0; i < 14; i++) {
+ _gotTo[i] = inSaveFile->readUint16LE();
}
_lives = inSaveFile->readSByte();
_shots = inSaveFile->readUint16LE();
_score = inSaveFile->readSint32LE();
_difficulty = inSaveFile->readByte();
- _cur_scene = inSaveFile->readString();
+ _curScene = inSaveFile->readString();
delete inSaveFile;
_gameInProgress = true;
- _ChangeDifficulty(_difficulty);
+ changeDifficulty(_difficulty);
return true;
}
// misc game functions
-void GameDrugWars::_DisplayShotFiredImage(Common::Point *point) {
+void GameDrugWars::displayShotFiredImage(Common::Point *point) {
if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
@@ -586,15 +581,15 @@ void GameDrugWars::_DisplayShotFiredImage(Common::Point *point) {
}
}
-void GameDrugWars::_EnableVideoFadeIn() {
+void GameDrugWars::enableVideoFadeIn() {
// TODO implement
}
-uint16 GameDrugWars::_SceneToNumber(Scene *scene) {
- return atoi(scene->name.substr(5).c_str());
+uint16 GameDrugWars::sceneToNumber(Scene *scene) {
+ return atoi(scene->_name.substr(5).c_str());
}
-uint16 GameDrugWars::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
+uint16 GameDrugWars::randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
if (max == 1) {
return 0;
}
@@ -603,401 +598,401 @@ uint16 GameDrugWars::_RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
if (*mask == fullMask) {
*mask = 0;
}
- uint16 random = 0;
+ uint16 randomNum = 0;
// find an unused random number
while (1) {
- random = _rnd->getRandomNumber(max - 1);
+ randomNum = _rnd->getRandomNumber(max - 1);
// check if bit is already used
- unsigned int bit = 1 << random;
- if (!((*mask & bit) || random == exclude)) {
+ uint16 bit = 1 << randomNum;
+ if (!((*mask & bit) || randomNum == exclude)) {
// set the bit in mask
*mask |= bit;
break;
}
}
- return random;
+ return randomNum;
}
-uint16 GameDrugWars::_PickRandomScene(uint8 index, uint8 max) {
- if (_random_scenes[index] == nullptr) {
- error("_PickRandomScene called with illegal index: %d", index);
+uint16 GameDrugWars::pickRandomScene(uint8 index, uint8 max) {
+ if (_randomScenes[index] == nullptr) {
+ error("GameDrugWars::pickRandomScene(): called with illegal index: %d", index);
}
if (max != 0) {
- _random_max = max;
- _random_mask = 0;
- _random_picked = 0;
- _random_scene_count = 0;
- while (_random_scenes[index][_random_scene_count] != 0) {
- _random_scene_count++;
+ _randomMax = max;
+ _randomMask = 0;
+ _randomPicked = 0;
+ _randomSceneCount = 0;
+ while (_randomScenes[index][_randomSceneCount] != 0) {
+ _randomSceneCount++;
}
}
- unsigned short count = _random_max--;
+ uint16 count = _randomMax--;
if (count > 0) {
- _random_picked = _RandomUnusedInt(_random_scene_count, &_random_mask, _random_picked);
- return _random_scenes[index][_random_picked];
+ _randomPicked = randomUnusedInt(_randomSceneCount, &_randomMask, _randomPicked);
+ return _randomScenes[index][_randomPicked];
}
return 0;
}
-uint16 GameDrugWars::_PickDeathScene() {
- if (_stage != _old_stage) {
- _old_stage = _stage;
- _death_mask = 0;
- _death_picked = -1;
- _death_scene_count = 0;
- while (_died_scenes_by_stage[_stage][_death_scene_count] != 0) {
- _death_scene_count++;
+uint16 GameDrugWars::pickDeathScene() {
+ if (_stage != _oldStage) {
+ _oldStage = _stage;
+ _deathMask = 0;
+ _deathPicked = -1;
+ _deathSceneCount = 0;
+ while (_diedScenesByStage[_stage][_deathSceneCount] != 0) {
+ _deathSceneCount++;
}
}
- _death_picked = _RandomUnusedInt(_death_scene_count, &_death_mask, _death_picked);
- return _died_scenes_by_stage[_stage][_death_picked];
+ _deathPicked = randomUnusedInt(_deathSceneCount, &_deathMask, _deathPicked);
+ return _diedScenesByStage[_stage][_deathPicked];
}
-void GameDrugWars::_scene_nxtscn_generic(uint8 index) {
+void GameDrugWars::sceneNxtscnGeneric(uint8 index) {
uint16 nextSceneId = 0;
- _got_to[index] = 0;
- if (_got_to[0] || _got_to[1] || _got_to[3] || _got_to[2]) {
+ _gotTo[index] = 0;
+ if (_gotTo[0] || _gotTo[1] || _gotTo[3] || _gotTo[2]) {
nextSceneId = 0x26;
- } else if (_got_to[4] || _got_to[5] || _got_to[6]) {
+ } else if (_gotTo[4] || _gotTo[5] || _gotTo[6]) {
if (_stage == 1) {
nextSceneId = 0x52;
} else {
_stage = 1;
nextSceneId = 0x50;
}
- } else if (_got_to[7] || _got_to[8] || _got_to[9]) {
+ } else if (_gotTo[7] || _gotTo[8] || _gotTo[9]) {
if (_stage == 2) {
nextSceneId = 0x9A;
} else {
_stage = 2;
nextSceneId = 0x81;
}
- } else if (_got_to[10] || _got_to[11] || _got_to[12]) {
+ } else if (_gotTo[10] || _gotTo[11] || _gotTo[12]) {
if (_stage == 3) {
nextSceneId = 0xDF;
} else {
_stage = 3;
nextSceneId = 0x14B;
}
- } else if (_got_to[13]) {
+ } else if (_gotTo[13]) {
_stage = 4;
nextSceneId = 0x18F;
} else {
nextSceneId = 0x21;
}
- _cur_scene = Common::String::format("scene%d", nextSceneId);
+ _curScene = Common::String::format("scene%d", nextSceneId);
}
-void GameDrugWars::_rect_select_generic(uint8 index) {
- if (_got_to[index] > 0) {
- _cur_scene = Common::String::format("scene%d", _got_to[index]);
- _got_to_index = index;
+void GameDrugWars::rectSelectGeneric(uint8 index) {
+ if (_gotTo[index] > 0) {
+ _curScene = Common::String::format("scene%d", _gotTo[index]);
+ _gotToIndex = index;
}
}
// Script functions: RectHit
-void GameDrugWars::_rect_shotmenu(Rect *rect) {
- _DoMenu();
+void GameDrugWars::rectShotMenu(Rect *rect) {
+ doMenu();
}
-void GameDrugWars::_rect_save(Rect *rect) {
- if(_SaveState()) {
- _DoSaveSound();
+void GameDrugWars::rectSave(Rect *rect) {
+ if (saveState()) {
+ doSaveSound();
}
}
-void GameDrugWars::_rect_load(Rect *rect) {
- if(_LoadState()) {
- _DoLoadSound();
+void GameDrugWars::rectLoad(Rect *rect) {
+ if (loadState()) {
+ doLoadSound();
}
}
-void GameDrugWars::_rect_continue(Rect *rect) {
+void GameDrugWars::rectContinue(Rect *rect) {
_inMenu = false;
_fired = false;
if (_lives <= 0) {
_score = (int32)(_score * 0.7f);
- uint16 returnScene = _stage_start_scenes[_stage];
- _cur_scene = Common::String::format("scene%d", returnScene);
- _NewGame();
+ uint16 returnScene = _stageStartScenes[_stage];
+ _curScene = Common::String::format("scene%d", returnScene);
+ newGame();
}
}
-void GameDrugWars::_rect_start(Rect *rect) {
+void GameDrugWars::rectStart(Rect *rect) {
_inMenu = false;
_fired = false;
_gameInProgress = true;
if (_isDemo) {
- _cur_scene = "scene54";
- _got_to_index = 1;
- _got_to[_got_to_index] = 54;
+ _curScene = "scene54";
+ _gotToIndex = 1;
+ _gotTo[_gotToIndex] = 54;
} else {
- _cur_scene = "scene53";
+ _curScene = "scene53";
}
- _ResetParams();
- _NewGame();
+ resetParams();
+ newGame();
}
-void GameDrugWars::_rect_select_target_practice(Rect *rect) {
- _rect_select_generic(0);
- _got_to[0] = 0;
+void GameDrugWars::rectSelectTargetPractice(Rect *rect) {
+ rectSelectGeneric(0);
+ _gotTo[0] = 0;
}
-void GameDrugWars::_rect_select_bar(Rect *rect) {
- _got_to[0] = 0;
- _rect_select_generic(1);
+void GameDrugWars::rectSelectBar(Rect *rect) {
+ _gotTo[0] = 0;
+ rectSelectGeneric(1);
}
-void GameDrugWars::_rect_select_car_chase(Rect *rect) {
- _got_to[0] = 0;
- _rect_select_generic(2);
+void GameDrugWars::rectSelectCarChase(Rect *rect) {
+ _gotTo[0] = 0;
+ rectSelectGeneric(2);
}
-void GameDrugWars::_rect_select_drug_house(Rect *rect) {
- _got_to[0] = 0;
- _rect_select_generic(3);
+void GameDrugWars::rectSelectDrugHouse(Rect *rect) {
+ _gotTo[0] = 0;
+ rectSelectGeneric(3);
}
-void GameDrugWars::_rect_select_office(Rect *rect) {
- _rect_select_generic(4);
+void GameDrugWars::rectSelectOffice(Rect *rect) {
+ rectSelectGeneric(4);
}
-void GameDrugWars::_rect_select_court(Rect *rect) {
- _rect_select_generic(5);
+void GameDrugWars::rectSelectCourt(Rect *rect) {
+ rectSelectGeneric(5);
}
-void GameDrugWars::_rect_select_bus(Rect *rect) {
- _rect_select_generic(6);
+void GameDrugWars::rectSelectBus(Rect *rect) {
+ rectSelectGeneric(6);
}
-void GameDrugWars::_rect_select_docks(Rect *rect) {
- _rect_select_generic(7);
+void GameDrugWars::rectSelectDocks(Rect *rect) {
+ rectSelectGeneric(7);
}
-void GameDrugWars::_rect_select_house_boat(Rect *rect) {
- _rect_select_generic(9);
+void GameDrugWars::rectSelectHouseBoat(Rect *rect) {
+ rectSelectGeneric(9);
}
-void GameDrugWars::_rect_select_party(Rect *rect) {
- _rect_select_generic(8);
+void GameDrugWars::rectSelectParty(Rect *rect) {
+ rectSelectGeneric(8);
}
-void GameDrugWars::_rect_select_airport(Rect *rect) {
- _rect_select_generic(10);
+void GameDrugWars::rectSelectAirport(Rect *rect) {
+ rectSelectGeneric(10);
}
-void GameDrugWars::_rect_select_mansion(Rect *rect) {
- _rect_select_generic(11);
+void GameDrugWars::rectSelectMansion(Rect *rect) {
+ rectSelectGeneric(11);
}
-void GameDrugWars::_rect_select_village(Rect *rect) {
- _rect_select_generic(12);
+void GameDrugWars::rectSelectVillage(Rect *rect) {
+ rectSelectGeneric(12);
}
// Script functions: Scene PreOps
-void GameDrugWars::_scene_pso_got_to(Scene *scene) {
- uint16 sceneId = _SceneToNumber(scene);
- _got_to[_got_to_index] = sceneId;
- if (_got_to_index == 13) {
- _final_stage_scene = _SceneToNumber(scene);
+void GameDrugWars::scenePsoGotTo(Scene *scene) {
+ uint16 sceneId = sceneToNumber(scene);
+ _gotTo[_gotToIndex] = sceneId;
+ if (_gotToIndex == 13) {
+ _finalStageScene = sceneToNumber(scene);
}
- _EnableVideoFadeIn();
+ enableVideoFadeIn();
}
// Script functions: Scene NxtScn
-void GameDrugWars::_scene_nxtscn_game_won(Scene *scene) {
+void GameDrugWars::sceneNxtscnGameWon(Scene *scene) {
_gameInProgress = false;
- _cur_scene = _startscene;
+ _curScene = _startScene;
}
-void GameDrugWars::_scene_nxtscn_did_not_continue(Scene *scene) {
+void GameDrugWars::sceneNxtscnDidNotContinue(Scene *scene) {
_gameInProgress = false;
- _cur_scene = _startscene;
+ _curScene = _startScene;
}
-void GameDrugWars::_scene_nxtscn_lose_a_life(Scene *scene) {
+void GameDrugWars::sceneNxtscnLoseALife(Scene *scene) {
uint16 picked = 0;
if (!_debug_godMode) {
_lives--;
}
if (_isDemo) {
- _cur_scene = "scene83";
+ _curScene = "scene83";
return;
} else if (_lives > 0) {
- _DisplayLivesLeft();
- picked = _PickDeathScene();
+ displayLivesLeft();
+ picked = pickDeathScene();
} else {
- picked = _dead_scenes[_stage];
+ picked = _deadScenes[_stage];
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameDrugWars::_scene_nxtscn_continue_game(Scene *scene) {
+void GameDrugWars::sceneNxtscnContinueGame(Scene *scene) {
if (_continues < 2) {
- _cur_scene = "scene438";
+ _curScene = "scene438";
} else {
- _scene_nxtscn_did_not_continue(scene);
+ sceneNxtscnDidNotContinue(scene);
}
}
-void GameDrugWars::_scene_nxtscn_kill_innocent_man(Scene *scene) {
+void GameDrugWars::sceneNxtscnKillInnocentMan(Scene *scene) {
uint16 picked = 0;
if (!_debug_godMode) {
_lives--;
}
if (_isDemo) {
- _scene_nxtscn_after_die(scene);
+ sceneNxtscnAfterDie(scene);
return;
} else if (_lives > 0) {
- picked = _stage_start_scenes[_stage];
+ picked = _stageStartScenes[_stage];
} else {
- picked = _dead_scenes[_stage];
+ picked = _deadScenes[_stage];
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameDrugWars::_scene_nxtscn_kill_innocent_woman(Scene *scene) {
- _scene_nxtscn_kill_innocent_man(scene);
+void GameDrugWars::sceneNxtscnKillInnocentWoman(Scene *scene) {
+ sceneNxtscnKillInnocentMan(scene);
}
-void GameDrugWars::_scene_nxtscn_after_die(Scene *scene) {
+void GameDrugWars::sceneNxtscnAfterDie(Scene *scene) {
if (_isDemo) {
- if (_got_to[_got_to_index] > 54) {
- _cur_scene = "scene67";
+ if (_gotTo[_gotToIndex] > 54) {
+ _curScene = "scene67";
} else {
- _cur_scene = "scene54";
+ _curScene = "scene54";
}
} else {
- uint16 picked = _stage_start_scenes[_stage];
- _cur_scene = Common::String::format("scene%d", picked);
+ uint16 picked = _stageStartScenes[_stage];
+ _curScene = Common::String::format("scene%d", picked);
}
}
-void GameDrugWars::_scene_nxtscn_init_random(Scene *scene) {
- int totalRandom = (_difficulty * 2) + _random_scenes_difficulty[_got_to_index] + 2;
- uint16 picked = _PickRandomScene(_got_to_index, totalRandom);
- _cur_scene = Common::String::format("scene%d", picked);
+void GameDrugWars::sceneNxtscnInitRandom(Scene *scene) {
+ int totalRandom = (_difficulty * 2) + _randomScenesDifficulty[_gotToIndex] + 2;
+ uint16 picked = pickRandomScene(_gotToIndex, totalRandom);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameDrugWars::_scene_nxtscn_continue_random(Scene *scene) {
- uint16 picked = _PickRandomScene(_got_to_index, 0);
+void GameDrugWars::sceneNxtscnContinueRandom(Scene *scene) {
+ uint16 picked = pickRandomScene(_gotToIndex, 0);
if (picked == 0) {
- picked = _random_scenes_continue[_got_to_index];
+ picked = _randomScenesContinue[_gotToIndex];
if (picked == 0) {
- error("_scene_nxtscn_continue_random called with illegal _got_to_index: %d", _got_to_index);
+ error("GameDrugWars::sceneNxtscnContinueRandom(): called with illegal _got_to_index: %d", _gotToIndex);
}
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
-void GameDrugWars::_scene_nxtscn_select_scenario(Scene *scene) {
+void GameDrugWars::sceneNxtscnSelectScenario(Scene *scene) {
uint16 picked = 0;
switch (_stage) {
case 0:
- if (_got_to[0] > 0) {
- _rect_select_generic(0);
- _got_to[0] = 0;
- } else if (_got_to[1] > 0) {
- _rect_select_generic(1);
- } else if (_got_to[2] > 0) {
- _rect_select_generic(2);
- } else if (_got_to[3] > 0) {
- _rect_select_generic(3);
+ if (_gotTo[0] > 0) {
+ rectSelectGeneric(0);
+ _gotTo[0] = 0;
+ } else if (_gotTo[1] > 0) {
+ rectSelectGeneric(1);
+ } else if (_gotTo[2] > 0) {
+ rectSelectGeneric(2);
+ } else if (_gotTo[3] > 0) {
+ rectSelectGeneric(3);
} else {
picked = 0x83;
_stage = 1;
}
break;
case 1:
- if (_got_to[4] > 0) {
- _rect_select_generic(4);
- } else if (_got_to[5] > 0) {
- _rect_select_generic(5);
- } else if (_got_to[6] > 0) {
- _rect_select_generic(6);
+ if (_gotTo[4] > 0) {
+ rectSelectGeneric(4);
+ } else if (_gotTo[5] > 0) {
+ rectSelectGeneric(5);
+ } else if (_gotTo[6] > 0) {
+ rectSelectGeneric(6);
} else {
picked = 0xEE;
_stage = 2;
}
break;
case 2:
- if (_got_to[7] > 0) {
- _rect_select_generic(7);
- } else if (_got_to[8] > 0) {
- _rect_select_generic(8);
- } else if (_got_to[9] > 0) {
- _rect_select_generic(9);
+ if (_gotTo[7] > 0) {
+ rectSelectGeneric(7);
+ } else if (_gotTo[8] > 0) {
+ rectSelectGeneric(8);
+ } else if (_gotTo[9] > 0) {
+ rectSelectGeneric(9);
} else {
picked = 0x0132;
_stage = 3;
}
break;
case 3:
- if (_got_to[10] > 0) {
- _rect_select_generic(10);
- } else if (_got_to[11] > 0) {
- _rect_select_generic(11);
- } else if (_got_to[12] > 0) {
- _rect_select_generic(12);
+ if (_gotTo[10] > 0) {
+ rectSelectGeneric(10);
+ } else if (_gotTo[11] > 0) {
+ rectSelectGeneric(11);
+ } else if (_gotTo[12] > 0) {
+ rectSelectGeneric(12);
} else {
- picked = _final_stage_scene;
- _got_to_index = 13;
+ picked = _finalStageScene;
+ _gotToIndex = 13;
_stage = 4;
}
break;
}
if (picked != 0) {
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
}
-void GameDrugWars::_scene_nxtscn_finish_scenario(Scene *scene) {
+void GameDrugWars::sceneNxtscnFinishScenario(Scene *scene) {
uint16 picked = 0;
- _got_to[_got_to_index] = 0;
+ _gotTo[_gotToIndex] = 0;
if (_isDemo) {
- _cur_scene = _startscene;
+ _curScene = _startScene;
return;
}
- if (_got_to[0] || _got_to[1] || _got_to[3] || _got_to[2]) {
+ if (_gotTo[0] || _gotTo[1] || _gotTo[3] || _gotTo[2]) {
picked = 0x51;
- } else if (_got_to[4] || _got_to[5] || _got_to[6]) {
+ } else if (_gotTo[4] || _gotTo[5] || _gotTo[6]) {
if (_stage == 1) {
picked = 0x83;
} else {
_stage = 1;
picked = 0x6B;
}
- } else if (_got_to[7] || _got_to[8] || _got_to[9]) {
+ } else if (_gotTo[7] || _gotTo[8] || _gotTo[9]) {
if (_stage == 2) {
picked = 0xEE;
} else {
_stage = 2;
picked = 0xB6;
}
- } else if (_got_to[10] || _got_to[11] || _got_to[12]) {
+ } else if (_gotTo[10] || _gotTo[11] || _gotTo[12]) {
if (_stage == 3) {
picked = 0x0132;
} else {
_stage = 3;
picked = 0x0109;
}
- } else if (_got_to[13] != 0) {
+ } else if (_gotTo[13] != 0) {
_stage = 13;
_stage = 4;
picked = 0x017F;
} else {
picked = 0x21;
}
- _cur_scene = Common::String::format("scene%d", picked);
+ _curScene = Common::String::format("scene%d", picked);
}
// Script functions: WepDwn
-void GameDrugWars::_scene_default_wepdwn(Scene *scene) {
+void GameDrugWars::sceneDefaultWepdwn(Scene *scene) {
_shots = 10;
}
// Debug methods
-void GameDrugWars::debug_warpTo(int val) {
+void GameDrugWars::debugWarpTo(int val) {
// TODO implement
}
@@ -1017,7 +1012,7 @@ bool DebuggerDrugWars::cmdWarpTo(int argc, const char **argv) {
return true;
} else {
int val = atoi(argv[1]);
- _game->debug_warpTo(val);
+ _game->debugWarpTo(val);
return false;
}
}
diff --git a/engines/alg/game_drugwars.h b/engines/alg/game_drugwars.h
index f74e3f79f53..c8a3ddc52e5 100644
--- a/engines/alg/game_drugwars.h
+++ b/engines/alg/game_drugwars.h
@@ -50,10 +50,10 @@ class GameDrugWars : public Game {
};
public:
- GameDrugWars(AlgEngine *vm, const ADGameDescription *desc);
+ GameDrugWars(AlgEngine *vm, const AlgGameDescription *gd);
~GameDrugWars();
Common::Error run();
- void debug_warpTo(int val);
+ void debugWarpTo(int val);
private:
void init();
@@ -82,115 +82,115 @@ private:
Graphics::Surface _bulletholeIcon;
// constants
- const int16 _random_scenes0[7] = {0x29, 0x2B, 0x2D, 0x2F, 0x31, 0x33, 0};
- const int16 _random_scenes1[6] = {0x37, 0x39, 0x3B, 0x3D, 0x3F, 0};
- const int16 _random_scenes4[8] = {0xA8, 0xAA, 0xAC, 0xAE, 0xB0, 0xB2, 0xB4, 0};
- const int16 _random_scenes8[8] = {0xC0, 0xC2, 0xC4, 0xC6, 0xC8, 0xCA, 0xCC, 0};
- const int16 _random_scenes9[6] = {0xFE, 0x0100, 0x0102, 0x01A3, 0x0105, 0};
- const int16 _random_scenes10[8] = {0x0161, 0x0163, 0x0165, 0x0167, 0x016A, 0x016C, 0x016E, 0};
- const int16 _random_scenes11[9] = {0x010B, 0x010D, 0x010F, 0x0111, 0x0113, 0x0115, 0x0117, 0x0119, 0};
- const int16 _random_scenes12[10] = {0x014C, 0x014E, 0x0150, 0x0152, 0x0154, 0x0156, 0x0158, 0x015A, 0x015C, 0};
+ const int16 _randomScenes0[7] = {0x29, 0x2B, 0x2D, 0x2F, 0x31, 0x33, 0};
+ const int16 _randomScenes1[6] = {0x37, 0x39, 0x3B, 0x3D, 0x3F, 0};
+ const int16 _randomScenes4[8] = {0xA8, 0xAA, 0xAC, 0xAE, 0xB0, 0xB2, 0xB4, 0};
+ const int16 _randomScenes8[8] = {0xC0, 0xC2, 0xC4, 0xC6, 0xC8, 0xCA, 0xCC, 0};
+ const int16 _randomScenes9[6] = {0xFE, 0x0100, 0x0102, 0x01A3, 0x0105, 0};
+ const int16 _randomScenes10[8] = {0x0161, 0x0163, 0x0165, 0x0167, 0x016A, 0x016C, 0x016E, 0};
+ const int16 _randomScenes11[9] = {0x010B, 0x010D, 0x010F, 0x0111, 0x0113, 0x0115, 0x0117, 0x0119, 0};
+ const int16 _randomScenes12[10] = {0x014C, 0x014E, 0x0150, 0x0152, 0x0154, 0x0156, 0x0158, 0x015A, 0x015C, 0};
- const int16 *_random_scenes[14] = {_random_scenes0, _random_scenes1, nullptr, nullptr, _random_scenes4, nullptr, nullptr, nullptr,
- _random_scenes8, _random_scenes9, _random_scenes10, _random_scenes11, _random_scenes12, nullptr};
- const uint8 _random_scenes_difficulty[14] = {6, 4, 0, 0, 6, 0, 0, 0, 5, 6, 7, 8, 8, 0};
- const uint16 _random_scenes_continue[14] = {0x51, 0x41, 0, 0, 0x01B5, 0, 0, 0, 0xCE, 0x0107, 0x0170, 0x011B, 0x015E, 0};
+ const int16 *_randomScenes[14] = {_randomScenes0, _randomScenes1, nullptr, nullptr, _randomScenes4, nullptr, nullptr, nullptr,
+ _randomScenes8, _randomScenes9, _randomScenes10, _randomScenes11, _randomScenes12, nullptr};
+ const uint8 _randomScenesDifficulty[14] = {6, 4, 0, 0, 6, 0, 0, 0, 5, 6, 7, 8, 8, 0};
+ const uint16 _randomScenesContinue[14] = {0x51, 0x41, 0, 0, 0x01B5, 0, 0, 0, 0xCE, 0x0107, 0x0170, 0x011B, 0x015E, 0};
- const int16 _died_scenes_stage0[4] = {0x52, 0x53, 0x54, 0};
- const int16 _died_scenes_stage1[5] = {0x85, 0x86, 0x88, 0x89, 0};
- const int16 _died_scenes_stage2[3] = {0xEF, 0xF0, 0};
- const int16 _died_scenes_stage3[3] = {0x0135, 0x0136, 0};
- const int16 _died_scenes_stage4[3] = {0x0135, 0x0136, 0};
+ const int16 _diedScenesStage0[4] = {0x52, 0x53, 0x54, 0};
+ const int16 _diedScenesStage1[5] = {0x85, 0x86, 0x88, 0x89, 0};
+ const int16 _diedScenesStage2[3] = {0xEF, 0xF0, 0};
+ const int16 _diedScenesStage3[3] = {0x0135, 0x0136, 0};
+ const int16 _diedScenesStage4[3] = {0x0135, 0x0136, 0};
- const int16 *_died_scenes_by_stage[5] = {_died_scenes_stage0, _died_scenes_stage1, _died_scenes_stage2, _died_scenes_stage3, _died_scenes_stage4};
+ const int16 *_diedScenesByStage[5] = {_diedScenesStage0, _diedScenesStage1, _diedScenesStage2, _diedScenesStage3, _diedScenesStage4};
- uint16 _dead_scenes[5] = {0x56, 0x8A, 0xF2, 0x0134, 0x0134};
+ uint16 _deadScenes[5] = {0x56, 0x8A, 0xF2, 0x0134, 0x0134};
- const uint16 _stage_start_scenes[5] = {0x51, 0x83, 0xEE, 0x0132, 0x017F};
+ const uint16 _stageStartScenes[5] = {0x51, 0x83, 0xEE, 0x0132, 0x017F};
- const uint16 _scenario_start_scenes[14] = {0x27, 0x36, 0x4A, 0x57, 0x9D, 0x8B, 0x74, 0xD8, 0xBF, 0xB8, 0x0160, 0x010A, 0x0137, 0x017F};
+ const uint16 _scenarioStartScenes[14] = {0x27, 0x36, 0x4A, 0x57, 0x9D, 0x8B, 0x74, 0xD8, 0xBF, 0xB8, 0x0160, 0x010A, 0x0137, 0x017F};
bool _isDemo = 0;
// gamestate
uint8 _continues = 0;
- uint16 _got_to[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- int8 _got_to_index = 0;
+ uint16 _gotTo[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ int8 _gotToIndex = 0;
int8 _stage = 0;
- int8 _old_stage = -1;
- uint8 _random_scene_count = 0;
- uint8 _random_max = 0;
- uint16 _random_mask = 0;
- uint16 _random_picked = 0;
- uint16 _death_mask = 0;
- int16 _death_picked = 0;
- uint8 _death_scene_count = 0;
- uint16 _final_stage_scene = _stage_start_scenes[4];
+ int8 _oldStage = -1;
+ uint8 _randomSceneCount = 0;
+ uint8 _randomMax = 0;
+ uint16 _randomMask = 0;
+ uint16 _randomPicked = 0;
+ uint16 _deathMask = 0;
+ int16 _deathPicked = 0;
+ uint8 _deathSceneCount = 0;
+ uint16 _finalStageScene = _stageStartScenes[4];
// base functions
- void _NewGame();
- void _ResetParams();
- void _DoMenu();
- void _ChangeDifficulty(uint8 newDifficulty);
- void _ShowDifficulty(uint8 newDifficulty, bool updateCursor);
- void _DoCursor();
- void _UpdateMouse();
- void _MoveMouse();
- void _DisplayLivesLeft();
- void _DisplayScores();
- void _DisplayShotsLeft();
- bool _WeaponDown();
- bool _SaveState();
- bool _LoadState();
+ void newGame();
+ void resetParams();
+ void doMenu();
+ void changeDifficulty(uint8 newDifficulty);
+ void showDifficulty(uint8 newDifficulty, bool updateCursor);
+ void updateCursor();
+ void updateMouse();
+ void moveMouse();
+ void displayLivesLeft();
+ void displayScores();
+ void displayShotsLeft();
+ bool weaponDown();
+ bool saveState();
+ bool loadState();
// misc game functions
- void _DisplayShotFiredImage(Common::Point *point);
- void _EnableVideoFadeIn();
- uint16 _SceneToNumber(Scene *scene);
- uint16 _RandomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
- uint16 _PickRandomScene(uint8 index, uint8 max);
- uint16 _PickDeathScene();
- void _scene_nxtscn_generic(uint8 index);
- void _rect_select_generic(uint8 index);
+ void displayShotFiredImage(Common::Point *point);
+ void enableVideoFadeIn();
+ uint16 sceneToNumber(Scene *scene);
+ uint16 randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
+ uint16 pickRandomScene(uint8 index, uint8 max);
+ uint16 pickDeathScene();
+ void sceneNxtscnGeneric(uint8 index);
+ void rectSelectGeneric(uint8 index);
// Script functions: RectHit
- void _rect_shotmenu(Rect *rect);
- void _rect_save(Rect *rect);
- void _rect_load(Rect *rect);
- void _rect_continue(Rect *rect);
- void _rect_start(Rect *rect);
- void _rect_select_target_practice(Rect *rect);
- void _rect_select_bar(Rect *rect);
- void _rect_select_car_chase(Rect *rect);
- void _rect_select_drug_house(Rect *rect);
- void _rect_select_office(Rect *rect);
- void _rect_select_court(Rect *rect);
- void _rect_select_bus(Rect *rect);
- void _rect_select_docks(Rect *rect);
- void _rect_select_house_boat(Rect *rect);
- void _rect_select_party(Rect *rect);
- void _rect_select_airport(Rect *rect);
- void _rect_select_mansion(Rect *rect);
- void _rect_select_village(Rect *rect);
+ void rectShotMenu(Rect *rect);
+ void rectSave(Rect *rect);
+ void rectLoad(Rect *rect);
+ void rectContinue(Rect *rect);
+ void rectStart(Rect *rect);
+ void rectSelectTargetPractice(Rect *rect);
+ void rectSelectBar(Rect *rect);
+ void rectSelectCarChase(Rect *rect);
+ void rectSelectDrugHouse(Rect *rect);
+ void rectSelectOffice(Rect *rect);
+ void rectSelectCourt(Rect *rect);
+ void rectSelectBus(Rect *rect);
+ void rectSelectDocks(Rect *rect);
+ void rectSelectHouseBoat(Rect *rect);
+ void rectSelectParty(Rect *rect);
+ void rectSelectAirport(Rect *rect);
+ void rectSelectMansion(Rect *rect);
+ void rectSelectVillage(Rect *rect);
// Script functions: Scene PreOps
- void _scene_pso_got_to(Scene *scene);
+ void scenePsoGotTo(Scene *scene);
// Script functions: Scene NxtScn
- void _scene_nxtscn_game_won(Scene *scene);
- void _scene_nxtscn_lose_a_life(Scene *scene);
- void _scene_nxtscn_continue_game(Scene *scene);
- void _scene_nxtscn_did_not_continue(Scene *scene);
- void _scene_nxtscn_kill_innocent_man(Scene *scene);
- void _scene_nxtscn_kill_innocent_woman(Scene *scene);
- void _scene_nxtscn_after_die(Scene *scene);
- void _scene_nxtscn_init_random(Scene *scene);
- void _scene_nxtscn_continue_random(Scene *scene);
- void _scene_nxtscn_select_scenario(Scene *scene);
- void _scene_nxtscn_finish_scenario(Scene *scene);
+ void sceneNxtscnGameWon(Scene *scene);
+ void sceneNxtscnLoseALife(Scene *scene);
+ void sceneNxtscnContinueGame(Scene *scene);
+ void sceneNxtscnDidNotContinue(Scene *scene);
+ void sceneNxtscnKillInnocentMan(Scene *scene);
+ void sceneNxtscnKillInnocentWoman(Scene *scene);
+ void sceneNxtscnAfterDie(Scene *scene);
+ void sceneNxtscnInitRandom(Scene *scene);
+ void sceneNxtscnContinueRandom(Scene *scene);
+ void sceneNxtscnSelectScenario(Scene *scene);
+ void sceneNxtscnFinishScenario(Scene *scene);
// Script functions: Scene WepDwn
- void _scene_default_wepdwn(Scene *scene);
+ void sceneDefaultWepdwn(Scene *scene);
};
class DebuggerDrugWars : public GUI::Debugger {
diff --git a/engines/alg/game_johnnyrock.cpp b/engines/alg/game_johnnyrock.cpp
index 5193bcfa127..fa8fae76567 100644
--- a/engines/alg/game_johnnyrock.cpp
+++ b/engines/alg/game_johnnyrock.cpp
@@ -25,7 +25,6 @@
#include "common/system.h"
#include "graphics/cursorman.h"
-#include "graphics/pixelformat.h"
#include "alg/game_johnnyrock.h"
#include "alg/graphics.h"
@@ -33,10 +32,10 @@
namespace Alg {
-GameJohnnyRock::GameJohnnyRock(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
- if (scumm_stricmp(desc->gameId, "johnrocs") == 0) {
+GameJohnnyRock::GameJohnnyRock(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
+ if (gd->gameType == GType_JOHNROC_SS_DOS) {
_libFileName = "johnroc.lib";
- } else if (scumm_stricmp(desc->gameId, "johnrocd") == 0) {
+ } else if (gd->gameType == GType_JOHNROC_DS_DOS) {
_libFileName = "johnrocd.lib";
}
}
@@ -45,27 +44,29 @@ GameJohnnyRock::~GameJohnnyRock() {
}
void GameJohnnyRock::init() {
+ Game::init();
+
_videoPosX = 11;
_videoPosY = 2;
- _SetupCursorTimer();
+ setupCursorTimer();
loadLibArchive(_libFileName);
_sceneInfo->loadScnFile("johnroc.scn");
- _startscene = _sceneInfo->getStartScene();
+ _startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
_menuzone = new Zone();
- _menuzone->name = "MainMenu";
- _menuzone->ptrfb = "GLOBALHIT";
+ _menuzone->_name = "MainMenu";
+ _menuzone->_ptrfb = "GLOBALHIT";
_menuzone->addRect(0x0C, 0xBB, 0x3C, 0xC7, nullptr, 0, "SHOTMENU", "0");
_submenzone = new Zone();
- _submenzone->name = "SubMenu";
- _submenzone->ptrfb = "GLOBALHIT";
+ _submenzone->_name = "SubMenu";
+ _submenzone->_ptrfb = "GLOBALHIT";
_submenzone->addRect(0x10, 0x0F, 0x78, 0x34, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x10, 0x8E, 0x8A, 0xAF, nullptr, 0, "CONTMENU", "0");
@@ -76,11 +77,11 @@ void GameJohnnyRock::init() {
_submenzone->addRect(0xD2, 0x50, 0x125, 0x6B, nullptr, 0, "RECTAVG", "0");
_submenzone->addRect(0xD2, 0x6D, 0x122, 0x86, nullptr, 0, "RECTHARD", "0");
- _shotSound = _LoadSoundFile("blow.8b");
- _emptySound = _LoadSoundFile("empty.8b");
- _saveSound = _LoadSoundFile("saved.8b");
- _loadSound = _LoadSoundFile("loaded.8b");
- _skullSound = _LoadSoundFile("money.8b");
+ _shotSound = loadSoundFile("blow.8b");
+ _emptySound = loadSoundFile("empty.8b");
+ _saveSound = loadSoundFile("saved.8b");
+ _loadSound = loadSoundFile("loaded.8b");
+ _skullSound = loadSoundFile("money.8b");
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
@@ -93,159 +94,159 @@ void GameJohnnyRock::init() {
_background = AlgGraphics::loadVgaBackground("backgrnd.vga", _palette);
_screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
- _MoveMouse();
+ moveMouse();
}
void GameJohnnyRock::registerScriptFunctions() {
#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new JRScriptFunctionRect(this, &GameJohnnyRock::func);
- RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
- RECT_HIT_FUNCTION("NEWSCENE", _rect_newscene);
- RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
- RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
- RECT_HIT_FUNCTION("STARTMENU", _rect_start);
- RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
- RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
- RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
- RECT_HIT_FUNCTION("RECTEASY", _rect_easy);
- RECT_HIT_FUNCTION("RECTAVG", _rect_average);
- RECT_HIT_FUNCTION("RECTHARD", _rect_hard);
- RECT_HIT_FUNCTION("KILLINNOCENT", _rect_killinnocent);
- RECT_HIT_FUNCTION("SELCASINO", _rect_selectcasino);
- RECT_HIT_FUNCTION("SELPOOLH", _rect_selectpoolhall);
- RECT_HIT_FUNCTION("SELWAREHSE", _rect_selectwarehouse);
- RECT_HIT_FUNCTION("SELGARAGE", _rect_selectgarage);
- RECT_HIT_FUNCTION("SELMANSION", _rect_selectmansion);
- RECT_HIT_FUNCTION("SELAMMO", _rect_selectammo);
- RECT_HIT_FUNCTION("SELOFFICE", _rect_selectoffice);
- RECT_HIT_FUNCTION("MANBUST", _rect_shotmanbust);
- RECT_HIT_FUNCTION("WOMANBUST", _rect_shotwomanbust);
- RECT_HIT_FUNCTION("BLUEVASE", _rect_shotbluevase);
- RECT_HIT_FUNCTION("CAT", _rect_shotcat);
- RECT_HIT_FUNCTION("INDIAN", _rect_shotindian);
- RECT_HIT_FUNCTION("PLATE", _rect_shotplate);
- RECT_HIT_FUNCTION("BLUEDRESSPIC", _rect_shotbluedresspic);
- RECT_HIT_FUNCTION("MODERNPIC", _rect_shotmodernpic);
- RECT_HIT_FUNCTION("MONALISA", _rect_shotmonalisa);
- RECT_HIT_FUNCTION("GWASHINGTON", _rect_shotgwashington);
- RECT_HIT_FUNCTION("BOYINREDPIC", _rect_shotboyinredpic);
- RECT_HIT_FUNCTION("COATOFARMS", _rect_shotcoatofarms);
- RECT_HIT_FUNCTION("COMBNOA0", _rect_shotcombinationA0);
- RECT_HIT_FUNCTION("COMBNOA1", _rect_shotcombinationA1);
- RECT_HIT_FUNCTION("COMBNOA2", _rect_shotcombinationA2);
- RECT_HIT_FUNCTION("COMBNOA3", _rect_shotcombinationA3);
- RECT_HIT_FUNCTION("COMBNOA4", _rect_shotcombinationA4);
- RECT_HIT_FUNCTION("COMBNOA5", _rect_shotcombinationA5);
- RECT_HIT_FUNCTION("COMBNOB0", _rect_shotcombinationB0);
- RECT_HIT_FUNCTION("COMBNOB1", _rect_shotcombinationB1);
- RECT_HIT_FUNCTION("COMBNOB2", _rect_shotcombinationB2);
- RECT_HIT_FUNCTION("COMBNOB3", _rect_shotcombinationB3);
- RECT_HIT_FUNCTION("COMBNOB4", _rect_shotcombinationB4);
- RECT_HIT_FUNCTION("COMBNOB5", _rect_shotcombinationB5);
- RECT_HIT_FUNCTION("LUCKNO0", _rect_shotluckynum0);
- RECT_HIT_FUNCTION("LUCKNO1", _rect_shotluckynum1);
- RECT_HIT_FUNCTION("LUCKNO2", _rect_shotluckynum2);
- RECT_HIT_FUNCTION("LUCKNO3", _rect_shotluckynum3);
- RECT_HIT_FUNCTION("LUCKNO4", _rect_shotluckynum4);
- RECT_HIT_FUNCTION("LUCKNO5", _rect_shotluckynum5);
+ RECT_HIT_FUNCTION("DEFAULT", rectNewScene);
+ RECT_HIT_FUNCTION("NEWSCENE", rectNewScene);
+ RECT_HIT_FUNCTION("EXITMENU", rectExit);
+ RECT_HIT_FUNCTION("CONTMENU", rectContinue);
+ RECT_HIT_FUNCTION("STARTMENU", rectStart);
+ RECT_HIT_FUNCTION("SHOTMENU", rectShotMenu);
+ RECT_HIT_FUNCTION("RECTSAVE", rectSave);
+ RECT_HIT_FUNCTION("RECTLOAD", rectLoad);
+ RECT_HIT_FUNCTION("RECTEASY", rectEasy);
+ RECT_HIT_FUNCTION("RECTAVG", rectAverage);
+ RECT_HIT_FUNCTION("RECTHARD", rectHard);
+ RECT_HIT_FUNCTION("KILLINNOCENT", rectKillInnocent);
+ RECT_HIT_FUNCTION("SELCASINO", rectSelectCasino);
+ RECT_HIT_FUNCTION("SELPOOLH", rectSelectPoolhall);
+ RECT_HIT_FUNCTION("SELWAREHSE", rectSelectWarehouse);
+ RECT_HIT_FUNCTION("SELGARAGE", rectSelectGarage);
+ RECT_HIT_FUNCTION("SELMANSION", rectSelectMansion);
+ RECT_HIT_FUNCTION("SELAMMO", rectSelectAmmo);
+ RECT_HIT_FUNCTION("SELOFFICE", rectSelectOffice);
+ RECT_HIT_FUNCTION("MANBUST", rectShotManBust);
+ RECT_HIT_FUNCTION("WOMANBUST", rectShotWomanBust);
+ RECT_HIT_FUNCTION("BLUEVASE", rectShotBlueVase);
+ RECT_HIT_FUNCTION("CAT", rectShotCat);
+ RECT_HIT_FUNCTION("INDIAN", rectShotIndian);
+ RECT_HIT_FUNCTION("PLATE", rectShotPlate);
+ RECT_HIT_FUNCTION("BLUEDRESSPIC", rectShotBlueDressPic);
+ RECT_HIT_FUNCTION("MODERNPIC", rectShotModernPic);
+ RECT_HIT_FUNCTION("MONALISA", rectShotMonaLisa);
+ RECT_HIT_FUNCTION("GWASHINGTON", rectShotGWashington);
+ RECT_HIT_FUNCTION("BOYINREDPIC", rectShotBoyInRedPic);
+ RECT_HIT_FUNCTION("COATOFARMS", rectShotCoatOfArms);
+ RECT_HIT_FUNCTION("COMBNOA0", rectShotCombinationA0);
+ RECT_HIT_FUNCTION("COMBNOA1", rectShotCombinationA1);
+ RECT_HIT_FUNCTION("COMBNOA2", rectShotCombinationA2);
+ RECT_HIT_FUNCTION("COMBNOA3", rectShotCombinationA3);
+ RECT_HIT_FUNCTION("COMBNOA4", rectShotCombinationA4);
+ RECT_HIT_FUNCTION("COMBNOA5", rectShotCombinationA5);
+ RECT_HIT_FUNCTION("COMBNOB0", rectShotCombinationB0);
+ RECT_HIT_FUNCTION("COMBNOB1", rectShotCombinationB1);
+ RECT_HIT_FUNCTION("COMBNOB2", rectShotCombinationB2);
+ RECT_HIT_FUNCTION("COMBNOB3", rectShotCombinationB3);
+ RECT_HIT_FUNCTION("COMBNOB4", rectShotCombinationB4);
+ RECT_HIT_FUNCTION("COMBNOB5", rectShotCombinationB5);
+ RECT_HIT_FUNCTION("LUCKNO0", rectShotLuckyNumber0);
+ RECT_HIT_FUNCTION("LUCKNO1", rectShotLuckyNumber1);
+ RECT_HIT_FUNCTION("LUCKNO2", rectShotLuckyNumber2);
+ RECT_HIT_FUNCTION("LUCKNO3", rectShotLuckyNumber3);
+ RECT_HIT_FUNCTION("LUCKNO4", rectShotLuckyNumber4);
+ RECT_HIT_FUNCTION("LUCKNO5", rectShotLuckyNumber5);
#undef RECT_HIT_FUNCTION
#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new JRScriptFunctionScene(this, &GameJohnnyRock::func);
- PRE_OPS_FUNCTION("DRAWRCT", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
- PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
- PRE_OPS_FUNCTION("PAUSFI", _scene_pso_pause_fadein);
- PRE_OPS_FUNCTION("PREREAD", _scene_pso_preread);
- PRE_OPS_FUNCTION("PAUSPR", _scene_pso_pause_preread);
- PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("DRAWRCTFDI", _scene_pso_drawrct_fadein);
+ PRE_OPS_FUNCTION("DRAWRCT", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("PAUSE", scenePsoPause);
+ PRE_OPS_FUNCTION("FADEIN", scenePsoFadeIn);
+ PRE_OPS_FUNCTION("PAUSFI", scenePsoPauseFadeIn);
+ PRE_OPS_FUNCTION("PREREAD", scenePsoPreRead);
+ PRE_OPS_FUNCTION("PAUSPR", scenePsoPausePreRead);
+ PRE_OPS_FUNCTION("DEFAULT", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("DRAWRCTFDI", scenePsoDrawRctFadeIn);
#undef PRE_OPS_FUNCTION
#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new JRScriptFunctionScene(this, &GameJohnnyRock::func);
- INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
- INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
- INS_OPS_FUNCTION("SPAUSE", _scene_iso_spause);
- INS_OPS_FUNCTION("STARTGAME", _scene_iso_startgame);
- INS_OPS_FUNCTION("SHOOTPAST", _scene_iso_shootpast);
- INS_OPS_FUNCTION("GOTTOCASINO", _scene_iso_gotocasino);
- INS_OPS_FUNCTION("GOTTOPOOLH", _scene_iso_gotopoolh);
- INS_OPS_FUNCTION("GOTTOWAREHSE", _scene_iso_gotowarehse);
- INS_OPS_FUNCTION("INWAREHSE2", _scene_iso_inwarehse2);
- INS_OPS_FUNCTION("INWAREHSE3", _scene_iso_inwarehse3);
- INS_OPS_FUNCTION("GOTOGARAGE", _scene_iso_gotogarage);
- INS_OPS_FUNCTION("GOTOMANSION", _scene_iso_gotomansion);
- INS_OPS_FUNCTION("INMANSION1", _scene_iso_inmansion1);
+ INS_OPS_FUNCTION("DEFAULT", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("PAUSE", sceneIsoPause);
+ INS_OPS_FUNCTION("SPAUSE", sceneIsoShootpastPause);
+ INS_OPS_FUNCTION("STARTGAME", sceneIsoStartGame);
+ INS_OPS_FUNCTION("SHOOTPAST", sceneIsoShootpast);
+ INS_OPS_FUNCTION("GOTTOCASINO", sceneIsoGotoCasino);
+ INS_OPS_FUNCTION("GOTTOPOOLH", sceneIsoGotoPoolhall);
+ INS_OPS_FUNCTION("GOTTOWAREHSE", sceneIsoGotoWarehouse);
+ INS_OPS_FUNCTION("INWAREHSE2", sceneIsoInWarehouse2);
+ INS_OPS_FUNCTION("INWAREHSE3", sceneIsoInwarehouse3);
+ INS_OPS_FUNCTION("GOTOGARAGE", sceneIsoGotoGarage);
+ INS_OPS_FUNCTION("GOTOMANSION", sceneIsoGotoMansion);
+ INS_OPS_FUNCTION("INMANSION1", sceneIsoInMansion1);
#undef INS_OPS_FUNCTION
#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new JRScriptFunctionScene(this, &GameJohnnyRock::func);
- NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
- NXT_SCN_FUNCTION("DRAWGUN", _scene_default_nxtscn);
- NXT_SCN_FUNCTION("DIED", _scene_nxtscn_died);
- NXT_SCN_FUNCTION("BOMBDEAD", _scene_nxtscn_bombdead);
- NXT_SCN_FUNCTION("PIKUNDRTAKR", _scene_nxtscn_pikundrtakr);
- NXT_SCN_FUNCTION("CALLATTRACT", _scene_nxtscn_callattract);
- NXT_SCN_FUNCTION("PICKLUCKNO", _scene_nxtscn_pikluckno);
- NXT_SCN_FUNCTION("PICKMAP", _scene_nxtscn_pickmap);
- NXT_SCN_FUNCTION("PICKCLUE", _scene_nxtscn_pickclue);
- NXT_SCN_FUNCTION("MAPTIMEOUT", _scene_nxtscn_maptimeout);
- NXT_SCN_FUNCTION("ENTCASINO", _scene_nxtscn_entcasino);
- NXT_SCN_FUNCTION("CASINOWHAT?", _scene_nxtscn_casinowhat);
- NXT_SCN_FUNCTION("ENTPOOLH", _scene_nxtscn_entpoolhall);
- NXT_SCN_FUNCTION("POOLHCLUE", _scene_nxtscn_poolhclue);
- NXT_SCN_FUNCTION("ENTWAREHSE", _scene_nxtscn_entwarehse);
- NXT_SCN_FUNCTION("WAREHSECLUE", _scene_nxtscn_warehseclue);
- NXT_SCN_FUNCTION("ENTGARAGE", _scene_nxtscn_entgarage);
- NXT_SCN_FUNCTION("GARAGECLUE", _scene_nxtscn_garageclue);
- NXT_SCN_FUNCTION("ENTMANSION", _scene_nxtscn_entmansion);
- NXT_SCN_FUNCTION("GIVECLUE", _scene_nxtscn_giveclue);
- NXT_SCN_FUNCTION("PICKFLOWERMAN", _scene_nxtscn_pikflwrman);
- NXT_SCN_FUNCTION("RANDOMSCENE", _scene_nxtscn_randomscene);
- NXT_SCN_FUNCTION("ENDRANDSCENE", _scene_nxtscn_endrandscene);
- NXT_SCN_FUNCTION("SCN_KILLINNOCENT", _scene_nxtscn_killinnocent);
+ NXT_SCN_FUNCTION("DEFAULT", sceneDefaultNxtscn);
+ NXT_SCN_FUNCTION("DRAWGUN", sceneDefaultNxtscn);
+ NXT_SCN_FUNCTION("DIED", sceneNxtscnDied);
+ NXT_SCN_FUNCTION("BOMBDEAD", sceneNxtscnBombDead);
+ NXT_SCN_FUNCTION("PIKUNDRTAKR", sceneNxtscnPickUndertaker);
+ NXT_SCN_FUNCTION("CALLATTRACT", sceneNxtscnCallAttract);
+ NXT_SCN_FUNCTION("PICKLUCKNO", sceneNxtscnPickLuckyNumber);
+ NXT_SCN_FUNCTION("PICKMAP", sceneNxtscnPickMap);
+ NXT_SCN_FUNCTION("PICKCLUE", sceneNxtscnPickClue);
+ NXT_SCN_FUNCTION("MAPTIMEOUT", sceneNxtscnMapTimeout);
+ NXT_SCN_FUNCTION("ENTCASINO", sceneNxtscnEnterCasino);
+ NXT_SCN_FUNCTION("CASINOWHAT?", sceneNxtscnCasinoWhat);
+ NXT_SCN_FUNCTION("ENTPOOLH", sceneNxtscnEnterPoolhall);
+ NXT_SCN_FUNCTION("POOLHCLUE", sceneNxtscnPoolhallClue);
+ NXT_SCN_FUNCTION("ENTWAREHSE", sceneNxtscnEnterWarehouse);
+ NXT_SCN_FUNCTION("WAREHSECLUE", sceneNxtscnWarehouseClue);
+ NXT_SCN_FUNCTION("ENTGARAGE", sceneNxtscnEnterGarage);
+ NXT_SCN_FUNCTION("GARAGECLUE", sceneNxtscnGarageClue);
+ NXT_SCN_FUNCTION("ENTMANSION", sceneNxtscnEnterMansion);
+ NXT_SCN_FUNCTION("GIVECLUE", sceneNxtscnGiveClue);
+ NXT_SCN_FUNCTION("PICKFLOWERMAN", sceneNxtscnPickFlowerMan);
+ NXT_SCN_FUNCTION("RANDOMSCENE", sceneNxtscnRandomScene);
+ NXT_SCN_FUNCTION("ENDRANDSCENE", sceneNxtscnEndRandScene);
+ NXT_SCN_FUNCTION("SCN_KILLINNOCENT", sceneNxtscnKillInnocent);
#undef NXT_SCN_FUNCTION
- _zonePtrFb["DEFAULT"] = new JRScriptFunctionPoint(this, &GameJohnnyRock::_zone_bullethole);
- _sceneShowMsg["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::_scene_sm_donothing);
- _sceneWepDwn["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::_scene_default_wepdwn);
- _sceneScnScr["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::_scene_default_score);
- _sceneNxtFrm["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::_scene_nxtfrm);
+ _zonePtrFb["DEFAULT"] = new JRScriptFunctionPoint(this, &GameJohnnyRock::zoneBullethole);
+ _sceneShowMsg["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::sceneSmDonothing);
+ _sceneWepDwn["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::sceneDefaultWepdwn);
+ _sceneScnScr["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::sceneDefaultScore);
+ _sceneNxtFrm["DEFAULT"] = new JRScriptFunctionScene(this, &GameJohnnyRock::sceneNxtfrm);
}
void GameJohnnyRock::verifyScriptFunctions() {
Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
for (size_t i = 0; i < scenes->size(); i++) {
Scene *scene = (*scenes)[i];
- getScriptFunctionScene(PREOP, scene->preop);
+ getScriptFunctionScene(PREOP, scene->_preop);
// TODO: SHOWMSG
- getScriptFunctionScene(INSOP, scene->insop);
- getScriptFunctionScene(WEPDWN, scene->wepdwn);
- getScriptFunctionScene(SCNSCR, scene->scnscr);
- getScriptFunctionScene(NXTFRM, scene->nxtfrm);
- getScriptFunctionScene(NXTSCN, scene->nxtscn);
- for (size_t j = 0; j < scene->zones.size(); j++) {
- Zone *zone = scene->zones[j];
- getScriptFunctionZonePtrFb(zone->ptrfb);
- for (size_t k = 0; k < zone->rects.size(); k++) {
- getScriptFunctionRectHit(zone->rects[k].rectHit);
+ getScriptFunctionScene(INSOP, scene->_insop);
+ getScriptFunctionScene(WEPDWN, scene->_wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->_scnscr);
+ getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->_nxtscn);
+ for (size_t j = 0; j < scene->_zones.size(); j++) {
+ Zone *zone = scene->_zones[j];
+ getScriptFunctionZonePtrFb(zone->_ptrfb);
+ for (size_t k = 0; k < zone->_rects.size(); k++) {
+ getScriptFunctionRectHit(zone->_rects[k]._rectHit);
}
}
}
}
JRScriptFunctionPoint GameJohnnyRock::getScriptFunctionZonePtrFb(Common::String name) {
- JRScriptFunctionPointMap::iterator it = _zonePtrFb.find(name);
+ auto it = _zonePtrFb.find(name);
if (it != _zonePtrFb.end()) {
return (*(*it)._value);
} else {
- error("Could not find zonePtrFb function: %s", name.c_str());
+ error("GameJohnnyRock::getScriptFunctionZonePtrFb(): Could not find zonePtrFb function: %s", name.c_str());
}
}
JRScriptFunctionRect GameJohnnyRock::getScriptFunctionRectHit(Common::String name) {
- JRScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ auto it = _rectHitFuncs.find(name);
if (it != _rectHitFuncs.end()) {
return (*(*it)._value);
} else {
- error("Could not find rectHit function: %s", name.c_str());
+ error("GameJohnnyRock::getScriptFunctionRectHit(): Could not find rectHit function: %s", name.c_str());
}
}
@@ -274,7 +275,7 @@ JRScriptFunctionScene GameJohnnyRock::getScriptFunctionScene(SceneFuncType type,
functionMap = &_sceneNxtScn;
break;
default:
- error("Unkown scene script type: %u", type);
+ error("GameJohnnyRock::getScriptFunctionScene(): Unkown scene script type: %u", type);
break;
}
JRScriptFunctionSceneMap::iterator it;
@@ -282,7 +283,7 @@ JRScriptFunctionScene GameJohnnyRock::getScriptFunctionScene(SceneFuncType type,
if (it != functionMap->end()) {
return (*(*it)._value);
} else {
- error("Could not find scene type %u function: %s", type, name.c_str());
+ error("GameJohnnyRock::getScriptFunctionScene(): Could not find scene type %u function: %s", type, name.c_str());
}
}
@@ -303,65 +304,62 @@ void GameJohnnyRock::callScriptFunctionScene(SceneFuncType type, Common::String
Common::Error GameJohnnyRock::run() {
init();
- _NewGame();
- _cur_scene = _startscene;
+ newGame();
+ _curScene = _startScene;
Common::String oldscene;
while (!_vm->shouldQuit()) {
_leftDown = false;
- oldscene = _cur_scene;
- _SetFrame();
+ oldscene = _curScene;
_fired = false;
- Scene *scene = _sceneInfo->findScene(_cur_scene);
+ Scene *scene = _sceneInfo->findScene(_curScene);
if (!loadScene(scene)) {
- error("Cannot find scene %s in libfile", scene->name.c_str());
+ error("GameJohnnyRock::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
g_system->getMixer()->stopHandle(_sceneAudioHandle);
g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
- _nextFrameTime = _GetMsTime() + 100;
- callScriptFunctionScene(PREOP, scene->preop, scene);
- _currentFrame = _GetFrame(scene);
- while (_currentFrame <= scene->endFrame && _cur_scene == oldscene && !_vm->shouldQuit()) {
- _UpdateMouse();
+ _nextFrameTime = getMsTime() + 100;
+ callScriptFunctionScene(PREOP, scene->_preop, scene);
+ _currentFrame = getFrame(scene);
+ while (_currentFrame <= scene->_endFrame && _curScene == oldscene && !_vm->shouldQuit()) {
+ updateMouse();
// TODO: call scene->messageFunc
- callScriptFunctionScene(INSOP, scene->insop, scene);
- _holster = _WeaponDown();
+ callScriptFunctionScene(INSOP, scene->_insop, scene);
+ _holster = weaponDown();
if (_holster) {
- callScriptFunctionScene(WEPDWN, scene->wepdwn, scene);
+ callScriptFunctionScene(WEPDWN, scene->_wepdwn, scene);
}
Common::Point firedCoords;
- if (__Fired(&firedCoords)) {
+ if (fired(&firedCoords)) {
if (!_holster) {
- Rect *hitGlobalRect = _CheckZone(_menuzone, &firedCoords);
+ Rect *hitGlobalRect = checkZone(_menuzone, &firedCoords);
if (hitGlobalRect != nullptr) {
- callScriptFunctionRectHit(hitGlobalRect->rectHit, hitGlobalRect);
- } else {
- if (_shots > 0) {
- if (!_debug_unlimitedAmmo) {
- _shots--;
- }
- _UpdateStat();
- Rect *hitRect = nullptr;
- Zone *hitSceneZone = _CheckZonesV1(scene, hitRect, &firedCoords);
- if (hitSceneZone != nullptr) {
- callScriptFunctionZonePtrFb(hitSceneZone->ptrfb, &firedCoords);
- callScriptFunctionRectHit(hitRect->rectHit, hitRect);
- } else {
- _default_bullethole(&firedCoords);
- }
+ callScriptFunctionRectHit(hitGlobalRect->_rectHit, hitGlobalRect);
+ } else if (_shots > 0) {
+ if (!_debug_unlimitedAmmo) {
+ _shots--;
+ }
+ updateStat();
+ Rect *hitRect = nullptr;
+ Zone *hitSceneZone = checkZonesV1(scene, hitRect, &firedCoords);
+ if (hitSceneZone != nullptr) {
+ callScriptFunctionZonePtrFb(hitSceneZone->_ptrfb, &firedCoords);
+ callScriptFunctionRectHit(hitRect->_rectHit, hitRect);
} else {
- _PlaySound(_emptySound);
- _whichGun = 9;
+ defaultBullethole(&firedCoords);
}
+ } else {
+ playSound(_emptySound);
+ _whichGun = 9;
}
}
}
- if (_cur_scene == oldscene) {
- callScriptFunctionScene(NXTFRM, scene->nxtfrm, scene);
+ if (_curScene == oldscene) {
+ callScriptFunctionScene(NXTFRM, scene->_nxtfrm, scene);
}
- _DisplayScore();
- _MoveMouse();
+ displayScore();
+ moveMouse();
if (_pauseTime > 0) {
g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
} else {
@@ -370,13 +368,14 @@ Common::Error GameJohnnyRock::run() {
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
}
- int32 remainingMillis = _nextFrameTime - _GetMsTime();
+ updateScreen();
+ int32 remainingMillis = _nextFrameTime - getMsTime();
if (remainingMillis < 10) {
if (_videoDecoder->getCurrentFrame() > 0) {
_videoDecoder->getNextFrame();
}
- remainingMillis = _nextFrameTime - _GetMsTime();
- _nextFrameTime = _GetMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
+ remainingMillis = _nextFrameTime - getMsTime();
+ _nextFrameTime = getMsTime() + (remainingMillis > 0 ? remainingMillis : 0) + 100;
}
if (remainingMillis > 0) {
if (remainingMillis > 15) {
@@ -384,32 +383,31 @@ Common::Error GameJohnnyRock::run() {
}
g_system->delayMillis(remainingMillis);
}
- _currentFrame = _GetFrame(scene);
- updateScreen();
+ _currentFrame = getFrame(scene);
}
// frame limit reached or scene changed, prepare for next scene
_hadPause = false;
_pauseTime = 0;
- if (_ret_scene != "") {
- _cur_scene = _ret_scene;
- _ret_scene = "";
+ if (_retScene != "") {
+ _curScene = _retScene;
+ _retScene = "";
}
- if (_sub_scene != "") {
- _ret_scene = _sub_scene;
- _sub_scene = "";
+ if (_subScene != "") {
+ _retScene = _subScene;
+ _subScene = "";
}
- if (_cur_scene == oldscene) {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ if (_curScene == oldscene) {
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
- if (_cur_scene == "") {
+ if (_curScene == "") {
_vm->quitGame();
}
}
- _RemoveCursorTimer();
+ removeCursorTimer();
return Common::kNoError;
}
-bool GameJohnnyRock::__Fired(Common::Point *point) {
+bool GameJohnnyRock::fired(Common::Point *point) {
pollEvents();
_fired = false;
if (!_leftDown) {
@@ -420,11 +418,11 @@ bool GameJohnnyRock::__Fired(Common::Point *point) {
_leftDown = true;
}
if (_buttonDown) {
- if (_thisGameTimer - _mach_gun_timer > 3) {
+ if (_thisGameTimer - _machGunTimer > 3) {
_buttonDown = false;
- _mgun_cnt++;
- if (_mgun_cnt > 5) {
- _mgun_cnt = 0;
+ _mgunCnt++;
+ if (_mgunCnt > 5) {
+ _mgunCnt = 0;
_leftDown = false;
}
}
@@ -433,124 +431,122 @@ bool GameJohnnyRock::__Fired(Common::Point *point) {
_fired = true;
point->x = _mousePos.x;
point->y = _mousePos.y;
- _mach_gun_timer = _thisGameTimer;
+ _machGunTimer = _thisGameTimer;
_buttonDown = true;
return true;
}
-void GameJohnnyRock::_NewGame() {
- _game_money = 2000;
+void GameJohnnyRock::newGame() {
+ _gameMoney = 2000;
_shots = 400;
_score = 0;
_holster = false;
- _UpdateStat();
- _ret_scene = "";
- _sub_scene = "";
+ updateStat();
+ _retScene = "";
+ _subScene = "";
}
-void GameJohnnyRock::_ResetParams() {
- _sub_scene = "";
- _money_scene = "";
- _this_map = _rnd->getRandomNumber(2);
+void GameJohnnyRock::resetParams() {
+ _subScene = "";
+ _moneyScene = "";
+ _thisMap = _rnd->getRandomNumber(2);
_clues = 0;
- _got_this_number = 0;
- _got_this_clue = 0;
- _this_clue = 0;
+ _gotThisNumber = 0;
+ _gotThisClue = 0;
+ _thisClue = 0;
_office = 0;
_casino = 0;
- _pool_hall = 0;
+ _poolHall = 0;
_warehouse = 0;
_garage = 0;
_mansion = 0;
- _did_continue = 0;
- _this_difficulty = _difficulty - 1;
- _casino_type = _rnd->getRandomNumber(1);
- _pool_hall_type = _rnd->getRandomNumber(2);
- _warehouse_type = _rnd->getRandomNumber(2);
- _garage_type = _rnd->getRandomNumber(1);
- _map_timeout = 0;
- _ammo_again = 0;
+ _didContinue = 0;
+ _thisDifficulty = _difficulty - 1;
+ _casinoType = _rnd->getRandomNumber(1);
+ _poolHallType = _rnd->getRandomNumber(2);
+ _warehouseType = _rnd->getRandomNumber(2);
+ _garageType = _rnd->getRandomNumber(1);
+ _mapTimeout = 0;
+ _ammoAgain = 0;
_combinations[0] = _rnd->getRandomNumber(5);
_combinations[1] = _rnd->getRandomNumber(5);
_combinations[2] = _rnd->getRandomNumber(5);
_combinations[3] = _rnd->getRandomNumber(5);
- _who_did_it = _rnd->getRandomNumber(3);
- _in_warehouse = 0;
- _office_count = 0;
- _had_go_to_mansion = 0;
- _random_place_bits = 0;
- for (uint8 i = 0; i < 5; i++) {
- // this assigns places from _random_places
- uint16 picked = _pick_bits(&_random_place_bits, 6);
- _entrance_index[i] = picked;
- }
- _random_place_bits = 0;
+ _whoDidIt = _rnd->getRandomNumber(3);
+ _inWarehouse = 0;
+ _officeCount = 0;
+ _hadGoToMansion = 0;
+ _randomPlaceBits = 0;
+ for (int i = 0; i < 5; i++) {
+ // this assigns places from _randomPlaces
+ uint16 picked = pickBits(&_randomPlaceBits, 6);
+ _entranceIndex[i] = picked;
+ }
+ _randomPlaceBits = 0;
for (uint8 i = 5; i < 19; i++) {
- // this assigns places from _random_places_mr
- uint16 picked = _pick_bits(&_random_place_bits, 8);
- _entrance_index[i] = picked;
+ // this assigns places from _randomPlacesMR
+ uint16 picked = pickBits(&_randomPlaceBits, 8);
+ _entranceIndex[i] = picked;
}
- _max_repeat = _this_difficulty + 4;
- _repeat_random_place = 0;
- _got_to = 0;
- _UpdateStat();
+ _maxRepeat = _thisDifficulty + 4;
+ _repeatRandomPlace = 0;
+ _gotTo = 0;
+ updateStat();
}
-void GameJohnnyRock::_OutShots() {
+void GameJohnnyRock::outShots() {
_shots = 400;
_score = 0;
_holster = false;
- _UpdateStat();
+ updateStat();
}
-void GameJohnnyRock::_DoMenu() {
- uint32 startTime = _GetMsTime();
- _RestoreCursor();
- _DoCursor();
+void GameJohnnyRock::doMenu() {
+ uint32 startTime = getMsTime();
+ updateCursor();
_inMenu = true;
- _MoveMouse();
+ moveMouse();
g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
- _ShowDifficulty(_difficulty, false);
+ showDifficulty(_difficulty, false);
while (_inMenu && !_vm->shouldQuit()) {
Common::Point firedCoords;
- if (__Fired(&firedCoords)) {
- Rect *hitMenuRect = _CheckZone(_submenzone, &firedCoords);
+ if (fired(&firedCoords)) {
+ Rect *hitMenuRect = checkZone(_submenzone, &firedCoords);
if (hitMenuRect != nullptr) {
- callScriptFunctionRectHit(hitMenuRect->rectHit, hitMenuRect);
+ callScriptFunctionRectHit(hitMenuRect->_rectHit, hitMenuRect);
}
}
_leftDown = false;
if (_difficulty != _oldDifficulty) {
- _ChangeDifficulty(_difficulty);
+ changeDifficulty(_difficulty);
}
- g_system->delayMillis(15);
updateScreen();
+ g_system->delayMillis(15);
}
- _RestoreCursor();
- _DoCursor();
+ updateCursor();
g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
if (_hadPause) {
- unsigned long endTime = _GetMsTime();
- unsigned long timeDiff = endTime - startTime;
+ uint32 endTime = getMsTime();
+ uint32 timeDiff = endTime - startTime;
_pauseTime += timeDiff;
_nextFrameTime += timeDiff;
}
}
-void GameJohnnyRock::_UpdateStat() {
+void GameJohnnyRock::updateStat() {
if (_score != _oldScore) {
_oldScore = _score;
Common::String buffer = Common::String::format("%05d", _score);
- for (uint8 i = 0; i < 5; i++) {
+ for (int i = 0; i < 5; i++) {
uint8 digit = buffer[i] - '0';
AlgGraphics::drawImage(_screen, &(*_numbers)[digit], (i * 7) + 0x7D, 0xBE);
}
}
- if (_game_money != _oldgame_money) {
- _oldgame_money = _game_money;
- Common::String buffer = Common::String::format("%04d", _game_money < 0 ? 0 : _game_money);
- for (uint8 i = 0; i < 4; i++) {
+ if (_gameMoney != _oldGameMoney) {
+ _oldGameMoney = _gameMoney;
+ Common::String buffer = Common::String::format("%04d", _gameMoney < 0 ? 0 : _gameMoney);
+ for (int i = 0; i < 4; i++) {
uint8 digit = buffer[i] - '0';
AlgGraphics::drawImage(_screen, &(*_numbers)[digit], (i * 7) + 0x43, 0xBE);
}
@@ -558,7 +554,7 @@ void GameJohnnyRock::_UpdateStat() {
if (_shots != _oldShots) {
_oldShots = _shots;
Common::String buffer = Common::String::format("%04d", _shots);
- for (uint8 i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
uint8 digit = buffer[i] - '0';
AlgGraphics::drawImage(_screen, &(*_numbers)[digit], (i * 7) + 0x10A, 0xBE);
}
@@ -566,36 +562,35 @@ void GameJohnnyRock::_UpdateStat() {
AlgGraphics::drawImage(_screen, &(*_difficultyIcon)[_difficulty - 1], 0xBA, 0xBE);
}
-void GameJohnnyRock::_DisplayScore() {
- _UpdateStat();
+void GameJohnnyRock::displayScore() {
+ updateStat();
}
-void GameJohnnyRock::_ShowDifficulty(uint8 newDifficulty, bool updateCursor) {
+void GameJohnnyRock::showDifficulty(uint8 newDifficulty, bool cursor) {
// reset menu screen
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
- AlgGraphics::drawImageCentered(_screen, &_levelIcon, _diffpos[newDifficulty][0], _diffpos[newDifficulty][1]);
- if (updateCursor) {
- _DoCursor();
+ AlgGraphics::drawImageCentered(_screen, &_levelIcon, _diffPos[newDifficulty][0], _diffPos[newDifficulty][1]);
+ if (cursor) {
+ updateCursor();
}
}
-void GameJohnnyRock::_ChangeDifficulty(uint8 newDifficulty) {
+void GameJohnnyRock::changeDifficulty(uint8 newDifficulty) {
if (newDifficulty == _oldDifficulty) {
return;
}
- _ShowDifficulty(newDifficulty, true);
- Game::_AdjustDifficulty(newDifficulty, _oldDifficulty);
+ showDifficulty(newDifficulty, true);
+ Game::adjustDifficulty(newDifficulty, _oldDifficulty);
_oldDifficulty = newDifficulty;
_difficulty = newDifficulty;
}
-void GameJohnnyRock::_DoCursor() {
+void GameJohnnyRock::updateCursor() {
_oldWhichGun = _whichGun;
}
-void GameJohnnyRock::_UpdateMouse() {
+void GameJohnnyRock::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::PixelFormat pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
Graphics::Surface *cursor = &(*_gun)[_whichGun];
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2);
@@ -604,13 +599,13 @@ void GameJohnnyRock::_UpdateMouse() {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0, false, &pixelFormat);
+ CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
}
-void GameJohnnyRock::_MoveMouse() {
+void GameJohnnyRock::moveMouse() {
if (_inMenu) {
if (_mousePos.y > 0xB7) {
_mousePos.y = 0xB7;
@@ -623,184 +618,184 @@ void GameJohnnyRock::_MoveMouse() {
_whichGun = 0;
}
}
- _UpdateMouse();
+ updateMouse();
}
-bool GameJohnnyRock::_WeaponDown() {
+bool GameJohnnyRock::weaponDown() {
if (_rightDown && _mousePos.y >= 0xBC && _mousePos.x >= 0x37) {
return true;
}
return false;
}
-bool GameJohnnyRock::_SaveState() {
+bool GameJohnnyRock::saveState() {
Common::OutSaveFile *outSaveFile;
Common::String saveFileName = _vm->getSaveStateName(0);
if (!(outSaveFile = g_system->getSavefileManager()->openForSaving(saveFileName))) {
- warning("Can't create file '%s', game not saved", saveFileName.c_str());
+ warning("GameJohnnyRock::saveState(): Can't create file '%s', game not saved", saveFileName.c_str());
return false;
}
outSaveFile->writeUint32BE(MKTAG('A', 'L', 'G', 'S')); // header
outSaveFile->writeByte(0); // version, unused for now
- outSaveFile->writeUint16LE(_total_dies);
- outSaveFile->writeSint16LE(_game_money);
- outSaveFile->writeUint16LE(_ammo_again);
- outSaveFile->writeUint16LE(_map_timeout);
- outSaveFile->writeByte(_lucky_number);
- outSaveFile->writeByte(_this_map);
+ outSaveFile->writeUint16LE(_totalDies);
+ outSaveFile->writeSint16LE(_gameMoney);
+ outSaveFile->writeUint16LE(_ammoAgain);
+ outSaveFile->writeUint16LE(_mapTimeout);
+ outSaveFile->writeByte(_luckyNumber);
+ outSaveFile->writeByte(_thisMap);
outSaveFile->writeUint16LE(_clues);
- outSaveFile->writeUint16LE(_place_bits);
- outSaveFile->writeByte(_random_count);
- outSaveFile->writeUint16LE(_doctor_bits);
- outSaveFile->writeUint16LE(_undertaker_bits);
- for (uint8 i = 0; i < 4; i++) {
- outSaveFile->writeByte(_clue_table[i]);
- }
- outSaveFile->writeUint16LE(_this_clue);
- outSaveFile->writeByte(_got_this_number);
+ outSaveFile->writeUint16LE(_placeBits);
+ outSaveFile->writeByte(_randomCount);
+ outSaveFile->writeUint16LE(_doctorBits);
+ outSaveFile->writeUint16LE(_undertakerBits);
+ for (int i = 0; i < 4; i++) {
+ outSaveFile->writeByte(_clueTable[i]);
+ }
+ outSaveFile->writeUint16LE(_thisClue);
+ outSaveFile->writeByte(_gotThisNumber);
outSaveFile->writeByte(_casino);
- outSaveFile->writeByte(_pool_hall);
+ outSaveFile->writeByte(_poolHall);
outSaveFile->writeByte(_warehouse);
outSaveFile->writeByte(_garage);
outSaveFile->writeByte(_office);
- outSaveFile->writeByte(_casino_type);
- outSaveFile->writeByte(_pool_hall_type);
- outSaveFile->writeByte(_warehouse_type);
- outSaveFile->writeByte(_garage_type);
+ outSaveFile->writeByte(_casinoType);
+ outSaveFile->writeByte(_poolHallType);
+ outSaveFile->writeByte(_warehouseType);
+ outSaveFile->writeByte(_garageType);
outSaveFile->writeByte(_mansion);
- outSaveFile->writeByte(_in_warehouse);
- outSaveFile->writeByte(_in_office);
- outSaveFile->writeUint16LE(_got_to);
- for (uint8 i = 0; i < 20; i++) {
- outSaveFile->writeUint16LE(_entrance_index[i]);
+ outSaveFile->writeByte(_inWarehouse);
+ outSaveFile->writeByte(_inOffice);
+ outSaveFile->writeUint16LE(_gotTo);
+ for (int i = 0; i < 20; i++) {
+ outSaveFile->writeUint16LE(_entranceIndex[i]);
}
- for (uint8 i = 0; i < 10; i++) {
- outSaveFile->writeUint16LE(_random_scenes_index[i]);
+ for (int i = 0; i < 10; i++) {
+ outSaveFile->writeUint16LE(_randomScenesIndex[i]);
}
- for (uint8 i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
outSaveFile->writeByte(_combinations[i]);
}
- outSaveFile->writeByte(_who_did_it);
- outSaveFile->writeByte(_had_go_to_mansion);
- outSaveFile->writeUint16LE(_office_count);
- outSaveFile->writeUint16LE(_random_place_bits);
- outSaveFile->writeByte(_max_random_count);
- outSaveFile->writeUint16LE(_goto_after_random);
- outSaveFile->writeUint16LE(_repeat_random_place);
- outSaveFile->writeUint16LE(_max_repeat);
- outSaveFile->writeUint16LE(_got_this_clue);
- outSaveFile->writeUint16LE(_did_continue);
- outSaveFile->writeUint16LE(_this_game_time);
+ outSaveFile->writeByte(_whoDidIt);
+ outSaveFile->writeByte(_hadGoToMansion);
+ outSaveFile->writeUint16LE(_officeCount);
+ outSaveFile->writeUint16LE(_randomPlaceBits);
+ outSaveFile->writeByte(_maxRandomCount);
+ outSaveFile->writeUint16LE(_gotoAfterRandom);
+ outSaveFile->writeUint16LE(_repeatRandomPlace);
+ outSaveFile->writeUint16LE(_maxRepeat);
+ outSaveFile->writeUint16LE(_gotThisClue);
+ outSaveFile->writeUint16LE(_didContinue);
+ outSaveFile->writeUint16LE(_thisGameTime);
outSaveFile->writeUint16LE(_shots);
outSaveFile->writeSint32LE(_score);
outSaveFile->writeByte(_holster);
outSaveFile->writeByte(_difficulty);
- outSaveFile->writeByte(_this_difficulty);
- outSaveFile->writeString(_money_scene);
+ outSaveFile->writeByte(_thisDifficulty);
+ outSaveFile->writeString(_moneyScene);
outSaveFile->writeByte(0);
- outSaveFile->writeString(_cur_scene);
+ outSaveFile->writeString(_curScene);
outSaveFile->writeByte(0);
- outSaveFile->writeString(_sub_scene);
+ outSaveFile->writeString(_subScene);
outSaveFile->writeByte(0);
- outSaveFile->writeString(_ret_scene);
+ outSaveFile->writeString(_retScene);
outSaveFile->writeByte(0);
- outSaveFile->writeByte(_random_scenes_savestate_index);
+ outSaveFile->writeByte(_randomScenesSavestateIndex);
outSaveFile->finalize();
delete outSaveFile;
return true;
}
-bool GameJohnnyRock::_LoadState() {
+bool GameJohnnyRock::loadState() {
Common::InSaveFile *inSaveFile;
Common::String saveFileName = _vm->getSaveStateName(0);
if (!(inSaveFile = g_system->getSavefileManager()->openForLoading(saveFileName))) {
- debug("Can't load file '%s', game not loaded", saveFileName.c_str());
+ debug("GameJohnnyRock::loadState(): Can't load file '%s', game not loaded", saveFileName.c_str());
return false;
}
uint32 header = inSaveFile->readUint32BE();
if (header != MKTAG('A', 'L', 'G', 'S')) {
- warning("Unkown save file, header: %d", header);
+ warning("GameJohnnyRock::loadState(): Unkown save file, header: %s", tag2str(header));
return false;
}
inSaveFile->skip(1); // version, unused for now
- _total_dies = inSaveFile->readUint16LE();
- _game_money = inSaveFile->readSint16LE();
- _ammo_again = inSaveFile->readUint16LE();
- _map_timeout = inSaveFile->readUint16LE();
- _lucky_number = inSaveFile->readByte();
- _this_map = inSaveFile->readByte();
+ _totalDies = inSaveFile->readUint16LE();
+ _gameMoney = inSaveFile->readSint16LE();
+ _ammoAgain = inSaveFile->readUint16LE();
+ _mapTimeout = inSaveFile->readUint16LE();
+ _luckyNumber = inSaveFile->readByte();
+ _thisMap = inSaveFile->readByte();
_clues = inSaveFile->readUint16LE();
- _place_bits = inSaveFile->readUint16LE();
- _random_count = inSaveFile->readByte();
- _doctor_bits = inSaveFile->readUint16LE();
- _undertaker_bits = inSaveFile->readUint16LE();
- for (uint8 i = 0; i < 4; i++) {
- _clue_table[i] = inSaveFile->readByte();
- }
- _this_clue = inSaveFile->readUint16LE();
- _got_this_number = inSaveFile->readByte();
+ _placeBits = inSaveFile->readUint16LE();
+ _randomCount = inSaveFile->readByte();
+ _doctorBits = inSaveFile->readUint16LE();
+ _undertakerBits = inSaveFile->readUint16LE();
+ for (int i = 0; i < 4; i++) {
+ _clueTable[i] = inSaveFile->readByte();
+ }
+ _thisClue = inSaveFile->readUint16LE();
+ _gotThisNumber = inSaveFile->readByte();
_casino = inSaveFile->readByte();
- _pool_hall = inSaveFile->readByte();
+ _poolHall = inSaveFile->readByte();
_warehouse = inSaveFile->readByte();
_garage = inSaveFile->readByte();
_office = inSaveFile->readByte();
- _casino_type = inSaveFile->readByte();
- _pool_hall_type = inSaveFile->readByte();
- _warehouse_type = inSaveFile->readByte();
- _garage_type = inSaveFile->readByte();
+ _casinoType = inSaveFile->readByte();
+ _poolHallType = inSaveFile->readByte();
+ _warehouseType = inSaveFile->readByte();
+ _garageType = inSaveFile->readByte();
_mansion = inSaveFile->readByte();
- _in_warehouse = inSaveFile->readByte();
- _in_office = inSaveFile->readByte();
- _got_to = inSaveFile->readUint16LE();
- for (uint8 i = 0; i < 20; i++) {
- _entrance_index[i] = inSaveFile->readUint16LE();
+ _inWarehouse = inSaveFile->readByte();
+ _inOffice = inSaveFile->readByte();
+ _gotTo = inSaveFile->readUint16LE();
+ for (int i = 0; i < 20; i++) {
+ _entranceIndex[i] = inSaveFile->readUint16LE();
}
- for (uint8 i = 0; i < 10; i++) {
- _random_scenes_index[i] = inSaveFile->readUint16LE();
+ for (int i = 0; i < 10; i++) {
+ _randomScenesIndex[i] = inSaveFile->readUint16LE();
}
- for (uint8 i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
_combinations[i] = inSaveFile->readByte();
}
- _who_did_it = inSaveFile->readByte();
- _had_go_to_mansion = inSaveFile->readByte();
- _office_count = inSaveFile->readUint16LE();
- _random_place_bits = inSaveFile->readUint16LE();
- _max_random_count = inSaveFile->readByte();
- _goto_after_random = inSaveFile->readUint16LE();
- _repeat_random_place = inSaveFile->readUint16LE();
- _max_repeat = inSaveFile->readUint16LE();
- _got_this_clue = inSaveFile->readUint16LE();
- _did_continue = inSaveFile->readUint16LE();
- _this_game_time = inSaveFile->readUint16LE();
+ _whoDidIt = inSaveFile->readByte();
+ _hadGoToMansion = inSaveFile->readByte();
+ _officeCount = inSaveFile->readUint16LE();
+ _randomPlaceBits = inSaveFile->readUint16LE();
+ _maxRandomCount = inSaveFile->readByte();
+ _gotoAfterRandom = inSaveFile->readUint16LE();
+ _repeatRandomPlace = inSaveFile->readUint16LE();
+ _maxRepeat = inSaveFile->readUint16LE();
+ _gotThisClue = inSaveFile->readUint16LE();
+ _didContinue = inSaveFile->readUint16LE();
+ _thisGameTime = inSaveFile->readUint16LE();
_shots = inSaveFile->readUint16LE();
_score = inSaveFile->readSint32LE();
_holster = inSaveFile->readByte();
_difficulty = inSaveFile->readByte();
- _this_difficulty = inSaveFile->readByte();
- _money_scene = inSaveFile->readString();
- _cur_scene = inSaveFile->readString();
- _sub_scene = inSaveFile->readString();
- _ret_scene = inSaveFile->readString();
- _random_scenes_savestate_index = inSaveFile->readByte();
+ _thisDifficulty = inSaveFile->readByte();
+ _moneyScene = inSaveFile->readString();
+ _curScene = inSaveFile->readString();
+ _subScene = inSaveFile->readString();
+ _retScene = inSaveFile->readString();
+ _randomScenesSavestateIndex = inSaveFile->readByte();
delete inSaveFile;
// find out where _random_scenes should point
- uint16 placeIndex = _entrance_index[_random_scenes_savestate_index];
- if (_random_scenes_savestate_index < 5) {
- _random_scenes = _random_places[placeIndex];
+ uint16 placeIndex = _entranceIndex[_randomScenesSavestateIndex];
+ if (_randomScenesSavestateIndex < 5) {
+ _randomScenes = _randomPlaces[placeIndex];
} else {
- _random_scenes = _random_places_mr[placeIndex];
+ _randomScenes = _randomPlacesMR[placeIndex];
}
- _ChangeDifficulty(_difficulty);
- debug("lucky number: %d", (_lucky_number + 1));
+ changeDifficulty(_difficulty);
+ debug("lucky number: %d", (_luckyNumber + 1));
return true;
}
-void GameJohnnyRock::_DoMoneySound() {
- _PlaySound(_skullSound);
+void GameJohnnyRock::doMoneySound() {
+ playSound(_skullSound);
}
// Misc game functions
-Common::String GameJohnnyRock::_NumtoScene(int n) {
+Common::String GameJohnnyRock::numToScene(int n) {
switch (n) {
case 1:
return "scene1a";
@@ -825,7 +820,7 @@ Common::String GameJohnnyRock::_NumtoScene(int n) {
}
}
-uint16 GameJohnnyRock::_ScenetoNum(Common::String sceneName) {
+uint16 GameJohnnyRock::sceneToNum(Common::String sceneName) {
Common::String temp;
uint16 index = 4;
if (sceneName[index] == 'e') {
@@ -841,666 +836,665 @@ uint16 GameJohnnyRock::_ScenetoNum(Common::String sceneName) {
return atoi(temp.c_str());
}
-void GameJohnnyRock::_default_bullethole(Common::Point *point) {
+void GameJohnnyRock::defaultBullethole(Common::Point *point) {
if (point->x >= 14 && point->x <= 306 && point->y >= 5 && point->y <= 169) {
- _RestoreCursor();
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
- _DoCursor();
+ updateCursor();
_shotFired = true;
- _DoShot();
+ doShot();
}
}
-uint16 GameJohnnyRock::_pick_bits(uint16 *bits, uint8 max) {
+uint16 GameJohnnyRock::pickBits(uint16 *bits, uint8 max) {
// reset bits if full
if (*bits == (0xFFFF >> (16 - max))) {
*bits = 0;
}
- uint8 random = _rnd->getRandomNumber(max - 1);
+ uint8 randomNum = _rnd->getRandomNumber(max - 1);
// find first unused bit position
- while (*bits & (1 << random)) {
- random++;
- if (random >= max) {
- random = 0;
+ while (*bits & (1 << randomNum)) {
+ randomNum++;
+ if (randomNum >= max) {
+ randomNum = 0;
}
}
- *bits |= (1 << random);
- return random;
+ *bits |= (1 << randomNum);
+ return randomNum;
}
-uint16 GameJohnnyRock::_pick_random_place(uint8 place) {
- _random_scenes_savestate_index = place;
- uint16 placeIndex = _entrance_index[place];
+uint16 GameJohnnyRock::pickRandomPlace(uint8 place) {
+ _randomScenesSavestateIndex = place;
+ uint16 placeIndex = _entranceIndex[place];
if (place < 5) {
- _random_scenes = _random_places[placeIndex];
+ _randomScenes = _randomPlaces[placeIndex];
} else {
- _random_scenes = _random_places_mr[placeIndex];
+ _randomScenes = _randomPlacesMR[placeIndex];
}
- _place_bits = 0;
- _random_count = 0;
- memset(&_random_scenes_index, 0, (10 * sizeof(uint16)));
- for (uint8 i = 0; i < (_random_scenes[0] + 4); i++) {
- _random_scenes_index[i] = _random_scenes[i];
+ _placeBits = 0;
+ _randomCount = 0;
+ memset(&_randomScenesIndex, 0, (10 * sizeof(uint16)));
+ for (int i = 0; i < (_randomScenes[0] + 4); i++) {
+ _randomScenesIndex[i] = _randomScenes[i];
}
- if (_random_scenes[1] < 0) {
- _max_random_count = (_this_difficulty * 2) - _random_scenes[1];
+ if (_randomScenes[1] < 0) {
+ _maxRandomCount = (_thisDifficulty * 2) - _randomScenes[1];
} else {
- _max_random_count = _random_scenes[1];
+ _maxRandomCount = _randomScenes[1];
}
- uint16 index = _pick_bits(&_place_bits, _random_scenes[0]);
- return _random_scenes[index + 4];
+ uint16 index = pickBits(&_placeBits, _randomScenes[0]);
+ return _randomScenes[index + 4];
}
-void GameJohnnyRock::_show_combination() {
- uint16 offset = (_got_this_clue * 6) + _combinations[_got_this_clue];
- _got_this_clue++;
- if (_got_this_clue == 4) {
+void GameJohnnyRock::showCombination() {
+ uint16 offset = (_gotThisClue * 6) + _combinations[_gotThisClue];
+ _gotThisClue++;
+ if (_gotThisClue == 4) {
_mansion = 3;
}
- _cur_scene = _NumtoScene(offset + 0xDB);
+ _curScene = numToScene(offset + 0xDB);
}
// Script functions: Zone
-void GameJohnnyRock::_zone_bullethole(Common::Point *point) {
- _default_bullethole(point);
+void GameJohnnyRock::zoneBullethole(Common::Point *point) {
+ defaultBullethole(point);
}
-void GameJohnnyRock::_rect_shotmenu(Rect *rect) {
- _DoMenu();
+void GameJohnnyRock::rectShotMenu(Rect *rect) {
+ doMenu();
}
-void GameJohnnyRock::_rect_save(Rect *rect) {
- if(_SaveState()) {
- _DoSaveSound();
+void GameJohnnyRock::rectSave(Rect *rect) {
+ if (saveState()) {
+ doSaveSound();
}
}
-void GameJohnnyRock::_rect_load(Rect *rect) {
- if(_LoadState()) {
- _DoLoadSound();
+void GameJohnnyRock::rectLoad(Rect *rect) {
+ if (loadState()) {
+ doLoadSound();
}
}
-void GameJohnnyRock::_rect_continue(Rect *rect) {
+void GameJohnnyRock::rectContinue(Rect *rect) {
_inMenu = 0;
_fired = 0;
- if (_game_money < 0) {
- _NewGame();
- _ret_scene = "";
- _sub_scene = "";
- if (_in_office) {
- _cur_scene = _NumtoScene(_in_office);
+ if (_gameMoney < 0) {
+ newGame();
+ _retScene = "";
+ _subScene = "";
+ if (_inOffice) {
+ _curScene = numToScene(_inOffice);
} else {
- _cur_scene = _NumtoScene(_this_map + 174);
+ _curScene = numToScene(_thisMap + 174);
}
- _did_continue++;
+ _didContinue++;
}
if (_shots <= 0) {
- _OutShots();
- _did_continue++;
+ outShots();
+ _didContinue++;
}
}
-void GameJohnnyRock::_rect_start(Rect *rect) {
+void GameJohnnyRock::rectStart(Rect *rect) {
_inMenu = 0;
_fired = 0;
- _this_difficulty = 0;
- Scene *scene = _sceneInfo->findScene(_startscene);
- if (scene->nxtscn == "DRAWGUN") {
+ _thisDifficulty = 0;
+ Scene *scene = _sceneInfo->findScene(_startScene);
+ if (scene->_nxtscn == "DRAWGUN") {
callScriptFunctionScene(NXTSCN, "DRAWGUN", scene);
}
- _cur_scene = _startscene;
- _ResetParams();
- _NewGame();
- _UpdateStat();
+ _curScene = _startScene;
+ resetParams();
+ newGame();
+ updateStat();
}
-void GameJohnnyRock::_rect_killinnocent(Rect *rect) {
- _in_office = _ScenetoNum(_cur_scene);
- if (_in_office >= 0x13) {
- _in_office = 0;
+void GameJohnnyRock::rectKillInnocent(Rect *rect) {
+ _inOffice = sceneToNum(_curScene);
+ if (_inOffice >= 0x13) {
+ _inOffice = 0;
}
if (!_debug_godMode) {
- _game_money -= 400;
+ _gameMoney -= 400;
}
- if (_game_money < 0) {
- _sub_scene = "scene358";
- _ret_scene = "";
- _cur_scene = "scene151";
+ if (_gameMoney < 0) {
+ _subScene = "scene358";
+ _retScene = "";
+ _curScene = "scene151";
} else {
switch (_rnd->getRandomNumber(2)) {
case 0:
- _cur_scene = "scene151";
+ _curScene = "scene151";
break;
case 1:
- _cur_scene = "scene152";
+ _curScene = "scene152";
break;
case 2:
- _cur_scene = "scene153";
+ _curScene = "scene153";
break;
}
}
}
-void GameJohnnyRock::_rect_selectcasino(Rect *rect) {
- _ret_scene = "";
- if (_mansion == 5 && _who_did_it == 1) {
- _repeat_random_place = _max_repeat;
- _goto_after_random = 0xF5;
- _cur_scene = _NumtoScene(_pick_random_place(_max_repeat + 5));
+void GameJohnnyRock::rectSelectCasino(Rect *rect) {
+ _retScene = "";
+ if (_mansion == 5 && _whoDidIt == 1) {
+ _repeatRandomPlace = _maxRepeat;
+ _gotoAfterRandom = 0xF5;
+ _curScene = numToScene(pickRandomPlace(_maxRepeat + 5));
} else if (_casino == 0) {
- if (_got_to & 1) {
- _cur_scene = "scene19";
+ if (_gotTo & 1) {
+ _curScene = "scene19";
} else {
- _goto_after_random = 0x13;
- _cur_scene = _NumtoScene(_pick_random_place(0));
+ _gotoAfterRandom = 0x13;
+ _curScene = numToScene(pickRandomPlace(0));
}
} else if (_casino == 1 || _casino == 3) {
- _cur_scene = "scene44";
+ _curScene = "scene44";
} else {
_casino = 3;
if (_rnd->getRandomBit()) { // original: (_this_game_time & 1) == 0
- _cur_scene = "scene64";
+ _curScene = "scene64";
} else {
- _cur_scene = "scene65";
+ _curScene = "scene65";
}
}
}
-void GameJohnnyRock::_rect_selectpoolhall(Rect *rect) {
- _ret_scene = "";
- if (_mansion == 5 && _who_did_it == 0) {
- _repeat_random_place = _max_repeat;
- _goto_after_random = 0xF7;
- _cur_scene = _NumtoScene(_pick_random_place(_max_repeat + 5));
- } else if (_pool_hall == 0) {
- if (_got_to & 2) {
- _cur_scene = "scene66";
+void GameJohnnyRock::rectSelectPoolhall(Rect *rect) {
+ _retScene = "";
+ if (_mansion == 5 && _whoDidIt == 0) {
+ _repeatRandomPlace = _maxRepeat;
+ _gotoAfterRandom = 0xF7;
+ _curScene = numToScene(pickRandomPlace(_maxRepeat + 5));
+ } else if (_poolHall == 0) {
+ if (_gotTo & 2) {
+ _curScene = "scene66";
} else {
- _goto_after_random = 0x42;
- _cur_scene = _NumtoScene(_pick_random_place(1));
+ _gotoAfterRandom = 0x42;
+ _curScene = numToScene(pickRandomPlace(1));
}
- } else if (_pool_hall == 1 || _pool_hall == 3) {
- _cur_scene = "scene82";
+ } else if (_poolHall == 1 || _poolHall == 3) {
+ _curScene = "scene82";
} else {
- _pool_hall = 3;
- _cur_scene = "scene89";
+ _poolHall = 3;
+ _curScene = "scene89";
}
}
-void GameJohnnyRock::_rect_selectwarehouse(Rect *rect) {
- _ret_scene = "";
- if (_mansion == 5 && _who_did_it == 2) {
- _repeat_random_place = _max_repeat;
- _goto_after_random = 0xF9;
- _cur_scene = _NumtoScene(_pick_random_place(_max_repeat + 5));
+void GameJohnnyRock::rectSelectWarehouse(Rect *rect) {
+ _retScene = "";
+ if (_mansion == 5 && _whoDidIt == 2) {
+ _repeatRandomPlace = _maxRepeat;
+ _gotoAfterRandom = 0xF9;
+ _curScene = numToScene(pickRandomPlace(_maxRepeat + 5));
} else if (_warehouse == 0) {
- if (_in_warehouse < 2) {
- if (_got_to & 4) {
- _cur_scene = "scene90";
+ if (_inWarehouse < 2) {
+ if (_gotTo & 4) {
+ _curScene = "scene90";
} else {
- _in_warehouse = 1;
- _goto_after_random = 0x5A;
- _cur_scene = _NumtoScene(_pick_random_place(2));
+ _inWarehouse = 1;
+ _gotoAfterRandom = 0x5A;
+ _curScene = numToScene(pickRandomPlace(2));
}
- } else if (_in_warehouse == 2) {
- _cur_scene = "scene93";
- } else if (_in_warehouse == 3) {
- _cur_scene = "scene119";
+ } else if (_inWarehouse == 2) {
+ _curScene = "scene93";
+ } else if (_inWarehouse == 3) {
+ _curScene = "scene119";
}
} else if (_warehouse == 1 || _warehouse == 3) {
- _cur_scene = "scene122";
+ _curScene = "scene122";
} else {
_warehouse = 3;
- _cur_scene = "scene121";
+ _curScene = "scene121";
}
}
-void GameJohnnyRock::_rect_selectgarage(Rect *rect) {
- _ret_scene = "";
- if (_mansion == 5 && _who_did_it == 3) {
- _repeat_random_place = _max_repeat;
- _goto_after_random = 0xFB;
- _cur_scene = _NumtoScene(_pick_random_place(_max_repeat + 5));
+void GameJohnnyRock::rectSelectGarage(Rect *rect) {
+ _retScene = "";
+ if (_mansion == 5 && _whoDidIt == 3) {
+ _repeatRandomPlace = _maxRepeat;
+ _gotoAfterRandom = 0xFB;
+ _curScene = numToScene(pickRandomPlace(_maxRepeat + 5));
} else if (_garage == 0) {
- if (_got_to & 8) {
- _cur_scene = "scene123";
+ if (_gotTo & 8) {
+ _curScene = "scene123";
} else {
- _goto_after_random = 0x7B;
- _cur_scene = _NumtoScene(_pick_random_place(3));
+ _gotoAfterRandom = 0x7B;
+ _curScene = numToScene(pickRandomPlace(3));
}
} else if (_garage == 1 || _garage == 3) {
- _cur_scene = "scene138";
+ _curScene = "scene138";
} else {
_garage = 3;
- _cur_scene = "scene139";
+ _curScene = "scene139";
}
}
-void GameJohnnyRock::_rect_selectmansion(Rect *rect) {
- _place_bits = 0;
- _random_count = 1;
- _ret_scene = "";
+void GameJohnnyRock::rectSelectMansion(Rect *rect) {
+ _placeBits = 0;
+ _randomCount = 1;
+ _retScene = "";
if (_mansion == 1) {
- uint16 picked = _pick_bits(&_place_bits, 5);
- _cur_scene = _NumtoScene(0xB8 + (picked * 2));
+ uint16 picked = pickBits(&_placeBits, 5);
+ _curScene = numToScene(0xB8 + (picked * 2));
} else if (_mansion == 2) {
- _cur_scene = "scene194";
+ _curScene = "scene194";
} else if (_mansion == 3) {
- _cur_scene = "scene207";
+ _curScene = "scene207";
} else if (_mansion == 4) {
- _got_this_number = 0;
- _cur_scene = "scene212";
+ _gotThisNumber = 0;
+ _curScene = "scene212";
} else if (_mansion == 5) {
- _cur_scene = "scene243";
+ _curScene = "scene243";
} else {
- if (_garage == 0 || _casino == 0 || _pool_hall == 0 || _warehouse == 0) {
- _cur_scene = "scene243";
- } else if (_got_to & 0x10) {
- _cur_scene = "scene180";
+ if (_garage == 0 || _casino == 0 || _poolHall == 0 || _warehouse == 0) {
+ _curScene = "scene243";
+ } else if (_gotTo & 0x10) {
+ _curScene = "scene180";
} else {
- _goto_after_random = 0xB4;
- _cur_scene = _NumtoScene(_pick_random_place(4));
+ _gotoAfterRandom = 0xB4;
+ _curScene = numToScene(pickRandomPlace(4));
}
}
}
-void GameJohnnyRock::_rect_selectammo(Rect *rect) {
- _ret_scene = "";
- if (_game_money >= 100) {
+void GameJohnnyRock::rectSelectAmmo(Rect *rect) {
+ _retScene = "";
+ if (_gameMoney >= 100) {
if (!_debug_godMode) {
- _game_money -= 100;
+ _gameMoney -= 100;
}
_shots += 200;
- _ammo_again = 0;
- _DoMoneySound();
- _cur_scene = "scene178";
+ _ammoAgain = 0;
+ doMoneySound();
+ _curScene = "scene178";
} else {
- _ammo_again++;
- if (_ammo_again >= 2) {
- _cur_scene = "scene243";
+ _ammoAgain++;
+ if (_ammoAgain >= 2) {
+ _curScene = "scene243";
} else {
- _cur_scene = "scene179";
+ _curScene = "scene179";
}
}
}
-void GameJohnnyRock::_rect_selectoffice(Rect *rect) {
- _ret_scene = "";
+void GameJohnnyRock::rectSelectOffice(Rect *rect) {
+ _retScene = "";
if (!_office) {
_office = 1;
- _cur_scene = "scene168";
+ _curScene = "scene168";
} else {
if (_rnd->getRandomBit()) { // original: _this_game_time & 1
- _cur_scene = "scene243";
+ _curScene = "scene243";
} else {
- _cur_scene = "scene262";
+ _curScene = "scene262";
}
}
}
-void GameJohnnyRock::_shotclue(uint8 clue) {
- if (_clue_table[_got_this_clue] == clue) {
- _show_combination();
+void GameJohnnyRock::shotClue(uint8 clue) {
+ if (_clueTable[_gotThisClue] == clue) {
+ showCombination();
} else {
- _got_this_clue = 0;
- _cur_scene = "scene374";
+ _gotThisClue = 0;
+ _curScene = "scene374";
}
}
-void GameJohnnyRock::_rect_shotmanbust(Rect *rect) {
- _shotclue(0);
+void GameJohnnyRock::rectShotManBust(Rect *rect) {
+ shotClue(0);
}
-void GameJohnnyRock::_rect_shotwomanbust(Rect *rect) {
- _shotclue(1);
+void GameJohnnyRock::rectShotWomanBust(Rect *rect) {
+ shotClue(1);
}
-void GameJohnnyRock::_rect_shotbluevase(Rect *rect) {
- _shotclue(2);
+void GameJohnnyRock::rectShotBlueVase(Rect *rect) {
+ shotClue(2);
}
-void GameJohnnyRock::_rect_shotcat(Rect *rect) {
- _shotclue(3);
+void GameJohnnyRock::rectShotCat(Rect *rect) {
+ shotClue(3);
}
-void GameJohnnyRock::_rect_shotindian(Rect *rect) {
- _shotclue(4);
+void GameJohnnyRock::rectShotIndian(Rect *rect) {
+ shotClue(4);
}
-void GameJohnnyRock::_rect_shotplate(Rect *rect) {
- _shotclue(5);
+void GameJohnnyRock::rectShotPlate(Rect *rect) {
+ shotClue(5);
}
-void GameJohnnyRock::_rect_shotbluedresspic(Rect *rect) {
- _shotclue(6);
+void GameJohnnyRock::rectShotBlueDressPic(Rect *rect) {
+ shotClue(6);
}
-void GameJohnnyRock::_rect_shotmodernpic(Rect *rect) {
- _shotclue(7);
+void GameJohnnyRock::rectShotModernPic(Rect *rect) {
+ shotClue(7);
}
-void GameJohnnyRock::_rect_shotmonalisa(Rect *rect) {
- _shotclue(8);
+void GameJohnnyRock::rectShotMonaLisa(Rect *rect) {
+ shotClue(8);
}
-void GameJohnnyRock::_rect_shotgwashington(Rect *rect) {
- _shotclue(9);
+void GameJohnnyRock::rectShotGWashington(Rect *rect) {
+ shotClue(9);
}
-void GameJohnnyRock::_rect_shotboyinredpic(Rect *rect) {
- _shotclue(10);
+void GameJohnnyRock::rectShotBoyInRedPic(Rect *rect) {
+ shotClue(10);
}
-void GameJohnnyRock::_rect_shotcoatofarms(Rect *rect) {
- _shotclue(11);
+void GameJohnnyRock::rectShotCoatOfArms(Rect *rect) {
+ shotClue(11);
}
-void GameJohnnyRock::_shotcombination(uint8 combination, bool combinationB) {
- if (_combinations[_got_this_number] == combination) {
- _got_this_number++;
- if (_got_this_number >= 4) {
+void GameJohnnyRock::shotCombination(uint8 combination, bool combinationB) {
+ if (_combinations[_gotThisNumber] == combination) {
+ _gotThisNumber++;
+ if (_gotThisNumber >= 4) {
_mansion = 5;
- _cur_scene = _NumtoScene(_who_did_it + 0xD7);
+ _curScene = numToScene(_whoDidIt + 0xD7);
} else {
if (combinationB) {
- _cur_scene = "scene213";
+ _curScene = "scene213";
} else {
- _cur_scene = "scene214";
+ _curScene = "scene214";
}
}
} else {
- _got_this_number = 0;
- _cur_scene = "scene376";
+ _gotThisNumber = 0;
+ _curScene = "scene376";
}
}
-void GameJohnnyRock::_rect_shotcombinationA0(Rect *rect) {
- _shotcombination(0, false);
+void GameJohnnyRock::rectShotCombinationA0(Rect *rect) {
+ shotCombination(0, false);
}
-void GameJohnnyRock::_rect_shotcombinationA1(Rect *rect) {
- _shotcombination(1, false);
+void GameJohnnyRock::rectShotCombinationA1(Rect *rect) {
+ shotCombination(1, false);
}
-void GameJohnnyRock::_rect_shotcombinationA2(Rect *rect) {
- _shotcombination(2, false);
+void GameJohnnyRock::rectShotCombinationA2(Rect *rect) {
+ shotCombination(2, false);
}
-void GameJohnnyRock::_rect_shotcombinationA3(Rect *rect) {
- _shotcombination(3, false);
+void GameJohnnyRock::rectShotCombinationA3(Rect *rect) {
+ shotCombination(3, false);
}
-void GameJohnnyRock::_rect_shotcombinationA4(Rect *rect) {
- _shotcombination(4, false);
+void GameJohnnyRock::rectShotCombinationA4(Rect *rect) {
+ shotCombination(4, false);
}
-void GameJohnnyRock::_rect_shotcombinationA5(Rect *rect) {
- _shotcombination(5, false);
+void GameJohnnyRock::rectShotCombinationA5(Rect *rect) {
+ shotCombination(5, false);
}
-void GameJohnnyRock::_rect_shotcombinationB0(Rect *rect) {
- _shotcombination(0, true);
+void GameJohnnyRock::rectShotCombinationB0(Rect *rect) {
+ shotCombination(0, true);
}
-void GameJohnnyRock::_rect_shotcombinationB1(Rect *rect) {
- _shotcombination(1, true);
+void GameJohnnyRock::rectShotCombinationB1(Rect *rect) {
+ shotCombination(1, true);
}
-void GameJohnnyRock::_rect_shotcombinationB2(Rect *rect) {
- _shotcombination(2, true);
+void GameJohnnyRock::rectShotCombinationB2(Rect *rect) {
+ shotCombination(2, true);
}
-void GameJohnnyRock::_rect_shotcombinationB3(Rect *rect) {
- _shotcombination(3, true);
+void GameJohnnyRock::rectShotCombinationB3(Rect *rect) {
+ shotCombination(3, true);
}
-void GameJohnnyRock::_rect_shotcombinationB4(Rect *rect) {
- _shotcombination(4, true);
+void GameJohnnyRock::rectShotCombinationB4(Rect *rect) {
+ shotCombination(4, true);
}
-void GameJohnnyRock::_rect_shotcombinationB5(Rect *rect) {
- _shotcombination(5, true);
+void GameJohnnyRock::rectShotCombinationB5(Rect *rect) {
+ shotCombination(5, true);
}
-void GameJohnnyRock::_shotluckynumber(uint8 number) {
- if (_lucky_number != number || _cur_scene == _money_scene) {
+void GameJohnnyRock::shotLuckyNumber(uint8 number) {
+ if (_luckyNumber != number || _curScene == _moneyScene) {
return;
}
- _DoMoneySound();
- _game_money += 100;
+ doMoneySound();
+ _gameMoney += 100;
_score += 500;
- _money_scene = _cur_scene;
+ _moneyScene = _curScene;
}
-void GameJohnnyRock::_rect_shotluckynum0(Rect *rect) {
- _shotluckynumber(0);
+void GameJohnnyRock::rectShotLuckyNumber0(Rect *rect) {
+ shotLuckyNumber(0);
}
-void GameJohnnyRock::_rect_shotluckynum1(Rect *rect) {
- _shotluckynumber(1);
+void GameJohnnyRock::rectShotLuckyNumber1(Rect *rect) {
+ shotLuckyNumber(1);
}
-void GameJohnnyRock::_rect_shotluckynum2(Rect *rect) {
- _shotluckynumber(2);
+void GameJohnnyRock::rectShotLuckyNumber2(Rect *rect) {
+ shotLuckyNumber(2);
}
-void GameJohnnyRock::_rect_shotluckynum3(Rect *rect) {
- _shotluckynumber(3);
+void GameJohnnyRock::rectShotLuckyNumber3(Rect *rect) {
+ shotLuckyNumber(3);
}
-void GameJohnnyRock::_rect_shotluckynum4(Rect *rect) {
- _shotluckynumber(4);
+void GameJohnnyRock::rectShotLuckyNumber4(Rect *rect) {
+ shotLuckyNumber(4);
}
-void GameJohnnyRock::_rect_shotluckynum5(Rect *rect) {
- _shotluckynumber(5);
+void GameJohnnyRock::rectShotLuckyNumber5(Rect *rect) {
+ shotLuckyNumber(5);
}
// Script functions: Scene PreOps
// Script functions: Scene Scene InsOps
-void GameJohnnyRock::_scene_iso_shootpast(Scene *scene) {
+void GameJohnnyRock::sceneIsoShootpast(Scene *scene) {
if (_fired) {
- if (_ret_scene != "") {
- _cur_scene = _ret_scene;
- _ret_scene = "";
- } else if (_sub_scene != "") {
- _cur_scene = _sub_scene;
- _sub_scene = "";
+ if (_retScene != "") {
+ _curScene = _retScene;
+ _retScene = "";
+ } else if (_subScene != "") {
+ _curScene = _subScene;
+ _subScene = "";
} else {
- callScriptFunctionScene(NXTSCN, scene->nxtscn, scene);
+ callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
}
}
-void GameJohnnyRock::_scene_iso_spause(Scene *scene) {
- _scene_iso_shootpast(scene);
- _scene_iso_pause(scene);
+void GameJohnnyRock::sceneIsoShootpastPause(Scene *scene) {
+ sceneIsoShootpast(scene);
+ sceneIsoPause(scene);
}
-void GameJohnnyRock::_scene_iso_gotocasino(Scene *scene) {
- _got_to |= 1;
- _scene_iso_shootpast(scene);
+void GameJohnnyRock::sceneIsoGotoCasino(Scene *scene) {
+ _gotTo |= 1;
+ sceneIsoShootpast(scene);
}
-void GameJohnnyRock::_scene_iso_gotopoolh(Scene *scene) {
- _got_to |= 2;
- _scene_iso_shootpast(scene);
+void GameJohnnyRock::sceneIsoGotoPoolhall(Scene *scene) {
+ _gotTo |= 2;
+ sceneIsoShootpast(scene);
}
-void GameJohnnyRock::_scene_iso_gotowarehse(Scene *scene) {
- _got_to |= 4;
+void GameJohnnyRock::sceneIsoGotoWarehouse(Scene *scene) {
+ _gotTo |= 4;
}
-void GameJohnnyRock::_scene_iso_inwarehse2(Scene *scene) {
- _in_warehouse = 2;
- _scene_iso_shootpast(scene);
+void GameJohnnyRock::sceneIsoInWarehouse2(Scene *scene) {
+ _inWarehouse = 2;
+ sceneIsoShootpast(scene);
}
-void GameJohnnyRock::_scene_iso_inwarehse3(Scene *scene) {
- _in_warehouse = 3;
- _scene_iso_shootpast(scene);
+void GameJohnnyRock::sceneIsoInwarehouse3(Scene *scene) {
+ _inWarehouse = 3;
+ sceneIsoShootpast(scene);
}
-void GameJohnnyRock::_scene_iso_gotogarage(Scene *scene) {
- _got_to |= 8;
- _scene_iso_shootpast(scene);
+void GameJohnnyRock::sceneIsoGotoGarage(Scene *scene) {
+ _gotTo |= 8;
+ sceneIsoShootpast(scene);
}
-void GameJohnnyRock::_scene_iso_gotomansion(Scene *scene) {
- _got_to |= 0x10;
+void GameJohnnyRock::sceneIsoGotoMansion(Scene *scene) {
+ _gotTo |= 0x10;
}
-void GameJohnnyRock::_scene_iso_inmansion1(Scene *scene) {
+void GameJohnnyRock::sceneIsoInMansion1(Scene *scene) {
_mansion = 1;
}
// Script functions: Scene NxtScn
-void GameJohnnyRock::_scene_nxtscn_died(Scene *scene) {
- uint16 sceneNum = _ScenetoNum(_cur_scene);
- _in_office = sceneNum;
+void GameJohnnyRock::sceneNxtscnDied(Scene *scene) {
+ uint16 sceneNum = sceneToNum(_curScene);
+ _inOffice = sceneNum;
if (sceneNum >= 0x13) {
- _in_office = 0;
+ _inOffice = 0;
}
- _total_dies++;
+ _totalDies++;
if (!_debug_godMode) {
- _game_money -= 400;
+ _gameMoney -= 400;
}
- if (_game_money < 0) {
+ if (_gameMoney < 0) {
switch (_rnd->getRandomNumber(2)) {
case 0:
- _cur_scene = "scene148";
+ _curScene = "scene148";
break;
case 1:
- _cur_scene = "scene149";
+ _curScene = "scene149";
break;
case 2:
- _cur_scene = "scene150";
+ _curScene = "scene150";
break;
}
} else {
- switch (_pick_bits(&_doctor_bits, 8)) {
+ switch (pickBits(&_doctorBits, 8)) {
case 0:
- _cur_scene = "scene140";
+ _curScene = "scene140";
break;
case 1:
- _cur_scene = "scene141";
+ _curScene = "scene141";
break;
case 2:
- _cur_scene = "scene142";
+ _curScene = "scene142";
break;
case 3:
- _cur_scene = "scene143";
+ _curScene = "scene143";
break;
case 4:
- _cur_scene = "scene144";
+ _curScene = "scene144";
break;
case 5:
- _cur_scene = "scene145";
+ _curScene = "scene145";
break;
case 6:
- _cur_scene = "scene146";
+ _curScene = "scene146";
break;
case 7:
- _cur_scene = "scene147";
+ _curScene = "scene147";
break;
}
}
}
-void GameJohnnyRock::_scene_nxtscn_bombdead(Scene *scene) {
- uint16 sceneNum = _ScenetoNum(_cur_scene);
- _in_office = sceneNum;
+void GameJohnnyRock::sceneNxtscnBombDead(Scene *scene) {
+ uint16 sceneNum = sceneToNum(_curScene);
+ _inOffice = sceneNum;
if (sceneNum >= 0x13) {
- _in_office = 0;
+ _inOffice = 0;
}
- _total_dies++;
+ _totalDies++;
if (!_debug_godMode) {
- _game_money -= 400;
+ _gameMoney -= 400;
}
- if (_game_money < 0) {
+ if (_gameMoney < 0) {
switch (_rnd->getRandomNumber(2)) {
case 0:
- _cur_scene = "scene148";
+ _curScene = "scene148";
break;
case 1:
- _cur_scene = "scene149";
+ _curScene = "scene149";
break;
case 2:
- _cur_scene = "scene150";
+ _curScene = "scene150";
break;
}
} else {
- _cur_scene = "scene142";
+ _curScene = "scene142";
}
}
-void GameJohnnyRock::_scene_nxtscn_pikundrtakr(Scene *scene) {
- switch (_pick_bits(&_undertaker_bits, 3)) {
+void GameJohnnyRock::sceneNxtscnPickUndertaker(Scene *scene) {
+ switch (pickBits(&_undertakerBits, 3)) {
case 0:
- _cur_scene = "scene154";
+ _curScene = "scene154";
break;
case 1:
- _cur_scene = "scene155";
+ _curScene = "scene155";
break;
case 2:
- _cur_scene = "scene156";
+ _curScene = "scene156";
break;
}
}
-void GameJohnnyRock::_scene_nxtscn_callattract(Scene *scene) {
- _ResetParams();
- _NewGame();
- _cur_scene = "scn354aa";
+void GameJohnnyRock::sceneNxtscnCallAttract(Scene *scene) {
+ resetParams();
+ newGame();
+ _curScene = "scn354aa";
}
-void GameJohnnyRock::_scene_nxtscn_pikluckno(Scene *scene) {
- _lucky_number = _rnd->getRandomNumber(5);
- debug("lucky number: %d", (_lucky_number + 1));
- _cur_scene = Common::String::format("scene%d", _lucky_number + 3);
+void GameJohnnyRock::sceneNxtscnPickLuckyNumber(Scene *scene) {
+ _luckyNumber = _rnd->getRandomNumber(5);
+ debug("lucky number: %d", (_luckyNumber + 1));
+ _curScene = Common::String::format("scene%d", _luckyNumber + 3);
}
-void GameJohnnyRock::_scene_nxtscn_pickmap(Scene *scene) {
+void GameJohnnyRock::sceneNxtscnPickMap(Scene *scene) {
Common::String nextScene;
- if (_game_money < 0) {
+ if (_gameMoney < 0) {
switch (_rnd->getRandomNumber(2)) {
case 0:
- _cur_scene = "scene148";
+ _curScene = "scene148";
break;
case 1:
- _cur_scene = "scene149";
+ _curScene = "scene149";
break;
case 2:
- _cur_scene = "scene150";
+ _curScene = "scene150";
break;
}
return;
}
- uint16 sceneNum = _ScenetoNum(_cur_scene);
+ uint16 sceneNum = sceneToNum(_curScene);
if (sceneNum == 18) {
- _in_office = 0;
- }
- if (_in_office) {
- nextScene = _NumtoScene(_in_office);
- } else if (_office_count < 10) {
- if ((_office_count % 3) == 0) {
- uint16 sceneNume = _office_table[_office_count / 3];
- nextScene = _NumtoScene(sceneNume);
+ _inOffice = 0;
+ }
+ if (_inOffice) {
+ nextScene = numToScene(_inOffice);
+ } else if (_officeCount < 10) {
+ if ((_officeCount % 3) == 0) {
+ uint16 sceneNume = _officeTable[_officeCount / 3];
+ nextScene = numToScene(sceneNume);
}
- _office_count++;
- } else if (_this_clue == 2 && !_had_go_to_mansion) {
- if (!_did_continue) {
- _this_difficulty++;
- if (_this_difficulty > 7)
- _this_difficulty = 7;
+ _officeCount++;
+ } else if (_thisClue == 2 && !_hadGoToMansion) {
+ if (!_didContinue) {
+ _thisDifficulty++;
+ if (_thisDifficulty > 7)
+ _thisDifficulty = 7;
}
- _had_go_to_mansion = 1;
- if (_pool_hall) {
- _pool_hall = 2;
+ _hadGoToMansion = 1;
+ if (_poolHall) {
+ _poolHall = 2;
nextScene = "scene162";
} else if (_casino) {
_casino = 2;
@@ -1509,15 +1503,15 @@ void GameJohnnyRock::_scene_nxtscn_pickmap(Scene *scene) {
_warehouse = 2;
nextScene = "scene165";
}
- } else if (_this_clue == 3 && _had_go_to_mansion == 1) {
- if (_total_dies < 4) {
- _this_difficulty++;
- if (_this_difficulty > 7)
- _this_difficulty = 7;
+ } else if (_thisClue == 3 && _hadGoToMansion == 1) {
+ if (_totalDies < 4) {
+ _thisDifficulty++;
+ if (_thisDifficulty > 7)
+ _thisDifficulty = 7;
}
- _had_go_to_mansion = 2;
- if (_pool_hall == 1) {
- _pool_hall = 2;
+ _hadGoToMansion = 2;
+ if (_poolHall == 1) {
+ _poolHall = 2;
nextScene = "scene162";
} else if (_casino == 1) {
_casino = 2;
@@ -1526,213 +1520,213 @@ void GameJohnnyRock::_scene_nxtscn_pickmap(Scene *scene) {
_warehouse = 2;
nextScene = "scene165";
}
- } else if (_had_go_to_mansion == 2 && _garage && _casino && _pool_hall && _warehouse) {
- if (_total_dies < 5 || _did_continue <= 1) {
- _this_difficulty++;
- if (_this_difficulty > 7)
- _this_difficulty = 7;
+ } else if (_hadGoToMansion == 2 && _garage && _casino && _poolHall && _warehouse) {
+ if (_totalDies < 5 || _didContinue <= 1) {
+ _thisDifficulty++;
+ if (_thisDifficulty > 7)
+ _thisDifficulty = 7;
}
- _had_go_to_mansion = 3;
+ _hadGoToMansion = 3;
nextScene = "scene166";
}
- if(nextScene.size() > 0) {
- _cur_scene = nextScene;
+ if (nextScene.size() > 0) {
+ _curScene = nextScene;
} else {
- _cur_scene = _NumtoScene(_this_map + 174);
+ _curScene = numToScene(_thisMap + 174);
}
}
-void GameJohnnyRock::_scene_nxtscn_pickclue(Scene *scene) {
- uint16 picked = _pick_bits(&_clues, 12);
- _clue_table[_this_clue] = picked;
- _this_clue++;
- _cur_scene = _NumtoScene(picked + 0xC3);
+void GameJohnnyRock::sceneNxtscnPickClue(Scene *scene) {
+ uint16 picked = pickBits(&_clues, 12);
+ _clueTable[_thisClue] = picked;
+ _thisClue++;
+ _curScene = numToScene(picked + 0xC3);
}
-void GameJohnnyRock::_scene_nxtscn_maptimeout(Scene *scene) {
- _map_timeout++;
- if (_map_timeout < 3) {
- _cur_scene = "scene360";
+void GameJohnnyRock::sceneNxtscnMapTimeout(Scene *scene) {
+ _mapTimeout++;
+ if (_mapTimeout < 3) {
+ _curScene = "scene360";
} else {
- _cur_scene = "scene262";
+ _curScene = "scene262";
}
}
-void GameJohnnyRock::_scene_nxtscn_entcasino(Scene *scene) {
- _place_bits = 0;
- _random_count = 0;
+void GameJohnnyRock::sceneNxtscnEnterCasino(Scene *scene) {
+ _placeBits = 0;
+ _randomCount = 0;
uint16 sceneNum;
- if (_casino_type != 0) {
- sceneNum = (_pick_bits(&_place_bits, 12) * 2) + 0x14;
+ if (_casinoType != 0) {
+ sceneNum = (pickBits(&_placeBits, 12) * 2) + 0x14;
} else {
- sceneNum = (_pick_bits(&_place_bits, 8) * 2) + 0x2D;
+ sceneNum = (pickBits(&_placeBits, 8) * 2) + 0x2D;
}
- _cur_scene = _NumtoScene(sceneNum);
+ _curScene = numToScene(sceneNum);
}
-void GameJohnnyRock::_scene_nxtscn_casinowhat(Scene *scene) {
- _random_count++;
- uint16 maxRandom = ((_this_difficulty * 3) + 6);
- if (_random_count > maxRandom) {
+void GameJohnnyRock::sceneNxtscnCasinoWhat(Scene *scene) {
+ _randomCount++;
+ uint16 maxRandom = ((_thisDifficulty * 3) + 6);
+ if (_randomCount > maxRandom) {
_casino = 1;
- _cur_scene = "scene63a";
+ _curScene = "scene63a";
} else {
uint16 sceneNum;
- if (_casino_type != 0) {
- sceneNum = (_pick_bits(&_place_bits, 12) * 2) + 0x14;
+ if (_casinoType != 0) {
+ sceneNum = (pickBits(&_placeBits, 12) * 2) + 0x14;
} else {
- sceneNum = (_pick_bits(&_place_bits, 8) * 2) + 0x2D;
+ sceneNum = (pickBits(&_placeBits, 8) * 2) + 0x2D;
}
- _cur_scene = _NumtoScene(sceneNum);
+ _curScene = numToScene(sceneNum);
}
}
-void GameJohnnyRock::_scene_nxtscn_entpoolhall(Scene *scene) {
- if (_pool_hall_type == 0) {
- _cur_scene = "scene67";
- } else if (_pool_hall_type == 1) {
- _cur_scene = "scene73";
+void GameJohnnyRock::sceneNxtscnEnterPoolhall(Scene *scene) {
+ if (_poolHallType == 0) {
+ _curScene = "scene67";
+ } else if (_poolHallType == 1) {
+ _curScene = "scene73";
} else {
- _cur_scene = "scene78";
+ _curScene = "scene78";
}
}
-void GameJohnnyRock::_scene_nxtscn_poolhclue(Scene *scene) {
- _pool_hall = 1;
- uint16 clue = _pick_bits(&_clues, 12);
- _clue_table[_this_clue] = clue;
- _this_clue++;
- _cur_scene = _NumtoScene(clue + 0xC3);
+void GameJohnnyRock::sceneNxtscnPoolhallClue(Scene *scene) {
+ _poolHall = 1;
+ uint16 clue = pickBits(&_clues, 12);
+ _clueTable[_thisClue] = clue;
+ _thisClue++;
+ _curScene = numToScene(clue + 0xC3);
}
-void GameJohnnyRock::_scene_nxtscn_entwarehse(Scene *scene) {
- if (_warehouse_type == 0) {
- _cur_scene = "scene94";
- } else if (_warehouse_type == 1) {
- _cur_scene = "scene102";
+void GameJohnnyRock::sceneNxtscnEnterWarehouse(Scene *scene) {
+ if (_warehouseType == 0) {
+ _curScene = "scene94";
+ } else if (_warehouseType == 1) {
+ _curScene = "scene102";
} else {
- _cur_scene = "scene110";
+ _curScene = "scene110";
}
}
-void GameJohnnyRock::_scene_nxtscn_warehseclue(Scene *scene) {
+void GameJohnnyRock::sceneNxtscnWarehouseClue(Scene *scene) {
_warehouse = 1;
- uint16 clue = _pick_bits(&_clues, 12);
- _clue_table[_this_clue] = clue;
- _this_clue++;
- _cur_scene = _NumtoScene(clue + 0xC3);
+ uint16 clue = pickBits(&_clues, 12);
+ _clueTable[_thisClue] = clue;
+ _thisClue++;
+ _curScene = numToScene(clue + 0xC3);
}
-void GameJohnnyRock::_scene_nxtscn_entgarage(Scene *scene) {
- if (_garage_type != 0) {
- _cur_scene = "scene124";
+void GameJohnnyRock::sceneNxtscnEnterGarage(Scene *scene) {
+ if (_garageType != 0) {
+ _curScene = "scene124";
} else {
- _cur_scene = "scene131";
+ _curScene = "scene131";
}
}
-void GameJohnnyRock::_scene_nxtscn_garageclue(Scene *scene) {
+void GameJohnnyRock::sceneNxtscnGarageClue(Scene *scene) {
_garage = 1;
- uint16 clue = _pick_bits(&_clues, 12);
- _clue_table[_this_clue] = clue;
- _this_clue++;
- _cur_scene = _NumtoScene(clue + 0xC3);
+ uint16 clue = pickBits(&_clues, 12);
+ _clueTable[_thisClue] = clue;
+ _thisClue++;
+ _curScene = numToScene(clue + 0xC3);
}
-void GameJohnnyRock::_scene_nxtscn_entmansion(Scene *scene) {
+void GameJohnnyRock::sceneNxtscnEnterMansion(Scene *scene) {
_mansion = 1;
- _random_count++;
- uint16 maxRandom = ((_this_difficulty * 2) + 7);
- if (_random_count <= maxRandom) {
- uint16 picked = _pick_bits(&_place_bits, 5);
- _cur_scene = _NumtoScene((picked * 2) + 0xB8);
+ _randomCount++;
+ uint16 maxRandom = ((_thisDifficulty * 2) + 7);
+ if (_randomCount <= maxRandom) {
+ uint16 picked = pickBits(&_placeBits, 5);
+ _curScene = numToScene((picked * 2) + 0xB8);
} else {
_mansion = 2;
- _cur_scene = "scene194";
+ _curScene = "scene194";
}
}
-void GameJohnnyRock::_scene_nxtscn_giveclue(Scene *scene) {
+void GameJohnnyRock::sceneNxtscnGiveClue(Scene *scene) {
_score += 1000;
- _game_money += 50;
- _scene_nxtscn_pickmap(scene);
+ _gameMoney += 50;
+ sceneNxtscnPickMap(scene);
}
-void GameJohnnyRock::_scene_nxtscn_pikflwrman(Scene *scene) {
+void GameJohnnyRock::sceneNxtscnPickFlowerMan(Scene *scene) {
if (_rnd->getRandomBit()) {
- _cur_scene = "scene10a";
+ _curScene = "scene10a";
} else {
- _cur_scene = "scene12a";
+ _curScene = "scene12a";
}
}
-void GameJohnnyRock::_scene_nxtscn_randomscene(Scene *scene) {
- _random_count++;
- if (_random_count <= _max_random_count) {
- _place_bits = _pick_bits(&_place_bits, _random_scenes[0]);
- _cur_scene = _NumtoScene(_random_scenes[_place_bits + 4]);
+void GameJohnnyRock::sceneNxtscnRandomScene(Scene *scene) {
+ _randomCount++;
+ if (_randomCount <= _maxRandomCount) {
+ _placeBits = pickBits(&_placeBits, _randomScenes[0]);
+ _curScene = numToScene(_randomScenes[_placeBits + 4]);
} else {
- if (_random_scenes[2] != 0) {
- _cur_scene = _NumtoScene(_random_scenes[2]);
- } else if (_repeat_random_place > 0) {
- _repeat_random_place--;
- _max_repeat--;
- uint16 picked = _pick_random_place(_repeat_random_place + 5);
- _cur_scene = _NumtoScene(picked);
+ if (_randomScenes[2] != 0) {
+ _curScene = numToScene(_randomScenes[2]);
+ } else if (_repeatRandomPlace > 0) {
+ _repeatRandomPlace--;
+ _maxRepeat--;
+ uint16 picked = pickRandomPlace(_repeatRandomPlace + 5);
+ _curScene = numToScene(picked);
} else {
- _cur_scene = _NumtoScene(_goto_after_random);
- _goto_after_random = 0;
- _place_bits = 0;
- _random_count = 1;
+ _curScene = numToScene(_gotoAfterRandom);
+ _gotoAfterRandom = 0;
+ _placeBits = 0;
+ _randomCount = 1;
}
}
}
-void GameJohnnyRock::_scene_nxtscn_endrandscene(Scene *scene) {
- if (_repeat_random_place > 0) {
- _repeat_random_place--;
- _max_repeat--;
- uint16 picked = _pick_random_place(_repeat_random_place + 5);
- _cur_scene = _NumtoScene(picked);
+void GameJohnnyRock::sceneNxtscnEndRandScene(Scene *scene) {
+ if (_repeatRandomPlace > 0) {
+ _repeatRandomPlace--;
+ _maxRepeat--;
+ uint16 picked = pickRandomPlace(_repeatRandomPlace + 5);
+ _curScene = numToScene(picked);
} else {
- _cur_scene = _NumtoScene(_goto_after_random);
- _goto_after_random = 0;
- _place_bits = 0;
- _random_count = 1;
+ _curScene = numToScene(_gotoAfterRandom);
+ _gotoAfterRandom = 0;
+ _placeBits = 0;
+ _randomCount = 1;
}
}
-void GameJohnnyRock::_scene_nxtscn_killinnocent(Scene *scene) {
+void GameJohnnyRock::sceneNxtscnKillInnocent(Scene *scene) {
if (!_debug_godMode) {
- _game_money -= 400;
+ _gameMoney -= 400;
}
- if (_game_money < 0) {
- _ret_scene = "scene358";
- _cur_scene = "scene151";
+ if (_gameMoney < 0) {
+ _retScene = "scene358";
+ _curScene = "scene151";
} else {
switch (_rnd->getRandomNumber(2)) {
case 0:
- _cur_scene = "scene151";
+ _curScene = "scene151";
break;
case 1:
- _cur_scene = "scene152";
+ _curScene = "scene152";
break;
case 2:
- _cur_scene = "scene153";
+ _curScene = "scene153";
break;
}
}
}
// Script functions: WepDwn
-void GameJohnnyRock::_scene_default_wepdwn(Scene *scene) {
+void GameJohnnyRock::sceneDefaultWepdwn(Scene *scene) {
_inHolster = 9;
_whichGun = 7;
- _UpdateMouse();
+ updateMouse();
}
// Debug methods
-void GameJohnnyRock::debug_warpTo(int val) {
+void GameJohnnyRock::debugWarpTo(int val) {
// TODO implement
}
@@ -1752,7 +1746,7 @@ bool DebuggerJohnnyRock::cmdWarpTo(int argc, const char **argv) {
return true;
} else {
int val = atoi(argv[1]);
- _game->debug_warpTo(val);
+ _game->debugWarpTo(val);
return false;
}
}
diff --git a/engines/alg/game_johnnyrock.h b/engines/alg/game_johnnyrock.h
index 6c11b14454d..2d424aed3ba 100644
--- a/engines/alg/game_johnnyrock.h
+++ b/engines/alg/game_johnnyrock.h
@@ -52,10 +52,10 @@ class GameJohnnyRock : public Game {
};
public:
- GameJohnnyRock(AlgEngine *vm, const ADGameDescription *desc);
+ GameJohnnyRock(AlgEngine *vm, const AlgGameDescription *gd);
~GameJohnnyRock();
Common::Error run();
- void debug_warpTo(int val);
+ void debugWarpTo(int val);
private:
void init();
@@ -84,193 +84,193 @@ private:
Graphics::Surface _bulletholeIcon;
// constants
- const int16 _random_rooftop[6] = {2, -4, 0x104, 0x1E, 0x100, 0x102};
- const int16 _random_theater[9] = {5, -5, 0x111, 0x1E, 0x107, 0x109, 0x10B, 0x10D, 0x10F};
- const int16 _random_alley[10] = {6, -4, 0, 0x1E, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D};
- const int16 _random_funeral[10] = {6, -5, 0, 0x1E, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129};
- const int16 _random_funeral_mr[10] = {6, -5, 0x12B, 0x1E, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129};
- const int16 _random_book[7] = {3, 5, 0, 0x1E, 0x12E, 0x130, 0x132};
- const int16 _random_book_mr[8] = {4, 0x5, 0, 0x1E, 0x12E, 0x130, 0x132, 0x134};
- const int16 _random_stairway[8] = {4, -3, 0, 0x1E, 0x139, 0x13B, 0x13D, 0x13F};
- const int16 _random_hall[8] = {4, -5, 0, 0x1E, 0x141, 0x143, 0x145, 0x146};
- const int16 _random_windows[10] = {6, -3, 0, 0x1E, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E};
- const int16 _random_car[5] = {1, 1, 0, 0, 0x0FE};
- const int16 _random_hall1[5] = {1, 1, 0, 0x1E, 0x148};
- const int16 _random_elevator[5] = {1, 1, 0, 0, 0x14C};
- const int16 _random_elevator_mr[5] = {1, 1, 0, 0, 0x151};
- const int16 _random_baby[5] = {1, 1, 0, 0, 0x160};
- const int16 *_random_places[6] = {_random_windows, _random_stairway, _random_car, _random_hall1, _random_elevator, _random_baby};
- const int16 *_random_places_mr[8] = {_random_book_mr, _random_funeral_mr, _random_alley, _random_theater, _random_hall, _random_windows, _random_hall1, _random_rooftop};
+ const int16 _randomRooftop[6] = {2, -4, 0x104, 0x1E, 0x100, 0x102};
+ const int16 _randomTheater[9] = {5, -5, 0x111, 0x1E, 0x107, 0x109, 0x10B, 0x10D, 0x10F};
+ const int16 _randomAlley[10] = {6, -4, 0, 0x1E, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D};
+ const int16 _randomFuneral[10] = {6, -5, 0, 0x1E, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129};
+ const int16 _randomFuneralMR[10] = {6, -5, 0x12B, 0x1E, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129};
+ const int16 _randomBook[7] = {3, 5, 0, 0x1E, 0x12E, 0x130, 0x132};
+ const int16 _randomBookMR[8] = {4, 0x5, 0, 0x1E, 0x12E, 0x130, 0x132, 0x134};
+ const int16 _randomStairway[8] = {4, -3, 0, 0x1E, 0x139, 0x13B, 0x13D, 0x13F};
+ const int16 _randomHall[8] = {4, -5, 0, 0x1E, 0x141, 0x143, 0x145, 0x146};
+ const int16 _randomWindows[10] = {6, -3, 0, 0x1E, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E};
+ const int16 _randomCar[5] = {1, 1, 0, 0, 0x0FE};
+ const int16 _randomHall1[5] = {1, 1, 0, 0x1E, 0x148};
+ const int16 _randomElevator[5] = {1, 1, 0, 0, 0x14C};
+ const int16 _randomElevatorMR[5] = {1, 1, 0, 0, 0x151};
+ const int16 _randomBaby[5] = {1, 1, 0, 0, 0x160};
+ const int16 *_randomPlaces[6] = {_randomWindows, _randomStairway, _randomCar, _randomHall1, _randomElevator, _randomBaby};
+ const int16 *_randomPlacesMR[8] = {_randomBookMR, _randomFuneralMR, _randomAlley, _randomTheater, _randomHall, _randomWindows, _randomHall1, _randomRooftop};
- const int16 _office_table[5] = {0xA7, 0x9F, 0x9E, 0x0A0, 0x0AD};
+ const int16 _officeTable[5] = {0xA7, 0x9F, 0x9E, 0x0A0, 0x0AD};
- const uint16 _diffpos[4][2] = {{0, 0}, {0xCD, 0x35}, {0xD2, 0x53}, {0xD2, 0x6E}};
+ const uint16 _diffPos[4][2] = {{0, 0}, {0xCD, 0x35}, {0xD2, 0x53}, {0xD2, 0x6E}};
// gamestate
- uint16 _total_dies = 0;
- int16 _game_money = 0;
- int16 _oldgame_money = 0;
- uint16 _ammo_again = 0;
- uint16 _map_timeout = 0;
- uint8 _lucky_number = 0;
- uint8 _this_map = 0;
+ uint16 _totalDies = 0;
+ int16 _gameMoney = 0;
+ int16 _oldGameMoney = 0;
+ uint16 _ammoAgain = 0;
+ uint16 _mapTimeout = 0;
+ uint8 _luckyNumber = 0;
+ uint8 _thisMap = 0;
uint16 _clues = 0;
- uint16 _place_bits = 0;
- uint8 _random_count = 0;
- uint16 _doctor_bits = 0;
- uint16 _undertaker_bits = 0;
- uint16 _this_clue = 0;
- uint8 _got_this_number = 0;
+ uint16 _placeBits = 0;
+ uint8 _randomCount = 0;
+ uint16 _doctorBits = 0;
+ uint16 _undertakerBits = 0;
+ uint16 _thisClue = 0;
+ uint8 _gotThisNumber = 0;
uint8 _casino = 0;
- uint8 _pool_hall = 0;
+ uint8 _poolHall = 0;
uint8 _warehouse = 0;
uint8 _garage = 0;
uint8 _office = 0;
- uint8 _casino_type = 0;
- uint8 _pool_hall_type = 0;
- uint8 _warehouse_type = 0;
- uint8 _garage_type = 0;
+ uint8 _casinoType = 0;
+ uint8 _poolHallType = 0;
+ uint8 _warehouseType = 0;
+ uint8 _garageType = 0;
uint8 _mansion = 0;
- uint8 _in_warehouse = 0;
- uint8 _in_office = 0;
- uint16 _got_to = 0;
- uint8 _who_did_it = 0;
- uint8 _had_go_to_mansion = 0;
- uint16 _office_count = 0;
- uint16 _random_place_bits = 0;
- uint8 _max_random_count = 0;
- uint16 _goto_after_random = 0;
- uint16 _repeat_random_place = 0;
- uint16 _max_repeat = 0;
- uint16 _got_this_clue = 0;
- uint16 _did_continue = 0;
- uint16 _this_game_time = 0;
- uint8 _this_difficulty = 0;
- uint8 _clue_table[4];
+ uint8 _inWarehouse = 0;
+ uint8 _inOffice = 0;
+ uint16 _gotTo = 0;
+ uint8 _whoDidIt = 0;
+ uint8 _hadGoToMansion = 0;
+ uint16 _officeCount = 0;
+ uint16 _randomPlaceBits = 0;
+ uint8 _maxRandomCount = 0;
+ uint16 _gotoAfterRandom = 0;
+ uint16 _repeatRandomPlace = 0;
+ uint16 _maxRepeat = 0;
+ uint16 _gotThisClue = 0;
+ uint16 _didContinue = 0;
+ uint16 _thisGameTime = 0;
+ uint8 _thisDifficulty = 0;
+ uint8 _clueTable[4];
uint8 _combinations[4];
- uint16 _entrance_index[20];
- const int16 *_random_scenes = nullptr;
- uint8 _random_scenes_savestate_index = 0;
- uint16 _random_scenes_index[10];
- Common::String _money_scene = "";
- uint8 _mgun_cnt = 0;
- uint32 _mach_gun_timer = 0;
+ uint16 _entranceIndex[20];
+ const int16 *_randomScenes = nullptr;
+ uint8 _randomScenesSavestateIndex = 0;
+ uint16 _randomScenesIndex[10];
+ Common::String _moneyScene = "";
+ uint8 _mgunCnt = 0;
+ uint32 _machGunTimer = 0;
// base functions
- bool __Fired(Common::Point *point);
- void _NewGame();
- void _ResetParams();
- void _OutShots();
- void _DoMenu();
- void _UpdateStat();
- void _DisplayScore();
- void _ShowDifficulty(uint8 newDifficulty, bool updateCursor);
- void _ChangeDifficulty(uint8 newDifficulty);
- void _DoCursor();
- void _UpdateMouse();
- void _MoveMouse();
- bool _WeaponDown();
- bool _SaveState();
- bool _LoadState();
- void _DoMoneySound();
+ bool fired(Common::Point *point);
+ void newGame();
+ void resetParams();
+ void outShots();
+ void doMenu();
+ void updateStat();
+ void displayScore();
+ void showDifficulty(uint8 newDifficulty, bool updateCursor);
+ void changeDifficulty(uint8 newDifficulty);
+ void updateCursor();
+ void updateMouse();
+ void moveMouse();
+ bool weaponDown();
+ bool saveState();
+ bool loadState();
+ void doMoneySound();
// misc game functions
- Common::String _NumtoScene(int n);
- uint16 _ScenetoNum(Common::String sceneName);
- void _default_bullethole(Common::Point *point);
- uint16 _pick_bits(uint16 *bits, uint8 max);
- uint16 _pick_random_place(uint8 place);
- void _show_combination();
- void _shotclue(uint8 clue);
- void _shotcombination(uint8 combination, bool combinationB);
- void _shotluckynumber(uint8 number);
+ Common::String numToScene(int n);
+ uint16 sceneToNum(Common::String sceneName);
+ void defaultBullethole(Common::Point *point);
+ uint16 pickBits(uint16 *bits, uint8 max);
+ uint16 pickRandomPlace(uint8 place);
+ void showCombination();
+ void shotClue(uint8 clue);
+ void shotCombination(uint8 combination, bool combinationB);
+ void shotLuckyNumber(uint8 number);
// Script functions: Zone
- void _zone_bullethole(Common::Point *point);
+ void zoneBullethole(Common::Point *point);
// Script functions: RectHit
- void _rect_shotmenu(Rect *rect);
- void _rect_save(Rect *rect);
- void _rect_load(Rect *rect);
- void _rect_continue(Rect *rect);
- void _rect_start(Rect *rect);
- void _rect_killinnocent(Rect *rect);
- void _rect_selectcasino(Rect *rect);
- void _rect_selectpoolhall(Rect *rect);
- void _rect_selectwarehouse(Rect *rect);
- void _rect_selectgarage(Rect *rect);
- void _rect_selectmansion(Rect *rect);
- void _rect_selectammo(Rect *rect);
- void _rect_selectoffice(Rect *rect);
- void _rect_shotmanbust(Rect *rect);
- void _rect_shotwomanbust(Rect *rect);
- void _rect_shotbluevase(Rect *rect);
- void _rect_shotcat(Rect *rect);
- void _rect_shotindian(Rect *rect);
- void _rect_shotplate(Rect *rect);
- void _rect_shotbluedresspic(Rect *rect);
- void _rect_shotmodernpic(Rect *rect);
- void _rect_shotmonalisa(Rect *rect);
- void _rect_shotgwashington(Rect *rect);
- void _rect_shotboyinredpic(Rect *rect);
- void _rect_shotcoatofarms(Rect *rect);
- void _rect_shotcombinationA0(Rect *rect);
- void _rect_shotcombinationA1(Rect *rect);
- void _rect_shotcombinationA2(Rect *rect);
- void _rect_shotcombinationA3(Rect *rect);
- void _rect_shotcombinationA4(Rect *rect);
- void _rect_shotcombinationA5(Rect *rect);
- void _rect_shotcombinationB0(Rect *rect);
- void _rect_shotcombinationB1(Rect *rect);
- void _rect_shotcombinationB2(Rect *rect);
- void _rect_shotcombinationB3(Rect *rect);
- void _rect_shotcombinationB4(Rect *rect);
- void _rect_shotcombinationB5(Rect *rect);
- void _rect_shotluckynum0(Rect *rect);
- void _rect_shotluckynum1(Rect *rect);
- void _rect_shotluckynum2(Rect *rect);
- void _rect_shotluckynum3(Rect *rect);
- void _rect_shotluckynum4(Rect *rect);
- void _rect_shotluckynum5(Rect *rect);
+ void rectShotMenu(Rect *rect);
+ void rectSave(Rect *rect);
+ void rectLoad(Rect *rect);
+ void rectContinue(Rect *rect);
+ void rectStart(Rect *rect);
+ void rectKillInnocent(Rect *rect);
+ void rectSelectCasino(Rect *rect);
+ void rectSelectPoolhall(Rect *rect);
+ void rectSelectWarehouse(Rect *rect);
+ void rectSelectGarage(Rect *rect);
+ void rectSelectMansion(Rect *rect);
+ void rectSelectAmmo(Rect *rect);
+ void rectSelectOffice(Rect *rect);
+ void rectShotManBust(Rect *rect);
+ void rectShotWomanBust(Rect *rect);
+ void rectShotBlueVase(Rect *rect);
+ void rectShotCat(Rect *rect);
+ void rectShotIndian(Rect *rect);
+ void rectShotPlate(Rect *rect);
+ void rectShotBlueDressPic(Rect *rect);
+ void rectShotModernPic(Rect *rect);
+ void rectShotMonaLisa(Rect *rect);
+ void rectShotGWashington(Rect *rect);
+ void rectShotBoyInRedPic(Rect *rect);
+ void rectShotCoatOfArms(Rect *rect);
+ void rectShotCombinationA0(Rect *rect);
+ void rectShotCombinationA1(Rect *rect);
+ void rectShotCombinationA2(Rect *rect);
+ void rectShotCombinationA3(Rect *rect);
+ void rectShotCombinationA4(Rect *rect);
+ void rectShotCombinationA5(Rect *rect);
+ void rectShotCombinationB0(Rect *rect);
+ void rectShotCombinationB1(Rect *rect);
+ void rectShotCombinationB2(Rect *rect);
+ void rectShotCombinationB3(Rect *rect);
+ void rectShotCombinationB4(Rect *rect);
+ void rectShotCombinationB5(Rect *rect);
+ void rectShotLuckyNumber0(Rect *rect);
+ void rectShotLuckyNumber1(Rect *rect);
+ void rectShotLuckyNumber2(Rect *rect);
+ void rectShotLuckyNumber3(Rect *rect);
+ void rectShotLuckyNumber4(Rect *rect);
+ void rectShotLuckyNumber5(Rect *rect);
// Script functions: Scene InsOps
- void _scene_iso_shootpast(Scene *scene);
- void _scene_iso_spause(Scene *scene);
- void _scene_iso_gotocasino(Scene *scene);
- void _scene_iso_gotopoolh(Scene *scene);
- void _scene_iso_gotowarehse(Scene *scene);
- void _scene_iso_inwarehse2(Scene *scene);
- void _scene_iso_inwarehse3(Scene *scene);
- void _scene_iso_gotogarage(Scene *scene);
- void _scene_iso_gotomansion(Scene *scene);
- void _scene_iso_inmansion1(Scene *scene);
+ void sceneIsoShootpast(Scene *scene);
+ void sceneIsoShootpastPause(Scene *scene);
+ void sceneIsoGotoCasino(Scene *scene);
+ void sceneIsoGotoPoolhall(Scene *scene);
+ void sceneIsoGotoWarehouse(Scene *scene);
+ void sceneIsoInWarehouse2(Scene *scene);
+ void sceneIsoInwarehouse3(Scene *scene);
+ void sceneIsoGotoGarage(Scene *scene);
+ void sceneIsoGotoMansion(Scene *scene);
+ void sceneIsoInMansion1(Scene *scene);
// Script functions: Scene NxtScn
- void _scene_nxtscn_died(Scene *scene);
- void _scene_nxtscn_bombdead(Scene *scene);
- void _scene_nxtscn_pikundrtakr(Scene *scene);
- void _scene_nxtscn_callattract(Scene *scene);
- void _scene_nxtscn_pikluckno(Scene *scene);
- void _scene_nxtscn_pickmap(Scene *scene);
- void _scene_nxtscn_pickclue(Scene *scene);
- void _scene_nxtscn_maptimeout(Scene *scene);
- void _scene_nxtscn_entcasino(Scene *scene);
- void _scene_nxtscn_casinowhat(Scene *scene);
- void _scene_nxtscn_entpoolhall(Scene *scene);
- void _scene_nxtscn_poolhclue(Scene *scene);
- void _scene_nxtscn_entwarehse(Scene *scene);
- void _scene_nxtscn_warehseclue(Scene *scene);
- void _scene_nxtscn_entgarage(Scene *scene);
- void _scene_nxtscn_garageclue(Scene *scene);
- void _scene_nxtscn_entmansion(Scene *scene);
- void _scene_nxtscn_giveclue(Scene *scene);
- void _scene_nxtscn_pikflwrman(Scene *scene);
- void _scene_nxtscn_randomscene(Scene *scene);
- void _scene_nxtscn_endrandscene(Scene *scene);
- void _scene_nxtscn_killinnocent(Scene *scene);
+ void sceneNxtscnDied(Scene *scene);
+ void sceneNxtscnBombDead(Scene *scene);
+ void sceneNxtscnPickUndertaker(Scene *scene);
+ void sceneNxtscnCallAttract(Scene *scene);
+ void sceneNxtscnPickLuckyNumber(Scene *scene);
+ void sceneNxtscnPickMap(Scene *scene);
+ void sceneNxtscnPickClue(Scene *scene);
+ void sceneNxtscnMapTimeout(Scene *scene);
+ void sceneNxtscnEnterCasino(Scene *scene);
+ void sceneNxtscnCasinoWhat(Scene *scene);
+ void sceneNxtscnEnterPoolhall(Scene *scene);
+ void sceneNxtscnPoolhallClue(Scene *scene);
+ void sceneNxtscnEnterWarehouse(Scene *scene);
+ void sceneNxtscnWarehouseClue(Scene *scene);
+ void sceneNxtscnEnterGarage(Scene *scene);
+ void sceneNxtscnGarageClue(Scene *scene);
+ void sceneNxtscnEnterMansion(Scene *scene);
+ void sceneNxtscnGiveClue(Scene *scene);
+ void sceneNxtscnPickFlowerMan(Scene *scene);
+ void sceneNxtscnRandomScene(Scene *scene);
+ void sceneNxtscnEndRandScene(Scene *scene);
+ void sceneNxtscnKillInnocent(Scene *scene);
// Script functions: Scene WepDwn
- void _scene_default_wepdwn(Scene *scene);
+ void sceneDefaultWepdwn(Scene *scene);
};
class DebuggerJohnnyRock : public GUI::Debugger {
diff --git a/engines/alg/game_maddog.cpp b/engines/alg/game_maddog.cpp
index dd2766a151c..4003da03d46 100644
--- a/engines/alg/game_maddog.cpp
+++ b/engines/alg/game_maddog.cpp
@@ -25,7 +25,6 @@
#include "common/system.h"
#include "graphics/cursorman.h"
-#include "graphics/pixelformat.h"
#include "alg/game_maddog.h"
#include "alg/graphics.h"
@@ -33,7 +32,7 @@
namespace Alg {
-GameMaddog::GameMaddog(AlgEngine *vm, const ADGameDescription *desc) : Game(vm) {
+GameMaddog::GameMaddog(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
_libFileName = "maddog.lib";
}
@@ -41,28 +40,30 @@ GameMaddog::~GameMaddog() {
}
void GameMaddog::init() {
+ Game::init();
+
_videoPosX = 56;
_videoPosY = 8;
- _SetupCursorTimer();
+ setupCursorTimer();
loadLibArchive(_libFileName);
_sceneInfo->loadScnFile("maddog.scn");
- _startscene = _sceneInfo->getStartScene();
+ _startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
_menuzone = new Zone();
- _menuzone->name = "MainMenu";
- _menuzone->ptrfb = "GLOBALHIT";
+ _menuzone->_name = "MainMenu";
+ _menuzone->_ptrfb = "GLOBALHIT";
_menuzone->addRect(0x0C, 0xAC, 0x3D, 0xBF, nullptr, 0, "SHOTMENU", "0");
_menuzone->addRect(0x00, 0xA6, 0x013F, 0xC7, nullptr, 0, "DEFAULT", "0"); // _mm_bott
_menuzone->addRect(0x00, 0x00, 0x3B, 0xC7, nullptr, 0, "DEFAULT", "0"); // _mm_left
_submenzone = new Zone();
- _submenzone->name = "SubMenu";
- _submenzone->ptrfb = "GLOBALHIT";
+ _submenzone->_name = "SubMenu";
+ _submenzone->_ptrfb = "GLOBALHIT";
_submenzone->addRect(0x8A, 0x3B, 0xC2, 0x48, nullptr, 0, "STARTBOT", "0");
_submenzone->addRect(0x8A, 0x4E, 0xC2, 0x59, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x8A, 0x60, 0xC2, 0x6B, nullptr, 0, "CONTMENU", "0");
@@ -73,14 +74,14 @@ void GameMaddog::init() {
_submenzone->addRect(0x42, 0x53, 0x5C, 0x70, nullptr, 0, "RECTAVG", "0");
_submenzone->addRect(0x42, 0x72, 0x62, 0x8A, nullptr, 0, "RECTHARD", "0");
- _shotSound = _LoadSoundFile("blow.8b");
- _emptySound = _LoadSoundFile("empty.8b");
- _saveSound = _LoadSoundFile("saved.8b");
- _loadSound = _LoadSoundFile("loaded.8b");
- _skullSound = _LoadSoundFile("skull.8b");
- _easySound = _LoadSoundFile("deputy.8b");
- _avgSound = _LoadSoundFile("sheriff.8b");
- _hardSound = _LoadSoundFile("marshall.8b");
+ _shotSound = loadSoundFile("blow.8b");
+ _emptySound = loadSoundFile("empty.8b");
+ _saveSound = loadSoundFile("saved.8b");
+ _loadSound = loadSoundFile("loaded.8b");
+ _skullSound = loadSoundFile("skull.8b");
+ _easySound = loadSoundFile("deputy.8b");
+ _avgSound = loadSoundFile("sheriff.8b");
+ _hardSound = loadSoundFile("marshall.8b");
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
@@ -101,147 +102,147 @@ void GameMaddog::init() {
_background = AlgGraphics::loadVgaBackground("backgrnd.vga", _palette);
_screen->copyRectToSurface(_background->getPixels(), _background->pitch, 0, 0, _background->w, _background->h);
- _MoveMouse();
+ moveMouse();
}
void GameMaddog::registerScriptFunctions() {
#define ZONE_PTRFB_FUNCTION(name, func) _zonePtrFb[name] = new MDScriptFunctionPoint(this, &GameMaddog::func);
- ZONE_PTRFB_FUNCTION("DEFAULT", _zone_bullethole);
- ZONE_PTRFB_FUNCTION("GLOBALHIT", _zone_globalhit);
- ZONE_PTRFB_FUNCTION("BULLETHOLE", _zone_bullethole);
- ZONE_PTRFB_FUNCTION("SKULL", _zone_skullhole);
+ ZONE_PTRFB_FUNCTION("DEFAULT", zoneBullethole);
+ ZONE_PTRFB_FUNCTION("GLOBALHIT", zoneGlobalHit);
+ ZONE_PTRFB_FUNCTION("BULLETHOLE", zoneBullethole);
+ ZONE_PTRFB_FUNCTION("SKULL", zoneSkullhole);
#undef ZONE_PTRFB_FUNCTION
#define RECT_HIT_FUNCTION(name, func) _rectHitFuncs[name] = new MDScriptFunctionRect(this, &GameMaddog::func);
- RECT_HIT_FUNCTION("DEFAULT", _rect_newscene);
- RECT_HIT_FUNCTION("STARTMENU", _rect_start);
- RECT_HIT_FUNCTION("SHOTMENU", _rect_shotmenu);
- RECT_HIT_FUNCTION("EXITMENU", _rect_exit);
- RECT_HIT_FUNCTION("CONTMENU", _rect_continue);
- RECT_HIT_FUNCTION("RECTSAVE", _rect_save);
- RECT_HIT_FUNCTION("RECTLOAD", _rect_load);
- RECT_HIT_FUNCTION("RECTEASY", _rect_easy);
- RECT_HIT_FUNCTION("RECTAVG", _rect_average);
- RECT_HIT_FUNCTION("RECTHARD", _rect_hard);
- RECT_HIT_FUNCTION("STARTBOT", _rect_startbottles);
- RECT_HIT_FUNCTION("HIDEFRONT", _rect_hidefront);
- RECT_HIT_FUNCTION("HIDEREAR", _rect_hiderear);
- RECT_HIT_FUNCTION("NEWSCENE", _rect_newscene);
- RECT_HIT_FUNCTION("MENUSELECT", _rect_menuselect);
- RECT_HIT_FUNCTION("SKULL", _rect_skull);
- RECT_HIT_FUNCTION("KILLMAN", _rect_killman);
- RECT_HIT_FUNCTION("KILLWOMAN", _rect_killwoman);
- RECT_HIT_FUNCTION("PROSPSIGN", _rect_prospsign);
- RECT_HIT_FUNCTION("MINESIGN", _rect_minesign);
- RECT_HIT_FUNCTION("MINEITEM1", _rect_mineitem1);
- RECT_HIT_FUNCTION("MINEITEM2", _rect_mineitem2);
- RECT_HIT_FUNCTION("MINEITEM3", _rect_mineitem3);
- RECT_HIT_FUNCTION("MINELANTERN", _rect_minelantern);
- RECT_HIT_FUNCTION("SHOTHIDEOUT", _rect_shothideout);
- RECT_HIT_FUNCTION("SHOTRIGHT", _rect_shotright);
- RECT_HIT_FUNCTION("SHOTLEFT", _rect_shotleft);
+ RECT_HIT_FUNCTION("DEFAULT", rectNewScene);
+ RECT_HIT_FUNCTION("STARTMENU", rectStart);
+ RECT_HIT_FUNCTION("SHOTMENU", rectShotMenu);
+ RECT_HIT_FUNCTION("EXITMENU", rectExit);
+ RECT_HIT_FUNCTION("CONTMENU", rectContinue);
+ RECT_HIT_FUNCTION("RECTSAVE", rectSave);
+ RECT_HIT_FUNCTION("RECTLOAD", rectLoad);
+ RECT_HIT_FUNCTION("RECTEASY", rectEasy);
+ RECT_HIT_FUNCTION("RECTAVG", rectAverage);
+ RECT_HIT_FUNCTION("RECTHARD", rectHard);
+ RECT_HIT_FUNCTION("STARTBOT", rectStartBottles);
+ RECT_HIT_FUNCTION("HIDEFRONT", rectHideFront);
+ RECT_HIT_FUNCTION("HIDEREAR", rectHideRear);
+ RECT_HIT_FUNCTION("NEWSCENE", rectNewScene);
+ RECT_HIT_FUNCTION("MENUSELECT", rectMenuSelect);
+ RECT_HIT_FUNCTION("SKULL", rectSkull);
+ RECT_HIT_FUNCTION("KILLMAN", rectKillMan);
+ RECT_HIT_FUNCTION("KILLWOMAN", rectKillWoman);
+ RECT_HIT_FUNCTION("PROSPSIGN", rectProspSign);
+ RECT_HIT_FUNCTION("MINESIGN", rectMineSign);
+ RECT_HIT_FUNCTION("MINEITEM1", rectMineItem1);
+ RECT_HIT_FUNCTION("MINEITEM2", rectMineItem2);
+ RECT_HIT_FUNCTION("MINEITEM3", rectMineItem3);
+ RECT_HIT_FUNCTION("MINELANTERN", rectMineLantern);
+ RECT_HIT_FUNCTION("SHOTHIDEOUT", rectShotHideout);
+ RECT_HIT_FUNCTION("SHOTRIGHT", rectShotRight);
+ RECT_HIT_FUNCTION("SHOTLEFT", rectShotLeft);
#undef RECT_HIT_FUNCTION
#define PRE_OPS_FUNCTION(name, func) _scenePreOps[name] = new MDScriptFunctionScene(this, &GameMaddog::func);
- PRE_OPS_FUNCTION("DRAWRCT", _scene_pso_drawrct);
- PRE_OPS_FUNCTION("PAUSE", _scene_pso_pause);
- PRE_OPS_FUNCTION("PRESHOOTOUT", _scene_pso_shootout);
- PRE_OPS_FUNCTION("MDSHOOTOUT", _scene_pso_mdshootout);
- PRE_OPS_FUNCTION("FADEIN", _scene_pso_fadein);
- PRE_OPS_FUNCTION("PAUSFI", _scene_pso_pause_fadein);
- PRE_OPS_FUNCTION("PREREAD", _scene_pso_preread);
- PRE_OPS_FUNCTION("PAUSPR", _scene_pso_pause_preread);
- PRE_OPS_FUNCTION("DEFAULT", _scene_pso_drawrct);
+ PRE_OPS_FUNCTION("DRAWRCT", scenePsoDrawRct);
+ PRE_OPS_FUNCTION("PAUSE", scenePsoPause);
+ PRE_OPS_FUNCTION("PRESHOOTOUT", scenePsoShootout);
+ PRE_OPS_FUNCTION("MDSHOOTOUT", scenePsoMDShootout);
+ PRE_OPS_FUNCTION("FADEIN", scenePsoFadeIn);
+ PRE_OPS_FUNCTION("PAUSFI", scenePsoPauseFadeIn);
+ PRE_OPS_FUNCTION("PREREAD", scenePsoPreRead);
+ PRE_OPS_FUNCTION("PAUSPR", scenePsoPausePreRead);
+ PRE_OPS_FUNCTION("DEFAULT", scenePsoDrawRct);
#undef PRE_OPS_FUNCTION
#define INS_OPS_FUNCTION(name, func) _sceneInsOps[name] = new MDScriptFunctionScene(this, &GameMaddog::func);
- INS_OPS_FUNCTION("DEFAULT", _scene_iso_donothing);
- INS_OPS_FUNCTION("PAUSE", _scene_iso_pause);
- INS_OPS_FUNCTION("SPAUSE", _scene_iso_spause);
- INS_OPS_FUNCTION("STARTGAME", _scene_iso_startgame);
- INS_OPS_FUNCTION("SHOOTPAST", _scene_iso_shootpast);
- INS_OPS_FUNCTION("SKIPSALOON", _scene_iso_skipsaloon);
- INS_OPS_FUNCTION("SKIPSALOON2", _scene_iso_skipsaloon2);
- INS_OPS_FUNCTION("CHECKSALOON", _scene_iso_checksaloon);
- INS_OPS_FUNCTION("INTOSTABLE", _scene_iso_intostable);
- INS_OPS_FUNCTION("INTOFFICE", _scene_iso_intoffice);
- INS_OPS_FUNCTION("INTOBANK_SP", _scene_iso_intobank);
- INS_OPS_FUNCTION("CHKBARTNDR", _scene_iso_chkbartndr);
- INS_OPS_FUNCTION("DIDHIDEOUT", _scene_iso_didhideout);
- INS_OPS_FUNCTION("DIDSIGNPOST", _scene_iso_didsignpost);
- INS_OPS_FUNCTION("DOSHOOTOUT", _scene_iso_doshootout);
- INS_OPS_FUNCTION("MDSHOOTOUT", _scene_iso_mdshootout);
- INS_OPS_FUNCTION("SHOTINTO24", _scene_iso_donothing);
- INS_OPS_FUNCTION("SHOTINTO116", _scene_iso_shotinto116);
+ INS_OPS_FUNCTION("DEFAULT", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("PAUSE", sceneIsoPause);
+ INS_OPS_FUNCTION("SPAUSE", sceneIsoShootPastPause);
+ INS_OPS_FUNCTION("STARTGAME", sceneIsoStartGame);
+ INS_OPS_FUNCTION("SHOOTPAST", sceneIsoShootPast);
+ INS_OPS_FUNCTION("SKIPSALOON", sceneIsoSkipSaloon);
+ INS_OPS_FUNCTION("SKIPSALOON2", sceneIsoSkipSaloon2);
+ INS_OPS_FUNCTION("CHECKSALOON", sceneIsoCheckSaloon);
+ INS_OPS_FUNCTION("INTOSTABLE", sceneIsoIntoStable);
+ INS_OPS_FUNCTION("INTOFFICE", sceneIsoIntoOffice);
+ INS_OPS_FUNCTION("INTOBANK_SP", sceneIsoIntoBank);
+ INS_OPS_FUNCTION("CHKBARTNDR", sceneIsoCheckBartender);
+ INS_OPS_FUNCTION("DIDHIDEOUT", sceneIsoDidHideout);
+ INS_OPS_FUNCTION("DIDSIGNPOST", sceneIsoDidSignPost);
+ INS_OPS_FUNCTION("DOSHOOTOUT", sceneIsoDoShootout);
+ INS_OPS_FUNCTION("MDSHOOTOUT", sceneIsoMDShootout);
+ INS_OPS_FUNCTION("SHOTINTO24", sceneIsoDoNothing);
+ INS_OPS_FUNCTION("SHOTINTO116", sceneIsoShotInto116);
#undef INS_OPS_FUNCTION
#define NXT_SCN_FUNCTION(name, func) _sceneNxtScn[name] = new MDScriptFunctionScene(this, &GameMaddog::func);
- NXT_SCN_FUNCTION("DEFAULT", _scene_default_nxtscn);
- NXT_SCN_FUNCTION("DRAWGUN", _scene_default_nxtscn);
- NXT_SCN_FUNCTION("PICKBOTTLE", _scene_nxtscn_pickbottle);
- NXT_SCN_FUNCTION("DIED", _scene_nxtscn_died);
- NXT_SCN_FUNCTION("AUTOSEL", _scene_nxtscn_autosel);
- NXT_SCN_FUNCTION("FINSALOON", _scene_nxtscn_finsaloon);
- NXT_SCN_FUNCTION("FINOFFICE", _scene_nxtscn_finoffice);
- NXT_SCN_FUNCTION("FINSTABLE", _scene_nxtscn_finstable);
- NXT_SCN_FUNCTION("FINBANK", _scene_nxtscn_finbank);
- NXT_SCN_FUNCTION("PICSALOON", _scene_nxtscn_picsaloon);
- NXT_SCN_FUNCTION("KILLMAN", _scene_nxtscn_killman);
- NXT_SCN_FUNCTION("KILLWOMAN", _scene_nxtscn_killwoman);
- NXT_SCN_FUNCTION("BANK", _scene_nxtscn_bank);
- NXT_SCN_FUNCTION("STABLE", _scene_nxtscn_stable);
- NXT_SCN_FUNCTION("SAVPROSP", _scene_nxtscn_savprosp);
- NXT_SCN_FUNCTION("PICKTOSS", _scene_nxtscn_picktoss);
- NXT_SCN_FUNCTION("HITTOSS", _scene_nxtscn_hittoss);
- NXT_SCN_FUNCTION("MISSTOSS", _scene_nxtscn_misstoss);
- NXT_SCN_FUNCTION("PICKSIGN", _scene_nxtscn_picksign);
- NXT_SCN_FUNCTION("BROCKMAN", _scene_nxtscn_brockman);
- NXT_SCN_FUNCTION("LROCKMAN", _scene_nxtscn_lrockman);
- NXT_SCN_FUNCTION("HOTELMEN", _scene_nxtscn_hotelmen);
+ NXT_SCN_FUNCTION("DEFAULT", sceneDefaultNxtscn);
+ NXT_SCN_FUNCTION("DRAWGUN", sceneDefaultNxtscn);
+ NXT_SCN_FUNCTION("PICKBOTTLE", sceneNxtscnPickBottle);
+ NXT_SCN_FUNCTION("DIED", sceneNxtscnDied);
+ NXT_SCN_FUNCTION("AUTOSEL", sceneNxtscnAutoSelect);
+ NXT_SCN_FUNCTION("FINSALOON", sceneNxtscnFinishSaloon);
+ NXT_SCN_FUNCTION("FINOFFICE", sceneNxtscnFinishOffice);
+ NXT_SCN_FUNCTION("FINSTABLE", sceneNxtscnFinishStable);
+ NXT_SCN_FUNCTION("FINBANK", sceneNxtscnFinishBank);
+ NXT_SCN_FUNCTION("PICSALOON", sceneNxtscnPicSaloon);
+ NXT_SCN_FUNCTION("KILLMAN", sceneNxtscnKillMan);
+ NXT_SCN_FUNCTION("KILLWOMAN", sceneNxtscnKillWoman);
+ NXT_SCN_FUNCTION("BANK", sceneNxtscnBank);
+ NXT_SCN_FUNCTION("STABLE", sceneNxtscnStable);
+ NXT_SCN_FUNCTION("SAVPROSP", sceneNxtscnSavProsp);
+ NXT_SCN_FUNCTION("PICKTOSS", sceneNxtscnPickToss);
+ NXT_SCN_FUNCTION("HITTOSS", sceneNxtscnHitToss);
+ NXT_SCN_FUNCTION("MISSTOSS", sceneNxtscnMissToss);
+ NXT_SCN_FUNCTION("PICKSIGN", sceneNxtscnPickSign);
+ NXT_SCN_FUNCTION("BROCKMAN", sceneNxtscnBRockMan);
+ NXT_SCN_FUNCTION("LROCKMAN", sceneNxtscnLRockMan);
+ NXT_SCN_FUNCTION("HOTELMEN", sceneNxtscnHotelMen);
#undef NXT_SCN_FUNCTION
- _sceneShowMsg["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::_scene_sm_donothing);
- _sceneWepDwn["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::_scene_default_wepdwn);
- _sceneScnScr["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::_scene_default_score);
- _sceneNxtFrm["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::_scene_nxtfrm);
+ _sceneShowMsg["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::sceneSmDonothing);
+ _sceneWepDwn["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::sceneDefaultWepdwn);
+ _sceneScnScr["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::sceneDefaultScore);
+ _sceneNxtFrm["DEFAULT"] = new MDScriptFunctionScene(this, &GameMaddog::sceneNxtfrm);
}
void GameMaddog::verifyScriptFunctions() {
Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
for (size_t i = 0; i < scenes->size(); i++) {
Scene *scene = (*scenes)[i];
- getScriptFunctionScene(PREOP, scene->preop);
+ getScriptFunctionScene(PREOP, scene->_preop);
// TODO: SHOWMSG
- getScriptFunctionScene(INSOP, scene->insop);
- getScriptFunctionScene(WEPDWN, scene->wepdwn);
- getScriptFunctionScene(SCNSCR, scene->scnscr);
- getScriptFunctionScene(NXTFRM, scene->nxtfrm);
- getScriptFunctionScene(NXTSCN, scene->nxtscn);
- for (size_t j = 0; j < scene->zones.size(); j++) {
- Zone *zone = scene->zones[j];
- getScriptFunctionZonePtrFb(zone->ptrfb);
- for (size_t k = 0; k < zone->rects.size(); k++) {
- getScriptFunctionRectHit(zone->rects[k].rectHit);
+ getScriptFunctionScene(INSOP, scene->_insop);
+ getScriptFunctionScene(WEPDWN, scene->_wepdwn);
+ getScriptFunctionScene(SCNSCR, scene->_scnscr);
+ getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
+ getScriptFunctionScene(NXTSCN, scene->_nxtscn);
+ for (size_t j = 0; j < scene->_zones.size(); j++) {
+ Zone *zone = scene->_zones[j];
+ getScriptFunctionZonePtrFb(zone->_ptrfb);
+ for (size_t k = 0; k < zone->_rects.size(); k++) {
+ getScriptFunctionRectHit(zone->_rects[k]._rectHit);
}
}
}
}
MDScriptFunctionPoint GameMaddog::getScriptFunctionZonePtrFb(Common::String name) {
- MDScriptFunctionPointMap::iterator it = _zonePtrFb.find(name);
+ auto it = _zonePtrFb.find(name);
if (it != _zonePtrFb.end()) {
return (*(*it)._value);
} else {
- error("Could not find zonePtrFb function: %s", name.c_str());
+ error("GameMaddog::getScriptFunctionZonePtrFb(): Could not find zonePtrFb function: %s", name.c_str());
}
}
MDScriptFunctionRect GameMaddog::getScriptFunctionRectHit(Common::String name) {
- MDScriptFunctionRectMap::iterator it = _rectHitFuncs.find(name);
+ auto it = _rectHitFuncs.find(name);
if (it != _rectHitFuncs.end()) {
return (*(*it)._value);
} else {
- error("Could not find rectHit function: %s", name.c_str());
+ error("GameMaddog::getScriptFunctionRectHit(): Could not find rectHit function: %s", name.c_str());
}
}
@@ -270,7 +271,7 @@ MDScriptFunctionScene GameMaddog::getScriptFunctionScene(SceneFuncType type, Com
functionMap = &_sceneNxtScn;
break;
default:
- error("Unkown scene script type: %u", type);
+ error("GameMaddog::getScriptFunctionScene(): Unkown scene script type: %u", type);
break;
}
MDScriptFunctionSceneMap::iterator it;
@@ -278,7 +279,7 @@ MDScriptFunctionScene GameMaddog::getScriptFunctionScene(SceneFuncType type, Com
if (it != functionMap->end()) {
return (*(*it)._value);
Commit: a8205c964dd956d7e61b548b276fbc6aa264f43d
https://github.com/scummvm/scummvm/commit/a8205c964dd956d7e61b548b276fbc6aa264f43d
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: Graphics: fix unnecessary copying of surfaces on load
Changed paths:
engines/alg/game.h
engines/alg/game_bountyhunter.cpp
engines/alg/game_bountyhunter.h
engines/alg/game_crimepatrol.cpp
engines/alg/game_crimepatrol.h
engines/alg/game_drugwars.cpp
engines/alg/game_drugwars.h
engines/alg/game_johnnyrock.cpp
engines/alg/game_johnnyrock.h
engines/alg/game_maddog.cpp
engines/alg/game_maddog.h
engines/alg/game_maddog2.cpp
engines/alg/game_maddog2.h
engines/alg/game_spacepirates.cpp
engines/alg/game_spacepirates.h
engines/alg/graphics.cpp
engines/alg/graphics.h
diff --git a/engines/alg/game.h b/engines/alg/game.h
index eb28d1ba82f..51369c8e8ce 100644
--- a/engines/alg/game.h
+++ b/engines/alg/game.h
@@ -61,8 +61,8 @@ protected:
Graphics::Surface *_background;
Graphics::Surface *_screen;
- Common::Array<Graphics::Surface> *_gun;
- Common::Array<Graphics::Surface> *_numbers;
+ Common::Array<Graphics::Surface *> *_gun;
+ Common::Array<Graphics::Surface *> *_numbers;
Audio::SeekableAudioStream *_saveSound = nullptr;
Audio::SeekableAudioStream *_loadSound = nullptr;
diff --git a/engines/alg/game_bountyhunter.cpp b/engines/alg/game_bountyhunter.cpp
index 6c765f470e8..46f72d06954 100644
--- a/engines/alg/game_bountyhunter.cpp
+++ b/engines/alg/game_bountyhunter.cpp
@@ -84,18 +84,18 @@ void GameBountyHunter::init() {
_gun = AlgGraphics::loadScreenCoordAniImage("bh_gun.ani", _palette);
_shotgun = AlgGraphics::loadScreenCoordAniImage("bh_buck.ani", _palette);
_numbers = AlgGraphics::loadAniImage("bh_num.ani", _palette);
- Common::Array<Graphics::Surface> *bullets = AlgGraphics::loadAniImage("bh_ammo.ani", _palette);
+ auto bullets = AlgGraphics::loadAniImage("bh_ammo.ani", _palette);
_shotIcon = (*bullets)[0];
_emptyIcon = (*bullets)[1];
- Common::Array<Graphics::Surface> *lives = AlgGraphics::loadAniImage("bh_life.ani", _palette);
+ auto lives = AlgGraphics::loadAniImage("bh_life.ani", _palette);
_liveIcon = (*lives)[0];
_deadIcon = (*lives)[1];
- Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("bh_hole.ani", _palette);
+ auto hole = AlgGraphics::loadScreenCoordAniImage("bh_hole.ani", _palette);
_bulletholeIcon = (*hole)[0];
- Common::Array<Graphics::Surface> *players = AlgGraphics::loadAniImage("bh_plyr.ani", _palette);
+ auto players = AlgGraphics::loadAniImage("bh_plyr.ani", _palette);
_playersIcon1 = (*players)[0];
_playersIcon2 = (*players)[1];
- Common::Array<Graphics::Surface> *text = AlgGraphics::loadAniImage("bh_text.ani", _palette);
+ auto text = AlgGraphics::loadAniImage("bh_text.ani", _palette);
_textScoreIcon = (*text)[0];
_textMenuIcon = (*text)[1];
_textBlackBarIcon = (*text)[2];
@@ -470,9 +470,9 @@ void GameBountyHunter::updateCursor() {
void GameBountyHunter::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ Graphics::Surface *cursor = (*_gun)[_whichGun];
if (_playerGun[0] == 2 && _whichGun < 2) {
- cursor = &(*_shotgun)[_whichGun];
+ cursor = (*_shotgun)[_whichGun];
}
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 8;
@@ -522,12 +522,12 @@ void GameBountyHunter::displayLivesLeft(uint8 player) {
}
int posY = 0x67;
for (int i = 0; i < 3; i++) {
- AlgGraphics::drawImage(_screen, &_deadIcon, 0x12F, posY);
+ AlgGraphics::drawImage(_screen, _deadIcon, 0x12F, posY);
posY += 0xE;
}
posY = 0x67;
for (int i = 0; i < _lives; i++) {
- AlgGraphics::drawImage(_screen, &_liveIcon, 0x12F, posY);
+ AlgGraphics::drawImage(_screen, _liveIcon, 0x12F, posY);
posY += 0xE;
}
_oldLives = _lives;
@@ -541,7 +541,7 @@ void GameBountyHunter::displayScores(uint8 player) {
int posX = 0x9B;
for (int i = 0; i < 5; i++) {
uint8 digit = scoreString[i] - '0';
- AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xBF);
+ AlgGraphics::drawImage(_screen, (*_numbers)[digit], posX, 0xBF);
posX += 7;
}
_oldScore = _score;
@@ -553,12 +553,12 @@ void GameBountyHunter::displayShotsLeft(uint8 player) {
}
uint16 posX = 0xEE;
for (int i = 0; i < 10; i++) {
- AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBE);
+ AlgGraphics::drawImage(_screen, _emptyIcon, posX, 0xBE);
posX += 5;
}
posX = 0xEE;
for (int i = 0; i < _shots; i++) {
- AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBE);
+ AlgGraphics::drawImage(_screen, _shotIcon, posX, 0xBE);
posX += 5;
}
_oldShots = _shots;
@@ -635,7 +635,7 @@ void GameBountyHunter::displayShotFiredImage(Common::Point *point) {
if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), _bulletholeIcon, targetX, targetY);
}
}
@@ -837,17 +837,17 @@ void GameBountyHunter::rectStart(Rect *rect) {
void GameBountyHunter::rectTogglePlayers(Rect *rect) {
if (_numPlayers == 1) {
_numPlayers = 2;
- AlgGraphics::drawImage(_screen, &_playersIcon2, 0xCE, 0x95);
- AlgGraphics::drawImage(_screen, &_textBlackBarIcon, 0x78, 0xBF);
- AlgGraphics::drawImage(_screen, &_textBlackBarIcon, 0x0C, 0xBF);
+ AlgGraphics::drawImage(_screen, _playersIcon2, 0xCE, 0x95);
+ AlgGraphics::drawImage(_screen, _textBlackBarIcon, 0x78, 0xBF);
+ AlgGraphics::drawImage(_screen, _textBlackBarIcon, 0x0C, 0xBF);
displayShotsLeft(1);
displayLivesLeft(1);
} else {
_numPlayers = 1;
- AlgGraphics::drawImage(_screen, &_playersIcon1, 0xCE, 0x95);
- AlgGraphics::drawImage(_screen, &_textScoreIcon, 0x78, 0xBF);
- AlgGraphics::drawImage(_screen, &_textMenuIcon, 0x0C, 0xBF);
- AlgGraphics::drawImage(_screen, &_textBlackBarIcon, 0x50, 0xBE);
+ AlgGraphics::drawImage(_screen, _playersIcon1, 0xCE, 0x95);
+ AlgGraphics::drawImage(_screen, _textScoreIcon, 0x78, 0xBF);
+ AlgGraphics::drawImage(_screen, _textMenuIcon, 0x0C, 0xBF);
+ AlgGraphics::drawImage(_screen, _textBlackBarIcon, 0x50, 0xBE);
}
doSkullSound();
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
diff --git a/engines/alg/game_bountyhunter.h b/engines/alg/game_bountyhunter.h
index 708a223b2da..ddfd18dc051 100644
--- a/engines/alg/game_bountyhunter.h
+++ b/engines/alg/game_bountyhunter.h
@@ -76,19 +76,19 @@ private:
BHScriptFunctionSceneMap _sceneNxtScn;
// images
- Graphics::Surface _shotIcon;
- Graphics::Surface _emptyIcon;
- Graphics::Surface _liveIcon;
- Graphics::Surface _deadIcon;
- Graphics::Surface _diffIcon;
- Graphics::Surface _bulletholeIcon;
- Graphics::Surface _playersIcon1;
- Graphics::Surface _playersIcon2;
- Graphics::Surface _textScoreIcon;
- Graphics::Surface _textMenuIcon;
- Graphics::Surface _textBlackBarIcon;
- Common::Array<Graphics::Surface> *_bagsIcons;
- Common::Array<Graphics::Surface> *_shotgun;
+ Graphics::Surface *_shotIcon;
+ Graphics::Surface *_emptyIcon;
+ Graphics::Surface *_liveIcon;
+ Graphics::Surface *_deadIcon;
+ Graphics::Surface *_diffIcon;
+ Graphics::Surface *_bulletholeIcon;
+ Graphics::Surface *_playersIcon1;
+ Graphics::Surface *_playersIcon2;
+ Graphics::Surface *_textScoreIcon;
+ Graphics::Surface *_textMenuIcon;
+ Graphics::Surface *_textBlackBarIcon;
+ Common::Array<Graphics::Surface *> *_bagsIcons;
+ Common::Array<Graphics::Surface *> *_shotgun;
// sounds
Audio::SeekableAudioStream *_shotgunSound = nullptr;
diff --git a/engines/alg/game_crimepatrol.cpp b/engines/alg/game_crimepatrol.cpp
index 73ef87eb0a8..4ab2aa6b784 100644
--- a/engines/alg/game_crimepatrol.cpp
+++ b/engines/alg/game_crimepatrol.cpp
@@ -86,15 +86,15 @@ void GameCrimePatrol::init() {
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
- Common::Array<Graphics::Surface> *bullets = AlgGraphics::loadAniImage("bullets.ani", _palette);
+ auto bullets = AlgGraphics::loadAniImage("bullets.ani", _palette);
_shotIcon = (*bullets)[0];
_emptyIcon = (*bullets)[1];
- Common::Array<Graphics::Surface> *lives = AlgGraphics::loadAniImage("lives.ani", _palette);
+ auto lives = AlgGraphics::loadAniImage("lives.ani", _palette);
_liveIcon = (*lives)[0];
_deadIcon = (*lives)[1];
- Common::Array<Graphics::Surface> *difficlt = AlgGraphics::loadScreenCoordAniImage("difficlt.ani", _palette);
+ auto difficlt = AlgGraphics::loadScreenCoordAniImage("difficlt.ani", _palette);
_difficultyIcon = (*difficlt)[0];
- Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
+ auto hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
_bulletholeIcon = (*hole)[0];
_background = AlgGraphics::loadVgaBackground("cp_menu.vga", _palette);
@@ -463,7 +463,7 @@ void GameCrimePatrol::showDifficulty(uint8 newDifficulty, bool cursor) {
// reset menu screen
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
uint16 posY = 0x45 + ((newDifficulty - 1) * 0x21);
- AlgGraphics::drawImageCentered(_screen, &_difficultyIcon, 0x0115, posY);
+ AlgGraphics::drawImageCentered(_screen, _difficultyIcon, 0x0115, posY);
if (cursor) {
updateCursor();
}
@@ -475,7 +475,7 @@ void GameCrimePatrol::updateCursor() {
void GameCrimePatrol::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ Graphics::Surface *cursor = (*_gun)[_whichGun];
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 3;
uint16 hotspotY = (cursor->h / 2) + 3;
@@ -524,12 +524,12 @@ void GameCrimePatrol::displayLivesLeft() {
}
int posY = 0x67;
for (int i = 0; i < 3; i++) {
- AlgGraphics::drawImage(_screen, &_deadIcon, 0x12F, posY);
+ AlgGraphics::drawImage(_screen, _deadIcon, 0x12F, posY);
posY += 0xE;
}
posY = 0x67;
for (int i = 0; i < _lives; i++) {
- AlgGraphics::drawImage(_screen, &_liveIcon, 0x12F, posY);
+ AlgGraphics::drawImage(_screen, _liveIcon, 0x12F, posY);
posY += 0xE;
}
_oldLives = _lives;
@@ -543,7 +543,7 @@ void GameCrimePatrol::displayScores() {
int posX = 0x9B;
for (int i = 0; i < 5; i++) {
uint8 digit = scoreString[i] - '0';
- AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xBF);
+ AlgGraphics::drawImage(_screen, (*_numbers)[digit], posX, 0xBF);
posX += 7;
}
_oldScore = _score;
@@ -555,12 +555,12 @@ void GameCrimePatrol::displayShotsLeft() {
}
uint16 posX = 0xEE;
for (int i = 0; i < 10; i++) {
- AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBE);
+ AlgGraphics::drawImage(_screen, _emptyIcon, posX, 0xBE);
posX += 5;
}
posX = 0xEE;
for (int i = 0; i < _shots; i++) {
- AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBE);
+ AlgGraphics::drawImage(_screen, _shotIcon, posX, 0xBE);
posX += 5;
}
_oldShots = _shots;
@@ -625,7 +625,7 @@ void GameCrimePatrol::displayShotFiredImage(Common::Point *point) {
if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), _bulletholeIcon, targetX, targetY);
}
}
diff --git a/engines/alg/game_crimepatrol.h b/engines/alg/game_crimepatrol.h
index 119cf2477ac..178b75604ec 100644
--- a/engines/alg/game_crimepatrol.h
+++ b/engines/alg/game_crimepatrol.h
@@ -74,12 +74,12 @@ private:
CPScriptFunctionSceneMap _sceneNxtScn;
// images
- Graphics::Surface _shotIcon;
- Graphics::Surface _emptyIcon;
- Graphics::Surface _liveIcon;
- Graphics::Surface _deadIcon;
- Graphics::Surface _difficultyIcon;
- Graphics::Surface _bulletholeIcon;
+ Graphics::Surface *_shotIcon;
+ Graphics::Surface *_emptyIcon;
+ Graphics::Surface *_liveIcon;
+ Graphics::Surface *_deadIcon;
+ Graphics::Surface *_difficultyIcon;
+ Graphics::Surface *_bulletholeIcon;
// constants
const int16 _scenesLevel0[2] = {0x0191, 0};
diff --git a/engines/alg/game_drugwars.cpp b/engines/alg/game_drugwars.cpp
index 7830bf832ec..547fbc5805f 100644
--- a/engines/alg/game_drugwars.cpp
+++ b/engines/alg/game_drugwars.cpp
@@ -86,15 +86,15 @@ void GameDrugWars::init() {
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
- Common::Array<Graphics::Surface> *bullets = AlgGraphics::loadAniImage("bullets.ani", _palette);
+ auto bullets = AlgGraphics::loadAniImage("bullets.ani", _palette);
_shotIcon = (*bullets)[0];
_emptyIcon = (*bullets)[1];
- Common::Array<Graphics::Surface> *lives = AlgGraphics::loadAniImage("lives.ani", _palette);
+ auto lives = AlgGraphics::loadAniImage("lives.ani", _palette);
_liveIcon = (*lives)[0];
_deadIcon = (*lives)[1];
- Common::Array<Graphics::Surface> *difficlt = AlgGraphics::loadScreenCoordAniImage("difficlt.ani", _palette);
+ auto difficlt = AlgGraphics::loadScreenCoordAniImage("difficlt.ani", _palette);
_difficultyIcon = (*difficlt)[0];
- Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
+ auto hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
_bulletholeIcon = (*hole)[0];
_background = AlgGraphics::loadVgaBackground("dw_menu.vga", _palette);
@@ -406,7 +406,7 @@ void GameDrugWars::showDifficulty(uint8 newDifficulty, bool cursor) {
// reset menu screen
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
uint16 posY = 0x3C + ((newDifficulty - 1) * 0x21);
- AlgGraphics::drawImageCentered(_screen, &_difficultyIcon, 0x0115, posY);
+ AlgGraphics::drawImageCentered(_screen, _difficultyIcon, 0x0115, posY);
if (cursor) {
updateCursor();
}
@@ -418,7 +418,7 @@ void GameDrugWars::updateCursor() {
void GameDrugWars::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ Graphics::Surface *cursor = (*_gun)[_whichGun];
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 3;
uint16 hotspotY = (cursor->h / 2) + 3;
@@ -467,12 +467,12 @@ void GameDrugWars::displayLivesLeft() {
}
int posY = 0x67;
for (int i = 0; i < 3; i++) {
- AlgGraphics::drawImage(_screen, &_deadIcon, 0x12F, posY);
+ AlgGraphics::drawImage(_screen, _deadIcon, 0x12F, posY);
posY += 0xE;
}
posY = 0x67;
for (int i = 0; i < _lives; i++) {
- AlgGraphics::drawImage(_screen, &_liveIcon, 0x12F, posY);
+ AlgGraphics::drawImage(_screen, _liveIcon, 0x12F, posY);
posY += 0xE;
}
_oldLives = _lives;
@@ -486,7 +486,7 @@ void GameDrugWars::displayScores() {
int posX = 0x9B;
for (int i = 0; i < 5; i++) {
uint8 digit = scoreString[i] - '0';
- AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xBF);
+ AlgGraphics::drawImage(_screen, (*_numbers)[digit], posX, 0xBF);
posX += 7;
}
_oldScore = _score;
@@ -498,12 +498,12 @@ void GameDrugWars::displayShotsLeft() {
}
uint16 posX = 0xEE;
for (int i = 0; i < 10; i++) {
- AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBE);
+ AlgGraphics::drawImage(_screen, _emptyIcon, posX, 0xBE);
posX += 5;
}
posX = 0xEE;
for (int i = 0; i < _shots; i++) {
- AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBE);
+ AlgGraphics::drawImage(_screen, _shotIcon, posX, 0xBE);
posX += 5;
}
_oldShots = _shots;
@@ -577,7 +577,7 @@ void GameDrugWars::displayShotFiredImage(Common::Point *point) {
if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), _bulletholeIcon, targetX, targetY);
}
}
diff --git a/engines/alg/game_drugwars.h b/engines/alg/game_drugwars.h
index c8a3ddc52e5..c8e978ad479 100644
--- a/engines/alg/game_drugwars.h
+++ b/engines/alg/game_drugwars.h
@@ -74,12 +74,12 @@ private:
DWScriptFunctionSceneMap _sceneNxtScn;
// images
- Graphics::Surface _shotIcon;
- Graphics::Surface _emptyIcon;
- Graphics::Surface _liveIcon;
- Graphics::Surface _deadIcon;
- Graphics::Surface _difficultyIcon;
- Graphics::Surface _bulletholeIcon;
+ Graphics::Surface *_shotIcon;
+ Graphics::Surface *_emptyIcon;
+ Graphics::Surface *_liveIcon;
+ Graphics::Surface *_deadIcon;
+ Graphics::Surface *_difficultyIcon;
+ Graphics::Surface *_bulletholeIcon;
// constants
const int16 _randomScenes0[7] = {0x29, 0x2B, 0x2D, 0x2F, 0x31, 0x33, 0};
diff --git a/engines/alg/game_johnnyrock.cpp b/engines/alg/game_johnnyrock.cpp
index fa8fae76567..d5ff3ac3550 100644
--- a/engines/alg/game_johnnyrock.cpp
+++ b/engines/alg/game_johnnyrock.cpp
@@ -86,9 +86,9 @@ void GameJohnnyRock::init() {
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
_difficultyIcon = AlgGraphics::loadAniImage("diff.ani", _palette);
- Common::Array<Graphics::Surface> *level = AlgGraphics::loadScreenCoordAniImage("level.ani", _palette);
+ auto level = AlgGraphics::loadScreenCoordAniImage("level.ani", _palette);
_levelIcon = (*level)[0];
- Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
+ auto hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
_bulletholeIcon = (*hole)[0];
_background = AlgGraphics::loadVgaBackground("backgrnd.vga", _palette);
@@ -540,7 +540,7 @@ void GameJohnnyRock::updateStat() {
Common::String buffer = Common::String::format("%05d", _score);
for (int i = 0; i < 5; i++) {
uint8 digit = buffer[i] - '0';
- AlgGraphics::drawImage(_screen, &(*_numbers)[digit], (i * 7) + 0x7D, 0xBE);
+ AlgGraphics::drawImage(_screen, (*_numbers)[digit], (i * 7) + 0x7D, 0xBE);
}
}
if (_gameMoney != _oldGameMoney) {
@@ -548,7 +548,7 @@ void GameJohnnyRock::updateStat() {
Common::String buffer = Common::String::format("%04d", _gameMoney < 0 ? 0 : _gameMoney);
for (int i = 0; i < 4; i++) {
uint8 digit = buffer[i] - '0';
- AlgGraphics::drawImage(_screen, &(*_numbers)[digit], (i * 7) + 0x43, 0xBE);
+ AlgGraphics::drawImage(_screen, (*_numbers)[digit], (i * 7) + 0x43, 0xBE);
}
}
if (_shots != _oldShots) {
@@ -556,10 +556,10 @@ void GameJohnnyRock::updateStat() {
Common::String buffer = Common::String::format("%04d", _shots);
for (int i = 0; i < 4; i++) {
uint8 digit = buffer[i] - '0';
- AlgGraphics::drawImage(_screen, &(*_numbers)[digit], (i * 7) + 0x10A, 0xBE);
+ AlgGraphics::drawImage(_screen, (*_numbers)[digit], (i * 7) + 0x10A, 0xBE);
}
}
- AlgGraphics::drawImage(_screen, &(*_difficultyIcon)[_difficulty - 1], 0xBA, 0xBE);
+ AlgGraphics::drawImage(_screen, (*_difficultyIcon)[_difficulty - 1], 0xBA, 0xBE);
}
void GameJohnnyRock::displayScore() {
@@ -569,7 +569,7 @@ void GameJohnnyRock::displayScore() {
void GameJohnnyRock::showDifficulty(uint8 newDifficulty, bool cursor) {
// reset menu screen
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
- AlgGraphics::drawImageCentered(_screen, &_levelIcon, _diffPos[newDifficulty][0], _diffPos[newDifficulty][1]);
+ AlgGraphics::drawImageCentered(_screen, _levelIcon, _diffPos[newDifficulty][0], _diffPos[newDifficulty][1]);
if (cursor) {
updateCursor();
}
@@ -591,7 +591,7 @@ void GameJohnnyRock::updateCursor() {
void GameJohnnyRock::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ Graphics::Surface *cursor = (*_gun)[_whichGun];
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2);
uint16 hotspotY = (cursor->h / 2);
@@ -840,7 +840,7 @@ void GameJohnnyRock::defaultBullethole(Common::Point *point) {
if (point->x >= 14 && point->x <= 306 && point->y >= 5 && point->y <= 169) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), _bulletholeIcon, targetX, targetY);
updateCursor();
_shotFired = true;
doShot();
diff --git a/engines/alg/game_johnnyrock.h b/engines/alg/game_johnnyrock.h
index 2d424aed3ba..82de211c8ea 100644
--- a/engines/alg/game_johnnyrock.h
+++ b/engines/alg/game_johnnyrock.h
@@ -79,9 +79,9 @@ private:
JRScriptFunctionSceneMap _sceneNxtScn;
// images
- Common::Array<Graphics::Surface> *_difficultyIcon;
- Graphics::Surface _levelIcon;
- Graphics::Surface _bulletholeIcon;
+ Common::Array<Graphics::Surface *> *_difficultyIcon;
+ Graphics::Surface *_levelIcon;
+ Graphics::Surface *_bulletholeIcon;
// constants
const int16 _randomRooftop[6] = {2, -4, 0x104, 0x1E, 0x100, 0x102};
diff --git a/engines/alg/game_maddog.cpp b/engines/alg/game_maddog.cpp
index 4003da03d46..38f1cde4b68 100644
--- a/engines/alg/game_maddog.cpp
+++ b/engines/alg/game_maddog.cpp
@@ -85,18 +85,18 @@ void GameMaddog::init() {
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
- Common::Array<Graphics::Surface> *bullet = AlgGraphics::loadAniImage("bullet.ani", _palette);
+ auto bullet = AlgGraphics::loadAniImage("bullet.ani", _palette);
_shotIcon = (*bullet)[0];
_emptyIcon = (*bullet)[1];
- Common::Array<Graphics::Surface> *hat = AlgGraphics::loadAniImage("hat.ani", _palette);
+ auto hat = AlgGraphics::loadAniImage("hat.ani", _palette);
_liveIcon = (*hat)[0];
_deadIcon = (*hat)[1];
- Common::Array<Graphics::Surface> *shootout = AlgGraphics::loadAniImage("shootout.ani", _palette);
+ auto shootout = AlgGraphics::loadAniImage("shootout.ani", _palette);
_reloadIcon = (*shootout)[0];
_drawIcon = (*shootout)[1];
- Common::Array<Graphics::Surface> *knife = AlgGraphics::loadScreenCoordAniImage("knife.ani", _palette);
+ auto knife = AlgGraphics::loadScreenCoordAniImage("knife.ani", _palette);
_knifeIcon = (*knife)[0];
- Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
+ auto hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
_bulletholeIcon = (*hole)[0];
_background = AlgGraphics::loadVgaBackground("backgrnd.vga", _palette);
@@ -475,11 +475,11 @@ void GameMaddog::updateStat() {
if (_lives != _oldLives) {
if (_lives > _oldLives) {
for (uint8 i = _oldLives; i < _lives; i++) {
- AlgGraphics::drawImage(_screen, &_liveIcon, _livePos[i][0], _livePos[i][1]);
+ AlgGraphics::drawImage(_screen, _liveIcon, _livePos[i][0], _livePos[i][1]);
}
} else {
for (uint8 i = _lives; i < _oldLives; i++) {
- AlgGraphics::drawImage(_screen, &_deadIcon, _livePos[i][0], _livePos[i][1]);
+ AlgGraphics::drawImage(_screen, _deadIcon, _livePos[i][0], _livePos[i][1]);
}
}
_oldLives = _lives;
@@ -487,11 +487,11 @@ void GameMaddog::updateStat() {
if (_shots != _oldShots) {
if (_shots > _oldShots) {
for (uint8 i = _oldShots; i < _shots; i++) {
- AlgGraphics::drawImage(_screen, &_shotIcon, _shotPos[i][0], _shotPos[i][1]);
+ AlgGraphics::drawImage(_screen, _shotIcon, _shotPos[i][0], _shotPos[i][1]);
}
} else {
for (uint8 i = _shots; i < _oldShots; i++) {
- AlgGraphics::drawImage(_screen, &_emptyIcon, _shotPos[i][0], _shotPos[i][1]);
+ AlgGraphics::drawImage(_screen, _emptyIcon, _shotPos[i][0], _shotPos[i][1]);
}
}
_oldShots = _shots;
@@ -511,7 +511,7 @@ void GameMaddog::changeDifficulty(uint8 newDifficulty) {
void GameMaddog::showDifficulty(uint8 newDifficulty, bool cursor) {
// reset menu screen
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
- AlgGraphics::drawImageCentered(_screen, &_knifeIcon, _diffPos[newDifficulty][0], _diffPos[newDifficulty][1]);
+ AlgGraphics::drawImageCentered(_screen, _knifeIcon, _diffPos[newDifficulty][0], _diffPos[newDifficulty][1]);
if (cursor) {
updateCursor();
}
@@ -523,7 +523,7 @@ void GameMaddog::updateCursor() {
void GameMaddog::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ Graphics::Surface *cursor = (*_gun)[_whichGun];
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2);
uint16 hotspotY = (cursor->h / 2);
@@ -565,7 +565,7 @@ void GameMaddog::displayScore() {
} else {
digit = scoreString[i] - '0' - 1;
}
- AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xAD);
+ AlgGraphics::drawImage(_screen, (*_numbers)[digit], posX, 0xAD);
posX += 10;
}
}
@@ -663,7 +663,7 @@ void GameMaddog::defaultBullethole(Common::Point *point) {
if (point->x >= 59 && point->y <= 166) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), _bulletholeIcon, targetX, targetY);
updateCursor();
_shotFired = true;
doShot();
@@ -834,7 +834,7 @@ void GameMaddog::zoneSkullhole(Common::Point *point) {
if (point->x >= 59 && point->y <= 166) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), _bulletholeIcon, targetX, targetY);
updateCursor();
_shotFired = true;
@@ -1067,7 +1067,7 @@ void GameMaddog::scenePsoShootout(Scene *scene) {
}
_inShootout = true;
updateStat();
- AlgGraphics::drawImage(_screen, &_reloadIcon, 0x40, 0xB0);
+ AlgGraphics::drawImage(_screen, _reloadIcon, 0x40, 0xB0);
updateCursor();
}
@@ -1078,7 +1078,7 @@ void GameMaddog::scenePsoMDShootout(Scene *scene) {
}
_inShootout = true;
updateStat();
- AlgGraphics::drawImage(_screen, &_reloadIcon, 0x40, 0xB0);
+ AlgGraphics::drawImage(_screen, _reloadIcon, 0x40, 0xB0);
updateCursor();
}
@@ -1172,7 +1172,7 @@ void GameMaddog::sceneIsoDidSignPost(Scene *scene) {
void GameMaddog::sceneIsoDoShootout(Scene *scene) {
if (_currentFrame > (uint32)_minF) {
if (_inShootout) {
- AlgGraphics::drawImage(_screen, &_drawIcon, 0x40, 0xB0);
+ AlgGraphics::drawImage(_screen, _drawIcon, 0x40, 0xB0);
updateCursor();
}
_inShootout = false;
@@ -1201,7 +1201,7 @@ void GameMaddog::sceneIsoShotInto116(Scene *scene) {
// Script functions: Scene NxtScn
void GameMaddog::sceneDefaultNxtscn(Scene *scene) {
// wipe background drawing from shootout
- _screen->copyRectToSurface(_background->getBasePtr(0x40, 0xB0), _background->pitch, 0x40, 0xB0, _reloadIcon.w, _reloadIcon.h);
+ _screen->copyRectToSurface(_background->getBasePtr(0x40, 0xB0), _background->pitch, 0x40, 0xB0, _reloadIcon->w, _reloadIcon->h);
updateCursor();
Game::sceneDefaultNxtscn(scene);
}
diff --git a/engines/alg/game_maddog.h b/engines/alg/game_maddog.h
index 7effbd1056e..84546fe47c0 100644
--- a/engines/alg/game_maddog.h
+++ b/engines/alg/game_maddog.h
@@ -79,14 +79,14 @@ private:
MDScriptFunctionSceneMap _sceneNxtScn;
// images
- Graphics::Surface _shotIcon;
- Graphics::Surface _emptyIcon;
- Graphics::Surface _liveIcon;
- Graphics::Surface _deadIcon;
- Graphics::Surface _reloadIcon;
- Graphics::Surface _drawIcon;
- Graphics::Surface _knifeIcon;
- Graphics::Surface _bulletholeIcon;
+ Graphics::Surface *_shotIcon;
+ Graphics::Surface *_emptyIcon;
+ Graphics::Surface *_liveIcon;
+ Graphics::Surface *_deadIcon;
+ Graphics::Surface *_reloadIcon;
+ Graphics::Surface *_drawIcon;
+ Graphics::Surface *_knifeIcon;
+ Graphics::Surface *_bulletholeIcon;
// constants
const uint16 _fight[3] = {208, 228, 243};
diff --git a/engines/alg/game_maddog2.cpp b/engines/alg/game_maddog2.cpp
index f2577ecc9a7..8f2554cfaf3 100644
--- a/engines/alg/game_maddog2.cpp
+++ b/engines/alg/game_maddog2.cpp
@@ -86,18 +86,18 @@ void GameMaddog2::init() {
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
- Common::Array<Graphics::Surface> *bullet = AlgGraphics::loadAniImage("bullet.ani", _palette);
+ auto bullet = AlgGraphics::loadAniImage("bullet.ani", _palette);
_shotIcon = (*bullet)[0];
_emptyIcon = (*bullet)[1];
- Common::Array<Graphics::Surface> *hat = AlgGraphics::loadAniImage("hat.ani", _palette);
+ auto hat = AlgGraphics::loadAniImage("hat.ani", _palette);
_liveIcon = (*hat)[0];
_deadIcon = (*hat)[1];
- Common::Array<Graphics::Surface> *shootout = AlgGraphics::loadAniImage("shootout.ani", _palette);
+ auto shootout = AlgGraphics::loadAniImage("shootout.ani", _palette);
_reloadIcon = (*shootout)[0];
_drawIcon = (*shootout)[1];
- Common::Array<Graphics::Surface> *knife = AlgGraphics::loadScreenCoordAniImage("knife.ani", _palette);
+ auto knife = AlgGraphics::loadScreenCoordAniImage("knife.ani", _palette);
_knifeIcon = (*knife)[0];
- Common::Array<Graphics::Surface> *hole = AlgGraphics::loadAniImage("hole.ani", _palette);
+ auto hole = AlgGraphics::loadAniImage("hole.ani", _palette);
_bulletholeIcon = (*hole)[0];
_background = AlgGraphics::loadVgaBackground("backgrnd.vga", _palette);
@@ -488,11 +488,11 @@ void GameMaddog2::updateStat() {
if (_lives != _oldLives) {
if (_lives > _oldLives) {
for (uint8 i = _oldLives; i < _lives; i++) {
- AlgGraphics::drawImage(_screen, &_liveIcon, _livepos[i][0], _livepos[i][1]);
+ AlgGraphics::drawImage(_screen, _liveIcon, _livepos[i][0], _livepos[i][1]);
}
} else {
for (uint8 i = _lives; i < _oldLives; i++) {
- AlgGraphics::drawImage(_screen, &_deadIcon, _livepos[i][0], _livepos[i][1]);
+ AlgGraphics::drawImage(_screen, _deadIcon, _livepos[i][0], _livepos[i][1]);
}
}
_oldLives = _lives;
@@ -500,11 +500,11 @@ void GameMaddog2::updateStat() {
if (_shots != _oldShots) {
if (_shots > _oldShots) {
for (uint8 i = _oldShots; i < _shots; i++) {
- AlgGraphics::drawImage(_screen, &_shotIcon, _shotpos[i][0], _shotpos[i][1]);
+ AlgGraphics::drawImage(_screen, _shotIcon, _shotpos[i][0], _shotpos[i][1]);
}
} else {
for (uint8 i = _shots; i < _oldShots; i++) {
- AlgGraphics::drawImage(_screen, &_emptyIcon, _shotpos[i][0], _shotpos[i][1]);
+ AlgGraphics::drawImage(_screen, _emptyIcon, _shotpos[i][0], _shotpos[i][1]);
}
}
_oldShots = _shots;
@@ -524,7 +524,7 @@ void GameMaddog2::changeDifficulty(uint8 newDifficulty) {
void GameMaddog2::showDifficulty(uint8 newDifficulty, bool cursor) {
// reset menu screen
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
- AlgGraphics::drawImageCentered(_screen, &_knifeIcon, _diffpos[newDifficulty - 1][0], _diffpos[newDifficulty - 1][1]);
+ AlgGraphics::drawImageCentered(_screen, _knifeIcon, _diffpos[newDifficulty - 1][0], _diffpos[newDifficulty - 1][1]);
if (cursor) {
updateCursor();
}
@@ -536,7 +536,7 @@ void GameMaddog2::updateCursor() {
void GameMaddog2::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ Graphics::Surface *cursor = (*_gun)[_whichGun];
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2);
uint16 hotspotY = (cursor->h / 2);
@@ -582,7 +582,7 @@ void GameMaddog2::displayScore() {
int posX = 0xE6;
for (int i = 0; i < 5; i++) {
uint8 digit = scoreString[i] - '0';
- AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xBE);
+ AlgGraphics::drawImage(_screen, (*_numbers)[digit], posX, 0xBE);
posX += 7;
}
}
@@ -756,7 +756,7 @@ void GameMaddog2::defaultBullethole(Common::Point *point) {
if (point->x >= 14 && point->x <= 306 && point->y >= 5 && point->y <= 169) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), _bulletholeIcon, targetX, targetY);
updateCursor();
_shotFired = true;
doShot();
@@ -987,7 +987,7 @@ void GameMaddog2::zoneSkullhole(Common::Point *point) {
if (point->x >= 14 && point->x <= 306 && point->y >= 5 && point->y <= 169) {
uint16 targetX = point->x - _videoPosX;
uint16 targetY = point->y - _videoPosY;
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), _bulletholeIcon, targetX, targetY);
updateCursor();
_shotFired = true;
@@ -1204,7 +1204,7 @@ void GameMaddog2::scenePsoShootout(Scene *scene) {
}
_inShootout = true;
updateStat();
- AlgGraphics::drawImage(_screen, &_reloadIcon, 0x37, 0xBE);
+ AlgGraphics::drawImage(_screen, _reloadIcon, 0x37, 0xBE);
updateCursor();
}
@@ -1215,7 +1215,7 @@ void GameMaddog2::scenePsoMDShootout(Scene *scene) {
}
_inShootout = true;
updateStat();
- AlgGraphics::drawImage(_screen, &_reloadIcon, 0x37, 0xBE);
+ AlgGraphics::drawImage(_screen, _reloadIcon, 0x37, 0xBE);
updateCursor();
}
@@ -1312,7 +1312,7 @@ void GameMaddog2::sceneIsoDoShootout(Scene *scene) {
return;
}
if (_inShootout) {
- AlgGraphics::drawImage(_screen, &_drawIcon, 0x37, 0xBE);
+ AlgGraphics::drawImage(_screen, _drawIcon, 0x37, 0xBE);
updateCursor();
}
_inShootout = false;
@@ -1326,7 +1326,7 @@ void GameMaddog2::sceneIsoDoShootout(Scene *scene) {
// Script functions: Scene NxtScn
void GameMaddog2::sceneDefaultNxtscn(Scene *scene) {
// wipe background drawing from shootout
- _screen->copyRectToSurface(_background->getBasePtr(0x37, 0xBE), _background->pitch, 0x37, 0xBE, _reloadIcon.w, _reloadIcon.h);
+ _screen->copyRectToSurface(_background->getBasePtr(0x37, 0xBE), _background->pitch, 0x37, 0xBE, _reloadIcon->w, _reloadIcon->h);
Game::sceneDefaultNxtscn(scene);
}
diff --git a/engines/alg/game_maddog2.h b/engines/alg/game_maddog2.h
index 62c1901f9b5..372ef6c03b7 100644
--- a/engines/alg/game_maddog2.h
+++ b/engines/alg/game_maddog2.h
@@ -79,14 +79,14 @@ private:
MD2ScriptFunctionSceneMap _sceneNxtScn;
// images
- Graphics::Surface _shotIcon;
- Graphics::Surface _emptyIcon;
- Graphics::Surface _liveIcon;
- Graphics::Surface _deadIcon;
- Graphics::Surface _reloadIcon;
- Graphics::Surface _drawIcon;
- Graphics::Surface _knifeIcon;
- Graphics::Surface _bulletholeIcon;
+ Graphics::Surface *_shotIcon;
+ Graphics::Surface *_emptyIcon;
+ Graphics::Surface *_liveIcon;
+ Graphics::Surface *_deadIcon;
+ Graphics::Surface *_reloadIcon;
+ Graphics::Surface *_drawIcon;
+ Graphics::Surface *_knifeIcon;
+ Graphics::Surface *_bulletholeIcon;
// constants
const int16 _sb_clue[3] = {0x67, 0x68, 0x69};
diff --git a/engines/alg/game_spacepirates.cpp b/engines/alg/game_spacepirates.cpp
index bb9ff051fcd..fb00f9404da 100644
--- a/engines/alg/game_spacepirates.cpp
+++ b/engines/alg/game_spacepirates.cpp
@@ -94,15 +94,15 @@ void GameSpacePirates::init() {
_gun = AlgGraphics::loadScreenCoordAniImage("gun.ani", _palette);
_difficultyIcon = (*_gun)[1];
_numbers = AlgGraphics::loadAniImage("numbers.ani", _palette);
- Common::Array<Graphics::Surface> *bullets = AlgGraphics::loadAniImage("bullets.ani", _palette);
+ auto bullets = AlgGraphics::loadAniImage("bullets.ani", _palette);
_shotIcon = (*bullets)[0];
_emptyIcon = (*bullets)[1];
- Common::Array<Graphics::Surface> *lives = AlgGraphics::loadAniImage("lives.ani", _palette);
+ auto lives = AlgGraphics::loadAniImage("lives.ani", _palette);
_liveIcon1 = (*lives)[0];
_liveIcon2 = (*lives)[1];
_liveIcon3 = (*lives)[2];
_deadIcon = (*lives)[3];
- Common::Array<Graphics::Surface> *hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
+ auto hole = AlgGraphics::loadScreenCoordAniImage("hole.ani", _palette);
_bulletholeIcon = (*hole)[0];
_background = AlgGraphics::loadVgaBackground("backgrnd.vga", _palette);
@@ -497,7 +497,7 @@ void GameSpacePirates::showDifficulty(uint8 newDifficulty, bool cursor) {
} else if (newDifficulty == 2) {
posY = 0x86;
}
- AlgGraphics::drawImageCentered(_screen, &_difficultyIcon, 0x0111, posY);
+ AlgGraphics::drawImageCentered(_screen, _difficultyIcon, 0x0111, posY);
if (cursor) {
updateCursor();
}
@@ -509,7 +509,7 @@ void GameSpacePirates::updateCursor() {
void GameSpacePirates::updateMouse() {
if (_oldWhichGun != _whichGun) {
- Graphics::Surface *cursor = &(*_gun)[_whichGun];
+ Graphics::Surface *cursor = (*_gun)[_whichGun];
CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 8;
uint16 hotspotY = (cursor->h / 2) + 10;
@@ -569,16 +569,16 @@ void GameSpacePirates::displayLivesLeft() {
margin = 13;
}
for (int i = 0; i < 3; i++) {
- AlgGraphics::drawImage(_screen, &_deadIcon, posX, posY + (i * margin));
+ AlgGraphics::drawImage(_screen, _deadIcon, posX, posY + (i * margin));
}
if (_lives > 2) {
- AlgGraphics::drawImage(_screen, &_liveIcon3, posX, posY + (margin * 2));
+ AlgGraphics::drawImage(_screen, _liveIcon3, posX, posY + (margin * 2));
}
if (_lives > 1) {
- AlgGraphics::drawImage(_screen, &_liveIcon2, posX, posY + margin);
+ AlgGraphics::drawImage(_screen, _liveIcon2, posX, posY + margin);
}
if (_lives > 0) {
- AlgGraphics::drawImage(_screen, &_liveIcon1, posX, posY);
+ AlgGraphics::drawImage(_screen, _liveIcon1, posX, posY);
}
_oldLives = _lives;
}
@@ -591,7 +591,7 @@ void GameSpacePirates::displayScores() {
int posX = 0x71;
for (int i = 0; i < 5; i++) {
uint8 digit = scoreString[i] - '0';
- AlgGraphics::drawImage(_screen, &(*_numbers)[digit], posX, 0xBF);
+ AlgGraphics::drawImage(_screen, (*_numbers)[digit], posX, 0xBF);
posX += 7;
}
_oldScore = _score;
@@ -603,12 +603,12 @@ void GameSpacePirates::displayShotsLeft() {
}
uint16 posX = 0xAA;
for (int i = 0; i < 10; i++) {
- AlgGraphics::drawImage(_screen, &_emptyIcon, posX, 0xBF);
+ AlgGraphics::drawImage(_screen, _emptyIcon, posX, 0xBF);
posX += 8;
}
posX = 0xAA;
for (int i = 0; i < _shots; i++) {
- AlgGraphics::drawImage(_screen, &_shotIcon, posX, 0xBF);
+ AlgGraphics::drawImage(_screen, _shotIcon, posX, 0xBF);
posX += 8;
}
_oldShots = _shots;
@@ -745,7 +745,7 @@ void GameSpacePirates::displayShotFiredImage(Common::Point *point) {
if (point->x >= _videoPosX && point->x <= (_videoPosX + _videoDecoder->getWidth()) && point->y >= _videoPosY && point->y <= (_videoPosY + _videoDecoder->getHeight())) {
uint16 targetX = point->x - _videoPosX - 4;
uint16 targetY = point->y - _videoPosY - 4;
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &_bulletholeIcon, targetX, targetY);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), _bulletholeIcon, targetX, targetY);
}
}
@@ -1312,7 +1312,7 @@ void GameSpacePirates::sceneIsoPickAWorld(Scene *scene) {
if (_worldDone[world]) {
uint16 centerX = zone->_rects[i].left + (zone->_rects[i].width() / 2);
uint16 centerY = zone->_rects[i].top + (zone->_rects[i].height() / 2);
- AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), &(*_gun)[2], centerX - 16, centerY - 24);
+ AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), (*_gun)[2], centerX - 16, centerY - 24);
}
world--;
}
diff --git a/engines/alg/game_spacepirates.h b/engines/alg/game_spacepirates.h
index 1f9b78342cb..a6761bac07b 100644
--- a/engines/alg/game_spacepirates.h
+++ b/engines/alg/game_spacepirates.h
@@ -76,14 +76,14 @@ private:
SPScriptFunctionSceneMap _sceneMissedRects;
// images
- Graphics::Surface _shotIcon;
- Graphics::Surface _emptyIcon;
- Graphics::Surface _deadIcon;
- Graphics::Surface _liveIcon1;
- Graphics::Surface _liveIcon2;
- Graphics::Surface _liveIcon3;
- Graphics::Surface _difficultyIcon;
- Graphics::Surface _bulletholeIcon;
+ Graphics::Surface *_shotIcon;
+ Graphics::Surface *_emptyIcon;
+ Graphics::Surface *_deadIcon;
+ Graphics::Surface *_liveIcon1;
+ Graphics::Surface *_liveIcon2;
+ Graphics::Surface *_liveIcon3;
+ Graphics::Surface *_difficultyIcon;
+ Graphics::Surface *_bulletholeIcon;
// constants
diff --git a/engines/alg/graphics.cpp b/engines/alg/graphics.cpp
index 348814de97a..f20b8e0fd70 100644
--- a/engines/alg/graphics.cpp
+++ b/engines/alg/graphics.cpp
@@ -59,8 +59,8 @@ Graphics::Surface *AlgGraphics::loadVgaBackground(const Common::Path &path, uint
}
// for "normal" ani images
-Common::Array<Graphics::Surface> *AlgGraphics::loadAniImage(const Common::Path &path, uint8 *palette) {
- Common::Array<Graphics::Surface> *images = new Common::Array<Graphics::Surface>();
+Common::Array<Graphics::Surface *> *AlgGraphics::loadAniImage(const Common::Path &path, uint8 *palette) {
+ Common::Array<Graphics::Surface *> *images = new Common::Array<Graphics::Surface *>();
Common::File aniFile;
if (!aniFile.open(path)) {
error("AlgGraphics::loadAniImage(): Can't open image file '%s'", path.toString().c_str());
@@ -95,7 +95,7 @@ Common::Array<Graphics::Surface> *AlgGraphics::loadAniImage(const Common::Path &
aniImage->setPixel(x, y, aniFile.readByte());
}
}
- images->push_back(*aniImage);
+ images->push_back(aniImage);
}
}
aniFile.close();
@@ -105,8 +105,8 @@ Common::Array<Graphics::Surface> *AlgGraphics::loadAniImage(const Common::Path &
// for ani images that use relative positioning.
// because these are meant to be drawn directly onto a 320x200 screen, they use relative offsets assuming that resolution.
// as we don't always want to draw directly to screen, we draw to the center of a virtual screen and then copy from a centered subrect.
-Common::Array<Graphics::Surface> *AlgGraphics::loadScreenCoordAniImage(const Common::Path &path, uint8 *palette) {
- Common::Array<Graphics::Surface> *images = new Common::Array<Graphics::Surface>();
+Common::Array<Graphics::Surface *> *AlgGraphics::loadScreenCoordAniImage(const Common::Path &path, uint8 *palette) {
+ Common::Array<Graphics::Surface *> *images = new Common::Array<Graphics::Surface *>();
Common::File aniFile;
if (!aniFile.open(path)) {
error("AlgGraphics::loadScreenCoordAniImage(): Can't open image file '%s'", path.toString().c_str());
@@ -148,7 +148,7 @@ Common::Array<Graphics::Surface> *AlgGraphics::loadScreenCoordAniImage(const Com
subSectionRect.right = (renderTarget->w / 2) + (aniImage->w / 2);
subSectionRect.bottom = (renderTarget->h / 2) + (aniImage->h / 2);
aniImage->copyRectToSurface(*renderTarget, 0, 0, subSectionRect);
- images->push_back(*aniImage);
+ images->push_back(aniImage);
renderTarget->free();
}
aniFile.close();
diff --git a/engines/alg/graphics.h b/engines/alg/graphics.h
index 5f11d9d17b6..a54888661b6 100644
--- a/engines/alg/graphics.h
+++ b/engines/alg/graphics.h
@@ -30,8 +30,8 @@ namespace Alg {
class AlgGraphics {
public:
static Graphics::Surface *loadVgaBackground(const Common::Path &path, uint8 *palette);
- static Common::Array<Graphics::Surface> *loadAniImage(const Common::Path &path, uint8 *palette);
- static Common::Array<Graphics::Surface> *loadScreenCoordAniImage(const Common::Path &path, uint8 *palette);
+ static Common::Array<Graphics::Surface *> *loadAniImage(const Common::Path &path, uint8 *palette);
+ static Common::Array<Graphics::Surface *> *loadScreenCoordAniImage(const Common::Path &path, uint8 *palette);
static void drawImage(Graphics::Surface *dest, Graphics::Surface *src, int32 x, int32 y);
static void drawImageCentered(Graphics::Surface *dest, Graphics::Surface *src, int32 x, int32 y);
};
Commit: 7f7446f145dd60e70324040161b045fdc66303bc
https://github.com/scummvm/scummvm/commit/7f7446f145dd60e70324040161b045fdc66303bc
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: moved game-specific files to logic sub-folder
Changed paths:
A engines/alg/logic/game_bountyhunter.cpp
A engines/alg/logic/game_bountyhunter.h
A engines/alg/logic/game_crimepatrol.cpp
A engines/alg/logic/game_crimepatrol.h
A engines/alg/logic/game_drugwars.cpp
A engines/alg/logic/game_drugwars.h
A engines/alg/logic/game_johnnyrock.cpp
A engines/alg/logic/game_johnnyrock.h
A engines/alg/logic/game_maddog.cpp
A engines/alg/logic/game_maddog.h
A engines/alg/logic/game_maddog2.cpp
A engines/alg/logic/game_maddog2.h
A engines/alg/logic/game_spacepirates.cpp
A engines/alg/logic/game_spacepirates.h
R engines/alg/game_bountyhunter.cpp
R engines/alg/game_bountyhunter.h
R engines/alg/game_crimepatrol.cpp
R engines/alg/game_crimepatrol.h
R engines/alg/game_drugwars.cpp
R engines/alg/game_drugwars.h
R engines/alg/game_johnnyrock.cpp
R engines/alg/game_johnnyrock.h
R engines/alg/game_maddog.cpp
R engines/alg/game_maddog.h
R engines/alg/game_maddog2.cpp
R engines/alg/game_maddog2.h
R engines/alg/game_spacepirates.cpp
R engines/alg/game_spacepirates.h
engines/alg/alg.cpp
engines/alg/module.mk
diff --git a/engines/alg/alg.cpp b/engines/alg/alg.cpp
index 18368c8e90a..c0db9e162c2 100644
--- a/engines/alg/alg.cpp
+++ b/engines/alg/alg.cpp
@@ -24,13 +24,13 @@
#include "alg/alg.h"
#include "alg/detection.h"
#include "alg/game.h"
-#include "alg/game_bountyhunter.h"
-#include "alg/game_crimepatrol.h"
-#include "alg/game_drugwars.h"
-#include "alg/game_johnnyrock.h"
-#include "alg/game_maddog.h"
-#include "alg/game_maddog2.h"
-#include "alg/game_spacepirates.h"
+#include "alg/logic/game_bountyhunter.h"
+#include "alg/logic/game_crimepatrol.h"
+#include "alg/logic/game_drugwars.h"
+#include "alg/logic/game_johnnyrock.h"
+#include "alg/logic/game_maddog.h"
+#include "alg/logic/game_maddog2.h"
+#include "alg/logic/game_spacepirates.h"
namespace Alg {
diff --git a/engines/alg/game_bountyhunter.cpp b/engines/alg/logic/game_bountyhunter.cpp
similarity index 99%
rename from engines/alg/game_bountyhunter.cpp
rename to engines/alg/logic/game_bountyhunter.cpp
index 46f72d06954..a47fb376edf 100644
--- a/engines/alg/game_bountyhunter.cpp
+++ b/engines/alg/logic/game_bountyhunter.cpp
@@ -26,7 +26,7 @@
#include "graphics/cursorman.h"
-#include "alg/game_bountyhunter.h"
+#include "alg/logic/game_bountyhunter.h"
#include "alg/graphics.h"
#include "alg/scene.h"
diff --git a/engines/alg/game_bountyhunter.h b/engines/alg/logic/game_bountyhunter.h
similarity index 100%
rename from engines/alg/game_bountyhunter.h
rename to engines/alg/logic/game_bountyhunter.h
diff --git a/engines/alg/game_crimepatrol.cpp b/engines/alg/logic/game_crimepatrol.cpp
similarity index 99%
rename from engines/alg/game_crimepatrol.cpp
rename to engines/alg/logic/game_crimepatrol.cpp
index 4ab2aa6b784..eab67186721 100644
--- a/engines/alg/game_crimepatrol.cpp
+++ b/engines/alg/logic/game_crimepatrol.cpp
@@ -26,7 +26,7 @@
#include "graphics/cursorman.h"
-#include "alg/game_crimepatrol.h"
+#include "alg/logic/game_crimepatrol.h"
#include "alg/graphics.h"
#include "alg/scene.h"
diff --git a/engines/alg/game_crimepatrol.h b/engines/alg/logic/game_crimepatrol.h
similarity index 100%
rename from engines/alg/game_crimepatrol.h
rename to engines/alg/logic/game_crimepatrol.h
diff --git a/engines/alg/game_drugwars.cpp b/engines/alg/logic/game_drugwars.cpp
similarity index 99%
rename from engines/alg/game_drugwars.cpp
rename to engines/alg/logic/game_drugwars.cpp
index 547fbc5805f..a0ac2ab1130 100644
--- a/engines/alg/game_drugwars.cpp
+++ b/engines/alg/logic/game_drugwars.cpp
@@ -26,7 +26,7 @@
#include "graphics/cursorman.h"
-#include "alg/game_drugwars.h"
+#include "alg/logic/game_drugwars.h"
#include "alg/graphics.h"
#include "alg/scene.h"
diff --git a/engines/alg/game_drugwars.h b/engines/alg/logic/game_drugwars.h
similarity index 100%
rename from engines/alg/game_drugwars.h
rename to engines/alg/logic/game_drugwars.h
diff --git a/engines/alg/game_johnnyrock.cpp b/engines/alg/logic/game_johnnyrock.cpp
similarity index 99%
rename from engines/alg/game_johnnyrock.cpp
rename to engines/alg/logic/game_johnnyrock.cpp
index d5ff3ac3550..cf130671cff 100644
--- a/engines/alg/game_johnnyrock.cpp
+++ b/engines/alg/logic/game_johnnyrock.cpp
@@ -26,7 +26,7 @@
#include "graphics/cursorman.h"
-#include "alg/game_johnnyrock.h"
+#include "alg/logic/game_johnnyrock.h"
#include "alg/graphics.h"
#include "alg/scene.h"
diff --git a/engines/alg/game_johnnyrock.h b/engines/alg/logic/game_johnnyrock.h
similarity index 100%
rename from engines/alg/game_johnnyrock.h
rename to engines/alg/logic/game_johnnyrock.h
diff --git a/engines/alg/game_maddog.cpp b/engines/alg/logic/game_maddog.cpp
similarity index 99%
rename from engines/alg/game_maddog.cpp
rename to engines/alg/logic/game_maddog.cpp
index 38f1cde4b68..bf4f8517560 100644
--- a/engines/alg/game_maddog.cpp
+++ b/engines/alg/logic/game_maddog.cpp
@@ -26,7 +26,7 @@
#include "graphics/cursorman.h"
-#include "alg/game_maddog.h"
+#include "alg/logic/game_maddog.h"
#include "alg/graphics.h"
#include "alg/scene.h"
diff --git a/engines/alg/game_maddog.h b/engines/alg/logic/game_maddog.h
similarity index 100%
rename from engines/alg/game_maddog.h
rename to engines/alg/logic/game_maddog.h
diff --git a/engines/alg/game_maddog2.cpp b/engines/alg/logic/game_maddog2.cpp
similarity index 99%
rename from engines/alg/game_maddog2.cpp
rename to engines/alg/logic/game_maddog2.cpp
index 8f2554cfaf3..6bbd38e1d54 100644
--- a/engines/alg/game_maddog2.cpp
+++ b/engines/alg/logic/game_maddog2.cpp
@@ -26,7 +26,7 @@
#include "graphics/cursorman.h"
-#include "alg/game_maddog2.h"
+#include "alg/logic/game_maddog2.h"
#include "alg/graphics.h"
#include "alg/scene.h"
diff --git a/engines/alg/game_maddog2.h b/engines/alg/logic/game_maddog2.h
similarity index 100%
rename from engines/alg/game_maddog2.h
rename to engines/alg/logic/game_maddog2.h
diff --git a/engines/alg/game_spacepirates.cpp b/engines/alg/logic/game_spacepirates.cpp
similarity index 99%
rename from engines/alg/game_spacepirates.cpp
rename to engines/alg/logic/game_spacepirates.cpp
index fb00f9404da..7e9c8a6ad5b 100644
--- a/engines/alg/game_spacepirates.cpp
+++ b/engines/alg/logic/game_spacepirates.cpp
@@ -26,7 +26,7 @@
#include "graphics/cursorman.h"
-#include "alg/game_spacepirates.h"
+#include "alg/logic/game_spacepirates.h"
#include "alg/graphics.h"
#include "alg/scene.h"
diff --git a/engines/alg/game_spacepirates.h b/engines/alg/logic/game_spacepirates.h
similarity index 100%
rename from engines/alg/game_spacepirates.h
rename to engines/alg/logic/game_spacepirates.h
diff --git a/engines/alg/module.mk b/engines/alg/module.mk
index 41ccae880a1..3a9afc49527 100644
--- a/engines/alg/module.mk
+++ b/engines/alg/module.mk
@@ -4,16 +4,16 @@ MODULE_OBJS := \
alg.o \
graphics.o \
game.o \
- game_bountyhunter.o \
- game_crimepatrol.o \
- game_drugwars.o \
- game_johnnyrock.o \
- game_maddog.o \
- game_maddog2.o \
- game_spacepirates.o \
metaengine.o \
scene.o \
- video.o
+ video.o \
+ logic/game_bountyhunter.o \
+ logic/game_crimepatrol.o \
+ logic/game_drugwars.o \
+ logic/game_johnnyrock.o \
+ logic/game_maddog.o \
+ logic/game_maddog2.o \
+ logic/game_spacepirates.o
MODULE_DIRS += \
engines/alg
Commit: a009324785b478079a2dd22ee871d3abc9979d73
https://github.com/scummvm/scummvm/commit/a009324785b478079a2dd22ee871d3abc9979d73
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: fix a few memory leaks (hopefully)
Changed paths:
engines/alg/game.cpp
engines/alg/logic/game_bountyhunter.cpp
engines/alg/logic/game_crimepatrol.cpp
engines/alg/logic/game_drugwars.cpp
engines/alg/logic/game_johnnyrock.cpp
engines/alg/logic/game_maddog.cpp
engines/alg/logic/game_maddog2.cpp
engines/alg/logic/game_spacepirates.cpp
engines/alg/scene.cpp
engines/alg/video.cpp
diff --git a/engines/alg/game.cpp b/engines/alg/game.cpp
index 137109948a5..ce383826367 100644
--- a/engines/alg/game.cpp
+++ b/engines/alg/game.cpp
@@ -42,8 +42,10 @@ Game::~Game() {
_libFileEntries.clear();
delete _rnd;
delete[] _palette;
- delete _screen;
delete _background;
+ delete _screen;
+ delete _gun;
+ delete _numbers;
delete _videoDecoder;
delete _sceneInfo;
}
diff --git a/engines/alg/logic/game_bountyhunter.cpp b/engines/alg/logic/game_bountyhunter.cpp
index a47fb376edf..d24950ef5a4 100644
--- a/engines/alg/logic/game_bountyhunter.cpp
+++ b/engines/alg/logic/game_bountyhunter.cpp
@@ -42,6 +42,19 @@ GameBountyHunter::GameBountyHunter(AlgEngine *vm, const AlgGameDescription *gd)
}
GameBountyHunter::~GameBountyHunter() {
+ delete _shotIcon;
+ delete _emptyIcon;
+ delete _liveIcon;
+ delete _deadIcon;
+ delete _diffIcon;
+ delete _bulletholeIcon;
+ delete _playersIcon1;
+ delete _playersIcon2;
+ delete _textScoreIcon;
+ delete _textMenuIcon;
+ delete _textBlackBarIcon;
+ delete _bagsIcons;
+ delete _shotgun;
}
void GameBountyHunter::init() {
diff --git a/engines/alg/logic/game_crimepatrol.cpp b/engines/alg/logic/game_crimepatrol.cpp
index eab67186721..c5a2ac88c48 100644
--- a/engines/alg/logic/game_crimepatrol.cpp
+++ b/engines/alg/logic/game_crimepatrol.cpp
@@ -44,6 +44,12 @@ GameCrimePatrol::GameCrimePatrol(AlgEngine *vm, const AlgGameDescription *gd) :
}
GameCrimePatrol::~GameCrimePatrol() {
+ delete _shotIcon;
+ delete _emptyIcon;
+ delete _liveIcon;
+ delete _deadIcon;
+ delete _difficultyIcon;
+ delete _bulletholeIcon;
}
void GameCrimePatrol::init() {
diff --git a/engines/alg/logic/game_drugwars.cpp b/engines/alg/logic/game_drugwars.cpp
index a0ac2ab1130..4128429a8f8 100644
--- a/engines/alg/logic/game_drugwars.cpp
+++ b/engines/alg/logic/game_drugwars.cpp
@@ -44,6 +44,12 @@ GameDrugWars::GameDrugWars(AlgEngine *vm, const AlgGameDescription *gd) : Game(v
}
GameDrugWars::~GameDrugWars() {
+ delete _shotIcon;
+ delete _emptyIcon;
+ delete _liveIcon;
+ delete _deadIcon;
+ delete _difficultyIcon;
+ delete _bulletholeIcon;
}
void GameDrugWars::init() {
diff --git a/engines/alg/logic/game_johnnyrock.cpp b/engines/alg/logic/game_johnnyrock.cpp
index cf130671cff..e9029b7806a 100644
--- a/engines/alg/logic/game_johnnyrock.cpp
+++ b/engines/alg/logic/game_johnnyrock.cpp
@@ -41,6 +41,9 @@ GameJohnnyRock::GameJohnnyRock(AlgEngine *vm, const AlgGameDescription *gd) : Ga
}
GameJohnnyRock::~GameJohnnyRock() {
+ delete _difficultyIcon;
+ delete _levelIcon;
+ delete _bulletholeIcon;
}
void GameJohnnyRock::init() {
diff --git a/engines/alg/logic/game_maddog.cpp b/engines/alg/logic/game_maddog.cpp
index bf4f8517560..f18bd808ba0 100644
--- a/engines/alg/logic/game_maddog.cpp
+++ b/engines/alg/logic/game_maddog.cpp
@@ -37,6 +37,14 @@ GameMaddog::GameMaddog(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
}
GameMaddog::~GameMaddog() {
+ delete _shotIcon;
+ delete _emptyIcon;
+ delete _liveIcon;
+ delete _deadIcon;
+ delete _reloadIcon;
+ delete _drawIcon;
+ delete _knifeIcon;
+ delete _bulletholeIcon;
}
void GameMaddog::init() {
diff --git a/engines/alg/logic/game_maddog2.cpp b/engines/alg/logic/game_maddog2.cpp
index 6bbd38e1d54..9f10d8362df 100644
--- a/engines/alg/logic/game_maddog2.cpp
+++ b/engines/alg/logic/game_maddog2.cpp
@@ -41,6 +41,14 @@ GameMaddog2::GameMaddog2(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm)
}
GameMaddog2::~GameMaddog2() {
+ delete _shotIcon;
+ delete _emptyIcon;
+ delete _liveIcon;
+ delete _deadIcon;
+ delete _reloadIcon;
+ delete _drawIcon;
+ delete _knifeIcon;
+ delete _bulletholeIcon;
}
void GameMaddog2::init() {
diff --git a/engines/alg/logic/game_spacepirates.cpp b/engines/alg/logic/game_spacepirates.cpp
index 7e9c8a6ad5b..c3ce32c0cb9 100644
--- a/engines/alg/logic/game_spacepirates.cpp
+++ b/engines/alg/logic/game_spacepirates.cpp
@@ -44,6 +44,14 @@ GameSpacePirates::GameSpacePirates(AlgEngine *vm, const AlgGameDescription *gd)
}
GameSpacePirates::~GameSpacePirates() {
+ delete _shotIcon;
+ delete _emptyIcon;
+ delete _deadIcon;
+ delete _liveIcon1;
+ delete _liveIcon2;
+ delete _liveIcon3;
+ delete _difficultyIcon;
+ delete _bulletholeIcon;
}
void GameSpacePirates::init() {
diff --git a/engines/alg/scene.cpp b/engines/alg/scene.cpp
index e8878b1432d..3dc9781b293 100644
--- a/engines/alg/scene.cpp
+++ b/engines/alg/scene.cpp
@@ -31,6 +31,8 @@ SceneInfo::SceneInfo() {
}
SceneInfo::~SceneInfo() {
+ _scenes.clear();
+ _zones.clear();
}
void SceneInfo::loadScnFile(const Common::Path &path) {
diff --git a/engines/alg/video.cpp b/engines/alg/video.cpp
index 3fbb5b89055..5c4ca822789 100644
--- a/engines/alg/video.cpp
+++ b/engines/alg/video.cpp
@@ -68,11 +68,17 @@ void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
assert(typeInterHh == 0x0d);
assert(typeIntraHhv == 0x0e);
assert(typeInterHhv == 0x0f);
+ _currentChunk = 0;
+ _bytesLeft = _size - chunkSize - 6;
+ if (_frame != nullptr) {
+ delete _frame;
+ }
+ if (_audioStream != nullptr) {
+ delete _audioStream;
+ }
_frame = new Graphics::Surface();
_frame->create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
_audioStream = makePacketizedRawStream(8000, Audio::FLAG_UNSIGNED);
- _currentChunk = 0;
- _bytesLeft = _size - chunkSize - 6;
}
void AlgVideoDecoder::skipNumberOfFrames(uint32 num) {
Commit: ec6926052e32bb3acda9b4efeea6a7952bb2a604
https://github.com/scummvm/scummvm/commit/ec6926052e32bb3acda9b4efeea6a7952bb2a604
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: Refactoring, feedback implemented, bug fixes
Changed paths:
engines/alg/alg.cpp
engines/alg/alg.h
engines/alg/detection.cpp
engines/alg/detection.h
engines/alg/detection_tables.h
engines/alg/game.cpp
engines/alg/game.h
engines/alg/graphics.cpp
engines/alg/logic/game_bountyhunter.cpp
engines/alg/logic/game_bountyhunter.h
engines/alg/logic/game_crimepatrol.cpp
engines/alg/logic/game_crimepatrol.h
engines/alg/logic/game_drugwars.cpp
engines/alg/logic/game_drugwars.h
engines/alg/logic/game_johnnyrock.cpp
engines/alg/logic/game_johnnyrock.h
engines/alg/logic/game_maddog.cpp
engines/alg/logic/game_maddog.h
engines/alg/logic/game_maddog2.cpp
engines/alg/logic/game_maddog2.h
engines/alg/logic/game_spacepirates.cpp
engines/alg/logic/game_spacepirates.h
engines/alg/metaengine.cpp
engines/alg/scene.cpp
engines/alg/scene.h
engines/alg/video.cpp
engines/alg/video.h
diff --git a/engines/alg/alg.cpp b/engines/alg/alg.cpp
index c0db9e162c2..8f62e207394 100644
--- a/engines/alg/alg.cpp
+++ b/engines/alg/alg.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "common/config-manager.h"
#include "engines/util.h"
#include "alg/alg.h"
@@ -35,54 +36,45 @@
namespace Alg {
AlgEngine::AlgEngine(OSystem *syst, const AlgGameDescription *gd)
- : Engine(syst) {
+ : Engine(syst), _gameDescription(gd) {
switch (gd->gameType) {
- case Alg::GType_CPATROL_SS_DOS:
- case Alg::GType_CPATROL_DS_DOS:
- case Alg::GType_CPATROL_DEMO_DOS: {
+ case Alg::GType_CRIME_PATROL: {
GameCrimePatrol *game = new GameCrimePatrol(this, gd);
_debugger = new DebuggerCrimePatrol(game);
_game = game;
break;
}
- case Alg::GType_DWARS_SS_DOS:
- case Alg::GType_DWARS_DS_DOS:
- case Alg::GType_DWARS_DEMO_DOS: {
+ case Alg::GType_DRUG_WARS: {
GameDrugWars *game = new GameDrugWars(this, gd);
_debugger = new DebuggerDrugWars(game);
_game = game;
break;
}
- case Alg::GType_JOHNROC_SS_DOS:
- case Alg::GType_JOHNROC_DS_DOS: {
+ case Alg::GType_WSJR: {
GameJohnnyRock *game = new GameJohnnyRock(this, gd);
_debugger = new DebuggerJohnnyRock(game);
_game = game;
break;
}
- case Alg::GType_LBHUNTER_DOS:
- case Alg::GType_LBHUNTER_DEMO_DOS: {
+ case Alg::GType_LAST_BOUNTY_HUNTER: {
GameBountyHunter *game = new GameBountyHunter(this, gd);
_debugger = new DebuggerBountyHunter(game);
_game = game;
break;
}
- case Alg::GType_MADDOG_DOS: {
+ case Alg::GType_MADDOG: {
GameMaddog *game = new GameMaddog(this, gd);
_debugger = new DebuggerMaddog(game);
_game = game;
break;
}
- case Alg::GType_MADDOG2_SS_DOS:
- case Alg::GType_MADDOG2_DS_DOS: {
+ case Alg::GType_MADDOG2: {
GameMaddog2 *game = new GameMaddog2(this, gd);
_debugger = new DebuggerMaddog2(game);
_game = game;
break;
}
- case Alg::GType_SPIRATES_SS_DOS:
- case Alg::GType_SPIRATES_DS_DOS:
- case Alg::GType_SPIRATES_DEMO_DOS: {
+ case Alg::GType_SPACE_PIRATES: {
GameSpacePirates *game = new GameSpacePirates(this, gd);
_debugger = new DebuggerSpacePirates(game);
_game = game;
@@ -98,6 +90,9 @@ AlgEngine::~AlgEngine() {
Common::Error AlgEngine::run() {
initGraphics(320, 200);
setDebugger(_debugger);
+ if (ConfMan.hasKey("single_speed_videos")) {
+ _useSingleSpeedVideos = ConfMan.getBool("single_speed_videos");
+ }
return _game->run();
}
diff --git a/engines/alg/alg.h b/engines/alg/alg.h
index fe7ea27e6a1..22a1292828a 100644
--- a/engines/alg/alg.h
+++ b/engines/alg/alg.h
@@ -47,14 +47,17 @@ class AlgEngine : public Engine {
public:
AlgEngine(OSystem *syst, const AlgGameDescription *desc);
~AlgEngine();
-
Common::Error run();
-
bool hasFeature(EngineFeature f) const;
+ Common::Platform getPlatform() const;
+ bool isDemo() const;
+ bool useSingleSpeedVideos() const { return _useSingleSpeedVideos; };
private:
+ const AlgGameDescription *_gameDescription;
Game *_game;
GUI::Debugger *_debugger;
+ bool _useSingleSpeedVideos = false;
};
class Console : public GUI::Debugger {
diff --git a/engines/alg/detection.cpp b/engines/alg/detection.cpp
index 126592e7327..1899779d6f4 100644
--- a/engines/alg/detection.cpp
+++ b/engines/alg/detection.cpp
@@ -26,35 +26,25 @@
#include "alg/detection.h"
#include "alg/detection_tables.h"
-static const PlainGameDescriptor algGame[] = {
- { "cpatrols", "Crime Patrol (lower video quality)" },
- { "cpatrold", "Crime Patrol" },
- { "cpatroldemo", "Crime Patrol Demo" },
- { "dwarss", "Drug Wars (lower video quality)" },
- { "dwarsd", "Drug Wars" },
- { "dwarsdemo", "Drug Wars Demo" },
- { "johnrocs", "Who Shot Johnny Rock? (lower video quality)" },
- { "johnrocd", "Who Shot Johnny Rock?" },
+static const PlainGameDescriptor algGames[] = {
+ { "cpatrol", "Crime Patrol" },
+ { "dwars", "Drug Wars" },
+ { "johnroc", "Who Shot Johnny Rock?" },
{ "lbhunter", "The Last Bounty Hunter" },
- { "lbhunterdemo", "The Last Bounty Hunter Demo" },
{ "maddog", "Mad Dog McCree" },
- { "maddog2s", "Mad Dog II: The Lost Gold (lower video quality)" },
- { "maddog2d", "Mad Dog II: The Lost Gold" },
- { "spiratess", "Space Pirates (lower video quality)" },
- { "spiratesd", "Space Pirates" },
- { "spiratesdemo", "Space Pirates Demo" },
+ { "maddog2", "Mad Dog II: The Lost Gold" },
+ { "spirates", "Space Pirates" },
{ nullptr, nullptr }
};
static const DebugChannelDef debugFlagList[] = {
- { Alg::kAlgDebugGeneral, "general", "General" },
- { Alg::kAlgDebugGraphics, "graphics", "Graphics" },
- DEBUG_CHANNEL_END
-};
+ {Alg::kAlgDebugGeneral, "general", "General"},
+ {Alg::kAlgDebugGraphics, "graphics", "Graphics"},
+ DEBUG_CHANNEL_END};
class AlgMetaEngineDetection : public AdvancedMetaEngineDetection<Alg::AlgGameDescription> {
public:
- AlgMetaEngineDetection() : AdvancedMetaEngineDetection(Alg::gameDescriptions, algGame) {
+ AlgMetaEngineDetection() : AdvancedMetaEngineDetection(Alg::gameDescriptions, algGames) {
_guiOptions = GUIO1(GUIO_NOMIDI);
_maxScanDepth = 1;
}
diff --git a/engines/alg/detection.h b/engines/alg/detection.h
index b2ab0660070..a4de10363ed 100644
--- a/engines/alg/detection.h
+++ b/engines/alg/detection.h
@@ -27,22 +27,13 @@
namespace Alg {
enum AlgGameType {
- GType_CPATROL_SS_DOS,
- GType_CPATROL_DS_DOS,
- GType_CPATROL_DEMO_DOS,
- GType_DWARS_SS_DOS,
- GType_DWARS_DS_DOS,
- GType_DWARS_DEMO_DOS,
- GType_JOHNROC_SS_DOS,
- GType_JOHNROC_DS_DOS,
- GType_LBHUNTER_DOS,
- GType_LBHUNTER_DEMO_DOS,
- GType_MADDOG_DOS,
- GType_MADDOG2_SS_DOS,
- GType_MADDOG2_DS_DOS,
- GType_SPIRATES_SS_DOS,
- GType_SPIRATES_DS_DOS,
- GType_SPIRATES_DEMO_DOS,
+ GType_CRIME_PATROL,
+ GType_DRUG_WARS,
+ GType_WSJR,
+ GType_LAST_BOUNTY_HUNTER,
+ GType_MADDOG,
+ GType_MADDOG2,
+ GType_SPACE_PIRATES,
};
struct AlgGameDescription {
@@ -58,6 +49,8 @@ struct AlgGameDescription {
}
};
+#define GAMEOPTION_SINGLE_SPEED_VERSION GUIO_GAMEOPTIONS1
+
} // End of namespace Alg
#endif // ALG_DETECTION_H
diff --git a/engines/alg/detection_tables.h b/engines/alg/detection_tables.h
index c349a906a13..11b887cc8de 100644
--- a/engines/alg/detection_tables.h
+++ b/engines/alg/detection_tables.h
@@ -23,111 +23,72 @@ namespace Alg {
static const AlgGameDescription gameDescriptions[] = {
{
- // Crime Patrol (v1.00) (Single Speed CD-ROM Version)
+ // Crime Patrol (v1.00) (DOS)
{
- "cpatrols",
- "",
- AD_ENTRY1s("CPSS.LIB", "feddb53975c9832c0f54055c15350389", 193353403),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
- },
- GType_CPATROL_SS_DOS,
- },
- {
- // Crime Patrol (v1.00) (Double Speed CD-ROM Version)
- {
- "cpatrold",
+ "cpatrol",
"",
AD_ENTRY1s("CPDS.LIB", "43579f72207298f154f6fb2b1a24e193", 303710700),
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
},
- GType_CPATROL_DS_DOS,
+ GType_CRIME_PATROL,
},
{
- // Crime Patrol Demo
+ // Crime Patrol Demo (DOS)
{
- "cpatroldemo",
- "",
+ "cpatrol",
+ "Demo",
AD_ENTRY1s("CP.LIB", "0621e198afb7be96279beec770cd8461", 16859660),
Common::EN_ANY,
Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ ADGF_DEMO,
+ GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
},
- GType_CPATROL_DEMO_DOS,
+ GType_CRIME_PATROL,
},
{
- // Drug Wars (v1.00) (Single Speed CD-ROM Version)
+ // Drug Wars (v1.00) (DOS)
{
- "dwarss",
- "",
- AD_ENTRY1s("DWSS.LIB", "f041a2b106d3ba27b03b5695e5263172", 191903386),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
- },
- GType_DWARS_SS_DOS,
- },
- {
- // Drug Wars (v1.00) (Double Speed CD-ROM Version)
- {
- "dwarsd",
+ "dwars",
"",
AD_ENTRY1s("DWDS.LIB", "f00bc0d980eac72b6bbfa691808b62ae", 320739868),
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
},
- GType_DWARS_DS_DOS,
+ GType_DRUG_WARS,
},
{
- // Drug Wars Demo
+ // Drug Wars Demo (DOS)
{
- "dwarsdemo",
- "",
+ "dwars",
+ "Demo",
AD_ENTRY1s("DWDEMO.LIB", "1f0cf57c8aeb326c37777c4ad82e7889", 24435449),
Common::EN_ANY,
Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ ADGF_DEMO,
+ GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
},
- GType_DWARS_DEMO_DOS,
+ GType_DRUG_WARS,
},
{
- // Who Shot Johnny Rock? (v1.00) (Single Speed CD-ROM Version)
+ // Who Shot Johnny Rock? (v1.00) (DOS)
{
- "johnrocs",
- "",
- AD_ENTRY1s("JOHNROC.LIB", "3cbf7843ef2fdf23716301dceaa2eb10", 141833752),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
- },
- GType_JOHNROC_SS_DOS,
- },
- {
- // Who Shot Johnny Rock? (v1.00) (Double Speed CD-ROM Version)
- {
- "johnrocd",
+ "johnroc",
"",
AD_ENTRY1s("JOHNROCD.LIB", "93c38b5fc7d1ae6e9dccf4f7a1c313a8", 326535618),
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
},
- GType_JOHNROC_DS_DOS,
+ GType_WSJR,
},
{
- // The Last Bounty Hunter (v1.00)
+ // The Last Bounty Hunter (v1.00) (DOS)
{
"lbhunter",
"",
@@ -135,25 +96,25 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_UNSTABLE,
- GUIO1(GUIO_NOMIDI)
+ GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
},
- GType_LBHUNTER_DOS,
+ GType_LAST_BOUNTY_HUNTER,
},
{
- // The Last Bounty Hunter Demo
+ // The Last Bounty Hunter Demo (DOS)
{
- "lbhunterdemo",
- "",
+ "lbhunter",
+ "demo",
AD_ENTRY1s("BHDEMO.LIB", "af5fbbd5e18d96225077eb6bf2cac680", 28368775),
Common::EN_ANY,
Common::kPlatformDOS,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NOMIDI)
+ ADGF_UNSTABLE | ADGF_DEMO,
+ GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
},
- GType_LBHUNTER_DEMO_DOS,
+ GType_LAST_BOUNTY_HUNTER,
},
{
- // Mad Dog McCree (v1.03a)
+ // Mad Dog McCree (v1.03a) (DOS)
{
"maddog",
"",
@@ -161,74 +122,48 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
- },
- GType_MADDOG_DOS,
- },
- {
- // Mad Dog II: The Lost Gold (v1.00) (Single Speed CD-ROM Version)
- {
- "maddog2s",
- "",
- AD_ENTRY1s("MADDOG2.LIB", "7b54bca3932b28d8776eaed16a9f43b5", 185708043),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
},
- GType_MADDOG2_SS_DOS,
+ GType_MADDOG,
},
{
- // Mad Dog II: The Lost Gold (v1.00) (Double Speed CD-ROM Version)
+ // Mad Dog II: The Lost Gold (v1.00) (DOS)
{
- "maddog2d",
+ "maddog2",
"",
AD_ENTRY1s("MADDOG2D.LIB", "1660b1728573481483c50206ad92a0ca", 291119013),
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
- },
- GType_MADDOG2_DS_DOS,
- },
- {
- // Space Pirates (v1.00) (Single Speed CD-ROM Version)
- {
- "spiratess",
- "",
- AD_ENTRY1s("SPSS.LIB", "c006d9f85fd86024b57d69875f23c473", 175141152),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
},
- GType_SPIRATES_SS_DOS,
+ GType_MADDOG2,
},
{
- // Space Pirates (v1.00) (Double Speed CD-ROM Version)
+ // Space Pirates (v1.00) (DOS)
{
- "spiratesd",
+ "spirates",
"",
AD_ENTRY1s("SPDS.LIB", "223d3a339d542905c437a6a63cf6dbd8", 273506701),
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
},
- GType_SPIRATES_DS_DOS,
+ GType_SPACE_PIRATES,
},
{
- // Space Pirates Demo
+ // Space Pirates Demo (DOS)
{
- "spiratesdemo",
- "",
+ "spirates",
+ "Demo",
AD_ENTRY1s("SP.LIB", "a1a1b7c9ed28ff2484ab8362825c3973", 14556553),
Common::EN_ANY,
Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NOMIDI)
+ ADGF_DEMO,
+ GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
},
- GType_SPIRATES_DEMO_DOS,
+ GType_SPACE_PIRATES,
},
{ AD_TABLE_END_MARKER, 0 }
diff --git a/engines/alg/game.cpp b/engines/alg/game.cpp
index ce383826367..b3772d1ee55 100644
--- a/engines/alg/game.cpp
+++ b/engines/alg/game.cpp
@@ -24,6 +24,7 @@
#include "common/events.h"
#include "common/substream.h"
#include "common/timer.h"
+#include "graphics/cursorman.h"
#include "graphics/paletteman.h"
#include "alg/graphics.h"
@@ -42,12 +43,52 @@ Game::~Game() {
_libFileEntries.clear();
delete _rnd;
delete[] _palette;
- delete _background;
- delete _screen;
- delete _gun;
- delete _numbers;
delete _videoDecoder;
delete _sceneInfo;
+ if (_background) {
+ _background->free();
+ delete _background;
+ }
+ if (_screen) {
+ _screen->free();
+ delete _screen;
+ }
+ for (auto item : *_gun) {
+ if (item) {
+ item->free();
+ delete item;
+ }
+ }
+ for (auto item : *_numbers) {
+ if (item) {
+ item->free();
+ delete item;
+ }
+ }
+ if (_saveSound != nullptr) {
+ delete _saveSound;
+ }
+ if (_loadSound != nullptr) {
+ delete _loadSound;
+ }
+ if (_easySound != nullptr) {
+ delete _easySound;
+ }
+ if (_avgSound != nullptr) {
+ delete _avgSound;
+ }
+ if (_hardSound != nullptr) {
+ delete _hardSound;
+ }
+ if (_skullSound != nullptr) {
+ delete _skullSound;
+ }
+ if (_shotSound != nullptr) {
+ delete _shotSound;
+ }
+ if (_emptySound != nullptr) {
+ delete _emptySound;
+ }
}
void Game::init() {
@@ -68,6 +109,11 @@ Common::Error Game::run() {
return Common::kNoError;
}
+void Game::shutdown() {
+ g_system->getMixer()->stopAll();
+ _vm->quitGame();
+}
+
bool Game::pollEvents() {
Common::Event event;
bool hasEvents = false;
@@ -113,7 +159,7 @@ void Game::loadLibArchive(const Common::Path &path) {
_libFileEntries[entryName] = entryOffset;
}
_libFile.seek(0);
- _videoDecoder->setStream(_libFile.readStream(_libFile.size()));
+ _videoDecoder->setReadStream(_libFile.readStream(_libFile.size()));
}
bool Game::loadScene(Scene *scene) {
@@ -166,11 +212,11 @@ bool Game::fired(Common::Point *point) {
Rect *Game::checkZone(Zone *zone, Common::Point *point) {
for (auto &rect : zone->_rects) {
- if (point->x >= rect.left &&
- point->x <= rect.right &&
- point->y >= rect.top &&
- point->y <= rect.bottom) {
- return ▭
+ if (point->x >= rect->left &&
+ point->x <= rect->right &&
+ point->y >= rect->top &&
+ point->y <= rect->bottom) {
+ return rect;
}
}
return nullptr;
@@ -219,7 +265,7 @@ void Game::adjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty) {
for (size_t j = 0; j < scene->_zones.size(); j++) {
Zone *zone = scene->_zones[j];
for (size_t k = 0; k < zone->_rects.size(); k++) {
- Rect *rect = &zone->_rects[k];
+ Rect *rect = zone->_rects[k];
if (!(scene->_diff & 0x02)) {
int16 cx = (rect->left + rect->right) / 2;
int16 cy = (rect->top + rect->bottom) / 2;
@@ -260,6 +306,30 @@ int8 Game::skipToNewScene(Scene *scene) {
return 0;
}
+uint16 Game::randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
+ if (max == 1) {
+ return 0;
+ }
+ // reset mask if full
+ uint16 fullMask = 0xFFFF >> (16 - max);
+ if (*mask == fullMask) {
+ *mask = 0;
+ }
+ uint16 randomNum = 0;
+ // find an unused random number
+ while (1) {
+ randomNum = _rnd->getRandomNumber(max - 1);
+ // check if bit is already used
+ uint16 bit = 1 << randomNum;
+ if (!((*mask & bit) || randomNum == exclude)) {
+ // set the bit in mask
+ *mask |= bit;
+ break;
+ }
+ }
+ return randomNum;
+}
+
// Sound
Audio::SeekableAudioStream *Game::loadSoundFile(const Common::Path &path) {
Common::File *file = new Common::File();
@@ -313,7 +383,7 @@ static void cursorTimerCallback(void *refCon) {
}
void Game::setupCursorTimer() {
- g_system->getTimerManager()->installTimerProc(&cursorTimerCallback, 1000000 / 50, (void *)this, "newtimer");
+ g_system->getTimerManager()->installTimerProc(&cursorTimerCallback, 1000000 / 50, (void *)this, "cursortimer");
}
void Game::removeCursorTimer() {
@@ -384,7 +454,7 @@ void Game::rectHard(Rect *rect) {
}
void Game::rectExit(Rect *rect) {
- _vm->quitGame();
+ shutdown();
}
// Script functions: Scene PreOps
@@ -487,20 +557,20 @@ void Game::sceneNxtfrm(Scene *scene) {
void Game::debug_drawZoneRects() {
if (_debug_drawRects || debugChannelSet(1, Alg::kAlgDebugGraphics)) {
if (_inMenu) {
- for (auto &rect : _submenzone->_rects) {
- _screen->drawLine(rect.left, rect.top, rect.right, rect.top, 1);
- _screen->drawLine(rect.left, rect.top, rect.left, rect.bottom, 1);
- _screen->drawLine(rect.right, rect.bottom, rect.right, rect.top, 1);
- _screen->drawLine(rect.right, rect.bottom, rect.left, rect.bottom, 1);
+ for (auto rect : _submenzone->_rects) {
+ _screen->drawLine(rect->left, rect->top, rect->right, rect->top, 1);
+ _screen->drawLine(rect->left, rect->top, rect->left, rect->bottom, 1);
+ _screen->drawLine(rect->right, rect->bottom, rect->right, rect->top, 1);
+ _screen->drawLine(rect->right, rect->bottom, rect->left, rect->bottom, 1);
}
} else if (_curScene != "") {
Scene *targetScene = _sceneInfo->findScene(_curScene);
for (auto &zone : targetScene->_zones) {
- for (Rect &rect : zone->_rects) {
- _screen->drawLine(rect.left, rect.top, rect.right, rect.top, 1);
- _screen->drawLine(rect.left, rect.top, rect.left, rect.bottom, 1);
- _screen->drawLine(rect.right, rect.bottom, rect.right, rect.top, 1);
- _screen->drawLine(rect.right, rect.bottom, rect.left, rect.bottom, 1);
+ for (auto rect : zone->_rects) {
+ _screen->drawLine(rect->left, rect->top, rect->right, rect->top, 1);
+ _screen->drawLine(rect->left, rect->top, rect->left, rect->bottom, 1);
+ _screen->drawLine(rect->right, rect->bottom, rect->right, rect->top, 1);
+ _screen->drawLine(rect->right, rect->bottom, rect->left, rect->bottom, 1);
}
}
}
diff --git a/engines/alg/game.h b/engines/alg/game.h
index 51369c8e8ce..5e5c672db05 100644
--- a/engines/alg/game.h
+++ b/engines/alg/game.h
@@ -52,7 +52,6 @@ protected:
SceneInfo *_sceneInfo;
Common::RandomSource *_rnd;
- Common::Path _libFileName;
Common::File _libFile;
Common::HashMap<Common::String, uint32> _libFileEntries;
@@ -79,13 +78,14 @@ protected:
Zone *_menuzone;
Zone *_submenzone;
- bool _leftDown;
- bool _rightDown;
+ bool _leftDown = 0;
+ bool _rightDown = 0;
Common::Point _mousePos;
const uint32 _pauseDiffScale[3] = {0x10000, 0x8000, 0x4000};
const uint32 _rectDiffScale[3] = {0x10000, 0x0C000, 0x8000};
+ void shutdown();
bool pollEvents();
void loadLibArchive(const Common::Path &path);
Audio::SeekableAudioStream *loadSoundFile(const Common::Path &path);
@@ -100,6 +100,7 @@ protected:
uint32 getFrame(Scene *scene);
void adjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty);
int8 skipToNewScene(Scene *scene);
+ uint16 randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
void debug_drawZoneRects();
// Sounds
diff --git a/engines/alg/graphics.cpp b/engines/alg/graphics.cpp
index f20b8e0fd70..30c585e8510 100644
--- a/engines/alg/graphics.cpp
+++ b/engines/alg/graphics.cpp
@@ -121,7 +121,7 @@ Common::Array<Graphics::Surface *> *AlgGraphics::loadScreenCoordAniImage(const C
uint16 length = 0;
int16 offset = 0;
uint32 dest = 0;
- uint32 x, y = 0;
+ uint32 x = 0, y = 0;
while (aniFile.pos() < aniFile.size()) {
Graphics::Surface *renderTarget = new Graphics::Surface();
renderTarget->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
diff --git a/engines/alg/logic/game_bountyhunter.cpp b/engines/alg/logic/game_bountyhunter.cpp
index d24950ef5a4..02a833671a6 100644
--- a/engines/alg/logic/game_bountyhunter.cpp
+++ b/engines/alg/logic/game_bountyhunter.cpp
@@ -26,35 +26,71 @@
#include "graphics/cursorman.h"
-#include "alg/logic/game_bountyhunter.h"
#include "alg/graphics.h"
+#include "alg/logic/game_bountyhunter.h"
#include "alg/scene.h"
namespace Alg {
GameBountyHunter::GameBountyHunter(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
- if (gd->gameType == GType_LBHUNTER_DOS) {
- _libFileName = "bhds.lib";
- } else if (gd->gameType == GType_LBHUNTER_DEMO_DOS) {
- _libFileName = "bhdemo.lib";
- _isDemo = true;
- }
}
GameBountyHunter::~GameBountyHunter() {
- delete _shotIcon;
- delete _emptyIcon;
- delete _liveIcon;
- delete _deadIcon;
- delete _diffIcon;
- delete _bulletholeIcon;
- delete _playersIcon1;
- delete _playersIcon2;
- delete _textScoreIcon;
- delete _textMenuIcon;
- delete _textBlackBarIcon;
- delete _bagsIcons;
- delete _shotgun;
+ if (_shotIcon) {
+ _shotIcon->free();
+ delete _shotIcon;
+ }
+ if (_emptyIcon) {
+ _emptyIcon->free();
+ delete _emptyIcon;
+ }
+ if (_liveIcon) {
+ _liveIcon->free();
+ delete _liveIcon;
+ }
+ if (_deadIcon) {
+ _deadIcon->free();
+ delete _deadIcon;
+ }
+ if (_diffIcon) {
+ _diffIcon->free();
+ delete _diffIcon;
+ }
+ if (_bulletholeIcon) {
+ _bulletholeIcon->free();
+ delete _bulletholeIcon;
+ }
+ if (_playersIcon1) {
+ _playersIcon1->free();
+ delete _playersIcon1;
+ }
+ if (_playersIcon2) {
+ _playersIcon2->free();
+ delete _playersIcon2;
+ }
+ if (_textScoreIcon) {
+ _textScoreIcon->free();
+ delete _textScoreIcon;
+ }
+ if (_textMenuIcon) {
+ _textMenuIcon->free();
+ delete _textMenuIcon;
+ }
+ if (_textBlackBarIcon) {
+ _textBlackBarIcon->free();
+ delete _textBlackBarIcon;
+ }
+ for (auto item : *_bagsIcons) {
+ item->free();
+ delete item;
+ }
+ for (auto item : *_shotgun) {
+ item->free();
+ delete item;
+ }
+ if (_shotgunSound != nullptr) {
+ delete _shotgunSound;
+ }
}
void GameBountyHunter::init() {
@@ -63,23 +99,22 @@ void GameBountyHunter::init() {
_videoPosX = 0;
_videoPosY = 0;
- loadLibArchive(_libFileName);
+ if (_vm->isDemo()) {
+ loadLibArchive("bhdemo.lib");
+ } else {
+ loadLibArchive("bhds.lib");
+ }
+
_sceneInfo->loadScnFile("bh.scn");
_startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
- _menuzone = new Zone();
- _menuzone->_name = "MainMenu";
- _menuzone->_ptrfb = "GLOBALHIT";
-
+ _menuzone = new Zone("MainMenu", "GLOBALHIT");
_menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
- _submenzone = new Zone();
- _submenzone->_name = "SubMenu";
- _submenzone->_ptrfb = "GLOBALHIT";
-
+ _submenzone = new Zone("SubMenu", "GLOBALHIT");
_submenzone->addRect(0, 0, 0x78, 0x3C, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0xC8, 0, 0x0140, 0x3C, nullptr, 0, "RECTLOAD", "0");
_submenzone->addRect(0xC8, 0x3C, 0x0140, 0x78, nullptr, 0, "RECTSAVE", "0");
@@ -256,9 +291,8 @@ void GameBountyHunter::registerScriptFunctions() {
}
void GameBountyHunter::verifyScriptFunctions() {
- Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
- for (size_t i = 0; i < scenes->size(); i++) {
- Scene *scene = (*scenes)[i];
+ auto scenes = _sceneInfo->getScenes();
+ for (auto scene : *scenes) {
getScriptFunctionScene(PREOP, scene->_preop);
getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
getScriptFunctionScene(INSOP, scene->_insop);
@@ -266,10 +300,9 @@ void GameBountyHunter::verifyScriptFunctions() {
getScriptFunctionScene(SCNSCR, scene->_scnscr);
getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
getScriptFunctionScene(NXTSCN, scene->_nxtscn);
- for (size_t j = 0; j < scene->_zones.size(); j++) {
- Zone *zone = scene->_zones[j];
- for (size_t k = 0; k < zone->_rects.size(); k++) {
- getScriptFunctionRectHit(zone->_rects[k]._rectHit);
+ for (auto zone : scene->_zones) {
+ for (auto rect : zone->_rects) {
+ getScriptFunctionRectHit(rect->_rectHit);
}
}
}
@@ -434,7 +467,7 @@ Common::Error GameBountyHunter::run() {
callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
if (_curScene == "") {
- _vm->quitGame();
+ shutdown();
}
}
return Common::kNoError;
@@ -504,7 +537,7 @@ void GameBountyHunter::moveMouse() {
if (_inMenu) {
_whichGun = 3; // in menu cursor
} else {
- // disabled for now, because glitchy
+ // TODO: disabled for now, because glitchy
/*
uint16 x = _mousePos.x;
uint16 y = _mousePos.y;
@@ -675,30 +708,6 @@ uint16 GameBountyHunter::beginLevel(uint8 levelNumber) {
return sceneNum;
}
-uint16 GameBountyHunter::randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
- if (max == 1) {
- return 0;
- }
- // reset mask if full
- uint16 fullMask = 0xFFFF >> (16 - max);
- if (*mask == fullMask) {
- *mask = 0;
- }
- uint16 randomNum = 0;
- // find an unused random number
- while (1) {
- randomNum = _rnd->getRandomNumber(max - 1);
- // check if bit is already used
- uint16 bit = 1 << randomNum;
- if (!((*mask & bit) || randomNum == exclude)) {
- // set the bit in mask
- *mask |= bit;
- break;
- }
- }
- return randomNum;
-}
-
uint16 GameBountyHunter::pickRandomScene(uint16 *sceneList, uint8 max) {
if (max == 0) {
return 0;
@@ -839,7 +848,7 @@ void GameBountyHunter::rectStart(Rect *rect) {
_fired = false;
_gameInProgress = true;
_restartScene = 0;
- if (_isDemo) {
+ if (_vm->isDemo()) {
setNextScene(0x45); // TODO fix
} else {
setNextScene(0x45);
@@ -1220,22 +1229,7 @@ void GameBountyHunter::sceneNxtscnWoundedMain(Scene *scene) {
}
void GameBountyHunter::sceneNxtscnEndLevel(Scene *scene) {
- switch (_currentLevel) {
- case 0:
- _levelDoneMask |= 0x02;
- break;
- case 1:
- _levelDoneMask |= 0x04;
- break;
- case 2:
- _levelDoneMask |= 0x08;
- break;
- case 3:
- _levelDoneMask |= 0x10;
- break;
- default:
- return;
- }
+ _levelDoneMask |= (2 << _currentLevel);
_numLevelsDone++;
if (_numLevelsDone > 1 && _unk_2ADA6 < 2) {
_unk_2ADA6++;
diff --git a/engines/alg/logic/game_bountyhunter.h b/engines/alg/logic/game_bountyhunter.h
index ddfd18dc051..98ecc7c2673 100644
--- a/engines/alg/logic/game_bountyhunter.h
+++ b/engines/alg/logic/game_bountyhunter.h
@@ -53,12 +53,12 @@ class GameBountyHunter : public Game {
public:
GameBountyHunter(AlgEngine *vm, const AlgGameDescription *gd);
- ~GameBountyHunter();
- Common::Error run();
+ ~GameBountyHunter() override;
+ Common::Error run() override;
void debugWarpTo(int val);
private:
- void init();
+ void init() override;
void registerScriptFunctions();
void verifyScriptFunctions();
BHScriptFunctionRect getScriptFunctionRectHit(Common::String name);
@@ -118,7 +118,7 @@ private:
const uint8 _mainLevelMasks[5] = {2, 4, 8, 0x10, 0x80};
const uint8 _gunfightCountDown[15] = {5, 4, 3, 3, 3, 4, 3, 3, 2, 1, 3, 2, 2, 2, 1};
- const uint16 _firstSceneInScenario[4] = {4, 0x36, 0x36, 0x66};
+ // const uint16 _firstSceneInScenario[4] = {4, 0x36, 0x36, 0x66};
const uint16 _moneyScenes[4] = {0x017D, 0x013C, 0xC3, 0x69};
const uint16 _gunfightScenarios[18] = {0x0116, 0x0118, 0x011B, 0x011D, 0x011F, 0x0121, 0x0123, 0x0125, 0x0127,
0x0129, 0x012B, 0x012D, 0x012F, 0x0131, 0x0133, 0x0135, 0x0137, 0x0139};
@@ -127,8 +127,6 @@ private:
const uint16 _onePlayerOfTwoDead[2] = {0x0109, 0x010A};
const uint16 _allPlayersDead = 0x108;
- bool _isDemo = 0;
-
// gamestate
uint16 _restartScene = 0;
uint8 _numPlayers = 1;
@@ -144,10 +142,10 @@ private:
uint8 _levelDoneMask = 0;
uint8 _numSubLevelsDone = 0;
- uint16 _usedScenes = 0;
- int16 _lastPick = -1;
- int16 _initted = 0;
- int16 _sceneCount = 0;
+ // uint16 _usedScenes = 0;
+ // int16 _lastPick = -1;
+ // int16 _initted = 0;
+ // int16 _sceneCount = 0;
uint16 *_randomSceneList;
uint8 _randomMax = 0;
@@ -197,7 +195,6 @@ private:
void iconShotgun();
void iconReset();
uint16 beginLevel(uint8 levelNumber);
- uint16 randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
uint16 pickRandomScene(uint16 *sceneList, uint8 max);
uint16 pickGunfightScene();
uint16 pickInnocentScene();
diff --git a/engines/alg/logic/game_crimepatrol.cpp b/engines/alg/logic/game_crimepatrol.cpp
index c5a2ac88c48..661253a450e 100644
--- a/engines/alg/logic/game_crimepatrol.cpp
+++ b/engines/alg/logic/game_crimepatrol.cpp
@@ -26,30 +26,40 @@
#include "graphics/cursorman.h"
-#include "alg/logic/game_crimepatrol.h"
#include "alg/graphics.h"
+#include "alg/logic/game_crimepatrol.h"
#include "alg/scene.h"
namespace Alg {
GameCrimePatrol::GameCrimePatrol(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
- if (gd->gameType == GType_CPATROL_SS_DOS) {
- _libFileName = "cpss.lib";
- } else if (gd->gameType == GType_CPATROL_DS_DOS) {
- _libFileName = "cpds.lib";
- } else if (gd->gameType == GType_CPATROL_DEMO_DOS) {
- _libFileName = "cp.lib";
- _isDemo = true;
- }
}
GameCrimePatrol::~GameCrimePatrol() {
- delete _shotIcon;
- delete _emptyIcon;
- delete _liveIcon;
- delete _deadIcon;
- delete _difficultyIcon;
- delete _bulletholeIcon;
+ if (_shotIcon) {
+ _shotIcon->free();
+ delete _shotIcon;
+ }
+ if (_emptyIcon) {
+ _emptyIcon->free();
+ delete _emptyIcon;
+ }
+ if (_liveIcon) {
+ _liveIcon->free();
+ delete _liveIcon;
+ }
+ if (_deadIcon) {
+ _deadIcon->free();
+ delete _deadIcon;
+ }
+ if (_difficultyIcon) {
+ _difficultyIcon->free();
+ delete _difficultyIcon;
+ }
+ if (_bulletholeIcon) {
+ _bulletholeIcon->free();
+ delete _bulletholeIcon;
+ }
}
void GameCrimePatrol::init() {
@@ -58,23 +68,24 @@ void GameCrimePatrol::init() {
_videoPosX = 11;
_videoPosY = 2;
- loadLibArchive(_libFileName);
+ if (_vm->isDemo()) {
+ loadLibArchive("cp.lib");
+ } else if(_vm->useSingleSpeedVideos()) {
+ loadLibArchive("cpss.lib");
+ } else {
+ loadLibArchive("cpds.lib");
+ }
+
_sceneInfo->loadScnFile("cp.scn");
_startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
- _menuzone = new Zone();
- _menuzone->_name = "MainMenu";
- _menuzone->_ptrfb = "GLOBALHIT";
-
+ _menuzone = new Zone("MainMenu", "GLOBALHIT");
_menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
- _submenzone = new Zone();
- _submenzone->_name = "SubMenu";
- _submenzone->_ptrfb = "GLOBALHIT";
-
+ _submenzone = new Zone("SubMenu", "GLOBALHIT");
_submenzone->addRect(0x1C, 0x11, 0x5D, 0x20, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x1C, 0x31, 0x5D, 0x40, nullptr, 0, "RECTLOAD", "0");
_submenzone->addRect(0x1C, 0x51, 0x5D, 0x60, nullptr, 0, "RECTSAVE", "0");
@@ -223,9 +234,8 @@ void GameCrimePatrol::registerScriptFunctions() {
}
void GameCrimePatrol::verifyScriptFunctions() {
- Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
- for (size_t i = 0; i < scenes->size(); i++) {
- Scene *scene = (*scenes)[i];
+ auto scenes = _sceneInfo->getScenes();
+ for (auto scene : *scenes) {
getScriptFunctionScene(PREOP, scene->_preop);
getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
getScriptFunctionScene(INSOP, scene->_insop);
@@ -233,10 +243,9 @@ void GameCrimePatrol::verifyScriptFunctions() {
getScriptFunctionScene(SCNSCR, scene->_scnscr);
getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
getScriptFunctionScene(NXTSCN, scene->_nxtscn);
- for (size_t j = 0; j < scene->_zones.size(); j++) {
- Zone *zone = scene->_zones[j];
- for (size_t k = 0; k < zone->_rects.size(); k++) {
- getScriptFunctionRectHit(zone->_rects[k]._rectHit);
+ for (auto zone : scene->_zones) {
+ for (auto rect : zone->_rects) {
+ getScriptFunctionRectHit(rect->_rectHit);
}
}
}
@@ -404,7 +413,7 @@ Common::Error GameCrimePatrol::run() {
callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
if (_curScene == "") {
- _vm->quitGame();
+ shutdown();
}
}
return Common::kNoError;
@@ -499,7 +508,7 @@ void GameCrimePatrol::moveMouse() {
if (_inMenu) {
_whichGun = 3; // in menu cursor
} else {
- // disabled for now, because glitchy
+ // TODO: disabled for now, because glitchy
/*
uint16 x = _mousePos.x;
uint16 y = _mousePos.y;
@@ -643,30 +652,6 @@ uint16 GameCrimePatrol::sceneToNumber(Scene *scene) {
return atoi(scene->_name.substr(5).c_str());
}
-uint16 GameCrimePatrol::randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
- if (max == 1) {
- return 0;
- }
- // reset mask if full
- uint16 fullMask = 0xFFFF >> (16 - max);
- if (*mask == fullMask) {
- *mask = 0;
- }
- uint16 randomNum = 0;
- // find an unused random number
- while (1) {
- randomNum = _rnd->getRandomNumber(max - 1);
- // check if bit is already used
- uint16 bit = 1 << randomNum;
- if (!((*mask & bit) || randomNum == exclude)) {
- // set the bit in mask
- *mask |= bit;
- break;
- }
- }
- return randomNum;
-}
-
uint16 GameCrimePatrol::pickRandomScene(uint8 index, uint8 max) {
if (max != 0) {
_randomMax = max;
@@ -776,7 +761,7 @@ void GameCrimePatrol::rectStart(Rect *rect) {
_inMenu = false;
_fired = false;
_gameInProgress = true;
- if (_isDemo) {
+ if (_vm->isDemo()) {
_curScene = "scene39";
_gotTo[1] = 39;
} else {
@@ -956,7 +941,7 @@ void GameCrimePatrol::sceneNxtscnLoseALife(Scene *scene) {
if (!_debug_godMode) {
_lives--;
}
- if (_isDemo) {
+ if (_vm->isDemo()) {
_curScene = "scene39";
return;
} else if (_lives > 0) {
@@ -1092,7 +1077,7 @@ void GameCrimePatrol::sceneNxtscnSelectDeltaScenario(Scene *scene) {
}
void GameCrimePatrol::sceneNxtscnFinishGangFight(Scene *scene) {
- if (_isDemo) {
+ if (_vm->isDemo()) {
_curScene = _startScene;
return;
}
diff --git a/engines/alg/logic/game_crimepatrol.h b/engines/alg/logic/game_crimepatrol.h
index 178b75604ec..373a2d821d0 100644
--- a/engines/alg/logic/game_crimepatrol.h
+++ b/engines/alg/logic/game_crimepatrol.h
@@ -51,12 +51,12 @@ class GameCrimePatrol : public Game {
public:
GameCrimePatrol(AlgEngine *vm, const AlgGameDescription *gd);
- ~GameCrimePatrol();
- Common::Error run();
+ ~GameCrimePatrol() override;
+ void init() override;
void debugWarpTo(int val);
private:
- void init();
+ Common::Error run() override;
void registerScriptFunctions();
void verifyScriptFunctions();
CPScriptFunctionRect getScriptFunctionRectHit(Common::String name);
@@ -111,9 +111,9 @@ private:
const int16 _scenesLevel26[10] = {0x0157, 0x0159, 0x015B, 0x015D, 0x015F, 0x0161, 0x0163, 0x0165, 0x0167, 0};
const int16 *_levelScenes[27] = {_scenesLevel0, _scenesLevel1, _scenesLevel2, _scenesLevel3, _scenesLevel4, _scenesLevel5, _scenesLevel6,
- _scenesLevel7, _scenesLevel8, _scenesLevel9, _scenesLevel10, _scenesLevel11, _scenesLevel12, _scenesLevel13,
- _scenesLevel14, _scenesLevel15, _scenesLevel16, _scenesLevel17, _scenesLevel18, _scenesLevel19, _scenesLevel20,
- _scenesLevel21, _scenesLevel22, _scenesLevel23, _scenesLevel24, _scenesLevel25, _scenesLevel26};
+ _scenesLevel7, _scenesLevel8, _scenesLevel9, _scenesLevel10, _scenesLevel11, _scenesLevel12, _scenesLevel13,
+ _scenesLevel14, _scenesLevel15, _scenesLevel16, _scenesLevel17, _scenesLevel18, _scenesLevel19, _scenesLevel20,
+ _scenesLevel21, _scenesLevel22, _scenesLevel23, _scenesLevel24, _scenesLevel25, _scenesLevel26};
const int16 _diedScenesStage0[5] = {0x30, 0x31, 0x47, 0x51, 0};
const int16 _diedScenesStage1[7] = {0x5E, 0x5F, 0x7E, 0x7F, 0x98, 0x99, 0};
@@ -132,8 +132,6 @@ private:
const int16 _practiceTargetRight[5] = {0x0104, 0x6D, 0xCB, 0x95, 0x0104};
const int16 _practiceTargetBottom[5] = {0x3D, 0x79, 0x7B, 0xA1, 0xA1};
- bool _isDemo = 0;
-
// gamestate
uint16 _gotTo[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int8 _stage = 0;
@@ -168,7 +166,6 @@ private:
void displayShotFiredImage(Common::Point *point);
void enableVideoFadeIn();
uint16 sceneToNumber(Scene *scene);
- uint16 randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
uint16 pickRandomScene(uint8 index, uint8 max);
uint16 pickDeathScene();
void sceneNxtscnGeneric(uint8 index);
diff --git a/engines/alg/logic/game_drugwars.cpp b/engines/alg/logic/game_drugwars.cpp
index 4128429a8f8..3984c7bf27c 100644
--- a/engines/alg/logic/game_drugwars.cpp
+++ b/engines/alg/logic/game_drugwars.cpp
@@ -26,30 +26,40 @@
#include "graphics/cursorman.h"
-#include "alg/logic/game_drugwars.h"
#include "alg/graphics.h"
+#include "alg/logic/game_drugwars.h"
#include "alg/scene.h"
namespace Alg {
GameDrugWars::GameDrugWars(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
- if (gd->gameType == GType_DWARS_SS_DOS) {
- _libFileName = "dwss.lib";
- } else if (gd->gameType == GType_DWARS_DS_DOS) {
- _libFileName = "dwds.lib";
- } else if (gd->gameType == GType_DWARS_DEMO_DOS) {
- _libFileName = "dwdemo.lib";
- _isDemo = true;
- }
}
GameDrugWars::~GameDrugWars() {
- delete _shotIcon;
- delete _emptyIcon;
- delete _liveIcon;
- delete _deadIcon;
- delete _difficultyIcon;
- delete _bulletholeIcon;
+ if (_shotIcon) {
+ _shotIcon->free();
+ delete _shotIcon;
+ }
+ if (_emptyIcon) {
+ _emptyIcon->free();
+ delete _emptyIcon;
+ }
+ if (_liveIcon) {
+ _liveIcon->free();
+ delete _liveIcon;
+ }
+ if (_deadIcon) {
+ _deadIcon->free();
+ delete _deadIcon;
+ }
+ if (_difficultyIcon) {
+ _difficultyIcon->free();
+ delete _difficultyIcon;
+ }
+ if (_bulletholeIcon) {
+ _bulletholeIcon->free();
+ delete _bulletholeIcon;
+ }
}
void GameDrugWars::init() {
@@ -58,23 +68,24 @@ void GameDrugWars::init() {
_videoPosX = 11;
_videoPosY = 2;
- loadLibArchive(_libFileName);
+ if (_vm->isDemo()) {
+ loadLibArchive("dwdemo.lib");
+ } else if(_vm->useSingleSpeedVideos()) {
+ loadLibArchive("dwss.lib");
+ } else {
+ loadLibArchive("dwds.lib");
+ }
+
_sceneInfo->loadScnFile("dw.scn");
_startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
- _menuzone = new Zone();
- _menuzone->_name = "MainMenu";
- _menuzone->_ptrfb = "GLOBALHIT";
-
+ _menuzone = new Zone("MainMenu", "GLOBALHIT");
_menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
- _submenzone = new Zone();
- _submenzone->_name = "SubMenu";
- _submenzone->_ptrfb = "GLOBALHIT";
-
+ _submenzone = new Zone("SubMenu", "GLOBALHIT");
_submenzone->addRect(0x1C, 0x13, 0x5D, 0x22, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x1C, 0x33, 0x5D, 0x42, nullptr, 0, "RECTLOAD", "0");
_submenzone->addRect(0x1C, 0x53, 0x5D, 0x62, nullptr, 0, "RECTSAVE", "0");
@@ -171,9 +182,8 @@ void GameDrugWars::registerScriptFunctions() {
}
void GameDrugWars::verifyScriptFunctions() {
- Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
- for (size_t i = 0; i < scenes->size(); i++) {
- Scene *scene = (*scenes)[i];
+ auto scenes = _sceneInfo->getScenes();
+ for (auto scene : *scenes) {
getScriptFunctionScene(PREOP, scene->_preop);
getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
getScriptFunctionScene(INSOP, scene->_insop);
@@ -181,10 +191,9 @@ void GameDrugWars::verifyScriptFunctions() {
getScriptFunctionScene(SCNSCR, scene->_scnscr);
getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
getScriptFunctionScene(NXTSCN, scene->_nxtscn);
- for (size_t j = 0; j < scene->_zones.size(); j++) {
- Zone *zone = scene->_zones[j];
- for (size_t k = 0; k < zone->_rects.size(); k++) {
- getScriptFunctionRectHit(zone->_rects[k]._rectHit);
+ for (auto zone : scene->_zones) {
+ for (auto rect : zone->_rects) {
+ getScriptFunctionRectHit(rect->_rectHit);
}
}
}
@@ -347,7 +356,7 @@ Common::Error GameDrugWars::run() {
callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
if (_curScene == "") {
- _vm->quitGame();
+ shutdown();
}
}
return Common::kNoError;
@@ -442,7 +451,7 @@ void GameDrugWars::moveMouse() {
if (_inMenu) {
_whichGun = 3; // in menu cursor
} else {
- // disabled for now, because glitchy
+ // TODO: disabled for now, because glitchy
/*
uint16 x = _mousePos.x;
uint16 y = _mousePos.y;
@@ -595,30 +604,6 @@ uint16 GameDrugWars::sceneToNumber(Scene *scene) {
return atoi(scene->_name.substr(5).c_str());
}
-uint16 GameDrugWars::randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude) {
- if (max == 1) {
- return 0;
- }
- // reset mask if full
- uint16 fullMask = 0xFFFF >> (16 - max);
- if (*mask == fullMask) {
- *mask = 0;
- }
- uint16 randomNum = 0;
- // find an unused random number
- while (1) {
- randomNum = _rnd->getRandomNumber(max - 1);
- // check if bit is already used
- uint16 bit = 1 << randomNum;
- if (!((*mask & bit) || randomNum == exclude)) {
- // set the bit in mask
- *mask |= bit;
- break;
- }
- }
- return randomNum;
-}
-
uint16 GameDrugWars::pickRandomScene(uint8 index, uint8 max) {
if (_randomScenes[index] == nullptr) {
error("GameDrugWars::pickRandomScene(): called with illegal index: %d", index);
@@ -728,7 +713,7 @@ void GameDrugWars::rectStart(Rect *rect) {
_inMenu = false;
_fired = false;
_gameInProgress = true;
- if (_isDemo) {
+ if (_vm->isDemo()) {
_curScene = "scene54";
_gotToIndex = 1;
_gotTo[_gotToIndex] = 54;
@@ -821,7 +806,7 @@ void GameDrugWars::sceneNxtscnLoseALife(Scene *scene) {
if (!_debug_godMode) {
_lives--;
}
- if (_isDemo) {
+ if (_vm->isDemo()) {
_curScene = "scene83";
return;
} else if (_lives > 0) {
@@ -846,7 +831,7 @@ void GameDrugWars::sceneNxtscnKillInnocentMan(Scene *scene) {
if (!_debug_godMode) {
_lives--;
}
- if (_isDemo) {
+ if (_vm->isDemo()) {
sceneNxtscnAfterDie(scene);
return;
} else if (_lives > 0) {
@@ -862,7 +847,7 @@ void GameDrugWars::sceneNxtscnKillInnocentWoman(Scene *scene) {
}
void GameDrugWars::sceneNxtscnAfterDie(Scene *scene) {
- if (_isDemo) {
+ if (_vm->isDemo()) {
if (_gotTo[_gotToIndex] > 54) {
_curScene = "scene67";
} else {
@@ -955,7 +940,7 @@ void GameDrugWars::sceneNxtscnSelectScenario(Scene *scene) {
void GameDrugWars::sceneNxtscnFinishScenario(Scene *scene) {
uint16 picked = 0;
_gotTo[_gotToIndex] = 0;
- if (_isDemo) {
+ if (_vm->isDemo()) {
_curScene = _startScene;
return;
}
diff --git a/engines/alg/logic/game_drugwars.h b/engines/alg/logic/game_drugwars.h
index c8e978ad479..9e3776d4ddb 100644
--- a/engines/alg/logic/game_drugwars.h
+++ b/engines/alg/logic/game_drugwars.h
@@ -51,12 +51,12 @@ class GameDrugWars : public Game {
public:
GameDrugWars(AlgEngine *vm, const AlgGameDescription *gd);
- ~GameDrugWars();
- Common::Error run();
+ ~GameDrugWars() override;
+ Common::Error run() override;
void debugWarpTo(int val);
private:
- void init();
+ void init() override;
void registerScriptFunctions();
void verifyScriptFunctions();
DWScriptFunctionRect getScriptFunctionRectHit(Common::String name);
@@ -92,7 +92,7 @@ private:
const int16 _randomScenes12[10] = {0x014C, 0x014E, 0x0150, 0x0152, 0x0154, 0x0156, 0x0158, 0x015A, 0x015C, 0};
const int16 *_randomScenes[14] = {_randomScenes0, _randomScenes1, nullptr, nullptr, _randomScenes4, nullptr, nullptr, nullptr,
- _randomScenes8, _randomScenes9, _randomScenes10, _randomScenes11, _randomScenes12, nullptr};
+ _randomScenes8, _randomScenes9, _randomScenes10, _randomScenes11, _randomScenes12, nullptr};
const uint8 _randomScenesDifficulty[14] = {6, 4, 0, 0, 6, 0, 0, 0, 5, 6, 7, 8, 8, 0};
const uint16 _randomScenesContinue[14] = {0x51, 0x41, 0, 0, 0x01B5, 0, 0, 0, 0xCE, 0x0107, 0x0170, 0x011B, 0x015E, 0};
@@ -110,8 +110,6 @@ private:
const uint16 _scenarioStartScenes[14] = {0x27, 0x36, 0x4A, 0x57, 0x9D, 0x8B, 0x74, 0xD8, 0xBF, 0xB8, 0x0160, 0x010A, 0x0137, 0x017F};
- bool _isDemo = 0;
-
// gamestate
uint8 _continues = 0;
uint16 _gotTo[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -147,7 +145,6 @@ private:
void displayShotFiredImage(Common::Point *point);
void enableVideoFadeIn();
uint16 sceneToNumber(Scene *scene);
- uint16 randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
uint16 pickRandomScene(uint8 index, uint8 max);
uint16 pickDeathScene();
void sceneNxtscnGeneric(uint8 index);
diff --git a/engines/alg/logic/game_johnnyrock.cpp b/engines/alg/logic/game_johnnyrock.cpp
index e9029b7806a..03d69267ec3 100644
--- a/engines/alg/logic/game_johnnyrock.cpp
+++ b/engines/alg/logic/game_johnnyrock.cpp
@@ -26,24 +26,28 @@
#include "graphics/cursorman.h"
-#include "alg/logic/game_johnnyrock.h"
#include "alg/graphics.h"
+#include "alg/logic/game_johnnyrock.h"
#include "alg/scene.h"
namespace Alg {
GameJohnnyRock::GameJohnnyRock(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
- if (gd->gameType == GType_JOHNROC_SS_DOS) {
- _libFileName = "johnroc.lib";
- } else if (gd->gameType == GType_JOHNROC_DS_DOS) {
- _libFileName = "johnrocd.lib";
- }
}
GameJohnnyRock::~GameJohnnyRock() {
- delete _difficultyIcon;
- delete _levelIcon;
- delete _bulletholeIcon;
+ for (auto item : *_difficultyIcon) {
+ item->free();
+ delete item;
+ }
+ if (_levelIcon) {
+ _levelIcon->free();
+ delete _levelIcon;
+ }
+ if (_bulletholeIcon) {
+ _bulletholeIcon->free();
+ delete _bulletholeIcon;
+ }
}
void GameJohnnyRock::init() {
@@ -54,23 +58,22 @@ void GameJohnnyRock::init() {
setupCursorTimer();
- loadLibArchive(_libFileName);
+ if(_vm->useSingleSpeedVideos()) {
+ loadLibArchive("johnroc.lib");
+ } else {
+ loadLibArchive("johnrocd.lib");
+ }
+
_sceneInfo->loadScnFile("johnroc.scn");
_startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
- _menuzone = new Zone();
- _menuzone->_name = "MainMenu";
- _menuzone->_ptrfb = "GLOBALHIT";
-
+ _menuzone = new Zone("MainMenu", "GLOBALHIT");
_menuzone->addRect(0x0C, 0xBB, 0x3C, 0xC7, nullptr, 0, "SHOTMENU", "0");
- _submenzone = new Zone();
- _submenzone->_name = "SubMenu";
- _submenzone->_ptrfb = "GLOBALHIT";
-
+ _submenzone = new Zone("SubMenu", "GLOBALHIT");
_submenzone->addRect(0x10, 0x0F, 0x78, 0x34, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x10, 0x8E, 0x8A, 0xAF, nullptr, 0, "CONTMENU", "0");
_submenzone->addRect(0x10, 0x3A, 0x6A, 0x5C, nullptr, 0, "RECTSAVE", "0");
@@ -215,21 +218,18 @@ void GameJohnnyRock::registerScriptFunctions() {
}
void GameJohnnyRock::verifyScriptFunctions() {
- Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
- for (size_t i = 0; i < scenes->size(); i++) {
- Scene *scene = (*scenes)[i];
+ auto scenes = _sceneInfo->getScenes();
+ for (auto scene : *scenes) {
getScriptFunctionScene(PREOP, scene->_preop);
- // TODO: SHOWMSG
+ getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
getScriptFunctionScene(INSOP, scene->_insop);
getScriptFunctionScene(WEPDWN, scene->_wepdwn);
getScriptFunctionScene(SCNSCR, scene->_scnscr);
getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
getScriptFunctionScene(NXTSCN, scene->_nxtscn);
- for (size_t j = 0; j < scene->_zones.size(); j++) {
- Zone *zone = scene->_zones[j];
- getScriptFunctionZonePtrFb(zone->_ptrfb);
- for (size_t k = 0; k < zone->_rects.size(); k++) {
- getScriptFunctionRectHit(zone->_rects[k]._rectHit);
+ for (auto zone : scene->_zones) {
+ for (auto rect : zone->_rects) {
+ getScriptFunctionRectHit(rect->_rectHit);
}
}
}
@@ -403,7 +403,7 @@ Common::Error GameJohnnyRock::run() {
callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
if (_curScene == "") {
- _vm->quitGame();
+ shutdown();
}
}
removeCursorTimer();
diff --git a/engines/alg/logic/game_johnnyrock.h b/engines/alg/logic/game_johnnyrock.h
index 82de211c8ea..83423d462a8 100644
--- a/engines/alg/logic/game_johnnyrock.h
+++ b/engines/alg/logic/game_johnnyrock.h
@@ -53,12 +53,12 @@ class GameJohnnyRock : public Game {
public:
GameJohnnyRock(AlgEngine *vm, const AlgGameDescription *gd);
- ~GameJohnnyRock();
- Common::Error run();
+ ~GameJohnnyRock() override;
+ Common::Error run() override;
void debugWarpTo(int val);
private:
- void init();
+ void init() override;
void registerScriptFunctions();
void verifyScriptFunctions();
JRScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
@@ -87,17 +87,14 @@ private:
const int16 _randomRooftop[6] = {2, -4, 0x104, 0x1E, 0x100, 0x102};
const int16 _randomTheater[9] = {5, -5, 0x111, 0x1E, 0x107, 0x109, 0x10B, 0x10D, 0x10F};
const int16 _randomAlley[10] = {6, -4, 0, 0x1E, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D};
- const int16 _randomFuneral[10] = {6, -5, 0, 0x1E, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129};
const int16 _randomFuneralMR[10] = {6, -5, 0x12B, 0x1E, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129};
- const int16 _randomBook[7] = {3, 5, 0, 0x1E, 0x12E, 0x130, 0x132};
- const int16 _randomBookMR[8] = {4, 0x5, 0, 0x1E, 0x12E, 0x130, 0x132, 0x134};
+ const int16 _randomBookMR[8] = {4, 5, 0, 0x1E, 0x12E, 0x130, 0x132, 0x134};
const int16 _randomStairway[8] = {4, -3, 0, 0x1E, 0x139, 0x13B, 0x13D, 0x13F};
const int16 _randomHall[8] = {4, -5, 0, 0x1E, 0x141, 0x143, 0x145, 0x146};
const int16 _randomWindows[10] = {6, -3, 0, 0x1E, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E};
const int16 _randomCar[5] = {1, 1, 0, 0, 0x0FE};
const int16 _randomHall1[5] = {1, 1, 0, 0x1E, 0x148};
const int16 _randomElevator[5] = {1, 1, 0, 0, 0x14C};
- const int16 _randomElevatorMR[5] = {1, 1, 0, 0, 0x151};
const int16 _randomBaby[5] = {1, 1, 0, 0, 0x160};
const int16 *_randomPlaces[6] = {_randomWindows, _randomStairway, _randomCar, _randomHall1, _randomElevator, _randomBaby};
const int16 *_randomPlacesMR[8] = {_randomBookMR, _randomFuneralMR, _randomAlley, _randomTheater, _randomHall, _randomWindows, _randomHall1, _randomRooftop};
diff --git a/engines/alg/logic/game_maddog.cpp b/engines/alg/logic/game_maddog.cpp
index f18bd808ba0..06eb5d06ffc 100644
--- a/engines/alg/logic/game_maddog.cpp
+++ b/engines/alg/logic/game_maddog.cpp
@@ -26,25 +26,48 @@
#include "graphics/cursorman.h"
-#include "alg/logic/game_maddog.h"
#include "alg/graphics.h"
+#include "alg/logic/game_maddog.h"
#include "alg/scene.h"
namespace Alg {
GameMaddog::GameMaddog(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
- _libFileName = "maddog.lib";
}
GameMaddog::~GameMaddog() {
- delete _shotIcon;
- delete _emptyIcon;
- delete _liveIcon;
- delete _deadIcon;
- delete _reloadIcon;
- delete _drawIcon;
- delete _knifeIcon;
- delete _bulletholeIcon;
+ if (_shotIcon) {
+ _shotIcon->free();
+ delete _shotIcon;
+ }
+ if (_emptyIcon) {
+ _emptyIcon->free();
+ delete _emptyIcon;
+ }
+ if (_liveIcon) {
+ _liveIcon->free();
+ delete _liveIcon;
+ }
+ if (_deadIcon) {
+ _deadIcon->free();
+ delete _deadIcon;
+ }
+ if (_reloadIcon) {
+ _reloadIcon->free();
+ delete _reloadIcon;
+ }
+ if (_drawIcon) {
+ _drawIcon->free();
+ delete _drawIcon;
+ }
+ if (_knifeIcon) {
+ _knifeIcon->free();
+ delete _knifeIcon;
+ }
+ if (_bulletholeIcon) {
+ _bulletholeIcon->free();
+ delete _bulletholeIcon;
+ }
}
void GameMaddog::init() {
@@ -55,23 +78,19 @@ void GameMaddog::init() {
setupCursorTimer();
- loadLibArchive(_libFileName);
+ loadLibArchive("maddog.lib");
_sceneInfo->loadScnFile("maddog.scn");
_startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
- _menuzone = new Zone();
- _menuzone->_name = "MainMenu";
- _menuzone->_ptrfb = "GLOBALHIT";
+ _menuzone = new Zone("MainMenu", "GLOBALHIT");
_menuzone->addRect(0x0C, 0xAC, 0x3D, 0xBF, nullptr, 0, "SHOTMENU", "0");
_menuzone->addRect(0x00, 0xA6, 0x013F, 0xC7, nullptr, 0, "DEFAULT", "0"); // _mm_bott
_menuzone->addRect(0x00, 0x00, 0x3B, 0xC7, nullptr, 0, "DEFAULT", "0"); // _mm_left
- _submenzone = new Zone();
- _submenzone->_name = "SubMenu";
- _submenzone->_ptrfb = "GLOBALHIT";
+ _submenzone = new Zone("SubMenu", "GLOBALHIT");
_submenzone->addRect(0x8A, 0x3B, 0xC2, 0x48, nullptr, 0, "STARTBOT", "0");
_submenzone->addRect(0x8A, 0x4E, 0xC2, 0x59, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x8A, 0x60, 0xC2, 0x6B, nullptr, 0, "CONTMENU", "0");
@@ -216,21 +235,18 @@ void GameMaddog::registerScriptFunctions() {
}
void GameMaddog::verifyScriptFunctions() {
- Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
- for (size_t i = 0; i < scenes->size(); i++) {
- Scene *scene = (*scenes)[i];
+ auto scenes = _sceneInfo->getScenes();
+ for (auto scene : *scenes) {
getScriptFunctionScene(PREOP, scene->_preop);
- // TODO: SHOWMSG
+ getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
getScriptFunctionScene(INSOP, scene->_insop);
getScriptFunctionScene(WEPDWN, scene->_wepdwn);
getScriptFunctionScene(SCNSCR, scene->_scnscr);
getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
getScriptFunctionScene(NXTSCN, scene->_nxtscn);
- for (size_t j = 0; j < scene->_zones.size(); j++) {
- Zone *zone = scene->_zones[j];
- getScriptFunctionZonePtrFb(zone->_ptrfb);
- for (size_t k = 0; k < zone->_rects.size(); k++) {
- getScriptFunctionRectHit(zone->_rects[k]._rectHit);
+ for (auto zone : scene->_zones) {
+ for (auto rect : zone->_rects) {
+ getScriptFunctionRectHit(rect->_rectHit);
}
}
}
@@ -407,7 +423,7 @@ Common::Error GameMaddog::run() {
callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
if (_curScene == "") {
- _vm->quitGame();
+ shutdown();
}
}
removeCursorTimer();
diff --git a/engines/alg/logic/game_maddog.h b/engines/alg/logic/game_maddog.h
index 84546fe47c0..4309d78045c 100644
--- a/engines/alg/logic/game_maddog.h
+++ b/engines/alg/logic/game_maddog.h
@@ -58,7 +58,7 @@ public:
void debugWarpTo(int val);
private:
- void init();
+ void init() override;
void registerScriptFunctions();
void verifyScriptFunctions();
MDScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
diff --git a/engines/alg/logic/game_maddog2.cpp b/engines/alg/logic/game_maddog2.cpp
index 9f10d8362df..a0140714314 100644
--- a/engines/alg/logic/game_maddog2.cpp
+++ b/engines/alg/logic/game_maddog2.cpp
@@ -26,29 +26,48 @@
#include "graphics/cursorman.h"
-#include "alg/logic/game_maddog2.h"
#include "alg/graphics.h"
+#include "alg/logic/game_maddog2.h"
#include "alg/scene.h"
namespace Alg {
GameMaddog2::GameMaddog2(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
- if (gd->gameType == GType_MADDOG2_SS_DOS) {
- _libFileName = "maddog2.lib";
- } else if (gd->gameType == GType_MADDOG2_DS_DOS) {
- _libFileName = "maddog2d.lib";
- }
}
GameMaddog2::~GameMaddog2() {
- delete _shotIcon;
- delete _emptyIcon;
- delete _liveIcon;
- delete _deadIcon;
- delete _reloadIcon;
- delete _drawIcon;
- delete _knifeIcon;
- delete _bulletholeIcon;
+ if (_shotIcon) {
+ _shotIcon->free();
+ delete _shotIcon;
+ }
+ if (_emptyIcon) {
+ _emptyIcon->free();
+ delete _emptyIcon;
+ }
+ if (_liveIcon) {
+ _liveIcon->free();
+ delete _liveIcon;
+ }
+ if (_deadIcon) {
+ _deadIcon->free();
+ delete _deadIcon;
+ }
+ if (_reloadIcon) {
+ _reloadIcon->free();
+ delete _reloadIcon;
+ }
+ if (_drawIcon) {
+ _drawIcon->free();
+ delete _drawIcon;
+ }
+ if (_knifeIcon) {
+ _knifeIcon->free();
+ delete _knifeIcon;
+ }
+ if (_bulletholeIcon) {
+ _bulletholeIcon->free();
+ delete _bulletholeIcon;
+ }
}
void GameMaddog2::init() {
@@ -59,24 +78,23 @@ void GameMaddog2::init() {
setupCursorTimer();
- loadLibArchive(_libFileName);
+ if(_vm->useSingleSpeedVideos()) {
+ loadLibArchive("maddog2.lib");
+ } else {
+ loadLibArchive("maddog2d.lib");
+ }
+
_sceneInfo->loadScnFile("maddog2.scn");
_startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
- _menuzone = new Zone();
- _menuzone->_name = "MainMenu";
- _menuzone->_ptrfb = "GLOBALHIT";
-
+ _menuzone = new Zone("MainMenu", "GLOBALHIT");
_menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
_menuzone->addRect(0x08, 0xA9, 0x013C, 0xC7, nullptr, 0, "DEFAULT", "0"); // _mm_bott
- _submenzone = new Zone();
- _submenzone->_name = "SubMenu";
- _submenzone->_ptrfb = "GLOBALHIT";
-
+ _submenzone = new Zone("SubMenu", "GLOBALHIT");
_submenzone->addRect(0x2F, 0x16, 0x64, 0x2B, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x2F, 0xA0, 0x8D, 0xC7, nullptr, 0, "CONTMENU", "0");
_submenzone->addRect(0x2F, 0x40, 0x64, 0x54, nullptr, 0, "RECTSAVE", "0");
@@ -231,21 +249,18 @@ void GameMaddog2::registerScriptFunctions() {
}
void GameMaddog2::verifyScriptFunctions() {
- Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
- for (size_t i = 0; i < scenes->size(); i++) {
- Scene *scene = (*scenes)[i];
+ auto scenes = _sceneInfo->getScenes();
+ for (auto scene : *scenes) {
getScriptFunctionScene(PREOP, scene->_preop);
- // TODO: SHOWMSG
+ getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
getScriptFunctionScene(INSOP, scene->_insop);
getScriptFunctionScene(WEPDWN, scene->_wepdwn);
getScriptFunctionScene(SCNSCR, scene->_scnscr);
getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
getScriptFunctionScene(NXTSCN, scene->_nxtscn);
- for (size_t j = 0; j < scene->_zones.size(); j++) {
- Zone *zone = scene->_zones[j];
- getScriptFunctionZonePtrFb(zone->_ptrfb);
- for (size_t k = 0; k < zone->_rects.size(); k++) {
- getScriptFunctionRectHit(zone->_rects[k]._rectHit);
+ for (auto zone : scene->_zones) {
+ for (auto rect : zone->_rects) {
+ getScriptFunctionRectHit(rect->_rectHit);
}
}
}
@@ -419,7 +434,7 @@ Common::Error GameMaddog2::run() {
callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
if (_curScene == "") {
- _vm->quitGame();
+ shutdown();
}
}
removeCursorTimer();
@@ -496,11 +511,11 @@ void GameMaddog2::updateStat() {
if (_lives != _oldLives) {
if (_lives > _oldLives) {
for (uint8 i = _oldLives; i < _lives; i++) {
- AlgGraphics::drawImage(_screen, _liveIcon, _livepos[i][0], _livepos[i][1]);
+ AlgGraphics::drawImage(_screen, _liveIcon, _livePos[i][0], _livePos[i][1]);
}
} else {
for (uint8 i = _lives; i < _oldLives; i++) {
- AlgGraphics::drawImage(_screen, _deadIcon, _livepos[i][0], _livepos[i][1]);
+ AlgGraphics::drawImage(_screen, _deadIcon, _livePos[i][0], _livePos[i][1]);
}
}
_oldLives = _lives;
@@ -508,11 +523,11 @@ void GameMaddog2::updateStat() {
if (_shots != _oldShots) {
if (_shots > _oldShots) {
for (uint8 i = _oldShots; i < _shots; i++) {
- AlgGraphics::drawImage(_screen, _shotIcon, _shotpos[i][0], _shotpos[i][1]);
+ AlgGraphics::drawImage(_screen, _shotIcon, _shotPos[i][0], _shotPos[i][1]);
}
} else {
for (uint8 i = _shots; i < _oldShots; i++) {
- AlgGraphics::drawImage(_screen, _emptyIcon, _shotpos[i][0], _shotpos[i][1]);
+ AlgGraphics::drawImage(_screen, _emptyIcon, _shotPos[i][0], _shotPos[i][1]);
}
}
_oldShots = _shots;
@@ -532,7 +547,7 @@ void GameMaddog2::changeDifficulty(uint8 newDifficulty) {
void GameMaddog2::showDifficulty(uint8 newDifficulty, bool cursor) {
// reset menu screen
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
- AlgGraphics::drawImageCentered(_screen, _knifeIcon, _diffpos[newDifficulty - 1][0], _diffpos[newDifficulty - 1][1]);
+ AlgGraphics::drawImageCentered(_screen, _knifeIcon, _diffPos[newDifficulty - 1][0], _diffPos[newDifficulty - 1][1]);
if (cursor) {
updateCursor();
}
@@ -692,53 +707,30 @@ bool GameMaddog2::loadState() {
Common::String GameMaddog2::numToScene(int n) {
switch (n) {
case 1:
- return "scene1aa";
case 31:
- return "scen31a";
case 34:
- return "scen34a";
case 41:
- return "scen41a";
case 42:
- return "scen42a";
case 67:
- return "scen67a";
case 85:
- return "scen85a";
case 106:
- return "scen106a";
case 118:
- return "scen118a";
case 171:
- return "scen171a";
case 180:
- return "scen180a";
case 181:
- return "scen181a";
case 182:
- return "scen182a";
case 197:
- return "scen197a";
case 199:
- return "scen199a";
case 201:
- return "scen201a";
case 203:
- return "scen203a";
case 227:
- return "scen227a";
case 244:
- return "scen244a";
case 253:
- return "scen253a";
case 287:
- return "scen287a";
case 288:
- return "scen288a";
case 295:
- return "scen295a";
case 296:
- return "scen296a";
+ return Common::String::format("scen%da", n);
default:
return Common::String::format("scene%d", n);
}
@@ -775,7 +767,8 @@ uint16 GameMaddog2::die() {
updateStat();
uint8 randomNum = _rnd->getRandomNumber(9);
if (randomNum >= 4 && _lives >= 3) {
- return pickBits(&_dieBits, 6);
+ uint16 picked = pickBits(&_dieBits, 6);
+ return _dieScenes[picked];
}
if (_lives == 2) {
return 0x9D;
@@ -827,10 +820,10 @@ uint16 GameMaddog2::pickShootout() {
_lastPick = _lastShootOut;
if (_difficulty == 1) {
_lastShootOut = pickBits(&_shootOutBits, 5);
- return _ez_shoot_outs[_lastShootOut];
+ return _ezShootOuts[_lastShootOut];
} else {
_lastShootOut = pickBits(&_shootOutBits, 6);
- return _shoot_outs[_lastShootOut];
+ return _shootOuts[_lastShootOut];
}
}
@@ -843,18 +836,18 @@ void GameMaddog2::nextSB() {
} else {
_sbGotTo++;
}
- if (_sb_scenes[_sbGotTo] == 0x87) {
+ if (_sbScenes[_sbGotTo] == 0x87) {
_placeBits = 0;
_pickMask = 0;
ggPickMan();
// _scene_pso_fadein(cur_scene);
} else {
if (_sbGotTo == 7 || _sbGotTo == 9) {
- _curScene = numToScene(_sb_scenes[_sbGotTo]);
+ _curScene = numToScene(_sbScenes[_sbGotTo]);
} else {
_shootOutCnt++;
if (_shootOutCnt <= 3) {
- _curScene = numToScene(_sb_scenes[_sbGotTo]);
+ _curScene = numToScene(_sbScenes[_sbGotTo]);
// _scene_pso_fadein(cur_scene);
} else {
_shootoutFromDie = false;
@@ -873,18 +866,18 @@ void GameMaddog2::nextBB() {
} else {
_bbGotTo++;
}
- if (_bb_scenes[_bbGotTo] == 0x87) {
+ if (_bbScenes[_bbGotTo] == 0x87) {
_placeBits = 0;
_pickMask = 0;
ggPickMan();
// _scene_pso_fadein(cur_scene);
} else {
if (_bbGotTo == 7 || _bbGotTo == 9) {
- _curScene = numToScene(_bb_scenes[_bbGotTo]);
+ _curScene = numToScene(_bbScenes[_bbGotTo]);
} else {
_shootOutCnt++;
if (_shootOutCnt <= 3) {
- _curScene = numToScene(_bb_scenes[_bbGotTo]);
+ _curScene = numToScene(_bbScenes[_bbGotTo]);
// _scene_pso_fadein(cur_scene);
} else {
_shootoutFromDie = false;
@@ -903,22 +896,22 @@ void GameMaddog2::nextTP() {
} else {
_tpGotTo++;
}
- if (_tp_scenes[_tpGotTo] == 0xDC) {
+ if (_tpScenes[_tpGotTo] == 0xDC) {
_placeBits = 0;
_pickMask = 0;
}
- if (_tp_scenes[_tpGotTo] == 0x87) {
+ if (_tpScenes[_tpGotTo] == 0x87) {
_placeBits = 0;
_pickMask = 0;
ggPickMan();
// _scene_pso_fadein(cur_scene);
} else {
if (_tpGotTo == 7 || _tpGotTo == 9) {
- _curScene = numToScene(_tp_scenes[_tpGotTo]);
+ _curScene = numToScene(_tpScenes[_tpGotTo]);
} else {
_shootOutCnt++;
if (_shootOutCnt <= 3) {
- _curScene = numToScene(_tp_scenes[_tpGotTo]);
+ _curScene = numToScene(_tpScenes[_tpGotTo]);
// _scene_pso_fadein(cur_scene);
} else {
_shootoutFromDie = false;
@@ -933,7 +926,7 @@ void GameMaddog2::ggPickMan() {
uint8 totalRandom = ((_difficulty - 1) * 2) + 3;
if (_randomCount < totalRandom) {
uint16 index = pickBits(&_placeBits, 3);
- _curScene = numToScene(_gg_scenes[index]);
+ _curScene = numToScene(_ggScenes[index]);
} else {
_curScene = "scene139";
}
@@ -1052,12 +1045,12 @@ void GameMaddog2::rectSelectBeaver(Rect *rect) {
_thisGuide = 0;
_randomCount = 0;
_placeBits = 0;
- if (_sb_scenes[_sbGotTo] == 0x87) {
+ if (_sbScenes[_sbGotTo] == 0x87) {
_pickMask = 0;
ggPickMan();
// scene_pso_fadein(cur_scene);
} else {
- _curScene = numToScene(_sb_scenes[_sbGotTo]);
+ _curScene = numToScene(_sbScenes[_sbGotTo]);
// scene_pso_fadein(cur_scene);
}
}
@@ -1070,12 +1063,12 @@ void GameMaddog2::rectSelectBonnie(Rect *rect) {
_thisGuide = 1;
_randomCount = 0;
_placeBits = 0;
- if (_bb_scenes[_bbGotTo] == 0x87) {
+ if (_bbScenes[_bbGotTo] == 0x87) {
_pickMask = 0;
ggPickMan();
// scene_pso_fadein(cur_scene);
} else {
- _curScene = numToScene(_bb_scenes[_bbGotTo]);
+ _curScene = numToScene(_bbScenes[_bbGotTo]);
// scene_pso_fadein(cur_scene);
}
}
@@ -1088,12 +1081,12 @@ void GameMaddog2::rectSelectProfessor(Rect *rect) {
_thisGuide = 2;
_randomCount = 0;
_placeBits = 0;
- if (_tp_scenes[_tpGotTo] == 0x87) {
+ if (_tpScenes[_tpGotTo] == 0x87) {
_pickMask = 0;
ggPickMan();
// scene_pso_fadein(cur_scene);
} else {
- _curScene = numToScene(_tp_scenes[_tpGotTo]);
+ _curScene = numToScene(_tpScenes[_tpGotTo]);
// scene_pso_fadein(cur_scene);
}
}
@@ -1467,13 +1460,13 @@ void GameMaddog2::sceneNxtscnSelectGuide(Scene *scene) {
}
switch (_thisGuide) {
case 0:
- _curScene = numToScene(_sb_scenes[_sbGotTo]);
+ _curScene = numToScene(_sbScenes[_sbGotTo]);
break;
case 1:
- _curScene = numToScene(_bb_scenes[_bbGotTo]);
+ _curScene = numToScene(_bbScenes[_bbGotTo]);
break;
case 2:
- _curScene = numToScene(_tp_scenes[_tpGotTo]);
+ _curScene = numToScene(_tpScenes[_tpGotTo]);
break;
}
}
@@ -1488,21 +1481,21 @@ void GameMaddog2::sceneNxtscnFinishBonnie(Scene *scene) {
void GameMaddog2::sceneNxtscnShowGGClue(Scene *scene) {
_shootoutFromDie = false;
- _curScene = numToScene(_bb_clue[_whichGatlingGun]);
+ _curScene = numToScene(_bbClue[_whichGatlingGun]);
}
void GameMaddog2::sceneNxtscnBBAfterClue(Scene *scene) {
_shootoutFromDie = false;
_randomCount = 0;
_bbGotTo = 6;
- _curScene = numToScene(_bb_scenes[_bbGotTo]);
+ _curScene = numToScene(_bbScenes[_bbGotTo]);
}
void GameMaddog2::sceneNxtscnAsFarSheGoes(Scene *scene) {
_shootoutFromDie = false;
_randomCount = 0;
_gotTo = 12;
- _curScene = numToScene(_bb_scenes[_gotTo]);
+ _curScene = numToScene(_bbScenes[_gotTo]);
}
void GameMaddog2::sceneNxtscnSaveBeaver(Scene *scene) {
@@ -1515,21 +1508,21 @@ void GameMaddog2::sceneNxtscnFinishBeaver(Scene *scene) {
void GameMaddog2::sceneNxtscnToGatlingGunSBClue(Scene *scene) {
_shootoutFromDie = false;
- _curScene = numToScene(_sb_clue[_whichGatlingGun]);
+ _curScene = numToScene(_sbClue[_whichGatlingGun]);
}
void GameMaddog2::sceneNxtscnToGuideafterClue(Scene *scene) {
_shootoutFromDie = false;
_randomCount = 0;
_sbGotTo = 6;
- _curScene = numToScene(_sb_scenes[_sbGotTo]);
+ _curScene = numToScene(_sbScenes[_sbGotTo]);
}
void GameMaddog2::sceneNxtscnToGuideCave(Scene *scene) {
_shootoutFromDie = false;
_randomCount = 0;
_sbGotTo = 12;
- _gotTo = _sb_scenes[_sbGotTo];
+ _gotTo = _sbScenes[_sbGotTo];
_curScene = numToScene(_gotTo);
}
@@ -1538,7 +1531,7 @@ void GameMaddog2::sceneNxtscnInitRandomVillage(Scene *scene) {
_placeBits = 0;
_randomCount = 0;
int index = pickBits(&_placeBits, 6);
- _curScene = numToScene(_village_scenes[index]);
+ _curScene = numToScene(_villageScenes[index]);
}
void GameMaddog2::sceneNxtscnPickVillageScenes(Scene *scene) {
@@ -1546,7 +1539,7 @@ void GameMaddog2::sceneNxtscnPickVillageScenes(Scene *scene) {
uint8 totalRandom = ((_difficulty - 1) * 2) + 5;
if (_randomCount < totalRandom) {
int index = pickBits(&_placeBits, 6);
- _curScene = numToScene(_village_scenes[index]);
+ _curScene = numToScene(_villageScenes[index]);
} else {
_curScene = "scene100";
}
@@ -1562,21 +1555,21 @@ void GameMaddog2::sceneNxtscnFinishProfessor(Scene *scene) {
void GameMaddog2::sceneNxtscnToGatlingGunTPClue(Scene *scene) {
_shootoutFromDie = false;
- _curScene = numToScene(_tp_clue[_whichGatlingGun]);
+ _curScene = numToScene(_tpClue[_whichGatlingGun]);
}
void GameMaddog2::sceneNxtscnTPAfterClue(Scene *scene) {
_shootoutFromDie = false;
_randomCount = 0;
_tpGotTo = 6;
- _curScene = numToScene(_tp_scenes[_tpGotTo]);
+ _curScene = numToScene(_tpScenes[_tpGotTo]);
}
void GameMaddog2::sceneNxtscnFinishGatlingGun1(Scene *scene) {
_shootoutFromDie = false;
_randomCount = 0;
_tpGotTo = 12;
- _gotTo = _tp_scenes[_tpGotTo];
+ _gotTo = _tpScenes[_tpGotTo];
_curScene = numToScene(_gotTo);
}
@@ -1611,7 +1604,7 @@ void GameMaddog2::sceneNxtscnInitRandomCowboys(Scene *scene) {
_placeBits = 0;
_randomCount = 0;
uint16 picked = pickBits(&_placeBits, 7);
- _curScene = numToScene(_cowboy_scenes[picked]);
+ _curScene = numToScene(_cowboyScenes[picked]);
}
void GameMaddog2::sceneNxtscnToCowboyScenes(Scene *scene) {
@@ -1619,7 +1612,7 @@ void GameMaddog2::sceneNxtscnToCowboyScenes(Scene *scene) {
uint8 totalRandom = ((_difficulty - 1) * 2) + 7;
if (_randomCount < totalRandom) {
uint16 picked = pickBits(&_placeBits, 7);
- _curScene = numToScene(_cowboy_scenes[picked]);
+ _curScene = numToScene(_cowboyScenes[picked]);
} else {
genericNext();
}
@@ -1629,7 +1622,7 @@ void GameMaddog2::sceneNxtscnInitRandomFarmyard(Scene *scene) {
_placeBits = 0;
_randomCount = 0;
uint16 picked = pickBits(&_placeBits, 4);
- _curScene = numToScene(_farmyard_scenes[picked]);
+ _curScene = numToScene(_farmyardScenes[picked]);
}
void GameMaddog2::sceneNxtscnToFarmyardScenes(Scene *scene) {
@@ -1637,7 +1630,7 @@ void GameMaddog2::sceneNxtscnToFarmyardScenes(Scene *scene) {
uint8 totalRandom = ((_difficulty - 1) * 2) + 5;
if (_randomCount < totalRandom) {
uint16 picked = pickBits(&_placeBits, 4);
- _curScene = numToScene(_farmyard_scenes[picked]);
+ _curScene = numToScene(_farmyardScenes[picked]);
} else {
genericNext();
}
@@ -1647,7 +1640,7 @@ void GameMaddog2::sceneNxtscnInitRandomCave(Scene *scene) {
_placeBits = 0;
_randomCount = 0;
uint16 picked = pickBits(&_placeBits, 5);
- _curScene = numToScene(_cave_scenes[picked]);
+ _curScene = numToScene(_caveScenes[picked]);
}
void GameMaddog2::sceneNxtscnToCaveScenes(Scene *scene) {
@@ -1655,7 +1648,7 @@ void GameMaddog2::sceneNxtscnToCaveScenes(Scene *scene) {
uint8 totalRandom = ((_difficulty - 1) * 2) + 8;
if (_randomCount < totalRandom) {
uint16 picked = pickBits(&_placeBits, 5);
- _curScene = numToScene(_cave_scenes[picked]);
+ _curScene = numToScene(_caveScenes[picked]);
} else {
_gotTo = 0xEE;
_curScene = numToScene(_gotTo);
diff --git a/engines/alg/logic/game_maddog2.h b/engines/alg/logic/game_maddog2.h
index 372ef6c03b7..7497c4007c2 100644
--- a/engines/alg/logic/game_maddog2.h
+++ b/engines/alg/logic/game_maddog2.h
@@ -53,12 +53,12 @@ class GameMaddog2 : public Game {
public:
GameMaddog2(AlgEngine *vm, const AlgGameDescription *gd);
- ~GameMaddog2();
- Common::Error run();
+ ~GameMaddog2() override;
+ Common::Error run() override;
void debugWarpTo(int val);
private:
- void init();
+ void init() override;
void registerScriptFunctions();
void verifyScriptFunctions();
MD2ScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
@@ -89,27 +89,26 @@ private:
Graphics::Surface *_bulletholeIcon;
// constants
- const int16 _sb_clue[3] = {0x67, 0x68, 0x69};
- const int16 _bb_clue[3] = {0x47, 0x49, 0x48};
- const int16 _tp_clue[3] = {0x84, 0x85, 0x86};
- const int16 _sb_scenes[14] = {0x4A, 0x50, 0xB8, 0x55, 0x57, 0x66, 0xBE, 0x94, 0x87, 0x93, 0xCD, 0x95, 0xE3, -1};
- const int16 _bb_scenes[14] = {0x33, 0x39, 0xB4, 0x41, 0x43, 0x46, 0xA2, 0x8D, 0x87, 0x8F, 0xCD, 0x8E, 0xE3, -1};
- const int16 _tp_scenes[14] = {0x6A, 0xC3, 0x76, 0x81, 0xAD, 0x83, 0xDC, 0x92, 0x87, 0x90, 0xCD, 0x91, 0xE3, -1};
- const int16 _village_scenes[6] = {0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62};
- const int16 _cowboy_scenes[7] = {0xCD, 0xCF, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA};
- const int16 _farmyard_scenes[4] = {0xDC, 0xDE, 0x129, 0xE1};
- const int16 _cave_scenes[5] = {0xE4, 0xE6, 0xE8, 0xEA, 0xEC};
- const int16 _ez_shoot_outs[5] = {0xAB, 0xBC, 0xC5, 0xC7, 0xCB};
- const int16 _shoot_outs[6] = {0xAB, 0xBC, 0xC5, 0xC7, 0xC9, 0xCB};
- const int16 _gg_scenes[3] = {0x87, 0x88, 0x89};
- const int16 _die_scenes[6] = {0x96, 0x97, 0x98, 0x9B, 0x9F, 0xA1};
+ const int16 _sbClue[3] = {0x67, 0x68, 0x69};
+ const int16 _bbClue[3] = {0x47, 0x49, 0x48};
+ const int16 _tpClue[3] = {0x84, 0x85, 0x86};
+ const int16 _sbScenes[14] = {0x4A, 0x50, 0xB8, 0x55, 0x57, 0x66, 0xBE, 0x94, 0x87, 0x93, 0xCD, 0x95, 0xE3, -1};
+ const int16 _bbScenes[14] = {0x33, 0x39, 0xB4, 0x41, 0x43, 0x46, 0xA2, 0x8D, 0x87, 0x8F, 0xCD, 0x8E, 0xE3, -1};
+ const int16 _tpScenes[14] = {0x6A, 0xC3, 0x76, 0x81, 0xAD, 0x83, 0xDC, 0x92, 0x87, 0x90, 0xCD, 0x91, 0xE3, -1};
+ const int16 _villageScenes[6] = {0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62};
+ const int16 _cowboyScenes[7] = {0xCD, 0xCF, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA};
+ const int16 _farmyardScenes[4] = {0xDC, 0xDE, 0x129, 0xE1};
+ const int16 _caveScenes[5] = {0xE4, 0xE6, 0xE8, 0xEA, 0xEC};
+ const int16 _ezShootOuts[5] = {0xAB, 0xBC, 0xC5, 0xC7, 0xCB};
+ const int16 _shootOuts[6] = {0xAB, 0xBC, 0xC5, 0xC7, 0xC9, 0xCB};
+ const int16 _ggScenes[3] = {0x87, 0x88, 0x89};
+ const int16 _dieScenes[6] = {0x96, 0x97, 0x98, 0x9B, 0x9F, 0xA1};
- const uint16 _diffpos[3][2] = {{0x0FA, 0x6E}, {0xFA, 0x8E}, {0xFA, 0xAF}};
- const uint16 _livepos[3][2] = {{0x81, 0xBE}, {0x70, 0xBE}, {0x5F, 0xBE}};
- const uint16 _shotpos[12][2] = {{0x96, 0xBD}, {0x9A, 0xBD}, {0x9E, 0xBD}, {0x0A2, 0xBD}, {0x0A6, 0xBD}, {0x0AA, 0xBD}, {0x0AE, 0xBD}, {0x0B2, 0xBD}, {0x0B6, 0xBD}, {0x0BA, 0xBD}, {0x0BE, 0xBD}, {0x0C2, 0xBD}};
+ const uint16 _diffPos[3][2] = {{0x0FA, 0x6E}, {0xFA, 0x8E}, {0xFA, 0xAF}};
+ const uint16 _livePos[3][2] = {{0x81, 0xBE}, {0x70, 0xBE}, {0x5F, 0xBE}};
+ const uint16 _shotPos[12][2] = {{0x96, 0xBD}, {0x9A, 0xBD}, {0x9E, 0xBD}, {0x0A2, 0xBD}, {0x0A6, 0xBD}, {0x0AA, 0xBD}, {0x0AE, 0xBD}, {0x0B2, 0xBD}, {0x0B6, 0xBD}, {0x0BA, 0xBD}, {0x0BE, 0xBD}, {0x0C2, 0xBD}};
// gamestate
- uint16 _beenTo = 0;
uint16 _dieBits = 0;
uint16 _gotTo = 0;
uint16 _sbGotTo = 0;
diff --git a/engines/alg/logic/game_spacepirates.cpp b/engines/alg/logic/game_spacepirates.cpp
index c3ce32c0cb9..b166e1abe9d 100644
--- a/engines/alg/logic/game_spacepirates.cpp
+++ b/engines/alg/logic/game_spacepirates.cpp
@@ -26,32 +26,44 @@
#include "graphics/cursorman.h"
-#include "alg/logic/game_spacepirates.h"
#include "alg/graphics.h"
+#include "alg/logic/game_spacepirates.h"
#include "alg/scene.h"
namespace Alg {
GameSpacePirates::GameSpacePirates(AlgEngine *vm, const AlgGameDescription *gd) : Game(vm) {
- if (gd->gameType == GType_SPIRATES_SS_DOS) {
- _libFileName = "spss.lib";
- } else if (gd->gameType == GType_SPIRATES_DS_DOS) {
- _libFileName = "spds.lib";
- } else if (gd->gameType == GType_SPIRATES_DEMO_DOS) {
- _libFileName = "sp.lib";
- _isDemo = true;
- }
}
GameSpacePirates::~GameSpacePirates() {
- delete _shotIcon;
- delete _emptyIcon;
- delete _deadIcon;
- delete _liveIcon1;
- delete _liveIcon2;
- delete _liveIcon3;
- delete _difficultyIcon;
- delete _bulletholeIcon;
+ if (_shotIcon) {
+ _shotIcon->free();
+ delete _shotIcon;
+ }
+ if (_emptyIcon) {
+ _emptyIcon->free();
+ delete _emptyIcon;
+ }
+ if (_deadIcon) {
+ _deadIcon->free();
+ delete _deadIcon;
+ }
+ if (_liveIcon1) {
+ _liveIcon1->free();
+ delete _liveIcon1;
+ }
+ if (_liveIcon2) {
+ _liveIcon2->free();
+ delete _liveIcon2;
+ }
+ if (_liveIcon3) {
+ _liveIcon3->free();
+ delete _liveIcon3;
+ }
+ if (_bulletholeIcon) {
+ _bulletholeIcon->free();
+ delete _bulletholeIcon;
+ }
}
void GameSpacePirates::init() {
@@ -64,23 +76,24 @@ void GameSpacePirates::init() {
_lives = 3;
_shots = 10;
- loadLibArchive(_libFileName);
- _sceneInfo->loadScnFile(_isDemo ? "spacepir.scn" : "sp.scn");
+ if (_vm->isDemo()) {
+ loadLibArchive("sp.lib");
+ } else if(_vm->useSingleSpeedVideos()) {
+ loadLibArchive("spss.lib");
+ } else {
+ loadLibArchive("spds.lib");
+ }
+
+ _sceneInfo->loadScnFile(_vm->isDemo() ? "spacepir.scn" : "sp.scn");
_startScene = _sceneInfo->getStartScene();
registerScriptFunctions();
verifyScriptFunctions();
- _menuzone = new Zone();
- _menuzone->_name = "MainMenu";
- _menuzone->_ptrfb = "GLOBALHIT";
-
+ _menuzone = new Zone("MainMenu", "GLOBALHIT");
_menuzone->addRect(0x0C, 0xAA, 0x38, 0xC7, nullptr, 0, "SHOTMENU", "0");
- _submenzone = new Zone();
- _submenzone->_name = "SubMenu";
- _submenzone->_ptrfb = "GLOBALHIT";
-
+ _submenzone = new Zone("SubMenu", "GLOBALHIT");
_submenzone->addRect(0x24, 0x16, 0x64, 0x26, nullptr, 0, "STARTMENU", "0");
_submenzone->addRect(0x24, 0x36, 0x64, 0x46, nullptr, 0, "RECTLOAD", "0");
_submenzone->addRect(0x24, 0x56, 0x64, 0x66, nullptr, 0, "RECTSAVE", "0");
@@ -239,9 +252,8 @@ void GameSpacePirates::registerScriptFunctions() {
}
void GameSpacePirates::verifyScriptFunctions() {
- Common::Array<Scene *> *scenes = _sceneInfo->getScenes();
- for (size_t i = 0; i < scenes->size(); i++) {
- Scene *scene = (*scenes)[i];
+ auto scenes = _sceneInfo->getScenes();
+ for (auto scene : *scenes) {
getScriptFunctionScene(PREOP, scene->_preop);
getScriptFunctionScene(SHOWMSG, scene->_scnmsg);
getScriptFunctionScene(INSOP, scene->_insop);
@@ -249,11 +261,9 @@ void GameSpacePirates::verifyScriptFunctions() {
getScriptFunctionScene(SCNSCR, scene->_scnscr);
getScriptFunctionScene(NXTFRM, scene->_nxtfrm);
getScriptFunctionScene(NXTSCN, scene->_nxtscn);
- getScriptFunctionScene(MISSEDRECTS, scene->_missedRects);
- for (size_t j = 0; j < scene->_zones.size(); j++) {
- Zone *zone = scene->_zones[j];
- for (size_t k = 0; k < zone->_rects.size(); k++) {
- getScriptFunctionRectHit(zone->_rects[k]._rectHit);
+ for (auto zone : scene->_zones) {
+ for (auto rect : zone->_rects) {
+ getScriptFunctionRectHit(rect->_rectHit);
}
}
}
@@ -412,7 +422,7 @@ Common::Error GameSpacePirates::run() {
callScriptFunctionScene(NXTSCN, scene->_nxtscn, scene);
}
if (_curScene == "") {
- _vm->quitGame();
+ shutdown();
}
}
return Common::kNoError;
@@ -538,7 +548,7 @@ void GameSpacePirates::moveMouse() {
if (_inMenu) {
_whichGun = 2; // in menu cursor
} else {
- // disabled for now, because glitchy
+ // TODO: disabled for now, because glitchy
/*
uint16 x = _mousePos.x;
uint16 y = _mousePos.y;
@@ -571,7 +581,7 @@ void GameSpacePirates::displayLivesLeft() {
int16 posY = 0x73;
int16 posX = 0x0130;
int16 margin = 14;
- if (_isDemo) {
+ if (_vm->isDemo()) {
posY = 0x68;
posX = 0x012F;
margin = 13;
@@ -889,7 +899,7 @@ void GameSpacePirates::rectStart(Rect *rect) {
_inMenu = false;
_fired = false;
_gameInProgress = true;
- _curScene = _isDemo ? "scene62" : "scene187";
+ _curScene = _vm->isDemo() ? "scene62" : "scene187";
resetParams();
newGame();
}
@@ -931,7 +941,7 @@ void GameSpacePirates::rectKillInnocentPerson(Rect *rect) {
}
_nextSceneFound = true;
_playerDied = true;
- if (_isDemo) {
+ if (_vm->isDemo()) {
_curScene = "scene185";
return;
}
@@ -1318,8 +1328,8 @@ void GameSpacePirates::sceneIsoPickAWorld(Scene *scene) {
uint8 world = 3;
for (size_t i = 0; i < zone->_rects.size(); i++) {
if (_worldDone[world]) {
- uint16 centerX = zone->_rects[i].left + (zone->_rects[i].width() / 2);
- uint16 centerY = zone->_rects[i].top + (zone->_rects[i].height() / 2);
+ uint16 centerX = zone->_rects[i]->left + (zone->_rects[i]->width() / 2);
+ uint16 centerY = zone->_rects[i]->top + (zone->_rects[i]->height() / 2);
AlgGraphics::drawImageCentered(_videoDecoder->getVideoFrame(), (*_gun)[2], centerX - 16, centerY - 24);
}
world--;
@@ -1372,13 +1382,13 @@ void GameSpacePirates::sceneNxtscnPlayerDied(Scene *scene) {
_lives--;
}
if (_lives > 0) {
- if (_isDemo) {
+ if (_vm->isDemo()) {
picked = 178;
} else {
picked = randomNumberInRange(0xB2, 0xB4);
}
} else {
- if (_isDemo) {
+ if (_vm->isDemo()) {
picked = 172;
} else {
uint8 randomNum = _rnd->getRandomNumber(9);
diff --git a/engines/alg/logic/game_spacepirates.h b/engines/alg/logic/game_spacepirates.h
index a6761bac07b..99fb188b433 100644
--- a/engines/alg/logic/game_spacepirates.h
+++ b/engines/alg/logic/game_spacepirates.h
@@ -52,12 +52,12 @@ class GameSpacePirates : public Game {
public:
GameSpacePirates(AlgEngine *vm, const AlgGameDescription *gd);
- ~GameSpacePirates();
- Common::Error run();
+ ~GameSpacePirates() override;
+ Common::Error run() override;
void debugWarpTo(int val);
private:
- void init();
+ void init() override;
void registerScriptFunctions();
void verifyScriptFunctions();
SPScriptFunctionRect getScriptFunctionRectHit(Common::String name);
@@ -87,8 +87,6 @@ private:
// constants
- bool _isDemo = 0;
-
// gamestate
bool _gameLoaded = false;
int8 _livesLoaded = 0;
diff --git a/engines/alg/metaengine.cpp b/engines/alg/metaengine.cpp
index e6172c14891..7183f392b53 100644
--- a/engines/alg/metaengine.cpp
+++ b/engines/alg/metaengine.cpp
@@ -19,17 +19,54 @@
*
*/
+#include "common/translation.h"
#include "engines/advancedDetector.h"
#include "alg/alg.h"
#include "alg/detection.h"
+namespace Alg {
+
+static const ADExtraGuiOptionsMap optionsList[] = {
+ {
+ GAMEOPTION_SINGLE_SPEED_VERSION,
+ {
+ _s("Use lower quality single speed CD-ROM video"),
+ _s("These videos are of lower quality, the default version uses double speed CD-ROM videos which are of better quality"),
+ "single_speed_videos",
+ false,
+ 0,
+ 0
+ },
+ },
+ AD_EXTRA_GUI_OPTIONS_TERMINATOR
+};
+
+Common::Platform AlgEngine::getPlatform() const {
+ return _gameDescription->desc.platform;
+}
+
+bool AlgEngine::isDemo() const {
+ return (bool)(_gameDescription->desc.flags & ADGF_DEMO);
+}
+
+} // namespace Alg
+
class AlgMetaEngine : public AdvancedMetaEngine<Alg::AlgGameDescription> {
public:
const char *getName() const override {
return "alg";
}
+ const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override {
+ return Alg::optionsList;
+ }
+
+ bool hasFeature(MetaEngineFeature f) const override {
+ return
+ (f == kSimpleSavesNames);
+ }
+
Common::Error createInstance(OSystem *syst, Engine **engine, const Alg::AlgGameDescription *gd) const override;
};
diff --git a/engines/alg/scene.cpp b/engines/alg/scene.cpp
index 3dc9781b293..4bd10bca319 100644
--- a/engines/alg/scene.cpp
+++ b/engines/alg/scene.cpp
@@ -31,6 +31,12 @@ SceneInfo::SceneInfo() {
}
SceneInfo::~SceneInfo() {
+ for (auto scene : _scenes) {
+ delete scene;
+ }
+ for (auto zone : _zones) {
+ delete zone;
+ }
_scenes.clear();
_zones.clear();
}
@@ -49,8 +55,8 @@ void SceneInfo::loadScnFile(const Common::Path &path) {
}
Common::StringTokenizer tokenizer(line, " ");
int8 token = getToken(_mainTokens, tokenizer.nextToken());
- uint32 startFrame, endFrame = 0;
- Common::String sceneName, zoneName = nullptr;
+ uint32 startFrame = 0, endFrame = 0;
+ Common::String sceneName = nullptr, zoneName = nullptr;
switch (token) {
case 0: // ;
break;
@@ -89,26 +95,7 @@ void SceneInfo::loadScnFile(const Common::Path &path) {
}
void SceneInfo::parseScene(Common::String sceneName, uint32 startFrame, uint32 endFrame) {
- Scene *scene = new Scene();
- scene->_preop = "DEFAULT";
- scene->_insop = "DEFAULT";
- scene->_scnmsg = "DEFAULT";
- scene->_wepdwn = "DEFAULT";
- scene->_scnscr = "DEFAULT";
- scene->_nxtfrm = "DEFAULT";
- scene->_nxtscn = "DEFAULT";
- scene->_missedRects = "DEFAULT";
- scene->_missedRects = "DEFAULT";
- scene->_scnscrParam = 0;
- scene->_dataParam1 = 0;
- scene->_dataParam2 = 0;
- scene->_dataParam3 = 0;
- scene->_dataParam4 = 0;
- scene->_dataParam5 = "";
- scene->_name = sceneName;
- scene->_startFrame = startFrame;
- scene->_endFrame = endFrame;
- scene->_difficultyMod = 0;
+ Scene *scene = new Scene(sceneName, startFrame, endFrame);
bool done = false;
while (_scnFile.pos() < _scnFile.size() && !done) {
Common::String line = _scnFile.readLine();
@@ -190,10 +177,7 @@ void SceneInfo::parseScene(Common::String sceneName, uint32 startFrame, uint32 e
}
void SceneInfo::parseZone(Common::String zoneName, uint32 startFrame, uint32 endFrame) {
- Zone *zone = new Zone();
- zone->_name = zoneName;
- zone->_startFrame = startFrame;
- zone->_endFrame = endFrame;
+ Zone *zone = new Zone(zoneName, startFrame, endFrame);
bool done = false;
while (_scnFile.pos() < _scnFile.size() && !done) {
Common::String line = _scnFile.readLine();
@@ -231,7 +215,7 @@ void SceneInfo::parseZone(Common::String zoneName, uint32 startFrame, uint32 end
rect->_score = atoi(tokenizer.nextToken().c_str());
rect->_rectHit = tokenizer.nextToken();
rect->_unknown = tokenizer.nextToken();
- zone->_rects.push_back(*rect);
+ zone->_rects.push_back(rect);
} else {
rect = new Rect();
rect->_isMoving = false;
@@ -243,7 +227,7 @@ void SceneInfo::parseZone(Common::String zoneName, uint32 startFrame, uint32 end
rect->_score = atoi(tokenizer.nextToken().c_str());
rect->_rectHit = tokenizer.nextToken();
rect->_unknown = tokenizer.nextToken();
- zone->_rects.push_back(*rect);
+ zone->_rects.push_back(rect);
}
} break;
case 4: // ;
@@ -300,6 +284,10 @@ void SceneInfo::addZonesToScenes() {
}
}
+void SceneInfo::addScene(Scene *scene) {
+ _scenes.push_back(scene);
+}
+
Zone *SceneInfo::findZone(Common::String zoneName) {
for (uint32 i = 0; i < _zones.size(); i++) {
if (_zones[i]->_name.equalsIgnoreCase(zoneName)) {
@@ -319,23 +307,6 @@ Scene *SceneInfo::findScene(Common::String sceneName) {
error("SceneInfo::findScene(): Cannot find scene %s", sceneName.c_str());
}
-void SceneInfo::addScene(Scene *scene) {
- _scenes.push_back(scene);
-}
-
-void Zone::addRect(int16 left, int16 top, int16 right, int16 bottom, Common::String scene, uint32 score, Common::String rectHit, Common::String unknown) {
- Rect *rect = new Rect();
- rect->left = left;
- rect->top = top;
- rect->right = right;
- rect->bottom = bottom;
- rect->_scene = scene;
- rect->_score = score;
- rect->_rectHit = rectHit;
- rect->_unknown = unknown;
- _rects.push_back(*rect);
-}
-
int8 SceneInfo::getToken(const struct TokenEntry *tokenList, Common::String token) {
for (int i = 0; tokenList[i].name != nullptr; i++) {
if (token == tokenList[i].name) {
@@ -362,4 +333,59 @@ bool SceneInfo::ignoreScriptLine(Common::String line) {
return false;
}
+Scene::Scene(Common::String name, uint32 startFrame, uint32 endFrame) {
+ _preop = "DEFAULT";
+ _insop = "DEFAULT";
+ _scnmsg = "DEFAULT";
+ _wepdwn = "DEFAULT";
+ _scnscr = "DEFAULT";
+ _nxtfrm = "DEFAULT";
+ _nxtscn = "DEFAULT";
+ _missedRects = "DEFAULT";
+ _missedRects = "DEFAULT";
+ _scnscrParam = 0;
+ _dataParam1 = 0;
+ _dataParam2 = 0;
+ _dataParam3 = 0;
+ _dataParam4 = 0;
+ _dataParam5 = "";
+ _name = name;
+ _startFrame = startFrame;
+ _endFrame = endFrame;
+ _difficultyMod = 0;
+}
+
+Scene::~Scene() {
+}
+
+Zone::Zone(Common::String name, Common::String ptrfb) {
+ _name = name;
+ _ptrfb = ptrfb;
+}
+
+Zone::Zone(Common::String name, uint32 startFrame, uint32 endFrame) {
+ _name = name;
+ _startFrame = startFrame;
+ _endFrame = endFrame;
+}
+
+Zone::~Zone() {
+ for (auto rect : _rects) {
+ delete rect;
+ }
+}
+
+void Zone::addRect(int16 left, int16 top, int16 right, int16 bottom, Common::String scene, uint32 score, Common::String rectHit, Common::String unknown) {
+ Rect *rect = new Rect();
+ rect->left = left;
+ rect->top = top;
+ rect->right = right;
+ rect->bottom = bottom;
+ rect->_scene = scene;
+ rect->_score = score;
+ rect->_rectHit = rectHit;
+ rect->_unknown = unknown;
+ _rects.push_back(rect);
+}
+
} // End of namespace Alg
diff --git a/engines/alg/scene.h b/engines/alg/scene.h
index 791e8787136..5084d71e838 100644
--- a/engines/alg/scene.h
+++ b/engines/alg/scene.h
@@ -87,17 +87,22 @@ public:
class Zone {
public:
+ Zone(Common::String name, uint32 startFrame, uint32 endFrame);
+ Zone(Common::String name, Common::String ptrfb);
+ ~Zone();
Common::String _name;
uint32 _startFrame;
uint32 _endFrame;
Common::String _ptrfb;
- Common::Array<Rect> _rects;
+ Common::Array<Rect *> _rects;
Common::String _next;
void addRect(int16 left, int16 top, int16 right, int16 bottom, Common::String scene, uint32 score, Common::String rectHit, Common::String unknown);
};
class Scene {
public:
+ Scene(Common::String name, uint32 startFrame, uint32 endFrame);
+ ~Scene();
Common::String _name;
uint32 _startFrame;
uint32 _endFrame;
diff --git a/engines/alg/video.cpp b/engines/alg/video.cpp
index 5c4ca822789..7967dc5e078 100644
--- a/engines/alg/video.cpp
+++ b/engines/alg/video.cpp
@@ -34,8 +34,13 @@ AlgVideoDecoder::AlgVideoDecoder() {
}
AlgVideoDecoder::~AlgVideoDecoder() {
- delete _frame;
- delete _audioStream;
+ if (_frame) {
+ _frame->free();
+ delete _frame;
+ }
+ if (_audioStream) {
+ delete _audioStream;
+ }
}
void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
@@ -70,7 +75,8 @@ void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
assert(typeInterHhv == 0x0f);
_currentChunk = 0;
_bytesLeft = _size - chunkSize - 6;
- if (_frame != nullptr) {
+ if (_frame) {
+ _frame->free();
delete _frame;
}
if (_audioStream != nullptr) {
@@ -81,6 +87,13 @@ void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
_audioStream = makePacketizedRawStream(8000, Audio::FLAG_UNSIGNED);
}
+void AlgVideoDecoder::setReadStream(Common::SeekableReadStream *stream) {
+ if (_stream) {
+ delete stream;
+ }
+ _stream = stream;
+}
+
void AlgVideoDecoder::skipNumberOfFrames(uint32 num) {
uint32 videoFramesSkipped = 0;
while (videoFramesSkipped < num && _bytesLeft > 0) {
diff --git a/engines/alg/video.h b/engines/alg/video.h
index 6fe7cccdcc7..b74b4ef6bfc 100644
--- a/engines/alg/video.h
+++ b/engines/alg/video.h
@@ -35,8 +35,8 @@ public:
void getNextFrame();
void loadVideoFromStream(uint32 offset);
void skipNumberOfFrames(uint32 num);
+ void setReadStream(Common::SeekableReadStream *stream);
bool isFinished() { return _bytesLeft == 0; }
- void setStream(Common::SeekableReadStream *stream) { _stream = stream; }
Audio::PacketizedAudioStream *getAudioStream() { return _audioStream; }
Graphics::Surface *getVideoFrame() { return _frame; }
void setPalette(uint8 *palette) { _palette = palette; }
Commit: 8537d9913fe12635ff773e3a2177d16f3ccd8f21
https://github.com/scummvm/scummvm/commit/8537d9913fe12635ff773e3a2177d16f3ccd8f21
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: Implement some fixes from review
Changed paths:
engines/alg/alg.h
engines/alg/detection.cpp
engines/alg/detection.h
engines/alg/detection_tables.h
engines/alg/game.cpp
engines/alg/logic/game_bountyhunter.cpp
engines/alg/logic/game_crimepatrol.cpp
engines/alg/logic/game_drugwars.cpp
engines/alg/logic/game_johnnyrock.cpp
engines/alg/logic/game_maddog.cpp
engines/alg/logic/game_maddog2.cpp
engines/alg/logic/game_spacepirates.cpp
diff --git a/engines/alg/alg.h b/engines/alg/alg.h
index 22a1292828a..b9055954446 100644
--- a/engines/alg/alg.h
+++ b/engines/alg/alg.h
@@ -60,14 +60,6 @@ private:
bool _useSingleSpeedVideos = false;
};
-class Console : public GUI::Debugger {
-public:
- Console(AlgEngine *vm) {
- }
- virtual ~Console(void) {
- }
-};
-
} // End of namespace Alg
#endif
diff --git a/engines/alg/detection.cpp b/engines/alg/detection.cpp
index 1899779d6f4..06c47e334de 100644
--- a/engines/alg/detection.cpp
+++ b/engines/alg/detection.cpp
@@ -45,7 +45,7 @@ static const DebugChannelDef debugFlagList[] = {
class AlgMetaEngineDetection : public AdvancedMetaEngineDetection<Alg::AlgGameDescription> {
public:
AlgMetaEngineDetection() : AdvancedMetaEngineDetection(Alg::gameDescriptions, algGames) {
- _guiOptions = GUIO1(GUIO_NOMIDI);
+ _guiOptions = GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES);
_maxScanDepth = 1;
}
diff --git a/engines/alg/detection.h b/engines/alg/detection.h
index a4de10363ed..a16c4ab069d 100644
--- a/engines/alg/detection.h
+++ b/engines/alg/detection.h
@@ -37,16 +37,11 @@ enum AlgGameType {
};
struct AlgGameDescription {
+ AD_GAME_DESCRIPTION_HELPERS(desc);
+
ADGameDescription desc;
uint8 gameType;
- uint32 sizeBuffer() const {
- return desc.sizeBuffer();
- }
-
- void *toBuffer(void *buffer) {
- return desc.toBuffer(buffer);
- }
};
#define GAMEOPTION_SINGLE_SPEED_VERSION GUIO_GAMEOPTIONS1
diff --git a/engines/alg/detection_tables.h b/engines/alg/detection_tables.h
index 11b887cc8de..c2caad8ecd2 100644
--- a/engines/alg/detection_tables.h
+++ b/engines/alg/detection_tables.h
@@ -31,7 +31,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
+ GUIO1(GAMEOPTION_SINGLE_SPEED_VERSION)
},
GType_CRIME_PATROL,
},
@@ -44,7 +44,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_DEMO,
- GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
+ GUIO0()
},
GType_CRIME_PATROL,
},
@@ -57,7 +57,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
+ GUIO1(GAMEOPTION_SINGLE_SPEED_VERSION)
},
GType_DRUG_WARS,
},
@@ -70,7 +70,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_DEMO,
- GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
+ GUIO0()
},
GType_DRUG_WARS,
},
@@ -83,7 +83,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
+ GUIO1(GAMEOPTION_SINGLE_SPEED_VERSION)
},
GType_WSJR,
},
@@ -96,7 +96,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_UNSTABLE,
- GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
+ GUIO0()
},
GType_LAST_BOUNTY_HUNTER,
},
@@ -109,7 +109,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_UNSTABLE | ADGF_DEMO,
- GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
+ GUIO1(GAMEOPTION_SINGLE_SPEED_VERSION)
},
GType_LAST_BOUNTY_HUNTER,
},
@@ -122,7 +122,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
+ GUIO0()
},
GType_MADDOG,
},
@@ -135,7 +135,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
+ GUIO1(GAMEOPTION_SINGLE_SPEED_VERSION)
},
GType_MADDOG2,
},
@@ -148,7 +148,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
- GUIO3(GUIO_NOMIDI, GUIO_NOSUBTITLES, GAMEOPTION_SINGLE_SPEED_VERSION)
+ GUIO1(GAMEOPTION_SINGLE_SPEED_VERSION)
},
GType_SPACE_PIRATES,
},
@@ -161,7 +161,7 @@ static const AlgGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_DEMO,
- GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES)
+ GUIO0()
},
GType_SPACE_PIRATES,
},
diff --git a/engines/alg/game.cpp b/engines/alg/game.cpp
index b3772d1ee55..fbe6366acc5 100644
--- a/engines/alg/game.cpp
+++ b/engines/alg/game.cpp
@@ -338,7 +338,7 @@ Audio::SeekableAudioStream *Game::loadSoundFile(const Common::Path &path) {
delete file;
return nullptr;
}
- return Audio::makeRawStream(new Common::SeekableSubReadStream(file, 0, file->size(), DisposeAfterUse::NO), 8000, Audio::FLAG_UNSIGNED, DisposeAfterUse::NO);
+ return Audio::makeRawStream(file, 8000, Audio::FLAG_UNSIGNED, DisposeAfterUse::NO);
}
void Game::playSound(Audio::SeekableAudioStream *stream) {
diff --git a/engines/alg/logic/game_bountyhunter.cpp b/engines/alg/logic/game_bountyhunter.cpp
index 02a833671a6..4bc65d90629 100644
--- a/engines/alg/logic/game_bountyhunter.cpp
+++ b/engines/alg/logic/game_bountyhunter.cpp
@@ -520,14 +520,13 @@ void GameBountyHunter::updateMouse() {
if (_playerGun[0] == 2 && _whichGun < 2) {
cursor = (*_shotgun)[_whichGun];
}
- CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 8;
uint16 hotspotY = (cursor->h / 2) + 8;
if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
+ CursorMan.replaceCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
diff --git a/engines/alg/logic/game_crimepatrol.cpp b/engines/alg/logic/game_crimepatrol.cpp
index 661253a450e..1a346111256 100644
--- a/engines/alg/logic/game_crimepatrol.cpp
+++ b/engines/alg/logic/game_crimepatrol.cpp
@@ -491,14 +491,13 @@ void GameCrimePatrol::updateCursor() {
void GameCrimePatrol::updateMouse() {
if (_oldWhichGun != _whichGun) {
Graphics::Surface *cursor = (*_gun)[_whichGun];
- CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 3;
uint16 hotspotY = (cursor->h / 2) + 3;
if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
+ CursorMan.replaceCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
diff --git a/engines/alg/logic/game_drugwars.cpp b/engines/alg/logic/game_drugwars.cpp
index 3984c7bf27c..b75db5a6fc8 100644
--- a/engines/alg/logic/game_drugwars.cpp
+++ b/engines/alg/logic/game_drugwars.cpp
@@ -434,14 +434,13 @@ void GameDrugWars::updateCursor() {
void GameDrugWars::updateMouse() {
if (_oldWhichGun != _whichGun) {
Graphics::Surface *cursor = (*_gun)[_whichGun];
- CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 3;
uint16 hotspotY = (cursor->h / 2) + 3;
if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
+ CursorMan.replaceCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
diff --git a/engines/alg/logic/game_johnnyrock.cpp b/engines/alg/logic/game_johnnyrock.cpp
index 03d69267ec3..026825f4ce9 100644
--- a/engines/alg/logic/game_johnnyrock.cpp
+++ b/engines/alg/logic/game_johnnyrock.cpp
@@ -595,14 +595,13 @@ void GameJohnnyRock::updateCursor() {
void GameJohnnyRock::updateMouse() {
if (_oldWhichGun != _whichGun) {
Graphics::Surface *cursor = (*_gun)[_whichGun];
- CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2);
uint16 hotspotY = (cursor->h / 2);
if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
+ CursorMan.replaceCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
diff --git a/engines/alg/logic/game_maddog.cpp b/engines/alg/logic/game_maddog.cpp
index 06eb5d06ffc..d9ffcbf546e 100644
--- a/engines/alg/logic/game_maddog.cpp
+++ b/engines/alg/logic/game_maddog.cpp
@@ -548,14 +548,13 @@ void GameMaddog::updateCursor() {
void GameMaddog::updateMouse() {
if (_oldWhichGun != _whichGun) {
Graphics::Surface *cursor = (*_gun)[_whichGun];
- CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2);
uint16 hotspotY = (cursor->h / 2);
if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
+ CursorMan.replaceCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
diff --git a/engines/alg/logic/game_maddog2.cpp b/engines/alg/logic/game_maddog2.cpp
index a0140714314..eb447c32862 100644
--- a/engines/alg/logic/game_maddog2.cpp
+++ b/engines/alg/logic/game_maddog2.cpp
@@ -560,14 +560,13 @@ void GameMaddog2::updateCursor() {
void GameMaddog2::updateMouse() {
if (_oldWhichGun != _whichGun) {
Graphics::Surface *cursor = (*_gun)[_whichGun];
- CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2);
uint16 hotspotY = (cursor->h / 2);
if (debugChannelSet(1, Alg::kAlgDebugGraphics)) {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
+ CursorMan.replaceCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
diff --git a/engines/alg/logic/game_spacepirates.cpp b/engines/alg/logic/game_spacepirates.cpp
index b166e1abe9d..196790875d5 100644
--- a/engines/alg/logic/game_spacepirates.cpp
+++ b/engines/alg/logic/game_spacepirates.cpp
@@ -528,7 +528,6 @@ void GameSpacePirates::updateCursor() {
void GameSpacePirates::updateMouse() {
if (_oldWhichGun != _whichGun) {
Graphics::Surface *cursor = (*_gun)[_whichGun];
- CursorMan.popAllCursors();
uint16 hotspotX = (cursor->w / 2) + 8;
uint16 hotspotY = (cursor->h / 2) + 10;
if (_whichGun == 2) {
@@ -538,7 +537,7 @@ void GameSpacePirates::updateMouse() {
cursor->drawLine(0, hotspotY, cursor->w, hotspotY, 1);
cursor->drawLine(hotspotX, 0, hotspotX, cursor->h, 1);
}
- CursorMan.pushCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
+ CursorMan.replaceCursor(cursor->getPixels(), cursor->w, cursor->h, hotspotX, hotspotY, 0);
CursorMan.showMouse(true);
_oldWhichGun = _whichGun;
}
Commit: a6366061c33d46185e4f19430537cdbe2e74818a
https://github.com/scummvm/scummvm/commit/a6366061c33d46185e4f19430537cdbe2e74818a
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: refactoring from PR feedback
Changed paths:
engines/alg/detection.cpp
engines/alg/game.cpp
engines/alg/graphics.cpp
engines/alg/logic/game_bountyhunter.cpp
engines/alg/video.cpp
engines/alg/video.h
diff --git a/engines/alg/detection.cpp b/engines/alg/detection.cpp
index 06c47e334de..c174f1ac242 100644
--- a/engines/alg/detection.cpp
+++ b/engines/alg/detection.cpp
@@ -27,20 +27,21 @@
#include "alg/detection_tables.h"
static const PlainGameDescriptor algGames[] = {
- { "cpatrol", "Crime Patrol" },
- { "dwars", "Drug Wars" },
- { "johnroc", "Who Shot Johnny Rock?" },
- { "lbhunter", "The Last Bounty Hunter" },
{ "maddog", "Mad Dog McCree" },
- { "maddog2", "Mad Dog II: The Lost Gold" },
+ { "johnroc", "Who Shot Johnny Rock?" },
{ "spirates", "Space Pirates" },
+ { "maddog2", "Mad Dog II: The Lost Gold" },
+ { "cpatrol", "Crime Patrol" },
+ { "dwars", "Crime Patrol 2: Drug Wars" },
+ { "lbhunter", "The Last Bounty Hunter" },
{ nullptr, nullptr }
};
static const DebugChannelDef debugFlagList[] = {
- {Alg::kAlgDebugGeneral, "general", "General"},
- {Alg::kAlgDebugGraphics, "graphics", "Graphics"},
- DEBUG_CHANNEL_END};
+ { Alg::kAlgDebugGeneral, "general", "General" },
+ { Alg::kAlgDebugGraphics, "graphics", "Graphics" },
+ DEBUG_CHANNEL_END
+};
class AlgMetaEngineDetection : public AdvancedMetaEngineDetection<Alg::AlgGameDescription> {
public:
diff --git a/engines/alg/game.cpp b/engines/alg/game.cpp
index fbe6366acc5..4d250799a97 100644
--- a/engines/alg/game.cpp
+++ b/engines/alg/game.cpp
@@ -65,30 +65,14 @@ Game::~Game() {
delete item;
}
}
- if (_saveSound != nullptr) {
- delete _saveSound;
- }
- if (_loadSound != nullptr) {
- delete _loadSound;
- }
- if (_easySound != nullptr) {
- delete _easySound;
- }
- if (_avgSound != nullptr) {
- delete _avgSound;
- }
- if (_hardSound != nullptr) {
- delete _hardSound;
- }
- if (_skullSound != nullptr) {
- delete _skullSound;
- }
- if (_shotSound != nullptr) {
- delete _shotSound;
- }
- if (_emptySound != nullptr) {
- delete _emptySound;
- }
+ delete _saveSound;
+ delete _loadSound;
+ delete _easySound;
+ delete _avgSound;
+ delete _hardSound;
+ delete _skullSound;
+ delete _shotSound;
+ delete _emptySound;
}
void Game::init() {
@@ -159,7 +143,7 @@ void Game::loadLibArchive(const Common::Path &path) {
_libFileEntries[entryName] = entryOffset;
}
_libFile.seek(0);
- _videoDecoder->setReadStream(_libFile.readStream(_libFile.size()));
+ _videoDecoder->setInputFile(&_libFile);
}
bool Game::loadScene(Scene *scene) {
@@ -338,7 +322,7 @@ Audio::SeekableAudioStream *Game::loadSoundFile(const Common::Path &path) {
delete file;
return nullptr;
}
- return Audio::makeRawStream(file, 8000, Audio::FLAG_UNSIGNED, DisposeAfterUse::NO);
+ return Audio::makeRawStream(file, 8000, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
}
void Game::playSound(Audio::SeekableAudioStream *stream) {
diff --git a/engines/alg/graphics.cpp b/engines/alg/graphics.cpp
index 30c585e8510..b26fc2932c2 100644
--- a/engines/alg/graphics.cpp
+++ b/engines/alg/graphics.cpp
@@ -49,9 +49,7 @@ Graphics::Surface *AlgGraphics::loadVgaBackground(const Common::Path &path, uint
}
Graphics::Surface *surface = new Graphics::Surface();
surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
- uint8 *pixels = new uint8[width * height]();
- vgaFile.read(pixels, width * height);
- surface->setPixels(pixels);
+ vgaFile.read(surface->getPixels(), width * height);
Common::Rect backgroundRect = Common::Rect(0, 0, width, height);
surface->flipVertical(backgroundRect);
vgaFile.close();
@@ -179,22 +177,7 @@ void AlgGraphics::drawImage(Graphics::Surface *dst, Graphics::Surface *src, int3
void AlgGraphics::drawImageCentered(Graphics::Surface *dst, Graphics::Surface *src, int32 x, int32 y) {
int32 dstX = x - (src->w / 2);
int32 dstY = y - (src->h / 2);
- Common::Rect subRect = Common::Rect(0, 0, src->w, src->h);
- if (dstX < 0) {
- subRect.left -= dstX;
- dstX = 0;
- }
- if (dstY < 0) {
- subRect.top -= dstY;
- dstY = 0;
- }
- if (dstX + src->w > dst->w) {
- subRect.right -= dstX + src->w - dst->w;
- }
- if (dstY + src->h > dst->h) {
- subRect.bottom -= dstY + src->h - dst->h;
- }
- dst->copyRectToSurfaceWithKey(src->getBasePtr(subRect.left, subRect.top), src->pitch, dstX, dstY, subRect.width(), subRect.height(), 0x00);
+ drawImage(dst, src, dstX, dstY);
}
} // End of namespace Alg
diff --git a/engines/alg/logic/game_bountyhunter.cpp b/engines/alg/logic/game_bountyhunter.cpp
index 4bc65d90629..f6a4d1295f1 100644
--- a/engines/alg/logic/game_bountyhunter.cpp
+++ b/engines/alg/logic/game_bountyhunter.cpp
@@ -88,9 +88,7 @@ GameBountyHunter::~GameBountyHunter() {
item->free();
delete item;
}
- if (_shotgunSound != nullptr) {
- delete _shotgunSound;
- }
+ delete _shotgunSound;
}
void GameBountyHunter::init() {
diff --git a/engines/alg/video.cpp b/engines/alg/video.cpp
index 7967dc5e078..fa819bd1b57 100644
--- a/engines/alg/video.cpp
+++ b/engines/alg/video.cpp
@@ -28,7 +28,6 @@
namespace Alg {
AlgVideoDecoder::AlgVideoDecoder() {
- _stream = nullptr;
_frame = nullptr;
_audioStream = nullptr;
}
@@ -44,24 +43,24 @@ AlgVideoDecoder::~AlgVideoDecoder() {
}
void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
- _stream->seek(offset);
- _size = _stream->readUint32LE();
+ _input->seek(offset);
+ _size = _input->readUint32LE();
_currentFrame = 0;
- uint16 chunkType = _stream->readUint16LE();
- uint32 chunkSize = _stream->readUint32LE();
- _numChunks = _stream->readUint16LE();
- _frameRate = _stream->readUint16LE();
- _videoMode = _stream->readUint16LE();
- _width = _stream->readUint16LE();
- _height = _stream->readUint16LE();
- uint16 typeRaw = _stream->readUint16LE();
- uint16 typeInter = _stream->readUint16LE();
- uint16 typeIntraHh = _stream->readUint16LE();
- uint16 typeInterHh = _stream->readUint16LE();
- uint16 typeIntraHhv = _stream->readUint16LE();
- uint16 typeInterHhv = _stream->readUint16LE();
+ uint16 chunkType = _input->readUint16LE();
+ uint32 chunkSize = _input->readUint32LE();
+ _numChunks = _input->readUint16LE();
+ _frameRate = _input->readUint16LE();
+ _videoMode = _input->readUint16LE();
+ _width = _input->readUint16LE();
+ _height = _input->readUint16LE();
+ uint16 typeRaw = _input->readUint16LE();
+ uint16 typeInter = _input->readUint16LE();
+ uint16 typeIntraHh = _input->readUint16LE();
+ uint16 typeInterHh = _input->readUint16LE();
+ uint16 typeIntraHhv = _input->readUint16LE();
+ uint16 typeInterHhv = _input->readUint16LE();
if (chunkSize == 0x18) {
- _audioType = _stream->readUint16LE();
+ _audioType = _input->readUint16LE();
}
assert(chunkType == 0x00);
assert(chunkSize == 0x16 || chunkSize == 0x18);
@@ -79,7 +78,7 @@ void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
_frame->free();
delete _frame;
}
- if (_audioStream != nullptr) {
+ if (_audioStream) {
delete _audioStream;
}
_frame = new Graphics::Surface();
@@ -87,18 +86,11 @@ void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
_audioStream = makePacketizedRawStream(8000, Audio::FLAG_UNSIGNED);
}
-void AlgVideoDecoder::setReadStream(Common::SeekableReadStream *stream) {
- if (_stream) {
- delete stream;
- }
- _stream = stream;
-}
-
void AlgVideoDecoder::skipNumberOfFrames(uint32 num) {
uint32 videoFramesSkipped = 0;
while (videoFramesSkipped < num && _bytesLeft > 0) {
- uint16 chunkType = _stream->readUint16LE();
- uint32 chunkSize = _stream->readUint32LE();
+ uint16 chunkType = _input->readUint16LE();
+ uint32 chunkSize = _input->readUint32LE();
_currentChunk++;
switch (chunkType) {
case MKTAG16(0x00, 0x08):
@@ -112,41 +104,41 @@ void AlgVideoDecoder::skipNumberOfFrames(uint32 num) {
_currentFrame++;
break;
}
- _stream->skip(chunkSize);
+ _input->skip(chunkSize);
_bytesLeft -= chunkSize + 6;
}
// find next keyframe
bool nextKeyframeFound = false;
while (!nextKeyframeFound && _bytesLeft > 0) {
- uint16 chunkType = _stream->readUint16LE();
- uint32 chunkSize = _stream->readUint32LE();
+ uint16 chunkType = _input->readUint16LE();
+ uint32 chunkSize = _input->readUint32LE();
_currentChunk++;
switch (chunkType) {
case MKTAG16(0x00, 0x08):
case MKTAG16(0x00, 0x0c):
case MKTAG16(0x00, 0x0e):
nextKeyframeFound = true;
- _stream->seek(-6, SEEK_CUR);
+ _input->seek(-6, SEEK_CUR);
break;
case MKTAG16(0x00, 0x05):
case MKTAG16(0x00, 0x0d):
case MKTAG16(0x00, 0x0f):
case MKTAG16(0x00, 0x02):
- _stream->skip(chunkSize);
+ _input->skip(chunkSize);
_bytesLeft -= chunkSize + 6;
videoFramesSkipped++;
_currentFrame++;
break;
default:
- _stream->skip(chunkSize);
+ _input->skip(chunkSize);
_bytesLeft -= chunkSize + 6;
}
}
}
void AlgVideoDecoder::readNextChunk() {
- uint16 chunkType = _stream->readUint16LE();
- uint32 chunkSize = _stream->readUint32LE();
+ uint16 chunkType = _input->readUint16LE();
+ uint32 chunkSize = _input->readUint32LE();
_currentChunk++;
switch (chunkType) {
case MKTAG16(0x00, 0x00):
@@ -190,7 +182,7 @@ void AlgVideoDecoder::readNextChunk() {
break;
case MKTAG16(0x00, 0x02):
warning("AlgVideoDecoder::readNextChunk(): raw video not supported");
- _stream->skip(chunkSize);
+ _input->skip(chunkSize);
break;
default:
error("AlgVideoDecoder::readNextChunk(): Unknown chunk encountered: %d", chunkType);
@@ -213,14 +205,14 @@ void AlgVideoDecoder::decodeIntraFrame(uint32 size, uint8 hh, uint8 hv) {
int32 runLength = 0;
uint8 readByte, color = 0;
while (bytesRemaining > 0) {
- readByte = _stream->readByte();
+ readByte = _input->readByte();
if (readByte & 0x80) {
runLength = 1;
color = readByte;
bytesRemaining--;
} else {
runLength = (readByte & 0x7F) + 2;
- color = _stream->readByte();
+ color = _input->readByte();
bytesRemaining -= 2;
}
while (runLength > 0) {
@@ -248,13 +240,13 @@ void AlgVideoDecoder::decodeIntraFrame(uint32 size, uint8 hh, uint8 hv) {
void AlgVideoDecoder::decodeInterFrame(uint32 size, uint8 hh, uint8 hv) {
uint32 bytesRead = 0;
uint16 length = 0, x = 0, y = 0, replacementBytesLeft = 0;
- replacementBytesLeft = _stream->readUint16LE();
+ replacementBytesLeft = _input->readUint16LE();
bytesRead += 2;
if (replacementBytesLeft == 0) {
- _stream->skip(size - 2);
+ _input->skip(size - 2);
return;
}
- Common::SeekableReadStream *replacement = _stream->readStream(replacementBytesLeft);
+ Common::SeekableReadStream *replacement = _input->readStream(replacementBytesLeft);
bytesRead += replacementBytesLeft;
while (replacementBytesLeft > 1) {
length = replacement->readByte();
@@ -269,7 +261,7 @@ void AlgVideoDecoder::decodeInterFrame(uint32 size, uint8 hh, uint8 hv) {
uint8 replaceArray = replacement->readByte();
for (uint8 j = 0x80; j > 0; j = j >> 1) {
if (replaceArray & j) {
- uint8 color = _stream->readByte();
+ uint8 color = _input->readByte();
bytesRead++;
_frame->setPixel(x, y, color);
if (hh) {
@@ -294,15 +286,15 @@ void AlgVideoDecoder::updatePalette(uint32 size, bool partial) {
uint32 bytesRead = 0;
uint16 start = 0, count = 256;
if (partial) {
- start = _stream->readUint16LE();
- count = _stream->readUint16LE();
+ start = _input->readUint16LE();
+ count = _input->readUint16LE();
bytesRead += 4;
}
uint16 paletteIndex = start * 3;
for (uint16 i = 0; i < count; i++) {
- uint8 r = _stream->readByte() * 4;
- uint8 g = _stream->readByte() * 4;
- uint8 b = _stream->readByte() * 4;
+ uint8 r = _input->readByte() * 4;
+ uint8 g = _input->readByte() * 4;
+ uint8 b = _input->readByte() * 4;
_palette[paletteIndex++] = r;
_palette[paletteIndex++] = g;
_palette[paletteIndex++] = b;
@@ -313,7 +305,7 @@ void AlgVideoDecoder::updatePalette(uint32 size, bool partial) {
void AlgVideoDecoder::readAudioData(uint32 size, uint16 rate) {
assert(_audioType == 21);
- _audioStream->queuePacket(_stream->readStream(size));
+ _audioStream->queuePacket(_input->readStream(size));
}
} // End of namespace Alg
diff --git a/engines/alg/video.h b/engines/alg/video.h
index b74b4ef6bfc..528b68cae94 100644
--- a/engines/alg/video.h
+++ b/engines/alg/video.h
@@ -23,6 +23,7 @@
#define ALG_VIDEO_H
#include "audio/audiostream.h"
+#include "common/file.h"
#include "common/stream.h"
#include "graphics/surface.h"
@@ -35,7 +36,7 @@ public:
void getNextFrame();
void loadVideoFromStream(uint32 offset);
void skipNumberOfFrames(uint32 num);
- void setReadStream(Common::SeekableReadStream *stream);
+ void setInputFile(Common::File *input) { _input = input; }
bool isFinished() { return _bytesLeft == 0; }
Audio::PacketizedAudioStream *getAudioStream() { return _audioStream; }
Graphics::Surface *getVideoFrame() { return _frame; }
@@ -46,7 +47,7 @@ public:
uint32 getCurrentFrame() { return _currentFrame; }
private:
- Common::SeekableReadStream *_stream;
+ Common::File *_input;
Graphics::Surface *_frame;
Audio::PacketizedAudioStream *_audioStream;
uint8 *_palette;
Commit: 3e03257b2b96600219d3c014d02ee7236ee2358e
https://github.com/scummvm/scummvm/commit/3e03257b2b96600219d3c014d02ee7236ee2358e
Author: loki (loki at localhost)
Date: 2025-04-10T22:50:44+02:00
Commit Message:
ALG: Video and graphics refactoring
Changed paths:
engines/alg/game.h
engines/alg/graphics.cpp
engines/alg/logic/game_bountyhunter.cpp
engines/alg/logic/game_crimepatrol.cpp
engines/alg/logic/game_drugwars.cpp
engines/alg/logic/game_johnnyrock.cpp
engines/alg/logic/game_maddog.cpp
engines/alg/logic/game_maddog2.cpp
engines/alg/logic/game_spacepirates.cpp
engines/alg/video.cpp
engines/alg/video.h
diff --git a/engines/alg/game.h b/engines/alg/game.h
index 5e5c672db05..d99228365c3 100644
--- a/engines/alg/game.h
+++ b/engines/alg/game.h
@@ -73,7 +73,6 @@ protected:
Audio::SeekableAudioStream *_emptySound = nullptr;
Audio::SoundHandle _sfxAudioHandle;
- Audio::SoundHandle _sceneAudioHandle;
Zone *_menuzone;
Zone *_submenzone;
diff --git a/engines/alg/graphics.cpp b/engines/alg/graphics.cpp
index b26fc2932c2..386ae9436a8 100644
--- a/engines/alg/graphics.cpp
+++ b/engines/alg/graphics.cpp
@@ -89,9 +89,7 @@ Common::Array<Graphics::Surface *> *AlgGraphics::loadAniImage(const Common::Path
aniImage->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
for (uint16 y = 0; y < height; y++) {
aniFile.skip(4);
- for (uint16 x = 0; x < width; x++) {
- aniImage->setPixel(x, y, aniFile.readByte());
- }
+ aniFile.read(aniImage->getBasePtr(0, y), width);
}
images->push_back(aniImage);
}
@@ -131,12 +129,9 @@ Common::Array<Graphics::Surface *> *AlgGraphics::loadScreenCoordAniImage(const C
}
offset = aniFile.readSint16LE();
dest = centerOffset + offset;
- for (uint16 i = 0; i < length; i++) {
- y = dest / renderTarget->w;
- x = dest - (y * renderTarget->w);
- renderTarget->setPixel(x, y, aniFile.readByte());
- dest++;
- }
+ y = dest / renderTarget->w;
+ x = dest - (y * renderTarget->w);
+ aniFile.read(renderTarget->getBasePtr(x, y), length);
}
Graphics::Surface *aniImage = new Graphics::Surface();
aniImage->create(96, 96, Graphics::PixelFormat::createFormatCLUT8());
diff --git a/engines/alg/logic/game_bountyhunter.cpp b/engines/alg/logic/game_bountyhunter.cpp
index f6a4d1295f1..2ba4b930a47 100644
--- a/engines/alg/logic/game_bountyhunter.cpp
+++ b/engines/alg/logic/game_bountyhunter.cpp
@@ -375,9 +375,6 @@ Common::Error GameBountyHunter::run() {
error("GameBountyHunter::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
_sceneSkipped = false;
- Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
- g_system->getMixer()->stopHandle(_sceneAudioHandle);
- g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
_nextFrameTime = getMsTime() + 100;
callScriptFunctionScene(PREOP, scene->_preop, scene);
@@ -434,9 +431,9 @@ Common::Error GameBountyHunter::run() {
displayShotsLeft(0);
moveMouse();
if (_pauseTime > 0) {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
} else {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
}
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
@@ -485,7 +482,7 @@ void GameBountyHunter::doMenu() {
updateCursor();
_inMenu = true;
moveMouse();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
while (_inMenu && !_vm->shouldQuit()) {
Common::Point firedCoords;
@@ -499,7 +496,7 @@ void GameBountyHunter::doMenu() {
g_system->delayMillis(15);
}
updateCursor();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
if (_hadPause) {
uint32 endTime = getMsTime();
uint32 timeDiff = endTime - startTime;
diff --git a/engines/alg/logic/game_crimepatrol.cpp b/engines/alg/logic/game_crimepatrol.cpp
index 1a346111256..a157e3c679a 100644
--- a/engines/alg/logic/game_crimepatrol.cpp
+++ b/engines/alg/logic/game_crimepatrol.cpp
@@ -324,9 +324,6 @@ Common::Error GameCrimePatrol::run() {
}
}
_sceneSkipped = false;
- Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
- g_system->getMixer()->stopHandle(_sceneAudioHandle);
- g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
_nextFrameTime = getMsTime() + 100;
callScriptFunctionScene(PREOP, scene->_preop, scene);
@@ -381,9 +378,9 @@ Common::Error GameCrimePatrol::run() {
displayShotsLeft();
moveMouse();
if (_pauseTime > 0) {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
} else {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
}
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
@@ -438,7 +435,7 @@ void GameCrimePatrol::doMenu() {
updateCursor();
_inMenu = true;
moveMouse();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
showDifficulty(_difficulty, false);
while (_inMenu && !_vm->shouldQuit()) {
@@ -456,7 +453,7 @@ void GameCrimePatrol::doMenu() {
g_system->delayMillis(15);
}
updateCursor();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
if (_hadPause) {
uint32 endTime = getMsTime();
uint32 timeDiff = endTime - startTime;
diff --git a/engines/alg/logic/game_drugwars.cpp b/engines/alg/logic/game_drugwars.cpp
index b75db5a6fc8..370fc14a437 100644
--- a/engines/alg/logic/game_drugwars.cpp
+++ b/engines/alg/logic/game_drugwars.cpp
@@ -268,9 +268,6 @@ Common::Error GameDrugWars::run() {
error("GameDrugWars::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
_sceneSkipped = false;
- Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
- g_system->getMixer()->stopHandle(_sceneAudioHandle);
- g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
_nextFrameTime = getMsTime() + 100;
callScriptFunctionScene(PREOP, scene->_preop, scene);
@@ -325,9 +322,9 @@ Common::Error GameDrugWars::run() {
displayShotsLeft();
moveMouse();
if (_pauseTime > 0) {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
} else {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
}
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
@@ -381,7 +378,7 @@ void GameDrugWars::doMenu() {
updateCursor();
_inMenu = true;
moveMouse();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
showDifficulty(_difficulty, false);
while (_inMenu && !_vm->shouldQuit()) {
@@ -399,7 +396,7 @@ void GameDrugWars::doMenu() {
g_system->delayMillis(15);
}
updateCursor();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
if (_hadPause) {
uint32 endTime = getMsTime();
uint32 timeDiff = endTime - startTime;
diff --git a/engines/alg/logic/game_johnnyrock.cpp b/engines/alg/logic/game_johnnyrock.cpp
index 026825f4ce9..201f6f2c998 100644
--- a/engines/alg/logic/game_johnnyrock.cpp
+++ b/engines/alg/logic/game_johnnyrock.cpp
@@ -318,9 +318,6 @@ Common::Error GameJohnnyRock::run() {
if (!loadScene(scene)) {
error("GameJohnnyRock::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
- Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
- g_system->getMixer()->stopHandle(_sceneAudioHandle);
- g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
_nextFrameTime = getMsTime() + 100;
callScriptFunctionScene(PREOP, scene->_preop, scene);
@@ -364,9 +361,9 @@ Common::Error GameJohnnyRock::run() {
displayScore();
moveMouse();
if (_pauseTime > 0) {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
} else {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
}
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
@@ -509,7 +506,7 @@ void GameJohnnyRock::doMenu() {
updateCursor();
_inMenu = true;
moveMouse();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
showDifficulty(_difficulty, false);
while (_inMenu && !_vm->shouldQuit()) {
@@ -528,7 +525,7 @@ void GameJohnnyRock::doMenu() {
g_system->delayMillis(15);
}
updateCursor();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
if (_hadPause) {
uint32 endTime = getMsTime();
uint32 timeDiff = endTime - startTime;
diff --git a/engines/alg/logic/game_maddog.cpp b/engines/alg/logic/game_maddog.cpp
index d9ffcbf546e..a8d1843bc69 100644
--- a/engines/alg/logic/game_maddog.cpp
+++ b/engines/alg/logic/game_maddog.cpp
@@ -338,9 +338,6 @@ Common::Error GameMaddog::run() {
if (!loadScene(scene)) {
error("GameMaddog::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
- Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
- g_system->getMixer()->stopHandle(_sceneAudioHandle);
- g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_nextFrameTime = getMsTime() + 100;
callScriptFunctionScene(PREOP, scene->_preop, scene);
_currentFrame = getFrame(scene);
@@ -384,9 +381,9 @@ Common::Error GameMaddog::run() {
displayScore();
moveMouse();
if (_pauseTime > 0) {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
} else {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
}
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
@@ -468,7 +465,7 @@ void GameMaddog::doMenu() {
updateCursor();
_inMenu = true;
moveMouse();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
showDifficulty(_difficulty, false);
while (_inMenu && !_vm->shouldQuit()) {
@@ -486,7 +483,7 @@ void GameMaddog::doMenu() {
g_system->delayMillis(15);
}
updateCursor();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
if (_hadPause) {
uint32 endTime = getMsTime();
uint32 timeDiff = endTime - startTime;
diff --git a/engines/alg/logic/game_maddog2.cpp b/engines/alg/logic/game_maddog2.cpp
index eb447c32862..a037cfa2ad0 100644
--- a/engines/alg/logic/game_maddog2.cpp
+++ b/engines/alg/logic/game_maddog2.cpp
@@ -348,9 +348,6 @@ Common::Error GameMaddog2::run() {
if (!loadScene(scene)) {
error("GameMaddog2::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
- Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
- g_system->getMixer()->stopHandle(_sceneAudioHandle);
- g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
_nextFrameTime = getMsTime() + 100;
callScriptFunctionScene(PREOP, scene->_preop, scene);
@@ -395,9 +392,9 @@ Common::Error GameMaddog2::run() {
displayScore();
moveMouse();
if (_pauseTime > 0) {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
} else {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
}
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
@@ -480,7 +477,7 @@ void GameMaddog2::doMenu() {
updateCursor();
_inMenu = true;
moveMouse();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
showDifficulty(_difficulty, false);
while (_inMenu && !_vm->shouldQuit()) {
@@ -498,7 +495,7 @@ void GameMaddog2::doMenu() {
g_system->delayMillis(15);
}
updateCursor();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
if (_hadPause) {
uint32 endTime = getMsTime();
uint32 timeDiff = endTime - startTime;
diff --git a/engines/alg/logic/game_spacepirates.cpp b/engines/alg/logic/game_spacepirates.cpp
index 196790875d5..d8b4430012c 100644
--- a/engines/alg/logic/game_spacepirates.cpp
+++ b/engines/alg/logic/game_spacepirates.cpp
@@ -341,9 +341,6 @@ Common::Error GameSpacePirates::run() {
error("GameSpacePirates::run(): Cannot find scene %s in libfile", scene->_name.c_str());
}
_nextSceneFound = false;
- Audio::PacketizedAudioStream *audioStream = _videoDecoder->getAudioStream();
- g_system->getMixer()->stopHandle(_sceneAudioHandle);
- g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_sceneAudioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
_paletteDirty = true;
_nextFrameTime = getMsTime() + 100;
callScriptFunctionScene(PREOP, scene->_preop, scene);
@@ -391,9 +388,9 @@ Common::Error GameSpacePirates::run() {
displayShotsLeft();
moveMouse();
if (_pauseTime > 0) {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
} else {
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
}
if (_videoDecoder->getCurrentFrame() == 0) {
_videoDecoder->getNextFrame();
@@ -470,7 +467,7 @@ void GameSpacePirates::doMenu() {
updateCursor();
_inMenu = true;
moveMouse();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, true);
+ _videoDecoder->pauseAudio(true);
_screen->copyRectToSurface(_background->getBasePtr(_videoPosX, _videoPosY), _background->pitch, _videoPosX, _videoPosY, _videoDecoder->getWidth(), _videoDecoder->getHeight());
showDifficulty(_difficulty, false);
while (_inMenu && !_vm->shouldQuit()) {
@@ -488,7 +485,7 @@ void GameSpacePirates::doMenu() {
g_system->delayMillis(15);
}
updateCursor();
- g_system->getMixer()->pauseHandle(_sceneAudioHandle, false);
+ _videoDecoder->pauseAudio(false);
if (_hadPause) {
uint32 endTime = getMsTime();
uint32 timeDiff = endTime - startTime;
diff --git a/engines/alg/video.cpp b/engines/alg/video.cpp
index fa819bd1b57..7322054dec6 100644
--- a/engines/alg/video.cpp
+++ b/engines/alg/video.cpp
@@ -84,6 +84,8 @@ void AlgVideoDecoder::loadVideoFromStream(uint32 offset) {
_frame = new Graphics::Surface();
_frame->create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
_audioStream = makePacketizedRawStream(8000, Audio::FLAG_UNSIGNED);
+ g_system->getMixer()->stopHandle(_audioHandle);
+ g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_audioHandle, _audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);
}
void AlgVideoDecoder::skipNumberOfFrames(uint32 num) {
@@ -215,24 +217,17 @@ void AlgVideoDecoder::decodeIntraFrame(uint32 size, uint8 hh, uint8 hv) {
color = _input->readByte();
bytesRemaining -= 2;
}
- while (runLength > 0) {
- if (color > 0) {
- _frame->setPixel(x, y, color);
- if (hh) {
- _frame->setPixel(x + 1, y, color);
- }
- if (hv) {
- _frame->setPixel(x, y + 1, color);
- _frame->setPixel(x + 1, y + 1, color);
- }
- }
- x += 1 + hh;
- runLength--;
- if (x >= _width) {
- x = 0;
- y += 1 + hv;
+ if (color > 0) {
+ memset(_frame->getBasePtr(x, y), color, runLength * (1 + hh));
+ if (hv) {
+ memset(_frame->getBasePtr(x, y + 1), color, runLength * (1 + hh));
}
}
+ x += runLength + (hh * runLength);
+ if (x >= _width) {
+ x = 0;
+ y += 1 + hv;
+ }
}
assert(bytesRemaining == 0);
}
@@ -263,13 +258,9 @@ void AlgVideoDecoder::decodeInterFrame(uint32 size, uint8 hh, uint8 hv) {
if (replaceArray & j) {
uint8 color = _input->readByte();
bytesRead++;
- _frame->setPixel(x, y, color);
- if (hh) {
- _frame->setPixel(x + 1, y, color);
- }
+ memset(_frame->getBasePtr(x, y), color, (1 + hh));
if (hv) {
- _frame->setPixel(x, y + 1, color);
- _frame->setPixel(x + 1, y + 1, color);
+ memset(_frame->getBasePtr(x, y + 1), color, (1 + hh));
}
}
x += 1 + hh;
diff --git a/engines/alg/video.h b/engines/alg/video.h
index 528b68cae94..5682c66b2bd 100644
--- a/engines/alg/video.h
+++ b/engines/alg/video.h
@@ -23,8 +23,11 @@
#define ALG_VIDEO_H
#include "audio/audiostream.h"
+#include "audio/mixer.h"
+
#include "common/file.h"
#include "common/stream.h"
+
#include "graphics/surface.h"
namespace Alg {
@@ -38,10 +41,10 @@ public:
void skipNumberOfFrames(uint32 num);
void setInputFile(Common::File *input) { _input = input; }
bool isFinished() { return _bytesLeft == 0; }
- Audio::PacketizedAudioStream *getAudioStream() { return _audioStream; }
Graphics::Surface *getVideoFrame() { return _frame; }
void setPalette(uint8 *palette) { _palette = palette; }
bool isPaletteDirty() { return _paletteDirty; }
+ void pauseAudio(bool pause) { g_system->getMixer()->pauseHandle(_audioHandle, pause); }
uint16 getWidth() { return _width; }
uint16 getHeight() { return _height; }
uint32 getCurrentFrame() { return _currentFrame; }
@@ -50,6 +53,7 @@ private:
Common::File *_input;
Graphics::Surface *_frame;
Audio::PacketizedAudioStream *_audioStream;
+ Audio::SoundHandle _audioHandle;
uint8 *_palette;
bool _paletteDirty;
bool _gotVideoFrame;
More information about the Scummvm-git-logs
mailing list