English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 23 June 2019, 18:04   #1
MartinW
Registered User
 
Join Date: Mar 2017
Location: Minehead / UK
Posts: 608
Understanding framerate

I think I'm confusing myself!

Simple question...

If I have a main loop such as this (pseudo code):

Code:
while (!mouseClick())
{
    gameLogic();

    WaitTOF();
    updatePlayfield();
}
Not taking into account when things get too slow and it can't render at full speed for now, will that loop 50 times per second on PAL, 60 times per second on NTSC due to the WatTOF, or will it loop as fast as it possibly can?

[EDIT] I'll leave the question there but never mind. As soon as I posted I noticed I had a setting wrong in my WinUAE display settings!!
MartinW is offline  
Old 05 July 2019, 06:17   #2
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,400
Post

Quote:
Originally Posted by MartinW View Post
I think I'm confusing myself!

Simple question...

If I have a main loop such as this (pseudo code):

Code:
while (!mouseClick())
{
    gameLogic();

    WaitTOF();
    updatePlayfield();
}



Not taking into account when things get too slow and it can't render at full speed for now, will that loop 50 times per second on PAL, 60 times per second on NTSC due to the WatTOF, or will it loop as fast as it possibly can?

[EDIT] I'll leave the question there but never mind. As soon as I posted I noticed I had a setting wrong in my WinUAE display settings!!
I was playing around with this kind of update loop back in the 80's, from memory my solution was this:

Code:
while (!mouseClick())
{
   ticks = (currentTime - lastTime)
    
    gameLogic(ticks);

    updateDisplay();
}
The idea behind this approach is that the faster your CPU is then the smaller the ticks will be for updating your game world which will result is smoother movement (and more frames per second) but the world will always be updated in a linear manner (no slow-down, just frame skipping on slower CPU's).

I could be wrong though, that was many years ago
NovaCoder is offline  
Old 05 July 2019, 12:15   #3
MartinW
Registered User
 
Join Date: Mar 2017
Location: Minehead / UK
Posts: 608
Well I did consider that perhaps I should be using a timer but I was more thinking about that from a knowing my FPS point of view which in the end I just enabled the onscreen display in Win-UAE and my monitor

[EDIT] I just added an artificial delay to my 'GameLogic' method and realised that the WinUAE FPS display is always displaying 50 anyway regardless of how many updates per second my game is doing because at the end of the day, that's the FPS of the emulated monitor. So I could do with an FPS display anyway. Hmm, so I am going to need to tackle fonts earlier than I thought!

BUT, doesn't that only work if you're double-buffering and can therefore write to the screen at any point? I need to ensure I'm not updating the display outside of VBlank which is why I have the Wait in there.

I'm still a little stuck but for a different reason and I think my current problem is more ensuring that the sprite hardware doesn't read from my sprite struct when I'm updating it which works 99.9% of the time but it looks like it occasionally doesn't work.

Last edited by MartinW; 05 July 2019 at 12:24.
MartinW is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Saint Dragon framerate fix Puggsy project.WHDLoad 20 22 May 2019 19:05
WHDLoad low framerate - tooltype options? AndersHP support.Apps 5 07 March 2011 14:22
[A1200] Weird skips in framerate (WHDLoad) 8bitbubsy support.Hardware 2 16 January 2010 12:39
Stunt Car Racer framerate john4p support.WinUAE 18 03 December 2008 21:45
Framerate limit not working when JIT enabled rsn8887 support.WinUAE 0 18 October 2008 05:09

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 20:02.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.13765 seconds with 15 queries