Combining *REFRESH with WAIT

In attempting to write programs which run in both BBC BASIC for SDL 2.0 and Matrix Brandy I have in the past had difficulty achieving synchronisation with vertical refresh on both (without using conditional code). After some experimentation this pair of statements seems to do the trick:
*REFRESH
WAIT
In BBCSDL the *REFRESH waits for vSync and the WAIT does nothing, in Matrix Brandy the *REFRESH doesn't wait for vSync but the WAIT does. The end result seems to be that the same thing happens on both.

Comments

  • That'll be an implementation error on my part as I wasn't aware of that subtlety. I can add a WAIT call to *Refresh.
  • Soruk wrote: »
    That'll be an implementation error on my part as I wasn't aware of that subtlety. I can add a WAIT call to *Refresh.
    I assumed that *REFRESH not waiting for vsync was for compatibility with BBC BASIC for Windows which, since there's no way of achieving it in GDI32, doesn't either (it's one of the more surprising limitations of GDI32 that such a capability wasn't provided, perhaps early video cards didn't make it possible).

    Because of the nature of SDL 2.0 the 'refresh' and the 'wait for vsync' are inseparable, since both happen as a result of calling SDL_RenderPresent(), hence *REFRESH unavoidably works differently in BB4W and BBCSDL.

    So I'm happy with the way things are. Anyway your proposal would result in an incompatibility with existing programs, since if you were to make that change any program (containing both *REFRESH and WAIT) would render at half speed, since both would wait for vSync!

    Ensuring existing programs (of which there must be tens of thousands) continue to work properly is my number one consideration when making any changes or extensions to my BASICs, but seems not to concern you at all when making changes to Matrix Brandy! I find such a divergence of approach mystifying, and a little scary.
  • With Matrix Brandy being much newer, I take the approach that it's highly likely there are bugs and implementation misinterpretations, and those should be fixed - you've been working on BBC BASIC in one form or another for almost as long as I have lived so your history and background have far more breadth and depth than I could ever hope to have. But, since you have implementations of *Refresh that don't wait for vSync, then I'll leave it alone.
  • Soruk wrote: »
    With Matrix Brandy being much newer, I take the approach that it's highly likely there are bugs and implementation misinterpretations, and those should be fixed
    I adopted the 'don't make incompatible changes' policy when my BASICs were still quite young! For example I discovered the ADVAL bug in BB4W quite early on, but have never fixed it to this day (probably 20 years later) because of that concern, and I even copied the bug into BBCSDL. :p

    Think of the poor BASIC programmer, which in this case is me. Suppose you did change Matrix Brandy to make *REFRESH wait for vSync, then for a considerable (indeed indefinite) period of time there would be users with the old version (which doesn't wait) and users with the new version (which does).

    How then would I write a program with the intention of it running in Matrix Brandy? Basically I couldn't, unless the program somehow tested the version at runtime and used different code depending on what it found. I don't consider that to be an acceptable overhead.