diff options
author | Sven Hesse | 2010-02-03 09:32:16 +0000 |
---|---|---|
committer | Sven Hesse | 2010-02-03 09:32:16 +0000 |
commit | 9cad13957da8a67e68dd4e268eb53f8e413eb4be (patch) | |
tree | 6a806d398ca22e0e587e69a5208fe6461953c602 /engines/gob | |
parent | e7d5849ac88c78189eac18e7480e09b00ed5602c (diff) | |
download | scummvm-rg350-9cad13957da8a67e68dd4e268eb53f8e413eb4be.tar.gz scummvm-rg350-9cad13957da8a67e68dd4e268eb53f8e413eb4be.tar.bz2 scummvm-rg350-9cad13957da8a67e68dd4e268eb53f8e413eb4be.zip |
Implementing saving/loading for Fascination. Tested in the DOS floppy versions and the Amiga version
svn-id: r47845
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/gob.cpp | 3 | ||||
-rw-r--r-- | engines/gob/module.mk | 1 | ||||
-rw-r--r-- | engines/gob/save/saveload.h | 12 | ||||
-rw-r--r-- | engines/gob/save/saveload_fascin.cpp | 130 |
4 files changed, 70 insertions, 76 deletions
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index b600b5b416..81b15f6d57 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -378,8 +378,7 @@ bool GobEngine::initGameParts() { _map = new Map_v2(this); _goblin = new Goblin_v2(this); _scenery = new Scenery_v2(this); - _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); -// _saveLoad = new SaveLoad_Fascination(this, _targetName.c_str()); + _saveLoad = new SaveLoad_Fascination(this, _targetName.c_str()); break; case kGameTypeWeen: diff --git a/engines/gob/module.mk b/engines/gob/module.mk index e9bf353305..69e7dbcf52 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -66,6 +66,7 @@ MODULE_OBJS := \ save/saveload_v3.o \ save/saveload_v4.o \ save/saveload_v6.o \ + save/saveload_fascin.o \ save/saveload_playtoons.o \ save/saveconverter.o \ save/saveconverter_v2.o \ diff --git a/engines/gob/save/saveload.h b/engines/gob/save/saveload.h index 82988e9c23..de64be36f0 100644 --- a/engines/gob/save/saveload.h +++ b/engines/gob/save/saveload.h @@ -153,6 +153,7 @@ protected: struct SaveFile { const char *sourceName; SaveMode mode; + int slot; SaveHandler *handler; const char *description; }; @@ -160,7 +161,7 @@ protected: /** Handles the save slots. */ class GameHandler : public SaveHandler { public: - GameHandler(GobEngine *vm, const char *target); + GameHandler(GobEngine *vm, const char *target, int slot, byte *index, bool *hasIndex); ~GameHandler(); int32 getSize(); @@ -178,17 +179,20 @@ protected: int getSlotRemainder(int32 offset) const; }; - byte _index[kIndexSize]; - bool _hasIndex; + byte *_index; + bool *_hasIndex; + int _slot; File *_slotFile; void buildIndex(byte *buffer) const; }; + byte _index[kIndexSize]; + bool _hasIndex; + static SaveFile _saveFiles[]; - GameHandler *_gameHandler; NotesHandler *_notesHandler; TempSpriteHandler *_tempSpriteHandler; diff --git a/engines/gob/save/saveload_fascin.cpp b/engines/gob/save/saveload_fascin.cpp index d6c9885bf5..6c3d22ecf3 100644 --- a/engines/gob/save/saveload_fascin.cpp +++ b/engines/gob/save/saveload_fascin.cpp @@ -31,22 +31,22 @@ namespace Gob { SaveLoad_Fascination::SaveFile SaveLoad_Fascination::_saveFiles[] = { - { "cat.cat", kSaveModeSave, 0, "savegame catalog"}, - { "save0.inf", kSaveModeSave, 0, "savegame"}, - { "save1.inf", kSaveModeSave, 0, "savegame"}, - { "save2.inf", kSaveModeSave, 0, "savegame"}, - { "save3.inf", kSaveModeSave, 0, "savegame"}, - { "save4.inf", kSaveModeSave, 0, "savegame"}, - { "save5.inf", kSaveModeSave, 0, "savegame"}, - { "save6.inf", kSaveModeSave, 0, "savegame"}, - { "save7.inf", kSaveModeSave, 0, "savegame"}, - { "save8.inf", kSaveModeSave, 0, "savegame"}, - { "save9.inf", kSaveModeSave, 0, "savegame"}, - { "save10.inf", kSaveModeSave, 0, "savegame"}, - { "save11.inf", kSaveModeSave, 0, "savegame"}, - { "save12.inf", kSaveModeSave, 0, "savegame"}, - { "save13.inf", kSaveModeSave, 0, "savegame"}, - { "save14.inf", kSaveModeSave, 0, "savegame"}, + { "cat.cat", kSaveModeSave, -1, 0, "savegame catalog"}, + { "save0.inf", kSaveModeSave, 0, 0, "savegame"}, + { "save1.inf", kSaveModeSave, 1, 0, "savegame"}, + { "save2.inf", kSaveModeSave, 2, 0, "savegame"}, + { "save3.inf", kSaveModeSave, 3, 0, "savegame"}, + { "save4.inf", kSaveModeSave, 4, 0, "savegame"}, + { "save5.inf", kSaveModeSave, 5, 0, "savegame"}, + { "save6.inf", kSaveModeSave, 6, 0, "savegame"}, + { "save7.inf", kSaveModeSave, 7, 0, "savegame"}, + { "save8.inf", kSaveModeSave, 8, 0, "savegame"}, + { "save9.inf", kSaveModeSave, 9, 0, "savegame"}, + { "save10.inf", kSaveModeSave, 10, 0, "savegame"}, + { "save11.inf", kSaveModeSave, 11, 0, "savegame"}, + { "save12.inf", kSaveModeSave, 12, 0, "savegame"}, + { "save13.inf", kSaveModeSave, 13, 0, "savegame"}, + { "save14.inf", kSaveModeSave, 14, 0, "savegame"}, }; @@ -58,27 +58,21 @@ SaveLoad_Fascination::GameHandler::File::~File() { } int SaveLoad_Fascination::GameHandler::File::getSlot(int32 offset) const { - uint32 varSize = SaveHandler::getVarSize(_vm); - - if (varSize == 0) - return -1; - - return ((offset - kIndexSize) / varSize); + return ((offset - kIndexSize) / 320); } int SaveLoad_Fascination::GameHandler::File::getSlotRemainder(int32 offset) const { - uint32 varSize = SaveHandler::getVarSize(_vm); + return ((offset - kIndexSize) % 320); +} - if (varSize == 0) - return -1; - return ((offset - kIndexSize) % varSize); -} +SaveLoad_Fascination::GameHandler::GameHandler(GobEngine *vm, const char *target, + int slot, byte *index, bool *hasIndex) : SaveHandler(vm) { + _index = index; + _hasIndex = hasIndex; -SaveLoad_Fascination::GameHandler::GameHandler(GobEngine *vm, const char *target) : SaveHandler(vm) { - memset(_index, 0, kIndexSize); - _hasIndex = false; + _slot = slot; _slotFile = new File(vm, target); } @@ -108,7 +102,7 @@ bool SaveLoad_Fascination::GameHandler::load(int16 dataVar, int32 size, int32 of size = varSize; } - if (offset == 0) { + if ((offset == 0) && (_slot == -1)) { // Save index if (((uint32) size) != kIndexSize) { @@ -120,16 +114,18 @@ bool SaveLoad_Fascination::GameHandler::load(int16 dataVar, int32 size, int32 of buildIndex(_vm->_inter->_variables->getAddressOff8(dataVar)); } else { - // Save slot, whole variable block + // Load slot - uint32 slot = _slotFile->getSlot(offset); - int slotRem = _slotFile->getSlotRemainder(offset); + uint32 slot = _slot; + int slotRem = 0; + if (_slot == -1) { + slot = _slotFile->getSlot(offset); + slotRem = _slotFile->getSlotRemainder(offset); + } debugC(2, kDebugSaveLoad, "Loading from slot %d", slot); - if ((slot >= kSlotCount) || (slotRem != 0) || - (dataVar != 0) || (((uint32) size) != varSize)) { - + if ((slot >= kSlotCount) || (slotRem != 0) || (size != 320)) { warning("Invalid loading procedure (%d, %d, %d, %d, %d)", dataVar, size, offset, slot, slotRem); return false; @@ -144,7 +140,7 @@ bool SaveLoad_Fascination::GameHandler::load(int16 dataVar, int32 size, int32 of SavePartInfo info(kSlotNameLength, (uint32) _vm->getGameType(), 0, _vm->getEndianness(), varSize); - SavePartVars vars(_vm, varSize); + SavePartVars vars(_vm, size); if (!reader->load()) { delete reader; @@ -161,7 +157,7 @@ bool SaveLoad_Fascination::GameHandler::load(int16 dataVar, int32 size, int32 of } // Get all variables - if (!vars.writeInto(0, 0, varSize)) { + if (!vars.writeInto(dataVar, 0, size)) { delete reader; return false; } @@ -173,6 +169,10 @@ bool SaveLoad_Fascination::GameHandler::load(int16 dataVar, int32 size, int32 of } bool SaveLoad_Fascination::GameHandler::save(int16 dataVar, int32 size, int32 offset) { + if ((_slot == -1) && (offset == 0) && (size == 5400)) + // Initialize empty file + return true; + uint32 varSize = SaveHandler::getVarSize(_vm); if (varSize == 0) @@ -184,7 +184,7 @@ bool SaveLoad_Fascination::GameHandler::save(int16 dataVar, int32 size, int32 of size = varSize; } - if (offset == 0) { + if ((offset == 0) && (_slot == -1)) { // Save index if (((uint32) size) != kIndexSize) { @@ -194,43 +194,45 @@ bool SaveLoad_Fascination::GameHandler::save(int16 dataVar, int32 size, int32 of // Just copy the index into our buffer _vm->_inter->_variables->copyTo(dataVar, _index, kIndexSize); - _hasIndex = true; + *_hasIndex = true; } else { - // Save slot, whole variable block + // Save slot - uint32 slot = _slotFile->getSlot(offset); - int slotRem = _slotFile->getSlotRemainder(offset); + uint32 slot = _slot; + int slotRem = 0; + if (_slot == -1) { + slot = _slotFile->getSlot(offset); + slotRem = _slotFile->getSlotRemainder(offset); + } debugC(2, kDebugSaveLoad, "Saving to slot %d", slot); - if ((slot >= kSlotCount) || (slotRem != 0) || - (dataVar != 0) || (((uint32) size) != varSize)) { - + if ((slot >= kSlotCount) || (slotRem != 0) || (size != 320)) { warning("Invalid saving procedure (%d, %d, %d, %d, %d)", dataVar, size, offset, slot, slotRem); return false; } // An index is needed for the save slot description - if (!_hasIndex) { + if (!*_hasIndex) { warning("No index written yet"); return false; } - _hasIndex = false; + *_hasIndex = false; Common::String slotFile = _slotFile->build(slot); SaveWriter writer(2, slot, slotFile); SavePartInfo info(kSlotNameLength, (uint32) _vm->getGameType(), 0, _vm->getEndianness(), varSize); - SavePartVars vars(_vm, varSize); + SavePartVars vars(_vm, size); // Write the description info.setDesc(_index + (slot * kSlotNameLength), kSlotNameLength); // Write all variables - if (!vars.readFrom(0, 0, varSize)) + if (!vars.readFrom(dataVar, 0, size)) return false; if (!writer.writePart(0, &info)) @@ -258,28 +260,16 @@ void SaveLoad_Fascination::GameHandler::buildIndex(byte *buffer) const { SaveLoad_Fascination::SaveLoad_Fascination(GobEngine *vm, const char *targetName) : SaveLoad(vm) { - _gameHandler = new GameHandler(vm, targetName); - - _saveFiles[0].handler = _gameHandler; - _saveFiles[1].handler = _gameHandler; - _saveFiles[2].handler = _gameHandler; - _saveFiles[3].handler = _gameHandler; - _saveFiles[4].handler = _gameHandler; - _saveFiles[5].handler = _gameHandler; - _saveFiles[6].handler = _gameHandler; - _saveFiles[7].handler = _gameHandler; - _saveFiles[8].handler = _gameHandler; - _saveFiles[9].handler = _gameHandler; - _saveFiles[10].handler = _gameHandler; - _saveFiles[11].handler = _gameHandler; - _saveFiles[12].handler = _gameHandler; - _saveFiles[13].handler = _gameHandler; - _saveFiles[14].handler = _gameHandler; - _saveFiles[15].handler = _gameHandler; + memset(_index, 0, kIndexSize); + _hasIndex = false; + + for (int i = 0; i < 16; i++) + _saveFiles[i].handler = new GameHandler(vm, targetName, _saveFiles[i].slot, _index, &_hasIndex); } SaveLoad_Fascination::~SaveLoad_Fascination() { - delete _gameHandler; + for (int i = 0; i < 16; i++) + delete _saveFiles[i].handler; } const SaveLoad_Fascination::SaveFile *SaveLoad_Fascination::getSaveFile(const char *fileName) const { |