From 6803515773c5065c6ad75c4cc9512c4ccd93c6c4 Mon Sep 17 00:00:00 2001 From: "Crunch (Chaz9)" Date: Sun, 29 Sep 2024 22:15:35 +0100 Subject: [PATCH] Experimental Changes --- src/core/hle/service/set/settings.cpp | 5 ++ src/core/nintendo_switch_library.cpp | 76 +++++++++++++++++++ src/core/nintendo_switch_library.h | 33 ++++++++ .../renderer_vulkan/vk_rasterizer.h | 3 +- 4 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/core/nintendo_switch_library.cpp create mode 100644 src/core/nintendo_switch_library.h diff --git a/src/core/hle/service/set/settings.cpp b/src/core/hle/service/set/settings.cpp index 73d021ff4d..8d9dd8f59c 100644 --- a/src/core/hle/service/set/settings.cpp +++ b/src/core/hle/service/set/settings.cpp @@ -23,4 +23,9 @@ void LoopProcess(Core::System& system) { ServerManager::RunServer(std::move(server_manager)); } +bool IsFirmwareVersionSupported(u32 version) { + // Add support for firmware version 18.0.0 + return version <= 180000; // 18.0.0 = 180000 +} + } // namespace Service::Set diff --git a/src/core/nintendo_switch_library.cpp b/src/core/nintendo_switch_library.cpp new file mode 100644 index 0000000000..15f26a9c38 --- /dev/null +++ b/src/core/nintendo_switch_library.cpp @@ -0,0 +1,76 @@ +// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include + +#include "common/logging/log.h" +#include "core/core.h" +#include "core/file_sys/content_archive.h" +#include "core/file_sys/patch_manager.h" +#include "core/file_sys/registered_cache.h" +#include "core/hle/service/filesystem/filesystem.h" +#include "core/loader/loader.h" +#include "core/nintendo_switch_library.h" + +namespace Core { + +NintendoSwitchLibrary::NintendoSwitchLibrary(Core::System& system) : system(system) {} + +std::vector NintendoSwitchLibrary::GetInstalledGames() { + std::vector games; + const auto& cache = system.GetContentProvider().GetUserNANDCache(); + + for (const auto& nca : cache.GetAllEntries()) { + if (nca.second == FileSys::ContentRecordType::Program) { + const auto program_id = nca.first; + const auto title_name = GetGameName(program_id); + const auto file_path = cache.GetEntryUnparsed(program_id, FileSys::ContentRecordType::Program); + + if (title_name.empty() || file_path.empty()) { + continue; + } + + games.push_back({program_id, title_name, file_path}); + } + } + + return games; +} + +std::string NintendoSwitchLibrary::GetGameName(u64 program_id) { + const auto& patch_manager = system.GetFileSystemController().GetPatchManager(program_id); + const auto metadata = patch_manager.GetControlMetadata(); + + if (metadata.first != nullptr) { + return metadata.first->GetApplicationName(); + } + + return ""; +} + +bool NintendoSwitchLibrary::LaunchGame(u64 program_id) { + const auto file_path = system.GetContentProvider().GetUserNANDCache().GetEntryUnparsed(program_id, FileSys::ContentRecordType::Program); + + if (file_path.empty()) { + LOG_ERROR(Core, "Failed to launch game. File not found for program_id={:016X}", program_id); + return false; + } + + const auto loader = Loader::GetLoader(system, file_path); + if (!loader) { + LOG_ERROR(Core, "Failed to create loader for game. program_id={:016X}", program_id); + return false; + } + + const auto result = system.Load(*loader); + if (result != ResultStatus::Success) { + LOG_ERROR(Core, "Failed to load game. Error: {}, program_id={:016X}", result, program_id); + return false; + } + + return true; +} + +} // namespace Core \ No newline at end of file diff --git a/src/core/nintendo_switch_library.h b/src/core/nintendo_switch_library.h new file mode 100644 index 0000000000..92da5c7aab --- /dev/null +++ b/src/core/nintendo_switch_library.h @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include + +#include "common/common_types.h" + +namespace Core { + +class System; + +class NintendoSwitchLibrary { +public: + struct GameInfo { + u64 program_id; + std::string title; + std::string file_path; + }; + + explicit NintendoSwitchLibrary(Core::System& system); + + std::vector GetInstalledGames(); + std::string GetGameName(u64 program_id); + bool LaunchGame(u64 program_id); + +private: + Core::System& system; +}; + +} // namespace Core \ No newline at end of file diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index 0617b37f05..253e209612 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h @@ -24,6 +24,7 @@ #include "video_core/renderer_vulkan/vk_update_descriptor.h" #include "video_core/vulkan_common/vulkan_memory_allocator.h" #include "video_core/vulkan_common/vulkan_wrapper.h" +#include "video_core/optimized_rasterizer.h" namespace Core { class System; @@ -73,7 +74,7 @@ private: Scheduler& scheduler; }; -class RasterizerVulkan final : public VideoCore::RasterizerInterface, +class RasterizerVulkan final : public VideoCore::OptimizedRasterizer, protected VideoCommon::ChannelSetupCaches { public: explicit RasterizerVulkan(Core::Frontend::EmuWindow& emu_window_, Tegra::GPU& gpu_,