cdp1871: devcb2. (nw)

This commit is contained in:
Curt Coder 2014-02-25 22:04:05 +00:00
parent bafeeb70d9
commit d6a74a31b4
4 changed files with 182 additions and 182 deletions

View File

@ -13,15 +13,12 @@
#include "cdp1871.h"
// device type definition
const device_type CDP1871 = &device_creator<cdp1871_device>;
//**************************************************************************
// MACROS / CONSTANTS
//**************************************************************************
static const UINT8 CDP1871_KEY_CODES[4][11][8] =
const UINT8 cdp1871_device::key_codes[4][11][8] =
{
// normal
{
@ -86,6 +83,14 @@ static const UINT8 CDP1871_KEY_CODES[4][11][8] =
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type CDP1871 = &device_creator<cdp1871_device>;
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
@ -94,45 +99,37 @@ static const UINT8 CDP1871_KEY_CODES[4][11][8] =
// cdp1871_device - constructor
//-------------------------------------------------
cdp1871_device::cdp1871_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, CDP1871, "RCA CDP1871", tag, owner, clock, "cdp1871", __FILE__),
m_inhibit(false),
m_sense(0),
m_drive(0),
m_da(0),
m_next_da(CLEAR_LINE),
m_rpt(0),
m_next_rpt(CLEAR_LINE)
cdp1871_device::cdp1871_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, CDP1871, "RCA CDP1871", tag, owner, clock, "cdp1871", __FILE__),
m_read_d1(*this),
m_read_d2(*this),
m_read_d3(*this),
m_read_d4(*this),
m_read_d5(*this),
m_read_d6(*this),
m_read_d7(*this),
m_read_d8(*this),
m_read_d9(*this),
m_read_d10(*this),
m_read_d11(*this),
m_write_da(*this),
m_write_rpt(*this),
m_inhibit(false),
m_sense(0),
m_drive(0),
m_shift(0),
m_shift_latch(0),
m_control(0),
m_control_latch(0),
m_alpha(0),
m_da(0),
m_next_da(CLEAR_LINE),
m_rpt(0),
m_next_rpt(CLEAR_LINE)
{
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void cdp1871_device::device_config_complete()
{
// inherit a copy of the static data
const cdp1871_interface *intf = reinterpret_cast<const cdp1871_interface *>(static_config());
if (intf != NULL)
*static_cast<cdp1871_interface *>(this) = *intf;
// or initialize to defaults if none provided
else
{
memset(&out_da_cb, 0, sizeof(out_da_cb));
memset(&out_rpt_cb, 0, sizeof(out_rpt_cb));
// m_in_d_cb[]
memset(&in_shift_cb, 0, sizeof(in_shift_cb));
memset(&in_control_cb, 0, sizeof(in_control_cb));
memset(&in_alpha_cb, 0, sizeof(in_alpha_cb));
}
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@ -140,22 +137,19 @@ void cdp1871_device::device_config_complete()
void cdp1871_device::device_start()
{
// resolve callbacks
m_out_da_func.resolve(out_da_cb, *this);
m_out_rpt_func.resolve(out_rpt_cb, *this);
m_in_d_func[0].resolve(in_d1_cb, *this);
m_in_d_func[1].resolve(in_d2_cb, *this);
m_in_d_func[2].resolve(in_d3_cb, *this);
m_in_d_func[3].resolve(in_d4_cb, *this);
m_in_d_func[4].resolve(in_d5_cb, *this);
m_in_d_func[5].resolve(in_d6_cb, *this);
m_in_d_func[6].resolve(in_d7_cb, *this);
m_in_d_func[7].resolve(in_d8_cb, *this);
m_in_d_func[8].resolve(in_d9_cb, *this);
m_in_d_func[9].resolve(in_d10_cb, *this);
m_in_d_func[10].resolve(in_d11_cb, *this);
m_in_shift_func.resolve(in_shift_cb, *this);
m_in_control_func.resolve(in_control_cb, *this);
m_in_alpha_func.resolve(in_alpha_cb, *this);
m_read_d1.resolve_safe(0xff);
m_read_d2.resolve_safe(0xff);
m_read_d3.resolve_safe(0xff);
m_read_d4.resolve_safe(0xff);
m_read_d5.resolve_safe(0xff);
m_read_d6.resolve_safe(0xff);
m_read_d7.resolve_safe(0xff);
m_read_d8.resolve_safe(0xff);
m_read_d9.resolve_safe(0xff);
m_read_d10.resolve_safe(0xff);
m_read_d11.resolve_safe(0xff);
m_write_da.resolve_safe();
m_write_rpt.resolve_safe();
// set initial values
change_output_lines();
@ -169,7 +163,10 @@ void cdp1871_device::device_start()
save_item(NAME(m_sense));
save_item(NAME(m_drive));
save_item(NAME(m_shift));
save_item(NAME(m_shift_latch));
save_item(NAME(m_control));
save_item(NAME(m_control_latch));
save_item(NAME(m_alpha));
save_item(NAME(m_da));
save_item(NAME(m_next_da));
save_item(NAME(m_rpt));
@ -199,14 +196,14 @@ void cdp1871_device::change_output_lines()
{
m_da = m_next_da;
m_out_da_func(m_da);
m_write_da(m_da);
}
if (m_next_rpt != m_rpt)
{
m_rpt = m_next_rpt;
m_out_rpt_func(m_rpt);
m_write_rpt(m_rpt);
}
}
@ -244,14 +241,26 @@ void cdp1871_device::detect_keypress()
{
UINT8 data = 0;
data = m_in_d_func[m_drive](0);
switch (m_drive) {
case 0: data = m_read_d1(0); break;
case 1: data = m_read_d2(0); break;
case 2: data = m_read_d3(0); break;
case 3: data = m_read_d4(0); break;
case 4: data = m_read_d5(0); break;
case 5: data = m_read_d6(0); break;
case 6: data = m_read_d7(0); break;
case 7: data = m_read_d8(0); break;
case 8: data = m_read_d9(0); break;
case 9: data = m_read_d10(0); break;
case 10: data = m_read_d11(0); break;
}
if (data == (1 << m_sense))
{
if (!m_inhibit)
{
m_shift = m_in_shift_func();
m_control = m_in_control_func();
m_shift_latch = m_shift;
m_control_latch = m_control;
m_inhibit = true;
m_next_da = ASSERT_LINE;
}
@ -269,38 +278,17 @@ void cdp1871_device::detect_keypress()
//-------------------------------------------------
// data_r - keyboard data read
// read - keyboard data read
//-------------------------------------------------
READ8_MEMBER( cdp1871_device::data_r )
READ8_MEMBER( cdp1871_device::read )
{
int table = 0;
int alpha = m_in_alpha_func();
if (m_control) table = 3; else if (m_shift) table = 2; else if (alpha) table = 1;
if (m_control_latch) table = 3; else if (m_shift_latch) table = 2; else if (m_alpha) table = 1;
// reset DA on next TPB
m_next_da = CLEAR_LINE;
return CDP1871_KEY_CODES[table][m_drive][m_sense];
}
//-------------------------------------------------
// da_r - data available
//-------------------------------------------------
READ_LINE_MEMBER( cdp1871_device::da_r )
{
return m_da;
}
//-------------------------------------------------
// rpt_r - keyboard repeat
//-------------------------------------------------
READ_LINE_MEMBER( cdp1871_device::rpt_r )
{
return m_rpt;
return key_codes[table][m_drive][m_sense];
}

View File

@ -14,7 +14,7 @@
D3 3 | | 38 CONTROL
D4 4 | | 37 ALPHA
D5 5 | | 36 DEBOUNCE
D6 6 | | 35 _RTP
D6 6 | | 35 _RPT
D7 7 | | 34 TPB
D8 8 | | 33 _DA
D9 9 | | 32 BUS 7
@ -41,23 +41,48 @@
//**************************************************************************
// MACROS / CONSTANTS
//**************************************************************************
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_CDP1871_ADD(_tag, _intrf, _clock) \
MCFG_DEVICE_ADD(_tag, CDP1871, _clock) \
MCFG_DEVICE_CONFIG(_intrf)
#define MCFG_CDP1871_D1_CALLBACK(_read) \
devcb = &cdp1871_device::set_d1_rd_callback(*device, DEVCB2_##_read);
#define CDP1871_INTERFACE(name) \
const cdp1871_interface (name)=
#define MCFG_CDP1871_D2_CALLBACK(_read) \
devcb = &cdp1871_device::set_d2_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_D3_CALLBACK(_read) \
devcb = &cdp1871_device::set_d3_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_D4_CALLBACK(_read) \
devcb = &cdp1871_device::set_d4_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_D5_CALLBACK(_read) \
devcb = &cdp1871_device::set_d5_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_D6_CALLBACK(_read) \
devcb = &cdp1871_device::set_d6_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_D7_CALLBACK(_read) \
devcb = &cdp1871_device::set_d7_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_D8_CALLBACK(_read) \
devcb = &cdp1871_device::set_d8_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_D9_CALLBACK(_read) \
devcb = &cdp1871_device::set_d9_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_D10_CALLBACK(_read) \
devcb = &cdp1871_device::set_d10_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_D11_CALLBACK(_read) \
devcb = &cdp1871_device::set_d11_rd_callback(*device, DEVCB2_##_read);
#define MCFG_CDP1871_DA_CALLBACK(_write) \
devcb = &cdp1871_device::set_da_wr_callback(*device, DEVCB2_##_write);
#define MCFG_CDP1871_RPT_CALLBACK(_write) \
devcb = &cdp1871_device::set_rpt_wr_callback(*device, DEVCB2_##_write);
@ -65,51 +90,39 @@
// TYPE DEFINITIONS
//**************************************************************************
// ======================> cdp1871_interface
struct cdp1871_interface
{
devcb_read8 in_d1_cb;
devcb_read8 in_d2_cb;
devcb_read8 in_d3_cb;
devcb_read8 in_d4_cb;
devcb_read8 in_d5_cb;
devcb_read8 in_d6_cb;
devcb_read8 in_d7_cb;
devcb_read8 in_d8_cb;
devcb_read8 in_d9_cb;
devcb_read8 in_d10_cb;
devcb_read8 in_d11_cb;
devcb_read_line in_shift_cb;
devcb_read_line in_control_cb;
devcb_read_line in_alpha_cb;
// this gets called for every change of the DA pin (pin 33)
devcb_write_line out_da_cb;
// this gets called for every change of the RPT pin (pin 35)
devcb_write_line out_rpt_cb;
};
// ======================> cdp1871_device
class cdp1871_device : public device_t,
public cdp1871_interface
class cdp1871_device : public device_t
{
public:
// construction/destruction
cdp1871_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
DECLARE_READ8_MEMBER( data_r );
template<class _Object> static devcb2_base &set_d1_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d1.set_callback(object); }
template<class _Object> static devcb2_base &set_d2_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d2.set_callback(object); }
template<class _Object> static devcb2_base &set_d3_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d3.set_callback(object); }
template<class _Object> static devcb2_base &set_d4_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d4.set_callback(object); }
template<class _Object> static devcb2_base &set_d5_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d5.set_callback(object); }
template<class _Object> static devcb2_base &set_d6_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d6.set_callback(object); }
template<class _Object> static devcb2_base &set_d7_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d7.set_callback(object); }
template<class _Object> static devcb2_base &set_d8_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d8.set_callback(object); }
template<class _Object> static devcb2_base &set_d9_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d9.set_callback(object); }
template<class _Object> static devcb2_base &set_d10_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d10.set_callback(object); }
template<class _Object> static devcb2_base &set_d11_rd_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_read_d11.set_callback(object); }
template<class _Object> static devcb2_base &set_da_wr_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_write_da.set_callback(object); }
template<class _Object> static devcb2_base &set_rpt_wr_callback(device_t &device, _Object object) { return downcast<cdp1871_device &>(device).m_write_rpt.set_callback(object); }
DECLARE_READ_LINE_MEMBER( da_r );
DECLARE_READ_LINE_MEMBER( rpt_r );
DECLARE_READ8_MEMBER( read );
DECLARE_READ_LINE_MEMBER( da_r ) { return m_da; }
DECLARE_READ_LINE_MEMBER( rpt_r ) { return m_rpt; }
DECLARE_WRITE_LINE_MEMBER( shift_w ) { m_shift = state; }
DECLARE_WRITE_LINE_MEMBER( control_w ) { m_control = state; }
DECLARE_WRITE_LINE_MEMBER( alpha_w ) { m_alpha = state; }
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
@ -118,19 +131,29 @@ protected:
void detect_keypress();
private:
devcb_resolved_write_line m_out_da_func;
devcb_resolved_write_line m_out_rpt_func;
devcb_resolved_read8 m_in_d_func[11];
devcb_resolved_read_line m_in_shift_func;
devcb_resolved_read_line m_in_control_func;
devcb_resolved_read_line m_in_alpha_func;
devcb2_read8 m_read_d1;
devcb2_read8 m_read_d2;
devcb2_read8 m_read_d3;
devcb2_read8 m_read_d4;
devcb2_read8 m_read_d5;
devcb2_read8 m_read_d6;
devcb2_read8 m_read_d7;
devcb2_read8 m_read_d8;
devcb2_read8 m_read_d9;
devcb2_read8 m_read_d10;
devcb2_read8 m_read_d11;
devcb2_write_line m_write_da;
devcb2_write_line m_write_rpt;
bool m_inhibit; // scan counter clock inhibit
int m_sense; // sense input scan counter
int m_drive; // modifier inputs
int m_shift; // latched shift modifier
int m_control; // latched control modifier
int m_shift;
int m_shift_latch; // latched shift modifier
int m_control;
int m_control_latch; // latched control modifier
int m_alpha;
int m_da; // data available flag
int m_next_da; // next value of data available flag
@ -139,6 +162,8 @@ private:
// timers
emu_timer *m_scan_timer; // keyboard scan timer
static const UINT8 key_codes[4][11][8];
};

