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 > multipalettes

#177599 - PypeBros - Sun Sep 09, 2012 8:07 pm

Hello, all.

I've (at least) reached the point where I'll start add multi-palette support (aka extended palettes) to my game edition tools. I think I've understood most of how VRAM_E bank can be used, but I'm likely to need multi-colors only on *one* of the planes, so using VRAM_E could be some kind of waste here, esp. since there could be some (textured) 3D joining the game later on.

So I was wondering whether one of the 16K VRAM bank could be used as follow:
- slot 0 would provide 16 palettes (offset 0x0000 to 0x1FFF) for BG2
- slot 1 would provide 8 palettes for BG1 (offset 0x2000 to 0x2FFF) and 8 palettes for BG3 (offset 0x3000 to 0x3FFF).
- I'd use the OFS bits of BG1CNT to force it use the same slots as BG3.
- BG0 actually don't need palettes since it's the 3D stuff.

I'm gonna give it a try, but since I might do it wrong, if something has messed with that already, I'd be more than happy to listen, too ;)

Cheers.
_________________
SEDS: Sprite Edition on DS :: modplayer


Last edited by PypeBros on Mon Sep 10, 2012 10:40 am; edited 1 time in total

#177600 - sverx - Sun Sep 09, 2012 10:16 pm

Yes, you can use extended palettes using a single 16KB VRAM bank.
You can find an example I wrote on my tutorial here (the tutorial it's in Italian but the code is simple)
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177601 - PypeBros - Mon Sep 10, 2012 9:34 am

thanks for the link, sverx. I'm not surprised that *you* investigated the topic already :)

Btw, I read on your tutorial "- nel modo rotazionale a 256 colori viene usata sempre e solo la palette standard dei background, anche quando le palette estese sono attive." which I understand as "ROTSCALE backgrounds still use BG_PALETTE, whatever the DISPLAY_BG_EXT_PALETTE dictates". Do you know whether that stays true for "extended" rot/scale layers (which iirc still have 16 bit per tile, including a place for palette selection) or just the legacy "affine" layers (which, iirc, have only access to 256 tiles, and no tile swapping either) ?

I also see you use vramSetBankG (VRAM_G_BG_EXT_PALETTE_SLOT23); ... I had in mind that it would indeed be the way to use 16K extended palettes on 4 layers, as layers 2 and 3 have no control on the "slots" they're going to use.

Anyway, I'm gonna extend your tutorial code with BG2 and figure out :)
_________________
SEDS: Sprite Edition on DS :: modplayer

#177602 - sverx - Mon Sep 10, 2012 11:03 am

'Normal' rot/scale backgrounds cannot use extended palettes, so they'll keep on using the colors defined in the standard palette.
'Extended' rot/scale backgrounds CAN use extended palettes.
Check http://nocash.emubase.de/gbatek.htm#dsvideoextendedpalettes :)

Then you can use either VRAM Bank F or G if you only need 16KB of extended palette space. Here's the list of all the VRAM modes, again from my -quite old now- tutorial. I hope that makes it clearer :)
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177603 - PypeBros - Mon Sep 10, 2012 12:20 pm

sverx wrote:
'Extended' rot/scale backgrounds CAN use extended palettes.
Check http://nocash.emubase.de/gbatek.htm#dsvideoextendedpalettes :)

Oh! now I see it!
Quote:

BG Extended Palette enabled in DISPCNT Bit 30, when enabled,

standard palette --> ...
256-color tiles (with 8bit bgmap entries) (rot/scal)
...
extended palette --> 256-color tiles (with 16bit bgmap entries)(text,rot/scal)


Thanks for sharing your knowledge. For some reason, no matter how much I re-read entries in gbatek, I never manage to infer as much as I should out of it... that's pretty frustrating >_<
_________________
SEDS: Sprite Edition on DS :: modplayer

#177604 - sverx - Mon Sep 10, 2012 1:46 pm

PypeBros wrote:
... no matter how much I re-read entries in gbatek, I never manage to infer as much as I should out of it...


The same to me too. Each time I read it again, I find something I had missed.

edit: Congratulations on your NEO Retro Coding Compo 2012 silver medal :)
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177605 - PypeBros - Mon Sep 10, 2012 3:01 pm

[quote="sverx"]
PypeBros wrote:

edit: Congratulations on your NEO Retro Coding Compo 2012 silver medal :)


eh ... thanks. I wasn't aware they had finally completed the evaluation. Hopefully, that could help with the broken hardware issues :)
_________________
SEDS: Sprite Edition on DS :: modplayer