aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-04 00:50:06 -0400
committerPaul Gilbert2016-07-15 19:19:20 -0400
commitb3bcf1cc4e2c22cedafd63417bb1d22ef591dd41 (patch)
tree8ba7f40b527d27c000e45414cb0db85b57cf8a9a /engines/titanic
parent4e766db41cae9d747f49cbfefbb5a23612768ea5 (diff)
downloadscummvm-rg350-b3bcf1cc4e2c22cedafd63417bb1d22ef591dd41.tar.gz
scummvm-rg350-b3bcf1cc4e2c22cedafd63417bb1d22ef591dd41.tar.bz2
scummvm-rg350-b3bcf1cc4e2c22cedafd63417bb1d22ef591dd41.zip
TITANIC: Finished TTquotes load
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/true_talk/tt_quotes.cpp42
-rw-r--r--engines/titanic/true_talk/tt_quotes.h16
2 files changed, 45 insertions, 13 deletions
diff --git a/engines/titanic/true_talk/tt_quotes.cpp b/engines/titanic/true_talk/tt_quotes.cpp
index ced7f8e454..734ad58fbd 100644
--- a/engines/titanic/true_talk/tt_quotes.cpp
+++ b/engines/titanic/true_talk/tt_quotes.cpp
@@ -22,25 +22,50 @@
#include "common/algorithm.h"
#include "titanic/true_talk/tt_quotes.h"
+#include "titanic/titanic.h"
namespace Titanic {
TTquotes::TTquotes() {
Common::fill(&_array[0], &_array[256], 0);
_dataP = nullptr;
- _field540 = 0;
+ _dataSize = 0;
_field544 = 0;
}
TTquotes::~TTquotes() {
- for (int idx = 0; idx < 26; ++idx)
- delete _alphabet[idx]._dataP;
-
- delete _dataP;
+ delete[] _dataP;
}
void TTquotes::load(const CString &name) {
- // TODO
+ Common::SeekableReadStream *r = g_vm->_filesManager->getResource("TEXT/JRQuotes.txt");
+ size_t size = r->readUint32LE();
+
+ _dataSize = _field544 = size;
+ _dataP = new char[size + 0x10];
+
+ for (int idx = 0; idx < 256; ++idx)
+ _array[idx] = r->readUint32LE();
+
+ for (int charIdx = 0; charIdx < 26; ++charIdx) {
+ TTquotesLetter &letter = _alphabet[charIdx];
+ int count = r->readUint32LE();
+
+ // Load the list of entries for the given letter
+ letter._entries.resize(count);
+ for (int idx = 0; idx < count; ++idx) {
+ letter._entries[idx]._val1 = r->readByte();
+ letter._entries[idx]._val2 = r->readByte();
+ letter._entries[idx]._strP = _dataP + r->readUint32LE();
+ }
+ }
+
+ // Read in buffer and then decode it
+ r->read((byte *)_dataP, _dataSize);
+ for (size_t idx = 0; idx < _dataSize; idx += 4)
+ WRITE_LE_UINT32((byte *)_dataP + idx, READ_LE_UINT32((byte *)_dataP + idx) ^ 0xA55A5AA5);
+
+ delete r;
}
int TTquotes::read(const char *str) {
@@ -75,8 +100,9 @@ int TTquotes::read(const char *startP, const char *endP) {
return 0;
uint index = MIN((uint)(*startP - 'a'), (uint)25);
- TTquotesEntry &entry = _alphabet[index];
- if (!entry._dataP || entry._field4 <= 0)
+ TTquotesLetter &letter = _alphabet[index];
+ if (letter._entries.empty())
+ // No entries for the letter, so exit immediately
return 0;
// TODO
diff --git a/engines/titanic/true_talk/tt_quotes.h b/engines/titanic/true_talk/tt_quotes.h
index 2af612ca32..6649c1f744 100644
--- a/engines/titanic/true_talk/tt_quotes.h
+++ b/engines/titanic/true_talk/tt_quotes.h
@@ -24,23 +24,29 @@
#define TITANIC_TT_QUOTES_H
#include "common/scummsys.h"
+#include "common/stream.h"
#include "titanic/support/string.h"
namespace Titanic {
class TTquotes {
struct TTquotesEntry {
- byte *_dataP;
+ byte _val1, _val2;
+ const char *_strP;
+ TTquotesEntry() : _val1(0), _val2(0), _strP(nullptr) {}
+ };
+ struct TTquotesLetter {
+ Common::Array<TTquotesEntry> _entries;
int _field4;
int _field8;
- TTquotesEntry() : _dataP(nullptr), _field4(0), _field8(0) {}
+ TTquotesLetter() : _field4(0), _field8(0) {}
};
private:
- TTquotesEntry _alphabet[26];
+ TTquotesLetter _alphabet[26];
uint _array[256];
- byte *_dataP;
- int _field540;
+ const char *_dataP;
+ size_t _dataSize;
int _field544;
private:
int read(const char *startP, const char *endP);