Skip to content

Commit b1da4a1

Browse files
committed
bus/a2gameio: Add serial printer interface [AJR]
1 parent 957db01 commit b1da4a1

4 files changed

Lines changed: 151 additions & 4 deletions

File tree

scripts/src/bus.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,18 @@ if BUSES["A2GAMEIO"] then
212212
MAME_DIR .. "src/devices/bus/a2gameio/computereyes.h",
213213
MAME_DIR .. "src/devices/bus/a2gameio/gameio.cpp",
214214
MAME_DIR .. "src/devices/bus/a2gameio/gameio.h",
215-
MAME_DIR .. "src/devices/bus/a2gameio/joystick.cpp",
216-
MAME_DIR .. "src/devices/bus/a2gameio/joystick.h",
215+
MAME_DIR .. "src/devices/bus/a2gameio/gizmo.cpp",
216+
MAME_DIR .. "src/devices/bus/a2gameio/gizmo.h",
217217
MAME_DIR .. "src/devices/bus/a2gameio/joyport.cpp",
218218
MAME_DIR .. "src/devices/bus/a2gameio/joyport.h",
219219
MAME_DIR .. "src/devices/bus/a2gameio/joyport_paddles.cpp",
220220
MAME_DIR .. "src/devices/bus/a2gameio/joyport_paddles.h",
221+
MAME_DIR .. "src/devices/bus/a2gameio/joystick.cpp",
222+
MAME_DIR .. "src/devices/bus/a2gameio/joystick.h",
221223
MAME_DIR .. "src/devices/bus/a2gameio/paddles.cpp",
222224
MAME_DIR .. "src/devices/bus/a2gameio/paddles.h",
223-
MAME_DIR .. "src/devices/bus/a2gameio/gizmo.cpp",
224-
MAME_DIR .. "src/devices/bus/a2gameio/gizmo.h",
225+
MAME_DIR .. "src/devices/bus/a2gameio/serial.cpp",
226+
MAME_DIR .. "src/devices/bus/a2gameio/serial.h",
225227
MAME_DIR .. "src/devices/bus/a2gameio/wico_joystick.cpp",
226228
MAME_DIR .. "src/devices/bus/a2gameio/wico_joystick.h",
227229
}

src/devices/bus/a2gameio/gameio.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "bus/a2gameio/paddles.h"
6060
#include "bus/a2gameio/gizmo.h"
6161
#include "bus/a2gameio/wico_joystick.h"
62+
#include "bus/a2gameio/serial.h"
6263

6364
//**************************************************************************
6465
// CONNECTOR DEVICE IMPLEMENTATION
@@ -85,6 +86,7 @@ void apple2_gameio_device::iiandplus_options(device_slot_interface &slot)
8586
slot.option_add("compeyes", APPLE2_COMPUTEREYES);
8687
slot.option_add("wicojoy", APPLE2_WICO_JOYSTICK);
8788
slot.option_add("brightpen", APPLE2_BRIGHTPEN);
89+
slot.option_add("serial", APPLE2_GAMEIO_SERIAL);
8890
}
8991

9092
void apple2_gameio_device::default_options(device_slot_interface &slot)
@@ -93,6 +95,7 @@ void apple2_gameio_device::default_options(device_slot_interface &slot)
9395
slot.option_add("paddles", APPLE2_PADDLES);
9496
slot.option_add("gizmo", APPLE2_GIZMO);
9597
slot.option_add("compeyes", APPLE2_COMPUTEREYES);
98+
slot.option_add("serial", APPLE2_GAMEIO_SERIAL);
9699
}
97100

98101
void apple2_gameio_device::joystick_options(device_slot_interface &slot)
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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")

src/devices/bus/a2gameio/serial.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// license:BSD-3-Clause
2+
// copyright-holders:AJR
3+
4+
#ifndef MAME_BUS_A2GAMEIO_SERIAL_H
5+
#define MAME_BUS_A2GAMEIO_SERIAL_H
6+
7+
#pragma once
8+
9+
#include "bus/a2gameio/gameio.h"
10+
11+
// device type declaration
12+
DECLARE_DEVICE_TYPE(APPLE2_GAMEIO_SERIAL, device_a2gameio_interface)
13+
14+
#endif // MAME_BUS_A2GAMEIO_SERIAL_H

0 commit comments

Comments
 (0)