@@ -22,46 +22,39 @@ int32_t finishAsyncFunction(int32_t returnCode)
22
22
return returnCode;
23
23
}
24
24
25
- int32_t checkForMemoryCard (int32_t channel )
25
+ int32_t checkForMemoryCard ()
26
26
{
27
- return gc::card::CARDProbeEx (channel , nullptr , nullptr );
27
+ return gc::card::CARDProbeEx (CARD_SLOTA , nullptr , nullptr );
28
28
}
29
29
30
- int32_t mountCard (int32_t channel )
30
+ int32_t mountCard ()
31
31
{
32
32
void *WorkArea = *reinterpret_cast <uint32_t **>(
33
33
reinterpret_cast <uint32_t >(ttyd::cardmgr::cardMgrWorkPointer) + 0x4 );
34
34
35
- int32_t ReturnCode = gc::card::CARDMountAsync (channel , WorkArea, nullptr , nullptr );
35
+ int32_t ReturnCode = gc::card::CARDMountAsync (CARD_SLOTA , WorkArea, nullptr , nullptr );
36
36
return finishAsyncFunction (ReturnCode);
37
37
}
38
38
39
- int32_t unmountCard (int32_t channel )
39
+ int32_t unmountCard ()
40
40
{
41
- return gc::card::CARDUnmount (channel );
41
+ return gc::card::CARDUnmount (CARD_SLOTA );
42
42
}
43
43
44
- int32_t openFileFromCard (int32_t channel,
45
- const char *fileName, gc::card::CARDFileInfo *fileInfo)
44
+ int32_t openFileFromCard (const char *fileName, gc::card::CARDFileInfo *fileInfo)
46
45
{
47
- return gc::card::CARDOpen (channel , fileName, fileInfo);
46
+ return gc::card::CARDOpen (CARD_SLOTA , fileName, fileInfo);
48
47
}
49
48
50
49
int32_t closeFileFromCard (gc::card::CARDFileInfo *fileInfo)
51
50
{
52
51
return gc::card::CARDClose (fileInfo);
53
52
}
54
53
55
- void closeFileAndUnmountCard (gc::card::CARDFileInfo *fileInfo, int32_t channel)
56
- {
57
- closeFileFromCard (fileInfo);
58
- unmountCard (channel);
59
- }
60
-
61
- int32_t createFileOnCard (int32_t channel, const char *fileName,
54
+ int32_t createFileOnCard (const char *fileName,
62
55
uint32_t size, gc::card::CARDFileInfo *fileInfo)
63
56
{
64
- int32_t ReturnCode = gc::card::CARDCreateAsync (channel , fileName, size, fileInfo, nullptr );
57
+ int32_t ReturnCode = gc::card::CARDCreateAsync (CARD_SLOTA , fileName, size, fileInfo, nullptr );
65
58
return finishAsyncFunction (ReturnCode);
66
59
}
67
60
@@ -79,46 +72,45 @@ int32_t writeToFileOnCard(gc::card::CARDFileInfo *fileInfo,
79
72
return finishAsyncFunction (ReturnCode);
80
73
}
81
74
82
- int32_t deleteFileOnCard (int32_t channel, const char *fileName)
75
+ int32_t deleteFileOnCard (const char *fileName)
83
76
{
84
- return gc::card::CARDDelete (channel , fileName);
77
+ return gc::card::CARDDelete (CARD_SLOTA , fileName);
85
78
}
86
79
87
- int32_t getFileStatus (int32_t channel, int32_t fileNum, gc::card::CARDStat *stat)
80
+ int32_t getFileStatus (int32_t fileNum, gc::card::CARDStat *stat)
88
81
{
89
- return gc::card::CARDGetStatus (channel , fileNum, stat);
82
+ return gc::card::CARDGetStatus (CARD_SLOTA , fileNum, stat);
90
83
}
91
84
92
- int32_t setFileStatus (int32_t channel,
93
- int32_t fileNum, gc::card::CARDStat *stat)
85
+ int32_t setFileStatus (int32_t fileNum, gc::card::CARDStat *stat)
94
86
{
95
- int32_t ReturnCode = gc::card::CARDSetStatusAsync (channel , fileNum, stat, nullptr );
87
+ int32_t ReturnCode = gc::card::CARDSetStatusAsync (CARD_SLOTA , fileNum, stat, nullptr );
96
88
return finishAsyncFunction (ReturnCode);
97
89
}
98
90
99
91
int32_t loadSettings (const char *settingsFileName)
100
92
{
101
93
// Load the settings file
102
- int32_t ReturnCode = checkForMemoryCard (CARD_SLOTA );
94
+ int32_t ReturnCode = checkForMemoryCard ();
103
95
if (ReturnCode != CARD_RESULT_READY)
104
96
{
105
97
return ReturnCode;
106
98
}
107
99
108
100
// Mount the memory card in slot A
109
- ReturnCode = mountCard (CARD_SLOTA );
101
+ ReturnCode = mountCard ();
110
102
if (ReturnCode != CARD_RESULT_READY)
111
103
{
112
104
return ReturnCode;
113
105
}
114
106
115
107
// Open the settings file
116
108
gc::card::CARDFileInfo FileInfo;
117
- ReturnCode = openFileFromCard (CARD_SLOTA, settingsFileName, &FileInfo);
109
+ ReturnCode = openFileFromCard (settingsFileName, &FileInfo);
118
110
119
111
if (ReturnCode != CARD_RESULT_READY)
120
112
{
121
- unmountCard (CARD_SLOTA );
113
+ unmountCard ();
122
114
return ReturnCode;
123
115
}
124
116
@@ -130,7 +122,8 @@ int32_t loadSettings(const char *settingsFileName)
130
122
if (ReturnCode != CARD_RESULT_READY)
131
123
{
132
124
delete[] (FileData);
133
- closeFileAndUnmountCard (&FileInfo, CARD_SLOTA);
125
+ closeFileFromCard (&FileInfo);
126
+ unmountCard ();
134
127
return ReturnCode;
135
128
}
136
129
@@ -164,7 +157,8 @@ int32_t loadSettings(const char *settingsFileName)
164
157
ReturnCode = readFromFileOnCard (&FileInfo, MiscData, StoredFileSizeAdjusted, 0x2000 );
165
158
166
159
// Close and unmount the card, as it's no longer needed
167
- closeFileAndUnmountCard (&FileInfo, CARD_SLOTA);
160
+ closeFileFromCard (&FileInfo);
161
+ unmountCard ();
168
162
169
163
if (ReturnCode != CARD_RESULT_READY)
170
164
{
@@ -223,14 +217,14 @@ int32_t writeSettings(const char *settingsDescription,
223
217
const char *settingsFileName, const char *relFileName)
224
218
{
225
219
// Load the settings file
226
- int32_t ReturnCode = checkForMemoryCard (CARD_SLOTA );
220
+ int32_t ReturnCode = checkForMemoryCard ();
227
221
if (ReturnCode != CARD_RESULT_READY)
228
222
{
229
223
return ReturnCode;
230
224
}
231
225
232
226
// Mount the memory card in slot A
233
- ReturnCode = mountCard (CARD_SLOTA );
227
+ ReturnCode = mountCard ();
234
228
if (ReturnCode != CARD_RESULT_READY)
235
229
{
236
230
return ReturnCode;
@@ -244,7 +238,7 @@ int32_t writeSettings(const char *settingsDescription,
244
238
245
239
// Open the settings file if it exists
246
240
gc::card::CARDFileInfo FileInfo;
247
- ReturnCode = openFileFromCard (CARD_SLOTA, settingsFileName, &FileInfo);
241
+ ReturnCode = openFileFromCard (settingsFileName, &FileInfo);
248
242
249
243
switch (ReturnCode)
250
244
{
@@ -258,7 +252,8 @@ int32_t writeSettings(const char *settingsDescription,
258
252
if (ReturnCode != CARD_RESULT_READY)
259
253
{
260
254
delete[] (FileData);
261
- closeFileAndUnmountCard (&FileInfo, CARD_SLOTA);
255
+ closeFileFromCard (&FileInfo);
256
+ unmountCard ();
262
257
return ReturnCode;
263
258
}
264
259
@@ -279,15 +274,15 @@ int32_t writeSettings(const char *settingsDescription,
279
274
ReturnCode = closeFileFromCard (&FileInfo);
280
275
if (ReturnCode != CARD_RESULT_READY)
281
276
{
282
- unmountCard (CARD_SLOTA );
277
+ unmountCard ();
283
278
return ReturnCode;
284
279
}
285
280
286
281
// Delete the current file
287
- ReturnCode = deleteFileOnCard (CARD_SLOTA, settingsFileName);
282
+ ReturnCode = deleteFileOnCard (settingsFileName);
288
283
if (ReturnCode != CARD_RESULT_READY)
289
284
{
290
- unmountCard (CARD_SLOTA );
285
+ unmountCard ();
291
286
return ReturnCode;
292
287
}
293
288
@@ -314,7 +309,7 @@ int32_t writeSettings(const char *settingsDescription,
314
309
}
315
310
default :
316
311
{
317
- unmountCard (CARD_SLOTA );
312
+ unmountCard ();
318
313
return ReturnCode;
319
314
}
320
315
}
@@ -363,7 +358,8 @@ int32_t writeSettings(const char *settingsDescription,
363
358
ReturnCode = writeToFileOnCard (&FileInfo, MiscData, FileSizeAdjusted, 0x2000 );
364
359
365
360
delete[] (MiscData);
366
- closeFileAndUnmountCard (&FileInfo, CARD_SLOTA);
361
+ closeFileFromCard (&FileInfo);
362
+ unmountCard ();
367
363
return ReturnCode;
368
364
}
369
365
@@ -372,11 +368,11 @@ int32_t createSettingsFile(const char *settingsFileName,
372
368
{
373
369
// Get the banner and icon data from the desired REL file
374
370
gc::card::CARDFileInfo FileInfo;
375
- int32_t ReturnCode = openFileFromCard (CARD_SLOTA, relFileName, &FileInfo);
371
+ int32_t ReturnCode = openFileFromCard (relFileName, &FileInfo);
376
372
377
373
if (ReturnCode != CARD_RESULT_READY)
378
374
{
379
- unmountCard (CARD_SLOTA );
375
+ unmountCard ();
380
376
return ReturnCode;
381
377
}
382
378
@@ -388,7 +384,8 @@ int32_t createSettingsFile(const char *settingsFileName,
388
384
if (ReturnCode != CARD_RESULT_READY)
389
385
{
390
386
delete[] (BannerIconData);
391
- closeFileAndUnmountCard (&FileInfo, CARD_SLOTA);
387
+ closeFileFromCard (&FileInfo);
388
+ unmountCard ();
392
389
return ReturnCode;
393
390
}
394
391
@@ -397,7 +394,7 @@ int32_t createSettingsFile(const char *settingsFileName,
397
394
if (ReturnCode != CARD_RESULT_READY)
398
395
{
399
396
delete[] (BannerIconData);
400
- unmountCard (CARD_SLOTA );
397
+ unmountCard ();
401
398
return ReturnCode;
402
399
}
403
400
@@ -409,23 +406,23 @@ int32_t createSettingsFile(const char *settingsFileName,
409
406
uint32_t FileSizeAdjusted = (FileSize + 0x2000 - 1 ) & ~(0x2000 - 1 );
410
407
411
408
// Create the new file
412
- ReturnCode = createFileOnCard (CARD_SLOTA, settingsFileName, FileSizeAdjusted, &FileInfo);
409
+ ReturnCode = createFileOnCard (settingsFileName, FileSizeAdjusted, &FileInfo);
413
410
if (ReturnCode != CARD_RESULT_READY)
414
411
{
415
412
delete[] (BannerIconData);
416
- unmountCard (CARD_SLOTA );
413
+ unmountCard ();
417
414
return ReturnCode;
418
415
}
419
416
420
417
// Get the stats for the new file
421
418
gc::card::CARDStat CardStat;
422
419
int32_t FileNumber = FileInfo.fileNum ;
423
420
424
- ReturnCode = getFileStatus (CARD_SLOTA, FileNumber, &CardStat);
421
+ ReturnCode = getFileStatus (FileNumber, &CardStat);
425
422
if (ReturnCode != CARD_RESULT_READY)
426
423
{
427
424
delete[] (BannerIconData);
428
- unmountCard (CARD_SLOTA );
425
+ unmountCard ();
429
426
return ReturnCode;
430
427
}
431
428
@@ -437,20 +434,20 @@ int32_t createSettingsFile(const char *settingsFileName,
437
434
CardStat.commentAddress = 0x2000 ;
438
435
439
436
// Set the stats for the new file
440
- ReturnCode = setFileStatus (CARD_SLOTA, FileNumber, &CardStat);
437
+ ReturnCode = setFileStatus (FileNumber, &CardStat);
441
438
if (ReturnCode != CARD_RESULT_READY)
442
439
{
443
440
delete[] (BannerIconData);
444
- unmountCard (CARD_SLOTA );
441
+ unmountCard ();
445
442
return ReturnCode;
446
443
}
447
444
448
445
// Open the new file
449
- ReturnCode = openFileFromCard (CARD_SLOTA, settingsFileName, settingsFileInfo);
446
+ ReturnCode = openFileFromCard (settingsFileName, settingsFileInfo);
450
447
if (ReturnCode != CARD_RESULT_READY)
451
448
{
452
449
delete[] (BannerIconData);
453
- unmountCard (CARD_SLOTA );
450
+ unmountCard ();
454
451
return ReturnCode;
455
452
}
456
453
@@ -462,7 +459,8 @@ int32_t createSettingsFile(const char *settingsFileName,
462
459
463
460
if (ReturnCode != CARD_RESULT_READY)
464
461
{
465
- closeFileAndUnmountCard (settingsFileInfo, CARD_SLOTA);
462
+ closeFileFromCard (settingsFileInfo);
463
+ unmountCard ();
466
464
}
467
465
468
466
return ReturnCode;
0 commit comments