Homebrew Development

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

  1. MaiconErick

    MaiconErick GBAtemp Regular

    Member
    1
    Jan 4, 2016
    Brazil
    Does anyone have the source code of PCHex++?
    I'm really interested on learning to make a cool GUI like that, FBI's seems too complicated :X
    The github for PCHex++ doesn't exist anymore :(
     
  2. Slattz

    Slattz Easygoing Fairy

    Member
    7
    Nov 21, 2015
    Ireland
    Here it is. Though this uses some outdated libs, it's recommended to use citro3d now.

    If you want an easy way to render a 2D UI, you could use pp2d, which is a wrapper for citro3d.
    I know some people here don't like it for their own reasons but it's probably the best/easiest way to render a 2D UI atm. You could easily replicate PCHex++'s UI using it.
    BernardoGiordano's discord server is linked in that readme & you can find the latest pp2d pinned in the pp2d channel there, along with an example, if you decide you'd like to use it.
     
  3. MaiconErick

    MaiconErick GBAtemp Regular

    Member
    1
    Jan 4, 2016
    Brazil
    I'm trying to use the pp2d example, but when I try to 'make', I get a bunch of these errors:

    c:/pp/source/pp2d/pp2d.c:336: undefined reference to `C3D_Init'
    c:/pp/source/pp2d/pp2d.c:338: undefined reference to `C3D_RenderTargetCreate'
    c:/pp/source/pp2d/pp2d.c:339: undefined reference to `C3D_RenderTargetSetClear'

    I don't know if I'm using a wrong Makefile, I'm using the devkitPRO examples' Makefile, and I added /source/pp2d to the sources in Makefile.
    You're helping me a lot, thanks. :lol:
     
  4. Slattz

    Slattz Easygoing Fairy

    Member
    7
    Nov 21, 2015
    Ireland
    You don't have citro3d, or at least it's headers, installed I think. You can get it from here. Extract the folders in the .bz2 file to the libctru folder in your devkitPro folder.
    For me, that's C:\devkitPro\libctru but it may be different for you depending on where you installed devkitPro.
     
  5. MaiconErick

    MaiconErick GBAtemp Regular

    Member
    1
    Jan 4, 2016
    Brazil
    I ran a make install on citro3d last night, and when I tried to paste the folders now, I already had all those files, so I'm guessing I already had citro3d installed.
    Still not working.
    I have the same devkitPro path.

    I didn't install pp2d, just put the folder in 'sources' folder of the project. I was reading on reddit that would be enough.
     
    Last edited by MaiconErick, Feb 5, 2018
  6. Slattz

    Slattz Easygoing Fairy

    Member
    7
    Nov 21, 2015
    Ireland
    is citro3d in the libs section of the makefile then (LIBS := -lcitro3d)? and yea, pp2d is fine in the sources folder
     
    MaiconErick likes this.
  7. MaiconErick

    MaiconErick GBAtemp Regular

    Member
    1
    Jan 4, 2016
    Brazil
    It wasn't. It works now, thanks.
    Gonna play with pp2d now :)
     
    Slattz likes this.
  8. MaiconErick

    MaiconErick GBAtemp Regular

    Member
    1
    Jan 4, 2016
    Brazil
    Do you know of a way do display animated gifs on a homebrew?
    @Slattz
     
  9. Slattz

    Slattz Easygoing Fairy

    Member
    7
    Nov 21, 2015
    Ireland
    I don't know of a way to use gifs on homebrew. Someone else might know more though, but I think it may not be possible atm.
     
    MaiconErick likes this.
  10. ElijahZAwesome

    ElijahZAwesome Hey. I exist. Woo

    Member
    5
    Jul 12, 2016
    United States
    Narnia
    old post but i still cant figure out romfs for what i need lol. Can I load sounds and stuff from romfs? The example is helping a little but i still can't get it right.
     
  11. nop90

    nop90 GBAtemp Advanced Maniac

    Member
    11
    Jan 11, 2014
    Italy
    Rome
    You can load whatever file you want from RomFS, as long as:
    • you crate a RomFS package with the content you want to load (this is automated in the buid proces if you put your files in a data folder - e.g DATA - use the right makefile with the ROMFS variable defined as your data folder, and, for the CIA package, if you use a rsf file with the romfs option enabled
    • you init the romfs service before trying to access it (remember to close it befor exiting the program)
    • you use a path beginning with romfs:/ for your file (fopen, fclose, fread works as usual, but remember you can't list directory content)
    • remember that file and folder names are case sensitive
     
  12. ElijahZAwesome

    ElijahZAwesome Hey. I exist. Woo

    Member
    5
    Jul 12, 2016
    United States
    Narnia
    alright... ill mess around some more.

    I set ROMFS as a ROMFS folder respectively, I tried both Result rc = romfsInit(); and just romfsInit();, and loaded a raw sound from romfs:/resources/menu.raw, and theres no missing file error in Citra but the sound doesnt play
     
  13. ElijahZAwesome

    ElijahZAwesome Hey. I exist. Woo

    Member
    5
    Jul 12, 2016
    United States
    Narnia
    Im trying my best, i really am lol. No luck. For context, heres the repo of the code im using https://github.com/ElijahZAwesome/Minicraft3DS/

    the notable files are https://github.com/ElijahZAwesome/Minicraft3DS/blob/master/build.bat

    and https://github.com/ElijahZAwesome/Minicraft3DS/blob/master/source/Sound.c

    and
    Code:
    void loadSound(Sound * snd, char * filename){
        romfsInit();
        FILE *file = fopen(filename, "rb");
        if(file != NULL){
            fseek(file, 0, SEEK_END);
            snd->size = ftell(file);
            fseek(file, 0, SEEK_SET);
            snd->buffer = linearAlloc(snd->size);
            fread(snd->buffer, 1, snd->size, file);
        }
        fclose(file);
        romfsExit();
    }
    in https://github.com/ElijahZAwesome/Minicraft3DS/blob/master/source/main.c
     
  14. nop90

    nop90 GBAtemp Advanced Maniac

    Member
    11
    Jan 11, 2014
    Italy
    Rome
    Gave only a fast look to you code, and the first thing I notice is:

    Code:
    loadSound(&snd_playerHurt, "resources/playerhurt.raw");
    
    the file name miss the starting romfs:/. it should be:

    Code:
    loadSound(&snd_playerHurt, "romfs:/resources/playerhurt.raw");
    
    Second think, don't call romfsInit() and romfsExit(); inside a functio. Put the at the beginning and at the end of main().

    Sorry, I don't have time now to deeply check your code.
     
  15. ElijahZAwesome

    ElijahZAwesome Hey. I exist. Woo

    Member
    5
    Jul 12, 2016
    United States
    Narnia
    Thanks, ill move romfsInit to the beginning of main, but as for not including romfs:/ some of them are romfs: and some arent, for testing. sorry.
     
  16. ElijahZAwesome

    ElijahZAwesome Hey. I exist. Woo

    Member
    5
    Jul 12, 2016
    United States
    Narnia
    I moved the initiations and exits to main() and still nothing. also added romfs:/ to every sound. nothing.
     
  17. nop90

    nop90 GBAtemp Advanced Maniac

    Member
    11
    Jan 11, 2014
    Italy
    Rome
    Other two hints:

    you set the CSND format as SOUND_FORMAT_16BIT, than you set the snd->size as the raw file size (number of bytes) and pass it as the sound lenght (number of 16 samples). somewhere you have to divide that value by two, or you'll read out of allocated memory and your code will crash (on a real 3ds).

    Other important thing, check that your raw sound stream are:
    1) mono
    2) 16 bit samples
    3) little endian encoded

    I suggest to use 8 bit mono streans, this lower the final volume, but your files will be smaller and you don't have to worry about endianess.

    About file sizes, loading a big amount of data on linear memory, can easily over it's availability, and when you linearalloc() the memory, you're noth chhecking if you have a valid pointer or a null value (meaning no memory left). Very dangerous :evil:
     
  18. ElijahZAwesome

    ElijahZAwesome Hey. I exist. Woo

    Member
    5
    Jul 12, 2016
    United States
    Narnia
    but... it works just fine if you have the sound in a folder on the SD...
     
  19. nop90

    nop90 GBAtemp Advanced Maniac

    Member
    11
    Jan 11, 2014
    Italy
    Rome
    this changes the situation.

    I'll check the makefile and try to build the program with my toolchain. I'll make you know.
     
  20. nop90

    nop90 GBAtemp Advanced Maniac

    Member
    11
    Jan 11, 2014
    Italy
    Rome
    And the answer is:

    you try to open the file playerdeath.raw that isn't in the romfs package. This probably stop the service and the other sound file aren't loaded.