aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage/globals.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tsage/globals.cpp')
-rw-r--r--engines/tsage/globals.cpp123
1 files changed, 95 insertions, 28 deletions
diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp
index 52bd42fc5c..788ab71b76 100644
--- a/engines/tsage/globals.cpp
+++ b/engines/tsage/globals.cpp
@@ -28,8 +28,8 @@
namespace TsAGE {
-Globals *_globals = NULL;
-ResourceManager *_resourceManager = NULL;
+Globals *g_globals = NULL;
+ResourceManager *g_resourceManager = NULL;
/*--------------------------------------------------------------------------*/
@@ -56,7 +56,7 @@ Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface
_stripNum = 0;
_gfxEdgeAdjust = 3;
- if (_vm->getFeatures() & GF_DEMO) {
+ if (g_vm->getFeatures() & GF_DEMO) {
_gfxFontNumber = 0;
_gfxColors.background = 6;
_gfxColors.foreground = 0;
@@ -67,15 +67,15 @@ Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface
_color1 = _gfxColors.foreground;
_color2 = _gfxColors.foreground;
_color3 = _gfxColors.foreground;
- } else if (_vm->getGameID() == GType_BlueForce) {
+ } else if (g_vm->getGameID() == GType_BlueForce) {
// Blue Force
_gfxFontNumber = 0;
_gfxColors.background = 89;
_gfxColors.foreground = 83;
_fontColors.background = 88;
_fontColors.foreground = 92;
- _dialogCenter.y = 165;
- } else if ((_vm->getGameID() == GType_Ringworld) && (_vm->getFeatures() & GF_CD)) {
+ _dialogCenter.y = 140;
+ } else if ((g_vm->getGameID() == GType_Ringworld) && (g_vm->getFeatures() & GF_CD)) {
_gfxFontNumber = 50;
_gfxColors.background = 53;
_gfxColors.foreground = 0;
@@ -108,9 +108,9 @@ Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface
_scrollFollower = NULL;
_inventory = NULL;
- switch (_vm->getGameID()) {
+ switch (g_vm->getGameID()) {
case GType_Ringworld:
- if (!(_vm->getFeatures() & GF_DEMO)) {
+ if (!(g_vm->getFeatures() & GF_DEMO)) {
_inventory = new Ringworld::RingworldInvObjectList();
_game = new Ringworld::RingworldGame();
} else {
@@ -132,12 +132,12 @@ Globals::~Globals() {
delete _inventory;
delete _sceneHandler;
delete _game;
- _globals = NULL;
+ g_globals = NULL;
}
void Globals::reset() {
Common::set_to(&_flags[0], &_flags[MAX_FLAGS], false);
- _saver->addFactory(classFactoryProc);
+ g_saver->addFactory(classFactoryProc);
}
void Globals::synchronize(Serializer &s) {
@@ -184,33 +184,100 @@ void Globals::dispatchSounds() {
namespace BlueForce {
BlueForceGlobals::BlueForceGlobals(): Globals() {
- _interfaceY = 0;
- _v51C44 = 1;
- _v4CEA2 = 0;
+}
+
+void BlueForceGlobals::synchronize(Serializer &s) {
+ Globals::synchronize(s);
+
+ s.syncAsSint16LE(_dayNumber);
+ s.syncAsSint16LE(_v4CEA4);
+ s.syncAsSint16LE(_marinaWomanCtr);
+ s.syncAsSint16LE(_v4CEB6);
+ s.syncAsSint16LE(_safeCombination);
+ s.syncAsSint16LE(_v4CEC0);
+ s.syncAsSint16LE(_v4CEC2);
+ s.syncAsSint16LE(_v4CEC4);
+ s.syncAsSint16LE(_v4CEC8);
+ s.syncAsSint16LE(_deziTopic);
+ s.syncAsSint16LE(_deathReason);
+ s.syncAsSint16LE(_driveFromScene);
+ s.syncAsSint16LE(_driveToScene);
+ s.syncAsSint16LE(_v501FC);
+ s.syncAsSint16LE(_v50696);
+ s.syncAsSint16LE(_v5098C);
+ s.syncAsSint16LE(_v5098D);
+ s.syncAsSint16LE(_v50CC2);
+ s.syncAsSint16LE(_v50CC4);
+ s.syncAsSint16LE(_v50CC6);
+ s.syncAsSint16LE(_v50CC8);
+ s.syncAsSint16LE(_v51C42);
+ s.syncAsSint16LE(_v51C44);
+ s.syncAsSint16LE(_interfaceY);
+ s.syncAsSint16LE(_bookmark);
+ s.syncAsSint16LE(_mapLocationId);
+ s.syncAsSint16LE(_clip1Bullets);
+ s.syncAsSint16LE(_clip2Bullets);
+}
+
+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;
+
+ _interfaceY = BF_INTERFACE_Y;
+ _dayNumber = 0;
_v4CEA4 = 0;
- _v4CEA8 = 0;
- _v4CEF2 = 0;
- _v4CEF4 = 0;
- _v4CF9E = 0;
- _v4E238 = 0;
+ _marinaWomanCtr = 0;
+ _v4CEB6 = 0;
+ _safeCombination = 0;
+ _v4CEC0 = 0;
+ _v4CEC2 = 0;
+ _v4CEC4 = 0;
+ _v4CEC8 = 1;
+ _deziTopic = 0;
+ _deathReason = 0;
_v501FC = 0;
+ _v50696 = 0;
+ _v5098C = 0;
+ _v5098D = 0;
+ _v50CC2 = 0;
+ _v50CC4 = 0;
+ _v50CC6 = 0;
+ _v50CC8 = 0;
_v51C42 = 0;
- _bikiniHutState = 0;
- _mapLocationId = 1;
- Common::set_to(_globalFlags, _globalFlags + 12, 0);
+ _v51C44 = 1;
+ _clip1Bullets = 8;
+ _clip2Bullets = 8;
}
-void BlueForceGlobals::synchronize(Serializer &s) {
- Globals::synchronize(s);
- error("Sync variables");
+bool BlueForceGlobals::getHasBullets() {
+ if (!getFlag(fGunLoaded))
+ return false;
+ return BF_GLOBALS.getFlag(fLoadedSpare) ? (_clip2Bullets > 0) : (_clip1Bullets > 0);
}
-bool BlueForceGlobals::getFlag(int v) {
- return _globalFlags[v / 8] & (1 << (v % 8));
+void BlueForceGlobals::set2Flags(int flagNum) {
+ if (!getFlag(flagNum + 1)) {
+ setFlag(flagNum + 1);
+ setFlag(flagNum);
+ }
}
-void BlueForceGlobals::setFlag(int v) {
- _globalFlags[v / 8] |= 1 << (v % 8);
+bool BlueForceGlobals::removeFlag(int flagNum) {
+ bool result = getFlag(flagNum);
+ clearFlag(flagNum);
+ return result;
}
} // end of namespace BlueForce