aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/access/access.cpp58
-rw-r--r--engines/access/access.h9
-rw-r--r--engines/access/amazon/amazon_game.cpp40
-rw-r--r--engines/access/amazon/amazon_game.h48
-rw-r--r--engines/access/data.cpp14
-rw-r--r--engines/access/data.h6
-rw-r--r--engines/access/inventory.cpp10
-rw-r--r--engines/access/inventory.h5
-rw-r--r--engines/access/player.cpp8
-rw-r--r--engines/access/player.h6
-rw-r--r--engines/access/sound.cpp2
11 files changed, 170 insertions, 36 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 3e8eff3614..9525608b2b 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -76,8 +76,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_currentMan = 0;
_newTime = 0;
_newDate = 0;
- _intTim[3] = 0;
- _timer[3] = 0;
Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr);
Common::fill(&_establishTable[0], &_establishTable[100], false);
Common::fill(&_flags[0], &_flags[256], 0);
@@ -180,33 +178,9 @@ Common::Error AccessEngine::run() {
playGame();
- dummyLoop();
return Common::kNoError;
}
-void AccessEngine::dummyLoop() {
- // Dummy game loop
- while (!shouldQuit()) {
- _events->pollEvents();
-
- _curTime = g_system->getMillis();
- // Process machine once every tick
- while (_curTime - _lastTime < 20) {
- g_system->delayMillis(5);
- _curTime = g_system->getMillis();
- }
-
- _lastTime = _curTime;
-
- g_system->updateScreen();
-
- if (_events->_leftButton) {
- CursorType cursorId = _events->getCursor();
- _events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_ARROW : (CursorType)(cursorId + 1));
- }
- }
-}
-
int AccessEngine::getRandomNumber(int maxNumber) {
return _randomSource.getRandomNumber(maxNumber);
}
@@ -411,4 +385,36 @@ void AccessEngine::freeChar() {
_animation->freeAnimationData();
}
+void AccessEngine::synchronize(Common::Serializer &s) {
+ s.syncAsUint16LE(_conversation);
+ s.syncAsUint16LE(_currentMan);
+ s.syncAsUint32LE(_newTime);
+ s.syncAsUint32LE(_newDate);
+
+ for (int i = 0; i < 256; ++i)
+ s.syncAsUint16LE(_flags[i]);
+ for (int i = 0; i < 366; ++i) {
+ s.syncAsByte(_help1[i]);
+ s.syncAsByte(_help2[i]);
+ s.syncAsByte(_help3[i]);
+ }
+
+ s.syncAsUint16LE(_travel);
+ s.syncAsUint16LE(_ask);
+ s.syncAsUint16LE(_rScrollRow);
+ s.syncAsUint16LE(_rScrollCol);
+ s.syncAsSint16LE(_rScrollX);
+ s.syncAsSint16LE(_rScrollY);
+ s.syncAsUint16LE(_rOldRectCount);
+ s.syncAsUint16LE(_rNewRectCount);
+ s.syncAsUint16LE(_rKeyFlag);
+ s.syncAsUint16LE(_mapOffset);
+ s.syncAsUint16LE(_screenVirtX);
+
+ // Synchronize sub-objects
+ _timers.synchronize(s);
+ _inventory->synchronize(s);
+ _player->synchronize(s);
+}
+
} // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 55810e8a16..7d76be9039 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -27,6 +27,7 @@
#include "common/system.h"
#include "common/error.h"
#include "common/random.h"
+#include "common/serializer.h"
#include "common/util.h"
#include "engines/engine.h"
#include "graphics/surface.h"
@@ -90,7 +91,6 @@ private:
*/
void setVGA();
- void dummyLoop();
protected:
const AccessGameDescription *_gameDescription;
Common::RandomSource _randomSource;
@@ -110,6 +110,11 @@ protected:
* Play the game
*/
virtual void playGame() = 0;
+
+ /**
+ * Synchronize savegame data
+ */
+ virtual void synchronize(Common::Serializer &s);
public:
AnimationManager *_animation;
BubbleBox *_bubbleBox;
@@ -177,8 +182,6 @@ public:
int _currentMan;
uint32 _newTime;
uint32 _newDate;
- int _intTim[3];
- int _timer[3];
int _flags[256];
byte _help1[366];
byte _help2[366];
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index cf383ce45a..0ccaae85dc 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -44,7 +44,7 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_hitCount = 0;
_saveRiver = 0;
_hitSafe = 0;
- _oldTitleChap = _chapter = 0;
+ _oldTitleChapter = _chapter = 0;
_updateChapter = -1;
_topList = 0;
_botList = 0;
@@ -291,10 +291,10 @@ void AmazonEngine::tileScreen() {
if (!_screen->_vesaMode)
return;
- if (!_clearSummaryFlag && (_oldTitleChap == _chapter))
+ if (!_clearSummaryFlag && (_oldTitleChapter == _chapter))
return;
- _oldTitleChap = _chapter;
+ _oldTitleChapter = _chapter;
int idx = _chapter - 1;
if (!_files->existFile(_tileFiles[idx]))
@@ -361,6 +361,40 @@ void AmazonEngine::drawHelp() {
error("TODO: drawHelp");
}
+void AmazonEngine::synchronize(Common::Serializer &s) {
+ AccessEngine::synchronize(s);
+
+ s.syncAsSint16LE(_canoeLane);
+ s.syncAsSint16LE(_canoeYPos);
+ s.syncAsSint16LE(_hitCount);
+ s.syncAsSint16LE(_saveRiver);
+ s.syncAsSint16LE(_hitSafe);
+ s.syncAsSint16LE(_chapter);
+ s.syncAsSint16LE(_topList);
+ s.syncAsSint16LE(_botList);
+ s.syncAsSint16LE(_riverIndex);
+ s.syncAsSint16LE(_rawInactiveX);
+ s.syncAsSint16LE(_rawInactiveY);
+ s.syncAsSint16LE(_inactiveYOff);
+ for (int i = 0; i < 100; ++i)
+ s.syncAsSint16LE(_esTabTable[i]);
+}
+
+/*------------------------------------------------------------------------*/
+
+Guard::Guard() {
+ _guardCel = 0;
+ _gCode1 = _gCode2 = 0;
+ _xMid = _yMid = 0;
+}
+
+Plane::Plane() {
+ _pCount = 0;
+ _planeCount = 0;
+ _propCount = 0;
+ _xCount = 0;
+}
+
} // End of namespace Amazon
} // End of namespace Access
diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h
index 59511c4546..6511b377ae 100644
--- a/engines/access/amazon/amazon_game.h
+++ b/engines/access/amazon/amazon_game.h
@@ -29,6 +29,29 @@ namespace Access {
namespace Amazon {
+class Plane {
+public:
+ int _pCount;
+ Common::Point _position;
+ int _planeCount;
+ int _propCount;
+ int _xCount;
+public:
+ Plane();
+};
+
+class Guard {
+public:
+ int _guardCel;
+ Common::Point _position;
+ int _gCode1;
+ int _gCode2;
+ Common::Rect _bounds;
+ int _xMid, _yMid;
+public:
+ Guard();
+};
+
class AmazonEngine : public AccessEngine {
private:
bool _skipStart;
@@ -39,7 +62,6 @@ private:
int _hitCount;
int _saveRiver;
int _hitSafe;
- int _oldTitleChap;
int _topList;
int _botList;
int _riverIndex;
@@ -47,6 +69,8 @@ private:
int _rawInactiveY;
int _inactiveYOff;
int _esTabTable[100];
+
+ // Other fields
Common::Point _tilePos;
byte _tileData[1455];
@@ -84,6 +108,11 @@ protected:
* Play the game
*/
virtual void playGame();
+
+ /**
+ * Synchronize savegame data
+ */
+ virtual void synchronize(Common::Serializer &s);
public:
// Fields that are mapped to flags
int &_guardLocation;
@@ -100,11 +129,24 @@ public:
int &_allenFlag;
int &_noSound;
+ // Saved fields
+ int _chapter;
+
// Other game specific fields
+ Guard _guard;
+ Plane _plane;
int _hintLevel;
-
- int _chapter;
int _updateChapter;
+ int _oldTitleChapter;
+ int _maxHits;
+ int _oldScrollCol;
+ bool _deathFlag;
+ int _deathCount;
+ int _deathType;
+ int _mapPtr;
+ int _canoeVXPos;
+ int _canoeMoveCount;
+ int _canoeFrame;
public:
AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc);
diff --git a/engines/access/data.cpp b/engines/access/data.cpp
index 0279cd5052..cbc52c0a26 100644
--- a/engines/access/data.cpp
+++ b/engines/access/data.cpp
@@ -59,4 +59,18 @@ void TimerList::updateTimers() {
}
}
+void TimerList::synchronize(Common::Serializer &s) {
+ int count = size();
+ s.syncAsUint16LE(count);
+
+ if (!s.isSaving())
+ resize(count);
+
+ for (int i = 0; i < count; ++i) {
+ s.syncAsUint32LE((*this)[i]._initTm);
+ s.syncAsUint32LE((*this)[i]._timer);
+ s.syncAsByte((*this)[i]._flag);
+ }
+}
+
} // End of namespace Access
diff --git a/engines/access/data.h b/engines/access/data.h
index 1d64a6ff86..3b3485e459 100644
--- a/engines/access/data.h
+++ b/engines/access/data.h
@@ -26,6 +26,7 @@
#include "common/scummsys.h"
#include "common/array.h"
#include "common/rect.h"
+#include "common/serializer.h"
#include "common/types.h"
#include "graphics/surface.h"
#include "access/files.h"
@@ -74,6 +75,11 @@ public:
* Update the timer list
*/
void updateTimers();
+
+ /**
+ * Synchronize savegame data
+ */
+ void synchronize(Common::Serializer &s);
};
class ExtraCell {
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp
index dbc3cbac89..25c906056f 100644
--- a/engines/access/inventory.cpp
+++ b/engines/access/inventory.cpp
@@ -354,5 +354,15 @@ void InventoryManager::combineItems() {
warning("TODO: combineItems");
}
+void InventoryManager::synchronize(Common::Serializer &s) {
+ int count = _inv.size();
+ s.syncAsUint16LE(count);
+
+ if (!s.isSaving())
+ _inv.resize(count);
+
+ for (int i = 0; i < count; ++i)
+ s.syncAsUint16LE((*this)[i]);
+}
} // End of namespace Access
diff --git a/engines/access/inventory.h b/engines/access/inventory.h
index a95581c2d0..0ff9020250 100644
--- a/engines/access/inventory.h
+++ b/engines/access/inventory.h
@@ -108,6 +108,11 @@ public:
void refreshInventory();
int newDisplayInv();
+
+ /**
+ * Synchronize savegame data
+ */
+ void synchronize(Common::Serializer &s);
};
} // End of namespace Access
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index df2ad67826..b8eb08acd8 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -827,4 +827,12 @@ bool Player::scrollRight() {
return true;
}
+void Player::synchronize(Common::Serializer &s) {
+ s.syncAsUint16LE(_roomNumber);
+ s.syncAsSint16LE(_rawPlayerLow.x);
+ s.syncAsSint16LE(_rawPlayer.x);
+ s.syncAsSint16LE(_rawPlayerLow.y);
+ s.syncAsSint16LE(_rawPlayer.y);
+}
+
} // End of namespace Access
diff --git a/engines/access/player.h b/engines/access/player.h
index 7ba0c05b21..c5c9afa087 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "common/rect.h"
+#include "common/serializer.h"
#include "access/asurface.h"
#include "access/data.h"
@@ -127,6 +128,11 @@ public:
void calcPlayer();
void checkScroll();
+
+ /**
+ * Synchronize savegame data
+ */
+ void synchronize(Common::Serializer &s);
};
} // End of namespace Access
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 52d9d00e08..91910f2917 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -39,7 +39,7 @@ SoundManager::~SoundManager() {
}
void SoundManager::clearSounds() {
- for (int i = 0; i < _soundTable.size(); ++i)
+ for (uint i = 0; i < _soundTable.size(); ++i)
delete _soundTable[i];
_soundTable.clear();
_soundPriority.clear();