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: