Marius Posted January 4, 2011 Share Posted January 4, 2011 Hi. I'm writing a program in which I have my own VBI routine. At the beginning of the program I have thise code: LDY #<VBI LDX #>VBI LDA #$06 JSR $E45C <the main routines of the program; not needed for this post to type that all over> VBI some code JMP $E45F This works perfect. But... the program itselfs has a normal EXIT (at some point there is a RTS, and the program exits to DOS) But then the VBI keeps running. How do I re-initialise the VBI so it is just the way it WAS before I had my program? Thanks Marius Quote Link to comment Share on other sites More sharing options...
Bryan Posted January 4, 2011 Share Posted January 4, 2011 I would imagine you'd need to save the original and call E45C again on exit. Quote Link to comment Share on other sites More sharing options...
Rybags Posted January 5, 2011 Share Posted January 5, 2011 Do the same as before, but with E4/5F in X/Y. Or if you're real fussy, LDY $E460 LDX $E461 But the save/restore method might be more desirable given that something before you might have already been using the vector, e.g. a Time display routine. You could even get real tricky and create a VBI chain, e.g. save the old vector and test the high byte, if it's less than $C0 then it means something is already using it. Quote Link to comment Share on other sites More sharing options...
Shawn Jefferson Posted January 5, 2011 Share Posted January 5, 2011 (edited) Here's how I did it (actually may have nicked this from someone else ) It doesn't take into account anything else that may have hooked the VBI before my program. SETVBV = $E45C ;vector to set VBLANK parameters XITVBV = $E462 ;vector to process deferred VBLANK _reset_vbi: lda #7 ; deferred vblank ldx #>XITVBV ; hi address of vbi routine ldy #<XITVBV ; lo address of vbi routine jsr SETVBV ; jump to os set vblank routine rts Edited January 5, 2011 by Shawn Jefferson Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted January 5, 2011 Share Posted January 5, 2011 yes, simply point to the exit routine XITVBV (depending on the VBL $e462 or $e45f) and with the OS routine SETVBV. As it sets the vectors in a safe mode. Quote Link to comment Share on other sites More sharing options...
Marius Posted January 5, 2011 Author Share Posted January 5, 2011 Is this also a good way? (EDIT: oh now I read that is just what Bryan advised...) The first thing in the program is: storing $222 and $223 in a 'safe place' (labels stored222 and stored223) ... and right before the end of the program (the RTS) I restore the info this way: LDY stored222 LDX stored223 LDA #$06 JSR e45c This worked too. I guess this is the 'safest' way... so that everyting was just the way it was before lauching the program. Am I right or this a wrong method? Thanks Marius p.s. Mapping the Atari writes that Stage1 VBI address is in VVBLKI ($222 and $223). Quote Link to comment Share on other sites More sharing options...
drac030 Posted January 5, 2011 Share Posted January 5, 2011 Save and restore is the best method. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.