0 Members and 5 Guests are viewing this topic.
: Header:... //Some other parts of your program::Lbl HOOK:::Return
add a,e push HL push BC push DE push AF ld l,a ; load a to l to make it usable in axe ld h,00 ;function goes here pop AF ; restore the registers we might have messed up pop DE pop BC pop HL
: Header... Some other parts of your program::Lbl HOOK:Asm(83E5C5D5F56F2600):->K //store ans in axe variable K to use in your compare statements::Asm(F1D1C1E1):Return
in a,(6) ;current ROM page to A _bcall(_EnableRawKeyHook) ; Usually we now quit the program using _bjump(_JForceCmdNoChar)
:LHOOK:Asm(DB06EF664F):: // return to OS:Asm(CD50002740)
:Asm(EF6F4F) // = _bcall(_ClrRawKeyHook)
pop AF ld a,h push AF
:9 //this now replaces the key pressed with the code for "CLEAR" (example):Asm(F17CF5):... //use only ends of if statements here - that doesn't mess anything up.:Asm(F1D1C1E1) //usual restore routine:
:.KeyHook //name of my app:LHOOK:Asm(DB06EF664F) //enable Hook:Asm(CD50002740) //return:Lbl HOOK:Asm(83E5C5D5F56F2600):->K:!If K-138 //someone pressed "STO->":Asm(EF6F4F) //Disable the hook:Else!If K-142 //someone pressed "0":0:Asm(F17CF5) //write 0 so the keypress is being ignored:End //only an end of an "if"-statement, that's ok:Asm(F1D1C1E1):Return
How to make it work from RAM :Replace Asm(CD50002740) by Return. As first instruction, copy your hook to a fixed RAM area and put that area in HL before enabling the hook.
:Asm(EF6F4F) //Disable the hook:!If K-142 //someone pressed "0"
You forgot the End between these two lines of code in your example program:Code: [Select]:Asm(EF6F4F) //Disable the hook:!If K-142 //someone pressed "0"
Also what do I do to disable the memory menu instead of the 0 key?
edit 2: Is there a way to chain hooks?
Haha... Well... to be honest that was my initial intention which lead me to explore this whole thing....Not just blocking it, but rather open up a menu that looks and behaves visually the same but doesn't do anything... ehhhrmmm I better stop talking now...
I'm not an assembly programmer, I just get by... What do you mean by chaining hooks?
Hook chaining is done by calling the already existing hook within your own hook, I guess. Remember to put the right value in A though.
QuoteHaha... Well... to be honest that was my initial intention which lead me to explore this whole thing....Not just blocking it, but rather open up a menu that looks and behaves visually the same but doesn't do anything... ehhhrmmm I better stop talking now... That is pretty cool, good luck with that!
I'm already doing some cool stuff with that code. I made it so that whenever enter is pressed it displayes "do it yourself". This is so going on my friends calculator
; address in HL in a,(6) ; current rom page _bcall(_EnableHomescreenHook) _bjump(_JForceCmdNoChar) ; Quit ;Hook itself: add a,e ; 0x83 required to be identified as legal routine push HL push BC push DE push AF ld l,a ; load a to l to make it usable in axe ld h,00 ; function goes here pop AF ; restore the registers we might have messed up pop DE pop BC pop HL cp a ; set zeroflagDisable: _bcall(_ClrHomescreenHook)
:LHOOK:Asm(DB06EFAB4F):Asm(CD50002740)::Lbl Hook:Asm(83E5C5D5F56F2600):!If ->A://Do some crazy stuff like _bcall(_Random) store some random stuff in OP1::Asm(EF794B)://Disable the hook::Asm(EFAE4F):End://restore and cp a:Asm(F1D1C1E1BF) //note the BF, otherwise things get messed up badly:Return
Quote from: Matrefeytontias on December 27, 2013, 08:37:34 pmHook chaining is done by calling the already existing hook within your own hook, I guess. Remember to put the right value in A though.Seems doable, so you have to somehow get the address of the other existing hook and then call it.