Hello,
Sorry, I posted this thread before I had properly tested it. I was wondering if WAIT with no parameters behaved differently in BBCSDL vs BB4W, but now I see that they seem to behave the same. It looks like WAIT with no parameters waits for one centisecond.
I posted this thread because I noticed that my TENIS ball game seemed to run slower on BB4W. I'm going to examine further and see if I can work out why.
Regards,
Patrick
Behaviour of WAIT?
-
- Posts: 177
- Joined: Mon 02 Apr 2018, 21:51
Re: Behaviour of WAIT?
Now I know what I was wondering about - it's the behaviour of *REFRESH, not WAIT.
In BBCSDL, *REFRESH seems to wait for vsync. In BB4W, this isn't the case.
I tested it with this short program:
In BBCSDL, *REFRESH seems to wait for vsync. In BB4W, this isn't the case.
I tested it with this short program:
Code: Select all
*REFRESH OFF
TIME=0
C%=0
REPEAT
C%+=1
UNTILTIME>100
PRINTC%
*REFRESH
TIME=0
C%=0
REPEAT
C%+=1:OSCLI"REFRESH"
UNTILTIME>100
PRINTC%
*REFRESH
TIME=0
C%=0
REPEAT
C%+=1:WAIT
UNTILTIME>100
PRINTC%
*REFRESH
Re: Behaviour of WAIT?
Well, rather a minimum of one centisecond (it hands back control to the Windows kernel, so a task switch is likely; how long it waits will depend on what other processes are running and how many CPU cores there are).
What made you think that WAIT might be responsible? If your program involves any I/O (i.e. it's not performing purely a computational task), and particularly graphics output, then there's no reason to expect its speed to be at all similar on BB4W and BBCSDL. I've seen programs that run much slower in BBCSDL compared with BB4W, and others that run much faster.I noticed that my TENIS ball game seemed to run slower on BB4W.
The example program 'squares.bbc' supplied with BBCSDL (all editions) is a case in point: on this PC it runs something like ten times faster in BBCSDL than in BB4W! This is by no means typical, but does indicate just how large the difference can be.
Richard.
-
- Posts: 177
- Joined: Mon 02 Apr 2018, 21:51
Re: Behaviour of WAIT?
Hello,
It turned out that the game was running slower in BB4W because of a timing routine in my game. The timing code counts the number of frames drawn for 1 second, and then uses that number to decide how fast the ball should move. This was intended to make it run at the same speed in case of different refresh rates. But it seems that it doesn't work correctly, so the game ended up running too slowly on BB4W.
Patrick
I got confused and thought it was WAIT because in my game code, WAIT and *REFRESH were next to each other. And that was because I originally wrote the game for RISC OS, where WAIT was there to wait for VSYNC, and originally in the place of the *REFRESH command, there was a procedure call that I wrote to operate RISC OS's features for switching screen banks.What made you think that WAIT might be responsible? If your program involves any I/O (i.e. it's not performing purely a computational task), and particularly graphics output, then there's no reason to expect its speed to be at all similar on BB4W and BBCSDL. I've seen programs that run much slower in BBCSDL compared with BB4W, and others that run much faster.
It turned out that the game was running slower in BB4W because of a timing routine in my game. The timing code counts the number of frames drawn for 1 second, and then uses that number to decide how fast the ball should move. This was intended to make it run at the same speed in case of different refresh rates. But it seems that it doesn't work correctly, so the game ended up running too slowly on BB4W.
Patrick