bool Ps2SaveFileManager::setupIcon(const char *dest, const char *ico, const char *descr1, const char *descr2) { mcIcon icon_sys; memset(&icon_sys, 0, sizeof(mcIcon)); memcpy(icon_sys.head, "PS2D", 4); char title[256]; if (!stricmp("SAVEGAME", descr1)) { // these are broken sword 1 savegames sprintf(title, "BSword1\n%s", descr2); icon_sys.nlOffset = 8; } else { sprintf(title, "%s\n%s", descr1, descr2); icon_sys.nlOffset = strlen(descr1) + 1; } strcpy_sjis((short*)&(icon_sys.title), title); icon_sys.trans = 0x10; 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((char*)icon_sys.view, ico); strcpy((char*)icon_sys.copy, ico); strcpy((char*)icon_sys.del, ico); int fd, res; fd = _mc->open(dest, O_WRONLY | O_CREAT); if (fd >= 0) { res = _mc->write(fd, &icon_sys, sizeof(icon_sys)); _mc->close(fd); return (res == sizeof(icon_sys)); } else return false; }
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 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 );