Example #1
0
void mazerbla_state::greatgun(machine_config &config)
{
	/* basic machine hardware */
	Z80(config, m_maincpu, MASTER_CLOCK);  /* 4 MHz, no NMI, IM2 - vectors at 0xf8, 0xfa, 0xfc */
	m_maincpu->set_addrmap(AS_PROGRAM, &mazerbla_state::mazerbla_map);
	m_maincpu->set_addrmap(AS_IO, &mazerbla_state::greatgun_io_map);
	m_maincpu->set_irq_acknowledge_callback(FUNC(mazerbla_state::irq_callback));

	Z80(config, m_subcpu, SOUND_CLOCK / 4);   /* 3.579500 MHz, NMI - caused by sound command write, periodic INT */
	m_subcpu->set_addrmap(AS_PROGRAM, &mazerbla_state::greatgun_sound_map);
	m_subcpu->set_periodic_int(FUNC(mazerbla_state::sound_interrupt), attotime::from_hz((double)14318180/16/16/16/16 ));

	z80_device &sub2(Z80(config, "sub2", MASTER_CLOCK)); /* 4 MHz, no  NMI, IM1 INT */
	sub2.set_addrmap(AS_PROGRAM, &mazerbla_state::mazerbla_cpu3_map);
	sub2.set_addrmap(AS_IO, &mazerbla_state::greatgun_cpu3_io_map);
/* (vblank related ??) int generated by a custom video processor
    and cleared on ANY port access.
    but handled differently for now
    */
	sub2.set_vblank_int("screen", FUNC(mazerbla_state::irq0_line_hold));

	MB_VCU(config, m_vcu, SOUND_CLOCK/4);
	m_vcu->set_cpu_tag("sub2");
	m_vcu->set_palette_tag("palette");

	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);

	/* video hardware */
	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
	m_screen->set_refresh_hz(60);
	m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500) /* not accurate */);
	m_screen->set_size(40*8, 32*8);
	m_screen->set_visarea(0*8, 32*8-1, 0*8, 28*8-1);
	m_screen->set_screen_update(FUNC(mazerbla_state::screen_update_mazerbla));
	m_screen->screen_vblank().set(FUNC(mazerbla_state::screen_vblank));

	PALETTE(config, "palette", FUNC(mazerbla_state::mazerbla_palette), 246+1);

	/* sound hardware */
	SPEAKER(config, "mono").front_center();

	ay8910_device &ay1(AY8910(config, "ay1", SOUND_CLOCK / 8));
	ay1.port_b_read_callback().set(m_soundlatch, FUNC(generic_latch_8_device::read));
	ay1.add_route(ALL_OUTPUTS, "mono", 0.30);

	ay8910_device &ay2(AY8910(config, "ay2", SOUND_CLOCK / 8));
	ay2.port_b_write_callback().set(FUNC(mazerbla_state::gg_led_ctrl_w));
	ay2.add_route(ALL_OUTPUTS, "mono", 1.0);

	GENERIC_LATCH_8(config, m_soundlatch);
	m_soundlatch->data_pending_callback().set_inputline(m_subcpu, INPUT_LINE_NMI);
	m_soundlatch->set_separate_acknowledge(true);
}