aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/console.cpp4
-rw-r--r--engines/mohawk/cursors.cpp4
-rw-r--r--engines/mohawk/detection.cpp1
-rw-r--r--engines/mohawk/detection_tables.h149
-rw-r--r--engines/mohawk/livingbooks.cpp176
-rw-r--r--engines/mohawk/livingbooks.h67
-rw-r--r--engines/mohawk/livingbooks_code.cpp238
-rw-r--r--engines/mohawk/livingbooks_code.h22
-rw-r--r--engines/mohawk/resource.h148
-rw-r--r--engines/mohawk/sound.cpp2
10 files changed, 633 insertions, 178 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 6dce147513..ee67c9f23c 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -563,7 +563,7 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) {
// deriven.
debugN("\n\nDumping scripts for %s\'s card %d!\n", argv[1], (uint16)atoi(argv[3]));
debugN("==================================\n\n");
- Common::SeekableReadStream *cardStream = _vm->getResource(MKID_BE('CARD'), (uint16)atoi(argv[3]));
+ Common::SeekableReadStream *cardStream = _vm->getResource(MKTAG('C','A','R','D'), (uint16)atoi(argv[3]));
cardStream->seek(4);
RivenScriptList scriptList = _vm->_scriptMan->readScripts(cardStream, false);
for (uint32 i = 0; i < scriptList.size(); i++) {
@@ -576,7 +576,7 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) {
debugN("\n\nDumping scripts for %s\'s card %d hotspots!\n", argv[1], (uint16)atoi(argv[3]));
debugN("===========================================\n\n");
- Common::SeekableReadStream *hsptStream = _vm->getResource(MKID_BE('HSPT'), (uint16)atoi(argv[3]));
+ Common::SeekableReadStream *hsptStream = _vm->getResource(MKTAG('H','S','P','T'), (uint16)atoi(argv[3]));
uint16 hotspotCount = hsptStream->readUint16BE();
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index 9233a8497c..b4969f990a 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -221,7 +221,7 @@ void MacCursorManager::setCursor(uint16 id) {
}
// Try a color cursor first
- Common::SeekableReadStream *stream = _resFork->getResource(MKID_BE('crsr'), id);
+ Common::SeekableReadStream *stream = _resFork->getResource(MKTAG('c','r','s','r'), id);
if (stream) {
byte *cursor, *palette;
@@ -239,7 +239,7 @@ void MacCursorManager::setCursor(uint16 id) {
}
// Fall back to b&w cursors
- stream = _resFork->getResource(MKID_BE('CURS'), id);
+ stream = _resFork->getResource(MKTAG('C','U','R','S'), id);
if (stream) {
setMacXorCursor(stream);
diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp
index c31df3010d..cad24b55f1 100644
--- a/engines/mohawk/detection.cpp
+++ b/engines/mohawk/detection.cpp
@@ -121,6 +121,7 @@ static const PlainGameDescriptor mohawkGames[] = {
{"csworld", "Where in the World is Carmen Sandiego?"},
{"csamtrak", "Where in America is Carmen Sandiego? (The Great Amtrak Train Adventure)"},
{"carmentq", "Carmen Sandiego's ThinkQuick Challenge"},
+ {"carmentqc", "Carmen Sandiego's ThinkQuick Challenge Custom Question Creator"},
{"maggiesfa", "Maggie's Farmyard Adventure"},
{"jamesmath", "James Discovers/Explores Math"},
{"treehouse", "The Treehouse"},
diff --git a/engines/mohawk/detection_tables.h b/engines/mohawk/detection_tables.h
index 27ee3401f5..a8f9ee557b 100644
--- a/engines/mohawk/detection_tables.h
+++ b/engines/mohawk/detection_tables.h
@@ -610,6 +610,21 @@ static const MohawkGameDescription gameDescriptions[] = {
{
{
+ "carmentqc",
+ "",
+ AD_ENTRY1("Outline.txt", "6a281eefe72987afb0f8fb6cf84553f5"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_LIVINGBOOKSV5,
+ 0,
+ 0
+ },
+
+ {
+ {
"maggiesfa",
"",
AD_ENTRY1("Outline", "b7dc6e65fa9e80784a5bb8b557aa37c4"),
@@ -869,6 +884,22 @@ static const MohawkGameDescription gameDescriptions[] = {
"TORTOISE.EXE"
},
+ // From Scarlatti in bug #3275626
+ {
+ {
+ "tortoise",
+ "Demo v1.1",
+ AD_ENTRY1("TORTOISE.512", "14400a3358a3f1148e4d4b47bc3523c9"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_LIVINGBOOKSV1,
+ GF_DEMO,
+ "TORTOISE.EXE"
+ },
+
{
{
"tortoise",
@@ -929,6 +960,22 @@ static const MohawkGameDescription gameDescriptions[] = {
"ARTHUR.EXE"
},
+ // From Scarlatti in bug #3275626
+ {
+ {
+ "arthur",
+ "Demo v1.1",
+ AD_ENTRY1("ARTHUR.512", "dabdd466dea26ab5ecb9415cf73f8601"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_LIVINGBOOKSV1,
+ GF_DEMO,
+ "ARTHUR.EXE"
+ },
+
{
{
"arthur",
@@ -1006,6 +1053,22 @@ static const MohawkGameDescription gameDescriptions[] = {
"GRANDMA.EXE"
},
+ // From Scarlatti in bug #3275626
+ {
+ {
+ "grandma",
+ "Demo v1.1",
+ AD_ENTRY1("GRANDMA.512", "4f616647245bb4e37e6dab7557dad304"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_LIVINGBOOKSV1,
+ GF_DEMO,
+ "GRANDMA.EXE"
+ },
+
{
{
"grandma",
@@ -1036,6 +1099,23 @@ static const MohawkGameDescription gameDescriptions[] = {
"Living Books Player"
},
+ // Ruff's Bone 1.0
+ // From pacifist
+ {
+ {
+ "ruff",
+ "",
+ AD_ENTRY1("RUFF.512", "3dbda0de6f47a64d1714d89f5a5f60d1"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_LIVINGBOOKSV1,
+ 0,
+ "RUFF.EXE"
+ },
+
{
{
"ruff",
@@ -1051,36 +1131,35 @@ static const MohawkGameDescription gameDescriptions[] = {
"RUFF.EXE"
},
+ // From Scarlatti in bug #3275626
{
{
"ruff",
"Demo",
- AD_ENTRY1("Ruff's Bone Demo", "22553ac2ceb2a166bdf1def6ad348532"),
+ AD_ENTRY1("RUFF.512", "07b9d013e2400d61ca268892a76de4d2"),
Common::EN_ANY,
- Common::kPlatformMacintosh,
+ Common::kPlatformWindows,
ADGF_DEMO,
Common::GUIO_NONE
},
GType_LIVINGBOOKSV1,
GF_DEMO,
- "Living Books Player"
+ "RUFF.EXE"
},
- // Ruff's Bone 1.0
- // From pacifist
{
{
"ruff",
- "",
- AD_ENTRY1("RUFF.512", "3dbda0de6f47a64d1714d89f5a5f60d1"),
+ "Demo",
+ AD_ENTRY1("Ruff's Bone Demo", "22553ac2ceb2a166bdf1def6ad348532"),
Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_NO_FLAGS,
+ Common::kPlatformMacintosh,
+ ADGF_DEMO,
Common::GUIO_NONE
},
GType_LIVINGBOOKSV1,
- 0,
- "RUFF.EXE"
+ GF_DEMO,
+ "Living Books Player"
},
{
@@ -1113,6 +1192,22 @@ static const MohawkGameDescription gameDescriptions[] = {
"NEWKID.EXE"
},
+ // From Scarlatti in bug #3275626
+ {
+ {
+ "newkid",
+ "Demo v1.1",
+ AD_ENTRY1("NEWKID.512", "de576f3481f62e84eda03b4d2307492b"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_LIVINGBOOKSV1,
+ GF_DEMO,
+ "NEWKID.EXE"
+ },
+
{
{
"newkid",
@@ -1174,6 +1269,22 @@ static const MohawkGameDescription gameDescriptions[] = {
"BIRTHDAY.EXE"
},
+ // From Scarlatti in bug #3275626
+ {
+ {
+ "arthurbday",
+ "Demo",
+ AD_ENTRY1("BIRTHDAY.512", "2946b1e06f59ea607b8b29dfc6ba8976"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_LIVINGBOOKSV1,
+ GF_DEMO,
+ "BIRTHDAY.EXE"
+ },
+
{
{
"arthurbday",
@@ -1219,6 +1330,22 @@ static const MohawkGameDescription gameDescriptions[] = {
"Little Monster at School"
},
+ // From Scarlatti in bug #3275626
+ {
+ {
+ "lilmonster",
+ "Demo",
+ AD_ENTRY1("MONSTER.512", "029e57f1fc8dd1f93f6623a1841f0df2"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_LIVINGBOOKSV1,
+ GF_DEMO,
+ "MONSTER.EXE"
+ },
+
{
{
"catinthehat",
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index 542cc9645d..7f6c3cc43a 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -72,6 +72,48 @@ Common::Rect MohawkEngine_LivingBooks::readRect(Common::SeekableSubReadStreamEnd
return rect;
}
+LBPage::LBPage(MohawkEngine_LivingBooks *vm) : _vm(vm) {
+ _code = NULL;
+ _mhk = NULL;
+
+ _baseId = 0;
+ _cascade = false;
+}
+
+void LBPage::open(MohawkArchive *mhk, uint16 baseId) {
+ _mhk = mhk;
+ _baseId = baseId;
+
+ _vm->addArchive(_mhk);
+ if (_vm->hasResource(ID_BCOD, baseId))
+ _code = new LBCode(_vm, baseId);
+
+ loadBITL(baseId);
+ for (uint i = 0; i < _items.size(); i++)
+ _vm->addItem(_items[i]);
+
+ for (uint32 i = 0; i < _items.size(); i++)
+ _items[i]->init();
+}
+
+void LBPage::itemDestroyed(LBItem *item) {
+ for (uint i = 0; i < _items.size(); i++)
+ if (item == _items[i]) {
+ _items.remove_at(i);
+ return;
+ }
+ error("itemDestroyed didn't find item");
+}
+
+LBPage::~LBPage() {
+ delete _code;
+ _vm->removeItems(_items);
+ for (uint i = 0; i < _items.size(); i++)
+ delete _items[i];
+ _vm->removeArchive(_mhk);
+ delete _mhk;
+}
+
MohawkEngine_LivingBooks::MohawkEngine_LivingBooks(OSystem *syst, const MohawkGameDescription *gamedesc) : MohawkEngine(syst, gamedesc) {
_needsUpdate = false;
_needsRedraw = false;
@@ -82,11 +124,11 @@ MohawkEngine_LivingBooks::MohawkEngine_LivingBooks(OSystem *syst, const MohawkGa
_alreadyShowedIntro = false;
- _code = NULL;
-
_rnd = new Common::RandomSource();
g_eventRec.registerRandomSource(*_rnd, "livingbooks");
+ _page = NULL;
+
const Common::FSNode gameDataDir(ConfMan.get("path"));
// Rugrats
SearchMan.addSubDirectoryMatching(gameDataDir, "program");
@@ -281,16 +323,9 @@ void MohawkEngine_LivingBooks::destroyPage() {
_eventQueue.clear();
- delete _code;
- _code = NULL;
-
- for (uint32 i = 0; i < _items.size(); i++)
- delete _items[i];
- _items.clear();
-
- for (uint32 i = 0; i < _mhk.size(); i++)
- delete _mhk[i];
- _mhk.clear();
+ delete _page;
+ assert(_items.empty());
+ _page = NULL;
_notifyEvents.clear();
@@ -342,7 +377,8 @@ bool MohawkEngine_LivingBooks::loadPage(LBMode mode, uint page, uint subpage) {
MohawkArchive *pageArchive = createMohawkArchive();
if (!filename.empty() && pageArchive->open(filename)) {
- _mhk.push_back(pageArchive);
+ _page = new LBPage(this);
+ _page->open(pageArchive, 1000);
} else {
delete pageArchive;
debug(2, "Could not find page %d.%d for '%s'", page, subpage, name.c_str());
@@ -360,7 +396,7 @@ bool MohawkEngine_LivingBooks::loadPage(LBMode mode, uint page, uint subpage) {
}
}
- debug(1, "Stack Version: %d", getResourceVersion());
+ debug(1, "Page Version: %d", _page->getResourceVersion());
_curMode = mode;
_curPage = page;
@@ -370,13 +406,6 @@ bool MohawkEngine_LivingBooks::loadPage(LBMode mode, uint page, uint subpage) {
_gfx->setPalette(1000);
- if (hasResource(ID_BCOD, 1000))
- _code = new LBCode(this);
-
- loadBITL(1000);
- for (uint32 i = 0; i < _items.size(); i++)
- _items[i]->init();
-
_phase = 0;
_introDone = false;
@@ -523,6 +552,7 @@ void MohawkEngine_LivingBooks::updatePage() {
_items.remove_at(i);
i--;
delete delayedEvent.item;
+ _page->itemDestroyed(delayedEvent.item);
if (_focus == delayedEvent.item)
_focus = NULL;
break;
@@ -550,6 +580,39 @@ void MohawkEngine_LivingBooks::updatePage() {
}
}
+void MohawkEngine_LivingBooks::addArchive(MohawkArchive *archive) {
+ _mhk.push_back(archive);
+}
+
+void MohawkEngine_LivingBooks::removeArchive(MohawkArchive *archive) {
+ for (uint i = 0; i < _mhk.size(); i++) {
+ if (archive != _mhk[i])
+ continue;
+ _mhk.remove_at(i);
+ return;
+ }
+
+ error("removeArchive didn't find archive");
+}
+
+void MohawkEngine_LivingBooks::addItem(LBItem *item) {
+ _items.push_back(item);
+}
+
+void MohawkEngine_LivingBooks::removeItems(const Common::Array<LBItem *> &items) {
+ for (uint i = 0; i < items.size(); i++) {
+ bool found = false;
+ for (uint16 j = 0; j < _items.size(); j++) {
+ if (items[i] != _items[j])
+ continue;
+ found = true;
+ _items.remove_at(j);
+ break;
+ }
+ assert(found);
+ }
+}
+
LBItem *MohawkEngine_LivingBooks::getItemById(uint16 id) {
for (uint16 i = 0; i < _items.size(); i++)
if (_items[i]->getId() == id)
@@ -558,6 +621,14 @@ LBItem *MohawkEngine_LivingBooks::getItemById(uint16 id) {
return NULL;
}
+LBItem *MohawkEngine_LivingBooks::getItemByName(Common::String name) {
+ for (uint16 i = 0; i < _items.size(); i++)
+ if (_items[i]->getName() == name)
+ return _items[i];
+
+ return NULL;
+}
+
void MohawkEngine_LivingBooks::setFocus(LBItem *focus) {
_focus = focus;
}
@@ -624,9 +695,9 @@ void MohawkEngine_LivingBooks::lockSound(LBItem *owner, bool lock) {
}
}
-// Only 1 VSRN resource per stack, Id 1000
-uint16 MohawkEngine_LivingBooks::getResourceVersion() {
- Common::SeekableReadStream *versionStream = getResource(ID_VRSN, 1000);
+// Only 1 VSRN resource per page
+uint16 LBPage::getResourceVersion() {
+ Common::SeekableReadStream *versionStream = _vm->getResource(ID_VRSN, _baseId);
// FIXME: some V2 games have very strange version entries
if (versionStream->size() != 2)
@@ -638,43 +709,43 @@ uint16 MohawkEngine_LivingBooks::getResourceVersion() {
return version;
}
-void MohawkEngine_LivingBooks::loadBITL(uint16 resourceId) {
- Common::SeekableSubReadStreamEndian *bitlStream = wrapStreamEndian(ID_BITL, resourceId);
+void LBPage::loadBITL(uint16 resourceId) {
+ Common::SeekableSubReadStreamEndian *bitlStream = _vm->wrapStreamEndian(ID_BITL, resourceId);
while (true) {
- Common::Rect rect = readRect(bitlStream);
+ Common::Rect rect = _vm->readRect(bitlStream);
uint16 type = bitlStream->readUint16();
LBItem *res;
switch (type) {
case kLBPictureItem:
- res = new LBPictureItem(this, rect);
+ res = new LBPictureItem(_vm, this, rect);
break;
case kLBAnimationItem:
- res = new LBAnimationItem(this, rect);
+ res = new LBAnimationItem(_vm, this, rect);
break;
case kLBPaletteItem:
- res = new LBPaletteItem(this, rect);
+ res = new LBPaletteItem(_vm, this, rect);
break;
case kLBGroupItem:
- res = new LBGroupItem(this, rect);
+ res = new LBGroupItem(_vm, this, rect);
break;
case kLBSoundItem:
- res = new LBSoundItem(this, rect);
+ res = new LBSoundItem(_vm, this, rect);
break;
case kLBLiveTextItem:
- res = new LBLiveTextItem(this, rect);
+ res = new LBLiveTextItem(_vm, this, rect);
break;
case kLBMovieItem:
- res = new LBMovieItem(this, rect);
+ res = new LBMovieItem(_vm, this, rect);
break;
case kLBMiniGameItem:
- res = new LBMiniGameItem(this, rect);
+ res = new LBMiniGameItem(_vm, this, rect);
break;
default:
warning("Unknown item type %04x", type);
case 3: // often used for buttons
- res = new LBItem(this, rect);
+ res = new LBItem(_vm, this, rect);
break;
}
@@ -1802,7 +1873,7 @@ LBScriptEntry::~LBScriptEntry() {
delete subentries[i];
}
-LBItem::LBItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : _vm(vm), _rect(rect) {
+LBItem::LBItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : _vm(vm), _page(page), _rect(rect) {
_phase = 0;
_loopMode = 0;
@@ -1926,13 +1997,14 @@ LBScriptEntry *LBItem::parseScriptEntry(uint16 type, uint16 &size, Common::Seeka
debug(4, "%d targets with targeting type %04x", count, targetingType);
// FIXME: targeting by name
+ uint oldAlign = size % 2;
for (uint i = 0; i < count; i++) {
Common::String target = _vm->readString(stream);
warning("ignoring target '%s' in script entry", target.c_str());
size -= target.size() + 1;
}
- if (size % 2 == 1) {
+ if (size % 2 != oldAlign) {
stream->skip(1);
size--;
}
@@ -2190,9 +2262,9 @@ void LBItem::readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEnd
{
assert(size == 4);
uint offset = stream->readUint32();
- if (!_vm->_code)
+ if (!_page->_code)
error("no BCOD?");
- _vm->_code->runCode(this, offset);
+ _page->_code->runCode(this, offset);
}
break;
@@ -2659,9 +2731,9 @@ int LBItem::runScriptEntry(LBScriptEntry *entry) {
break;
case kLBOpSendExpression:
- if (!_vm->_code)
+ if (!_page->_code)
error("no BCOD?");
- _vm->_code->runCode(this, entry->offset);
+ _page->_code->runCode(this, entry->offset);
break;
case kLBOpRunSubentries:
@@ -2694,10 +2766,10 @@ int LBItem::runScriptEntry(LBScriptEntry *entry) {
case kLBOpJumpUnlessExpression:
case kLBOpBreakExpression:
case kLBOpJumpToExpression:
- if (!_vm->_code)
+ if (!_page->_code)
error("no BCOD?");
{
- LBValue r = _vm->_code->runCode(this, entry->offset);
+ LBValue r = _page->_code->runCode(this, entry->offset);
// FIXME
return r.integer;
}
@@ -2973,7 +3045,7 @@ bool LBItem::checkCondition(const Common::String &condition) {
return false; // unreachable
}
-LBSoundItem::LBSoundItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
+LBSoundItem::LBSoundItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBSoundItem");
_running = false;
}
@@ -3019,7 +3091,7 @@ void LBSoundItem::stop() {
LBItem::stop();
}
-LBGroupItem::LBGroupItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
+LBGroupItem::LBGroupItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBGroupItem");
_starting = false;
}
@@ -3134,7 +3206,7 @@ void LBGroupItem::stop() {
}
}
-LBPaletteItem::LBPaletteItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
+LBPaletteItem::LBPaletteItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBPaletteItem");
_fadeInStart = 0;
@@ -3219,7 +3291,7 @@ void LBPaletteItem::update() {
LBItem::update();
}
-LBLiveTextItem::LBLiveTextItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
+LBLiveTextItem::LBLiveTextItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
_currentPhrase = 0xFFFF;
_currentWord = 0xFFFF;
debug(3, "new LBLiveTextItem");
@@ -3466,7 +3538,7 @@ void LBLiveTextItem::notify(uint16 data, uint16 from) {
LBItem::notify(data, from);
}
-LBPictureItem::LBPictureItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
+LBPictureItem::LBPictureItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBPictureItem");
}
@@ -3509,7 +3581,7 @@ void LBPictureItem::draw() {
_vm->_gfx->copyAnimImageToScreen(_resourceId, _rect.left, _rect.top);
}
-LBAnimationItem::LBAnimationItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
+LBAnimationItem::LBAnimationItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
_anim = NULL;
_running = false;
debug(3, "new LBAnimationItem");
@@ -3608,7 +3680,7 @@ void LBAnimationItem::draw() {
_anim->draw();
}
-LBMovieItem::LBMovieItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
+LBMovieItem::LBMovieItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBMovieItem");
}
@@ -3637,7 +3709,7 @@ bool LBMovieItem::togglePlaying(bool playing, bool restart) {
return LBItem::togglePlaying(playing, restart);
}
-LBMiniGameItem::LBMiniGameItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
+LBMiniGameItem::LBMiniGameItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect) : LBItem(vm, page, rect) {
debug(3, "new LBMiniGameItem");
}
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 3eff039385..cd3b206d57 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -237,6 +237,7 @@ enum {
};
class MohawkEngine_LivingBooks;
+class LBPage;
class LBGraphics;
class LBAnimation;
@@ -357,7 +358,7 @@ class LBItem {
friend class LBCode;
public:
- LBItem(MohawkEngine_LivingBooks *vm, Common::Rect rect);
+ LBItem(MohawkEngine_LivingBooks *vm, LBPage *page, Common::Rect rect);
virtual ~LBItem();
void readFrom(Common::SeekableSubReadStreamEndian *stream);
@@ -385,11 +386,14 @@ public:
virtual void notify(uint16 data, uint16 from); // 0x1A
uint16 getId() { return _itemId; }
+ const Common::String &getName() { return _desc; }
+ const Common::Rect &getRect() { return _rect; }
uint16 getSoundPriority() { return _soundMode; }
bool isAmbient() { return _isAmbient; }
protected:
MohawkEngine_LivingBooks *_vm;
+ LBPage *_page;
void setNextTime(uint16 min, uint16 max);
void setNextTime(uint16 min, uint16 max, uint32 start);
@@ -425,7 +429,7 @@ protected:
class LBSoundItem : public LBItem {
public:
- LBSoundItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBSoundItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBSoundItem();
void update();
@@ -443,7 +447,7 @@ struct GroupEntry {
class LBGroupItem : public LBItem {
public:
- LBGroupItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBGroupItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
@@ -467,7 +471,7 @@ protected:
class LBPaletteItem : public LBItem {
public:
- LBPaletteItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBPaletteItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBPaletteItem();
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
@@ -494,7 +498,7 @@ struct LiveTextPhrase {
class LBLiveTextItem : public LBItem {
public:
- LBLiveTextItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBLiveTextItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
@@ -523,7 +527,7 @@ protected:
class LBPictureItem : public LBItem {
public:
- LBPictureItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBPictureItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
@@ -534,7 +538,7 @@ public:
class LBAnimationItem : public LBItem {
public:
- LBAnimationItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBAnimationItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBAnimationItem();
void setEnabled(bool enabled);
@@ -555,7 +559,7 @@ protected:
class LBMovieItem : public LBItem {
public:
- LBMovieItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBMovieItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBMovieItem();
void update();
@@ -564,14 +568,14 @@ public:
class LBMiniGameItem : public LBItem {
public:
- LBMiniGameItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ LBMiniGameItem(MohawkEngine_LivingBooks *_vm, LBPage *page, Common::Rect rect);
~LBMiniGameItem();
bool togglePlaying(bool playing, bool restart);
};
struct NotifyEvent {
- NotifyEvent(uint t, uint p) : type(t), param(p) { }
+ NotifyEvent(uint t, uint p) : type(t), param(p), newUnknown(0), newMode(0), newPage(0), newSubpage(0) { }
uint type;
uint param;
@@ -594,6 +598,30 @@ struct DelayedEvent {
DelayedEventType type;
};
+class LBPage {
+public:
+ LBPage(MohawkEngine_LivingBooks *vm);
+ ~LBPage();
+
+ void open(MohawkArchive *mhk, uint16 baseId);
+ uint16 getResourceVersion();
+
+ void itemDestroyed(LBItem *item);
+
+ LBCode *_code;
+
+protected:
+ MohawkEngine_LivingBooks *_vm;
+
+ MohawkArchive *_mhk;
+ Common::Array<LBItem *> _items;
+
+ uint16 _baseId;
+ bool _cascade;
+
+ void loadBITL(uint16 resourceId);
+};
+
class MohawkEngine_LivingBooks : public MohawkEngine {
protected:
Common::Error run();
@@ -614,7 +642,13 @@ public:
Common::Rect readRect(Common::SeekableSubReadStreamEndian *stream);
GUI::Debugger *getDebugger() { return _console; }
+ void addArchive(MohawkArchive *archive);
+ void removeArchive(MohawkArchive *Archive);
+ void addItem(LBItem *item);
+ void removeItems(const Common::Array<LBItem *> &items);
+
LBItem *getItemById(uint16 id);
+ LBItem *getItemByName(Common::String name);
void setFocus(LBItem *focus);
void setEnableForAll(bool enable, LBItem *except = 0);
@@ -633,11 +667,13 @@ public:
void prevPage();
void nextPage();
- LBCode *_code;
-
// TODO: make private
Common::HashMap<Common::String, LBValue> _variables;
+ // helper functions, also used by LBProxyItem
+ Common::String getFileNameFromConfig(const Common::String &section, const Common::String &key, Common::String &leftover);
+ MohawkArchive *createMohawkArchive() const;
+
private:
LivingBooksConsole *_console;
Common::ConfigFile _bookInfoFile;
@@ -651,6 +687,7 @@ private:
LBMode _curMode;
uint16 _curPage, _curSubPage;
uint16 _phase;
+ LBPage *_page;
Common::Array<LBItem *> _items;
Common::Queue<DelayedEvent> _eventQueue;
LBItem *_focus;
@@ -663,8 +700,6 @@ private:
uint16 _soundLockOwner;
uint16 _maxSoundPriority;
- uint16 getResourceVersion();
- void loadBITL(uint16 resourceId);
void loadSHP(uint16 resourceId);
bool tryDefaultPage();
@@ -698,10 +733,6 @@ private:
Common::String getStringFromConfig(const Common::String &section, const Common::String &key);
Common::String getStringFromConfig(const Common::String &section, const Common::String &key, Common::String &leftover);
int getIntFromConfig(const Common::String &section, const Common::String &key);
- Common::String getFileNameFromConfig(const Common::String &section, const Common::String &key, Common::String &leftover);
-
- // Platform/Version functions
- MohawkArchive *createMohawkArchive() const;
};
} // End of namespace Mohawk
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index c0718d941a..84f69af2ac 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -71,6 +71,19 @@ bool LBValue::isZero() const {
return toInt() == 0; // FIXME
}
+Common::String LBValue::toString() const {
+ switch (type) {
+ case kLBValueString:
+ return string;
+ case kLBValueInteger:
+ return Common::String::format("%d", integer);
+ case kLBValueReal:
+ return Common::String::format("%f", real);
+ default:
+ return string; // FIXME
+ }
+}
+
int LBValue::toInt() const {
return integer; // FIXME
}
@@ -79,8 +92,38 @@ double LBValue::toDouble() const {
return real; // FIXME
}
-LBCode::LBCode(MohawkEngine_LivingBooks *vm) : _vm(vm) {
- Common::SeekableSubReadStreamEndian *bcodStream = _vm->wrapStreamEndian(ID_BCOD, 1000);
+Common::Point LBValue::toPoint() const {
+ switch (type) {
+ case kLBValueString:
+ // FIXME
+ return Common::Point();
+ case kLBValueInteger:
+ return Common::Point(integer, integer);
+ case kLBValuePoint:
+ return point;
+ default:
+ error("failed to convert to point");
+ }
+}
+
+Common::Rect LBValue::toRect() const {
+ switch (type) {
+ case kLBValueString:
+ // FIXME
+ return Common::Rect();
+ case kLBValueInteger:
+ return Common::Rect(integer, integer, integer, integer);
+ case kLBValueRect:
+ return rect;
+ case kLBValueItemPtr:
+ return item->getRect();
+ default:
+ error("failed to convert to rect");
+ }
+}
+
+LBCode::LBCode(MohawkEngine_LivingBooks *vm, uint16 baseId) : _vm(vm) {
+ Common::SeekableSubReadStreamEndian *bcodStream = _vm->wrapStreamEndian(ID_BCOD, baseId);
uint32 totalSize = bcodStream->readUint32();
if (totalSize != (uint32)bcodStream->size())
@@ -206,7 +249,7 @@ LBValue LBCode::runCode(byte terminator) {
if (_currToken == terminator || _currToken == kTokenEndOfFile)
break;
if (_currToken != kTokenEndOfStatement && _currToken != kTokenEndOfFile)
- error("missing EOS");
+ error("missing EOS (got %02x)", _currToken);
debugN("\n");
}
@@ -214,8 +257,29 @@ LBValue LBCode::runCode(byte terminator) {
}
void LBCode::parseStatement() {
- // FIXME: logical operators
parseComparisons();
+
+ if (_currToken != kTokenAnd && _currToken != kTokenOr)
+ return;
+ byte op = _currToken;
+ if (op == kTokenAnd)
+ debugN(" && ");
+ else
+ debugN(" || ");
+
+ nextToken();
+ parseComparisons();
+
+ LBValue val2 = _stack.pop();
+ LBValue val1 = _stack.pop();
+ bool result;
+ if (op == kTokenAnd)
+ result = !val1.isZero() && !val2.isZero();
+ else
+ result = !val1.isZero() || !val2.isZero();
+
+ debugN(" [--> %s]", result ? "true" : "false");
+ _stack.push(result);
}
void LBCode::parseComparisons() {
@@ -253,7 +317,7 @@ void LBCode::parseComparisons() {
error("comparison didn't get enough values");
LBValue val2 = _stack.pop();
LBValue val1 = _stack.pop();
- bool result;
+ bool result = false;
// FIXME: should work for non-integers!!
switch (comparison) {
case kTokenEquals:
@@ -277,17 +341,50 @@ void LBCode::parseComparisons() {
}
debugN(" [--> %s]", result ? "true" : "false");
- _stack.push(result ? 1 : 0);
+ _stack.push(result);
}
void LBCode::parseConcat() {
parseArithmetic1();
- // FIXME: string concat
+
+ if (_currToken != kTokenConcat)
+ return;
+
+ debugN(" & ");
+ nextToken();
+ parseArithmetic1();
+
+ LBValue val2 = _stack.pop();
+ LBValue val1 = _stack.pop();
+ Common::String result = val1.toString() + val2.toString();
+ debugN(" [--> \"%s\"]", result.c_str());
+ _stack.push(result);
}
void LBCode::parseArithmetic1() {
parseArithmetic2();
- // FIXME: -/+ math operators
+
+ if (_currToken != kTokenMinus && _currToken != kTokenPlus)
+ return;
+
+ byte op = _currToken;
+ if (op == kTokenMinus)
+ debugN(" - ");
+ else if (op == kTokenPlus)
+ debugN(" + ");
+
+ nextToken();
+ parseArithmetic2();
+
+ LBValue val2 = _stack.pop();
+ LBValue val1 = _stack.pop();
+ LBValue result;
+ // TODO: cope with non-integers
+ if (op == kTokenMinus)
+ result = val1.toInt() - val2.toInt();
+ else
+ result = val1.toInt() + val2.toInt();
+ _stack.push(result);
}
void LBCode::parseArithmetic2() {
@@ -310,10 +407,11 @@ void LBCode::parseMain() {
Common::String varname = _currValue.string;
debugN("%s", varname.c_str());
nextToken();
- if (varname == "self") {
+ if (varname.equalsIgnoreCase("self")) {
_stack.push(LBValue(_currSource));
if (_currToken == kTokenAssign)
error("attempted assignment to self");
+ break;
} else if (_currToken == kTokenAssign) {
debugN(" = ");
nextToken();
@@ -326,7 +424,16 @@ void LBCode::parseMain() {
} else {
_stack.push(_vm->_variables[varname]);
}
- // FIXME: pre/postincrement
+ // FIXME: pre/postincrement for non-integers
+ if (_currToken == kTokenPlusPlus) {
+ debugN("++");
+ _vm->_variables[varname].integer++;
+ nextToken();
+ } else if (_currToken == kTokenMinusMinus) {
+ debugN("--");
+ _vm->_variables[varname].integer--;
+ nextToken();
+ }
}
break;
@@ -348,6 +455,17 @@ void LBCode::parseMain() {
nextToken();
break;
+ case kTokenTrue:
+ debugN("TRUE");
+ _stack.push(true);
+ nextToken();
+ break;
+ case kTokenFalse:
+ debugN("FALSE");
+ _stack.push(false);
+ nextToken();
+ break;
+
case kTokenOpenBracket:
debugN("(");
nextToken();
@@ -442,6 +560,21 @@ Common::Array<LBValue> LBCode::readParams() {
return params;
}
+Common::Rect LBCode::getRectFromParams(const Common::Array<LBValue> &params) {
+ if (params.size() == 0) {
+ assert(_currSource);
+ return _currSource->getRect();
+ } else if (params.size() == 1) {
+ const LBValue &val = params[0];
+ LBItem *item = _vm->getItemByName(val.toString());
+ if (item)
+ return item->getRect();
+ else
+ return val.toRect();
+ } else
+ error("getRectFromParams got called with weird state");
+}
+
struct CodeCommandInfo {
const char *name;
typedef void (LBCode::*CommandFunc)(const Common::Array<LBValue> &params);
@@ -457,16 +590,16 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
{ "max", 0 },
{ "min", 0 },
{ "abs", 0 },
- { "getRect", 0 }, // also "makeRect"
+ { "getRect", &LBCode::cmdGetRect }, // also "makeRect"
{ "makePt", 0 }, // also "makePair"
- { "topleft", 0 },
- { "bottomright", 0 },
+ { "topLeft", &LBCode::cmdTopLeft },
+ { "bottomRight", &LBCode::cmdBottomRight },
{ "mousePos", 0 },
- { "top", 0 },
- { "left", 0 },
- { "bottom", 0 },
+ { "top", &LBCode::cmdTop },
+ { "left", &LBCode::cmdLeft },
+ { "bottom", &LBCode::cmdBottom },
// 0x10
- { "right", 0 },
+ { "right", &LBCode::cmdRight },
{ "xpos", 0 },
{ "ypos", 0 },
{ "playFrom", 0 },
@@ -607,6 +740,67 @@ void LBCode::cmdUnimplemented(const Common::Array<LBValue> &params) {
warning("unimplemented command called");
}
+void LBCode::cmdGetRect(const Common::Array<LBValue> &params) {
+ if (params.size() < 2) {
+ _stack.push(getRectFromParams(params));
+ } else if (params.size() == 2) {
+ Common::Point p1 = params[0].toPoint();
+ Common::Point p2 = params[1].toPoint();
+ _stack.push(Common::Rect(p1.x, p1.y, p2.x, p2.y));
+ } else if (params.size() == 4) {
+ _stack.push(Common::Rect(params[0].toInt(), params[1].toInt(), params[2].toInt(), params[3].toInt()));
+ } else
+ error("incorrect number of parameters (%d) to getRect", params.size());
+}
+
+void LBCode::cmdTopLeft(const Common::Array<LBValue> &params) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to topLeft", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(Common::Point(rect.top, rect.left));
+}
+
+void LBCode::cmdBottomRight(const Common::Array<LBValue> &params) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to bottomRight", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(Common::Point(rect.bottom, rect.right));
+}
+
+void LBCode::cmdTop(const Common::Array<LBValue> &params) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to top", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(rect.top);
+}
+
+void LBCode::cmdLeft(const Common::Array<LBValue> &params) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to left", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(rect.left);
+}
+
+void LBCode::cmdBottom(const Common::Array<LBValue> &params) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to bottom", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(rect.bottom);
+}
+
+void LBCode::cmdRight(const Common::Array<LBValue> &params) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to right", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(rect.right);
+}
+
void LBCode::cmdSetPlayParams(const Common::Array<LBValue> &params) {
if (params.size() > 8)
error("too many parameters (%d) to setPlayParams", params.size());
@@ -785,6 +979,16 @@ void LBCode::runNotifyCommand() {
}
break;
+ case kLBNotifyQuit:
+ {
+ debugN("quit");
+ Common::Array<LBValue> params = readParams();
+ if (params.size() != 0)
+ error("incorrect number of parameters (%d) to quit", params.size());
+ _vm->addNotifyEvent(NotifyEvent(kLBNotifyQuit, 0));
+ }
+ break;
+
default:
error("unknown notify command %02x in code", commandType);
}
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 71174cc09e..cd9ac1004a 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -57,6 +57,14 @@ struct LBValue {
type = kLBValueString;
string = str;
}
+ LBValue(const Common::Point &p) {
+ type = kLBValuePoint;
+ point = p;
+ }
+ LBValue(const Common::Rect &r) {
+ type = kLBValueRect;
+ rect = r;
+ }
LBValue(LBItem *itm) {
type = kLBValueItemPtr;
item = itm;
@@ -99,8 +107,11 @@ struct LBValue {
bool isNumeric() const;
bool isZero() const;
+ Common::String toString() const;
int toInt() const;
double toDouble() const;
+ Common::Point toPoint() const;
+ Common::Rect toRect() const;
};
enum {
@@ -169,7 +180,7 @@ enum {
class LBCode {
public:
- LBCode(MohawkEngine_LivingBooks *vm);
+ LBCode(MohawkEngine_LivingBooks *vm, uint16 baseId);
~LBCode();
LBValue runCode(LBItem *src, uint32 offset);
@@ -199,12 +210,21 @@ protected:
void parseMain();
Common::Array<LBValue> readParams();
+ Common::Rect getRectFromParams(const Common::Array<LBValue> &params);
+
void runGeneralCommand();
void runItemCommand();
void runNotifyCommand();
public:
void cmdUnimplemented(const Common::Array<LBValue> &params);
+ void cmdGetRect(const Common::Array<LBValue> &params);
+ void cmdTopLeft(const Common::Array<LBValue> &params);
+ void cmdBottomRight(const Common::Array<LBValue> &params);
+ void cmdTop(const Common::Array<LBValue> &params);
+ void cmdLeft(const Common::Array<LBValue> &params);
+ void cmdBottom(const Common::Array<LBValue> &params);
+ void cmdRight(const Common::Array<LBValue> &params);
void cmdSetPlayParams(const Common::Array<LBValue> &params);
void cmdSetKeyEvent(const Common::Array<LBValue> &params);
void cmdSetHitTest(const Common::Array<LBValue> &params);
diff --git a/engines/mohawk/resource.h b/engines/mohawk/resource.h
index 18e8f80fb2..07c727951c 100644
--- a/engines/mohawk/resource.h
+++ b/engines/mohawk/resource.h
@@ -34,102 +34,102 @@
namespace Mohawk {
// Main FourCC's
-#define ID_MHWK MKID_BE('MHWK') // Main FourCC
-#define ID_RSRC MKID_BE('RSRC') // Resource Directory Tag
+#define ID_MHWK MKTAG('M','H','W','K') // Main FourCC
+#define ID_RSRC MKTAG('R','S','R','C') // Resource Directory Tag
// Myst Resource FourCC's
-#define ID_CLRC MKID_BE('CLRC') // Cursor Hotspots
-#define ID_EXIT MKID_BE('EXIT') // Card Exit Scripts
-#define ID_HINT MKID_BE('HINT') // Cursor Hints
-#define ID_INIT MKID_BE('INIT') // Card Entrance Scripts
-#define ID_MSND MKID_BE('MSND') // Standard Mohawk Sound
-#define ID_RLST MKID_BE('RLST') // Resource List, Specifies HotSpots
-#define ID_RSFL MKID_BE('RSFL') // ??? (system.dat only)
-#define ID_VIEW MKID_BE('VIEW') // Card Details
-#define ID_WDIB MKID_BE('WDIB') // LZ-Compressed Windows Bitmap
+#define ID_CLRC MKTAG('C','L','R','C') // Cursor Hotspots
+#define ID_EXIT MKTAG('E','X','I','T') // Card Exit Scripts
+#define ID_HINT MKTAG('H','I','N','T') // Cursor Hints
+#define ID_INIT MKTAG('I','N','I','T') // Card Entrance Scripts
+#define ID_MSND MKTAG('M','S','N','D') // Standard Mohawk Sound
+#define ID_RLST MKTAG('R','L','S','T') // Resource List, Specifies HotSpots
+#define ID_RSFL MKTAG('R','S','F','L') // ??? (system.dat only)
+#define ID_VIEW MKTAG('V','I','E','W') // Card Details
+#define ID_WDIB MKTAG('W','D','I','B') // LZ-Compressed Windows Bitmap
// Myst Masterpiece Edition Resource FourCC's (In addition to Myst FourCC's)
-#define ID_HELP MKID_BE('HELP') // Help Chunk
-#define ID_MJMP MKID_BE('MJMP') // MSND Jumps (To reduce MSND duplication)
-#define ID_PICT MKID_BE('PICT') // JPEG/PICT/WDIB Image
+#define ID_HELP MKTAG('H','E','L','P') // Help Chunk
+#define ID_MJMP MKTAG('M','J','M','P') // MSND Jumps (To reduce MSND duplication)
+#define ID_PICT MKTAG('P','I','C','T') // JPEG/PICT/WDIB Image
// Riven Resource FourCC's
-#define ID_BLST MKID_BE('BLST') // Card Hotspot Enabling Lists
-#define ID_CARD MKID_BE('CARD') // Card Scripts
-#define ID_FLST MKID_BE('FLST') // Card SFXE Lists
-#define ID_HSPT MKID_BE('HSPT') // Card Hotspots
-#define ID_MLST MKID_BE('MLST') // Card Movie Lists
-#define ID_NAME MKID_BE('NAME') // Object Names
-#define ID_PLST MKID_BE('PLST') // Card Picture Lists
-#define ID_RMAP MKID_BE('RMAP') // Card Codes
-#define ID_SFXE MKID_BE('SFXE') // Water Effect Animations
-#define ID_SLST MKID_BE('SLST') // Card Ambient Sound Lists
-#define ID_TMOV MKID_BE('tMOV') // QuickTime Movie
+#define ID_BLST MKTAG('B','L','S','T') // Card Hotspot Enabling Lists
+#define ID_CARD MKTAG('C','A','R','D') // Card Scripts
+#define ID_FLST MKTAG('F','L','S','T') // Card SFXE Lists
+#define ID_HSPT MKTAG('H','S','P','T') // Card Hotspots
+#define ID_MLST MKTAG('M','L','S','T') // Card Movie Lists
+#define ID_NAME MKTAG('N','A','M','E') // Object Names
+#define ID_PLST MKTAG('P','L','S','T') // Card Picture Lists
+#define ID_RMAP MKTAG('R','M','A','P') // Card Codes
+#define ID_SFXE MKTAG('S','F','X','E') // Water Effect Animations
+#define ID_SLST MKTAG('S','L','S','T') // Card Ambient Sound Lists
+#define ID_TMOV MKTAG('t','M','O','V') // QuickTime Movie
// Riven Saved Game FourCC's
-#define ID_VARS MKID_BE('VARS') // Variable Values
-#define ID_VERS MKID_BE('VERS') // Version Info
-#define ID_ZIPS MKID_BE('ZIPS') // Zip Mode Status
+#define ID_VARS MKTAG('V','A','R','S') // Variable Values
+#define ID_VERS MKTAG('V','E','R','S') // Version Info
+#define ID_ZIPS MKTAG('Z','I','P','S') // Zip Mode Status
// Zoombini Resource FourCC's
-#define ID_SND MKID_BE('\0SND') // Standard Mohawk Sound
-#define ID_CURS MKID_BE('CURS') // Cursor
-#define ID_SCRB MKID_BE('SCRB') // Feature Script
-#define ID_SCRS MKID_BE('SCRS') // Snoid Script
-#define ID_NODE MKID_BE('NODE') // Walk Node
-#define ID_PATH MKID_BE('PATH') // Walk Path
-#define ID_SHPL MKID_BE('SHPL') // Shape List
+#define ID_SND MKTAG( 0 ,'S','N','D') // Standard Mohawk Sound
+#define ID_CURS MKTAG('C','U','R','S') // Cursor
+#define ID_SCRB MKTAG('S','C','R','B') // Feature Script
+#define ID_SCRS MKTAG('S','C','R','S') // Snoid Script
+#define ID_NODE MKTAG('N','O','D','E') // Walk Node
+#define ID_PATH MKTAG('P','A','T','H') // Walk Path
+#define ID_SHPL MKTAG('S','H','P','L') // Shape List
// Living Books Resource FourCC's
-#define ID_TCUR MKID_BE('tCUR') // Cursor
-#define ID_BITL MKID_BE('BITL') // Book Item List
-#define ID_CTBL MKID_BE('CTBL') // Color Table
-#define ID_SCRP MKID_BE('SCRP') // Script
-#define ID_SPR MKID_BE('SPR#') // Sprite?
-#define ID_VRSN MKID_BE('VRSN') // Version
-#define ID_ANI MKID_BE('ANI ') // Animation
-#define ID_SHP MKID_BE('SHP#') // Shape
-#define ID_WAV MKID_BE('WAV ') // Old Sound Resource
-#define ID_BMAP MKID_BE('BMAP') // Old Mohawk Bitmap
-#define ID_BCOD MKID_BE('BCOD') // Book Code
+#define ID_TCUR MKTAG('t','C','U','R') // Cursor
+#define ID_BITL MKTAG('B','I','T','L') // Book Item List
+#define ID_CTBL MKTAG('C','T','B','L') // Color Table
+#define ID_SCRP MKTAG('S','C','R','P') // Script
+#define ID_SPR MKTAG('S','P','R','#') // Sprite?
+#define ID_VRSN MKTAG('V','R','S','N') // Version
+#define ID_ANI MKTAG('A','N','I',' ') // Animation
+#define ID_SHP MKTAG('S','H','P','#') // Shape
+#define ID_WAV MKTAG('W','A','V',' ') // Old Sound Resource
+#define ID_BMAP MKTAG('B','M','A','P') // Old Mohawk Bitmap
+#define ID_BCOD MKTAG('B','C','O','D') // Book Code
// JamesMath Resource FourCC's
-#define ID_TANM MKID_BE('tANM') // Animation?
-#define ID_TMFO MKID_BE('tMFO') // ???
+#define ID_TANM MKTAG('t','A','N','M') // Animation?
+#define ID_TMFO MKTAG('t','M','F','O') // ???
// CSTime Resource FourCC's
-#define ID_CINF MKID_BE('CINF') // Case Info
-#define ID_CONV MKID_BE('CONV') // Conversation
-#define ID_HOTS MKID_BE('HOTS') // Hotspot
-#define ID_INVO MKID_BE('INVO') // Inventory Object
-#define ID_QARS MKID_BE('QARS') // Question and Responses
-#define ID_SCEN MKID_BE('SCEN') // Scene
-#define ID_STRI MKID_BE('STRI') // String Entry?
+#define ID_CINF MKTAG('C','I','N','F') // Case Info
+#define ID_CONV MKTAG('C','O','N','V') // Conversation
+#define ID_HOTS MKTAG('H','O','T','S') // Hotspot
+#define ID_INVO MKTAG('I','N','V','O') // Inventory Object
+#define ID_QARS MKTAG('Q','A','R','S') // Question and Responses
+#define ID_SCEN MKTAG('S','C','E','N') // Scene
+#define ID_STRI MKTAG('S','T','R','I') // String Entry?
// Mohawk Wave Tags
-#define ID_WAVE MKID_BE('WAVE') // Game Sound (Third Tag)
-#define ID_ADPC MKID_BE('ADPC') // Game Sound Chunk
-#define ID_DATA MKID_BE('Data') // Game Sound Chunk
-#define ID_CUE MKID_BE('Cue#') // Game Sound Chunk
+#define ID_WAVE MKTAG('W','A','V','E') // Game Sound (Third Tag)
+#define ID_ADPC MKTAG('A','D','P','C') // Game Sound Chunk
+#define ID_DATA MKTAG('D','a','t','a') // Game Sound Chunk
+#define ID_CUE MKTAG('C','u','e','#') // Game Sound Chunk
// Mohawk MIDI Tags
-#define ID_MIDI MKID_BE('MIDI') // Game Sound (Third Tag), instead of WAVE
-#define ID_PRG MKID_BE('Prg#') // MIDI Patch
+#define ID_MIDI MKTAG('M','I','D','I') // Game Sound (Third Tag), instead of WAVE
+#define ID_PRG MKTAG('P','r','g','#') // MIDI Patch
// Common Resource FourCC's
-#define ID_TBMP MKID_BE('tBMP') // Standard Mohawk Bitmap
-#define ID_TWAV MKID_BE('tWAV') // Standard Mohawk Sound
-#define ID_TPAL MKID_BE('tPAL') // Standard Mohawk Palette
-#define ID_TCNT MKID_BE('tCNT') // Shape Count (CSWorld, CSAmtrak, JamesMath)
-#define ID_TSCR MKID_BE('tSCR') // Script (CSWorld, CSAmtrak, Treehouse)
-#define ID_STRL MKID_BE('STRL') // String List (Zoombini, CSWorld, CSAmtrak)
-#define ID_TBMH MKID_BE('tBMH') // Standard Mohawk Bitmap
-#define ID_TMID MKID_BE('tMID') // Standard Mohawk MIDI
-#define ID_REGS MKID_BE('REGS') // Registration Data - Shape Offsets (Zoombini, Treehouse)
-#define ID_BYTS MKID_BE('BYTS') // Byte Array? (Used as Database Entry in CSWorld, CSAmtrak)
-#define ID_INTS MKID_BE('INTS') // uint16 Array? (CSWorld, CSAmtrak)
-#define ID_BBOX MKID_BE('BBOX') // Boxes? (CSWorld, CSAmtrak)
-#define ID_SYSX MKID_BE('SYSX') // MIDI Sysex
+#define ID_TBMP MKTAG('t','B','M','P') // Standard Mohawk Bitmap
+#define ID_TWAV MKTAG('t','W','A','V') // Standard Mohawk Sound
+#define ID_TPAL MKTAG('t','P','A','L') // Standard Mohawk Palette
+#define ID_TCNT MKTAG('t','C','N','T') // Shape Count (CSWorld, CSAmtrak, JamesMath)
+#define ID_TSCR MKTAG('t','S','C','R') // Script (CSWorld, CSAmtrak, Treehouse)
+#define ID_STRL MKTAG('S','T','R','L') // String List (Zoombini, CSWorld, CSAmtrak)
+#define ID_TBMH MKTAG('t','B','M','H') // Standard Mohawk Bitmap
+#define ID_TMID MKTAG('t','M','I','D') // Standard Mohawk MIDI
+#define ID_REGS MKTAG('R','E','G','S') // Registration Data - Shape Offsets (Zoombini, Treehouse)
+#define ID_BYTS MKTAG('B','Y','T','S') // Byte Array? (Used as Database Entry in CSWorld, CSAmtrak)
+#define ID_INTS MKTAG('I','N','T','S') // uint16 Array? (CSWorld, CSAmtrak)
+#define ID_BBOX MKTAG('B','B','O','X') // Boxes? (CSWorld, CSAmtrak)
+#define ID_SYSX MKTAG('S','Y','S','X') // MIDI Sysex
struct FileTable {
uint32 offset;
diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp
index b4ae50b74a..9759f14699 100644
--- a/engines/mohawk/sound.cpp
+++ b/engines/mohawk/sound.cpp
@@ -479,7 +479,7 @@ Audio::AudioStream *Sound::makeMohawkWaveStream(Common::SeekableReadStream *stre
return Audio::makeRawStream(dataChunk.audioData, dataChunk.sampleRate, flags);
} else if (dataChunk.encoding == kCodecADPCM) {
uint32 blockAlign = dataChunk.channels * dataChunk.bitsPerSample / 8;
- return Audio::makeADPCMStream(dataChunk.audioData, DisposeAfterUse::YES, dataSize, Audio::kADPCMIma, dataChunk.sampleRate, dataChunk.channels, blockAlign);
+ return Audio::makeADPCMStream(dataChunk.audioData, DisposeAfterUse::YES, dataSize, Audio::kADPCMDVI, dataChunk.sampleRate, dataChunk.channels, blockAlign);
} else if (dataChunk.encoding == kCodecMPEG2) {
#ifdef USE_MAD
return Audio::makeMP3Stream(dataChunk.audioData, DisposeAfterUse::YES);