From c9186f51b9502a4cfb1881f2db4f92eeb6227144 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 6 Mar 2014 20:30:05 -0500 Subject: MADS: Added in Rex Nebular globals class --- engines/mads/game.cpp | 10 ++--- engines/mads/game.h | 7 +++- engines/mads/mads.cpp | 1 + engines/mads/mads.h | 1 + engines/mads/messages.cpp | 1 - engines/mads/module.mk | 1 + engines/mads/nebular/game_nebular.cpp | 71 ++++++++++++++++++-------------- engines/mads/nebular/game_nebular.h | 6 +++ engines/mads/nebular/globals_nebular.cpp | 51 +++++++++++++++++++++++ engines/mads/nebular/globals_nebular.h | 63 ++++++++++++++++++++++++++++ engines/mads/nebular/nebular_scenes.cpp | 3 ++ engines/mads/nebular/nebular_scenes.h | 14 +++++++ engines/mads/nebular/nebular_scenes1.cpp | 53 ++++++++++++++++++++++++ engines/mads/nebular/nebular_scenes1.h | 56 +++++++++++++++++++++++++ engines/mads/nebular/nebular_scenes8.cpp | 29 +++++++++++-- engines/mads/nebular/nebular_scenes8.h | 10 ++++- engines/mads/scene.cpp | 9 ++-- 17 files changed, 336 insertions(+), 50 deletions(-) create mode 100644 engines/mads/nebular/globals_nebular.cpp create mode 100644 engines/mads/nebular/globals_nebular.h create mode 100644 engines/mads/nebular/nebular_scenes1.cpp create mode 100644 engines/mads/nebular/nebular_scenes1.h (limited to 'engines/mads') diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index 025cf8d530..b64c59c986 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -66,14 +66,14 @@ Game::~Game() { } void Game::run() { + initialiseGlobals(); + _statusFlag = true; int protectionResult = checkCopyProtection(); switch (protectionResult) { case 1: // Copy protection failed _scene._nextSceneId = 804; - initialiseGlobals(); - _globalFlags[5] = 0xFFFF; _saveSlot = -1; break; case 2: @@ -253,11 +253,7 @@ void Game::sectionLoop() { // TODO: sub_1DD46(3) // Check whether to show a dialog - if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globalFlags[5]) { - _scene._spriteSlots.releasePlayerSprites(); - _vm->_dialogs->showDialog(); - _vm->_dialogs->_pendingDialog = DIALOG_NONE; - } + checkShowDialog(); } } diff --git a/engines/mads/game.h b/engines/mads/game.h index aa3c38596c..0cd46b6f7e 100644 --- a/engines/mads/game.h +++ b/engines/mads/game.h @@ -97,6 +97,12 @@ protected: * Set up the section handler specific to each section */ virtual void setSectionHandler() = 0; + + /** + * Checks for whether to show a dialog + */ + virtual void checkShowDialog() = 0; + //@} public: @@ -106,7 +112,6 @@ public: int _sectionNumber; int _priorSectionNumber; int _currentSectionNumber; - Common::Array _globalFlags; InventoryObjects _objects; Scene _scene; int _v2; diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp index fcf03952c7..c6d2e2ec26 100644 --- a/engines/mads/mads.cpp +++ b/engines/mads/mads.cpp @@ -42,6 +42,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) : _invObjectStill = false; _textWindowStill = false; _screenFade = SCREEN_FADE_FAST; + _musicFlag = false; _debugger = nullptr; _dialogs = nullptr; diff --git a/engines/mads/mads.h b/engines/mads/mads.h index abe6e790c2..2fbac32c4a 100644 --- a/engines/mads/mads.h +++ b/engines/mads/mads.h @@ -105,6 +105,7 @@ public: bool _invObjectStill; bool _textWindowStill; ScreenFade _screenFade; + bool _musicFlag; public: MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc); virtual ~MADSEngine(); diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp index 11db00f1b9..33a6a8ef6c 100644 --- a/engines/mads/messages.cpp +++ b/engines/mads/messages.cpp @@ -37,7 +37,6 @@ KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) { _entries.push_back(rec); } - scene._textSpacing = -1; _talkFont = _vm->_font->getFont(FONT_CONVERSATION); word_8469E = 0; } diff --git a/engines/mads/module.mk b/engines/mads/module.mk index 7197a60955..2f4982f9f8 100644 --- a/engines/mads/module.mk +++ b/engines/mads/module.mk @@ -3,6 +3,7 @@ MODULE := engines/mads MODULE_OBJS := \ nebular/dialogs_nebular.o \ nebular/game_nebular.o \ + nebular/globals_nebular.o \ nebular/sound_nebular.o \ nebular/nebular_scenes.o \ nebular/nebular_scenes8.o \ diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp index c55abf5601..c18561bac0 100644 --- a/engines/mads/nebular/game_nebular.cpp +++ b/engines/mads/nebular/game_nebular.cpp @@ -28,6 +28,7 @@ #include "mads/msurface.h" #include "mads/nebular/game_nebular.h" #include "mads/nebular/dialogs_nebular.h" +#include "mads/nebular/globals_nebular.h" namespace MADS { @@ -38,6 +39,9 @@ GameNebular::GameNebular(MADSEngine *vm): Game(vm) { } int GameNebular::checkCopyProtection() { + // DEBUG: Flag copy protection failure + _globals[5] = 0xFFFF; + if (!ConfMan.getBool("copy_protection")) return true; @@ -52,32 +56,27 @@ int GameNebular::checkCopyProtection() { } void GameNebular::initialiseGlobals() { - // Allocate globals space - _globalFlags.resize(210); - for (int i = 0; i < 210; ++i) - _globalFlags[i] = 0; - // Set specific values needed by the game - _globalFlags[4] = 8; - _globalFlags[33] = 1; - _globalFlags[10] = 0xFFFF; - _globalFlags[13] = 0xFFFF; - _globalFlags[15] = 0xFFFF; - _globalFlags[19] = 0xFFFF; - _globalFlags[20] = 0xFFFF; - _globalFlags[21] = 0xFFFF; - _globalFlags[95] = 0xFFFF; + _globals[4] = 8; + _globals[33] = 1; + _globals[10] = 0xFFFF; + _globals[13] = 0xFFFF; + _globals[15] = 0xFFFF; + _globals[19] = 0xFFFF; + _globals[20] = 0xFFFF; + _globals[21] = 0xFFFF; + _globals[95] = 0xFFFF; _objects.setData(3, 17, nullptr); // Put the values 0 through 3 in a random order in global slots 83 to 86 for (int i = 0; i < 4;) { int randomVal = _vm->getRandomNumber(3); - _globalFlags[83 + i] = randomVal; + _globals[83 + i] = randomVal; bool flag = false; for (int idx2 = 0; idx2 < i; ++idx2) { - if (_globalFlags[83 + idx2] == randomVal) + if (_globals[83 + idx2] == randomVal) flag = true; } @@ -88,11 +87,11 @@ void GameNebular::initialiseGlobals() { // Put the values 0 through 3 in a random order in global slots 87 to 90 for (int i = 0; i < 4;) { int randomVal = _vm->getRandomNumber(3); - _globalFlags[87 + i] = randomVal; + _globals[87 + i] = randomVal; bool flag = false; for (int idx2 = 0; idx2 < i; ++idx2) { - if (_globalFlags[87 + idx2] == randomVal) + if (_globals[87 + idx2] == randomVal) flag = true; } @@ -100,20 +99,20 @@ void GameNebular::initialiseGlobals() { ++i; } - _globalFlags[120] = 501; - _globalFlags[121] = 0xFFFF; - _globalFlags[55] = 0xFFFF; - _globalFlags[119] = 1; - _globalFlags[134] = 4; + _globals[120] = 501; + _globals[121] = 0xFFFF; + _globals[55] = 0xFFFF; + _globals[119] = 1; + _globals[134] = 4; // Fill out the globals 200 to 209 with unique random values less than 10000 for (int i = 0; i < 10; ++i) { int randomVal = _vm->getRandomNumber(9999); - _globalFlags[200 + i] = randomVal; + _globals[200 + i] = randomVal; bool flag = false; for (int idx2 = 0; idx2 < i; ++idx2) { - if (_globalFlags[200 + idx2] == randomVal) + if (_globals[200 + idx2] == randomVal) flag = true; } @@ -124,20 +123,20 @@ void GameNebular::initialiseGlobals() { // Difficulty level control switch (_difficultyLevel) { case DIFFICULTY_HARD: - _globalFlags[35] = 0; + _globals[35] = 0; _objects.setRoom(9, 1); _objects.setRoom(50, 1); - _globalFlags[137] = 5; - _globalFlags[136] = 0; + _globals[137] = 5; + _globals[136] = 0; break; case DIFFICULTY_MEDIUM: - _globalFlags[35] = 0; + _globals[35] = 0; _objects.setRoom(8, 1); - _globalFlags[137] = 0xFFFF; - _globalFlags[136] = 6; + _globals[137] = 0xFFFF; + _globals[136] = 6; break; case DIFFICULTY_EASY: - _globalFlags[35] = 2; + _globals[35] = 2; _objects.setRoom(8, 1); _objects.setRoom(27, 1); break; @@ -185,6 +184,14 @@ void GameNebular::setSectionHandler() { } } +void GameNebular::checkShowDialog() { + if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[5]) { + _scene._spriteSlots.releasePlayerSprites(); + _vm->_dialogs->showDialog(); + _vm->_dialogs->_pendingDialog = DIALOG_NONE; + } +} + } // End of namespace Nebular } // End of namespace MADS diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h index 6395ba0e4e..0250f66d8e 100644 --- a/engines/mads/nebular/game_nebular.h +++ b/engines/mads/nebular/game_nebular.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "mads/game.h" +#include "mads/nebular/globals_nebular.h" namespace MADS { @@ -40,6 +41,11 @@ protected: virtual void initialiseGlobals(); virtual void setSectionHandler(); + + virtual void checkShowDialog(); + +public: + Globals _globals; }; diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp new file mode 100644 index 0000000000..20789cd154 --- /dev/null +++ b/engines/mads/nebular/globals_nebular.cpp @@ -0,0 +1,51 @@ +/* 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 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" +#include "common/config-manager.h" +#include "mads/nebular/globals_nebular.h" + +namespace MADS { + +namespace Nebular { + +Globals::Globals() { + // Initialise global flags + _flags.resize(210); + for (int i = 0; i < 210; ++i) + _flags[i] = 0; + + // Initialise game flags + _chairHotspotIndex = 0; + _v1 = 0; + _v2 = 0; + _v3 = 0; + _v4 = 0; + _v5 = 0; + _v6 = 0; + _v7 = 0; + _v8 = 0; +} + +} // End of namespace Nebular + +} // End of namespace MADS diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h new file mode 100644 index 0000000000..0d8da78e42 --- /dev/null +++ b/engines/mads/nebular/globals_nebular.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 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef MADS_GLOBALS_NEBULAR_H +#define MADS_GLOBALS_NEBULAR_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "mads/game.h" + +namespace MADS { + +namespace Nebular { + +class Globals { +private: + Common::Array _flags; +public: + int _chairHotspotIndex; + int _v1; + int _v2; + int _v3; + int _v4; + int _v5; + int _v6; + int _v7; + int _v8; +public: + /** + * Constructor + */ + Globals(); + + /** + * Square brackets operator for accessing flags + */ + uint16 &operator[](int idx) { return _flags[idx]; } +}; + +} // End of namespace Nebular + +} // End of namespace MADS + +#endif /* MADS_GLOBALS_NEBULAR_H */ diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp index e1dec2c34c..f82e102bfa 100644 --- a/engines/mads/nebular/nebular_scenes.cpp +++ b/engines/mads/nebular/nebular_scenes.cpp @@ -46,6 +46,9 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) { return new Scene804(vm); } +NebularScene::NebularScene(MADSEngine *vm) : SceneLogic(vm) { +} + } // End of namespace Nebular } // End of namespace MADS diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h index 1997202fbd..9d617bb543 100644 --- a/engines/mads/nebular/nebular_scenes.h +++ b/engines/mads/nebular/nebular_scenes.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "mads/game.h" #include "mads/scene.h" +#include "mads/nebular/globals_nebular.h" namespace MADS { @@ -88,6 +89,19 @@ public: static SceneLogic *createScene(MADSEngine *vm); }; +/** + * Specialized base class for Rex Nebular game scenes + */ +class NebularScene : public SceneLogic { +protected: + Globals &_globals; +public: + /** + * Constructor + */ + NebularScene(MADSEngine *vm); +}; + } // End of namespace Nebular } // End of namespace MADS diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp new file mode 100644 index 0000000000..1de4eca509 --- /dev/null +++ b/engines/mads/nebular/nebular_scenes1.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" +#include "mads/mads.h" +#include "mads/scene.h" +#include "mads/nebular/nebular_scenes.h" +#include "mads/nebular/nebular_scenes1.h" + +namespace MADS { + +namespace Nebular { + +void Scene101::setup() { +} + +void Scene101::enter() { +} + +void Scene101::step() { +} + +void Scene101::preActions() { +} + +void Scene101::actions() { +} + +void Scene101::postActions() { +} + +} // End of namespace Nebular + +} // End of namespace MADS diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h new file mode 100644 index 0000000000..da6a2f0903 --- /dev/null +++ b/engines/mads/nebular/nebular_scenes1.h @@ -0,0 +1,56 @@ +/* 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 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef MADS_NEBULAR_SCENES1_H +#define MADS_NEBULAR_SCENES1_H + +#include "common/scummsys.h" +#include "mads/game.h" +#include "mads/scene.h" +#include "mads/nebular/nebular_scenes.h" + +namespace MADS { + +namespace Nebular { + +class Scene101: public NebularScene { +public: + Scene101(MADSEngine *vm) : NebularScene(vm) {} + + virtual void setup(); + + virtual void enter(); + + virtual void step(); + + virtual void preActions(); + + virtual void actions(); + + virtual void postActions(); +}; + +} // End of namespace Nebular + +} // End of namespace MADS + +#endif /* MADS_NEBULAR_SCENES1_H */ diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp index ee06dd00d3..d08e64506e 100644 --- a/engines/mads/nebular/nebular_scenes8.cpp +++ b/engines/mads/nebular/nebular_scenes8.cpp @@ -32,13 +32,12 @@ namespace Nebular { void Scene8xx::setup1() { _vm->_sound->command(5); - if ((_vm->_game->_globalFlags[178] && !_vm->_game->_globalFlags[179]) || + if ((_globals[178] && !_globals[179]) || _scene->_nextSceneId == 804 || _scene->_nextSceneId == 805 || _scene->_nextSceneId == 808 || _scene->_nextSceneId == 810) { _vm->_game->_player._spritesPrefix = ""; } else { - _vm->_game->_player._spritesPrefix = _vm->_game->_globalFlags[0] - == SEX_FEMALE ? "ROX" : "RXM"; + _vm->_game->_player._spritesPrefix = _globals[0] == SEX_FEMALE ? "ROX" : "RXM"; } _vm->_palette->setEntry(16, 0x0A, 0x3F, 0x3F); @@ -49,6 +48,30 @@ void Scene8xx::setup2() { _vm->_game->_aaName = Resources::formatAAName(5); } +void Scene8xx::enter1() { + if (_vm->_musicFlag) { + switch (_scene->_nextSceneId) { + case 801: + case 802: + case 803: + case 804: + case 806: + case 807: + case 808: + _vm->_sound->command(20); + break; + case 805: + _vm->_sound->command(23); + break; + case 810: + _vm->_sound->command(10); + break; + default: + break; + } + } +} + /*------------------------------------------------------------------------*/ void Scene804::setup() { diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h index 3f5d2744fa..a3bc97a990 100644 --- a/engines/mads/nebular/nebular_scenes8.h +++ b/engines/mads/nebular/nebular_scenes8.h @@ -26,12 +26,13 @@ #include "common/scummsys.h" #include "mads/game.h" #include "mads/scene.h" +#include "mads/nebular/nebular_scenes.h" namespace MADS { namespace Nebular { -class Scene8xx : public SceneLogic { +class Scene8xx : public NebularScene { protected: /** * Initial setup code shared by several scenes @@ -42,8 +43,13 @@ protected: * Initial setup code shared by several scenes */ void setup2(); + + /** + * Common scene enter code used by multiple scenes + */ + void enter1(); public: - Scene8xx(MADSEngine *vm) : SceneLogic(vm) {} + Scene8xx(MADSEngine *vm) : NebularScene(vm) {} }; class Scene804: public Scene8xx { diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index b285229926..f974be4d1e 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -28,9 +28,10 @@ namespace MADS { -Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), - _dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), - _screenObjects(vm), _sequences(vm), _textDisplay(vm) { +Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _dirtyAreas(_vm), + _dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), + _screenObjects(vm), _sequences(vm), _spriteSlots(vm), + _textDisplay(vm) { _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; @@ -47,6 +48,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm), _freeAnimationFlag = false; _animation = nullptr; _activeAnimation = nullptr; + _textSpacing = -1; _verbList.push_back(VerbInit(VERB_LOOK, 2, 0)); _verbList.push_back(VerbInit(VERB_TAKE, 2, 0)); @@ -424,7 +426,6 @@ void Scene::doFrame() { void Scene::drawElements(bool transitionFlag, bool surfaceFlag) { // Draw any sprites - _dirtyAreas.clear(); _spriteSlots.drawBackground(); // Process dirty areas -- cgit v1.2.3