Prev: 55837 Up: Map Next: 55869
55848: Random Number
Output
A Random number
RandomNumber 55848 LD DE,(53786) DE=*Game_Clock.
55852 INC DE Increment DE by one.
The max value is 10240 so test the higher order byte to check if this limit has been hit.
55853 LD A,D If D is 40 then jump to ResetSeed.
55854 CP 40
55856 JR Z,ResetSeed
Update the "clock" value.
WriteSeed 55858 LD (53786),DE Write DE back to *Game_Clock.
The "random number" is actually a byte from the Spectrum ROM. The "clock" is used as a pointer to return a value from between memory locations 0000-10239.
55862 LD A,(DE) A=*DE.
55863 RET Return.
Reset the "clock" back to 0000.
ResetSeed 55864 LD D,0 D=0.
55866 JP WriteSeed Jump to WriteSeed.
Prev: 55837 Up: Map Next: 55869