diff --git a/include/services/nfc.hpp b/include/services/nfc.hpp index 361688b2f..ed4a85653 100644 --- a/include/services/nfc.hpp +++ b/include/services/nfc.hpp @@ -35,8 +35,10 @@ class NFCService { Old3DSAdapterStatus adapterStatus; TagStatus tagStatus; + bool initialized = false; // Service commands + void communicationGetResult(u32 messagePointer); void communicationGetStatus(u32 messagePointer); void initialize(u32 messagePointer); void getTagInRangeEvent(u32 messagePointer); diff --git a/src/core/services/nfc.cpp b/src/core/services/nfc.cpp index b3346ce70..eadb1b921 100644 --- a/src/core/services/nfc.cpp +++ b/src/core/services/nfc.cpp @@ -11,6 +11,7 @@ namespace NFCCommands { GetTagOutOfRangeEvent = 0x000C0000, GetTagState = 0x000D0000, CommunicationGetStatus = 0x000F0000, + CommunicationGetResult = 0x00120000, }; } @@ -20,6 +21,7 @@ void NFCService::reset() { adapterStatus = Old3DSAdapterStatus::Idle; tagStatus = TagStatus::NotInitialized; + initialized = false; } void NFCService::handleSyncRequest(u32 messagePointer) { @@ -42,6 +44,7 @@ void NFCService::initialize(u32 messagePointer) { adapterStatus = Old3DSAdapterStatus::InitializationComplete; tagStatus = TagStatus::Initialized; + initialized = true; // TODO: This should error if already initialized. Also sanitize type. mem.write32(messagePointer, IPC::responseHeader(0x1, 1, 0)); mem.write32(messagePointer + 4, Result::Success); @@ -93,7 +96,7 @@ void NFCService::getTagState(u32 messagePointer) { void NFCService::communicationGetStatus(u32 messagePointer) { log("NFC::CommunicationGetStatus"); - if (adapterStatus != Old3DSAdapterStatus::InitializationComplete) { + if (!initialized) { Helpers::warn("NFC::CommunicationGetStatus: Old 3DS NFC Adapter not initialized\n"); } @@ -104,6 +107,7 @@ void NFCService::communicationGetStatus(u32 messagePointer) { void NFCService::startCommunication(u32 messagePointer) { log("NFC::StartCommunication\n"); + // adapterStatus = Old3DSAdapterStatus::Active; // TODO: Actually start communication when we emulate amiibo mem.write32(messagePointer, IPC::responseHeader(0x3, 1, 0)); @@ -112,6 +116,7 @@ void NFCService::startCommunication(u32 messagePointer) { void NFCService::stopCommunication(u32 messagePointer) { log("NFC::StopCommunication\n"); + adapterStatus = Old3DSAdapterStatus::InitializationComplete; // TODO: Actually stop communication when we emulate amiibo mem.write32(messagePointer, IPC::responseHeader(0x4, 1, 0));