(mess) qx10kbd: update to use z80dart (nw)

This commit is contained in:
cracyc 2013-05-28 21:34:06 +00:00
parent 8ef48d0144
commit 94d818b894
7 changed files with 97 additions and 85 deletions

View File

@ -571,6 +571,12 @@ void z80dart_channel::device_reset()
void z80dart_channel::tra_callback()
{
if (!(m_wr[5] & WR5_TX_ENABLE))
{
if (!(m_out_txd_func.isnull()))
m_out_txd_func(1);
return;
}
if (m_out_txd_func.isnull())
transmit_register_send_bit();
else

View File

@ -6,7 +6,6 @@
Status:
Driver boots and load CP/M from floppy image. Needs upd7220 for gfx
and keyboard hooked to upd7021.
Done:
- preliminary memory map
@ -34,7 +33,7 @@
#include "cpu/z80/z80.h"
#include "machine/pit8253.h"
#include "machine/pic8259.h"
#include "machine/z80sio.h"
#include "machine/z80dart.h"
#include "machine/mc146818.h"
#include "machine/i8255.h"
#include "machine/am9517a.h"
@ -77,7 +76,7 @@ public:
required_device<pit8253_device> m_pit_2;
required_device<pic8259_device> m_pic_m;
required_device<pic8259_device> m_pic_s;
required_device<z80sio_device> m_scc;
required_device<upd7201_device> m_scc;
required_device<i8255_device> m_ppi;
required_device<am9517a_device> m_dma_1;
required_device<am9517a_device> m_dma_2;
@ -119,7 +118,8 @@ public:
DECLARE_WRITE8_MEMBER( vram_w );
DECLARE_READ8_MEMBER(memory_read_byte);
DECLARE_WRITE8_MEMBER(memory_write_byte);
DECLARE_WRITE8_MEMBER(keyboard_w);
DECLARE_WRITE_LINE_MEMBER(keyboard_clk);
DECLARE_WRITE_LINE_MEMBER(keyboard_irq);
UINT8 *m_char_rom;
@ -466,61 +466,44 @@ READ8_MEMBER(qx10_state::mc146818_r)
Channel B: RS232
*/
#if 0
static UPD7201_INTERFACE(qx10_upd7201_interface)
{
DEVCB_NULL, /* interrupt */
{
{
0, /* receive clock */
0, /* transmit clock */
DEVCB_NULL, /* receive DRQ */
DEVCB_NULL, /* transmit DRQ */
DEVCB_DEVICE_LINE_MEMBER("kbd", serial_keyboard_device, tx_r),
DEVCB_DEVICE_LINE_MEMBER("kbd", serial_keyboard_device, rx_w),
DEVCB_NULL, /* clear to send */
DEVCB_NULL, /* data carrier detect */
DEVCB_NULL, /* ready to send */
DEVCB_NULL, /* data terminal ready */
DEVCB_NULL, /* wait */
DEVCB_NULL /* sync output */
}, {
0, /* receive clock */
0, /* transmit clock */
DEVCB_NULL, /* receive DRQ */
DEVCB_NULL, /* transmit DRQ */
DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, rx),
DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, tx),
DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, cts_r),
DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, dcd_r),
DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, rts_w),
DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, rs232_port_device, dtr_w),
DEVCB_NULL, /* wait */
DEVCB_NULL /* sync output */
}
}
};
#endif
0, 0, 0, 0, // channel b clock set by pit2 channel 2
static struct z80sio_interface qx10_upd7201_interface =
DEVCB_DEVICE_LINE_MEMBER("kbd", serial_keyboard_device, tx_r),
DEVCB_DEVICE_LINE_MEMBER("kbd", serial_keyboard_device, rx_w),
DEVCB_NULL,
DEVCB_NULL,
DEVCB_NULL,
DEVCB_NULL,
DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, rx),
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_NULL,
DEVCB_NULL,
DEVCB_DRIVER_LINE_MEMBER(qx10_state, keyboard_irq)
};
static struct serial_keyboard_interface qx10_keyboard_interface =
{
DEVCB_DEVICE_LINE_MEMBER("pic8259_master", pic8259_device, ir4_w),
DEVCB_NULL,
DEVCB_NULL,
DEVCB_NULL,
DEVCB_DEVICE_MEMBER16("kbd", qx10_keyboard_device, tx_w),
DEVCB_NULL
};
WRITE8_MEMBER(qx10_state::keyboard_w)
WRITE_LINE_MEMBER(qx10_state::keyboard_irq)
{
m_scc->receive_data(0, data);
m_scc->m1_r(); // always set
m_pic_m->ir4_w(state);
}
static struct keyboard_interface qx10_keyboard_interface =
WRITE_LINE_MEMBER(qx10_state::keyboard_clk)
{
DEVCB_DRIVER_MEMBER(qx10_state, keyboard_w)
};
// clock keyboard too
m_scc->rxca_w(state);
m_scc->txca_w(state);
}
/*
Timer 0
@ -550,8 +533,8 @@ static const struct pit8253_config qx10_pit8253_2_config =
{
{
{ MAIN_CLK / 8, DEVCB_LINE_VCC, DEVCB_NULL },
{ MAIN_CLK / 8, DEVCB_LINE_VCC, DEVCB_NULL },
{ MAIN_CLK / 8, DEVCB_LINE_VCC, DEVCB_NULL },
{ MAIN_CLK / 8, DEVCB_LINE_VCC, DEVCB_DRIVER_LINE_MEMBER(qx10_state, keyboard_clk) },
{ MAIN_CLK / 8, DEVCB_LINE_VCC, DEVCB_DEVICE_LINE_MEMBER("upd7201", z80dart_device, rxtxcb_w) },
}
};
@ -691,7 +674,7 @@ static ADDRESS_MAP_START( qx10_io , AS_IO, 8, qx10_state)
AM_RANGE(0x04, 0x07) AM_DEVREADWRITE_LEGACY("pit8253_2", pit8253_r, pit8253_w)
AM_RANGE(0x08, 0x09) AM_DEVREADWRITE("pic8259_master", pic8259_device, read, write)
AM_RANGE(0x0c, 0x0d) AM_DEVREADWRITE("pic8259_slave", pic8259_device, read, write)
AM_RANGE(0x10, 0x13) AM_DEVREADWRITE("upd7201", z80sio_device, read, write)
AM_RANGE(0x10, 0x13) AM_DEVREADWRITE("upd7201", z80dart_device, cd_ba_r, cd_ba_w)
AM_RANGE(0x14, 0x17) AM_DEVREADWRITE("i8255", i8255_device, read, write)
AM_RANGE(0x18, 0x1b) AM_READ_PORT("DSW") AM_WRITE(qx10_18_w)
AM_RANGE(0x1c, 0x1f) AM_WRITE(prom_sel_w)
@ -900,7 +883,7 @@ static MACHINE_CONFIG_START( qx10, qx10_state )
MCFG_PIT8253_ADD("pit8253_2", qx10_pit8253_2_config)
MCFG_PIC8259_ADD("pic8259_master", INPUTLINE("maincpu", 0), VCC, READ8(qx10_state, get_slave_ack))
MCFG_PIC8259_ADD("pic8259_slave", DEVWRITELINE("pic8259_master", pic8259_device, ir7_w), GND, NULL)
MCFG_Z80SIO_ADD("upd7201", MAIN_CLK/4, qx10_upd7201_interface)
MCFG_UPD7201_ADD("upd7201", MAIN_CLK/4, qx10_upd7201_interface)
MCFG_I8255_ADD("i8255", qx10_i8255_interface)
MCFG_I8237_ADD("8237dma_1", MAIN_CLK/4, qx10_dma8237_1_interface)
MCFG_I8237_ADD("8237dma_2", MAIN_CLK/4, qx10_dma8237_2_interface)

View File

@ -388,7 +388,7 @@ static INPUT_PORTS_START(serial_keyboard)
PORT_CONFSETTING( 0x00, "8N1")
PORT_CONFSETTING( 0x10, "7E1")
PORT_CONFSETTING( 0x20, "8N2")
PORT_CONFSETTING( 0x30, "8O1")
PORT_CONFSETTING( 0x30, "8E1")
INPUT_PORTS_END
ioport_constructor serial_keyboard_device::device_input_ports() const
@ -399,7 +399,16 @@ ioport_constructor serial_keyboard_device::device_input_ports() const
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_serial_port_interface(mconfig, *this)
device_serial_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_serial_port_interface(mconfig, *this),
m_io_term_frame(*this, "TERM_FRAME")
{
}
@ -416,7 +425,7 @@ void serial_keyboard_device::device_config_complete()
}
}
static int rates[] = {150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200};
static int rates[] = {150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 110};
void serial_keyboard_device::device_start()
{
@ -432,9 +441,22 @@ void serial_keyboard_device::device_start()
INPUT_CHANGED_MEMBER(serial_keyboard_device::update_frame)
{
set_tra_rate(rates[newval & 0x0f]);
reset();
}
switch(newval & 0x30)
void serial_keyboard_device::device_reset()
{
generic_keyboard_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]);
switch(val & 0x30)
{
case 0x10:
set_data_frame(7, 1, SERIAL_PARITY_EVEN);
@ -447,21 +469,11 @@ INPUT_CHANGED_MEMBER(serial_keyboard_device::update_frame)
set_data_frame(8, 2, SERIAL_PARITY_NONE);
break;
case 0x30:
set_data_frame(8, 1, SERIAL_PARITY_ODD);
set_data_frame(8, 1, SERIAL_PARITY_EVEN);
break;
}
}
void serial_keyboard_device::device_reset()
{
generic_keyboard_device::device_reset();
m_rbit = 1;
if(m_slot)
m_owner->out_rx(m_rbit);
else
m_out_tx_func(m_rbit);
}
void serial_keyboard_device::send_key(UINT8 code)
{
if(is_transmit_register_empty())

View File

@ -57,6 +57,7 @@ protected:
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);
@ -82,6 +83,7 @@ class serial_keyboard_device :
{
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);
DECLARE_WRITE_LINE_MEMBER(rx_w) { m_tbit = state; check_for_start(state); }
DECLARE_READ_LINE_MEMBER(tx_r);
@ -102,6 +104,7 @@ private:
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;

View File

@ -1,9 +1,9 @@
// TODO: when z80sio becomes a serial device, inherit from serial_keyboard_device; dump 8049 mcu; key repeat
// TODO: dump 8049 mcu; key repeat
#include "machine/qx10kbd.h"
qx10_keyboard_device::qx10_keyboard_device(const machine_config& mconfig, const char* tag, device_t* owner, UINT32 clock) :
generic_keyboard_device(mconfig, QX10_KEYBOARD, "QX10 Keyboard", tag, owner, 0, "qx10_keyboard", __FILE__),
serial_keyboard_device(mconfig, QX10_KEYBOARD, "QX10 Keyboard", tag, owner, 0, "qx10_keyboard", __FILE__),
m_io_kbd8(*this, "TERM_LINE8"),
m_io_kbd9(*this, "TERM_LINE9"),
m_io_kbda(*this, "TERM_LINEA"),
@ -14,10 +14,8 @@ qx10_keyboard_device::qx10_keyboard_device(const machine_config& mconfig, const
{
}
WRITE16_MEMBER(qx10_keyboard_device::tx_w)
void qx10_keyboard_device::write(UINT8 data)
{
if(offset)
return;
switch(data & 0xe0)
{
default:
@ -259,22 +257,29 @@ static INPUT_PORTS_START( qx10_keyboard )
PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("CLS/LINE")
PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_UNUSED)
/* PORT_START("TERM_FRAME")
PORT_START("TERM_FRAME")
PORT_CONFNAME(0x0f, 0x03, "Baud") PORT_CHANGED_MEMBER(DEVICE_SELF, serial_keyboard_device, update_frame, 0)
PORT_CONFSETTING( 0x03, "1200")
PORT_CONFNAME(0x30, 0x30, "Format") PORT_CHANGED_MEMBER(DEVICE_SELF, serial_keyboard_device, update_frame, 0)
PORT_CONFSETTING( 0x30, "8O1")*/
PORT_CONFSETTING( 0x30, "8E1")
INPUT_PORTS_END
void qx10_keyboard_device::device_start()
{
generic_keyboard_device::device_start();
memset(m_state, '\0', sizeof(m_state));
}
ioport_constructor qx10_keyboard_device::device_input_ports() const
{
return INPUT_PORTS_NAME(qx10_keyboard);
}
void qx10_keyboard_device::device_start()
{
serial_keyboard_device::device_start();
memset(m_state, '\0', sizeof(m_state));
set_rcv_rate(1200);
}
void qx10_keyboard_device::rcv_complete()
{
receive_register_extract();
write(get_received_char());
}
const device_type QX10_KEYBOARD = &device_creator<qx10_keyboard_device>;

