1.1 --- a/src/video/gem/SDL_gemevents.c Mon Jun 06 21:50:26 2005 +0000
1.2 +++ b/src/video/gem/SDL_gemevents.c Tue Jun 07 11:52:46 2005 +0000
1.3 @@ -245,6 +245,9 @@
1.4 case WM_TOPPED:
1.5 wind_set(message[3],WF_TOP,message[4],0,0,0);
1.6 SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
1.7 + if (VDI_setpalette) {
1.8 + VDI_setpalette(this, VDI_curpalette);
1.9 + }
1.10 break;
1.11 case WM_REDRAW:
1.12 if (!GEM_lock_redraw) {
1.13 @@ -307,6 +310,9 @@
1.14 case WM_BOTTOMED:
1.15 case WM_UNTOPPED:
1.16 SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
1.17 + if (VDI_setpalette) {
1.18 + VDI_setpalette(this, VDI_oldpalette);
1.19 + }
1.20 break;
1.21 }
1.22
2.1 --- a/src/video/gem/SDL_gemvideo.c Mon Jun 06 21:50:26 2005 +0000
2.2 +++ b/src/video/gem/SDL_gemvideo.c Tue Jun 07 11:52:46 2005 +0000
2.3 @@ -106,6 +106,7 @@
2.4 static void GEM_FreeBuffers(_THIS);
2.5 static void GEM_ClearScreen(_THIS);
2.6 static void GEM_ClearRect(_THIS, short *rect);
2.7 +static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]);
2.8 static void GEM_LockScreen(_THIS);
2.9 static void GEM_UnlockScreen(_THIS);
2.10 static void refresh_window(_THIS, int winhandle, short *rect);
2.11 @@ -396,6 +397,8 @@
2.12 VDI_oldpalette[i][1] = rgb[1];
2.13 VDI_oldpalette[i][2] = rgb[2];
2.14 }
2.15 + VDI_setpalette = GEM_SetNewPalette;
2.16 + memcpy(VDI_curpalette,VDI_oldpalette,sizeof(VDI_curpalette));
2.17
2.18 /* Setup screen info */
2.19 GEM_title_name = empty_name;
2.20 @@ -520,6 +523,23 @@
2.21 v_show_c(VDI_handle, 1);
2.22 }
2.23
2.24 +static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3])
2.25 +{
2.26 + int i;
2.27 + short rgb[3];
2.28 +
2.29 + if (VDI_oldnumcolors==0)
2.30 + return;
2.31 +
2.32 + for(i = 0; i < VDI_oldnumcolors; i++) {
2.33 + rgb[0] = newpal[i][0];
2.34 + rgb[1] = newpal[i][1];
2.35 + rgb[2] = newpal[i][2];
2.36 +
2.37 + vs_color(VDI_handle, i, rgb);
2.38 + }
2.39 +}
2.40 +
2.41 static void GEM_LockScreen(_THIS)
2.42 {
2.43 if (!GEM_locked) {
2.44 @@ -1048,9 +1068,9 @@
2.45 g = colors[i].g;
2.46 b = colors[i].b;
2.47
2.48 - rgb[0] = (1000 * r) / 255;
2.49 - rgb[1] = (1000 * g) / 255;
2.50 - rgb[2] = (1000 * b) / 255;
2.51 + rgb[0] = VDI_curpalette[i][0] = (1000 * r) / 255;
2.52 + rgb[1] = VDI_curpalette[i][1] =(1000 * g) / 255;
2.53 + rgb[2] = VDI_curpalette[i][2] =(1000 * b) / 255;
2.54
2.55 vs_color(VDI_handle, vdi_index[firstcolor+i], rgb);
2.56 }
2.57 @@ -1101,20 +1121,7 @@
2.58
2.59 appl_exit();
2.60
2.61 - /* Restore palette */
2.62 - if (VDI_oldnumcolors) {
2.63 - int i;
2.64 -
2.65 - for(i = 0; i < VDI_oldnumcolors; i++) {
2.66 - short rgb[3];
2.67 -
2.68 - rgb[0] = VDI_oldpalette[i][0];
2.69 - rgb[1] = VDI_oldpalette[i][1];
2.70 - rgb[2] = VDI_oldpalette[i][2];
2.71 -
2.72 - vs_color(VDI_handle, i, rgb);
2.73 - }
2.74 - }
2.75 + GEM_SetNewPalette(this, VDI_oldpalette);
2.76
2.77 /* Close VDI workstation */
2.78 if (VDI_handle) {
3.1 --- a/src/video/gem/SDL_gemvideo.h Mon Jun 06 21:50:26 2005 +0000
3.2 +++ b/src/video/gem/SDL_gemvideo.h Tue Jun 07 11:52:46 2005 +0000
3.3 @@ -65,6 +65,9 @@
3.4 short blit_coords[8]; /* Coordinates for bitblt */
3.5 MFDB src_mfdb, dst_mfdb; /* VDI MFDB for bitblt */
3.6 Uint16 old_palette[256][3]; /* Saved current palette */
3.7 + Uint16 cur_palette[256][3]; /* SDL application palette */
3.8 + /* Function to set/restore palette */
3.9 + void (*setpalette)(_THIS, Uint16 newpal[256][3]);
3.10
3.11 /* GEM infos */
3.12 short desk_x, desk_y; /* Desktop properties */
3.13 @@ -96,6 +99,8 @@
3.14 #define VDI_pixelsize (this->hidden->pixelsize)
3.15 #define VDI_oldnumcolors (this->hidden->old_numcolors)
3.16 #define VDI_oldpalette (this->hidden->old_palette)
3.17 +#define VDI_curpalette (this->hidden->cur_palette)
3.18 +#define VDI_setpalette (this->hidden->setpalette)
3.19 #define VDI_pitch (this->hidden->pitch)
3.20 #define VDI_format (this->hidden->format)
3.21 #define VDI_screen (this->hidden->screen)