VisualPinball / VisualPinball.Engine.PinMAME

PinMAME support for VPE
MIT License
2 stars 1 forks source link

gle: added solenoid startup delay and mech disable settings #13

Closed jsm174 closed 3 years ago

jsm174 commented 3 years ago

The PR adds the following options to the PinMAME game logic engine:

Disable mechs will set all pinmame mechs to null, basically disabling any built in mech, such as the gun motor on T2.

Note, there is no getMaxMechs exposed by Pinmame-dotnet, so currently we have it hardcoded to 10. The next time I update pinmame-dotnet, I will add this.

The Solenoid startup delay will disable any OnSolenoid messages from being delivered until the delay has passed. We have noticed that System 80 games, the outhole coil is fired for a 65ms within the first 200ms after pinmame starts. This is causing the ball to automatically be in the shooter lane on startup.

A couple things about this approach:

freezy commented 3 years ago

Two questions:

jsm174 commented 3 years ago
  • Wasn't there a global flag in PinMAME to disable any mech simulation?

Not exactly.. Let me try to explain g_fHandleMechanics with psuedo code.

if VPINMAME
   if g_fHandleMechanics
      update mechs 0 - 4
      update simulation
   else
      update mechs 5 - 9
      do not update simulation 

if NOT VPINMAME
   update mechs 0 - 4
   if g_fHandleMechanics
      update simulation

From the VPinball side, any calls to vp_setMechData use a 1 index, but internally sets mechs 5 - 9

vp_setMechData(1, ...) sets mech 5 vp_setMechData(2, ...) sets mech 6

From the VPinball side, and calls to vp_getMechData use a 1 index, but internally gets mechs 5 - 9

vp_getMechData(-1) gets the speed for mech 5 vp_getMechData(-2) gets the speed for mech 6 vp_getMechData(1) gets the position for mech 5 vp_getMechData(2) gets the position for mech 6

Should I make libpinmame work like vpinmame?

freezy commented 3 years ago

Oh okay. So by "update simulation" you mean trigger switches within PinMAME directly, right? So in any case we'll get mech events (which in the cannon case is the rotation step?).

I don't know the difference between updating mechs 0-4 versus 5-9, so I can't answer your question. What are the pros & contras?

jsm174 commented 3 years ago

Oh okay. So by "update simulation" you mean trigger switches within PinMAME directly, right? So in any case we'll get mech events (which in the cannon case is the rotation step?).

Not exactly. Crazy I know.. Stick with me:

Update simulation is like when you run pinmame standalone and it pretends to have a ball, working trough, etc.

Lets take T2:

if NOT VPINMAME
   update mechs 0 - 4
   if g_fHandleMechanics
      update simulation

1) update mech 0 will calculate the speed and position of gun motor if solenoid is active, and set gun home and gun mark switches based on position

2) if g_fHandleMechanics, update simulation by calling t2_handleMech().

Finally, lets take vpinmame / vpinball and go through g5k_002:

if VPINMAME
   if g_fHandleMechanics
      update mechs 0 - 4
      update simulation
   else
      update mechs 5 - 9
      do not update simulation 

1) update mech 5 will calculate the speed and position of gun motor if solenoid is active, and set gun home and gun mark switches based on position 2) g_fHandleMechanics is 0, so no simulation called, no other switches are effected

jsm174 commented 3 years ago

I think the best course of action, to reduce confusion, is to just make it work like vpinmame.

jsm174 commented 3 years ago

libpinmame and pinmame-dot were updated to support the above discussion.

built in mechs are now disabled when g_fHandleMechanics is 0.

I found and instance where Bride of Pinbot uses different int values with g_fHandleMechanics, so I switched it from bool to int.