Prev: 6C9C Up: Map Next: 6CD2
6CAC: Check whether any characters have been hit by a fist, pellet or conker
Used by the routines at 6C9C, 74C8 and 76AC. Returns with the carry flag reset if someone is in the same location as the fist, pellet or conker, and with D holding that person's character number.
Input
B Number of potential victims to check
D Character number of the first potential victim to check
H Puncher's, pellet's or conker's character number
6CAC EX DE,HL
6CAD LD L,$01 Point HL at byte 0x01 of the next potential target's character buffer
6CAF LD E,L Point DE at byte 0x01 of the puncher's, pellet's or conker's character buffer
6CB0 LD A,(DE) A=x-coordinate of the fist/pellet/conker
6CB1 CP (HL) Does this match the target character's x-coordinate?
6CB2 JR Z,$6CBA Jump if so
6CB4 INC H Move to the next potential target
6CB5 DJNZ $6CAD Jump back until all potential targets have been checked
6CB7 EX DE,HL
6CB8 SCF Signal: no character was hit
6CB9 RET
A potential victim of the fist, pellet or conker was found at the right x-coordinate. What about the y-coordinate?
6CBA INC L Point HL at byte 0x02 of the next potential target's character buffer
6CBB INC E Point DE at byte 0x02 of the puncher's, pellet's, or conker's character buffer
6CBC LD A,(DE) A=y-coordinate of the fist/pellet/conker
6CBD CP (HL) Does this match the target character's y-coordinate?
6CBE JR NZ,$6CB4 Jump back to consider the next character if not
The potential victim's coordinates are a perfect match.
6CC0 LD A,H A=number of the stricken character
6CC1 CP $D2 Was ERIC hit?
6CC3 JR Z,$6CCD Jump if so
6CC5 LD L,$12 Bytes 0x11 and 0x12 of the character's buffer may hold the address of an uninterruptible subcommand routine (which would prevent him from being knocked over); pick up the MSB in A
6CC7 LD A,(HL)
6CC8 AND A Can this character be knocked over at the moment?
6CC9 JR NZ,$6CB4 Jump back to consider the next character if not
6CCB EX DE,HL Transfer the stricken character's number to D
6CCC RET
ERIC was the potential victim.
6CCD LD A,($7FFB) Collect ERIC's status flags from 7FFB; now A=0 unless ERIC is engaged in some activity other than walking
6CD0 JR $6CC8
Prev: 6C9C Up: Map Next: 6CD2