xbg wrote:
So thats my whole ISR...
I see you are using the 6526's timer B to generate IRQs. You should know that many 6526s have a defect that will cause the timer B interrupt to not work. Specifically, reading the interrupt status register one or two clock cycles before timer B is scheduled to underflow and interrupt may result in no interrupt occurring. Other than performing a "before and after" comparison on the timer contents, there is no workaround. As I recall, there was a 60 to 80 percent defect rate with these devices.
Also, you can make your code a bit more succinct:
Code:
int_routine pha
...you may need code here to differentiate
between an IRQ & a BRK instruction...
lda cia_icr ;read 6526's interrupt status...
;
; ——————————————————————————————————————————————————————————————
; If the above read operation occurs one or two Ø2 cycles before
; timer B is scheduled to interrupt, that interrupt may not occur
; & subsequent code may fail.
; ——————————————————————————————————————————————————————————————
;
lsr A ;timer A interrupt?
bcc check_timer_b ;no
;
inc sid_flag ;yes
;
check_timer_b lsr A ;timer B interrupt?
bcc check_uart ;no
;
; ———————————————————
; The above may fail!
; ———————————————————
;
inc tb_flag ;yes
;
check_uart lda uart_isr ;get int status register & ack
cmp #$06 ;line status register int (RX byte ready)
bne end_int
;
inc uart_flag
;
end_int pla
rti
Instead of doing specific comparisons on the 6526's status, you can just right-shift the accumulator and let carry tell you if the timer IRQ flag bits were or were not set. Also, note that there is no point in pushing registers that will not be used in the ISR, unless you like wasting clock cycles. Furthermore, your ISR makes no differentiation between an IRQ and BRK. If your foreground code has $00 in it and the 'C02 reads it as an opcode, that's a BRK and when it executes RTI it will land on the wrong address.
Lastly, the standard 6526 is rated for 1 MHz operation. The rarely seen 6526B was rated for 2 MHz operation. Set your clock accordingly! You'd be better off with the WDC 65C22, which can be clocked to 14 MHz and whose timer interrupts work as they should.