[Scummvm-cvs-logs] scummvm master -> 9f56876165d10dbfc86d8f232345ea0a766966bf

fuzzie fuzzie at fuzzie.org
Sat Nov 26 23:53:19 CET 2011


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a6af439eff MOHAWK: Add Rugrats subfolders to the path too.
dc02f67127 MOHAWK: Add some basic LB list support.
9f56876165 MOHAWK: Add the start of support for LBXDataFile.


Commit: a6af439effc1bc5381a86f41b8d4c66f9e19d567
    https://github.com/scummvm/scummvm/commit/a6af439effc1bc5381a86f41b8d4c66f9e19d567
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-11-26T14:37:54-08:00

Commit Message:
MOHAWK: Add Rugrats subfolders to the path too.

Changed paths:
    engines/mohawk/livingbooks.cpp



diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index ca3e37b..d0c8bf3 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -141,8 +141,12 @@ MohawkEngine_LivingBooks::MohawkEngine_LivingBooks(OSystem *syst, const MohawkGa
 
 	const Common::FSNode gameDataDir(ConfMan.get("path"));
 	// Rugrats
-	SearchMan.addSubDirectoryMatching(gameDataDir, "program");
-	SearchMan.addSubDirectoryMatching(gameDataDir, "Rugrats Adventure Game");
+	const Common::FSNode ProgPath = gameDataDir.getChild("program");
+	if (ProgPath.exists())
+		SearchMan.addDirectory(ProgPath.getPath(), ProgPath, 0, 2);
+	const Common::FSNode RugPath = gameDataDir.getChild("Rugrats Adventure Game");
+	if (RugPath.exists())
+		SearchMan.addDirectory(RugPath.getPath(), RugPath, 0, 2);
 	// CarmenTQ
 	const Common::FSNode CTQPath = gameDataDir.getChild("95instal");
 	if (CTQPath.exists())


Commit: dc02f6712796d63a34bbbd4bfbab309a11bdb879
    https://github.com/scummvm/scummvm/commit/dc02f6712796d63a34bbbd4bfbab309a11bdb879
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-11-26T14:45:40-08:00

Commit Message:
MOHAWK: Add some basic LB list support.

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 28cf477..59b0510 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -480,26 +480,66 @@ void LBCode::parseMain() {
 			if (_currToken == kTokenAssign)
 				error("attempted assignment to self");
 			break;
-		} else if (_currToken == kTokenAssign) {
+		}
+		bool indexing = false;
+		LBValue index;
+		if (_currToken == kTokenListStart) {
+			debugN("[");
+			nextToken();
+			parseStatement();
+			if (_currToken != kTokenListEnd)
+				error("expected list end");
+			debugN("]");
+			nextToken();
+			if (!_stack.size())
+				error("index failed");
+			indexing = true;
+			index = _stack.pop();
+		}
+		if (_currToken == kTokenAssign) {
 			debugN(" = ");
 			nextToken();
 			parseStatement();
 			if (!_stack.size())
 				error("assignment failed");
-			LBValue *val = &_vm->_variables[varname];
-			*val = _stack.pop();
+			LBValue *val;
+			if (indexing)
+				val = getIndexedVar(varname, index);
+			else
+				val = &_vm->_variables[varname];
+			if (val)
+				*val = _stack.pop();
+			else
+				*val = LBValue();
 			_stack.push(*val);
 		} else {
-			_stack.push(_vm->_variables[varname]);
+			if (indexing) {
+				LBValue *val = getIndexedVar(varname, index);
+				if (val)
+					_stack.push(*val);
+				else
+					_stack.push(LBValue());
+			} else
+				_stack.push(_vm->_variables[varname]);
 		}
 		// FIXME: pre/postincrement for non-integers
 		if (_currToken == kTokenPlusPlus) {
 			debugN("++");
-			_vm->_variables[varname].integer++;
+			if (indexing) {
+				LBValue *val = getIndexedVar(varname, index);
+				if (val)
+					val->integer++;
+			} else
+				_vm->_variables[varname].integer++;
 			nextToken();
 		} else if (_currToken == kTokenMinusMinus) {
 			debugN("--");
-			_vm->_variables[varname].integer--;
+			if (indexing) {
+				LBValue *val = getIndexedVar(varname, index);
+				if (val)
+					val->integer--;
+			} else
+				_vm->_variables[varname].integer--;
 			nextToken();
 		}
 		}
