Prev: ACFC Up: Map Next: AD34
AD25: Generate Random Number
Returns a number from 00 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 AD25 PUSH BC Walk around the range until the refresh count runs out.
AD26 LD C,A
AD27 LD A,R
AD29 LD B,A
AD2A LD A,C
Random_Mix AD2B DEC A
AD2C JR NZ,GenerateRandomNumber_0
AD2E LD A,C
GenerateRandomNumber_0 AD2F DJNZ Random_Mix
AD31 DEC A
AD32 POP BC Restore BC from the stack.
AD33 RET Return.
Prev: ACFC Up: Map Next: AD34