 .OPT NO LIST›;  SAVE #D1:INTERUPT.M65›;›;›;  LOAD #D1:INIT.M65›;›  LIST› .PAGE "Interrupt Handler"› *= $C000›;›OSROM› .WORD $9211 rom c/sum› .BYTE $10   day bcd rev date› .BYTE $05   month "› .BYTE $83   year  "› .BYTE 0     Option byte› .BYTE "BB"  Part num. Alpha› .BYTE $00   ; "    "  bcd› .BYTE $00   ; "    "    "› .BYTE $01   ; "    "    "› .BYTE 2     Rev num›;›INTINI› LDA #$40    Interrupt› STA NMIEN   handler init› LDA TRIG3› STA GINTLK› RTS›;›NMI› BIT NMIST   Check for dli› BPL ?NODLI  Skip if not› JMP (VDSLST) else exec dli›;›?NODLI› CLD         Must be Vbi› PHA         cuz Reset doesn't› TXA         come here.› PHA› TYA         When pulled:› PHA         y,x,a,p,rti› STA NMIRES  clear nmist› JMP (VVBLKI) to dosysvbv›;›IRQ› CLD         Default irq› JMP (VIMIRQ) handler follows›;›?REGIRQ› PHA         right here› LDA IRQST› AND #$20    Serial in ready?› BNE ?NOSERIN Go if not› LDA #$DF    Process Serin› STA IRQEN   Clear int› LDA POKMSK  Re-enable all› STA IRQEN   as set by user› JMP (VSERIN) jmp xserin in sio›;›?NOSERIN› TXA         Save x on stack› PHA› LDA $D1FF   Check hardware› AND PDMSK   select for PDev› BEQ ?NOPDEV int. Go if not› JMP (VPIRQ) Process PDevice›;›?NOPDEV› LDX #6›;›?WHATIRQ› LDA ?IRQTYP,X› CPX #5      Seroc?› BNE ?NOSEROC Skip if not› AND POKMSK  also skip if› BEQ ?NXTTYP not enabled›;›?NOSEROC› BIT IRQST› BEQ ?GOTTYP›;›?NXTTYP› DEX         No match, check› BPL ?WHATIRQ next› JMP ?PIA?   Go check PIA›;›?GOTTYP› EOR #$FF    Clear int› STA IRQEN› LDA POKMSK  Reset irqen as› STA IRQEN   set by user› CPX #0      Branch if not› BNE ?XIRQHDLR the Break key› LDA KEYDIS  or is and keybd› BNE ?PIA?   is disabled›;›?XIRQHDLR› LDA ?IRQOFF,X› TAX         jump to irq› LDA VDSLST,X handler› STA JVECK› LDA VDSLST+1,X› STA JVECK+1› PLA› TAX› JMP (JVECK)›;›?XBRKKY› LDA #0      Break Key Irq› STA BRKKEY  Clear flag› STA SSFLAG  Kill freeze› STA CRSINH  Restore cursor› STA ATRACT  Kill Atract› PLA         Restore accum.› RTI›;›?PIA?› PLA         Check for PIA› TAX         interrupt› BIT PACTL   Branch if not› BPL ?NOPORTA vprced› LDA PORTA   Else clear int› JMP (VPRCED) and process›;›?NOPORTA› BIT PBCTL   Check for› BPL ?BRKOPCODE Vinter› LDA PORTB   Clear int› JMP (VINTER) and procss›;›?BRKOPCODE› PLA› STA JVECK   Save a temporary› PLA         Pull flags› PHA         and re-save› AND #$10    Test for Brk opcode› BEQ ?NOFIND go if not› LDA JVECK   Restore stack› PHA         and› JMP (VBREAK) process Brk›;›?NOFIND› LDA JVECK   no id, fix› PHA         stack and exit›;›?PLARTI› PLA›;›RTI› RTI›;›;›?IRQTYP› .BYTE $80   Break key› .BYTE $40   Keyboard› .BYTE $04   Timer4› .BYTE $02   Timer2› .BYTE $01   Timer1› .BYTE $08   SerOc› .BYTE $10   SerOr› .BYTE $20   SerIn›;›?IRQOFF› .BYTE 54    Brkkey Offsets› .BYTE 8     Vkybd   from› .BYTE 20    Vtimr3  vdslst› .BYTE 18    Vtimr2› .BYTE 16    Vtimr1› .BYTE 14    Vseroc› .BYTE 12    Vseror› .BYTE 10    Vserin›;›LOCKUP› JMP LOCKUP›;›;›DOSYSBV› INC RTCLOK+2 update› BNE ?ATRACT? clok and› INC ATRACT  atract (starts› INC RTCLOK+1 ;256/60*128 "› BNE ?ATRACT? after keypress› INC RTCLOK  i.e. 9'06"›;›?ATRACT?› LDA #$FE    process› LDX #0      atract mode› LDY ATRACT  skip if less› BPL ?XATRACT than 128› STA ATRACT  execute atract› LDX RTCLOK+1 random value› LDA #$F6    half luminance›;›?XATRACT› STA DRKMSK› STX COLRSH› LDA COLOR1› EOR COLRSH  reverse hue› AND DRKMSK  cut luminance› STA COLPF1  set it› LDX #0      Process timer1› JSR ?DECTMR used by sio› BNE ?CRITIC? Not expired› JSR ?XTIMR1 handle if due›;›?CRITIC?› LDA CRITIC  skip 2nd› BNE ?EXITEARLY stage if› TSX         critic or if› LDA $0104,X interrupt flag› AND #4      set at entry› BEQ ?STAGE2›;›?EXITEARLY› JMP DOXITBV›;›;›?STAGE2› LDA TRIG3   Cartridge› CMP GINTLK  changed?› BNE LOCKUP  Yes, quit.› LDA PENV    Update light pen› STA LPENV   shadow regs› LDA PENH› STA LPENH› LDA SDLSTH  update antic› STA DLISTH  location› LDA SDLSTL› STA DLISTL› LDA SDMCTL› STA DMACTL› LDA GPRIOR  also gtia› STA PRIOR› LDA VSFLAG  Time to scroll?› BEQ ?CLRCONSOL Not yet› DEC VSFLAG  Scroll screen› LDA #8› SEC         Put number of› SBC VSFLAG  scan lines to› AND #7      fine scroll into› STA VSCROL  Antic›;›?CLRCONSOL› LDX #8› STX CONSOL  clear consol›;›?PMATRACT› CLI        Atract mode for› LDA PCOLR0,X player-missiles› EOR COLRSH› AND DRKMSK› STA COLPM0,X› DEX› BPL ?PMATRACT› LDA CHBAS   Update charset› STA CHBASE  location› LDA CHACT   and display› STA CHACTL  mode› LDX #2› JSR ?DECTMR Process Cdtmv2› BNE ?OTHERTMR? Not yet› JSR ?XTIMR2 execute cdtmv2›;›?OTHERTMR?› LDX #2    process›;›?TMRLOOP› INX         timers 3-5› INX› LDA CDTMV1,X› ORA CDTMV1+1,X› BEQ ?NXTTIMR› JSR ?DECTMR› STA CDTMA1,X›;›?NXTTIMR› CPX #8› BNE ?TMRLOOP› LDA SKSTAT  Last key still› AND #4      pressed?› BEQ ?KEYTIM Yes› LDA KEYDEL  delay expired?› BEQ ?KEYTIM› DEC KEYDEL  Else dec it›;›?KEYTIM› LDA SRTIMR  Now 0?› BEQ ?XSTICK1 Skip if so› LDA SKSTAT  Last key still?› AND #4› BNE ?KEYREPEXIT No skip› DEC SRTIMR  Time now 1› BNE ?XSTICK1 no, skip› LDA KEYDIS  Keyboard off? *› BNE ?XSTICK1 Yes, skip    *› LDA KEYREP  Reset timer› STA SRTIMR› LDA KBCODE› CMP #159    Control 1?› BEQ ?XSTICK1 yes, skip› CMP #131    Control f1?   *› BEQ ?XSTICK1 yes, ignore  *› CMP #132    Control f2?   *› BEQ ?XSTICK1 ignore       *› CMP #148    Control f4?   *› BEQ ?XSTICK1 ignore       *› AND #$3F    Mask Shft/Ctrl› CMP #17     Help?› BEQ ?XSTICK1 ignore› LDA KBCODE  repeat key› STA CH      press› JMP ?XSTICK1›;›?KEYREPEXIT› LDA #0   Reset timer› STA SRTIMR›;›?XSTICK1› LDA PORTA› LSR A       update stick› LSR A       and paddle› LSR A       shadow regs› LSR A› STA STICK1› STA STICK3  ;*› LDA PORTA› AND #$0F› STA STICK0› STA STICK2  ;*› LDA TRIG0› STA STRIG0› STA STRIG2  ;*› LDA TRIG1› STA STRIG1› STA STRIG3  ;*› LDX #3›;›?PADLOOP› LDA POT0,X  Read pots› STA PADDL0,X and save› STA PADDL4,X ;*› DEX› BPL ?PADLOOP› STA POTGO   reset pot scan› LDX #2› LDY #1›;›?PTRIGLOOP› LDA STICK0,Y› LSR A› LSR A› LSR A› STA PTRIG1,X› STA PTRIG5,X ;*› LDA #0› ROL A› STA PTRIG0,X› STA PTRIG4,X ;*› DEX› DEX› DEY› BPL ?PTRIGLOOP› JMP (VVBLKD) End of vbi›;›?XTIMR1› JMP (CDTMA1)›;›;›?XTIMR2› JMP (CDTMA2)›;›;›?DECTMR› LDY CDTMV1,X Decrement› BNE ?DECIT  countdown timers› LDY CDTMV1+1,X› BEQ ?EXITDECTMR› DEC CDTMV1+1,X›;›?DECIT› DEC CDTMV1,X› BNE ?EXITDECTMR› LDY CDTMV1+1,X› BNE ?EXITDECTMR› LDA #0      return 0 and +ve› RTS         if timer expired›;›?EXITDECTMR› LDA #$FF else› RTS         non0 and -ve›;›DOSETBV› ASL A       Set interrupt› STA INTEMP  vector or timer› TXA› LDX #5› STA WSYNC   Wait for hsync›;›?WAIT5› DEX         Waste 24 cycles› BNE ?WAIT5› LDX INTEMP› STA VIMIRQ+1,X› TYA› STA VIMIRQ,X› RTS›;›DOXITBV› PLA         Exit vblank nmi› TAY› PLA› TAX› PLA› RTI›