diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core.cpp | 16 | ||||
-rw-r--r-- | src/core/core.h | 13 | ||||
-rw-r--r-- | src/core/file_sys/content_archive.cpp | 6 | ||||
-rw-r--r-- | src/core/file_sys/content_archive.h | 10 | ||||
-rw-r--r-- | src/core/file_sys/directory.h | 23 | ||||
-rw-r--r-- | src/core/frontend/applets/web_browser.cpp | 2 | ||||
-rw-r--r-- | src/core/frontend/applets/web_browser.h | 4 | ||||
-rw-r--r-- | src/core/hle/service/am/applets/web_browser.cpp | 12 | ||||
-rw-r--r-- | src/core/loader/loader.h | 4 | ||||
-rw-r--r-- | src/core/loader/nax.cpp | 9 | ||||
-rw-r--r-- | src/core/loader/nax.h | 3 | ||||
-rw-r--r-- | src/core/loader/nca.cpp | 19 | ||||
-rw-r--r-- | src/core/loader/nca.h | 3 | ||||
-rw-r--r-- | src/core/loader/nsp.cpp | 9 | ||||
-rw-r--r-- | src/core/loader/nsp.h | 3 | ||||
-rw-r--r-- | src/core/loader/xci.cpp | 8 | ||||
-rw-r--r-- | src/core/loader/xci.h | 3 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 2 | ||||
-rw-r--r-- | src/yuzu/applets/web_browser.cpp | 6 | ||||
-rw-r--r-- | src/yuzu/applets/web_browser.h | 9 |
20 files changed, 114 insertions, 50 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 31c590866..572814e4b 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -443,27 +443,31 @@ std::shared_ptr<FileSys::VfsFilesystem> System::GetFilesystem() const { return impl->virtual_filesystem; } -void System::SetProfileSelector(std::unique_ptr<Core::Frontend::ProfileSelectApplet> applet) { +void System::SetProfileSelector(std::unique_ptr<Frontend::ProfileSelectApplet> applet) { impl->profile_selector = std::move(applet); } -const Core::Frontend::ProfileSelectApplet& System::GetProfileSelector() const { +const Frontend::ProfileSelectApplet& System::GetProfileSelector() const { return *impl->profile_selector; } -void System::SetSoftwareKeyboard(std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> applet) { +void System::SetSoftwareKeyboard(std::unique_ptr<Frontend::SoftwareKeyboardApplet> applet) { impl->software_keyboard = std::move(applet); } -const Core::Frontend::SoftwareKeyboardApplet& System::GetSoftwareKeyboard() const { +const Frontend::SoftwareKeyboardApplet& System::GetSoftwareKeyboard() const { return *impl->software_keyboard; } -void System::SetWebBrowser(std::unique_ptr<Core::Frontend::WebBrowserApplet> applet) { +void System::SetWebBrowser(std::unique_ptr<Frontend::WebBrowserApplet> applet) { impl->web_browser = std::move(applet); } -const Core::Frontend::WebBrowserApplet& System::GetWebBrowser() const { +Frontend::WebBrowserApplet& System::GetWebBrowser() { + return *impl->web_browser; +} + +const Frontend::WebBrowserApplet& System::GetWebBrowser() const { return *impl->web_browser; } diff --git a/src/core/core.h b/src/core/core.h index a53dbb4d4..511a5ad3a 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -243,17 +243,18 @@ public: std::shared_ptr<FileSys::VfsFilesystem> GetFilesystem() const; - void SetProfileSelector(std::unique_ptr<Core::Frontend::ProfileSelectApplet> applet); + void SetProfileSelector(std::unique_ptr<Frontend::ProfileSelectApplet> applet); - const Core::Frontend::ProfileSelectApplet& GetProfileSelector() const; + const Frontend::ProfileSelectApplet& GetProfileSelector() const; - void SetSoftwareKeyboard(std::unique_ptr<Core::Frontend::SoftwareKeyboardApplet> applet); + void SetSoftwareKeyboard(std::unique_ptr<Frontend::SoftwareKeyboardApplet> applet); - const Core::Frontend::SoftwareKeyboardApplet& GetSoftwareKeyboard() const; + const Frontend::SoftwareKeyboardApplet& GetSoftwareKeyboard() const; - void SetWebBrowser(std::unique_ptr<Core::Frontend::WebBrowserApplet> applet); + void SetWebBrowser(std::unique_ptr<Frontend::WebBrowserApplet> applet); - const Core::Frontend::WebBrowserApplet& GetWebBrowser() const; + Frontend::WebBrowserApplet& GetWebBrowser(); + const Frontend::WebBrowserApplet& GetWebBrowser() const; private: System(); diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index 19b6f8600..5aa3b600b 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp @@ -359,6 +359,8 @@ bool NCA::ReadPFS0Section(const NCASectionHeader& section, const NCASectionTable dirs.push_back(std::move(npfs)); if (IsDirectoryExeFS(dirs.back())) exefs = dirs.back(); + else if (IsDirectoryLogoPartition(dirs.back())) + logo = dirs.back(); } else { if (has_rights_id) status = Loader::ResultStatus::ErrorIncorrectTitlekeyOrTitlekek; @@ -546,4 +548,8 @@ u64 NCA::GetBaseIVFCOffset() const { return ivfc_offset; } +VirtualDir NCA::GetLogoPartition() const { + return logo; +} + } // namespace FileSys diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index 99294cbb4..5d4d05c82 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h @@ -74,6 +74,13 @@ inline bool IsDirectoryExeFS(const std::shared_ptr<VfsDirectory>& pfs) { return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr; } +inline bool IsDirectoryLogoPartition(const VirtualDir& pfs) { + // NintendoLogo is the static image in the top left corner while StartupMovie is the animation + // in the bottom right corner. + return pfs->GetFile("NintendoLogo.png") != nullptr && + pfs->GetFile("StartupMovie.gif") != nullptr; +} + // An implementation of VfsDirectory that represents a Nintendo Content Archive (NCA) conatiner. // After construction, use GetStatus to determine if the file is valid and ready to be used. class NCA : public ReadOnlyVfsDirectory { @@ -102,6 +109,8 @@ public: // Returns the base ivfc offset used in BKTR patching. u64 GetBaseIVFCOffset() const; + VirtualDir GetLogoPartition() const; + private: bool CheckSupportedNCA(const NCAHeader& header); bool HandlePotentialHeaderDecryption(); @@ -122,6 +131,7 @@ private: VirtualFile romfs = nullptr; VirtualDir exefs = nullptr; + VirtualDir logo = nullptr; VirtualFile file; VirtualFile bktr_base_romfs; u64 ivfc_offset = 0; diff --git a/src/core/file_sys/directory.h b/src/core/file_sys/directory.h index 6690aa575..7b5c509fb 100644 --- a/src/core/file_sys/directory.h +++ b/src/core/file_sys/directory.h @@ -39,27 +39,4 @@ static_assert(sizeof(Entry) == 0x310, "Directory Entry struct isn't exactly 0x31 static_assert(offsetof(Entry, type) == 0x304, "Wrong offset for type in Entry."); static_assert(offsetof(Entry, file_size) == 0x308, "Wrong offset for file_size in Entry."); -class DirectoryBackend : NonCopyable { -public: - DirectoryBackend() {} - virtual ~DirectoryBackend() {} - - /** - * List files contained in the directory - * @param count Number of entries to return at once in entries - * @param entries Buffer to read data into - * @return Number of entries listed - */ - virtual u64 Read(const u64 count, Entry* entries) = 0; - - /// Returns the number of entries still left to read. - virtual u64 GetEntryCount() const = 0; - - /** - * Close the directory - * @return true if the directory closed correctly - */ - virtual bool Close() const = 0; -}; - } // namespace FileSys diff --git a/src/core/frontend/applets/web_browser.cpp b/src/core/frontend/applets/web_browser.cpp index 6a36b4b8f..3a3d3d0bf 100644 --- a/src/core/frontend/applets/web_browser.cpp +++ b/src/core/frontend/applets/web_browser.cpp @@ -13,7 +13,7 @@ DefaultWebBrowserApplet::~DefaultWebBrowserApplet() = default; void DefaultWebBrowserApplet::OpenPage(std::string_view filename, std::function<void()> unpack_romfs_callback, - std::function<void()> finished_callback) const { + std::function<void()> finished_callback) { LOG_INFO(Service_AM, "(STUBBED) called - No suitable web browser implementation found to open website page " "at '{}'!", diff --git a/src/core/frontend/applets/web_browser.h b/src/core/frontend/applets/web_browser.h index 41d272d26..f952856af 100644 --- a/src/core/frontend/applets/web_browser.h +++ b/src/core/frontend/applets/web_browser.h @@ -14,7 +14,7 @@ public: virtual ~WebBrowserApplet(); virtual void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, - std::function<void()> finished_callback) const = 0; + std::function<void()> finished_callback) = 0; }; class DefaultWebBrowserApplet final : public WebBrowserApplet { @@ -22,7 +22,7 @@ public: ~DefaultWebBrowserApplet() override; void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, - std::function<void()> finished_callback) const override; + std::function<void()> finished_callback) override; }; } // namespace Core::Frontend diff --git a/src/core/hle/service/am/applets/web_browser.cpp b/src/core/hle/service/am/applets/web_browser.cpp index d975207f5..9b0aa7f5f 100644 --- a/src/core/hle/service/am/applets/web_browser.cpp +++ b/src/core/hle/service/am/applets/web_browser.cpp @@ -2,9 +2,16 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <array> +#include <cstring> +#include <vector> + +#include "common/assert.h" +#include "common/common_funcs.h" #include "common/common_paths.h" +#include "common/file_util.h" #include "common/hex_util.h" -#include "common/logging/backend.h" +#include "common/logging/log.h" #include "common/string_util.h" #include "core/core.h" #include "core/file_sys/content_archive.h" @@ -12,7 +19,6 @@ #include "core/file_sys/nca_metadata.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/romfs.h" -#include "core/file_sys/romfs_factory.h" #include "core/file_sys/vfs_types.h" #include "core/frontend/applets/web_browser.h" #include "core/hle/kernel/process.h" @@ -146,7 +152,7 @@ void WebBrowser::Execute() { return; } - const auto& frontend{Core::System::GetInstance().GetWebBrowser()}; + auto& frontend{Core::System::GetInstance().GetWebBrowser()}; frontend.OpenPage(filename, [this] { UnpackRomFS(); }, [this] { Finalize(); }); } diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 01f984098..bb925f4a6 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -178,6 +178,8 @@ public: /** * Get the banner (typically banner section) of the application + * In the context of NX, this is the animation that displays in the bottom right of the screen + * when a game boots. Stored in GIF format. * @param buffer Reference to buffer to store data * @return ResultStatus result of function */ @@ -187,6 +189,8 @@ public: /** * Get the logo (typically logo section) of the application + * In the context of NX, this is the static image that displays in the top left of the screen + * when a game boots. Stored in JPEG format. * @param buffer Reference to buffer to store data * @return ResultStatus result of function */ diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp index a093e3d36..93a970d10 100644 --- a/src/core/loader/nax.cpp +++ b/src/core/loader/nax.cpp @@ -79,4 +79,13 @@ u64 AppLoader_NAX::ReadRomFSIVFCOffset() const { ResultStatus AppLoader_NAX::ReadProgramId(u64& out_program_id) { return nca_loader->ReadProgramId(out_program_id); } + +ResultStatus AppLoader_NAX::ReadBanner(std::vector<u8>& buffer) { + return nca_loader->ReadBanner(buffer); +} + +ResultStatus AppLoader_NAX::ReadLogo(std::vector<u8>& buffer) { + return nca_loader->ReadLogo(buffer); +} + } // namespace Loader diff --git a/src/core/loader/nax.h b/src/core/loader/nax.h index 0a97511b8..f40079574 100644 --- a/src/core/loader/nax.h +++ b/src/core/loader/nax.h @@ -39,6 +39,9 @@ public: u64 ReadRomFSIVFCOffset() const override; ResultStatus ReadProgramId(u64& out_program_id) override; + ResultStatus ReadBanner(std::vector<u8>& buffer) override; + ResultStatus ReadLogo(std::vector<u8>& buffer) override; + private: std::unique_ptr<FileSys::NAX> nax; std::unique_ptr<AppLoader_NCA> nca_loader; diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 7e1b0d84f..ce8196fcf 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp @@ -84,4 +84,23 @@ ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { return ResultStatus::Success; } +ResultStatus AppLoader_NCA::ReadBanner(std::vector<u8>& buffer) { + if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) + return ResultStatus::ErrorNotInitialized; + const auto logo = nca->GetLogoPartition(); + if (logo == nullptr) + return ResultStatus::ErrorNoIcon; + buffer = logo->GetFile("StartupMovie.gif")->ReadAllBytes(); + return ResultStatus::Success; +} + +ResultStatus AppLoader_NCA::ReadLogo(std::vector<u8>& buffer) { + if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) + return ResultStatus::ErrorNotInitialized; + const auto logo = nca->GetLogoPartition(); + if (logo == nullptr) + return ResultStatus::ErrorNoIcon; + buffer = logo->GetFile("NintendoLogo.png")->ReadAllBytes(); + return ResultStatus::Success; +} } // namespace Loader diff --git a/src/core/loader/nca.h b/src/core/loader/nca.h index cbbe701d2..b9f077468 100644 --- a/src/core/loader/nca.h +++ b/src/core/loader/nca.h @@ -39,6 +39,9 @@ public: u64 ReadRomFSIVFCOffset() const override; ResultStatus ReadProgramId(u64& out_program_id) override; + ResultStatus ReadBanner(std::vector<u8>& buffer) override; + ResultStatus ReadLogo(std::vector<u8>& buffer) override; + private: std::unique_ptr<FileSys::NCA> nca; std::unique_ptr<AppLoader_DeconstructedRomDirectory> directory_loader; diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index 7fcb12aa2..7da1f8960 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp @@ -166,4 +166,13 @@ ResultStatus AppLoader_NSP::ReadManualRomFS(FileSys::VirtualFile& file) { file = nca->GetRomFS(); return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; } + +ResultStatus AppLoader_NSP::ReadBanner(std::vector<u8>& buffer) { + return secondary_loader->ReadBanner(buffer); +} + +ResultStatus AppLoader_NSP::ReadLogo(std::vector<u8>& buffer) { + return secondary_loader->ReadLogo(buffer); +} + } // namespace Loader diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h index b6b309400..953a1b508 100644 --- a/src/core/loader/nsp.h +++ b/src/core/loader/nsp.h @@ -46,6 +46,9 @@ public: ResultStatus ReadControlData(FileSys::NACP& nacp) override; ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; + ResultStatus ReadBanner(std::vector<u8>& buffer) override; + ResultStatus ReadLogo(std::vector<u8>& buffer) override; + private: std::unique_ptr<FileSys::NSP> nsp; std::unique_ptr<AppLoader> secondary_loader; diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index ff60a3756..89f7bbf77 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -137,4 +137,12 @@ ResultStatus AppLoader_XCI::ReadManualRomFS(FileSys::VirtualFile& file) { return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; } +ResultStatus AppLoader_XCI::ReadBanner(std::vector<u8>& buffer) { + return nca_loader->ReadBanner(buffer); +} + +ResultStatus AppLoader_XCI::ReadLogo(std::vector<u8>& buffer) { + return nca_loader->ReadLogo(buffer); +} + } // namespace Loader diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h index e18531c93..d6995b61e 100644 --- a/src/core/loader/xci.h +++ b/src/core/loader/xci.h @@ -46,6 +46,9 @@ public: ResultStatus ReadControlData(FileSys::NACP& control) override; ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; + ResultStatus ReadBanner(std::vector<u8>& buffer) override; + ResultStatus ReadLogo(std::vector<u8>& buffer) override; + private: std::unique_ptr<FileSys::XCI> xci; std::unique_ptr<AppLoader_NCA> nca_loader; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 73567eb8c..27d259f51 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -365,7 +365,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { // (sometimes it's half the screen, sometimes three quarters). To avoid this, enable the // clip distances only when it's written by a shader stage. for (std::size_t i = 0; i < Maxwell::NumClipDistances; ++i) { - clip_distances[i] |= shader->GetShaderEntries().clip_distances[i]; + clip_distances[i] = clip_distances[i] || shader->GetShaderEntries().clip_distances[i]; } // When VertexA is enabled, we have dual vertex shaders diff --git a/src/yuzu/applets/web_browser.cpp b/src/yuzu/applets/web_browser.cpp index c59b7ade1..6a9138d53 100644 --- a/src/yuzu/applets/web_browser.cpp +++ b/src/yuzu/applets/web_browser.cpp @@ -86,9 +86,9 @@ QtWebBrowser::QtWebBrowser(GMainWindow& main_window) { QtWebBrowser::~QtWebBrowser() = default; void QtWebBrowser::OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, - std::function<void()> finished_callback) const { - this->unpack_romfs_callback = unpack_romfs_callback; - this->finished_callback = finished_callback; + std::function<void()> finished_callback) { + this->unpack_romfs_callback = std::move(unpack_romfs_callback); + this->finished_callback = std::move(finished_callback); const auto index = url.find('?'); if (index == std::string::npos) { diff --git a/src/yuzu/applets/web_browser.h b/src/yuzu/applets/web_browser.h index bba273767..1a3d67353 100644 --- a/src/yuzu/applets/web_browser.h +++ b/src/yuzu/applets/web_browser.h @@ -38,16 +38,15 @@ public: ~QtWebBrowser() override; void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback, - std::function<void()> finished_callback) const override; + std::function<void()> finished_callback) override; signals: void MainWindowOpenPage(std::string_view filename, std::string_view additional_args) const; -public slots: +private: void MainWindowUnpackRomFS(); void MainWindowFinishedBrowsing(); -private: - mutable std::function<void()> unpack_romfs_callback; - mutable std::function<void()> finished_callback; + std::function<void()> unpack_romfs_callback; + std::function<void()> finished_callback; }; |