diff --git a/src/game/game_107fb0.c b/src/game/game_107fb0.c index 8e8f64a7b..c6466338a 100644 --- a/src/game/game_107fb0.c +++ b/src/game/game_107fb0.c @@ -3919,75 +3919,37 @@ char *pakMenuTextPagesUsed(struct menuitem *item) return g_StringPointer2; } -GLOBAL_ASM( -glabel func0f10b83c -/* f10b83c: 3c058007 */ lui $a1,%hi(g_EditingPak) -/* f10b840: 8ca54a4c */ lw $a1,%lo(g_EditingPak)($a1) -/* f10b844: 27bdffe8 */ addiu $sp,$sp,-24 -/* f10b848: afbf0014 */ sw $ra,0x14($sp) -/* f10b84c: afa40018 */ sw $a0,0x18($sp) -/* f10b850: 00005025 */ or $t2,$zero,$zero -/* f10b854: 14a00005 */ bnez $a1,.L0f10b86c -/* f10b858: 00005825 */ or $t3,$zero,$zero -/* f10b85c: 0fc5b9f1 */ jal langGet -/* f10b860: 2404578e */ addiu $a0,$zero,0x578e -/* f10b864: 1000002c */ b .L0f10b918 -/* f10b868: 8fbf0014 */ lw $ra,0x14($sp) -.L0f10b86c: -/* f10b86c: 3c084e50 */ lui $t0,0x4e50 -/* f10b870: 35084445 */ ori $t0,$t0,0x4445 -/* f10b874: 00001825 */ or $v1,$zero,$zero -/* f10b878: 00a02025 */ or $a0,$a1,$zero -/* f10b87c: 24090010 */ addiu $t1,$zero,0x10 -/* f10b880: 24073459 */ addiu $a3,$zero,0x3459 -/* f10b884: 24060001 */ addiu $a2,$zero,0x1 -.L0f10b888: -/* f10b888: 8c8e0200 */ lw $t6,0x200($a0) -/* f10b88c: 00037940 */ sll $t7,$v1,0x5 -/* f10b890: 00af1021 */ addu $v0,$a1,$t7 -/* f10b894: 54ce000a */ bnel $a2,$t6,.L0f10b8c0 -/* f10b898: 240b0001 */ addiu $t3,$zero,0x1 -/* f10b89c: 94580008 */ lhu $t8,0x8($v0) -/* f10b8a0: 54f80008 */ bnel $a3,$t8,.L0f10b8c4 -/* f10b8a4: 24630001 */ addiu $v1,$v1,0x1 -/* f10b8a8: 8c590004 */ lw $t9,0x4($v0) -/* f10b8ac: 55190005 */ bnel $t0,$t9,.L0f10b8c4 -/* f10b8b0: 24630001 */ addiu $v1,$v1,0x1 -/* f10b8b4: 10000002 */ b .L0f10b8c0 -/* f10b8b8: 240a0001 */ addiu $t2,$zero,0x1 -/* f10b8bc: 240b0001 */ addiu $t3,$zero,0x1 -.L0f10b8c0: -/* f10b8c0: 24630001 */ addiu $v1,$v1,0x1 -.L0f10b8c4: -/* f10b8c4: 1469fff0 */ bne $v1,$t1,.L0f10b888 -/* f10b8c8: 24840004 */ addiu $a0,$a0,0x4 -/* f10b8cc: 51400006 */ beqzl $t2,.L0f10b8e8 -/* f10b8d0: 94ac0242 */ lhu $t4,0x242($a1) -/* f10b8d4: 0fc5b9f1 */ jal langGet -/* f10b8d8: 2404578e */ addiu $a0,$zero,0x578e -/* f10b8dc: 1000000e */ b .L0f10b918 -/* f10b8e0: 8fbf0014 */ lw $ra,0x14($sp) -/* f10b8e4: 94ac0242 */ lhu $t4,0x242($a1) -.L0f10b8e8: -/* f10b8e8: 2981001c */ slti $at,$t4,0x1c -/* f10b8ec: 14200003 */ bnez $at,.L0f10b8fc -/* f10b8f0: 00000000 */ nop -/* f10b8f4: 15600005 */ bnez $t3,.L0f10b90c -/* f10b8f8: 00000000 */ nop -.L0f10b8fc: -/* f10b8fc: 0fc5b9f1 */ jal langGet -/* f10b900: 24045790 */ addiu $a0,$zero,0x5790 -/* f10b904: 10000004 */ b .L0f10b918 -/* f10b908: 8fbf0014 */ lw $ra,0x14($sp) -.L0f10b90c: -/* f10b90c: 0fc5b9f1 */ jal langGet -/* f10b910: 2404578f */ addiu $a0,$zero,0x578f -/* f10b914: 8fbf0014 */ lw $ra,0x14($sp) -.L0f10b918: -/* f10b918: 27bd0018 */ addiu $sp,$sp,0x18 -/* f10b91c: 03e00008 */ jr $ra -/* f10b920: 00000000 */ nop -); +char *pakMenuTextStatusMessage(struct menuitem *item) +{ + s32 haspdfile = false; + s32 hasemptyfile = false; + s32 i; + + if (g_EditingPak == NULL) { + return langGet(L_OPTIONS(398)); // "Perfect Dark note already exists on this Controller Pak." + } + + for (i = 0; i < ARRAYCOUNT(g_EditingPak->filestates); i++) { + if (g_EditingPak->filesinuse[i] == true) { + if (g_EditingPak->filestates[i].company_code == ROM_COMPANYCODE + && g_EditingPak->filestates[i].game_code == ROM_GAMECODE) { + haspdfile = true; + } + } else { + hasemptyfile = true; + } + } + + if (haspdfile) { + return langGet(L_OPTIONS(398)); // "Perfect Dark note already exists on this Controller Pak." + } + + if (g_EditingPak->pagesfree < 28 || !hasemptyfile) { + return langGet(L_OPTIONS(400)); // "Controller Pak is too full to save note- 1 note and 28 pages required to save to Controller Pak." + } + + return langGet(L_OPTIONS(399)); // "There is enough space for Perfect Dark note." +} GLOBAL_ASM( glabel func0f10b924 @@ -5280,7 +5242,7 @@ struct menuitem menuitems_gamenotes[] = { { MENUITEMTYPE_LABEL, 0, 0x00000010, L_OPTIONS(389), L_OPTIONS(390), NULL }, // "Note", "Pages" { MENUITEMTYPE_LIST, 0, 0x00200000, 0x000000c8, 0x0000006e, menucustomDeleteGameNote }, { MENUITEMTYPE_LABEL, 0, 0x00000010, (u32)&pakMenuTextPagesFree, (u32)&pakMenuTextPagesUsed, NULL }, - { MENUITEMTYPE_LABEL, 0, 0x00000010, (u32)&func0f10b83c, 0x00000000, NULL }, + { MENUITEMTYPE_LABEL, 0, 0x00000010, (u32)&pakMenuTextStatusMessage, 0x00000000, NULL }, { MENUITEMTYPE_LABEL, 0, 0x00000030, L_OPTIONS(391), 0x00000000, NULL }, // "Press the B Button to exit." { MENUITEMTYPE_END, 0, 0x00000000, 0x00000000, 0x00000000, NULL }, }; diff --git a/src/include/PR/os_pfs.h b/src/include/PR/os_pfs.h index f1c92a878..f1d27b53f 100644 --- a/src/include/PR/os_pfs.h +++ b/src/include/PR/os_pfs.h @@ -44,6 +44,30 @@ extern "C" { * */ +typedef struct { + int status; + OSMesgQueue *queue; + int channel; + u8 id[32]; + u8 label[32]; + int version; + int dir_size; + int inode_table; /* block location */ + int minode_table; /* mirrioring inode_table */ + int dir_table; /* block location */ + int inode_start_page; /* page # */ + u8 banks; + u8 activebank; +} OSPfs; + +typedef struct { + u32 file_size; /* bytes */ + u32 game_code; + u16 company_code; + char ext_name[4]; + char game_name[16]; +} OSPfsState; + /************************************************************************** * * Global definitions diff --git a/src/include/constants.h b/src/include/constants.h index 6179e22a2..2970cd05e 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -26,6 +26,9 @@ #define TEXT(bankid, index) ((bankid << 9) | index) #define VOLUME(volume) (volume > 0x5000 ? 0x5000 : volume) +#define ROM_COMPANYCODE 0x3459 +#define ROM_GAMECODE 0x4e504445 // "NPDE" in ASCII + // These actions are assigned to chr->actiontype #define ACT_INIT 0 #define ACT_STAND 1 diff --git a/src/include/game/game_107fb0.h b/src/include/game/game_107fb0.h index 39b625b0d..3a97e2d0f 100644 --- a/src/include/game/game_107fb0.h +++ b/src/include/game/game_107fb0.h @@ -43,7 +43,7 @@ u32 func0f10aad8(void); void func0f10b0c4(s32 arg0); char *pakMenuTextPagesFree(struct menuitem *item); char *pakMenuTextPagesUsed(struct menuitem *item); -u32 func0f10b83c(void); +char *pakMenuTextStatusMessage(struct menuitem *item); u32 func0f10b924(void); u32 func0f10c900(void); void func0f10c970(void); diff --git a/src/include/types.h b/src/include/types.h index 3c12f164c..e411e0996 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -7145,150 +7145,8 @@ struct remoteminething { }; struct pakdata { - /*0x000*/ u32 unk000; - /*0x004*/ u32 unk004; - /*0x008*/ u32 unk008; - /*0x00c*/ u32 unk00c; - /*0x010*/ u32 unk010; - /*0x014*/ u32 unk014; - /*0x018*/ u32 unk018; - /*0x01c*/ u32 unk01c; - /*0x020*/ u32 unk020; - /*0x024*/ u32 unk024; - /*0x028*/ u32 unk028; - /*0x02c*/ u32 unk02c; - /*0x030*/ u32 unk030; - /*0x034*/ u32 unk034; - /*0x038*/ u32 unk038; - /*0x03c*/ u32 unk03c; - /*0x040*/ u32 unk040; - /*0x044*/ u32 unk044; - /*0x048*/ u32 unk048; - /*0x04c*/ u32 unk04c; - /*0x050*/ u32 unk050; - /*0x054*/ u32 unk054; - /*0x058*/ u32 unk058; - /*0x05c*/ u32 unk05c; - /*0x060*/ u32 unk060; - /*0x064*/ u32 unk064; - /*0x068*/ u32 unk068; - /*0x06c*/ u32 unk06c; - /*0x070*/ u32 unk070; - /*0x074*/ u32 unk074; - /*0x078*/ u32 unk078; - /*0x07c*/ u32 unk07c; - /*0x080*/ u32 unk080; - /*0x084*/ u32 unk084; - /*0x088*/ u32 unk088; - /*0x08c*/ u32 unk08c; - /*0x090*/ u32 unk090; - /*0x094*/ u32 unk094; - /*0x098*/ u32 unk098; - /*0x09c*/ u32 unk09c; - /*0x0a0*/ u32 unk0a0; - /*0x0a4*/ u32 unk0a4; - /*0x0a8*/ u32 unk0a8; - /*0x0ac*/ u32 unk0ac; - /*0x0b0*/ u32 unk0b0; - /*0x0b4*/ u32 unk0b4; - /*0x0b8*/ u32 unk0b8; - /*0x0bc*/ u32 unk0bc; - /*0x0c0*/ u32 unk0c0; - /*0x0c4*/ u32 unk0c4; - /*0x0c8*/ u32 unk0c8; - /*0x0cc*/ u32 unk0cc; - /*0x0d0*/ u32 unk0d0; - /*0x0d4*/ u32 unk0d4; - /*0x0d8*/ u32 unk0d8; - /*0x0dc*/ u32 unk0dc; - /*0x0e0*/ u32 unk0e0; - /*0x0e4*/ u32 unk0e4; - /*0x0e8*/ u32 unk0e8; - /*0x0ec*/ u32 unk0ec; - /*0x0f0*/ u32 unk0f0; - /*0x0f4*/ u32 unk0f4; - /*0x0f8*/ u32 unk0f8; - /*0x0fc*/ u32 unk0fc; - /*0x100*/ u32 unk100; - /*0x104*/ u32 unk104; - /*0x108*/ u32 unk108; - /*0x10c*/ u32 unk10c; - /*0x110*/ u32 unk110; - /*0x114*/ u32 unk114; - /*0x118*/ u32 unk118; - /*0x11c*/ u32 unk11c; - /*0x120*/ u32 unk120; - /*0x124*/ u32 unk124; - /*0x128*/ u32 unk128; - /*0x12c*/ u32 unk12c; - /*0x130*/ u32 unk130; - /*0x134*/ u32 unk134; - /*0x138*/ u32 unk138; - /*0x13c*/ u32 unk13c; - /*0x140*/ u32 unk140; - /*0x144*/ u32 unk144; - /*0x148*/ u32 unk148; - /*0x14c*/ u32 unk14c; - /*0x150*/ u32 unk150; - /*0x154*/ u32 unk154; - /*0x158*/ u32 unk158; - /*0x15c*/ u32 unk15c; - /*0x160*/ u32 unk160; - /*0x164*/ u32 unk164; - /*0x168*/ u32 unk168; - /*0x16c*/ u32 unk16c; - /*0x170*/ u32 unk170; - /*0x174*/ u32 unk174; - /*0x178*/ u32 unk178; - /*0x17c*/ u32 unk17c; - /*0x180*/ u32 unk180; - /*0x184*/ u32 unk184; - /*0x188*/ u32 unk188; - /*0x18c*/ u32 unk18c; - /*0x190*/ u32 unk190; - /*0x194*/ u32 unk194; - /*0x198*/ u32 unk198; - /*0x19c*/ u32 unk19c; - /*0x1a0*/ u32 unk1a0; - /*0x1a4*/ u32 unk1a4; - /*0x1a8*/ u32 unk1a8; - /*0x1ac*/ u32 unk1ac; - /*0x1b0*/ u32 unk1b0; - /*0x1b4*/ u32 unk1b4; - /*0x1b8*/ u32 unk1b8; - /*0x1bc*/ u32 unk1bc; - /*0x1c0*/ u32 unk1c0; - /*0x1c4*/ u32 unk1c4; - /*0x1c8*/ u32 unk1c8; - /*0x1cc*/ u32 unk1cc; - /*0x1d0*/ u32 unk1d0; - /*0x1d4*/ u32 unk1d4; - /*0x1d8*/ u32 unk1d8; - /*0x1dc*/ u32 unk1dc; - /*0x1e0*/ u32 unk1e0; - /*0x1e4*/ u32 unk1e4; - /*0x1e8*/ u32 unk1e8; - /*0x1ec*/ u32 unk1ec; - /*0x1f0*/ u32 unk1f0; - /*0x1f4*/ u32 unk1f4; - /*0x1f8*/ u32 unk1f8; - /*0x1fc*/ u32 unk1fc; - /*0x200*/ u32 unk200; - /*0x204*/ u32 unk204; - /*0x208*/ u32 unk208; - /*0x20c*/ u32 unk20c; - /*0x210*/ u32 unk210; - /*0x214*/ u32 unk214; - /*0x218*/ u32 unk218; - /*0x21c*/ u32 unk21c; - /*0x220*/ u32 unk220; - /*0x224*/ u32 unk224; - /*0x228*/ u32 unk228; - /*0x22c*/ u32 unk22c; - /*0x230*/ u32 unk230; - /*0x234*/ u32 unk234; - /*0x238*/ u32 unk238; - /*0x23c*/ u32 unk23c; + /*0x000*/ OSPfsState filestates[16]; + /*0x200*/ bool filesinuse[16]; /*0x240*/ u16 pagesused; /*0x242*/ u16 pagesfree; };