From ecb08b2cd6fd059ebb7cb893955c20a0995b0099 Mon Sep 17 00:00:00 2001 From: Tom <37988779+TwistedTom@users.noreply.github.com> Date: Tue, 12 Nov 2019 16:45:35 +0000 Subject: [PATCH] ZX Spectrum floating bus support (#5883) * floating bus * only official machine has floating bus --- src/devices/bus/spectrum/exp.h | 60 +++++++------ src/mame/drivers/spectrum.cpp | 151 +++++++++++++++++++++++++-------- src/mame/includes/spectrum.h | 5 ++ 3 files changed, 152 insertions(+), 64 deletions(-) diff --git a/src/devices/bus/spectrum/exp.h b/src/devices/bus/spectrum/exp.h index c17b88f0a9b..366e27c9e5e 100644 --- a/src/devices/bus/spectrum/exp.h +++ b/src/devices/bus/spectrum/exp.h @@ -8,34 +8,38 @@ Pinout: - A15 1 A14 - A13 2 A12 - D7 3 +5v - ¬OE 4 NC - SLOT 5 SLOT - D0 6 0v - D1 7 0v - D2 8 ¬CK - D6 9 A0 - D5 10 A1 - D3 11 A2 - D4 12 A3 - ¬INT 13 NC - ¬NMI 14 0v - ¬HALT 15 ¬OE - ¬MREQ 16 NC - ¬IORQ 17 NC - ¬RD 18 NC - ¬WR 19 ¬BUSRQ - NC 20 ¬RESET - ¬WAIT 21 A7 - +12v 22 A6 - NC 23 A5 - ¬M1 24 A4 - ¬RFSH 25 ¬ROMCS - A8 26 ¬BUSACK - A10 27 A9 - NC 28 A11 + 48K 128K/+2 +2A/+2B/+3/3B + + A B A B A B + A15 1 A14 A15 1 A14 A15 1 A14 + A13 2 A12 A13 2 A12 A13 2 A12 + D7 3 +5V D7 3 +5v D7 3 +5v + NC 4 +9V NC 4 +9V /OE ROM1 4 NC + SLOT 5 SLOT SLOT 5 SLOT SLOT 5 SLOT + D0 6 GND D0 6 GND D0 6 GND + D1 7 GND D1 7 GND D1 7 GND + D2 8 CLK D2 8 CLK D2 8 CKEXT + D6 9 A0 D6 9 A0 D6 9 A0 + D5 10 A1 D5 10 A1 D5 10 A1 + D3 11 A2 D3 11 A2 D3 11 A2 + D4 12 A3 D4 12 A3 D4 12 A3 + /INT 13 /IORQGE /INT 13 /IORQGE (+2 only) /INT 13 NC + /NMI 14 GND /NMI 14 GND /NMI 14 GND + /HALT 15 VIDEO /HALT 15 NC /HALT 15 /OE ROM2 + /MREQ 16 /Y /MREQ 16 NC /MREQ 16 /DRD + /IORQ 17 V /IORQ 17 NC /IORQ 17 /DWR + /RD 18 U /RD 18 NC /RD 18 /MTR + /WR 19 /BUSRQ /WR 19 /BUSRQ /WR 19 /BUSRQ + -5V 20 /RESET -5V 20 /RESET NC 20 /RESET + /WAIT 21 A7 /WAIT 21 A7 /WAIT 21 A7 + +12V 22 A6 +12V 22 A6 +12V 22 A6 + 12VAC 23 A5 12VAC 23 A5 -12V 23 A5 + /M1 24 A4 /M1 24 A4 /M1 24 A4 + /RFSH 25 /ROMCS /RFSH 25 /ROMCS /RFSH 25 NC + A8 26 /BUSACK A8 26 /BUSACK A8 26 /BUSACK + A10 27 A9 A10 27 A9 A10 27 A9 + NC 28 A11 NC 28 A11 RESET 28 A11 + **********************************************************************/ diff --git a/src/mame/drivers/spectrum.cpp b/src/mame/drivers/spectrum.cpp index 07ab5e8ce22..c42d52985e7 100644 --- a/src/mame/drivers/spectrum.cpp +++ b/src/mame/drivers/spectrum.cpp @@ -447,6 +447,32 @@ READ8_MEMBER(spectrum_state::spectrum_port_fe_r) } READ8_MEMBER(spectrum_state::spectrum_port_ula_r) +{ + // known ports used for reading floating bus are: + // 0x28ff Arkanoid, Cobra, Renegade, Short Circuit, Terra Cresta + // 0x40ff Sidewize + + // note, these games clash with Beta disk (status reg is R:xxff) + + offset |= 1; + //logerror("fb: %04x\n", offset); + + // Arkanoid, Cobra, Renegade, Short Circuit, Terra Cresta + if (offset == 0x28ff) + return floating_bus_r(); + + // Sidewize + if (offset == 0x40ff) + return floating_bus_r(); + + // Pass through to expansion device if present + if (m_exp->get_card_device()) + return m_exp->iorq_r(offset); + + return floating_bus_r(); +} + +READ8_MEMBER(spectrum_state::spectrum_clone_port_ula_r) { int vpos = m_screen->vpos(); @@ -477,12 +503,56 @@ void spectrum_state::spectrum_data(address_map &map) /* ports are not decoded full. The function decodes the ports appropriately */ void spectrum_state::spectrum_io(address_map &map) +{ + map(0x0000, 0xffff).w(m_exp, FUNC(spectrum_expansion_slot_device::iorq_w)); + map(0x00, 0x00).rw(FUNC(spectrum_state::spectrum_port_fe_r), FUNC(spectrum_state::spectrum_port_fe_w)).select(0xfffe); + map(0x01, 0x01).r(FUNC(spectrum_state::spectrum_port_ula_r)).select(0xfffe); +} + +void spectrum_state::spectrum_clone_io(address_map &map) { map(0x0000, 0xffff).rw(m_exp, FUNC(spectrum_expansion_slot_device::iorq_r), FUNC(spectrum_expansion_slot_device::iorq_w)); map(0x00, 0x00).rw(FUNC(spectrum_state::spectrum_port_fe_r), FUNC(spectrum_state::spectrum_port_fe_w)).select(0xfffe); - map(0x01, 0x01).r(FUNC(spectrum_state::spectrum_port_ula_r)); // .mirror(0xfffe); + map(0x01, 0x01).r(FUNC(spectrum_state::spectrum_clone_port_ula_r)); // .mirror(0xfffe); } +uint8_t spectrum_state::floating_bus_r() +{ + /* + * "floating bus" + * (cpu can peek at the video bus via odd i/o read, some games use it for timing instead of vblank) + * + * It seems this trick was found quite late in the life of the original Sinclair models, + * then found not to work properly on the later Amstrad models, so was mostly abandoned by devs. + * This means most games that use it were released in a relatively small window of mid-late 1986. + * + * known games: + * Arkanoid + * Cobra + * Sidewize + * Short Circuit + * Renegade + * Terra Cresta + * + * ...others? + * + * Note, some were later re-released as "fixed" +2A compatible versions with the floating bus code removed (Arkanoid, Cobra, others?). + */ + + uint8_t data = 0xff; + int hpos = m_screen->hpos(); + int vpos = m_screen->vpos(); + + // peek into attribute ram when beam is in display area + // ula always returns ff when in border area (or h/vblank) + + if ((hpos >= 48 && hpos < 304) && (vpos >= 48 && vpos < 240)) + data = m_video_ram[0x1800 + (((vpos-48)/8)*32) + ((hpos-48)/8)]; + + return data; +} + + /* Input ports */ /****************************************************************************************************/ @@ -760,6 +830,12 @@ void spectrum_state::spectrum(machine_config &config) // available via bankswitching. } +void spectrum_state::spectrum_clone(machine_config &config) +{ + spectrum(config); + m_maincpu->set_addrmap(AS_IO, &spectrum_state::spectrum_clone_io); +} + /*************************************************************************** Game driver(s) @@ -997,38 +1073,41 @@ ROM_START(zvezda) ROM_LOAD( "2764-far-cpu_blue.bin", 0x2000, 0x2000, CRC(ebab64bc) SHA1(8c98a8b6e927b02cf602c20a1b50838e60f7785b)) ROM_END -// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS -COMP( 1982, spectrum, 0, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Sinclair Research Ltd", "ZX Spectrum" , 0 ) -COMP( 1987, spec80k, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "ZX Spectrum 80K", MACHINE_UNOFFICIAL ) -COMP( 1995, specide, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "ZX Spectrum IDE", MACHINE_UNOFFICIAL ) -COMP( 1986, inves, spectrum, 0, spectrum, spec_plus, spectrum_state, init_spectrum, "Investronica", "Inves Spectrum 48K+", 0 ) -COMP( 1985, tk90x, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Micro Digital", "TK 90X Color Computer", 0 ) -COMP( 1986, tk95, spectrum, 0, spectrum, spec_plus, spectrum_state, init_spectrum, "Micro Digital", "TK 95 Color Computer", 0 ) -COMP( 1985, hc85, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "ICE-Felix", "HC-85", 0 ) -COMP( 1988, hc88, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "ICE-Felix", "HC-88", MACHINE_NOT_WORKING ) -COMP( 1990, hc90, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "ICE-Felix", "HC-90", 0 ) -COMP( 1991, hc91, spectrum, 0, spectrum, spec_plus, spectrum_state, init_spectrum, "ICE-Felix", "HC-91", 0 ) -COMP( 1988, cobrasp, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "ITCI", "Cobra (ITCI)", MACHINE_NOT_WORKING ) -COMP( 1988, cobra80, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "ITCI", "Cobra 80K (ITCI)", MACHINE_NOT_WORKING ) -COMP( 1987, cip01, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Electronica", "CIP-01", 0 ) // keyboard should be spectrum, but image was not clear -COMP( 1988, cip03, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Electronica", "CIP-03", 0 ) // keyboard should be spectrum, but image was not clear -COMP( 1990, jet, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Electromagnetica", "JET", 0 ) // keyboard should be spectrum, but image was not clear -COMP( 1987, dgama87, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik Gama 87", 0 ) -COMP( 1988, dgama88, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik Gama 88", 0 ) -COMP( 1989, dgama89, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik Gama 89", 0 ) -COMP( 1990, didakt90, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik 90", 0 ) -COMP( 1991, didakm91, spectrum, 0, spectrum, spec_plus, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik M 91", 0 ) -COMP( 1992, didakm92, spectrum, 0, spectrum, spec_plus, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik M 92", 0 ) -COMP( 1992, didaktk, spectrum, 0, spectrum, spec_plus, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik Kompakt", 0 ) -COMP( 1993, didakm93, spectrum, 0, spectrum, spec_plus, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik M 93", 0 ) -COMP( 1988, mistrum, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Amaterske RADIO", "Mistrum", 0 ) // keyboard could be spectrum in some models (since it was a build-yourself design) -COMP( 198?, bk08, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Orel", "BK-08", 0 ) -COMP( 1990, blitzs, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "Blic", 0 ) // no keyboard images found -COMP( 1990, byte, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "Byte", 0 ) // no keyboard images found -COMP( 199?, orizon, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "Orizon-Micro", 0 ) // no keyboard images found -COMP( 1993, quorum48, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "Kvorum 48K", MACHINE_NOT_WORKING ) -COMP( 1993, magic6, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "Magic 6", MACHINE_NOT_WORKING ) // keyboard should be spectrum, but image was not clear -COMP( 1990, compani1, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "Kompanion 1", 0 ) // no keyboard images found -COMP( 1990, spektrbk, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "Spektr BK-001", 0 ) -COMP( 1989, sintez2, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Signal", "Sintez 2", 0 ) -COMP( 1990, zvezda, spectrum, 0, spectrum, spectrum, spectrum_state, init_spectrum, "", "Zvezda", 0 ) + +/* Any clone known to have the same "floating bus" behaviour as official Sinclair models should be changed to use the "spectrum" machine */ + +// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS +COMP( 1982, spectrum, 0, 0, spectrum, spectrum, spectrum_state, init_spectrum, "Sinclair Research Ltd", "ZX Spectrum" , 0 ) +COMP( 1987, spec80k, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "ZX Spectrum 80K", MACHINE_UNOFFICIAL ) +COMP( 1995, specide, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "ZX Spectrum IDE", MACHINE_UNOFFICIAL ) +COMP( 1986, inves, spectrum, 0, spectrum_clone, spec_plus, spectrum_state, init_spectrum, "Investronica", "Inves Spectrum 48K+", 0 ) +COMP( 1985, tk90x, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Micro Digital", "TK 90X Color Computer", 0 ) +COMP( 1986, tk95, spectrum, 0, spectrum_clone, spec_plus, spectrum_state, init_spectrum, "Micro Digital", "TK 95 Color Computer", 0 ) +COMP( 1985, hc85, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "ICE-Felix", "HC-85", 0 ) +COMP( 1988, hc88, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "ICE-Felix", "HC-88", MACHINE_NOT_WORKING ) +COMP( 1990, hc90, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "ICE-Felix", "HC-90", 0 ) +COMP( 1991, hc91, spectrum, 0, spectrum_clone, spec_plus, spectrum_state, init_spectrum, "ICE-Felix", "HC-91", 0 ) +COMP( 1988, cobrasp, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "ITCI", "Cobra (ITCI)", MACHINE_NOT_WORKING ) +COMP( 1988, cobra80, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "ITCI", "Cobra 80K (ITCI)", MACHINE_NOT_WORKING ) +COMP( 1987, cip01, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Electronica", "CIP-01", 0 ) // keyboard should be spectrum, but image was not clear +COMP( 1988, cip03, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Electronica", "CIP-03", 0 ) // keyboard should be spectrum, but image was not clear +COMP( 1990, jet, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Electromagnetica", "JET", 0 ) // keyboard should be spectrum, but image was not clear +COMP( 1987, dgama87, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik Gama 87", 0 ) +COMP( 1988, dgama88, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik Gama 88", 0 ) +COMP( 1989, dgama89, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik Gama 89", 0 ) +COMP( 1990, didakt90, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik 90", 0 ) +COMP( 1991, didakm91, spectrum, 0, spectrum_clone, spec_plus, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik M 91", 0 ) +COMP( 1992, didakm92, spectrum, 0, spectrum_clone, spec_plus, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik M 92", 0 ) +COMP( 1992, didaktk, spectrum, 0, spectrum_clone, spec_plus, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik Kompakt", 0 ) +COMP( 1993, didakm93, spectrum, 0, spectrum_clone, spec_plus, spectrum_state, init_spectrum, "Didaktik Skalica", "Didaktik M 93", 0 ) +COMP( 1988, mistrum, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Amaterske RADIO", "Mistrum", 0 ) // keyboard could be spectrum in some models (since it was a build-yourself design) +COMP( 198?, bk08, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Orel", "BK-08", 0 ) +COMP( 1990, blitzs, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "Blic", 0 ) // no keyboard images found +COMP( 1990, byte, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "Byte", 0 ) // no keyboard images found +COMP( 199?, orizon, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "Orizon-Micro", 0 ) // no keyboard images found +COMP( 1993, quorum48, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "Kvorum 48K", MACHINE_NOT_WORKING ) +COMP( 1993, magic6, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "Magic 6", MACHINE_NOT_WORKING ) // keyboard should be spectrum, but image was not clear +COMP( 1990, compani1, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "Kompanion 1", 0 ) // no keyboard images found +COMP( 1990, spektrbk, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "Spektr BK-001", 0 ) +COMP( 1989, sintez2, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "Signal", "Sintez 2", 0 ) +COMP( 1990, zvezda, spectrum, 0, spectrum_clone, spectrum, spectrum_state, init_spectrum, "", "Zvezda", 0 ) diff --git a/src/mame/includes/spectrum.h b/src/mame/includes/spectrum.h index c33549f48e2..ddc842af5f4 100644 --- a/src/mame/includes/spectrum.h +++ b/src/mame/includes/spectrum.h @@ -95,6 +95,7 @@ public: void spectrum_common(machine_config &config); void spectrum(machine_config &config); + void spectrum_clone(machine_config &config); void spectrum_128(machine_config &config); void init_spectrum(); @@ -148,6 +149,7 @@ protected: 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_clone_port_ula_r); DECLARE_READ8_MEMBER(spectrum_128_pre_opcode_fetch_r); DECLARE_WRITE8_MEMBER(spectrum_128_bank1_w); @@ -183,6 +185,7 @@ protected: void spectrum_128_mem(address_map &map); void spectrum_128_fetch(address_map &map); void spectrum_io(address_map &map); + void spectrum_clone_io(address_map &map); void spectrum_opcodes(address_map &map); void spectrum_map(address_map &map); void spectrum_data(address_map &map); @@ -245,6 +248,8 @@ protected: void log_quickload(const char *type, uint32_t start, uint32_t length, uint32_t exec, const char *exec_format); void setup_scr(uint8_t *quickdata, uint32_t quicksize); void setup_raw(uint8_t *quickdata, uint32_t quicksize); + + uint8_t floating_bus_r(); };