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

svn-id: r35062
This commit is contained in:
Johannes Schickel 2008-11-14 22:08:10 +00:00
parent bb87d39424
commit 5a0556f09c
31 changed files with 461 additions and 442 deletions

View file

@ -77,9 +77,9 @@ void OSystem_SDL::fillMouseEvent(Common::Event &event, int x, int y) {
// Adjust for the screen scaling // Adjust for the screen scaling
if (!_overlayVisible) { if (!_overlayVisible) {
event.mouse.x /= _scaleFactor; event.mouse.x /= _videoMode.scaleFactor;
event.mouse.y /= _scaleFactor; event.mouse.y /= _videoMode.scaleFactor;
if (_adjustAspectRatio) if (_videoMode.aspectRatio)
event.mouse.y = aspect2Real(event.mouse.y); event.mouse.y = aspect2Real(event.mouse.y);
} }
} }
@ -196,10 +196,10 @@ bool OSystem_SDL::pollEvent(Common::Event &event) {
if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN if (b == Common::KBD_ALT && (ev.key.keysym.sym == SDLK_RETURN
|| ev.key.keysym.sym == SDLK_KP_ENTER)) { || ev.key.keysym.sym == SDLK_KP_ENTER)) {
beginGFXTransaction(); beginGFXTransaction();
setFullscreenMode(!_fullscreen); setFullscreenMode(!_videoMode.fullscreen);
endGFXTransaction(); endGFXTransaction();
#ifdef USE_OSD #ifdef USE_OSD
if (_fullscreen) if (_videoMode.fullscreen)
displayMessageOnOSD("Fullscreen mode"); displayMessageOnOSD("Fullscreen mode");
else else
displayMessageOnOSD("Windowed mode"); displayMessageOnOSD("Windowed mode");

File diff suppressed because it is too large Load diff

View file

@ -116,25 +116,28 @@ void OSystem_SDL::initBackend() {
// Enable unicode support if possible // Enable unicode support if possible
SDL_EnableUNICODE(1); SDL_EnableUNICODE(1);
_oldVideoMode.setup = false;
_videoMode.setup = false;
_cksumValid = false; _cksumValid = false;
#if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) && !defined(DISABLE_SCALERS) #if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) && !defined(DISABLE_SCALERS)
_mode = GFX_DOUBLESIZE; _videoMode.mode = GFX_DOUBLESIZE;
_scaleFactor = 2; _videoMode.scaleFactor = 2;
_videoMode.aspectRatio = ConfMan.getBool("aspect_ratio");
_scalerProc = Normal2x; _scalerProc = Normal2x;
_adjustAspectRatio = ConfMan.getBool("aspect_ratio");
#else // for small screen platforms #else // for small screen platforms
_mode = GFX_NORMAL; _videoMode.mode = GFX_NORMAL;
_scaleFactor = 1; _videoMode.scaleFactor = 1;
_videoMode.aspectRatio = false;
_scalerProc = Normal1x; _scalerProc = Normal1x;
_adjustAspectRatio = false;
#endif #endif
_scalerType = 0; _scalerType = 0;
_modeFlags = 0; _modeFlags = 0;
#if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) #if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
_fullscreen = ConfMan.getBool("fullscreen"); _videoMode.fullscreen = ConfMan.getBool("fullscreen");
#else #else
_fullscreen = true; _videoMode.fullscreen = true;
#endif #endif
#if !defined(MACOSX) && !defined(__SYMBIAN32__) #if !defined(MACOSX) && !defined(__SYMBIAN32__)
@ -192,8 +195,7 @@ OSystem_SDL::OSystem_SDL()
#ifdef USE_OSD #ifdef USE_OSD
_osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0), _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0),
#endif #endif
_hwscreen(0), _screen(0), _screenWidth(0), _screenHeight(0), _hwscreen(0), _screen(0), _tmpscreen(0),
_tmpscreen(0), _overlayWidth(0), _overlayHeight(0),
_overlayVisible(false), _overlayVisible(false),
_overlayscreen(0), _tmpscreen2(0), _overlayscreen(0), _tmpscreen2(0),
_samplesPerSec(0), _samplesPerSec(0),
@ -429,9 +431,9 @@ bool OSystem_SDL::getFeatureState(Feature f) {
switch (f) { switch (f) {
case kFeatureFullscreenMode: case kFeatureFullscreenMode:
return _fullscreen; return _videoMode.fullscreen;
case kFeatureAspectRatioCorrection: case kFeatureAspectRatioCorrection:
return _adjustAspectRatio; return _videoMode.aspectRatio;
case kFeatureAutoComputeDirtyRects: case kFeatureAutoComputeDirtyRects:
return _modeFlags & DF_WANT_RECT_OPTIM; return _modeFlags & DF_WANT_RECT_OPTIM;
default: default:

View file

@ -80,7 +80,7 @@ public:
virtual void initBackend(); virtual void initBackend();
void beginGFXTransaction(void); void beginGFXTransaction(void);
void endGFXTransaction(void); TransactionError endGFXTransaction(void);
// Set the size of the video bitmap. // Set the size of the video bitmap.
// Typically, 320x200 // Typically, 320x200
@ -179,8 +179,8 @@ public:
virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h);
virtual int16 getHeight(); virtual int16 getHeight();
virtual int16 getWidth(); virtual int16 getWidth();
virtual int16 getOverlayHeight() { return _overlayHeight; } virtual int16 getOverlayHeight() { return _videoMode.overlayHeight; }
virtual int16 getOverlayWidth() { return _overlayWidth; } virtual int16 getOverlayWidth() { return _videoMode.overlayWidth; }
virtual const GraphicsMode *getSupportedGraphicsModes() const; virtual const GraphicsMode *getSupportedGraphicsModes() const;
virtual int getDefaultGraphicsMode() const; virtual int getDefaultGraphicsMode() const;
@ -226,16 +226,12 @@ protected:
// unseen game screen // unseen game screen
SDL_Surface *_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) // temporary screen (for scalers)
SDL_Surface *_tmpscreen; SDL_Surface *_tmpscreen;
SDL_Surface *_tmpscreen2; SDL_Surface *_tmpscreen2;
// overlay // overlay
SDL_Surface *_overlayscreen; SDL_Surface *_overlayscreen;
int _overlayWidth, _overlayHeight;
bool _overlayVisible; bool _overlayVisible;
Graphics::PixelFormat _overlayFormat; Graphics::PixelFormat _overlayFormat;
@ -253,36 +249,39 @@ protected:
enum { enum {
kTransactionNone = 0, kTransactionNone = 0,
kTransactionCommit = 1, kTransactionActive = 1,
kTransactionActive = 2 kTransactionRollback = 2
}; };
struct TransactionDetails { struct TransactionDetails {
int mode;
bool modeChanged;
int w;
int h;
bool sizeChanged; bool sizeChanged;
bool fs;
bool fsChanged;
bool ar;
bool arChanged;
bool needHotswap; bool needHotswap;
bool needUpdatescreen; bool needUpdatescreen;
bool needUnload;
bool needToggle;
bool normal1xScaler; bool normal1xScaler;
}; };
TransactionDetails _transactionDetails; 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 */ /** Force full redraw on next updateScreen */
bool _forceFull; bool _forceFull;
ScalerProc *_scalerProc; ScalerProc *_scalerProc;
int _scalerType; int _scalerType;
int _scaleFactor;
int _mode;
int _transactionMode; int _transactionMode;
bool _fullscreen;
bool _screenIsLocked; bool _screenIsLocked;
Graphics::Surface _framebuffer; Graphics::Surface _framebuffer;
@ -292,9 +291,6 @@ protected:
bool _modeChanged; bool _modeChanged;
int _screenChangeCount; int _screenChangeCount;
/** True if aspect ratio correction is enabled. */
bool _adjustAspectRatio;
enum { enum {
NUM_DIRTY_RECT = 100, NUM_DIRTY_RECT = 100,
MAX_SCALING = 3 MAX_SCALING = 3
@ -417,9 +413,9 @@ protected:
virtual void internUpdateScreen(); // overloaded by CE backend 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 unloadGFXMode(); // overloaded by CE backend
virtual void hotswapGFXMode(); // overloaded by CE backend virtual bool hotswapGFXMode(); // overloaded by CE backend
void setFullscreenMode(bool enable); void setFullscreenMode(bool enable);
void setAspectRatioCorrection(bool enable); void setAspectRatioCorrection(bool enable);
@ -427,8 +423,8 @@ protected:
virtual bool saveScreenshot(const char *filename); // overloaded by CE backend virtual bool saveScreenshot(const char *filename); // overloaded by CE backend
int effectiveScreenHeight() const { int effectiveScreenHeight() const {
return (_adjustAspectRatio ? real2Aspect(_screenHeight) : _screenHeight) return (_videoMode.aspectRatio ? real2Aspect(_videoMode.screenHeight) : _videoMode.screenHeight)
* _scaleFactor; * _videoMode.scaleFactor;
} }
void setupIcon(); void setupIcon();

View file

@ -67,7 +67,8 @@ static bool launcherDialog(OSystem &system) {
system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio")); system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
if (ConfMan.hasKey("fullscreen")) if (ConfMan.hasKey("fullscreen"))
system.setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("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 // 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 // a --gui-theme option, to allow that option to be working, we need to initialize

View file

@ -393,12 +393,30 @@ public:
*/ */
virtual void beginGFXTransaction() {} 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. * End (and thereby commit) the current GFX transaction.
* @see beginGFXTransaction * @see beginGFXTransaction
* @see kTransactionError
* @return returns a ORed combination of TransactionError values or 0 on success
*/ */
virtual void endGFXTransaction() {} virtual TransactionError endGFXTransaction() { return kTransactionSuccess; }
/** /**

View file

@ -782,10 +782,7 @@ AgiEngine::~AgiEngine() {
Common::Error AgiBase::init() { Common::Error AgiBase::init() {
// Initialize backend // Initialize backend
_system->beginGFXTransaction(); initGraphics(320, 200, false);
initCommonGFX(false);
_system->initSize(320, 200);
_system->endGFXTransaction();
initialize(); initialize();

View file

@ -540,10 +540,7 @@ Common::Error AGOSEngine::init() {
_screenHeight = 200; _screenHeight = 200;
} }
_system->beginGFXTransaction(); initGraphics(_screenWidth, _screenHeight, getGameType() == GType_FF || getGameType() == GType_PP);
initCommonGFX(getGameType() == GType_FF || getGameType() == GType_PP);
_system->initSize(_screenWidth, _screenHeight);
_system->endGFXTransaction();
// Setup mixer // Setup mixer
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));

View file

@ -76,10 +76,7 @@ CineEngine::~CineEngine() {
Common::Error CineEngine::init() { Common::Error CineEngine::init() {
// Initialize backend // Initialize backend
_system->beginGFXTransaction(); initGraphics(320, 200, false);
initCommonGFX(false);
_system->initSize(320, 200);
_system->endGFXTransaction();
if (g_cine->getPlatform() == Common::kPlatformPC) { if (g_cine->getPlatform() == Common::kPlatformPC) {
g_sound = new PCSound(_mixer, this); g_sound = new PCSound(_mixer, this);

View file

@ -72,10 +72,7 @@ CruiseEngine::~CruiseEngine() {
Common::Error CruiseEngine::init() { Common::Error CruiseEngine::init() {
// Initialize backend // Initialize backend
_system->beginGFXTransaction(); initGraphics(320, 200, false);
initCommonGFX(false);
_system->initSize(320, 200);
_system->endGFXTransaction();
initialize(); initialize();

View file

@ -106,10 +106,7 @@ DrasculaEngine::~DrasculaEngine() {
Common::Error DrasculaEngine::init() { Common::Error DrasculaEngine::init() {
// Initialize backend // Initialize backend
_system->beginGFXTransaction(); initGraphics(320, 200, false);
initCommonGFX(false);
_system->initSize(320, 200);
_system->endGFXTransaction();
switch (getLanguage()) { switch (getLanguage()) {
case Common::EN_ANY: case Common::EN_ANY:

View file

@ -125,15 +125,62 @@ void initCommonGFX(bool defaultTo1XScaler) {
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); 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) { void GUIErrorMessage(const Common::String msg) {
g_system->setWindowCaption("Error"); g_system->setWindowCaption("Error");
g_system->beginGFXTransaction(); g_system->beginGFXTransaction();
initCommonGFX(false); initCommonGFX(false);
g_system->initSize(320, 200); g_system->initSize(320, 200);
g_system->endGFXTransaction(); if (g_system->endGFXTransaction() == OSystem::kTransactionSuccess) {
GUI::MessageDialog dialog(msg);
GUI::MessageDialog dialog(msg); dialog.runModal();
dialog.runModal(); } else {
error(msg.c_str());
}
} }
void Engine::checkCD() { void Engine::checkCD() {

View file

@ -51,7 +51,18 @@ namespace GUI {
void initCommonGFX(bool defaultTo1XScaler); 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); void GUIErrorMessage(const Common::String msg);

View file

@ -169,10 +169,7 @@ void Video::clearScreen() {
} }
void Video::setSize(bool defaultTo1XScaler) { void Video::setSize(bool defaultTo1XScaler) {
_vm->_system->beginGFXTransaction(); initGraphics(_vm->_width, _vm->_height, defaultTo1XScaler);
_vm->_system->initSize(_vm->_width, _vm->_height);
initCommonGFX(defaultTo1XScaler);
_vm->_system->endGFXTransaction();
} }
void Video::retrace(bool mouse) { void Video::retrace(bool mouse) {

View file

@ -66,10 +66,7 @@ GroovieEngine::~GroovieEngine() {
Common::Error GroovieEngine::init() { Common::Error GroovieEngine::init() {
// Initialize the graphics // Initialize the graphics
_system->beginGFXTransaction(); initGraphics(640, 480, true);
initCommonGFX(true);
_system->initSize(640, 480);
_system->endGFXTransaction();
// Create debugger. It requires GFX to be initialized // Create debugger. It requires GFX to be initialized
_debugger = new Debugger(this); _debugger = new Debugger(this);

View file

@ -89,10 +89,7 @@ IgorEngine::~IgorEngine() {
} }
Common::Error IgorEngine::init() { Common::Error IgorEngine::init() {
_system->beginGFXTransaction(); initGraphics(320, 200, false);
initCommonGFX(false);
_system->initSize(320, 200);
_system->endGFXTransaction();
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
return Common::kNoError; return Common::kNoError;

View file

@ -186,24 +186,26 @@ void Screen::setResolution() {
byte palette[4*256]; byte palette[4*256];
_system->grabPalette(palette, 0, 256); _system->grabPalette(palette, 0, 256);
int width = 320, height = 200;
bool defaultTo1xScaler = false;
if (_vm->gameFlags().useHiResOverlay) { if (_vm->gameFlags().useHiResOverlay) {
_system->beginGFXTransaction(); defaultTo1xScaler = true;
if (_debugEnabled) height = 400;
_system->initSize(960, 400);
else if (_debugEnabled)
_system->initSize(640, 400); width = 960;
initCommonGFX(true); else
_system->endGFXTransaction(); width = 640;
} else { } else {
_system->beginGFXTransaction(); if (_debugEnabled)
if (_debugEnabled) width = 640;
_system->initSize(640, 200); else
else width = 320;
_system->initSize(320, 200);
initCommonGFX(false);
_system->endGFXTransaction();
} }
initGraphics(width, height, defaultTo1xScaler);
_system->setPalette(palette, 0, 256); _system->setPalette(palette, 0, 256);
} }

View file

@ -52,10 +52,7 @@ Common::Error LureEngine::init() {
int_engine = this; int_engine = this;
_initialised = false; _initialised = false;
_system->beginGFXTransaction(); initGraphics(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT, false);
initCommonGFX(false);
_system->initSize(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
_system->endGFXTransaction();
// Check the version of the lure.dat file // Check the version of the lure.dat file
Common::File f; Common::File f;

View file

@ -143,13 +143,10 @@ M4Engine::~M4Engine() {
Common::Error M4Engine::init() { Common::Error M4Engine::init() {
// Initialize backend // Initialize backend
_system->beginGFXTransaction();
initCommonGFX(isM4());
if (isM4()) if (isM4())
_system->initSize(640, 480); initGraphics(640, 480, true);
else else
_system->initSize(320, 200); initGraphics(320, 200, false);
_system->endGFXTransaction();
_screen = new M4Surface(true); // Special form for creating screen reference _screen = new M4Surface(true); // Special form for creating screen reference

View file

@ -130,10 +130,7 @@ MadeEngine::~MadeEngine() {
Common::Error MadeEngine::init() { Common::Error MadeEngine::init() {
// Initialize backend // Initialize backend
_system->beginGFXTransaction(); initGraphics(320, 200, false);
initCommonGFX(false);
_system->initSize(320, 200);
_system->endGFXTransaction();
return Common::kNoError; return Common::kNoError;
} }

View file

@ -749,10 +749,7 @@ void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) {
Gfx::Gfx(Parallaction* vm) : Gfx::Gfx(Parallaction* vm) :
_vm(vm), _disk(vm->_disk) { _vm(vm), _disk(vm->_disk) {
_vm->_system->beginGFXTransaction(); initGraphics(_vm->_screenWidth, _vm->_screenHeight, _vm->getGameType() == GType_BRA);
_vm->_system->initSize(_vm->_screenWidth, _vm->_screenHeight);
initCommonGFX(_vm->getGameType() == GType_BRA);
_vm->_system->endGFXTransaction();
setPalette(_palette); setPalette(_palette);

View file

@ -473,10 +473,7 @@ Common::Error QueenEngine::go() {
} }
Common::Error QueenEngine::init() { Common::Error QueenEngine::init() {
_system->beginGFXTransaction(); initGraphics(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT, false);
initCommonGFX(false);
_system->initSize(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
_system->endGFXTransaction();
_resource = new Resource(); _resource = new Resource();

View file

@ -40,10 +40,7 @@ namespace Saga {
#define RID_IHNM_HOURGLASS_CURSOR 11 // not in demo #define RID_IHNM_HOURGLASS_CURSOR 11 // not in demo
Gfx::Gfx(SagaEngine *vm, OSystem *system, int width, int height) : _vm(vm), _system(system) { Gfx::Gfx(SagaEngine *vm, OSystem *system, int width, int height) : _vm(vm), _system(system) {
_system->beginGFXTransaction(); initGraphics(width, height, width > 320);
initCommonGFX(width > 320);
_system->initSize(width, height);
_system->endGFXTransaction();
debug(5, "Init screen %dx%d", width, height); debug(5, "Init screen %dx%d", width, height);
// Convert surface data to R surface data // Convert surface data to R surface data

View file

@ -822,10 +822,7 @@ ScummEngine_vCUPhe::~ScummEngine_vCUPhe() {
} }
Common::Error ScummEngine_vCUPhe::init() { Common::Error ScummEngine_vCUPhe::init() {
_system->beginGFXTransaction(); initGraphics(CUP_Player::kDefaultVideoWidth, CUP_Player::kDefaultVideoHeight, true);
_system->initSize(CUP_Player::kDefaultVideoWidth, CUP_Player::kDefaultVideoHeight);
initCommonGFX(true);
_system->endGFXTransaction();
return Common::kNoError; return Common::kNoError;
} }
@ -1069,23 +1066,16 @@ Common::Error ScummEngine::init() {
loadCJKFont(); loadCJKFont();
// Initialize backend // Initialize backend
_system->beginGFXTransaction(); if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
bool defaultTo1XScaler = false; initGraphics(Common::kHercW, Common::kHercH, true);
if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { } else if (_useCJKMode) {
_system->initSize(Common::kHercW, Common::kHercH); initGraphics(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier,
defaultTo1XScaler = true; // CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so
} else if (_useCJKMode) { // there is no text surface for them. This takes that into account
_system->initSize(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier); (_screenWidth * _textSurfaceMultiplier > 320));
} else {
// CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so initGraphics(_screenWidth, _screenHeight, _screenWidth > 320);
// 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(); setupScumm();

View file

@ -238,10 +238,7 @@ Common::Error SkyEngine::go() {
} }
Common::Error SkyEngine::init() { Common::Error SkyEngine::init() {
_system->beginGFXTransaction(); initGraphics(320, 200, false);
initCommonGFX(false);
_system->initSize(320, 200);
_system->endGFXTransaction();
if (ConfMan.getBool("sfx_mute")) { if (ConfMan.getBool("sfx_mute")) {
SkyEngine::_systemVars.systemFlags |= SF_FX_OFF; SkyEngine::_systemVars.systemFlags |= SF_FX_OFF;

View file

@ -78,10 +78,7 @@ SwordEngine::~SwordEngine() {
Common::Error SwordEngine::init() { Common::Error SwordEngine::init() {
_system->beginGFXTransaction(); initGraphics(640, 480, true);
initCommonGFX(true);
_system->initSize(640, 480);
_system->endGFXTransaction();
if ( 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1mac") || if ( 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1mac") ||
0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1macdemo") ) 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1macdemo") )

View file

@ -52,8 +52,6 @@ Screen::Screen(Sword2Engine *vm, int16 width, int16 height) {
_dirtyGrid = _buffer = NULL; _dirtyGrid = _buffer = NULL;
_vm->_system->initSize(width, height);
_screenWide = width; _screenWide = width;
_screenDeep = height; _screenDeep = height;

View file

@ -371,10 +371,8 @@ Common::Error Sword2Engine::init() {
_resman = NULL; _resman = NULL;
_memory = NULL; _memory = NULL;
_system->beginGFXTransaction(); initGraphics(640, 480, true);
initCommonGFX(true); _screen = new Screen(this, 640, 480);
_screen = new Screen(this, 640, 480);
_system->endGFXTransaction();
// Create the debugger as early as possible (but not before the // Create the debugger as early as possible (but not before the
// screen object!) so that errors can be displayed in it. In // screen object!) so that errors can be displayed in it. In

View file

@ -660,10 +660,7 @@ TinselEngine::~TinselEngine() {
Common::Error TinselEngine::init() { Common::Error TinselEngine::init() {
// Initialize backend // Initialize backend
_system->beginGFXTransaction(); initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT, false);
initCommonGFX(false);
_system->initSize(SCREEN_WIDTH, SCREEN_HEIGHT);
_system->endGFXTransaction();
_screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT, 1); _screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT, 1);

View file

@ -82,10 +82,7 @@ ToucheEngine::~ToucheEngine() {
} }
Common::Error ToucheEngine::init() { Common::Error ToucheEngine::init() {
_system->beginGFXTransaction(); initGraphics(kScreenWidth, kScreenHeight, true);
initCommonGFX(true);
_system->initSize(kScreenWidth, kScreenHeight);
_system->endGFXTransaction();
Graphics::setupFont(_language); Graphics::setupFont(_language);

View file

@ -42,10 +42,7 @@ TuckerEngine::~TuckerEngine() {
} }
Common::Error TuckerEngine::init() { Common::Error TuckerEngine::init() {
_system->beginGFXTransaction(); initGraphics(320, 200, false);
initCommonGFX(false);
_system->initSize(320, 200);
_system->endGFXTransaction();
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));