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:
Adrian Conlon
2019-02-15 00:26:01 +00:00
parent cf4e633034
commit c6a7003b8d
3 changed files with 28 additions and 20 deletions
+9 -1
View File
@@ -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);
}
}