#include <tamtypes.h>
#include <kernel.h>
#include <sifrpc.h>
#include <loadfile.h>
#include <fileio.h>
#include <malloc.h>
#include <libmc.h>
#include <stdio.h>
#include <string.h>
Go to the source code of this file.
◆ ARRAY_ENTRIES
◆ TYPE_XMC
◆ CreateSave()
Definition at line 147 of file mc_example.c.
150 int icon_fd,icon_size;
156 { 255, 255, 255, 0 },
157 { 255, 255, 255, 0 },
162 { 0.5, 0.5, 0.5, 0.0 },
163 { 0.0,-0.4,-0.1, 0.0 },
164 {-0.5,-0.5, 0.5, 0.0 },
168 { 0.3, 0.3, 0.3, 0.00 },
169 { 0.4, 0.4, 0.4, 0.00 },
170 { 0.5, 0.5, 0.5, 0.00 },
173 static iconFVECTOR ambient = { 0.50, 0.50, 0.50, 0.00 };
176 if(
mkdir(
"mc0:PS2DEV", 0777) < 0)
return -1;
182 memset(&icon_sys, 0,
sizeof(
mcIcon));
183 strcpy(icon_sys.
head,
"PS2D");
186 icon_sys.
trans = 0x60;
188 memcpy(icon_sys.
lightDir, lightdir,
sizeof(lightdir));
189 memcpy(icon_sys.
lightCol, lightcol,
sizeof(lightcol));
190 memcpy(icon_sys.
lightAmbient, ambient,
sizeof(ambient));
191 strcpy(icon_sys.
view,
"ps2dev.icn");
192 strcpy(icon_sys.
copy,
"ps2dev.icn");
193 strcpy(icon_sys.
del,
"ps2dev.icn");
196 mc_fd = open(
"mc0:PS2DEV/icon.sys",O_WRONLY | O_CREAT);
197 if(mc_fd < 0)
return -2;
199 write(mc_fd, &icon_sys,
sizeof(icon_sys));
201 printf(
"icon.sys written sucessfully.\n");
206 icon_fd = open(
"host:ps2dev.icn",O_RDONLY);
207 if(icon_fd < 0)
return -3;
209 icon_size = lseek(icon_fd,0,SEEK_END);
210 lseek(icon_fd,0,SEEK_SET);
212 icon_buffer = malloc(icon_size);
213 if(icon_buffer ==
NULL)
return -4;
214 if(read(icon_fd, icon_buffer, icon_size) != icon_size)
return -5;
217 icon_fd = open(
"mc0:PS2DEV/ps2dev.icn",O_WRONLY | O_CREAT);
218 if(icon_fd < 0)
return -6;
220 write(icon_fd,icon_buffer,icon_size);
222 printf(
"ps2dev.icn written sucessfully.\n");
int mkdir(const char *path, mode_t mode)
int strcpy_sjis(short *sjis_buff, const char *ascii_buff)
References mcIcon::bgCol, bgcolor, mcIcon::copy, mcIcon::del, mcIcon::head, mcIcon::lightAmbient, mcIcon::lightCol, mcIcon::lightDir, mkdir(), mcIcon::nlOffset, NULL, strcpy_sjis(), mcIcon::title, mcIcon::trans, and mcIcon::view.
Referenced by main().
◆ LoadModules()
void LoadModules |
( |
void |
| ) |
|
Definition at line 228 of file mc_example.c.
235 printf(
"Failed to load module: SIO2MAN");
241 printf(
"Failed to load module: MCMAN");
247 printf(
"Failed to load module: MCSERV");
253 printf(
"Failed to load module: SIO2MAN");
259 printf(
"Failed to load module: MCMAN");
265 printf(
"Failed to load module: MCSERV");
int SifLoadModule(const char *path, int arg_len, const char *args)
References NULL, SifLoadModule(), and SleepThread().
Referenced by main().
◆ main()
Definition at line 39 of file mc_example.c.
49 printf(
"Failed to initialise memcard server!\n");
54 printf(
"Failed to initialise memcard server!\n");
59 printf(
"\nMemory card library example code - by Sjeep\n\n");
80 printf(
"mcGetInfo returned %d\n",ret);
86 printf(
"mcGetInfo returned %d\n",ret);
104 printf(
"mcGetDir returned %d\n\nListing of root directory on memory card:\n\n", ret);
106 for(i=0; i < ret; i++)
109 printf(
"[DIR] %s\n",
mcDir[i].name);
111 printf(
"%s - %d bytes\n",
mcDir[i].name,
mcDir[i].fileSizeByte);
115 fd = open(
"mc0:PS2DEV/icon.sys", O_RDONLY);
118 printf(
"\nNo previous save exists, creating...\n");
122 printf(
"Failed to create save! Errorno: %d\n",ret);
128 printf(
"\nPrevious save exists, listing directory\n\n");
131 printf(
"mcGetDir returned %d\n\n", ret);
133 for(i=0; i < ret; i++)
136 printf(
"[DIR] %s\n",
mcDir[i].name);
138 printf(
"%s - %d bytes\n",
mcDir[i].name,
mcDir[i].fileSizeByte);
int mcGetDir(int port, int slot, const char *name, unsigned mode, int maxent, sceMcTblGetDir *table)
int mcGetInfo(int port, int slot, int *type, int *free, int *format)
int mcSync(int mode, int *cmd, int *result)
static mcTable mcDir[ARRAY_ENTRIES]
void SifInitRpc(int mode)
References ARRAY_ENTRIES, CreateSave(), LoadModules(), MC_ATTR_SUBDIR, mc_Format, mc_Free, mc_Type, MC_TYPE_MC, MC_TYPE_XMC, mcDir, mcGetDir(), mcGetInfo(), mcInit(), mcSync(), NULL, SifExitRpc(), SifInitRpc(), and SleepThread().
◆ mc_Format
◆ mc_Free
◆ mc_Type
◆ mcDir