From 9602e450d0836caca83879278052071eb727bb6c Mon Sep 17 00:00:00 2001 From: smf- Date: Sat, 4 Jan 2014 15:36:22 +0000 Subject: [PATCH] Added PET user port joystick adapter [smf] --- .gitattributes | 2 + src/emu/bus/bus.mak | 1 + src/emu/bus/pet/petuja.c | 108 +++++++++++++++++++++++++++++++++++++++ src/emu/bus/pet/petuja.h | 66 ++++++++++++++++++++++++ src/emu/bus/pet/user.c | 3 ++ 5 files changed, 180 insertions(+) create mode 100644 src/emu/bus/pet/petuja.c create mode 100644 src/emu/bus/pet/petuja.h diff --git a/.gitattributes b/.gitattributes index c7330e332d5..4f7444729d2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -789,6 +789,8 @@ src/emu/bus/pet/diag264_lb_tape.c svneol=native#text/plain src/emu/bus/pet/diag264_lb_tape.h svneol=native#text/plain src/emu/bus/pet/exp.c svneol=native#text/plain src/emu/bus/pet/exp.h svneol=native#text/plain +src/emu/bus/pet/petuja.c svneol=native#text/plain +src/emu/bus/pet/petuja.h svneol=native#text/plain src/emu/bus/pet/superpet.c svneol=native#text/plain src/emu/bus/pet/superpet.h svneol=native#text/plain src/emu/bus/pet/user.c svneol=native#text/plain diff --git a/src/emu/bus/bus.mak b/src/emu/bus/bus.mak index 856b0960772..d6fe525c16e 100644 --- a/src/emu/bus/bus.mak +++ b/src/emu/bus/bus.mak @@ -335,6 +335,7 @@ BUSOBJS += $(BUSOBJ)/pet/exp.o BUSOBJS += $(BUSOBJ)/pet/64k.o BUSOBJS += $(BUSOBJ)/pet/superpet.o BUSOBJS += $(BUSOBJ)/pet/user.o +BUSOBJS += $(BUSOBJ)/pet/petuja.o endif diff --git a/src/emu/bus/pet/petuja.c b/src/emu/bus/pet/petuja.c new file mode 100644 index 00000000000..6d0376aa549 --- /dev/null +++ b/src/emu/bus/pet/petuja.c @@ -0,0 +1,108 @@ +// license:BSD-3-Clause +// copyright-holders:smf +/********************************************************************** + + Commodore PET userport joystick adapter emulation + + http://zimmers.net/cbmpics/cbm/PETx/petfaq.html + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "petuja.h" + + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type PET_USERPORT_JOYSTICK_ADAPTER = &device_creator; + + +//------------------------------------------------- +// INPUT_PORTS( petuja ) +//------------------------------------------------- + +static INPUT_PORTS_START( petuja ) + PORT_START("JOY") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_adapter_device, write_up1) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_adapter_device, write_down1) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, device_pet_user_port_interface, output_e) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, device_pet_user_port_interface, output_f) + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_adapter_device, write_up2) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_adapter_device, write_down2) + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, device_pet_user_port_interface, output_k) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, device_pet_user_port_interface, output_l) + + PORT_START("FIRE") + PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_adapter_device, write_fire1) + PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_adapter_device, write_fire2) +INPUT_PORTS_END + + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor pet_userport_joystick_adapter_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( petuja ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// pet_userport_joystick_adapter_device - constructor +//------------------------------------------------- + +pet_userport_joystick_adapter_device::pet_userport_joystick_adapter_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, PET_USERPORT_JOYSTICK_ADAPTER, "PET Userport Joystick Adapter", tag, owner, clock, "petuja", __FILE__), + device_pet_user_port_interface(mconfig, *this), + m_up1(1), + m_down1(1), + m_fire1(1), + m_up2(1), + m_down2(1), + m_fire2(1) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void pet_userport_joystick_adapter_device::device_start() +{ +} + + +//------------------------------------------------- +// update_port1 +//------------------------------------------------- + +void pet_userport_joystick_adapter_device::update_port1() +{ + printf( "update port1\n" ); + output_c(m_up1 && m_fire1); + output_d(m_down1 && m_fire1); +} + + +//------------------------------------------------- +// update_port2 +//------------------------------------------------- + +void pet_userport_joystick_adapter_device::update_port2() +{ + printf( "update port2\n" ); + output_h(m_up2 && m_fire2); + output_j(m_down2 && m_fire2); +} diff --git a/src/emu/bus/pet/petuja.h b/src/emu/bus/pet/petuja.h new file mode 100644 index 00000000000..de93d1fb370 --- /dev/null +++ b/src/emu/bus/pet/petuja.h @@ -0,0 +1,66 @@ +// license:BSD-3-Clause +// copyright-holders:smf +/********************************************************************** + + Commodore PET userport joystick adapter emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#pragma once + +#ifndef __PETUJA__ +#define __PETUJA__ + + +#include "emu.h" +#include "user.h" + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> pet_userport_joystick_adapter_device + +class pet_userport_joystick_adapter_device : public device_t, + public device_pet_user_port_interface +{ +public: + // construction/destruction + pet_userport_joystick_adapter_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual ioport_constructor device_input_ports() const; + + // device_pet_user_port_interface overrides + WRITE_LINE_MEMBER( write_up1 ) { m_up1 = state; update_port1(); } + WRITE_LINE_MEMBER( write_down1 ) { m_down1 = state; update_port1(); } + WRITE_LINE_MEMBER( write_fire1 ) { m_fire1 = state; update_port1(); } + WRITE_LINE_MEMBER( write_up2 ) { m_up2 = state; update_port2(); } + WRITE_LINE_MEMBER( write_down2 ) { m_down2 = state; update_port2(); } + WRITE_LINE_MEMBER( write_fire2 ) { m_fire2 = state; update_port2(); } + +protected: + // device-level overrides + virtual void device_start(); + + void update_port1(); + void update_port2(); + int m_up1; + int m_down1; + int m_fire1; + int m_up2; + int m_down2; + int m_fire2; +}; + + +// device type definition +extern const device_type PET_USERPORT_JOYSTICK_ADAPTER; + + +#endif diff --git a/src/emu/bus/pet/user.c b/src/emu/bus/pet/user.c index 80e0b812fde..784a56404cf 100644 --- a/src/emu/bus/pet/user.c +++ b/src/emu/bus/pet/user.c @@ -165,5 +165,8 @@ WRITE_LINE_MEMBER( pet_user_port_device::write_m ) { if (m_card != NULL) m_card- // SLOT_INTERFACE( pet_user_port_cards ) //------------------------------------------------- +#include "petuja.h" + SLOT_INTERFACE_START( pet_user_port_cards ) + SLOT_INTERFACE("petuja", PET_USERPORT_JOYSTICK_ADAPTER) SLOT_INTERFACE_END