As the external agent, the RCP should define its memory maps.

master
Nabile Rahmani 2017-12-20 01:20:12 +01:00
parent 71904ce63f
commit cc81d9d21d
4 changed files with 81 additions and 79 deletions

View File

@ -1,6 +1,4 @@
using System.Collections.Generic;
namespace DotN64
namespace DotN64
{
using CPU;
using Extensions;
@ -9,8 +7,6 @@ namespace DotN64
public class Nintendo64
{
#region Properties
public IReadOnlyList<MappingEntry> MemoryMaps { get; }
public VR4300 CPU { get; }
public RealityCoprocessor RCP { get; }
@ -25,80 +21,13 @@ namespace DotN64
#region Constructors
public Nintendo64()
{
RCP = new RealityCoprocessor(this);
PIF = new PeripheralInterface(this);
MemoryMaps = new[]
{
new MappingEntry(0x1FC00000, 0x1FC007BF, false) // PIF Boot ROM.
{
Read = PIF.MemoryMaps.ReadWord,
Write = PIF.MemoryMaps.WriteWord
},
new MappingEntry(0x1FC007C0, 0x1FC007FF, false) // PIF (JoyChannel) RAM.
{
Read = PIF.MemoryMaps.ReadWord,
Write = PIF.MemoryMaps.WriteWord
},
new MappingEntry(0x04600000, 0x046FFFFF, false) // Peripheral interface (PI) registers.
{
Read = RCP.PI.MemoryMaps.ReadWord,
Write = RCP.PI.MemoryMaps.WriteWord
},
new MappingEntry(0x04000000, 0x040FFFFF, false) // SP registers.
{
Read = RCP.SP.MemoryMaps.ReadWord,
Write = RCP.SP.MemoryMaps.WriteWord
},
new MappingEntry(0x04400000, 0x044FFFFF, false) // Video interface (VI) registers.
{
Read = RCP.VI.MemoryMaps.ReadWord,
Write = RCP.VI.MemoryMaps.WriteWord
},
new MappingEntry(0x04500000, 0x045FFFFF, false) // Audio interface (AI) registers.
{
Read = RCP.AI.MemoryMaps.ReadWord,
Write = RCP.AI.MemoryMaps.WriteWord
},
new MappingEntry(0x04300000, 0x043FFFFF, false) // MIPS interface (MI) registers.
{
Read = RCP.MI.MemoryMaps.ReadWord,
Write = RCP.MI.MemoryMaps.WriteWord
},
new MappingEntry(0x04800000, 0x048FFFFF, false) // Serial interface (SI) registers.
{
Read = RCP.SI.MemoryMaps.ReadWord,
Write = RCP.SI.MemoryMaps.WriteWord
},
new MappingEntry(0x10000000, 0x1FBFFFFF, false) // Cartridge Domain 1 Address 2.
{
Read = RCP.PI.MemoryMaps.ReadWord
},
new MappingEntry(0x04100000, 0x041FFFFF, false) // DP command registers.
{
Read = RCP.DP.MemoryMaps.ReadWord,
Write = RCP.DP.MemoryMaps.WriteWord
},
new MappingEntry(0x04700000, 0x047FFFFF, false) // RDRAM interface (RI) registers.
{
Read = RCP.RI.MemoryMaps.ReadWord,
Write = RCP.RI.MemoryMaps.WriteWord
},
new MappingEntry(0x00000000, 0x03EFFFFF, false) // RDRAM memory.
{
Read = RAM.MemoryMaps.ReadWord,
Write = RAM.MemoryMaps.WriteWord
},
new MappingEntry(0x03F00000, 0x03FFFFFF, false) // RDRAM registers.
{
Read = RAM.MemoryMaps.ReadWord,
Write = RAM.MemoryMaps.WriteWord
}
};
RCP = new RealityCoprocessor(this);
CPU = new VR4300
{
DivMode = 0b01, // Assuming this value as the CPU is clocked at 93.75 MHz, and the RCP would be clocked at 93.75 / 3 * 2 = 62.5 MHz.
ReadSysAD = MemoryMaps.ReadWord,
WriteSysAD = MemoryMaps.WriteWord
ReadSysAD = RCP.MemoryMaps.ReadWord,
WriteSysAD = RCP.MemoryMaps.WriteWord
};
}
#endregion

View File

@ -90,14 +90,14 @@ namespace DotN64
for (int i = 0; i < writes.GetLength(0); i++)
{
nintendo64.MemoryMaps.WriteWord(writes[i, 0], writes[i, 1]);
nintendo64.RCP.MemoryMaps.WriteWord(writes[i, 0], writes[i, 1]);
}
if (DeviceStateFlags.ROM == DeviceState.ROMType.Cartridge && nintendo64.Cartridge != null)
{
for (int i = 0x40; i < 0x1000; i += sizeof(uint)) // Copying the bootstrap code from the cartridge to the RSP's DMEM.
{
nintendo64.MemoryMaps.WriteWord((ulong)(0x04000000 + i), BitHelper.FromBigEndian(BitConverter.ToUInt32(nintendo64.Cartridge.ROM, i)));
BitHelper.Write(nintendo64.RCP.SP.DMEM, i, BitHelper.FromBigEndian(BitConverter.ToUInt32(nintendo64.Cartridge.ROM, i)));
}
}

View File

@ -82,7 +82,7 @@ namespace DotN64.RCP
{
WriteLength = v & ((1 << 24) - 1);
Status |= StatusRegister.DMABusy;
var maps = rcp.Nintendo64.MemoryMaps;
var maps = rcp.MemoryMaps;
for (uint i = 0; i < WriteLength + 1; i += sizeof(uint))
{

View File

@ -1,8 +1,14 @@
namespace DotN64.RCP
using System.Collections.Generic;
namespace DotN64.RCP
{
using Extensions;
public partial class RealityCoprocessor
{
#region Properties
public IReadOnlyList<MappingEntry> MemoryMaps { get; }
public Nintendo64 Nintendo64 { get; }
public SignalProcessor SP { get; } = new SignalProcessor();
@ -32,6 +38,73 @@
VI = new VideoInterface(this);
MI = new MIPSInterface(this);
RI = new RDRAMInterface(this);
MemoryMaps = new[]
{
new MappingEntry(0x1FC00000, 0x1FC007BF, false) // PIF Boot ROM.
{
Read = Nintendo64.PIF.MemoryMaps.ReadWord,
Write = Nintendo64.PIF.MemoryMaps.WriteWord
},
new MappingEntry(0x1FC007C0, 0x1FC007FF, false) // PIF (JoyChannel) RAM.
{
Read = Nintendo64.PIF.MemoryMaps.ReadWord,
Write = Nintendo64.PIF.MemoryMaps.WriteWord
},
new MappingEntry(0x04600000, 0x046FFFFF, false) // Peripheral interface (PI) registers.
{
Read = PI.MemoryMaps.ReadWord,
Write = PI.MemoryMaps.WriteWord
},
new MappingEntry(0x04000000, 0x040FFFFF, false) // SP registers.
{
Read = SP.MemoryMaps.ReadWord,
Write = SP.MemoryMaps.WriteWord
},
new MappingEntry(0x04400000, 0x044FFFFF, false) // Video interface (VI) registers.
{
Read = VI.MemoryMaps.ReadWord,
Write = VI.MemoryMaps.WriteWord
},
new MappingEntry(0x04500000, 0x045FFFFF, false) // Audio interface (AI) registers.
{
Read = AI.MemoryMaps.ReadWord,
Write = AI.MemoryMaps.WriteWord
},
new MappingEntry(0x04300000, 0x043FFFFF, false) // MIPS interface (MI) registers.
{
Read = MI.MemoryMaps.ReadWord,
Write = MI.MemoryMaps.WriteWord
},
new MappingEntry(0x04800000, 0x048FFFFF, false) // Serial interface (SI) registers.
{
Read = SI.MemoryMaps.ReadWord,
Write = SI.MemoryMaps.WriteWord
},
new MappingEntry(0x10000000, 0x1FBFFFFF, false) // Cartridge Domain 1 Address 2.
{
Read = PI.MemoryMaps.ReadWord
},
new MappingEntry(0x04100000, 0x041FFFFF, false) // DP command registers.
{
Read = DP.MemoryMaps.ReadWord,
Write = DP.MemoryMaps.WriteWord
},
new MappingEntry(0x04700000, 0x047FFFFF, false) // RDRAM interface (RI) registers.
{
Read = RI.MemoryMaps.ReadWord,
Write = RI.MemoryMaps.WriteWord
},
new MappingEntry(0x00000000, 0x03EFFFFF, false) // RDRAM memory.
{
Read = Nintendo64.RAM.MemoryMaps.ReadWord,
Write = Nintendo64.RAM.MemoryMaps.WriteWord
},
new MappingEntry(0x03F00000, 0x03FFFFFF, false) // RDRAM registers.
{
Read = Nintendo64.RAM.MemoryMaps.ReadWord,
Write = Nintendo64.RAM.MemoryMaps.WriteWord
}
};
}
#endregion
}