![]() |
Routines |
| Prev: C0CC | Up: Map | Next: C0F8 |
|
Used by the routine at InitialiseGame.
Stirs the two random numbers in FirstRandomNumber and SecondRandomNumber. The first uses FrameCounter and the refresh register, and the second uses the frame counter and the return address, so it is different for every routine which calls this.
|
||||
|
Stir the first random number with the frame counter and the refresh register.
|
||||
| UpdateRandomNumbers | C0D3 | LD DE,($A216) | Fetch FrameCounter into DE. | |
| C0D7 | LD HL,($A218) | Fetch FirstRandomNumber. | ||
| C0DA | LD A,R | Fetch the refresh register. | ||
| C0DC | ADD A,E | Add the low byte of the frame counter. | ||
| C0DD | ADD A,L | Add the low byte of the random number. | ||
| C0DE | LD L,A | Set the low byte of the new number. | ||
| C0DF | LD A,R | Fetch the refresh register again. | ||
| C0E1 | ADD A,D | Add the high byte of the frame counter. | ||
| C0E2 | ADD A,H | Add the high byte of the random number. | ||
| C0E3 | LD H,A | Set the high byte of the new number. | ||
|
Store the first random number.
|
||||
| C0E4 | LD ($A218),HL | Set FirstRandomNumber. | ||
|
Stir the second random number with the frame counter and the return address.
|
||||
| C0E7 | POP BC | Fetch the return address into BC, leaving it on the stack. | ||
| C0E8 | PUSH BC | |||
| C0E9 | LD HL,($A21A) | Fetch SecondRandomNumber. | ||
| C0EC | LD A,C | Fetch the low byte of the return address. | ||
| C0ED | SUB E | Subtract the low byte of the frame counter. | ||
| C0EE | ADD A,L | Add the low byte of the random number. | ||
| C0EF | LD L,A | Set the low byte of the new number. | ||
| C0F0 | LD A,B | Fetch the high byte of the return address. | ||
| C0F1 | SUB D | Subtract the high byte of the frame counter. | ||
| C0F2 | ADD A,H | Add the high byte of the random number. | ||
| C0F3 | LD H,A | Set the high byte of the new number. | ||
|
Store the second random number.
|
||||
| C0F4 | LD ($A21A),HL | Set SecondRandomNumber. | ||
| C0F7 | RET | Return. | ||
| Prev: C0CC | Up: Map | Next: C0F8 |