Real Time Clock help

support for the ARM toolchain
Post Reply
bobingabout
Posts: 4
Joined: Sat Apr 10, 2010 3:31 am

Real Time Clock help

Post by bobingabout » Sun Apr 11, 2010 9:47 pm

ok, i'm not sure where i should post things about general NDS programming, so, i chose here.

I looked at the examples, seems to use time() to get seconds passed since midnight january 1st 1970, which isn't too bad, since what i need is seconds passed since midnight january 1st 2000, which on the PC i calculated from the date and time.

Problem is, what i'm using it for needs to be more accurate than seconds, i need miliseconds (as used in a windows.h time function), or hundredths of a second (as used in dos.h in a borland turbo C++ time function). Anyone know where i can get a fractions of a second return on the nintendo DS?

if you assume seconds is the base unit of our conventional measurement of time, then the Reason why i need this accuracy is because i'm working with a fictional clock (actually more than one) that works with a base different to the length of a second (one is longer, another is shorter). and i don't want the time to tick in seconds, suddenly skipping values, or displaying the same one twice as long every now and then to compensate. EG, anyone ever though about accurately displaying a metric time clock side by side with a conventional time clock? There are 10 metric hours a day, 100 metric mins a metric hour, and 100 metric seconds a metric min. the length of a metric time second, aka quint/quinto/quintoday is different than the length of a second (its basicly the length of a day / 100000, so there's 100 thousand metric seconds in a day, or 24*60*60=86400 seconds a day, so the length of a second is a 86400th of a day, so metric second is a little shorter.). you get my point right?

also, on top of that, reading this tutorial http://www.dev-scene.com/NDS/Tutorials states that the DS can't handle Floating point values. ok, i can work around that (currently i've worked around that by replacing a lot of my decimal point multipliers with percentage values, deviding by 100 at the end of my long formuas, and doing all divides as late in the formula as possible, it gives accurate enough results for the purposes of my project, plus if i need the fraction i can mod 100 instead of devide by 100 to get the remainder), but the tutorial sugests i use fixed point maths, yet the part thats suposed to explain it hasn't been written. Anyone care to link me to any detailed explanation, or tutorials on how fixed point maths works?

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Real Time Clock help

Post by WinterMute » Mon Apr 12, 2010 9:06 am

The RTC operates only in seconds, if you need millisecond accuracy you'll need to work with the hardware timers.

You can use floating point math just fine, it's slower than it would be on a machine with hardware support so obviously you don't want to overuse this.
Help keep devkitPro toolchains free, Donate today

Personal Blog

bobingabout
Posts: 4
Joined: Sat Apr 10, 2010 3:31 am

Re: Real Time Clock help

Post by bobingabout » Mon Apr 12, 2010 6:00 pm

WinterMute wrote:The RTC operates only in seconds, if you need millisecond accuracy you'll need to work with the hardware timers.
i kinda figured something like that, i guess i'll look into timers.
WinterMute wrote:You can use floating point math just fine, it's slower than it would be on a machine with hardware support so obviously you don't want to overuse this.
Really? i can still use floating point maths?

since the game is turn based, most of the "Heavy" maths will only be done when the player, or AI chooses to do something, and i'm quite certain it can be done within a frame, so maybe i should put it back to floating point maths?


Also, i'd still like a tutorial or something on fixed point

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: Real Time Clock help

Post by elhobbs » Mon Apr 12, 2010 6:13 pm

fixed point is not unique to the ds - did you try searching?

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: Real Time Clock help

Post by vuurrobin » Mon Apr 12, 2010 6:23 pm

or look here for a tutorial on fixed point math:

http://www.coranac.com/tonc/text/fixed.htm

but yea, you can still use floating point math, it just is slower than normal.

bobingabout
Posts: 4
Joined: Sat Apr 10, 2010 3:31 am

Re: Real Time Clock help

Post by bobingabout » Tue Apr 13, 2010 7:32 am

vuurrobin wrote:or look here for a tutorial on fixed point math:

http://www.coranac.com/tonc/text/fixed.htm

but yea, you can still use floating point math, it just is slower than normal.
i did, but aparantly i suck at searching XD

thanks for the help

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests