aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2019-06-16 08:41:10 -0700
committerPaul Gilbert2019-06-16 14:59:26 -0700
commit3acba22cba5831b641b0bdaab26c337327d5911e (patch)
treebcc0d5148c33650ba09163a4c68a06f97fa5364c /engines
parentdbc0a5ff091ae880bfa0098afbfc90796e178230 (diff)
downloadscummvm-rg350-3acba22cba5831b641b0bdaab26c337327d5911e.tar.gz
scummvm-rg350-3acba22cba5831b641b0bdaab26c337327d5911e.tar.bz2
scummvm-rg350-3acba22cba5831b641b0bdaab26c337327d5911e.zip
GLK: FROTZ: Move creation of Quetzal ANNO chunk into base Quetzal writer
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/frotz/quetzal.cpp9
-rw-r--r--engines/glk/quetzal.cpp32
-rw-r--r--engines/glk/quetzal.h7
3 files changed, 38 insertions, 10 deletions
diff --git a/engines/glk/frotz/quetzal.cpp b/engines/glk/frotz/quetzal.cpp
index d12d41da88..64929c0f5b 100644
--- a/engines/glk/frotz/quetzal.cpp
+++ b/engines/glk/frotz/quetzal.cpp
@@ -65,13 +65,6 @@ bool Quetzal::save(Common::WriteStream *svf, Processor *proc, const Common::Stri
ws.writeByte(pc & 0xff);
}
- // Write 'ANNO' chunk
- {
- Common::WriteStream &ws = _writer.add(ID_ANNO);
- ws.write(desc.c_str(), desc.size());
- ws.writeByte(0);
- }
-
// Write `CMem' chunk.
{
Common::WriteStream &ws = _writer.add(ID_CMem);
@@ -166,7 +159,7 @@ bool Quetzal::save(Common::WriteStream *svf, Processor *proc, const Common::Stri
}
// Write the save data out
- _writer.save(svf, ID_IFZS);
+ _writer.save(svf, desc, ID_IFZS);
// After all that, still nothing went wrong!
return true;
diff --git a/engines/glk/quetzal.cpp b/engines/glk/quetzal.cpp
index fb2f70cb78..1425f419c4 100644
--- a/engines/glk/quetzal.cpp
+++ b/engines/glk/quetzal.cpp
@@ -21,7 +21,10 @@
*/
#include "glk/quetzal.h"
+#include "glk/glk_api.h"
+#include "glk/events.h"
#include "common/memstream.h"
+#include "common/system.h"
namespace Glk {
@@ -85,7 +88,10 @@ Common::WriteStream &QuetzalWriter::add(uint32 chunkId) {
return _chunks.back()._stream;
}
-void QuetzalWriter::save(Common::WriteStream *out, uint32 formType) {
+void QuetzalWriter::save(Common::WriteStream *out, const Common::String &saveName, uint32 formType) {
+ // Add chunks common to all Glk savegames
+ addCommonChunks(saveName);
+
// Calculate the size of the chunks
uint size = 4;
for (uint idx = 0; idx < _chunks.size(); ++idx)
@@ -108,4 +114,28 @@ void QuetzalWriter::save(Common::WriteStream *out, uint32 formType) {
}
}
+void QuetzalWriter::addCommonChunks(const Common::String &saveName) {
+ // Write 'ANNO' chunk
+ {
+ Common::WriteStream &ws = add(ID_ANNO);
+ ws.write(saveName.c_str(), saveName.size());
+ ws.writeByte(0);
+ }
+
+ // Write 'SCVM' chunk with gameplay statistics
+ {
+ Common::WriteStream &ws = add(ID_SCVM);
+
+ // Write out the save date/time
+ TimeDate td;
+ g_system->getTimeAndDate(td);
+ ws.writeSint16LE(td.tm_year + 1900);
+ ws.writeSint16LE(td.tm_mon + 1);
+ ws.writeSint16LE(td.tm_mday);
+ ws.writeSint16LE(td.tm_hour);
+ ws.writeSint16LE(td.tm_min);
+ ws.writeUint32LE(g_vm->_events->getTotalPlayTicks());
+ }
+}
+
} // End of namespace Glk
diff --git a/engines/glk/quetzal.h b/engines/glk/quetzal.h
index 19dd9397a2..454786f31c 100644
--- a/engines/glk/quetzal.h
+++ b/engines/glk/quetzal.h
@@ -157,6 +157,11 @@ class QuetzalWriter {
};
private:
Common::Array<Chunk> _chunks;
+
+ /**
+ * Add chunks common to all Glk savegames
+ */
+ void addCommonChunks(const Common::String &saveName);
public:
/**
* Clear
@@ -171,7 +176,7 @@ public:
/**
* Save the added chunks to file
*/
- void save(Common::WriteStream *out, uint32 formType = ID_IFSF);
+ void save(Common::WriteStream *out, const Common::String &saveName, uint32 formType = ID_IFSF);
};
} // End of namespace Glk