Prev: F4CD Up: Map Next: F4F1
F4D2: Get the attribute file address of a pellet's potential target or the safe
Used by the routines at 6DEF (to check whether a shield has been hit) and F726 (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
F4D2 LD HL,$7F00 7F00 holds the leftmost column of the skool on screen (0-64)
F4D5 LD A,E Set A to the true x-coordinate of the potential target
F4D6 AND $7F
F4D8 SUB (HL) Return with the carry flag set if the pellet is off-screen to the left
F4D9 RET C
F4DA CP $20 The screen is 32 columns wide
F4DC CCF Return with carry flag set if the pellet is off-screen to the right
F4DD RET C
The potential target is on-screen.
F4DE LD L,A L=screen x-coordinate (0-31) of the potential target
F4DF LD A,D A=screen y-coordinate (2, 8 or 14) of the potential target
F4E0 SUB $98
F4E2 RRCA A=0x40 (top floor), 0x01 (middle floor), or 0xC1 (bottom floor
F4E3 RRCA
F4E4 RRCA
F4E5 LD H,A Save this floor indicator in H for now
F4E6 AND $E0 A=0x40 (top floor), 0x00 (middle) or 0xC0 (bottom)
F4E8 ADD A,L Add the screen x-coordinate to get the LSB of the attribute file address of the potential target
F4E9 LD L,A Copy the LSB to L
F4EA LD A,H A=0x00 (top floor) or 0x01 (middle floor or bottom floor)
F4EB AND $03
F4ED ADD A,$58 Add 0x58 to get the MSB of the attribute file address of the potential target
F4EF LD H,A Copy the MSB to H
F4F0 RET Return with the carry flag reset
Prev: F4CD Up: Map Next: F4F1