Pokémon Mystery Dungeon: Red Rescue Team/pksdir0: Difference between revisions

From Data Crystal
Jump to navigation Jump to search
mNo edit summary
(i reverse engineered some functions relating to the pksdir directory structures, and updated this page with my findings.)
Line 3: Line 3:
"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.
"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.


Its use is unknown, but it is probably just a development leftover with no use whatsoever. It can probably be modified or removed without consequences to game functionality.
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 outside of that structure with no known purpose.
Special care should be taken in evaluating its usage context before modifying these strings or any data near them/following them, as the game ensures that the string is present when parsing the directory structure.


It is not present in [[Pokémon Mystery Dungeon: Blue Rescue Team|Blue Rescue Team]].
The directory structure is laid out as follows:
<pre>
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
</pre>
 
The file entry structure referenced by the last pointer is similarly simple, each entry being 8 bytes in size:
<pre>
offset    length    description
---------  ------  -------------
00 (0x00)    4    pointer to a string with the filename
04 (0x04)    4    pointer to the actual file data
</pre>
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 [[Pokémon Mystery Dungeon: Red Rescue Team|SIRO Data Header]] (also see this [https://projectpokemon.org/home/docs/mystery-dungeon-nds/sir0siro-format-r46/ 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 (and by extension the directory structures) are not present in [[Pokémon Mystery Dungeon: Blue Rescue Team|Blue Rescue Team]], likely because of the built-in support for files and directories of the DS.

Revision as of 16:17, 23 July 2021

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.

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 outside of that structure with no known purpose. Special care should be taken in evaluating its usage context before modifying these strings or any data near them/following them, as the game ensures that the string is present when parsing the directory structure.

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 (and by extension the directory structures) are not present in Blue Rescue Team, likely because of the built-in support for files and directories of the DS.