Hi everyone,
I’m starting with homebrew development on the Nintendo DS and I’m trying to display a simple 8x8 sprite on the SUB (bottom) screen.
My PNG is 16x16 pixels and contains 4 sub-sprites of 8x8. I exported it using grit with this command:
I’m starting with homebrew development on the Nintendo DS and I’m trying to display a simple 8x8 sprite on the SUB (bottom) screen.
My PNG is 16x16 pixels and contains 4 sub-sprites of 8x8. I exported it using grit with this command:
Here’s the full C code I’m using with libnds, but the sprite does not appear on the screen:grit flechas.png -gt -gB2 -tw 8 -th 8 -p -m!
#include <nds.h>
#include <stdio.h>
#include "sprites/flechas.h"
void Vblank() {}
int main(void) {
irqSet(IRQ_VBLANK, Vblank);
videoSetModeSub(MODE_0_2D);
vramSetBankI(VRAM_I_SUB_SPRITE);
oamInit(&oamSub, SpriteMapping_1D_32, false);
// Copy palette to SUB sprite memory
dmaCopy(flechasPal, SPRITE_PALETTE_SUB, flechasPalLen);
// Allocate VRAM for a 16x16 sprite
u16* gfx = oamAllocateGfx(&oamSub, SpriteSize_16x16, SpriteColorFormat_16Color);
dmaCopy(flechasTiles, gfx, flechasTilesLen);
// Set up the sprite
oamSet(&oamSub, 0, 80, 50, 0, 0,
SpriteSize_16x16, SpriteColorFormat_16Color,
gfx, -1, false, false, false, false, false);
while(1) {
swiWaitForVBlank();
oamUpdate(&oamSub);
}
return 0;
}
This is the header file generated by grit for my sprite flechas.png:
//{{BLOCK(flechas)
//======================================================================
//
// flechas, 16x16@2,
// + palette 256 entries, not compressed
// + 4 tiles not compressed
// Total size: 512 + 64 = 576
//
// Time-stamp: 2025-08-23, 19:52:36
// Exported by Cearn's GBA Image Transmogrifier, v0.9.2
//
//
//======================================================================
#ifndef GRIT_FLECHAS_H
#define GRIT_FLECHAS_H
#define flechasTilesLen 64
extern const unsigned int flechasTiles[16];
#define flechasPalLen 512
extern const unsigned short flechasPal[256];
#endif // GRIT_FLECHAS_H
//}}BLOCK(flechas)







