| Routines

62674: Get the attribute file address of a pellet's potential target or the safe

Used by the routines at 28143 (to check whether a shield has been hit) and 63270 (to make the safe flash). If the pellet's potential target or the safe is on-screen, this routine returns with the carry flag reset and HL holding the attribute file address.
Input
D | Target y-coordinate
E | 128 + target x-coordinate
62674 | LD HL,32512 | 32512 holds the leftmost column of the skool on screen (0-64)
62677 | LD A,E | Set A to the true x-coordinate of the potential target
62678 | AND 127
62680 | SUB (HL) | Return with the carry flag set if the pellet is off-screen to the left
62681 | RET C
62682 | CP 32 | The screen is 32 columns wide
62684 | CCF | Return with carry flag set if the pellet is off-screen to the right
62685 | RET C
The potential target is on-screen.
62686 | LD L,A | L=screen x-coordinate (0-31) of the potential target
62687 | LD A,D | A=screen y-coordinate (2, 8 or 14) of the potential target
62688 | SUB 152
62690 | RRCA | A=64 (top floor), 1 (middle floor), or 193 (bottom floor
62691 | RRCA
62692 | RRCA
62693 | LD H,A | Save this floor indicator in H for now
62694 | AND 224 | A=64 (top floor), 0 (middle) or 192 (bottom)
62696 | ADD A,L | Add the screen x-coordinate to get the LSB of the attribute file address of the potential target
62697 | LD L,A | Copy the LSB to L
62698 | LD A,H | A=0 (top floor) or 1 (middle floor or bottom floor)
62699 | AND 3
62701 | ADD A,88 | Add 88 to get the MSB of the attribute file address of the potential target
62703 | LD H,A | Copy the MSB to H
62704 | RET | Return with the carry flag reset