summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus
diff options
context:
space:
mode:
author MetalliC <0vetal0@gmail.com>2020-07-21 21:11:42 +0300
committer MetalliC <0vetal0@gmail.com>2020-07-21 21:11:42 +0300
commit4ee02e245986c4dbbe31000d4fb0c3180914591f (patch)
treeef4df0ee46bbb1adc6849fee06bdec3aee5b056e /src/devices/bus
parent41cb8485f759e83773e3e4189de7f7a08c2c3ec5 (diff)
bus/spectrum/floppyone.cpp, bus/spectrum/sixword.cpp add serial and parallel ports
Diffstat (limited to 'src/devices/bus')
-rw-r--r--src/devices/bus/spectrum/floppyone.cpp43
-rw-r--r--src/devices/bus/spectrum/floppyone.h8
-rw-r--r--src/devices/bus/spectrum/sixword.cpp134
-rw-r--r--src/devices/bus/spectrum/sixword.h13
4 files changed, 170 insertions, 28 deletions
diff --git a/src/devices/bus/spectrum/floppyone.cpp b/src/devices/bus/spectrum/floppyone.cpp
index 2bf11a8c27e..054065a53cb 100644
--- a/src/devices/bus/spectrum/floppyone.cpp
+++ b/src/devices/bus/spectrum/floppyone.cpp
@@ -3,7 +3,7 @@
/*********************************************************************
FloppyOne DOS Interface
- (c) 1984/5 Rocky P. Gush
+ (c) 1984/5 Rocky P. Gush (RSA)
FD1791-based floppy drive and printer interface with 4K RAM and 8K ROM
Was mainly designed as tape replacement, and sort of emulate how tapes works,
@@ -20,12 +20,13 @@
SAVE "name" - save program
!FORMAT "diskname";"password";tracks - format disk, if disk was already formatted you'll be prompted for password.
!6=n - set text mode, 0 - regular 32-column, 3 - 64-column
- There is more of special "!x=n" commands, but theirs functions is not known, manual is missing.
+ !B=rs232delay, 0=use parallel printer (default)
+ There is more of special "!x=n" commands, but theirs functions is not known, manual is missing.
Some information about this device https://worldofspectrum.org/forums/discussion/42944/rocky-gush-floppy-drive-interface/p1
Notes / TODOs:
- Interface1 compatibility mode is not well understood and not fully implemented
- - Serial printer interface not implemented
+ - RS232 partially implemented
*********************************************************************/
@@ -118,6 +119,12 @@ void spectrum_flpone_device::device_add_mconfig(machine_config &config)
FLOPPY_CONNECTOR(config, "fdc:2", flpone_floppies, nullptr, spectrum_flpone_device::floppy_formats).enable_sound(true);
FLOPPY_CONNECTOR(config, "fdc:3", flpone_floppies, nullptr, spectrum_flpone_device::floppy_formats).enable_sound(true);
+ // parallel printer port
+ CENTRONICS(config, m_centronics, centronics_devices, "printer");
+ m_centronics->busy_handler().set(FUNC(spectrum_flpone_device::busy_w));
+
+ RS232_PORT(config, m_rs232, default_rs232_devices, nullptr);
+
// passthru
SPECTRUM_EXPANSION_SLOT(config, m_exp, spectrum_expansion_devices, nullptr);
m_exp->irq_handler().set(DEVICE_SELF_OWNER, FUNC(spectrum_expansion_slot_device::irq_w));
@@ -146,6 +153,8 @@ spectrum_flpone_device::spectrum_flpone_device(const machine_config &mconfig, co
, m_fdc(*this, "fdc")
, m_floppy(*this, "fdc:%u", 0)
, m_exp(*this, "exp")
+ , m_centronics(*this, "centronics")
+ , m_rs232(*this, "rs232")
, m_sw1(*this, "SW1")
, m_sw2(*this, "SW2")
{
@@ -161,6 +170,8 @@ void spectrum_flpone_device::device_start()
save_item(NAME(m_romcs));
save_item(NAME(m_ram));
+ save_item(NAME(m_busy));
+ save_item(NAME(m_shifter));
}
//-------------------------------------------------
@@ -171,6 +182,8 @@ void spectrum_flpone_device::device_reset()
{
m_romcs = 0;
m_if1cs = 0;
+ m_busy = 1;
+ m_shifter = 0;
}
//**************************************************************************
@@ -223,10 +236,14 @@ uint8_t spectrum_flpone_device::mreq_r(offs_t offset)
case 0: case 8:
data = m_fdc->read(offset & 3);
break;
- case 4: // D5 - printer BUSY / /BUSY
- data = 0;
+ case 4: // D5 - Centronics /BUSY / RS232 /DSR
+ data &= ~(m_busy << 5);
+ //data &= ~(m_rs232->dsr_r() << 5); // TODO findout how both of these combined at same bit
break;
- case 0xc: // printer STROBE pulse
+ case 0xc: // Centronics STROBE pulse
+ m_centronics->write_strobe(1);
+ m_centronics->write_strobe(0);
+ m_centronics->write_strobe(1);
break;
}
break;
@@ -254,7 +271,19 @@ void spectrum_flpone_device::mreq_w(offs_t offset, uint8_t data)
case 0: case 8:
m_fdc->write(offset & 3, data);
break;
- case 4: // D7 - printer serial data
+ case 4: // D7 - Centronics shifter data / RS232 TX
+ m_shifter = (m_shifter << 1) | BIT(data, 7);
+
+ m_centronics->write_data0(BIT(m_shifter, 0));
+ m_centronics->write_data1(BIT(m_shifter, 1));
+ m_centronics->write_data2(BIT(m_shifter, 2));
+ m_centronics->write_data3(BIT(m_shifter, 3));
+ m_centronics->write_data4(BIT(m_shifter, 4));
+ m_centronics->write_data5(BIT(m_shifter, 5));
+ m_centronics->write_data6(BIT(m_shifter, 6));
+ m_centronics->write_data7(BIT(m_shifter, 7));
+
+ m_rs232->write_txd(BIT(data, 7));
break;
case 0xc:
{
diff --git a/src/devices/bus/spectrum/floppyone.h b/src/devices/bus/spectrum/floppyone.h
index e97fea269f2..944128bbaf7 100644
--- a/src/devices/bus/spectrum/floppyone.h
+++ b/src/devices/bus/spectrum/floppyone.h
@@ -13,6 +13,8 @@
#include "softlist.h"
#include "imagedev/floppy.h"
#include "machine/wd_fdc.h"
+#include "bus/centronics/ctronics.h"
+#include "bus/rs232/rs232.h"
#include "formats/fl1_dsk.h"
//**************************************************************************
@@ -47,16 +49,22 @@ protected:
virtual void mreq_w(offs_t offset, uint8_t data) override;
virtual DECLARE_READ_LINE_MEMBER(romcs) override;
+ DECLARE_WRITE_LINE_MEMBER(busy_w) { m_busy = state; };
+
required_memory_region m_rom;
required_memory_region m_prom;
required_device<wd_fdc_device_base> m_fdc;
required_device_array<floppy_connector, 4> m_floppy;
required_device<spectrum_expansion_slot_device> m_exp;
+ required_device<centronics_device> m_centronics;
+ required_device<rs232_port_device> m_rs232;
required_ioport m_sw1;
required_ioport m_sw2;
int m_romcs, m_if1cs;
u8 m_ram[0x1000];
+ int m_busy;
+ uint8_t m_shifter;
};
diff --git a/src/devices/bus/spectrum/sixword.cpp b/src/devices/bus/spectrum/sixword.cpp
index cbfc21a946a..df0f707f442 100644
--- a/src/devices/bus/spectrum/sixword.cpp
+++ b/src/devices/bus/spectrum/sixword.cpp
@@ -12,16 +12,18 @@
How to use:
Press "Interrupt" button and you'll get into console where you may type commands, like:
C[AT] [drive] - list disk contents, drive 0-3
+ D[ATE] [dd-mm-yy] - set current date, or show firmware build date
F[ORMAT] diskname - format disk
S[AVE] filename - save snapshot to disk
L[OAD] filename - load snapshot from disk
A[LTER] address data - change value in RAM
Q[UIT] - return to BASIC/game
* - reset
- Starting form Swift Disc O/S V2 most of commands may be called from BASIC using syntax like "COMMAND %drive;"filename"", for example:
+ Starting from Swift Disc O/S V2 most of commands may be called from BASIC using syntax like "COMMAND %drive;"filename"", for example:
CAT %0
LOAD %0;"game"
and so on, plus additional commands for sequential file access.
+ FORMAT %#4;"T",1200,79 - printer setup: channel 4, text mode, 1200 baud, 79 column
Manual: https://k1.spdns.de/Vintage/Sinclair/82/Peripherals/Disc%20Interfaces/SixWord%20Swift%20Disc%20Interface/Swift%20Disc%20Operating%20Manual.pdf
@@ -30,12 +32,13 @@
(c) 1989 SIXWORD ltd (UK)
Same as above but extended to 32KB ROM, most of discrete ICs replaced with PALs, smaller form factor.
+ Was available in several favours - with serial or parallel printer port.
It seems RAM was planned to be extended to 16KB, but 2nd RAM IC is not populated on known devices.
- Was available in several favours - with or without printer port, various number of supported drives, etc.
- Dumped v4.2 firmware supports 2 disk drives, but hardware still supports up to 4x.
+ Dumped v4.2 firmware supports only 2 disk drives (but PCB still have wired drive 3 and 4 select) and serial port.
Notes / TODOs:
- - serial printer interface not hooked
+ - serial out not working properly with v4.2 ROM, it produce short TX low pulse after each character, which (mistakenly) considered as start bit by current diserial.cpp.
+ - parallel port hookup based on ROM disassembly and may be not accurate (i.e. ports may require to be enabled by some of m_control bits, or something like that)
*********************************************************************/
@@ -68,6 +71,15 @@ INPUT_PORTS_START(swiftdisc)
PORT_BIT(0xe0, IP_ACTIVE_HIGH, IPT_UNUSED)
INPUT_PORTS_END
+INPUT_PORTS_START(swiftdisc2)
+ PORT_INCLUDE(swiftdisc)
+
+ PORT_START("CONF")
+ PORT_CONFNAME(0x01, 0x01, "Printer intrface")
+ PORT_CONFSETTING(0x01, "Serial")
+ PORT_CONFSETTING(0x00, "Parallel")
+INPUT_PORTS_END
+
//-------------------------------------------------
// input_ports - device-specific input ports
//-------------------------------------------------
@@ -77,6 +89,11 @@ ioport_constructor spectrum_swiftdisc_device::device_input_ports() const
return INPUT_PORTS_NAME(swiftdisc);
}
+ioport_constructor spectrum_swiftdisc2_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(swiftdisc2);
+}
+
//-------------------------------------------------
// SLOT_INTERFACE( floppies )
//-------------------------------------------------
@@ -138,12 +155,23 @@ void spectrum_swiftdisc_device::device_add_mconfig(machine_config &config)
FLOPPY_CONNECTOR(config, "fdc:2", swiftdisc_floppies, nullptr, spectrum_swiftdisc_device::floppy_formats).enable_sound(true);
FLOPPY_CONNECTOR(config, "fdc:3", swiftdisc_floppies, nullptr, spectrum_swiftdisc_device::floppy_formats).enable_sound(true);
+ RS232_PORT(config, m_rs232, default_rs232_devices, "printer");
+
// passthru
SPECTRUM_EXPANSION_SLOT(config, m_exp, spectrum_expansion_devices, nullptr);
m_exp->irq_handler().set(DEVICE_SELF_OWNER, FUNC(spectrum_expansion_slot_device::irq_w));
m_exp->nmi_handler().set(DEVICE_SELF_OWNER, FUNC(spectrum_expansion_slot_device::nmi_w));
}
+void spectrum_swiftdisc2_device::device_add_mconfig(machine_config &config)
+{
+ spectrum_swiftdisc_device::device_add_mconfig(config);
+
+ // parallel printer port
+ CENTRONICS(config, m_centronics, centronics_devices, nullptr);
+ m_centronics->busy_handler().set(FUNC(spectrum_swiftdisc2_device::busy_w));
+}
+
const tiny_rom_entry *spectrum_swiftdisc_device::device_rom_region() const
{
return ROM_NAME(swiftdisc);
@@ -169,6 +197,7 @@ spectrum_swiftdisc_device::spectrum_swiftdisc_device(const machine_config &mconf
, m_fdc(*this, "fdc")
, m_floppy(*this, "fdc:%u", 0)
, m_exp(*this, "exp")
+ , m_rs232(*this, "rs232")
, m_joy(*this, "JOY")
{
}
@@ -180,6 +209,8 @@ spectrum_swiftdisc_device::spectrum_swiftdisc_device(const machine_config &mconf
spectrum_swiftdisc2_device::spectrum_swiftdisc2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: spectrum_swiftdisc_device(mconfig, SPECTRUM_SWIFTDISC2, tag, owner, clock)
+ , m_centronics(*this, "centronics")
+ , m_conf(*this, "CONF")
{
}
@@ -202,6 +233,8 @@ void spectrum_swiftdisc2_device::device_start()
{
spectrum_swiftdisc_device::device_start();
save_item(NAME(m_rambank));
+ save_item(NAME(m_busy));
+ save_item(NAME(m_txd_on));
}
//-------------------------------------------------
@@ -213,12 +246,17 @@ void spectrum_swiftdisc_device::device_reset()
m_romcs = 0;
m_rombank = 0;
m_control = 0;
+ m_rs232->write_txd(1);
}
void spectrum_swiftdisc2_device::device_reset()
{
spectrum_swiftdisc_device::device_reset();
m_rambank = 0;
+ m_busy = 0;
+ m_txd_on = 0;
+ m_rs232->write_dtr(1);
+ m_centronics->write_strobe(1);
}
//**************************************************************************
@@ -268,7 +306,12 @@ uint8_t spectrum_swiftdisc_device::mreq_r(offs_t offset)
if (!BIT(offset, 3))
data = m_fdc->read(offset & 3);
else
- data = 0; // D0 - DTR input, D1 - RX input
+ {
+ // D0 - RS232 DSR, D1 - RS232 RX
+ data &= ~3;
+ data |= m_rs232->dsr_r() << 0;
+ data |= m_rs232->rxd_r() << 1;
+ }
break;
}
}
@@ -306,8 +349,9 @@ void spectrum_swiftdisc_device::mreq_w(offs_t offset, uint8_t data)
m_rombank &= ~0x2000;
m_rombank |= BIT(data, 5) << 13;
+ // D3 - RS232 /TX
+ m_rs232->write_txd(!BIT(data, 3));
m_control = data;
- // D3 - /TX output
}
break;
case 0x1000:
@@ -387,7 +431,7 @@ uint8_t spectrum_swiftdisc2_device::mreq_r(offs_t offset)
if (!BIT(offset, 4))
data = m_fdc->read(offset & 3);
else
- data &= ~1; // D0 - nc, but seems was planned to do something, leftover from prev version ?
+ data = control_r();
break;
}
}
@@ -436,22 +480,35 @@ uint8_t spectrum_swiftdisc2_device::iorq_r(offs_t offset)
uint8_t data = m_exp->iorq_r(offset);
if (m_romcs && (offset & 0xf890) == 0x3000)
- data &= ~1; // IO port mirror
+ data &= control_r();
if (!BIT(offset, 5) && !BIT(m_control, 3))
data = m_joy->read();
- if (BIT(m_control, 2))
+ if (m_conf->read())
{
- if (!BIT(offset, 3))
+ if (BIT(m_control, 2))
{
- data |= 0x80; // D7 - /serial input
+ if (!BIT(offset, 3)) // port F7
+ {
+ // D7 - RS232 /RX
+ data &= ~(m_rs232->rxd_r() << 7);
+ }
+ if (!BIT(offset, 4)) // port EF
+ {
+ data &= ~4;
+ data |= 0x0b;
+ // D3 - RS232 /DSR
+ data &= ~(m_rs232->dsr_r() << 3);
+ }
}
- if (!BIT(offset, 4))
+ }
+ else
+ {
+ if (!BIT(offset, 3)) // port F7
{
- data &= ~0x0f;
- data |= 3;
- data |= 8; // D3 - /serial input
+ // D7 - Centronics /BUSY
+ data &= ~(m_busy << 7);
}
}
@@ -463,22 +520,57 @@ void spectrum_swiftdisc2_device::iorq_w(offs_t offset, uint8_t data)
if (m_romcs && (offset & 0xf890) == 0x3000)
control_w(data);
- if (BIT(m_control, 2))
+ if (m_conf->read())
{
- if (!BIT(offset, 3))
+ if (BIT(m_control, 2))
{
- // D0 - /serial output
+ if (!BIT(offset, 3)) // port F7
+ {
+ // D0 - RS232 /TX
+ if (m_txd_on)
+ m_rs232->write_txd(!BIT(data, 0));
+ }
+ if (!BIT(offset, 4)) // port EF
+ {
+ // D0 - 0=reset /TX latch (set output to 1)
+ // D4 - RS232 /DTR
+ m_txd_on = BIT(data, 0);
+ if (!m_txd_on)
+ m_rs232->write_txd(1);
+ m_rs232->write_dtr(!BIT(data, 4));
+ }
}
- if (!BIT(offset, 4))
+ }
+ else
+ {
+ if (!BIT(offset, 3)) // F7
+ {
+ // D0 - Centronics /STROBE
+ m_centronics->write_strobe(BIT(data, 0));
+ }
+ if (!BIT(offset, 4)) // EF
{
- // D0 - 0=reset above latch
- // D4 - /serial output
+ // D0 - D7 - Centronics data
+ m_centronics->write_data0(BIT(data, 0));
+ m_centronics->write_data1(BIT(data, 1));
+ m_centronics->write_data2(BIT(data, 2));
+ m_centronics->write_data3(BIT(data, 3));
+ m_centronics->write_data4(BIT(data, 4));
+ m_centronics->write_data5(BIT(data, 5));
+ m_centronics->write_data6(BIT(data, 6));
+ m_centronics->write_data7(BIT(data, 7));
}
}
m_exp->iorq_w(offset, data);
}
+uint8_t spectrum_swiftdisc2_device::control_r()
+{
+ // D0 - printer interface type, 0 - parallel, 1 - serial
+ return 0xfe | m_conf->read();
+}
+
void spectrum_swiftdisc2_device::control_w(uint8_t data)
{
floppy_image_device* floppy = nullptr;
diff --git a/src/devices/bus/spectrum/sixword.h b/src/devices/bus/spectrum/sixword.h
index 1ed63bb28bd..f0a369f6328 100644
--- a/src/devices/bus/spectrum/sixword.h
+++ b/src/devices/bus/spectrum/sixword.h
@@ -12,6 +12,8 @@
#include "softlist.h"
#include "imagedev/floppy.h"
#include "machine/wd_fdc.h"
+#include "bus/centronics/ctronics.h"
+#include "bus/rs232/rs232.h"
#include "formats/swd_dsk.h"
//**************************************************************************
@@ -53,6 +55,7 @@ protected:
required_device<wd_fdc_device_base> m_fdc;
required_device_array<floppy_connector, 4> m_floppy;
required_device<spectrum_expansion_slot_device> m_exp;
+ required_device<rs232_port_device> m_rs232;
required_ioport m_joy;
int m_romcs;
@@ -73,6 +76,9 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
+ virtual ioport_constructor device_input_ports() const override;
+
+ virtual void device_add_mconfig(machine_config &config) override;
virtual const tiny_rom_entry *device_rom_region() const override;
virtual void post_opcode_fetch(offs_t offset) override;
@@ -80,10 +86,17 @@ protected:
virtual void mreq_w(offs_t offset, uint8_t data) override;
virtual uint8_t iorq_r(offs_t offset) override;
virtual void iorq_w(offs_t offset, uint8_t data) override;
+ DECLARE_WRITE_LINE_MEMBER(busy_w) { m_busy = state; };
+
+ required_device<centronics_device> m_centronics;
+ required_ioport m_conf;
+ uint8_t control_r();
void control_w(uint8_t data);
int m_rambank;
+ int m_busy;
+ int m_txd_on;
};