From fc15d7fe4c0cee95eb24c812f5449bc285170ec3 Mon Sep 17 00:00:00 2001 From: Barry Rodewald Date: Thu, 24 Dec 2020 23:31:02 +1300 Subject: [PATCH] amstrad: add support for the Cheetah 125 Special rotational joystick, supported in Victory Road. --- src/mame/drivers/amstrad.cpp | 48 +++++++++++++++++++++++++----------- src/mame/includes/amstrad.h | 2 ++ src/mame/machine/amstrad.cpp | 23 ++++++++++++++--- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/mame/drivers/amstrad.cpp b/src/mame/drivers/amstrad.cpp index 5d2700c011c..61a305dffb9 100644 --- a/src/mame/drivers/amstrad.cpp +++ b/src/mame/drivers/amstrad.cpp @@ -241,12 +241,12 @@ static INPUT_PORTS_START( amstrad_keyboard ) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') PORT_START("kbrow.9") - PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(1) PORT_8WAY - PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(1) PORT_8WAY - PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(1) PORT_8WAY - PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1) PORT_8WAY - PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1) - PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1) + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(1) PORT_8WAY PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(1) PORT_8WAY PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(1) PORT_8WAY PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1) PORT_8WAY PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1) PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1) PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) /* The bit for the third button is officially undocumented: Amstrad joysticks actually use only two buttons. The only device that reads this bit is the AMX mouse, which uses @@ -335,28 +335,41 @@ INPUT_PORTS_END static INPUT_PORTS_START( amx_mouse ) PORT_START("mouse_input1") - PORT_BIT(0xff , 0, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_PLAYER(1) PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) + PORT_BIT(0xff , 0, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_PLAYER(1) PORT_CONDITION("controller_type", 0x02, EQUALS, 0x02) PORT_START("mouse_input2") - PORT_BIT(0xff , 0, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_PLAYER(1) PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) + PORT_BIT(0xff , 0, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_PLAYER(1) PORT_CONDITION("controller_type", 0x02, EQUALS, 0x02) PORT_START("mouse_input3") - PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_NAME("Left mouse button") PORT_CODE(MOUSECODE_BUTTON1) PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) - PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_BUTTON5) PORT_NAME("Right mouse button") PORT_CODE(MOUSECODE_BUTTON2) PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) - PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_BUTTON6) PORT_NAME("Middle mouse button") PORT_CODE(MOUSECODE_BUTTON3) PORT_CONDITION("controller_type", 0x01, EQUALS, 0x01) + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_NAME("Left mouse button") PORT_CODE(MOUSECODE_BUTTON1) PORT_CONDITION("controller_type", 0x02, EQUALS, 0x02) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_BUTTON5) PORT_NAME("Right mouse button") PORT_CODE(MOUSECODE_BUTTON2) PORT_CONDITION("controller_type", 0x02, EQUALS, 0x02) + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_BUTTON6) PORT_NAME("Middle mouse button") PORT_CODE(MOUSECODE_BUTTON3) PORT_CONDITION("controller_type", 0x02, EQUALS, 0x02) PORT_START("controller_type") - PORT_CONFNAME( 0x03, 0x00, "Joystick port device" ) - PORT_CONFSETTING(0x00, "2-button Joystick" ) - PORT_CONFSETTING(0x01, "AMX mouse interface" ) - PORT_CONFSETTING(0x02, "Nothing" ) + PORT_CONFNAME( 0x07, 0x01, "Joystick port device" ) + PORT_CONFSETTING(0x00, "Nothing" ) + PORT_CONFSETTING(0x01, "2-button joystick" ) + PORT_CONFSETTING(0x02, "AMX mouse interface" ) + PORT_CONFSETTING(0x04, "Cheetah 125 Special rotational joystick" ) INPUT_PORTS_END +static INPUT_PORTS_START( cheetah_125_special ) + PORT_START("cheetah") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(1) PORT_8WAY PORT_NAME("Cheetah 125 Up") PORT_CONDITION("controller_type", 0x04, EQUALS, 0x04) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(1) PORT_8WAY PORT_NAME("Cheetah 125 Down") PORT_CONDITION("controller_type", 0x04, EQUALS, 0x04) + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(1) PORT_8WAY PORT_NAME("Cheetah 125 Left") PORT_CONDITION("controller_type", 0x04, EQUALS, 0x04) + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1) PORT_8WAY PORT_NAME("Cheetah 125 Right") PORT_CONDITION("controller_type", 0x04, EQUALS, 0x04) + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1) PORT_NAME("Cheetah 125 Fire") PORT_CONDITION("controller_type", 0x04, EQUALS, 0x04) + PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1) PORT_NAME("Cheetah 125 Rotate Left") PORT_CONDITION("controller_type", 0x04, EQUALS, 0x04) + PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(1) PORT_NAME("Cheetah 125 Rotate Right") PORT_CONDITION("controller_type", 0x04, EQUALS, 0x04) +INPUT_PORTS_END + static INPUT_PORTS_START( cpc464 ) PORT_INCLUDE(amstrad_keyboard) PORT_INCLUDE(crtc_links) PORT_INCLUDE(amx_mouse) + PORT_INCLUDE(cheetah_125_special) INPUT_PORTS_END @@ -383,6 +396,7 @@ static INPUT_PORTS_START( cpc664 ) PORT_INCLUDE(crtc_links) PORT_INCLUDE(amx_mouse) + PORT_INCLUDE(cheetah_125_special) INPUT_PORTS_END @@ -415,6 +429,7 @@ static INPUT_PORTS_START( cpc6128 ) PORT_INCLUDE(crtc_links) PORT_INCLUDE(amx_mouse) + PORT_INCLUDE(cheetah_125_special) INPUT_PORTS_END @@ -483,6 +498,7 @@ static INPUT_PORTS_START( cpc6128f ) PORT_INCLUDE(crtc_links) PORT_INCLUDE(amx_mouse) + PORT_INCLUDE(cheetah_125_special) INPUT_PORTS_END static INPUT_PORTS_START( cpc6128s ) @@ -554,6 +570,7 @@ static INPUT_PORTS_START( kccomp ) PORT_INCLUDE(crtc_links) PORT_INCLUDE(amx_mouse) + PORT_INCLUDE(cheetah_125_special) INPUT_PORTS_END @@ -743,6 +760,7 @@ static INPUT_PORTS_START( aleste ) PORT_INCLUDE(crtc_links) PORT_INCLUDE(amx_mouse) + PORT_INCLUDE(cheetah_125_special) INPUT_PORTS_END diff --git a/src/mame/includes/amstrad.h b/src/mame/includes/amstrad.h index e757031cf87..b69c5122fcb 100644 --- a/src/mame/includes/amstrad.h +++ b/src/mame/includes/amstrad.h @@ -152,6 +152,7 @@ public: m_io_mouse(*this,"mouse_input%u", 1U), m_io_solder_links(*this, "solder_links"), m_io_green_display(*this, "green_display"), + m_io_cheetah(*this, "cheetah"), m_io_ctrltype(*this,"controller_type"), m_screen(*this, "screen"), m_palette(*this, "palette") @@ -270,6 +271,7 @@ protected: optional_ioport_array<3> m_io_mouse; required_ioport m_io_solder_links; required_ioport m_io_green_display; + optional_ioport m_io_cheetah; optional_ioport m_io_ctrltype; required_device m_screen; required_device m_palette; diff --git a/src/mame/machine/amstrad.cpp b/src/mame/machine/amstrad.cpp index 13109d4da1f..7a6ba398b73 100644 --- a/src/mame/machine/amstrad.cpp +++ b/src/mame/machine/amstrad.cpp @@ -2698,13 +2698,28 @@ uint8_t amstrad_state::amstrad_psg_porta_read() { if(m_system_type != SYSTEM_GX4000) { - if (m_io_ctrltype.read_safe(0) == 1 && (m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F) == 9) + if (m_io_ctrltype.read_safe(0) == 0 && (m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F) == 9) + { + return (m_io_kbrow[m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F].read_safe(0) & 0x80) | 0x7f; + } + // AMX mouse + if (m_io_ctrltype.read_safe(0) == 2 && (m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F) == 9) { return m_amx_mouse_data; } - if (m_io_ctrltype.read_safe(0) == 2 && (m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F) == 9) + // Cheetah 125 Special rotational joystick + if (m_io_ctrltype.read_safe(0) == 4 && (m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F) == 9) { - return (m_io_kbrow[m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F].read_safe(0) & 0x80) | 0x7f; + return (m_io_kbrow[m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F].read_safe(0) & 0x80) | (m_io_cheetah->read() & 0x1f) | 0x60; + } + if (m_io_ctrltype.read_safe(0) == 4 && (m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F) == 6) + { + uint8_t p = (m_io_kbrow[m_ppi_port_outputs[amstrad_ppi_PortC] & 0x0F].read_safe(0)); + if(!(m_io_cheetah->read() & 0x20)) + p &= ~0x04; + if(!(m_io_cheetah->read() & 0x40)) + p &= ~0x08; + return p; } } @@ -2743,7 +2758,7 @@ IRQ_CALLBACK_MEMBER(amstrad_state::amstrad_cpu_acknowledge_int) if(m_system_type != SYSTEM_GX4000) { // update AMX mouse inputs (normally done every 1/300th of a second) - if (m_io_ctrltype.read_safe(0) == 1) + if (m_io_ctrltype.read_safe(0) == 2) { static uint8_t prev_x,prev_y; uint8_t data_x, data_y;