diff options
author | 2014-02-15 01:29:27 +0000 | |
---|---|---|
committer | 2014-02-15 01:29:27 +0000 | |
commit | b37d92de7246ff7da31a235b996e89db6f8c8d22 (patch) | |
tree | 616a8439278f4ff3331b677c9b841ed71657290a /src/emu/bus/rs232/rs232.c | |
parent | 88bc8a4673a710bdcdd2640f39b3b33bc2b76ab0 (diff) |
created src\emu\bus\rs232 & src\emu\bus\midi directories and separated rs232 and midi devices, changed h89 to use an rs232 port to communicate with the serial terminal to instead of connecting it directly. [smf]
Diffstat (limited to 'src/emu/bus/rs232/rs232.c')
-rw-r--r-- | src/emu/bus/rs232/rs232.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/src/emu/bus/rs232/rs232.c b/src/emu/bus/rs232/rs232.c new file mode 100644 index 00000000000..0d8778070ba --- /dev/null +++ b/src/emu/bus/rs232/rs232.c @@ -0,0 +1,99 @@ +#include "rs232.h" + +const device_type RS232_PORT = &device_creator<rs232_port_device>; + +rs232_port_device::rs232_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, RS232_PORT, "RS232 Port", tag, owner, clock, "rs232", __FILE__), + device_slot_interface(mconfig, *this), + m_rxd_handler(*this), + m_dcd_handler(*this), + m_dsr_handler(*this), + m_ri_handler(*this), + m_cts_handler(*this), + m_dev(NULL) +{ +} + +rs232_port_device::rs232_port_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) + : device_t(mconfig, type, name, tag, owner, clock, shortname, source), + device_slot_interface(mconfig, *this), + m_rxd_handler(*this), + m_dcd_handler(*this), + m_dsr_handler(*this), + m_ri_handler(*this), + m_cts_handler(*this), + m_dev(NULL) +{ +} + +rs232_port_device::~rs232_port_device() +{ +} + +void rs232_port_device::device_config_complete() +{ + m_dev = dynamic_cast<device_rs232_port_interface *>(get_card_device()); +} + +void rs232_port_device::device_start() +{ + m_rxd_handler.resolve_safe(); + m_dcd_handler.resolve_safe(); + m_dsr_handler.resolve_safe(); + m_ri_handler.resolve_safe(); + m_cts_handler.resolve_safe(); + + save_item(NAME(m_rxd)); + save_item(NAME(m_dcd)); + save_item(NAME(m_dsr)); + save_item(NAME(m_ri)); + save_item(NAME(m_cts)); + + m_rxd = 1; + m_dcd = 0; + m_dsr = 0; + m_ri = 0; + m_cts = 0; + + m_rxd_handler(1); + m_dcd_handler(0); + m_dsr_handler(0); + m_ri_handler(0); + m_cts_handler(0); +} + +WRITE_LINE_MEMBER( rs232_port_device::write_txd ) +{ + if(m_dev) + m_dev->input_txd(state); +} + +WRITE_LINE_MEMBER( rs232_port_device::write_dtr ) +{ + if(m_dev) + m_dev->input_dtr(state); +} + +WRITE_LINE_MEMBER( rs232_port_device::write_rts ) +{ + if(m_dev) + return m_dev->input_rts(state); +} + +#include "null_modem.h" +#include "terminal.h" + +device_rs232_port_interface::device_rs232_port_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device) +{ + m_port = dynamic_cast<rs232_port_device *>(device.owner()); +} + +device_rs232_port_interface::~device_rs232_port_interface() +{ +} + +SLOT_INTERFACE_START( default_rs232_devices ) + SLOT_INTERFACE("serial_terminal", SERIAL_TERMINAL) + SLOT_INTERFACE("null_modem", NULL_MODEM) +SLOT_INTERFACE_END |