mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-11-25 06:17:29 +00:00
Simplify bus addressing
This commit is contained in:
@@ -61,7 +61,8 @@ namespace EightBit
|
|||||||
|
|
||||||
public byte Read(Register16 absolute)
|
public byte Read(Register16 absolute)
|
||||||
{
|
{
|
||||||
return this.Read(absolute.Low, absolute.High);
|
this.Address.Assign(absolute);
|
||||||
|
return this.Read();
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte Read(byte low, byte high)
|
public byte Read(byte low, byte high)
|
||||||
@@ -92,18 +93,22 @@ namespace EightBit
|
|||||||
public void Write(ushort absolute, byte value)
|
public void Write(ushort absolute, byte value)
|
||||||
{
|
{
|
||||||
this.Address.Word = absolute;
|
this.Address.Word = absolute;
|
||||||
this.Write(value);
|
this.Data = value;
|
||||||
|
this.Write();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(Register16 absolute, byte value)
|
public void Write(Register16 absolute, byte value)
|
||||||
{
|
{
|
||||||
this.Write(absolute.Low, absolute.High, value);
|
this.Address.Assign(absolute);
|
||||||
|
this.Data = value;
|
||||||
|
this.Write();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(byte low, byte high, byte value)
|
public void Write(byte low, byte high, byte value)
|
||||||
{
|
{
|
||||||
this.Address.Assign(low, high);
|
this.Address.Assign(low, high);
|
||||||
this.Write(value);
|
this.Data = value;
|
||||||
|
this.Write();
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1030:Use events where appropriate", Justification = "The word 'raise' is used in an electrical sense")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1030:Use events where appropriate", Justification = "The word 'raise' is used in an electrical sense")]
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ namespace EightBit
|
|||||||
|
|
||||||
protected void Restart(byte address)
|
protected void Restart(byte address)
|
||||||
{
|
{
|
||||||
this.MEMPTR.Assign(address, 0);
|
this.MEMPTR.Assign(address);
|
||||||
this.Call(this.MEMPTR);
|
this.Call(this.MEMPTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,23 +202,28 @@ namespace EightBit
|
|||||||
protected void MemoryWrite(byte low, byte high, byte data)
|
protected void MemoryWrite(byte low, byte high, byte data)
|
||||||
{
|
{
|
||||||
this.Bus.Address.Assign(low, high);
|
this.Bus.Address.Assign(low, high);
|
||||||
this.MemoryWrite(data);
|
this.Bus.Data = data;
|
||||||
|
this.MemoryWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void MemoryWrite(ushort address, byte data)
|
protected void MemoryWrite(ushort address, byte data)
|
||||||
{
|
{
|
||||||
this.Bus.Address.Word = address;
|
this.Bus.Address.Word = address;
|
||||||
this.MemoryWrite(data);
|
this.Bus.Data = data;
|
||||||
|
this.MemoryWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void MemoryWrite(Register16 address, byte data)
|
protected void MemoryWrite(Register16 address, byte data)
|
||||||
{
|
{
|
||||||
this.MemoryWrite(address.Low, address.High, data);
|
this.Bus.Address.Assign(address);
|
||||||
|
this.Bus.Data = data;
|
||||||
|
this.MemoryWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void MemoryWrite(Register16 address)
|
protected void MemoryWrite(Register16 address)
|
||||||
{
|
{
|
||||||
this.MemoryWrite(address.Low, address.High);
|
this.Bus.Address.Assign(address);
|
||||||
|
this.MemoryWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void MemoryWrite(byte data)
|
protected void MemoryWrite(byte data)
|
||||||
@@ -245,7 +250,8 @@ namespace EightBit
|
|||||||
|
|
||||||
protected byte MemoryRead(Register16 address)
|
protected byte MemoryRead(Register16 address)
|
||||||
{
|
{
|
||||||
return this.MemoryRead(address.Low, address.High);
|
this.Bus.Address.Assign(address);
|
||||||
|
return this.MemoryRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual byte MemoryRead()
|
protected virtual byte MemoryRead()
|
||||||
@@ -279,7 +285,8 @@ namespace EightBit
|
|||||||
|
|
||||||
protected Register16 GetWordPaged(Register16 address)
|
protected Register16 GetWordPaged(Register16 address)
|
||||||
{
|
{
|
||||||
return this.GetWordPaged(address.High, address.Low);
|
this.Bus.Address.Assign(address);
|
||||||
|
return this.GetWordPaged();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Register16 GetWordPaged(byte page, byte offset)
|
protected Register16 GetWordPaged(byte page, byte offset)
|
||||||
@@ -292,7 +299,8 @@ namespace EightBit
|
|||||||
|
|
||||||
protected void SetWordPaged(Register16 address, Register16 value)
|
protected void SetWordPaged(Register16 address, Register16 value)
|
||||||
{
|
{
|
||||||
this.SetWordPaged(address.High, address.Low, value);
|
this.Bus.Address.Assign(address);
|
||||||
|
this.SetWordPaged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SetWordPaged(byte page, byte offset, Register16 value)
|
protected void SetWordPaged(byte page, byte offset, Register16 value)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ namespace EightBit
|
|||||||
|
|
||||||
public bool Equals(Register16? rhs) => ReferenceEquals(this, rhs) || (rhs is not null && rhs.Low == this.Low && rhs.High == this.High);
|
public bool Equals(Register16? rhs) => ReferenceEquals(this, rhs) || (rhs is not null && rhs.Low == this.Low && rhs.High == this.High);
|
||||||
|
|
||||||
public void Assign(byte low, byte high)
|
public void Assign(byte low, byte high = 0)
|
||||||
{
|
{
|
||||||
this.Low = low;
|
this.Low = low;
|
||||||
this.High = high;
|
this.High = high;
|
||||||
@@ -93,9 +93,17 @@ namespace EightBit
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ushort Increment() => this.Word++;
|
public Register16 Increment()
|
||||||
|
{
|
||||||
|
this.Word++;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ushort Decrement() => this.Word--;
|
public Register16 Decrement()
|
||||||
|
{
|
||||||
|
this.Word--;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -725,7 +725,7 @@ namespace M6502
|
|||||||
|
|
||||||
protected void AbsoluteAddress() => this.FetchWordAddress();
|
protected void AbsoluteAddress() => this.FetchWordAddress();
|
||||||
|
|
||||||
protected void ZeroPageAddress() => this.Bus.Address.Assign(this.FetchByte(), 0);
|
protected void ZeroPageAddress() => this.Bus.Address.Assign(this.FetchByte());
|
||||||
|
|
||||||
protected void ZeroPageIndirectAddress()
|
protected void ZeroPageIndirectAddress()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user