From 3c458e8b4893866639734a572a7d8e5ce6c7c1ce Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 5 May 2020 20:13:17 -0400 Subject: Decompile GF funcs responsible for overlays --- arm9/lib/include/FS_file.h | 164 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 arm9/lib/include/FS_file.h (limited to 'arm9/lib/include/FS_file.h') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h new file mode 100644 index 00000000..08a698d0 --- /dev/null +++ b/arm9/lib/include/FS_file.h @@ -0,0 +1,164 @@ +#ifndef NITRO_FS_FILE_H_ +#define NITRO_FS_FILE_H_ + +#include "nitro.h" + +#include "FS_archive.h" + +struct FSFile; + +#define FS_DMA_NOT_USE ((u32)~0) + +typedef struct FSDirPos +{ + struct FSArchive *arc; + u16 own_id; + u16 index; + u32 pos; +} +FSDirPos; + +typedef struct FSFileID +{ + struct FSArchive *arc; + u32 file_id; +} +FSFileID; + +typedef struct +{ + union + { + FSFileID file_id; + FSDirPos dir_id; + }; + u32 is_directory; + u32 name_len; + char name[128]; +} +FSDirEntry; + + +typedef struct +{ + FSDirPos pos; +} +FSSeekDirInfo; + + +typedef struct +{ + FSDirEntry *p_entry; + BOOL skip_string; +} +FSReadDirInfo; + + +typedef struct +{ + FSDirPos pos; + const char *path; + BOOL find_directory; + union + { + FSFileID *file; + FSDirPos *dir; + } + result; +} +FSFindPathInfo; + + +typedef struct +{ + u8 *buf; + u32 buf_len; + u16 total_len; + u16 dir_id; +} +FSGetPathInfo; + + +typedef struct +{ + FSFileID id; +} +FSOpenFileFastInfo; + + +typedef struct +{ + u32 top; + u32 bottom; + u32 index; +} +FSOpenFileDirectInfo; + + +typedef struct +{ + u32 reserved; +} +FSCloseFileInfo; + + +typedef struct +{ + void *dst; + u32 len_org; + u32 len; +} +FSReadFileInfo; + + +typedef struct +{ + const void *src; + u32 len_org; + u32 len; +} +FSWriteFileInfo; + +typedef struct FSFile +{ + FSFileLink link; + struct FSArchive *arc; + u32 stat; + FSCommandType command; + FSResult error; + OSThreadQueue queue[1]; + u32 filler; // Figure out what this actually is + union { + struct + { + u32 own_id; + u32 top; + u32 bottom; + u32 pos; + } file; + struct + { + FSDirPos pos; + u32 parent; + } dir; + } prop; + + union { + FSReadFileInfo readfile; + FSWriteFileInfo writefile; + + FSSeekDirInfo seekdir; + FSReadDirInfo readdir; + FSFindPathInfo findpath; + FSGetPathInfo getpath; + FSOpenFileFastInfo openfilefast; + FSOpenFileDirectInfo openfiledirect; + FSCloseFileInfo closefile; + }; +} +FSFile; + +u32 FS_SetDefaultDMA(u32 dma_no); // returns the previous selection +void FS_InitFile(FSFile * p_file); + +#endif //NITRO_FS_FILE_H_ -- cgit v1.2.3 From cd5559a2093c2be1167eba2f2ef38eedb32a8a1d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 5 May 2020 21:59:23 -0400 Subject: Decompile FS_file.c --- arm9/lib/include/FS_file.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'arm9/lib/include/FS_file.h') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 08a698d0..4871b660 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -5,6 +5,21 @@ #include "FS_archive.h" +#define FS_FILE_STATUS_BUSY 0x00000001 +#define FS_FILE_STATUS_CANCEL 0x00000002 +#define FS_FILE_STATUS_SYNC 0x00000004 +#define FS_FILE_STATUS_ASYNC 0x00000008 +#define FS_FILE_STATUS_IS_FILE 0x00000010 +#define FS_FILE_STATUS_IS_DIR 0x00000020 +#define FS_FILE_STATUS_OPERATING 0x00000040 + +typedef enum FSSeekFileMode +{ + FS_SEEK_SET = 0, + FS_SEEK_CUR, + FS_SEEK_END +} FSSeekFileMode; + struct FSFile; #define FS_DMA_NOT_USE ((u32)~0) @@ -127,7 +142,6 @@ typedef struct FSFile FSCommandType command; FSResult error; OSThreadQueue queue[1]; - u32 filler; // Figure out what this actually is union { struct { @@ -154,11 +168,12 @@ typedef struct FSFile FSOpenFileFastInfo openfilefast; FSOpenFileDirectInfo openfiledirect; FSCloseFileInfo closefile; - }; + } arg; } FSFile; u32 FS_SetDefaultDMA(u32 dma_no); // returns the previous selection void FS_InitFile(FSFile * p_file); +BOOL FS_WaitAsync(FSFile * p_file); #endif //NITRO_FS_FILE_H_ -- cgit v1.2.3 From 9f3c697d9dee85da8c9bf4f708a340d5023194ec Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 May 2020 18:14:26 -0400 Subject: FS_overlay.c --- arm9/lib/include/FS_file.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'arm9/lib/include/FS_file.h') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 4871b660..89f69d86 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -175,5 +175,18 @@ FSFile; u32 FS_SetDefaultDMA(u32 dma_no); // returns the previous selection void FS_InitFile(FSFile * p_file); BOOL FS_WaitAsync(FSFile * p_file); +BOOL FS_OpenFileDirect(FSFile * p_file, FSArchive * p_arc, u32 image_top, u32 image_bottom, u32 file_index); +int FS_ReadFile(FSFile * p_file, void * dst, s32 len); +int FS_ReadFileAsync(FSFile * p_file, void * dst, s32 len); +BOOL FS_OpenFileFast(FSFile * p_file, FSFileID file_id); + +static inline u32 const FS_GetFileImageTop(volatile const FSFile * p_file) { + return p_file->prop.file.top; +} + +static inline u32 const FS_GetLength(volatile const FSFile * p_file) +{ + return p_file->prop.file.bottom - p_file->prop.file.top; +} #endif //NITRO_FS_FILE_H_ -- cgit v1.2.3 From d4575098dbd671e2b6fd27ad65b984502c90465b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 May 2020 08:52:32 -0400 Subject: FS_archive.c WIP --- arm9/lib/include/FS_file.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'arm9/lib/include/FS_file.h') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 89f69d86..92e2149e 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -189,4 +189,24 @@ static inline u32 const FS_GetLength(volatile const FSFile * p_file) return p_file->prop.file.bottom - p_file->prop.file.top; } +static inline BOOL FS_IsCanceling(volatile const FSFile * p_file) +{ + return (p_file->stat & FS_FILE_STATUS_CANCEL) ? TRUE : FALSE; +} + +static inline BOOL FS_IsFileSyncMode(volatile const FSFile * p_file) +{ + return (p_file->stat & FS_FILE_STATUS_SYNC) ? TRUE : FALSE; +} + +static inline BOOL FS_IsBusy(volatile const FSFile * p_file) +{ + return p_file->stat & FS_FILE_STATUS_BUSY ? TRUE : FALSE; +} + +static inline BOOL FS_IsSucceeded(volatile const FSFile * p_file) +{ + return (p_file->error == FS_RESULT_SUCCESS) ? TRUE : FALSE; +} + #endif //NITRO_FS_FILE_H_ -- cgit v1.2.3 From 34ec05f983cec0517765640d084f58e86aa20d79 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 May 2020 17:53:16 -0400 Subject: Finish FS_archive.c --- arm9/lib/include/FS_file.h | 1 + 1 file changed, 1 insertion(+) (limited to 'arm9/lib/include/FS_file.h') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 92e2149e..fdf6c4e2 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -179,6 +179,7 @@ BOOL FS_OpenFileDirect(FSFile * p_file, FSArchive * p_arc, u32 image_top, u32 im int FS_ReadFile(FSFile * p_file, void * dst, s32 len); int FS_ReadFileAsync(FSFile * p_file, void * dst, s32 len); BOOL FS_OpenFileFast(FSFile * p_file, FSFileID file_id); +BOOL FS_CloseFile(FSFile * p_file); static inline u32 const FS_GetFileImageTop(volatile const FSFile * p_file) { return p_file->prop.file.top; -- cgit v1.2.3 From 1966623ed0516e84d8129e8f22dba502b018bcc3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 May 2020 08:35:17 -0400 Subject: Finish FS_command_default.c --- arm9/lib/include/FS_file.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'arm9/lib/include/FS_file.h') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index fdf6c4e2..55825c61 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -13,6 +13,8 @@ #define FS_FILE_STATUS_IS_DIR 0x00000020 #define FS_FILE_STATUS_OPERATING 0x00000040 +#define FS_FILE_NAME_MAX 127 + typedef enum FSSeekFileMode { FS_SEEK_SET = 0, @@ -210,4 +212,9 @@ static inline BOOL FS_IsSucceeded(volatile const FSFile * p_file) return (p_file->error == FS_RESULT_SUCCESS) ? TRUE : FALSE; } +static inline BOOL FS_IsDir(volatile const FSFile * p_file) +{ + return (p_file->stat & FS_FILE_STATUS_IS_DIR) ? TRUE : FALSE; +} + #endif //NITRO_FS_FILE_H_ -- cgit v1.2.3 From d3bd9a77bb8ca065d295911aca7fbd2da4a846f5 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 May 2020 11:52:42 -0400 Subject: Some prototypes in FS_file.h --- arm9/lib/include/FS_file.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arm9/lib/include/FS_file.h') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 55825c61..9857a40c 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -180,8 +180,10 @@ BOOL FS_WaitAsync(FSFile * p_file); BOOL FS_OpenFileDirect(FSFile * p_file, FSArchive * p_arc, u32 image_top, u32 image_bottom, u32 file_index); int FS_ReadFile(FSFile * p_file, void * dst, s32 len); int FS_ReadFileAsync(FSFile * p_file, void * dst, s32 len); +BOOL FS_OpenFile(FSFile * p_file, const char * path); BOOL FS_OpenFileFast(FSFile * p_file, FSFileID file_id); BOOL FS_CloseFile(FSFile * p_file); +BOOL FS_SeekFile(FSFile * p_file, int offset, FSSeekFileMode origin); static inline u32 const FS_GetFileImageTop(volatile const FSFile * p_file) { return p_file->prop.file.top; -- cgit v1.2.3 From b398a161f324f88a4d4c8682eb15c63a62753a43 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 May 2020 19:39:43 -0400 Subject: Fix style inconsistencies --- arm9/lib/include/FS_file.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'arm9/lib/include/FS_file.h') diff --git a/arm9/lib/include/FS_file.h b/arm9/lib/include/FS_file.h index 9857a40c..3a7d8730 100644 --- a/arm9/lib/include/FS_file.h +++ b/arm9/lib/include/FS_file.h @@ -5,13 +5,13 @@ #include "FS_archive.h" -#define FS_FILE_STATUS_BUSY 0x00000001 -#define FS_FILE_STATUS_CANCEL 0x00000002 -#define FS_FILE_STATUS_SYNC 0x00000004 -#define FS_FILE_STATUS_ASYNC 0x00000008 -#define FS_FILE_STATUS_IS_FILE 0x00000010 -#define FS_FILE_STATUS_IS_DIR 0x00000020 -#define FS_FILE_STATUS_OPERATING 0x00000040 +#define FS_FILE_STATUS_BUSY 0x00000001 +#define FS_FILE_STATUS_CANCEL 0x00000002 +#define FS_FILE_STATUS_SYNC 0x00000004 +#define FS_FILE_STATUS_ASYNC 0x00000008 +#define FS_FILE_STATUS_IS_FILE 0x00000010 +#define FS_FILE_STATUS_IS_DIR 0x00000020 +#define FS_FILE_STATUS_OPERATING 0x00000040 #define FS_FILE_NAME_MAX 127 @@ -81,7 +81,7 @@ typedef struct FSFileID *file; FSDirPos *dir; } - result; + result; } FSFindPathInfo; -- cgit v1.2.3