aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/sdl/graphics.cpp2
-rw-r--r--base/engine.cpp25
-rw-r--r--base/engine.h5
-rw-r--r--base/main.cpp31
-rw-r--r--kyra/kyra.cpp8
-rw-r--r--kyra/kyra.h2
-rw-r--r--queen/queen.cpp7
-rw-r--r--queen/queen.h2
-rw-r--r--saga/gfx.cpp10
-rw-r--r--saga/gfx.h2
-rw-r--r--saga/saga.cpp4
-rw-r--r--saga/saga.h2
-rw-r--r--scumm/scumm.cpp7
-rw-r--r--scumm/scumm.h2
-rw-r--r--simon/simon.cpp7
-rw-r--r--simon/simon.h2
-rw-r--r--sky/sky.cpp7
-rw-r--r--sky/sky.h2
-rw-r--r--sword1/sword1.cpp26
-rw-r--r--sword1/sword1.h2
-rw-r--r--sword2/sword2.cpp7
-rw-r--r--sword2/sword2.h2
22 files changed, 93 insertions, 71 deletions
diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp
index ea16da6694..81bd672c9a 100644
--- a/backends/sdl/graphics.cpp
+++ b/backends/sdl/graphics.cpp
@@ -1062,8 +1062,6 @@ void OSystem_SDL::toggleMouseGrab() {
}
void OSystem_SDL::draw_mouse() {
- assert (_transactionMode == kTransactionNone);
-
if (_mouseDrawn || !_mouseVisible)
return;
diff --git a/base/engine.cpp b/base/engine.cpp
index 252b9d752b..7cdbc7c663 100644
--- a/base/engine.cpp
+++ b/base/engine.cpp
@@ -23,10 +23,10 @@
#include <malloc.h>
#endif
#include "base/engine.h"
-#include "base/gameDetector.h"
#include "common/config-manager.h"
#include "common/file.h"
#include "common/timer.h"
+#include "common/scaler.h" // For GFX_NORMAL
#include "sound/mixer.h"
/* FIXME - BIG HACK for MidiEmu */
@@ -58,6 +58,29 @@ Engine::~Engine() {
g_engine = NULL;
}
+void Engine::initCommonGFX(GameDetector &detector) {
+ const bool useDefaultGraphicsMode =
+ !ConfMan.hasKey("gfx_mode", detector._targetName) ||
+ !scumm_stricmp(ConfMan.get("gfx_mode", detector._targetName).c_str(), "normal") ||
+ !scumm_stricmp(ConfMan.get("gfx_mode", detector._targetName).c_str(), "default");
+
+ // See if the game should default to 1x scaler
+ if (useDefaultGraphicsMode && (detector._game.features & GF_DEFAULT_TO_1X_SCALER)) {
+ _system->setGraphicsMode(GFX_NORMAL);
+ } else {
+ // Override global scaler with any game-specific define
+ if (ConfMan.hasKey("gfx_mode")) {
+ _system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
+ }
+ }
+
+ // (De)activate aspect-ratio correction as determined by the config settings
+ _system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
+
+ // (De)activate fullscreen mode as determined by the config settings
+ _system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
+}
+
const char *Engine::getSavePath() const {
#if defined(__PALM_OS__)
diff --git a/base/engine.h b/base/engine.h
index 3774c52ac8..47bf5d5b02 100644
--- a/base/engine.h
+++ b/base/engine.h
@@ -24,6 +24,7 @@
#include "common/scummsys.h"
#include "common/str.h"
#include "common/system.h"
+#include "base/gameDetector.h"
class SoundMixer;
class Timer;
@@ -46,7 +47,7 @@ public:
* Init the engine.
* @return 0 for success, else an error code.
*/
- virtual int init() = 0;
+ virtual int init(GameDetector &detector) = 0;
/**
* Start the main engine loop.
@@ -64,6 +65,8 @@ public:
/** Specific for each engine: prepare error string. */
virtual void errorString(const char *buf_input, char *buf_output) = 0;
+
+ void initCommonGFX(GameDetector &detector);
};
extern Engine *g_engine;
diff --git a/base/main.cpp b/base/main.cpp
index 695df68546..3abb77bc94 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -35,7 +35,6 @@
#include "base/version.h"
#include "common/config-manager.h"
#include "common/file.h"
-#include "common/scaler.h" // For GFX_NORMAL
#include "common/timer.h"
#include "gui/newgui.h"
#include "gui/launcher.h"
@@ -247,11 +246,6 @@ static int runGame(GameDetector &detector, OSystem *system) {
system->setWindowCaption(caption.c_str());
}
- const bool useDefaultGraphicsMode =
- !ConfMan.hasKey("gfx_mode", detector._targetName) ||
- !scumm_stricmp(ConfMan.get("gfx_mode", detector._targetName).c_str(), "normal") ||
- !scumm_stricmp(ConfMan.get("gfx_mode", detector._targetName).c_str(), "default");
-
// Create the game engine
Engine *engine = detector.createEngine(system);
assert(engine);
@@ -265,29 +259,8 @@ static int runGame(GameDetector &detector, OSystem *system) {
int result;
- // Start GFX transaction
- system->beginGFXTransaction();
-
- // See if the game should default to 1x scaler
- if (useDefaultGraphicsMode && (detector._game.features & GF_DEFAULT_TO_1X_SCALER)) {
- system->setGraphicsMode(GFX_NORMAL);
- } else {
- // Override global scaler with any game-specific define
- if (ConfMan.hasKey("gfx_mode")) {
- system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
- }
- }
-
- // (De)activate aspect-ratio correction as determined by the config settings
- system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
-
- // (De)activate fullscreen mode as determined by the config settings
- system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
-
- // Init the engine (this might change the screen parameters
- result = engine->init();
-
- system->endGFXTransaction();
+ // Init the engine (this might change the screen parameters
+ result = engine->init(detector);
// Run the game engine if the initialization was successful.
if (result == 0) {
diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp
index 32f2dea384..27012257cb 100644
--- a/kyra/kyra.cpp
+++ b/kyra/kyra.cpp
@@ -123,10 +123,14 @@ KyraEngine::KyraEngine(GameDetector *detector, OSystem *syst)
}
}
-int KyraEngine::init() {
+int KyraEngine::init(GameDetector &detector) {
// Initialize backen
- _system->initSize(320, 200);
+ _system->beginGFXTransaction();
+ initCommonGFX(detector);
+ _system->initSize(320, 200);
+ _system->endGFXTransaction();
+
_screen = new uint8[320*200];
memset(_screen, 0, sizeof(uint8) * 320 * 200);
diff --git a/kyra/kyra.h b/kyra/kyra.h
index e269ad71d2..e299ba8026 100644
--- a/kyra/kyra.h
+++ b/kyra/kyra.h
@@ -68,7 +68,7 @@ public:
protected:
int go();
- int init();
+ int init(GameDetector &detector);
void shutdown();
Resourcemanager* _resMgr;
MusicPlayer* _midiDriver;
diff --git a/queen/queen.cpp b/queen/queen.cpp
index dffdf208a4..88b0463452 100644
--- a/queen/queen.cpp
+++ b/queen/queen.cpp
@@ -316,8 +316,11 @@ int QueenEngine::go() {
return 0;
}
-int QueenEngine::init() {
- _system->initSize(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
+int QueenEngine::init(GameDetector &detector) {
+ _system->beginGFXTransaction();
+ initCommonGFX(detector);
+ _system->initSize(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
+ _system->endGFXTransaction();
_bam = new BamScene(this);
_resource = new Resource();
diff --git a/queen/queen.h b/queen/queen.h
index ceb895d2ce..6ef5d463c6 100644
--- a/queen/queen.h
+++ b/queen/queen.h
@@ -124,7 +124,7 @@ protected:
void errorString(const char *buf_input, char *buf_output);
int go();
- int init();
+ int init(GameDetector &detector);
int _talkSpeed;
diff --git a/saga/gfx.cpp b/saga/gfx.cpp
index 7a7a5397c6..436ddfdb2e 100644
--- a/saga/gfx.cpp
+++ b/saga/gfx.cpp
@@ -35,11 +35,13 @@
namespace Saga {
-Gfx::Gfx(OSystem *system, int width, int height) {
+Gfx::Gfx(OSystem *system, int width, int height, GameDetector &detector) : _system(system) {
SURFACE back_buf;
- _system = system;
- _system->initSize(width, height);
+ _system->beginGFXTransaction();
+ _vm->initCommonGFX(detector);
+ _system->initSize(width, height);
+ _system->endGFXTransaction();
debug(0, "Init screen %dx%d", width, height);
// Convert surface data to R surface data
@@ -61,7 +63,7 @@ Gfx::Gfx(OSystem *system, int width, int height) {
// For now, always show the mouse cursor.
setCursor(1);
- g_system->showMouse(true);
+ _system->showMouse(true);
}
/*
diff --git a/saga/gfx.h b/saga/gfx.h
index 8bccae32c8..7188d7f134 100644
--- a/saga/gfx.h
+++ b/saga/gfx.h
@@ -98,7 +98,7 @@ bool hitTestPoly(const Point *points, unsigned int npoints, const Point& test_po
class Gfx {
public:
- Gfx(OSystem *system, int width, int height);
+ Gfx(OSystem *system, int width, int height, GameDetector &detector);
SURFACE *getBackBuffer();
int getWhite();
int getBlack();
diff --git a/saga/saga.cpp b/saga/saga.cpp
index 236ed78ae2..b71c1313d1 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -124,7 +124,7 @@ void SagaEngine::errorString(const char *buf1, char *buf2) {
strcpy(buf2, buf1);
}
-int SagaEngine::init() {
+int SagaEngine::init(GameDetector &detector) {
_soundEnabled = 1;
_musicEnabled = 1;
@@ -183,7 +183,7 @@ int SagaEngine::init() {
// Initialize graphics
GAME_DISPLAYINFO disp_info;
GAME_GetDisplayInfo(&disp_info);
- _gfx = new Gfx(_system, disp_info.logical_w, disp_info.logical_h);
+ _gfx = new Gfx(_system, disp_info.logical_w, disp_info.logical_h, detector);
// Graphics should be initialized before music
int midiDriver = GameDetector::detectMusicDriver(MDT_NATIVE | MDT_ADLIB | MDT_PREFER_NATIVE);
diff --git a/saga/saga.h b/saga/saga.h
index e140839740..7a7abe765b 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -89,7 +89,7 @@ class SagaEngine : public Engine {
protected:
int go();
- int init();
+ int init(GameDetector &detector);
public:
SagaEngine(GameDetector * detector, OSystem * syst);
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index bdb91a1d99..864d261207 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -976,10 +976,13 @@ ScummEngine_v70he::ScummEngine_v70he(GameDetector *detector, OSystem *syst, cons
#pragma mark --- Initialization ---
#pragma mark -
-int ScummEngine::init() {
+int ScummEngine::init(GameDetector &detector) {
// Initialize backend
- _system->initSize(_screenWidth, _screenHeight);
+ _system->beginGFXTransaction();
+ initCommonGFX(detector);
+ _system->initSize(_screenWidth, _screenHeight);
+ _system->endGFXTransaction();
int cd_num = ConfMan.getInt("cdrom");
if (cd_num >= 0 && (_features & GF_AUDIOTRACKS))
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 43b7728958..25aeaac501 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -388,7 +388,7 @@ public:
int go();
// Init functions
- int init();
+ int init(GameDetector &detector);
virtual void setupScummVars();
void initScummVars();
diff --git a/simon/simon.cpp b/simon/simon.cpp
index 44332bc3ba..193619f937 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -661,14 +661,17 @@ SimonEngine::SimonEngine(GameDetector *detector, OSystem *syst)
"\x5\x5\x4\x6\x5\x3\x4\x5\x6\x3\x5\x5\x4\x6\x5\x3\x4\x6\x5\x6\x6\x6\x5\x5\x5\x6\x5\x6\x6\x6\x6\x6", 32);
}
-int SimonEngine::init() {
+int SimonEngine::init(GameDetector &detector) {
// Setup mixer
if (!_mixer->isReady())
warning("Sound initialization failed. "
"Features of the game that depend on sound synchronization will most likely break");
set_volume(ConfMan.getInt("sfx_volume"));
- _system->initSize(320, 200);
+ _system->beginGFXTransaction();
+ initCommonGFX(detector);
+ _system->initSize(320, 200);
+ _system->endGFXTransaction();
// Setup midi driver
MidiDriver *driver = 0;
diff --git a/simon/simon.h b/simon/simon.h
index b0c72491c1..b27781abe2 100644
--- a/simon/simon.h
+++ b/simon/simon.h
@@ -740,7 +740,7 @@ protected:
void resfile_read(void *dst, uint32 offs, uint32 size);
- int init();
+ int init(GameDetector &detector);
int go();
void openGameFile();
diff --git a/sky/sky.cpp b/sky/sky.cpp
index 17a2747191..bde61fcd0d 100644
--- a/sky/sky.cpp
+++ b/sky/sky.cpp
@@ -245,8 +245,11 @@ int SkyEngine::go() {
return 0;
}
-int SkyEngine::init() {
- _system->initSize(320, 200);
+int SkyEngine::init(GameDetector &detector) {
+ _system->beginGFXTransaction();
+ initCommonGFX(detector);
+ _system->initSize(320, 200);
+ _system->endGFXTransaction();
if (!_mixer->isReady())
warning("Sound initialisation failed");
diff --git a/sky/sky.h b/sky/sky.h
index d4e57e9a7a..08f56002c4 100644
--- a/sky/sky.h
+++ b/sky/sky.h
@@ -100,7 +100,7 @@ protected:
uint32 _lastSaveTime;
Text *getText();
- int init();
+ int init(GameDetector &detector);
void initItemList();
void initVirgin();
diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp
index 4033ec8704..fa8d4d2258 100644
--- a/sword1/sword1.cpp
+++ b/sword1/sword1.cpp
@@ -109,6 +109,16 @@ SwordEngine::SwordEngine(GameDetector *detector, OSystem *syst)
if (!_mixer->isReady())
warning("Sound initialization failed");
+
+ // Add default file directories
+ File::addDefaultDirectory(_gameDataPath + "CLUSTERS/");
+ File::addDefaultDirectory(_gameDataPath + "MUSIC/");
+ File::addDefaultDirectory(_gameDataPath + "SPEECH/");
+ File::addDefaultDirectory(_gameDataPath + "VIDEO/");
+ File::addDefaultDirectory(_gameDataPath + "clusters/");
+ File::addDefaultDirectory(_gameDataPath + "music/");
+ File::addDefaultDirectory(_gameDataPath + "speech/");
+ File::addDefaultDirectory(_gameDataPath + "video/");
}
SwordEngine::~SwordEngine() {
@@ -123,19 +133,13 @@ SwordEngine::~SwordEngine() {
delete _resMan;
}
-int SwordEngine::init() {
+int SwordEngine::init(GameDetector &detector) {
- // Add default file directories
- File::addDefaultDirectory(_gameDataPath + "CLUSTERS/");
- File::addDefaultDirectory(_gameDataPath + "MUSIC/");
- File::addDefaultDirectory(_gameDataPath + "SPEECH/");
- File::addDefaultDirectory(_gameDataPath + "VIDEO/");
- File::addDefaultDirectory(_gameDataPath + "clusters/");
- File::addDefaultDirectory(_gameDataPath + "music/");
- File::addDefaultDirectory(_gameDataPath + "speech/");
- File::addDefaultDirectory(_gameDataPath + "video/");
+ _system->beginGFXTransaction();
+ initCommonGFX(detector);
+ _system->initSize(640, 480);
+ _system->endGFXTransaction();
- _system->initSize(640, 480);
debug(5, "Starting resource manager");
_resMan = new ResMan("swordres.rif");
debug(5, "Starting object manager");
diff --git a/sword1/sword1.h b/sword1/sword1.h
index 835e4701e3..52db32e867 100644
--- a/sword1/sword1.h
+++ b/sword1/sword1.h
@@ -76,7 +76,7 @@ public:
uint32 _features;
protected:
int go();
- int init();
+ int init(GameDetector &detector);
private:
void delay(uint amount);
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index 05ba3bf340..ffdb700d4a 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -223,11 +223,14 @@ void Sword2Engine::setupPersistentResources() {
_resman->openResource(CUR_PLAYER_ID);
}
-int Sword2Engine::init() {
+int Sword2Engine::init(GameDetector &detector) {
// Get some falling RAM and put it in your pocket, never let it slip
// away
- _graphics = new Graphics(this, 640, 480);
+ _system->beginGFXTransaction();
+ initCommonGFX(detector);
+ _graphics = new Graphics(this, 640, 480);
+ _system->endGFXTransaction();
// Create the debugger as early as possible (but not before the
// graphics object!) so that errors can be displayed in it. In
diff --git a/sword2/sword2.h b/sword2/sword2.h
index e775195dd4..84a3084c73 100644
--- a/sword2/sword2.h
+++ b/sword2/sword2.h
@@ -171,7 +171,7 @@ public:
Sword2Engine(GameDetector *detector, OSystem *syst);
~Sword2Engine();
int go();
- int init();
+ int init(GameDetector &detector);
void setupPersistentResources();