From 99ce1117c70cfd4800b120ca8bc62c5a1d41146c Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 9 Jul 2020 12:19:06 -0400 Subject: [PATCH 1/4] settings: Remove storage size options --- src/core/settings.h | 29 ----- src/yuzu/configuration/config.cpp | 29 +---- .../configuration/configure_filesystem.cpp | 27 ---- .../configuration/configure_filesystem.ui | 121 ------------------ src/yuzu_cmd/config.cpp | 9 -- 5 files changed, 1 insertion(+), 214 deletions(-) diff --git a/src/core/settings.h b/src/core/settings.h index 850ca4072c..29dc57c161 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -346,31 +346,6 @@ struct TouchscreenInput { u32 rotation_angle; }; -enum class NANDTotalSize : u64 { - S29_1GB = 0x747C00000ULL, -}; - -enum class NANDUserSize : u64 { - S26GB = 0x680000000ULL, -}; - -enum class NANDSystemSize : u64 { - S2_5GB = 0xA0000000, -}; - -enum class SDMCSize : u64 { - S1GB = 0x40000000, - S2GB = 0x80000000, - S4GB = 0x100000000ULL, - S8GB = 0x200000000ULL, - S16GB = 0x400000000ULL, - S32GB = 0x800000000ULL, - S64GB = 0x1000000000ULL, - S128GB = 0x2000000000ULL, - S256GB = 0x4000000000ULL, - S1TB = 0x10000000000ULL, -}; - enum class RendererBackend { OpenGL = 0, Vulkan = 1, @@ -491,10 +466,6 @@ struct Values { bool gamecard_inserted; bool gamecard_current_game; std::string gamecard_path; - NANDTotalSize nand_total_size; - NANDSystemSize nand_system_size; - NANDUserSize nand_user_size; - SDMCSize sdmc_size; // Debugging bool record_frame_times; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 1b2b1b2bb6..f48785697e 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -505,22 +505,6 @@ void Config::ReadDataStorageValues() { ReadSetting(QStringLiteral("gamecard_current_game"), false).toBool(); Settings::values.gamecard_path = ReadSetting(QStringLiteral("gamecard_path"), QStringLiteral("")).toString().toStdString(); - Settings::values.nand_total_size = static_cast( - ReadSetting(QStringLiteral("nand_total_size"), - QVariant::fromValue(static_cast(Settings::NANDTotalSize::S29_1GB))) - .toULongLong()); - Settings::values.nand_user_size = static_cast( - ReadSetting(QStringLiteral("nand_user_size"), - QVariant::fromValue(static_cast(Settings::NANDUserSize::S26GB))) - .toULongLong()); - Settings::values.nand_system_size = static_cast( - ReadSetting(QStringLiteral("nand_system_size"), - QVariant::fromValue(static_cast(Settings::NANDSystemSize::S2_5GB))) - .toULongLong()); - Settings::values.sdmc_size = static_cast( - ReadSetting(QStringLiteral("sdmc_size"), - QVariant::fromValue(static_cast(Settings::SDMCSize::S16GB))) - .toULongLong()); qt_config->endGroup(); } @@ -1006,18 +990,7 @@ void Config::SaveDataStorageValues() { false); WriteSetting(QStringLiteral("gamecard_path"), QString::fromStdString(Settings::values.gamecard_path), QStringLiteral("")); - WriteSetting(QStringLiteral("nand_total_size"), - QVariant::fromValue(static_cast(Settings::values.nand_total_size)), - QVariant::fromValue(static_cast(Settings::NANDTotalSize::S29_1GB))); - WriteSetting(QStringLiteral("nand_user_size"), - QVariant::fromValue(static_cast(Settings::values.nand_user_size)), - QVariant::fromValue(static_cast(Settings::NANDUserSize::S26GB))); - WriteSetting(QStringLiteral("nand_system_size"), - QVariant::fromValue(static_cast(Settings::values.nand_system_size)), - QVariant::fromValue(static_cast(Settings::NANDSystemSize::S2_5GB))); - WriteSetting(QStringLiteral("sdmc_size"), - QVariant::fromValue(static_cast(Settings::values.sdmc_size)), - QVariant::fromValue(static_cast(Settings::SDMCSize::S16GB))); + qt_config->endGroup(); } diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp index 835ee821cd..a089f57337 100644 --- a/src/yuzu/configuration/configure_filesystem.cpp +++ b/src/yuzu/configuration/configure_filesystem.cpp @@ -11,19 +11,6 @@ #include "yuzu/configuration/configure_filesystem.h" #include "yuzu/uisettings.h" -namespace { - -template -void SetComboBoxFromData(QComboBox* combo_box, T data) { - const auto index = combo_box->findData(QVariant::fromValue(static_cast(data))); - if (index >= combo_box->count() || index < 0) - return; - - combo_box->setCurrentIndex(index); -} - -} // Anonymous namespace - ConfigureFilesystem::ConfigureFilesystem(QWidget* parent) : QWidget(parent), ui(std::make_unique()) { ui->setupUi(this); @@ -73,11 +60,6 @@ void ConfigureFilesystem::setConfiguration() { ui->cache_game_list->setChecked(UISettings::values.cache_game_list); - SetComboBoxFromData(ui->nand_size, Settings::values.nand_total_size); - SetComboBoxFromData(ui->usrnand_size, Settings::values.nand_user_size); - SetComboBoxFromData(ui->sysnand_size, Settings::values.nand_system_size); - SetComboBoxFromData(ui->sdmc_size, Settings::values.sdmc_size); - UpdateEnabledControls(); } @@ -98,15 +80,6 @@ void ConfigureFilesystem::applyConfiguration() { Settings::values.dump_nso = ui->dump_nso->isChecked(); UISettings::values.cache_game_list = ui->cache_game_list->isChecked(); - - Settings::values.nand_total_size = static_cast( - ui->nand_size->itemData(ui->nand_size->currentIndex()).toULongLong()); - Settings::values.nand_system_size = static_cast( - ui->nand_size->itemData(ui->sysnand_size->currentIndex()).toULongLong()); - Settings::values.nand_user_size = static_cast( - ui->nand_size->itemData(ui->usrnand_size->currentIndex()).toULongLong()); - Settings::values.sdmc_size = static_cast( - ui->nand_size->itemData(ui->sdmc_size->currentIndex()).toULongLong()); } void ConfigureFilesystem::SetDirectory(DirectoryTarget target, QLineEdit* edit) { diff --git a/src/yuzu/configuration/configure_filesystem.ui b/src/yuzu/configuration/configure_filesystem.ui index 58cd07f527..84bea06001 100644 --- a/src/yuzu/configuration/configure_filesystem.ui +++ b/src/yuzu/configuration/configure_filesystem.ui @@ -115,127 +115,6 @@ - - - - Storage Sizes - - - - - - SD Card - - - - - - - System NAND - - - - - - - - 2.5 GB - - - - - - - - 32 GB - - - - 1 GB - - - - - 2 GB - - - - - 4 GB - - - - - 8 GB - - - - - 16 GB - - - - - 32 GB - - - - - 64 GB - - - - - 128 GB - - - - - 256 GB - - - - - 1 TB - - - - - - - - - 26 GB - - - - - - - - User NAND - - - - - - - NAND - - - - - - - - 29.1 GB - - - - - - - diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 23763144fb..dce70a1e00 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -335,15 +335,6 @@ void Config::ReadValues() { Settings::values.gamecard_current_game = sdl2_config->GetBoolean("Data Storage", "gamecard_current_game", false); Settings::values.gamecard_path = sdl2_config->Get("Data Storage", "gamecard_path", ""); - Settings::values.nand_total_size = static_cast(sdl2_config->GetInteger( - "Data Storage", "nand_total_size", static_cast(Settings::NANDTotalSize::S29_1GB))); - Settings::values.nand_user_size = static_cast(sdl2_config->GetInteger( - "Data Storage", "nand_user_size", static_cast(Settings::NANDUserSize::S26GB))); - Settings::values.nand_system_size = static_cast( - sdl2_config->GetInteger("Data Storage", "nand_system_size", - static_cast(Settings::NANDSystemSize::S2_5GB))); - Settings::values.sdmc_size = static_cast(sdl2_config->GetInteger( - "Data Storage", "sdmc_size", static_cast(Settings::SDMCSize::S16GB))); // System Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", false); From d3785160073b5dec5f620e9ccc3f6e103689ea13 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 9 Jul 2020 12:29:12 -0400 Subject: [PATCH 2/4] bis_factory: Use hardware default NAND partition sizes Sets the total space of user and system partitions to their hardware defaults. Furthermore, return the total space as free space for the user partition to prevent it from reaching zero. Some games like Bioshock 2 check for the available free space prior to save creation, and we should not be limited by arbitrary limits. --- src/core/file_sys/bis_factory.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/file_sys/bis_factory.cpp b/src/core/file_sys/bis_factory.cpp index 8935a62c30..a412dbd9c7 100644 --- a/src/core/file_sys/bis_factory.cpp +++ b/src/core/file_sys/bis_factory.cpp @@ -12,6 +12,10 @@ namespace FileSys { +constexpr u64 NAND_USER_SIZE = 0x680000000; // 26624 MiB +constexpr u64 NAND_SYSTEM_SIZE = 0xA0000000; // 2560 MiB +constexpr u64 NAND_TOTAL_SIZE = 0x747C00000; // 29820 MiB + BISFactory::BISFactory(VirtualDir nand_root_, VirtualDir load_root_, VirtualDir dump_root_) : nand_root(std::move(nand_root_)), load_root(std::move(load_root_)), dump_root(std::move(dump_root_)), @@ -110,30 +114,27 @@ VirtualDir BISFactory::GetImageDirectory() const { u64 BISFactory::GetSystemNANDFreeSpace() const { const auto sys_dir = GetOrCreateDirectoryRelative(nand_root, "/system"); - if (sys_dir == nullptr) - return 0; + if (sys_dir == nullptr) { + return GetSystemNANDTotalSpace(); + } return GetSystemNANDTotalSpace() - sys_dir->GetSize(); } u64 BISFactory::GetSystemNANDTotalSpace() const { - return static_cast(Settings::values.nand_system_size); + return NAND_SYSTEM_SIZE; } u64 BISFactory::GetUserNANDFreeSpace() const { - const auto usr_dir = GetOrCreateDirectoryRelative(nand_root, "/user"); - if (usr_dir == nullptr) - return 0; - - return GetUserNANDTotalSpace() - usr_dir->GetSize(); + return GetUserNANDTotalSpace(); } u64 BISFactory::GetUserNANDTotalSpace() const { - return static_cast(Settings::values.nand_user_size); + return NAND_USER_SIZE; } u64 BISFactory::GetFullNANDTotalSpace() const { - return static_cast(Settings::values.nand_total_size); + return NAND_TOTAL_SIZE; } VirtualDir BISFactory::GetBCATDirectory(u64 title_id) const { From bc260d4b5bf2a2222424c7211f46116ac089c598 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 9 Jul 2020 12:32:07 -0400 Subject: [PATCH 3/4] sdmc_factory: Set the SDMC total size to 1 TiB We should not be limited by the SDMC's partition size, set this to 1 TiB. Hardware is limited to the max allowed by the MBR partition table which is 2 TiB. --- src/core/file_sys/sdmc_factory.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp index 5113a1ca64..6f732e4d84 100644 --- a/src/core/file_sys/sdmc_factory.cpp +++ b/src/core/file_sys/sdmc_factory.cpp @@ -10,6 +10,8 @@ namespace FileSys { +constexpr u64 SDMC_TOTAL_SIZE = 0x10000000000; // 1 TiB + SDMCFactory::SDMCFactory(VirtualDir dir_) : dir(std::move(dir_)), contents(std::make_unique( GetOrCreateDirectoryRelative(dir, "/Nintendo/Contents/registered"), @@ -46,7 +48,7 @@ u64 SDMCFactory::GetSDMCFreeSpace() const { } u64 SDMCFactory::GetSDMCTotalSpace() const { - return static_cast(Settings::values.sdmc_size); + return SDMC_TOTAL_SIZE; } } // namespace FileSys From 9108fb8dd1c8528202182e38bf57139a50a3f5fb Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 9 Jul 2020 14:38:28 -0400 Subject: [PATCH 4/4] bis_factory: Set User NAND free space to be 1 MiB less than total. --- src/core/file_sys/bis_factory.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/file_sys/bis_factory.cpp b/src/core/file_sys/bis_factory.cpp index a412dbd9c7..285277ef80 100644 --- a/src/core/file_sys/bis_factory.cpp +++ b/src/core/file_sys/bis_factory.cpp @@ -126,7 +126,9 @@ u64 BISFactory::GetSystemNANDTotalSpace() const { } u64 BISFactory::GetUserNANDFreeSpace() const { - return GetUserNANDTotalSpace(); + // For some reason games such as BioShock 1 checks whether this is exactly 0x680000000 bytes. + // Set the free space to be 1 MiB less than the total as a workaround to this issue. + return GetUserNANDTotalSpace() - 0x100000; } u64 BISFactory::GetUserNANDTotalSpace() const {