Prev: 48961 Up: Map Next: 48981
48965: Generate Random Number
Return a number between 0 and the limit passed in.
Output
A A random number derived from *FRAMES
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.
Prev: 48961 Up: Map Next: 48981