diff --git a/Ryujinx.Core/OsHle/Services/FspSrv/IFileSystem.cs b/Ryujinx.Core/OsHle/Services/FspSrv/IFileSystem.cs index 7db0815485..3593bafbbe 100644 --- a/Ryujinx.Core/OsHle/Services/FspSrv/IFileSystem.cs +++ b/Ryujinx.Core/OsHle/Services/FspSrv/IFileSystem.cs @@ -50,7 +50,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv { long Position = Context.Request.PtrBuff[0].Position; - string Name = ReadUtf8String(Context.Memory, Position); + string Name = ReadUtf8String(Context); long Mode = Context.RequestData.ReadInt64(); int Size = Context.RequestData.ReadInt32(); @@ -84,7 +84,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv { long Position = Context.Request.PtrBuff[0].Position; - string Name = ReadUtf8String(Context.Memory, Position); + string Name = ReadUtf8String(Context); string FileName = Context.Ns.VFs.GetFullPath(Path, Name); @@ -107,7 +107,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv { long Position = Context.Request.PtrBuff[0].Position; - string Name = ReadUtf8String(Context.Memory, Position); + string Name = ReadUtf8String(Context); string DirName = Context.Ns.VFs.GetFullPath(Path, Name); @@ -145,7 +145,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv { long Position = Context.Request.PtrBuff[0].Position; - string Name = ReadUtf8String(Context.Memory, Position); + string Name = ReadUtf8String(Context); string DirName = Context.Ns.VFs.GetFullPath(Path, Name); @@ -166,11 +166,8 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv public long RenameFile(ServiceCtx Context) { - long OldPosition = Context.Request.PtrBuff[0].Position; - long NewPosition = Context.Request.PtrBuff[0].Position; - - string OldName = ReadUtf8String(Context.Memory, OldPosition); - string NewName = ReadUtf8String(Context.Memory, NewPosition); + string OldName = ReadUtf8String(Context, 0); + string NewName = ReadUtf8String(Context, 1); string OldFileName = Context.Ns.VFs.GetFullPath(Path, OldName); string NewFileName = Context.Ns.VFs.GetFullPath(Path, NewName); @@ -197,11 +194,8 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv public long RenameDirectory(ServiceCtx Context) { - long OldPosition = Context.Request.PtrBuff[0].Position; - long NewPosition = Context.Request.PtrBuff[0].Position; - - string OldName = ReadUtf8String(Context.Memory, OldPosition); - string NewName = ReadUtf8String(Context.Memory, NewPosition); + string OldName = ReadUtf8String(Context, 0); + string NewName = ReadUtf8String(Context, 1); string OldDirName = Context.Ns.VFs.GetFullPath(Path, OldName); string NewDirName = Context.Ns.VFs.GetFullPath(Path, NewName); @@ -230,7 +224,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv { long Position = Context.Request.PtrBuff[0].Position; - string Name = ReadUtf8String(Context.Memory, Position); + string Name = ReadUtf8String(Context); string FileName = Context.Ns.VFs.GetFullPath(Path, Name); @@ -258,7 +252,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv int FilterFlags = Context.RequestData.ReadInt32(); - string Name = ReadUtf8String(Context.Memory, Position); + string Name = ReadUtf8String(Context); string FileName = Context.Ns.VFs.GetFullPath(Path, Name); @@ -294,7 +288,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv int FilterFlags = Context.RequestData.ReadInt32(); - string Name = ReadUtf8String(Context.Memory, Position); + string Name = ReadUtf8String(Context); string DirName = Context.Ns.VFs.GetFullPath(Path, Name); @@ -331,7 +325,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv { long Position = Context.Request.PtrBuff[0].Position; - string Name = ReadUtf8String(Context.Memory, Position); + string Name = ReadUtf8String(Context); Context.ResponseData.Write(Context.Ns.VFs.GetDrive().AvailableFreeSpace); @@ -342,7 +336,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv { long Position = Context.Request.PtrBuff[0].Position; - string Name = ReadUtf8String(Context.Memory, Position); + string Name = ReadUtf8String(Context); Context.ResponseData.Write(Context.Ns.VFs.GetDrive().TotalSize); @@ -381,13 +375,16 @@ namespace Ryujinx.Core.OsHle.IpcServices.FspSrv } } - private string ReadUtf8String(AMemory Memory, long Position) + private string ReadUtf8String(ServiceCtx Context, int Index = 0) { + long Position = Context.Request.PtrBuff[Index].Position; + long Size = Context.Request.PtrBuff[Index].Size; + using (MemoryStream MS = new MemoryStream()) { - while (true) + while (Size-- > 0) { - byte Value = Memory.ReadByte(Position++); + byte Value = Context.Memory.ReadByte(Position++); if (Value == 0) { diff --git a/Ryujinx.Core/OsHle/Services/Set/ServiceSetSys.cs b/Ryujinx.Core/OsHle/Services/Set/ServiceSetSys.cs index 68b3035426..41c5d8b3b3 100644 --- a/Ryujinx.Core/OsHle/Services/Set/ServiceSetSys.cs +++ b/Ryujinx.Core/OsHle/Services/Set/ServiceSetSys.cs @@ -22,8 +22,8 @@ namespace Ryujinx.Core.OsHle.IpcServices.Set public static long GetColorSetId(ServiceCtx Context) { - //Use white system theme - Context.ResponseData.Write(1); + Context.ResponseData.Write((int)Context.Ns.Settings.ThemeColor); + return 0; } diff --git a/Ryujinx.Core/Settings/ColorSet.cs b/Ryujinx.Core/Settings/ColorSet.cs new file mode 100644 index 0000000000..43483363fa --- /dev/null +++ b/Ryujinx.Core/Settings/ColorSet.cs @@ -0,0 +1,8 @@ +namespace Ryujinx.Core.Settings +{ + public enum ColorSet + { + BasicWhite = 0, + BasicBlack = 1 + } +} diff --git a/Ryujinx.Core/Settings/SetSys.cs b/Ryujinx.Core/Settings/SetSys.cs new file mode 100644 index 0000000000..d8b6eb6ef5 --- /dev/null +++ b/Ryujinx.Core/Settings/SetSys.cs @@ -0,0 +1,7 @@ +namespace Ryujinx.Core.Settings +{ + public class SetSys + { + public ColorSet ThemeColor; + } +} diff --git a/Ryujinx.Core/Switch.cs b/Ryujinx.Core/Switch.cs index 0d5f8e72fd..6f41da8144 100644 --- a/Ryujinx.Core/Switch.cs +++ b/Ryujinx.Core/Switch.cs @@ -1,6 +1,7 @@ using ChocolArm64.Memory; using Ryujinx.Core.Input; using Ryujinx.Core.OsHle; +using Ryujinx.Core.Settings; using Ryujinx.Graphics.Gal; using Ryujinx.Graphics.Gpu; using System; @@ -15,7 +16,9 @@ namespace Ryujinx.Core internal NsGpu Gpu { get; private set; } internal Horizon Os { get; private set; } internal VirtualFs VFs { get; private set; } - public Hid Hid { get; private set; } + + public Hid Hid { get; private set; } + public SetSys Settings { get; private set; } public event EventHandler Finish; @@ -24,9 +27,11 @@ namespace Ryujinx.Core Ram = Marshal.AllocHGlobal((IntPtr)AMemoryMgr.RamSize); Gpu = new NsGpu(Renderer); - Os = new Horizon(this); VFs = new VirtualFs(); - Hid = new Hid(this); + + Hid = new Hid(this); + Os = new Horizon(this); + Settings = new SetSys(); } public void FinalizeAllProcesses()