![]() |
Routines |
| Prev: 954E | Up: Map | Next: 959B |
|
||||||||
|
The R register is incremented every instruction, providing a pseudo-random value.
|
||||||||
| GetRandomNumber | 9579 | LD A,R | H=R. | |||||
| 957B | LD H,A | |||||||
| WasteTime_Loop_1 | 957C | DEC A | Count down to zero from the refresh value. | |||||
| 957D | JR NZ,WasteTime_Loop_1 | |||||||
| 957F | LD A,R | L=R. | ||||||
| 9581 | LD L,A | |||||||
| 9582 | LD DE,($5C79) | HL+=*FRAMES+01. | ||||||
| 9586 | ADD HL,DE | |||||||
| 9587 | LD A,%00111111 | Keep only the lower 6 bits of H. | ||||||
| 9589 | AND H | |||||||
| 958A | LD H,A | |||||||
| 958B | LD A,(HL) | Load the byte from the ZX Spectrum ROM pointed to by HL, store it in H. | ||||||
| 958C | LD H,A | |||||||
| WasteTime_Loop_2 | 958D | DEC A | Count down to zero from the ZX Spectrum ROM byte value. | |||||
| 958E | JR NZ,WasteTime_Loop_2 | |||||||
|
Ensure the value in A is in the range 00-34.
|
||||||||
| 9590 | LD A,H | A=H. | ||||||
| 9591 | LD H,$34 | H=34. | ||||||
| GetRandomNumber_Loop | 9593 | SUB H | Subtract 34 from A. | |||||
| 9594 | JR Z,GetRandomNumber_Loop | Jump back to GetRandomNumber_Loop if the result is zero. | ||||||
| 9596 | CP $35 | Jump back to GetRandomNumber_Loop if the result is higher than, or equal to 35. | ||||||
| 9598 | JR NC,GetRandomNumber_Loop | |||||||
| 959A | RET | Return. | ||||||
| Prev: 954E | Up: Map | Next: 959B |