From 27aa4f64093d8279de68ff94cbf6bc1e2d4557e0 Mon Sep 17 00:00:00 2001 From: Robin Sergeant Date: Wed, 20 Dec 2023 16:28:40 +0000 Subject: rm/rmnimbus.cpp: Fixed joystick input. (#11857) --- src/mame/rm/rmnimbus.cpp | 18 ++++++--------- src/mame/rm/rmnimbus.h | 3 +-- src/mame/rm/rmnimbus_m.cpp | 57 ++++++++++++++++++++++++++++------------------ 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/mame/rm/rmnimbus.cpp b/src/mame/rm/rmnimbus.cpp index 33c9073f55d..6b95e3ab962 100644 --- a/src/mame/rm/rmnimbus.cpp +++ b/src/mame/rm/rmnimbus.cpp @@ -54,6 +54,7 @@ void rmnimbus_state::nimbus_io(address_map &map) map(0x0000, 0x0031).rw(FUNC(rmnimbus_state::nimbus_video_io_r), FUNC(rmnimbus_state::nimbus_video_io_w)); map(0x0080, 0x0080).rw(FUNC(rmnimbus_state::nimbus_mcu_r), FUNC(rmnimbus_state::nimbus_mcu_w)); map(0x0092, 0x0092).rw(FUNC(rmnimbus_state::nimbus_iou_r), FUNC(rmnimbus_state::nimbus_iou_w)); + map(0x00a0, 0x00a0).r(FUNC(rmnimbus_state::nimbus_joystick_r)); map(0x00a4, 0x00a4).rw(FUNC(rmnimbus_state::nimbus_mouse_js_r), FUNC(rmnimbus_state::nimbus_mouse_js_w)); map(0x00c0, 0x00cf).rw(FUNC(rmnimbus_state::nimbus_pc8031_r), FUNC(rmnimbus_state::nimbus_pc8031_w)).umask16(0x00ff); map(0x00e0, 0x00ef).rw(AY8910_TAG, FUNC(ay8910_device::data_r), FUNC(ay8910_device::address_data_w)).umask16(0x00ff); @@ -66,18 +67,13 @@ void rmnimbus_state::nimbus_io(address_map &map) static INPUT_PORTS_START( nimbus ) - PORT_START("config") - PORT_CONFNAME( 0x01, 0x00, "Input Port 0 Device") - PORT_CONFSETTING( 0x00, "Mouse" ) - PORT_CONFSETTING( 0x01, DEF_STR( Joystick ) ) - PORT_START(JOYSTICK0_TAG) - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_8WAY // XB - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_8WAY // XA - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_8WAY // YA - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_8WAY // YB - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_8WAY + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_8WAY + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_8WAY + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_8WAY + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_START(MOUSE_BUTTON_TAG) /* Mouse buttons */ PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Mouse Button 2") PORT_CODE(MOUSECODE_BUTTON2) diff --git a/src/mame/rm/rmnimbus.h b/src/mame/rm/rmnimbus.h index 531683e4412..f311ad20f26 100644 --- a/src/mame/rm/rmnimbus.h +++ b/src/mame/rm/rmnimbus.h @@ -75,7 +75,6 @@ public: m_fdc(*this, FDC_TAG), m_z80sio(*this, Z80SIO_TAG), m_screen(*this, "screen"), - m_io_config(*this, "config"), m_io_joystick0(*this, JOYSTICK0_TAG), m_io_mouse_button(*this, MOUSE_BUTTON_TAG), m_io_mousex(*this, MOUSEX_TAG), @@ -103,7 +102,6 @@ private: required_device m_fdc; required_device m_z80sio; required_device m_screen; - required_ioport m_io_config; required_ioport m_io_joystick0; required_ioport m_io_mouse_button; required_ioport m_io_mousex; @@ -150,6 +148,7 @@ private: void nimbus_rompack_w(offs_t offset, uint8_t data); void nimbus_sound_ay8910_porta_w(uint8_t data); void nimbus_sound_ay8910_portb_w(uint8_t data); + uint8_t nimbus_joystick_r(); uint8_t nimbus_mouse_js_r(); void nimbus_mouse_js_w(uint8_t data); uint16_t nimbus_video_io_r(offs_t offset, uint16_t mem_mask = ~0); diff --git a/src/mame/rm/rmnimbus_m.cpp b/src/mame/rm/rmnimbus_m.cpp index 203da2724d6..34a2e1a9a65 100644 --- a/src/mame/rm/rmnimbus_m.cpp +++ b/src/mame/rm/rmnimbus_m.cpp @@ -118,13 +118,13 @@ chdman createhd -o ST125N.chd -chs 41921,1,1 -ss 512 #define MOUSE_INT_ENABLE 0x08 #define PC8031_INT_ENABLE 0x10 -#define MOUSE_NONE 0x00 -#define MOUSE_LEFT 0x01 -#define MOUSE_RIGHT 0x02 -#define MOUSE_DOWN 0x04 -#define MOUSE_UP 0x08 -#define MOUSE_LBUTTON 0x10 -#define MOUSE_RBUTTON 0x20 +#define CONTROLLER_NONE 0x00 +#define CONTROLLER_LEFT 0x01 +#define CONTROLLER_RIGHT 0x02 +#define CONTROLLER_DOWN 0x04 +#define CONTROLLER_UP 0x08 +#define CONTROLLER_BUTTON0 0x10 +#define CONTROLLER_BUTTON1 0x20 // Frequency in Hz to poll for mouse movement. #define MOUSE_POLL_FREQUENCY 500 @@ -990,9 +990,6 @@ TIMER_CALLBACK_MEMBER(rmnimbus_state::do_mouse) uint8_t mya; uint8_t myb; - // Read mouse buttons - m_nimbus_mouse.m_reg0a4 = m_io_mouse_button->read(); - // Read mose positions and calculate difference from previous value mouse_x = m_io_mousex->read(); mouse_y = m_io_mousey->read(); @@ -1075,6 +1072,28 @@ void rmnimbus_state::mouse_js_reset() m_nimbus_mouse.m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(MOUSE_POLL_FREQUENCY)); } +uint8_t rmnimbus_state::nimbus_joystick_r() +{ + /* Only the joystick drection data is read from this port + (which corresponds to the the low nibble of m_io_joystick0). + The joystick buttons are read from the mouse data port instead. */ + uint8_t result = m_io_joystick0->read() & 0x0f; + + if (result & CONTROLLER_RIGHT) + { + // when the stick is pushed right the left bit must also be set! + result |= CONTROLLER_LEFT; + } + + if (result & CONTROLLER_UP) + { + // when the stick is pushed up the down bit must also be set! + result |= CONTROLLER_DOWN; + } + + return result; +} + uint8_t rmnimbus_state::nimbus_mouse_js_r() { /* @@ -1091,18 +1110,12 @@ uint8_t rmnimbus_state::nimbus_mouse_js_r() 7 ?? always reads 1 */ - uint8_t result; - //int pc=m_maincpu->_pc(); - - if (m_io_config->read() & 0x01) - { - result=m_nimbus_mouse.m_reg0a4 | 0xC0; - //logerror("mouse_js_r: pc=%05X, result=%02X\n",pc,result); - } - else - { - result = m_io_joystick0->read() | 0xC0; - } + uint8_t result = m_nimbus_mouse.m_reg0a4 | 0xc0; + + // set button bits if either mouse or joystick buttons are pressed + result |= m_io_mouse_button->read(); + // NB only the two button bits of the joystick are read from this port + result |= m_io_joystick0->read() & 0x30; return result; } -- cgit v1.2.3