HLE/Archives: Allow multiple loaded applications to access their SelfNCCH archive independently.
The loaders now register each loaded ROM with the SelfNCCH factory, which keeps the data around for the duration of the emulation session. When opening the SelfNCCH archive, the factory queries the current program's programid and uses that as a key to the map that contains the NCCHData structure (RomFS, Icon, Banner, etc). 3dsx files do not have a programid and will use a default of 0 for this value, thus, only 1 3dsx file with RomFS is loadable at the same time.
This commit is contained in:
parent
d881dee818
commit
774e7deae8
6 changed files with 66 additions and 19 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "core/file_sys/archive_savedata.h"
|
||||
#include "core/file_sys/archive_sdmc.h"
|
||||
#include "core/file_sys/archive_sdmcwriteonly.h"
|
||||
#include "core/file_sys/archive_selfncch.h"
|
||||
#include "core/file_sys/archive_systemsavedata.h"
|
||||
#include "core/file_sys/directory_backend.h"
|
||||
#include "core/file_sys/errors.h"
|
||||
|
@ -48,7 +49,7 @@ struct hash<Service::FS::ArchiveIdCode> {
|
|||
return std::hash<Type>()(static_cast<Type>(id_code));
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
static constexpr Kernel::Handle INVALID_HANDLE{};
|
||||
|
||||
|
@ -564,6 +565,21 @@ void RegisterArchiveTypes() {
|
|||
auto systemsavedata_factory =
|
||||
std::make_unique<FileSys::ArchiveFactory_SystemSaveData>(nand_directory);
|
||||
RegisterArchiveType(std::move(systemsavedata_factory), ArchiveIdCode::SystemSaveData);
|
||||
|
||||
auto selfncch_factory = std::make_unique<FileSys::ArchiveFactory_SelfNCCH>();
|
||||
RegisterArchiveType(std::move(selfncch_factory), ArchiveIdCode::SelfNCCH);
|
||||
}
|
||||
|
||||
void RegisterSelfNCCH(Loader::AppLoader& app_loader) {
|
||||
auto itr = id_code_map.find(ArchiveIdCode::SelfNCCH);
|
||||
if (itr == id_code_map.end()) {
|
||||
LOG_ERROR(Service_FS,
|
||||
"Could not register a new NCCH because the SelfNCCH archive hasn't been created");
|
||||
return;
|
||||
}
|
||||
|
||||
auto* factory = static_cast<FileSys::ArchiveFactory_SelfNCCH*>(itr->second.get());
|
||||
factory->Register(app_loader);
|
||||
}
|
||||
|
||||
void UnregisterArchiveTypes() {
|
||||
|
|
|
@ -21,6 +21,10 @@ static constexpr char SYSTEM_ID[]{"00000000000000000000000000000000"};
|
|||
/// The scrambled SD card CID, also known as ID1
|
||||
static constexpr char SDCARD_ID[]{"00000000000000000000000000000000"};
|
||||
|
||||
namespace Loader {
|
||||
class AppLoader;
|
||||
}
|
||||
|
||||
namespace Service {
|
||||
namespace FS {
|
||||
|
||||
|
@ -259,6 +263,9 @@ void ArchiveInit();
|
|||
/// Shutdown archives
|
||||
void ArchiveShutdown();
|
||||
|
||||
/// Registers a new NCCH file with the SelfNCCH archive factory
|
||||
void RegisterSelfNCCH(Loader::AppLoader& app_loader);
|
||||
|
||||
/// Register all archive types
|
||||
void RegisterArchiveTypes();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue