Prev: 61994 Up: Map Next: 62060
62011: 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 45056. 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 62011 LD IX,39883 The random numbers.
62015 LD H,(IX+2) Read offset 2 of IX into H.
62018 LD L,(IX+3) Read offset 3 of IX into L.
62021 INC HL Advance HL.
62022 LD A,H A=H.
62023 AND %10101111 Keep the bits of A that are set in 175.
62025 LD (IX+2),A Write A to offset 2 of IX.
62028 LD (IX+3),L Write L to offset 3 of IX.
62031 LD B,(HL) Read HL into B.
62032 LD A,(23607) The controls.
62035 ADD A,B A gains B.
62036 ADD A,5 Add 5 to A.
62038 ADD A,(IX+0) Add the byte at offset 0 of IX to A.
62041 LD (IX+0),A Write A to offset 0 of IX.
62044 LD A,B A=B.
62045 CPL Invert A.
62046 LD B,A B=A.
62047 LD A,(23607) The controls.
62050 ADD A,9 Add 9 to A.
62052 ADD A,B A gains B.
62053 ADD A,(IX+1) Add the byte at offset 1 of IX to A.
62056 LD (IX+1),A Write A to offset 1 of IX.
62059 RET Return.
Prev: 61994 Up: Map Next: 62060