Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Broseph Radson on January 21, 2011, 09:05:54 pm

Title: 84+/SE System Clock?
Post by: Broseph Radson on January 21, 2011, 09:05:54 pm
Does anyone know how to get the system time on an 84+? I know how to get the battery state and free ram and some other stuff (thanks to wikiti) but i dont know how to get the time. Im assuming it will require Asm(hex).
Title: Re: 84+/SE System Clock?
Post by: jnesselr on January 21, 2011, 09:07:51 pm
Does anyone know how to get the system time on an 84+? I know how to get the battery state and free ram and some other stuff (thanks to wikiti) but i dont know how to get the time. Im assuming it will require Asm(hex).
Yes, well it's kinda complicated.  There are several ports that describe it.  And yes, it will require asm(

Look at this: http://wikiti.brandonw.net/index.php?title=83Plus:Ports:40
Title: Re: 84+/SE System Clock?
Post by: calc84maniac on January 21, 2011, 09:10:05 pm
Code: [Select]
.Input is pointer to 4-byte area to write the 32-bit time value (little endian)
Asm(0E45EDA20CEDA20CEDA20CEDA2)
.Output is pointer+4, and time value is written to memory

Assembly source here:
Code: [Select]
ld c,$45
ini
inc c
ini
inc c
ini
inc c
ini
Title: Re: 84+/SE System Clock?
Post by: Broseph Radson on January 21, 2011, 09:10:23 pm
O.o so i need to get a value from ports 45 thru 48 then?
Title: Re: 84+/SE System Clock?
Post by: Xeda112358 on January 21, 2011, 09:13:35 pm
Since Axe uses up to 65535, usually, you will probably have to deal with a simple timer. For example, doing Asm(DB456FDB4667 *should* store the current timer value mod 65536 in Ans.
Title: Re: 84+/SE System Clock?
Post by: Broseph Radson on January 21, 2011, 09:22:11 pm
Code: [Select]
.Input is pointer to 4-byte area to write the 32-bit time value (little endian)
Asm(0E45EDA20CEDA20CEDA20CEDA2)
.Output is pointer+4, and time value is written to memory

Assembly source here:
Code: [Select]
ld c,$45
ini
inc c
ini
inc c
ini
inc c
ini

Is there a way to format the output of this, and make it update? It doesnt appear to update within the program (its in a subroutine that is called once on each iteration of my main loop)
Title: Re: 84+/SE System Clock?
Post by: calc84maniac on January 21, 2011, 09:24:07 pm
I don't understand what you mean. Could I see the source code?
Title: Re: 84+/SE System Clock?
Post by: Broseph Radson on January 21, 2011, 09:30:31 pm
K
Code: [Select]
Fix 0
Fix 5
Repeat getKey(15)
sub(TR)
DispGraphClrDraw //EDIT: This is also in there lol
End

Return

Lbl TR //time and RAM :)
Asm(EFE542EF9247EF5641)->R //RAM
Asm(0E45EDA20CEDA20CEDA20CEDA2)->T //time i guess
Text(0,56,R>Dec
Text(70,56,T>Dec //Without >dec it only displays a 4, with it it diplays some weird long number
Return
Title: Re: 84+/SE System Clock?
Post by: calc84maniac on January 21, 2011, 09:33:39 pm
You have to put a pointer to the place to store to in the "last result". Example:
Code: [Select]
°A
Asm(0E45EDA20CEDA20CEDA20CEDA2)
Then A holds low 16 bits and B holds the high 16 bits.
Title: Re: 84+/SE System Clock?
Post by: Broseph Radson on January 21, 2011, 09:42:02 pm
Oh i see what you mean by confusing. Ill be back later. Just got my n64 hooked up so imma play Goldeneye with my dad
Title: Re: 84+/SE System Clock?
Post by: Broseph Radson on January 24, 2011, 05:28:32 pm
OK finally got a chance to get back to this. I tried using that method and its one big long number ???
Title: Re: 84+/SE System Clock?
Post by: calcdude84se on January 27, 2011, 09:05:53 am
Indeed. It is the number of seconds since January 1, 1970, making it equivalent to Unix time (http://en.wikipedia.org/wiki/Unix_time)
You'll have to convert seconds into years, months, days, hours, minutes, and seconds. ;)
Title: Re: 84+/SE System Clock?
Post by: Broseph Radson on January 28, 2011, 12:02:43 pm
Im trying to do something like the Basic GetTimeStr(12)
Title: Re: 84+/SE System Clock?
Post by: FloppusMaximus on January 28, 2011, 11:27:37 pm
I think it's actually the number of seconds since January 1, 1997, and it's local time, not UTC.  So not exactly Unix time.

Quote
Im trying to do something like the Basic GetTimeStr(12)
What does that do?  I don't remember how the BASIC time functions work.
Title: Re: 84+/SE System Clock?
Post by: Xeda112358 on January 28, 2011, 11:29:07 pm
Quote
Im trying to do something like the Basic GetTimeStr(12)
What does that do?  I don't remember how the BASIC time functions work.
That returns a string telling the time, normally.
Title: Re: 84+/SE System Clock?
Post by: FloppusMaximus on January 29, 2011, 12:08:22 am
Well, if you're only interested in the time of day (not the date), that's relatively easy.  Doing it in pure Axe, using only 16-bit math, would be interesting and difficult, but the boot code provides an undocumented routine (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:80B1) that you can use to divide a 32-bit number by a 16-bit number.  Something like this (untested):
Code: [Select]
Asm(
217884  ; ld hl, OP1
014904  ; ld bc, $0449
0D      ; dec c
EDA2    ; ini
20FB    ; jr nz, $ - 5
113C00  ; ld de, 60
EFB180  ; B_CALL Div32ByDE
)
{e8486}→S ; number of seconds
Asm(
113C00  ; ld de, 60
EFB180  ; B_CALL Div32ByDE
)
{e8486}→M ; number of minutes
Asm(
111800  ; ld de, 24
EFB180  ; B_CALL Div32ByDE
)
{e8486}→H ; number of hours
would obtain the hours, minutes, and seconds since midnight; I'll let somebody else figure out how to turn that into a string.
Title: Re: 84+/SE System Clock?
Post by: ferox on January 31, 2011, 12:31:18 am
Im trying to do something like the Basic GetTimeStr(12)

i do know a BASIC syntax for this:

Code: [Select]
getTime->L1

this stores the hours into L1(1) mins into L1(2) and secs into L1(3)
btw, it only knows 24 hours, no AM or PM display
Title: Re: 84+/SE System Clock?
Post by: calcdude84se on February 01, 2011, 08:40:33 pm
Sadly, he's looking for Axe code. That'd work for BASIC, though ;)
Floppus, nice! Didn't know about that bcall :D
Title: Re: 84+/SE System Clock?
Post by: thepenguin77 on February 01, 2011, 08:54:07 pm
i do know a BASIC syntax for this:

Code: [Select]
getTime->L1

And just like almost every basic command, it has a bcall counter part. bcall(_getTime) puts seconds, minutes, and hours all on the floating point stack. The method of retrieval can vary, but there are two distinct strategies. Pop and grab each one through op1, or pop them consecutively into op1 2 and 3.

So, method 1:
Code: [Select]
EF5B51 EF9043 grab OP1 seconds EF9043 grab OP1 minutes EF9043 grab OP1 hours
And method 2:
Code: [Select]
EF5B51 EF9043 EF8D43 EF8A43 OP1 = secs OP2 = minutes OP3 = hours


Just remember that those answers are TI floating point. So you'll have to convert them.

Title: Re: 84+/SE System Clock?
Post by: calcdude84se on February 01, 2011, 09:00:09 pm
Axe has float{ for that (converting from TI FP), so your method will work too :)