diff options
Diffstat (limited to 'src/devices/bus/electron/cart')
32 files changed, 744 insertions, 202 deletions
diff --git a/src/devices/bus/electron/cart/abr.cpp b/src/devices/bus/electron/cart/abr.cpp index c894d5e9c71..1d2455e56c1 100644 --- a/src/devices/bus/electron/cart/abr.cpp +++ b/src/devices/bus/electron/cart/abr.cpp @@ -46,16 +46,13 @@ void electron_abr_device::device_start() // read - cartridge data read //------------------------------------------------- -uint8_t electron_abr_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_abr_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; - if (!infc && !infd) + if (oe) { - if (offset >= 0x0000 && offset < 0x4000) - { - data = m_nvram[(offset & 0x3fff) | (romqa << 14)]; - } + data = m_nvram[(offset & 0x3fff) | (romqa << 14)]; } return data; @@ -65,7 +62,7 @@ uint8_t electron_abr_device::read(address_space &space, offs_t offset, int infc, // write - cartridge data write //------------------------------------------------- -void electron_abr_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_abr_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { @@ -85,10 +82,9 @@ void electron_abr_device::write(address_space &space, offs_t offset, uint8_t dat break; } } - - if (!infc && !infd) + else if (oe) { - if (offset >= 0x0000 && offset < 0x4000 && !m_bank_locked[romqa]) + if (!m_bank_locked[romqa]) { m_nvram[(offset & 0x3fff) | (romqa << 14)] = data; } diff --git a/src/devices/bus/electron/cart/abr.h b/src/devices/bus/electron/cart/abr.h index b985db0a44d..3ef92c95a8d 100644 --- a/src/devices/bus/electron/cart/abr.h +++ b/src/devices/bus/electron/cart/abr.h @@ -32,8 +32,8 @@ protected: virtual void device_start() override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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: bool m_bank_locked[2]; diff --git a/src/devices/bus/electron/cart/ap34.cpp b/src/devices/bus/electron/cart/ap34.cpp index 30847c55aa4..694df390266 100644 --- a/src/devices/bus/electron/cart/ap34.cpp +++ b/src/devices/bus/electron/cart/ap34.cpp @@ -47,7 +47,7 @@ void ap34_floppies(device_slot_interface &device) void electron_ap34_device::device_add_mconfig(machine_config &config) { /* fdc */ - WD1770(config, m_fdc, 16_MHz_XTAL / 2); + WD1770(config, m_fdc, DERIVED_CLOCK(1, 2)); FLOPPY_CONNECTOR(config, m_floppy0, ap34_floppies, "525qd", electron_ap34_device::floppy_formats).enable_sound(true); FLOPPY_CONNECTOR(config, m_floppy1, ap34_floppies, nullptr, electron_ap34_device::floppy_formats).enable_sound(true); } @@ -81,9 +81,9 @@ void electron_ap34_device::device_start() // read - cartridge data read //------------------------------------------------- -uint8_t electron_ap34_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_ap34_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { - uint8_t data = 0xfe; + uint8_t data = 0xff; if (infc) { @@ -97,18 +97,16 @@ uint8_t electron_ap34_device::read(address_space &space, offs_t offset, int infc break; } } - - if (!infc && !infd) + else if (oe) { - if (offset >= 0x0000 && offset < 0x4000) - { - data = m_rom[(offset & 0x3fff) + (romqa * 0x4000)]; - } - if (m_ram.size() != 0 && romqa == 0 && offset >= 0x3000) { data = m_ram[offset & 0x0fff]; } + else + { + data = m_rom[(offset & 0x3fff) | (romqa << 14)]; + } } return data; @@ -118,14 +116,14 @@ uint8_t electron_ap34_device::read(address_space &space, offs_t offset, int infc // write - cartridge data write //------------------------------------------------- -void electron_ap34_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_ap34_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { switch (offset & 0xff) { case 0xc0: - wd1770_control_w(space, 0, data); + wd1770_control_w(data); break; case 0xc4: case 0xc5: @@ -135,8 +133,7 @@ void electron_ap34_device::write(address_space &space, offs_t offset, uint8_t da break; } } - - if (!infc && !infd) + else if (oe) { if (m_ram.size() != 0 && romqa == 0 && offset >= 0x3000) { @@ -150,7 +147,7 @@ void electron_ap34_device::write(address_space &space, offs_t offset, uint8_t da // IMPLEMENTATION //************************************************************************** -WRITE8_MEMBER(electron_ap34_device::wd1770_control_w) +void electron_ap34_device::wd1770_control_w(uint8_t data) { floppy_image_device *floppy = nullptr; @@ -167,6 +164,7 @@ WRITE8_MEMBER(electron_ap34_device::wd1770_control_w) m_fdc->dden_w(BIT(data, 3)); // bit 4: NMI - not connected + //m_slot->nmi_w(!BIT(data, 4)); // bit 5: reset if (!BIT(data, 5)) m_fdc->soft_reset(); diff --git a/src/devices/bus/electron/cart/ap34.h b/src/devices/bus/electron/cart/ap34.h index b3fb911b8f6..69b47514487 100644 --- a/src/devices/bus/electron/cart/ap34.h +++ b/src/devices/bus/electron/cart/ap34.h @@ -36,11 +36,11 @@ protected: virtual void device_add_mconfig(machine_config &config) override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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: - DECLARE_WRITE8_MEMBER(wd1770_control_w); + void wd1770_control_w(uint8_t data); DECLARE_FLOPPY_FORMATS(floppy_formats); required_device<wd1770_device> m_fdc; diff --git a/src/devices/bus/electron/cart/ap5.cpp b/src/devices/bus/electron/cart/ap5.cpp new file mode 100644 index 00000000000..660587c7642 --- /dev/null +++ b/src/devices/bus/electron/cart/ap5.cpp @@ -0,0 +1,171 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + ACP Advanced Plus 5 + +**********************************************************************/ + + +#include "emu.h" +#include "ap5.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(ELECTRON_AP5, electron_ap5_device, "electron_ap5", "P.R.E.S. Advanced Plus 5") + + +//------------------------------------------------- +// device_add_mconfig - add device configuration +//------------------------------------------------- + +void electron_ap5_device::device_add_mconfig(machine_config &config) +{ + /* rom sockets */ + GENERIC_SOCKET(config, m_romslot[0], generic_plain_slot, "electron_rom", "bin,rom"); // ROM SLOT 14 + m_romslot[0]->set_device_load(device_image_load_delegate(&electron_ap5_device::device_image_load_rom1_load, this)); + GENERIC_SOCKET(config, m_romslot[1], generic_plain_slot, "electron_rom", "bin,rom"); // ROM SLOT 15 + m_romslot[1]->set_device_load(device_image_load_delegate(&electron_ap5_device::device_image_load_rom2_load, this)); + + /* via */ + VIA6522(config, m_via, DERIVED_CLOCK(1, 16)); + m_via->readpb_handler().set(m_userport, FUNC(bbc_userport_slot_device::pb_r)); + m_via->writepb_handler().set(m_userport, FUNC(bbc_userport_slot_device::pb_w)); + m_via->irq_handler().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::irq_w)); + + /* user port */ + BBC_USERPORT_SLOT(config, m_userport, bbc_userport_devices, nullptr); + m_userport->cb1_handler().set(m_via, FUNC(via6522_device::write_cb1)); + m_userport->cb2_handler().set(m_via, FUNC(via6522_device::write_cb2)); + + /* 1mhz bus port */ + BBC_1MHZBUS_SLOT(config, m_1mhzbus, DERIVED_CLOCK(1, 16), bbc_1mhzbus_devices, nullptr); + m_1mhzbus->irq_handler().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::irq_w)); + m_1mhzbus->nmi_handler().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::nmi_w)); + + /* tube port */ + BBC_TUBE_SLOT(config, m_tube, electron_tube_devices, nullptr); + m_tube->irq_handler().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::irq_w)); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// electron_ap5_device - constructor +//------------------------------------------------- + +electron_ap5_device::electron_ap5_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ELECTRON_AP5, tag, owner, clock) + , device_electron_cart_interface(mconfig, *this) + , m_via(*this, "via6522") + , m_tube(*this, "tube") + , m_1mhzbus(*this, "1mhzbus") + , m_userport(*this, "userport") + , m_romslot(*this, "rom%u", 1) +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void electron_ap5_device::device_start() +{ +} + +//------------------------------------------------- +// read - cartridge data read +//------------------------------------------------- + +uint8_t electron_ap5_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) +{ + uint8_t data = 0xff; + + if (infc) + { + data = m_1mhzbus->fred_r(offset); + + switch (offset & 0xf0) + { + case 0xb0: + data &= m_via->read(offset & 0x0f); + break; + + case 0xe0: + data &= m_tube->host_r(offset & 0x0f); + break; + } + } + else if (infd) + { + data = m_1mhzbus->jim_r(offset); + } + else if (oe) + { + data = m_romslot[romqa]->read_rom(offset & 0x3fff); + } + else if (oe2) + { + data = m_rom[offset & 0x1fff]; + } + + return data; +} + +//------------------------------------------------- +// write - cartridge data write +//------------------------------------------------- + +void electron_ap5_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) +{ + if (infc) + { + m_1mhzbus->fred_w(offset, data); + + switch (offset & 0xf0) + { + case 0xb0: + m_via->write(offset & 0x0f, data); + break; + + case 0xe0: + m_tube->host_w(offset & 0x0f, data); + break; + } + } + else if (infd) + { + m_1mhzbus->jim_w(offset, data); + } +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +image_init_result electron_ap5_device::load_rom(device_image_interface &image, generic_slot_device *slot) +{ + uint32_t size = slot->common_get_size("rom"); + + // socket accepts 8K and 16K ROM only + if (size != 0x2000 && size != 0x4000) + { + image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid size: Only 8K/16K is supported"); + return image_init_result::FAIL; + } + + slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + slot->common_load_rom(slot->get_rom_base(), size, "rom"); + + // mirror 8K ROMs + uint8_t *crt = slot->get_rom_base(); + if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); + + return image_init_result::PASS; +} diff --git a/src/devices/bus/electron/cart/ap5.h b/src/devices/bus/electron/cart/ap5.h new file mode 100644 index 00000000000..846f3fbc649 --- /dev/null +++ b/src/devices/bus/electron/cart/ap5.h @@ -0,0 +1,60 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + ACP Advanced Plus 5 + +**********************************************************************/ + +#ifndef MAME_BUS_ELECTRON_CART_AP5_H +#define MAME_BUS_ELECTRON_CART_AP5_H + +#include "slot.h" +#include "machine/6522via.h" +#include "bus/bbc/1mhzbus/1mhzbus.h" +#include "bus/bbc/tube/tube.h" +#include "bus/bbc/userport/userport.h" +#include "bus/generic/slot.h" +#include "bus/generic/carts.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class electron_ap5_device : + public device_t, + public device_electron_cart_interface +{ +public: + // construction/destruction + electron_ap5_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + // device-level overrides + virtual void device_start() 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: + image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1_load) { return load_rom(image, m_romslot[0]); } + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2_load) { return load_rom(image, m_romslot[1]); } + + required_device<via6522_device> m_via; + required_device<bbc_tube_slot_device> m_tube; + required_device<bbc_1mhzbus_slot_device> m_1mhzbus; + required_device<bbc_userport_slot_device> m_userport; + required_device_array<generic_slot_device, 2> m_romslot; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(ELECTRON_AP5, electron_ap5_device) + + +#endif // MAME_BUS_ELECTRON_CART_AP5_H diff --git a/src/devices/bus/electron/cart/aqr.cpp b/src/devices/bus/electron/cart/aqr.cpp index 8a3edebd194..8be0176efc4 100644 --- a/src/devices/bus/electron/cart/aqr.cpp +++ b/src/devices/bus/electron/cart/aqr.cpp @@ -48,16 +48,13 @@ void electron_aqr_device::device_start() // read - cartridge data read //------------------------------------------------- -uint8_t electron_aqr_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_aqr_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; - if (!infc && !infd) + if (oe) { - if (offset >= 0x0000 && offset < 0x4000) - { - data = m_ram[(offset & 0x3fff) | (m_page_register << 14)]; - } + data = m_ram[(offset & 0x3fff) | (m_page_register << 14)]; } return data; @@ -67,7 +64,7 @@ uint8_t electron_aqr_device::read(address_space &space, offs_t offset, int infc, // write - cartridge data write //------------------------------------------------- -void electron_aqr_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_aqr_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { @@ -84,12 +81,8 @@ void electron_aqr_device::write(address_space &space, offs_t offset, uint8_t dat break; } } - - if (!infc && !infd) + else if (oe) { - if (offset >= 0x0000 && offset < 0x4000 && !m_lock_register) - { - m_ram[(offset & 0x3fff) | (m_page_register << 14)] = data; - } + m_ram[(offset & 0x3fff) | (m_page_register << 14)] = data; } } diff --git a/src/devices/bus/electron/cart/aqr.h b/src/devices/bus/electron/cart/aqr.h index 6ede0b8144d..820f967b5cf 100644 --- a/src/devices/bus/electron/cart/aqr.h +++ b/src/devices/bus/electron/cart/aqr.h @@ -32,8 +32,8 @@ protected: virtual void device_start() override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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: uint8_t m_page_register; diff --git a/src/devices/bus/electron/cart/click.cpp b/src/devices/bus/electron/cart/click.cpp index a4a0bfd5af2..bdeebeba79b 100644 --- a/src/devices/bus/electron/cart/click.cpp +++ b/src/devices/bus/electron/cart/click.cpp @@ -27,7 +27,7 @@ void electron_click_device::device_add_mconfig(machine_config &config) { /* rtc */ MC146818(config, m_rtc, 32.768_kHz_XTAL); - m_rtc->irq().set(FUNC(electron_click_device::irq_w)); + m_rtc->irq().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::irq_w)); } //------------------------------------------------- @@ -88,7 +88,7 @@ void electron_click_device::device_reset() // read - cartridge data read //------------------------------------------------- -uint8_t electron_click_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_click_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; @@ -98,15 +98,14 @@ uint8_t electron_click_device::read(address_space &space, offs_t offset, int inf { case 0xf8: case 0xf9: - data = m_rtc->read(space, offset & 0x01); + data = m_rtc->read(offset & 0x01); break; case 0xfc: data = m_page_register; break; } } - - if (!infc && !infd) + else if (oe) { offs_t rom_page_offset = (m_page_register & 0x03) * 0x2000; offs_t ram_page_offset = ((m_page_register & 0x0c) >> 2) * 0x2000; @@ -128,7 +127,7 @@ uint8_t electron_click_device::read(address_space &space, offs_t offset, int inf // write - cartridge data write //------------------------------------------------- -void electron_click_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_click_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { @@ -136,15 +135,14 @@ void electron_click_device::write(address_space &space, offs_t offset, uint8_t d { case 0xf8: case 0xf9: - m_rtc->write(space, offset & 0x01, data); + m_rtc->write(offset & 0x01, data); break; case 0xfc: m_page_register = data; break; } } - - if (!infc && !infd) + else if (oe) { offs_t ram_page_offset = ((m_page_register & 0x0c) >> 2) * 0x2000; @@ -166,8 +164,3 @@ INPUT_CHANGED_MEMBER(electron_click_device::click_button) m_slot->irq_w(CLEAR_LINE); } } - -WRITE_LINE_MEMBER(electron_click_device::irq_w) -{ - m_slot->irq_w(state); -} diff --git a/src/devices/bus/electron/cart/click.h b/src/devices/bus/electron/cart/click.h index 5fbc18d4759..cb7dd114687 100644 --- a/src/devices/bus/electron/cart/click.h +++ b/src/devices/bus/electron/cart/click.h @@ -41,12 +41,10 @@ protected: virtual void device_reset() override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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: - DECLARE_WRITE_LINE_MEMBER(irq_w); - required_device<mc146818_device> m_rtc; uint8_t m_page_register; diff --git a/src/devices/bus/electron/cart/cumana.cpp b/src/devices/bus/electron/cart/cumana.cpp index 80ebeab394b..8792395b503 100644 --- a/src/devices/bus/electron/cart/cumana.cpp +++ b/src/devices/bus/electron/cart/cumana.cpp @@ -48,12 +48,13 @@ void cumana_floppies(device_slot_interface &device) void electron_cumana_device::device_add_mconfig(machine_config &config) { /* fdc */ - FD1793(config, m_fdc, 16_MHz_XTAL / 16); // TODO: Not known whether DRQ and INTRQ are connected + FD1793(config, m_fdc, DERIVED_CLOCK(1, 16)); // TODO: Not known whether DRQ and INTRQ are connected FLOPPY_CONNECTOR(config, m_floppy0, cumana_floppies, "525qd", electron_cumana_device::floppy_formats).enable_sound(true); FLOPPY_CONNECTOR(config, m_floppy1, cumana_floppies, nullptr, electron_cumana_device::floppy_formats).enable_sound(true); /* rtc */ MC146818(config, m_rtc, 32.768_kHz_XTAL); + m_rtc->irq().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::irq_w)); } //************************************************************************** @@ -86,7 +87,7 @@ void electron_cumana_device::device_start() // read - cartridge data read //------------------------------------------------- -uint8_t electron_cumana_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_cumana_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; @@ -102,12 +103,11 @@ uint8_t electron_cumana_device::read(address_space &space, offs_t offset, int in break; case 0x98: case 0x9c: - data = m_rtc->read(space, BIT(offset, 2)); + data = m_rtc->read(BIT(offset, 2)); break; } } - - if (!infc && !infd) + else if (oe) { switch (romqa) { @@ -134,7 +134,7 @@ uint8_t electron_cumana_device::read(address_space &space, offs_t offset, int in // write - cartridge data write //------------------------------------------------- -void electron_cumana_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_cumana_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { @@ -147,17 +147,15 @@ void electron_cumana_device::write(address_space &space, offs_t offset, uint8_t m_fdc->write(offset & 0x03, data); break; case 0x94: - wd1793_control_w(space, 0, data); + wd1793_control_w(data); break; case 0x98: case 0x9c: - m_rtc->write(space, BIT(offset, 2), data); - break; + m_rtc->write(BIT(offset, 2), data); break; } } - - if (!infc && !infd) + else if (oe) { if (romqa == 0 && offset >= 0x3800) { @@ -171,7 +169,7 @@ void electron_cumana_device::write(address_space &space, offs_t offset, uint8_t // IMPLEMENTATION //************************************************************************** -WRITE8_MEMBER(electron_cumana_device::wd1793_control_w) +void electron_cumana_device::wd1793_control_w(uint8_t data) { floppy_image_device *floppy = nullptr; diff --git a/src/devices/bus/electron/cart/cumana.h b/src/devices/bus/electron/cart/cumana.h index 9092f82bd65..9a3bc2ab834 100644 --- a/src/devices/bus/electron/cart/cumana.h +++ b/src/devices/bus/electron/cart/cumana.h @@ -37,11 +37,11 @@ protected: virtual void device_add_mconfig(machine_config &config) override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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: - DECLARE_WRITE8_MEMBER(wd1793_control_w); + void wd1793_control_w(uint8_t data); DECLARE_FLOPPY_FORMATS(floppy_formats); required_device<fd1793_device> m_fdc; diff --git a/src/devices/bus/electron/cart/mgc.cpp b/src/devices/bus/electron/cart/mgc.cpp index 41cc29dfbfb..5f80559c47a 100644 --- a/src/devices/bus/electron/cart/mgc.cpp +++ b/src/devices/bus/electron/cart/mgc.cpp @@ -65,17 +65,14 @@ void electron_mgc_device::device_reset() // read - cartridge data read //------------------------------------------------- -uint8_t electron_mgc_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_mgc_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; - if (!infc && !infd) + if (oe) { - if (offset >= 0x0000 && offset < 0x4000) - { - int m_page_mode = BIT(m_control_latch, 2) ? BIT(m_control_latch, 1) : !romqa; - data = m_nvram[(offset & 0x3fff) | (m_page_latch << 14) | (m_page_mode << 21)]; - } + int m_page_mode = BIT(m_control_latch, 2) ? BIT(m_control_latch, 1) : !romqa; + data = m_nvram[(offset & 0x3fff) | (m_page_latch << 14) | (m_page_mode << 21)]; } return data; @@ -85,7 +82,7 @@ uint8_t electron_mgc_device::read(address_space &space, offs_t offset, int infc, // write - cartridge data write //------------------------------------------------- -void electron_mgc_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_mgc_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { @@ -100,13 +97,9 @@ void electron_mgc_device::write(address_space &space, offs_t offset, uint8_t dat break; } } - - if (!infc && !infd) + else if (oe) { - if (offset >= 0x0000 && offset < 0x4000 && BIT(m_control_latch, 0)) - { - int m_page_mode = BIT(m_control_latch, 2) ? BIT(m_control_latch, 1) : !romqa; - m_nvram[(offset & 0x3fff) | (m_page_latch << 14) | (m_page_mode << 21)] = data; - } + int m_page_mode = BIT(m_control_latch, 2) ? BIT(m_control_latch, 1) : !romqa; + m_nvram[(offset & 0x3fff) | (m_page_latch << 14) | (m_page_mode << 21)] = data; } } diff --git a/src/devices/bus/electron/cart/mgc.h b/src/devices/bus/electron/cart/mgc.h index 8835a703107..bf23aa34391 100644 --- a/src/devices/bus/electron/cart/mgc.h +++ b/src/devices/bus/electron/cart/mgc.h @@ -33,8 +33,8 @@ protected: virtual void device_reset() override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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: uint8_t m_page_latch; diff --git a/src/devices/bus/electron/cart/peg400.cpp b/src/devices/bus/electron/cart/peg400.cpp index 8d92131aa04..abca703474a 100644 --- a/src/devices/bus/electron/cart/peg400.cpp +++ b/src/devices/bus/electron/cart/peg400.cpp @@ -44,7 +44,7 @@ void peg400_floppies(device_slot_interface &device) void electron_peg400_device::device_add_mconfig(machine_config &config) { /* fdc */ - WD1770(config, m_fdc, 16_MHz_XTAL / 2); + WD1770(config, m_fdc, DERIVED_CLOCK(1, 2)); m_fdc->drq_wr_callback().set(FUNC(electron_peg400_device::fdc_drq_w)); FLOPPY_CONNECTOR(config, m_floppy0, peg400_floppies, "525qd", electron_peg400_device::floppy_formats).enable_sound(true); FLOPPY_CONNECTOR(config, m_floppy1, peg400_floppies, nullptr, electron_peg400_device::floppy_formats).enable_sound(true); @@ -79,7 +79,7 @@ void electron_peg400_device::device_start() // read - cartridge data read //------------------------------------------------- -uint8_t electron_peg400_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_peg400_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; @@ -95,15 +95,14 @@ uint8_t electron_peg400_device::read(address_space &space, offs_t offset, int in break; } } - - if (!infc && !infd) + else if (oe) { switch (romqa) { case 0: if (offset < 0x3800) { - data = m_rom[(offset & 0x3fff) + (romqa * 0x4000)]; + data = m_rom[(offset & 0x3fff) | (romqa << 14)]; } else { @@ -111,7 +110,7 @@ uint8_t electron_peg400_device::read(address_space &space, offs_t offset, int in } break; case 1: - data = m_rom[(offset & 0x3fff) + (romqa * 0x4000)]; + data = m_rom[(offset & 0x3fff) | (romqa << 14)]; break; } } @@ -123,14 +122,14 @@ uint8_t electron_peg400_device::read(address_space &space, offs_t offset, int in // write - cartridge data write //------------------------------------------------- -void electron_peg400_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_peg400_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { switch (offset & 0xff) { case 0xc0: - wd1770_control_w(space, 0, data); + wd1770_control_w(data); break; case 0xc4: case 0xc5: @@ -140,8 +139,7 @@ void electron_peg400_device::write(address_space &space, offs_t offset, uint8_t break; } } - - if (!infc && !infd) + else if (oe) { if (romqa == 0 && offset >= 0x3800) { @@ -155,7 +153,7 @@ void electron_peg400_device::write(address_space &space, offs_t offset, uint8_t // IMPLEMENTATION //************************************************************************** -WRITE8_MEMBER(electron_peg400_device::wd1770_control_w) +void electron_peg400_device::wd1770_control_w(uint8_t data) { floppy_image_device *floppy = nullptr; diff --git a/src/devices/bus/electron/cart/peg400.h b/src/devices/bus/electron/cart/peg400.h index 8b7a7af9b44..035947a1e59 100644 --- a/src/devices/bus/electron/cart/peg400.h +++ b/src/devices/bus/electron/cart/peg400.h @@ -34,11 +34,11 @@ protected: virtual void device_add_mconfig(machine_config &config) override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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: - DECLARE_WRITE8_MEMBER(wd1770_control_w); + void wd1770_control_w(uint8_t data); DECLARE_FLOPPY_FORMATS(floppy_formats); DECLARE_WRITE_LINE_MEMBER(fdc_drq_w); diff --git a/src/devices/bus/electron/cart/romp144.cpp b/src/devices/bus/electron/cart/romp144.cpp new file mode 100644 index 00000000000..6e4eb96bd84 --- /dev/null +++ b/src/devices/bus/electron/cart/romp144.cpp @@ -0,0 +1,162 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + JAFA Systems ROMPlus-144 + +**********************************************************************/ + + +#include "emu.h" +#include "romp144.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(ELECTRON_ROMP144, electron_romp144_device, "electron_romp144", "JAFA Systems ROMPlus-144") + + +//------------------------------------------------- +// device_add_mconfig - add device configuration +//------------------------------------------------- + +void electron_romp144_device::device_add_mconfig(machine_config &config) +{ + /* rom sockets */ + GENERIC_SOCKET(config, m_romslot[0], generic_plain_slot, "electron_rom", "bin,rom"); + m_romslot[0]->set_device_load(device_image_load_delegate(&electron_romp144_device::device_image_load_rom0, this)); + GENERIC_SOCKET(config, m_romslot[1], generic_plain_slot, "electron_rom", "bin,rom"); + m_romslot[1]->set_device_load(device_image_load_delegate(&electron_romp144_device::device_image_load_rom1, this)); + GENERIC_SOCKET(config, m_romslot[2], generic_plain_slot, "electron_rom", "bin,rom"); + m_romslot[2]->set_device_load(device_image_load_delegate(&electron_romp144_device::device_image_load_rom2, this)); + GENERIC_SOCKET(config, m_romslot[3], generic_plain_slot, "electron_rom", "bin,rom"); + m_romslot[3]->set_device_load(device_image_load_delegate(&electron_romp144_device::device_image_load_rom3, this)); + GENERIC_SOCKET(config, m_romslot[4], generic_plain_slot, "electron_rom", "bin,rom"); + m_romslot[4]->set_device_load(device_image_load_delegate(&electron_romp144_device::device_image_load_rom4, this)); + GENERIC_SOCKET(config, m_romslot[5], generic_plain_slot, "electron_rom", "bin,rom"); + m_romslot[5]->set_device_load(device_image_load_delegate(&electron_romp144_device::device_image_load_rom5, this)); + GENERIC_SOCKET(config, m_romslot[6], generic_plain_slot, "electron_rom", "bin,rom"); + m_romslot[6]->set_device_load(device_image_load_delegate(&electron_romp144_device::device_image_load_rom6, this)); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// electron_romp144_device - constructor +//------------------------------------------------- + +electron_romp144_device::electron_romp144_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ELECTRON_ROMP144, tag, owner, clock) + , device_electron_cart_interface(mconfig, *this) + , m_romslot(*this, "rom%u", 7) +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void electron_romp144_device::device_start() +{ + m_rom_select = 0xff; + m_rom_latch = 0xff; + + save_item(NAME(m_rom_select)); + save_item(NAME(m_rom_latch)); +} + +//------------------------------------------------- +// read - cartridge data read +//------------------------------------------------- + +uint8_t electron_romp144_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) +{ + uint8_t data = 0xff; + + if (oe) + { + if (romqa) + { + if ((m_rom_select & 0x07) == 0x00) + data = m_ram[offset & 0x3fff]; + else + data = m_romslot[(m_rom_select & 0x07) - 1]->read_rom(offset & 0x3fff); + } + else + { + if ((m_rom_select & 0x0f) == 0x08) + data = m_ram[(offset & 0x3fff) | 0x4000]; + else + data = m_rom[offset & 0x1fff]; + + /* roms selected with a read to latch */ + if ((offset & 0x3f00) == 0x3f00) + { + m_rom_latch = offset & 0x0f; + } + } + } + + return data; +} + +//------------------------------------------------- +// write - cartridge data write +//------------------------------------------------- + +void electron_romp144_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) +{ + if (oe) + { + if (romqa) + { + if ((m_rom_select & 0x07) == 0x00) + m_ram[offset & 0x3fff] = data; + } + else + { + if ((m_rom_select & 0x0f) == 0x08) + m_ram[(offset & 0x3fff) | 0x4000] = data; + + /* roms selected with a write to select */ + if ((offset & 0x3f00) == 0x3f00) + { + /* does the write match the read (upper RAM cannot be de-selected to protect *RSUBSTITUTE) */ + if (m_rom_latch == (offset & 0x0f) && m_rom_select != 0x08) + { + m_rom_select = m_rom_latch; + } + } + } + } +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +image_init_result electron_romp144_device::load_rom(device_image_interface &image, generic_slot_device *slot) +{ + uint32_t size = slot->common_get_size("rom"); + + // socket accepts 8K and 16K ROM only + if (size != 0x2000 && size != 0x4000) + { + image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid size: Only 8K/16K is supported"); + return image_init_result::FAIL; + } + + slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + slot->common_load_rom(slot->get_rom_base(), size, "rom"); + + // mirror 8K ROMs + uint8_t *crt = slot->get_rom_base(); + if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); + + return image_init_result::PASS; +} diff --git a/src/devices/bus/electron/cart/romp144.h b/src/devices/bus/electron/cart/romp144.h new file mode 100644 index 00000000000..45916a3ab38 --- /dev/null +++ b/src/devices/bus/electron/cart/romp144.h @@ -0,0 +1,60 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + JAFA Systems ROMPlus-144 + +**********************************************************************/ + +#ifndef MAME_BUS_ELECTRON_CART_ROMP144_H +#define MAME_BUS_ELECTRON_CART_ROMP144_H + +#include "slot.h" +#include "bus/generic/slot.h" +#include "bus/generic/carts.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class electron_romp144_device : + public device_t, + public device_electron_cart_interface +{ +public: + // construction/destruction + electron_romp144_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + // device-level overrides + virtual void device_start() 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: + image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom0) { return load_rom(image, m_romslot[0]); } + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1) { return load_rom(image, m_romslot[1]); } + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2) { return load_rom(image, m_romslot[2]); } + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom3) { return load_rom(image, m_romslot[3]); } + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom4) { return load_rom(image, m_romslot[4]); } + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom5) { return load_rom(image, m_romslot[5]); } + DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom6) { return load_rom(image, m_romslot[6]); } + + required_device_array<generic_slot_device, 7> m_romslot; + + uint8_t m_rom_select; + uint8_t m_rom_latch; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(ELECTRON_ROMP144, electron_romp144_device) + + +#endif // MAME_BUS_ELECTRON_CART_ROMP144_H diff --git a/src/devices/bus/electron/cart/slot.cpp b/src/devices/bus/electron/cart/slot.cpp index aae2f65594d..f8682b9c654 100644 --- a/src/devices/bus/electron/cart/slot.cpp +++ b/src/devices/bus/electron/cart/slot.cpp @@ -100,14 +100,6 @@ electron_cartslot_device::electron_cartslot_device(const machine_config &mconfig } //------------------------------------------------- -// electron_cartslot_device - destructor -//------------------------------------------------- - -electron_cartslot_device::~electron_cartslot_device() -{ -} - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -237,13 +229,13 @@ std::string electron_cartslot_device::get_default_card_software(get_default_card // read - cartridge read //------------------------------------------------- -uint8_t electron_cartslot_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_cartslot_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; if (m_cart != nullptr) { - data = m_cart->read(space, offset, infc, infd, romqa); + data = m_cart->read(offset, infc, infd, romqa, oe, oe2); } return data; @@ -253,11 +245,11 @@ uint8_t electron_cartslot_device::read(address_space &space, offs_t offset, int // write - cartridge write //------------------------------------------------- -void electron_cartslot_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_cartslot_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (m_cart != nullptr) { - m_cart->write(space, offset, data, infc, infd, romqa); + m_cart->write(offset, data, infc, infd, romqa, oe, oe2); } } @@ -268,15 +260,20 @@ void electron_cartslot_device::write(address_space &space, offs_t offset, uint8_ #include "abr.h" #include "ap34.h" +#include "ap5.h" #include "aqr.h" #include "click.h" #include "cumana.h" #include "mgc.h" #include "peg400.h" +//#include "pmse2p.h" +#include "romp144.h" +//#include "rs423.h" #include "sndexp.h" #include "sndexp3.h" #include "sp64.h" #include "stlefs.h" +#include "tube.h" #include "std.h" @@ -285,13 +282,18 @@ void electron_cart(device_slot_interface &device) device.option_add_internal("std", ELECTRON_STDCART); device.option_add_internal("abr", ELECTRON_ABR); device.option_add_internal("ap34", ELECTRON_AP34); + device.option_add_internal("ap5", ELECTRON_AP5); 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("mgc", ELECTRON_MGC); device.option_add_internal("peg400", ELECTRON_PEG400); + //device.option_add_internal("pmse2p", ELECTRON_PMSE2P); + device.option_add_internal("romp144", ELECTRON_ROMP144); + //device.option_add_internal("rs423", ELECTRON_RS423); device.option_add_internal("sndexp", ELECTRON_SNDEXP); device.option_add_internal("sndexp3", ELECTRON_SNDEXP3); device.option_add_internal("sp64", ELECTRON_SP64); device.option_add_internal("stlefs", ELECTRON_STLEFS); + device.option_add_internal("tube", ELECTRON_TUBE); } diff --git a/src/devices/bus/electron/cart/slot.h b/src/devices/bus/electron/cart/slot.h index 9e4b66182f1..d31bc16258c 100644 --- a/src/devices/bus/electron/cart/slot.h +++ b/src/devices/bus/electron/cart/slot.h @@ -105,16 +105,6 @@ #define ELECTRON_CART_ROM_REGION_TAG ":cart:rom" -#define MCFG_ELECTRON_CARTSLOT_ADD(_tag, _slot_intf, _def_slot) \ - MCFG_DEVICE_ADD(_tag, ELECTRON_CARTSLOT, 0) \ - MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) - -#define MCFG_ELECTRON_CARTSLOT_IRQ_HANDLER(_devcb) \ - downcast<electron_cartslot_device &>(*device).set_irq_handler(DEVCB_##_devcb); - -#define MCFG_ELECTRON_CARTSLOT_NMI_HANDLER(_devcb) \ - downcast<electron_cartslot_device &>(*device).set_nmi_handler(DEVCB_##_devcb); - //************************************************************************** // TYPE DEFINITIONS @@ -130,12 +120,21 @@ class electron_cartslot_device : public device_t, { public: // construction/destruction + template <typename T> + electron_cartslot_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock, T &&slot_options, const char *default_option) + : electron_cartslot_device(mconfig, tag, owner, clock) + { + option_reset(); + slot_options(*this); + set_default_option(default_option); + set_fixed(false); + } + electron_cartslot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual ~electron_cartslot_device(); // callbacks - template <class Object> devcb_base &set_irq_handler(Object &&cb) { return m_irq_handler.set_callback(std::forward<Object>(cb)); } - template <class Object> devcb_base &set_nmi_handler(Object &&cb) { return m_nmi_handler.set_callback(std::forward<Object>(cb)); } + auto irq_handler() { return m_irq_handler.bind(); } + auto nmi_handler() { return m_nmi_handler.bind(); } // device-level overrides virtual void device_start() override; @@ -159,8 +158,8 @@ public: virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override; // reading and writing - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa); - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa); + virtual uint8_t read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2); + virtual void write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2); DECLARE_WRITE_LINE_MEMBER(irq_w) { m_irq_handler(state); } DECLARE_WRITE_LINE_MEMBER(nmi_w) { m_nmi_handler(state); } @@ -183,8 +182,8 @@ public: virtual ~device_electron_cart_interface(); // reading and writing - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) { return 0xff; } - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) { } + virtual uint8_t read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { return 0xff; } + virtual void write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { } void rom_alloc(uint32_t size, const char *tag); void ram_alloc(uint32_t size); diff --git a/src/devices/bus/electron/cart/sndexp.cpp b/src/devices/bus/electron/cart/sndexp.cpp index de0c7704020..4ba27cb4825 100644 --- a/src/devices/bus/electron/cart/sndexp.cpp +++ b/src/devices/bus/electron/cart/sndexp.cpp @@ -27,11 +27,13 @@ DEFINE_DEVICE_TYPE(ELECTRON_SNDEXP, electron_sndexp_device, "electron_sndexp", " // device_add_mconfig - add device configuration //------------------------------------------------- -MACHINE_CONFIG_START(electron_sndexp_device::device_add_mconfig) +void electron_sndexp_device::device_add_mconfig(machine_config &config) +{ + /* sound hardware */ SPEAKER(config, "mono").front_center(); - MCFG_DEVICE_ADD("sn76489", SN76489, 16_MHz_XTAL / 4) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) -MACHINE_CONFIG_END + SN76489(config, m_sn, DERIVED_CLOCK(1, 4)); + m_sn->add_route(ALL_OUTPUTS, "mono", 1.0); +} //------------------------------------------------- // INPUT_PORTS( sndexp ) @@ -87,11 +89,11 @@ void electron_sndexp_device::device_start() // read - cartridge data read //------------------------------------------------- -uint8_t electron_sndexp_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_sndexp_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; - if (!infc && !infd) + if (oe) { if (m_jumper->read()) { @@ -124,7 +126,7 @@ uint8_t electron_sndexp_device::read(address_space &space, offs_t offset, int in // write - cartridge data write //------------------------------------------------- -void electron_sndexp_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_sndexp_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { @@ -142,8 +144,7 @@ void electron_sndexp_device::write(address_space &space, offs_t offset, uint8_t break; } } - - if (!infc && !infd) + else if (oe) { if (m_jumper->read()) { diff --git a/src/devices/bus/electron/cart/sndexp.h b/src/devices/bus/electron/cart/sndexp.h index 87d94ba84a2..5627c2ff734 100644 --- a/src/devices/bus/electron/cart/sndexp.h +++ b/src/devices/bus/electron/cart/sndexp.h @@ -33,8 +33,8 @@ protected: virtual ioport_constructor device_input_ports() const override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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<sn76489_device> m_sn; diff --git a/src/devices/bus/electron/cart/sndexp3.cpp b/src/devices/bus/electron/cart/sndexp3.cpp index 1bf32aa2fb4..afaf927e443 100644 --- a/src/devices/bus/electron/cart/sndexp3.cpp +++ b/src/devices/bus/electron/cart/sndexp3.cpp @@ -23,12 +23,13 @@ DEFINE_DEVICE_TYPE(ELECTRON_SNDEXP3, electron_sndexp3_device, "electron_sndexp3" // device_add_mconfig - add device configuration //------------------------------------------------- -MACHINE_CONFIG_START(electron_sndexp3_device::device_add_mconfig) +void electron_sndexp3_device::device_add_mconfig(machine_config &config) +{ /* sound hardware */ SPEAKER(config, "mono").front_center(); - MCFG_DEVICE_ADD("sn76489", SN76489, 16_MHz_XTAL / 4) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) -MACHINE_CONFIG_END + SN76489(config, m_sn, DERIVED_CLOCK(1, 4)); + m_sn->add_route(ALL_OUTPUTS, "mono", 1.0); +} //************************************************************************** // LIVE DEVICE @@ -61,11 +62,11 @@ void electron_sndexp3_device::device_start() // read - cartridge data read //------------------------------------------------- -uint8_t electron_sndexp3_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_sndexp3_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; - if (!infc && !infd && romqa) + if (oe && romqa) { if (offset < 0x2000) { @@ -84,7 +85,7 @@ uint8_t electron_sndexp3_device::read(address_space &space, offs_t offset, int i // write - cartridge data write //------------------------------------------------- -void electron_sndexp3_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_sndexp3_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { @@ -102,8 +103,7 @@ void electron_sndexp3_device::write(address_space &space, offs_t offset, uint8_t break; } } - - if (!infc && !infd && romqa) + else if (oe && romqa) { if (offset >= 0x2000) { diff --git a/src/devices/bus/electron/cart/sndexp3.h b/src/devices/bus/electron/cart/sndexp3.h index 2ad0869ca65..95d437b63e2 100644 --- a/src/devices/bus/electron/cart/sndexp3.h +++ b/src/devices/bus/electron/cart/sndexp3.h @@ -32,8 +32,8 @@ protected: virtual void device_add_mconfig(machine_config &config) override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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<sn76489_device> m_sn; diff --git a/src/devices/bus/electron/cart/sp64.cpp b/src/devices/bus/electron/cart/sp64.cpp index 11db24fbba6..9b5d497999e 100644 --- a/src/devices/bus/electron/cart/sp64.cpp +++ b/src/devices/bus/electron/cart/sp64.cpp @@ -55,7 +55,7 @@ void electron_sp64_device::device_reset() // read - cartridge data read //------------------------------------------------- -uint8_t electron_sp64_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_sp64_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; @@ -68,15 +68,14 @@ uint8_t electron_sp64_device::read(address_space &space, offs_t offset, int infc break; } } - - if (!infc && !infd) + else if (oe) { - offs_t rom_page_offset = m_page_register * 0x4000; + offs_t rom_page_offset = m_page_register << 14; switch (romqa) { case 0: - data = m_rom[rom_page_offset + (offset & 0x3fff)]; + data = m_rom[rom_page_offset | (offset & 0x3fff)]; break; case 1: data = m_ram[offset & 0x1fff]; @@ -91,7 +90,7 @@ uint8_t electron_sp64_device::read(address_space &space, offs_t offset, int infc // write - cartridge data write //------------------------------------------------- -void electron_sp64_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_sp64_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { @@ -102,8 +101,7 @@ void electron_sp64_device::write(address_space &space, offs_t offset, uint8_t da break; } } - - if (!infc && !infd) + else if (oe) { if (romqa == 1) { diff --git a/src/devices/bus/electron/cart/sp64.h b/src/devices/bus/electron/cart/sp64.h index 7e5de9f18f6..68954fc9d30 100644 --- a/src/devices/bus/electron/cart/sp64.h +++ b/src/devices/bus/electron/cart/sp64.h @@ -33,8 +33,8 @@ protected: virtual void device_reset() override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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: uint8_t m_page_register; diff --git a/src/devices/bus/electron/cart/std.cpp b/src/devices/bus/electron/cart/std.cpp index b66e3b2ce0d..f2b7333f347 100644 --- a/src/devices/bus/electron/cart/std.cpp +++ b/src/devices/bus/electron/cart/std.cpp @@ -43,13 +43,13 @@ void electron_stdcart_device::device_start() // read - cartridge data read //------------------------------------------------- -uint8_t electron_stdcart_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_stdcart_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; - if (!infc && !infd) + if (oe) { - data = m_rom[(offset & 0x3fff) + (romqa * 0x4000)]; + data = m_rom[(offset & 0x3fff) | (romqa << 14)]; } return data; diff --git a/src/devices/bus/electron/cart/std.h b/src/devices/bus/electron/cart/std.h index e81e5684ee2..3fc9cefbcd9 100644 --- a/src/devices/bus/electron/cart/std.h +++ b/src/devices/bus/electron/cart/std.h @@ -31,7 +31,7 @@ protected: virtual void device_start() override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; + virtual uint8_t read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) override; }; // device type definition diff --git a/src/devices/bus/electron/cart/stlefs.cpp b/src/devices/bus/electron/cart/stlefs.cpp index 83dbf998f2a..47566871a9d 100644 --- a/src/devices/bus/electron/cart/stlefs.cpp +++ b/src/devices/bus/electron/cart/stlefs.cpp @@ -47,9 +47,9 @@ void stlefs_floppies(device_slot_interface &device) void electron_stlefs_device::device_add_mconfig(machine_config &config) { /* fdc */ - WD1770(config, m_fdc, 16_MHz_XTAL / 2); - m_fdc->intrq_wr_callback().set(FUNC(electron_stlefs_device::fdc_intrq_w)); - m_fdc->drq_wr_callback().set(FUNC(electron_stlefs_device::fdc_drq_w)); + WD1770(config, m_fdc, DERIVED_CLOCK(1, 2)); + m_fdc->intrq_wr_callback().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::irq_w)); + m_fdc->drq_wr_callback().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::nmi_w)); FLOPPY_CONNECTOR(config, m_floppy0, stlefs_floppies, "525qd", electron_stlefs_device::floppy_formats).enable_sound(true); FLOPPY_CONNECTOR(config, m_floppy1, stlefs_floppies, nullptr, electron_stlefs_device::floppy_formats).enable_sound(true); } @@ -83,7 +83,7 @@ void electron_stlefs_device::device_start() // read - cartridge data read //------------------------------------------------- -uint8_t electron_stlefs_device::read(address_space &space, offs_t offset, int infc, int infd, int romqa) +uint8_t electron_stlefs_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) { uint8_t data = 0xff; @@ -99,13 +99,9 @@ uint8_t electron_stlefs_device::read(address_space &space, offs_t offset, int in break; } } - - if (!infc && !infd) + else if (oe) { - if (offset >= 0x0000 && offset < 0x4000) - { - data = m_rom[(offset & 0x3fff) + (romqa * 0x4000)]; - } + data = m_rom[(offset & 0x3fff) | (romqa << 14)]; } return data; @@ -115,14 +111,14 @@ uint8_t electron_stlefs_device::read(address_space &space, offs_t offset, int in // write - cartridge data write //------------------------------------------------- -void electron_stlefs_device::write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) +void electron_stlefs_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) { if (infc) { switch (offset & 0xff) { case 0xc0: - wd1770_control_w(space, 0, data); + wd1770_control_w(data); break; case 0xc4: case 0xc5: @@ -141,7 +137,7 @@ void electron_stlefs_device::write(address_space &space, offs_t offset, uint8_t // IMPLEMENTATION //************************************************************************** -WRITE8_MEMBER(electron_stlefs_device::wd1770_control_w) +void electron_stlefs_device::wd1770_control_w(uint8_t data) { floppy_image_device *floppy = nullptr; @@ -160,13 +156,3 @@ WRITE8_MEMBER(electron_stlefs_device::wd1770_control_w) // bit 5: reset if (!BIT(data, 5)) m_fdc->soft_reset(); } - -void electron_stlefs_device::fdc_intrq_w(int state) -{ - m_slot->irq_w(state); -} - -void electron_stlefs_device::fdc_drq_w(int state) -{ - m_slot->nmi_w(state); -} diff --git a/src/devices/bus/electron/cart/stlefs.h b/src/devices/bus/electron/cart/stlefs.h index 2123261907a..421850943e2 100644 --- a/src/devices/bus/electron/cart/stlefs.h +++ b/src/devices/bus/electron/cart/stlefs.h @@ -36,13 +36,11 @@ protected: virtual void device_add_mconfig(machine_config &config) override; // electron_cart_interface overrides - virtual uint8_t read(address_space &space, offs_t offset, int infc, int infd, int romqa) override; - virtual void write(address_space &space, offs_t offset, uint8_t data, int infc, int infd, int romqa) override; + 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: - DECLARE_WRITE8_MEMBER(wd1770_control_w); - DECLARE_WRITE_LINE_MEMBER(fdc_intrq_w); - DECLARE_WRITE_LINE_MEMBER(fdc_drq_w); + void wd1770_control_w(uint8_t data); DECLARE_FLOPPY_FORMATS(floppy_formats); required_device<wd1770_device> m_fdc; diff --git a/src/devices/bus/electron/cart/tube.cpp b/src/devices/bus/electron/cart/tube.cpp new file mode 100644 index 00000000000..02dcd00275d --- /dev/null +++ b/src/devices/bus/electron/cart/tube.cpp @@ -0,0 +1,91 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + Acorn Electron Tube Interface + +**********************************************************************/ + + +#include "emu.h" +#include "tube.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(ELECTRON_TUBE, electron_tube_device, "electron_tube", "Acorn Electron Tube Interface") + + +//------------------------------------------------- +// device_add_mconfig - add device configuration +//------------------------------------------------- + +void electron_tube_device::device_add_mconfig(machine_config &config) +{ + /* tube port */ + BBC_TUBE_SLOT(config, m_tube, electron_tube_devices, nullptr); + m_tube->irq_handler().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::irq_w)); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// electron_tube_device - constructor +//------------------------------------------------- + +electron_tube_device::electron_tube_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ELECTRON_TUBE, tag, owner, clock) + , device_electron_cart_interface(mconfig, *this) + , m_tube(*this, "tube") +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void electron_tube_device::device_start() +{ +} + +//------------------------------------------------- +// read - cartridge data read +//------------------------------------------------- + +uint8_t electron_tube_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2) +{ + uint8_t data = 0xff; + + if (infc) + { + if (offset >= 0xe0 && offset < 0xf0) + { + data = m_tube->host_r(offset & 0x0f); + } + } + else if (oe2) + { + data = m_rom[offset & 0x1fff]; + } + + return data; +} + +//------------------------------------------------- +// write - cartridge data write +//------------------------------------------------- + +void electron_tube_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) +{ + if (infc) + { + if (offset >= 0xe0 && offset < 0xf0) + { + m_tube->host_w(offset & 0x0f, data); + } + } +} diff --git a/src/devices/bus/electron/cart/tube.h b/src/devices/bus/electron/cart/tube.h new file mode 100644 index 00000000000..1d239ef5215 --- /dev/null +++ b/src/devices/bus/electron/cart/tube.h @@ -0,0 +1,47 @@ +// license:BSD-3-Clause +// copyright-holders:Nigel Barnes +/********************************************************************** + + Acorn Electron Tube Interface + +**********************************************************************/ + +#ifndef MAME_BUS_ELECTRON_CART_TUBE_H +#define MAME_BUS_ELECTRON_CART_TUBE_H + +#include "slot.h" +#include "bus/bbc/tube/tube.h" + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class electron_tube_device : + public device_t, + public device_electron_cart_interface +{ +public: + // construction/destruction + electron_tube_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + // device-level overrides + virtual void device_start() 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<bbc_tube_slot_device> m_tube; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(ELECTRON_TUBE, electron_tube_device) + + +#endif // MAME_BUS_ELECTRON_CART_TUBE_H |