c64: added mouse controller (nw)

This commit is contained in:
hap 2019-05-13 19:12:11 +02:00
parent 88190884b6
commit 582b9e279f
5 changed files with 162 additions and 0 deletions

View File

@ -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",

View File

@ -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.

View File

@ -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);

View File

@ -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();
}

View File

@ -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