[Scummvm-cvs-logs] SF.net SVN: scummvm:[42925] scummvm/branches/branch-1-0-0/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Jul 30 16:14:02 CEST 2009


Revision: 42925
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42925&view=rev
Author:   fingolfin
Date:     2009-07-30 14:14:02 +0000 (Thu, 30 Jul 2009)

Log Message:
-----------
Backported Indy3 Mac fixes to 1.0.0 branch

Modified Paths:
--------------
    scummvm/branches/branch-1-0-0/engines/scumm/script.cpp
    scummvm/branches/branch-1-0-0/engines/scumm/scumm.cpp
    scummvm/branches/branch-1-0-0/engines/scumm/scumm.h
    scummvm/branches/branch-1-0-0/engines/scumm/sound.cpp
    scummvm/branches/branch-1-0-0/engines/scumm/verbs.cpp

Modified: scummvm/branches/branch-1-0-0/engines/scumm/script.cpp
===================================================================
--- scummvm/branches/branch-1-0-0/engines/scumm/script.cpp	2009-07-30 13:44:50 UTC (rev 42924)
+++ scummvm/branches/branch-1-0-0/engines/scumm/script.cpp	2009-07-30 14:14:02 UTC (rev 42925)
@@ -23,10 +23,9 @@
  *
  */
 
-
-
 #include "common/config-manager.h"
 #include "common/util.h"
+#include "common/system.h"
 
 #include "scumm/actor.h"
 #include "scumm/object.h"
