I am attempting to create an Assembly program such that, when I run it, it turns off the calculator, and when I turn on the calculator, the program is still running. This program will then ask for a password to enter the calculator.
I have tried the following code to turn off the calculator.

Code:
.nolist
   #include "ti84pcse.inc"
   
.list
   .org UserMem-2
   .db tExtTok,tAsm84CCmp
   
   ld a,1
   out (pIntMask),a
   halt
   res onInterrupt,(iy+onFlags)
   ld a,$B
   out (pIntMask),a
   ret


When I run it on jsTIfied, it turns off the calculator, but I cannot turn it on again without resetting.

I apologize for constantly asking this vague question as opposed to a more specific one, but: what is wrong with my program?
Have you tried this on your calc? Emulators often have trouble with the LCD. The code works fine on my 83+.
Cool idea, scatMan7fh4y5rbuyrdrar!
I took a big risk and ran it on my actual calculator. The calculator did not turn off: it froze, and no button on the keyboard, including the ON button, that I pressed did anything. Luckily there is a nice and easy reset button on the back of the color editions, so I didn't have to take out the batteries.

Thus, the problem is not the emulator but the code. And speaking of code, here is my updated but unoptimized code, now displaying my name (which I have edited out here). The email and phone number will be displayed with _VPutS, with which I have yet to experiment.

Code:
.nolist
   #include "ti84pcse.inc"
   #define MathPrintFlags1 $44
   #define MathPrintActive 5
   #define PutMapFlags $4a
   #define PutMapUseColor 4
   
.list
   .org UserMem-2
   .db tExtTok,tAsm84CCmp
   
   ld a,1
   out (pIntMask),a
   halt
   res onInterrupt,(iy+onFlags)
   ld a,$B
   out (pIntMask),a
   res MathPrintActive,(iy+MathPrintFlags1)
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,prompt
   bcall(_PutS)
   bcall(_NewLine)
   bcall(_NewLine)
   ld hl,info1
   bcall(_PutS)
   ld hl,$FFE0
   ld (textBGColor),hl
   set PutMapUseColor,(iy+PutMapFlags)
   ld hl,info2
   bcall(_PutS)
   res PutMapUseColor,(iy+PutMapFlags)
   ld hl,info3
   bcall(_PutS)
   bcall(_NewLine)
   ret
prompt:
   .db "Password:",0
info1:
   .db "This calculator belongs to",0
info2:
   .db "--- ---",0
info3:
   .db ".",0
;email:
   ;.db "---@---.com",0
;phone:
   ;.db "(...) ...-...",0
I can't really say since i don't have an 84+CSE to test it out on, your code works just fine on my 83+/84+SE. Maybe it's due to a difference in the LCDs? I'd wait for someone with more knowledge of the CSE (like Kerm) to share their thoughts. WikiTi has some info on it but i'm not sure if that's exactly the same thing. There's also something in the "07: Display Control 1" section ("1 1 D1: Turn off LCD??"). I haven't touched a CSE so i dunno what else to say. But it would be nice to use the interrupt mask port.
I'm not sure that the LCD is the problem, because even if I didn't power down the LCD, the calculator would still power down (though the LCD would still be on) and then turn on and resume the program when ON is pressed. However, when I run the program, that doesn't even happen.

If I can't figure this out, then is there another way to make the program run at startup? Is there some sort of queue onto which I can push the address of this program? I would personally prefer the method that I am currently using, but the queue method also sounds good.
On the TI-84+CSE, it's much, much easier to use the _PowerOff BCALL than to try to manually turn off the calculator. Combine an OffScript + RawKeyHook to launch your code when the calculator turns back on if you don't want your program running all the time.
Thanks! Is OffScript some sort of term that I don't know, or does it just mean code to turn off the calculator?

This will give me good practice in using hooks, which I will need for the project that I will soon resume, the fake reset program.

EDIT: Never mind, I figured out what OFFSCRPT is.

EDIT: Here is my updated code. I am finished but for the OFFSCRPT code itself.

Code:
.nolist
   #include "ti84pcse.inc"
   #define MathPrintFlags1 $44
   #define MathPrintActive 5
   #define scriptFlag $33
   #define alt_Off 1
   #define PutMapFlags $4a
   #define PutMapUseColor 4

