From 209466630554264069c7258cffa06a7ef5a84ded Mon Sep 17 00:00:00 2001 From: Nigel Barnes Date: Sat, 4 Jun 2022 23:02:33 +0100 Subject: New working software list additions ----------------------------------- electron_cart: ElkSD Plus 1 [Ramtop, Nigel Barnes] bbcm_cart: Master SD [Ramptop, Nigel Barnes] --- hash/bbcm_cart.xml | 12 ++ hash/electron_cart.xml | 12 ++ scripts/src/bus.lua | 4 + src/devices/bus/bbc/cart/mastersd.cpp | 174 ++++++++++++++++++++++++++++ src/devices/bus/bbc/cart/mastersd.h | 59 ++++++++++ src/devices/bus/bbc/cart/slot.cpp | 2 + src/devices/bus/electron/cart/elksdp1.cpp | 184 ++++++++++++++++++++++++++++++ src/devices/bus/electron/cart/elksdp1.h | 59 ++++++++++ src/devices/bus/electron/cart/slot.cpp | 2 + 9 files changed, 508 insertions(+) create mode 100644 src/devices/bus/bbc/cart/mastersd.cpp create mode 100644 src/devices/bus/bbc/cart/mastersd.h create mode 100644 src/devices/bus/electron/cart/elksdp1.cpp create mode 100644 src/devices/bus/electron/cart/elksdp1.h diff --git a/hash/bbcm_cart.xml b/hash/bbcm_cart.xml index 53755bcffa0..e6905b6c6b8 100644 --- a/hash/bbcm_cart.xml +++ b/hash/bbcm_cart.xml @@ -120,6 +120,18 @@ Acorn BBC Master ROM Cartridges + + Master SD + 2020 + Ramtop + + + + + + + + Master Mega 256 1987 diff --git a/hash/electron_cart.xml b/hash/electron_cart.xml index 679893f8ba1..3d5f10e1735 100644 --- a/hash/electron_cart.xml +++ b/hash/electron_cart.xml @@ -447,6 +447,18 @@ This list contains all known cartridges for the Acorn Electron. The Acorn Plus 1 + + ElkSD Plus 1 + 2020 + Ramtop + + + + + + + + Pegasus 400 v1.01 1987 diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index e3a695648fd..585b50e007e 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -524,6 +524,8 @@ if (BUSES["BBC_CART"]~=null) then MAME_DIR .. "src/devices/bus/bbc/cart/slot.h", MAME_DIR .. "src/devices/bus/bbc/cart/click.cpp", MAME_DIR .. "src/devices/bus/bbc/cart/click.h", + MAME_DIR .. "src/devices/bus/bbc/cart/mastersd.cpp", + MAME_DIR .. "src/devices/bus/bbc/cart/mastersd.h", MAME_DIR .. "src/devices/bus/bbc/cart/mega256.cpp", MAME_DIR .. "src/devices/bus/bbc/cart/mega256.h", MAME_DIR .. "src/devices/bus/bbc/cart/mr8000.cpp", @@ -1249,6 +1251,8 @@ if (BUSES["ELECTRON_CART"]~=null) then MAME_DIR .. "src/devices/bus/electron/cart/click.h", MAME_DIR .. "src/devices/bus/electron/cart/cumana.cpp", MAME_DIR .. "src/devices/bus/electron/cart/cumana.h", + MAME_DIR .. "src/devices/bus/electron/cart/elksdp1.cpp", + MAME_DIR .. "src/devices/bus/electron/cart/elksdp1.h", MAME_DIR .. "src/devices/bus/electron/cart/mgc.cpp", MAME_DIR .. "src/devices/bus/electron/cart/mgc.h", MAME_DIR .. "src/devices/bus/electron/cart/peg400.cpp", diff --git a/src/devices/bus/bbc/cart/mastersd.cpp b/src/devices/bus/bbc/cart/mastersd.cpp new file mode 100644 index 00000000000..1c1d21ede72 --- /dev/null +++ b/src/devices/bus/bbc/cart/mastersd.cpp @@ -0,0 +1,174 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + MasterSD BBC Master SD Cartridge + + http://ramtop-retro.uk/mastersd.html + +**********************************************************************/ + + +#include "emu.h" +#include "mastersd.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(BBC_MASTERSD, bbc_mastersd_device, "bbc_mastersd", "MasterSD BBC Master SD Cartridge") + + +//------------------------------------------------- +// device_add_mconfig - add device configuration +//------------------------------------------------- + +void bbc_mastersd_device::device_add_mconfig(machine_config &config) +{ + SPI_SDCARD(config, m_sdcard, 0); + m_sdcard->spi_miso_callback().set([this](int state) { m_in_bit = state; }); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// bbc_mastersd_device - constructor +//------------------------------------------------- + +bbc_mastersd_device::bbc_mastersd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, BBC_MASTERSD, tag, owner, clock) + , device_bbc_cart_interface(mconfig, *this) + , m_sdcard(*this, "sdcard") + , m_spi_clock_state(false) + , m_spi_clock_sysclk(false) + , m_spi_clock_cycles(0) +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void bbc_mastersd_device::device_start() +{ + m_ram = make_unique_clear(0x8000); + + m_spi_clock = timer_alloc(FUNC(bbc_mastersd_device::spi_clock), this); + + save_pointer(NAME(m_ram), 0x8000); + save_item(NAME(m_spi_clock_state)); + save_item(NAME(m_spi_clock_sysclk)); + save_item(NAME(m_spi_clock_cycles)); + save_item(NAME(m_in_bit)); + save_item(NAME(m_in_latch)); + save_item(NAME(m_out_latch)); +} + +//------------------------------------------------- +// device_reset - device-specific startup +//------------------------------------------------- + +void bbc_mastersd_device::device_reset() +{ + m_spi_clock->adjust(attotime::never); + m_spi_clock_cycles = 0; + m_spi_clock_state = false; +} + + +//------------------------------------------------- +// read - cartridge data read +//------------------------------------------------- + +uint8_t bbc_mastersd_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) +{ + uint8_t data = 0xff; + + if (oe) + { + if (offset >= 0x3600 || romqa == 1) + { + data = m_ram[(offset & 0x3fff) | (romqa << 14)]; + } + else if (offset == 0x35fe) // SPI controller data port + { + data = m_in_latch; + } + else if (offset == 0x35ff) // SPI controller status register + { + data = m_spi_clock_cycles > 0 ? 0x01 : 0x00; + } + else + { + data = m_rom[offset & 0x3fff]; + } + } + + return data; +} + +//------------------------------------------------- +// write - cartridge data write +//------------------------------------------------- + +void bbc_mastersd_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) +{ + if (oe) + { + if (offset >= 0x3600 || romqa == 1) + { + m_ram[(offset & 0x3fff) | (romqa << 14)] = data; + } + else if (offset == 0x35fe) // SPI controller data port + { + m_out_latch = data; + m_spi_clock_cycles = 8; + + if (m_spi_clock_sysclk) // TODO: confirm fast/slow clock and dividers + m_spi_clock->adjust(attotime::from_hz(16_MHz_XTAL / 2), 0, attotime::from_hz(16_MHz_XTAL / 2)); + else + m_spi_clock->adjust(attotime::from_hz(16_MHz_XTAL / 32), 0, attotime::from_hz(16_MHz_XTAL / 32)); + } + else if (offset == 0x35ff) // SPI controller clock register + { + m_spi_clock_sysclk = bool(BIT(data, 0)); + } + } +} + + +TIMER_CALLBACK_MEMBER(bbc_mastersd_device::spi_clock) +{ + if (m_spi_clock_cycles > 0) + { + m_sdcard->spi_ss_w(1); + + if (m_spi_clock_state) + { + m_in_latch <<= 1; + m_in_latch &= ~0x01; + m_in_latch |= m_in_bit; + + m_sdcard->spi_clock_w(1); + + m_spi_clock_cycles--; + } + else + { + m_sdcard->spi_mosi_w(BIT(m_out_latch, 7)); + m_sdcard->spi_clock_w(0); + + m_out_latch <<= 1; + } + + m_spi_clock_state = !m_spi_clock_state; + } + else + { + m_spi_clock_state = false; + m_spi_clock->adjust(attotime::never); + } +} diff --git a/src/devices/bus/bbc/cart/mastersd.h b/src/devices/bus/bbc/cart/mastersd.h new file mode 100644 index 00000000000..cd6d399176d --- /dev/null +++ b/src/devices/bus/bbc/cart/mastersd.h @@ -0,0 +1,59 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + MasterSD BBC Master SD Cartridge + +**********************************************************************/ + +#ifndef MAME_BUS_BBC_CART_MASTERSD_H +#define MAME_BUS_BBC_CART_MASTERSD_H + +#include "slot.h" +#include "machine/spi_sdcard.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class bbc_mastersd_device : public device_t, public device_bbc_cart_interface +{ +public: + // construction/destruction + bbc_mastersd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + + // optional information overrides + virtual void device_add_mconfig(machine_config &config) override; + + // electron_cart_interface overrides + virtual uint8_t read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) override; + virtual void write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) override; + +private: + required_device m_sdcard; + + TIMER_CALLBACK_MEMBER(spi_clock); + + emu_timer *m_spi_clock; + bool m_spi_clock_state; + bool m_spi_clock_sysclk; + int m_spi_clock_cycles; + int m_in_bit; + uint8_t m_in_latch; + uint8_t m_out_latch; + + std::unique_ptr m_ram; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(BBC_MASTERSD, bbc_mastersd_device) + + +#endif // MAME_BUS_BBC_CART_MASTERSD_H diff --git a/src/devices/bus/bbc/cart/slot.cpp b/src/devices/bus/bbc/cart/slot.cpp index d67924503ea..04e01ac04db 100644 --- a/src/devices/bus/bbc/cart/slot.cpp +++ b/src/devices/bus/bbc/cart/slot.cpp @@ -62,6 +62,7 @@ bbc_cartslot_device::bbc_cartslot_device(const machine_config &mconfig, const ch #include "bus/electron/cart/abr.h" #include "bus/electron/cart/aqr.h" #include "click.h" +#include "mastersd.h" #include "mega256.h" #include "mr8000.h" #include "msc.h" @@ -73,6 +74,7 @@ void bbcm_cart(device_slot_interface &device) device.option_add_internal("abr", ELECTRON_ABR); device.option_add_internal("aqr", ELECTRON_AQR); device.option_add_internal("click", BBC_CLICK); + device.option_add_internal("mastersd", BBC_MASTERSD); device.option_add_internal("mega256", BBC_MEGA256); device.option_add_internal("mr8000", BBC_MR8000); device.option_add_internal("msc", BBC_MSC); diff --git a/src/devices/bus/electron/cart/elksdp1.cpp b/src/devices/bus/electron/cart/elksdp1.cpp new file mode 100644 index 00000000000..c2baf7e7801 --- /dev/null +++ b/src/devices/bus/electron/cart/elksdp1.cpp @@ -0,0 +1,184 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + ElkSD-Plus 1 Electron SD Cartridge + + http://ramtop-retro.uk/elksdp1.html + +**********************************************************************/ + + +#include "emu.h" +#include "elksdp1.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(ELECTRON_ELKSDP1, electron_elksdp1_device, "electron_elksdp1", "ElkSD-Plus 1 Electron SD Cartridge") + + +//------------------------------------------------- +// device_add_mconfig - add device configuration +//------------------------------------------------- + +void electron_elksdp1_device::device_add_mconfig(machine_config &config) +{ + SPI_SDCARD(config, m_sdcard, 0); + m_sdcard->spi_miso_callback().set([this](int state) { m_in_bit = state; }); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// electron_elksdp1_device - constructor +//------------------------------------------------- + +electron_elksdp1_device::electron_elksdp1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ELECTRON_ELKSDP1, tag, owner, clock) + , device_electron_cart_interface(mconfig, *this) + , m_sdcard(*this, "sdcard") + , m_spi_clock_state(false) + , m_spi_clock_sysclk(false) + , m_spi_clock_cycles(0) +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void electron_elksdp1_device::device_start() +{ + m_ram = make_unique_clear(0x8000); + + m_spi_clock = timer_alloc(FUNC(electron_elksdp1_device::spi_clock), this); + + save_pointer(NAME(m_ram), 0x8000); + save_item(NAME(m_spi_clock_state)); + save_item(NAME(m_spi_clock_sysclk)); + save_item(NAME(m_spi_clock_cycles)); + save_item(NAME(m_in_bit)); + save_item(NAME(m_in_latch)); + save_item(NAME(m_out_latch)); +} + +//------------------------------------------------- +// device_reset - device-specific startup +//------------------------------------------------- + +void electron_elksdp1_device::device_reset() +{ + m_spi_clock->adjust(attotime::never); + m_spi_clock_cycles = 0; + m_spi_clock_state = false; +} + + +//------------------------------------------------- +// read - cartridge data read +//------------------------------------------------- + +uint8_t electron_elksdp1_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) +{ + uint8_t data = 0xff; + + if (infc) + { + switch (offset) + { + case 0x80: // SPI controller data port + data = m_in_latch; + break; + + case 0x81: // SPI controller status register + data = m_spi_clock_cycles > 0 ? 0x01 : 0x00; + break; + } + } + if (oe) + { + if (offset >= 0x3600 || romqa == 1) + { + data = m_ram[(offset & 0x3fff) | (romqa << 14)]; + } + else + { + data = m_rom[offset & 0x3fff]; + } + } + + return data; +} + +//------------------------------------------------- +// write - cartridge data write +//------------------------------------------------- + +void electron_elksdp1_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) +{ + if (infc) + { + switch (offset) + { + case 0x80: // SPI controller data port + m_out_latch = data; + m_spi_clock_cycles = 8; + + if (m_spi_clock_sysclk) // TODO: confirm fast/slow clock dividers + m_spi_clock->adjust(attotime::from_hz(16_MHz_XTAL / 2), 0, attotime::from_hz(16_MHz_XTAL / 2)); + else + m_spi_clock->adjust(attotime::from_hz(16_MHz_XTAL / 32), 0, attotime::from_hz(16_MHz_XTAL / 32)); + break; + + case 0x81: // SPI controller clock register + m_spi_clock_sysclk = bool(BIT(data, 0)); + break; + } + } + if (oe) + { + if (offset >= 0x3600 || romqa == 1) + { + m_ram[(offset & 0x3fff) | (romqa << 14)] = data; + } + } +} + + +TIMER_CALLBACK_MEMBER(electron_elksdp1_device::spi_clock) +{ + if (m_spi_clock_cycles > 0) + { + m_sdcard->spi_ss_w(1); + + if (m_spi_clock_state) + { + m_in_latch <<= 1; + m_in_latch &= ~0x01; + m_in_latch |= m_in_bit; + + m_sdcard->spi_clock_w(1); + + m_spi_clock_cycles--; + } + else + { + m_sdcard->spi_mosi_w(BIT(m_out_latch, 7)); + m_sdcard->spi_clock_w(0); + + m_out_latch <<= 1; + } + + m_spi_clock_state = !m_spi_clock_state; + } + else + { + m_spi_clock_state = false; + m_spi_clock->adjust(attotime::never); + } +} diff --git a/src/devices/bus/electron/cart/elksdp1.h b/src/devices/bus/electron/cart/elksdp1.h new file mode 100644 index 00000000000..d0f606591ec --- /dev/null +++ b/src/devices/bus/electron/cart/elksdp1.h @@ -0,0 +1,59 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + ElkSD-Plus 1 Electron SD Cartridge + +**********************************************************************/ + +#ifndef MAME_BUS_ELECTRON_CART_ELKSDP1_H +#define MAME_BUS_ELECTRON_CART_ELKSDP1_H + +#include "slot.h" +#include "machine/spi_sdcard.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class electron_elksdp1_device : public device_t, public device_electron_cart_interface +{ +public: + // construction/destruction + electron_elksdp1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + + // optional information overrides + virtual void device_add_mconfig(machine_config &config) override; + + // electron_cart_interface overrides + virtual uint8_t read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) override; + virtual void write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) override; + +private: + required_device m_sdcard; + + TIMER_CALLBACK_MEMBER(spi_clock); + + emu_timer *m_spi_clock; + bool m_spi_clock_state; + bool m_spi_clock_sysclk; + int m_spi_clock_cycles; + int m_in_bit; + uint8_t m_in_latch; + uint8_t m_out_latch; + + std::unique_ptr m_ram; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(ELECTRON_ELKSDP1, electron_elksdp1_device) + + +#endif // MAME_BUS_ELECTRON_CART_ELKSDP1_H diff --git a/src/devices/bus/electron/cart/slot.cpp b/src/devices/bus/electron/cart/slot.cpp index 046fee21e2c..6502fb7d4ac 100644 --- a/src/devices/bus/electron/cart/slot.cpp +++ b/src/devices/bus/electron/cart/slot.cpp @@ -261,6 +261,7 @@ void electron_cartslot_device::write(offs_t offset, uint8_t data, int infc, int #include "aqr.h" #include "click.h" #include "cumana.h" +#include "elksdp1.h" #include "mgc.h" #include "peg400.h" //#include "pmse2p.h" @@ -283,6 +284,7 @@ void electron_cart(device_slot_interface &device) device.option_add_internal("aqr", ELECTRON_AQR); device.option_add_internal("click", ELECTRON_CLICK); device.option_add_internal("cumana", ELECTRON_CUMANA); + device.option_add_internal("elksdp1", ELECTRON_ELKSDP1); device.option_add_internal("mgc", ELECTRON_MGC); device.option_add_internal("peg400", ELECTRON_PEG400); //device.option_add_internal("pmse2p", ELECTRON_PMSE2P); -- cgit v1.2.3