![]() |
Routines |
| Prev: 26066 | Up: Map | Next: 26086 |
|
Used by the routines at GameLoop and ActionKill.
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 | 26070 | PUSH BC | Stash BC on the stack. | |||||||||
| 26071 | LD C,A | Store the exclusive upper bound in C. | ||||||||||
| 26072 | LD A,(23672) | Load *FRAMES into B as the loop count. | ||||||||||
| 26075 | LD B,A | |||||||||||
| 26076 | LD A,C | Restore the exclusive upper bound into A. | ||||||||||
| GenerateRandomNumber_Loop | 26077 | DEC A | Decrease the walking value by one. | |||||||||
| 26078 | JR NZ,GenerateRandomNumber_Next | Jump to GenerateRandomNumber_Next if it has not wrapped past zero. | ||||||||||
| 26080 | LD A,C | Wrap back to the exclusive upper bound. | ||||||||||
| GenerateRandomNumber_Next | 26081 | DJNZ GenerateRandomNumber_Loop | Decrease the frame-count loop by one and loop back to GenerateRandomNumber_Loop until the count is zero. | |||||||||
| 26083 | DEC A | Decrease the result by one so the range starts at 0. | ||||||||||
| 26084 | POP BC | Restore BC from the stack. | ||||||||||
| 26085 | RET | Return. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: 26066 | Up: Map | Next: 26086 |