summaryrefslogtreecommitdiff
path: root/Emulator/Chip/Bus.cs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-06 22:36:34 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-06 22:36:34 +1000
commit7a8d2bcd75d88a5429937bf551878c55e1dcf0fd (patch)
tree81bc1f259fb8678513aa8b214df4ef72720bb585 /Emulator/Chip/Bus.cs
parent16f3cb74564cf7c19da6e13666c98aca36094716 (diff)
moved everything to seperate projects, and started compiler work + push and pop instructions added
Diffstat (limited to 'Emulator/Chip/Bus.cs')
-rw-r--r--Emulator/Chip/Bus.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/Emulator/Chip/Bus.cs b/Emulator/Chip/Bus.cs
new file mode 100644
index 0000000..0907f61
--- /dev/null
+++ b/Emulator/Chip/Bus.cs
@@ -0,0 +1,37 @@
+namespace Q1.Emulator.Chip;
+
+using System.Collections.Generic;
+using System.Linq;
+
+public class Bus : BusDevice
+{
+ public List<BusDevice> Devices;
+
+ public Bus(u16 addressableStart, u16 addressableEnd) : base(addressableStart, addressableEnd)
+ {
+ this.Devices = [];
+ }
+ private BusDevice? GetDevice(u16 address)
+ {
+ BusDevice? device = this.Devices.FirstOrDefault(x => address >= x.AddressableStart && address < x.AddressableEnd);
+ return device;
+ }
+
+ public override u8 Read(u16 address)
+ {
+ BusDevice? device = this.GetDevice(address);
+ if (device == null)
+ return 0;
+
+ return device.Read(address);
+ }
+
+ public override void Write(u16 address, u8 value)
+ {
+ BusDevice? device = this.GetDevice(address);
+ if (device == null)
+ return;
+
+ device.Write(address, value);
+ }
+} \ No newline at end of file