Compare commits

...

7 Commits

Author SHA1 Message Date
Evan Husted
3dfbf55611 Merge remote-tracking branch 'origin/master' 2024-12-22 16:01:19 -06:00
Evan Husted
cb355f504d UI: Rearrange help menu item & merge wiki page link buttons into a "category" button. 2024-12-22 16:01:09 -06:00
Marco Carvalho
b5483d8fe0 Prefer generic overload when type is known (#430) 2024-12-22 13:23:35 -06:00
Evan Husted
8259f790d7 misc: Cleanup locale validator 2024-12-22 13:19:10 -06:00
Evan Husted
1ea345faa7 UI: Move Match PC Time to next to the time selector & change label & tooltip to clarify behavior further. 2024-12-22 12:53:48 -06:00
Marco Carvalho
5913ceda40 Avoid zero-length array allocations (#427) 2024-12-22 11:36:05 -06:00
Marco Carvalho
decd37ce6d Add missing "yield return" (#424) 2024-12-21 23:28:31 -06:00
23 changed files with 137 additions and 160 deletions

View File

@@ -14,20 +14,20 @@ namespace Ryujinx.BuildValidationTasks
{ {
string path = System.Reflection.Assembly.GetExecutingAssembly().Location; string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
if (path.Split(new string[] { "src" }, StringSplitOptions.None).Length == 1 ) if (path.Split(["src"], StringSplitOptions.None).Length == 1)
{ {
//i assume that we are in a build directory in the solution dir //i assume that we are in a build directory in the solution dir
path = new FileInfo(path).Directory.Parent.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName; path = new FileInfo(path).Directory!.Parent!.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
} }
else else
{ {
path = path.Split(new string[] { "src" }, StringSplitOptions.None)[0]; path = path.Split(["src"], StringSplitOptions.None)[0];
path = new FileInfo(path).Directory.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName; path = new FileInfo(path).Directory!.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
} }
string data; string data;
using (StreamReader sr = new StreamReader(path)) using (StreamReader sr = new(path))
{ {
data = sr.ReadToEnd(); data = sr.ReadToEnd();
} }
@@ -38,13 +38,10 @@ namespace Ryujinx.BuildValidationTasks
{ {
LocalesEntry locale = json.Locales[i]; LocalesEntry locale = json.Locales[i];
foreach (string language in json.Languages) foreach (string langCode in json.Languages.Where(it => !locale.Translations.ContainsKey(it)))
{ {
if (!locale.Translations.ContainsKey(language)) locale.Translations.Add(langCode, string.Empty);
{ Log.LogMessage(MessageImportance.High, $"Added '{langCode}' to Locale '{locale.ID}'");
locale.Translations.Add(language, "");
Log.LogMessage(MessageImportance.High, $"Added {{{language}}} to Locale {{{locale.ID}}}");
}
} }
locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value); locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
@@ -53,7 +50,7 @@ namespace Ryujinx.BuildValidationTasks
string jsonString = JsonConvert.SerializeObject(json, Formatting.Indented); string jsonString = JsonConvert.SerializeObject(json, Formatting.Indented);
using (StreamWriter sw = new StreamWriter(path)) using (StreamWriter sw = new(path))
{ {
sw.Write(jsonString); sw.Write(jsonString);
} }

View File

@@ -230,25 +230,20 @@ namespace Ryujinx.Cpu.AppleHv
{ {
if (size == 0) if (size == 0)
{ {
return Enumerable.Empty<HostMemoryRange>(); yield break;
} }
var guestRegions = GetPhysicalRegionsImpl(va, size); var guestRegions = GetPhysicalRegionsImpl(va, size);
if (guestRegions == null) if (guestRegions == null)
{ {
return null; yield break;
} }
var regions = new HostMemoryRange[guestRegions.Count]; foreach (var guestRegion in guestRegions)
for (int i = 0; i < regions.Length; i++)
{ {
var guestRegion = guestRegions[i];
nint pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size); nint pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size);
regions[i] = new HostMemoryRange((nuint)(ulong)pointer, guestRegion.Size); yield return new HostMemoryRange((nuint)(ulong)pointer, guestRegion.Size);
} }
return regions;
} }
/// <inheritdoc/> /// <inheritdoc/>
@@ -256,23 +251,24 @@ namespace Ryujinx.Cpu.AppleHv
{ {
if (size == 0) if (size == 0)
{ {
return Enumerable.Empty<MemoryRange>(); yield break;
} }
return GetPhysicalRegionsImpl(va, size); foreach (var physicalRegion in GetPhysicalRegionsImpl(va, size))
{
yield return physicalRegion;
}
} }
private List<MemoryRange> GetPhysicalRegionsImpl(ulong va, ulong size) private IEnumerable<MemoryRange> GetPhysicalRegionsImpl(ulong va, ulong size)
{ {
if (!ValidateAddress(va) || !ValidateAddressAndSize(va, size)) if (!ValidateAddress(va) || !ValidateAddressAndSize(va, size))
{ {
return null; yield break;
} }
int pages = GetPagesCount(va, (uint)size, out va); int pages = GetPagesCount(va, (uint)size, out va);
var regions = new List<MemoryRange>();
ulong regionStart = GetPhysicalAddressInternal(va); ulong regionStart = GetPhysicalAddressInternal(va);
ulong regionSize = PageSize; ulong regionSize = PageSize;
@@ -280,14 +276,14 @@ namespace Ryujinx.Cpu.AppleHv
{ {
if (!ValidateAddress(va + PageSize)) if (!ValidateAddress(va + PageSize))
{ {
return null; yield break;
} }
ulong newPa = GetPhysicalAddressInternal(va + PageSize); ulong newPa = GetPhysicalAddressInternal(va + PageSize);
if (GetPhysicalAddressInternal(va) + PageSize != newPa) if (GetPhysicalAddressInternal(va) + PageSize != newPa)
{ {
regions.Add(new MemoryRange(regionStart, regionSize)); yield return new MemoryRange(regionStart, regionSize);
regionStart = newPa; regionStart = newPa;
regionSize = 0; regionSize = 0;
} }
@@ -296,9 +292,7 @@ namespace Ryujinx.Cpu.AppleHv
regionSize += PageSize; regionSize += PageSize;
} }
regions.Add(new MemoryRange(regionStart, regionSize)); yield return new MemoryRange(regionStart, regionSize);
return regions;
} }
/// <remarks> /// <remarks>

View File

@@ -250,25 +250,20 @@ namespace Ryujinx.Cpu.Jit
{ {
if (size == 0) if (size == 0)
{ {
return Enumerable.Empty<HostMemoryRange>(); yield break;
} }
var guestRegions = GetPhysicalRegionsImpl(va, size); var guestRegions = GetPhysicalRegionsImpl(va, size);
if (guestRegions == null) if (guestRegions == null)
{ {
return null; yield break;
} }
var regions = new HostMemoryRange[guestRegions.Count]; foreach (var guestRegion in guestRegions)
for (int i = 0; i < regions.Length; i++)
{ {
var guestRegion = guestRegions[i];
nint pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size); nint pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size);
regions[i] = new HostMemoryRange((nuint)(ulong)pointer, guestRegion.Size); yield return new HostMemoryRange((nuint)(ulong)pointer, guestRegion.Size);
} }
return regions;
} }
/// <inheritdoc/> /// <inheritdoc/>
@@ -276,23 +271,24 @@ namespace Ryujinx.Cpu.Jit
{ {
if (size == 0) if (size == 0)
{ {
return Enumerable.Empty<MemoryRange>(); yield break;
} }
return GetPhysicalRegionsImpl(va, size); foreach (var physicalRegion in GetPhysicalRegionsImpl(va, size))
{
yield return physicalRegion;
}
} }
private List<MemoryRange> GetPhysicalRegionsImpl(ulong va, ulong size) private IEnumerable<MemoryRange> GetPhysicalRegionsImpl(ulong va, ulong size)
{ {
if (!ValidateAddress(va) || !ValidateAddressAndSize(va, size)) if (!ValidateAddress(va) || !ValidateAddressAndSize(va, size))
{ {
return null; yield break;
} }
int pages = GetPagesCount(va, (uint)size, out va); int pages = GetPagesCount(va, (uint)size, out va);
var regions = new List<MemoryRange>();
ulong regionStart = GetPhysicalAddressInternal(va); ulong regionStart = GetPhysicalAddressInternal(va);
ulong regionSize = PageSize; ulong regionSize = PageSize;
@@ -300,14 +296,14 @@ namespace Ryujinx.Cpu.Jit
{ {
if (!ValidateAddress(va + PageSize)) if (!ValidateAddress(va + PageSize))
{ {
return null; yield break;
} }
ulong newPa = GetPhysicalAddressInternal(va + PageSize); ulong newPa = GetPhysicalAddressInternal(va + PageSize);
if (GetPhysicalAddressInternal(va) + PageSize != newPa) if (GetPhysicalAddressInternal(va) + PageSize != newPa)
{ {
regions.Add(new MemoryRange(regionStart, regionSize)); yield return new MemoryRange(regionStart, regionSize);
regionStart = newPa; regionStart = newPa;
regionSize = 0; regionSize = 0;
} }
@@ -316,9 +312,7 @@ namespace Ryujinx.Cpu.Jit
regionSize += PageSize; regionSize += PageSize;
} }
regions.Add(new MemoryRange(regionStart, regionSize)); yield return new MemoryRange(regionStart, regionSize);
return regions;
} }
/// <inheritdoc/> /// <inheritdoc/>

View File

@@ -475,17 +475,15 @@ namespace Ryujinx.Cpu.Jit
return GetPhysicalRegionsImpl(va, size); return GetPhysicalRegionsImpl(va, size);
} }
private List<MemoryRange> GetPhysicalRegionsImpl(ulong va, ulong size) private IEnumerable<MemoryRange> GetPhysicalRegionsImpl(ulong va, ulong size)
{ {
if (!ValidateAddress(va) || !ValidateAddressAndSize(va, size)) if (!ValidateAddress(va) || !ValidateAddressAndSize(va, size))
{ {
return null; yield break;
} }
int pages = GetPagesCount(va, (uint)size, out va); int pages = GetPagesCount(va, (uint)size, out va);
var regions = new List<MemoryRange>();
ulong regionStart = GetPhysicalAddressInternal(va); ulong regionStart = GetPhysicalAddressInternal(va);
ulong regionSize = PageSize; ulong regionSize = PageSize;
@@ -493,14 +491,14 @@ namespace Ryujinx.Cpu.Jit
{ {
if (!ValidateAddress(va + PageSize)) if (!ValidateAddress(va + PageSize))
{ {
return null; yield break;
} }
ulong newPa = GetPhysicalAddressInternal(va + PageSize); ulong newPa = GetPhysicalAddressInternal(va + PageSize);
if (GetPhysicalAddressInternal(va) + PageSize != newPa) if (GetPhysicalAddressInternal(va) + PageSize != newPa)
{ {
regions.Add(new MemoryRange(regionStart, regionSize)); yield return new MemoryRange(regionStart, regionSize);
regionStart = newPa; regionStart = newPa;
regionSize = 0; regionSize = 0;
} }
@@ -509,9 +507,7 @@ namespace Ryujinx.Cpu.Jit
regionSize += PageSize; regionSize += PageSize;
} }
regions.Add(new MemoryRange(regionStart, regionSize)); yield return new MemoryRange(regionStart, regionSize);
return regions;
} }
/// <inheritdoc/> /// <inheritdoc/>

