Prev: F5EC Up: Map Next: F60A
F5F4: Get Random Number
Used by the routine at JumpTable_GetRandomNumber.
(((B + C) % 0100 + AB) % 0100) * 0100 + (C + CD) % 0100
Output
A The random number
Get_RandomNumber F5F4 PUSH BC Stash BC on the stack.
F5F5 LD BC,($64B2) BC=*RandomNumberSeed.
F5F9 LD A,C B=B+C.
F5FA ADD A,B
F5FB LD B,A
F5FC LD A,$CD C=CD+C.
F5FE ADD A,C
F5FF LD C,A
F600 LD A,$AB B+=AB.
F602 ADC A,B
F603 LD B,A
F604 LD ($64B2),BC Write the updated BC to *RandomNumberSeed.
F608 POP BC Restore BC from the stack.
F609 RET Return.
View the equivalent code in Booty.
Prev: F5EC Up: Map Next: F60A