mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Rework system title handling with up-to-date title list and region detection support. (#6356)
This commit is contained in:
		
							parent
							
								
									b5d6f645bd
								
							
						
					
					
						commit
						5346ca27b5
					
				
					 12 changed files with 1292 additions and 806 deletions
				
			
		|  | @ -458,6 +458,8 @@ add_library(core STATIC | |||
|     rpc/udp_server.h | ||||
|     savestate.cpp | ||||
|     savestate.h | ||||
|     system_titles.cpp | ||||
|     system_titles.h | ||||
|     telemetry_session.cpp | ||||
|     telemetry_session.h | ||||
|     tracer/citrace.h | ||||
|  |  | |||
|  | @ -25,6 +25,7 @@ | |||
| #include "core/loader/ncch.h" | ||||
| #include "core/loader/smdh.h" | ||||
| #include "core/memory.h" | ||||
| #include "core/system_titles.h" | ||||
| #include "network/network.h" | ||||
| 
 | ||||
| ////////////////////////////////////////////////////////////////////////////////////////////////////
 | ||||
|  | @ -162,7 +163,10 @@ ResultStatus AppLoader_NCCH::LoadExec(std::shared_ptr<Kernel::Process>& process) | |||
|     return ResultStatus::Error; | ||||
| } | ||||
| 
 | ||||
| void AppLoader_NCCH::ParseRegionLockoutInfo() { | ||||
| void AppLoader_NCCH::ParseRegionLockoutInfo(u64 program_id) { | ||||
|     auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); | ||||
|     ASSERT_MSG(cfg, "CFG Module missing!"); | ||||
| 
 | ||||
|     std::vector<u8> smdh_buffer; | ||||
|     if (ReadIcon(smdh_buffer) == ResultStatus::Success && smdh_buffer.size() >= sizeof(SMDH)) { | ||||
|         SMDH smdh; | ||||
|  | @ -176,9 +180,12 @@ void AppLoader_NCCH::ParseRegionLockoutInfo() { | |||
|             } | ||||
|             region_lockout >>= 1; | ||||
|         } | ||||
|         auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); | ||||
|         ASSERT_MSG(cfg, "CFG Module missing!"); | ||||
|         cfg->SetPreferredRegionCodes(regions); | ||||
|     } else { | ||||
|         const auto region = Core::GetSystemTitleRegion(program_id); | ||||
|         if (region.has_value()) { | ||||
|             cfg->SetPreferredRegionCodes({region.value()}); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -229,7 +236,7 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr<Kernel::Process>& process) { | |||
| 
 | ||||
|     system.ArchiveManager().RegisterSelfNCCH(*this); | ||||
| 
 | ||||
|     ParseRegionLockoutInfo(); | ||||
|     ParseRegionLockoutInfo(ncch_program_id); | ||||
| 
 | ||||
|     return ResultStatus::Success; | ||||
| } | ||||
|  |  | |||
|  | @ -76,7 +76,9 @@ private: | |||
|     ResultStatus LoadExec(std::shared_ptr<Kernel::Process>& process); | ||||
| 
 | ||||
|     /// Reads the region lockout info in the SMDH and send it to CFG service
 | ||||
|     void ParseRegionLockoutInfo(); | ||||
|     /// If an SMDH is not present, the program ID is compared against a list
 | ||||
|     /// of known system titles to determine the region.
 | ||||
|     void ParseRegionLockoutInfo(u64 program_id); | ||||
| 
 | ||||
|     /// Detects whether the NCCH contains GBA Virtual Console.
 | ||||
|     bool IsGbaVirtualConsole(const std::vector<u8>& code); | ||||
|  |  | |||
							
								
								
									
										1123
									
								
								src/core/system_titles.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1123
									
								
								src/core/system_titles.cpp
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										28
									
								
								src/core/system_titles.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/core/system_titles.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| // Copyright 2023 Citra Emulator Project
 | ||||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <vector> | ||||
| #include "common/common_types.h" | ||||
| 
 | ||||
| namespace Core { | ||||
| 
 | ||||
| constexpr u32 NUM_SYSTEM_TITLE_REGIONS = 7; | ||||
| 
 | ||||
| enum SystemTitleSet : u32 { Minimal = 1 << 0, Old3ds = 1 << 1, New3ds = 1 << 2 }; | ||||
| 
 | ||||
| /// Returns a list of firmware title IDs for a specific set and region.
 | ||||
| std::vector<u64> GetSystemTitleIds(SystemTitleSet set, u32 region); | ||||
| 
 | ||||
| /// Gets the home menu title ID for a specific region.
 | ||||
| u64 GetHomeMenuTitleId(u32 region); | ||||
| 
 | ||||
| /// Gets the home menu NCCH path for a specific region.
 | ||||
| std::string GetHomeMenuNcchPath(u32 region); | ||||
| 
 | ||||
| /// Returns the region of a system title, if it can be determined.
 | ||||
| std::optional<u32> GetSystemTitleRegion(u64 title_id); | ||||
| 
 | ||||
| } // namespace Core
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue