diff --git a/hash/bbcm_cart.xml b/hash/bbcm_cart.xml
index e6905b6c6b8..65db485c34c 100644
--- a/hash/bbcm_cart.xml
+++ b/hash/bbcm_cart.xml
@@ -132,6 +132,18 @@ Acorn BBC Master ROM Cartridges
+
+ Master SD R2
+ 2020
+ Ramtop
+
+
+
+
+
+
+
+
Master Mega 256
1987
diff --git a/src/devices/bus/bbc/cart/mastersd.cpp b/src/devices/bus/bbc/cart/mastersd.cpp
index 1c1d21ede72..afeb9921785 100644
--- a/src/devices/bus/bbc/cart/mastersd.cpp
+++ b/src/devices/bus/bbc/cart/mastersd.cpp
@@ -18,6 +18,7 @@
//**************************************************************************
DEFINE_DEVICE_TYPE(BBC_MASTERSD, bbc_mastersd_device, "bbc_mastersd", "MasterSD BBC Master SD Cartridge")
+DEFINE_DEVICE_TYPE(BBC_MASTERSDR2, bbc_mastersdr2_device, "bbc_mastersdr2", "MasterSD R2 BBC Master SD Cartridge")
//-------------------------------------------------
@@ -38,8 +39,8 @@ void bbc_mastersd_device::device_add_mconfig(machine_config &config)
// 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)
+bbc_mastersd_device::bbc_mastersd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, type, tag, owner, clock)
, device_bbc_cart_interface(mconfig, *this)
, m_sdcard(*this, "sdcard")
, m_spi_clock_state(false)
@@ -48,6 +49,16 @@ bbc_mastersd_device::bbc_mastersd_device(const machine_config &mconfig, const ch
{
}
+bbc_mastersd_device::bbc_mastersd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : bbc_mastersd_device(mconfig, BBC_MASTERSD, tag, owner, clock)
+{
+}
+
+bbc_mastersdr2_device::bbc_mastersdr2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : bbc_mastersd_device(mconfig, BBC_MASTERSDR2, tag, owner, clock)
+{
+}
+
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@@ -110,6 +121,38 @@ uint8_t bbc_mastersd_device::read(offs_t offset, int infc, int infd, int romqa,
return data;
}
+uint8_t bbc_mastersdr2_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
//-------------------------------------------------
@@ -139,6 +182,36 @@ void bbc_mastersd_device::write(offs_t offset, uint8_t data, int infc, int infd,
}
}
+void bbc_mastersdr2_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(bbc_mastersd_device::spi_clock)
{
diff --git a/src/devices/bus/bbc/cart/mastersd.h b/src/devices/bus/bbc/cart/mastersd.h
index cd6d399176d..6ce6a2574d2 100644
--- a/src/devices/bus/bbc/cart/mastersd.h
+++ b/src/devices/bus/bbc/cart/mastersd.h
@@ -17,6 +17,8 @@
// TYPE DEFINITIONS
//**************************************************************************
+// ======================> bbc_mastersd_device
+
class bbc_mastersd_device : public device_t, public device_bbc_cart_interface
{
public:
@@ -24,6 +26,8 @@ public:
bbc_mastersd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
protected:
+ bbc_mastersd_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
@@ -35,7 +39,6 @@ protected:
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);
@@ -52,8 +55,25 @@ private:
};
+// ======================> bbc_mastersdr2_device
+
+class bbc_mastersdr2_device : public bbc_mastersd_device
+{
+public:
+ // construction/destruction
+ bbc_mastersdr2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+protected:
+ // 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;
+};
+
+
+
// device type definition
DECLARE_DEVICE_TYPE(BBC_MASTERSD, bbc_mastersd_device)
+DECLARE_DEVICE_TYPE(BBC_MASTERSDR2, bbc_mastersdr2_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 04e01ac04db..91ab2779842 100644
--- a/src/devices/bus/bbc/cart/slot.cpp
+++ b/src/devices/bus/bbc/cart/slot.cpp
@@ -75,6 +75,7 @@ void bbcm_cart(device_slot_interface &device)
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("mastersdr2", BBC_MASTERSDR2);
device.option_add_internal("mega256", BBC_MEGA256);
device.option_add_internal("mr8000", BBC_MR8000);
device.option_add_internal("msc", BBC_MSC);