diff options
author | David Haywood <28625134+DavidHaywood@users.noreply.github.com> | 2019-08-31 21:26:27 +0100 |
---|---|---|
committer | MetalliC <0vetal0@gmail.com> | 2019-08-31 23:26:27 +0300 |
commit | d673a392f177ba6ee8889493ae6c5c7d4e5271a4 (patch) | |
tree | 0c71f307b5ad8c9aba51c0376ef79cb9ad808e52 | |
parent | 49a844fc7b388894bd4f149df5f4ff6f6583fa97 (diff) |
push forward with the spectrum betadisc stuff, now system at least boots with it enabled (nw) (#5576)
* work towards betadisc (nw)
* work towards older betadisk support (nw)
* some refactoring (nw)
* add note from Metallic (nw)
27 files changed, 166 insertions, 84 deletions
diff --git a/src/devices/bus/spectrum/beta.cpp b/src/devices/bus/spectrum/beta.cpp index 4f46db864c2..e713b548a0e 100644 --- a/src/devices/bus/spectrum/beta.cpp +++ b/src/devices/bus/spectrum/beta.cpp @@ -60,8 +60,23 @@ separate as the enable / disable mechanisms are different and remaining mappings of devices unconfirmed - These devices are not currently working as the disable logic is - not understood. + --- + + Based on older BDI schematics, it seems the logic is like: + + memory access 0x3CXX (any type of access: code or data, read or write) -> temporary use BDI ROM (NOT permanent latch/switch like in beta128) + memory access <0x4000 area and BDI ROM_latch==true -> use BDI ROM + + IO write to port 0bxxxxxx00 -> D7 master_latch, 0=enable, 1=disable + + while master_latch is enabled access to regular Spectrum IO is blocked (output /IORQ forced to 1) but enabled BDI ports: + + IO write to port 0b1xxxx111 -> D7 BDI ROM_latch (0=enable, 1=disble), D6 - FDC DDEN, D4 - SIDE, D3 - FDC HLT, D2 - FDC /MR (reset), D0-1 - floppy drive select. + IO read port 0b1xxxx111 <- D7 - FDC INTRQ, D6 - FDC DRQ + IO read/write ports 0b0YYxx111 - access FDC ports YY + + So mostly the same as beta128, except for new BDI ROM_latch bit + *********************************************************************/ @@ -266,6 +281,8 @@ void spectrum_betav2_device::device_reset() { // always paged in on boot? (no mode switch like beta128) m_romcs = 1; + m_romlatch = 0; +// m_masterportdisable = 1; } //************************************************************************** @@ -277,30 +294,42 @@ READ_LINE_MEMBER(spectrum_betav2_device::romcs) return m_romcs | m_exp->romcs(); } - -void spectrum_betav2_device::opcode_fetch(offs_t offset) +void spectrum_betav2_device::fetch(offs_t offset) { - m_exp->opcode_fetch(offset); - if (!machine().side_effects_disabled()) { if ((offset & 0xff00) == 0x3c00) m_romcs = 1; + else + m_romcs = 0; - // how does the ROM get disabled on these older beta units - // there are no RETs that end up in RAM as with the 128 - // so it looks like jumps to the 0xxx and 1xxx regions, but - // that doesn't work? + if (!m_romlatch) + { + if (offset < 0x4000) + m_romcs = 1; + } } } +void spectrum_betav2_device::pre_opcode_fetch(offs_t offset) +{ + m_exp->pre_opcode_fetch(offset); + fetch(offset); +} + +void spectrum_betav2_device::pre_data_fetch(offs_t offset) +{ + m_exp->pre_data_fetch(offset); + fetch(offset); +} + uint8_t spectrum_betav2_device::iorq_r(offs_t offset) { uint8_t data = m_exp->iorq_r(offset); -#if 0 // this is the Beta 128 logic, it may or may not be the same here +// if (!m_masterportdisable) if (m_romcs) - { + { switch (offset & 0xff) { case 0x1f: case 0x3f: case 0x5f: case 0x7f: @@ -314,14 +343,18 @@ uint8_t spectrum_betav2_device::iorq_r(offs_t offset) break; } } -#endif return data; } void spectrum_betav2_device::iorq_w(offs_t offset, uint8_t data) { -#if 0 // this is the Beta 128 logic, it may or may not be the same here +// if ((offset & 0x03) == 0x00) +// { +// m_masterportdisable = data & 0x80; +// } + +// if (!m_masterportdisable) if (m_romcs) { switch (offset & 0xff) @@ -331,6 +364,8 @@ void spectrum_betav2_device::iorq_w(offs_t offset, uint8_t data) break; case 0xff: + m_romlatch = data & 0x80; + floppy_image_device* floppy = m_floppy[data & 3]->get_device(); m_fdc->set_floppy(floppy); @@ -356,7 +391,7 @@ void spectrum_betav2_device::iorq_w(offs_t offset, uint8_t data) break; } } -#endif + m_exp->iorq_w(offset, data); } @@ -400,6 +435,7 @@ INPUT_CHANGED_MEMBER(spectrum_betaplus_device::magic_button) { m_slot->nmi_w(ASSERT_LINE); m_romcs = 1; + m_romlatch = 0; } else { diff --git a/src/devices/bus/spectrum/beta.h b/src/devices/bus/spectrum/beta.h index df2c16a2738..d9b1d8e914e 100644 --- a/src/devices/bus/spectrum/beta.h +++ b/src/devices/bus/spectrum/beta.h @@ -40,7 +40,8 @@ protected: virtual void device_add_mconfig(machine_config &config) override; virtual const tiny_rom_entry *device_rom_region() const override; - virtual void opcode_fetch(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; + virtual void pre_data_fetch(offs_t offset) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; virtual uint8_t iorq_r(offs_t offset) override; @@ -53,6 +54,10 @@ protected: required_device<spectrum_expansion_slot_device> m_exp; int m_romcs; + int m_romlatch; +// int m_masterportdisable; + + void fetch(offs_t offset); }; class spectrum_betav3_device : diff --git a/src/devices/bus/spectrum/beta128.cpp b/src/devices/bus/spectrum/beta128.cpp index 5b989482560..f034016a85e 100644 --- a/src/devices/bus/spectrum/beta128.cpp +++ b/src/devices/bus/spectrum/beta128.cpp @@ -176,9 +176,9 @@ READ_LINE_MEMBER(spectrum_beta128_device::romcs) } -void spectrum_beta128_device::opcode_fetch(offs_t offset) +void spectrum_beta128_device::pre_opcode_fetch(offs_t offset) { - m_exp->opcode_fetch(offset); + m_exp->pre_opcode_fetch(offset); if (!machine().side_effects_disabled()) { diff --git a/src/devices/bus/spectrum/beta128.h b/src/devices/bus/spectrum/beta128.h index c82313c7c89..b3734687e72 100644 --- a/src/devices/bus/spectrum/beta128.h +++ b/src/devices/bus/spectrum/beta128.h @@ -40,7 +40,7 @@ protected: virtual const tiny_rom_entry *device_rom_region() const override; virtual ioport_constructor device_input_ports() const override; - virtual void opcode_fetch(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; virtual uint8_t iorq_r(offs_t offset) override; diff --git a/src/devices/bus/spectrum/exp.cpp b/src/devices/bus/spectrum/exp.cpp index a58b2dc7f55..6092f87d9ce 100644 --- a/src/devices/bus/spectrum/exp.cpp +++ b/src/devices/bus/spectrum/exp.cpp @@ -101,20 +101,28 @@ READ_LINE_MEMBER(spectrum_expansion_slot_device::romcs) // fetch_r //------------------------------------------------- -void spectrum_expansion_slot_device::opcode_fetch(offs_t offset) +void spectrum_expansion_slot_device::pre_opcode_fetch(offs_t offset) { if (m_card) - m_card->opcode_fetch(offset); + m_card->pre_opcode_fetch(offset); } -//------------------------------------------------- -// fetch_r -//------------------------------------------------- +void spectrum_expansion_slot_device::post_opcode_fetch(offs_t offset) +{ + if (m_card) + m_card->post_opcode_fetch(offset); +} + +void spectrum_expansion_slot_device::pre_data_fetch(offs_t offset) +{ + if (m_card) + m_card->pre_data_fetch(offset); +} -void spectrum_expansion_slot_device::opcode_fetch_post(offs_t offset) +void spectrum_expansion_slot_device::post_data_fetch(offs_t offset) { if (m_card) - m_card->opcode_fetch_post(offset); + m_card->post_data_fetch(offset); } //------------------------------------------------- diff --git a/src/devices/bus/spectrum/exp.h b/src/devices/bus/spectrum/exp.h index 71b95b2a213..5de81d4ae43 100644 --- a/src/devices/bus/spectrum/exp.h +++ b/src/devices/bus/spectrum/exp.h @@ -73,8 +73,11 @@ public: auto irq_handler() { return m_irq_handler.bind(); } auto nmi_handler() { return m_nmi_handler.bind(); } - void opcode_fetch(offs_t offset); - void opcode_fetch_post(offs_t offset); + void pre_opcode_fetch(offs_t offset); + void post_opcode_fetch(offs_t offset); + void pre_data_fetch(offs_t offset); + void post_data_fetch(offs_t offset); + uint8_t mreq_r(offs_t offset); void mreq_w(offs_t offset, uint8_t data); uint8_t iorq_r(offs_t offset); @@ -107,8 +110,10 @@ public: device_spectrum_expansion_interface(const machine_config &mconfig, device_t &device); // reading and writing - virtual void opcode_fetch(offs_t offset) { }; - virtual void opcode_fetch_post(offs_t offset) { }; + virtual void pre_opcode_fetch(offs_t offset) { }; + virtual void post_opcode_fetch(offs_t offset) { }; + virtual void pre_data_fetch(offs_t offset) { }; + virtual void post_data_fetch(offs_t offset) { }; virtual uint8_t mreq_r(offs_t offset) { return 0xff; } virtual void mreq_w(offs_t offset, uint8_t data) { } virtual uint8_t iorq_r(offs_t offset) { return 0xff; } diff --git a/src/devices/bus/spectrum/fuller.cpp b/src/devices/bus/spectrum/fuller.cpp index 636967cbdd6..f44965e5a03 100644 --- a/src/devices/bus/spectrum/fuller.cpp +++ b/src/devices/bus/spectrum/fuller.cpp @@ -93,9 +93,9 @@ READ_LINE_MEMBER(spectrum_fuller_device::romcs) return m_exp->romcs(); } -void spectrum_fuller_device::opcode_fetch(offs_t offset) +void spectrum_fuller_device::pre_opcode_fetch(offs_t offset) { - m_exp->opcode_fetch(offset); + m_exp->pre_opcode_fetch(offset); } uint8_t spectrum_fuller_device::mreq_r(offs_t offset) diff --git a/src/devices/bus/spectrum/fuller.h b/src/devices/bus/spectrum/fuller.h index 12f7805eff0..cc6a4c8fec0 100644 --- a/src/devices/bus/spectrum/fuller.h +++ b/src/devices/bus/spectrum/fuller.h @@ -37,7 +37,7 @@ protected: virtual void device_add_mconfig(machine_config &config) override; virtual ioport_constructor device_input_ports() const override; - virtual void opcode_fetch(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; virtual uint8_t iorq_r(offs_t offset) override; diff --git a/src/devices/bus/spectrum/intf1.cpp b/src/devices/bus/spectrum/intf1.cpp index 420db4fd9d2..bbdf324b2e0 100644 --- a/src/devices/bus/spectrum/intf1.cpp +++ b/src/devices/bus/spectrum/intf1.cpp @@ -111,9 +111,9 @@ READ_LINE_MEMBER(spectrum_intf1_device::romcs) // the Interface 1 looks for specific bus conditions to enable / disable the expansion overlay ROM // the enable must occur BEFORE the opcode is fetched, as the opcode must be fetched from the expansion ROM -void spectrum_intf1_device::opcode_fetch(offs_t offset) +void spectrum_intf1_device::pre_opcode_fetch(offs_t offset) { - m_exp->opcode_fetch(offset); + m_exp->pre_opcode_fetch(offset); if (!machine().side_effects_disabled()) { @@ -127,9 +127,9 @@ void spectrum_intf1_device::opcode_fetch(offs_t offset) } // the disable must occur AFTER the opcode fetch, or the incorrect opcode is fetched for 0x0700 -void spectrum_intf1_device::opcode_fetch_post(offs_t offset) +void spectrum_intf1_device::post_opcode_fetch(offs_t offset) { - m_exp->opcode_fetch_post(offset); + m_exp->post_opcode_fetch(offset); if (!machine().side_effects_disabled()) { diff --git a/src/devices/bus/spectrum/intf1.h b/src/devices/bus/spectrum/intf1.h index 7fc2ec743d5..b128c42ea92 100644 --- a/src/devices/bus/spectrum/intf1.h +++ b/src/devices/bus/spectrum/intf1.h @@ -37,8 +37,8 @@ protected: virtual void device_add_mconfig(machine_config &config) override; virtual const tiny_rom_entry *device_rom_region() const override; - virtual void opcode_fetch(offs_t offset) override; - virtual void opcode_fetch_post(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; + virtual void post_opcode_fetch(offs_t offset) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; virtual uint8_t iorq_r(offs_t offset) override; diff --git a/src/devices/bus/spectrum/melodik.cpp b/src/devices/bus/spectrum/melodik.cpp index f6abc0f98d6..9a6f743a65b 100644 --- a/src/devices/bus/spectrum/melodik.cpp +++ b/src/devices/bus/spectrum/melodik.cpp @@ -69,9 +69,9 @@ READ_LINE_MEMBER(spectrum_melodik_device::romcs) return m_exp->romcs(); } -void spectrum_melodik_device::opcode_fetch(offs_t offset) +void spectrum_melodik_device::pre_opcode_fetch(offs_t offset) { - m_exp->opcode_fetch(offset); + m_exp->pre_opcode_fetch(offset); } uint8_t spectrum_melodik_device::mreq_r(offs_t offset) diff --git a/src/devices/bus/spectrum/melodik.h b/src/devices/bus/spectrum/melodik.h index 4300d946cd4..bf1514f600c 100644 --- a/src/devices/bus/spectrum/melodik.h +++ b/src/devices/bus/spectrum/melodik.h @@ -36,7 +36,7 @@ protected: // optional information overrides virtual void device_add_mconfig(machine_config &config) override; - virtual void opcode_fetch(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; virtual uint8_t iorq_r(offs_t offset) override; diff --git a/src/devices/bus/spectrum/mface.cpp b/src/devices/bus/spectrum/mface.cpp index 82797743ed8..807787126b2 100644 --- a/src/devices/bus/spectrum/mface.cpp +++ b/src/devices/bus/spectrum/mface.cpp @@ -177,9 +177,9 @@ READ_LINE_MEMBER(spectrum_mface1_device::romcs) return m_romcs | m_exp->romcs(); } -void spectrum_mface1_device::opcode_fetch(offs_t offset) +void spectrum_mface1_device::pre_opcode_fetch(offs_t offset) { - m_exp->opcode_fetch(offset); + m_exp->pre_opcode_fetch(offset); if (!machine().side_effects_disabled()) { diff --git a/src/devices/bus/spectrum/mface.h b/src/devices/bus/spectrum/mface.h index bbe8311808c..bf286cf9823 100644 --- a/src/devices/bus/spectrum/mface.h +++ b/src/devices/bus/spectrum/mface.h @@ -38,7 +38,7 @@ protected: virtual const tiny_rom_entry *device_rom_region() const override; virtual ioport_constructor device_input_ports() const override; - virtual void opcode_fetch(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; virtual uint8_t iorq_r(offs_t offset) override; diff --git a/src/devices/bus/spectrum/opus.cpp b/src/devices/bus/spectrum/opus.cpp index 239560cd512..88eb2deb6a3 100644 --- a/src/devices/bus/spectrum/opus.cpp +++ b/src/devices/bus/spectrum/opus.cpp @@ -162,9 +162,9 @@ READ_LINE_MEMBER(spectrum_opus_device::romcs) return m_romcs | m_exp->romcs(); } -void spectrum_opus_device::opcode_fetch(offs_t offset) +void spectrum_opus_device::pre_opcode_fetch(offs_t offset) { - m_exp->opcode_fetch(offset); + m_exp->pre_opcode_fetch(offset); if (!machine().side_effects_disabled()) { diff --git a/src/devices/bus/spectrum/opus.h b/src/devices/bus/spectrum/opus.h index 8d72d8be94b..62e4e640b58 100644 --- a/src/devices/bus/spectrum/opus.h +++ b/src/devices/bus/spectrum/opus.h @@ -42,7 +42,7 @@ protected: virtual ioport_constructor device_input_ports() const override; virtual const tiny_rom_entry *device_rom_region() const override; - virtual void opcode_fetch(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; virtual uint8_t iorq_r(offs_t offset) override; diff --git a/src/devices/bus/spectrum/uslot.cpp b/src/devices/bus/spectrum/uslot.cpp index d27f1ec572d..b689df0cecb 100644 --- a/src/devices/bus/spectrum/uslot.cpp +++ b/src/devices/bus/spectrum/uslot.cpp @@ -76,10 +76,10 @@ READ_LINE_MEMBER(spectrum_uslot_device::romcs) return m_exp1->romcs() | m_exp2->romcs(); } -void spectrum_uslot_device::opcode_fetch(offs_t offset) +void spectrum_uslot_device::pre_opcode_fetch(offs_t offset) { - m_exp1->opcode_fetch(offset); - m_exp2->opcode_fetch(offset); + m_exp1->pre_opcode_fetch(offset); + m_exp2->pre_opcode_fetch(offset); } uint8_t spectrum_uslot_device::mreq_r(offs_t offset) diff --git a/src/devices/bus/spectrum/uslot.h b/src/devices/bus/spectrum/uslot.h index 6cfa90c45e9..8df9dc79b4a 100644 --- a/src/devices/bus/spectrum/uslot.h +++ b/src/devices/bus/spectrum/uslot.h @@ -36,7 +36,7 @@ protected: // optional information overrides virtual void device_add_mconfig(machine_config &config) override; - virtual void opcode_fetch(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; virtual uint8_t iorq_r(offs_t offset) override; diff --git a/src/devices/bus/spectrum/usource.cpp b/src/devices/bus/spectrum/usource.cpp index 13f302b14c5..4acee2141cd 100644 --- a/src/devices/bus/spectrum/usource.cpp +++ b/src/devices/bus/spectrum/usource.cpp @@ -83,7 +83,7 @@ READ_LINE_MEMBER(spectrum_usource_device::romcs) return m_romcs; } -void spectrum_usource_device::opcode_fetch(offs_t offset) +void spectrum_usource_device::pre_opcode_fetch(offs_t offset) { if (!machine().side_effects_disabled() && (offset == 0x2bae)) { diff --git a/src/devices/bus/spectrum/usource.h b/src/devices/bus/spectrum/usource.h index daf792f076f..1f0d7d44e58 100644 --- a/src/devices/bus/spectrum/usource.h +++ b/src/devices/bus/spectrum/usource.h @@ -38,7 +38,7 @@ protected: // optional information overrides virtual const tiny_rom_entry *device_rom_region() const override; - virtual void opcode_fetch(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; virtual DECLARE_READ_LINE_MEMBER(romcs) override; virtual uint8_t mreq_r(offs_t offset) override; diff --git a/src/devices/bus/spectrum/uspeech.cpp b/src/devices/bus/spectrum/uspeech.cpp index 60374fd3c2c..d3476bbc441 100644 --- a/src/devices/bus/spectrum/uspeech.cpp +++ b/src/devices/bus/spectrum/uspeech.cpp @@ -99,7 +99,7 @@ READ_LINE_MEMBER(spectrum_uspeech_device::romcs) return m_romcs; } -void spectrum_uspeech_device::opcode_fetch(offs_t offset) +void spectrum_uspeech_device::pre_opcode_fetch(offs_t offset) { if (!machine().side_effects_disabled() && (offset == 0x0038)) { diff --git a/src/devices/bus/spectrum/uspeech.h b/src/devices/bus/spectrum/uspeech.h index 8013abf9222..078e33599af 100644 --- a/src/devices/bus/spectrum/uspeech.h +++ b/src/devices/bus/spectrum/uspeech.h @@ -40,7 +40,7 @@ protected: virtual const tiny_rom_entry *device_rom_region() const override; virtual void device_add_mconfig(machine_config &config) override; - virtual void opcode_fetch(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; virtual DECLARE_READ_LINE_MEMBER(romcs) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; diff --git a/src/devices/bus/spectrum/wafa.cpp b/src/devices/bus/spectrum/wafa.cpp index 79d89eebe4c..d3757d20e47 100644 --- a/src/devices/bus/spectrum/wafa.cpp +++ b/src/devices/bus/spectrum/wafa.cpp @@ -106,9 +106,9 @@ READ_LINE_MEMBER(spectrum_wafa_device::romcs) return m_romcs | m_exp->romcs(); } -void spectrum_wafa_device::opcode_fetch(offs_t offset) +void spectrum_wafa_device::pre_opcode_fetch(offs_t offset) { - m_exp->opcode_fetch(offset); + m_exp->pre_opcode_fetch(offset); if (!machine().side_effects_disabled()) { @@ -124,9 +124,9 @@ void spectrum_wafa_device::opcode_fetch(offs_t offset) } } -void spectrum_wafa_device::opcode_fetch_post(offs_t offset) +void spectrum_wafa_device::post_opcode_fetch(offs_t offset) { - m_exp->opcode_fetch_post(offset); + m_exp->post_opcode_fetch(offset); if (!machine().side_effects_disabled()) { diff --git a/src/devices/bus/spectrum/wafa.h b/src/devices/bus/spectrum/wafa.h index ceb8924b7ae..81428c61e84 100644 --- a/src/devices/bus/spectrum/wafa.h +++ b/src/devices/bus/spectrum/wafa.h @@ -39,8 +39,8 @@ protected: virtual void device_add_mconfig(machine_config &config) override; virtual const tiny_rom_entry *device_rom_region() const override; - virtual void opcode_fetch(offs_t offset) override; - virtual void opcode_fetch_post(offs_t offset) override; + virtual void pre_opcode_fetch(offs_t offset) override; + virtual void post_opcode_fetch(offs_t offset) override; virtual uint8_t mreq_r(offs_t offset) override; virtual void mreq_w(offs_t offset, uint8_t data) override; virtual uint8_t iorq_r(offs_t offset) override; diff --git a/src/mame/drivers/spec128.cpp b/src/mame/drivers/spec128.cpp index 4f669d13c1b..30c3cff92b9 100644 --- a/src/mame/drivers/spec128.cpp +++ b/src/mame/drivers/spec128.cpp @@ -165,7 +165,7 @@ resulting mess can be seen in the F4 viewer display. /****************************************************************************************************/ /* Spectrum 128 specific functions */ -READ8_MEMBER(spectrum_state::spectrum_128_opcode_fetch_r) +READ8_MEMBER(spectrum_state::spectrum_128_pre_opcode_fetch_r) { /* this allows expansion devices to act upon opcode fetches from MEM addresses */ if (BIT(m_port_7ffd_data, 4)) @@ -174,9 +174,9 @@ READ8_MEMBER(spectrum_state::spectrum_128_opcode_fetch_r) for example, interface1 detection fetches requires fetches at 0008 / 0708 to enable paged ROM and then fetches at 0700 to disable it */ - m_exp->opcode_fetch(offset); + m_exp->pre_opcode_fetch(offset); uint8_t retval = m_maincpu->space(AS_PROGRAM).read_byte(offset); - m_exp->opcode_fetch_post(offset); + m_exp->post_opcode_fetch(offset); return retval; } @@ -271,7 +271,7 @@ void spectrum_state::spectrum_128_mem(address_map &map) void spectrum_state::spectrum_128_fetch(address_map &map) { - map(0x0000, 0xffff).r(FUNC(spectrum_state::spectrum_128_opcode_fetch_r)); + map(0x0000, 0xffff).r(FUNC(spectrum_state::spectrum_128_pre_opcode_fetch_r)); } MACHINE_RESET_MEMBER(spectrum_state,spectrum_128) diff --git a/src/mame/drivers/spectrum.cpp b/src/mame/drivers/spectrum.cpp index 951218cc422..c3c496109dc 100644 --- a/src/mame/drivers/spectrum.cpp +++ b/src/mame/drivers/spectrum.cpp @@ -291,18 +291,31 @@ SamRam /****************************************************************************************************/ /* Spectrum 48k functions */ -READ8_MEMBER(spectrum_state::opcode_fetch_r) +READ8_MEMBER(spectrum_state::pre_opcode_fetch_r) { /* this allows expansion devices to act upon opcode fetches from MEM addresses for example, interface1 detection fetches requires fetches at 0008 / 0708 to enable paged ROM and then fetches at 0700 to disable it */ - m_exp->opcode_fetch(offset); - uint8_t retval = m_maincpu->space(AS_PROGRAM).read_byte(offset); - m_exp->opcode_fetch_post(offset); + m_exp->pre_opcode_fetch(offset); + uint8_t retval = m_specmem->space(AS_PROGRAM).read_byte(offset); + m_exp->post_opcode_fetch(offset); return retval; } +READ8_MEMBER(spectrum_state::spectrum_data_r) +{ + m_exp->pre_data_fetch(offset); + uint8_t retval = m_specmem->space(AS_PROGRAM).read_byte(offset); + m_exp->post_data_fetch(offset); + return retval; +} + +WRITE8_MEMBER(spectrum_state::spectrum_data_w) +{ + m_specmem->space(AS_PROGRAM).write_byte(offset,data); +} + WRITE8_MEMBER(spectrum_state::spectrum_rom_w) { if (m_exp->romcs()) @@ -442,17 +455,23 @@ READ8_MEMBER(spectrum_state::spectrum_port_ula_r) /* Memory Maps */ -void spectrum_state::spectrum_mem(address_map &map) +void spectrum_state::spectrum_map(address_map &map) { map(0x0000, 0x3fff).rw(FUNC(spectrum_state::spectrum_rom_r), FUNC(spectrum_state::spectrum_rom_w)); map(0x4000, 0x5aff).ram().share("video_ram"); + // installed later depending on ramsize //map(0x5b00, 0x7fff).ram(); //map(0x8000, 0xffff).ram(); } -void spectrum_state::spectrum_fetch(address_map &map) +void spectrum_state::spectrum_opcodes(address_map &map) +{ + map(0x0000, 0xffff).rw(FUNC(spectrum_state::spectrum_data_r), FUNC(spectrum_state::spectrum_data_w)); +} + +void spectrum_state::spectrum_data(address_map &map) { - map(0x0000, 0xffff).r(FUNC(spectrum_state::opcode_fetch_r)); + map(0x0000, 0xffff).r(FUNC(spectrum_state::pre_opcode_fetch_r)); } /* ports are not decoded full. @@ -625,14 +644,12 @@ INPUT_PORTS_END void spectrum_state::init_spectrum() { - address_space &space = m_maincpu->space(AS_PROGRAM); - switch (m_ram->size()) { case 48*1024: - space.install_ram(0x8000, 0xffff, nullptr); // Fall through + m_specmem->space(AS_PROGRAM).install_ram(0x8000, 0xffff, nullptr); // Fall through case 16*1024: - space.install_ram(0x5b00, 0x7fff, nullptr); + m_specmem->space(AS_PROGRAM).install_ram(0x5b00, 0x7fff, nullptr); } } @@ -686,11 +703,13 @@ void spectrum_state::spectrum_common(machine_config &config) { /* basic machine hardware */ Z80(config, m_maincpu, X1 / 4); /* This is verified only for the ZX Spectrum. Other clones are reported to have different clocks */ - m_maincpu->set_addrmap(AS_PROGRAM, &spectrum_state::spectrum_mem); + m_maincpu->set_addrmap(AS_PROGRAM, &spectrum_state::spectrum_opcodes); + m_maincpu->set_addrmap(AS_OPCODES, &spectrum_state::spectrum_data); m_maincpu->set_addrmap(AS_IO, &spectrum_state::spectrum_io); - m_maincpu->set_addrmap(AS_OPCODES, &spectrum_state::spectrum_fetch); m_maincpu->set_vblank_int("screen", FUNC(spectrum_state::spec_interrupt)); + ADDRESS_MAP_BANK(config, m_specmem).set_map(&spectrum_state::spectrum_map).set_options(ENDIANNESS_LITTLE, 8, 16, 0x10000); + config.m_minimum_quantum = attotime::from_hz(60); MCFG_MACHINE_RESET_OVERRIDE(spectrum_state, spectrum ) diff --git a/src/mame/includes/spectrum.h b/src/mame/includes/spectrum.h index 13a05db3348..c33549f48e2 100644 --- a/src/mame/includes/spectrum.h +++ b/src/mame/includes/spectrum.h @@ -12,7 +12,7 @@ #pragma once #include "machine/spec_snqk.h" - +#include "machine/bankdev.h" #include "bus/spectrum/exp.h" #include "imagedev/cassette.h" #include "imagedev/snapquik.h" @@ -59,6 +59,8 @@ struct EVENT_LIST_ITEM }; + + class spectrum_state : public driver_device { public: @@ -69,6 +71,7 @@ public: m_screen(*this, "screen"), m_cassette(*this, "cassette"), m_ram(*this, RAM_TAG), + m_specmem(*this, "specmem"), m_speaker(*this, "speaker"), m_exp(*this, "exp"), m_io_line0(*this, "LINE0"), @@ -97,6 +100,7 @@ public: void init_spectrum(); protected: + enum { TIMER_IRQ_ON, @@ -135,14 +139,17 @@ protected: uint8_t *m_ram_0000; uint8_t m_ram_disabled_by_beta; - DECLARE_READ8_MEMBER(opcode_fetch_r); + DECLARE_READ8_MEMBER(pre_opcode_fetch_r); DECLARE_WRITE8_MEMBER(spectrum_rom_w); DECLARE_READ8_MEMBER(spectrum_rom_r); + DECLARE_READ8_MEMBER(spectrum_data_r); + DECLARE_WRITE8_MEMBER(spectrum_data_w); + DECLARE_WRITE8_MEMBER(spectrum_port_fe_w); DECLARE_READ8_MEMBER(spectrum_port_fe_r); DECLARE_READ8_MEMBER(spectrum_port_ula_r); - DECLARE_READ8_MEMBER(spectrum_128_opcode_fetch_r); + DECLARE_READ8_MEMBER(spectrum_128_pre_opcode_fetch_r); DECLARE_WRITE8_MEMBER(spectrum_128_bank1_w); DECLARE_READ8_MEMBER(spectrum_128_bank1_r); DECLARE_WRITE8_MEMBER(spectrum_128_port_7ffd_w); @@ -176,11 +183,13 @@ protected: void spectrum_128_mem(address_map &map); void spectrum_128_fetch(address_map &map); void spectrum_io(address_map &map); - void spectrum_mem(address_map &map); - void spectrum_fetch(address_map &map); + void spectrum_opcodes(address_map &map); + void spectrum_map(address_map &map); + void spectrum_data(address_map &map); required_device<cassette_image_device> m_cassette; required_device<ram_device> m_ram; + optional_device<address_map_bank_device> m_specmem; required_device<speaker_sound_device> m_speaker; optional_device<spectrum_expansion_slot_device> m_exp; |