Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Speed difference program with sync on and off

Author
Message
bfrnhout
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Vlissingen
Posted: 13th Sep 2010 22:54
I find a difference in a program that i wrote. Its not finished but some code i have made and it can run. When i run it with
SYNC ON
and i update the screen manualy the sprite animation i put in runs faster then when i turn
SYNC OFF
And let the DB make the automatic refresh (i think its 40 FPS). the animation is going slower.
the function i wrote

My question is why is there a difference i give the animation a delay value for the next frame. so i think i suppose i do not have to see a difference.

What is wrong in my point of view.

Games is live so to live do the games
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Sep 2010 15:31
SYNC OFF activates a sleep command in the sync processing, which allows the rest of Windows to steal more of a share of the processor.

You can control that flag directly with the SYNC SLEEP command after you've use SYNC ON (which clears the flag) or SYNC OFF (which sets it).

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
bfrnhout
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Vlissingen
Posted: 15th Sep 2010 22:44
I am loosing you. In my program i try to work with the command SYNC ON to do it manualy. Then my animation is running at the speed it intended to do.
When i remove the line from the program and let DBP do it all by himself the animation is running slower. In the manual says than DBP wil run on 40 FPS. So i do not give any SYNC command.
I did set the FPS rate to 60 and then the animation is running on the speed it supposed to run.
It does not matter if windows is stealing resource time or not. The internal clock counter is used to determen when the next frame is due.
And the manual is writing that SYNC SLEEP gives the time to windows on the value that is given.

What i did do was running a timer in the function to see what time difference there must be. TO my supprice there was no time difference. So if that is not there why then the animation difference.

Games is live so to live do the games
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 15th Sep 2010 23:51
What are you asking? By Default Db runs at 40 fps unless you change it. If you set it to 60 it will run at 60, if possible. Obviously the animation will run slower if you are running at 40 fps compared to 60. Always turn sync on and use sync at the end of your loop. It will run better. Also don't bother setting your fps at all just use set display mode x,y,32,1.

http://s6.bitefight.org/c.php?uid=103081
Mugen Wizardry
User Banned
Posted: 15th Sep 2010 23:52
multiply ur speed factors by timer based movement. theres an awesome plugin by ShaunRW somewhere in the forums that does just that. =D

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 16th Sep 2010 01:47
You are confusing "sync on" with "v-sync". It seems like there is the same, but they are not. I have found that if I don't use "sync on", sprites will flicker. If you are wanting to turn "v-sync" off, simply don't turn it on. I use code similar to this:

if I want "v-sync" off and:

if I want "v-sync" on.

The fastest code is the code never written.
Mugen Wizardry
User Banned
Posted: 16th Sep 2010 01:48
THEN use Timer Based Movement to make it even better speed it will stop MOST lag

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Sep 2010 04:41
Quote: "When i remove the line from the program and let DBP do it all by himself the animation is running slower. In the manual says than DBP wil run on 40 FPS. So i do not give any SYNC command. "


If you use SYNC OFF and it runs slower and if slower = bad... then SYNC OFF = bad. It shouldn't be an issue for you to keep SYNC ON and never ever use SYNC OFF.

If you do have timer based animation/movement then don't limit the frames per second to 40 or 60 fps but let the roof off by using SYNC RATE 0. At zero it SYNCs as fast as the computer running it can handle it.



Using the above code snip with SYNC RATE 0 I get about 1,500 fps.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Sep 2010 15:05
Quote: "If you do have timer based animation/movement then don't limit the frames per second to 40 or 60 fps but let the roof off by using SYNC RATE 0. At zero it SYNCs as fast as the computer running it can handle it."


There's absolutely no point in doing that unless you are deliberately trying to use the GFX card as a fast processor which isn't the case in most games applications. On high performance GFX cards you can often hear an audible background scream or whistle when the GFX card is running at maximum fps. That's probably not good for either your sanity or the graphics card. I now try to remember to use "sync rate 0" only when I'm benchmarking. No point otherwise.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Sep 2010 15:05
In addition, with the Sleep command being issued, and other processes grabbing the processor for a time, you also have to remember that windows doesn't have to give control back to you until the sleep has expired (normally up to 10ms on XP) and all other programs at the same priority level as your program have also had a chance to run for a while.

