aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/PalmOS/Src/palm.cpp7
-rw-r--r--backends/PalmOS/Src/palm.h11
-rw-r--r--backends/dc/audio.cpp4
-rw-r--r--backends/dc/dc.h6
-rw-r--r--backends/dc/display.cpp2
-rw-r--r--backends/gp32/gp32.cpp6
-rw-r--r--backends/gp32/gp32.h6
-rw-r--r--backends/intern.h2
-rw-r--r--backends/midi/adlib.cpp6
-rw-r--r--backends/morphos/morphos.cpp8
-rw-r--r--backends/morphos/morphos.h6
-rw-r--r--backends/null/null.cpp6
-rw-r--r--backends/sdl/sdl-common.cpp199
-rw-r--r--backends/sdl/sdl-common.h28
-rw-r--r--backends/sdl/sdl.cpp47
-rw-r--r--backends/wince/wince-sdl.cpp6
-rw-r--r--backends/wince/wince-sdl.h4
-rw-r--r--backends/x11/x11.cpp19
18 files changed, 206 insertions, 167 deletions
diff --git a/backends/PalmOS/Src/palm.cpp b/backends/PalmOS/Src/palm.cpp
index 98f15d7944..05ebe67520 100644
--- a/backends/PalmOS/Src/palm.cpp
+++ b/backends/PalmOS/Src/palm.cpp
@@ -230,7 +230,7 @@ void OSystem_PALMOS::unload_gfx_mode() {
}
-void OSystem_PALMOS::init_size(uint w, uint h) {
+void OSystem_PALMOS::initSize(uint w, uint h) {
_screenWidth = w;
_screenHeight = h;
_offScreenPitch = gVars->screenPitch; // direct screen / flipping use this, reset later if buffered
@@ -1593,13 +1593,12 @@ static Err sndCallback(void* UserDataP, SndStreamRef stream, void* bufferP, UInt
return errNone;
}
-bool OSystem_PALMOS::set_sound_proc(SoundProc proc, void *param, SoundFormat format) {
+bool OSystem_PALMOS::setSoundCallback(SoundProc proc, void *param) {
Boolean success = false;
if (!_sound.active) {
_sound.proc = proc;
_sound.param = param;
- _sound.format = format;
_sound.active = true; // always true when we call this function
// try to create sound stream
@@ -1622,7 +1621,7 @@ bool OSystem_PALMOS::set_sound_proc(SoundProc proc, void *param, SoundFormat for
return success;
}
-void OSystem_PALMOS::clear_sound_proc() {
+void OSystem_PALMOS::clearSoundCallback() {
if (_sound.active) {
if (!_sound.useHandler) {
SndStreamStop(_sound.sndRefNum);
diff --git a/backends/PalmOS/Src/palm.h b/backends/PalmOS/Src/palm.h
index c1dbc29140..cd87daf12c 100644
--- a/backends/PalmOS/Src/palm.h
+++ b/backends/PalmOS/Src/palm.h
@@ -37,7 +37,6 @@ Err HwrDisplayPalette(UInt8 operation, Int16 startIndex,
typedef struct {
OSystem::SoundProc proc;
void *param;
- OSystem::SoundFormat format;
SndStreamRef sndRefNum;
bool active, useHandler;
@@ -51,7 +50,7 @@ public:
// Set the size of the video bitmap.
// Typically, 320x200
- void init_size(uint w, uint h);
+ void initSize(uint w, uint h);
// Draw a bitmap to screen.
// The screen will not be updated to reflect the new bitmap
@@ -103,14 +102,14 @@ public:
* @param param an arbitrary parameter which is stored and passed to proc.
* @param format the sample type format.
*/
- bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
+ bool setSoundCallback(SoundProc proc, void *param);
/**
- * Remove any audio callback previously set via set_sound_proc, thus effectively
+ * Remove any audio callback previously set via setSoundCallback, thus effectively
* stopping all audio output immediately.
- * @see set_sound_proc
+ * @see setSoundCallback
*/
- void clear_sound_proc();
+ void clearSoundCallback();
//@}
// Poll cdrom status
diff --git a/backends/dc/audio.cpp b/backends/dc/audio.cpp
index a31d4b1884..2838e0779d 100644
--- a/backends/dc/audio.cpp
+++ b/backends/dc/audio.cpp
@@ -34,7 +34,7 @@ void initSound()
do_sound_command(CMD_SET_BUFFER(3));
}
-bool OSystem_Dreamcast::set_sound_proc(SoundProc proc, void *param, SoundFormat format)
+bool OSystem_Dreamcast::setSoundCallback(SoundProc proc, void *param)
{
#if SAMPLE_MODE == 0
assert(format == SOUND_16BIT);
@@ -49,7 +49,7 @@ bool OSystem_Dreamcast::set_sound_proc(SoundProc proc, void *param, SoundFormat
return true;
}
-void OSystem_Dreamcast::clear_sound_proc()
+void OSystem_Dreamcast::clearSoundCallback()
{
_sound_proc = NULL;
_sound_proc_param = NULL;
diff --git a/backends/dc/dc.h b/backends/dc/dc.h
index 57ba12ef51..b39d442856 100644
--- a/backends/dc/dc.h
+++ b/backends/dc/dc.h
@@ -35,7 +35,7 @@ class OSystem_Dreamcast : public OSystem {
// Set the size of the video bitmap.
// Typically, 320x200
- void init_size(uint w, uint h);
+ void initSize(uint w, uint h);
int16 get_height() { return _screen_h; }
int16 get_width() { return _screen_w; }
@@ -71,8 +71,8 @@ class OSystem_Dreamcast : public OSystem {
bool poll_event(Event *event);
// Set function that generates samples
- bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
- void clear_sound_proc();
+ bool setSoundCallback(SoundProc proc, void *param);
+ void clearSoundCallback();
// Poll cdrom status
// Returns true if cd audio is playing
diff --git a/backends/dc/display.cpp b/backends/dc/display.cpp
index 2900e1e363..13d23d6eb1 100644
--- a/backends/dc/display.cpp
+++ b/backends/dc/display.cpp
@@ -141,7 +141,7 @@ void OSystem_Dreamcast::set_palette(const byte *colors, uint start, uint num)
_screen_dirty = true;
}
-void OSystem_Dreamcast::init_size(uint w, uint h)
+void OSystem_Dreamcast::initSize(uint w, uint h)
{
assert(w <= SCREEN_W && h <= SCREEN_H);
diff --git a/backends/gp32/gp32.cpp b/backends/gp32/gp32.cpp
index 88527fef32..1d529e25bd 100644
--- a/backends/gp32/gp32.cpp
+++ b/backends/gp32/gp32.cpp
@@ -56,7 +56,7 @@ void OSystem_GP32::set_palette(const byte *colors, uint start, uint num) {
// Set the size of the video bitmap.
// Typically, 320x200
-void OSystem_GP32::init_size(uint w, uint h) {
+void OSystem_GP32::initSize(uint w, uint h) {
// Avoid redundant res changes
if ((int)w == _screenWidth && (int)h == _screenHeight)
return;
@@ -976,11 +976,11 @@ bool OSystem_GP32::poll_event(Event *event) { // fixme: make more user-friendly
// Set the function to be invoked whenever samples need to be generated
// Format is the sample type format.
// Only 16-bit signed mode is needed for simon & scumm
-bool OSystem_GP32::set_sound_proc(SoundProc proc, void *param, SoundFormat format) {
+bool OSystem_GP32::setSoundCallback(SoundProc proc, void *param) {
return false;
}
-void OSystem_GP32::clear_sound_proc() {
+void OSystem_GP32::clearSoundCallback() {
//_sound_proc = NULL;
//_sound_proc_param = NULL;
}
diff --git a/backends/gp32/gp32.h b/backends/gp32/gp32.h
index 0faf3f0cf2..2b692f0493 100644
--- a/backends/gp32/gp32.h
+++ b/backends/gp32/gp32.h
@@ -39,7 +39,7 @@ public:
// Set the size of the video bitmap.
// Typically, 320x200
- void init_size(uint w, uint h);
+ void initSize(uint w, uint h);
int16 get_height() { return _screenHeight; }
int16 get_width() { return _screenWidth; }
@@ -80,8 +80,8 @@ public:
// Set the function to be invoked whenever samples need to be generated
// Format is the sample type format.
// Only 16-bit signed mode is needed for simon & scumm
- bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
- void clear_sound_proc();
+ bool setSoundCallback(SoundProc proc, void *param);
+ void clearSoundCallback();
// Get or set a property
uint32 property(int param, Property *value);
diff --git a/backends/intern.h b/backends/intern.h
index 57a763a17c..9d07aba0c0 100644
--- a/backends/intern.h
+++ b/backends/intern.h
@@ -27,7 +27,7 @@
/* Factory functions. This means we don't have to include the headers for
* all backends.
*/
-extern OSystem *OSystem_SDL_create(int gfx_driver);
+extern OSystem *OSystem_SDL_create();
extern OSystem *OSystem_NULL_create();
extern OSystem *OSystem_MorphOS_create(int gfx_driver, bool full_screen);
extern OSystem *OSystem_Dreamcast_create();
diff --git a/backends/midi/adlib.cpp b/backends/midi/adlib.cpp
index 02261fed71..7fb0de39b1 100644
--- a/backends/midi/adlib.cpp
+++ b/backends/midi/adlib.cpp
@@ -852,11 +852,7 @@ int MidiDriver_ADLIB::open() {
_adlib_reg_cache = (byte *)calloc(256, 1);
- // We need to emulate one YM3812 chip
- int env_bits = g_system->property(OSystem::PROP_GET_FMOPL_ENV_BITS, NULL);
- int eg_ent = g_system->property(OSystem::PROP_GET_FMOPL_EG_ENT, NULL);
- OPLBuildTables((env_bits ? env_bits : FMOPL_ENV_BITS_HQ), (eg_ent ? eg_ent : FMOPL_EG_ENT_HQ));
- _opl = OPLCreate(OPL_TYPE_YM3812, 3579545, _mixer->getOutputRate());
+ _opl = makeAdlibOPL(_mixer->getOutputRate());
adlib_write(1, 0x20);
adlib_write(8, 0x40);
diff --git a/backends/morphos/morphos.cpp b/backends/morphos/morphos.cpp
index 2482d5e274..d36965538d 100644
--- a/backends/morphos/morphos.cpp
+++ b/backends/morphos/morphos.cpp
@@ -1436,13 +1436,13 @@ void OSystem_MorphOS::set_mouse_cursor(const byte *buf, uint w, uint h, int hots
UndrawMouse();
}
-bool OSystem_MorphOS::set_sound_proc(OSystem::SoundProc proc, void *param, OSystem::SoundFormat format)
+bool OSystem_MorphOS::setSoundCallback(OSystem::SoundProc proc, void *param)
{
if (ScummSoundThread)
{
if (SoundProc == proc)
return true;
- clear_sound_proc();
+ clearSoundCallback();
}
SoundProc = proc;
@@ -1479,7 +1479,7 @@ void OSystem_MorphOS::fill_sound(byte *stream, int len)
memset(stream, 0x0, len);
}
-void OSystem_MorphOS::clear_sound_proc()
+void OSystem_MorphOS::clearSoundCallback()
{
if (ScummSoundThread)
{
@@ -1490,7 +1490,7 @@ void OSystem_MorphOS::clear_sound_proc()
}
}
-void OSystem_MorphOS::init_size(uint w, uint h)
+void OSystem_MorphOS::initSize(uint w, uint h)
{
if (ScummBuffer)
{
diff --git a/backends/morphos/morphos.h b/backends/morphos/morphos.h
index deea09bbf7..49ea1a654a 100644
--- a/backends/morphos/morphos.h
+++ b/backends/morphos/morphos.h
@@ -47,7 +47,7 @@ class OSystem_MorphOS : public OSystem
// Set the size of the video bitmap.
// Typically, 320x200
- virtual void init_size(uint w, uint h);
+ virtual void initSize(uint w, uint h);
// Draw a bitmap to screen.
// The screen will not be updated to reflect the new bitmap
@@ -101,9 +101,9 @@ class OSystem_MorphOS : public OSystem
virtual void warp_mouse(int x, int y);
// Set the function to be invoked whenever samples need to be generated
- virtual bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
+ virtual bool setSoundCallback(SoundProc proc, void *param);
void fill_sound (byte * stream, int len);
- void clear_sound_proc();
+ void clearSoundCallback();
virtual uint32 property(int param, Property *value);
diff --git a/backends/null/null.cpp b/backends/null/null.cpp
index d5c53b78ce..6e60044b2c 100644
--- a/backends/null/null.cpp
+++ b/backends/null/null.cpp
@@ -30,7 +30,7 @@
class OSystem_NULL : public OSystem {
public:
void set_palette(const byte *colors, uint start, uint num) {}
- void init_size(uint w, uint h);
+ void initSize(uint w, uint h);
void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) {}
void move_screen(int dx, int dy) {}
void update_screen() {}
@@ -41,7 +41,7 @@ public:
uint32 get_msecs();
void delay_msecs(uint msecs);
bool poll_event(Event *event) { return false; }
- bool set_sound_proc(SoundProc proc, void *param, SoundFormat format) {}
+ bool setSoundCallback(SoundProc proc, void *param) {}
void quit() { exit(1); }
uint32 property(int param, Property *value) { return 0; }
static OSystem *create(int gfx_mode, bool full_screen);
@@ -52,7 +52,7 @@ private:
uint32 get_ticks();
};
-void OSystem_NULL::init_size(uint w, uint h, byte sound) {
+void OSystem_NULL::initSize(uint w, uint h, byte sound) {
msec_start = get_ticks();
}
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp
index 3ecd5197e8..4e4d522f41 100644
--- a/backends/sdl/sdl-common.cpp
+++ b/backends/sdl/sdl-common.cpp
@@ -47,29 +47,23 @@
#define JOY_BUT_SPACE 4
#define JOY_BUT_F5 5
-OSystem *OSystem_SDL_create(int gfx_mode) {
- return OSystem_SDL_Common::create(gfx_mode);
+OSystem *OSystem_SDL_create() {
+ return OSystem_SDL_Common::create();
}
-OSystem *OSystem_SDL_Common::create(int gfx_mode) {
+OSystem *OSystem_SDL_Common::create() {
OSystem_SDL_Common *syst = OSystem_SDL_Common::create_intern();
- syst->init_intern(gfx_mode);
+ syst->init_intern();
return syst;
}
-void OSystem_SDL_Common::init_intern(int gfx_mode) {
+void OSystem_SDL_Common::init_intern() {
int joystick_num = ConfMan.getInt("joystick_num");
uint32 sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
- cksum_valid = false;
- _mode = gfx_mode;
- _full_screen = ConfMan.getBool("fullscreen");
- _adjustAspectRatio = ConfMan.getBool("aspect_ratio");
- _mode_flags = 0;
-
if (joystick_num > -1)
sdlFlags |= SDL_INIT_JOYSTICK;
@@ -84,6 +78,13 @@ void OSystem_SDL_Common::init_intern(int gfx_mode) {
// Enable unicode support if possible
SDL_EnableUNICODE(1);
+ cksum_valid = false;
+ _mode = GFX_DOUBLESIZE;
+ _full_screen = ConfMan.getBool("fullscreen");
+ _adjustAspectRatio = ConfMan.getBool("aspect_ratio");
+ _mode_flags = 0;
+
+
#ifndef MACOSX // Don't set icon on OS X, as we use a nicer external icon there
// Setup the icon
setup_icon();
@@ -133,7 +134,7 @@ OSystem_SDL_Common::~OSystem_SDL_Common() {
SDL_Quit();
}
-void OSystem_SDL_Common::init_size(uint w, uint h) {
+void OSystem_SDL_Common::initSize(uint w, uint h) {
// Avoid redundant res changes
if ((int)w == _screenWidth && (int)h == _screenHeight)
return;
@@ -622,7 +623,7 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
// Alt-Return toggles full screen mode
if (b == KBD_ALT && ev.key.keysym.sym == SDLK_RETURN) {
- property(PROP_TOGGLE_FULLSCREEN, NULL);
+ setFeatureState(kFeatureFullscreenMode, !_full_screen);
break;
}
@@ -654,7 +655,7 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
#else
// Ctrl-m toggles mouse capture
if (b == KBD_CTRL && ev.key.keysym.sym == 'm') {
- property(PROP_TOGGLE_MOUSE_GRAB, NULL);
+ toggleMouseGrab();
break;
}
@@ -695,13 +696,11 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
}
}
-
- Property prop;
int factor = _scaleFactor - 1;
// Ctrl-Alt-a toggles aspect ratio correction
if (ev.key.keysym.sym == 'a') {
- property(PROP_TOGGLE_ASPECT_RATIO, NULL);
+ setFeatureState(kFeatureAspectRatioCorrection, !_adjustAspectRatio);
break;
}
@@ -710,8 +709,7 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
if (ev.key.keysym.sym == '=' || ev.key.keysym.sym == '+' || ev.key.keysym.sym == '-') {
factor += (ev.key.keysym.sym == '-' ? -1 : +1);
if (0 <= factor && factor < 4 && gfxModes[_scalerType][factor] >= 0) {
- prop.gfx_mode = gfxModes[_scalerType][factor];
- property(PROP_SET_GFX_MODE, &prop);
+ setGraphicsMode(gfxModes[_scalerType][factor]);
}
break;
}
@@ -725,8 +723,7 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
assert(factor > 0);
factor--;
}
- prop.gfx_mode = gfxModes[_scalerType][factor];
- property(PROP_SET_GFX_MODE, &prop);
+ setGraphicsMode(gfxModes[_scalerType][factor]);
break;
}
}
@@ -1014,12 +1011,11 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
return false;
}
-bool OSystem_SDL_Common::set_sound_proc(SoundProc proc, void *param, SoundFormat format) {
+bool OSystem_SDL_Common::setSoundCallback(SoundProc proc, void *param) {
SDL_AudioSpec desired;
memset(&desired, 0, sizeof(desired));
- /* only one format supported at the moment */
desired.freq = SAMPLES_PER_SEC;
desired.format = AUDIO_S16SYS;
desired.channels = 2;
@@ -1033,55 +1029,140 @@ bool OSystem_SDL_Common::set_sound_proc(SoundProc proc, void *param, SoundFormat
return true;
}
-void OSystem_SDL_Common::clear_sound_proc() {
+void OSystem_SDL_Common::clearSoundCallback() {
SDL_CloseAudio();
}
-uint32 OSystem_SDL_Common::property(int param, Property *value) {
- switch(param) {
+static const OSystem::GraphicsMode gfx_modes[] = {
+ {"1x", "Normal (no scaling)", GFX_NORMAL},
+ {"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},
+ {0, 0, 0}
+};
+
+const OSystem::GraphicsMode *OSystem_SDL_Common::getSupportedGraphicsModes() const {
+ return gfx_modes;
+}
- case PROP_WANT_RECT_OPTIM:
- _mode_flags |= DF_WANT_RECT_OPTIM;
- break;
+bool OSystem_SDL_Common::setGraphicsMode(int mode) {
+ Common::StackLock lock(_graphicsMutex, this);
- case PROP_GET_FULLSCREEN:
- return _full_screen;
+ // FIXME! HACK, hard coded threshold, not good
+ // Really should check the 'mode' against the list of supported
+ // modes, and then decide whether to accept it.
+ if (mode > 11)
+ return false;
- case PROP_GET_GFX_MODE:
- return _mode;
-
- case PROP_SET_WINDOW_CAPTION:
- SDL_WM_SetCaption(value->caption, value->caption);
- return 1;
-
- case PROP_OPEN_CD:
- if (SDL_InitSubSystem(SDL_INIT_CDROM) == -1)
- _cdrom = NULL;
- else {
- _cdrom = SDL_CDOpen(value->cd_num);
- // Did it open? Check if _cdrom is NULL
- if (!_cdrom) {
- warning("Couldn't open drive: %s", SDL_GetError());
- } else {
- cd_num_loops = 0;
- cd_stop_time = 0;
- cd_end_time = 0;
- }
+ _mode = mode;
+ hotswap_gfx_mode();
+ return true;
+}
+
+int OSystem_SDL_Common::getGraphicsMode() const {
+ return _mode;
+}
+
+
+void OSystem_SDL_Common::setWindowCaption(const char *caption) {
+ SDL_WM_SetCaption(caption, caption);
+}
+
+bool OSystem_SDL_Common::openCD(int drive) {
+ if (SDL_InitSubSystem(SDL_INIT_CDROM) == -1)
+ _cdrom = NULL;
+ else {
+ _cdrom = SDL_CDOpen(drive);
+ // Did it open? Check if _cdrom is NULL
+ if (!_cdrom) {
+ warning("Couldn't open drive: %s", SDL_GetError());
+ } else {
+ cd_num_loops = 0;
+ cd_stop_time = 0;
+ cd_end_time = 0;
}
- break;
+ }
+
+ return (_cdrom != NULL);
+}
+
+int OSystem_SDL_Common::getOutputSampleRate() const {
+ return SAMPLES_PER_SEC;
+}
- case PROP_GET_SAMPLE_RATE:
- return SAMPLES_PER_SEC;
- case PROP_TOGGLE_MOUSE_GRAB:
- if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF)
- SDL_WM_GrabInput(SDL_GRAB_ON);
+bool OSystem_SDL_Common::hasFeature(Feature f) {
+ return
+ (f == kFeatureFullscreenMode) ||
+ (f == kFeatureAspectRatioCorrection) ||
+ (f == kFeatureAutoComputeDirtyRects);
+}
+
+void OSystem_SDL_Common::setFeatureState(Feature f, bool enable) {
+ Common::StackLock lock(_graphicsMutex, this);
+
+ switch (f) {
+ case kFeatureFullscreenMode:
+ if (_full_screen != enable) {
+ //assert(_hwscreen != 0);
+ _full_screen ^= true;
+#ifdef MACOSX
+ // On OS X, SDL_WM_ToggleFullScreen is currently not implemented. Worse,
+ // it still always returns -1. So we simply don't call it at all and
+ // use hotswap_gfx_mode() directly to switch to fullscreen mode.
+ hotswap_gfx_mode();
+#else
+ if (!SDL_WM_ToggleFullScreen(_hwscreen)) {
+ // if ToggleFullScreen fails, achieve the same effect with hotswap gfx mode
+ hotswap_gfx_mode();
+ }
+#endif
+ }
+ break;
+ case kFeatureAspectRatioCorrection:
+ if (_screenHeight == 200 && _adjustAspectRatio != enable) {
+ //assert(_hwscreen != 0);
+ _adjustAspectRatio ^= true;
+ hotswap_gfx_mode();
+ }
+ break;
+ case kFeatureAutoComputeDirtyRects:
+ if (enable)
+ _mode_flags |= DF_WANT_RECT_OPTIM;
else
- SDL_WM_GrabInput(SDL_GRAB_OFF);
+ _mode_flags &= ~DF_WANT_RECT_OPTIM;
+ break;
+ default:
break;
}
+}
- return 0;
+bool OSystem_SDL_Common::getFeatureState(Feature f) {
+ switch (f) {
+ case kFeatureFullscreenMode:
+ return _full_screen;
+ case kFeatureAspectRatioCorrection:
+ return _adjustAspectRatio;
+ case kFeatureAutoComputeDirtyRects:
+ return _mode_flags & DF_WANT_RECT_OPTIM;
+ default:
+ return false;
+ }
+}
+
+void OSystem_SDL_Common::toggleMouseGrab() {
+ if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF)
+ SDL_WM_GrabInput(SDL_GRAB_ON);
+ else
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
}
void OSystem_SDL_Common::quit() {
diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h
index 3d47ca582e..cdd5b0c1de 100644
--- a/backends/sdl/sdl-common.h
+++ b/backends/sdl/sdl-common.h
@@ -33,7 +33,7 @@ class OSystem_SDL_Common : public OSystem {
public:
// Set the size of the video bitmap.
// Typically, 320x200
- void init_size(uint w, uint h);
+ void initSize(uint w, uint h);
// Set colors of the palette
void set_palette(const byte *colors, uint start, uint num);
@@ -72,9 +72,9 @@ public:
bool poll_event(Event *event);
// Set function that generates samples
- bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
+ bool setSoundCallback(SoundProc proc, void *param);
- void clear_sound_proc();
+ void clearSoundCallback();
// Poll CD status
// Returns true if cd audio is playing
@@ -92,8 +92,6 @@ public:
// Quit
void quit();
- // Set a parameter
- uint32 property(int param, Property *value);
// Add a callback timer
void set_timer(TimerProc callback, int timer);
@@ -117,7 +115,21 @@ public:
virtual int16 RGBToColor(uint8 r, uint8 g, uint8 b);
virtual void colorToRGB(int16 color, uint8 &r, uint8 &g, uint8 &b);
- static OSystem *create(int gfx_mode);
+
+ virtual const GraphicsMode *getSupportedGraphicsModes() const;
+ virtual bool setGraphicsMode(int mode);
+ virtual int getGraphicsMode() const;
+
+ virtual void setWindowCaption(const char *caption);
+ virtual bool openCD(int drive);
+ virtual int getOutputSampleRate() const;
+
+ virtual bool hasFeature(Feature f);
+ virtual void setFeatureState(Feature f, bool enable);
+ virtual bool getFeatureState(Feature f);
+
+
+ static OSystem *create();
protected:
OSystem_SDL_Common();
@@ -125,7 +137,7 @@ protected:
static OSystem_SDL_Common *create_intern();
- void init_intern(int gfx_mode);
+ void init_intern();
// unseen game screen
SDL_Surface *_screen;
@@ -218,10 +230,12 @@ protected:
/** Set the position of the virtual mouse cursor. */
void set_mouse_pos(int x, int y);
void fillMouseEvent(Event &event, int x, int y);
+ void toggleMouseGrab();
virtual void load_gfx_mode() = 0;
virtual void unload_gfx_mode() = 0;
+ virtual void hotswap_gfx_mode() = 0;
virtual bool save_screenshot(const char *filename) = 0;
diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp
index 456ed2c5bf..384af1673c 100644
--- a/backends/sdl/sdl.cpp
+++ b/backends/sdl/sdl.cpp
@@ -31,9 +31,6 @@ public:
// Update the dirty areas of the screen
void update_screen();
- // Set a parameter
- uint32 property(int param, Property *value);
-
protected:
SDL_Surface *_hwscreen; // hardware screen
@@ -42,7 +39,7 @@ protected:
virtual void load_gfx_mode();
virtual void unload_gfx_mode();
virtual bool save_screenshot(const char *filename);
- void hotswap_gfx_mode();
+ virtual void hotswap_gfx_mode();
};
OSystem_SDL_Common *OSystem_SDL_Common::create_intern() {
@@ -363,48 +360,6 @@ void OSystem_SDL::update_screen() {
_forceFull = false;
}
-uint32 OSystem_SDL::property(int param, Property *value) {
-
- Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
-
- if (param == PROP_TOGGLE_FULLSCREEN) {
- assert(_hwscreen != 0);
- _full_screen ^= true;
-#ifdef MACOSX
- // On OS X, SDL_WM_ToggleFullScreen is currently not implemented. Worse,
- // it still always returns -1. So we simply don't call it at all and
- // use hotswap_gfx_mode() directly to switch to fullscreen mode.
- hotswap_gfx_mode();
-#else
- if (!SDL_WM_ToggleFullScreen(_hwscreen)) {
- // if ToggleFullScreen fails, achieve the same effect with hotswap gfx mode
- hotswap_gfx_mode();
- }
-#endif
- return 1;
- } else if (param == PROP_SET_GFX_MODE) {
- if (value->gfx_mode > 11) // FIXME! HACK, hard coded threshold, not good
- return 0;
-
- _mode = value->gfx_mode;
- hotswap_gfx_mode();
-
- return 1;
- } else if (param == PROP_TOGGLE_ASPECT_RATIO) {
- if (_screenHeight == 200) {
- assert(_hwscreen != 0);
- _adjustAspectRatio ^= true;
- hotswap_gfx_mode();
- }
- } else if (param == PROP_HAS_SCALER) {
- if (value->gfx_mode <= 11) // FIXME: Hardcoded
- return 1;
- return 0;
- }
-
- return OSystem_SDL_Common::property(param, value);
-}
-
bool OSystem_SDL::save_screenshot(const char *filename) {
assert(_hwscreen != NULL);
diff --git a/backends/wince/wince-sdl.cpp b/backends/wince/wince-sdl.cpp
index df2dbe574c..6fb88a4948 100644
--- a/backends/wince/wince-sdl.cpp
+++ b/backends/wince/wince-sdl.cpp
@@ -219,7 +219,7 @@ void OSystem_WINCE3::get_sample_rate() {
#endif
}
-bool OSystem_WINCE3::set_sound_proc(SoundProc proc, void *param, SoundFormat format) {
+bool OSystem_WINCE3::setSoundCallback(SoundProc proc, void *param) {
SDL_AudioSpec desired;
int thread_priority;
@@ -322,7 +322,7 @@ void OSystem_WINCE3::update_game_settings() {
}
}
-void OSystem_WINCE3::init_size(uint w, uint h) {
+void OSystem_WINCE3::initSize(uint w, uint h) {
if (w == 320 && h == 200)
h = 240; // use the extra 40 pixels height for the toolbar
@@ -333,7 +333,7 @@ void OSystem_WINCE3::init_size(uint w, uint h) {
else
_toolbarHandler.setOffset(400);
- OSystem_SDL_Common::init_size(w, h);
+ OSystem_SDL_Common::initSize(w, h);
update_game_settings();
diff --git a/backends/wince/wince-sdl.h b/backends/wince/wince-sdl.h
index 81c0bb2c26..a8e131f5cd 100644
--- a/backends/wince/wince-sdl.h
+++ b/backends/wince/wince-sdl.h
@@ -46,7 +46,7 @@ public:
// Set a parameter
uint32 property(int param, Property *value);
- void init_size(uint w, uint h);
+ void initSize(uint w, uint h);
// Overloaded from SDL_Common (toolbar handling)
bool poll_event(Event *event);
@@ -61,7 +61,7 @@ public:
// Overloaded from SDL_Commmon
void quit();
// Overloaded from SDL_Commmon (master volume and sample rate subtleties)
- bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
+ bool setSoundCallback(SoundProc proc, void *param);
// GUI and action stuff
void swap_panel_visibility();
diff --git a/backends/x11/x11.cpp b/backends/x11/x11.cpp
index 32e02b848d..3ce815a728 100644
--- a/backends/x11/x11.cpp
+++ b/backends/x11/x11.cpp
@@ -60,7 +60,7 @@ public:
// Set the size of the video bitmap.
// Typically, 320x200
- void init_size(uint w, uint h);
+ void initSize(uint w, uint h);
// Draw a bitmap to screen.
// The screen will not be updated to reflect the new bitmap
@@ -99,9 +99,9 @@ public:
bool poll_event(Event *event);
// Set function that generates samples
- bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
+ bool setSoundCallback(SoundProc proc, void *param);
- void clear_sound_proc();
+ void clearSoundCallback();
// Poll cdrom status
// Returns true if cd audio is playing
@@ -203,7 +203,6 @@ private:
typedef struct {
OSystem::SoundProc sound_proc;
void *param;
- byte format;
} THREAD_PARAM;
#undef CAPTURE_SOUND
@@ -417,7 +416,7 @@ uint32 OSystem_X11::get_msecs()
((current_time.tv_usec - start_time.tv_usec) / 1000));
}
-void OSystem_X11::init_size(uint w, uint h)
+void OSystem_X11::initSize(uint w, uint h)
{
static XShmSegmentInfo shminfo;
@@ -456,24 +455,20 @@ void OSystem_X11::init_size(uint w, uint h)
palette = (uint16 *)calloc(256, sizeof(uint16));
}
-bool OSystem_X11::set_sound_proc(SoundProc proc, void *param, SoundFormat format)
+bool OSystem_X11::setSoundCallback(SoundProc proc, void *param)
{
static THREAD_PARAM thread_param;
/* And finally start the music thread */
thread_param.param = param;
thread_param.sound_proc = proc;
- thread_param.format = format;
- if (format == SOUND_16BIT)
- pthread_create(&sound_thread, NULL, sound_and_music_thread, (void *)&thread_param);
- else
- warning("Only support 16 bit sound for now. Disabling sound ");
+ pthread_create(&sound_thread, NULL, sound_and_music_thread, (void *)&thread_param);
return true;
}
-void OSystem_X11::clear_sound_proc() {
+void OSystem_X11::clearSoundCallback() {
// TODO implement this...
// The sound_thread has to be stopped in a nice way. In particular,
// using pthread_kill would be a bad idea. Rather, use pthread_cancel,