[Scummvm-cvs-logs] CVS: scummvm/backends/sdl sdl-common.cpp,1.14,1.15 sdl-common.h,1.6,1.7 sdl.cpp,1.11,1.12 sdl_gl.cpp,1.14,1.15

Max Horn fingolfin at users.sourceforge.net
Wed Nov 13 06:39:10 CET 2002


Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory usw-pr-cvs1:/tmp/cvs-serv25096

Modified Files:
	sdl-common.cpp sdl-common.h sdl.cpp sdl_gl.cpp 
Log Message:
properly initialize everything -> works w/o our custom new/delete now!

Index: sdl-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- sdl-common.cpp	21 Oct 2002 22:25:52 -0000	1.14
+++ sdl-common.cpp	13 Nov 2002 14:38:48 -0000	1.15
@@ -68,13 +68,19 @@
 
 OSystem_SDL_Common::OSystem_SDL_Common()
 	: _screen(0), _screenWidth(0), _screenHeight(0), _cdrom(0),
-	_dirty_checksums(0), _currentShakePos(0), _newShakePos(0)
+	_dirty_checksums(0),
+	_mouseVisible(false), _mouseDrawn(false), _mouseData(0),
+	_mouseHotspotX(0), _mouseHotspotY(0),
+	_currentShakePos(0), _newShakePos(0)
 {
 	// allocate palette storage
 	_currentPalette = (SDL_Color*)calloc(sizeof(SDL_Color), 256);
 
 	// allocate the dirty rect storage
 	_mouseBackup = (byte*)malloc(MAX_MOUSE_W * MAX_MOUSE_H * MAX_SCALING * 2);
+	
+	// reset mouse state
+	memset(&km, 0, sizeof(km));
 }
 
 OSystem_SDL_Common::~OSystem_SDL_Common()
@@ -382,16 +388,16 @@
 }
 	
 void OSystem_SDL_Common::set_mouse_pos(int x, int y) {
-	if (x != _mouse_cur_state.x || y != _mouse_cur_state.y) {
-		_mouse_cur_state.x = x;
-		_mouse_cur_state.y = y;
+	if (x != _mouseCurState.x || y != _mouseCurState.y) {
+		_mouseCurState.x = x;
+		_mouseCurState.y = y;
 		undraw_mouse();
 	}
 }
 	
 void OSystem_SDL_Common::set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) {
-	_mouse_cur_state.w = w;
-	_mouse_cur_state.h = h;
+	_mouseCurState.w = w;
+	_mouseCurState.h = h;
 
 	_mouseHotspotX = hotspot_x;
 	_mouseHotspotY = hotspot_y;
@@ -709,10 +715,10 @@
 	if (_mouseDrawn || !_mouseVisible)
 		return;
 
-	int x = _mouse_cur_state.x - _mouseHotspotX;
-	int y = _mouse_cur_state.y - _mouseHotspotY;
-	int w = _mouse_cur_state.w;
-	int h = _mouse_cur_state.h;
+	int x = _mouseCurState.x - _mouseHotspotX;
+	int y = _mouseCurState.y - _mouseHotspotY;
+	int w = _mouseCurState.w;
+	int h = _mouseCurState.h;
 	byte color;
 	byte *src = _mouseData;		// Image representing the mouse
 	byte *bak = _mouseBackup;		// Surface used to backup the area obscured by the mouse
@@ -726,7 +732,7 @@
 	}
 	if (y < 0) {
 		h += y;
-		src -= y * _mouse_cur_state.w;
+		src -= y * _mouseCurState.w;
 		y = 0;
 	}
 	if (w > _screenWidth - x)
@@ -740,10 +746,10 @@
 
 	// Store the bounding box so that undraw mouse can restore the area the
 	// mouse currently covers to its original content.
-	_mouse_old_state.x = x;
-	_mouse_old_state.y = y;
-	_mouse_old_state.w = w;
-	_mouse_old_state.h = h;
+	_mouseOldState.x = x;
+	_mouseOldState.y = y;
+	_mouseOldState.w = w;
+	_mouseOldState.h = h;
 
 	// Draw the mouse cursor; backup the covered area in "bak"
 
@@ -764,7 +770,7 @@
 			dst++;
 			width--;
 		}
-		src += _mouse_cur_state.w - w;
+		src += _mouseCurState.w - w;
 		bak += MAX_MOUSE_W - w;
 		dst += _screenWidth - w;
 		h--;
