![]() |
Routines |
| Prev: 48961 | Up: Map | Next: 48981 |
|
Used by the routines at Events_Elf, Events_FlyingLizard, Events_KorlWarrior and Handler_ResolveAttack.
Return a number between 0 and the limit passed in.
|
||||||||
| GenerateRandomNumber | 48965 | PUSH BC | Save the limit and take the low byte of *FRAMES as the scramble. | |||||
| 48966 | LD C,A | |||||||
| 48967 | LD A,(23672) | |||||||
| 48970 | LD B,A | |||||||
| 48971 | LD A,C | |||||||
| GenerateRandomNumber_Loop | 48972 | DEC A | Step the result down, wrapping to the limit when it passes zero. | |||||
| 48973 | JR NZ,GenerateRandomNumber_Repeat | |||||||
| 48975 | LD A,C | |||||||
| GenerateRandomNumber_Repeat | 48976 | DJNZ GenerateRandomNumber_Loop | Repeat that step once for each frame count. | |||||
| 48978 | DEC A | Step the result down once more, so the range starts at zero. | ||||||
| 48979 | POP BC | Restore the saved limit from the stack. | ||||||
| 48980 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 48961 | Up: Map | Next: 48981 |