.list
   .org UserMem-2
   .db tExtTok,tAsm84CCmp

   res MathPrintActive,(iy+MathPrintFlags1)
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   rst rFINDSYM
   jr c,CreateOFFSCRPT
   or b
   jr nz,DelOFFSCRPTArc
   bcall(_DelVar)
   jr CreateOFFSCRPT
DelOFFSCRPTArc:
   bcall(_DelVarArc)
CreateOFFSCRPT:
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_EnoughMem)
   jr c,NotEnoughMem
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_CreateAppVar)
   set alt_Off,(iy+scriptFlag)
   bcall(_PowerOff)
NotEnoughMem:
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,NotEnoughMemMsg
   bcall(_PutS)
   bcall(_NewLine)
   ret

NotEnoughMemMsg:
   .db "Not enough memory!",0
OFFSCRPTName:
   .db AppVarObj,"OFFSCRPT",0

OFFSCRPTStart:
   ld a,8
   ld (pIntMask),a
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,prompt
   bcall(_PutS)
   bcall(_NewLine)
   bcall(_NewLine)
   ld hl,info1
   ;display rest of stuff
   ;ask for input
   ;restore ON interrupt flag
   ;reset OFFSCRPT flag
   ret

prompt:
   .db "Password:",0
info1:
   .db "This calculator belongs to",0
;info2:
   ;.db "--- ---",0
;info3:
   ;.db ".",0
;email:
   ;.db "---@---.com",0
;phone:
   ;.db "(...) ...-....",0
OFFSCRPTEnd:


EDIT: Never mind. You shall see my problem in my next post.
I overlooked a major problem. I know how to create an AppVar, which is in my code, as you shall see in a moment. However, how do I transfer the contents I want to the AppVar?

The following is my current code. Other than the AppVar problem, finishing displaying all the text, and debugging, I am finished.

Code:
.nolist
   #include "ti84pcse.inc"
   #define MathPrintFlags1 $44
   #define MathPrintActive 5
   #define scriptFlag $33
   #define alt_Off 1
   #define PutMapFlags $4a
   #define PutMapUseColor 4

.list
   .org UserMem-2
   .db tExtTok,tAsm84CCmp

   res MathPrintActive,(iy+MathPrintFlags1)
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   rst rFINDSYM
   jr c,CreateOFFSCRPT
   or b
   jr nz,DelOFFSCRPTArc
   bcall(_DelVar)
   jr CreateOFFSCRPT
DelOFFSCRPTArc:
   bcall(_DelVarArc)
CreateOFFSCRPT:
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_EnoughMem)
   jr c,NotEnoughMem
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_CreateAppVar)
   set alt_Off,(iy+scriptFlag)
   bcall(_PowerOff)
NotEnoughMem:
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,NotEnoughMemMsg
   bcall(_PutS)
   bcall(_NewLine)
   ret

NotEnoughMemMsg:
   .db "Not enough memory!",0
OFFSCRPTName:
   .db AppVarObj,"OFFSCRPT",0

OFFSCRPTStart:
   ld a,$A
   ld (pIntMask),a
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,prompt
   bcall(_PutS)
   bcall(_NewLine)
   bcall(_NewLine)
   ld hl,info1
   ;display rest of stuff
   bcall(_HomeUp)
   ld hl,curCol
   ld (hl),$B
   bcall(_GetKey)
   ld b,a
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   ld c,a
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   ld f,a
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   ld d,a
   ld a,$2A
   bcall(_PutC)
   ld a,b
   cp k[eypress]
   jr nz,Fail
   ld a,c
   cp k[eypress]
   jr nz,Fail
   ld a,f
   cp k[eypress]
   jr nz,Fail
   ld a,d
   cp k[eypress]
   jr z,Success
Fail:
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,wrongpassword
   bcall(_PutS)
   bcall(_GetKey)
   jr OFFSCRPTStart
Success:
   ld a,$B
   ld (pIntMask),a
   set alt_Off,(iy+scriptFlag)
   ret

prompt:
   .db "Password:",0
info1:
   .db "This calculator belongs to",0
;info2:
   ;.db "--- ---",0
;info3:
   ;.db ".",0
;email:
   ;.db "---@---.com",0
;phone:
   ;.db "(...) ...-....",0
wrongpassword:
   .db "Wrong password! Try again.",0
