Prev: F22A Up: Map Next: F26C
F23B: Get Random Numbers
Used by the routines at ChooseItemSites, RunTitleMenu and RunLife.
Makes two new random numbers at RandomNumbers, using a pointer to a byte of memory that is moved on one place each time and stays below B000. The byte that it points to is added to each number, together with the value of the value of the controls (see ReadControls), so pressing the controls at different times changes the numbers.
RandomNumber F23B LD IX,$9BCB The random numbers.
F23F LD H,(IX+$02) Read offset 02 of IX into H.
F242 LD L,(IX+$03) Read offset 03 of IX into L.
F245 INC HL Advance HL.
F246 LD A,H A=H.
F247 AND %10101111 Keep the bits of A that are set in AF.
F249 LD (IX+$02),A Write A to offset 02 of IX.
F24C LD (IX+$03),L Write L to offset 03 of IX.
F24F LD B,(HL) Read HL into B.
F250 LD A,($5C37) The controls.
F253 ADD A,B A gains B.
F254 ADD A,$05 Add 05 to A.
F256 ADD A,(IX+$00) Add the byte at offset 00 of IX to A.
F259 LD (IX+$00),A Write A to offset 00 of IX.
F25C LD A,B A=B.
F25D CPL Invert A.
F25E LD B,A B=A.
F25F LD A,($5C37) The controls.
F262 ADD A,$09 Add 09 to A.
F264 ADD A,B A gains B.
F265 ADD A,(IX+$01) Add the byte at offset 01 of IX to A.
F268 LD (IX+$01),A Write A to offset 01 of IX.
F26B RET Return.
Prev: F22A Up: Map Next: F26C