2017-10-03 19:49:25 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
2017-08-28 08:53:48 +02:00
|
|
|
|
|
2017-10-09 08:21:31 +02:00
|
|
|
|
namespace DotN64
|
2017-08-28 08:53:48 +02:00
|
|
|
|
{
|
2017-12-18 08:50:25 +01:00
|
|
|
|
using Helpers;
|
|
|
|
|
|
2018-01-23 18:46:12 +01:00
|
|
|
|
public partial class Cartridge
|
2017-08-28 08:53:48 +02:00
|
|
|
|
{
|
2018-01-23 18:46:12 +01:00
|
|
|
|
#region Fields
|
|
|
|
|
public const ushort HeaderSize = 0x40, BootstrapSize = 0x1000 - HeaderSize;
|
|
|
|
|
#endregion
|
|
|
|
|
|
2017-08-28 08:53:48 +02:00
|
|
|
|
#region Properties
|
2018-06-27 16:08:45 +02:00
|
|
|
|
public byte[] ROM { get; }
|
2017-10-03 19:49:25 +02:00
|
|
|
|
|
2017-12-18 08:50:25 +01:00
|
|
|
|
public uint ClockRate => BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x04));
|
2017-10-03 19:49:25 +02:00
|
|
|
|
|
2018-11-21 16:05:28 +01:00
|
|
|
|
public uint BootAddress => BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x08));
|
2017-10-03 19:49:25 +02:00
|
|
|
|
|
2018-11-21 16:05:28 +01:00
|
|
|
|
public uint Release => BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x0C));
|
2017-10-03 19:49:25 +02:00
|
|
|
|
|
|
|
|
|
public uint[] CRC => new[]
|
|
|
|
|
{
|
2017-12-18 08:50:25 +01:00
|
|
|
|
BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x10)),
|
|
|
|
|
BitHelper.FromBigEndian(BitConverter.ToUInt32(ROM, 0x14))
|
2017-10-03 19:49:25 +02:00
|
|
|
|
};
|
|
|
|
|
|
2017-10-13 21:02:42 +02:00
|
|
|
|
public string ImageName => Encoding.ASCII.GetString(ROM, 0x20, 0x34 - 0x20);
|
2017-10-03 19:49:25 +02:00
|
|
|
|
|
2018-11-21 16:05:28 +01:00
|
|
|
|
public string ID => Encoding.ASCII.GetString(ROM, 0x3B, 4);
|
2018-01-23 18:46:12 +01:00
|
|
|
|
|
2018-11-21 16:05:28 +01:00
|
|
|
|
public MediaFormat Format => (MediaFormat)ROM[0x3B];
|
2017-10-03 19:49:25 +02:00
|
|
|
|
|
2018-12-11 20:47:19 +01:00
|
|
|
|
public RegionCode Region => (RegionCode)ROM[0x3E];
|
2017-10-03 19:49:25 +02:00
|
|
|
|
|
2018-01-23 18:46:12 +01:00
|
|
|
|
public byte Version => ROM[0x3F];
|
2017-08-28 08:53:48 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
2018-06-27 16:08:45 +02:00
|
|
|
|
#region Constructors
|
|
|
|
|
public Cartridge(byte[] rom)
|
|
|
|
|
{
|
|
|
|
|
ROM = rom;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 21:36:41 +02:00
|
|
|
|
public Cartridge(FileInfo file)
|
|
|
|
|
: this(File.ReadAllBytes(file.FullName)) { }
|
2017-08-28 08:53:48 +02:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|