Navigation Menu

Skip to content

Commit

Permalink
atari:gem: Simplify palette changes by removing most temp variables
Browse files Browse the repository at this point in the history
  • Loading branch information
pmandin committed Oct 12, 2017
1 parent 2a27988 commit a43a479
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
8 changes: 2 additions & 6 deletions src/video/gem/SDL_gemevents.c
Expand Up @@ -208,9 +208,7 @@ static int do_messages(_THIS, short *message, short latest_msg_id)
/* Continue with TOP event processing */
case WM_ONTOP:
SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
if (VDI_setpalette) {
VDI_setpalette(this, VDI_curpalette);
}
VDI_setpalette(this, VDI_curpalette);
break;
case WM_REDRAW:
if (!GEM_lock_redraw) {
Expand Down Expand Up @@ -283,9 +281,7 @@ static int do_messages(_THIS, short *message, short latest_msg_id)
/* Continue with BOTTOM event processing */
case WM_UNTOPPED:
SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
if (VDI_setpalette) {
VDI_setpalette(this, VDI_oldpalette);
}
VDI_setpalette(this, VDI_oldpalette);
break;
}

Expand Down
32 changes: 10 additions & 22 deletions src/video/gem/SDL_gemvideo.c
Expand Up @@ -506,15 +506,15 @@ void GEM_ClearRect(_THIS, short *pxy)
{
short oldrgb[3], rgb[3]={0,0,0};

vq_color(VDI_handle, vdi_index[0], 0, oldrgb);
vs_color(VDI_handle, vdi_index[0], rgb);
vq_color(VDI_handle, 0, 0, oldrgb);
vs_color(VDI_handle, 0, rgb);

vsf_color(VDI_handle,0);
vsf_interior(VDI_handle,1);
vsf_perimeter(VDI_handle,0);
v_bar(VDI_handle, pxy);

vs_color(VDI_handle, vdi_index[0], oldrgb);
vs_color(VDI_handle, 0, oldrgb);
}

void GEM_ClearRectXYWH(_THIS, short *rect)
Expand Down Expand Up @@ -546,17 +546,9 @@ static void GEM_ClearScreen(_THIS)
static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3])
{
int i;
short rgb[3];

if (VDI_oldnumcolors==0)
return;

for(i = 0; i < VDI_oldnumcolors; i++) {
rgb[0] = newpal[i][0];
rgb[1] = newpal[i][1];
rgb[2] = newpal[i][2];

vs_color(VDI_handle, i, rgb);
vs_color(VDI_handle, i, (short *) newpal[i]);
}
}

Expand Down Expand Up @@ -1133,19 +1125,15 @@ static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)

for(i = 0; i < ncolors; i++)
{
int r, g, b;
short rgb[3];

r = colors[i].r;
g = colors[i].g;
b = colors[i].b;
int j;

rgb[0] = VDI_curpalette[i][0] = (1000 * r) / 255;
rgb[1] = VDI_curpalette[i][1] = (1000 * g) / 255;
rgb[2] = VDI_curpalette[i][2] = (1000 * b) / 255;
j = vdi_index[firstcolor+i];
VDI_curpalette[j][0] = (1000 * colors[i].r) / 255;
VDI_curpalette[j][1] = (1000 * colors[i].g) / 255;
VDI_curpalette[j][2] = (1000 * colors[i].b) / 255;

if (has_input_focus) {
vs_color(VDI_handle, vdi_index[firstcolor+i], rgb);
vs_color(VDI_handle, j, (short *) VDI_curpalette[j]);
}
}

Expand Down

0 comments on commit a43a479

Please sign in to comment.