[Scummvm-cvs-logs] SF.net SVN: scummvm:[35062] scummvm/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Nov 14 23:08:11 CET 2008


Revision: 35062
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35062&view=rev
Author:   lordhoto
Date:     2008-11-14 22:08:10 +0000 (Fri, 14 Nov 2008)

Log Message:
-----------
Committed my patch #2123680 "SDL: Backend transaction / rollback support".

Modified Paths:
--------------
    scummvm/trunk/backends/platform/sdl/events.cpp
    scummvm/trunk/backends/platform/sdl/graphics.cpp
    scummvm/trunk/backends/platform/sdl/sdl.cpp
    scummvm/trunk/backends/platform/sdl/sdl.h
    scummvm/trunk/base/main.cpp
    scummvm/trunk/common/system.h
    scummvm/trunk/engines/agi/agi.cpp
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/cine/cine.cpp
    scummvm/trunk/engines/cruise/cruise.cpp
    scummvm/trunk/engines/drascula/drascula.cpp
    scummvm/trunk/engines/engine.cpp
    scummvm/trunk/engines/engine.h
    scummvm/trunk/engines/gob/video.cpp
    scummvm/trunk/engines/groovie/groovie.cpp
    scummvm/trunk/engines/igor/igor.cpp
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/lure/lure.cpp
    scummvm/trunk/engines/m4/m4.cpp
    scummvm/trunk/engines/made/made.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/queen/queen.cpp
    scummvm/trunk/engines/saga/gfx.cpp
    scummvm/trunk/engines/scumm/scumm.cpp
    scummvm/trunk/engines/sky/sky.cpp
    scummvm/trunk/engines/sword1/sword1.cpp
    scummvm/trunk/engines/sword2/screen.cpp
    scummvm/trunk/engines/sword2/sword2.cpp
    scummvm/trunk/engines/tinsel/tinsel.cpp
    scummvm/trunk/engines/touche/touche.cpp
    scummvm/trunk/engines/tucker/tucker.cpp

Modified: scummvm/trunk/backends/platform/sdl/events.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/events.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/backends/platform/sdl/events.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -77,9 +77,9 @@
 
 	// Adjust for the screen scaling
 	if (!_overlayVisible) {
-		event.mouse.x /= _scaleFactor;
-		event.mouse.y /= _scaleFactor;
-		if (_adjustAspectRatio)
+		event.mouse.x /= _videoMode.scaleFactor;
+		event.mouse.y /= _videoMode.scaleFactor;
+		if (_videoMode.aspectRatio)
 			event.mouse.y = aspect2Real(event.mouse.y);
 	}
 }
@@ -196,10 +196,10 @@
 			if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN
 			                  || ev.key.keysym.sym == SDLK_KP_ENTER)) {
 				beginGFXTransaction();
-				setFullscreenMode(!_fullscreen);
+					setFullscreenMode(!_videoMode.fullscreen);
 				endGFXTransaction();
 #ifdef USE_OSD
-				if (_fullscreen)
+				if (_videoMode.fullscreen)
 					displayMessageOnOSD("Fullscreen mode");
 				else
 					displayMessageOnOSD("Windowed mode");

Modified: scummvm/trunk/backends/platform/sdl/graphics.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/graphics.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/backends/platform/sdl/graphics.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -49,7 +49,7 @@
 };
 
 // Table of relative scalers magnitudes
-// [definedScale - 1][_scaleFactor - 1]
+// [definedScale - 1][scaleFactor - 1]
 static ScalerProc *scalersMagn[3][3] = {
 #ifndef DISABLE_SCALERS
 	{ Normal1x, AdvMame2x, AdvMame3x },
@@ -86,122 +86,146 @@
 }
 
 void OSystem_SDL::beginGFXTransaction(void) {
-	assert (_transactionMode == kTransactionNone);
+	assert(_transactionMode == kTransactionNone);
 
 	_transactionMode = kTransactionActive;
 
-	_transactionDetails.modeChanged = false;
 	_transactionDetails.sizeChanged = false;
-	_transactionDetails.arChanged = false;
-	_transactionDetails.fsChanged = false;
 
 	_transactionDetails.needHotswap = false;
 	_transactionDetails.needUpdatescreen = false;
-	_transactionDetails.needUnload = false;
 
 	_transactionDetails.normal1xScaler = false;
+
+	_oldVideoMode = _videoMode;
 }
 
