Jump to content
xzerix

Starting out with VBI

Recommended Posts

Hi all,

 

I'm starting out with VBIs. What I - eventually - want to do is have a table driven DLI with the counter telling it which line of the screen it's on being reset to zero during the VBI. I figured this gives me the greatest flexibility over using VCOUNT especially if I only want interrupts on some lines and not all of them (and it means I can figure out how to do other stuff - play music? - during the VBI)

 

So I've tried:

0600: 68 PLA
0601: AD 24 02 LDA VVBLKD
0604: 8D 4D 06 STA $064D
0607: AD 25 02 LDA VVBLKD+1
060A: 8D 4E 06 STA $064E
060D: A2 06 LDX #$06
060F: A0 24 LDY #$24
0611: A9 07 LDA #$07
0613: 20 5C E4 JSR SETVBV

 

Which as I see it backs up the old interrupt vector to $064D/E and sets the interrupt vector to $0624, which is where the following routine resides...

 

0624: A9 00 LDA #$00
0626: 8D FF 06 STA $06FF
0629: 4C 62 E4 JMP XITVBV

 

Then I use X=USR(1536) which causes an immediate crash - so what am I doing wrong, please?

Share this post


Link to post
Share on other sites

Calling it from Basic? You need RTS after the JSR SETVBV.

 

Potential problem you might see is that the DLI might execute first up before the VBlank (and not necessarily the first of multiple DLIs).

 

You can avoid that with something like a wait:

 

 

  lda $14
waitvb
  cmp $14
  beq waitvb
  lda #$c0
  sta $d40e ; enable DLI when VBlank finishes
  • Like 1

Share this post


Link to post
Share on other sites

D'oh! That's it - of course!

 

Thanks very much Rybags. I'd previously tried your way (wait vbl, then enable interrupts) but I stumbled across the VBI way and then lost the link, so I had a go at doing it for myself.

 

If its not a daft question why DON'T I need to push the X, Y, and A to the stack and then pull them off after the routine - like a DLI - is it that the interrupt handler does it for itself?

 

Cheers!

Share this post


Link to post
Share on other sites

D'oh! That's it - of course!

 

Thanks very much Rybags. I'd previously tried your way (wait vbl, then enable interrupts) but I stumbled across the VBI way and then lost the link, so I had a go at doing it for myself.

 

If its not a daft question why DON'T I need to push the X, Y, and A to the stack and then pull them off after the routine - like a DLI - is it that the interrupt handler does it for itself?

 

Cheers!

If I understand correctly, the OS handles pushing and popping the registers for VBIs, but for DLIs the user must do this. Keep in mind, that DLIs are very limited in time, so try to keep the pushing and popping to a minimum,

Share this post


Link to post
Share on other sites

Since this is for DLI control, the immediate VBI is recommended over the deferred VBI. The deferred VBI can be skipped if a random IRQ happens to be going on when the VBI fires, and you don't want the DLI setup to be skipped. To do this, use VVBLKI instead of VVBLKD, and chain from the end of your code to the old handler instead of to XITVBV.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...