From dd67f283574b55da3a3b0db466827edfe3c60caf Mon Sep 17 00:00:00 2001 From: mahlemiut Date: Thu, 24 Apr 2014 00:15:14 +0000 Subject: [PATCH] amstrad: added preliminary Amstrad/Pace RS232C interface. The terminal software included with the original Amstrad interface works, but not much else does at this stage. [Barry Rodewald] Out of whatsnew: HoneyTerm (part of the later Pace interface) expects bit 6 of RR0 on the Z80DART to be set (seems to unsupported in the current z80dart device). Not sure on why other software doesn't work as yet. --- .gitattributes | 2 + src/emu/bus/bus.mak | 1 + src/emu/bus/cpc/cpc_rs232.c | 147 ++++++++++++++++++++++++++++++++++++ src/emu/bus/cpc/cpc_rs232.h | 50 ++++++++++++ src/mess/drivers/amstrad.c | 2 + src/mess/includes/amstrad.h | 1 + 6 files changed, 203 insertions(+) create mode 100644 src/emu/bus/cpc/cpc_rs232.c create mode 100644 src/emu/bus/cpc/cpc_rs232.h diff --git a/.gitattributes b/.gitattributes index bb0cc376b00..d4488c071c0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -753,6 +753,8 @@ src/emu/bus/cpc/cpc_pds.c svneol=native#text/plain src/emu/bus/cpc/cpc_pds.h svneol=native#text/plain src/emu/bus/cpc/cpc_rom.c svneol=native#text/plain src/emu/bus/cpc/cpc_rom.h svneol=native#text/plain +src/emu/bus/cpc/cpc_rs232.c svneol=native#text/plain +src/emu/bus/cpc/cpc_rs232.h svneol=native#text/plain src/emu/bus/cpc/cpc_ssa1.c svneol=native#text/plain src/emu/bus/cpc/cpc_ssa1.h svneol=native#text/plain src/emu/bus/cpc/cpcexp.c svneol=native#text/plain diff --git a/src/emu/bus/bus.mak b/src/emu/bus/bus.mak index b36b6a79b48..c16ea7c153b 100644 --- a/src/emu/bus/bus.mak +++ b/src/emu/bus/bus.mak @@ -974,6 +974,7 @@ BUSOBJS += $(BUSOBJ)/cpc/cpcexp.o BUSOBJS += $(BUSOBJ)/cpc/cpc_ssa1.o BUSOBJS += $(BUSOBJ)/cpc/cpc_rom.o BUSOBJS += $(BUSOBJ)/cpc/cpc_pds.o +BUSOBJS += $(BUSOBJ)/cpc/cpc_rs232.o BUSOBJS += $(BUSOBJ)/cpc/mface2.o endif diff --git a/src/emu/bus/cpc/cpc_rs232.c b/src/emu/bus/cpc/cpc_rs232.c new file mode 100644 index 00000000000..8c991c812ec --- /dev/null +++ b/src/emu/bus/cpc/cpc_rs232.c @@ -0,0 +1,147 @@ +/* + * cpc_rs232.c + * + * Created on: 22/04/2014 + */ + +#include "cpc_rs232.h" +#include "includes/amstrad.h" + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type CPC_RS232 = &device_creator; + +Z80DART_INTERFACE(dart_intf) +{ + 0, //m_rxca; + 0, //m_txca; + 0, //m_rxcb; + 0, //m_txcb; + + DEVCB_DEVICE_LINE_MEMBER("rs232",rs232_port_device,write_txd), //m_out_txda_cb; + DEVCB_DEVICE_LINE_MEMBER("rs232",rs232_port_device,write_dtr), //m_out_dtra_cb; + DEVCB_DEVICE_LINE_MEMBER("rs232",rs232_port_device,write_rts), //m_out_rtsa_cb; + DEVCB_NULL, //m_out_wrdya_cb; + DEVCB_NULL, //m_out_synca_cb; + + DEVCB_NULL, //m_out_txdb_cb; + DEVCB_NULL, //m_out_dtrb_cb; + DEVCB_NULL, //m_out_rtsb_cb; + DEVCB_NULL, //m_out_wrdyb_cb; + DEVCB_NULL, //m_out_syncb_cb; + + DEVCB_NULL, //m_out_int_cb; + DEVCB_NULL, //m_out_rxdrqa_cb; + DEVCB_NULL, //m_out_txdrqa_cb; + DEVCB_NULL, //m_out_rxdrqb_cb; + DEVCB_NULL //m_out_txdrqb_cb; +}; + + +// device machine config +static MACHINE_CONFIG_FRAGMENT( cpc_rs232 ) + MCFG_DEVICE_ADD("pit", PIT8253, 0) + MCFG_PIT8253_CLK0(2000000) + MCFG_PIT8253_CLK1(2000000) + MCFG_PIT8253_CLK2(2000000) + MCFG_PIT8253_OUT0_HANDLER(WRITELINE(cpc_rs232_device, pit_out0_w)) + MCFG_PIT8253_OUT1_HANDLER(WRITELINE(cpc_rs232_device, pit_out1_w)) + MCFG_PIT8253_OUT2_HANDLER(WRITELINE(cpc_rs232_device, pit_out2_w)) + + MCFG_Z80DART_ADD("dart", XTAL_4MHz, dart_intf) + + MCFG_RS232_PORT_ADD("rs232",default_rs232_devices,NULL) + MCFG_RS232_RXD_HANDLER(DEVWRITELINE("dart",z80dart_device,rxa_w)) + MCFG_RS232_DCD_HANDLER(DEVWRITELINE("dart",z80dart_device,dcda_w)) + MCFG_RS232_CTS_HANDLER(DEVWRITELINE("dart",z80dart_device,ctsa_w)) +// MCFG_RS232_RI_HANDLER(DEVWRITELINE("dart",z80dart_device,ria_w)) + + // pass-through + MCFG_DEVICE_ADD("exp", CPC_EXPANSION_SLOT, 0) + MCFG_DEVICE_SLOT_INTERFACE(cpc_exp_cards, NULL, false) + MCFG_CPC_EXPANSION_SLOT_OUT_IRQ_CB(DEVWRITELINE("^", cpc_expansion_slot_device, irq_w)) + MCFG_CPC_EXPANSION_SLOT_OUT_NMI_CB(DEVWRITELINE("^", cpc_expansion_slot_device, nmi_w)) + MCFG_CPC_EXPANSION_SLOT_OUT_ROMDIS_CB(DEVWRITELINE("^", cpc_expansion_slot_device, romdis_w)) // ROMDIS + MCFG_CPC_EXPANSION_SLOT_OUT_ROMEN_CB(DEVWRITELINE("^", cpc_expansion_slot_device, romen_w)) // /ROMEN + +MACHINE_CONFIG_END + +machine_config_constructor cpc_rs232_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( cpc_rs232 ); +} + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +cpc_rs232_device::cpc_rs232_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, CPC_RS232, "Amstrad/Pace RS232C interface", tag, owner, clock, "cpc_ser", __FILE__), + device_cpc_expansion_card_interface(mconfig, *this), + m_pit(*this,"pit"), + m_dart(*this,"dart"), + m_rs232(*this,"rs232") +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void cpc_rs232_device::device_start() +{ + device_t* cpu = machine().device("maincpu"); + address_space& space = cpu->memory().space(AS_IO); + m_slot = dynamic_cast(owner()); + + space.install_readwrite_handler(0xfadc,0xfadf,0,0,read8_delegate(FUNC(cpc_rs232_device::dart_r),this),write8_delegate(FUNC(cpc_rs232_device::dart_w),this)); + space.install_readwrite_handler(0xfbdc,0xfbdf,0,0,read8_delegate(FUNC(cpc_rs232_device::pit_r),this),write8_delegate(FUNC(cpc_rs232_device::pit_w),this)); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void cpc_rs232_device::device_reset() +{ +} + + +WRITE_LINE_MEMBER(cpc_rs232_device::pit_out0_w) +{ + m_dart->txca_w(state); +} + +WRITE_LINE_MEMBER(cpc_rs232_device::pit_out1_w) +{ + m_dart->rxca_w(state); +} + +WRITE_LINE_MEMBER(cpc_rs232_device::pit_out2_w) +{ + m_dart->txcb_w(state); + m_dart->rxcb_w(state); +} + +READ8_MEMBER(cpc_rs232_device::dart_r) +{ + return m_dart->ba_cd_r(space,offset); +} + +WRITE8_MEMBER(cpc_rs232_device::dart_w) +{ + m_dart->ba_cd_w(space,offset,data); +} + +READ8_MEMBER(cpc_rs232_device::pit_r) +{ + return m_pit->read(space,offset); +} + +WRITE8_MEMBER(cpc_rs232_device::pit_w) +{ + m_pit->write(space,offset,data); +} diff --git a/src/emu/bus/cpc/cpc_rs232.h b/src/emu/bus/cpc/cpc_rs232.h new file mode 100644 index 00000000000..9ec118adbc6 --- /dev/null +++ b/src/emu/bus/cpc/cpc_rs232.h @@ -0,0 +1,50 @@ +/* + * cpc_rs232.h + * + * Created on: 22/04/2014 + */ + +#ifndef CPC_RS232_H_ +#define CPC_RS232_H_ + +#include "emu.h" +#include "machine/z80dart.h" +#include "machine/pit8253.h" +#include "bus/rs232/rs232.h" +#include "cpcexp.h" + +class cpc_rs232_device : public device_t, + public device_cpc_expansion_card_interface +{ +public: + // construction/destruction + cpc_rs232_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual machine_config_constructor device_mconfig_additions() const; + + DECLARE_WRITE_LINE_MEMBER(pit_out0_w); + DECLARE_WRITE_LINE_MEMBER(pit_out1_w); + DECLARE_WRITE_LINE_MEMBER(pit_out2_w); + + DECLARE_READ8_MEMBER(dart_r); + DECLARE_WRITE8_MEMBER(dart_w); + DECLARE_READ8_MEMBER(pit_r); + DECLARE_WRITE8_MEMBER(pit_w); + + required_device m_pit; + required_device m_dart; + required_device m_rs232; +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + +private: + cpc_expansion_slot_device *m_slot; +}; + +// device type definition +extern const device_type CPC_RS232; + +#endif /* CPC_RS232_H_ */ diff --git a/src/mess/drivers/amstrad.c b/src/mess/drivers/amstrad.c index 135839abd0f..41d37f4fac9 100644 --- a/src/mess/drivers/amstrad.c +++ b/src/mess/drivers/amstrad.c @@ -835,6 +835,7 @@ SLOT_INTERFACE_START(cpc_exp_cards) SLOT_INTERFACE("rom", CPC_ROM) SLOT_INTERFACE("multiface2", CPC_MFACE2) SLOT_INTERFACE("pds", CPC_PDS) + SLOT_INTERFACE("rs232", CPC_RS232) SLOT_INTERFACE_END SLOT_INTERFACE_START(cpcplus_exp_cards) @@ -842,6 +843,7 @@ SLOT_INTERFACE_START(cpcplus_exp_cards) SLOT_INTERFACE("dkspeech", CPC_DKSPEECH) SLOT_INTERFACE("rom", CPC_ROM) SLOT_INTERFACE("pds", CPC_PDS) + SLOT_INTERFACE("rs232", CPC_RS232) SLOT_INTERFACE_END static MACHINE_CONFIG_START( amstrad_nofdc, amstrad_state ) diff --git a/src/mess/includes/amstrad.h b/src/mess/includes/amstrad.h index 39c89a0c99a..1010953c75e 100644 --- a/src/mess/includes/amstrad.h +++ b/src/mess/includes/amstrad.h @@ -19,6 +19,7 @@ #include "bus/cpc/cpc_rom.h" #include "bus/cpc/mface2.h" #include "bus/cpc/cpc_pds.h" +#include "bus/cpc/cpc_rs232.h" #include "machine/ram.h" #include "imagedev/cassette.h" #include "bus/centronics/ctronics.h"