emailler/drivers/vic20input.s

88 lines
2.1 KiB
ArmAsm
Raw Normal View History

.export get_key
2013-12-13 21:24:03 +00:00
.export check_for_abort_key
.export get_key_if_available
.export get_key_ip65
.export abort_key
.exportzp abort_key_default = $18
.exportzp abort_key_disable = $ff
2013-12-13 21:24:03 +00:00
.import ip65_process
.data
abort_key: .byte $18 ; RUN/STOP
.code
2013-12-13 21:24:03 +00:00
; use VIC 20 Kernel ROM function to read a key
; inputs: none
; outputs: A contains ASCII value of key just pressed
2013-12-13 21:24:03 +00:00
get_key:
ldy #0
sty $cc ; cursor on
@loop:
2013-12-13 21:24:03 +00:00
jsr get_key_if_available
bcc @loop
ldy #1
sty $cc ; cursor off
2013-12-13 21:24:03 +00:00
rts
; use VIC 20 Kernel ROM function to read a key
; inputs: none
; outputs: sec if key pressed, clear otherwise
; A contains ASCII value of key just pressed
get_key_if_available:
jsr $f1f9 ; not officially documented - where F1F5 (GETIN) falls through to if device # is 0 (KEYBD)
beq no_key
sec
rts
2013-12-13 21:24:03 +00:00
; process inbound ip packets while waiting for a keypress
2013-12-13 21:24:03 +00:00
get_key_ip65:
jsr ip65_process
jsr get_key_if_available
bcc get_key_ip65
2013-12-13 21:24:03 +00:00
rts
; check whether the abort key is being pressed
; inputs: none
; outputs: sec if abort key pressed, clear otherwise
2013-12-13 21:24:03 +00:00
check_for_abort_key:
lda $cb ; current key pressed
cmp abort_key
bne no_key
2013-12-13 21:24:03 +00:00
@flush_loop:
jsr get_key_if_available
bcs @flush_loop
lda $cb ; current key pressed
cmp abort_key
2013-12-13 21:24:03 +00:00
beq @flush_loop
sec
rts
no_key:
2013-12-13 21:24:03 +00:00
clc
rts
; -- LICENSE FOR vic20input.s --
2013-12-13 21:24:03 +00:00
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
2013-12-13 21:24:03 +00:00
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
2013-12-13 21:24:03 +00:00
; The Original Code is ip65.
;
2013-12-13 21:24:03 +00:00
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
2013-12-13 21:24:03 +00:00
; -- LICENSE END --