aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWalter van Niftrik2009-10-15 11:57:36 +0000
committerWalter van Niftrik2009-10-15 11:57:36 +0000
commit0d6ab8c73a1059885a6ecb93f530f690de84e22f (patch)
treea52ef3fc3144723131779884ef29e7af76d3859b /engines
parent5d6b2564953fd1452d4af7130c7c39fb6d301b1d (diff)
downloadscummvm-rg350-0d6ab8c73a1059885a6ecb93f530f690de84e22f.tar.gz
scummvm-rg350-0d6ab8c73a1059885a6ecb93f530f690de84e22f.tar.bz2
scummvm-rg350-0d6ab8c73a1059885a6ecb93f530f690de84e22f.zip
SCI: Add support for reg_t based segments to Message()
svn-id: r45113
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kstring.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 2f8ea1f33c..de86b8472e 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -670,20 +670,35 @@ reg_t kMessage(EngineState *s, int argc, reg_t *argv) {
s->_msgState->lastQuery(module, msg);
- byte *buffer = s->_segMan->derefBulkPtr(argv[1], 10);
-
- if (buffer) {
- assert(s->_segMan->dereference(argv[1]).isRaw);
-
- WRITE_LE_UINT16(buffer, module);
- WRITE_LE_UINT16(buffer + 2, msg.noun);
- WRITE_LE_UINT16(buffer + 4, msg.verb);
- WRITE_LE_UINT16(buffer + 6, msg.cond);
- WRITE_LE_UINT16(buffer + 8, msg.seq);
+ bool ok = false;
+
+ if (s->_segMan->dereference(argv[1]).isRaw) {
+ byte *buffer = s->_segMan->derefBulkPtr(argv[1], 10);
+
+ if (buffer) {
+ ok = true;
+ WRITE_LE_UINT16(buffer, module);
+ WRITE_LE_UINT16(buffer + 2, msg.noun);
+ WRITE_LE_UINT16(buffer + 4, msg.verb);
+ WRITE_LE_UINT16(buffer + 6, msg.cond);
+ WRITE_LE_UINT16(buffer + 8, msg.seq);
+ }
} else {
- warning("Message: buffer %04x:%04x invalid or too small to hold the tuple", PRINT_REG(argv[1]));
+ reg_t *buffer = s->_segMan->derefRegPtr(argv[1], 5);
+
+ if (buffer) {
+ ok = true;
+ buffer[0] = make_reg(0, module);
+ buffer[1] = make_reg(0, msg.noun);
+ buffer[2] = make_reg(0, msg.verb);
+ buffer[3] = make_reg(0, msg.cond);
+ buffer[4] = make_reg(0, msg.seq);
+ }
}
+ if (!ok)
+ warning("Message: buffer %04x:%04x invalid or too small to hold the tuple", PRINT_REG(argv[1]));
+
return NULL_REG;
}
default: