diff options
-rw-r--r-- | src/devices/bus/electron/exp.cpp | 30 | ||||
-rw-r--r-- | src/devices/bus/electron/exp.h | 6 | ||||
-rw-r--r-- | src/devices/bus/electron/fbjoy.cpp | 22 | ||||
-rw-r--r-- | src/devices/bus/electron/fbjoy.h | 3 | ||||
-rw-r--r-- | src/devices/bus/electron/m2105.cpp | 78 | ||||
-rw-r--r-- | src/devices/bus/electron/m2105.h | 5 | ||||
-rw-r--r-- | src/devices/bus/electron/plus1.cpp | 76 | ||||
-rw-r--r-- | src/devices/bus/electron/plus1.h | 6 | ||||
-rw-r--r-- | src/devices/bus/electron/plus3.cpp | 57 | ||||
-rw-r--r-- | src/devices/bus/electron/plus3.h | 10 | ||||
-rw-r--r-- | src/devices/bus/electron/pwrjoy.cpp | 36 | ||||
-rw-r--r-- | src/devices/bus/electron/pwrjoy.h | 6 | ||||
-rw-r--r-- | src/devices/bus/electron/rombox.cpp | 80 | ||||
-rw-r--r-- | src/devices/bus/electron/rombox.h | 7 | ||||
-rw-r--r-- | src/devices/bus/electron/romboxp.cpp | 102 | ||||
-rw-r--r-- | src/devices/bus/electron/romboxp.h | 5 | ||||
-rw-r--r-- | src/mame/drivers/electron.cpp | 30 | ||||
-rw-r--r-- | src/mame/includes/electron.h | 5 | ||||
-rw-r--r-- | src/mame/machine/electron.cpp | 99 |
19 files changed, 486 insertions, 177 deletions
diff --git a/src/devices/bus/electron/exp.cpp b/src/devices/bus/electron/exp.cpp index 7328e1283af..2db692a1257 100644 --- a/src/devices/bus/electron/exp.cpp +++ b/src/devices/bus/electron/exp.cpp @@ -87,9 +87,35 @@ void electron_expansion_slot_device::device_start() void electron_expansion_slot_device::device_reset() { - if (get_card_device()) + if (m_card != nullptr) { - get_card_device()->reset(); + m_card->device().reset(); + } +} + +//------------------------------------------------- +// expbus_r - expansion data read +//------------------------------------------------- + +uint8_t electron_expansion_slot_device::expbus_r(address_space &space, offs_t offset, uint8_t data) +{ + if (m_card != nullptr) + { + data = m_card->expbus_r(space, offset, data); + } + + return data; +} + +//------------------------------------------------- +// expbus_w - expansion data write +//------------------------------------------------- + +void electron_expansion_slot_device::expbus_w(address_space &space, offs_t offset, uint8_t data) +{ + if (m_card != nullptr) + { + m_card->expbus_w(space, offset, data); } } diff --git a/src/devices/bus/electron/exp.h b/src/devices/bus/electron/exp.h index 9ebf65410fd..6b60d4f30cb 100644 --- a/src/devices/bus/electron/exp.h +++ b/src/devices/bus/electron/exp.h @@ -139,6 +139,9 @@ public: template <class Object> static devcb_base &set_nmi_handler(device_t &device, Object &&cb) { return downcast<electron_expansion_slot_device &>(device).m_nmi_handler.set_callback(std::forward<Object>(cb)); } + uint8_t expbus_r(address_space &space, offs_t offset, uint8_t data); + void expbus_w(address_space &space, offs_t offset, uint8_t data); + DECLARE_WRITE_LINE_MEMBER( irq_w ) { m_irq_handler(state); } DECLARE_WRITE_LINE_MEMBER( nmi_w ) { m_nmi_handler(state); } @@ -163,6 +166,9 @@ public: // construction/destruction virtual ~device_electron_expansion_interface(); + virtual uint8_t expbus_r(address_space &space, offs_t offset, uint8_t data) { return data; } + virtual void expbus_w(address_space &space, offs_t offset, uint8_t data) { } + protected: device_electron_expansion_interface(const machine_config &mconfig, device_t &device); diff --git a/src/devices/bus/electron/fbjoy.cpp b/src/devices/bus/electron/fbjoy.cpp index 643b697615b..6c4939edbf5 100644 --- a/src/devices/bus/electron/fbjoy.cpp +++ b/src/devices/bus/electron/fbjoy.cpp @@ -60,27 +60,19 @@ electron_fbjoy_device::electron_fbjoy_device(const machine_config &mconfig, cons void electron_fbjoy_device::device_start() { - address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); - m_slot = dynamic_cast<electron_expansion_slot_device *>(owner()); - - space.install_read_handler(0xfcc0, 0xfcc0, READ8_DELEGATE(electron_fbjoy_device, joystick_r)); } //------------------------------------------------- -// device_reset - device-specific reset +// expbus_r - expansion data read //------------------------------------------------- -void electron_fbjoy_device::device_reset() +uint8_t electron_fbjoy_device::expbus_r(address_space &space, offs_t offset, uint8_t data) { -} + if (offset == 0xfcc0) + { + data = m_joy->read() | 0xe0; + } - -//************************************************************************** -// IMPLEMENTATION -//************************************************************************** - -READ8_MEMBER(electron_fbjoy_device::joystick_r) -{ - return m_joy->read() | 0xe0; + return data; } diff --git a/src/devices/bus/electron/fbjoy.h b/src/devices/bus/electron/fbjoy.h index d532c896d46..b45c242d907 100644 --- a/src/devices/bus/electron/fbjoy.h +++ b/src/devices/bus/electron/fbjoy.h @@ -33,12 +33,11 @@ public: // optional information overrides virtual ioport_constructor device_input_ports() const override; - DECLARE_READ8_MEMBER(joystick_r); + virtual uint8_t expbus_r(address_space &space, offs_t offset, uint8_t data) override; protected: // device-level overrides virtual void device_start() override; - virtual void device_reset() override; private: required_ioport m_joy; diff --git a/src/devices/bus/electron/m2105.cpp b/src/devices/bus/electron/m2105.cpp index 2c5921c8d3a..8d72ddc52c4 100644 --- a/src/devices/bus/electron/m2105.cpp +++ b/src/devices/bus/electron/m2105.cpp @@ -121,6 +121,7 @@ electron_m2105_device::electron_m2105_device(const machine_config &mconfig, cons , m_tms(*this, "tms5220") , m_centronics(*this, "centronics") , m_irqs(*this, "irqs") + , m_romsel(0) { } @@ -130,12 +131,7 @@ electron_m2105_device::electron_m2105_device(const machine_config &mconfig, cons void electron_m2105_device::device_start() { - address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); m_slot = dynamic_cast<electron_expansion_slot_device *>(owner()); - - space.install_readwrite_handler(0xfc40, 0xfc5f, READ8_DEVICE_DELEGATE(m_via6522_1, via6522_device, read), WRITE8_DEVICE_DELEGATE(m_via6522_1, via6522_device, write)); - space.install_readwrite_handler(0xfc60, 0xfc6f, READ8_DEVICE_DELEGATE(m_duart, scn2681_device, read), WRITE8_DEVICE_DELEGATE(m_duart, scn2681_device, write)); - space.install_readwrite_handler(0xfc70, 0xfc8f, READ8_DEVICE_DELEGATE(m_via6522_0, via6522_device, read), WRITE8_DEVICE_DELEGATE(m_via6522_0, via6522_device, write)); } //------------------------------------------------- @@ -144,10 +140,74 @@ void electron_m2105_device::device_start() void electron_m2105_device::device_reset() { - machine().root_device().membank("bank2")->configure_entry(12, memregion("exp_rom")->base() + 0x0000); - machine().root_device().membank("bank2")->configure_entry(13, memregion("exp_rom")->base() + 0x4000); - machine().root_device().membank("bank2")->configure_entry( 0, memregion("exp_rom")->base() + 0x8000); - machine().root_device().membank("bank2")->configure_entry( 2, memregion("exp_rom")->base() + 0xc000); +} + +//------------------------------------------------- +// expbus_r - expansion data read +//------------------------------------------------- + +uint8_t electron_m2105_device::expbus_r(address_space &space, offs_t offset, uint8_t data) +{ + if (offset >= 0x8000 && offset < 0xc000) + { + switch (m_romsel) + { + case 0: + data = memregion("exp_rom")->base()[0x8000 + (offset & 0x3fff)]; + break; + case 2: + data = memregion("exp_rom")->base()[0xc000 + (offset & 0x3fff)]; + break; + case 12: + data = memregion("exp_rom")->base()[0x0000 + (offset & 0x3fff)]; + break; + case 13: + data = memregion("exp_rom")->base()[0x4000 + (offset & 0x3fff)]; + break; + } + } + else if (offset >= 0xfc40 && offset < 0xfc60) + { + data = m_via6522_1->read(space, offset); + } + else if (offset >= 0xfc60 && offset < 0xfc70) + { + data = m_duart->read(space, offset & 0x0f); + } + else if (offset >= 0xfc70 && offset < 0xfc90) + { + data = m_via6522_0->read(space, offset); + } + + return data; +} + +//------------------------------------------------- +// expbus_w - expansion data write +//------------------------------------------------- + +void electron_m2105_device::expbus_w(address_space &space, offs_t offset, uint8_t data) +{ + if (offset >= 0x8000 && offset < 0xc000) + { + logerror("write ram bank %d\n", m_romsel); + } + else if (offset >= 0xfc40 && offset < 0xfc60) + { + m_via6522_1->write(space, offset, data); + } + else if (offset >= 0xfc60 && offset < 0xfc70) + { + m_duart->write(space, offset & 0x0f, data); + } + else if (offset >= 0xfc70 && offset < 0xfc90) + { + m_via6522_0->write(space, offset, data); + } + else if (offset == 0xfe05) + { + m_romsel = data & 0x0f; + } } diff --git a/src/devices/bus/electron/m2105.h b/src/devices/bus/electron/m2105.h index 2411913008c..3fab3b52128 100644 --- a/src/devices/bus/electron/m2105.h +++ b/src/devices/bus/electron/m2105.h @@ -40,6 +40,9 @@ protected: virtual void device_add_mconfig(machine_config &config) override; virtual const tiny_rom_entry *device_rom_region() const override; + virtual uint8_t expbus_r(address_space &space, offs_t offset, uint8_t data) override; + virtual void expbus_w(address_space &space, offs_t offset, uint8_t data) override; + private: DECLARE_WRITE_LINE_MEMBER(intrq_w); @@ -50,6 +53,8 @@ private: required_device<tms5220_device> m_tms; required_device<centronics_device> m_centronics; required_device<input_merger_device> m_irqs; + + uint8_t m_romsel; }; diff --git a/src/devices/bus/electron/plus1.cpp b/src/devices/bus/electron/plus1.cpp index a4c1810c204..839b175fcd3 100644 --- a/src/devices/bus/electron/plus1.cpp +++ b/src/devices/bus/electron/plus1.cpp @@ -139,45 +139,85 @@ electron_plus1_device::electron_plus1_device(const machine_config &mconfig, cons m_adc(*this, "adc"), m_joy(*this, "JOY%u", 1), m_buttons(*this, "BUTTONS"), + m_romsel(0), m_centronics_busy(0), m_adc_ready(0) { } + //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void electron_plus1_device::device_start() { - address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); - m_slot = dynamic_cast<electron_expansion_slot_device *>(owner()); - - space.install_readwrite_handler(0xfc70, 0xfc70, READ8_DEVICE_DELEGATE(m_adc, adc0844_device, read), WRITE8_DEVICE_DELEGATE(m_adc, adc0844_device, write)); - space.install_write_handler(0xfc71, 0xfc71, WRITE8_DEVICE_DELEGATE("cent_data_out", output_latch_device, write)); - space.install_read_handler(0xfc72, 0xfc72, READ8_DELEGATE(electron_plus1_device, status_r)); } + //------------------------------------------------- -// device_reset - device-specific reset +// expbus_r - expansion data read //------------------------------------------------- -void electron_plus1_device::device_reset() +uint8_t electron_plus1_device::expbus_r(address_space &space, offs_t offset, uint8_t data) { - std::string region_tag; - memory_region *tmp_reg; - if (m_cart_sk2 && (tmp_reg = memregion(region_tag.assign(m_cart_sk2->tag()).append(GENERIC_ROM_REGION_TAG).c_str()))) + if (offset >= 0x8000 && offset < 0xc000) { - machine().root_device().membank("bank2")->configure_entries(0, 2, tmp_reg->base(), 0x4000); + switch (m_romsel) + { + case 0: + case 1: + if (m_cart_sk2->exists()) + { + data = m_cart_sk2->read_rom(space, (offset & 0x3fff) + (m_romsel & 0x01) * 0x4000); + } + break; + case 2: + case 3: + if (m_cart_sk1->exists()) + { + data = m_cart_sk1->read_rom(space, (offset & 0x3fff) + (m_romsel & 0x01) * 0x4000); + } + break; + case 12: + data = memregion("exp_rom")->base()[offset & 0x1fff]; + break; + } } - if (m_cart_sk1 && (tmp_reg = memregion(region_tag.assign(m_cart_sk1->tag()).append(GENERIC_ROM_REGION_TAG).c_str()))) + else if (offset == 0xfc70) { - machine().root_device().membank("bank2")->configure_entries(2, 2, tmp_reg->base(), 0x4000); + data = m_adc->read(space, offset); } + else if (offset == 0xfc72) + { + data = status_r(space, offset); + } + + return data; +} + - machine().root_device().membank("bank2")->configure_entry(12, memregion("exp_rom")->base()); +//------------------------------------------------- +// expbus_w - expansion data write +//------------------------------------------------- + +void electron_plus1_device::expbus_w(address_space &space, offs_t offset, uint8_t data) +{ + if (offset == 0xfc70) + { + m_adc->write(space, offset, data); + } + else if (offset == 0xfc71) + { + m_cent_data_out->write(data); + } + else if (offset == 0xfe05) + { + m_romsel = data & 0x0f; + } } + //************************************************************************** // IMPLEMENTATION //************************************************************************** @@ -218,7 +258,7 @@ image_init_result electron_plus1_device::load_cart(device_image_interface &image return image_init_result::FAIL; } - slot->rom_alloc(filesize, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); image.fread(slot->get_rom_base(), filesize); return image_init_result::PASS; } @@ -239,13 +279,13 @@ image_init_result electron_plus1_device::load_cart(device_image_interface &image return image_init_result::FAIL; } - slot->rom_alloc(upsize + losize, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + slot->rom_alloc(0x8000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); if (upsize) memcpy(slot->get_rom_base(), image.get_software_region("uprom"), upsize); if (losize) - memcpy(slot->get_rom_base() + upsize, image.get_software_region("lorom"), losize); + memcpy(slot->get_rom_base() + 0x4000, image.get_software_region("lorom"), losize); return image_init_result::PASS; } diff --git a/src/devices/bus/electron/plus1.h b/src/devices/bus/electron/plus1.h index 75eb44ce91a..f527703e9c8 100644 --- a/src/devices/bus/electron/plus1.h +++ b/src/devices/bus/electron/plus1.h @@ -30,14 +30,17 @@ public: electron_plus1_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; virtual const tiny_rom_entry *device_rom_region() const override; virtual ioport_constructor device_input_ports() const override; + virtual uint8_t expbus_r(address_space &space, offs_t offset, uint8_t data) override; + virtual void expbus_w(address_space &space, offs_t offset, uint8_t data) override; + private: DECLARE_READ8_MEMBER(status_r); DECLARE_WRITE_LINE_MEMBER(busy_w); @@ -56,6 +59,7 @@ private: required_ioport_array<4> m_joy; required_ioport m_buttons; + uint8_t m_romsel; int m_centronics_busy; int m_adc_ready; }; diff --git a/src/devices/bus/electron/plus3.cpp b/src/devices/bus/electron/plus3.cpp index a033a929cb2..6da70b7cf62 100644 --- a/src/devices/bus/electron/plus3.cpp +++ b/src/devices/bus/electron/plus3.cpp @@ -93,10 +93,12 @@ const tiny_rom_entry *electron_plus3_device::device_rom_region() const electron_plus3_device::electron_plus3_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, ELECTRON_PLUS3, tag, owner, clock) , device_electron_expansion_interface(mconfig, *this) + , m_exp(*this, "exp") , m_exp_rom(*this, "exp_rom") , m_fdc(*this, "fdc") , m_floppy0(*this, "fdc:0") , m_floppy1(*this, "fdc:1") + , m_romsel(0) { } @@ -106,20 +108,55 @@ electron_plus3_device::electron_plus3_device(const machine_config &mconfig, cons void electron_plus3_device::device_start() { - address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); - m_slot = dynamic_cast<electron_expansion_slot_device *>(owner()); +} - space.install_readwrite_handler(0xfcc0, 0xfcc0, READ8_DELEGATE(electron_plus3_device, wd1770_status_r), WRITE8_DELEGATE(electron_plus3_device, wd1770_status_w)); - space.install_readwrite_handler(0xfcc4, 0xfcc7, READ8_DEVICE_DELEGATE(m_fdc, wd1770_device, read), WRITE8_DEVICE_DELEGATE(m_fdc, wd1770_device, write)); +//------------------------------------------------- +// expbus_r - expansion data read +//------------------------------------------------- + +uint8_t electron_plus3_device::expbus_r(address_space &space, offs_t offset, uint8_t data) +{ + if (offset >= 0x8000 && offset < 0xc000) + { + if (m_romsel == 4) + { + data = memregion("exp_rom")->base()[offset & 0x3fff]; + } + } + else if (offset == 0xfcc0) + { + data = 0xff; + } + else if (offset >= 0xfcc4 && offset < 0xfcc8) + { + data = m_fdc->read(space, offset & 0x03); + } + + data &= m_exp->expbus_r(space, offset, data); + + return data; } //------------------------------------------------- -// device_reset - device-specific reset +// expbus_w - expansion data write //------------------------------------------------- -void electron_plus3_device::device_reset() +void electron_plus3_device::expbus_w(address_space &space, offs_t offset, uint8_t data) { - machine().root_device().membank("bank2")->configure_entry(4, memregion("exp_rom")->base()); + m_exp->expbus_w(space, offset, data); + + if (offset == 0xfcc0) + { + wd1770_status_w(space, offset, data); + } + else if (offset >= 0xfcc4 && offset < 0xfcc8) + { + m_fdc->write(space, offset & 0x03, data); + } + else if (offset == 0xfe05) + { + m_romsel = data & 0x0f; + } } @@ -127,12 +164,6 @@ void electron_plus3_device::device_reset() // IMPLEMENTATION //************************************************************************** -READ8_MEMBER(electron_plus3_device::wd1770_status_r) -{ - return 0xff; -} - - WRITE8_MEMBER(electron_plus3_device::wd1770_status_w) { floppy_image_device *floppy = nullptr; diff --git a/src/devices/bus/electron/plus3.h b/src/devices/bus/electron/plus3.h index ef27f075ffc..7ebad268c10 100644 --- a/src/devices/bus/electron/plus3.h +++ b/src/devices/bus/electron/plus3.h @@ -25,26 +25,28 @@ public: // construction/destruction electron_plus3_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - DECLARE_READ8_MEMBER(wd1770_status_r); - DECLARE_WRITE8_MEMBER(wd1770_status_w); - 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; virtual const tiny_rom_entry *device_rom_region() const override; + virtual uint8_t expbus_r(address_space &space, offs_t offset, uint8_t data) override; + virtual void expbus_w(address_space &space, offs_t offset, uint8_t data) override; + private: + DECLARE_WRITE8_MEMBER(wd1770_status_w); DECLARE_FLOPPY_FORMATS(floppy_formats); + required_device<electron_expansion_slot_device> m_exp; required_memory_region m_exp_rom; required_device<wd1770_device> m_fdc; required_device<floppy_connector> m_floppy0; optional_device<floppy_connector> m_floppy1; + uint8_t m_romsel; int m_drive_control; }; diff --git a/src/devices/bus/electron/pwrjoy.cpp b/src/devices/bus/electron/pwrjoy.cpp index 98d6422cdd8..42919f378ec 100644 --- a/src/devices/bus/electron/pwrjoy.cpp +++ b/src/devices/bus/electron/pwrjoy.cpp @@ -60,6 +60,7 @@ electron_pwrjoy_device::electron_pwrjoy_device(const machine_config &mconfig, co , device_electron_expansion_interface(mconfig, *this) , m_exp_rom(*this, "exp_rom") , m_joy(*this, "JOY") + , m_romsel(0) { } @@ -70,28 +71,39 @@ electron_pwrjoy_device::electron_pwrjoy_device(const machine_config &mconfig, co void electron_pwrjoy_device::device_start() { - address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); - m_slot = dynamic_cast<electron_expansion_slot_device *>(owner()); - - space.install_read_handler(0xfcc0, 0xfcc0, READ8_DELEGATE(electron_pwrjoy_device, joystick_r)); } //------------------------------------------------- -// device_reset - device-specific reset +// expbus_r - expansion data read //------------------------------------------------- -void electron_pwrjoy_device::device_reset() +uint8_t electron_pwrjoy_device::expbus_r(address_space &space, offs_t offset, uint8_t data) { - machine().root_device().membank("bank2")->configure_entry(15, memregion("exp_rom")->base()); + if (offset >= 0x8000 && offset < 0xc000) + { + if (m_romsel == 15) + { + data = memregion("exp_rom")->base()[offset & 0x1fff]; + } + } + else if (offset == 0xfcc0) + { + data = m_joy->read() | 0xe0; + } + + return data; } -//************************************************************************** -// IMPLEMENTATION -//************************************************************************** +//------------------------------------------------- +// expbus_w - expansion data write +//------------------------------------------------- -READ8_MEMBER(electron_pwrjoy_device::joystick_r) +void electron_pwrjoy_device::expbus_w(address_space &space, offs_t offset, uint8_t data) { - return m_joy->read() | 0xe0; + if (offset == 0xfe05) + { + m_romsel = data & 0x0f; + } } diff --git a/src/devices/bus/electron/pwrjoy.h b/src/devices/bus/electron/pwrjoy.h index 1566f21d10d..be392a1c622 100644 --- a/src/devices/bus/electron/pwrjoy.h +++ b/src/devices/bus/electron/pwrjoy.h @@ -32,16 +32,18 @@ public: virtual const tiny_rom_entry *device_rom_region() const override; virtual ioport_constructor device_input_ports() const override; - DECLARE_READ8_MEMBER(joystick_r); + virtual uint8_t expbus_r(address_space &space, offs_t offset, uint8_t data) override; + virtual void expbus_w(address_space &space, offs_t offset, uint8_t data) override; protected: // device-level overrides virtual void device_start() override; - virtual void device_reset() override; private: required_memory_region m_exp_rom; required_ioport m_joy; + + uint8_t m_romsel; }; diff --git a/src/devices/bus/electron/rombox.cpp b/src/devices/bus/electron/rombox.cpp index 6622784d731..39ab61e1bc2 100644 --- a/src/devices/bus/electron/rombox.cpp +++ b/src/devices/bus/electron/rombox.cpp @@ -32,10 +32,10 @@ static INPUT_PORTS_START( rombox ) PORT_CONFSETTING(0x01, "RAM") PORT_CONFNAME(0x02, 0x00, "A2") // not implemented PORT_CONFSETTING(0x00, "8K or 16K") - PORT_CONFSETTING(0x01, "4K") + PORT_CONFSETTING(0x02, "4K") PORT_CONFNAME(0x04, 0x00, "B") PORT_CONFSETTING(0x00, "ROM 0,1,2,3") - PORT_CONFSETTING(0x02, "ROM 12,13,14,15") + PORT_CONFSETTING(0x04, "ROM 12,13,14,15") INPUT_PORTS_END //------------------------------------------------- @@ -89,8 +89,11 @@ MACHINE_CONFIG_END electron_rombox_device::electron_rombox_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, ELECTRON_ROMBOX, tag, owner, clock), device_electron_expansion_interface(mconfig, *this), + m_exp(*this, "exp"), m_rom(*this, "rom%u", 1), - m_option(*this, "OPTION") + m_option(*this, "OPTION"), + m_romsel(0), + m_rom_base(0) { } @@ -100,7 +103,6 @@ electron_rombox_device::electron_rombox_device(const machine_config &mconfig, co void electron_rombox_device::device_start() { - m_slot = dynamic_cast<electron_expansion_slot_device *>(owner()); } //------------------------------------------------- @@ -109,21 +111,65 @@ void electron_rombox_device::device_start() void electron_rombox_device::device_reset() { - std::string region_tag; - memory_region *tmp_reg; + m_rom_base = (m_option->read() & 0x04) ? 12 : 0; +} - int rom_base = (m_option->read() & 0x04) ? 0 : 12; - for (int i = 0; i < 4; i++) +//------------------------------------------------- +// expbus_r - expansion data read +//------------------------------------------------- + +uint8_t electron_rombox_device::expbus_r(address_space &space, offs_t offset, uint8_t data) +{ + if (offset >= 0x8000 && offset < 0xc000) { - if (m_rom[i] && (tmp_reg = memregion(region_tag.assign(m_rom[i]->tag()).append(GENERIC_ROM_REGION_TAG).c_str()))) + switch (m_romsel) { - machine().root_device().membank("bank2")->configure_entry(4 + i, tmp_reg->base()); + case 0: + case 1: + case 2: + case 3: + if (m_rom_base == 0 && m_rom[m_romsel + 4]->exists()) + { + data = m_rom[m_romsel + 4]->read_rom(space, offset & 0x3fff); + } + break; + case 4: + case 5: + case 6: + case 7: + if (m_rom[m_romsel - 4]->exists()) + { + data = m_rom[m_romsel - 4]->read_rom(space, offset & 0x3fff); + } + break; + case 12: + case 13: + case 14: + case 15: + if (m_rom_base == 12 && m_rom[m_romsel - 8]->exists()) + { + data = m_rom[m_romsel - 8]->read_rom(space, offset & 0x3fff); + } + break; } + } - if (m_rom[i + 4] && (tmp_reg = memregion(region_tag.assign(m_rom[i + 4]->tag()).append(GENERIC_ROM_REGION_TAG).c_str()))) - { - machine().root_device().membank("bank2")->configure_entry(rom_base + i, tmp_reg->base()); - } + data &= m_exp->expbus_r(space, offset, data); + + return data; +} + +//------------------------------------------------- +// expbus_w - expansion data write +//------------------------------------------------- + +void electron_rombox_device::expbus_w(address_space &space, offs_t offset, uint8_t data) +{ + m_exp->expbus_w(space, offset, data); + + if (offset == 0xfe05) + { + m_romsel = data & 0x0f; } } @@ -142,8 +188,12 @@ image_init_result electron_rombox_device::load_rom(device_image_interface &image return image_init_result::FAIL; } - slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + 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/rombox.h b/src/devices/bus/electron/rombox.h index 694f8d0d17d..045db388838 100644 --- a/src/devices/bus/electron/rombox.h +++ b/src/devices/bus/electron/rombox.h @@ -35,6 +35,9 @@ protected: virtual void device_add_mconfig(machine_config &config) override; virtual ioport_constructor device_input_ports() const override; + virtual uint8_t expbus_r(address_space &space, offs_t offset, uint8_t data) override; + virtual void expbus_w(address_space &space, offs_t offset, uint8_t data) 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_rom[0]); } @@ -46,8 +49,12 @@ private: DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom7_load) { return load_rom(image, m_rom[6]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom8_load) { return load_rom(image, m_rom[7]); } + required_device<electron_expansion_slot_device> m_exp; required_device_array<generic_slot_device, 8> m_rom; required_ioport m_option; + + uint8_t m_romsel; + uint8_t m_rom_base; }; diff --git a/src/devices/bus/electron/romboxp.cpp b/src/devices/bus/electron/romboxp.cpp index 3a4b90eb51d..7a9c171703e 100644 --- a/src/devices/bus/electron/romboxp.cpp +++ b/src/devices/bus/electron/romboxp.cpp @@ -123,7 +123,10 @@ electron_romboxp_device::electron_romboxp_device(const machine_config &mconfig, m_cart(*this, "cart%u", 1), m_centronics(*this, "centronics"), m_cent_data_out(*this, "cent_data_out"), - m_option(*this, "OPTION") + m_option(*this, "OPTION"), + m_romsel(0), + m_rom_base(0), + m_centronics_busy(0) { } @@ -133,11 +136,6 @@ electron_romboxp_device::electron_romboxp_device(const machine_config &mconfig, void electron_romboxp_device::device_start() { - address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); - m_slot = dynamic_cast<electron_expansion_slot_device *>(owner()); - - space.install_write_handler(0xfc71, 0xfc71, WRITE8_DEVICE_DELEGATE("cent_data_out", output_latch_device, write)); - space.install_read_handler(0xfc72, 0xfc72, READ8_DELEGATE(electron_romboxp_device, status_r)); } //------------------------------------------------- @@ -146,27 +144,77 @@ void electron_romboxp_device::device_start() void electron_romboxp_device::device_reset() { - std::string region_tag; - memory_region *tmp_reg; + m_rom_base = (m_option->read() & 0x02) ? 4 : 12; +} + +//------------------------------------------------- +// expbus_r - expansion data read +//------------------------------------------------- - int rom_base = (m_option->read() & 0x02) ? 4 : 12; - for (int i = 0; i < 4; i++) +uint8_t electron_romboxp_device::expbus_r(address_space &space, offs_t offset, uint8_t data) +{ + if (offset >= 0x8000 && offset < 0xc000) { - if (m_rom[i] && (tmp_reg = memregion(region_tag.assign(m_rom[i]->tag()).append(GENERIC_ROM_REGION_TAG).c_str()))) + switch (m_romsel) { - machine().root_device().membank("bank2")->configure_entry(rom_base + i, tmp_reg->base()); + case 0: + case 1: + if (m_cart[1]->exists()) + { + data = m_cart[1]->read_rom(space, (offset & 0x3fff) + (m_romsel & 0x01) * 0x4000); + } + break; + case 2: + case 3: + if (m_cart[0]->exists()) + { + data = m_cart[0]->read_rom(space, (offset & 0x3fff) + (m_romsel & 0x01) * 0x4000); + } + break; + case 4: + case 5: + case 6: + case 7: + if (m_rom_base == 4 && m_rom[m_romsel - 4]->exists()) + { + data = m_rom[m_romsel - 4]->read_rom(space, offset & 0x3fff); + } + break; + case 12: + data = memregion("exp_rom")->base()[offset & 0x1fff]; + break; + case 13: + case 14: + case 15: + if (m_rom_base == 12 && m_rom[m_romsel - 12]->exists()) + { + data = m_rom[m_romsel - 12]->read_rom(space, offset & 0x3fff); + } + break; } } - - for (int i = 0; i < 2; i++) + else if (offset == 0xfc72) { - if (m_cart[i] && (tmp_reg = memregion(region_tag.assign(m_cart[i]->tag()).append(GENERIC_ROM_REGION_TAG).c_str()))) - { - machine().root_device().membank("bank2")->configure_entries(i * 2, 2, tmp_reg->base(), 0x4000); - } + data = status_r(space, offset); } - machine().root_device().membank("bank2")->configure_entry(12, memregion("exp_rom")->base()); + return data; +} + +//------------------------------------------------- +// expbus_w - expansion data write +//------------------------------------------------- + +void electron_romboxp_device::expbus_w(address_space &space, offs_t offset, uint8_t data) +{ + if (offset == 0xfc71) + { + m_cent_data_out->write(data); + } + else if (offset == 0xfe05) + { + m_romsel = data & 0x0f; + } } //************************************************************************** @@ -176,13 +224,13 @@ void electron_romboxp_device::device_reset() READ8_MEMBER(electron_romboxp_device::status_r) { // Status: b7: printer Busy - return m_centronics_busy << 7; + return (m_centronics_busy << 7) | 0x7f; } WRITE_LINE_MEMBER(electron_romboxp_device::busy_w) { - m_centronics_busy = state; + m_centronics_busy = !state; } @@ -197,9 +245,13 @@ image_init_result electron_romboxp_device::load_rom(device_image_interface &imag return image_init_result::FAIL; } - slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + 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; } @@ -216,7 +268,7 @@ image_init_result electron_romboxp_device::load_cart(device_image_interface &ima return image_init_result::FAIL; } - slot->rom_alloc(filesize, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); image.fread(slot->get_rom_base(), filesize); return image_init_result::PASS; } @@ -237,13 +289,13 @@ image_init_result electron_romboxp_device::load_cart(device_image_interface &ima return image_init_result::FAIL; } - slot->rom_alloc(upsize + losize, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); + slot->rom_alloc(0x8000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); if (upsize) memcpy(slot->get_rom_base(), image.get_software_region("uprom"), upsize); if (losize) - memcpy(slot->get_rom_base() + upsize, image.get_software_region("lorom"), losize); + memcpy(slot->get_rom_base() + 0x4000, image.get_software_region("lorom"), losize); return image_init_result::PASS; } diff --git a/src/devices/bus/electron/romboxp.h b/src/devices/bus/electron/romboxp.h index ec4a9c16c00..1b5646bbbb3 100644 --- a/src/devices/bus/electron/romboxp.h +++ b/src/devices/bus/electron/romboxp.h @@ -37,6 +37,9 @@ protected: virtual const tiny_rom_entry *device_rom_region() const override; virtual ioport_constructor device_input_ports() const override; + virtual uint8_t expbus_r(address_space &space, offs_t offset, uint8_t data) override; + virtual void expbus_w(address_space &space, offs_t offset, uint8_t data) override; + private: DECLARE_READ8_MEMBER(status_r); DECLARE_WRITE_LINE_MEMBER(busy_w); @@ -58,6 +61,8 @@ private: required_device<output_latch_device> m_cent_data_out; required_ioport m_option; + uint8_t m_romsel; + uint8_t m_rom_base; int m_centronics_busy; }; diff --git a/src/mame/drivers/electron.cpp b/src/mame/drivers/electron.cpp index ec6650d76b7..0bd6611e052 100644 --- a/src/mame/drivers/electron.cpp +++ b/src/mame/drivers/electron.cpp @@ -90,12 +90,12 @@ PALETTE_INIT_MEMBER(electron_state, electron) static ADDRESS_MAP_START(electron_mem, AS_PROGRAM, 8, electron_state ) AM_RANGE(0x0000, 0x7fff) AM_READWRITE(electron_mem_r, electron_mem_w) /* 32KB of RAM */ - AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank2") /* Banked ROM pages */ - AM_RANGE(0xc000, 0xfbff) AM_ROM AM_REGION("user1", 0x40000) /* OS ROM */ + AM_RANGE(0x8000, 0xbfff) AM_READWRITE(electron_paged_r, electron_paged_w) /* Banked ROM pages */ + AM_RANGE(0xc000, 0xfbff) AM_ROM AM_REGION("mos", 0x0000) /* OS ROM */ AM_RANGE(0xfc00, 0xfcff) AM_READWRITE(electron_fred_r, electron_fred_w ) /* FRED */ AM_RANGE(0xfd00, 0xfdff) AM_READWRITE(electron_jim_r, electron_jim_w ) /* JIM */ AM_RANGE(0xfe00, 0xfeff) AM_READWRITE(electron_sheila_r, electron_sheila_w ) /* SHEILA */ - AM_RANGE(0xff00, 0xffff) AM_ROM AM_REGION("user1", 0x43f00) /* OS ROM continued */ + AM_RANGE(0xff00, 0xffff) AM_ROM AM_REGION("mos", 0x3f00) /* OS ROM continued */ ADDRESS_MAP_END INPUT_CHANGED_MEMBER(electron_state::trigger_reset) @@ -252,26 +252,10 @@ MACHINE_CONFIG_END /* Electron Rom Load */ ROM_START(electron) - ROM_REGION( 0x44000, "user1", 0 ) /* OS Rom */ - ROM_LOAD( "b02_acornos-1.rom", 0x40000, 0x4000, CRC(a0c2cf43) SHA1(a27ce645472cc5497690e4bfab43710efbb0792d) ) /* OS rom */ - /* 00000 0 Second external socket on the expansion module (SK2) */ - /* 04000 1 Second external socket on the expansion module (SK2) */ - /* 08000 2 First external socket on the expansion module (SK1) */ - /* 0c000 3 First external socket on the expansion module (SK1) */ - /* 10000 4 Disc */ - /* 14000 5 USER applications */ - /* 18000 6 USER applications */ - /* 1c000 7 Modem interface ROM */ - /* 20000 8 Keyboard */ - /* 24000 9 Keyboard mirror */ - /* 28000 10 BASIC rom */ - /* 2c000 11 BASIC rom mirror */ - /* 30000 12 Expansion module operating system */ - /* 34000 13 High priority slot in expansion module */ - /* 38000 14 ECONET */ - /* 3c000 15 Reserved */ - ROM_LOAD("basic.rom", 0x28000, 0x4000, CRC(79434781) SHA1(4a7393f3a45ea309f744441c16723e2ef447a281)) - ROM_COPY("user1", 0x28000, 0x2c000, 0x4000) + ROM_REGION( 0x4000, "mos", 0 ) + ROM_LOAD( "b02_acornos-1.rom", 0x0000, 0x4000, CRC(a0c2cf43) SHA1(a27ce645472cc5497690e4bfab43710efbb0792d) ) + ROM_REGION( 0x4000, "basic", 0 ) + ROM_LOAD( "basic.rom", 0x0000, 0x4000, CRC(79434781) SHA1(4a7393f3a45ea309f744441c16723e2ef447a281) ) ROM_END diff --git a/src/mame/includes/electron.h b/src/mame/includes/electron.h index 6782f660e82..539ac4119de 100644 --- a/src/mame/includes/electron.h +++ b/src/mame/includes/electron.h @@ -18,8 +18,6 @@ #include "sound/beep.h" #include "bus/electron/exp.h" -#include "bus/generic/slot.h" -#include "bus/generic/carts.h" /* Interrupts */ #define INT_HIGH_TONE 0x40 @@ -84,9 +82,10 @@ public: int m_map4[256]; int m_map16[256]; emu_timer *m_scanline_timer; - DECLARE_READ8_MEMBER(electron_read_keyboard); DECLARE_READ8_MEMBER(electron_mem_r); DECLARE_WRITE8_MEMBER(electron_mem_w); + DECLARE_READ8_MEMBER(electron_paged_r); + DECLARE_WRITE8_MEMBER(electron_paged_w); DECLARE_READ8_MEMBER(electron_fred_r); DECLARE_WRITE8_MEMBER(electron_fred_w); DECLARE_READ8_MEMBER(electron_jim_r); diff --git a/src/mame/machine/electron.cpp b/src/mame/machine/electron.cpp index 008cb662965..923cb9ea565 100644 --- a/src/mame/machine/electron.cpp +++ b/src/mame/machine/electron.cpp @@ -142,22 +142,6 @@ TIMER_CALLBACK_MEMBER(electron_state::electron_tape_timer_handler) } } -READ8_MEMBER(electron_state::electron_read_keyboard) -{ - uint8_t data = 0; - - //logerror( "PC=%04x: keyboard read from paged rom area, address: %04x", activecpu_get_pc(), offset ); - for (int i = 0; i < 14; i++) - { - if (!(offset & 1)) - data |= m_keybd[i]->read() & 0x0f; - - offset = offset >> 1; - } - //logerror( ", data: %02x\n", data ); - return data; -} - READ8_MEMBER(electron_state::electron_mem_r) { //waitforramsync(); @@ -170,26 +154,84 @@ WRITE8_MEMBER(electron_state::electron_mem_w) m_ram->write(offset, data); } +READ8_MEMBER(electron_state::electron_paged_r) +{ + /* 0 Second external socket on the expansion module (SK2) */ + /* 1 Second external socket on the expansion module (SK2) */ + /* 2 First external socket on the expansion module (SK1) */ + /* 3 First external socket on the expansion module (SK1) */ + /* 4 Disc */ + /* 5 USER applications */ + /* 6 USER applications */ + /* 7 Modem interface ROM */ + /* 8 Keyboard */ + /* 9 Keyboard mirror */ + /* 10 BASIC rom */ + /* 11 BASIC rom mirror */ + /* 12 Expansion module operating system */ + /* 13 High priority slot in expansion module */ + /* 14 ECONET */ + /* 15 Reserved */ + + uint8_t data = 0; + + switch (m_ula.rompage) + { + case 8: + case 9: + /* Keyboard */ + for (int i = 0; i < 14; i++) + { + if (!(offset & 1)) + data |= m_keybd[i]->read() & 0x0f; + + offset = offset >> 1; + } + break; + + case 10: + case 11: + /* BASIC */ + data = memregion("basic")->base()[offset & 0x3fff]; + break; + + default: + /* ROM in extension devices */ + data = m_exp->expbus_r(space, 0x8000 + offset, 0xff); + break; + } + return data; +} + +WRITE8_MEMBER(electron_state::electron_paged_w) +{ + m_exp->expbus_w(space, 0x8000 + offset, data); +} + READ8_MEMBER(electron_state::electron_fred_r) { /* The Issue 4 ULA returns data from OS ROM, whereas Issue 6 ULA will return 0xfc */ - logerror("FRED: read fc%02x\n", offset); - return 0xfc; + //logerror("FRED: read fc%02x\n", offset); + return m_exp->expbus_r(space, 0xfc00 + offset, 0xfc); } WRITE8_MEMBER(electron_state::electron_fred_w) { + //logerror("FRED: write fc%02x\n", offset); + m_exp->expbus_w(space, 0xfc00 + offset, data); } READ8_MEMBER(electron_state::electron_jim_r) { /* The Issue 4 ULA returns data from OS ROM, whereas Issue 6 ULA will return 0xfd */ - logerror("JIM: read fd%02x\n", offset); - return 0xfd; + //logerror("JIM: read fd%02x\n", offset); + return m_exp->expbus_r(space, 0xfd00 + offset, 0xfd); } WRITE8_MEMBER(electron_state::electron_jim_w) { + //logerror("JIM: write fd%02x\n", offset); + m_exp->expbus_w(space, 0xfd00 + offset, data); } READ8_MEMBER(electron_state::electron_sheila_r) @@ -210,7 +252,7 @@ READ8_MEMBER(electron_state::electron_sheila_r) data = m_ula.tape_byte; break; } - logerror( "ULA: read offset %02x: %02x\n", offset, data ); + //logerror( "ULA: read fe%02x: %02x\n", offset, data ); return data; } @@ -219,8 +261,10 @@ static const uint16_t electron_screen_base[8] = { 0x3000, 0x3000, 0x3000, 0x4000 WRITE8_MEMBER(electron_state::electron_sheila_w) { + m_exp->expbus_w(space, 0xfe00 + offset, data); + int i = electron_palette_offset[(( offset >> 1 ) & 0x03)]; - logerror( "ULA: write offset %02x <- %02x\n", offset & 0x0f, data ); + //logerror( "ULA: write fe%02x <- %02x\n", offset & 0x0f, data ); switch( offset & 0x0f ) { case 0x00: /* Interrupt control */ @@ -251,13 +295,7 @@ WRITE8_MEMBER(electron_state::electron_sheila_w) if ( m_ula.rompage == 8 || m_ula.rompage == 9 ) { m_ula.rompage = 8; - space.install_read_handler( 0x8000, 0xbfff, read8_delegate(FUNC(electron_state::electron_read_keyboard),this)); } - else - { - space.install_read_bank( 0x8000, 0xbfff, "bank2"); - } - membank("bank2")->set_entry(m_ula.rompage); } if ( data & 0x10 ) { @@ -368,8 +406,6 @@ TIMER_CALLBACK_MEMBER(electron_state::setup_beep) void electron_state::machine_reset() { - membank("bank2")->set_entry(0); - m_ula.communication_mode = 0x04; m_ula.screen_mode = 0; m_ula.cassette_motor_mode = 0; @@ -384,9 +420,6 @@ void electron_state::machine_reset() void electron_state::machine_start() { - for (int page = 0; page < 16; page++) - membank("bank2")->configure_entries(page, 1, memregion("user1")->base() + page * 0x4000, 0x4000); - m_ula.interrupt_status = 0x82; m_ula.interrupt_control = 0x00; timer_set(attotime::zero, TIMER_SETUP_BEEP); |