• Welcome to SCdev.org. Please log in.

Welcome to the new SCdev forums!

multiple backgrounds question

Started by ferroptic, September 27, 2006, 09:28:47 PM

Previous topic - Next topic

ferroptic

This is for the NDSlib gurus out there-

I can't seem to figure out how to define graphical backgrounds for more than one background layer -

ie, I know I can make a rotation background as both BG2 and BG3 in mode 5, and I can set up bits like

SUB_BG2_CR = BG_BMP8_256x256;
SUB_BG3_CR = BG_BMP8_256x256;

I can load graphical data into BG_GFX_SUB, but I can't find a way to differentiate where that data's headed between BG2 and BG3. I expect them to have to share a pallette, but is there a way to make sense of how to load data into them?

I've used dmaCopy to copy binary image data, and used the loadPCX .data16 method, and using either can get one background humming no problem, scrolling it around and stretching it and all kinds of nice things. I just can't seem to find documentation on how to specify even a memory register for another background to use, so I could dump the data directly to the memory and just assign a layer to look at a certain address. If it was as simple as the library having a BG3_GFX_SUB I'd have licked it by now, but I'm pretty worn out on this.

Anyone have a clue for a self taught noob?

Kudaku

i didn't exactly read your post but maybe you should try gbadev.com
try the forums there

bitblt

I'm not sure I understand exactly what you are trying to do, but I hope this helps.

I set the BG modes like this . . .

videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);

I set the VRAM banks like this . . .

vramSetMainBanks(VRAM_A_MAIN_BG_0x6000000, VRAM_B_LCD, VRAM_C_SUB_BG_0x6200000, VRAM_D_LCD);

I set BG3 and SUB_BG3 like this . . .

BG3_CR = BG_BMP16_256x256;
SUB_BG3_CR = BG_BMP16_256x256;

Now I have two pointers, BG_GFX (top screen) and BG_GFX_SUB (bottom screen).  I can copy data from the top screen to the bottom screen like this . . .

dmaCopy(BG_GFX, BG_GFX_SUB, 256*256*2);

or manipulate screen pixels directly like this . . .

for (u32 i = 0; i < bg_size; i++) BG_GFX = 31 | BIT(15);
   
If you want to mix multiple BGs on the same screen then study the DevKitPro Complex_2D example.

ferroptic

Quote from: "bitblt"
If you want to mix multiple BGs on the same screen then study the DevKitPro Complex_2D example.

Yeah, this is exactly what I'm trying to do. The complex2d example tiles solid color blocks into a map in a way that I can't find any good documentation for. I suppose I could import the graphics I have in a similar tile fashion, but I don't really understand how the maps work very well.

Basically, I have a background for one screen that stays static - then, on the other screen, a "field" that's 2 screens high - 256x384 - that I want to scroll up and down following a sprite. Since neither 256x384 or 256x512 are valid background sizes, I've tried exhaustively loading data into a 512x512 background, but I can't seem to get it to display right - so I figured I'd make 2 256x256 ones, and tie their scroll values such that it would appear to operate as one scrolling 256x512(really only 256x384) background. I've loaded a 256x192(one screen dimension) image into a single 256x256 with no problem, and scroll it around with transparency working fine.

Splitting the different image data into the two backgrounds is what's proving difficult, and my initial thought was to try to duplicate the checkerboards on the complex2d file.

Anyone have a good tutorial on tile maps and screen bases and all the other ndslib CR attribs whatever they are that make that file work? The for loops that draw the tiles seem simple enough, but I don't understand how the system knows those maps apply to each background layer, etc.

Kudaku, I'll check there, but I have had nothing but good experiences posing questions here, and so I figured I'd hit this up first.

Thanks all-