aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMax Horn2004-10-15 22:28:12 +0000
committerMax Horn2004-10-15 22:28:12 +0000
commitbb462f64e0c374fea76a6e513d29b60d049f9aa0 (patch)
tree9fa8e66007868b584cb9d871becbc44d151f0f79 /backends
parentccb8d04f35baeca212ef535c208f7e7abdc62ebf (diff)
downloadscummvm-rg350-bb462f64e0c374fea76a6e513d29b60d049f9aa0.tar.gz
scummvm-rg350-bb462f64e0c374fea76a6e513d29b60d049f9aa0.tar.bz2
scummvm-rg350-bb462f64e0c374fea76a6e513d29b60d049f9aa0.zip
Renamed _scaler_proc -> _scalerProc; cleaned up _scalerType handling
svn-id: r15563
Diffstat (limited to 'backends')
-rw-r--r--backends/sdl/events.cpp33
-rw-r--r--backends/sdl/graphics.cpp17
-rw-r--r--backends/sdl/sdl-common.h15
-rw-r--r--backends/sdl/sdl.cpp7
4 files changed, 35 insertions, 37 deletions
diff --git a/backends/sdl/events.cpp b/backends/sdl/events.cpp
index 48686908a7..ad5801a380 100644
--- a/backends/sdl/events.cpp
+++ b/backends/sdl/events.cpp
@@ -39,17 +39,6 @@
#define JOY_BUT_F5 5
-static const int s_gfxModeSwitchTable[][4] = {
- { GFX_NORMAL, GFX_DOUBLESIZE, GFX_TRIPLESIZE, -1 },
- { GFX_NORMAL, GFX_ADVMAME2X, GFX_ADVMAME3X, -1 },
- { GFX_NORMAL, GFX_HQ2X, GFX_HQ3X, -1 },
- { GFX_NORMAL, GFX_2XSAI, -1, -1 },
- { GFX_NORMAL, GFX_SUPER2XSAI, -1, -1 },
- { GFX_NORMAL, GFX_SUPEREAGLE, -1, -1 },
- { GFX_NORMAL, GFX_TV2X, -1, -1 },
- { GFX_NORMAL, GFX_DOTMATRIX, -1, -1 }
- };
-
static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode)
@@ -252,25 +241,7 @@ bool OSystem_SDL::pollEvent(Event &event) {
// Ctrl-Alt-<key> will change the GFX mode
if ((b & (KBD_CTRL|KBD_ALT)) == (KBD_CTRL|KBD_ALT)) {
- // FIXME EVIL HACK: This shouldn't be a static int, rather it
- // should be a member variable. Furthermore, it shouldn't be
- // set in this code, rather it should be set by load_gfx_mode().
- // But for now this quick&dirty hack works.
- static int _scalerType = 0;
- if (_mode != GFX_NORMAL) {
- // Try to figure out which gfx mode "group" we are in
- // This is just a temporary hack until the proper solution
- // (i.e. code in load_gfx_mode()) is in effect.
- for (int i = 0; i < ARRAYSIZE(s_gfxModeSwitchTable); i++) {
- if (s_gfxModeSwitchTable[i][1] == _mode || s_gfxModeSwitchTable[i][2] == _mode) {
- _scalerType = i;
- break;
- }
- }
- }
- int factor = _scaleFactor - 1;
-
// Ctrl-Alt-a toggles aspect ratio correction
if (ev.key.keysym.sym == 'a') {
setFeatureState(kFeatureAspectRatioCorrection, !_adjustAspectRatio);
@@ -294,13 +265,13 @@ bool OSystem_SDL::pollEvent(Event &event) {
int newMode = -1;
+ int factor = _scaleFactor - 1;
// Increase/decrease the scale factor
- // TODO: Shall we 'wrap around' here?
if (ev.key.keysym.sym == SDLK_EQUALS || ev.key.keysym.sym == SDLK_PLUS || ev.key.keysym.sym == SDLK_MINUS ||
ev.key.keysym.sym == SDLK_KP_PLUS || ev.key.keysym.sym == SDLK_KP_MINUS) {
factor += (ev.key.keysym.sym == SDLK_MINUS || ev.key.keysym.sym == SDLK_KP_MINUS) ? -1 : +1;
- if (0 <= factor && factor < 4 && s_gfxModeSwitchTable[_scalerType][factor] >= 0) {
+ if (0 <= factor && factor <= 3) {
newMode = s_gfxModeSwitchTable[_scalerType][factor];
}
}
diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp
index f074f0e34d..f6b981110d 100644
--- a/backends/sdl/graphics.cpp
+++ b/backends/sdl/graphics.cpp
@@ -112,12 +112,23 @@ bool OSystem_SDL::setGraphicsMode(int mode) {
}
_mode = mode;
- _scaler_proc = newScalerProc;
+ _scalerProc = newScalerProc;
if (newScaleFactor != _scaleFactor) {
_scaleFactor = newScaleFactor;
hotswap_gfx_mode();
}
+ // Determine the "scaler type", i.e. essentially an index into the
+ // s_gfxModeSwitchTable array defined in events.cpp.
+ if (_mode != GFX_NORMAL) {
+ for (int i = 0; i < ARRAYSIZE(s_gfxModeSwitchTable); i++) {
+ if (s_gfxModeSwitchTable[i][1] == _mode || s_gfxModeSwitchTable[i][2] == _mode) {
+ _scalerType = i;
+ break;
+ }
+ }
+ }
+
if (!_screen)
return true;
@@ -380,7 +391,7 @@ void OSystem_SDL::internUpdateScreen() {
uint32 srcPitch, dstPitch;
SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects;
- if (_scaler_proc == Normal1x && !_adjustAspectRatio) {
+ if (_scalerProc == Normal1x && !_adjustAspectRatio) {
SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen;
for (r = _dirty_rect_list; r != last_rect; ++r) {
dst = *r;
@@ -428,7 +439,7 @@ void OSystem_SDL::internUpdateScreen() {
dst_y = real2Aspect(dst_y);
}
- _scaler_proc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
+ _scalerProc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
(byte *)_hwscreen->pixels + r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h);
}
diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h
index 6ccaf26a07..fde699ae6b 100644
--- a/backends/sdl/sdl-common.h
+++ b/backends/sdl/sdl-common.h
@@ -36,6 +36,18 @@
#define USE_OSD 1
#endif
+static const int s_gfxModeSwitchTable[][4] = {
+ { GFX_NORMAL, GFX_DOUBLESIZE, GFX_TRIPLESIZE, -1 },
+ { GFX_NORMAL, GFX_ADVMAME2X, GFX_ADVMAME3X, -1 },
+ { GFX_NORMAL, GFX_HQ2X, GFX_HQ3X, -1 },
+ { GFX_NORMAL, GFX_2XSAI, -1, -1 },
+ { GFX_NORMAL, GFX_SUPER2XSAI, -1, -1 },
+ { GFX_NORMAL, GFX_SUPEREAGLE, -1, -1 },
+ { GFX_NORMAL, GFX_TV2X, -1, -1 },
+ { GFX_NORMAL, GFX_DOTMATRIX, -1, -1 }
+ };
+
+
class OSystem_SDL : public OSystem {
public:
OSystem_SDL();
@@ -181,7 +193,8 @@ protected:
};
bool _forceFull; // Force full redraw on next updateScreen
- ScalerProc *_scaler_proc;
+ ScalerProc *_scalerProc;
+ int _scalerType;
int _scaleFactor;
int _mode;
bool _full_screen;
diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp
index f6ad91b452..7883d292f5 100644
--- a/backends/sdl/sdl.cpp
+++ b/backends/sdl/sdl.cpp
@@ -65,14 +65,17 @@ void OSystem_SDL::init_intern() {
#ifndef _WIN32_WCE
_mode = GFX_DOUBLESIZE;
_scaleFactor = 2;
- _scaler_proc = Normal2x;
+ _scalerProc = Normal2x;
_full_screen = ConfMan.getBool("fullscreen");
_adjustAspectRatio = ConfMan.getBool("aspect_ratio");
#else
_mode = GFX_NORMAL;
+ _scaleFactor = 1;
+ _scalerProc = Normal1x;
_full_screen = true;
_adjustAspectRatio = false;
#endif
+ _scalerType = 0;
_mode_flags = 0;
@@ -96,7 +99,7 @@ OSystem_SDL::OSystem_SDL()
_hwscreen(0), _screen(0), _screenWidth(0), _screenHeight(0),
_tmpscreen(0), _overlayVisible(false),
_samplesPerSec(0),
- _cdrom(0), _scaler_proc(0), _modeChanged(false), _dirty_checksums(0),
+ _cdrom(0), _scalerProc(0), _modeChanged(false), _dirty_checksums(0),
_mouseVisible(false), _mouseDrawn(false), _mouseData(0),
_mouseHotspotX(0), _mouseHotspotY(0),
_currentShakePos(0), _newShakePos(0),