Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nimbus joystick fix #11857

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Nimbus joystick fix #11857

merged 2 commits into from
Dec 20, 2023

Conversation

RobinSergeant
Copy link
Contributor

This pull request fixes RM Nimbus joystick emulation by using the correct port address for directional data and setting the correct bits when that address is read. Currently the mouse data port (0xa4) is used for all joystick data, but only the buttons are actually read from this port. The joystick port (0xa0) is used for the directional data as described in chapter 2 of of the service manual (https://www.thenimbus.co.uk/upgrades-and-maintenance/service-manual).

This can be demonstrated/tested by running the following RM Basic program which does not work without my change:

10 SET MODE 40
20 SET JOYSTICK
30 REPEAT
40   ASK JOYSTICK X%, Y%, Button%
50   POINTS X%, Y%
60 UNTIL Button% = 1

I have also removed the "Input Port 0 Device" config port as this is no longer necessary and prevented the mouse buttons from working properly when set to the wrong value (the original code read joystick data when this was to "mouse", and mouse data when it was set to "joystick"). The mouse and joystick can now co-exist quite happily with joystick buttons doubling as mouse buttons and vice versa.

The wrong bits were also being set for each direction and I have of course corrected these to match those given in the service manual. The above RM Basic program proves that theses are now correct.

The original machine also allowed switching between two joysticks by writing to ports 0xa0 (to select joystick 0) and 0xa2 (to select joystick 1), but I have not implemented this as it seems unnecessary - I have not found any software that makes use of it and I don't think it's possible to test using RM Basic.

Please let me know if you have any questions!

Comment on lines +1082 to +1092
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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a very odd design decision, and at first glance it would seem to require more logic than just mapping one direction to each bit. Do you know why it has this quirk of always setting the left bit for horizontal directions and always setting the down bit for vertical directions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing it's related to the physical hardware design, but it's actually stated in the service manual. They have a table saying something like "right = left + right" :-) Maybe it's really a bit to say the X axis is effected and then a bit for positive/negative.

It threw me at first because without setting the extra bits only left and down worked. Then I noticed the cryptic table in the service manual.

All 8 directions work with my RM basic test app so fairly confident it's correct now!

@cuavas cuavas merged commit 27aa4f6 into mamedev:master Dec 20, 2023
@RobinSergeant RobinSergeant deleted the nimbus_joystick_fix branch January 2, 2024 14:28
einstein95 pushed a commit to einstein95/mame that referenced this pull request Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants