timing - Who's calling my interrupt handler if I have both CIAs turned off? -


i'm trying set simple raster interrupt handler change background color in given stripe. however, interrupt handler seems called time. (the code uses ca65's format)

.include "c64.inc"  row = 100  .segment "zpsave"  .segment "startup"          sei          ;; turn off basic , kernal rom         lda #$35         sta $01          ;; flush cia irqs         bit cia1_icr         bit cia2_icr          ;; turn off cia interrupts         lda #%011111111         sta cia1_icr         sta cia2_icr          ;; set target raster line         lda #%01111111         , vic_ctrl1         sta vic_ctrl1          lda #row         sta vic_hline          ;; enable vic interrupt         lda #%00000001         sta vic_imr          ;; install interrupt handler         lda #<isr         sta $fffe         lda #>isr         sta $ffff         cli          rts  .macro isr_pre         pha         txa         pha         tya         pha .endmacro  .macro isr_post         pla         tay         pla         tax         rti .endmacro  ;;; acknowledge vic interrupt .macro ack_vic         lda vic_irr         , #$01         sta vic_irr .endmacro  .proc isr         isr_pre         ack_vic          ;; uncommenting these lines works around problem         ;; lda vic_hline         ;; cmp #row         ;; bne exit          lda #1         sta vic_bordercolor         sta vic_bg_color0          ldx #50 :       dex         bne :-          lda #0         sta vic_bordercolor         sta vic_bg_color0  exit:   isr_post .endproc 

if comment out 3 lines marked "workaround" in above code, interrupt handler called time, not on (the start of) row row:

without workaround

if uncomment 3 lines, works, it's unstable, guess because of same unintended interrupts:

with workaround

i've found several problems code posted above, , fixing of them fixed problem:

  1. the bitmask turning off cia interrupts wrong (it accidentally 9 bits long) -- causing interrupt firings...
  2. the isr postscriptum macro missing pla restore a register -- screwed state royally, whatever happened old code more-or-less chance...
  3. the vic interrupt not flushed in interrupt setup code -- after fixing previous 2 problems, interrupts never triggered.
  4. there's nothing rts @ end of setup code, since turn off kernal , basic rom

so fixed code follows:

.include "c64.inc"  row = 100  ;;; acknowledge vic interrupt .macro ack_vic         lda vic_irr         , #$01         sta vic_irr .endmacro  .segment "zpsave"  .segment "startup"          sei          ;; turn off basic , kernal rom         lda #$35         sta $01          ;; flush cia irqs         bit cia1_icr         bit cia2_icr         ack_vic          ;; turn off cia interrupts         lda #%01111111         sta cia1_icr         sta cia2_icr          ;; set target raster line         lda #%01111111         , vic_ctrl1         sta vic_ctrl1          lda #row         sta vic_hline          ;; enable vic interrupt         lda #%00000001         sta vic_imr          ;; install interrupt handler         lda #<isr         sta $fffe         lda #>isr         sta $ffff         cli             jmp *  .macro isr_pre         pha         txa         pha         tya         pha .endmacro  .macro isr_post         pla         tay         pla         tax         pla         rti .endmacro  .proc isr         isr_pre         ack_vic          lda #1         sta vic_bordercolor         sta vic_bg_color0          ldx #50 :       dex         bne :-          lda #0         sta vic_bordercolor         sta vic_bg_color0  exit:   isr_post .endproc 

this results, expected, in solid white stripe. unknown reason, stripe starts @ middle of screen horizontally, guess that'd 1 separate question.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -