Fixed ROM header fields, and added an option to display headers.

MediaFormat values were guesses from various games (i.e. SM64 is a regular cartridge, OoT was to be expanded, and 64dd.org disk ID listings).
master
Nabile Rahmani 2018-11-21 16:05:28 +01:00
parent 10470e40b1
commit 84f14de487
3 changed files with 25 additions and 8 deletions

View File

@ -104,9 +104,24 @@ namespace DotN64.Desktop
break;
case "windowed":
case "w":
options.FullScreenVideo = false;
break;
}
break;
case "--info":
var cartridge = LoadCartridge(args[++i]);
Console.WriteLine($"Image name: {cartridge.ImageName}");
Console.WriteLine($"ID: {cartridge.ID}");
Console.WriteLine($"Version: {1.0f + (cartridge.Version & ((1 << 4) - 1) >> 4) + (cartridge.Version & ((1 << 4) - 1)) * 0.1f:0.0}");
Console.WriteLine($"Media format: {cartridge.Format}");
Console.WriteLine($"Country: {cartridge.Country}");
Console.WriteLine($"Size: {cartridge.ROM.Length / (float)0x100000:0.##} MB");
Console.WriteLine($"CRC: 0x{cartridge.CRC[0]:X8}, 0x{cartridge.CRC[1]:X8}");
Console.WriteLine($"Boot address: 0x{cartridge.BootAddress:X8}");
Console.WriteLine($"Clock rate: {cartridge.ClockRate}");
Console.WriteLine($"Release: {cartridge.Release}");
return;
default:
options.Cartridge = arg;
break;
@ -223,6 +238,7 @@ namespace DotN64.Desktop
Console.WriteLine("\t-h, --help: Shows this help.");
Console.WriteLine("\t-v, --video <width>x<height> <mode = 'fullscreen', 'f', 'borderless', 'b', 'windowed', 'w'>: Sets the window mode.");
Console.WriteLine("\t--no-video: Disables the video output.");
Console.WriteLine("\t--info <ROM image>: Displays header information for a game.");
}
#endregion

View File

@ -2,11 +2,12 @@
{
public partial class Cartridge
{
public enum MediaFormat
public enum MediaFormat : byte
{
Cartridge = 'N',
Disk = 'D',
ExpandableCartridge = 'E'
ExpandableCartridge = (byte)'C',
Disk = (byte)'D',
ExpansionDisk = (byte)'E',
Cartridge = (byte)'N'
}
}
}

View File

@ -17,9 +17,9 @@ namespace DotN64
public uint ClockRate => BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x04));
public uint BootAddressOffset => BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x08));
public uint BootAddress => BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x08));
public uint ReleaseOffset => BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x0C));
public uint Release => BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x0C));
public uint[] CRC => new[]
{
@ -29,9 +29,9 @@ namespace DotN64
public string ImageName => Encoding.ASCII.GetString(ROM, 0x20, 0x34 - 0x20);
public MediaFormat Format => (MediaFormat)BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x38));
public string ID => Encoding.ASCII.GetString(ROM, 0x3B, 4);
public ushort ID => BitHelper.FromBigEndian(BitConverter.ToUInt16(ROM, 0x3C));
public MediaFormat Format => (MediaFormat)ROM[0x3B];
public CountryCode Country => (CountryCode)ROM[0x3E];