#154605 - Polaris - Sat Apr 19, 2008 1:43 am
I'm having some trouble to make two different backgrounds use different parts of the BG_PALETTE (SUB in this case).
This is what I got so far.
Anyone that understands a bit of what's going on in here will probably figure out that what is happening is that both backgrounds get painted using only the first 16 palette values. So the second image Controls.png in this case shows up, but with the wrong colors.
I looked around a bit on the forums first and found that each tile has 15 bits that describe it, or something like that. And that if I want to tell each tile of a given background to use a specific 16 color palette I should do so by modifying bit 12-15.Theory is fine and I almost understand it, but I can't for the love of god make it work in practice!
In my specific case, where should I apply 1 << 12 in order for the tiles of Background 2 to use the values starting from BG_PALETTE_SUB[16]?
Since i'm in the bit 12-15 range, I have another question :P
Each tile has 4 bits to tell it which palette it should use, if all bits are set to 0 it uses the first palette. I'm assuming that setting each bit separately gives the tile access to the 2nd, 3rd, 4th and 5th palettes respectively. But how should I set those bits if I want to use from the sixth palette onwards?
Last edited by Polaris on Sat Apr 19, 2008 4:27 pm; edited 1 time in total
This is what I got so far.
Code: |
u16 *mapMemorySub = (u16*)BG_MAP_RAM_SUB(2); u8 *tileMemorySub = (u8*)BG_TILE_RAM_SUB(1); u16 *controlsMapMemory = (u16*)BG_MAP_RAM_SUB(4); u8 *controlsTileMemory = (u8*)BG_TILE_RAM_SUB(5); BACKGROUND_SUB.control[0] = BG_32x64 | BG_COLOR_16 | BG_MAP_BASE(2) | BG_TILE_BASE(1) | BG_PRIORITY(1); BACKGROUND_SUB.control[2] = BG_32x32 | BG_COLOR_16 | BG_MAP_BASE(4) | BG_TILE_BASE(5) | BG_PRIORITY(0); dmaCopy(BGTilesPal, BG_PALETTE_SUB, BGTilesPalLen); dmaCopy(ControlsPal, &BG_PALETTE_SUB[16], ControlsPalLen); dmaCopy(BGTiles, tileMemorySub, BGTilesLen); dmaCopy(ControlsTiles, controlsTileMemory, ControlsTilesLen); for(u16 i=0; i<sizeof(BGMap)/2; i++){ mapMemorySub[i] = 0; } for(u16 i=0; i<sizeof(ControlsMap); i++){ controlsMapMemory[i] = Controls_map[i]; } |
Anyone that understands a bit of what's going on in here will probably figure out that what is happening is that both backgrounds get painted using only the first 16 palette values. So the second image Controls.png in this case shows up, but with the wrong colors.
I looked around a bit on the forums first and found that each tile has 15 bits that describe it, or something like that. And that if I want to tell each tile of a given background to use a specific 16 color palette I should do so by modifying bit 12-15.Theory is fine and I almost understand it, but I can't for the love of god make it work in practice!
In my specific case, where should I apply 1 << 12 in order for the tiles of Background 2 to use the values starting from BG_PALETTE_SUB[16]?
Since i'm in the bit 12-15 range, I have another question :P
Each tile has 4 bits to tell it which palette it should use, if all bits are set to 0 it uses the first palette. I'm assuming that setting each bit separately gives the tile access to the 2nd, 3rd, 4th and 5th palettes respectively. But how should I set those bits if I want to use from the sixth palette onwards?
Last edited by Polaris on Sat Apr 19, 2008 4:27 pm; edited 1 time in total