Thanks James! I'll give that I try at some point and see if I can do that. This would mean that the program route is also a viable option, if this works the way I hope it does.
Since the APD is interrupt-based, that would mean that many things could also be fixed... (Mateo ponders)
Well, Mateo finished pondering and wishes he had reached this topic sooner...
So, looking at your very first post, it looks like you just wanted a way to turn off the calculator and turn it back on while maintaining your program's state? I think this was preferable, if I remember correctly. Now we can avoid all the KeyHook craziness and OffScript oddness and focus on getting things done... I think...
So, here's the code that I have working right now; just run it, the calculator turns off, Press the [ON] key to turn it back on, and from there you can do whatever you like. The _GetKey call is in there because it is very useful when working with the APD; take a look at its documentation for more information. Hope this helps!
EDIT: If the password fails, just jump back to the PasswordProgram label, which will take care of everything again.
Code: .nolist
#include "ti84pcse.inc"
#define MathPrintFlags1 $44
#define MathPrintActive 5
.list
.org UserMem-2
.db tExtTok,tAsm84CCmp
PasswordProgram:
ei
bcall(_EnableAPD) ; Make sure it's actually working
ld a,1
ld (apdTimer),a
ld (apdSubTimer),a
res MathPrintActive,(iy+MathPrintFlags1)
bcall(_maybe_ClrScrnFull) ; I don't know what you have it defined as, but this is what it is for me in my include file. Change it to whatever clears the screen
bcall(_HomeUp)
ld hl,PressText
bcall(_PutS)
bcall(_NewLine)
bcall(_NewLine)
bcall(_PutS)
bcall(_GetKey)
bcall(_NewLine)
di
; This is where you can put in your password getting code and stuff
ei
ret
PressText:
.db "Calculator Locked.",0
.db "Press Enter...",0
Also, because chickendude had the original idea:
chickendude wrote:
Also, another option might be installing an interrupt (again, not generally something you will be messing with in your first project). I see in ti83plus.inc that there is an "apdtimer" equate, i wonder if that's where the OS counts down for the APD (auto-powerdown)? If there's also an equate for the CSE that would be great, perhaps you could check if it = a certain value (for example, 3) then take control of the calc before it actually APDs. When the calc turns back on, ask for the password then reset the APD value.
So yes, you could also implement a custom interrupt or TSR which will execute when your calculator powers down as well. (A little bit too advanced though for this program, but I imagine it could be possible.)