aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2019-06-30 17:28:26 -0700
committerPaul Gilbert2019-07-06 15:27:08 -0700
commit18566feefcb9f4fa4d7395ffa6e6f2a6f0247d0e (patch)
tree38b0e02e10d0fb320947712a8b0650c97df0c4ef
parentec979b8555cfc10cca3858df2cca635c04f240d2 (diff)
downloadscummvm-rg350-18566feefcb9f4fa4d7395ffa6e6f2a6f0247d0e.tar.gz
scummvm-rg350-18566feefcb9f4fa4d7395ffa6e6f2a6f0247d0e.tar.bz2
scummvm-rg350-18566feefcb9f4fa4d7395ffa6e6f2a6f0247d0e.zip
GLK: ALAN3: Implement savegame code
-rw-r--r--engines/glk/alan3/acode.cpp35
-rw-r--r--engines/glk/alan3/acode.h6
-rw-r--r--engines/glk/alan3/alan3.cpp20
-rw-r--r--engines/glk/alan3/alan3.h5
-rw-r--r--engines/glk/alan3/current.cpp14
-rw-r--r--engines/glk/alan3/current.h5
-rw-r--r--engines/glk/alan3/event.cpp6
-rw-r--r--engines/glk/alan3/event.h14
-rw-r--r--engines/glk/alan3/instance.cpp15
-rw-r--r--engines/glk/alan3/instance.h6
-rw-r--r--engines/glk/alan3/inter.cpp4
-rw-r--r--engines/glk/alan3/save.cpp263
-rw-r--r--engines/glk/alan3/save.h7
-rw-r--r--engines/glk/module.mk1
14 files changed, 196 insertions, 205 deletions
diff --git a/engines/glk/alan3/acode.cpp b/engines/glk/alan3/acode.cpp
new file mode 100644
index 0000000000..3dbfaa5cc0
--- /dev/null
+++ b/engines/glk/alan3/acode.cpp
@@ -0,0 +1,35 @@
+/* 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 "glk/alan3/acode.h"
+
+namespace Glk {
+namespace Alan3 {
+
+void AttributeEntry::synchronize(Common::Serializer &s) {
+ s.syncAsSint32LE(code);
+ s.syncAsSint32LE(value);
+ s.syncAsSint32LE(id);
+}
+
+} // End of namespace Alan3
+} // End of namespace Glk
diff --git a/engines/glk/alan3/acode.h b/engines/glk/alan3/acode.h
index 7aa1d8e92d..6e663fabd0 100644
--- a/engines/glk/alan3/acode.h
+++ b/engines/glk/alan3/acode.h
@@ -24,6 +24,7 @@
#define GLK_ACODE
#include "common/scummsys.h"
+#include "common/serializer.h"
namespace Glk {
namespace Alan3 {
@@ -370,6 +371,11 @@ struct AttributeEntry { /* ATTRIBUTE LIST */
string pointer, a set has a pointer
to a dynamically allocated set */
Aaddr id; /* Address to the name */
+
+ /**
+ * Save/resotre data from save file
+ */
+ void synchronize(Common::Serializer &s);
} PACKED_STRUCT;
struct AttributeHeaderEntry { /* ATTRIBUTE LIST in header */
diff --git a/engines/glk/alan3/alan3.cpp b/engines/glk/alan3/alan3.cpp
index bbcd6da7f5..7fc7e8416a 100644
--- a/engines/glk/alan3/alan3.cpp
+++ b/engines/glk/alan3/alan3.cpp
@@ -26,6 +26,7 @@
#include "glk/alan3/glkio.h"
#include "glk/alan3/options.h"
#include "glk/alan3/output.h"
+#include "glk/alan3/save.h"
#include "glk/alan3/syserr.h"
#include "common/system.h"
#include "common/config-manager.h"
@@ -131,29 +132,14 @@ void Alan3::deinitialize() {
}
Common::Error Alan3::readSaveData(Common::SeekableReadStream *rs) {
- Common::Serializer s(rs, nullptr);
- synchronizeSave(s);
-
+ Glk::Alan3::restoreGame(rs);
return Common::kNoError;
}
Common::Error Alan3::writeGameData(Common::WriteStream *ws) {
- Common::Serializer s(nullptr, ws);
- synchronizeSave(s);
-
- ws->flush();
+ Glk::Alan3::saveGame(ws);
return Common::kNoError;
}
-// This works around gcc errors for passing packed structure fields
-void syncVal(Common::Serializer &s, uint32 *fld) {
- uint32 &v = *fld;
- s.syncAsUint32LE(v);
-}
-
-void Alan3::synchronizeSave(Common::Serializer &s) {
- // TODO
-}
-
} // End of namespace Alan3
} // End of namespace Glk
diff --git a/engines/glk/alan3/alan3.h b/engines/glk/alan3/alan3.h
index 6693476b3c..73a9a03d0b 100644
--- a/engines/glk/alan3/alan3.h
+++ b/engines/glk/alan3/alan3.h
@@ -47,11 +47,6 @@ private:
* Deinitialization
*/
void deinitialize();
-
- /**
- * Synchronize data to or from a save file
- */
- void synchronizeSave(Common::Serializer &s);
public:
/**
* Constructor
diff --git a/engines/glk/alan3/current.cpp b/engines/glk/alan3/current.cpp
index 7c2dfe2d66..37b568222e 100644
--- a/engines/glk/alan3/current.cpp
+++ b/engines/glk/alan3/current.cpp
@@ -29,5 +29,19 @@ namespace Alan3 {
CurVars current;
bool gameStateChanged = FALSE;
+void CurVars::synchronize(Common::Serializer &s) {
+ s.syncAsSint32LE(syntax);
+ s.syncAsSint32LE(verb);
+ s.syncAsSint32LE(location);
+ s.syncAsSint32LE(actor);
+ s.syncAsSint32LE(instance);
+ s.syncAsSint32LE(tick);
+ s.syncAsSint32LE(score);
+ s.syncAsSint32LE(visits);
+ s.syncAsSint32LE(sourceLine);
+ s.syncAsSint32LE(sourceFile);
+ s.syncAsUint32LE(meta);
+}
+
} // End of namespace Alan3
} // End of namespace Glk
diff --git a/engines/glk/alan3/current.h b/engines/glk/alan3/current.h
index 8c986531b2..91a217b311 100644
--- a/engines/glk/alan3/current.h
+++ b/engines/glk/alan3/current.h
@@ -41,6 +41,11 @@ struct CurVars {
sourceLine,
sourceFile;
bool meta;
+
+ /**
+ * Save/load data from save file
+ */
+ void synchronize(Common::Serializer &s);
};
/* DATA */
diff --git a/engines/glk/alan3/event.cpp b/engines/glk/alan3/event.cpp
index ce866be6e9..73d7d9d876 100644
--- a/engines/glk/alan3/event.cpp
+++ b/engines/glk/alan3/event.cpp
@@ -31,5 +31,11 @@ EventQueueEntry *eventQueue = NULL;
int eventQueueTop = 0;
EventEntry *events;
+void EventQueueEntry::synchronize(Common::Serializer &s) {
+ s.syncAsSint32LE(after);
+ s.syncAsSint32LE(event);
+ s.syncAsSint32LE(where);
+}
+
} // End of namespace Alan3
} // End of namespace Glk
diff --git a/engines/glk/alan3/event.h b/engines/glk/alan3/event.h
index 0a76d3c8c2..e0199f013b 100644
--- a/engines/glk/alan3/event.h
+++ b/engines/glk/alan3/event.h
@@ -23,18 +23,26 @@
#ifndef GLK_ALAN3_EVENT
#define GLK_ALAN3_EVENT
+#include "common/serializer.h"
#include "glk/alan3/acode.h"
#include "glk/alan3/types.h"
namespace Glk {
namespace Alan3 {
-/* TYPES */
-typedef struct EventQueueEntry { /* EVENT QUEUE ENTRIES */
+/**
+ * Event queue entries
+ */
+struct EventQueueEntry {
int after;
int event;
int where;
-} EventQueueEntry;
+
+ /**
+ * Save/load from a save file
+ */
+ void synchronize(Common::Serializer &s);
+};
/* DATA */
diff --git a/engines/glk/alan3/instance.cpp b/engines/glk/alan3/instance.cpp
index 89e3659c93..05ccd694bf 100644
--- a/engines/glk/alan3/instance.cpp
+++ b/engines/glk/alan3/instance.cpp
@@ -52,6 +52,21 @@ AttributeEntry *attributes; /* Dynamic attribute values */
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+void AdminEntry::synchronize(Common::Serializer &s) {
+ s.syncAsUint32LE(location);
+
+ Aword attr = 0;
+ s.syncAsUint32LE(attr);
+
+ s.syncAsUint32LE(alreadyDescribed);
+ s.syncAsUint32LE(visitsCount);
+ s.syncAsUint32LE(script);
+ s.syncAsUint32LE(step);
+ s.syncAsUint32LE(waitCount);
+}
+
+/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+
/* Instance query methods */
/*======================================================================*/
diff --git a/engines/glk/alan3/instance.h b/engines/glk/alan3/instance.h
index 6c62bb56d7..bd4319518d 100644
--- a/engines/glk/alan3/instance.h
+++ b/engines/glk/alan3/instance.h
@@ -23,6 +23,7 @@
#ifndef GLK_ALAN3_INSTANCE
#define GLK_ALAN3_INSTANCE
+#include "common/serializer.h"
#include "glk/alan3/acode.h"
#include "glk/alan3/types.h"
#include "glk/alan3/set.h"
@@ -39,6 +40,11 @@ struct AdminEntry { /* Administrative data about instances */
Aint script;
Aint step;
Aint waitCount;
+
+ /**
+ * Save/Restore data
+ */
+ void synchronize(Common::Serializer &s);
};
diff --git a/engines/glk/alan3/inter.cpp b/engines/glk/alan3/inter.cpp
index 042144204f..22198546f2 100644
--- a/engines/glk/alan3/inter.cpp
+++ b/engines/glk/alan3/inter.cpp
@@ -601,13 +601,13 @@ void interpret(Aaddr adr) {
case I_SAVE: {
if (traceInstructionOption)
printf("SAVE\t\t\t\t\t\t");
- save();
+ g_vm->saveGame();
break;
}
case I_RESTORE: {
if (traceInstructionOption)
printf("RESTORE\t\t\t\t\t\t");
- restore();
+ g_vm->loadGame();
break;
}
case I_RESTART: {
diff --git a/engines/glk/alan3/save.cpp b/engines/glk/alan3/save.cpp
index 506cf9ded0..0d33ea6959 100644
--- a/engines/glk/alan3/save.cpp
+++ b/engines/glk/alan3/save.cpp
@@ -20,14 +20,24 @@
*
*/
+#include "glk/alan3/save.h"
+#include "glk/alan3/acode.h"
+#include "glk/alan3/args.h"
+#include "glk/alan3/current.h"
+#include "glk/alan3/event.h"
+#include "glk/alan3/instance.h"
+#include "glk/alan3/lists.h"
+#include "glk/alan3/memory.h"
+#include "glk/alan3/msg.h"
+#include "glk/alan3/options.h"
+#include "glk/alan3/score.h"
+#include "glk/alan3/types.h"
+
namespace Glk {
namespace Alan3 {
-#ifdef TODO
-
/*----------------------------------------------------------------------*/
-static void saveStrings(AFILE saveFile) {
-
+static void saveStrings(Common::WriteStream *saveFile) {
StringInitEntry *initEntry;
if (header->stringInitTable != 0)
@@ -35,68 +45,77 @@ static void saveStrings(AFILE saveFile) {
!isEndOfArray(initEntry); initEntry++) {
char *attr = (char *)getInstanceStringAttribute(initEntry->instanceCode, initEntry->attributeCode);
Aint length = strlen(attr) + 1;
- fwrite((void *)&length, sizeof(length), 1, saveFile);
- fwrite((void *)attr, 1, length, saveFile);
+ saveFile->writeUint32LE(length);
+ saveFile->write(attr, length);
}
}
/*----------------------------------------------------------------------*/
-static void saveSets(AFILE saveFile) {
+static void saveSets(Common::WriteStream *saveFile) {
SetInitEntry *initEntry;
if (header->setInitTable != 0)
for (initEntry = (SetInitEntry *)pointerTo(header->setInitTable);
!isEndOfArray(initEntry); initEntry++) {
Set *attr = (Set *)getInstanceSetAttribute(initEntry->instanceCode, initEntry->attributeCode);
- fwrite((void *)&attr->size, sizeof(attr->size), 1, saveFile);
- fwrite((void *)attr->members, sizeof(attr->members[0]), attr->size, saveFile);
+ saveFile->writeUint32LE(attr->size);
+ saveFile->write(attr->members, attr->size);
}
}
/*----------------------------------------------------------------------*/
-static void saveGameInfo(AFILE saveFile) {
- fwrite((void *)"ASAV", 1, 4, saveFile);
- fwrite((void *)&header->version, 1, sizeof(Aword), saveFile);
- fwrite((void *)adventureName, 1, strlen(adventureName) + 1, saveFile);
- fwrite((void *)&header->uid, 1, sizeof(Aword), saveFile);
+static void saveGameInfo(Common::WriteStream *saveFile) {
+ saveFile->writeUint32BE(MKTAG('A', 'S', 'A', 'V'));
+ saveFile->write(header->version, 4);
+ saveFile->write(adventureName, strlen(adventureName) + 1);
+ saveFile->writeUint32LE(header->uid);
}
/*----------------------------------------------------------------------*/
-static void saveAdmin(AFILE saveFile) {
- fwrite((void *)&admin[1], sizeof(AdminEntry), header->instanceMax, saveFile);
+static void saveAdmin(Common::WriteStream *saveFile) {
+ Common::Serializer s(nullptr, saveFile);
+ for (uint i = 1; i <= header->instanceMax; i++)
+ admin[i].synchronize(s);
}
/*----------------------------------------------------------------------*/
-static void saveAttributeArea(AFILE saveFile) {
- fwrite((void *)attributes, header->attributesAreaSize, sizeof(Aword), saveFile);
+static void saveAttributeArea(Common::WriteStream *saveFile) {
+ Common::Serializer s(nullptr, saveFile);
+ for (Aint i = 0; i < header->attributesAreaSize; ++i)
+ attributes[i].synchronize(s);
}
/*----------------------------------------------------------------------*/
-static void saveEventQueue(AFILE saveFile) {
- fwrite((void *)&eventQueueTop, sizeof(eventQueueTop), 1, saveFile);
- fwrite((void *)&eventQueue[0], sizeof(eventQueue[0]), eventQueueTop, saveFile);
+static void saveEventQueue(Common::WriteStream *saveFile) {
+ Common::Serializer s(nullptr, saveFile);
+
+ s.syncAsSint32LE(eventQueueTop);
+ for (int i = 0; i < eventQueueTop; ++i)
+ eventQueue[i].synchronize(s);
}
/*----------------------------------------------------------------------*/
-static void saveCurrentValues(AFILE saveFile) {
- fwrite((void *)&current, sizeof(current), 1, saveFile);
+static void saveCurrentValues(Common::WriteStream *saveFile) {
+ Common::Serializer s(nullptr, saveFile);
+ current.synchronize(s);
}
/*----------------------------------------------------------------------*/
-static void saveScores(AFILE saveFile) {
- fwrite((void *)scores, sizeof(Aword), header->scoreCount, saveFile);
+static void saveScores(Common::WriteStream *saveFile) {
+ for (Aint i = 0; i < header->scoreCount; ++i)
+ saveFile->writeUint32LE(scores[i]);
}
/*----------------------------------------------------------------------*/
-static void saveGame(AFILE saveFile) {
+void saveGame(Common::WriteStream *saveFile) {
/* Save tag, version of interpreter, name and uid of game */
saveGameInfo(saveFile);
@@ -115,88 +134,34 @@ static void saveGame(AFILE saveFile) {
}
-/*======================================================================*/
-void save(void) {
-#ifdef HAVE_GLK
- frefid_t saveFileRef;
- strid_t saveFile;
- saveFileRef = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Write, 0);
- if (saveFileRef == NULL)
- error(M_SAVEFAILED);
- saveFile = glk_stream_open_file(saveFileRef, filemode_Write, 0);
-
-#else
- FILE *saveFile;
- char str[256];
-
- current.location = where(HERO, DIRECT);
- /* First save ? */
- if (saveFileName[0] == '\0') {
- strcpy(saveFileName, adventureName);
- strcat(saveFileName, ".sav");
- }
- printMessage(M_SAVEWHERE);
- sprintf(str, "(%s) : ", saveFileName);
- output(str);
-#ifdef USE_READLINE
- readline(str);
-#else
- gets(str);
-#endif
- if (str[0] == '\0')
- strcpy(str, saveFileName);
- col = 1;
- if ((saveFile = fopen(str, READ_MODE)) != NULL)
- /* It already existed */
- if (!regressionTestOption) {
- /* Ask for overwrite confirmation */
- if (!confirm(M_SAVEOVERWRITE))
- abortPlayerCommand(); /* Return to player without saying anything */
- }
- strcpy(saveFileName, str);
- if ((saveFile = fopen(saveFileName, WRITE_MODE)) == NULL)
- error(M_SAVEFAILED);
-#endif
-
- saveGame(saveFile);
-
- fclose(saveFile);
-}
-
-
/*----------------------------------------------------------------------*/
-static void restoreStrings(AFILE saveFile) {
+static void restoreStrings(Common::SeekableReadStream *saveFile) {
StringInitEntry *initEntry;
if (header->stringInitTable != 0)
for (initEntry = (StringInitEntry *)pointerTo(header->stringInitTable);
!isEndOfArray(initEntry); initEntry++) {
- Aint length;
- char *string;
- fread((void *)&length, sizeof(Aint), 1, saveFile);
- string = allocate(length + 1);
- fread((void *)string, 1, length, saveFile);
+ Aint length = saveFile->readUint32LE();
+ char *string = (char *)allocate(length + 1);
+
+ saveFile->read(string, length);
setInstanceAttribute(initEntry->instanceCode, initEntry->attributeCode, toAptr(string));
}
}
/*----------------------------------------------------------------------*/
-static void restoreSets(AFILE saveFile) {
+static void restoreSets(Common::SeekableReadStream *saveFile) {
SetInitEntry *initEntry;
if (header->setInitTable != 0)
for (initEntry = (SetInitEntry *)pointerTo(header->setInitTable);
!isEndOfArray(initEntry); initEntry++) {
- Aint setSize;
- Set *set;
- int i;
-
- fread((void *)&setSize, sizeof(setSize), 1, saveFile);
- set = newSet(setSize);
- for (i = 0; i < setSize; i++) {
- Aword member;
- fread((void *)&member, sizeof(member), 1, saveFile);
+ Aint setSize = saveFile->readUint32LE();
+ Set *set = newSet(setSize);
+
+ for (int i = 0; i < setSize; i++) {
+ Aword member = saveFile->readUint32LE();
addToSet(set, member);
}
setInstanceAttribute(initEntry->instanceCode, initEntry->attributeCode, toAptr(set));
@@ -205,92 +170,91 @@ static void restoreSets(AFILE saveFile) {
/*----------------------------------------------------------------------*/
-static void restoreScores(AFILE saveFile) {
- fread((void *)scores, sizeof(Aword), header->scoreCount, saveFile);
+static void restoreScores(Common::SeekableReadStream *saveFile) {
+ for (Aint i = 0; i < header->scoreCount; ++i)
+ scores[i] = saveFile->readUint32LE();
}
/*----------------------------------------------------------------------*/
-static void restoreEventQueue(AFILE saveFile) {
- fread((void *)&eventQueueTop, sizeof(eventQueueTop), 1, saveFile);
- if (eventQueueTop > eventQueueSize) {
- deallocate(eventQueue);
- eventQueue = allocate(eventQueueTop * sizeof(eventQueue[0]));
- }
- fread((void *)&eventQueue[0], sizeof(eventQueue[0]), eventQueueTop, saveFile);
+static void restoreEventQueue(Common::SeekableReadStream *saveFile) {
+ Common::Serializer s(saveFile, nullptr);
+
+ s.syncAsSint32LE(eventQueueTop);
+ for (int i = 0; i < eventQueueTop; ++i)
+ eventQueue[i].synchronize(s);
}
/*----------------------------------------------------------------------*/
-static void restoreAdmin(AFILE saveFile) {
- /* Restore admin for instances, remember to reset attribute area pointer */
- int i;
- for (i = 1; i <= header->instanceMax; i++) {
+static void restoreAdmin(Common::SeekableReadStream *saveFile) {
+ // Restore admin for instances, remember to reset attribute area pointer
+ Common::Serializer s(saveFile, nullptr);
+ for (uint i = 1; i <= header->instanceMax; i++) {
AttributeEntry *currentAttributesArea = admin[i].attributes;
- fread((void *)&admin[i], sizeof(AdminEntry), 1, saveFile);
+ admin[i].synchronize(s);
admin[i].attributes = currentAttributesArea;
}
}
/*----------------------------------------------------------------------*/
-static void restoreAttributeArea(AFILE saveFile) {
- fread((void *)attributes, header->attributesAreaSize, sizeof(Aword), saveFile);
+static void restoreAttributeArea(Common::SeekableReadStream *saveFile) {
+ Common::Serializer s(saveFile, nullptr);
+ for (Aint i = 0; i < header->attributesAreaSize; ++i)
+ attributes[i].synchronize(s);
}
/*----------------------------------------------------------------------*/
-static void restoreCurrentValues(AFILE saveFile) {
- fread((void *)&current, sizeof(current), 1, saveFile);
+static void restoreCurrentValues(Common::SeekableReadStream *saveFile) {
+ Common::Serializer s(saveFile, nullptr);
+ current.synchronize(s);
}
/*----------------------------------------------------------------------*/
-static void verifyGameId(AFILE saveFile) {
- Aword savedUid;
-
- fread((void *)&savedUid, sizeof(Aword), 1, saveFile);
+static void verifyGameId(Common::SeekableReadStream *saveFile) {
+ Aword savedUid = saveFile->readUint32LE();
if (!ignoreErrorOption && savedUid != header->uid)
error(M_SAVEVERS);
}
/*----------------------------------------------------------------------*/
-static void verifyGameName(AFILE saveFile) {
+static void verifyGameName(Common::SeekableReadStream *saveFile) {
char savedName[256];
int i = 0;
- while ((savedName[i++] = fgetc(saveFile)) != '\0');
+ while ((savedName[i++] = saveFile->readByte()) != '\0');
if (strcmp(savedName, adventureName) != 0)
error(M_SAVENAME);
}
/*----------------------------------------------------------------------*/
-static void verifyCompilerVersion(AFILE saveFile) {
+static void verifyCompilerVersion(Common::SeekableReadStream *saveFile) {
char savedVersion[4];
- fread((void *)&savedVersion, sizeof(Aword), 1, saveFile);
- if (!ignoreErrorOption && strncmp(savedVersion, header->version, 4))
+ saveFile->read(&savedVersion, 4);
+ if (!ignoreErrorOption && memcmp(savedVersion, header->version, 4))
error(M_SAVEVERS);
}
/*----------------------------------------------------------------------*/
-static void verifySaveFile(AFILE saveFile) {
- char string[256];
-
- fread((void *)&string, 1, 4, saveFile);
+static void verifySaveFile(Common::SeekableReadStream *saveFile) {
+ char string[5];
+ saveFile->read(string, 4);
string[4] = '\0';
+
if (strcmp(string, "ASAV") != 0)
error(M_NOTASAVEFILE);
}
/*----------------------------------------------------------------------*/
-static void restoreGame(AFILE saveFile) {
- if (saveFile == NULL) syserr("'restoreGame()' from a null fileref");
-
+void restoreGame(Common::SeekableReadStream *saveFile) {
verifySaveFile(saveFile);
/* Verify version of compiler/interpreter of saved game with us */
@@ -311,54 +275,5 @@ static void restoreGame(AFILE saveFile) {
restoreSets(saveFile);
}
-
-/*======================================================================*/
-void restore(void) {
-#ifdef HAVE_GLK
- frefid_t saveFileRef;
- strid_t saveFile;
- saveFileRef = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Read, 0);
- if (saveFileRef == NULL) return;
- saveFile = glk_stream_open_file(saveFileRef, filemode_Read, 0);
- if (saveFile == NULL) return;
-
-#else
- char str[1000];
- FILE *saveFile;
-
- current.location = where(HERO, DIRECT);
- /* First save ? */
- if (saveFileName[0] == '\0') {
- strcpy(saveFileName, adventureName);
- strcat(saveFileName, ".sav");
- }
- printMessage(M_RESTOREFROM);
- sprintf(str, "(%s) : ", saveFileName);
- output(str);
-#ifdef USE_READLINE
- readline(str);
-#else
- gets(str);
-#endif
-
- col = 1;
- if (str[0] == '\0') {
- strcpy(str, saveFileName);
- }
- if ((saveFile = fopen(str, READ_MODE)) == NULL)
- error(M_SAVEMISSING);
- strcpy(saveFileName, str); /* Save it for future use */
-
-#endif
-
- restoreGame(saveFile);
-
- fclose(saveFile);
-}
-#else
-void save() {}
-void restore() {}
-#endif
-
} // End of namespace Alan3
} // End of namespace Glk
diff --git a/engines/glk/alan3/save.h b/engines/glk/alan3/save.h
index 3f12f05ccc..e4b00f6746 100644
--- a/engines/glk/alan3/save.h
+++ b/engines/glk/alan3/save.h
@@ -23,14 +23,13 @@
#ifndef GLK_ALAN3_SAVE
#define GLK_ALAN3_SAVE
-/* Header file for save and restore unit in Alan interpreter */
+#include "common/stream.h"
namespace Glk {
namespace Alan3 {
-/* Functions: */
-extern void save();
-extern void restore();
+extern void saveGame(Common::WriteStream *saveFile);
+extern void restoreGame(Common::SeekableReadStream *saveFile);
} // End of namespace Alan3
} // End of namespace Glk
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index 902b9fc3bd..65ddd80f6a 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -49,6 +49,7 @@ MODULE_OBJS := \
alan2/sysdep.o \
alan2/term.o \
alan2/types.o \
+ alan3/acode.o \
alan3/act.o \
alan3/actor.o \
alan3/alan3.o \