The clock and time
Phosphoneo’s time is a number of cycles. No computer clock enters it: that is why a run repeats identically.
The constants
| What | Value |
|---|---|
| 65C02 frequency | 6.25 MHz |
| one frame | 109,226 cycles, i.e. 60 Hz |
| one timer tick | 62,500 cycles, i.e. 100 Hz |
| one second of machine time | 6,250,000 cycles |
The firmware’s 100 Hz timer is derived from emulated cycles, not from the wall clock as in the official emulator: a program that waits on the timer therefore gives the same result on every run.
Window or not
Without a window, Phosphoneo goes as fast as it can. In a window (--sdl) or with --realtime, one emulated frame lasts 1/60 s of wall-clock time: emulation is identical, only slowed down.
How much does an API call cost?
By default, 0 cycles: the 65C02 resumes as soon as the call is handled, as in the official emulator. With --api-latency, it is frozen for the number of cycles calibrated in co-simulation, per function:
| Call | Order of magnitude |
|---|---|
| 2,6 write a character | ≈ 31 cycles |
| 5,2 draw a line | ≈ 1,200 cycles |
| 5,3 filled rectangle | up to 30,000 cycles (≈ 5 ms) |
| 5,4 filled ellipse | up to 70,000 cycles (≈ 11 ms) |
These are per-function averages, in a constructed unit (24.4 ARM steps per cycle) that has not been measured on the board: an ARM step is not an ARM cycle, and real latency depends on the parameters (a rectangle’s size). The board measurement protocol is written (docs/PROTOCOLE-MESURE-CARTE.md); it is waiting to be run.