| Routines

6DEF: Check whether a shield has been hit

Used by the routine at 6DC6. 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
6DEF | LD A,($7FEA) | 7FEA holds the game mode indicator
6DF2 | RRCA | Are the shields hittable at the moment?
6DF3 | RET NC | Return if not (it's either demo mode, or ERIC's looking for the safe combination)
6DF4 | RRCA | Now bit 7 of C is reset if we're in 'flash the shields' mode, or set if in 'unflash the shields' mode
6DF5 | LD C,A
6DF6 | LD B,$0A | 100 points for hitting a shield on the top floor
6DF8 | LD A,D | A=y-coordinate of the potential target
6DF9 | CP $9A | This is the y-coordinate of the shields on the top floor
6DFB | JR Z,$6E0B | Jump if the pellet or ERIC's hand is at shield-height on the top floor
6DFD | CP $A0 | This is the y-coordinate of the shields on the middle floor
6DFF | LD B,$14 | 200 points for hitting a shield on the middle floor
6E01 | JR Z,$6E0B | Jump if the pellet or ERIC's hand is at shield-height on the middle floor
6E03 | LD B,$28 | 400 points for hitting a shield on the bottom floor
6E05 | CP $A6 | This is the y-coordinate of the shields on the bottom floor
6E07 | JR Z,$6E0B | Jump if the pellet or ERIC's hand is at shield-height on the bottom floor
6E09 | AND A | Reset the carry flag to indicate that no shield was hit
6E0A | RET |
The pellet or ERIC's hand is at the right height to hit a shield. Is it at the right x-coordinate?
6E0B | CALL $F4D2 | Is the potential target on-screen?
6E0E | CCF |
6E0F | RET NC | Return with the carry flag reset if not
6E10 | LD A,(DE) | A=attribute of the potential target
6E11 | AND $38 | 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)
6E13 | RET Z
6E14 | LD A,(DE)
6E15 | AND $07
6E17 | RET Z
6E18 | LD A,(DE) | A=attribute of the shield
6E19 | 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
6E1A | RLCA
6E1B | RET C
6E1C | LD A,(DE) | A=attribute of the shield
6E1D | XOR $80 | Toggle the FLASH status of the shield
6E1F | LD (DE),A | Insert the new attribute byte into the skool graphic data
6E20 | LD (HL),A | Apply the new attribute on-screen
6E21 | LD A,B | A=10 (top floor), 20 (middle) or 40 (bottom)
6E22 | CALL $6AFD | Add 100, 200 or 400 to the score and print it
6E25 | CALL $E4EC | Play the 'hit a shield' sound effect
6E28 | LD HL,$7FEB | 7FEB holds the shield counter
6E2B | DEC (HL) | One more shield hit
6E2C | SCF | Set the carry flag to indicate that a shield was hit
6E2D | RET NZ | Return unless the last shield was hit
6E2E | CALL $F8B4 | All the shields have been hit; take appropriate action
6E31 | SCF | Set the carry flag to indicate that a shield was hit
6E32 | RET |