Prev: CE79 Up: Map Next: CEF8
CE89: The monsters of graphics 64-79: wander, and hurt the knight
The update routine for graphics 64-79 (UPDATES): four kinds of four frames, the kind chosen when it appears by the villain nearest to it (APPEARING_UPDATE). It wanders: a new random step at random times (WANDER_STEP, each way up to 14 a turn), turned to face its step and tested against the walls (MOVE_SPLIT), moved (APPLY_STEP), and its frame stepped on (NEXT_FRAME_MOD4); drawn mirrored when the town is turned round. More than two cells from the knight either way, it is gone.
An antibody that touches it (ANTIBODY_STRIKE) vanishes with it, and 5 goes on the score. If it touches the knight (TOUCHING_KNIGHT, not while he is appearing) the score gets 5 as well and the monster vanishes, but it takes one of his hits; at the last, his life ends. Monsters of 112-127 (MONSTER112_UPDATE) and the creature of 136-139 (CREATURE_UPDATE) come in at MONSTER_HITS_KNIGHT, and a villain (VILLAIN_WANDER) at KNIGHT_KILLED, whatever his hits.
Input
IX the record
WANDERING_MONSTER CE89 LD B,$07 a new step now and then, up to 14 each way
CE8B CALL WANDER_STEP
CE8E CALL MOVE_SPLIT face it, against the walls; move; the next frame
CE91 CALL APPLY_STEP
CE94 CALL NEXT_FRAME_MOD4
CE97 LD A,(VIEW) bit 6 of its flags, drawn mirrored, set when the town is turned round
CE9A RRCA
CE9B RRCA
CE9C AND $40
CE9E LD C,A
CE9F LD A,(IX+$07)
CEA2 AND $BF
CEA4 OR C
CEA5 LD (IX+$07),A
CEA8 LD C,$03 more than two cells from the knight: gone
CEAA CALL NEAR_KNIGHT
CEAD JR NC,MONSTER_OUT_OF_RANGE
CEAF CALL ANTIBODY_STRIKE struck by an antibody
CEB2 JR C,MONSTER_SHOT
CEB4 CALL TOUCHING_KNIGHT not touching the knight
CEB7 RET NC
CEB8 CALL MONSTER_SCORE touching him: 5 on the score, and...
This entry point is used by the routines at CREATURE_UPDATE and MONSTER112_UPDATE.
MONSTER_HITS_KNIGHT CEBB LD (IX+$00),$0C ...it vanishes, and he loses a hit; with some left, that is all
CEBF LD HL,HITS
CEC2 DEC (HL)
CEC3 RET NZ
This entry point is used by the routine at VILLAIN_WANDER.
KNIGHT_KILLED CEC4 LD A,(KNIGHT_COLUMN) his life ends: his cell, facing and flags into the start records, so the next life starts here
CEC7 LD (START_U_CELL),A
CECA LD A,(KNIGHT_ROW)
CECD LD (START_V_CELL),A
CED0 LD A,(KNIGHT_FACING)
CED3 LD (START_FACING),A
CED6 LD A,(KNIGHT_FLAGS)
CED9 LD (START_FLAGS),A
CEDC LD A,$0C both his records vanish; NEW_LIFE starts the next life when that has run
CEDE LD (KNIGHT),A
CEE1 LD (KNIGHT_TOP),A
CEE4 RET
MONSTER_SHOT CEE5 LD (IY+$00),$0C the antibody and the monster both vanish
CEE9 LD (IX+$00),$0C
MONSTER_SCORE CEED LD BC,$0005 5 on the score
CEF0 JP ADD_SCORE
MONSTER_OUT_OF_RANGE CEF3 LD (IX+$00),$00 the record empty
CEF7 RET
The score's digits end in two that nothing adds to (the byte after SCORE_LOW, cleared at each game and printed with the rest by ADD_SCORE), so 5 shows as 500.
Prev: CE79 Up: Map Next: CEF8