diff --git a/asmjitsrc/asmjit.vcxproj b/asmjitsrc/asmjit.vcxproj index 9290793a44..c923796bc5 100644 --- a/asmjitsrc/asmjit.vcxproj +++ b/asmjitsrc/asmjit.vcxproj @@ -1,10 +1,22 @@  + + Debug - LLVM + x64 + + + Debug - MemLeak + x64 + Debug x64 + + Release - LLVM + x64 + Release x64 @@ -71,64 +83,42 @@ 8.1 - + StaticLibrary - true - v140 Unicode - - - StaticLibrary - false v140 - Unicode - + + - - + + + + + + + + + + + + + + + + + - - $(SolutionDir)lib\$(Configuration)-$(Platform)\ - - - - - $(SolutionDir)lib\$(Configuration)-$(Platform)\ - - - - + - Level3 - Disabled - false - ASMJIT_STATIC;_MBCS;%(PreprocessorDefinitions) + NotUsing + ASMJIT_STATIC;%(PreprocessorDefinitions) - - true - - - - - Level3 - MaxSpeed - true - true - false - ASMJIT_STATIC;_UNICODE;UNICODE;%(PreprocessorDefinitions) - MultiThreadedDLL - - - true - true - true - diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index 8830ea9c3d..39d17eecd2 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -820,7 +820,6 @@ int DecryptEDAT(const std::string& input_file_name, const std::string& output_fi // Prepare the files. fs::file input(input_file_name); fs::file output(output_file_name, fom::rewrite); - fs::file rap(rap_file_name); // Set keys (RIF and DEVKLIC). unsigned char rifkey[0x10]; @@ -879,8 +878,10 @@ int DecryptEDAT(const std::string& input_file_name, const std::string& output_fi } // Read the RAP file, if provided. - if (rap) + if (rap_file_name.size()) { + fs::file rap(rap_file_name); + unsigned char rapkey[0x10]; memset(rapkey, 0, 0x10); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index 44fd5d9f00..d3204c22f3 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -75,7 +75,7 @@ s32 npDrmIsAvailable(u32 k_licensee_addr, vm::cptr drm_path) std::string pf_str("00000001"); // TODO: Allow multiple profiles. Use default for now. std::string rap_path("/dev_hdd0/home/" + pf_str + "/exdata/"); - // Search dev_usb000 for a compatible RAP file. + // Search for a compatible RAP file. for (const auto entry : vfsDir(rap_path)) { if (entry->name.find(titleID) != std::string::npos) @@ -88,13 +88,19 @@ s32 npDrmIsAvailable(u32 k_licensee_addr, vm::cptr drm_path) if (rap_path.back() == '/') { sceNp.warning("npDrmIsAvailable(): Can't find RAP file for '%s' (titleID='%s')", drm_path.get_ptr(), titleID); + rap_path.clear(); } // Decrypt this EDAT using the supplied k_licensee and matching RAP file. std::string enc_drm_path_local, dec_drm_path_local, rap_path_local; + Emu.GetVFS().GetDevice(enc_drm_path, enc_drm_path_local); Emu.GetVFS().GetDevice(dec_drm_path, dec_drm_path_local); - Emu.GetVFS().GetDevice(rap_path, rap_path_local); + + if (rap_path.size()) + { + Emu.GetVFS().GetDevice(rap_path, rap_path_local); + } if (DecryptEDAT(enc_drm_path_local, dec_drm_path_local, 8, rap_path_local, k_licensee, false) >= 0) { diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 9168206802..294dfaf635 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -218,7 +218,7 @@ void Emulator::Load() if (dir_list.size() >= 2 && dir_list.back() == "USRDIR" && *(dir_list.end() - 2) == "PS3_GAME") { // mount detected /dev_bdvd/ directory - Emu.GetVFS().Mount("/dev_bdvd/", elf_dir.substr(0, elf_dir.length() - 17), new vfsDeviceLocalFile()); + Emu.GetVFS().Mount("/dev_bdvd/", elf_dir.substr(0, elf_dir.length() - 16), new vfsDeviceLocalFile()); } } diff --git a/rpcs3/Gui/ConLogFrame.cpp b/rpcs3/Gui/ConLogFrame.cpp index ad235866a0..30ece36362 100644 --- a/rpcs3/Gui/ConLogFrame.cpp +++ b/rpcs3/Gui/ConLogFrame.cpp @@ -27,12 +27,10 @@ LogFrame::LogFrame(wxWindow* parent) m_log_file.open(fs::get_config_dir() + "RPCS3.log", fom::read | fom::create); m_tty_file.open(fs::get_config_dir() + "TTY.log", fom::read | fom::create); - // Check for updates every ~10 ms - m_timer.Start(10); - m_tty->SetBackgroundColour(wxColour("Black")); m_log->SetBackgroundColour(wxColour("Black")); m_tty->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); + m_tty->SetDefaultStyle(wxColour(255, 255, 255)); m_tabs.AddPage(m_log, "Log"); m_tabs.AddPage(m_tty, "TTY"); @@ -46,6 +44,9 @@ LogFrame::LogFrame(wxWindow* parent) Bind(wxEVT_MENU, &LogFrame::OnContextMenu, this, id_log_copy); Show(); + + // Check for updates every ~10 ms + m_timer.Start(10); } LogFrame::~LogFrame() @@ -101,42 +102,42 @@ void LogFrame::OnContextMenu(wxCommandEvent& event) void LogFrame::OnTimer(wxTimerEvent& event) { - char buf[8192]; - - const auto stamp0 = std::chrono::high_resolution_clock::now(); + char buf[4096]; + // Get UTF-8 string from file auto get_utf8 = [&](const fs::file& file, u64 size) -> wxString { - // Bruteforce valid UTF-8 (TODO) - for (u64 read = file.read(buf, size); read; read--) + size = file.read(buf, size); + + for (u64 i = 0; i < size; i++) { - wxString text = wxString::FromUTF8(buf, read); - if (!text.empty()) + // Get UTF-8 sequence length (no real validation performed) + const u64 tail = + (buf[i] & 0xF0) == 0xF0 ? 3 : + (buf[i] & 0xE0) == 0xE0 ? 2 : + (buf[i] & 0xC0) == 0xC0 ? 1 : 0; + + if (i + tail >= size) { - file.seek(read - size, fs::seek_cur); - return text; + file.seek(i - size, fs::seek_cur); + return wxString::FromUTF8(buf, i); } } - return{}; + return wxString::FromUTF8(buf, size); }; + const auto stamp0 = std::chrono::high_resolution_clock::now(); + // Check TTY logs while (const u64 size = std::min(sizeof(buf), _log::g_tty_file.size() - m_tty_file.seek(0, fs::seek_cur))) { const wxString& text = get_utf8(m_tty_file, size); - if (text.size()) - { - m_tty->SetDefaultStyle(wxColour(255, 255, 255)); - m_tty->AppendText(text); - } + m_tty->AppendText(text); // Limit processing time - if (std::chrono::high_resolution_clock::now() >= stamp0 + 4ms) - { - break; - } + if (std::chrono::high_resolution_clock::now() >= stamp0 + 4ms || text.empty()) break; } const auto stamp1 = std::chrono::high_resolution_clock::now(); @@ -146,16 +147,27 @@ void LogFrame::OnTimer(wxTimerEvent& event) { const wxString& text = get_utf8(m_log_file, size); - std::size_t start = 0, pos = 0; + // Append text if necessary + auto flush_logs = [&](u64 start, u64 pos) + { + if (pos != start && m_level <= rpcs3::config.misc.log.level.value()) + { + m_log->SetDefaultStyle(m_color); + m_log->AppendText(text.substr(start, pos - start)); + } + }; - for (; pos < text.size(); pos++) + // Parse log level formatting + for (std::size_t start = 0, pos = 0;; pos++) { if (text[pos] == L'·') { if (text.size() - pos <= 3) { - // Cannot get log string: abort + // Cannot get log formatting: abort m_log_file.seek(0 - text.substr(pos).ToUTF8().length(), fs::seek_cur); + + flush_logs(start, pos); break; } @@ -177,34 +189,22 @@ void LogFrame::OnTimer(wxTimerEvent& event) default: continue; } - if (pos != start && m_level <= rpcs3::config.misc.log.level.value()) - { - m_log->SetDefaultStyle(m_color); - m_log->AppendText(text.substr(start, pos - start)); - } + flush_logs(start, pos); start = pos + 3; m_level = level; m_color = color; } } - } - if (pos != start && m_level <= rpcs3::config.misc.log.level.value()) - { - m_log->SetDefaultStyle(m_color); - m_log->AppendText(text.substr(start, pos - start)); - } - - if (m_log->GetLastPosition() > 1024 * 1024) - { - m_log->Remove(0, m_log->GetLastPosition() - 512 * 1024); + if (pos >= text.size()) + { + flush_logs(start, pos); + break; + } } // Limit processing time - if (std::chrono::high_resolution_clock::now() >= stamp1 + 3ms) - { - break; - } + if (std::chrono::high_resolution_clock::now() >= stamp1 + 3ms || text.empty()) break; } } diff --git a/rpcs3_default.props b/rpcs3_default.props index 4a097de958..608b5ec62a 100644 --- a/rpcs3_default.props +++ b/rpcs3_default.props @@ -3,6 +3,7 @@ + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx12\Include;..\glm;..\GSL\include $(SolutionDir)lib\$(Configuration)-$(Platform)\ $(SolutionDir)lib\$(Configuration)-$(Platform)\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(SolutionDir)tmp\$(ProjectName)-$(Configuration)-$(Platform)\ @@ -13,7 +14,6 @@ true - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx12\Include;..\glm;..\GSL\include Level3 false true