diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 84b5ea324c7..02a3afc5b83 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -869,6 +869,10 @@ if (BUSES["HPHIL"]~=null) then MAME_DIR .. "src/devices/bus/hp_hil/hp_hil.h", MAME_DIR .. "src/devices/bus/hp_hil/hil_devices.cpp", MAME_DIR .. "src/devices/bus/hp_hil/hil_devices.h", + MAME_DIR .. "src/devices/bus/hp_hil/hlebase.cpp", + MAME_DIR .. "src/devices/bus/hp_hil/hlebase.h", + MAME_DIR .. "src/devices/bus/hp_hil/hlemouse.cpp", + MAME_DIR .. "src/devices/bus/hp_hil/hlemouse.h", MAME_DIR .. "src/devices/bus/hp_hil/hlekbd.cpp", MAME_DIR .. "src/devices/bus/hp_hil/hlekbd.h", } diff --git a/src/devices/bus/hp_dio/human_interface.cpp b/src/devices/bus/hp_dio/human_interface.cpp index 7804377e46a..d35f8acf518 100644 --- a/src/devices/bus/hp_dio/human_interface.cpp +++ b/src/devices/bus/hp_dio/human_interface.cpp @@ -41,6 +41,11 @@ void human_interface_device::device_add_mconfig(machine_config &config) keyboard.set_default_option("hp_46021a"); keyboard.set_hp_hil_slot(this, "mlc"); + hp_hil_slot_device &mouse(HP_HIL_SLOT(config, "hil2", 0)); + hp_hil_devices(mouse); + mouse.set_default_option("hp_46060b"); + mouse.set_hp_hil_slot(this, "mlc"); + SPEAKER(config, "mono").front_center(); sn76494_device &sound(SN76494(config, "sn76494", 333333)); sound.add_route(ALL_OUTPUTS, "mono", 0.75); diff --git a/src/devices/bus/hp_hil/hil_devices.cpp b/src/devices/bus/hp_hil/hil_devices.cpp index 422ff680c4c..b7b6ae85513 100644 --- a/src/devices/bus/hp_hil/hil_devices.cpp +++ b/src/devices/bus/hp_hil/hil_devices.cpp @@ -10,4 +10,5 @@ void hp_hil_devices(device_slot_interface &device) { device.option_add(STR_KBD_HP_INTEGRAL, HP_IPC_HLE_KEYBOARD); device.option_add(STR_KBD_HP_46021A, HP_ITF_HLE_KEYBOARD); + device.option_add(STR_MOUSE_HP_46060B, HP_46060B_MOUSE); } diff --git a/src/devices/bus/hp_hil/hlebase.cpp b/src/devices/bus/hp_hil/hlebase.cpp new file mode 100644 index 00000000000..5ac421a2497 --- /dev/null +++ b/src/devices/bus/hp_hil/hlebase.cpp @@ -0,0 +1,152 @@ +// license:BSD-3-Cl ause +// copyright-holders:Sergey Svishchev +#include "emu.h" +#include "hlebase.h" +#include "hlekbd.h" + +//#define VERBOSE 1 +#include "logmacro.h" + +namespace bus { + namespace hp_hil { + +/*************************************************************************** + BASE HLE KEYBOARD DEVICE +***************************************************************************/ + +/*-------------------------------------------------- + hle_device_base::hle_device_base + designated device constructor +--------------------------------------------------*/ + +hle_device_base::hle_device_base(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, type, tag, owner, clock) + , device_hp_hil_interface(mconfig, *this) +{ } + + +/*-------------------------------------------------- + hle_device_base::~hle_device_base + destructor +--------------------------------------------------*/ + +hle_device_base::~hle_device_base() +{ } + + +/*-------------------------------------------------- + hle_device_base::device_start + perform expensive initialisations, allocate + resources, register for save state +--------------------------------------------------*/ + +void hle_device_base::device_start() +{ + set_hp_hil_mlc_device(); + + m_powerup = true; + m_passthru = false; +} + + +/*-------------------------------------------------- + hle_device_base::device_reset + perform startup tasks, also used for host + requested reset +--------------------------------------------------*/ + +void hle_device_base::device_reset() +{ +} + +bool hle_device_base::hil_write(uint16_t *pdata) +{ + int frames = 0; + uint8_t addr = (*pdata >> 8) & 7; + uint8_t data = *pdata & 0xff; + bool command = BIT(*pdata, 11); + + LOG("%d: rx from mlc %04X (%s addr %d, data %02X)\n", m_device_id, *pdata, + command ? "command" : "data", addr, data); + + if (!command) + goto out; + + if (addr != 0 && addr != m_device_id) + goto out; + + switch (data) + { + case HPHIL_IFC: + m_powerup = false; + break; + + case HPHIL_EPT: + m_passthru = true; + break; + + case HPHIL_ELB: + m_passthru = false; + break; + + case 0x09: + case 0x0a: + case 0x0b: + case 0x0c: + case 0x0d: + case 0x0e: + case 0x0f: + m_device_id = data - 8; + m_device_id16 = (data - 8) << 8; + *pdata &= ~7; + *pdata += (data - 7); + break; + + case HPHIL_POL: + case HPHIL_POL+1: + case HPHIL_POL+2: + case HPHIL_POL+3: + case HPHIL_POL+4: + case HPHIL_POL+5: + case HPHIL_POL+6: + case HPHIL_POL+7: + case HPHIL_POL+8: + case HPHIL_POL+9: + case HPHIL_POL+10: + case HPHIL_POL+11: + case HPHIL_POL+12: + case HPHIL_POL+13: + case HPHIL_POL+14: + case HPHIL_POL+15: + frames = hil_poll(); + *pdata += frames; + break; + + case HPHIL_DSR: + m_device_id = m_device_id16 = 0; + m_powerup = true; + break; + + case HPHIL_IDD: + hil_idd(); + break; + + case HPHIL_DHR: + m_powerup = true; + m_passthru = false; + device_reset(); + return true; + break; + + default: + LOG("command %02X unknown\n", data); + break; + } +out: + if (!m_passthru) + m_hp_hil_mlc->hil_write(*pdata); + return m_passthru; +} + +} // namespace bus::hp_hil +} // namespace bus diff --git a/src/devices/bus/hp_hil/hlebase.h b/src/devices/bus/hp_hil/hlebase.h new file mode 100644 index 00000000000..58e320507fe --- /dev/null +++ b/src/devices/bus/hp_hil/hlebase.h @@ -0,0 +1,43 @@ +// license:BSD-3-Clause +// copyright-holders:Sergey Svishchev +#ifndef MAME_DEVICES_HP_HIL_HLEBASE_H +#define MAME_DEVICES_HP_HIL_HLEBASE_H + +#pragma once + +#include "hp_hil.h" +#include "machine/keyboard.h" + + +namespace bus { + namespace hp_hil { + +class hle_device_base + : public device_t + , public device_hp_hil_interface +{ +public: + virtual ~hle_device_base() override; + void transmit_byte(uint8_t byte); +protected: + // constructor/destructor + hle_device_base(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, uint32_t clock); + + // device overrides + virtual void device_start() override; + virtual void device_reset() override; + + // device_hp_hil_interface overrides + virtual bool hil_write(uint16_t *data) override; + virtual void hil_idd() = 0; + virtual int hil_poll() = 0; +private: + + + util::fifo m_fifo; +}; + +} // namespace bus::hp_hil +} // namespace bus + +#endif // MAME_DEVICES_HP_HIL_HLEBASE_H diff --git a/src/devices/bus/hp_hil/hlekbd.cpp b/src/devices/bus/hp_hil/hlekbd.cpp index 5cca998409d..4771243bef9 100644 --- a/src/devices/bus/hp_hil/hlekbd.cpp +++ b/src/devices/bus/hp_hil/hlekbd.cpp @@ -14,8 +14,8 @@ DEFINE_DEVICE_TYPE_NS(HP_IPC_HLE_KEYBOARD, bus::hp_hil, hle_hp_ipc_device, "hp_ipc_hle_kbd", "HP Integral Keyboard (HLE)") DEFINE_DEVICE_TYPE_NS(HP_ITF_HLE_KEYBOARD, bus::hp_hil, hle_hp_itf_device, "hp_itf_hle_kbd", "HP ITF Keyboard") - -namespace bus { namespace hp_hil { +namespace bus { + namespace hp_hil { namespace { @@ -408,192 +408,27 @@ INPUT_PORTS_START( itf_basic ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~') INPUT_PORTS_END - - INPUT_PORTS_START( hle_hp_itf_device ) PORT_INCLUDE( itf_basic ) PORT_INCLUDE( itf_id ) INPUT_PORTS_END - } // anonymous namespace - -/*************************************************************************** - BASE HLE KEYBOARD DEVICE -***************************************************************************/ - -/*-------------------------------------------------- - hle_device_base::hle_device_base - designated device constructor ---------------------------------------------------*/ - -hle_device_base::hle_device_base(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock) - , device_hp_hil_interface(mconfig, *this) - , device_matrix_keyboard_interface(mconfig, *this, "COL1", "COL2", "COL3", "COL4", "COL5", "COL6", "COL7", "COL8", "COL9", "COL10", "COL11", "COL12", "COL13", "COL14", "COL15") -{ } - - -/*-------------------------------------------------- - hle_device_base::~hle_device_base - destructor ---------------------------------------------------*/ - -hle_device_base::~hle_device_base() -{ } - - -/*-------------------------------------------------- - hle_device_base::device_start - perform expensive initialisations, allocate - resources, register for save state ---------------------------------------------------*/ - -void hle_device_base::device_start() -{ - set_hp_hil_mlc_device(); - - m_powerup = true; - m_passthru = false; -} - - -/*-------------------------------------------------- - hle_device_base::device_reset - perform startup tasks, also used for host - requested reset ---------------------------------------------------*/ - -void hle_device_base::device_reset() -{ - m_fifo.clear(); - - // kick the base - reset_key_state(); - start_processing(attotime::from_hz(1'200)); -} - -// ' -bool hle_device_base::hil_write(uint16_t *pdata) -{ - int frames = 0; - uint8_t addr = (*pdata >> 8) & 7; - uint8_t data = *pdata & 0xff; - bool command = BIT(*pdata, 11); - - LOG("rx from mlc %04X (%s addr %d, data %02X)\n", *pdata, - command ? "command" : "data", addr, data); - if (!command) - goto out; - - if (addr != 0 && addr != m_device_id) - goto out; - - switch (data) - { - case HPHIL_IFC: - m_powerup = false; - break; - - case HPHIL_EPT: - m_passthru = true; - break; - - case HPHIL_ELB: - m_passthru = false; - break; - - case 0x09: - case 0x0a: - case 0x0b: - case 0x0c: - case 0x0d: - case 0x0e: - case 0x0f: - m_device_id = data - 8; - m_device_id16 = (data - 8) << 8; - *pdata &= ~7; - *pdata += (data - 7); - break; - - case HPHIL_POL: - if (!m_fifo.empty()) - { - - frames = 1; - m_hp_hil_mlc->hil_write(m_device_id16 | 0x40); // Keycode Set 1, no coordinate data - while (!m_fifo.empty()) - { - m_hp_hil_mlc->hil_write(m_device_id16 | m_fifo.dequeue()); - frames++; - } - } - m_hp_hil_mlc->hil_write(HPMLC_W1_C | (addr << 8) | HPHIL_POL | (frames)); - *pdata &= ~7; - *pdata += frames; - return true; - - case HPHIL_DSR: - m_device_id = m_device_id16 = 0; - m_powerup = true; - break; - - case HPHIL_IDD: - m_hp_hil_mlc->hil_write(0x0100 | ioport("COL0")->read()); - m_hp_hil_mlc->hil_write(m_device_id16 | 0); - break; - - case HPHIL_DHR: - m_powerup = true; - m_passthru = false; - device_reset(); - return true; - break; - - default: - LOG("command %02X unknown\n", data); - break; - } -out: - if (!m_passthru) { - m_hp_hil_mlc->hil_write(*pdata); - return false; - } - return true; -} - -void hle_device_base::transmit_byte(uint8_t byte) +void hle_hp_ipc_device::transmit_byte(uint8_t byte) { if (!m_fifo.full()) { m_fifo.enqueue(byte); } -// else -// printf("queuing fail (fifo full)\n"); } -/*-------------------------------------------------- - hle_device_base::key_make - handle a key being pressed ---------------------------------------------------*/ - -void hle_device_base::key_make(uint8_t row, uint8_t column) +void hle_hp_itf_device::transmit_byte(uint8_t byte) { - transmit_byte((((row + 1) ^ 8) << 4) + (column << 1)); + if (!m_fifo.full()) { + m_fifo.enqueue(byte); + } } - -/*-------------------------------------------------- - hle_device_base::key_break - handle a key being released ---------------------------------------------------*/ - -void hle_device_base::key_break(uint8_t row, uint8_t column) -{ - transmit_byte((((row + 1) ^ 8) << 4) + (column << 1) + 1); -} - - /*************************************************************************** HP INTEGRAL HLE KEYBOARD DEVICE ***************************************************************************/ @@ -605,8 +440,62 @@ void hle_device_base::key_break(uint8_t row, uint8_t column) hle_hp_ipc_device::hle_hp_ipc_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) : hle_device_base(mconfig, HP_IPC_HLE_KEYBOARD, tag, owner, clock) + , device_matrix_keyboard_interface(mconfig, *this, "COL1", "COL2", "COL3", "COL4", "COL5", "COL6", "COL7", "COL8", "COL9", "COL10", "COL11", "COL12", "COL13", "COL14", "COL15") { } +void hle_hp_ipc_device::device_reset() +{ + m_fifo.clear(); + reset_key_state(); + start_processing(attotime::from_hz(1'200)); +} + +void hle_hp_ipc_device::hil_idd() +{ + m_hp_hil_mlc->hil_write(0x0100 | ioport("COL0")->read()); + m_hp_hil_mlc->hil_write(m_device_id16 | 0); + return; +} + +void hle_hp_ipc_device::key_make(uint8_t row, uint8_t column) +{ + transmit_byte((((row + 1) ^ 8) << 4) + (column << 1)); +} + + +void hle_hp_ipc_device::key_break(uint8_t row, uint8_t column) +{ + transmit_byte((((row + 1) ^ 8) << 4) + (column << 1) + 1); +} + +int hle_hp_ipc_device::hil_poll() +{ + int frames = 1; + if (m_fifo.empty()) + return frames; + + m_hp_hil_mlc->hil_write(m_device_id16 | 0x40); // Keycode Set 1, no coordinate data + while (!m_fifo.empty()) { + m_hp_hil_mlc->hil_write(m_device_id16 | m_fifo.dequeue()); + frames++; + } + return frames; +} + +int hle_hp_itf_device::hil_poll() +{ + int frames = 0; + if (m_fifo.empty()) + return frames; + LOG("KBD HAVE DATA\n"); + frames++; + m_hp_hil_mlc->hil_write(m_device_id16 | 0x40); // Keycode Set 1, no coordinate data + while (!m_fifo.empty()) { + m_hp_hil_mlc->hil_write(m_device_id16 | m_fifo.dequeue()); + frames++; + } + return frames; +} /*-------------------------------------------------- hle_hp_ipc_device::device_input_ports @@ -629,8 +518,28 @@ ioport_constructor hle_hp_ipc_device::device_input_ports() const hle_hp_itf_device::hle_hp_itf_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) : hle_device_base(mconfig, HP_ITF_HLE_KEYBOARD, tag, owner, clock) + , device_matrix_keyboard_interface(mconfig, *this, "COL1", "COL2", "COL3", "COL4", "COL5", "COL6", "COL7", "COL8", "COL9", "COL10", "COL11", "COL12", "COL13", "COL14", "COL15") { } +void hle_hp_itf_device::device_reset() +{ + m_fifo.clear(); + reset_key_state(); + start_processing(attotime::from_hz(1'200)); +} + +void hle_hp_itf_device::key_make(uint8_t row, uint8_t column) +{ + LOG("make\n"); + transmit_byte((((row + 1) ^ 8) << 4) + (column << 1)); +} + + +void hle_hp_itf_device::key_break(uint8_t row, uint8_t column) +{ + LOG("break\n"); + transmit_byte((((row + 1) ^ 8) << 4) + (column << 1) + 1); +} /*-------------------------------------------------- hle_hp_itf_device::device_input_ports @@ -643,4 +552,12 @@ ioport_constructor hle_hp_itf_device::device_input_ports() const } -} } // namespace bus::hp_hil +void hle_hp_itf_device::hil_idd() +{ + m_hp_hil_mlc->hil_write(m_device_id16 | ioport("COL0")->read()); + m_hp_hil_mlc->hil_write(m_device_id16 | 0x04); + return; +} + +} // namespace bus::hp_hil +} // namespace bus diff --git a/src/devices/bus/hp_hil/hlekbd.h b/src/devices/bus/hp_hil/hlekbd.h index 837e8501933..714b0ba6d2b 100644 --- a/src/devices/bus/hp_hil/hlekbd.h +++ b/src/devices/bus/hp_hil/hlekbd.h @@ -6,64 +6,92 @@ #pragma once #include "hp_hil.h" +#include "hlebase.h" #include "machine/keyboard.h" -namespace bus { namespace hp_hil { +namespace bus { + namespace hp_hil { -class hle_device_base - : public device_t - , public device_hp_hil_interface - , protected device_matrix_keyboard_interface<15U> -{ -public: - virtual ~hle_device_base() override; - - static constexpr feature_type imperfect_features() { return feature::KEYBOARD; } - -protected: - // constructor/destructor - hle_device_base(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, uint32_t clock); - - // device overrides - virtual void device_start() override; - virtual void device_reset() override; - - // device_matrix_keyboard_interface overrides - virtual void key_make(uint8_t row, uint8_t column) override; - virtual void key_break(uint8_t row, uint8_t column) override; - - // device_hp_hil_interface overrides - virtual bool hil_write(uint16_t *data) override; - -private: - void transmit_byte(uint8_t byte); - - util::fifo m_fifo; -}; - - -class hle_hp_ipc_device : public hle_device_base +class hle_hp_ipc_device + : public hle_device_base + , protected device_matrix_keyboard_interface<15U> { public: hle_hp_ipc_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock); virtual ioport_constructor device_input_ports() const override; + virtual void device_reset() override; + + // device_matrix_keyboard_interface overrides + virtual void key_make(uint8_t row, uint8_t column) override; + virtual void key_break(uint8_t row, uint8_t column) override; + virtual int hil_poll() override; + virtual void hil_idd() override; +private: + util::fifo m_fifo; + void transmit_byte(uint8_t byte); }; -class hle_hp_itf_device : public hle_device_base +class hle_hp_itf_device + : public hle_device_base + , protected device_matrix_keyboard_interface<15U> { public: hle_hp_itf_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock); - + virtual void device_reset() override; virtual ioport_constructor device_input_ports() const override; + + // device_matrix_keyboard_interface overrides + virtual void key_make(uint8_t row, uint8_t column) override; + virtual void key_break(uint8_t row, uint8_t column) override; + virtual int hil_poll() override; + virtual void hil_idd() override; +private: + util::fifo m_fifo; + void transmit_byte(uint8_t byte); }; -} } // namespace bus::hp_hil +class hle_hp_46060b_device + : public hle_device_base +{ +public: + hle_hp_46060b_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock); + virtual void device_reset() override; + virtual ioport_constructor device_input_ports() const override; + virtual int hil_poll() override; + virtual void hil_idd() override; + enum state_mask + { + MOUSE_YPOS = 0x000000ff, + MOUSE_XPOS = 0x0000ff00, + MOUSE_LBUTTON = 0x00010000, + MOUSE_MBUTTON = 0x00020000, + MOUSE_RBUTTON = 0x00040000, + + MOUSE_BUTTONS = 0x00070000 + }; + + DECLARE_INPUT_CHANGED_MEMBER(mouse_button); + DECLARE_INPUT_CHANGED_MEMBER(mouse_x); + DECLARE_INPUT_CHANGED_MEMBER(mouse_y); + + int8_t mouse_x_delta; + int8_t mouse_y_delta; + uint32_t mouse_buttons; + util::fifo m_fifo; + +}; + + + +} // namespace bus::hp_hil +} // namespace bus DECLARE_DEVICE_TYPE_NS(HP_IPC_HLE_KEYBOARD, bus::hp_hil, hle_hp_ipc_device); DECLARE_DEVICE_TYPE_NS(HP_ITF_HLE_KEYBOARD, bus::hp_hil, hle_hp_itf_device); +DECLARE_DEVICE_TYPE_NS(HP_46060B_MOUSE, bus::hp_hil, hle_hp_46060b_device); #endif // MAME_DEVICES_HP_HIL_HLEKBD_H diff --git a/src/devices/bus/hp_hil/hlemouse.cpp b/src/devices/bus/hp_hil/hlemouse.cpp new file mode 100644 index 00000000000..9fc6c9db985 --- /dev/null +++ b/src/devices/bus/hp_hil/hlemouse.cpp @@ -0,0 +1,127 @@ +// license:BSD-3-Clause +// copyright-holders:Sven Schnelle +#include "emu.h" +#include "hlekbd.h" + +#include "machine/keyboard.ipp" +//#define VERBOSE 1 +#include "logmacro.h" + +/*************************************************************************** + DEVICE TYPE GLOBALS +***************************************************************************/ + +DEFINE_DEVICE_TYPE_NS(HP_46060B_MOUSE, bus::hp_hil, hle_hp_46060b_device, "hp_46060b", "HP 46060B Mouse") + +namespace bus { + namespace hp_hil { + +namespace { + +/*************************************************************************** + INPUT PORT DEFINITIONS +***************************************************************************/ + +INPUT_PORTS_START( hle_hp_46060b_device ) + PORT_START("mouse_buttons") + PORT_BIT(hle_hp_46060b_device::MOUSE_LBUTTON, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Mouse Left Button") PORT_CODE(MOUSECODE_BUTTON1) PORT_CHANGED_MEMBER(DEVICE_SELF, hle_hp_46060b_device, mouse_button, nullptr) + PORT_BIT(hle_hp_46060b_device::MOUSE_MBUTTON, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse Middle Button") PORT_CODE(MOUSECODE_BUTTON3) PORT_CHANGED_MEMBER(DEVICE_SELF, hle_hp_46060b_device, mouse_button, nullptr) + PORT_BIT(hle_hp_46060b_device::MOUSE_RBUTTON, IP_ACTIVE_HIGH, IPT_BUTTON3) PORT_NAME("Mouse Right Button") PORT_CODE(MOUSECODE_BUTTON2) PORT_CHANGED_MEMBER(DEVICE_SELF, hle_hp_46060b_device, mouse_button, nullptr) + + PORT_START("mouse_x") + PORT_BIT(0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(50) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, hle_hp_46060b_device, mouse_x, nullptr) + PORT_START("mouse_y") + PORT_BIT(0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(50) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, hle_hp_46060b_device, mouse_y, nullptr) +INPUT_PORTS_END +} // anonymous namespace + +hle_hp_46060b_device::hle_hp_46060b_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) + : hle_device_base(mconfig, HP_46060B_MOUSE, tag, owner, clock) +{ } + +void hle_hp_46060b_device::device_reset() +{ + m_fifo.clear(); +} + +int hle_hp_46060b_device::hil_poll() +{ + int frames = 0; + uint16_t reports = 0; + + if (mouse_x_delta || mouse_y_delta) + reports |= 2; + + if (!m_fifo.empty()) + reports |= 0x40; + + if (!reports) + return 0; + + m_hp_hil_mlc->hil_write(m_device_id16 | reports); // report X & Y data + frames++; + if (mouse_x_delta || mouse_y_delta) { + m_hp_hil_mlc->hil_write(m_device_id16 | (uint8_t)mouse_x_delta); + m_hp_hil_mlc->hil_write(m_device_id16 | (uint8_t)mouse_y_delta); + mouse_x_delta = 0; + mouse_y_delta = 0; + frames+=2; + } + + while (!m_fifo.empty()) { + m_hp_hil_mlc->hil_write(m_device_id16 | m_fifo.dequeue()); + frames++; + } + + return frames; +} + + +void hle_hp_46060b_device::hil_idd() +{ + m_hp_hil_mlc->hil_write(m_device_id16 | 0x68); + m_hp_hil_mlc->hil_write(m_device_id16 | 0x12); // report X & Y Axes + m_hp_hil_mlc->hil_write(m_device_id16 | 0xc2); // resolution Low + m_hp_hil_mlc->hil_write(m_device_id16 | 0x1e); // resolution High + return; +} + +ioport_constructor hle_hp_46060b_device::device_input_ports() const +{ + return INPUT_PORTS_NAME(hle_hp_46060b_device); +} + +INPUT_CHANGED_MEMBER(hle_hp_46060b_device::mouse_y) +{ + int8_t delta = newval - oldval; + mouse_y_delta += -delta; +} + +INPUT_CHANGED_MEMBER(hle_hp_46060b_device::mouse_x) +{ + int8_t delta = newval - oldval; + mouse_x_delta += delta; +} + +INPUT_CHANGED_MEMBER(hle_hp_46060b_device::mouse_button) +{ + const ioport_value data = field.port().read(); + uint32_t _data = data & MOUSE_BUTTONS; + + switch(_data ^ mouse_buttons) { + case MOUSE_LBUTTON: + if (!m_fifo.full()) { + m_fifo.enqueue(_data ? 0x80 : 0x81); + } + break; + case MOUSE_RBUTTON: + if (!m_fifo.full()) { + m_fifo.enqueue(_data ? 0x82 : 0x83); + } + break; + } + mouse_buttons = data; +} + +} // namesapce bus::hp_hil +} // namespace bus diff --git a/src/devices/bus/hp_hil/hlemouse.h b/src/devices/bus/hp_hil/hlemouse.h new file mode 100644 index 00000000000..7abfc1d5192 --- /dev/null +++ b/src/devices/bus/hp_hil/hlemouse.h @@ -0,0 +1,52 @@ +// license:BSD-3-Clause +// copyright-holders:Sven Schnelle +#ifndef MAME_DEVICES_HP_HIL_HLEMOUSE_H +#define MAME_DEVICES_HP_HIL_HLEMOUSE_H + +#pragma once + +#include "hp_hil.h" +#include "hlebase.h" +#include "machine/keyboard.h" + + +namespace bus { + namespace hp_hil { + +class hle_hp_46060b_device + : public hle_device_base +{ +public: + hle_hp_46060b_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock); + virtual void device_reset() override; + virtual ioport_constructor device_input_ports() const override; + virtual int hil_poll() override; + virtual void hil_idd() override; + enum state_mask + { + MOUSE_YPOS = 0x000000ff, + MOUSE_XPOS = 0x0000ff00, + MOUSE_LBUTTON = 0x00010000, + MOUSE_MBUTTON = 0x00020000, + MOUSE_RBUTTON = 0x00040000, + + MOUSE_BUTTONS = 0x00070000 + }; + + DECLARE_INPUT_CHANGED_MEMBER(mouse_button); + DECLARE_INPUT_CHANGED_MEMBER(mouse_x); + DECLARE_INPUT_CHANGED_MEMBER(mouse_y); + + int8_t mouse_x_delta; + int8_t mouse_y_delta; + uint32_t mouse_buttons; + util::fifo m_fifo; + +}; + +} // namespace bus::hp_hil +} // namespace bus + +DECLARE_DEVICE_TYPE_NS(HP_46060B_MOUSE, bus::hp_hil, hle_hp_46060b_device); + +#endif // MAME_DEVICES_HP_HIL_HLEMOUSE_H diff --git a/src/mame/drivers/hp_ipc.cpp b/src/mame/drivers/hp_ipc.cpp index c28116b37a4..de97ac955c5 100644 --- a/src/mame/drivers/hp_ipc.cpp +++ b/src/mame/drivers/hp_ipc.cpp @@ -758,6 +758,7 @@ MACHINE_CONFIG_START(hp_ipc_state::hp_ipc_base) MCFG_HP_HIL_INT_CALLBACK(WRITELINE(*this, hp_ipc_state, irq_2)) MCFG_HP_HIL_NMI_CALLBACK(WRITELINE(*this, hp_ipc_state, irq_7)) MCFG_HP_HIL_SLOT_ADD("mlc", "hil1", hp_hil_devices, "hp_ipc_kbd") + MCFG_HP_HIL_SLOT_ADD("mlc", "hil2", hp_hil_devices, "hp_46060b") MCFG_DEVICE_ADD("hpib", TMS9914, 4_MHz_XTAL) MCFG_TMS9914_INT_WRITE_CB(WRITELINE(*this, hp_ipc_state, irq_3))