|
Post by lamptonworm on Feb 24, 2020 19:57:11 GMT
Hi,
Bit of a strange one, implementing a MOD with the following code in one of the main loops.
The weird bit, is with the AT/DISPLAY commented out, stepping through using the debugger shows Z cycling 1,3,5,7,9 but with those lines included it shows Z cycling 0,2,4,6,8. (edit.. Hmm actually not sure why it doesn't count 0,1,2,3 etc reading this back ie steps of 1). Either way, or could be related, any idea why using AT/DISPLAY impacts the value of Z?
LET Z = CLOCK LET E = Z DIVIDE E BY 10 MULTIPLY E BY 10 SUBTRACT E FROM Z
AT 4 0 DISPLAY Z
IF Z = 0 BORDER 2 ELSE BORDER 0 ENDIF
Cheers, LW.
|
|
|
Post by Jonathan Cauldwell on Mar 1, 2020 14:17:45 GMT
On the Spectrum CLOCK is basically the last value of the system variable at 23672, which is updated by the ROM interrupt routine. The engine runs at 25 FPS so this byte is incremented twice each main loop and read by the vsync routine in the engine. The value starts at zero when the Spectrum is switched on and keeps counting up after that, only stopping for things like loading, saving and beeper sounds. So your code will cycle through odd numbers or even numbers depending on where the clock stands when you start the game.
Hope that clears it up.
|
|
|
Post by lamptonworm on Mar 3, 2020 21:13:41 GMT
|
|