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.

DS development > Problem with Windows

#86727 - LiraNuna - Thu Jun 08, 2006 8:21 pm

I know how windows are working, and even used them on the GBA back then.
But is it me, or they are wierd on the DS?

I follow only GBAtek for my gfx needs, and I assume it's the same on the DS (it even crosspand the defines in libnds' video.h...).
I am using window 1 (yes, it's enabled on 0x4000000, and Window X0, X1, Y0 and Y1 are already inited) and I want my display as follows:

BG0, BG1, BG3 and Sprites are on:
    BG0 is displayed inside and outside of window1
    BG1 is shown only inside window 1
    BG3 is allways displayed on top on both BGs
    HW Effect is applied on BG3
    Sprites anywhere on the screen
    Priority: BG3 > BG1 > Sprites > BG0

So I follow my needs, and sets up my code with info from GBAtek:

Code:
WIN_IN = BIT(8) | BIT(9) | BIT(11) | BIT(12) | BIT(13);
WIN_OUT = BIT(0) | BIT(3) | BIT(4) | BIT(5);


Result:
    BG0 is showing inside and outside window 1.
    BG1 isn't showing at all.
    BG3 is showing inside and outside window 1.
    Sprites are showing inside and outside window 1.
    HW effects are applied.


Thanks for your help.

#86739 - DekuTree64 - Thu Jun 08, 2006 9:05 pm

I know you said it is, but it sounds like win1 isn't turned on, or isn't sized properly. Make sure all the regs you're setting are for the same screen, and that they're not being overwritten anywhere (like ORing bits into the window size regs, which I think are write only).

Also keep in mind that the window size reg fields are only 8 bits each, so if you try to set the window 256 pixels wide, it will overflow. This kind of hurts the usefulness of windows on the DS, but I guess they decided it wasn't worth the extra cost to redesign the hardware to get that one last pixel.

There's also a weird problem that the top coordinate of the window doesn't seem to take effect until it gets at least 7 pixels down from the top of the screen. Any less than 7 and the window just extends all the way to the top of the screen. I guess it's a hardware bug of some sort.

EDIT: I ran some tests, and the top coordinate doesn't work within the upper 7 pixels unless the bottom coordinate is ALSO within the upper 7. Then it works fine. Bizarre.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#86746 - LiraNuna - Thu Jun 08, 2006 9:47 pm

The window is turned on, and the coordinates are fine.
When I change WIN_IN and WIN_OUT registers, I get diffrent results, but never what I really want i.e only BG0 clipped with the window (Black on inside of window).

I never got anything to be only inside of a window, but that's what windows are for...

#86997 - LiraNuna - Sun Jun 11, 2006 9:30 am

No one can help?
</n00b>

#88090 - LiraNuna - Sat Jun 17, 2006 3:19 pm

I got my problem solved. no thanks for help

#88093 - Dark Knight ez - Sat Jun 17, 2006 3:33 pm

Sorry I could not be of any help. If I were knowledgable on the subject, I would have responded to your request.
May I enquire as to how you solved your problem?