diff --git a/src/mame/drivers/discoboy.cpp b/src/mame/drivers/discoboy.cpp index bdb78873e74..184a56d9a75 100644 --- a/src/mame/drivers/discoboy.cpp +++ b/src/mame/drivers/discoboy.cpp @@ -44,6 +44,7 @@ Notes: #include "emu.h" #include "cpu/z80/z80.h" #include "machine/gen_latch.h" +#include "machine/74157.h" #include "sound/msm5205.h" #include "sound/3812intf.h" @@ -57,6 +58,7 @@ public: m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), m_msm(*this, "msm"), + m_adpcm_select(*this, "adpcm_select"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), m_soundlatch(*this, "soundlatch") { } @@ -65,13 +67,14 @@ public: uint8_t m_ram_bank; uint8_t m_gfxbank; uint8_t m_port_00; - int m_adpcm; - uint8_t m_toggle; + + bool m_toggle; /* devices */ required_device m_maincpu; required_device m_audiocpu; required_device m_msm; + required_device m_adpcm_select; required_device m_gfxdecode; required_device m_palette; required_device m_soundlatch; @@ -94,7 +97,6 @@ public: DECLARE_READ8_MEMBER(discoboy_ram_att_r); DECLARE_WRITE8_MEMBER(discoboy_ram_att_w); DECLARE_READ8_MEMBER(discoboy_port_06_r); - DECLARE_WRITE8_MEMBER(yunsung8_adpcm_w); DECLARE_WRITE8_MEMBER(yunsung8_sound_bankswitch_w); DECLARE_DRIVER_INIT(discoboy); virtual void machine_start() override; @@ -350,17 +352,11 @@ WRITE8_MEMBER(discoboy_state::yunsung8_sound_bankswitch_w) logerror("%s: Bank %02X\n", machine().describe_context(), data); } -WRITE8_MEMBER(discoboy_state::yunsung8_adpcm_w) -{ - /* Swap the nibbles */ - m_adpcm = ((data & 0xf) << 4) | ((data >> 4) & 0xf); -} - static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, discoboy_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("sndbank") AM_RANGE(0xe000, 0xe000) AM_WRITE(yunsung8_sound_bankswitch_w) - AM_RANGE(0xe400, 0xe400) AM_WRITE(yunsung8_adpcm_w) + AM_RANGE(0xe400, 0xe400) AM_DEVWRITE("adpcm_select", ls157_device, ba_w) AM_RANGE(0xec00, 0xec01) AM_DEVWRITE("ymsnd", ym3812_device, write) AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_RANGE(0xf800, 0xf800) AM_DEVREAD("soundlatch", generic_latch_8_device, read) @@ -467,7 +463,6 @@ void discoboy_state::machine_start() save_item(NAME(m_ram_bank)); save_item(NAME(m_port_00)); save_item(NAME(m_gfxbank)); - save_item(NAME(m_adpcm)); save_item(NAME(m_toggle)); } @@ -476,16 +471,17 @@ void discoboy_state::machine_reset() m_ram_bank = 0; m_port_00 = 0; m_gfxbank = 0; - m_adpcm = 0x80; - m_toggle = 0; + m_toggle = false; } WRITE_LINE_MEMBER(discoboy_state::yunsung8_adpcm_int) { - m_msm->data_w(m_adpcm >> 4); - m_adpcm <<= 4; + if (!state) + return; - m_toggle ^= 1; + m_toggle = !m_toggle; + m_adpcm_select->select_w(m_toggle); + m_audiocpu->set_input_line(INPUT_LINE_NMI, m_toggle); } static MACHINE_CONFIG_START( discoboy, discoboy_state ) @@ -498,8 +494,6 @@ static MACHINE_CONFIG_START( discoboy, discoboy_state ) MCFG_CPU_ADD("audiocpu", Z80, XTAL_10MHz/2) /* 5 MHz? */ MCFG_CPU_PROGRAM_MAP(sound_map) - MCFG_CPU_PERIODIC_INT_DRIVER(discoboy_state, nmi_line_pulse, 32*60) - /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -523,6 +517,9 @@ static MACHINE_CONFIG_START( discoboy, discoboy_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.6) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.6) + MCFG_DEVICE_ADD("adpcm_select", LS157, 0) + MCFG_74LS157_OUT_CB(DEVWRITE8("msm", msm5205_device, data_w)) + MCFG_SOUND_ADD("msm", MSM5205, XTAL_400kHz) MCFG_MSM5205_VCLK_CB(WRITELINE(discoboy_state, yunsung8_adpcm_int)) /* interrupt function */ MCFG_MSM5205_PRESCALER_SELECTOR(MSM5205_S96_4B) /* 4KHz, 4 Bits */ diff --git a/src/mame/drivers/yunsung8.cpp b/src/mame/drivers/yunsung8.cpp index a6c1934b0ff..d5e4ac0ccd4 100644 --- a/src/mame/drivers/yunsung8.cpp +++ b/src/mame/drivers/yunsung8.cpp @@ -54,19 +54,19 @@ WRITE8_MEMBER(yunsung8_state::bankswitch_w) READ8_MEMBER(yunsung8_state::sound_command_r) { - m_audiocpu->set_input_line (0, CLEAR_LINE); - return (m_soundlatch->read (space, 0)); + m_audiocpu->set_input_line(0, CLEAR_LINE); + return m_soundlatch->read(space, 0); } -WRITE8_MEMBER (yunsung8_state::sound_command_w) +WRITE8_MEMBER(yunsung8_state::sound_command_w) { - m_soundlatch->write (space, 0, data); - m_audiocpu->set_input_line (0, ASSERT_LINE); + m_soundlatch->write(space, 0, data); + m_audiocpu->set_input_line(0, ASSERT_LINE); } -WRITE8_MEMBER (yunsung8_state::main_irq_ack_w) +WRITE8_MEMBER(yunsung8_state::main_irq_ack_w) { - m_maincpu->set_input_line (0, CLEAR_LINE); + m_maincpu->set_input_line(0, CLEAR_LINE); } /* @@ -118,18 +118,13 @@ WRITE8_MEMBER(yunsung8_state::sound_bankswitch_w) logerror("%s: Bank %02X\n", machine().describe_context(), data); } -WRITE8_MEMBER(yunsung8_state::adpcm_w) -{ - m_adpcm = data; -} - static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, yunsung8_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("soundbank") // Banked ROM AM_RANGE(0xe000, 0xe000) AM_WRITE(sound_bankswitch_w) // ROM Bank - AM_RANGE(0xe400, 0xe400) AM_WRITE(adpcm_w) + AM_RANGE(0xe400, 0xe400) AM_DEVWRITE("adpcm_select", ls157_device, ba_w) AM_RANGE(0xec00, 0xec01) AM_DEVWRITE("ymsnd", ym3812_device, write) AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_RANGE(0xf800, 0xf800) AM_READ(sound_command_r) // From Main CPU @@ -321,13 +316,12 @@ GFXDECODE_END WRITE_LINE_MEMBER(yunsung8_state::adpcm_int) { - m_msm->data_w(m_adpcm & 0x0F); - m_adpcm >>= 4; + if (!state) + return; - m_toggle ^= 1; - - if (m_toggle) - m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); + m_toggle = !m_toggle; + m_adpcm_select->select_w(m_toggle); + m_audiocpu->set_input_line(INPUT_LINE_NMI, m_toggle); } void yunsung8_state::machine_start() @@ -341,7 +335,6 @@ void yunsung8_state::machine_start() save_item(NAME(m_videoram)); save_item(NAME(m_layers_ctrl)); save_item(NAME(m_videobank)); - save_item(NAME(m_adpcm)); save_item(NAME(m_toggle)); } @@ -349,8 +342,7 @@ void yunsung8_state::machine_reset() { m_videobank = 0; m_layers_ctrl = 0; - m_adpcm = 0; - m_toggle = 0; + m_toggle = false; } @@ -384,6 +376,9 @@ static MACHINE_CONFIG_START( yunsung8, yunsung8_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) + MCFG_DEVICE_ADD("adpcm_select", LS157, 0) + MCFG_74LS157_OUT_CB(DEVWRITE8("msm", msm5205_device, data_w)) + MCFG_SOUND_ADD("msm", MSM5205, XTAL_400kHz) /* verified on pcb */ MCFG_MSM5205_VCLK_CB(WRITELINE(yunsung8_state, adpcm_int)) /* interrupt function */ MCFG_MSM5205_PRESCALER_SELECTOR(MSM5205_S96_4B) /* 4KHz, 4 Bits */ diff --git a/src/mame/includes/yunsung8.h b/src/mame/includes/yunsung8.h index 35130ae611a..94903be37e1 100644 --- a/src/mame/includes/yunsung8.h +++ b/src/mame/includes/yunsung8.h @@ -7,6 +7,7 @@ *************************************************************************/ #include "machine/gen_latch.h" +#include "machine/74157.h" #include "sound/msm5205.h" class yunsung8_state : public driver_device @@ -17,6 +18,7 @@ public: m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), m_msm(*this, "msm"), + m_adpcm_select(*this, "adpcm_select"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), m_soundlatch(*this, "soundlatch") @@ -32,13 +34,13 @@ public: int m_videobank; /* misc */ - int m_adpcm; - int m_toggle; + bool m_toggle; /* devices */ required_device m_maincpu; required_device m_audiocpu; required_device m_msm; + required_device m_adpcm_select; required_device m_gfxdecode; required_device m_palette; required_device m_soundlatch; @@ -50,7 +52,6 @@ public: DECLARE_READ8_MEMBER(sound_command_r); DECLARE_WRITE8_MEMBER(sound_command_w); DECLARE_WRITE8_MEMBER(main_irq_ack_w); - DECLARE_WRITE8_MEMBER(adpcm_w); DECLARE_WRITE8_MEMBER(videobank_w); DECLARE_READ8_MEMBER(videoram_r); DECLARE_WRITE8_MEMBER(videoram_w);