Programming Question


Zaephen said:
crow_riot said:
try adding

Code:
  #include <sys/mman.h>
Thanks Crow, that fixed it :D !
Now could anyone tell me easily what the difference between the value this is giving me vs what I was getting with SDL_GetTicks()?
Just using this with the code I had set up to figure FPS isn't working.

its a little hazy, but basically i think gph kernel isnt correct. There are are multiple timers on the pollux so the code you added just reads the value from a second timer.

Edit opps i missed the point of the question, was about the units.
 
Last edited by a moderator:
You guys freakin' rock! Me thinks I have everything fixed now. I had to multiply the delta (twice I think) to get the the same resolution as SDL_GetTicks() but the log is showing more consistent values than my initial code with SDL_GetTicks. Meaning, before I had values of like 0.002 to 0.010 and everything in between where as now it seems to be 0.007 mostly.
Still wrapping my head around this stuff as it been a good long while since I did any coding (and I was far from an expert even when I did code a bit).
I dislike adding things like Notazs stuff because I don't fully understand how it's doing what it's doing. I need to study up on that stuff more I guess. It works like a freakin' charm though.
As he's mostly responsible for PicoDrive (I think), I'll certainly trust what he says or has written as I think that's one slick emulator. I never was much of a fan of the Genesis but I doubt anyone will argue that PicoDrive runs great.
 
If I may pick your brains once more, I'm still having an issue with loading .png images. I believe it has to do with one of the libraries not being on the WiZ. I've put every libpng.xxx and libSDLimage.xxx file from my dev/target folder and it still won't work (I know that's over-kill LOL).
Anyone know off-handedly which other lib I'm missing that I should add or what else the problem could be?
 
Zaephen said:
Rodolfo said:
When the machine executes this code from main(), tick1 is not initialized yet.
I believe it is. The first thing main() does is call Initialize() in which I have "tick1 = SDL_GetTicks();".


Ooops... Damn CTRL+F ;) I didn't see tick1 being initialized in Initialize() call. Sorry.
 
Last edited by a moderator:
Zaephen said:
If I may pick your brains once more, I'm still having an issue with loading .png images. I believe it has to do with one of the libraries not being on the WiZ. I've put every libpng.xxx and libSDLimage.xxx file from my dev/target folder and it still won't work (I know that's over-kill LOL).
Anyone know off-handedly which other lib I'm missing that I should add or what else the problem could be?

i recall the wiz png library having issues. try linking to libpng12 or include the toolchain png12 lib with you binary
 
Last edited by a moderator:
Pickle said:
Zaephen said:
If I may pick your brains once more, I'm still having an issue with loading .png images. I believe it has to do with one of the libraries not being on the WiZ. I've put every libpng.xxx and libSDLimage.xxx file from my dev/target folder and it still won't work (I know that's over-kill LOL).
Anyone know off-handedly which other lib I'm missing that I should add or what else the problem could be?

i recall the wiz png library having issues. try linking to libpng12 or include the toolchain png12 lib with you binary
I included all the libpng12.so.something files just to be sure and it still won't load the image :(. Any other ideas?
 
Last edited by a moderator:
I think it is actually libpng.so.3.* you need. At least that worked for me. Take lib/target/libpng.so.3.29.0 from GPH-SDK and rename it to libpng.so.3 on the SD card.
 
hmn said:
I think it is actually libpng.so.3.* you need. At least that worked for me. Take lib/target/libpng.so.3.29.0 from GPH-SDK and rename it to libpng.so.3 on the SD card.
Worked like a charm. Thanks buddy ;).
 
Last edited by a moderator:
For those of you that have done such a thing, what is the best way to run your game at 60 FPS? If you look at the code I posted at the beginning of this thread, it allows the program to run as fast as it can but keeps things moving at a given velocity. Could someone give me a good example of forcing the program to run at 60 FPS?
Meaning, would you allow it to run as fast as is can, keeping track of how many FPS its rendered, then when it has reached 60, force it to bypass doing anything except running through the game loop until the next second starts?
 
Zaephen said:
For those of you that have done such a thing, what is the best way to run your game at 60 FPS? If you look at the code I posted at the beginning of this thread, it allows the program to run as fast as it can but keeps things moving at a given velocity. Could someone give me a good example of forcing the program to run at 60 FPS?
Meaning, would you allow it to run as fast as is can, keeping track of how many FPS its rendered, then when it has reached 60, force it to bypass doing anything except running through the game loop until the next second starts?

the most basic method is to measure the start and end of the game loop, if this time is less then 16 ms (1000/60=16.66) you simply wait/delay the time left. If you get greater than the limit you can do frame skipping. But as you might see this will actually be 63 fps since the 16.66 is rounded to 16. (you may avoid this if you used a higher resolution timer like the wiz has, but if you use SDL which a 1ms res, then you have this behavior)

ive been using this method to get an exact 60 fps. If you take the timeperiod for 3 frames in succession the total time is an even 50 ms.
Measure the first 2 frames with the 16 ms duration, but measure the third frame with reference to when the frame group was started over a 50 ms duration. This third frame will sync/correct for the error caused by the first 2 frames.

Edit: Another way you may account for the timer inaccuracy is to use a vsync to trigger drawing of the frame. But again this isnt necessarily portable across devices.
 
Last edited by a moderator:
Exophase said:
I definitely recommend the vsync method nonetheless so you prevent tearing.
Does SDL/Linux/WiZ support vsync?
 
Last edited by a moderator:
Zaephen said:
Exophase said:
I definitely recommend the vsync method nonetheless so you prevent tearing.
Does SDL/Linux/WiZ support vsync?

Wiz yes (there might be an example in wizlib, cant find out at the moment, i think though it just checking a value in memreg address)
standard GPH SDL no
ikari SDL yes (see http://www.gp32x.de/board/index.php?/topic/50876-copy-320x240-buffer-to-240x320-screen/page__view__findpost__p__820187__hl__vsync__fromsearch__1)
 
Last edited by a moderator:
Back
Top