How can I display sprites on screen on the Nintendo DS using nflib?

735 views Asked by At

Documentation I find online is vague. The only forum I found that's good was https://gbatemp.net/threads/ds-programming-for-newbies.322106/page-8#post-4445495. I followed the code on screen, I made a sprite (16 x 16, 256 color palette) and wrote the code. The sprite doesn't seem to display, all I get is the top screen to be black and the bottom screen to be white on my physical DSi. Desmume throws a "The ROM header is invalid. The device size has increased for the provided file size". Am I missing something? I can't really find what I'm missing since I'm trying to code for a 15 year old console, so if anyone knows here what I'm doing wrong, please, please tell me. The file names under the nitrofiles folder are "stickman.img" and "stickman.pal". Here's my code:

#include <gl2d.h>
#include <nds.h>
#include <nf_lib.h>
#include <stdio.h>

int main(int argc, char **argv){
    NF_Set2D(0, 0);
    NF_SetRootFolder("NITROFS");

    NF_InitSpriteBuffers();
    NF_InitSpriteSys(0);
    
    NF_LoadSpriteGfx("stickman", 0, 16, 16);
    NF_LoadSpritePal("stickman", 0);

    NF_VramSpriteGfx(0, 0, 0, false);
    NF_VramSpritePal(0, 0, 0);
    while(1) {
        NF_SpriteOamSet(0);
        swiWaitForVBlank();
        oamUpdate(&oamMain);
    }
    return 0;
}
1

There are 1 answers

0
AerGlass On BEST ANSWER

You didn't create the sprite.

Use NF_CreateSprite(), for example:

NF_CreateSprite(0, 0, 0, 0, 8, 16);

After creating the sprite, update oam.