OFFSCRPTEnd:
When you create the appvar, _CreateAppVar should return with de pointing to the start of its data in RAM. You can load what you want into de or use "ex de,hl" to swap de and hl, since it's much more convenient to work with hl than with de.
So, as chickendude has already stated, you can use the pointer to the data in RAM, but make sure that you skip over the first two size bytes of the data.

So, right after that bcall you can do something like this:

Code:
inc de
inc de
ld hl,OFFSCRPTStart
ld bc,OFFSCRPTEnd-OFFSCRPTStart
ldir


Where the two varible names are pointers to the data in memory, or they could also be addresses which hold a different address through indirection.

NOTE: You are also going to want to make the size you make the app varible a little bigger than the size of the bytes you are trying to plug into it. I've had a couple issues with that in the past. Add an extra 2 bytes and you should be set. Smile
Ah, thanks, i forgot to mention the size bytes. I'm not sure what you mean about the extra space, though, i don't think i've ever had issues with that in the past. What sort of issues have you had? Is it specific to the CSE or is it something you've noticed on the entire 83+ series?
Once I finished coding, I prayed to every god of whom I could think, though I am an atheist, and, with a racing heart, ran the program. Do you think it worked?? Of course not!! Either I am cursed, or this happens to all programmers: my programs never, ever work the first time.

First off, I took away the bcall(_PowerOff) from the program. It now creates the AppVar, and then I can turn the calculator off manually.

When I run the program, it displays a bunch of empty lines (it's not really supposed to display anything) and ends. If I press anything other than CLEAR and, I think, a few other buttons, the calculator crashes.

Once I pressed CLEAR, I looked to see whether or not the AppVar was created, and, for once, it was successful. At least we know that, to an extent, the code of the AppVar creation works.

When I turn off the calculator, it does not turn off. It shows a blank screen and completely freezes. Nothing I do works, except resetting the calculator.

Can someone please tell me what is wrong with my code? I apologize for making you read all of my rather long code, but it is necessary to figure out what is wrong.

In addition, I would like to know whether or not you approve of my method of storing the keypresses. I stored them in the program, but I am not sure whether or not I did this correctly.

Code:
.nolist
   #include "ti84pcse.inc"
   #define MathPrintFlags1 $44
   #define MathPrintActive 5
   #define scriptFlag $33
   #define alt_Off 1
   #define PutMapFlags $4a
   #define PutMapUseColor 4

.list
   .org UserMem-2
   .db tExtTok,tAsm84CCmp

   res MathPrintActive,(iy+MathPrintFlags1)
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   rst rFINDSYM
   jr c,CreateOFFSCRPT
   or b
   jr nz,DelOFFSCRPTArc
   bcall(_DelVar)
   jr CreateOFFSCRPT
DelOFFSCRPTArc:
   bcall(_DelVarArc)
CreateOFFSCRPT:
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_EnoughMem)
   jr c,NotEnoughMem
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_CreateAppVar)
   inc de
   inc de
   ld hl,OFFSCRPTStart
   ld bc,OFFSCRPTEnd-OFFSCRPTStart
   ldir
   set alt_Off,(iy+scriptFlag)
   ret
NotEnoughMem:
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,NotEnoughMemMsg
   bcall(_PutS)
   bcall(_NewLine)
   ret

NotEnoughMemMsg:
   .db "Not enough memory!",0
OFFSCRPTName:
   .db AppVarObj,"OFFSCRPT",0

OFFSCRPTStart:
   bcall(_GetKey)
   ld a,$A
   ld (pIntMask),a
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,prompt
   bcall(_PutS)
   bcall(_NewLine)
   bcall(_NewLine)
   ld hl,info1
   ;display rest of stuff
   bcall(_HomeUp)
   ld hl,curCol
   ld (hl),$B
   bcall(_GetKey)
   ld ix,press1
   ld (ix),a
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   ld (ix+1),a
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   ld (ix+2),a
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   ld (ix+3),a
   ld a,$2A
   bcall(_PutC)
   ld a,(ix)
   cp kUp
   jr nz,Fail
   ld a,(ix+1)
   cp kRight
   jr nz,Fail
   ld a,(ix+2)
   cp kDown
   jr nz,Fail
   ld a,(ix+3)
   cp kDown
   jr z,Success
