mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-03-11 17:55:44 +00:00
Revert "nacp: add support for zlib-compressed title blocks"
This reverts commit 76bb4ae2d0.
This commit is contained in:
parent
76bb4ae2d0
commit
ba81c3131e
12 changed files with 20 additions and 138 deletions
|
|
@ -20,7 +20,5 @@ namespace Ryujinx.HLE.HOS.SystemState
|
|||
SimplifiedChinese,
|
||||
TraditionalChinese,
|
||||
BrazilianPortuguese,
|
||||
Polish,
|
||||
Thai,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ namespace Ryujinx.HLE.HOS.SystemState
|
|||
"es-419",
|
||||
"zh-Hans",
|
||||
"zh-Hant",
|
||||
"pt-BR",
|
||||
"pl",
|
||||
"th"
|
||||
"pt-BR"
|
||||
];
|
||||
|
||||
internal long DesiredKeyboardLayout { get; private set; }
|
||||
|
|
|
|||
|
|
@ -18,7 +18,5 @@ namespace Ryujinx.HLE.HOS.SystemState
|
|||
TraditionalChinese,
|
||||
SimplifiedChinese,
|
||||
BrazilianPortuguese,
|
||||
Polish,
|
||||
Thai,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using Ryujinx.Common.Configuration;
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.HLE.Loaders.Executables;
|
||||
using Ryujinx.HLE.Utilities;
|
||||
using Ryujinx.Memory;
|
||||
using System.Linq;
|
||||
using static Ryujinx.HLE.HOS.ModLoader;
|
||||
|
|
@ -87,18 +86,11 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
|||
|
||||
if (!isHomebrew && programId > 0x010000000000FFFF)
|
||||
{
|
||||
ApplicationControlProperty.ApplicationTitle[] titles =
|
||||
NacpHelper.GetTitleEntries(in nacpData.Value);
|
||||
|
||||
int langIdx = (int)device.System.State.DesiredTitleLanguage;
|
||||
if (langIdx < titles.Length)
|
||||
{
|
||||
programName = titles[langIdx].NameString.ToString();
|
||||
}
|
||||
programName = nacpData.Value.Title[(int)device.System.State.DesiredTitleLanguage].NameString.ToString();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(programName))
|
||||
{
|
||||
foreach (ApplicationControlProperty.ApplicationTitle appTitle in titles)
|
||||
foreach (ApplicationControlProperty.ApplicationTitle appTitle in nacpData.Value.Title)
|
||||
{
|
||||
if (appTitle.Name[0] != 0)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -194,22 +194,15 @@ namespace Ryujinx.HLE.Loaders.Processes
|
|||
{
|
||||
nacpStorage.Read(0, nacpData.ByteSpan);
|
||||
|
||||
ApplicationControlProperty.ApplicationTitle[] titles =
|
||||
Utilities.NacpHelper.GetTitleEntries(in nacpData.Value);
|
||||
programName = nacpData.Value.Title[(int)_device.System.State.DesiredTitleLanguage].NameString.ToString();
|
||||
|
||||
int langIdx = (int)_device.System.State.DesiredTitleLanguage;
|
||||
if (langIdx < titles.Length)
|
||||
{
|
||||
programName = titles[langIdx].NameString.ToString();
|
||||
}
|
||||
|
||||
if ((int)TitleLanguage.AmericanEnglish < titles.Length &&
|
||||
"Switch Verification" == titles[(int)TitleLanguage.AmericanEnglish].NameString.ToString())
|
||||
if ("Switch Verification" ==
|
||||
nacpData.Value.Title[(int)TitleLanguage.AmericanEnglish].NameString.ToString())
|
||||
throw new InvalidOperationException();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(programName))
|
||||
{
|
||||
foreach (ApplicationControlProperty.ApplicationTitle nacpTitles in titles)
|
||||
foreach (ApplicationControlProperty.ApplicationTitle nacpTitles in nacpData.Value.Title)
|
||||
{
|
||||
if (nacpTitles.Name[0] != 0)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using Ryujinx.Common.Logging;
|
|||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||
using Ryujinx.HLE.Utilities;
|
||||
using Ryujinx.Horizon.Common;
|
||||
|
||||
namespace Ryujinx.HLE.Loaders.Processes
|
||||
|
|
@ -55,17 +54,11 @@ namespace Ryujinx.HLE.Loaders.Processes
|
|||
{
|
||||
ulong programId = metaLoader.ProgramId;
|
||||
|
||||
ApplicationControlProperty.ApplicationTitle[] titles =
|
||||
NacpHelper.GetTitleEntries(in ApplicationControlProperties);
|
||||
|
||||
if ((int)titleLanguage < titles.Length)
|
||||
{
|
||||
Name = titles[(int)titleLanguage].NameString.ToString();
|
||||
}
|
||||
Name = ApplicationControlProperties.Title[(int)titleLanguage].NameString.ToString();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Name))
|
||||
{
|
||||
foreach (ApplicationControlProperty.ApplicationTitle appTitle in titles)
|
||||
foreach (ApplicationControlProperty.ApplicationTitle appTitle in ApplicationControlProperties.Title)
|
||||
{
|
||||
if (appTitle.Name[0] != 0)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Ns;
|
||||
|
||||
namespace Ryujinx.HLE.Utilities
|
||||
{
|
||||
public static class NacpHelper
|
||||
{
|
||||
private const int UncompressedTitleCount = 16;
|
||||
private const int CompressedTitleCount = 32;
|
||||
private const int TitleEntrySize = 0x300;
|
||||
private const int TitleCompressionByteIndex = 1; // offset within Reserved3214
|
||||
|
||||
/// <summary>
|
||||
/// Returns the resolved title entries from an NACP. When the title block is zlib-compressed
|
||||
/// (indicated by a compression flag at NACP offset 0x3215), the first 0x3000 bytes are treated
|
||||
/// as a raw-deflate compressed blob that decompresses to 0x6000 bytes containing up to 32 title
|
||||
/// entries. Otherwise the 16 uncompressed entries are returned directly.
|
||||
/// </summary>
|
||||
public static ApplicationControlProperty.ApplicationTitle[] GetTitleEntries(
|
||||
ref readonly ApplicationControlProperty nacp)
|
||||
{
|
||||
byte titleCompression = nacp.Reserved3214[TitleCompressionByteIndex];
|
||||
|
||||
if (titleCompression != 1)
|
||||
{
|
||||
var titles = new ApplicationControlProperty.ApplicationTitle[UncompressedTitleCount];
|
||||
for (int i = 0; i < UncompressedTitleCount; i++)
|
||||
titles[i] = nacp.Title[i];
|
||||
return titles;
|
||||
}
|
||||
|
||||
ReadOnlySpan<byte> titleBytes = MemoryMarshal.AsBytes(
|
||||
(ReadOnlySpan<ApplicationControlProperty.ApplicationTitle>)nacp.Title);
|
||||
|
||||
ushort compressedBlobSize = BinaryPrimitives.ReadUInt16LittleEndian(titleBytes);
|
||||
ReadOnlySpan<byte> compressedBlob = titleBytes.Slice(2, compressedBlobSize);
|
||||
|
||||
byte[] decompressed = new byte[CompressedTitleCount * TitleEntrySize];
|
||||
|
||||
using (var compressedStream = new MemoryStream(compressedBlob.ToArray()))
|
||||
using (var deflateStream = new DeflateStream(compressedStream, CompressionMode.Decompress))
|
||||
{
|
||||
int totalRead = 0;
|
||||
while (totalRead < decompressed.Length)
|
||||
{
|
||||
int read = deflateStream.Read(decompressed, totalRead, decompressed.Length - totalRead);
|
||||
if (read == 0)
|
||||
break;
|
||||
totalRead += read;
|
||||
}
|
||||
}
|
||||
|
||||
var result = new ApplicationControlProperty.ApplicationTitle[CompressedTitleCount];
|
||||
for (int i = 0; i < CompressedTitleCount; i++)
|
||||
{
|
||||
result[i] = MemoryMarshal.Read<ApplicationControlProperty.ApplicationTitle>(
|
||||
decompressed.AsSpan(i * TitleEntrySize, TitleEntrySize));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -58,10 +58,7 @@ namespace Ryujinx.Horizon.Sdk.Ns
|
|||
public RepairFlagValue RepairFlag;
|
||||
public byte ProgramIndex;
|
||||
public RequiredNetworkServiceLicenseOnLaunchValue RequiredNetworkServiceLicenseOnLaunchFlag;
|
||||
public byte ApplicationErrorCodePrefix;
|
||||
public TitleCompressionValue TitleCompression;
|
||||
public byte AcdIndex;
|
||||
public byte ApparentPlatform;
|
||||
public Array4<byte> Reserved3214;
|
||||
public ApplicationNeighborDetectionClientConfiguration NeighborDetectionClientConfiguration;
|
||||
public ApplicationJitConfiguration JitConfiguration;
|
||||
public RequiredAddOnContentsSetBinaryDescriptor RequiredAddOnContentsSetBinaryDescriptors;
|
||||
|
|
@ -133,8 +130,6 @@ namespace Ryujinx.Horizon.Sdk.Ns
|
|||
TraditionalChinese = 13,
|
||||
SimplifiedChinese = 14,
|
||||
BrazilianPortuguese = 15,
|
||||
Polish = 16,
|
||||
Thai = 17,
|
||||
}
|
||||
|
||||
public enum Organization
|
||||
|
|
@ -307,11 +302,5 @@ namespace Ryujinx.Horizon.Sdk.Ns
|
|||
Deny = 0,
|
||||
Allow = 1,
|
||||
}
|
||||
|
||||
public enum TitleCompressionValue : byte
|
||||
{
|
||||
Disable = 0,
|
||||
Enable = 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,9 +167,7 @@ namespace Ryujinx.Headless
|
|||
ApplicationControlProperty nacp = activeProcess.ApplicationControlProperties;
|
||||
int desiredLanguage = (int)Device.System.State.DesiredTitleLanguage;
|
||||
|
||||
ApplicationControlProperty.ApplicationTitle[] titles = Ryujinx.HLE.Utilities.NacpHelper.GetTitleEntries(in nacp);
|
||||
string titleName = desiredLanguage < titles.Length ? titles[desiredLanguage].NameString.ToString() : string.Empty;
|
||||
string titleNameSection = string.IsNullOrWhiteSpace(titleName) ? string.Empty : $" - {titleName}";
|
||||
string titleNameSection = string.IsNullOrWhiteSpace(nacp.Title[desiredLanguage].NameString.ToString()) ? string.Empty : $" - {nacp.Title[desiredLanguage].NameString.ToString()}";
|
||||
string titleVersionSection = string.IsNullOrWhiteSpace(nacp.DisplayVersionString.ToString()) ? string.Empty : $" v{nacp.DisplayVersionString.ToString()}";
|
||||
string titleIdSection = string.IsNullOrWhiteSpace(activeProcess.ProgramIdText) ? string.Empty : $" ({activeProcess.ProgramIdText.ToUpper()})";
|
||||
string titleArchSection = activeProcess.Is64Bit ? " (64-bit)" : " (32-bit)";
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ using Ryujinx.Common.Logging;
|
|||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using Ryujinx.HLE.Utilities;
|
||||
using Ryujinx.HLE.Loaders.Npdm;
|
||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||
using Ryujinx.HLE.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
|
@ -440,10 +440,8 @@ namespace Ryujinx.Ava.Systems.AppLibrary
|
|||
|
||||
GetApplicationInformation(ref controlHolder.Value, ref application);
|
||||
|
||||
ApplicationControlProperty.ApplicationTitle[] verifyTitles =
|
||||
NacpHelper.GetTitleEntries(in controlHolder.Value);
|
||||
if ((int)TitleLanguage.AmericanEnglish < verifyTitles.Length &&
|
||||
"Switch Verification" == verifyTitles[(int)TitleLanguage.AmericanEnglish].NameString.ToString())
|
||||
if ("Switch Verification" == controlHolder.Value
|
||||
.Title[(int)TitleLanguage.AmericanEnglish].NameString.ToString())
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
|
@ -1393,13 +1391,10 @@ namespace Ryujinx.Ava.Systems.AppLibrary
|
|||
{
|
||||
_ = Enum.TryParse(DesiredLanguage.ToString(), out TitleLanguage desiredTitleLanguage);
|
||||
|
||||
ApplicationControlProperty.ApplicationTitle[] titles =
|
||||
NacpHelper.GetTitleEntries(in controlData);
|
||||
|
||||
if (titles.Length > (int)desiredTitleLanguage)
|
||||
if (controlData.Title.Length > (int)desiredTitleLanguage)
|
||||
{
|
||||
data.Name = titles[(int)desiredTitleLanguage].NameString.ToString();
|
||||
data.Developer = titles[(int)desiredTitleLanguage].PublisherString.ToString();
|
||||
data.Name = controlData.Title[(int)desiredTitleLanguage].NameString.ToString();
|
||||
data.Developer = controlData.Title[(int)desiredTitleLanguage].PublisherString.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1409,7 +1404,7 @@ namespace Ryujinx.Ava.Systems.AppLibrary
|
|||
|
||||
if (string.IsNullOrWhiteSpace(data.Name))
|
||||
{
|
||||
foreach (ApplicationControlProperty.ApplicationTitle controlTitle in titles)
|
||||
foreach (ref readonly ApplicationControlProperty.ApplicationTitle controlTitle in controlData.Title)
|
||||
{
|
||||
if (!controlTitle.NameString.IsEmpty())
|
||||
{
|
||||
|
|
@ -1422,7 +1417,7 @@ namespace Ryujinx.Ava.Systems.AppLibrary
|
|||
|
||||
if (string.IsNullOrWhiteSpace(data.Developer))
|
||||
{
|
||||
foreach (ApplicationControlProperty.ApplicationTitle controlTitle in titles)
|
||||
foreach (ref readonly ApplicationControlProperty.ApplicationTitle controlTitle in controlData.Title)
|
||||
{
|
||||
if (!controlTitle.PublisherString.IsEmpty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ namespace Ryujinx.Ava.Systems.Configuration.System
|
|||
SimplifiedChinese,
|
||||
TraditionalChinese,
|
||||
BrazilianPortuguese,
|
||||
Polish,
|
||||
Thai,
|
||||
}
|
||||
|
||||
public static class LanguageEnumHelper
|
||||
|
|
|
|||
|
|
@ -168,10 +168,7 @@ namespace Ryujinx.Ava.UI.Views.Main
|
|||
if (!ViewModel.IsGameRunning)
|
||||
return;
|
||||
|
||||
ApplicationControlProperty.ApplicationTitle[] titles = Ryujinx.HLE.Utilities.NacpHelper.GetTitleEntries(
|
||||
in ViewModel.AppHost.Device.Processes.ActiveApplication.ApplicationControlProperties);
|
||||
int langIdx = (int)ViewModel.AppHost.Device.System.State.DesiredTitleLanguage;
|
||||
string name = langIdx < titles.Length ? titles[langIdx].NameString.ToString() : string.Empty;
|
||||
string name = ViewModel.AppHost.Device.Processes.ActiveApplication.ApplicationControlProperties.Title[(int)ViewModel.AppHost.Device.System.State.DesiredTitleLanguage].NameString.ToString();
|
||||
|
||||
await StyleableAppWindow.ShowAsync(
|
||||
new CheatWindow(
|
||||
|
|
|
|||
Loading…
Reference in a new issue