diff options
author | Alyssa Milburn | 2011-07-02 00:23:04 +0200 |
---|---|---|
committer | Alyssa Milburn | 2011-07-02 00:23:04 +0200 |
commit | 35ef5ea28c7ea7db1abe5e78ba7993c21a1c493c (patch) | |
tree | 85f0821a2357f4e6f5ebdf1a280e020cca4f11f7 /engines | |
parent | aceb1470cb8448bc76453c6db47b76750219a318 (diff) | |
download | scummvm-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.cpp | 37 | ||||
-rw-r--r-- | engines/mohawk/livingbooks_code.h | 7 |
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> ¶ms) { warning("unimplemented command called"); } +void LBCode::cmdEval(const Common::Array<LBValue> ¶ms) { + // 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> ¶ms) { + 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> ¶ms) { 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> ¶ms) { warning("ignoring moveTo"); } +void LBCode::itemSeek(const Common::Array<LBValue> ¶ms) { + 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> ¶ms) { 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> ¶ms); + void cmdEval(const Common::Array<LBValue> ¶ms); + void cmdRandom(const Common::Array<LBValue> ¶ms); void cmdGetRect(const Common::Array<LBValue> ¶ms); void cmdTopLeft(const Common::Array<LBValue> ¶ms); void cmdBottomRight(const Common::Array<LBValue> ¶ms); @@ -233,9 +235,10 @@ public: void cmdSetHitTest(const Common::Array<LBValue> ¶ms); void cmdKey(const Common::Array<LBValue> ¶ms); - void itemSetParent(const Common::Array<LBValue> ¶ms); - void itemMoveTo(const Common::Array<LBValue> ¶ms); void itemIsPlaying(const Common::Array<LBValue> ¶ms); + void itemMoveTo(const Common::Array<LBValue> ¶ms); + void itemSeek(const Common::Array<LBValue> ¶ms); + void itemSetParent(const Common::Array<LBValue> ¶ms); }; } // End of namespace Mohawk |