int FileWrite( FHANDLE handle, void *buffer, int size ) { int ret = 0; if( handle.dt == DT_CD ) { ret = fioWrite( handle.fh, buffer, size ); } else if( handle.dt == DT_HDD ) { ret = fileXioWrite( handle.fh, buffer, size ); } else if( handle.dt == DT_MC ) { ret = fioWrite( handle.fh, buffer, size ); } else if( handle.dt == DT_USB ) { ret = fioWrite( handle.fh, buffer, size ); } else if( handle.dt == DT_HOST ) { ret = fioWrite( handle.fh, buffer, size ); } else if( handle.dt == DT_SMB_SHARE ) { ret = smbc_write( handle.fh, buffer, size ); } return ret; }
int CreateSave(void) { int mc_fd; int icon_fd,icon_size; char* icon_buffer; mcIcon icon_sys; static iconIVECTOR bgcolor[4] = { { 68, 23, 116, 0 }, // top left { 255, 255, 255, 0 }, // top right { 255, 255, 255, 0 }, // bottom left { 68, 23, 116, 0 }, // bottom right }; static iconFVECTOR lightdir[3] = { { 0.5, 0.5, 0.5, 0.0 }, { 0.0,-0.4,-0.1, 0.0 }, {-0.5,-0.5, 0.5, 0.0 }, }; static iconFVECTOR lightcol[3] = { { 0.3, 0.3, 0.3, 0.00 }, { 0.4, 0.4, 0.4, 0.00 }, { 0.5, 0.5, 0.5, 0.00 }, }; static iconFVECTOR ambient = { 0.50, 0.50, 0.50, 0.00 }; if(fioMkdir("mc0:PS2DEV") < 0) return -1; // Set up icon.sys. This is the file which controls how our memory card save looks // in the PS2 browser screen. It contains info on the bg colour, lighting, save name // and icon filenames. Please note that the save name is sjis encoded. memset(&icon_sys, 0, sizeof(mcIcon)); strcpy(icon_sys.head, "PS2D"); strcpy_sjis((short *)&icon_sys.title, "Memcard Example\nPS2Dev r0x0rs"); icon_sys.nlOffset = 16; icon_sys.trans = 0x60; memcpy(icon_sys.bgCol, bgcolor, sizeof(bgcolor)); memcpy(icon_sys.lightDir, lightdir, sizeof(lightdir)); memcpy(icon_sys.lightCol, lightcol, sizeof(lightcol)); memcpy(icon_sys.lightAmbient, ambient, sizeof(ambient)); strcpy(icon_sys.view, "ps2dev.icn"); // these filenames are relative to the directory strcpy(icon_sys.copy, "ps2dev.icn"); // in which icon.sys resides. strcpy(icon_sys.del, "ps2dev.icn"); // Write icon.sys to the memory card (Note that this filename is fixed) mc_fd = fioOpen("mc0:PS2DEV/icon.sys",O_WRONLY | O_CREAT); if(mc_fd < 0) return -2; fioWrite(mc_fd, &icon_sys, sizeof(icon_sys)); fioClose(mc_fd); printf("icon.sys written sucessfully.\n"); // Write icon file to the memory card. // Note: The icon file was created with my bmp2icon tool, available for download at // http://www.ps2dev.org icon_fd = fioOpen("host:ps2dev.icn",O_RDONLY); if(icon_fd < 0) return -3; icon_size = fioLseek(icon_fd,0,SEEK_END); fioLseek(icon_fd,0,SEEK_SET); icon_buffer = malloc(icon_size); if(icon_buffer == NULL) return -4; if(fioRead(icon_fd, icon_buffer, icon_size) != icon_size) return -5; fioClose(icon_fd); icon_fd = fioOpen("mc0:PS2DEV/ps2dev.icn",O_WRONLY | O_CREAT); if(icon_fd < 0) return -6; fioWrite(icon_fd,icon_buffer,icon_size); fioClose(icon_fd); printf("ps2dev.icn written sucessfully.\n"); return 0; }
int fioPutc(int fd,int c) { return fioWrite(fd,&c,1); }
int Sys_FileWrite (int handle, void *data, int count) { return fioWrite(sys_handles[handle], data, count); }
static tsize_t _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) { return ((tsize_t) fioWrite((int) fd, buf, (size_t) size)); }
int SMS_SaveConfig ( void ) { int retVal = 0; int lRes; MC_GetInfo ( 0, 0, &lRes, &lRes, &lRes ); MC_Sync ( &lRes ); if ( lRes > -2 ) { SMS_MCTable lDir __attribute__( ( aligned( 64 ) ) ); MC_GetDir ( 0, 0, s_pSMS, 0, 1, &lDir ); MC_Sync ( &lRes ); if ( lRes || !fioMkdir ( s_pMC0SMS ) ) { int lFD = fioOpen ( s_pIcoSys, O_RDONLY ); if ( lFD < 0 ) { static int lBgClr[ 4 ][ 4 ] __attribute__( ( section( ".data" ) ) ) = { { 68, 23, 116, 0 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, { 68, 23, 116, 0 } }; static float lLightDir[ 3 ][ 4 ] __attribute__( ( section( ".data" ) ) ) = { { 0.5F, 0.5F, 0.5F, 0.0F }, { 0.0F, -0.4F, -0.1F, 0.0F }, { -0.5F, -0.5F, 0.5F, 0.0F } }; static float lLightCol[ 3 ][ 4 ] __attribute__( ( section( ".data" ) ) ) = { { 0.3F, 0.3F, 0.3F, 0.0F }, { 0.4F, 0.4F, 0.4F, 0.0F }, { 0.5F, 0.5F, 0.5F, 0.0F } }; static float lAmb[ 4 ] __attribute__( ( section( ".data" ) ) ) = { 0.5F, 0.5F, 0.5F, 0.0F }; SMS_MCIcon lIcon; memset ( &lIcon, 0, sizeof ( SMS_MCIcon ) ); strcpy ( lIcon.m_Header, s_pPS2D ); strcpy_sjis ( ( short* )&lIcon.m_Title, s_pSMS + 1 ); lIcon.m_Offset = 16; lIcon.m_Trans = 0x60; memcpy ( lIcon.m_ClrBg, lBgClr, sizeof ( lBgClr ) ); memcpy ( lIcon.m_LightDir, lLightDir, sizeof ( lLightDir ) ); memcpy ( lIcon.m_LightCol, lLightCol, sizeof ( lLightCol ) ); memcpy ( lIcon.m_LightAmb, lAmb, sizeof ( lAmb ) ); strcpy ( lIcon.m_View, s_pSMSICN ); strcpy ( lIcon.m_Copy, s_pSMSICN ); strcpy ( lIcon.m_Del, s_pSMSICN ); lFD = fioOpen ( s_pIcoSys, O_WRONLY | O_CREAT ); if ( lFD >= 0 ) { fioWrite ( lFD, &lIcon, sizeof ( lIcon ) ); fioClose ( lFD ); lFD = fioOpen ( s_pSMSIcn, O_WRONLY | O_CREAT ); if ( lFD >= 0 ) { fioWrite ( lFD, g_IconSMS, sizeof ( g_IconSMS ) ); fioClose ( lFD ); } /* end if */ } /* end if */ } else fioClose ( lFD );