2011-02-14 09:37:27 +00:00
|
|
|
/* 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 "tsage/globals.h"
|
2011-04-25 07:06:35 +00:00
|
|
|
#include "tsage/tsage.h"
|
2011-08-13 09:49:54 +00:00
|
|
|
#include "tsage/blue_force/blueforce_logic.h"
|
|
|
|
#include "tsage/ringworld/ringworld_demo.h"
|
|
|
|
#include "tsage/ringworld/ringworld_logic.h"
|
2011-02-14 09:37:27 +00:00
|
|
|
|
2011-08-15 10:47:59 +00:00
|
|
|
namespace TsAGE {
|
2011-02-14 09:37:27 +00:00
|
|
|
|
|
|
|
Globals *_globals = NULL;
|
2011-04-25 07:06:35 +00:00
|
|
|
ResourceManager *_resourceManager = NULL;
|
2011-02-14 09:37:27 +00:00
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a saved object that can be instantiated
|
|
|
|
*/
|
|
|
|
static SavedObject *classFactoryProc(const Common::String &className) {
|
|
|
|
if (className == "ObjectMover") return new ObjectMover();
|
|
|
|
if (className == "NpcMover") return new NpcMover();
|
|
|
|
if (className == "ObjectMover2") return new ObjectMover2();
|
|
|
|
if (className == "ObjectMover3") return new ObjectMover3();
|
|
|
|
if (className == "PlayerMover") return new PlayerMover();
|
2011-04-27 20:52:20 +00:00
|
|
|
if (className == "SceneObjectWrapper") return new SceneObjectWrapper();
|
2011-05-08 09:08:35 +00:00
|
|
|
if (className == "PaletteRotation") return new PaletteRotation();
|
|
|
|
if (className == "PaletteFader") return new PaletteFader();
|
2011-02-14 09:37:27 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
2011-06-03 13:02:24 +00:00
|
|
|
Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface),
|
2011-08-16 11:15:18 +00:00
|
|
|
_randomSource("tsage"), _color1(0), _color2(255), _color3(255) {
|
2011-02-14 09:37:27 +00:00
|
|
|
reset();
|
2011-02-24 11:24:19 +00:00
|
|
|
_stripNum = 0;
|
2011-06-04 04:22:09 +00:00
|
|
|
_gfxEdgeAdjust = 3;
|
2011-04-13 19:27:46 +00:00
|
|
|
|
2011-04-28 09:14:37 +00:00
|
|
|
if (_vm->getFeatures() & GF_DEMO) {
|
|
|
|
_gfxFontNumber = 0;
|
|
|
|
_gfxColors.background = 6;
|
|
|
|
_gfxColors.foreground = 0;
|
2011-06-04 06:29:20 +00:00
|
|
|
_fontColors.background = 255;
|
|
|
|
_fontColors.foreground = 6;
|
2011-04-28 09:14:37 +00:00
|
|
|
_dialogCenter.y = 80;
|
2011-06-03 13:02:24 +00:00
|
|
|
// Workaround in order to use later version of the engine
|
2011-08-16 11:15:18 +00:00
|
|
|
_color1 = _gfxColors.foreground;
|
|
|
|
_color2 = _gfxColors.foreground;
|
|
|
|
_color3 = _gfxColors.foreground;
|
|
|
|
} else if (_vm->getGameID() == GType_BlueForce) {
|
|
|
|
// Blue Force
|
|
|
|
_gfxFontNumber = 0;
|
|
|
|
_gfxColors.background = 89;
|
|
|
|
_gfxColors.foreground = 83;
|
|
|
|
_fontColors.background = 88;
|
|
|
|
_fontColors.foreground = 92;
|
2011-09-05 10:57:06 +00:00
|
|
|
_dialogCenter.y = 140;
|
2011-05-28 05:21:38 +00:00
|
|
|
} else if ((_vm->getGameID() == GType_Ringworld) && (_vm->getFeatures() & GF_CD)) {
|
|
|
|
_gfxFontNumber = 50;
|
|
|
|
_gfxColors.background = 53;
|
|
|
|
_gfxColors.foreground = 0;
|
|
|
|
_fontColors.background = 51;
|
|
|
|
_fontColors.foreground = 54;
|
2011-08-16 11:15:18 +00:00
|
|
|
_color1 = 18;
|
|
|
|
_color2 = 18;
|
|
|
|
_color3 = 18;
|
2011-04-28 09:14:37 +00:00
|
|
|
} else {
|
|
|
|
_gfxFontNumber = 50;
|
|
|
|
_gfxColors.background = 53;
|
|
|
|
_gfxColors.foreground = 18;
|
|
|
|
_fontColors.background = 51;
|
|
|
|
_fontColors.foreground = 54;
|
2011-06-03 13:02:24 +00:00
|
|
|
// Workaround in order to use later version of the engine
|
2011-08-16 11:15:18 +00:00
|
|
|
_color1 = _gfxColors.foreground;
|
|
|
|
_color2 = _gfxColors.foreground;
|
|
|
|
_color3 = _gfxColors.foreground;
|
2011-04-28 09:14:37 +00:00
|
|
|
}
|
2011-02-14 09:37:27 +00:00
|
|
|
_screenSurface.setScreenSurface();
|
|
|
|
_gfxManagers.push_back(&_gfxManagerInstance);
|
|
|
|
|
|
|
|
_sceneObjects = &_sceneObjectsInstance;
|
|
|
|
_sceneObjects_queue.push_front(_sceneObjects);
|
|
|
|
|
2011-03-18 11:58:36 +00:00
|
|
|
_prevSceneOffset = Common::Point(-1, -1);
|
2011-06-22 08:30:59 +00:00
|
|
|
_sounds.push_back(&_soundHandler);
|
|
|
|
_sounds.push_back(&_sequenceManager._soundHandler);
|
2011-04-25 09:39:45 +00:00
|
|
|
|
|
|
|
_scrollFollower = NULL;
|
|
|
|
_inventory = NULL;
|
|
|
|
|
2011-05-14 08:19:35 +00:00
|
|
|
switch (_vm->getGameID()) {
|
|
|
|
case GType_Ringworld:
|
|
|
|
if (!(_vm->getFeatures() & GF_DEMO)) {
|
2011-08-15 09:26:15 +00:00
|
|
|
_inventory = new Ringworld::RingworldInvObjectList();
|
|
|
|
_game = new Ringworld::RingworldGame();
|
2011-05-14 08:19:35 +00:00
|
|
|
} else {
|
2011-08-15 09:26:15 +00:00
|
|
|
_game = new Ringworld::RingworldDemoGame();
|
2011-05-14 08:19:35 +00:00
|
|
|
}
|
2011-08-20 09:14:23 +00:00
|
|
|
_sceneHandler = new SceneHandler();
|
2011-05-14 08:19:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GType_BlueForce:
|
2011-08-15 09:26:15 +00:00
|
|
|
_game = new BlueForce::BlueForceGame();
|
2011-08-23 11:12:07 +00:00
|
|
|
_inventory = new BlueForce::BlueForceInvObjectList();
|
2011-08-20 09:14:23 +00:00
|
|
|
_sceneHandler = new BlueForce::SceneHandlerExt();
|
2011-05-14 08:19:35 +00:00
|
|
|
break;
|
2011-04-25 09:39:45 +00:00
|
|
|
}
|
2011-02-17 13:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Globals::~Globals() {
|
2011-08-13 11:14:48 +00:00
|
|
|
_scenePalette.clearListeners();
|
2011-05-06 09:38:17 +00:00
|
|
|
delete _inventory;
|
2011-08-20 09:14:23 +00:00
|
|
|
delete _sceneHandler;
|
2011-05-06 09:38:17 +00:00
|
|
|
delete _game;
|
2011-05-27 11:19:06 +00:00
|
|
|
_globals = NULL;
|
2011-02-14 09:37:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::reset() {
|
|
|
|
Common::set_to(&_flags[0], &_flags[MAX_FLAGS], false);
|
|
|
|
_saver->addFactory(classFactoryProc);
|
|
|
|
}
|
|
|
|
|
2011-05-04 08:41:47 +00:00
|
|
|
void Globals::synchronize(Serializer &s) {
|
2011-05-04 07:52:36 +00:00
|
|
|
if (s.getVersion() >= 2)
|
2011-05-04 08:41:47 +00:00
|
|
|
SavedObject::synchronize(s);
|
2011-02-14 09:37:27 +00:00
|
|
|
assert(_gfxManagers.size() == 1);
|
|
|
|
|
2011-05-04 08:41:47 +00:00
|
|
|
_sceneItems.synchronize(s);
|
2011-02-14 09:37:27 +00:00
|
|
|
SYNC_POINTER(_sceneObjects);
|
2011-05-04 08:41:47 +00:00
|
|
|
_sceneObjects_queue.synchronize(s);
|
2011-02-14 09:37:27 +00:00
|
|
|
s.syncAsSint32LE(_gfxFontNumber);
|
2011-04-14 12:12:27 +00:00
|
|
|
s.syncAsSint32LE(_gfxColors.background);
|
|
|
|
s.syncAsSint32LE(_gfxColors.foreground);
|
|
|
|
s.syncAsSint32LE(_fontColors.background);
|
|
|
|
s.syncAsSint32LE(_fontColors.foreground);
|
2011-06-19 22:59:48 +00:00
|
|
|
|
2011-06-03 13:02:24 +00:00
|
|
|
if (s.getVersion() >= 4) {
|
2011-08-16 11:15:18 +00:00
|
|
|
s.syncAsByte(_color1);
|
|
|
|
s.syncAsByte(_color2);
|
|
|
|
s.syncAsByte(_color3);
|
2011-06-03 13:02:24 +00:00
|
|
|
}
|
2011-02-14 09:37:27 +00:00
|
|
|
|
2011-04-14 12:34:28 +00:00
|
|
|
s.syncAsSint16LE(_dialogCenter.x); s.syncAsSint16LE(_dialogCenter.y);
|
2011-06-22 08:30:59 +00:00
|
|
|
_sounds.synchronize(s);
|
2011-02-14 09:37:27 +00:00
|
|
|
for (int i = 0; i < 256; ++i)
|
|
|
|
s.syncAsByte(_flags[i]);
|
|
|
|
|
|
|
|
s.syncAsSint16LE(_sceneOffset.x); s.syncAsSint16LE(_sceneOffset.y);
|
2011-03-18 11:58:36 +00:00
|
|
|
s.syncAsSint16LE(_prevSceneOffset.x); s.syncAsSint16LE(_prevSceneOffset.y);
|
2011-02-14 09:37:27 +00:00
|
|
|
SYNC_POINTER(_scrollFollower);
|
|
|
|
s.syncAsSint32LE(_stripNum);
|
|
|
|
}
|
|
|
|
|
2011-06-22 08:30:59 +00:00
|
|
|
void Globals::dispatchSound(ASound *obj) {
|
|
|
|
obj->dispatch();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::dispatchSounds() {
|
|
|
|
Common::for_each(_sounds.begin(), _sounds.end(), Globals::dispatchSound);
|
|
|
|
}
|
|
|
|
|
2011-08-11 12:05:44 +00:00
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
2011-08-15 09:26:15 +00:00
|
|
|
namespace BlueForce {
|
2011-08-14 10:18:32 +00:00
|
|
|
|
2011-08-11 12:05:44 +00:00
|
|
|
BlueForceGlobals::BlueForceGlobals(): Globals() {
|
2011-09-04 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BlueForceGlobals::synchronize(Serializer &s) {
|
|
|
|
Globals::synchronize(s);
|
2011-09-10 01:22:39 +00:00
|
|
|
|
|
|
|
s.syncAsSint16LE(_dayNumber);
|
|
|
|
s.syncAsSint16LE(_v4CEA4);
|
2011-09-23 11:49:19 +00:00
|
|
|
s.syncAsSint16LE(_marinaWomanCtr);
|
2011-09-17 07:41:12 +00:00
|
|
|
s.syncAsSint16LE(_v4CEB6);
|
2011-09-23 19:52:40 +00:00
|
|
|
s.syncAsSint16LE(_v4CEC0);
|
2011-09-20 12:06:58 +00:00
|
|
|
s.syncAsSint16LE(_v4CEC2);
|
2011-09-23 19:52:40 +00:00
|
|
|
s.syncAsSint16LE(_v4CEC8);
|
2011-09-17 07:41:12 +00:00
|
|
|
s.syncAsSint16LE(_deziTopic);
|
2011-09-11 11:50:39 +00:00
|
|
|
s.syncAsSint16LE(_deathReason);
|
2011-09-10 01:22:39 +00:00
|
|
|
s.syncAsSint16LE(_driveFromScene);
|
|
|
|
s.syncAsSint16LE(_driveToScene);
|
|
|
|
s.syncAsSint16LE(_v501FC);
|
|
|
|
s.syncAsSint16LE(_v50696);
|
2011-09-13 10:49:37 +00:00
|
|
|
s.syncAsSint16LE(_v5098C);
|
|
|
|
s.syncAsSint16LE(_v5098D);
|
2011-09-26 12:55:29 +00:00
|
|
|
s.syncAsSint16LE(_v50CC2);
|
|
|
|
s.syncAsSint16LE(_v50CC4);
|
|
|
|
s.syncAsSint16LE(_v50CC6);
|
|
|
|
s.syncAsSint16LE(_v50CC8);
|
2011-09-10 01:22:39 +00:00
|
|
|
s.syncAsSint16LE(_v51C42);
|
|
|
|
s.syncAsSint16LE(_v51C44);
|
|
|
|
s.syncAsSint16LE(_interfaceY);
|
|
|
|
s.syncAsSint16LE(_bookmark);
|
|
|
|
s.syncAsSint16LE(_mapLocationId);
|
|
|
|
s.syncAsSint16LE(_clip1Bullets);
|
|
|
|
s.syncAsSint16LE(_clip2Bullets);
|
2011-09-04 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BlueForceGlobals::reset() {
|
|
|
|
Globals::reset();
|
|
|
|
_scenePalette.clearListeners();
|
|
|
|
|
|
|
|
_scrollFollower = &_player;
|
|
|
|
_bookmark = bNone;
|
|
|
|
|
|
|
|
// Reset the inventory
|
|
|
|
((BlueForceInvObjectList *)_inventory)->reset();
|
|
|
|
BF_GLOBALS._uiElements.updateInventory();
|
|
|
|
BF_GLOBALS._uiElements._scoreValue = 0;
|
|
|
|
|
|
|
|
_mapLocationId = 1;
|
|
|
|
_driveFromScene = 300;
|
|
|
|
_driveToScene = 0;
|
|
|
|
|
2011-09-13 09:47:31 +00:00
|
|
|
_interfaceY = BF_INTERFACE_Y;
|
2011-09-04 09:11:59 +00:00
|
|
|
_dayNumber = 0;
|
2011-08-26 09:07:43 +00:00
|
|
|
_v4CEA4 = 0;
|
2011-09-23 11:49:19 +00:00
|
|
|
_marinaWomanCtr = 0;
|
2011-09-17 07:41:12 +00:00
|
|
|
_v4CEB6 = 0;
|
2011-09-23 19:52:40 +00:00
|
|
|
_v4CEC0 = 0;
|
2011-09-20 12:06:58 +00:00
|
|
|
_v4CEC2 = 0;
|
2011-09-23 19:52:40 +00:00
|
|
|
_v4CEC8 = 1;
|
2011-09-17 07:41:12 +00:00
|
|
|
_deziTopic = 0;
|
2011-09-11 11:50:39 +00:00
|
|
|
_deathReason = 0;
|
2011-08-20 09:14:23 +00:00
|
|
|
_v501FC = 0;
|
2011-09-13 10:49:37 +00:00
|
|
|
_v50696 = 0;
|
2011-09-11 05:30:34 +00:00
|
|
|
_v5098C = 0;
|
|
|
|
_v5098D = 0;
|
2011-09-26 12:55:29 +00:00
|
|
|
_v50CC2 = 0;
|
|
|
|
_v50CC4 = 0;
|
|
|
|
_v50CC6 = 0;
|
|
|
|
_v50CC8 = 0;
|
2011-08-20 09:14:23 +00:00
|
|
|
_v51C42 = 0;
|
2011-09-13 10:49:37 +00:00
|
|
|
_v51C44 = 1;
|
2011-09-04 11:09:22 +00:00
|
|
|
_clip1Bullets = 8;
|
|
|
|
_clip2Bullets = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BlueForceGlobals::getHasBullets() {
|
|
|
|
if (!getFlag(fGunLoaded))
|
|
|
|
return false;
|
|
|
|
return BF_GLOBALS.getFlag(fLoadedSpare) ? (_clip2Bullets > 0) : (_clip1Bullets > 0);
|
2011-08-11 12:05:44 +00:00
|
|
|
}
|
2011-06-22 08:30:59 +00:00
|
|
|
|
2011-09-11 05:30:34 +00:00
|
|
|
void BlueForceGlobals::set2Flags(int flagNum) {
|
|
|
|
if (!getFlag(flagNum + 1)) {
|
|
|
|
setFlag(flagNum + 1);
|
|
|
|
setFlag(flagNum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BlueForceGlobals::removeFlag(int flagNum) {
|
|
|
|
bool result = getFlag(flagNum);
|
|
|
|
clearFlag(flagNum);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-08-15 09:26:15 +00:00
|
|
|
} // end of namespace BlueForce
|
|
|
|
|
2011-08-15 10:47:59 +00:00
|
|
|
} // end of namespace TsAGE
|