summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author smf- <smf-@users.noreply.github.com>2014-02-15 01:29:27 +0000
committer smf- <smf-@users.noreply.github.com>2014-02-15 01:29:27 +0000
commitb37d92de7246ff7da31a235b996e89db6f8c8d22 (patch)
tree616a8439278f4ff3331b677c9b841ed71657290a /src/emu
parent88bc8a4673a710bdcdd2640f39b3b33bc2b76ab0 (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')
-rw-r--r--src/emu/bus/a2bus/a2midi.c13
-rw-r--r--src/emu/bus/a2bus/a2midi.h4
-rw-r--r--src/emu/bus/a2bus/a2ssc.c16
-rw-r--r--src/emu/bus/a2bus/a2ssc.h1
-rw-r--r--src/emu/bus/bus.mak24
-rw-r--r--src/emu/bus/c64/midi_maplin.c11
-rw-r--r--src/emu/bus/c64/midi_maplin.h4
-rw-r--r--src/emu/bus/c64/midi_namesoft.c11
-rw-r--r--src/emu/bus/c64/midi_namesoft.h4
-rw-r--r--src/emu/bus/c64/midi_passport.c11
-rw-r--r--src/emu/bus/c64/midi_passport.h4
-rw-r--r--src/emu/bus/c64/midi_sci.c11
-rw-r--r--src/emu/bus/c64/midi_sci.h4
-rw-r--r--src/emu/bus/c64/midi_siel.c11
-rw-r--r--src/emu/bus/c64/midi_siel.h4
-rw-r--r--src/emu/bus/c64/swiftlink.c11
-rw-r--r--src/emu/bus/c64/swiftlink.h2
-rw-r--r--src/emu/bus/c64/turbo232.c10
-rw-r--r--src/emu/bus/c64/turbo232.h5
-rw-r--r--src/emu/bus/ieee488/hardbox.c5
-rw-r--r--src/emu/bus/ieee488/hardbox.h6
-rw-r--r--src/emu/bus/ieee488/shark.c3
-rw-r--r--src/emu/bus/ieee488/shark.h4
-rw-r--r--src/emu/bus/ieee488/softbox.c19
-rw-r--r--src/emu/bus/ieee488/softbox.h8
-rw-r--r--src/emu/bus/midi/midi.c40
-rw-r--r--src/emu/bus/midi/midi.h62
-rw-r--r--src/emu/bus/midi/midiinport.c32
-rw-r--r--src/emu/bus/midi/midiinport.h34
-rw-r--r--src/emu/bus/midi/midioutport.c27
-rw-r--r--src/emu/bus/midi/midioutport.h34
-rw-r--r--src/emu/bus/pet/superpet.c12
-rw-r--r--src/emu/bus/pet/superpet.h3
-rw-r--r--src/emu/bus/rs232/keyboard.c184
-rw-r--r--src/emu/bus/rs232/keyboard.h64
-rw-r--r--src/emu/bus/rs232/null_modem.c27
-rw-r--r--src/emu/bus/rs232/null_modem.h27
-rw-r--r--src/emu/bus/rs232/rs232.c99
-rw-r--r--src/emu/bus/rs232/rs232.h100
-rw-r--r--src/emu/bus/rs232/ser_mouse.c248
-rw-r--r--src/emu/bus/rs232/ser_mouse.h86
-rw-r--r--src/emu/bus/rs232/terminal.c157
-rw-r--r--src/emu/bus/rs232/terminal.h45
-rw-r--r--src/emu/bus/s100/wunderbus.c49
-rw-r--r--src/emu/bus/s100/wunderbus.h2
-rw-r--r--src/emu/bus/vic20/vic1011.c14
-rw-r--r--src/emu/bus/vic20/vic1011.h3
-rw-r--r--src/emu/emu.mak12
-rw-r--r--src/emu/machine/keyboard.c364
-rw-r--r--src/emu/machine/keyboard.h69
-rw-r--r--src/emu/machine/terminal.c415
-rw-r--r--src/emu/machine/terminal.h75
52 files changed, 2342 insertions, 148 deletions
diff --git a/src/emu/bus/a2bus/a2midi.c b/src/emu/bus/a2bus/a2midi.c
index eddf833895a..3b026667acd 100644
--- a/src/emu/bus/a2bus/a2midi.c
+++ b/src/emu/bus/a2bus/a2midi.c
@@ -6,9 +6,10 @@
*********************************************************************/
-#include "emu.h"
-#include "includes/apple2.h"
#include "a2midi.h"
+#include "bus/midi/midi.h"
+#include "bus/midi/midiinport.h"
+#include "bus/midi/midioutport.h"
/***************************************************************************
@@ -36,7 +37,7 @@ static ACIA6850_INTERFACE( acia_interface )
{
31250*16, // tx clock
0, // rx clock (we manually clock rx)
- DEVCB_DEVICE_LINE_MEMBER("mdout", serial_port_device, tx), // tx out
+ DEVCB_DEVICE_LINE_MEMBER("mdout", midi_port_device, write_txd), // tx out
DEVCB_NULL, // rts out
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, a2bus_midi_device, acia_irq_w)
};
@@ -53,10 +54,10 @@ MACHINE_CONFIG_FRAGMENT( midi )
MCFG_PTM6840_ADD(MIDI_PTM_TAG, ptm_interface)
MCFG_ACIA6850_ADD(MIDI_ACIA_TAG, acia_interface)
- MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, a2bus_midi_device, midi_rx_w))
+ MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
+ MCFG_MIDI_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, a2bus_midi_device, midi_rx_w))
- MCFG_SERIAL_PORT_ADD("mdout", midiout_slot, "midiout")
+ MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout")
MACHINE_CONFIG_END
//-------------------------------------------------
diff --git a/src/emu/bus/a2bus/a2midi.h b/src/emu/bus/a2bus/a2midi.h
index 1cd1c447c75..c46e2bb8665 100644
--- a/src/emu/bus/a2bus/a2midi.h
+++ b/src/emu/bus/a2bus/a2midi.h
@@ -9,13 +9,9 @@
#ifndef __A2BUS_MIDI__
#define __A2BUS_MIDI__
-#include "emu.h"
#include "a2bus.h"
#include "machine/6840ptm.h"
#include "machine/6850acia.h"
-#include "machine/serial.h"
-#include "machine/midiinport.h"
-#include "machine/midioutport.h"
//**************************************************************************
// TYPE DEFINITIONS
diff --git a/src/emu/bus/a2bus/a2ssc.c b/src/emu/bus/a2bus/a2ssc.c
index 2b0404bda5a..ec647509737 100644
--- a/src/emu/bus/a2bus/a2ssc.c
+++ b/src/emu/bus/a2bus/a2ssc.c
@@ -6,12 +6,8 @@
*********************************************************************/
-#include "emu.h"
-#include "includes/apple2.h"
#include "a2ssc.h"
-#include "machine/terminal.h"
-#include "machine/null_modem.h"
-#include "machine/serial.h"
+#include "bus/rs232/rs232.h"
/***************************************************************************
@@ -31,13 +27,13 @@ const device_type A2BUS_SSC = &device_creator<a2bus_ssc_device>;
MACHINE_CONFIG_FRAGMENT( ssc )
MCFG_DEVICE_ADD(SSC_ACIA_TAG, MOS6551, XTAL_1_8432MHz)
MCFG_MOS6551_IRQ_HANDLER(WRITELINE(a2bus_ssc_device, acia_irq_w))
- MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE(SSC_RS232_TAG, rs232_port_device, tx))
+ MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE(SSC_RS232_TAG, rs232_port_device, write_txd))
MCFG_RS232_PORT_ADD(SSC_RS232_TAG, default_rs232_devices, NULL)
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(SSC_ACIA_TAG, mos6551_device, rxd_w))
- MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(SSC_ACIA_TAG, mos6551_device, dcd_w))
- MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(SSC_ACIA_TAG, mos6551_device, dsr_w))
- MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(SSC_ACIA_TAG, mos6551_device, cts_w))
+ MCFG_RS232_RXD_HANDLER(DEVWRITELINE(SSC_ACIA_TAG, mos6551_device, rxd_w))
+ MCFG_RS232_DCD_HANDLER(DEVWRITELINE(SSC_ACIA_TAG, mos6551_device, dcd_w))
+ MCFG_RS232_DSR_HANDLER(DEVWRITELINE(SSC_ACIA_TAG, mos6551_device, dsr_w))
+ MCFG_RS232_CTS_HANDLER(DEVWRITELINE(SSC_ACIA_TAG, mos6551_device, cts_w))
MACHINE_CONFIG_END
ROM_START( ssc )
diff --git a/src/emu/bus/a2bus/a2ssc.h b/src/emu/bus/a2bus/a2ssc.h
index ada44ea659e..feeffb306fa 100644
--- a/src/emu/bus/a2bus/a2ssc.h
+++ b/src/emu/bus/a2bus/a2ssc.h
@@ -9,7 +9,6 @@
#ifndef __A2BUS_SSC__
#define __A2BUS_SSC__
-#include "emu.h"
#include "a2bus.h"
#include "machine/mos6551.h"
diff --git a/src/emu/bus/bus.mak b/src/emu/bus/bus.mak
index df272541fd6..820760a9304 100644
--- a/src/emu/bus/bus.mak
+++ b/src/emu/bus/bus.mak
@@ -579,3 +579,27 @@ BUSOBJS += $(BUSOBJ)/centronics/covox.o
BUSOBJS += $(BUSOBJ)/centronics/dsjoy.o
BUSOBJS += $(BUSOBJ)/centronics/image.o
endif
+
+#-------------------------------------------------
+#
+#@src/emu/bus/rs232/rs232.h,BUSES += RS232
+#-------------------------------------------------
+
+ifneq ($(filter RS232,$(BUSES)),)
+BUSOBJS += $(BUSOBJ)/rs232/keyboard.o
+BUSOBJS += $(BUSOBJ)/rs232/null_modem.o
+BUSOBJS += $(BUSOBJ)/rs232/rs232.o
+BUSOBJS += $(BUSOBJ)/rs232/ser_mouse.o
+BUSOBJS += $(BUSOBJ)/rs232/terminal.o
+endif
+
+#-------------------------------------------------
+#
+#@src/emu/bus/midi/midi.h,BUSES += MIDI
+#-------------------------------------------------
+
+ifneq ($(filter MIDI,$(BUSES)),)
+BUSOBJS += $(BUSOBJ)/midi/midi.o
+BUSOBJS += $(BUSOBJ)/midi/midiinport.o
+BUSOBJS += $(BUSOBJ)/midi/midioutport.o
+endif
diff --git a/src/emu/bus/c64/midi_maplin.c b/src/emu/bus/c64/midi_maplin.c
index 4300d2b95e2..df6830064c2 100644
--- a/src/emu/bus/c64/midi_maplin.c
+++ b/src/emu/bus/c64/midi_maplin.c
@@ -10,6 +10,9 @@
**********************************************************************/
#include "midi_maplin.h"
+#include "bus/midi/midi.h"
+#include "bus/midi/midiinport.h"
+#include "bus/midi/midioutport.h"
@@ -41,7 +44,7 @@ static ACIA6850_INTERFACE( acia_intf )
{
500000,
0, // rx clock (we manually clock rx)
- DEVCB_DEVICE_LINE_MEMBER("mdout", serial_port_device, tx),
+ DEVCB_DEVICE_LINE_MEMBER("mdout", midi_port_device, write_txd),
DEVCB_NULL,
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_maplin_midi_cartridge_device, acia_irq_w)
};
@@ -82,10 +85,10 @@ SLOT_INTERFACE_END
static MACHINE_CONFIG_FRAGMENT( c64_maplin_midi )
MCFG_ACIA6850_ADD(MC6850_TAG, acia_intf)
- MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_maplin_midi_cartridge_device, midi_rx_w))
+ MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
+ MCFG_MIDI_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_maplin_midi_cartridge_device, midi_rx_w))
- MCFG_SERIAL_PORT_ADD("mdout", midiout_slot, "midiout")
+ MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout")
MACHINE_CONFIG_END
diff --git a/src/emu/bus/c64/midi_maplin.h b/src/emu/bus/c64/midi_maplin.h
index 94faa9a5c20..c9ddf94dbe4 100644
--- a/src/emu/bus/c64/midi_maplin.h
+++ b/src/emu/bus/c64/midi_maplin.h
@@ -14,12 +14,8 @@
#ifndef __C64_MIDI_MAPLIN__
#define __C64_MIDI_MAPLIN__
-#include "emu.h"
#include "exp.h"
#include "machine/6850acia.h"
-#include "machine/serial.h"
-#include "machine/midiinport.h"
-#include "machine/midioutport.h"
diff --git a/src/emu/bus/c64/midi_namesoft.c b/src/emu/bus/c64/midi_namesoft.c
index dcee8205f1c..aea458cbd5a 100644
--- a/src/emu/bus/c64/midi_namesoft.c
+++ b/src/emu/bus/c64/midi_namesoft.c
@@ -10,6 +10,9 @@
**********************************************************************/
#include "midi_namesoft.h"
+#include "bus/midi/midi.h"
+#include "bus/midi/midiinport.h"
+#include "bus/midi/midioutport.h"
@@ -41,7 +44,7 @@ static ACIA6850_INTERFACE( acia_intf )
{
500000,
0, // rx clock (we manually clock rx)
- DEVCB_DEVICE_LINE_MEMBER("mdout", serial_port_device, tx),
+ DEVCB_DEVICE_LINE_MEMBER("mdout", midi_port_device, write_txd),
DEVCB_NULL,
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_namesoft_midi_cartridge_device, acia_irq_w)
};
@@ -82,10 +85,10 @@ SLOT_INTERFACE_END
static MACHINE_CONFIG_FRAGMENT( c64_passport_midi )
MCFG_ACIA6850_ADD(MC6850_TAG, acia_intf)
- MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_namesoft_midi_cartridge_device, midi_rx_w))
+ MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
+ MCFG_MIDI_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_namesoft_midi_cartridge_device, midi_rx_w))
- MCFG_SERIAL_PORT_ADD("mdout", midiout_slot, "midiout")
+ MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout")
MACHINE_CONFIG_END
diff --git a/src/emu/bus/c64/midi_namesoft.h b/src/emu/bus/c64/midi_namesoft.h
index f5d54f6337f..547fee0140a 100644
--- a/src/emu/bus/c64/midi_namesoft.h
+++ b/src/emu/bus/c64/midi_namesoft.h
@@ -14,12 +14,8 @@
#ifndef __C64_MIDI_NAMESOFT__
#define __C64_MIDI_NAMESOFT__
-#include "emu.h"
#include "exp.h"
#include "machine/6850acia.h"
-#include "machine/serial.h"
-#include "machine/midiinport.h"
-#include "machine/midioutport.h"
diff --git a/src/emu/bus/c64/midi_passport.c b/src/emu/bus/c64/midi_passport.c
index 3c4a1d092b0..e28b0182553 100644
--- a/src/emu/bus/c64/midi_passport.c
+++ b/src/emu/bus/c64/midi_passport.c
@@ -10,6 +10,9 @@
**********************************************************************/
#include "midi_passport.h"
+#include "bus/midi/midi.h"
+#include "bus/midi/midiinport.h"
+#include "bus/midi/midioutport.h"
@@ -64,7 +67,7 @@ static ACIA6850_INTERFACE( acia_intf )
{
500000,
0, // rx clock (we manually clock rx)
- DEVCB_DEVICE_LINE_MEMBER("mdout", serial_port_device, tx),
+ DEVCB_DEVICE_LINE_MEMBER("mdout", midi_port_device, write_txd),
DEVCB_NULL,
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_passport_midi_cartridge_device, acia_irq_w)
};
@@ -106,10 +109,10 @@ static MACHINE_CONFIG_FRAGMENT( c64_passport_midi )
MCFG_ACIA6850_ADD(MC6850_TAG, acia_intf)
MCFG_PTM6840_ADD(MC6840_TAG, ptm_intf)
- MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_passport_midi_cartridge_device, midi_rx_w))
+ MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
+ MCFG_MIDI_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_passport_midi_cartridge_device, midi_rx_w))
- MCFG_SERIAL_PORT_ADD("mdout", midiout_slot, "midiout")
+ MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout")
MACHINE_CONFIG_END
diff --git a/src/emu/bus/c64/midi_passport.h b/src/emu/bus/c64/midi_passport.h
index fe02d5fef52..a126e97d56d 100644
--- a/src/emu/bus/c64/midi_passport.h
+++ b/src/emu/bus/c64/midi_passport.h
@@ -14,13 +14,9 @@
#ifndef __C64_MIDI_PASSPORT__
#define __C64_MIDI_PASSPORT__
-#include "emu.h"
#include "exp.h"
#include "machine/6840ptm.h"
#include "machine/6850acia.h"
-#include "machine/serial.h"
-#include "machine/midiinport.h"
-#include "machine/midioutport.h"
diff --git a/src/emu/bus/c64/midi_sci.c b/src/emu/bus/c64/midi_sci.c
index 144e1510299..ef39829bfb7 100644
--- a/src/emu/bus/c64/midi_sci.c
+++ b/src/emu/bus/c64/midi_sci.c
@@ -10,6 +10,9 @@
**********************************************************************/
#include "midi_sci.h"
+#include "bus/midi/midi.h"
+#include "bus/midi/midiinport.h"
+#include "bus/midi/midioutport.h"
@@ -41,7 +44,7 @@ static ACIA6850_INTERFACE( acia_intf )
{
500000,
0, // rx clock (we manually clock rx)
- DEVCB_DEVICE_LINE_MEMBER("mdout", serial_port_device, tx),
+ DEVCB_DEVICE_LINE_MEMBER("mdout", midi_port_device, write_txd),
DEVCB_NULL,
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_sequential_midi_cartridge_device, acia_irq_w)
};
@@ -82,10 +85,10 @@ SLOT_INTERFACE_END
static MACHINE_CONFIG_FRAGMENT( c64_sequential_midi )
MCFG_ACIA6850_ADD(MC6850_TAG, acia_intf)
- MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_sequential_midi_cartridge_device, midi_rx_w))
+ MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
+ MCFG_MIDI_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_sequential_midi_cartridge_device, midi_rx_w))
- MCFG_SERIAL_PORT_ADD("mdout", midiout_slot, "midiout")
+ MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout")
MACHINE_CONFIG_END
diff --git a/src/emu/bus/c64/midi_sci.h b/src/emu/bus/c64/midi_sci.h
index c1ff88cdcb8..1f5010ff3c6 100644
--- a/src/emu/bus/c64/midi_sci.h
+++ b/src/emu/bus/c64/midi_sci.h
@@ -14,12 +14,8 @@
#ifndef __C64_MIDI_SCI__
#define __C64_MIDI_SCI__
-#include "emu.h"
#include "exp.h"
#include "machine/6850acia.h"
-#include "machine/serial.h"
-#include "machine/midiinport.h"
-#include "machine/midioutport.h"
diff --git a/src/emu/bus/c64/midi_siel.c b/src/emu/bus/c64/midi_siel.c
index 8f2e4160365..7acda555651 100644
--- a/src/emu/bus/c64/midi_siel.c
+++ b/src/emu/bus/c64/midi_siel.c
@@ -10,6 +10,9 @@
**********************************************************************/
#include "midi_siel.h"
+#include "bus/midi/midi.h"
+#include "bus/midi/midiinport.h"
+#include "bus/midi/midioutport.h"
@@ -41,7 +44,7 @@ static ACIA6850_INTERFACE( acia_intf )
{
XTAL_2MHz,
0, // rx clock (we manually clock rx)
- DEVCB_DEVICE_LINE_MEMBER("mdout", serial_port_device, tx),
+ DEVCB_DEVICE_LINE_MEMBER("mdout", midi_port_device, write_txd),
DEVCB_NULL,
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, c64_siel_midi_cartridge_device, acia_irq_w)
};
@@ -82,10 +85,10 @@ SLOT_INTERFACE_END
static MACHINE_CONFIG_FRAGMENT( c64_siel_midi )
MCFG_ACIA6850_ADD(MC6850_TAG, acia_intf)
- MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_siel_midi_cartridge_device, midi_rx_w))
+ MCFG_MIDI_PORT_ADD("mdin", midiin_slot, "midiin")
+ MCFG_MIDI_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, c64_siel_midi_cartridge_device, midi_rx_w))
- MCFG_SERIAL_PORT_ADD("mdout", midiout_slot, "midiout")
+ MCFG_MIDI_PORT_ADD("mdout", midiout_slot, "midiout")
MACHINE_CONFIG_END
diff --git a/src/emu/bus/c64/midi_siel.h b/src/emu/bus/c64/midi_siel.h
index 80a94d25f7a..a4682c488b9 100644
--- a/src/emu/bus/c64/midi_siel.h
+++ b/src/emu/bus/c64/midi_siel.h
@@ -14,12 +14,8 @@
#ifndef __C64_MIDI_SIEL__
#define __C64_MIDI_SIEL__
-#include "emu.h"
#include "exp.h"
#include "machine/6850acia.h"
-#include "machine/serial.h"
-#include "machine/midiinport.h"
-#include "machine/midioutport.h"
diff --git a/src/emu/bus/c64/swiftlink.c b/src/emu/bus/c64/swiftlink.c
index 2552239b2a2..0f7604860ec 100644
--- a/src/emu/bus/c64/swiftlink.c
+++ b/src/emu/bus/c64/swiftlink.c
@@ -16,6 +16,7 @@
*/
#include "swiftlink.h"
+#include "bus/rs232/rs232.h"
@@ -42,13 +43,13 @@ const device_type C64_SWIFTLINK = &device_creator<c64_swiftlink_cartridge_device
static MACHINE_CONFIG_FRAGMENT( c64_swiftlink )
MCFG_DEVICE_ADD(MOS6551_TAG, MOS6551, XTAL_3_6864MHz)
MCFG_MOS6551_IRQ_HANDLER(WRITELINE(c64_swiftlink_cartridge_device, acia_irq_w))
- MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE(RS232_TAG, rs232_port_device, tx))
+ MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE(RS232_TAG, rs232_port_device, write_txd))
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, rxd_w))
- MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dcd_w))
- MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dsr_w))
- MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, cts_w))
+ MCFG_RS232_RXD_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, rxd_w))
+ MCFG_RS232_DCD_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dcd_w))
+ MCFG_RS232_DSR_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dsr_w))
+ MCFG_RS232_CTS_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, cts_w))
MACHINE_CONFIG_END
diff --git a/src/emu/bus/c64/swiftlink.h b/src/emu/bus/c64/swiftlink.h
index d4aec28f962..f9b615dd56b 100644
--- a/src/emu/bus/c64/swiftlink.h
+++ b/src/emu/bus/c64/swiftlink.h
@@ -15,10 +15,8 @@
#define __SWIFTLINK__
-#include "emu.h"
#include "exp.h"
#include "machine/mos6551.h"
-#include "machine/serial.h"
diff --git a/src/emu/bus/c64/turbo232.c b/src/emu/bus/c64/turbo232.c
index 8e497cda3d3..73cb133d767 100644
--- a/src/emu/bus/c64/turbo232.c
+++ b/src/emu/bus/c64/turbo232.c
@@ -42,13 +42,13 @@ const device_type C64_TURBO232 = &device_creator<c64_turbo232_cartridge_device>;
static MACHINE_CONFIG_FRAGMENT( c64_turbo232 )
MCFG_DEVICE_ADD(MOS6551_TAG, MOS6551, XTAL_3_6864MHz)
MCFG_MOS6551_IRQ_HANDLER(WRITELINE(c64_turbo232_cartridge_device, acia_irq_w))
- MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE(RS232_TAG, rs232_port_device, tx))
+ MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE(RS232_TAG, rs232_port_device, write_txd))
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, rxd_w))
- MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dcd_w))
- MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dsr_w))
- MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, cts_w))
+ MCFG_RS232_RXD_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, rxd_w))
+ MCFG_RS232_DCD_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dcd_w))
+ MCFG_RS232_DSR_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dsr_w))
+ MCFG_RS232_CTS_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, cts_w))
MACHINE_CONFIG_END
diff --git a/src/emu/bus/c64/turbo232.h b/src/emu/bus/c64/turbo232.h
index 4686bfa4626..308c7455b26 100644
--- a/src/emu/bus/c64/turbo232.h
+++ b/src/emu/bus/c64/turbo232.h
@@ -15,12 +15,9 @@
#define __TURBO232__
-#include "emu.h"
#include "exp.h"
#include "machine/mos6551.h"
-#include "machine/null_modem.h"
-#include "machine/serial.h"
-#include "machine/terminal.h"
+#include "bus/rs232/rs232.h"
diff --git a/src/emu/bus/ieee488/hardbox.c b/src/emu/bus/ieee488/hardbox.c
index cfc914d6d87..9b877a27f41 100644
--- a/src/emu/bus/ieee488/hardbox.c
+++ b/src/emu/bus/ieee488/hardbox.c
@@ -43,6 +43,11 @@
#include "hardbox.h"
+#include "cpu/z80/z80.h"
+#include "machine/i8251.h"
+#include "machine/i8255.h"
+#include "imagedev/harddriv.h"
+#include "includes/corvushd.h"
diff --git a/src/emu/bus/ieee488/hardbox.h b/src/emu/bus/ieee488/hardbox.h
index 5c6c4631bdc..4f705085ec0 100644
--- a/src/emu/bus/ieee488/hardbox.h
+++ b/src/emu/bus/ieee488/hardbox.h
@@ -14,13 +14,7 @@
#ifndef __PET_HARDBOX__
#define __PET_HARDBOX__
-#include "emu.h"
#include "ieee488.h"
-#include "cpu/z80/z80.h"
-#include "imagedev/harddriv.h"
-#include "includes/corvushd.h"
-#include "machine/i8255.h"
-#include "machine/serial.h"
diff --git a/src/emu/bus/ieee488/shark.c b/src/emu/bus/ieee488/shark.c
index 0b417a7fb61..16c66fda0c0 100644
--- a/src/emu/bus/ieee488/shark.c
+++ b/src/emu/bus/ieee488/shark.c
@@ -10,6 +10,9 @@
**********************************************************************/
#include "shark.h"
+#include "bus/rs232/rs232.h"
+#include "cpu/i8085/i8085.h"
+#include "imagedev/harddriv.h"
diff --git a/src/emu/bus/ieee488/shark.h b/src/emu/bus/ieee488/shark.h
index f38fbd90501..8306e5210d9 100644
--- a/src/emu/bus/ieee488/shark.h
+++ b/src/emu/bus/ieee488/shark.h
@@ -16,11 +16,7 @@
#ifndef __SHARK__
#define __SHARK__
-#include "emu.h"
#include "ieee488.h"
-#include "cpu/i8085/i8085.h"
-#include "imagedev/harddriv.h"
-#include "machine/serial.h"
diff --git a/src/emu/bus/ieee488/softbox.c b/src/emu/bus/ieee488/softbox.c
index 475dba99d82..21de6666d6d 100644
--- a/src/emu/bus/ieee488/softbox.c
+++ b/src/emu/bus/ieee488/softbox.c
@@ -18,7 +18,12 @@
#include "softbox.h"
-
+#include "bus/rs232/rs232.h"
+#include "cpu/z80/z80.h"
+#include "imagedev/harddriv.h"
+#include "includes/corvushd.h"
+#include "machine/i8251.h"
+#include "machine/i8255.h"
//**************************************************************************
@@ -99,9 +104,9 @@ ADDRESS_MAP_END
static const i8251_interface usart_intf =
{
- DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, tx),
- DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, dtr_w),
- DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, rts_w),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, write_txd),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, write_dtr),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, write_rts),
DEVCB_NULL,
DEVCB_NULL,
DEVCB_NULL,
@@ -284,10 +289,12 @@ static MACHINE_CONFIG_FRAGMENT( softbox )
MCFG_HARDDISK_ADD("harddisk2")
MCFG_HARDDISK_ADD("harddisk3")
MCFG_HARDDISK_ADD("harddisk4")
+
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
+ MCFG_RS232_RXD_HANDLER(DEVWRITELINE(I8251_TAG, i8251_device, write_rx))
+ MCFG_RS232_DSR_HANDLER(DEVWRITELINE(I8251_TAG, i8251_device, write_dsr))
MCFG_DEVICE_CARD_DEVICE_INPUT_DEFAULTS("serial_terminal", terminal)
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(I8251_TAG, i8251_device, write_rx))
- MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(I8251_TAG, i8251_device, write_dsr))
+
//MCFG_IMI7000_BUS_ADD("imi5000h", NULL, NULL, NULL)
MACHINE_CONFIG_END
diff --git a/src/emu/bus/ieee488/softbox.h b/src/emu/bus/ieee488/softbox.h
index 3f7bb21f80f..9edc2f8adcb 100644
--- a/src/emu/bus/ieee488/softbox.h
+++ b/src/emu/bus/ieee488/softbox.h
@@ -14,16 +14,8 @@
#ifndef __PET_SOFTBOX__
#define __PET_SOFTBOX__
-#include "emu.h"
#include "ieee488.h"
-#include "bus/imi7000/imi7000.h"
-#include "cpu/z80/z80.h"
-#include "imagedev/harddriv.h"
-#include "includes/corvushd.h"
#include "machine/com8116.h"
-#include "machine/i8251.h"
-#include "machine/i8255.h"
-#include "machine/serial.h"
diff --git a/src/emu/bus/midi/midi.c b/src/emu/bus/midi/midi.c
new file mode 100644
index 00000000000..5021f82f440
--- /dev/null
+++ b/src/emu/bus/midi/midi.c
@@ -0,0 +1,40 @@
+#include "midi.h"
+
+const device_type MIDI_PORT = &device_creator<midi_port_device>;
+
+device_midi_port_interface::device_midi_port_interface(const machine_config &mconfig, device_t &device)
+ : device_slot_card_interface(mconfig, device)
+{
+}
+
+device_midi_port_interface::~device_midi_port_interface()
+{
+}
+
+midi_port_device::midi_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, MIDI_PORT, "Midi Port", tag, owner, clock, "midi_port", __FILE__),
+ device_slot_interface(mconfig, *this),
+ m_rxd_handler(*this),
+ m_dev(NULL)
+{
+}
+
+midi_port_device::~midi_port_device()
+{
+}
+
+void midi_port_device::device_config_complete()
+{
+ m_dev = dynamic_cast<device_midi_port_interface *>(get_card_device());
+}
+
+void midi_port_device::device_start()
+{
+ m_rxd_handler.resolve_safe();
+}
+
+WRITE_LINE_MEMBER( midi_port_device::write_txd )
+{
+ if(m_dev)
+ m_dev->input_txd(state);
+}
diff --git a/src/emu/bus/midi/midi.h b/src/emu/bus/midi/midi.h
new file mode 100644
index 00000000000..7b386ac9de4
--- /dev/null
+++ b/src/emu/bus/midi/midi.h
@@ -0,0 +1,62 @@
+#ifndef __BUS_MIDI_H__
+#define __BUS_MIDI_H__
+
+#include "emu.h"
+
+#define MCFG_MIDI_PORT_ADD(_tag, _slot_intf, _def_slot) \
+ MCFG_DEVICE_ADD(_tag, MIDI_PORT, 0) \
+ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
+
+#define MCFG_MIDI_RX_HANDLER(_devcb) \
+ devcb = &midi_port_device::set_rx_handler(*device, DEVCB2_##_devcb);
+
+class device_midi_port_interface;
+
+class midi_port_device : public device_t,
+ public device_slot_interface
+{
+ friend class device_midi_port_interface;
+
+public:
+ midi_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ virtual ~midi_port_device();
+
+ // static configuration helpers
+ template<class _Object> static devcb2_base &set_rx_handler(device_t &device, _Object object) { return downcast<midi_port_device &>(device).m_rxd_handler.set_callback(object); }
+
+ DECLARE_WRITE_LINE_MEMBER( write_txd );
+
+ DECLARE_READ_LINE_MEMBER( rx_r ) { return m_rxd; }
+
+protected:
+ virtual void device_start();
+ virtual void device_config_complete();
+
+ int m_rxd;
+
+ devcb2_write_line m_rxd_handler;
+
+private:
+ device_midi_port_interface *m_dev;
+};
+
+class device_midi_port_interface : public device_slot_card_interface
+{
+ friend class midi_port_device;
+
+public:
+ device_midi_port_interface(const machine_config &mconfig, device_t &device);
+ virtual ~device_midi_port_interface();
+
+ virtual DECLARE_WRITE_LINE_MEMBER( input_txd ) {}
+ DECLARE_WRITE_LINE_MEMBER( output_rxd ) { m_port->m_rxd = state; m_port->m_rxd_handler(state); }
+
+protected:
+ midi_port_device *m_port;
+};
+
+extern const device_type MIDI_PORT;
+
+SLOT_INTERFACE_EXTERN( default_midi_devices );
+
+#endif
diff --git a/src/emu/bus/midi/midiinport.c b/src/emu/bus/midi/midiinport.c
new file mode 100644
index 00000000000..906a183e7b4
--- /dev/null
+++ b/src/emu/bus/midi/midiinport.c
@@ -0,0 +1,32 @@
+/*********************************************************************
+
+ midiinport.c
+
+ MIDI In serial port - glues the image device to the pluggable serial port
+
+*********************************************************************/
+
+#include "midiinport.h"
+
+const device_type MIDIIN_PORT = &device_creator<midiin_port_device>;
+
+midiin_port_device::midiin_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, MIDIIN_PORT, "MIDI In port", tag, owner, clock, "midiin_port", __FILE__),
+ device_midi_port_interface(mconfig, *this),
+ m_midiin(*this, "midiinimg")
+{
+}
+
+static midiin_config midiin_port_image_config =
+{
+ DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, midiin_port_device, read)
+};
+
+static MACHINE_CONFIG_FRAGMENT(midiin_port_config)
+ MCFG_MIDIIN_ADD("midiinimg", midiin_port_image_config)
+MACHINE_CONFIG_END
+
+machine_config_constructor midiin_port_device::device_mconfig_additions() const
+{
+ return MACHINE_CONFIG_NAME(midiin_port_config);
+}
diff --git a/src/emu/bus/midi/midiinport.h b/src/emu/bus/midi/midiinport.h
new file mode 100644
index 00000000000..fd2bce7f86b
--- /dev/null
+++ b/src/emu/bus/midi/midiinport.h
@@ -0,0 +1,34 @@
+/*********************************************************************
+
+ midiinport.h
+
+ MIDI In port - glues the image device to the pluggable midi port
+
+*********************************************************************/
+
+#ifndef _MIDIINPORT_H_
+#define _MIDIINPORT_H_
+
+#include "midi.h"
+#include "imagedev/midiin.h"
+
+class midiin_port_device : public device_t,
+ public device_midi_port_interface
+{
+public:
+ midiin_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ DECLARE_WRITE_LINE_MEMBER( read ) { output_rxd(state); }
+
+protected:
+ virtual machine_config_constructor device_mconfig_additions() const;
+ virtual void device_start() { m_owner = dynamic_cast<midi_port_device *>(owner()); }
+ virtual void device_reset() { }
+
+private:
+ required_device<midiin_device> m_midiin;
+};
+
+extern const device_type MIDIIN_PORT;
+
+#endif
diff --git a/src/emu/bus/midi/midioutport.c b/src/emu/bus/midi/midioutport.c
new file mode 100644
index 00000000000..1d4f9e4b408
--- /dev/null
+++ b/src/emu/bus/midi/midioutport.c
@@ -0,0 +1,27 @@
+/*********************************************************************
+
+ midioutport.c
+
+ MIDI Out serial port - glues the image device to the pluggable serial port
+
+*********************************************************************/
+
+#include "midioutport.h"
+
+const device_type MIDIOUT_PORT = &device_creator<midiout_port_device>;
+
+midiout_port_device::midiout_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, MIDIOUT_PORT, "MIDI Out port", tag, owner, clock, "midiout_port", __FILE__),
+ device_midi_port_interface(mconfig, *this),
+ m_midiout(*this, "midioutimg")
+{
+}
+
+static MACHINE_CONFIG_FRAGMENT(midiout_port_config)
+ MCFG_MIDIOUT_ADD("midioutimg")
+MACHINE_CONFIG_END
+
+machine_config_constructor midiout_port_device::device_mconfig_additions() const
+{
+ return MACHINE_CONFIG_NAME(midiout_port_config);
+}
diff --git a/src/emu/bus/midi/midioutport.h b/src/emu/bus/midi/midioutport.h
new file mode 100644
index 00000000000..573eea5cc0f
--- /dev/null
+++ b/src/emu/bus/midi/midioutport.h
@@ -0,0 +1,34 @@
+/*********************************************************************
+
+ midioutport.h
+
+ MIDI Out port - glues the image device to the pluggable midi port
+
+*********************************************************************/
+
+#ifndef _MIDIOUTPORT_H_
+#define _MIDIOUTPORT_H_
+
+#include "midi.h"
+#include "imagedev/midiout.h"
+
+class midiout_port_device : public device_t,
+ public device_midi_port_interface
+{
+public:
+ midiout_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ virtual machine_config_constructor device_mconfig_additions() const;
+ DECLARE_WRITE_LINE_MEMBER( read ) { }
+ virtual void tx(UINT8 state) { m_midiout->tx(state); }
+
+protected:
+ virtual void device_start() { }
+ virtual void device_reset() { }
+
+private:
+ required_device<midiout_device> m_midiout;
+};
+
+extern const device_type MIDIOUT_PORT;
+
+#endif
diff --git a/src/emu/bus/pet/superpet.c b/src/emu/bus/pet/superpet.c
index 777aa907e5a..5135571ed3b 100644
--- a/src/emu/bus/pet/superpet.c
+++ b/src/emu/bus/pet/superpet.c
@@ -10,6 +10,8 @@
**********************************************************************/
#include "superpet.h"
+#include "bus/rs232/rs232.h"
+#include "cpu/m6809/m6809.h"
@@ -77,13 +79,13 @@ static MACHINE_CONFIG_FRAGMENT( superpet )
MCFG_DEVICE_ADD(MOS6551_TAG, MOS6551, XTAL_1_8432MHz)
MCFG_MOS6551_IRQ_HANDLER(WRITELINE(superpet_device, acia_irq_w))
- MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE(RS232_TAG, rs232_port_device, tx))
+ MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE(RS232_TAG, rs232_port_device, write_txd))
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, rxd_w))
- MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dcd_w))
- MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dsr_w))
- MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, cts_w))
+ MCFG_RS232_RXD_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, rxd_w))
+ MCFG_RS232_DCD_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dcd_w))
+ MCFG_RS232_DSR_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, dsr_w))
+ MCFG_RS232_CTS_HANDLER(DEVWRITELINE(MOS6551_TAG, mos6551_device, cts_w))
MACHINE_CONFIG_END
diff --git a/src/emu/bus/pet/superpet.h b/src/emu/bus/pet/superpet.h
index 3aa21a6d33b..de7d6ee9f75 100644
--- a/src/emu/bus/pet/superpet.h
+++ b/src/emu/bus/pet/superpet.h
@@ -14,12 +14,9 @@
#ifndef __SUPERPET__
#define __SUPERPET__
-#include "emu.h"
#include "exp.h"
-#include "cpu/m6809/m6809.h"
#include "machine/mos6551.h"
#include "machine/mos6702.h"
-#include "machine/serial.h"
diff --git a/src/emu/bus/rs232/keyboard.c b/src/emu/bus/rs232/keyboard.c
new file mode 100644
index 00000000000..8b83decc708
--- /dev/null
+++ b/src/emu/bus/rs232/keyboard.c
@@ -0,0 +1,184 @@
+/***************************************************************************
+Generic ASCII Keyboard
+
+Use MCFG_SERIAL_KEYBOARD_ADD to attach this as a serial device to a terminal
+or computer.
+
+Use MCFG_ASCII_KEYBOARD_ADD to attach as a generic ascii input device in
+cases where either the driver isn't developed enough yet; or for testing;
+or for the case of a computer with an inbuilt (not serial) ascii keyboard.
+
+Example of usage in a driver.
+
+In MACHINE_CONFIG
+ MCFG_ASCII_KEYBOARD_ADD(KEYBOARD_TAG, keyboard_intf)
+
+In the code:
+
+WRITE8_MEMBER( xxx_state::kbd_put )
+{
+ (code to capture the key as it is pressed)
+}
+
+static ASCII_KEYBOARD_INTERFACE( keyboard_intf )
+{
+ DEVCB_DRIVER_MEMBER(xxx_state, kbd_put)
+};
+
+***************************************************************************/
+
+#include "keyboard.h"
+
+/***************************************************************************
+ IMPLEMENTATION
+***************************************************************************/
+
+static INPUT_PORTS_START(serial_keyboard)
+ PORT_INCLUDE(generic_keyboard)
+ PORT_START("TERM_FRAME")
+ PORT_CONFNAME(0x0f, 0x06, "Baud") PORT_CHANGED_MEMBER(DEVICE_SELF, serial_keyboard_device, update_frame, 0)
+ PORT_CONFSETTING( 0x0d, "110")
+ PORT_CONFSETTING( 0x00, "150")
+ PORT_CONFSETTING( 0x01, "300")
+ PORT_CONFSETTING( 0x02, "600")
+ PORT_CONFSETTING( 0x03, "1200")
+ PORT_CONFSETTING( 0x04, "2400")
+ PORT_CONFSETTING( 0x05, "4800")
+ PORT_CONFSETTING( 0x06, "9600")
+ PORT_CONFSETTING( 0x07, "14400")
+ PORT_CONFSETTING( 0x08, "19200")
+ PORT_CONFSETTING( 0x09, "28800")
+ PORT_CONFSETTING( 0x0a, "38400")
+ PORT_CONFSETTING( 0x0b, "57600")
+ PORT_CONFSETTING( 0x0c, "115200")
+ PORT_CONFNAME(0x30, 0x00, "Format") PORT_CHANGED_MEMBER(DEVICE_SELF, serial_keyboard_device, update_frame, 0)
+ PORT_CONFSETTING( 0x00, "8N1")
+ PORT_CONFSETTING( 0x10, "7E1")
+ PORT_CONFSETTING( 0x20, "8N2")
+ PORT_CONFSETTING( 0x30, "8E1")
+INPUT_PORTS_END
+
+ioport_constructor serial_keyboard_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(serial_keyboard);
+}
+
+serial_keyboard_device::serial_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_keyboard_device(mconfig, SERIAL_KEYBOARD, "Serial Keyboard", tag, owner, clock, "serial_keyboard", __FILE__),
+ device_serial_interface(mconfig, *this),
+ device_rs232_port_interface(mconfig, *this),
+ m_io_term_frame(*this, "TERM_FRAME")
+{
+}
+
+serial_keyboard_device::serial_keyboard_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)
+ : generic_keyboard_device(mconfig, type, name, tag, owner, clock, shortname, source),
+ device_serial_interface(mconfig, *this),
+ device_rs232_port_interface(mconfig, *this),
+ m_io_term_frame(*this, "TERM_FRAME")
+{
+}
+
+void serial_keyboard_device::device_config_complete()
+{
+ const serial_keyboard_interface *intf = reinterpret_cast<const serial_keyboard_interface *>(static_config());
+ if(intf != NULL)
+ {
+ *static_cast<serial_keyboard_interface *>(this) = *intf;
+ }
+ else
+ {
+ memset(&m_out_tx_cb, 0, sizeof(m_out_tx_cb));
+ }
+}
+
+static int rates[] = {150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 110};
+
+void serial_keyboard_device::device_start()
+{
+ int baud = clock();
+ if(!baud) baud = 9600;
+ m_out_tx_func.resolve(m_out_tx_cb, *this);
+ m_timer = timer_alloc();
+ set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
+ set_tra_rate(baud);
+}
+
+INPUT_CHANGED_MEMBER(serial_keyboard_device::update_frame)
+{
+ reset();
+}
+
+void serial_keyboard_device::device_reset()
+{
+ generic_keyboard_device::device_reset();
+ m_rbit = 1;
+ if (m_port)
+ output_rxd(m_rbit);
+ else
+ m_out_tx_func(m_rbit);
+
+ UINT8 val = m_io_term_frame->read();
+ set_tra_rate(rates[val & 0x0f]);
+
+ switch(val & 0x30)
+ {
+ case 0x10:
+ set_data_frame(1, 7, PARITY_EVEN, STOP_BITS_1);
+ break;
+ case 0x00:
+ default:
+ set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
+ break;
+ case 0x20:
+ set_data_frame(1, 8, PARITY_NONE, STOP_BITS_2);
+ break;
+ case 0x30:
+ set_data_frame(1, 8, PARITY_EVEN, STOP_BITS_1);
+ break;
+ }
+}
+
+void serial_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ if (id)
+ device_serial_interface::device_timer(timer, id, param, ptr);
+ else
+ generic_keyboard_device::device_timer(timer, id, param, ptr);
+}
+
+void serial_keyboard_device::send_key(UINT8 code)
+{
+ if(is_transmit_register_empty())
+ {
+ transmit_register_setup(code);
+ return;
+ }
+ m_key_valid = true;
+ m_curr_key = code;
+}
+
+void serial_keyboard_device::tra_callback()
+{
+ m_rbit = transmit_register_get_data_bit();
+ if(m_port)
+ output_rxd(m_rbit);
+ else
+ m_out_tx_func(m_rbit);
+}
+
+void serial_keyboard_device::tra_complete()
+{
+ if(m_key_valid)
+ {
+ transmit_register_setup(m_curr_key);
+ m_key_valid = false;
+ }
+}
+
+READ_LINE_MEMBER(serial_keyboard_device::tx_r)
+{
+ return m_rbit;
+}
+
+const device_type SERIAL_KEYBOARD = &device_creator<serial_keyboard_device>;
diff --git a/src/emu/bus/rs232/keyboard.h b/src/emu/bus/rs232/keyboard.h
new file mode 100644
index 00000000000..8e0da84ea20
--- /dev/null
+++ b/src/emu/bus/rs232/keyboard.h
@@ -0,0 +1,64 @@
+#ifndef __RS232_KEYBOARD_H__
+#define __RS232_KEYBOARD_H__
+
+#include "rs232.h"
+#include "machine/keyboard.h"
+
+/***************************************************************************
+ TYPE DEFINITIONS
+***************************************************************************/
+
+struct serial_keyboard_interface
+{
+ devcb_write_line m_out_tx_cb;
+};
+
+/***************************************************************************
+ DEVICE CONFIGURATION MACROS
+***************************************************************************/
+
+#define MCFG_SERIAL_KEYBOARD_ADD(_tag, _intrf, _clock) \
+ MCFG_DEVICE_ADD(_tag, SERIAL_KEYBOARD, _clock) \
+ MCFG_DEVICE_CONFIG(_intrf)
+
+/***************************************************************************
+ FUNCTION PROTOTYPES
+***************************************************************************/
+
+class serial_keyboard_device :
+ public generic_keyboard_device,
+ public device_serial_interface,
+ public device_rs232_port_interface,
+ public serial_keyboard_interface
+{
+public:
+ serial_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ serial_keyboard_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);
+
+ virtual DECLARE_WRITE_LINE_MEMBER( input_txd ) { device_serial_interface::rx_w(state); }
+ DECLARE_READ_LINE_MEMBER(tx_r);
+
+ virtual ioport_constructor device_input_ports() const;
+
+ DECLARE_INPUT_CHANGED_MEMBER(update_frame);
+
+protected:
+ virtual void device_start();
+ virtual void device_config_complete();
+ virtual void device_reset();
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
+ virtual void tra_callback();
+ virtual void tra_complete();
+ virtual void input_callback(UINT8 state) { m_input_state = state; }
+ virtual void send_key(UINT8 code);
+private:
+ int m_rbit;
+ UINT8 m_curr_key;
+ bool m_key_valid;
+ devcb_resolved_write_line m_out_tx_func;
+ required_ioport m_io_term_frame;
+};
+
+extern const device_type SERIAL_KEYBOARD;
+
+#endif /* __RS232_KEYBOARD_H__ */
diff --git a/src/emu/bus/rs232/null_modem.c b/src/emu/bus/rs232/null_modem.c
new file mode 100644
index 00000000000..e477faf5906
--- /dev/null
+++ b/src/emu/bus/rs232/null_modem.c
@@ -0,0 +1,27 @@
+#include "null_modem.h"
+
+const device_type NULL_MODEM = &device_creator<null_modem_device>;
+
+null_modem_device::null_modem_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, NULL_MODEM, "Null Modem", tag, owner, clock, "null_modem", __FILE__),
+ device_rs232_port_interface(mconfig, *this),
+ m_bitbanger(*this, "bitbanger")
+{
+}
+
+static bitbanger_config null_modem_image_config =
+{
+ DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, null_modem_device, read),
+ BITBANGER_MODEM,
+ BITBANGER_9600,
+ BITBANGER_0PERCENT
+};
+
+static MACHINE_CONFIG_FRAGMENT(null_modem_config)
+ MCFG_BITBANGER_ADD("bitbanger", null_modem_image_config);
+MACHINE_CONFIG_END
+
+machine_config_constructor null_modem_device::device_mconfig_additions() const
+{
+ return MACHINE_CONFIG_NAME(null_modem_config);
+}
diff --git a/src/emu/bus/rs232/null_modem.h b/src/emu/bus/rs232/null_modem.h
new file mode 100644
index 00000000000..14c462b00fa
--- /dev/null
+++ b/src/emu/bus/rs232/null_modem.h
@@ -0,0 +1,27 @@
+#ifndef NULL_MODEM_H_
+#define NULL_MODEM_H_
+
+#include "bus/rs232/rs232.h"
+#include "imagedev/bitbngr.h"
+
+class null_modem_device : public device_t,
+ public device_rs232_port_interface
+{
+public:
+ null_modem_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ virtual machine_config_constructor device_mconfig_additions() const;
+
+ WRITE_LINE_MEMBER( read ) { output_rxd(state); } /// HACK for DEVCB
+ virtual WRITE_LINE_MEMBER( input_txd ) { m_bitbanger->output(state); }
+
+protected:
+ virtual void device_start() {}
+ virtual void device_reset() { output_rxd(1); }
+
+private:
+ required_device<bitbanger_device> m_bitbanger;
+};
+
+extern const device_type NULL_MODEM;
+
+#endif
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
diff --git a/src/emu/bus/rs232/rs232.h b/src/emu/bus/rs232/rs232.h
new file mode 100644
index 00000000000..e4b7ed3ac0b
--- /dev/null
+++ b/src/emu/bus/rs232/rs232.h
@@ -0,0 +1,100 @@
+#ifndef __BUS_RS232_H__
+#define __BUS_RS232_H__
+
+#include "emu.h"
+
+#define MCFG_RS232_PORT_ADD(_tag, _slot_intf, _def_slot) \
+ MCFG_DEVICE_ADD(_tag, RS232_PORT, 0) \
+ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
+
+#define MCFG_RS232_RXD_HANDLER(_devcb) \
+ devcb = &rs232_port_device::set_rx_handler(*device, DEVCB2_##_devcb);
+
+#define MCFG_RS232_DCD_HANDLER(_devcb) \
+ devcb = &rs232_port_device::set_dcd_handler(*device, DEVCB2_##_devcb);
+
+#define MCFG_RS232_DSR_HANDLER(_devcb) \
+ devcb = &rs232_port_device::set_dsr_handler(*device, DEVCB2_##_devcb);
+
+#define MCFG_RS232_RI_HANDLER(_devcb) \
+ devcb = &rs232_port_device::set_ri_handler(*device, DEVCB2_##_devcb);
+
+#define MCFG_RS232_CTS_HANDLER(_devcb) \
+ devcb = &rs232_port_device::set_cts_handler(*device, DEVCB2_##_devcb);
+
+class device_rs232_port_interface;
+
+class rs232_port_device : public device_t,
+ public device_slot_interface
+{
+ friend class device_rs232_port_interface;
+
+public:
+ rs232_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ 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);
+ virtual ~rs232_port_device();
+
+ // static configuration helpers
+ template<class _Object> static devcb2_base &set_rx_handler(device_t &device, _Object object) { return downcast<rs232_port_device &>(device).m_rxd_handler.set_callback(object); }
+ template<class _Object> static devcb2_base &set_dcd_handler(device_t &device, _Object object) { return downcast<rs232_port_device &>(device).m_dcd_handler.set_callback(object); }
+ template<class _Object> static devcb2_base &set_dsr_handler(device_t &device, _Object object) { return downcast<rs232_port_device &>(device).m_dsr_handler.set_callback(object); }
+ template<class _Object> static devcb2_base &set_ri_handler(device_t &device, _Object object) { return downcast<rs232_port_device &>(device).m_ri_handler.set_callback(object); }
+ template<class _Object> static devcb2_base &set_cts_handler(device_t &device, _Object object) { return downcast<rs232_port_device &>(device).m_cts_handler.set_callback(object); }
+
+ DECLARE_WRITE_LINE_MEMBER( write_txd );
+ DECLARE_WRITE_LINE_MEMBER( write_dtr );
+ DECLARE_WRITE_LINE_MEMBER( write_rts );
+
+ DECLARE_READ_LINE_MEMBER( rxd_r ) { return m_rxd; }
+ DECLARE_READ_LINE_MEMBER( dcd_r ) { return m_dcd; }
+ DECLARE_READ_LINE_MEMBER( dsr_r ) { return m_dsr; }
+ DECLARE_READ_LINE_MEMBER( ri_r ) { return m_ri; }
+ DECLARE_READ_LINE_MEMBER( cts_r ) { return m_cts; }
+
+protected:
+ virtual void device_start();
+ virtual void device_config_complete();
+
+ int m_rxd;
+ int m_dcd;
+ int m_dsr;
+ int m_ri;
+ int m_cts;
+
+ devcb2_write_line m_rxd_handler;
+ devcb2_write_line m_dcd_handler;
+ devcb2_write_line m_dsr_handler;
+ devcb2_write_line m_ri_handler;
+ devcb2_write_line m_cts_handler;
+
+private:
+ device_rs232_port_interface *m_dev;
+};
+
+class device_rs232_port_interface: public device_slot_card_interface
+{
+ friend class rs232_port_device;
+
+public:
+ device_rs232_port_interface(const machine_config &mconfig, device_t &device);
+ virtual ~device_rs232_port_interface();
+
+ virtual DECLARE_WRITE_LINE_MEMBER( input_txd ) {}
+ virtual DECLARE_WRITE_LINE_MEMBER( input_dtr ) {}
+ virtual DECLARE_WRITE_LINE_MEMBER( input_rts ) {}
+
+ DECLARE_WRITE_LINE_MEMBER( output_rxd ) { m_port->m_rxd = state; m_port->m_rxd_handler(state); }
+ DECLARE_WRITE_LINE_MEMBER( output_dcd ) { m_port->m_dcd = state; m_port->m_dcd_handler(state); }
+ DECLARE_WRITE_LINE_MEMBER( output_dsr ) { m_port->m_dsr = state; m_port->m_dsr_handler(state); }
+ DECLARE_WRITE_LINE_MEMBER( output_ri ) { m_port->m_ri = state; m_port->m_ri_handler(state); }
+ DECLARE_WRITE_LINE_MEMBER( output_cts ) { m_port->m_cts = state; m_port->m_cts_handler(state); }
+
+protected:
+ rs232_port_device *m_port;
+};
+
+extern const device_type RS232_PORT;
+
+SLOT_INTERFACE_EXTERN( default_rs232_devices );
+
+#endif
diff --git a/src/emu/bus/rs232/ser_mouse.c b/src/emu/bus/rs232/ser_mouse.c
new file mode 100644
index 00000000000..2f81512730c
--- /dev/null
+++ b/src/emu/bus/rs232/ser_mouse.c
@@ -0,0 +1,248 @@
+/***************************************************************************
+
+ machine/ser_mouse.c
+
+ Code for emulating PC-style serial mouses
+
+***************************************************************************/
+
+#include "ser_mouse.h"
+
+
+serial_mouse_device::serial_mouse_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_rs232_port_interface(mconfig, *this),
+ device_serial_interface(mconfig, *this),
+ m_x(*this, "ser_mouse_x"),
+ m_y(*this, "ser_mouse_y"),
+ m_btn(*this, "ser_mouse_btn")
+{
+}
+
+const device_type MSFT_SERIAL_MOUSE = &device_creator<microsoft_mouse_device>;
+
+microsoft_mouse_device::microsoft_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : serial_mouse_device(mconfig, MSFT_SERIAL_MOUSE, "Microsoft Serial Mouse", tag, owner, clock, "microsoft_mouse", __FILE__)
+{
+}
+
+const device_type MSYSTEM_SERIAL_MOUSE = &device_creator<mouse_systems_mouse_device>;
+
+mouse_systems_mouse_device::mouse_systems_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : serial_mouse_device(mconfig, MSYSTEM_SERIAL_MOUSE, "Mouse Systems Serial Mouse", tag, owner, clock, "mouse_systems_mouse", __FILE__)
+{
+}
+
+void serial_mouse_device::device_start()
+{
+ m_timer = timer_alloc();
+ m_enabled = false;
+ set_frame();
+ set_tra_rate(1200);
+}
+
+void serial_mouse_device::device_reset()
+{
+ m_head = m_tail = 0;
+ output_rxd(0);
+ output_dcd(0);
+ output_dsr(0);
+ output_ri(0);
+ output_cts(0);
+}
+
+void serial_mouse_device::tra_complete()
+{
+ if(m_tail != m_head)
+ transmit_register_setup(unqueue_data());
+}
+
+void serial_mouse_device::tra_callback()
+{
+ output_rxd(transmit_register_get_data_bit());
+}
+
+/**************************************************************************
+ * Check for mouse moves and buttons. Build delta x/y packets
+ **************************************************************************/
+void serial_mouse_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ if (id)
+ {
+ device_serial_interface::device_timer(timer, id, param, ptr);
+ return;
+ }
+
+ static int ox = 0, oy = 0;
+ int nx,ny;
+ int dx, dy, nb;
+ int mbc;
+
+ /* Do not get deltas or send packets if queue is not empty (Prevents drifting) */
+ if (m_head==m_tail)
+ {
+ nx = m_x->read();
+
+ dx = nx - ox;
+ if (dx<=-0x800) dx = nx + 0x1000 - ox; /* Prevent jumping */
+ if (dx>=0x800) dx = nx - 0x1000 - ox;
+ ox = nx;
+
+ ny = m_y->read();
+
+ dy = ny - oy;
+ if (dy<=-0x800) dy = ny + 0x1000 - oy;
+ if (dy>=0x800) dy = ny - 0x1000 - oy;
+ oy = ny;
+
+ nb = m_btn->read();
+ mbc = nb^m_mb;
+ m_mb = nb;
+
+ /* check if there is any delta or mouse buttons changed */
+ if ( (dx!=0) || (dy!=0) || (mbc!=0) )
+ mouse_trans(dx, dy, nb, mbc);
+ }
+
+
+ if(m_tail != m_head && is_transmit_register_empty())
+ transmit_register_setup(unqueue_data());
+}
+
+void microsoft_mouse_device::mouse_trans(int dx, int dy, int nb, int mbc)
+{
+ /* split deltas into packets of -128..+127 max */
+ do
+ {
+ UINT8 m0, m1, m2;
+ int ddx = (dx < -128) ? -128 : (dx > 127) ? 127 : dx;
+ int ddy = (dy < -128) ? -128 : (dy > 127) ? 127 : dy;
+ m0 = 0x40 | ((nb << 4) & 0x30) | ((ddx >> 6) & 0x03) | ((ddy >> 4) & 0x0c);
+ m1 = ddx & 0x3f;
+ m2 = ddy & 0x3f;
+
+ /* KT - changed to use a function */
+ queue_data(m0 | 0x40);
+ queue_data(m1 & 0x03f);
+ queue_data(m2 & 0x03f);
+ if ((mbc & 0x04) != 0) /* If button 3 changed send extra byte */
+ queue_data( (nb & 0x04) << 3);
+
+ dx -= ddx;
+ dy -= ddy;
+ } while( dx || dy );
+}
+
+/* mouse systems mouse
+ from "PC Mouse information" by Tomi Engdahl */
+
+/*
+ The data is sent in 5 byte packets in following format:
+ D7 D6 D5 D4 D3 D2 D1 D0
+
+ 1. 1 0 0 0 0 LB CB RB
+ 2. X7 X6 X5 X4 X3 X2 X1 X0
+ 3. Y7 Y6 Y5 Y4 Y3 Y4 Y1 Y0
+ 4. X7' X6' X5' X4' X3' X2' X1' X0'
+ 5. Y7' Y6' Y5' Y4' Y3' Y4' Y1' Y0'
+
+ LB is left button state (0=pressed, 1=released)
+ CB is center button state (0=pressed, 1=released)
+ RB is right button state (0=pressed, 1=released)
+ X7-X0 movement in X direction since last packet in signed byte
+ format (-128..+127), positive direction right
+ Y7-Y0 movement in Y direction since last packet in signed byte
+ format (-128..+127), positive direction up
+ X7'-X0' movement in X direction since sending of X7-X0 packet in signed byte
+ format (-128..+127), positive direction right
+ Y7'-Y0' movement in Y direction since sending of Y7-Y0 in signed byte
+ format (-128..+127), positive direction up
+
+ The last two bytes in the packet (bytes 4 and 5) contains information
+ about movement data changes which have occurred after data bytes 2 and 3 have been sent. */
+
+void mouse_systems_mouse_device::mouse_trans(int dx, int dy, int nb, int mbc)
+{
+ dy =-dy;
+
+ do
+ {
+ int ddx = (dx < -128) ? -128 : (dx > 127) ? 127 : dx;
+ int ddy = (dy < -128) ? -128 : (dy > 127) ? 127 : dy;
+
+ /* KT - changed to use a function */
+ queue_data(0x080 | ((((nb & 0x04) >> 1) + ((nb & 0x02) << 1) + (nb & 0x01)) ^ 0x07));
+ queue_data(ddx);
+ queue_data(ddy);
+ /* for now... */
+ queue_data(0);
+ queue_data(0);
+ dx -= ddx;
+ dy -= ddy;
+ } while( dx || dy );
+}
+
+/**************************************************************************
+ * Check for mouse control line changes and (de-)install timer
+ **************************************************************************/
+
+void serial_mouse_device::set_mouse_enable(bool state)
+{
+ if(state && !m_enabled)
+ {
+ m_timer->adjust(attotime::zero, 0, attotime::from_hz(240));
+ output_rxd(1);
+ }
+ else if(!state && m_enabled)
+ {
+ m_timer->adjust(attotime::never);
+ m_head = m_tail = 0;
+ output_rxd(0);
+ }
+ m_enabled = state;
+
+}
+
+void microsoft_mouse_device::check_state()
+{
+ if (m_dtr && m_rts)
+ {
+ /* RTS toggled */
+ if (!m_old_rts && m_rts)
+ {
+ /* reset mouse */
+ serial_mouse_device::device_reset();
+ /* Identify as Microsoft 3 Button Mouse */
+ queue_data('M');
+ queue_data('3');
+ }
+ /* start a timer to scan the mouse input */
+ set_mouse_enable(true);
+ }
+ else
+ set_mouse_enable(false);
+}
+
+
+
+/**************************************************************************
+ * Mouse INPUT_PORT declarations
+ **************************************************************************/
+
+static INPUT_PORTS_START( ser_mouse )
+ PORT_START( "ser_mouse_btn" )
+ PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Left Button") PORT_CODE(MOUSECODE_BUTTON1)
+ PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse Middle Button") PORT_CODE(MOUSECODE_BUTTON3)
+ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Mouse Right Button") PORT_CODE(MOUSECODE_BUTTON2)
+
+ PORT_START( "ser_mouse_x" ) /* Mouse - X AXIS */
+ PORT_BIT( 0xfff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1)
+
+ PORT_START( "ser_mouse_y" ) /* Mouse - Y AXIS */
+ PORT_BIT( 0xfff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1)
+INPUT_PORTS_END
+
+ioport_constructor serial_mouse_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(ser_mouse);
+}
diff --git a/src/emu/bus/rs232/ser_mouse.h b/src/emu/bus/rs232/ser_mouse.h
new file mode 100644
index 00000000000..5ba86cca495
--- /dev/null
+++ b/src/emu/bus/rs232/ser_mouse.h
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ *
+ * machine/ser_mouse.h
+ *
+ ****************************************************************************/
+
+#ifndef SER_MOUSE_H_
+#define SER_MOUSE_H_
+
+#include "rs232.h"
+
+class serial_mouse_device :
+ public device_t,
+ public device_rs232_port_interface,
+ public device_serial_interface
+{
+public:
+ serial_mouse_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);
+
+ virtual ioport_constructor device_input_ports() const;
+
+protected:
+ virtual void device_start();
+ virtual void device_reset();
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
+ virtual void mouse_trans(int dx, int dy, int nb, int mbc) = 0;
+ virtual void set_frame() = 0;
+ void set_mouse_enable(bool state);
+ void queue_data(UINT8 data) {m_queue[m_head] = data; ++m_head %= 256;}
+ UINT8 unqueue_data() {UINT8 ret = m_queue[m_tail]; ++m_tail %= 256; return ret;}
+ virtual void input_callback(UINT8 state) { m_input_state = state; }
+ virtual void tra_complete();
+ virtual void tra_callback();
+private:
+ UINT8 m_queue[256];
+ UINT8 m_head, m_tail, m_mb;
+
+ emu_timer *m_timer;
+ bool m_enabled;
+
+ required_ioport m_x;
+ required_ioport m_y;
+ required_ioport m_btn;
+};
+
+class microsoft_mouse_device : public serial_mouse_device
+{
+public:
+ microsoft_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ virtual DECLARE_WRITE_LINE_MEMBER( input_dtr ) { m_dtr = state; check_state(); }
+ virtual DECLARE_WRITE_LINE_MEMBER( input_rts ) { m_rts = state; check_state(); m_old_rts = state; }
+
+protected:
+ virtual void set_frame() { set_data_frame(1, 7, PARITY_NONE, STOP_BITS_2); }
+ virtual void mouse_trans(int dx, int dy, int nb, int mbc);
+ virtual void device_reset() {m_old_rts = 0; serial_mouse_device::device_reset();}
+
+private:
+ void check_state();
+ int m_dtr;
+ int m_rts;
+ int m_old_rts;
+};
+
+extern const device_type MSFT_SERIAL_MOUSE;
+
+class mouse_systems_mouse_device : public serial_mouse_device
+{
+public:
+ mouse_systems_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ virtual DECLARE_WRITE_LINE_MEMBER( input_dtr ) { m_dtr = state; check_state(); }
+ virtual DECLARE_WRITE_LINE_MEMBER( input_rts ) { m_rts = state; check_state(); }
+
+protected:
+ virtual void set_frame() { set_data_frame(1, 8, PARITY_NONE, STOP_BITS_2); }
+ virtual void mouse_trans(int dx, int dy, int nb, int mbc);
+
+private:
+ void check_state() { set_mouse_enable((m_dtr && m_rts)?true:false); }
+ int m_dtr;
+ int m_rts;
+};
+
+extern const device_type MSYSTEM_SERIAL_MOUSE;
+
+#endif /* SER_MOUSE_H_ */
diff --git a/src/emu/bus/rs232/terminal.c b/src/emu/bus/rs232/terminal.c
new file mode 100644
index 00000000000..b2ba0692743
--- /dev/null
+++ b/src/emu/bus/rs232/terminal.c
@@ -0,0 +1,157 @@
+#include "terminal.h"
+
+static INPUT_PORTS_START(serial_terminal)
+ PORT_INCLUDE(generic_terminal)
+ PORT_START("TERM_TXBAUD")
+ PORT_CONFNAME(0xff, 0x06, "TX Baud") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, serial_terminal_device, update_serial)
+ PORT_CONFSETTING( 0x0d, "110")
+ PORT_CONFSETTING( 0x00, "150")
+ PORT_CONFSETTING( 0x01, "300")
+ PORT_CONFSETTING( 0x02, "600")
+ PORT_CONFSETTING( 0x03, "1200")
+ PORT_CONFSETTING( 0x04, "2400")
+ PORT_CONFSETTING( 0x05, "4800")
+ PORT_CONFSETTING( 0x06, "9600")
+ PORT_CONFSETTING( 0x07, "14400")
+ PORT_CONFSETTING( 0x08, "19200")
+ PORT_CONFSETTING( 0x09, "28800")
+ PORT_CONFSETTING( 0x0a, "38400")
+ PORT_CONFSETTING( 0x0b, "57600")
+ PORT_CONFSETTING( 0x0c, "115200")
+
+ PORT_START("TERM_RXBAUD")
+ PORT_CONFNAME(0xff, 0x06, "RX Baud") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, serial_terminal_device, update_serial)
+ PORT_CONFSETTING( 0x0d, "110")
+ PORT_CONFSETTING( 0x00, "150")
+ PORT_CONFSETTING( 0x01, "300")
+ PORT_CONFSETTING( 0x02, "600")
+ PORT_CONFSETTING( 0x03, "1200")
+ PORT_CONFSETTING( 0x04, "2400")
+ PORT_CONFSETTING( 0x05, "4800")
+ PORT_CONFSETTING( 0x06, "9600")
+ PORT_CONFSETTING( 0x07, "14400")
+ PORT_CONFSETTING( 0x08, "19200")
+ PORT_CONFSETTING( 0x09, "28800")
+ PORT_CONFSETTING( 0x0a, "38400")
+ PORT_CONFSETTING( 0x0b, "57600")
+ PORT_CONFSETTING( 0x0c, "115200")
+
+ PORT_START("TERM_STARTBITS")
+ PORT_CONFNAME(0xff, 0x01, "Start Bits") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, serial_terminal_device, update_serial)
+ PORT_CONFSETTING( 0x00, "0")
+ PORT_CONFSETTING( 0x01, "1")
+
+ PORT_START("TERM_DATABITS")
+ PORT_CONFNAME(0xff, 0x03, "Data Bits") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, serial_terminal_device, update_serial)
+ PORT_CONFSETTING( 0x00, "5")
+ PORT_CONFSETTING( 0x01, "6")
+ PORT_CONFSETTING( 0x02, "7")
+ PORT_CONFSETTING( 0x03, "8")
+ PORT_CONFSETTING( 0x04, "9")
+
+ PORT_START("TERM_PARITY")
+ PORT_CONFNAME(0xff, 0x00, "Parity") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, serial_terminal_device, update_serial)
+ PORT_CONFSETTING( 0x00, "None")
+ PORT_CONFSETTING( 0x01, "Odd")
+ PORT_CONFSETTING( 0x02, "Even")
+ PORT_CONFSETTING( 0x03, "Mark")
+ PORT_CONFSETTING( 0x04, "Space")
+
+ PORT_START("TERM_STOPBITS")
+ PORT_CONFNAME(0xff, 0x01, "Stop Bits") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, serial_terminal_device, update_serial)
+ PORT_CONFSETTING( 0x00, "0")
+ PORT_CONFSETTING( 0x01, "1")
+ PORT_CONFSETTING( 0x02, "1.5")
+ PORT_CONFSETTING( 0x03, "2")
+INPUT_PORTS_END
+
+ioport_constructor serial_terminal_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(serial_terminal);
+}
+
+serial_terminal_device::serial_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : generic_terminal_device(mconfig, SERIAL_TERMINAL, "Serial Terminal", tag, owner, clock, "serial_terminal", __FILE__),
+ device_serial_interface(mconfig, *this),
+ device_rs232_port_interface(mconfig, *this),
+ m_io_term_txbaud(*this, "TERM_TXBAUD"),
+ m_io_term_rxbaud(*this, "TERM_RXBAUD"),
+ m_io_term_startbits(*this, "TERM_STARTBITS"),
+ m_io_term_databits(*this, "TERM_DATABITS"),
+ m_io_term_parity(*this, "TERM_PARITY"),
+ m_io_term_stopbits(*this, "TERM_STOPBITS")
+{
+}
+
+void serial_terminal_device::device_start()
+{
+}
+
+WRITE_LINE_MEMBER(serial_terminal_device::update_serial)
+{
+ static const int m_baud[] = {150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 110};
+ static const int m_startbits[] = {0, 1};
+ static const int m_databits[] = {5, 6, 7, 8, 9};
+ static const parity_t m_parity[] = {PARITY_NONE, PARITY_ODD, PARITY_EVEN, PARITY_MARK, PARITY_SPACE};
+ static const stop_bits_t m_stopbits[] = {STOP_BITS_0, STOP_BITS_1, STOP_BITS_1_5, STOP_BITS_2};
+
+ UINT8 startbits = m_io_term_startbits->read();
+ UINT8 databits = m_io_term_databits->read();
+ UINT8 parity = m_io_term_parity->read();
+ UINT8 stopbits = m_io_term_stopbits->read();
+
+ set_data_frame(m_startbits[startbits], m_databits[databits], m_parity[parity], m_stopbits[stopbits]);
+
+ UINT8 txbaud = m_io_term_txbaud->read();
+ set_tra_rate(m_baud[txbaud]);
+
+ UINT8 rxbaud = m_io_term_rxbaud->read();
+ set_rcv_rate(m_baud[rxbaud]);
+}
+
+void serial_terminal_device::device_reset()
+{
+ generic_terminal_device::device_reset();
+
+ output_rxd(1);
+
+ update_serial(0);
+}
+
+void serial_terminal_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ device_serial_interface::device_timer(timer, id, param, ptr);
+}
+
+void serial_terminal_device::send_key(UINT8 code)
+{
+ if(is_transmit_register_empty())
+ {
+ transmit_register_setup(code);
+ return;
+ }
+ m_key_valid = true;
+ m_curr_key = code;
+}
+
+void serial_terminal_device::tra_callback()
+{
+ output_rxd(transmit_register_get_data_bit());
+}
+
+void serial_terminal_device::tra_complete()
+{
+ if(m_key_valid)
+ {
+ transmit_register_setup(m_curr_key);
+ m_key_valid = false;
+ }
+}
+
+void serial_terminal_device::rcv_complete()
+{
+ receive_register_extract();
+ term_write(get_received_char());
+}
+
+const device_type SERIAL_TERMINAL = &device_creator<serial_terminal_device>;
diff --git a/src/emu/bus/rs232/terminal.h b/src/emu/bus/rs232/terminal.h
new file mode 100644
index 00000000000..ec382457dc7
--- /dev/null
+++ b/src/emu/bus/rs232/terminal.h
@@ -0,0 +1,45 @@
+#ifndef __RS232_TERMINAL_H__
+#define __RS232_TERMINAL_H__
+
+#include "rs232.h"
+#include "machine/terminal.h"
+
+
+class serial_terminal_device : public generic_terminal_device,
+ public device_serial_interface,
+ public device_rs232_port_interface
+{
+public:
+ serial_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ virtual DECLARE_WRITE_LINE_MEMBER( input_txd ) { device_serial_interface::rx_w(state); }
+
+ DECLARE_WRITE_LINE_MEMBER(update_serial);
+
+protected:
+ virtual void device_start();
+ virtual void device_reset();
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
+ virtual ioport_constructor device_input_ports() const;
+
+ virtual void tra_callback();
+ virtual void tra_complete();
+ virtual void rcv_complete();
+ virtual void input_callback(UINT8 state) { m_input_state = state; }
+ virtual void send_key(UINT8 code);
+
+private:
+ required_ioport m_io_term_txbaud;
+ required_ioport m_io_term_rxbaud;
+ required_ioport m_io_term_startbits;
+ required_ioport m_io_term_databits;
+ required_ioport m_io_term_parity;
+ required_ioport m_io_term_stopbits;
+
+ UINT8 m_curr_key;
+ bool m_key_valid;
+};
+
+extern const device_type SERIAL_TERMINAL;
+
+#endif /* __RS232_TERMINAL_H__ */
diff --git a/src/emu/bus/s100/wunderbus.c b/src/emu/bus/s100/wunderbus.c
index e28f87fbbed..7f0f0e4ed2f 100644
--- a/src/emu/bus/s100/wunderbus.c
+++ b/src/emu/bus/s100/wunderbus.c
@@ -10,6 +10,7 @@
**********************************************************************/
#include "wunderbus.h"
+#include "bus/rs232/rs232.h"
@@ -66,9 +67,9 @@ WRITE_LINE_MEMBER( s100_wunderbus_device::pic_int_w )
static ins8250_interface ace1_intf =
{
- DEVCB_DEVICE_LINE_MEMBER(RS232_A_TAG, serial_port_device, tx),
- DEVCB_DEVICE_LINE_MEMBER(RS232_A_TAG, rs232_port_device, dtr_w),
- DEVCB_DEVICE_LINE_MEMBER(RS232_A_TAG, rs232_port_device, rts_w),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_A_TAG, rs232_port_device, write_txd),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_A_TAG, rs232_port_device, write_dtr),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_A_TAG, rs232_port_device, write_rts),
DEVCB_DEVICE_LINE_MEMBER(I8259A_TAG, pic8259_device, ir3_w),
DEVCB_NULL,
DEVCB_NULL
@@ -81,9 +82,9 @@ static ins8250_interface ace1_intf =
static ins8250_interface ace2_intf =
{
- DEVCB_DEVICE_LINE_MEMBER(RS232_B_TAG, serial_port_device, tx),
- DEVCB_DEVICE_LINE_MEMBER(RS232_B_TAG, rs232_port_device, dtr_w),
- DEVCB_DEVICE_LINE_MEMBER(RS232_B_TAG, rs232_port_device, rts_w),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_B_TAG, rs232_port_device, write_txd),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_B_TAG, rs232_port_device, write_dtr),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_B_TAG, rs232_port_device, write_rts),
DEVCB_DEVICE_LINE_MEMBER(I8259A_TAG, pic8259_device, ir4_w),
DEVCB_NULL,
DEVCB_NULL
@@ -96,9 +97,9 @@ static ins8250_interface ace2_intf =
static ins8250_interface ace3_intf =
{
- DEVCB_DEVICE_LINE_MEMBER(RS232_C_TAG, serial_port_device, tx),
- DEVCB_DEVICE_LINE_MEMBER(RS232_C_TAG, rs232_port_device, dtr_w),
- DEVCB_DEVICE_LINE_MEMBER(RS232_C_TAG, rs232_port_device, rts_w),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_C_TAG, rs232_port_device, write_txd),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_C_TAG, rs232_port_device, write_dtr),
+ DEVCB_DEVICE_LINE_MEMBER(RS232_C_TAG, rs232_port_device, write_rts),
DEVCB_DEVICE_LINE_MEMBER(I8259A_TAG, pic8259_device, ir5_w),
DEVCB_NULL,
DEVCB_NULL
@@ -140,26 +141,26 @@ static MACHINE_CONFIG_FRAGMENT( s100_wunderbus )
MCFG_INS8250_ADD(INS8250_3_TAG, ace3_intf, XTAL_18_432MHz/10)
MCFG_RS232_PORT_ADD(RS232_A_TAG, default_rs232_devices, "serial_terminal")
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, rx_w))
- MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, dcd_w))
- MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, dsr_w))
- MCFG_RS232_OUT_RI_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, ri_w))
- MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, cts_w))
+ MCFG_RS232_RXD_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, rx_w))
+ MCFG_RS232_DCD_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, dcd_w))
+ MCFG_RS232_DSR_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, dsr_w))
+ MCFG_RS232_RI_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, ri_w))
+ MCFG_RS232_CTS_HANDLER(DEVWRITELINE(INS8250_1_TAG, ins8250_uart_device, cts_w))
MCFG_DEVICE_CARD_DEVICE_INPUT_DEFAULTS("serial_terminal", terminal)
MCFG_RS232_PORT_ADD(RS232_B_TAG, default_rs232_devices, NULL)
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, rx_w))
- MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, dcd_w))
- MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, dsr_w))
- MCFG_RS232_OUT_RI_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, ri_w))
- MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, cts_w))
+ MCFG_RS232_RXD_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, rx_w))
+ MCFG_RS232_DCD_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, dcd_w))
+ MCFG_RS232_DSR_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, dsr_w))
+ MCFG_RS232_RI_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, ri_w))
+ MCFG_RS232_CTS_HANDLER(DEVWRITELINE(INS8250_2_TAG, ins8250_uart_device, cts_w))
MCFG_RS232_PORT_ADD(RS232_C_TAG, default_rs232_devices, NULL)
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, rx_w))
- MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, dcd_w))
- MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, dsr_w))
- MCFG_RS232_OUT_RI_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, ri_w))
- MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, cts_w))
+ MCFG_RS232_RXD_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, rx_w))
+ MCFG_RS232_DCD_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, dcd_w))
+ MCFG_RS232_DSR_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, dsr_w))
+ MCFG_RS232_RI_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, ri_w))
+ MCFG_RS232_CTS_HANDLER(DEVWRITELINE(INS8250_3_TAG, ins8250_uart_device, cts_w))
MCFG_UPD1990A_ADD(UPD1990C_TAG, XTAL_32_768kHz, NULL, DEVWRITELINE(DEVICE_SELF, s100_wunderbus_device, rtc_tp_w))
MACHINE_CONFIG_END
diff --git a/src/emu/bus/s100/wunderbus.h b/src/emu/bus/s100/wunderbus.h
index bb8adcc25bc..2ce59c881b8 100644
--- a/src/emu/bus/s100/wunderbus.h
+++ b/src/emu/bus/s100/wunderbus.h
@@ -14,11 +14,9 @@
#ifndef __S100_WUNDERBUS__
#define __S100_WUNDERBUS__
-#include "emu.h"
#include "s100.h"
#include "machine/ins8250.h"
#include "machine/pic8259.h"
-#include "machine/serial.h"
#include "machine/upd1990a.h"
diff --git a/src/emu/bus/vic20/vic1011.c b/src/emu/bus/vic20/vic1011.c
index e076bd3652a..5e86be9d81c 100644
--- a/src/emu/bus/vic20/vic1011.c
+++ b/src/emu/bus/vic20/vic1011.c
@@ -34,10 +34,10 @@ const device_type VIC1011 = &device_creator<vic1011_device>;
static MACHINE_CONFIG_FRAGMENT( vic1011 )
MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
- MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, output_rxd))
- MCFG_RS232_OUT_DCD_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, output_h))
- MCFG_RS232_OUT_CTS_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, output_k))
- MCFG_RS232_OUT_DSR_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, output_l))
+ MCFG_RS232_RXD_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, output_rxd))
+ MCFG_RS232_DCD_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, output_h))
+ MCFG_RS232_CTS_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, output_k))
+ MCFG_RS232_DSR_HANDLER(DEVWRITELINE(DEVICE_SELF, vic1011_device, output_l))
MACHINE_CONFIG_END
@@ -85,12 +85,12 @@ WRITE_LINE_MEMBER( vic1011_device::output_rxd )
void vic1011_device::input_d(int state)
{
- m_rs232->rts_w(state);
+ m_rs232->write_rts(state);
}
void vic1011_device::input_e(int state)
{
- m_rs232->dtr_w(state);
+ m_rs232->write_dtr(state);
}
void vic1011_device::input_j(int state)
@@ -100,5 +100,5 @@ void vic1011_device::input_j(int state)
void vic1011_device::input_m(int state)
{
- m_rs232->tx(!state);
+ m_rs232->write_txd(!state);
}
diff --git a/src/emu/bus/vic20/vic1011.h b/src/emu/bus/vic20/vic1011.h
index 90e149560d9..10c2963b75d 100644
--- a/src/emu/bus/vic20/vic1011.h
+++ b/src/emu/bus/vic20/vic1011.h
@@ -14,9 +14,8 @@
#ifndef __VIC1011__
#define __VIC1011__
-#include "emu.h"
#include "user.h"
-#include "machine/serial.h"
+#include "bus/rs232/rs232.h"
diff --git a/src/emu/emu.mak b/src/emu/emu.mak
index cbaeb86772d..8b2abe052b3 100644
--- a/src/emu/emu.mak
+++ b/src/emu/emu.mak
@@ -35,6 +35,7 @@ OBJDIRS += \
$(EMUOBJ)/bus/c64 \
$(EMUOBJ)/bus/cbm2 \
$(EMUOBJ)/bus/cbmiec \
+ $(EMUOBJ)/bus/centronics \
$(EMUOBJ)/bus/comx35 \
$(EMUOBJ)/bus/ecbbus \
$(EMUOBJ)/bus/econet \
@@ -42,9 +43,11 @@ OBJDIRS += \
$(EMUOBJ)/bus/ieee488 \
$(EMUOBJ)/bus/imi7000 \
$(EMUOBJ)/bus/isbx \
+ $(EMUOBJ)/bus/midi \
$(EMUOBJ)/bus/pc_kbd \
$(EMUOBJ)/bus/pet \
$(EMUOBJ)/bus/plus4 \
+ $(EMUOBJ)/bus/rs232 \
$(EMUOBJ)/bus/s100 \
$(EMUOBJ)/bus/vcs \
$(EMUOBJ)/bus/vic10 \
@@ -54,7 +57,6 @@ OBJDIRS += \
$(EMUOBJ)/bus/wangpc \
$(EMUOBJ)/bus/a2bus \
$(EMUOBJ)/bus/nubus \
- $(EMUOBJ)/bus/centronics \
$(EMUOBJ)/bus/iq151 \
$(EMUOBJ)/bus/kc \
$(EMUOBJ)/bus/tvc \
@@ -190,12 +192,14 @@ EMUDRIVEROBJS = \
EMUMACHINEOBJS = \
$(EMUMACHINE)/bcreader.o \
$(EMUMACHINE)/buffer.o \
- $(EMUMACHINE)/latch.o \
$(EMUMACHINE)/generic.o \
- $(EMUMACHINE)/ram.o \
- $(EMUMACHINE)/nvram.o \
+ $(EMUMACHINE)/keyboard.o \
$(EMUMACHINE)/laserdsc.o \
+ $(EMUMACHINE)/latch.o \
$(EMUMACHINE)/netlist.o \
+ $(EMUMACHINE)/nvram.o \
+ $(EMUMACHINE)/ram.o \
+ $(EMUMACHINE)/terminal.o \
EMUIMAGEDEVOBJS = \
$(EMUIMAGEDEV)/bitbngr.o \
diff --git a/src/emu/machine/keyboard.c b/src/emu/machine/keyboard.c
new file mode 100644
index 00000000000..84ba2e74129
--- /dev/null
+++ b/src/emu/machine/keyboard.c
@@ -0,0 +1,364 @@
+/***************************************************************************
+Generic ASCII Keyboard
+
+Use MCFG_ASCII_KEYBOARD_ADD to attach as a generic ascii input device in
+cases where either the driver isn't developed enough yet; or for testing;
+or for the case of a computer with an inbuilt (not serial) ascii keyboard.
+
+Example of usage in a driver.
+
+In MACHINE_CONFIG
+ MCFG_ASCII_KEYBOARD_ADD(KEYBOARD_TAG, keyboard_intf)
+
+In the code:
+
+WRITE8_MEMBER( xxx_state::kbd_put )
+{
+ (code to capture the key as it is pressed)
+}
+
+static ASCII_KEYBOARD_INTERFACE( keyboard_intf )
+{
+ DEVCB_DRIVER_MEMBER(xxx_state, kbd_put)
+};
+
+***************************************************************************/
+
+#include "machine/keyboard.h"
+
+/***************************************************************************
+ IMPLEMENTATION
+***************************************************************************/
+
+
+generic_keyboard_device::generic_keyboard_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),
+ m_io_kbd0(*this, "TERM_LINE0"),
+ m_io_kbd1(*this, "TERM_LINE1"),
+ m_io_kbd2(*this, "TERM_LINE2"),
+ m_io_kbd3(*this, "TERM_LINE3"),
+ m_io_kbd4(*this, "TERM_LINE4"),
+ m_io_kbd5(*this, "TERM_LINE5"),
+ m_io_kbd6(*this, "TERM_LINE6"),
+ m_io_kbd7(*this, "TERM_LINE7"),
+ m_io_kbdc(*this, "TERM_LINEC")
+{
+}
+
+generic_keyboard_device::generic_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, GENERIC_KEYBOARD, "Generic Keyboard", tag, owner, clock, "generic_keyboard", __FILE__),
+ m_io_kbd0(*this, "TERM_LINE0"),
+ m_io_kbd1(*this, "TERM_LINE1"),
+ m_io_kbd2(*this, "TERM_LINE2"),
+ m_io_kbd3(*this, "TERM_LINE3"),
+ m_io_kbd4(*this, "TERM_LINE4"),
+ m_io_kbd5(*this, "TERM_LINE5"),
+ m_io_kbd6(*this, "TERM_LINE6"),
+ m_io_kbd7(*this, "TERM_LINE7"),
+ m_io_kbdc(*this, "TERM_LINEC")
+{
+}
+
+
+UINT8 generic_keyboard_device::row_number(UINT8 code)
+{
+ if BIT(code,0) return 0;
+ if BIT(code,1) return 1;
+ if BIT(code,2) return 2;
+ if BIT(code,3) return 3;
+ if BIT(code,4) return 4;
+ if BIT(code,5) return 5;
+ if BIT(code,6) return 6;
+ if BIT(code,7) return 7;
+ return 0;
+}
+
+UINT8 generic_keyboard_device::keyboard_handler(UINT8 last_code, UINT8 *scan_line)
+{
+ int i;
+ UINT8 code = 0;
+ UINT8 key_code = 0;
+ UINT8 retVal = 0;
+ UINT8 shift = BIT(m_io_kbdc->read(), 1);
+ UINT8 caps = BIT(m_io_kbdc->read(), 2);
+ UINT8 ctrl = BIT(m_io_kbdc->read(), 0);
+ i = *scan_line;
+ {
+ if (i == 0) code = m_io_kbd0->read();
+ else
+ if (i == 1) code = m_io_kbd1->read();
+ else
+ if (i == 2) code = m_io_kbd2->read();
+ else
+ if (i == 3) code = m_io_kbd3->read();
+ else
+ if (i == 4) code = m_io_kbd4->read();
+ else
+ if (i == 5) code = m_io_kbd5->read();
+ else
+ if (i == 6) code = m_io_kbd6->read();
+ else
+ if (i == 7) code = m_io_kbd7->read();
+
+ if (code != 0)
+ {
+ if (i==0 && shift==0) {
+ key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs
+ }
+ if (i==0 && shift==1) {
+ key_code = 0x20 + row_number(code) + 8*i; // for shifted numbers
+ }
+ if (i==1 && shift==0) {
+ if (row_number(code) < 4) {
+ key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs
+ } else {
+ key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs
+ }
+ }
+ if (i==1 && shift==1) {
+ if (row_number(code) < 4) {
+ key_code = 0x20 + row_number(code) + 8*i; // for numbers and some signs
+ } else {
+ key_code = 0x30 + row_number(code) + 8*i; // for numbers and some signs
+ }
+ }
+ if (i>=2 && i<=4 && (shift ^ caps)==0 && ctrl==0) {
+ key_code = 0x60 + row_number(code) + (i-2)*8; // for small letters
+ }
+ if (i>=2 && i<=4 && (shift ^ caps)==1 && ctrl==0) {
+ key_code = 0x40 + row_number(code) + (i-2)*8; // for big letters
+ }
+ if (i>=2 && i<=5 && ctrl==1) {
+ key_code = 0x00 + row_number(code) + (i-2)*8; // for CTRL + letters
+ }
+ if (i==5 && shift==1 && ctrl==0) {
+ if (row_number(code)<7) {
+ if (row_number(code)<3) {
+ key_code = (caps ? 0x60 : 0x40) + row_number(code) + (i-2)*8; // for big letters
+ } else {
+ key_code = 0x60 + row_number(code) + (i-2)*8; // for upper symbols letters
+ }
+ } else {
+ key_code = 0x40 + row_number(code) + (i-2)*8; // for DEL it is switched
+ }
+ }
+ if (i==5 && shift==0 && ctrl==0) {
+ if (row_number(code)<7) {
+ if (row_number(code)<3) {
+ key_code = (caps ? 0x40 : 0x60) + row_number(code) + (i-2)*8; // for small letters
+ } else {
+ key_code = 0x40 + row_number(code) + (i-2)*8; // for lower symbols letters
+ }
+ } else {
+ key_code = 0x60 + row_number(code) + (i-2)*8; // for DEL it is switched
+ }
+ }
+
+ if (i==6) {
+ switch(row_number(code))
+ {
+/* case 0: key_code = 0x11; break;
+ case 1: key_code = 0x12; break;
+ case 2: key_code = 0x13; break;
+ case 3: key_code = 0x14; break;*/
+ case 4: key_code = 0x20; break; // Space
+ case 5: key_code = 0x0A; break; // LineFeed
+ case 6: key_code = 0x09; break; // TAB
+ case 7: key_code = 0x0D; break; // Enter
+ }
+ }
+ if (i==7)
+ {
+ switch(row_number(code))
+ {
+ case 0: key_code = 0x1B; break; // Escape
+ case 1: key_code = 0x08; break; // Backspace
+ }
+ }
+ retVal = key_code;
+ } else {
+ *scan_line += 1;
+ if (*scan_line==8) {
+ *scan_line = 0;
+ }
+ }
+ }
+ return retVal;
+}
+
+void generic_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ UINT8 new_code;
+ new_code = keyboard_handler(m_last_code, &m_scan_line);
+ if ((m_last_code != new_code) && (new_code))
+ send_key(new_code);
+ m_last_code = new_code;
+}
+
+/***************************************************************************
+ VIDEO HARDWARE
+***************************************************************************/
+
+static MACHINE_CONFIG_FRAGMENT( generic_keyboard )
+MACHINE_CONFIG_END
+
+machine_config_constructor generic_keyboard_device::device_mconfig_additions() const
+{
+ return MACHINE_CONFIG_NAME(generic_keyboard);
+}
+
+void generic_keyboard_device::device_start()
+{
+ m_keyboard_func.resolve(m_keyboard_cb, *this);
+ m_timer = timer_alloc();
+}
+
+void generic_keyboard_device::device_config_complete()
+{
+ const keyboard_interface *intf = reinterpret_cast<const keyboard_interface *>(static_config());
+ if(intf != NULL)
+ {
+ *static_cast<keyboard_interface *>(this) = *intf;
+ }
+ else
+ {
+ memset(&m_keyboard_cb, 0, sizeof(m_keyboard_cb));
+ }
+}
+
+void generic_keyboard_device::device_reset()
+{
+ m_last_code = 0;
+ m_scan_line = 0;
+ m_timer->adjust(attotime::from_hz(2400), 0, attotime::from_hz(2400));
+}
+
+/*
+Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex
+-------------------------------------------------------------------------------------
+(nul) 0 0000 0x00 | (sp) 32 0040 0x20 | @ 64 0100 0x40 | ` 96 0140 0x60
+(soh) 1 0001 0x01 | ! 33 0041 0x21 | A 65 0101 0x41 | a 97 0141 0x61
+(stx) 2 0002 0x02 | " 34 0042 0x22 | B 66 0102 0x42 | b 98 0142 0x62
+(etx) 3 0003 0x03 | # 35 0043 0x23 | C 67 0103 0x43 | c 99 0143 0x63
+(eot) 4 0004 0x04 | $ 36 0044 0x24 | D 68 0104 0x44 | d 100 0144 0x64
+(enq) 5 0005 0x05 | % 37 0045 0x25 | E 69 0105 0x45 | e 101 0145 0x65
+(ack) 6 0006 0x06 | & 38 0046 0x26 | F 70 0106 0x46 | f 102 0146 0x66
+(bel) 7 0007 0x07 | ' 39 0047 0x27 | G 71 0107 0x47 | g 103 0147 0x67
+(bs) 8 0010 0x08 | ( 40 0050 0x28 | H 72 0110 0x48 | h 104 0150 0x68
+(ht) 9 0011 0x09 | ) 41 0051 0x29 | I 73 0111 0x49 | i 105 0151 0x69
+(nl) 10 0012 0x0a | * 42 0052 0x2a | J 74 0112 0x4a | j 106 0152 0x6a
+(vt) 11 0013 0x0b | + 43 0053 0x2b | K 75 0113 0x4b | k 107 0153 0x6b
+(np) 12 0014 0x0c | , 44 0054 0x2c | L 76 0114 0x4c | l 108 0154 0x6c
+(cr) 13 0015 0x0d | - 45 0055 0x2d | M 77 0115 0x4d | m 109 0155 0x6d
+(so) 14 0016 0x0e | . 46 0056 0x2e | N 78 0116 0x4e | n 110 0156 0x6e
+(si) 15 0017 0x0f | / 47 0057 0x2f | O 79 0117 0x4f | o 111 0157 0x6f
+(dle) 16 0020 0x10 | 0 48 0060 0x30 | P 80 0120 0x50 | p 112 0160 0x70
+(dc1) 17 0021 0x11 | 1 49 0061 0x31 | Q 81 0121 0x51 | q 113 0161 0x71
+(dc2) 18 0022 0x12 | 2 50 0062 0x32 | R 82 0122 0x52 | r 114 0162 0x72
+(dc3) 19 0023 0x13 | 3 51 0063 0x33 | S 83 0123 0x53 | s 115 0163 0x73
+(dc4) 20 0024 0x14 | 4 52 0064 0x34 | T 84 0124 0x54 | t 116 0164 0x74
+(nak) 21 0025 0x15 | 5 53 0065 0x35 | U 85 0125 0x55 | u 117 0165 0x75
+(syn) 22 0026 0x16 | 6 54 0066 0x36 | V 86 0126 0x56 | v 118 0166 0x76
+(etb) 23 0027 0x17 | 7 55 0067 0x37 | W 87 0127 0x57 | w 119 0167 0x77
+(can) 24 0030 0x18 | 8 56 0070 0x38 | X 88 0130 0x58 | x 120 0170 0x78
+(em) 25 0031 0x19 | 9 57 0071 0x39 | Y 89 0131 0x59 | y 121 0171 0x79
+(sub) 26 0032 0x1a | : 58 0072 0x3a | Z 90 0132 0x5a | z 122 0172 0x7a
+(esc) 27 0033 0x1b | ; 59 0073 0x3b | [ 91 0133 0x5b | { 123 0173 0x7b
+(fs) 28 0034 0x1c | < 60 0074 0x3c | \ 92 0134 0x5c | | 124 0174 0x7c
+(gs) 29 0035 0x1d | = 61 0075 0x3d | ] 93 0135 0x5d | } 125 0175 0x7d
+(rs) 30 0036 0x1e | > 62 0076 0x3e | ^ 94 0136 0x5e | ~ 126 0176 0x7e
+(us) 31 0037 0x1f | ? 63 0077 0x3f | _ 95 0137 0x5f | (del) 127 0177 0x7f
+
+*/
+INPUT_PORTS_START( generic_keyboard )
+ PORT_START("TERM_LINEC")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Ctrl") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL)
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Caps Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK))
+ PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED)
+ PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
+
+ PORT_START("TERM_LINE0")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"')
+ PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
+ PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
+ PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
+ PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
+ PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'')
+
+ PORT_START("TERM_LINE1")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*')
+ PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
+ PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
+ PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=')
+ PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
+ PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
+
+ PORT_START("TERM_LINE2")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_END) PORT_CHAR('`') PORT_CHAR('@')
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
+ PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
+ PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
+ PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
+ PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
+ PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
+
+ PORT_START("TERM_LINE3")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
+ PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
+ PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
+ PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
+ PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
+ PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
+
+ PORT_START("TERM_LINE4")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
+ PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
+ PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
+ PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
+ PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
+ PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
+
+ PORT_START("TERM_LINE5")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
+ PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
+ PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|')
+ PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
+ PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('^') PORT_CHAR('~')
+ PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("DEL") PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL))
+
+ PORT_START("TERM_LINE6")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
+ PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
+ PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
+ PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
+ PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LF") PORT_CODE(KEYCODE_RALT) PORT_CHAR(10)
+ PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR(9)
+ PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
+
+ PORT_START("TERM_LINE7")
+ PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Escape") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
+ PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Backspace") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
+INPUT_PORTS_END
+
+ioport_constructor generic_keyboard_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(generic_keyboard);
+}
+
+const device_type GENERIC_KEYBOARD = &device_creator<generic_keyboard_device>;
diff --git a/src/emu/machine/keyboard.h b/src/emu/machine/keyboard.h
new file mode 100644
index 00000000000..bb03845f8ef
--- /dev/null
+++ b/src/emu/machine/keyboard.h
@@ -0,0 +1,69 @@
+#ifndef __KEYBOARD_H__
+#define __KEYBOARD_H__
+
+#include "emu.h"
+
+/***************************************************************************
+ TYPE DEFINITIONS
+***************************************************************************/
+
+struct keyboard_interface
+{
+ devcb_write8 m_keyboard_cb;
+};
+
+#define ASCII_KEYBOARD_INTERFACE(name) const keyboard_interface (name) =
+
+/***************************************************************************
+ DEVICE CONFIGURATION MACROS
+***************************************************************************/
+
+#define MCFG_ASCII_KEYBOARD_ADD(_tag, _intrf) \
+ MCFG_DEVICE_ADD(_tag, GENERIC_KEYBOARD, 0) \
+ MCFG_DEVICE_CONFIG(_intrf)
+
+/***************************************************************************
+ FUNCTION PROTOTYPES
+***************************************************************************/
+
+INPUT_PORTS_EXTERN( generic_keyboard );
+
+class generic_keyboard_device :
+ public device_t,
+ public keyboard_interface
+{
+public:
+ generic_keyboard_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);
+ generic_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ virtual ioport_constructor device_input_ports() const;
+ virtual machine_config_constructor device_mconfig_additions() const;
+protected:
+ required_ioport m_io_kbd0;
+ required_ioport m_io_kbd1;
+ required_ioport m_io_kbd2;
+ required_ioport m_io_kbd3;
+ required_ioport m_io_kbd4;
+ required_ioport m_io_kbd5;
+ required_ioport m_io_kbd6;
+ required_ioport m_io_kbd7;
+ required_ioport m_io_kbdc;
+
+ virtual void device_start();
+ virtual void device_reset();
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
+ virtual void device_config_complete();
+ virtual void send_key(UINT8 code) { m_keyboard_func(0, code); }
+ emu_timer *m_timer;
+private:
+ virtual UINT8 keyboard_handler(UINT8 last_code, UINT8 *scan_line);
+ UINT8 row_number(UINT8 code);
+ UINT8 m_last_code;
+ UINT8 m_scan_line;
+
+ devcb_resolved_write8 m_keyboard_func;
+};
+
+extern const device_type GENERIC_KEYBOARD;
+
+#endif /* __KEYBOARD_H__ */
diff --git a/src/emu/machine/terminal.c b/src/emu/machine/terminal.c
new file mode 100644
index 00000000000..f9c091445e8
--- /dev/null
+++ b/src/emu/machine/terminal.c
@@ -0,0 +1,415 @@
+#include "machine/terminal.h"
+
+#define KEYBOARD_TAG "keyboard"
+
+/***************************************************************************
+ IMPLEMENTATION
+***************************************************************************/
+
+static const UINT8 terminal_font[256*16] =
+{
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x92, 0x44, 0x92, 0x44, 0x92, 0x44, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x88, 0x88, 0xf8, 0x88, 0x88, 0x3e, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf0, 0x80, 0xe0, 0x80, 0x9e, 0x10, 0x1c, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x78, 0x80, 0x80, 0x78, 0x3c, 0x22, 0x3c, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x80, 0x80, 0xf8, 0x3e, 0x20, 0x3c, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x10, 0xfe, 0x10, 0x10, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x88, 0xc8, 0xa8, 0x98, 0x88, 0x20, 0x20, 0x20, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x88, 0x88, 0x50, 0x20, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x10, 0x10, 0x10, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x10, 0x10, 0x10, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x10, 0x10, 0x10, 0xff, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x10, 0x10, 0x10, 0x1f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x10, 0x10, 0x10, 0xf0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x10, 0x10, 0x10, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x08, 0x20, 0x80, 0x20, 0x08, 0x02, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x20, 0x08, 0x02, 0x08, 0x20, 0x80, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfe, 0x24, 0x24, 0x24, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x04, 0xfe, 0x10, 0xfe, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x1c, 0x22, 0x20, 0xf8, 0x20, 0x78, 0xa6, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x24, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x48, 0x48, 0xfc, 0x48, 0xfc, 0x48, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x7c, 0x90, 0x7c, 0x12, 0x7c, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc2, 0xc4, 0x08, 0x10, 0x20, 0x46, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x70, 0x88, 0x88, 0x70, 0x8a, 0x84, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x18, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x44, 0x28, 0xfe, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x10, 0xfe, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x44, 0x82, 0x82, 0x82, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x30, 0x50, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x78, 0x84, 0x02, 0x1c, 0x60, 0x80, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfe, 0x04, 0x08, 0x1c, 0x02, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfe, 0x80, 0xbc, 0xc2, 0x02, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3c, 0x42, 0x80, 0xbc, 0xc2, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfe, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7c, 0x82, 0x82, 0x7c, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x78, 0x84, 0x86, 0x7a, 0x02, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x08, 0x20, 0x80, 0x20, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x20, 0x08, 0x02, 0x08, 0x20, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7c, 0x82, 0x0c, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7c, 0x82, 0x8a, 0x92, 0x9c, 0x80, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x28, 0x44, 0x82, 0xfe, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0x42, 0x42, 0x7c, 0x42, 0x42, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3c, 0x42, 0x80, 0x80, 0x80, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf8, 0x44, 0x42, 0x42, 0x42, 0x44, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfe, 0x80, 0x80, 0xf8, 0x80, 0x80, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfe, 0x80, 0x80, 0xf8, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3c, 0x42, 0x80, 0x80, 0x8e, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0e, 0x04, 0x04, 0x04, 0x04, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x82, 0x8c, 0xb0, 0xc0, 0xb0, 0x8c, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x82, 0xc6, 0xaa, 0x92, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x82, 0xc2, 0xa2, 0x92, 0x8a, 0x86, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0x82, 0x82, 0xfc, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7c, 0x82, 0x82, 0x82, 0x8a, 0x84, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0x82, 0x82, 0xfc, 0x88, 0x84, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7c, 0x82, 0x80, 0x7c, 0x02, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfe, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x82, 0x82, 0x82, 0x92, 0x92, 0xaa, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfe, 0x04, 0x08, 0x10, 0x20, 0x40, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x3c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x28, 0x44, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x30, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7c, 0x02, 0x7e, 0x82, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x80, 0xbc, 0xc2, 0x82, 0xc2, 0xbc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x3c, 0x42, 0x80, 0x40, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x02, 0x7a, 0x86, 0x82, 0x86, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7c, 0x82, 0xfe, 0x80, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x1c, 0x22, 0x20, 0xf8, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7c, 0x84, 0x84, 0x7c, 0x04, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//g
+ 0x00, 0x80, 0x80, 0xbc, 0xc2, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x30, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x80, 0x88, 0x90, 0xe0, 0x88, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xc4, 0xaa, 0x92, 0x92, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xbc, 0xc2, 0x82, 0x82, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7c, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xbc, 0xc2, 0xc2, 0xbc, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7a, 0x86, 0x86, 0x7a, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x9c, 0x62, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x7c, 0x80, 0x7c, 0x02, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x20, 0x20, 0xf8, 0x20, 0x20, 0x24, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x82, 0x82, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x82, 0x82, 0x92, 0xaa, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x84, 0x48, 0x30, 0x48, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x84, 0x84, 0x8c, 0x74, 0x04, 0x84, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfe, 0x04, 0x18, 0x20, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0e, 0x10, 0x10, 0x60, 0x10, 0x10, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x10, 0x10, 0x0c, 0x10, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x62, 0x92, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+generic_terminal_device::generic_terminal_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),
+ m_io_term_conf(*this, "TERM_CONF")
+{
+}
+
+generic_terminal_device::generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, GENERIC_TERMINAL, "Generic Terminal", tag, owner, clock, "generic_terminal", __FILE__),
+ m_io_term_conf(*this, "TERM_CONF")
+{
+}
+
+void generic_terminal_device::scroll_line()
+{
+ memmove(m_buffer,m_buffer+TERMINAL_WIDTH,(TERMINAL_HEIGHT-1)*TERMINAL_WIDTH);
+ memset(m_buffer + TERMINAL_WIDTH*(TERMINAL_HEIGHT-1),0x20,TERMINAL_WIDTH);
+}
+
+void generic_terminal_device::write_char(UINT8 data)
+{
+ m_buffer[m_y_pos*TERMINAL_WIDTH+m_x_pos] = data;
+ m_x_pos++;
+ if (m_x_pos >= TERMINAL_WIDTH)
+ {
+ m_x_pos = 0;
+ m_y_pos++;
+ if (m_y_pos >= TERMINAL_HEIGHT)
+ {
+ scroll_line();
+ m_y_pos = TERMINAL_HEIGHT-1;
+ }
+ }
+}
+
+void generic_terminal_device::clear()
+{
+ memset(m_buffer,0x20,TERMINAL_WIDTH*TERMINAL_HEIGHT);
+ m_x_pos = 0;
+ m_y_pos = 0;
+}
+
+void generic_terminal_device::term_write(UINT8 data)
+{
+ if (data > 0x1f)
+ {
+ // printable char
+ if (data!=0x7f) write_char(data);
+ }
+ else
+ {
+ switch(data)
+ {
+ case 0x07 : // bell
+ break;
+
+ case 0x08: if (m_x_pos) m_x_pos--;
+ break;
+
+ case 0x09: m_x_pos = (m_x_pos & 0xf8) + 8;
+ if (m_x_pos >= TERMINAL_WIDTH)
+ m_x_pos = TERMINAL_WIDTH-1;
+ break;
+
+ case 0x0a: m_y_pos++;
+ m_x_pos = 0;
+ if (m_y_pos >= TERMINAL_HEIGHT)
+ {
+ scroll_line();
+ m_y_pos = TERMINAL_HEIGHT-1;
+ }
+ break;
+
+ case 0x0b: if (m_y_pos) m_y_pos--;
+ break;
+
+ case 0x0c: clear();
+ break;
+
+ case 0x0d: m_x_pos = 0;
+ break;
+
+ case 0x1e: m_x_pos = 0;
+ m_y_pos = 0;
+ break;
+ }
+ }
+}
+
+/***************************************************************************
+ VIDEO HARDWARE
+***************************************************************************/
+UINT32 generic_terminal_device::update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect)
+{
+ UINT8 options = m_io_term_conf->read();
+ UINT16 cursor = m_y_pos * TERMINAL_WIDTH + m_x_pos;
+ UINT8 y,ra,chr,gfx;
+ UINT16 sy=0,ma=0,x;
+ UINT32 font_color;
+ switch (options & 0x30)
+ {
+ case 0x10:
+ font_color = 0x00ff7e00;
+ break;
+ case 0x20:
+ font_color = 0x00ffffff;
+ break;
+ default:
+ font_color = 0x0000ff00;
+ break;
+ }
+
+ m_framecnt++;
+
+ for (y = 0; y < TERMINAL_HEIGHT; y++)
+ {
+ for (ra = 0; ra < 10; ra++)
+ {
+ UINT32 *p = &bitmap.pix32(sy++);
+
+ for (x = ma; x < ma + TERMINAL_WIDTH; x++)
+ {
+ chr = m_buffer[x];
+ gfx = terminal_font[(chr<<4) | ra ];
+
+ if ((x == cursor) && (options & 1)) // at cursor position and want a cursor
+ {
+ if ((options & 2) || (ra == 9)) // block, or underline & at bottom line
+ {
+ if ((options & 4) && (m_framecnt & 8)) // want blink & time to blink
+ {
+ }
+ else
+ {
+ if (options & 8)
+ gfx ^= 0xff; // invert
+ else
+ gfx |= 0xff; // overwrite
+ }
+ }
+ }
+
+ /* Display a scanline of a character */
+ *p++ = (BIT( gfx, 7 ))?font_color:0;
+ *p++ = (BIT( gfx, 6 ))?font_color:0;
+ *p++ = (BIT( gfx, 5 ))?font_color:0;
+ *p++ = (BIT( gfx, 4 ))?font_color:0;
+ *p++ = (BIT( gfx, 3 ))?font_color:0;
+ *p++ = (BIT( gfx, 2 ))?font_color:0;
+ *p++ = (BIT( gfx, 1 ))?font_color:0;
+ *p++ = (BIT( gfx, 0 ))?font_color:0;
+ }
+ }
+ ma+=TERMINAL_WIDTH;
+ }
+ return 0;
+}
+
+WRITE8_MEMBER( generic_terminal_device::kbd_put )
+{
+ if (data)
+ send_key(data);
+}
+
+static ASCII_KEYBOARD_INTERFACE( keyboard_intf )
+{
+ DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, generic_terminal_device, kbd_put)
+};
+
+/***************************************************************************
+ VIDEO HARDWARE
+***************************************************************************/
+
+static MACHINE_CONFIG_FRAGMENT( generic_terminal )
+ MCFG_SCREEN_ADD(TERMINAL_SCREEN_TAG, RASTER)
+ MCFG_SCREEN_REFRESH_RATE(50)
+ MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
+ MCFG_SCREEN_SIZE(TERMINAL_WIDTH*8, TERMINAL_HEIGHT*10)
+ MCFG_SCREEN_VISIBLE_AREA(0, TERMINAL_WIDTH*8-1, 0, TERMINAL_HEIGHT*10-1)
+ MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, generic_terminal_device, update)
+ MCFG_ASCII_KEYBOARD_ADD(KEYBOARD_TAG, keyboard_intf)
+MACHINE_CONFIG_END
+
+machine_config_constructor generic_terminal_device::device_mconfig_additions() const
+{
+ return MACHINE_CONFIG_NAME(generic_terminal);
+}
+
+void generic_terminal_device::device_start()
+{
+ m_keyboard_func.resolve(m_keyboard_cb, *this);
+}
+
+void generic_terminal_device::device_config_complete()
+{
+ const terminal_interface *intf = reinterpret_cast<const terminal_interface *>(static_config());
+ if(intf != NULL)
+ {
+ *static_cast<terminal_interface *>(this) = *intf;
+ }
+ else
+ {
+ memset(&m_keyboard_cb, 0, sizeof(m_keyboard_cb));
+ }
+}
+
+void generic_terminal_device::device_reset()
+{
+ clear();
+ m_framecnt = 0;
+}
+
+/*
+Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex
+-------------------------------------------------------------------------------------
+(nul) 0 0000 0x00 | (sp) 32 0040 0x20 | @ 64 0100 0x40 | ` 96 0140 0x60
+(soh) 1 0001 0x01 | ! 33 0041 0x21 | A 65 0101 0x41 | a 97 0141 0x61
+(stx) 2 0002 0x02 | " 34 0042 0x22 | B 66 0102 0x42 | b 98 0142 0x62
+(etx) 3 0003 0x03 | # 35 0043 0x23 | C 67 0103 0x43 | c 99 0143 0x63
+(eot) 4 0004 0x04 | $ 36 0044 0x24 | D 68 0104 0x44 | d 100 0144 0x64
+(enq) 5 0005 0x05 | % 37 0045 0x25 | E 69 0105 0x45 | e 101 0145 0x65
+(ack) 6 0006 0x06 | & 38 0046 0x26 | F 70 0106 0x46 | f 102 0146 0x66
+(bel) 7 0007 0x07 | ' 39 0047 0x27 | G 71 0107 0x47 | g 103 0147 0x67
+(bs) 8 0010 0x08 | ( 40 0050 0x28 | H 72 0110 0x48 | h 104 0150 0x68
+(ht) 9 0011 0x09 | ) 41 0051 0x29 | I 73 0111 0x49 | i 105 0151 0x69
+(nl) 10 0012 0x0a | * 42 0052 0x2a | J 74 0112 0x4a | j 106 0152 0x6a
+(vt) 11 0013 0x0b | + 43 0053 0x2b | K 75 0113 0x4b | k 107 0153 0x6b
+(np) 12 0014 0x0c | , 44 0054 0x2c | L 76 0114 0x4c | l 108 0154 0x6c
+(cr) 13 0015 0x0d | - 45 0055 0x2d | M 77 0115 0x4d | m 109 0155 0x6d
+(so) 14 0016 0x0e | . 46 0056 0x2e | N 78 0116 0x4e | n 110 0156 0x6e
+(si) 15 0017 0x0f | / 47 0057 0x2f | O 79 0117 0x4f | o 111 0157 0x6f
+(dle) 16 0020 0x10 | 0 48 0060 0x30 | P 80 0120 0x50 | p 112 0160 0x70
+(dc1) 17 0021 0x11 | 1 49 0061 0x31 | Q 81 0121 0x51 | q 113 0161 0x71
+(dc2) 18 0022 0x12 | 2 50 0062 0x32 | R 82 0122 0x52 | r 114 0162 0x72
+(dc3) 19 0023 0x13 | 3 51 0063 0x33 | S 83 0123 0x53 | s 115 0163 0x73
+(dc4) 20 0024 0x14 | 4 52 0064 0x34 | T 84 0124 0x54 | t 116 0164 0x74
+(nak) 21 0025 0x15 | 5 53 0065 0x35 | U 85 0125 0x55 | u 117 0165 0x75
+(syn) 22 0026 0x16 | 6 54 0066 0x36 | V 86 0126 0x56 | v 118 0166 0x76
+(etb) 23 0027 0x17 | 7 55 0067 0x37 | W 87 0127 0x57 | w 119 0167 0x77
+(can) 24 0030 0x18 | 8 56 0070 0x38 | X 88 0130 0x58 | x 120 0170 0x78
+(em) 25 0031 0x19 | 9 57 0071 0x39 | Y 89 0131 0x59 | y 121 0171 0x79
+(sub) 26 0032 0x1a | : 58 0072 0x3a | Z 90 0132 0x5a | z 122 0172 0x7a
+(esc) 27 0033 0x1b | ; 59 0073 0x3b | [ 91 0133 0x5b | { 123 0173 0x7b
+(fs) 28 0034 0x1c | < 60 0074 0x3c | \ 92 0134 0x5c | | 124 0174 0x7c
+(gs) 29 0035 0x1d | = 61 0075 0x3d | ] 93 0135 0x5d | } 125 0175 0x7d
+(rs) 30 0036 0x1e | > 62 0076 0x3e | ^ 94 0136 0x5e | ~ 126 0176 0x7e
+(us) 31 0037 0x1f | ? 63 0077 0x3f | _ 95 0137 0x5f | (del) 127 0177 0x7f
+
+*/
+INPUT_PORTS_START( generic_terminal )
+ PORT_START("TERM_CONF")
+ PORT_CONFNAME( 0x01, 0x01, "Cursor")
+ PORT_CONFSETTING( 0x00, DEF_STR(No))
+ PORT_CONFSETTING( 0x01, DEF_STR(Yes))
+ PORT_CONFNAME( 0x02, 0x02, "Type")
+ PORT_CONFSETTING( 0x00, "Underline")
+ PORT_CONFSETTING( 0x02, "Block")
+ PORT_CONFNAME( 0x04, 0x04, "Blinking")
+ PORT_CONFSETTING( 0x00, DEF_STR(No))
+ PORT_CONFSETTING( 0x04, DEF_STR(Yes))
+ PORT_CONFNAME( 0x08, 0x08, "Invert")
+ PORT_CONFSETTING( 0x00, DEF_STR(No))
+ PORT_CONFSETTING( 0x08, DEF_STR(Yes))
+ PORT_CONFNAME( 0x30, 0x00, "Color")
+ PORT_CONFSETTING( 0x00, "Green")
+ PORT_CONFSETTING( 0x10, "Amber")
+ PORT_CONFSETTING( 0x20, "White")
+INPUT_PORTS_END
+
+ioport_constructor generic_terminal_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(generic_terminal);
+}
+
+const device_type GENERIC_TERMINAL = &device_creator<generic_terminal_device>;
+
diff --git a/src/emu/machine/terminal.h b/src/emu/machine/terminal.h
new file mode 100644
index 00000000000..59e91cfd7d6
--- /dev/null
+++ b/src/emu/machine/terminal.h
@@ -0,0 +1,75 @@
+#ifndef __TERMINAL_H__
+#define __TERMINAL_H__
+
+#include "machine/keyboard.h"
+
+#define TERMINAL_SCREEN_TAG "terminal_screen"
+
+/***************************************************************************
+ TYPE DEFINITIONS
+***************************************************************************/
+
+struct terminal_interface
+{
+ devcb_write8 m_keyboard_cb;
+};
+
+#define GENERIC_TERMINAL_INTERFACE(name) const terminal_interface (name) =
+
+/***************************************************************************
+ DEVICE CONFIGURATION MACROS
+***************************************************************************/
+
+#define MCFG_GENERIC_TERMINAL_ADD(_tag, _intrf) \
+ MCFG_DEVICE_ADD(_tag, GENERIC_TERMINAL, 0) \
+ MCFG_DEVICE_CONFIG(_intrf)
+
+#define MCFG_GENERIC_TERMINAL_REMOVE(_tag) \
+ MCFG_DEVICE_REMOVE(_tag)
+
+/***************************************************************************
+ FUNCTION PROTOTYPES
+***************************************************************************/
+
+#define TERMINAL_WIDTH 80
+#define TERMINAL_HEIGHT 24
+
+INPUT_PORTS_EXTERN( generic_terminal );
+
+class generic_terminal_device :
+ public device_t,
+ public terminal_interface
+{
+public:
+ generic_terminal_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);
+ generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ DECLARE_WRITE8_MEMBER(write) { term_write(data); }
+ DECLARE_WRITE8_MEMBER(kbd_put);
+ UINT32 update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect);
+
+ virtual ioport_constructor device_input_ports() const;
+ virtual machine_config_constructor device_mconfig_additions() const;
+protected:
+ required_ioport m_io_term_conf;
+
+ virtual void term_write(UINT8 data);
+ virtual void device_start();
+ virtual void device_reset();
+ virtual void device_config_complete();
+ virtual void send_key(UINT8 code) { m_keyboard_func(0, code); }
+ UINT8 m_buffer[TERMINAL_WIDTH*50]; // make big enough for teleprinter
+ UINT8 m_x_pos;
+private:
+ void scroll_line();
+ void write_char(UINT8 data);
+ void clear();
+
+ UINT8 m_framecnt;
+ UINT8 m_y_pos;
+
+ devcb_resolved_write8 m_keyboard_func;
+};
+
+extern const device_type GENERIC_TERMINAL;
+
+#endif /* __TERMINAL_H__ */