From cd14ef8e6c56b35b4ce9d8467d83892dcc068140 Mon Sep 17 00:00:00 2001 From: MetalliC <0vetal0@gmail.com> Date: Thu, 2 Jul 2020 23:01:59 +0300 Subject: spectrum/mgt.cpp make DISCiPLE/+D to work with 128K Spectrum models --- src/devices/bus/spectrum/exp.cpp | 4 +- src/devices/bus/spectrum/mgt.cpp | 79 +++++++++++++++++++++++++++------------- src/devices/bus/spectrum/mgt.h | 9 +++++ 3 files changed, 65 insertions(+), 27 deletions(-) diff --git a/src/devices/bus/spectrum/exp.cpp b/src/devices/bus/spectrum/exp.cpp index d7962da4b7b..fc53c13a3dd 100644 --- a/src/devices/bus/spectrum/exp.cpp +++ b/src/devices/bus/spectrum/exp.cpp @@ -211,7 +211,7 @@ void spectrum_expansion_devices(device_slot_interface &device) void spec128_expansion_devices(device_slot_interface &device) { device.option_add("beta128", SPECTRUM_BETA128); - //device.option_add("disciple", SPECTRUM_DISCIPLE); + device.option_add("disciple", SPECTRUM_DISCIPLE); device.option_add("intf1", SPECTRUM_INTF1); device.option_add("intf2", SPECTRUM_INTF2); device.option_add("kempjoy", SPECTRUM_KEMPJOY); @@ -219,7 +219,7 @@ void spec128_expansion_devices(device_slot_interface &device) device.option_add("mikroplus", SPECTRUM_MIKROPLUS); device.option_add("mprint", SPECTRUM_MPRINT); device.option_add("opus", SPECTRUM_OPUS); - //device.option_add("plusd", SPECTRUM_PLUSD); + device.option_add("plusd", SPECTRUM_PLUSD); device.option_add("plus2test", SPECTRUM_PLUS2TEST); device.option_add("protek", SPECTRUM_PROTEK); device.option_add("specdrum", SPECTRUM_SPECDRUM); diff --git a/src/devices/bus/spectrum/mgt.cpp b/src/devices/bus/spectrum/mgt.cpp index e63789f2033..4a869d45fae 100644 --- a/src/devices/bus/spectrum/mgt.cpp +++ b/src/devices/bus/spectrum/mgt.cpp @@ -136,7 +136,7 @@ -------------- DISCiPLE - GDOS v3: all ok, occassional "no system file" when loading system disk, ok on 2nd attempt + GDOS v3: all ok GDOS v2: all ok UNIDOS: all ok @@ -145,7 +145,9 @@ UNIDOS: all ok - Not working with 128K/+2 yet... + DISCiPLE and 128K compatibility notes: + there is some magic involved and its still not clear how exactly it boots on 128K (but it was confirmed to work on real hardware), + currently we assume paging in cannot be triggered for a while after reset. **********************************************************************/ @@ -193,6 +195,11 @@ INPUT_PORTS_START(disciple) PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_8WAY PORT_PLAYER(2) PORT_NAME("Sinclair P2 Down") PORT_CODE(KEYCODE_2_PAD) PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_8WAY PORT_PLAYER(2) PORT_NAME("Sinclair P2 Up") PORT_CODE(KEYCODE_8_PAD) PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2) PORT_NAME("Sinclair P2 Button 1") PORT_CODE(KEYCODE_0_PAD) + + PORT_START("INH") + PORT_CONFNAME(0x01, 0x01, "Inhibit Button") + PORT_CONFSETTING(0x01, "Off (Disciple enabled)") + PORT_CONFSETTING(0x00, "On (Disciple disabled)") INPUT_PORTS_END //------------------------------------------------- @@ -343,6 +350,8 @@ spectrum_disciple_device::spectrum_disciple_device(const machine_config &mconfig , m_exp(*this, "exp") , m_joy1(*this, "JOY1") , m_joy2(*this, "JOY2") + , m_inhibit(*this, "INH") + , m_control(0xff) // check me { } @@ -362,6 +371,8 @@ void spectrum_disciple_device::device_start() { spectrum_plusd_device::device_start(); save_item(NAME(m_map)); + save_item(NAME(m_control)); + save_item(NAME(m_reset_delay)); } //------------------------------------------------- @@ -377,6 +388,8 @@ void spectrum_disciple_device::device_reset() { spectrum_plusd_device::device_reset(); m_map = false; + m_reset_delay = true; + timer_set(attotime::from_usec(10), TIMER_RESET); // delay time is a guess } //************************************************************************** @@ -394,7 +407,6 @@ void spectrum_plusd_device::pre_opcode_fetch(offs_t offset) { switch (offset) { - case 0x0000: case 0x0008: case 0x003a: case 0x0066: @@ -408,19 +420,19 @@ uint8_t spectrum_plusd_device::iorq_r(offs_t offset) { uint8_t data = 0xff; - switch (offset & 0xff) + switch (offset & 0x7e) // address lines 0 and 7-15 ignored { - case 0xe3: // fdc status reg - case 0xeb: // fdc track reg - case 0xf3: // fdc sector reg - case 0xfb: // fdc data reg + case 0x62: // fdc status reg + case 0x6a: // fdc track reg + case 0x72: // fdc sector reg + case 0x7a: // fdc data reg data = m_fdc->read((offset >> 3) & 0x03); break; - case 0xe7: // page in + case 0x66: // page in if (!machine().side_effects_disabled()) m_romcs = 1; break; - case 0xf7: // bit 7: printer busy + case 0x76: // bit 7: printer busy data = m_centronics_busy ? 0x80 : 0x00; break; } @@ -430,15 +442,15 @@ uint8_t spectrum_plusd_device::iorq_r(offs_t offset) void spectrum_plusd_device::iorq_w(offs_t offset, uint8_t data) { - switch (offset & 0xff) + switch (offset & 0x7e) // address lines 0 and 7-15 ignored { - case 0xe3: // fdc command reg - case 0xeb: // fdc track reg - case 0xf3: // fdc sector reg - case 0xfb: // fdc data reg + case 0x62: // fdc command reg + case 0x6a: // fdc track reg + case 0x72: // fdc sector reg + case 0x7a: // fdc data reg m_fdc->write((offset >> 3) & 0x03, data); break; - case 0xef: // bit 0-1: drive select, 6: printer strobe, 7: side select + case 0x6e: // bit 0-1: drive select, 6: printer strobe, 7: side select { floppy_image_device* floppy = nullptr; if (data & 1) @@ -450,10 +462,10 @@ void spectrum_plusd_device::iorq_w(offs_t offset, uint8_t data) if (floppy) floppy->ss_w(BIT(data, 7)); } break; - case 0xe7: // page out + case 0x66: // page out m_romcs = 0; break; - case 0xf7: // printer data + case 0x76: // printer data m_centronics->write_data0(BIT(data, 0)); m_centronics->write_data1(BIT(data, 1)); m_centronics->write_data2(BIT(data, 2)); @@ -527,17 +539,19 @@ READ_LINE_MEMBER(spectrum_disciple_device::romcs) void spectrum_disciple_device::pre_opcode_fetch(offs_t offset) { - m_exp->pre_opcode_fetch(offset); + if (m_inhibit->read() || !BIT(m_control, 4)) // when inhibit button pressed - /M1 passthrought might be blocked + m_exp->pre_opcode_fetch(offset); if (!machine().side_effects_disabled()) { switch (offset) { - case 0x0000: + case 0x0001: case 0x0008: case 0x0066: case 0x028e: - m_romcs = 1; + if (!m_reset_delay && (m_inhibit->read() || !BIT(m_control, 4))) + m_romcs = 1; break; } } @@ -561,11 +575,11 @@ uint8_t spectrum_disciple_device::iorq_r(offs_t offset) // 7: network... break; case 0x7b: // reset boot - if (!machine().side_effects_disabled()) + if (!machine().side_effects_disabled() && !m_reset_delay) m_map = false; break; case 0xbb: // page in - if (!machine().side_effects_disabled()) + if (!machine().side_effects_disabled() && !m_reset_delay) m_romcs = 1; break; case 0xfe: // sinclair joysticks @@ -600,16 +614,19 @@ void spectrum_disciple_device::iorq_w(offs_t offset, uint8_t data) // 5: exp select... m_centronics->write_strobe(BIT(data, 6)); // 7: network... + m_control = data; } break; case 0x3b: // wait when net=1 // ... break; case 0x7b: // set boot - m_map = true; + if (!m_reset_delay) + m_map = true; break; case 0xbb: // page out - m_romcs = 0; + if (!m_reset_delay) + m_romcs = 0; break; case 0xfb: // printer data m_centronics->write_data0(BIT(data, 0)); @@ -691,3 +708,15 @@ void spectrum_disciple_device::mreq_w(offs_t offset, uint8_t data) if (m_exp->romcs()) m_exp->mreq_w(offset, data); } + +void spectrum_disciple_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch (id) + { + case TIMER_RESET: + m_reset_delay = false; + break; + default: + throw emu_fatalerror("Unknown id in spectrum_disciple_device::device_timer"); + } +} diff --git a/src/devices/bus/spectrum/mgt.h b/src/devices/bus/spectrum/mgt.h index bbc69da6eb2..ee3a7c9fe82 100644 --- a/src/devices/bus/spectrum/mgt.h +++ b/src/devices/bus/spectrum/mgt.h @@ -72,9 +72,15 @@ public: spectrum_disciple_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: + enum + { + TIMER_RESET + }; + // device-level overrides virtual void device_start() override; virtual void device_reset() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // optional information overrides virtual void device_add_mconfig(machine_config &config) override; @@ -92,8 +98,11 @@ private: required_device m_exp; required_ioport m_joy1; required_ioport m_joy2; + required_ioport m_inhibit; bool m_map; + u8 m_control; + bool m_reset_delay; }; -- cgit v1.2.3