[Scummvm-cvs-logs] CVS: scummvm sdl.cpp,1.116,1.117

Max Horn fingolfin at users.sourceforge.net
Thu May 9 11:24:06 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv12678

Modified Files:
	sdl.cpp 
Log Message:
fix for #553206 (Palette latencies)

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sdl.cpp,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- sdl.cpp	9 May 2002 17:39:38 -0000	1.116
+++ sdl.cpp	9 May 2002 18:23:33 -0000	1.117
@@ -105,15 +105,13 @@
 	SDL_Surface *sdl_screen;
 	SDL_Surface *sdl_hwscreen;
 	SDL_Surface *sdl_tmpscreen;
-	SDL_Surface *sdl_palscreen;
 	SDL_CD *cdrom;
 
 	enum {
-		DF_FORCE_FULL_ON_PALETTE = 1,
-		DF_WANT_RECT_OPTIM = 2,
-		DF_2xSAI = 4,
-		DF_SEPARATE_TEMPSCREEN = 8,
-		DF_UPDATE_EXPAND_1_PIXEL = 16,
+		DF_WANT_RECT_OPTIM			= 1 << 0,
+		DF_REAL_8BIT				= 1 << 1,
+		DF_SEPARATE_TEMPSCREEN		= 1 << 2,
+		DF_UPDATE_EXPAND_1_PIXEL	= 1 << 3
 	};
 
 	int _mode;
@@ -127,13 +125,10 @@
 
 	enum {
 		NUM_DIRTY_RECT = 100,
-		//SCREEN_WIDTH = 320,
-		//SCREEN_HEIGHT = 240,
-		//CKSUM_NUM = (SCREEN_WIDTH*SCREEN_HEIGHT/(8*8)),
 
 		MAX_MOUSE_W = 40,
 		MAX_MOUSE_H = 40,
-		MAX_SCALING = 3,
+		MAX_SCALING = 3
 	};
 
 	int SCREEN_WIDTH, SCREEN_HEIGHT, CKSUM_NUM;
@@ -309,7 +304,7 @@
 
 	if (_sai_func) {
 		uint16 *tmp_screen = (uint16*)calloc((SCREEN_WIDTH+3)*(SCREEN_HEIGHT+3),sizeof(uint16));
-		_mode_flags = DF_FORCE_FULL_ON_PALETTE | DF_WANT_RECT_OPTIM | DF_2xSAI | DF_SEPARATE_TEMPSCREEN | DF_UPDATE_EXPAND_1_PIXEL;
+		_mode_flags = DF_WANT_RECT_OPTIM | DF_SEPARATE_TEMPSCREEN | DF_UPDATE_EXPAND_1_PIXEL;
 
 		sdl_hwscreen = SDL_SetVideoMode(SCREEN_WIDTH * scaling, SCREEN_HEIGHT * scaling, 16, 
 			_full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
@@ -332,7 +327,6 @@
 		if (sdl_tmpscreen == NULL)
 			error("sdl_tmpscreen failed");
 		
-		sdl_palscreen = sdl_screen;
 	} else {
 		switch(scaling) {
 		case 3:
@@ -346,7 +340,7 @@
 			break;
 		}
 
-		_mode_flags = DF_WANT_RECT_OPTIM;
+		_mode_flags = DF_WANT_RECT_OPTIM | DF_REAL_8BIT;
 
 		sdl_hwscreen = SDL_SetVideoMode(SCREEN_WIDTH * scaling, SCREEN_HEIGHT * scaling, 8, 
 			_full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
@@ -355,7 +349,6 @@
 			error("sdl_hwscreen failed");
 		
 		sdl_tmpscreen = sdl_screen;
-		sdl_palscreen = sdl_hwscreen;
 	}
 }
 
@@ -546,16 +539,15 @@
 	/* First make sure the mouse is drawn, if it should be drawn. */
 	draw_mouse();
 	
-
-	if (_palette_changed_last != 0) {
-		SDL_SetColors(sdl_palscreen, _cur_pal + _palette_changed_first, 
+	// Palette update in case we are NOT in "real" 8 bit color mode
+	if (((_mode_flags & DF_REAL_8BIT) == 0) && _palette_changed_last != 0) {
+		SDL_SetColors(sdl_screen, _cur_pal + _palette_changed_first, 
 			_palette_changed_first,
 			_palette_changed_last - _palette_changed_first);
 		
 		_palette_changed_last = 0;
 
-		if (_mode_flags & DF_FORCE_FULL_ON_PALETTE)
-			force_full = true;
+		force_full = true;
 	}
 
 	if (_current_shake_pos != _new_shake_pos) {
@@ -587,7 +579,7 @@
 
 
 	/* Convert appropriate parts of the image into 16bpp */
-	if (_mode_flags & DF_2xSAI) {
+	if ((_mode_flags & DF_REAL_8BIT) == 0) {
 		SDL_Rect dst;
 		for(r=dirty_rect_list; r!=last_rect; ++r) {
 			dst = *r;
@@ -604,7 +596,7 @@
 	srcPitch = sdl_tmpscreen->pitch;
 	dstPitch = sdl_hwscreen->pitch;
 
-	if (_mode_flags & DF_2xSAI) {
+	if ((_mode_flags & DF_REAL_8BIT) == 0) {
 		for(r=dirty_rect_list; r!=last_rect; ++r) {
 			register int dst_y = r->y + _current_shake_pos;
 			register int dst_h = 0;
@@ -654,8 +646,18 @@
 	SDL_UnlockSurface(sdl_tmpscreen);
 	SDL_UnlockSurface(sdl_hwscreen);
 
-	SDL_UpdateRects(sdl_hwscreen, num_dirty_rects, dirty_rect_list);
+	// Palette update in case we are in "real" 8 bit color mode
+	if (_mode_flags & DF_REAL_8BIT && _palette_changed_last != 0) {
+		SDL_SetColors(sdl_hwscreen, _cur_pal + _palette_changed_first, 
+			_palette_changed_first,
+			_palette_changed_last - _palette_changed_first);
+		
+		_palette_changed_last = 0;
+	}
 	
+	// Finally, blit all our changes to the screen
+	SDL_UpdateRects(sdl_hwscreen, num_dirty_rects, dirty_rect_list);
+
 	num_dirty_rects = 0;
 	force_full = false;
 }
@@ -854,7 +856,10 @@
 	force_full = true;
 
 	/* reset palette */
-	SDL_SetColors(sdl_palscreen, _cur_pal, 0, 256);
+	if (_mode_flags & DF_REAL_8BIT)
+		SDL_SetColors(sdl_hwscreen, _cur_pal, 0, 256);
+	else
+		SDL_SetColors(sdl_screen, _cur_pal, 0, 256);
 
 	/* blit image */
 	OSystem_SDL::copy_rect(bak_mem, SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);





More information about the Scummvm-git-logs mailing list