コード例 #1
0
ファイル: info.c プロジェクト: nitrologic/emu
static void print_game_display(FILE *out, const game_driver *game, const machine_config *config)
{
	const device_config *screen;

	/* iterate over screens */
	for (screen = video_screen_first(config); screen != NULL; screen = video_screen_next(screen))
	{
		const screen_config *scrconfig = (const screen_config *)screen->inline_config;

		fprintf(out, "\t\t<display");

		switch (scrconfig->type)
		{
			case SCREEN_TYPE_RASTER:	fprintf(out, " type=\"raster\"");	break;
			case SCREEN_TYPE_VECTOR:	fprintf(out, " type=\"vector\"");	break;
			case SCREEN_TYPE_LCD:		fprintf(out, " type=\"lcd\"");		break;
			default:					fprintf(out, " type=\"unknown\"");	break;
		}

		/* output the orientation as a string */
		switch (game->flags & ORIENTATION_MASK)
		{
			case ORIENTATION_FLIP_X:
				fprintf(out, " rotate=\"0\" flipx=\"yes\"");
				break;
			case ORIENTATION_FLIP_Y:
				fprintf(out, " rotate=\"180\" flipx=\"yes\"");
				break;
			case ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
				fprintf(out, " rotate=\"180\"");
				break;
			case ORIENTATION_SWAP_XY:
				fprintf(out, " rotate=\"90\" flipx=\"yes\"");
				break;
			case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X:
				fprintf(out, " rotate=\"90\"");
				break;
			case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_Y:
				fprintf(out, " rotate=\"270\"");
				break;
			case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
				fprintf(out, " rotate=\"270\" flipx=\"yes\"");
				break;
			default:
				fprintf(out, " rotate=\"0\"");
				break;
		}

		/* output width and height only for games that are not vector */
		if (scrconfig->type != SCREEN_TYPE_VECTOR)
		{
			int dx = scrconfig->visarea.max_x - scrconfig->visarea.min_x + 1;
			int dy = scrconfig->visarea.max_y - scrconfig->visarea.min_y + 1;

			fprintf(out, " width=\"%d\"", dx);
			fprintf(out, " height=\"%d\"", dy);
		}

		/* output refresh rate */
		fprintf(out, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(scrconfig->refresh));

		/* output raw video parameters only for games that are not vector */
		/* and had raw parameters specified                               */
		if ((scrconfig->type != SCREEN_TYPE_VECTOR) && !scrconfig->oldstyle_vblank_supplied)
		{
			int pixclock = scrconfig->width * scrconfig->height * ATTOSECONDS_TO_HZ(scrconfig->refresh);

			fprintf(out, " pixclock=\"%d\"", pixclock);
			fprintf(out, " htotal=\"%d\"", scrconfig->width);
			fprintf(out, " hbend=\"%d\"", scrconfig->visarea.min_x);
			fprintf(out, " hbstart=\"%d\"", scrconfig->visarea.max_x+1);
			fprintf(out, " vtotal=\"%d\"", scrconfig->height);
			fprintf(out, " vbend=\"%d\"", scrconfig->visarea.min_y);
			fprintf(out, " vbstart=\"%d\"", scrconfig->visarea.max_y+1);
		}
		fprintf(out, " />\n");
	}
}
コード例 #2
0
ファイル: emupal.c プロジェクト: cdenix/ps3-mame-0125
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);
	}
}