ref: 89ac13b4f2bf950bec584fe8adc4aa1c8748c3e2
parent: 5673503ff3524db56ae73cbe29ad0a2571beb657
author: Simon Howard <fraggle@gmail.com>
date: Sat Aug 6 13:30:30 EDT 2005
Only change palette on screen updates Subversion-branch: /trunk/chocolate-doom Subversion-revision: 44
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_video.c 40 2005-08-04 22:23:07Z fraggle $
+// $Id: i_video.c 44 2005-08-06 17:30:30Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.14 2005/08/06 17:30:30 fraggle
+// Only change palette on screen updates
+//
// Revision 1.13 2005/08/04 22:23:07 fraggle
// Use zone memory function. Add command line options
//
@@ -72,7 +75,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: i_video.c 40 2005-08-04 22:23:07Z fraggle $";
+rcsid[] = "$Id: i_video.c 44 2005-08-06 17:30:30Z fraggle $";
#include <ctype.h>
#include <SDL.h>
@@ -92,6 +95,10 @@
#define POINTER_WARP_COUNTDOWN 1
+// palette
+static SDL_Color palette[256];
+static boolean palette_to_set;
+
// Fake mouse handling.
// This cannot work properly w/o DGA.
// Needs an invisible mouse cursor at least.
@@ -594,7 +601,15 @@
// draw to screen
- SDL_Flip(screen);
+ if (palette_to_set)
+ {
+ SDL_SetColors(screen, palette, 0, 256);
+ palette_to_set = 0;
+ }
+ else
+ {
+ SDL_Flip(screen);
+ }
}
@@ -610,19 +625,18 @@
//
// I_SetPalette
//
-void I_SetPalette (byte* palette)
+void I_SetPalette (byte *doompalette)
{
- SDL_Color sdl_palette[256];
int i;
for (i=0; i<256; ++i)
{
- sdl_palette[i].r = *palette++;
- sdl_palette[i].g = *palette++;
- sdl_palette[i].b = *palette++;
+ palette[i].r = *doompalette++;
+ palette[i].g = *doompalette++;
+ palette[i].b = *doompalette++;
}
- SDL_SetColors(screen, sdl_palette, 0, 256);
+ palette_to_set = 1;
}
@@ -665,6 +679,11 @@
SDL_WM_GrabInput(SDL_GRAB_ON);
LoadDiskImage();
+
+ {
+ SDL_Event dummy;
+ while (SDL_PollEvent(&dummy));
+ }
}
unsigned exptable[256];