mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
(MESS) kc: devcb2. (nw)
This commit is contained in:
parent
80028e446b
commit
3d9eab4737
@ -113,11 +113,6 @@ Z80CTC_INTERFACE( kc85_ctc_intf )
|
||||
DEVCB_DRIVER_LINE_MEMBER(kc_state, video_toggle_blink_state)
|
||||
};
|
||||
|
||||
const kc_keyb_interface kc85_keyboard_interface =
|
||||
{
|
||||
DEVCB_DRIVER_LINE_MEMBER(kc_state, keyboard_cb)
|
||||
};
|
||||
|
||||
static const cassette_interface kc_cassette_interface =
|
||||
{
|
||||
kc_cassette_formats,
|
||||
@ -148,7 +143,8 @@ static MACHINE_CONFIG_START( kc85_3, kc_state )
|
||||
MCFG_PALETTE_ADD("palette", KC85_PALETTE_SIZE)
|
||||
MCFG_PALETTE_INIT_OWNER(kc_state, kc85 )
|
||||
|
||||
MCFG_KC_KEYBOARD_ADD("keyboard", XTAL_4MHz, kc85_keyboard_interface)
|
||||
MCFG_DEVICE_ADD("keyboard", KC_KEYBOARD, XTAL_4MHz)
|
||||
MCFG_KC_KEYBOARD_OUT_CALLBACK(WRITELINE(kc_state, keyboard_cb))
|
||||
|
||||
/* sound hardware */
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
@ -201,7 +197,8 @@ static MACHINE_CONFIG_START( kc85_4, kc85_4_state )
|
||||
MCFG_PALETTE_ADD("palette", KC85_PALETTE_SIZE)
|
||||
MCFG_PALETTE_INIT_OWNER(kc85_4_state, kc85 )
|
||||
|
||||
MCFG_KC_KEYBOARD_ADD("keyboard", XTAL_4MHz, kc85_keyboard_interface)
|
||||
MCFG_DEVICE_ADD("keyboard", KC_KEYBOARD, XTAL_4MHz)
|
||||
MCFG_KC_KEYBOARD_OUT_CALLBACK(WRITELINE(kc_state, keyboard_cb))
|
||||
|
||||
/* sound hardware */
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
|
@ -436,7 +436,8 @@ INPUT_PORTS_END
|
||||
// kc_keyboard_device - constructor
|
||||
//-------------------------------------------------
|
||||
kc_keyboard_device::kc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
device_t(mconfig, KC_KEYBOARD, "KC Keyboard", tag, owner, clock, "kc_keyboard", __FILE__)
|
||||
device_t(mconfig, KC_KEYBOARD, "KC Keyboard", tag, owner, clock, "kc_keyboard", __FILE__),
|
||||
m_write_out(*this)
|
||||
{
|
||||
}
|
||||
|
||||
@ -455,7 +456,7 @@ kc_keyboard_device::~kc_keyboard_device()
|
||||
void kc_keyboard_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
m_keyboard_out_func.resolve(m_keyboard_out_cb, *this);
|
||||
m_write_out.resolve_safe();
|
||||
|
||||
m_timer_transmit_pulse = timer_alloc(TIMER_TRANSMIT_PULSE);
|
||||
|
||||
@ -469,7 +470,7 @@ void kc_keyboard_device::device_start()
|
||||
void kc_keyboard_device::device_reset()
|
||||
{
|
||||
// set initial state
|
||||
m_keyboard_out_func(CLEAR_LINE);
|
||||
m_write_out(CLEAR_LINE);
|
||||
|
||||
m_transmit_buffer.pulse_sent = 0;
|
||||
m_transmit_buffer.pulse_count = 0;
|
||||
@ -477,28 +478,6 @@ void kc_keyboard_device::device_reset()
|
||||
memset(&m_transmit_buffer, 0, sizeof(m_transmit_buffer));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void kc_keyboard_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const kc_keyb_interface *intf = reinterpret_cast<const kc_keyb_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
{
|
||||
*static_cast<kc_keyb_interface *>(this) = *intf;
|
||||
}
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_keyboard_out_func, 0, sizeof(m_keyboard_out_func));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// input_ports - device-specific input ports
|
||||
//-------------------------------------------------
|
||||
@ -530,7 +509,7 @@ void kc_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int
|
||||
LOG(("KC keyboard sending pulse: %02x\n", pulse_state));
|
||||
|
||||
// send pulse
|
||||
m_keyboard_out_func(pulse_state ? ASSERT_LINE : CLEAR_LINE);
|
||||
m_write_out(pulse_state ? ASSERT_LINE : CLEAR_LINE);
|
||||
|
||||
// update counts
|
||||
m_transmit_buffer.pulse_sent++;
|
||||
|
@ -9,6 +9,9 @@
|
||||
#ifndef __KC_KEYB_H__
|
||||
#define __KC_KEYB_H__
|
||||
|
||||
#define MCFG_KC_KEYBOARD_OUT_CALLBACK(_write) \
|
||||
devcb = &kc_keyboard_device::set_out_wr_callback(*device, DEVCB2_##_write);
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
@ -16,23 +19,17 @@
|
||||
/* number of pulses that can be stored */
|
||||
#define KC_TRANSMIT_BUFFER_LENGTH 256
|
||||
|
||||
// ======================> kc_keyb_interface
|
||||
|
||||
struct kc_keyb_interface
|
||||
{
|
||||
devcb_write_line m_keyboard_out_cb;
|
||||
};
|
||||
|
||||
// ======================> kc_keyboard_device
|
||||
|
||||
class kc_keyboard_device : public device_t,
|
||||
public kc_keyb_interface
|
||||
class kc_keyboard_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
kc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~kc_keyboard_device();
|
||||
|
||||
template<class _Object> static devcb2_base &set_out_wr_callback(device_t &device, _Object object) { return downcast<kc_keyboard_device &>(device).m_write_out.set_callback(object); }
|
||||
|
||||
// optional information overrides
|
||||
virtual ioport_constructor device_input_ports() const;
|
||||
|
||||
@ -40,7 +37,6 @@ protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
virtual void device_config_complete();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
void add_pulse_to_transmit_buffer(int pulse_state, int pulse_number = 1);
|
||||
@ -52,7 +48,7 @@ private:
|
||||
|
||||
// internal state
|
||||
emu_timer * m_timer_transmit_pulse;
|
||||
devcb_resolved_write_line m_keyboard_out_func;
|
||||
devcb2_write_line m_write_out;
|
||||
|
||||
// pulses to transmit
|
||||
struct
|
||||
@ -66,12 +62,4 @@ private:
|
||||
// device type definition
|
||||
extern const device_type KC_KEYBOARD;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
DEVICE CONFIGURATION MACROS
|
||||
***************************************************************************/
|
||||
|
||||
#define MCFG_KC_KEYBOARD_ADD(_tag,_clock,_config) \
|
||||
MCFG_DEVICE_ADD(_tag, KC_KEYBOARD, _clock) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
#endif /* __KC_KEYB_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user