2013-12-27 13:57:56 +00:00
|
|
|
.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
|
2017-06-05 15:20:27 +00:00
|
|
|
.export abort_key
|
|
|
|
.exportzp abort_key_default = $3f
|
|
|
|
.exportzp abort_key_disable = $ff
|
2013-12-13 21:24:03 +00:00
|
|
|
|
|
|
|
.import ip65_process
|
|
|
|
|
|
|
|
|
2017-06-05 15:20:27 +00:00
|
|
|
.data
|
|
|
|
|
|
|
|
abort_key: .byte $3f ; RUN/STOP
|
|
|
|
|
|
|
|
|
2014-07-07 18:56:21 +00:00
|
|
|
.code
|
2013-12-13 21:24:03 +00:00
|
|
|
|
2013-12-27 13:57:56 +00:00
|
|
|
; use C64 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:
|
2017-05-16 21:44:04 +00:00
|
|
|
ldy #0
|
|
|
|
sty $cc ; cursor on
|
2017-06-05 15:20:27 +00:00
|
|
|
@loop:
|
2013-12-13 21:24:03 +00:00
|
|
|
jsr get_key_if_available
|
2017-08-09 19:27:21 +00:00
|
|
|
bcc @loop
|
2017-09-29 13:47:44 +00:00
|
|
|
@wait_no_cursor:
|
|
|
|
sei
|
|
|
|
ldy $cf ; cursor currently displayed?
|
|
|
|
beq @done ; no
|
|
|
|
cli ; yes, wait longer
|
|
|
|
bne @wait_no_cursor
|
|
|
|
@done:
|
2017-05-16 21:44:04 +00:00
|
|
|
ldy #1
|
|
|
|
sty $cc ; cursor off
|
2017-09-29 13:47:44 +00:00
|
|
|
cli
|
2013-12-13 21:24:03 +00:00
|
|
|
rts
|
|
|
|
|
2013-12-27 13:57:56 +00:00
|
|
|
; use C64 Kernel ROM function to read a key
|
|
|
|
; inputs: none
|
2017-08-09 19:27:21 +00:00
|
|
|
; outputs: sec if key pressed, clear otherwise
|
|
|
|
; A contains ASCII value of key just pressed
|
|
|
|
get_key_if_available:
|
2017-08-20 18:58:49 +00:00
|
|
|
ldy #$ff
|
2017-08-09 19:27:21 +00:00
|
|
|
jsr $f142 ; not officially documented - where F13E (GETIN) falls through to if device # is 0 (KEYBD)
|
2017-08-20 18:58:49 +00:00
|
|
|
cpy #$ff ; Y gets modified iff there's a character available - this approach allows to read ^@ as 0
|
2017-08-09 19:27:21 +00:00
|
|
|
beq no_key
|
|
|
|
sec
|
|
|
|
rts
|
2013-12-13 21:24:03 +00:00
|
|
|
|
2013-12-27 13:57:56 +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
|
2017-08-09 19:27:21 +00:00
|
|
|
bcc get_key_ip65
|
2013-12-13 21:24:03 +00:00
|
|
|
rts
|
|
|
|
|
2017-06-05 15:20:27 +00:00
|
|
|
; check whether the abort key is being pressed
|
2013-12-27 13:57:56 +00:00
|
|
|
; inputs: none
|
2017-06-05 15:20:27 +00:00
|
|
|
; outputs: sec if abort key pressed, clear otherwise
|
2013-12-13 21:24:03 +00:00
|
|
|
check_for_abort_key:
|
2013-12-27 13:57:56 +00:00
|
|
|
lda $cb ; current key pressed
|
2017-06-05 15:20:27 +00:00
|
|
|
cmp abort_key
|
2017-08-09 19:27:21 +00:00
|
|
|
bne no_key
|
2013-12-13 21:24:03 +00:00
|
|
|
@flush_loop:
|
|
|
|
jsr get_key_if_available
|
2017-08-09 19:27:21 +00:00
|
|
|
bcs @flush_loop
|
2013-12-27 13:57:56 +00:00
|
|
|
lda $cb ; current key pressed
|
2017-06-05 15:20:27 +00:00
|
|
|
cmp abort_key
|
2013-12-13 21:24:03 +00:00
|
|
|
beq @flush_loop
|
|
|
|
sec
|
|
|
|
rts
|
2017-08-09 19:27:21 +00:00
|
|
|
no_key:
|
2013-12-13 21:24:03 +00:00
|
|
|
clc
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-29 22:39:35 +00:00
|
|
|
; -- LICENSE FOR c64input.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-27 13:57:56 +00:00
|
|
|
;
|
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-27 13:57:56 +00:00
|
|
|
;
|
2013-12-13 21:24:03 +00:00
|
|
|
; The Original Code is ip65.
|
2013-12-27 13:57:56 +00:00
|
|
|
;
|
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
|
2013-12-27 13:57:56 +00:00
|
|
|
; Jonno Downes. All Rights Reserved.
|
2013-12-13 21:24:03 +00:00
|
|
|
; -- LICENSE END --
|