Fail:
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,wrongpassword
   bcall(_PutS)
   bcall(_GetKey)
   jp OFFSCRPTStart
Success:
   ld a,$B
   ld (pIntMask),a
   res alt_Off,(iy+scriptFlag)
   ret

prompt:
   .db "Password:",0
info1:
   .db "This calculator belongs to",0
;info2:
   ;.db "--- ---",0
;email:
   ;.db "---@---.com",0
;phone:
   ;.db "(...) ...-....",0
wrongpassword:
   .db "Wrong password! Try again.",0
press1:
   .db 0
press2:
   .db 0
press3:
   .db 0
press4:
   .db 0

   .db 0,0
OFFSCRPTEnd:
Ignore that thing I said about a certain bcall. Razz
chickendude wrote:
Mateo, rst rFINDSYM is exactly the same as the bcall, just two bytes smaller and faster.

Chickendude++ for that. Smile *I'm not one for optimization. Wink I go with what I know works and use it. Razz Oh well. I'll be sure to remember that from now on.

So, as chickendude pointed out, when you use labels, you have to redirect them. That is because they are in your appvar, not your program. You can do this by finding where your appvar is in memory and beginning execution there. That's probably the main thing throwing it off.

As for checking keypresses, at least once you get the code running, there are many useful items, such as cpi, cpir, among other things that I perfer to use. Let's see if this can be made to work first though. Razz

"or b" can usually be written as "ld a,b / or a", if that makes more sense. Chickendude points out some better techniques as well.

chickendude wrote:
Ah, thanks, i forgot to mention the size bytes. I'm not sure what you mean about the extra space, though, i don't think i've ever had issues with that in the past. What sort of issues have you had? Is it specific to the CSE or is it something you've noticed on the entire 83+ series?

No, I think it usually because I am not sure if the size bytes need to be included in the size... Sometimes I end up with weird VAT entries if I don't. Seems like always making it bigger fixes the problem.
Your programs will almost never run correctly the first time you write them, especially if you write it all at once. It's better to write it one bit at a time and test it so that you can weed out problems. If you write the whole program at once without testing in between each stage you'll find that debugging will be a nightmare since it's harder to know where the problems are coming from. For example, in this instance, i would advise you to take it one step at a time, first check to make sure that your AppVar is getting created (and has the proper size) then (or pause if you are using an emulator).

I'll look through your code later, but i can see one potential problem with your code right now. You're loading the stuff after OFFSCRPTStart into your AppVar, however the labels are pointing inside your program. Your program gets loaded into $9D95 so the labels are all pointing a little bit after that. However, when the AppVar runs, it's still pointing to the same location just after $9D95 only now your program isn't loaded there anymore so who knows what it's reading.

Also, what are you trying to do with "or b"? Check if b = 0? That will only work if a also = 0. If a = 1 and b = 0, "or b" will still leave a at 1. You can either first do "xor a" or use a different method to check if b = 0 (for example, dec b \ inc b).

I'll see if i can get your programming running on an 83+ later. In the meantime, it can be a good idea to follow your code in a debugger line by line to see if you can find what's going wrong.

EDIT: Mateo, rst rFINDSYM is exactly the same as the bcall, just two bytes smaller and faster.

EDIT2: I also wanted to say that your code is looking much nicer. Well, apart from the part where you check for keypresses to match the password Razz But we can look at that when you get the basic functionality working.

EDIT3: Reading a bit further into things, i don't think you'll be able to run your code as the calculator is turning off. As Kerm mentions, you'll need to set up a Raw Key Hook in your offscrpt which will run when the calculator turns on (the offscrpt, as the name implies, is run as the calculator turns off, not as it turns on). I'm not sure of a good way to do this, however, without writing a flash app. It might be easier just to make your program turn the calc off, ask for the password, then exit if it is correct, rather than deal with all these hooks and things which i've personally never used. I just spent the last hour or so trying to figure out how to get a hook to run from RAM without success. Hooks will usually be stored in a flash app.

For now i'd say skip all this offscrpt/hook stuff and work on the main body of your program: the password protection part. Start your program with _PowerOff and then jump to the beginning if the password is incorrect.

If you want some more info, you can check out FloppusMaximus' post here: http://www.cemetech.net/forum/viewtopic.php?p=195861#195861
The main point of interest regarding why things weren't working before:
Quote:
- GetKey halts the CPU, which freezes the system since interrupts have been disabled.
Thank you very much for your help.

