diff options
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/support/simple_file.cpp | 15 | ||||
-rw-r--r-- | engines/titanic/support/simple_file.h | 5 | ||||
-rw-r--r-- | engines/titanic/true_talk/st_vocab.cpp | 66 | ||||
-rw-r--r-- | engines/titanic/true_talk/st_vocab.h | 2 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_word.cpp | 28 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_word.h | 27 |
6 files changed, 135 insertions, 8 deletions
diff --git a/engines/titanic/support/simple_file.cpp b/engines/titanic/support/simple_file.cpp index b7f666a1ef..18a75864a8 100644 --- a/engines/titanic/support/simple_file.cpp +++ b/engines/titanic/support/simple_file.cpp @@ -78,6 +78,12 @@ size_t SimpleFile::write(const void *src, size_t count) { return _outStream->write(src, count); } +byte SimpleFile::readByte() { + byte b; + safeRead(&b, 1); + return b; +} + CString SimpleFile::readString() { char c; CString result; @@ -368,13 +374,22 @@ bool SimpleFile::scanf(const char *format, ...) { if (!Common::isSpace(c)) return false; } else if (formatStr.hasPrefix("%d")) { + // Read in a number formatStr = CString(formatStr.c_str() + 2); int *param = (int *)va_arg(va, int *); *param = readNumber(); + } else if (formatStr.hasPrefix("%s")) { + // Read in text until the next space + formatStr = CString(formatStr.c_str() + 2); + CString *str = (CString *)va_arg(va, CString *); + str->clear(); + while (!eos() && (c = readByte()) != ' ') + *str += c; } } va_end(va); + return !eos(); } /*------------------------------------------------------------------------*/ diff --git a/engines/titanic/support/simple_file.h b/engines/titanic/support/simple_file.h index 431df016ad..db453c46c7 100644 --- a/engines/titanic/support/simple_file.h +++ b/engines/titanic/support/simple_file.h @@ -87,6 +87,11 @@ public: virtual size_t write(const void *src, size_t count); /** + * Read a byte + */ + byte readByte(); + + /** * Read a string from the file */ CString readString(); diff --git a/engines/titanic/true_talk/st_vocab.cpp b/engines/titanic/true_talk/st_vocab.cpp index b725101214..3850c64de2 100644 --- a/engines/titanic/true_talk/st_vocab.cpp +++ b/engines/titanic/true_talk/st_vocab.cpp @@ -26,7 +26,7 @@ namespace Titanic { -STVocab::STVocab(int val): _field0(0), _field4(0), _vocab(nullptr), +STVocab::STVocab(int val): _field0(0), _field4(0), _word(nullptr), _fieldC(0), _field10(0), _field18(val) { _field14 = load("STvocab.txt"); } @@ -34,12 +34,70 @@ STVocab::STVocab(int val): _field0(0), _field4(0), _vocab(nullptr), int STVocab::load(const CString &name) { SimpleFile *file = g_vm->_fileReader._owner->openResource(name); int result = 0; + int param = -1; + int mode = 0; + bool skipFlag; - while (!file->eos()) { - int mode = file->readNumber(); + while (!result && !file->eos()) { + skipFlag = false; + int param = file->readNumber(); + TTString space(" "); switch (mode) { - case 0: + case 0: { + if (_word) + result = _word->readSyn(file); + skipFlag = true; + break; + } + + case 1: { + TTWord2 *word = new TTWord2(space, 0, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + case 2: { + TTWord3 *word = new TTWord3(space, 0, 0, 0, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + case 3: + case 9: { + TTWord1 *word = new TTWord1(space, 0, 0, 0); + result = word->load(file, &mode); + _word = word; + break; + } + + case 4: + case 5: + case 7: { + TTWord *word = new TTWord(space, 0, 0); + result = word->load(file, &mode); + _word = word; + break; + } + + case 8: { + TTWord4 *word = new TTWord4(space, 0, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + case 6: { + TTWord5 *word = new TTWord5(space, 0, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + default: + result = 4; break; } } diff --git a/engines/titanic/true_talk/st_vocab.h b/engines/titanic/true_talk/st_vocab.h index 090dc74237..cc25150981 100644 --- a/engines/titanic/true_talk/st_vocab.h +++ b/engines/titanic/true_talk/st_vocab.h @@ -33,7 +33,7 @@ class STVocab { private: int _field0; int _field4; - TTString *_vocab; + TTWord *_word; int _fieldC; int _field10; int _field14; diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp index 4405f72555..a37b049d6e 100644 --- a/engines/titanic/true_talk/tt_word.cpp +++ b/engines/titanic/true_talk/tt_word.cpp @@ -30,9 +30,13 @@ TTWord::TTWord(TTString &str, int val1, int val2) : _string(str), _status = str.getStatus() == SS_VALID ? SS_VALID : SS_5; } -/*------------------------------------------------------------------------*/ +int TTWord::readSyn(SimpleFile *file) { + return 0; +} -void TTWord::readSyn(SimpleFile *file) { +int TTWord::load(SimpleFile *file, int *mode) { + // TODO + return 0; } /*------------------------------------------------------------------------*/ @@ -47,6 +51,11 @@ TTWord2::TTWord2(TTString &str, int val1, int val2, int val3, int val4) : TTWord1(str, val1, val2, val3), _field30(val4) { } +int TTWord2::load(SimpleFile *file) { + // TODO + return 0; +} + /*------------------------------------------------------------------------*/ TTWord3::TTWord3(TTString &str, int val1, int val2, int val3, int val4, int val5, int val6) : @@ -54,6 +63,11 @@ TTWord3::TTWord3(TTString &str, int val1, int val2, int val3, int val4, int val5 _field38(0) { } +int TTWord3::load(SimpleFile *file) { + // TODO + return 0; +} + /*------------------------------------------------------------------------*/ TTWord4::TTWord4(TTString &str, int val1, int val2, int val3, int val4) : @@ -66,10 +80,20 @@ TTWord4::TTWord4(TTString &str, int val1, int val2, int val3, int val4) : } } +int TTWord4::load(SimpleFile *file) { + // TODO + return 0; +} + /*------------------------------------------------------------------------*/ TTWord5::TTWord5(TTString &str, int val1, int val2, int val3, int val4) : TTWord1(str, val1, val2, val3), _field30(val4) { } +int TTWord5::load(SimpleFile *file) { + // TODO + return 0; +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_word.h b/engines/titanic/true_talk/tt_word.h index d8b34ed04e..1a8b7368f5 100644 --- a/engines/titanic/true_talk/tt_word.h +++ b/engines/titanic/true_talk/tt_word.h @@ -42,7 +42,12 @@ protected: public: TTWord(TTString &str, int val1, int val2); - void readSyn(SimpleFile *file); + int readSyn(SimpleFile *file); + + /** + * Load the word + */ + int load(SimpleFile *file, int *mode); }; class TTWord1 : public TTWord { @@ -57,6 +62,11 @@ protected: int _field30; public: TTWord2(TTString &str, int val1, int val2, int val3, int val4); + + /** + * Load the word + */ + int load(SimpleFile *file); }; class TTWord3 : public TTWord1 { @@ -67,6 +77,11 @@ protected: int _field3C; public: TTWord3(TTString &str, int val1, int val2, int val3, int val4, int val5, int val6); + + /** + * Load the word + */ + int load(SimpleFile *file); }; class TTWord4 : public TTWord1 { @@ -74,6 +89,11 @@ protected: int _field30; public: TTWord4(TTString &str, int val1, int val2, int val3, int val4); + + /** + * Load the word + */ + int load(SimpleFile *file); }; class TTWord5 : public TTWord1 { @@ -81,6 +101,11 @@ protected: int _field30; public: TTWord5(TTString &str, int val1, int val2, int val3, int val4); + + /** + * Load the word + */ + int load(SimpleFile *file); }; } // End of namespace Titanic |