Beispiel #1
0
void gr_palette_step_up (int r, int g, int b)
{
	int i = 0;
	ubyte *p = gr_palette;
	int temp;

	int colors[768];

	if (gr_palette_faded_out) return;

	if ((r==last_r) && (g==last_g) && (b==last_b)) return;

	last_r = r;
	last_g = g;
	last_b = b;

	while (i < 768)
	{
		temp = (int)(*p++) + r + gr_palette_gamma;
		if (temp<0) temp=0;
		else if (temp>63) temp=63;
		colors[i++] = temp;
		temp = (int)(*p++) + g + gr_palette_gamma;
		if (temp<0) temp=0;
		else if (temp>63) temp=63;
		colors[i++] = temp;
		temp = (int)(*p++) + b + gr_palette_gamma;
		if (temp<0) temp=0;
		else if (temp>63) temp=63;
		colors[i++] = temp;
	}
	vga_setpalvec (0, 256, colors);
}
Beispiel #2
0
int gr_palette_fade_in (ubyte *pal, int nsteps, int allow_keys)
{
	int i, j;
	ubyte c;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	int fade_colors[768];

	if (!gr_palette_faded_out) return 0;

	for (i=0; i<768; i++)
	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i] + gr_palette_gamma) / nsteps;
	}

 	for (j=0; j<nsteps; j++ )
	{
		for (i = 0; i < 768; i++ )
		{
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i] + gr_palette_gamma))
				fade_palette[i] = i2f(pal[i] + gr_palette_gamma);
			c = f2i(fade_palette[i]);
			if (c > 63) c = 63;
			fade_colors[i] = c;
		}
		vga_setpalvec (0, 256, fade_colors);
	}

	gr_palette_faded_out = 0;
	return 0;
}
Beispiel #3
0
/* ---------------------------------------------------------------- */
int set_bkgr_stored_colours(const unsigned short *base_colour,
                            const unsigned char *grey_levels, 
                          	int colour_start, int colours_used)
{ 
    unsigned short r, g, b, grey;
    int *pal_buffer,  *pal_buf_ptr;
    int x;

    pal_buf_ptr = pal_buffer = (int *) malloc(colours_used * 3 * sizeof(int));
		if (pal_buffer == NULL) return 0;

		r = base_colour[0];
		g = base_colour[1];
		b = base_colour[2];
    for (x = 0; x<colours_used; x++)
    {   grey = grey_levels[x];
				*pal_buf_ptr++ = (grey * r) >> 10;	
				*pal_buf_ptr++ = (grey * g) >> 10;	
				*pal_buf_ptr++ = (grey * b) >> 10;	
	   	  cm_pixels[colour_start+x] = colour_start+x;
    }

    x = vga_setpalvec(colour_start, colours_used, pal_buffer);

    free(pal_buffer);
  	return  (x == colours_used);
}
Beispiel #4
0
void gr_palette_clear ()
{
	int colors[768];

	memset (colors, 0, 768 * sizeof(int));
	vga_setpalvec (0, 256, colors);

	gr_palette_faded_out = 1;
}
Beispiel #5
0
void d_raster_setpalette(d_palette_t *p)
{
    int i, pal[D_NCLUTITEMS*D_BYTESPERCOLOR];

    for(i = 0; i < D_NCLUTITEMS*D_BYTESPERCOLOR; i++) {
        pal[i] = p->clut[i]>>2;
    }
    vga_setpalvec(0, D_NCLUTITEMS, pal);
    return;
}
Beispiel #6
0
void I_SetPalette(byte *palette)
{
	int i;

	for (i = 0; i < 256; i++)
	{
		colors[i].r = gammatable[usegamma][*palette++] >> 2;
		colors[i].g	= gammatable[usegamma][*palette++] >> 2;
		colors[i].b = gammatable[usegamma][*palette++] >> 2;
	}
	vga_setpalvec(0, 256, (int *)colors);
}
Beispiel #7
0
void gr_palette_load (ubyte *pal)	
{
	int i;
	int colors[768];

	for (i = 0; i < 768; i++)
	{
		gr_current_pal[i] = pal[i];
		if (gr_current_pal[i] > 63) gr_current_pal[i] = 63;
		colors[i] = (min(gr_current_pal[i] + gr_palette_gamma, 63));
	}

	vga_setpalvec (0, 256, colors);

	gr_palette_faded_out = 0;
	init_computed_colors();
}
void VID_SetPalette (byte *palette)
{
	static int	tmppal[256*3];
	int		*tp;
	int		i;

	if (!svgalib_inited)
		return;
	if (svgalib_backgrounded)
		return;

	memcpy(vid_current_palette, palette, sizeof(vid_current_palette));

	if (vga_getcolors() == 256)
	{
		tp = tmppal;
		for (i = 256 * 3; i; i--)
			*(tp++) = *(palette++) >> 2;

		if (vga_oktowrite())
			vga_setpalvec(0, 256, tmppal);
	}
Beispiel #9
0
/*
** SWimp_SetPalette
**
** System specific palette setting routine.  A NULL palette means
** to use the existing palette.  The palette is expected to be in
** a padded 4-byte xRGB format.
*/
void SWimp_SetPalette( const unsigned char *palette )
{
	static int tmppal[256*3];
	const unsigned char *pal;
	int *tp;
	int i;

    if ( !palette )
        palette = ( const unsigned char * ) sw_state.currentpalette;
 
	if (vga_getcolors() == 256)
	{
		tp = tmppal;
		pal = palette;

		for (i=0 ; i < 256 ; i++, pal += 4, tp += 3) {
			tp[0] = pal[0] >> 2;
			tp[1] = pal[1] >> 2;
			tp[2] = pal[2] >> 2;
		}

		if (vga_oktowrite())
			vga_setpalvec(0, 256, tmppal);
	}
Beispiel #10
0
static int set_static_stored_colours(int start_colour, int colour_count,
        const unsigned char rgb[])
{	int i;    
  int *pal_buffer, *pal_buf_ptr;
	const unsigned char *rgbptr;

	pal_buf_ptr = pal_buffer = (int *) malloc(StaticColours * 3 * sizeof(int));
	if (pal_buffer == NULL) return 0;
	rgbptr = rgb;
    
  for (i=0; i<colour_count; i++)
	{
	  *pal_buf_ptr++ = *rgbptr++ >> 2; 
    *pal_buf_ptr++ = *rgbptr++ >> 2; 
    *pal_buf_ptr++ = *rgbptr++ >> 2; 

		cm_pixels[start_colour+i] = start_colour + i;	
  }

	i = vga_setpalvec(start_colour, colour_count, pal_buffer);
	free(pal_buffer);
  return  (i == colour_count);

}
Beispiel #11
0
static void focus_in_routine(void)
{
    game.status &= ~GMST_SUSPENDED;	 
		vga_setpalvec(0, 256, palvec);
		reset_advance();
}