aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlyssa Milburn2011-12-02 00:06:58 +0100
committerAlyssa Milburn2011-12-02 00:06:58 +0100
commit3be628735bb9e1b36fafe96bd704fa0005a3d7b5 (patch)
tree9cef7e101faa71e04e05e2ebefef3d126d4b5a7c /engines
parent2657d14636847affdfc0f2e488465ceb3549da24 (diff)
downloadscummvm-rg350-3be628735bb9e1b36fafe96bd704fa0005a3d7b5.tar.gz
scummvm-rg350-3be628735bb9e1b36fafe96bd704fa0005a3d7b5.tar.bz2
scummvm-rg350-3be628735bb9e1b36fafe96bd704fa0005a3d7b5.zip
MOHAWK: Implement LB exec,return.
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/livingbooks_code.cpp36
-rw-r--r--engines/mohawk/livingbooks_code.h2
2 files changed, 36 insertions, 2 deletions
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 421a9646ac..8e7c69b070 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -851,8 +851,8 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
{ "getProperty", 0 },
{ "copyList", 0 },
{ "invoke", 0 },
- { "exec", 0 },
- { "return", 0 },
+ { "exec", &LBCode::cmdExec },
+ { "return", &LBCode::cmdReturn },
{ "sendSync", 0 },
{ "moveViewOrigin", 0 },
{ "addToGroup", 0 },
@@ -1189,6 +1189,38 @@ void LBCode::cmdDeleteAt(const Common::Array<LBValue> &params) {
params[0].list->array.remove_at(params[1].integer - 1);
}
+void LBCode::cmdExec(const Common::Array<LBValue> &params) {
+ if (params.size() != 1)
+ error("incorrect number of parameters (%d) to exec", params.size());
+ if (params[0].type != kLBValueInteger || params[0].integer < 0)
+ error("invalid offset passed to exec");
+ uint offset = (uint)params[0].integer;
+
+ uint32 oldOffset = _currOffset;
+ byte oldToken = _currToken;
+ LBValue val = runCode(_currSource, offset);
+ _currOffset = oldOffset;
+ _currToken = oldToken;
+
+ _stack.push(val);
+ _stack.push(val);
+}
+
+void LBCode::cmdReturn(const Common::Array<LBValue> &params) {
+ if (params.size() != 2)
+ error("incorrect number of parameters (%d) to return", params.size());
+
+ if (!_stack.size())
+ error("empty stack on entry to return");
+
+ if (params[0] == _stack.top()) {
+ _stack.pop();
+ _stack.push(params[1]);
+ _currToken = kTokenEndOfFile;
+ } else
+ _stack.push(_stack.top());
+}
+
void LBCode::cmdSetPlayParams(const Common::Array<LBValue> &params) {
if (params.size() > 8)
error("too many parameters (%d) to setPlayParams", params.size());
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 71328bb776..2cb1994492 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -270,6 +270,8 @@ public:
void cmdSetAt(const Common::Array<LBValue> &params);
void cmdListLen(const Common::Array<LBValue> &params);
void cmdDeleteAt(const Common::Array<LBValue> &params);
+ void cmdExec(const Common::Array<LBValue> &params);
+ void cmdReturn(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);