The one in 47 is just supposed to be a timer. It didn't work out, so I just cut it out. It doesn't serve much in this. Line 48, though, is:Could you tell me what are lines 47 and 48?
Normal because you need to check keynewpress and not keysheld, don't know the exact function with nflib in the second while
u16 keys = 0;
I changed all keysHeld() to keysDown() and it still does the same thing. I even removed the systemShutDown() and it still turns off. I think there is an overflow somewhere, but I'm not sure.Oh, I think I know what's going on
The DS waits in the first loop for A to be pressed. When you press it, it loads the other BG and proceeds to do the second loop. BUT when it arrives there the button A is still pressed (the DS loads the BG faster than you can press and release the button). Then it doesn't even wait for another button press, and proceeds to shut down
To fix it you could use keysDown() instead of keysHeld():
keysHeld returns true when the button is pressed, but keysDown only returns true if the button was just pressed since the last key read.
// Carga el archivo BITMAP de imagen en formato RAW a la RAM
NF_Load16bitsBg("bmp/top_intro_1", 0);
NF_Load16bitsBg("bmp/touch_intro_1", 1);
// Tranfiere la imagen a la VRAM de ambas pantallas
NF_Copy16bitsBuffer(0, 0, 0);
NF_Copy16bitsBuffer(1, 0, 1);
swiWaitForVBlank();
// Si no es necesario usarla mas, borrala de la RAM
if( !(keysDown() & KEY_A)) { scanKeys();}
NF_Unload16bitsBg(0);
NF_Unload16bitsBg(1);
NF_Reset16bitsBgBuffers();
NF_Load16bitsBg("bmp/top_intro_2", 0);
NF_Load16bitsBg("bmp/touch_intro_2", 1);
NF_Copy16bitsBuffer(0, 0, 0);
NF_Copy16bitsBuffer(1, 0, 1);
swiWaitForVBlank();
if( !(keysDown() & KEY_A)) { scanKeys();}
NF_Unload16bitsBg(0);
NF_Unload16bitsBg(1);
NF_Reset16bitsBgBuffers();
swiWaitForVBlank();

extern "C"
{
void __libnds_exit(int rc) {
iprintf("\nExiting with retcode %d\n", rc);
while(1) swiWaitForVBlank();
}
}
Ok. I added defaultExceptionHandler() and ran it. It ran without giving an error. It just shut off. I then added the function you provided. It won't compile properly, sayingHmm, then it's probably a bug in the library.
There are two things to try.
First, call defaultExceptionHandler() at the beginning of your main. This will set up the DS so that the "guru meditation error" screen appears in some (most?) kinds of crashes, so we'll have more information.
Second, put this function somewhere in your code.
I once had a similar shutdown problem.The program was getting aborted as if main() had returned. libnds shuts down the DS if main returns. That function "overrides" libnds behavior.Code:extern "C" { void __libnds_exit(int rc) { iprintf("\nExiting with retcode %d\n", rc); while(1) swiWaitForVBlank(); } }
c:/deckitpro/examples/graphics/bg16bitsload/source/main.c:33:9: error: expected identifier or '(' before string constant.

void __libnds_exit(int rc) {
iprintf("\nExiting with retcode %d\n", rc);
while(1) swiWaitForVBlank();
}
Ok. It compiles and works. Now, it does as before, but stays on top/touch_intro_2. With no input. But it doesn't shut off now.Oh, I didn't notice you were coding in C.
Remove the extern "C" part
It should look just like this
Code:void __libnds_exit(int rc) { iprintf("\nExiting with retcode %d\n", rc); while(1) swiWaitForVBlank(); }
No, not yet. I was planning to add debugging tools once I could create a main menu.That's good news
Do you have set up a console so you can see the output? xD
Debugging something without a console is hard...

if( !(keysDown() & KEY_A)) { scanKeys();}
iprintf("a");
NF_Unload16bitsBg(0);
iprintf("b");
NF_Unload16bitsBg(1);
iprintf("c");
NF_Reset16bitsBgBuffers();
iprintf("d");
NF_Load16bitsBg("bmp/top_intro_2", 0);
iprintf("e");
NF_Load16bitsBg("bmp/touch_intro_2", 1);
iprintf("f");
NF_Copy16bitsBuffer(0, 0, 0);
iprintf("g");
NF_Copy16bitsBuffer(1, 0, 1);
iprintf("h");
swiWaitForVBlank();
It does have that because before anything starts, it says "Init FAT Please wait..." I added that and it never displayed anything. I'm unsure as to if it will display overtop an image, though. I ran it and got nothing.Well, you should have *something*
Debugging a homebrew is a really annoying process, I know
What I usually do is always have a console on one of these screens.
Just call consoleDemoInit() and you'll have a console on the sub screen. (It uses VRAM_C, not sure if that'd work well with the lib you're using).
Then you can print out what's the game doing to see where it's hanging.
this way you'll at least know which line is causing the problem...Code:if( !(keysDown() & KEY_A)) { scanKeys();} iprintf("a"); NF_Unload16bitsBg(0); iprintf("b"); NF_Unload16bitsBg(1); iprintf("c"); NF_Reset16bitsBgBuffers(); iprintf("d"); NF_Load16bitsBg("bmp/top_intro_2", 0); iprintf("e"); NF_Load16bitsBg("bmp/touch_intro_2", 1); iprintf("f"); NF_Copy16bitsBuffer(0, 0, 0); iprintf("g"); NF_Copy16bitsBuffer(1, 0, 1); iprintf("h"); swiWaitForVBlank();
Well, all images render correctly. The issue is it won't wait for the buttons.There might be some problems with line 47, this error appears only when you try to return some data in void functions or failed something in relation with returning values, not sure but 16bit bg is quite heavy, maybe your library allows only one screen in 16bit mode..
I'll look at that, but Audacity doesn't give me an option to export as RAW. Is there another library that doesn't have such a restriction on RAW filesize?The best is audacity but keep in mind to:
Change project rate, the box down left of the window
change the sample rate, i mean there is some options on the left of the audio stream
Once you have change both, you have to speed up the track, go in effects menu, change speed. Use (old rate)/(new rate)-1 to know the good percentage.
Them file->export raw (headerless)format, usually in 8bit pcm but it is as you want
for your buttons problem, instead of doing a while (!keydown)scankey ; try
do {scankeys; }while (!keydown)
Well, it seems that Maxmod also has the same filesize restriction, so I guess I must find a different source for the songs I am using. Or find a better program that can make the filesize as small as possible.Well it should be using maxmod i guess, in audacity just edit the option, there you can choose the non compressed export format
I was going to implement BGM, as well as the audio for the cutscene, which is from :45-1:45 in length. I might try maxmod though, I'll be implementing it now.What kind of sound do you want to play? 256kb is about 10seconds.. Quite enough in most cases, or. You can try the stream stream from maxmod though I never tried it
I went and added that in, and the code doesn't break, but when ran, stays on top/touch_intro_1. makefile gives meWell why not use mod or it musics? Or just try streaming from fat or nitrofs
I already told you how to do for the buttons problem..
c:/devkitPro/examples/graphics/bg16bitsload/source/main.c:55:6: warning: unused
variable 'keys' [-Wunused-variable]
do {scanKeys;} while( !(keysDown() & KEY_A));


