From 7a8d2bcd75d88a5429937bf551878c55e1dcf0fd Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Wed, 6 Aug 2025 22:36:34 +1000 Subject: moved everything to seperate projects, and started compiler work + push and pop instructions added --- Emulator/Chip/RamDevice.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Emulator/Chip/RamDevice.cs (limited to 'Emulator/Chip/RamDevice.cs') diff --git a/Emulator/Chip/RamDevice.cs b/Emulator/Chip/RamDevice.cs new file mode 100644 index 0000000..8d5b051 --- /dev/null +++ b/Emulator/Chip/RamDevice.cs @@ -0,0 +1,33 @@ +namespace Q1.Emulator.Chip; + +public class RamDevice : BusDevice +{ + public u8[] Memory; + + public RamDevice(u16 start, u16 size) : base(start, (u16) (start + size)) + { + this.Memory = new u8[size]; + } + + public override void Reset() + { + this.Memory = new u8[this.AddressableEnd - this.AddressableStart]; + } + + public override void Clock() + { + // No clocking needed for RAM + } + + public override u8 Read(u16 address) + { + u16 relativeAddress = this.GetRelativeAddress(address); + return this.Memory[relativeAddress]; + } + + public override void Write(u16 address, u8 value) + { + u16 relativeAddress = this.GetRelativeAddress(address); + this.Memory[relativeAddress] = value; + } +} \ No newline at end of file -- cgit v1.3.1