From 26825ca414c08df51d8f8603b03d4f9a56c8a3b5 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 14 Feb 2022 02:49:37 +0100 Subject: [PATCH] early-access version 2490 --- README.md | 2 +- src/core/hle/service/nfp/nfp.cpp | 24 +++++++++++++------ src/core/hle/service/nfp/nfp.h | 11 ++++++--- .../renderer_vulkan/vk_rasterizer.cpp | 4 ++-- src/yuzu/debugger/console.cpp | 1 + 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 84ebc50f8..8d08b7483 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2489. +This is the source code for early-access 2490. ## Legal Notice diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 63e257975..513107715 100755 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp @@ -479,25 +479,35 @@ void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { } bool Module::Interface::LoadAmiibo(const std::vector& buffer) { - if (buffer.size() < sizeof(NTAG215File)) { - LOG_ERROR(Service_NFP, "Wrong file size"); - return false; - } - if (device_state != DeviceState::SearchingForTag) { LOG_ERROR(Service_NFP, "Game is not looking for amiibos, current state {}", device_state); return false; } + constexpr auto tag_size = sizeof(NTAG215File); + constexpr auto tag_size_without_password = sizeof(NTAG215File) - sizeof(NTAG215Password); + + std::vector amiibo_buffer = buffer; + + if (amiibo_buffer.size() < tag_size_without_password) { + LOG_ERROR(Service_NFP, "Wrong file size {}", buffer.size()); + return false; + } + + // Ensure it has the correct size + if (amiibo_buffer.size() != tag_size) { + amiibo_buffer.resize(tag_size, 0); + } + LOG_INFO(Service_NFP, "Amiibo detected"); - std::memcpy(&tag_data, buffer.data(), sizeof(tag_data)); + std::memcpy(&tag_data, buffer.data(), tag_size); if (!IsAmiiboValid()) { return false; } // This value can't be dumped from a tag. Generate it - tag_data.PWD = GetTagPassword(tag_data.uuid); + tag_data.password.PWD = GetTagPassword(tag_data.uuid); device_state = DeviceState::TagFound; activate_event->GetWritableEvent().Signal(); diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h index bc3b1967f..022f13b29 100755 --- a/src/core/hle/service/nfp/nfp.h +++ b/src/core/hle/service/nfp/nfp.h @@ -153,6 +153,13 @@ public: }; static_assert(sizeof(EncryptedAmiiboFile) == 0x1F8, "AmiiboFile is an invalid size"); + struct NTAG215Password { + u32 PWD; // Password to allow write access + u16 PACK; // Password acknowledge reply + u16 RFUI; // Reserved for future use + }; + static_assert(sizeof(NTAG215Password) == 0x8, "NTAG215Password is an invalid size"); + struct NTAG215File { TagUuid uuid; // Unique serial number u16 lock_bytes; // Set defined pages as read only @@ -161,9 +168,7 @@ public: u32 dynamic_lock; // Dynamic lock u32 CFG0; // Defines memory protected by password u32 CFG1; // Defines number of verification attempts - u32 PWD; // Password to allow write access - u16 PACK; // Password acknowledge reply - u16 RFUI; // Reserved for future use + NTAG215Password password; // Password data }; static_assert(sizeof(NTAG215File) == 0x21C, "NTAG215File is an invalid size"); diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 23422d4c9..2227d9197 100755 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -183,6 +183,8 @@ void RasterizerVulkan::Draw(bool is_indexed, bool is_instanced) { SCOPE_EXIT({ gpu.TickWork(); }); FlushWork(); + query_cache.UpdateCounters(); + GraphicsPipeline* const pipeline{pipeline_cache.CurrentGraphicsPipeline()}; if (!pipeline) { return; @@ -194,8 +196,6 @@ void RasterizerVulkan::Draw(bool is_indexed, bool is_instanced) { UpdateDynamicStates(); - query_cache.UpdateCounters(); - const auto& regs{maxwell3d.regs}; const u32 num_instances{maxwell3d.mme_draw.instance_count}; const DrawParams draw_params{MakeDrawParams(regs, num_instances, is_instanced, is_indexed)}; diff --git a/src/yuzu/debugger/console.cpp b/src/yuzu/debugger/console.cpp index f89ea8ea7..4b508b466 100755 --- a/src/yuzu/debugger/console.cpp +++ b/src/yuzu/debugger/console.cpp @@ -30,6 +30,7 @@ void ToggleConsole() { freopen_s(&temp, "CONIN$", "r", stdin); freopen_s(&temp, "CONOUT$", "w", stdout); freopen_s(&temp, "CONOUT$", "w", stderr); + SetConsoleOutputCP(65001); SetColorConsoleBackendEnabled(true); } } else {