Changed serial terminal to use separate data bits/parity and stop bit settings to allow more diversity.

This commit is contained in:
smf- 2014-01-08 20:46:12 +00:00
parent 24f13a9d4c
commit 1ec3795d20
14 changed files with 105 additions and 70 deletions

View File

@ -106,8 +106,10 @@ static ins8250_interface ace3_intf =
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x0d ) // 110
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x20 ) // 8N2
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x0d ) // 110
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x03 ) // 8
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x00 ) // N
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x02 ) // 2
DEVICE_INPUT_DEFAULTS_END

View File

@ -1069,8 +1069,10 @@ WRITE_LINE_MEMBER( bulletf_state::req_w )
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x00 ) // 8N1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x03 ) // 8
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x00 ) // N
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END

View File

@ -176,8 +176,10 @@ WRITE_LINE_MEMBER( exp85_state::sod_w )
/* Terminal Interface */
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x10 ) // 7E1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x02 ) // 7
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x02 ) // E
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END
static const serial_terminal_interface terminal_intf =

View File

@ -130,8 +130,10 @@ static const i8251_interface usart_r_intf =
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x00 ) // 8N1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x03 ) // 8
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x00 ) // N
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END

View File

@ -124,13 +124,17 @@ static INPUT_PORTS_START( isbc )
INPUT_PORTS_END
static DEVICE_INPUT_DEFAULTS_START( isbc86_terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x01 ) // 300
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x20 ) // 8N2
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x01 ) // 300
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x03 ) // 8
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x00 ) // N
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x02 ) // 2
DEVICE_INPUT_DEFAULTS_END
static DEVICE_INPUT_DEFAULTS_START( isbc286_terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x10 ) // 7E1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x02 ) // 7
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x02 ) // E
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END
static const serial_terminal_interface terminal_intf =

View File

@ -91,8 +91,10 @@ static INPUT_PORTS_START( pipbug )
INPUT_PORTS_END
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x0d ) // 110
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x10 ) // 7E1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x0d ) // 110
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x02 ) // 7
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x02 ) // E
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END
static const serial_terminal_interface terminal_intf =

View File

@ -494,8 +494,10 @@ static const centronics_interface centronics_intf =
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x08 ) // 19200
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x10 ) // 7E1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x08 ) // 19200
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x02 ) // 7
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x02 ) // E
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END

View File

@ -159,8 +159,10 @@ static I8279_INTERFACE( sdk86_intf )
};
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x05 ) // 4800
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x20 ) // 8N2
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x05 ) // 4800
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x03 ) // 8
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x00 ) // N
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x02 ) // 2
DEVICE_INPUT_DEFAULTS_END
static MACHINE_CONFIG_START( sdk86, sdk86_state )

View File

@ -335,8 +335,10 @@ static I8255A_INTERFACE( ppi1_intf )
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x10 ) // 7E1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x02 ) // 7
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x02 ) // E
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END

View File

@ -497,8 +497,10 @@ static const z80_daisy_config super6_daisy_chain[] =
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x08 ) // 19200
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x00 ) // 8N1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x08 ) // 19200
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x03 ) // 8
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x00 ) // N
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END

View File

@ -341,8 +341,10 @@ static Z80PIO_INTERFACE( pio_intf )
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x00 ) // 8N1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x03 ) // 8
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x00 ) // N
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END

View File

@ -496,8 +496,10 @@ void xor100_state::fdc_drq_w(bool state)
static DEVICE_INPUT_DEFAULTS_START( terminal )
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x0f, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_FRAME", 0x30, 0x00 ) // 8N1
DEVICE_INPUT_DEFAULTS( "TERM_BAUD", 0xff, 0x06 ) // 9600
DEVICE_INPUT_DEFAULTS( "TERM_DATABITS", 0xff, 0x03 ) // 8
DEVICE_INPUT_DEFAULTS( "TERM_PARITY", 0xff, 0x00 ) // N
DEVICE_INPUT_DEFAULTS( "TERM_STOPBITS", 0xff, 0x00 ) // 1
DEVICE_INPUT_DEFAULTS_END

View File

