From 76602afcebe6945469e9c79cd82c10e46c6e5f08 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 18 Aug 2018 20:16:50 +0100 Subject: [PATCH] sam: fix keyboard scan logic With this fixed we now get key events. We don't get the right keys because the keyboard map isn't yet correct. --- Kernel/platform-sam/sam.s | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Kernel/platform-sam/sam.s b/Kernel/platform-sam/sam.s index 489968d5..dcc538c0 100644 --- a/Kernel/platform-sam/sam.s +++ b/Kernel/platform-sam/sam.s @@ -21,6 +21,7 @@ .globl _platform_reboot .globl _platform_copier_l .globl _platform_copier_h + .globl _keyscan ; exported debugging tools .globl _platform_monitor @@ -196,21 +197,30 @@ outcw: in a,(248) ; _keyscan: ld hl, #_keyin - ld b, #0xFE -keyscl: ld c, #249 ; need BC out to get address lines - in a, (c) - and #0xE0 ; top 3 bits valid - ld d, a - ld c, #254 - in a, (c) - and #0x1F ; low 5 bits - or d + ld bc, #0xFEFE ; F9 is keyboard port (254) +keyscl: + ; Read low 5 bits from port F9, with the mask in the top address + ; lines (contents of B) + in e, (c) + ; Do the same for port FE for the upper lines, load A before + ; so we keep the mask right + ld a,b + in a, (0xF9) + xor e + and #0xE0 ; keep top 3 bits + xor e + ; Save our decode + cpl ld (hl), a inc hl - scf rlc b jr c, keyscl + ; Have we done all the lines (FE FD FB F7 EF DF BF 7F) + ; Now do FF which is the special case as we have no high bits + ; attached to it. + ld b,#0xFF in a, (c) + cpl and #0x1F ld (hl), a ret -- 2.34.1