I was following this tutorial on Commodore 64 timer interrupts and tried to replicate it (except all I was planning on doing was changing the border color.) I noticed that my interrupt only occurs once, and never triggers again. I don't understand why. (Just as an aside, when I first tested this, I also had a scanline IRQ set up and it worked fine, except it also halted the main program and only interrupts could run!)
Here's a minimal reproducible example. The border color changes from light blue to light gray and never again (only one inc $D020
gets executed.) I tried changing the timer values a bit but it doesn't make a difference, the IRQ only happens once. What did I miss?
org $0801
;INIT CODE
db $0E,$08,$0A,$00,$9E,$20,$28,$32,$30,$36,$34,$29,$00,$00,$00
sei
lda #%01010010
STA $DC0F
;TIMER B COUNTS TIMER A UNDERFLOW
;LOAD START VALUE INTO TIMER,
;INDICATE TIMER UNDERFLOW ON PORT B BIT 7
LDA #$FF
STA $DC04
LDA #$00
STA $DC05 ;LOAD TIMER 1 WITH VALUE $00FF
LDX #$01
STX $DC06
DEX
STX $DC07 ;LOAD TIMER 2 WITH VALUE $0001
LDA #<IRQ
STA $0314
LDA #>IRQ
STA $0315 ;LOAD IRQ VECTOR WITH IRQ ROUTINE ADDR.
LDA #%00010001
STA $DC0E ;TURN ON TIMER 1 AND LOAD THE START VALUE
CLI
forever:
jmp forever
IRQ:
LDA #%01111111
STA $DC0D
LDA $DC0D ;IRQ ACK
INC $D020 ;UPTICK THE BORDER COLOR
pla
tay
pla
tax
pla
rti