View File

@ -8,19 +8,19 @@
MCFG_DEVICE_ADD(_tag, QX10_KEYBOARD, 1200) \
MCFG_DEVICE_CONFIG(_intrf)
class qx10_keyboard_device : public generic_keyboard_device
class qx10_keyboard_device : public serial_keyboard_device
{
public:
qx10_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual ioport_constructor device_input_ports() const;
DECLARE_WRITE16_MEMBER(tx_w);
protected:
virtual void device_start();
virtual void rcv_complete();
private:
virtual UINT8 keyboard_handler(UINT8 last_code, UINT8 *scan_line);
void write(UINT8 data);
required_ioport m_io_kbd8;
required_ioport m_io_kbd9;

View File

@ -441,7 +441,7 @@ static INPUT_PORTS_START(serial_terminal)
PORT_CONFSETTING( 0x00, "8N1")
PORT_CONFSETTING( 0x10, "7E1")
PORT_CONFSETTING( 0x20, "8N2")
PORT_CONFSETTING( 0x30, "8O1")
PORT_CONFSETTING( 0x30, "8E1")
INPUT_PORTS_END
ioport_constructor serial_terminal_device::device_input_ports() const
@ -514,6 +514,9 @@ void serial_terminal_device::device_reset()
case 0x20:
set_data_frame(8, 2, SERIAL_PARITY_NONE);
break;
case 0x30:
set_data_frame(8, 1, SERIAL_PARITY_EVEN);
break;
}
}