![]() |
Routines |
| Prev: 46966 | Up: Map | Next: 46991 |
|
Returns a number from 0 up to, but not including, A.
The frame counter chooses how far to walk around that range.
|
||||||||||||
|
Mix the frame counter into a number below the limit in A.
|
||||||||||||
| GenerateRandomNumber | 46975 | PUSH BC | Stash BC on the stack. | |||||||||
| 46976 | LD C,A | Store the exclusive upper bound in C. | ||||||||||
| 46977 | CALL FetchFrames | Call FetchFrames to read *FRAMES. | ||||||||||
| 46980 | LD B,A | Use the frame counter as the loop count in B. | ||||||||||
| 46981 | LD A,C | Restore the exclusive upper bound into A. | ||||||||||
| GenerateRandomNumber_Loop | 46982 | DEC A | Decrease the walking value by one. | |||||||||
| 46983 | JR NZ,GenerateRandomNumber_Next | Jump to GenerateRandomNumber_Next if it has not wrapped past zero. | ||||||||||
| 46985 | LD A,C | Wrap back to the exclusive upper bound. | ||||||||||
| GenerateRandomNumber_Next | 46986 | DJNZ GenerateRandomNumber_Loop | Decrease the frame-count loop by one and loop back to GenerateRandomNumber_Loop until the count is zero. | |||||||||
| 46988 | DEC A | Decrease the result by one so the range starts at 0. | ||||||||||
| 46989 | POP BC | Restore BC from the stack. | ||||||||||
| 46990 | RET | Return. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: 46966 | Up: Map | Next: 46991 |