Prev: $2B9F Up: Map Next: $2CA5
$2BB0: Check whether a shield has been hit or jumped up to
Used by the routines at $1042 and $176F.
Input
XY Coordinates of ERIC's hand or a catapult pellet
$2BB0 STX $56 Store the target x-coordinate at $56 and the target y-coordinate at $57.
$2BB2 STY $57
$2BB4 LDA #$58 Prepare to address the shield locations and status table at $58E0.
$2BB6 STA $4F
$2BB8 LDA #$E0
$2BBA STA $4E
$2BBC LDY #$2B We start with the last shield and work backwards.
$2BBE LDA ($4E),Y Pick up a shield y-coordinate.
$2BC0 CMP $57 Does it match the target y-coordinate?
$2BC2 BEQ $2BD1 Branch if so.
$2BC4 CPY #$01 Have we checked every shield yet?
$2BC6 BEQ $2BCE Return if so.
$2BC8 DEY Otherwise point at the next shield in the table.
$2BC9 DEY
$2BCA DEY
$2BCB JMP $2BBE Jump back to check it.
$2BCE JMP $2CA4 Return.
$2BD1 DEY Point at the shield's x-coordinate and pick it up.
$2BD2 LDA ($4E),Y
$2BD4 CMP $56 Does it match the target x-coordinate?
$2BD6 BEQ $2BE1 Branch if so.
$2BD8 CPY #$00 Have we checked every shield yet?
$2BDA BEQ $2BCE Return if so.
$2BDC DEY Otherwise point at the next shield in the table.
$2BDD DEY
$2BDE JMP $2BBE Jump back to check it.
A shield has been hit.
$2BE1 LDA $46 Pick up the game mode indicator from $46.
$2BE3 CMP #$01 Have all the shields been flashed yet?
$2BE5 BEQ $2BFE Branch if not.
$2BE7 CMP #$03 Has ERIC opened the safe?
$2BE9 BEQ $2BEE Branch if so.
$2BEB JMP $2CA0 Jump forward.
$2BEE INY Point at the shield's status byte and pick it up.
$2BEF INY
$2BF0 LDA ($4E),Y
$2BF2 BNE $2BF7 Branch if the shield is flashing.
$2BF4 JMP $2CA0 Otherwise jump forward to terminate the pellet's flight.
$2BF7 LDA #$00 Set the shield's status byte to 0: it is no longer flashing.
$2BF9 STA ($4E),Y
$2BFB JMP $2C0B Jump forward.
$2BFE INY Point at the shield's status byte and pick it up.
$2BFF INY
$2C00 LDA ($4E),Y
$2C02 BEQ $2C07 Branch if the shield is not flashing.
$2C04 JMP $2CA0 Otherwise jump forward to terminate the pellet's flight.
$2C07 LDA #$01 Set the shield's status byte to 1: it is flashing.
$2C09 STA ($4E),Y
$2C0B LDA $57 Pick up the target y-coordinate from $57.
$2C0D CMP #$07 Is the shield on the top floor?
$2C0F BCC $2C1F Branch if so.
$2C11 CMP #$0E Is the shield on the middle floor?
$2C13 BCC $2C1A Branch if so.
$2C15 LDA #$28 A shield on the bottom floor is worth 400 points.
$2C17 JMP $2C21 Jump forward.
$2C1A LDA #$14 A shield on the middle floor is worth 200 points.
$2C1C JMP $2C21 Jump forward.
$2C1F LDA #$0A A shield on the top floor is worth 100 points.
$2C21 JSR $1D37 Add to the score and print it.
$2C24 LDA #$01 Set the sound effect identifier at $2C to 1: a shield has been hit.
$2C26 STA $2C
$2C28 LDA #$11 Initialise the sound effect timer at $2D.
$2C2A STA $2D
$2C2C INC $D9 Increment the shield counter at $D9.
$2C2E LDA $D9 Pick up the new value of the shield counter.
$2C30 CMP #$0F Have all 15 shields been hit?
$2C32 BEQ $2C37 Branch if so.
$2C34 JMP $2CA0 Otherwise jump forward to terminate the pellet's flight.
All 15 shields have been hit. This entry point is used by the routine at $176F when ERIC has opened the safe.
$2C37 LDA #$00 Reset the shield counter at $D9 to 0.
$2C39 STA $D9
$2C3B INC $46 Increment the game mode indicator at $46.
$2C3D LDA $46 Pick up the new value of the game mode indicator.
$2C3F CMP #$04 Has the last shield just been unflashed?
$2C41 BEQ $2C57 Branch if so.
$2C43 CMP #$02 Has the last shield just been flashed?
$2C45 BEQ $2C4C Branch if so.
$2C47 LDA #$C8 2000 points will be awarded.
$2C49 JMP $2C4E Jump forward.
$2C4C LDA #$64 1000 points will be awarded.
$2C4E JSR $1D37 Add to the score and print it.
$2C51 JSR $BA48 Play the 'Got all shields' tune.
$2C54 JMP $2CA0 Jump forward to terminate the pellet's flight.
$2C57 LDA #$01 Reset the game mode indicator to 1: ERIC has gone up a year.
$2C59 STA $46
$2C5B INC $7D 5000 points will be awarded.
$2C5D LDA #$F4
$2C5F JSR $1D37 Add to the score and print it.
$2C62 JSR $292F Generate a new safe combination code.
$2C65 JSR $2AAA Set MR CREAK's birth year.
$2C68 LDA #$08 Store the width (in character cells) of the area in which the WELL DONE message will be printed at $9D.
$2C6A STA $9D
$2C6C LDA #$46 Store $4680 (WELL DONE! GO) at $D6.
$2C6E STA $D7
$2C70 LDA #$80
$2C72 STA $D6
$2C74 JSR $2005 Write this message into the text graphic buffer.
$2C77 JSR $213B Centre the text in the text graphic buffer.
$2C7A LDX #$10 These are the coordinates at which to print the first line of text.
$2C7C LDY #$15
$2C7E JSR $3868 Copy the text graphic buffer to the screen.
$2C81 LDA #$90 Store $4690 (UP A YEAR) at $D6.
$2C83 STA $D6
$2C85 JSR $2005 Write this message into the text graphic buffer.
$2C88 JSR $213B Centre the text in the text graphic buffer.
$2C8B LDX #$10 These are the coordinates at which to print the second line of text.
$2C8D LDY #$17
$2C8F JSR $3868 Copy the text graphic buffer to the screen.
$2C92 LDA #$00 Set the safe status indicator at $D5 to $00: the safe is not flashing.
$2C94 STA $D5
$2C96 LDA #$01 Set the LSB and MSB of the lesson clock to 1. The bell will ring soon.
$2C98 STA $40
$2C9A STA $FD
$2C9C JSR $BA00 Play the theme tune.
$2C9F RTS
$2CA0 LDA #$01 Set the remaining distance for the pellet to travel to 1, ensuring that it is terminated on the next pass.
$2CA2 STA $B2
$2CA4 RTS
Prev: $2B9F Up: Map Next: $2CA5