Homebrew Development

Discussion in '3DS - Homebrew Development and Emulators' started by aliak11, Jan 16, 2014.

  1. Maxouille

    Maxouille Member

    Newcomer
    42
    10
    Nov 2, 2016
    France
    Alola
    Yes
     
    Last edited by Maxouille, May 5, 2017
  2. erman1337

    erman1337 GBAtemp Maniac

    Member
    1,211
    931
    Sep 27, 2015
    Belgium
    Brussels
    I suggest you to use this: https://github.com/Steveice10/BuildTemplate
     
  3. yerWizard

    yerWizard Member

    Newcomer
    32
    37
    Oct 21, 2016
    Im trying to compile OpenAL-Soft for the 3ds and im getting these errors at compilation:

    Code:
    [  2%] Building C object CMakeFiles/OpenAL.dir/common/rwlock.c.obj
    In file included from /home/sdk/openal-soft/common/rwlock.c:8:0:
    /home/sdk/openal-soft/common/threads.h:122:9: error: unknown type name 'pthread_t'
     typedef pthread_t althrd_t;
             ^~~~~~~~~
    /home/sdk/openal-soft/common/threads.h:123:9: error: unknown type name 'pthread_mutex_t'
     typedef pthread_mutex_t almtx_t;
             ^~~~~~~~~~~~~~~
    /home/sdk/openal-soft/common/threads.h:124:9: error: unknown type name 'pthread_cond_t'
     typedef pthread_cond_t alcnd_t;
             ^~~~~~~~~~~~~~
    /home/sdk/openal-soft/common/threads.h:125:9: error: unknown type name 'pthread_key_t'
     typedef pthread_key_t altss_t;
             ^~~~~~~~~~~~~
    /home/sdk/openal-soft/common/threads.h:126:9: error: unknown type name 'pthread_once_t'
     typedef pthread_once_t alonce_flag;
    
    In the cmake process prior the file pthreads.h had been found but not some functions of pthreads.h which is strange.
    cmake output
     
    Last edited by yerWizard, May 8, 2017
  4. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    811
    299
    Jul 28, 2008
    United States
    Thread support is somewhat limited on the 3ds. It requires cooperative multitasking - or you end up with hung threads. So, most threaded apps/libraries are not going to work without quite a bit of effort and modification.
     
  5. yerWizard

    yerWizard Member

    Newcomer
    32
    37
    Oct 21, 2016
    I see.
    This is going to be harder than i'd hoped :P.
    Thanks.
     
  6. MRJPGames

    MRJPGames Pretty great guy

    Member
    1,111
    717
    Aug 17, 2013
    Netherlands
    The Netherlands
    Does anyone know how to get the username set for the 3DS in settings?
    I want this for leaderboards without having to implement a keyboard kek.
     
  7. erman1337

    erman1337 GBAtemp Maniac

    Member
    1,211
    931
    Sep 27, 2015
    Belgium
    Brussels
    Last edited by erman1337, May 12, 2017
  8. MRJPGames

    MRJPGames Pretty great guy

    Member
    1,111
    717
    Aug 17, 2013
    Netherlands
    The Netherlands
    Thanks for the reply. However this doesn't work for me at all... The code I have to try to load this is this:
    Code:
        cfguInit();
        u8 username;
        CFGU_GetConfigInfoBlk2(0xC1, 0x000A0000, &username);
        string user(test, 0xC1);
        name[0]=user;
        cfguExit();
    
    I also tried using the FRD:U service, which did give me results better than this method which on emulator gives nothing and on real hardware just a bunch of Á's. The FRD service method gave me Cta on emulator and Jse on console, where they should've been Citra and Jasper respectively. If anyone know either how to use the cfgu method properly or how to use the frd method help would be much appreciated!
     
    Last edited by MRJPGames, May 13, 2017
  9. Kartik

    Kartik Gbatemp advanced fan

    Member
    356
    261
    Jun 6, 2015
    India
    github
    The username returned is actually utf16, so you need to convert it to ut8:-
    Code:
     cfguInit();
     u8 * outdata = malloc(0x1C);
     u8 * outdata2 = malloc(0x1C);
     CFGU_GetConfigInfoBlk2 (0x1C, 0x000A0000, outdata);
     utf16_to_utf8(outdata2,(u16*)outdata,0x1C);
     printf("Username:%s",(char*)outdata2);
     cfguExit();
    
     
    Last edited by Kartik, May 13, 2017
    MRJPGames likes this.
  10. erman1337

    erman1337 GBAtemp Maniac

    Member
    1,211
    931
    Sep 27, 2015
    Belgium
    Brussels
    Don't you need to put an \0 terminator at the end because the utf16_to_utf8 output isn't terminated
     
  11. MRJPGames

    MRJPGames Pretty great guy

    Member
    1,111
    717
    Aug 17, 2013
    Netherlands
    The Netherlands
    Thanks! This works!

    For anyone wondering this is the code I ended up using (as my project is c++ and wants string output):
    Code:
        cfguInit();
        u8 * outdata = (u8*)malloc(0x1C);
        u8 * outdata2 = (u8*)malloc(0x1C);
        CFGU_GetConfigInfoBlk2 (0x1C, 0x000A0000, outdata);
        utf16_to_utf8(outdata2,(u16*)outdata,0x1C);
        string str((char*)outdata2, 0x1C);
        name[0] = str;
        cfguExit();
    
     
    renhei likes this.
  12. yerWizard

    yerWizard Member

    Newcomer
    32
    37
    Oct 21, 2016
    I modified the textured cube example to make a simple move camera using the circlepad to learn citro3d and picasso and i'm having a lot of trouble with the view and model matrices.
    The cube just doesn't show up on the screen when i add the view matrix to the main file and shader file.
    Here's the main.c and the v.pica shader.
     
    Last edited by yerWizard, May 13, 2017
  13. catlover007

    catlover007 GBAtemp Regular

    Member
    173
    200
    Oct 23, 2015
    Germany
    I think you moved the cube into the wrong direction. Instead of:
    Code:
    Mtx_Translate(&model, 0.0, 0.0, 2.0f, true);
    
    try:
    Code:
    Mtx_Translate(&model, 0.0, 0.0, -2.0f, true);
    
    Although modelview and projection are already split up in the original example, (atleast I think) it's smarter to premultiply projection * view * model to a MVP matrix. This makes the shader much less complex.
     
  14. yerWizard

    yerWizard Member

    Newcomer
    32
    37
    Oct 21, 2016
    Code:
    Mtx_Translate(&model, 0.0, 0.0, -2.0f, true);
    
    This didn't work. Also i'll have to look into the premultiplying of the matrices, i still don't understand much of this.
     
  15. MRJPGames

    MRJPGames Pretty great guy

    Member
    1,111
    717
    Aug 17, 2013
    Netherlands
    The Netherlands
    Hi, I have this really weird problem. My game save to an XML file, which used to work fine. But for some reason stopped working. The weirdest thing is that when testing in citra it works just fine. It is only on real hardware that it doesn't work. However the weirdest thing is that it USED to work just fine. And I didn't change any code involving saving. Now I did change other code, one of which also loads the XML file. But in earlier testing this worked fine, now however it reads nothing at all, just like the save code. Does anyone know what could cause a program to stop being able to read files?

    The way I read the files currently is:
    Code:
    std::ifstream t(fileLocation);
    std::stringstream buffer;
    buffer << t.rdbuf();
    
    The code that is meant to create/update the file is this:
    Code:
    xml_doc.SaveFile(fileLocation.c_str());
    
    And again this exact code USED to work, but has stopped working for whatever reason.
    The only thing I could think of is that there might be a memory issue, where if too little ram is available the file will fail to load or write? But at the very least linearFreeMem() gives me ~16MB of free space, which should be more than enough for the small XML file...
     
  16. catlover007

    catlover007 GBAtemp Regular

    Member
    173
    200
    Oct 23, 2015
    Germany
    Ah, I found another error in your code:
    Code:
    uLoc_model        = shaderInstanceGetUniformLocation(program.vertexShader, "modelView");
    
    you renamed the uniform from modelView to model. Maybe it works after changes this.

    Also instead of writing a = a + b or a = a - b you can simply write a += b or a -= b(this works with almost every operator, e.g. *=, |= or %=)
     
    Last edited by catlover007, May 14, 2017
    yerWizard likes this.
  17. Kartik

    Kartik Gbatemp advanced fan

    Member
    356
    261
    Jun 6, 2015
    India
    github
    Are you sure you don't have memory leaks in your code?Also try using a different SD card.
     
  18. yerWizard

    yerWizard Member

    Newcomer
    32
    37
    Oct 21, 2016
    This along with the previous fix did it! Thanks!
     
  19. MRJPGames

    MRJPGames Pretty great guy

    Member
    1,111
    717
    Aug 17, 2013
    Netherlands
    The Netherlands
    I'm not sure I don't leak memory. However linearFreeMem() reports as much free memory before as after file load/online load so if this reporting is accurate it doesn't leak any memory. As for using another SD card, though it shouldn't make a diffrence as I'm able to read and write from it just fine using ftpd, I did try it and as expected it changed nothing. Just for the sake of it I also tried it on my o3DS (with of course yet another SD card) this also did not work.

    So the question still stands, WHY did it suddenly stop working... And why does it work in emulator, meaning the code should in theory be fine?

    Of course I tried some other things as well. As the Online object was what I was working on around the time it stopped working I though it might be useful to try to see what happens when I remove this class completely, essentially reverting back to the last working version. However this still does not work...

    So essentially I have no idea what the problem could possibly be...
    Here is the code involving loading/saving of files (fileLocation is always requested with "3ds/AoTHISave.xml"):
    Warning: Spoilers inside!
    I'll push the version which still includes Online etc. to GitHub soon the repo is: https://github.com/MrJPGames/AoTHI3D
    I really hope someone can tell me what I'm doing wrong and where. (except for the terrible coding practices of course I'm well aware of those)
     
  20. catlover007

    catlover007 GBAtemp Regular

    Member
    173
    200
    Oct 23, 2015
    Germany
    As far as I know the linear memory is a different heap, than the standard heap. It's a smaller special memory region, which other hardware components can access. So you aren't getting the amount of free memory in the heap, your're allocating from with malloc(or C++ new) with linearFreeMem.
    But I think it's really unlikely that the error is a result of a full heap.