diff options
Diffstat (limited to 'src/devices/machine/pckeybrd.cpp')
-rw-r--r-- | src/devices/machine/pckeybrd.cpp | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/src/devices/machine/pckeybrd.cpp b/src/devices/machine/pckeybrd.cpp index 29559c3cde9..3e59b741798 100644 --- a/src/devices/machine/pckeybrd.cpp +++ b/src/devices/machine/pckeybrd.cpp @@ -24,8 +24,10 @@ /* AT keyboard documentation comes from www.beyondlogic.org and HelpPC documentation */ -/* to enable logging of keyboard read/writes */ -#define LOG_KEYBOARD 0 +/* for logging of keyboard read/writes */ +#define LOG_KEYBOARD (1U << 1) +#define VERBOSE (0) +#include "logmacro.h" /* @@ -286,7 +288,7 @@ pc_keyboard_device::pc_keyboard_device(const machine_config &mconfig, const char pc_keyboard_device::pc_keyboard_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock), - m_ioport(*this, ":pc_keyboard_%u", 0), + m_ioport(*this, "pc_keyboard_%u", 0), m_out_keypress_func(*this) { } @@ -300,7 +302,7 @@ at_keyboard_device::at_keyboard_device(const machine_config &mconfig, const char } -void pc_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(pc_keyboard_device::poll_keys) { polling(); if(!charqueue_empty()) @@ -315,26 +317,27 @@ void pc_keyboard_device::device_start() save_item(NAME(m_on)); save_item(NAME(m_head)); save_item(NAME(m_tail)); - save_pointer(NAME(m_queue), ARRAY_LENGTH(m_queue)); - save_pointer(NAME(m_make), ARRAY_LENGTH(m_make)); + save_item(NAME(m_queue)); + save_item(NAME(m_make)); - memset(m_make, 0, sizeof(m_make)); + std::fill(std::begin(m_make), std::end(m_make), 0); - machine().ioport().natkeyboard().configure( + machine().natkeyboard().configure( ioport_queue_chars_delegate(&pc_keyboard_device::queue_chars, this), ioport_accept_char_delegate(&pc_keyboard_device::accept_char, this), ioport_charqueue_empty_delegate(&pc_keyboard_device::charqueue_empty, this)); - m_out_keypress_func.resolve_safe(); - m_keyboard_timer = timer_alloc(); + m_keyboard_timer = timer_alloc(FUNC(at_keyboard_device::poll_keys), this); } void at_keyboard_device::device_start() { - save_item(NAME(m_scan_code_set)); - save_item(NAME(m_input_state)); pc_keyboard_device::device_start(); + m_leds.resolve(); + + save_item(NAME(m_scan_code_set)); + save_item(NAME(m_input_state)); } void pc_keyboard_device::device_reset() @@ -360,7 +363,7 @@ void at_keyboard_device::device_reset() m_leds[1] = 0; } -WRITE_LINE_MEMBER(pc_keyboard_device::enable) +void pc_keyboard_device::enable(int state) { if(state && !m_on) { @@ -378,12 +381,11 @@ WRITE_LINE_MEMBER(pc_keyboard_device::enable) /* insert a code into the buffer */ void pc_keyboard_device::queue_insert(uint8_t data) { - if (LOG_KEYBOARD) - logerror("keyboard queueing %.2x\n",data); + LOGMASKED(LOG_KEYBOARD, "keyboard queueing %.2x\n", data); m_queue[m_head] = data; m_head++; - m_head %= ARRAY_LENGTH(m_queue); + m_head %= std::size(m_queue); } @@ -392,7 +394,7 @@ int pc_keyboard_device::queue_size(void) int queue_size; queue_size = m_head - m_tail; if (queue_size < 0) - queue_size += ARRAY_LENGTH(m_queue); + queue_size += std::size(m_queue); return queue_size; } @@ -614,7 +616,7 @@ void pc_keyboard_device::polling(void) } } -READ8_MEMBER(pc_keyboard_device::read) +uint8_t pc_keyboard_device::read() { int data; if (m_tail == m_head) @@ -622,11 +624,10 @@ READ8_MEMBER(pc_keyboard_device::read) data = m_queue[m_tail]; - if (LOG_KEYBOARD) - logerror("read(): Keyboard Read 0x%02x\n",data); + LOGMASKED(LOG_KEYBOARD, "read(): Keyboard Read 0x%02x\n", data); m_tail++; - m_tail %= ARRAY_LENGTH(m_queue); + m_tail %= std::size(m_queue); return data; } @@ -688,10 +689,9 @@ Note: each command is acknowledged by FAh (ACK), if not mentioned otherwise. SeeAlso: #P046 */ -WRITE8_MEMBER(at_keyboard_device::write) +void at_keyboard_device::write(uint8_t data) { - if (LOG_KEYBOARD) - logerror("keyboard write %.2x\n",data); + LOGMASKED(LOG_KEYBOARD, "keyboard write %.2x\n", data); switch (m_input_state) { @@ -775,7 +775,7 @@ WRITE8_MEMBER(at_keyboard_device::write) if (data & 0x080) { /* command received instead of code - execute command */ - write(space, offset, data); + write(data); } else { @@ -799,7 +799,7 @@ WRITE8_MEMBER(at_keyboard_device::write) if (data & 0x080) { /* command received instead of code - execute command */ - write(space, offset, data); + write(data); } else { @@ -830,7 +830,7 @@ WRITE8_MEMBER(at_keyboard_device::write) if (data & 0x080) { /* command received instead of code - execute command */ - write(space, offset, data); + write(data); } else { @@ -1117,7 +1117,7 @@ INPUT_PORTS_START( pc_keyboard ) PORT_BIT ( 0xff80, 0x0000, IPT_UNUSED ) INPUT_PORTS_END -INPUT_PORTS_START( at_keyboard ) +static INPUT_PORTS_START( at_keyboard ) PORT_START("pc_keyboard_0") PORT_BIT ( 0x0001, 0x0000, IPT_UNUSED ) /* unused scancode 0 */ PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) /* Esc 01 81 */ @@ -1242,6 +1242,18 @@ INPUT_PORTS_START( at_keyboard ) PORT_BIT ( 0xfffe, 0x0000, IPT_UNUSED ) INPUT_PORTS_END + +ioport_constructor pc_keyboard_device::device_input_ports() const +{ + return INPUT_PORTS_NAME(pc_keyboard); +} + + +ioport_constructor at_keyboard_device::device_input_ports() const +{ + return INPUT_PORTS_NAME(at_keyboard); +} + /*************************************************************************** Inputx stuff ***************************************************************************/ |