Homebrew Video Cutscenes

  • Thread starter Thread starter loco365
  • Start date Start date
  • Views Views 6,091
  • Replies Replies 46
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
 
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
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:
Code:
u16 keys = 0;
I think it's to initiate the keys, but I'm not 100% 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.
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.

EDIT:
I changed it to this:
Code:
// 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();
It displays all images, but when it starts, it displays the first ones, then the second ones, then shuts off with no user input.
 
Hmm, 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.
Code:
extern "C"
{
void __libnds_exit(int rc) {
iprintf("\nExiting with retcode %d\n", rc);
while(1) swiWaitForVBlank();
}
}
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.
 
Hmm, 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.
Code:
extern "C"
{
void __libnds_exit(int rc) {
iprintf("\nExiting with retcode %d\n", rc);
while(1) swiWaitForVBlank();
}
}
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.
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, saying
Code:
c:/deckitpro/examples/graphics/bg16bitsload/source/main.c:33:9: error: expected identifier or '(' before string constant.

Although changing the while statements to if statements did work a bit.
 
Oh, I didn't notice you were coding in C.

Remove the extern "C" part :P
It should look just like this

Code:
void __libnds_exit(int rc) {
iprintf("\nExiting with retcode %d\n", rc);
while(1) swiWaitForVBlank();
}
 
Oh, I didn't notice you were coding in C.

Remove the extern "C" part :P
It should look just like this

Code:
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.
 
Well, you should have *something* :P

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.
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();
this way you'll at least know which line is causing the problem...
 
Well, you should have *something* :P

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.
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();
this way you'll at least know which line is causing the problem...
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.
 
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..
 
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..
Well, all images render correctly. The issue is it won't wait for the buttons.
Edit: What do you use to convert audio? I'm working with audio to get that working so I can run it with the video in the next part, but I can't get my RAW sound files below 256KB.
 
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)
 
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)
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?
 
Well it should be using maxmod i guess, in audacity just edit the option, there you can choose the non compressed export format
 
Well it should be using maxmod i guess, in audacity just edit the option, there you can choose the non compressed export format
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.

Edir: Or perhaps bypass that restriction... Hm...
 
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
 
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 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.

Edit: Almost have audio, except it won't compile because it says I haven't defined my audio clip. wtf

Edit2: Got audio working. Now to get buttonpresses operational.

Edit3: I now know how to load .WAV samples, but mine is too long (50 seconds) and it's filesize is too large to compile.
 
Well 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..
 
Well 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..
I went and added that in, and the code doesn't break, but when ran, stays on top/touch_intro_1. makefile gives me
Code:
c:/devkitPro/examples/graphics/bg16bitsload/source/main.c:55:6: warning: unused
variable 'keys' [-Wunused-variable]
when there is
Code:
do {scanKeys;} while( !(keysDown() & KEY_A));
on that line.

As for audio, .mod and .it work completely fine (I have one implemented for the game itself now) but for the video cutscene, I want to pair it with it's original audio, or else it won't make any sense.
 

Site & Scene News

Popular threads in this forum