Ryujinx/Ryujinx.HLE/Loaders/Npdm/Npdm.cs

73 lines
2.3 KiB
C#
Raw Normal View History

2018-11-29 03:01:19 +01:00
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
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 05:32:51 +01:00
public class Npdm
2018-11-29 03:01:19 +01:00
{
private const int MetaMagic = 'M' << 0 | 'E' << 8 | 'T' << 16 | 'A' << 24;
public byte MmuFlags { get; private set; }
public bool Is64Bit { get; private set; }
public byte MainThreadPriority { get; private set; }
public byte DefaultCpuId { get; private set; }
public int PersonalMmHeapSize { get; private set; }
public int Version { get; private set; }
public int MainThreadStackSize { get; private set; }
Added GUI to Ryujinx (#695) * Added GUI to Ryujinx * Updated to use Glade Also added scrollbar and default dark theme * Added support for loading icon from .nro files and cleaned up the code a bit * Added General Settings Menu (read-only for now) and moved some functionality from MainMenu.cs to ApplicationLibrary.cs * Added custom GUI theme support and changed the defualt theme to one I just wrote * Added GTK to process path, fixed a bug and minor edits * some more edits and a bug fix * general settings menu is now fully functional. also fixed the bug where ryujinx crashes when it trys to load an invalid gamedir * big rewrite * aesthetic changes to General Settings menu * Added Control Settings one day done feature :P * minor changes * 1st wave of changes * 2nd wave of changes * 3rd wave of changes * Cleanup settings ui * minor edits * new about window added, still needs styling * added spin button for new option and tooltips to settings * Game icons and names are now shown in the games list * add nuget package which contains gtk dependencies * requested changes have been changed * put CreateGameWindow on a new thread and stopped destroying the main menu when a game loads * fixed bug that allowed a user to attempt to load multiple games at a time which causes a crash * Added LastPlayed and TimePlayed columns to the game list * Did some testing and fixed some bugs Im not happy with one of the fixes so i will do it properly an upcoming commit * did some more bug testing and fixed another 2 bugs * caught an exception when ryujinx tries to load non-homebrew as homebrew * Large changes Rewrote ApplicationLibrary.cs (added comments too) so any devs reading it wont get eye cancer, also its probably more efficient now. Added 2 new columns (Developer name and application version) to the game list and wrote the logic for it. Ryujinx now loads NRO's TitleName and TitleID from the NACP file instead of the default NPDM. I also killed a lot of bugs * Moved Files moved ApplicationLibrary.cs to Ryujinx.HLE as that is a better place for it. Moved contents of GUI folder to Ui folder and changed the namespaces of the gui files from Ryujinx to Ryujinx.Ui * Added 'Open Ryujinx Folder' button to the file menu and did some small fixes * New features * updated nuget package with missing dlls and changed emmauss' requested changes * fixed some minor issues * all requested changes marked as resolved have been changed * gdkchan's requested changes * fixed an issue with settings window getting chopped on small res * fixed 2 problems caused by rebase * changed the default theme * applied Thog's patch to fix issue on linux * fixed issue caused by rebase * added update check button that runs ryujinx-updater * reads version info from installer and displays it in about menu * changes completed * requested changes changed * fixed issue with default theme * fixed a bug and completed requested changes * added more tooltips and changed some text
2019-09-02 18:03:57 +02:00
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)
2018-11-29 03:01:19 +01:00
{
BinaryReader reader = new BinaryReader(stream);
2018-11-29 03:01:19 +01:00
if (reader.ReadInt32() != MetaMagic)
2018-11-29 03:01:19 +01:00
{
throw new InvalidNpdmException("NPDM Stream doesn't contain NPDM file!");
}
reader.ReadInt64();
2018-11-29 03:01:19 +01:00
MmuFlags = reader.ReadByte();
2018-11-29 03:01:19 +01:00
Is64Bit = (MmuFlags & 1) != 0;
2018-11-29 03:01:19 +01:00
reader.ReadByte();
2018-11-29 03:01:19 +01:00
MainThreadPriority = reader.ReadByte();
DefaultCpuId = reader.ReadByte();
2018-11-29 03:01:19 +01:00
reader.ReadInt32();
2018-11-29 03:01:19 +01:00
PersonalMmHeapSize = reader.ReadInt32();
2018-11-29 03:01:19 +01:00
Version = reader.ReadInt32();
2018-11-29 03:01:19 +01:00
MainThreadStackSize = reader.ReadInt32();
2018-11-29 03:01:19 +01:00
byte[] tempTitleName = reader.ReadBytes(0x10);
2018-11-29 03:01:19 +01:00
TitleName = Encoding.UTF8.GetString(tempTitleName, 0, tempTitleName.Length).Trim('\0');
2018-11-29 03:01:19 +01:00
ProductCode = reader.ReadBytes(0x10);
2018-11-29 03:01:19 +01:00
stream.Seek(0x30, SeekOrigin.Current);
2018-11-29 03:01:19 +01:00
int aci0Offset = reader.ReadInt32();
int aci0Size = reader.ReadInt32();
int acidOffset = reader.ReadInt32();
int acidSize = reader.ReadInt32();
2018-11-29 03:01:19 +01:00
Aci0 = new Aci0(stream, aci0Offset);
Acid = new Acid(stream, acidOffset);
2018-11-29 03:01:19 +01:00
}
}
}