João Costa @JD557@blog.joaocosta.eu Follow

Portuguese software engineer at Kevel.

My instance is running on a small server so please #nobot

Web

https://www.joaocosta.eu/

GitHub

https://github.com/JD557

Twitter

https://twitter.com/JD557

Itch.io

https://jd557.itch.io

  • Notes
  • Articles 6
  • Followers 47
  • Following 59
João Costa's avatar
João Costa
@JD557@blog.joaocosta.eu

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. 😂

An Introduction to Chip-8/Octo joaocosta.eu
A small led screen showing a Chip-8 rock paper scissors game, alognside a 4x4 button keypad
  • permalink
  • 8 hours ago
  • 1 reply
João Costa's avatar
João Costa
@JD557@blog.joaocosta.eu

in reply to this object

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:

  • The screen is refreshed in parallel with the simulation
  • If the CPU speed is higher than 2.5kHz, the image is rendered at the native resolution (instead of a 2x scale)
  • permalink
  • interact from your instance
  • 2 hours ago
Powered by microblog.pub 2.0.0+dev (source code) and the ActivityPub protocol. Admin.