#50045 - DShappy - Thu Aug 04, 2005 7:53 pm
Hey guys, here is my problem...
I'm creating a font system for use on the DS's BG0 using tiles. Everything is up and running smoothly except for transparency / alpha. I've read that index 0 in the palette is the "clear color" / "key color" along with others saying you have to set the 16th pad bit of the 16bit color value to on (1). I've tried bothways (and may others) but can't seems to get it working :(
Here is my code:
///////////////////////////////////////////////////////////////
// Graphics Init
///////////////////////////////////////////////////////////////
const int char_base = 0;
const int screen_base = 20;
DISPLAY_CR = MODE_0_2D | DISPLAY_BG0_ACTIVE;
SUB_DISPLAY_CR = MODE_0_2D | DISPLAY_BG0_ACTIVE;
SUB_BG0_CR = BG_256_COLOR | BG_TILE_BASE(char_base) | BG_MAP_BASE(screen_base);
BG0_CR = BG_256_COLOR | BG_TILE_BASE(char_base) | BG_MAP_BASE(screen_base) ;
vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankC(VRAM_C_SUB_BG);
///////////////////////////////////////////////////////////////
// Tile/Palette Init
///////////////////////////////////////////////////////////////
u16* sub_tile = (u16*)CHAR_BASE_BLOCK_SUB(char_base);
u16* sub_map = (u16*)SCREEN_BASE_BLOCK_SUB(screen_base);
u16* tile = (u16*)CHAR_BASE_BLOCK(char_base);
u16* map = (u16*)SCREEN_BASE_BLOCK(screen_base);
cNDSFile tmp;
files.LoadFile( "font1b8x8.SPI", &tmp );
for(i = 0,j=0; i < tmp.length; i+=2,j++)
{
sub_tile[j] = (tmp.data[i + 1] << 8) | tmp.data[i];
}
for(i = (tmp.length / 2); i < ((tmp.length / 2) + 32); ++i)
{
sub_tile[i] = 0x0202;
}
BG_PALETTE_SUB[0] = RGB15(31, 0, 31) | (1 << 15); // Key color ???
BG_PALETTE_SUB[1] = RGB15(0, 0, 0);
BG_PALETTE_SUB[2] = RGB15(0, 0, 31);
for(j = 0; j < (tmp.length / 64); ++j)
{
sub_map[j] = j;
}
for(j = (tmp.length / 64); j < 768; ++j)
{
sub_map[j] = (tmp.length / 64);
}
///////////////////////////////////////////////////////////////
Any help would be way cool! :)
I'm creating a font system for use on the DS's BG0 using tiles. Everything is up and running smoothly except for transparency / alpha. I've read that index 0 in the palette is the "clear color" / "key color" along with others saying you have to set the 16th pad bit of the 16bit color value to on (1). I've tried bothways (and may others) but can't seems to get it working :(
Here is my code:
///////////////////////////////////////////////////////////////
// Graphics Init
///////////////////////////////////////////////////////////////
const int char_base = 0;
const int screen_base = 20;
DISPLAY_CR = MODE_0_2D | DISPLAY_BG0_ACTIVE;
SUB_DISPLAY_CR = MODE_0_2D | DISPLAY_BG0_ACTIVE;
SUB_BG0_CR = BG_256_COLOR | BG_TILE_BASE(char_base) | BG_MAP_BASE(screen_base);
BG0_CR = BG_256_COLOR | BG_TILE_BASE(char_base) | BG_MAP_BASE(screen_base) ;
vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankC(VRAM_C_SUB_BG);
///////////////////////////////////////////////////////////////
// Tile/Palette Init
///////////////////////////////////////////////////////////////
u16* sub_tile = (u16*)CHAR_BASE_BLOCK_SUB(char_base);
u16* sub_map = (u16*)SCREEN_BASE_BLOCK_SUB(screen_base);
u16* tile = (u16*)CHAR_BASE_BLOCK(char_base);
u16* map = (u16*)SCREEN_BASE_BLOCK(screen_base);
cNDSFile tmp;
files.LoadFile( "font1b8x8.SPI", &tmp );
for(i = 0,j=0; i < tmp.length; i+=2,j++)
{
sub_tile[j] = (tmp.data[i + 1] << 8) | tmp.data[i];
}
for(i = (tmp.length / 2); i < ((tmp.length / 2) + 32); ++i)
{
sub_tile[i] = 0x0202;
}
BG_PALETTE_SUB[0] = RGB15(31, 0, 31) | (1 << 15); // Key color ???
BG_PALETTE_SUB[1] = RGB15(0, 0, 0);
BG_PALETTE_SUB[2] = RGB15(0, 0, 31);
for(j = 0; j < (tmp.length / 64); ++j)
{
sub_map[j] = j;
}
for(j = (tmp.length / 64); j < 768; ++j)
{
sub_map[j] = (tmp.length / 64);
}
///////////////////////////////////////////////////////////////
Any help would be way cool! :)