diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 463f8169a55..a57b22de5bd 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -4612,6 +4612,8 @@ if (BUSES["ZXBUS"]~=null) then files { MAME_DIR .. "src/devices/bus/spectrum/zxbus.cpp", MAME_DIR .. "src/devices/bus/spectrum/zxbus.h", + MAME_DIR .. "src/devices/bus/spectrum/nemoide.cpp", + MAME_DIR .. "src/devices/bus/spectrum/nemoide.h", MAME_DIR .. "src/devices/bus/spectrum/neogs.cpp", MAME_DIR .. "src/devices/bus/spectrum/neogs.h", MAME_DIR .. "src/devices/bus/spectrum/smuc.cpp", diff --git a/src/devices/bus/spectrum/nemoide.cpp b/src/devices/bus/spectrum/nemoide.cpp new file mode 100644 index 00000000000..ff3954a5aca --- /dev/null +++ b/src/devices/bus/spectrum/nemoide.cpp @@ -0,0 +1,85 @@ +// license:BSD-3-Clause +// copyright-holders:Andrei I. Holub + +#include "emu.h" +#include "nemoide.h" + +#include "bus/ata/ataintf.h" +#include "bus/ata/atapicdr.h" +#include "bus/ata/hdd.h" + +namespace bus::spectrum::zxbus { + +namespace { + +class nemoide_device : public device_t, public device_zxbus_card_interface +{ +public: + nemoide_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, ZXBUS_NEMOIDE, tag, owner, clock) + , device_zxbus_card_interface(mconfig, *this) + , m_ata(*this, "ata") + { } + +protected: + virtual void device_add_mconfig(machine_config &config) override; + virtual void device_start() override; + +private: + void map_io(address_map &map); + + u8 ata_r(offs_t offset); + void ata_w(offs_t offset, u8 data); + + required_device m_ata; + + u8 m_ata_data_latch; +}; + +u8 nemoide_device::ata_r(offs_t offset) +{ + const u16 data = m_ata->cs0_r((offset >> 5) & 7); + if (!machine().side_effects_disabled()) + m_ata_data_latch = data >> 8; + + return data & 0xff; +} + +void nemoide_device::ata_w(offs_t offset, u8 data) +{ + const u16 ata_data = (m_ata_data_latch << 8) | data; + m_ata->cs0_w((offset >> 5) & 7, ata_data); +} + +void nemoide_device::map_io(address_map &map) +{ + map(0x00011, 0x00011).mirror(0xff00).lrw8(NAME([this]() { return m_ata_data_latch; }) + , NAME([this](offs_t offset, u8 data) { m_ata_data_latch = data; })); + map(0x00010, 0x00010).select(0xffe0).rw(FUNC(nemoide_device::ata_r), FUNC(nemoide_device::ata_w)); + map(0x000c8, 0x000c8).mirror(0xff00).lrw8(NAME([this]() { return m_ata->cs1_r(6); }) + , NAME([this](offs_t offset, u8 data) { m_ata->cs1_w(6, data); })); +} + +static void nemoide_ata_devices(device_slot_interface &device) +{ + device.option_add("hdd", IDE_HARDDISK); + device.option_add("cdrom", ATAPI_CDROM); +} + +void nemoide_device::device_add_mconfig(machine_config &config) +{ + ATA_INTERFACE(config, m_ata).options(nemoide_ata_devices, "hdd", "hdd", false); +} + +void nemoide_device::device_start() +{ + save_item(NAME(m_ata_data_latch)); + + m_zxbus->install_device(0x00000, 0x1ffff, *this, &nemoide_device::map_io); +} + +} // anonymous namespace + +} // namespace bus::spectrum::zxbus + +DEFINE_DEVICE_TYPE_PRIVATE(ZXBUS_NEMOIDE, device_zxbus_card_interface, bus::spectrum::zxbus::nemoide_device, "nemoide", "Nemo IDE Controller") diff --git a/src/devices/bus/spectrum/nemoide.h b/src/devices/bus/spectrum/nemoide.h new file mode 100644 index 00000000000..441f3c9514a --- /dev/null +++ b/src/devices/bus/spectrum/nemoide.h @@ -0,0 +1,14 @@ +// license:BSD-3-Clause +// copyright-holders:Andrei I. Holub + +#ifndef MAME_SINCLAIR_NEMOIDE_H +#define MAME_SINCLAIR_NEMOIDE_H + +#pragma once + +#include "zxbus.h" + + +DECLARE_DEVICE_TYPE(ZXBUS_NEMOIDE, device_zxbus_card_interface) + +#endif // MAME_SINCLAIR_NEMOIDE_H diff --git a/src/devices/bus/spectrum/neogs.cpp b/src/devices/bus/spectrum/neogs.cpp index c2da1d03fd7..45abaed5ae0 100644 --- a/src/devices/bus/spectrum/neogs.cpp +++ b/src/devices/bus/spectrum/neogs.cpp @@ -426,9 +426,9 @@ const tiny_rom_entry *neogs_device::device_rom_region() const void neogs_device::neogsmap(address_map &map) { - map(0x00bb, 0x00bb).mirror(0xff00).rw(FUNC(neogs_device::neogs_status_r), FUNC(neogs_device::neogs_command_w)); - map(0x00b3, 0x00b3).mirror(0xff00).rw(FUNC(neogs_device::neogs_data_r), FUNC(neogs_device::neogs_data_w)); - map(0x0033, 0x0033).mirror(0xff00).w(FUNC(neogs_device::neogs_ctrl_w)); + map(0x000bb, 0x000bb).mirror(0xff00).rw(FUNC(neogs_device::neogs_status_r), FUNC(neogs_device::neogs_command_w)); + map(0x000b3, 0x000b3).mirror(0xff00).rw(FUNC(neogs_device::neogs_data_r), FUNC(neogs_device::neogs_data_w)); + map(0x00033, 0x00033).mirror(0xff00).w(FUNC(neogs_device::neogs_ctrl_w)); } void neogs_device::device_start() diff --git a/src/devices/bus/spectrum/zxbus.cpp b/src/devices/bus/spectrum/zxbus.cpp index f2899d70763..24546353cf7 100644 --- a/src/devices/bus/spectrum/zxbus.cpp +++ b/src/devices/bus/spectrum/zxbus.cpp @@ -66,11 +66,13 @@ void device_zxbus_card_interface::interface_pre_start() } +#include "nemoide.h" #include "neogs.h" #include "smuc.h" void zxbus_cards(device_slot_interface &device) { + device.option_add("nemoide", ZXBUS_NEMOIDE); device.option_add("neogs", ZXBUS_NEOGS); device.option_add("smuc", ZXBUS_SMUC); }