Prev: CB79 Up: Map Next: CB92
CB85: Random nibble
This is a cheap pseudo-random number generator. It returns the bottom nibbles from the bytes at $9000..$90FF, in sequence.
Used by the routine at get_target.
Output
A Pseudo-random number from 0..15.
HL Preserved.
random_nibble CB85 PUSH HL Preserve HL
CB86 LD HL,($C41A) Point at the prng_pointer (initialised on load to $9000)
CB89 INC L Increment its bottom byte, wrapping at $90FF
CB8A LD A,(HL) Fetch a byte from the pointer
CB8B AND $0F Mask off the bottom nibble
CB8D LD ($C41A),HL Save the incremented prng_pointer
CB90 POP HL Restore HL
CB91 RET Return
Prev: CB79 Up: Map Next: CB92