I thought it would be nice to share, since someone might have use for it..
Code: Select all
ld bc,$0701
ld de,$FEFF
ld hl,$0800
-: out (c),e
push hl ;delay
out (c),d
sll d
pop hl ;delay
in a,(1)
xor e ;edited to save a byte and 3 tstates (thanx spencer, I didn't see it)
jr nz,{+}
ld a,l
add a,h
ld l,a
djnz {-}
xor a
ret ;edited to return the code in A
+:
-: inc l
rra
jr nc,{-}
ld a,l ;edited to return the code in A
ret
This routine obviously is not optimal, but it works (that is, it returns the right scancode)
edit: I originally returned the code in L because I would load something else in H and then save them off at the same time, but if everyone wants it to be in A that's fine
these are the scancodes:
(I did NOT make a mistake with the inconsistent $ !)
some names may be mis-spelled so watch out.
Code: Select all
skdown = 1
skleft = 2
skright = 3
skup = 4
skgraph = $31
sktrace = $32
skzoom = $33
skwindow = $34
skyequ = $35
sk2nd = $36
skalpha = $30
skmode = $37
skdel = $38
skgraphvar = $28
skstat = $20
skmath = $2F
skapps = 39
skprgm = 31
skvars = 23
skclear = 15
skrecip = 46
sksin = 38
skcos = 30
sktan = 22
skpow = 14
sksquare = 45
skcomma = 37
sklparen = 29
skrparen = 21
skdiv = 13
sklog = 44
sk7 = 36
sk8 = 28
sk9 = 20
skmul = 12
skln = 43
sk4 = 35
sk5 = 27
sk6 = 19
skminus = 11
sksto = 42
sk1 = 34
sk2 = 26
sk3 = 18
skadd = 10
sk0 = 33
skdcpt = 25
skneg = 17
skenter = 9