enable 0/255 palette swap

This commit is contained in:
Bradley Bell 2002-09-07 07:19:59 +00:00
parent 4daf5205bb
commit 6fccad867c
2 changed files with 149 additions and 3 deletions

View file

@ -1,4 +1,4 @@
/* $Id: palette.c,v 1.5 2002-08-15 07:17:39 btb Exp $ */
/* $Id: palette.c,v 1.6 2002-09-07 07:18:22 btb Exp $ */
/*
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
@ -11,9 +11,134 @@ CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
/*
* Graphical routines for setting the palette
*
* Old Log:
* Revision 1.41 1995/02/02 14:26:31 john
* Made palette fades work better with gamma thingy..
*
* Revision 1.40 1994/12/08 19:03:46 john
* Made functions use cfile.
*
* Revision 1.39 1994/12/01 11:23:27 john
* Limited Gamma from 0-8.
*
* Revision 1.38 1994/11/28 01:31:08 mike
* optimize color lookup function, caching recently used colors.
*
* Revision 1.37 1994/11/18 22:50:18 john
* Changed shorts to ints in parameters.
*
* Revision 1.36 1994/11/15 17:54:59 john
* Made text palette fade in when game over.
*
* Revision 1.35 1994/11/10 19:53:14 matt
* Fixed error handling is gr_use_palette_table()
*
* Revision 1.34 1994/11/07 13:53:48 john
* Added better gamma stufff.
*
* Revision 1.33 1994/11/07 13:37:56 john
* Added gamma correction stuff.
*
* Revision 1.32 1994/11/05 13:20:14 john
* Fixed bug with find_closest_color_current not working.
*
* Revision 1.31 1994/11/05 13:08:09 john
* MAde it return 0 when palette already faded out.
*
* Revision 1.30 1994/11/05 13:05:34 john
* Added back in code to allow keys during fade.
*
* Revision 1.29 1994/11/05 12:49:50 john
* Fixed bug with previous comment..
*
* Revision 1.28 1994/11/05 12:48:46 john
* Made palette only fade in / out when its supposed to.
*
* Revision 1.27 1994/11/05 12:46:43 john
* Changed palette stuff a bit.
*
* Revision 1.26 1994/11/01 12:59:35 john
* Reduced palette.256 size.
*
* Revision 1.25 1994/10/26 23:55:35 john
* Took out roller; Took out inverse table.
*
* Revision 1.24 1994/10/04 22:03:05 matt
* Fixed bug: palette wasn't fading all the way out or in
*
* Revision 1.23 1994/09/22 16:08:40 john
* Fixed some palette stuff.
*
* Revision 1.22 1994/09/19 11:44:31 john
* Changed call to allocate selector to the dpmi module.
*
* Revision 1.21 1994/09/12 19:28:09 john
* Fixed bug with unclipped fonts clipping.
*
* Revision 1.20 1994/09/12 18:18:39 john
* Set 254 and 255 to fade to themselves in fadetable
*
* Revision 1.19 1994/09/12 14:40:10 john
* Neatend.
*
* Revision 1.18 1994/09/09 09:31:55 john
* Made find_closest_color not look at superx spot of 254
*
* Revision 1.17 1994/08/09 11:27:08 john
* Add cthru stuff.
*
* Revision 1.16 1994/08/01 11:03:51 john
* MAde it read in old/new palette.256
*
* Revision 1.15 1994/07/27 18:30:27 john
* Took away the blending table.
*
* Revision 1.14 1994/06/09 10:39:52 john
* In fade out.in functions, returned 1 if key was pressed...
*
* Revision 1.13 1994/05/31 19:04:16 john
* Added key to stop fade if desired.
*
* Revision 1.12 1994/05/06 12:50:20 john
* Added supertransparency; neatend things up; took out warnings.
*
* Revision 1.11 1994/05/03 19:39:02 john
* *** empty log message ***
*
* Revision 1.10 1994/04/22 11:16:07 john
* *** empty log message ***
*
* Revision 1.9 1994/04/08 16:59:40 john
* Add fading poly's; Made palette fade 32 instead of 16.
*
* Revision 1.8 1994/03/16 17:21:17 john
* Added slow palette searching options.
*
* Revision 1.7 1994/01/07 11:47:33 john
* made use cflib
*
* Revision 1.6 1993/12/21 11:41:04 john
* *** empty log message ***
*
* Revision 1.5 1993/12/09 15:02:47 john
* Changed palette stuff majorly
*
* Revision 1.4 1993/12/07 12:31:41 john
* moved bmd_palette to gr_palette
*
* Revision 1.3 1993/10/15 16:22:23 john
* *** empty log message ***
*
* Revision 1.2 1993/09/26 18:59:46 john
* fade stuff
*
* Revision 1.1 1993/09/08 11:44:03 john
* Initial revision
*
*/
#ifdef HAVE_CONFIG_H
@ -74,6 +199,9 @@ void gr_use_palette_table( char * filename )
{
CFILE *fp;
int i,fsize;
#ifdef SWAP_0_255
ubyte c;
#endif
fp = cfopen( filename, "rb" );
@ -101,6 +229,22 @@ void gr_use_palette_table( char * filename )
gr_fade_table[i*256+255] = 255;
}
// swap colors 0 and 255 of the palette along with fade table entries
#ifdef SWAP_0_255
for (i = 0; i < 3; i++) {
c = gr_palette[i];
gr_palette[i] = gr_palette[765+i];
gr_palette[765+i] = c;
}
for (i = 0; i < GR_FADE_LEVELS * 256; i++) {
if (gr_fade_table[i] == 0)
gr_fade_table[i] = 255;
}
for (i=0; i<GR_FADE_LEVELS; i++)
gr_fade_table[i*256] = TRANSPARENCY_COLOR;
#endif
}
#define SQUARE(x) ((x)*(x))

View file

@ -1,4 +1,4 @@
/* $Id: gr.h,v 1.16 2002-09-05 08:03:40 btb Exp $ */
/* $Id: gr.h,v 1.17 2002-09-07 07:19:59 btb Exp $ */
/*
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
@ -18,12 +18,14 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "pstypes.h"
#include "fix.h"
#ifdef MACINTOSH
#if defined(MACINTOSH) || defined(MACDATA)
#define SWAP_0_255 1 // swap black and white
#define TRANSPARENCY_COLOR 0 // palette entry of transparency color -- 0 on the mac
#define TRANSPARENCY_COLOR_STR "0"
#else
#define SWAP_0_255 0 // no swapping for PC people
#define TRANSPARENCY_COLOR 255 // palette entry of transparency color -- 255 on the PC
#define TRANSPARENCY_COLOR_STR "255"
#endif
#define GR_FADE_LEVELS 34