atari:gem: Simplify palette changes by removing most temp variables SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Thu, 12 Oct 2017 22:49:00 +0200
branchSDL-1.2
changeset 11608850f1a16dc81
parent 11580 b28174b10269
child 11609 3d3ad743ac60
atari:gem: Simplify palette changes by removing most temp variables
src/video/gem/SDL_gemevents.c
src/video/gem/SDL_gemvideo.c
     1.1 --- a/src/video/gem/SDL_gemevents.c	Mon Oct 09 21:36:10 2017 +0200
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Thu Oct 12 22:49:00 2017 +0200
     1.3 @@ -208,9 +208,7 @@
     1.4  			/* Continue with TOP event processing */
     1.5  		case WM_ONTOP:
     1.6  			SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
     1.7 -			if (VDI_setpalette) {
     1.8 -				VDI_setpalette(this, VDI_curpalette);
     1.9 -			}
    1.10 +			VDI_setpalette(this, VDI_curpalette);
    1.11  			break;
    1.12  		case WM_REDRAW:
    1.13  			if (!GEM_lock_redraw) {
    1.14 @@ -283,9 +281,7 @@
    1.15  			/* Continue with BOTTOM event processing */
    1.16  		case WM_UNTOPPED:
    1.17  			SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
    1.18 -			if (VDI_setpalette) {
    1.19 -				VDI_setpalette(this, VDI_oldpalette);
    1.20 -			}
    1.21 +			VDI_setpalette(this, VDI_oldpalette);
    1.22  			break;
    1.23  	}
    1.24  
     2.1 --- a/src/video/gem/SDL_gemvideo.c	Mon Oct 09 21:36:10 2017 +0200
     2.2 +++ b/src/video/gem/SDL_gemvideo.c	Thu Oct 12 22:49:00 2017 +0200
     2.3 @@ -506,15 +506,15 @@
     2.4  {
     2.5  	short oldrgb[3], rgb[3]={0,0,0};
     2.6  
     2.7 -	vq_color(VDI_handle, vdi_index[0], 0, oldrgb);
     2.8 -	vs_color(VDI_handle, vdi_index[0], rgb);
     2.9 +	vq_color(VDI_handle, 0, 0, oldrgb);
    2.10 +	vs_color(VDI_handle, 0, rgb);
    2.11  
    2.12  	vsf_color(VDI_handle,0);
    2.13  	vsf_interior(VDI_handle,1);
    2.14  	vsf_perimeter(VDI_handle,0);
    2.15  	v_bar(VDI_handle, pxy);
    2.16  
    2.17 -	vs_color(VDI_handle, vdi_index[0], oldrgb);
    2.18 +	vs_color(VDI_handle, 0, oldrgb);
    2.19  }
    2.20  
    2.21  void GEM_ClearRectXYWH(_THIS, short *rect)
    2.22 @@ -546,17 +546,9 @@
    2.23  static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3])
    2.24  {
    2.25  	int i;
    2.26 -	short rgb[3];
    2.27 -
    2.28 -	if (VDI_oldnumcolors==0)
    2.29 -		return;
    2.30  
    2.31  	for(i = 0; i < VDI_oldnumcolors; i++) {
    2.32 -		rgb[0] = newpal[i][0];
    2.33 -		rgb[1] = newpal[i][1];
    2.34 -		rgb[2] = newpal[i][2];
    2.35 -
    2.36 -		vs_color(VDI_handle, i, rgb);
    2.37 +		vs_color(VDI_handle, i, (short *) newpal[i]);
    2.38  	}
    2.39  }
    2.40  
    2.41 @@ -1133,19 +1125,15 @@
    2.42  
    2.43  	for(i = 0; i < ncolors; i++)
    2.44  	{
    2.45 -		int r, g, b;
    2.46 -		short rgb[3];
    2.47 +		int j;
    2.48  
    2.49 -		r = colors[i].r;
    2.50 -		g = colors[i].g;
    2.51 -		b = colors[i].b;
    2.52 -
    2.53 -		rgb[0] = VDI_curpalette[i][0] = (1000 * r) / 255;
    2.54 -		rgb[1] = VDI_curpalette[i][1] = (1000 * g) / 255;
    2.55 -		rgb[2] = VDI_curpalette[i][2] = (1000 * b) / 255;
    2.56 +		j = vdi_index[firstcolor+i];
    2.57 +		VDI_curpalette[j][0] = (1000 * colors[i].r) / 255;
    2.58 +		VDI_curpalette[j][1] = (1000 * colors[i].g) / 255;
    2.59 +		VDI_curpalette[j][2] = (1000 * colors[i].b) / 255;
    2.60  
    2.61  		if (has_input_focus) {
    2.62 -			vs_color(VDI_handle, vdi_index[firstcolor+i], rgb);
    2.63 +			vs_color(VDI_handle, j, (short *) VDI_curpalette[j]);
    2.64  		}
    2.65  	}
    2.66