![]() |
Routines |
| Prev: BF41 | Up: Map | Next: BF55 |
|
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 | BF45 | PUSH BC | Stash BC on the stack. | |||||||||
| BF46 | LD C,A | Store the exclusive upper bound in C. | ||||||||||
| BF47 | LD A,($5C78) | Load *FRAMES into B as the loop count. | ||||||||||
| BF4A | LD B,A | |||||||||||
| BF4B | LD A,C | Restore the exclusive upper bound into A. | ||||||||||
| GenerateRandomNumber_Loop | BF4C | DEC A | Decrease the walking value by one. | |||||||||
| BF4D | JR NZ,GenerateRandomNumber_Next | Jump to GenerateRandomNumber_Next if it has not wrapped past zero. | ||||||||||
| BF4F | LD A,C | Wrap back to the exclusive upper bound. | ||||||||||
| GenerateRandomNumber_Next | BF50 | DJNZ GenerateRandomNumber_Loop | Decrease the frame-count loop by one and loop back to GenerateRandomNumber_Loop until the count is zero. | |||||||||
| BF52 | DEC A | Decrease the result by one so the range starts at 00. | ||||||||||
| BF53 | POP BC | Restore BC from the stack. | ||||||||||
| BF54 | RET | Return. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: BF41 | Up: Map | Next: BF55 |