1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-24 11:31:31 +00:00
cc65/libsrc/lynx/cgetc.s

70 lines
2.0 KiB
ArmAsm
Raw Normal View History

;
; Karri Kaksonen, Harry Dodgson 2006-01-07
;
; char cgetc (void);
;
.export _cgetc
.import _kbhit
.import KBEDG
.import KBSTL
; --------------------------------------------------------------------------
; 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 '?'.
2022-04-17 14:06:22 +00:00
_cgetc:
jsr _kbhit ; Check for char available
2019-10-16 21:22:41 +00:00
beq _cgetc
2019-10-30 17:32:35 +00:00
ora KBSTL
ldx #0
and #1
2019-10-16 21:22:41 +00:00
beq @L5
lda KBEDG ; Pause button is pressed
and #$0c
2019-10-16 21:22:41 +00:00
beq @L2
ora KBSTL
2019-10-16 21:22:41 +00:00
@L1:
bit #$04
2019-10-16 21:22:41 +00:00
beq @L3 ; Pause + Opt 1 = Reset
bit #$08
2019-10-16 21:22:41 +00:00
beq @L4 ; Pause + Opt 2 = Flip
lda #'?' ; All buttons pressed
bra reset_and_exit
2019-10-16 21:22:41 +00:00
@L2:
lda KBSTL ; Pause alone was the last placed button
and #$0c
2019-10-16 21:22:41 +00:00
bne @L1
lda #'P' ; Pause pressed
bra reset_and_exit
2019-10-16 21:22:41 +00:00
@L3:
lda #'R' ; Reset pressed
bra reset_and_exit
2019-10-16 21:22:41 +00:00
@L4:
lda #'F' ; Flip pressed
bra reset_and_exit
2019-10-16 21:22:41 +00:00
@L5:
lda KBEDG ; No Pause pressed
ora KBSTL
bit #$08
beq @L7
2019-10-16 21:22:41 +00:00
bit #$04
beq @L6
lda #'3' ; opt 1 + opt 2 pressed
bra reset_and_exit
2019-10-16 21:22:41 +00:00
@L6:
lda #'1' ; opt 1 pressed
bra reset_and_exit
2019-10-16 21:22:41 +00:00
@L7:
lda #'2' ; opt 2 pressed
reset_and_exit:
stz KBEDG
rts