forked from MightyPork/crsn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.6 KiB
59 lines
1.6 KiB
4 years ago
|
(
|
||
|
; Helper to check key codes of physical keys
|
||
|
|
||
|
(sc-init 200 200)
|
||
|
(lds @cout "Press keys in the window to see their codes...\n")
|
||
|
(sym pressed r15)
|
||
|
(mkbf pressed 256)
|
||
|
(:loop)
|
||
|
(sc-poll)
|
||
|
(mslp 10)
|
||
|
(sym cnt r14)
|
||
|
(ld cnt 0)
|
||
|
(:next)
|
||
|
(sc-key _ cnt
|
||
|
(inval? (nop))
|
||
|
(nz?
|
||
|
(bfrd r1 @pressed cnt
|
||
|
(z?
|
||
|
(call printnum cnt)
|
||
|
(lds @cout " PRESS\n")
|
||
|
(bfwr @pressed cnt 1)
|
||
|
(rng r0 0 #ffffff)
|
||
|
(sc-erase r0)
|
||
|
(sc-blit)
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
(z?
|
||
|
(bfrd r1 @pressed cnt
|
||
|
(nz?
|
||
|
(call printnum cnt)
|
||
|
(lds @cout " RELEASE\n")
|
||
|
(bfwr @pressed cnt 0)
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
(inc cnt)
|
||
|
(cmp cnt 256 (ne? (j :next)))
|
||
|
(j :loop)
|
||
|
|
||
|
; this is a version if itoa that prints a number
|
||
|
(proc printnum num
|
||
|
(mkbf r15)
|
||
|
(ld r1 num)
|
||
|
(tst r1 (<0? (mul r1 -1)))
|
||
|
(:next)
|
||
|
(mod r0 r1 10)
|
||
|
(add r0 '0')
|
||
|
(bfrpush @r15 r0)
|
||
|
(div r1 10 (z?
|
||
|
(tst num (<0? (bfrpush @r15 '-')))
|
||
|
(lds @cout @r15)
|
||
|
(del @r15)
|
||
|
(ret)))
|
||
|
(j :next)
|
||
|
)
|
||
|
)
|