From 81ae6dfd1176747976dce893fc1edb6663f0b444 Mon Sep 17 00:00:00 2001 From: Kevin Nakamura Date: Sun, 11 Sep 2022 05:43:14 +0900 Subject: [PATCH] Limit service from being processed more often than coins. JVS' + noisy switches can cause coin problems. --- firmware/td-io.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/firmware/td-io.c b/firmware/td-io.c index bcbefbe..23012d2 100644 --- a/firmware/td-io.c +++ b/firmware/td-io.c @@ -382,9 +382,20 @@ int main() { msg_send[o] = JVS_REPORT_GOOD; o++; uint32_t switches = read_switches(); + + /* With JVS' speeds, buttons can get bouncy. Games generally only process + * inputs once per frame, but coin and service logic can happen between game + * frames. We limit coin processing at a rate well above bounciness but less + * than 1/60th of a second. */ + static uint8_t service_pressed = 0; if ((now - last_process_coin) > 12000) { process_coin(switches); last_process_coin = now; + service_pressed = (switches >> SR_SERVICE) & 1; + } + else { + switches = (switches & ~(1 << SR_SERVICE) + | (service_pressed << SR_SERVICE)); } msg_send[o] = ((switches >> SR_TEST) & 1) << 7 | ((switches >> SR_TILT) & 1) << 6;