I have a simple raw key hook which should run a no stub asm program. However it gives Error:Invalid. I know the program i am trying to run is not Invalid - i can run it with Asm(). The issue here seems to be the fact that i am calling _ExecutePrgm from a hook. Anyone know how to get around this? It is very important for me to be able to run a program from a hook :/

appvarHOOK:

Code:

#include "ti84pce.inc"
 
AppvarStart:
    .db $83
 
    ld (plotSScreen),a
    cp kPrgm        ; was Prgms pressed?
    ret nz
    ld hl,$D007E0
    ld b,(hl)
    ld a,kQuit
    cp b
    jr nz,return
   
    ld hl,ShellPrgm ;actual program running stuff
    call _mov9toop1
    call _ExecutePrgm
    ld a,0
    ld (plotSScreen),a
return:
    ld a,(plotSScreen)
    ret
ShellPrgm:
    .db ProtProgObj,"SHELL",0


Program install:

Code:

.nolist
#include "ti84pce.inc"

_FindAlphaUp   equ 0020E8Ch
_FindAlphaDn   equ 0020E90h
.list
   
   .org UserMem-2
   .db tExtTok,tAsm84CeCmp
   
   ld hl,RawKeyHookAppvar
   call   _mov9toop1
   call _ChkFindSym
   ex de,hl
   push hl
      add hl,hl
   pop hl
   jr nc,appVarInArc
   call _Arc_Unarc
   call _chkfindsym
   ex de,hl
appVarInArc:
   ld bc,9
   add hl,bc
   ld c,(hl)
   add hl,bc
   inc   hl ; bypass size bytes
   inc   hl
   inc   hl
   call $0213CC
   
   ld hl,InstallProgramName
   call _mov9toop1
   call _Arc_Unarc
   ret

notFound:
 .db "AppVarHOOK not found",0
InstallProgramName
  .db ProtProgObj,"INSTALL",0
RawKeyHookAppvar:
 .db AppVarObj,"HOOK",0
 


Program SHELL:


Code:

#include "ti84pce.inc"
   .org UserMem-2
   .db tExtTok,tAsm84CeCmp
   ret
The problem appears to be that the hook program is archived, so any location-dependent code will not work. And you have one line of location-dependent code: ld hl,ShellPrgm.

EDIT: I've been made aware that what follows is broken in at least one way, so don't use it. But I'll keep it rather than just delete it for posterity.

Here's my suggested fix, which has the advantage of allowing you to make other relocation adjustments without more origin fetching (as long as the relocation targets are within a signed byte of RelocBase):

Code:

#include "ti84pce.inc"
 
AppvarStart:
    .db $83
 
    ld (plotSScreen),a
    cp kPrgm        ; was Prgms pressed?
    ret nz
    ld hl,$D007E0
    ld b,(hl)
    ld a,kQuit
    cp b
    jr nz,return
   
    call RelocBase
RelocBase:
    pop ix
    lea hl,ix-RelocBase+ShellPrgm ;actual program running stuff
    call _mov9toop1
    call _ExecutePrgm
    ld a,0
    ld (plotSScreen),a
return:
    ld a,(plotSScreen)
    ret
ShellPrgm:
    .db ProtProgObj,"SHELL",0
  
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