cgang: add mailbox (nw)

This commit is contained in:
hap 2019-12-13 00:48:06 +01:00
parent 60cc29eb84
commit c8cf005641

View file

@ -22,7 +22,7 @@ Main CPU side:
Audio CPU side: Audio CPU side:
- HD68B09EP @ 2MHz (8MHz XTAL) - HD68B09EP @ 2MHz (8MHz XTAL)
- 32KB ROM(27C256), 16KB RAM(2*HM6264AP-10) - 32KB ROM(27C256), 16KB RAM(2*HM6264AP-10, some pins N/C)
- M5L8255AP-5 PPI - M5L8255AP-5 PPI
- Namco CUS121 sound interface, same chip used in Namco System 1 - Namco CUS121 sound interface, same chip used in Namco System 1
- Yamaha YM2151 @ 3.57MHz, 2*NEC D7759C @ 640kHz - Yamaha YM2151 @ 3.57MHz, 2*NEC D7759C @ 640kHz
@ -40,6 +40,8 @@ Cabinet:
#include "emu.h" #include "emu.h"
#include "cpu/m6809/m6809.h" #include "cpu/m6809/m6809.h"
#include "machine/gen_latch.h"
#include "machine/i8255.h"
#include "machine/pit8253.h" #include "machine/pit8253.h"
#include "machine/ripple_counter.h" #include "machine/ripple_counter.h"
#include "speaker.h" #include "speaker.h"
@ -54,7 +56,9 @@ public:
driver_device(mconfig, type, tag), driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"), m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"), m_audiocpu(*this, "audiocpu"),
m_pit(*this, "pit%u", 0) m_latch(*this, "latch%u", 0),
m_pit(*this, "pit%u", 0),
m_ppi(*this, "ppi%u", 0)
{ } { }
// machine drivers // machine drivers
@ -67,7 +71,9 @@ private:
// devices/pointers // devices/pointers
required_device<cpu_device> m_maincpu; required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu; required_device<cpu_device> m_audiocpu;
required_device_array<generic_latch_8_device, 2> m_latch;
required_device_array<pit8253_device, 2> m_pit; required_device_array<pit8253_device, 2> m_pit;
required_device_array<i8255_device, 5> m_ppi;
// address maps // address maps
void main_map(address_map &map); void main_map(address_map &map);
@ -79,6 +85,12 @@ private:
DECLARE_WRITE8_MEMBER(main_irq_clear_w) { m_maincpu->set_input_line(M6809_IRQ_LINE, CLEAR_LINE); } DECLARE_WRITE8_MEMBER(main_irq_clear_w) { m_maincpu->set_input_line(M6809_IRQ_LINE, CLEAR_LINE); }
DECLARE_WRITE8_MEMBER(main_firq_clear_w) { m_maincpu->set_input_line(M6809_FIRQ_LINE, CLEAR_LINE); } DECLARE_WRITE8_MEMBER(main_firq_clear_w) { m_maincpu->set_input_line(M6809_FIRQ_LINE, CLEAR_LINE); }
DECLARE_WRITE8_MEMBER(spot_w);
DECLARE_READ8_MEMBER(ppi0_c_r);
DECLARE_READ8_MEMBER(ppi4_c_r);
int m_main_irq = 0; int m_main_irq = 0;
int m_main_firq = 0; int m_main_firq = 0;
}; };
@ -116,9 +128,34 @@ WRITE_LINE_MEMBER(cgang_state::main_firq_w)
m_main_firq = state; m_main_firq = state;
} }
READ8_MEMBER(cgang_state::ppi0_c_r)
{
u8 data = 0;
// PC7: CALL-CPU1
data |= m_latch[1]->pending_r() ? 0 : 0x80;
return data | 0x7f;
}
// audiocpu // audiocpu
WRITE8_MEMBER(cgang_state::spot_w)
{
}
READ8_MEMBER(cgang_state::ppi4_c_r)
{
u8 data = 0;
// PC2: CALL-CPU2
data |= m_latch[0]->pending_r() ? 0 : 4;
return data | 0xfb;
}
/****************************************************************************** /******************************************************************************
Address Maps Address Maps
@ -128,6 +165,12 @@ void cgang_state::main_map(address_map &map)
{ {
map.unmap_value_high(); map.unmap_value_high();
map(0x0000, 0x1fff).ram(); map(0x0000, 0x1fff).ram();
map(0x2000, 0x2003).rw(m_ppi[0], FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x2004, 0x2007).rw(m_ppi[1], FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x2008, 0x200b).rw(m_ppi[2], FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x200c, 0x200f).rw(m_ppi[3], FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x4000, 0x4000).mirror(0x0003).w(m_latch[0], FUNC(generic_latch_8_device::write));
map(0x4004, 0x4004).mirror(0x0003).r(m_latch[1], FUNC(generic_latch_8_device::read));
map(0x4008, 0x4008).mirror(0x0003).w(FUNC(cgang_state::main_irq_clear_w)); map(0x4008, 0x4008).mirror(0x0003).w(FUNC(cgang_state::main_irq_clear_w));
map(0x400c, 0x400c).mirror(0x0003).w(FUNC(cgang_state::main_firq_clear_w)); map(0x400c, 0x400c).mirror(0x0003).w(FUNC(cgang_state::main_firq_clear_w));
map(0x4010, 0x4013).rw(m_pit[0], FUNC(pit8253_device::read), FUNC(pit8253_device::write)); map(0x4010, 0x4013).rw(m_pit[0], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
@ -138,7 +181,11 @@ void cgang_state::main_map(address_map &map)
void cgang_state::sound_map(address_map &map) void cgang_state::sound_map(address_map &map)
{ {
map.unmap_value_high(); map.unmap_value_high();
map(0x0000, 0x1fff).ram(); map(0x0000, 0x0fff).ram();
map(0x2000, 0x2003).mirror(0x0ffc).rw(m_ppi[4], FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x3000, 0x3000).mirror(0x0fff).r(m_latch[0], FUNC(generic_latch_8_device::read));
map(0x4000, 0x4000).mirror(0x0fff).w(m_latch[1], FUNC(generic_latch_8_device::write));
map(0x7000, 0x7000).mirror(0x0fff).w(FUNC(cgang_state::spot_w));
map(0x8000, 0xffff).rom(); map(0x8000, 0xffff).rom();
} }
@ -165,6 +212,7 @@ void cgang_state::cgang(machine_config &config)
MC6809E(config, m_audiocpu, 8_MHz_XTAL/4); MC6809E(config, m_audiocpu, 8_MHz_XTAL/4);
m_audiocpu->set_addrmap(AS_PROGRAM, &cgang_state::sound_map); m_audiocpu->set_addrmap(AS_PROGRAM, &cgang_state::sound_map);
m_audiocpu->set_periodic_int(FUNC(cgang_state::nmi_line_pulse), attotime::from_hz(8_MHz_XTAL/4 / 0x1000));
PIT8253(config, m_pit[0], 0); PIT8253(config, m_pit[0], 0);
m_pit[0]->set_clk<0>(4_MHz_XTAL/4); m_pit[0]->set_clk<0>(4_MHz_XTAL/4);
@ -183,6 +231,26 @@ void cgang_state::cgang(machine_config &config)
int_clk.count_out_cb().append(FUNC(cgang_state::main_irq_w)).bit(3); int_clk.count_out_cb().append(FUNC(cgang_state::main_irq_w)).bit(3);
int_clk.count_out_cb().append(FUNC(cgang_state::main_firq_w)).bit(4); int_clk.count_out_cb().append(FUNC(cgang_state::main_firq_w)).bit(4);
GENERIC_LATCH_8(config, m_latch[0]);
GENERIC_LATCH_8(config, m_latch[1]);
I8255(config, m_ppi[0]); // 0x9b: all = input
m_ppi[0]->in_pa_callback().set_constant(0xff);
m_ppi[0]->in_pb_callback().set_constant(0xff);
m_ppi[0]->in_pc_callback().set(FUNC(cgang_state::ppi0_c_r));
I8255(config, m_ppi[1]); // 0x9a: A & B = input, Clow = output, Chigh = input
m_ppi[1]->in_pa_callback().set_constant(0xff);
m_ppi[1]->in_pb_callback().set_constant(0xff);
m_ppi[1]->in_pc_callback().set_constant(0xff);
I8255(config, m_ppi[2]); // 0x80: all = output
I8255(config, m_ppi[3]); // 0x80: all = output
I8255(config, m_ppi[4]); // 0x89: A & B = output, C = input
m_ppi[4]->in_pc_callback().set(FUNC(cgang_state::ppi4_c_r));
/* sound hardware */ /* sound hardware */
SPEAKER(config, "mono").front_center(); SPEAKER(config, "mono").front_center();
} }