View File

@@ -8,8 +8,6 @@ namespace Ryujinx.Cpu.LightningJit.CodeGen.Arm64
{ {
public IEnumerable<ulong> GetCallStack(nint framePointer, nint codeRegionStart, int codeRegionSize, nint codeRegion2Start, int codeRegion2Size) public IEnumerable<ulong> GetCallStack(nint framePointer, nint codeRegionStart, int codeRegionSize, nint codeRegion2Start, int codeRegion2Size)
{ {
List<ulong> functionPointers = new();
while (true) while (true)
{ {
nint functionPointer = Marshal.ReadIntPtr(framePointer, nint.Size); nint functionPointer = Marshal.ReadIntPtr(framePointer, nint.Size);
@@ -20,11 +18,9 @@ namespace Ryujinx.Cpu.LightningJit.CodeGen.Arm64
break; break;
} }
functionPointers.Add((ulong)functionPointer - 4); yield return (ulong)functionPointer - 4;
framePointer = Marshal.ReadIntPtr(framePointer); framePointer = Marshal.ReadIntPtr(framePointer);
} }
return functionPointers;
} }
} }
} }

View File

@@ -168,16 +168,14 @@ namespace Ryujinx.Graphics.Vulkan
return BinarySearch(list, offset, size) >= 0; return BinarySearch(list, offset, size) >= 0;
} }
public readonly List<Range> FindOverlaps(int offset, int size) public readonly IEnumerable<Range> FindOverlaps(int offset, int size)
{ {
var list = _ranges; var list = _ranges;
if (list == null) if (list == null)
{ {
return null; yield break;
} }
List<Range> result = null;
int index = BinarySearch(list, offset, size); int index = BinarySearch(list, offset, size);
if (index >= 0) if (index >= 0)
@@ -189,12 +187,10 @@ namespace Ryujinx.Graphics.Vulkan
do do
{ {
(result ??= new List<Range>()).Add(list[index++]); yield return list[index++];
} }
while (index < list.Count && list[index].OverlapsWith(offset, size)); while (index < list.Count && list[index].OverlapsWith(offset, size));
} }
return result;
} }
private static int BinarySearch(List<Range> list, int offset, int size) private static int BinarySearch(List<Range> list, int offset, int size)

