I wish to change ingame the palette of tiles (planA / PlanB) for showing part of picture. I have one palette with the good color and one black to hide multiple parts of the picture. (never at the same place). So I can only use 2 palettes because I need the others for sprites. And I'll do that with vblank only.
I write some tiles with color with VDP_setTileMapXY( PLANB, TILE_ATTR_FULL(Pal0,0,0,0,1), x, y) and others in black with VDP_setTileMapXY( PLANB, TILE_ATTR_FULL(Pal1,0,0,0,1), x, y), etc ...
I wish to only change the Palette of some tiles, instead of using setTileMapXY with all values(index, flip....). Something like Tile_Palette(x,y,Pal0); to save cpu time.
Is it possible ? or I need to write my asm function maybe ?
Change only tile palette
Moderator: Stef
Re: Change only tile palette
You can't save cpu time like that, it's a word VRAM write no matter what. If you only passed the palette, the function would have to read the word, change those bits, and write it back - being more than 2x slower.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Change only tile palette
But VDP_setTileMapXY(..) itself is really slow, it's better to prepare the whole tilemap in RAM (and a region of the map) and update it in one shot with VDP_setTileMapDataEx(..) or VDP_VDP_setTileMapDataRectEx(..)
Re: Change only tile palette
Ok, it's logical. I think of that because I also need to change priority.cero wrote:You can't save cpu time like that, it's a word VRAM write no matter what. If you only passed the palette, the function would have to read the word, change those bits, and write it back - being more than 2x slower.
In my case, I load my tileset with IMAGE and I use an array for drawing tiles.Stef wrote:But VDP_setTileMapXY(..) itself is really slow, it's better to prepare the whole tilemap in RAM (and a region of the map) and update it in one shot with VDP_setTileMapDataEx(..) or VDP_VDP_setTileMapDataRectEx(..)
For using VDP_setTileMapDataEx or VDP_setTileMapDataRectEx, I need to load a premade picture so I'll have a different tileset for each picture and a map->tilemap in ram. So if I use VDP_setTileMapDataRectEx, The sgdk already know the tilemap.
I'll make some tests.
Re: Change only tile palette
After some tests, I use setMapEx and seems to work well :
I need two plans because of the Priority.
I try VDP_setTileMapDataEx(..) and VDP_setTileMapDataRectEx(..) but never find the right value for data :
Code: Select all
VDP_loadTileSet(myRoom[0]->tileset, ind, NULL);
VDP_setMapEx(PLAN_B, myRoom[0]->map, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 0, 1, 0, 0, 24, 22);
VDP_setMapEx(PLAN_A, myRoom[0]->map, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, ind), 24, 13, 24, 12, 16, 10);
I try VDP_setTileMapDataEx(..) and VDP_setTileMapDataRectEx(..) but never find the right value for data :
Code: Select all
void VDP_setTileMapDataEx ( u16 plan, const u16 * data, ...
data tile attributes data pointer (see TILE_ATTR_FULL() and TILE_ATTR() macros).