[Scummvm-cvs-logs] scummvm master -> 10454194bc8ba1bdcc02899ca3b28f8ac6f8ea97
fuzzie
fuzzie at fuzzie.org
Thu Apr 7 23:13:04 CEST 2011
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
be09bef7f7 MOHAWK: Add getItemByName for LB.
f65840feef MOHAWK: Add some more LBValue helpers.
ac1522e177 MOHAWK: Implement some more LBCode ops.
10454194bc MOHAWK: Implement some LBCode rect commands.
Commit: be09bef7f7c8fc6f6f8a3c9a9b3534a54c8a41e4
https://github.com/scummvm/scummvm/commit/be09bef7f7c8fc6f6f8a3c9a9b3534a54c8a41e4
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-04-07T14:03:54-07:00
Commit Message:
MOHAWK: Add getItemByName for LB.
Changed paths:
engines/mohawk/livingbooks.cpp
engines/mohawk/livingbooks.h
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index 542cc96..6ecf9f9 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -558,6 +558,14 @@ LBItem *MohawkEngine_LivingBooks::getItemById(uint16 id) {
return NULL;
}
+LBItem *MohawkEngine_LivingBooks::getItemByName(Common::String name) {
+ for (uint16 i = 0; i < _items.size(); i++)
+ if (_items[i]->getName() == name)
+ return _items[i];
+
+ return NULL;
+}
+
void MohawkEngine_LivingBooks::setFocus(LBItem *focus) {
_focus = focus;
}
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 3eff039..123c250 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -385,6 +385,7 @@ public:
virtual void notify(uint16 data, uint16 from); // 0x1A
uint16 getId() { return _itemId; }
+ const Common::String &getName() { return _desc; }
uint16 getSoundPriority() { return _soundMode; }
bool isAmbient() { return _isAmbient; }
@@ -615,6 +616,7 @@ public:
GUI::Debugger *getDebugger() { return _console; }
LBItem *getItemById(uint16 id);
+ LBItem *getItemByName(Common::String name);
void setFocus(LBItem *focus);
void setEnableForAll(bool enable, LBItem *except = 0);
Commit: f65840feef59557d3c759e7fa44996ae76d199be
https://github.com/scummvm/scummvm/commit/f65840feef59557d3c759e7fa44996ae76d199be
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-04-07T14:05:22-07:00
Commit Message:
MOHAWK: Add some more LBValue helpers.
Changed paths:
engines/mohawk/livingbooks.h
engines/mohawk/livingbooks_code.cpp
engines/mohawk/livingbooks_code.h
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 123c250..90540d2 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -386,6 +386,7 @@ public:
uint16 getId() { return _itemId; }
const Common::String &getName() { return _desc; }
+ const Common::Rect &getRect() { return _rect; }
uint16 getSoundPriority() { return _soundMode; }
bool isAmbient() { return _isAmbient; }
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 78345ab..dc72b2f 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -71,6 +71,19 @@ bool LBValue::isZero() const {
return toInt() == 0; // FIXME
}
+Common::String LBValue::toString() const {
+ switch (type) {
+ case kLBValueString:
+ return string;
+ case kLBValueInteger:
+ return Common::String::format("%d", integer);
+ case kLBValueReal:
+ return Common::String::format("%f", real);
+ default:
+ return string; // FIXME
+ }
+}
+
int LBValue::toInt() const {
return integer; // FIXME
}
@@ -79,6 +92,36 @@ double LBValue::toDouble() const {
return real; // FIXME
}
+Common::Point LBValue::toPoint() const {
+ switch (type) {
+ case kLBValueString:
+ // FIXME
+ return Common::Point();
+ case kLBValueInteger:
+ return Common::Point(integer, integer);
+ case kLBValuePoint:
+ return point;
+ default:
+ error("failed to convert to point");
+ }
+}
+
+Common::Rect LBValue::toRect() const {
+ switch (type) {
+ case kLBValueString:
+ // FIXME
+ return Common::Rect();
+ case kLBValueInteger:
+ return Common::Rect(integer, integer, integer, integer);
+ case kLBValueRect:
+ return rect;
+ case kLBValueItemPtr:
+ return item->getRect();
+ default:
+ error("failed to convert to rect");
+ }
+}
+
LBCode::LBCode(MohawkEngine_LivingBooks *vm) : _vm(vm) {
Common::SeekableSubReadStreamEndian *bcodStream = _vm->wrapStreamEndian(ID_BCOD, 1000);
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 71174cc..50b5783 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -57,6 +57,14 @@ struct LBValue {
type = kLBValueString;
string = str;
}
+ LBValue(const Common::Point &p) {
+ type = kLBValuePoint;
+ point = p;
+ }
+ LBValue(const Common::Rect &r) {
+ type = kLBValueRect;
+ rect = r;
+ }
LBValue(LBItem *itm) {
type = kLBValueItemPtr;
item = itm;
@@ -99,8 +107,11 @@ struct LBValue {
bool isNumeric() const;
bool isZero() const;
+ Common::String toString() const;
int toInt() const;
double toDouble() const;
+ Common::Point toPoint() const;
+ Common::Rect toRect() const;
};
enum {
Commit: ac1522e177de979d6d9ef3248c0747de3dba00b5
https://github.com/scummvm/scummvm/commit/ac1522e177de979d6d9ef3248c0747de3dba00b5
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-04-07T14:07:04-07:00
Commit Message:
MOHAWK: Implement some more LBCode ops.
Changed paths:
engines/mohawk/livingbooks_code.cpp
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index dc72b2f..354fb04 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -249,7 +249,7 @@ LBValue LBCode::runCode(byte terminator) {
if (_currToken == terminator || _currToken == kTokenEndOfFile)
break;
if (_currToken != kTokenEndOfStatement && _currToken != kTokenEndOfFile)
- error("missing EOS");
+ error("missing EOS (got %02x)", _currToken);
debugN("\n");
}
@@ -325,12 +325,45 @@ void LBCode::parseComparisons() {
void LBCode::parseConcat() {
parseArithmetic1();
- // FIXME: string concat
+
+ if (_currToken != kTokenConcat)
+ return;
+
+ debugN(" & ");
+ nextToken();
+ parseArithmetic1();
+
+ LBValue val2 = _stack.pop();
+ LBValue val1 = _stack.pop();
+ Common::String result = val1.toString() + val2.toString();
+ debugN(" [--> \"%s\"]", result.c_str());
+ _stack.push(result);
}
void LBCode::parseArithmetic1() {
parseArithmetic2();
- // FIXME: -/+ math operators
+
+ if (_currToken != kTokenMinus && _currToken != kTokenPlus)
+ return;
+
+ byte op = _currToken;
+ if (op == kTokenMinus)
+ debugN(" - ");
+ else if (op == kTokenPlus)
+ debugN(" + ");
+
+ nextToken();
+ parseArithmetic2();
+
+ LBValue val2 = _stack.pop();
+ LBValue val1 = _stack.pop();
+ LBValue result;
+ // TODO: cope with non-integers
+ if (op == kTokenMinus)
+ result = val1.toInt() - val2.toInt();
+ else
+ result = val1.toInt() + val2.toInt();
+ _stack.push(result);
}
void LBCode::parseArithmetic2() {
@@ -357,6 +390,7 @@ void LBCode::parseMain() {
_stack.push(LBValue(_currSource));
if (_currToken == kTokenAssign)
error("attempted assignment to self");
+ break;
} else if (_currToken == kTokenAssign) {
debugN(" = ");
nextToken();
@@ -369,7 +403,16 @@ void LBCode::parseMain() {
} else {
_stack.push(_vm->_variables[varname]);
}
- // FIXME: pre/postincrement
+ // FIXME: pre/postincrement for non-integers
+ if (_currToken == kTokenPlusPlus) {
+ debugN("++");
+ _vm->_variables[varname].integer++;
+ nextToken();
+ } else if (_currToken == kTokenMinusMinus) {
+ debugN("--");
+ _vm->_variables[varname].integer--;
+ nextToken();
+ }
}
break;
@@ -391,6 +434,17 @@ void LBCode::parseMain() {
nextToken();
break;
+ case kTokenTrue:
+ debugN("TRUE");
+ _stack.push(true);
+ nextToken();
+ break;
+ case kTokenFalse:
+ debugN("FALSE");
+ _stack.push(false);
+ nextToken();
+ break;
+
case kTokenOpenBracket:
debugN("(");
nextToken();
Commit: 10454194bc8ba1bdcc02899ca3b28f8ac6f8ea97
https://github.com/scummvm/scummvm/commit/10454194bc8ba1bdcc02899ca3b28f8ac6f8ea97
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-04-07T14:08:55-07:00
Commit Message:
MOHAWK: Implement some LBCode rect commands.
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 354fb04..661c238 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -539,6 +539,21 @@ Common::Array<LBValue> LBCode::readParams() {
return params;
}
+Common::Rect LBCode::getRectFromParams(const Common::Array<LBValue> ¶ms) {
+ if (params.size() == 0) {
+ assert(_currSource);
+ return _currSource->getRect();
+ } else if (params.size() == 1) {
+ const LBValue &val = params[0];
+ LBItem *item = _vm->getItemByName(val.toString());
+ if (item)
+ return item->getRect();
+ else
+ return val.toRect();
+ } else
+ error("getRectFromParams got called with weird state");
+}
+
struct CodeCommandInfo {
const char *name;
typedef void (LBCode::*CommandFunc)(const Common::Array<LBValue> ¶ms);
@@ -554,16 +569,16 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
{ "max", 0 },
{ "min", 0 },
{ "abs", 0 },
- { "getRect", 0 }, // also "makeRect"
+ { "getRect", &LBCode::cmdGetRect }, // also "makeRect"
{ "makePt", 0 }, // also "makePair"
- { "topleft", 0 },
- { "bottomright", 0 },
+ { "topLeft", &LBCode::cmdTopLeft },
+ { "bottomRight", &LBCode::cmdBottomRight },
{ "mousePos", 0 },
- { "top", 0 },
- { "left", 0 },
- { "bottom", 0 },
+ { "top", &LBCode::cmdTop },
+ { "left", &LBCode::cmdLeft },
+ { "bottom", &LBCode::cmdBottom },
// 0x10
- { "right", 0 },
+ { "right", &LBCode::cmdRight },
{ "xpos", 0 },
{ "ypos", 0 },
{ "playFrom", 0 },
@@ -704,6 +719,67 @@ void LBCode::cmdUnimplemented(const Common::Array<LBValue> ¶ms) {
warning("unimplemented command called");
}
+void LBCode::cmdGetRect(const Common::Array<LBValue> ¶ms) {
+ if (params.size() < 2) {
+ _stack.push(getRectFromParams(params));
+ } else if (params.size() == 2) {
+ Common::Point p1 = params[0].toPoint();
+ Common::Point p2 = params[1].toPoint();
+ _stack.push(Common::Rect(p1.x, p1.y, p2.x, p2.y));
+ } else if (params.size() == 4) {
+ _stack.push(Common::Rect(params[0].toInt(), params[1].toInt(), params[2].toInt(), params[3].toInt()));
+ } else
+ error("incorrect number of parameters (%d) to getRect", params.size());
+}
+
+void LBCode::cmdTopLeft(const Common::Array<LBValue> ¶ms) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to topLeft", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(Common::Point(rect.top, rect.left));
+}
+
+void LBCode::cmdBottomRight(const Common::Array<LBValue> ¶ms) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to bottomRight", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(Common::Point(rect.bottom, rect.right));
+}
+
+void LBCode::cmdTop(const Common::Array<LBValue> ¶ms) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to top", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(rect.top);
+}
+
+void LBCode::cmdLeft(const Common::Array<LBValue> ¶ms) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to left", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(rect.left);
+}
+
+void LBCode::cmdBottom(const Common::Array<LBValue> ¶ms) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to bottom", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(rect.bottom);
+}
+
+void LBCode::cmdRight(const Common::Array<LBValue> ¶ms) {
+ if (params.size() > 1)
+ error("too many parameters (%d) to right", params.size());
+
+ Common::Rect rect = getRectFromParams(params);
+ _stack.push(rect.right);
+}
+
void LBCode::cmdSetPlayParams(const Common::Array<LBValue> ¶ms) {
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 50b5783..bd9a565 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -210,12 +210,21 @@ protected:
void parseMain();
Common::Array<LBValue> readParams();
+ Common::Rect getRectFromParams(const Common::Array<LBValue> ¶ms);
+
void runGeneralCommand();
void runItemCommand();
void runNotifyCommand();
public:
void cmdUnimplemented(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);
+ void cmdTop(const Common::Array<LBValue> ¶ms);
+ void cmdLeft(const Common::Array<LBValue> ¶ms);
+ void cmdBottom(const Common::Array<LBValue> ¶ms);
+ void cmdRight(const Common::Array<LBValue> ¶ms);
void cmdSetPlayParams(const Common::Array<LBValue> ¶ms);
void cmdSetKeyEvent(const Common::Array<LBValue> ¶ms);
void cmdSetHitTest(const Common::Array<LBValue> ¶ms);
More information about the Scummvm-git-logs
mailing list