diff options
author | Paul Gilbert | 2019-04-28 17:42:22 +1000 |
---|---|---|
committer | Paul Gilbert | 2019-04-28 17:42:22 +1000 |
commit | 3040135f06756de04d2b4ca2a581062baa19816b (patch) | |
tree | 92ffb2751d0b1aa7ea99e0ccf4d4d89a81328115 /engines | |
parent | efcd8ab27047c82da67f98c4246427c8f2c19d4c (diff) | |
download | scummvm-rg350-3040135f06756de04d2b4ca2a581062baa19816b.tar.gz scummvm-rg350-3040135f06756de04d2b4ca2a581062baa19816b.tar.bz2 scummvm-rg350-3040135f06756de04d2b4ca2a581062baa19816b.zip |
GLK: Record gli arrays for memory streams
Diffstat (limited to 'engines')
-rw-r--r-- | engines/glk/glulxe/exec.cpp | 2 | ||||
-rw-r--r-- | engines/glk/glulxe/glkop.cpp | 4 | ||||
-rw-r--r-- | engines/glk/streams.cpp | 10 | ||||
-rw-r--r-- | engines/glk/streams.h | 6 |
4 files changed, 21 insertions, 1 deletions
diff --git a/engines/glk/glulxe/exec.cpp b/engines/glk/glulxe/exec.cpp index 55cd918ebb..01faad888f 100644 --- a/engines/glk/glulxe/exec.cpp +++ b/engines/glk/glulxe/exec.cpp @@ -39,7 +39,7 @@ void Glulxe::execute_loop() { gfloat32 valf, valf1, valf2; #endif /* FLOAT_SUPPORT */ - while (!done_executing) { + while (!done_executing && !g_vm->shouldQuit()) { profile_tick(); debugger_tick(); diff --git a/engines/glk/glulxe/glkop.cpp b/engines/glk/glulxe/glkop.cpp index 68e60c7bec..635d90bb7b 100644 --- a/engines/glk/glulxe/glkop.cpp +++ b/engines/glk/glulxe/glkop.cpp @@ -1165,6 +1165,10 @@ void Glulxe::glulxe_retained_unregister(void *array, uint len, const char *type uint ix, addr2, val; uint elemsize = 0; + // TODO: See if original GLULXE has code I'm overlooking to cleanly close everything before freeing memmap + if (!memmap) + return; + if (typecode[4] == 'C') elemsize = 1; else if (typecode[4] == 'I') diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp index b124e30ec9..907cde4d66 100644 --- a/engines/glk/streams.cpp +++ b/engines/glk/streams.cpp @@ -318,6 +318,16 @@ MemoryStream::MemoryStream(Streams *streams, void *buf, size_t buflen, FileMode else _bufEnd = (byte *)buf + buflen; _bufEof = mode == filemode_Write ? _buf : _bufEnd; + + if (g_vm->gli_register_arr) + _arrayRock = (*g_vm->gli_register_arr)(buf, buflen, unicode ? "&+#!Iu" : "&+#!Cn"); +} + +MemoryStream::~MemoryStream() { + if (g_vm->gli_unregister_arr) { + const char *typedesc = _unicode ? "&+#!Iu" : "&+#!Cn"; + (*g_vm->gli_unregister_arr)(_buf, _bufLen, typedesc, _arrayRock); + } } void MemoryStream::putChar(unsigned char ch) { diff --git a/engines/glk/streams.h b/engines/glk/streams.h index a34ba6f0a4..f899936ef3 100644 --- a/engines/glk/streams.h +++ b/engines/glk/streams.h @@ -381,6 +381,7 @@ private: void *_bufEnd; void *_bufEof; size_t _bufLen; ///< # of bytes for latin1, # of 4-byte words for unicode + gidispatch_rock_t _arrayRock; public: /** * Constructor @@ -388,6 +389,11 @@ public: MemoryStream(Streams *streams, void *buf, size_t buflen, FileMode mode, uint rock = 0, bool unicode = true); /** + * Destructor + */ + virtual ~MemoryStream(); + + /** * Write a character */ virtual void putChar(unsigned char ch) override; |