Getting started with libnds
Posted: Wed May 07, 2014 6:39 pm
Thanks, I'll see how it goes using straight up libnds then!
I'm having a little trouble setting up GFX the DS. Ideally I'd like to have all of my VRAM banks set up in a similar way to how PAlib used to, so I would like to have extended palettes for sprites and backgrounds and be able to load 4 layers of backgrounds on each screen.
I have ball.bin and pal.bin (converted with grit) in my data folder and am using this code:
The screen displays nothing, so I assume that either I have set up the VRAM banks incorrectly or that I have not correctly unlocked the extended sprite palette before attempting to dmaCopy to the palette.
Many thanks.
I'm having a little trouble setting up GFX the DS. Ideally I'd like to have all of my VRAM banks set up in a similar way to how PAlib used to, so I would like to have extended palettes for sprites and backgrounds and be able to load 4 layers of backgrounds on each screen.
I have ball.bin and pal.bin (converted with grit) in my data folder and am using this code:
Code: Select all
#include <nds.h>
#include "ball_bin.h"
#include "pal_bin.h"
int main(int argc, char **argv) {
videoSetMode(MODE_5_2D);
videoSetModeSub(MODE_5_2D);
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
vramSetBankB(VRAM_B_MAIN_SPRITE);
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
vramSetBankD(VRAM_D_SUB_SPRITE);
vramSetBankF(VRAM_F_SPRITE_EXT_PALETTE);
vramSetBankI(VRAM_I_SUB_SPRITE_EXT_PALETTE);
oamInit(&oamMain, SpriteMapping_1D_128, true);
oamInit(&oamSub, SpriteMapping_1D_128, true);
u16 *ball = NULL;
ball = oamAllocateGfx(&oamSub, SpriteSize_32x32, SpriteColorFormat_256Color);
dmaCopy(ball_bin, ball, 1024);
vramSetBankF(VRAM_F_LCD);
vramSetBankF(VRAM_I_LCD);
dmaCopy(pal_bin, VRAM_F_EXT_SPR_PALETTE[0], 512);
dmaCopy(pal_bin, VRAM_I_EXT_SPR_PALETTE[0], 512);
vramSetBankF(VRAM_F_SPRITE_EXT_PALETTE);
vramSetBankI(VRAM_I_SUB_SPRITE_EXT_PALETTE);
oamSet(&oamSub, 0, 0, 0, 0, 0, SpriteSize_32x32, SpriteColorFormat_256Color, ball, -1, false, false, false, false, false);
while(1) {
scanKeys();
swiWaitForVBlank();
oamUpdate(&oamMain);
oamUpdate(&oamSub);
}
return 0;
}
Many thanks.