diff options
Diffstat (limited to 'src/devices/bus/electron')
-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 |
16 files changed, 411 insertions, 118 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; }; |