aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorMax Horn2004-02-24 22:39:42 +0000
committerMax Horn2004-02-24 22:39:42 +0000
commitd158280425efac5f4ec72e00fb2b7389cdfb5a75 (patch)
treef1bdab69e381b2a28320fdeb30936482565e5099 /base
parent70f910cbe19e9c7320a56fa48669f7a5e9df00e6 (diff)
downloadscummvm-rg350-d158280425efac5f4ec72e00fb2b7389cdfb5a75.tar.gz
scummvm-rg350-d158280425efac5f4ec72e00fb2b7389cdfb5a75.tar.bz2
scummvm-rg350-d158280425efac5f4ec72e00fb2b7389cdfb5a75.zip
the OSystem changes we discussed on the ML (note: renaming of the existing OSystem API is not yet finished); porters will have to fix their ports to get them to compile again
svn-id: r13036
Diffstat (limited to 'base')
-rw-r--r--base/gameDetector.cpp64
-rw-r--r--base/gameDetector.h9
-rw-r--r--base/main.cpp31
3 files changed, 26 insertions, 78 deletions
diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp
index d5cb1eaef2..037a3efce9 100644
--- a/base/gameDetector.cpp
+++ b/base/gameDetector.cpp
@@ -96,46 +96,12 @@ static const char USAGE_STRING[] =
;
#endif
-/**
- * List of graphic 'modes' we potentially support. Potentially because not all
- * backends actually support all the filters listed here. At this point only
- * the SDL backend supports all (except for the PalmOS ones of course).
- * @todo Remove this explicit list of graphic modes and rather extend the
- * OSystem API to allow querying a backend for the modes it supports.
- */
-const GraphicsMode g_gfx_modes[] = {
- {"normal", "Normal (no scaling)", GFX_NORMAL},
- {"1x", "Normal (no scaling)", GFX_NORMAL},
-#ifndef __PALM_OS__ // reduce contant data size
- {"2x", "2x", GFX_DOUBLESIZE},
- {"3x", "3x", GFX_TRIPLESIZE},
- {"2xsai", "2xSAI", GFX_2XSAI},
- {"super2xsai", "Super2xSAI", GFX_SUPER2XSAI},
- {"supereagle", "SuperEagle", GFX_SUPEREAGLE},
- {"advmame2x", "AdvMAME2x", GFX_ADVMAME2X},
- {"advmame3x", "AdvMAME3x", GFX_ADVMAME3X},
- {"hq2x", "HQ2x", GFX_HQ2X},
- {"hq3x", "HQ3x", GFX_HQ3X},
- {"tv2x", "TV2x", GFX_TV2X},
- {"dotmatrix", "DotMatrix", GFX_DOTMATRIX},
-#else
- {"flipping", "Page Flipping", GFX_FLIPPING},
- {"buffered", "Buffered", GFX_BUFFERED},
- {"wide", "Wide (HiRes+ only)", GFX_WIDE},
-#endif
- {0, 0, 0}
-};
-
GameDetector::GameDetector() {
// Graphics
ConfMan.registerDefault("fullscreen", false);
ConfMan.registerDefault("aspect_ratio", false);
-#ifndef _WIN32_WCE
- ConfMan.registerDefault("gfx_mode", "2x");
-#else
ConfMan.registerDefault("gfx_mode", "normal");
-#endif
// Sound & Music
ConfMan.registerDefault("master_volume", 192);
@@ -350,12 +316,22 @@ void GameDetector::parseCommandLine(int argc, char **argv) {
END_OPTION
DO_OPTION('g', "gfx-mode")
- int gfx_mode = parseGraphicsMode(option);
+ // Check whether 'option' specifies a valid graphics mode.
+ bool isValid = false;
+ if (!scumm_stricmp(option, "normal") || !scumm_stricmp(option, "default"))
+ isValid = true;
+ if (!isValid) {
+ const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
+ while (gm->name && !isValid) {
+ isValid = !scumm_stricmp(gm->name, option);
+ gm++;
+ }
+ }
// TODO: Instead of just showing the generic help text,
// maybe print a message like:
// "'option' is not a supported graphic mode on this machine.
// Available graphic modes: ..."
- if (gfx_mode == -1)
+ if (!isValid)
goto ShowHelpAndExit;
ConfMan.set("gfx_mode", option, kTransientDomain);
END_OPTION
@@ -493,22 +469,6 @@ void GameDetector::setTarget(const String &name) {
ConfMan.setActiveDomain(name);
}
-int GameDetector::parseGraphicsMode(const String &str) {
- if (str.isEmpty())
- return -1;
-
- const char *s = str.c_str();
- const GraphicsMode *gm = g_gfx_modes;
- while (gm->name) {
- if (!scumm_stricmp(gm->name, s)) {
- return gm->id;
- }
- gm++;
- }
-
- return -1;
-}
-
bool GameDetector::detectGame() {
String realGame;
diff --git a/base/gameDetector.h b/base/gameDetector.h
index 62fc365055..cd02fba45d 100644
--- a/base/gameDetector.h
+++ b/base/gameDetector.h
@@ -54,14 +54,6 @@ struct GameSettings {
uint32 features;
};
-struct GraphicsMode {
- const char *name;
- const char *description;
- int id;
-};
-
-extern const GraphicsMode g_gfx_modes[];
-
class GameDetector {
typedef Common::String String;
@@ -85,7 +77,6 @@ public:
static SoundMixer *createMixer();
static MidiDriver *createMidi(int midiDriver);
- static int parseGraphicsMode(const String &s); // Used in main()
static int detectMusicDriver(int midiFlags);
static GameSettings findGame(const String &gameName, const Plugin **plugin = NULL);
diff --git a/base/main.cpp b/base/main.cpp
index 2141c9d05a..85cfc059fd 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -176,12 +176,15 @@ static void do_memory_test(void) {
#endif
static int launcherDialog(GameDetector &detector, OSystem *system) {
- // FIXME - we need to call init_size() here so that we can display for example
+ // Set the user specified graphics mode (if any).
+ system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
+
+ // FIXME - we need to call initSize() here so that we can display for example
// the launcher dialog. But the Engine object will also call it again (possibly
// with a different widht/height!9 However, this method is not for all OSystem
// implementations reentrant (it is so now for the SDL backend). Thus we need
// to fix all backends to support it, if they don't already.
- system->init_size(320, 200);
+ system->initSize(320, 200);
// FIXME - mouse cursors are currently always set via 8 bit data.
// Thus for now we need to setup a dummy palette. On the long run, we might
@@ -219,7 +222,6 @@ static int launcherDialog(GameDetector &detector, OSystem *system) {
}
static void runGame(GameDetector &detector, OSystem *system) {
- OSystem::Property prop;
// Set the window caption to the game name
Common::String caption(ConfMan.get("description", detector._targetName));
@@ -229,26 +231,22 @@ static void runGame(GameDetector &detector, OSystem *system) {
if (caption.isEmpty())
caption = detector._targetName;
if (!caption.isEmpty()) {
- prop.caption = caption.c_str();
- system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
+ system->setWindowCaption(caption.c_str());
}
// See if the game should default to 1x scaler
if (!ConfMan.hasKey("gfx_mode", detector._targetName) &&
(detector._game.features & GF_DEFAULT_TO_1X_SCALER)) {
- prop.gfx_mode = GFX_NORMAL;
- system->property(OSystem::PROP_SET_GFX_MODE, &prop);
+ system->setGraphicsMode(GFX_NORMAL);
} else {
// Override global scaler with any game-specific define
if (ConfMan.hasKey("gfx_mode")) {
- prop.gfx_mode = detector.parseGraphicsMode(ConfMan.get("gfx_mode"));
- system->property(OSystem::PROP_SET_GFX_MODE, &prop);
+ system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
}
}
// (De)activate fullscreen mode as determined by the config settings
- if (ConfMan.getBool("fullscreen") != (system->property(OSystem::PROP_GET_FULLSCREEN, 0) != 0))
- system->property(OSystem::PROP_TOGGLE_FULLSCREEN, 0);
+ system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
// Create the game engine
Engine *engine = detector.createEngine(system);
@@ -258,18 +256,17 @@ static void runGame(GameDetector &detector, OSystem *system) {
engine->go();
// Stop all sound processing now (this prevents some race conditions later on)
- system->clear_sound_proc();
+ system->clearSoundCallback();
// Free up memory
delete engine;
};
#ifndef _WIN32_WCE
-int main(int argc, char *argv[]) {
+extern "C" int main(int argc, char *argv[]) {
#else
extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
#endif
- OSystem::Property prop;
char *cfgFilename = NULL, *s=argv[1];
#if defined(UNIX)
@@ -346,15 +343,15 @@ extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
#endif
detector.parseCommandLine(argc, argv);
- // Create the system object
+ // Ensure the system object exists (it may have already been created
+ // at an earlier point, though!)
OSystem *system = OSystem::instance();
// Create the timer services
g_timer = new Timer(system);
// Set initial window caption
- prop.caption = gScummVMFullVersion;
- system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
+ system->setWindowCaption(gScummVMFullVersion);
// Unless a game was specified, show the launcher dialog
if (detector._targetName.isEmpty())