aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlyssa Milburn2010-12-05 22:10:50 +0000
committerAlyssa Milburn2010-12-05 22:10:50 +0000
commit7c9dc9f117e4ad7f78d0069c38e707e43d35bf5b (patch)
tree12b2da0d735c6c56e7aaff3543d59b6ab3cc318f /engines
parent433a10e7736efe69011915ec5ec6dad49d6b933b (diff)
downloadscummvm-rg350-7c9dc9f117e4ad7f78d0069c38e707e43d35bf5b.tar.gz
scummvm-rg350-7c9dc9f117e4ad7f78d0069c38e707e43d35bf5b.tar.bz2
scummvm-rg350-7c9dc9f117e4ad7f78d0069c38e707e43d35bf5b.zip
MOHAWK: handle LB 2/3 kLBNotifyChangeMode, kLBActionNotified matching
svn-id: r54792
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/livingbooks.cpp64
-rw-r--r--engines/mohawk/livingbooks.h15
2 files changed, 48 insertions, 31 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index 0f9e302d0c..2bbb27bbb9 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -1036,10 +1036,14 @@ void MohawkEngine_LivingBooks::handleNotify(NotifyEvent &event) {
nextPage();
break;
- case kLBNotifyQuit:
- debug(2, "kLBNotifyQuit: %d", event.param);
-
- quitGame();
+ case kLBNotifyChangeMode:
+ if (getGameType() == GType_LIVINGBOOKSV1) {
+ debug(2, "kLBNotifyChangeMode: %d", event.param);
+ quitGame();
+ } else {
+ // FIXME
+ warning("ignoring V2/V3 kLBNotifyChangeMode");
+ }
break;
case kLBNotifyCursorChange:
@@ -1635,26 +1639,25 @@ void LBItem::readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEnd
size -= (2 + entry->argc * 4);
}
- if (type == kLBNotifyScript && entry->opcode == kLBNotifyQuit) {
+ if (type == kLBNotifyScript && entry->opcode == kLBNotifyChangeMode && _vm->getGameType() != GType_LIVINGBOOKSV1) {
if (size < 8) {
- error("%d unknown bytes in notify entry 0x%04x", size, entry->opcode);
+ error("%d unknown bytes in notify entry kLBNotifyChangeMode", size);
}
- uint16 opcodeId = stream->readUint16();
- uint16 modeId = stream->readUint16();
- uint16 pageId = stream->readUint16();
- uint16 subPageId = stream->readUint16();
- // FIXME
- warning("unknown notify: opcode %04x, mode %d, page %d.%d", opcodeId, modeId, pageId, subPageId);
+ entry->newUnknown = stream->readUint16();
+ entry->newMode = stream->readUint16();
+ entry->newPage = stream->readUint16();
+ entry->newSubpage = stream->readUint16();
+ debug(4, "kLBNotifyChangeMode: unknown %04x, mode %d, page %d.%d",
+ entry->newUnknown, entry->newMode, entry->newPage, entry->newSubpage);
size -= 8;
}
- if (entry->action == 7) {
+ // FIXME: what is 0x1d?
+ if (entry->action == kLBActionNotified || entry->opcode == 0x1d) {
if (size < 4)
- error("not enough bytes (%d) in action 7, opcode 0x%04x", size, entry->opcode);
- // FIXME: meh
+ error("not enough bytes (%d) in action %d, opcode 0x%04x", size, entry->action, entry->opcode);
+ entry->matchFrom = stream->readUint16();
+ entry->matchNotify = stream->readUint16();
size -= 4;
- uint16 itemId = stream->readUint16();
- uint16 unknown = stream->readUint16();
- warning("ignoring id %d, unknown 0x%04x in script entry (type 0x%04x, action 0x%04x, opcode 0x%04x)", itemId, unknown, entry->type, entry->action, entry->opcode);
}
if (entry->opcode == 0xffff) {
if (size < 4)
@@ -2009,25 +2012,28 @@ void LBItem::stop() {
}
void LBItem::notify(uint16 data, uint16 from) {
- if (_timingMode != 4)
- return;
-
- // TODO: is this correct?
- if (_periodMin != from)
- return;
- if (_periodMax != data)
- return;
+ if (_timingMode == 4) {
+ // TODO: is this correct?
+ if (_periodMin == from && _periodMax == data) {
+ debug(2, "Handling notify 0x%04x (from %d)", data, from);
+ setNextTime(0, 0);
+ }
+ }
- debug(2, "Handling notify 0x%04x (from %d)", data, from);
- setNextTime(0, 0);
+ runScript(kLBActionNotified, data, from);
}
-void LBItem::runScript(uint id) {
+void LBItem::runScript(uint id, uint16 data, uint16 from) {
for (uint i = 0; i < _scriptEntries.size(); i++) {
LBScriptEntry *entry = _scriptEntries[i];
if (entry->action != id)
continue;
+ if (id == kLBActionNotified) {
+ if (entry->matchFrom != from || entry->matchNotify != data)
+ continue;
+ }
+
bool conditionsMatch = true;
for (uint n = 0; n < entry->conditions.size(); n++) {
if (!checkCondition(entry->conditions[n])) {
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 94cc7f423f..4215889574 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -134,7 +134,7 @@ enum {
kLBNotifyGoToControls = 2,
kLBNotifyChangePage = 3,
kLBNotifyIntroDone = 5,
- kLBNotifyQuit = 6,
+ kLBNotifyChangeMode = 6,
kLBNotifyCursorChange = 7
};
@@ -150,10 +150,21 @@ struct LBScriptEntry {
uint16 action;
uint16 opcode;
uint16 param;
+
uint16 argc;
uint16 *argvParam;
uint16 *argvTarget;
+ // kLBNotifyChangeMode
+ uint16 newUnknown;
+ uint16 newMode;
+ uint16 newPage;
+ uint16 newSubpage;
+
+ // kLBActionNotified
+ uint16 matchFrom;
+ uint16 matchNotify;
+
Common::String command;
Common::Array<Common::String> conditions;
};
@@ -300,7 +311,7 @@ protected:
bool _isAmbient;
Common::Array<LBScriptEntry *> _scriptEntries;
- void runScript(uint id);
+ void runScript(uint id, uint16 data = 0, uint16 from = 0);
LBValue parseValue(const Common::String &command, uint &pos);
void runCommand(const Common::String &command);