aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorJussi Pitkanen2011-06-16 12:34:40 +0300
committerEugene Sandulenko2011-08-13 23:27:05 +0100
commit368a3722a3cae2326efaf124608605058b274cd5 (patch)
treefa38939b89731a96027a771934db35811d0b773b /engines/agi
parentc731f1f48c780ed09db03c8c5347d5e96da886ac (diff)
downloadscummvm-rg350-368a3722a3cae2326efaf124608605058b274cd5.tar.gz
scummvm-rg350-368a3722a3cae2326efaf124608605058b274cd5.tar.bz2
scummvm-rg350-368a3722a3cae2326efaf124608605058b274cd5.zip
AGI: Implement loader for V1 words.tok dictionary
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/agi.h1
-rw-r--r--engines/agi/loader_v1.cpp19
-rw-r--r--engines/agi/words.cpp30
3 files changed, 37 insertions, 13 deletions
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 368aecfca2..3e644dace8 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -1024,6 +1024,7 @@ public:
public:
int showWords();
int loadWords(const char *);
+ int loadWords_v1(Common::File &f);
void unloadWords();
int findWord(const char *word, int *flen);
void dictionaryWords(char *);
diff --git a/engines/agi/loader_v1.cpp b/engines/agi/loader_v1.cpp
index ab350cd920..02a20c9bc8 100644
--- a/engines/agi/loader_v1.cpp
+++ b/engines/agi/loader_v1.cpp
@@ -26,33 +26,25 @@
#define IMAGE_SIZE 368640 // = 40 * 2 * 9 * 512 = tracks * sides * sectors * sector size
#define SECTOR_OFFSET(s) ((s) * 512)
-
#define DDP_BASE_SECTOR 0x1C2
-
#define DDP_LOGDIR_SEC SECTOR_OFFSET(171) + 5
#define DDP_LOGDIR_MAX 43
-
#define DDP_PICDIR_SEC SECTOR_OFFSET(180) + 5
#define DDP_PICDIR_MAX 30
-
#define DDP_VIEWDIR_SEC SECTOR_OFFSET(189) + 5
#define DDP_VIEWDIR_MAX 171
-
#define DDP_SNDDIR_SEC SECTOR_OFFSET(198) + 5
#define DDP_SNDDIR_MAX 64
-
#define BC_LOGDIR_SEC SECTOR_OFFSET(90) + 5
#define BC_LOGDIR_MAX 118
-
#define BC_VIEWDIR_SEC SECTOR_OFFSET(96) + 5
#define BC_VIEWDIR_MAX 180
-
#define BC_PICDIR_SEC SECTOR_OFFSET(93) + 8
#define BC_PICDIR_MAX 117
-
#define BC_SNDDIR_SEC SECTOR_OFFSET(99) + 5
#define BC_SNDDIR_MAX 29
+#define BC_WORDS SECTOR_OFFSET(0x26D) + 5
namespace Agi {
@@ -321,9 +313,14 @@ int AgiLoader_v1::loadObjects(const char *fname) {
return _vm->loadObjects(fname);
}
-// TODO: Find the disk image equivalent.
int AgiLoader_v1::loadWords(const char *fname) {
- return _vm->loadWords(fname);
+ if (_vm->getGameID() == GID_BC) {
+ Common::File f;
+ f.open(_filenameDisk0);
+ f.seek(BC_WORDS, SEEK_SET);
+ return _vm->loadWords_v1(f);
+ }
+ return errOK;
}
}
diff --git a/engines/agi/words.cpp b/engines/agi/words.cpp
index 4004abd697..8b53e9d3a3 100644
--- a/engines/agi/words.cpp
+++ b/engines/agi/words.cpp
@@ -36,6 +36,33 @@ static char *myStrndup(const char *src, int n) {
return tmp;
}
+int AgiEngine::loadWords_v1(Common::File &f) {
+ char str[64];
+ int k;
+
+ // Loop through alphabet, as words in the dictionary file are sorted by
+ // first character
+ f.seek(f.pos() + 26 * 2, SEEK_SET);
+ do {
+ // Read next word
+ for (k = 0; k < (int)sizeof(str) - 1; k++) {
+ str[k] = f.readByte();
+ if (str[k] == 0 || (uint8)str[k] == 0xFF)
+ break;
+ }
+
+ // And store it in our internal dictionary
+ if (k > 0) {
+ AgiWord *w = new AgiWord;
+ w->word = myStrndup(str, k + 1);
+ w->id = f.readUint16LE();
+ _game.words[str[0] - 'a'].push_back(w);
+ }
+ } while((uint8)str[0] != 0xFF);
+
+ return errOK;
+}
+
int AgiEngine::loadWords(const char *fname) {
Common::File fp;
@@ -50,8 +77,7 @@ int AgiEngine::loadWords(const char *fname) {
for (int i = 0; i < 26; i++) {
fp.seek(i * 2, SEEK_SET);
int offset = fp.readUint16BE();
- if (offset == 0)
- continue;
+ if (offset == 0) continue;
fp.seek(offset, SEEK_SET);
int k = fp.readByte();
while (!fp.eos() && !fp.err()) {