Extended Palettes and Transparency
Posted: Thu Jul 04, 2019 9:23 pm
Hello everyone,
I'm a new developer on nintendo ds and I'm trying to build some simple examples to test the feature of the nintendo ds. In the quest doing this I marched upon Extended Palettes which seem to be new compared to the gba. If I understand correctly the idea is that you can sacrifice some ram to have a maximum of 16*256 colors per background instead of juste 256 for the main or the sub and would hence allows for much richer graphics.
So I tried to setup the extended palette in the same fashion that the exemples at https://github.com/devkitPro/nds-exampl ... ackgrounds, (I noted that I had to set the while loop to true to work on desmume for some reason even if it works on the ds). So far so good now the problem is I wanted to use the extended palette with some tiled graphics.More specifically a tiled background on the sub engine bg 2 with tiles and palette generated by grit and a custom map and also a bg 1 with text that would be mapped manually from tiles and palette generated with grit too.
I could achieve to have both backgrounds displayed but I still have a minor problem because my text background is not transparent. So I was wondering if this is expected with extended palettes or not.
Here are some of the relevant calls that summarize what I have done:
I set the grit like this for the bg2:
And for the text
both images use the correct color 0xFF00FF as transparnet background color
And the result is the following one :
Thx for reading and if anyone has an idea where this come from or could explain me the limitations of extended palettes it would be great!
I'm a new developer on nintendo ds and I'm trying to build some simple examples to test the feature of the nintendo ds. In the quest doing this I marched upon Extended Palettes which seem to be new compared to the gba. If I understand correctly the idea is that you can sacrifice some ram to have a maximum of 16*256 colors per background instead of juste 256 for the main or the sub and would hence allows for much richer graphics.
So I tried to setup the extended palette in the same fashion that the exemples at https://github.com/devkitPro/nds-exampl ... ackgrounds, (I noted that I had to set the while loop to true to work on desmume for some reason even if it works on the ds). So far so good now the problem is I wanted to use the extended palette with some tiled graphics.More specifically a tiled background on the sub engine bg 2 with tiles and palette generated by grit and a custom map and also a bg 1 with text that would be mapped manually from tiles and palette generated with grit too.
I could achieve to have both backgrounds displayed but I still have a minor problem because my text background is not transparent. So I was wondering if this is expected with extended palettes or not.
Here are some of the relevant calls that summarize what I have done:
Code: Select all
bgExtPaletteEnableSub();
vramSetBankC(VRAM_C_SUB_BG);
videoSetModeSub(MODE_0_2D);
int bg1Sub = bgInit(1, BgType_Text8bpp, BgSize_T_256x256, 1, 2);
int bg2Sub = bgInit(2, BgType_Text8bpp, BgSize_T_256x256, 1, 0);
dmaCopy(menuButtonTiles, (void *)bgGetGfxPtr(bg2Sub), menuButtonTilesLen);
vramSetBankH(VRAM_H_LCD); // for sub engine
dmaCopy(menuButtonPal, (void *)&VRAM_H_EXT_PALETTE[bg2Sub - 4][0], menuButtonPalLen);
vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE); // for sub engine
dmaCopy(backgroundTextMap, (void *)bgGetMapPtr(bg2Sub), backgroundTextMapLen);
dmaCopy(ocrFontTiles, bgGetGfxPtr(bg1Sub), ocrFontTilesLen);
vramSetBankH(VRAM_H_LCD); // for sub engine
dmaCopy(ocrFontPal, &VRAM_H_EXT_PALETTE[bg1Sub - 4][0], ocrFontPalLen);
vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
// setting map manually with bgGetMapPtr(bg1Sub)[pos] = ...
I set the grit like this for the bg2:
Code: Select all
-g -gt -gB8 -p -m -mR8 -gTFF00FF
Code: Select all
-g -gt -gB8 -p -m! -mR! -gTFF00FF
And the result is the following one :
Thx for reading and if anyone has an idea where this come from or could explain me the limitations of extended palettes it would be great!