From 489b7b21e6e009157d59a836d99f34fff3bae25f Mon Sep 17 00:00:00 2001 From: Adrian Conlon <98398945+AdrianConlon@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:23:18 +0100 Subject: [PATCH] Clarifications of EightBit library --- EightBit/Bus.cs | 3 +-- EightBit/Chip.cs | 4 ---- EightBit/Device.cs | 4 ---- EightBit/InputOutput.cs | 4 ---- EightBit/IntelOpCodeDecoded.cs | 6 +----- EightBit/MemoryMapping.cs | 2 +- EightBit/Register16.cs | 2 +- EightBit/Rom.cs | 7 +------ 8 files changed, 5 insertions(+), 27 deletions(-) diff --git a/EightBit/Bus.cs b/EightBit/Bus.cs index 95e3d07..1f7aa06 100644 --- a/EightBit/Bus.cs +++ b/EightBit/Bus.cs @@ -61,8 +61,7 @@ namespace EightBit public void Write() { this.OnWritingByte(); - var value = this.Data; // N.B. Don't join these two lines together: the - this.Reference() = value; // data bus integrity is lost, due to evaluation order! + this.Reference() = this.Data; this.OnWrittenByte(); } diff --git a/EightBit/Chip.cs b/EightBit/Chip.cs index 35b4310..73abd90 100644 --- a/EightBit/Chip.cs +++ b/EightBit/Chip.cs @@ -6,10 +6,6 @@ namespace EightBit { public class Chip : Device { - protected Chip() - { - } - public static byte Bit(int which) => (byte)(1 << which); public static byte Bit(byte which) => Bit((int)which); diff --git a/EightBit/Device.cs b/EightBit/Device.cs index 44eb97a..6e83291 100644 --- a/EightBit/Device.cs +++ b/EightBit/Device.cs @@ -10,10 +10,6 @@ namespace EightBit { private PinLevel powerLine; - protected Device() - { - } - public event EventHandler? RaisingPOWER; public event EventHandler? RaisedPOWER; diff --git a/EightBit/InputOutput.cs b/EightBit/InputOutput.cs index efe5e4c..89bd935 100644 --- a/EightBit/InputOutput.cs +++ b/EightBit/InputOutput.cs @@ -11,10 +11,6 @@ namespace EightBit private readonly byte[] input = new byte[0x100]; private readonly byte[] output = new byte[0x100]; - public InputOutput() - { - } - public event EventHandler? ReadingPort; public event EventHandler? ReadPort; diff --git a/EightBit/IntelOpCodeDecoded.cs b/EightBit/IntelOpCodeDecoded.cs index 41d6476..955ec81 100644 --- a/EightBit/IntelOpCodeDecoded.cs +++ b/EightBit/IntelOpCodeDecoded.cs @@ -4,12 +4,8 @@ namespace EightBit { - public class IntelOpCodeDecoded + public sealed class IntelOpCodeDecoded { - public IntelOpCodeDecoded() - { - } - public IntelOpCodeDecoded(byte opCode) { this.X = (opCode & 0b11000000) >> 6; // 0 - 3 diff --git a/EightBit/MemoryMapping.cs b/EightBit/MemoryMapping.cs index e3291f1..0dba224 100644 --- a/EightBit/MemoryMapping.cs +++ b/EightBit/MemoryMapping.cs @@ -4,7 +4,7 @@ namespace EightBit { - public class MemoryMapping(Memory memory, ushort begin, ushort mask, AccessLevel access) + public sealed class MemoryMapping(Memory memory, ushort begin, ushort mask, AccessLevel access) { public MemoryMapping(Memory memory, ushort begin, Mask mask, AccessLevel access) : this(memory, begin, (ushort)mask, access) diff --git a/EightBit/Register16.cs b/EightBit/Register16.cs index 4f43143..48e2467 100644 --- a/EightBit/Register16.cs +++ b/EightBit/Register16.cs @@ -7,7 +7,7 @@ namespace EightBit using System.Diagnostics; [DebuggerDisplay("Word = {Word}")] - public class Register16 + public sealed class Register16 { private byte low; private byte high; diff --git a/EightBit/Rom.cs b/EightBit/Rom.cs index 5a8f202..5a8e36e 100644 --- a/EightBit/Rom.cs +++ b/EightBit/Rom.cs @@ -7,15 +7,10 @@ namespace EightBit using System; using System.IO; - public class Rom(int size) : Memory + public class Rom(int size = 0) : Memory { private byte[] bytes = new byte[size]; - public Rom() - : this(0) - { - } - public override int Size => this.bytes.Length; public static int Load(Stream file, ref byte[] output, int writeOffset = 0, int readOffset = 0, int limit = -1, int maximumSize = -1)