#22595 - col - Thu Jun 24, 2004 8:27 pm
I have been writing some hblank based fx. Part of one of the effect involves switching on a transparent overlay layer at a specific scanline. The effect worked fine on VisualBoyAdvance, but on hardware, there was a 2 line gap. When I setup the code to switch the layer on two lines early, it works fine on hardware, but obviously glitches on vba.
My (tentative) conclusion is that it takes the gba video processor about two scanlines to turn a layer on. Can anyone confirm this?
I can work around this problem by using a slightly different approach to achieve the same effect without switching layers on or off, but I am interested to know if anyone else has experienced this issue?
Are there other similar hardware-related timing constraints to beware of when developing hblank fx?
cheers
Col
#22596 - poslundc - Thu Jun 24, 2004 8:36 pm
Ah, you've run into the infamous REG_DISPCNT bug. Well, it's not so much a bug as it is a trait of the hardware that's not properly reflected by emulators. Basically, turning on any of the backgrounds during VDraw will result in a couple of scanline's worth of garbage.
For what you're describing, though, it should be just as easy to do it with windows instead. If you don't have the windows to spare, another plausible approach (off the top of my head) would be to have an auxillary map of transparent squares set up in VRAM, and just switch REG_BGXCNT on the appropriate scanline to switch away from the transparent map to your overlay.
OR, since you're doing it as a translucent overlay, if you wanted to get really kooky with it you could set your effects register to blend 100% of the background and 0% of the foreground, then switch it to 50/50 (or whatever) when you hit your scanline.
Dan.
#22597 - tepples - Thu Jun 24, 2004 8:38 pm
col wrote: |
I have been writing some hblank based fx. Part of one of the effect involves switching on a transparent overlay layer at a specific scanline. The effect worked fine on VisualBoyAdvance, but on hardware, there was a 2 line gap. |
Known "feature" in hardware:
http://forum.gbadev.org/viewtopic.php?t=2232&highlight=layer+scanlines
It takes a couple scanlines to turn a layer on. I may have to do some tests to investigate the exact nature of the "garbage" that appears when a layer is not all the way turned on yet. (It may be possible to use this as an anti-emulation technique.) But you can use windowing to work around this: tell a layer to display only within a window.
Quote: |
Are there other similar hardware-related timing constraints to beware of when developing hblank fx? |
You do need to load the first scanline's data during vblank.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#22603 - sgeos - Fri Jun 25, 2004 2:37 am
tepples wrote: |
Quote: | Are there other similar hardware-related timing constraints to beware of when developing hblank fx? |
You do need to load the first scanline's data during vblank. |
One probably wants to calculate next scanline's state this scanline.
-Brendan
#22621 - poslundc - Fri Jun 25, 2004 2:14 pm
sgeos wrote: |
tepples wrote: | Quote: | Are there other similar hardware-related timing constraints to beware of when developing hblank fx? |
You do need to load the first scanline's data during vblank. |
One probably wants to calculate next scanline's state this scanline. |
Or, calculate the state for every scanline during VBlank and store them in an array for easy access.
Of course, if you're just switching an effect such as a translucent layer on and off, you just need to calculate which line you want to do it on.
Dan.
#22767 - col - Mon Jun 28, 2004 11:59 pm
Thanks for the input guys.
Its good to know that there is a lag issue with REG_DISPCNT, and it wasn't just me going nuts.
For what its worth, I'll either use the blending regs, or (more probably) update my overlay tilemap to include an empty section, then juggle that with the scroll registers. The reason i'm favouring the more complicated option is that I'm am considering dividing up my overlay for other uses anyway, so an extra section won't be any hassle.
cheers
Col