-
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
Changes from all commits
28a0d6d
9a8bd3e
7766500
b0f8387
f7eec6f
0d8f472
80eaa2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,7 +72,6 @@ void midvunit_state::machine_start() | |
| midvunit_base_state::machine_start(); | ||
|
|
||
| save_item(NAME(m_adc_shift)); | ||
| save_item(NAME(m_last_port0)); | ||
| save_item(NAME(m_shifter_state)); | ||
| save_item(NAME(m_galil_input_index)); | ||
| save_item(NAME(m_galil_input_length)); | ||
|
|
@@ -132,28 +131,29 @@ void midvplus_state::machine_reset() | |
| uint32_t midvunit_state::port0_r() | ||
| { | ||
| uint16_t val = m_in0->read(); | ||
| uint16_t diff = val ^ m_last_port0; | ||
|
|
||
| if (!machine().side_effects_disabled()) | ||
| { | ||
| // make sure the shift controls are mutually exclusive | ||
| 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 | ||
|
Comment on lines
-140
to
+148
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That was intentional, to make it playable with buttons. It isn’t intuitive, but it can be learned.
It won’t work with the original shifter that lacks a neutral switch.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's setup just like Daytona and Sega Rally. |
||
| } | ||
|
|
||
| // Bits 10–13 (0x3C00) represent gear state | ||
| val = (val | 0x3c00) ^ (m_shifter_state << 10); | ||
|
|
||
| return (val << 16) | val; | ||
| } | ||
|
|
||
|
|
||
| /************************************* | ||
| * | ||
| * ADC input ports | ||
|
|
@@ -742,15 +742,15 @@ static INPUT_PORTS_START( midvunit ) | |
| PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_START1 ) | ||
| PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_TILT ) // Slam Switch | ||
| PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Enter") PORT_CODE(KEYCODE_F2) // Test switch | ||
| PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNUSED ) | ||
| 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_BUTTON8 ) PORT_NAME("4th Gear") // 4th | ||
| PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("3rd Gear") // 3rd | ||
| PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("2nd Gear") // 2nd | ||
| PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("1st Gear") // 1st | ||
| 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 | ||
| PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_COIN4 ) | ||
| PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNUSED ) | ||
|
|
||
|
|
||
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
diffor the ternary operators actually makes the comment make more sense.