MADS: Added in Rex Nebular globals class

This commit is contained in:
Paul Gilbert 2014-03-06 20:30:05 -05:00
parent 2d9bb392ae
commit c9186f51b9
17 changed files with 336 additions and 50 deletions

View File

@ -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();
}
}

View File

@ -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<uint16> _globalFlags;
InventoryObjects _objects;
Scene _scene;
int _v2;

View File

@ -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;

View File

@ -105,6 +105,7 @@ public:
bool _invObjectStill;
bool _textWindowStill;
ScreenFade _screenFade;
bool _musicFlag;
public:
MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc);
virtual ~MADSEngine();

View File

@ -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;
}

View File

@ -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 \

View File

@ -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

View File

@ -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;
};

View File

@ -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

View File

@ -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<uint16> _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 */

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 */

View File

@ -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() {

View File

@ -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 {

View File

@ -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