Prev: 44284 Up: Map Next: 44340
44325: Generate Random Number
Returns a number from 0 up to, but not including, A.
The refresh register chooses how far to walk around that range.
Nothing in the game calls it.
Input
A Exclusive upper bound
Output
A The generated number
Mix the refresh register into a number below the limit in A. Nothing in the game calls this.
GenerateRandomNumber 44325 PUSH BC Walk around the range until the refresh count runs out.
44326 LD C,A
44327 LD A,R
44329 LD B,A
44330 LD A,C
Random_Mix 44331 DEC A
44332 JR NZ,GenerateRandomNumber_0
44334 LD A,C
GenerateRandomNumber_0 44335 DJNZ Random_Mix
44337 DEC A
44338 POP BC Restore BC from the stack.
44339 RET Return.
Prev: 44284 Up: Map Next: 44340