@@ -334,45 +334,63 @@ void nnNfpExport_MountRom(PPCInterpreter_t* hCPU)
334
334
osLib_returnFromFunction (hCPU, BUILD_NN_RESULT (NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0 ));
335
335
}
336
336
337
- typedef struct
338
- {
339
- /* +0x00 */ uint8 characterId[3 ];
340
- /* +0x03 */ uint8 amiiboSeries;
341
- /* +0x04 */ uint16be number;
342
- /* +0x06 */ uint8 nfpType;
343
- /* +0x07 */ uint8 unused[0x2F ];
344
- }nfpRomInfo_t;
345
-
346
- static_assert (offsetof(nfpRomInfo_t, amiiboSeries) == 0x3, "nfpRomInfo.seriesId has invalid offset");
347
- static_assert (offsetof(nfpRomInfo_t, number) == 0x4, "nfpRomInfo.number has invalid offset");
348
- static_assert (offsetof(nfpRomInfo_t, nfpType) == 0x6, "nfpRomInfo.nfpType has invalid offset");
349
- static_assert (sizeof (nfpRomInfo_t) == 0x36, "nfpRomInfo_t has invalid size");
350
-
351
- void nnNfpExport_GetNfpRomInfo (PPCInterpreter_t* hCPU)
337
+ namespace nn ::nfp
352
338
{
353
- cemuLog_log (LogType::NN_NFP, " GetNfpRomInfo(0x{:08x})" , hCPU->gpr [3 ]);
354
- ppcDefineParamStructPtr (romInfo, nfpRomInfo_t, 0 );
339
+ struct RomInfo
340
+ {
341
+ /* +0x00 */ uint8 characterId[3 ];
342
+ /* +0x03 */ uint8 amiiboSeries;
343
+ /* +0x04 */ uint16be number;
344
+ /* +0x06 */ uint8 nfpType;
345
+ /* +0x07 */ uint8 unused[0x2F ];
346
+ };
355
347
356
- nnNfpLock ();
357
- if (nfp_data.hasActiveAmiibo == false )
348
+ static_assert (offsetof(RomInfo, amiiboSeries) == 0x3 );
349
+ static_assert (offsetof(RomInfo, number) == 0x4 );
350
+ static_assert (offsetof(RomInfo, nfpType) == 0x6 );
351
+ static_assert (sizeof (RomInfo) == 0x36 );
352
+
353
+ using ReadOnlyInfo = RomInfo; // same layout
354
+
355
+ void GetRomInfo (RomInfo* romInfo)
358
356
{
359
- nnNfpUnlock ();
360
- osLib_returnFromFunction (hCPU, BUILD_NN_RESULT (NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_NFP, 0 )); // todo: Return correct error code
361
- return ;
357
+ cemu_assert_debug (nfp_data.hasActiveAmiibo );
358
+ memset (romInfo, 0x00 , sizeof (RomInfo));
359
+ romInfo->characterId [0 ] = nfp_data.amiiboNFCData .amiiboIdentificationBlock .gameAndCharacterId [0 ];
360
+ romInfo->characterId [1 ] = nfp_data.amiiboNFCData .amiiboIdentificationBlock .gameAndCharacterId [1 ];
361
+ romInfo->characterId [2 ] = nfp_data.amiiboNFCData .amiiboIdentificationBlock .characterVariation ; // guessed
362
+ romInfo->amiiboSeries = nfp_data.amiiboNFCData .amiiboIdentificationBlock .amiiboSeries ; // guessed
363
+ romInfo->number = *(uint16be*)nfp_data.amiiboNFCData .amiiboIdentificationBlock .amiiboModelNumber ; // guessed
364
+ romInfo->nfpType = nfp_data.amiiboNFCData .amiiboIdentificationBlock .amiiboFigureType ; // guessed
365
+ memset (romInfo->unused , 0x00 , sizeof (romInfo->unused ));
362
366
}
363
- memset (romInfo, 0x00 , sizeof (nfpRomInfo_t));
364
367
365
- romInfo->characterId [0 ] = nfp_data.amiiboNFCData .amiiboIdentificationBlock .gameAndCharacterId [0 ];
366
- romInfo->characterId [1 ] = nfp_data.amiiboNFCData .amiiboIdentificationBlock .gameAndCharacterId [1 ];
367
- romInfo->characterId [2 ] = nfp_data.amiiboNFCData .amiiboIdentificationBlock .characterVariation ; // guessed
368
-
369
- romInfo->amiiboSeries = nfp_data.amiiboNFCData .amiiboIdentificationBlock .amiiboSeries ; // guessed
370
- romInfo->number = *(uint16be*)nfp_data.amiiboNFCData .amiiboIdentificationBlock .amiiboModelNumber ; // guessed
371
- romInfo->nfpType = nfp_data.amiiboNFCData .amiiboIdentificationBlock .amiiboFigureType ; // guessed
368
+ nnResult GetNfpRomInfo (RomInfo* romInfo)
369
+ {
370
+ nnNfpLock ();
371
+ if (nfp_data.hasActiveAmiibo == false )
372
+ {
373
+ nnNfpUnlock ();
374
+ return BUILD_NN_RESULT (NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_NFP, 0 ); // todo: Return correct error code
375
+ }
376
+ GetRomInfo (romInfo);
377
+ nnNfpUnlock ();
378
+ return BUILD_NN_RESULT (NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0 );
379
+ }
372
380
373
- nnNfpUnlock ();
374
- osLib_returnFromFunction (hCPU, BUILD_NN_RESULT (NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0 ));
375
- }
381
+ nnResult GetNfpReadOnlyInfo (ReadOnlyInfo* readOnlyInfo)
382
+ {
383
+ nnNfpLock ();
384
+ if (nfp_data.hasActiveAmiibo == false )
385
+ {
386
+ nnNfpUnlock ();
387
+ return BUILD_NN_RESULT (NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_NFP, 0 ); // todo: Return correct error code
388
+ }
389
+ GetRomInfo (readOnlyInfo);
390
+ nnNfpUnlock ();
391
+ return BUILD_NN_RESULT (NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0 );
392
+ }
393
+ };
376
394
377
395
typedef struct
378
396
{
@@ -880,13 +898,13 @@ void nnNfp_update()
880
898
if (amiiboElapsedTouchTime >= 1500 )
881
899
{
882
900
nnNfp_unloadAmiibo ();
901
+ if (nfp_data.deactivateEvent )
902
+ {
903
+ coreinit::OSEvent* osEvent = (coreinit::OSEvent*)memory_getPointerFromVirtualOffset (nfp_data.deactivateEvent );
904
+ coreinit::OSSignalEvent (osEvent);
905
+ }
883
906
}
884
907
nnNfpUnlock ();
885
- if (nfp_data.deactivateEvent )
886
- {
887
- coreinit::OSEvent* osEvent = (coreinit::OSEvent*)memory_getPointerFromVirtualOffset (nfp_data.deactivateEvent );
888
- coreinit::OSSignalEvent (osEvent);
889
- }
890
908
}
891
909
892
910
void nnNfpExport_GetNfpState (PPCInterpreter_t* hCPU)
@@ -1001,8 +1019,6 @@ namespace nn::nfp
1001
1019
osLib_addFunction (" nn_nfp" , " Mount__Q2_2nn3nfpFv" , nnNfpExport_Mount);
1002
1020
osLib_addFunction (" nn_nfp" , " MountRom__Q2_2nn3nfpFv" , nnNfpExport_MountRom);
1003
1021
osLib_addFunction (" nn_nfp" , " Unmount__Q2_2nn3nfpFv" , nnNfpExport_Unmount);
1004
-
1005
- osLib_addFunction (" nn_nfp" , " GetNfpRomInfo__Q2_2nn3nfpFPQ3_2nn3nfp7RomInfo" , nnNfpExport_GetNfpRomInfo);
1006
1022
osLib_addFunction (" nn_nfp" , " GetNfpCommonInfo__Q2_2nn3nfpFPQ3_2nn3nfp10CommonInfo" , nnNfpExport_GetNfpCommonInfo);
1007
1023
osLib_addFunction (" nn_nfp" , " GetNfpRegisterInfo__Q2_2nn3nfpFPQ3_2nn3nfp12RegisterInfo" , nnNfpExport_GetNfpRegisterInfo);
1008
1024
@@ -1028,7 +1044,9 @@ namespace nn::nfp
1028
1044
{
1029
1045
nnNfp_load (); // legacy interface, update these to use cafeExportRegister / cafeExportRegisterFunc
1030
1046
1031
- cafeExportRegisterFunc (nn::nfp::GetErrorCode, " nn_nfp" , " GetErrorCode__Q2_2nn3nfpFRCQ2_2nn6Result" , LogType::Placeholder);
1047
+ cafeExportRegisterFunc (nn::nfp::GetErrorCode, " nn_nfp" , " GetErrorCode__Q2_2nn3nfpFRCQ2_2nn6Result" , LogType::NN_NFP);
1048
+ cafeExportRegisterFunc (nn::nfp::GetNfpRomInfo, " nn_nfp" , " GetNfpRomInfo__Q2_2nn3nfpFPQ3_2nn3nfp7RomInfo" , LogType::NN_NFP);
1049
+ cafeExportRegisterFunc (nn::nfp::GetNfpReadOnlyInfo, " nn_nfp" , " GetNfpReadOnlyInfo__Q2_2nn3nfpFPQ3_2nn3nfp12ReadOnlyInfo" , LogType::NN_NFP);
1032
1050
}
1033
1051
1034
1052
}
0 commit comments