diff --git a/CREDITS.txt b/CREDITS.txt index c47967b9..87cd2364 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -31,6 +31,7 @@ other parts of the project, feel free to add yourself to this file! - tech-ticks - Rhokin - ShadyGamerX +- ElectricGeorge - The rest of the contributors to Project Pokémon's technical documentation for the NDS Mystery Dungeon games, which can be found here: https://projectpokemon.org/home/docs/mystery-dungeon-nds/ diff --git a/headers/data/arm9.h b/headers/data/arm9.h index 5e8c5928..efcadd03 100644 --- a/headers/data/arm9.h +++ b/headers/data/arm9.h @@ -162,8 +162,8 @@ extern enum overlay_group_id LOADED_OVERLAY_GROUP_0; extern enum overlay_group_id LOADED_OVERLAY_GROUP_1; extern enum overlay_group_id LOADED_OVERLAY_GROUP_2; extern bool DEBUG_IS_INITIALIZED; -extern struct pack_file_opened* PACK_FILES_OPENED; -extern const char* PACK_FILE_PATHS_TABLE[6]; +extern struct pack_file_opened* DIRECTORY_FILES_EXTRACTED; +extern const char* DIRECTORY_FILE_TABLE[6]; extern struct item* BAG_ITEMS_PTR_MIRROR; extern void* ITEM_DATA_TABLE_PTRS[3]; extern struct move_data_table* MOVE_DATA_TABLE_PTR; diff --git a/headers/functions/arm9.h b/headers/functions/arm9.h index aa8f8b9b..378d2dd8 100644 --- a/headers/functions/arm9.h +++ b/headers/functions/arm9.h @@ -88,48 +88,50 @@ bool GetHeldButtons(int controller, undefined* btn_ptr); bool GetPressedButtons(int controller, undefined* btn_ptr); bool GetReleasedStylus(undefined* stylus_ptr); void KeyWaitInit(void); -void DataTransferInit(void); -void DataTransferStop(void); -void FileInitVeneer(struct file_stream* file); -void FileOpen(struct file_stream* file, const char* filepath); +void FileRom_InitDataTransfer(void); +void FileRom_StopDataTransfer(void); +void FileRom_Veneer_FileInit(struct file_stream* file); +void FileRom_HandleOpen(struct file_stream* file, const char* filepath); uint32_t FileGetSize(struct file_stream* file); -uint32_t FileRead(struct file_stream* file, void* buf, uint32_t size); -void FileSeek(struct file_stream* file, int offset, int whence); +uint32_t FileRom_HandleRead(struct file_stream* file, void* buf, uint32_t size); +void FileRom_HandleSeek(struct file_stream* file, int offset, int whence); void FileClose(struct file_stream* file); void UnloadFile(void* ptr); void LoadFileFromRom(struct iovec* iov, const char* filepath, uint32_t flags); void UpdateFadeStatus(struct screen_fade* fstruct, int param_2, int duration); bool HandleFades(struct screen_fade* fstruct); int GetFadeStatus(struct screen_fade* fstruct); -void InitDebug(void); -void InitDebugFlag(void); -bool GetDebugFlag(enum debug_flag flag); -void SetDebugFlag(enum debug_flag flag, bool val); -void InitDebugStripped6(void); +void Debug_Init(void); +void Debug_InitDebugFlag(void); +bool Debug_GetDebugFlag(enum debug_flag flag); +void Debug_SetDebugFlag(enum debug_flag flag, bool val); +void Debug_Stripped6(void); int AppendProgPos(char* str, struct prog_pos_info* prog_pos, const char* msg); -void InitDebugStripped5(void); -void DebugPrintTrace(const char* msg, struct prog_pos_info* prog_pos); +void Debug_Stripped5(void); +void Debug_PrintTrace(const char* msg, struct prog_pos_info* prog_pos); void DebugDisplay(const char* fmt, ...); -void DebugPrint0(const char* fmt, ...); -void InitDebugLogFlag(void); -bool GetDebugLogFlag(enum debug_log_flag flag); -void SetDebugLogFlag(enum debug_log_flag flag, bool val); -void DebugPrint(uint8_t level, const char* fmt, ...); -void InitDebugStripped4(void); -void InitDebugStripped3(void); -void InitDebugStripped2(void); -void InitDebugStripped1(void); -void FatalError(struct prog_pos_info prog_pos, const char* fmt, ...); -void OpenAllPackFiles(void); -uint32_t GetFileLengthInPackWithPackNb(enum pack_file_id pack_id, uint32_t file_index); -uint32_t LoadFileInPackWithPackId(enum pack_file_id pack_id, uint32_t file_index, - void* output_buffer); -void AllocAndLoadFileInPack(enum pack_file_id pack_id, uint32_t file_index, - struct pack_alloc_and_load_result* output, uint32_t malloc_flags); -void OpenPackFile(struct pack_file_opened* pack_file, const char* file_name); -uint32_t GetFileLengthInPack(struct pack_file_opened* pack_file, uint32_t file_index); -uint32_t LoadFileInPack(struct pack_file_opened* pack_file, void* output_buffer, - uint32_t file_index); +void Debug_Print0(const char* fmt, ...); +void Debug_InitLogFlag(void); +bool Debug_GetLogFlag(enum debug_log_flag flag); +void Debug_SetLogFlag(enum debug_log_flag flag, bool val); +void Debug_Print(uint8_t level, const char* fmt, ...); +void Debug_Stripped4(void); +void Debug_Stripped3(void); +void Debug_Stripped2(void); +void Debug_Stripped1(void); +void Debug_FatalError(struct prog_pos_info prog_pos, const char* fmt, ...); +void DirectoryFileMngr_ExtractAllDirectoryFiles(void); +uint32_t DirectoryFileMngr_GetDirectoryFileSize(enum pack_file_id pack_id, uint32_t file_index); +uint32_t DirectoryFileMngr_LoadDirectoryFile(enum pack_file_id pack_id, uint32_t file_index, + void* output_buffer); +void DirectoryFileMngr_OpenDirectoryFile(enum pack_file_id pack_id, uint32_t file_index, + struct pack_alloc_and_load_result* output, + uint32_t malloc_flags); +void DirectoryFile_ExtractDirectoryFile(struct pack_file_opened* pack_file, const char* file_name); +uint32_t DirectoryFile_GetDirectoryFileSize(struct pack_file_opened* pack_file, + uint32_t file_index); +uint32_t DirectoryFile_LoadDirectoryFile(struct pack_file_opened* pack_file, void* output_buffer, + uint32_t file_index); void GetDungeonResultMsg(union damage_source damage_source_or_result, char* buffer, int buffer_size, undefined* param_4); union damage_source GetDamageSource(enum move_id, enum item_id); diff --git a/headers/types/common/file_io.h b/headers/types/common/file_io.h index 8ecbd33a..9c0cdfc7 100644 --- a/headers/types/common/file_io.h +++ b/headers/types/common/file_io.h @@ -65,7 +65,7 @@ struct pack_file_opened { }; ASSERT_SIZE(struct pack_file_opened, 84); -// Data to return result of the AllocAndLoadFileInPack function +// Data to return result of the DirectoryFileMngr_OpenDirectoryFile function struct pack_alloc_and_load_result { void* data; uint32_t length; diff --git a/symbols/arm9.yml b/symbols/arm9.yml index c3e27a2b..5d8ac6dc 100644 --- a/symbols/arm9.yml +++ b/symbols/arm9.yml @@ -902,7 +902,7 @@ arm9: Implements (most of?) SPECIAL_PROC_KEY_WAIT_INIT (see ScriptSpecialProcessCall). No params. - - name: DataTransferInit + - name: FileRom_InitDataTransfer address: EU: 0x2008168 NA: 0x2008168 @@ -911,7 +911,7 @@ arm9: Initializes data transfer mode to get data from the ROM cartridge. No params. - - name: DataTransferStop + - name: FileRom_StopDataTransfer address: EU: 0x2008194 NA: 0x2008194 @@ -919,10 +919,10 @@ arm9: description: |- Finalizes data transfer from the ROM cartridge. - This function must always be called if DataTransferInit was called, or the game will crash. + This function must always be called if FileRom_InitDataTransfer was called, or the game will crash. No params. - - name: FileInitVeneer + - name: FileRom_Veneer_FileInit address: EU: 0x2008204 NA: 0x2008204 @@ -933,7 +933,7 @@ arm9: See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer- r0: file_stream pointer - - name: FileOpen + - name: FileRom_HandleOpen address: EU: 0x2008210 NA: 0x2008210 @@ -953,7 +953,7 @@ arm9: r0: file_stream pointer return: file size - - name: FileRead + - name: FileRom_HandleRead address: EU: 0x2008254 NA: 0x2008254 @@ -961,15 +961,15 @@ arm9: description: |- Reads the contents of a file into the given buffer, and moves the file cursor accordingly. - Data transfer mode must have been initialized (with DataTransferInit) prior to calling this function. This function looks like it's doing something akin to calling read(2) or fread(3) in a loop until all the bytes have been successfully read. + Data transfer mode must have been initialized (with FileRom_InitDataTransfer) prior to calling this function. This function looks like it's doing something akin to calling read(2) or fread(3) in a loop until all the bytes have been successfully read. - Note: If code is running from IRQ mode, it appears that FileRead hangs the game. When the processor mode is forced into SYSTEM mode FileRead once again works, so it appears that ROM access only works in certain processor modes. Note that forcing the processor into a different mode is generally a bad idea and should be avoided as it will easily corrupt that processor mode's states. + Note: If code is running from IRQ mode, it appears that FileRom_HandleRead hangs the game. When the processor mode is forced into SYSTEM mode FileRom_HandleRead once again works, so it appears that ROM access only works in certain processor modes. Note that forcing the processor into a different mode is generally a bad idea and should be avoided as it will easily corrupt that processor mode's states. r0: file_stream pointer r1: [output] buffer r2: number of bytes to read return: number of bytes read - - name: FileSeek + - name: FileRom_HandleSeek address: EU: 0x20082A8 NA: 0x20082A8 @@ -993,7 +993,7 @@ arm9: description: |- Closes a file. - Data transfer mode must have been initialized (with DataTransferInit) prior to calling this function. + Data transfer mode must have been initialized (with FileRom_InitDataTransfer) prior to calling this function. Note: It is possible to keep a file stream open even if data transfer mode has been stopped, in which case the file stream can be used again if data transfer mode is reinitialized. @@ -1050,7 +1050,7 @@ arm9: r0: screen_fade return: int - - name: InitDebug + - name: Debug_Init address: EU: 0x200C15C NA: 0x200C0D4 @@ -1058,7 +1058,7 @@ arm9: description: |- Would have initialized debugging-related things, if they were not removed. As for the release version, does nothing but set DEBUG_IS_INITIALIZED to true. - - name: InitDebugFlag + - name: Debug_InitDebugFlag address: EU: 0x200C194 NA: 0x200C10C @@ -1066,7 +1066,7 @@ arm9: description: |- Would have initialized the debug flags. Does nothing in release binary. - - name: GetDebugFlag + - name: Debug_GetDebugFlag address: EU: 0x200C198 NA: 0x200C110 @@ -1076,7 +1076,7 @@ arm9: r0: flag ID return: flag value - - name: SetDebugFlag + - name: Debug_SetDebugFlag address: EU: 0x200C1A0 NA: 0x200C118 @@ -1086,7 +1086,7 @@ arm9: r0: flag ID r1: flag value - - name: InitDebugStripped6 + - name: Debug_Stripped6 address: EU: 0x200C1A4 NA: 0x200C11C @@ -1106,13 +1106,13 @@ arm9: r1: program position info r2: base message return: number of characters printed, excluding the null-terminator - - name: InitDebugStripped5 + - name: Debug_Stripped5 address: EU: 0x200C1F0 NA: 0x200C168 JP: 0x200C168 description: "Does nothing, only called in the debug initialization function." - - name: DebugPrintTrace + - name: Debug_PrintTrace address: EU: 0x200C1F4 NA: 0x200C16C @@ -1139,11 +1139,11 @@ arm9: This still constructs the string with vsprintf, but doesn't actually do anything with it in the final binary. - Identical to DebugPrint0 in release builds. + Identical to Debug_Print0 in release builds. r0: format ...: variadic - - name: DebugPrint0 + - name: Debug_Print0 address: EU: - 0x200C284 @@ -1160,7 +1160,7 @@ arm9: r0: format ...: variadic - - name: InitDebugLogFlag + - name: Debug_InitLogFlag address: EU: 0x200C2B8 NA: 0x200C230 @@ -1168,7 +1168,7 @@ arm9: description: |- Would have initialized the debug log flags. Does nothing in release binary. - - name: GetDebugLogFlag + - name: Debug_GetLogFlag address: EU: 0x200C2BC NA: 0x200C234 @@ -1178,7 +1178,7 @@ arm9: r0: flag ID return: flag value - - name: SetDebugLogFlag + - name: Debug_SetLogFlag address: EU: 0x200C2C4 NA: 0x200C23C @@ -1188,7 +1188,7 @@ arm9: r0: flag ID r1: flag value - - name: DebugPrint + - name: Debug_Print address: EU: 0x200C2C8 NA: 0x200C240 @@ -1199,31 +1199,31 @@ arm9: r0: log level r1: format ...: variadic - - name: InitDebugStripped4 + - name: Debug_Stripped4 address: EU: 0x200C2D4 NA: 0x200C24C JP: 0x200C24C description: "Does nothing, only called in the debug initialization function." - - name: InitDebugStripped3 + - name: Debug_Stripped3 address: EU: 0x200C2D8 NA: 0x200C250 JP: 0x200C250 description: "Does nothing, only called in the debug initialization function." - - name: InitDebugStripped2 + - name: Debug_Stripped2 address: EU: 0x200C2DC NA: 0x200C254 JP: 0x200C254 description: "Does nothing, only called in the debug initialization function." - - name: InitDebugStripped1 + - name: Debug_Stripped1 address: EU: 0x200C2E0 NA: 0x200C258 JP: 0x200C258 description: "Does nothing, only called in the debug initialization function." - - name: FatalError + - name: Debug_FatalError address: EU: 0x200C2E4 NA: 0x200C25C @@ -1236,39 +1236,39 @@ arm9: r0: program position info r1: format ...: variadic - - name: OpenAllPackFiles + - name: DirectoryFileMngr_ExtractAllDirectoryFiles address: EU: 0x200C364 NA: 0x200C2DC JP: 0x200C2DC description: |- - Open the 6 files at PACK_FILE_PATHS_TABLE into PACK_FILES_OPENED. Called during game initialization. + Open the 6 files at DIRECTORY_FILE_TABLE into DIRECTORY_FILES_EXTRACTED. Called during game initialization. No params. - - name: GetFileLengthInPackWithPackNb + - name: DirectoryFileMngr_GetDirectoryFileSize address: EU: 0x200C3C4 NA: 0x200C33C JP: 0x200C33C description: |- - Call GetFileLengthInPack after looking up the global Pack archive by its number + Call DirectoryFile_GetDirectoryFileSize after looking up the global Pack archive by its number r0: pack file number r1: file number return: size of the file in bytes from the Pack Table of Content - - name: LoadFileInPackWithPackId + - name: DirectoryFileMngr_LoadDirectoryFile address: EU: 0x200C3E4 NA: 0x200C35C JP: 0x200C35C description: |- - Call LoadFileInPack after looking up the global Pack archive by its identifier + Call DirectoryFile_LoadDirectoryFile after looking up the global Pack archive by its identifier r0: pack file identifier r1: file index r2: [output] target buffer return: number of read bytes (identical to the length of the pack from the Table of Content) - - name: AllocAndLoadFileInPack + - name: DirectoryFileMngr_OpenDirectoryFile address: EU: 0x200C410 NA: 0x200C388 @@ -1281,7 +1281,7 @@ arm9: r1: file index r2: [output] result struct (will contain length and pointer) r3: allocation flags - - name: OpenPackFile + - name: DirectoryFile_ExtractDirectoryFile address: EU: 0x200C468 NA: 0x200C3E0 @@ -1291,7 +1291,7 @@ arm9: r0: [output] pack file struct r1: file name - - name: GetFileLengthInPack + - name: DirectoryFile_GetDirectoryFileSize address: EU: 0x200C4FC NA: 0x200C474 @@ -1302,7 +1302,7 @@ arm9: r0: pack file struct r1: file index return: size of the file in bytes from the Pack Table of Content - - name: LoadFileInPack + - name: DirectoryFile_LoadDirectoryFile address: EU: 0x200C50C NA: 0x200C484 @@ -9750,7 +9750,7 @@ arm9: Checks if a mission contains valid fields. For example, a mission will be considered invalid if the ID of the monsters or items involved are out of bounds, if their entries are marked as invalid, if the destination floor does not exist, etc. - If the mission fails one of the checks, the game will print an error message explaining what is wrong using DebugPrint0. + If the mission fails one of the checks, the game will print an error message explaining what is wrong using Debug_Print0. r0: mission to check return: True if the mission is valid, false if it's not. @@ -14069,7 +14069,7 @@ arm9: NA: 0x20AF698 length: NA: 0x1 - - name: PACK_FILES_OPENED + - name: DIRECTORY_FILES_EXTRACTED address: EU: 0x20AFF54 NA: 0x20AF69C @@ -14077,10 +14077,10 @@ arm9: EU: 0x4 NA: 0x4 description: |- - [Runtime] A pointer to the 6 opened Pack files (listed at PACK_FILE_PATHS_TABLE) + [Runtime] A pointer to the 6 opened Pack files (listed at DIRECTORY_FILE_TABLE) type: struct pack_file_opened* - - name: PACK_FILE_PATHS_TABLE + - name: DIRECTORY_FILE_TABLE address: EU: 0x20AFF58 NA: 0x20AF6A0 diff --git a/symbols/overlay10.yml b/symbols/overlay10.yml index 1d78acac..d96d17e7 100644 --- a/symbols/overlay10.yml +++ b/symbols/overlay10.yml @@ -293,7 +293,7 @@ overlay10: description: |- Initializes a buffer that contains data related to tilesets (such as dungeon::unknown_file_buffer_0x102A8). - Calls AllocAndLoadFileInPack and DecompressAtNormalVeneer. + Calls DirectoryFileMngr_OpenDirectoryFile and DecompressAtNormalVeneer. r0: Pointer to the buffer to init r1: Tileset ID