Skip to content

Commit 110eb06

Browse files
authored
card fixes and adjustments (#116)
* fix name comparing when creating save files (creating set when set_sav exists) * add functions found in gcmm to retrieve the amount of free blocks & the memory card serial numbers * Add GetStatusEx & SetStatusEx wrappers * expose raw read/write functions (so MC tools can use them)
1 parent 6ce9f2b commit 110eb06

3 files changed

Lines changed: 245 additions & 147 deletions

File tree

gc/ogc/card.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,41 @@ typedef struct _card_dir {
156156
bool showall;
157157
} card_dir;
158158

159+
/*! \typedef struct card_direntry
160+
\brief structure to hold the information of the save file entry ( aka GCI )
161+
\param gamecode[4] string identifier <=4.
162+
\param company[2] string identifier <=2.
163+
\param padding always 0xFF.
164+
\param banner_fmt format of banner.
165+
\param filename[CARD_FILENAMELEN] name of the file on card.
166+
\param last_modified last time it was modified,in seconds since 1970 in seconds.
167+
\param icon_addr icon image address in file.
168+
\param icon_fmt icon image format.
169+
\param icon_speed speed of an animated icon.
170+
\param permission permissions of the save file.
171+
\param copy_times how many times the save file has been copied.
172+
\param block starting block of the save file.
173+
\param length size of the save file..
174+
\param padding always 0xFFFF.
175+
\param comment_addr address in file of the comment block.
176+
*/
177+
typedef struct _card_direntry {
178+
u8 gamecode[4];
179+
u8 company[2];
180+
u8 pad_00;
181+
u8 banner_fmt;
182+
u8 filename[CARD_FILENAMELEN];
183+
u32 last_modified;
184+
u32 icon_addr;
185+
u16 icon_fmt;
186+
u16 icon_speed;
187+
u8 permission;
188+
u8 copy_times;
189+
u16 block;
190+
u16 length;
191+
u16 pad_01;
192+
u32 comment_addr;
193+
} card_direntry;
159194

160195
/*! \typedef struct card_stat
161196
\brief structure to hold the additional statistical informations.
@@ -165,6 +200,7 @@ typedef struct _card_dir {
165200
\param company[2] string identifier <=2.
166201
\param banner_fmt format of banner.
167202
\param icon_addr icon image address in file.
203+
\param icon_fmt icon image format.
168204
\param icon_speed speed of an animated icon.
169205
\param comment_addr address in file of the comment block.
170206
\param offset_banner offset in file to the banner's image data.
@@ -514,6 +550,15 @@ s32 CARD_GetBlockCount(s32 chn,u32 *block_count);
514550
*/
515551
s32 CARD_GetStatus(s32 chn,s32 fileno,card_stat *stats);
516552

553+
/*! \fn s32 CARD_GetStatusEx(s32 chn, s32 fileno, card_direntry *entry)
554+
\brief Get the directory entry (GCI header)
555+
\param[in] chn CARD slot.
556+
\param[in] fileno file index. returned by a previous call to CARD_Open().
557+
\param[out] entry pointer to receive the directory entry.
558+
559+
\return \ref card_errors "card error codes"
560+
*/
561+
s32 CARD_GetStatusEx(s32 chn, s32 fileno, card_direntry *entry);
517562

518563
/*! \fn s32 CARD_SetStatus(s32 chn,s32 fileno,card_stat *stats)
519564
\brief Set additional file statistic informations. Synchronous version.
@@ -537,6 +582,14 @@ s32 CARD_SetStatus(s32 chn,s32 fileno,card_stat *stats);
537582
*/
538583
s32 CARD_SetStatusAsync(s32 chn,s32 fileno,card_stat *stats,cardcallback callback);
539584

585+
/*! \fn s32 CARD_SetStatusEx(s32 chn, s32 fileno, card_direntry *entry)
586+
\brief Set the directory entry (preferably from a GCI header), except block index and lenght
587+
\param[in] chn CARD slot.
588+
\param[in] fileno file index. returned by a previous call to CARD_Open().
589+
\param[out] entry pointer to a directory entry structure (or GCI header).
590+
\return \ref card_errors "card error codes"
591+
*/
592+
s32 CARD_SetStatusEx(s32 chn, s32 fileno, card_direntry *entry);
540593

541594
/*! \fn s32 CARD_GetAttributes(s32 chn,s32 fileno,u8 *attr)
542595
\brief Get additional file attributes. Synchronous version.
@@ -598,6 +651,22 @@ s32 CARD_SetCompany(const char *company);
598651
*/
599652
s32 CARD_SetGamecode(const char *gamecode);
600653

654+
/*! \fn s32 CARD_GetSerialNo(s32 chn, u32 *serial1, u32 *serial2)
655+
\brief Get the encrypted serial numbers of the memory card
656+
\param[in] chn CARD slot.
657+
\param[in] serial1 & serial2 CARD slot.
658+
\return \ref card_errors "card error codes" or free blocks
659+
*/
660+
s32 CARD_GetSerialNo(s32 chn,u32 *serial1,u32 *serial2);
661+
662+
/*! \fn s32 CARD_GetFreeBlocks(s32 chn, u16* freeblocks)
663+
\brief Get the free blocks in memory card
664+
\param[in] chn CARD slot.
665+
\param[in] freeblocks pointer to receive freeblocks value.
666+
\return \ref card_errors "card error codes" or free blocks
667+
*/
668+
s32 CARD_GetFreeBlocks(s32 chn, u16* freeblocks);
669+
601670
#ifdef __cplusplus
602671
}
603672
#endif /* __cplusplus */

gc/ogc/es.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ typedef struct _tmd {
144144
u16 title_version;
145145
u16 num_contents;
146146
u16 boot_index;
147-
u16 fill3;
147+
u16 fill2;
148148
// content records follow
149149
// C99 flexible array
150150
tmd_content contents[];

0 commit comments

Comments
 (0)