Any way to include resources inside 3ds, 3dsx or CIA files?

Discussion in '3DS - Homebrew Development and Emulators' started by cebolleto, Apr 27, 2015.

  1. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    5
    Jul 28, 2008
    United States
  2. cebolleto
    OP

    cebolleto GBAtemp Regular

    Member
    5
    Mar 5, 2010
    Yes, you are right
    I have changed it to
    Code:
    u8 file_binary_lowpath[20]  = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
            FS_path fs_path = { PATH_BINARY, 20, file_binary_lowpath };
    but it still doesn't work. I have configured romfsArchive as an empty path on purpose. Where should it point to?
     
  3. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    5
    Jul 28, 2008
    United States
    So fs_path looks good now. Take a look at savedatacheck_archive in the example. That is what romfsArchive should look like. You need to be supplying the file name you are trying to open. Plus the other values are different too.
     
  4. cebolleto
    OP

    cebolleto GBAtemp Regular

    Member
    5
    Mar 5, 2010
    But what is the path supposed to be?
    It says in the documentation that OpenFile will return a handle to the romfs archive and parsing it has to be done manually
     
  5. cebolleto
    OP

    cebolleto GBAtemp Regular

    Member
    5
    Mar 5, 2010
    Back to this topic, I've been trying several attempts, even making sure the romfs is being included on the .cia but no matter what I try, it doesn't work

    Could anyone help me?
     
  6. cebolleto
    OP

    cebolleto GBAtemp Regular

    Member
    5
    Mar 5, 2010
    Ok, I finally managed to get this working (with some help). Here is the code in case someone is interested

    Code:
    void romfsTest()
    {
        FS_archive romfsArchive    = { ARCH_ROMFS, { PATH_EMPTY, 1, (u8*)"" } };
    
        Result rc = 0;
        rc = FSUSER_OpenArchive(NULL, &romfsArchive);
        if(rc == 0) {
           
            Handle fd;
            u8 file_binary_lowpath[20]  = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
            FS_path fs_path = { PATH_BINARY, 12, file_binary_lowpath};
            rc = FSUSER_OpenFile(NULL, &fd, romfsArchive, fs_path, FS_OPEN_READ, FS_ATTRIBUTE_NONE);
            if(rc == 0) {
                char data[1024];
                u32 bytesRead;
                rc = FSFILE_Read(fd, &bytesRead, 0, data, (u32)1024);
                if(rc == 0) {
                    printf("Data read:%d\n", (int)bytesRead);
                    int i = 0;
                    for(i = 0; i < bytesRead; ++i)
                    {
                        printf("%c", data[i]);
                    }
                } else {
                    printf("FSFILE_Read failed(%x)\n", (int)rc);
                }
            } else {
                printf("FSUSER_OpenFile failed(%x)\n", (int)rc);
            }
        } else {
            printf("FSUSER_OpenArchive failed(%x)\n", (int)rc);
        }
    }
    this will print on the console the first 1024 characters of the romfs file if properly added to the .cia or .3ds
     
    hippy dave likes this.
Loading...