From 34be7d416603f0601877f208e6250dae416a92b2 Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 14 Apr 2016 21:20:49 -0400 Subject: Eliminate device_t::static_config, a type-unsafe legacy feature. Rewrite or remove every last instance of MCFG_DEVICE_CONFIG and its two aliases, including within comments and dead code. Make the Z80/Z180 daisy chain an interface that interfaces with the existing interface. Z8000 has been hooked up to this as well (p8000_16 already configures it), but currently does nothing with it. --- src/devices/bus/abcbus/fd2.cpp | 2 +- src/devices/bus/abcbus/hdc.cpp | 2 +- src/devices/bus/abcbus/lux10828.cpp | 2 +- src/devices/bus/abcbus/lux21046.cpp | 2 +- src/devices/bus/abcbus/lux21056.cpp | 2 +- src/devices/bus/abcbus/turbo.cpp | 2 +- src/devices/bus/ecbbus/grip.cpp | 2 +- src/devices/bus/imi7000/imi5000h.cpp | 2 +- src/devices/bus/kc/d004.cpp | 2 +- src/devices/bus/ti99x/handset.h | 7 --- src/devices/bus/wangpc/rtc.cpp | 2 +- src/devices/bus/wangpc/wdc.cpp | 2 +- src/devices/cpu/pdp1/pdp1.cpp | 2 +- src/devices/cpu/pdp1/pdp1.h | 7 +++ src/devices/cpu/z180/z180.cpp | 11 +--- src/devices/cpu/z180/z180.h | 3 +- src/devices/cpu/z180/z180op.inc | 4 +- src/devices/cpu/z180/z180ops.h | 2 +- src/devices/cpu/z80/tmpz84c015.cpp | 2 +- src/devices/cpu/z80/z80.cpp | 17 +++--- src/devices/cpu/z80/z80.h | 3 +- src/devices/cpu/z80/z80daisy.cpp | 110 ++++++++++++++++++++--------------- src/devices/cpu/z80/z80daisy.h | 55 ++++++++++++------ src/devices/cpu/z8000/z8000.cpp | 2 + src/devices/cpu/z8000/z8000.h | 4 +- src/devices/imagedev/flopdrv.cpp | 13 ++--- src/devices/imagedev/flopdrv.h | 18 +++--- src/devices/machine/ldv1000.cpp | 2 +- src/devices/sound/flt_rc.h | 4 +- 29 files changed, 160 insertions(+), 128 deletions(-) (limited to 'src/devices') diff --git a/src/devices/bus/abcbus/fd2.cpp b/src/devices/bus/abcbus/fd2.cpp index 6a7c4cc5f4d..e967c3050cf 100644 --- a/src/devices/bus/abcbus/fd2.cpp +++ b/src/devices/bus/abcbus/fd2.cpp @@ -237,7 +237,7 @@ static MACHINE_CONFIG_FRAGMENT( abc_fd2 ) MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_4MHz/2) MCFG_CPU_PROGRAM_MAP(abc_fd2_mem) MCFG_CPU_IO_MAP(abc_fd2_io) - MCFG_CPU_CONFIG(daisy_chain) + MCFG_Z80_DAISY_CHAIN(daisy_chain) MCFG_DEVICE_ADD(Z80PIO_TAG, Z80PIO, XTAL_4MHz/2) MCFG_Z80PIO_OUT_INT_CB(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0)) diff --git a/src/devices/bus/abcbus/hdc.cpp b/src/devices/bus/abcbus/hdc.cpp index 7450f60819e..4108daa85a3 100644 --- a/src/devices/bus/abcbus/hdc.cpp +++ b/src/devices/bus/abcbus/hdc.cpp @@ -84,7 +84,7 @@ static MACHINE_CONFIG_FRAGMENT( abc_hdc ) MCFG_CPU_ADD(Z80_TAG, Z80, 4000000) MCFG_CPU_PROGRAM_MAP(abc_hdc_mem) MCFG_CPU_IO_MAP(abc_hdc_io) - MCFG_CPU_CONFIG(daisy_chain) + MCFG_Z80_DAISY_CHAIN(daisy_chain) MCFG_DEVICE_ADD(SASIBUS_TAG, SCSI_PORT, 0) MCFG_SCSIDEV_ADD(SASIBUS_TAG ":" SCSI_PORT_DEVICE1, "harddisk", SCSIHD, SCSI_ID_0) diff --git a/src/devices/bus/abcbus/lux10828.cpp b/src/devices/bus/abcbus/lux10828.cpp index e14bdf9a20e..4b9c074e193 100644 --- a/src/devices/bus/abcbus/lux10828.cpp +++ b/src/devices/bus/abcbus/lux10828.cpp @@ -329,7 +329,7 @@ static MACHINE_CONFIG_FRAGMENT( luxor_55_10828 ) MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_4MHz/2) MCFG_CPU_PROGRAM_MAP(luxor_55_10828_mem) MCFG_CPU_IO_MAP(luxor_55_10828_io) - MCFG_CPU_CONFIG(daisy_chain) + MCFG_Z80_DAISY_CHAIN(daisy_chain) MCFG_DEVICE_ADD(Z80PIO_TAG, Z80PIO, XTAL_4MHz/2) MCFG_Z80PIO_OUT_INT_CB(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0)) diff --git a/src/devices/bus/abcbus/lux21046.cpp b/src/devices/bus/abcbus/lux21046.cpp index 733aee9538e..5a7f693d275 100644 --- a/src/devices/bus/abcbus/lux21046.cpp +++ b/src/devices/bus/abcbus/lux21046.cpp @@ -286,7 +286,7 @@ static const z80_daisy_config z80_daisy_chain[] = static MACHINE_CONFIG_FRAGMENT( luxor_55_21046 ) MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_16MHz/4) - MCFG_CPU_CONFIG(z80_daisy_chain) + MCFG_Z80_DAISY_CHAIN(z80_daisy_chain) MCFG_CPU_PROGRAM_MAP(luxor_55_21046_mem) MCFG_CPU_IO_MAP(luxor_55_21046_io) diff --git a/src/devices/bus/abcbus/lux21056.cpp b/src/devices/bus/abcbus/lux21056.cpp index f506c1b8e01..f5227393a0a 100644 --- a/src/devices/bus/abcbus/lux21056.cpp +++ b/src/devices/bus/abcbus/lux21056.cpp @@ -247,7 +247,7 @@ static MACHINE_CONFIG_FRAGMENT( luxor_55_21056 ) MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_8MHz/2) MCFG_CPU_PROGRAM_MAP(luxor_55_21056_mem) MCFG_CPU_IO_MAP(luxor_55_21056_io) - MCFG_CPU_CONFIG(daisy_chain) + MCFG_Z80_DAISY_CHAIN(daisy_chain) MCFG_DEVICE_ADD(Z80DMA_TAG, Z80DMA, XTAL_8MHz/2) MCFG_Z80DMA_OUT_BUSREQ_CB(INPUTLINE(Z80_TAG, INPUT_LINE_HALT)) diff --git a/src/devices/bus/abcbus/turbo.cpp b/src/devices/bus/abcbus/turbo.cpp index 449f4697a48..1f16cadab96 100644 --- a/src/devices/bus/abcbus/turbo.cpp +++ b/src/devices/bus/abcbus/turbo.cpp @@ -85,7 +85,7 @@ static MACHINE_CONFIG_FRAGMENT( turbo_kontroller ) MCFG_CPU_ADD(Z80_TAG, Z80, 4000000) MCFG_CPU_PROGRAM_MAP(turbo_kontroller_mem) MCFG_CPU_IO_MAP(turbo_kontroller_io) - MCFG_CPU_CONFIG(daisy_chain) + MCFG_Z80_DAISY_CHAIN(daisy_chain) MACHINE_CONFIG_END diff --git a/src/devices/bus/ecbbus/grip.cpp b/src/devices/bus/ecbbus/grip.cpp index ca0cd2a579a..3a47b5692fc 100644 --- a/src/devices/bus/ecbbus/grip.cpp +++ b/src/devices/bus/ecbbus/grip.cpp @@ -454,7 +454,7 @@ WRITE8_MEMBER( grip_device::kb_w ) static MACHINE_CONFIG_FRAGMENT( grip ) // basic machine hardware MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_16MHz/4) - MCFG_CPU_CONFIG(grip_daisy_chain) + MCFG_Z80_DAISY_CHAIN(grip_daisy_chain) MCFG_CPU_PROGRAM_MAP(grip_mem) MCFG_CPU_IO_MAP(grip_io) diff --git a/src/devices/bus/imi7000/imi5000h.cpp b/src/devices/bus/imi7000/imi5000h.cpp index cea944b9eaf..bca1e9f0083 100644 --- a/src/devices/bus/imi7000/imi5000h.cpp +++ b/src/devices/bus/imi7000/imi5000h.cpp @@ -341,7 +341,7 @@ WRITE8_MEMBER( imi5000h_device::pio3_pb_w ) static MACHINE_CONFIG_FRAGMENT( imi5000h ) MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_8MHz/2) - MCFG_CPU_CONFIG(z80_daisy_chain) + MCFG_Z80_DAISY_CHAIN(z80_daisy_chain) MCFG_CPU_PROGRAM_MAP(imi5000h_mem) MCFG_CPU_IO_MAP(imi5000h_io) diff --git a/src/devices/bus/kc/d004.cpp b/src/devices/bus/kc/d004.cpp index 4895c5419c4..c22b5c16f9c 100644 --- a/src/devices/bus/kc/d004.cpp +++ b/src/devices/bus/kc/d004.cpp @@ -67,7 +67,7 @@ static MACHINE_CONFIG_FRAGMENT(kc_d004) MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_8MHz/2) MCFG_CPU_PROGRAM_MAP(kc_d004_mem) MCFG_CPU_IO_MAP(kc_d004_io) - MCFG_CPU_CONFIG(kc_d004_daisy_chain) + MCFG_Z80_DAISY_CHAIN(kc_d004_daisy_chain) MCFG_DEVICE_ADD(Z80CTC_TAG, Z80CTC, XTAL_8MHz/2) MCFG_Z80CTC_INTR_CB(INPUTLINE(Z80_TAG, 0)) diff --git a/src/devices/bus/ti99x/handset.h b/src/devices/bus/ti99x/handset.h index 3f9de1b6221..5e592bd2ebc 100644 --- a/src/devices/bus/ti99x/handset.h +++ b/src/devices/bus/ti99x/handset.h @@ -58,13 +58,6 @@ private: emu_timer *m_delay_timer; }; -#define MCFG_HANDSET_ADD(_tag, _intf, _clock ) \ - MCFG_DEVICE_ADD(_tag, HANDSET, _clock) \ - MCFG_DEVICE_CONFIG(_intf) - -#define TI99_HANDSET_INTERFACE(name) \ - const ti99_handset_intf(name) = - /****************************************************************************/ extern const device_type TI99_JOYSTICK; diff --git a/src/devices/bus/wangpc/rtc.cpp b/src/devices/bus/wangpc/rtc.cpp index f8a436af0c8..34279514870 100644 --- a/src/devices/bus/wangpc/rtc.cpp +++ b/src/devices/bus/wangpc/rtc.cpp @@ -104,7 +104,7 @@ static const z80_daisy_config wangpc_rtc_daisy_chain[] = static MACHINE_CONFIG_FRAGMENT( wangpc_rtc ) MCFG_CPU_ADD(Z80_TAG, Z80, 2000000) - MCFG_CPU_CONFIG(wangpc_rtc_daisy_chain) + MCFG_Z80_DAISY_CHAIN(wangpc_rtc_daisy_chain) MCFG_CPU_PROGRAM_MAP(wangpc_rtc_mem) MCFG_CPU_IO_MAP(wangpc_rtc_io) diff --git a/src/devices/bus/wangpc/wdc.cpp b/src/devices/bus/wangpc/wdc.cpp index 7b2dafdd5f9..b4326319cf3 100644 --- a/src/devices/bus/wangpc/wdc.cpp +++ b/src/devices/bus/wangpc/wdc.cpp @@ -91,7 +91,7 @@ ADDRESS_MAP_END static MACHINE_CONFIG_FRAGMENT( wangpc_wdc ) MCFG_CPU_ADD(Z80_TAG, Z80, 2000000) // XTAL_10MHz / ? - //MCFG_CPU_CONFIG(wangpc_wdc_daisy_chain) + //MCFG_Z80_DAISY_CHAIN(wangpc_wdc_daisy_chain) MCFG_CPU_PROGRAM_MAP(wangpc_wdc_mem) MCFG_CPU_IO_MAP(wangpc_wdc_io) diff --git a/src/devices/cpu/pdp1/pdp1.cpp b/src/devices/cpu/pdp1/pdp1.cpp index 0a2cf9e1061..dad758a1d9d 100644 --- a/src/devices/cpu/pdp1/pdp1.cpp +++ b/src/devices/cpu/pdp1/pdp1.cpp @@ -391,7 +391,7 @@ pdp1_device::pdp1_device(const machine_config &mconfig, const char *tag, device_ void pdp1_device::device_config_complete() { // inherit a copy of the static data - const pdp1_reset_param_t *intf = reinterpret_cast(static_config()); + const pdp1_reset_param_t *intf = m_reset_param; if (intf != nullptr) *static_cast(this) = *intf; diff --git a/src/devices/cpu/pdp1/pdp1.h b/src/devices/cpu/pdp1/pdp1.h index 2cb01f5c20b..f6d742a2a4e 100644 --- a/src/devices/cpu/pdp1/pdp1.h +++ b/src/devices/cpu/pdp1/pdp1.h @@ -81,6 +81,8 @@ public: // construction/destruction pdp1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + static void static_set_reset_param(device_t &device, const pdp1_reset_param_t *param) { downcast(device).m_reset_param = param; } + void pulse_start_clear(); void io_complete() { m_ios = 1; } void pdp1_null_iot(int op2, int nac, int mb, int *io, int ac); @@ -190,10 +192,15 @@ private: void field_interrupt(); void execute_instruction(); + const pdp1_reset_param_t *m_reset_param; }; extern const device_type PDP1; +#define MCFG_PDP1_RESET_PARAM(_param) \ + pdp1_device::static_set_reset_param(*device, &(_param)); + + #endif /* __PDP1_H__ */ diff --git a/src/devices/cpu/z180/z180.cpp b/src/devices/cpu/z180/z180.cpp index 8e3e5e6fb5d..7b389baec26 100644 --- a/src/devices/cpu/z180/z180.cpp +++ b/src/devices/cpu/z180/z180.cpp @@ -83,6 +83,7 @@ const device_type Z180 = &device_creator; z180_device::z180_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : cpu_device(mconfig, Z180, "Z180", tag, owner, clock, "z180", __FILE__) + , z80_daisy_chain_interface(mconfig, *this) , m_program_config("program", ENDIANNESS_LITTLE, 8, 20, 0) , m_io_config("io", ENDIANNESS_LITTLE, 8, 16, 0) , m_decrypted_opcodes_config("program", ENDIANNESS_LITTLE, 8, 20, 0) @@ -1888,11 +1889,6 @@ void z180_device::device_start() int oldval, newval, val; UINT8 *padd, *padc, *psub, *psbc; - if (static_config() != nullptr) - { - m_daisy.init(this, (const z80_daisy_config *)static_config()); - } - /* allocate big flag arrays once */ SZHVC_add = std::make_unique(2*256*256); SZHVC_sub = std::make_unique(2*256*256); @@ -2241,7 +2237,6 @@ void z180_device::device_reset() IO_OMCR = Z180_OMCR_RESET; IO_IOCR = Z180_IOCR_RESET; - m_daisy.reset(); z180_mmu(); } @@ -2496,8 +2491,8 @@ void z180_device::execute_set_input(int irqline, int state) /* update the IRQ state */ m_irq_state[irqline] = state; - if (m_daisy.present()) - m_irq_state[0] = m_daisy.update_irq_state(); + if (daisy_chain_present()) + m_irq_state[0] = daisy_update_irq_state(); /* the main execute loop will take the interrupt */ } diff --git a/src/devices/cpu/z180/z180.h b/src/devices/cpu/z180/z180.h index e76c75501ba..87980e29f4e 100644 --- a/src/devices/cpu/z180/z180.h +++ b/src/devices/cpu/z180/z180.h @@ -125,7 +125,7 @@ enum #define Z180_IRQ2 2 /* Execute IRQ2 */ -class z180_device : public cpu_device +class z180_device : public cpu_device, public z80_daisy_chain_interface { public: // construction/destruction @@ -184,7 +184,6 @@ private: UINT8 m_timer_cnt; /* timer counter / divide by 20 */ UINT8 m_dma0_cnt; /* dma0 counter / divide by 20 */ UINT8 m_dma1_cnt; /* dma1 counter / divide by 20 */ - z80_daisy_chain m_daisy; address_space *m_program; direct_read_data *m_direct; address_space *m_oprogram; diff --git a/src/devices/cpu/z180/z180op.inc b/src/devices/cpu/z180/z180op.inc index b3005629a78..c00515ee9a5 100644 --- a/src/devices/cpu/z180/z180op.inc +++ b/src/devices/cpu/z180/z180op.inc @@ -310,8 +310,8 @@ int z180_device::take_interrupt(int irq) if( irq == Z180_INT_IRQ0 ) { /* Daisy chain mode? If so, call the requesting device */ - if (m_daisy.present()) - irq_vector = m_daisy.call_ack_device(); + if (daisy_chain_present()) + irq_vector = daisy_call_ack_device(); /* else call back the cpu interface to retrieve the vector */ else diff --git a/src/devices/cpu/z180/z180ops.h b/src/devices/cpu/z180/z180ops.h index 36f06a6847f..6fb50e18112 100644 --- a/src/devices/cpu/z180/z180ops.h +++ b/src/devices/cpu/z180/z180ops.h @@ -233,7 +233,7 @@ UINT32 z180_device::ARG16() POP(PC); \ /* according to http://www.msxnet.org/tech/Z80/z80undoc.txt */ \ /* m_IFF1 = m_IFF2; */ \ - m_daisy.call_reti_device(); \ + daisy_call_reti_device(); \ } /*************************************************************** diff --git a/src/devices/cpu/z80/tmpz84c015.cpp b/src/devices/cpu/z80/tmpz84c015.cpp index d61ae4ef4c5..6c1f88c087a 100644 --- a/src/devices/cpu/z80/tmpz84c015.cpp +++ b/src/devices/cpu/z80/tmpz84c015.cpp @@ -163,7 +163,7 @@ WRITE8_MEMBER(tmpz84c015_device::irq_priority_w) { dev[prio[data][2]] }, { nullptr } }; - m_daisy.init(this, daisy_chain); + daisy_init(daisy_chain); m_irq_priority = data; } diff --git a/src/devices/cpu/z80/z80.cpp b/src/devices/cpu/z80/z80.cpp index 306b1ae49f2..8d30ae2df3d 100644 --- a/src/devices/cpu/z80/z80.cpp +++ b/src/devices/cpu/z80/z80.cpp @@ -110,7 +110,6 @@ #include "emu.h" #include "debugger.h" #include "z80.h" -#include "z80daisy.h" #define VERBOSE 0 @@ -647,7 +646,7 @@ inline void z80_device::reti() pop(m_pc); WZ = PC; m_iff1 = m_iff2; - m_daisy.call_reti_device(); + daisy_call_reti_device(); } /*************************************************************** @@ -3160,8 +3159,8 @@ void z80_device::take_interrupt() m_iff1 = m_iff2 = 0; /* Daisy chain mode? If so, call the requesting device */ - if (m_daisy.present()) - irq_vector = m_daisy.call_ack_device(); + if (daisy_chain_present()) + irq_vector = daisy_call_ack_device(); /* else call back the cpu interface to retrieve the vector */ else @@ -3419,8 +3418,6 @@ void z80_device::device_start() m_decrypted_opcodes_direct = &m_decrypted_opcodes->direct(); m_io = &space(AS_IO); - if (static_config() != nullptr) - m_daisy.init(this, (const z80_daisy_config *)static_config()); m_irq_callback = device_irq_acknowledge_delegate(FUNC(z80_device::standard_irq_callback_member), this); IX = IY = 0xffff; /* IX and IY are FFFF after a reset! */ @@ -3494,8 +3491,6 @@ void z80_device::device_reset() m_iff1 = 0; m_iff2 = 0; - m_daisy.reset(); - WZ=PCD; } @@ -3582,8 +3577,8 @@ void z80_device::execute_set_input(int inputnum, int state) case INPUT_LINE_IRQ0: /* update the IRQ state via the daisy chain */ m_irq_state = state; - if (m_daisy.present()) - m_irq_state = ( m_daisy.update_irq_state() == ASSERT_LINE ) ? ASSERT_LINE : m_irq_state; + if (daisy_chain_present()) + m_irq_state = (daisy_update_irq_state() == ASSERT_LINE ) ? ASSERT_LINE : m_irq_state; /* the main execute loop will take the interrupt */ break; @@ -3700,6 +3695,7 @@ void z80_device::z80_set_cycle_tables(const UINT8 *op, const UINT8 *cb, const UI z80_device::z80_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : cpu_device(mconfig, Z80, "Z80", tag, owner, clock, "z80", __FILE__), + z80_daisy_chain_interface(mconfig, *this), m_program_config("program", ENDIANNESS_LITTLE, 8, 16, 0), m_decrypted_opcodes_config("decrypted_opcodes", ENDIANNESS_LITTLE, 8, 16, 0), m_io_config("io", ENDIANNESS_LITTLE, 8, 16, 0), @@ -3710,6 +3706,7 @@ z80_device::z80_device(const machine_config &mconfig, const char *tag, device_t z80_device::z80_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source), + z80_daisy_chain_interface(mconfig, *this), m_program_config("program", ENDIANNESS_LITTLE, 8, 16, 0), m_decrypted_opcodes_config("decrypted_opcodes", ENDIANNESS_LITTLE, 8, 16, 0), m_io_config("io", ENDIANNESS_LITTLE, 8, 16, 0), diff --git a/src/devices/cpu/z80/z80.h b/src/devices/cpu/z80/z80.h index 38cc207347e..e3733807770 100644 --- a/src/devices/cpu/z80/z80.h +++ b/src/devices/cpu/z80/z80.h @@ -37,7 +37,7 @@ enum Z80_GENPCBASE = STATE_GENPCBASE }; -class z80_device : public cpu_device +class z80_device : public cpu_device, public z80_daisy_chain_interface { public: z80_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); @@ -283,7 +283,6 @@ protected: device_irq_acknowledge_delegate m_irq_callback; int m_icount; - z80_daisy_chain m_daisy; UINT8 m_rtemp; const UINT8 * m_cc_op; const UINT8 * m_cc_cb; diff --git a/src/devices/cpu/z80/z80daisy.cpp b/src/devices/cpu/z80/z80daisy.cpp index 6553760160b..9d06fe1c9fc 100644 --- a/src/devices/cpu/z80/z80daisy.cpp +++ b/src/devices/cpu/z80/z80daisy.cpp @@ -21,7 +21,8 @@ //------------------------------------------------- device_z80daisy_interface::device_z80daisy_interface(const machine_config &mconfig, device_t &device) - : device_interface(device, "z80daisy") + : device_interface(device, "z80daisy"), + m_daisy_next(nullptr) { } @@ -41,31 +42,61 @@ device_z80daisy_interface::~device_z80daisy_interface() //************************************************************************** //------------------------------------------------- -// z80_daisy_chain - constructor +// z80_daisy_chain_interface - constructor //------------------------------------------------- -z80_daisy_chain::z80_daisy_chain() - : m_daisy_list(nullptr) +z80_daisy_chain_interface::z80_daisy_chain_interface(const machine_config &mconfig, device_t &device) + : device_interface(device, "z80daisychain"), + m_daisy_config(nullptr), + m_chain(nullptr) { } //------------------------------------------------- -// init - allocate the daisy chain based on the -// provided configuration +// z80_daisy_chain_interface - destructor //------------------------------------------------- +z80_daisy_chain_interface::~z80_daisy_chain_interface() +{ +} + + +//------------------------------------------------- +// static_set_daisy_config - configuration helper +// to set up the daisy chain +//------------------------------------------------- +void z80_daisy_chain_interface::static_set_daisy_config(device_t &device, const z80_daisy_config *config) +{ + z80_daisy_chain_interface *daisyintf; + if (!device.interface(daisyintf)) + throw emu_fatalerror("MCFG_Z80_DAISY_CHAIN called on device '%s' with no daisy chain interface", device.tag()); + daisyintf->m_daisy_config = config; +} + + +//------------------------------------------------- +// interface_post_start - work to be done after +// actually starting a device +//------------------------------------------------- + +void z80_daisy_chain_interface::interface_post_start() +{ + if (m_daisy_config != nullptr) + daisy_init(m_daisy_config); +} -void z80_daisy_chain::init(device_t *cpudevice, const z80_daisy_config *daisy) +void z80_daisy_chain_interface::daisy_init(const z80_daisy_config *daisy) { // create a linked list of devices - daisy_entry **tailptr = &m_daisy_list; + device_z80daisy_interface **tailptr = &m_chain; for ( ; daisy->devname != nullptr; daisy++) { // find the device - device_t *target; - if ((target = cpudevice->subdevice(daisy->devname)) == nullptr) + device_t *target = device().subdevice(daisy->devname); + if (target == nullptr) { - if ((target = cpudevice->siblingdevice(daisy->devname)) == nullptr) + target = device().siblingdevice(daisy->devname); + if (target == nullptr) fatalerror("Unable to locate device '%s'\n", daisy->devname); } @@ -75,26 +106,24 @@ void z80_daisy_chain::init(device_t *cpudevice, const z80_daisy_config *daisy) fatalerror("Device '%s' does not implement the z80daisy interface!\n", daisy->devname); // append to the end, or overwrite existing entry - daisy_entry *next = (*tailptr) ? (*tailptr)->m_next : nullptr; - if (*tailptr != nullptr) - auto_free(cpudevice->machine(), *tailptr); - *tailptr = auto_alloc(cpudevice->machine(), daisy_entry(target)); - (*tailptr)->m_next = next; - tailptr = &(*tailptr)->m_next; + device_z80daisy_interface *next = (*tailptr != nullptr) ? (*tailptr)->m_daisy_next : nullptr; + *tailptr = intf; + (*tailptr)->m_daisy_next = next; + tailptr = &(*tailptr)->m_daisy_next; } } //------------------------------------------------- -// reset - send a reset signal to all chained -// devices +// interface_post_reset - work to be done after a +// device is reset //------------------------------------------------- -void z80_daisy_chain::reset() +void z80_daisy_chain_interface::interface_post_reset() { - // loop over all devices and call their reset function - for (daisy_entry *daisy = m_daisy_list; daisy != nullptr; daisy = daisy->m_next) - daisy->m_device->reset(); + // loop over all chained devices and call their reset function + for (device_z80daisy_interface *intf = m_chain; intf != nullptr; intf = intf->m_daisy_next) + intf->device().reset(); } @@ -103,13 +132,13 @@ void z80_daisy_chain::reset() // return assert/clear based on the state //------------------------------------------------- -int z80_daisy_chain::update_irq_state() +int z80_daisy_chain_interface::daisy_update_irq_state() { // loop over all devices; dev[0] is highest priority - for (daisy_entry *daisy = m_daisy_list; daisy != nullptr; daisy = daisy->m_next) + for (device_z80daisy_interface *intf = m_chain; intf != nullptr; intf = intf->m_daisy_next) { // if this device is asserting the INT line, that's the one we want - int state = daisy->m_interface->z80daisy_irq_state(); + int state = intf->z80daisy_irq_state(); if (state & Z80_DAISY_INT) return ASSERT_LINE; @@ -126,16 +155,16 @@ int z80_daisy_chain::update_irq_state() // from a chained device and return the vector //------------------------------------------------- -int z80_daisy_chain::call_ack_device() +int z80_daisy_chain_interface::daisy_call_ack_device() { int vector = 0; // loop over all devices; dev[0] is the highest priority - for (daisy_entry *daisy = m_daisy_list; daisy != nullptr; daisy = daisy->m_next) + for (device_z80daisy_interface *intf = m_chain; intf != nullptr; intf = intf->m_daisy_next) { // if this device is asserting the INT line, that's the one we want - int state = daisy->m_interface->z80daisy_irq_state(); - vector = daisy->m_interface->z80daisy_irq_ack(); + int state = intf->z80daisy_irq_state(); + vector = intf->z80daisy_irq_ack(); if (state & Z80_DAISY_INT) return vector; } @@ -149,31 +178,18 @@ int z80_daisy_chain::call_ack_device() // the chain //------------------------------------------------- -void z80_daisy_chain::call_reti_device() +void z80_daisy_chain_interface::daisy_call_reti_device() { // loop over all devices; dev[0] is the highest priority - for (daisy_entry *daisy = m_daisy_list; daisy != nullptr; daisy = daisy->m_next) + for (device_z80daisy_interface *intf = m_chain; intf != nullptr; intf = intf->m_daisy_next) { // if this device is asserting the IEO line, that's the one we want - int state = daisy->m_interface->z80daisy_irq_state(); + int state = intf->z80daisy_irq_state(); if (state & Z80_DAISY_IEO) { - daisy->m_interface->z80daisy_irq_reti(); + intf->z80daisy_irq_reti(); return; } } //logerror("z80daisy_call_reti_device: failed to find an device to reti!\n"); } - - -//------------------------------------------------- -// daisy_entry - constructor -//------------------------------------------------- - -z80_daisy_chain::daisy_entry::daisy_entry(device_t *device) - : m_next(nullptr), - m_device(device), - m_interface(nullptr) -{ - device->interface(m_interface); -} diff --git a/src/devices/cpu/z80/z80daisy.h b/src/devices/cpu/z80/z80daisy.h index 258df6cd017..9248c31c6da 100644 --- a/src/devices/cpu/z80/z80daisy.h +++ b/src/devices/cpu/z80/z80daisy.h @@ -25,6 +25,16 @@ const UINT8 Z80_DAISY_IEO = 0x02; // interrupt disable mask (IEO) +//************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** + +// configure devices +#define MCFG_Z80_DAISY_CHAIN(_config) \ + z80_daisy_chain_interface::static_set_daisy_config(*device, _config); + + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -43,6 +53,8 @@ struct z80_daisy_config class device_z80daisy_interface : public device_interface { + friend class z80_daisy_chain_interface; + public: // construction/destruction device_z80daisy_interface(const machine_config &mconfig, device_t &device); @@ -52,37 +64,44 @@ public: virtual int z80daisy_irq_state() = 0; virtual int z80daisy_irq_ack() = 0; virtual void z80daisy_irq_reti() = 0; + +private: + device_z80daisy_interface *m_daisy_next; // next device in the chain }; -// ======================> z80_daisy_chain +// ======================> z80_daisy_chain_interface -class z80_daisy_chain +class z80_daisy_chain_interface : public device_interface { public: - z80_daisy_chain(); - void init(device_t *cpudevice, const z80_daisy_config *daisy); + // construction/destruction + z80_daisy_chain_interface(const machine_config &mconfig, device_t &device); + virtual ~z80_daisy_chain_interface(); - bool present() const { return (m_daisy_list != nullptr); } + // configuration helpers + static void static_set_daisy_config(device_t &device, const z80_daisy_config *config); - void reset(); - int update_irq_state(); - int call_ack_device(); - void call_reti_device(); + // getters + bool daisy_chain_present() const { return (m_chain != nullptr); } protected: - class daisy_entry - { - public: - daisy_entry(device_t *device); + // interface-level overrides + virtual void interface_post_start() override; + virtual void interface_post_reset() override; + + // initialization + void daisy_init(const z80_daisy_config *daisy); - daisy_entry * m_next; // next device - device_t * m_device; // associated device - device_z80daisy_interface * m_interface; // associated device's daisy interface - }; + // callbacks + int daisy_update_irq_state(); + int daisy_call_ack_device(); + void daisy_call_reti_device(); - daisy_entry * m_daisy_list; // head of the daisy chain +private: + const z80_daisy_config *m_daisy_config; + device_z80daisy_interface *m_chain; // head of the daisy chain }; diff --git a/src/devices/cpu/z8000/z8000.cpp b/src/devices/cpu/z8000/z8000.cpp index 9d796a518dd..9f71abf47a8 100644 --- a/src/devices/cpu/z8000/z8000.cpp +++ b/src/devices/cpu/z8000/z8000.cpp @@ -35,6 +35,7 @@ const device_type Z8002 = &device_creator; z8002_device::z8002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : cpu_device(mconfig, Z8002, "Z8002", tag, owner, clock, "z8002", __FILE__) + , z80_daisy_chain_interface(mconfig, *this) , m_program_config("program", ENDIANNESS_BIG, 16, 16, 0) , m_io_config("io", ENDIANNESS_BIG, 8, 16, 0) , m_mo_out(*this), m_ppc(0), m_pc(0), m_psapseg(0), m_psapoff(0), m_fcw(0), m_refresh(0), m_nspseg(0), m_nspoff(0), m_irq_req(0), m_irq_vec(0), m_op_valid(0), m_nmi_state(0), m_mi(0), m_program(nullptr), m_data(nullptr), m_direct(nullptr), m_io(nullptr), m_icount(0) @@ -45,6 +46,7 @@ z8002_device::z8002_device(const machine_config &mconfig, const char *tag, devic z8002_device::z8002_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source) + , z80_daisy_chain_interface(mconfig, *this) , m_program_config("program", ENDIANNESS_BIG, 16, 20, 0) , m_io_config("io", ENDIANNESS_BIG, 16, 16, 0) , m_mo_out(*this), m_ppc(0), m_pc(0), m_psapseg(0), m_psapoff(0), m_fcw(0), m_refresh(0), m_nspseg(0), m_nspoff(0), m_irq_req(0), m_irq_vec(0), m_op_valid(0), m_nmi_state(0), m_mi(0), m_program(nullptr), m_data(nullptr), m_direct(nullptr), m_io(nullptr), m_icount(0) diff --git a/src/devices/cpu/z8000/z8000.h b/src/devices/cpu/z8000/z8000.h index 98ccc6ddea4..288a2700c99 100644 --- a/src/devices/cpu/z8000/z8000.h +++ b/src/devices/cpu/z8000/z8000.h @@ -5,6 +5,8 @@ #ifndef __Z8000_H__ #define __Z8000_H__ +#include "cpu/z80/z80daisy.h" + enum { @@ -31,7 +33,7 @@ enum #define MCFG_Z8000_MO(_devcb) \ devcb = &z8002_device::set_mo_callback(*device, DEVCB_##_devcb); -class z8002_device : public cpu_device +class z8002_device : public cpu_device, public z80_daisy_chain_interface { public: // construction/destruction diff --git a/src/devices/imagedev/flopdrv.cpp b/src/devices/imagedev/flopdrv.cpp index 71bfd2c7158..9842e4af0b1 100644 --- a/src/devices/imagedev/flopdrv.cpp +++ b/src/devices/imagedev/flopdrv.cpp @@ -127,7 +127,7 @@ void legacy_floppy_image_device::floppy_drive_init() m_index_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(legacy_floppy_image_device::floppy_drive_index_callback),this)); m_idx = 0; - floppy_drive_set_geometry(((floppy_interface*)static_config())->floppy_type); + floppy_drive_set_geometry(m_config->floppy_type); /* initialise id index - not so important */ m_id_index = 0; @@ -426,7 +426,7 @@ int legacy_floppy_image_device::internal_floppy_device_load(int create_format, o device_image_interface *image = nullptr; interface(image); /* figure out the floppy options */ - floppy_options = ((floppy_interface*)static_config())->formats; + floppy_options = m_config->formats; if (has_been_created()) { @@ -776,7 +776,6 @@ legacy_floppy_image_device::~legacy_floppy_image_device() void legacy_floppy_image_device::device_start() { - m_config = (const floppy_interface*)static_config(); floppy_drive_init(); m_drive_id = floppy_get_drive(this); @@ -816,7 +815,7 @@ void legacy_floppy_image_device::device_start() void legacy_floppy_image_device::device_config_complete() { m_extension_list[0] = '\0'; - const struct FloppyFormat *floppy_options = ((floppy_interface*)static_config())->formats; + const struct FloppyFormat *floppy_options = m_config->formats; for (int i = 0; floppy_options[i].construct; i++) { // only add if creatable @@ -885,9 +884,9 @@ void legacy_floppy_image_device::call_unload() bool legacy_floppy_image_device::is_creatable() const { int cnt = 0; - if (static_config() ) + if (m_config != nullptr) { - const struct FloppyFormat *floppy_options = ((floppy_interface*)static_config())->formats; + const struct FloppyFormat *floppy_options = m_config->formats; int i; for ( i = 0; floppy_options[i].construct; i++ ) { if(floppy_options[i].param_guidelines) cnt++; @@ -898,5 +897,5 @@ bool legacy_floppy_image_device::is_creatable() const const char *legacy_floppy_image_device::image_interface() const { - return ((floppy_interface *)static_config())->interface; + return m_config->interface; } diff --git a/src/devices/imagedev/flopdrv.h b/src/devices/imagedev/flopdrv.h index 9d4333cfae2..de01485ba97 100644 --- a/src/devices/imagedev/flopdrv.h +++ b/src/devices/imagedev/flopdrv.h @@ -96,6 +96,7 @@ public: legacy_floppy_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); ~legacy_floppy_image_device(); + static void static_set_floppy_config(device_t &device, const floppy_interface *config) { downcast(device).m_config = config; } template static devcb_base &set_out_idx_func(device_t &device, _Object object) { return downcast(device).m_out_idx_func.set_callback(object); } virtual bool call_load() override; @@ -242,24 +243,27 @@ int floppy_get_count(running_machine &machine); #define FLOPPY_3 "floppy3" +#define MCFG_LEGACY_FLOPPY_CONFIG(_config) \ + legacy_floppy_image_device::static_set_floppy_config(*device, &(_config)); + #define MCFG_LEGACY_FLOPPY_DRIVE_ADD(_tag, _config) \ MCFG_DEVICE_ADD(_tag, LEGACY_FLOPPY, 0) \ - MCFG_DEVICE_CONFIG(_config) + MCFG_LEGACY_FLOPPY_CONFIG(_config) #define MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(_config) \ MCFG_DEVICE_ADD(FLOPPY_0, LEGACY_FLOPPY, 0) \ - MCFG_DEVICE_CONFIG(_config) \ + MCFG_LEGACY_FLOPPY_CONFIG(_config) \ MCFG_DEVICE_ADD(FLOPPY_1, LEGACY_FLOPPY, 0) \ - MCFG_DEVICE_CONFIG(_config) \ + MCFG_LEGACY_FLOPPY_CONFIG(_config) \ MCFG_DEVICE_ADD(FLOPPY_2, LEGACY_FLOPPY, 0) \ - MCFG_DEVICE_CONFIG(_config) \ + MCFG_LEGACY_FLOPPY_CONFIG(_config) \ MCFG_DEVICE_ADD(FLOPPY_3, LEGACY_FLOPPY, 0) \ - MCFG_DEVICE_CONFIG(_config) + MCFG_LEGACY_FLOPPY_CONFIG(_config) #define MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(_config) \ MCFG_DEVICE_ADD(FLOPPY_0, LEGACY_FLOPPY, 0) \ - MCFG_DEVICE_CONFIG(_config) \ + MCFG_LEGACY_FLOPPY_CONFIG(_config) \ MCFG_DEVICE_ADD(FLOPPY_1, LEGACY_FLOPPY, 0) \ - MCFG_DEVICE_CONFIG(_config) + MCFG_LEGACY_FLOPPY_CONFIG(_config) #endif /* __FLOPDRV_H__ */ diff --git a/src/devices/machine/ldv1000.cpp b/src/devices/machine/ldv1000.cpp index 1e6224adc0d..36dae481853 100644 --- a/src/devices/machine/ldv1000.cpp +++ b/src/devices/machine/ldv1000.cpp @@ -86,7 +86,7 @@ static const z80_daisy_config daisy_chain[] = static MACHINE_CONFIG_FRAGMENT( ldv1000 ) MCFG_CPU_ADD("ldv1000", Z80, XTAL_5MHz/2) - MCFG_CPU_CONFIG(daisy_chain) + MCFG_Z80_DAISY_CHAIN(daisy_chain) MCFG_CPU_PROGRAM_MAP(ldv1000_map) MCFG_CPU_IO_MAP(ldv1000_portmap) diff --git a/src/devices/sound/flt_rc.h b/src/devices/sound/flt_rc.h index 79c1abfa2ca..e6bc72baaa7 100644 --- a/src/devices/sound/flt_rc.h +++ b/src/devices/sound/flt_rc.h @@ -34,11 +34,11 @@ * This filter may be setup just with * * MCFG_FILTER_RC_ADD("tag", 0) - * MCFG_FILTER_RC_AC(&flt_rc_ac_default) + * MCFG_FILTER_RC_AC() * * Default behaviour: * - * Without MCFG_SOUND_CONFIG, a disabled FLT_RC_LOWPASS is created + * Without MCFG_FILTER_RC_AC, a disabled FLT_RC_LOWPASS is created * */ -- cgit v1.2.3-70-g09d2