diff options
author | Filippos Karapetis | 2019-06-11 00:47:42 +0300 |
---|---|---|
committer | Filippos Karapetis | 2019-06-11 00:48:16 +0300 |
commit | 05301c240b3ccc195c533cf7a2eddde683ee7d06 (patch) | |
tree | 65bab6bed51b68fe67abb47fc3aaf2f0017e2bfc /engines/startrek/room.cpp | |
parent | 709d606e016235b663e04b9abfa9d537bdc753f0 (diff) | |
download | scummvm-rg350-05301c240b3ccc195c533cf7a2eddde683ee7d06.tar.gz scummvm-rg350-05301c240b3ccc195c533cf7a2eddde683ee7d06.tar.bz2 scummvm-rg350-05301c240b3ccc195c533cf7a2eddde683ee7d06.zip |
STARTREK: Load more messages from RDF files
The whole Demon chapter has been converted to the new logic.
The offsets for the extra room messages have been hardcoded, for now,
inside loadOtherRoomMessages(), until we figure out how they are
referenced.
Diffstat (limited to 'engines/startrek/room.cpp')
-rw-r--r-- | engines/startrek/room.cpp | 132 |
1 files changed, 103 insertions, 29 deletions
diff --git a/engines/startrek/room.cpp b/engines/startrek/room.cpp index d3bf2d8f80..e550d9c1a1 100644 --- a/engines/startrek/room.cpp +++ b/engines/startrek/room.cpp @@ -52,6 +52,7 @@ Room::Room(StarTrekEngine *vm, const Common::String &name) : _vm(vm), _awayMissi rdfFile->read(_rdfData, size); delete rdfFile; + _rdfName = name; _roomIndex = name.lastChar() - '0'; _roomActionList = nullptr; @@ -115,11 +116,13 @@ Room::Room(StarTrekEngine *vm, const Common::String &name) : _vm(vm), _awayMissi } loadRoomMessages(); + loadOtherRoomMessages(); memset(&_roomVar, 0, sizeof(_roomVar)); } Room::~Room() { _lookMessages.clear(); + _lookWithTalkerMessages.clear(); _talkMessages.clear(); delete[] _rdfData; } @@ -127,40 +130,106 @@ Room::~Room() { void Room::loadRoomMessages() { // TODO: There are some more messages which are not stored in that offset uint16 messagesOffset = readRdfWord(32); - byte *text = _rdfData + messagesOffset; - int messageNum; - bool isTalkMessage; + const char *text = (const char *)_rdfData + messagesOffset; do { while (*text != '#') text++; - if (text[5] != '\\') - error("loadRoomMessages: Invalid message"); + loadRoomMessage(text); - isTalkMessage = (text[10] == '_'); + while (*text != '\0') + text++; - // TODO: There are also 'L' messages (look at something, but has a talker). - // These clash with the normal talk ones (with underscores) - if (text[10] == 'L') { + // Peek the next byte, in case there's a filler text + if (Common::isAlpha(*(text + 1))) { while (*text != '\0') text++; - - continue; } + } while (*(text + 1) == '#'); +} - sscanf((const char *)(text + 11), "%3d", &messageNum); - if (text[14] != '#') - error("loadRoomMessages: Invalid message"); +void Room::loadRoomMessage(const char *text) { + int messageNum; + bool isTalkMessage; + bool isLookWithTalkerMessage; - if (isTalkMessage) - _talkMessages[messageNum] = Common::String((const char *)text); - else - _lookMessages[messageNum] = Common::String((const char *)text); + if (text[5] != '\\') + error("loadRoomMessage: Invalid message"); - while (*text != '\0') - text++; - } while (*(text + 1) == '#'); + isTalkMessage = (text[10] == '_' || text[10] == 'U'); // U = Uhura + isLookWithTalkerMessage = (text[10] == 'L'); + + sscanf((const char *)(text + 11), "%3d", &messageNum); + if (text[14] != '#') + error("loadRoomMessage: Invalid message"); + + if (isTalkMessage) + _talkMessages[messageNum] = Common::String((const char *)text); + else if (isLookWithTalkerMessage) + _lookWithTalkerMessages[messageNum] = Common::String((const char *)text); + else + _lookMessages[messageNum] = Common::String((const char *)text); + +} + +// HACK: We hardcode the other room messages here. Remove once we figure +// how these are indexed +void Room::loadOtherRoomMessages() { + int *offsets = nullptr; + + if (_rdfName == "DEMON0") { + int o[] = { 0x1d9, 0x422, 0x48f, 0x4d1, 0x536, 0x578, -1 }; + offsets = o; + } else if (_rdfName == "DEMON1") { + int o[] = { + 0x5d4, 0x716, 0x791, 0x7ec, 0x99e, 0xa06, 0xa51, 0xa96, 0xacc, 0xb5a, + 0xb87, 0xc46, 0xcd5, 0xd82, 0xe55, 0x107e, 0x1186, 0x11d1, 0x1216, 0x1271, + 0x12a4, 0x12f3, 0x1335, 0x1371, 0x13b4, 0x1419, 0x1467, 0x14b2, 0x14fd, -1 + }; + offsets = o; + } else if (_rdfName == "DEMON2") { + int o[] = { + 0x165, 0x195, 0x1c6, 0x1f7, 0x24a, 0x27d, 0x2c6, 0x311, 0x41a, 0x489, + 0x538, 0x5ba, 0x64d, 0x74d, 0x7ab, 0x817, 0x8a4, 0x950, 0x9e1, -1 + }; + offsets = o; + } else if (_rdfName == "DEMON3") { + int o[] = { + 0x662, 0x6d3, 0x7a5, 0xa19, 0xa9a, 0xbd7, 0xc30, 0xcfe, 0xe13, 0xed2, + 0x104e, 0x118e, 0x1248, 0x12a4, 0x12f4, 0x1383, 0x13d5, 0x1443, 0x14b1, + 0x1522, 0x15ab, 0x15f5, 0x1648, 0x16ad, -1 + }; + offsets = o; + } else if (_rdfName == "DEMON4") { + int o[] = { + 0x254, 0x2f3, 0x392, 0x41f, 0x642, 0x7b3, 0xa6a, 0xb34, 0xba4, 0xc7b, + -1 + }; + offsets = o; + } else if (_rdfName == "DEMON5") { + int o[] = { + 0x27c, 0x2e7, 0x387, 0x438, 0x483, 0x4de, 0x58f, 0x5e2, 0x61f, 0x713, + 0x783, 0x812, 0x8af, 0x904, 0x95e, 0x9b8, 0xb7e, 0xccc, -1 + }; + offsets = o; + } else if (_rdfName == "DEMON6") { + int o[] = { + 0x265, 0x2cb, 0x40c, 0x473, 0x52a, 0x5cd, 0x697, 0x6e5, 0x787, 0x97b, + 0x9f5, 0xa5f, 0xb7e, 0xbf1, 0xca7, 0xe54, 0xee4, + -1 + }; + offsets = o; + } + + if (offsets == nullptr) + return; + + int i = 0; + while (offsets[i] != -1) { + loadRoomMessage((const char *)_rdfData + offsets[i]); + i++; + } } uint16 Room::readRdfWord(int offset) { @@ -340,7 +409,7 @@ int Room::showRoomSpecificText(const char **array) { return _vm->showText(&StarTrekEngine::readTextFromArrayWithChoices, (uintptr)array, 20, 20, textColor, true, false, false); } -int Room::showText(const TextRef *textIDs, bool fromRDF) { +int Room::showText(const TextRef *textIDs, bool fromRDF, bool lookWithTalker) { int numIDs = 0; int retval; while (textIDs[numIDs] != TX_BLANK) @@ -350,9 +419,14 @@ int Room::showText(const TextRef *textIDs, bool fromRDF) { for (int i = 0; i <= numIDs; i++) { // TODO: This isn't nice, but it's temporary till we migrate to reading text from RDF files - if (i > 0 && fromRDF) - text[i] = (textIDs[0] == TX_NULL) ? _lookMessages[textIDs[i]].c_str() : _talkMessages[textIDs[i]].c_str(); - else + if (i > 0 && fromRDF) { + if (textIDs[0] == TX_NULL) + text[i] = _lookMessages[textIDs[i]].c_str(); + else if (lookWithTalker) + text[i] = _lookWithTalkerMessages[textIDs[i]].c_str(); + else + text[i] = _talkMessages[textIDs[i]].c_str(); + } else text[i] = g_gameStrings[textIDs[i]]; } @@ -362,16 +436,16 @@ int Room::showText(const TextRef *textIDs, bool fromRDF) { return retval; } -int Room::showText(TextRef speaker, TextRef text, bool fromRDF) { +int Room::showText(TextRef speaker, TextRef text, bool fromRDF, bool lookWithTalker) { TextRef textIDs[3]; textIDs[0] = speaker; textIDs[1] = text; textIDs[2] = TX_BLANK; - return showText(textIDs, fromRDF); + return showText(textIDs, fromRDF, lookWithTalker); } -int Room::showText(TextRef text, bool fromRDF) { - return showText(TX_NULL, text, fromRDF); +int Room::showText(TextRef text, bool fromRDF, bool lookWithTalker) { + return showText(TX_NULL, text, fromRDF, lookWithTalker); } void Room::giveItem(int item) { |