aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-29 22:28:22 -0400
committerPaul Gilbert2014-03-29 22:28:22 -0400
commit89af9dde8c412b4d11cd0107fe20f9bbbfd2e3bc (patch)
treee1d9bceb46ed0824f7c93e3fdc8c75d53a1b7349 /engines
parent32b9530789e1c308e3afe849c27c21285dfe1ab3 (diff)
downloadscummvm-rg350-89af9dde8c412b4d11cd0107fe20f9bbbfd2e3bc.tar.gz
scummvm-rg350-89af9dde8c412b4d11cd0107fe20f9bbbfd2e3bc.tar.bz2
scummvm-rg350-89af9dde8c412b4d11cd0107fe20f9bbbfd2e3bc.zip
MADS: Implemented message loading/decoding
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/dialogs.cpp3
-rw-r--r--engines/mads/dialogs.h1
-rw-r--r--engines/mads/game.cpp49
-rw-r--r--engines/mads/game.h1
-rw-r--r--engines/mads/nebular/game_nebular.cpp2
5 files changed, 55 insertions, 1 deletions
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index c5e99f859e..04e89fad61 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -342,7 +342,8 @@ Dialogs::Dialogs(MADSEngine *vm): _vm(vm) {
}
void Dialogs::show(int msgId) {
-
+ Common::StringArray msg = _vm->_game->getMessage(msgId);
+ warning("%s\n", msg[0].c_str());
}
} // End of namespace MADS
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 3f623a688b..35e4a85926 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -190,6 +190,7 @@ public:
virtual void showDialog() = 0;
virtual void showPicture(int objId, int msgId, int arg3 = 0) = 0;
+
void show(int msgId);
};
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index f81c752667..33cb52cec9 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -21,7 +21,9 @@
*/
#include "common/scummsys.h"
+#include "common/memstream.h"
#include "mads/mads.h"
+#include "mads/compression.h"
#include "mads/game.h"
#include "mads/game_data.h"
#include "mads/events.h"
@@ -329,4 +331,51 @@ void Game::loadQuotes() {
f.close();
}
+Common::StringArray Game::getMessage(uint32 id) {
+ File f("*MESSAGES.DAT");
+ int count = f.readUint16LE();
+
+ for (int idx = 0; idx < count; ++idx) {
+ uint32 itemId = f.readUint32LE();
+ uint32 offset = f.readUint32LE();
+ uint16 size = f.readUint16LE();
+
+ if (itemId == id) {
+ // Get the source buffer size
+ uint16 sizeIn;
+ if (idx == (count - 1)) {
+ sizeIn = f.size() - offset;
+ } else {
+ f.skip(4);
+ uint32 nextOffset = f.readUint32LE();
+ sizeIn = nextOffset - offset;
+ }
+
+ // Get the compressed data
+ f.seek(offset);
+ byte *bufferIn = new byte[sizeIn];
+ f.read(bufferIn, sizeIn);
+
+ // Decompress it
+ char *bufferOut = new char[size];
+ FabDecompressor fab;
+ fab.decompress(bufferIn, sizeIn, (byte *)bufferOut, size);
+
+ // Form the output string list
+ Common::StringArray result;
+ const char *p = bufferOut;
+ while (p < (bufferOut + size)) {
+ result.push_back(p);
+ p += strlen(p) + 1;
+ }
+
+ delete[] bufferIn;
+ delete[] bufferOut;
+ return result;
+ }
+ }
+
+ error("Invalid message Id specified");
+}
+
} // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 9da2694456..4521ad68c1 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -150,6 +150,7 @@ public:
uint32 getQuotesSize() { return _quotes.size(); }
const Common::String &getQuote(uint32 index) { return _quotes[index - 1]; }
+ Common::StringArray getMessage(uint32 id);
/**
* Standard object handling across the game
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 34af685981..2c6be6cfc2 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -52,6 +52,8 @@ ProtectionResult GameNebular::checkCopyProtection() {
dlg->show();
delete dlg;
*/
+ // Debug
+ _vm->_dialogs->show(1);
// DEBUG: Return that copy protection failed
return PROTECTION_SUCCEED;