Implemented non production mode setting grabbing

This commit is contained in:
David Marcec 2018-07-10 15:21:09 +10:00
parent 6346d56bee
commit 2fa1387f54

View file

@ -2,6 +2,7 @@ using ChocolArm64.Memory;
using Ryujinx.HLE.Logging;
using System;
using System.Collections.Concurrent;
using System.Text;
using System.Threading;
namespace Ryujinx.HLE.OsHle.Services.Nv.NvHostCtrl
@ -83,12 +84,41 @@ namespace Ryujinx.HLE.OsHle.Services.Nv.NvHostCtrl
long InputPosition = Context.Request.GetBufferType0x21().Position;
long OutputPosition = Context.Request.GetBufferType0x22().Position;
string Nv = AMemoryHelper.ReadAsciiString(Context.Memory, InputPosition + 0, 0x41);
string Domain = AMemoryHelper.ReadAsciiString(Context.Memory, InputPosition + 0, 0x41);
string Name = AMemoryHelper.ReadAsciiString(Context.Memory, InputPosition + 0x41, 0x41);
Context.Memory.WriteByte(OutputPosition + 0x82, (byte)'0');
if (Set.NxSettings.Settings.TryGetValue($"{Domain}!{Name}", out object NvSetting))
{
byte[] SettingBuffer = new byte[0x101];
Context.Ns.Log.PrintStub(LogClass.ServiceNv, "Stubbed.");
if (NvSetting is string StringValue)
{
if(StringValue.Length > 0x100)
{
Context.Ns.Log.PrintError(Logging.LogClass.ServiceNv, $"{Domain}!{Name} String value size is too big!");
}
else
{
SettingBuffer = Encoding.ASCII.GetBytes(StringValue + "\0");
}
}
if (NvSetting is int IntValue)
{
SettingBuffer = BitConverter.GetBytes(IntValue);
}
else if (NvSetting is bool BoolValue)
{
SettingBuffer[0] = BoolValue ? (byte)1 : (byte)0;
}
else
{
throw new NotImplementedException(NvSetting.GetType().Name);
}
Context.Memory.WriteBytes(OutputPosition + 0x82, SettingBuffer);
Context.Ns.Log.PrintDebug(Logging.LogClass.ServiceNv, $"Got setting {Domain}!{Name}");
}
return NvResult.Success;
}