mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-29 06:36:24 +02:00
HLE: extract custom NACP data functionality into a static helper for generic reuse elsewhere, and clarify magic numbers.
This commit is contained in:
parent
eda4f4349b
commit
290a6ad5de
2 changed files with 48 additions and 20 deletions
37
src/Ryujinx.HLE/StructHelpers.cs
Normal file
37
src/Ryujinx.HLE/StructHelpers.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue