Equivalent to Windows GetTickCount();

Post Reply
tomjkear
Posts: 5
Joined: Wed Sep 30, 2009 1:03 pm

Equivalent to Windows GetTickCount();

Post by tomjkear » Wed Sep 30, 2009 1:46 pm

Sorry to create another post but this is a totally seperate issue I am pondering over.
I regularly use the Windows GetTickCount() function for timing things within Windows apps.
Is there an equivalent function for NDS development or can someon assist me in writing one?
Alternatively is there a better method for ensureing events are triggered at the right times?

Thanks again,
Tom

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

Re: Equivalent to Windows GetTickCount();

Post by vuurrobin » Wed Sep 30, 2009 3:36 pm

I think most people use vblank for timing stuff. if you want something more acurate, then using the hardware timers will probably be better I think.

as for GetTickCount(), I think its easier to keep a counter yourself and increase it every vblank.

tomjkear
Posts: 5
Joined: Wed Sep 30, 2009 1:03 pm

Re: Equivalent to Windows GetTickCount();

Post by tomjkear » Wed Sep 30, 2009 6:09 pm

vuurrobin wrote:I think most people use vblank for timing stuff. if you want something more acurate, then using the hardware timers will probably be better I think.

as for GetTickCount(), I think its easier to keep a counter yourself and increase it every vblank.
Thanks for the response.

So how do I go about either method? Do I just increment a variable after passing the vblank function call within the main game loop? If so, how do I then turn this into a count for timing?

I am reading bits and pieces about hardware timers...the DS has 4!? How do I implement a timer using these?

Cheers,
Tom

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

Re: Equivalent to Windows GetTickCount();

Post by vuurrobin » Wed Sep 30, 2009 10:32 pm

incrementing a variable after the waitForVBlank function is probably the easiest, but if your code may take longer than 1 vblank cycle, then setting up a vblank interupt might be more acurate. as for converting it, 60 vblanks takes about 1 second.

I haven't worked with the hardware timers (yet), but looking at the libnds docs might help:
http://libnds.devkitpro.org/a00102.html

Post Reply

Who is online

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