@@ -611,6 +651,17 @@ void LBCode::parseMain() {
 	}
 }
 
+LBValue *LBCode::getIndexedVar(Common::String varname, const LBValue &index) {
+	LBValue &var = _vm->_variables[varname];
+	if (var.type != kLBValueList)
+		error("variable '%s' was indexed, but isn't a list", varname.c_str());
+	if (index.type != kLBValueInteger)
+		error("index wasn't an integer");
+	if (index.integer < 1 || index.integer > (int)var.list->array.size())
+		return NULL;
+	return &var.list->array[index.integer - 1];
+}
+
 LBItem *LBCode::resolveItem(const LBValue &value) {
 	if (value.type == kLBValueItemPtr)
 		return value.item;
@@ -731,7 +782,7 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
 	{ "getPage", 0 },
 	{ "getWorldRect", 0 },
 	{ "isWorldWrap", 0 },
-	{ "newList", 0 },
+	{ "newList", &LBCode::cmdNewList },
 	{ "deleteList", 0 },
 	{ "add", 0 },
 	{ 0, 0 },
@@ -741,9 +792,9 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
 	{ 0, 0 },
 	{ "getIndex", 0 },
 	{ "setAt", 0 },
-	{ "listLen", 0 },
-	{ "deleteAt", 0 },
-	{ "clearList", 0 },
+	{ "listLen", &LBCode::cmdListLen },
+	{ "deleteAt", &LBCode::cmdDeleteAt },
+	{ "clearList", &LBCode::cmdUnimplemented },
 	{ "setWorld", 0 },
 	{ "setProperty", 0 },
 	{ "getProperty", 0 },
@@ -961,6 +1012,37 @@ void LBCode::cmdSetDragParams(const Common::Array<LBValue> &params) {
 	warning("ignoring setDragParams");
 }
 
+void LBCode::cmdNewList(const Common::Array<LBValue> &params) {
+	if (params.size() != 0)
+		error("incorrect number of parameters (%d) to newList", params.size());
+
+	_stack.push(Common::SharedPtr<LBList>(new LBList));
+}
+
+void LBCode::cmdListLen(const Common::Array<LBValue> &params) {
+	if (params.size() != 1)
+		error("incorrect number of parameters (%d) to listLen", params.size());
+
+	if (params[0].type != kLBValueList || !params[0].list)
+		error("invalid lbx object passed to lbxFunc");
+
+	_stack.push(params[0].list->array.size());
+}
+
+void LBCode::cmdDeleteAt(const Common::Array<LBValue> &params) {
+	if (params.size() != 2)
+		error("incorrect number of parameters (%d) to deleteAt", params.size());
+
+	if (params[0].type != kLBValueList || !params[0].list)
+		error("invalid lbx object passed to deleteAt");
+
+	if (params[1].type != kLBValueInteger)
+		error("invalid index passed to deleteAt");
+	if (params[1].integer < 1 || params[1].integer > (int)params[0].list->array.size())
+		return;
+	params[0].list->array.remove_at(params[1].integer - 1);
+}
+
 void LBCode::cmdSetPlayParams(const Common::Array<LBValue> &params) {
 	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 84ea66a..552a5f4 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -23,6 +23,7 @@
 #ifndef MOHAWK_LIVINGBOOKS_CODE_H
 #define MOHAWK_LIVINGBOOKS_CODE_H
 
+#include "common/ptr.h"
 #include "common/rect.h"
 #include "common/stack.h"
 #include "common/substream.h"
@@ -31,6 +32,7 @@ namespace Mohawk {
 
 class MohawkEngine_LivingBooks;
 class LBItem;
+struct LBList;
 
 enum LBValueType {
 	kLBValueString,
@@ -38,7 +40,8 @@ enum LBValueType {
 	kLBValueReal,
 	kLBValuePoint,
 	kLBValueRect,
-	kLBValueItemPtr
+	kLBValueItemPtr,
+	kLBValueList
 };
 
 struct LBValue {
@@ -66,6 +69,10 @@ struct LBValue {
 		type = kLBValueItemPtr;
 		item = itm;
 	}
+	LBValue(Common::SharedPtr<LBList> l) {
+		type = kLBValueList;
+		list = l;
+	}
 	LBValue(const LBValue &val) {
 		type = val.type;
 		switch (type) {
@@ -87,6 +94,9 @@ struct LBValue {
 		case kLBValueItemPtr:
 			item = val.item;
 			break;
+		case kLBValueList:
+			list = val.list;
+			break;
 		}
 	}
 
@@ -97,6 +107,7 @@ struct LBValue {
 	Common::Point point;
 	Common::Rect rect;
 	LBItem *item;
+	Common::SharedPtr<LBList> list;
 
 	bool operator==(const LBValue &x) const;
 	bool operator!=(const LBValue &x) const;
@@ -111,6 +122,10 @@ struct LBValue {
 	Common::Rect toRect() const;
 };
 
+struct LBList {
+	Common::Array<LBValue> array;
+};
+
 enum {
 	kLBCodeLiteralInteger = 0x1
 };
@@ -207,6 +222,7 @@ protected:
 	void parseArithmetic2();
 	void parseMain();
 
+	LBValue *getIndexedVar(Common::String varname, const LBValue &index);
 	LBItem *resolveItem(const LBValue &value);
 	Common::Array<LBValue> readParams();
 	Common::Rect getRectFromParams(const Common::Array<LBValue> &params);
@@ -233,6 +249,9 @@ public:
 	void cmdBottom(const Common::Array<LBValue> &params);
 	void cmdRight(const Common::Array<LBValue> &params);
 	void cmdSetDragParams(const Common::Array<LBValue> &params);
+	void cmdNewList(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);
 	void cmdSetKeyEvent(const Common::Array<LBValue> &params);
 	void cmdSetHitTest(const Common::Array<LBValue> &params);


Commit: 9f56876165d10dbfc86d8f232345ea0a766966bf
    https://github.com/scummvm/scummvm/commit/9f56876165d10dbfc86d8f232345ea0a766966bf
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-11-26T14:50:45-08:00

Commit Message:
MOHAWK: Add the start of support for LBXDataFile.

Changed paths:
  A engines/mohawk/livingbooks_lbx.cpp
  A engines/mohawk/livingbooks_lbx.h
    engines/mohawk/livingbooks_code.cpp
    engines/mohawk/livingbooks_code.h
    engines/mohawk/module.mk



diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 59b0510..c18f491 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "mohawk/livingbooks.h"
+#include "mohawk/livingbooks_lbx.h"
 #include "mohawk/resource.h"
 
 #include "common/system.h"
@@ -830,8 +831,8 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
 	{ "setDisplay", &LBCode::cmdUnimplemented },
 	{ "getDisplay", 0 },
 	{ 0, 0 },
-	{ "lbxCreate", 0 },
-	{ "lbxFunc", 0 },
+	{ "lbxCreate", &LBCode::cmdLBXCreate },
+	{ "lbxFunc", &LBCode::cmdLBXFunc },
 	{ "waitCursor", 0 },
 	{ "debugBreak", 0 },
 	{ "menuItemEnable", 0 },
@@ -1086,6 +1087,32 @@ void LBCode::cmdSetHitTest(const Common::Array<LBValue> &params) {
 	warning("ignoring setHitTest");
 }
 
+void LBCode::cmdLBXCreate(const Common::Array<LBValue> &params) {
+	if (params.size() != 1)
+		error("incorrect number of parameters (%d) to lbxCreate", params.size());
+
+	_stack.push(createLBXObject(_vm, params[0].toInt()));
+}
+
+void LBCode::cmdLBXFunc(const Common::Array<LBValue> &params) {
+	if (params.size() < 2)
+		error("incorrect number of parameters (%d) to lbxFunc", params.size());
+
+	if (params[0].type != kLBValueLBX || !params[0].lbx)
+		error("invalid lbx object passed to lbxFunc");
+
+	Common::SharedPtr<LBXObject> lbx = params[0].lbx;
+	uint callId = params[1].toInt();
+
+	Common::Array<LBValue> callParams;
+	for (uint i = 0; i < params.size() - 2; i++)
+		callParams.push_back(params[i + 2]);
+
+	LBValue result;
+	if (lbx->call(callId, callParams, result))
+		_stack.push(result);
+}
+
 void LBCode::cmdKey(const Common::Array<LBValue> &params) {
 	_stack.push(0); // FIXME
 	warning("ignoring Key");
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 552a5f4..ce59105 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -32,6 +32,7 @@ namespace Mohawk {
 
 class MohawkEngine_LivingBooks;
 class LBItem;
+class LBXObject;
 struct LBList;
 
 enum LBValueType {
@@ -41,6 +42,7 @@ enum LBValueType {
 	kLBValuePoint,
 	kLBValueRect,
 	kLBValueItemPtr,
+	kLBValueLBX,
 	kLBValueList
 };
 
@@ -69,6 +71,10 @@ struct LBValue {
 		type = kLBValueItemPtr;
 		item = itm;
 	}
+	LBValue(Common::SharedPtr<LBXObject> l) {
+		type = kLBValueLBX;
+		lbx = l;
+	}
 	LBValue(Common::SharedPtr<LBList> l) {
 		type = kLBValueList;
 		list = l;
@@ -94,6 +100,9 @@ struct LBValue {
 		case kLBValueItemPtr:
 			item = val.item;
 			break;
+		case kLBValueLBX:
+			lbx = val.lbx;
+			break;
 		case kLBValueList:
 			list = val.list;
 			break;
@@ -107,6 +116,7 @@ struct LBValue {
 	Common::Point point;
 	Common::Rect rect;
 	LBItem *item;
+	Common::SharedPtr<LBXObject> lbx;
 	Common::SharedPtr<LBList> list;
 
 	bool operator==(const LBValue &x) const;
@@ -255,6 +265,8 @@ public:
 	void cmdSetPlayParams(const Common::Array<LBValue> &params);
 	void cmdSetKeyEvent(const Common::Array<LBValue> &params);
 	void cmdSetHitTest(const Common::Array<LBValue> &params);
+	void cmdLBXCreate(const Common::Array<LBValue> &params);
+	void cmdLBXFunc(const Common::Array<LBValue> &params);
 	void cmdKey(const Common::Array<LBValue> &params);
 
 	void itemIsPlaying(const Common::Array<LBValue> &params);
diff --git a/engines/mohawk/livingbooks_lbx.cpp b/engines/mohawk/livingbooks_lbx.cpp
new file mode 100644
index 0000000..9628e06
--- /dev/null
+++ b/engines/mohawk/livingbooks_lbx.cpp
@@ -0,0 +1,141 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "engines/mohawk/livingbooks.h"
+#include "engines/mohawk/livingbooks_lbx.h"
+
+namespace Mohawk {
+
+class LBXDataFile : public LBXObject {
+public:
+	LBXDataFile(MohawkEngine_LivingBooks *vm);
+	~LBXDataFile();
+
+	bool call(uint callId, const Common::Array<LBValue> &params, LBValue &result);
+
+protected:
+	Common::ConfigFile _dataFile;
+	Common::String _curSection;
+
+	void open(const Common::String &filename);
+	bool sectionExists(const Common::String &section);
+};
+
+LBXDataFile::LBXDataFile(MohawkEngine_LivingBooks *vm) : LBXObject(vm) {
+}
+
+LBXDataFile::~LBXDataFile() {
+}
+
+enum {
+	kLBXDataFileOpen = 1,
+	kLBXDataFileGetSectionList = 4,
+	kLBXDataFileSetCurSection = 5,
+	kLBXDataFileLoadCurSectionVars = 8,
+	kLBXDataFileDeleteCurSection = 10,
+	kLBXDataFileSectionExists = 14
+};
+
+bool LBXDataFile::call(uint callId, const Common::Array<LBValue> &params, LBValue &result) {
+	switch (callId) {
+	case kLBXDataFileOpen:
+		if (params.size() != 1)
+			error("incorrect number of parameters (%d) to LBXDataFile::open", params.size());
+
+		open(params[0].toString());
+		return false;
+
+	case kLBXDataFileGetSectionList:
+		{
+		Common::SharedPtr<LBList> list = Common::SharedPtr<LBList>(new LBList);
+		Common::ConfigFile::SectionList sections = _dataFile.getSections();
+		for (Common::List<Common::ConfigFile::Section>::const_iterator i = sections.begin(); i != sections.end(); ++i)
+			list->array.push_back(LBValue(i->name));
+		result = LBValue(list);
+		}
+		return true;
+
+	case kLBXDataFileSetCurSection:
+		if (params.size() != 1)
+			error("incorrect number of parameters (%d) to LBXDataFile::setCurSection", params.size());
+
+		_curSection = params[0].toString();
+		return false;
+
+	case kLBXDataFileLoadCurSectionVars:
+		if (params.size() != 0)
+			error("incorrect number of parameters (%d) to LBXDataFile::loadCurSectionVars", params.size());
+
+		{
+		const Common::ConfigFile::SectionKeyList globals = _dataFile.getKeys(_curSection);
+		for (Common::ConfigFile::SectionKeyList::const_iterator i = globals.begin(); i != globals.end(); i++) {
+			Common::String command = Common::String::format("%s = %s", i->key.c_str(), i->value.c_str());
+			LBCode tempCode(_vm, 0);
+			uint offset = tempCode.parseCode(command);
+			tempCode.runCode(NULL, offset);
+		}
+		}
+		return false;
+
+	case kLBXDataFileDeleteCurSection:
+		if (params.size() != 0)
+			error("incorrect number of parameters (%d) to LBXDataFile::deleteCurSection", params.size());
+
+		_dataFile.removeSection(_curSection);
+		return false;
+
+	case kLBXDataFileSectionExists:
+		if (params.size() != 1)
+			error("incorrect number of parameters (%d) to LBXDataFile::sectionExists", params.size());
+		if (_dataFile.hasSection(params[0].toString()))
+			result = 1;
+		else
+			result = 0;
+		return true;
+
+	default:
+		error("LBXDataFile call %d is unknown", callId);
+	}
+}
+
+void LBXDataFile::open(const Common::String &filename) {
+	_dataFile.clear();
+
+	if (_dataFile.loadFromFile(filename))
+		return;
+
+	// FIXME: try savegames
+
+	error("LBXDataFile::open: couldn't open '%s'", filename.c_str());
+}
+
+Common::SharedPtr<LBXObject> createLBXObject(MohawkEngine_LivingBooks *vm, uint16 type) {
+	switch (type) {
+	case 1001:
+		return Common::SharedPtr<LBXObject>(new LBXDataFile(vm));
+
+	default:
+		error("unknown LBX object type %d", type);
+	}
+}
+
+} // End of namespace Mohawk
diff --git a/engines/mohawk/livingbooks_lbx.h b/engines/mohawk/livingbooks_lbx.h
new file mode 100644
index 0000000..3cca0a8
--- /dev/null
+++ b/engines/mohawk/livingbooks_lbx.h
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef MOHAWK_LIVINGBOOKS_LBX_H
+#define MOHAWK_LIVINGBOOKS_LBX_H
+
+#include "engines/mohawk/livingbooks_code.h"
+
+#include "common/ptr.h"
+
+namespace Mohawk {
+
+class LBXObject {
+public:
+	LBXObject(MohawkEngine_LivingBooks *vm) : _vm(vm) { }
+	virtual ~LBXObject() { }
+
+	virtual bool call(uint callId, const Common::Array<LBValue> &params, LBValue &result) = 0;
+
+protected:
+	MohawkEngine_LivingBooks *_vm;
+};
+
+Common::SharedPtr<LBXObject> createLBXObject(MohawkEngine_LivingBooks *vm, uint16 type);
+
+} // End of namespace Mohawk
+
+#endif
diff --git a/engines/mohawk/module.mk b/engines/mohawk/module.mk
index 30f1d40..882f396 100644
--- a/engines/mohawk/module.mk
+++ b/engines/mohawk/module.mk
@@ -10,6 +10,7 @@ MODULE_OBJS = \
 	installer_archive.o \
 	livingbooks.o \
 	livingbooks_code.o \
+	livingbooks_lbx.o \
 	mohawk.o \
 	resource.o \
 	sound.o \






More information about the Scummvm-git-logs mailing list