Skip to content

Commit 468697e

Browse files
committed
memcard progress
1 parent cbd33d0 commit 468697e

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

decompile/General/MEMCARD/MEMCARD_04_StringInit.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ char *DECOMP_MEMCARD_StringInit(int slotIndex, char *dstString)
88
dstString = &sdata->s_memcardDirHeader[0];
99
}
1010

11-
// *dstString = (((int)slotIndex >> 4 & 1U) + 0x30) * 0x10000 |
12-
// ((slotIndex & 3) + 0x30) * 0x1000000 | 0x7562;
1311
*(int *)&dstString[0] = 0x30307562; // bu00
1412
dstString[3] = '0' + slotIndex; // bu0X where X = slotIndex
1513

decompile/General/MEMCARD/MEMCARD_05_StringSet.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
void DECOMP_MEMCARD_StringSet(char *dstString, int slotIdx, char *srcString)
44

55
{
6+
int i;
67
MEMCARD_StringInit(slotIdx, dstString);
78

8-
int i;
9-
for (i = 0; dstString[i] != '\0'; i++)
10-
;
9+
// fast strlen
10+
for (i = 0; dstString[i] != '\0'; i++);
1111

1212
// copy string from src to dst
1313
for (int j = 0; (srcString[j] != '\0' && i < 63); j++)
1414
{
1515
dstString[i] = srcString[j];
1616
i++;
1717
}
18+
19+
// nullptr
1820
dstString[i] = '\0';
1921
return;
2022
}

decompile/General/MEMCARD/MEMCARD_16_GetFreeBytes.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ void DECOMP_MEMCARD_GetFreeBytes(int slotIdx)
99
struct DIRENTRY *firstEntry;
1010
struct DIRENTRY entry;
1111

12-
MEMCARD_StringSet(sdata->s_bu00_BASCUS_94426_slots, slotIdx, sdata->s_AnyFile);
13-
1412
int bytesUsedMemCard = 0;
13+
MEMCARD_StringSet(sdata->s_bu00_BASCUS_94426_slots, slotIdx, sdata->s_AnyFile);
1514

1615
// string for directory and file of save that is in use
1716
firstEntry = firstfile(sdata->s_bu00_BASCUS_94426_slots, &entry);
1817

19-
for (struct DIRENTRY *nxtEntry = &entry; firstEntry == nxtEntry; nxtEntry = nextfile(&entry))
18+
for (
19+
struct DIRENTRY *nxtEntry = &entry;
20+
firstEntry == nxtEntry;
21+
nxtEntry = nextfile(&entry)
22+
)
2023
{
21-
bytesUsedMemCard = bytesUsedMemCard + (entry.size + 0x1fffU & 0xffffe000);
24+
bytesUsedMemCard += entry.size + 0x1fffU;
25+
bytesUsedMemCard &= 0xffffe000;
2226
}
2327

2428
sdata->memoryCard_SizeRemaining = 0x1e000 - bytesUsedMemCard;

decompile/General/MEMCARD/MEMCARD_25_EraseFile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// NOTE: unused function?
44
uint8_t DECOMP_MEMCARD_EraseFile(int slotIdx, char *srcString)
55
{
6-
if (sdata->memcard_stage)
6+
if (sdata->memcard_stage != 0)
77
return 1;
8+
89
char name[64];
910
MEMCARD_StringSet(name, slotIdx, srcString);
1011
sdata->memcard_stage = (erase(name)) ? 14 : 13;

0 commit comments

Comments
 (0)