aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorAlyssa Milburn2011-02-01 22:00:37 +0000
committerAlyssa Milburn2011-02-01 22:00:37 +0000
commit40a9b710a50417c09c62e9861994489b2335e62a (patch)
treeff4efde303df9b26c298a8f529830159eace109e /engines/mohawk
parente1bdfe16e38e6ef66ab6141d63140aec162cc132 (diff)
downloadscummvm-rg350-40a9b710a50417c09c62e9861994489b2335e62a.tar.gz
scummvm-rg350-40a9b710a50417c09c62e9861994489b2335e62a.tar.bz2
scummvm-rg350-40a9b710a50417c09c62e9861994489b2335e62a.zip
MOHAWK: Handle some LB script entry params.
svn-id: r55712
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/livingbooks.cpp51
-rw-r--r--engines/mohawk/livingbooks.h2
2 files changed, 47 insertions, 6 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index b384c6af28..6017ab1218 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -1640,6 +1640,7 @@ uint16 LBAnimation::getParentId() {
}
LBScriptEntry::LBScriptEntry() {
+ state = 0;
argvParam = NULL;
argvTarget = NULL;
}
@@ -1747,6 +1748,7 @@ LBScriptEntry *LBItem::parseScriptEntry(uint16 type, uint16 &size, Common::Seeka
if (type == kLBMsgListScript && entry->opcode == kLBOpRunSubentries) {
debug(4, "%d script subentries:", entry->param);
+ entry->argc = 0;
for (uint i = 0; i < entry->param; i++) {
LBScriptEntry *subentry = parseScriptEntry(type, size, stream, true);
entry->subentries.push_back(subentry);
@@ -2313,19 +2315,56 @@ void LBItem::runScript(uint event, uint16 data, uint16 from) {
}
void LBItem::runScriptEntry(LBScriptEntry *entry) {
- if (entry->param != 0xffff) {
- // TODO: if param is 1/2/3..
- warning("Ignoring script entry (type 0x%04x, event 0x%04x, opcode 0x%04x, param 0x%04x)",
- entry->type, entry->event, entry->opcode, entry->param);
+ if (entry->state == 0xffff)
return;
- }
+ uint start = 0;
uint count = entry->argc;
// zero targets = apply to self
if (!count)
count = 1;
- for (uint n = 0; n < count; n++) {
+ switch (entry->param) {
+ case 0xfffe:
+ // Run once (disable self after run).
+ entry->state = 0xffff;
+ break;
+ case 0xffff:
+ break;
+ case 0:
+ case 1:
+ case 2:
+ start = entry->state;
+ entry->state++;
+ if (entry->state >= count) {
+ switch (entry->param) {
+ case 0:
+ // Disable..
+ entry->state = 0xffff;
+ return;
+ case 1:
+ // Stay at the end.
+ entry->state = count - 1;
+ break;
+ case 2:
+ // Loop.
+ entry->state = 0;
+ break;
+ }
+ }
+ count = 1;
+ break;
+ case 3:
+ // Pick random target.
+ start = _vm->_rnd->getRandomNumberRng(0, count);
+ count = 1;
+ break;
+ default:
+ warning("Weird param for script entry (type 0x%04x, event 0x%04x, opcode 0x%04x, param 0x%04x)",
+ entry->type, entry->event, entry->opcode, entry->param);
+ }
+
+ for (uint n = start; n < count; n++) {
LBItem *target;
debug(2, "Script run: type 0x%04x, event 0x%04x, opcode 0x%04x, param 0x%04x",
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 18f37a9a3a..7b072e61de 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -228,6 +228,8 @@ struct LBScriptEntry {
LBScriptEntry();
~LBScriptEntry();
+ uint16 state;
+
uint16 type;
uint16 event;
uint16 opcode;