This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
using_the_fnt_and_fat_to_locate_files [2024/08/16 00:21] – [Directory Structure] zero_one | using_the_fnt_and_fat_to_locate_files [2024/08/29 19:54] (current) – [Reading the FNT] zero_one | ||
---|---|---|---|
Line 10: | Line 10: | ||
===== Reading the FNT ===== | ===== Reading the FNT ===== | ||
- | As stated before, the FNT starts with a list of directories, | + | As stated before, the FNT starts with a list of directories, |
==== Directory and Entries Count ==== | ==== Directory and Entries Count ==== | ||
Line 19: | Line 19: | ||
* Offset - 4 bytes - An offset from the beginning of the FNT for the first entry in this directory | * Offset - 4 bytes - An offset from the beginning of the FNT for the first entry in this directory | ||
* FirstID - 2 bytes - The ID of the first file in the sub-table pointed to by the Offset. A directory entry will only ever point at the first file. | * FirstID - 2 bytes - The ID of the first file in the sub-table pointed to by the Offset. A directory entry will only ever point at the first file. | ||
- | * ParentID - 2 bytes - If this is the first directory in the table, then this value is the number of directories in the list. Else, it's the ID of the parent directory that this directory is in. This is how sub-folders work. Directory IDs exist in the range 0xF000-0xFFFF, | + | * ParentID - 2 bytes - If this is the first directory in the table, then this value is the number of directories in the list. Else, it's the ID of the parent directory that this directory is in. This is how sub-folders work. Directory IDs exist in the range 0xF000-0xFFFF, |
{{mph_nrfs_directory_structure.png}} | {{mph_nrfs_directory_structure.png}} | ||
Line 57: | Line 57: | ||
{{mph_nrfs_directory_containing_file.png}} | {{mph_nrfs_directory_containing_file.png}} | ||
- | From this, we can see several things. First is the offset: 0x3DD. Taking our FNT offset of 0x163A00 and adding 0x3DD to it gives us 0x163DDD, which is the location of the first file entry in the entries table. We've just gone backwards from that. Secondly, we can see a parentID of 0xF000. | + | From this, we can see several things. First is the offset: 0x3DD. Taking our FNT offset of 0x163A00 and adding 0x3DD to it gives us 0x163DDD, which is the location of the first file entry in the entries table. We've just gone backwards from that. Secondly, we can see a parentID of 0xF000. |
So how do we get the offset for our file? The directory structure gives us the ID of the first file in the directory. Subsequent files are found by simply incrementing that ID. We know that the file we're looking for was the fourth file in our list of entries, so we just add 3 to our first ID to get a value of 0x16, or 22 in decimal. | So how do we get the offset for our file? The directory structure gives us the ID of the first file in the directory. Subsequent files are found by simply incrementing that ID. We know that the file we're looking for was the fourth file in our list of entries, so we just add 3 to our first ID to get a value of 0x16, or 22 in decimal. |