summaryrefslogtreecommitdiff
path: root/Emulator/Chip
diff options
context:
space:
mode:
Diffstat (limited to 'Emulator/Chip')
-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