| Routines

29856: Check whether any adults were hit by the pellet, water, sherry or conker

Used by the routine at 29896. Returns with the zero flag set if a character was hit, and the stricken character's number in B.
Input
DE | Pellet/water/sherry/conker's coordinates
H | Pellet/water/sherry/conker's character number (213 or 214)
29856 | LD B,6 | There are six adult characters
This entry point is used by the routine at 30380 with B=5 (only five of the adults are pelletable) and H=213/214 (BOY WANDER's or ERIC's pellet).
29858 | LD C,H | Save the projectile's character number in C
29859 | LD H,200 | 200=MR WACKER
29861 | LD L,2 | Point HL at byte 2 of the potential target's character buffer
29863 | LD A,D | A=projectile's y-coordinate
29864 | CP (HL) | Does it match the y-coordinate of the character?
29865 | JR NZ,29889 | Jump if not
29867 | LD L,0 |
29869 | LD A,(HL) | A=character's animatory state
29870 | AND 135 | Is the character sitting on the floor facing left (already struck)?
29872 | CP 6
29874 | JR Z,29881 | Jump if so
29876 | DEC L | L=-1
29877 | CP 134 | Is the character sitting on the floor facing right (already struck)?
29879 | JR Z,29882 | Jump if so
29881 | INC L |
29882 | LD A,L | A=-1 if the character is sitting on the floor facing right, 0 if he's standing, or 1 if he's sitting on the floor facing left
29883 | LD L,1 | Byte 1 of the character's buffer holds his x-coordinate
29885 | ADD A,(HL) | Now A=x-coordinate of the character's head
29886 | CP E | Does it match the x-coordinate of the projectile?
29887 | JR Z,29892 | Jump if so
29889 | INC H | Next potential target
29890 | DJNZ 29861 | Jump back to consider any remaining characters
29892 | LD B,H | B=number of the character who was hit by the projectile (if any)
29893 | LD H,C | Restore the projectile's character number to H
29894 | RET | Return with the zero flag set if a character was hit