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() {
assert (_transactionMode == kTransactionNone);
if (_mouseDrawn || !_mouseVisible)
return;

View file

@ -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__)

View file

@ -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;

View file

@ -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();
result = engine->init(detector);
// Run the game engine if the initialization was successful.
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
_system->beginGFXTransaction();
initCommonGFX(detector);
_system->initSize(320, 200);
_system->endGFXTransaction();
_screen = new uint8[320*200];
memset(_screen, 0, sizeof(uint8) * 320 * 200);

View file

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

View file

@ -316,8 +316,11 @@ int QueenEngine::go() {
return 0;
}
int QueenEngine::init() {
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();

View file

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

View file

@ -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->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);
}
/*

View file

@ -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();

View file

@ -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);

View file

@ -89,7 +89,7 @@ class SagaEngine : public Engine {
protected:
int go();
int init();
int init(GameDetector &detector);
public:
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 -
int ScummEngine::init() {
int ScummEngine::init(GameDetector &detector) {
// Initialize backend
_system->beginGFXTransaction();
initCommonGFX(detector);
_system->initSize(_screenWidth, _screenHeight);
_system->endGFXTransaction();
int cd_num = ConfMan.getInt("cdrom");
if (cd_num >= 0 && (_features & GF_AUDIOTRACKS))

View file

@ -388,7 +388,7 @@ public:
int go();
// Init functions
int init();
int init(GameDetector &detector);
virtual void setupScummVars();
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);
}
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->beginGFXTransaction();
initCommonGFX(detector);
_system->initSize(320, 200);
_system->endGFXTransaction();
// Setup midi driver
MidiDriver *driver = 0;

View file

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

View file

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

View file

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

View file

@ -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() {
// 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/");
int SwordEngine::init(GameDetector &detector) {
_system->beginGFXTransaction();
initCommonGFX(detector);
_system->initSize(640, 480);
_system->endGFXTransaction();
debug(5, "Starting resource manager");
_resMan = new ResMan("swordres.rif");
debug(5, "Starting object manager");

View file

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

View file

@ -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
_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

View file

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