From 0d6ab8c73a1059885a6ecb93f530f690de84e22f Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Thu, 15 Oct 2009 11:57:36 +0000 Subject: SCI: Add support for reg_t based segments to Message() svn-id: r45113 --- engines/sci/engine/kstring.cpp | 37 ++++++++++++++++++++++++++----------- 1 file 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: -- cgit v1.2.3