gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Finding: The GBA window behaves oddly

#125786 - Dwedit - Tue Apr 17, 2007 12:47 am

Illustration: [Images not permitted - Click here to view it]

What's happening: At scanline #141, I'm updating DISPCNT and WIN0H.
Here are the register values:

WIN0H (before):0...0
WIN0H (after) :129...200
WIN1H: 40...200
WIN0V: 8...152
WIN1V: 8...152
WININ0: SFX O 3 _ 1 _
WININ1: SFX O 3 2 1 0
DISPCNT (before): W1 on, W0 off, Layer 3 off, layer 0,1,2 on
DISPCNT (after): W1 on, W0 on, Layer 0,1,2,3 on

So basically 'layer 3' changes from off to on, and 'window 0 enabled' changes from off to on. The window 1 stuff is probably irrelevant.

What's supposed to happen is that layer 3 gets enabled for Window 0, but instead, layer 3 stays disabled for 2 scanlines after the change! The effect varies across emulators, NO$GBA shows what ideally should happen (wrong), and VisualBoyAdvance shows the layer disabled for only one scanline.
Having layer 3 enabled in DISPCNT for all scanlines seems to fix the glitch.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#125790 - DekuTree64 - Tue Apr 17, 2007 1:52 am

It has nothing to do with the window. It is a known hardware limitation that turning on a BG layer takes a couple scanlines (and if I remember right, displays random garbage in the meantime). However, you can change an active BG's settings all you want, so you can point it to a blank screen map to effectively turn it off.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#125791 - tepples - Tue Apr 17, 2007 1:54 am

DekuTree64 is right.

In another topic (several years ago?) about mid-screen mode changes such as those used in F-Zero and Mario Kart games, we discovered that turning layers on and off mid-screen using DISPCNT causes artifacts for a few scanlines. Using the window registers produces the desired effect. But unfortunately, phpBB search is insufficient and forum.gbadev.org blocks Googlebot, so I can't dig up more information.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#125935 - gladius - Wed Apr 18, 2007 10:00 am

I think this was the thread you were talking about Tepples: http://forum.gbadev.org/viewtopic.php?t=1303&highlight=.