[Scummvm-cvs-logs] SF.net SVN: scummvm:[34957] scummvm/trunk/engines/sword2

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sun Nov 9 15:32:24 CET 2008


Revision: 34957
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34957&view=rev
Author:   eriktorbjorn
Date:     2008-11-09 14:32:24 +0000 (Sun, 09 Nov 2008)

Log Message:
-----------
Allow pausing (from the outside) during credits and palette fades. Refactored the
code to distinguish outside pausing from in-game pausing, to avoid cursor-related
problems. The screen is now only dimmed during in-game pausing.

Modified Paths:
--------------
    scummvm/trunk/engines/sword2/palette.cpp
    scummvm/trunk/engines/sword2/screen.cpp
    scummvm/trunk/engines/sword2/screen.h
    scummvm/trunk/engines/sword2/sword2.cpp
    scummvm/trunk/engines/sword2/sword2.h

Modified: scummvm/trunk/engines/sword2/palette.cpp
===================================================================
--- scummvm/trunk/engines/sword2/palette.cpp	2008-11-09 13:50:41 UTC (rev 34956)
+++ scummvm/trunk/engines/sword2/palette.cpp	2008-11-09 14:32:24 UTC (rev 34957)
@@ -164,8 +164,11 @@
 void Screen::dimPalette(bool dim) {
 	if (dim != _dimPalette) {
 		_dimPalette = dim;
-		setSystemPalette(_palette, 0, 256);
-		setNeedFullRedraw();
+		// If the palette is in the middle of fading, don't update it.
+		if (_fadeStatus != RDFADE_DOWN && _fadeStatus != RDFADE_UP) {
+			setSystemPalette(_palette, 0, 256);
+			setNeedFullRedraw();
+		}
 	}
 }
 
@@ -180,7 +183,7 @@
 
 	_fadeTotalTime = (int32)(time * 1000);
 	_fadeStatus = RDFADE_UP;
-	_fadeStartTime = _vm->_system->getMillis();
+	_fadeStartTime = getTick();
 
 	return RD_OK;
 }
@@ -196,7 +199,7 @@
 
 	_fadeTotalTime = (int32)(time * 1000);
 	_fadeStatus = RDFADE_DOWN;
-	_fadeStartTime = _vm->_system->getMillis();
+	_fadeStartTime = getTick();
 
 	return RD_OK;
 }
@@ -232,7 +235,7 @@
 
 	// I don't know if this is necessary, but let's limit how often the
 	// palette is updated, just to be safe.
-	currentTime = _vm->_system->getMillis();
+	currentTime = getTick();
 	if (currentTime - previousTime <= 25)
 		return;
 

Modified: scummvm/trunk/engines/sword2/screen.cpp
===================================================================
--- scummvm/trunk/engines/sword2/screen.cpp	2008-11-09 13:50:41 UTC (rev 34956)
+++ scummvm/trunk/engines/sword2/screen.cpp	2008-11-09 14:32:24 UTC (rev 34957)
@@ -111,6 +111,10 @@
 	free(_lightMask);
 }
 
