diff --git a/src/devices/bus/x68k/x68k_midi.cpp b/src/devices/bus/x68k/x68k_midi.cpp index 52835653730..abcc0b34955 100644 --- a/src/devices/bus/x68k/x68k_midi.cpp +++ b/src/devices/bus/x68k/x68k_midi.cpp @@ -39,10 +39,8 @@ x68k_midi_device::x68k_midi_device(const machine_config &mconfig, const char *ta void x68k_midi_device::device_start() { - device_t* cpu = machine().device("maincpu"); - address_space& space = cpu->memory().space(AS_PROGRAM); m_slot = dynamic_cast(owner()); - space.install_readwrite_handler(0xeafa00,0xeafa0f,read8_delegate(FUNC(x68k_midi_device::x68k_midi_reg_r),this),write8_delegate(FUNC(x68k_midi_device::x68k_midi_reg_w),this),0x00ff00ff); + m_slot->space().install_readwrite_handler(0xeafa00,0xeafa0f,read8_delegate(FUNC(x68k_midi_device::x68k_midi_reg_r),this),write8_delegate(FUNC(x68k_midi_device::x68k_midi_reg_w),this),0x00ff00ff); } void x68k_midi_device::device_reset() diff --git a/src/devices/bus/x68k/x68k_neptunex.cpp b/src/devices/bus/x68k/x68k_neptunex.cpp index fdbbcb6a89e..7a7b7c3aaab 100644 --- a/src/devices/bus/x68k/x68k_neptunex.cpp +++ b/src/devices/bus/x68k/x68k_neptunex.cpp @@ -39,17 +39,15 @@ x68k_neptune_device::x68k_neptune_device(const machine_config &mconfig, const ch void x68k_neptune_device::device_start() { - device_t* cpu = machine().device("maincpu"); char mac[7]; uint32_t num = machine().rand(); - address_space& space = cpu->memory().space(AS_PROGRAM); m_slot = dynamic_cast(owner()); memset(m_prom, 0x57, 16); sprintf(mac+2, "\x1b%c%c%c", (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff); mac[0] = 0; mac[1] = 0; // avoid gcc warning memcpy(m_prom, mac, 6); m_dp8390->set_mac(mac); - space.install_readwrite_handler(0xece000,0xece3ff,read16_delegate(FUNC(x68k_neptune_device::x68k_neptune_port_r),this),write16_delegate(FUNC(x68k_neptune_device::x68k_neptune_port_w),this),0xffffffff); + m_slot->space().install_readwrite_handler(0xece000,0xece3ff,read16_delegate(FUNC(x68k_neptune_device::x68k_neptune_port_r),this),write16_delegate(FUNC(x68k_neptune_device::x68k_neptune_port_w),this),0xffffffff); } void x68k_neptune_device::device_reset() { diff --git a/src/devices/bus/x68k/x68k_scsiext.cpp b/src/devices/bus/x68k/x68k_scsiext.cpp index 8002fc041e6..3cf18f9d2ee 100644 --- a/src/devices/bus/x68k/x68k_scsiext.cpp +++ b/src/devices/bus/x68k/x68k_scsiext.cpp @@ -65,15 +65,14 @@ x68k_scsiext_device::x68k_scsiext_device(const machine_config &mconfig, const ch void x68k_scsiext_device::device_start() { - device_t* cpu = machine().device("maincpu"); - uint8_t* ROM; - address_space& space = cpu->memory().space(AS_PROGRAM); m_slot = dynamic_cast(owner()); - space.install_read_bank(0xea0020,0xea1fff,"scsi_ext"); - space.unmap_write(0xea0020,0xea1fff); - ROM = machine().root_device().memregion(subtag("scsiexrom").c_str())->base(); + m_slot->space().install_read_bank(0xea0020,0xea1fff,"scsi_ext"); + m_slot->space().unmap_write(0xea0020,0xea1fff); + + uint8_t *ROM = machine().root_device().memregion(subtag("scsiexrom").c_str())->base(); machine().root_device().membank("scsi_ext")->set_base(ROM); - space.install_readwrite_handler(0xea0000,0xea001f,read8_delegate(FUNC(x68k_scsiext_device::register_r),this),write8_delegate(FUNC(x68k_scsiext_device::register_w),this),0x00ff00ff); + +m_slot->space().install_readwrite_handler(0xea0000,0xea001f,read8_delegate(FUNC(x68k_scsiext_device::register_r),this),write8_delegate(FUNC(x68k_scsiext_device::register_w),this),0x00ff00ff); } void x68k_scsiext_device::device_reset() diff --git a/src/devices/bus/x68k/x68kexp.cpp b/src/devices/bus/x68k/x68kexp.cpp index 9d9cded5bd8..dc51559d632 100644 --- a/src/devices/bus/x68k/x68kexp.cpp +++ b/src/devices/bus/x68k/x68kexp.cpp @@ -36,6 +36,7 @@ device_x68k_expansion_card_interface::~device_x68k_expansion_card_interface() x68k_expansion_slot_device::x68k_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, X68K_EXPANSION_SLOT, tag, owner, clock), device_slot_interface(mconfig, *this), + m_space(*this, finder_base::DUMMY_TAG, -1), m_out_irq2_cb(*this), m_out_irq4_cb(*this), m_out_nmi_cb(*this), diff --git a/src/devices/bus/x68k/x68kexp.h b/src/devices/bus/x68k/x68kexp.h index 5130fb668d8..26b3ba06ad6 100644 --- a/src/devices/bus/x68k/x68kexp.h +++ b/src/devices/bus/x68k/x68kexp.h @@ -119,11 +119,14 @@ public: x68k_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); virtual ~x68k_expansion_slot_device(); + template void set_space(T &&tag, int spacenum) { m_space.set_tag(std::forward(tag), spacenum); } + auto out_irq2_callback() { return m_out_irq2_cb.bind(); } auto out_irq4_callback() { return m_out_irq4_cb.bind(); } auto out_nmi_callback() { return m_out_nmi_cb.bind(); } auto out_reset_callback() { return m_out_reset_cb.bind(); } + address_space &space() { return *m_space; } DECLARE_WRITE_LINE_MEMBER( irq2_w ); DECLARE_WRITE_LINE_MEMBER( irq4_w ); @@ -137,6 +140,8 @@ protected: virtual void device_start() override; virtual void device_reset() override; + required_address_space m_space; + devcb_write_line m_out_irq2_cb; devcb_write_line m_out_irq4_cb; devcb_write_line m_out_nmi_cb; diff --git a/src/mame/drivers/x68k.cpp b/src/mame/drivers/x68k.cpp index 268e903a736..ede53c0d39a 100644 --- a/src/mame/drivers/x68k.cpp +++ b/src/mame/drivers/x68k.cpp @@ -1628,6 +1628,7 @@ void x68k_state::x68000_base(machine_config &config) SOFTWARE_LIST(config, "flop_list").set_original("x68k_flop"); X68K_EXPANSION_SLOT(config, m_expansion, x68000_exp_cards, nullptr); + m_expansion->set_space(m_maincpu, AS_PROGRAM); m_expansion->out_irq2_callback().set(FUNC(x68k_state::irq2_line)); m_expansion->out_irq4_callback().set(FUNC(x68k_state::irq4_line)); m_expansion->out_nmi_callback().set_inputline(m_maincpu, M68K_IRQ_7);