Prev: 28102 Up: Map Next: 28211
28143: Check whether a shield has been hit
Used by the routine at 28102. Returns with the carry flag set if a shield was hit (either by a catapult pellet or by ERIC while jumping).
Input
D Target y-coordinate
E 128 + target x-coordinate
28143 LD A,(32746) 32746 holds the game mode indicator
28146 RRCA Are the shields hittable at the moment?
28147 RET NC Return if not (it's either demo mode, or ERIC's looking for the safe combination)
28148 RRCA Now bit 7 of C is reset if we're in 'flash the shields' mode, or set if in 'unflash the shields' mode
28149 LD C,A
28150 LD B,10 100 points for hitting a shield on the top floor
28152 LD A,D A=y-coordinate of the potential target
28153 CP 154 This is the y-coordinate of the shields on the top floor
28155 JR Z,28171 Jump if the pellet or ERIC's hand is at shield-height on the top floor
28157 CP 160 This is the y-coordinate of the shields on the middle floor
28159 LD B,20 200 points for hitting a shield on the middle floor
28161 JR Z,28171 Jump if the pellet or ERIC's hand is at shield-height on the middle floor
28163 LD B,40 400 points for hitting a shield on the bottom floor
28165 CP 166 This is the y-coordinate of the shields on the bottom floor
28167 JR Z,28171 Jump if the pellet or ERIC's hand is at shield-height on the bottom floor
28169 AND A Reset the carry flag to indicate that no shield was hit
28170 RET
The pellet or ERIC's hand is at the right height to hit a shield. Is it at the right x-coordinate?
28171 CALL 62674 Is the potential target on-screen?
28174 CCF
28175 RET NC Return with the carry flag reset if not
28176 LD A,(DE) A=attribute of the potential target
28177 AND 56 Return if the potential target is drawn in black paper or black ink (which is normally true only if it's not a shield, but is also true if a speech bubble has been drawn over a shield; in this case, the routine exits here, which is a bug)
28179 RET Z
28180 LD A,(DE)
28181 AND 7
28183 RET Z
28184 LD A,(DE) A=attribute of the shield
28185 XOR C Check whether we should make the shields flash or not flash, and return unless the flash status of the shield should be toggled
28186 RLCA
28187 RET C
28188 LD A,(DE) A=attribute of the shield
28189 XOR 128 Toggle the FLASH status of the shield
28191 LD (DE),A Insert the new attribute byte into the skool graphic data
28192 LD (HL),A Apply the new attribute on-screen
28193 LD A,B A=10 (top floor), 20 (middle) or 40 (bottom)
28194 CALL 27389 Add 100, 200 or 400 to the score and print it
28197 CALL 58604 Play the 'hit a shield' sound effect
28200 LD HL,32747 32747 holds the shield counter
28203 DEC (HL) One more shield hit
28204 SCF Set the carry flag to indicate that a shield was hit
28205 RET NZ Return unless the last shield was hit
28206 CALL 63668 All the shields have been hit; take appropriate action
28209 SCF Set the carry flag to indicate that a shield was hit
28210 RET
Prev: 28102 Up: Map Next: 28211