Skip to content

Commit

Permalink
Merge pull request #212 from vbousquet/generalized_pwm
Browse files Browse the repository at this point in the history
PWM: Fix (legacy) modulated solenoids for generation other than WPC
  • Loading branch information
toxieainc authored Feb 2, 2024
2 parents 38a0251 + 039876b commit 8f3c2e6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/wpc/vpintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,14 @@ int vp_getChangedLamps(vp_tChgLamps chgStat) {
int vp_getChangedSolenoids(vp_tChgSols chgStat)
{
int ii, idx = 0;
if (coreGlobals.nSolenoids && (
(options.usemodsol & CORE_MODOUT_ENABLE_PHYSOUT)
|| ((core_gameData->gen & GEN_ALLWPC) && (options.usemodsol & CORE_MODOUT_ENABLE_MODSOL)) ))
// The backward compatibility is not perfect here: mod sol was only available for a bunch of gnerations, and would limit modulation to the first 32 solenoids
if (coreGlobals.nSolenoids && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT | CORE_MODOUT_ENABLE_MODSOL)))
{
float state[CORE_MODOUT_SOL_MAX];
core_getAllPhysicSols(state);
for (ii = 0; ii < coreGlobals.nSolenoids; ii++) {
if ((options.usemodsol == CORE_MODOUT_ENABLE_MODSOL) && coreGlobals.physicOutputState[CORE_MODOUT_SOL0 + ii].type == CORE_MODOUT_BULB_44_6_3V_AC_REV)
state[ii] = 1.0f - state[ii];
UINT8 v = saturatedByte(state[ii]);
if (v != locals.lastPhysicsOutput[CORE_MODOUT_SOL0 + ii]) {
chgStat[idx].solNo = ii + 1;
Expand Down

0 comments on commit 8f3c2e6

Please sign in to comment.