sprite palettes, 256 colors[solved]?
sprite palettes, 256 colors[solved]?
hey everyone, i was experimenting with 256 color sprites. when i tried to load two different 256 color sprites, one sprite screwed up: it used the palette of the first sprite. ok, i began searching, and read that it was impossible to have two or more 256 color palletes. but when i used palib, you could have different 256 palletes, so how is this possible?
Last edited by Tomdev on Wed Feb 11, 2009 8:43 pm, edited 2 times in total.
Re: sprite palettes, 256 colors?
It's certainly not impossible. What you're looking for is enabling extended palettes which gives you 16 256 color palettes for each screen they're enabled for.
Haven't quite tackled how this is enabled yet myself though... I can see how it would be done by setting registers, but it would be best to see if someone more experienced comes along to show maybe a typical way to handle it.
Here's the gbatek info on it: http://nocash.emubase.de/gbatek.htm#dsv ... edpalettes
Haven't quite tackled how this is enabled yet myself though... I can see how it would be done by setting registers, but it would be best to see if someone more experienced comes along to show maybe a typical way to handle it.
Here's the gbatek info on it: http://nocash.emubase.de/gbatek.htm#dsv ... edpalettes
Re: sprite palettes, 256 colors?
ok, i have heard about that vram bank h or something was used for extended palletes
Re: sprite palettes, 256 colors?
In writing a quick example to address this question I found a few issues with libnds sprite ext palette handling. These have been repaired and uploaded to the svn. Here is an example for sprite ext palette usage via libnds (requires current svn of libnds as of 2-5-2009)
Code: Select all
/*---------------------------------------------------------------------------------
Simple extended palette demo. Creates two sprites on the main display
using palette 0 and palette 1.
-- dovoto
---------------------------------------------------------------------------------*/
#include <nds.h>
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
int i = 0;
touchPosition touch;
videoSetMode(MODE_0_2D);
vramSetBankA(VRAM_A_MAIN_SPRITE);
oamInit(&oamMain, SpriteMapping_1D_128, true);
u16* gfx1 = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color);
u16* gfx2 = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color);
// notice both sprites are filled with color 1
for(i = 0; i < 16 * 16 / 2; i++)
{
gfx1[i] = 1 | (1 << 8);
gfx2[i] = 1 | (1 << 8);
}
// unlock vram (cannot write to vram while it is mapped as a palette)
vramSetBankF(VRAM_F_LCD);
VRAM_F_EXT_PALETTE[0][1] = RGB15(31,0,0);
VRAM_F_EXT_PALETTE[1][1] = RGB15(0,31,0);
// set vram to ex palette
vramSetBankF(VRAM_F_SPRITE_EXT_PALETTE);
while(1) {
scanKeys();
if(keysHeld() & KEY_TOUCH)
touchRead(&touch);
oamSet(&oamMain, //main graphics engine context
0, //oam index (0 to 127)
touch.px, touch.py, //x and y pixle location of the sprite
0, //priority, lower renders last (on top)
0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
SpriteSize_16x16,
SpriteColorFormat_256Color,
gfx1, //pointer to the loaded graphics
-1, //sprite rotation data
false, //double the size when rotating?
false, //hide the sprite?
false, false, //vflip, hflip
false //apply mosaic
);
oamSet(&oamMain,
1,
SCREEN_WIDTH - touch.px,
SCREEN_HEIGHT - touch.py,
0,
1, //use second palette
SpriteSize_16x16,
SpriteColorFormat_256Color,
gfx2,
-1,
false,
false,
false, false,
false
);
swiWaitForVBlank();
oamUpdate(&oamMain);
}
return 0;
}
Re: sprite palettes, 256 colors?
thanks, i will download the libnds out of the svn.
edit: stupid but i can't find the svn(i never look in a svn) can someone say where i can find it?
edit: stupid but i can't find the svn(i never look in a svn) can someone say where i can find it?
-
- Site Admin
- Posts: 2003
- Joined: Tue Aug 09, 2005 3:21 am
- Location: UK
- Contact:
Re: sprite palettes, 256 colors?
You're probably best waiting for the stable release which should hopefully be available in a few days. SVN is generally in a state of flux and not always in a state that can be compiled by end users.
Re: sprite palettes, 256 colors?
thanks for your reply wintermute, i will wait for the update
Re: sprite palettes, 256 colors?
Looking at that example, doesn't this:
Need to be this?
Code: Select all
videoSetMode(MODE_0_2D);
Code: Select all
videoSetMode(MODE_0_2D | DISPLAY_SPR_EXT_PALETTE);
Re: sprite palettes, 256 colors?
No. The sprite and bg api both handle the setting of the display control registers as needed.Sylus101 wrote:Looking at that example, doesn't this:
Need to be this?Code: Select all
videoSetMode(MODE_0_2D);
Code: Select all
videoSetMode(MODE_0_2D | DISPLAY_SPR_EXT_PALETTE);
Who is online
Users browsing this forum: No registered users and 1 guest