Example #1
0
void generic_machine_init(running_machine *machine)
{
	int counternum;

	/* reset coin counters */
	for (counternum = 0; counternum < COIN_COUNTERS; counternum++)
	{
		lastcoin[counternum] = 0;
		coinlockedout[counternum] = 0;
		servicecoinlockedout[counternum] = 0;
	}

	/* reset NVRAM size and pointers */
	generic_nvram_size = 0;
	generic_nvram = NULL;
	generic_nvram16 = NULL;
	generic_nvram32 = NULL;

	/* reset memory card info */
	memcard_inserted = -1;

	/* register a reset callback and save state for interrupt enable */
	add_reset_callback(machine, interrupt_reset);
	state_save_register_item_array("cpu", 0, interrupt_enable);

	/* register for configuration */
	config_register("counters", counters_load, counters_save);

	/* for memory cards, request save state and an exit callback */
	if (machine->drv->memcard_handler != NULL)
	{
		state_save_register_global(memcard_inserted);
		add_exit_callback(machine, memcard_eject);
	}
}
Example #2
0
int sound_init(running_machine *machine)
{
	/* handle -nosound */
	nosound_mode = (Machine->sample_rate == 0);
	if (nosound_mode)
		Machine->sample_rate = 11025;

	/* count the speakers */
	for (totalspeakers = 0; Machine->drv->speaker[totalspeakers].tag; totalspeakers++) ;
	VPRINTF(("total speakers = %d\n", totalspeakers));

	/* initialize the OSD layer */
	VPRINTF(("osd_start_audio_stream\n"));
	samples_this_frame = osd_start_audio_stream(1);
	if (!samples_this_frame)
		return 1;

	/* allocate memory for mix buffers */
	leftmix = auto_malloc(Machine->sample_rate * sizeof(*leftmix));
	rightmix = auto_malloc(Machine->sample_rate * sizeof(*rightmix));
	finalmix = auto_malloc(Machine->sample_rate * sizeof(*finalmix));

	/* allocate a global timer for sound timing */
	sound_update_timer = mame_timer_alloc(NULL);

	/* initialize the streams engine */
	VPRINTF(("streams_init\n"));
	streams_init();

	/* now start up the sound chips and tag their streams */
	VPRINTF(("start_sound_chips\n"));
	if (start_sound_chips())
		return 1;

	/* then create all the speakers */
	VPRINTF(("start_speakers\n"));
	if (start_speakers())
		return 1;

	/* finally, do all the routing */
	VPRINTF(("route_sound\n"));
	if (route_sound())
		return 1;

	if (MAKE_WAVS)
		wavfile = wav_open("finalmix.wav", Machine->sample_rate, 2);

	/* enable sound by default */
	global_sound_enabled = TRUE;

	/* register callbacks */
	config_register("mixer", sound_load, sound_save);
	add_pause_callback(machine, sound_pause);
	add_reset_callback(machine, sound_reset);
	add_exit_callback(machine, sound_exit);

	return 0;
}
Example #3
0
void gtia_init(running_machine *machine, const gtia_interface *intf)
{
	memset(&gtia, 0, sizeof(gtia));
	gtia.intf = *intf;

	add_reset_callback(Machine, gtia_reset);

	/* state saves */
	gtia_state(machine);
}
Example #4
0
void sound_init(running_machine *machine)
{
	attotime update_frequency = SOUND_UPDATE_FREQUENCY;
	const char *filename;

	/* handle -nosound */
	nosound_mode = !options_get_bool(mame_options(), OPTION_SOUND);
	if (nosound_mode)
		Machine->sample_rate = 11025;

	/* count the speakers */
	for (totalspeakers = 0; Machine->drv->speaker[totalspeakers].tag; totalspeakers++) ;
	VPRINTF(("total speakers = %d\n", totalspeakers));

	/* allocate memory for mix buffers */
	leftmix = auto_malloc(Machine->sample_rate * sizeof(*leftmix));
	rightmix = auto_malloc(Machine->sample_rate * sizeof(*rightmix));
	finalmix = auto_malloc(Machine->sample_rate * sizeof(*finalmix));

	/* allocate a global timer for sound timing */
	sound_update_timer = timer_alloc(sound_update, NULL);
	timer_adjust(sound_update_timer, update_frequency, 0, update_frequency);

	/* initialize the streams engine */
	VPRINTF(("streams_init\n"));
	streams_init(machine, update_frequency.attoseconds);

	/* now start up the sound chips and tag their streams */
	VPRINTF(("start_sound_chips\n"));
	start_sound_chips();

	/* then create all the speakers */
	VPRINTF(("start_speakers\n"));
	start_speakers();

	/* finally, do all the routing */
	VPRINTF(("route_sound\n"));
	route_sound();

	/* open the output WAV file if specified */
	filename = options_get_string(mame_options(), OPTION_WAVWRITE);
	if (filename[0] != 0)
		wavfile = wav_open(filename, machine->sample_rate, 2);

	/* enable sound by default */
	global_sound_enabled = TRUE;
	sound_muted = FALSE;
	sound_set_attenuation(options_get_int(mame_options(), OPTION_VOLUME));

	/* register callbacks */
	config_register("mixer", sound_load, sound_save);
	add_pause_callback(machine, sound_pause);
	add_reset_callback(machine, sound_reset);
	add_exit_callback(machine, sound_exit);
}
Example #5
0
void watchdog_init(running_machine *machine)
{
	/* allocate a timer for the watchdog */
	watchdog_timer = timer_alloc(machine, watchdog_callback, NULL);

	add_reset_callback(machine, watchdog_internal_reset);

	/* save some stuff in the default tag */
	state_save_register_item(machine, "watchdog", NULL, 0, watchdog_enabled);
	state_save_register_item(machine, "watchdog", NULL, 0, watchdog_counter);
}
Example #6
0
void tecmosys_prot_init(running_machine *machine, int which)
{
	switch (which)
	{
	case 0:	device_data = &deroon_data; break;
	case 1: device_data = &tkdensho_data; break;
	case 2: device_data = &tkdensha_data; break;
	}

	add_reset_callback(machine, tecmosys_prot_reset);
}
Example #7
0
void sam_init(const sam6883_interface *intf)
{
	sam.state = 0;
	sam.old_state = ~0;
	sam.intf = intf;

	add_reset_callback(sam_reset);

	/* save state registration */
	state_save_register_item("6883sam", 0, sam.state);
	state_save_register_item("6883sam", 0, sam.video_position);
	state_save_register_func_postload(update_sam);
}
Example #8
0
static void nes_vh_start(ppu_t ppu_type, double scanlines_per_frame)
{
	ppu2c0x_interface ppu_interface;

	nes_zapper_hack = NULL;

	memset(&ppu_interface, 0, sizeof(ppu_interface));
	ppu_interface.type				= ppu_type;
	ppu_interface.num				= 1;
	ppu_interface.vrom_region[0]	= nes.chr_chunks ? REGION_GFX1 : REGION_INVALID;
	ppu_interface.mirroring[0]		= PPU_MIRROR_NONE;
	ppu_interface.nmi_handler[0]	= ppu_nmi;

	ppu2c0x_init(&ppu_interface);
	ppu2c0x_set_vidaccess_callback(0, nes_ppu_vidaccess);
	ppu2c0x_set_scanlines_per_frame(0, ceil(scanlines_per_frame));

	if (nes.four_screen_vram)
	{
		ppu2c0x_set_mirroring(0, PPU_MIRROR_4SCREEN);
	}
	else
	{
		switch(nes.hard_mirroring)
		{
			case 0:
				ppu2c0x_set_mirroring(0, PPU_MIRROR_HORZ);
				break;
			case 1:
				ppu2c0x_set_mirroring(0, PPU_MIRROR_VERT);
				break;
		}
	}

	add_reset_callback(Machine, nes_vh_reset);

	/* Reset the mapper variables. Will also mark the char-gen ram as dirty */
	mapper_reset(nes.mapper);
}
Example #9
0
static int nes_vh_start(int ppu_scanlines_per_frame)
{
	ppu2c03b_interface ppu_interface;

	memset(&ppu_interface, 0, sizeof(ppu_interface));
	ppu_interface.num				= 1;
	ppu_interface.vrom_region[0]	= nes.chr_chunks ? REGION_GFX1 : REGION_INVALID;
	ppu_interface.mirroring[0]		= PPU_MIRROR_NONE;
	ppu_interface.nmi_handler[0]	= ppu_nmi;

	ppu2c03b_init(&ppu_interface);
	ppu2c03b_set_vidaccess_callback(0, nes_ppu_vidaccess);
	ppu2c03b_set_scanlines_per_frame(0, ppu_scanlines_per_frame);

	if (nes.four_screen_vram)
	{
		/* TODO: figure out what to do here */
	}
	else
	{
		switch(nes.hard_mirroring) {
		case 0:
			ppu2c03b_set_mirroring(0, PPU_MIRROR_HORZ);
			break;
		case 1:
			ppu2c03b_set_mirroring(0, PPU_MIRROR_VERT);
			break;
		}
	}

	add_reset_callback(nes_vh_reset);

	/* Reset the mapper variables. Will also mark the char-gen ram as dirty */
	mapper_reset (nes.mapper);
	return 0;
}
Example #10
0
static void atari_machine_start(running_machine *machine, int type, const pia6821_interface *pia_intf, int has_cart)
{
	gtia_interface gtia_intf;

	atari = type;

	/* GTIA */
	memset(&gtia_intf, 0, sizeof(gtia_intf));
	if (port_tag_to_index("console") >= 0)
		gtia_intf.console_read = console_read;
	if (sndti_exists(SOUND_DAC, 0))
		gtia_intf.console_write = console_write;
	gtia_init(machine, &gtia_intf);

	/* pokey */
	add_reset_callback(Machine, pokey_reset);

	/* PIA */
	if (pia_intf)
	{
		pia_config(0, pia_intf);
		add_reset_callback(Machine, _pia_reset);
	}

	/* ANTIC */
	add_reset_callback(Machine, _antic_reset);

	/* cartridge */
	if (has_cart)
		add_reset_callback(Machine, cart_reset);

#ifdef MESS
	{
		offs_t ram_top;
		offs_t ram_size;

		if (!strcmp(Machine->gamedrv->name, "a400")
			|| !strcmp(Machine->gamedrv->name, "a400pal")
			|| !strcmp(Machine->gamedrv->name, "a800")
			|| !strcmp(Machine->gamedrv->name, "a800pal")
			|| !strcmp(Machine->gamedrv->name, "a800xl"))
		{
			ram_size = 0xA000;
		}
		else
		{
			ram_size = 0x8000;
		}

		/* install RAM */
		ram_top = MIN(mess_ram_size, ram_size) - 1;
		memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM,
			0x0000, ram_top, 0, 0, SMH_BANK2);
		memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM,
			0x0000, ram_top, 0, 0, SMH_BANK2);
		memory_set_bankptr(2, mess_ram);
	}
#endif /* MESS */

	/* save states */
	state_save_register_global_pointer(((UINT8 *) &antic.r), sizeof(antic.r));
	state_save_register_global_pointer(((UINT8 *) &antic.w), sizeof(antic.w));
}