Exemple #1
0
void palette_init(running_machine *machine)
{
	palette_private *palette = auto_malloc(sizeof(*palette));

	/* request cleanup */
	machine->palette_data = palette;
	add_exit_callback(machine, palette_exit);

	/* reset all our data */
	memset(palette, 0, sizeof(*palette));
	palette->format = machine->screen[0].format;

	/* determine the color mode */
	switch (palette->format)
	{
		case BITMAP_FORMAT_INDEXED16:
			/* indexed modes are fine for everything */
			break;

		case BITMAP_FORMAT_RGB15:
		case BITMAP_FORMAT_RGB32:
			/* RGB modes can't use color tables */
			assert(machine->drv->color_table_len == 0);
			break;

		case BITMAP_FORMAT_INVALID:
			/* invalid format means no palette - or at least it should */
			assert(machine->drv->total_colors == 0);
			assert(machine->drv->color_table_len == 0);
			return;

		default:
			fatalerror("Unsupported screen bitmap format!");
			break;
	}

	/* allocate all the data structures */
	if (machine->drv->total_colors > 0)
	{
		int numcolors;

		allocate_palette(machine, palette);
		allocate_color_tables(machine, palette);
		allocate_shadow_tables(machine, palette);

		/* set up save/restore of the palette */
		numcolors = palette_get_num_colors(machine->palette);
		palette->save_pen = auto_malloc(sizeof(*palette->save_pen) * numcolors);
		palette->save_bright = auto_malloc(sizeof(*palette->save_bright) * numcolors);
		state_save_register_global_pointer(palette->save_pen, numcolors);
		state_save_register_global_pointer(palette->save_bright, numcolors);
		state_save_register_func_presave(palette_presave);
		state_save_register_func_postload(palette_postload);
	}
}
Exemple #2
0
void device_palette_interface::interface_pre_start()
{
	// allocate the palette
	u32 numentries = palette_entries();
	allocate_palette(numentries);
	allocate_color_tables();
	allocate_shadow_tables();

	// allocate indirection tables
	int indirect_colors = palette_indirect_entries();
	if (indirect_colors > 0)
	{
		m_indirect_colors.resize(indirect_colors);
		for (int color = 0; color < indirect_colors; color++)
		{
			// alpha = 0 ensures change is detected the first time set_indirect_color() is called
			m_indirect_colors[color] = rgb_t::transparent();
		}

		m_indirect_pens.resize(numentries);
		for (int pen = 0; pen < numentries; pen++)
			m_indirect_pens[pen] = pen % indirect_colors;
	}
}
Exemple #3
0
void palette_init(running_machine *machine)
{
	int format;
	palette_private *palette = auto_malloc(sizeof(*palette));
	const device_config *device = video_screen_first(machine->config);

	/* get the format from the first screen, or use BITMAP_FORMAT_INVALID, if screenless */
	if (device != NULL)
	{
		screen_config *config = device->inline_config;
		format = config->format;
	}
	else
		format = BITMAP_FORMAT_INVALID;

	/* request cleanup */
	machine->palette_data = palette;
	add_exit_callback(machine, palette_exit);

	/* reset all our data */
	memset(palette, 0, sizeof(*palette));
	palette->format = format;

	/* determine the color mode */
	switch (format)
	{
		case BITMAP_FORMAT_INDEXED16:
		case BITMAP_FORMAT_RGB15:
		case BITMAP_FORMAT_RGB32:
			/* indexed and RGB modes are fine for everything */
			break;

		case BITMAP_FORMAT_INVALID:
			/* invalid format means no palette - or at least it should */
			assert(machine->config->total_colors == 0);
			return;

		default:
			fatalerror("Unsupported screen bitmap format!");
			break;
	}

	/* allocate all the data structures */
	if (machine->config->total_colors > 0)
	{
		int numcolors;

		allocate_palette(machine, palette);
		allocate_color_tables(machine, palette);
		allocate_shadow_tables(machine, palette);

		/* set up save/restore of the palette */
		numcolors = palette_get_num_colors(machine->palette);
		palette->save_pen = auto_malloc(sizeof(*palette->save_pen) * numcolors);
		palette->save_bright = auto_malloc(sizeof(*palette->save_bright) * numcolors);
		state_save_register_global_pointer(palette->save_pen, numcolors);
		state_save_register_global_pointer(palette->save_bright, numcolors);
		state_save_register_presave(machine, palette_presave, palette);
		state_save_register_postload(machine, palette_postload, palette);
	}
}