## Usage
diff --git a/docs/compatibility.csv b/docs/compatibility.csv
index 570c93618..6cb10e8d8 100644
--- a/docs/compatibility.csv
+++ b/docs/compatibility.csv
@@ -332,6 +332,7 @@
0100E680149DC000,"Arcaea",,playable,2023-03-16 19:31:21
01003C2010C78000,"Archaica: The Path Of Light",crash,nothing,2020-10-16 13:22:26
01004DA012976000,"Area 86",,playable,2020-12-16 16:45:52
+01008d8006a6a000,"Arena of Valor",crash,boots,2025-02-03 22:19:34
0100691013C46000,"ARIA CHRONICLE",,playable,2022-11-16 13:50:55
0100D4A00B284000,"ARK: Survival Evolved",gpu;nvdec;online-broken;UE4;ldn-untested,ingame,2024-04-16 00:53:56
0100C56012C96000,"Arkanoid vs. Space Invaders",services,ingame,2021-01-21 12:50:30
@@ -426,6 +427,7 @@
0100E48013A34000,"Balan Wonderworld Demo",gpu;services;UE4;demo,ingame,2023-02-16 20:05:07
0100CD801CE5E000,"Balatro",,ingame,2024-04-21 02:01:53
010010A00DA48000,"Baldur's Gate and Baldur's Gate II: Enhanced Editions",32-bit,playable,2022-09-12 23:52:15
+0100fd1014726000,"Baldur's Gate: Dark Alliance",ldn-untested,ingame,2025-02-03 22:21:00
0100BC400FB64000,"Balthazar's Dream",,playable,2022-09-13 00:13:22
01008D30128E0000,"Bamerang",,playable,2022-10-26 00:29:39
010013C010C5C000,"Banner of the Maid",,playable,2021-06-14 15:23:37
@@ -528,6 +530,7 @@
01005950022EC000,"Blade Strangers",nvdec,playable,2022-07-17 19:02:43
0100DF0011A6A000,"Bladed Fury",,playable,2022-10-26 11:36:26
0100CFA00CC74000,"Blades of Time",deadlock;online,boots,2022-07-17 19:19:58
+01003d700dd8a000,"Blades",,boots,2025-02-03 22:22:00
01006CC01182C000,"Blair Witch",nvdec;UE4,playable,2022-10-01 14:06:16
010039501405E000,"Blanc",gpu;slow,ingame,2023-02-22 14:00:13
0100698009C6E000,"Blasphemous",nvdec,playable,2021-03-01 12:15:31
@@ -955,7 +958,7 @@
010012800EBAE000,"Disney TSUM TSUM FESTIVAL",crash,menus,2020-07-14 14:05:28
01009740120FE000,"DISTRAINT 2",,playable,2020-09-03 16:08:12
010075B004DD2000,"DISTRAINT: Deluxe Edition",,playable,2020-06-15 23:42:24
-010027400CDC6000,"Divinity: Original Sin 2 - Definitive Edition",services;crash;online-broken;regression,menus,2023-08-13 17:20:03
+010027400CDC6000,"Divinity: Original Sin 2 - Definitive Edition",services;crash;online-broken;regression,ingame,2025-02-03 22:12:30
01001770115C8000,"Dodo Peak",nvdec;UE4,playable,2022-10-04 16:13:05
010077B0100DA000,"Dogurai",,playable,2020-10-04 02:40:16
010048100D51A000,"Dokapon Up! Mugen no Roulette",gpu;Needs Update,menus,2022-12-08 19:39:10
@@ -1246,7 +1249,7 @@
0100A6B00D4EC000,"Furwind",,playable,2021-02-19 19:44:08
0100ECE00C0C4000,"Fury Unleashed",crash;services,ingame,2020-10-18 11:52:40
010070000ED9E000,"Fury Unleashed Demo",,playable,2020-10-08 20:09:21
-0100E1F013674000,"FUSER™",nvdec;UE4,playable,2022-10-17 20:58:32
+0100E1F013674000,"FUSER™",nvdec;UE4;slow;gpu,ingame,2025-02-12 16:03:00
0100A7A015E4C000,"Fushigi no Gensokyo Lotus Labyrinth",Needs Update;audio;gpu;nvdec,ingame,2021-01-20 15:30:02
01003C300B274000,"Futari de! Nyanko Daisensou",,playable,2024-01-05 22:26:52
010055801134E000,"FUZE Player",online-broken;vulkan-backend-bug,ingame,2022-10-18 12:23:53
@@ -1654,7 +1657,7 @@
0100A73006E74000,"Legendary Eleven",,playable,2021-06-08 12:09:03
0100A7700B46C000,"Legendary Fishing",online,playable,2021-04-14 15:08:46
0100739018020000,"LEGO® 2K Drive",gpu;ldn-works,ingame,2024-04-09 02:05:12
-01003A30012C0000,"LEGO® CITY Undercover",nvdec,playable,2024-09-30 08:44:27
+010085500130a000,"LEGO® CITY Undercover",nvdec,playable,2024-09-30 08:44:27
010070D009FEC000,"LEGO® DC Super-Villains",,playable,2021-05-27 18:10:37
010052A00B5D2000,"LEGO® Harry Potter™ Collection",crash,ingame,2024-01-31 10:28:07
010073C01AF34000,"LEGO® Horizon Adventures™",vulkan-backend-bug;opengl-backend-bug;UE4,ingame,2025-01-07 04:24:56
@@ -1913,6 +1916,7 @@
010073E008E6E000,"Mugsters",,playable,2021-01-28 17:57:17
0100A8400471A000,"MUJO",,playable,2020-05-08 16:31:04
0100211005E94000,"Mulaka",,playable,2021-01-28 18:07:20
+01008e2013fb4000,"Multi Quiz",ldn-untested,ingame,2025-02-03 22:26:00
010038B00B9AE000,"Mummy Pinball",,playable,2022-08-05 16:08:11
01008E200C5C2000,"Muse Dash",,playable,2020-06-06 14:41:29
010035901046C000,"Mushroom Quest",,playable,2020-05-17 13:07:08
@@ -2028,6 +2032,7 @@
010003C00B868000,"Ninjin: Clash of Carrots",online-broken,playable,2024-07-10 05:12:26
0100746010E4C000,"NinNinDays",,playable,2022-11-20 15:17:29
0100C9A00ECE6000,"Nintendo 64™ – Nintendo Switch Online",gpu;vulkan,ingame,2024-04-23 20:21:07
+0100e0601c632000,"Nintendo 64™ – Nintendo Switch Online: MATURE 17+",,ingame,2025-02-03 22:27:00
0100D870045B6000,"Nintendo Entertainment System™ - Nintendo Switch Online",online,playable,2022-07-01 15:45:06
0100C4B0034B2000,"Nintendo Labo Toy-Con 01 Variety Kit",gpu,ingame,2022-08-07 12:56:07
01001E9003502000,"Nintendo Labo Toy-Con 03 Vehicle Kit",services;crash,menus,2022-08-03 17:20:11
@@ -2058,7 +2063,7 @@
010002700C34C000,"Numbala",,playable,2020-05-11 12:01:07
010020500C8C8000,"Number Place 10000",gpu,menus,2021-11-24 09:14:23
010003701002C000,"Nurse Love Syndrome",,playable,2022-10-13 10:05:22
-0000000000000000,"nx-hbmenu",Needs Update;homebrew,boots,2024-04-06 22:05:32
+,"nx-hbmenu",Needs Update;homebrew,boots,2024-04-06 22:05:32
,"nxquake2",services;crash;homebrew,nothing,2022-08-04 23:14:04
010049F00EC30000,"Nyan Cat: Lost in Space",online,playable,2021-06-12 13:22:03
01002E6014FC4000,"O---O",,playable,2022-10-29 12:12:14
@@ -2466,7 +2471,7 @@
0100AFE00DDAC000,"Royal Roads",,playable,2020-11-17 12:54:38
0100E2C00B414000,"RPG Maker MV",nvdec,playable,2021-01-05 20:12:01
01005CD015986000,"rRootage Reloaded",,playable,2022-08-05 23:20:18
-0000000000000000,"RSDKv5u",homebrew,ingame,2024-04-01 16:25:34
+,"RSDKv5u",homebrew,ingame,2024-04-01 16:25:34
010009B00D33C000,"Rugby Challenge 4",slow;online-broken;UE4,playable,2022-10-06 12:45:53
01006EC00F2CC000,"RUINER",UE4,playable,2022-10-03 14:11:33
010074F00DE4A000,"Run the Fan",,playable,2021-02-27 13:36:28
@@ -2475,6 +2480,7 @@
010081C0191D8000,"Rune Factory 3 Special",,playable,2023-10-15 08:32:49
010051D00E3A4000,"Rune Factory 4 Special",32-bit;crash;nvdec,ingame,2023-05-06 08:49:17
010014D01216E000,"Rune Factory 5 (JP)",gpu,ingame,2021-06-01 12:00:36
+010071E0145F8000,"Rustler",,playable,2025-02-10 20:17:12
0100E21013908000,"RWBY: Grimm Eclipse - Definitive Edition",online-broken,playable,2022-11-03 10:44:01
010012C0060F0000,"RXN -Raijin-",nvdec,playable,2021-01-10 16:05:43
0100B8B012ECA000,"S.N.I.P.E.R. - Hunter Scope",,playable,2021-04-19 15:58:09
@@ -2483,7 +2489,7 @@
0100A5200C2E0000,"Safety First!",,playable,2021-01-06 09:05:23
0100A51013530000,"SaGa Frontier Remastered",nvdec,playable,2022-11-03 13:54:56
010003A00D0B4000,"SaGa SCARLET GRACE: AMBITIONS™",,playable,2022-10-06 13:20:31
-01008D100D43E000,"Saints Row IV®: Re-Elected™",ldn-untested;LAN,playable,2023-12-04 18:33:37
+01008D100D43E000,"Saints Row IV®: Re-Elected™",ldn-untested;LAN;deadlock,ingame,2025-02-02 16:57:53
0100DE600BEEE000,"SAINTS ROW®: THE THIRD™ - THE FULL PACKAGE",slow;LAN,playable,2023-08-24 02:40:58
01007F000EB36000,"Sakai and...",nvdec,playable,2022-12-15 13:53:19
0100B1400E8FE000,"Sakuna: Of Rice and Ruin",,playable,2023-07-24 13:47:13
@@ -2532,7 +2538,7 @@
0100C3E00B700000,"SEGA AGES Space Harrier",,playable,2021-01-11 12:57:40
010054400D2E6000,"SEGA AGES Virtua Racing",online-broken,playable,2023-01-29 17:08:39
01001E700AC60000,"SEGA AGES Wonder Boy: Monster Land",online,playable,2021-05-05 16:28:25
-0100B3C014BDA000,"SEGA Genesis™ – Nintendo Switch Online",crash;regression,nothing,2022-04-11 07:27:21
+0100B3C014BDA000,"SEGA Genesis™ – Nintendo Switch Online",crash;regression,ingame,2025-02-03 22:13:30
0100F7300B24E000,"SEGA Mega Drive Classics",online,playable,2021-01-05 11:08:00
01009840046BC000,"Semispheres",,playable,2021-01-06 23:08:31
0100D1800D902000,"SENRAN KAGURA Peach Ball",,playable,2021-06-03 15:12:10
@@ -2668,10 +2674,10 @@
01004F401BEBE000,"Song of Nunu: A League of Legends Story",,ingame,2024-07-12 18:53:44
0100E5400BF94000,"Songbird Symphony",,playable,2021-02-27 02:44:04
010031D00A604000,"Songbringer",,playable,2020-06-22 10:42:02
-0000000000000000,"Sonic 1 (2013)",crash;homebrew,ingame,2024-04-06 18:31:20
-0000000000000000,"Sonic 2 (2013)",crash;homebrew,ingame,2024-04-01 16:25:30
-0000000000000000,"Sonic A.I.R",homebrew,ingame,2024-04-01 16:25:32
-0000000000000000,"Sonic CD",crash;homebrew,ingame,2024-04-01 16:25:31
+,"Sonic 1 (2013)",crash;homebrew,ingame,2024-04-06 18:31:20
+,"Sonic 2 (2013)",crash;homebrew,ingame,2024-04-01 16:25:30
+,"Sonic A.I.R",homebrew,ingame,2024-04-01 16:25:32
+,"Sonic CD",crash;homebrew,ingame,2024-04-01 16:25:31
010040E0116B8000,"Sonic Colors: Ultimate",,playable,2022-11-12 21:24:26
01001270012B6000,"SONIC FORCES™",,playable,2024-07-28 13:11:21
01004AD014BF0000,"Sonic Frontiers",gpu;deadlock;amd-vendor-bug;intel-vendor-bug,ingame,2024-09-05 09:18:53
@@ -2688,7 +2694,7 @@
0100707011722000,"Space Elite Force",,playable,2020-11-27 15:21:05
010047B010260000,"Space Pioneer",,playable,2022-10-20 12:24:37
010010A009830000,"Space Ribbon",,playable,2022-08-15 17:17:10
-0000000000000000,"SpaceCadetPinball",homebrew,ingame,2024-04-18 19:30:04
+,"SpaceCadetPinball",homebrew,ingame,2024-04-18 19:30:04
0100D9B0041CE000,"Spacecats with Lasers",,playable,2022-08-15 17:22:44
010034800FB60000,"Spaceland",,playable,2020-11-01 14:31:56
010028D0045CE000,"Sparkle 2",,playable,2020-10-19 11:51:39
@@ -2833,7 +2839,7 @@
0100000000010000,"Super Mario Odyssey™",nvdec;intel-vendor-bug;mac-bug,playable,2024-08-25 01:32:34
010036B0034E4000,"Super Mario Party™",gpu;Needs Update;ldn-works,ingame,2024-06-21 05:10:16
0100BC0018138000,"Super Mario RPG™",gpu;audio;nvdec,ingame,2024-06-19 17:43:42
-0000000000000000,"Super Mario World",homebrew,boots,2024-06-13 01:40:31
+,"Super Mario World",homebrew,boots,2024-06-13 01:40:31
010049900F546000,"Super Mario™ 3D All-Stars",services-horizon;slow;vulkan;amd-vendor-bug,ingame,2024-05-07 02:38:16
010028600EBDA000,"Super Mario™ 3D World + Bowser’s Fury",ldn-works,playable,2024-07-31 10:45:37
01004F8006A78000,"Super Meat Boy",services,playable,2020-04-02 23:10:07
@@ -2964,6 +2970,7 @@
0100C38004DCC000,"The Flame In The Flood: Complete Edition",gpu;nvdec;UE4,ingame,2022-08-22 16:23:49
010007700D4AC000,"The Forbidden Arts",,playable,2021-01-26 16:26:24
010030700CBBC000,"The friends of Ringo Ishikawa",,playable,2022-08-22 16:33:17
+0100b620139d8000,"The Game of Life 2",ldn-untested,ingame,2025-02-03 22:30:00
01006350148DA000,"The Gardener and the Wild Vines",gpu,ingame,2024-04-29 16:32:10
0100B13007A6A000,"The Gardens Between",,playable,2021-01-29 16:16:53
010036E00FB20000,"The Great Ace Attorney Chronicles",,playable,2023-06-22 21:26:29
@@ -2981,6 +2988,8 @@
010015D003EE4000,"The Jackbox Party Pack 2",online-working,playable,2022-08-22 18:23:40
0100CC80013D6000,"The Jackbox Party Pack 3",slow;online-working,playable,2022-08-22 18:41:06
0100E1F003EE8000,"The Jackbox Party Pack 4",online-working,playable,2022-08-22 18:56:34
+01006fe0096ac000,"The Jackbox Party Pack 5",ldn-untested,boots,2025-02-03 22:32:00
+01005a400db52000,"The Jackbox Party Pack 6",ldn-untested,boots,2025-02-03 22:32:00
010052C00B184000,"The Journey Down: Chapter One",nvdec,playable,2021-02-24 13:32:41
01006BC00B188000,"The Journey Down: Chapter Three",nvdec,playable,2021-02-24 13:45:27
01009AB00B186000,"The Journey Down: Chapter Two",nvdec,playable,2021-02-24 13:32:13
@@ -3159,6 +3168,7 @@
010055E00CA68000,"Trine 4: The Nightmare Prince",gpu,nothing,2025-01-07 05:47:46
0100D9000A930000,"Trine Enchanted Edition",ldn-untested;nvdec,playable,2021-06-03 11:28:15
01002D7010A54000,"Trinity Trigger",crash,ingame,2023-03-03 03:09:09
+010020700a5e0000,"TRIVIAL PURSUIT Live!",ldn-untested,ingame,2025-02-03 22:35:00
0100868013FFC000,"TRIVIAL PURSUIT Live! 2",,boots,2022-12-19 00:04:33
0100F78002040000,"Troll and I™",gpu;nvdec,ingame,2021-06-04 16:58:50
0100145011008000,"Trollhunters: Defenders of Arcadia",gpu;nvdec,ingame,2020-11-30 13:27:09
@@ -3208,6 +3218,7 @@
0100AB2010B4C000,"Unlock The King",,playable,2020-09-01 13:58:27
0100A3E011CB0000,"Unlock the King 2",,playable,2021-06-15 20:43:55
01005AA00372A000,"UNO® for Nintendo Switch",nvdec;ldn-untested,playable,2022-07-28 14:49:47
+0100b6e012ebe000,"UNO",ldn-untested,ingame,2025-02-03 22:40:00
0100E5D00CC0C000,"Unravel Two",nvdec,playable,2024-05-23 15:45:05
010001300CC4A000,"Unruly Heroes",,playable,2021-01-07 18:09:31
0100B410138C0000,"Unspottable",,playable,2022-10-25 19:28:49
@@ -3372,6 +3383,7 @@
0100F47016F26000,"Yomawari 3",,playable,2022-05-10 08:26:51
010012F00B6F2000,"Yomawari: The Long Night Collection",,playable,2022-09-03 14:36:59
0100CC600ABB2000,"Yonder: The Cloud Catcher Chronicles (Retail Only)",,playable,2021-01-28 14:06:25
+0100534009ff2000,"Yonder: The Cloud Catcher Chronicles",,playable,2025-02-03 22:19:13
0100BE50042F6000,"Yono and the Celestial Elephants",,playable,2021-01-28 18:23:58
0100F110029C8000,"Yooka-Laylee",,playable,2021-01-28 14:21:45
010022F00DA66000,"Yooka-Laylee and the Impossible Lair",,playable,2021-03-05 17:32:21
diff --git a/src/ARMeilleure/CodeGen/CompiledFunction.cs b/src/ARMeilleure/CodeGen/CompiledFunction.cs
index 8ea7ff532..7014f715a 100644
--- a/src/ARMeilleure/CodeGen/CompiledFunction.cs
+++ b/src/ARMeilleure/CodeGen/CompiledFunction.cs
@@ -1,7 +1,6 @@
using ARMeilleure.CodeGen.Linking;
using ARMeilleure.CodeGen.Unwinding;
using ARMeilleure.Translation.Cache;
-using System;
using System.Runtime.InteropServices;
namespace ARMeilleure.CodeGen
diff --git a/src/ARMeilleure/IntermediateRepresentation/MemoryOperand.cs b/src/ARMeilleure/IntermediateRepresentation/MemoryOperand.cs
index 45695396f..d22c89a75 100644
--- a/src/ARMeilleure/IntermediateRepresentation/MemoryOperand.cs
+++ b/src/ARMeilleure/IntermediateRepresentation/MemoryOperand.cs
@@ -1,4 +1,3 @@
-using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
diff --git a/src/ARMeilleure/Memory/ReservedRegion.cs b/src/ARMeilleure/Memory/ReservedRegion.cs
index a3ebd610d..dfe17c933 100644
--- a/src/ARMeilleure/Memory/ReservedRegion.cs
+++ b/src/ARMeilleure/Memory/ReservedRegion.cs
@@ -7,6 +7,7 @@ namespace ARMeilleure.Memory
public const int DefaultGranularity = 65536; // Mapping granularity in Windows.
public IJitMemoryBlock Block { get; }
+ public IJitMemoryAllocator Allocator { get; }
public nint Pointer => Block.Pointer;
@@ -21,6 +22,7 @@ namespace ARMeilleure.Memory
granularity = DefaultGranularity;
}
+ Allocator = allocator;
Block = allocator.Reserve(maxSize);
_maxSize = maxSize;
_sizeGranularity = granularity;
diff --git a/src/ARMeilleure/Native/JitSupportDarwin.cs b/src/ARMeilleure/Native/JitSupportDarwin.cs
index 39df3878f..9383b9a08 100644
--- a/src/ARMeilleure/Native/JitSupportDarwin.cs
+++ b/src/ARMeilleure/Native/JitSupportDarwin.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
diff --git a/src/ARMeilleure/Signal/TestMethods.cs b/src/ARMeilleure/Signal/TestMethods.cs
index 5f9f456bc..684157860 100644
--- a/src/ARMeilleure/Signal/TestMethods.cs
+++ b/src/ARMeilleure/Signal/TestMethods.cs
@@ -1,6 +1,5 @@
using ARMeilleure.IntermediateRepresentation;
using ARMeilleure.Translation;
-using System;
using System.Runtime.InteropServices;
using static ARMeilleure.IntermediateRepresentation.Operand.Factory;
diff --git a/src/ARMeilleure/Signal/WindowsPartialUnmapHandler.cs b/src/ARMeilleure/Signal/WindowsPartialUnmapHandler.cs
index 7aa3e4788..0df2f41cd 100644
--- a/src/ARMeilleure/Signal/WindowsPartialUnmapHandler.cs
+++ b/src/ARMeilleure/Signal/WindowsPartialUnmapHandler.cs
@@ -1,7 +1,6 @@
using ARMeilleure.IntermediateRepresentation;
using ARMeilleure.Translation;
using Ryujinx.Common.Memory.PartialUnmaps;
-using System;
using System.Runtime.InteropServices;
using static ARMeilleure.IntermediateRepresentation.Operand.Factory;
diff --git a/src/ARMeilleure/State/ExecutionContext.cs b/src/ARMeilleure/State/ExecutionContext.cs
index 314b06b13..6996ec221 100644
--- a/src/ARMeilleure/State/ExecutionContext.cs
+++ b/src/ARMeilleure/State/ExecutionContext.cs
@@ -1,5 +1,4 @@
using ARMeilleure.Memory;
-using System;
namespace ARMeilleure.State
{
diff --git a/src/ARMeilleure/Translation/ArmEmitterContext.cs b/src/ARMeilleure/Translation/ArmEmitterContext.cs
index 5d09783ff..196120e92 100644
--- a/src/ARMeilleure/Translation/ArmEmitterContext.cs
+++ b/src/ARMeilleure/Translation/ArmEmitterContext.cs
@@ -6,7 +6,6 @@ using ARMeilleure.Instructions;
using ARMeilleure.IntermediateRepresentation;
using ARMeilleure.Memory;
using ARMeilleure.State;
-using System;
using System.Collections.Generic;
using System.Reflection;
using static ARMeilleure.IntermediateRepresentation.Operand.Factory;
diff --git a/src/ARMeilleure/Translation/Cache/JitCache.cs b/src/ARMeilleure/Translation/Cache/JitCache.cs
index d7e8201d8..bc75e7d3f 100644
--- a/src/ARMeilleure/Translation/Cache/JitCache.cs
+++ b/src/ARMeilleure/Translation/Cache/JitCache.cs
@@ -2,6 +2,8 @@ using ARMeilleure.CodeGen;
using ARMeilleure.CodeGen.Unwinding;
using ARMeilleure.Memory;
using ARMeilleure.Native;
+using Humanizer;
+using Ryujinx.Common.Logging;
using Ryujinx.Memory;
using System;
using System.Collections.Generic;
@@ -18,9 +20,8 @@ namespace ARMeilleure.Translation.Cache
private static readonly int _pageMask = _pageSize - 1;
private const int CodeAlignment = 4; // Bytes.
- private const int CacheSize = 2047 * 1024 * 1024;
+ private const int CacheSize = 256 * 1024 * 1024;
- private static ReservedRegion _jitRegion;
private static JitCacheInvalidation _jitCacheInvalidator;
private static CacheMemoryAllocator _cacheAllocator;
@@ -30,6 +31,9 @@ namespace ARMeilleure.Translation.Cache
private static readonly Lock _lock = new();
private static bool _initialized;
+ private static readonly List _jitRegions = new();
+ private static int _activeRegionIndex = 0;
+
[SupportedOSPlatform("windows")]
[LibraryImport("kernel32.dll", SetLastError = true)]
public static partial nint FlushInstructionCache(nint hProcess, nint lpAddress, nuint dwSize);
@@ -48,7 +52,9 @@ namespace ARMeilleure.Translation.Cache
return;
}
- _jitRegion = new ReservedRegion(allocator, CacheSize);
+ ReservedRegion firstRegion = new(allocator, CacheSize);
+ _jitRegions.Add(firstRegion);
+ _activeRegionIndex = 0;
if (!OperatingSystem.IsWindows() && !OperatingSystem.IsMacOS())
{
@@ -59,7 +65,9 @@ namespace ARMeilleure.Translation.Cache
if (OperatingSystem.IsWindows())
{
- JitUnwindWindows.InstallFunctionTableHandler(_jitRegion.Pointer, CacheSize, _jitRegion.Pointer + Allocate(_pageSize));
+ JitUnwindWindows.InstallFunctionTableHandler(
+ firstRegion.Pointer, CacheSize, firstRegion.Pointer + Allocate(_pageSize)
+ );
}
_initialized = true;
@@ -75,8 +83,8 @@ namespace ARMeilleure.Translation.Cache
Debug.Assert(_initialized);
int funcOffset = Allocate(code.Length);
-
- nint funcPtr = _jitRegion.Pointer + funcOffset;
+ ReservedRegion targetRegion = _jitRegions[_activeRegionIndex];
+ nint funcPtr = targetRegion.Pointer + funcOffset;
if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
@@ -90,9 +98,9 @@ namespace ARMeilleure.Translation.Cache
}
else
{
- ReprotectAsWritable(funcOffset, code.Length);
+ ReprotectAsWritable(targetRegion, funcOffset, code.Length);
Marshal.Copy(code, 0, funcPtr, code.Length);
- ReprotectAsExecutable(funcOffset, code.Length);
+ ReprotectAsExecutable(targetRegion, funcOffset, code.Length);
if (OperatingSystem.IsWindows() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
@@ -116,52 +124,83 @@ namespace ARMeilleure.Translation.Cache
{
Debug.Assert(_initialized);
- int funcOffset = (int)(pointer.ToInt64() - _jitRegion.Pointer.ToInt64());
-
- if (TryFind(funcOffset, out CacheEntry entry, out int entryIndex) && entry.Offset == funcOffset)
+ foreach (ReservedRegion region in _jitRegions)
{
- _cacheAllocator.Free(funcOffset, AlignCodeSize(entry.Size));
- _cacheEntries.RemoveAt(entryIndex);
+ if (pointer.ToInt64() < region.Pointer.ToInt64() ||
+ pointer.ToInt64() >= (region.Pointer + CacheSize).ToInt64())
+ {
+ continue;
+ }
+
+ int funcOffset = (int)(pointer.ToInt64() - region.Pointer.ToInt64());
+
+ if (TryFind(funcOffset, out CacheEntry entry, out int entryIndex) && entry.Offset == funcOffset)
+ {
+ _cacheAllocator.Free(funcOffset, AlignCodeSize(entry.Size));
+ _cacheEntries.RemoveAt(entryIndex);
+ }
+
+ return;
}
}
}
- private static void ReprotectAsWritable(int offset, int size)
+ private static void ReprotectAsWritable(ReservedRegion region, int offset, int size)
{
int endOffs = offset + size;
-
int regionStart = offset & ~_pageMask;
int regionEnd = (endOffs + _pageMask) & ~_pageMask;
- _jitRegion.Block.MapAsRwx((ulong)regionStart, (ulong)(regionEnd - regionStart));
+ region.Block.MapAsRwx((ulong)regionStart, (ulong)(regionEnd - regionStart));
}
- private static void ReprotectAsExecutable(int offset, int size)
+ private static void ReprotectAsExecutable(ReservedRegion region, int offset, int size)
{
int endOffs = offset + size;
-
int regionStart = offset & ~_pageMask;
int regionEnd = (endOffs + _pageMask) & ~_pageMask;
- _jitRegion.Block.MapAsRx((ulong)regionStart, (ulong)(regionEnd - regionStart));
+ region.Block.MapAsRx((ulong)regionStart, (ulong)(regionEnd - regionStart));
}
private static int Allocate(int codeSize)
{
codeSize = AlignCodeSize(codeSize);
- int allocOffset = _cacheAllocator.Allocate(codeSize);
-
- if (allocOffset < 0)
+ for (int i = _activeRegionIndex; i < _jitRegions.Count; i++)
{
- throw new OutOfMemoryException("JIT Cache exhausted.");
+ int allocOffset = _cacheAllocator.Allocate(codeSize);
+
+ if (allocOffset >= 0)
+ {
+ _jitRegions[i].ExpandIfNeeded((ulong)allocOffset + (ulong)codeSize);
+ _activeRegionIndex = i;
+ return allocOffset;
+ }
}
- _jitRegion.ExpandIfNeeded((ulong)allocOffset + (ulong)codeSize);
+ int exhaustedRegion = _activeRegionIndex;
+ var newRegion = new ReservedRegion(_jitRegions[0].Allocator, CacheSize);
+ _jitRegions.Add(newRegion);
+ _activeRegionIndex = _jitRegions.Count - 1;
+
+ int newRegionNumber = _activeRegionIndex;
- return allocOffset;
+ Logger.Warning?.Print(LogClass.Cpu, $"JIT Cache Region {exhaustedRegion} exhausted, creating new Cache Region {newRegionNumber} ({((newRegionNumber + 1) * CacheSize).Bytes()} Total Allocation).");
+
+ _cacheAllocator = new CacheMemoryAllocator(CacheSize);
+
+ int allocOffsetNew = _cacheAllocator.Allocate(codeSize);
+ if (allocOffsetNew < 0)
+ {
+ throw new OutOfMemoryException("Failed to allocate in new Cache Region!");
+ }
+
+ newRegion.ExpandIfNeeded((ulong)allocOffsetNew + (ulong)codeSize);
+ return allocOffsetNew;
}
+
private static int AlignCodeSize(int codeSize)
{
return checked(codeSize + (CodeAlignment - 1)) & ~(CodeAlignment - 1);
@@ -185,18 +224,21 @@ namespace ARMeilleure.Translation.Cache
{
lock (_lock)
{
- int index = _cacheEntries.BinarySearch(new CacheEntry(offset, 0, default));
-
- if (index < 0)
+ foreach (ReservedRegion _ in _jitRegions)
{
- index = ~index - 1;
- }
+ int index = _cacheEntries.BinarySearch(new CacheEntry(offset, 0, default));
- if (index >= 0)
- {
- entry = _cacheEntries[index];
- entryIndex = index;
- return true;
+ if (index < 0)
+ {
+ index = ~index - 1;
+ }
+
+ if (index >= 0)
+ {
+ entry = _cacheEntries[index];
+ entryIndex = index;
+ return true;
+ }
}
}
diff --git a/src/ARMeilleure/Translation/Cache/JitCacheInvalidation.cs b/src/ARMeilleure/Translation/Cache/JitCacheInvalidation.cs
index e24f5e864..02e27b941 100644
--- a/src/ARMeilleure/Translation/Cache/JitCacheInvalidation.cs
+++ b/src/ARMeilleure/Translation/Cache/JitCacheInvalidation.cs
@@ -1,5 +1,4 @@
using ARMeilleure.Memory;
-using System;
using System.Runtime.InteropServices;
namespace ARMeilleure.Translation.Cache
diff --git a/src/ARMeilleure/Translation/DelegateInfo.cs b/src/ARMeilleure/Translation/DelegateInfo.cs
index 64ee7bc9c..c27dbd6b4 100644
--- a/src/ARMeilleure/Translation/DelegateInfo.cs
+++ b/src/ARMeilleure/Translation/DelegateInfo.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace ARMeilleure.Translation
{
class DelegateInfo
diff --git a/src/ARMeilleure/Translation/DispatcherFunction.cs b/src/ARMeilleure/Translation/DispatcherFunction.cs
index f8b9dc31e..db5e27344 100644
--- a/src/ARMeilleure/Translation/DispatcherFunction.cs
+++ b/src/ARMeilleure/Translation/DispatcherFunction.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace ARMeilleure.Translation
{
delegate void DispatcherFunction(nint nativeContext, ulong startAddress);
diff --git a/src/ARMeilleure/Translation/GuestFunction.cs b/src/ARMeilleure/Translation/GuestFunction.cs
index 5c7c733f9..b02d260df 100644
--- a/src/ARMeilleure/Translation/GuestFunction.cs
+++ b/src/ARMeilleure/Translation/GuestFunction.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace ARMeilleure.Translation
{
delegate ulong GuestFunction(nint nativeContextPtr);
diff --git a/src/ARMeilleure/Translation/PTC/Ptc.cs b/src/ARMeilleure/Translation/PTC/Ptc.cs
index b53fdd4df..1301aaebe 100644
--- a/src/ARMeilleure/Translation/PTC/Ptc.cs
+++ b/src/ARMeilleure/Translation/PTC/Ptc.cs
@@ -3,6 +3,8 @@ using ARMeilleure.CodeGen.Linking;
using ARMeilleure.CodeGen.Unwinding;
using ARMeilleure.Common;
using ARMeilleure.Memory;
+using ARMeilleure.State;
+using Humanizer;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
@@ -30,8 +32,8 @@ namespace ARMeilleure.Translation.PTC
{
private const string OuterHeaderMagicString = "PTCohd\0\0";
private const string InnerHeaderMagicString = "PTCihd\0\0";
-
- private const uint InternalVersion = 6998; //! To be incremented manually for each change to the ARMeilleure project.
+
+ private const uint InternalVersion = 7007; //! To be incremented manually for each change to the ARMeilleure project.
private const string ActualDir = "0";
private const string BackupDir = "1";
@@ -184,6 +186,36 @@ namespace ARMeilleure.Translation.PTC
InitializeCarriers();
}
+ private bool ContainsBlacklistedFunctions()
+ {
+ List blacklist = Profiler.GetBlacklistedFunctions();
+ bool containsBlacklistedFunctions = false;
+ _infosStream.Seek(0L, SeekOrigin.Begin);
+ bool foundBadFunction = false;
+
+ for (int index = 0; index < GetEntriesCount(); index++)
+ {
+ InfoEntry infoEntry = DeserializeStructure(_infosStream);
+ foreach (ulong address in blacklist)
+ {
+ if (infoEntry.Address == address)
+ {
+ containsBlacklistedFunctions = true;
+ Logger.Warning?.Print(LogClass.Ptc, "PPTC cache invalidated: Found blacklisted functions in PPTC cache");
+ foundBadFunction = true;
+ break;
+ }
+ }
+
+ if (foundBadFunction)
+ {
+ break;
+ }
+ }
+
+ return containsBlacklistedFunctions;
+ }
+
private void PreLoad()
{
string fileNameActual = $"{CachePathActual}.cache";
@@ -532,7 +564,7 @@ namespace ARMeilleure.Translation.PTC
public void LoadTranslations(Translator translator)
{
- if (AreCarriersEmpty())
+ if (AreCarriersEmpty() || ContainsBlacklistedFunctions())
{
return;
}
@@ -835,10 +867,18 @@ namespace ARMeilleure.Translation.PTC
while (profiledFuncsToTranslate.TryDequeue(out (ulong address, PtcProfiler.FuncProfile funcProfile) item))
{
ulong address = item.address;
+ ExecutionMode executionMode = item.funcProfile.Mode;
+ bool highCq = item.funcProfile.HighCq;
Debug.Assert(Profiler.IsAddressInStaticCodeRange(address));
- TranslatedFunction func = translator.Translate(address, item.funcProfile.Mode, item.funcProfile.HighCq);
+ TranslatedFunction func = translator.Translate(address, executionMode, highCq);
+
+ if (func == null)
+ {
+ Profiler.UpdateEntry(address, executionMode, true, true);
+ continue;
+ }
bool isAddressUnique = translator.Functions.TryAdd(address, func.GuestSize, func);
@@ -884,8 +924,11 @@ namespace ARMeilleure.Translation.PTC
sw.Stop();
PtcStateChanged?.Invoke(PtcLoadingState.Loaded, _translateCount, _translateTotalCount);
-
- Logger.Info?.Print(LogClass.Ptc, $"{_translateCount} of {_translateTotalCount} functions translated | Thread count: {degreeOfParallelism} in {sw.Elapsed.TotalSeconds} s");
+
+ Logger.Info?.Print(LogClass.Ptc,
+ $"{_translateCount} of {_translateTotalCount} functions translated in {sw.Elapsed.TotalSeconds} seconds " +
+ $"| {"function".ToQuantity(_translateTotalCount - _translateCount)} blacklisted " +
+ $"| Thread count: {degreeOfParallelism}");
Thread preSaveThread = new(PreSave)
{
diff --git a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs
index 21987f72d..f3aaa58ff 100644
--- a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs
+++ b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs
@@ -24,11 +24,12 @@ namespace ARMeilleure.Translation.PTC
{
private const string OuterHeaderMagicString = "Pohd\0\0\0\0";
- private const uint InternalVersion = 5518; //! Not to be incremented manually for each change to the ARMeilleure project.
+ private const uint InternalVersion = 7007; //! Not to be incremented manually for each change to the ARMeilleure project.
- private static readonly uint[] _migrateInternalVersions =
+ private static readonly uint[] _migrateInternalVersions =
[
- 1866
+ 1866,
+ 5518,
];
private const int SaveInterval = 30; // Seconds.
@@ -77,20 +78,30 @@ namespace ARMeilleure.Translation.PTC
private void TimerElapsed(object _, ElapsedEventArgs __)
=> new Thread(PreSave) { Name = "Ptc.DiskWriter" }.Start();
- public void AddEntry(ulong address, ExecutionMode mode, bool highCq)
+ public void AddEntry(ulong address, ExecutionMode mode, bool highCq, bool blacklist = false)
{
if (IsAddressInStaticCodeRange(address))
{
Debug.Assert(!highCq);
- lock (_lock)
+ if (blacklist)
{
- ProfiledFuncs.TryAdd(address, new FuncProfile(mode, highCq: false));
+ lock (_lock)
+ {
+ ProfiledFuncs[address] = new FuncProfile(mode, highCq: false, true);
+ }
+ }
+ else
+ {
+ lock (_lock)
+ {
+ ProfiledFuncs.TryAdd(address, new FuncProfile(mode, highCq: false, false));
+ }
}
}
}
- public void UpdateEntry(ulong address, ExecutionMode mode, bool highCq)
+ public void UpdateEntry(ulong address, ExecutionMode mode, bool highCq, bool? blacklist = null)
{
if (IsAddressInStaticCodeRange(address))
{
@@ -100,7 +111,7 @@ namespace ARMeilleure.Translation.PTC
{
Debug.Assert(ProfiledFuncs.ContainsKey(address));
- ProfiledFuncs[address] = new FuncProfile(mode, highCq: true);
+ ProfiledFuncs[address] = new FuncProfile(mode, highCq: true, blacklist ?? ProfiledFuncs[address].Blacklist);
}
}
}
@@ -116,7 +127,7 @@ namespace ARMeilleure.Translation.PTC
foreach (KeyValuePair profiledFunc in ProfiledFuncs)
{
- if (!funcs.ContainsKey(profiledFunc.Key))
+ if (!funcs.ContainsKey(profiledFunc.Key) && !profiledFunc.Value.Blacklist)
{
profiledFuncsToTranslate.Enqueue((profiledFunc.Key, profiledFunc.Value));
}
@@ -131,6 +142,22 @@ namespace ARMeilleure.Translation.PTC
ProfiledFuncs.TrimExcess();
}
+ public List GetBlacklistedFunctions()
+ {
+ List funcs = [];
+
+ foreach ((ulong ptr, FuncProfile funcProfile) in ProfiledFuncs)
+ {
+ if (!funcProfile.Blacklist)
+ continue;
+
+ if (!funcs.Contains(ptr))
+ funcs.Add(ptr);
+ }
+
+ return funcs;
+ }
+
public void PreLoad()
{
_lastHash = default;
@@ -221,13 +248,18 @@ namespace ARMeilleure.Translation.PTC
return false;
}
+ Func migrateEntryFunc = null;
+
switch (outerHeader.InfoFileVersion)
{
case InternalVersion:
ProfiledFuncs = Deserialize(stream);
break;
case 1866:
- ProfiledFuncs = Deserialize(stream, (address, profile) => (address + 0x500000UL, profile));
+ migrateEntryFunc = (address, profile) => (address + 0x500000UL, profile);
+ goto case 5518;
+ case 5518:
+ ProfiledFuncs = DeserializeAddBlacklist(stream, migrateEntryFunc);
break;
default:
Logger.Error?.Print(LogClass.Ptc, $"No migration path for {nameof(outerHeader.InfoFileVersion)} '{outerHeader.InfoFileVersion}'. Discarding cache.");
@@ -257,6 +289,16 @@ namespace ARMeilleure.Translation.PTC
return DeserializeDictionary(stream, DeserializeStructure);
}
+ private static Dictionary DeserializeAddBlacklist(Stream stream, Func migrateEntryFunc = null)
+ {
+ if (migrateEntryFunc != null)
+ {
+ return DeserializeAndUpdateDictionary(stream, (Stream stream) => { return new FuncProfile(DeserializeStructure(stream)); }, migrateEntryFunc);
+ }
+
+ return DeserializeDictionary(stream, (Stream stream) => { return new FuncProfile(DeserializeStructure(stream)); });
+ }
+
private static ReadOnlySpan GetReadOnlySpan(MemoryStream memoryStream)
{
return new(memoryStream.GetBuffer(), (int)memoryStream.Position, (int)memoryStream.Length - (int)memoryStream.Position);
@@ -388,13 +430,35 @@ namespace ARMeilleure.Translation.PTC
}
}
- [StructLayout(LayoutKind.Sequential, Pack = 1/*, Size = 5*/)]
+ [StructLayout(LayoutKind.Sequential, Pack = 1/*, Size = 6*/)]
public struct FuncProfile
{
public ExecutionMode Mode;
public bool HighCq;
+ public bool Blacklist;
- public FuncProfile(ExecutionMode mode, bool highCq)
+ public FuncProfile(ExecutionMode mode, bool highCq, bool blacklist)
+ {
+ Mode = mode;
+ HighCq = highCq;
+ Blacklist = blacklist;
+ }
+
+ public FuncProfile(FuncProfilePreBlacklist fp)
+ {
+ Mode = fp.Mode;
+ HighCq = fp.HighCq;
+ Blacklist = false;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1/*, Size = 5*/)]
+ public struct FuncProfilePreBlacklist
+ {
+ public ExecutionMode Mode;
+ public bool HighCq;
+
+ public FuncProfilePreBlacklist(ExecutionMode mode, bool highCq)
{
Mode = mode;
HighCq = highCq;
diff --git a/src/ARMeilleure/Translation/TranslatedFunction.cs b/src/ARMeilleure/Translation/TranslatedFunction.cs
index 3d7ae9ffe..181cc5578 100644
--- a/src/ARMeilleure/Translation/TranslatedFunction.cs
+++ b/src/ARMeilleure/Translation/TranslatedFunction.cs
@@ -1,5 +1,4 @@
using ARMeilleure.Common;
-using System;
namespace ARMeilleure.Translation
{
diff --git a/src/ARMeilleure/Translation/Translator.cs b/src/ARMeilleure/Translation/Translator.cs
index 0f18c8045..14c80f24b 100644
--- a/src/ARMeilleure/Translation/Translator.cs
+++ b/src/ARMeilleure/Translation/Translator.cs
@@ -5,7 +5,6 @@ using ARMeilleure.Diagnostics;
using ARMeilleure.Instructions;
using ARMeilleure.IntermediateRepresentation;
using ARMeilleure.Memory;
-using ARMeilleure.Signal;
using ARMeilleure.State;
using ARMeilleure.Translation.Cache;
using ARMeilleure.Translation.PTC;
@@ -249,6 +248,11 @@ namespace ARMeilleure.Translation
ControlFlowGraph cfg = EmitAndGetCFG(context, blocks, out Range funcRange, out Counter counter);
+ if (cfg == null)
+ {
+ return null;
+ }
+
ulong funcSize = funcRange.End - funcRange.Start;
Logger.EndPass(PassName.Translation, cfg);
@@ -407,6 +411,11 @@ namespace ARMeilleure.Translation
if (opCode.Instruction.Emitter != null)
{
opCode.Instruction.Emitter(context);
+ if (opCode.Instruction.Name == InstName.Und && blkIndex == 0)
+ {
+ range = new Range(rangeStart, rangeEnd);
+ return null;
+ }
}
else
{
diff --git a/src/ARMeilleure/Translation/TranslatorStubs.cs b/src/ARMeilleure/Translation/TranslatorStubs.cs
index f719dba31..458a42434 100644
--- a/src/ARMeilleure/Translation/TranslatorStubs.cs
+++ b/src/ARMeilleure/Translation/TranslatorStubs.cs
@@ -4,7 +4,6 @@ using ARMeilleure.IntermediateRepresentation;
using ARMeilleure.State;
using ARMeilleure.Translation.Cache;
using System;
-using System.Reflection;
using System.Runtime.InteropServices;
using static ARMeilleure.IntermediateRepresentation.Operand.Factory;
diff --git a/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceSession.cs b/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceSession.cs
index 51cd43c55..9170b73c7 100644
--- a/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceSession.cs
+++ b/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceSession.cs
@@ -4,7 +4,6 @@ using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
using Ryujinx.Memory;
using System;
-using System.Buffers;
using System.Collections.Concurrent;
using System.Threading;
diff --git a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIo.cs b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIo.cs
index 9decd79fc..6a12e8c0c 100644
--- a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIo.cs
+++ b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIo.cs
@@ -1,5 +1,4 @@
using Ryujinx.Common.Memory;
-using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
diff --git a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoDeviceContext.cs b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoDeviceContext.cs
index efea52b35..7c782bd76 100644
--- a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoDeviceContext.cs
+++ b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoDeviceContext.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static Ryujinx.Audio.Backends.SoundIo.Native.SoundIo;
diff --git a/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs b/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs
index e9cc6a8e1..1540cd0e3 100644
--- a/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs
+++ b/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs
@@ -4,7 +4,6 @@ using Ryujinx.Audio.Common;
using Ryujinx.Common.Memory;
using Ryujinx.Memory;
using System;
-using System.Buffers;
using System.Collections.Concurrent;
using System.Runtime.CompilerServices;
using System.Threading;
diff --git a/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs b/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs
index 6f31755a3..a06ab21a7 100644
--- a/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs
+++ b/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs
@@ -1,7 +1,6 @@
using Ryujinx.Common;
using Ryujinx.Common.Memory;
using System;
-using System.Buffers;
using System.Threading;
namespace Ryujinx.Audio.Backends.Common
diff --git a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/MemoryPoolState.cs b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/MemoryPoolState.cs
index d0133622a..50153af37 100644
--- a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/MemoryPoolState.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/MemoryPoolState.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.InteropServices;
using CpuAddress = System.UInt64;
using DspAddress = System.UInt64;
diff --git a/src/Ryujinx.Common/Configuration/VSyncMode.cs b/src/Ryujinx.Common/Configuration/VSyncMode.cs
index ca93b5e1c..e0bf2591f 100644
--- a/src/Ryujinx.Common/Configuration/VSyncMode.cs
+++ b/src/Ryujinx.Common/Configuration/VSyncMode.cs
@@ -6,4 +6,16 @@ namespace Ryujinx.Common.Configuration
Unbounded,
Custom
}
+
+ public static class VSyncModeExtensions
+ {
+ public static VSyncMode Next(this VSyncMode vsync, bool customEnabled = false) =>
+ vsync switch
+ {
+ VSyncMode.Switch => customEnabled ? VSyncMode.Custom : VSyncMode.Unbounded,
+ VSyncMode.Unbounded => VSyncMode.Switch,
+ VSyncMode.Custom => VSyncMode.Unbounded,
+ _ => VSyncMode.Switch
+ };
+ }
}
diff --git a/src/Ryujinx.Common/Helpers/FileAssociationHelper.cs b/src/Ryujinx.Common/Helpers/FileAssociationHelper.cs
index 7ed5e869a..6e14a796e 100644
--- a/src/Ryujinx.Common/Helpers/FileAssociationHelper.cs
+++ b/src/Ryujinx.Common/Helpers/FileAssociationHelper.cs
@@ -1,5 +1,4 @@
using Microsoft.Win32;
-using Ryujinx.Common;
using Ryujinx.Common.Logging;
using System;
using System.Diagnostics;
diff --git a/src/Ryujinx.Common/Helpers/ObjectiveC.cs b/src/Ryujinx.Common/Helpers/ObjectiveC.cs
index d8e02f54d..4c2481f6e 100644
--- a/src/Ryujinx.Common/Helpers/ObjectiveC.cs
+++ b/src/Ryujinx.Common/Helpers/ObjectiveC.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
diff --git a/src/Ryujinx.Common/Helpers/Patterns.cs b/src/Ryujinx.Common/Helpers/Patterns.cs
new file mode 100644
index 000000000..84cc1353a
--- /dev/null
+++ b/src/Ryujinx.Common/Helpers/Patterns.cs
@@ -0,0 +1,118 @@
+using System.Text.RegularExpressions;
+
+namespace Ryujinx.Common.Helper
+{
+ public static partial class Patterns
+ {
+ #region Accessors
+
+ public static readonly Regex Numeric = NumericRegex();
+
+ public static readonly Regex AmdGcn = AmdGcnRegex();
+ public static readonly Regex NvidiaConsumerClass = NvidiaConsumerClassRegex();
+
+ public static readonly Regex DomainLp1Ns = DomainLp1NsRegex();
+ public static readonly Regex DomainLp1Lp1Npln = DomainLp1Lp1NplnRegex();
+ public static readonly Regex DomainLp1Znc = DomainLp1ZncRegex();
+ public static readonly Regex DomainSbApi = DomainSbApiRegex();
+ public static readonly Regex DomainSbAccounts = DomainSbAccountsRegex();
+ public static readonly Regex DomainAccounts = DomainAccountsRegex();
+
+ public static readonly Regex Module = ModuleRegex();
+ public static readonly Regex FsSdk = FsSdkRegex();
+ public static readonly Regex SdkMw = SdkMwRegex();
+
+ // ReSharper disable once InconsistentNaming
+ public static readonly Regex CJK = CJKRegex();
+
+ public static readonly Regex LdnPassphrase = LdnPassphraseRegex();
+
+ public static readonly Regex CleanText = CleanTextRegex();
+
+ #endregion
+
+ #region Generated pattern stubs
+
+ #region Numeric validation
+
+ [GeneratedRegex("[0-9]|.")]
+ internal static partial Regex NumericRegex();
+
+ #endregion
+
+ #region GPU names
+
+ [GeneratedRegex(
+ "Radeon (((HD|R(5|7|9|X)) )?((M?[2-6]\\d{2}(\\D|$))|([7-8]\\d{3}(\\D|$))|Fury|Nano))|(Pro Duo)")]
+ internal static partial Regex AmdGcnRegex();
+
+ [GeneratedRegex("NVIDIA GeForce (R|G)?TX? (\\d{3}\\d?)M?")]
+ internal static partial Regex NvidiaConsumerClassRegex();
+
+ #endregion
+
+ #region DNS blocking
+
+ public static readonly Regex[] BlockedHosts =
+ [
+ DomainLp1Ns,
+ DomainLp1Lp1Npln,
+ DomainLp1Znc,
+ DomainSbApi,
+ DomainSbAccounts,
+ DomainAccounts
+ ];
+
+ const RegexOptions DnsRegexOpts =
+ RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture;
+
+ [GeneratedRegex(@"^(.*)\-lp1\.(n|s)\.n\.srv\.nintendo\.net$", DnsRegexOpts)]
+ internal static partial Regex DomainLp1NsRegex();
+
+ [GeneratedRegex(@"^(.*)\-lp1\.lp1\.t\.npln\.srv\.nintendo\.net$", DnsRegexOpts)]
+ internal static partial Regex DomainLp1Lp1NplnRegex();
+
+ [GeneratedRegex(@"^(.*)\-lp1\.(znc|p)\.srv\.nintendo\.net$", DnsRegexOpts)]
+ internal static partial Regex DomainLp1ZncRegex();
+
+ [GeneratedRegex(@"^(.*)\-sb\-api\.accounts\.nintendo\.com$", DnsRegexOpts)]
+ internal static partial Regex DomainSbApiRegex();
+
+ [GeneratedRegex(@"^(.*)\-sb\.accounts\.nintendo\.com$", DnsRegexOpts)]
+ internal static partial Regex DomainSbAccountsRegex();
+
+ [GeneratedRegex(@"^accounts\.nintendo\.com$", DnsRegexOpts)]
+ internal static partial Regex DomainAccountsRegex();
+
+ #endregion
+
+ #region Executable information
+
+ [GeneratedRegex(@"[a-z]:[\\/][ -~]{5,}\.nss", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
+ internal static partial Regex ModuleRegex();
+
+ [GeneratedRegex(@"sdk_version: ([0-9.]*)")]
+ internal static partial Regex FsSdkRegex();
+
+ [GeneratedRegex(@"SDK MW[ -~]*")]
+ internal static partial Regex SdkMwRegex();
+
+ #endregion
+
+ #region CJK
+
+ [GeneratedRegex(
+ "\\p{IsHangulJamo}|\\p{IsCJKRadicalsSupplement}|\\p{IsCJKSymbolsandPunctuation}|\\p{IsEnclosedCJKLettersandMonths}|\\p{IsCJKCompatibility}|\\p{IsCJKUnifiedIdeographsExtensionA}|\\p{IsCJKUnifiedIdeographs}|\\p{IsHangulSyllables}|\\p{IsCJKCompatibilityForms}")]
+ private static partial Regex CJKRegex();
+
+ #endregion
+
+ [GeneratedRegex("Ryujinx-[0-9a-f]{8}")]
+ private static partial Regex LdnPassphraseRegex();
+
+ [GeneratedRegex(@"[^\u0000\u0009\u000A\u000D\u0020-\uFFFF]..")]
+ private static partial Regex CleanTextRegex();
+
+ #endregion
+ }
+}
diff --git a/src/Ryujinx.Common/Helpers/RefEvent.cs b/src/Ryujinx.Common/Helpers/RefEvent.cs
new file mode 100644
index 000000000..f339dfb7c
--- /dev/null
+++ b/src/Ryujinx.Common/Helpers/RefEvent.cs
@@ -0,0 +1,58 @@
+using Gommon;
+using System.Collections.Generic;
+using System.Threading;
+
+namespace Ryujinx.Common.Helper
+{
+ public class RefEvent
+ {
+ public delegate void Handler(ref T arg);
+
+ private readonly Lock _subLock = new();
+ private readonly List _subscriptions = [];
+
+ public bool HasSubscribers
+ {
+ get
+ {
+ lock (_subLock)
+ return _subscriptions.Count != 0;
+ }
+ }
+
+ public IReadOnlyList Subscriptions
+ {
+ get
+ {
+ lock (_subLock)
+ return _subscriptions;
+ }
+ }
+
+ public void Add(Handler subscriber)
+ {
+ Guard.Require(subscriber, nameof(subscriber));
+ lock (_subLock)
+ _subscriptions.Add(subscriber);
+ }
+
+ public void Remove(Handler subscriber)
+ {
+ Guard.Require(subscriber, nameof(subscriber));
+ lock (_subLock)
+ _subscriptions.Remove(subscriber);
+ }
+
+ public void Clear()
+ {
+ lock (_subLock)
+ _subscriptions.Clear();
+ }
+
+ public void Call(ref T arg)
+ {
+ foreach (Handler subscription in Subscriptions)
+ subscription(ref arg);
+ }
+ }
+}
diff --git a/src/Ryujinx.Common/Helpers/RunningPlatform.cs b/src/Ryujinx.Common/Helpers/RunningPlatform.cs
index 61f5bd614..8d85c4a3c 100644
--- a/src/Ryujinx.Common/Helpers/RunningPlatform.cs
+++ b/src/Ryujinx.Common/Helpers/RunningPlatform.cs
@@ -10,14 +10,18 @@ namespace Ryujinx.Common.Helper
public static bool IsMacOS => OperatingSystem.IsMacOS();
public static bool IsWindows => OperatingSystem.IsWindows();
public static bool IsLinux => OperatingSystem.IsLinux();
+
+ public static bool IsArm => RuntimeInformation.OSArchitecture is Architecture.Arm64;
+
+ public static bool IsX64 => RuntimeInformation.OSArchitecture is Architecture.X64;
- public static bool IsIntelMac => IsMacOS && RuntimeInformation.OSArchitecture is Architecture.X64;
- public static bool IsArmMac => IsMacOS && RuntimeInformation.OSArchitecture is Architecture.Arm64;
+ public static bool IsIntelMac => IsMacOS && IsX64;
+ public static bool IsArmMac => IsMacOS && IsArm;
- public static bool IsX64Windows => IsWindows && (RuntimeInformation.OSArchitecture is Architecture.X64);
- public static bool IsArmWindows => IsWindows && (RuntimeInformation.OSArchitecture is Architecture.Arm64);
+ public static bool IsX64Windows => IsWindows && IsX64;
+ public static bool IsArmWindows => IsWindows && IsArm;
- public static bool IsX64Linux => IsLinux && (RuntimeInformation.OSArchitecture is Architecture.X64);
- public static bool IsArmLinux => IsLinux && (RuntimeInformation.OSArchitecture is Architecture.Arm64);
+ public static bool IsX64Linux => IsLinux && IsX64;
+ public static bool IsArmLinux => IsLinux && IsArmMac;
}
}
diff --git a/src/Ryujinx.Common/TitleIDs.cs b/src/Ryujinx.Common/TitleIDs.cs
index 72262c6a0..76d873f60 100644
--- a/src/Ryujinx.Common/TitleIDs.cs
+++ b/src/Ryujinx.Common/TitleIDs.cs
@@ -3,7 +3,6 @@ using Ryujinx.Common.Configuration;
using Ryujinx.Common.Helper;
using System;
using System.Linq;
-using System.Runtime.InteropServices;
namespace Ryujinx.Common
{
@@ -30,10 +29,11 @@ namespace Ryujinx.Common
public static readonly string[] GreatMetalTitles =
[
- "010076f0049a2000", // Bayonetta
+ "01009b500007c000", // ARMS
"0100a5c00d162000", // Cuphead
"010023800d64a000", // Deltarune
"01003a30012c0000", // LEGO City Undercover
+ "010048701995e000", // Luigi's Manion 2 HD
"010028600EBDA000", // Mario 3D World
"0100152000022000", // Mario Kart 8 Deluxe
"010075a016a3a000", // Persona 4 Arena Ultimax
@@ -47,11 +47,16 @@ namespace Ryujinx.Common
"01006f8002326000", // Animal Crossings: New Horizons
"01009bf0072d4000", // Captain Toad: Treasure Tracker
"01009510001ca000", // Fast RMX
- "01005CA01580E000", // Persona 5 Royale
+ "01005CA01580E000", // Persona 5 Royal
+ "0100b880154fc000", // Persona 5 The Royal (Japan)
+ "010015100b514000", // Super Mario Bros. Wonder
"0100000000010000", // Super Mario Odyssey
- //Isaac claims it has a issue in level 2, but I am not able to replicate it on my M3. More testing would be appreciated:
- "010015100b514000", // Super Mario Bros. Wonder
+ // Further testing is appreciated, I did not test the entire game:
+ "01007300020fa000", // Astral Chain
+ "010076f0049a2000", // Bayonetta
+ "0100cf5010fec000", // Bayonetta Origins: Cereza and the Lost Demon
+ "0100f4300bf2c000", // New Pokemon Snap
];
public static string GetDiscordGameAsset(string titleId)
@@ -159,15 +164,16 @@ namespace Ryujinx.Common
"0100ba0018500000", // Splatoon 3: Splatfest World Premiere
//NSO Membership games
- "0100ccf019c8c000", // F-ZERO 99
"0100c62011050000", // GB - Nintendo Switch Online
"010012f017576000", // GBA - Nintendo Switch Online
"0100c9a00ece6000", // N64 - Nintendo Switch Online
"0100e0601c632000", // N64 - Nintendo Switch Online 18+
"0100d870045b6000", // NES - Nintendo Switch Online
+ "0100b3c014bda000", // SEGA Genesis - Nintendo Switch Online
+ "01008d300c50c000", // SNES - Nintendo Switch Online
+ "0100ccf019c8c000", // F-ZERO 99
"0100ad9012510000", // PAC-MAN 99
"010040600c5ce000", // Tetris 99
- "01008d300c50c000", // SNES - Nintendo Switch Online
"0100277011f1a000", // Super Mario Bros. 35
//Misc Nintendo 1st party games
@@ -213,6 +219,7 @@ namespace Ryujinx.Common
//Misc Games
"010056e00853a000", // A Hat in Time
"0100fd1014726000", // Baldurs Gate: Dark Alliance
+ "01008c2019598000", // Bluey: The Video Game
"0100c6800b934000", // Brawlhalla
"0100dbf01000a000", // Burnout Paradise Remastered
"0100744001588000", // Cars 3: Driven to Win
diff --git a/src/Ryujinx.Common/Utilities/Rainbow.cs b/src/Ryujinx.Common/Utilities/Rainbow.cs
index a3db94925..eb1c187c4 100644
--- a/src/Ryujinx.Common/Utilities/Rainbow.cs
+++ b/src/Ryujinx.Common/Utilities/Rainbow.cs
@@ -1,4 +1,5 @@
using Gommon;
+using Ryujinx.Common.Helper;
using System;
using System.Drawing;
using System.Threading;
@@ -55,7 +56,7 @@ namespace Ryujinx.Common.Utilities
{
_color = HsbToRgb((_color.GetHue() + Speed) / 360);
- _updatedHandler.Call(_color.ToArgb());
+ _updatedHandler.Call(ref _color);
}
}
@@ -67,13 +68,13 @@ namespace Ryujinx.Common.Utilities
_color = Color.Blue;
}
- public static event Action Updated
+ public static event RefEvent.Handler Updated
{
add => _updatedHandler.Add(value);
remove => _updatedHandler.Remove(value);
}
- private static readonly Event _updatedHandler = new();
+ private static readonly RefEvent _updatedHandler = new();
private static Color HsbToRgb(float hue, float saturation = 1, float brightness = 1)
{
diff --git a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs
index 9d459d062..1949cabdf 100644
--- a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs
+++ b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs
@@ -1,6 +1,5 @@
using ARMeilleure.State;
using Ryujinx.Memory;
-using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
diff --git a/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs b/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs
index 28c78074d..decb0e4e3 100644
--- a/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs
+++ b/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs
@@ -5,7 +5,6 @@ using Ryujinx.Memory.Tracking;
using System;
using System.Buffers;
using System.Collections.Generic;
-using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
diff --git a/src/Ryujinx.Cpu/AppleHv/HvVm.cs b/src/Ryujinx.Cpu/AppleHv/HvVm.cs
index dc115f515..6ad44621b 100644
--- a/src/Ryujinx.Cpu/AppleHv/HvVm.cs
+++ b/src/Ryujinx.Cpu/AppleHv/HvVm.cs
@@ -1,5 +1,4 @@
using Ryujinx.Memory;
-using System;
using System.Runtime.Versioning;
using System.Threading;
diff --git a/src/Ryujinx.Cpu/Jit/JitCpuContext.cs b/src/Ryujinx.Cpu/Jit/JitCpuContext.cs
index 0793f382d..a29def8e8 100644
--- a/src/Ryujinx.Cpu/Jit/JitCpuContext.cs
+++ b/src/Ryujinx.Cpu/Jit/JitCpuContext.cs
@@ -2,7 +2,6 @@ using ARMeilleure.Common;
using ARMeilleure.Memory;
using ARMeilleure.Translation;
using Ryujinx.Cpu.Signal;
-using Ryujinx.Memory;
namespace Ryujinx.Cpu.Jit
{
diff --git a/src/Ryujinx.Cpu/Jit/MemoryManager.cs b/src/Ryujinx.Cpu/Jit/MemoryManager.cs
index 2635a2c7d..9e5d29cca 100644
--- a/src/Ryujinx.Cpu/Jit/MemoryManager.cs
+++ b/src/Ryujinx.Cpu/Jit/MemoryManager.cs
@@ -5,7 +5,6 @@ using Ryujinx.Memory.Tracking;
using System;
using System.Buffers;
using System.Collections.Generic;
-using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
diff --git a/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs b/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs
index c2f7d3f4b..9ae4ca5a9 100644
--- a/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs
+++ b/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs
@@ -8,7 +8,6 @@ using Ryujinx.Memory.Tracking;
using System;
using System.Buffers;
using System.Collections.Generic;
-using System.Linq;
using System.Runtime.CompilerServices;
namespace Ryujinx.Cpu.Jit
diff --git a/src/Ryujinx.Cpu/LightningJit/AarchCompiler.cs b/src/Ryujinx.Cpu/LightningJit/AarchCompiler.cs
index 89e1499c0..68dff624c 100644
--- a/src/Ryujinx.Cpu/LightningJit/AarchCompiler.cs
+++ b/src/Ryujinx.Cpu/LightningJit/AarchCompiler.cs
@@ -3,7 +3,6 @@ using ARMeilleure.Memory;
using Ryujinx.Cpu.LightningJit.Arm32;
using Ryujinx.Cpu.LightningJit.Arm64;
using Ryujinx.Cpu.LightningJit.State;
-using System;
using System.Runtime.InteropServices;
namespace Ryujinx.Cpu.LightningJit
diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/Compiler.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/Compiler.cs
index 0d56f28c9..3121d4f95 100644
--- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/Compiler.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/Compiler.cs
@@ -2,7 +2,6 @@ using ARMeilleure.Common;
using ARMeilleure.Memory;
using Ryujinx.Cpu.LightningJit.CodeGen;
using Ryujinx.Cpu.LightningJit.CodeGen.Arm64;
-using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpCompare.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpCompare.cs
index f5f306099..c1b51750f 100644
--- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpCompare.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpCompare.cs
@@ -1,5 +1,4 @@
using Ryujinx.Cpu.LightningJit.CodeGen;
-using System;
using System.Diagnostics;
namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpMove.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpMove.cs
index 5c1eefacf..2be82ff2a 100644
--- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpMove.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpMove.cs
@@ -1,5 +1,3 @@
-using Ryujinx.Cpu.LightningJit.CodeGen;
-
namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
{
static class InstEmitVfpMove
diff --git a/src/Ryujinx.Cpu/LightningJit/Arm64/SysUtils.cs b/src/Ryujinx.Cpu/LightningJit/Arm64/SysUtils.cs
index 69689a391..a61f35280 100644
--- a/src/Ryujinx.Cpu/LightningJit/Arm64/SysUtils.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Arm64/SysUtils.cs
@@ -1,5 +1,3 @@
-using System.Diagnostics;
-
namespace Ryujinx.Cpu.LightningJit.Arm64
{
static class SysUtils
diff --git a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Compiler.cs b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Compiler.cs
index 2900cbda4..1e087591c 100644
--- a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Compiler.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Compiler.cs
@@ -3,7 +3,6 @@ using ARMeilleure.Memory;
using Ryujinx.Cpu.LightningJit.CodeGen;
using Ryujinx.Cpu.LightningJit.CodeGen.Arm64;
using Ryujinx.Cpu.LightningJit.Graph;
-using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs
index 5849401ab..ccf8ad964 100644
--- a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs
@@ -1,4 +1,6 @@
using ARMeilleure.Memory;
+using Humanizer;
+using Ryujinx.Common.Logging;
using Ryujinx.Memory;
using System;
using System.Collections.Generic;
@@ -15,9 +17,8 @@ namespace Ryujinx.Cpu.LightningJit.Cache
private static readonly int _pageMask = _pageSize - 1;
private const int CodeAlignment = 4; // Bytes.
- private const int CacheSize = 2047 * 1024 * 1024;
+ private const int CacheSize = 256 * 1024 * 1024;
- private static ReservedRegion _jitRegion;
private static JitCacheInvalidation _jitCacheInvalidator;
private static CacheMemoryAllocator _cacheAllocator;
@@ -26,6 +27,8 @@ namespace Ryujinx.Cpu.LightningJit.Cache
private static readonly Lock _lock = new();
private static bool _initialized;
+ private static readonly List _jitRegions = new();
+ private static int _activeRegionIndex = 0;
[SupportedOSPlatform("windows")]
[LibraryImport("kernel32.dll", SetLastError = true)]
@@ -45,7 +48,9 @@ namespace Ryujinx.Cpu.LightningJit.Cache
return;
}
- _jitRegion = new ReservedRegion(allocator, CacheSize);
+ ReservedRegion firstRegion = new(allocator, CacheSize);
+ _jitRegions.Add(firstRegion);
+ _activeRegionIndex = 0;
if (!OperatingSystem.IsWindows() && !OperatingSystem.IsMacOS())
{
@@ -65,8 +70,8 @@ namespace Ryujinx.Cpu.LightningJit.Cache
Debug.Assert(_initialized);
int funcOffset = Allocate(code.Length);
-
- nint funcPtr = _jitRegion.Pointer + funcOffset;
+ ReservedRegion targetRegion = _jitRegions[_activeRegionIndex];
+ nint funcPtr = targetRegion.Pointer + funcOffset;
if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
@@ -80,18 +85,11 @@ namespace Ryujinx.Cpu.LightningJit.Cache
}
else
{
- ReprotectAsWritable(funcOffset, code.Length);
- code.CopyTo(new Span((void*)funcPtr, code.Length));
- ReprotectAsExecutable(funcOffset, code.Length);
+ ReprotectAsWritable(targetRegion, funcOffset, code.Length);
+ Marshal.Copy(code.ToArray(), 0, funcPtr, code.Length);
+ ReprotectAsExecutable(targetRegion, funcOffset, code.Length);
- if (OperatingSystem.IsWindows() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
- {
- FlushInstructionCache(Process.GetCurrentProcess().Handle, funcPtr, (nuint)code.Length);
- }
- else
- {
- _jitCacheInvalidator?.Invalidate(funcPtr, (ulong)code.Length);
- }
+ _jitCacheInvalidator?.Invalidate(funcPtr, (ulong)code.Length);
}
Add(funcOffset, code.Length);
@@ -106,50 +104,80 @@ namespace Ryujinx.Cpu.LightningJit.Cache
{
Debug.Assert(_initialized);
- int funcOffset = (int)(pointer.ToInt64() - _jitRegion.Pointer.ToInt64());
-
- if (TryFind(funcOffset, out CacheEntry entry, out int entryIndex) && entry.Offset == funcOffset)
+ foreach (ReservedRegion region in _jitRegions)
{
- _cacheAllocator.Free(funcOffset, AlignCodeSize(entry.Size));
- _cacheEntries.RemoveAt(entryIndex);
+ if (pointer.ToInt64() < region.Pointer.ToInt64() ||
+ pointer.ToInt64() >= (region.Pointer + CacheSize).ToInt64())
+ {
+ continue;
+ }
+
+ int funcOffset = (int)(pointer.ToInt64() - region.Pointer.ToInt64());
+
+ if (TryFind(funcOffset, out CacheEntry entry, out int entryIndex) && entry.Offset == funcOffset)
+ {
+ _cacheAllocator.Free(funcOffset, AlignCodeSize(entry.Size));
+ _cacheEntries.RemoveAt(entryIndex);
+ }
+
+ return;
}
}
}
- private static void ReprotectAsWritable(int offset, int size)
+ private static void ReprotectAsWritable(ReservedRegion region, int offset, int size)
{
int endOffs = offset + size;
-
int regionStart = offset & ~_pageMask;
int regionEnd = (endOffs + _pageMask) & ~_pageMask;
- _jitRegion.Block.MapAsRwx((ulong)regionStart, (ulong)(regionEnd - regionStart));
+ region.Block.MapAsRwx((ulong)regionStart, (ulong)(regionEnd - regionStart));
}
- private static void ReprotectAsExecutable(int offset, int size)
+ private static void ReprotectAsExecutable(ReservedRegion region, int offset, int size)
{
int endOffs = offset + size;
-
int regionStart = offset & ~_pageMask;
int regionEnd = (endOffs + _pageMask) & ~_pageMask;
- _jitRegion.Block.MapAsRx((ulong)regionStart, (ulong)(regionEnd - regionStart));
+ region.Block.MapAsRx((ulong)regionStart, (ulong)(regionEnd - regionStart));
}
private static int Allocate(int codeSize)
{
codeSize = AlignCodeSize(codeSize);
- int allocOffset = _cacheAllocator.Allocate(codeSize);
-
- if (allocOffset < 0)
+ for (int i = _activeRegionIndex; i < _jitRegions.Count; i++)
{
- throw new OutOfMemoryException("JIT Cache exhausted.");
+ int allocOffset = _cacheAllocator.Allocate(codeSize);
+
+ if (allocOffset >= 0)
+ {
+ _jitRegions[i].ExpandIfNeeded((ulong)allocOffset + (ulong)codeSize);
+ _activeRegionIndex = i;
+ return allocOffset;
+ }
}
- _jitRegion.ExpandIfNeeded((ulong)allocOffset + (ulong)codeSize);
+ int exhaustedRegion = _activeRegionIndex;
+ ReservedRegion newRegion = new(_jitRegions[0].Allocator, CacheSize);
+ _jitRegions.Add(newRegion);
+ _activeRegionIndex = _jitRegions.Count - 1;
+
+ int newRegionNumber = _activeRegionIndex;
- return allocOffset;
+ Logger.Warning?.Print(LogClass.Cpu, $"JIT Cache Region {exhaustedRegion} exhausted, creating new Cache Region {newRegionNumber} ({((newRegionNumber + 1) * CacheSize).Bytes()} Total Allocation).");
+
+ _cacheAllocator = new CacheMemoryAllocator(CacheSize);
+
+ int allocOffsetNew = _cacheAllocator.Allocate(codeSize);
+ if (allocOffsetNew < 0)
+ {
+ throw new OutOfMemoryException("Failed to allocate in new Cache Region!");
+ }
+
+ newRegion.ExpandIfNeeded((ulong)allocOffsetNew + (ulong)codeSize);
+ return allocOffsetNew;
}
private static int AlignCodeSize(int codeSize)
diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/JitCacheInvalidation.cs b/src/Ryujinx.Cpu/LightningJit/Cache/JitCacheInvalidation.cs
index e851327d4..ae71aa1d3 100644
--- a/src/Ryujinx.Cpu/LightningJit/Cache/JitCacheInvalidation.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Cache/JitCacheInvalidation.cs
@@ -1,5 +1,4 @@
using ARMeilleure.Memory;
-using System;
using System.Runtime.InteropServices;
namespace Ryujinx.Cpu.LightningJit.Cache
diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/JitSupportDarwin.cs b/src/Ryujinx.Cpu/LightningJit/Cache/JitSupportDarwin.cs
index ed02a9c28..e0de1e7e0 100644
--- a/src/Ryujinx.Cpu/LightningJit/Cache/JitSupportDarwin.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Cache/JitSupportDarwin.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs b/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs
index 1bbf70182..65d297c28 100644
--- a/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs
@@ -12,7 +12,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
{
private const int CodeAlignment = 4; // Bytes.
private const int SharedCacheSize = 2047 * 1024 * 1024;
- private const int LocalCacheSize = 128 * 1024 * 1024;
+ private const int LocalCacheSize = 256 * 1024 * 1024;
// How many calls to the same function we allow until we pad the shared cache to force the function to become available there
// and allow the guest to take the fast path.
diff --git a/src/Ryujinx.Cpu/LightningJit/CodeGen/Arm64/StackWalker.cs b/src/Ryujinx.Cpu/LightningJit/CodeGen/Arm64/StackWalker.cs
index 1432c4598..491132408 100644
--- a/src/Ryujinx.Cpu/LightningJit/CodeGen/Arm64/StackWalker.cs
+++ b/src/Ryujinx.Cpu/LightningJit/CodeGen/Arm64/StackWalker.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
diff --git a/src/Ryujinx.Cpu/LightningJit/IStackWalker.cs b/src/Ryujinx.Cpu/LightningJit/IStackWalker.cs
index 375c09d26..f5bbc65d3 100644
--- a/src/Ryujinx.Cpu/LightningJit/IStackWalker.cs
+++ b/src/Ryujinx.Cpu/LightningJit/IStackWalker.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
namespace Ryujinx.Cpu.LightningJit
diff --git a/src/Ryujinx.Cpu/LightningJit/TranslatedFunction.cs b/src/Ryujinx.Cpu/LightningJit/TranslatedFunction.cs
index df0f52b8c..70cdd0bfe 100644
--- a/src/Ryujinx.Cpu/LightningJit/TranslatedFunction.cs
+++ b/src/Ryujinx.Cpu/LightningJit/TranslatedFunction.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace Ryujinx.Cpu.LightningJit
{
class TranslatedFunction
diff --git a/src/Ryujinx.Cpu/LightningJit/Translator.cs b/src/Ryujinx.Cpu/LightningJit/Translator.cs
index cb3957490..5f3fe8783 100644
--- a/src/Ryujinx.Cpu/LightningJit/Translator.cs
+++ b/src/Ryujinx.Cpu/LightningJit/Translator.cs
@@ -5,7 +5,6 @@ using Ryujinx.Cpu.LightningJit.Cache;
using Ryujinx.Cpu.LightningJit.CodeGen.Arm64;
using Ryujinx.Cpu.LightningJit.State;
using Ryujinx.Cpu.Signal;
-using Ryujinx.Memory;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
diff --git a/src/Ryujinx.Cpu/Signal/WindowsSignalHandlerRegistration.cs b/src/Ryujinx.Cpu/Signal/WindowsSignalHandlerRegistration.cs
index 7ac15b816..8afaeef0f 100644
--- a/src/Ryujinx.Cpu/Signal/WindowsSignalHandlerRegistration.cs
+++ b/src/Ryujinx.Cpu/Signal/WindowsSignalHandlerRegistration.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.InteropServices;
namespace Ryujinx.Cpu.Signal
diff --git a/src/Ryujinx.Graphics.Device/ISynchronizationManager.cs b/src/Ryujinx.Graphics.Device/ISynchronizationManager.cs
index 2a8d1d9b7..5c2b6a2e3 100644
--- a/src/Ryujinx.Graphics.Device/ISynchronizationManager.cs
+++ b/src/Ryujinx.Graphics.Device/ISynchronizationManager.cs
@@ -1,6 +1,4 @@
-using Ryujinx.Common.Logging;
using System;
-using System.Threading;
namespace Ryujinx.Graphics.Device
{
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs
index c2276480b..5d420a140 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs
@@ -1,6 +1,5 @@
using Ryujinx.Common;
using Ryujinx.Graphics.GAL;
-using System;
using System.Collections.Generic;
namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs
index d1a1cc35c..9383d3a3f 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs
@@ -1,4 +1,3 @@
-using Ryujinx.Graphics.Device;
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs
index 17ed57d96..fc3b64c03 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs
@@ -4,7 +4,6 @@ using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Graphics.Shader;
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Gpu.Image
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
index 0bd715d89..6efb7f334 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
@@ -1,5 +1,4 @@
using Ryujinx.Common.Memory;
-using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Memory;
using Ryujinx.Memory.Range;
using System;
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
index d9dd7f1d9..8a78b99e0 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
@@ -7,7 +7,6 @@ using Ryujinx.Memory;
using Ryujinx.Memory.Range;
using Ryujinx.Memory.Tracking;
using System;
-using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs
index beaad0579..b6ece6f83 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/SupportBufferUpdater.cs
@@ -1,6 +1,5 @@
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Shader;
-using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs
index ef314501d..4683a5d0c 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs
@@ -2,7 +2,6 @@ using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Engine;
using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Shader;
-using System;
using System.Linq;
namespace Ryujinx.Graphics.Gpu.Shader
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index e7e0ba154..476ae3d82 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -1,4 +1,3 @@
-using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.GAL;
diff --git a/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs b/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs
index b68a64a47..d51b0ef60 100644
--- a/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs
@@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
}
using ManualResetEvent waitEvent = new(false);
- SyncpointWaiterHandle info = _syncpoints[id].RegisterCallback(threshold, (x) => waitEvent.Set());
+ SyncpointWaiterHandle info = _syncpoints[id].RegisterCallback(threshold, _ => waitEvent.Set());
if (info == null)
{
@@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
bool signaled = waitEvent.WaitOne(timeout);
- if (!signaled && info != null)
+ if (!signaled)
{
Logger.Error?.Print(LogClass.Gpu, $"Wait on syncpoint {id} for threshold {threshold} took more than {timeout.TotalMilliseconds}ms, resuming execution...");
diff --git a/src/Ryujinx.Graphics.Metal/EnumConversion.cs b/src/Ryujinx.Graphics.Metal/EnumConversion.cs
index e498546e8..7cfb5cbd4 100644
--- a/src/Ryujinx.Graphics.Metal/EnumConversion.cs
+++ b/src/Ryujinx.Graphics.Metal/EnumConversion.cs
@@ -1,7 +1,6 @@
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.GAL;
using SharpMetal.Metal;
-using System;
using System.Runtime.Versioning;
namespace Ryujinx.Graphics.Metal
diff --git a/src/Ryujinx.Graphics.Metal/HardwareInfo.cs b/src/Ryujinx.Graphics.Metal/HardwareInfo.cs
index 413fabf09..f6a132f09 100644
--- a/src/Ryujinx.Graphics.Metal/HardwareInfo.cs
+++ b/src/Ryujinx.Graphics.Metal/HardwareInfo.cs
@@ -76,7 +76,7 @@ namespace Ryujinx.Graphics.Metal
return model;
}
- return "";
+ return string.Empty;
}
}
}
diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs
index b5ef710b1..098622b2a 100644
--- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs
+++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
{
struct AVCodec
diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs
index d745e9f04..256ccd0a8 100644
--- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs
+++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
{
struct AVCodec501
diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs
index 1de0a13e4..96c1a0f67 100644
--- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs
+++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs
@@ -1,5 +1,4 @@
using Ryujinx.Common.Memory;
-using System;
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
{
diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVFrame.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVFrame.cs
index 97c30c718..46b1e06a7 100644
--- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVFrame.cs
+++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVFrame.cs
@@ -1,5 +1,4 @@
using Ryujinx.Common.Memory;
-using System;
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
{
diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFCodec.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFCodec.cs
index 95926298c..09bcc9c31 100644
--- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFCodec.cs
+++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFCodec.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
{
struct FFCodec where T : struct
diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFCodecLegacy.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFCodecLegacy.cs
index 873d2518a..ee0db4730 100644
--- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFCodecLegacy.cs
+++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/FFCodecLegacy.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
{
struct FFCodecLegacy where T : struct
diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Surface.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Surface.cs
index c13cfe1aa..023b470f2 100644
--- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Surface.cs
+++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Surface.cs
@@ -1,6 +1,5 @@
using Ryujinx.Graphics.Nvdec.FFmpeg.Native;
using Ryujinx.Graphics.Video;
-using System;
namespace Ryujinx.Graphics.Nvdec.FFmpeg
{
diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
index d9bda185b..6bab536d1 100644
--- a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
+++ b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Surface.cs
@@ -1,6 +1,5 @@
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.Video;
-using System;
using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Nvdec.Vp9.Types
diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/AreaScalingFilter.cs b/src/Ryujinx.Graphics.OpenGL/Effects/AreaScalingFilter.cs
index 927f4cbfe..c95463e37 100644
--- a/src/Ryujinx.Graphics.OpenGL/Effects/AreaScalingFilter.cs
+++ b/src/Ryujinx.Graphics.OpenGL/Effects/AreaScalingFilter.cs
@@ -2,7 +2,6 @@ using OpenTK.Graphics.OpenGL;
using Ryujinx.Common;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.OpenGL.Image;
-using System;
using static Ryujinx.Graphics.OpenGL.Effects.ShaderHelper;
namespace Ryujinx.Graphics.OpenGL.Effects
diff --git a/src/Ryujinx.Graphics.OpenGL/Helper/GLXHelper.cs b/src/Ryujinx.Graphics.OpenGL/Helper/GLXHelper.cs
index b722bbf04..d7ca560a1 100644
--- a/src/Ryujinx.Graphics.OpenGL/Helper/GLXHelper.cs
+++ b/src/Ryujinx.Graphics.OpenGL/Helper/GLXHelper.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
diff --git a/src/Ryujinx.Graphics.OpenGL/Helper/WGLHelper.cs b/src/Ryujinx.Graphics.OpenGL/Helper/WGLHelper.cs
index 7072bbd9f..54516c81e 100644
--- a/src/Ryujinx.Graphics.OpenGL/Helper/WGLHelper.cs
+++ b/src/Ryujinx.Graphics.OpenGL/Helper/WGLHelper.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
diff --git a/src/Ryujinx.Graphics.OpenGL/IOpenGLContext.cs b/src/Ryujinx.Graphics.OpenGL/IOpenGLContext.cs
index 525418d74..5443465ea 100644
--- a/src/Ryujinx.Graphics.OpenGL/IOpenGLContext.cs
+++ b/src/Ryujinx.Graphics.OpenGL/IOpenGLContext.cs
@@ -1,4 +1,3 @@
-using Ryujinx.Graphics.OpenGL.Helper;
using System;
namespace Ryujinx.Graphics.OpenGL
diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs
index c779f5e8d..a9464834a 100644
--- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Declarations.cs
@@ -1,5 +1,4 @@
using Ryujinx.Common;
-using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.StructuredIr;
using Ryujinx.Graphics.Shader.Translation;
@@ -218,7 +217,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
foreach (MemoryDefinition memory in memories)
{
- string arraySize = "";
+ string arraySize = string.Empty;
if ((memory.Type & AggregateType.Array) != 0)
{
arraySize = $"[{memory.ArrayLength}]";
@@ -240,7 +239,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
BufferDefinition buffer = buffers[i];
bool needsPadding = buffer.Layout == BufferLayout.Std140;
- string fsiSuffix = !constant && fsi ? " [[raster_order_group(0)]]" : "";
+ string fsiSuffix = !constant && fsi ? " [[raster_order_group(0)]]" : string.Empty;
bufferDec[i] = $"{addressSpace} {Defaults.StructPrefix}_{buffer.Name}* {buffer.Name}{fsiSuffix};";
@@ -257,7 +256,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
type &= ~AggregateType.Array;
string typeName = GetVarTypeName(type);
- string arraySuffix = "";
+ string arraySuffix = string.Empty;
if (field.Type.HasFlag(AggregateType.Array))
{
@@ -353,7 +352,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
imageTypeName = $"array<{imageTypeName}, {image.ArrayLength}>";
}
- string fsiSuffix = fsi ? " [[raster_order_group(0)]]" : "";
+ string fsiSuffix = fsi ? " [[raster_order_group(0)]]" : string.Empty;
imageDec[i] = $"{imageTypeName} {image.Name}{fsiSuffix};";
}
@@ -454,7 +453,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
IoVariable.VertexIndex => "[[vertex_id]]",
// IoVariable.PointCoord => "[[point_coord]]",
IoVariable.UserDefined => context.Definitions.Stage == ShaderStage.Fragment ? $"[[user(loc{ioDefinition.Location})]]" : $"[[attribute({ioDefinition.Location})]]",
- _ => ""
+ _ => string.Empty
};
context.AppendLine($"{type} {name} {iq}{suffix};");
@@ -545,7 +544,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
IoVariable.FragmentOutputColor => $"[[color({ioDefinition.Location})]]",
IoVariable.FragmentOutputDepth => "[[depth(any)]]",
IoVariable.ClipDistance => $"[[clip_distance]][{Defaults.TotalClipDistances}]",
- _ => ""
+ _ => string.Empty
};
context.AppendLine($"{type} {name} {suffix};");
diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs
index b3a995c6a..a84a75e4f 100644
--- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs
@@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
inputsCount--;
}
- string fieldName = "";
+ string fieldName = string.Empty;
switch (storageKind)
{
case StorageKind.ConstantBuffer:
@@ -140,7 +140,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
}
}
varName += fieldName;
- varName += fieldHasPadding ? ".x" : "";
+ varName += fieldHasPadding ? ".x" : string.Empty;
if (isStore)
{
@@ -434,7 +434,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
string prefix = intCoords ? "uint" : "float";
- return prefix + (count > 1 ? count : "") + "(" + coords + ")";
+ return prefix + (count > 1 ? count : string.Empty) + "(" + coords + ")";
}
Append(AssemblePVector(pCount));
@@ -504,7 +504,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
}
texCallBuilder.Append(')');
- texCallBuilder.Append(colorIsVector ? GetMaskMultiDest(texOp.Index) : "");
+ texCallBuilder.Append(colorIsVector ? GetMaskMultiDest(texOp.Index) : string.Empty);
return texCallBuilder.ToString();
}
@@ -558,7 +558,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
{
if (mask == 0x0)
{
- return "";
+ return string.Empty;
}
string swizzle = ".";
diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs
index bc38ea26b..8ca24fcd3 100644
--- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/MslGenerator.cs
@@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
if (parameters.Definitions.Stage is not (ShaderStage.Vertex or ShaderStage.Fragment or ShaderStage.Compute))
{
Logger.Warning?.Print(LogClass.Gpu, $"Attempted to generate unsupported shader type {parameters.Definitions.Stage}!");
- return "";
+ return string.Empty;
}
CodeGenContext context = new(info, parameters);
diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs
index 5abbf1fa8..4fe214778 100644
--- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs
@@ -4,7 +4,6 @@ using Ryujinx.Graphics.Shader.Translation;
using Spv.Generator;
using System;
using System.Collections.Generic;
-using static Spv.Specification;
using Instruction = Spv.Generator.Instruction;
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
diff --git a/src/Ryujinx.Graphics.Shader/SamplerType.cs b/src/Ryujinx.Graphics.Shader/SamplerType.cs
index 20352d13e..f81d512fa 100644
--- a/src/Ryujinx.Graphics.Shader/SamplerType.cs
+++ b/src/Ryujinx.Graphics.Shader/SamplerType.cs
@@ -199,7 +199,7 @@ namespace Ryujinx.Graphics.Shader
_ => "float"
};
- return $"{typeName}<{format}{(image ? ", access::read_write" : "")}>";
+ return $"{typeName}<{format}{(image ? ", access::read_write" : string.Empty)}>";
}
}
}
diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs
index 5d46ab498..3f2e4991f 100644
--- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs
+++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs
@@ -1,5 +1,4 @@
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
-using Ryujinx.Graphics.Shader.Translation;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Ryujinx.Graphics.Video/Plane.cs b/src/Ryujinx.Graphics.Video/Plane.cs
index 4e4e65b32..338de1644 100644
--- a/src/Ryujinx.Graphics.Video/Plane.cs
+++ b/src/Ryujinx.Graphics.Video/Plane.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace Ryujinx.Graphics.Video
{
public readonly record struct Plane(nint Pointer, int Length);
diff --git a/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs b/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs
index 5e3bf39db..406f33304 100644
--- a/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs
+++ b/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs
@@ -3,7 +3,6 @@ using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Shader;
using Silk.NET.Vulkan;
using System;
-using System.Buffers;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs
index ba8b3e499..191811593 100644
--- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs
+++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs
@@ -11,7 +11,6 @@ using System.Runtime.InteropServices;
using BlendOp = Silk.NET.Vulkan.BlendOp;
using Buffer = Silk.NET.Vulkan.Buffer;
using CompareOp = Ryujinx.Graphics.GAL.CompareOp;
-using Format = Ryujinx.Graphics.GAL.Format;
using FrontFace = Ryujinx.Graphics.GAL.FrontFace;
using IndexType = Ryujinx.Graphics.GAL.IndexType;
using PolygonMode = Ryujinx.Graphics.GAL.PolygonMode;
diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineHelperShader.cs b/src/Ryujinx.Graphics.Vulkan/PipelineHelperShader.cs
index dfbf19013..b9074dfdb 100644
--- a/src/Ryujinx.Graphics.Vulkan/PipelineHelperShader.cs
+++ b/src/Ryujinx.Graphics.Vulkan/PipelineHelperShader.cs
@@ -1,5 +1,4 @@
using Silk.NET.Vulkan;
-using VkFormat = Silk.NET.Vulkan.Format;
namespace Ryujinx.Graphics.Vulkan
{
diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineLayoutFactory.cs b/src/Ryujinx.Graphics.Vulkan/PipelineLayoutFactory.cs
index 1cf569290..612a8b25d 100644
--- a/src/Ryujinx.Graphics.Vulkan/PipelineLayoutFactory.cs
+++ b/src/Ryujinx.Graphics.Vulkan/PipelineLayoutFactory.cs
@@ -1,7 +1,5 @@
-using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using Silk.NET.Vulkan;
-using System;
using System.Collections.ObjectModel;
namespace Ryujinx.Graphics.Vulkan
diff --git a/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueue.cs b/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueue.cs
index 8dd94a42d..24b0e7787 100644
--- a/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueue.cs
+++ b/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueue.cs
@@ -2,7 +2,6 @@ using Ryujinx.Graphics.GAL;
using Silk.NET.Vulkan;
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Threading;
namespace Ryujinx.Graphics.Vulkan.Queries
diff --git a/src/Ryujinx.Graphics.Vulkan/TextureBuffer.cs b/src/Ryujinx.Graphics.Vulkan/TextureBuffer.cs
index 073eee2ca..8a2cd2102 100644
--- a/src/Ryujinx.Graphics.Vulkan/TextureBuffer.cs
+++ b/src/Ryujinx.Graphics.Vulkan/TextureBuffer.cs
@@ -2,8 +2,6 @@ using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using Silk.NET.Vulkan;
using System;
-using System.Collections.Generic;
-using Format = Ryujinx.Graphics.GAL.Format;
using VkFormat = Silk.NET.Vulkan.Format;
namespace Ryujinx.Graphics.Vulkan
diff --git a/src/Ryujinx.Graphics.Vulkan/Vendor.cs b/src/Ryujinx.Graphics.Vulkan/Vendor.cs
index 6a2a76a88..550ba0221 100644
--- a/src/Ryujinx.Graphics.Vulkan/Vendor.cs
+++ b/src/Ryujinx.Graphics.Vulkan/Vendor.cs
@@ -1,5 +1,4 @@
using Silk.NET.Vulkan;
-using System.Text.RegularExpressions;
namespace Ryujinx.Graphics.Vulkan
{
@@ -16,14 +15,8 @@ namespace Ryujinx.Graphics.Vulkan
Unknown,
}
- static partial class VendorUtils
+ static class VendorUtils
{
- [GeneratedRegex("Radeon (((HD|R(5|7|9|X)) )?((M?[2-6]\\d{2}(\\D|$))|([7-8]\\d{3}(\\D|$))|Fury|Nano))|(Pro Duo)")]
- public static partial Regex AmdGcnRegex();
-
- [GeneratedRegex("NVIDIA GeForce (R|G)?TX? (\\d{3}\\d?)M?")]
- public static partial Regex NvidiaConsumerClassRegex();
-
public static Vendor FromId(uint id)
{
return id switch
diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanException.cs b/src/Ryujinx.Graphics.Vulkan/VulkanException.cs
index e203a3a21..5d67ab838 100644
--- a/src/Ryujinx.Graphics.Vulkan/VulkanException.cs
+++ b/src/Ryujinx.Graphics.Vulkan/VulkanException.cs
@@ -1,6 +1,5 @@
using Silk.NET.Vulkan;
using System;
-using System.Runtime.Serialization;
namespace Ryujinx.Graphics.Vulkan
{
diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs
index 986baf91b..e90606dcf 100644
--- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs
+++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs
@@ -1,5 +1,6 @@
using Gommon;
using Ryujinx.Common.Configuration;
+using Ryujinx.Common.Helper;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Shader;
@@ -375,11 +376,11 @@ namespace Ryujinx.Graphics.Vulkan
GpuVersion = $"Vulkan v{ParseStandardVulkanVersion(properties.ApiVersion)}, Driver v{ParseDriverVersion(ref properties)}";
- IsAmdGcn = !IsMoltenVk && Vendor == Vendor.Amd && VendorUtils.AmdGcnRegex().IsMatch(GpuRenderer);
+ IsAmdGcn = !IsMoltenVk && Vendor == Vendor.Amd && Patterns.AmdGcn.IsMatch(GpuRenderer);
if (Vendor == Vendor.Nvidia)
{
- Match match = VendorUtils.NvidiaConsumerClassRegex().Match(GpuRenderer);
+ Match match = Patterns.NvidiaConsumerClass.Match(GpuRenderer);
if (match != null && int.TryParse(match.Groups[2].Value, out int gpuNumber))
{
diff --git a/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs b/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs
index 17aab8105..23068bf72 100644
--- a/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs
+++ b/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs
@@ -7,7 +7,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
-using System.Runtime.Serialization;
using System.Text;
namespace Ryujinx.HLE.Exceptions
diff --git a/src/Ryujinx.HLE/HLEConfiguration.cs b/src/Ryujinx.HLE/HLEConfiguration.cs
index 8ac76508f..0b7ae3974 100644
--- a/src/Ryujinx.HLE/HLEConfiguration.cs
+++ b/src/Ryujinx.HLE/HLEConfiguration.cs
@@ -192,6 +192,7 @@ namespace Ryujinx.HLE
///
/// The desired hacky workarounds.
///
+ /// This cannot be changed after instantiation.
public EnabledDirtyHack[] Hacks { internal get; set; }
public HLEConfiguration(VirtualFileSystem virtualFileSystem,
diff --git a/src/Ryujinx.HLE/HOS/Applets/AppletManager.cs b/src/Ryujinx.HLE/HOS/Applets/AppletManager.cs
index 5895c67bb..5bda957bc 100644
--- a/src/Ryujinx.HLE/HOS/Applets/AppletManager.cs
+++ b/src/Ryujinx.HLE/HOS/Applets/AppletManager.cs
@@ -4,8 +4,6 @@ using Ryujinx.HLE.HOS.Applets.Cabinet;
using Ryujinx.HLE.HOS.Applets.Dummy;
using Ryujinx.HLE.HOS.Applets.Error;
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
-using System;
-using System.Collections.Generic;
namespace Ryujinx.HLE.HOS.Applets
{
diff --git a/src/Ryujinx.HLE/HOS/Applets/Dummy/DummyApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Dummy/DummyApplet.cs
index 6b16aee7b..a581e1864 100644
--- a/src/Ryujinx.HLE/HOS/Applets/Dummy/DummyApplet.cs
+++ b/src/Ryujinx.HLE/HOS/Applets/Dummy/DummyApplet.cs
@@ -1,10 +1,8 @@
-using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
-using Ryujinx.HLE.HOS.Applets;
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
using System;
using System.IO;
-using System.Runtime.InteropServices;
+
namespace Ryujinx.HLE.HOS.Applets.Dummy
{
internal class DummyApplet : IApplet
diff --git a/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs
index 54b5721c1..47bfadc4c 100644
--- a/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs
+++ b/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs
@@ -5,6 +5,7 @@ using LibHac.FsSystem;
using LibHac.Ncm;
using LibHac.Tools.FsSystem;
using LibHac.Tools.FsSystem.NcaUtils;
+using Ryujinx.Common.Helper;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
using Ryujinx.HLE.HOS.SystemState;
@@ -14,7 +15,6 @@ using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
-using System.Text.RegularExpressions;
namespace Ryujinx.HLE.HOS.Applets.Error
{
@@ -30,9 +30,6 @@ namespace Ryujinx.HLE.HOS.Applets.Error
public event EventHandler AppletStateChanged;
- [GeneratedRegex(@"[^\u0000\u0009\u000A\u000D\u0020-\uFFFF]..")]
- private static partial Regex CleanTextRegex();
-
public ErrorApplet(Horizon horizon)
{
_horizon = horizon;
@@ -107,7 +104,7 @@ namespace Ryujinx.HLE.HOS.Applets.Error
private static string CleanText(string value)
{
- return CleanTextRegex().Replace(value, string.Empty).Replace("\0", string.Empty);
+ return Patterns.CleanText.Replace(value, string.Empty).Replace("\0", string.Empty);
}
private string GetMessageText(uint module, uint description, string key)
@@ -161,13 +158,15 @@ namespace Ryujinx.HLE.HOS.Applets.Error
string[] buttons = GetButtonsText(module, description, "DlgBtn");
- bool showDetails = _horizon.Device.UIHandler.DisplayErrorAppletDialog($"Error Code: {module}-{description:0000}", "\n" + message, buttons);
+ (uint Module, uint Description) errorCodeTuple = (module, uint.Parse(description.ToString("0000")));
+
+ bool showDetails = _horizon.Device.UIHandler.DisplayErrorAppletDialog($"Error Code: {module}-{description:0000}", "\n" + message, buttons, errorCodeTuple);
if (showDetails)
{
message = GetMessageText(module, description, "FlvMsg");
buttons = GetButtonsText(module, description, "FlvBtn");
- _horizon.Device.UIHandler.DisplayErrorAppletDialog($"Details: {module}-{description:0000}", "\n" + message, buttons);
+ _horizon.Device.UIHandler.DisplayErrorAppletDialog($"Details: {module}-{description:0000}", "\n" + message, buttons, errorCodeTuple);
}
}
diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/CJKCharacterValidation.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/CJKCharacterValidation.cs
deleted file mode 100644
index 6134a3cdd..000000000
--- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/CJKCharacterValidation.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.Text.RegularExpressions;
-
-namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
-{
- public static partial class CJKCharacterValidation
- {
- public static bool IsCJK(char value)
- {
- Regex regex = CJKRegex();
-
- return regex.IsMatch(value.ToString());
- }
-
- [GeneratedRegex("\\p{IsHangulJamo}|\\p{IsCJKRadicalsSupplement}|\\p{IsCJKSymbolsandPunctuation}|\\p{IsEnclosedCJKLettersandMonths}|\\p{IsCJKCompatibility}|\\p{IsCJKUnifiedIdeographsExtensionA}|\\p{IsCJKUnifiedIdeographs}|\\p{IsHangulSyllables}|\\p{IsCJKCompatibilityForms}")]
- private static partial Regex CJKRegex();
- }
-}
diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/CharacterValidation.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/CharacterValidation.cs
new file mode 100644
index 000000000..5ce8204cb
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/CharacterValidation.cs
@@ -0,0 +1,10 @@
+using Ryujinx.Common.Helper;
+
+namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
+{
+ public static class CharacterValidation
+ {
+ public static bool IsNumeric(char value) => Patterns.Numeric.IsMatch(value.ToString());
+ public static bool IsCJK(char value) => Patterns.CJK.IsMatch(value.ToString());
+ }
+}
diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/NumericCharacterValidation.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/NumericCharacterValidation.cs
deleted file mode 100644
index d72b68eae..000000000
--- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/NumericCharacterValidation.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.Text.RegularExpressions;
-
-namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
-{
- public static partial class NumericCharacterValidation
- {
- public static bool IsNumeric(char value)
- {
- Regex regex = NumericRegex();
-
- return regex.IsMatch(value.ToString());
- }
-
- [GeneratedRegex("[0-9]|.")]
- private static partial Regex NumericRegex();
- }
-}
diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs
index 4d4ef8996..11f527285 100644
--- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs
+++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs
@@ -5,7 +5,6 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
-using System.Runtime.InteropServices;
using System.Threading;
namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
diff --git a/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs b/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs
index 95b6167f3..08d929bf0 100644
--- a/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs
+++ b/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs
@@ -20,6 +20,7 @@ namespace Ryujinx.HLE.HOS
private readonly string _titleIdText;
private readonly string _displayVersion;
private readonly bool _diskCacheEnabled;
+ private readonly string _diskCacheSelector;
private readonly ulong _codeAddress;
private readonly ulong _codeSize;
@@ -31,6 +32,7 @@ namespace Ryujinx.HLE.HOS
string titleIdText,
string displayVersion,
bool diskCacheEnabled,
+ string diskCacheSelector,
ulong codeAddress,
ulong codeSize)
{
@@ -39,6 +41,7 @@ namespace Ryujinx.HLE.HOS
_titleIdText = titleIdText;
_displayVersion = displayVersion;
_diskCacheEnabled = diskCacheEnabled;
+ _diskCacheSelector = diskCacheSelector;
_codeAddress = codeAddress;
_codeSize = codeSize;
}
@@ -114,7 +117,7 @@ namespace Ryujinx.HLE.HOS
}
}
- DiskCacheLoadState = processContext.Initialize(_titleIdText, _displayVersion, _diskCacheEnabled, _codeAddress, _codeSize, "default"); //Ready for exefs profiles
+ DiskCacheLoadState = processContext.Initialize(_titleIdText, _displayVersion, _diskCacheEnabled, _codeAddress, _codeSize, _diskCacheSelector ?? "default");
return processContext;
}
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs b/src/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs
index e036f366b..25c663e9a 100644
--- a/src/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs
+++ b/src/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs
@@ -2,7 +2,6 @@ using Ryujinx.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.Horizon.Common;
using System.Collections.Generic;
-using System.Threading;
namespace Ryujinx.HLE.HOS.Kernel.Common
{
diff --git a/src/Ryujinx.HLE/HOS/ModLoader.cs b/src/Ryujinx.HLE/HOS/ModLoader.cs
index ff691914c..c652024cf 100644
--- a/src/Ryujinx.HLE/HOS/ModLoader.cs
+++ b/src/Ryujinx.HLE/HOS/ModLoader.cs
@@ -6,6 +6,7 @@ using LibHac.Loader;
using LibHac.Tools.Fs;
using LibHac.Tools.FsSystem;
using LibHac.Tools.FsSystem.RomFs;
+using LibHac.Util;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Utilities;
@@ -19,6 +20,7 @@ using System.Collections.Specialized;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Security.Cryptography;
using LazyFile = Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy.LazyFile;
using Path = System.IO.Path;
@@ -294,7 +296,7 @@ namespace Ryujinx.HLE.HOS
AddModsFromDirectory(mods, applicationDir, modMetadata);
}
- public static void QueryContentsDir(ModCache mods, DirectoryInfo contentsDir, ulong applicationId)
+ public static void QueryContentsDir(ModCache mods, DirectoryInfo contentsDir, ulong applicationId, ulong[] installedDlcs)
{
if (!contentsDir.Exists)
{
@@ -309,6 +311,16 @@ namespace Ryujinx.HLE.HOS
{
QueryApplicationDir(mods, applicationDir, applicationId);
}
+
+ foreach (ulong installedDlcId in installedDlcs)
+ {
+ DirectoryInfo dlcModDir = FindApplicationDir(contentsDir, $"{installedDlcId:x16}");
+
+ if (dlcModDir != null)
+ {
+ QueryApplicationDir(mods, dlcModDir, applicationId);
+ }
+ }
}
private static int QueryCheatsDir(ModCache mods, DirectoryInfo cheatsDir)
@@ -415,7 +427,7 @@ namespace Ryujinx.HLE.HOS
{
foreach ((ulong applicationId, ModCache cache) in modCaches)
{
- QueryContentsDir(cache, searchDir, applicationId);
+ QueryContentsDir(cache, searchDir, applicationId, Array.Empty());
}
return true;
@@ -581,6 +593,7 @@ namespace Ryujinx.HLE.HOS
public BitVector32 Stubs;
public BitVector32 Replaces;
public MetaLoader Npdm;
+ public string Hash;
public bool Modified => (Stubs.Data | Replaces.Data) != 0;
}
@@ -591,8 +604,11 @@ namespace Ryujinx.HLE.HOS
{
Stubs = new BitVector32(),
Replaces = new BitVector32(),
+ Hash = null,
};
+ string tempHash = string.Empty;
+
if (!_appMods.TryGetValue(applicationId, out ModCache mods) || mods.ExefsDirs.Count == 0)
{
return modLoadResult;
@@ -628,8 +644,16 @@ namespace Ryujinx.HLE.HOS
modLoadResult.Replaces[1 << i] = true;
- nsos[i] = new NsoExecutable(nsoFile.OpenRead().AsStorage(), nsoName);
- Logger.Info?.Print(LogClass.ModLoader, $"NSO '{nsoName}' replaced");
+ using (FileStream stream = nsoFile.OpenRead())
+ {
+ nsos[i] = new NsoExecutable(stream.AsStorage(), nsoName);
+ Logger.Info?.Print(LogClass.ModLoader, $"NSO '{nsoName}' replaced");
+ using (MD5 md5 = MD5.Create())
+ {
+ stream.Seek(0, SeekOrigin.Begin);
+ tempHash += BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLowerInvariant();
+ }
+ }
}
modLoadResult.Stubs[1 << i] |= File.Exists(Path.Combine(mod.Path.FullName, nsoName + StubExtension));
@@ -661,6 +685,14 @@ namespace Ryujinx.HLE.HOS
}
}
+ if (!string.IsNullOrEmpty(tempHash))
+ {
+ using (MD5 md5 = MD5.Create())
+ {
+ modLoadResult.Hash += BitConverter.ToString(md5.ComputeHash(tempHash.ToBytes())).Replace("-", string.Empty).ToLowerInvariant();
+ }
+ }
+
return modLoadResult;
}
diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs
index 517359e70..712967180 100644
--- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs
@@ -121,7 +121,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
private void UpdatePassphraseIfNeeded()
{
- string passphrase = _config.MultiplayerLdnPassphrase ?? "";
+ string passphrase = _config.MultiplayerLdnPassphrase ?? string.Empty;
if (passphrase != _passphrase)
{
_passphrase = passphrase;
diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Ver3StoreData.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Ver3StoreData.cs
index 3930b3312..d3df58215 100644
--- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/Ver3StoreData.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/Ver3StoreData.cs
@@ -1,5 +1,4 @@
using Ryujinx.Common.Memory;
-using Ryujinx.Common.Utilities;
using System;
using System.Runtime.InteropServices;
diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs
index 36a89070d..7e3e4c0a2 100644
--- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs
@@ -7,7 +7,6 @@ using Ryujinx.HLE.HOS.Services.Mii.Types;
using Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption;
using Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager;
using System;
-using System.Collections.Generic;
using System.IO;
using System.Linq;
diff --git a/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs b/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs
index 271b8fc84..6d03d8d05 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs
@@ -2,7 +2,6 @@ using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.HOS.Kernel.Ipc;
-using Ryujinx.HLE.HOS.Services.Apm;
using Ryujinx.Horizon.Common;
using System;
using System.Collections.Generic;
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs
index 3db2712f3..018bb8f14 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs
@@ -150,6 +150,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
{ BsdSocketOption.SoLinger, SocketOptionName.Linger },
{ BsdSocketOption.SoOobInline, SocketOptionName.OutOfBandInline },
{ BsdSocketOption.SoReusePort, SocketOptionName.ReuseAddress },
+ { BsdSocketOption.SoNoSigpipe, SocketOptionName.DontLinger },
{ BsdSocketOption.SoSndBuf, SocketOptionName.SendBuffer },
{ BsdSocketOption.SoRcvBuf, SocketOptionName.ReceiveBuffer },
{ BsdSocketOption.SoSndLoWat, SocketOptionName.SendLowWater },
diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs
index 78c6be164..507e60573 100644
--- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs
+++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsBlacklist.cs
@@ -1,37 +1,13 @@
+using Ryujinx.Common.Helper;
using System.Text.RegularExpressions;
namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
{
- static partial class DnsBlacklist
+ static class DnsBlacklist
{
- const RegexOptions RegexOpts = RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture;
-
- [GeneratedRegex(@"^(.*)\-lp1\.(n|s)\.n\.srv\.nintendo\.net$", RegexOpts)]
- private static partial Regex BlockedHost1();
- [GeneratedRegex(@"^(.*)\-lp1\.lp1\.t\.npln\.srv\.nintendo\.net$", RegexOpts)]
- private static partial Regex BlockedHost2();
- [GeneratedRegex(@"^(.*)\-lp1\.(znc|p)\.srv\.nintendo\.net$", RegexOpts)]
- private static partial Regex BlockedHost3();
- [GeneratedRegex(@"^(.*)\-sb\-api\.accounts\.nintendo\.com$", RegexOpts)]
- private static partial Regex BlockedHost4();
- [GeneratedRegex(@"^(.*)\-sb\.accounts\.nintendo\.com$", RegexOpts)]
- private static partial Regex BlockedHost5();
- [GeneratedRegex(@"^accounts\.nintendo\.com$", RegexOpts)]
- private static partial Regex BlockedHost6();
-
- private static readonly Regex[] _blockedHosts =
- [
- BlockedHost1(),
- BlockedHost2(),
- BlockedHost3(),
- BlockedHost4(),
- BlockedHost5(),
- BlockedHost6()
- ];
-
public static bool IsHostBlocked(string host)
{
- foreach (Regex regex in _blockedHosts)
+ foreach (Regex regex in Patterns.BlockedHosts)
{
if (regex.IsMatch(host))
{
diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IHOSBinderDriver.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IHOSBinderDriver.cs
index 2ffa961cb..e23e6fa3f 100644
--- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IHOSBinderDriver.cs
+++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/IHOSBinderDriver.cs
@@ -3,7 +3,6 @@ using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.Horizon.Common;
using System;
-using System.Buffers;
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
{
diff --git a/src/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs b/src/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs
index 5217612b9..84f229d8e 100644
--- a/src/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs
+++ b/src/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs
@@ -2,6 +2,7 @@ using LibHac.Common.FixedArrays;
using LibHac.Fs;
using LibHac.Loader;
using LibHac.Tools.FsSystem;
+using Ryujinx.Common.Helper;
using Ryujinx.Common.Logging;
using System;
using System.Text;
@@ -29,13 +30,6 @@ namespace Ryujinx.HLE.Loaders.Executables
public string Name;
public Array32 BuildId;
- [GeneratedRegex(@"[a-z]:[\\/][ -~]{5,}\.nss", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
- private static partial Regex ModuleRegex();
- [GeneratedRegex(@"sdk_version: ([0-9.]*)")]
- private static partial Regex FsSdkRegex();
- [GeneratedRegex(@"SDK MW[ -~]*")]
- private static partial Regex SdkMwRegex();
-
public NsoExecutable(IStorage inStorage, string name = null)
{
NsoReader reader = new();
@@ -90,7 +84,7 @@ namespace Ryujinx.HLE.Loaders.Executables
if (string.IsNullOrEmpty(modulePath))
{
- Match moduleMatch = ModuleRegex().Match(rawTextBuffer);
+ Match moduleMatch = Patterns.Module.Match(rawTextBuffer);
if (moduleMatch.Success)
{
modulePath = moduleMatch.Value;
@@ -99,13 +93,13 @@ namespace Ryujinx.HLE.Loaders.Executables
stringBuilder.AppendLine($" Module: {modulePath}");
- Match fsSdkMatch = FsSdkRegex().Match(rawTextBuffer);
+ Match fsSdkMatch = Patterns.FsSdk.Match(rawTextBuffer);
if (fsSdkMatch.Success)
{
stringBuilder.AppendLine($" FS SDK Version: {fsSdkMatch.Value.Replace("sdk_version: ", string.Empty)}");
}
- MatchCollection sdkMwMatches = SdkMwRegex().Matches(rawTextBuffer);
+ MatchCollection sdkMwMatches = Patterns.SdkMw.Matches(rawTextBuffer);
if (sdkMwMatches.Count != 0)
{
string libHeader = " SDK Libraries: ";
diff --git a/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs b/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs
index 5874636e7..dec52e2e3 100644
--- a/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs
+++ b/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs
@@ -4,7 +4,6 @@ using LibHac.Fs.Fsa;
using LibHac.Loader;
using LibHac.Ns;
using LibHac.Tools.FsSystem;
-using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Gpu;
@@ -84,13 +83,6 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
// Apply Nsos patches.
device.Configuration.VirtualFileSystem.ModLoader.ApplyNsoPatches(programId, nsoExecutables);
- // Don't use PTC if ExeFS files have been replaced.
- bool enablePtc = device.System.EnablePtc && !modLoadResult.Modified;
- if (!enablePtc)
- {
- Logger.Warning?.Print(LogClass.Ptc, "Detected unsupported ExeFs modifications. PTC disabled.");
- }
-
string programName = string.Empty;
if (!isHomebrew && programId > 0x010000000000FFFF)
@@ -117,7 +109,8 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
device.System.KernelContext,
metaLoader,
nacpData,
- enablePtc,
+ device.System.EnablePtc,
+ modLoadResult.Hash,
true,
programName,
metaLoader.GetProgramId(),
diff --git a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs
index 726b017b6..4c0866531 100644
--- a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs
+++ b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs
@@ -235,6 +235,7 @@ namespace Ryujinx.HLE.Loaders.Processes
dummyExeFs.GetNpdm(),
nacpData,
diskCacheEnabled: false,
+ diskCacheSelector: null,
allowCodeMemoryForJit: true,
programName,
programId,
diff --git a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs
index b11057da2..cedd11ae9 100644
--- a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs
+++ b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs
@@ -21,7 +21,6 @@ using Ryujinx.HLE.Loaders.Processes.Extensions;
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Arp;
using System;
-using System.Linq;
using System.Runtime.InteropServices;
using ApplicationId = LibHac.Ncm.ApplicationId;
@@ -186,6 +185,7 @@ namespace Ryujinx.HLE.Loaders.Processes
string.Empty,
string.Empty,
false,
+ null,
codeAddress,
codeSize);
@@ -226,6 +226,7 @@ namespace Ryujinx.HLE.Loaders.Processes
MetaLoader metaLoader,
BlitStruct applicationControlProperties,
bool diskCacheEnabled,
+ string diskCacheSelector,
bool allowCodeMemoryForJit,
string name,
ulong programId,
@@ -379,6 +380,7 @@ namespace Ryujinx.HLE.Loaders.Processes
$"{programId:x16}",
displayVersion,
diskCacheEnabled,
+ diskCacheSelector,
codeStart,
codeSize);
diff --git a/src/Ryujinx.HLE/Loaders/Processes/ProcessResult.cs b/src/Ryujinx.HLE/Loaders/Processes/ProcessResult.cs
index 3a7042670..6fd9408ed 100644
--- a/src/Ryujinx.HLE/Loaders/Processes/ProcessResult.cs
+++ b/src/Ryujinx.HLE/Loaders/Processes/ProcessResult.cs
@@ -88,7 +88,7 @@ namespace Ryujinx.HLE.Loaders.Processes
bool isFirmwareApplication = ProgramId <= 0x0100000000007FFF;
string name = !isFirmware
- ? (isFirmwareApplication ? "Firmware Application " : "") + (!string.IsNullOrWhiteSpace(Name) ? Name : "")
+ ? (isFirmwareApplication ? "Firmware Application " : string.Empty) + (!string.IsNullOrWhiteSpace(Name) ? Name : "")
: "Firmware";
// TODO: LibHac npdm currently doesn't support version field.
diff --git a/src/Ryujinx.HLE/UI/IHostUIHandler.cs b/src/Ryujinx.HLE/UI/IHostUIHandler.cs
index 8ccb5cf89..3748eef39 100644
--- a/src/Ryujinx.HLE/UI/IHostUIHandler.cs
+++ b/src/Ryujinx.HLE/UI/IHostUIHandler.cs
@@ -45,10 +45,12 @@ namespace Ryujinx.HLE.UI
/// The value associated to the .
void ExecuteProgram(Switch device, ProgramSpecifyKind kind, ulong value);
+ ///
/// Displays a Message Dialog box specific to Error Applet and blocks until it is closed.
///
/// False when OK is pressed, True when another button (Details) is pressed.
- bool DisplayErrorAppletDialog(string title, string message, string[] buttonsText);
+ // ReSharper disable once UnusedParameter.Global
+ bool DisplayErrorAppletDialog(string title, string message, string[] buttonsText, (uint Module, uint Description)? errorCode = null);
///
/// Creates a handler to process keyboard inputs into text strings.
diff --git a/src/Ryujinx.Horizon.Common/IExternalEvent.cs b/src/Ryujinx.Horizon.Common/IExternalEvent.cs
index dedf4c72a..2cb96bf31 100644
--- a/src/Ryujinx.Horizon.Common/IExternalEvent.cs
+++ b/src/Ryujinx.Horizon.Common/IExternalEvent.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace Ryujinx.Horizon.Common
{
public interface IExternalEvent
diff --git a/src/Ryujinx.Horizon/HorizonStatic.cs b/src/Ryujinx.Horizon/HorizonStatic.cs
index 305d54bd1..a936a5a2d 100644
--- a/src/Ryujinx.Horizon/HorizonStatic.cs
+++ b/src/Ryujinx.Horizon/HorizonStatic.cs
@@ -1,31 +1,37 @@
using Ryujinx.Horizon.Common;
+using Ryujinx.Horizon.Prepo.Types;
using Ryujinx.Memory;
using System;
+using System.Threading;
namespace Ryujinx.Horizon
{
public static class HorizonStatic
{
- [ThreadStatic]
- private static HorizonOptions _options;
+ internal static void HandlePlayReport(PlayReport report) =>
+ new Thread(() => PlayReport?.Invoke(report))
+ {
+ Name = "HLE.PlayReportEvent",
+ IsBackground = true,
+ Priority = ThreadPriority.AboveNormal
+ }.Start();
+
+ public static event Action PlayReport;
- [ThreadStatic]
- private static ISyscallApi _syscall;
+ [field: ThreadStatic]
+ public static HorizonOptions Options { get; private set; }
- [ThreadStatic]
- private static IVirtualMemoryManager _addressSpace;
+ [field: ThreadStatic]
+ public static ISyscallApi Syscall { get; private set; }
- [ThreadStatic]
- private static IThreadContext _threadContext;
+ [field: ThreadStatic]
+ public static IVirtualMemoryManager AddressSpace { get; private set; }
- [ThreadStatic]
- private static int _threadHandle;
+ [field: ThreadStatic]
+ public static IThreadContext ThreadContext { get; private set; }
- public static HorizonOptions Options => _options;
- public static ISyscallApi Syscall => _syscall;
- public static IVirtualMemoryManager AddressSpace => _addressSpace;
- public static IThreadContext ThreadContext => _threadContext;
- public static int CurrentThreadHandle => _threadHandle;
+ [field: ThreadStatic]
+ public static int CurrentThreadHandle { get; private set; }
public static void Register(
HorizonOptions options,
@@ -34,11 +40,11 @@ namespace Ryujinx.Horizon
IThreadContext threadContext,
int threadHandle)
{
- _options = options;
- _syscall = syscallApi;
- _addressSpace = addressSpace;
- _threadContext = threadContext;
- _threadHandle = threadHandle;
+ Options = options;
+ Syscall = syscallApi;
+ AddressSpace = addressSpace;
+ ThreadContext = threadContext;
+ CurrentThreadHandle = threadHandle;
}
}
}
diff --git a/src/Ryujinx.Horizon/Prepo/Ipc/PrepoService.cs b/src/Ryujinx.Horizon/Prepo/Ipc/PrepoService.cs
index 4ed7dd48e..0ca851e6e 100644
--- a/src/Ryujinx.Horizon/Prepo/Ipc/PrepoService.cs
+++ b/src/Ryujinx.Horizon/Prepo/Ipc/PrepoService.cs
@@ -17,12 +17,6 @@ namespace Ryujinx.Horizon.Prepo.Ipc
{
partial class PrepoService : IPrepoService
{
- enum PlayReportKind
- {
- Normal,
- System,
- }
-
private readonly ArpApi _arp;
private readonly PrepoServicePermissionLevel _permissionLevel;
private ulong _systemSessionId;
@@ -194,10 +188,17 @@ namespace Ryujinx.Horizon.Prepo.Ipc
{
return PrepoResult.InvalidBufferSize;
}
-
+
StringBuilder builder = new();
MessagePackObject deserializedReport = MessagePackSerializer.UnpackMessagePackObject(reportBuffer.ToArray());
+ PlayReport playReport = new()
+ {
+ Kind = playReportKind,
+ Room = gameRoom,
+ ReportData = deserializedReport
+ };
+
builder.AppendLine();
builder.AppendLine("PlayReport log:");
builder.AppendLine($" Kind: {playReportKind}");
@@ -207,10 +208,12 @@ namespace Ryujinx.Horizon.Prepo.Ipc
if (pid != 0)
{
builder.AppendLine($" Pid: {pid}");
+ playReport.Pid = pid;
}
else
{
builder.AppendLine($" ApplicationId: {applicationId}");
+ playReport.AppId = applicationId;
}
Result result = _arp.GetApplicationInstanceId(out ulong applicationInstanceId, pid);
@@ -221,15 +224,20 @@ namespace Ryujinx.Horizon.Prepo.Ipc
_arp.GetApplicationLaunchProperty(out ApplicationLaunchProperty applicationLaunchProperty, applicationInstanceId).AbortOnFailure();
+ playReport.Version = applicationLaunchProperty.Version;
+
builder.AppendLine($" ApplicationVersion: {applicationLaunchProperty.Version}");
if (!userId.IsNull)
{
builder.AppendLine($" UserId: {userId}");
+ playReport.UserId = userId;
}
builder.AppendLine($" Room: {gameRoom}");
builder.AppendLine($" Report: {MessagePackObjectFormatter.Format(deserializedReport)}");
+
+ HorizonStatic.HandlePlayReport(playReport);
Logger.Info?.Print(LogClass.ServicePrepo, builder.ToString());
diff --git a/src/Ryujinx.Horizon/Prepo/Types/PlayReport.cs b/src/Ryujinx.Horizon/Prepo/Types/PlayReport.cs
new file mode 100644
index 000000000..e896219d5
--- /dev/null
+++ b/src/Ryujinx.Horizon/Prepo/Types/PlayReport.cs
@@ -0,0 +1,24 @@
+using MsgPack;
+using Ryujinx.Horizon.Sdk.Account;
+using Ryujinx.Horizon.Sdk.Ncm;
+
+namespace Ryujinx.Horizon.Prepo.Types
+{
+ public struct PlayReport
+ {
+ public PlayReportKind Kind { get; init; }
+ public string Room { get; init; }
+ public MessagePackObject ReportData { get; init; }
+
+ public ApplicationId? AppId;
+ public ulong? Pid;
+ public uint Version;
+ public Uid? UserId;
+ }
+
+ public enum PlayReportKind
+ {
+ Normal,
+ System,
+ }
+}
diff --git a/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRenderer.cs b/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRenderer.cs
index 168d58619..84c88d13b 100644
--- a/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRenderer.cs
+++ b/src/Ryujinx.Horizon/Sdk/Audio/Detail/AudioRenderer.cs
@@ -1,7 +1,6 @@
using Ryujinx.Audio;
using Ryujinx.Audio.Integration;
using Ryujinx.Audio.Renderer.Server;
-using Ryujinx.Common.Memory;
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Sf;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
diff --git a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs
index acec66e82..d74e50a61 100644
--- a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs
+++ b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs
@@ -2,7 +2,6 @@ using Ryujinx.Common;
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Sf;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
-using System;
namespace Ryujinx.Horizon.Sdk.Codec.Detail
{
diff --git a/src/Ryujinx.Horizon/Sdk/Friends/Detail/BlockedUserImpl.cs b/src/Ryujinx.Horizon/Sdk/Friends/Detail/BlockedUserImpl.cs
index d5f8a0313..a7ede259f 100644
--- a/src/Ryujinx.Horizon/Sdk/Friends/Detail/BlockedUserImpl.cs
+++ b/src/Ryujinx.Horizon/Sdk/Friends/Detail/BlockedUserImpl.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Friends.Detail
{
struct BlockedUserImpl
diff --git a/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendCandidateImpl.cs b/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendCandidateImpl.cs
index 21e99c754..1051343d6 100644
--- a/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendCandidateImpl.cs
+++ b/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendCandidateImpl.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Friends.Detail
{
struct FriendCandidateImpl
diff --git a/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendInvitationForViewerImpl.cs b/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendInvitationForViewerImpl.cs
index 416ba3655..06134f245 100644
--- a/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendInvitationForViewerImpl.cs
+++ b/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendInvitationForViewerImpl.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Friends.Detail
{
struct FriendInvitationForViewerImpl
diff --git a/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendRequestImpl.cs b/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendRequestImpl.cs
index ba5671692..108b56008 100644
--- a/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendRequestImpl.cs
+++ b/src/Ryujinx.Horizon/Sdk/Friends/Detail/FriendRequestImpl.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Friends.Detail
{
struct FriendRequestImpl
diff --git a/src/Ryujinx.Horizon/Sdk/Friends/Detail/NintendoNetworkIdFriendImpl.cs b/src/Ryujinx.Horizon/Sdk/Friends/Detail/NintendoNetworkIdFriendImpl.cs
index 66d61e4c1..7b7460481 100644
--- a/src/Ryujinx.Horizon/Sdk/Friends/Detail/NintendoNetworkIdFriendImpl.cs
+++ b/src/Ryujinx.Horizon/Sdk/Friends/Detail/NintendoNetworkIdFriendImpl.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Friends.Detail
{
struct NintendoNetworkIdFriendImpl
diff --git a/src/Ryujinx.Horizon/Sdk/Friends/Detail/PlayHistoryImpl.cs b/src/Ryujinx.Horizon/Sdk/Friends/Detail/PlayHistoryImpl.cs
index 9f90f0c8f..37f4d7c2d 100644
--- a/src/Ryujinx.Horizon/Sdk/Friends/Detail/PlayHistoryImpl.cs
+++ b/src/Ryujinx.Horizon/Sdk/Friends/Detail/PlayHistoryImpl.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Friends.Detail
{
struct PlayHistoryImpl
diff --git a/src/Ryujinx.Horizon/Sdk/Friends/Detail/ProfileImpl.cs b/src/Ryujinx.Horizon/Sdk/Friends/Detail/ProfileImpl.cs
index f779d93cf..422f814ce 100644
--- a/src/Ryujinx.Horizon/Sdk/Friends/Detail/ProfileImpl.cs
+++ b/src/Ryujinx.Horizon/Sdk/Friends/Detail/ProfileImpl.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Friends.Detail
{
struct ProfileImpl
diff --git a/src/Ryujinx.Horizon/Sdk/Friends/Detail/SnsAccountFriendImpl.cs b/src/Ryujinx.Horizon/Sdk/Friends/Detail/SnsAccountFriendImpl.cs
index dc6adf03a..f3d0cdce3 100644
--- a/src/Ryujinx.Horizon/Sdk/Friends/Detail/SnsAccountFriendImpl.cs
+++ b/src/Ryujinx.Horizon/Sdk/Friends/Detail/SnsAccountFriendImpl.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Friends.Detail
{
struct SnsAccountFriendImpl
diff --git a/src/Ryujinx.Horizon/Sdk/Friends/FriendInvitationId.cs b/src/Ryujinx.Horizon/Sdk/Friends/FriendInvitationId.cs
index 7be19d574..46e734ed2 100644
--- a/src/Ryujinx.Horizon/Sdk/Friends/FriendInvitationId.cs
+++ b/src/Ryujinx.Horizon/Sdk/Friends/FriendInvitationId.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Friends
{
struct FriendInvitationId
diff --git a/src/Ryujinx.Horizon/Sdk/Ns/ApplicationControlProperty.cs b/src/Ryujinx.Horizon/Sdk/Ns/ApplicationControlProperty.cs
index 12c19168d..7640967c6 100644
--- a/src/Ryujinx.Horizon/Sdk/Ns/ApplicationControlProperty.cs
+++ b/src/Ryujinx.Horizon/Sdk/Ns/ApplicationControlProperty.cs
@@ -1,8 +1,5 @@
using Ryujinx.Common.Memory;
-using Ryujinx.Horizon.Sdk.Arp.Detail;
using System;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using System.Text;
namespace Ryujinx.Horizon.Sdk.Ns
diff --git a/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs b/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs
index 422f756e4..0cd147771 100644
--- a/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs
+++ b/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Threading;
namespace Ryujinx.Horizon.Sdk.OsTypes
diff --git a/src/Ryujinx.Horizon/Sdk/Settings/Factory/CountryCode.cs b/src/Ryujinx.Horizon/Sdk/Settings/Factory/CountryCode.cs
index daf2ba3b8..33234ed76 100644
--- a/src/Ryujinx.Horizon/Sdk/Settings/Factory/CountryCode.cs
+++ b/src/Ryujinx.Horizon/Sdk/Settings/Factory/CountryCode.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices;
-
namespace Ryujinx.Horizon.Sdk.Settings.Factory
{
struct CountryCode
diff --git a/src/Ryujinx.Horizon/Usb/Ipc/PdManager.cs b/src/Ryujinx.Horizon/Usb/Ipc/PdManager.cs
index 1c502919b..120d7b51a 100644
--- a/src/Ryujinx.Horizon/Usb/Ipc/PdManager.cs
+++ b/src/Ryujinx.Horizon/Usb/Ipc/PdManager.cs
@@ -1,4 +1,3 @@
-using Ryujinx.Horizon.Sdk.Sf.Hipc;
using Ryujinx.Horizon.Sdk.Usb;
namespace Ryujinx.Horizon.Usb.Ipc
diff --git a/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs b/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs
index a473d7042..3b243eed0 100644
--- a/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs
+++ b/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs
@@ -2,8 +2,6 @@ using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Utilities;
-using Ryujinx.HLE.HOS.Services.Hid;
-using SDL2;
using System;
using System.Collections.Generic;
using System.Numerics;
@@ -12,7 +10,7 @@ using static SDL2.SDL;
namespace Ryujinx.Input.SDL2
{
- class SDL2Gamepad : IGamepad
+ public class SDL2Gamepad : IGamepad
{
private bool HasConfiguration => _configuration != null;
@@ -113,7 +111,7 @@ namespace Ryujinx.Input.SDL2
byte blue = packedRgb > 0 ? (byte)(packedRgb % 256) : (byte)0;
if (SDL_GameControllerSetLED(_gamepadHandle, red, green, blue) != 0)
- Logger.Error?.Print(LogClass.Hid, "LED is not supported on this game controller.");
+ Logger.Error?.Print(LogClass.Hid, "LED setting failed; probably in the middle of disconnecting.");
}
private GamepadFeaturesFlag GetFeaturesFlag()
diff --git a/src/Ryujinx.Input/HLE/NpadManager.cs b/src/Ryujinx.Input/HLE/NpadManager.cs
index 4a54b7ead..21219d91b 100644
--- a/src/Ryujinx.Input/HLE/NpadManager.cs
+++ b/src/Ryujinx.Input/HLE/NpadManager.cs
@@ -185,6 +185,15 @@ namespace Ryujinx.Input.HLE
}
}
+ public bool InputUpdatesBlocked
+ {
+ get
+ {
+ lock (_lock)
+ return _blockInputUpdates;
+ }
+ }
+
public void BlockInputUpdates()
{
lock (_lock)
diff --git a/src/Ryujinx.Memory/AddressSpaceManager.cs b/src/Ryujinx.Memory/AddressSpaceManager.cs
index 150e538fe..f9d514b55 100644
--- a/src/Ryujinx.Memory/AddressSpaceManager.cs
+++ b/src/Ryujinx.Memory/AddressSpaceManager.cs
@@ -1,7 +1,6 @@
using Ryujinx.Memory.Range;
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Runtime.CompilerServices;
namespace Ryujinx.Memory
diff --git a/src/Ryujinx.Memory/Tracking/RegionFlags.cs b/src/Ryujinx.Memory/Tracking/RegionFlags.cs
index ceb8e56a6..1eefdfbc0 100644
--- a/src/Ryujinx.Memory/Tracking/RegionFlags.cs
+++ b/src/Ryujinx.Memory/Tracking/RegionFlags.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Ryujinx.Memory.Tracking
{
diff --git a/src/Ryujinx.Memory/WindowsShared/WindowsApi.cs b/src/Ryujinx.Memory/WindowsShared/WindowsApi.cs
index 0d002dada..d146e55a4 100644
--- a/src/Ryujinx.Memory/WindowsShared/WindowsApi.cs
+++ b/src/Ryujinx.Memory/WindowsShared/WindowsApi.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
diff --git a/src/Ryujinx.SDL2.Common/SDL2Driver.cs b/src/Ryujinx.SDL2.Common/SDL2Driver.cs
index 047ccbebf..851c07867 100644
--- a/src/Ryujinx.SDL2.Common/SDL2Driver.cs
+++ b/src/Ryujinx.SDL2.Common/SDL2Driver.cs
@@ -1,6 +1,5 @@
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
-using Ryujinx.Common.Utilities;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
diff --git a/src/Ryujinx.Tests/Cpu/CpuTest.cs b/src/Ryujinx.Tests/Cpu/CpuTest.cs
index da0f03e6b..6f749463e 100644
--- a/src/Ryujinx.Tests/Cpu/CpuTest.cs
+++ b/src/Ryujinx.Tests/Cpu/CpuTest.cs
@@ -1,6 +1,5 @@
using ARMeilleure;
using ARMeilleure.State;
-using ARMeilleure.Translation;
using NUnit.Framework;
using Ryujinx.Cpu.Jit;
using Ryujinx.Memory;
diff --git a/src/Ryujinx.Tests/Cpu/CpuTest32.cs b/src/Ryujinx.Tests/Cpu/CpuTest32.cs
index 81ed9bcc9..d4c8156d7 100644
--- a/src/Ryujinx.Tests/Cpu/CpuTest32.cs
+++ b/src/Ryujinx.Tests/Cpu/CpuTest32.cs
@@ -1,6 +1,5 @@
using ARMeilleure;
using ARMeilleure.State;
-using ARMeilleure.Translation;
using NUnit.Framework;
using Ryujinx.Cpu.Jit;
using Ryujinx.Memory;
diff --git a/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs b/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs
index b7ad8efe7..3d8847dc4 100644
--- a/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs
+++ b/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs
@@ -1,5 +1,4 @@
using NUnit.Framework;
-using System;
namespace Ryujinx.Tests.Cpu
{
diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs
index b85b17b89..b26921e6a 100644
--- a/src/Ryujinx/AppHost.cs
+++ b/src/Ryujinx/AppHost.cs
@@ -319,31 +319,12 @@ namespace Ryujinx.Ava
public void VSyncModeToggle()
{
VSyncMode oldVSyncMode = Device.VSyncMode;
- VSyncMode newVSyncMode = VSyncMode.Switch;
bool customVSyncIntervalEnabled = ConfigurationState.Instance.Graphics.EnableCustomVSyncInterval.Value;
- switch (oldVSyncMode)
- {
- case VSyncMode.Switch:
- newVSyncMode = VSyncMode.Unbounded;
- break;
- case VSyncMode.Unbounded:
- if (customVSyncIntervalEnabled)
- {
- newVSyncMode = VSyncMode.Custom;
- }
- else
- {
- newVSyncMode = VSyncMode.Switch;
- }
-
- break;
- case VSyncMode.Custom:
- newVSyncMode = VSyncMode.Switch;
- break;
- }
-
- UpdateVSyncMode(this, new ReactiveEventArgs(oldVSyncMode, newVSyncMode));
+ UpdateVSyncMode(this, new ReactiveEventArgs(
+ oldVSyncMode,
+ oldVSyncMode.Next(customVSyncIntervalEnabled))
+ );
}
private void UpdateCustomVSyncIntervalValue(object sender, ReactiveEventArgs e)
@@ -536,7 +517,7 @@ namespace Ryujinx.Ava
Device?.System.ChangeDockedModeState(e.NewValue);
}
- private void UpdateAudioVolumeState(object sender, ReactiveEventArgs e)
+ public void UpdateAudioVolumeState(object sender, ReactiveEventArgs e)
{
Device?.SetVolume(e.NewValue);
@@ -957,7 +938,9 @@ namespace Ryujinx.Ava
ConfigurationState.Instance.System.EnableInternetAccess,
ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
ConfigurationState.Instance.System.FsGlobalAccessLogMode,
- ConfigurationState.Instance.System.SystemTimeOffset,
+ ConfigurationState.Instance.System.MatchSystemTime
+ ? 0
+ : ConfigurationState.Instance.System.SystemTimeOffset,
ConfigurationState.Instance.System.TimeZone,
ConfigurationState.Instance.System.MemoryManagerMode,
ConfigurationState.Instance.System.IgnoreMissingServices,
@@ -1058,6 +1041,7 @@ namespace Ryujinx.Ava
if (_viewModel.StartGamesInFullscreen)
{
_viewModel.WindowState = WindowState.FullScreen;
+ _viewModel.Window.TitleBar.ExtendsContentIntoTitleBar = true;
}
if (_viewModel.WindowState is WindowState.FullScreen || _viewModel.StartGamesWithoutUI)
diff --git a/src/Ryujinx/Assets/Styles/CheckboxMenuItemStyle.axaml b/src/Ryujinx/Assets/Styles/CheckboxMenuItemStyle.axaml
deleted file mode 100644
index 13176c84f..000000000
--- a/src/Ryujinx/Assets/Styles/CheckboxMenuItemStyle.axaml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
diff --git a/src/Ryujinx/Assets/Styles/Styles.xaml b/src/Ryujinx/Assets/Styles/Styles.xaml
index 3d0c91840..5523f551a 100644
--- a/src/Ryujinx/Assets/Styles/Styles.xaml
+++ b/src/Ryujinx/Assets/Styles/Styles.xaml
@@ -218,6 +218,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Ryujinx/UI/Controls/ApplicationDataView.axaml.cs b/src/Ryujinx/UI/Controls/ApplicationDataView.axaml.cs
new file mode 100644
index 000000000..57dba3228
--- /dev/null
+++ b/src/Ryujinx/UI/Controls/ApplicationDataView.axaml.cs
@@ -0,0 +1,83 @@
+using Avalonia.Controls;
+using Avalonia.Input.Platform;
+using Avalonia.Interactivity;
+using Avalonia.Styling;
+using FluentAvalonia.UI.Controls;
+using Ryujinx.Ava.Common.Locale;
+using Ryujinx.Ava.UI.Helpers;
+using Ryujinx.Ava.UI.ViewModels;
+using Ryujinx.Ava.UI.Windows;
+using Ryujinx.Ava.Utilities.AppLibrary;
+using Ryujinx.Ava.Utilities.Compat;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Ryujinx.Ava.UI.Controls
+{
+ public partial class ApplicationDataView : UserControl
+ {
+ public static async Task Show(ApplicationData appData)
+ {
+ ContentDialog contentDialog = new()
+ {
+ Title = appData.Name,
+ PrimaryButtonText = string.Empty,
+ SecondaryButtonText = string.Empty,
+ CloseButtonText = LocaleManager.Instance[LocaleKeys.SettingsButtonClose],
+ MinWidth = 256,
+ Content = new ApplicationDataView { DataContext = new ApplicationDataViewModel(appData) }
+ };
+
+ Style closeButton = new(x => x.Name("CloseButton"));
+ closeButton.Setters.Add(new Setter(WidthProperty, 160d));
+
+ Style closeButtonParent = new(x => x.Name("CommandSpace"));
+ closeButtonParent.Setters.Add(new Setter(HorizontalAlignmentProperty,
+ Avalonia.Layout.HorizontalAlignment.Center));
+
+ contentDialog.Styles.Add(closeButton);
+ contentDialog.Styles.Add(closeButtonParent);
+
+ await ContentDialogHelper.ShowAsync(contentDialog);
+ }
+
+ public ApplicationDataView()
+ {
+ InitializeComponent();
+ }
+
+ private async void PlayabilityStatus_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (sender is not Button { Content: TextBlock playabilityLabel })
+ return;
+
+ if (RyujinxApp.AppLifetime.Windows.TryGetFirst(x => x is ContentDialogOverlayWindow, out Window window))
+ window.Close(ContentDialogResult.None);
+
+ await CompatibilityList.Show((string)playabilityLabel.Tag);
+ }
+
+ private async void IdString_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (DataContext is not MainWindowViewModel mwvm)
+ return;
+
+ if (sender is not Button { Content: TextBlock idText })
+ return;
+
+ if (!RyujinxApp.IsClipboardAvailable(out IClipboard clipboard))
+ return;
+
+ ApplicationData appData = mwvm.Applications.FirstOrDefault(it => it.IdString == idText.Text);
+ if (appData is null)
+ return;
+
+ await clipboard.SetTextAsync(appData.IdString);
+
+ NotificationHelper.ShowInformation(
+ "Copied Title ID",
+ $"{appData.Name} ({appData.IdString})");
+ }
+ }
+}
+
diff --git a/src/Ryujinx/UI/Controls/ApplicationGridView.axaml b/src/Ryujinx/UI/Controls/ApplicationGridView.axaml
index 629bdebbf..7f7e3260b 100644
--- a/src/Ryujinx/UI/Controls/ApplicationGridView.axaml
+++ b/src/Ryujinx/UI/Controls/ApplicationGridView.axaml
@@ -13,9 +13,6 @@
mc:Ignorable="d"
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
x:DataType="viewModels:MainWindowViewModel">
-
-
-
@@ -68,7 +65,7 @@
Grid.Row="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
- Source="{Binding Icon, Converter={StaticResource ByteImage}}" />
+ Source="{Binding Icon, Converter={x:Static helpers:BitmapArrayValueConverter.Instance}}" />
-
-
-
@@ -62,7 +59,7 @@
Classes.large="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridLarge}"
Classes.normal="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridMedium}"
Classes.small="{Binding $parent[UserControl].((viewModels:MainWindowViewModel)DataContext).IsGridSmall}"
- Source="{Binding Icon, Converter={StaticResource ByteImage}}" />
+ Source="{Binding Icon, Converter={x:Static helpers:BitmapArrayValueConverter.Instance}}" />
+
diff --git a/src/Ryujinx/UI/Controls/ApplicationListView.axaml.cs b/src/Ryujinx/UI/Controls/ApplicationListView.axaml.cs
index 41919ebf5..fb38fdb72 100644
--- a/src/Ryujinx/UI/Controls/ApplicationListView.axaml.cs
+++ b/src/Ryujinx/UI/Controls/ApplicationListView.axaml.cs
@@ -1,12 +1,11 @@
using Avalonia.Controls;
-using Avalonia.Controls.Notifications;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Interactivity;
-using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Ava.Utilities.AppLibrary;
+using Ryujinx.Ava.Utilities.Compat;
using System;
using System.Linq;
@@ -30,6 +29,17 @@ namespace Ryujinx.Ava.UI.Controls
if (sender is ListBox { SelectedItem: ApplicationData selected })
RaiseEvent(new ApplicationOpenedEventArgs(selected, ApplicationOpenedEvent));
}
+
+ private async void PlayabilityStatus_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (DataContext is not MainWindowViewModel mwvm)
+ return;
+
+ if (sender is not Button { Content: TextBlock playabilityLabel })
+ return;
+
+ await CompatibilityList.Show((string)playabilityLabel.Tag);
+ }
private async void IdString_OnClick(object sender, RoutedEventArgs e)
{
diff --git a/src/Ryujinx/UI/Controls/DlcSelectView.axaml.cs b/src/Ryujinx/UI/Controls/DlcSelectView.axaml.cs
index c011ca110..939acc0a3 100644
--- a/src/Ryujinx/UI/Controls/DlcSelectView.axaml.cs
+++ b/src/Ryujinx/UI/Controls/DlcSelectView.axaml.cs
@@ -1,6 +1,4 @@
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
+using Avalonia.Controls;
using Avalonia.Styling;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale;
diff --git a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs
index b5d085ba1..ae83f9e98 100644
--- a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs
+++ b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs
@@ -159,6 +159,7 @@ namespace Ryujinx.Ava.UI.Helpers
Symbol = (Symbol)symbol,
Margin = new Thickness(10),
FontSize = 40,
+ FlowDirection = FlowDirection.LeftToRight,
VerticalAlignment = VerticalAlignment.Center,
};
diff --git a/src/Ryujinx/UI/Helpers/Converters/BitmapArrayValueConverter.cs b/src/Ryujinx/UI/Helpers/Converters/BitmapArrayValueConverter.cs
index 7b599a48b..750523068 100644
--- a/src/Ryujinx/UI/Helpers/Converters/BitmapArrayValueConverter.cs
+++ b/src/Ryujinx/UI/Helpers/Converters/BitmapArrayValueConverter.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Ava.UI.Helpers
{
internal class BitmapArrayValueConverter : IValueConverter
{
- public static BitmapArrayValueConverter Instance = new();
+ public static readonly BitmapArrayValueConverter Instance = new();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
diff --git a/src/Ryujinx/UI/Helpers/Converters/DownloadableContentLabelConverter.cs b/src/Ryujinx/UI/Helpers/Converters/DownloadableContentLabelConverter.cs
index 22193b97e..7ed26050c 100644
--- a/src/Ryujinx/UI/Helpers/Converters/DownloadableContentLabelConverter.cs
+++ b/src/Ryujinx/UI/Helpers/Converters/DownloadableContentLabelConverter.cs
@@ -11,7 +11,7 @@ namespace Ryujinx.Ava.UI.Helpers
{
internal class DownloadableContentLabelConverter : IMultiValueConverter
{
- public static DownloadableContentLabelConverter Instance = new();
+ public static readonly DownloadableContentLabelConverter Instance = new();
public object Convert(IList
diff --git a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs
index 67deb9723..36f451fe4 100644
--- a/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs
+++ b/src/Ryujinx/UI/Windows/SettingsWindow.axaml.cs
@@ -1,12 +1,9 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
-using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.Common.Locale;
-using Ryujinx.Ava.UI.Models;
using Ryujinx.Ava.UI.ViewModels;
-using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.HLE.FileSystem;
using Ryujinx.Input;
using System;
@@ -34,7 +31,6 @@ namespace Ryujinx.Ava.UI.Windows
#if DEBUG
this.AttachDevTools(new KeyGesture(Key.F12, KeyModifiers.Alt));
#endif
-
}
public SettingsWindow()
diff --git a/src/Ryujinx/UI/Windows/TitleUpdateWindow.axaml b/src/Ryujinx/UI/Windows/TitleUpdateWindow.axaml
index a8ec5d29a..4da727db5 100644
--- a/src/Ryujinx/UI/Windows/TitleUpdateWindow.axaml
+++ b/src/Ryujinx/UI/Windows/TitleUpdateWindow.axaml
@@ -14,9 +14,6 @@
mc:Ignorable="d"
x:DataType="viewModels:TitleUpdateViewModel"
Focusable="True">
-
-
-
-
+
diff --git a/src/Ryujinx/UI/Windows/XCITrimmerWindow.axaml b/src/Ryujinx/UI/Windows/XCITrimmerWindow.axaml
index 2d56931b5..bc135d4ec 100644
--- a/src/Ryujinx/UI/Windows/XCITrimmerWindow.axaml
+++ b/src/Ryujinx/UI/Windows/XCITrimmerWindow.axaml
@@ -13,11 +13,6 @@
x:DataType="viewModels:XCITrimmerViewModel"
Focusable="True"
mc:Ignorable="d">
-
-
-
-
-
@@ -186,7 +181,7 @@
HorizontalAlignment="Left"
VerticalAlignment="Center"
MaxLines="1"
- Text="{Binding ., Converter={StaticResource StatusLabel}}">
+ Text="{Binding ., Converter={x:Static helpers:XCITrimmerFileStatusConverter.Instance}}">
@@ -194,7 +189,7 @@
Classes="h1"
Text="{ext:Locale XCITrimmerTitleStatusFailed}" />
>
+ Text="{Binding ., Converter={x:Static helpers:XCITrimmerFileSpaceSavingsConverter.Instance}}">>
diff --git a/src/Ryujinx/Updater.cs b/src/Ryujinx/Updater.cs
index f8b4b2beb..338e9de43 100644
--- a/src/Ryujinx/Updater.cs
+++ b/src/Ryujinx/Updater.cs
@@ -43,7 +43,18 @@ namespace Ryujinx.Ava
private const int ConnectionCount = 4;
private static string _buildVer;
- private static string _platformExt;
+
+ private static readonly string _platformExt =
+ RunningPlatform.IsMacOS
+ ? "macos_universal.app.tar.gz"
+ : RunningPlatform.IsWindows
+ ? "win_x64.zip"
+ : RunningPlatform.IsX64Linux
+ ? "linux_x64.tar.gz"
+ : RunningPlatform.IsArmLinux
+ ? "linux_arm64.tar.gz"
+ : throw new PlatformNotSupportedException();
+
private static string _buildUrl;
private static long _buildSize;
private static bool _updateSuccessful;
@@ -51,30 +62,8 @@ namespace Ryujinx.Ava
private static readonly string[] _windowsDependencyDirs = [];
- public static async Task BeginUpdateAsync(bool showVersionUpToDate = false)
+ public static async Task> CheckVersionAsync(bool showVersionUpToDate = false)
{
- if (_running)
- {
- return;
- }
-
- _running = true;
-
- // Detect current platform
- if (OperatingSystem.IsMacOS())
- {
- _platformExt = "macos_universal.app.tar.gz";
- }
- else if (OperatingSystem.IsWindows())
- {
- _platformExt = "win_x64.zip";
- }
- else if (OperatingSystem.IsLinux())
- {
- string arch = RuntimeInformation.OSArchitecture == Architecture.Arm64 ? "arm64" : "x64";
- _platformExt = $"linux_{arch}.tar.gz";
- }
-
if (!Version.TryParse(Program.Version, out Version currentVersion))
{
Logger.Error?.Print(LogClass.Application, $"Failed to convert the current {RyujinxApp.FullAppName} version!");
@@ -85,7 +74,7 @@ namespace Ryujinx.Ava
_running = false;
- return;
+ return default;
}
Logger.Info?.Print(LogClass.Application, "Checking for updates.");
@@ -123,7 +112,7 @@ namespace Ryujinx.Ava
_running = false;
- return;
+ return default;
}
break;
@@ -149,7 +138,7 @@ namespace Ryujinx.Ava
_running = false;
- return;
+ return default;
}
}
catch (Exception exception)
@@ -161,7 +150,7 @@ namespace Ryujinx.Ava
_running = false;
- return;
+ return default;
}
if (!Version.TryParse(_buildVer, out Version newVersion))
@@ -174,9 +163,27 @@ namespace Ryujinx.Ava
_running = false;
+ return default;
+ }
+
+ return (currentVersion, newVersion);
+ }
+
+ public static async Task BeginUpdateAsync(bool showVersionUpToDate = false)
+ {
+ if (_running)
+ {
return;
}
+ _running = true;
+
+ Optional<(Version, Version)> versionTuple = await CheckVersionAsync(showVersionUpToDate);
+
+ if (_running is false || !versionTuple.HasValue) return;
+
+ (Version currentVersion, Version newVersion) = versionTuple.Value;
+
if (newVersion <= currentVersion)
{
if (showVersionUpToDate)
diff --git a/src/Ryujinx/Utilities/AppLibrary/ApplicationData.cs b/src/Ryujinx/Utilities/AppLibrary/ApplicationData.cs
index 98c879df3..747ead8ca 100644
--- a/src/Ryujinx/Utilities/AppLibrary/ApplicationData.cs
+++ b/src/Ryujinx/Utilities/AppLibrary/ApplicationData.cs
@@ -1,3 +1,4 @@
+using Gommon;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Fsa;
@@ -7,11 +8,14 @@ using LibHac.Ns;
using LibHac.Tools.Fs;
using LibHac.Tools.FsSystem;
using LibHac.Tools.FsSystem.NcaUtils;
+using Ryujinx.Ava.Common.Locale;
+using Ryujinx.Ava.Utilities.Compat;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.Loaders.Processes.Extensions;
using System;
using System.IO;
+using System.Text;
using System.Text.Json.Serialization;
namespace Ryujinx.Ava.Utilities.AppLibrary
@@ -21,11 +25,29 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
public bool Favorite { get; set; }
public byte[] Icon { get; set; }
public string Name { get; set; } = "Unknown";
- public ulong Id { get; set; }
+
+ private ulong _id;
+
+ public ulong Id
+ {
+ get => _id;
+ set
+ {
+ _id = value;
+
+ Compatibility = CompatibilityCsv.Find(Id);
+ }
+ }
public string Developer { get; set; } = "Unknown";
public string Version { get; set; } = "0";
public int PlayerCount { get; set; }
public int GameCount { get; set; }
+
+ public bool HasLdnGames => PlayerCount != 0 && GameCount != 0;
+
+ public bool HasRichPresenceAsset => DiscordIntegrationModule.HasAssetImage(IdString);
+ public bool HasDynamicRichPresenceSupport => DiscordIntegrationModule.HasAnalyzer(IdString);
+
public TimeSpan TimePlayed { get; set; }
public DateTime? LastPlayed { get; set; }
public string FileExtension { get; set; }
@@ -37,11 +59,39 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
public string TimePlayedString => ValueFormatUtils.FormatTimeSpan(TimePlayed);
- public bool HasPlayedPreviously => TimePlayedString != string.Empty;
+ public bool HasPlayedPreviously => TimePlayed.TotalSeconds > 1;
public string LastPlayedString => ValueFormatUtils.FormatDateTime(LastPlayed)?.Replace(" ", "\n");
public string FileSizeString => ValueFormatUtils.FormatFileSize(FileSize);
+
+ public Optional Compatibility { get; private set; }
+
+ public bool HasPlayabilityInfo => Compatibility.HasValue;
+
+ public string LocalizedStatus => Compatibility.Convert(x => x.LocalizedStatus);
+
+ public bool HasCompatibilityLabels => !FormattedCompatibilityLabels.Equals(string.Empty);
+
+ public string FormattedCompatibilityLabels
+ => Compatibility.Convert(x => x.FormattedIssueLabels).OrElse(string.Empty);
+
+ public LocaleKeys? PlayabilityStatus => Compatibility.Convert(x => x.Status).OrElse(null);
+
+ public string LocalizedStatusTooltip =>
+ Compatibility.Convert(x =>
+#pragma warning disable CS8509 // It is exhaustive for all possible values this can contain.
+ LocaleManager.Instance[x.Status switch
+#pragma warning restore CS8509
+ {
+ LocaleKeys.CompatibilityListPlayable => LocaleKeys.CompatibilityListPlayableTooltip,
+ LocaleKeys.CompatibilityListIngame => LocaleKeys.CompatibilityListIngameTooltip,
+ LocaleKeys.CompatibilityListMenus => LocaleKeys.CompatibilityListMenusTooltip,
+ LocaleKeys.CompatibilityListBoots => LocaleKeys.CompatibilityListBootsTooltip,
+ LocaleKeys.CompatibilityListNothing => LocaleKeys.CompatibilityListNothingTooltip,
+ }]
+ ).OrElse(string.Empty);
+
[JsonIgnore] public string IdString => Id.ToString("x16");
@@ -51,16 +101,16 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
public static string GetBuildId(VirtualFileSystem virtualFileSystem, IntegrityCheckLevel checkLevel, string titleFilePath)
{
- using FileStream file = new(titleFilePath, FileMode.Open, FileAccess.Read);
-
- Nca mainNca = null;
- Nca patchNca = null;
-
if (!System.IO.Path.Exists(titleFilePath))
{
Logger.Error?.Print(LogClass.Application, $"File \"{titleFilePath}\" does not exist.");
return string.Empty;
}
+
+ using FileStream file = new(titleFilePath, FileMode.Open, FileAccess.Read);
+
+ Nca mainNca = null;
+ Nca patchNca = null;
string extension = System.IO.Path.GetExtension(titleFilePath).ToLower();
diff --git a/src/Ryujinx/Utilities/AppLibrary/ApplicationLibrary.cs b/src/Ryujinx/Utilities/AppLibrary/ApplicationLibrary.cs
index 7577b9f74..79cac1a0e 100644
--- a/src/Ryujinx/Utilities/AppLibrary/ApplicationLibrary.cs
+++ b/src/Ryujinx/Utilities/AppLibrary/ApplicationLibrary.cs
@@ -111,6 +111,67 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return data;
}
+ ///
+ /// Gets a name for an available content file based on the Application ID ''.
+ ///
+ /// For Applications, this returns the localized name of the app found in the file.
+ /// For DLCs, this returns the name of the file that contains the DLC, minus the file extension.
+ ///
+ /// The Application ID to search for.
+ ///
+ /// If the provided Application ID does not have a corresponding Application OR DLC file,
+ /// formatted as hexadecimal is returned.
+ ///
+ /// A formatted Application name, or as hexadecimal if none is found.
+ public string GetNameForApplicationId(ulong id)
+ {
+ DynamicData.Kernel.Optional appData = Applications.Lookup(id);
+ if (appData.HasValue)
+ return appData.Value.Name;
+
+ if (!DownloadableContents.Keys.FindFirst(x => x.TitleId == id).TryGet(out DownloadableContentModel dlcData))
+ return id.ToString("X16");
+
+ string name = Path.GetFileNameWithoutExtension(dlcData.FileName)!;
+ int idx = name.IndexOf('[');
+ if (idx != -1)
+ name = name[..idx];
+
+ return name;
+ }
+
+ public bool FindApplication(ulong id, out ApplicationData foundData)
+ {
+ DynamicData.Kernel.Optional appData = Applications.Lookup(id);
+ foundData = appData.HasValue ? appData.Value : null;
+
+ return appData.HasValue;
+ }
+
+ public bool FindUpdate(ulong id, out TitleUpdateModel foundData)
+ {
+ Gommon.Optional appData =
+ TitleUpdates.Keys.FindFirst(x => x.TitleId == id);
+ foundData = appData.HasValue ? appData.Value : null;
+
+ return appData.HasValue;
+ }
+
+ public TitleUpdateModel[] FindUpdatesFor(ulong id)
+ => TitleUpdates.Keys.Where(x => x.TitleIdBase == (id & ~0x1FFFUL)).ToArray();
+
+ public (TitleUpdateModel TitleUpdate, bool IsSelected)[] FindUpdateConfigurationFor(ulong id)
+ => TitleUpdates.Items.Where(x => x.TitleUpdate.TitleIdBase == (id & ~0x1FFFUL)).ToArray();
+
+ public DownloadableContentModel[] FindDlcsFor(ulong id)
+ => DownloadableContents.Keys.Where(x => x.TitleIdBase == (id & ~0x1FFFUL)).ToArray();
+
+ public (DownloadableContentModel Dlc, bool IsEnabled)[] FindDlcConfigurationFor(ulong id)
+ => DownloadableContents.Items.Where(x => x.Dlc.TitleIdBase == (id & ~0x1FFFUL)).ToArray();
+
+ public bool HasDlcs(ulong id)
+ => DownloadableContents.Keys.Any(x => x.TitleIdBase == (id & ~0x1FFFUL));
+
/// The configured key set is missing a key.
/// The NCA header could not be decrypted.
/// The NCA version is not supported.
diff --git a/src/Ryujinx/Utilities/AppletMetadata.cs b/src/Ryujinx/Utilities/AppletMetadata.cs
index a165487a3..50f01b4c0 100644
--- a/src/Ryujinx/Utilities/AppletMetadata.cs
+++ b/src/Ryujinx/Utilities/AppletMetadata.cs
@@ -45,7 +45,7 @@ namespace Ryujinx.Ava.Utilities
if (string.IsNullOrEmpty(contentPath))
goto BadData;
- appData = new() { Name = Name, Id = ProgramId, Path = GetContentPath(contentManager) };
+ appData = new() { Name = Name, Id = ProgramId, Path = contentPath };
appControl = StructHelpers.CreateCustomNacpData(Name, Version);
return true;
diff --git a/src/Ryujinx/Utilities/CommandLineState.cs b/src/Ryujinx/Utilities/CommandLineState.cs
index 96b5d1b86..3eafb8d01 100644
--- a/src/Ryujinx/Utilities/CommandLineState.cs
+++ b/src/Ryujinx/Utilities/CommandLineState.cs
@@ -10,6 +10,7 @@ namespace Ryujinx.Ava.Utilities
public static bool? OverrideDockedMode { get; private set; }
public static bool? OverrideHardwareAcceleration { get; private set; }
public static string OverrideGraphicsBackend { get; private set; }
+ public static string OverrideBackendThreading { get; private set; }
public static string OverrideHideCursor { get; private set; }
public static string BaseDirPathArg { get; private set; }
public static string Profile { get; private set; }
@@ -74,6 +75,16 @@ namespace Ryujinx.Ava.Utilities
OverrideGraphicsBackend = args[++i];
break;
+ case "--backend-threading":
+ if (i + 1 >= args.Length)
+ {
+ Logger.Error?.Print(LogClass.Application, $"Invalid option '{arg}'");
+
+ continue;
+ }
+
+ OverrideBackendThreading = args[++i];
+ break;
case "-i":
case "--application-id":
LaunchApplicationId = args[++i];
diff --git a/src/Ryujinx/Utilities/Compat/CompatibilityCsv.cs b/src/Ryujinx/Utilities/Compat/CompatibilityCsv.cs
index af80c5a28..b58c05299 100644
--- a/src/Ryujinx/Utilities/Compat/CompatibilityCsv.cs
+++ b/src/Ryujinx/Utilities/Compat/CompatibilityCsv.cs
@@ -47,11 +47,6 @@ namespace Ryujinx.Ava.Utilities.Compat
Logger.Debug?.Print(LogClass.UI, "Compatibility CSV loaded.", "LoadCompatibility");
}
- public static void Unload()
- {
- _entries = null;
- }
-
private static CompatibilityEntry[] _entries;
public static CompatibilityEntry[] Entries
@@ -64,6 +59,22 @@ namespace Ryujinx.Ava.Utilities.Compat
return _entries;
}
}
+
+ public static CompatibilityEntry Find(string titleId)
+ => Entries.FirstOrDefault(x => x.TitleId.HasValue && x.TitleId.Value.EqualsIgnoreCase(titleId));
+
+ public static CompatibilityEntry Find(ulong titleId)
+ => Find(titleId.ToString("X16"));
+
+ public static LocaleKeys? GetStatus(string titleId)
+ => Find(titleId)?.Status;
+
+ public static LocaleKeys? GetStatus(ulong titleId) => GetStatus(titleId.ToString("X16"));
+
+ public static string GetLabels(string titleId)
+ => Find(titleId)?.FormattedIssueLabels;
+
+ public static string GetLabels(ulong titleId) => GetLabels(titleId.ToString("X16"));
}
public class CompatibilityEntry
@@ -100,12 +111,25 @@ namespace Ryujinx.Ava.Utilities.Compat
public Optional TitleId { get; }
public string[] Labels { get; }
public LocaleKeys? Status { get; }
+
+ public LocaleKeys? StatusDescription
+ => Status switch
+ {
+ LocaleKeys.CompatibilityListPlayable => LocaleKeys.CompatibilityListPlayableTooltip,
+ LocaleKeys.CompatibilityListIngame => LocaleKeys.CompatibilityListIngameTooltip,
+ LocaleKeys.CompatibilityListMenus => LocaleKeys.CompatibilityListMenusTooltip,
+ LocaleKeys.CompatibilityListBoots => LocaleKeys.CompatibilityListBootsTooltip,
+ LocaleKeys.CompatibilityListNothing => LocaleKeys.CompatibilityListNothingTooltip,
+ _ => null
+ };
+
public DateTime LastUpdated { get; }
public string LocalizedLastUpdated =>
LocaleManager.FormatDynamicValue(LocaleKeys.CompatibilityListLastUpdated, LastUpdated.Humanize());
-
+
public string LocalizedStatus => LocaleManager.Instance[Status!.Value];
+ public string LocalizedStatusDescription => LocaleManager.Instance[StatusDescription!.Value];
public string FormattedTitleId => TitleId
.OrElse(new string(' ', 16));
@@ -113,20 +137,17 @@ namespace Ryujinx.Ava.Utilities.Compat
.Select(FormatLabelName)
.JoinToString(", ");
- public override string ToString()
- {
- StringBuilder sb = new("CompatibilityEntry: {");
- sb.Append($"{nameof(GameName)}=\"{GameName}\", ");
- sb.Append($"{nameof(TitleId)}={TitleId}, ");
- sb.Append($"{nameof(Labels)}={
- Labels.FormatCollection(it => $"\"{it}\"", separator: ", ", prefix: "[", suffix: "]")
- }, ");
- sb.Append($"{nameof(Status)}=\"{Status}\", ");
- sb.Append($"{nameof(LastUpdated)}=\"{LastUpdated}\"");
- sb.Append('}');
-
- return sb.ToString();
- }
+ public override string ToString() =>
+ new StringBuilder("CompatibilityEntry: {")
+ .Append($"{nameof(GameName)}=\"{GameName}\", ")
+ .Append($"{nameof(TitleId)}={TitleId}, ")
+ .Append($"{nameof(Labels)}={
+ Labels.FormatCollection(it => $"\"{it}\"", separator: ", ", prefix: "[", suffix: "]")
+ }, ")
+ .Append($"{nameof(Status)}=\"{Status}\", ")
+ .Append($"{nameof(LastUpdated)}=\"{LastUpdated}\"")
+ .Append('}')
+ .ToString();
public static string FormatLabelName(string labelName) => labelName.ToLower() switch
{
diff --git a/src/Ryujinx/Utilities/Compat/CompatibilityList.axaml b/src/Ryujinx/Utilities/Compat/CompatibilityList.axaml
index 73ec84c53..ef70a23d1 100644
--- a/src/Ryujinx/Utilities/Compat/CompatibilityList.axaml
+++ b/src/Ryujinx/Utilities/Compat/CompatibilityList.axaml
@@ -34,7 +34,7 @@
Text="{ext:Locale CompatibilityListWarning}" />
-
+
@@ -64,6 +64,8 @@
VerticalAlignment="Center"
Text="{Binding LocalizedStatus}"
Width="85"
+ Background="Transparent"
+ ToolTip.Tip="{Binding LocalizedStatusDescription}"
Foreground="{Binding Status, Converter={x:Static helpers:PlayabilityStatusConverter.Shared}}"
TextWrapping="NoWrap" />
/// The current version of the file format
///
- public const int CurrentVersion = 61;
+ public const int CurrentVersion = 67;
///
/// Version of the configuration file format
@@ -113,6 +111,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// Enables printing FS access log messages
///
public bool LoggingEnableFsAccessLog { get; set; }
+
+ ///
+ /// Enables log messages from Avalonia
+ ///
+ public bool LoggingEnableAvalonia { get; set; }
///
/// Controls which log messages are written to the log targets
@@ -143,6 +146,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// Change System Time Offset in seconds
///
public long SystemTimeOffset { get; set; }
+
+ ///
+ /// Instead of setting the time via configuration, use the values provided by the system.
+ ///
+ public bool MatchSystemTime { get; set; }
///
/// Enables or disables Docked Mode
@@ -155,9 +163,19 @@ namespace Ryujinx.Ava.Utilities.Configuration
public bool EnableDiscordIntegration { get; set; }
///
- /// Checks for updates when Ryujinx starts when enabled
+ /// DEPRECATED: Checks for updates when Ryujinx starts when enabled
///
public bool CheckUpdatesOnStart { get; set; }
+
+ ///
+ /// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
+ ///
+ public UpdaterType UpdateCheckerType { get; set; }
+
+ ///
+ /// How the emulator should behave when you click off/on the window.
+ ///
+ public FocusLostType FocusLostActionType { get; set; }
///
/// Show "Confirm Exit" Dialog
@@ -370,30 +388,26 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// Enable or disable mouse support (Independent from controllers binding)
///
public bool EnableMouse { get; set; }
+
+ ///
+ /// Enable/disable the ability to control Ryujinx when it's not the currently focused window.
+ ///
+ public bool DisableInputWhenOutOfFocus { get; set; }
///
/// Hotkey Keyboard Bindings
///
public KeyboardHotkeys Hotkeys { get; set; }
- ///
- /// Legacy keyboard control bindings
- ///
- /// Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)
- /// TODO: Remove this when those older versions aren't in use anymore.
- public List KeyboardConfig { get; set; }
-
- ///
- /// Legacy controller control bindings
- ///
- /// Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)
- /// TODO: Remove this when those older versions aren't in use anymore.
- public List ControllerConfig { get; set; }
-
///
/// Input configurations
///
public List InputConfig { get; set; }
+
+ ///
+ /// The speed of spectrum cycling for the Rainbow LED feature.
+ ///
+ public float RainbowSpeed { get; set; }
///
/// Graphics backend
diff --git a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs
index 3ccac2647..6bca36340 100644
--- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs
+++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Migration.cs
@@ -45,6 +45,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
EnableDiscordIntegration.Value = cff.EnableDiscordIntegration;
CheckUpdatesOnStart.Value = cff.CheckUpdatesOnStart;
+ UpdateCheckerType.Value = cff.UpdateCheckerType;
+ FocusLostActionType.Value = cff.FocusLostActionType;
ShowConfirmExit.Value = cff.ShowConfirmExit;
RememberWindowState.Value = cff.RememberWindowState;
ShowTitleBar.Value = cff.ShowTitleBar;
@@ -138,8 +140,10 @@ namespace Ryujinx.Ava.Utilities.Configuration
Hid.EnableKeyboard.Value = cff.EnableKeyboard;
Hid.EnableMouse.Value = cff.EnableMouse;
+ Hid.DisableInputWhenOutOfFocus.Value = cff.DisableInputWhenOutOfFocus;
Hid.Hotkeys.Value = cff.Hotkeys;
Hid.InputConfig.Value = cff.InputConfig ?? [];
+ Hid.RainbowSpeed.Value = cff.RainbowSpeed;
Multiplayer.LanInterfaceId.Value = cff.MultiplayerLanInterfaceId;
Multiplayer.Mode.Value = cff.MultiplayerMode;
@@ -427,7 +431,13 @@ namespace Ryujinx.Ava.Utilities.Configuration
LedColor = new Color(255, 5, 1, 253).ToUInt32()
};
}
- })
+ }),
+ (62, static cff => cff.RainbowSpeed = 1f),
+ (63, static cff => cff.MatchSystemTime = false),
+ (64, static cff => cff.LoggingEnableAvalonia = false),
+ (65, static cff => cff.UpdateCheckerType = cff.CheckUpdatesOnStart ? UpdaterType.PromptAtStartup : UpdaterType.Off),
+ (66, static cff => cff.DisableInputWhenOutOfFocus = false),
+ (67, static cff => cff.FocusLostActionType = cff.DisableInputWhenOutOfFocus ? FocusLostType.BlockInput : FocusLostType.DoNothing)
);
}
}
diff --git a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs
index 2d77c139d..51c40cc99 100644
--- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs
+++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs
@@ -1,12 +1,14 @@
using ARMeilleure;
using Gommon;
using Ryujinx.Ava.Utilities.Configuration.System;
+using Ryujinx.Ava.Utilities.Configuration.UI;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Multiplayer;
using Ryujinx.Common.Helper;
using Ryujinx.Common.Logging;
+using Ryujinx.Common.Utilities;
using Ryujinx.HLE;
using System.Collections.Generic;
using System.Linq;
@@ -253,6 +255,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// Enables printing FS access log messages
///
public ReactiveObject EnableFsAccessLog { get; private set; }
+
+ ///
+ /// Enables log messages from Avalonia
+ ///
+ public ReactiveObject EnableAvaloniaLog { get; private set; }
///
/// Controls which log messages are written to the log targets
@@ -280,6 +287,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
EnableTrace = new ReactiveObject();
EnableGuest = new ReactiveObject();
EnableFsAccessLog = new ReactiveObject();
+ EnableAvaloniaLog = new ReactiveObject();
FilteredClasses = new ReactiveObject();
EnableFileLog = new ReactiveObject();
EnableFileLog.LogChangesToValue(nameof(EnableFileLog));
@@ -311,6 +319,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// System Time Offset in Seconds
///
public ReactiveObject SystemTimeOffset { get; private set; }
+
+ ///
+ /// Instead of setting the time via configuration, use the values provided by the system.
+ ///
+ public ReactiveObject MatchSystemTime { get; private set; }
///
/// Enables or disables Docked Mode
@@ -387,6 +400,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
TimeZone.LogChangesToValue(nameof(TimeZone));
SystemTimeOffset = new ReactiveObject();
SystemTimeOffset.LogChangesToValue(nameof(SystemTimeOffset));
+ MatchSystemTime = new ReactiveObject();
+ MatchSystemTime.LogChangesToValue(nameof(MatchSystemTime));
EnableDockedMode = new ReactiveObject();
EnableDockedMode.LogChangesToValue(nameof(EnableDockedMode));
EnablePtc = new ReactiveObject();
@@ -432,6 +447,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// Enable or disable mouse support (Independent from controllers binding)
///
public ReactiveObject EnableMouse { get; private set; }
+
+ ///
+ /// Enable/disable the ability to control Ryujinx when it's not the currently focused window.
+ ///
+ public ReactiveObject DisableInputWhenOutOfFocus { get; private set; }
///
/// Hotkey Keyboard Bindings
@@ -444,13 +464,21 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// TODO: Implement a ReactiveList class.
///
public ReactiveObject> InputConfig { get; private set; }
+
+ ///
+ /// The speed of spectrum cycling for the Rainbow LED feature.
+ ///
+ public ReactiveObject RainbowSpeed { get; }
public HidSection()
{
EnableKeyboard = new ReactiveObject();
EnableMouse = new ReactiveObject();
+ DisableInputWhenOutOfFocus = new ReactiveObject();
Hotkeys = new ReactiveObject();
InputConfig = new ReactiveObject>();
+ RainbowSpeed = new ReactiveObject();
+ RainbowSpeed.Event += (_, args) => Rainbow.Speed = args.NewValue;
}
}
@@ -746,6 +774,16 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// Checks for updates when Ryujinx starts when enabled
///
public ReactiveObject CheckUpdatesOnStart { get; private set; }
+
+ ///
+ /// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
+ ///
+ public ReactiveObject UpdateCheckerType { get; private set; }
+
+ ///
+ /// How the emulator should behave when you click off/on the window.
+ ///
+ public ReactiveObject FocusLostActionType { get; private set; }
///
/// Show "Confirm Exit" Dialog
@@ -783,6 +821,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
Hacks = new HacksSection();
EnableDiscordIntegration = new ReactiveObject();
CheckUpdatesOnStart = new ReactiveObject();
+ UpdateCheckerType = new ReactiveObject();
+ FocusLostActionType = new ReactiveObject();
ShowConfirmExit = new ReactiveObject();
RememberWindowState = new ReactiveObject();
ShowTitleBar = new ReactiveObject();
diff --git a/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs b/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs
index 80b3e5c03..774b9217e 100644
--- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs
+++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.cs
@@ -46,6 +46,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
LoggingEnableTrace = Logger.EnableTrace,
LoggingEnableGuest = Logger.EnableGuest,
LoggingEnableFsAccessLog = Logger.EnableFsAccessLog,
+ LoggingEnableAvalonia = Logger.EnableAvaloniaLog,
LoggingFilteredClasses = Logger.FilteredClasses,
LoggingGraphicsDebugLevel = Logger.GraphicsDebugLevel,
SystemLanguage = System.Language,
@@ -55,6 +56,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
DockedMode = System.EnableDockedMode,
EnableDiscordIntegration = EnableDiscordIntegration,
CheckUpdatesOnStart = CheckUpdatesOnStart,
+ UpdateCheckerType = UpdateCheckerType,
+ FocusLostActionType = FocusLostActionType,
ShowConfirmExit = ShowConfirmExit,
RememberWindowState = RememberWindowState,
ShowTitleBar = ShowTitleBar,
@@ -129,10 +132,10 @@ namespace Ryujinx.Ava.Utilities.Configuration
ShowConsole = UI.ShowConsole,
EnableKeyboard = Hid.EnableKeyboard,
EnableMouse = Hid.EnableMouse,
+ DisableInputWhenOutOfFocus = Hid.DisableInputWhenOutOfFocus,
Hotkeys = Hid.Hotkeys,
- KeyboardConfig = [],
- ControllerConfig = [],
InputConfig = Hid.InputConfig,
+ RainbowSpeed = Hid.RainbowSpeed,
GraphicsBackend = Graphics.GraphicsBackend,
PreferredGpu = Graphics.PreferredGpu,
MultiplayerLanInterfaceId = Multiplayer.LanInterfaceId,
@@ -166,6 +169,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
Logger.EnableTrace.Value = false;
Logger.EnableGuest.Value = true;
Logger.EnableFsAccessLog.Value = false;
+ Logger.EnableAvaloniaLog.Value = false;
Logger.FilteredClasses.Value = [];
Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None;
System.Language.Value = Language.AmericanEnglish;
@@ -174,7 +178,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
System.SystemTimeOffset.Value = 0;
System.EnableDockedMode.Value = true;
EnableDiscordIntegration.Value = true;
- CheckUpdatesOnStart.Value = true;
+ UpdateCheckerType.Value = UpdaterType.PromptAtStartup;
+ FocusLostActionType.Value = FocusLostType.DoNothing;
ShowConfirmExit.Value = true;
RememberWindowState.Value = true;
ShowTitleBar.Value = !OperatingSystem.IsWindows();
@@ -204,8 +209,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
Multiplayer.LanInterfaceId.Value = "0";
Multiplayer.Mode.Value = MultiplayerMode.Disabled;
Multiplayer.DisableP2p.Value = false;
- Multiplayer.LdnPassphrase.Value = "";
- Multiplayer.LdnServer.Value = "";
+ Multiplayer.LdnPassphrase.Value = string.Empty;
+ Multiplayer.LdnServer.Value = string.Empty;
UI.GuiColumns.FavColumn.Value = true;
UI.GuiColumns.IconColumn.Value = true;
UI.GuiColumns.AppColumn.Value = true;
@@ -243,6 +248,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
UI.WindowStartup.WindowMaximized.Value = false;
Hid.EnableKeyboard.Value = false;
Hid.EnableMouse.Value = false;
+ Hid.DisableInputWhenOutOfFocus.Value = false;
Hid.Hotkeys.Value = new KeyboardHotkeys
{
ToggleVSyncMode = Key.F1,
@@ -255,6 +261,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
VolumeUp = Key.Unbound,
VolumeDown = Key.Unbound,
};
+ Hid.RainbowSpeed.Value = 1f;
Hid.InputConfig.Value =
[
new StandardKeyboardInputConfig
diff --git a/src/Ryujinx/Utilities/Configuration/UI/FocusLostType.cs b/src/Ryujinx/Utilities/Configuration/UI/FocusLostType.cs
new file mode 100644
index 000000000..eea588539
--- /dev/null
+++ b/src/Ryujinx/Utilities/Configuration/UI/FocusLostType.cs
@@ -0,0 +1,15 @@
+using Ryujinx.Common.Utilities;
+using System.Text.Json.Serialization;
+
+namespace Ryujinx.Ava.Utilities.Configuration.UI
+{
+ [JsonConverter(typeof(TypedStringEnumConverter))]
+ public enum FocusLostType
+ {
+ DoNothing,
+ BlockInput,
+ MuteAudio,
+ BlockInputAndMuteAudio,
+ PauseEmulation
+ }
+}
diff --git a/src/Ryujinx/Utilities/Configuration/UI/UpdaterType.cs b/src/Ryujinx/Utilities/Configuration/UI/UpdaterType.cs
new file mode 100644
index 000000000..2ab17a497
--- /dev/null
+++ b/src/Ryujinx/Utilities/Configuration/UI/UpdaterType.cs
@@ -0,0 +1,13 @@
+using Ryujinx.Common.Utilities;
+using System.Text.Json.Serialization;
+
+namespace Ryujinx.Ava.Utilities.Configuration.UI
+{
+ [JsonConverter(typeof(TypedStringEnumConverter))]
+ public enum UpdaterType
+ {
+ Off,
+ PromptAtStartup,
+ CheckInBackground
+ }
+}
diff --git a/src/Ryujinx/Utilities/PlayReport/Analyzer.cs b/src/Ryujinx/Utilities/PlayReport/Analyzer.cs
new file mode 100644
index 000000000..51047cc32
--- /dev/null
+++ b/src/Ryujinx/Utilities/PlayReport/Analyzer.cs
@@ -0,0 +1,123 @@
+using Gommon;
+using Ryujinx.Ava.Utilities.AppLibrary;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Linq;
+
+namespace Ryujinx.Ava.Utilities.PlayReport
+{
+ ///
+ /// The entrypoint for the Play Report analysis system.
+ ///
+ public class Analyzer
+ {
+ private readonly List _specs = [];
+
+ public string[] TitleIds => Specs.SelectMany(x => x.TitleIds).ToArray();
+
+ public IReadOnlyList Specs => new ReadOnlyCollection(_specs);
+
+ ///
+ /// Add an analysis spec matching a specific game by title ID, with the provided spec configuration.
+ ///
+ /// The ID of the game to listen to Play Reports in.
+ /// The configuration function for the analysis spec.
+ /// The current , for chaining convenience.
+ public Analyzer AddSpec(string titleId, Func transform)
+ {
+ Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
+ $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
+
+ return AddSpec(transform(GameSpec.Create(titleId)));
+ }
+
+ ///
+ /// Add an analysis spec matching a specific game by title ID, with the provided spec configuration.
+ ///
+ /// The ID of the game to listen to Play Reports in.
+ /// The configuration function for the analysis spec.
+ /// The current , for chaining convenience.
+ public Analyzer AddSpec(string titleId, Action transform)
+ {
+ Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
+ $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
+
+ return AddSpec(GameSpec.Create(titleId).Apply(transform));
+ }
+
+ ///
+ /// Add an analysis spec matching a specific set of games by title IDs, with the provided spec configuration.
+ ///
+ /// The IDs of the games to listen to Play Reports in.
+ /// The configuration function for the analysis spec.
+ /// The current , for chaining convenience.
+ public Analyzer AddSpec(IEnumerable titleIds,
+ Func transform)
+ {
+ string[] tids = titleIds.ToArray();
+ Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
+ $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
+
+ return AddSpec(transform(GameSpec.Create(tids)));
+ }
+
+ ///
+ /// Add an analysis spec matching a specific set of games by title IDs, with the provided spec configuration.
+ ///
+ /// The IDs of the games to listen to Play Reports in.
+ /// The configuration function for the analysis spec.
+ /// The current , for chaining convenience.
+ public Analyzer AddSpec(IEnumerable titleIds, Action transform)
+ {
+ string[] tids = titleIds.ToArray();
+ Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
+ $"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
+
+ return AddSpec(GameSpec.Create(tids).Apply(transform));
+ }
+
+ ///
+ /// Add an analysis spec matching a specific game by title ID, with the provided pre-configured spec.
+ ///
+ /// The to add.
+ /// The current , for chaining convenience.
+ public Analyzer AddSpec(GameSpec spec)
+ {
+ _specs.Add(spec);
+ return this;
+ }
+
+
+ ///
+ /// Runs the configured for the specified game title ID.
+ ///
+ /// The game currently running.
+ /// The Application metadata information, including localized game name and play time information.
+ /// The Play Report received from HLE.
+ /// A struct representing a possible formatted value.
+ public FormattedValue Format(
+ string runningGameId,
+ ApplicationMetadata appMeta,
+ Horizon.Prepo.Types.PlayReport playReport
+ )
+ {
+ if (!playReport.ReportData.IsDictionary)
+ return FormattedValue.Unhandled;
+
+ if (!_specs.TryGetFirst(s => runningGameId.EqualsAnyIgnoreCase(s.TitleIds), out GameSpec spec))
+ return FormattedValue.Unhandled;
+
+ foreach (FormatterSpecBase formatSpec in spec.ValueFormatters.OrderBy(x => x.Priority))
+ {
+ if (!formatSpec.Format(appMeta, playReport, out FormattedValue value))
+ continue;
+
+ return value;
+ }
+
+ return FormattedValue.Unhandled;
+ }
+ }
+}
diff --git a/src/Ryujinx/Utilities/PlayReport/Delegates.cs b/src/Ryujinx/Utilities/PlayReport/Delegates.cs
new file mode 100644
index 000000000..92569d32e
--- /dev/null
+++ b/src/Ryujinx/Utilities/PlayReport/Delegates.cs
@@ -0,0 +1,40 @@
+namespace Ryujinx.Ava.Utilities.PlayReport
+{
+ ///
+ /// The delegate type that powers single value formatters.
+ /// Takes in the result value from the Play Report, and outputs:
+ ///
+ /// a formatted string,
+ ///
+ /// a signal that nothing was available to handle it,
+ ///
+ /// OR a signal to reset the value that the caller is using the for.
+ ///
+ public delegate FormattedValue SingleValueFormatter(SingleValue value);
+
+ ///
+ /// The delegate type that powers multiple value formatters.
+ /// Takes in the result values from the Play Report, and outputs:
+ ///
+ /// a formatted string,
+ ///
+ /// a signal that nothing was available to handle it,
+ ///
+ /// OR a signal to reset the value that the caller is using the for.
+ ///
+ public delegate FormattedValue MultiValueFormatter(MultiValue value);
+
+ ///
+ /// The delegate type that powers multiple value formatters.
+ /// The dictionary passed to this delegate is sparsely populated;
+ /// that is, not every key specified in the Play Report needs to match for this to be used.
+ /// Takes in the result values from the Play Report, and outputs:
+ ///
+ /// a formatted string,
+ ///
+ /// a signal that nothing was available to handle it,
+ ///
+ /// OR a signal to reset the value that the caller is using the for.
+ ///
+ public delegate FormattedValue SparseMultiValueFormatter(SparseMultiValue value);
+}
diff --git a/src/Ryujinx/Utilities/PlayReport/MatchedValues.cs b/src/Ryujinx/Utilities/PlayReport/MatchedValues.cs
new file mode 100644
index 000000000..46cae678a
--- /dev/null
+++ b/src/Ryujinx/Utilities/PlayReport/MatchedValues.cs
@@ -0,0 +1,73 @@
+using MsgPack;
+using Ryujinx.Ava.Utilities.AppLibrary;
+using System.Collections.Generic;
+
+namespace Ryujinx.Ava.Utilities.PlayReport
+{
+ public abstract class MatchedValue
+ {
+ protected MatchedValue(T matched)
+ {
+ Matched = matched;
+ }
+
+ ///
+ /// The currently running application's .
+ ///
+ public ApplicationMetadata Application { get; init; }
+
+ ///
+ /// The entire play report.
+ ///
+ public Horizon.Prepo.Types.PlayReport PlayReport { get; init; }
+
+ ///
+ /// The matched value from the Play Report.
+ ///
+ public T Matched { get; init; }
+ }
+
+ ///
+ /// The input data to a ,
+ /// containing the currently running application's ,
+ /// and the matched from the Play Report.
+ ///
+ public class SingleValue : MatchedValue
+ {
+ public SingleValue(Value matched) : base(matched)
+ {
+ }
+ }
+
+ ///
+ /// The input data to a ,
+ /// containing the currently running application's ,
+ /// and the matched s from the Play Report.
+ ///
+ public class MultiValue : MatchedValue
+ {
+ public MultiValue(Value[] matched) : base(matched)
+ {
+ }
+
+ public MultiValue(IEnumerable matched) : base(Value.ConvertPackedObjects(matched))
+ {
+ }
+ }
+
+ ///
+ /// The input data to a ,
+ /// containing the currently running application's ,
+ /// and the matched s from the Play Report.
+ ///
+ public class SparseMultiValue : MatchedValue>
+ {
+ public SparseMultiValue(Dictionary matched) : base(matched)
+ {
+ }
+
+ public SparseMultiValue(Dictionary matched) : base(Value.ConvertPackedObjectMap(matched))
+ {
+ }
+ }
+}
diff --git a/src/Ryujinx/Utilities/PlayReport/PlayReports.Formatters.cs b/src/Ryujinx/Utilities/PlayReport/PlayReports.Formatters.cs
new file mode 100644
index 000000000..cabace6bb
--- /dev/null
+++ b/src/Ryujinx/Utilities/PlayReport/PlayReports.Formatters.cs
@@ -0,0 +1,632 @@
+using Gommon;
+using System;
+using System.Buffers.Binary;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Ryujinx.Ava.Utilities.PlayReport
+{
+ public partial class PlayReports
+ {
+ private static FormattedValue BreathOfTheWild_MasterMode(SingleValue value)
+ => value.Matched.BoxedValue is 1 ? "Playing Master Mode" : FormattedValue.ForceReset;
+
+ private static FormattedValue TearsOfTheKingdom_CurrentField(SingleValue value) =>
+ value.Matched.DoubleValue switch
+ {
+ > 800d => "Exploring the Sky Islands",
+ < -201d => "Exploring the Depths",
+ _ => "Roaming Hyrule"
+ };
+
+ private static FormattedValue SuperMarioOdyssey_AssistMode(SingleValue value)
+ => value.Matched.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode";
+
+ private static FormattedValue SuperMarioOdysseyChina_AssistMode(SingleValue value)
+ => value.Matched.BoxedValue is 1 ? "Playing in 帮助模式" : "Playing in 普通模式";
+
+ private static FormattedValue SuperMario3DWorldOrBowsersFury(SingleValue value)
+ => value.Matched.BoxedValue is 0 ? "Playing Super Mario 3D World" : "Playing Bowser's Fury";
+
+ private static FormattedValue MarioKart8Deluxe_Mode(SingleValue value)
+ => value.Matched.StringValue switch
+ {
+ // Single Player
+ "Single" => "Single Player",
+ // Multiplayer
+ "Multi-2players" => "Multiplayer 2 Players",
+ "Multi-3players" => "Multiplayer 3 Players",
+ "Multi-4players" => "Multiplayer 4 Players",
+ // Wireless/LAN Play
+ "Local-Single" => "Wireless/LAN Play",
+ "Local-2players" => "Wireless/LAN Play 2 Players",
+ // CC Classes
+ "50cc" => "50cc",
+ "100cc" => "100cc",
+ "150cc" => "150cc",
+ "Mirror" => "Mirror (150cc)",
+ "200cc" => "200cc",
+ // Modes
+ "GrandPrix" => "Grand Prix",
+ "TimeAttack" => "Time Trials",
+ "VS" => "VS Races",
+ "Battle" => "Battle Mode",
+ "RaceStart" => "Selecting a Course",
+ "Race" => "Racing",
+ _ => FormattedValue.ForceReset
+ };
+
+ private static FormattedValue PokemonSVUnionCircle(SingleValue value)
+ => value.Matched.BoxedValue is 0 ? "Playing Alone" : "Playing in a group";
+
+ private static FormattedValue PokemonSVArea(SingleValue value)
+ => value.Matched.StringValue switch
+ {
+ // Base Game Locations
+ "a_w01" => "South Area One",
+ "a_w02" => "Mesagoza",
+ "a_w03" => "The Pokemon League",
+ "a_w04" => "South Area Two",
+ "a_w05" => "South Area Four",
+ "a_w06" => "South Area Six",
+ "a_w07" => "South Area Five",
+ "a_w08" => "South Area Three",
+ "a_w09" => "West Area One",
+ "a_w10" => "Asado Desert",
+ "a_w11" => "West Area Two",
+ "a_w12" => "Medali",
+ "a_w13" => "Tagtree Thicket",
+ "a_w14" => "East Area Three",
+ "a_w15" => "Artazon",
+ "a_w16" => "East Area Two",
+ "a_w18" => "Casseroya Lake",
+ "a_w19" => "Glaseado Mountain",
+ "a_w20" => "North Area Three",
+ "a_w21" => "North Area One",
+ "a_w22" => "North Area Two",
+ "a_w23" => "The Great Crater of Paldea",
+ "a_w24" => "South Paldean Sea",
+ "a_w25" => "West Paldean Sea",
+ "a_w26" => "East Paldean Sea",
+ "a_w27" => "Nouth Paldean Sea",
+ //TODO DLC Locations
+ _ => FormattedValue.ForceReset
+ };
+
+ private static FormattedValue SuperSmashBrosUltimate_Mode(SparseMultiValue values)
+ {
+ // Check if the PlayReport is for a challenger approach or an achievement.
+ if (values.Matched.TryGetValue("fighter", out Value fighter) && values.Matched.ContainsKey("reason"))
+ {
+ return $"Challenger Approaches - {SuperSmashBrosUltimate_Character(fighter)}";
+ }
+
+ if (values.Matched.TryGetValue("fighter", out fighter) && values.Matched.ContainsKey("challenge_count"))
+ {
+ return $"Fighter Unlocked - {SuperSmashBrosUltimate_Character(fighter)}";
+ }
+
+ if (values.Matched.TryGetValue("anniversary", out Value anniversary))
+ {
+ return $"Achievement Unlocked - ID: {anniversary}";
+ }
+
+ if (values.Matched.ContainsKey("adv_slot"))
+ {
+ return
+ "Playing Adventure Mode"; // Doing this as it can be a placeholder until we can grab the character.
+ }
+
+ // Check if we have a match_mode at this point, if not, go to default.
+ if (!values.Matched.TryGetValue("match_mode", out Value matchMode))
+ {
+ return "Smashing";
+ }
+
+ return matchMode.BoxedValue switch
+ {
+ 0 when values.Matched.TryGetValue("player_1_fighter", out Value player) &&
+ values.Matched.TryGetValue("player_2_fighter", out Value challenger)
+ => $"Last Smashed: {SuperSmashBrosUltimate_Character(challenger)}'s Fighter Challenge - {SuperSmashBrosUltimate_Character(player)}",
+ 1 => $"Last Smashed: Normal Battle - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 2 when values.Matched.TryGetValue("player_1_rank", out Value team)
+ => team.BoxedValue is 0
+ ? "Last Smashed: Squad Strike - Red Team Wins"
+ : "Last Smashed: Squad Strike - Blue Team Wins",
+ 3 => $"Last Smashed: Custom Smash - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 4 => $"Last Smashed: Super Sudden Death - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 5 => $"Last Smashed: Smashdown - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 6 => $"Last Smashed: Tourney Battle - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 7 when values.Matched.TryGetValue("player_1_fighter", out Value player)
+ => $"Last Smashed: Spirit Board Battle as {SuperSmashBrosUltimate_Character(player)}",
+ 8 when values.Matched.TryGetValue("player_1_fighter", out Value player)
+ => $"Playing Adventure Mode as {SuperSmashBrosUltimate_Character(player)}",
+ 10 when values.Matched.TryGetValue("match_submode", out Value battle) &&
+ values.Matched.TryGetValue("player_1_fighter", out Value player)
+ => $"Last Smashed: Classic Mode, Battle {(int)battle.BoxedValue + 1}/8 as {SuperSmashBrosUltimate_Character(player)}",
+ 12 => $"Last Smashed: Century Smash - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 13 => $"Last Smashed: All-Star Smash - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 14 => $"Last Smashed: Cruel Smash - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 15 when values.Matched.TryGetValue("player_1_fighter", out Value player)
+ => $"Last Smashed: Home-Run Contest - {SuperSmashBrosUltimate_Character(player)}",
+ 16 when values.Matched.TryGetValue("player_1_fighter", out Value player1) &&
+ values.Matched.TryGetValue("player_2_fighter", out Value player2)
+ => $"Last Smashed: Home-Run Content (Co-op) - {SuperSmashBrosUltimate_Character(player1)} and {SuperSmashBrosUltimate_Character(player2)}",
+ 17 => $"Last Smashed: Home-Run Contest (Versus) - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 18 when values.Matched.TryGetValue("player_1_fighter", out Value player1) &&
+ values.Matched.TryGetValue("player_2_fighter", out Value player2)
+ => $"Fresh out of Training mode - {SuperSmashBrosUltimate_Character(player1)} with {SuperSmashBrosUltimate_Character(player2)}",
+ 58 => $"Last Smashed: LDN Battle - {SuperSmashBrosUltimate_PlayerListing(values)}",
+ 63 when values.Matched.TryGetValue("player_1_fighter", out Value player)
+ => $"Last Smashed: DLC Spirit Board Battle as {SuperSmashBrosUltimate_Character(player)}",
+ _ => "Smashing"
+ };
+ }
+
+ private static string SuperSmashBrosUltimate_Character(Value value) =>
+ BinaryPrimitives.ReverseEndianness(
+ BitConverter.ToInt64(((MsgPack.MessagePackExtendedTypeObject)value.BoxedValue).GetBody(), 0)) switch
+ {
+ 0x0 => "Mario",
+ 0x1 => "Donkey Kong",
+ 0x2 => "Link",
+ 0x3 => "Samus",
+ 0x4 => "Dark Samus",
+ 0x5 => "Yoshi",
+ 0x6 => "Kirby",
+ 0x7 => "Fox",
+ 0x8 => "Pikachu",
+ 0x9 => "Luigi",
+ 0xA => "Ness",
+ 0xB => "Captain Falcon",
+ 0xC => "Jigglypuff",
+ 0xD => "Peach",
+ 0xE => "Daisy",
+ 0xF => "Bowser",
+ 0x10 => "Ice Climbers",
+ 0x11 => "Sheik",
+ 0x12 => "Zelda",
+ 0x13 => "Dr. Mario",
+ 0x14 => "Pichu",
+ 0x15 => "Falco",
+ 0x16 => "Marth",
+ 0x17 => "Lucina",
+ 0x18 => "Young Link",
+ 0x19 => "Ganondorf",
+ 0x1A => "Mewtwo",
+ 0x1B => "Roy",
+ 0x1C => "Chrom",
+ 0x1D => "Mr Game & Watch",
+ 0x1E => "Meta Knight",
+ 0x1F => "Pit",
+ 0x20 => "Dark Pit",
+ 0x21 => "Zero Suit Samus",
+ 0x22 => "Wario",
+ 0x23 => "Snake",
+ 0x24 => "Ike",
+ 0x25 => "Pokémon Trainer",
+ 0x26 => "Diddy Kong",
+ 0x27 => "Lucas",
+ 0x28 => "Sonic",
+ 0x29 => "King Dedede",
+ 0x2A => "Olimar",
+ 0x2B => "Lucario",
+ 0x2C => "R.O.B.",
+ 0x2D => "Toon Link",
+ 0x2E => "Wolf",
+ 0x2F => "Villager",
+ 0x30 => "Mega Man",
+ 0x31 => "Wii Fit Trainer",
+ 0x32 => "Rosalina & Luma",
+ 0x33 => "Little Mac",
+ 0x34 => "Greninja",
+ 0x35 => "Palutena",
+ 0x36 => "Pac-Man",
+ 0x37 => "Robin",
+ 0x38 => "Shulk",
+ 0x39 => "Bowser Jr.",
+ 0x3A => "Duck Hunt",
+ 0x3B => "Ryu",
+ 0x3C => "Ken",
+ 0x3D => "Cloud",
+ 0x3E => "Corrin",
+ 0x3F => "Bayonetta",
+ 0x40 => "Richter",
+ 0x41 => "Inkling",
+ 0x42 => "Ridley",
+ 0x43 => "King K. Rool",
+ 0x44 => "Simon",
+ 0x45 => "Isabelle",
+ 0x46 => "Incineroar",
+ 0x47 => "Mii Brawler",
+ 0x48 => "Mii Swordfighter",
+ 0x49 => "Mii Gunner",
+ 0x4A => "Piranha Plant",
+ 0x4B => "Joker",
+ 0x4C => "Hero",
+ 0x4D => "Banjo",
+ 0x4E => "Terry",
+ 0x4F => "Byleth",
+ 0x50 => "Min Min",
+ 0x51 => "Steve",
+ 0x52 => "Sephiroth",
+ 0x53 => "Pyra/Mythra",
+ 0x54 => "Kazuya",
+ 0x55 => "Sora",
+ 0xFE => "Random",
+ 0xFF => "Scripted Entity",
+ _ => "Unknown"
+ };
+
+ private static string SuperSmashBrosUltimate_PlayerListing(SparseMultiValue values)
+ {
+ List<(string Character, int PlayerNumber, int? Rank)> players = [];
+
+ foreach (KeyValuePair player in values.Matched)
+ {
+ if (player.Key.StartsWith("player_") && player.Key.EndsWith("_fighter") &&
+ player.Value.BoxedValue is not null)
+ {
+ if (!int.TryParse(player.Key.Split('_')[1], out int playerNumber))
+ continue;
+
+ string character = SuperSmashBrosUltimate_Character(player.Value);
+ int? rank = values.Matched.TryGetValue($"player_{playerNumber}_rank", out Value rankValue)
+ ? rankValue.IntValue
+ : null;
+
+ players.Add((character, playerNumber, rank));
+ }
+ }
+
+ players = players.OrderBy(p => p.Rank ?? int.MaxValue).ToList();
+
+ return players.Count > 4
+ ? $"{players.Count} Players - {
+ players.Take(3)
+ .Select(p => $"{p.Character}({p.PlayerNumber}){RankMedal(p.Rank)}")
+ .JoinToString(", ")
+ }"
+ : players
+ .Select(p => $"{p.Character}({p.PlayerNumber}){RankMedal(p.Rank)}")
+ .JoinToString(", ");
+
+ string RankMedal(int? rank) => rank switch
+ {
+ 0 => "🥇",
+ 1 => "🥈",
+ 2 => "🥉",
+ _ => ""
+ };
+ }
+
+ private static FormattedValue NsoEmulator_LaunchedGame(SingleValue value) => value.Matched.StringValue switch
+ {
+ #region SEGA Genesis
+
+ "m_0054_e" => Playing("Alien Soldier"),
+ "m_3978_e" => Playing("Alien Storm"),
+ "m_5234_e" => Playing("ALISIA DRAGOON"),
+ "m_5003_e" => Playing("Streets of Rage 2"),
+ "m_4843_e" => Playing("Kid Chameleon"),
+ "m_2874_e" => Playing("Columns"),
+ "m_3167_e" => Playing("Comix Zone"),
+ "m_5007_e" => Playing("Contra: Hard Corps"),
+ "m_0865_e" => Playing("Ghouls 'n Ghosts"),
+ "m_0935_e" => Playing("Dynamite Headdy"),
+ "m_8314_e" => Playing("Earthworm Jim"),
+ "m_5012_e" => Playing("Ecco the Dolphin"),
+ "m_2207_e" => Playing("Flicky"),
+ "m_9432_e" => Playing("Golden Axe II"),
+ "m_5015_e" => Playing("Golden Axe"),
+ "m_5017_e" => Playing("Gunstar Heroes"),
+ "m_0732_e" => Playing("Altered Beast"),
+ "m_2245_e" or "m_2245_pd" or "m_2245_pf" => Playing("Landstalker"),
+ "m_1654_e" => Playing("Target Earth"),
+ "m_7050_e" => Playing("Light Crusader"),
+ "m_5027_e" => Playing("M.U.S.H.A."),
+ "m_5028_e" => Playing("Phantasy Star IV"),
+ "m_9155_e" => Playing("Pulseman"),
+ "m_5030_e" => Playing("Dr. Robotnik's Mean Bean Machine"),
+ "m_0098_e" => Playing("Crusader of Centy"),
+ "m_0098_k" => Playing("신창세기 라그나센티"),
+ "m_0098_pd" or "m_0098_pf" or "m_0098_ps" => Playing("Soleil"),
+ "m_5033_e" => Playing("Ristar"),
+ "m_1987_e" => Playing("MEGA MAN: THE WILY WARS"),
+ "m_2609_e" => Playing("WOLF OF THE BATTLEFIELD: MERCS"),
+ "m_3353_e" => Playing("Shining Force II"),
+ "m_5036_e" => Playing("Shining Force"),
+ "m_9866_e" => Playing("Sonic The Hedgehog Spinball"),
+ "m_5041_e" => Playing("Sonic The Hedgehog 2"),
+ "m_5523_e" => Playing("Space Harrier II"),
+ "m_0041_e" => Playing("STREET FIGHTER II' : SPECIAL CHAMPION EDITION"),
+ "m_5044_e" => Playing("STRIDER"),
+ "m_6353_e" => Playing("Super Fantasy Zone"),
+ "m_9569_e" => Playing("Beyond Oasis"),
+ "m_9569_k" => Playing("스토리 오브 도어"),
+ "m_9569_pd" or "m_9569_ps" => Playing("The Story of Thor"),
+ "m_9569_pf" => Playing("La Légende de Thor"),
+ "m_5049_e" => Playing("Shinobi III: Return of the Ninja Master"),
+ "m_6811_e" => Playing("The Revenge of Shinobi"),
+ "m_4372_e" => Playing("Thunder Force II"),
+ "m_1535_e" => Playing("ToeJam & Earl in Panic on Funkotron"),
+ "m_0432_e" => Playing("ToeJam & Earl"),
+ "m_5052_e" => Playing("Castlevania: BLOODLINES"),
+ "m_3626_e" => Playing("VectorMan"),
+ "m_7955_e" => Playing("Sword of Vermilion"),
+ "m_0394_e" => Playing("Virtua Fighter 2"),
+ "m_9417_e" => Playing("Zero Wing"),
+
+ #endregion
+
+ #region Nintendo 64
+
+ "n_1653_e" or "n_1653_p" => Playing("1080º ™ Snowboarding"),
+ "n_4868_e" or "n_4868_p" => Playing("Banjo Kazooie™"),
+ "n_1226_e" or "n_1226_p" => Playing("Banjo-Tooie™"),
+ "n_3083_e" or "n_3083_p" => Playing("Blast Corps"),
+ "n_3007_e" => Playing("Dr. Mario™ 64"),
+ "n_4238_e" => Playing("Excitebike™ 64"),
+ "n_1870_e" => Playing("Extreme G"),
+ "n_2456_e" => Playing("F-Zero™ X"),
+ "n_4631_e" => Playing("GoldenEye 007"),
+ "n_1635_e" => Playing("Harvest Moon 64"),
+ "n_2225_e" => Playing("Iggy’s Reckin’ Balls"),
+ "n_1625_e" or "n_1625_p" => Playing("JET FORCE GEMINI™"),
+ "n_3052_e" => Playing("Kirby 64™: The Crystal Shards"),
+ "n_4371_e" => Playing("Mario Golf™"),
+ "n_3013_e" => Playing("Mario Kart™ 64"),
+ "n_1053_e" or "n_1053_p" => Playing("Mario Party™ 2"),
+ "n_2965_e" or "n_2965_p" => Playing("Mario Party™ 3"),
+ "n_4737_e" or "n_4737_p" => Playing("Mario Party™"),
+ "n_3017_e" => Playing("Mario Tennis™"),
+ "n_2992_e" or "n_2992_p" => Playing("Paper Mario™"),
+ "n_3783_e" or "n_3783_p" => Playing("Pilotwings™ 64"),
+ "n_1848_e" or "n_1848_pd" or "n_1848_pf" => Playing("Pokémon™ Puzzle League"),
+ "n_3240_e" or "n_3240_pd" or "n_3240_pf" or "n_3240_pi" or "n_3240_ps" => Playing("Pokémon Snap™"),
+ "n_4590_e" or "n_4590_pd" or "n_4590_pf" or "n_4590_pi" or "n_4590_ps" => Playing("Pokémon Stadium™"),
+ "n_3309_e" or "n_3309_pd" or "n_3309_pf" or "n_3309_pi" or "n_3309_ps" => Playing("Pokémon Stadium 2™"),
+ "n_3029_e" => Playing("Sin & Punishment™"),
+ "n_3030_e" => Playing("Star Fox™ 64"),
+ "n_3030_p" => Playing("Lylat Wars™"),
+ "n_3031_e" or "n_3031_p" => Playing("Super Mario 64™"),
+ "n_4813_e" or "n_4813_p" => Playing("Wave Race™ 64"),
+ "n_3034_e" => Playing("WIN BACK: COVERT OPERATIONS"),
+ "n_3034_p" => Playing("OPERATION: WIN BACK"),
+ "n_3036_e" or "n_3036_p" => Playing("Yoshi's Story™"),
+ "n_1407_e" or "n_1407_p" => Playing("The Legend of Zelda™: Majora's Mask™"),
+ "n_3038_e" or "n_3038_p" => Playing("The Legend of Zelda™: Ocarina of Time™"),
+
+ #endregion
+
+ #region NES
+
+ "clv_p_naaae" => Playing("Super Mario Bros.™"),
+ "clv_p_naabe" => Playing("Super Mario Bros.™: The Lost Levels"),
+ "clv_p_naace" or "clv_p_naace_sp1" => Playing("Super Mario Bros.™ 3"),
+ "clv_p_naade" => Playing("Super Mario Bros.™ 2"),
+ "clv_p_naaee" => Playing("Donkey Kong™"),
+ "clv_p_naafe" => Playing("Donkey Kong Jr.™"),
+ "clv_p_naage" => Playing("Donkey Kong™ 3"),
+ "clv_p_naahe" => Playing("Excitebike™"),
+ "clv_p_naaje" => Playing("EarthBound Beginnings"),
+ "clv_p_naame" => Playing("NES™ Open Tournament Golf"),
+ "clv_p_naane" or "clv_p_naane_sp1" => Playing("The Legend of Zelda™"),
+ "clv_p_naape" or "clv_p_naape_sp1" => Playing("Kirby's Adventure™"),
+ "clv_p_naaqe" or "clv_p_naaqe_sp1" or "clv_p_naaqe_sp2" => Playing("Metroid™"),
+ "clv_p_naare" => Playing("Balloon Fight™"),
+ "clv_p_naase" or "clv_p_naase_sp1" => Playing("Zelda II - The Adventure of Link™"),
+ "clv_p_naate" => Playing("Punch-Out!!™ Featuring Mr. Dream"),
+ "clv_p_naaue" => Playing("Ice Climber™"),
+ "clv_p_naave" or "clv_p_naave_sp1" => Playing("Kid Icarus™"),
+ "clv_p_naawe" => Playing("Mario Bros.™"),
+ "clv_p_naaxe" or "clv_p_naaxe_sp1" => Playing("Dr. Mario™"),
+ "clv_p_naaye" => Playing("Yoshi™"),
+ "clv_p_naaze" => Playing("StarTropics™"),
+ "clv_p_nabce" or "clv_p_nabce_sp1" => Playing("Ghosts'n Goblins™"),
+ "clv_p_nabre" or "clv_p_nabre_sp1" or "clv_p_nabre_sp2" => Playing("Gradius"),
+ "clv_p_nacbe" or "clv_p_nacbe_sp1" => Playing("Ninja Gaiden"),
+ "clv_p_nacce" => Playing("Solomon's Key"),
+ "clv_p_nacde" => Playing("Tecmo Bowl"),
+ "clv_p_nacfe" => Playing("Double Dragon"),
+ "clv_p_nache" => Playing("Double Dragon II: The Revenge"),
+ "clv_p_nacje" => Playing("River City Ransom"),
+ "clv_p_nacke" => Playing("Super Dodge Ball"),
+ "clv_p_nacle" => Playing("Downtown Nekketsu March Super-Awesome Field Day!"),
+ "clv_p_nacpe" => Playing("The Mystery of Atlantis"),
+ "clv_p_nacre" => Playing("Soccer"),
+ "clv_p_nacse" or "clv_p_nacse_sp1" => Playing("Ninja JaJaMaru-kun"),
+ "clv_p_nacte" => Playing("Ice Hockey"),
+ "clv_p_nacue" or "clv_p_nacue_sp1" => Playing("Blaster Master"),
+ "clv_p_nacwe" => Playing("ADVENTURES OF LOLO"),
+ "clv_p_nacxe" => Playing("Wario's Woods™"),
+ "clv_p_nacye" => Playing("Tennis"),
+ "clv_p_nacze" => Playing("Wrecking Crew™"),
+ "clv_p_nadbe" => Playing("Joy Mech Fight™"),
+ "clv_p_nadde" or "clv_p_nadde_sp1" => Playing("Star Soldier"),
+ "clv_p_nadke" => Playing("Tetris®"),
+ "clv_p_nadle" => Playing("Pro Wrestling"),
+ "clv_p_nadpe" => Playing("Baseball"),
+ "clv_p_nadte" or "clv_p_nadte_sp1" => Playing("TwinBee"),
+ "clv_p_nadue" or "clv_p_nadue_sp1" => Playing("Mighty Bomb Jack"),
+ "clv_p_nadve" => Playing("Kung-Fu Heroes"),
+ "clv_p_nadxe" => Playing("City Connection"),
+ "clv_p_nadye" => Playing("Rygar"),
+ "clv_p_naeae" => Playing("Crystalis"),
+ "clv_p_naece" => Playing("Vice: Project Doom"),
+ "clv_p_naehe" => Playing("Clu Clu Land™"),
+ "clv_p_naeie" => Playing("VS. Excitebike™"),
+ "clv_p_naeje" => Playing("Volleyball™"),
+ "clv_p_naeke" => Playing("JOURNEY TO SILIUS"),
+ "clv_p_naele" => Playing("S.C.A.T.: Special Cybernetic Attack Team"),
+ "clv_p_naeme" => Playing("Shadow of the Ninja"),
+ "clv_p_naene" => Playing("Nightshade"),
+ "clv_p_naepe" => Playing("The Immortal"),
+ "clv_p_naeqe" => Playing("Eliminator Boat Duel"),
+ "clv_p_naere" => Playing("Fire 'n Ice"),
+ "clv_p_nafce" => Playing("XEVIOUS"),
+ "clv_p_nagpe" => Playing("DAIVA STORY 6 IMPERIAL OF NIRSARTIA"),
+ "clv_p_nagqe" => Playing("DIG DUGⅡ"),
+ "clv_p_nague" => Playing("MAPPY-LAND"),
+ "clv_p_nahhe" => Playing("Mach Rider™"),
+ "clv_p_nahje" => Playing("Pinball"),
+ "clv_p_nahre" => Playing("Mystery Tower"),
+ "clv_p_nahte" => Playing("Urban Champion™"),
+ "clv_p_nahue" => Playing("Donkey Kong Jr.™ Math"),
+ "clv_p_nahve" => Playing("The Mysterious Murasame Castle"),
+ "clv_p_najae" => Playing("DEVIL WORLD™"),
+ "clv_p_najbe" => Playing("Golf"),
+ "clv_p_najpe" => Playing("R.C. PRO-AM™"),
+ "clv_p_najre" => Playing("COBRA TRIANGLE™"),
+ "clv_p_najse" => Playing("SNAKE RATTLE N ROLL™"),
+ "clv_p_najte" => Playing("SOLAR® JETMAN"),
+
+ #endregion
+
+ #region SNES
+
+ "s_2180_e" => Playing("BATTLETOADS™ DOUBLE DRAGON™"),
+ "s_2179_e" => Playing("BATTLETOADS™ IN BATTLEMANIACS"),
+ "s_2182_e" => Playing("BIG RUN"),
+ "s_2156_e" => Playing("Bombuzal"),
+ "s_2002_e" => Playing("BRAWL BROTHERS"),
+ "s_2025_e" => Playing("Breath of Fire II"),
+ "s_2003_e" => Playing("Breath Of Fire"),
+ "s_2163_e" => Playing("Claymates"),
+ "s_2150_e" => Playing("Congo's Caper"),
+ "s_2171_e" => Playing("COSMO GANG THE PUZZLE"),
+ "s_2004_e" => Playing("Demon's Crest"),
+ "s_2026_e" => Playing("Kunio-kun no Dodgeball da yo Zen'in Shūgō!"),
+ "s_2060_e" => Playing("Donkey Kong Country 2: Diddy's Kong Quest"),
+ "s_2061_e" => Playing("Donkey Kong Country 3: Dixie Kong's Double Trouble!"),
+ "s_2055_e" => Playing("Donkey Kong Country"),
+ "s_2139_e" => Playing("DOOMSDAY WARRIOR"),
+ "s_2051_e" => Playing("EarthBound"),
+ "s_2162_e" => Playing("Earthworm Jim™ 2"),
+ "s_2005_e" => Playing("F-ZERO™"),
+ "s_2183_e" => Playing("FATAL FURY 2"),
+ "s_2174_e" => Playing("Fighter's History"),
+ "s_2037_e" => Playing("Harvest Moon"),
+ "s_2161_e" => Playing("Jelly Boy"),
+ "s_2006_e" => Playing("Joe & Mac 2: Lost in the Tropics"),
+ "s_2169_e" => Playing("Caveman Ninja"),
+ "s_2181_e" => Playing("KILLER INSTINCT™"),
+ "s_2029_e" or "s_2029_e_sp1" => Playing("Kirby Super Star™"),
+ "s_2121_e" => Playing("Kirby's Avalanche™"),
+ "s_2007_e" or "s_2007_e_sp1" => Playing("Kirby's Dream Course™"),
+ "s_2008_e" or "s_2008_e_sp1" => Playing("Kirby's Dream Land™ 3"),
+ "s_2172_e" => Playing("Kirby’s Star Stacker™"),
+ "s_2151_e" => Playing("Magical Drop2"),
+ "s_2044_e" => Playing("Mario's Super Picross"),
+ "s_2038_e" => Playing("Natsume Championship Wrestling"),
+ "s_2140_e" => Playing("Operation Logic Bomb"),
+ "s_2034_e" => Playing("Panel de Pon"),
+ "s_2009_e" => Playing("Pilotwings™"),
+ "s_2010_e" => Playing("Pop'n TwinBee"),
+ "s_2157_e" => Playing("Prehistorik Man"),
+ "s_2145_e" => Playing("Psycho Dream"),
+ "s_2141_e" => Playing("Rival Turf!"),
+ "s_2152_e" => Playing("SIDE POCKET"),
+ "s_2158_e" => Playing("Spanky’s™ Quest"),
+ "s_2031_e" => Playing("Star Fox™ 2"),
+ "s_2011_e" => Playing("Star Fox™"),
+ "s_2012_e" => Playing("Stunt Race FX™"),
+ "s_2032_e" => Playing("Amazing Hebereke"),
+ "s_2159_e" => Playing("Super Baseball Simulator 1.000"),
+ "s_2013_e" => Playing("SUPER E.D.F. EARTH DEFENSE FORCE"),
+ "s_2014_e" => Playing("Smash Tennis"),
+ "s_2015_e" => Playing("Super Ghouls'n Ghosts™"),
+ "s_2033_e" => Playing("Super Mario All-Stars™"),
+ "s_2016_e" or "s_2016_e_sp1" => Playing("Super Mario Kart™"),
+ "s_2017_e" or "s_2017_e_sp1" => Playing("Super Mario World™"),
+ "s_2018_e" or "s_2018_e_sp1" => Playing("Super Metroid™"),
+ "s_2184_e" => Playing("Super Ninja Boy"),
+ "s_2019_e" or "s_2019_e_sp1" => Playing("Super Punch-Out!!™"),
+ "s_2020_e" => Playing("Super Puyo Puyo 2"),
+ "s_2133_e" => Playing("SUPER R-TYPE"),
+ "s_2021_e" => Playing("Super Soccer"),
+ "s_2022_e" => Playing("Super Tennis"),
+ "s_2136_e" => Playing("Sutte Hakkun"),
+ "s_2142_e" => Playing("The Ignition Factor"),
+ "s_2143_e" => Playing("The Peace Keepers"),
+ "s_2146_e" => Playing("Tuff E Nuff"),
+ "s_2144_e" => Playing("SUPER VALIS Ⅳ"),
+ "s_2049_e" => Playing("Wild Guns"),
+ "s_2096_e" => Playing("Wrecking Crew™ '98"),
+ "s_2023_e" => Playing("Super Mario World™ 2: Yoshi's Island™"),
+ "s_2024_e" => Playing("The Legend of Zelda™: A Link to the Past™"),
+
+ #endregion
+
+ #region GameBoy
+
+ "c_7224_e" or "c_7224_p" => Playing("Alone in the Dark: The New Nightmare"),
+ "c_5022_e" => Playing("Blaster Master: Enemy Below"),
+ "c_3381_e" => Playing("Game & Watch™ Gallery 3"),
+ "c_0282_e" => Playing("Kirby Tilt ‘n’ Tumble™"),
+ "c_4471_e" or "c_4471_p" => Playing("Mario Golf™"),
+ "c_9947_e" => Playing("Mario Tennis™"),
+ "c_3191_e" or "c_3191_p" or "c_3191_x" => Playing("Pokémon™ Trading Card Game"),
+ "c_8914_e" or "c_8914_p" => Playing("Quest for Camelot™"),
+ "c_2648_e" => Playing("Tetris® DX"),
+ "c_5928_e" => Playing("Wario Land™ 3"),
+ "c_3996_e" or "c_3996_pd" or "c_3996_pf" => Playing("The Legend of Zelda™: Link's Awakening DX™"),
+ "c_8852_e" or "c_8852_p" => Playing("The Legend of Zelda™: Oracle of Ages™"),
+ "c_9130_e" or "c_9130_p" => Playing("The Legend of Zelda™: Oracle of Seasons™"),
+ "d_6879_e" => Playing("Alleyway™"),
+ "d_7618_e" => Playing("Baseball"),
+ "d_6005_e" => Playing("BurgerTime Deluxe"),
+ "d_7120_e" => Playing("Castlevania Legends"),
+ "d_2744_e" => Playing("Dr. Mario™"),
+ "d_1593_e" => Playing("Donkey Kong Land 2™"),
+ "d_7216_e" => Playing("Donkey Kong Land III™"),
+ "d_4971_e" => Playing("Donkey Kong Land™"),
+ "d_7984_e" => Playing("GARGOYLE'S QUEST"),
+ "d_8212_e" => Playing("Kirby's Dream Land™ 2"),
+ "d_5661_e" => Playing("Kirby's Dream Land™"),
+ "d_3837_e" => Playing("MEGA MAN II"),
+ "d_1965_e" => Playing("MEGA MAN III"),
+ "d_0194_e" => Playing("MEGA MAN IV"),
+ "d_1425_e" => Playing("MEGA MAN V"),
+ "d_9324_e" => Playing("MEGA MAN: DR. WILY'S REVENGE"),
+ "d_1577_e" => Playing("Metroid™ II - Return of Samus™"),
+ "d_5124_e" => Playing("Super Mario Land™ 2 - 6 Golden Coins™"),
+ "d_7970_e" => Playing("Super Mario Land™"),
+ "d_8484_e" => Playing("Tetris®"),
+
+ #endregion
+
+ #region GameBoy Advance
+
+ "a_9694_e" => Playing("Densetsu no Starfy 1"),
+ "a_5600_e" => Playing("Densetsu no Starfy 2"),
+ "a_7565_e" => Playing("Densetsu no Starfy 3"),
+ "a_6553_e" => Playing("F-ZERO CLIMAX"),
+ "a_7842_e" or "a_7842_p" => Playing("F-Zero™- GP Legend"),
+ "a_9283_e" => Playing("F-Zero™ Maximum Velocity"),
+ "a_3744_e" or "a_3744_x" or "a_3744_y" => Playing("Fire Emblem™"),
+ "a_8978_d" or "a_8978_e" or "a_8978_f" or "a_8978_i" or "a_8978_s" => Playing("Golden Sun™: The Lost Age"),
+ "a_3108_d" or "a_3108_e" or "a_3108_f" or "a_3108_i" or "a_3108_s" => Playing("Golden Sun™"),
+ "a_3654_e" or "a_3654_p" => Playing("Kirby™ & The Amazing Mirror"),
+ "a_7279_p" => Playing("Kuru Kuru Kururin™"),
+ "a_7311_e" or "a_7311_p" => Playing("Mario & Luigi™: Superstar Saga"),
+ "a_6845_e" => Playing("Mario Kart™: Super Circuit™"),
+ "a_4139_e" or "a_4139_p" => Playing("Metroid™ Fusion"),
+ "a_6834_e" or "a_6834_p" => Playing("Metroid™: Zero Mission"),
+ "a_8989_e" or "a_8989_p" => Playing("Pokémon™ Mystery Dungeon: Red Rescue Team"),
+ "a_9444_e" => Playing("Super Mario™ Advance"),
+ "a_9901_e" or "a_9901_p" => Playing("Super Mario™ Advance 4: Super Mario Bros.™ 3"),
+ "a_2939_e" => Playing("Super Mario World™: Super Mario Advance 2"),
+ "a_2939_p" => Playing("Super Mario World™: Super Mario Advance 2™"),
+ "a_1302_e" => Playing("WarioWare™, Inc.: Mega Microgame$!"),
+ "a_1302_p" => Playing("WarioWare™, Inc.: Minigame Mania."),
+ "a_6960_e" or "a_6960_p" => Playing("Yoshi's Island™: Super Mario™ Advance 3"),
+ "a_5190_e" or "a_5190_p" => Playing("The Legend of Zelda™: A Link to the Past™ Four Swords"),
+ "a_8665_e" or "a_8665_p" => Playing("The Legend of Zelda™: The Minish Cap"),
+
+ #endregion
+
+ _ => FormattedValue.ForceReset
+ };
+ }
+}
diff --git a/src/Ryujinx/Utilities/PlayReport/PlayReports.cs b/src/Ryujinx/Utilities/PlayReport/PlayReports.cs
new file mode 100644
index 000000000..d5568962e
--- /dev/null
+++ b/src/Ryujinx/Utilities/PlayReport/PlayReports.cs
@@ -0,0 +1,68 @@
+namespace Ryujinx.Ava.Utilities.PlayReport
+{
+ public static partial class PlayReports
+ {
+ public static Analyzer Analyzer { get; } = new Analyzer()
+ .AddSpec(
+ "01007ef00011e000",
+ spec => spec
+ .AddValueFormatter("IsHardMode", BreathOfTheWild_MasterMode)
+ // reset to normal status when switching between normal & master mode in title screen
+ .AddValueFormatter("AoCVer", FormattedValue.SingleAlwaysResets)
+ )
+ .AddSpec(
+ "0100f2c0115b6000",
+ spec => spec
+ .AddValueFormatter("PlayerPosY", TearsOfTheKingdom_CurrentField))
+ .AddSpec(
+ "0100000000010000",
+ spec =>
+ spec.AddValueFormatter("is_kids_mode", SuperMarioOdyssey_AssistMode)
+ )
+ .AddSpec(
+ "010075000ecbe000",
+ spec =>
+ spec.AddValueFormatter("is_kids_mode", SuperMarioOdysseyChina_AssistMode)
+ )
+ .AddSpec(
+ "010028600ebda000",
+ spec => spec.AddValueFormatter("mode", SuperMario3DWorldOrBowsersFury)
+ )
+ .AddSpec( // Global & China IDs
+ ["0100152000022000", "010075100e8ec000"],
+ spec => spec.AddValueFormatter("To", MarioKart8Deluxe_Mode)
+ )
+ .AddSpec(
+ ["0100a3d008c5c000", "01008f6008c5e000"],
+ spec => spec
+ .AddValueFormatter("area_no", PokemonSVArea)
+ .AddValueFormatter("team_circle", PokemonSVUnionCircle)
+ )
+ .AddSpec(
+ "01006a800016e000",
+ spec => spec
+ .AddSparseMultiValueFormatter(
+ [
+ // Metadata to figure out what PlayReport we have.
+ "match_mode", "match_submode", "anniversary", "fighter", "reason", "challenge_count",
+ "adv_slot",
+ // List of Fighters
+ "player_1_fighter", "player_2_fighter", "player_3_fighter", "player_4_fighter",
+ "player_5_fighter", "player_6_fighter", "player_7_fighter", "player_8_fighter",
+ // List of rankings/placements
+ "player_1_rank", "player_2_rank", "player_3_rank", "player_4_rank", "player_5_rank",
+ "player_6_rank", "player_7_rank", "player_8_rank"
+ ],
+ SuperSmashBrosUltimate_Mode
+ )
+ )
+ .AddSpec(
+ [
+ "0100c9a00ece6000", "01008d300c50c000", "0100d870045b6000",
+ "010012f017576000", "0100c62011050000", "0100b3c014bda000"],
+ spec => spec.AddValueFormatter("launch_title_id", NsoEmulator_LaunchedGame)
+ );
+
+ private static string Playing(string game) => $"Playing {game}";
+ }
+}
diff --git a/src/Ryujinx/Utilities/PlayReport/Specs.cs b/src/Ryujinx/Utilities/PlayReport/Specs.cs
new file mode 100644
index 000000000..f1b94de68
--- /dev/null
+++ b/src/Ryujinx/Utilities/PlayReport/Specs.cs
@@ -0,0 +1,235 @@
+using MsgPack;
+using Ryujinx.Ava.Utilities.AppLibrary;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Ryujinx.Ava.Utilities.PlayReport
+{
+ ///
+ /// A mapping of title IDs to value formatter specs.
+ ///
+ /// Generally speaking, use the .AddSpec(...) methods instead of creating this class yourself.
+ ///
+ public class GameSpec
+ {
+ public static GameSpec Create(string requiredTitleId, params IEnumerable otherTitleIds)
+ => new() { TitleIds = otherTitleIds.Prepend(requiredTitleId).ToArray() };
+
+ public static GameSpec Create(IEnumerable titleIds)
+ => new() { TitleIds = titleIds.ToArray() };
+
+ private int _lastPriority;
+
+ public required string[] TitleIds { get; init; }
+
+ public List ValueFormatters { get; } = [];
+
+
+ ///
+ /// Add a value formatter to the current
+ /// matching a specific key that could exist in a Play Report for the previously specified title IDs.
+ ///
+ /// The key name to match.
+ /// The function which can return a potential formatted value.
+ /// The current , for chaining convenience.
+ public GameSpec AddValueFormatter(
+ string reportKey,
+ SingleValueFormatter valueFormatter
+ ) => AddValueFormatter(_lastPriority++, reportKey, valueFormatter);
+
+ ///
+ /// Add a value formatter at a specific priority to the current
+ /// matching a specific key that could exist in a Play Report for the previously specified title IDs.
+ ///
+ /// The resolution priority of this value formatter. Higher resolves sooner.
+ /// The key name to match.
+ /// The function which can return a potential formatted value.
+ /// The current , for chaining convenience.
+ public GameSpec AddValueFormatter(
+ int priority,
+ string reportKey,
+ SingleValueFormatter valueFormatter
+ ) => AddValueFormatter(new FormatterSpec
+ {
+ Priority = priority, ReportKeys = [reportKey], Formatter = valueFormatter
+ });
+
+ ///
+ /// Add a multi-value formatter to the current
+ /// matching a specific set of keys that could exist in a Play Report for the previously specified title IDs.
+ ///
+ /// The key names to match.
+ /// The function which can format the values.
+ /// The current , for chaining convenience.
+ public GameSpec AddMultiValueFormatter(
+ string[] reportKeys,
+ MultiValueFormatter valueFormatter
+ ) => AddMultiValueFormatter(_lastPriority++, reportKeys, valueFormatter);
+
+ ///
+ /// Add a multi-value formatter at a specific priority to the current
+ /// matching a specific set of keys that could exist in a Play Report for the previously specified title IDs.
+ ///
+ /// The resolution priority of this value formatter. Higher resolves sooner.
+ /// The key names to match.
+ /// The function which can format the values.
+ /// The current , for chaining convenience.
+ public GameSpec AddMultiValueFormatter(
+ int priority,
+ string[] reportKeys,
+ MultiValueFormatter valueFormatter
+ ) => AddValueFormatter(new MultiFormatterSpec
+ {
+ Priority = priority, ReportKeys = reportKeys, Formatter = valueFormatter
+ });
+
+ ///
+ /// Add a multi-value formatter to the current
+ /// matching a specific set of keys that could exist in a Play Report for the previously specified title IDs.
+ ///
+ /// The 'Sparse' multi-value formatters do not require every key to be present.
+ /// If you need this requirement, use .
+ ///
+ /// The key names to match.
+ /// The function which can format the values.
+ /// The current , for chaining convenience.
+ public GameSpec AddSparseMultiValueFormatter(
+ string[] reportKeys,
+ SparseMultiValueFormatter valueFormatter
+ ) => AddSparseMultiValueFormatter(_lastPriority++, reportKeys, valueFormatter);
+
+ ///
+ /// Add a multi-value formatter at a specific priority to the current
+ /// matching a specific set of keys that could exist in a Play Report for the previously specified title IDs.
+ ///
+ /// The 'Sparse' multi-value formatters do not require every key to be present.
+ /// If you need this requirement, use .
+ ///
+ /// The resolution priority of this value formatter. Higher resolves sooner.
+ /// The key names to match.
+ /// The function which can format the values.
+ /// The current , for chaining convenience.
+ public GameSpec AddSparseMultiValueFormatter(
+ int priority,
+ string[] reportKeys,
+ SparseMultiValueFormatter valueFormatter
+ ) => AddValueFormatter(new SparseMultiFormatterSpec
+ {
+ Priority = priority, ReportKeys = reportKeys, Formatter = valueFormatter
+ });
+
+ private GameSpec AddValueFormatter(T formatterSpec) where T : FormatterSpecBase
+ {
+ ValueFormatters.Add(formatterSpec);
+ return this;
+ }
+ }
+
+ ///
+ /// A struct containing the data for a mapping of a key in a Play Report to a formatter for its potential value.
+ ///
+ public class FormatterSpec : FormatterSpecBase
+ {
+ public override bool GetData(Horizon.Prepo.Types.PlayReport playReport, out object result)
+ {
+ if (!playReport.ReportData.AsDictionary().TryGetValue(ReportKeys[0], out MessagePackObject valuePackObject))
+ {
+ result = null;
+ return false;
+ }
+
+ result = valuePackObject;
+ return true;
+ }
+ }
+
+ ///
+ /// A struct containing the data for a mapping of an arbitrary key set in a Play Report to a formatter for their potential values.
+ ///
+ public class MultiFormatterSpec : FormatterSpecBase
+ {
+ public override bool GetData(Horizon.Prepo.Types.PlayReport playReport, out object result)
+ {
+ List packedObjects = [];
+ foreach (string reportKey in ReportKeys)
+ {
+ if (!playReport.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
+ {
+ result = null;
+ return false;
+ }
+
+ packedObjects.Add(valuePackObject);
+ }
+
+ result = packedObjects;
+ return true;
+ }
+ }
+
+ ///
+ /// A struct containing the data for a mapping of an arbitrary key set in a Play Report to a formatter for their sparsely populated potential values.
+ ///
+ public class SparseMultiFormatterSpec : FormatterSpecBase
+ {
+ public override bool GetData(Horizon.Prepo.Types.PlayReport playReport, out object result)
+ {
+ Dictionary packedObjects = [];
+ foreach (string reportKey in ReportKeys)
+ {
+ if (!playReport.ReportData.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
+ continue;
+
+ packedObjects.Add(reportKey, valuePackObject);
+ }
+
+ result = packedObjects;
+ return true;
+ }
+ }
+
+ public abstract class FormatterSpecBase
+ {
+ public abstract bool GetData(Horizon.Prepo.Types.PlayReport playReport, out object data);
+
+ public int Priority { get; init; }
+ public string[] ReportKeys { get; init; }
+ public Delegate Formatter { get; init; }
+
+ public bool Format(ApplicationMetadata appMeta, Horizon.Prepo.Types.PlayReport playReport,
+ out FormattedValue formattedValue)
+ {
+ formattedValue = default;
+ if (!GetData(playReport, out object data))
+ return false;
+
+ if (data is FormattedValue fv)
+ {
+ formattedValue = fv;
+ return true;
+ }
+
+ switch (Formatter)
+ {
+ case SingleValueFormatter svf when data is MessagePackObject match:
+ formattedValue = svf(
+ new SingleValue(match) { Application = appMeta, PlayReport = playReport }
+ );
+ return true;
+ case MultiValueFormatter mvf when data is List matches:
+ formattedValue = mvf(
+ new MultiValue(matches) { Application = appMeta, PlayReport = playReport }
+ );
+ return true;
+ case SparseMultiValueFormatter smvf when data is Dictionary sparseMatches:
+ formattedValue = smvf(
+ new SparseMultiValue(sparseMatches) { Application = appMeta, PlayReport = playReport }
+ );
+ return true;
+ default:
+ throw new InvalidOperationException("Formatter delegate is not of a known type!");
+ }
+ }
+ }
+}
diff --git a/src/Ryujinx/Utilities/PlayReport/Value.cs b/src/Ryujinx/Utilities/PlayReport/Value.cs
new file mode 100644
index 000000000..b3108a41e
--- /dev/null
+++ b/src/Ryujinx/Utilities/PlayReport/Value.cs
@@ -0,0 +1,160 @@
+using MsgPack;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Ryujinx.Ava.Utilities.PlayReport
+{
+ ///
+ /// The base input data to a ValueFormatter delegate,
+ /// and the matched from the Play Report.
+ ///
+ public readonly struct Value
+ {
+ public Value(MessagePackObject packedValue)
+ {
+ PackedValue = packedValue;
+ }
+
+ ///
+ /// The matched value from the Play Report.
+ ///
+ public MessagePackObject PackedValue { get; init; }
+
+ ///
+ /// Access the as its underlying .NET type.
+ ///
+ /// Does not seem to work well with comparing numeric types,
+ /// so use XValue properties for that.
+ ///
+ public object BoxedValue => PackedValue.ToObject();
+
+ public override string ToString()
+ {
+ object boxed = BoxedValue;
+ return boxed == null
+ ? "null"
+ : boxed.ToString();
+ }
+
+ public static implicit operator Value(MessagePackObject matched) => new(matched);
+
+ public static Value[] ConvertPackedObjects(IEnumerable packObjects)
+ => packObjects.Select(packObject => new Value(packObject)).ToArray();
+
+ public static Dictionary ConvertPackedObjectMap(Dictionary packObjects)
+ => packObjects.ToDictionary(
+ x => x.Key,
+ x => new Value(x.Value)
+ );
+
+ #region AsX accessors
+
+ public bool BooleanValue => PackedValue.AsBoolean();
+ public byte ByteValue => PackedValue.AsByte();
+ public sbyte SByteValue => PackedValue.AsSByte();
+ public short ShortValue => PackedValue.AsInt16();
+ public ushort UShortValue => PackedValue.AsUInt16();
+ public int IntValue => PackedValue.AsInt32();
+ public uint UIntValue => PackedValue.AsUInt32();
+ public long LongValue => PackedValue.AsInt64();
+ public ulong ULongValue => PackedValue.AsUInt64();
+ public float FloatValue => PackedValue.AsSingle();
+ public double DoubleValue => PackedValue.AsDouble();
+ public string StringValue => PackedValue.AsString();
+ public Span BinaryValue => PackedValue.AsBinary();
+
+ #endregion
+ }
+
+ ///
+ /// A potential formatted value returned by a ValueFormatter delegate.
+ ///
+ public readonly struct FormattedValue
+ {
+ ///
+ /// Was any handler able to match anything in the Play Report?
+ ///
+ public bool Handled { get; private init; }
+
+ ///
+ /// Did the handler request the caller of the to reset the existing value?
+ ///
+ public bool Reset { get; private init; }
+
+ ///
+ /// The formatted value, only present if is true, and is false.
+ ///
+ public string FormattedString { get; private init; }
+
+ ///
+ /// The intended path of execution for having a string to return: simply return the string.
+ /// This implicit conversion will make the struct for you.
+ ///
+ /// If the input is null, is returned.
+ ///
+ /// The formatted string value.
+ /// The automatically constructed struct.
+ public static implicit operator FormattedValue(string formattedValue)
+ => formattedValue is not null
+ ? new FormattedValue { Handled = true, FormattedString = formattedValue }
+ : Unhandled;
+
+ public override string ToString()
+ {
+ if (!Handled)
+ return "";
+
+ if (Reset)
+ return "";
+
+ return FormattedString;
+ }
+
+ ///
+ /// Return this to tell the caller there is no value to return.
+ ///
+ public static readonly FormattedValue Unhandled = default;
+
+ ///
+ /// Return this to suggest the caller reset the value it's using the for.
+ ///
+ public static readonly FormattedValue ForceReset = new() { Handled = true, Reset = true };
+
+ ///
+ /// A delegate singleton you can use to always return in a .
+ ///
+ public static readonly SingleValueFormatter SingleAlwaysResets = _ => ForceReset;
+
+ ///
+ /// A delegate singleton you can use to always return in a .
+ ///
+ public static readonly MultiValueFormatter MultiAlwaysResets = _ => ForceReset;
+
+ ///
+ /// A delegate singleton you can use to always return in a .
+ ///
+ public static readonly SparseMultiValueFormatter SparseMultiAlwaysResets = _ => ForceReset;
+
+ ///
+ /// A delegate factory you can use to always return the specified
+ /// in a .
+ ///
+ /// The string to always return for this delegate instance.
+ public static SingleValueFormatter SingleAlwaysReturns(string formattedValue) => _ => formattedValue;
+
+ ///
+ /// A delegate factory you can use to always return the specified
+ /// in a .
+ ///
+ /// The string to always return for this delegate instance.
+ public static MultiValueFormatter MultiAlwaysReturns(string formattedValue) => _ => formattedValue;
+
+ ///
+ /// A delegate factory you can use to always return the specified
+ /// in a .
+ ///
+ /// The string to always return for this delegate instance.
+ public static SparseMultiValueFormatter SparseMultiAlwaysReturns(string formattedValue) => _ => formattedValue;
+ }
+}
diff --git a/src/Ryujinx/Utilities/SystemInfo/SystemInfo.cs b/src/Ryujinx/Utilities/SystemInfo/SystemInfo.cs
index 0d45c52f2..aa7094ec7 100644
--- a/src/Ryujinx/Utilities/SystemInfo/SystemInfo.cs
+++ b/src/Ryujinx/Utilities/SystemInfo/SystemInfo.cs
@@ -24,9 +24,9 @@ namespace Ryujinx.Ava.Utilities.SystemInfo
public void Print()
{
- Logger.Notice.Print(LogClass.Application, $"Operating System: {OsDescription}");
- Logger.Notice.Print(LogClass.Application, $"CPU: {CpuName}");
- Logger.Notice.Print(LogClass.Application, $"RAM: Total {ToGBString(RamTotal)} ; Available {ToGBString(RamAvailable)}");
+ Logger.Notice.Print(LogClass.Application, $"Operating System: {OsDescription}", "PrintSystemInfo");
+ Logger.Notice.Print(LogClass.Application, $"CPU: {CpuName}", "PrintSystemInfo");
+ Logger.Notice.Print(LogClass.Application, $"RAM: Total {ToGBString(RamTotal)} ; Available {ToGBString(RamAvailable)}", "PrintSystemInfo");
}
public static SystemInfo Gather()