[Scummvm-cvs-logs] SF.net SVN: scummvm:[54856] scummvm/trunk/engines/mohawk

bgk at users.sourceforge.net bgk at users.sourceforge.net
Fri Dec 10 20:51:01 CET 2010


Revision: 54856
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54856&view=rev
Author:   bgk
Date:     2010-12-10 19:51:00 +0000 (Fri, 10 Dec 2010)

Log Message:
-----------
MOHAWK: Implement Myst opcode 115, give page to book

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/myst_areas.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/myst.h

Modified: scummvm/trunk/engines/mohawk/myst_areas.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-10 10:46:17 UTC (rev 54855)
+++ scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-10 19:51:00 UTC (rev 54856)
@@ -138,10 +138,10 @@
 	// Position values require modulus 10000 to keep in sane range.
 	_left = rlstStream->readUint16LE() % 10000;
 	_top = rlstStream->readUint16LE() % 10000;
-	_loop = rlstStream->readUint16LE();
+	_playOnCardChange = rlstStream->readUint16LE();
 	_direction = rlstStream->readUint16LE();
 	_playBlocking = rlstStream->readUint16LE();
-	_playOnCardChange = rlstStream->readUint16LE();
+	_loop = rlstStream->readUint16LE();
 	_u3 = rlstStream->readUint16LE();
 
 	if (_direction != 1)

Modified: scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2010-12-10 10:46:17 UTC (rev 54855)
+++ scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2010-12-10 19:51:00 UTC (rev 54856)
@@ -63,7 +63,7 @@
 	OPCODE(109, opcode_109);
 	OPCODE(113, opcode_113);
 	OPCODE(114, opcode_114);
-	OPCODE(115, opcode_115);
+	OPCODE(115, o_bookGivePage);
 	OPCODE(116, opcode_116);
 	OPCODE(117, opcode_117);
 	OPCODE(118, opcode_118);
@@ -219,6 +219,10 @@
 			return 1;
 		else
 			return 2;
+	case 46:
+		return bookCountPages(100);
+	case 47:
+		return bookCountPages(101);
 	case 49: // Generator running
 		return myst.generatorVoltage > 0;
 	case 52: // Generator Switch #1
@@ -339,6 +343,41 @@
 	return refresh;
 }
 
+uint16 MystScriptParser_Myst::bookCountPages(uint16 var) {
+	MystVariables::Globals &globals = _vm->_saveLoad->_v->globals;
+
+	uint16 pages = 0;
+	uint16 cnt = 0;
+
+	// Select book according to var
+	if (var == 100)
+		pages = globals.redPagesInBook;
+	else if (var == 101)
+		pages = globals.bluePagesInBook;
+
+	// Special page present
+	if (pages & 64)
+		return 6;
+
+	// Count pages
+	if (pages & 1)
+		cnt++;
+
+	if (pages & 2)
+		cnt++;
+
+	if (pages & 4)
+		cnt++;
+
+	if (pages & 8)
+		cnt++;
+
+	if (pages & 16)
+		cnt++;
+
+	return cnt;
+}
+
 void MystScriptParser_Myst::o_libraryBookPageTurnLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	debugC(kDebugScript, "Opcode %d: Turn book page left", op);
 
@@ -552,41 +591,93 @@
 		unknown(op, var, argc, argv);
 }
 
