Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Insanely frustrated with the white flashing screens!

Author
Message
Zaxtor99
9
Years of Service
User Offline
Joined: 27th Jul 2011
Location: Boise, Idaho, USA
Posted: 26th Feb 2012 23:04
Okay, one of my first ever DarkBasic Classic games had no flashing screen issues because it was a text game and cleared the screen every time a new choice was made to write new text and options/inventory etc.

Now, trying to make games since that game with very few CLS commands has resulted in erratic flashing screens of white light at completely random times within the game.

I have read some other threads about this, and tried all of the solutions I've seen, but regardless of my code, I still seem to get them, especially when running the final game on a Windows 7 machine.

I have also tried changing the compatibility properties of the program to 'Run this program as an Administrator' and checking three boxes to disable virtual themes, desktop composition, and disabling the display scaling on high DPI settings.

I'd added a CLS 0 and SYNC command to the very beginning of my code, and nothing seems to be working.

Is there sure-fire ways of making sure your program doesn't ever have these sync or flashing problems? I

I never have purchased the full version of DB Pro as of yet, but does it still have their weird problems?

I know that my answer will simply be that the problem is "in my code". I've tried putting the sync command in my code at the end of my main loop so that the program syncs only once per cycle of the main loop, and I have turned sync off completely with SYNC OFF early in the game with no sync commands afterwards. Both give erratic flashing problems however.

I know I asked this same question once before here, and my answer was to use a SYNC command after every text written to the screen. That seems utterly ridiculous to me however as if I did that, I'd have 19,000 SYNC commands in my game.

Just seems there has to be a better way and its frustrating as well because of how erratic and abnormal this flashing issue is. For example, if it happened every time in my game at the same point, at least I could understand it better. But sometimes it happens immediately after running my game, and sometimes it happens 15 minutes into it, and yet other times, it won't happen at all.

Thanks for any help/suggestions in advance!
Quel
11
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 27th Feb 2012 08:33
Well, the intelligent way of doing things is to have a main loop, and ONE sync... the end.

-Mental Hybrid: A unique heavy story based shoot'em ~40% (primary project)
-CoreFleet: An underground commander unit based RTS (canned) ~15%
Zaxtor99
9
Years of Service
User Offline
Joined: 27th Jul 2011
Location: Boise, Idaho, USA
Posted: 27th Feb 2012 15:44 Edited at: 27th Feb 2012 15:47
Yeah, I would agree. However, on my Windows 7 computers, that results in random white flashing screens at random times. On my Windows XP machine, it seems to be pretty stable though.

I guess I could always CLS the screen every loop as well and redraw everything to make sure it doesn't happen, but that doesn't seem "intelligent" as you say.

I guess what I'd love to know here is what specifically causes the white light flashing screens so that maybe I can better understand what I can do to avoid these erratic results in my programs...
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Feb 2012 18:32 Edited at: 27th Feb 2012 18:37
At the top of your program after the SYNC RATE is set, try including the line
cls : sync

That seems to sorta set things up sometimes.


Something to check is inside the setup.ini file which should live in the same directory as DB.exe. There is a flag blitflipmode . If it is set to zero, try setting it to one:

blitflipmode=1

If it is set to one, try setting it to zero. I wrote up a description about it some years ago based on my limited understanding of Direct X 7. It seems to make sense but I haven't really thought about it for a while. Anyway, here is the description


Quote: "blitflipmode Whenever the screen is blitted, display graphics information is basically copied from one area of memory to the other. If a screen is flipped, a pointer to where the display information is in memory, is changed. Flipping is faster than blitting. In windowed mode, graphics are blitted. In fullscreen mode, it seems graphics buffers are flipped. Sometimes, because of video card drivers and the setup of the graphics card, flipping may cause some display problems with DBC - like slow downs, or a disappearing mouse. In these cases, you would set blitflipmode to 1 so that all graphics are blitted through the Windows Graphics Device Interface (GDI). Sometimes when 2d is rendered with 3d, the 2d graphics may flicker or flash. If there are multiple SYNCS called in the program, the 2d portion of the screen that overlaps the 3d portion will be erased and redrawn. If blitflipmode is set to 1, the overlapped portion may flash (because it is being redrawn pixel by pixel); if blitflipmode is set to 0, it will not flash (because the whole image is flipped at once). In general however, I've found most display problems are corrected with blitflipmode=1
"


This also implies that you should included a copy of setup.ini with your executable of your game.

Another possibility: With modern windows OSs there can be some forced timing issues that come with modern Direct X. No matter what the SYNC rate is set to, DBC will lock to a generic sync rate of 60 fps. This isn't the actual screen redraw rate, this is the iteration rate of a loop with a sync command in it:

do
sync
loop

This loop would be forced to run at 17 milliseconds per iteration.

To get around this limitation, load and play a midi or mp3 file as MUSIC (not a sound) at the start of your program. This somehow allows the iteration control back to DBC so you can set whatever sync rate you like. This may also help in controlling the flashing that may be tied to aa imposed limit on synchronization.

One other thing to try, is setting up your own "page flipping" so to speak. You create a background bitmap, do all of your 2d drawing there (including text), and then copy the background bitmap to screen zero (the drawing area):



If you are mixing 2d and 3d, this method will draw over any 3d unless you set DRAW TO BACK before you do your bitmap copy:



Enjoy your day.
Zaxtor99
9
Years of Service
User Offline
Joined: 27th Jul 2011
Location: Boise, Idaho, USA
Posted: 28th Feb 2012 05:16
Latch.. You FLAT OUT ROCK man!

That seems to be what I was missing... was the load mp3 to take control of the timing or whatever from Windows 7.

I first tried to change the setup blitflipmode to 0 as I already had changed it to 1 prior to try and solve this issue.

I then added your load sound "xxx.mp3" command and added an mp3 file to my project folder. Tested and still the flashing screen. (All the rest of my code was the same already such as the CLS and SYNC at the beginning of my program.

So I decided to make a small program and test everything at this point.

I reset the blitflipmode back to 1 in my setup.ini file. Then wrote a small program that clears the screen, sets the display mode,sets the sync rate to 30, then cls:sync again then loads an mp3 file.

Afterwards it simply a center text "Hello" command set the center of my screen followed by a DO:LOOP

With my flipbitmode set to 1, and loading the mp3 file, this sample test ran 50 of 50 times with no flashing!! Awesome!

To verify, I took out the load sound "xxxx.mp3" command and ran again.
3 of 10 times was a flashing screen!

Wow, just wow. You are a life saver... ehh rather an EYE and HUGE frustration saver Latch!!

Thanks a million!


- Zaxx
Latch
14
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 1st Mar 2012 00:15
Glad it worked!

Enjoy your day.

Login to post a reply

Server time is: 2020-08-15 12:48:34
Your offset time is: 2020-08-15 12:48:34