[Scummvm-git-logs] scummvm master -> 6f46b174df5f861220b935e16ce998b66062e4ca

bgK bastien.bouclet at gmail.com
Wed Jul 5 20:36:58 CEST 2017


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

Summary:
6f46b174df MOHAWK: Myst: Poll for events every 10ms when waiting


Commit: 6f46b174df5f861220b935e16ce998b66062e4ca
    https://github.com/scummvm/scummvm/commit/6f46b174df5f861220b935e16ce998b66062e4ca
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2017-07-05T20:35:26+02:00

Commit Message:
MOHAWK: Myst: Poll for events every 10ms when waiting

Changed paths:
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h
    engines/mohawk/myst_stacks/intro.cpp
    engines/mohawk/myst_stacks/mechanical.cpp
    engines/mohawk/myst_stacks/myst.cpp
    engines/mohawk/myst_stacks/selenitic.cpp


diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index d1da36a..3d45e38 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -370,16 +370,16 @@ bool MohawkEngine_Myst::pollEvent(Common::Event &event) {
 	return eventReturned;
 }
 
-bool MohawkEngine_Myst::skippableWait(uint32 duration) {
-	uint32 end = _system->getMillis() + duration;
+bool MohawkEngine_Myst::wait(uint32 duration, bool skippable) {
+	uint32 end = getTotalPlayTime() + duration;
 	bool skipped = false;
 
-	while (_system->getMillis() < end && !skipped) {
+	while (getTotalPlayTime() < end && !skipped && !shouldQuit()) {
 		Common::Event event;
 		while (_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
 			case Common::EVENT_LBUTTONUP:
-				skipped = true;
+				skipped = skippable;
 				break;
 			case Common::EVENT_KEYDOWN:
 				switch (event.kbd.keycode) {
@@ -387,7 +387,7 @@ bool MohawkEngine_Myst::skippableWait(uint32 duration) {
 					pauseGame();
 					break;
 				case Common::KEYCODE_ESCAPE:
-					skipped = true;
+					skipped = skippable;
 					break;
 				default:
 					break;
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index f313e38..588880a 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -188,7 +188,7 @@ public:
 	void checkCursorHints();
 	MystArea *updateCurrentResource();
 	void pollAndDiscardEvents();
-	bool skippableWait(uint32 duration);
+	bool wait(uint32 duration, bool skippable = false);
 
 	MystSoundBlock readSoundBlock(Common::ReadStream *stream) const;
 	void applySoundBlock(const MystSoundBlock &block);
diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp
index f448108..e465180 100644
--- a/engines/mohawk/myst_stacks/intro.cpp
+++ b/engines/mohawk/myst_stacks/intro.cpp
@@ -155,7 +155,7 @@ void Intro::mystLinkBook_run() {
 	if (_startTime == 1) {
 		_startTime = 0;
 
-		if (!_vm->skippableWait(5000)) {
+		if (!_vm->wait(5000, true)) {
 			_linkBookMovie->playMovie();
 			_vm->_gfx->copyImageToBackBuffer(4, Common::Rect(544, 333));
 			_vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index 3324c9a..6daa5bd 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -401,7 +401,7 @@ void Mechanical::o_elevatorRotationStop(uint16 op, uint16 var, uint16 argc, uint
 				break;
 
 			_vm->redrawArea(12);
-			_vm->_system->delayMillis(100);
+			_vm->wait(100);
 		}
 
 		// Increment position
@@ -633,7 +633,7 @@ void Mechanical::elevatorGoMiddle_run() {
 				_vm->_sound->playSoundBlocking(13120);
 				_vm->_sound->replaceSoundMyst(8120);
 				_vm->_gfx->copyImageToBackBuffer(6327, Common::Rect(544, 333));
-				_vm->_system->delayMillis(500);
+				_vm->wait(500);
 				_vm->_sound->replaceSoundMyst(9120);
 				static uint16 moviePos[2] = { 3540, 5380 };
 				o_elevatorWindowMovie(121, 0, 2, moviePos);
@@ -690,7 +690,7 @@ void Mechanical::o_elevatorWaitTimeout(uint16 op, uint16 var, uint16 argc, uint1
 	// Wait while the elevator times out
 	while (_elevatorGoingMiddle) {
 		runPersistentScripts();
-		_vm->skippableWait(10);
+		_vm->_system->delayMillis(10);
 	}
 }
 
@@ -788,7 +788,7 @@ void Mechanical::elevatorRotation_run() {
 
 		_vm->_sound->replaceSoundMyst(_elevatorRotationSoundId);
 		_vm->redrawArea(11);
-		_vm->_system->delayMillis(100);
+		_vm->wait(100);
 	}
 }
 
@@ -913,7 +913,7 @@ void Mechanical::fortressSimulation_run() {
 	if (_fortressSimulationInit) {
 		// Init sequence
 		_vm->_sound->replaceBackgroundMyst(_fortressSimulationStartSound1, 65535);
-		_vm->skippableWait(5000);
+		_vm->wait(5000, true);
 		_vm->_sound->replaceSoundMyst(_fortressSimulationStartSound2);
 
 		// Update movie while the sound is playing
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index 424dd2f..d9a1178 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -1135,7 +1135,7 @@ void Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv
 
 	if (!_state.clockTowerBridgeOpen && correctTime) {
 		_vm->_sound->replaceSoundMyst(soundId);
-		_vm->_system->delayMillis(500);
+		_vm->wait(500);
 
 		// Gears rise up
 		VideoHandle gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack));
@@ -1150,7 +1150,7 @@ void Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv
 		_vm->redrawArea(12);
 	} else if (_state.clockTowerBridgeOpen && !correctTime) {
 		_vm->_sound->replaceSoundMyst(soundId);
-		_vm->_system->delayMillis(500);
+		_vm->wait(500);
 
 		// Gears sink down
 		VideoHandle gears = _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack));
@@ -1179,7 +1179,7 @@ void Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 argc, uint16 *argv)
 	_vm->_gfx->copyImageSectionToScreen(4699, src, dest);
 	_vm->_system->updateScreen();
 
-	_vm->_system->delayMillis(200);
+	_vm->wait(200);
 
 	_vm->_gfx->copyBackBufferToScreen(dest);
 	_vm->_system->updateScreen();
@@ -1315,7 +1315,7 @@ void Myst::imagerValidation_run() {
 
 		_imagerValidationStep++;
 
-		_vm->_system->delayMillis(50);
+		_vm->wait(50);
 
 		_imagerRedButton->drawConditionalDataToScreen(0);
 
@@ -1763,7 +1763,7 @@ void Myst::o_observatoryGoButton(uint16 op, uint16 var, uint16 argc, uint16 *arg
 		uint32 end = _vm->_system->getMillis() + 32 * ABS(distance) / 50 + 800;
 
 		while (end > _vm->_system->getMillis()) {
-			_vm->_system->delayMillis(50);
+			_vm->wait(50);
 
 			observatoryUpdateVisualizer(_vm->_rnd->getRandomNumber(409), _vm->_rnd->getRandomNumber(409));
 
@@ -2231,35 +2231,35 @@ void Myst::rocketCheckSolution() {
 	soundId = rocketSliderGetSound(_rocketSlider1->_pos.y);
 	_vm->_sound->replaceSoundMyst(soundId);
 	_rocketSlider1->drawConditionalDataToScreen(2);
-	_vm->_system->delayMillis(250);
+	_vm->wait(250);
 	if (soundId != 9558)
 		solved = false;
 
 	soundId = rocketSliderGetSound(_rocketSlider2->_pos.y);
 	_vm->_sound->replaceSoundMyst(soundId);
 	_rocketSlider2->drawConditionalDataToScreen(2);
-	_vm->_system->delayMillis(250);
+	_vm->wait(250);
 	if (soundId != 9546)
 		solved = false;
 
 	soundId = rocketSliderGetSound(_rocketSlider3->_pos.y);
 	_vm->_sound->replaceSoundMyst(soundId);
 	_rocketSlider3->drawConditionalDataToScreen(2);
-	_vm->_system->delayMillis(250);
+	_vm->wait(250);
 	if (soundId != 9543)
 		solved = false;
 
 	soundId = rocketSliderGetSound(_rocketSlider4->_pos.y);
 	_vm->_sound->replaceSoundMyst(soundId);
 	_rocketSlider4->drawConditionalDataToScreen(2);
-	_vm->_system->delayMillis(250);
+	_vm->wait(250);
 	if (soundId != 9553)
 		solved = false;
 
 	soundId = rocketSliderGetSound(_rocketSlider5->_pos.y);
 	_vm->_sound->replaceSoundMyst(soundId);
 	_rocketSlider5->drawConditionalDataToScreen(2);
-	_vm->_system->delayMillis(250);
+	_vm->wait(250);
 	if (soundId != 9560)
 		solved = false;
 
@@ -3011,7 +3011,7 @@ void Myst::clockGearsCheckSolution() {
 		_clockWeightPosition = 2214;
 
 		_vm->_sound->replaceSoundMyst(6113);
-		_vm->_system->delayMillis(1000);
+		_vm->wait(1000);
 		_vm->_sound->replaceSoundMyst(7113);
 
 		// Gear opening video
@@ -3067,7 +3067,7 @@ void Myst::clockReset() {
 	// Close gear
 	if (_state.gearsOpen) {
 		_vm->_sound->replaceSoundMyst(6113);
-		_vm->_system->delayMillis(1000);
+		_vm->wait(1000);
 		_vm->_sound->replaceSoundMyst(7113);
 
 		// Gear closing movie
@@ -3544,33 +3544,33 @@ void Myst::observatory_run() {
 		if (observatoryIsDDMMYYYY2400()) {
 			_vm->_sound->replaceSoundMyst(8500);
 			_observatoryDaySlider->drawConditionalDataToScreen(2);
-			_vm->_system->delayMillis(200);
+			_vm->wait(200);
 			_vm->redrawResource(_observatoryDaySlider);
 
 			_vm->_sound->replaceSoundMyst(8500);
 			_observatoryMonthSlider->drawConditionalDataToScreen(2);
-			_vm->_system->delayMillis(200);
+			_vm->wait(200);
 			_vm->redrawResource(_observatoryMonthSlider);
 		} else {
 			_vm->_sound->replaceSoundMyst(8500);
 			_observatoryMonthSlider->drawConditionalDataToScreen(2);
-			_vm->_system->delayMillis(200);
+			_vm->wait(200);
 			_vm->redrawResource(_observatoryMonthSlider);
 
 			_vm->_sound->replaceSoundMyst(8500);
 			_observatoryDaySlider->drawConditionalDataToScreen(2);
-			_vm->_system->delayMillis(200);
+			_vm->wait(200);
 			_vm->redrawResource(_observatoryDaySlider);
 		}
 
 		_vm->_sound->replaceSoundMyst(8500);
 		_observatoryYearSlider->drawConditionalDataToScreen(2);
-		_vm->_system->delayMillis(200);
+		_vm->wait(200);
 		_vm->redrawResource(_observatoryYearSlider);
 
 		_vm->_sound->replaceSoundMyst(8500);
 		_observatoryTimeSlider->drawConditionalDataToScreen(2);
-		_vm->_system->delayMillis(200);
+		_vm->wait(200);
 		_vm->redrawResource(_observatoryTimeSlider);
 
 		_vm->_cursor->showCursor();
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 815d40e..ad3de69 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -363,7 +363,7 @@ void Selenitic::mazeRunnerBacktrack(uint16 &oldPosition) {
 		}
 
 		_mazeRunnerCompass->drawConditionalDataToScreen(_mazeRunnerDirection);
-		_vm->_system->delayMillis(150);
+		_vm->wait(150);
 	}
 }
 
@@ -608,8 +608,7 @@ void Selenitic::o_soundReceiverSigma(uint16 op, uint16 var, uint16 argc, uint16
 		soundReceiverDrawView();
 		uint16 soundId = soundReceiverCurrentSound(source, *_soundReceiverPosition);
 		_vm->_sound->replaceBackgroundMyst(soundId);
-		_vm->_system->delayMillis(1000);
-		_vm->pollAndDiscardEvents();
+		_vm->wait(1000);
 	}
 
 	_soundReceiverPosition = oldPosition;
@@ -870,8 +869,7 @@ void Selenitic::o_soundLockEndMove(uint16 op, uint16 var, uint16 argc, uint16 *a
 void Selenitic::soundLockCheckSolution(MystAreaSlider *slider, uint16 value, uint16 solution, bool &solved) {
 	slider->drawConditionalDataToScreen(2);
 	_vm->_sound->replaceSoundMyst(soundLockCurrentSound(value / 12, false));
-	_vm->_system->delayMillis(1500);
-	_vm->pollAndDiscardEvents();
+	_vm->wait(1500);
 
 	if (value / 12 != solution)
 		solved = false;





More information about the Scummvm-git-logs mailing list