2004-11-13 10:34:06 +00:00
|
|
|
;
|
2007-02-09 08:24:03 +00:00
|
|
|
; Karri Kaksonen, Harry Dodgson 2006-01-06
|
2004-11-13 10:34:06 +00:00
|
|
|
;
|
|
|
|
; unsigned char kbhit (void);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _kbhit
|
|
|
|
.export KBEDG
|
|
|
|
.export KBSTL
|
|
|
|
.import return1
|
2004-11-13 10:34:06 +00:00
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; 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 '?'.
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.data
|
|
|
|
KBTMP: .byte 0
|
|
|
|
KBPRV: .byte 0
|
|
|
|
KBEDG: .byte 0
|
|
|
|
KBSTL: .byte 0
|
|
|
|
KBDEB: .byte 0
|
|
|
|
KBNPR: .byte 0
|
2004-11-13 10:34:06 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.code
|
2004-11-13 10:34:06 +00:00
|
|
|
_kbhit:
|
2019-10-30 08:14:17 +00:00
|
|
|
lda KBEDG
|
2022-04-17 14:06:22 +00:00
|
|
|
bne L1
|
2013-05-09 11:56:54 +00:00
|
|
|
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
|
2019-10-30 17:32:35 +00:00
|
|
|
L1: tax
|
2009-11-24 18:31:16 +00:00
|
|
|
rts
|
2019-10-28 19:02:18 +00:00
|
|
|
|