Code: Select all
10 ORG $5000
20 ORCC #$50 * Disable IRQ/FIRQ interrupts
30 LDX #ISR
40 CMPX $010D
50 BEQ DISBLE
60 ENABLE LDA $FF03 * Disable Frame Sync Interrupt
70 ANDA #$FE
80 STA $FF03
90 LDA $FF01 * Enable Horizontal Sync Interrupt
100 ORA #$01
110 STA $FF01
120 BRA SETVEC
130 DISBLE LDX #$9D3D
140 LDA $FF01 * Disable Horizontal Sync Interrupt
150 ANDA #$FE
160 STA $FF01
170 LDA $FF03 * Enable Frame Sync Interrupt
180 ORA #$01
190 STA $FF03
200 SETVEC STX $010D * Set secondary IRQ vector
210 ANDCC #$AF * Enable IRQ/FIRQ interrupts
220 RTS * Return to BASIC
230 ISR LDA $FF00 * Interrupt Service Routine
240 INC $0400
250 LDA $FF03 * Check for 50 Hz Frame Sync Flag
260 BMI BASIRQ
270 RTI
280 BASIRQ INC $0401
290 JMP $9D3D * Jump to BASIC's Interrupt Service Routine (Update TIMER etc)