View File

@@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Vulkan
_api = api; _api = api;
_physicalDevice = physicalDevice; _physicalDevice = physicalDevice;
int totalFormats = Enum.GetNames(typeof(Format)).Length; int totalFormats = Enum.GetNames<Format>().Length;
_bufferTable = new FormatFeatureFlags[totalFormats]; _bufferTable = new FormatFeatureFlags[totalFormats];
_optimalTable = new FormatFeatureFlags[totalFormats]; _optimalTable = new FormatFeatureFlags[totalFormats];

View File

@@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Vulkan
static FormatTable() static FormatTable()
{ {
_table = new VkFormat[Enum.GetNames(typeof(Format)).Length]; _table = new VkFormat[Enum.GetNames<Format>().Length];
_reverseMap = new Dictionary<VkFormat, Format>(); _reverseMap = new Dictionary<VkFormat, Format>();
#pragma warning disable IDE0055 // Disable formatting #pragma warning disable IDE0055 // Disable formatting

View File

@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
{ {
_pipeline = pipeline; _pipeline = pipeline;
int count = Enum.GetNames(typeof(CounterType)).Length; int count = Enum.GetNames<CounterType>().Length;
_counterQueues = new CounterQueue[count]; _counterQueues = new CounterQueue[count];

View File

@@ -341,7 +341,7 @@ namespace Ryujinx.HLE.HOS
{ {
if (VirtualAmiibo.ApplicationBytes.Length > 0) if (VirtualAmiibo.ApplicationBytes.Length > 0)
{ {
VirtualAmiibo.ApplicationBytes = new byte[0]; VirtualAmiibo.ApplicationBytes = Array.Empty<byte>();
VirtualAmiibo.InputBin = string.Empty; VirtualAmiibo.InputBin = string.Empty;
} }
if (NfpDevices[nfpDeviceId].State == NfpDeviceState.SearchingForTag) if (NfpDevices[nfpDeviceId].State == NfpDeviceState.SearchingForTag)
@@ -356,7 +356,7 @@ namespace Ryujinx.HLE.HOS
VirtualAmiibo.InputBin = path; VirtualAmiibo.InputBin = path;
if (VirtualAmiibo.ApplicationBytes.Length > 0) if (VirtualAmiibo.ApplicationBytes.Length > 0)
{ {
VirtualAmiibo.ApplicationBytes = new byte[0]; VirtualAmiibo.ApplicationBytes = Array.Empty<byte>();
} }
byte[] encryptedData = File.ReadAllBytes(path); byte[] encryptedData = File.ReadAllBytes(path);
VirtualAmiiboFile newFile = AmiiboBinReader.ReadBinFile(encryptedData); VirtualAmiiboFile newFile = AmiiboBinReader.ReadBinFile(encryptedData);

View File

@@ -357,7 +357,6 @@ namespace Ryujinx.HLE.HOS
{ {
string cheatName = DefaultCheatName; string cheatName = DefaultCheatName;
List<string> instructions = new(); List<string> instructions = new();
List<Cheat> cheats = new();
using StreamReader cheatData = cheatFile.OpenText(); using StreamReader cheatData = cheatFile.OpenText();
while (cheatData.ReadLine() is { } line) while (cheatData.ReadLine() is { } line)
@@ -373,13 +372,13 @@ namespace Ryujinx.HLE.HOS
Logger.Warning?.Print(LogClass.ModLoader, $"Ignoring cheat '{cheatFile.FullName}' because it is malformed"); Logger.Warning?.Print(LogClass.ModLoader, $"Ignoring cheat '{cheatFile.FullName}' because it is malformed");
return Array.Empty<Cheat>(); yield break;
} }
// Add the previous section to the list. // Add the previous section to the list.
if (instructions.Count > 0) if (instructions.Count > 0)
{ {
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions)); yield return new Cheat($"<{cheatName} Cheat>", cheatFile, instructions);
} }
// Start a new cheat section. // Start a new cheat section.
@@ -396,10 +395,8 @@ namespace Ryujinx.HLE.HOS
// Add the last section being processed. // Add the last section being processed.
if (instructions.Count > 0) if (instructions.Count > 0)
{ {
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions)); yield return new Cheat($"<{cheatName} Cheat>", cheatFile, instructions);
} }
return cheats;
} }
// Assumes searchDirPaths don't overlap // Assumes searchDirPaths don't overlap

