mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 06:35:40 +12:00
Add reading amiibo from .amiibo file
This commit is contained in:
parent
3110da1fd6
commit
72ae5d2bfa
5 changed files with 45 additions and 2 deletions
|
@ -137,7 +137,7 @@ set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services
|
|||
src/core/services/y2r.cpp src/core/services/cam.cpp src/core/services/ldr_ro.cpp
|
||||
src/core/services/act.cpp src/core/services/nfc.cpp src/core/services/dlp_srvr.cpp
|
||||
src/core/services/ir_user.cpp src/core/services/http.cpp src/core/services/soc.cpp
|
||||
src/core/services/ssl.cpp src/core/services/news_u.cpp
|
||||
src/core/services/ssl.cpp src/core/services/news_u.cpp src/core/services/amiibo_device.cpp
|
||||
)
|
||||
set(PICA_SOURCE_FILES src/core/PICA/gpu.cpp src/core/PICA/regs.cpp src/core/PICA/shader_unit.cpp
|
||||
src/core/PICA/shader_interpreter.cpp src/core/PICA/dynapica/shader_rec.cpp
|
||||
|
@ -181,6 +181,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
|
|||
include/fs/romfs.hpp include/fs/ivfc.hpp include/discord_rpc.hpp include/services/http.hpp include/result/result_cfg.hpp
|
||||
include/applets/applet.hpp include/applets/mii_selector.hpp include/math_util.hpp include/services/soc.hpp
|
||||
include/services/news_u.hpp include/applets/software_keyboard.hpp include/applets/applet_manager.hpp include/fs/archive_user_save_data.hpp
|
||||
include/services/amiibo_device.hpp
|
||||
)
|
||||
|
||||
cmrc_add_resource_library(
|
||||
|
|
15
include/services/amiibo_device.hpp
Normal file
15
include/services/amiibo_device.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
|
||||
#include "helpers.hpp"
|
||||
#include "io_file.hpp"
|
||||
|
||||
class AmiiboDevice {
|
||||
public:
|
||||
static constexpr size_t tagSize = 0x21C;
|
||||
|
||||
bool loaded = false;
|
||||
std::array<u8, tagSize> raw;
|
||||
|
||||
void reset();
|
||||
};
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include <filesystem>
|
||||
|
||||
#include "amiibo_device.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
|
@ -35,6 +36,7 @@ class NFCService {
|
|||
// Kernel events signaled when an NFC tag goes in and out of range respectively
|
||||
std::optional<Handle> tagInRangeEvent, tagOutOfRangeEvent;
|
||||
|
||||
AmiiboDevice device;
|
||||
Old3DSAdapterStatus adapterStatus;
|
||||
TagStatus tagStatus;
|
||||
bool initialized = false;
|
||||
|
|
3
src/core/services/amiibo_device.cpp
Normal file
3
src/core/services/amiibo_device.cpp
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include "services/amiibo_device.hpp"
|
||||
|
||||
void AmiiboDevice::reset() { loaded = false; }
|
|
@ -1,4 +1,5 @@
|
|||
#include "services/nfc.hpp"
|
||||
#include "io_file.hpp"
|
||||
#include "ipc.hpp"
|
||||
#include "kernel.hpp"
|
||||
|
||||
|
@ -18,6 +19,7 @@ namespace NFCCommands {
|
|||
}
|
||||
|
||||
void NFCService::reset() {
|
||||
device.reset();
|
||||
tagInRangeEvent = std::nullopt;
|
||||
tagOutOfRangeEvent = std::nullopt;
|
||||
|
||||
|
@ -43,7 +45,27 @@ void NFCService::handleSyncRequest(u32 messagePointer) {
|
|||
}
|
||||
}
|
||||
|
||||
bool NFCService::loadAmiibo(const std::filesystem::path& path) { return true; }
|
||||
bool NFCService::loadAmiibo(const std::filesystem::path& path) {
|
||||
IOFile file(path, "rb");
|
||||
|
||||
if (!file.isOpen()) {
|
||||
printf("Failed to open Amiibo file");
|
||||
file.close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto [success, bytesRead] = file.readBytes(&device.raw, AmiiboDevice::tagSize);
|
||||
if (!success || bytesRead != AmiiboDevice::tagSize) {
|
||||
printf("Failed to read entire tag from Amiibo file: File might not be a proper amiibo file\n");
|
||||
file.close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void NFCService::initialize(u32 messagePointer) {
|
||||
const u8 type = mem.read8(messagePointer + 4);
|
||||
|
|
Loading…
Add table
Reference in a new issue