+uint32 Screen::getTick() {
+	return _vm->getMillis() - _pauseTicks;
+}
+
 void Screen::pauseScreen(bool pause) {
 	if (pause) {
 		_pauseStartTick = _vm->_system->getMillis();
@@ -323,10 +327,10 @@
 		updateDisplay();
 
 		_frameCount++;
-		if (_vm->getMillis() > _cycleTime) {
+		if (getTick() > _cycleTime) {
 			_fps = _frameCount;
 			_frameCount = 0;
-			_cycleTime = _vm->getMillis() + 1000;
+			_cycleTime = getTick() + 1000;
 		}
 	} while (!endRenderCycle());
 
@@ -397,7 +401,7 @@
 	waitForFade();
 
 	if (time > 0) {
-		uint32 targetTime = _vm->getMillis() + (time * 1000);
+		uint32 targetTime = _vm->_system->getMillis() + (time * 1000);
 		_vm->sleepUntil(targetTime);
 	} else {
 		while (!_vm->shouldQuit()) {
@@ -1038,10 +1042,8 @@
 	bool abortCredits = false;
 
 	int scrollSteps = lineTop + CREDITS_FONT_HEIGHT;
-	uint32 musicStart = _vm->getMillis();
+	uint32 musicStart = getTick();
 
-	_pauseTicks = 0;
-
 	// Ideally the music should last just a tiny bit longer than the
 	// credits. Note that musicTimeRemaining() will return 0 if the music
 	// is muted, so we need a sensible fallback for that case.

Modified: scummvm/trunk/engines/sword2/screen.h
===================================================================
--- scummvm/trunk/engines/sword2/screen.h	2008-11-09 13:50:41 UTC (rev 34956)
+++ scummvm/trunk/engines/sword2/screen.h	2008-11-09 14:32:24 UTC (rev 34957)
@@ -355,6 +355,8 @@
 	uint32 _pauseTicks;
 	uint32 _pauseStartTick;
 
+	uint32 getTick();
+
 public:
 	Screen(Sword2Engine *vm, int16 width, int16 height);
 	~Screen();

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2008-11-09 13:50:41 UTC (rev 34956)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2008-11-09 14:32:24 UTC (rev 34957)
@@ -451,7 +451,7 @@
 
 #ifdef SWORD2_DEBUG
 		if (_stepOneCycle) {
-			pauseEngineIntern(true);
+			pauseEngine(true);
 			_stepOneCycle = false;
 		}
 #endif
@@ -465,9 +465,9 @@
 				switch (ke->kbd.keycode) {
 				case Common::KEYCODE_p:
 					if (_gamePaused)
-						pauseEngineIntern(false);
+						pauseEngine(false);
 					else
-						pauseEngineIntern(true);
+						pauseEngine(true);
 					break;
 				case Common::KEYCODE_c:
 					if (!_logic->readVar(DEMO) && !_mouse->isChoosing()) {
@@ -480,7 +480,7 @@
 				case Common::KEYCODE_SPACE:
 					if (_gamePaused) {
 						_stepOneCycle = true;
-						pauseEngineIntern(false);
+						pauseEngine(false);
 					}
 					break;
 				case Common::KEYCODE_s:
@@ -741,19 +741,13 @@
 	}
 }
 
-void Sword2Engine::pauseEngineIntern(bool pause) {
-	if (pause) {
-		// FIXME: We should never disallow pausing.
+void Sword2Engine::pauseEngine(bool pause) {
+	if (pause == _gamePaused)
+		return;
 
-		// Don't allow Pause while screen fading or while black
-		if (_screen->getFadeStatus() != RDFADE_NONE)
-			return;
+	pauseEngineIntern(pause);
 
-		_sound->pauseAllSound();
-		_mouse->pauseEngine(true);
-		_logic->pauseMovie(true);
-		_screen->pauseScreen(true);
-
+	if (pause) {
 #ifdef SWORD2_DEBUG
 		// Don't dim it if we're single-stepping through frames
 		// dim the palette during the pause
@@ -763,21 +757,31 @@
 #else
 		_screen->dimPalette(true);
 #endif
+	} else {
+		_screen->dimPalette(false);
 
+		// If mouse is about or we're in a chooser menu
+		if (!_mouse->getMouseStatus() || _mouse->isChoosing())
+			_mouse->setMouse(NORMAL_MOUSE_ID);
+	}
+}
+
+void Sword2Engine::pauseEngineIntern(bool pause) {
+	if (pause == _gamePaused)
+		return;
+
+	if (pause) {
+		_sound->pauseAllSound();
+		_mouse->pauseEngine(true);
+		_logic->pauseMovie(true);
+		_screen->pauseScreen(true);
 		_gamePaused = true;
 	} else {
 		_mouse->pauseEngine(false);
 		_logic->pauseMovie(false);
 		_screen->pauseScreen(false);
 		_sound->unpauseAllSound();
-
-		_screen->dimPalette(false);
-
 		_gamePaused = false;
-
-		// If mouse is about or we're in a chooser menu
-		if (!_mouse->getMouseStatus() || _mouse->isChoosing())
-			_mouse->setMouse(NORMAL_MOUSE_ID);
 	}
 }
 

Modified: scummvm/trunk/engines/sword2/sword2.h
===================================================================
--- scummvm/trunk/engines/sword2/sword2.h	2008-11-09 13:50:41 UTC (rev 34956)
+++ scummvm/trunk/engines/sword2/sword2.h	2008-11-09 14:32:24 UTC (rev 34957)
@@ -135,6 +135,8 @@
 	Sword2Engine(OSystem *syst);
 	~Sword2Engine();
 
+	void pauseEngine(bool pause);
+
 	int getFramesPerSecond();
 
 	void registerDefaultSettings();


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