Hey guys, I need some help with hooks!
My KeyHook is working fine, but for whatever reason the ParserHook doesn't enable.

The code for the parserHook is only so dummy-like so that i easily find it in the emulator debugger

Code:
.export
.binarymode intel

.inclabels "ti8x.lbl"         ; Label file containing equates

#define _EnableHomescreenHook $4FAB
#define _EnableRawKeyHook $4F66
#define _EnableParserHook $5026
#define _DispTail $495D
#define _DispHead $495A

.deflong bjump(label)         ; Jump macro
   call BRT_JUMP0
   .dw label
.enddeflong

.deflong bcall(label)         ; Call macro
   rst rBR_CALL
   .dw label
.enddeflong

.defpage 0, 16*1024, $4000      ; Page 0 definition

.page 0
#define APPNAME "Vectors "
#define APPNAMELEN 7
#define APPPAGES 1
#include header.asm
run:
   ld hl,keyHook
   in a,(6)
   bcall(_EnableRawKeyHook)
   ld hl,parserHook
   in a,(6)
   bcall(_EnableParserHook)
   bjump(_JForceCmdNoChar)       ; Exit

keyHook:
   .db $83
   cp kMul
   jr z,_keyHook_mulKey
   jr ReturnNZ
_keyHook_mulKey:
   ld hl,(editCursor)
   dec hl
   dec hl
   ld a,(hl)
   bcall(_IsA2ByteTok)
   jr z,_keyHook_mulKey_Exit
   inc hl
   ld a,(hl)
   ld b,a
   ld c,0
   cp tMul
   jr nz,{+1@}
      ld b,tAdd
      ld c,1
   @:
   cp tAdd
   jr nz,{+1@}
      ld b,tMul
      ld c,1
   @:
   ld a,1
   cp c
   jr nz,_keyHook_mulKey_Exit
      ld (hl),b
      bcall(_DispHead)
      ld (editCursor),hl
      bcall(_DispTail)
      xor a
      jr ReturnZ
   _keyHook_mulKey_Exit:
   ld a,kMul
   jr ReturnNZ

parserHook:
   or a
   jr nz,ReturnZ
   ld a,a
   ld a,a
   ld a,a
   ld a,a

ReturnNZ:
   or a
   ret
ReturnZ:
   cp a
   ret


EDIT: Nevermind, runer found the bug, I was missing a .db $83 to tell the os that this is a hook

EDIT2: Having the same issue now with token hooks, they don't get triggered Sad

Code:
.export
.binarymode intel

.inclabels "ti8x.lbl"         ; Label file containing equates
#include "extraequ.inc"

#define _EnableHomescreenHook $4FAB
#define _EnableRawKeyHook $4F66
#define _EnableParserHook $5026
#define _EnableTokenHook $9BC8
#define _DispTail $495D
#define _DispHead $495A
#define customTokenPrefix $62
#define tScalarProduct $6240
#define tScalarProductLower $40
#define tCrossProduct $6241
#define tCrossProductLower $41

.deflong bjump(label)         ; Jump macro
   call BRT_JUMP0
   .dw label
.enddeflong

.deflong bcall(label)         ; Call macro
   rst rBR_CALL
   .dw label
.enddeflong

.defpage 0, 16*1024, $4000      ; Page 0 definition

.page 0
#define APPNAME "Vectors "
#define APPNAMELEN 7
#define APPPAGES 1
#include header.asm
run:
   ld hl,keyHook
   in a,(6)
   bcall(_EnableRawKeyHook)
   ld hl,parserHook
   in a,(6)
   bcall(_EnableParserHook)
   ld hl,tokenHook
   in a,(6)
   bcall(_EnableTokenHook)
   
   bjump(_JForceCmdNoChar)       ; Exit

*snip*

tokenHook:
   .db $83
   ld a,d
   *snip*
   ret

ReturnNZ:
   or a
   ret
ReturnZ:
   cp a
   ret
What's exactly wrong with it? This code works for me:

Code:
   ld hl,tokenHook
   in a,(6)
   bcall(_SetTokenHook)
   
   bjump(_JForceCmdNoChar)       ; Exit

tokenHook:
   .db $83
   ld hl,tokenTxt
   ld de,$8001
   ld bc,7
   ldir
   ld hl,$8000
   ret

tokenTxt:
.db 6,"Token("
EDIT: Btw, in my ti83plus.inc, it's defined as _SetTokenHook, not _EnableTokenHook.
I manually #define it as $9BC8
And currently i just have a breakpoint in there to test if it gets triggered....
You've defined the bcall as $9BC8? There are no bcalls in RAM, _SetTokenHook should be at $4F99.
That's it, thanks!
Seems like i messed up the hook location with the bcall location <_< (http://wikiti.brandonw.net/index.php?title=83Plus:Hooks:9BC8)
Cool, glad to hear it's working now Smile

Also, i guess that's probably just a filler code, but here's a more optimized version of the raw key hook in the first post:

Code:
keyHook:
   .db $83
   cp kMul
   ret nz      ;if it's already nz, we don't need to set it again
_keyHook_mulKey:
   ld hl,(editCursor)
   dec hl
   dec hl
   ld a,(hl)   ;make sure previous token isn't 2-byte token
   bcall(_isA2ByteTok)
    jr z,_keyHook_mulKey_Exit
   inc hl
   ld a,(hl)   ;get token
   cp tMul      ;check if it's * or +
    jr z,$+6
   cp tAdd
    jr nz,_keyHook_mulKey_Exit   ;if it isn't, don't change anything
   xor tMul^tAdd
   ld (hl),a
   bcall(_DispHead)
   ld (editCursor),hl
   bcall(_DispTail)
   xor a
   ret
_keyHook_mulKey_Exit:
   ld a,kMul
   jr ReturnNZ
EDIT: Changed the toggling part to "xor tMul^tAdd" Wink
That code already changed a lot by now, hehe
Does anyone know where I can find a good example of the token hook? All the examples I found were really vague.
ASB wrote:
Does anyone know where I can find a good example of the token hook? All the examples I found were really vague.
Can you be more specific about what you found lacking in the current examples? Perhaps that would help us guide you toward a clearer piece of sample code.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement