OK, I just finished writing a Chip-8 implementation in Scala and connected a 4x4 keypad to my Raspberry, so now I can actually play games there!
I did hit an annoying issue here, though... The fact that:
- The screen refresh logic is slow (I think this is a limitation if I2C)
- Chip8 doesn't have any kind of VSync
Means that I need to simulate the CPU at a high-ish clock rate (10KHz) so that I don't spend a bunch of time drawing intermediate states. I think this might cause issue in some games (In my local simulator, 1KHz seems to be the soft spot for most games).
As an aside, this is the second time that I give Chip8 a try (I gave a talk about that in 2016: https://joaocosta.eu/Talks/Chip8/#/)
Turns out I was making things way too complex back then by trying to be smart... This time I went "Ints everywhere and immutability goes brrrr" and it was super easy to implement.
OK, I noticed that I was writing to the screen suing a very slow API. I did notice that before, but wasn't able to fix it at the time.
This time I ended up just not using WiringPi and writing the data directly. It's not clear to me what is wrong in WiringPi, but I'll assume there's some weird bug in there.
On top of that, I think I found a decent compromise for now: