this post was submitted on 20 Mar 2024
76 points (98.7% liked)

RetroGaming

19551 readers
243 users here now

Vintage gaming community.

Rules:

  1. Be kind.
  2. No spam or soliciting for money.
  3. No racism or other bigotry allowed.
  4. Obviously nothing illegal.

If you see these please report them.

founded 1 year ago
MODERATORS
 

An update to my previous post. I was able to improive the average lag by disabling the serial monitor, passing a reference of the controller to the polling logic (eliminating the need to loop over the current state and previous state to determine if buttons should be pressed), and adding a 1ms delay between loops (should have realized that the board need some down time between calls). I've added the code since I think 8ms is a perfectly good lag result for a diy project.

top 4 comments
sorted by: hot top controversial new old
[–] Toes@ani.social 5 points 8 months ago (1 children)

Have you explored changing the polling logic to interrupt?

[–] v1605@lemmy.world 3 points 8 months ago (1 children)

Can you provide an example? I only experimented with delay and found that 1 millisecond gave the best improvement.

[–] Toes@ani.social 2 points 8 months ago (1 children)

I'm not familiar with the hardware at hand, but an example is how the PS/2 port on a computer is interrupt based. Where you press a button and it informs the cpu of the button press. I was curious if the hardware you're working with has something akin to that.

[–] v1605@lemmy.world 8 points 8 months ago

The SNES uses shift registers on the controller. Polling it requires reading the registers to get the current state.