Sherlock: annotated disassembly

Routines

Prev: D29D Up: Map Next: D2AD
D2A4: A random number from 0 to A
The size of D2AD's result (it can be negative): |x - A|, where x is a pseudo-random byte halved until it is no more than 2A. So 0 to A inclusive, not 'below A'.
Input
A The limit
Output
A A random number from 0 to the limit
D2A4 CALL $D2AD Call the routine "The random number generator" (D2AD)
D2A7 BIT 7,A Test bit 7 of A - Make it positive
D2A9 RET Z If bit 7 of A is clear, return
D2AA NEG Negate A
D2AC RET Return to the caller
Prev: D29D Up: Map Next: D2AD