![]() |
Routines |
| Prev: DD01 | Up: Map | Next: DD6A |
|
Used by the routines at MONSTER112_UPDATE and VILLAIN_WANDER.
Used by the villains (VILLAIN_WANDER) and the monsters of graphics 112-127 (MONSTER112_UPDATE). Stopped by a wall, it turns a quarter left or right at random and starts a new count of up to 63 turns. Otherwise the count (the low bits of the facing byte) goes down each turn, and when its low five bits reach 0: with bit 5 of the flags clear it turns at random the same way; with it set it turns towards the knight (KNIGHT_DIRECTION, TURN_TO_KNIGHT_TABLE) and starts a count of 1-16.
Bit 5 is set only for a monster spawned in the first half of a 256-turn cycle (SPAWN_MONSTER); the villains never have it, so they wander and never chase. The counts are set from the random number's high byte and tested on only five bits, so a count of 32-63 runs out after the count less 32.
|
||||||||
| STEER | DD28 | BIT 0,(IX+$07) | Stopped by a wall: turn | |||||
| DD2C | JR NZ,STEER_0 | |||||||
| DD2E | DEC (IX+$06) | Count down; done unless the low five bits are 0 | ||||||
| DD31 | LD A,(IX+$06) | |||||||
| DD34 | AND $1F | |||||||
| DD36 | RET NZ | |||||||
| DD37 | BIT 5,(IX+$07) | A chaser turns towards the knight | ||||||
| DD3B | JR NZ,STEER_3 | |||||||
| STEER_0 | DD3D | LD A,(RANDOM) | Turn left or right at random | |||||
| DD40 | CP $80 | |||||||
| DD42 | LD A,(IX+$06) | |||||||
| DD45 | JR NC,STEER_2 | |||||||
| DD47 | ADD A,$40 | Right | ||||||
| STEER_1 | DD49 | LD C,A | A new count, the random number's high byte's low six bits ORed with what was left of the old one | |||||
| DD4A | LD A,($BBAB) | |||||||
| DD4D | AND $3F | |||||||
| DD4F | OR C | |||||||
| DD50 | LD (IX+$06),A | |||||||
| DD53 | RET | |||||||
| STEER_2 | DD54 | SUB $40 | Left | |||||
| DD56 | JR STEER_1 | |||||||
| STEER_3 | DD58 | CALL KNIGHT_DIRECTION | A: the knight's direction, 0-3 | |||||
| DD5B | LD C,A | |||||||
| DD5C | LD A,(IX+$06) | Where it is compared with the facing: 0 ahead, 1 to the left, 2 behind, 3 to the right | ||||||
| DD5F | RLCA | |||||||
| DD60 | RLCA | |||||||
| DD61 | SUB C | |||||||
| DD62 | AND $03 | |||||||
| DD64 | LD BC,TURN_TO_KNIGHT_TABLE | Turn by it (TURN_TO_KNIGHT_TABLE) | ||||||
| DD67 | JP DISPATCH | |||||||
| Prev: DD01 | Up: Map | Next: DD6A |