View File

@@ -23,18 +23,18 @@ namespace Ryujinx.HLE.HOS.Services
public IpcService(ServerBase server = null) public IpcService(ServerBase server = null)
{ {
CmifCommands = typeof(IpcService).Assembly.GetTypes() CmifCommands = GetType().Assembly.GetTypes()
.Where(type => type == GetType()) .Where(type => type == GetType())
.SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)) .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
.SelectMany(methodInfo => methodInfo.GetCustomAttributes(typeof(CommandCmifAttribute)) .SelectMany(methodInfo => methodInfo.GetCustomAttributes<CommandCmifAttribute>()
.Select(command => (((CommandCmifAttribute)command).Id, methodInfo))) .Select(command => (command.Id, methodInfo)))
.ToDictionary(command => command.Id, command => command.methodInfo); .ToDictionary(command => command.Id, command => command.methodInfo);
TipcCommands = typeof(IpcService).Assembly.GetTypes() TipcCommands = GetType().Assembly.GetTypes()
.Where(type => type == GetType()) .Where(type => type == GetType())
.SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)) .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
.SelectMany(methodInfo => methodInfo.GetCustomAttributes(typeof(CommandTipcAttribute)) .SelectMany(methodInfo => methodInfo.GetCustomAttributes<CommandTipcAttribute>()
.Select(command => (((CommandTipcAttribute)command).Id, methodInfo))) .Select(command => (command.Id, methodInfo)))
.ToDictionary(command => command.Id, command => command.methodInfo); .ToDictionary(command => command.Id, command => command.methodInfo);
Server = server; Server = server;

View File

@@ -444,7 +444,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
private ResultCode ScanInternal(IVirtualMemoryManager memory, ushort channel, ScanFilter scanFilter, ulong bufferPosition, ulong bufferSize, out ulong counter) private ResultCode ScanInternal(IVirtualMemoryManager memory, ushort channel, ScanFilter scanFilter, ulong bufferPosition, ulong bufferSize, out ulong counter)
{ {
ulong networkInfoSize = (ulong)Marshal.SizeOf(typeof(NetworkInfo)); ulong networkInfoSize = (ulong)Marshal.SizeOf<NetworkInfo>();
ulong maxGames = bufferSize / networkInfoSize; ulong maxGames = bufferSize / networkInfoSize;
MemoryHelper.FillWithZeros(memory, bufferPosition, (int)bufferSize); MemoryHelper.FillWithZeros(memory, bufferPosition, (int)bufferSize);

View File

@@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
static class VirtualAmiibo static class VirtualAmiibo
{ {
public static uint OpenedApplicationAreaId; public static uint OpenedApplicationAreaId;
public static byte[] ApplicationBytes = new byte[0]; public static byte[] ApplicationBytes = Array.Empty<byte>();
public static string InputBin = string.Empty; public static string InputBin = string.Empty;
public static string NickName = string.Empty; public static string NickName = string.Empty;
private static readonly AmiiboJsonSerializerContext _serializerContext = AmiiboJsonSerializerContext.Default; private static readonly AmiiboJsonSerializerContext _serializerContext = AmiiboJsonSerializerContext.Default;
@@ -137,7 +137,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
if (ApplicationBytes.Length > 0) if (ApplicationBytes.Length > 0)
{ {
byte[] bytes = ApplicationBytes; byte[] bytes = ApplicationBytes;
ApplicationBytes = new byte[0]; ApplicationBytes = Array.Empty<byte>();
return bytes; return bytes;
} }
VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId); VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId);

View File

@@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm
{ {
if (_services.TryGetValue(name, out Type type)) if (_services.TryGetValue(name, out Type type))
{ {
ServiceAttribute serviceAttribute = (ServiceAttribute)type.GetCustomAttributes(typeof(ServiceAttribute)).First(service => ((ServiceAttribute)service).Name == name); ServiceAttribute serviceAttribute = type.GetCustomAttributes<ServiceAttribute>().First(service => service.Name == name);
IpcService service = GetServiceInstance(type, context, serviceAttribute.Parameter); IpcService service = GetServiceInstance(type, context, serviceAttribute.Parameter);

View File

@@ -34,14 +34,14 @@ namespace Ryujinx.Horizon.Kernel.Generators
private const string TypeResult = NamespaceHorizonCommon + "." + TypeResultName; private const string TypeResult = NamespaceHorizonCommon + "." + TypeResultName;
private const string TypeExecutionContext = "IExecutionContext"; private const string TypeExecutionContext = "IExecutionContext";
private static readonly string[] _expectedResults = new string[] private static readonly string[] _expectedResults =
{ [
$"{TypeResultName}.Success", $"{TypeResultName}.Success",
$"{TypeKernelResultName}.TimedOut", $"{TypeKernelResultName}.TimedOut",
$"{TypeKernelResultName}.Cancelled", $"{TypeKernelResultName}.Cancelled",
$"{TypeKernelResultName}.PortRemoteClosed", $"{TypeKernelResultName}.PortRemoteClosed",
$"{TypeKernelResultName}.InvalidState", $"{TypeKernelResultName}.InvalidState",
}; ];
private readonly struct OutParameter private readonly struct OutParameter
{ {

View File

@@ -106,10 +106,13 @@ namespace Ryujinx.Memory
{ {
if (size == 0) if (size == 0)
{ {
return Enumerable.Empty<HostMemoryRange>(); yield break;
} }
return GetHostRegionsImpl(va, size); foreach (var hostRegion in GetHostRegionsImpl(va, size))
{
yield return hostRegion;
}
} }
/// <inheritdoc/> /// <inheritdoc/>
@@ -117,51 +120,36 @@ namespace Ryujinx.Memory
{ {
if (size == 0) if (size == 0)
{ {
return Enumerable.Empty<MemoryRange>(); yield break;
} }
var hostRegions = GetHostRegionsImpl(va, size); var hostRegions = GetHostRegionsImpl(va, size);
if (hostRegions == null) if (hostRegions == null)
{ {
return null; yield break;
} }
var regions = new MemoryRange[hostRegions.Count];
ulong backingStart = (ulong)_backingMemory.Pointer; ulong backingStart = (ulong)_backingMemory.Pointer;
ulong backingEnd = backingStart + _backingMemory.Size; ulong backingEnd = backingStart + _backingMemory.Size;
int count = 0; foreach (var hostRegion in hostRegions)
for (int i = 0; i < regions.Length; i++)
{ {
var hostRegion = hostRegions[i];
if (hostRegion.Address >= backingStart && hostRegion.Address < backingEnd) if (hostRegion.Address >= backingStart && hostRegion.Address < backingEnd)
{ {
regions[count++] = new MemoryRange(hostRegion.Address - backingStart, hostRegion.Size); yield return new MemoryRange(hostRegion.Address - backingStart, hostRegion.Size);
} }
} }
if (count != regions.Length)
{
return new ArraySegment<MemoryRange>(regions, 0, count);
}
return regions;
} }
private List<HostMemoryRange> GetHostRegionsImpl(ulong va, ulong size) private IEnumerable<HostMemoryRange> GetHostRegionsImpl(ulong va, ulong size)
{ {
if (!ValidateAddress(va) || !ValidateAddressAndSize(va, size)) if (!ValidateAddress(va) || !ValidateAddressAndSize(va, size))
{ {
return null; yield break;
} }
int pages = GetPagesCount(va, size, out va); int pages = GetPagesCount(va, size, out va);
var regions = new List<HostMemoryRange>();
nuint regionStart = GetHostAddress(va); nuint regionStart = GetHostAddress(va);
ulong regionSize = PageSize; ulong regionSize = PageSize;
@@ -169,14 +157,14 @@ namespace Ryujinx.Memory
{ {
if (!ValidateAddress(va + PageSize)) if (!ValidateAddress(va + PageSize))
{ {
return null; yield break;
} }
nuint newHostAddress = GetHostAddress(va + PageSize); nuint newHostAddress = GetHostAddress(va + PageSize);
if (GetHostAddress(va) + PageSize != newHostAddress) if (GetHostAddress(va) + PageSize != newHostAddress)
{ {
regions.Add(new HostMemoryRange(regionStart, regionSize)); yield return new HostMemoryRange(regionStart, regionSize);
regionStart = newHostAddress; regionStart = newHostAddress;
regionSize = 0; regionSize = 0;
} }
@@ -185,9 +173,7 @@ namespace Ryujinx.Memory
regionSize += PageSize; regionSize += PageSize;
} }
regions.Add(new HostMemoryRange(regionStart, regionSize)); yield return new HostMemoryRange(regionStart, regionSize);
return regions;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]

View File

@@ -1125,6 +1125,30 @@
"zh_TW": "檢查更新" "zh_TW": "檢查更新"
} }
}, },
{
"ID": "MenuBarHelpFaqAndGuides",
"Translations": {
"ar_SA": "",
"de_DE": "",
"el_GR": "",
"en_US": "FAQ & Guides",
"es_ES": "",
"fr_FR": "",
"he_IL": "",
"it_IT": "",
"ja_JP": "",
"ko_KR": "",
"no_NO": "",
"pl_PL": "",
"pt_BR": "",
"ru_RU": "",
"th_TH": "",
"tr_TR": "",
"uk_UA": "",
"zh_CN": "",
"zh_TW": ""
}
},
{ {
"ID": "MenuBarHelpFaq", "ID": "MenuBarHelpFaq",
"Translations": { "Translations": {
@@ -3771,7 +3795,7 @@
"ar_SA": "", "ar_SA": "",
"de_DE": "", "de_DE": "",
"el_GR": "", "el_GR": "",
"en_US": "Match PC Time", "en_US": "Resync to PC Date & Time",
"es_ES": "", "es_ES": "",
"fr_FR": "", "fr_FR": "",
"he_IL": "", "he_IL": "",
@@ -14571,7 +14595,7 @@
"ar_SA": "", "ar_SA": "",
"de_DE": "", "de_DE": "",
"el_GR": "", "el_GR": "",
"en_US": "Change System Time to match your PC's date & time.", "en_US": "Resync System Time to match your PC's current date & time.\n\nThis is not an active setting, it can still fall out of sync; in which case just click this button again.",
"es_ES": "", "es_ES": "",
"fr_FR": "", "fr_FR": "",
"he_IL": "", "he_IL": "",

View File

@@ -97,7 +97,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{ {
if (IsModified) if (IsModified)
{ {
_playerIdChoose = value; _playerIdChoose = value;
return; return;
} }
@@ -105,7 +105,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
IsModified = false; IsModified = false;
_playerId = value; _playerId = value;
if (!Enum.IsDefined(typeof(PlayerIndex), _playerId)) if (!Enum.IsDefined<PlayerIndex>(_playerId))
{ {
_playerId = PlayerIndex.Player1; _playerId = PlayerIndex.Player1;

View File

@@ -290,6 +290,11 @@
</MenuItem> </MenuItem>
</MenuItem> </MenuItem>
<MenuItem VerticalAlignment="Center" Header="{ext:Locale MenuBarHelp}"> <MenuItem VerticalAlignment="Center" Header="{ext:Locale MenuBarHelp}">
<MenuItem
Click="OpenAboutWindow"
Header="{ext:Locale MenuBarHelpAbout}"
Icon="{ext:Icon fa-solid fa-circle-info}"
ToolTip.Tip="{ext:Locale OpenAboutTooltip}" />
<MenuItem <MenuItem
Name="UpdateMenuItem" Name="UpdateMenuItem"
IsEnabled="{Binding CanUpdate}" IsEnabled="{Binding CanUpdate}"
@@ -298,30 +303,26 @@
Icon="{ext:Icon mdi-update}" Icon="{ext:Icon mdi-update}"
ToolTip.Tip="{ext:Locale CheckUpdatesTooltip}" /> ToolTip.Tip="{ext:Locale CheckUpdatesTooltip}" />
<Separator /> <Separator />
<MenuItem <MenuItem VerticalAlignment="Center" Header="{ext:Locale MenuBarHelpFaqAndGuides}" Icon="{ext:Icon fa-solid fa-question}" >
Click="MenuItem_OnClick" <MenuItem
Header="{ext:Locale MenuBarHelpFaq}" Click="MenuItem_OnClick"
Icon="{ext:Icon fa-github}" Header="{ext:Locale MenuBarHelpFaq}"
Tag="https://github.com/GreemDev/Ryujinx/wiki/FAQ-and-Troubleshooting" Icon="{ext:Icon fa-github}"
ToolTip.Tip="{ext:Locale MenuBarHelpFaqTooltip}" /> Tag="https://github.com/GreemDev/Ryujinx/wiki/FAQ-and-Troubleshooting"
<MenuItem ToolTip.Tip="{ext:Locale MenuBarHelpFaqTooltip}" />
Click="MenuItem_OnClick" <MenuItem
Header="{ext:Locale MenuBarHelpSetup}" Click="MenuItem_OnClick"
Icon="{ext:Icon fa-github}" Header="{ext:Locale MenuBarHelpSetup}"
Tag="https://github.com/GreemDev/Ryujinx/wiki/Ryujinx-Setup-&amp;-Configuration-Guide" Icon="{ext:Icon fa-github}"
ToolTip.Tip="{ext:Locale MenuBarHelpSetupTooltip}" /> Tag="https://github.com/GreemDev/Ryujinx/wiki/Ryujinx-Setup-&amp;-Configuration-Guide"
<MenuItem ToolTip.Tip="{ext:Locale MenuBarHelpSetupTooltip}" />
Click="MenuItem_OnClick" <MenuItem
Header="{ext:Locale MenuBarHelpMultiplayer}" Click="MenuItem_OnClick"
Icon="{ext:Icon fa-github}" Header="{ext:Locale MenuBarHelpMultiplayer}"
Tag="https://github.com/GreemDev/Ryujinx/wiki/Multiplayer%E2%80%90(LDN%E2%80%90Local%E2%80%90Wireless)%E2%80%90Guide" Icon="{ext:Icon fa-github}"
ToolTip.Tip="{ext:Locale MenuBarHelpMultiplayerTooltip}" /> Tag="https://github.com/GreemDev/Ryujinx/wiki/Multiplayer%E2%80%90(LDN%E2%80%90Local%E2%80%90Wireless)%E2%80%90Guide"
<Separator /> ToolTip.Tip="{ext:Locale MenuBarHelpMultiplayerTooltip}" />
<MenuItem </MenuItem>
Click="OpenAboutWindow"
Header="{ext:Locale MenuBarHelpAbout}"
Icon="{ext:Icon fa-solid fa-circle-info}"
ToolTip.Tip="{ext:Locale OpenAboutTooltip}" />
</MenuItem> </MenuItem>
</Menu> </Menu>
</DockPanel> </DockPanel>

View File

@@ -52,7 +52,7 @@ namespace Ryujinx.Ava.UI.Views.Main
private void AspectRatioStatus_OnClick(object sender, RoutedEventArgs e) private void AspectRatioStatus_OnClick(object sender, RoutedEventArgs e)
{ {
AspectRatio aspectRatio = ConfigurationState.Instance.Graphics.AspectRatio.Value; AspectRatio aspectRatio = ConfigurationState.Instance.Graphics.AspectRatio.Value;
ConfigurationState.Instance.Graphics.AspectRatio.Value = (int)aspectRatio + 1 > Enum.GetNames(typeof(AspectRatio)).Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1; ConfigurationState.Instance.Graphics.AspectRatio.Value = (int)aspectRatio + 1 > Enum.GetNames<AspectRatio>().Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
} }
private void Refresh_OnClick(object sender, RoutedEventArgs e) => Window.LoadApplications(); private void Refresh_OnClick(object sender, RoutedEventArgs e) => Window.LoadApplications();

View File

@@ -181,15 +181,11 @@
SelectedTime="{Binding CurrentTime}" SelectedTime="{Binding CurrentTime}"
Width="350" Width="350"
ToolTip.Tip="{ext:Locale TimeTooltip}" /> ToolTip.Tip="{ext:Locale TimeTooltip}" />
</StackPanel>
<StackPanel
Margin="350,0,0,10"
Orientation="Horizontal">
<Button <Button
Margin="10, 0, 0, 0"
VerticalAlignment="Center" VerticalAlignment="Center"
Click="MatchSystemTime_OnClick" Click="MatchSystemTime_OnClick"
Background="{DynamicResource SystemAccentColor}" Background="{DynamicResource SystemAccentColor}"
Width="150"
ToolTip.Tip="{ext:Locale MatchTimeTooltip}"> ToolTip.Tip="{ext:Locale MatchTimeTooltip}">
<TextBlock Text="{ext:Locale SettingsTabSystemSystemTimeMatch}" /> <TextBlock Text="{ext:Locale SettingsTabSystemSystemTimeMatch}" />
</Button> </Button>

View File

@@ -1,7 +1,7 @@
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.ViewModels;
using System;
using TimeZone = Ryujinx.Ava.UI.Models.TimeZone; using TimeZone = Ryujinx.Ava.UI.Models.TimeZone;
namespace Ryujinx.Ava.UI.Views.Settings namespace Ryujinx.Ava.UI.Views.Settings