mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-01-22 16:16:17 +00:00
Code analysis corrections.
This commit is contained in:
@@ -14,6 +14,7 @@ namespace EightBit
|
||||
|
||||
public override void PokeWord(ushort address, Register16 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
Bus.Poke(address, value.High);
|
||||
Bus.Poke(++address, value.Low);
|
||||
}
|
||||
@@ -50,12 +51,14 @@ namespace EightBit
|
||||
|
||||
protected override void PushWord(Register16 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
Push(value.Low);
|
||||
Push(value.High);
|
||||
}
|
||||
|
||||
protected override void SetWord(Register16 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
MemoryWrite(value.High);
|
||||
++Bus.Address.Word;
|
||||
MemoryWrite(value.Low);
|
||||
@@ -63,6 +66,7 @@ namespace EightBit
|
||||
|
||||
protected override void SetWordPaged(Register16 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
MemoryWrite(value.High);
|
||||
++Bus.Address.Low;
|
||||
MemoryWrite(value.Low);
|
||||
|
||||
@@ -28,13 +28,21 @@ namespace EightBit
|
||||
|
||||
public byte Peek(ushort absolute) => Reference(absolute);
|
||||
|
||||
public byte Peek(Register16 absolute) => Peek(absolute.Word);
|
||||
public byte Peek(Register16 absolute)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(absolute);
|
||||
return Peek(absolute.Word);
|
||||
}
|
||||
|
||||
public void Poke(byte value) => Reference() = value;
|
||||
|
||||
public void Poke(ushort absolute, byte value) => Reference(absolute) = value;
|
||||
|
||||
public void Poke(Register16 absolute, byte value) => Poke(absolute.Word, value);
|
||||
public void Poke(Register16 absolute, byte value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(absolute);
|
||||
Poke(absolute.Word, value);
|
||||
}
|
||||
|
||||
public byte Read()
|
||||
{
|
||||
@@ -50,7 +58,11 @@ namespace EightBit
|
||||
return Read();
|
||||
}
|
||||
|
||||
public byte Read(Register16 absolute) => Read(absolute.Low, absolute.High);
|
||||
public byte Read(Register16 absolute)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(absolute);
|
||||
return Read(absolute.Low, absolute.High);
|
||||
}
|
||||
|
||||
public byte Read(byte low, byte high)
|
||||
{
|
||||
@@ -77,7 +89,11 @@ namespace EightBit
|
||||
Write(value);
|
||||
}
|
||||
|
||||
public void Write(Register16 absolute, byte value) => Write(absolute.Low, absolute.High, value);
|
||||
public void Write(Register16 absolute, byte value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(absolute);
|
||||
Write(absolute.Low, absolute.High, value);
|
||||
}
|
||||
|
||||
public void Write(byte low, byte high, byte value)
|
||||
{
|
||||
@@ -116,7 +132,11 @@ namespace EightBit
|
||||
return ref mapped.Memory.Reference(offset);
|
||||
}
|
||||
|
||||
protected ref byte Reference(Register16 absolute) => ref Reference(absolute.Word);
|
||||
protected ref byte Reference(Register16 absolute)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(absolute);
|
||||
return ref Reference(absolute.Word);
|
||||
}
|
||||
|
||||
protected ref byte Reference() => ref Reference(Address);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace EightBit
|
||||
|
||||
public override void PokeWord(ushort address, Register16 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
Bus.Poke(address, value.Low);
|
||||
Bus.Poke(++address, value.High);
|
||||
}
|
||||
@@ -51,12 +52,14 @@ namespace EightBit
|
||||
|
||||
protected override void PushWord(Register16 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
Push(value.High);
|
||||
Push(value.Low);
|
||||
}
|
||||
|
||||
protected override void SetWord(Register16 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
MemoryWrite(value.Low);
|
||||
++Bus.Address.Word;
|
||||
MemoryWrite(value.High);
|
||||
@@ -64,6 +67,7 @@ namespace EightBit
|
||||
|
||||
protected override void SetWordPaged(Register16 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
MemoryWrite(value.Low);
|
||||
++Bus.Address.Low;
|
||||
MemoryWrite(value.High);
|
||||
|
||||
@@ -176,9 +176,17 @@ namespace EightBit
|
||||
MemoryWrite(data);
|
||||
}
|
||||
|
||||
protected void MemoryWrite(Register16 address, byte data) => MemoryWrite(address.Low, address.High, data);
|
||||
protected void MemoryWrite(Register16 address, byte data)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(address);
|
||||
MemoryWrite(address.Low, address.High, data);
|
||||
}
|
||||
|
||||
protected void MemoryWrite(Register16 address) => MemoryWrite(address.Low, address.High);
|
||||
protected void MemoryWrite(Register16 address)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(address);
|
||||
MemoryWrite(address.Low, address.High);
|
||||
}
|
||||
|
||||
protected void MemoryWrite(byte data)
|
||||
{
|
||||
@@ -202,7 +210,11 @@ namespace EightBit
|
||||
return MemoryRead();
|
||||
}
|
||||
|
||||
protected byte MemoryRead(Register16 address) => MemoryRead(address.Low, address.High);
|
||||
protected byte MemoryRead(Register16 address)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(address);
|
||||
return MemoryRead(address.Low, address.High);
|
||||
}
|
||||
|
||||
protected virtual byte MemoryRead() => BusRead();
|
||||
|
||||
@@ -223,6 +235,7 @@ namespace EightBit
|
||||
|
||||
protected Register16 GetWordPaged(Register16 address)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(address);
|
||||
return GetWordPaged(address.High, address.Low);
|
||||
}
|
||||
|
||||
@@ -236,6 +249,7 @@ namespace EightBit
|
||||
|
||||
protected void SetWordPaged(Register16 address, Register16 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(address);
|
||||
SetWordPaged(address.High, address.Low, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace EightBit
|
||||
|
||||
public Register16(Register16 rhs)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(rhs);
|
||||
Low = rhs.Low;
|
||||
High = rhs.High;
|
||||
}
|
||||
@@ -65,7 +66,11 @@ namespace EightBit
|
||||
|
||||
public ref byte High => ref _high;
|
||||
|
||||
public static bool operator ==(Register16 left, Register16 right) => left.Equals(right);
|
||||
public static bool operator ==(Register16 left, Register16 right)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(left);
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(Register16 left, Register16 right) => !(left == right);
|
||||
|
||||
@@ -99,6 +104,7 @@ namespace EightBit
|
||||
|
||||
public void Assign(Register16 from)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(from);
|
||||
Assign(from._low, from._high);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ namespace EightBit
|
||||
|
||||
public static int Load(Stream file, ref byte[] output, int writeOffset = 0, int readOffset = 0, int limit = -1, int maximumSize = -1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(file);
|
||||
ArgumentNullException.ThrowIfNull(output);
|
||||
|
||||
var size = (int)file.Length;
|
||||
|
||||
if ((maximumSize > 0) && ((size - readOffset) > maximumSize))
|
||||
@@ -61,6 +64,8 @@ namespace EightBit
|
||||
|
||||
public override int Load(byte[] from, int writeOffset = 0, int readOffset = 0, int limit = -1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(from);
|
||||
|
||||
if (limit < 0)
|
||||
{
|
||||
limit = Math.Min(from.Length, Size - readOffset);
|
||||
|
||||
Reference in New Issue
Block a user