This "suggested method" for testing for a device reset is not well thought through at all.
Do
Sync
`Check If Screen Was Lost First Thing After Sync
If RecoveryMode_ScreenValid() = 0
`Handle Recovery Of Game Assets
RecoveryMode_Main()
`Increment Crash Counter For The Demo Purposes
INC CrashCounter
EndIf
`Operate The Game
YRotate Object 1, Object Angle Y(1) + 0.01
Text 10, 10, "Crashed " + Str$(CrashCounter) + " times."
Loop
End
`Tests whether Screen was lost, based on loaded image being deleted when screen is lost.
Function RecoveryMode_ScreenValid()
retVal = Image Exist(10)
EndFunction retVal
The reason why? The code above assumes the device reset occurs here:
Do
Sync
`Check If Screen Was Lost First Thing After Sync
<---------------------- DEVICE RESET HERE ---------------------->
If RecoveryMode_ScreenValid() = 0
`Handle Recovery Of Game Assets
RecoveryMode_Main()
`Increment Crash Counter For The Demo Purposes
INC CrashCounter
EndIf
`Operate The Game
YRotate Object 1, Object Angle Y(1) + 0.01
Text 10, 10, "Crashed " + Str$(CrashCounter) + " times."
Loop
End
`Tests whether Screen was lost, based on loaded image being deleted when screen is lost.
Function RecoveryMode_ScreenValid()
retVal = Image Exist(10)
EndFunction retVal
And whoever thinks that it
does occur there every time is sadly mistaken. A device reset can occur
at any point during runtime in a DBP application. For example, if it were to happen here:
Do
Sync
`Check If Screen Was Lost First Thing After Sync
If RecoveryMode_ScreenValid() = 0
`Handle Recovery Of Game Assets
RecoveryMode_Main()
`Increment Crash Counter For The Demo Purposes
INC CrashCounter
EndIf
<---------------------- DEVICE RESET HERE ---------------------->
`Operate The Game
YRotate Object 1, Object Angle Y(1) + 0.01
Text 10, 10, "Crashed " + Str$(CrashCounter) + " times."
Loop
End
`Tests whether Screen was lost, based on loaded image being deleted when screen is lost.
Function RecoveryMode_ScreenValid()
retVal = Image Exist(10)
EndFunction retVal
The program will not catch it in time and crash.
The reason why it's working most of the time is because the program spends most of its time refreshing the screen (the "sync" command). Thus, the chance of a program crashing can be calculated with the following formula:
a = time spent processing code
b = time spent refreshing the screen
x = chance of crashing in %
x = 100*a/b
TheComet
Taumatawhakatangihangakoauauotamateapokaiwhenuakitanatahu is a hill
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch is a town
Chargoggagoggmanchauggagoggchaubunagungamaugg is a lake