|
| 1 | +// license:BSD-3-Clause |
| 2 | +// copyright-holders:AJR |
| 3 | +/********************************************************************* |
| 4 | +
|
| 5 | + Serial printer interface for Apple II Game I/O connector |
| 6 | +
|
| 7 | + This bitbanged RS-232 adapter connects annunciator #0 to a serial |
| 8 | + transmit line using either discrete transistors or a MC1488 |
| 9 | + driver. Software drivers for this type of interface (which works |
| 10 | + best at low baud rates) are listed in the Apple II Reference |
| 11 | + Manual ("A Simple Serial Output," p. 114–121) and in various |
| 12 | + hobbyist magazine articles. A few commercial programs also |
| 13 | + support it. |
| 14 | +
|
| 15 | +*********************************************************************/ |
| 16 | + |
| 17 | +#include "emu.h" |
| 18 | +#include "bus/a2gameio/serial.h" |
| 19 | + |
| 20 | +#include "bus/rs232/rs232.h" |
| 21 | + |
| 22 | + |
| 23 | +namespace { |
| 24 | + |
| 25 | +//************************************************************************** |
| 26 | +// TYPE DEFINITIONS |
| 27 | +//************************************************************************** |
| 28 | + |
| 29 | +// ======================> apple2_gameio_serial_device |
| 30 | + |
| 31 | +class apple2_gameio_serial_device : public device_t, public device_a2gameio_interface |
| 32 | +{ |
| 33 | +public: |
| 34 | + // construction/destruction |
| 35 | + apple2_gameio_serial_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); |
| 36 | + |
| 37 | +protected: |
| 38 | + // device-level overrides |
| 39 | + virtual ioport_constructor device_input_ports() const override ATTR_COLD; |
| 40 | + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; |
| 41 | + virtual void device_start() override ATTR_COLD; |
| 42 | + |
| 43 | + // device_a2gameio_interface overrides |
| 44 | + virtual int sw0_r() override; |
| 45 | + virtual void an0_w(int state) override; |
| 46 | + virtual bool has_sw0() const override { return true; } |
| 47 | + |
| 48 | +private: |
| 49 | + // device finders |
| 50 | + required_device<rs232_port_device> m_rs232; |
| 51 | + |
| 52 | + // input ports |
| 53 | + required_ioport m_config; |
| 54 | +}; |
| 55 | + |
| 56 | + |
| 57 | +//************************************************************************** |
| 58 | +// DEVICE CONFIGURATION |
| 59 | +//************************************************************************** |
| 60 | + |
| 61 | +static INPUT_PORTS_START(gameio_serial) |
| 62 | + PORT_START("CONFIG") |
| 63 | + PORT_CONFNAME(0x01, 0x01, "Ready input") |
| 64 | + /* |
| 65 | + "If your printer is not equipped with a read ready signal, connect Game I/O pin 2 to pin 1. |
| 66 | + This causes continual output without interruption, a state that can be dealt with only by |
| 67 | + the hardiest of printers." |
| 68 | + — Hayden Apple Assembly Language Development System manual, appendix A |
| 69 | + */ |
| 70 | + PORT_CONFSETTING(0x00, DEF_STR(None)) |
| 71 | + PORT_CONFSETTING(0x01, "DSR") |
| 72 | +INPUT_PORTS_END |
| 73 | + |
| 74 | +ioport_constructor apple2_gameio_serial_device::device_input_ports() const |
| 75 | +{ |
| 76 | + return INPUT_PORTS_NAME(gameio_serial); |
| 77 | +} |
| 78 | + |
| 79 | +void apple2_gameio_serial_device::device_add_mconfig(machine_config &config) |
| 80 | +{ |
| 81 | + RS232_PORT(config, m_rs232, default_rs232_devices, "printer"); |
| 82 | +} |
| 83 | + |
| 84 | + |
| 85 | +//************************************************************************** |
| 86 | +// DEVICE IMPLEMENTATION |
| 87 | +//************************************************************************** |
| 88 | + |
| 89 | +apple2_gameio_serial_device::apple2_gameio_serial_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) |
| 90 | + : device_t(mconfig, APPLE2_GAMEIO_SERIAL, tag, owner, clock) |
| 91 | + , device_a2gameio_interface(mconfig, *this) |
| 92 | + , m_rs232(*this, "rs232") |
| 93 | + , m_config(*this, "CONFIG") |
| 94 | +{ |
| 95 | +} |
| 96 | + |
| 97 | +void apple2_gameio_serial_device::device_start() |
| 98 | +{ |
| 99 | +} |
| 100 | + |
| 101 | +void apple2_gameio_serial_device::an0_w(int state) |
| 102 | +{ |
| 103 | + // Apple II: $C058 = mark, $C059 = space |
| 104 | + m_rs232->write_txd(!state); |
| 105 | +} |
| 106 | + |
| 107 | +int apple2_gameio_serial_device::sw0_r() |
| 108 | +{ |
| 109 | + // 1 = ready, 0 = not ready |
| 110 | + switch (m_config->read()) |
| 111 | + { |
| 112 | + case 0x01: |
| 113 | + return !m_rs232->dsr_r(); |
| 114 | + |
| 115 | + default: |
| 116 | + return 1; |
| 117 | + } |
| 118 | +} |
| 119 | + |
| 120 | +} // anonymous namespace |
| 121 | + |
| 122 | + |
| 123 | +//************************************************************************** |
| 124 | +// GLOBAL VARIABLES |
| 125 | +//************************************************************************** |
| 126 | + |
| 127 | +// device type definition |
| 128 | +DEFINE_DEVICE_TYPE_PRIVATE(APPLE2_GAMEIO_SERIAL, device_a2gameio_interface, apple2_gameio_serial_device, "a2gameio_serial", "Apple II Game I/O serial printer interface") |
0 commit comments