Implement some suggestions from the code analysis.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2019-02-14 23:51:32 +00:00
parent 63db46a7bc
commit cf4e633034
6 changed files with 35 additions and 57 deletions

View File

@ -55,10 +55,7 @@ namespace EightBit
return this.Read(); return this.Read();
} }
public byte Read(Register16 absolute) public byte Read(Register16 absolute) => this.Read(absolute.Word);
{
return this.Read(absolute.Word);
}
public byte Read(byte low, byte high) public byte Read(byte low, byte high)
{ {
@ -86,10 +83,7 @@ namespace EightBit
this.Write(value); this.Write(value);
} }
public void Write(Register16 absolute, byte value) public void Write(Register16 absolute, byte value) => this.Write(absolute.Word, value);
{
this.Write(absolute.Word, value);
}
public void Write(byte low, byte high, byte value) public void Write(byte low, byte high, byte value)
{ {

View File

@ -6,6 +6,6 @@ namespace EightBit
{ {
public interface IMapper public interface IMapper
{ {
MemoryMapping Mapping(ushort address); MemoryMapping Mapping(ushort absolute);
} }
} }

View File

@ -6,11 +6,11 @@ namespace EightBit
{ {
public class IntelOpCodeDecoded public class IntelOpCodeDecoded
{ {
private int x; private readonly int x;
private int y; private readonly int y;
private int z; private readonly int z;
private int p; private readonly int p;
private int q; private readonly int q;
public IntelOpCodeDecoded() public IntelOpCodeDecoded()
{ {

View File

@ -16,10 +16,7 @@ namespace EightBit
public abstract byte Peek(ushort address); public abstract byte Peek(ushort address);
public virtual ref byte Reference(ushort address) public virtual ref byte Reference(ushort address) => throw new NotImplementedException();
{
throw new NotImplementedException();
}
public abstract int Load(FileStream file, int writeOffset = 0, int readOffset = 0, int limit = -1); public abstract int Load(FileStream file, int writeOffset = 0, int readOffset = 0, int limit = -1);

View File

@ -48,25 +48,13 @@ namespace EightBit
this.Word = rhs.Word; this.Word = rhs.Word;
} }
public static Register16 operator ++(Register16 value) public static Register16 operator ++(Register16 value) => Increment(value);
{
return Increment(value);
}
public static Register16 operator --(Register16 value) public static Register16 operator --(Register16 value) => Decrement(value);
{
return Decrement(value);
}
public static bool operator ==(Register16 left, Register16 right) public static bool operator ==(Register16 left, Register16 right) => left.Equals(right);
{
return left.Equals(right);
}
public static bool operator !=(Register16 left, Register16 right) public static bool operator !=(Register16 left, Register16 right) => !(left == right);
{
return !(left == right);
}
public static Register16 Increment(Register16 value) public static Register16 Increment(Register16 value)
{ {
@ -91,9 +79,6 @@ namespace EightBit
return rhs.Word == this.Word; return rhs.Word == this.Word;
} }
public override int GetHashCode() public override int GetHashCode() => this.Word;
{
return this.Word;
}
} }
} }

View File

@ -9,28 +9,30 @@ namespace EightBit
[Flags] [Flags]
public enum StatusBits : byte public enum StatusBits : byte
{ {
// Negative None = 0,
NF = Bits.Bit7,
// Overflow // Carry
VF = Bits.Bit6, CF = Bits.Bit0,
// reserved
RF = Bits.Bit5,
// Brk
BF = Bits.Bit4,
// D (use BCD for arithmetic)
DF = Bits.Bit3,
// I (IRQ disable)
IF = Bits.Bit2,
// Zero // Zero
ZF = Bits.Bit1, ZF = Bits.Bit1,
// Carry // I (IRQ disable)
CF = Bits.Bit0, IF = Bits.Bit2,
}
// D (use BCD for arithmetic)
DF = Bits.Bit3,
// Brk
BF = Bits.Bit4,
// reserved
RF = Bits.Bit5,
// Overflow
VF = Bits.Bit6,
// Negative
NF = Bits.Bit7,
}
} }