mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-11-03 16:16:45 +00:00
Some performance updates
This commit is contained in:
@@ -4,21 +4,43 @@
|
||||
|
||||
namespace EightBit
|
||||
{
|
||||
public sealed class MemoryMapping(Memory memory, ushort begin, ushort mask, AccessLevel access)
|
||||
public sealed class MemoryMapping
|
||||
{
|
||||
public MemoryMapping(Memory memory, ushort begin, ushort mask, AccessLevel access)
|
||||
{
|
||||
this._memory = memory;
|
||||
this._begin = begin;
|
||||
this._mask = mask;
|
||||
this._access = access;
|
||||
for (int i = ushort.MinValue; i < ushort.MaxValue + 1; ++i)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(i >= ushort.MinValue);
|
||||
System.Diagnostics.Debug.Assert(i <= ushort.MaxValue);
|
||||
this._offsets[i] = this.CalculateOffset((ushort)i);
|
||||
}
|
||||
}
|
||||
|
||||
public MemoryMapping(Memory memory, ushort begin, Mask mask, AccessLevel access)
|
||||
: this(memory, begin, (ushort)mask, access)
|
||||
{
|
||||
}
|
||||
|
||||
public Memory Memory { get; set; } = memory;
|
||||
private readonly int[] _offsets = new int[ushort.MaxValue + 1];
|
||||
private readonly Memory _memory;
|
||||
private readonly ushort _begin;
|
||||
private readonly ushort _mask;
|
||||
private readonly AccessLevel _access;
|
||||
|
||||
public ushort Begin { get; set; } = begin;
|
||||
public Memory Memory => this._memory;
|
||||
|
||||
public ushort Mask { get; set; } = mask;
|
||||
public ushort Begin => this._begin;
|
||||
|
||||
public AccessLevel Access { get; set; } = access;
|
||||
public ushort Mask => this._mask;
|
||||
|
||||
public int Offset(ushort absolute) => (absolute - this.Begin) & this.Mask;
|
||||
public AccessLevel Access => this._access;
|
||||
|
||||
private int CalculateOffset(ushort absolute) => (absolute - this.Begin) & this.Mask;
|
||||
|
||||
public int Offset(ushort absolute) => this._offsets[absolute];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,8 @@ namespace EightBit
|
||||
|
||||
public void Assign(Register16 from)
|
||||
{
|
||||
this.Assign(from.Low, from.High);
|
||||
this.Low = from.Low;
|
||||
this.High = from.High;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -972,11 +972,11 @@ namespace M6502
|
||||
|
||||
private void JSR()
|
||||
{
|
||||
this.Intermediate.Low = this.FetchByte();
|
||||
var low = this.FetchByte();
|
||||
this.SwallowPop();
|
||||
this.PushWord(this.PC);
|
||||
this.PC.High = this.FetchByte();
|
||||
this.PC.Low = this.Intermediate.Low;
|
||||
var high = this.FetchByte();
|
||||
this.PC.Assign(low, high);
|
||||
}
|
||||
|
||||
private void PHP() => this.Push(SetBit(this.P, StatusBits.BF));
|
||||
|
||||
Reference in New Issue
Block a user