gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > get ticks?

#37483 - quonic - Fri Mar 11, 2005 11:18 pm

Is there a "get_tick" function or register?
The reason I ask is because I wan't to be able to calculate the time elapsed sense the GBA has been truned on.
_________________
Comming Soon: http://www.spyingwind.com

#37487 - DiscoStew - Sat Mar 12, 2005 12:25 am

Since it has been turned on, or would when the program actually begins execution be feasible enough? The latter seems simple enough if you decide to use the GBA's Timers right when your code begins executing.

As for right when the GBA is turned on, I haven't the slightest clue.
_________________
DS - It's all about DiscoStew

#37491 - quonic - Sat Mar 12, 2005 1:16 am

I guess as soon as the program starts.
'cus all I wan't to do is count the Frame Rate while ingame.
It is intended to help my engine "auto skip" frames.
Ex:
Code:

int b=1;
int y=0;
int x=100;

while(true)
{
  ham_ClearBackBuffer(0);

  b=getFPS(); // Returns Current FPS
  b=60-b;  // I think 60 FPS is the max I dont know

  ham_PutPixel(x, y+b, 1); // b is ment to move the pixel faster
 
 
  ham_FlipBGBuffer();
}



_________________
Comming Soon: http://www.spyingwind.com

#37493 - zazery - Sat Mar 12, 2005 1:36 am

First thing I suggest is to not count all the time elapsed. You can count the frames per second using the hblank interrupt. I don't use HAM so I won't know if there was anything for it in the library. You have to understand that functions like 'ham_ClearBackBuffer()' aren't actually in the hardware, they are in the code the author of HAMlib wrote. It is possible to write your own function to count the FPS though it is harder than using the HAMlib to do it.

Check out these topics I found when I searched for 'fps' on the fourm:
frames per second
Game Concepts for Newbie

#37504 - poslundc - Sat Mar 12, 2005 8:01 am

Fundamentals:

The GBA goes through an entire draw-blank cycle approximately every 60th of a second.

This means that when your program begins, you can initialize a global variable to zero, and every time VBlank occurs increment it by one. Divide this number by 60 to obtain the number of seconds that have passed since your program began.

Dan.

#37523 - quonic - Sat Mar 12, 2005 4:53 pm

Thanks for ya'lls help.
_________________
Comming Soon: http://www.spyingwind.com