mirror of
https://github.com/holub/mame
synced 2025-06-05 12:26:35 +03:00
a800: Add Atari CX85 Numeric Keypad to controller port options
This commit is contained in:
parent
9db9cc0300
commit
b53e5439f0
@ -2574,6 +2574,8 @@ if (BUSES["VCS_CTRL"]~=null) then
|
||||
files {
|
||||
MAME_DIR .. "src/devices/bus/vcs_ctrl/ctrl.cpp",
|
||||
MAME_DIR .. "src/devices/bus/vcs_ctrl/ctrl.h",
|
||||
MAME_DIR .. "src/devices/bus/vcs_ctrl/cx85.cpp",
|
||||
MAME_DIR .. "src/devices/bus/vcs_ctrl/cx85.h",
|
||||
MAME_DIR .. "src/devices/bus/vcs_ctrl/joystick.cpp",
|
||||
MAME_DIR .. "src/devices/bus/vcs_ctrl/joystick.h",
|
||||
MAME_DIR .. "src/devices/bus/vcs_ctrl/joybooster.cpp",
|
||||
|
@ -65,6 +65,7 @@ void vcs_control_port_device::device_start()
|
||||
// SLOT_INTERFACE( vcs_control_port_devices )
|
||||
//-------------------------------------------------
|
||||
|
||||
#include "cx85.h"
|
||||
#include "joybooster.h"
|
||||
#include "joystick.h"
|
||||
#include "keypad.h"
|
||||
@ -88,4 +89,6 @@ void a800_control_port_devices(device_slot_interface &device)
|
||||
{
|
||||
vcs_control_port_devices(device);
|
||||
device.set_option_machine_config("pad", &vcs_paddles_device::reverse_players);
|
||||
|
||||
device.option_add("cx85", ATARI_CX85);
|
||||
}
|
||||
|
128
src/devices/bus/vcs_ctrl/cx85.cpp
Normal file
128
src/devices/bus/vcs_ctrl/cx85.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:AJR
|
||||
/**********************************************************************
|
||||
|
||||
Atari CX85 Numeric Keypad
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "cx85.h"
|
||||
|
||||
#include "machine/rescap.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE TYPE DEFINITION
|
||||
//**************************************************************************
|
||||
|
||||
DEFINE_DEVICE_TYPE(ATARI_CX85, atari_cx85_device, "atari_cx85", "Atari CX85 Numeric Keypad")
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INPUT PORTS
|
||||
//**************************************************************************
|
||||
|
||||
static INPUT_PORTS_START(atari_cx85)
|
||||
PORT_START("X1")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad -") PORT_CODE(KEYCODE_PLUS_PAD)
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 3") PORT_CODE(KEYCODE_3_PAD)
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 9") PORT_CODE(KEYCODE_9_PAD)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 6") PORT_CODE(KEYCODE_6_PAD)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
|
||||
PORT_START("X2")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad + Enter") PORT_CODE(KEYCODE_ENTER_PAD)
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 2") PORT_CODE(KEYCODE_2_PAD)
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 8") PORT_CODE(KEYCODE_8_PAD)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 5") PORT_CODE(KEYCODE_5_PAD)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
|
||||
PORT_START("X3")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD)
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 1") PORT_CODE(KEYCODE_1_PAD)
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 7") PORT_CODE(KEYCODE_7_PAD)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 4") PORT_CODE(KEYCODE_4_PAD)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
|
||||
PORT_START("X4")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 0") PORT_CODE(KEYCODE_0_PAD)
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad F2 (Yes)") PORT_CODE(KEYCODE_SLASH_PAD)
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad F4 (No)") PORT_CODE(KEYCODE_MINUS_PAD)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad F3 (Del)") PORT_CODE(KEYCODE_ASTERISK)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad F1 (Escape)") PORT_CODE(KEYCODE_NUMLOCK)
|
||||
INPUT_PORTS_END
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// atari_cx85_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
atari_cx85_device::atari_cx85_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
|
||||
: device_t(mconfig, ATARI_CX85, tag, owner, clock)
|
||||
, device_vcs_control_port_interface(mconfig, *this)
|
||||
, m_encoder(*this, "encoder")
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_add_mconfig - add device configuration
|
||||
//-------------------------------------------------
|
||||
|
||||
void atari_cx85_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
MM74C923(config, m_encoder, 0); // MCM74C923N
|
||||
m_encoder->set_cap_osc(CAP_U(.1));
|
||||
m_encoder->set_cap_debounce(CAP_U(.47));
|
||||
m_encoder->data_tri_callback().set_constant(0);
|
||||
m_encoder->x1_rd_callback().set_ioport("X1");
|
||||
m_encoder->x2_rd_callback().set_ioport("X2");
|
||||
m_encoder->x3_rd_callback().set_ioport("X3");
|
||||
m_encoder->x4_rd_callback().set_ioport("X4");
|
||||
m_encoder->da_wr_callback().set(FUNC(atari_cx85_device::trigger_w)).invert();
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_input_ports - device-specific input ports
|
||||
//-------------------------------------------------
|
||||
|
||||
ioport_constructor atari_cx85_device::device_input_ports() const
|
||||
{
|
||||
return INPUT_PORTS_NAME(atari_cx85);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void atari_cx85_device::device_start()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// vcs_joy_r - read digital inputs
|
||||
//-------------------------------------------------
|
||||
|
||||
u8 atari_cx85_device::vcs_joy_r()
|
||||
{
|
||||
// 74C923 outputs are buffered through 4049B
|
||||
if (m_encoder->da_r())
|
||||
{
|
||||
u8 inputs = m_encoder->read();
|
||||
logerror("Inputs read: %d%d%d%d%d\n", BIT(inputs, 4), BIT(inputs, 3), BIT(inputs, 2), BIT(inputs, 1), BIT(inputs, 0));
|
||||
}
|
||||
return (~m_encoder->read() & 0x0f) | (m_encoder->da_r() ? 0 : 0x20);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// vcs_pot_x_r - sample B pot
|
||||
//-------------------------------------------------
|
||||
|
||||
u8 atari_cx85_device::vcs_pot_x_r()
|
||||
{
|
||||
return BIT(m_encoder->read(), 4) ? 0 : 0xff;
|
||||
}
|
54
src/devices/bus/vcs_ctrl/cx85.h
Normal file
54
src/devices/bus/vcs_ctrl/cx85.h
Normal file
@ -0,0 +1,54 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:AJR
|
||||
/**********************************************************************
|
||||
|
||||
Atari CX85 Numeric Keypad
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef MAME_BUS_VCS_CTRL_CX85_H
|
||||
#define MAME_BUS_VCS_CTRL_CX85_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ctrl.h"
|
||||
#include "machine/mm74c922.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
// ======================> atari_cx85_device
|
||||
|
||||
class atari_cx85_device : public device_t,
|
||||
public device_vcs_control_port_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
atari_cx85_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start() override;
|
||||
virtual void device_add_mconfig(machine_config &config) override;
|
||||
|
||||
// optional information overrides
|
||||
virtual ioport_constructor device_input_ports() const override;
|
||||
|
||||
// device_vcs_control_port_interface overrides
|
||||
virtual u8 vcs_joy_r() override;
|
||||
virtual u8 vcs_pot_x_r() override;
|
||||
|
||||
virtual bool has_pot_x() override { return true; }
|
||||
virtual bool has_pot_y() override { return false; } // pin 9 not used
|
||||
|
||||
private:
|
||||
required_device<mm74c923_device> m_encoder;
|
||||
};
|
||||
|
||||
|
||||
// device type declaration
|
||||
DECLARE_DEVICE_TYPE(ATARI_CX85, atari_cx85_device)
|
||||
|
||||
#endif // MAME_BUS_VCS_CTRL_CX85_H
|
Loading…
Reference in New Issue
Block a user