![]() |
Routines |
| Prev: 45185 | Up: Map | Next: 45210 |
|
Used by the routines at Event_Roman and Event_Fomorian.
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 | 45194 | PUSH BC | Stash BC on the stack. | |||||||||
| 45195 | LD C,A | Store the exclusive upper bound in C. | ||||||||||
| 45196 | CALL FetchFrames | Call FetchFrames to read *FRAMES. | ||||||||||
| 45199 | LD B,A | Use the frame counter as the loop count in B. | ||||||||||
| 45200 | LD A,C | Restore the exclusive upper bound into A. | ||||||||||
| GenerateRandomNumber_Loop | 45201 | DEC A | Decrease the walking value by one. | |||||||||
| 45202 | JR NZ,GenerateRandomNumber_Next | Jump to GenerateRandomNumber_Next if it has not wrapped past zero. | ||||||||||
| 45204 | LD A,C | Wrap back to the exclusive upper bound. | ||||||||||
| GenerateRandomNumber_Next | 45205 | DJNZ GenerateRandomNumber_Loop | Decrease the frame-count loop by one and loop back to GenerateRandomNumber_Loop until the count is zero. | |||||||||
| 45207 | DEC A | Decrease the result by one so the range starts at 0. | ||||||||||
| 45208 | POP BC | Restore BC from the stack. | ||||||||||
| 45209 | RET | Return. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: 45185 | Up: Map | Next: 45210 |