Exemplo n.º 1
0
void gr_palette_load (ubyte *pal)	
{
	int i, j;
	ggi_color colors[256];

	for (i = 0, j = 0; j < 256; j++)
	{
		gr_current_pal[i] = pal[i];
		if (gr_current_pal[i] > 63) gr_current_pal[i] = 63;
		colors[j].r = (min(gr_current_pal[i] + gr_palette_gamma, 63)) * 0x3ff;
		i++;
                gr_current_pal[i] = pal[i];
                if (gr_current_pal[i] > 63) gr_current_pal[i] = 63;
                colors[j].g = (min(gr_current_pal[i] + gr_palette_gamma, 63)) * 0x3ff;
		i++;
                gr_current_pal[i] = pal[i];
                if (gr_current_pal[i] > 63) gr_current_pal[i] = 63;
                colors[j].b = (min(gr_current_pal[i] + gr_palette_gamma, 63)) * 0x3ff;
		i++;
	}

	ggiSetPalette(screenvis, 0, 256, colors);

	gr_palette_faded_out = 0;
	init_computed_colors();
}
Exemplo n.º 2
0
void gr_palette_load( ubyte *pal )	
{
 int i, j;
 SDL_Palette *palette;
 SDL_Color colors[256];

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

 palette = screen->format->palette;

 if (palette == NULL) {
    return; // Display is not palettised
 }

 for (i = 0, j = 0; j < 256; j++) {
     //changed on 980913 by adb to fix palette problems
     colors[j].r = (min(gr_current_pal[i++] + gr_palette_gamma, 63)) * 4;
     colors[j].g = (min(gr_current_pal[i++] + gr_palette_gamma, 63)) * 4;
     colors[j].b = (min(gr_current_pal[i++] + gr_palette_gamma, 63)) * 4;
     //end changes by adb
 }
 SDL_SetColors(screen, colors, 0, 256);

 gr_palette_faded_out = 0;
 init_computed_colors();
}
Exemplo n.º 3
0
int gr_find_closest_color( int r, int g, int b )
{
	int i, j;
	int best_value, best_index, value;

	if (Num_computed_colors == 0)
		init_computed_colors();

	//	If we've already computed this color, return it!
	for (i=0; i<Num_computed_colors; i++)
		if (r == Computed_colors[i].r)
			if (g == Computed_colors[i].g)
				if (b == Computed_colors[i].b) {
					if (i > 4) {
						color_record	trec;
						trec = Computed_colors[i-1];
						Computed_colors[i-1] = Computed_colors[i];
						Computed_colors[i] = trec;
						return Computed_colors[i-1].color_num;
					}
					return Computed_colors[i].color_num;
				}

//	r &= 63;
//	g &= 63;
//	b &= 63;

//	best_value = SQUARE(r-gr_palette[0])+SQUARE(g-gr_palette[1])+SQUARE(b-gr_palette[2]);
//	best_index = 0;
	best_value = SQUARE(r-gr_palette[765])+SQUARE(g-gr_palette[766])+SQUARE(b-gr_palette[767]);
	best_index = 255;
	if (best_value==0) {
		add_computed_color(r, g, b, best_index);
 		return best_index;
	}
	j=0;
	// only go to 255, 'cause we dont want to check the transparent color.
	for (i=1; i<254; i++ )	{
		j += 3;
		value = SQUARE(r-gr_palette[j])+SQUARE(g-gr_palette[j+1])+SQUARE(b-gr_palette[j+2]);
		if ( value < best_value )	{
			if (value==0) {
				add_computed_color(r, g, b, i);
				return i;
			}
			best_value = value;
			best_index = i;
		}
	}
	add_computed_color(r, g, b, best_index);
	return best_index;
}
Exemplo n.º 4
0
void gr_palette_load( ubyte *pal )	
{
	int i, j;
	GDHandle old_device;
	ColorSpec colors[256];
//	PaletteHandle palette;
//	RGBColor color;
//	CTabHandle ctable;

	for (i=0; i<768; i++ ) {
// 		gr_current_pal[i] = pal[i] + gr_palette_gamma;
		gr_current_pal[i] = pal[i];
		if (gr_current_pal[i] > 63) gr_current_pal[i] = 63;
	}
	for (i = 0, j = 0; j < 256; j++) {
		colors[j].value = j;
		colors[j].rgb.red = gr_mac_gamma[gr_current_pal[i++]];
		colors[j].rgb.green = gr_mac_gamma[gr_current_pal[i++]];
		colors[j].rgb.blue = gr_mac_gamma[gr_current_pal[i++]];
	}
	old_device = GetGDevice();
	SetGDevice(GameMonitor);
	SetEntries(0, 255, colors);
	SetGDevice(old_device);

#if 0
	palette = GetPalette(GameWindow);
	for (i = 0; i < 768; i += 3) {
		color.red = gr_current_pal[i] << 9;
		color.green = gr_current_pal[i+1] << 9;
		color.blue = gr_current_pal[i+2] << 9;
		SetEntryColor(palette, i / 3, &color);
	}
	
	ctable = (CTabHandle)NewHandle(sizeof(ColorTable));
	Palette2CTab(palette, ctable);
	AnimatePalette(GameWindow, ctable, 0, 0, 256);
	ActivatePalette(GameWindow);
	
	DisposeHandle((Handle)ctable);

	if (GameGWorld != NULL) {
		ctable = (**GetGWorldPixMap(GameGWorld)).pmTable;	// get the color table for the gWorld.
		CTabChanged(ctable);
		(**ctable).ctSeed = (**(**(*(CGrafPtr)GameWindow).portPixMap).pmTable).ctSeed;
	}
#endif
	gr_palette_faded_out = 0;
	init_computed_colors();
}
Exemplo n.º 5
0
void gr_palette_load( ubyte *pal )
{
	int i;

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

	gr_palette_step_up(0, 0, 0); // make ogl_setbrightness_internal get run so that menus get brightened too.
	init_computed_colors();
}
Exemplo n.º 6
0
void gr_palette_load( ubyte * pal )
{
	int i;
	ubyte c;
	outp( 0x3c6, 0xff );
	outp( 0x3c8, 0 );
	for (i=0; i<768; i++ )	{
		c = pal[i] + gr_palette_gamma;
		if ( c > 63 ) c = 63;
		outp( 0x3c9,c);
 		gr_current_pal[i] = pal[i];
	}
	gr_palette_faded_out = 0;

	init_computed_colors();
}
Exemplo n.º 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();
}
Exemplo n.º 8
0
Arquivo: vid.c Projeto: btb/d2x
void gr_palette_load( ubyte *pal )	
{
 int i;//, j;

 for (i=0; i<768; i++ ) {
     gr_current_pal[i] = pal[i];
     if (gr_current_pal[i] > 63) gr_current_pal[i] = 63;
 }
 //palette = screen->format->palette;

 gr_palette_faded_out=0;

	gr_palette_step_up(0, 0, 0); // make ogl_setbrightness_internal get run so that menus get brightened too.

 init_computed_colors();

	ogl_init_shared_palette();
}
Exemplo n.º 9
0
void gr_palette_load( ubyte * pal )	
{
	int i;
	ubyte c;
	HRESULT ddresult;

	Assert(_lpDDPalActive!=0);

	for (i=0; i<256; i++ )	{
		c = pal[i*3] + gr_palette_gamma;
		if ( c > 63 ) c = 63;
		PalGDIData.ScratchPal[i].peRed = c << 2;
 		gr_current_pal[i*3] = pal[i*3];
		c = pal[i*3+1] + gr_palette_gamma;
		if ( c > 63 ) c = 63;
		PalGDIData.ScratchPal[i].peGreen = c << 2;
 		gr_current_pal[i*3+1] = pal[i*3+1];
		c = pal[i*3+2] + gr_palette_gamma;
		if ( c > 63 ) c = 63;
		PalGDIData.ScratchPal[i].peBlue = c << 2;
 		gr_current_pal[i*3+2] = pal[i*3+2];
		PalGDIData.ScratchPal[i].peFlags = 0;
	}
	
	if (!hPalGDI) {
		ddresult = IDirectDrawPalette_SetEntries(_lpDDPalActive, 0,
											0, 256,
											PalGDIData.ScratchPal);
		Assert(ddresult == DD_OK);
	}
	else {
		HDC hdc;

		hdc = GetDC(GetLibraryWindow());		
		SetPaletteEntries(hPalGDI, 0, PalGDIData.num, PalGDIData.ScratchPal);
		RealizePalette(hdc);
		ReleaseDC(GetLibraryWindow(), hdc);
	}

	gr_palette_faded_out = 0;

	init_computed_colors();
}