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 > Help: multiple palettes? [solved]

#166632 - Emmanuel - Thu Feb 12, 2009 3:22 pm

Well, first of all, in my BackgrounsAllInOne example, the extended palette is missing, it's an empty function... in case that was the example that answers this...

Well, what I'm trying to accomplish:
To have each background with a different tile set, map, and palette...

I load the palette with:
Code:
memcpy(BG_PALETTE, buffer, size);

and
Code:
memcpy(BG_PALETTE_SUB, buffer, size);


But that gives me one palette per screen... how can I make it so each background can have it's palette? I'm gonna be using multiple layers, 256 colors each, and only the most recently added bg looks like it's supposed to (obviously... according to my code...)


Last edited by Emmanuel on Fri Feb 13, 2009 4:07 pm; edited 1 time in total

#166641 - albinofrenchy - Thu Feb 12, 2009 5:52 pm

As far as all this graphics stuff goes, I'm a complete newb and have never used an extended palette. But if you haven't looked at this tutorial yet, it might be beneficial for you.

#166661 - elwing - Fri Feb 13, 2009 8:12 am

I think TONC documentation about palette is still relevent for the NDS... and if that is the case, it is the document you want to read...

#166664 - Emmanuel - Fri Feb 13, 2009 10:34 am

Tonc seems to be for GBA, and I didn't found anything about extended palettes...
I got how to write the Palette: I set a bank as LCD, write, and then set the bank to ext_palette... but I still don't get how to tell the BG which palette to use, it still uses the defaul one apparently...
LiraNuna's is for an older libnds apparently, as the code didn't compile, and he uses gfx2gba... while I use grit...

sorry for my noobness... I just changed from PAlib and I've never coded at low level...

I've tested it with dualis, and it tells me I copied the palette to the slot I wanted... but, the background still looks inappropiately... how do I tell the BG to use the Main slot1 palette?

Right now, on hardware and nogba the last background loaded looks OK but the first one looks all black... but on DeSemuME it looks perfectly...
I know I must be missing something small... any ideas?

For the archive, I fixed it... I had forgotten to set the VRAM bank as LCD before copying the palette

#166743 - sverx - Mon Feb 16, 2009 10:16 am

You should enable extended palettes:
Code:
videoSetMode ( <your mode> | DISPLAY_BG_EXT_PALETTE);


Did you do that?
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#166746 - Emmanuel - Mon Feb 16, 2009 1:42 pm

sverx wrote:
You should enable extended palettes:
Code:
videoSetMode ( <your mode> | DISPLAY_BG_EXT_PALETTE);


Did you do that?


OMG! Thx... you just solved my other problem... I had done that for main screen... but

Code:
videoSetModeSub(MODE_0_2D|
                DISPLAY_BG0_ACTIVE |
                DISPLAY_BG1_ACTIVE |
            DISPLAY_BG2_ACTIVE |
            DISPLAY_BG3_ACTIVE |
            DISPLAY_BG_EXT_PALETTE);

and know that other prob is fixed...
I was having a problem with the subscreen not using extended palette
THX!

#166749 - sverx - Mon Feb 16, 2009 3:40 pm

Emmanuel wrote:
you just solved my other problem...


lol... so which problem is left? If you still can't see extended palettes I guess it's because you forgot to specify the palette that should be used in the tile, check here

Code:
tilenum |= (palette << 12);

_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#166753 - Emmanuel - Mon Feb 16, 2009 4:48 pm

sverx wrote:

lol... so which problem is left?

None, solved... and you just solved another problem I was having before I posted with that link...

Thanks, fixed completely