![]() |
Routines |
| Prev: B776 | Up: Map | Next: B78F |
|
Returns a number from 00 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 | B77F | PUSH BC | Stash BC on the stack. | |||||||||
| B780 | LD C,A | Store the exclusive upper bound in C. | ||||||||||
| B781 | CALL FetchFrames | Call FetchFrames to read *FRAMES. | ||||||||||
| B784 | LD B,A | Use the frame counter as the loop count in B. | ||||||||||
| B785 | LD A,C | Restore the exclusive upper bound into A. | ||||||||||
| GenerateRandomNumber_Loop | B786 | DEC A | Decrease the walking value by one. | |||||||||
| B787 | JR NZ,GenerateRandomNumber_Next | Jump to GenerateRandomNumber_Next if it has not wrapped past zero. | ||||||||||
| B789 | LD A,C | Wrap back to the exclusive upper bound. | ||||||||||
| GenerateRandomNumber_Next | B78A | DJNZ GenerateRandomNumber_Loop | Decrease the frame-count loop by one and loop back to GenerateRandomNumber_Loop until the count is zero. | |||||||||
| B78C | DEC A | Decrease the result by one so the range starts at 00. | ||||||||||
| B78D | POP BC | Restore BC from the stack. | ||||||||||
| B78E | RET | Return. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: B776 | Up: Map | Next: B78F |