I have updated the "or b" to "ld a,b \ or a". I have also redesigned the password check system: it no longer stores keypresses in the program, but rather sets b to 0, and adds 1 to b every time a correct key is pressed, and only continuing if b is 4 at the end.

I shall look into Raw Key Hooks sometime soon. Indeed, that is what Kerm first said to me, but I forgot about that. In the meantime, however, how do I do what chickendude pointed out and MateoConLechuga elaborated? How do I redirect labels?

It's funny: I was beginning to suspect that there was a problem with labels, because when I started testing early on, instead of freezing with a blank screen, the calculator froze with "ry!" displayed at the beginning of the screen. The only point in my code where that string occurred was in the "not enough memory" message, which is not in the AppVar.

Here is my current code, just for fun.

Code:
.nolist
   #include "ti84pcse.inc"
   #define MathPrintFlags1 $44
   #define MathPrintActive 5
   #define scriptFlag $33
   #define alt_Off 1
   #define PutMapFlags $4a
   #define PutMapUseColor 4

.list
   .org UserMem-2
   .db tExtTok,tAsm84CCmp

   res MathPrintActive,(iy+MathPrintFlags1)
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   rst rFINDSYM
   jr c,CreateOFFSCRPT
   ld a,b
   or a
   jr nz,DelOFFSCRPTArc
   bcall(_DelVar)
   jr CreateOFFSCRPT
DelOFFSCRPTArc:
   bcall(_DelVarArc)
CreateOFFSCRPT:
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_EnoughMem)
   jr c,NotEnoughMem
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_CreateAppVar)
   inc de
   inc de
   ld hl,OFFSCRPTStart
   ld bc,OFFSCRPTEnd-OFFSCRPTStart
   ldir
   set alt_Off,(iy+scriptFlag)
   ret
NotEnoughMem:
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,NotEnoughMemMsg
   bcall(_PutS)
   bcall(_NewLine)
   ret

NotEnoughMemMsg:
   .db "Not enough memory!",0
OFFSCRPTName:
   .db AppVarObj,"OFFSCRPT",0

OFFSCRPTStart:
   bcall(_GetKey)
   ld a,$A
   ld (pIntMask),a
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,prompt
   bcall(_PutS)
   bcall(_NewLine)
   bcall(_NewLine)
   ld hl,info1
   ;display rest of stuff
   bcall(_HomeUp)
   ld hl,curCol
   ld (hl),$B
   ld b,0
   bcall(_GetKey)
   cp kUp
   jr nz,SecondKeyPress
   inc b
SecondKeyPress:
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   cp kRight
   jr nz,ThirdKeyPress
   inc b
ThirdKeyPress:
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   cp kDown
   jr nz,FourthKeyPress
   inc b
FourthKeyPress:
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   cp kDown
   jr nz,Next
   inc b
Next:
   ld a,$2A
   bcall(_PutC)
   ld a,b
   cp 4
   jr z,Success
Fail:
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,wrongpassword
   bcall(_PutS)
   bcall(_GetKey)
   jr OFFSCRPTStart
Success:
   ld a,$B
   ld (pIntMask),a
   res alt_Off,(iy+scriptFlag)
   ret

prompt:
   .db "Password:",0
info1:
   .db "This calculator belongs to",0
;info2:
   ;.db "--- ---",0
;email:
   ;.db "---@---.com",0
;phone:
   ;.db "(...) ...-....",0
wrongpassword:
   .db "Wrong password! Try again.",0
OFFSCRPTEnd:
Actually I don't have too much experience with OS stuff, but looking around, it looks like OFFSCRPT is loaded into $8001. So, just define your labels inside the appvar by doing .org $8001. I'm actually not sure if that would even work... Getting a raw key hook to execute from RAM and created by a program is no easy task. I'll try to learn a little more and see what happens. Kerm would definitely have more knowledge on that topic, however. Smile
I think your best bet for this project would be to turn it into a flash app. Like Mateo, getting it to run from RAM is a bit beyond my abilities. Getting it to run from a flash application however is a bit easier, since you just need to provide the current flash page (the one the app is running from). You can get this from port 6: in a,(6) will put the current flash page in Memory Bank A (this is the page loaded into $4000-$7FFF, where flash applications are run from). If this sounds confusing, i'd wait a little bit before trying to tackle it. Making a flash app isn't too hard these days, but it would turn your 200 byte program into a 16kb flash app. What i would do personally just to keep the project going is write a program that turns off the LCD (_PowerOff). Then, when the calc is turned back on, go into your password program. If the password is incorrect, turn the calc back off and start from the beginning.

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.
When I added ".org $8001" and ran the program, for some weird reason, the calculator displayed the "not enough memory" message perfectly, and ended the program, without crashing or creating the AppVar.
I shall probably turn this into an app, but only after much trying to get it to work as a program.
Here is my current code:

