[Scummvm-cvs-logs] CVS: scummvm/backends/sdl events.cpp,1.8,1.9 graphics.cpp,1.14,1.15 sdl-common.h,1.64,1.65 sdl.cpp,1.73,1.74

Max Horn fingolfin at users.sourceforge.net
Fri Oct 15 15:31:31 CEST 2004


Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16486

Modified Files:
	events.cpp graphics.cpp sdl-common.h sdl.cpp 
Log Message:
Renamed _scaler_proc -> _scalerProc; cleaned up _scalerType handling

Index: events.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/events.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- events.cpp	28 Sep 2004 20:19:23 -0000	1.8
+++ events.cpp	15 Oct 2004 22:28:12 -0000	1.9
@@ -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 @@
 
 			// 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 @@
 
 
 				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];
 					}
 				}

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/graphics.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- graphics.cpp	13 Oct 2004 06:36:29 -0000	1.14
+++ graphics.cpp	15 Oct 2004 22:28:12 -0000	1.15
@@ -112,12 +112,23 @@
 	}
 
 	_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 @@
 		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 @@
 						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);
 				}
 

Index: sdl-common.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- sdl-common.h	28 Sep 2004 20:19:23 -0000	1.64
+++ sdl-common.h	15 Oct 2004 22:28:12 -0000	1.65
@@ -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 @@
 	};
 
 	bool _forceFull; // Force full redraw on next updateScreen
-	ScalerProc *_scaler_proc;
+	ScalerProc *_scalerProc;
+	int _scalerType;
 	int _scaleFactor;
 	int _mode;
 	bool _full_screen;

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- sdl.cpp	28 Sep 2004 20:19:23 -0000	1.73
+++ sdl.cpp	15 Oct 2004 22:28:12 -0000	1.74
@@ -65,14 +65,17 @@
 #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 @@
 	_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),





More information about the Scummvm-git-logs mailing list