![]() |
Routines |
| Prev: 46966 | Up: Map | Next: 46991 |
|
Pick a number below the limit in A.
|
||||||||
| GenerateRandomNumber | 46975 | PUSH BC | Remember the caller's registers. | |||||
| 46976 | LD C,A | Remember the upper limit. | ||||||
| 46977 | CALL FetchFrames | Call FetchFrames to read the frame counter. | ||||||
| 46980 | LD B,A | Use the frame counter as the spin count. | ||||||
| 46981 | LD A,C | |||||||
| GenerateRandomNumber_Loop | 46982 | DEC A | Count down inside the limit. | |||||
| 46983 | JR NZ,GenerateRandomNumber_Next | |||||||
| 46985 | LD A,C | |||||||
| GenerateRandomNumber_Next | 46986 | DJNZ GenerateRandomNumber_Loop | Count down B and repeat from GenerateRandomNumber_Loop until the count is exhausted. | |||||
| 46988 | DEC A | Step the count in A down. | ||||||
| 46989 | POP BC | Restore the caller's BC from the stack, leaving the random number in A. | ||||||
| 46990 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 46966 | Up: Map | Next: 46991 |