![]() |
Routines |
| Prev: BF41 | Up: Map | Next: BF55 |
|
Used by the routines at Events_Elf, Events_FlyingLizard, Events_KorlWarrior and Handler_ResolveAttack.
Return a number between 00 and the limit passed in.
|
||||||||
| GenerateRandomNumber | BF45 | PUSH BC | Save the limit and take the low byte of *FRAMES as the scramble. | |||||
| BF46 | LD C,A | |||||||
| BF47 | LD A,($5C78) | |||||||
| BF4A | LD B,A | |||||||
| BF4B | LD A,C | |||||||
| GenerateRandomNumber_Loop | BF4C | DEC A | Step the result down, wrapping to the limit when it passes zero. | |||||
| BF4D | JR NZ,GenerateRandomNumber_Repeat | |||||||
| BF4F | LD A,C | |||||||
| GenerateRandomNumber_Repeat | BF50 | DJNZ GenerateRandomNumber_Loop | Repeat that step once for each frame count. | |||||
| BF52 | DEC A | Step the result down once more, so the range starts at zero. | ||||||
| BF53 | POP BC | Restore the saved limit from the stack. | ||||||
| BF54 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: BF41 | Up: Map | Next: BF55 |