diff --git a/src/game/pak/pak.c b/src/game/pak/pak.c index 762485799..ae2f53cda 100644 --- a/src/game/pak/pak.c +++ b/src/game/pak/pak.c @@ -33,7 +33,7 @@ const char var7f1b3b18[] = "Pak %d -> Pak_UpdateAndGetPakNoteInfo - ERROR - ekPa struct var800a2380 var800a2380[5]; u32 var800a317c; -struct var800a3180 var800a3180[4]; +OSPfs g_Pfses[4]; u32 var800a3320; u32 var800a3324; u32 var800a3328; @@ -394,8 +394,7 @@ s32 func0f116e84(s8 device, u16 company_code, u32 game_code, char *game_name, ch #else joy000150e8(123, "pak.c"); #endif - result = func0f117e00(device == SAVEDEVICE_GAMEPAK ? NULL : &var800a3180[device], - company_code, game_code, game_name, ext_name); + result = func0f117e00(PFS(device), company_code, game_code, game_name, ext_name); #if VERSION >= VERSION_NTSC_1_0 joy00015144(); #else @@ -917,8 +916,8 @@ glabel func0f117520 /* f1175e8: 01445023 */ subu $t2,$t2,$a0 /* f1175ec: 000a5080 */ sll $t2,$t2,0x2 /* f1175f0: 01445021 */ addu $t2,$t2,$a0 -/* f1175f4: 3c0b800a */ lui $t3,%hi(var800a3180) -/* f1175f8: 256b3180 */ addiu $t3,$t3,%lo(var800a3180) +/* f1175f4: 3c0b800a */ lui $t3,%hi(g_Pfses) +/* f1175f8: 256b3180 */ addiu $t3,$t3,%lo(g_Pfses) /* f1175fc: 000a50c0 */ sll $t2,$t2,0x3 /* f117600: 014b2821 */ addu $a1,$t2,$t3 .L0f117604: @@ -1572,10 +1571,18 @@ glabel func0f11789c ); #endif -s32 func0f117b04(OSMesgQueue *mq, struct var800a3180 *arg1, s32 channel, s32 arg3) +#if VERSION >= VERSION_NTSC_1_0 +s32 func0f117b04(OSMesgQueue *mq, OSPfs *pfs, s32 channel, s32 *arg3) +#else +s32 func0f117b04(OSMesgQueue *mq, OSPfs *pfs, s32 channel) +#endif { - if (arg1) { - return func00006d60(mq, arg1, channel, arg3); + if (pfs) { +#if VERSION >= VERSION_NTSC_1_0 + return osPfsInitPak(mq, pfs, channel, arg3); +#else + return osPfsInitPak(mq, pfs, channel); +#endif } if (!g_PakHasEeprom) { @@ -1651,9 +1658,9 @@ s32 func0f117c0c(s32 arg0, s32 *arg1, s32 *arg2) return 0; } -s32 func0f117c80(struct var800a3180 *arg0, s32 *arg1) +s32 func0f117c80(OSPfs *pfs, s32 *arg1) { - if (arg0) { + if (pfs) { s32 result; #if VERSION >= VERSION_NTSC_1_0 @@ -1661,7 +1668,9 @@ s32 func0f117c80(struct var800a3180 *arg0, s32 *arg1) #else joy000150e8(1337, "pak.c"); #endif - result = func0004ce60(arg0, arg1); + + result = func0004ce60(pfs, arg1); + #if VERSION >= VERSION_NTSC_1_0 joy00015144(); #else @@ -1733,10 +1742,10 @@ u32 func0f117d90(u32 arg0, u16 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5, u32 return 0; } -u32 func0f117e00(struct var800a3180 *arg0, u16 company_code, u32 game_code, char *game_name, char *ext_name) +u32 func0f117e00(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name) { - if (arg0) { - return func0004d480(arg0, company_code, game_code, game_name, ext_name); + if (pfs) { + return func0004d480(pfs, company_code, game_code, game_name, ext_name); } if (g_PakHasEeprom == 0) { @@ -1783,9 +1792,9 @@ u32 func0f117e58(u32 arg0, u16 arg1, u32 arg2, u32 arg3, u32 arg4, u32 *arg5) return 0x80; } -s32 func0f117ec0(struct var800a3180 *arg0, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, u32 numbytes) +s32 func0f117ec0(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, u32 numbytes) { - if (arg0) { + if (pfs) { s32 result; #if VERSION >= VERSION_NTSC_1_0 @@ -1793,7 +1802,9 @@ s32 func0f117ec0(struct var800a3180 *arg0, u16 company_code, u32 game_code, u8 * #else joy000150e8(1496, "pak.c"); #endif - result = func00006550(arg0, company_code, game_code, game_name, ext_name, numbytes); + + result = func00006550(pfs, company_code, game_code, game_name, ext_name, numbytes); + #if VERSION >= VERSION_NTSC_1_0 joy00015144(); #else @@ -1857,7 +1868,7 @@ s32 func0f118000(s8 device) { s32 value; - func0f117c80(device == SAVEDEVICE_GAMEPAK ? NULL : &var800a3180[device], &value); + func0f117c80(PFS(device), &value); return value / 256; } @@ -1965,8 +1976,7 @@ s32 func0f118334(s8 device, s32 numpages) func0f118000(device); numbytes = numpages * 256; - errno = func0f117ec0(device == SAVEDEVICE_GAMEPAK ? NULL : &var800a3180[device], - ROM_COMPANYCODE, ROM_GAMECODE, g_PakNoteGameName, g_PakNoteExtName, numbytes); + errno = func0f117ec0(PFS(device), ROM_COMPANYCODE, ROM_GAMECODE, g_PakNoteGameName, g_PakNoteExtName, numbytes); func0f11c39c(errno, device, 1, VERSION >= VERSION_NTSC_FINAL ? 1802 : 1788); if (errno == 0) { @@ -7420,8 +7430,8 @@ glabel func0f11a574 /* f11a5f4: 24170004 */ addiu $s7,$zero,0x4 /* f11a5f8: 16b70005 */ bne $s5,$s7,.L0f11a610 /* f11a5fc: 26850290 */ addiu $a1,$s4,0x290 -/* f11a600: 3c1e800a */ lui $s8,%hi(var800a3180) -/* f11a604: 27de3180 */ addiu $s8,$s8,%lo(var800a3180) +/* f11a600: 3c1e800a */ lui $s8,%hi(g_Pfses) +/* f11a604: 27de3180 */ addiu $s8,$s8,%lo(g_Pfses) /* f11a608: 10000009 */ beqz $zero,.L0f11a630 /* f11a60c: 00002025 */ or $a0,$zero,$zero .L0f11a610: @@ -7429,8 +7439,8 @@ glabel func0f11a574 /* f11a614: 01555023 */ subu $t2,$t2,$s5 /* f11a618: 000a5080 */ sll $t2,$t2,0x2 /* f11a61c: 01555021 */ addu $t2,$t2,$s5 -/* f11a620: 3c1e800a */ lui $s8,%hi(var800a3180) -/* f11a624: 27de3180 */ addiu $s8,$s8,%lo(var800a3180) +/* f11a620: 3c1e800a */ lui $s8,%hi(g_Pfses) +/* f11a624: 27de3180 */ addiu $s8,$s8,%lo(g_Pfses) /* f11a628: 000a50c0 */ sll $t2,$t2,0x3 /* f11a62c: 03ca2021 */ addu $a0,$s8,$t2 .L0f11a630: @@ -7749,8 +7759,8 @@ glabel func0f11a7dc /* f11a818: 01f17823 */ subu $t7,$t7,$s1 /* f11a81c: 000f7880 */ sll $t7,$t7,0x2 /* f11a820: 01f17821 */ addu $t7,$t7,$s1 -/* f11a824: 3c18800a */ lui $t8,%hi(var800a3180) -/* f11a828: 27183180 */ addiu $t8,$t8,%lo(var800a3180) +/* f11a824: 3c18800a */ lui $t8,%hi(g_Pfses) +/* f11a828: 27183180 */ addiu $t8,$t8,%lo(g_Pfses) /* f11a82c: 000f78c0 */ sll $t7,$t7,0x3 /* f11a830: 01f82021 */ addu $a0,$t7,$t8 .L0f11a834: @@ -8020,8 +8030,8 @@ glabel func0f11a8f4 /* f11a9a8: 01b16823 */ subu $t5,$t5,$s1 /* f11a9ac: 000d6880 */ sll $t5,$t5,0x2 /* f11a9b0: 01b16821 */ addu $t5,$t5,$s1 -/* f11a9b4: 3c0e800a */ lui $t6,%hi(var800a3180) -/* f11a9b8: 25ce3180 */ addiu $t6,$t6,%lo(var800a3180) +/* f11a9b4: 3c0e800a */ lui $t6,%hi(g_Pfses) +/* f11a9b8: 25ce3180 */ addiu $t6,$t6,%lo(g_Pfses) /* f11a9bc: 000d68c0 */ sll $t5,$t5,0x3 /* f11a9c0: 01ae2021 */ addu $a0,$t5,$t6 .L0f11a9c4: @@ -8072,8 +8082,8 @@ glabel func0f11a8f4 /* f11aa6c: 01916023 */ subu $t4,$t4,$s1 /* f11aa70: 000c6080 */ sll $t4,$t4,0x2 /* f11aa74: 01916021 */ addu $t4,$t4,$s1 -/* f11aa78: 3c0d800a */ lui $t5,%hi(var800a3180) -/* f11aa7c: 25ad3180 */ addiu $t5,$t5,%lo(var800a3180) +/* f11aa78: 3c0d800a */ lui $t5,%hi(g_Pfses) +/* f11aa7c: 25ad3180 */ addiu $t5,$t5,%lo(g_Pfses) /* f11aa80: 000c60c0 */ sll $t4,$t4,0x3 /* f11aa84: 018d2021 */ addu $a0,$t4,$t5 .L0f11aa88: @@ -8270,8 +8280,8 @@ glabel func0f11a8f4 /* f11a728: 01b16823 */ subu $t5,$t5,$s1 /* f11a72c: 000d6880 */ sll $t5,$t5,0x2 /* f11a730: 01b16821 */ addu $t5,$t5,$s1 -/* f11a734: 3c0e800a */ lui $t6,%hi(var800a3180) -/* f11a738: 25ce3180 */ addiu $t6,$t6,%lo(var800a3180) +/* f11a734: 3c0e800a */ lui $t6,%hi(g_Pfses) +/* f11a738: 25ce3180 */ addiu $t6,$t6,%lo(g_Pfses) /* f11a73c: 000d68c0 */ sll $t5,$t5,0x3 /* f11a740: 01ae2021 */ addu $a0,$t5,$t6 .L0f11a744_2: @@ -8322,8 +8332,8 @@ glabel func0f11a8f4 /* f11a7ec: 01916023 */ subu $t4,$t4,$s1 /* f11a7f0: 000c6080 */ sll $t4,$t4,0x2 /* f11a7f4: 01916021 */ addu $t4,$t4,$s1 -/* f11a7f8: 3c0d800a */ lui $t5,%hi(var800a3180) -/* f11a7fc: 25ad3180 */ addiu $t5,$t5,%lo(var800a3180) +/* f11a7f8: 3c0d800a */ lui $t5,%hi(g_Pfses) +/* f11a7fc: 25ad3180 */ addiu $t5,$t5,%lo(g_Pfses) /* f11a800: 000c60c0 */ sll $t4,$t4,0x3 /* f11a804: 018d2021 */ addu $a0,$t4,$t5 .L0f11a808_2: @@ -8719,8 +8729,8 @@ glabel func0f11ac7c /* f11acbc: 01f07823 */ subu $t7,$t7,$s0 /* f11acc0: 000f7880 */ sll $t7,$t7,0x2 /* f11acc4: 01f07821 */ addu $t7,$t7,$s0 -/* f11acc8: 3c18800a */ lui $t8,%hi(var800a3180) -/* f11accc: 27183180 */ addiu $t8,$t8,%lo(var800a3180) +/* f11acc8: 3c18800a */ lui $t8,%hi(g_Pfses) +/* f11accc: 27183180 */ addiu $t8,$t8,%lo(g_Pfses) /* f11acd0: 000f78c0 */ sll $t7,$t7,0x3 /* f11acd4: 01f82821 */ addu $a1,$t7,$t8 .L0f11acd8: @@ -8792,8 +8802,8 @@ glabel func0f11ac7c /* f11adc8: 01906023 */ subu $t4,$t4,$s0 /* f11adcc: 000c6080 */ sll $t4,$t4,0x2 /* f11add0: 01906021 */ addu $t4,$t4,$s0 -/* f11add4: 3c0d800a */ lui $t5,%hi(var800a3180) -/* f11add8: 25ad3180 */ addiu $t5,$t5,%lo(var800a3180) +/* f11add4: 3c0d800a */ lui $t5,%hi(g_Pfses) +/* f11add8: 25ad3180 */ addiu $t5,$t5,%lo(g_Pfses) /* f11addc: 000c60c0 */ sll $t4,$t4,0x3 /* f11ade0: 018d2821 */ addu $a1,$t4,$t5 .L0f11ade4: @@ -8854,8 +8864,8 @@ glabel func0f11ac7c /* f11aeb0: 01d07023 */ subu $t6,$t6,$s0 /* f11aeb4: 000e7080 */ sll $t6,$t6,0x2 /* f11aeb8: 01d07021 */ addu $t6,$t6,$s0 -/* f11aebc: 3c0f800a */ lui $t7,%hi(var800a3180) -/* f11aec0: 25ef3180 */ addiu $t7,$t7,%lo(var800a3180) +/* f11aebc: 3c0f800a */ lui $t7,%hi(g_Pfses) +/* f11aec0: 25ef3180 */ addiu $t7,$t7,%lo(g_Pfses) /* f11aec4: 000e70c0 */ sll $t6,$t6,0x3 /* f11aec8: 01cf2821 */ addu $a1,$t6,$t7 .L0f11aecc: @@ -9235,8 +9245,8 @@ glabel pakWipeEeprom /* f11b070: 3c0a800a */ lui $t2,%hi(var800a2380) /* f11b074: 254a2380 */ addiu $t2,$t2,%lo(var800a2380) /* f11b078: 00094880 */ sll $t1,$t1,0x2 -/* f11b07c: 3c17800a */ lui $s7,%hi(var800a3180) -/* f11b080: 26f73180 */ addiu $s7,$s7,%lo(var800a3180) +/* f11b07c: 3c17800a */ lui $s7,%hi(g_Pfses) +/* f11b080: 26f73180 */ addiu $s7,$s7,%lo(g_Pfses) /* f11b084: 012aa021 */ addu $s4,$t1,$t2 /* f11b088: 241e0068 */ addiu $s8,$zero,0x68 /* f11b08c: 27b60068 */ addiu $s6,$sp,0x68 @@ -10043,8 +10053,8 @@ glabel pakForceScrub /* f11b650: 01d27023 */ subu $t6,$t6,$s2 /* f11b654: 000e7080 */ sll $t6,$t6,0x2 /* f11b658: 01d27021 */ addu $t6,$t6,$s2 -/* f11b65c: 3c0f800a */ lui $t7,%hi(var800a3180) -/* f11b660: 25ef3180 */ addiu $t7,$t7,%lo(var800a3180) +/* f11b65c: 3c0f800a */ lui $t7,%hi(g_Pfses) +/* f11b660: 25ef3180 */ addiu $t7,$t7,%lo(g_Pfses) /* f11b664: 000e70c0 */ sll $t6,$t6,0x3 /* f11b668: 01cf8821 */ addu $s1,$t6,$t7 .L0f11b66c: @@ -10569,8 +10579,8 @@ glabel func0f11b86c /* f11bac0: 00047603 */ sra $t6,$a0,0x18 /* f11bac4: 01916021 */ addu $t4,$t4,$s1 /* f11bac8: 24010004 */ addiu $at,$zero,0x4 -/* f11bacc: 3c0d800a */ lui $t5,%hi(var800a3180) -/* f11bad0: 25ad3180 */ addiu $t5,$t5,%lo(var800a3180) +/* f11bacc: 3c0d800a */ lui $t5,%hi(g_Pfses) +/* f11bad0: 25ad3180 */ addiu $t5,$t5,%lo(g_Pfses) /* f11bad4: 000c60c0 */ sll $t4,$t4,0x3 /* f11bad8: 00005012 */ mflo $t2 /* f11badc: 01c02025 */ or $a0,$t6,$zero @@ -11288,8 +11298,8 @@ glabel func0f11bc54 /* f11c148: 0019c880 */ sll $t9,$t9,0x2 /* f11c14c: 0337c821 */ addu $t9,$t9,$s7 /* f11c150: 24010004 */ addiu $at,$zero,0x4 -/* f11c154: 3c0b800a */ lui $t3,%hi(var800a3180) -/* f11c158: 256b3180 */ addiu $t3,$t3,%lo(var800a3180) +/* f11c154: 3c0b800a */ lui $t3,%hi(g_Pfses) +/* f11c158: 256b3180 */ addiu $t3,$t3,%lo(g_Pfses) /* f11c15c: 0019c8c0 */ sll $t9,$t9,0x3 /* f11c160: 0000c012 */ mflo $t8 /* f11c164: 00045603 */ sra $t2,$a0,0x18 @@ -11865,7 +11875,7 @@ glabel pakRepair /* f11c308: afa2001c */ sw $v0,0x1c($sp) /* f11c30c: 83a2002b */ lb $v0,0x2b($sp) /* f11c310: 24010004 */ addiu $at,$zero,0x4 -/* f11c314: 3c08800a */ lui $t0,%hi(var800a3180) +/* f11c314: 3c08800a */ lui $t0,%hi(g_Pfses) /* f11c318: 14410003 */ bne $v0,$at,.L0f11c328 /* f11c31c: 0002c880 */ sll $t9,$v0,0x2 /* f11c320: 10000007 */ beqz $zero,.L0f11c340 @@ -11875,10 +11885,10 @@ glabel pakRepair /* f11c32c: 0019c880 */ sll $t9,$t9,0x2 /* f11c330: 0322c821 */ addu $t9,$t9,$v0 /* f11c334: 0019c8c0 */ sll $t9,$t9,0x3 -/* f11c338: 25083180 */ addiu $t0,$t0,%lo(var800a3180) +/* f11c338: 25083180 */ addiu $t0,$t0,%lo(g_Pfses) /* f11c33c: 03282821 */ addu $a1,$t9,$t0 .L0f11c340: -/* f11c340: 0c0135bc */ jal func0004d6f0 +/* f11c340: 0c0135bc */ jal osPfsChecker /* f11c344: 00a02025 */ or $a0,$a1,$zero /* f11c348: 0c005451 */ jal joy00015144 /* f11c34c: afa20024 */ sw $v0,0x24($sp) @@ -11947,7 +11957,7 @@ glabel pakRepair /* f1162bc: 25297658 */ addiu $t1,$t1,0x7658 /* f1162c0: 01092821 */ addu $a1,$t0,$t1 .NB0f1162c4: -/* f1162c4: 0c013a9c */ jal func0004d6f0 +/* f1162c4: 0c013a9c */ jal osPfsChecker /* f1162c8: 00a02025 */ or $a0,$a1,$zero /* f1162cc: 3c057f1b */ lui $a1,0x7f1b /* f1162d0: afa20024 */ sw $v0,0x24($sp) @@ -12480,7 +12490,7 @@ void pakExecuteDebugOperations(void) s32 device = g_PakDebugPakInit - 1; joy000150e8(); - func0f117b04(&var80099e78, (device == SAVEDEVICE_GAMEPAK ? NULL : &var800a3180[device]), device, 0); + func0f117b04(&var80099e78, PFS(device), device, 0); joy00015144(); g_PakDebugPakInit = false; } @@ -13137,8 +13147,7 @@ glabel func0f116768nb s32 func0f11cbd8(s8 device, s32 arg1, char *arg2, u16 arg3) { - s32 result = func000513b0(device == SAVEDEVICE_GAMEPAK ? NULL : &var800a3180[device], - false, arg1, arg2, arg3); + s32 result = func000513b0(PFS(device), false, arg1, arg2, arg3); if (result) { func0f11cb9c(result); @@ -13150,8 +13159,7 @@ s32 func0f11cbd8(s8 device, s32 arg1, char *arg2, u16 arg3) s32 func0f11cc6c(s8 device, u16 arg1, char *arg2, u16 arg3) { - s32 result = func000513b0(device == SAVEDEVICE_GAMEPAK ? NULL : &var800a3180[device], - true, arg1, arg2, arg3); + s32 result = func000513b0(PFS(device), true, arg1, arg2, arg3); if (result) { func0f11cb9c(result); @@ -16932,7 +16940,7 @@ s32 func0f11e844(s8 device) joy000150e8(); - value = func00050d60(device == SAVEDEVICE_GAMEPAK ? NULL : &var800a3180[device], sp38, &sp37); + value = func00050d60(PFS(device), sp38, &sp37); #if VERSION >= VERSION_NTSC_FINAL // NTSC Final sets sp28 to 1 unconditionally. @@ -16974,7 +16982,7 @@ s32 func0f11e844(s8 device) } if (sp28) { - if (func00006330(device == SAVEDEVICE_GAMEPAK ? NULL : &var800a3180[device], 0)) { + if (func00006330(PFS(device), 0)) { sp24 = 0; } } diff --git a/src/include/PR/os_pfs.h b/src/include/PR/os_pfs.h index 8dbeab50e..0dd998d1b 100644 --- a/src/include/PR/os_pfs.h +++ b/src/include/PR/os_pfs.h @@ -88,12 +88,47 @@ typedef struct { #define PFS_ERR_ID_FATAL 10 /* dead ram pack */ #define PFS_ERR_DEVICE 11 /* wrong device type */ +#define OS_PFS_VERSION 0x0200 +#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8) +#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255) + +#define PFS_FILE_NAME_LEN 16 +#define PFS_FILE_EXT_LEN 4 +#define BLOCKSIZE 32 /* bytes */ +#define PFS_ONE_PAGE 8 /* blocks */ +#define PFS_MAX_BANKS 62 + +#define PFS_INITIALIZED 0x1 +#define PFS_CORRUPTED 0x2 + /************************************************************************** * * Macro definitions * */ +#define SET_ACTIVEBANK_TO_ZERO \ + if (pfs->activebank != 0) \ + { \ + pfs->activebank = 0; \ + ERRCK(__osPfsSelectBank(pfs)) \ + } + +#define PFS_CHECK_ID \ + if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \ + return PFS_ERR_NEW_PACK; + +#define PFS_CHECK_STATUS \ + if ((pfs->status & PFS_INITIALIZED) == 0) \ + return PFS_ERR_INVALID; + +#define PFS_GET_STATUS \ + __osSiGetAccess(); \ + ret = __osPfsGetStatus(queue, channel); \ + __osSiRelAccess(); \ + if (ret != 0) \ + return ret; + /************************************************************************** * * Extern variables diff --git a/src/include/bss.h b/src/include/bss.h index 7b6d0943a..4a61ae5d2 100644 --- a/src/include/bss.h +++ b/src/include/bss.h @@ -210,7 +210,7 @@ extern void *var800a2368; extern u16 g_NumSpecialCovers; extern u16 *g_SpecialCoverNums; extern struct var800a2380 var800a2380[5]; -extern struct var800a3180 var800a3180[4]; +extern OSPfs g_Pfses[4]; extern u32 var800a33a0; extern u32 var800a33a4; extern struct explosion *g_Explosions; diff --git a/src/include/constants.h b/src/include/constants.h index 0cc3ef8d9..40ded411d 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -34,6 +34,7 @@ #define PLAYERCOUNT3012() ((g_Vars.players[3] ? 1 : 0) + (g_Vars.players[0] ? 1 : 0) + (g_Vars.players[1] ? 1 : 0) + (g_Vars.players[2] ? 1 : 0)) #define SECSTOTIME240(secs) (secs * 240) #define SECSTOTIME60(secs) (secs * 60) +#define PFS(device) (device == SAVEDEVICE_GAMEPAK ? NULL : &g_Pfses[device]) #if VERSION >= VERSION_NTSC_1_0 #define VOLUME(volume) (volume > 0x5000 ? 0x5000 : volume) diff --git a/src/include/game/pak/pak.h b/src/include/game/pak/pak.h index 546d42ab2..fc966fe44 100644 --- a/src/include/game/pak/pak.h +++ b/src/include/game/pak/pak.h @@ -41,15 +41,21 @@ u32 func0f117520(s8 arg0, u32 arg1, u32 *arg2); void pakDumpBuffer(u8 *buffer, u32 len, char *name); void pakDumpEeprom(void); s32 func0f11789c(s8 arg0, s32 arg1, s32 arg2, void *arg3, s32 *arg4, s32 arg5); -s32 func0f117b04(OSMesgQueue *mq, struct var800a3180 *arg1, s32 channel, s32 arg3); + +#if VERSION >= VERSION_NTSC_1_0 +s32 func0f117b04(OSMesgQueue *mq, OSPfs *pfs, s32 channel, s32 *arg3); +#else +s32 func0f117b04(OSMesgQueue *mq, OSPfs *pfs, s32 channel); +#endif + s32 func0f117b4c(s32 arg0, s32 arg1, u8 operation, u32 address, u32 len, u8 *buffer); s32 func0f117c0c(s32 arg0, s32 *arg1, s32 *arg2); -s32 func0f117c80(struct var800a3180 *arg0, s32 *arg1); +s32 func0f117c80(OSPfs *pfs, s32 *arg1); s32 func0f117ce4(s32 arg0, s32 arg1, OSPfsState *note); u32 func0f117d90(u32 arg0, u16 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5, u32 *arg6); -u32 func0f117e00(struct var800a3180 *arg0, u16 company_code, u32 game_code, char *game_name, char *ext_name); +u32 func0f117e00(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name); u32 func0f117e58(u32 arg0, u16 arg1, u32 arg2, u32 arg3, u32 arg4, u32 *arg5); -s32 func0f117ec0(struct var800a3180 *arg0, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, u32 numbytes); +s32 func0f117ec0(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, u32 numbytes); s32 func0f117f80(s8 device); s32 func0f117fc0(s8 device); s32 func0f118000(s8 device); diff --git a/src/include/lib/lib_06330.h b/src/include/lib/lib_06330.h index 9e29dda4a..8b0d3259f 100644 --- a/src/include/lib/lib_06330.h +++ b/src/include/lib/lib_06330.h @@ -4,6 +4,6 @@ #include "data.h" #include "types.h" -s32 func00006330(struct var800a3180 *arg0, u32 arg1); +s32 func00006330(OSPfs *pfs, u32 arg1); #endif diff --git a/src/include/lib/lib_06550.h b/src/include/lib/lib_06550.h index 48a8aa4ab..7a3fba83e 100644 --- a/src/include/lib/lib_06550.h +++ b/src/include/lib/lib_06550.h @@ -4,9 +4,15 @@ #include "data.h" #include "types.h" -s32 func00006550(struct var800a3180 *arg0, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, u32 numbytes); -s32 func00006d60(OSMesgQueue *mq, struct var800a3180 *arg1, s32 channel, s32 arg3); -u32 func00006f98(void); -u32 func00007084(void); +s32 func00006550(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, u32 numbytes); + +#if VERSION >= VERSION_NTSC_1_0 +s32 osPfsInitPak(OSMesgQueue *mq, OSPfs *pfs, s32 channel, s32 *arg3); +#else +s32 osPfsInitPak(OSMesgQueue *mq, OSPfs *pfs, s32 channel); +#endif + +s32 func00006f98(OSPfs *pfs); +s32 func00007084(OSPfs *pfs); #endif diff --git a/src/include/lib/lib_4c090.h b/src/include/lib/lib_4c090.h index 14d6390e4..bfcc53edf 100644 --- a/src/include/lib/lib_4c090.h +++ b/src/include/lib/lib_4c090.h @@ -5,9 +5,9 @@ #include "types.h" u32 func0004c090(void); -u32 func0004c104(void); -u32 func0004c200(void); -u32 func0004c550(void); +s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum); +s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid); +s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp); u32 func0004c6b4(void); u32 func0004c860(void); u32 func0004c934(void); diff --git a/src/include/lib/lib_4ce60.h b/src/include/lib/lib_4ce60.h index a91ea6bf1..2b195f6b4 100644 --- a/src/include/lib/lib_4ce60.h +++ b/src/include/lib/lib_4ce60.h @@ -4,6 +4,6 @@ #include "data.h" #include "types.h" -s32 func0004ce60(struct var800a3180 *arg0, s32 *arg1); +s32 func0004ce60(OSPfs *pfs, s32 *arg1); #endif diff --git a/src/include/lib/lib_4d480.h b/src/include/lib/lib_4d480.h index f23de8c7d..cd7e19526 100644 --- a/src/include/lib/lib_4d480.h +++ b/src/include/lib/lib_4d480.h @@ -4,7 +4,7 @@ #include "data.h" #include "types.h" -u32 func0004d480(struct var800a3180 *arg0, u16 company_code, u32 game_code, char *game_name, char *ext_name); +u32 func0004d480(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name); u32 func0004d658(void); #endif diff --git a/src/include/lib/lib_4d6f0.h b/src/include/lib/lib_4d6f0.h index 60408fe33..9caa20255 100644 --- a/src/include/lib/lib_4d6f0.h +++ b/src/include/lib/lib_4d6f0.h @@ -4,7 +4,7 @@ #include "data.h" #include "types.h" -u32 func0004d6f0(void); +s32 osPfsChecker(OSPfs *pfs); u32 func0004dc28(void); u32 func0004def4(void); u32 func0004e090(void); diff --git a/src/include/lib/lib_4f5e0.h b/src/include/lib/lib_4f5e0.h index 48988640f..1039dfa90 100644 --- a/src/include/lib/lib_4f5e0.h +++ b/src/include/lib/lib_4f5e0.h @@ -4,9 +4,9 @@ #include "data.h" #include "types.h" -void func0004f5e0(struct var800a3180 *arg0, u32 arg1); +void func0004f5e0(OSPfs *pfs, u32 arg1); u32 func0004f748(void); -bool func0004f854(OSMesgQueue *mq, struct var800a3180 *arg1, s32 arg2); +bool func0004f854(OSMesgQueue *mq, OSPfs *pfs, s32 arg2); u32 func0004f9b0(void); u32 func0004fbc0(void); u32 func0004fbf0(void); diff --git a/src/include/lib/lib_50d60.h b/src/include/lib/lib_50d60.h index 82a1d05bd..31961080b 100644 --- a/src/include/lib/lib_50d60.h +++ b/src/include/lib/lib_50d60.h @@ -4,6 +4,6 @@ #include "data.h" #include "types.h" -s32 func00050d60(struct var800a3180 *arg0, char *arg1, u8 *arg2); +s32 func00050d60(OSPfs *pfs, char *arg1, u8 *arg2); #endif diff --git a/src/include/lib/lib_513b0.h b/src/include/lib/lib_513b0.h index ae8d72389..0a6ad519d 100644 --- a/src/include/lib/lib_513b0.h +++ b/src/include/lib/lib_513b0.h @@ -4,6 +4,6 @@ #include "data.h" #include "types.h" -s32 func000513b0(struct var800a3180 *arg0, bool arg1, u16 arg2, char *arg3, u16 arg4); +s32 func000513b0(OSPfs *pfs, bool arg1, u16 arg2, char *arg3, u16 arg4); #endif diff --git a/src/include/types.h b/src/include/types.h index 432c4bc36..13b97da6f 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -6773,35 +6773,6 @@ struct joydata { s32 unk200; }; -struct var800a3180 { - /*0x00*/ u32 unk00; - /*0x04*/ u32 unk04; - /*0x08*/ u32 unk08; - /*0x0c*/ u32 unk0c; - /*0x10*/ u32 unk10; - /*0x14*/ u32 unk14; - /*0x18*/ u32 unk18; - /*0x1c*/ u32 unk1c; - /*0x20*/ u32 unk20; - /*0x24*/ u32 unk24; - /*0x28*/ u32 unk28; - /*0x2c*/ u32 unk2c; - /*0x30*/ u32 unk30; - /*0x34*/ u32 unk34; - /*0x38*/ u32 unk38; - /*0x3c*/ u32 unk3c; - /*0x40*/ u32 unk40; - /*0x44*/ u32 unk44; - /*0x48*/ u32 unk48; - /*0x4c*/ u32 unk4c; - /*0x50*/ u32 unk50; - /*0x54*/ u32 unk54; - /*0x58*/ u32 unk58; - /*0x5c*/ u32 unk5c; - /*0x60*/ u32 unk60; - /*0x64*/ u32 unk64; -}; - struct guncmd { u8 type; u8 unk01; diff --git a/src/lib/joy.c b/src/lib/joy.c index c7ba7e1f8..438146e25 100644 --- a/src/lib/joy.c +++ b/src/lib/joy.c @@ -1312,10 +1312,10 @@ void joy0001519c(void) osSetEventMesg(OS_EVENT_SI, &var80099e78, 0); for (i = 0; i < 4; i++) { - if (!func0004f854(&var80099e78, (i == 4 ? NULL : &var800a3180[i]), i)) { - func0004f5e0((i == 4 ? NULL : &var800a3180[i]), 0); - func0004f5e0((i == 4 ? NULL : &var800a3180[i]), 0); - func0004f5e0((i == 4 ? NULL : &var800a3180[i]), 0); + if (!func0004f854(&var80099e78, PFS(i), i)) { + func0004f5e0(PFS(i), 0); + func0004f5e0(PFS(i), 0); + func0004f5e0(PFS(i), 0); } } } @@ -1351,10 +1351,10 @@ void joy000153c4(s8 arg0, s32 arg1) joy000150e8(); } - if (func0004f854(&var80099e78, arg0 == 4 ? NULL : &var800a3180[arg0], arg0) == 0) { - func0004f5e0(arg0 == 4 ? NULL : &var800a3180[arg0], 0); - func0004f5e0(arg0 == 4 ? NULL : &var800a3180[arg0], 0); - func0004f5e0(arg0 == 4 ? NULL : &var800a3180[arg0], 0); + if (func0004f854(&var80099e78, PFS(arg0), arg0) == 0) { + func0004f5e0(PFS(arg0), 0); + func0004f5e0(PFS(arg0), 0); + func0004f5e0(PFS(arg0), 0); } if (arg1) { @@ -1538,14 +1538,14 @@ void joy0001561c(void) switch (var800a2380[i].unk004) { case 3: var800a2380[i].unk004 = 4; - func0004f5e0(i == 4 ? NULL : &var800a3180[i], 1); + func0004f5e0(PFS(i), 1); break; case 4: if (var800a2380[i].unk284 != -1) { if (var800a2380[i].unk28c == 0) { - func0004f5e0(i == 4 ? NULL : &var800a3180[i], 1); + func0004f5e0(PFS(i), 1); } else if (var800a2380[i].unk284 == var800a2380[i].unk28c) { - func0004f5e0(i == 4 ? NULL : &var800a3180[i], 0); + func0004f5e0(PFS(i), 0); } var800a2380[i].unk28c++; @@ -1563,10 +1563,10 @@ void joy0001561c(void) break; case 5: var800a2380[i].unk004 = 2; - func0004f5e0(i == 4 ? NULL : &var800a3180[i], 0); + func0004f5e0(PFS(i), 0); break; case 6: - func0004f5e0(i == 4 ? NULL : &var800a3180[i], 0); + func0004f5e0(PFS(i), 0); var800a2380[i].unk004 = 7; break; case 8: diff --git a/src/lib/lib_06550.c b/src/lib/lib_06550.c index d243d2610..c7ce42bf2 100644 --- a/src/lib/lib_06550.c +++ b/src/lib/lib_06550.c @@ -599,315 +599,99 @@ glabel func00006550 ); #if VERSION >= VERSION_NTSC_1_0 -GLOBAL_ASM( -glabel func00006d60 -/* 6d60: 27bdff90 */ addiu $sp,$sp,-112 -/* 6d64: afbf001c */ sw $ra,0x1c($sp) -/* 6d68: afb00018 */ sw $s0,0x18($sp) -/* 6d6c: 00a08025 */ or $s0,$a1,$zero -/* 6d70: afa40070 */ sw $a0,0x70($sp) -/* 6d74: afa60078 */ sw $a2,0x78($sp) -/* 6d78: 0c012a18 */ jal __osSiGetAccess -/* 6d7c: afa7007c */ sw $a3,0x7c($sp) -/* 6d80: 8fa40070 */ lw $a0,0x70($sp) -/* 6d84: 0c012ea4 */ jal __osPfsGetStatus -/* 6d88: 8fa50078 */ lw $a1,0x78($sp) -/* 6d8c: 0c012a29 */ jal __osSiRelAccess -/* 6d90: afa2006c */ sw $v0,0x6c($sp) -/* 6d94: 8fa3006c */ lw $v1,0x6c($sp) -/* 6d98: 8fae0070 */ lw $t6,0x70($sp) -/* 6d9c: 02002025 */ or $a0,$s0,$zero -/* 6da0: 50600004 */ beqzl $v1,.L00006db4 -/* 6da4: ae0e0004 */ sw $t6,0x4($s0) -/* 6da8: 10000076 */ b .L00006f84 -/* 6dac: 00601025 */ or $v0,$v1,$zero -/* 6db0: ae0e0004 */ sw $t6,0x4($s0) -.L00006db4: -/* 6db4: 8faf0078 */ lw $t7,0x78($sp) -/* 6db8: ae000000 */ sw $zero,0x0($s0) -/* 6dbc: 0c001be6 */ jal func00006f98 -/* 6dc0: ae0f0008 */ sw $t7,0x8($s0) -/* 6dc4: 10400003 */ beqz $v0,.L00006dd4 -/* 6dc8: 02002025 */ or $a0,$s0,$zero -/* 6dcc: 1000006e */ b .L00006f88 -/* 6dd0: 8fbf001c */ lw $ra,0x1c($sp) -.L00006dd4: -/* 6dd4: 0c013378 */ jal __osPfsSelectBank -/* 6dd8: 00002825 */ or $a1,$zero,$zero -/* 6ddc: 10400003 */ beqz $v0,.L00006dec -/* 6de0: 24060001 */ addiu $a2,$zero,0x1 -/* 6de4: 10000068 */ b .L00006f88 -/* 6de8: 8fbf001c */ lw $ra,0x1c($sp) -.L00006dec: -/* 6dec: 8e040004 */ lw $a0,0x4($s0) -/* 6df0: 8e050008 */ lw $a1,0x8($s0) -/* 6df4: 0c012e18 */ jal __osContRamRead -/* 6df8: 27a70048 */ addiu $a3,$sp,0x48 -/* 6dfc: 10400003 */ beqz $v0,.L00006e0c -/* 6e00: 27a40048 */ addiu $a0,$sp,0x48 -/* 6e04: 10000060 */ b .L00006f88 -/* 6e08: 8fbf001c */ lw $ra,0x1c($sp) -.L00006e0c: -/* 6e0c: 27a5006a */ addiu $a1,$sp,0x6a -/* 6e10: 0c013041 */ jal func0004c104 -/* 6e14: 27a60068 */ addiu $a2,$sp,0x68 -/* 6e18: 97b8006a */ lhu $t8,0x6a($sp) -/* 6e1c: 97b90064 */ lhu $t9,0x64($sp) -/* 6e20: 27a50048 */ addiu $a1,$sp,0x48 -/* 6e24: afa50044 */ sw $a1,0x44($sp) -/* 6e28: 17190004 */ bne $t8,$t9,.L00006e3c -/* 6e2c: 97a90068 */ lhu $t1,0x68($sp) -/* 6e30: 97aa0066 */ lhu $t2,0x66($sp) -/* 6e34: 512a000a */ beql $t1,$t2,.L00006e60 -/* 6e38: 97ad0060 */ lhu $t5,0x60($sp) -.L00006e3c: -/* 6e3c: 0c013154 */ jal func0004c550 -/* 6e40: 02002025 */ or $a0,$s0,$zero -/* 6e44: 50400006 */ beqzl $v0,.L00006e60 -/* 6e48: 97ad0060 */ lhu $t5,0x60($sp) -/* 6e4c: 8e0b0000 */ lw $t3,0x0($s0) -/* 6e50: 356c0004 */ ori $t4,$t3,0x4 -/* 6e54: 1000004b */ b .L00006f84 -/* 6e58: ae0c0000 */ sw $t4,0x0($s0) -/* 6e5c: 97ad0060 */ lhu $t5,0x60($sp) -.L00006e60: -/* 6e60: 27a50048 */ addiu $a1,$sp,0x48 -/* 6e64: 02002025 */ or $a0,$s0,$zero -/* 6e68: 31ae0001 */ andi $t6,$t5,0x1 -/* 6e6c: 55c00016 */ bnezl $t6,.L00006ec8 -/* 6e70: 8fa40044 */ lw $a0,0x44($sp) -/* 6e74: 0c013080 */ jal func0004c200 -/* 6e78: 27a60020 */ addiu $a2,$sp,0x20 -/* 6e7c: 10400009 */ beqz $v0,.L00006ea4 -/* 6e80: 00401825 */ or $v1,$v0,$zero -/* 6e84: 2401000a */ addiu $at,$zero,0xa -/* 6e88: 14410004 */ bne $v0,$at,.L00006e9c -/* 6e8c: 00000000 */ nop -/* 6e90: 8e0f0000 */ lw $t7,0x0($s0) -/* 6e94: 35f80004 */ ori $t8,$t7,0x4 -/* 6e98: ae180000 */ sw $t8,0x0($s0) -.L00006e9c: -/* 6e9c: 10000039 */ b .L00006f84 -/* 6ea0: 00601025 */ or $v0,$v1,$zero -.L00006ea4: -/* 6ea4: 97a90038 */ lhu $t1,0x38($sp) -/* 6ea8: 27b90020 */ addiu $t9,$sp,0x20 -/* 6eac: afb90044 */ sw $t9,0x44($sp) -/* 6eb0: 312a0001 */ andi $t2,$t1,0x1 -/* 6eb4: 55400004 */ bnezl $t2,.L00006ec8 -/* 6eb8: 8fa40044 */ lw $a0,0x44($sp) -/* 6ebc: 10000031 */ b .L00006f84 -/* 6ec0: 2402000b */ addiu $v0,$zero,0xb -/* 6ec4: 8fa40044 */ lw $a0,0x44($sp) -.L00006ec8: -/* 6ec8: 2605000c */ addiu $a1,$s0,0xc -/* 6ecc: 0c012c5c */ jal bcopy -/* 6ed0: 24060020 */ addiu $a2,$zero,0x20 -/* 6ed4: 8fab0044 */ lw $t3,0x44($sp) -/* 6ed8: 24190010 */ addiu $t9,$zero,0x10 -/* 6edc: 24090008 */ addiu $t1,$zero,0x8 -/* 6ee0: 916c001b */ lbu $t4,0x1b($t3) -/* 6ee4: 8e040004 */ lw $a0,0x4($s0) -/* 6ee8: 8e050008 */ lw $a1,0x8($s0) -/* 6eec: ae0c004c */ sw $t4,0x4c($s0) -/* 6ef0: 8fad0044 */ lw $t5,0x44($sp) -/* 6ef4: 24060007 */ addiu $a2,$zero,0x7 -/* 6ef8: 2607002c */ addiu $a3,$s0,0x2c -/* 6efc: 91ae001a */ lbu $t6,0x1a($t5) -/* 6f00: ae190050 */ sw $t9,0x50($s0) -/* 6f04: ae090054 */ sw $t1,0x54($s0) -/* 6f08: 31c200ff */ andi $v0,$t6,0xff -/* 6f0c: 000218c0 */ sll $v1,$v0,0x3 -/* 6f10: 00027840 */ sll $t7,$v0,0x1 -/* 6f14: 24680008 */ addiu $t0,$v1,0x8 -/* 6f18: 25f80003 */ addiu $t8,$t7,0x3 -/* 6f1c: 01035021 */ addu $t2,$t0,$v1 -/* 6f20: ae180060 */ sw $t8,0x60($s0) -/* 6f24: ae080058 */ sw $t0,0x58($s0) -/* 6f28: ae0a005c */ sw $t2,0x5c($s0) -/* 6f2c: 0c012e18 */ jal __osContRamRead -/* 6f30: a20e0064 */ sb $t6,0x64($s0) -/* 6f34: 10400003 */ beqz $v0,.L00006f44 -/* 6f38: 00000000 */ nop -/* 6f3c: 10000012 */ b .L00006f88 -/* 6f40: 8fbf001c */ lw $ra,0x1c($sp) -.L00006f44: -/* 6f44: 0c0135bc */ jal func0004d6f0 -/* 6f48: 02002025 */ or $a0,$s0,$zero -/* 6f4c: 8e0b0000 */ lw $t3,0x0($s0) -/* 6f50: 00401825 */ or $v1,$v0,$zero -/* 6f54: 02002025 */ or $a0,$s0,$zero -/* 6f58: 356c0001 */ ori $t4,$t3,0x1 -/* 6f5c: ae0c0000 */ sw $t4,0x0($s0) -/* 6f60: 8fad007c */ lw $t5,0x7c($sp) -/* 6f64: 51a00007 */ beqzl $t5,.L00006f84 -/* 6f68: 00601025 */ or $v0,$v1,$zero -/* 6f6c: 0c001c21 */ jal func00007084 -/* 6f70: afa2006c */ sw $v0,0x6c($sp) -/* 6f74: 8fae007c */ lw $t6,0x7c($sp) -/* 6f78: 8fa3006c */ lw $v1,0x6c($sp) -/* 6f7c: adc20000 */ sw $v0,0x0($t6) -/* 6f80: 00601025 */ or $v0,$v1,$zero -.L00006f84: -/* 6f84: 8fbf001c */ lw $ra,0x1c($sp) -.L00006f88: -/* 6f88: 8fb00018 */ lw $s0,0x18($sp) -/* 6f8c: 27bd0070 */ addiu $sp,$sp,0x70 -/* 6f90: 03e00008 */ jr $ra -/* 6f94: 00000000 */ nop -); +s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, s32 channel, s32 *arg3) #else -const char var70053ad0nb[] = "pfsinitpak.c -> ret = %d\n"; - -GLOBAL_ASM( -glabel func00006d60 -/* 6ea0: 27bdff90 */ addiu $sp,$sp,-112 -/* 6ea4: afbf001c */ sw $ra,0x1c($sp) -/* 6ea8: afb00018 */ sw $s0,0x18($sp) -/* 6eac: 00a08025 */ or $s0,$a1,$zero -/* 6eb0: afa40070 */ sw $a0,0x70($sp) -/* 6eb4: 0c013a80 */ jal __osSiGetAccess -/* 6eb8: afa60078 */ sw $a2,0x78($sp) -/* 6ebc: 8fa40070 */ lw $a0,0x70($sp) -/* 6ec0: 0c013284 */ jal __osPfsGetStatus -/* 6ec4: 8fa50078 */ lw $a1,0x78($sp) -/* 6ec8: 0c013a91 */ jal __osSiRelAccess -/* 6ecc: afa2006c */ sw $v0,0x6c($sp) -/* 6ed0: 8fa5006c */ lw $a1,0x6c($sp) -/* 6ed4: 8fae0070 */ lw $t6,0x70($sp) -/* 6ed8: 02002025 */ or $a0,$s0,$zero -/* 6edc: 50a00004 */ beqzl $a1,.NB00006ef0 -/* 6ee0: ae0e0004 */ sw $t6,0x4($s0) -/* 6ee4: 1000006e */ beqz $zero,.NB000070a0 -/* 6ee8: 00a01025 */ or $v0,$a1,$zero -/* 6eec: ae0e0004 */ sw $t6,0x4($s0) -.NB00006ef0: -/* 6ef0: 8faf0078 */ lw $t7,0x78($sp) -/* 6ef4: ae000000 */ sw $zero,0x0($s0) -/* 6ef8: 0c001c2d */ jal func00006f98 -/* 6efc: ae0f0008 */ sw $t7,0x8($s0) -/* 6f00: 10400003 */ beqz $v0,.NB00006f10 -/* 6f04: 02002025 */ or $a0,$s0,$zero -/* 6f08: 10000066 */ beqz $zero,.NB000070a4 -/* 6f0c: 8fbf001c */ lw $ra,0x1c($sp) -.NB00006f10: -/* 6f10: 0c013828 */ jal __osPfsSelectBank -/* 6f14: 00002825 */ or $a1,$zero,$zero -/* 6f18: 10400003 */ beqz $v0,.NB00006f28 -/* 6f1c: 24060001 */ addiu $a2,$zero,0x1 -/* 6f20: 10000060 */ beqz $zero,.NB000070a4 -/* 6f24: 8fbf001c */ lw $ra,0x1c($sp) -.NB00006f28: -/* 6f28: 8e040004 */ lw $a0,0x4($s0) -/* 6f2c: 8e050008 */ lw $a1,0x8($s0) -/* 6f30: 0c0131f8 */ jal __osContRamRead -/* 6f34: 27a70048 */ addiu $a3,$sp,0x48 -/* 6f38: 10400003 */ beqz $v0,.NB00006f48 -/* 6f3c: 27a40048 */ addiu $a0,$sp,0x48 -/* 6f40: 10000058 */ beqz $zero,.NB000070a4 -/* 6f44: 8fbf001c */ lw $ra,0x1c($sp) -.NB00006f48: -/* 6f48: 27a5006a */ addiu $a1,$sp,0x6a -/* 6f4c: 0c0134f1 */ jal func0004c104 -/* 6f50: 27a60068 */ addiu $a2,$sp,0x68 -/* 6f54: 97b8006a */ lhu $t8,0x6a($sp) -/* 6f58: 97b90064 */ lhu $t9,0x64($sp) -/* 6f5c: 27a50048 */ addiu $a1,$sp,0x48 -/* 6f60: afa50044 */ sw $a1,0x44($sp) -/* 6f64: 17190004 */ bne $t8,$t9,.NB00006f78 -/* 6f68: 97a90068 */ lhu $t1,0x68($sp) -/* 6f6c: 97aa0066 */ lhu $t2,0x66($sp) -/* 6f70: 512a000a */ beql $t1,$t2,.NB00006f9c -/* 6f74: 97ad0060 */ lhu $t5,0x60($sp) -.NB00006f78: -/* 6f78: 0c013604 */ jal func0004c550 -/* 6f7c: 02002025 */ or $a0,$s0,$zero -/* 6f80: 50400006 */ beqzl $v0,.NB00006f9c -/* 6f84: 97ad0060 */ lhu $t5,0x60($sp) -/* 6f88: 8e0b0000 */ lw $t3,0x0($s0) -/* 6f8c: 356c0004 */ ori $t4,$t3,0x4 -/* 6f90: 10000043 */ beqz $zero,.NB000070a0 -/* 6f94: ae0c0000 */ sw $t4,0x0($s0) -/* 6f98: 97ad0060 */ lhu $t5,0x60($sp) -.NB00006f9c: -/* 6f9c: 27a50048 */ addiu $a1,$sp,0x48 -/* 6fa0: 02002025 */ or $a0,$s0,$zero -/* 6fa4: 31ae0001 */ andi $t6,$t5,0x1 -/* 6fa8: 55c00016 */ bnezl $t6,.NB00007004 -/* 6fac: 8fa40044 */ lw $a0,0x44($sp) -/* 6fb0: 0c013530 */ jal func0004c200 -/* 6fb4: 27a60020 */ addiu $a2,$sp,0x20 -/* 6fb8: 10400009 */ beqz $v0,.NB00006fe0 -/* 6fbc: 00402825 */ or $a1,$v0,$zero -/* 6fc0: 2401000a */ addiu $at,$zero,0xa -/* 6fc4: 14410004 */ bne $v0,$at,.NB00006fd8 -/* 6fc8: 00000000 */ sll $zero,$zero,0x0 -/* 6fcc: 8e0f0000 */ lw $t7,0x0($s0) -/* 6fd0: 35f80004 */ ori $t8,$t7,0x4 -/* 6fd4: ae180000 */ sw $t8,0x0($s0) -.NB00006fd8: -/* 6fd8: 10000031 */ beqz $zero,.NB000070a0 -/* 6fdc: 00a01025 */ or $v0,$a1,$zero -.NB00006fe0: -/* 6fe0: 97a90038 */ lhu $t1,0x38($sp) -/* 6fe4: 27b90020 */ addiu $t9,$sp,0x20 -/* 6fe8: afb90044 */ sw $t9,0x44($sp) -/* 6fec: 312a0001 */ andi $t2,$t1,0x1 -/* 6ff0: 55400004 */ bnezl $t2,.NB00007004 -/* 6ff4: 8fa40044 */ lw $a0,0x44($sp) -/* 6ff8: 10000029 */ beqz $zero,.NB000070a0 -/* 6ffc: 2402000b */ addiu $v0,$zero,0xb -/* 7000: 8fa40044 */ lw $a0,0x44($sp) -.NB00007004: -/* 7004: 2605000c */ addiu $a1,$s0,0xc -/* 7008: 0c01303c */ jal bcopy -/* 700c: 24060020 */ addiu $a2,$zero,0x20 -/* 7010: 8fab0044 */ lw $t3,0x44($sp) -/* 7014: 24190010 */ addiu $t9,$zero,0x10 -/* 7018: 24090008 */ addiu $t1,$zero,0x8 -/* 701c: 916c001b */ lbu $t4,0x1b($t3) -/* 7020: 8e040004 */ lw $a0,0x4($s0) -/* 7024: 8e050008 */ lw $a1,0x8($s0) -/* 7028: ae0c004c */ sw $t4,0x4c($s0) -/* 702c: 8fad0044 */ lw $t5,0x44($sp) -/* 7030: 24060007 */ addiu $a2,$zero,0x7 -/* 7034: 2607002c */ addiu $a3,$s0,0x2c -/* 7038: 91ae001a */ lbu $t6,0x1a($t5) -/* 703c: ae190050 */ sw $t9,0x50($s0) -/* 7040: ae090054 */ sw $t1,0x54($s0) -/* 7044: 31c200ff */ andi $v0,$t6,0xff -/* 7048: 000218c0 */ sll $v1,$v0,0x3 -/* 704c: 00027840 */ sll $t7,$v0,0x1 -/* 7050: 24680008 */ addiu $t0,$v1,0x8 -/* 7054: 25f80003 */ addiu $t8,$t7,0x3 -/* 7058: 01035021 */ addu $t2,$t0,$v1 -/* 705c: ae180060 */ sw $t8,0x60($s0) -/* 7060: ae080058 */ sw $t0,0x58($s0) -/* 7064: ae0a005c */ sw $t2,0x5c($s0) -/* 7068: 0c0131f8 */ jal __osContRamRead -/* 706c: a20e0064 */ sb $t6,0x64($s0) -/* 7070: 10400003 */ beqz $v0,.NB00007080 -/* 7074: 00402825 */ or $a1,$v0,$zero -/* 7078: 1000000a */ beqz $zero,.NB000070a4 -/* 707c: 8fbf001c */ lw $ra,0x1c($sp) -.NB00007080: -/* 7080: 3c047005 */ lui $a0,0x7005 -/* 7084: 0c00c47d */ jal crashPrint -/* 7088: 24843ad0 */ addiu $a0,$a0,0x3ad0 -/* 708c: 0c013a9c */ jal func0004d6f0 -/* 7090: 02002025 */ or $a0,$s0,$zero -/* 7094: 8e0b0000 */ lw $t3,0x0($s0) -/* 7098: 356c0001 */ ori $t4,$t3,0x1 -/* 709c: ae0c0000 */ sw $t4,0x0($s0) -.NB000070a0: -/* 70a0: 8fbf001c */ lw $ra,0x1c($sp) -.NB000070a4: -/* 70a4: 8fb00018 */ lw $s0,0x18($sp) -/* 70a8: 27bd0070 */ addiu $sp,$sp,0x70 -/* 70ac: 03e00008 */ jr $ra -/* 70b0: 00000000 */ sll $zero,$zero,0x0 -); +s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, s32 channel) #endif +{ + s32 ret; + u16 sum; + u16 isum; + u8 temp[32]; + __OSPackId *id; + __OSPackId newid; + + ret = 0; + + __osSiGetAccess(); + ret = __osPfsGetStatus(queue, channel); + __osSiRelAccess(); + + if (ret != 0) { + return ret; + } + + pfs->queue = queue; + pfs->channel = channel; + pfs->status = 0; + + ERRCK(func00006f98(pfs)); + ERRCK(__osPfsSelectBank(pfs, 0)); + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp)); + __osIdCheckSum((u16*)temp, &sum, &isum); + + id = (__OSPackId *)temp; + + if (id->checksum != sum || id->inverted_checksum != isum) { + ret = __osCheckPackId(pfs, id); + + if (ret != 0) { + pfs->status |= 4; + return ret; + } + } + + if ((id->deviceid & 1) == 0) { + ret = __osRepairPackId(pfs, id, &newid); + + if (ret != 0) { + if (ret == 10) { + pfs->status |= 4; + } + + return ret; + } + + id = &newid; + + if ((id->deviceid & 1) == 0) { + return PFS_ERR_DEVICE; + } + } + + bcopy(id, pfs->id, 0x20); + + pfs->version = id->version; + pfs->banks = id->banks; + pfs->inode_start_page = pfs->banks * 2 + 3; + pfs->dir_size = 0x10; + pfs->inode_table = 8; + pfs->minode_table = pfs->banks * PFS_ONE_PAGE + 8; + pfs->dir_table = pfs->minode_table + pfs->banks * PFS_ONE_PAGE; + +#if VERSION >= VERSION_NTSC_1_0 + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 7, pfs->label)); + ret = osPfsChecker(pfs); + pfs->status |= PFS_INITIALIZED; + + if (arg3 != NULL) { + *arg3 = func00007084(pfs); + } +#else + + ret = __osContRamRead(pfs->queue, pfs->channel, 7, pfs->label); + + if (ret != 0) { + return ret; + } + + crashPrint("pfsinitpak.c -> ret = %d\n", ret); + ret = osPfsChecker(pfs); + pfs->status |= PFS_INITIALIZED; +#endif + + return ret; +} GLOBAL_ASM( glabel func00006f98 diff --git a/src/lib/lib_4c090.c b/src/lib/lib_4c090.c index fa03789aa..7787a19e7 100644 --- a/src/lib/lib_4c090.c +++ b/src/lib/lib_4c090.c @@ -113,7 +113,7 @@ glabel func0004c090 ); GLOBAL_ASM( -glabel func0004c104 +glabel __osIdCheckSum /* 4c104: a4c00000 */ sh $zero,0x0($a2) /* 4c108: a4a00000 */ sh $zero,0x0($a1) /* 4c10c: 94820000 */ lhu $v0,0x0($a0) @@ -181,7 +181,7 @@ glabel func0004c104 ); GLOBAL_ASM( -glabel func0004c200 +glabel __osRepairPackId /* 4c200: 27bdff60 */ addiu $sp,$sp,-160 /* 4c204: afbf003c */ sw $ra,0x3c($sp) /* 4c208: afb60038 */ sw $s6,0x38($sp) @@ -336,7 +336,7 @@ glabel func0004c200 /* 4c418: a68b0018 */ sh $t3,0x18($s4) /* 4c41c: 92cc001b */ lbu $t4,0x1b($s6) /* 4c420: 2686001e */ addiu $a2,$s4,0x1e -/* 4c424: 0c013041 */ jal func0004c104 +/* 4c424: 0c013041 */ jal __osIdCheckSum /* 4c428: a28c001b */ sb $t4,0x1b($s4) /* 4c42c: 240d0001 */ addiu $t5,$zero,0x1 /* 4c430: 240e0003 */ addiu $t6,$zero,0x3 @@ -424,7 +424,7 @@ glabel func0004c200 ); GLOBAL_ASM( -glabel func0004c550 +glabel __osCheckPackId /* 4c550: 27bdffa0 */ addiu $sp,$sp,-96 /* 4c554: afbf003c */ sw $ra,0x3c($sp) /* 4c558: afb60038 */ sw $s6,0x38($sp) @@ -471,7 +471,7 @@ glabel func0004c550 /* 4c5f4: 8fbf003c */ lw $ra,0x3c($sp) .L0004c5f8: /* 4c5f8: 02802825 */ or $a1,$s4,$zero -/* 4c5fc: 0c013041 */ jal func0004c104 +/* 4c5fc: 0c013041 */ jal __osIdCheckSum /* 4c600: 02c03025 */ or $a2,$s6,$zero /* 4c604: 97a90052 */ lhu $t1,0x52($sp) /* 4c608: 964a001c */ lhu $t2,0x1c($s2) @@ -555,7 +555,7 @@ glabel func0004c6b4 /* 4c70c: 8fbf001c */ lw $ra,0x1c($sp) .L0004c710: /* 4c710: 27a5006e */ addiu $a1,$sp,0x6e -/* 4c714: 0c013041 */ jal func0004c104 +/* 4c714: 0c013041 */ jal __osIdCheckSum /* 4c718: 27a6006c */ addiu $a2,$sp,0x6c /* 4c71c: 97af006e */ lhu $t7,0x6e($sp) /* 4c720: 97b80068 */ lhu $t8,0x68($sp) @@ -567,14 +567,14 @@ glabel func0004c6b4 /* 4c738: 53290015 */ beql $t9,$t1,.L0004c790 /* 4c73c: 962a0018 */ lhu $t2,0x18($s1) .L0004c740: -/* 4c740: 0c013154 */ jal func0004c550 +/* 4c740: 0c013154 */ jal __osCheckPackId /* 4c744: 02002025 */ or $a0,$s0,$zero /* 4c748: 2401000a */ addiu $at,$zero,0xa /* 4c74c: 1441000b */ bne $v0,$at,.L0004c77c /* 4c750: 00401825 */ or $v1,$v0,$zero /* 4c754: 02002025 */ or $a0,$s0,$zero /* 4c758: 27a5004c */ addiu $a1,$sp,0x4c -/* 4c75c: 0c013080 */ jal func0004c200 +/* 4c75c: 0c013080 */ jal __osRepairPackId /* 4c760: 27a60028 */ addiu $a2,$sp,0x28 /* 4c764: 10400003 */ beqz $v0,.L0004c774 /* 4c768: 00000000 */ nop @@ -596,7 +596,7 @@ glabel func0004c6b4 /* 4c798: 314b0001 */ andi $t3,$t2,0x1 /* 4c79c: 5560000d */ bnezl $t3,.L0004c7d4 /* 4c7a0: 02202025 */ or $a0,$s1,$zero -/* 4c7a4: 0c013080 */ jal func0004c200 +/* 4c7a4: 0c013080 */ jal __osRepairPackId /* 4c7a8: 27a60028 */ addiu $a2,$sp,0x28 /* 4c7ac: 10400003 */ beqz $v0,.L0004c7bc /* 4c7b0: 97ac0040 */ lhu $t4,0x40($sp) diff --git a/src/lib/lib_4d6f0.c b/src/lib/lib_4d6f0.c index 8b2535432..64c9dc0d7 100644 --- a/src/lib/lib_4d6f0.c +++ b/src/lib/lib_4d6f0.c @@ -8,7 +8,7 @@ #include "types.h" GLOBAL_ASM( -glabel func0004d6f0 +glabel osPfsChecker /* 4d6f0: 27bdfb38 */ addiu $sp,$sp,-1224 /* 4d6f4: afbf0044 */ sw $ra,0x44($sp) /* 4d6f8: afbe0040 */ sw $s8,0x40($sp) diff --git a/src/lib/lib_51570.c b/src/lib/lib_51570.c index 34aedbc8c..ae5b042e2 100644 --- a/src/lib/lib_51570.c +++ b/src/lib/lib_51570.c @@ -58,7 +58,7 @@ glabel func000051570 /* 51614: 8fbf001c */ lw $ra,0x1c($sp) .L00051618: /* 51618: 27a5006a */ addiu $a1,$sp,0x6a -/* 5161c: 0c013041 */ jal func0004c104 +/* 5161c: 0c013041 */ jal __osIdCheckSum /* 51620: 27a60068 */ addiu $a2,$sp,0x68 /* 51624: 97b8006a */ lhu $t8,0x6a($sp) /* 51628: 97b90064 */ lhu $t9,0x64($sp) @@ -70,7 +70,7 @@ glabel func000051570 /* 51640: 512a000a */ beql $t1,$t2,.L0005166c /* 51644: 97ad0060 */ lhu $t5,0x60($sp) .L00051648: -/* 51648: 0c013154 */ jal func0004c550 +/* 51648: 0c013154 */ jal __osCheckPackId /* 5164c: 02002025 */ or $a0,$s0,$zero /* 51650: 50400006 */ beqzl $v0,.L0005166c /* 51654: 97ad0060 */ lhu $t5,0x60($sp) @@ -85,7 +85,7 @@ glabel func000051570 /* 51674: 31ae0001 */ andi $t6,$t5,0x1 /* 51678: 55c00016 */ bnezl $t6,.L000516d4 /* 5167c: 8fa40044 */ lw $a0,0x44($sp) -/* 51680: 0c013080 */ jal func0004c200 +/* 51680: 0c013080 */ jal __osRepairPackId /* 51684: 27a60020 */ addiu $a2,$sp,0x20 /* 51688: 10400009 */ beqz $v0,.L000516b0 /* 5168c: 00401825 */ or $v1,$v0,$zero @@ -141,7 +141,7 @@ glabel func000051570 /* 51748: 10000007 */ b .L00051768 /* 5174c: 8fbf001c */ lw $ra,0x1c($sp) .L00051750: -/* 51750: 0c0135bc */ jal func0004d6f0 +/* 51750: 0c0135bc */ jal osPfsChecker /* 51754: 02002025 */ or $a0,$s0,$zero /* 51758: 8e0b0000 */ lw $t3,0x0($s0) /* 5175c: 356c0001 */ ori $t4,$t3,0x1