diff --git a/hash/pet_cass.xml b/hash/pet_cass.xml index a41ed204d6b..1420d2aa123 100644 --- a/hash/pet_cass.xml +++ b/hash/pet_cass.xml @@ -304,11 +304,11 @@ - + Cursor 11 1979 - + The Code Works @@ -317,11 +317,11 @@ - + Cursor 12 1979 - + The Code Works @@ -369,11 +369,11 @@ - + Cursor 16 1980 - + The Code Works @@ -2775,11 +2775,11 @@ - + Seawolf 1978 - + Creative Software @@ -2841,8 +2841,8 @@ - - + + @@ -2860,6 +2860,19 @@ + + Supermon + 1979 + Toronto PET User Group + + + + + + + + + Soundware Checkers 1978 diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 3da1e88cb3c..eebdd5d8a1d 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -1047,6 +1047,8 @@ if (BUSES["PET"]~=null) then MAME_DIR .. "src/devices/bus/pet/petuja.h", MAME_DIR .. "src/devices/bus/pet/cb2snd.cpp", MAME_DIR .. "src/devices/bus/pet/cb2snd.h", + MAME_DIR .. "src/devices/bus/pet/2joysnd.h", + MAME_DIR .. "src/devices/bus/pet/2joysnd.cpp", } end diff --git a/src/devices/bus/pet/2joysnd.cpp b/src/devices/bus/pet/2joysnd.cpp new file mode 100644 index 00000000000..b0ac30bf0d1 --- /dev/null +++ b/src/devices/bus/pet/2joysnd.cpp @@ -0,0 +1,163 @@ +// license:BSD-3-Clause +// copyright-holders: Ken White +/********************************************************************** + + Commodore PET user port dual joystick and sound device emulation + + BEST OF THE PET GAZETTE magazine documents attaching Atari-style joysticks + with DB-9S connectors to a DB-25P connector plugged into the user port. + page 42, PET AND THE DUAL JOYSTICKS by Chuck Johnson + page 47, STANDARD #1 (CB2 Sound) + +**********************************************************************/ + +/* + +Connections +---------- + User Joysticks + Port ____ + / | + F ----- | 1 | joy 1 up + > --- | 6 | joy 1 button + E ----- | 2 | joy 1 down + | 7 | + D ----- | 3 | joy 1 left + | 8 | + C ----- | 4 | joy 1 right + | 9 | + | 5 | + \____| + ____ + / | + L ----- | 1 | joy 2 up + > --- | 6 | joy 2 button + K ----- | 2 | joy 2 down + | 7 | + J ----- | 3 | joy 2 left + | 8 | + H ----- | 4 | joy 2 right + | 9 | + | 5 | + \____| + + M ----- audio amplifier + +*/ + +#include "2joysnd.h" + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type PET_USERPORT_JOYSTICK_AND_SOUND_DEVICE = &device_creator; + +#define DAC_TAG "dac" + +MACHINE_CONFIG_FRAGMENT( 2joysnd ) + MCFG_SPEAKER_STANDARD_MONO("cb2spkr") + MCFG_SOUND_ADD(DAC_TAG, DAC, 0) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "cb2spkr", 1.00) +MACHINE_CONFIG_END + +//------------------------------------------------- +// INPUT_PORTS( 2joysnd ) +//------------------------------------------------- + +static INPUT_PORTS_START( 2joysnd ) + PORT_START("JOY") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, device_pet_user_port_interface, output_c) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, device_pet_user_port_interface, output_d) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_and_sound_device, write_down1) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_and_sound_device, write_up1) + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, device_pet_user_port_interface, output_h) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, device_pet_user_port_interface, output_j) + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_and_sound_device, write_down2) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_and_sound_device, write_up2) + + PORT_START("FIRE") + PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_and_sound_device, write_fire1) + PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, pet_userport_joystick_and_sound_device, write_fire2) +INPUT_PORTS_END + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor pet_userport_joystick_and_sound_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( 2joysnd ); +} + +//------------------------------------------------- +// machine_config_additions - device-specific +// machine configurations +//------------------------------------------------- + +machine_config_constructor pet_userport_joystick_and_sound_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( 2joysnd ); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// pet_user_port_dual_joystick_and_sound_device - constructor +//------------------------------------------------- + +pet_userport_joystick_and_sound_device::pet_userport_joystick_and_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, PET_USERPORT_JOYSTICK_AND_SOUND_DEVICE, "Dual Joysticks and Sound", tag, owner, clock, "2joysnd", __FILE__), + device_pet_user_port_interface(mconfig, *this), + m_dac(*this, DAC_TAG), + 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_and_sound_device::device_start() +{ +} + + +//------------------------------------------------- +// update_port1 +//------------------------------------------------- + +void pet_userport_joystick_and_sound_device::update_port1() +{ +// printf( "update port1\n" ); + output_f(m_up1 && m_fire1); + output_e(m_down1 && m_fire1); +} + + +//------------------------------------------------- +// update_port2 +//------------------------------------------------- + +void pet_userport_joystick_and_sound_device::update_port2() +{ +// printf( "update port2\n" ); + output_l(m_up2 && m_fire2); + output_k(m_down2 && m_fire2); +} + + +DECLARE_WRITE_LINE_MEMBER( pet_userport_joystick_and_sound_device::input_m ) +{ + m_dac->write_unsigned8(state ? 0xff : 0x00); +} diff --git a/src/devices/bus/pet/2joysnd.h b/src/devices/bus/pet/2joysnd.h new file mode 100644 index 00000000000..26a2f193d71 --- /dev/null +++ b/src/devices/bus/pet/2joysnd.h @@ -0,0 +1,72 @@ +// license:BSD-3-Clause +// copyright-holders: Ken White +/********************************************************************** + + Commodore PET user port dual joystick and CB2 sound emulation + +**********************************************************************/ + +#pragma once + +#ifndef __2JOYSND__ +#define __2JOYSND__ + + +#include "emu.h" +#include "user.h" +#include "sound/dac.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> pet_userport_joystick_adapter_device + +class pet_userport_joystick_and_sound_device : public device_t, + public device_pet_user_port_interface +{ +public: + // construction/destruction + pet_userport_joystick_and_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual ioport_constructor device_input_ports() const override; + + virtual machine_config_constructor device_mconfig_additions() const override; + + virtual DECLARE_WRITE_LINE_MEMBER( input_m ) override; + + required_device m_dac; + + // 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() override; + + 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_AND_SOUND_DEVICE; + + +#endif diff --git a/src/devices/bus/pet/user.cpp b/src/devices/bus/pet/user.cpp index f56132c5dd3..c79f9eec83a 100644 --- a/src/devices/bus/pet/user.cpp +++ b/src/devices/bus/pet/user.cpp @@ -122,9 +122,11 @@ device_pet_user_port_interface::~device_pet_user_port_interface() #include "diag.h" #include "petuja.h" #include "cb2snd.h" +#include "2joysnd.h" SLOT_INTERFACE_START( pet_user_port_cards ) SLOT_INTERFACE("diag", PET_USERPORT_DIAGNOSTIC_CONNECTOR) SLOT_INTERFACE("petuja", PET_USERPORT_JOYSTICK_ADAPTER) SLOT_INTERFACE("cb2snd", PET_USERPORT_CB2_SOUND_DEVICE) + SLOT_INTERFACE("2joysnd", PET_USERPORT_JOYSTICK_AND_SOUND_DEVICE) SLOT_INTERFACE_END