mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-01-22 16:16:17 +00:00
Add easy to use Register16 assignment methods
This commit is contained in:
@@ -54,8 +54,7 @@ namespace EightBit
|
||||
|
||||
public byte Read(byte low, byte high)
|
||||
{
|
||||
this.Address.Low = low;
|
||||
this.Address.High = high;
|
||||
this.Address.Assign(low, high);
|
||||
return this.Read();
|
||||
}
|
||||
|
||||
@@ -83,8 +82,7 @@ namespace EightBit
|
||||
|
||||
public void Write(byte low, byte high, byte value)
|
||||
{
|
||||
this.Address.Low = low;
|
||||
this.Address.High = high;
|
||||
this.Address.Assign(low, high);
|
||||
this.Write(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -143,24 +143,21 @@ namespace EightBit
|
||||
protected sealed override Register16 GetWord()
|
||||
{
|
||||
var returned = base.GetWord();
|
||||
this.MEMPTR.Low = this.Bus.Address.Low;
|
||||
this.MEMPTR.High = this.Bus.Address.High;
|
||||
this.MEMPTR.Assign(this.Bus.Address);
|
||||
return returned;
|
||||
}
|
||||
|
||||
protected sealed override void SetWord(Register16 value)
|
||||
{
|
||||
base.SetWord(value);
|
||||
this.MEMPTR.Low = this.Bus.Address.Low;
|
||||
this.MEMPTR.High = this.Bus.Address.High;
|
||||
this.MEMPTR.Assign(this.Bus.Address);
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
protected void Restart(byte address)
|
||||
{
|
||||
this.MEMPTR.Low = address;
|
||||
this.MEMPTR.High = 0;
|
||||
this.MEMPTR.Assign(address, 0);
|
||||
this.Call(this.MEMPTR);
|
||||
}
|
||||
|
||||
@@ -199,8 +196,7 @@ namespace EightBit
|
||||
protected void FetchWordMEMPTR()
|
||||
{
|
||||
this.FetchWord();
|
||||
this.MEMPTR.Low = this.Intermediate.Low;
|
||||
this.MEMPTR.High = this.Intermediate.High;
|
||||
this.MEMPTR.Assign(this.Intermediate);
|
||||
}
|
||||
|
||||
protected void JumpIndirect()
|
||||
@@ -223,8 +219,7 @@ namespace EightBit
|
||||
|
||||
protected bool JumpRelativeConditional(bool condition)
|
||||
{
|
||||
this.Intermediate.Low = this.PC.Low;
|
||||
this.Intermediate.High = this.PC.High;
|
||||
this.Intermediate.Assign(this.PC);
|
||||
++this.PC.Word;
|
||||
if (condition)
|
||||
{
|
||||
@@ -238,8 +233,7 @@ namespace EightBit
|
||||
protected override sealed void Return()
|
||||
{
|
||||
base.Return();
|
||||
this.MEMPTR.Low = this.PC.Low;
|
||||
this.MEMPTR.High = this.PC.High;
|
||||
this.MEMPTR.Assign(this.PC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,15 +138,13 @@ namespace EightBit
|
||||
|
||||
protected void MemoryWrite(byte low, byte high)
|
||||
{
|
||||
this.Bus.Address.Low = low;
|
||||
this.Bus.Address.High = high;
|
||||
this.Bus.Address.Assign(low, high);
|
||||
this.MemoryWrite();
|
||||
}
|
||||
|
||||
protected void MemoryWrite(byte low, byte high, byte data)
|
||||
{
|
||||
this.Bus.Address.Low = low;
|
||||
this.Bus.Address.High = high;
|
||||
this.Bus.Address.Assign(low, high);
|
||||
this.MemoryWrite(data);
|
||||
}
|
||||
|
||||
@@ -172,8 +170,7 @@ namespace EightBit
|
||||
|
||||
protected byte MemoryRead(byte low, byte high)
|
||||
{
|
||||
this.Bus.Address.Low = low;
|
||||
this.Bus.Address.High = high;
|
||||
this.Bus.Address.Assign(low, high);
|
||||
return this.MemoryRead();
|
||||
}
|
||||
|
||||
@@ -191,9 +188,9 @@ namespace EightBit
|
||||
|
||||
protected byte FetchByte()
|
||||
{
|
||||
var returned = this.MemoryRead(this.PC);
|
||||
this.Bus.Address.Assign(this.PC);
|
||||
this.PC.Word++;
|
||||
return returned;
|
||||
return this.MemoryRead();
|
||||
}
|
||||
|
||||
protected abstract Register16 GetWord();
|
||||
@@ -209,8 +206,7 @@ namespace EightBit
|
||||
|
||||
protected Register16 GetWordPaged(byte page, byte offset)
|
||||
{
|
||||
this.Bus.Address.Low = offset;
|
||||
this.Bus.Address.High = page;
|
||||
this.Bus.Address.Assign(offset, page);
|
||||
return this.GetWordPaged();
|
||||
}
|
||||
|
||||
@@ -223,8 +219,7 @@ namespace EightBit
|
||||
|
||||
protected void SetWordPaged(byte page, byte offset, Register16 value)
|
||||
{
|
||||
this.Bus.Address.Low = offset;
|
||||
this.Bus.Address.High = page;
|
||||
this.Bus.Address.Assign(offset, page);
|
||||
this.SetWordPaged(value);
|
||||
}
|
||||
|
||||
@@ -233,8 +228,7 @@ namespace EightBit
|
||||
protected void FetchWordAddress()
|
||||
{
|
||||
this.FetchWord();
|
||||
this.Bus.Address.Low = this.Intermediate.Low;
|
||||
this.Bus.Address.High = this.Intermediate.High;
|
||||
this.Bus.Address.Assign(this.Intermediate);
|
||||
}
|
||||
|
||||
protected abstract void Push(byte value);
|
||||
@@ -253,8 +247,7 @@ namespace EightBit
|
||||
|
||||
protected Register16 GetWord(Register16 address)
|
||||
{
|
||||
this.Bus.Address.Low = address.Low;
|
||||
this.Bus.Address.High = address.High;
|
||||
this.Bus.Address.Assign(address);
|
||||
return this.GetWord();
|
||||
}
|
||||
|
||||
@@ -266,8 +259,7 @@ namespace EightBit
|
||||
|
||||
protected void SetWord(Register16 address, Register16 value)
|
||||
{
|
||||
this.Bus.Address.Low = address.Low;
|
||||
this.Bus.Address.High = address.High;
|
||||
this.Bus.Address.Assign(address);
|
||||
this.SetWord(value);
|
||||
}
|
||||
|
||||
@@ -275,8 +267,7 @@ namespace EightBit
|
||||
|
||||
protected void Jump(Register16 destination)
|
||||
{
|
||||
this.PC.Low = destination.Low;
|
||||
this.PC.High = destination.High;
|
||||
this.PC.Assign(destination);
|
||||
}
|
||||
|
||||
protected void Call(ushort destination)
|
||||
|
||||
@@ -90,5 +90,16 @@ namespace EightBit
|
||||
|
||||
return rhs.Low == this.Low && rhs.High == this.High;
|
||||
}
|
||||
|
||||
public void Assign(byte low, byte high)
|
||||
{
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
}
|
||||
|
||||
public void Assign(Register16 from)
|
||||
{
|
||||
this.Assign(from.low, from.high);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user