Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,475,196
  • Replies Replies 6,048
  • Likes Likes 54
So I've ended up resorting to using audio via RAW since I believe that's the simplest thing for my skill level to implement.

However, ever since implementing a function to load and play a sound, my app now crashes upon launching. For reference, I used the load_audio function from 3DS Nyan Cat. I did csndInit() in main, before attempting to use other csnd functions, am I missing something else?

EDIT: It still crashes when I comment out all load_audio calls, but runs fine when I comment out both the load_audio and csndInit() calls. Am I initializing something wrong?
 
Last edited by LeifEricson,
So, I made a small homebrew app that shows text (basic, I know. But I'm a noob)
Anyways, is there a better way of doing this? Using the \b command over and over again can get annoying.
Here's the part of my code that has \b over and over again
Code:
if (kHeld & KEY_A) printf("\x1b[8;1HYou are holding A for more text");
if (kUp & KEY_A) printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");// \b is a backspace, needs to be copied per the amount of spaces. Need to find better way of clearing the "holding A" text.
Thanks :)
 
OK, so I'm unable to compile libSDL_3DS-v0.3 with devkitpro. I keep getting errors.
I'm using a Virtual Machine of Windows 7x64.

I have detailed every single mousclick and button press in the attached image and have written down every step for someone to please look over and tell me what I'm doing wrong. If anyone could please help me out I appreciate it a lot.

The steps are in this quote. It is quite long but I wanted to detail EVERY single thing I'm doing. EVERYTHING is there. If you don't see something there that means I didn't do it. Please Please take a look at this and the attached image and tell me what I'm doing wrong.
EDIT: The image reads left to right with each vertical column being a new step and each horizontal row being a break in a series of steps to make it more easily readable.

HOST Computer: Windows 7 Ultimate x64 SP1
VM Software: VMware Workstation 10.0.1 build-1379776
VM OS: Windows: Windows 7 Ultimate x64 SP1
Windows ISO MD5: c9f7ecb768acb82daacf5030e14b271e

Navigate to Python.org
Download: Python 3.4.3 Windows x86-64 MSI Installer
https://www.python.org/ftp/python/3.4.3/python-3.4.3.amd64.msi

Download: Python 2.7.10 Windows x86-64 MSI Installer
https://www.python.org/ftp/python/2.7.10/python-2.7.10.amd64.msi

Install Python 2.7.10 and 3.4.3.

Download: CTRULIB v0.5.0
https://github.com/smealum/ctrulib/releases/tag/v0.5.0

Download: devkitProUpdater-1.5.4
http://sourceforge.net/projects/devkitpro/files/Automated Installer/

Install devkitProUpdater-1.5.4

Run DevKitPro's MSYS.BAT to generate a Windows Username folder, "VMTake2" in devkitpro\msys\home

Copy ctrulib-0.5.0 from its compressed zip and into the devkitpro\msys\home\VMTake2 folder

use MSYS.bat to successfully "make" ctrulib\examples\graphics\printing\hello-world

Download: libSDL_3DS-v0.3.zip
https://gbatemp.net/threads/sdl-for-3ds.374519/

Extract: libSDL_3DS-v0.3.zip to devkitpro\msys\home\VMTake2

Attempt to "make" libSDL_3DS-v0.3\example with errors
>bin2s data/demo.wav | arm-none-eabi-as -o data/demo.o
>/bin/sh: bin2s: command not found
>/bin/sh: arm-none-eabi-as: command not found
>make: *** [data/demo.o] Error 127

-------

PS:
If relevant, here's a copy of my System PATH
c:\devkitPro\msys\bin;C:\Python34\;C:\Python34\Scripts;C:\Python27\;C:\Python27\Scripts;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
 

Attachments

  • Steps.jpg
    Steps.jpg
    1.2 MB · Views: 198
OK, so I'm unable to compile libSDL_3DS-v0.3 with devkitpro. I keep getting errors.
I'm using a Virtual Machine of Windows 7x64.

I have detailed every single mousclick and button press in the attached image and have written down every step for someone to please look over and tell me what I'm doing wrong. If anyone could please help me out I appreciate it a lot.

