-
Notifications
You must be signed in to change notification settings - Fork 2.2k
midway/midvunit.cpp: shifter fix, dedicated neutral #14480
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor points to address.
src/mame/midway/midvunit.cpp
Outdated
| { | ||
| m_shifter_state = 8; // Gear 4 | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please omit the braces so that the new code better-resembles the old code.
src/mame/midway/midvunit.cpp
Outdated
| m_shifter_state = 8; // Gear 4 | ||
| } | ||
|
|
||
| m_last_port0 = val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the removal of diff, m_last_port0 is now entirely unused in the driver other than this assignment here. Depending on the compiler, this may pop an "assigned but never used" warning, so please remove the member entirely.
src/mame/midway/midvunit.cpp
Outdated
| PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("3rd Gear") // 3rd | ||
| PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("2nd Gear") // 2nd | ||
| PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("1st Gear") // 1st | ||
| PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON5) PORT_NAME("Neutral Gear") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Project preference is to keep ports in bit-order, so please don't move bit 0x0020 to be after bit 0x2000.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I bring them in order the neutral gear will pop up unconnected to the gears in the menu, no?
PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Neutral Gear")
PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN3 )
PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_VOLUME_DOWN )
PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_VOLUME_UP )
PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_NAME("4th Gear") // 4th
PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("3rd Gear") // 3rd
PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("2nd Gear") // 2nd
PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("1st Gear") // 1st
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to mess stuff up because the system will actually be reading the fake neutral button in bit five of the coin/start/service port.
|
|
||
| if (!machine().side_effects_disabled()) | ||
| { | ||
| // make sure the shift controls are mutually exclusive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could keep this comment? It clarifies why the implementation is making an exception for the gearbox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, and the new implementation without the need for diff or the ternary operators actually makes the comment make more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t particularly like the current code, but if your changing it, can you at least add the option of directly mapped shifter inputs with a machine configuration switch, so people with a real shifter setup can use it?
| if ((diff & 0x0400) && !(val & 0x0400)) | ||
| m_shifter_state = (m_shifter_state == 1) ? 0 : 1; | ||
| if ((diff & 0x0800) && !(val & 0x0800)) | ||
| m_shifter_state = (m_shifter_state == 2) ? 0 : 2; | ||
| if ((diff & 0x1000) && !(val & 0x1000)) | ||
| m_shifter_state = (m_shifter_state == 4) ? 0 : 4; | ||
| if ((diff & 0x2000) && !(val & 0x2000)) | ||
| m_shifter_state = (m_shifter_state == 8) ? 0 : 8; | ||
| m_last_port0 = val; | ||
| // neutral has priority | ||
| if (!(val & 0x0020)) | ||
| m_shifter_state = 0; // Neutral | ||
| else if (!(val & 0x0400)) | ||
| m_shifter_state = 1; // Gear 1 | ||
| else if (!(val & 0x0800)) | ||
| m_shifter_state = 2; // Gear 2 | ||
| else if (!(val & 0x1000)) | ||
| m_shifter_state = 4; // Gear 3 | ||
| else if (!(val & 0x2000)) | ||
| m_shifter_state = 8; // Gear 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good reason for not preserving detecting buttons being pressed? Previously, if you pressed a gear button before releasing the previous gear, button it would shift immediately. This change makes it only downshift immediately on pressing a button. It makes more sense for the behaviour to be the same irrespective of the gears involved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was wrong before. the gear would shift to neutral on double press (same gear twice)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also I changed the code to use with a real shifter. that was my motivation to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has been tested with a shifter and keyboard. works just fine and as I would expect.
btw I kindly as you to understand that this is my very first commit and I literally started working with visual studio yesterday. So please excuse mistakes. I did test before the pull request and it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was wrong before. the gear would shift to neutral on double press (same gear twice)
That was intentional, to make it playable with buttons. It isn’t intuitive, but it can be learned.
also I changed the code to use with a real shifter. that was my motivation to begin with.
It won’t work with the original shifter that lacks a neutral switch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's setup just like Daytona and Sega Rally.
|
I did it myself, it’s simpler: 6523b65 |
This change adds a dedicated Neutral Gear input to the Midway V Unit driver.
Added “Neutral Gear” input definition to IN0 (bit 0x0020).
Updated gear handling logic in port0_r() to properly interpret the neutral input.
This works similar to the neutral gear in model 2.