From 836a003c8e092653d4fdf9c83df2b7f7401717d2 Mon Sep 17 00:00:00 2001
From: emmauss <emmausssss@gmail.com>
Date: Thu, 5 Apr 2018 01:16:59 +0300
Subject: [PATCH] stubs (#69)

---
 .../OsHle/Services/Am/ICommonStateGetter.cs    |  2 +-
 Ryujinx.Core/OsHle/Services/Hid/ServiceHid.cs  |  7 +++++++
 Ryujinx.Core/OsHle/Services/Nifm/IRequest.cs   | 18 +++++++++++++++++-
 Ryujinx.Core/OsHle/Services/Ns/ServiceNs.cs    |  9 ++++++++-
 .../Services/Vi/IApplicationDisplayService.cs  | 11 +++++++++++
 .../OsHle/Services/Vi/ISystemDisplayService.cs |  8 +++++++-
 Ryujinx.Core/OsHle/Svc/SvcHandler.cs           |  1 +
 Ryujinx.Core/OsHle/Svc/SvcThread.cs            |  7 +++++++
 8 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/Ryujinx.Core/OsHle/Services/Am/ICommonStateGetter.cs b/Ryujinx.Core/OsHle/Services/Am/ICommonStateGetter.cs
index 7ce98ef859..7fb144ee11 100644
--- a/Ryujinx.Core/OsHle/Services/Am/ICommonStateGetter.cs
+++ b/Ryujinx.Core/OsHle/Services/Am/ICommonStateGetter.cs
@@ -56,7 +56,7 @@ namespace Ryujinx.Core.OsHle.Services.Am
 
         public long GetPerformanceMode(ServiceCtx Context)
         {
-            Context.ResponseData.Write((byte)0);
+            Context.ResponseData.Write((byte)Apm.PerformanceMode.Handheld);
 
             return 0;
         }
diff --git a/Ryujinx.Core/OsHle/Services/Hid/ServiceHid.cs b/Ryujinx.Core/OsHle/Services/Hid/ServiceHid.cs
index 46c868aab0..7c9a350b0a 100644
--- a/Ryujinx.Core/OsHle/Services/Hid/ServiceHid.cs
+++ b/Ryujinx.Core/OsHle/Services/Hid/ServiceHid.cs
@@ -15,6 +15,7 @@ namespace Ryujinx.Core.OsHle.Services.Hid
             m_Commands = new Dictionary<int, ServiceProcessRequest>()
             {
                 {   0, CreateAppletResource                    },
+                {   1, ActivateDebugPad                        },
                 {  11, ActivateTouchScreen                     },
                 {  66, StartSixAxisSensor                      },
                 { 100, SetSupportedNpadStyleSet                },
@@ -22,6 +23,7 @@ namespace Ryujinx.Core.OsHle.Services.Hid
                 { 102, SetSupportedNpadIdType                  },
                 { 103, ActivateNpad                            },
                 { 120, SetNpadJoyHoldType                      },
+                { 121, GetNpadJoyHoldType                      },
                 { 122, SetNpadJoyAssignmentModeSingleByDefault },
                 { 123, SetNpadJoyAssignmentModeSingle          },
                 { 124, SetNpadJoyAssignmentModeDual            },
@@ -39,6 +41,11 @@ namespace Ryujinx.Core.OsHle.Services.Hid
             return 0;
         }
 
+        public long ActivateDebugPad(ServiceCtx Context)
+        {
+            return 0;
+        }
+
         public long ActivateTouchScreen(ServiceCtx Context)
         {
             long Unknown = Context.RequestData.ReadInt64();
diff --git a/Ryujinx.Core/OsHle/Services/Nifm/IRequest.cs b/Ryujinx.Core/OsHle/Services/Nifm/IRequest.cs
index 307da1d67b..929bb26e9b 100644
--- a/Ryujinx.Core/OsHle/Services/Nifm/IRequest.cs
+++ b/Ryujinx.Core/OsHle/Services/Nifm/IRequest.cs
@@ -19,7 +19,9 @@ namespace Ryujinx.Core.OsHle.Services.Nifm
             {
                 { 0, GetRequestState               },
                 { 1, GetResult                     },
-                { 2, GetSystemEventReadableHandles }
+                { 2, GetSystemEventReadableHandles },
+                { 3, Cancel                        },
+                { 4, Submit                        },
             };
 
             Event = new KEvent();
@@ -52,6 +54,20 @@ namespace Ryujinx.Core.OsHle.Services.Nifm
             return 0;
         }
 
+        public long Cancel(ServiceCtx Context)
+        {
+            //Todo: Stub
+
+            return 0;
+        }
+
+        public long Submit(ServiceCtx Context)
+        {
+            //Todo: Stub
+
+            return 0;
+        }
+
         public void Dispose()
         {
             Dispose(true);
diff --git a/Ryujinx.Core/OsHle/Services/Ns/ServiceNs.cs b/Ryujinx.Core/OsHle/Services/Ns/ServiceNs.cs
index 7f8faaa5f3..c28ecc7ab2 100644
--- a/Ryujinx.Core/OsHle/Services/Ns/ServiceNs.cs
+++ b/Ryujinx.Core/OsHle/Services/Ns/ServiceNs.cs
@@ -13,8 +13,15 @@ namespace Ryujinx.Core.OsHle.Services.Ns
         {
             m_Commands = new Dictionary<int, ServiceProcessRequest>()
             {
-                //{ 1, Function }
+                { 2, CountAddOnContent }
             };
         }
+
+        public static long CountAddOnContent(ServiceCtx Context)
+        {
+            Context.ResponseData.Write(0);
+
+            return 0;
+        }
     }
 }
\ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Services/Vi/IApplicationDisplayService.cs b/Ryujinx.Core/OsHle/Services/Vi/IApplicationDisplayService.cs
index c7e7524c10..b92dc16c44 100644
--- a/Ryujinx.Core/OsHle/Services/Vi/IApplicationDisplayService.cs
+++ b/Ryujinx.Core/OsHle/Services/Vi/IApplicationDisplayService.cs
@@ -25,6 +25,7 @@ namespace Ryujinx.Core.OsHle.Services.Vi
                 {  103, GetIndirectDisplayTransactionService },
                 { 1010, OpenDisplay                          },
                 { 1020, CloseDisplay                         },
+                { 1102, GetDisplayResolution                 },
                 { 2020, OpenLayer                            },
                 { 2021, CloseLayer                           },
                 { 2030, CreateStrayLayer                     },
@@ -84,6 +85,16 @@ namespace Ryujinx.Core.OsHle.Services.Vi
             return 0;
         }
 
+        public long GetDisplayResolution(ServiceCtx Context)
+        {
+            long DisplayId = Context.RequestData.ReadInt32();
+
+            Context.ResponseData.Write(1280);
+            Context.ResponseData.Write(720);
+
+            return 0;
+        }
+
         public long OpenLayer(ServiceCtx Context)
         {
             long LayerId = Context.RequestData.ReadInt64();
diff --git a/Ryujinx.Core/OsHle/Services/Vi/ISystemDisplayService.cs b/Ryujinx.Core/OsHle/Services/Vi/ISystemDisplayService.cs
index 02aafebb24..3bdeb32a68 100644
--- a/Ryujinx.Core/OsHle/Services/Vi/ISystemDisplayService.cs
+++ b/Ryujinx.Core/OsHle/Services/Vi/ISystemDisplayService.cs
@@ -13,7 +13,8 @@ namespace Ryujinx.Core.OsHle.Services.Vi
         {
             m_Commands = new Dictionary<int, ServiceProcessRequest>()
             {
-                { 2205, SetLayerZ }
+                { 2205, SetLayerZ },
+                { 2207, SetLayerVisibility }
             };
         }
 
@@ -21,5 +22,10 @@ namespace Ryujinx.Core.OsHle.Services.Vi
         {
             return 0;
         }
+
+        public static long SetLayerVisibility(ServiceCtx Context)
+        {
+            return 0;
+        }
     }
 }
\ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Svc/SvcHandler.cs b/Ryujinx.Core/OsHle/Svc/SvcHandler.cs
index 3ce56a3cd7..3bdb1060ae 100644
--- a/Ryujinx.Core/OsHle/Svc/SvcHandler.cs
+++ b/Ryujinx.Core/OsHle/Svc/SvcHandler.cs
@@ -40,6 +40,7 @@ namespace Ryujinx.Core.OsHle.Svc
                 { 0x0c, SvcGetThreadPriority             },
                 { 0x0d, SvcSetThreadPriority             },
                 { 0x0f, SvcSetThreadCoreMask             },
+                { 0x10, SvcGetCurrentProcessorNumber     },
                 { 0x12, SvcClearEvent                    },
                 { 0x13, SvcMapSharedMemory               },
                 { 0x14, SvcUnmapSharedMemory             },
diff --git a/Ryujinx.Core/OsHle/Svc/SvcThread.cs b/Ryujinx.Core/OsHle/Svc/SvcThread.cs
index f58c2dc0af..c58cffcaaf 100644
--- a/Ryujinx.Core/OsHle/Svc/SvcThread.cs
+++ b/Ryujinx.Core/OsHle/Svc/SvcThread.cs
@@ -117,6 +117,13 @@ namespace Ryujinx.Core.OsHle.Svc
             //TODO: Error codes.
         }
 
+        private void SvcGetCurrentProcessorNumber(AThreadState ThreadState)
+        {
+            KThread CurrThread = Process.GetThread(ThreadState.Tpidr);
+
+            ThreadState.X0 = (ulong)CurrThread.ProcessorId;
+        }
+
         private void SvcGetThreadId(AThreadState ThreadState)
         {
             int Handle = (int)ThreadState.X1;