#16841 - jenswa - Wed Feb 25, 2004 8:13 pm
Most pc games have an option to display the fps in the game.
Some gba demo's i've seen have a fps display too.
My question, how to create a fps display in my own gba demo?
Display the counter isn't the problem, but calculating the fps is.
Apart from the fact, my demo is synced with WaitForVsync(), i could create a static counter with 60.
But that is not what i was looking for.
If i comment the WaitForVsync() the function, my demo runs much faster, i want have the frame rate displayed then.
Any awnsers?
Jenswa
_________________
It seems this wasn't lost after all.
#16843 - poslundc - Wed Feb 25, 2004 8:46 pm
Since you know that the vertical refresh occurs approximately 60 times per second, you can just use a global variable to count the number of times your code runs in a single frame.
Then when VBlank arrives, update your FPS display with your counter multiplied by 60. Then reset the counter to zero. (Be careful, if your code is fast enough to run a second time before VBlank is finished then you will have to maintain a flag to know when you are in and out of VBlank.)
Or if you want, count it over 60 VBlanks to obtain a more precise result, and then don't multiply by 60. Just maintain an additional counter so you know how many VBlanks have gone past before displaying. This is probably a better way, as it will also work if your FPS is less than 60.
For more accurate results, you could increment your counter every time through the game loop, and then set a timer interrupt to fire after exactly a second has passed. That interrupt then updates a variable that you display every VBlank as the FPS, and then resets the counter to zero.
Dan.
#16856 - jenswa - Wed Feb 25, 2004 11:18 pm
What your saying sounds logicial to me, but i am not sure i am following you.
Quote: |
Since you know that the vertical refresh occurs approximately 60 times per second, you can just use a global variable to count the number of times your code runs in a single frame. |
Should i put a global variable in my main loop (the stuff between the while(1) ) and increase it every loop, enable vblank interrupt, so when vblank occurs i can display the global variable and after that reset the global variable to zero.
For more accuracy, i can count the number of vblanks and divide (shouldn't use it too much and the gba) the global variable by the number the vblanks.
I am not following this part: "use a global variable to count the number of times your code runs in a single frame".
_________________
It seems this wasn't lost after all.
#16866 - tepples - Thu Feb 26, 2004 5:07 am
jenswa wrote: |
Should i put a global variable in my main loop (the stuff between the while(1) ) and increase it every loop, enable vblank interrupt, so when vblank occurs i can display the global variable and after that reset the global variable to zero. |
That's exactly it. However, I'd use a bit of a low-pass filter to smooth out the displayed frame rate over a few frames so that you can display "in-between" rates; otherwise, you will have it jumping back and forth between 60 and 120.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#16869 - dagamer34 - Thu Feb 26, 2004 5:13 am
J. Harbor's programming book has example of what tepples is talking about.
_________________
Little kids and Playstation 2's don't mix. :(
#16885 - jenswa - Thu Feb 26, 2004 9:42 am
Cool, i am now at school, i'll try it out when i come home later this day.
Thanks for the explaination.
_________________
It seems this wasn't lost after all.
#16888 - FluBBa - Thu Feb 26, 2004 12:45 pm
In your mainloop you have a global variable that you count up for every loop it does.
In your VBlank interrupt you have a variable that you count up by one every VBlank.
When the VBlank variable reaches 60, read out the mainloop variable and display it.
Now reset both variables.
Loop.
I hope that made any sense =)
_________________
I probably suck, my not is a programmer.
#16889 - jenswa - Thu Feb 26, 2004 12:47 pm
Yup, i thought of that last night when i couldn't sleep, haven't tried it, but should work.
Thanks
_________________
It seems this wasn't lost after all.
#17191 - Burre - Wed Mar 03, 2004 9:33 am
This might be a little bit OT, but it is a question that have been nagging me for quite some time. How common is it to use 30 Hz instead of 60 Hz? How many of you have that setup? The reason for asking is that I have been calculating on performance hit with my end product and is opting for an 30 Hz (I could really use the runtime). How noticable is the difference? I know it is significantly slower but if the display is synced, will it really matter? Is it really noticable?
_________________
"The best optimizer is between your ears..."
#17197 - poslundc - Wed Mar 03, 2004 3:21 pm
This is an interesting question, and something you'd have to experiment with to see.
According to film theory, persistence of vision can be achieved as low as 12-15 FPS. Video in North America is shot at 30 FPS (NTSC) and in Europe at 25 FPS (PAL).
So 30 FPS is certainly enough in theory. In practice I personally find (although I haven't tested this on the GBA) that I can still sometimes tell the difference between 30 FPS and a higher framerate, although there are diminishing returns the higher it gets, ie. there's no way I could tell the difference between 48 and 60 FPS.
I think 60 FPS might be a good choice as a kind of Nyquist rate: if the general audience perceives 30 FPS as fluid motion, double it to ensure they never miss a beat. This might be more important on the GBA than other media, since the player is much closer to the screen than they are to a television set or a movie screen.
If you want to do stuff at 30 FPS, just make sure you keep in mind that since you need to sustain the image for two frames, you've still only got 68 lines of VBlank (every other frame) in which to update the screen. Let us know if you find a visible difference.
Dan.
#17199 - ampz - Wed Mar 03, 2004 3:56 pm
Movies are 24FPS.
Another thing to think about is the speed of moving stuff on your screen. If the sprites in your game move at a speed of 30pixels per second, then 60FPS will make no difference at all compared to 30FPS.
In one game I have been working on the sprites move at 15pixels per second, so I simply use 15FPS.
#17201 - poslundc - Wed Mar 03, 2004 5:44 pm
Another thing to keep in mind is that a higher frame rate can naturally provide you with a tighter game loop for more accurate game physics, AI, etc.
I think that even more than persistence of vision, this is the compelling reason for having a 60 Hz refresh rate.
Other than that, I'm not even certain why the refresh rate of the GBA is 60 Hz. On monitors, etc. it makes sense because your display refresh isn't guaranteed to be synched to the application, so you want to at least double the refresh rate in order to make sure you can achieve 30+ FPS from the software to the screen.
On the GBA, however, the application is synched to the hardware. If 30 FPS is sufficient, you'd think they'd use it as their refresh rate.
Dan (now considering the possibility of reducing his game's frame rate and gaining tons more processing time).
#17208 - ampz - Wed Mar 03, 2004 7:53 pm
They probably use 60fps just to make the screen flicker free.
30fps software framerate would save some battery by allowing the GBA to stay in halt mode for longer periods of time...
#17210 - XeroxBoy - Wed Mar 03, 2004 10:05 pm
NTSC TVs use 60Hz, right?
Nintendo probably synched the GBA to that to simplify porting old games. I'm sure PAL gamers can attest to what happens when a lazy developer modifies a game for a different monitor and doesn't properly synch things up.
#17211 - Miked0801 - Wed Mar 03, 2004 10:33 pm
NTSC is 30Hz Interlaced - 60 hz even lines, 60 Hz odd so overall of 30Hz. PAL is 25Hz - 50Hz every othe line but with no overscan so you have more area to display stuff :)
#17213 - ampz - Thu Mar 04, 2004 12:40 am
Overscan?
PAL have more area (higher resolution) because of the lower refreshrate.
Old games (like SNES games) must operate with 25FPS / 30FPS due to the interlacing.
#17214 - poslundc - Thu Mar 04, 2004 12:44 am
Miked0801 wrote: |
NTSC is 30Hz Interlaced - 60 hz even lines, 60 Hz odd so overall of 30Hz. |
Actually, this also answers my question of why the GBA is 60 Hz... it also interlaces (more-or-less) to an effective 30 Hz.
Dan.
#17222 - FluBBa - Thu Mar 04, 2004 11:45 am
ampz wrote: |
Old games (like SNES games) must operate with 25FPS / 30FPS due to the interlacing. |
No way. Yes the SNES can supply an interlaced signal to the TV, but it doesn't have to and not many games use it.
And even when sending an interlaced signal you can still update your graphics at 50/60FPS and see it.
_________________
I probably suck, my not is a programmer.
#17253 - Burre - Fri Mar 05, 2004 2:23 am
poslundc wrote: |
This is an interesting question, and something you'd have to experiment with to see.
According to film theory, persistence of vision can be achieved as low as 12-15 FPS. Video in North America is shot at 30 FPS (NTSC) and in Europe at 25 FPS (PAL).
So 30 FPS is certainly enough in theory. In practice I personally find (although I haven't tested this on the GBA) that I can still sometimes tell the difference between 30 FPS and a higher framerate, although there are diminishing returns the higher it gets, ie. there's no way I could tell the difference between 48 and 60 FPS.
I think 60 FPS might be a good choice as a kind of Nyquist rate: if the general audience perceives 30 FPS as fluid motion, double it to ensure they never miss a beat. This might be more important on the GBA than other media, since the player is much closer to the screen than they are to a television set or a movie screen.
If you want to do stuff at 30 FPS, just make sure you keep in mind that since you need to sustain the image for two frames, you've still only got 68 lines of VBlank (every other frame) in which to update the screen. Let us know if you find a visible difference.
Dan. |
Yeah I know about the Vblank issue, but thanks for reminding me. I'm only using it for data transfer to VRAM so it works fine. I've heard earlier that about 20 (which is close to your estimated 12-15) is the limit to feel animation so I'm not worried about that. But I'm not sure how smooth it will look and feel. One should probably not think 30 fps movie and 30 fps game as equal either since the frames in movies are "blurred" during intense movement and games are static images. In that way, a movie and a game at the same Hz will look different.
I will definately look in to it and give feedback on the issue. I just have to reorganize my draw and update fuctions properly, and then I'll test it for visual differences on actual hardware. I'll get back to you on that after my mid term exams. 388 lines of calculations *drool*.
_________________
"The best optimizer is between your ears..."
#17433 - ampz - Mon Mar 08, 2004 2:16 am
FluBBa wrote: |
ampz wrote: | Old games (like SNES games) must operate with 25FPS / 30FPS due to the interlacing. |
No way. Yes the SNES can supply an interlaced signal to the TV, but it doesn't have to and not many games use it.
And even when sending an interlaced signal you can still update your graphics at 50/60FPS and see it. |
I did a quick search. You are right.
The SNES had a resolution of 256x224. This means the SNES simply treat the TV as a 50/60Hz non-interlaced monitor at the expense of cutting the resolution in half.
#17826 - Burre - Mon Mar 15, 2004 3:17 pm
I'm back from mid-term exams and have tried to alter the fps. Imho 30 fps is to slow when moving a lot of gfx simultaneously, it wasn't a viable solution for us, so we're probably aiming at 60 fps. Obj movement looked ok, but mapscrolling looked awful in our demo. So I guess 60 is the way to go...
_________________
"The best optimizer is between your ears..."
#17838 - Miked0801 - Mon Mar 15, 2004 6:30 pm
Um. We run an RPG at 30Hz without issue here. You're really gonna hamstring yourself trying to stay at 60Hz. Look a bit closer. Perhaps your game was fluctuating 60,30,60,20,60,etc. at looke gittery because of it.
#17856 - Burre - Tue Mar 16, 2004 1:37 am
Well it all depends. How fast are you moving sprites and BG around? Our game is a space/adventure so movements are quite intense. Sure it might be "regular" glitches, but I doubt it.
What about triggering vblank at even 60Hz (with IRQ) and letting gameplay calculations reside inside the vdraw and letting it "overflow" it's timeframe when needed. Would that be a worse solution? It would mean updating every/every-other frame, but only slowing down when needed.
_________________
"The best optimizer is between your ears..."
#17879 - OptiRoc - Tue Mar 16, 2004 2:27 pm
The difference between 30 and 60 fps is very pronounced, even on a GBA display. For an example, compare Wai Wai Racing with Super Mario Kart SC. Konami uses the extra processing time for a more advanced camera routine, but I can't say it's worth the trade-off.