diff --git a/src/wpc/core.c b/src/wpc/core.c index 5e82360d7..e8d32cb82 100644 --- a/src/wpc/core.c +++ b/src/wpc/core.c @@ -2626,7 +2626,7 @@ void core_update_pwm_outputs(const int startIndex, const int count) // Write binary state of outputs, taking care of PWM integration based on physical model of the connected device void core_write_pwm_output(int index, int count, UINT8 bitStates) { - const float now = (float) timer_get_time(); + const double now = timer_get_time(); core_tPhysicOutput* output = &coreGlobals.physicOutputState[index]; for (int i = 0; i < count; i++, bitStates = bitStates >> 1, index++, output++) { const int pos = index >> 3, ofs = index & 7; @@ -2645,7 +2645,7 @@ void core_write_pwm_output_8b(int index, UINT8 bitStates) UINT8 changeMask = coreGlobals.binaryOutputState[index >> 3] ^ bitStates; if (!changeMask) return; - const float now = (float) timer_get_time(); + const double now = timer_get_time(); for (core_tPhysicOutput* output = &coreGlobals.physicOutputState[index]; changeMask; changeMask >>= 1, output++) if (changeMask & 1) { @@ -2662,7 +2662,7 @@ void core_write_masked_pwm_output_8b(int index, UINT8 bitStates, UINT8 bitMask) UINT8 changeMask = bitMask & (coreGlobals.binaryOutputState[index >> 3] ^ bitStates); // Identify differences if (!changeMask) return; - const float now = (float) timer_get_time(); + const double now = timer_get_time(); for (core_tPhysicOutput* output = &coreGlobals.physicOutputState[index]; changeMask; changeMask >>= 1, output++) if (changeMask & 1) { diff --git a/src/wpc/core.h b/src/wpc/core.h index 13c13bb51..f3362dc19 100644 --- a/src/wpc/core.h +++ b/src/wpc/core.h @@ -463,7 +463,7 @@ typedef struct { float switchDownLatency; } sol; // Physical model of a solenoid } state; - float flipTimeStamps[FLIP_BUFFER_SIZE]; + double flipTimeStamps[FLIP_BUFFER_SIZE]; unsigned int flipBufferPos; unsigned int lastIntegrationFlipPos; } core_tPhysicOutput; @@ -654,12 +654,11 @@ extern void core_nvram(void *file, int write, void *mem, size_t length, UINT8 in /* makes it easier to swap bits */ extern const UINT8 core_swapNyb[16]; -INLINE UINT8 core_revbyte(UINT8 x) { return (core_swapNyb[x & 0xf]<<4)|(core_swapNyb[x>>4]); } +INLINE UINT8 core_revbyte(UINT8 x) { return (core_swapNyb[x & 0xf] << 4)|(core_swapNyb[x >> 4]); } INLINE UINT8 core_revnyb(UINT8 x) { return core_swapNyb[x]; } INLINE UINT16 core_revword(UINT16 x) { - UINT8 lo,hi; - lo = core_revbyte(x & 0x00ff); - hi = core_revbyte((x & 0xff00)>>8); + UINT8 lo = core_revbyte(x & 0x00ff); + UINT8 hi = core_revbyte((x >> 8) & 0x00ff); return ((lo<<8) | hi); }