@@ -786,92 +785,65 @@
 }
 
 void ScummEngine::inventoryScriptIndy3Mac() {
-	VerbSlot *vs;
-	int args[24];
-	int j, slot;
+	int slot;
 
-	memset(args, 0, sizeof(args));
+	// VAR(67) controls the scroll offset of the inventory in Indy3 for Macintosh.
+	// The inventory consists of two columns with three items visible in each,
+	// so a maximum of six items are visible at once.
 
-	if (VAR(67) < 0) {
+	// The scroll offset must be non-negative and if there are six or less items
+	// in the inventory, the inventory is fixed in the top position.
+	const int invCount = getInventoryCount(VAR(VAR_EGO));
+	if (VAR(67) < 0 || invCount <= 6) {
 		VAR(67) = 0;
 	}
-	args[5] = getInventoryCount(VAR(VAR_EGO));
-	if (args[5] <= 6) {
-		VAR(67) = 0;
-	}
-	if (args[5] >= 6) {
-		args[5] -= 6;
-	}
-	args[6] = 0;
-	if (VAR(67) >= args[5]) {
-		VAR(67) = args[5];
-		args[4] = args[5];
-		args[5] /= 2;
-		args[5] *= 2;
-		args[4] -= args[5];
-		if (args[4]) {
+
+	// If there are more than six items in the inventory, clamp the scroll position
+	// to be at most invCount-6, rounded up to the next even integer.
+	bool scrolledToBottom = false;
+	if (invCount > 6 && VAR(67) >= invCount - 6) {
+		VAR(67) = invCount - 6;
+		// Odd number of inventory items? -> increment VAR(67) to make it even
+		if (invCount & 1) {
 			VAR(67)++;
 		}
-		args[6]++;
+		scrolledToBottom = true;
 	}
-	args[2] = 1;
-	for (j = 1; j < 7; j++) {
-		args[1] = (VAR(67) + args[2]);
-		args[3] = findInventory(VAR(VAR_EGO),args[1]);
-		VAR(82 + args[2]) = args[3];
-		args[2]++;
-	}
 
-	byte tmp[6];
+	// Now update var 83 till 89 to contain the inventory IDs of the
+	// corresponding inventory slots.
+	// Also setup fake verbs for the inventory
+	byte tmp[6] = { 0xFF, 0x06, 0x52, 0x00, 0x00, 0x00 };
+	for (int j = 1; j < 7; j++) {
+		int tmpA = (VAR(67) + j);
+		int tmpB = findInventory(VAR(VAR_EGO), tmpA);
+		VAR(82 + j) = tmpB;
 
-	tmp[0] = 0xFF;
-	tmp[1] = 0x06;
-	tmp[3] = 0x00;
-	tmp[4] = 0x00;
-
-	for (j = 0; j < 6; j++) {
-		tmp[2] = 0x53 + j;
-
-		slot = getVerbSlot(101 + j, 0);
-		vs = &_verbs[slot];
+		// Setup fake verb
+		tmp[2] = 0x52 + j;
+		slot = getVerbSlot(100 + j, 0);
 		loadPtrToResource(rtVerb, slot, tmp);
+
+		VerbSlot *vs = &_verbs[slot];
 		vs->type = kTextVerbType;
 		vs->imgindex = 0;
 		vs->curmode = 1;
 		drawVerb(slot, 0);
 	}
 
-	args[5] = getInventoryCount(VAR(VAR_EGO));
-	if (args[5] > 6) {
-		slot = getVerbSlot(107, 0);
-		if (VAR(67)) {
-			vs = &_verbs[slot];
-			vs->curmode = 1;
-		} else {
-			vs = &_verbs[slot];
-			vs->curmode = 0;
-		}
-		drawVerb(slot, 0);
-		slot = getVerbSlot(108, 0);
-		if (!args[6]) {
-			vs = &_verbs[slot];
-			vs->curmode = 1;
-		} else {
-			vs = &_verbs[slot];
-			vs->curmode = 0;
-		}
-		drawVerb(slot, 0);
-	} else {
-		slot = getVerbSlot(107, 0);
-		vs = &_verbs[slot];
-		vs->curmode = 0;
-		drawVerb(slot, 0);
-		slot = getVerbSlot(108, 0);
-		vs = &_verbs[slot];
-		vs->curmode = 0;
-		drawVerb(slot, 0);
-	}
+	// Enable up arrow if there are more than six items and we are not already
+	// scrolled all the way up.
+	slot = getVerbSlot(107, 0);
+	_verbs[slot].curmode = (invCount > 6 && VAR(67)) ? 1 : 0;
+	drawVerb(slot, 0);
 
+	// Enable down arrow if there are more than six items and we are not already
+	// scrolled all the way down.
+	slot = getVerbSlot(108, 0);
+	_verbs[slot].curmode = (invCount > 6 && !scrolledToBottom) ? 1 : 0;
+	drawVerb(slot, 0);
+
+	// Redraw!
 	verbMouseOver(0);
 }
 
@@ -1204,7 +1176,7 @@
 		args[4] = VAR(VAR_VIRT_MOUSE_Y);
 	}
 
-	// Macintosh verison of indy3ega used different interface, so adjust values.
+	// Macintosh version of indy3ega used different interface, so adjust values.
 	if (_game.id == GID_INDY3 && _game.platform == Common::kPlatformMacintosh) {
 		if (clickArea == kVerbClickArea && (val >= 101 && val <= 108)) {
 			if (val == 107) {
@@ -1216,10 +1188,16 @@
 				inventoryScriptIndy3Mac();
 				return;
 			} else {
-				args[0] = 3;
-				args[1] = VAR(83 + (val - 101));
+				args[0] = kInventoryClickArea;
+				args[1] = VAR(82 + (val - 100));
 			}
 		}
+
+		// Clicks are handled differently in Indy3 mac: param 2 of the
+		// input script is set to 0 for normal clicks, and to 1 for double clicks.
+		uint32 time = _system->getMillis();
+		args[2] = (time < _lastInputScriptTime + 500);	// 500 ms double click delay
+		_lastInputScriptTime = time;
 	}
 
 	if (verbScript)

Modified: scummvm/branches/branch-1-0-0/engines/scumm/scumm.cpp
===================================================================
--- scummvm/branches/branch-1-0-0/engines/scumm/scumm.cpp	2009-07-30 13:44:50 UTC (rev 42924)
+++ scummvm/branches/branch-1-0-0/engines/scumm/scumm.cpp	2009-07-30 14:14:02 UTC (rev 42925)
@@ -181,6 +181,7 @@
 	_mouseAndKeyboardStat = 0;
 	_leftBtnPressed = 0;
 	_rightBtnPressed = 0;
+	_lastInputScriptTime = 0;
 	_bootParam = 0;
 	_dumpScripts = false;
 	_debugMode = 0;

Modified: scummvm/branches/branch-1-0-0/engines/scumm/scumm.h
===================================================================
--- scummvm/branches/branch-1-0-0/engines/scumm/scumm.h	2009-07-30 13:44:50 UTC (rev 42924)
+++ scummvm/branches/branch-1-0-0/engines/scumm/scumm.h	2009-07-30 14:14:02 UTC (rev 42925)
@@ -612,6 +612,12 @@
 	uint16 _mouseAndKeyboardStat;
 	byte _leftBtnPressed, _rightBtnPressed;
 
+	/**
+	 * Last time runInputScript was run (measured in terms of OSystem::getMillis()).
+	 * This is currently only used for Indy3 mac to detect "double clicks".
+	 */
+	uint32 _lastInputScriptTime;
+
 	/** The bootparam, to be passed to the script 1, the bootscript. */
 	int _bootParam;
 

Modified: scummvm/branches/branch-1-0-0/engines/scumm/sound.cpp
===================================================================
--- scummvm/branches/branch-1-0-0/engines/scumm/sound.cpp	2009-07-30 13:44:50 UTC (rev 42924)
+++ scummvm/branches/branch-1-0-0/engines/scumm/sound.cpp	2009-07-30 14:14:02 UTC (rev 42925)
@@ -23,6 +23,9 @@
  *
  */
 
+#include "common/config-manager.h"
+#include "common/timer.h"
+#include "common/util.h"
 
 #include "scumm/actor.h"
 #include "scumm/file.h"
@@ -32,10 +35,6 @@
 #include "scumm/sound.h"
 #include "scumm/util.h"
 
-#include "common/config-manager.h"
-#include "common/timer.h"
-#include "common/util.h"
-
 #include "sound/adpcm.h"
 #include "sound/audiocd.h"
 #include "sound/flac.h"
@@ -46,8 +45,6 @@
 #include "sound/vorbis.h"
 #include "sound/wave.h"
 
-
-
 namespace Scumm {
 
 struct MP3OffsetTable {					/* Compressed Sound (.SO3) */
@@ -420,17 +417,16 @@
 		sound = (char *)malloc(size);
 		int vol = ptr[24] * 4;
 		int loopStart = 0, loopEnd = 0;
-#if 0	// Disabling this until after 0.11.0
 		int loopcount = ptr[27];
 		if (loopcount > 1) {
 			// TODO: We can only loop once, or infinitely many times, but
 			// have no support for a finite number of repetitions.
-			// This is
+			// So far, I have seen only 1 and 255 (for infinite repetitions),
+			// so maybe this is not really a problem.
 			loopStart = READ_BE_UINT16(ptr + 10) - READ_BE_UINT16(ptr + 8);
 			loopEnd = READ_BE_UINT16(ptr + 14);
 			flags |= Audio::Mixer::FLAG_LOOP;
 		}
-#endif
 
 		memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
 		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, rate,

Modified: scummvm/branches/branch-1-0-0/engines/scumm/verbs.cpp
===================================================================
--- scummvm/branches/branch-1-0-0/engines/scumm/verbs.cpp	2009-07-30 13:44:50 UTC (rev 42924)
+++ scummvm/branches/branch-1-0-0/engines/scumm/verbs.cpp	2009-07-30 14:14:02 UTC (rev 42925)
@@ -629,14 +629,14 @@
 			if (vs->verbid && vs->saveid == 0 && vs->curmode == 1) {
 				if (_mouseAndKeyboardStat == vs->key) {
 					// Trigger verb as if the user clicked it
-					runInputScript(1, vs->verbid, 1);
+					runInputScript(kVerbClickArea, vs->verbid, 1);
 					return;
 				}
 			}
 		}
 
 		// Generic keyboard input
-		runInputScript(4, _mouseAndKeyboardStat, 1);
+		runInputScript(kKeyClickArea, _mouseAndKeyboardStat, 1);
 	} else if (_mouseAndKeyboardStat & MBS_MOUSE_MASK) {
 		VirtScreen *zone = findVirtScreen(_mouse.y);
 		const byte code = _mouseAndKeyboardStat & MBS_LEFT_CLICK ? 1 : 2;
@@ -649,7 +649,7 @@
 
 		if (zone->number == kVerbVirtScreen && _mouse.y <= zone->topline + 8) {
 			// Click into V2 sentence line
-			runInputScript(5, 0, 0);
+			runInputScript(kSentenceClickArea, 0, 0);
 		} else if (zone->number == kVerbVirtScreen && _mouse.y > zone->topline + inventoryArea) {
 			// Click into V2 inventory
 			checkV2Inventory(_mouse.x, _mouse.y);
@@ -657,7 +657,7 @@
 			over = findVerbAtPos(_mouse.x, _mouse.y);
 			if (over != 0) {
 				// Verb was clicked
-				runInputScript(1, _verbs[over].verbid, code);
+				runInputScript(kVerbClickArea, _verbs[over].verbid, code);
 			} else {
 				// Scene was clicked
 				runInputScript((zone->number == kMainVirtScreen) ? kSceneClickArea : kVerbClickArea, 0, code);


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