[Scummvm-cvs-logs] scummvm master -> 19ee63703b2c5f1636344ea58121d4e1e7bb7167

bgK bastien.bouclet at gmail.com
Thu Feb 11 07:42:00 CET 2016


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:
e9525f53c6 MOHAWK: Move debug rect draw control to the console
19ee63703b MOHAWK: Share the code applying sound blocks


Commit: e9525f53c654a1527f94a5638c06a94aee45d224
    https://github.com/scummvm/scummvm/commit/e9525f53c654a1527f94a5638c06a94aee45d224
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-11T07:38:23+01:00

Commit Message:
MOHAWK: Move debug rect draw control to the console

It was previously bound to F4

Changed paths:
    engines/mohawk/console.cpp
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h



diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 9b5bae7..629cfdf 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -63,6 +63,7 @@ MystConsole::MystConsole(MohawkEngine_Myst *vm) : GUI::Debugger(), _vm(vm) {
 	registerCmd("disableInitOpcodes",	WRAP_METHOD(MystConsole, Cmd_DisableInitOpcodes));
 	registerCmd("cache",				WRAP_METHOD(MystConsole, Cmd_Cache));
 	registerCmd("resources",			WRAP_METHOD(MystConsole, Cmd_Resources));
+	registerVar("show_resource_rects",  &_vm->_showResourceRects);
 }
 
 MystConsole::~MystConsole() {
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 9ee2caf..7f38a86 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -303,11 +303,6 @@ Common::Error MohawkEngine_Myst::run() {
 				case Common::KEYCODE_SPACE:
 					pauseGame();
 					break;
-				case Common::KEYCODE_F4:
-					_showResourceRects = !_showResourceRects;
-					if (_showResourceRects)
-						drawResourceRects();
-					break;
 				case Common::KEYCODE_F5:
 					_needsPageDrop = false;
 					_needsShowMap = false;
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 34607d8..37e0eaf 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -189,6 +189,8 @@ public:
 	bool _needsShowMap;
 	bool _needsShowDemoMenu;
 
+	bool _showResourceRects;
+
 	MystGraphics *_gfx;
 	MystGameState *_gameState;
 	MystScriptParser *_scriptParser;
@@ -228,7 +230,6 @@ private:
 	uint16 _curCard;
 	MystView _view;
 
-	bool _showResourceRects;
 	bool _runExitScript;
 
 	void dropPage();


Commit: 19ee63703b2c5f1636344ea58121d4e1e7bb7167
    https://github.com/scummvm/scummvm/commit/19ee63703b2c5f1636344ea58121d4e1e7bb7167
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2016-02-11T07:38:23+01:00

Commit Message:
MOHAWK: Share the code applying sound blocks

Changed paths:
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h
    engines/mohawk/myst_scripts.cpp



diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 7f38a86..d4ac513 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -560,36 +560,7 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {
 	drawCardBackground();
 
 	// Handle sound
-	int16 soundAction = 0;
-	uint16 soundActionVolume = 0;
-
-	if (_view.sound == kMystSoundActionConditional) {
-		uint16 soundVarValue = _scriptParser->getVar(_view.soundVar);
-		if (soundVarValue >= _view.soundList.size())
-			warning("Conditional sound variable outside range");
-		else {
-			soundAction = _view.soundList[soundVarValue].action;
-			soundActionVolume = _view.soundList[soundVarValue].volume;
-		}
-	} else {
-		soundAction = _view.sound;
-		soundActionVolume = _view.soundVolume;
-	}
-
-	if (soundAction == kMystSoundActionContinue)
-		debug(2, "Continuing with current sound");
-	else if (soundAction == kMystSoundActionChangeVolume) {
-		debug(2, "Continuing with current sound, changing volume");
-		_sound->changeBackgroundVolumeMyst(soundActionVolume);
-	} else if (soundAction == kMystSoundActionStop) {
-		debug(2, "Stopping sound");
-		_sound->stopBackgroundMyst();
-	} else if (soundAction > 0) {
-		debug(2, "Playing new sound %d", soundAction);
-		_sound->replaceBackgroundMyst(soundAction, soundActionVolume);
-	} else {
-		error("Unknown sound action %d", soundAction);
-	}
+	applySoundBlock(_view.soundBlock);
 
 	if (_view.flags & kMystZipDestination)
 		_gameState->addZipDest(_curStack, card);
@@ -711,30 +682,31 @@ void MohawkEngine_Myst::loadCard() {
 	}
 
 	// The Sound Block (Reminiscent of Riven SLST resources)
-	_view.sound = viewStream->readSint16LE();
-	debugCN(kDebugView, "Sound Control: %d = ", _view.sound);
-	if (_view.sound > 0) {
+	MystSoundBlock soundBlock;
+	soundBlock.sound = viewStream->readSint16LE();
+	debugCN(kDebugView, "Sound Control: %d = ", soundBlock.sound);
+	if (soundBlock.sound > 0) {
 		debugC(kDebugView, "Play new Sound, change volume");
-		debugC(kDebugView, "\tSound: %d", _view.sound);
-		_view.soundVolume = viewStream->readUint16LE();
-		debugC(kDebugView, "\tVolume: %d", _view.soundVolume);
-	} else if (_view.sound == kMystSoundActionContinue)
+		debugC(kDebugView, "\tSound: %d", soundBlock.sound);
+		soundBlock.soundVolume = viewStream->readUint16LE();
+		debugC(kDebugView, "\tVolume: %d", soundBlock.soundVolume);
+	} else if (soundBlock.sound == kMystSoundActionContinue)
 		debugC(kDebugView, "Continue current sound");
-	else if (_view.sound == kMystSoundActionChangeVolume) {
+	else if (soundBlock.sound == kMystSoundActionChangeVolume) {
 		debugC(kDebugView, "Continue current sound, change volume");
-		_view.soundVolume = viewStream->readUint16LE();
-		debugC(kDebugView, "\tVolume: %d", _view.soundVolume);
-	} else if (_view.sound == kMystSoundActionStop) {
+		soundBlock.soundVolume = viewStream->readUint16LE();
+		debugC(kDebugView, "\tVolume: %d", soundBlock.soundVolume);
+	} else if (soundBlock.sound == kMystSoundActionStop) {
 		debugC(kDebugView, "Stop sound");
-	} else if (_view.sound == kMystSoundActionConditional) {
+	} else if (soundBlock.sound == kMystSoundActionConditional) {
 		debugC(kDebugView, "Conditional sound list");
-		_view.soundVar = viewStream->readUint16LE();
-		debugC(kDebugView, "\tVar: %d", _view.soundVar);
+		soundBlock.soundVar = viewStream->readUint16LE();
+		debugC(kDebugView, "\tVar: %d", soundBlock.soundVar);
 		uint16 soundCount = viewStream->readUint16LE();
 		debugC(kDebugView, "\tCount: %d", soundCount);
 
 		for (uint16 i = 0; i < soundCount; i++) {
-			MystSoundItem sound;
+			MystSoundBlock::SoundItem sound;
 
 			sound.action = viewStream->readSint16LE();
 			debugC(kDebugView, "\t\tCondition %d: Action %d", i, sound.action);
@@ -743,13 +715,15 @@ void MohawkEngine_Myst::loadCard() {
 				debugC(kDebugView, "\t\tCondition %d: Volume %d", i, sound.volume);
 			}
 
-			_view.soundList.push_back(sound);
+			soundBlock.soundList.push_back(sound);
 		}
 	} else {
 		debugC(kDebugView, "Unknown");
-		warning("Unknown sound control value '%d' in card '%d'", _view.sound, _curCard);
+		warning("Unknown sound control value '%d' in card '%d'", soundBlock.sound, _curCard);
 	}
 
+	_view.soundBlock = soundBlock;
+
 	// Resources that scripts can call upon
 	uint16 scriptResCount = viewStream->readUint16LE();
 	debugC(kDebugView, "Script Resource Count: %d", scriptResCount);
@@ -831,12 +805,12 @@ void MohawkEngine_Myst::loadCard() {
 	}
 
 	// Precache Sound Block data
-	if (_view.sound > 0)
-		cachePreload(ID_MSND, _view.sound);
-	else if (_view.sound == kMystSoundActionConditional) {
-		uint16 value = _scriptParser->getVar(_view.soundVar);
-		if (_view.soundList[value].action > 0) {
-			cachePreload(ID_MSND, _view.soundList[value].action);
+	if (_view.soundBlock.sound > 0)
+		cachePreload(ID_MSND, _view.soundBlock.sound);
+	else if (_view.soundBlock.sound == kMystSoundActionConditional) {
+		uint16 value = _scriptParser->getVar(_view.soundBlock.soundVar);
+		if (_view.soundBlock.soundList[value].action > 0) {
+			cachePreload(ID_MSND, _view.soundBlock.soundList[value].action);
 		}
 	}
 
@@ -871,7 +845,7 @@ void MohawkEngine_Myst::loadCard() {
 
 void MohawkEngine_Myst::unloadCard() {
 	_view.conditionalImages.clear();
-	_view.soundList.clear();
+	_view.soundBlock.soundList.clear();
 	_view.scriptResources.clear();
 }
 
@@ -1200,4 +1174,37 @@ void MohawkEngine_Myst::dropPage() {
 	checkCursorHints();
 }
 
+void MohawkEngine_Myst::applySoundBlock(const MystSoundBlock &block) {
+	int16 soundAction = 0;
+	uint16 soundActionVolume = 0;
+
+	if (block.sound == kMystSoundActionConditional) {
+		uint16 soundVarValue = _scriptParser->getVar(block.soundVar);
+		if (soundVarValue >= block.soundList.size())
+			warning("Conditional sound variable outside range");
+		else {
+			soundAction = block.soundList[soundVarValue].action;
+			soundActionVolume = block.soundList[soundVarValue].volume;
+		}
+	} else {
+		soundAction = block.sound;
+		soundActionVolume = block.soundVolume;
+	}
+
+	if (soundAction == kMystSoundActionContinue)
+		debug(2, "Continuing with current sound");
+	else if (soundAction == kMystSoundActionChangeVolume) {
+		debug(2, "Continuing with current sound, changing volume");
+		_sound->changeBackgroundVolumeMyst(soundActionVolume);
+	} else if (soundAction == kMystSoundActionStop) {
+		debug(2, "Stopping sound");
+		_sound->stopBackgroundMyst();
+	} else if (soundAction > 0) {
+		debug(2, "Playing new sound %d", soundAction);
+		_sound->replaceBackgroundMyst(soundAction, soundActionVolume);
+	} else {
+		error("Unknown sound action %d", soundAction);
+	}
+}
+
 } // End of namespace Mohawk
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 37e0eaf..59ec45c 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -97,9 +97,16 @@ struct MystCondition {
 	Common::Array<uint16> values;
 };
 
-struct MystSoundItem {
-	int16 action;
-	uint16 volume;
+struct MystSoundBlock {
+	struct SoundItem {
+		int16 action;
+		uint16 volume;
+	};
+
+	int16 sound;
+	uint16 soundVolume;
+	uint16 soundVar;
+	Common::Array<SoundItem> soundList;
 };
 
 // View Sound Action Type
@@ -124,10 +131,7 @@ struct MystView {
 	uint16 mainImage;
 
 	// Sound Data
-	int16 sound;
-	uint16 soundVolume;
-	uint16 soundVar;
-	Common::Array<MystSoundItem> soundList;
+	MystSoundBlock soundBlock;
 
 	// Script Resources
 	enum ScriptResourceType {
@@ -182,6 +186,7 @@ public:
 	void checkCursorHints();
 	MystArea *updateCurrentResource();
 	bool skippableWait(uint32 duration);
+	void applySoundBlock(const MystSoundBlock &block);
 
 	bool _tweaksEnabled;
 	bool _needsUpdate;
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index b2a2221..74ff895 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -673,82 +673,51 @@ void MystScriptParser::o_copyImageToBackBuffer(uint16 op, uint16 var, uint16 arg
 	_vm->_gfx->copyImageSectionToBackBuffer(imageId, srcRect, dstRect);
 }
 
-// TODO: Implement common engine function for read and processing of sound blocks
-//       for use by this opcode and VIEW sound block.
 // TODO: Though the playSound and PlaySoundBlocking opcodes play sounds immediately,
 //       this opcode changes the main background sound playing..
 //       Current behavior here and with VIEW sound block is not right as demonstrated
 //       by Channelwood Card 3280 (Tank Valve) and water flow sound behavior in pipe
 //       on cards leading from shed...
 void MystScriptParser::o_changeBackgroundSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	int16 *soundList = nullptr;
-	uint16 *soundListVolume = nullptr;
 
 	// Used on Stoneship Card 2080
 	// Used on Channelwood Card 3225 with argc = 8 i.e. Conditional Sound List
-	if (argc == 1 || argc == 2 || argc == 8) {
-		debugC(kDebugScript, "Opcode %d: Process Sound Block", op);
-		uint16 decodeIdx = 0;
-
-		int16 soundAction = argv[decodeIdx++];
-		uint16 soundVolume = 65535;
-		if (soundAction == kMystSoundActionChangeVolume || soundAction > 0) {
-			soundVolume = argv[decodeIdx++];
-		} else if (soundAction == kMystSoundActionConditional) {
-			debugC(kDebugScript, "Conditional sound list");
-			uint16 condVar = argv[decodeIdx++];
-			uint16 condVarValue = getVar(condVar);
-			uint16 condCount = argv[decodeIdx++];
-
-			debugC(kDebugScript, "\tcondVar: %d = %d", condVar, condVarValue);
-			debugC(kDebugScript, "\tcondCount: %d", condCount);
-
-			soundList = new int16[condCount];
-			soundListVolume = new uint16[condCount];
-
-			if (condVarValue >= condCount)
-				warning("Opcode %d: Conditional sound variable outside range",  op);
-			else {
-				for (uint16 i = 0; i < condCount; i++) {
-					soundList[i] = argv[decodeIdx++];
-					debugC(kDebugScript, "\t\tCondition %d: Action %d", i, soundList[i]);
-					if (soundList[i] == kMystSoundActionChangeVolume || soundList[i] > 0) {
-						soundListVolume[i] = argv[decodeIdx++];
-					} else
-						soundListVolume[i] = 65535;
-					debugC(kDebugScript, "\t\tCondition %d: Volume %d", i, soundListVolume[i]);
-				}
-
-				soundAction = soundList[condVarValue];
-				soundVolume = soundListVolume[condVarValue];
-			}
-		}
+	debugC(kDebugScript, "Opcode %d: Process Sound Block", op);
+
+	uint16 decodeIdx = 0;
+
+	MystSoundBlock soundBlock;
+	soundBlock.sound = argv[decodeIdx++];
+	soundBlock.soundVolume = 65535;
+
+	if (soundBlock.sound == kMystSoundActionChangeVolume || soundBlock.sound > 0) {
+		soundBlock.soundVolume = argv[decodeIdx++];
+	} else if (soundBlock.sound == kMystSoundActionConditional) {
+		debugC(kDebugScript, "Conditional sound list");
+		soundBlock.soundVar = argv[decodeIdx++];
+
+		uint16 condCount = argv[decodeIdx++];
+		debugC(kDebugScript, "\tcondCount: %d", condCount);
+		for (uint16 i = 0; i < condCount; i++) {
+			MystSoundBlock::SoundItem item;
 
-		if (soundAction == kMystSoundActionContinue)
-			debugC(kDebugScript, "Continue current sound");
-		else if (soundAction == kMystSoundActionChangeVolume) {
-			debugC(kDebugScript, "Continue current sound, change volume");
-			debugC(kDebugScript, "\tVolume: %d", soundVolume);
-			_vm->_sound->changeBackgroundVolumeMyst(soundVolume);
-		} else if (soundAction == kMystSoundActionStop) {
-			debugC(kDebugScript, "Stop sound");
-			_vm->_sound->stopBackgroundMyst();
-		} else if (soundAction > 0) {
-			debugC(kDebugScript, "Play new Sound, change volume");
-			debugC(kDebugScript, "\tSound: %d", soundAction);
-			debugC(kDebugScript, "\tVolume: %d", soundVolume);
-			_vm->_sound->replaceBackgroundMyst(soundAction, soundVolume);
-		} else {
-			debugC(kDebugScript, "Unknown");
-			warning("Unknown sound control value in opcode %d", op);
+			item.action = argv[decodeIdx++];
+			debugC(kDebugScript, "\t\tCondition %d: Action %d", i, item.action);
+
+			if (item.action == kMystSoundActionChangeVolume || item.action > 0) {
+				item.volume = argv[decodeIdx++];
+			} else
+				item.volume = 65535;
+			debugC(kDebugScript, "\t\tCondition %d: Volume %d", i, item.volume);
+
+			soundBlock.soundList.push_back(item);
 		}
-	} else
-		warning("Unknown arg count in opcode %d", op);
+	} else {
+		debugC(kDebugScript, "Unknown");
+		warning("Unknown sound control value in opcode %d", op);
+	}
 
-	delete[] soundList;
-	soundList = nullptr;
-	delete[] soundListVolume;
-	soundListVolume = nullptr;
+	_vm->applySoundBlock(soundBlock);
 }
 
 void MystScriptParser::o_soundPlaySwitch(uint16 op, uint16 var, uint16 argc, uint16 *argv) {






More information about the Scummvm-git-logs mailing list