diff options
author | Walter van Niftrik | 2010-01-31 19:47:54 +0000 |
---|---|---|
committer | Walter van Niftrik | 2010-01-31 19:47:54 +0000 |
commit | a92bb6193be1bcc1e00aed4ced749a5226f5815d (patch) | |
tree | d9da72f32eccf054fb703e2ef02f6cb4a92b3e30 /engines/sci/engine/kmisc.cpp | |
parent | 4acb18f6b9faa4a0faf3f88ae74926e9c1074ed5 (diff) | |
download | scummvm-rg350-a92bb6193be1bcc1e00aed4ced749a5226f5815d.tar.gz scummvm-rg350-a92bb6193be1bcc1e00aed4ced749a5226f5815d.tar.bz2 scummvm-rg350-a92bb6193be1bcc1e00aed4ced749a5226f5815d.zip |
SCI: Implement kMemorySegment().
svn-id: r47776
Diffstat (limited to 'engines/sci/engine/kmisc.cpp')
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 229dcb8367..50be5509d7 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -121,6 +121,43 @@ reg_t kMemoryInfo(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } +enum kMemorySegmentFunc { + K_MEMORYSEGMENT_SAVE_DATA = 0, + K_MEMORYSEGMENT_RESTORE_DATA = 1 +}; + +reg_t kMemorySegment(EngineState *s, int argc, reg_t *argv) { + // MemorySegment provides access to a 256-byte block of memory that remains + // intact across restarts and restores + + switch (argv[0].toUint16()) { + case K_MEMORYSEGMENT_SAVE_DATA: { + if (argc < 3) + error("Insufficient number of arguments passed to MemorySegment"); + uint16 size = argv[2].toUint16(); + + if (!size) + size = s->_segMan->strlen(argv[1]) + 1; + + if (size > EngineState::kMemorySegmentMax) + size = EngineState::kMemorySegmentMax; + + s->_memorySegmentSize = size; + + // We assume that this won't be called on pointers + s->_segMan->memcpy(s->_memorySegment, argv[1], size); + break; + } + case K_MEMORYSEGMENT_RESTORE_DATA: + s->_segMan->memcpy(argv[1], s->_memorySegment, s->_memorySegmentSize); + break; + default: + error("Unknown MemorySegment operation %04x", argv[0].toUint16()); + } + + return argv[1]; +} + reg_t kFlushResources(EngineState *s, int argc, reg_t *argv) { run_gc(s); debugC(2, kDebugLevelRoom, "Entering room number %d", argv[0].toUint16()); |