
In fact I run in a problem I can't solve!

I was trying out the paletted pixel format, but I can't get it working:
Code: Select all
#include <nds.h>
int main(){
videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0);
u16 *oRam = (u16*)BG_BMP_RAM(0);
BG_PALETTE[0] = RGB15(0,31,0);
BG_PALETTE[1] = RGB15(31,0,0);
BG_PALETTE[2] = RGB15(0,0,31);
BG_PALETTE[3] = 0;
for(int i = 0; i < 128*192; i++){
oRam[i] = (i & 3);
}
while(1)
swiWaitForVBlank();
}
And that's not what I wanted! I think it depends on the type I used for "oRam". In fact it's made of 16 bit instead of 8, so the first 8 are set to 0 and cause the green to appear too many times.
So I changed that type to u8:
Code: Select all
#include <nds.h>
int main(){
videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0);
u8 *oRam = (u8*)BG_BMP_RAM(0);
BG_PALETTE[0] = RGB15(0,31,0);
BG_PALETTE[1] = RGB15(31,0,0);
BG_PALETTE[2] = RGB15(0,0,31);
BG_PALETTE[3] = 0;
for(int i = 0; i < 256*192; i++){
oRam[i] = (u8)(i & 3);
}
while(1)
swiWaitForVBlank();
}
Can anyone tell me where I'm mistaking?