Fix a`ll engines. They work, though current fix is just temporary.

There are plans to add some brains to GameDetector class, which will let us
avoid passing detector to init() method.

svn-id: r15873
This commit is contained in:
Eugene Sandulenko 2004-11-24 00:14:21 +00:00
parent 6414ec92a2
commit 31e434dcf1
22 changed files with 93 additions and 71 deletions

View file

@ -1062,8 +1062,6 @@ void OSystem_SDL::toggleMouseGrab() {
} }
void OSystem_SDL::draw_mouse() { void OSystem_SDL::draw_mouse() {
assert (_transactionMode == kTransactionNone);
if (_mouseDrawn || !_mouseVisible) if (_mouseDrawn || !_mouseVisible)
return; return;

View file

@ -23,10 +23,10 @@
#include <malloc.h> #include <malloc.h>
#endif #endif
#include "base/engine.h" #include "base/engine.h"
#include "base/gameDetector.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/file.h" #include "common/file.h"
#include "common/timer.h" #include "common/timer.h"
#include "common/scaler.h" // For GFX_NORMAL
#include "sound/mixer.h" #include "sound/mixer.h"
/* FIXME - BIG HACK for MidiEmu */ /* FIXME - BIG HACK for MidiEmu */
@ -58,6 +58,29 @@ Engine::~Engine() {
g_engine = NULL; 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 { const char *Engine::getSavePath() const {
#if defined(__PALM_OS__) #if defined(__PALM_OS__)

View file

@ -24,6 +24,7 @@
#include "common/scummsys.h" #include "common/scummsys.h"
#include "common/str.h" #include "common/str.h"
#include "common/system.h" #include "common/system.h"
#include "base/gameDetector.h"
class SoundMixer; class SoundMixer;
class Timer; class Timer;
@ -46,7 +47,7 @@ public:
* Init the engine. * Init the engine.
* @return 0 for success, else an error code. * @return 0 for success, else an error code.
*/ */
virtual int init() = 0; virtual int init(GameDetector &detector) = 0;
/** /**
* Start the main engine loop. * Start the main engine loop.
@ -64,6 +65,8 @@ public:
/** Specific for each engine: prepare error string. */ /** Specific for each engine: prepare error string. */
virtual void errorString(const char *buf_input, char *buf_output) = 0; virtual void errorString(const char *buf_input, char *buf_output) = 0;
void initCommonGFX(GameDetector &detector);
}; };
extern Engine *g_engine; extern Engine *g_engine;

View file

@ -35,7 +35,6 @@
#include "base/version.h" #include "base/version.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/file.h" #include "common/file.h"
#include "common/scaler.h" // For GFX_NORMAL
#include "common/timer.h" #include "common/timer.h"
#include "gui/newgui.h" #include "gui/newgui.h"
#include "gui/launcher.h" #include "gui/launcher.h"
@ -247,11 +246,6 @@ static int runGame(GameDetector &detector, OSystem *system) {
system->setWindowCaption(caption.c_str()); 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 // Create the game engine
Engine *engine = detector.createEngine(system); Engine *engine = detector.createEngine(system);
assert(engine); assert(engine);
@ -265,29 +259,8 @@ static int runGame(GameDetector &detector, OSystem *system) {
int result; int result;
// Start GFX transaction // Init the engine (this might change the screen parameters
system->beginGFXTransaction(); result = engine->init(detector);
// 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();
// Run the game engine if the initialization was successful. // Run the game engine if the initialization was successful.
if (result == 0) { if (result == 0) {

View file

@ -123,10 +123,14 @@ KyraEngine::KyraEngine(GameDetector *detector, OSystem *syst)
} }
} }
int KyraEngine::init() { int KyraEngine::init(GameDetector &detector) {
// Initialize backen // Initialize backen
_system->initSize(320, 200); _system->beginGFXTransaction();
initCommonGFX(detector);
_system->initSize(320, 200);
_system->endGFXTransaction();
_screen = new uint8[320*200]; _screen = new uint8[320*200];
memset(_screen, 0, sizeof(uint8) * 320 * 200); memset(_screen, 0, sizeof(uint8) * 320 * 200);

View file

@ -68,7 +68,7 @@ public:
protected: protected:
int go(); int go();
int init(); int init(GameDetector &detector);
void shutdown(); void shutdown();
Resourcemanager* _resMgr; Resourcemanager* _resMgr;
MusicPlayer* _midiDriver; MusicPlayer* _midiDriver;

View file

@ -316,8 +316,11 @@ int QueenEngine::go() {
return 0; return 0;
} }
int QueenEngine::init() { int QueenEngine::init(GameDetector &detector) {
_system->initSize(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT); _system->beginGFXTransaction();
initCommonGFX(detector);
_system->initSize(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
_system->endGFXTransaction();
_bam = new BamScene(this); _bam = new BamScene(this);
_resource = new Resource(); _resource = new Resource();

View file

@ -124,7 +124,7 @@ protected:
void errorString(const char *buf_input, char *buf_output); void errorString(const char *buf_input, char *buf_output);
int go(); int go();
int init(); int init(GameDetector &detector);
int _talkSpeed; int _talkSpeed;

View file

@ -35,11 +35,13 @@
namespace Saga { 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; SURFACE back_buf;
_system = system; _system->beginGFXTransaction();
_system->initSize(width, height); _vm->initCommonGFX(detector);
_system->initSize(width, height);
_system->endGFXTransaction();
debug(0, "Init screen %dx%d", width, height); debug(0, "Init screen %dx%d", width, height);
// Convert surface data to R surface data // 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. // For now, always show the mouse cursor.
setCursor(1); setCursor(1);
g_system->showMouse(true); _system->showMouse(true);
} }
/* /*

View file

@ -98,7 +98,7 @@ bool hitTestPoly(const Point *points, unsigned int npoints, const Point& test_po
class Gfx { class Gfx {
public: public:
Gfx(OSystem *system, int width, int height); Gfx(OSystem *system, int width, int height, GameDetector &detector);
SURFACE *getBackBuffer(); SURFACE *getBackBuffer();
int getWhite(); int getWhite();
int getBlack(); int getBlack();

View file

@ -124,7 +124,7 @@ void SagaEngine::errorString(const char *buf1, char *buf2) {
strcpy(buf2, buf1); strcpy(buf2, buf1);
} }
int SagaEngine::init() { int SagaEngine::init(GameDetector &detector) {
_soundEnabled = 1; _soundEnabled = 1;
_musicEnabled = 1; _musicEnabled = 1;
@ -183,7 +183,7 @@ int SagaEngine::init() {
// Initialize graphics // Initialize graphics
GAME_DISPLAYINFO disp_info; GAME_DISPLAYINFO disp_info;
GAME_GetDisplayInfo(&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 // Graphics should be initialized before music
int midiDriver = GameDetector::detectMusicDriver(MDT_NATIVE | MDT_ADLIB | MDT_PREFER_NATIVE); int midiDriver = GameDetector::detectMusicDriver(MDT_NATIVE | MDT_ADLIB | MDT_PREFER_NATIVE);

View file

@ -89,7 +89,7 @@ class SagaEngine : public Engine {
protected: protected:
int go(); int go();
int init(); int init(GameDetector &detector);
public: public:
SagaEngine(GameDetector * detector, OSystem * syst); SagaEngine(GameDetector * detector, OSystem * syst);

View file

@ -976,10 +976,13 @@ ScummEngine_v70he::ScummEngine_v70he(GameDetector *detector, OSystem *syst, cons
#pragma mark --- Initialization --- #pragma mark --- Initialization ---
#pragma mark - #pragma mark -
int ScummEngine::init() { int ScummEngine::init(GameDetector &detector) {
// Initialize backend // Initialize backend
_system->initSize(_screenWidth, _screenHeight); _system->beginGFXTransaction();
initCommonGFX(detector);
_system->initSize(_screenWidth, _screenHeight);
_system->endGFXTransaction();
int cd_num = ConfMan.getInt("cdrom"); int cd_num = ConfMan.getInt("cdrom");
if (cd_num >= 0 && (_features & GF_AUDIOTRACKS)) if (cd_num >= 0 && (_features & GF_AUDIOTRACKS))

View file

@ -388,7 +388,7 @@ public:
int go(); int go();
// Init functions // Init functions
int init(); int init(GameDetector &detector);
virtual void setupScummVars(); virtual void setupScummVars();
void initScummVars(); void initScummVars();

View file

@ -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); "\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 // Setup mixer
if (!_mixer->isReady()) if (!_mixer->isReady())
warning("Sound initialization failed. " warning("Sound initialization failed. "
"Features of the game that depend on sound synchronization will most likely break"); "Features of the game that depend on sound synchronization will most likely break");
set_volume(ConfMan.getInt("sfx_volume")); set_volume(ConfMan.getInt("sfx_volume"));
_system->initSize(320, 200); _system->beginGFXTransaction();
initCommonGFX(detector);
_system->initSize(320, 200);
_system->endGFXTransaction();
// Setup midi driver // Setup midi driver
MidiDriver *driver = 0; MidiDriver *driver = 0;

View file

@ -740,7 +740,7 @@ protected:
void resfile_read(void *dst, uint32 offs, uint32 size); void resfile_read(void *dst, uint32 offs, uint32 size);
int init(); int init(GameDetector &detector);
int go(); int go();
void openGameFile(); void openGameFile();

View file

@ -245,8 +245,11 @@ int SkyEngine::go() {
return 0; return 0;
} }
int SkyEngine::init() { int SkyEngine::init(GameDetector &detector) {
_system->initSize(320, 200); _system->beginGFXTransaction();
initCommonGFX(detector);
_system->initSize(320, 200);
_system->endGFXTransaction();
if (!_mixer->isReady()) if (!_mixer->isReady())
warning("Sound initialisation failed"); warning("Sound initialisation failed");

View file

@ -100,7 +100,7 @@ protected:
uint32 _lastSaveTime; uint32 _lastSaveTime;
Text *getText(); Text *getText();
int init(); int init(GameDetector &detector);
void initItemList(); void initItemList();
void initVirgin(); void initVirgin();

View file

@ -109,6 +109,16 @@ SwordEngine::SwordEngine(GameDetector *detector, OSystem *syst)
if (!_mixer->isReady()) if (!_mixer->isReady())
warning("Sound initialization failed"); 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() { SwordEngine::~SwordEngine() {
@ -123,19 +133,13 @@ SwordEngine::~SwordEngine() {
delete _resMan; delete _resMan;
} }
int SwordEngine::init() { int SwordEngine::init(GameDetector &detector) {
// Add default file directories _system->beginGFXTransaction();
File::addDefaultDirectory(_gameDataPath + "CLUSTERS/"); initCommonGFX(detector);
File::addDefaultDirectory(_gameDataPath + "MUSIC/"); _system->initSize(640, 480);
File::addDefaultDirectory(_gameDataPath + "SPEECH/"); _system->endGFXTransaction();
File::addDefaultDirectory(_gameDataPath + "VIDEO/");
File::addDefaultDirectory(_gameDataPath + "clusters/");
File::addDefaultDirectory(_gameDataPath + "music/");
File::addDefaultDirectory(_gameDataPath + "speech/");
File::addDefaultDirectory(_gameDataPath + "video/");
_system->initSize(640, 480);
debug(5, "Starting resource manager"); debug(5, "Starting resource manager");
_resMan = new ResMan("swordres.rif"); _resMan = new ResMan("swordres.rif");
debug(5, "Starting object manager"); debug(5, "Starting object manager");

View file

@ -76,7 +76,7 @@ public:
uint32 _features; uint32 _features;
protected: protected:
int go(); int go();
int init(); int init(GameDetector &detector);
private: private:
void delay(uint amount); void delay(uint amount);

View file

@ -223,11 +223,14 @@ void Sword2Engine::setupPersistentResources() {
_resman->openResource(CUR_PLAYER_ID); _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 // Get some falling RAM and put it in your pocket, never let it slip
// away // 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 // Create the debugger as early as possible (but not before the
// graphics object!) so that errors can be displayed in it. In // graphics object!) so that errors can be displayed in it. In

View file

@ -171,7 +171,7 @@ public:
Sword2Engine(GameDetector *detector, OSystem *syst); Sword2Engine(GameDetector *detector, OSystem *syst);
~Sword2Engine(); ~Sword2Engine();
int go(); int go();
int init(); int init(GameDetector &detector);
void setupPersistentResources(); void setupPersistentResources();