From fb131c9514c657e5d91ee9f7be2096891c1388ba Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 17 Feb 2024 18:15:54 +0100 Subject: bus/idpartner: added SASI adapter --- scripts/src/bus.lua | 2 + src/devices/bus/idpartner/bus.cpp | 3 + src/devices/bus/idpartner/bus.h | 3 + src/devices/bus/idpartner/sasi.cpp | 136 +++++++++++++++++++++++++++++++++++++ src/devices/bus/idpartner/sasi.h | 12 ++++ src/mame/sfrj/idpartner.cpp | 5 +- 6 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 src/devices/bus/idpartner/sasi.cpp create mode 100644 src/devices/bus/idpartner/sasi.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index a83f52012c7..6db8d1ac940 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -1525,6 +1525,8 @@ if (BUSES["IDPARTNER"]~=null) then MAME_DIR .. "src/devices/bus/idpartner/bus.h", MAME_DIR .. "src/devices/bus/idpartner/gdp.cpp", MAME_DIR .. "src/devices/bus/idpartner/gdp.h", + MAME_DIR .. "src/devices/bus/idpartner/sasi.cpp", + MAME_DIR .. "src/devices/bus/idpartner/sasi.h", } end diff --git a/src/devices/bus/idpartner/bus.cpp b/src/devices/bus/idpartner/bus.cpp index abf2535bcfc..6b82488062a 100644 --- a/src/devices/bus/idpartner/bus.cpp +++ b/src/devices/bus/idpartner/bus.cpp @@ -59,6 +59,7 @@ bus_device::bus_device(const machine_config &mconfig, const char *tag, device_t , m_io(*this, finder_base::DUMMY_TAG, -1) , m_int_handler(*this) , m_nmi_handler(*this) + , m_drq_handler(*this) { } @@ -77,8 +78,10 @@ void bus_device::device_reset() } // namespace bus::idpartner #include "gdp.h" +#include "sasi.h" void idpartner_exp_devices(device_slot_interface &device) { device.option_add("gdp", IDPARTNER_GDP); + device.option_add("sasi", IDPARTNER_SASI); } diff --git a/src/devices/bus/idpartner/bus.h b/src/devices/bus/idpartner/bus.h index 9b23b58b32c..0ac5cc6cb47 100644 --- a/src/devices/bus/idpartner/bus.h +++ b/src/devices/bus/idpartner/bus.h @@ -93,10 +93,12 @@ public: // callbacks auto int_handler() { return m_int_handler.bind(); } auto nmi_handler() { return m_nmi_handler.bind(); } + auto drq_handler() { return m_drq_handler.bind(); } // called from expansion device void int_w(int state) { m_int_handler(state); } void nmi_w(int state) { m_nmi_handler(state); } + void drq_w(int state) { m_drq_handler(state); } address_space &io() { return *m_io; } @@ -110,6 +112,7 @@ private: devcb_write_line m_int_handler; devcb_write_line m_nmi_handler; + devcb_write_line m_drq_handler; }; // ======================> device_exp_card_interface diff --git a/src/devices/bus/idpartner/sasi.cpp b/src/devices/bus/idpartner/sasi.cpp new file mode 100644 index 00000000000..a5d7ea2c654 --- /dev/null +++ b/src/devices/bus/idpartner/sasi.cpp @@ -0,0 +1,136 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic +/********************************************************************** + + Iskra Delta SASI Adapter + +**********************************************************************/ + +#include "emu.h" +#include "sasi.h" + +#include "bus/nscsi/devices.h" +#include "machine/nscsi_bus.h" +#include "machine/nscsi_cb.h" + +namespace { + +class idpartner_sasi_device : + public device_t, + public bus::idpartner::device_exp_card_interface +{ +public: + // construction/destruction + idpartner_sasi_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + // device_t implementation + virtual void device_start() override; + virtual void device_reset() override; + virtual void device_add_mconfig(machine_config &config) override; + + u8 stat_r(); + u8 data_r(); + void ctrl_w(u8 data); + void data_w(u8 data); + void reset_w(u8 data); + + void req_w(int state); + +private: + required_device m_sasibus; + required_device m_sasi; + + int m_drq_enable; + int m_data_enable; + int m_ack; +}; + + +idpartner_sasi_device::idpartner_sasi_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, IDPARTNER_SASI, tag, owner, clock) + , bus::idpartner::device_exp_card_interface(mconfig, *this) + , m_sasibus(*this, "sasibus") + , m_sasi(*this, "sasibus:7:scsicb") + , m_drq_enable(0) + , m_data_enable(0) + , m_ack(0) +{ +} + +/*---------------------------------- + device_t implementation +----------------------------------*/ + +void idpartner_sasi_device::device_start() +{ + m_bus->io().install_read_handler (0x10, 0x10, emu::rw_delegate(*this, FUNC(idpartner_sasi_device::stat_r))); // RDSTAT + m_bus->io().install_read_handler (0x11, 0x11, emu::rw_delegate(*this, FUNC(idpartner_sasi_device::data_r))); // RDDATA + m_bus->io().install_write_handler(0x10, 0x10, emu::rw_delegate(*this, FUNC(idpartner_sasi_device::ctrl_w))); // WRCONTR + m_bus->io().install_write_handler(0x11, 0x11, emu::rw_delegate(*this, FUNC(idpartner_sasi_device::data_w))); // WRDATA + m_bus->io().install_write_handler(0x12, 0x12, emu::rw_delegate(*this, FUNC(idpartner_sasi_device::reset_w))); // RESET +} + +void idpartner_sasi_device::device_reset() +{ +} + +u8 idpartner_sasi_device::stat_r() +{ + u8 data = (m_sasi->req_r() << 7) + | (m_sasi->io_r() << 6) + | (m_sasi->msg_r() << 5) + | (m_sasi->cd_r() << 4) + | (m_sasi->bsy_r() << 3); + return data; +} + +u8 idpartner_sasi_device::data_r() +{ + u8 data = m_sasi->read(); + if (m_data_enable) { + m_sasi->ack_w(1); + } + return data; +} + +void idpartner_sasi_device::ctrl_w(u8 data) +{ + m_sasi->write(BIT(data,0)); + m_sasi->sel_w(BIT(data,0)); + m_data_enable = BIT(data,1); + m_drq_enable = BIT(data,5); +} + +void idpartner_sasi_device::data_w(u8 data) +{ + m_sasi->write(data); + if (m_data_enable) { + m_sasi->ack_w(1); + } +} + +void idpartner_sasi_device::reset_w(u8 data) +{ + m_sasi->rst_w(1); + m_sasi->rst_w(0); +} + +void idpartner_sasi_device::req_w(int state) +{ + m_sasi->ack_w(0); +} + +void idpartner_sasi_device::device_add_mconfig(machine_config &config) +{ + NSCSI_BUS(config, m_sasibus); + NSCSI_CONNECTOR(config, "sasibus:0", default_scsi_devices, "s1410", true); + NSCSI_CONNECTOR(config, "sasibus:7", default_scsi_devices, "scsicb", true) + .option_add_internal("scsicb", NSCSI_CB) + .machine_config([this](device_t* device) { + downcast(*device).req_callback().set(*this, FUNC(idpartner_sasi_device::req_w)); + }); + } +} // anonymous namespace + +DEFINE_DEVICE_TYPE_PRIVATE(IDPARTNER_SASI, bus::idpartner::device_exp_card_interface, idpartner_sasi_device, "partner_sai", "Iskra Delta Partner SASI card") diff --git a/src/devices/bus/idpartner/sasi.h b/src/devices/bus/idpartner/sasi.h new file mode 100644 index 00000000000..645c8baed3d --- /dev/null +++ b/src/devices/bus/idpartner/sasi.h @@ -0,0 +1,12 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic +#ifndef MAME_BUS_IDPARTNER_SASI_H +#define MAME_BUS_IDPARTNER_SASI_H + +#pragma once + +#include "bus.h" + +DECLARE_DEVICE_TYPE_NS(IDPARTNER_SASI, bus::idpartner, device_exp_card_interface) + +#endif // MAME_BUS_IDPARTNER_SASI_H diff --git a/src/mame/sfrj/idpartner.cpp b/src/mame/sfrj/idpartner.cpp index 43e2d7cdee9..0cb3a063095 100644 --- a/src/mame/sfrj/idpartner.cpp +++ b/src/mame/sfrj/idpartner.cpp @@ -397,7 +397,6 @@ void idpartner_state::partner_base(machine_config &config) I8272A(config, m_fdc, XTAL(8'000'000) / 2, false); m_fdc->intrq_wr_callback().set(m_fdc_daisy, FUNC(idpartner_floppy_daisy_device::int_w)); m_fdc->drq_wr_callback().set(m_dma, FUNC(z80dma_device::rdy_w)); - m_fdc->ready_w(false); FLOPPY_CONNECTOR(config, m_floppy[0], partner_floppies, "fdd", partner_floppy_formats).enable_sound(true); FLOPPY_CONNECTOR(config, m_floppy[1], partner_floppies, nullptr, partner_floppy_formats).enable_sound(true); @@ -411,6 +410,7 @@ void idpartner_state::partner_base(machine_config &config) m_bus->set_io_space(m_maincpu, AS_IO); m_bus->int_handler().set_inputline(m_maincpu, INPUT_LINE_IRQ0); m_bus->nmi_handler().set_inputline(m_maincpu, INPUT_LINE_NMI); + m_bus->drq_handler().set(m_dma, FUNC(z80dma_device::rdy_w)); IDPARTNER_BUS_CONNECTOR(config, m_conn[0], m_bus, idpartner_exp_devices, nullptr); IDPARTNER_BUS_CONNECTOR(config, m_conn[1], m_bus, idpartner_exp_devices, nullptr); } @@ -421,6 +421,8 @@ void idpartner_state::partnerw(machine_config &config) m_serial[0]->set_default_option("terminal"); m_serial[0]->set_option_device_input_defaults("terminal", DEVICE_INPUT_DEFAULTS_NAME(terminal)); // must be below the DEVICE_INPUT_DEFAULTS_START block + + m_conn[1]->set_default_option("sasi"); } void idpartner_state::partner1fg(machine_config &config) @@ -439,6 +441,7 @@ void idpartner_state::partnerwfg(machine_config &config) m_serial[0]->set_default_option("keyboard"); m_conn[0]->set_default_option("gdp"); + m_conn[1]->set_default_option("sasi"); } /* ROM definition */ -- cgit v1.2.3