Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.

Pokémon Mystery Dungeon: Red Rescue Team/pksdir0

From Data Crystal
Jump to navigation Jump to search

This is a sub-page of Pokémon Mystery Dungeon: Red Rescue Team.

"pksdir0" is a 7-characters string with a null ending character, present several hundreds of times in the ROM, with different amount for different region localization.

In some instances, it is part of a pseudo-directory structure used by the game to compensate the GBAs lack of built-in file/directory support, but also occurs a lot more often outside of such a structure with no known purpose. In fact, the game only seems to contain 9 such structures total in contrast to the many times the string occurs in each version. Modifying or removing these strings might be safe in instances when it is not part of a directory structure, but care should still be taken as the reason for their presence is still unknown.

The directory structure is laid out as follows:

 offset    length    description
---------  ------   -------------
00 (0x00)     8     null-terminated "pksdir0" string (the game checks for this string, and refuses to load/find files if it is incorrect)
08 (0x08)     4     a four-byte integer holding the number of file entries in this pksdir structure
12 (0x0B)     4     little-endian GBA pointer to the table of file entries

The file entry structure referenced by the last pointer is similarly simple, each entry being 8 bytes in size:

 offset    length    description
---------  ------   -------------
00 (0x00)     4     pointer to a string with the filename
04 (0x04)     4     pointer to the actual file data

The file entries in the file entry table have to be in alphabetical order, more specifically in an ascending order according to their ANSI values with shorter names first (the game uses a special search algorithm that takes advantage of this ordering).


The code reading those directory structures has special handling for files with a SIRO Data Header (also see this SIR0/SIRO format decription). Red Rescue Team contains only the "pre-loaded" SIRO headers, and the function that is supposed to take a SIR0 header and load it into memory (becoming a SIRO header in the process) is a stub that simply returns without doing anything.

These strings are not present in Blue Rescue Team.