summaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/CMakeLists.txt8
-rw-r--r--src/yuzu/configuration/config.cpp2
-rw-r--r--src/yuzu/configuration/configure_general.cpp2
-rw-r--r--src/yuzu/configuration/configure_general.ui29
-rw-r--r--src/yuzu/debugger/wait_tree.cpp4
-rw-r--r--src/yuzu/main.cpp128
-rw-r--r--src/yuzu/main.h7
-rw-r--r--src/yuzu/main.ui27
8 files changed, 160 insertions, 47 deletions
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index b901c29d2..9379d9110 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -82,10 +82,10 @@ set(UIS
)
file(GLOB COMPAT_LIST
- ${CMAKE_BINARY_DIR}/dist/compatibility_list/compatibility_list.qrc
- ${CMAKE_BINARY_DIR}/dist/compatibility_list/compatibility_list.json)
-file(GLOB_RECURSE ICONS ${CMAKE_SOURCE_DIR}/dist/icons/*)
-file(GLOB_RECURSE THEMES ${CMAKE_SOURCE_DIR}/dist/qt_themes/*)
+ ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.qrc
+ ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.json)
+file(GLOB_RECURSE ICONS ${PROJECT_SOURCE_DIR}/dist/icons/*)
+file(GLOB_RECURSE THEMES ${PROJECT_SOURCE_DIR}/dist/qt_themes/*)
qt5_wrap_ui(UI_HDRS ${UIS})
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 71c6ebb41..d029590ff 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -122,6 +122,7 @@ void Config::ReadValues() {
qt_config->beginGroup("System");
Settings::values.use_docked_mode = qt_config->value("use_docked_mode", false).toBool();
+ Settings::values.enable_nfc = qt_config->value("enable_nfc", true).toBool();
Settings::values.username = qt_config->value("username", "yuzu").toString().toStdString();
Settings::values.language_index = qt_config->value("language_index", 1).toInt();
qt_config->endGroup();
@@ -258,6 +259,7 @@ void Config::SaveValues() {
qt_config->beginGroup("System");
qt_config->setValue("use_docked_mode", Settings::values.use_docked_mode);
+ qt_config->setValue("enable_nfc", Settings::values.enable_nfc);
qt_config->setValue("username", QString::fromStdString(Settings::values.username));
qt_config->setValue("language_index", Settings::values.language_index);
qt_config->endGroup();
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp
index f5db9e55b..537d6e576 100644
--- a/src/yuzu/configuration/configure_general.cpp
+++ b/src/yuzu/configuration/configure_general.cpp
@@ -31,6 +31,7 @@ void ConfigureGeneral::setConfiguration() {
ui->theme_combobox->setCurrentIndex(ui->theme_combobox->findData(UISettings::values.theme));
ui->use_cpu_jit->setChecked(Settings::values.use_cpu_jit);
ui->use_docked_mode->setChecked(Settings::values.use_docked_mode);
+ ui->enable_nfc->setChecked(Settings::values.enable_nfc);
}
void ConfigureGeneral::PopulateHotkeyList(const HotkeyRegistry& registry) {
@@ -45,4 +46,5 @@ void ConfigureGeneral::applyConfiguration() {
Settings::values.use_cpu_jit = ui->use_cpu_jit->isChecked();
Settings::values.use_docked_mode = ui->use_docked_mode->isChecked();
+ Settings::values.enable_nfc = ui->enable_nfc->isChecked();
}
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui
index 1775c4d40..b82fffde8 100644
--- a/src/yuzu/configuration/configure_general.ui
+++ b/src/yuzu/configuration/configure_general.ui
@@ -68,19 +68,26 @@
<property name="title">
<string>Emulation</string>
</property>
- <layout class="QHBoxLayout" name="EmulationHorizontalLayout">
+ <layout class="QHBoxLayout" name="EmulationHorizontalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="EmulationVerticalLayout">
+ <item>
+ <widget class="QCheckBox" name="use_docked_mode">
+ <property name="text">
+ <string>Enable docked mode</string>
+ </property>
+ </widget>
+ </item>
<item>
- <layout class="QVBoxLayout" name="EmulationVerticalLayout">
- <item>
- <widget class="QCheckBox" name="use_docked_mode">
- <property name="text">
- <string>Enable docked mode</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QCheckBox" name="enable_nfc">
+ <property name="text">
+ <string>Enable NFC</string>
+ </property>
+ </widget>
</item>
- </layout>
+ </layout>
+ </item>
+ </layout>
</widget>
</item>
<item>
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp
index 7403e9ccd..0c831c9f4 100644
--- a/src/yuzu/debugger/wait_tree.cpp
+++ b/src/yuzu/debugger/wait_tree.cpp
@@ -9,8 +9,8 @@
#include "core/core.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/handle_table.h"
-#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/mutex.h"
+#include "core/hle/kernel/process.h"
#include "core/hle/kernel/scheduler.h"
#include "core/hle/kernel/thread.h"
#include "core/hle/kernel/timer.h"
@@ -83,7 +83,7 @@ QString WaitTreeText::GetText() const {
}
WaitTreeMutexInfo::WaitTreeMutexInfo(VAddr mutex_address) : mutex_address(mutex_address) {
- auto& handle_table = Core::System::GetInstance().Kernel().HandleTable();
+ const auto& handle_table = Core::CurrentProcess()->GetHandleTable();
mutex_value = Memory::Read32(mutex_address);
owner_handle = static_cast<Kernel::Handle>(mutex_value & Kernel::Mutex::MutexOwnerMask);
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index bef9df00d..be9896614 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -60,6 +60,8 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include "core/hle/kernel/process.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/filesystem/fsp_ldr.h"
+#include "core/hle/service/nfp/nfp.h"
+#include "core/hle/service/sm/sm.h"
#include "core/loader/loader.h"
#include "core/perf_stats.h"
#include "core/settings.h"
@@ -100,6 +102,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
+constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000;
+
/**
* "Callouts" are one-time instructional messages shown to the user. In the config settings, there
* is a bitfield "callout_flags" options, used to track if a message has already been shown to the
@@ -422,6 +426,7 @@ void GMainWindow::ConnectMenuEvents() {
connect(ui.action_Select_SDMC_Directory, &QAction::triggered, this,
[this] { OnMenuSelectEmulatedDirectory(EmulatedDirectoryTarget::SDMC); });
connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close);
+ connect(ui.action_Load_Amiibo, &QAction::triggered, this, &GMainWindow::OnLoadAmiibo);
// Emulation
connect(ui.action_Start, &QAction::triggered, this, &GMainWindow::OnStartGame);
@@ -690,6 +695,7 @@ void GMainWindow::ShutdownGame() {
ui.action_Stop->setEnabled(false);
ui.action_Restart->setEnabled(false);
ui.action_Report_Compatibility->setEnabled(false);
+ ui.action_Load_Amiibo->setEnabled(false);
render_window->hide();
game_list->show();
game_list->setFilterFocus();
@@ -823,14 +829,10 @@ static bool RomFSRawCopy(QProgressDialog& dialog, const FileSys::VirtualDir& src
}
void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_path) {
- const auto path = fmt::format("{}{:016X}/romfs",
- FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), program_id);
-
- const auto failed = [this, &path] {
+ const auto failed = [this] {
QMessageBox::warning(this, tr("RomFS Extraction Failed!"),
tr("There was an error copying the RomFS files or the user "
"cancelled the operation."));
- vfs->DeleteDirectory(path);
};
const auto loader = Loader::GetLoader(vfs->OpenFile(game_path, FileSys::Mode::Read));
@@ -845,10 +847,24 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
return;
}
- const auto romfs =
- loader->IsRomFSUpdatable()
- ? FileSys::PatchManager(program_id).PatchRomFS(file, loader->ReadRomFSIVFCOffset())
- : file;
+ const auto installed = Service::FileSystem::GetUnionContents();
+ auto romfs_title_id = SelectRomFSDumpTarget(*installed, program_id);
+
+ if (!romfs_title_id) {
+ failed();
+ return;
+ }
+
+ const auto path = fmt::format(
+ "{}{:016X}/romfs", FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), *romfs_title_id);
+
+ FileSys::VirtualFile romfs;
+
+ if (*romfs_title_id == program_id) {
+ romfs = file;
+ } else {
+ romfs = installed->GetEntry(*romfs_title_id, FileSys::ContentRecordType::Data)->GetRomFS();
+ }
const auto extracted = FileSys::ExtractRomFS(romfs, FileSys::RomFSExtractionType::Full);
if (extracted == nullptr) {
@@ -860,6 +876,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
if (out == nullptr) {
failed();
+ vfs->DeleteDirectory(path);
return;
}
@@ -870,8 +887,11 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
"files into the new directory while <br>skeleton will only create the directory "
"structure."),
{"Full", "Skeleton"}, 0, false, &ok);
- if (!ok)
+ if (!ok) {
failed();
+ vfs->DeleteDirectory(path);
+ return;
+ }
const auto full = res == "Full";
const auto entry_size = CalculateRomFSEntrySize(extracted, full);
@@ -888,6 +908,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
} else {
progress.close();
failed();
+ vfs->DeleteDirectory(path);
}
}
@@ -1174,6 +1195,7 @@ void GMainWindow::OnStartGame() {
ui.action_Report_Compatibility->setEnabled(true);
discord_rpc->Update();
+ ui.action_Load_Amiibo->setEnabled(true);
}
void GMainWindow::OnPauseGame() {
@@ -1278,6 +1300,27 @@ void GMainWindow::OnConfigure() {
}
}
+void GMainWindow::OnLoadAmiibo() {
+ const QString extensions{"*.bin"};
+ const QString file_filter = tr("Amiibo File (%1);; All Files (*.*)").arg(extensions);
+ const QString filename = QFileDialog::getOpenFileName(this, tr("Load Amiibo"), "", file_filter);
+ if (!filename.isEmpty()) {
+ Core::System& system{Core::System::GetInstance()};
+ Service::SM::ServiceManager& sm = system.ServiceManager();
+ auto nfc = sm.GetService<Service::NFP::Module::Interface>("nfp:user");
+ if (nfc != nullptr) {
+ auto nfc_file = FileUtil::IOFile(filename.toStdString(), "rb");
+ if (!nfc_file.IsOpen()) {
+ return;
+ }
+ std::vector<u8> amiibo_buffer(nfc_file.GetSize());
+ nfc_file.ReadBytes(amiibo_buffer.data(), amiibo_buffer.size());
+ nfc_file.Close();
+ nfc->LoadAmiibo(amiibo_buffer);
+ }
+ }
+}
+
void GMainWindow::OnAbout() {
AboutDialog aboutDialog(this);
aboutDialog.exec();
@@ -1318,15 +1361,17 @@ void GMainWindow::UpdateStatusBar() {
void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) {
QMessageBox::StandardButton answer;
QString status_message;
- const QString common_message = tr(
- "The game you are trying to load requires additional files from your Switch to be dumped "
- "before playing.<br/><br/>For more information on dumping these files, please see the "
- "following wiki page: <a "
- "href='https://yuzu-emu.org/wiki/"
- "dumping-system-archives-and-the-shared-fonts-from-a-switch-console/'>Dumping System "
- "Archives and the Shared Fonts from a Switch Console</a>.<br/><br/>Would you like to quit "
- "back to the game list? Continuing emulation may result in crashes, corrupted save "
- "data, or other bugs.");
+ const QString common_message =
+ tr("The game you are trying to load requires additional files from your Switch to be "
+ "dumped "
+ "before playing.<br/><br/>For more information on dumping these files, please see the "
+ "following wiki page: <a "
+ "href='https://yuzu-emu.org/wiki/"
+ "dumping-system-archives-and-the-shared-fonts-from-a-switch-console/'>Dumping System "
+ "Archives and the Shared Fonts from a Switch Console</a>.<br/><br/>Would you like to "
+ "quit "
+ "back to the game list? Continuing emulation may result in crashes, corrupted save "
+ "data, or other bugs.");
switch (result) {
case Core::System::ResultStatus::ErrorSystemFiles: {
QString message = "yuzu was unable to locate a Switch system archive";
@@ -1357,9 +1402,12 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
this, tr("Fatal Error"),
tr("yuzu has encountered a fatal error, please see the log for more details. "
"For more information on accessing the log, please see the following page: "
- "<a href='https://community.citra-emu.org/t/how-to-upload-the-log-file/296'>How to "
- "Upload the Log File</a>.<br/><br/>Would you like to quit back to the game list? "
- "Continuing emulation may result in crashes, corrupted save data, or other bugs."),
+ "<a href='https://community.citra-emu.org/t/how-to-upload-the-log-file/296'>How "
+ "to "
+ "Upload the Log File</a>.<br/><br/>Would you like to quit back to the game "
+ "list? "
+ "Continuing emulation may result in crashes, corrupted save data, or other "
+ "bugs."),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
status_message = "Fatal Error encountered";
break;
@@ -1459,6 +1507,42 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) {
}
}
+boost::optional<u64> GMainWindow::SelectRomFSDumpTarget(
+ const FileSys::RegisteredCacheUnion& installed, u64 program_id) {
+ const auto dlc_entries =
+ installed.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
+ std::vector<FileSys::RegisteredCacheEntry> 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::RegisteredCacheEntry& entry) {
+ return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == program_id &&
+ installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success;
+ });
+
+ std::vector<u64> romfs_tids;
+ romfs_tids.push_back(program_id);
+ for (const auto& entry : dlc_match)
+ romfs_tids.push_back(entry.title_id);
+
+ if (romfs_tids.size() > 1) {
+ QStringList list{"Base"};
+ for (std::size_t i = 1; i < romfs_tids.size(); ++i)
+ list.push_back(QStringLiteral("DLC %1").arg(romfs_tids[i] & 0x7FF));
+
+ bool ok;
+ const auto res = QInputDialog::getItem(
+ this, tr("Select RomFS Dump Target"),
+ tr("Please select which RomFS you would like to dump."), list, 0, false, &ok);
+ if (!ok) {
+ return boost::none;
+ }
+
+ return romfs_tids[list.indexOf(res)];
+ }
+
+ return program_id;
+}
+
bool GMainWindow::ConfirmClose() {
if (emu_thread == nullptr || !UISettings::values.confirm_before_closing)
return true;
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 3663d6aed..7c7c223e1 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -10,6 +10,7 @@
#include <QMainWindow>
#include <QTimer>
+#include <boost/optional.hpp>
#include "common/common_types.h"
#include "core/core.h"
#include "ui_main.h"
@@ -29,8 +30,9 @@ class WaitTreeWidget;
enum class GameListOpenTarget;
namespace FileSys {
+class RegisteredCacheUnion;
class VfsFilesystem;
-}
+} // namespace FileSys
namespace Tegra {
class DebugContext;
@@ -164,6 +166,7 @@ private slots:
void OnMenuSelectEmulatedDirectory(EmulatedDirectoryTarget target);
void OnMenuRecentFile();
void OnConfigure();
+ void OnLoadAmiibo();
void OnAbout();
void OnToggleFilterBar();
void OnDisplayTitleBars(bool);
@@ -175,6 +178,8 @@ private slots:
void OnReinitializeKeys(ReinitializeKeyBehavior behavior);
private:
+ boost::optional<u64> SelectRomFSDumpTarget(const FileSys::RegisteredCacheUnion&,
+ u64 program_id);
void UpdateStatusBar();
Ui::MainWindow ui;
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui
index dffd9c788..48d099591 100644
--- a/src/yuzu/main.ui
+++ b/src/yuzu/main.ui
@@ -57,8 +57,8 @@
<string>Recent Files</string>
</property>
</widget>
- <addaction name="action_Install_File_NAND" />
- <addaction name="separator"/>
+ <addaction name="action_Install_File_NAND"/>
+ <addaction name="separator"/>
<addaction name="action_Load_File"/>
<addaction name="action_Load_Folder"/>
<addaction name="separator"/>
@@ -68,6 +68,8 @@
<addaction name="action_Select_NAND_Directory"/>
<addaction name="action_Select_SDMC_Directory"/>
<addaction name="separator"/>
+ <addaction name="action_Load_Amiibo"/>
+ <addaction name="separator"/>
<addaction name="action_Exit"/>
</widget>
<widget class="QMenu" name="menu_Emulation">
@@ -117,11 +119,14 @@
<addaction name="menu_Tools" />
<addaction name="menu_Help"/>
</widget>
- <action name="action_Install_File_NAND">
- <property name="text">
- <string>Install File to NAND...</string>
- </property>
- </action>
+ <action name="action_Install_File_NAND">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Install File to NAND...</string>
+ </property>
+ </action>
<action name="action_Load_File">
<property name="text">
<string>Load File...</string>
@@ -253,6 +258,14 @@
<string>Restart</string>
</property>
</action>
+ <action name="action_Load_Amiibo">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Load Amiibo...</string>
+ </property>
+ </action>
<action name="action_Report_Compatibility">
<property name="enabled">
<bool>false</bool>