Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Link on August 28, 2012, 06:40:25 pm

Title: Turn off Calc and Exit Program in Axe?
Post by: Link on August 28, 2012, 06:40:25 pm
Well, been playing around with Axe for a month or so, and was wondering if there's a way to turn off the calculator and exit the program? Is there some sort of axiom or asm technique to do that?
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Deep Toaster on August 28, 2012, 06:58:48 pm
:Asm(FDCB1696)
:Return


The first line tells the calculator to power off when the program exits, and the second line exits the program. (If you are in a subroutine when you run this, you should use Returnr instead of Return.)

Spoiler For Spoiler:
The first line actually tells the OS that the batteries are too low to run... Seems to work anyway :P
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Link on August 28, 2012, 07:02:33 pm
Brilliant! Thanks, really appreciate it!
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Deep Toaster on August 28, 2012, 07:10:35 pm
Edited my post (Runer112 pointed some stuff out over IRC).
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Hayleia on August 30, 2012, 09:22:17 am
:Asm(FDCB1696)
:Return


The first line tells the calculator to power off when the program exits, and the second line exits the program. (If you are in a subroutine when you run this, you should use Returnr instead of Return.)

Spoiler For Spoiler:
The first line actually tells the OS that the batteries are very low... Seems to work anyway :P
It doesn't work with zStart when the program is set on startup D:
(however, it works when launched from homescreen :))
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Xaychru04 on October 07, 2012, 03:55:01 pm
Wow, we can do a lot of things including pure assembly in an axe program !
I wanted to do a screen saver one month ago with axe but I didn't know how to launch it automaticly...
Anyway, I don't think it's possible to tell the OS to launch the program automaticly ^^
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: shmibs on October 07, 2012, 04:38:22 pm
/me is curious about this as well.
what would one have to do to make a program that automatically launches after a given amount of time, regardless of whether or not there is any user input? would modifying the os to add in a bit of code executed during interrupts work?
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: thepenguin77 on October 07, 2012, 09:07:36 pm
This sounds like a job for OFFSCRPT.

OFFSCRPT.8xv (appVar) gets copied to $8001 every time the calculator turns off. This catches both 2ND + ON as well as APD. So instead of going to APD, it can just display your screen saver.

Here's what your OFFSCRPT would look like:
Code: [Select]
.org $8001
bit 4, (iy + 8)
ret z ;this was a purposeful turn off


;do whatever you want, here's an example if you want to run an axe program

ld hl, axeName
rst 20h
bcall(_executePrgm)



;when you are done, you have two options

ret ;this will turn the calculator off

bcall(_jForceCMDNoChar) ;this will turn the calculator on

axeName:
.db protProgObj, "AXEPROG", 0


I realize this isn't exactly an axe answer, but, this is what must be done.
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Xaychru04 on October 08, 2012, 01:20:17 pm
I found a French tutorial that explains how to program in hexadecimal (I'm french), but it seems pretty difficult O.o
@thepinguin77: I've never used assembly but I'll try as soon as I can access to an emulator :)
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Matrefeytontias on October 08, 2012, 01:27:51 pm
@Xaychru04 ah ... that's mine ;D As far as I know, I wrote the only French hex tutorial (well, I never found another one, and you can believe that I searched).
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Xaychru04 on October 08, 2012, 04:45:20 pm
Yes, it was yours, and it's an excellent tutorial !
I will test programming in hexadecimal on an emulator too because I don't know if an error can just clear the RAM like Axe ( xD ) or can corrupt the memorry etc...
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Matrefeytontias on October 09, 2012, 01:43:35 am
Thanks :)

And yeah, you'd better program on an emulator, even if there is only a small chance of doing something else than a RAM clear (but there's still a chance ;) ).
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: bored_student on November 21, 2012, 10:58:18 am
Quote
OFFSCRPT.8xv (appVar) gets copied to $8001 every time the calculator turns off. This catches both 2ND + ON as well as APD. So instead of going to APD, it can just display your screen saver.

