From 582b9e279f2314b2c247290b23a6fb4c640576b6 Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 13 May 2019 19:12:11 +0200 Subject: c64: added mouse controller (nw) --- scripts/src/bus.lua | 2 + src/devices/bus/c64/fcc.cpp | 2 + src/devices/bus/vcs_ctrl/ctrl.cpp | 2 + src/devices/bus/vcs_ctrl/mouse.cpp | 100 +++++++++++++++++++++++++++++++++++++ src/devices/bus/vcs_ctrl/mouse.h | 56 +++++++++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 src/devices/bus/vcs_ctrl/mouse.cpp create mode 100644 src/devices/bus/vcs_ctrl/mouse.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index ed66b0cf67d..5933424f421 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -1801,6 +1801,8 @@ if (BUSES["VCS_CTRL"]~=null) then MAME_DIR .. "src/devices/bus/vcs_ctrl/keypad.h", MAME_DIR .. "src/devices/bus/vcs_ctrl/lightpen.cpp", MAME_DIR .. "src/devices/bus/vcs_ctrl/lightpen.h", + MAME_DIR .. "src/devices/bus/vcs_ctrl/mouse.cpp", + MAME_DIR .. "src/devices/bus/vcs_ctrl/mouse.h", MAME_DIR .. "src/devices/bus/vcs_ctrl/paddles.cpp", MAME_DIR .. "src/devices/bus/vcs_ctrl/paddles.h", MAME_DIR .. "src/devices/bus/vcs_ctrl/wheel.cpp", diff --git a/src/devices/bus/c64/fcc.cpp b/src/devices/bus/c64/fcc.cpp index cd9848cb26f..f454b647129 100644 --- a/src/devices/bus/c64/fcc.cpp +++ b/src/devices/bus/c64/fcc.cpp @@ -4,6 +4,8 @@ Tasc Final ChessCard cartridge emulation +It expects a mouse in port 2, and/or joystick in port 1. + The cartridge includes its own CPU (G65SC02P-4 @ 5MHz), making a relatively strong chess program possible on C64. It was also released for IBM PC, with an ISA card. diff --git a/src/devices/bus/vcs_ctrl/ctrl.cpp b/src/devices/bus/vcs_ctrl/ctrl.cpp index c4f735aacb6..57cdad8f4ba 100644 --- a/src/devices/bus/vcs_ctrl/ctrl.cpp +++ b/src/devices/bus/vcs_ctrl/ctrl.cpp @@ -71,6 +71,7 @@ void vcs_control_port_device::device_start() #include "joystick.h" #include "keypad.h" #include "lightpen.h" +#include "mouse.h" #include "paddles.h" #include "wheel.h" @@ -78,6 +79,7 @@ void vcs_control_port_devices(device_slot_interface &device) { device.option_add("joy", VCS_JOYSTICK); device.option_add("pad", VCS_PADDLES); + device.option_add("mouse", VCS_MOUSE); device.option_add("lp", VCS_LIGHTPEN); device.option_add("joybstr", VCS_JOYSTICK_BOOSTER); device.option_add("wheel", VCS_WHEEL); diff --git a/src/devices/bus/vcs_ctrl/mouse.cpp b/src/devices/bus/vcs_ctrl/mouse.cpp new file mode 100644 index 00000000000..76e1a6a8b38 --- /dev/null +++ b/src/devices/bus/vcs_ctrl/mouse.cpp @@ -0,0 +1,100 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder, hap +/********************************************************************** + + Mouse emulation (Commodore 1351 or compatible) + +**********************************************************************/ + +#include "emu.h" +#include "mouse.h" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(VCS_MOUSE, vcs_mouse_device, "vcs_mouse", "Atari / CBM Mouse") + + +static INPUT_PORTS_START( vcs_mouse ) + PORT_START("JOY") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) + PORT_BIT( 0xde, IP_ACTIVE_LOW, IPT_UNUSED ) + + PORT_START("POTX") + PORT_BIT( 0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) + + PORT_START("POTY") + PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_REVERSE +INPUT_PORTS_END + + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor vcs_mouse_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( vcs_mouse ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// vcs_mouse_device - constructor +//------------------------------------------------- + +vcs_mouse_device::vcs_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, VCS_MOUSE, tag, owner, clock), + device_vcs_control_port_interface(mconfig, *this), + m_joy(*this, "JOY"), + m_potx(*this, "POTX"), + m_poty(*this, "POTY") +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void vcs_mouse_device::device_start() +{ +} + + +//------------------------------------------------- +// vcs_joy_r - joystick read +//------------------------------------------------- + +uint8_t vcs_mouse_device::vcs_joy_r() +{ + return m_joy->read(); +} + + +//------------------------------------------------- +// vcs_pot_x_r - potentiometer X read +//------------------------------------------------- + +uint8_t vcs_mouse_device::vcs_pot_x_r() +{ + return m_potx->read(); +} + + +//------------------------------------------------- +// vcs_pot_y_r - potentiometer Y read +//------------------------------------------------- + +uint8_t vcs_mouse_device::vcs_pot_y_r() +{ + return m_poty->read(); +} diff --git a/src/devices/bus/vcs_ctrl/mouse.h b/src/devices/bus/vcs_ctrl/mouse.h new file mode 100644 index 00000000000..eab33d64aab --- /dev/null +++ b/src/devices/bus/vcs_ctrl/mouse.h @@ -0,0 +1,56 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder, hap +/********************************************************************** + + Mouse emulation (Commodore 1351 or compatible) + +**********************************************************************/ + +#ifndef MAME_BUS_VCS_CTRL_MOUSE_H +#define MAME_BUS_VCS_CTRL_MOUSE_H + +#pragma once + +#include "ctrl.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> vcs_mouse_device + +class vcs_mouse_device : public device_t, + public device_vcs_control_port_interface +{ +public: + // construction/destruction + vcs_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + // optional information overrides + virtual ioport_constructor device_input_ports() const override; + +protected: + // device-level overrides + virtual void device_start() override; + + // device_vcs_control_port_interface overrides + virtual uint8_t vcs_joy_r() override; + virtual uint8_t vcs_pot_x_r() override; + virtual uint8_t vcs_pot_y_r() override; + + virtual bool has_pot_x() override { return true; } + virtual bool has_pot_y() override { return true; } + +private: + required_ioport m_joy; + required_ioport m_potx; + required_ioport m_poty; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(VCS_MOUSE, vcs_mouse_device) + +#endif // MAME_BUS_VCS_CTRL_MOUSE_H -- cgit v1.2.3