PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
libmc.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16/*
17 NOTE: These functions will work with the MCMAN/MCSERV or XMCMAN/XMCSERV
18 modules stored in rom0. To determine which one you are using, send the
19 appropriate arg to the mcInit() function (MC_TYPE_MC or MC_TYPE_XMC)
20
21 NOTE: These functions seem to work for both psx and ps2 memcards
22
23 to use memcards:
24 1) first load modules (sio2man then mcman/mcserv)
25 2) call mcInit(MC_TYPE)
26 3) use mcGetInfo() to see if memcards are connected
27 4) use mcSync to check that the function has finished
28
29 all mc* functions except mcInit() are asynchronous and require mcSync()
30 usage to test when they are done
31*/
32
33#ifndef __LIBMC_H__
34#define __LIBMC_H__
35
36#include <libmc-common.h>
37
38#define MC_WAIT 0
39#define MC_NOWAIT 1
40
41#define MC_TYPE_PSX sceMcTypePS1
42#define MC_TYPE_PS2 sceMcTypePS2
43#define MC_TYPE_POCKET sceMcTypePDA
44#define MC_TYPE_NONE sceMcTypeNoCard
45
46#define MC_FORMATTED 1
47#define MC_UNFORMATTED 0
48
49// Valid bits in memcard file attributes (mctable.AttrFile)
50#define MC_ATTR_READABLE sceMcFileAttrReadable
51#define MC_ATTR_WRITEABLE sceMcFileAttrWriteable
52#define MC_ATTR_EXECUTABLE sceMcFileAttrExecutable
53#define MC_ATTR_PROTECTED sceMcFileAttrDupProhibit
54#define MC_ATTR_FILE sceMcFileAttrFile
55#define MC_ATTR_SUBDIR sceMcFileAttrSubdir
57#define MC_ATTR_OBJECT (sceMcFileAttrFile|sceMcFileAttrSubdir)
58#define MC_ATTR_CLOSED sceMcFileAttrClosed
59#define MC_ATTR_PDAEXEC sceMcFileAttrPDAExec
60#define MC_ATTR_PSX sceMcFileAttrPS1
62#define MC_ATTR_HIDDEN sceMcFileAttrHidden
63
66 MC_FUNC_NONE = 0x00,
67 MC_FUNC_GET_INFO,
68 MC_FUNC_OPEN,
69 MC_FUNC_CLOSE,
70 MC_FUNC_SEEK,
71 MC_FUNC_READ,
72 MC_FUNC_WRITE,
73 MC_FUNC_FLUSH = 0x0A,
74 MC_FUNC_MK_DIR,
75 MC_FUNC_CH_DIR,
76 MC_FUNC_GET_DIR,
77 MC_FUNC_SET_INFO,
78 MC_FUNC_DELETE,
79 MC_FUNC_FORMAT,
80 MC_FUNC_UNFORMAT,
81 MC_FUNC_GET_ENT,
82 MC_FUNC_RENAME,
83 MC_FUNC_CHG_PRITY,
84 MC_FUNC_ERASE_BLOCK = 0x5A,
85 MC_FUNC_READ_PAGE,
86 MC_FUNC_WRITE_PAGE,
87};
88
96 MCICON_TYPE_SAVED_DATA = 0, // "Saved Data (PlayStation(r)2)"
97 MCICON_TYPE_SOFTWARE_PS2, // "Software (PlayStation(r)2)"
98 MCICON_TYPE_SOFTWARE_PKT, // "Software (PocketStation(r))"
99 MCICON_TYPE_SETTINGS_DATA, // "Settings File (PlayStation(r)2)"
100 MCICON_TYPE_SYSTEM_DRIVER // "System driver"; Implemented on SCPH-5XXXX, previous models can't recognize it unless HDD-OSD is active
101};
102
103typedef int iconIVECTOR[4];
104typedef float iconFVECTOR[4];
105
106typedef struct
107{
109 unsigned char head[4];
111 unsigned short type;
113 unsigned short nlOffset;
115 unsigned unknown2;
117 unsigned trans;
119 iconIVECTOR bgCol[4];
121 iconFVECTOR lightDir[3];
123 iconFVECTOR lightCol[3];
125 iconFVECTOR lightAmbient;
127 unsigned short title[34];
129 unsigned char view[64];
131 unsigned char copy[64];
133 unsigned char del[64];
135 unsigned char unknown3[512];
136} mcIcon;
137
138typedef struct _sceMcTblGetDir { // size = 64
139 sceMcStDateTime _Create; // 0
140 sceMcStDateTime _Modify; // 8
141 u32 FileSizeByte; // 16
142 u16 AttrFile; // 20
143 u16 Reserve1; // 22
144 u32 Reserve2; // 24
145 u32 PdaAplNo; // 28
146 unsigned char EntryName[32]; // 32
148
149typedef struct
150{
151 struct
152 {
153 unsigned char unknown1;
155 unsigned char sec;
157 unsigned char min;
159 unsigned char hour;
161 unsigned char day;
163 unsigned char month;
165 unsigned short year;
166 } _create;
167
168 struct
169 {
170 unsigned char unknown2;
172 unsigned char sec;
174 unsigned char min;
176 unsigned char hour;
178 unsigned char day;
180 unsigned char month;
182 unsigned short year;
183 } _modify;
184
186 unsigned fileSizeByte;
188 unsigned short attrFile;
189 unsigned short unknown3;
190 unsigned unknown4[2];
192 unsigned char name[32];
193} mcTable __attribute__((deprecated, aligned (64)));
194
195// values to send to mcInit() to use either mcserv or xmcserv
196#define MC_TYPE_MC 0
197#define MC_TYPE_XMC 1
198
199#ifdef __cplusplus
200extern "C" {
201#endif
202
208int mcInit(int type);
209
223int mcGetInfo(int port, int slot, int* type, int* free, int* format);
224
235int mcOpen(int port, int slot, const char *name, int mode);
236
244int mcClose(int fd);
245
255int mcSeek(int fd, int offset, int origin);
256
257
267int mcRead(int fd, void *buffer, int size);
268
278int mcWrite(int fd, const void *buffer, int size);
279
287int mcFlush(int fd);
288
298int mcMkDir(int port, int slot, const char* name);
299
311int mcChdir(int port, int slot, const char* newDir, char* currentDir);
312
326int mcGetDir(int port, int slot, const char *name, unsigned mode, int maxent, sceMcTblGetDir* table);
327
339int mcSetFileInfo(int port, int slot, const char* name, const sceMcTblGetDir* info, unsigned flags);
340
350int mcDelete(int port, int slot, const char *name);
351
360int mcFormat(int port, int slot);
361
370int mcUnformat(int port, int slot);
371
381int mcGetEntSpace(int port, int slot, const char* path);
382
394int mcRename(int port, int slot, const char* oldName, const char* newName);
395
407int mcEraseBlock(int port, int slot, int block, int mode);
408
420int mcReadPage(int port, int slot, unsigned int page, void *buffer);
421
433int mcWritePage(int port, int slot, int page, const void *buffer);
434
444int mcChangeThreadPriority(int level);
445
453int mcSync(int mode, int *cmd, int *result);
454
459int mcReset(void);
460
461#ifdef __cplusplus
462}
463#endif
464
465#endif /* __LIBMC_H__ */
int mcReset(void)
Definition libmc.c:908
int mcGetEntSpace(int port, int slot, const char *path)
Definition libmc.c:693
int mcUnformat(int port, int slot)
Definition libmc.c:671
unsigned unknown2
Definition libmc.h:115
int mcSeek(int fd, int offset, int origin)
Definition libmc.c:424
int mcRead(int fd, void *buffer, int size)
Definition libmc.c:447
int mcMkDir(int port, int slot, const char *name)
Definition libmc.c:532
unsigned short type
Definition libmc.h:111
int mcWritePage(int port, int slot, int page, const void *buffer)
Definition libmc.c:814
int mcEraseBlock(int port, int slot, int block, int mode)
Definition libmc.c:746
int mcOpen(int port, int slot, const char *name, int mode)
Definition libmc.c:378
int mcRename(int port, int slot, const char *oldName, const char *newName)
Definition libmc.c:717
int mcChdir(int port, int slot, const char *newDir, char *currentDir)
Definition libmc.c:541
int mcSetFileInfo(int port, int slot, const char *name, const sceMcTblGetDir *info, unsigned flags)
Definition libmc.c:595
int mcReadPage(int port, int slot, unsigned int page, void *buffer)
Definition libmc.c:789
MCICON_TYPES
Definition libmc.h:95
int mcGetDir(int port, int slot, const char *name, unsigned mode, int maxent, sceMcTblGetDir *table)
Definition libmc.c:567
int mcClose(int fd)
Definition libmc.c:403
iconFVECTOR lightAmbient
Definition libmc.h:125
unsigned short nlOffset
Definition libmc.h:113
unsigned trans
Definition libmc.h:117
int mcGetInfo(int port, int slot, int *type, int *free, int *format)
Definition libmc.c:336
int mcInit(int type)
Definition libmc.c:230
MC_FUNC_NUMBERS
Definition libmc.h:65
int mcDelete(int port, int slot, const char *name)
Definition libmc.c:624
int mcFormat(int port, int slot)
Definition libmc.c:649
int mcWrite(int fd, const void *buffer, int size)
Definition libmc.c:473
int mcChangeThreadPriority(int level)
Definition libmc.c:843
int mcSync(int mode, int *cmd, int *result)
Definition libmc.c:866
unsigned fileSizeByte
Definition libmc.h:186
int mcFlush(int fd)
Definition libmc.c:511
unsigned short attrFile
Definition libmc.h:188