diff --git a/src/win32com/Controller.cpp b/src/win32com/Controller.cpp index e30ea3f59..153b391f7 100644 --- a/src/win32com/Controller.cpp +++ b/src/win32com/Controller.cpp @@ -402,8 +402,7 @@ STDMETHODIMP CController::get_Lamp(int nLamp, VARIANT_BOOL *pVal) if (WaitForSingleObject(m_hEmuIsRunning, 0) == WAIT_TIMEOUT) *pVal= false; else { - if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_LAMPS)) - core_update_pwm_outputs(CORE_MODOUT_LAMP0 + nLamp - 1, 1); + core_update_pwm_lamps(); *pVal = vp_getLamp(nLamp)?VARIANT_TRUE:VARIANT_FALSE; } @@ -420,8 +419,7 @@ STDMETHODIMP CController::get_Solenoid(int nSolenoid, VARIANT_BOOL *pVal) if (WaitForSingleObject(m_hEmuIsRunning, 0) == WAIT_TIMEOUT) *pVal= false; else { - if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_SOLENOIDS | CORE_MODOUT_ENABLE_MODSOL)) - core_update_pwm_outputs(CORE_MODOUT_SOL0 + nSolenoid - 1, 1); + core_update_pwm_solenoids(); *pVal = vp_getSolenoid(nSolenoid)?VARIANT_TRUE:VARIANT_FALSE; } return S_OK; @@ -1459,8 +1457,7 @@ STDMETHODIMP CController::get_GIString(int nString, int *pVal) { if (WaitForSingleObject(m_hEmuIsRunning, 0) == WAIT_TIMEOUT) *pVal = 0; else { - if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_GI)) - core_update_pwm_outputs(CORE_MODOUT_GI0 + nString - 1, 1); + core_update_pwm_gis(); *pVal = vp_getGI(nString); } diff --git a/src/wpc/capcom.c b/src/wpc/capcom.c index 1b953e5c9..798f2cabc 100644 --- a/src/wpc/capcom.c +++ b/src/wpc/capcom.c @@ -141,24 +141,6 @@ static NVRAM_HANDLER(cc); static void Skip_Error_Msg(void); static INTERRUPT_GEN(cc_vblank) { - /*------------------------------- - / copy local data to interface - /--------------------------------*/ - // TODO Why do we delay lamps/solenoids until VBLANK ? this creates artificial latency, direct set/callback would be better at least for solenoids - - /*-- lamps --*/ - memset(coreGlobals.lampMatrix, 0, sizeof(coreGlobals.lampMatrix)); - for (int i = 0; i < 8 + core_gameData->hw.lampCol; i++) - for (int j = 0; j < 8; j++) - if (coreGlobals.physicOutputState[CORE_MODOUT_LAMP0 + i * 8 + j].value >= 0.1f) - coreGlobals.lampMatrix[i] |= 1 << j; - - /*-- solenoids --*/ - coreGlobals.solenoids = 0; - for (int i = 0; i < 32; i++) - if (coreGlobals.physicOutputState[CORE_MODOUT_SOL0 + i].value >= 0.5f) - coreGlobals.solenoids |= 1 << i; - /*-- update leds (they are PWM faded, so uses physic output) --*/ coreGlobals.diagnosticLed = (coreGlobals.physicOutputState[CORE_MODOUT_LAMP0 + 8 * 8 + (core_gameData->hw.lampCol - 1) * 8 ].value >= 0.5f ? 1 : 0) | (coreGlobals.physicOutputState[CORE_MODOUT_LAMP0 + 8 * 8 + (core_gameData->hw.lampCol - 1) * 8 + 1].value >= 0.5f ? 2 : 0); diff --git a/src/wpc/core.c b/src/wpc/core.c index 9a0aa9e74..46d808408 100644 --- a/src/wpc/core.c +++ b/src/wpc/core.c @@ -2817,6 +2817,29 @@ void core_update_pwm_outputs(const int startIndex, const int count) // Perform integration of stable state up to now output->integrator(now, index, FALSE, output->lastIntegrationFlipPos & 1); } + // Also update non PWM data structure if needed + if (options.usemodsol & CORE_MODOUT_FORCE_ON) + { + if (((options.usemodsol & CORE_MODOUT_ENABLE_PHYSOUT_LAMPS) == 0) && (startIndex < CORE_MODOUT_LAMP0 + CORE_MODOUT_LAMP_MAX) && (startIndex + count >= CORE_MODOUT_LAMP0)) + { + for (int i = 0; i < 8 + core_gameData->hw.lampCol; i++) + { + UINT8 col = 0; + for (int j = 0; j < 8; j++) + if (coreGlobals.physicOutputState[CORE_MODOUT_LAMP0 + i * 8 + j].value >= 0.1f) + col |= 1 << j; + coreGlobals.lampMatrix[i] = col; + } + } + if (((options.usemodsol & (CORE_MODOUT_ENABLE_MODSOL | CORE_MODOUT_ENABLE_PHYSOUT_SOLENOIDS)) == 0) && (startIndex < CORE_MODOUT_SOL0 + CORE_MODOUT_SOL_MAX) && (startIndex + count >= CORE_MODOUT_SOL0)) + { + UINT32 sols = 0; + for (int i = 0; i < 32; i++) + if (coreGlobals.physicOutputState[CORE_MODOUT_SOL0 + i].value >= 0.5f) + sols |= 1 << i; + coreGlobals.solenoids = sols; + } + } } // Write binary state of outputs, taking care of PWM integration based on physical model of the connected device diff --git a/src/wpc/sam.c b/src/wpc/sam.c index 6f0878411..ff333033d 100644 --- a/src/wpc/sam.c +++ b/src/wpc/sam.c @@ -1453,10 +1453,6 @@ static MACHINE_INIT(sam) { for (int i = 0; i < coreGlobals.nSolenoids; i++) if (coreGlobals.physicOutputState[i].type != CORE_MODOUT_SOL_2_STATE) core_set_pwm_output_type(CORE_MODOUT_SOL0, 1, CORE_MODOUT_LEGACY_SOL_2_STATE); - if ((options.usemodsol & CORE_MODOUT_ENABLE_PHYSOUT_LAMPS) == 0) - core_set_pwm_output_type(CORE_MODOUT_LAMP0, 80 /*coreGlobals.nLamps*/, CORE_MODOUT_LEGACY_SOL_2_STATE); - if ((options.usemodsol & CORE_MODOUT_ENABLE_PHYSOUT_GI) == 0) - core_set_pwm_output_type(CORE_MODOUT_GI0, coreGlobals.nGI, CORE_MODOUT_LEGACY_SOL_2_STATE); } void sam_init(void) @@ -2104,25 +2100,12 @@ static INTERRUPT_GEN(sam_interface_update) { /--------------------------------*/ samlocals.vblankCount++; - /*-- lamps --*/ - memset(coreGlobals.lampMatrix, 0, sizeof(coreGlobals.lampMatrix)); - for (int i = 0; i < 8 + core_gameData->hw.lampCol; i++) - for (int j = 0; j < 8; j++) - if (coreGlobals.physicOutputState[CORE_MODOUT_LAMP0 + i * 8 + j].value >= 0.25f) - coreGlobals.lampMatrix[i] |= 1 << j; - /*-- display --*/ if ((samlocals.vblankCount % SAM_DISPLAYSMOOTH) == 0) { coreGlobals.diagnosticLed = samlocals.diagnosticLed; samlocals.diagnosticLed = 0; } - /*-- solenoids --*/ - coreGlobals.solenoids = 0; - for (int i = 0; i < 32; i++) - if (coreGlobals.physicOutputState[CORE_MODOUT_SOL0 + i].value >= 0.5f) - coreGlobals.solenoids |= 1 << i; - /*-- GameOn for Fast Flips --*/ if (samlocals.fastflipaddr > 0 && cpu_readmem32ledw(samlocals.fastflipaddr) == 0x01) {