aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorAlyssa Milburn2011-12-02 00:05:45 +0100
committerAlyssa Milburn2011-12-02 00:05:45 +0100
commit2657d14636847affdfc0f2e488465ceb3549da24 (patch)
tree505d0a03cb33c1a90ef91d0c957672339a68ee69 /engines/mohawk
parent82ff40c5485f381e15d22b6bc274cd1c49846fd6 (diff)
downloadscummvm-rg350-2657d14636847affdfc0f2e488465ceb3549da24.tar.gz
scummvm-rg350-2657d14636847affdfc0f2e488465ceb3549da24.tar.bz2
scummvm-rg350-2657d14636847affdfc0f2e488465ceb3549da24.zip
MOHAWK: Implement LB add,addAt,setAt.
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/livingbooks_code.cpp46
-rw-r--r--engines/mohawk/livingbooks_code.h3
2 files changed, 46 insertions, 3 deletions
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 138f35bbd3..421a9646ac 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -835,14 +835,14 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
{ "isWorldWrap", 0 },
{ "newList", &LBCode::cmdNewList },
{ "deleteList", 0 },
- { "add", 0 },
+ { "add", &LBCode::cmdAdd },
{ 0, 0 },
- { "addAt", 0 },
+ { "addAt", &LBCode::cmdAddAt },
{ "getAt", 0 },
// 0x30
{ 0, 0 },
{ "getIndex", 0 },
- { "setAt", 0 },
+ { "setAt", &LBCode::cmdSetAt },
{ "listLen", &LBCode::cmdListLen },
{ "deleteAt", &LBCode::cmdDeleteAt },
{ "clearList", &LBCode::cmdUnimplemented },
@@ -1125,6 +1125,46 @@ void LBCode::cmdNewList(const Common::Array<LBValue> &params) {
_stack.push(Common::SharedPtr<LBList>(new LBList));
}
+void LBCode::cmdAdd(const Common::Array<LBValue> &params) {
+ if (params.size() != 2)
+ error("incorrect number of parameters (%d) to add", params.size());
+
+ if (params[0].type != kLBValueList || !params[0].list)
+ error("invalid lbx object passed to add");
+
+ params[0].list->array.push_back(params[1]);
+}
+
+void LBCode::cmdAddAt(const Common::Array<LBValue> &params) {
+ if (params.size() != 3)
+ error("incorrect number of parameters (%d) to addAt", params.size());
+
+ if (params[0].type != kLBValueList || !params[0].list)
+ error("invalid lbx object passed to addAt");
+
+ if (params[1].type != kLBValueInteger || params[1].integer < 1)
+ error("invalid index passed to addAt");
+
+ if ((uint)params[1].integer > params[0].list->array.size())
+ params[0].list->array.resize(params[1].integer);
+ params[0].list->array.insert_at(params[1].integer - 1, params[2]);
+}
+
+void LBCode::cmdSetAt(const Common::Array<LBValue> &params) {
+ if (params.size() != 3)
+ error("incorrect number of parameters (%d) to setAt", params.size());
+
+ if (params[0].type != kLBValueList || !params[0].list)
+ error("invalid lbx object passed to setAt");
+
+ if (params[1].type != kLBValueInteger || params[1].integer < 1)
+ error("invalid index passed to setAt");
+
+ if ((uint)params[1].integer > params[0].list->array.size())
+ params[0].list->array.resize(params[1].integer);
+ params[0].list->array[params[1].integer - 1] = params[2];
+}
+
void LBCode::cmdListLen(const Common::Array<LBValue> &params) {
if (params.size() != 1)
error("incorrect number of parameters (%d) to listLen", params.size());
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 2e9153f53b..71328bb776 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -265,6 +265,9 @@ public:
void cmdMove(const Common::Array<LBValue> &params);
void cmdSetDragParams(const Common::Array<LBValue> &params);
void cmdNewList(const Common::Array<LBValue> &params);
+ void cmdAdd(const Common::Array<LBValue> &params);
+ void cmdAddAt(const Common::Array<LBValue> &params);
+ void cmdSetAt(const Common::Array<LBValue> &params);
void cmdListLen(const Common::Array<LBValue> &params);
void cmdDeleteAt(const Common::Array<LBValue> &params);
void cmdSetPlayParams(const Common::Array<LBValue> &params);