diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2018-08-13 18:40:46 -0400 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2018-08-13 18:40:46 -0400 |
commit | f21ebf0ba17d80036676ff2f63bd185f21d6174a (patch) | |
tree | 6f662ca38c4a1369d99552ad4487dc756e1c261d | |
parent | 279a202abbf04395e008b0bdc0ec1a516127b051 (diff) |
plus4: Use input merger for IRQ (nw)
mos7360: Replace MCFG_ macro with devcb; remove totally unnecessary use of machine().device (nw)
-rw-r--r-- | src/devices/sound/mos7360.cpp | 4 | ||||
-rw-r--r-- | src/devices/sound/mos7360.h | 29 | ||||
-rw-r--r-- | src/mame/drivers/plus4.cpp | 88 |
3 files changed, 23 insertions, 98 deletions
diff --git a/src/devices/sound/mos7360.cpp b/src/devices/sound/mos7360.cpp index db59db39d03..f1ced2e6a9e 100644 --- a/src/devices/sound/mos7360.cpp +++ b/src/devices/sound/mos7360.cpp @@ -279,10 +279,6 @@ mos7360_device::mos7360_device(const machine_config &mconfig, const char *tag, d void mos7360_device::device_start() { - // get the CPU device - m_cpu = machine().device<cpu_device>(m_cpu_tag); - assert(m_cpu != nullptr); - // resolve callbacks m_write_irq.resolve_safe(); m_read_k.resolve_safe(0xff); diff --git a/src/devices/sound/mos7360.h b/src/devices/sound/mos7360.h index 29150246e5b..d73f711cd76 100644 --- a/src/devices/sound/mos7360.h +++ b/src/devices/sound/mos7360.h @@ -37,24 +37,6 @@ -/*************************************************************************** - DEVICE CONFIGURATION MACROS -***************************************************************************/ - -#define MCFG_MOS7360_ADD(_tag, _screen_tag, _cpu_tag, _clock, _videoram_map, _irq, _k) \ - MCFG_SCREEN_ADD(_screen_tag, RASTER) \ - MCFG_SCREEN_REFRESH_RATE(mos7360_device::PAL_VRETRACERATE) \ - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) \ - MCFG_SCREEN_SIZE(336, 216) \ - MCFG_SCREEN_VISIBLE_AREA(0, 336 - 1, 0, 216 - 1) \ - MCFG_SCREEN_UPDATE_DEVICE(_tag, mos7360_device, screen_update) \ - MCFG_DEVICE_ADD(_tag, MOS7360, _clock) \ - MCFG_DEVICE_ADDRESS_MAP(0, _videoram_map) \ - MCFG_VIDEO_SET_SCREEN(_screen_tag) \ - downcast<mos7360_device *>(device)->set_callbacks(_cpu_tag, DEVCB_##_irq, DEVCB_##_k); - - - //************************************************************************** // MACROS / CONSTANTS //************************************************************************** @@ -93,14 +75,11 @@ public: static constexpr unsigned PAL_LINES = 312; // construction/destruction - //mos7360_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock); mos7360_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template <class Irq, class K> void set_callbacks(const char *cpu_tag, Irq &&irq, K &&k) { - m_cpu_tag = cpu_tag; - m_write_irq.set_callback(std::forward<Irq>(irq)); - m_read_k.set_callback(std::forward<K>(k)); - } + // callbacks + auto write_irq_callback() { return m_write_irq.bind(); } + auto read_k_callback() { return m_read_k.bind(); } virtual space_config_vector memory_space_config() const override; @@ -156,8 +135,6 @@ protected: devcb_write_line m_write_irq; devcb_read8 m_read_k; - const char *m_cpu_tag; - cpu_device *m_cpu; sound_stream *m_stream; uint8_t m_reg[0x20]; diff --git a/src/mame/drivers/plus4.cpp b/src/mame/drivers/plus4.cpp index a2cb4c6e626..1a8795940c3 100644 --- a/src/mame/drivers/plus4.cpp +++ b/src/mame/drivers/plus4.cpp @@ -25,6 +25,7 @@ #include "cpu/m6502/m7501.h" #include "imagedev/snapquik.h" #include "machine/cbm_snqk.h" +#include "machine/input_merger.h" #include "machine/mos6529.h" #include "machine/mos6551.h" #include "machine/mos8706.h" @@ -70,10 +71,7 @@ public: m_c2(*this, "c2"), m_row(*this, "ROW%u", 0), m_lock(*this, "LOCK"), - m_addr(0), - m_ted_irq(CLEAR_LINE), - m_acia_irq(CLEAR_LINE), - m_exp_irq(CLEAR_LINE) + m_addr(0) { } void plus4(machine_config &config); @@ -104,7 +102,6 @@ protected: virtual void machine_start() override; virtual void machine_reset() override; - void check_interrupts(); void bankswitch(offs_t offset, int phi0, int mux, int ras, int *scs, int *phi2, int *user, int *_6551, int *addr_clk, int *keyport, int *kernal); uint8_t read_memory(address_space &space, offs_t offset, int ba, int scs, int phi2, int user, int _6551, int addr_clk, int keyport, int kernal); @@ -114,7 +111,6 @@ protected: DECLARE_READ8_MEMBER( cpu_r ); - DECLARE_WRITE_LINE_MEMBER( ted_irq_w ); DECLARE_READ8_MEMBER( ted_k_r ); DECLARE_WRITE_LINE_MEMBER( write_kb0 ) { if (state) m_kb |= 1; else m_kb &= ~1; } @@ -126,10 +122,6 @@ protected: DECLARE_WRITE_LINE_MEMBER( write_kb6 ) { if (state) m_kb |= 64; else m_kb &= ~64; } DECLARE_WRITE_LINE_MEMBER( write_kb7 ) { if (state) m_kb |= 128; else m_kb &= ~128; } - DECLARE_WRITE_LINE_MEMBER( acia_irq_w ); - - DECLARE_WRITE_LINE_MEMBER( exp_irq_w ); - DECLARE_QUICKLOAD_LOAD_MEMBER( cbm_c16 ); enum @@ -151,11 +143,6 @@ protected: // memory state uint8_t m_addr; - // interrupt state - int m_ted_irq; - int m_acia_irq; - int m_exp_irq; - // keyboard state uint8_t m_kb; @@ -209,21 +196,6 @@ QUICKLOAD_LOAD_MEMBER( plus4_state, cbm_c16 ) } //************************************************************************** -// INTERRUPTS -//************************************************************************** - -//------------------------------------------------- -// check_interrupts - -//------------------------------------------------- - -void plus4_state::check_interrupts() -{ - m_maincpu->set_input_line(INPUT_LINE_IRQ0, m_ted_irq || m_acia_irq || m_exp_irq); -} - - - -//************************************************************************** // MEMORY MANAGEMENT //************************************************************************** @@ -734,13 +706,6 @@ WRITE8_MEMBER( plus4_state::cpu_w ) // ted7360_interface ted_intf //------------------------------------------------- -WRITE_LINE_MEMBER( plus4_state::ted_irq_w ) -{ - m_ted_irq = state; - - check_interrupts(); -} - READ8_MEMBER( plus4_state::ted_k_r ) { /* @@ -793,30 +758,6 @@ READ8_MEMBER( plus4_state::ted_k_r ) //------------------------------------------------- -// MOS6551_INTERFACE( acia_intf ) -//------------------------------------------------- - -WRITE_LINE_MEMBER( plus4_state::acia_irq_w ) -{ - m_acia_irq = state; - - check_interrupts(); -} - - -//------------------------------------------------- -// PLUS4_EXPANSION_INTERFACE( expansion_intf ) -//------------------------------------------------- - -WRITE_LINE_MEMBER( plus4_state::exp_irq_w ) -{ - m_exp_irq = state; - - check_interrupts(); -} - - -//------------------------------------------------- // SLOT_INTERFACE( cbm_datassette_devices ) //------------------------------------------------- @@ -849,9 +790,6 @@ void plus4_state::machine_start() // state saving save_item(NAME(m_addr)); - save_item(NAME(m_ted_irq)); - save_item(NAME(m_acia_irq)); - save_item(NAME(m_exp_irq)); save_item(NAME(m_kb)); if (m_acia) @@ -911,10 +849,24 @@ MACHINE_CONFIG_START(plus4_state::plus4) MCFG_M7501_PORT_PULLS(0x00, 0xc0) MCFG_QUANTUM_PERFECT_CPU(MOS7501_TAG) + INPUT_MERGER_ANY_HIGH(config, "mainirq").output_handler().set_inputline(m_maincpu, m7501_device::IRQ_LINE); + // video and sound hardware + MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) + MCFG_SCREEN_REFRESH_RATE(mos7360_device::PAL_VRETRACERATE) + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) + MCFG_SCREEN_SIZE(336, 216) + MCFG_SCREEN_VISIBLE_AREA(0, 336 - 1, 0, 216 - 1) + MCFG_SCREEN_UPDATE_DEVICE(MOS7360_TAG, mos7360_device, screen_update) + SPEAKER(config, "mono").front_center(); - MCFG_MOS7360_ADD(MOS7360_TAG, SCREEN_TAG, MOS7501_TAG, 0, ted_videoram_map, WRITELINE(*this, plus4_state, ted_irq_w), READ8(*this, plus4_state, ted_k_r)) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) + + MOS7360(config, m_ted, 0); + m_ted->set_addrmap(0, &plus4_state::ted_videoram_map); + m_ted->set_screen(SCREEN_TAG); + m_ted->write_irq_callback().set("mainirq", FUNC(input_merger_device::in_w<0>)); + m_ted->read_k_callback().set(FUNC(plus4_state::ted_k_r)); + m_ted->add_route(ALL_OUTPUTS, "mono", 0.25); // devices MCFG_PLS100_ADD(PLA_TAG) @@ -939,7 +891,7 @@ MACHINE_CONFIG_START(plus4_state::plus4) m_acia->rts_handler().set(m_user, FUNC(pet_user_port_device::write_d)).invert(); m_acia->dtr_handler().set(m_user, FUNC(pet_user_port_device::write_e)).invert(); m_acia->txd_handler().set(m_user, FUNC(pet_user_port_device::write_m)); - m_acia->irq_handler().set(FUNC(plus4_state::acia_irq_w)); + m_acia->irq_handler().set("mainirq", FUNC(input_merger_device::in_w<1>)); MCFG_DEVICE_ADD(m_spi_user, MOS6529, 0) MCFG_MOS6529_P0_HANDLER(WRITELINE(m_user, pet_user_port_device, write_b)) @@ -969,7 +921,7 @@ MACHINE_CONFIG_START(plus4_state::plus4) MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, nullptr) MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, "joy") MCFG_PLUS4_EXPANSION_SLOT_ADD(PLUS4_EXPANSION_SLOT_TAG, XTAL(14'318'181)/16, plus4_expansion_cards, nullptr) - MCFG_PLUS4_EXPANSION_SLOT_IRQ_CALLBACK(WRITELINE(*this, plus4_state, exp_irq_w)) + MCFG_PLUS4_EXPANSION_SLOT_IRQ_CALLBACK(WRITELINE("mainirq", input_merger_device, in_w<2>)) MCFG_PLUS4_EXPANSION_SLOT_CD_INPUT_CALLBACK(READ8(*this, plus4_state, read)) MCFG_PLUS4_EXPANSION_SLOT_CD_OUTPUT_CALLBACK(WRITE8(*this, plus4_state, write)) MCFG_PLUS4_EXPANSION_SLOT_AEC_CALLBACK(INPUTLINE(MOS7501_TAG, INPUT_LINE_HALT)) |