Skip to content

Commit 656ba91

Browse files
committed
memcard progress
1 parent 5c8fea3 commit 656ba91

File tree

13 files changed

+53
-48
lines changed

13 files changed

+53
-48
lines changed

decompile/General/MEMCARD/MEMCARD_13_CloseFile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ void DECOMP_MEMCARD_CloseFile(void)
88
// close(sdata->memcard_fd);
99
// sdata->memcard_fd = -1;
1010
// }
11-
// sdata->unk_card_8008D404 = 0;
11+
// sdata->memcard_stage = 0;
1212

1313
int fd = sdata->memcard_fd;
1414
sdata->memcard_fd = -1;
15-
sdata->unk_card_8008D404 = 0;
15+
sdata->memcard_stage = 0;
1616
if (fd != -1)
1717
close(fd);
1818
return;

decompile/General/MEMCARD/MEMCARD_21_Format.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
uint8_t DECOMP_MEMCARD_Format(int slotIdx)
44
{
5-
if (sdata->unk_card_8008D404 == 0)
5+
if (sdata->memcard_stage == 0)
66
{
77
char *someVar = MEMCARD_StringInit(slotIdx, 0);
88

99
// format always returns 1
1010
if (format(someVar))
1111
{
12-
sdata->unk_card_8008D404 = 2;
12+
sdata->memcard_stage = 2;
1313
sdata->memcardSlot = slotIdx;
1414
MEMCARD_SkipEvents();
1515

decompile/General/MEMCARD/MEMCARD_25_EraseFile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// NOTE: unused function?
44
uint8_t DECOMP_MEMCARD_EraseFile(int slotIdx, char *srcString)
55
{
6-
if (sdata->unk_card_8008D404)
6+
if (sdata->memcard_stage)
77
return 1;
88
char name[64];
99
MEMCARD_StringSet(name, slotIdx, srcString);
10-
sdata->unk_card_8008D404 = (erase(name)) ? 14 : 13;
10+
sdata->memcard_stage = (erase(name)) ? 14 : 13;
1111
MEMCARD_GetFreeBytes(slotIdx);
1212
return 7;
1313
}

decompile/General/zGlobal_SDATA.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ struct sData sdata_static =
314314
.region = "XXXX",
315315
#endif
316316

317-
.unk_card_8008D404 = 0,
317+
.memcard_stage = 0,
318318
.memcard_ptrStart = 0,
319319
.memcard_fd = -1,
320320
.memcard_remainingAttempts = 8,

decompile/WorkInProgress/src/MEMCARD/MEMCARD_FindFirstGhost.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// TODO: 4 bytes over budget
55
char *DECOMP_MEMCARD_FindFirstGhost(int slotIdx, char *srcString)
66
{
7-
if (sdata->unk_card_8008D404)
7+
if (sdata->memcard_stage)
88
{
99
return (char *)0;
1010
}
@@ -18,7 +18,7 @@ char *DECOMP_MEMCARD_FindFirstGhost(int slotIdx, char *srcString)
1818

1919
if (firstEntry == &someEntry)
2020
{
21-
sdata->unk_card_8008D404 = 0xf;
21+
sdata->memcard_stage = 0xf;
2222
strcpy(firstEntry->name, someEntry.name); // 0x80
2323
return &sdata->s_memcardFindGhostFile[0];
2424
}

decompile/WorkInProgress/src/MEMCARD/MEMCARD_FindNextGhost.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ char* DECOMP_MEMCARD_FindNextGhost(void)
99
struct DIRENTRY *nextEntry;
1010
struct DIRENTRY someEntry;
1111

12-
if (sdata->unk_card_8008D404 == 0xf)
12+
if (sdata->memcard_stage == 0xf)
1313
{
1414
nextEntry = nextfile(&someEntry);
1515
if (nextEntry == &someEntry)
1616
{
1717
strcpy(nextEntry->name, someEntry.name);
1818
return &sdata->s_memcardFindGhostFile[0];
1919
}
20-
sdata->unk_card_8008D404 = 0;
20+
sdata->memcard_stage = 0;
2121
}
2222

2323
return (char *)0;

decompile/WorkInProgress/src/MEMCARD/MEMCARD_GetInfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
uint8_t DECOMP_MEMCARD_GetInfo(int slotIdx)
44

55
{
6-
if (sdata->unk_card_8008D404 == 0)
6+
if (sdata->memcard_stage == 0)
77
{
88
MEMCARD_SkipEvents();
9-
sdata->unk_card_8008D404 = 1;
9+
sdata->memcard_stage = 1;
1010
sdata->memcardSlot = slotIdx;
1111

1212
// loop until check is "submitted",

decompile/WorkInProgress/src/MEMCARD/MEMCARD_Load.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
uint8_t MEMCARD_Load(int slotIdx, char *name, uint8_t *ptrMemcard, int memcardFileSize, unsigned int param5)
88

99
{
10-
if (sdata->unk_card_8008D404 != 0)
10+
if (sdata->memcard_stage != 0)
1111
{
1212
return 1;
1313
}
@@ -41,7 +41,7 @@ uint8_t MEMCARD_Load(int slotIdx, char *name, uint8_t *ptrMemcard, int memcardFi
4141
*/
4242
// process crc16 to the end of memory
4343
sdata->memcardStatusFlags = sdata->memcardStatusFlags | 8;
44-
sdata->unk_card_8008D404 = 3;
44+
sdata->memcard_stage = 3;
4545

4646
// Read memory card
4747
return MEMCARD_ReadFile(0, 0x80);

decompile/WorkInProgress/src/MEMCARD/MEMCARD_Save.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ uint8_t MEMCARD_Save(int slotIdx, char *name,
77

88
{
99

10-
if (sdata->unk_card_8008D404 != 0)
10+
if (sdata->memcard_stage != 0)
1111
return 1;
1212

1313
sdata->memcardIconSize = 0x100;
@@ -68,7 +68,7 @@ uint8_t MEMCARD_Save(int slotIdx, char *name,
6868

6969
if (sdata->memcard_fd != -1)
7070
{
71-
sdata->unk_card_8008D404 = 9;
71+
sdata->memcard_stage = 9;
7272
return MEMCARD_WriteFile(0, data.memcardIcon_PsyqHand, sdata->memcardIconSize);
7373
}
7474

decompile/WorkInProgress/src/MEMCARD/MEMCARD_Unkown.c

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#include <common.h>
22

3-
// TODO: Name function, add symbol
3+
// TODO: Name function, add symbol (MEMCARD_GetStageResult)
44
int FUN_8003ddac(void)
55
{
66
int readResult;
77
int event;
88
int iVar4;
99
int *ptrData;
1010

11-
switch (sdata->unk_card_8008D404)
11+
switch (sdata->memcard_stage)
1212
{
1313

14-
case 1:
14+
// after checking info
15+
case MC_STAGE_GETINFO:
1516

1617
event = MEMCARD_GetNextSwEvent();
1718

@@ -22,7 +23,7 @@ int FUN_8003ddac(void)
2223
if ((sdata->memcardStatusFlags & 1) != 0)
2324
{
2425
// allow the "switch" statement to go to stage 2
25-
sdata->unk_card_8008D404 = 2;
26+
sdata->memcard_stage = 2;
2627

2728
// do something wtih both memcards if they're present,
2829
MEMCARD_SkipEvents();
@@ -47,24 +48,24 @@ int FUN_8003ddac(void)
4748
{
4849
if (event != 7)
4950
{
50-
sdata->unk_card_8008D404 = 0;
51+
sdata->memcard_stage = 0;
5152

5253
sdata->memoryCard_SizeRemaining = 0;
5354

5455
return event;
5556
}
5657
return 7;
5758
}
58-
MEMCARD_SkipEvents();
59-
while (_card_clear(sdata->memcardSlot) != 1)
60-
;
59+
60+
MEMCARD_SkipEvents();
61+
while (_card_clear(sdata->memcardSlot) != 1);
62+
6163
event = MEMCARD_WaitForHwEvent();
6264
if (event == 0)
6365
{
64-
sdata->unk_card_8008D404 = 2;
66+
sdata->memcard_stage = 2;
6567
MEMCARD_SkipEvents();
66-
while (_card_load(sdata->memcardSlot) != 1)
67-
;
68+
while (_card_load(sdata->memcardSlot) != 1);
6869
return 7;
6970
}
7071
}
@@ -77,7 +78,7 @@ int FUN_8003ddac(void)
7778

7879
if (event == 0)
7980
{
80-
sdata->unk_card_8008D404 = 0;
81+
sdata->memcard_stage = 0;
8182
sdata->memcardStatusFlags = sdata->memcardStatusFlags & 0xfffffffe | 2;
8283

8384
MEMCARD_GetFreeBytes(sdata->memcardSlot);
@@ -86,7 +87,7 @@ int FUN_8003ddac(void)
8687
}
8788
if (event == 3)
8889
{
89-
sdata->unk_card_8008D404 = 0;
90+
sdata->memcard_stage = 0;
9091
sdata->memcardStatusFlags = sdata->memcardStatusFlags & 0xfffffffc;
9192
return 5;
9293
}
@@ -95,7 +96,7 @@ int FUN_8003ddac(void)
9596
return 7;
9697
}
9798
LAB_8003df38:
98-
sdata->unk_card_8008D404 = 0;
99+
sdata->memcard_stage = 0;
99100
break;
100101

101102
case 3:
@@ -105,7 +106,7 @@ int FUN_8003ddac(void)
105106
if (event == 0)
106107
{
107108
// allow "switch" statement to go to stage 4
108-
sdata->unk_card_8008D404 = 4;
109+
sdata->memcard_stage = 4;
109110

110111
// Bitwise & with 0xf to extract last 4 bits then increment by 1
111112
sdata->memcardIconSize = ((sdata->memcard_ptrStart[2] & 0xf) + 1) * 0x80;
@@ -149,7 +150,7 @@ int FUN_8003ddac(void)
149150
{
150151
sdata->crc16_checkpoint_byteIndex = 0;
151152
sdata->crc16_checkpoint_status = 0;
152-
sdata->unk_card_8008D404 = sdata->unk_card_8008D404 + 1;
153+
sdata->memcard_stage = sdata->memcard_stage + 1;
153154
if ((sdata->memcardStatusFlags & 8) == 0)
154155
{
155156
sdata->crc16_checkpoint_byteIndex = 0;
@@ -166,7 +167,7 @@ int FUN_8003ddac(void)
166167

167168
if (sdata->memcard_remainingAttempts > 0)
168169
{
169-
iVar4 = sdata->memcardIconSize + (sdata->unk_card_8008D404 - 4) * sdata->memoryCardFileSize_0x1680;
170+
iVar4 = sdata->memcardIconSize + (sdata->memcard_stage - 4) * sdata->memoryCardFileSize_0x1680;
170171
event = sdata->memoryCardFileSize_0x1680;
171172

172173
sdata->memcard_remainingAttempts = sdata->memcard_remainingAttempts + -1;
@@ -193,12 +194,12 @@ int FUN_8003ddac(void)
193194

194195
// at this point, assume checksum succeeded (return 1)
195196

196-
if (((sdata->memcardStatusFlags & 4) == 0) && (sdata->unk_card_8008D404 < 7))
197+
if (((sdata->memcardStatusFlags & 4) == 0) && (sdata->memcard_stage < 7))
197198
{
198199
// Make "switch" statement go to "next" stage
199-
sdata->unk_card_8008D404 = sdata->unk_card_8008D404 + 1;
200+
sdata->memcard_stage = sdata->memcard_stage + 1;
200201

201-
iVar4 = sdata->memcardIconSize + (sdata->unk_card_8008D404 - 4) * sdata->memoryCardFileSize_0x1680;
202+
iVar4 = sdata->memcardIconSize + (sdata->memcard_stage - 4) * sdata->memoryCardFileSize_0x1680;
202203
event = sdata->memoryCardFileSize_0x1680;
203204
READCARD_JUMP:
204205

@@ -219,7 +220,7 @@ int FUN_8003ddac(void)
219220

220221
if (event == 0)
221222
{
222-
if ((sdata->unk_card_8008D404 != 9) && ((10 < sdata->unk_card_8008D404 || ((sdata->memcardStatusFlags & 4) != 0))))
223+
if ((sdata->memcard_stage != 9) && ((10 < sdata->memcard_stage || ((sdata->memcardStatusFlags & 4) != 0))))
223224
{
224225
MEMCARD_CloseFile();
225226

@@ -228,10 +229,10 @@ int FUN_8003ddac(void)
228229
return 0;
229230
}
230231

231-
sdata->unk_card_8008D404 = sdata->unk_card_8008D404 + 1;
232+
sdata->memcard_stage = sdata->memcard_stage + 1;
232233

233234
LAB_8003e1e4:
234-
event = sdata->unk_card_8008D404 - 10;
235+
event = sdata->memcard_stage - 10;
235236
iVar4 = sdata->memcardIconSize + event * sdata->memoryCardFileSize_0x1680;
236237

237238
// pointer to memory card bytes
@@ -256,7 +257,7 @@ int FUN_8003ddac(void)
256257
goto CLOSEFILE_JUMP;
257258

258259
sdata->memcard_remainingAttempts = iVar4;
259-
if (sdata->unk_card_8008D404 != 9)
260+
if (sdata->memcard_stage != 9)
260261
goto LAB_8003e1e4;
261262

262263
iVar4 = 0;
@@ -272,11 +273,11 @@ int FUN_8003ddac(void)
272273
event = MEMCARD_WriteFile(iVar4, ptrData, event);
273274
break;
274275
case 13:
275-
sdata->unk_card_8008D404 = 0;
276+
sdata->memcard_stage = 0;
276277
event = 1;
277278
break;
278279
case 14:
279-
sdata->unk_card_8008D404 = 0;
280+
sdata->memcard_stage = 0;
280281
event = 0;
281282
}
282283
return event;

0 commit comments

Comments
 (0)