I know how to replace the VBL exception handler upon startup of my program, and restore it again upon exit but what I'd like to do is add a little bit of code to the existing VBL handler
I'm sure I had heard in the past that the trick is to point the exception vector to your code, do you thing, and then jump to the old handler's address, but I can't for the life of me make it work.
Am I barking up the wrong tree?
Code: Select all
... preamble ...
main:
; supexec hook_vbl
pea hook_vbl
move.w #38,-(sp)
trap #14 ; xbios
addq.l #6,sp
; some code
; cconin (wait for key)
move.w #1,-(sp)
trap #1
addq.l #2,sp
; supexec restore_vbl
pea restore_vbl
move.w #38,-(sp)
trap #14 ; xbios
addq.l #6,sp
rts
; end of main
hook_vbl:
move.w #$2700,sr ; disable interrupts
move.l $70.w,old_vbl ;save old vbl
move.l #vbl,$70.w ; insert my vbl
move.w #$2300,sr ; re-enable interrupts
rts
restore_vbl:
move.w #$2700,sr ; disable interrupts
move.l (old_vbl),$70.w ; restore old vbl
move.w #$2300,sr ; re-enable interrupts
rts
vbl:
; imaginary code here
rte
old_vbl:
ds.l 1
Cheers,
BW