The steps are in this quote. It is quite long but I wanted to detail EVERY single thing I'm doing. EVERYTHING is there. If you don't see something there that means I didn't do it. Please Please take a look at this and the attached image and tell me what I'm doing wrong.
EDIT: The image reads left to right with each vertical column being a new step and each horizontal row being a break in a series of steps to make it more easily readable.
I got all the libs compiled fine (with some changes, seeing it's a bit old now and things have changed in devkitpro since), but the demo won't build no matter what i do, always end up with cannot find 3dsx_crt0.o: No such file or directory

As for the error you're getting, obviously your PATH isn't setup right as it can't find arm-none-eabi-as.exe when it should be able to find it if your path is setup correctly. Either way, it clearly won't build the demo with a recent version of devkitpro (not for me anyway).
 
As for the error you're getting, obviously your PATH isn't setup right as it can't find arm-none-eabi-as.exe when it should be able to find it if your path is setup correctly. Either way, it clearly won't build the demo with a recent version of devkitpro (not for me anyway).

Huh weird. I included my PATH in the big long step by step text IDK what the problem could be. All this stuff is very confusing and I've never been able to get anything but CTRULIB to not throw a bunch of errors.
Like I just downloaded SF2DLIB for 3DS and like the other stuff in the step by step pics I provided I literally just extracted the zip into the devkitPro\msys\home\Username folder, navigated to the example directory and said "make" and of course it throws a bunch of errors, lol.

I feel like there's a missing step that everyone but me knows about which is super frustrating.
STEP1: Eveything I did in those pictures
STEP2: ????????
STEP3: Successfully compile

Like there was a thread recently of some kid who probably has about as much experience as me doing this stuff (ZERO) asking how to make a game and everyone said Python + SF2DLIB... and there's very little beginner level explanation for how actually put those 2 things together to make something :(

I'll probably make a similar big long question detailing everything in that thread tomorrow. It's frustrating though. It has been consistently proven that there's some essential inate knowledge that everyone but me has.
 

Attachments

  • more_errors.jpg
    more_errors.jpg
    260.8 KB · Views: 176
@Shadowtrance
About the 3dsx_crt0.o problem.
"3DS applications now need to be built with -mfloat-abi=hard, if you get " cannot find 3dsx_crt0.o: No such file or directory" on linking then look for -mfloat-abi=softfp in your Makefile, change it to mfloat-abi=hard then rebuild everything." Source

@dfsa3fdvc1
In the picture the linker cannot find the sf2d library.
What you need to do is
1st: download the sf2d library and with cmd run "make" in the directory where the Makefile is. Make sure that the library is compiled.
2nd: Run "make install" in the same directory to install automatically the library.
3rd: Navigate to sample directory and try to make sample again.
 
Yeah i already knew that. And i changed all the makefiles to hard, not sure what to change in the demo makefile though as it doesn't even have any -mfloat of any sort in it.

Doesn't really bother me as i was only really looking at it to maybe help the other guy out. :)
 
Guys I'm having some problems here...
I'm trying to code a simple game (Snake) for the 3DS. I'm using rand() to calculate coordinates for the thingy that you have to make the snake eat but rand() always returns the same value even though I use srand(time(NULL)) before.
This is the code I'm using:
srand(time(NULL));
int x = (((rand()%40+1)*10))-5;
int y = (((rand()%24+1)*10))-5;

For some reason this always returns 365 and 205. The compiler doesn't show any errors whatsoever and I used the same exact code in the pc version where it works completely fine.

I've read the source code of the sample of sf2dlib and it uses the same code, with a different range but that shouldn't make a difference.

I've included the math.h and time.h header so I really don't see any reason why it wouldn't work. Can you help me out?
 
Guys I'm having some problems here...
I'm trying to code a simple game (Snake) for the 3DS. I'm using rand() to calculate coordinates for the thingy that you have to make the snake eat but rand() always returns the same value even though I use srand(time(NULL)) before.
This is the code I'm using:
srand(time(NULL));
int x = (((rand()%40+1)*10))-5;
int y = (((rand()%24+1)*10))-5;

For some reason this always returns 365 and 205. The compiler doesn't show any errors whatsoever and I used the same exact code in the pc version where it works completely fine.

I've read the source code of the sample of sf2dlib and it uses the same code, with a different range but that shouldn't make a difference.

I've included the math.h and time.h header so I really don't see any reason why it wouldn't work. Can you help me out?
When do you call srand?
 
So I've ended up resorting to using audio via RAW since I believe that's the simplest thing for my skill level to implement.

However, ever since implementing a function to load and play a sound, my app now crashes upon launching. For reference, I used the load_audio function from 3DS Nyan Cat. I did csndInit() in main, before attempting to use other csnd functions, am I missing something else?

EDIT: It still crashes when I comment out all load_audio calls, but runs fine when I comment out both the load_audio and csndInit() calls. Am I initializing something wrong?

Anybody have any ideas about this?
 
I've tried it both in the constructor and right before I call rand ()

In my program, I call it in main pretty early, before the main loop. But instead of srand(time(NULL)), I use srand(osGetTime()). Don't know if it makes a difference or not, but I just preferred to use a libctru call to seed it as opposed to a time.h call, and it works fine for me.
 
Guys I'm having some problems here...
I'm trying to code a simple game (Snake) for the 3DS

Lol I'm creating a snake game too :P Maybe it's one of the simplest games to start with to learn a new hardware and Libs :)
There are already 2 snake games for 3DS. If we finish our games there will be 4 XD
 
