[Scummvm-cvs-logs] scummvm master -> 1d6df12446de5426b6992efcd388acf0a6d56cd1
fuzzie
fuzzie at fuzzie.org
Sat Jul 2 00:26:05 CEST 2011
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
35ef5ea28c MOHAWK: Try implementing LBCode eval, random and seek.
1d6df12446 MOHAWK: Always create a code object for every LBPage.
Commit: 35ef5ea28c7ea7db1abe5e78ba7993c21a1c493c
https://github.com/scummvm/scummvm/commit/35ef5ea28c7ea7db1abe5e78ba7993c21a1c493c
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-01T15:23:04-07:00
Commit Message:
MOHAWK: Try implementing LBCode eval, random and seek.
Changed paths:
engines/mohawk/livingbooks_code.cpp
engines/mohawk/livingbooks_code.h
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 89a77fb..21b9842 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 85bb706..9c58ed7 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
Commit: 1d6df12446de5426b6992efcd388acf0a6d56cd1
https://github.com/scummvm/scummvm/commit/1d6df12446de5426b6992efcd388acf0a6d56cd1
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-01T15:23:37-07:00
Commit Message:
MOHAWK: Always create a code object for every LBPage.
Changed paths:
engines/mohawk/livingbooks.cpp
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index d05c571..f9d18ff 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -87,8 +87,14 @@ void LBPage::open(Archive *mhk, uint16 baseId) {
_baseId = baseId;
_vm->addArchive(_mhk);
- if (_vm->hasResource(ID_BCOD, baseId))
+ if (!_vm->hasResource(ID_BCOD, baseId)) {
+ // assume that BCOD is mandatory for v4/v5
+ if (_vm->getGameType() == GType_LIVINGBOOKSV4 || _vm->getGameType() == GType_LIVINGBOOKSV5)
+ error("missing BCOD resource (id %d)", baseId);
+ _code = new LBCode(_vm, 0);
+ } else {
_code = new LBCode(_vm, baseId);
+ }
loadBITL(baseId);
for (uint i = 0; i < _items.size(); i++)
@@ -2300,8 +2306,6 @@ void LBItem::readData(uint16 type, uint16 size, Common::MemoryReadStreamEndian *
{
assert(size == 4);
uint offset = stream->readUint32();
- if (!_page->_code)
- error("no BCOD?");
_page->_code->runCode(this, offset);
}
break;
@@ -2823,8 +2827,6 @@ int LBItem::runScriptEntry(LBScriptEntry *entry) {
break;
case kLBOpSendExpression:
- if (!_page->_code)
- error("no BCOD?");
_page->_code->runCode(this, entry->offset);
break;
@@ -2858,8 +2860,6 @@ int LBItem::runScriptEntry(LBScriptEntry *entry) {
case kLBOpJumpUnlessExpression:
case kLBOpBreakExpression:
case kLBOpJumpToExpression:
- if (!_page->_code)
- error("no BCOD?");
{
LBValue r = _page->_code->runCode(this, entry->offset);
// FIXME
More information about the Scummvm-git-logs
mailing list