Back to Skool Routines
27820: Check if any characters are in front of fist or pellet
Used by the routines at 27804, 29896 and 30380. Returns with the carry flag reset if someone was in the same location as the fist or pellet, and D holding that person's character number.
B Number of characters to check
D Number of first character to check
H Puncher's or pellet's character number
27820 EX DE,HL
27821 LD L,1 Point HL at byte 1 of the next potential target's character buffer
27823 LD E,L Point DE at byte 1 of the pellet's or puncher's character buffer
27824 LD A,(DE) A=x-coordinate of pellet or puncher's fist
27825 CP (HL) Does this match the target character's x-coordinate?
27826 JR Z,27834 Jump if so
27828 INC H Move to the next potential target
27829 DJNZ 27821 Jump back until all potential targets have been checked
27831 EX DE,HL
27832 SCF Signal: no character was hit
27833 RET
A potential victim of the pellet or fist was found at the right x-coordinate. What about the y-coordinate?
27834 INC L Point HL at byte 2 of the next potential target's character buffer
27835 INC E Point DE at byte 2 of the pellet's or puncher's character buffer
27836 LD A,(DE) A=y-coordinate of pellet or puncher's fist
27837 CP (HL) Does this match the target character's y-coordinate?
27838 JR NZ,27828 Jump back to consider the next character if not
The potential victim's coordinates are a perfect match.
27840 LD A,H A=number of stricken character
27841 CP 210 Was ERIC hit?
27843 JR Z,27853 Jump if so
27845 LD L,18 Bytes 17 and 18 of the character's buffer may hold the address of a routine currently controlling that character (which would prevent him from being knocked over); pick up the MSB in A
27847 LD A,(HL)
27848 AND A Can this character be knocked over at the moment?
27849 JR NZ,27828 Jump back to consider the next character if not
27851 EX DE,HL Transfer the stricken character's number to D
27852 RET
ERIC was the potential victim.
27853 LD A,(32763) A=0 unless ERIC is engaged in some activity other than walking
27856 JR 27848