1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
;
; Karri Kaksonen, Harry Dodgson 2006-01-06
;
; unsigned char kbhit (void);
;
.export _kbhit
.export KBEDG
.export KBSTL
.import return1
; --------------------------------------------------------------------------
; The Atari Lynx has a very small keyboard - only 3 keys
; Opt1, Opt2 and Pause.
; But the designers have decided that pressing Pause and Opt1 at the
; same time means Restart and pressing Pause and Opt2 means Flip screen.
; For "easter egg" use I have also included all three keys pressed '?'
; and Opt1 + Opt2 pressed '3'.
; So the keyboard returns '1', '2', '3', 'P', 'R', 'F' or '?'.
.data
KBTMP: .byte 0
KBPRV: .byte 0
KBEDG: .byte 0
KBSTL: .byte 0
KBDEB: .byte 0
KBNPR: .byte 0
.code
_kbhit:
lda KBEDG
bne L1
lda $FCB0 ; Read the Opt buttons
and #$0c
sta KBTMP
lda $FCB1 ; Read Pause
and #1
ora KBTMP ; 0000210P
tax
and KBPRV
sta KBSTL ; for multibutton
txa
and KBDEB
sta KBEDG ; for just depressed
txa
and KBNPR
sta KBDEB ; for debouncing
txa
eor #$ff
sta KBNPR ; inverted previous ones pressed
stx KBPRV
lda KBEDG
L1: tax
rts
|