early-access version 3837

This commit is contained in:
pineappleEA
2023-08-27 02:56:33 +02:00
parent d07529eada
commit c807f0cfc8
17 changed files with 252 additions and 94 deletions
+72 -49
View File
@@ -2010,8 +2010,16 @@ bool GMainWindow::OnShutdownBegin() {
emit EmulationStopping();
int shutdown_time = 1000;
if (system->DebuggerEnabled()) {
shutdown_time = 0;
} else if (system->GetExitLocked()) {
shutdown_time = 5000;
}
shutdown_timer.setSingleShot(true);
shutdown_timer.start(system->DebuggerEnabled() ? 0 : 5000);
shutdown_timer.start(shutdown_time);
connect(&shutdown_timer, &QTimer::timeout, this, &GMainWindow::OnEmulationStopTimeExpired);
connect(emu_thread.get(), &QThread::finished, this, &GMainWindow::OnEmulationStopped);
@@ -2573,50 +2581,41 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
return;
}
FileSys::VirtualFile base_romfs;
if (loader->ReadRomFS(base_romfs) != Loader::ResultStatus::Success) {
failed();
return;
}
FileSys::VirtualFile packed_update_raw{};
loader->ReadUpdateRaw(packed_update_raw);
const auto& installed = system->GetContentProvider();
const auto romfs_title_id = SelectRomFSDumpTarget(installed, program_id);
if (!romfs_title_id) {
u64 title_id{};
u8 raw_type{};
if (!SelectRomFSDumpTarget(installed, program_id, &title_id, &raw_type)) {
failed();
return;
}
const auto type = *romfs_title_id == program_id ? FileSys::ContentRecordType::Program
: FileSys::ContentRecordType::Data;
const auto base_nca = installed.GetEntry(*romfs_title_id, type);
const auto type = static_cast<FileSys::ContentRecordType>(raw_type);
const auto base_nca = installed.GetEntry(title_id, type);
if (!base_nca) {
failed();
return;
}
const auto base_romfs = base_nca->GetRomFS();
if (!base_romfs) {
failed();
return;
}
const auto dump_dir =
target == DumpRomFSTarget::Normal
? Common::FS::GetYuzuPath(Common::FS::YuzuPath::DumpDir)
: Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir) / "atmosphere" / "contents";
const auto romfs_dir = fmt::format("{:016X}/romfs", *romfs_title_id);
const auto romfs_dir = fmt::format("{:016X}/romfs", title_id);
const auto path = Common::FS::PathToUTF8String(dump_dir / romfs_dir);
FileSys::VirtualFile romfs;
if (*romfs_title_id == program_id) {
const FileSys::PatchManager pm{program_id, system->GetFileSystemController(), installed};
romfs = pm.PatchRomFS(base_nca.get(), base_romfs, type, nullptr, false);
} else {
romfs = installed.GetEntry(*romfs_title_id, type)->GetRomFS();
}
const auto extracted = FileSys::ExtractRomFS(romfs, FileSys::RomFSExtractionType::Full);
if (extracted == nullptr) {
failed();
return;
}
const FileSys::PatchManager pm{title_id, system->GetFileSystemController(), installed};
auto romfs = pm.PatchRomFS(base_nca.get(), base_romfs, type, packed_update_raw, false);
const auto out = VfsFilesystemCreateDirectoryWrapper(vfs, path, FileSys::Mode::ReadWrite);
@@ -2640,6 +2639,12 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
return;
}
const auto extracted = FileSys::ExtractRomFS(romfs, FileSys::RomFSExtractionType::Full);
if (extracted == nullptr) {
failed();
return;
}
const auto full = res == selections.constFirst();
const auto entry_size = CalculateRomFSEntrySize(extracted, full);
@@ -3261,7 +3266,7 @@ void GMainWindow::OnPauseContinueGame() {
}
void GMainWindow::OnStopGame() {
if (system->GetExitLock() && !ConfirmForceLockedExit()) {
if (system->GetExitLocked() && !ConfirmForceLockedExit()) {
return;
}
@@ -4350,28 +4355,41 @@ bool GMainWindow::CheckSystemArchiveDecryption() {
return mii_nca->GetRomFS().get() != nullptr;
}
std::optional<u64> GMainWindow::SelectRomFSDumpTarget(const FileSys::ContentProvider& installed,
u64 program_id) {
const auto dlc_entries =
installed.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
std::vector<FileSys::ContentProviderEntry> dlc_match;
dlc_match.reserve(dlc_entries.size());
std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match),
[&program_id, &installed](const FileSys::ContentProviderEntry& entry) {
return FileSys::GetBaseTitleID(entry.title_id) == program_id &&
installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success;
});
bool GMainWindow::SelectRomFSDumpTarget(const FileSys::ContentProvider& installed, u64 program_id,
u64* selected_title_id, u8* selected_content_record_type) {
using ContentInfo = std::pair<FileSys::TitleType, FileSys::ContentRecordType>;
boost::container::flat_map<u64, ContentInfo> available_title_ids;
std::vector<u64> romfs_tids;
romfs_tids.push_back(program_id);
for (const auto& entry : dlc_match) {
romfs_tids.push_back(entry.title_id);
const auto RetrieveEntries = [&](FileSys::TitleType title_type,
FileSys::ContentRecordType record_type) {
const auto entries = installed.ListEntriesFilter(title_type, record_type);
for (const auto& entry : entries) {
if (FileSys::GetBaseTitleID(entry.title_id) == program_id &&
installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success) {
available_title_ids[entry.title_id] = {title_type, record_type};
}
}
};
RetrieveEntries(FileSys::TitleType::Application, FileSys::ContentRecordType::Program);
RetrieveEntries(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
if (available_title_ids.empty()) {
return false;
}
if (romfs_tids.size() > 1) {
QStringList list{QStringLiteral("Base")};
for (std::size_t i = 1; i < romfs_tids.size(); ++i) {
list.push_back(QStringLiteral("DLC %1").arg(romfs_tids[i] & 0x7FF));
size_t title_index = 0;
if (available_title_ids.size() > 1) {
QStringList list;
for (auto& [title_id, content_info] : available_title_ids) {
const auto hex_title_id = QString::fromStdString(fmt::format("{:X}", title_id));
if (content_info.first == FileSys::TitleType::Application) {
list.push_back(QStringLiteral("Application [%1]").arg(hex_title_id));
} else {
list.push_back(
QStringLiteral("DLC %1 [%2]").arg(title_id & 0x7FF).arg(hex_title_id));
}
}
bool ok;
@@ -4379,13 +4397,16 @@ std::optional<u64> GMainWindow::SelectRomFSDumpTarget(const FileSys::ContentProv
this, tr("Select RomFS Dump Target"),
tr("Please select which RomFS you would like to dump."), list, 0, false, &ok);
if (!ok) {
return {};
return false;
}
return romfs_tids[list.indexOf(res)];
title_index = list.indexOf(res);
}
return program_id;
const auto selected_info = available_title_ids.nth(title_index);
*selected_title_id = selected_info->first;
*selected_content_record_type = static_cast<u8>(selected_info->second.second);
return true;
}
bool GMainWindow::ConfirmClose() {
@@ -4515,6 +4536,8 @@ void GMainWindow::RequestGameExit() {
auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
bool has_signalled = false;
system->SetExitRequested(true);
if (applet_oe != nullptr) {
applet_oe->GetMessageQueue()->RequestExit();
has_signalled = true;
+2 -1
View File
@@ -375,7 +375,8 @@ private:
void RemoveAllTransferableShaderCaches(u64 program_id);
void RemoveCustomConfiguration(u64 program_id, const std::string& game_path);
void RemoveCacheStorage(u64 program_id);
std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
bool SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id,
u64* selected_title_id, u8* selected_content_record_type);
InstallResult InstallNSPXCI(const QString& filename);
InstallResult InstallNCA(const QString& filename);
void MigrateConfigFiles();