mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-03 00:35:54 +00:00
ACCESS: Add synchronize method for savegames
This commit is contained in:
parent
0ef365ab02
commit
8b9faf7de5
@ -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
|
||||
|
@ -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];
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
// Other game specific fields
|
||||
int _hintLevel;
|
||||
|
||||
// Saved fields
|
||||
int _chapter;
|
||||
|
||||
// Other game specific fields
|
||||
Guard _guard;
|
||||
Plane _plane;
|
||||
int _hintLevel;
|
||||
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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -108,6 +108,11 @@ public:
|
||||
void refreshInventory();
|
||||
|
||||
int newDisplayInv();
|
||||
|
||||
/**
|
||||
* Synchronize savegame data
|
||||
*/
|
||||
void synchronize(Common::Serializer &s);
|
||||
};
|
||||
|
||||
} // End of namespace Access
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user