nfsu / NFS

Is a tool created for rom hacking, it stands for Nintendo File System (Utils) and can quickly read and interpret nds files such as NARC, NCLR, NCGR, etc.
MIT License
24 stars 1 forks source link
armv7 armv9 data-structures editor emulator filesystem narc nds nintendo rom rom-hacking tool-kit

NFS logo
Nintendo File System

NFS(U) stands for Nintendo File System (Utils) and is designed to read and interpret nds files such as NARC, NCLR, NCGR, etc.

Why NFS?

As a kid I loved modifying existing roms for my personal use, but tools were/are either extremely lacking (both in use and looks) or they frequently crashed and were a pain to use. I finally decided to look into Nintendo's file system and how things could be written / read. Thanks to template magician LagMeester4000, I 'simplified' this system using C++ templates, allowing you to add custom formats within a few seconds. The reading/writing/converting is very quick and can be easily used in existing applications.

How to use

Down below you can see a simply use of the NFS API.

Reading raw ROM data

    Buffer buf = readFile("ROM.nds");
    try {
        NDS nds = NType::readNDS(buf);
    } catch (std::exception e) {
        printf("%s\n", e.what());
    }
    deleteBuffer(&buf);

If you've acquired your ROM, you have to load it into memory, so the program can read and modify (a copy) of it. This buffer can be deleted afterwards (and written to a folder, to save all changes made).
NDS is a format that seperates the header from the contents for a NDS file; it stores the important information in a struct and the other stuff in a buffer.

Converting the ROM into a FileSystem

A ROM is like a ZIP; except it is used for storing game data (models, images, sounds, palettes, maps, binary data, text, code and more). This means that it stores the file names into the ROM; which we can use to extract the files we need and where they are.

        FileSystem files;
        NType::convert(nds, &files);

This will put the file data into the files variable, which you can then loop through and use.

        for (auto iter = files.begin(); iter != files.end(); ++iter) {

            FileSystemObject fileSysObj = *iter;
            //More code...
        }

Checks for fso's

Fso stands for 'FileSystemObject' and it is what I call folders and files; this means that fileSysObj isn't always a file, it could also be a folder. To distinguish them, you can use the following functions: