How can I obtain the uptime of a Sinclair ZX Spectrum machine (ZX48, ZX128, or Pentagon clone) via their BASIC interpreter? Specifically, the same value used by RANDOMIZE 0
to seed its PRNG. I would assume that this uptime would be the number of cycles the MCU has gone through since boot and so would increment at 3.5 MHz (or some fraction thereof). If it is not possible to obtain through the BASIC interpreter, how would I go about getting it by writing code directly to memory, e.g. with DATA
?
The reason I am wondering is because I would like to generate a sequence of random numbers less predictable than that generated by RND
. To do that, I need an environmental source of entropy. Inter-keystroke timing is the perfect place to get that entropy (as the ZX has no HWRNG), but only if a high-resolution timer can be sampled at each keystroke. If this is an X/Y question, please let me know.
RANDOMIZE 0
does. The simplest way to do this actually isRANDOMIZE 0
RANDOMIZE 0
doesn't give you the value of the counter, but uses it directly. So unless you're suggesting reverse engineering the seed of the RNG based on its outputs, I don't think it helps much in getting the value of the actual timer.