Prev: 5D27 Up: Map Next: 6414
6400: Get Random Number
Used by the routines at 64AA, InitialiseLevel, 7088, 709D, InitialiseNewLevel and DemoModeInput.
Output
A Random number
Random numbers are just data pulled from addresses between 7900-7AFF (sequentially).
GetRandomNumber 6400 PUSH HL Stash HL on the stack.
6401 LD HL,($781E) HL=*RandomNumberSeed.
6404 LD A,(HL) A=*HL.
6405 INC L Increment L by one.
6406 JR NZ,UpdateRandomNumberSeed Jump to UpdateRandomNumberSeed if L is not zero.
6408 INC H Increment H by one.
6409 BIT 2,H Jump to UpdateRandomNumberSeed if bit 2 of H is not set.
640B JR Z,UpdateRandomNumberSeed
Bit 2 is set, this means that H has reached 7C so pull the range back down to 79.
640D LD H,$79 H=79.
UpdateRandomNumberSeed 640F LD ($781E),HL Write HL to *RandomNumberSeed.
6412 POP HL Restore HL from the stack.
6413 RET Return.
Prev: 5D27 Up: Map Next: 6414