early-access version 3967
This commit is contained in:
parent
fb0108d8c6
commit
0cb0486814
5 changed files with 82 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
||||||
yuzu emulator early access
|
yuzu emulator early access
|
||||||
=============
|
=============
|
||||||
|
|
||||||
This is the source code for early-access 3966.
|
This is the source code for early-access 3967.
|
||||||
|
|
||||||
## Legal Notice
|
## Legal Notice
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/fs/file.h"
|
#include "common/fs/file.h"
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/polyfill_ranges.h"
|
#include "common/polyfill_ranges.h"
|
||||||
|
#include "common/stb.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/constants.h"
|
#include "core/constants.h"
|
||||||
|
@ -38,9 +40,36 @@ static std::filesystem::path GetImagePath(const Common::UUID& uuid) {
|
||||||
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString());
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr u32 SanitizeJPEGSize(std::size_t size) {
|
static void JPGToMemory(void* context, void* data, int len) {
|
||||||
|
std::vector<u8>* jpg_image = static_cast<std::vector<u8>*>(context);
|
||||||
|
unsigned char* jpg = static_cast<unsigned char*>(data);
|
||||||
|
jpg_image->insert(jpg_image->end(), jpg, jpg + len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SanitizeJPEGImageSize(std::vector<u8>& image) {
|
||||||
constexpr std::size_t max_jpeg_image_size = 0x20000;
|
constexpr std::size_t max_jpeg_image_size = 0x20000;
|
||||||
return static_cast<u32>(std::min(size, max_jpeg_image_size));
|
constexpr int profile_dimensions = 256;
|
||||||
|
int original_width, original_height, color_channels;
|
||||||
|
|
||||||
|
const auto plain_image =
|
||||||
|
stbi_load_from_memory(image.data(), static_cast<int>(image.size()), &original_width,
|
||||||
|
&original_height, &color_channels, STBI_rgb);
|
||||||
|
|
||||||
|
// Resize image to match 256*256
|
||||||
|
if (original_width != profile_dimensions || original_height != profile_dimensions) {
|
||||||
|
// Use vector instead of array to avoid overflowing the stack
|
||||||
|
std::vector<u8> out_image(profile_dimensions * profile_dimensions * STBI_rgb);
|
||||||
|
stbir_resize_uint8_srgb(plain_image, original_width, original_height, 0, out_image.data(),
|
||||||
|
profile_dimensions, profile_dimensions, 0, STBI_rgb, 0,
|
||||||
|
STBIR_FILTER_BOX);
|
||||||
|
image.clear();
|
||||||
|
if (!stbi_write_jpg_to_func(JPGToMemory, &image, profile_dimensions, profile_dimensions,
|
||||||
|
STBI_rgb, out_image.data(), 0)) {
|
||||||
|
LOG_ERROR(Service_ACC, "Failed to resize the user provided image.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
image.resize(std::min(image.size(), max_jpeg_image_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
|
class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
|
||||||
|
@ -339,19 +368,20 @@ protected:
|
||||||
LOG_WARNING(Service_ACC,
|
LOG_WARNING(Service_ACC,
|
||||||
"Failed to load user provided image! Falling back to built-in backup...");
|
"Failed to load user provided image! Falling back to built-in backup...");
|
||||||
ctx.WriteBuffer(Core::Constants::ACCOUNT_BACKUP_JPEG);
|
ctx.WriteBuffer(Core::Constants::ACCOUNT_BACKUP_JPEG);
|
||||||
rb.Push(SanitizeJPEGSize(Core::Constants::ACCOUNT_BACKUP_JPEG.size()));
|
rb.Push(static_cast<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 size = SanitizeJPEGSize(image.GetSize());
|
std::vector<u8> buffer(image.GetSize());
|
||||||
std::vector<u8> buffer(size);
|
|
||||||
|
|
||||||
if (image.Read(buffer) != buffer.size()) {
|
if (image.Read(buffer) != buffer.size()) {
|
||||||
LOG_ERROR(Service_ACC, "Failed to read all the bytes in the user provided image.");
|
LOG_ERROR(Service_ACC, "Failed to read all the bytes in the user provided image.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SanitizeJPEGImageSize(buffer);
|
||||||
|
|
||||||
ctx.WriteBuffer(buffer);
|
ctx.WriteBuffer(buffer);
|
||||||
rb.Push<u32>(size);
|
rb.Push(static_cast<u32>(buffer.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetImageSize(HLERequestContext& ctx) {
|
void GetImageSize(HLERequestContext& ctx) {
|
||||||
|
@ -365,10 +395,18 @@ protected:
|
||||||
if (!image.IsOpen()) {
|
if (!image.IsOpen()) {
|
||||||
LOG_WARNING(Service_ACC,
|
LOG_WARNING(Service_ACC,
|
||||||
"Failed to load user provided image! Falling back to built-in backup...");
|
"Failed to load user provided image! Falling back to built-in backup...");
|
||||||
rb.Push(SanitizeJPEGSize(Core::Constants::ACCOUNT_BACKUP_JPEG.size()));
|
rb.Push(static_cast<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size()));
|
||||||
} else {
|
return;
|
||||||
rb.Push(SanitizeJPEGSize(image.GetSize()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<u8> buffer(image.GetSize());
|
||||||
|
|
||||||
|
if (image.Read(buffer) != buffer.size()) {
|
||||||
|
LOG_ERROR(Service_ACC, "Failed to read all the bytes in the user provided image.");
|
||||||
|
}
|
||||||
|
|
||||||
|
SanitizeJPEGImageSize(buffer);
|
||||||
|
rb.Push(static_cast<u32>(buffer.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Store(HLERequestContext& ctx) {
|
void Store(HLERequestContext& ctx) {
|
||||||
|
|
|
@ -69,6 +69,30 @@ enum class AppletId : u32 {
|
||||||
MyPage = 0x1A,
|
MyPage = 0x1A,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class AppletProgramId : u64 {
|
||||||
|
QLaunch = 0x0100000000001000ull,
|
||||||
|
Auth = 0x0100000000001001ull,
|
||||||
|
Cabinet = 0x0100000000001002ull,
|
||||||
|
Controller = 0x0100000000001003ull,
|
||||||
|
DataErase = 0x0100000000001004ull,
|
||||||
|
Error = 0x0100000000001005ull,
|
||||||
|
NetConnect = 0x0100000000001006ull,
|
||||||
|
ProfileSelect = 0x0100000000001007ull,
|
||||||
|
SoftwareKeyboard = 0x0100000000001008ull,
|
||||||
|
MiiEdit = 0x0100000000001009ull,
|
||||||
|
Web = 0x010000000000100Aull,
|
||||||
|
Shop = 0x010000000000100Bull,
|
||||||
|
OverlayDisplay = 0x01000000000100Cull,
|
||||||
|
PhotoViewer = 0x01000000000100Dull,
|
||||||
|
Settings = 0x010000000000100Eull,
|
||||||
|
OfflineWeb = 0x010000000000100Full,
|
||||||
|
LoginShare = 0x0100000000001010ull,
|
||||||
|
WebAuth = 0x0100000000001011ull,
|
||||||
|
Starter = 0x0100000000001012ull,
|
||||||
|
MyPage = 0x0100000000001013ull,
|
||||||
|
MaxProgramId = 0x0100000000001FFFull,
|
||||||
|
};
|
||||||
|
|
||||||
enum class LibraryAppletMode : u32 {
|
enum class LibraryAppletMode : u32 {
|
||||||
AllForeground = 0,
|
AllForeground = 0,
|
||||||
Background = 1,
|
Background = 1,
|
||||||
|
|
|
@ -306,10 +306,10 @@ void ConfigureProfileManager::SetUserImage() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some games crash when the profile image is too big. Resize any image bigger than 256x256
|
// Profile image must be 256x256
|
||||||
QImage image(image_path);
|
QImage image(image_path);
|
||||||
if (image.width() > 256 || image.height() > 256) {
|
if (image.width() != 256 || image.height() != 256) {
|
||||||
image = image.scaled(256, 256, Qt::KeepAspectRatio);
|
image = image.scaled(256, 256, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||||
if (!image.save(image_path)) {
|
if (!image.save(image_path)) {
|
||||||
QMessageBox::warning(this, tr("Error resizing user image"),
|
QMessageBox::warning(this, tr("Error resizing user image"),
|
||||||
tr("Unable to resize image"));
|
tr("Unable to resize image"));
|
||||||
|
|
|
@ -1908,7 +1908,10 @@ void GMainWindow::ConfigureFilesystemProvider(const std::string& filepath) {
|
||||||
void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t program_index,
|
void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t program_index,
|
||||||
StartGameType type, AmLaunchType launch_type) {
|
StartGameType type, AmLaunchType launch_type) {
|
||||||
LOG_INFO(Frontend, "yuzu starting...");
|
LOG_INFO(Frontend, "yuzu starting...");
|
||||||
|
|
||||||
|
if (program_id > static_cast<u64>(Service::AM::Applets::AppletProgramId::MaxProgramId)) {
|
||||||
StoreRecentFile(filename); // Put the filename on top of the list
|
StoreRecentFile(filename); // Put the filename on top of the list
|
||||||
|
}
|
||||||
|
|
||||||
// Save configurations
|
// Save configurations
|
||||||
UpdateUISettings();
|
UpdateUISettings();
|
||||||
|
@ -4273,7 +4276,7 @@ void GMainWindow::OnToggleStatusBar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnAlbum() {
|
void GMainWindow::OnAlbum() {
|
||||||
constexpr u64 AlbumId = 0x010000000000100Dull;
|
constexpr u64 AlbumId = static_cast<u64>(Service::AM::Applets::AppletProgramId::PhotoViewer);
|
||||||
auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
|
auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
|
||||||
if (!bis_system) {
|
if (!bis_system) {
|
||||||
QMessageBox::warning(this, tr("No firmware available"),
|
QMessageBox::warning(this, tr("No firmware available"),
|
||||||
|
@ -4296,7 +4299,7 @@ void GMainWindow::OnAlbum() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) {
|
void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) {
|
||||||
constexpr u64 CabinetId = 0x0100000000001002ull;
|
constexpr u64 CabinetId = static_cast<u64>(Service::AM::Applets::AppletProgramId::Cabinet);
|
||||||
auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
|
auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
|
||||||
if (!bis_system) {
|
if (!bis_system) {
|
||||||
QMessageBox::warning(this, tr("No firmware available"),
|
QMessageBox::warning(this, tr("No firmware available"),
|
||||||
|
@ -4320,7 +4323,7 @@ void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnMiiEdit() {
|
void GMainWindow::OnMiiEdit() {
|
||||||
constexpr u64 MiiEditId = 0x0100000000001009ull;
|
constexpr u64 MiiEditId = static_cast<u64>(Service::AM::Applets::AppletProgramId::MiiEdit);
|
||||||
auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
|
auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
|
||||||
if (!bis_system) {
|
if (!bis_system) {
|
||||||
QMessageBox::warning(this, tr("No firmware available"),
|
QMessageBox::warning(this, tr("No firmware available"),
|
||||||
|
|
Loading…
Reference in a new issue