-void MystScriptParser_Myst::opcode_115(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	if (argc == 3) {
-		uint16 cardIdLose = argv[0];
-		uint16 cardIdBookCover = argv[1];
-		uint16 soundIdAddPage = argv[2];
+void MystScriptParser_Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	MystVariables::Globals &globals = _vm->_saveLoad->_v->globals;
 
-		debugC(kDebugScript, "Opcode %d: Red and Blue Book/Page Interaction", op);
-		debugC(kDebugScript, "Var: %d", var);
-		debugC(kDebugScript, "Card Id (Lose): %d", cardIdLose);
-		debugC(kDebugScript, "Card Id (Book Cover): %d", cardIdBookCover);
-		debugC(kDebugScript, "SoundId (Add Page): %d", soundIdAddPage);
+	uint16 cardIdLose = argv[0];
+	uint16 cardIdBookCover = argv[1];
+	uint16 soundIdAddPage = argv[2];
 
-		// TODO: if holding page for this book, play SoundIdAddPage
-		if (false) { // TODO: Should be access to mainCursor...
-			_vm->_sound->playSound(soundIdAddPage);
-			// TODO: Code for updating variables based on adding page
-		}
+	debugC(kDebugScript, "Opcode %d: Red and Blue Book/Page Interaction", op);
+	debugC(kDebugScript, "Var: %d", var);
+	debugC(kDebugScript, "Card Id (Lose): %d", cardIdLose);
+	debugC(kDebugScript, "Card Id (Book Cover): %d", cardIdBookCover);
+	debugC(kDebugScript, "SoundId (Add Page): %d", soundIdAddPage);
 
-		// TODO: Add Tweak to improve original logic by denying
-		//       lose until all red / blue pages collected, rather
-		//       than allowing shortcut based on 1 fireplace page?
+	// No page or white page
+	if (!globals.heldPage || globals.heldPage == 13) {
+		_vm->changeToCard(cardIdBookCover, true);
+		return;
+	}
 
-		// If holding last page for this book i.e. var 24/25
-		// Then trigger Trapped in Book Losing Ending
-		if ((var == 100 && !_vm->_varStore->getVar(25)) ||
-			(var == 101 && !_vm->_varStore->getVar(24))) {
-			// TODO: Clear mainCursor back to nominal..
-			_vm->changeToCard(cardIdLose, true);
-		} else
-			_vm->changeToCard(cardIdBookCover, true);
+	uint16 bookVar = 101;
+	uint16 mask = 0;
 
-		// TODO: Is this logic here?
-		//       i.e. If was holding page, wait then auto open and play book...
-	} else
-		unknown(op, var, argc, argv);
+	switch (globals.heldPage) {
+	case 7:
+		bookVar = 100;
+	case 1:
+		mask = 1;
+		break;
+	case 8:
+		bookVar = 100;
+	case 2:
+		mask = 2;
+		break;
+	case 9:
+		bookVar = 100;
+	case 3:
+		mask = 4;
+		break;
+	case 10:
+		bookVar = 100;
+	case 4:
+		mask = 8;
+		break;
+	case 11:
+		bookVar = 100;
+	case 5:
+		mask = 16;
+		break;
+	case 12:
+		bookVar = 100;
+	case 6:
+		mask = 32;
+		break;
+	}
+
+	// Wrong book
+	if (bookVar != var) {
+		_vm->changeToCard(cardIdBookCover, true);
+		return;
+	}
+
+	_vm->_cursor->hideCursor();
+	_vm->_sound->playSoundBlocking(soundIdAddPage);
+	_vm->setMainCursor(kDefaultMystCursor);
+
+	// Add page to book
+	if (var == 100)
+		globals.redPagesInBook |= mask;
+	else
+		globals.bluePagesInBook |= mask;
+
+	// Remove page from hand
+	globals.heldPage = 0;
+
+	_vm->_cursor->showCursor();
+
+	if (mask == 32) {
+		// Loose
+		if (var == 100)
+			globals.currentAge = 9;
+		else
+			globals.currentAge = 10;
+
+		_vm->changeToCard(cardIdLose, true);
+	} else {
+		_vm->changeToCard(cardIdBookCover, true);
+	}
 }
 
 void MystScriptParser_Myst::opcode_116(uint16 op, uint16 var, uint16 argc, uint16 *argv) {

Modified: scummvm/trunk/engines/mohawk/myst_stacks/myst.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/myst.h	2010-12-10 10:46:17 UTC (rev 54855)
+++ scummvm/trunk/engines/mohawk/myst_stacks/myst.h	2010-12-10 19:51:00 UTC (rev 54856)
@@ -76,7 +76,7 @@
 	DECLARE_OPCODE(opcode_109);
 	DECLARE_OPCODE(opcode_113);
 	DECLARE_OPCODE(opcode_114);
-	DECLARE_OPCODE(opcode_115);
+	DECLARE_OPCODE(o_bookGivePage);
 	DECLARE_OPCODE(opcode_116);
 	DECLARE_OPCODE(opcode_117);
 	DECLARE_OPCODE(opcode_118);
@@ -205,6 +205,8 @@
 
 	void libraryCombinationBookTurnRight();
 	void libraryCombinationBookTurnLeft();
+
+	uint16 bookCountPages(uint16 var);
 };
 
 } // End of namespace Mohawk


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list