@@ -785,10 +791,10 @@
 		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
 
 	byte *dst, *bak = _mouseBackup;
-	const int old_mouse_x = _mouse_old_state.x;
-	const int old_mouse_y = _mouse_old_state.y;
-	const int old_mouse_w = _mouse_old_state.w;
-	const int old_mouse_h = _mouse_old_state.h;
+	const int old_mouse_x = _mouseOldState.x;
+	const int old_mouse_y = _mouseOldState.y;
+	const int old_mouse_w = _mouseOldState.w;
+	const int old_mouse_h = _mouseOldState.h;
 	int x, y;
 
 	// No need to do clipping here, since draw_mouse() did that already

Index: sdl-common.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- sdl-common.h	14 Oct 2002 11:02:27 -0000	1.6
+++ sdl-common.h	13 Nov 2002 14:38:49 -0000	1.7
@@ -153,14 +153,15 @@
 
 	struct MousePos {
 		int16 x, y, w, h;
+		MousePos() : x(0), y(0), w(0), h(0) {}
 	};
 
 	bool _mouseVisible;
 	bool _mouseDrawn;
 	byte *_mouseData;
 	byte *_mouseBackup;
-	MousePos _mouse_cur_state;
-	MousePos _mouse_old_state;
+	MousePos _mouseCurState;
+	MousePos _mouseOldState;
 	int16 _mouseHotspotX;
 	int16 _mouseHotspotY;
 

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- sdl.cpp	21 Oct 2002 22:25:52 -0000	1.11
+++ sdl.cpp	13 Nov 2002 14:38:49 -0000	1.12
@@ -27,7 +27,7 @@
 
 class OSystem_SDL_Normal : public OSystem_SDL_Common {
 public:
-	OSystem_SDL_Normal() : sdl_tmpscreen(0), sdl_hwscreen(0), _overlay_visible(false) {}
+	OSystem_SDL_Normal();
 
 	// Set colors of the palette
 	void set_palette(const byte *colors, uint start, uint num);
@@ -55,20 +55,26 @@
 
 	ScalerProc *_scaler_proc;
 
+	int TMP_SCREEN_WIDTH;
+
 	virtual void draw_mouse();
 	virtual void undraw_mouse();
 
 	virtual void load_gfx_mode();
 	virtual void unload_gfx_mode();
 	void hotswap_gfx_mode();
-	
-	int TMP_SCREEN_WIDTH;
 };
 
 OSystem_SDL_Common *OSystem_SDL_Common::create() {
 	return new OSystem_SDL_Normal();
 }
 
+OSystem_SDL_Normal::OSystem_SDL_Normal()
+	 : sdl_tmpscreen(0), sdl_hwscreen(0), _overlay_visible(false),
+	   _scaler_proc(0), TMP_SCREEN_WIDTH(0)
+{
+}
+
 void OSystem_SDL_Normal::set_palette(const byte *colors, uint start, uint num) {
 	const byte *b = colors;
 	uint i;
@@ -95,10 +101,10 @@
 	if (_mouseDrawn || !_mouseVisible)
 		return;
 
-	int x = _mouse_cur_state.x - _mouseHotspotX;
-	int y = _mouse_cur_state.y - _mouseHotspotY;
-	int w = _mouse_cur_state.w;
-	int h = _mouse_cur_state.h;
+	int x = _mouseCurState.x - _mouseHotspotX;
+	int y = _mouseCurState.y - _mouseHotspotY;
+	int w = _mouseCurState.w;
+	int h = _mouseCurState.h;
 	byte color;
 	byte *src = _mouseData;		// Image representing the mouse
 	uint16 *bak = (uint16*)_mouseBackup;	// Surface used to backup the area obscured by the mouse
@@ -112,7 +118,7 @@
 	}
 	if (y < 0) {
 		h += y;
-		src -= y * _mouse_cur_state.w;
+		src -= y * _mouseCurState.w;
 		y = 0;
 	}
 
@@ -127,10 +133,10 @@
 
 	// Store the bounding box so that undraw mouse can restore the area the
 	// mouse currently covers to its original content.
-	_mouse_old_state.x = x;
-	_mouse_old_state.y = y;
-	_mouse_old_state.w = w;
-	_mouse_old_state.h = h;
+	_mouseOldState.x = x;
+	_mouseOldState.y = y;
+	_mouseOldState.w = w;
+	_mouseOldState.h = h;
 
 	// Draw the mouse cursor; backup the covered area in "bak"
 
