I tried to make an offscrpt that saves your ram on poweroff:


Code:
#include    "ti83plus.inc"
_GroupAllVars      equ 50C5h

.org $8001
   ld  hl,  BackUpGroup
    rst  rMov9ToOP1
    bcall(_GroupAllVars)
   ret
BackUpGroup:
   .db GroupObj,"ZRAMBKUP",0
    ret
.end


But it just crashes my calculator when I turn it off. Ideas?
PS I did set 1, (iy+34h)
I never understood how do OFFSCRPTs work, can you tell me more about them ?
Matrefey: You can read more about OFFSCRPTs here: http://wikiti.brandonw.net/index.php?title=Offscrpt
Parrot: "and set bit 1 of (iy+33h) to indicate that an OFFSCRPT appvar is installed." I'm not sure what 1,(iy+34h) is.
Well...

- Before calling OFFSCRPT, the OS turns the LCD off and disables all interrupts (via port 3.)
- GroupAllVars tries to push something on the FPS, but because the homescreen edit buffer is open, there is no free RAM, so PushRealO1 throws an error.
- The system error handler is invoked; as you would expect, it displays the "ERR:MEMORY" screen (you can't see that it has done so because the LCD is turned off.) It then jumps to Mon, which calls GetKey.
- GetKey halts the CPU, which freezes the system since interrupts have been disabled.

There are a few lessons to be learned from this:
- You can't do something that involves creating or deleting variables while an edit buffer is open.
- OFFSCRPT is not set up to handle system errors at all. If you are thinking of calling a system routine that has any possibility whatsoever of throwing an error, you must set an error handler first.
- When OFFSCRPT is called, the calculator hardware is not in what you could call a sane state (port 3 set to 8). (edit: that's eight-paren, not Cool.)

I think the fundamental problem here, though, is that trying to do anything complicated while the calculator is turning off is a bad idea. (The same would be true if you used an app-change hook or homescreen hook instead of OFFSCRPT.) GroupAllVars, for instance, would cause you problems even if it were working "properly": what would you expect it to do when it needs to garbage-collect? A better idea would be to use OFFSCRPT to set up a hook (or other mechanism) that will do the work of grouping variables after the calc turns back on.
As I was telling parrotgeek on SAX, what Doors CS does (and thanks to BrandonW for this idea) is to use an OFFSCRPT to set up a GetKeyHook. When the calculator turns back on, regardless of what turned it off, the GetKeyHook will fire when the calculator first checks for a key. The GetKeyHook cancels itself, then does whatever needs to be done (for example, launching Doors CS). I think that's probably a decent sort of standard design for many tasks to be performed on power-on.
Quote:
A better idea would be to use OFFSCRPT to set up a hook (or other mechanism) that will do the work of grouping variables after the calc turns back on.

Seems like a sane choice from a programming point of view, but not so much usability wise, if you expect this program to group all of your programs and protect them from a RAM reset if the battery is pulled while it is off.
elfprince13 wrote:
Seems like a sane choice from a programming point of view, but not so much usability wise, if you expect this program to group all of your programs and protect them from a RAM reset if the battery is pulled while it is off.

True. Well, what I would probably do, if I wanted to write such a utility, is to create the group completely by hand (potentially including garbage collection, if need be.) And check to see whether the group already exists and whether any variables have been changed. But that would be considerably more difficult.

Code:

#include    "ti83plus.inc"
_GroupAllVars      equ 50C5h
;_closeeditbufnor   equ 476Eh
_RecallEd      equ 4750h ;_setupBuffer

.org $8001
   ld  a,  0Bh
   out  (3), a 
   bcall(_closeeditbufnor)
   ld  hl,  BackUpGroup
   rst  rMov9ToOP1
   bcall(_GroupAllVars)
   ;bcall(_RecallEd)
   ;need to set port 3 back?
   ret
BackUpGroup:
   .db GroupObj,"ZRAMBKUP",0
.end


so it does make the group, but the screen does not turn on while doing so.
also, when turning back on and hit continue or do not show again, calc crashes. how to fix?
do I need to reopen edit buffer? how?
and what is port 3 normally set to when calc is off?
  
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