Skip to content

Commit

Permalink
Merge pull request #258 from vbousquet/generalized_pwm
Browse files Browse the repository at this point in the history
PWM: Fix internal flag being used for data exchange
  • Loading branch information
toxieainc committed Mar 18, 2024
2 parents 9440f77 + e0b6c89 commit 48792e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/wpc/core.h
Expand Up @@ -364,13 +364,13 @@ extern void video_update_core_dmd(struct mame_bitmap *bitmap, const struct recta

/*-- Physical devices on binary outputs --*/

#define CORE_MODOUT_ENABLE_MODSOL 1 /* Bitmask for options.usemodsol to enable legacy behavior (simple solenoid linear integration for WPC/SAM) */
#define CORE_MODOUT_ENABLE_PHYSOUT_LAMPS 0x04
#define CORE_MODOUT_ENABLE_PHYSOUT_GI 0x08
#define CORE_MODOUT_ENABLE_MODSOL 0x01 /* Bitmask for options.usemodsol to enable legacy behavior (simple solenoid linear integration for WPC/SAM) */
#define CORE_MODOUT_ENABLE_PHYSOUT_LAMPS 0x04
#define CORE_MODOUT_ENABLE_PHYSOUT_GI 0x08
#define CORE_MODOUT_ENABLE_PHYSOUT_SOLENOIDS 0x10
#define CORE_MODOUT_ENABLE_PHYSOUT_ALPHASEGS 0x20
#define CORE_MODOUT_FORCE_ON 0x80 /* Bitmask for options.usemodsol for drivers that needs PWM integration to be performed whatever the user settings are. Note that this is internal to the driver. The exchanged value depends only on the user settings. */
#define CORE_MODOUT_ENABLE_PHYSOUT_ALL (CORE_MODOUT_ENABLE_PHYSOUT_LAMPS|CORE_MODOUT_ENABLE_PHYSOUT_GI|CORE_MODOUT_ENABLE_PHYSOUT_SOLENOIDS|CORE_MODOUT_ENABLE_PHYSOUT_ALPHASEGS) /* Bitmask for options.usemodsol to enable physics output for solenoids/Lamp/GI/AlphaSegments */
#define CORE_MODOUT_FORCE_ON 0x80 /* Bitmask for options.usemodsol for drivers that needs PWM integration to be performed whatever the user settings are */

#define CORE_MODOUT_LAMP_MAX (CORE_MAXLAMPCOL * 8) /* Maximum number of modulated outputs for lamps */
#define CORE_MODOUT_SOL_MAX 72 /* Maximum number of modulated outputs for solenoids */
Expand Down
10 changes: 5 additions & 5 deletions src/wpc/vpintf.c
Expand Up @@ -33,7 +33,7 @@ void vp_init(void) {
int vp_getLamp(int lampNo) {
if (coreData->lamp2m) lampNo = coreData->lamp2m(lampNo) - 8;
/*-- Physical output mode: return a physically meaningful value depending on the output type --*/
if (coreGlobals.nLamps && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT_LAMPS | CORE_MODOUT_FORCE_ON)))
if (coreGlobals.nLamps && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT_LAMPS)))
return (int)saturatedByte(coreGlobals.physicOutputState[CORE_MODOUT_LAMP0 + lampNo].value);
return (coreGlobals.lampMatrix[lampNo/8]>>(lampNo%8)) & 0x01;
}
Expand All @@ -53,7 +53,7 @@ int vp_getSolenoid(int solNo)
int vp_getGI(int giNo)
{
/*-- Physical output mode: return a physically meaningful value depending on the output type --*/
if (coreGlobals.nGI && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT_GI | CORE_MODOUT_FORCE_ON)))
if (coreGlobals.nGI && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT_GI)))
return (int)saturatedByte(coreGlobals.physicOutputState[CORE_MODOUT_GI0 + giNo].value);
return coreGlobals.gi[giNo];
}
Expand All @@ -65,7 +65,7 @@ int vp_getGI(int giNo)
int vp_getChangedLamps(vp_tChgLamps chgStat) {
int ii, idx = 0;
/*-- fill in array --*/
if (coreGlobals.nLamps && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT_LAMPS | CORE_MODOUT_FORCE_ON)))
if (coreGlobals.nLamps && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT_LAMPS)))
{
for (ii = 0; ii < coreGlobals.nLamps; ii++) {
UINT8 val = saturatedByte(coreGlobals.physicOutputState[CORE_MODOUT_LAMP0 + ii].value);
Expand Down Expand Up @@ -130,7 +130,7 @@ int vp_getChangedSolenoids(vp_tChgSols chgStat)
{
int ii, idx = 0;
// The backward compatibility is not perfect here: mod sol was only available for a bunch of generations, and would limit modulation to the first 32 solenoids
if (coreGlobals.nSolenoids && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT_SOLENOIDS | CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_MODSOL)))
if (coreGlobals.nSolenoids && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT_SOLENOIDS | CORE_MODOUT_ENABLE_MODSOL)))
{
float state[CORE_MODOUT_SOL_MAX];
core_getAllPhysicSols(state);
Expand Down Expand Up @@ -170,7 +170,7 @@ int vp_getChangedSolenoids(vp_tChgSols chgStat)
/-------------------------------------*/
int vp_getChangedGI(vp_tChgGIs chgStat) {
/*-- Physical output mode: return a physically meaningful value depending on the output type --*/
if (coreGlobals.nGI && (options.usemodsol & (CORE_MODOUT_ENABLE_PHYSOUT_GI | CORE_MODOUT_FORCE_ON)))
if (coreGlobals.nGI && (options.usemodsol & CORE_MODOUT_ENABLE_PHYSOUT_GI))
{
int idx = 0;
for (int i = 0; i < coreGlobals.nGI; i++) {
Expand Down

0 comments on commit 48792e0

Please sign in to comment.