Here is my code. It assumes a lot of things.
save=plotSScreen+200
;don't judge my save area - I will find a better one later
;It is safe as long as I don't pull up the graph since the homescreen does not affect it
set 7,(iy+28h)
ld hl,($9B84)
ld (save),hl
ld lh,($9B84+2)
ld (save+2),hl
ld hl,hook
ld de,save+4
push de
ld bc,HookEnd-Hook
ldir
pop hl
ld a,1
BCALL($4F66) ;sets the hook
ret
Hook:
db $83
push af
push af
ld hl,(save)
ld a,(save+2)
out (6),a
pop af
ld e,0
call CallHL
ld a,32 ;I did some experimentation and that seems to be the default value
out (6),a
pop af
ret
CallHL:
jp (hl)
HookEnd:
That is it. I'm sorry for the weird format. I copied it by hand from Mimas.
All this code is for testing. I realize how poorly it is written.