I keep having the Sprite GFX 0 is already in use. Error code 109 problem, ive tried everything and i cant fix it. heres my code
C++:
#include <nds.h>
#include <maxmod9.h>
#include <nf_lib.h>
#include <stdio.h>
volatile int frame = 0;
//---------------------------------------------------------------------------------
void Initialize()
{
NF_SetRootFolder("NITROFS");
NF_Set2D(0, 0);
NF_InitTiledBgBuffers();
NF_InitTiledBgSys(0);
// Load the BMP file as a sprite graphics with palette
NF_LoadSpriteGfx("nitrofiles/ui/birdekek.img", 0, 128, 32);
NF_LoadSpritePal("nitrofiles/ui/birdekek.img", 0);
// Apply the palette to the sprite
NF_VramSpriteGfx(0, 0, 0, false);
NF_VramSpritePal(0, 0, 0);
}
void Vblank()
{
frame++;
}
//---------------------------------------------------------------------------------
int main(int argc, char** argv)
{
irqSet(IRQ_VBLANK, Vblank);
consoleDemoInit();
Initialize();
// Play the sound effect (replace SFX_BIRDEKEK with the actual sound effect ID)
mmLoadEffect(0); // Example: Assuming SFX_BIRDEKEK is defined as 0
mmEffect(0); // Example: Assuming SFX_BIRDEKEK is defined as 0
consoleClear();
setBrightness(3, 0);
// Display the sprite
NF_CreateSprite(0, 0, 0, 0, 0, 0);
// Wait for 4 seconds (about 240 frames at 60 FPS) with fading to black
for (int i = 0; i < 240; i++)
{
setBrightness(3 - (i / 60), 0);
swiWaitForVBlank();
}
setBrightness(0, 0);
// Clear the sprite and load the main screen background
NF_DeleteSprite(0, 0);
NF_LoadTiledBg("nitrofiles/maps/mainscreen.img", "main_bg", 256, 192); // Pass the correct width and height
// Load and play the MOD file (replace MOD_MAINTHEME with the actual MOD file ID)
mmLoad(0); // Example: Assuming MOD_MAINTHEME is defined as 0
mmStart(0, MM_PLAY_LOOP); // Example: Assuming MOD_MAINTHEME is defined as 0
// Infinite loop for displaying the background and playing the MOD file
while (1)
{
swiWaitForVBlank();
}
return 0;
}