![]() |
Routines |
| Prev: B776 | Up: Map | Next: B78F |
|
Pick a number below the limit in A.
|
||||||||
| GenerateRandomNumber | B77F | PUSH BC | Remember the caller's registers. | |||||
| B780 | LD C,A | Remember the upper limit. | ||||||
| B781 | CALL FetchFrames | Call FetchFrames to read the frame counter. | ||||||
| B784 | LD B,A | Use the frame counter as the spin count. | ||||||
| B785 | LD A,C | |||||||
| GenerateRandomNumber_Loop | B786 | DEC A | Count down inside the limit. | |||||
| B787 | JR NZ,GenerateRandomNumber_Next | |||||||
| B789 | LD A,C | |||||||
| GenerateRandomNumber_Next | B78A | DJNZ GenerateRandomNumber_Loop | Count down B and repeat from GenerateRandomNumber_Loop until the count is exhausted. | |||||
| B78C | DEC A | Step the count in A down. | ||||||
| B78D | POP BC | Restore the caller's BC from the stack, leaving the random number in A. | ||||||
| B78E | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: B776 | Up: Map | Next: B78F |