@ -138,14 +138,12 @@ static const UINT8 terminal_font[256*16] =
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_frame(*this, "TERM_FRAME"),
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_frame(*this, "TERM_FRAME"),
m_io_term_conf(*this, "TERM_CONF")
{
}
@ -328,7 +326,6 @@ machine_config_constructor generic_terminal_device::device_mconfig_additions() c
void generic_terminal_device::device_start()
{
m_keyboard_func.resolve(m_keyboard_cb, *this);
m_timer = timer_alloc();
}
void generic_terminal_device::device_config_complete()
@ -416,8 +413,8 @@ const device_type GENERIC_TERMINAL = &device_creator<generic_terminal_device>;
static INPUT_PORTS_START(serial_terminal)
PORT_INCLUDE(generic_terminal)
PORT_START("TERM_FRAME")
PORT_CONFNAME(0x0f, 0x06, "Baud") PORT_CHANGED_MEMBER(DEVICE_SELF, serial_terminal_device, update_frame, 0)
PORT_START("TERM_BAUD")
PORT_CONFNAME(0xff, 0x06, "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")
@ -432,11 +429,28 @@ static INPUT_PORTS_START(serial_terminal)
PORT_CONFSETTING( 0x0a, "38400")
PORT_CONFSETTING( 0x0b, "57600")
PORT_CONFSETTING( 0x0c, "115200")
PORT_CONFNAME(0x30, 0x00, "Format") PORT_CHANGED_MEMBER(DEVICE_SELF, serial_terminal_device, update_frame, 0)
PORT_CONFSETTING( 0x00, "8N1")
PORT_CONFSETTING( 0x10, "7E1")
PORT_CONFSETTING( 0x20, "8N2")
PORT_CONFSETTING( 0x30, "8E1")
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, 0x00, "Stop Bits") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, serial_terminal_device, update_serial)
PORT_CONFSETTING( 0x00, "1")
// PORT_CONFSETTING( 0x01, "1.5")
PORT_CONFSETTING( 0x02, "2")
INPUT_PORTS_END
ioport_constructor serial_terminal_device::device_input_ports() const
@ -447,7 +461,11 @@ ioport_constructor serial_terminal_device::device_input_ports() const
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_serial_port_interface(mconfig, *this)
device_serial_port_interface(mconfig, *this),
m_io_term_baud(*this, "TERM_BAUD"),
m_io_term_databits(*this, "TERM_DATABITS"),
m_io_term_parity(*this, "TERM_PARITY"),
m_io_term_stopbits(*this, "TERM_STOPBITS")
{
}
@ -464,55 +482,41 @@ void serial_terminal_device::device_config_complete()
}
}
static int rates[] = {150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 110};
void serial_terminal_device::device_start()
{
int baud = clock();
if(!baud) baud = 9600;
m_owner = dynamic_cast<serial_port_device *>(owner());
m_out_tx_func.resolve(m_out_tx_cb, *this);
m_slot = m_owner && 1;
m_timer = timer_alloc();
set_rcv_rate(baud);
set_tra_rate(baud);
set_data_frame(8, 1, PARITY_NONE, false);
}
INPUT_CHANGED_MEMBER(serial_terminal_device::update_frame)
static int m_baud[] = {150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 110};
static int m_databits[] = {5, 6, 7, 8, 9};
static int m_parity[] = { device_serial_interface::PARITY_NONE, device_serial_interface::PARITY_ODD, device_serial_interface::PARITY_EVEN, device_serial_interface::PARITY_MARK, device_serial_interface::PARITY_SPACE };
static int m_stopbits[] = {1, 2, 2}; // diserial doesn't support 1.5 bits
WRITE_LINE_MEMBER(serial_terminal_device::update_serial)
{
device_reset();
UINT8 baud = m_io_term_baud->read();
UINT8 databits = m_io_term_databits->read();
UINT8 parity = m_io_term_parity->read();
UINT8 stopbits = m_io_term_stopbits->read();
set_tra_rate(m_baud[baud]);
set_rcv_rate(m_baud[baud]);
set_data_frame(m_databits[databits], m_parity[parity], m_stopbits[stopbits], false);
}
void serial_terminal_device::device_reset()
{
generic_terminal_device::device_reset();
m_rbit = 1;
if(m_slot)
m_owner->out_rx(m_rbit);
else
m_out_tx_func(m_rbit);
UINT8 val = m_io_term_frame->read();
set_tra_rate(rates[val & 0x0f]);
set_rcv_rate(rates[val & 0x0f]);
switch(val & 0x30)
{
case 0x10:
set_data_frame(7, 1, PARITY_EVEN, false);
break;
case 0x00:
default:
set_data_frame(8, 1, PARITY_NONE, false);
break;
case 0x20:
set_data_frame(8, 2, PARITY_NONE, false);
break;
case 0x30:
set_data_frame(8, 1, PARITY_EVEN, false);
break;
}
update_serial(0);
}
void serial_terminal_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)

View File

@ -60,7 +60,6 @@ public:
virtual ioport_constructor device_input_ports() const;
virtual machine_config_constructor device_mconfig_additions() const;
protected:
optional_ioport m_io_term_frame;
required_ioport m_io_term_conf;
virtual void term_write(UINT8 data);
@ -70,7 +69,6 @@ protected:
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;
emu_timer *m_timer;
private:
void scroll_line();
void write_char(UINT8 data);
@ -98,7 +96,8 @@ public:
virtual void tx(UINT8 state) { rx_w(state); }
virtual ioport_constructor device_input_ports() const;
DECLARE_INPUT_CHANGED_MEMBER(update_frame);
DECLARE_WRITE_LINE_MEMBER(update_serial);
protected:
virtual void device_start();
virtual void device_config_complete();
@ -109,7 +108,13 @@ protected:
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_baud;
required_ioport m_io_term_databits;
required_ioport m_io_term_parity;
required_ioport m_io_term_stopbits;
serial_port_device *m_owner;
bool m_slot;
UINT8 m_curr_key;