-void OSystem_SDL::endGFXTransaction(void) {
-	// for each engine we run initCommonGFX() as first thing in the transaction
-	// and initSize() is called later. If user runs launcher at 320x200 with
-	// 2x overlay, setting to Nomral1x sclaler in that case will be suppressed
-	// and backend is forced to 2x
-	//
-	// This leads to bad results such as 1280x960 window for 640x480 engines.
-	// To prevent that we rerun setGraphicsMode() if there was 1x scaler request
-	if (_transactionDetails.normal1xScaler)
-		setGraphicsMode(GFX_NORMAL);
+OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
+	int errors = kTransactionSuccess;
 
-	assert (_transactionMode == kTransactionActive);
+	assert(_transactionMode != kTransactionNone);
 
-	_transactionMode = kTransactionCommit;
-	if (_transactionDetails.modeChanged)
-		setGraphicsMode(_transactionDetails.mode);
+	if (_transactionMode == kTransactionRollback) {
+		if (_videoMode.fullscreen != _oldVideoMode.fullscreen) {
+			errors |= kTransactionFullscreenFailed;
 
-	if (_transactionDetails.sizeChanged)
-		initSize(_transactionDetails.w, _transactionDetails.h);
+			_videoMode.fullscreen = _oldVideoMode.fullscreen;
+		} else if (_videoMode.aspectRatio != _oldVideoMode.aspectRatio) {
+			errors |= kTransactionAspectRatioFailed;
 
-	if (_transactionDetails.arChanged)
-		setAspectRatioCorrection(_transactionDetails.ar);
+			_videoMode.aspectRatio = _oldVideoMode.aspectRatio;
+		} else if (_videoMode.mode != _oldVideoMode.mode) {
+			errors |= kTransactionModeSwitchFailed;
 
-	if (_transactionDetails.needUnload) {
+			_videoMode.mode = _oldVideoMode.mode;
+			_videoMode.scaleFactor = _oldVideoMode.scaleFactor;
+		} else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) {
+			errors |= kTransactionSizeChangeFailed;
+
+			_videoMode.screenWidth = _oldVideoMode.screenWidth;
+			_videoMode.screenHeight = _oldVideoMode.screenHeight;
+			_videoMode.overlayWidth = _oldVideoMode.overlayWidth;
+			_videoMode.overlayHeight = _oldVideoMode.overlayHeight;
+		}
+
+		if (_videoMode.fullscreen == _oldVideoMode.fullscreen &&
+			_videoMode.aspectRatio == _oldVideoMode.aspectRatio &&
+			_videoMode.mode == _oldVideoMode.mode &&
+			_videoMode.screenWidth == _oldVideoMode.screenWidth &&
+		   	_videoMode.screenHeight == _oldVideoMode.screenHeight) {
+
+			// Our new video mode would now be exactly the same as the
+			// old one. Since we still can not assume SDL_SetVideoMode
+			// to be working fine, we need to invalidate the old video
+			// mode, so loadGFXMode would error out properly.
+			_oldVideoMode.setup = false;
+		}
+	}
+
+	if (_transactionDetails.sizeChanged) {
 		unloadGFXMode();
-		loadGFXMode();
-		clearOverlay();
-	} else {
-		if (!_transactionDetails.fsChanged) {
-			if (_transactionDetails.needHotswap)
-				hotswapGFXMode();
-			else if (_transactionDetails.needUpdatescreen)
+		if (!loadGFXMode()) {
+			if (_oldVideoMode.setup) {
+				_transactionMode = kTransactionRollback;
+				errors |= endGFXTransaction();
+			}
+		} else {
+			setGraphicsModeIntern();
+			clearOverlay();
+
+			_videoMode.setup = true;
+			_modeChanged = true;
+		}
+	} else if (_transactionDetails.needHotswap) {
+		setGraphicsModeIntern();
+		if (!hotswapGFXMode()) {
+			if (_oldVideoMode.setup) {
+				_transactionMode = kTransactionRollback;
+				errors |= endGFXTransaction();
+			}
+		} else {
+			_videoMode.setup = true;
+			_modeChanged = true;
+
+			if (_transactionDetails.needUpdatescreen)
 				internUpdateScreen();
 		}
 	}
 
-	if (_transactionDetails.fsChanged)
-		setFullscreenMode(_transactionDetails.fs);
-
 	_transactionMode = kTransactionNone;
+	return (TransactionError)errors;
 }
 
 bool OSystem_SDL::setGraphicsMode(int mode) {
 	Common::StackLock lock(_graphicsMutex);
 
+	assert(_transactionMode == kTransactionActive);
+
+	if (_oldVideoMode.setup && _oldVideoMode.mode == mode)
+		return true;
+
 	int newScaleFactor = 1;
-	ScalerProc *newScalerProc;
 
 	switch(mode) {
 	case GFX_NORMAL:
 		newScaleFactor = 1;
-		newScalerProc = Normal1x;
 		break;
 #ifndef DISABLE_SCALERS
 	case GFX_DOUBLESIZE:
 		newScaleFactor = 2;
-		newScalerProc = Normal2x;
 		break;
 	case GFX_TRIPLESIZE:
 		newScaleFactor = 3;
-		newScalerProc = Normal3x;
 		break;
 
 	case GFX_2XSAI:
 		newScaleFactor = 2;
-		newScalerProc = _2xSaI;
 		break;
 	case GFX_SUPER2XSAI:
 		newScaleFactor = 2;
-		newScalerProc = Super2xSaI;
 		break;
 	case GFX_SUPEREAGLE:
 		newScaleFactor = 2;
-		newScalerProc = SuperEagle;
 		break;
 	case GFX_ADVMAME2X:
 		newScaleFactor = 2;
-		newScalerProc = AdvMame2x;
 		break;
 	case GFX_ADVMAME3X:
 		newScaleFactor = 3;
-		newScalerProc = AdvMame3x;
 		break;
 #ifndef DISABLE_HQ_SCALERS
 	case GFX_HQ2X:
 		newScaleFactor = 2;
-		newScalerProc = HQ2x;
 		break;
 	case GFX_HQ3X:
 		newScaleFactor = 3;
-		newScalerProc = HQ3x;
 		break;
 #endif
 	case GFX_TV2X:
 		newScaleFactor = 2;
-		newScalerProc = TV2x;
 		break;
 	case GFX_DOTMATRIX:
 		newScaleFactor = 2;
-		newScalerProc = DotMatrix;
 		break;
 #endif // DISABLE_SCALERS
 
@@ -211,47 +235,81 @@
 	}
 
 	_transactionDetails.normal1xScaler = (mode == GFX_NORMAL);
+	if (_oldVideoMode.setup && _oldVideoMode.scaleFactor != newScaleFactor)
+		_transactionDetails.needHotswap = true;
 
-	_mode = mode;
-	_scalerProc = newScalerProc;
+	_transactionDetails.needUpdatescreen = true;
 
-	if (_transactionMode == kTransactionActive) {
-		_transactionDetails.mode = mode;
-		_transactionDetails.modeChanged = true;
+	_videoMode.mode = mode;
+	_videoMode.scaleFactor = newScaleFactor;
 
-		if (newScaleFactor != _scaleFactor) {
-			_transactionDetails.needHotswap = true;
-			_scaleFactor = newScaleFactor;
-		}
+	return true;
+}
 
-		_transactionDetails.needUpdatescreen = true;
+void OSystem_SDL::setGraphicsModeIntern() {
+	Common::StackLock lock(_graphicsMutex);
+	ScalerProc *newScalerProc = 0;
 
-		return true;
-	}
+	switch (_videoMode.mode) {
+	case GFX_NORMAL:
+		newScalerProc = Normal1x;
+		break;
+#ifndef DISABLE_SCALERS
+	case GFX_DOUBLESIZE:
+		newScalerProc = Normal2x;
+		break;
+	case GFX_TRIPLESIZE:
+		newScalerProc = Normal3x;
+		break;
 
-	// NOTE: This should not be executed at transaction commit
-	//   Otherwise there is some unsolicited setGraphicsMode() call
-	//   which should be properly removed
-	if (newScaleFactor != _scaleFactor) {
-		assert(_transactionMode != kTransactionCommit);
+	case GFX_2XSAI:
+		newScalerProc = _2xSaI;
+		break;
+	case GFX_SUPER2XSAI:
+		newScalerProc = Super2xSaI;
+		break;
+	case GFX_SUPEREAGLE:
+		newScalerProc = SuperEagle;
+		break;
+	case GFX_ADVMAME2X:
+		newScalerProc = AdvMame2x;
+		break;
+	case GFX_ADVMAME3X:
+		newScalerProc = AdvMame3x;
+		break;
+#ifndef DISABLE_HQ_SCALERS
+	case GFX_HQ2X:
+		newScalerProc = HQ2x;
+		break;
+	case GFX_HQ3X:
+		newScalerProc = HQ3x;
+		break;
+#endif
+	case GFX_TV2X:
+		newScalerProc = TV2x;
+		break;
+	case GFX_DOTMATRIX:
+		newScalerProc = DotMatrix;
+		break;
+#endif // DISABLE_SCALERS
 
-		_scaleFactor = newScaleFactor;
-		hotswapGFXMode();
+	default:
+		error("Unknown gfx mode %d", _videoMode.mode);
 	}
 
-	// Determine the "scaler type", i.e. essentially an index into the
-	// s_gfxModeSwitchTable array defined in events.cpp.
-	if (_mode != GFX_NORMAL) {
+	_scalerProc = newScalerProc;
+	
+	if (_videoMode.mode != GFX_NORMAL) {
 		for (int i = 0; i < ARRAYSIZE(s_gfxModeSwitchTable); i++) {
-			if (s_gfxModeSwitchTable[i][1] == _mode || s_gfxModeSwitchTable[i][2] == _mode) {
+			if (s_gfxModeSwitchTable[i][1] == _videoMode.mode || s_gfxModeSwitchTable[i][2] == _videoMode.mode) {
 				_scalerType = i;
 				break;
 			}
 		}
 	}
 
-	if (!_screen)
-		return true;
+	if (!_screen || !_hwscreen)
+		return;
 
 	// Blit everything to the screen
 	_forceFull = true;
@@ -259,81 +317,58 @@
 	// Even if the old and new scale factors are the same, we may have a
 	// different scaler for the cursor now.
 	blitCursor();
-
-	if (_transactionMode != kTransactionCommit)
-		internUpdateScreen();
-
-	// Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later
-	_modeChanged = true;
-
-	return true;
 }
 
 int OSystem_SDL::getGraphicsMode() const {
 	assert (_transactionMode == kTransactionNone);
-	return _mode;
+	return _videoMode.mode;
 }
 
 void OSystem_SDL::initSize(uint w, uint h) {
+	assert(_transactionMode == kTransactionActive);
+
 	// Avoid redundant res changes
-	if ((int)w == _screenWidth && (int)h == _screenHeight &&
-		_transactionMode != kTransactionCommit)
+	if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight)
 		return;
 
-	_screenWidth = w;
-	_screenHeight = h;
+	_videoMode.screenWidth = w;
+	_videoMode.screenHeight = h;
 
-	_cksumNum = (_screenWidth * _screenHeight / (8 * 8));
+	_cksumNum = (w * h / (8 * 8));
 
-	if (_transactionMode == kTransactionActive) {
-		_transactionDetails.w = w;
-		_transactionDetails.h = h;
-		_transactionDetails.sizeChanged = true;
+	_transactionDetails.sizeChanged = true;
 
-		_transactionDetails.needUnload = true;
-
-		return;
-	}
-
 	free(_dirtyChecksums);
 	_dirtyChecksums = (uint32 *)calloc(_cksumNum * 2, sizeof(uint32));
-
-	if (_transactionMode != kTransactionCommit) {
-		unloadGFXMode();
-		loadGFXMode();
-
-		// if initSize() gets called in the middle, overlay is not transparent
-		clearOverlay();
-	}
 }
 
-void OSystem_SDL::loadGFXMode() {
+bool OSystem_SDL::loadGFXMode() {
 	assert(_inited);
 	_forceFull = true;
 
 	int hwW, hwH;
 
 #ifndef __MAEMO__
-	_overlayWidth = _screenWidth * _scaleFactor;
-	_overlayHeight = _screenHeight * _scaleFactor;
+	_videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
+	_videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor;
 
-	if (_screenHeight != 200 && _screenHeight != 400)
-		_adjustAspectRatio = false;
+	if (_videoMode.screenHeight != 200 && _videoMode.screenHeight != 400)
+		_videoMode.aspectRatio = false;
 
-	if (_adjustAspectRatio)
-		_overlayHeight = real2Aspect(_overlayHeight);
+	if (_videoMode.aspectRatio)
+		_videoMode.overlayHeight = real2Aspect(_videoMode.overlayHeight);
 
-	hwW = _screenWidth * _scaleFactor;
+	hwW = _videoMode.screenWidth * _videoMode.scaleFactor;
 	hwH = effectiveScreenHeight();
 #else
-	hwW = _overlayWidth;
-	hwH = _overlayHeight;
+	hwW = _videoMode.overlayWidth;
+	hwH = _videoMode.overlayHeight;
 #endif
 
 	//
 	// Create the surface that contains the 8 bit game data
 	//
-	_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth, _screenHeight, 8, 0, 0, 0, 0);
+	_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth, _videoMode.screenHeight, 8, 0, 0, 0, 0);
 	if (_screen == NULL)
 		error("allocating _screen failed");
 
@@ -342,27 +377,18 @@
 	//
 
 	_hwscreen = SDL_SetVideoMode(hwW, hwH, 16,
-		_fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
+		_videoMode.fullscreen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
 	);
 	if (_hwscreen == NULL) {
 		// DON'T use error(), as this tries to bring up the debug
 		// console, which WON'T WORK now that _hwscreen is hosed.
 
-		// FIXME: We should be able to continue the game without
-		// shutting down or bringing up the debug console, but at
-		// this point we've already screwed up all our member vars.
-		// We need to find a way to call SDL_SetVideoMode *before*
-		// that happens and revert to all the old settings if we
-		// can't pull off the switch to the new settings.
-		//
-		// Fingolfin says: the "easy" way to do that is not to modify
-		// the member vars before we are sure everything is fine. Think
-		// of "transactions, commit, rollback" style... we use local vars
-		// in place of the member vars, do everything etc. etc.. In case
-		// of a failure, rollback is trivial. Only if everything worked fine
-		// do we "commit" the changed values to the member vars.
-		warning("SDL_SetVideoMode says we can't switch to that mode (%s)", SDL_GetError());
-		quit();
+		if (!_oldVideoMode.setup) {
+			warning("SDL_SetVideoMode says we can't switch to that mode (%s)", SDL_GetError());
+			quit();
+		} else {
+			return false;
+		}
 	}
 
 	//
@@ -376,7 +402,7 @@
 		InitScalers(565);
 
 	// Need some extra bytes around when using 2xSaI
-	_tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth + 3, _screenHeight + 3,
+	_tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.screenWidth + 3, _videoMode.screenHeight + 3,
 						16,
 						_hwscreen->format->Rmask,
 						_hwscreen->format->Gmask,
@@ -386,7 +412,7 @@
 	if (_tmpscreen == NULL)
 		error("allocating _tmpscreen failed");
 
-	_overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight,
+	_overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth, _videoMode.overlayHeight,
 						16,
 						_hwscreen->format->Rmask,
 						_hwscreen->format->Gmask,
@@ -408,7 +434,7 @@
 	_overlayFormat.bShift = _overlayscreen->format->Bshift;
 	_overlayFormat.aShift = _overlayscreen->format->Ashift;
 
-	_tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth + 3, _overlayHeight + 3,
+	_tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _videoMode.overlayWidth + 3, _videoMode.overlayHeight + 3,
 						16,
 						_hwscreen->format->Rmask,
 						_hwscreen->format->Gmask,
@@ -433,10 +459,12 @@
 #endif
 
 	// keyboard cursor control, some other better place for it?
-	_km.x_max = _screenWidth * _scaleFactor - 1;
+	_km.x_max = _videoMode.screenWidth * _videoMode.scaleFactor - 1;
 	_km.y_max = effectiveScreenHeight() - 1;
 	_km.delay_time = 25;
 	_km.last_time = 0;
+
+	return true;
 }
 
 void OSystem_SDL::unloadGFXMode() {
@@ -474,29 +502,38 @@
 	DestroyScalers();
 }
 
-void OSystem_SDL::hotswapGFXMode() {
+bool OSystem_SDL::hotswapGFXMode() {
 	if (!_screen)
-		return;
+		return false;
 
 	// Keep around the old _screen & _overlayscreen so we can restore the screen data
 	// after the mode switch.
 	SDL_Surface *old_screen = _screen;
 	SDL_Surface *old_overlayscreen = _overlayscreen;
+	_screen = NULL;
+	_overlayscreen = NULL;
 
 	// Release the HW screen surface
-	SDL_FreeSurface(_hwscreen);
+	SDL_FreeSurface(_hwscreen); _hwscreen = NULL;
 
-	SDL_FreeSurface(_tmpscreen);
-	SDL_FreeSurface(_tmpscreen2);
+	SDL_FreeSurface(_tmpscreen); _tmpscreen = NULL;
+	SDL_FreeSurface(_tmpscreen2); _tmpscreen2 = NULL;
 
 #ifdef USE_OSD
 	// Release the OSD surface
-	SDL_FreeSurface(_osdSurface);
+	SDL_FreeSurface(_osdSurface); _osdSurface = NULL;
 #endif
 
 	// Setup the new GFX mode
-	loadGFXMode();
+	if (!loadGFXMode()) {
+		unloadGFXMode();
 
+		_screen = old_screen;
+		_overlayscreen = old_overlayscreen;
+
+		return false;
+	}
+
 	// reset palette
 	SDL_SetColors(_screen, _currentPalette, 0, 256);
 
@@ -514,8 +551,7 @@
 	// Blit everything to the screen
 	internUpdateScreen();
 
-	// Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later
-	_modeChanged = true;
+	return true;
 }
 
 void OSystem_SDL::updateScreen() {
@@ -539,9 +575,9 @@
 
 	// If the shake position changed, fill the dirty area with blackness
 	if (_currentShakePos != _newShakePos) {
-		SDL_Rect blackrect = {0, 0, _screenWidth * _scaleFactor, _newShakePos * _scaleFactor};
+		SDL_Rect blackrect = {0, 0, _videoMode.screenWidth * _videoMode.scaleFactor, _newShakePos * _videoMode.scaleFactor};
 
-		if (_adjustAspectRatio && !_overlayVisible)
+		if (_videoMode.aspectRatio && !_overlayVisible)
 			blackrect.h = real2Aspect(blackrect.h - 1) + 1;
 
 		SDL_FillRect(_hwscreen, &blackrect, 0);
@@ -586,15 +622,15 @@
 	if (!_overlayVisible) {
 		origSurf = _screen;
 		srcSurf = _tmpscreen;
-		width = _screenWidth;
-		height = _screenHeight;
+		width = _videoMode.screenWidth;
+		height = _videoMode.screenHeight;
 		scalerProc = _scalerProc;
-		scale1 = _scaleFactor;
+		scale1 = _videoMode.scaleFactor;
 	} else {
 		origSurf = _overlayscreen;
 		srcSurf = _tmpscreen2;
-		width = _overlayWidth;
-		height = _overlayHeight;
+		width = _videoMode.overlayWidth;
+		height = _videoMode.overlayHeight;
 		scalerProc = Normal1x;
 
 		scale1 = 1;
@@ -647,7 +683,7 @@
 				orig_dst_y = dst_y;
 				dst_y = dst_y * scale1;
 
-				if (_adjustAspectRatio && !_overlayVisible)
+				if (_videoMode.aspectRatio && !_overlayVisible)
 					dst_y = real2Aspect(dst_y);
 
 				assert(scalerProc != NULL);
@@ -661,7 +697,7 @@
 			r->h = dst_h * scale1;
 
 #ifndef DISABLE_SCALERS
-			if (_adjustAspectRatio && orig_dst_y < height && !_overlayVisible)
+			if (_videoMode.aspectRatio && orig_dst_y < height && !_overlayVisible)
 				r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1);
 #endif
 		}
@@ -704,51 +740,24 @@
 void OSystem_SDL::setFullscreenMode(bool enable) {
 	Common::StackLock lock(_graphicsMutex);
 	
-	if (_fullscreen == enable)
+	if (_oldVideoMode.setup && _oldVideoMode.fullscreen == enable)
 		return;
 
-	if (_transactionMode == kTransactionCommit) {
-		assert(_hwscreen != 0);
-		_fullscreen = enable;
-
-		// Switch between fullscreen and windowed mode by invoking hotswapGFXMode().
-		// We used to use SDL_WM_ToggleFullScreen() in the past, but this caused various
-		// problems. E.g. on OS X, it was implemented incorrectly for a long time; on
-		// the MAEMO platform, it seems to have caused problems, too.
-		// And on Linux, there were some troubles, too (see bug #1705410).
-		// So, we just do it "manually" now. There shouldn't be any drawbacks to that
-		// anyway.
-		hotswapGFXMode();
-	} else if (_transactionMode == kTransactionActive) {
-		_transactionDetails.fs = enable;
-		_transactionDetails.fsChanged = true;
-
+	if (_transactionMode == kTransactionActive) {
+		_videoMode.fullscreen = enable;
 		_transactionDetails.needHotswap = true;
 	}
 }
 
 void OSystem_SDL::setAspectRatioCorrection(bool enable) {
-	if (((_screenHeight == 200 || _screenHeight == 400) && _adjustAspectRatio != enable) ||
-		_transactionMode == kTransactionCommit) {
-		Common::StackLock lock(_graphicsMutex);
+	Common::StackLock lock(_graphicsMutex);
 
-		//assert(_hwscreen != 0);
-		_adjustAspectRatio = enable;
+	if (_oldVideoMode.setup && _oldVideoMode.aspectRatio == enable)
+		return;
 
-		if (_transactionMode == kTransactionActive) {
-			_transactionDetails.ar = enable;
-			_transactionDetails.arChanged = true;
-
-			_transactionDetails.needHotswap = true;
-
-			return;
-		} else {
-			if (_transactionMode != kTransactionCommit)
-				hotswapGFXMode();
-		}
-
-		// Make sure that an Common::EVENT_SCREEN_CHANGED gets sent later
-		_modeChanged = true;
+	if (_transactionMode == kTransactionActive) {
+		_videoMode.aspectRatio = enable;
+		_transactionDetails.needHotswap = true;
 	}
 }
 
@@ -763,13 +772,13 @@
 
 	Common::StackLock lock(_graphicsMutex);	// Lock the mutex until this function ends
 
-	assert(x >= 0 && x < _screenWidth);
-	assert(y >= 0 && y < _screenHeight);
-	assert(h > 0 && y + h <= _screenHeight);
-	assert(w > 0 && x + w <= _screenWidth);
+	assert(x >= 0 && x < _videoMode.screenWidth);
+	assert(y >= 0 && y < _videoMode.screenHeight);
+	assert(h > 0 && y + h <= _videoMode.screenHeight);
+	assert(w > 0 && x + w <= _videoMode.screenWidth);
 
-	if (((long)src & 3) == 0 && pitch == _screenWidth && x == 0 && y == 0 &&
-			w == _screenWidth && h == _screenHeight && _modeFlags & DF_WANT_RECT_OPTIM) {
+	if (((long)src & 3) == 0 && pitch == _videoMode.screenWidth && x == 0 && y == 0 &&
+			w == _videoMode.screenWidth && h == _videoMode.screenHeight && _modeFlags & DF_WANT_RECT_OPTIM) {
 		/* Special, optimized case for full screen updates.
 		 * It tries to determine what areas were actually changed,
 		 * and just updates those, on the actual display. */
@@ -788,12 +797,12 @@
 			y = 0;
 		}
 
-		if (w > _screenWidth - x) {
-			w = _screenWidth - x;
+		if (w > _videoMode.screenWidth - x) {
+			w = _videoMode.screenWidth - x;
 		}
 
-		if (h > _screenHeight - y) {
-			h = _screenHeight - y;
+		if (h > _videoMode.screenHeight - y) {
+			h = _videoMode.screenHeight - y;
 		}
 
 		if (w <= 0 || h <= 0)
@@ -807,15 +816,15 @@
 	if (SDL_LockSurface(_screen) == -1)
 		error("SDL_LockSurface failed: %s", SDL_GetError());
 
-	byte *dst = (byte *)_screen->pixels + y * _screenWidth + x;
+	byte *dst = (byte *)_screen->pixels + y * _videoMode.screenWidth + x;
 
-	if (_screenWidth == pitch && pitch == w) {
+	if (_videoMode.screenWidth == pitch && pitch == w) {
 		memcpy(dst, src, h*w);
 	} else {
 		do {
 			memcpy(dst, src, w);
 			src += pitch;
-			dst += _screenWidth;
+			dst += _videoMode.screenWidth;
 		} while (--h);
 	}
 
@@ -875,11 +884,11 @@
 	int height, width;
 
 	if (!_overlayVisible && !realCoordinates) {
-		width = _screenWidth;
-		height = _screenHeight;
+		width = _videoMode.screenWidth;
+		height = _videoMode.screenHeight;
 	} else {
-		width = _overlayWidth;
-		height = _overlayHeight;
+		width = _videoMode.overlayWidth;
+		height = _videoMode.overlayHeight;
 	}
 
 	// Extend the dirty region by 1 pixel for scalers
@@ -911,7 +920,7 @@
 	}
 
 #ifndef DISABLE_SCALERS
-	if (_adjustAspectRatio && !_overlayVisible && !realCoordinates) {
+	if (_videoMode.aspectRatio && !_overlayVisible && !realCoordinates) {
 		makeRectStretchable(x, y, w, h);
 	}
 #endif
@@ -936,14 +945,14 @@
 	assert(buf);
 	uint32 *sums = _dirtyChecksums;
 	uint x,y;
-	const uint last_x = (uint)_screenWidth / 8;
-	const uint last_y = (uint)_screenHeight / 8;
+	const uint last_x = (uint)_videoMode.screenWidth / 8;
+	const uint last_y = (uint)_videoMode.screenHeight / 8;
 
 	const uint BASE = 65521; /* largest prime smaller than 65536 */
 
 	/* the 8x8 blocks in buf are enumerated starting in the top left corner and
 	 * reading each line at a time from left to right */
-	for (y = 0; y != last_y; y++, buf += _screenWidth * (8 - 1))
+	for (y = 0; y != last_y; y++, buf += _videoMode.screenWidth * (8 - 1))
 		for (x = 0; x != last_x; x++, buf += 8) {
 			// Adler32 checksum algorithm (from RFC1950, used by gzip and zlib).
 			// This computes the Adler32 checksum of a 8x8 pixel block. Note
@@ -959,7 +968,7 @@
 					s1 += ptr[subX];
 					s2 += s1;
 				}
-				ptr += _screenWidth;
+				ptr += _videoMode.screenWidth;
 			}
 
 			s1 %= BASE;
@@ -989,8 +998,8 @@
 		int x, y, w;
 		uint32 *ck = _dirtyChecksums;
 
-		for (y = 0; y != _screenHeight / 8; y++) {
-			for (x = 0; x != _screenWidth / 8; x++, ck++) {
+		for (y = 0; y != _videoMode.screenHeight / 8; y++) {
+			for (x = 0; x != _videoMode.screenWidth / 8; x++, ck++) {
 				if (ck[0] != ck[_cksumNum]) {
 					/* found a dirty 8x8 block, now go as far to the right as possible,
 						 and at the same time, unmark the dirty status by setting old to new. */
@@ -998,7 +1007,7 @@
 					do {
 						ck[w + _cksumNum] = ck[w];
 						w++;
-					} while (x + w != _screenWidth / 8 && ck[w] != ck[w + _cksumNum]);
+					} while (x + w != _videoMode.screenWidth / 8 && ck[w] != ck[w + _cksumNum]);
 
 					addDirtyRect(x * 8, y * 8, w * 8, 8);
 
@@ -1015,11 +1024,11 @@
 }
 
 int16 OSystem_SDL::getHeight() {
-	return _screenHeight;
+	return _videoMode.screenHeight;
 }
 
 int16 OSystem_SDL::getWidth() {
-	return _screenWidth;
+	return _videoMode.screenWidth;
 }
 
 void OSystem_SDL::setPalette(const byte *colors, uint start, uint num) {
@@ -1105,11 +1114,11 @@
 
 	// Since resolution could change, put mouse to adjusted position
 	// Fixes bug #1349059
-	x = _mouseCurState.x * _scaleFactor;
-	if (_adjustAspectRatio)
-		y = real2Aspect(_mouseCurState.y) * _scaleFactor;
+	x = _mouseCurState.x * _videoMode.scaleFactor;
+	if (_videoMode.aspectRatio)
+		y = real2Aspect(_mouseCurState.y) * _videoMode.scaleFactor;
 	else
-		y = _mouseCurState.y * _scaleFactor;
+		y = _mouseCurState.y * _videoMode.scaleFactor;
 
 	warpMouse(x, y);
 
@@ -1128,9 +1137,9 @@
 
 	// Since resolution could change, put mouse to adjusted position
 	// Fixes bug #1349059
-	x = _mouseCurState.x / _scaleFactor;
-	y = _mouseCurState.y / _scaleFactor;
-	if (_adjustAspectRatio)
+	x = _mouseCurState.x / _videoMode.scaleFactor;
+	y = _mouseCurState.y / _videoMode.scaleFactor;
+	if (_videoMode.aspectRatio)
 		y = aspect2Real(y);
 
 	warpMouse(x, y);
@@ -1152,20 +1161,20 @@
 	SDL_Rect src, dst;
 	src.x = src.y = 0;
 	dst.x = dst.y = 1;
-	src.w = dst.w = _screenWidth;
-	src.h = dst.h = _screenHeight;
+	src.w = dst.w = _videoMode.screenWidth;
+	src.h = dst.h = _videoMode.screenHeight;
 	if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0)
 		error("SDL_BlitSurface failed: %s", SDL_GetError());
 
 	SDL_LockSurface(_tmpscreen);
 	SDL_LockSurface(_overlayscreen);
 	_scalerProc((byte *)(_tmpscreen->pixels) + _tmpscreen->pitch + 2, _tmpscreen->pitch,
-	(byte *)_overlayscreen->pixels, _overlayscreen->pitch, _screenWidth, _screenHeight);
+	(byte *)_overlayscreen->pixels, _overlayscreen->pitch, _videoMode.screenWidth, _videoMode.screenHeight);
 
 #ifndef DISABLE_SCALERS
-	if (_adjustAspectRatio)
+	if (_videoMode.aspectRatio)
 		stretch200To240((uint8 *)_overlayscreen->pixels, _overlayscreen->pitch,
-						_overlayWidth, _screenHeight * _scaleFactor, 0, 0, 0);
+						_videoMode.overlayWidth, _videoMode.screenHeight * _videoMode.scaleFactor, 0, 0, 0);
 #endif
 	SDL_UnlockSurface(_tmpscreen);
 	SDL_UnlockSurface(_overlayscreen);
@@ -1183,9 +1192,9 @@
 		error("SDL_LockSurface failed: %s", SDL_GetError());
 
 	byte *src = (byte *)_overlayscreen->pixels;
-	int h = _overlayHeight;
+	int h = _videoMode.overlayHeight;
 	do {
-		memcpy(buf, src, _overlayWidth * 2);
+		memcpy(buf, src, _videoMode.overlayWidth * 2);
 		src += _overlayscreen->pitch;
 		buf += pitch;
 	} while (--h);
@@ -1211,12 +1220,12 @@
 		y = 0;
 	}
 
-	if (w > _overlayWidth - x) {
-		w = _overlayWidth - x;
+	if (w > _videoMode.overlayWidth - x) {
+		w = _videoMode.overlayWidth - x;
 	}
 
-	if (h > _overlayHeight - y) {
-		h = _overlayHeight - y;
+	if (h > _videoMode.overlayHeight - y) {
+		h = _videoMode.overlayHeight - y;
 	}
 
 	if (w <= 0 || h <= 0)
@@ -1264,12 +1273,12 @@
 void OSystem_SDL::warpMouse(int x, int y) {
 	int y1 = y;
 
-	if (_adjustAspectRatio && !_overlayVisible)
+	if (_videoMode.aspectRatio && !_overlayVisible)
 		y1 = real2Aspect(y);
 
 	if (_mouseCurState.x != x || _mouseCurState.y != y) {
 		if (!_overlayVisible)
-			SDL_WarpMouse(x * _scaleFactor, y1 * _scaleFactor);
+			SDL_WarpMouse(x * _videoMode.scaleFactor, y1 * _videoMode.scaleFactor);
 		else
 			SDL_WarpMouse(x, y1);
 
@@ -1372,7 +1381,7 @@
 
 	int rW, rH;
 
-	if (_cursorTargetScale >= _scaleFactor) {
+	if (_cursorTargetScale >= _videoMode.scaleFactor) {
 		// The cursor target scale is greater or equal to the scale at
 		// which the rest of the screen is drawn. We do not downscale
 		// the cursor image, we draw it at its original size. It will
@@ -1385,22 +1394,22 @@
 
 		// The virtual dimensions may be larger than the original.
 
-		_mouseCurState.vW = w * _cursorTargetScale / _scaleFactor;
-		_mouseCurState.vH = h * _cursorTargetScale / _scaleFactor;
+		_mouseCurState.vW = w * _cursorTargetScale / _videoMode.scaleFactor;
+		_mouseCurState.vH = h * _cursorTargetScale / _videoMode.scaleFactor;
 		_mouseCurState.vHotX = _mouseCurState.hotX * _cursorTargetScale /
-			_scaleFactor;
+			_videoMode.scaleFactor;
 		_mouseCurState.vHotY = _mouseCurState.hotY * _cursorTargetScale /
-			_scaleFactor;
+			_videoMode.scaleFactor;
 	} else {
 		// The cursor target scale is smaller than the scale at which
 		// the rest of the screen is drawn. We scale up the cursor
 		// image to make it appear correct.
 
-		rW = w * _scaleFactor / _cursorTargetScale;
-		rH = h * _scaleFactor / _cursorTargetScale;
-		_mouseCurState.rHotX = _mouseCurState.hotX * _scaleFactor /
+		rW = w * _videoMode.scaleFactor / _cursorTargetScale;
+		rH = h * _videoMode.scaleFactor / _cursorTargetScale;
+		_mouseCurState.rHotX = _mouseCurState.hotX * _videoMode.scaleFactor /
 			_cursorTargetScale;
-		_mouseCurState.rHotY = _mouseCurState.hotY * _scaleFactor /
+		_mouseCurState.rHotY = _mouseCurState.hotY * _videoMode.scaleFactor /
 			_cursorTargetScale;
 
 		// The virtual dimensions will be the same as the original.
@@ -1415,7 +1424,7 @@
 	int rH1 = rH; // store original to pass to aspect-correction function later
 #endif
 
-	if (_adjustAspectRatio && _cursorTargetScale == 1) {
+	if (_videoMode.aspectRatio && _cursorTargetScale == 1) {
 		rH = real2Aspect(rH - 1) + 1;
 		_mouseCurState.rHotY = real2Aspect(_mouseCurState.rHotY);
 	}
@@ -1450,17 +1459,17 @@
 	// the game. This only works well with the non-blurring scalers so we
 	// actually only use the 1x, 1.5x, 2x and AdvMame scalers.
 
-	if (_cursorTargetScale == 1 && (_mode == GFX_DOUBLESIZE || _mode == GFX_TRIPLESIZE))
+	if (_cursorTargetScale == 1 && (_videoMode.mode == GFX_DOUBLESIZE || _videoMode.mode == GFX_TRIPLESIZE))
 		scalerProc = _scalerProc;
 	else
-		scalerProc = scalersMagn[_cursorTargetScale - 1][_scaleFactor - 1];
+		scalerProc = scalersMagn[_cursorTargetScale - 1][_videoMode.scaleFactor - 1];
 
 	scalerProc((byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch + 2,
 		_mouseOrigSurface->pitch, (byte *)_mouseSurface->pixels, _mouseSurface->pitch,
 		_mouseCurState.w, _mouseCurState.h);
 
 #ifndef DISABLE_SCALERS
-	if (_adjustAspectRatio && _cursorTargetScale == 1)
+	if (_videoMode.aspectRatio && _cursorTargetScale == 1)
 		cursorStretch200To240((uint8 *)_mouseSurface->pixels, _mouseSurface->pitch, rW, rH1, 0, 0, 0);
 #endif
 
@@ -1503,7 +1512,7 @@
 
 	// When we switch bigger overlay off mouse jumps. Argh!
 	// This is intended to prevent undrawing offscreen mouse
-	if (!_overlayVisible && (x >= _screenWidth || y >= _screenHeight)) {
+	if (!_overlayVisible && (x >= _videoMode.screenWidth || y >= _videoMode.screenHeight)) {
 		return;
 	}
 
@@ -1526,17 +1535,17 @@
 	dst.y = _mouseCurState.y;
 
 	if (!_overlayVisible) {
-		scale = _scaleFactor;
-		width = _screenWidth;
-		height = _screenHeight;
+		scale = _videoMode.scaleFactor;
+		width = _videoMode.screenWidth;
+		height = _videoMode.screenHeight;
 		dst.w = _mouseCurState.vW;
 		dst.h = _mouseCurState.vH;
 		hotX = _mouseCurState.vHotX;
 		hotY = _mouseCurState.vHotY;
 	} else {
 		scale = 1;
-		width = _overlayWidth;
-		height = _overlayHeight;
+		width = _videoMode.overlayWidth;
+		height = _videoMode.overlayHeight;
 		dst.w = _mouseCurState.rW;
 		dst.h = _mouseCurState.rH;
 		hotX = _mouseCurState.rHotX;
@@ -1558,7 +1567,7 @@
 		dst.y += _currentShakePos;
 	}
 
-	if (_adjustAspectRatio && !_overlayVisible)
+	if (_videoMode.aspectRatio && !_overlayVisible)
 		dst.y = real2Aspect(dst.y);
 
 	dst.x = scale * dst.x - _mouseCurState.rHotX;
@@ -1674,17 +1683,19 @@
 void OSystem_SDL::handleScalerHotkeys(const SDL_KeyboardEvent &key) {
 	// Ctrl-Alt-a toggles aspect ratio correction
 	if (key.keysym.sym == 'a') {
-		setFeatureState(kFeatureAspectRatioCorrection, !_adjustAspectRatio);
+		beginGFXTransaction();
+			setFeatureState(kFeatureAspectRatioCorrection, !_videoMode.aspectRatio);
+		endGFXTransaction();
 #ifdef USE_OSD
 		char buffer[128];
-		if (_adjustAspectRatio)
+		if (_videoMode.aspectRatio)
 			sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d",
-				_screenWidth, _screenHeight,
+				_videoMode.screenWidth, _videoMode.screenHeight,
 				_hwscreen->w, _hwscreen->h
 				);
 		else
 			sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d",
-				_screenWidth, _screenHeight,
+				_videoMode.screenWidth, _videoMode.screenHeight,
 				_hwscreen->w, _hwscreen->h
 				);
 		displayMessageOnOSD(buffer);
@@ -1694,7 +1705,7 @@
 	}
 
 	int newMode = -1;
-	int factor = _scaleFactor - 1;
+	int factor = _videoMode.scaleFactor - 1;
 
 	// Increase/decrease the scale factor
 	if (key.keysym.sym == SDLK_EQUALS || key.keysym.sym == SDLK_PLUS || key.keysym.sym == SDLK_MINUS ||
@@ -1720,13 +1731,15 @@
 	}
 
 	if (newMode >= 0) {
-		setGraphicsMode(newMode);
+		beginGFXTransaction();
+			setGraphicsMode(newMode);
+		endGFXTransaction();
 #ifdef USE_OSD
 		if (_osdSurface) {
 			const char *newScalerName = 0;
 			const GraphicsMode *g = getSupportedGraphicsModes();
 			while (g->name) {
-				if (g->id == _mode) {
+				if (g->id == _videoMode.mode) {
 					newScalerName = g->description;
 					break;
 				}
@@ -1736,7 +1749,7 @@
 				char buffer[128];
 				sprintf(buffer, "Active graphics filter: %s\n%d x %d -> %d x %d",
 					newScalerName,
-					_screenWidth, _screenHeight,
+					_videoMode.screenWidth, _videoMode.screenHeight,
 					_hwscreen->w, _hwscreen->h
 					);
 				displayMessageOnOSD(buffer);

Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -116,25 +116,28 @@
 	// Enable unicode support if possible
 	SDL_EnableUNICODE(1);
 
+	_oldVideoMode.setup = false;
+	_videoMode.setup = false;
+
 	_cksumValid = false;
 #if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) && !defined(DISABLE_SCALERS)
-	_mode = GFX_DOUBLESIZE;
-	_scaleFactor = 2;
+	_videoMode.mode = GFX_DOUBLESIZE;
+	_videoMode.scaleFactor = 2;
+	_videoMode.aspectRatio = ConfMan.getBool("aspect_ratio");
 	_scalerProc = Normal2x;
-	_adjustAspectRatio = ConfMan.getBool("aspect_ratio");
 #else // for small screen platforms
-	_mode = GFX_NORMAL;
-	_scaleFactor = 1;
+	_videoMode.mode = GFX_NORMAL;
+	_videoMode.scaleFactor = 1;
+	_videoMode.aspectRatio = false;
 	_scalerProc = Normal1x;
-	_adjustAspectRatio = false;
 #endif
 	_scalerType = 0;
 	_modeFlags = 0;
 
 #if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
-	_fullscreen = ConfMan.getBool("fullscreen");
+	_videoMode.fullscreen = ConfMan.getBool("fullscreen");
 #else
-	_fullscreen = true;
+	_videoMode.fullscreen = true;
 #endif
 
 #if !defined(MACOSX) && !defined(__SYMBIAN32__)
@@ -192,8 +195,7 @@
 #ifdef USE_OSD
 	_osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),
 #endif
-	_hwscreen(0), _screen(0), _screenWidth(0), _screenHeight(0),
-	_tmpscreen(0), _overlayWidth(0), _overlayHeight(0),
+	_hwscreen(0), _screen(0), _tmpscreen(0),
 	_overlayVisible(false),
 	_overlayscreen(0), _tmpscreen2(0),
 	_samplesPerSec(0),
@@ -429,9 +431,9 @@
 
 	switch (f) {
 	case kFeatureFullscreenMode:
-		return _fullscreen;
+		return _videoMode.fullscreen;
 	case kFeatureAspectRatioCorrection:
-		return _adjustAspectRatio;
+		return _videoMode.aspectRatio;
 	case kFeatureAutoComputeDirtyRects:
 		return _modeFlags & DF_WANT_RECT_OPTIM;
 	default:

Modified: scummvm/trunk/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.h	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/backends/platform/sdl/sdl.h	2008-11-14 22:08:10 UTC (rev 35062)
@@ -80,7 +80,7 @@
 	virtual void initBackend();
 
 	void beginGFXTransaction(void);
-	void endGFXTransaction(void);
+	TransactionError endGFXTransaction(void);
 
 	// Set the size of the video bitmap.
 	// Typically, 320x200
@@ -179,8 +179,8 @@
 	virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
 	virtual int16 getHeight();
 	virtual int16 getWidth();
-	virtual int16 getOverlayHeight()  { return _overlayHeight; }
-	virtual int16 getOverlayWidth()   { return _overlayWidth; }
+	virtual int16 getOverlayHeight()  { return _videoMode.overlayHeight; }
+	virtual int16 getOverlayWidth()   { return _videoMode.overlayWidth; }
 
 	virtual const GraphicsMode *getSupportedGraphicsModes() const;
 	virtual int getDefaultGraphicsMode() const;
@@ -226,16 +226,12 @@
 	// unseen game screen
 	SDL_Surface *_screen;
 
-	// TODO: We could get rid of the following two vars and just use _screen instead
-	int _screenWidth, _screenHeight;
-
 	// temporary screen (for scalers)
 	SDL_Surface *_tmpscreen;
 	SDL_Surface *_tmpscreen2;
 
 	// overlay
 	SDL_Surface *_overlayscreen;
-	int _overlayWidth, _overlayHeight;
 	bool _overlayVisible;
 	Graphics::PixelFormat _overlayFormat;
 
@@ -253,36 +249,39 @@
 
 	enum {
 		kTransactionNone = 0,
-		kTransactionCommit = 1,
-		kTransactionActive = 2
+		kTransactionActive = 1,
+		kTransactionRollback = 2
 	};
 
 	struct TransactionDetails {
-		int mode;
-		bool modeChanged;
-		int w;
-		int h;
 		bool sizeChanged;
-		bool fs;
-		bool fsChanged;
-		bool ar;
-		bool arChanged;
 		bool needHotswap;
 		bool needUpdatescreen;
-		bool needUnload;
-		bool needToggle;
 		bool normal1xScaler;
 	};
 	TransactionDetails _transactionDetails;
 
+	struct VideoState {
+		bool setup;
+
+		bool fullscreen;
+		bool aspectRatio;
+
+		int mode;
+		int scaleFactor;
+
+		int screenWidth, screenHeight;
+		int overlayWidth, overlayHeight;
+	};
+	VideoState _videoMode, _oldVideoMode;
+
+	void setGraphicsModeIntern();
+
 	/** Force full redraw on next updateScreen */
 	bool _forceFull;
 	ScalerProc *_scalerProc;
 	int _scalerType;
-	int _scaleFactor;
-	int _mode;
 	int _transactionMode;
-	bool _fullscreen;
 
 	bool _screenIsLocked;
 	Graphics::Surface _framebuffer;
@@ -292,9 +291,6 @@
 	bool _modeChanged;
 	int _screenChangeCount;
 
-	/** True if aspect ratio correction is enabled. */
-	bool _adjustAspectRatio;
-
 	enum {
 		NUM_DIRTY_RECT = 100,
 		MAX_SCALING = 3
@@ -417,9 +413,9 @@
 
 	virtual void internUpdateScreen(); // overloaded by CE backend
 
-	virtual void loadGFXMode(); // overloaded by CE backend
+	virtual bool loadGFXMode(); // overloaded by CE backend
 	virtual void unloadGFXMode(); // overloaded by CE backend
-	virtual void hotswapGFXMode(); // overloaded by CE backend
+	virtual bool hotswapGFXMode(); // overloaded by CE backend
 
 	void setFullscreenMode(bool enable);
 	void setAspectRatioCorrection(bool enable);
@@ -427,8 +423,8 @@
 	virtual bool saveScreenshot(const char *filename); // overloaded by CE backend
 
 	int effectiveScreenHeight() const {
-		return (_adjustAspectRatio ? real2Aspect(_screenHeight) : _screenHeight)
-			* _scaleFactor;
+		return (_videoMode.aspectRatio ? real2Aspect(_videoMode.screenHeight) : _videoMode.screenHeight)
+			* _videoMode.scaleFactor;
 	}
 
 	void setupIcon();

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/base/main.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -67,7 +67,8 @@
 			system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
 		if (ConfMan.hasKey("fullscreen"))
 			system.setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
-	system.endGFXTransaction();
+	if (system.endGFXTransaction() != OSystem::kTransactionSuccess)
+		error("Could not switch to graphics mode: 320x200 ('%s')", ConfMan.get("gfx_mode").c_str());
 
 	// When starting up launcher for the first time, the user might have specified
 	// a --gui-theme option, to allow that option to be working, we need to initialize

Modified: scummvm/trunk/common/system.h
===================================================================
--- scummvm/trunk/common/system.h	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/common/system.h	2008-11-14 22:08:10 UTC (rev 35062)
@@ -393,12 +393,30 @@
 	 */
 	virtual void beginGFXTransaction() {}
 
+	/**
+	 * This type is able to save the different errors which can happen while
+	 * changing GFX config values inside GFX transactions.
+	 *
+	 * endGFXTransaction returns a ORed combination of the '*Failed' values
+	 * if any problem occures, on success 0.
+	 *
+	 * @see endGFXTransaction
+	 */
+	enum TransactionError {
+		kTransactionSuccess = 0, 					/**< Everything fine (use EQUAL check for this one!) */
+		kTransactionAspectRatioFailed = (1 << 0),	/**< Failed switchting aspect ratio correction mode */
+		kTransactionFullscreenFailed = (1 << 1),	/**< Failed switchting fullscreen mode */
+		kTransactionModeSwitchFailed = (1 << 2),	/**< Failed switchting the GFX graphics mode (setGraphicsMode) */
+		kTransactionSizeChangeFailed = (1 << 3)		/**< Failed switchting the screen dimensions (initSize) */
+	};
 
 	/**
 	 * End (and thereby commit) the current GFX transaction.
 	 * @see beginGFXTransaction
+	 * @see kTransactionError
+	 * @return returns a ORed combination of TransactionError values or 0 on success
 	 */
-	virtual void endGFXTransaction() {}
+	virtual TransactionError endGFXTransaction() { return kTransactionSuccess; }
 
 
 	/**

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/agi/agi.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -782,10 +782,7 @@
 Common::Error AgiBase::init() {
 
 	// Initialize backend
-	_system->beginGFXTransaction();
-	initCommonGFX(false);
-	_system->initSize(320, 200);
-	_system->endGFXTransaction();
+	initGraphics(320, 200, false);
 
 	initialize();
 

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/agos/agos.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -540,10 +540,7 @@
 		_screenHeight = 200;
 	}
 
-	_system->beginGFXTransaction();
-		initCommonGFX(getGameType() == GType_FF || getGameType() == GType_PP);
-		_system->initSize(_screenWidth, _screenHeight);
-	_system->endGFXTransaction();
+	initGraphics(_screenWidth, _screenHeight, getGameType() == GType_FF || getGameType() == GType_PP);
 
 	// Setup mixer
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));

Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/cine/cine.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -76,10 +76,7 @@
 
 Common::Error CineEngine::init() {
 	// Initialize backend
-	_system->beginGFXTransaction();
-	initCommonGFX(false);
-	_system->initSize(320, 200);
-	_system->endGFXTransaction();
+	initGraphics(320, 200, false);
 
 	if (g_cine->getPlatform() == Common::kPlatformPC) {
 		g_sound = new PCSound(_mixer, this);

Modified: scummvm/trunk/engines/cruise/cruise.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/cruise/cruise.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -72,10 +72,7 @@
 
 Common::Error CruiseEngine::init() {
 	// Initialize backend
-	_system->beginGFXTransaction();
-	initCommonGFX(false);
-	_system->initSize(320, 200);
-	_system->endGFXTransaction();
+	initGraphics(320, 200, false);
 
 	initialize();
 

Modified: scummvm/trunk/engines/drascula/drascula.cpp
===================================================================
--- scummvm/trunk/engines/drascula/drascula.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/drascula/drascula.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -106,10 +106,7 @@
 
 Common::Error DrasculaEngine::init() {
 	// Initialize backend
-	_system->beginGFXTransaction();
-	initCommonGFX(false);
-	_system->initSize(320, 200);
-	_system->endGFXTransaction();
+	initGraphics(320, 200, false);
 
 	switch (getLanguage()) {
 	case Common::EN_ANY:

Modified: scummvm/trunk/engines/engine.cpp
===================================================================
--- scummvm/trunk/engines/engine.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/engine.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -125,15 +125,62 @@
 		g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
 }
 
+void initGraphics(int width, int height, bool defaultTo1xScaler) {
+	g_system->beginGFXTransaction();
+
+		initCommonGFX(defaultTo1xScaler);
+		g_system->initSize(width, height);
+
+	OSystem::TransactionError gfxError = g_system->endGFXTransaction();
+
+	if (gfxError == OSystem::kTransactionSuccess)
+		return;
+
+	// Error out on size switch failure
+	if (gfxError & OSystem::kTransactionSizeChangeFailed) {
+		char buffer[16];
+		snprintf(buffer, 16, "%dx%d", width, height);
+
+		Common::String message = "Could not switch to resolution: '";
+		message += buffer;
+		message += "'.";
+
+		GUIErrorMessage(message);
+		error(message.c_str());
+	}
+
+	// Just show warnings then these occur:
+	if (gfxError & OSystem::kTransactionModeSwitchFailed) {
+		Common::String message = "Could not switch to video mode: '";
+		message += ConfMan.get("gfx_mode");
+		message += "'.";
+
+		GUI::MessageDialog dialog(message);
+		dialog.runModal();		
+	}
+	
+	if (gfxError & OSystem::kTransactionAspectRatioFailed) {
+		GUI::MessageDialog dialog("Could not apply aspect ratio setting.");
+		dialog.runModal();
+	}
+
+	if (gfxError & OSystem::kTransactionFullscreenFailed) {
+		GUI::MessageDialog dialog("Could not apply fullscreen setting.");
+		dialog.runModal();
+	}
+}
+
 void GUIErrorMessage(const Common::String msg) {
 	g_system->setWindowCaption("Error");
 	g_system->beginGFXTransaction();
 		initCommonGFX(false);
 		g_system->initSize(320, 200);
-	g_system->endGFXTransaction();
-
-	GUI::MessageDialog dialog(msg);
-	dialog.runModal();
+	if (g_system->endGFXTransaction() == OSystem::kTransactionSuccess) {
+		GUI::MessageDialog dialog(msg);
+		dialog.runModal();
+	} else {
+		error(msg.c_str());
+	}
 }
 
 void Engine::checkCD() {

Modified: scummvm/trunk/engines/engine.h
===================================================================
--- scummvm/trunk/engines/engine.h	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/engine.h	2008-11-14 22:08:10 UTC (rev 35062)
@@ -51,8 +51,19 @@
 void initCommonGFX(bool defaultTo1XScaler);
 
 /**
- * Initialized graphics and shows error message.
+ * Setup the backend's screen size and graphics mode.
+ *
+ * Shows an various warnings on certain backend graphics
+ * transaction failures (aspect switch, fullscreen switch, etc.).
+ *
+ * Errors out when backend is not able to switch to the specified
+ * mode.
  */
+void initGraphics(int width, int height, bool defaultTo1xScaler);
+
+/**
+ * Initializes graphics and shows error message.
+ */
 void GUIErrorMessage(const Common::String msg);
 
 

Modified: scummvm/trunk/engines/gob/video.cpp
===================================================================
--- scummvm/trunk/engines/gob/video.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/gob/video.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -169,10 +169,7 @@
 }
 
 void Video::setSize(bool defaultTo1XScaler) {
-	_vm->_system->beginGFXTransaction();
-		_vm->_system->initSize(_vm->_width, _vm->_height);
-		initCommonGFX(defaultTo1XScaler);
-	_vm->_system->endGFXTransaction();
+	initGraphics(_vm->_width, _vm->_height, defaultTo1XScaler);
 }
 
 void Video::retrace(bool mouse) {

Modified: scummvm/trunk/engines/groovie/groovie.cpp
===================================================================
--- scummvm/trunk/engines/groovie/groovie.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/groovie/groovie.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -66,10 +66,7 @@
 
 Common::Error GroovieEngine::init() {
 	// Initialize the graphics
-	_system->beginGFXTransaction();
-	initCommonGFX(true);
-	_system->initSize(640, 480);
-	_system->endGFXTransaction();
+	initGraphics(640, 480, true);
 
 	// Create debugger. It requires GFX to be initialized
 	_debugger = new Debugger(this);

Modified: scummvm/trunk/engines/igor/igor.cpp
===================================================================
--- scummvm/trunk/engines/igor/igor.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/igor/igor.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -89,10 +89,7 @@
 }
 
 Common::Error IgorEngine::init() {
-	_system->beginGFXTransaction();
-		initCommonGFX(false);
-		_system->initSize(320, 200);
-	_system->endGFXTransaction();
+	initGraphics(320, 200, false);
 
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
 	return Common::kNoError;

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/kyra/screen.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -186,24 +186,26 @@
 	byte palette[4*256];
 	_system->grabPalette(palette, 0, 256);
 
+	int width = 320, height = 200;
+	bool defaultTo1xScaler = false;
+
 	if (_vm->gameFlags().useHiResOverlay) {
-		_system->beginGFXTransaction();
-			if (_debugEnabled)
-				_system->initSize(960, 400);
-			else
-				_system->initSize(640, 400);
-			initCommonGFX(true);
-		_system->endGFXTransaction();
+		defaultTo1xScaler = true;
+		height = 400;
+
+		if (_debugEnabled)
+			width = 960;
+		else
+			width = 640;
 	} else {
-		_system->beginGFXTransaction();
-			if (_debugEnabled)
-				_system->initSize(640, 200);
-			else
-				_system->initSize(320, 200);
-			initCommonGFX(false);
-		_system->endGFXTransaction();
+		if (_debugEnabled)
+			width = 640;
+		else
+			width = 320;
 	}
 
+	initGraphics(width, height, defaultTo1xScaler);
+
 	_system->setPalette(palette, 0, 256);
 }
 

Modified: scummvm/trunk/engines/lure/lure.cpp
===================================================================
--- scummvm/trunk/engines/lure/lure.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/lure/lure.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -52,10 +52,7 @@
 	int_engine = this;
 	_initialised = false;
 
-	_system->beginGFXTransaction();
-	initCommonGFX(false);
-	_system->initSize(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
-	_system->endGFXTransaction();
+	initGraphics(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT, false);
 
 	// Check the version of the lure.dat file
 	Common::File f;

Modified: scummvm/trunk/engines/m4/m4.cpp
===================================================================
--- scummvm/trunk/engines/m4/m4.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/m4/m4.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -143,13 +143,10 @@
 
 Common::Error M4Engine::init() {
 	// Initialize backend
-	_system->beginGFXTransaction();
-	initCommonGFX(isM4());
 	if (isM4())
-		_system->initSize(640, 480);
+		initGraphics(640, 480, true);
 	else
-		_system->initSize(320, 200);
-	_system->endGFXTransaction();
+		initGraphics(320, 200, false);
 
 	_screen = new M4Surface(true); // Special form for creating screen reference
 

Modified: scummvm/trunk/engines/made/made.cpp
===================================================================
--- scummvm/trunk/engines/made/made.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/made/made.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -130,10 +130,7 @@
 
 Common::Error MadeEngine::init() {
 	// Initialize backend
-	_system->beginGFXTransaction();
-	initCommonGFX(false);
-	_system->initSize(320, 200);
-	_system->endGFXTransaction();
+	initGraphics(320, 200, false);
 
 	return Common::kNoError;
 }

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -749,10 +749,7 @@
 Gfx::Gfx(Parallaction* vm) :
 	_vm(vm), _disk(vm->_disk) {
 
-	_vm->_system->beginGFXTransaction();
-		_vm->_system->initSize(_vm->_screenWidth, _vm->_screenHeight);
-		initCommonGFX(_vm->getGameType() == GType_BRA);
-	_vm->_system->endGFXTransaction();
+	initGraphics(_vm->_screenWidth, _vm->_screenHeight, _vm->getGameType() == GType_BRA);
 
 	setPalette(_palette);
 

Modified: scummvm/trunk/engines/queen/queen.cpp
===================================================================
--- scummvm/trunk/engines/queen/queen.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/queen/queen.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -473,10 +473,7 @@
 }
 
 Common::Error QueenEngine::init() {
-	_system->beginGFXTransaction();
-		initCommonGFX(false);
-		_system->initSize(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
-	_system->endGFXTransaction();
+	initGraphics(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT, false);
 
 	_resource = new Resource();
 

Modified: scummvm/trunk/engines/saga/gfx.cpp
===================================================================
--- scummvm/trunk/engines/saga/gfx.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/saga/gfx.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -40,10 +40,7 @@
 #define RID_IHNM_HOURGLASS_CURSOR 11 // not in demo
 
 Gfx::Gfx(SagaEngine *vm, OSystem *system, int width, int height) : _vm(vm), _system(system) {
-	_system->beginGFXTransaction();
-		initCommonGFX(width > 320);
-		_system->initSize(width, height);
-	_system->endGFXTransaction();
+	initGraphics(width, height, width > 320);
 
 	debug(5, "Init screen %dx%d", width, height);
 	// Convert surface data to R surface data

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -822,10 +822,7 @@
 }
 
 Common::Error ScummEngine_vCUPhe::init() {
-	_system->beginGFXTransaction();
-		_system->initSize(CUP_Player::kDefaultVideoWidth, CUP_Player::kDefaultVideoHeight);
-		initCommonGFX(true);
-	_system->endGFXTransaction();
+	initGraphics(CUP_Player::kDefaultVideoWidth, CUP_Player::kDefaultVideoHeight, true);
 
 	return Common::kNoError;
 }
@@ -1069,24 +1066,17 @@
 	loadCJKFont();
 
 	// Initialize backend
-	_system->beginGFXTransaction();
-		bool defaultTo1XScaler = false;
-		if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
-			_system->initSize(Common::kHercW, Common::kHercH);
-			defaultTo1XScaler = true;
-		} else if (_useCJKMode) {
-			_system->initSize(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier);
+	if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
+		initGraphics(Common::kHercW, Common::kHercH, true);
+	} else if (_useCJKMode) {
+		initGraphics(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier,
+					// CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so
+					// there is no text surface for them. This takes that into account
+					(_screenWidth * _textSurfaceMultiplier > 320));
+	} else {
+		initGraphics(_screenWidth, _screenHeight, _screenWidth > 320);
+	}
 
-			// CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so
-			// there is no text surface for them. This takes that into account
-			defaultTo1XScaler = (_screenWidth * _textSurfaceMultiplier > 320);
-		} else {
-			_system->initSize(_screenWidth, _screenHeight);
-			defaultTo1XScaler = (_screenWidth > 320);
-		}
-		initCommonGFX(defaultTo1XScaler);
-	_system->endGFXTransaction();
-
 	setupScumm();
 
 	readIndexFile();

Modified: scummvm/trunk/engines/sky/sky.cpp
===================================================================
--- scummvm/trunk/engines/sky/sky.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/sky/sky.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -238,10 +238,7 @@
 }
 
 Common::Error SkyEngine::init() {
-	_system->beginGFXTransaction();
-		initCommonGFX(false);
-		_system->initSize(320, 200);
-	_system->endGFXTransaction();
+	initGraphics(320, 200, false);
 
 	if (ConfMan.getBool("sfx_mute")) {
 		SkyEngine::_systemVars.systemFlags |= SF_FX_OFF;

Modified: scummvm/trunk/engines/sword1/sword1.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sword1.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/sword1/sword1.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -78,10 +78,7 @@
 
 Common::Error SwordEngine::init() {
 
-	_system->beginGFXTransaction();
-		initCommonGFX(true);
-		_system->initSize(640, 480);
-	_system->endGFXTransaction();
+	initGraphics(640, 480, true);
 
 	if ( 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1mac") ||
 	     0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1macdemo") )

Modified: scummvm/trunk/engines/sword2/screen.cpp
===================================================================
--- scummvm/trunk/engines/sword2/screen.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/sword2/screen.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -52,8 +52,6 @@
 
 	_dirtyGrid = _buffer = NULL;
 
-	_vm->_system->initSize(width, height);
-
 	_screenWide = width;
 	_screenDeep = height;
 

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -371,10 +371,8 @@
 	_resman = NULL;
 	_memory = NULL;
 
-	_system->beginGFXTransaction();
-		initCommonGFX(true);
-		_screen = new Screen(this, 640, 480);
-	_system->endGFXTransaction();
+	initGraphics(640, 480, true);
+	_screen = new Screen(this, 640, 480);
 
 	// Create the debugger as early as possible (but not before the
 	// screen object!) so that errors can be displayed in it. In

Modified: scummvm/trunk/engines/tinsel/tinsel.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/tinsel.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/tinsel/tinsel.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -660,10 +660,7 @@
 
 Common::Error TinselEngine::init() {
 	// Initialize backend
-	_system->beginGFXTransaction();
-		initCommonGFX(false);
-		_system->initSize(SCREEN_WIDTH, SCREEN_HEIGHT);
-	_system->endGFXTransaction();
+	initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT, false);
 
 	_screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT, 1);
 

Modified: scummvm/trunk/engines/touche/touche.cpp
===================================================================
--- scummvm/trunk/engines/touche/touche.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/touche/touche.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -82,10 +82,7 @@
 }
 
 Common::Error ToucheEngine::init() {
-	_system->beginGFXTransaction();
-		initCommonGFX(true);
-		_system->initSize(kScreenWidth, kScreenHeight);
-	_system->endGFXTransaction();
+	initGraphics(kScreenWidth, kScreenHeight, true);
 
 	Graphics::setupFont(_language);
 

Modified: scummvm/trunk/engines/tucker/tucker.cpp
===================================================================
--- scummvm/trunk/engines/tucker/tucker.cpp	2008-11-14 21:55:03 UTC (rev 35061)
+++ scummvm/trunk/engines/tucker/tucker.cpp	2008-11-14 22:08:10 UTC (rev 35062)
@@ -42,10 +42,7 @@
 }
 
 Common::Error TuckerEngine::init() {
-	_system->beginGFXTransaction();
-		initCommonGFX(false);
-		_system->initSize(320, 200);
-	_system->endGFXTransaction();
+	initGraphics(320, 200, false);
 
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));


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