Last edited by geocool,
Lol I'm creating a snake game too :P Maybe it's one of the simplest games to start with to learn a new hardware and Libs :)
There are already 2 snake games for 3DS. If we finish them there will be 4 XD

My first project is pretty daring: Fibbage for 3DS. Fibbage is a bluff-to-fill-in-the-blank party game by Jackbox Games (the makers of You Don't Know Jack). Basically you try to fill in the blank of a weird fact with a lie to trick other players into picking your lie, while simultaneously trying to pick the truth yourself.

My advantage is that I have previously coded a command line version of it in C++, so I can reuse a lot of my more back-end code. But it's still a pain in the ass to learn as I go how to handle graphics, audio, and video since even on the PC it's not something I've done before.
 
Lol I'm creating a snake game too :P Maybe it's one of the simplest games to start with to learn a new hardware and Libs :)
There are already 2 snake games for 3DS. If we finish our games there will be 4 XD
I'm gonna make one too then #Snake5
 
First you have to adapt the CSND callbacks to newer libctru syntax (unless you want to use my edited old libctru version.
lua_State is what official LUA intend for LUA stack.
Instead of lua_State you need to pass all the objects required from the function (for example the JPGV object or the filename and so on).
All the arguments you have to add can be found watching all the luaL_checkSOMETHING calls.

So I've successfully implemented your BMPV functions in my code (yeah, I know, use JPGV, but I'm sticking to BMPV for now). How do I go about using the functions? There's loadBMPV, startBMPV, and drawBMPV. I tried both loading and starting the BMPV with a bool flag so that it only gets done once, and then drawBMPV every frame, but Citra gives me a constant memory Write error. Basically load and draw work but as soon as I call startBMPV I start getting nasty errors, and of course the video doesn't show no matter what.

Here's my current version of startBMPV, I apologize in advance for the botched surgery I performed on it. I basically trimmed the fat so that it compiles on pure C and with the new libctru calls.

Code:
int startBMPV(BMPV* src, int loop, int ch1, int ch2){
    #ifndef SKIP_ERROR_HANDLING
        if (src->magic != 0x4C424D56) return 0;
    #endif
    src->ch2 = ch2;
    src->loop = loop;
    src->isPlaying = true;
    src->ch1 = ch1;
    src->currentFrame = 0;
    u32 bytesRead;
    if (src->samplerate != 0 && src->audio_size != 0){
        while(src->mem_size > 524288){
            src->mem_size = src->mem_size / 2;
        }
        if (src->audiotype == 1){
            FSFILE_Read(src->sourceFile, &bytesRead, 28, src->audiobuf, src->mem_size);
            csndPlaySound(ch1, SOUND_FORMAT_16BIT | SOUND_REPEAT, src->samplerate, (u32*)src->audiobuf, (u32*)src->audiobuf, src->mem_size);
        }else{
            u8* audiobuf = (u8*)linearAlloc(src->mem_size);
            FSFILE_Read(src->sourceFile, &bytesRead, 28, audiobuf, src->mem_size);
            src->audiobuf = (u8*)linearAlloc(src->mem_size/2);
            src->audiobuf2 = (u8*)linearAlloc(src->mem_size/2);
            u32 off=0;
            u32 i=0;
            u16 z;
            while (i < (src->mem_size)){
                z=0;
                while (z < (src->bytepersample/2)){
                    src->audiobuf[off+z] = audiobuf[i+z];
                    src->audiobuf2[off+z] = audiobuf[i+z+(src->bytepersample/2)];
                    z++;
                }
                i=i+src->bytepersample;
                off=off+(src->bytepersample/2);
            }
            linearFree(audiobuf);
            csndPlaySound(src->ch1, SOUND_FORMAT_16BIT | SOUND_REPEAT, src->samplerate, (u32*)src->audiobuf, (u32*)src->audiobuf, src->mem_size/2);
            csndPlaySound(src->ch2, SOUND_FORMAT_16BIT | SOUND_REPEAT, src->samplerate, (u32*)src->audiobuf2, (u32*)src->audiobuf2, src->mem_size/2);
        }
        CSND_SetPlayState(ch1, 1);
        if (src->audiotype == 2) CSND_SetPlayState(src->ch2, 1);
        CSND_UpdateInfo(0);
        src->tick = osGetTime();
        src->moltiplier = 1;
    }else src->tick = osGetTime();
    return 0;
}
 
