[Scummvm-cvs-logs] scummvm master -> a1e9cecd39bbd3541cc8e9cd69cca4578151b8d9

fuzzie fuzzie at fuzzie.org
Sun Jul 3 18:24: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:
57d4bad11c MOHAWK: Handle subpages in the LB console's changePage.
a1e9cecd39 MOHAWK: Implement the remaining LBCode arithmetic operators.


Commit: 57d4bad11cffc77a1d9b1269b6e9c471fe0e8374
    https://github.com/scummvm/scummvm/commit/57d4bad11cffc77a1d9b1269b6e9c471fe0e8374
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-03T09:18:00-07:00

Commit Message:
MOHAWK: Handle subpages in the LB console's changePage.

Changed paths:
    engines/mohawk/console.cpp



diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 05012be..e7dc846 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -700,14 +700,25 @@ bool LivingBooksConsole::Cmd_DrawImage(int argc, const char **argv) {
 }
 
 bool LivingBooksConsole::Cmd_ChangePage(int argc, const char **argv) {
-	if (argc == 1) {
-		DebugPrintf("Usage: changePage <page> [<mode>]\n");
+	if (argc < 2 || argc > 3) {
+		DebugPrintf("Usage: changePage <page>[.<subpage>] [<mode>]\n");
 		return true;
 	}
 
-	if (_vm->tryLoadPageStart(argc == 2 ? _vm->getCurMode() : (LBMode)atoi(argv[2]), atoi(argv[1])))
-		return false;
-	DebugPrintf("no such page %d\n", atoi(argv[1]));
+	int page, subpage = 0;
+	if (sscanf(argv[1], "%d.%d", &page, &subpage) == 0) {
+		DebugPrintf("Usage: changePage <page>[.<subpage>] [<mode>]\n");
+		return true;
+	}
+	LBMode mode = argc == 2 ? _vm->getCurMode() : (LBMode)atoi(argv[2]);
+	if (subpage == 0) {
+		if (_vm->tryLoadPageStart(mode, page))
+			return false;
+	} else {
+		if (_vm->loadPage(mode, page, subpage))
+			return false;
+	}
+	DebugPrintf("no such page %d.%d\n", page, subpage);
 	return true;
 }
 


Commit: a1e9cecd39bbd3541cc8e9cd69cca4578151b8d9
    https://github.com/scummvm/scummvm/commit/a1e9cecd39bbd3541cc8e9cd69cca4578151b8d9
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-07-03T09:19:32-07:00

Commit Message:
MOHAWK: Implement the remaining LBCode arithmetic operators.

Changed paths:
    engines/mohawk/livingbooks_code.cpp



diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 83b801e..e9ef251 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -405,8 +405,55 @@ void LBCode::parseArithmetic1() {
 }
 
 void LBCode::parseArithmetic2() {
-	// FIXME: other math operators
 	parseMain();
+
+	while (true) {
+		byte op = _currToken;
+		switch (op) {
+		case kTokenMultiply:
+			debugN(" * ");
+			break;
+		case kTokenDivide:
+			debugN(" / ");
+			break;
+		case kTokenIntDivide:
+			debugN(" div ");
+			break;
+		case kTokenModulo:
+			debugN(" %% ");
+			break;
+		default:
+			return;
+		}
+
+		nextToken();
+		parseMain();
+
+		LBValue val2 = _stack.pop();
+		LBValue val1 = _stack.pop();
+		LBValue result;
+		// TODO: cope with non-integers
+		if (op == kTokenMultiply) {
+			result = val1.toInt() * val2.toInt();
+		} else if (val2.toInt() == 0) {
+			result = 1;
+		} else {
+			switch (op) {
+			case kTokenDivide:
+				// TODO: fp divide
+				result = val1.toInt() / val2.toInt();
+				break;
+			case kTokenIntDivide:
+				result = val1.toInt() / val2.toInt();
+				break;
+			case kTokenModulo:
+				result = val1.toInt() % val2.toInt();
+				break;
+			}
+		}
+
+		_stack.push(result);
+	}
 }
 
 void LBCode::parseMain() {






More information about the Scummvm-git-logs mailing list