Recently, I've been trying to get VYSION to run when the [prgm] key is pressed, by way of a GetKey hook. I have the code for that here, which is an adapted version of code I found in this thread:
Code:
With MathPrint on, the shell loads correctly the first time the hook is run, but after that, the cursor gets stuck in the top left corner of the screen, resetting the calc when [clear] is pressed. With it off, the cursor returns to the correct position, but operations fail to execute, eventually bricking the calc when the hook is attempted to be run again:
When talking with people in Discord about this, I was given to understand that I need to somehow reload the home screen, using a command such as ti.newContext0 or ti.SetupHome, but these do not seem to work. Anyone who has knowledge of hooks and can see what's going wrong here, help would be much appreciated.
Code:
include 'include/ez80.inc'
include 'include/tiformat.inc'
include 'include/ti84pceg.inc'
format ti executable 'HS'
_Program:
call InstallStartHook
ret
_hook_start_addr:
virtual at ti.pixelShadow2
_hook_start:
db $83
ld (ti.plotSScreen),a
cp ti.kPrgm ; was Prgms pressed?
ret nz
ld hl,$D007E0
ld b,(hl)
ld a,ti.kQuit
cp b
jr nz,return
call RelocBase
RelocBase:
pop ix
lea hl,ix-RelocBase+ShellPrgm ;actual program running stuff
res ti.progExecuting,(iy + ti.newDispF)
res ti.cmdExec,(iy + ti.cmdFlags)
call ti.Mov9ToOP1
call ti.ExecutePrgm
ld a,0
ld (ti.plotSScreen),a
call ti.HomeUp
return:
ld a,(ti.plotSScreen)
ret
ShellPrgm:
db ti.ProtProgObj,"VYSION", 0
load code: $-_hook_start from _hook_start
end virtual
db code
InstallStartHook:
ld hl,_hook_start_addr
ld de,ti.pixelShadow2
ld bc,lengthof code
ldir
ld hl,ti.pixelShadow2
;jp ti.plotSScreen
jq ti.SetGetKeyHook
ret
ClearStartHook:
call ti.ClrGetKeyHook
ret
When talking with people in Discord about this, I was given to understand that I need to somehow reload the home screen, using a command such as ti.newContext0 or ti.SetupHome, but these do not seem to work. Anyone who has knowledge of hooks and can see what's going wrong here, help would be much appreciated.