Exemplo n.º 1
0
void nesapu_device::calculate_rates()
{
	int rate = clock() / 4;

	screen_device *screen = machine().first_screen();
	if (screen != nullptr)
	{
		m_samps_per_sync = rate / ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds());
		m_real_rate = m_samps_per_sync * ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds());
	}
	else
	{
		m_samps_per_sync = rate / screen_device::DEFAULT_FRAME_RATE;
		m_real_rate = m_samps_per_sync * screen_device::DEFAULT_FRAME_RATE;
	}
	m_buffer_size = m_samps_per_sync;
	m_apu_incsize = float(clock() / (float) m_real_rate);

	create_vbltimes(m_vbl_times,vbl_length,m_samps_per_sync);
	create_syncs(m_samps_per_sync);

	/* Adjust buffer size if 16 bits */
	m_buffer_size+=m_samps_per_sync;

	if (m_stream != nullptr)
		m_stream->set_sample_rate(rate);
	else
		m_stream = machine().sound().stream_alloc(*this, 0, 1, rate);
}
Exemplo n.º 2
0
void k053252_device::res_change()
{
	if(m_hc && m_vc &&
		m_hbp && m_hfp &&
		m_vbp && m_vfp &&
		m_hsw && m_vsw) //safety checks
	{
		rectangle visarea;
		//(HC+1) - HFP - HBP - 8*(HSW+1)
		//VC - VFP - VBP - (VSW+1)
		attoseconds_t refresh = HZ_TO_ATTOSECONDS(clock()) * (m_hc) * m_vc;

		visarea.min_x = m_offsx;
		visarea.min_y = m_offsy;
		visarea.max_x = m_offsx + m_hc - m_hfp - m_hbp - 8*(m_hsw) - 1;
		visarea.max_y = m_offsy + m_vc - m_vfp - m_vbp - (m_vsw) - 1;

		m_screen->configure(m_hc, m_vc, visarea, refresh);

		if (m_slave_screen.found())
			m_slave_screen->configure(m_hc, m_vc, visarea, refresh);

#if 0
		attoseconds_t hsync = HZ_TO_ATTOSECONDS(clock()) * (m_hc);
		printf("H %d HFP %d HSW %d HBP %d\n",m_hc,m_hfp,m_hsw*8,m_hbp);
		printf("V %d VFP %d VSW %d VBP %d\n",m_vc,m_vfp,m_vsw,m_vbp);
		// L stands for Legacy ...
		printf("L %d %d\n",m_offsx,m_offsy);
		printf("Screen params: Clock: %u V-Sync %.2f H-Sync %.f\n",clock(),ATTOSECONDS_TO_HZ(refresh),ATTOSECONDS_TO_HZ(hsync));
		printf("visible screen area: %d x %d\n\n",(visarea.max_x - visarea.min_x) + 1,(visarea.max_y - visarea.min_y) + 1);
#endif
	}
}
Exemplo n.º 3
0
void video_manager::update_refresh_speed()
{
	// only do this if the refreshspeed option is used
	if (machine().options().refresh_speed())
	{
		double minrefresh = machine().render().max_update_rate();
		if (minrefresh != 0)
		{
			// find the screen with the shortest frame period (max refresh rate)
			// note that we first check the token since this can get called before all screens are created
			attoseconds_t min_frame_period = ATTOSECONDS_PER_SECOND;
			screen_device_iterator iter(machine().root_device());
			for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next())
			{
				attoseconds_t period = screen->frame_period().attoseconds();
				if (period != 0)
					min_frame_period = MIN(min_frame_period, period);
			}

			// compute a target speed as an integral percentage
			// note that we lop 0.25Hz off of the minrefresh when doing the computation to allow for
			// the fact that most refresh rates are not accurate to 10 digits...
			UINT32 target_speed = floor((minrefresh - 0.25) * 1000.0 / ATTOSECONDS_TO_HZ(min_frame_period));
			UINT32 original_speed = original_speed_setting();
			target_speed = MIN(target_speed, original_speed);

			// if we changed, log that verbosely
			if (target_speed != m_speed)
			{
				osd_printf_verbose("Adjusting target speed to %.1f%% (hw=%.2fHz, game=%.2fHz, adjusted=%.2fHz)\n", target_speed / 10.0, minrefresh, ATTOSECONDS_TO_HZ(min_frame_period), ATTOSECONDS_TO_HZ(min_frame_period * 1000.0 / target_speed));
				m_speed = target_speed;
			}
		}
	}
}
Exemplo n.º 4
0
void avi_write::begin_avi_recording(const char *name)
{
	// stop any existing recording
	end_avi_recording();

	// reset the state
	m_frame = 0;
	m_next_frame_time = m_machine.time();

	const screen_device *primary_screen = screen_device_iterator(m_machine.root_device()).first();
	// build up information about this new movie
	avi_file::movie_info info;
	info.video_format = 0;
	info.video_timescale = 1000 * (primary_screen ? ATTOSECONDS_TO_HZ(primary_screen->frame_period().m_attoseconds) : screen_device::DEFAULT_FRAME_RATE);
	info.video_sampletime = 1000;
	info.video_numsamples = 0;
	info.video_width = m_width;
	info.video_height = m_height;
	info.video_depth = 24;

	info.audio_format = 0;
	info.audio_timescale = m_machine.sample_rate();
	info.audio_sampletime = 1;
	info.audio_numsamples = 0;
	info.audio_channels = 2;
	info.audio_samplebits = 16;
	info.audio_samplerate = m_machine.sample_rate();

	// compute the frame time
	m_frame_period = attotime::from_seconds(1000) / info.video_timescale;

	// create a new temporary movie file
	emu_file tempfile(m_machine.options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
	const osd_file::error filerr = (!name || !name[0] || !std::strcmp(name, OSDOPTVAL_AUTO))
			? m_machine.video().open_next(tempfile, "avi")
			: tempfile.open(name);

	// if we succeeded, make a copy of the name and create the real file over top
	if (filerr == osd_file::error::NONE)
	{
		const std::string fullpath = tempfile.fullpath();
		tempfile.close();

		// create the file and free the string
		avi_file::error avierr = avi_file::create(fullpath, info, m_output_file);
		if (avierr != avi_file::error::NONE)
		{
			osd_printf_error("Error creating AVI: %s\n", avi_file::error_string(avierr));
		}
		else
		{
			m_recording = true;
		}
	}
}
Exemplo n.º 5
0
static TIMER_CALLBACK( senjyo_sh_update )
{
	/* ctc2 timer single tone generator frequency */
	attotime period = z80ctc_getperiod (0, 2);
	if (attotime_compare(period, attotime_zero) != 0 )
		single_rate = ATTOSECONDS_TO_HZ(period.attoseconds);
	else
		single_rate = 0;

	sample_set_freq(0,single_rate);
}
Exemplo n.º 6
0
static INTERRUPT_GEN( vblank_callback )
{
	/* also update the speaker on the European version */
	beep_device *beep = device->machine->device<beep_device>("beep");
	if (beep != NULL)
	{
		z80ctc_device *ctc = device->machine->device<z80ctc_device>("ctc");
		beep_set_state(beep, 1);
		beep_set_frequency(beep, ATTOSECONDS_TO_HZ(ctc->period(0).attoseconds));
	}
}
Exemplo n.º 7
0
menu_autofire::menu_autofire(mame_ui_manager &mui, render_container &container) : menu(mui, container), last_toggle(false)
{
	const screen_device *screen = mui.machine().first_screen();

	if (screen == nullptr)
	{
		refresh = 60.0;
	}
	else
	{
		refresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds());
	}
}
Exemplo n.º 8
0
ui_menu_autofire::ui_menu_autofire(running_machine &machine, render_container *container) : ui_menu(machine, container), last_toggle(false)
{
	const screen_device *screen = machine.first_screen();

	if (screen == nullptr)
	{
		refresh = 60.0;
	}
	else
	{
		refresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds());
	}
}
Exemplo n.º 9
0
ui_menu_autofire::ui_menu_autofire(running_machine &machine, render_container *container) : ui_menu(machine, container)
{
	screen_device_iterator iter(machine.root_device());
	const screen_device *screen = iter.first();

	if (screen == nullptr)
	{
		refresh = 60.0;
	}
	else
	{
		refresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds());
	}
}
Exemplo n.º 10
0
static TIMER_CALLBACK( senjyo_sh_update )
{
	running_device *samples = machine->device("samples");

	/* ctc2 timer single tone generator frequency */
	z80ctc_device *ctc = machine->device<z80ctc_device>("z80ctc");
	attotime period = ctc->period(2);
	if (attotime_compare(period, attotime_zero) != 0 )
		single_rate = ATTOSECONDS_TO_HZ(period.attoseconds);
	else
		single_rate = 0;

	sample_set_freq(samples, 0,single_rate);
}
Exemplo n.º 11
0
static TIMER_CALLBACK( senjyo_sh_update )
{
	device_t *samples = machine->device("samples");
	senjyo_state *state = machine->driver_data<senjyo_state>();

	/* ctc2 timer single tone generator frequency */
	z80ctc_device *ctc = machine->device<z80ctc_device>("z80ctc");
	attotime period = ctc->period(2);
	if (period != attotime::zero)
		state->single_rate = ATTOSECONDS_TO_HZ(period.attoseconds);
	else
		state->single_rate = 0;

	sample_set_freq(samples, 0, state->single_rate);
}
Exemplo n.º 12
0
static void pick_best_mode(win_window_info *window)
{
	dd_info *dd = (dd_info *)window->drawdata;
	mode_enum_info einfo;
	HRESULT result;

	// determine the minimum width/height for the selected target
	// note: technically we should not be calling this from an alternate window
	// thread; however, it is only done during init time, and the init code on
	// the main thread is waiting for us to finish, so it is safe to do so here
	window->target->compute_minimum_size(einfo.minimum_width, einfo.minimum_height);

	// use those as the target for now
	einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale);
	einfo.target_height = einfo.minimum_height * MAX(1, video_config.prescale);

	// determine the refresh rate of the primary screen
	einfo.target_refresh = 60.0;
	const screen_device *primary_screen = window->machine().config().first_screen();
	if (primary_screen != NULL)
		einfo.target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh_attoseconds());
	printf("Target refresh = %f\n", einfo.target_refresh);

	// if we're not stretching, allow some slop on the minimum since we can handle it
	if (!video_config.hwstretch)
	{
		einfo.minimum_width -= 4;
		einfo.minimum_height -= 4;
	}

	// if we are stretching, aim for a mode approximately 2x the game's resolution
	else if (video_config.prescale <= 1)
	{
		einfo.target_width *= 2;
		einfo.target_height *= 2;
	}

	// fill in the rest of the data
	einfo.window = window;
	einfo.best_score = 0.0f;

	// enumerate the modes
	mame_printf_verbose("DirectDraw: Selecting video mode...\n");
	result = IDirectDraw7_EnumDisplayModes(dd->ddraw, DDEDM_REFRESHRATES, NULL, &einfo, enum_modes_callback);
	if (result != DD_OK) mame_printf_verbose("DirectDraw: Error %08X during EnumDisplayModes call\n", (int)result);
	mame_printf_verbose("DirectDraw: Mode selected = %4dx%4d@%3dHz\n", dd->width, dd->height, dd->refresh);
}
Exemplo n.º 13
0
uint8_t z80ctc_device::ctc_channel::read()
{
	// if we're in counter mode, just return the count
	if ((m_mode & MODE) == MODE_COUNTER || (m_mode & WAITING_FOR_TRIG))
		return m_down;

	// else compute the down counter value
	else
	{
		attotime period = ((m_mode & PRESCALER) == PRESCALER_16) ? m_device->m_period16 : m_device->m_period256;

		VPRINTF_CHANNEL(("CTC clock %f\n",ATTOSECONDS_TO_HZ(period.attoseconds())));

		if (m_timer != nullptr)
			return ((int)(m_timer->remaining().as_double() / period.as_double()) + 1) & 0xff;
		else
			return 0;
	}
}
Exemplo n.º 14
0
std::string machine_info::game_info_string()
{
	std::ostringstream buf;

	// print description, manufacturer, and CPU:
	util::stream_format(buf, _("%1$s\n%2$s %3$s\nDriver: %4$s\n\nCPU:\n"),
			m_machine.system().description,
			m_machine.system().year,
			m_machine.system().manufacturer,
			core_filename_extract_base(m_machine.system().source_file));

	// loop over all CPUs
	execute_interface_iterator execiter(m_machine.root_device());
	std::unordered_set<std::string> exectags;
	for (device_execute_interface &exec : execiter)
	{
		if (!exectags.insert(exec.device().tag()).second)
			continue;
		// get cpu specific clock that takes internal multiplier/dividers into account
		int clock = exec.device().clock();

		// count how many identical CPUs we have
		int count = 1;
		const char *name = exec.device().name();
		for (device_execute_interface &scan : execiter)
		{
			if (exec.device().type() == scan.device().type() && strcmp(name, scan.device().name()) == 0 && exec.device().clock() == scan.device().clock())
				if (exectags.insert(scan.device().tag()).second)
					count++;
		}

		// if more than one, prepend a #x in front of the CPU name
		// display clock in kHz or MHz
		util::stream_format(buf,
				(count > 1) ? "%1$d" UTF8_MULTIPLY "%2$s %3$d.%4$0*5$d%6$s\n" : "%2$s %3$d.%4$0*5$d%6$s\n",
				count,
				name,
				(clock >= 1000000) ? (clock / 1000000) : (clock / 1000),
				(clock >= 1000000) ? (clock % 1000000) : (clock % 1000),
				(clock >= 1000000) ? 6 : 3,
				(clock >= 1000000) ? _("MHz") : _("kHz"));
	}

	// loop over all sound chips
	sound_interface_iterator snditer(m_machine.root_device());
	std::unordered_set<std::string> soundtags;
	bool found_sound = false;
	for (device_sound_interface &sound : snditer)
	{
		if (!soundtags.insert(sound.device().tag()).second)
			continue;

		// append the Sound: string
		if (!found_sound)
			buf << _("\nSound:\n");
		found_sound = true;

		// count how many identical sound chips we have
		int count = 1;
		for (device_sound_interface &scan : snditer)
		{
			if (sound.device().type() == scan.device().type() && sound.device().clock() == scan.device().clock())
				if (soundtags.insert(scan.device().tag()).second)
					count++;
		}

		// if more than one, prepend a #x in front of the CPU name
		// display clock in kHz or MHz
		int clock = sound.device().clock();
		util::stream_format(buf,
				(count > 1)
					? ((clock != 0) ? "%1$d" UTF8_MULTIPLY "%2$s %3$d.%4$0*5$d%6$s\n" : "%1$d" UTF8_MULTIPLY "%2$s\n")
					: ((clock != 0) ? "%2$s %3$d.%4$0*5$d%6$s\n" : "%2$s\n"),
				count,
				sound.device().name(),
				(clock >= 1000000) ? (clock / 1000000) : (clock / 1000),
				(clock >= 1000000) ? (clock % 1000000) : (clock % 1000),
				(clock >= 1000000) ? 6 : 3,
				(clock >= 1000000) ? _("MHz") : _("kHz"));
	}

	// display screen information
	buf << _("\nVideo:\n");
	screen_device_iterator scriter(m_machine.root_device());
	int scrcount = scriter.count();
	if (scrcount == 0)
		buf << _("None\n");
	else
	{
		for (screen_device &screen : scriter)
		{
			std::string detail;
			if (screen.screen_type() == SCREEN_TYPE_VECTOR)
				detail = _("Vector");
			else
			{
				const rectangle &visarea = screen.visible_area();
				detail = string_format("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz",
						visarea.width(), visarea.height(),
						(m_machine.system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",
						ATTOSECONDS_TO_HZ(screen.frame_period().attoseconds()));
			}

			util::stream_format(buf,
					(scrcount > 1) ? _("%1$s: %2$s\n") : _("%2$s\n"),
					get_screen_desc(screen), detail);
		}
	}

	return buf.str();
}
Exemplo n.º 15
0
static int is_ntsc(running_machine *machine)
{
	return ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds) > 55;
}
Exemplo n.º 16
0
void ui_menu_device_config::populate()
{
	astring string;
	device_t *dev;

	string.printf("[This option is%s currently mounted in the running system]\n\n", m_mounted ? "" : " NOT");
	string.catprintf("Option: %s\n", m_option->name());

	dev = const_cast<machine_config &>(machine().config()).device_add(&machine().config().root_device(), m_option->name(), m_option->devtype(), 0);

	string.catprintf("Device: %s\n", dev->name());
	if (!m_mounted)
		string.cat("\nIf you select this option, the following items will be enabled:\n");
	else
		string.cat("\nThe selected option enables the following items:\n");

	// loop over all CPUs
	execute_interface_iterator execiter(*dev);
	if (execiter.count() > 0)
	{
		string.cat("* CPU:\n");
		tagmap_t<UINT8> exectags;
		for (device_execute_interface *exec = execiter.first(); exec != NULL; exec = execiter.next())
		{
			if (exectags.add(exec->device().tag(), 1, FALSE) == TMERR_DUPLICATE)
				continue;

			// get cpu specific clock that takes internal multiplier/dividers into account
			int clock = exec->device().clock();

			// count how many identical CPUs we have
			int count = 1;
			const char *name = exec->device().name();
			execute_interface_iterator execinneriter(*dev);
			for (device_execute_interface *scan = execinneriter.first(); scan != NULL; scan = execinneriter.next())
			{
				if (exec->device().type() == scan->device().type() && strcmp(name, scan->device().name()) == 0 && exec->device().clock() == scan->device().clock())
					if (exectags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE)
						count++;
			}

			// if more than one, prepend a #x in front of the CPU name
			if (count > 1)
				string.catprintf("  %d" UTF8_MULTIPLY, count);
			else
				string.cat("  ");
			string.cat(name);

			// display clock in kHz or MHz
			if (clock >= 1000000)
				string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
			else
				string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
		}
	}

	// display screen information
	screen_device_iterator scriter(*dev);
	if (scriter.count() > 0)
	{
		string.cat("* Video:\n");
		for (screen_device *screen = scriter.first(); screen != NULL; screen = scriter.next())
		{
			string.catprintf("  Screen '%s': ", screen->tag());

			if (screen->screen_type() == SCREEN_TYPE_VECTOR)
				string.cat("Vector\n");
			else
			{
				const rectangle &visarea = screen->visible_area();

				string.catprintf("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
									visarea.width(), visarea.height(),
									(machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",
									ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds));
			}
		}
	}

	// loop over all sound chips
	sound_interface_iterator snditer(*dev);
	if (snditer.count() > 0)
	{
		string.cat("* Sound:\n");
		tagmap_t<UINT8> soundtags;
		for (device_sound_interface *sound = snditer.first(); sound != NULL; sound = snditer.next())
		{
			if (soundtags.add(sound->device().tag(), 1, FALSE) == TMERR_DUPLICATE)
				continue;

			// count how many identical sound chips we have
			int count = 1;
			sound_interface_iterator sndinneriter(*dev);
			for (device_sound_interface *scan = sndinneriter.first(); scan != NULL; scan = sndinneriter.next())
			{
				if (sound->device().type() == scan->device().type() && sound->device().clock() == scan->device().clock())
					if (soundtags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE)
						count++;
			}
			// if more than one, prepend a #x in front of the CPU name
			if (count > 1)
				string.catprintf("  %d" UTF8_MULTIPLY, count);
			else
				string.cat("  ");
			string.cat(sound->device().name());

			// display clock in kHz or MHz
			int clock = sound->device().clock();
			if (clock >= 1000000)
				string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
			else if (clock != 0)
				string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
			else
				string.cat("\n");
		}
	}

	// scan for BIOS settings
	int bios = 0;
	if (dev->rom_region())
	{
		astring bios_str;
		// first loop through roms in search of default bios (shortname)
		for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++)
			if (ROMENTRY_ISDEFAULT_BIOS(rom))
				bios_str.cpy(ROM_GETNAME(rom));

		// then loop again to count bios options and to get the default bios complete name
		for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++)
		{
			if (ROMENTRY_ISSYSTEM_BIOS(rom))
			{
				bios++;
				if (bios_str == ROM_GETNAME(rom))
					bios_str.cpy(ROM_GETHASHDATA(rom));
			}
		}

		if (bios)
			string.catprintf("* BIOS settings:\n  %d options    [default: %s]\n", bios, bios_str.cstr());
	}

	int input = 0, input_mj = 0, input_hana = 0, input_gamble = 0, input_analog = 0, input_adjust = 0;
	int input_keypad = 0, input_keyboard = 0, dips = 0, confs = 0;
	astring errors, dips_opt, confs_opt;
	ioport_list portlist;
	device_iterator iptiter(*dev);
	for (device_t *iptdev = iptiter.first(); iptdev != NULL; iptdev = iptiter.next())
		portlist.append(*iptdev, errors);

	// check if the device adds inputs to the system
	for (ioport_port *port = portlist.first(); port != NULL; port = port->next())
		for (ioport_field *field = port->first_field(); field != NULL; field = field->next())
		{
			if (field->type() >= IPT_MAHJONG_FIRST && field->type() < IPT_MAHJONG_LAST)
				input_mj++;
			else if (field->type() >= IPT_HANAFUDA_FIRST && field->type() < IPT_HANAFUDA_LAST)
				input_hana++;
			else if (field->type() >= IPT_GAMBLING_FIRST && field->type() < IPT_GAMBLING_LAST)
				input_gamble++;
			else if (field->type() >= IPT_ANALOG_FIRST && field->type() < IPT_ANALOG_LAST)
				input_analog++;
			else if (field->type() == IPT_ADJUSTER)
				input_adjust++;
			else if (field->type() == IPT_KEYPAD)
				input_keypad++;
			else if (field->type() == IPT_KEYBOARD)
				input_keyboard++;
			else if (field->type() >= IPT_START1 && field->type() < IPT_UI_FIRST)
				input++;
			else if (field->type() == IPT_DIPSWITCH)
			{
				dips++;
				dips_opt.cat("  ").cat(field->name());
				for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next())
				{
					if (setting->value() == field->defvalue())
					{
						dips_opt.catprintf("    [default: %s]\n", setting->name());
						break;
					}
				}
			}
			else if (field->type() == IPT_CONFIG)
			{
				confs++;
				confs_opt.cat("  ").cat(field->name());
				for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next())
				{
					if (setting->value() == field->defvalue())
					{
						confs_opt.catprintf("    [default: %s]\n", setting->name());
						break;
					}
				}
			}
		}

	if (dips)
		string.cat("* Dispwitch settings:\n").cat(dips_opt);
	if (confs)
		string.cat("* Configuration settings:\n").cat(confs_opt);
	if (input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard)
		string.cat("* Input device(s):\n");
	if (input)
		string.catprintf("  User inputs    [%d inputs]\n", input);
	if (input_mj)
		string.catprintf("  Mahjong inputs    [%d inputs]\n", input_mj);
	if (input_hana)
		string.catprintf("  Hanafuda inputs    [%d inputs]\n", input_hana);
	if (input_gamble)
		string.catprintf("  Gambling inputs    [%d inputs]\n", input_gamble);
	if (input_analog)
		string.catprintf("  Analog inputs    [%d inputs]\n", input_analog);
	if (input_adjust)
		string.catprintf("  Adjuster inputs    [%d inputs]\n", input_adjust);
	if (input_keypad)
		string.catprintf("  Keypad inputs    [%d inputs]\n", input_keypad);
	if (input_keyboard)
		string.catprintf("  Keyboard inputs    [%d inputs]\n", input_keyboard);

	image_interface_iterator imgiter(*dev);
	if (imgiter.count() > 0)
	{
		string.cat("* Media Options:\n");
		for (const device_image_interface *imagedev = imgiter.first(); imagedev != NULL; imagedev = imgiter.next())
			string.catprintf("  %s    [tag: %s]\n", imagedev->image_type_name(), imagedev->device().tag());
	}

	slot_interface_iterator slotiter(*dev);
	if (slotiter.count() > 0)
	{
		string.cat("* Slot Options:\n");
		for (const device_slot_interface *slot = slotiter.first(); slot != NULL; slot = slotiter.next())
			string.catprintf("  %s    [default: %s]\n", slot->device().tag(), slot->default_option() ? slot->default_option() : "----");
	}

	if ((execiter.count() + scriter.count() + snditer.count() + imgiter.count() + slotiter.count() + bios + dips + confs
			+ input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard) == 0)
		string.cat("[None]\n");

	const_cast<machine_config &>(machine().config()).device_remove(&machine().config().root_device(), m_option->name());
	item_append(string, NULL, MENU_FLAG_MULTILINE, NULL);
}
Exemplo n.º 17
0
void video_manager::begin_recording(const char *name, movie_format format)
{
	// create a snapshot bitmap so we know what the target size is
	create_snapshot_bitmap(nullptr);

	// start up an AVI recording
	if (format == MF_AVI)
	{
		// stop any existing recording
		end_recording(format);

		// reset the state
		m_avi_frame = 0;
		m_avi_next_frame_time = machine().time();

		// build up information about this new movie
		screen_device *screen = machine().first_screen();
		avi_file::movie_info info;
		info.video_format = 0;
		info.video_timescale = 1000 * ((screen != nullptr) ? ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds()) : screen_device::DEFAULT_FRAME_RATE);
		info.video_sampletime = 1000;
		info.video_numsamples = 0;
		info.video_width = m_snap_bitmap.width();
		info.video_height = m_snap_bitmap.height();
		info.video_depth = 24;

		info.audio_format = 0;
		info.audio_timescale = machine().sample_rate();
		info.audio_sampletime = 1;
		info.audio_numsamples = 0;
		info.audio_channels = 2;
		info.audio_samplebits = 16;
		info.audio_samplerate = machine().sample_rate();

		// create a new temporary movie file
		osd_file::error filerr;
		std::string fullpath;
		{
			emu_file tempfile(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
			if (name != nullptr)
				filerr = tempfile.open(name);
			else
				filerr = open_next(tempfile, "avi");

			// if we succeeded, make a copy of the name and create the real file over top
			if (filerr == osd_file::error::NONE)
				fullpath = tempfile.fullpath();
		}

		if (filerr == osd_file::error::NONE)
		{
			// compute the frame time
			m_avi_frame_period = attotime::from_seconds(1000) / info.video_timescale;

			// create the file and free the string
			avi_file::error avierr = avi_file::create(fullpath, info, m_avi_file);
			if (avierr != avi_file::error::NONE)
			{
				osd_printf_error("Error creating AVI: %s\n", avi_file::error_string(avierr));
				return end_recording(format);
			}
		}
	}

	// start up a MNG recording
	else if (format == MF_MNG)
	{
		// stop any existing recording
		end_recording(format);

		// reset the state
		m_mng_frame = 0;
		m_mng_next_frame_time = machine().time();

		// create a new movie file and start recording
		m_mng_file = std::make_unique<emu_file>(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
		osd_file::error filerr;
		if (name != nullptr)
			filerr = m_mng_file->open(name);
		else
			filerr = open_next(*m_mng_file, "mng");

		if (filerr == osd_file::error::NONE)
		{
			// start the capture
			screen_device *screen = machine().first_screen();
			int rate = (screen != nullptr) ? ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds()) : screen_device::DEFAULT_FRAME_RATE;
			png_error pngerr = mng_capture_start(*m_mng_file, m_snap_bitmap, rate);
			if (pngerr != PNGERR_NONE)
			{
				osd_printf_error("Error capturing MNG, png_error=%d\n", pngerr);
				return end_recording(format);
			}

			// compute the frame time
			m_mng_frame_period = attotime::from_hz(rate);
		}
		else
		{
			osd_printf_error("Error creating MNG, osd_file::error=%d\n", int(filerr));
			m_mng_file.reset();
		}
	}
}
Exemplo n.º 18
0
void video_manager::begin_recording(const char *name, movie_format format)
{
	// stop any existign recording
	end_recording();

	// create a snapshot bitmap so we know what the target size is
	create_snapshot_bitmap(NULL);

	// reset the state
	m_movie_frame = 0;
	m_movie_next_frame_time = machine().time();

	// start up an AVI recording
	if (format == MF_AVI)
	{
		// build up information about this new movie
		avi_movie_info info;
		info.video_format = 0;
		info.video_timescale = 1000 * ((machine().primary_screen != NULL) ? ATTOSECONDS_TO_HZ(machine().primary_screen->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE);
		info.video_sampletime = 1000;
		info.video_numsamples = 0;
		info.video_width = m_snap_bitmap.width();
		info.video_height = m_snap_bitmap.height();
		info.video_depth = 24;

		info.audio_format = 0;
		info.audio_timescale = machine().sample_rate();
		info.audio_sampletime = 1;
		info.audio_numsamples = 0;
		info.audio_channels = 2;
		info.audio_samplebits = 16;
		info.audio_samplerate = machine().sample_rate();

		// create a new temporary movie file
		file_error filerr;
		astring fullpath;
		{
			emu_file tempfile(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
			if (name != NULL)
				filerr = tempfile.open(name);
			else
				filerr = open_next(tempfile, "avi");

			// compute the frame time
			m_movie_frame_period = attotime::from_seconds(1000) / info.video_timescale;

			// if we succeeded, make a copy of the name and create the real file over top
			if (filerr == FILERR_NONE)
				fullpath = tempfile.fullpath();
		}

		if (filerr == FILERR_NONE)
		{
			// create the file and free the string
			avi_error avierr = avi_create(fullpath, &info, &m_avifile);
			if (avierr != AVIERR_NONE)
				mame_printf_error("Error creating AVI: %s\n", avi_error_string(avierr));
		}
	}

	// start up a MNG recording
	else if (format == MF_MNG)
	{
		// create a new movie file and start recording
		m_mngfile = auto_alloc(machine(), emu_file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
		file_error filerr;
		if (name != NULL)
			filerr = m_mngfile->open(name);
		else
			filerr = open_next(*m_mngfile, "mng");

		if (filerr == FILERR_NONE)
		{
			// start the capture
			int rate = (machine().primary_screen != NULL) ? ATTOSECONDS_TO_HZ(machine().primary_screen->frame_period().attoseconds) : screen_device::DEFAULT_FRAME_RATE;
			png_error pngerr = mng_capture_start(*m_mngfile, m_snap_bitmap, rate);
			if (pngerr != PNGERR_NONE)
				return end_recording();

			// compute the frame time
			m_movie_frame_period = attotime::from_hz(rate);
		}
		else
		{
			mame_printf_error("Error creating MNG\n");
			global_free(m_mngfile);
			m_mngfile = NULL;
		}
	}
}
Exemplo n.º 19
0
int load_driver_mameinfo(const game_driver *drv, char *buffer, int bufsize, int filenum)
{
	machine_config config(*drv, MameUIGlobal());
	const game_driver *parent = NULL;
	char name[512];
	int mameinfo = 0;
	int is_bios = 0;

	*buffer = 0;

	if (filenum)
		snprintf(filename, ARRAY_LENGTH(filename), "%s\\messinfo.dat", GetDatsDir());
	else
		snprintf(filename, ARRAY_LENGTH(filename), "%s\\mameinfo.dat", GetDatsDir());

	if (filenum)
		strcat(buffer, "\n**** MESSINFO: ****\n\n");
	else
		strcat(buffer, "\n**** MAMEINFO: ****\n\n");

	/* List the game info 'flags' */
	if (drv->flags & MACHINE_NOT_WORKING)
		strcat(buffer, "THIS GAME DOESN'T WORK PROPERLY\n");

	if (drv->flags & MACHINE_UNEMULATED_PROTECTION)
		strcat(buffer, "The game has protection which isn't fully emulated.\n");

	if (drv->flags & MACHINE_IMPERFECT_GRAPHICS)
		strcat(buffer, "The video emulation isn't 100% accurate.\n");

	if (drv->flags & MACHINE_WRONG_COLORS)
		strcat(buffer, "The colors are completely wrong.\n");

	if (drv->flags & MACHINE_IMPERFECT_COLORS)
		strcat(buffer, "The colors aren't 100% accurate.\n");

	if (drv->flags & MACHINE_NO_SOUND)
		strcat(buffer, "The game lacks sound.\n");

	if (drv->flags & MACHINE_IMPERFECT_SOUND)
		strcat(buffer, "The sound emulation isn't 100% accurate.\n");

	if (drv->flags & MACHINE_SUPPORTS_SAVE)
		strcat(buffer, "Save state support.\n");

	if (drv->flags & MACHINE_MECHANICAL)
		strcat(buffer, "The game contains mechanical parts.\n");

	strcat(buffer, "\n");

	if (drv->flags & MACHINE_IS_BIOS_ROOT)
		is_bios = 1;

	/* try to open mameinfo datafile */
	if (ParseOpen(filename))
	{
		if (filenum)
		{
			/* create index if necessary */
			if (mess_idx)
				mameinfo = 1;
			else
				mameinfo = (index_datafile (&mess_idx, 0) != 0);

			/* load informational text (append) */
			if (mess_idx)
			{
				int len = strlen(buffer);
				int err = 0;
				const game_driver *gdrv;
				gdrv = drv;

				do
				{
					err = load_datafile_text(gdrv, buffer + len, bufsize - len, mess_idx, DATAFILE_TAG_MAME, 0, 1);
					int g = driver_list::clone(*gdrv);

					if (g!=-1)
						gdrv = &driver_list::driver(g);
					else
						gdrv = NULL;
				} while (err && gdrv);

				if (err)
					mameinfo = 0;
			}
		}
		else
		{
			/* create index if necessary */
			if (mame_idx)
				mameinfo = 1;
			else
				mameinfo = (index_datafile (&mame_idx, 0) != 0);

			/* load informational text (append) */
			if (mame_idx)
			{
				int len = strlen(buffer);
				int err = 0;
				const game_driver *gdrv;
				gdrv = drv;

				do
				{
					err = load_datafile_text(gdrv, buffer + len, bufsize - len, mame_idx, DATAFILE_TAG_MAME, 0, 1);
					int g = driver_list::clone(*gdrv);

					if (g!=-1)
						gdrv = &driver_list::driver(g);
					else
						gdrv = NULL;
				} while (err && gdrv);

				if (err)
					mameinfo = 0;
			}
		}

		ParseClose();
	}

	/* GAME INFORMATIONS */
	snprintf(name, ARRAY_LENGTH(name), "\nGAME: %s\n", drv->name);
	strcat(buffer, name);
	snprintf(name, ARRAY_LENGTH(name), "%s", drv->description);
	strcat(buffer, name);
	snprintf(name, ARRAY_LENGTH(name), " (%s %s)\n\nCPU:\n", drv->manufacturer, drv->year);
	strcat(buffer, name);
	/* iterate over CPUs */
	execute_interface_iterator iter(config.root_device());
	device_execute_interface *cpu = iter.first();

	while (cpu)
	{
		if (cpu->device().clock() >= 1000000)
			snprintf(name, ARRAY_LENGTH(name), "%s %d.%06d MHz\n", cpu->device().name(), cpu->device().clock() / 1000000, cpu->device().clock() % 1000000);
		else
			snprintf(name, ARRAY_LENGTH(name), "%s %d.%03d kHz\n", cpu->device().name(), cpu->device().clock() / 1000, cpu->device().clock() % 1000);

		strcat(buffer, name);
		cpu = iter.next();
	}

	strcat(buffer, "\nSOUND:\n");
	int has_sound = 0;
	/* iterate over sound chips */
	sound_interface_iterator sounditer(config.root_device());
	const device_sound_interface *sound = sounditer.first();

	while(sound)
	{
		int clock = 0;
		int count = 0;
		device_type sound_type_;
		char tmpname[1024];

		snprintf(tmpname, ARRAY_LENGTH(tmpname), "%s", sound->device().name());
		sound_type_ = sound->device().type();
		clock = sound->device().clock();
		has_sound = 1;
		count = 1;
		sound = sounditer.next();

		/* Matching chips at the same clock are aggregated */
		while (sound && sound->device().type() == sound_type_ && sound->device().clock() == clock)
		{
			count++;
			sound = sounditer.next();
		}

		if (count > 1)
		{
			snprintf(name, ARRAY_LENGTH(name), "%dx ",count);
			strcat(buffer, name);
		}

		strcat(buffer, tmpname);

		if (clock)
		{
			if (clock >= 1000000)
				snprintf(name, ARRAY_LENGTH(name), " %d.%06d MHz", clock / 1000000, clock % 1000000);
			else
				snprintf(name, ARRAY_LENGTH(name), " %d.%03d kHz", clock / 1000, clock % 1000);

			strcat(buffer, name);
		}

		strcat(buffer, "\n");
	}

	if (has_sound)
	{
		speaker_device_iterator iter(config.root_device());
		int channels = iter.count();

		if(channels == 1)
			snprintf(name, ARRAY_LENGTH(name), "%d Channel\n",channels);
		else
			snprintf(name, ARRAY_LENGTH(name), "%dx Channels\n",channels);

		strcat(buffer, name);
	}

	strcat(buffer, "\nVIDEO:\n");
	screen_device_iterator screeniter(config.root_device());
	const screen_device *screen = screeniter.first();

	if (screen == nullptr)
		strcat(buffer, "Screenless\n");
	else if (screen->screen_type() == SCREEN_TYPE_VECTOR)
		strcat(buffer,"Vector\n");
	else
	{
		for (; screen != nullptr; screen = screeniter.next())
		{
			if (drv->flags & ORIENTATION_SWAP_XY)
				snprintf(name, ARRAY_LENGTH(name), "%d x %d (V)", screen->visible_area().height(), screen->visible_area().width());
			else
				snprintf(name, ARRAY_LENGTH(name), "%d x %d (H)", screen->visible_area().width(), screen->visible_area().height());

			strcat(buffer, name);
			snprintf(name, ARRAY_LENGTH(name), " %f Hz", ATTOSECONDS_TO_HZ(screen->refresh_attoseconds()));
			strcat(buffer, name);
			strcat(buffer, "\n");
		}
	}

	strcat(buffer, "\nROM REGION:\n");
	int g = driver_list::clone(*drv);

	if (g!=-1)
		parent = &driver_list::driver(g);

	device_iterator deviter(config.root_device());

	for (device_t *device = deviter.first(); device; device = deviter.next())
	{
		for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region))
		{
			for (const rom_entry *rom = rom_first_file(region); rom != nullptr; rom = rom_next_file(rom))
			{
				hash_collection hashes(ROM_GETHASHDATA(rom));

				if (g!=-1)
				{
					machine_config pconfig(*parent, MameUIGlobal());
					device_iterator deviter(pconfig.root_device());

					for (device_t *device = deviter.first(); device != nullptr; device = deviter.next())
						for (const rom_entry *pregion = rom_first_region(*device); pregion != nullptr; pregion = rom_next_region(pregion))
							for (const rom_entry *prom = rom_first_file(pregion); prom != nullptr; prom = rom_next_file(prom))
							{
								hash_collection phashes(ROM_GETHASHDATA(prom));

								if (hashes == phashes)
									break;
							}
				}

				snprintf(name, ARRAY_LENGTH(name), "%-16s \t", ROM_GETNAME(rom));
				strcat(buffer, name);
				snprintf(name, ARRAY_LENGTH(name), "%09d \t", rom_file_size(rom));
				strcat(buffer, name);
				snprintf(name, ARRAY_LENGTH(name), "%-10s", ROMREGION_GETTAG(region));
				strcat(buffer, name);
				strcat(buffer, "\n");
			}
		}
	}

	samples_device_iterator samplesiter(config.root_device());

	for (samples_device *device = samplesiter.first(); device != nullptr; device = samplesiter.next())
	{
		samples_iterator sampiter(*device);

		if (sampiter.altbasename() != nullptr)
		{
			snprintf(name, ARRAY_LENGTH(name), "\nSAMPLES (%s):\n", sampiter.altbasename());
			strcat(buffer, name);
		}

		std::unordered_set<std::string> already_printed;

		for (const char *samplename = sampiter.first(); samplename != nullptr; samplename = sampiter.next())
		{
			// filter out duplicates
			if (!already_printed.insert(samplename).second)
				continue;

			// output the sample name
			snprintf(name, ARRAY_LENGTH(name), "%s.wav\n", samplename);
			strcat(buffer, name);
		}
	}

	if (!is_bios)
	{
		int g = driver_list::clone(*drv);

		if (g!=-1)
			drv = &driver_list::driver(g);

		strcat(buffer, "\nORIGINAL:\n");
		strcat(buffer, drv->description);
		strcat(buffer, "\n\nCLONES:\n");

		for (int i = 0; i < driver_list::total(); i++)
		{
			if (!strcmp (drv->name, driver_list::driver(i).parent))
			{
				strcat(buffer, driver_list::driver(i).description);
				strcat(buffer, "\n");
			}
		}
	}

	strcat(buffer, "\n");
	return (mameinfo == 0);
}
Exemplo n.º 20
0
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");
	}
}
Exemplo n.º 21
0
void info_xml_creator::output_display(device_t &device, const char *root_tag)
{
	// iterate over screens
	screen_device_iterator iter(device);
	for (const screen_device *screendev = iter.first(); screendev != NULL; screendev = iter.next())
	{
		if (strcmp(screendev->tag(), device.tag()))
		{
			astring newtag(screendev->tag()), oldtag(":");
			newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());

			fprintf(m_output, "\t\t<display");
			fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));

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

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

			// output width and height only for games that are not vector
			if (screendev->screen_type() != SCREEN_TYPE_VECTOR)
			{
				const rectangle &visarea = screendev->visible_area();
				fprintf(m_output, " width=\"%d\"", visarea.width());
				fprintf(m_output, " height=\"%d\"", visarea.height());
			}

			// output refresh rate
			fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds()));

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

				fprintf(m_output, " pixclock=\"%d\"", pixclock);
				fprintf(m_output, " htotal=\"%d\"", screendev->width());
				fprintf(m_output, " hbend=\"%d\"", screendev->visible_area().min_x);
				fprintf(m_output, " hbstart=\"%d\"", screendev->visible_area().max_x+1);
				fprintf(m_output, " vtotal=\"%d\"", screendev->height());
				fprintf(m_output, " vbend=\"%d\"", screendev->visible_area().min_y);
				fprintf(m_output, " vbstart=\"%d\"", screendev->visible_area().max_y+1);
			}
			fprintf(m_output, " />\n");
		}
	}
}
Exemplo n.º 22
0
void info_xml_creator::output_display()
{
	// iterate over screens
	for (const screen_device *device = m_drivlist.config().first_screen(); device != NULL; device = device->next_screen())
	{
		fprintf(m_output, "\t\t<display");

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

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

		// output width and height only for games that are not vector
		if (device->screen_type() != SCREEN_TYPE_VECTOR)
		{
			const rectangle &visarea = device->visible_area();
			fprintf(m_output, " width=\"%d\"", visarea.max_x - visarea.min_x + 1);
			fprintf(m_output, " height=\"%d\"", visarea.max_y - visarea.min_y + 1);
		}

		// output refresh rate
		fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(device->refresh_attoseconds()));

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

			fprintf(m_output, " pixclock=\"%d\"", pixclock);
			fprintf(m_output, " htotal=\"%d\"", device->width());
			fprintf(m_output, " hbend=\"%d\"", device->visible_area().min_x);
			fprintf(m_output, " hbstart=\"%d\"", device->visible_area().max_x+1);
			fprintf(m_output, " vtotal=\"%d\"", device->height());
			fprintf(m_output, " vbend=\"%d\"", device->visible_area().min_y);
			fprintf(m_output, " vbstart=\"%d\"", device->visible_area().max_y+1);
		}
		fprintf(m_output, " />\n");
	}
}
Exemplo n.º 23
0
void menu_device_config::populate()
{
	std::ostringstream str;
	device_t *dev;

	util::stream_format(str, "[This option is%s currently mounted in the running system]\n\n", m_mounted ? "" : " NOT");
	util::stream_format(str, "Option: %s\n", m_option->name());

	dev = const_cast<machine_config &>(machine().config()).device_add(&machine().config().root_device(), m_option->name(), m_option->devtype(), 0);

	util::stream_format(str, "Device: %s\n", dev->name());
	if (!m_mounted)
		str << "\nIf you select this option, the following items will be enabled:\n";
	else
		str << "\nThe selected option enables the following items:\n";

	// loop over all CPUs
	execute_interface_iterator execiter(*dev);
	if (execiter.count() > 0)
	{
		str << "* CPU:\n";
		std::unordered_set<std::string> exectags;
		for (device_execute_interface &exec : execiter)
		{
			if (!exectags.insert(exec.device().tag()).second)
				continue;

			// get cpu specific clock that takes internal multiplier/dividers into account
			int clock = exec.device().clock();

			// count how many identical CPUs we have
			int count = 1;
			const char *name = exec.device().name();
			for (device_execute_interface &scan : execiter)
			{
				if (exec.device().type() == scan.device().type() && strcmp(name, scan.device().name()) == 0 && exec.device().clock() == scan.device().clock())
					if (exectags.insert(scan.device().tag()).second)
						count++;
			}

			// if more than one, prepend a #x in front of the CPU name
			if (count > 1)
				util::stream_format(str, "  %d" UTF8_MULTIPLY, count);
			else
				str << "  ";
			str << name;

			// display clock in kHz or MHz
			if (clock >= 1000000)
				util::stream_format(str, " %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
			else
				util::stream_format(str, " %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
		}
	}

	// display screen information
	screen_device_iterator scriter(*dev);
	if (scriter.count() > 0)
	{
		str << "* Video:\n";
		for (screen_device &screen : scriter)
		{
			util::stream_format(str, "  Screen '%s': ", screen.tag());

			if (screen.screen_type() == SCREEN_TYPE_VECTOR)
				str << "Vector\n";
			else
			{
				const rectangle &visarea = screen.visible_area();

				util::stream_format(str, "%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
									visarea.width(), visarea.height(),
									(machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",
									ATTOSECONDS_TO_HZ(screen.frame_period().attoseconds()));
			}
		}
	}

	// loop over all sound chips
	sound_interface_iterator snditer(*dev);
	if (snditer.count() > 0)
	{
		str << "* Sound:\n";
		std::unordered_set<std::string> soundtags;
		for (device_sound_interface &sound : snditer)
		{
			if (!soundtags.insert(sound.device().tag()).second)
				continue;

			// count how many identical sound chips we have
			int count = 1;
			for (device_sound_interface &scan : snditer)
			{
				if (sound.device().type() == scan.device().type() && sound.device().clock() == scan.device().clock())
					if (soundtags.insert(scan.device().tag()).second)
						count++;
			}
			// if more than one, prepend a #x in front of the CPU name
			if (count > 1)
				util::stream_format(str,"  %d" UTF8_MULTIPLY, count);
			else
				str << "  ";
			str << sound.device().name();

			// display clock in kHz or MHz
			int clock = sound.device().clock();
			if (clock >= 1000000)
				util::stream_format(str," %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
			else if (clock != 0)
				util::stream_format(str," %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
			else
				str << '\n';
		}
	}

	// scan for BIOS settings
	int bios = 0;
	if (dev->rom_region())
	{
		std::string bios_str;
		// first loop through roms in search of default bios (shortname)
		for (const rom_entry &rom : dev->rom_region_vector())
			if (ROMENTRY_ISDEFAULT_BIOS(&rom))
				bios_str.assign(ROM_GETNAME(&rom));

		// then loop again to count bios options and to get the default bios complete name
		for (const rom_entry &rom : dev->rom_region_vector())
		{
			if (ROMENTRY_ISSYSTEM_BIOS(&rom))
			{
				bios++;
				if (bios_str.compare(ROM_GETNAME(&rom))==0)
					bios_str.assign(ROM_GETHASHDATA(&rom));
			}
		}

		if (bios)
			util::stream_format(str, "* BIOS settings:\n  %d options    [default: %s]\n", bios, bios_str.c_str());
	}

	int input = 0, input_mj = 0, input_hana = 0, input_gamble = 0, input_analog = 0, input_adjust = 0;
	int input_keypad = 0, input_keyboard = 0, dips = 0, confs = 0;
	std::string errors;
	std::ostringstream dips_opt, confs_opt;
	ioport_list portlist;
	for (device_t &iptdev : device_iterator(*dev))
		portlist.append(iptdev, errors);

	// check if the device adds inputs to the system
	for (auto &port : portlist)
		for (ioport_field &field : port.second->fields())
		{
			if (field.type() >= IPT_MAHJONG_FIRST && field.type() < IPT_MAHJONG_LAST)
				input_mj++;
			else if (field.type() >= IPT_HANAFUDA_FIRST && field.type() < IPT_HANAFUDA_LAST)
				input_hana++;
			else if (field.type() >= IPT_GAMBLING_FIRST && field.type() < IPT_GAMBLING_LAST)
				input_gamble++;
			else if (field.type() >= IPT_ANALOG_FIRST && field.type() < IPT_ANALOG_LAST)
				input_analog++;
			else if (field.type() == IPT_ADJUSTER)
				input_adjust++;
			else if (field.type() == IPT_KEYPAD)
				input_keypad++;
			else if (field.type() == IPT_KEYBOARD)
				input_keyboard++;
			else if (field.type() >= IPT_START1 && field.type() < IPT_UI_FIRST)
				input++;
			else if (field.type() == IPT_DIPSWITCH)
			{
				dips++;
				dips_opt << "  " << field.name();
				for (ioport_setting &setting : field.settings())
				{
					if (setting.value() == field.defvalue())
					{
						util::stream_format(dips_opt, "    [default: %s]\n", setting.name());
						break;
					}
				}
			}
			else if (field.type() == IPT_CONFIG)
			{
				confs++;
				confs_opt << "  " << field.name();
				for (ioport_setting &setting : field.settings())
				{
					if (setting.value() == field.defvalue())
					{
						util::stream_format(confs_opt, "    [default: %s]\n", setting.name());
						break;
					}
				}
			}
		}

	if (dips)
		str << "* Dispwitch settings:\n" << dips_opt.str();
	if (confs)
		str << "* Configuration settings:\n" << confs_opt.str();
	if (input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard)
		str << "* Input device(s):\n";
	if (input)
		util::stream_format(str, "  User inputs    [%d inputs]\n", input);
	if (input_mj)
		util::stream_format(str, "  Mahjong inputs    [%d inputs]\n", input_mj);
	if (input_hana)
		util::stream_format(str, "  Hanafuda inputs    [%d inputs]\n", input_hana);
	if (input_gamble)
		util::stream_format(str, "  Gambling inputs    [%d inputs]\n", input_gamble);
	if (input_analog)
		util::stream_format(str, "  Analog inputs    [%d inputs]\n", input_analog);
	if (input_adjust)
		util::stream_format(str, "  Adjuster inputs    [%d inputs]\n", input_adjust);
	if (input_keypad)
		util::stream_format(str, "  Keypad inputs    [%d inputs]\n", input_keypad);
	if (input_keyboard)
		util::stream_format(str, "  Keyboard inputs    [%d inputs]\n", input_keyboard);

	image_interface_iterator imgiter(*dev);
	if (imgiter.count() > 0)
	{
		str << "* Media Options:\n";
		for (const device_image_interface &imagedev : imgiter)
			util::stream_format(str, "  %s    [tag: %s]\n", imagedev.image_type_name(), imagedev.device().tag());
	}

	slot_interface_iterator slotiter(*dev);
	if (slotiter.count() > 0)
	{
		str << "* Slot Options:\n";
		for (const device_slot_interface &slot : slotiter)
			util::stream_format(str, "  %s    [default: %s]\n", slot.device().tag(), slot.default_option() ? slot.default_option() : "----");
	}

	if ((execiter.count() + scriter.count() + snditer.count() + imgiter.count() + slotiter.count() + bios + dips + confs
			+ input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard) == 0)
			str << "[None]\n";

	const_cast<machine_config &>(machine().config()).device_remove(&machine().config().root_device(), m_option->name());
	item_append(str.str(), "", FLAG_MULTILINE, nullptr);
}
Exemplo n.º 24
0
int gtia_device::is_ntsc()
{
	return ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds()) > 55;
}
Exemplo n.º 25
0
void nesapu_device::device_start()
{
	int rate = clock() / 4;

	/* Initialize global variables */
	m_samps_per_sync = rate / ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds);
	m_buffer_size = m_samps_per_sync;
	m_real_rate = m_samps_per_sync * ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds);
	m_apu_incsize = (float) (clock() / (float) m_real_rate);

	/* Use initializer calls */
	create_noise(m_noise_lut, 13, NOISE_LONG);
	create_vbltimes(m_vbl_times,vbl_length,m_samps_per_sync);
	create_syncs(m_samps_per_sync);

	/* Adjust buffer size if 16 bits */
	m_buffer_size+=m_samps_per_sync;

	/* Initialize individual chips */
	(m_APU.dpcm).memory = &machine().device(m_cpu_tag)->memory().space(AS_PROGRAM);

	m_stream = machine().sound().stream_alloc(*this, 0, 1, rate);

	/* register for save */
	for (int i = 0; i < 2; i++)
	{
		save_item(NAME(m_APU.squ[i].regs), i);
		save_item(NAME(m_APU.squ[i].vbl_length), i);
		save_item(NAME(m_APU.squ[i].freq), i);
		save_item(NAME(m_APU.squ[i].phaseacc), i);
		save_item(NAME(m_APU.squ[i].output_vol), i);
		save_item(NAME(m_APU.squ[i].env_phase), i);
		save_item(NAME(m_APU.squ[i].sweep_phase), i);
		save_item(NAME(m_APU.squ[i].adder), i);
		save_item(NAME(m_APU.squ[i].env_vol), i);
		save_item(NAME(m_APU.squ[i].enabled), i);
	}

	save_item(NAME(m_APU.tri.regs));
	save_item(NAME(m_APU.tri.linear_length));
	save_item(NAME(m_APU.tri.vbl_length));
	save_item(NAME(m_APU.tri.write_latency));
	save_item(NAME(m_APU.tri.phaseacc));
	save_item(NAME(m_APU.tri.output_vol));
	save_item(NAME(m_APU.tri.adder));
	save_item(NAME(m_APU.tri.counter_started));
	save_item(NAME(m_APU.tri.enabled));

	save_item(NAME(m_APU.noi.regs));
	save_item(NAME(m_APU.noi.cur_pos));
	save_item(NAME(m_APU.noi.vbl_length));
	save_item(NAME(m_APU.noi.phaseacc));
	save_item(NAME(m_APU.noi.output_vol));
	save_item(NAME(m_APU.noi.env_phase));
	save_item(NAME(m_APU.noi.env_vol));
	save_item(NAME(m_APU.noi.enabled));

	save_item(NAME(m_APU.dpcm.regs));
	save_item(NAME(m_APU.dpcm.address));
	save_item(NAME(m_APU.dpcm.length));
	save_item(NAME(m_APU.dpcm.bits_left));
	save_item(NAME(m_APU.dpcm.phaseacc));
	save_item(NAME(m_APU.dpcm.output_vol));
	save_item(NAME(m_APU.dpcm.cur_byte));
	save_item(NAME(m_APU.dpcm.enabled));
	save_item(NAME(m_APU.dpcm.irq_occurred));
	save_item(NAME(m_APU.dpcm.vol));

	save_item(NAME(m_APU.regs));

	#ifdef USE_QUEUE
	save_item(NAME(m_APU.queue));
	save_item(NAME(m_APU.head));
	save_item(NAME(m_APU.tail));
	#else
	save_item(NAME(m_APU.buf_pos));
	save_item(NAME(m_APU.step_mode));
	#endif
}
Exemplo n.º 26
0
static int is_ntsc(running_machine &machine)
{
	return ATTOSECONDS_TO_HZ(machine.primary_screen->frame_period().attoseconds) > 55;
}