@@ -151,7 +157,7 @@
 			dst++;
 			width--;
 		}
-		src += _mouse_cur_state.w - w;
+		src += _mouseCurState.w - w;
 		bak += MAX_MOUSE_W - w;
 		dst += TMP_SCREEN_WIDTH - w;
 		h--;
@@ -176,10 +182,10 @@
 		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
 
 	uint16 *dst, *bak = (uint16 *)_mouseBackup;
-	const int old_mouse_x = _mouse_old_state.x;
-	const int old_mouse_y = _mouse_old_state.y;
-	const int old_mouse_w = _mouse_old_state.w;
-	const int old_mouse_h = _mouse_old_state.h;
+	const int old_mouse_x = _mouseOldState.x;
+	const int old_mouse_y = _mouseOldState.y;
+	const int old_mouse_w = _mouseOldState.w;
+	const int old_mouse_h = _mouseOldState.h;
 	int x, y;
 
 	// No need to do clipping here, since draw_mouse() did that already

Index: sdl_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- sdl_gl.cpp	30 Oct 2002 02:31:49 -0000	1.14
+++ sdl_gl.cpp	13 Nov 2002 14:38:49 -0000	1.15
@@ -109,10 +109,10 @@
 	if (_mouseDrawn || !_mouseVisible)
 		return;
 
-	int x = _mouse_cur_state.x - _mouseHotspotX;
-	int y = _mouse_cur_state.y - _mouseHotspotY;
-	int w = _mouse_cur_state.w;
-	int h = _mouse_cur_state.h;
+	int x = _mouseCurState.x - _mouseHotspotX;
+	int y = _mouseCurState.y - _mouseHotspotY;
+	int w = _mouseCurState.w;
+	int h = _mouseCurState.h;
 	byte color;
 	byte *src = _mouseData;		// Image representing the mouse
 	uint16 *bak = (uint16*)_mouseBackup;	// Surface used to backup the area obscured by the mouse
@@ -126,7 +126,7 @@
 	}
 	if (y < 0) {
 		h += y;
-		src -= y * _mouse_cur_state.w;
+		src -= y * _mouseCurState.w;
 		y = 0;
 	}
 
@@ -141,10 +141,10 @@
 
 	// Store the bounding box so that undraw mouse can restore the area the
 	// mouse currently covers to its original content.
-	_mouse_old_state.x = x;
-	_mouse_old_state.y = y;
-	_mouse_old_state.w = w;
-	_mouse_old_state.h = h;
+	_mouseOldState.x = x;
+	_mouseOldState.y = y;
+	_mouseOldState.w = w;
+	_mouseOldState.h = h;
 
 	// Draw the mouse cursor; backup the covered area in "bak"
 
@@ -162,7 +162,7 @@
 			dst++;
 			width--;
 		}
-		src += _mouse_cur_state.w - w;
+		src += _mouseCurState.w - w;
 		bak += MAX_MOUSE_W - w;
 		dst += TMP_SCREEN_WIDTH - w;
 		h--;
@@ -190,10 +190,10 @@
 		error("SDL_LockSurface failed: %s.\n", SDL_GetError());
 
 	uint16 *dst, *bak = (uint16 *)_mouseBackup;
-	const int old_mouse_x = _mouse_old_state.x;
-	const int old_mouse_y = _mouse_old_state.y;
-	const int old_mouse_w = _mouse_old_state.w;
-	const int old_mouse_h = _mouse_old_state.h;
+	const int old_mouse_x = _mouseOldState.x;
+	const int old_mouse_y = _mouseOldState.y;
+	const int old_mouse_w = _mouseOldState.w;
+	const int old_mouse_h = _mouseOldState.h;
 	int x, y;
 
 	// No need to do clipping here, since draw_mouse() did that already
@@ -445,9 +445,9 @@
 /*		    SDL_FillRect(tmpSurface, &full, 0);
 		    fb2gl.blit16(tmpSurface,1,&full,0,_glScreenStart);
 		    fb2gl.display();
-		    double x = (double)((_mouse_cur_state.x) 
+		    double x = (double)((_mouseCurState.x) 
 			- (_screenWidth/2)) / (_screenWidth/2);
-		    double y = (double)((_mouse_cur_state.y) 
+		    double y = (double)((_mouseCurState.y) 
 			- (_screenHeight/2)) / (_screenHeight/2);
 		    glTranslatef(-x,y,0);
 */





More information about the Scummvm-git-logs mailing list