Routines |
Prev: 38222 | Up: Map | Next: 38299 |
|
||||||||
The R register is incremented every instruction, providing a pseudo-random value.
|
||||||||
GetRandomNumber | 38265 | LD A,R | H=R. | |||||
38267 | LD H,A | |||||||
WasteTime_Loop_1 | 38268 | DEC A | Count down to zero from the refresh value. | |||||
38269 | JR NZ,WasteTime_Loop_1 | |||||||
38271 | LD A,R | L=R. | ||||||
38273 | LD L,A | |||||||
38274 | LD DE,(23673) | HL+=*FRAMES+1. | ||||||
38278 | ADD HL,DE | |||||||
38279 | LD A,%00111111 | Keep only the lower 6 bits of H. | ||||||
38281 | AND H | |||||||
38282 | LD H,A | |||||||
38283 | LD A,(HL) | Load the byte from the ZX Spectrum ROM pointed to by HL, store it in H. | ||||||
38284 | LD H,A | |||||||
WasteTime_Loop_2 | 38285 | DEC A | Count down to zero from the ZX Spectrum ROM byte value. | |||||
38286 | JR NZ,WasteTime_Loop_2 | |||||||
Ensure the value in A is in the range 0-52.
|
||||||||
38288 | LD A,H | A=H. | ||||||
38289 | LD H,52 | H=52. | ||||||
GetRandomNumber_Loop | 38291 | SUB H | Subtract 52 from A. | |||||
38292 | JR Z,GetRandomNumber_Loop | Jump back to GetRandomNumber_Loop if the result is zero. | ||||||
38294 | CP 53 | Jump back to GetRandomNumber_Loop if the result is higher than, or equal to 53. | ||||||
38296 | JR NC,GetRandomNumber_Loop | |||||||
38298 | RET | Return. |
Prev: 38222 | Up: Map | Next: 38299 |