6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 5:39 pm

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Mon Dec 24, 2018 6:30 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8509
Location: Midwestern USA
lordbubsy wrote:
I got it working!

Interrupt Service Routine:
Code:
interrupt
         pha
         phx
         phy
         lda   isr
         and   #%00001000     ;check if interrupt is caused by C/T
         beq   endirq         ;no? exit irq
         jsr   playmusic      ;play music
         lda   rop12          ;clear counter ready interrupt status bit ($bf0f)  <———
endirq
         ply
         plx
         pla
         rti

Belated response to the above. The indicated instruction should be executed before the playmusic subroutine is called. In any wired-OR interrupt circuit, a finite amount of time will elapse after the cause of an IRQ is cleared before the microprocessor will see that no IRQ is pending. If you wait too long to clear the IRQ the MPU may still think it's being interrupted when the RTI is executed at the end of your interrupt service routine (IS). The result will be a spurious interrupt—an interrupt with no apparent cause, which in some cases can result in system fatality. It wouldn't be a problem with the above code, but may become a problem once you add more to your ISR.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 24, 2018 12:36 pm 
Offline

Joined: Wed Sep 11, 2013 8:43 pm
Posts: 207
Location: The Netherlands
Thanks for pointing that out BDD!

I’ve ANDed all interrupt lines in the CPLD.
Code:
IRQB            <= N_VIA0IRQ and N_VDPIRQ and N_DUARTIRQ and N_SPIIRQ;


I added a second IRQ, in this case from the VDP. It creates an IRQ when scan line 200 has reached. The IS routine scrolls the screen one pixel to the left and one pixel up, each 60th of a second.

So there are two interrupts independently going on. I’m amazed how well this works, SID music is playing without hick-ups, and the screen scrolls completely smooth.
Attachment:
20181220_212118.jpg
20181220_212118.jpg [ 3.86 MiB | Viewed 766 times ]

Sorry for the blurry picture, but it was uhm, in motion. :)
At the beginning of the scroll screen routine I changed the background color of the screen to green, at the end of the routine I changed it back to black. As a result you can see how much (little) raster time it takes to scroll the screen. The green raster line is visible at the bottom of the screen underneath the text “Test Screen”.
I did the same thing for the playmusic routine by changing the background color of the screen to red. Because the music isn’t playing in sync with the refresh rate of the screen, the red bars appear randomly on the screen. You can also see that the playmusic routine takes a little more time.

Here is the interrupt routine I'm using:
Code:
interrupt
        pha
        phx
        phy

        +vrfs   1               ; Read from vdp status register 1
        and     #%00000001      ; check if interrupt is caused by vdp scanline
        beq     sidirq          ; no? sid irq

        +vwtr   7,$c            ; change background color to green
        jsr     scrollscreen    ; scroll screen one pixel up and left
        +vwtr   7,$1            ; change background color to black
sidirq
        lda     isr
        and     #%00001000      ; check if interrupt is caused by C/T
        beq     endirq          ; no? exit irq
        +vwtr   7,$6            ; change background color to red
        lda     rop12           ; clear counter ready interrupt status bit
        jsr     playmusic       ; play music
        +vwtr   7,$1            ; change background color to black
endirq
        ply
        plx
        pla
        rti


_________________
Marco


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 39 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: