Change ReadAsciiString to use long for the Size, avoids some casting

This commit is contained in:
gdkchan 2018-03-15 21:02:35 -03:00
parent 7092ad7cc9
commit 3d37a88180
7 changed files with 9 additions and 9 deletions

View file

@ -70,11 +70,11 @@ namespace ChocolArm64.Memory
Marshal.StructureToPtr<T>(Value, Ptr, false);
}
public static string ReadAsciiString(AMemory Memory, long Position, int MaxSize = -1)
public static string ReadAsciiString(AMemory Memory, long Position, long MaxSize = -1)
{
using (MemoryStream MS = new MemoryStream())
{
for (int Offs = 0; Offs < MaxSize || MaxSize == -1; Offs++)
for (long Offs = 0; Offs < MaxSize || MaxSize == -1; Offs++)
{
byte Value = (byte)Memory.ReadByte(Position + Offs);

View file

@ -190,7 +190,7 @@ namespace Ryujinx.Audio.OpenAL
case AudioFormat.PcmInt16: return ALFormat.Stereo16;
}
}
throw new ArgumentException(nameof(Format));
}

View file

@ -51,7 +51,7 @@ namespace Ryujinx.Core.OsHle
long Value0 = Memory.ReadInt64(Position + 0x08);
long Value1 = Memory.ReadInt64(Position + 0x10);
FileName = AMemoryHelper.ReadAsciiString(Memory, Value0, (int)(Value1 - Value0));
FileName = AMemoryHelper.ReadAsciiString(Memory, Value0, Value1 - Value0);
break;
}

View file

@ -55,7 +55,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.Aud
long Position = Context.Request.SendBuff[0].Position;
long Size = Context.Request.SendBuff[0].Size;
string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position, (int)Size);
string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position, Size);
return 0;
}

View file

@ -89,11 +89,11 @@ namespace Ryujinx.Core.OsHle.IpcServices.Aud
long Position = Context.Request.ReceiveBuff[0].Position;
long Size = Context.Request.ReceiveBuff[0].Size;
int Count = (int)(Size >> 3);
uint Count = (uint)((ulong)Size >> 3);
long[] ReleasedBuffers = AudioOut.GetReleasedBuffers(Track);
for (int Index = 0; Index < Count; Index++)
for (uint Index = 0; Index < Count; Index++)
{
long Tag = 0;

View file

@ -41,7 +41,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.Aud
string DeviceName = AMemoryHelper.ReadAsciiString(
Context.Memory,
Context.Request.SendBuff[0].Position,
(int)Context.Request.SendBuff[0].Size);
Context.Request.SendBuff[0].Size);
if (DeviceName == string.Empty)
{

View file

@ -164,7 +164,7 @@ namespace Ryujinx.Core.OsHle.Svc
long Position = (long)ThreadState.X0;
long Size = (long)ThreadState.X1;
string Str = AMemoryHelper.ReadAsciiString(Memory, Position, (int)Size);
string Str = AMemoryHelper.ReadAsciiString(Memory, Position, Size);
Logging.Info($"SvcOutputDebugString: {Str}");