This commit is contained in:
Robbbert 2016-02-09 10:53:32 +11:00
commit a9f2f5ba4a

View File

@ -20,14 +20,27 @@ public:
k28_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_tms6100(*this, "tms6100"),
m_speech(*this, "speech"),
m_inp_matrix(*this, "IN")
{ }
// devices
required_device<cpu_device> m_maincpu;
required_device<tms6100_device> m_tms6100;
required_device<votrax_sc01_device> m_speech;
required_ioport_array<7> m_inp_matrix;
UINT16 m_inp_mux;
UINT8 m_inp_mux;
UINT8 m_phoneme;
int m_speech_strobe;
DECLARE_WRITE8_MEMBER(mcu_p0_w);
DECLARE_READ8_MEMBER(mcu_p1_r);
DECLARE_READ8_MEMBER(mcu_p2_r);
DECLARE_WRITE8_MEMBER(mcu_p2_w);
DECLARE_WRITE8_MEMBER(mcu_prog_w);
DECLARE_READ8_MEMBER(mcu_t1_r);
protected:
virtual void machine_start() override;
@ -37,9 +50,13 @@ void k28_state::machine_start()
{
// zerofill
m_inp_mux = 0;
m_speech_strobe = 0;
m_phoneme = 0x3f;
// register for savestates
save_item(NAME(m_inp_mux));
save_item(NAME(m_speech_strobe));
save_item(NAME(m_phoneme));
}
@ -49,12 +66,76 @@ void k28_state::machine_start()
***************************************************************************/
WRITE8_MEMBER(k28_state::mcu_p0_w)
{
// d0,d1: phoneme high bits
// d0-d2: input mux high bits
m_inp_mux = (m_inp_mux & 0xf) | (~data << 4 & 0x70);
m_phoneme = (m_phoneme & 0xf) | (data << 4 & 0x30);
// d3: SC-01 strobe, latch phoneme on rising edge
if (data & 8 && m_speech_strobe == 0)
m_speech->write(space, 0, m_phoneme);
m_speech_strobe = data & 8;
//printf("%d",data>>4&1);
// d4: VSM chip enable
// d6: VSM M0
// d7: VSM M1
m_tms6100->cs_w(~data >> 4 & 1);
m_tms6100->m0_w(data >> 6 & 1);
m_tms6100->m1_w(data >> 7 & 1);
m_tms6100->clk_w(1);
m_tms6100->clk_w(0);
}
READ8_MEMBER(k28_state::mcu_p1_r)
{
UINT8 data = 0;
// multiplexed inputs (active low)
for (int i = 0; i < 7; i++)
if (m_inp_mux >> i & 1)
data |= m_inp_matrix[i]->read();
return data ^ 0xff;
}
READ8_MEMBER(k28_state::mcu_p2_r)
{
// d3: VSM data
return (m_tms6100->data_line_r()) ? 8 : 0;
}
WRITE8_MEMBER(k28_state::mcu_p2_w)
{
// d0-d3: VSM data, input mux and SC-01 phoneme lower nibble
m_tms6100->add_w(space, 0, data);
m_inp_mux = (m_inp_mux & ~0xf) | (~data & 0xf);
m_phoneme = (m_phoneme & ~0xf) | (data & 0xf);
}
WRITE8_MEMBER(k28_state::mcu_prog_w)
{
// 8021 PROG: MM5445 CLK pin
}
READ8_MEMBER(k28_state::mcu_t1_r)
{
printf("1");
// 8021 T1: SC-01 A/R pin
return m_speech->request();
}
static ADDRESS_MAP_START( k28_mcu_map, AS_IO, 8, k28_state )
ADDRESS_MAP_UNMAP_LOW
//AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1)
//AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2)
//AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG)
//AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T1)
AM_RANGE(0x00, 0x00) AM_MIRROR(0xff) AM_WRITE(mcu_p0_w)
AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READ(mcu_p1_r)
AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(mcu_p2_r, mcu_p2_w)
AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_WRITE(mcu_prog_w)
AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(mcu_t1_r)
ADDRESS_MAP_END
@ -151,6 +232,7 @@ static MACHINE_CONFIG_START( k28, k28_state )
MCFG_CPU_ADD("maincpu", I8021, XTAL_3_579545MHz)
MCFG_CPU_IO_MAP(k28_mcu_map)
MCFG_DEVICE_ADD("tms6100", TMS6100, XTAL_3_579545MHz)
MCFG_DEFAULT_LAYOUT(layout_k28)
/* sound hardware */