MCHPR / MCHPRS

A multithreaded Minecraft server built for redstone.
MIT License
1.56k stars 67 forks source link

Add ability to synchronizing MCHPRS simulation with a real-time clock #98

Open benburk opened 1 year ago

benburk commented 1 year ago

Currently, it's difficult to synchronize a program running on a CPU with real-time. For example, running a game at 30fps or applying physics forces at certain intervals. Current solutions involve counting CPU cycles and setting the TPS accordingly, but different code paths or cache misses can make this difficult if not impossible.

As the interest in running more sophisticated programs on MCHPRS grows, I think it would be worthwhile to brainstorm potential solutions.

I propose introducing a clock generator block that pulses at 60hz. This signal could be divided into 30hz and 15hz with clock dividers (i.e. T-flip-flops). This circuit could be connected to a rising-edge monostable. When a CPU wants to synchronize itself, it could stall until it receives a pulse from this circuit.

I'm curious to hear people's thoughts and attempting an implementation if the community is interested.

- Embi