VERY experimental Nintendo Switch 2 emulator
C++
Deglobalize System: NFP
David Marcec37b2a234a2c5
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cppindex a5cb06f8a3..a42c22d447 100644--- a/src/core/hle/service/nfp/nfp.cpp+++ b/src/core/hle/service/nfp/nfp.cpp@@ -23,9 +23,9 @@ constexpr ResultCode ERR_TAG_FAILED(ErrorModule::NFP,constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152);} // namespace ErrCodes-Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)- : ServiceFramework(name), module(std::move(module)) {- auto& kernel = Core::System::GetInstance().Kernel();+Module::Interface::Interface(std::shared_ptr<Module> module, Core::System& system, const char* name)+ : ServiceFramework(name), module(std::move(module)), system(system) {+ auto& kernel = system.Kernel();nfc_tag_load = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic,"IUser:NFCTagDetected");}@@ -34,8 +34,8 @@ Module::Interface::~Interface() = default;class IUser final : public ServiceFramework<IUser> {public:- IUser(Module::Interface& nfp_interface)- : ServiceFramework("NFP::IUser"), nfp_interface(nfp_interface) {+ IUser(Module::Interface& nfp_interface, Core::System& system)+ : ServiceFramework("NFP::IUser"), nfp_interface(nfp_interface), system(system) {static const FunctionInfo functions[] = {{0, &IUser::Initialize, "Initialize"},{1, &IUser::Finalize, "Finalize"},@@ -65,7 +65,7 @@ public:};RegisterHandlers(functions);- auto& kernel = Core::System::GetInstance().Kernel();+ auto& kernel = system.Kernel();deactivate_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic, "IUser:DeactivateEvent");availability_change_event = Kernel::WritableEvent::CreateEventPair(@@ -324,6 +324,7 @@ private:Kernel::EventPair deactivate_event;Kernel::EventPair availability_change_event;const Module::Interface& nfp_interface;+ Core::System& system;};void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {@@ -331,7 +332,7 @@ void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {IPC::ResponseBuilder rb{ctx, 2, 0, 1};rb.Push(RESULT_SUCCESS);- rb.PushIpcInterface<IUser>(*this);+ rb.PushIpcInterface<IUser>(*this, system);}bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {@@ -353,9 +354,9 @@ const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() constreturn amiibo;}-void InstallInterfaces(SM::ServiceManager& service_manager) {+void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {auto module = std::make_shared<Module>();- std::make_shared<NFP_User>(module)->InstallAsService(service_manager);+ std::make_shared<NFP_User>(module, system)->InstallAsService(service_manager);}} // namespace Service::NFPdiff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.hindex a1817e9912..9718ef7456 100644--- a/src/core/hle/service/nfp/nfp.h+++ b/src/core/hle/service/nfp/nfp.h@@ -16,7 +16,7 @@ class Module final {public:class Interface : public ServiceFramework<Interface> {public:- explicit Interface(std::shared_ptr<Module> module, const char* name);+ explicit Interface(std::shared_ptr<Module> module, Core::System& system, const char* name);~Interface() override;struct ModelInfo {@@ -43,9 +43,10 @@ public:protected:std::shared_ptr<Module> module;+ Core::System& system;};};-void InstallInterfaces(SM::ServiceManager& service_manager);+void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);} // namespace Service::NFPdiff --git a/src/core/hle/service/nfp/nfp_user.cpp b/src/core/hle/service/nfp/nfp_user.cppindex 784a87c1b5..298184f173 100644--- a/src/core/hle/service/nfp/nfp_user.cpp+++ b/src/core/hle/service/nfp/nfp_user.cpp@@ -6,8 +6,8 @@namespace Service::NFP {-NFP_User::NFP_User(std::shared_ptr<Module> module)- : Module::Interface(std::move(module), "nfp:user") {+NFP_User::NFP_User(std::shared_ptr<Module> module, Core::System& system)+ : Module::Interface(std::move(module), system, "nfp:user") {static const FunctionInfo functions[] = {{0, &NFP_User::CreateUserInterface, "CreateUserInterface"},};diff --git a/src/core/hle/service/nfp/nfp_user.h b/src/core/hle/service/nfp/nfp_user.hindex 65d9aaf483..1686ebf206 100644--- a/src/core/hle/service/nfp/nfp_user.h+++ b/src/core/hle/service/nfp/nfp_user.h@@ -10,7 +10,7 @@ namespace Service::NFP {class NFP_User final : public Module::Interface {public:- explicit NFP_User(std::shared_ptr<Module> module);+ explicit NFP_User(std::shared_ptr<Module> module, Core::System& system);~NFP_User() override;};