Timing's easy, at least at first Given the clock of the emulated CPU and the frame rate of the game, you simply run the CPU for (clock / rate) cycles each frame.
So for a 1 MHz CPU (common in 6502 games) at 60 frames per second, you'd run the CPU for 1000000/60 = 16666 cycles each frame. Each time you were done running the CPU is when you'd update the screen, read the keyboard/joypads, and all the other stuff.
|