Prev: $3940 Up: Map Next: $3A90
$39C7: Interrupt routine
The address of this routine is placed at $FFFE by the routines at $2CD9, $BA00 and $BA48.
$39C7 PHA Push A onto the stack.
$39C8 TXA Push X onto the stack.
$39C9 PHA
$39CA TYA Push Y onto the stack.
$39CB PHA
This entry point is used by the routine at $BAB4.
$39CC INC $82 Increment the interrupt counter at $82.
$39CE DEC $2E Decrement the timing counter at $2E.
$39D0 DEC $C9 Decrement the shield/safe timing counter at $C9.
$39D2 BEQ $39D7 Branch if it's time to adjust the colours of the safe or any shields.
$39D4 JMP $3A41 Otherwise jump forward.
$39D7 LDA #$19 Reset the shield/safe timing counter at $C9 to $19.
$39D9 STA $C9
$39DB LDX #$0F Prepare to read 15 entries from the shield locations and status table at $58E0.
$39DD LDA #$58
$39DF STA $EE
$39E1 LDA #$E0
$39E3 STA $ED
$39E5 LDY #$00 Initialise the index.
$39E7 LDA ($ED),Y Pick up a shield's coordinates and copy them to $EF and $F0.
$39E9 STA $EF
$39EB INY
$39EC LDA ($ED),Y
$39EE STA $F0
$39F0 INY Pick up the shield's status byte.
$39F1 LDA ($ED),Y
$39F3 BEQ $3A22 Branch if it's zero (the shield is not flashing).
$39F5 LDA $EF Pick up the shield's x-coordinate.
$39F7 CMP $58 Is the shield off screen to the left?
$39F9 BCC $3A22 Branch if so.
$39FB CMP $59 Is the shield off screen to the right?
$39FD BCS $3A22 Branch if so.
$39FF STY $F4 Store the shield table index at $F4 temporarily.
$3A01 LDA #$CC Store $CC00 (the base address of the colour information) at $F2.
$3A03 STA $F3
$3A05 LDA #$00
$3A07 STA $F2
$3A09 LDY $F0 Pick up the shield's y-coordinate.
$3A0B BEQ $3A1B Branch if the y-coordinate is 0 (this never happens).
$3A0D LDA $F2 Adjust the colour information address stored at $F2 to the beginning of the row corresponding to the shield's y-coordinate.
$3A0F CLC
$3A10 ADC #$28
$3A12 BCC $3A16
$3A14 INC $F3
$3A16 STA $F2
$3A18 DEY
$3A19 BNE $3A0D
$3A1B LDA $EF Pick up the shield's x-coordinate.
$3A1D JSR $3A90 Update the colour information for this flashing shield.
$3A20 LDY $F4 Restore the shield table index from $F4.
$3A22 INY Point at the next entry in the shield table.
$3A23 DEX Have we checked every entry yet?
$3A24 BNE $39E7 Branch back if not.
$3A26 LDA $D5 Pick up the safe status indicator from $D5.
$3A28 BEQ $3A41 Branch unless the safe is flashing.
$3A2A LDA #$0A 10 is the x-coordinate of the safe.
$3A2C CMP $58 Is the safe off screen to the left?
$3A2E BCC $3A41 Branch if so.
$3A30 CMP $59 Is the safe off screen to the right?
$3A32 BCS $3A41 Branch if so.
$3A34 LDA #$CD Store $CD68 at $F2. This colour information address corresponds to the beginning of the row where the safe is.
$3A36 STA $F3
$3A38 LDA #$68
$3A3A STA $F2
$3A3C LDA #$0A 10 is the x-coordinate of the safe.
$3A3E JSR $3A90 Update the colour information for the safe.
$3A41 LDA $DC0D Acknowledge the interrupt.
$3A44 JSR $3940 Read the keyboard and store the result at $4C.
$3A47 LDA $4C Was a key pressed?
$3A49 BNE $3A85 Branch if so.
$3A4B LDA #$00 Prepare to read from data port A.
$3A4D STA $DC02
$3A50 LDA $DC00 Read from data port A.
$3A53 EOR #$FF Flip every bit.
$3A55 PHA Save the result temporarily.
$3A56 AND #$10 Keep only bit 4 (joystick fire button).
$3A58 BNE $3A7B Branch if the fire button was pressed.
$3A5A PLA Restore the joystick read result to A.
$3A5B LSR A Was the joystick moved up?
$3A5C BCC $3A63 Branch if not.
$3A5E LDA #$D1 Signal: joystick was moved up ('Q' with bit 7 set).
$3A60 JMP $3A83 Jump forward.
$3A63 LSR A Was the joystick moved down?
$3A64 BCC $3A6B Branch if not.
$3A66 LDA #$C1 Signal: joystick was moved down ('A' with bit 7 set).
$3A68 JMP $3A83 Jump forward.
$3A6B LSR A Was the joystick moved left?
$3A6C BCC $3A73 Branch if not.
$3A6E LDA #$CF Signal: joystick was moved left ('O' with bit 7 set).
$3A70 JMP $3A83 Jump forward.
$3A73 LSR A Was the joystick moved right?
$3A74 BCC $3A81 Branch if not.
$3A76 LDA #$D0 Signal: joystick was moved right ('P' with bit 7 set).
$3A78 JMP $3A83 Jump forward.
$3A7B PLA Restore the joystick read result to A.
$3A7C LDA #$46 Signal: joystick fire button was pressed ('F').
$3A7E JMP $3A83 Jump forward.
$3A81 LDA #$00 Signal: joystick was not moved.
$3A83 STA $4C Store the result of the joystick read at $4C.
$3A85 LDA #$FF Set all bits in the port A data direction register: every bit of port A can be read and written.
$3A87 STA $DC02
$3A8A PLA Restore Y from the stack.
$3A8B TAY
$3A8C PLA Restore X from the stack.
$3A8D TAX
$3A8E PLA Restore A from the stack.
$3A8F RTI
Prev: $3940 Up: Map Next: $3A90