diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2020-05-07 17:53:16 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2020-05-07 17:53:16 -0400 |
commit | 34ec05f983cec0517765640d084f58e86aa20d79 (patch) | |
tree | e07f5b2f882f1c498093d4fc936975f9e90ed5f6 /arm9 | |
parent | 13ecb2f5cb0bbfee814508f6d05d05074d426807 (diff) |
Finish FS_archive.c
Diffstat (limited to 'arm9')
-rw-r--r-- | arm9/arm9.lcf | 1 | ||||
-rw-r--r-- | arm9/asm/FS_archive.asm.s | 330 | ||||
-rw-r--r-- | arm9/asm/FS_rom.s | 4 | ||||
-rw-r--r-- | arm9/global.inc | 4 | ||||
-rw-r--r-- | arm9/lib/include/FS_archive.h | 12 | ||||
-rw-r--r-- | arm9/lib/include/FS_file.h | 1 | ||||
-rw-r--r-- | arm9/lib/include/FS_overlay.h | 13 | ||||
-rw-r--r-- | arm9/lib/include/FSi_util.h | 4 | ||||
-rw-r--r-- | arm9/lib/include/OS_system.h | 6 | ||||
-rw-r--r-- | arm9/lib/src/FS_archive.c | 163 | ||||
-rw-r--r-- | arm9/modules/13/asm/module_13_arm2.s | 6 |
11 files changed, 193 insertions, 351 deletions
diff --git a/arm9/arm9.lcf b/arm9/arm9.lcf index 9476f69c..c7342b57 100644 --- a/arm9/arm9.lcf +++ b/arm9/arm9.lcf @@ -203,7 +203,6 @@ SECTIONS { PXI_fifo.o (.text) FS_command.o (.text) FS_command_default.o (.text) - FS_archive.asm.o (.text) FS_archive.o (.text) FS_file.o (.text) FS_rom.o (.text) diff --git a/arm9/asm/FS_archive.asm.s b/arm9/asm/FS_archive.asm.s deleted file mode 100644 index ac647d7e..00000000 --- a/arm9/asm/FS_archive.asm.s +++ /dev/null @@ -1,330 +0,0 @@ - .include "asm/macros.inc" - .include "global.inc" - .section .text - - .extern FSi_GetPackedName - .extern FSi_ReadMemCallback - .extern FSi_WriteMemCallback - .extern FSi_ReadMemoryCore - .extern FSi_NextCommand - .extern FSi_ExecuteAsyncCommand - .extern FSi_ExecuteSyncCommand - .extern FSi_SendCommand - .extern FS_InitArchive - .extern FS_FindArchive - .extern FS_RegisterArchiveName - .extern FS_ReleaseArchiveName - .extern FS_LoadArchive - - arm_func_start FS_NotifyArchiveAsyncEnd -FS_NotifyArchiveAsyncEnd: ; 0x020D0B40 - stmdb sp!, {r4-r6,lr} - mov r4, r0 - ldr r0, [r4, #0x1c] - mov r6, r1 - ands r0, r0, #0x100 - beq _020D0B8C - ldr r2, [r4, #0x1c] - ldr r0, [r4, #0x24] - bic r2, r2, #0x100 - str r2, [r4, #0x1c] - bl FSi_ReleaseCommand - mov r0, r4 - bl FSi_NextCommand -_020D0B74: - cmp r0, #0x0 - ldmeqia sp!, {r4-r6,lr} - bxeq lr - bl FSi_ExecuteAsyncCommand - ldmia sp!, {r4-r6,lr} - bx lr -_020D0B8C: - ldr r5, [r4, #0x24] - bl OS_DisableInterrupts - str r6, [r5, #0x14] - ldr r1, [r4, #0x1c] - mov r5, r0 - bic r1, r1, #0x200 - add r0, r4, #0xc - str r1, [r4, #0x1c] - bl OS_WakeupThread - mov r0, r5 - bl OS_RestoreInterrupts - ldmia sp!, {r4-r6,lr} - bx lr - - arm_func_start FS_SetArchiveProc -FS_SetArchiveProc: ; 0x020D0BC0 - cmp r2, #0x0 - moveq r1, #0x0 - beq _020D0BD4 - cmp r1, #0x0 - moveq r2, #0x0 -_020D0BD4: - str r1, [r0, #0x54] - str r2, [r0, #0x58] - bx lr - - arm_func_start FS_ResumeArchive -FS_ResumeArchive: - stmdb sp!, {r4-r7,lr} - sub sp, sp, #0x4 - mov r4, r0 - mov r6, #0x0 - bl OS_DisableInterrupts - ldr r1, [r4, #0x1c] - mov r5, r0 - ands r0, r1, #0x8 - movne r0, #0x1 - moveq r0, r6 - cmp r0, #0x0 - moveq r7, #0x1 - movne r7, #0x0 - cmp r7, #0x0 - bne _020D0C34 - ldr r1, [r4, #0x1c] - mov r0, r4 - bic r1, r1, #0x8 - str r1, [r4, #0x1c] - bl FSi_NextCommand - mov r6, r0 -_020D0C34: - mov r0, r5 - bl OS_RestoreInterrupts -_020D0C3C: - cmp r6, #0x0 - beq _020D0C4C - mov r0, r6 - bl FSi_ExecuteAsyncCommand -_020D0C4C: - mov r0, r7 - add sp, sp, #0x4 - ldmia sp!, {r4-r7, lr} - bx lr - - arm_func_start FS_SuspendArchive -FS_SuspendArchive: ; 0x020D0C5C - stmdb sp!, {r4-r7,lr} - sub sp, sp, #0x4 - mov r6, r0 - bl OS_DisableInterrupts - ldr r1, [r6, #0x1c] - mov r4, r0 - ands r0, r1, #0x8 - movne r0, #0x1 - moveq r0, #0x0 - cmp r0, #0x0 - moveq r5, #0x1 - movne r5, #0x0 - cmp r5, #0x0 - beq _020D0CD4 - ldr r0, [r6, #0x1c] - ands r0, r0, #0x10 - beq _020D0CC8 - ldr r0, [r6, #0x1c] - orr r0, r0, #0x40 - str r0, [r6, #0x1c] - add r7, r6, #0x14 -_020D0CB0: - mov r0, r7 - bl OS_SleepThread - ldr r0, [r6, #0x1c] - ands r0, r0, #0x40 - bne _020D0CB0 - b _020D0CD4 -_020D0CC8: - ldr r0, [r6, #0x1c] - orr r0, r0, #0x8 - str r0, [r6, #0x1c] -_020D0CD4: - mov r0, r4 - bl OS_RestoreInterrupts - mov r0, r5 - add sp, sp, #0x4 - ldmia sp!, {r4-r7,lr} - bx lr - - arm_func_start FS_UnloadArchiveTables -FS_UnloadArchiveTables: ; 0x020D0CEC - stmdb sp!, {r4-r5,lr} - sub sp, sp, #0x4 - mov r5, r0 - ldr r0, [r5, #0x1c] - mov r4, #0x0 - ands r0, r0, #0x2 - movne r0, #0x1 - moveq r0, r4 - cmp r0, #0x0 - beq _020D0D74 - mov r0, r5 - bl FS_SuspendArchive - ldr r1, [r5, #0x1c] - ands r1, r1, #0x4 - movne r1, #0x1 - moveq r1, #0x0 - cmp r1, #0x0 - beq _020D0D64 - ldr r2, [r5, #0x1c] - mov r1, #0x0 - bic r2, r2, #0x4 - str r2, [r5, #0x1c] - ldr r4, [r5, #0x44] - str r1, [r5, #0x44] - ldr r1, [r5, #0x3c] - str r1, [r5, #0x2c] - ldr r1, [r5, #0x40] - str r1, [r5, #0x34] - ldr r1, [r5, #0x48] - str r1, [r5, #0x50] -_020D0D64: - cmp r0, #0x0 - beq _020D0D74 - mov r0, r5 - bl FS_ResumeArchive -_020D0D74: - mov r0, r4 - add sp, sp, #0x4 - ldmia sp!, {r4-r5,lr} - bx lr - - arm_func_start FUN_020D0D84 -FUN_020D0D84: ; 0x020D0D84 - stmdb sp!, {r4-r7,lr} - sub sp, sp, #0x4c - mov r7, r0 - ldr r3, [r7, #0x30] - ldr r0, [r7, #0x38] - mov r6, r1 - add r0, r3, r0 - add r0, r0, #0x20 - add r0, r0, #0x1f - bic r5, r0, #0x1f - cmp r5, r2 - bhi _020D0E9C - add r1, r6, #0x1f - add r0, sp, #0x4 - bic r4, r1, #0x1f - bl FS_InitFile - ldr r2, [r7, #0x2c] - mvn r0, #0x0 - str r0, [sp, #0x0] - ldr r3, [r7, #0x30] - add r0, sp, #0x4 - mov r1, r7 - add r3, r2, r3 - bl FS_OpenFileDirect -_020D0DE4: - cmp r0, #0x0 - beq _020D0E1C - ldr r2, [r7, #0x30] - add r0, sp, #0x4 - mov r1, r4 - bl FS_ReadFile - cmp r0, #0x0 - bge _020D0E14 - ldr r2, [r7, #0x30] - mov r0, r4 - mov r1, #0x0 - bl MI_CpuFill8 -_020D0E14: - add r0, sp, #0x4 - bl FS_CloseFile -_020D0E1C: - str r4, [r7, #0x2C] - ldr ip, [r7, #0x30] - ldr r2, [r7, #0x34] - mvn r0, #0x0 - str r0, [sp] - ldr r3, [r7, #0x38] - add r0, sp, #0x4 - mov r1, r7 - add r3, r2, r3 - add r4, r4, ip - bl FS_OpenFileDirect - cmp r0, #0x0 - beq _020D0E80 - ldr r2, [r7, #0x38] - add r0, sp, #0x4 - mov r1, r4 - bl FS_ReadFile - cmp r0, #0x0 - bge _020D0E78 - ldr r2, [r7, #0x38] - mov r0, r4 - mov r1, #0x0 - bl MI_CpuFill8 -_020D0E78: - add r0, sp, #0x4 - bl FS_CloseFile -_020D0E80: - str r4, [r7, #0x34] - ldr r0, _020D0EAC - str r6, [r7, #0x44] - str r0, [r7, #0x50] - ldr r0, [r7, #0x1C] - orr r0, r0, #0x4 - str r0, [r7, #0x1C] -_020D0E9C: - mov r0, r5 - add sp, sp, #0x4C - ldmia sp!, {r4-r7,lr} - bx lr -_020D0EAC: - .word FSi_ReadMemoryCore - - arm_func_start FUN_020D0EB0 -FUN_020D0EB0: ; 0x020D0EB0 - stmdb sp!, {r4-r8,lr} - mov r5, r0 - bl OS_DisableInterrupts - ldr r1, [r5, #0x1c] - mov r4, r0 - ands r0, r1, #0x2 - movne r0, #0x1 - moveq r0, #0x0 - cmp r0, #0x0 - beq _020D0F64 - mov r0, r5 - ldr r1, [r5, #0x1c] - bl FS_SuspendArchive - ldr r1, [r5, #0x1c] - mov r7, r0 - orr r0, r1, #0x80 - str r0, [r5, #0x1c] - ldr r0, [r5, #0x24] - cmp r0, #0x0 - beq _020D0F1C - mov r6, #0x3 -_020D0F04: - ldr r8, [r0, #0x4] - mov r1, r6 - bl FSi_ReleaseCommand - mov r0, r8 - cmp r8, #0x0 - bne _020D0F04 -_020D0F1C: - mov r0, #0x0 - str r0, [r5, #0x24] - cmp r7, #0x0 - beq _020D0F34 - mov r0, r5 - bl FS_ResumeArchive -_020D0F34: - mov r0, #0x0 - str r0, [r5, #0x28] - str r0, [r5, #0x2c] - str r0, [r5, #0x30] - str r0, [r5, #0x34] - str r0, [r5, #0x38] - str r0, [r5, #0x40] - ldr r0, [r5, #0x40] - str r0, [r5, #0x3c] - ldr r0, [r5, #0x1c] - bic r0, r0, #0xa2 - str r0, [r5, #0x1c] -_020D0F64: - mov r0, r4 - bl OS_RestoreInterrupts - mov r0, #0x1 - ldmia sp!, {r4-r8,lr} - bx lr diff --git a/arm9/asm/FS_rom.s b/arm9/asm/FS_rom.s index dc7baf6c..5cfeead6 100644 --- a/arm9/asm/FS_rom.s +++ b/arm9/asm/FS_rom.s @@ -4,14 +4,14 @@ arm_func_start FS_TryLoadTable FS_TryLoadTable: ; 0x020D1D10 - ldr ip, _020D1D28 ; =FUN_020D0D84 + ldr ip, _020D1D28 ; =FS_LoadArchiveTables mov r3, r0 mov r2, r1 ldr r0, _020D1D2C ; =0x021D5414 mov r1, r3 bx r12 .balign 4 -_020D1D28: .word FUN_020D0D84 +_020D1D28: .word FS_LoadArchiveTables _020D1D2C: .word 0x021D5414 arm_func_start FS_SetDefaultDMA diff --git a/arm9/global.inc b/arm9/global.inc index e2e45165..0db306cc 100644 --- a/arm9/global.inc +++ b/arm9/global.inc @@ -5021,8 +5021,8 @@ .extern FUN_020B7218
.extern FUN_020C2444
.extern FUN_020C5E04
-.extern FUN_020D0D84
-.extern FUN_020D0EB0
+.extern FS_LoadArchiveTables
+.extern FS_UnloadArchive
.extern FS_ReleaseArchiveName
.extern FUN_021EB9A4
.extern FUN_021EB9D8
diff --git a/arm9/lib/include/FS_archive.h b/arm9/lib/include/FS_archive.h index baf11add..a86478e8 100644 --- a/arm9/lib/include/FS_archive.h +++ b/arm9/lib/include/FS_archive.h @@ -168,7 +168,19 @@ static inline BOOL FSi_IsArchiveUnloading(volatile const FSArchive * p_arc) return (p_arc->flag & FS_ARCHIVE_FLAG_UNLOADING) != 0; } +static inline BOOL FSi_IsArchiveAsync(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_IS_ASYNC) != 0; +} + +static inline BOOL FS_IsArchiveTableLoaded(volatile const FSArchive * p_arc) +{ + return (p_arc->flag & FS_ARCHIVE_FLAG_TABLE_LOAD) ? TRUE : FALSE; +} + BOOL FSi_SendCommand(struct FSFile * file, FSCommandType command); BOOL FSi_ExecuteSyncCommand(struct FSFile * file); +BOOL FS_SuspendArchive(FSArchive * p_arc); +BOOL FS_ResumeArchive(FSArchive * p_arc); #endif //NITRO_FS_ARCHIVE_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; diff --git a/arm9/lib/include/FS_overlay.h b/arm9/lib/include/FS_overlay.h index 1ef6469c..6025d04a 100644 --- a/arm9/lib/include/FS_overlay.h +++ b/arm9/lib/include/FS_overlay.h @@ -45,12 +45,11 @@ static inline u32 const FS_GetOverlayTotalSize(FSOverlayInfo * p_ovi) return p_ovi->header.ram_size + p_ovi->header.bss_size; } -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_CloseFile(FSFile *p_file); +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); #endif //NITRO_FS_OVERLAY_H_ diff --git a/arm9/lib/include/FSi_util.h b/arm9/lib/include/FSi_util.h index babb6d75..1012df13 100644 --- a/arm9/lib/include/FSi_util.h +++ b/arm9/lib/include/FSi_util.h @@ -1,6 +1,10 @@ #ifndef NITRO_FSI_UTIL_H_ #define NITRO_FSI_UTIL_H_ +#define ALIGN_MASK(a) ((u32)((a) - 1)) + +#define ALIGN_BYTE(n, a) (((u32)(n) + ALIGN_MASK(a)) & ~ALIGN_MASK(a)) + static inline BOOL FSi_IsSlash(u32 c) { return (c == '/') || (c == '\\'); diff --git a/arm9/lib/include/OS_system.h b/arm9/lib/include/OS_system.h index 1b263b19..88137c3b 100644 --- a/arm9/lib/include/OS_system.h +++ b/arm9/lib/include/OS_system.h @@ -37,9 +37,7 @@ OSProcMode OS_GetProcMode(); void OS_SpinWait(); void OS_WaitVBlankIntr(); void OS_Terminate(void); -static inline void OS_TPanic(const char * message) -{ - OS_Terminate(); -} +#define OS_TPanic(...) OS_Terminate() +#define OS_TWarning(...) ((void)0) #endif //POKEDIAMOND_OS_SYSTEM_H diff --git a/arm9/lib/src/FS_archive.c b/arm9/lib/src/FS_archive.c index c8404144..44a4e451 100644 --- a/arm9/lib/src/FS_archive.c +++ b/arm9/lib/src/FS_archive.c @@ -42,9 +42,9 @@ FSResult FSi_WriteMemCallback(struct FSArchive * p_arc, const void * src, u32 po return FS_RESULT_SUCCESS; } -FSResult FSi_ReadMemoryCore(FSArchive * p_arc, u8 * dest, u32 offset, u32 size) +FSResult FSi_ReadMemoryCore(FSArchive * p_arc, void * dest, u32 pos, u32 size) { - MI_CpuCopy8((const void *)offset, dest, size); + MI_CpuCopy8((const void *)pos, dest, size); return FS_RESULT_SUCCESS; } @@ -283,3 +283,162 @@ BOOL FS_LoadArchive(FSArchive * p_arc, u32 base, u32 fat, u32 fat_size, u32 fnt, p_arc->flag |= FS_ARCHIVE_FLAG_LOADED; return TRUE; } + +BOOL FS_UnloadArchive(FSArchive * p_arc) +{ + OSIntrMode bak_psr = OS_DisableInterrupts(); + if (FS_IsArchiveLoaded(p_arc)) + { + if (FS_IsArchiveTableLoaded(p_arc)) + { + OS_TWarning("memory may leak. preloaded-table of archive \"%s\" (0x%08X)", p_arc->name.ptr, p_arc->load_mem); + } + { + FSFile *p, *q; + BOOL bak_state = FS_SuspendArchive(p_arc); + p_arc->flag |= FS_ARCHIVE_FLAG_UNLOADING; + for (p = p_arc->list.next; p; p = q) + { + q = p->link.next; + FSi_ReleaseCommand(p, FS_RESULT_CANCELED); + } + p_arc->list.next = NULL; + if (bak_state) + FS_ResumeArchive(p_arc); + } + p_arc->base = 0; + p_arc->fat = 0; + p_arc->fat_size = 0; + p_arc->fnt = 0; + p_arc->fnt_size = 0; + p_arc->fat_bak = p_arc->fnt_bak = 0; + p_arc->flag &= ~(FS_ARCHIVE_FLAG_CANCELING | FS_ARCHIVE_FLAG_LOADED | FS_ARCHIVE_FLAG_UNLOADING); + } + OS_RestoreInterrupts(bak_psr); + return TRUE; +} + +u32 FS_LoadArchiveTables(FSArchive *p_arc, void *p_mem, u32 max_size) +{ + u32 total_size = ALIGN_BYTE(p_arc->fat_size + p_arc->fnt_size + 32, 32); + if (total_size <= max_size) + { + u8 *p_cache = (u8 *)ALIGN_BYTE((u32)p_mem, 32); + FSFile tmp; + FS_InitFile(&tmp); + if (FS_OpenFileDirect(&tmp, p_arc, p_arc->fat, p_arc->fat + p_arc->fat_size, (u32)~0)) + { + if (FS_ReadFile(&tmp, p_cache, (s32)p_arc->fat_size) < 0) + { + MI_CpuFill8(p_cache, 0x00, p_arc->fat_size); + } + FS_CloseFile(&tmp); + } + p_arc->fat = (u32)p_cache; + p_cache += p_arc->fat_size; + if (FS_OpenFileDirect(&tmp, p_arc, p_arc->fnt, p_arc->fnt + p_arc->fnt_size, (u32)~0)) + { + if (FS_ReadFile(&tmp, p_cache, (s32)p_arc->fnt_size) < 0) + { + MI_CpuFill8(p_cache, 0x00, p_arc->fnt_size); + } + FS_CloseFile(&tmp); + } + p_arc->fnt = (u32)p_cache; + p_arc->load_mem = p_mem; + p_arc->table_func = FSi_ReadMemoryCore; + p_arc->flag |= FS_ARCHIVE_FLAG_TABLE_LOAD; + } + return total_size; +} + +void * FS_UnloadArchiveTables(FSArchive * p_arc) +{ + void *ret = NULL; + if (FS_IsArchiveLoaded(p_arc)) + { + BOOL bak_stat = FS_SuspendArchive(p_arc); + if (FS_IsArchiveTableLoaded(p_arc)) + { + p_arc->flag &= ~FS_ARCHIVE_FLAG_TABLE_LOAD; + ret = p_arc->load_mem; + p_arc->load_mem = NULL; + p_arc->fat = p_arc->fat_bak; + p_arc->fnt = p_arc->fnt_bak; + p_arc->table_func = p_arc->read_func; + } + if (bak_stat) + FS_ResumeArchive(p_arc); + } + return ret; +} + +BOOL FS_SuspendArchive(FSArchive * p_arc) +{ + OSIntrMode bak_psr = OS_DisableInterrupts(); + const BOOL bak_stat = !FS_IsArchiveSuspended(p_arc); + if (bak_stat) + { + if (FSi_IsArchiveRunning(p_arc)) + { + p_arc->flag |= FS_ARCHIVE_FLAG_SUSPENDING; + do { + OS_SleepThread(&p_arc->stat_q); + } while (FSi_IsArchiveSuspending(p_arc)); + } + else + { + p_arc->flag |= FS_ARCHIVE_FLAG_SUSPEND; + } + } + OS_RestoreInterrupts(bak_psr); + return bak_stat; +} + +BOOL FS_ResumeArchive(FSArchive * p_arc) +{ + FSFile * p_target = NULL; + OSIntrMode bak_psr = OS_DisableInterrupts(); + const BOOL bak_stat = !FS_IsArchiveSuspended(p_arc); + if (!bak_stat) + { + p_arc->flag &= ~FS_ARCHIVE_FLAG_SUSPEND; + p_target = FSi_NextCommand(p_arc); + } + OS_RestoreInterrupts(bak_psr); + if (p_target) + FSi_ExecuteAsyncCommand(p_target); + return bak_stat; +} + +void FS_SetArchiveProc(struct FSArchive * p_arc, FS_ARCHIVE_PROC_FUNC proc, u32 flags) +{ + if (!flags) + proc = NULL; + else if (!proc) + flags = 0; + p_arc->proc = proc; + p_arc->proc_flag = flags; +} + +void FS_NotifyArchiveAsyncEnd(FSArchive *p_arc, FSResult ret) +{ + if (FSi_IsArchiveAsync(p_arc)) + { + FSFile *p_file = p_arc->list.next; + p_arc->flag &= ~FS_ARCHIVE_FLAG_IS_ASYNC; + FSi_ReleaseCommand(p_file, ret); + p_file = FSi_NextCommand(p_arc); + if (p_file) + FSi_ExecuteAsyncCommand(p_file); + } + else + { + FSFile *p_file = p_arc->list.next; + OSIntrMode bak_psr = OS_DisableInterrupts(); + p_file->error = ret; + p_arc->flag &= ~FS_ARCHIVE_FLAG_IS_SYNC; + OS_WakeupThread(&p_arc->sync_q); + (void)OS_RestoreInterrupts(bak_psr); + } +} diff --git a/arm9/modules/13/asm/module_13_arm2.s b/arm9/modules/13/asm/module_13_arm2.s index aeb640f2..7910e1a0 100644 --- a/arm9/modules/13/asm/module_13_arm2.s +++ b/arm9/modules/13/asm/module_13_arm2.s @@ -31909,7 +31909,7 @@ MOD13_022395A0: ; 0x022395A0 ldr r0, _02239628 ; =0x02243190 ldr r0, [r0] add r0, r0, #0x88 - bl FUN_020D0EB0 + bl FS_UnloadArchive ldr r0, _02239628 ; =0x02243190 ldr r0, [r0] add r0, r0, #0x88 @@ -32012,7 +32012,7 @@ _02239738: ldr r0, [r0] mov r2, r1 add r0, r0, #0x88 - bl FUN_020D0D84 + bl FS_LoadArchiveTables mov r1, #4 mov r4, r0 bl MOD13_0223B004 @@ -32022,7 +32022,7 @@ _02239738: str r0, [r3] ldr r0, [r1] ldr r1, [r0], #0x88 - bl FUN_020D0D84 + bl FS_LoadArchiveTables ldr r1, _022397BC ; =0x02243190 mov r0, #0x20 ldr r1, [r1] |