mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-04-19 15:16:41 +00:00
Help out callers using Register16 arguments a little: Don't always require the ".Word" property to be passed.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
@@ -97,7 +97,7 @@ namespace EightBit
|
||||
protected override void HandleRESET()
|
||||
{
|
||||
base.HandleRESET();
|
||||
this.PC().Word = 0;
|
||||
this.Jump(0);
|
||||
}
|
||||
|
||||
protected sealed override void Push(byte value) => this.Bus.Write(--this.SP(), value);
|
||||
@@ -123,7 +123,7 @@ namespace EightBit
|
||||
{
|
||||
this.MEMPTR().Low = address;
|
||||
this.MEMPTR().High = 0;
|
||||
this.Call(this.MEMPTR().Word);
|
||||
this.Call(this.MEMPTR());
|
||||
}
|
||||
|
||||
protected bool CallConditional(bool condition)
|
||||
@@ -131,7 +131,7 @@ namespace EightBit
|
||||
this.MEMPTR().Word = this.FetchWord().Word;
|
||||
if (condition)
|
||||
{
|
||||
this.Call(this.MEMPTR().Word);
|
||||
this.Call(this.MEMPTR());
|
||||
}
|
||||
|
||||
return condition;
|
||||
@@ -142,7 +142,7 @@ namespace EightBit
|
||||
this.MEMPTR().Word = this.FetchWord().Word;
|
||||
if (condition)
|
||||
{
|
||||
this.Jump(this.MEMPTR().Word);
|
||||
this.Jump(this.MEMPTR());
|
||||
}
|
||||
|
||||
return condition;
|
||||
@@ -161,7 +161,7 @@ namespace EightBit
|
||||
protected void JumpRelative(sbyte offset)
|
||||
{
|
||||
this.MEMPTR().Word = (ushort)(this.PC().Word + offset);
|
||||
this.Jump(this.MEMPTR().Word);
|
||||
this.Jump(this.MEMPTR());
|
||||
}
|
||||
|
||||
protected bool JumpRelativeConditional(bool condition)
|
||||
|
||||
@@ -129,6 +129,8 @@ namespace EightBit
|
||||
this.BusWrite(data);
|
||||
}
|
||||
|
||||
protected void BusWrite(Register16 address, byte data) => this.BusWrite(address.Word, data);
|
||||
|
||||
protected void BusWrite(byte data)
|
||||
{
|
||||
this.Bus.Data = data;
|
||||
@@ -150,9 +152,11 @@ namespace EightBit
|
||||
return this.BusRead();
|
||||
}
|
||||
|
||||
protected byte BusRead(Register16 address) => this.BusRead(address.Word);
|
||||
|
||||
protected virtual byte BusRead() => this.Bus.Read(); // N.B. Should be the only real call into the "Bus.Read" code.
|
||||
|
||||
protected byte FetchByte() => this.BusRead(this.PC().Word++);
|
||||
protected byte FetchByte() => this.BusRead(this.PC()++);
|
||||
|
||||
protected abstract Register16 GetWord();
|
||||
|
||||
@@ -186,12 +190,16 @@ namespace EightBit
|
||||
|
||||
protected void Jump(ushort destination) => this.PC().Word = destination;
|
||||
|
||||
protected void Jump(Register16 destination) => this.Jump(destination.Word);
|
||||
|
||||
protected void Call(ushort destination)
|
||||
{
|
||||
this.PushWord(this.PC());
|
||||
this.Jump(destination);
|
||||
}
|
||||
|
||||
protected void Call(Register16 destination) => this.Call(destination.Word);
|
||||
|
||||
protected virtual void Return() => this.Jump(this.PopWord().Word);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user