So I've successfully implemented your BMPV functions in my code (yeah, I know, use JPGV, but I'm sticking to BMPV for now). How do I go about using the functions? There's loadBMPV, startBMPV, and drawBMPV. I tried both loading and starting the BMPV with a bool flag so that it only gets done once, and then drawBMPV every frame, but Citra gives me a constant memory Write error. Basically load and draw work but as soon as I call startBMPV I start getting nasty errors, and of course the video doesn't show no matter what.

Here's my current version of startBMPV, I apologize in advance for the botched surgery I performed on it. I basically trimmed the fat so that it compiles on pure C and with the new libctru calls.

Code:
int startBMPV(BMPV* src, int loop, int ch1, int ch2){
    #ifndef SKIP_ERROR_HANDLING
        if (src->magic != 0x4C424D56) return 0;
    #endif
    src->ch2 = ch2;
    src->loop = loop;
    src->isPlaying = true;
    src->ch1 = ch1;
    src->currentFrame = 0;
    u32 bytesRead;
    if (src->samplerate != 0 && src->audio_size != 0){
        while(src->mem_size > 524288){
            src->mem_size = src->mem_size / 2;
        }
        if (src->audiotype == 1){
            FSFILE_Read(src->sourceFile, &bytesRead, 28, src->audiobuf, src->mem_size);
            csndPlaySound(ch1, SOUND_FORMAT_16BIT | SOUND_REPEAT, src->samplerate, (u32*)src->audiobuf, (u32*)src->audiobuf, src->mem_size);
        }else{
            u8* audiobuf = (u8*)linearAlloc(src->mem_size);
            FSFILE_Read(src->sourceFile, &bytesRead, 28, audiobuf, src->mem_size);
            src->audiobuf = (u8*)linearAlloc(src->mem_size/2);
            src->audiobuf2 = (u8*)linearAlloc(src->mem_size/2);
            u32 off=0;
            u32 i=0;
            u16 z;
            while (i < (src->mem_size)){
                z=0;
                while (z < (src->bytepersample/2)){
                    src->audiobuf[off+z] = audiobuf[i+z];
                    src->audiobuf2[off+z] = audiobuf[i+z+(src->bytepersample/2)];
                    z++;
                }
                i=i+src->bytepersample;
                off=off+(src->bytepersample/2);
            }
            linearFree(audiobuf);
            csndPlaySound(src->ch1, SOUND_FORMAT_16BIT | SOUND_REPEAT, src->samplerate, (u32*)src->audiobuf, (u32*)src->audiobuf, src->mem_size/2);
            csndPlaySound(src->ch2, SOUND_FORMAT_16BIT | SOUND_REPEAT, src->samplerate, (u32*)src->audiobuf2, (u32*)src->audiobuf2, src->mem_size/2);
        }
        CSND_SetPlayState(ch1, 1);
        if (src->audiotype == 2) CSND_SetPlayState(src->ch2, 1);
        CSND_UpdateInfo(0);
        src->tick = osGetTime();
        src->moltiplier = 1;
    }else src->tick = osGetTime();
    return 0;
}

This is the BMPV reproduction sample for lpp-3ds:
https://github.com/Rinnegatamante/lpp-3ds/blob/master/samples/bmpv.lua

 
In my program, I call it in main pretty early, before the main loop. But instead of srand(time(NULL)), I use srand(osGetTime()). Don't know if it makes a difference or not, but I just preferred to use a libctru call to seed it as opposed to a time.h call, and it works fine for me.
welp, using osGetTime() actually did the trick, thanks!!
 
I think I'm losing my mind. Any time I try to do csndInit(), my program crashes. Every. Time. I removed every other csnd related call, and simply calling csndInit() causes a crash.

On a real 3DS, it just loads a few random sprites to the screen in random places and crashes. I can't even test it on Citra since it doesn't have sound emulation, though it does complain about being unable to initialize csnd and I get constant read32 errors when trying to play a sound. I must be forgetting something, what am I doing wrong!!!
 
How exactly do you use threads with ctrulib? I know that there's an example included but it that one doesn't compile at all for me.
 

Site & Scene News

Popular threads in this forum