Question about Inp ?

New to FreeBASIC? Post your questions here.
Daniel Ouellette
Posts: 96
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: Question about Inp ?

Post by Daniel Ouellette »

Even if it seems to work, it would be better to use Screensync since it also works. When the graphics card doesn't support Screensync, does it just go straight through or can it freeze?
Daniel Ouellette
Posts: 96
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: Question about Inp ?

Post by Daniel Ouellette »

I'll use Screensync if it's safe, that is, if it won't jam. But, the synchronization effect of "A = Inp(&h3da)" is still interesting.
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Question about Inp ?

Post by Imortis »

Daniel Ouellette wrote:I'll use Screensync if it's safe, that is, if it won't jam. But, the synchronization effect of "A = Inp(&h3da)" is still interesting.
Why or how would it jam? I have used screensync before, no issues.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Question about Inp ?

Post by caseih »

Are you using Inp with the Windows 32-bit or 64-bit compiler or are we talking about the DOS version?
Daniel Ouellette
Posts: 96
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: Question about Inp ?

Post by Daniel Ouellette »

I asked the question for Screensync because I have no idea what could be behind this command.

It's Windows 32-bit compiler.
Daniel Ouellette
Posts: 96
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: Question about Inp ?

Post by Daniel Ouellette »

In both cases, Screensync or "A = Inp(&h3da)", the synchronization effect is the same and the execution time is between 0.00001 sec and 0.01790 sec (a bit more sometimes).

0.00001 sec indicates that the graphics card has ended tracing the frame juste at the time of the Screensync command (as well as with "A = Inp(&h3da)"), I have doubts about the efficiency of the synchronization at that moment.
fxm
Moderator
Posts: 12108
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Question about Inp ?

Post by fxm »

Look at my article and example: Graphics Mode Refresh and Anti-Flickering
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Question about Inp ?

Post by Imortis »

Daniel Ouellette wrote:I asked the question for Screensync because I have no idea what could be behind this command.

It's Windows 32-bit compiler.
The windows Screensync translates to roughly this:

Code: Select all

Sleep(1000 / iif(refresh_rate, refresh_rate,60))
So it is just waiting for the set refresh rate of the system, and if that is not set, it just defaults to 1 60th of a second.
Daniel Ouellette
Posts: 96
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: Question about Inp ?

Post by Daniel Ouellette »

I'm not an expert like all of you, so I stupidly used "Sleep(1000 / iif(refresh_rate, refresh_rate,60))" and it doesn't work as well as Screensync and even "A = Inp(&h3da)".
Daniel Ouellette
Posts: 96
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: Question about Inp ?

Post by Daniel Ouellette »

According to my tests, Screensync and "A = Inp(&h3da)" query the hardware. It is not a Sleep related to the refresh rate.
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Question about Inp ?

Post by Imortis »

Daniel Ouellette wrote:According to my tests, Screensync and "A = Inp(&h3da)" query the hardware. It is not a Sleep related to the refresh rate.
I don't know what to tell you, then. This is the C code for the graphic library. There is no hardware query during Screensync.

Code: Select all

void fb_hWin32WaitVSync(void)
{
	Sleep(1000 / (__fb_gfx->refresh_rate ? __fb_gfx->refresh_rate : 60));
}
That is all it does in Win32, at least.

The refresh rate is grabbed by the library when you initialize a graphic screen. If you init a screen, it uses that, if you did not, it use 1/60 of a second.
Daniel Ouellette
Posts: 96
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: Question about Inp ?

Post by Daniel Ouellette »

What is Wait Vsync ?
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Question about Inp ?

Post by caseih »

It's the internal FB runtime function that Screensync calls on Windows.
Daniel Ouellette
Posts: 96
Joined: Apr 17, 2011 17:43
Location: Montréal, Canada
Contact:

Re: Question about Inp ?

Post by Daniel Ouellette »

Is it more than a Sleep ?
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Question about Inp ?

Post by Imortis »

Daniel Ouellette wrote:Is it more than a Sleep ?
No. That was the point of me posting it. That is exactly what code is executed when you call screensync or wait with the port number.
Post Reply