summaryrefslogtreecommitdiff
path: root/Emulator/Chip/HIDDevice.cs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-28 12:35:24 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-28 12:35:24 +1000
commit7f96fc5e7f412a66d460dcaa82bbdbcaea08f360 (patch)
tree67ebd30bce45f8e5ffed73212f287b4152a5b71d /Emulator/Chip/HIDDevice.cs
parent634681ce2bb36cd686943102a0f071cd6a09049f (diff)
everything is finally at peace
Diffstat (limited to 'Emulator/Chip/HIDDevice.cs')
-rw-r--r--Emulator/Chip/HIDDevice.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Emulator/Chip/HIDDevice.cs b/Emulator/Chip/HIDDevice.cs
index 87bb2c3..c8a7d04 100644
--- a/Emulator/Chip/HIDDevice.cs
+++ b/Emulator/Chip/HIDDevice.cs
@@ -1,5 +1,7 @@
namespace Q1.Emulator.Chip;
+using System;
+
public class HIDDevice : RamDevice
{
public HIDDevice(u16 start) : base(start, HIDDevice.CalculateSize()) { }
@@ -24,7 +26,7 @@ public class HIDDevice : RamDevice
int bit = scanCode & 7; // keyCode % 8
ushort addr = (ushort) (4 + index);
- u8 value = this.Read(addr);
+ u8 value = this.Read((u16) (this.AddressableStart + addr));
if (pressed)
value |= (u8) (1 << bit);
@@ -33,4 +35,15 @@ public class HIDDevice : RamDevice
this.Write((u16) (this.AddressableStart + addr), value);
}
+
+ public bool GetKeyboard(int scanCode)
+ {
+ int index = scanCode >> 3;
+ int bit = scanCode & 7;
+
+ ushort addr = (ushort) (4 + index);
+ byte value = this.Read((u16) (this.AddressableStart + addr));
+
+ return (value & (1 << bit)) != 0;
+ }
} \ No newline at end of file