Bottom line, if your process sleeps, then there are no guarantees on speed at all, and it can vary drastically depending on what else is running on your system.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Sep 2010 19:48
Quote: "On high performance GFX cards you can often hear an audible background scream or whistle when the GFX card is running at maximum fps."


Woah, I had no idea they did that. Of course I haven't had too many high quality graphics cards.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Sep 2010 23:43
Yes, when the fps gets into the 1000s or so. It's something to do with high frequency interference in the sound circuitry or something like that.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 17th Sep 2010 20:33
When you use sync off (which it is by default), every time you use a command which draws something to the screen, like a sprite or text command, the screen is automatically synced. therefore, you will actually be updating the screen many time per game loop which is what causes the flickering.
When using sync off, the screen will only update when you tell it. Therefore you won't get any flickering.

My signature is NOT a moderator plaything! Stop changing it!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Sep 2010 21:17
Quote: "When using sync off, the screen will only update when you tell it"


When using sync on perhaps?
bfrnhout
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Vlissingen
Posted: 17th Sep 2010 22:41
Thanks people. I hope i can bring the discussion to the right point.

Some awser i get is a good reason.

The game i am writing has a lot of time based animation. The animation is over 15 to 20 frames.
I do care the speed of the animation. And the animation is made so that even slower computer can handle it. Its not a new game or somthing. I dit wrote it in another basic program (BLITZ3D). And there i did miss a few things. Like sprite in 2D, Gamma setting on the sprite. And because i do a lot of work on the screen in B3D you must redaw the whole screen. And that give extra proces time.

What i was thinking is that if DBPro do the automatic frame rate and the timing set in the sprite that the animation was on time.

I did calculate the follow rule 1 sec = 1000 ms. So on 40 FPS = 25 ms. so i want te animation on 25 ms. But at game speed of 40 FPS. It means that DBPro some time missed the next frame and not displaying it. Even if the 25 ms are passed on some kind of reason DB is not skipping but holding the last frame. And then the animation is slower.

But i can not understand that, Why, simple i did put a timer on the call of this function and than and the time between call 1 and call 2 is 12 ms. So this code is called twice within the 25 ms.

What i think is the following:
The 2 times calling is 24 ms and the animation is 25 ms. 1 ms short. so the next call is at 36 ms. 11 ms overdue. the next frame of animation is showing. And the timer restart a 0 until it reach 25 again. So the next animation frame is again 11 ms overdue.
If this is reason what happend than i understand why my animation is slow.

Keep in mind i did take the average of the timing. The max was 35 ms and min was 2.

I hoop i make any sence of what i telling here.

Games is live so to live do the games
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 18th Sep 2010 18:53
Are you using

TIMER() OR HITIMER()??

HITIMER() is part of the Matrix1Utils DLL collection.

If you are using TIMER() then that is likely to be your problem. It's inaccurate and can screw up all kinds of things.

HITIMER() (as I understand it) references the system high performance timer, which is much more accurate and reliable.

Give that a try and see if your animations smooth out.

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 18th Sep 2010 19:03 Edited at: 18th Sep 2010 19:03
Quote: "I now try to remember to use "sync rate 0" only when I'm benchmarking."


You mean you don't use V-Sync normally (for non-benchmarking stuff)?
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 18th Sep 2010 19:20
If you want to limit the game to 40 fps then just user the timer approach suggested by others. Setting the framerate to 40 fps in DB actually puts pauses in the code to keep it at 40 fps, something you do NOT want to do.

http://s6.bitefight.org/c.php?uid=103081

Login to post a reply

Server time is: 2026-07-22 22:06:51
Your offset time is: 2026-07-22 22:06:51