View File

@ -260,7 +260,7 @@ READ8_MEMBER( comx35_state::io_r )
if (offset == 3)
{
data = m_kbe->data_r(space, 0);
data = m_kbe->read(space, 0);
}
return data;
@ -413,8 +413,8 @@ static INPUT_PORTS_START( comx35 )
PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("MODIFIERS")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CNTL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL))
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) PORT_WRITE_LINE_DEVICE_MEMBER(CDP1871_TAG, cdp1871_device, shift_w)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("CNTL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL)) PORT_WRITE_LINE_DEVICE_MEMBER(CDP1871_TAG, cdp1871_device, control_w)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("RESET")
@ -533,41 +533,6 @@ static COSMAC_INTERFACE( cosmac_intf )
};
//-------------------------------------------------
// CDP1871_INTERFACE( kbc_intf )
//-------------------------------------------------
READ_LINE_MEMBER( comx35_state::shift_r )
{
return BIT(m_modifiers->read(), 0);
}
READ_LINE_MEMBER( comx35_state::control_r )
{
return BIT(m_modifiers->read(), 1);
}
static CDP1871_INTERFACE( kbc_intf )
{
DEVCB_INPUT_PORT("D1"),
DEVCB_INPUT_PORT("D2"),
DEVCB_INPUT_PORT("D3"),
DEVCB_INPUT_PORT("D4"),
DEVCB_INPUT_PORT("D5"),
DEVCB_INPUT_PORT("D6"),
DEVCB_INPUT_PORT("D7"),
DEVCB_INPUT_PORT("D8"),
DEVCB_INPUT_PORT("D9"),
DEVCB_INPUT_PORT("D10"),
DEVCB_INPUT_PORT("D11"),
DEVCB_DRIVER_LINE_MEMBER(comx35_state, shift_r),
DEVCB_DRIVER_LINE_MEMBER(comx35_state, control_r),
DEVCB_NULL,
DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF3),
DEVCB_NULL // polled
};
//-------------------------------------------------
// cassette_interface cassette_intf
//-------------------------------------------------
@ -677,7 +642,19 @@ static MACHINE_CONFIG_START( pal, comx35_state )
MCFG_FRAGMENT_ADD(comx35_pal_video)
// peripheral hardware
MCFG_CDP1871_ADD(CDP1871_TAG, kbc_intf, CDP1869_CPU_CLK_PAL / 8)
MCFG_DEVICE_ADD(CDP1871_TAG, CDP1871, CDP1869_CPU_CLK_PAL/8)
MCFG_CDP1871_D1_CALLBACK(IOPORT("D1"))
MCFG_CDP1871_D2_CALLBACK(IOPORT("D2"))
MCFG_CDP1871_D3_CALLBACK(IOPORT("D3"))
MCFG_CDP1871_D4_CALLBACK(IOPORT("D4"))
MCFG_CDP1871_D5_CALLBACK(IOPORT("D5"))
MCFG_CDP1871_D6_CALLBACK(IOPORT("D6"))
MCFG_CDP1871_D7_CALLBACK(IOPORT("D7"))
MCFG_CDP1871_D8_CALLBACK(IOPORT("D8"))
MCFG_CDP1871_D9_CALLBACK(IOPORT("D9"))
MCFG_CDP1871_D10_CALLBACK(IOPORT("D10"))
MCFG_CDP1871_D11_CALLBACK(IOPORT("D11"))
MCFG_CDP1871_DA_CALLBACK(INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF3))
MCFG_QUICKLOAD_ADD("quickload", comx35_state, comx35_comx, "comx", 0)
MCFG_CASSETTE_ADD("cassette", cassette_intf)
@ -708,7 +685,19 @@ static MACHINE_CONFIG_START( ntsc, comx35_state )
MCFG_FRAGMENT_ADD(comx35_ntsc_video)
// peripheral hardware
MCFG_CDP1871_ADD(CDP1871_TAG, kbc_intf, CDP1869_CPU_CLK_NTSC / 8)
MCFG_DEVICE_ADD(CDP1871_TAG, CDP1871, CDP1869_CPU_CLK_PAL/8)
MCFG_CDP1871_D1_CALLBACK(IOPORT("D1"))
MCFG_CDP1871_D2_CALLBACK(IOPORT("D2"))
MCFG_CDP1871_D3_CALLBACK(IOPORT("D3"))
MCFG_CDP1871_D4_CALLBACK(IOPORT("D4"))
MCFG_CDP1871_D5_CALLBACK(IOPORT("D5"))
MCFG_CDP1871_D6_CALLBACK(IOPORT("D6"))
MCFG_CDP1871_D7_CALLBACK(IOPORT("D7"))
MCFG_CDP1871_D8_CALLBACK(IOPORT("D8"))
MCFG_CDP1871_D9_CALLBACK(IOPORT("D9"))
MCFG_CDP1871_D10_CALLBACK(IOPORT("D10"))
MCFG_CDP1871_D11_CALLBACK(IOPORT("D11"))
MCFG_CDP1871_DA_CALLBACK(INPUTLINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF3))
MCFG_QUICKLOAD_ADD("quickload", comx35_state, comx35_comx, "comx", 0)
MCFG_CASSETTE_ADD("cassette", cassette_intf)

View File

@ -78,8 +78,6 @@ public:
DECLARE_READ_LINE_MEMBER( ef2_r );
DECLARE_READ_LINE_MEMBER( ef4_r );
DECLARE_WRITE_LINE_MEMBER( q_w );
DECLARE_READ_LINE_MEMBER( shift_r );
DECLARE_READ_LINE_MEMBER( control_r );
DECLARE_WRITE_LINE_MEMBER( int_w );
DECLARE_WRITE_LINE_MEMBER( prd_w );
DECLARE_INPUT_CHANGED_MEMBER( trigger_reset );