This is my code so far:
Code: Select all
#include <nds.h>
// my function defined elsewhere, not important here
extern void loadTitleGfx(u16 *buffer_main, u16 *buffer_sub);
int main()
{
// pointer to the bg rams, where I can paint the bg layers
u16 *video_buffer = (u16*)BG_BMP_RAM(0);
u16 *video_buffer_sub = (u16*)BG_BMP_RAM_SUB(0);
// I set mode 5 for both screens, and I enable bg3 for both
videoSetMode(MODE_5_2D|DISPLAY_BG3_ACTIVE);
videoSetModeSub(MODE_5_2D|DISPLAY_BG3_ACTIVE);
// I don't really have much clue about this... when can I use which bank?
vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankC(VRAM_C_SUB_BG);
vramSetBankD(VRAM_D_SUB_SPRITE);
// setting the backgrounds
BACKGROUND.control[3] = BG_BMP16_256x256|BG_BMP_BASE(0);
BACKGROUND.bg3_rotation.xdy = 0;
BACKGROUND.bg3_rotation.xdx = 1<<8;
BACKGROUND.bg3_rotation.ydx = 0;
BACKGROUND.bg3_rotation.ydy = 1<<8;
BACKGROUND_SUB.control[3] = BG_BMP16_256x256|BG_BMP_BASE(0)|BG_PRIORITY(1);
BACKGROUND_SUB.bg3_rotation.xdy = 0;
BACKGROUND_SUB.bg3_rotation.xdx = 1<<8;
BACKGROUND_SUB.bg3_rotation.ydx = 0;
BACKGROUND_SUB.bg3_rotation.ydy = 1<<8;
// load title screens from memory and draw to bg3 layer main and sub, my custom function
loadTitleGfx(video_buffer, video_buffer_sub);
/////////////////////////////////////////////////////////
// THIS IS THE PART WHERE I HAVE PROBLEMS!
/////////////////////////////////////////////////////////
// init oam on sub screen
oamInit(&oamSub, SpriteMapping_Bmp_1D_128, false);
// sprite now points to the memory, where I can draw with ARGB16() like in VRAM?
u16 *sprite = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_Bmp);
// just fill the whole sprite with red color, alpha=1 (visible), correct?
for(int i=0;i<256;i++) sprite[i] = ARGB16(1, 31, 0, 0);
// main game loop
while(1)
{
oamSet(&oamSub, 0, 128, 64, 0, 0, SpriteSize_16x16, SpriteColorFormat_Bmp, sprite, 0,
false, false, false, false, false);
swiWaitForVBlank();
oamUpdate(&oamSub);
}
return 0;
}
Can anybody please help me?