My OFFSCRPT always crashs the calc. The code is copied to $8001 and executed. But every times it reaches bcall(_jForceCMDNoChar) the calculator simply doesn't react anymore


I leaved the
bit   4, (iy + 8 )
out because this way the bit is set always and my code is never executed
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Matrefeytontias on November 27, 2012, 10:04:49 am
Up,

thepenguin77, are you sure that your code will work assuming that the OS disables the LCD before calling OFFSCRPT ?
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: thepenguin77 on November 27, 2012, 12:41:35 pm
Quote
OFFSCRPT.8xv (appVar) gets copied to $8001 every time the calculator turns off. This catches both 2ND + ON as well as APD. So instead of going to APD, it can just display your screen saver.

My OFFSCRPT always crashs the calc. The code is copied to $8001 and executed. But every times it reaches bcall(_jForceCMDNoChar) the calculator simply doesn't react anymore


I leaved the
bit   4, (iy + 8 )
out because this way the bit is set always and my code is never executed

The OS does not disable the LCD before calling OFFSCRPT.

Quote
OFFSCRPT.8xv (appVar) gets copied to $8001 every time the calculator turns off. This catches both 2ND + ON as well as APD. So instead of going to APD, it can just display your screen saver.

My OFFSCRPT always crashs the calc. The code is copied to $8001 and executed. But every times it reaches bcall(_jForceCMDNoChar) the calculator simply doesn't react anymore


I leaved the
bit   4, (iy + 8 )
out because this way the bit is set always and my code is never executed

Post the code, that's the only way I can tell what's wrong with it. Also, bit 4, (iy + 8) is the APD flag. I do RET Z because the code you're looking at was for a screensaver, and you wouldn't want a screen saver to run if you were turning the calculator off on purpose.
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Matrefeytontias on November 27, 2012, 12:47:08 pm
As FloppusMaximus said here (http://www.cemetech.net/forum/viewtopic.php?p=195738#195738) :

Quote from: FloppusMaximus
Well...

- Before calling OFFSCRPT, the OS turns the LCD off and disables all interrupts (via port 3.)
[...]
- GetKey halts the CPU, which freezes the system since interrupts have been disabled.
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: thepenguin77 on November 27, 2012, 12:56:52 pm
As FloppusMaximus said here (http://www.cemetech.net/forum/viewtopic.php?p=195738#195738) :

Quote from: FloppusMaximus
Well...

- Before calling OFFSCRPT, the OS turns the LCD off and disables all interrupts (via port 3.)
[...]
- GetKey halts the CPU, which freezes the system since interrupts have been disabled.

Well, then I am wrong ;D You've convinced me to go disassemble the mechanism that calls OFFSCRPT because I guess I don't actually know where it is.
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Matrefeytontias on November 27, 2012, 01:11:07 pm
I tried to turn back the LCD on in OFFSCRPT :

Code: [Select]
.org $8001
 ld a,3
 out ($10),a
 ret
.end

It effectively turned the LCD on ... but then freezed O.o
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: thepenguin77 on November 27, 2012, 01:24:45 pm
Well, the problem here is that your code was not actually being run. I forgot, but OFFSCRPT copies one too few bytes (which is why it starts at $8001 btw). So, when you make your call to bcall(_createAppvar), just increase the size by one.
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: Matrefeytontias on November 27, 2012, 01:46:51 pm
Yay, I got it working !

This code, when turning the calc off by any mean, keeps the LCD on until you press [clear].

Code: [Select]
.org $8001
  ld a,3
  out ($10),a
loop:
  ld a,$FD
  out (1),a
  in a,(1)
  bit 6,a
  ret z
  jr loop
.end

I assume that it may be possible to run an Axe program as thepenguin77 said above but adding the two first lines of my code.
Title: Re: Turn off Calc and Exit Program in Axe?
Post by: bored_student on December 03, 2012, 09:51:22 am
My problem was that the display turned off and I didn't notice the calculator was nevertheless turned on.

I will try it once again as soon as I have a bit more time x.x