From 5b68b8ac057647962b318781d5cf3e0ea5b87e52 Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 1 Jun 2019 16:57:37 -0400 Subject: oricext/jasmin: Use addressable latch device (nw) --- src/devices/bus/oricext/jasmin.cpp | 86 +++++++++++++++----------------------- src/devices/bus/oricext/jasmin.h | 21 +++++----- 2 files changed, 44 insertions(+), 63 deletions(-) diff --git a/src/devices/bus/oricext/jasmin.cpp b/src/devices/bus/oricext/jasmin.cpp index a52505c7eea..0d3b8fce721 100644 --- a/src/devices/bus/oricext/jasmin.cpp +++ b/src/devices/bus/oricext/jasmin.cpp @@ -28,16 +28,16 @@ INPUT_PORTS_END void jasmin_device::map(address_map &map) { map(0x3f4, 0x3f7).rw("fdc", FUNC(wd1770_device::read), FUNC(wd1770_device::write)); - map(0x3f8, 0x3f8).w(FUNC(jasmin_device::side_sel_w)); - map(0x3f9, 0x3f9).w(FUNC(jasmin_device::fdc_reset_w)); - map(0x3fa, 0x3fa).w(FUNC(jasmin_device::ram_access_w)); - map(0x3fb, 0x3fb).w(FUNC(jasmin_device::rom_access_w)); - map(0x3fc, 0x3ff).w(FUNC(jasmin_device::select_w)); + map(0x3f8, 0x3ff).w(m_fdlatch, FUNC(ls259_device::write_d0)); } jasmin_device::jasmin_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : oricext_device(mconfig, JASMIN, tag, owner, clock), - fdc(*this, "fdc"), side_sel(false), fdc_reset(false), ram_access(false), rom_access(false), jasmin_rom(nullptr), cur_floppy(nullptr) + m_fdc(*this, "fdc"), + m_fdlatch(*this, "fdlatch"), + m_floppies(*this, "fdc:%u", 0U), + m_jasmin_rom(*this, "jasmin"), + m_cur_floppy(nullptr) { } @@ -48,23 +48,7 @@ jasmin_device::~jasmin_device() void jasmin_device::device_start() { oricext_device::device_start(); - jasmin_rom = device().machine().root_device().memregion(this->subtag("jasmin").c_str())->base(); cpu->space(AS_PROGRAM).install_device(0x0000, 0xffff, *this, &jasmin_device::map); - - for(int i=0; i<4; i++) { - char name[32]; - sprintf(name, "fdc:%d", i); - floppies[i] = subdevice(name)->get_device(); - } -} - -void jasmin_device::device_reset() -{ - side_sel = fdc_reset = ram_access = rom_access = false; - select[0] = select[1] = select[2] = select[3] = false; - remap(); - cur_floppy = nullptr; - fdc->set_floppy(nullptr); } const tiny_rom_entry *jasmin_device::device_rom_region() const @@ -74,13 +58,23 @@ const tiny_rom_entry *jasmin_device::device_rom_region() const void jasmin_device::device_add_mconfig(machine_config &config) { - WD1770(config, fdc, 8_MHz_XTAL); - fdc->drq_wr_callback().set(FUNC(oricext_device::irq_w)); + WD1770(config, m_fdc, 8_MHz_XTAL); + m_fdc->drq_wr_callback().set(FUNC(oricext_device::irq_w)); FLOPPY_CONNECTOR(config, "fdc:0", jasmin_floppies, "3dsdd", jasmin_device::floppy_formats); FLOPPY_CONNECTOR(config, "fdc:1", jasmin_floppies, nullptr, jasmin_device::floppy_formats); FLOPPY_CONNECTOR(config, "fdc:2", jasmin_floppies, nullptr, jasmin_device::floppy_formats); FLOPPY_CONNECTOR(config, "fdc:3", jasmin_floppies, nullptr, jasmin_device::floppy_formats); + + LS259(config, m_fdlatch); // U14 + m_fdlatch->q_out_cb<0>().set(FUNC(jasmin_device::side_sel_w)); + m_fdlatch->q_out_cb<1>().set(m_fdc, FUNC(wd1770_device::mr_w)); + m_fdlatch->q_out_cb<2>().set(FUNC(jasmin_device::ram_access_w)); + m_fdlatch->q_out_cb<3>().set(FUNC(jasmin_device::rom_access_w)); + m_fdlatch->q_out_cb<4>().set(FUNC(jasmin_device::select_w)); + m_fdlatch->q_out_cb<5>().set(FUNC(jasmin_device::select_w)); + m_fdlatch->q_out_cb<6>().set(FUNC(jasmin_device::select_w)); + m_fdlatch->q_out_cb<7>().set(FUNC(jasmin_device::select_w)); } ioport_constructor jasmin_device::device_input_ports() const @@ -90,24 +84,24 @@ ioport_constructor jasmin_device::device_input_ports() const void jasmin_device::remap() { - if(rom_access) { - if(ram_access) { + if(m_fdlatch->q3_r()) { + if(m_fdlatch->q2_r()) { bank_c000_r->set_base(ram+0xc000); bank_e000_r->set_base(ram+0xe000); - bank_f800_r->set_base(jasmin_rom); + bank_f800_r->set_base(m_jasmin_rom.target()); bank_c000_w->set_base(ram+0xc000); bank_e000_w->set_base(ram+0xe000); bank_f800_w->set_base(junk_write); } else { bank_c000_r->set_base(junk_read); bank_e000_r->set_base(junk_read); - bank_f800_r->set_base(jasmin_rom); + bank_f800_r->set_base(m_jasmin_rom.target()); bank_c000_w->set_base(junk_write); bank_e000_w->set_base(junk_write); bank_f800_w->set_base(junk_write); } } else { - if(ram_access) { + if(m_fdlatch->q2_r()) { bank_c000_r->set_base(ram+0xc000); bank_e000_r->set_base(ram+0xe000); bank_f800_r->set_base(ram+0xf800); @@ -128,46 +122,34 @@ void jasmin_device::remap() INPUT_CHANGED_MEMBER(jasmin_device::boot_pressed) { if(newval) { - rom_access = true; - remap(); + m_fdlatch->write_bit(3, 1); cpu->reset(); } } -WRITE8_MEMBER(jasmin_device::side_sel_w) -{ - side_sel = data & 1; - if(cur_floppy) - cur_floppy->ss_w(side_sel); -} - -WRITE8_MEMBER(jasmin_device::fdc_reset_w) +WRITE_LINE_MEMBER(jasmin_device::side_sel_w) { - if((data & 1) != fdc_reset) - fdc->soft_reset(); - fdc_reset = data & 1; + if(m_cur_floppy) + m_cur_floppy->ss_w(state); } -WRITE8_MEMBER(jasmin_device::ram_access_w) +WRITE_LINE_MEMBER(jasmin_device::ram_access_w) { - ram_access = data & 1; remap(); } -WRITE8_MEMBER(jasmin_device::rom_access_w) +WRITE_LINE_MEMBER(jasmin_device::rom_access_w) { - rom_access = data & 1; remap(); } -WRITE8_MEMBER(jasmin_device::select_w) +WRITE_LINE_MEMBER(jasmin_device::select_w) { - select[offset] = data & 1; - cur_floppy = nullptr; + m_cur_floppy = nullptr; for(int i=0; i != 4; i++) - if(select[i]) { - cur_floppy = floppies[i]; + if(BIT(m_fdlatch->output_state(), 4+i)) { + m_cur_floppy = m_floppies[i]->get_device(); break; } - fdc->set_floppy(cur_floppy); + m_fdc->set_floppy(m_cur_floppy); } diff --git a/src/devices/bus/oricext/jasmin.h b/src/devices/bus/oricext/jasmin.h index 4daf1feff09..a9c6fe78ba9 100644 --- a/src/devices/bus/oricext/jasmin.h +++ b/src/devices/bus/oricext/jasmin.h @@ -7,6 +7,7 @@ #include "oricext.h" #include "imagedev/floppy.h" +#include "machine/74259.h" #include "machine/wd_fdc.h" DECLARE_DEVICE_TYPE(JASMIN, jasmin_device) @@ -21,7 +22,6 @@ public: protected: virtual void device_start() override; - virtual void device_reset() override; const tiny_rom_entry *device_rom_region() const override; virtual void device_add_mconfig(machine_config &config) override; virtual ioport_constructor device_input_ports() const override; @@ -29,21 +29,20 @@ protected: private: void remap(); - DECLARE_WRITE8_MEMBER(side_sel_w); - DECLARE_WRITE8_MEMBER(fdc_reset_w); - DECLARE_WRITE8_MEMBER(ram_access_w); - DECLARE_WRITE8_MEMBER(rom_access_w); - DECLARE_WRITE8_MEMBER(select_w); + DECLARE_WRITE_LINE_MEMBER(side_sel_w); + DECLARE_WRITE_LINE_MEMBER(ram_access_w); + DECLARE_WRITE_LINE_MEMBER(rom_access_w); + DECLARE_WRITE_LINE_MEMBER(select_w); void map(address_map &map); DECLARE_FLOPPY_FORMATS(floppy_formats); - required_device fdc; - - bool side_sel, fdc_reset, ram_access, rom_access, select[4]; - uint8_t *jasmin_rom; - floppy_image_device *cur_floppy, *floppies[4]; + required_device m_fdc; + required_device m_fdlatch; + required_device_array m_floppies; + required_region_ptr m_jasmin_rom; + floppy_image_device *m_cur_floppy; }; #endif // MAME_BUS_ORICEXT_JASMIN_H -- cgit v1.2.3