![]() |
Routines |
| Prev: C55F | Up: Map | Next: C5CE |
|
NEXT_TURN adds one to TURNS, once a turn in the main loop and at a few points of a new game's set-up. STIR_RANDOM, the rest, is called after every record's update and before most random choices. The random number's low byte becomes R plus itself plus the turn counter's low byte, with the carry; its high byte just adds the turn counter's high byte, with no carry from the low. R counts the instructions run, which depends on all the game has done, so the low byte is hard to predict; the high byte is not -- a fixed step, the same for 256 turns at a time, added once a stir.
|
||||
| NEXT_TURN | C5B4 | LD HL,(TURNS) | one more turn | |
| C5B7 | INC HL | |||
| C5B8 | LD (TURNS),HL | |||
|
This entry point is used by the routines at NEW_GAME, RANDOM_START_CELL, SPAWN_MONSTER and PLACE_BONUS.
|
||||
| STIR_RANDOM | C5BB | LD HL,(TURNS) | STIR_RANDOM: the low byte from R, itself and the counter's low byte; the high byte plus the counter's high byte | |
| C5BE | LD DE,(RANDOM) | |||
| C5C2 | LD A,R | |||
| C5C4 | ADD A,E | |||
| C5C5 | ADC A,L | |||
| C5C6 | LD L,A | |||
| C5C7 | LD A,D | |||
| C5C8 | ADD A,H | |||
| C5C9 | LD H,A | |||
| C5CA | LD (RANDOM),HL | kept | ||
| C5CD | RET | |||
| Prev: C55F | Up: Map | Next: C5CE |