mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
Matched osPfsReFormat and osPfsNumFiles
This commit is contained in:
@@ -7,5 +7,4 @@
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0D0130/osPfsChecker.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0D0130/corrupted_init.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0D0130/corrupted.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0D0130/osPfsReFormat.s")
|
||||
GLOBAL_ASM("lib/asm/non_matchings/unknown_0D0130/osPfsNumFiles.s")
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/* The comment below is needed for this file to be picked up by generate_ld */
|
||||
/* RAM_POS: 0x800D0390 */
|
||||
|
||||
#include "libultra_internal.h"
|
||||
#include "controller.h"
|
||||
|
||||
s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used) {
|
||||
int j;
|
||||
s32 ret;
|
||||
__OSDir dir;
|
||||
int files;
|
||||
files = 0;
|
||||
PFS_CHECK_STATUS;
|
||||
PFS_CHECK_ID;
|
||||
SET_ACTIVEBANK_TO_ZERO;
|
||||
for (j = 0; j < pfs->dir_size; j++) {
|
||||
ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&dir));
|
||||
if (dir.company_code != 0 && dir.game_code != 0)
|
||||
files++;
|
||||
}
|
||||
*files_used = files;
|
||||
*max_files = pfs->dir_size;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/* The comment below is needed for this file to be picked up by generate_ld */
|
||||
/* RAM_POS: 0x800CFF90 */
|
||||
|
||||
#include "libultra_internal.h"
|
||||
#include "controller.h"
|
||||
#include "siint.h"
|
||||
|
||||
s32 osPfsReFormat(OSPfs *pfs, OSMesgQueue *queue, int channel) {
|
||||
int j;
|
||||
int i;
|
||||
__OSInode inode;
|
||||
u8 tmp_data[32];
|
||||
u8 *ptr;
|
||||
s32 ret;
|
||||
|
||||
__osSiGetAccess();
|
||||
ret = __osPfsGetStatus(queue, channel);
|
||||
|
||||
if (ret != 0) {
|
||||
//Single difference between this and libreultra
|
||||
//__osSiRelAccess();
|
||||
return ret;
|
||||
}
|
||||
|
||||
pfs->status ^= PFS_INITIALIZED;
|
||||
pfs->queue = queue;
|
||||
pfs->channel = channel;
|
||||
__osSiRelAccess();
|
||||
ERRCK(__osGetId(pfs));
|
||||
|
||||
SET_ACTIVEBANK_TO_ZERO;
|
||||
for (j = 0; j < ARRLEN(tmp_data); j++)
|
||||
tmp_data[j] = 0;
|
||||
|
||||
for (j = 0; j < pfs->dir_size; j++) {
|
||||
ERRCK(__osContRamWrite(queue, channel, pfs->dir_table + j, tmp_data, FALSE));
|
||||
}
|
||||
|
||||
for (j = 0; j < pfs->inodeStartPage; j++)
|
||||
inode.inodePage[j].ipage = 0;
|
||||
|
||||
for (j = pfs->inodeStartPage; j < ARRLEN(inode.inodePage); j++)
|
||||
inode.inodePage[j].ipage = 3;
|
||||
|
||||
inode.inodePage[0].ipage = __osSumcalc((u8*)&inode.inodePage[pfs->inodeStartPage],
|
||||
sizeof(__OSInodeUnit) * -pfs->inodeStartPage + sizeof(inode.inodePage));
|
||||
ptr = (u8 *)&inode;
|
||||
|
||||
for (j = 0; j < PFS_ONE_PAGE; j++){
|
||||
ERRCK(__osContRamWrite(queue, channel, pfs->inode_table + j, ptr + j * BLOCKSIZE, FALSE));
|
||||
ERRCK(__osContRamWrite(queue, channel, pfs->minode_table + j, ptr + j * BLOCKSIZE, FALSE));
|
||||
}
|
||||
|
||||
for (i = 1; i < pfs->banks; i++) {
|
||||
for (j = 1; j < ARRLEN(inode.inodePage); j++)
|
||||
inode.inodePage[j].ipage = 3;
|
||||
inode.inodePage[0].ipage = __osSumcalc((u8*)&inode.inodePage[1], -sizeof(__OSInodeUnit) + sizeof(inode.inodePage));
|
||||
ptr = (u8 *)&inode;
|
||||
for (j = 0; j < PFS_ONE_PAGE; j++) {
|
||||
ERRCK(__osContRamWrite(queue, channel, pfs->inode_table + i * PFS_ONE_PAGE + j, ptr + j * BLOCKSIZE, FALSE));
|
||||
ERRCK(__osContRamWrite(queue, channel, pfs->minode_table + i * PFS_ONE_PAGE + j, ptr + j * BLOCKSIZE, FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user