From c89a91449e1d430e4fd6348772735495687698e4 Mon Sep 17 00:00:00 2001 From: Nabile Rahmani Date: Fri, 21 Dec 2018 23:32:17 +0100 Subject: [PATCH] Set the MI version register to RCP v2.0. --- DotN64/DotN64.csproj | 1 + ...processor.MIPSInterface.VersionRegister.cs | 76 +++++++++++++++++++ .../MI/RealityCoprocessor.MIPSInterface.cs | 4 +- 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 DotN64/RCP/MI/RealityCoprocessor.MIPSInterface.VersionRegister.cs diff --git a/DotN64/DotN64.csproj b/DotN64/DotN64.csproj index 40b27f4..7add4e2 100644 --- a/DotN64/DotN64.csproj +++ b/DotN64/DotN64.csproj @@ -105,6 +105,7 @@ + diff --git a/DotN64/RCP/MI/RealityCoprocessor.MIPSInterface.VersionRegister.cs b/DotN64/RCP/MI/RealityCoprocessor.MIPSInterface.VersionRegister.cs new file mode 100644 index 0000000..023131f --- /dev/null +++ b/DotN64/RCP/MI/RealityCoprocessor.MIPSInterface.VersionRegister.cs @@ -0,0 +1,76 @@ +using System.Collections.Specialized; + +namespace DotN64.RCP +{ + public partial class RealityCoprocessor + { + public partial class MIPSInterface + { + public struct VersionRegister + { + #region Fields + private BitVector32 bits; + + private static readonly BitVector32.Section io = BitVector32.CreateSection((1 << 8) - 1), + rac = BitVector32.CreateSection((1 << 8) - 1, io), + rdp = BitVector32.CreateSection((1 << 8) - 1, rac), + rsp = BitVector32.CreateSection((1 << 8) - 1, rdp); + #endregion + + #region Properties + public byte IO + { + get => (byte)bits[io]; + set => bits[io] = value; + } + + public byte RAC + { + get => (byte)bits[rac]; + set => bits[rac] = value; + } + + public byte RDP + { + get => (byte)bits[rdp]; + set => bits[rdp] = value; + } + + public byte RSP + { + get => (byte)bits[rsp]; + set => bits[rsp] = value; + } + + /// + /// The prototype RCP chip. + /// + public static VersionRegister Version1 => new VersionRegister + { + IO = 1, + RAC = 1, + RDP = 1, + RSP = 1 + }; + + /// + /// The retail RCP chip. + /// + public static VersionRegister Version2 => new VersionRegister + { + IO = 2, + RAC = 1, + RDP = 2, + RSP = 2 + }; + #endregion + + #region Operators + public static implicit operator VersionRegister(uint data) => new VersionRegister { bits = new BitVector32((int)data) }; + + public static implicit operator uint(VersionRegister version) => (uint)version.bits.Data; + #endregion + } + } + } +} diff --git a/DotN64/RCP/MI/RealityCoprocessor.MIPSInterface.cs b/DotN64/RCP/MI/RealityCoprocessor.MIPSInterface.cs index 04625a3..20d82c2 100644 --- a/DotN64/RCP/MI/RealityCoprocessor.MIPSInterface.cs +++ b/DotN64/RCP/MI/RealityCoprocessor.MIPSInterface.cs @@ -13,6 +13,8 @@ namespace DotN64.RCP public InitModeRegister InitMode { get; set; } + public VersionRegister Version { get; set; } = VersionRegister.Version2; + public Interrupts InterruptMask { get; set; } private Interrupts interrupt; @@ -60,7 +62,7 @@ namespace DotN64.RCP }, new MappingEntry(0x04300004, 0x04300007) // MI version. { - Read = o => 0 // TODO. + Read = o => Version }, new MappingEntry(0x04300008, 0x0430000B) // MI interrupt. {