bool InputIsoFile::Open( const wxString& srcfile, bool testOnly ) { Close(); m_filename = srcfile; // Allow write sharing of the iso based on the ini settings. // Mostly useful for romhacking, where the disc is frequently // changed and the emulator would block modifications m_reader = new FlatFileReader(EmuConfig.CdvdShareWrite); m_reader->Open(m_filename); bool isBlockdump, isCompressed = false; if(isBlockdump = BlockdumpFileReader::DetectBlockdump(m_reader)) { delete m_reader; BlockdumpFileReader *bdr = new BlockdumpFileReader();; bdr->Open(m_filename); m_blockofs = bdr->GetBlockOffset(); m_blocksize = bdr->GetBlockSize(); m_reader = bdr; ReadUnit = 1; } else if (isCompressed = CompressedFileReader::DetectCompressed(m_reader)) { delete m_reader; m_reader = CompressedFileReader::GetNewReader(m_filename); m_reader->Open(m_filename); } bool detected = Detect(); if(testOnly) return detected; if (!detected) throw Exception::BadStream() .SetUserMsg(_("Unrecognized ISO image file format")) .SetDiagMsg(L"ISO mounting failed: PCSX2 is unable to identify the ISO image type."); if(!isBlockdump && !isCompressed) { ReadUnit = MaxReadUnit; m_reader->SetDataOffset(m_offset); m_reader->SetBlockSize(m_blocksize); // Returns the original reader if single-part or a Multipart reader otherwise AsyncFileReader* m_reader_old = m_reader; m_reader = MultipartFileReader::DetectMultipart(m_reader); if (m_reader != m_reader_old) // Not the same object the old one need to be deleted delete m_reader_old; } m_blocks = m_reader->GetBlockCount(); Console.WriteLn(Color_StrongBlue, L"isoFile open ok: %s", WX_STR(m_filename)); ConsoleIndentScope indent; Console.WriteLn("Image type = %s", nameFromType(m_type)); //Console.WriteLn("Fileparts = %u", m_numparts); // Pointless print, it's 1 unless it says otherwise above DevCon.WriteLn ("blocks = %u", m_blocks); DevCon.WriteLn ("offset = %d", m_offset); DevCon.WriteLn ("blocksize = %u", m_blocksize); DevCon.WriteLn ("blockoffset = %d", m_blockofs); return true; }
// Portable installations are assumed to be run in either administrator rights mode, or run // from "insecure media" such as a removable flash drive. In these cases, the default path for // PCSX2 user documents becomes ".", which is the current working directory. // // Portable installation mode is typically enabled via the presence of an INI file in the // same directory that PCSX2 is installed to. // wxConfigBase* Pcsx2App::TestForPortableInstall() { InstallationMode = InstallMode_Registered; const wxFileName portableIniFile( GetPortableIniPath() ); const wxDirName portableDocsFolder( portableIniFile.GetPath() ); if (Startup.PortableMode || portableIniFile.FileExists()) { wxString FilenameStr = portableIniFile.GetFullPath(); if (Startup.PortableMode) Console.WriteLn( L"(UserMode) Portable mode requested via commandline switch!" ); else Console.WriteLn( L"(UserMode) Found portable install ini @ %s", WX_STR(FilenameStr) ); // Just because the portable ini file exists doesn't mean we can actually run in portable // mode. In order to determine our read/write permissions to the PCSX2, we must try to // modify the configured documents folder, and catch any ensuing error. std::unique_ptr<wxFileConfig> conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) ); conf_portable->SetRecordDefaults(false); while( true ) { wxString accessFailedStr, createFailedStr; if (TestUserPermissionsRights( portableDocsFolder, createFailedStr, accessFailedStr )) break; wxDialogWithHelpers dialog( NULL, AddAppName(_("Portable mode error - %s")) ); wxTextCtrl* scrollText = new wxTextCtrl( &dialog, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_MULTILINE | wxTE_WORDWRAP ); if (!createFailedStr.IsEmpty()) scrollText->AppendText( createFailedStr + L"\n" ); if (!accessFailedStr.IsEmpty()) scrollText->AppendText( accessFailedStr + L"\n" ); dialog += dialog.Heading( _("PCSX2 has been installed as a portable application but cannot run due to the following errors:" ) ); dialog += scrollText | pxExpand.Border(wxALL, 16); dialog += 6; dialog += dialog.Text( GetMsg_PortableModeRights() ); // [TODO] : Add url for platform-relevant user permissions tutorials? (low priority) wxWindowID result = pxIssueConfirmation( dialog, MsgButtons().Retry().Cancel().Custom(_("Switch to User Documents Mode"), "switchmode") ); switch (result) { case wxID_CANCEL: throw Exception::StartupAborted( L"User canceled portable mode due to insufficient user access/permissions." ); case wxID_RETRY: // do nothing (continues while loop) break; case pxID_CUSTOM: wxDialogWithHelpers dialog2( NULL, AddAppName(_("%s is switching to local install mode.")) ); dialog2 += dialog2.Heading( _("Try to remove the file called \"portable.ini\" from your installation directory manually." ) ); dialog2 += 6; pxIssueConfirmation( dialog2, MsgButtons().OK() ); return NULL; } } // Success -- all user-based folders have write access. PCSX2 should be able to run error-free! // Force-set the custom documents mode, and set the InstallationMode = InstallMode_Portable; DocsFolderMode = DocsFolder_Custom; CustomDocumentsFolder = portableDocsFolder; return conf_portable.release(); } return NULL; }
// This function should be called once during program execution. void SysLogMachineCaps() { if ( !PCSX2_isReleaseVersion ) { Console.WriteLn(Color_StrongGreen, "PCSX2 %u.%u.%u-%lld %s" #ifndef DISABLE_BUILD_DATE "- compiled on " __DATE__ #endif , PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV, SVN_MODS ? "(modded)" : "" ); } else { // shorter release version string Console.WriteLn(Color_StrongGreen, "PCSX2 %u.%u.%u-%lld" #ifndef DISABLE_BUILD_DATE "- compiled on " __DATE__ #endif , PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV ); } Console.WriteLn( "Savestate version: 0x%x", g_SaveVersion); Console.Newline(); Console.WriteLn( Color_StrongBlack, "Host Machine Init:" ); Console.Indent().WriteLn( L"Operating System = %s\n" L"Physical RAM = %u MB", WX_STR(GetOSVersionString()), (u32)(GetPhysicalMemory() / _1mb) ); u32 speed = x86caps.CalculateMHz(); Console.Indent().WriteLn( L"CPU name = %s\n" L"Vendor/Model = %s (stepping %02X)\n" L"CPU speed = %u.%03u ghz (%u logical thread%ls)\n" L"x86PType = %s\n" L"x86Flags = %08x %08x\n" L"x86EFlags = %08x", WX_STR(fromUTF8( x86caps.FamilyName ).Trim().Trim(false)), WX_STR(fromUTF8( x86caps.VendorName )), x86caps.StepID, speed / 1000, speed % 1000, x86caps.LogicalCores, (x86caps.LogicalCores==1) ? L"" : L"s", WX_STR(x86caps.GetTypeName()), x86caps.Flags, x86caps.Flags2, x86caps.EFlags ); Console.Newline(); wxArrayString features[2]; // 2 lines, for readability! if( x86caps.hasStreamingSIMD2Extensions ) features[0].Add( L"SSE2" ); if( x86caps.hasStreamingSIMD3Extensions ) features[0].Add( L"SSE3" ); if( x86caps.hasSupplementalStreamingSIMD3Extensions ) features[0].Add( L"SSSE3" ); if( x86caps.hasStreamingSIMD4Extensions ) features[0].Add( L"SSE4.1" ); if( x86caps.hasStreamingSIMD4Extensions2 ) features[0].Add( L"SSE4.2" ); if( x86caps.hasAVX ) features[0].Add( L"AVX" ); if( x86caps.hasAVX2 ) features[0].Add( L"AVX2" ); if( x86caps.hasFMA) features[0].Add( L"FMA" ); if( x86caps.hasStreamingSIMD4ExtensionsA ) features[1].Add( L"SSE4a " ); const wxString result[2] = { JoinString( features[0], L".. " ), JoinString( features[1], L".. " ) }; Console.WriteLn( Color_StrongBlack, L"x86 Features Detected:" ); Console.Indent().WriteLn( result[0] + (result[1].IsEmpty() ? L"" : (L"\n" + result[1])) ); Console.Newline(); }
if (THREAD_VU1) cpuUsage.Write(L" | VU: %3d%%", m_CpuUsage.GetVUPct()); pxNonReleaseCode(cpuUsage.Write(L" | UI: %3d%%", m_CpuUsage.GetEEcorePct());) } const u64& smode2 = *(u64*)PS2GS_BASE(GS_SMODE2); SetTitle( pxsFmt( L"Slot %d | Speed%ls: %3d%% (%.02f)%ls | %ls-%ls | %s", States_GetCurrentSlot(), limiterStr, lround(per), fps, cpuUsage.c_str(), (smode2 & 2) ? L"frame" : L"field", (smode2 & 1) ? L"i" : L"p", WX_STR(fromUTF8(gsDest))) ); } void GSFrame::OnActivate( wxActivateEvent& evt ) { if( IsBeingDeleted() ) return; evt.Skip(); if( wxWindow* gsPanel = GetViewport() ) gsPanel->SetFocus(); } void GSFrame::OnMove( wxMoveEvent& evt ) { if( IsBeingDeleted() ) return;
// This method sets the requested language, based on wxLanguage id and an optional 'confirmation' // canonical code. If the canonical code is provided, it is used to confirm that the ID matches // the intended language/dialect. If the ID and canonical do not match, this method will use // wx's FindLAnguageInfo to provide a "best guess" canonical match (usually relying on the user's // operating system default). // // Rationale: wxWidgets language IDs are just simple enums, and not especially unique. Future // versions of PCSX2 may have language ID changes if built against new/different versions of wx. // To prevent PCSX2 from selecting a completely wrong language when upgraded, we double-check // the wxLanguage code against the canonical name. We can't simply use canonical names either // because those are not unique (dialects of chinese, for example), and wx returns the generic // form over a specific dialect, when given a choice. Thus a two-tier check is required. // // wxLanguage for specific dialect, and canonical as a fallback/safeguard in case the wxLanguage // id appears to be out of date. // // bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode ) { const wxLanguageInfo* info = wxLocale::GetLanguageInfo(wxLangId); // Check if you can load a similar language in case the current one is not yet provided if (info) { wxLanguage LangId_fallback = i18n_FallbackToAnotherLang((wxLanguage)info->Language); if (LangId_fallback != (wxLanguage)info->Language) info = wxLocale::GetLanguageInfo(LangId_fallback); } // note: language canonical name mismatch probably means wxWidgets version changed since // the user's ini file was provided. Missing/invalid ID probably means the same thing. // If either is true, and the caller provided a canonical name, then let wx do a best // match based on the canonical name. if (!info || (!langCode.IsEmpty() && (langCode.CmpNoCase(info->CanonicalName) != 0))) { if (!info) Console.Warning( "Invalid language identifier (wxID=%d)", wxLangId ); if (!langCode.IsEmpty() && (langCode.CmpNoCase(L"default")!=0)) { info = wxLocale::FindLanguageInfo(langCode); if (!info) Console.Warning( "Unrecognized language canonical name '%ls'", WX_STR(langCode) ); } } if (!info) return false; if (wxGetLocale() && (info->Language == wxGetLocale()->GetLanguage())) return true; std::unique_ptr<wxLocale> locale(new wxLocale(info->Language)); if( !locale->IsOk() ) { Console.Warning( L"SetLanguage: '%s' [%s] is not supported by the operating system", WX_STR(i18n_GetBetterLanguageName(info)), WX_STR(locale->GetCanonicalName()) ); return false; } wxLangId = (wxLanguage)locale->GetLanguage(); if (wxLangId == wxLANGUAGE_UNKNOWN) { Console.WriteLn("System-default language is unknown? Defaulting back to English/US."); wxLangId = wxLANGUAGE_ENGLISH_US; } // English/US is built in, so no need to load MO/PO files. if( pxIsEnglish(wxLangId) ) { locale.release(); return true; } Console.WriteLn( L"Loading language translation databases for '%s' [%s]", WX_STR(i18n_GetBetterLanguageName(info)), WX_STR(locale->GetCanonicalName()) ); static const wxChar* dictFiles[] = { L"pcsx2_Main", L"pcsx2_Iconized" }; bool foundone = false; for (uint i=0; i<ArraySize(dictFiles); ++i) { if (!dictFiles[i]) continue; if (!locale->AddCatalog(dictFiles[i])) Console.Indent().WriteLn(Color_StrongYellow, "%ls not found -- translation dictionary may be incomplete.", dictFiles[i]); else foundone = true; } if (!foundone) { Console.Warning("SetLanguage: Requested translation is not implemented yet."); return false; } locale.release(); return true; }