How does OFFSCRPT work?
souvik1997 wrote:
How does OFFSCRPT work?
I've moved this into the z80 ASM programming subforum for the sake of consistency.
So, the OFFSCRPT is an appvar that contains executable code. The code within it, if it exists, is run every time the calculator turns off under the TI-OS's control (although not necessarily if a program or shell turns the calculator off, of course). The contents of the OFFSCRPT appvar are copied to memory starting at $8001, executed, and cleared. For example, Doors CS can create the following OFFSCRPT appvar that will install a GetkeyHook to launch Doors CS once the calculator turns on again:
Code:
OffScrptCode:
.relocate $8001
bit 4,(IY+apdFlags)
ret nz
ld hl,MyAppName
rst 20h
bcall(_FindApp)
ret c
dec a ;this is on page 2
ld hl,MyGetKeyHook
bcall(_EnablegetKeyHook)
;set 0,(iy+34h)
ret
MyAppName:
.db AppObj,"DoorsCS7"
ret
.endrelocate
OffScrptCodeEnd:
Installing the OFFSCRPT involves creating the Appvar, of course, as well as setting bit 1 of (iy+33h) to indicate that an OFFSCRPT Appvar is installed. To uninstall it, delete the Appvar and reset 1, (iy+33h), although you can also get away with either only deleting the variable or only resetting the flag. The following code installs an OFFSCRPT if a=1, or removes it if a=0.
Code:
or a
jr z,RemoveOffScript
CreateOFFSCRIPT:
ld hl,OffScriptName
rst 20h
bcall(_chkfindsym)
jr nc,OffScrptCont
ld hl,OffScrptCodeEnd-OffScrptCode
bcall(_enoughmem)
jr c,OffScrptCont
ex de,hl
push hl
bcall(_createappvar)
inc de
inc de
ld hl,OffScrptCode
pop bc
ldir
set 1,(iy+33h)
jr OffScrptCont
RemoveOFFSCRIPT:
ld hl,OffScriptName
rst 20h
bcall(_chkfindsym)
bcallnc(_delvararc)
OffScrptCont:
There's a similar system called an ONSCRPT that is run when the calculator first powers on rather than when it's about to power off, but we've found it to be very unreliable and unpredictable.
souvik1997 wrote:
Thanks!
Sure thing, and please feel free to let me know if you have additional questions. May I ask what this is for? 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
» 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
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