Code:
.nolist
   #include "ti84pcse.inc"
   #define MathPrintFlags1 $44
   #define MathPrintActive 5
   #define scriptFlag $33
   #define alt_Off 1
   #define PutMapFlags $4a
   #define PutMapUseColor 4

.list
   .org UserMem-2
   .db tExtTok,tAsm84CCmp

   res MathPrintActive,(iy+MathPrintFlags1)
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   rst rFINDSYM
   jr c,CreateOFFSCRPT
   ld a,b
   or a
   jr nz,DelOFFSCRPTArc
   bcall(_DelVar)
   jr CreateOFFSCRPT
DelOFFSCRPTArc:
   bcall(_DelVarArc)
CreateOFFSCRPT:
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_EnoughMem)
   jr c,NotEnoughMem
   ld hl,OFFSCRPTName
   rst rMOV9TOOP1
   ld hl,OFFSCRPTEnd-OFFSCRPTStart
   bcall(_CreateAppVar)
   inc de
   inc de
   ld hl,OFFSCRPTStart
   ld bc,OFFSCRPTEnd-OFFSCRPTStart
   ldir
   set alt_Off,(iy+scriptFlag)
   ret
NotEnoughMem:
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,NotEnoughMemMsg
   bcall(_PutS)
   bcall(_NewLine)
   ret

NotEnoughMemMsg: .db "Not enough memory!",0
OFFSCRPTName: .db AppVarObj,"OFFSCRPT",0

OFFSCRPTStart:
   .org $8001
   bcall(_GetKey)
   ld a,$A
   ld (pIntMask),a
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,prompt
   bcall(_PutS)
   bcall(_NewLine)
   bcall(_NewLine)
   ld hl,info1
   ;display rest of stuff
   bcall(_HomeUp)
   ld hl,curCol
   ld (hl),$B
   ld b,0
   bcall(_GetKey)
   cp kUp
   jr nz,SecondKeyPress
   inc b
SecondKeyPress:
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   cp kRight
   jr nz,ThirdKeyPress
   inc b
ThirdKeyPress:
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   cp kDown
   jr nz,FourthKeyPress
   inc b
FourthKeyPress:
   ld a,$2A
   bcall(_PutC)
   bcall(_GetKey)
   cp kDown
   jr nz,Next
   inc b
Next:
   ld a,$2A
   bcall(_PutC)
   ld a,b
   cp 4
   jr z,Success
Fail:
   bcall(_ClrScrnFull)
   bcall(_HomeUp)
   ld hl,wrongpassword
   bcall(_PutS)
   bcall(_GetKey)
   jp OFFSCRPTStart
Success:
   ld a,$B
   ld (pIntMask),a
   res alt_Off,(iy+scriptFlag)
   ret

prompt: .db "Password:",0
info1: .db "This calculator belongs to",0
;info2: .db "--- ---",0
;email: .db "---@---.com",0
;phone: .db "(...) ...-....",0
wrongpassword: .db "Wrong password! Try again.",0
OFFSCRPTEnd:
Personally, I would not do this inside a program... But that's just me. Technically, anything is possible, but I believe that there are only a couple of these programs ever created that do what you are trying to do, and none of them are in program form. There is a big difference; it might just be easier to use _PowerOff and that way your program continues execution. This is way beyond my scope; I have not been able to execute a RawGetKeyHook within RAM at this point. I wish that I could help more. Sorry! Sad

EDIT: All that means that you should make it an APP, but if someone with more knowledge than me says otherwise, go with that. Smile
  
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
» Goto page 1, 2, 3, 4, 5  Next
» View previous topic :: View next topic  
Page 1 of 5
» 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