Jump to content

Vertical Blank, how to restore?

Recommended Posts

I understand that it would be good practice to "restore" the previous VBI routine address when "unhooking" a VBI routine that is no longer used.


But where would I get the address to restore to from? Can I simply read it from VVBLKI?


Do I assume correctly that if VBI program A is installed first and saves the correct address to restore to, and VBI program B is installed thereafter, uninstalling A would kill B as well as A knows nothing of B. Or ist there a defined way to tell a "previous" VBI routine about another one installed later?






Share this post

Link to post
Share on other sites

On the computer it's easy to restore to the system defaults since they're in the system Jump Table.


Immediate VBlank, either set VVBI to $E45F or copy the word at $E460 to $222.

Deferred, either set to $E462 or copy the word at $E463 to $224.


You could also do it via save/restore which would allow a previously user-defined one to continue working.

There's not really an arrangement for "chaining" - generally at a given time you take a VBlank vector and don't worry about the previous use. Of course you usually end Immediate VBlank routines by jumping back to the OS code though.

The danger with save/restore can be that if you call your init routine twice, then your routine might become the "old" as well and get restored to on exit. Way around that can be to do a compare, generally if the high byte of a VBlank vector in >= $C0 then it's pointing into the OS Rom.


For 5200, there's no jump table and good practice would be use save/restore method just in case a custom OS is installed (there's supposedly only 2 official OS versions).

5200 is a much more closed environment though, so anything on cart will usually get control and never pass it back to Dos, the OS or a running language like the computer.

  • Like 1

Share this post

Link to post
Share on other sites

>But where would I get the address to restore to from?

I always use the chaining method, i.e. I check if my pointer is already in:

- if yes, do nothing

- if no, save the current values in own buffer and restore them from there on exit, maybe even use them as end of my own VBI routine (if I want the previous routine to continue also).


This also works for the cases, where another program has installed an own handler that can run in parallel.
Of course that depends on the use-case.

  • Like 1

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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...