ryujinx/Ryujinx.HLE/Loaders/Npdm/Npdm.cs
Xpl0itR da4e0856c9 Add features to GUI (#757)
* controller image changes depending on the selected controller type

the new controller image assets are temporary until i get new ones

* Game list scans subdirs for games

* Key file existence check

* Only shows Program NCAs in Application list

* Change shown GUI columns without restarting

* Sort by column if you click on the column header

Columns are sorted as text so there are inaccuracies on some columns

* Fix sort on Time Played, Last Played and File Size columns

* Add ability to designate favourite games #1

TODO:
- Make fav games persistent
- Fix invisible check marks due to theme

* Add ability to designate favourite games #2

Also removed default theme

* Added a Windows specific build condition and a Linux bug fix

* bugfix

* Load metadata from JSONs

* Temp bug fix for MacOS

* lil clean up

* requested changes

* Misc fixes

* edited schema and config

* Show the TitleID of games on the title bar

* gui column config option have names

* Async loading of game list

* bugfix and cleanup

* thog's requested changes

* requested changes and cleanup

still need to fix the gtk seizure

* Fix issue where an ExeFS as a NSP didn't show up in the application list

* Minor fixes

* catch glib unhandled exceptions

* Make sure to do UI manipulation in the main thread

* Print path of invalid files

* Ac_k's requested changes

* Return of the dark theme

* move AboutInfo struct to another file

* sort usings

* changes

- gdkchan's requested changes that have been marked resolved
- made some structs internal as they aren't used outside of the GUI
- renamed Ryujinx.UI to Ryujinx.Ui to fit naming convention and folder structure
- fixed bug where controller type dropdown box is stretched
2019-11-29 15:32:51 +11:00

73 lines
2.3 KiB
C#

using Ryujinx.HLE.Exceptions;
using System.IO;
using System.Text;
namespace Ryujinx.HLE.Loaders.Npdm
{
// https://github.com/SciresM/hactool/blob/master/npdm.c
// https://github.com/SciresM/hactool/blob/master/npdm.h
// http://switchbrew.org/index.php?title=NPDM
public class Npdm
{
private const int MetaMagic = 'M' << 0 | 'E' << 8 | 'T' << 16 | 'A' << 24;
public byte MmuFlags { get; private set; }
public bool Is64Bits { get; private set; }
public byte MainThreadPriority { get; private set; }
public byte DefaultCpuId { get; private set; }
public int PersonalMmHeapSize { get; private set; }
public int ProcessCategory { get; private set; }
public int MainThreadStackSize { get; private set; }
public string TitleName { get; set; }
public byte[] ProductCode { get; private set; }
public Aci0 Aci0 { get; private set; }
public Acid Acid { get; private set; }
public Npdm(Stream stream)
{
BinaryReader reader = new BinaryReader(stream);
if (reader.ReadInt32() != MetaMagic)
{
throw new InvalidNpdmException("NPDM Stream doesn't contain NPDM file!");
}
reader.ReadInt64();
MmuFlags = reader.ReadByte();
Is64Bits = (MmuFlags & 1) != 0;
reader.ReadByte();
MainThreadPriority = reader.ReadByte();
DefaultCpuId = reader.ReadByte();
reader.ReadInt32();
PersonalMmHeapSize = reader.ReadInt32();
ProcessCategory = reader.ReadInt32();
MainThreadStackSize = reader.ReadInt32();
byte[] tempTitleName = reader.ReadBytes(0x10);
TitleName = Encoding.UTF8.GetString(tempTitleName, 0, tempTitleName.Length).Trim('\0');
ProductCode = reader.ReadBytes(0x10);
stream.Seek(0x30, SeekOrigin.Current);
int aci0Offset = reader.ReadInt32();
int aci0Size = reader.ReadInt32();
int acidOffset = reader.ReadInt32();
int acidSize = reader.ReadInt32();
Aci0 = new Aci0(stream, aci0Offset);
Acid = new Acid(stream, acidOffset);
}
}
}