I seem to remember some discussion a while back about making BMax itself more resistant to screensavers interrupting it, but I don't recall the details. In any case, I looked around and found
a thread on it (by netmaestro & Indiepath) with a solution, resulting in this code (not cross-platform, it's Windows-only, but that's one down and two to go):
' Below is from <a href="http://www.blitzbasic.com/Community/posts.php?topic=48372" target="_blank">http://www.blitzbasic.com/Community/posts.php?topic=48372</a>
Import "-luser32"
Extern "win32"
Function SystemParametersInfoW(stuff1:Int,Stuff2:Int,Stuff3:Int,Stuff4:Int) = "SystemParametersInfoW@16"
EndExtern
Const SPI_SETSCREENSAVEACTIVE :Int = 17
Const SPIF_SENDWININICHANGE :Int = 2
SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, False, Null, SPIF_SENDWININICHANGE) ' saver off
Local start = MilliSecs()
Graphics 800,600',32,85 '<-uncomment for full screen
Repeat
Cls
DrawText ( MilliSecs() - start ) / 1000, 10,10
Flip
' below reenables it after 70 seconds (with a 1 minute delay, it does kick in at 130 secs)
'If( ( MilliSecs() - start ) / 1000 ) = 70 ..
' SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, True, Null, SPIF_SENDWININICHANGE) ' saver on
Until KeyDown(KEY_ESCAPE)
SystemParametersInfoW(SPI_SETSCREENSAVEACTIVE, True, Null, SPIF_SENDWININICHANGE) ' saver on
Rem
There's also this, from <a href="http://www.devx.com/vb2themax/Tip/19033" target="_blank">http://www.devx.com/vb2themax/Tip/19033</a>
which provides additional functionality that could be converted:
Private Const SPI_SETSCREENSAVEACTIVE = 17
Private Const SPI_GETSCREENSAVEACTIVE = 16
Private Const SPIF_SENDWININICHANGE = &H2
Private Const SPIF_UPDATEINIFILE = &H1
Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
' return the Enabled state of the screen saver
Function GetScreenSaverState() As Boolean
Dim result As Long
SystemParametersInfo SPI_GETSCREENSAVEACTIVE, 0, result, 0
GetScreenSaverState = (result <> 0)
End Function
' enable or disable the screen saver
'
' if second argument is true, it writes changes in user's profile
' returns True if the operation was successful, False otherwise
Function SetScreenSaverState(ByVal enabled As Boolean, _
Optional ByVal PermanentChange As Boolean) As Boolean
Dim fuWinIni As Long
If PermanentChange Then
fuWinIni = SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE
End If
SetScreenSaverState = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, enabled, _
ByVal 0&, fuWinIni) <> 0
End Function
EndRem
In my tests (setting my saver to a 1-minute delay), I found that the saver wouldn't a start in fullscreen or windowed while a BlitzMax program was running, even without the "turn off" function above - I think that might be BlitzMax being resistant as I seem to recall reading. Actually, the saver
did start in windowed mode (my cursor briefly became an arrow/hourglass at the 1-minute mark), but didn't appear on screen (or interfere with my BlitzMax program's window) until I pressed Escape to end the program, at which point I saw my saver.
With the above code, though, that didn't happen. So it seems to disable the saver for real. I added the re-enable call to make sure that the saver would come back up after this program finished, and it did. I also tried out the commented-out test to see if the saver could be re-enabled after 70 seconds, while the program was running and it worked (the hourglass didn't appear at 60 seconds, but did at 130 seconds).