aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2019-09-17 18:52:37 -0700
committerPaul Gilbert2019-09-25 20:13:27 -0700
commit0026f9ab5e18bc8eebcd6b7dc1973bcfab39e1dd (patch)
tree91dc37b6bf9b621b10193298242329f76236727c
parent60c23ffaaf867777bde2001626d198cc4cce7d4b (diff)
downloadscummvm-rg350-0026f9ab5e18bc8eebcd6b7dc1973bcfab39e1dd.tar.gz
scummvm-rg350-0026f9ab5e18bc8eebcd6b7dc1973bcfab39e1dd.tar.bz2
scummvm-rg350-0026f9ab5e18bc8eebcd6b7dc1973bcfab39e1dd.zip
GLK: ADRIFT: In progress implementing savegames
-rw-r--r--engines/glk/adrift/adrift.cpp14
-rw-r--r--engines/glk/adrift/adrift.h4
-rw-r--r--engines/glk/adrift/os_glk.cpp2
-rw-r--r--engines/glk/adrift/os_glk.h2
-rw-r--r--engines/glk/adrift/scprotos.h2
-rw-r--r--engines/glk/adrift/scserial.cpp34
-rw-r--r--engines/glk/quetzal.cpp2
7 files changed, 25 insertions, 35 deletions
diff --git a/engines/glk/adrift/adrift.cpp b/engines/glk/adrift/adrift.cpp
index 9ba4e1c230..b3768643a0 100644
--- a/engines/glk/adrift/adrift.cpp
+++ b/engines/glk/adrift/adrift.cpp
@@ -22,6 +22,7 @@
#include "glk/adrift/adrift.h"
#include "glk/adrift/os_glk.h"
+#include "glk/adrift/scprotos.h"
namespace Glk {
namespace Adrift {
@@ -38,12 +39,23 @@ void Adrift::runGame() {
}
Common::Error Adrift::readSaveData(Common::SeekableReadStream *rs) {
- return Common::kNoError;
+ return ser_load_game((sc_gameref_t)gsc_game, if_read_saved_game, rs) ? Common::kNoError : Common::kReadingFailed;
}
Common::Error Adrift::writeGameData(Common::WriteStream *ws) {
+ ser_save_game((sc_gameref_t)gsc_game, if_write_saved_game, ws);
return Common::kNoError;
}
+sc_int Adrift::if_read_saved_game(void *opaque, sc_byte *buffer, sc_int length) {
+ Common::SeekableReadStream *rs = (Common::SeekableReadStream *)opaque;
+ return rs->read(buffer, length);
+}
+
+void Adrift::if_write_saved_game(void *opaque, const sc_byte *buffer, sc_int length) {
+ Common::WriteStream *ws = (Common::WriteStream *)opaque;
+ ws->write(buffer, length);
+}
+
} // End of namespace Adrift
} // End of namespace Glk
diff --git a/engines/glk/adrift/adrift.h b/engines/glk/adrift/adrift.h
index 81d7d30def..006293a829 100644
--- a/engines/glk/adrift/adrift.h
+++ b/engines/glk/adrift/adrift.h
@@ -27,6 +27,7 @@
#include "common/serializer.h"
#include "common/stack.h"
#include "glk/glk_api.h"
+#include "glk/adrift/scare.h"
namespace Glk {
namespace Adrift {
@@ -45,6 +46,9 @@ private:
* Deinitialization
*/
void deinitialize();
+
+ static void if_write_saved_game(void *opaque, const sc_byte *buffer, sc_int length);
+ static sc_int if_read_saved_game(void *opaque, sc_byte *buffer, sc_int length);
public:
/**
* Constructor
diff --git a/engines/glk/adrift/os_glk.cpp b/engines/glk/adrift/os_glk.cpp
index cfe61acae6..c9c9c0c856 100644
--- a/engines/glk/adrift/os_glk.cpp
+++ b/engines/glk/adrift/os_glk.cpp
@@ -78,7 +78,7 @@ static int gsc_commands_enabled = TRUE, gsc_abbreviations_enabled = TRUE,
gsc_unicode_enabled = TRUE;
/* Adrift game to interpret. */
-static sc_game gsc_game = nullptr;
+sc_game gsc_game = nullptr;
/* Special out-of-band os_confirm() options used locally with os_glk. */
static const sc_int GSC_CONF_SUBTLE_HINT = INT_MAX,
diff --git a/engines/glk/adrift/os_glk.h b/engines/glk/adrift/os_glk.h
index 52c7d8948b..7772b8fdcb 100644
--- a/engines/glk/adrift/os_glk.h
+++ b/engines/glk/adrift/os_glk.h
@@ -29,6 +29,8 @@
namespace Glk {
namespace Adrift {
+extern sc_game gsc_game;
+
extern bool adrift_startup_code(Common::SeekableReadStream *gameFile);
extern void adrift_main();
diff --git a/engines/glk/adrift/scprotos.h b/engines/glk/adrift/scprotos.h
index 9601f0618d..4172cfea0c 100644
--- a/engines/glk/adrift/scprotos.h
+++ b/engines/glk/adrift/scprotos.h
@@ -779,8 +779,6 @@ extern void if_read_line(sc_char *buffer, sc_int length);
extern void if_read_debug(sc_char *buffer, sc_int length);
extern sc_bool if_confirm(sc_int type);
extern void *if_open_saved_game(sc_bool is_save);
-extern void if_write_saved_game(void *opaque, const sc_byte *buffer, sc_int length);
-extern sc_int if_read_saved_game(void *opaque, sc_byte *buffer, sc_int length);
extern void if_close_saved_game(void *opaque);
extern void if_display_hints(sc_gameref_t game);
extern void if_update_sound(const sc_char *filepath, sc_int sound_offset,
diff --git a/engines/glk/adrift/scserial.cpp b/engines/glk/adrift/scserial.cpp
index 7b9a161961..fb771de2ae 100644
--- a/engines/glk/adrift/scserial.cpp
+++ b/engines/glk/adrift/scserial.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "glk/adrift/scare.h"
+#include "glk/adrift/adrift.h"
#include "glk/adrift/scprotos.h"
#include "glk/adrift/scgamest.h"
#include "common/textconsole.h"
@@ -293,20 +293,7 @@ void ser_save_game(sc_gameref_t game, sc_write_callbackref_t callback, void *opa
* the user.
*/
sc_bool ser_save_game_prompted(sc_gameref_t game) {
- void *opaque;
-
- /*
- * Open an output stream, and if successful, save a game using the opaque
- * value returned.
- */
- opaque = if_open_saved_game(TRUE);
- if (opaque) {
- ser_save_game(game, if_write_saved_game, opaque);
- if_close_saved_game(opaque);
- return TRUE;
- }
-
- return FALSE;
+ return g_vm->saveGame().getCode() == Common::kNoError;
}
@@ -621,22 +608,7 @@ sc_bool ser_load_game(sc_gameref_t game, sc_read_callbackref_t callback, void *o
* stream from the user.
*/
sc_bool ser_load_game_prompted(sc_gameref_t game) {
- void *opaque;
-
- /*
- * Open an input stream, and if successful, try to load a game using
- * the opaque value returned and the saved game callback.
- */
- opaque = if_open_saved_game(FALSE);
- if (opaque) {
- sc_bool status;
-
- status = ser_load_game(game, if_read_saved_game, opaque);
- if_close_saved_game(opaque);
- return status;
- }
-
- return FALSE;
+ return g_vm->loadGame().getCode() == Common::kNoError;
}
} // End of namespace Adrift
diff --git a/engines/glk/quetzal.cpp b/engines/glk/quetzal.cpp
index b83d855f57..e60460209a 100644
--- a/engines/glk/quetzal.cpp
+++ b/engines/glk/quetzal.cpp
@@ -31,10 +31,12 @@
namespace Glk {
const uint32 INTERPRETER_IDS[INTERPRETER_TADS3 + 1] = {
+ MKTAG('A', 'D', 'R', 'I'),
MKTAG('A', 'S', 'Y', 'S'),
MKTAG('A', 'G', 'I', 'L'),
MKTAG('A', 'L', 'N', '2'),
MKTAG('A', 'L', 'N', '3'),
+ MKTAG('B', 'O', 'C', 'F'),
MKTAG('Z', 'C', 'O', 'D'),
MKTAG('G', 'E', 'A', 'S'),
MKTAG('G', 'L', 'U', 'L'),