Added PET user port joystick adapter [smf]

This commit is contained in:
smf- 2014-01-04 15:36:22 +00:00
parent fad0af02cb
commit 9602e450d0
5 changed files with 180 additions and 0 deletions

2
.gitattributes vendored
View File

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

View File

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

108
src/emu/bus/pet/petuja.c Normal file
View File

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

66
src/emu/bus/pet/petuja.h Normal file
View File

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

View File

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