aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlyssa Milburn2011-07-02 00:23:04 +0200
committerAlyssa Milburn2011-07-02 00:23:04 +0200
commit35ef5ea28c7ea7db1abe5e78ba7993c21a1c493c (patch)
tree85f0821a2357f4e6f5ebdf1a280e020cca4f11f7 /engines
parentaceb1470cb8448bc76453c6db47b76750219a318 (diff)
downloadscummvm-rg350-35ef5ea28c7ea7db1abe5e78ba7993c21a1c493c.tar.gz
scummvm-rg350-35ef5ea28c7ea7db1abe5e78ba7993c21a1c493c.tar.bz2
scummvm-rg350-35ef5ea28c7ea7db1abe5e78ba7993c21a1c493c.zip
MOHAWK: Try implementing LBCode eval, random and seek.
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/livingbooks_code.cpp37
-rw-r--r--engines/mohawk/livingbooks_code.h7
2 files changed, 39 insertions, 5 deletions
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 89a77fbcfb..21b98424f6 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -638,8 +638,8 @@ struct CodeCommandInfo {
#define NUM_GENERAL_COMMANDS 129
CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
- { "eval", 0 },
- { "random", 0 },
+ { "eval", &LBCode::cmdEval },
+ { "random", &LBCode::cmdRandom },
{ "stringLen", 0 },
{ "substring", 0 },
{ "max", 0 },
@@ -795,6 +795,26 @@ void LBCode::cmdUnimplemented(const Common::Array<LBValue> &params) {
warning("unimplemented command called");
}
+void LBCode::cmdEval(const Common::Array<LBValue> &params) {
+ // FIXME: v4 eval is different?
+ if (params.size() != 1)
+ error("incorrect number of parameters (%d) to eval", params.size());
+
+ LBCode tempCode(_vm, 0);
+
+ uint offset = tempCode.parseCode(params[0].toString());
+ _stack.push(tempCode.runCode(_currSource, offset));
+}
+
+void LBCode::cmdRandom(const Common::Array<LBValue> &params) {
+ if (params.size() != 2)
+ error("incorrect number of parameters (%d) to random", params.size());
+
+ int min = params[0].toInt();
+ int max = params[1].toInt();
+ _stack.push(_vm->_rnd->getRandomNumberRng(min, max));
+}
+
void LBCode::cmdGetRect(const Common::Array<LBValue> &params) {
if (params.size() < 2) {
_stack.push(getRectFromParams(params));
@@ -937,7 +957,7 @@ CodeCommandInfo itemCommandInfo[NUM_ITEM_COMMANDS] = {
{ "moveTo", &LBCode::itemMoveTo },
{ "mute", 0 },
{ "play", 0 },
- { "seek", 0 },
+ { "seek", &LBCode::itemSeek },
{ "seekToFrame", 0 },
{ "setParent", &LBCode::itemSetParent },
{ "setZOrder", 0 },
@@ -973,6 +993,17 @@ void LBCode::itemMoveTo(const Common::Array<LBValue> &params) {
warning("ignoring moveTo");
}
+void LBCode::itemSeek(const Common::Array<LBValue> &params) {
+ if (params.size() != 2)
+ error("incorrect number of parameters (%d) to seek", params.size());
+
+ LBItem *item = resolveItem(params[0]);
+ if (!item)
+ error("attempted seek on invalid item (%s)", params[0].toString().c_str());
+ uint seekTo = params[1].toInt();
+ item->seek(seekTo);
+}
+
void LBCode::itemSetParent(const Common::Array<LBValue> &params) {
if (params.size() > 2)
error("incorrect number of parameters (%d) to setParent", params.size());
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 85bb706515..9c58ed7a46 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -220,6 +220,8 @@ protected:
public:
void cmdUnimplemented(const Common::Array<LBValue> &params);
+ void cmdEval(const Common::Array<LBValue> &params);
+ void cmdRandom(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);
@@ -233,9 +235,10 @@ public:
void cmdSetHitTest(const Common::Array<LBValue> &params);
void cmdKey(const Common::Array<LBValue> &params);
- void itemSetParent(const Common::Array<LBValue> &params);
- void itemMoveTo(const Common::Array<LBValue> &params);
void itemIsPlaying(const Common::Array<LBValue> &params);
+ void itemMoveTo(const Common::Array<LBValue> &params);
+ void itemSeek(const Common::Array<LBValue> &params);
+ void itemSetParent(const Common::Array<LBValue> &params);
};
} // End of namespace Mohawk