Skip to content

Conversation

@Endprodukt
Copy link

@Endprodukt Endprodukt commented Nov 4, 2025

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.

@Endprodukt Endprodukt changed the title Shifter fix midway/midvunit - shifter fix Nov 4, 2025
@Endprodukt Endprodukt changed the title midway/midvunit - shifter fix midway/midvunit.cpp: shifter fix, dedicated neutral Nov 4, 2025
Copy link
Contributor

@MooglyGuy MooglyGuy left a 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.

{
m_shifter_state = 8; // Gear 4
}

Copy link
Contributor

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.

m_shifter_state = 8; // Gear 4
}

m_last_port0 = val;
Copy link
Contributor

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.

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")
Copy link
Contributor

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.

Copy link
Author

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

Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

@cuavas cuavas left a 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?

Comment on lines -140 to +148
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
Copy link
Member

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.

Copy link
Author

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)

Copy link
Author

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.

Copy link
Author

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.

Copy link
Member

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.

Copy link
Author

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.

@cuavas
Copy link
Member

cuavas commented Nov 5, 2025

I did it myself, it’s simpler: 6523b65

@cuavas cuavas closed this Nov 5, 2025
@Endprodukt Endprodukt deleted the shifter-fix branch November 5, 2025 23:31
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.

4 participants