diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2020-05-05 20:13:17 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2020-05-05 20:13:17 -0400 |
commit | 3c458e8b4893866639734a572a7d8e5ce6c7c1ce (patch) | |
tree | 52fccbceefc204ab6350c1a1412f167ea007fffe /arm9/lib | |
parent | 6071299191b3386f1d266a25ec6b49af2c2beda5 (diff) |
Decompile GF funcs responsible for overlays
Diffstat (limited to 'arm9/lib')
-rw-r--r-- | arm9/lib/include/CARD_rom.h | 11 | ||||
-rw-r--r-- | arm9/lib/include/FS_archive.h | 90 | ||||
-rw-r--r-- | arm9/lib/include/FS_file.h | 164 | ||||
-rw-r--r-- | arm9/lib/include/FS_overlay.h | 42 | ||||
-rw-r--r-- | arm9/lib/include/MI_exMemory.h | 9 | ||||
-rw-r--r-- | arm9/lib/include/OS_system.h | 1 | ||||
-rw-r--r-- | arm9/lib/include/OS_thread.h | 8 | ||||
-rw-r--r-- | arm9/lib/include/mmap.h | 2 | ||||
-rw-r--r-- | arm9/lib/include/mmap_global.h | 4 |
9 files changed, 331 insertions, 0 deletions
diff --git a/arm9/lib/include/CARD_rom.h b/arm9/lib/include/CARD_rom.h new file mode 100644 index 00000000..327bc995 --- /dev/null +++ b/arm9/lib/include/CARD_rom.h @@ -0,0 +1,11 @@ +#ifndef NITRO_CARD_ROM_H_ +#define NITRO_CARD_ROM_H_ + +typedef struct +{ + u32 offset; + u32 length; +} +CARDRomRegion; + +#endif //NITRO_CARD_ROM_H_ diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h new file mode 100644 index 00000000..65bb2ea1 --- /dev/null +++ b/arm9/lib/include/FS_archive.h @@ -0,0 +1,90 @@ +#ifndef NITRO_FS_ARCHIVE_H_ +#define NITRO_FS_ARCHIVE_H_ + +#include "nitro.h" + +#include "OS_thread.h" + +struct FSFile; +struct FSArchive; + +typedef enum { + FS_COMMAND_ASYNC_BEGIN = 0, + FS_COMMAND_READFILE = FS_COMMAND_ASYNC_BEGIN, + FS_COMMAND_WRITEFILE, + FS_COMMAND_ASYNC_END, + + FS_COMMAND_SYNC_BEGIN = FS_COMMAND_ASYNC_END, + FS_COMMAND_SEEKDIR = FS_COMMAND_SYNC_BEGIN, + FS_COMMAND_READDIR, + FS_COMMAND_FINDPATH, + FS_COMMAND_GETPATH, + FS_COMMAND_OPENFILEFAST, + FS_COMMAND_OPENFILEDIRECT, + FS_COMMAND_CLOSEFILE, + FS_COMMAND_SYNC_END, + + FS_COMMAND_STATUS_BEGIN = FS_COMMAND_SYNC_END, + FS_COMMAND_ACTIVATE = FS_COMMAND_STATUS_BEGIN, + FS_COMMAND_IDLE, + FS_COMMAND_SUSPEND, + FS_COMMAND_RESUME, + FS_COMMAND_STATUS_END, + + FS_COMMAND_INVALID +} FSCommandType; + +typedef enum { + FS_RESULT_SUCCESS = 0, + FS_RESULT_FAILURE, + FS_RESULT_BUSY, + FS_RESULT_CANCELED, + FS_RESULT_CANCELLED = FS_RESULT_CANCELED, // SDK alias + FS_RESULT_UNSUPPORTED, + FS_RESULT_ERROR, + FS_RESULT_PROC_ASYNC, + FS_RESULT_PROC_DEFAULT, + FS_RESULT_PROC_UNKNOWN +} +FSResult; + +typedef FSResult (*FS_ARCHIVE_READ_FUNC) (struct FSArchive *p, void *dst, u32 pos, u32 size); +typedef FSResult (*FS_ARCHIVE_WRITE_FUNC) (struct FSArchive *p, const void *src, u32 pos, u32 size); +typedef FSResult (*FS_ARCHIVE_PROC_FUNC) (struct FSFile *, FSCommandType); + +typedef struct +{ + struct FSFile * prev; + struct FSFile * next; +} +FSFileLink; + +typedef struct FSArchive +{ + union + { + char ptr[4]; + u32 pack; + } name; + struct FSArchive * prev; + struct FSArchive * next; + OSThreadQueue sync_q; + OSThreadQueue stat_q; + u32 flag; + FSFileLink list; + u32 base; + u32 fat; + u32 fat_size; + u32 fnt; + u32 fnt_size; + u32 fat_bak; + u32 fnt_bak; + void * load_mem; + FS_ARCHIVE_READ_FUNC read_func; + FS_ARCHIVE_WRITE_FUNC write_func; + FS_ARCHIVE_READ_FUNC table_func; + FS_ARCHIVE_PROC_FUNC proc; + u32 proc_flag; +} FSArchive; + +#endif //NITRO_FS_ARCHIVE_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_ diff --git a/arm9/lib/include/FS_overlay.h b/arm9/lib/include/FS_overlay.h new file mode 100644 index 00000000..967169aa --- /dev/null +++ b/arm9/lib/include/FS_overlay.h @@ -0,0 +1,42 @@ +#ifndef NITRO_FS_OVERLAY_H_ +#define NITRO_FS_OVERLAY_H_ + +#include "nitro.h" +#include "MI_exMemory.h" +#include "FS_file.h" +#include "CARD_rom.h" + +typedef u32 FSOverlayID; + +typedef void (*FSOverlayInitFunc) (void); + +typedef struct FSOverlayInfoHeader +{ + u32 id; + u8 *ram_address; + u32 ram_size; + u32 bss_size; + FSOverlayInitFunc *sinit_init; + FSOverlayInitFunc *sinit_init_end; + u32 file_id; + u32 compressed:24; + u32 flag:8; +} FSOverlayInfoHeader; + +typedef struct FSOverlayInfo +{ + FSOverlayInfoHeader header; + MIProcessor target; + CARDRomRegion file_pos; +} FSOverlayInfo; + +BOOL FS_LoadOverlayInfo(FSOverlayInfo *p_ovi, MIProcessor target, FSOverlayID id); +BOOL FS_LoadOverlay(MIProcessor target, FSOverlayID id); +BOOL FS_UnloadOverlay(MIProcessor target, FSOverlayID id); +BOOL FS_LoadOverlayImage(FSOverlayInfo *p_ovi); +void FS_StartOverlay(FSOverlayInfo *p_ovi); +BOOL FS_LoadOverlayImageAsync(FSOverlayInfo *p_ovi, FSFile *p_file); +void FS_WaitAsync(FSFile *p_file); +void FS_CloseFile(FSFile *p_file); + +#endif //NITRO_FS_OVERLAY_H_ diff --git a/arm9/lib/include/MI_exMemory.h b/arm9/lib/include/MI_exMemory.h new file mode 100644 index 00000000..4a8a10a8 --- /dev/null +++ b/arm9/lib/include/MI_exMemory.h @@ -0,0 +1,9 @@ +#ifndef NITRO_MI_EXMEMORY_H_ +#define NITRO_MI_EXMEMORY_H_ + +typedef enum { + MI_PROCESSOR_ARM9 = 0, + MI_PROCESSOR_ARM7 = 1 +} MIProcessor; + +#endif //NITRO_MI_EXMEMORY_H_ diff --git a/arm9/lib/include/OS_system.h b/arm9/lib/include/OS_system.h index 93903315..794e16d2 100644 --- a/arm9/lib/include/OS_system.h +++ b/arm9/lib/include/OS_system.h @@ -5,6 +5,7 @@ #ifndef POKEDIAMOND_OS_SYSTEM_H #define POKEDIAMOND_OS_SYSTEM_H +#include "function_target.h" #include "consts.h" typedef enum { diff --git a/arm9/lib/include/OS_thread.h b/arm9/lib/include/OS_thread.h index 4fb70bf7..207dac1b 100644 --- a/arm9/lib/include/OS_thread.h +++ b/arm9/lib/include/OS_thread.h @@ -7,6 +7,14 @@ typedef struct _OSThread OSThread; +struct _OSThreadQueue +{ + OSThread *head; + OSThread *tail; +}; + +typedef struct _OSThreadQueue OSThreadQueue; + typedef struct OSThreadInfo { u16 isNeedRescheduling; u16 irqDepth; diff --git a/arm9/lib/include/mmap.h b/arm9/lib/include/mmap.h index d94df843..56ae08c8 100644 --- a/arm9/lib/include/mmap.h +++ b/arm9/lib/include/mmap.h @@ -12,8 +12,10 @@ extern u32 SDK_AUTOLOAD_DTCM_START[]; #define HW_MAIN_MEM_SHARED_SIZE 0x00001000 #define HW_MAIN_MEM_DEBUGGER_OFFSET 0x00700000 +#define HW_ITCM_IMAGE 0x01000000 #define HW_ITCM 0x01FF8000 #define HW_ITCM_SIZE 0x00008000 +#define HW_ITCM_END (HW_ITCM + HW_ITCM_SIZE) #define HW_WRAM 0x037F8000 diff --git a/arm9/lib/include/mmap_global.h b/arm9/lib/include/mmap_global.h new file mode 100644 index 00000000..e657e46f --- /dev/null +++ b/arm9/lib/include/mmap_global.h @@ -0,0 +1,4 @@ +#ifndef NITRO_MMAP_GLOBAL_H_ +#define NITRO_MMAP_GLOBAL_H_ + +#endif //NITRO_MMAP_GLOBAL_H_ |