General question: Does anyone know how to use the Menu hook? (and be willing to teach me how to use it)
I am familiar with how to use other hooks (home screen and key)
My current attempts have lead to some screwed up menus. (At least that much of the hook works)
I mainly use Axe, but can easily enough hash out a solution to a problem in assembly.
(I'm really just looking for some example code - I don't care if it is Axe or assembly and it doesn't even need to be commented!)
Thanks for any help! :)
WikiTI has the answer :)
See http://wikiti.brandonw.net/index.php?title=83Plus:Hooks:9BC0 or http://wikiti.brandonw.net/index.php?title=83PCE:Hooks:D02608 . I think both should work well.
Quote from: PT_ on September 20, 2016, 10:20:42 PM
WikiTI has the answer :)
See http://wikiti.brandonw.net/index.php?title=83Plus:Hooks:9BC0 or http://wikiti.brandonw.net/index.php?title=83PCE:Hooks:D02608 . I think both should work well.
Thanks, but I have already thoroughly covered wikiti.
I still seem to be missing something. Do you have any example code complete with the initialization of the hook to the execution? I know you use one in ICE. Even that code would be nice.
Well what do you want exactly then? Modify an OS menu? Replace the entries with your own 'tokens'?
Here is my code for the hooks in ICE. Since it's a combination of 3 hooks, I will post them all
InstallHooks:
ld hl, ICEAppvar
call _Mov9ToOP1
call _ChkFindSym
jr c, +_
call _Arc_Unarc
ld bc, 5 ; weird TI; it points HL to the address locating the memory, in the VAT, not the file type :/
add hl, bc
call _DelVar
_: ld hl, Hooks_end - KeyHook_start
call _CreateAppVar
push de
call _OP4ToOP1
pop de
inc de
inc de
ld hl, KeyHook_start
ld bc, Hooks_end - KeyHook_start
ldir
call _Arc_Unarc
call _ChkFindSym
ld hl, 19 ; archived program header+VAT entry
add hl, de
ld (hookDataStart), hl
call _SetGetCSCHook
ld de, KeyHook_end - KeyHook_start
add hl, de
call _SetMenuHook
ld de, MenuHook_end - MenuHook_start
add hl, de
jp _SetTokenHook
KeyHook_start:
.db 83h
cp 1Bh
ret nz
bit trace_is_pressed, (iy+myFlags)
jr z, +_
or 1
ld a, b
ret
_: ld a, (cxCurApp)
cp cxPrgmEdit
ld a, b
ret nz
res trace_is_pressed, (iy+myFlags)
cp skTrace
ret nz
set trace_is_pressed, (iy+myFlags)
ld a, skMath-1
inc a
ret
KeyHook_end:
MenuHook_start:
.db 83h
or a
jr z, ++_
cp a, 3
jr nz, +_
res trace_is_pressed, (iy+myFlags)
_: cp a
ret
_: bit trace_is_pressed, (iy+myFlags)
ret z
ld hl, (hookDataStart)
ld de, MenuHook_data - KeyHook_start
add hl, de
or 1
ret
MenuHook_data:
.db 4
.db 4, 3, 6, 5
.db 036h, 029h, 035h, 026h
.db 0FCh, 0B1h ; 1
.db 0FCh, 0B2h ; 2
.db 0FCh, 0B3h ; 3
.db 0FCh, 0B4h ; 4
.db 0FCh, 0B5h ; 5
.db 0FCh, 0B6h ; 6
.db 0FCh, 0B7h ; 7
.db 0FCh, 0B8h ; 8
.db 0FCh, 0B9h ; 9
.db 0FCh, 0BAh ; 10
.db 0FCh, 0BBh ; 11
.db 0FCh, 0BCh ; 12
.db 0FCh, 0BDh ; 13
.db 0FCh, 0BEh ; 14
.db 0FCh, 0BFh ; 15
.db 0FCh, 0C0h ; 16
.db 0FCh, 0C1h ; 17
.db 0FCh, 0C2h ; 18
MenuHook_end:
TokenHook_start:
.db 83h
ld a, d
cp 7
ret nz
ld a, e
cp 2+3+Token1-TokenHook_data
ret nc
sub 2
ld hl, (hookDataStart)
ld de, TokenHook_data - KeyHook_start
add hl, de
ld de, 0
ld e, a
add hl, de
ld hl, (hl)
ld de, (hookDataStart)
add hl, de
dec hl
ret
TokenHook_data:
.dl Token1 - KeyHook_start
.dl Token2 - KeyHook_start
.dl Token3 - KeyHook_start
.dl Token4 - KeyHook_start
.dl Token5 - KeyHook_start
.dl Token6 - KeyHook_start
.dl Token7 - KeyHook_start
.dl Token8 - KeyHook_start
.dl Token9 - KeyHook_start
.dl Token10 - KeyHook_start
.dl Token11 - KeyHook_start
.dl Token12 - KeyHook_start
.dl Token13 - KeyHook_start
.dl Token14 - KeyHook_start
.dl Token15 - KeyHook_start
.dl Token16 - KeyHook_start
.dl Token17 - KeyHook_start
.dl Token18 - KeyHook_start
Token1: .db 9, "ReadByte("
Token2: .db 12, "ReplaceByte("
Token3: .db 8, "AddByte("
Token4: .db 11, "DeleteByte("
Token5: .db 7, "Sprite("
Token6: .db 10, "Rectangle("
Token7: .db 11, "Background("
Token8: .db 4, "Inc("
Token9: .db 4, "Dec("
Token10: .db 8, "ExecHex("
Token11: .db 12, "SetVar3Byte("
Token12: .db 12, "SetVar1Byte("
Token13: .db 11, "SetListDim("
Token14: .db 10, "SetupPrgm("
Token15: .db 9, "CreateVar"
Token16: .db 10, "ArchiveVar"
Token17: .db 12, "UnArchiveVar"
Token18: .db 9, "DeleteVar"
; TODO:
; switch_
; case_
TokenHook_end:
Hooks_end:
Thanks! (a little late)
You didn't share you install code. I'm installing it to ram (So I don't have make an app each time) Do you have any other commands after the bcall to set the hook? (I have to use a clone of Axe's input because for some reason that makes the code work in ram...)