From 958a36bbb889d9b0231fb3ad9cd62a2bae0d9151 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 11 Oct 2022 01:53:28 +0300 Subject: [PATCH] Add CMemoryCardDriver::Update Former-commit-id: 45e15781667e9efd343bc6a0c0a23a280e4eb6e8 --- asm/MetroidPrime/CMemoryCardDriver.s | 111 +++++++++---------- include/Kyoto/CMemoryCardSys.hpp | 29 +++-- include/MetroidPrime/CMain.hpp | 1 + include/MetroidPrime/CMemoryCardDriver.hpp | 118 ++++++++++----------- src/MetroidPrime/CMemoryCardDriver.cpp | 99 ++++++++++++++--- 5 files changed, 215 insertions(+), 143 deletions(-) diff --git a/asm/MetroidPrime/CMemoryCardDriver.s b/asm/MetroidPrime/CMemoryCardDriver.s index 90c142fb..34f102bb 100644 --- a/asm/MetroidPrime/CMemoryCardDriver.s +++ b/asm/MetroidPrime/CMemoryCardDriver.s @@ -1349,7 +1349,7 @@ StartCardFormat__17CMemoryCardDriverFv: /* 8024D40C 0024A36C 7C 64 1B 79 */ or. r4, r3, r3 /* 8024D410 0024A370 41 82 00 0C */ beq lbl_8024D41C /* 8024D414 0024A374 7F E3 FB 78 */ mr r3, r31 -/* 8024D418 0024A378 48 00 0A D1 */ bl UpdateCardFormat__17CMemoryCardDriverFv +/* 8024D418 0024A378 48 00 0A D1 */ bl UpdateCardFormat__17CMemoryCardDriverF11ECardResult lbl_8024D41C: /* 8024D41C 0024A37C 80 01 00 14 */ lwz r0, 0x14(r1) /* 8024D420 0024A380 83 E1 00 0C */ lwz r31, 0xc(r1) @@ -1387,7 +1387,7 @@ StartFileDeleteAltTransactional__17CMemoryCardDriverFv: /* 8024D494 0024A3F4 41 82 00 10 */ beq lbl_8024D4A4 /* 8024D498 0024A3F8 7F C3 F3 78 */ mr r3, r30 /* 8024D49C 0024A3FC 7F E4 FB 78 */ mr r4, r31 -/* 8024D4A0 0024A400 48 00 0A 9D */ bl UpdateFileAltDeleteTransactional__17CMemoryCardDriverFv +/* 8024D4A0 0024A400 48 00 0A 9D */ bl UpdateFileAltDeleteTransactional__17CMemoryCardDriverF11ECardResult lbl_8024D4A4: /* 8024D4A4 0024A404 80 01 00 24 */ lwz r0, 0x24(r1) /* 8024D4A8 0024A408 83 E1 00 1C */ lwz r31, 0x1c(r1) @@ -1412,7 +1412,7 @@ StartFileWriteTransactional__17CMemoryCardDriverFv: /* 8024D4E8 0024A448 7C 64 1B 79 */ or. r4, r3, r3 /* 8024D4EC 0024A44C 41 82 00 0C */ beq lbl_8024D4F8 /* 8024D4F0 0024A450 7F E3 FB 78 */ mr r3, r31 -/* 8024D4F4 0024A454 48 00 0B ED */ bl UpdateFileWriteTransactional__17CMemoryCardDriverFv +/* 8024D4F4 0024A454 48 00 0B ED */ bl UpdateFileWriteTransactional__17CMemoryCardDriverF11ECardResult lbl_8024D4F8: /* 8024D4F8 0024A458 80 01 00 14 */ lwz r0, 0x14(r1) /* 8024D4FC 0024A45C 83 E1 00 0C */ lwz r31, 0xc(r1) @@ -1488,7 +1488,7 @@ lbl_8024D5E8: /* 8024D5F8 0024A558 7C 64 1B 79 */ or. r4, r3, r3 /* 8024D5FC 0024A55C 41 82 00 0C */ beq lbl_8024D608 /* 8024D600 0024A560 7F E3 FB 78 */ mr r3, r31 -/* 8024D604 0024A564 48 00 0B 85 */ bl UpdateFileCreateTransactional__17CMemoryCardDriverFv +/* 8024D604 0024A564 48 00 0B 85 */ bl UpdateFileCreateTransactional__17CMemoryCardDriverF11ECardResult lbl_8024D608: /* 8024D608 0024A568 80 01 00 34 */ lwz r0, 0x34(r1) /* 8024D60C 0024A56C 83 E1 00 2C */ lwz r31, 0x2c(r1) @@ -1650,7 +1650,7 @@ StartFileWrite__17CMemoryCardDriverFv: /* 8024D81C 0024A77C 7C 64 1B 79 */ or. r4, r3, r3 /* 8024D820 0024A780 41 82 00 0C */ beq lbl_8024D82C /* 8024D824 0024A784 7F E3 FB 78 */ mr r3, r31 -/* 8024D828 0024A788 48 00 09 9D */ bl UpdateFileWrite__17CMemoryCardDriverFv +/* 8024D828 0024A788 48 00 09 9D */ bl UpdateFileWrite__17CMemoryCardDriverF11ECardResult lbl_8024D82C: /* 8024D82C 0024A78C 80 01 00 14 */ lwz r0, 0x14(r1) /* 8024D830 0024A790 83 E1 00 0C */ lwz r31, 0xc(r1) @@ -1722,7 +1722,7 @@ lbl_8024D90C: /* 8024D91C 0024A87C 7C 64 1B 79 */ or. r4, r3, r3 /* 8024D920 0024A880 41 82 00 0C */ beq lbl_8024D92C /* 8024D924 0024A884 7F E3 FB 78 */ mr r3, r31 -/* 8024D928 0024A888 48 00 09 39 */ bl UpdateFileCreate__17CMemoryCardDriverFv +/* 8024D928 0024A888 48 00 09 39 */ bl UpdateFileCreate__17CMemoryCardDriverF11ECardResult lbl_8024D92C: /* 8024D92C 0024A88C 80 01 00 34 */ lwz r0, 0x34(r1) /* 8024D930 0024A890 83 E1 00 2C */ lwz r31, 0x2c(r1) @@ -1753,7 +1753,7 @@ StartFileRead__17CMemoryCardDriverFv: /* 8024D988 0024A8E8 7C 64 1B 79 */ or. r4, r3, r3 /* 8024D98C 0024A8EC 41 82 00 10 */ beq lbl_8024D99C /* 8024D990 0024A8F0 7F C3 F3 78 */ mr r3, r30 -/* 8024D994 0024A8F4 48 00 09 F9 */ bl UpdateFileRead__17CMemoryCardDriverFv +/* 8024D994 0024A8F4 48 00 09 F9 */ bl UpdateFileRead__17CMemoryCardDriverF11ECardResult /* 8024D998 0024A8F8 48 00 00 28 */ b lbl_8024D9C0 lbl_8024D99C: /* 8024D99C 0024A8FC 80 1E 01 94 */ lwz r0, 0x194(r30) @@ -1764,7 +1764,7 @@ lbl_8024D99C: /* 8024D9B0 0024A910 7C 64 1B 79 */ or. r4, r3, r3 /* 8024D9B4 0024A914 41 82 00 0C */ beq lbl_8024D9C0 /* 8024D9B8 0024A918 7F C3 F3 78 */ mr r3, r30 -/* 8024D9BC 0024A91C 48 00 09 D1 */ bl UpdateFileRead__17CMemoryCardDriverFv +/* 8024D9BC 0024A91C 48 00 09 D1 */ bl UpdateFileRead__17CMemoryCardDriverF11ECardResult lbl_8024D9C0: /* 8024D9C0 0024A920 80 01 00 14 */ lwz r0, 0x14(r1) /* 8024D9C4 0024A924 83 E1 00 0C */ lwz r31, 0xc(r1) @@ -1797,7 +1797,7 @@ StartFileDeleteAlt__17CMemoryCardDriverFv: /* 8024DA24 0024A984 7C 64 1B 79 */ or. r4, r3, r3 /* 8024DA28 0024A988 41 82 00 0C */ beq lbl_8024DA34 /* 8024DA2C 0024A98C 7F E3 FB 78 */ mr r3, r31 -/* 8024DA30 0024A990 48 00 09 05 */ bl UpdateFileDeleteAlt__17CMemoryCardDriverFv +/* 8024DA30 0024A990 48 00 09 05 */ bl UpdateFileDeleteAlt__17CMemoryCardDriverF11ECardResult lbl_8024DA34: /* 8024DA34 0024A994 80 01 00 14 */ lwz r0, 0x14(r1) /* 8024DA38 0024A998 83 E1 00 0C */ lwz r31, 0xc(r1) @@ -1833,7 +1833,7 @@ lbl_8024DA7C: /* 8024DAA0 0024AA00 7C 64 1B 79 */ or. r4, r3, r3 /* 8024DAA4 0024AA04 41 82 00 1C */ beq lbl_8024DAC0 /* 8024DAA8 0024AA08 7F E3 FB 78 */ mr r3, r31 -/* 8024DAAC 0024AA0C 48 00 07 F1 */ bl UpdateFileDeleteBad__17CMemoryCardDriverFv +/* 8024DAAC 0024AA0C 48 00 07 F1 */ bl UpdateFileDeleteBad__17CMemoryCardDriverF11ECardResult /* 8024DAB0 0024AA10 48 00 00 10 */ b lbl_8024DAC0 lbl_8024DAB4: /* 8024DAB4 0024AA14 38 84 00 48 */ addi r4, r4, 0x48 @@ -2057,7 +2057,7 @@ StartCardCheck__17CMemoryCardDriverFv: /* 8024DD94 0024ACF4 7C 64 1B 79 */ or. r4, r3, r3 /* 8024DD98 0024ACF8 41 82 00 0C */ beq lbl_8024DDA4 /* 8024DD9C 0024ACFC 7F E3 FB 78 */ mr r3, r31 -/* 8024DDA0 0024AD00 48 00 07 19 */ bl UpdateCardCheck__17CMemoryCardDriverFv +/* 8024DDA0 0024AD00 48 00 07 19 */ bl UpdateCardCheck__17CMemoryCardDriverF11ECardResult lbl_8024DDA4: /* 8024DDA4 0024AD04 80 01 00 14 */ lwz r0, 0x14(r1) /* 8024DDA8 0024AD08 83 E1 00 0C */ lwz r31, 0xc(r1) @@ -2081,7 +2081,7 @@ StartMountCard__17CMemoryCardDriverFv: /* 8024DDE4 0024AD44 7C 64 1B 79 */ or. r4, r3, r3 /* 8024DDE8 0024AD48 41 82 00 0C */ beq lbl_8024DDF4 /* 8024DDEC 0024AD4C 7F E3 FB 78 */ mr r3, r31 -/* 8024DDF0 0024AD50 48 00 07 51 */ bl UpdateMountCard__17CMemoryCardDriverFi +/* 8024DDF0 0024AD50 48 00 07 51 */ bl UpdateMountCard__17CMemoryCardDriverF11ECardResult lbl_8024DDF4: /* 8024DDF4 0024AD54 80 01 00 14 */ lwz r0, 0x14(r1) /* 8024DDF8 0024AD58 83 E1 00 0C */ lwz r31, 0xc(r1) @@ -2155,8 +2155,8 @@ StartCardProbe__17CMemoryCardDriverFv: /* 8024DEE0 0024AE40 38 21 00 10 */ addi r1, r1, 0x10 /* 8024DEE4 0024AE44 4E 80 00 20 */ blr -.global UpdateCardFormat__17CMemoryCardDriverFv -UpdateCardFormat__17CMemoryCardDriverFv: +.global UpdateCardFormat__17CMemoryCardDriverF11ECardResult +UpdateCardFormat__17CMemoryCardDriverF11ECardResult: /* 8024DEE8 0024AE48 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024DEEC 0024AE4C 7C 08 02 A6 */ mflr r0 /* 8024DEF0 0024AE50 2C 04 00 00 */ cmpwi r4, 0 @@ -2182,8 +2182,8 @@ lbl_8024DF2C: /* 8024DF34 0024AE94 38 21 00 10 */ addi r1, r1, 0x10 /* 8024DF38 0024AE98 4E 80 00 20 */ blr -.global UpdateFileAltDeleteTransactional__17CMemoryCardDriverFv -UpdateFileAltDeleteTransactional__17CMemoryCardDriverFv: +.global UpdateFileAltDeleteTransactional__17CMemoryCardDriverF11ECardResult +UpdateFileAltDeleteTransactional__17CMemoryCardDriverF11ECardResult: /* 8024DF3C 0024AE9C 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024DF40 0024AEA0 7C 08 02 A6 */ mflr r0 /* 8024DF44 0024AEA4 2C 04 00 00 */ cmpwi r4, 0 @@ -2271,7 +2271,7 @@ StartFileRenameBtoA__17CMemoryCardDriverFv: /* 8024E06C 0024AFCC 41 82 00 20 */ beq lbl_8024E08C /* 8024E070 0024AFD0 7F C3 F3 78 */ mr r3, r30 /* 8024E074 0024AFD4 7F E4 FB 78 */ mr r4, r31 -/* 8024E078 0024AFD8 48 00 00 2D */ bl UpdateFileRenameBtoA__17CMemoryCardDriverFv +/* 8024E078 0024AFD8 48 00 00 2D */ bl UpdateFileRenameBtoA__17CMemoryCardDriverF11ECardResult /* 8024E07C 0024AFDC 48 00 00 10 */ b lbl_8024E08C lbl_8024E080: /* 8024E080 0024AFE0 38 00 00 03 */ li r0, 3 @@ -2285,8 +2285,8 @@ lbl_8024E08C: /* 8024E09C 0024AFFC 38 21 00 30 */ addi r1, r1, 0x30 /* 8024E0A0 0024B000 4E 80 00 20 */ blr -.global UpdateFileRenameBtoA__17CMemoryCardDriverFv -UpdateFileRenameBtoA__17CMemoryCardDriverFv: +.global UpdateFileRenameBtoA__17CMemoryCardDriverF11ECardResult +UpdateFileRenameBtoA__17CMemoryCardDriverF11ECardResult: /* 8024E0A4 0024B004 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024E0A8 0024B008 7C 08 02 A6 */ mflr r0 /* 8024E0AC 0024B00C 2C 04 00 00 */ cmpwi r4, 0 @@ -2305,8 +2305,8 @@ lbl_8024E0D0: /* 8024E0D8 0024B038 38 21 00 10 */ addi r1, r1, 0x10 /* 8024E0DC 0024B03C 4E 80 00 20 */ blr -.global UpdateFileWriteTransactional__17CMemoryCardDriverFv -UpdateFileWriteTransactional__17CMemoryCardDriverFv: +.global UpdateFileWriteTransactional__17CMemoryCardDriverF11ECardResult +UpdateFileWriteTransactional__17CMemoryCardDriverF11ECardResult: /* 8024E0E0 0024B040 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024E0E4 0024B044 7C 08 02 A6 */ mflr r0 /* 8024E0E8 0024B048 2C 04 00 00 */ cmpwi r4, 0 @@ -2355,8 +2355,8 @@ lbl_8024E174: /* 8024E180 0024B0E0 38 21 00 10 */ addi r1, r1, 0x10 /* 8024E184 0024B0E4 4E 80 00 20 */ blr -.global UpdateFileCreateTransactional__17CMemoryCardDriverFv -UpdateFileCreateTransactional__17CMemoryCardDriverFv: +.global UpdateFileCreateTransactional__17CMemoryCardDriverF11ECardResult +UpdateFileCreateTransactional__17CMemoryCardDriverF11ECardResult: /* 8024E188 0024B0E8 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024E18C 0024B0EC 7C 08 02 A6 */ mflr r0 /* 8024E190 0024B0F0 2C 04 00 00 */ cmpwi r4, 0 @@ -2375,8 +2375,8 @@ lbl_8024E1B4: /* 8024E1BC 0024B11C 38 21 00 10 */ addi r1, r1, 0x10 /* 8024E1C0 0024B120 4E 80 00 20 */ blr -.global UpdateFileWrite__17CMemoryCardDriverFv -UpdateFileWrite__17CMemoryCardDriverFv: +.global UpdateFileWrite__17CMemoryCardDriverF11ECardResult +UpdateFileWrite__17CMemoryCardDriverF11ECardResult: /* 8024E1C4 0024B124 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024E1C8 0024B128 7C 08 02 A6 */ mflr r0 /* 8024E1CC 0024B12C 2C 04 00 00 */ cmpwi r4, 0 @@ -2421,8 +2421,8 @@ lbl_8024E24C: /* 8024E258 0024B1B8 38 21 00 10 */ addi r1, r1, 0x10 /* 8024E25C 0024B1BC 4E 80 00 20 */ blr -.global UpdateFileCreate__17CMemoryCardDriverFv -UpdateFileCreate__17CMemoryCardDriverFv: +.global UpdateFileCreate__17CMemoryCardDriverF11ECardResult +UpdateFileCreate__17CMemoryCardDriverF11ECardResult: /* 8024E260 0024B1C0 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024E264 0024B1C4 7C 08 02 A6 */ mflr r0 /* 8024E268 0024B1C8 2C 04 00 00 */ cmpwi r4, 0 @@ -2441,8 +2441,8 @@ lbl_8024E28C: /* 8024E294 0024B1F4 38 21 00 10 */ addi r1, r1, 0x10 /* 8024E298 0024B1F8 4E 80 00 20 */ blr -.global UpdateFileDeleteBad__17CMemoryCardDriverFv -UpdateFileDeleteBad__17CMemoryCardDriverFv: +.global UpdateFileDeleteBad__17CMemoryCardDriverF11ECardResult +UpdateFileDeleteBad__17CMemoryCardDriverF11ECardResult: /* 8024E29C 0024B1FC 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024E2A0 0024B200 7C 08 02 A6 */ mflr r0 /* 8024E2A4 0024B204 2C 04 00 00 */ cmpwi r4, 0 @@ -2485,8 +2485,8 @@ lbl_8024E320: /* 8024E32C 0024B28C 38 21 00 10 */ addi r1, r1, 0x10 /* 8024E330 0024B290 4E 80 00 20 */ blr -.global UpdateFileDeleteAlt__17CMemoryCardDriverFv -UpdateFileDeleteAlt__17CMemoryCardDriverFv: +.global UpdateFileDeleteAlt__17CMemoryCardDriverF11ECardResult +UpdateFileDeleteAlt__17CMemoryCardDriverF11ECardResult: /* 8024E334 0024B294 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024E338 0024B298 7C 08 02 A6 */ mflr r0 /* 8024E33C 0024B29C 2C 04 00 00 */ cmpwi r4, 0 @@ -2512,8 +2512,8 @@ lbl_8024E378: /* 8024E384 0024B2E4 38 21 00 10 */ addi r1, r1, 0x10 /* 8024E388 0024B2E8 4E 80 00 20 */ blr -.global UpdateFileRead__17CMemoryCardDriverFv -UpdateFileRead__17CMemoryCardDriverFv: +.global UpdateFileRead__17CMemoryCardDriverF11ECardResult +UpdateFileRead__17CMemoryCardDriverF11ECardResult: /* 8024E38C 0024B2EC 94 21 FF E0 */ stwu r1, -0x20(r1) /* 8024E390 0024B2F0 7C 08 02 A6 */ mflr r0 /* 8024E394 0024B2F4 2C 04 00 00 */ cmpwi r4, 0 @@ -2596,8 +2596,8 @@ lbl_8024E498: /* 8024E4B0 0024B410 38 21 00 20 */ addi r1, r1, 0x20 /* 8024E4B4 0024B414 4E 80 00 20 */ blr -.global UpdateCardCheck__17CMemoryCardDriverFv -UpdateCardCheck__17CMemoryCardDriverFv: +.global UpdateCardCheck__17CMemoryCardDriverF11ECardResult +UpdateCardCheck__17CMemoryCardDriverF11ECardResult: /* 8024E4B8 0024B418 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024E4BC 0024B41C 7C 08 02 A6 */ mflr r0 /* 8024E4C0 0024B420 2C 04 00 00 */ cmpwi r4, 0 @@ -2636,8 +2636,8 @@ lbl_8024E52C: /* 8024E538 0024B498 38 21 00 10 */ addi r1, r1, 0x10 /* 8024E53C 0024B49C 4E 80 00 20 */ blr -.global UpdateMountCard__17CMemoryCardDriverFi -UpdateMountCard__17CMemoryCardDriverFi: +.global UpdateMountCard__17CMemoryCardDriverF11ECardResult +UpdateMountCard__17CMemoryCardDriverF11ECardResult: /* 8024E540 0024B4A0 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024E544 0024B4A4 7C 08 02 A6 */ mflr r0 /* 8024E548 0024B4A8 2C 04 00 00 */ cmpwi r4, 0 @@ -2772,78 +2772,65 @@ lbl_8024E6B0: /* 8024E6F4 0024B654 7C 03 00 2E */ lwzx r0, r3, r0 /* 8024E6F8 0024B658 7C 09 03 A6 */ mtctr r0 /* 8024E6FC 0024B65C 4E 80 04 20 */ bctr -.global lbl_8024E700 lbl_8024E700: /* 8024E700 0024B660 7F A3 EB 78 */ mr r3, r29 /* 8024E704 0024B664 7F E4 FB 78 */ mr r4, r31 -/* 8024E708 0024B668 4B FF FE 39 */ bl UpdateMountCard__17CMemoryCardDriverFi +/* 8024E708 0024B668 4B FF FE 39 */ bl UpdateMountCard__17CMemoryCardDriverF11ECardResult /* 8024E70C 0024B66C 48 00 00 B0 */ b lbl_8024E7BC -.global lbl_8024E710 lbl_8024E710: /* 8024E710 0024B670 7F A3 EB 78 */ mr r3, r29 /* 8024E714 0024B674 7F E4 FB 78 */ mr r4, r31 -/* 8024E718 0024B678 4B FF FD A1 */ bl UpdateCardCheck__17CMemoryCardDriverFv +/* 8024E718 0024B678 4B FF FD A1 */ bl UpdateCardCheck__17CMemoryCardDriverF11ECardResult /* 8024E71C 0024B67C 48 00 00 A0 */ b lbl_8024E7BC -.global lbl_8024E720 lbl_8024E720: /* 8024E720 0024B680 7F A3 EB 78 */ mr r3, r29 /* 8024E724 0024B684 7F E4 FB 78 */ mr r4, r31 -/* 8024E728 0024B688 4B FF FB 75 */ bl UpdateFileDeleteBad__17CMemoryCardDriverFv +/* 8024E728 0024B688 4B FF FB 75 */ bl UpdateFileDeleteBad__17CMemoryCardDriverF11ECardResult /* 8024E72C 0024B68C 48 00 00 90 */ b lbl_8024E7BC -.global lbl_8024E730 lbl_8024E730: /* 8024E730 0024B690 7F A3 EB 78 */ mr r3, r29 /* 8024E734 0024B694 7F E4 FB 78 */ mr r4, r31 -/* 8024E738 0024B698 4B FF FC 55 */ bl UpdateFileRead__17CMemoryCardDriverFv +/* 8024E738 0024B698 4B FF FC 55 */ bl UpdateFileRead__17CMemoryCardDriverF11ECardResult /* 8024E73C 0024B69C 48 00 00 80 */ b lbl_8024E7BC -.global lbl_8024E740 lbl_8024E740: /* 8024E740 0024B6A0 7F A3 EB 78 */ mr r3, r29 /* 8024E744 0024B6A4 7F E4 FB 78 */ mr r4, r31 -/* 8024E748 0024B6A8 4B FF FB ED */ bl UpdateFileDeleteAlt__17CMemoryCardDriverFv +/* 8024E748 0024B6A8 4B FF FB ED */ bl UpdateFileDeleteAlt__17CMemoryCardDriverF11ECardResult /* 8024E74C 0024B6AC 48 00 00 70 */ b lbl_8024E7BC -.global lbl_8024E750 lbl_8024E750: /* 8024E750 0024B6B0 7F A3 EB 78 */ mr r3, r29 /* 8024E754 0024B6B4 7F E4 FB 78 */ mr r4, r31 -/* 8024E758 0024B6B8 4B FF FB 09 */ bl UpdateFileCreate__17CMemoryCardDriverFv +/* 8024E758 0024B6B8 4B FF FB 09 */ bl UpdateFileCreate__17CMemoryCardDriverF11ECardResult /* 8024E75C 0024B6BC 48 00 00 60 */ b lbl_8024E7BC -.global lbl_8024E760 lbl_8024E760: /* 8024E760 0024B6C0 7F A3 EB 78 */ mr r3, r29 /* 8024E764 0024B6C4 7F E4 FB 78 */ mr r4, r31 -/* 8024E768 0024B6C8 4B FF FA 5D */ bl UpdateFileWrite__17CMemoryCardDriverFv +/* 8024E768 0024B6C8 4B FF FA 5D */ bl UpdateFileWrite__17CMemoryCardDriverF11ECardResult /* 8024E76C 0024B6CC 48 00 00 50 */ b lbl_8024E7BC -.global lbl_8024E770 lbl_8024E770: /* 8024E770 0024B6D0 7F A3 EB 78 */ mr r3, r29 /* 8024E774 0024B6D4 7F E4 FB 78 */ mr r4, r31 -/* 8024E778 0024B6D8 4B FF FA 11 */ bl UpdateFileCreateTransactional__17CMemoryCardDriverFv +/* 8024E778 0024B6D8 4B FF FA 11 */ bl UpdateFileCreateTransactional__17CMemoryCardDriverF11ECardResult /* 8024E77C 0024B6DC 48 00 00 40 */ b lbl_8024E7BC -.global lbl_8024E780 lbl_8024E780: /* 8024E780 0024B6E0 7F A3 EB 78 */ mr r3, r29 /* 8024E784 0024B6E4 7F E4 FB 78 */ mr r4, r31 -/* 8024E788 0024B6E8 4B FF F9 59 */ bl UpdateFileWriteTransactional__17CMemoryCardDriverFv +/* 8024E788 0024B6E8 4B FF F9 59 */ bl UpdateFileWriteTransactional__17CMemoryCardDriverF11ECardResult /* 8024E78C 0024B6EC 48 00 00 30 */ b lbl_8024E7BC -.global lbl_8024E790 lbl_8024E790: /* 8024E790 0024B6F0 7F A3 EB 78 */ mr r3, r29 /* 8024E794 0024B6F4 7F E4 FB 78 */ mr r4, r31 -/* 8024E798 0024B6F8 4B FF F7 A5 */ bl UpdateFileAltDeleteTransactional__17CMemoryCardDriverFv +/* 8024E798 0024B6F8 4B FF F7 A5 */ bl UpdateFileAltDeleteTransactional__17CMemoryCardDriverF11ECardResult /* 8024E79C 0024B6FC 48 00 00 20 */ b lbl_8024E7BC -.global lbl_8024E7A0 lbl_8024E7A0: /* 8024E7A0 0024B700 7F A3 EB 78 */ mr r3, r29 /* 8024E7A4 0024B704 7F E4 FB 78 */ mr r4, r31 -/* 8024E7A8 0024B708 4B FF F8 FD */ bl UpdateFileRenameBtoA__17CMemoryCardDriverFv +/* 8024E7A8 0024B708 4B FF F8 FD */ bl UpdateFileRenameBtoA__17CMemoryCardDriverF11ECardResult /* 8024E7AC 0024B70C 48 00 00 10 */ b lbl_8024E7BC -.global lbl_8024E7B0 lbl_8024E7B0: /* 8024E7B0 0024B710 7F A3 EB 78 */ mr r3, r29 /* 8024E7B4 0024B714 7F E4 FB 78 */ mr r4, r31 -/* 8024E7B8 0024B718 4B FF F7 31 */ bl UpdateCardFormat__17CMemoryCardDriverFv -.global lbl_8024E7BC +/* 8024E7B8 0024B718 4B FF F7 31 */ bl UpdateCardFormat__17CMemoryCardDriverF11ECardResult lbl_8024E7BC: /* 8024E7BC 0024B71C 80 6D A0 78 */ lwz r3, gpMain@sda21(r13) /* 8024E7C0 0024B720 88 03 01 60 */ lbz r0, 0x160(r3) diff --git a/include/Kyoto/CMemoryCardSys.hpp b/include/Kyoto/CMemoryCardSys.hpp index a13f4422..6a779bbc 100644 --- a/include/Kyoto/CMemoryCardSys.hpp +++ b/include/Kyoto/CMemoryCardSys.hpp @@ -4,24 +4,41 @@ #include "types.h" // TODO: likely comes from dolphin sdk -enum ECardSlot { kCS_SlotA, kCS_SlotB }; -enum ECardResult { k_READY }; -struct FileHandle {}; +enum ECardResult { k_READY, k_NOCARD = -3 }; +struct FileHandle { + u8 x0_pad[0x10]; +}; + +struct ProbeResults { + ECardResult x0_error; + uint x4_cardSize; /* in megabits */ + uint x8_sectorSize; /* in bytes */ +}; class CMemoryCardSys { public: + enum EMemoryCardPort { kCS_SlotA, kCS_SlotB }; + struct CardFileHandle { - ECardSlot slot; + EMemoryCardPort slot; FileHandle handle; - CardFileHandle(ECardSlot slot) : slot(slot) {} + CardFileHandle(EMemoryCardPort slot) : slot(slot) {} int getFileNo() const; }; - struct CCardFileInfo {}; + class CCardFileInfo { + uchar pad[0x114]; + + public: + ~CCardFileInfo(); + }; CMemoryCardSys(); ~CMemoryCardSys(); + static ECardResult GetResultCode(int); + static ProbeResults IsMemoryCardInserted(EMemoryCardPort); + void Initialize(); private: diff --git a/include/MetroidPrime/CMain.hpp b/include/MetroidPrime/CMain.hpp index 898a89df..a0e81a1b 100644 --- a/include/MetroidPrime/CMain.hpp +++ b/include/MetroidPrime/CMain.hpp @@ -78,6 +78,7 @@ public: bool CheckReset(); void OpenWindow(); void SetRestartMode(ERestartMode s) { x12c_restartMode = s; } + void SetCardBusy(bool v) { x160_31_cardBusy = v; } void SetMaxSpeed(bool v) { // ? diff --git a/include/MetroidPrime/CMemoryCardDriver.hpp b/include/MetroidPrime/CMemoryCardDriver.hpp index ae27a410..c631669c 100644 --- a/include/MetroidPrime/CMemoryCardDriver.hpp +++ b/include/MetroidPrime/CMemoryCardDriver.hpp @@ -17,14 +17,13 @@ struct SMemoryCardFileInfo { rstl::string x14_name; rstl::vector< u8 > x24_saveFileData; rstl::vector< u8 > x34_saveData; - + SMemoryCardFileInfo(int cardPort, const rstl::string& name); SMemoryCardFileInfo(const SMemoryCardFileInfo& other) : x0_fileInfo(other.x0_fileInfo) , x14_name(other.x14_name) , x24_saveFileData(other.x24_saveFileData) - , x34_saveData(other.x34_saveData) - {} + , x34_saveData(other.x34_saveData) {} ECardResult Open(); ECardResult Close(); @@ -36,49 +35,49 @@ struct SMemoryCardFileInfo { ECardResult GetSaveDataOffset(u32& offOut) const; }; +enum EState { + kS_Initial = 0, + kS_Ready = 1, + kS_NoCard = 2, + kS_DriverClosed = 3, + kS_CardFormatted = 4, + kS_CardProbeDone = 5, + kS_CardMountDone = 6, + kS_CardCheckDone = 7, + kS_FileCreateDone = 8, + kS_FileCreateTransactionalDone = 9, + kS_FileWriteTransactionalDone = 10, + kS_FileAltDeleteTransactionalDone = 11, + kS_CardProbeFailed = 12, + kS_CardMountFailed = 13, + kS_CardCheckFailed = 14, + kS_FileDeleteBadFailed = 15, + kS_FileDeleteAltFailed = 16, + kS_FileBad = 17, + kS_FileCreateFailed = 18, + kS_FileWriteFailed = 19, + kS_FileCreateTransactionalFailed = 20, + kS_FileWriteTransactionalFailed = 21, + kS_FileAltDeleteTransactionalFailed = 22, + kS_FileRenameBtoAFailed = 23, + kS_CardFormatFailed = 24, + kS_CardProbe = 25, + kS_CardMount = 26, + kS_CardCheck = 27, + kS_FileDeleteBad = 28, + kS_FileRead = 29, + kS_FileDeleteAlt = 30, + kS_FileCreate = 31, + kS_FileWrite = 32, + kS_FileCreateTransactional = 33, + kS_FileWriteTransactional = 34, + kS_FileAltDeleteTransactional = 35, + kS_FileRenameBtoA = 36, + kS_CardFormat = 37 +}; + class CMemoryCardDriver { public: - enum EState { - kS_Initial = 0, - kS_Ready = 1, - kS_NoCard = 2, - kS_DriverClosed = 3, - kS_CardFormatted = 4, - kS_CardProbeDone = 5, - kS_CardMountDone = 6, - kS_CardCheckDone = 7, - kS_FileCreateDone = 8, - kS_FileCreateTransactionalDone = 9, - kS_FileWriteTransactionalDone = 10, - kS_FileDeleteAltTransactionalDone = 11, - kS_CardProbeFailed = 12, - kS_CardMountFailed = 13, - kS_CardCheckFailed = 14, - kS_FileDeleteBadFailed = 15, - kS_FileDeleteAltFailed = 16, - kS_FileBad = 17, - kS_FileCreateFailed = 18, - kS_FileWriteFailed = 19, - kS_FileCreateTransactionalFailed = 20, - kS_FileWriteTransactionalFailed = 21, - kS_FileDeleteAltTransactionalFailed = 22, - kS_FileRenameBtoAFailed = 23, - kS_CardFormatFailed = 24, - kS_CardProbe = 25, - kS_CardMount = 26, - kS_CardCheck = 27, - kS_FileDeleteBad = 28, - kS_FileRead = 29, - kS_FileDeleteAlt = 30, - kS_FileCreate = 31, - kS_FileWrite = 32, - kS_FileCreateTransactional = 33, - kS_FileWriteTransactional = 34, - kS_FileDeleteAltTransactional = 35, - kS_FileRenameBtoA = 36, - kS_CardFormat = 37 - }; - enum EError { kE_OK, kE_CardBroken, @@ -105,8 +104,7 @@ private: // void DoPut(CMemoryStreamOut& w) const { w.Put(x0_saveBuffer.data(), x0_saveBuffer.size()); } }; - - ECardSlot x0_cardPort; + CMemoryCardSys::EMemoryCardPort x0_cardPort; CAssetId x4_saveBanner; CAssetId x8_saveIcon0; CAssetId xc_saveIcon1; @@ -127,26 +125,26 @@ private: public: static bool IsCardBusy(EState); static bool IsCardWriting(EState); - CMemoryCardDriver(ECardSlot cardPort, CAssetId saveBanner, CAssetId saveIcon0, CAssetId saveIcon1, - bool importPersistent); + CMemoryCardDriver(CMemoryCardSys::EMemoryCardPort cardPort, CAssetId saveBanner, + CAssetId saveIcon0, CAssetId saveIcon1, bool importPersistent); void ClearFileInfo(); ~CMemoryCardDriver(); void Update(); void HandleCardError(int); - void UpdateMountCard(int); - void UpdateCardCheck(); - void UpdateFileRead(); - void UpdateFileDeleteAlt(); - void UpdateFileDeleteBad(); - void UpdateFileCreate(); - void UpdateFileWrite(); - void UpdateFileCreateTransactional(); - void UpdateFileWriteTransactional(); - void UpdateFileRenameBtoA(); + void UpdateMountCard(ECardResult); + void UpdateCardCheck(ECardResult); + void UpdateFileRead(ECardResult); + void UpdateFileDeleteAlt(ECardResult); + void UpdateFileDeleteBad(ECardResult); + void UpdateFileCreate(ECardResult); + void UpdateFileWrite(ECardResult); + void UpdateFileCreateTransactional(ECardResult); + void UpdateFileWriteTransactional(ECardResult); + void UpdateFileRenameBtoA(ECardResult); void StartFileRenameBtoA(); void WriteBackupBuf(); - void UpdateFileAltDeleteTransactional(); - void UpdateCardFormat(); + void UpdateFileAltDeleteTransactional(ECardResult); + void UpdateCardFormat(ECardResult); void StartCardProbe(); void UpdateCardProbe(); void StartMountCard(); diff --git a/src/MetroidPrime/CMemoryCardDriver.cpp b/src/MetroidPrime/CMemoryCardDriver.cpp index 291b9c6d..f6de52fb 100644 --- a/src/MetroidPrime/CMemoryCardDriver.cpp +++ b/src/MetroidPrime/CMemoryCardDriver.cpp @@ -1,10 +1,12 @@ #include "MetroidPrime/CMemoryCardDriver.hpp" +#include "MetroidPrime/CMain.hpp" + bool CMemoryCardDriver::IsCardBusy(EState) { return false; } bool CMemoryCardDriver::IsCardWriting(EState) { return false; } -CMemoryCardDriver::CMemoryCardDriver(ECardSlot cardPort, CAssetId saveBanner, CAssetId saveIcon0, CAssetId saveIcon1, +CMemoryCardDriver::CMemoryCardDriver(CMemoryCardSys::EMemoryCardPort cardPort, CAssetId saveBanner, CAssetId saveIcon0, CAssetId saveIcon1, bool importPersistent) : x0_cardPort(cardPort) , x4_saveBanner(saveBanner) @@ -35,41 +37,108 @@ CMemoryCardDriver::CMemoryCardDriver(ECardSlot cardPort, CAssetId saveBanner, CA )); } -void CMemoryCardDriver::ClearFileInfo() {} +void CMemoryCardDriver::ClearFileInfo() { + x198_fileInfo = nullptr; +} CMemoryCardDriver::~CMemoryCardDriver() {} -void CMemoryCardDriver::Update() {} +void CMemoryCardDriver::Update() { + ProbeResults result = CMemoryCardSys::IsMemoryCardInserted(x0_cardPort); + + if (result.x0_error == k_NOCARD) { + if (x10_state != kS_NoCard) + NoCardFound(); + gpMain->SetCardBusy(false); + return; + } + + if (x10_state == kS_CardProbe) { + UpdateCardProbe(); + gpMain->SetCardBusy(false); + return; + } + + ECardResult resultCode = CMemoryCardSys::GetResultCode(x0_cardPort); + bool cardBusy = false; + + if (IsCardBusy(x10_state)) { + cardBusy = true; + + switch (x10_state) { + case kS_CardMount: + UpdateMountCard(resultCode); + break; + case kS_CardCheck: + UpdateCardCheck(resultCode); + break; + case kS_FileDeleteBad: + UpdateFileDeleteBad(resultCode); + break; + case kS_FileRead: + UpdateFileRead(resultCode); + break; + case kS_FileDeleteAlt: + UpdateFileDeleteAlt(resultCode); + break; + case kS_FileCreate: + UpdateFileCreate(resultCode); + break; + case kS_FileWrite: + UpdateFileWrite(resultCode); + break; + case kS_FileCreateTransactional: + UpdateFileCreateTransactional(resultCode); + break; + case kS_FileWriteTransactional: + UpdateFileWriteTransactional(resultCode); + break; + case kS_FileAltDeleteTransactional: + UpdateFileAltDeleteTransactional(resultCode); + break; + case kS_FileRenameBtoA: + UpdateFileRenameBtoA(resultCode); + break; + case kS_CardFormat: + UpdateCardFormat(resultCode); + break; + default: + break; + } + } + + gpMain->SetCardBusy(cardBusy); +} void CMemoryCardDriver::HandleCardError(int) {} -void CMemoryCardDriver::UpdateMountCard(int) {} +void CMemoryCardDriver::UpdateMountCard(ECardResult) {} -void CMemoryCardDriver::UpdateCardCheck() {} +void CMemoryCardDriver::UpdateCardCheck(ECardResult) {} -void CMemoryCardDriver::UpdateFileRead() {} +void CMemoryCardDriver::UpdateFileRead(ECardResult) {} -void CMemoryCardDriver::UpdateFileDeleteAlt() {} +void CMemoryCardDriver::UpdateFileDeleteAlt(ECardResult) {} -void CMemoryCardDriver::UpdateFileDeleteBad() {} +void CMemoryCardDriver::UpdateFileDeleteBad(ECardResult) {} -void CMemoryCardDriver::UpdateFileCreate() {} +void CMemoryCardDriver::UpdateFileCreate(ECardResult) {} -void CMemoryCardDriver::UpdateFileWrite() {} +void CMemoryCardDriver::UpdateFileWrite(ECardResult) {} -void CMemoryCardDriver::UpdateFileCreateTransactional() {} +void CMemoryCardDriver::UpdateFileCreateTransactional(ECardResult) {} -void CMemoryCardDriver::UpdateFileWriteTransactional() {} +void CMemoryCardDriver::UpdateFileWriteTransactional(ECardResult) {} -void CMemoryCardDriver::UpdateFileRenameBtoA() {} +void CMemoryCardDriver::UpdateFileRenameBtoA(ECardResult) {} void CMemoryCardDriver::StartFileRenameBtoA() {} void CMemoryCardDriver::WriteBackupBuf() {} -void CMemoryCardDriver::UpdateFileAltDeleteTransactional() {} +void CMemoryCardDriver::UpdateFileAltDeleteTransactional(ECardResult) {} -void CMemoryCardDriver::UpdateCardFormat() {} +void CMemoryCardDriver::UpdateCardFormat(ECardResult) {} void CMemoryCardDriver::StartCardProbe() {}