Skip to content
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

Add support for switches which aren't part of the original switch matrix #7

Open
mkalkbrenner opened this issue Sep 3, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@mkalkbrenner
Copy link
Member

mkalkbrenner commented Sep 3, 2024

  • direct flipper buttons
  • coin door switches directly wired to the CPU
  • custom buttons

Those buttons should be treated like switch matrix buttons regarding the protocol so that all features like fastflips are supported without changes. libppuc should simply forward them like switch matrix buttons.

ppuc/pinmame must treat them differently. Some need to be send to the CPU others should be ignored.

We should follow the pattern of VPX. That's the mapping for Williams System 6:

'-------------------------
' S6 Data
'-------------------------
' Flipper Solenoid
Const GameOnSolenoid = 23
' Cabinet switches
Const swAdvance      = -7
Const swUpDown       = -6
Const swCPUDiag      = -5
Const swSoundDiag    = -4
Const swMasterEnter  = -3
Const swTilt         =  1
Const swBallRollTilt =  2
Const swStartButton  =  3
Const swCoin3        =  4
Const swCoin2        =  5
Const swCoin1        =  6
Const swSlamTilt     =  7
Const swHiScoreReset =  8
Const swLRFlip       = 82
Const swLLFlip       = 84
Const swURFlip       = 81
Const swULFlip       = 83

1-8 are part of the matrix, 81-84 are "virtual" (they directly power the flippers, no connection to the CPU).
The negative numbers are the switches directly wired to the CPU.

https://github.com/vpinball/vpinball/blob/a491317195b1f686eec7f30a23111d0e5c8a3c4b/scripts/s6.vbs#L17-L39

@mkalkbrenner mkalkbrenner added the enhancement New feature or request label Sep 3, 2024
@mkalkbrenner
Copy link
Member Author

SwitchState already supports negative numbers:
https://github.com/PPUC/libppuc/blob/ad4af67c58dd214e34a630b4503d1b751be50b38/src/PPUC.h#L31

libpinmame accepts these:
https://github.com/PPUC/ppuc/blob/50dee359261c5d4805e1436041348060759f7592/src/ppuc.cpp#L630

Our event IDs are uint8_t. So we need to define some custom IDs and convert them into negative numbers here:
https://github.com/PPUC/libppuc/blob/ad4af67c58dd214e34a630b4503d1b751be50b38/src/RS485Comm.cpp#L360

@mkalkbrenner
Copy link
Member Author

Let's map IDs above 240 to negative values:

241 => -1
242 => -2
...
247 => -7
...
254 => -14
255 is reserved.

Switch numbers between 200 and 240 could be custom switches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant