From a725cd2ba8839e166ac9f43893c2506214492661 Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 10 Jul 2017 11:23:32 -0400 Subject: starwars: Soundlatch modernization (nw) - 6532riot: Add some WRITE_LINEs to set individual port lines through callbacks --- src/devices/machine/6532riot.cpp | 27 ++++++++++++++++++ src/devices/machine/6532riot.h | 17 ++++++++++++ src/mame/audio/starwars.cpp | 60 ++-------------------------------------- src/mame/drivers/starwars.cpp | 15 +++++++--- src/mame/includes/starwars.h | 20 +++++++------- 5 files changed, 67 insertions(+), 72 deletions(-) diff --git a/src/devices/machine/6532riot.cpp b/src/devices/machine/6532riot.cpp index a04cac9fd79..762809cdf6a 100644 --- a/src/devices/machine/6532riot.cpp +++ b/src/devices/machine/6532riot.cpp @@ -378,6 +378,33 @@ uint8_t riot6532_device::portb_out_get() } +//------------------------------------------------- +// paN_w - write Port A lines individually +//------------------------------------------------- + +WRITE_LINE_MEMBER(riot6532_device::pa0_w) { porta_in_set(state ? 0x01 : 0x00, 0x01); } +WRITE_LINE_MEMBER(riot6532_device::pa1_w) { porta_in_set(state ? 0x02 : 0x00, 0x02); } +WRITE_LINE_MEMBER(riot6532_device::pa2_w) { porta_in_set(state ? 0x04 : 0x00, 0x04); } +WRITE_LINE_MEMBER(riot6532_device::pa3_w) { porta_in_set(state ? 0x08 : 0x00, 0x08); } +WRITE_LINE_MEMBER(riot6532_device::pa4_w) { porta_in_set(state ? 0x10 : 0x00, 0x10); } +WRITE_LINE_MEMBER(riot6532_device::pa5_w) { porta_in_set(state ? 0x20 : 0x00, 0x20); } +WRITE_LINE_MEMBER(riot6532_device::pa6_w) { porta_in_set(state ? 0x40 : 0x00, 0x40); } +WRITE_LINE_MEMBER(riot6532_device::pa7_w) { porta_in_set(state ? 0x80 : 0x00, 0x80); } + +//------------------------------------------------- +// pbN_w - write Port B lines individually +//------------------------------------------------- + +WRITE_LINE_MEMBER(riot6532_device::pb0_w) { portb_in_set(state ? 0x01 : 0x00, 0x01); } +WRITE_LINE_MEMBER(riot6532_device::pb1_w) { portb_in_set(state ? 0x02 : 0x00, 0x02); } +WRITE_LINE_MEMBER(riot6532_device::pb2_w) { portb_in_set(state ? 0x04 : 0x00, 0x04); } +WRITE_LINE_MEMBER(riot6532_device::pb3_w) { portb_in_set(state ? 0x08 : 0x00, 0x08); } +WRITE_LINE_MEMBER(riot6532_device::pb4_w) { portb_in_set(state ? 0x10 : 0x00, 0x10); } +WRITE_LINE_MEMBER(riot6532_device::pb5_w) { portb_in_set(state ? 0x20 : 0x00, 0x20); } +WRITE_LINE_MEMBER(riot6532_device::pb6_w) { portb_in_set(state ? 0x40 : 0x00, 0x40); } +WRITE_LINE_MEMBER(riot6532_device::pb7_w) { portb_in_set(state ? 0x80 : 0x00, 0x80); } + + //************************************************************************** // LIVE DEVICE //************************************************************************** diff --git a/src/devices/machine/6532riot.h b/src/devices/machine/6532riot.h index 36df16dbe73..2741334d9cd 100644 --- a/src/devices/machine/6532riot.h +++ b/src/devices/machine/6532riot.h @@ -61,6 +61,23 @@ public: void porta_in_set(uint8_t data, uint8_t mask); void portb_in_set(uint8_t data, uint8_t mask); + DECLARE_WRITE_LINE_MEMBER(pa0_w); + DECLARE_WRITE_LINE_MEMBER(pa1_w); + DECLARE_WRITE_LINE_MEMBER(pa2_w); + DECLARE_WRITE_LINE_MEMBER(pa3_w); + DECLARE_WRITE_LINE_MEMBER(pa4_w); + DECLARE_WRITE_LINE_MEMBER(pa5_w); + DECLARE_WRITE_LINE_MEMBER(pa6_w); + DECLARE_WRITE_LINE_MEMBER(pa7_w); + DECLARE_WRITE_LINE_MEMBER(pb0_w); + DECLARE_WRITE_LINE_MEMBER(pb1_w); + DECLARE_WRITE_LINE_MEMBER(pb2_w); + DECLARE_WRITE_LINE_MEMBER(pb3_w); + DECLARE_WRITE_LINE_MEMBER(pb4_w); + DECLARE_WRITE_LINE_MEMBER(pb5_w); + DECLARE_WRITE_LINE_MEMBER(pb6_w); + DECLARE_WRITE_LINE_MEMBER(pb7_w); + uint8_t porta_in_get(); uint8_t portb_in_get(); diff --git a/src/mame/audio/starwars.cpp b/src/mame/audio/starwars.cpp index 9a8b67e5e70..1f97abfd2de 100644 --- a/src/mame/audio/starwars.cpp +++ b/src/mame/audio/starwars.cpp @@ -10,7 +10,6 @@ ***************************************************************************/ #include "emu.h" -#include "cpu/m6809/m6809.h" #include "sound/tms5220.h" #include "includes/starwars.h" @@ -51,77 +50,22 @@ WRITE8_MEMBER(starwars_state::r6532_porta_w) } -WRITE_LINE_MEMBER(starwars_state::snd_interrupt) -{ - m_audiocpu->set_input_line(M6809_IRQ_LINE, state); -} - - /************************************* * * Sound CPU to/from main CPU * *************************************/ -TIMER_CALLBACK_MEMBER(starwars_state::sound_callback) -{ - m_riot->porta_in_set(0x40, 0x40); - m_main_data = param; - machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100)); -} - - -READ8_MEMBER(starwars_state::starwars_sin_r) -{ - m_riot->porta_in_set(0x00, 0x80); - return m_sound_data; -} - - -WRITE8_MEMBER(starwars_state::starwars_sout_w) -{ - machine().scheduler().synchronize(timer_expired_delegate(FUNC(starwars_state::sound_callback), this), data); -} - - - -/************************************* - * - * Main CPU to/from source CPU - * - *************************************/ - -READ8_MEMBER(starwars_state::starwars_main_read_r) -{ - m_riot->porta_in_set(0x00, 0x40); - return m_main_data; -} - - READ8_MEMBER(starwars_state::starwars_main_ready_flag_r) { return m_riot->porta_in_get() & 0xc0; /* only upper two flag bits mapped */ } -TIMER_CALLBACK_MEMBER(starwars_state::main_callback ) -{ - if (m_riot->porta_in_get() & 0x80) - logerror("Sound data not read %x\n", m_sound_data); - - m_riot->porta_in_set(0x80, 0x80); - m_sound_data = param; - machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(100)); -} - -WRITE8_MEMBER(starwars_state::starwars_main_wr_w) -{ - machine().scheduler().synchronize(timer_expired_delegate(FUNC(starwars_state::main_callback), this), data); -} - WRITE8_MEMBER(starwars_state::starwars_soundrst_w) { - m_riot->porta_in_set(0x00, 0xc0); + m_soundlatch->acknowledge_w(space, 0, 0); + m_mainlatch->acknowledge_w(space, 0, 0); /* reset sound CPU here */ m_audiocpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE); diff --git a/src/mame/drivers/starwars.cpp b/src/mame/drivers/starwars.cpp index a47be5f4314..116706f7fef 100644 --- a/src/mame/drivers/starwars.cpp +++ b/src/mame/drivers/starwars.cpp @@ -142,7 +142,8 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, starwars_state ) AM_RANGE(0x4340, 0x435f) AM_READ_PORT("DSW0") AM_RANGE(0x4360, 0x437f) AM_READ_PORT("DSW1") AM_RANGE(0x4380, 0x439f) AM_READ(starwars_adc_r) /* a-d control result */ - AM_RANGE(0x4400, 0x4400) AM_READWRITE(starwars_main_read_r, starwars_main_wr_w) + AM_RANGE(0x4400, 0x4400) AM_DEVREAD("mainlatch", generic_latch_8_device, read) + AM_RANGE(0x4400, 0x4400) AM_DEVWRITE("soundlatch", generic_latch_8_device, write) AM_RANGE(0x4401, 0x4401) AM_READ(starwars_main_ready_flag_r) AM_RANGE(0x4500, 0x45ff) AM_DEVREADWRITE("x2212", x2212_device, read, write) AM_RANGE(0x4600, 0x461f) AM_DEVWRITE("avg", avg_starwars_device, go_w) @@ -172,8 +173,8 @@ ADDRESS_MAP_END *************************************/ static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, starwars_state ) - AM_RANGE(0x0000, 0x07ff) AM_WRITE(starwars_sout_w) - AM_RANGE(0x0800, 0x0fff) AM_READ(starwars_sin_r) /* SIN Read */ + AM_RANGE(0x0000, 0x07ff) AM_DEVWRITE("mainlatch", generic_latch_8_device, write) + AM_RANGE(0x0800, 0x0fff) AM_DEVREAD("soundlatch", generic_latch_8_device, read) /* SIN Read */ AM_RANGE(0x1000, 0x107f) AM_RAM /* 6532 ram */ AM_RANGE(0x1080, 0x109f) AM_DEVREADWRITE("riot", riot6532_device, read, write) AM_RANGE(0x1800, 0x183f) AM_WRITE(quad_pokeyn_w) @@ -315,7 +316,7 @@ static MACHINE_CONFIG_START( starwars ) MCFG_RIOT6532_OUT_PA_CB(WRITE8(starwars_state, r6532_porta_w)) MCFG_RIOT6532_IN_PB_CB(DEVREAD8("tms", tms5220_device, status_r)) MCFG_RIOT6532_OUT_PB_CB(DEVWRITE8("tms", tms5220_device, data_w)) - MCFG_RIOT6532_IRQ_CB(WRITELINE(starwars_state, snd_interrupt)) + MCFG_RIOT6532_IRQ_CB(INPUTLINE("audiocpu", M6809_IRQ_LINE)) MCFG_X2212_ADD_AUTOSAVE("x2212") /* nvram */ @@ -347,6 +348,12 @@ static MACHINE_CONFIG_START( starwars ) MCFG_SOUND_ADD("tms", TMS5220, MASTER_CLOCK/2/9) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) + + MCFG_GENERIC_LATCH_8_ADD("soundlatch") + MCFG_GENERIC_LATCH_DATA_PENDING_CB(DEVWRITELINE("riot", riot6532_device, pa7_w)) + + MCFG_GENERIC_LATCH_8_ADD("mainlatch") + MCFG_GENERIC_LATCH_DATA_PENDING_CB(DEVWRITELINE("riot", riot6532_device, pa6_w)) MACHINE_CONFIG_END diff --git a/src/mame/includes/starwars.h b/src/mame/includes/starwars.h index 006e232d6e2..a0b9ca294f8 100644 --- a/src/mame/includes/starwars.h +++ b/src/mame/includes/starwars.h @@ -7,6 +7,7 @@ ***************************************************************************/ #include "machine/6532riot.h" +#include "machine/gen_latch.h" #include "includes/slapstic.h" @@ -15,6 +16,8 @@ class starwars_state : public driver_device public: starwars_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), + m_soundlatch(*this, "soundlatch"), + m_mainlatch(*this, "mainlatch"), m_riot(*this, "riot"), m_mathram(*this, "mathram"), m_maincpu(*this, "maincpu"), @@ -22,14 +25,18 @@ public: m_slapstic_device(*this, "slapstic") { } - uint8_t m_sound_data; - uint8_t m_main_data; + required_device m_soundlatch; + required_device m_mainlatch; required_device m_riot; + required_shared_ptr m_mathram; + required_device m_maincpu; + required_device m_audiocpu; + optional_device m_slapstic_device; + uint8_t *m_slapstic_source; uint8_t *m_slapstic_base; uint8_t m_slapstic_current_bank; uint8_t m_is_esb; - required_shared_ptr m_mathram; uint8_t m_control_num; int m_MPA; int m_BIC; @@ -58,11 +65,7 @@ public: DECLARE_READ8_MEMBER(starwars_div_rel_r); DECLARE_WRITE8_MEMBER(starwars_math_w); DECLARE_CUSTOM_INPUT_MEMBER(matrix_flag_r); - DECLARE_READ8_MEMBER(starwars_sin_r); - DECLARE_WRITE8_MEMBER(starwars_sout_w); - DECLARE_READ8_MEMBER(starwars_main_read_r); DECLARE_READ8_MEMBER(starwars_main_ready_flag_r); - DECLARE_WRITE8_MEMBER(starwars_main_wr_w); DECLARE_WRITE8_MEMBER(starwars_soundrst_w); DECLARE_WRITE8_MEMBER(quad_pokeyn_w); DECLARE_DRIVER_INIT(esb); @@ -78,7 +81,4 @@ public: void starwars_mproc_reset(); void run_mproc(); void esb_slapstic_tweak(address_space &space, offs_t offset); - required_device m_maincpu; - required_device m_audiocpu; - optional_device m_slapstic_device; }; -- cgit v1.2.3