Fixed SI interrupts and moved memory maps.

master
Nabile Rahmani 2018-12-11 20:36:16 +01:00
parent 6fc595dc27
commit 7b9ad33be2
3 changed files with 37 additions and 24 deletions

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
namespace DotN64
{
@ -16,8 +15,6 @@ namespace DotN64
#endregion
#region Properties
public IReadOnlyList<MappingEntry> MemoryMaps { get; }
public byte[] BootROM { get; set; }
public byte[] RAM { get; } = new byte[64];
@ -33,22 +30,6 @@ namespace DotN64
public PeripheralInterface(Nintendo64 nintendo64)
{
this.nintendo64 = nintendo64;
MemoryMaps = new[]
{
new MappingEntry(0x1FC00000, 0x1FC007BF) // PIF Boot ROM.
{
Read = o => BitHelper.FromBigEndian(BitConverter.ToUInt32(BootROM, (int)o))
},
new MappingEntry(0x1FC007C0, 0x1FC007FF) // PIF (JoyChannel) RAM.
{
Read = o => BitConverter.ToUInt32(RAM, (int)o),
Write = (o, d) =>
{
BitHelper.Write(RAM, (int)o, d);
OnRAMWritten((int)o);
}
}
};
}
#endregion
@ -57,7 +38,7 @@ namespace DotN64
/// Called when a word is written at a specified index in the RAM.
/// Handles actions sent through memory writes.
/// </summary>
private void OnRAMWritten(int index)
internal void OnRAMWritten(int index)
{
switch (index)
{

View File

@ -95,8 +95,8 @@ namespace DotN64.RCP
},
new MappingEntry(0x1FC00000, 0x1FC007FF, false)
{
Read = nintendo64.PIF.MemoryMaps.ReadWord,
Write = nintendo64.PIF.MemoryMaps.WriteWord
Read = SI.MemoryMaps.ReadWord,
Write = SI.MemoryMaps.WriteWord
}
};
}

View File

@ -1,10 +1,16 @@
namespace DotN64.RCP
using System;
namespace DotN64.RCP
{
using Helpers;
public partial class RealityCoprocessor
{
public partial class SerialInterface : Interface
{
#region Properties
private PeripheralInterface PIF => rcp.nintendo64.PIF;
public Statuses Status { get; set; }
#endregion
@ -17,11 +23,37 @@
new MappingEntry(0x04800018, 0x0480001B) // SI status.
{
Read = o => (uint)Status,
Write = (o, d) => Status &= ~Statuses.Interrupt
Write = (o, d) =>
{
Status &= ~Statuses.Interrupt;
rcp.MI.Interrupt &= ~MIPSInterface.Interrupts.SI;
}
},
new MappingEntry(0x1FC00000, 0x1FC007BF) // PIF Boot ROM.
{
Read = o => BitHelper.FromBigEndian(BitConverter.ToUInt32(PIF.BootROM, (int)o))
},
new MappingEntry(0x1FC007C0, 0x1FC007FF) // PIF (JoyChannel) RAM.
{
Read = o => BitConverter.ToUInt32(PIF.RAM, (int)o),
Write = (o, d) =>
{
BitHelper.Write(PIF.RAM, (int)o, d);
PIF.OnRAMWritten((int)o);
Interrupt();
}
}
};
}
#endregion
#region Methods
private void Interrupt()
{
Status |= Statuses.Interrupt;
rcp.MI.Interrupt |= MIPSInterface.Interrupts.SI;
}
#endregion
}
}
}