Help with Timer Interrupt
Posted: Thu Feb 08, 2018 2:41 pm
Hi
I'm new to the forums and the VIC-20 was my second computer (first was ZX81). I never got beyond BASIC programming, all my M/C was on later machines, so after 36 years I thought I'd try some M/C on the VIC.
I am having some trouble getting interrupts working properly though, I have written the following code to test a VIA 2, T2 interrupt but it gets stuck in the interrupt routine. Instead of returning to the main loop once the RTI is called it jumps straight back to $FF72. I am debugging in VICE but it doesn't show what the 6522s are doing so it doesn't help much. I know it will be something simple but I can't see it for the life of me and I've tried google.
Grateful for any assistance, thanks.
Dave
Code posted below.
I'm new to the forums and the VIC-20 was my second computer (first was ZX81). I never got beyond BASIC programming, all my M/C was on later machines, so after 36 years I thought I'd try some M/C on the VIC.
I am having some trouble getting interrupts working properly though, I have written the following code to test a VIA 2, T2 interrupt but it gets stuck in the interrupt routine. Instead of returning to the main loop once the RTI is called it jumps straight back to $FF72. I am debugging in VICE but it doesn't show what the 6522s are doing so it doesn't help much. I know it will be something simple but I can't see it for the life of me and I've tried google.
Grateful for any assistance, thanks.
Dave
Code posted below.
Code: Select all
*=$1046
start
sei ;disable interrupts
lda #<my_irq
ldx #>my_irq
sta $314
stx $315 ;set up interrupt address
ldy #$FF
sty $9218
sty $9219 ;set V2 T2 counter
lda #$7f ;clear all via#2 interrupt enable bits
sta $921e
lda #$a0 ;enable T2 interrupt on via#2
sta $921e
lda $921b ;read aux control
and #$df ;clear T2 control bit
sta $921b ;so T2 is one shot counter
cli ;now enable interrupts
loop
lda #$ff
sta $900f
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
jmp loop
my_irq
;is it from V2 T2
lda $921d
and #$20
beq my_irq_end
lda #$0
sta $900f ;set border/screen colour
lda #$FF
sta $9218 ;set V2 T2 counter
sta $9219 ;this write should clear int flag
my_irq_end
pla
tay
pla
tax
pla
rti