-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HLE: extract custom NACP data functionality into a static helper for …
…generic reuse elsewhere, and clarify magic numbers.
- Loading branch information
Showing
2 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using LibHac.Common; | ||
using LibHac.Ns; | ||
using System; | ||
using System.Text; | ||
|
||
namespace Ryujinx.HLE | ||
{ | ||
public static class StructHelpers | ||
{ | ||
public static BlitStruct<ApplicationControlProperty> CreateCustomNacpData(string name, string version) | ||
{ | ||
// https://switchbrew.org/wiki/NACP | ||
const int OffsetOfDisplayVersion = 0x3060; | ||
|
||
// https://switchbrew.org/wiki/NACP#ApplicationTitle | ||
const int TotalApplicationTitles = 0x10; | ||
const int SizeOfApplicationTitle = 0x300; | ||
const int OffsetOfApplicationPublisherStrings = 0x200; | ||
|
||
|
||
var nacpData = new BlitStruct<ApplicationControlProperty>(1); | ||
|
||
// name and publisher buffer | ||
// repeat once for each locale (the ApplicationControlProperty has 16 locales) | ||
for (int i = 0; i < TotalApplicationTitles; i++) | ||
{ | ||
Encoding.ASCII.GetBytes(name).AsSpan().CopyTo(nacpData.ByteSpan[(i * SizeOfApplicationTitle)..]); | ||
"Ryujinx"u8.CopyTo(nacpData.ByteSpan[(i * SizeOfApplicationTitle + OffsetOfApplicationPublisherStrings)..]); | ||
} | ||
|
||
// version buffer | ||
Encoding.ASCII.GetBytes(version).AsSpan().CopyTo(nacpData.ByteSpan[OffsetOfDisplayVersion..]); | ||
|
||
return nacpData; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters