No, there's no easy way out that you've missed. :)
The values returned by GetCSC correspond directly to the keypad hardware, and as you can see, they don't have much of anything to do with the labels on the keys. The GetKey routine has an internal lookup table that it uses to translate these "raw" GetCSC values into more logical key codes, but there's no OS-independent way for assembly programs to use that table. You either need to include your own lookup table, or else come up with a clever trick to avoid it.
Sadly, the cleverest trick I can think of at the moment is 24 bytes:
Code:
; input: A = scan code returned by GetCSC
sub sk0
jr z,number_ok
dec a
ld b,a
and 7
cp 3
jr nc,not_a_number
ld c,a
sub b
rrca
rrca
rrca
cp 3
jr nc,not_a_number
adc a,c
add a,c
add a,c
number_ok:
; A = numeric value 0-9
Whereas the following table-based version is only 21 bytes:
Code:
ld hl,num_key_table
ld bc,10
cpir
jr nz,not_a_number
ld a,c
number_ok:
...
num_key_table: .db sk9, sk8, sk7, sk6, sk5, sk4, sk3, sk2, sk1, sk0
|