chapter8/CH8PRG2.SRC:

10 POKMSK =    0010
20 KBCODE =    $D209
30 VKEYBD =    $0208
40 IRQEN  =    $D20E
45 IRQST  =    IRQEN
46 VMIRQ  =    $0216
60        *=   $600
80 START  SEI  ;   DISABLE IRQS
90        LDA  VMIRQ ; REPLACE THE IRQ VECTOR
0100      STA  NBRK+1 ;WITH OUR OWN
0110      LDA  VMIRQ+1 ; ALL IRQS WILL
0120  STA  NBRK+2  GO TO NBRK
0130      LDA  #IRQ&255
0140      STA  VMIRQ
0150      LDA  #IRQ/256
0160      STA  VMIRQ+1
0170      CLI  ; ENABLE IRQS
0200      LDA  VKEYBD ; POINT KEY IRQ TO
0210      STA  JUMP+1; REP
0220      LDA  VKEYBD+1
0230      STA  JUMP+2
0240      LDA  #REP&255; VECTOR KEY IRQ
0250      STA  VKEYBD; LOW BYTE OF VECTOR
0260      LDA  #REP/256
0270      STA  VKEYBD+1
0280      RTS
0290      *=$639
0300 REP  LDA  KBCODE ; ALL KEY IRQS COME HERE
0310      AND  #$80 ; CHECK IF CONTROL HIT
0320      BEQ  JUMP ;IF NOT HIT THEN GO
0330      PLA  ; ELSE IGNORE CONTROL KEY
0340      RTI
0360 JUMP JMP  ; JUMP THIS CALLS THE OLD KEY IRQ
0375 IRQ  PHA  ; ALL IRQS COME HERE
0380      LDA  IRQST ; CHECK IF [BREAK]
0390      BPL  BREAK ; IF [BREAK] IRQ,BRANCH
0405      PLA  ; ELSE CALL OLD IRQ VECTOR
0410 NBRK JMP  NBRK ; CALL OLD IRQ VECTOR
0430 BREAK LDA  #$7F ; HERE IF [BREAK]
0440      STA  IRQST ; SHOW NO [BREAK]
0450      LDA  POKMSK
0460      STA  IRQEN
0462      PLA
0464      RTI ; RETURN AS IF NO [BREAK]
0470      *=  $02E2
0480      .WORD START

Back to previous page