Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/mame/midway/midvunit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
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.

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
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.

}

// Bits 10–13 (0x3C00) represent gear state
val = (val | 0x3c00) ^ (m_shifter_state << 10);

return (val << 16) | val;
}


/*************************************
*
* ADC input ports
Expand Down Expand Up @@ -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 )

Expand Down
1 change: 0 additions & 1 deletion src/mame/midway/midvunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ class midvunit_state : public midvunit_base_state
required_ioport m_dsw;

uint8_t m_adc_shift = 0;
uint16_t m_last_port0 = 0;
uint8_t m_shifter_state = 0;
uint8_t m_galil_input_index = 0;
uint8_t m_galil_input_length = 0;
Expand Down