mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-20 04:29:13 +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
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
Add a link
Reference in a new issue