Allow Telnet65 to send ASCII code 0 - on the Apple II.

Chris made me aware that ASCII code 0 actually is a valid character (usually entered as Ctrl-Space or Ctrl-@) and that it is actually used (i.e. by EMACS).

The Apple II allows to natively enter the ASCII code 0 via Ctrl-@. However so far get_key_if_available returned 0 in accumulator to signal that no key was pressed. In order to allow the Apple II get_key_if_available to return the ASCII code 0 in the accumulator I changed it to use the carry flag to signal that no key was pressed.

Because get_key_if_available needs of course to behave the same on all targets I changed the other implementations to use the carry flag too.

Unfortunately I don't know enough about input capabilities of the C64 to decide on how to best get Telnet65 to send ASCII code 0 there.
This commit is contained in:
Oliver Schmidt 2017-08-09 21:27:21 +02:00
parent 0ecc367b85
commit 39f83b7709
6 changed files with 45 additions and 32 deletions

View File

@ -228,7 +228,7 @@ telnet_main_entry:
ldax #iac_response_buffer ldax #iac_response_buffer
jsr tcp_send jsr tcp_send
: jsr get_key_if_available : jsr get_key_if_available
beq @check_timeout bcc @check_timeout
ldx #0 ldx #0
stx tcp_send_data_len stx tcp_send_data_len
stx tcp_send_data_len+1 stx tcp_send_data_len+1

View File

@ -18,15 +18,17 @@ abort_key: .byte $9b ; ESC
; use Apple 2 monitor ROM function to read from keyboard ; use Apple 2 monitor ROM function to read from keyboard
; inputs: none ; inputs: none
; outputs: A contains ASCII code of key pressed ; outputs: A contains ASCII value of key just pressed
get_key = $fd0c get_key = $fd0c
; inputs: none ; inputs: none
; outputs: A contains ASCII value of key just pressed (0 if no key pressed) ; outputs: sec if key pressed, clear otherwise
; A contains ASCII value of key just pressed
get_key_if_available: get_key_if_available:
sec
lda $c000 ; current key pressed lda $c000 ; current key pressed
bmi got_key bmi got_key
lda #0 clc
rts rts
; process inbound ip packets while waiting for a keypress ; process inbound ip packets while waiting for a keypress

View File

@ -879,6 +879,7 @@ aDDigE rts
ProcOut ProcOut
lda kta,y ; keyboard to ASCII lda kta,y ; keyboard to ASCII
cmp #$ff
beq POrts ; ignore key beq POrts ; ignore key
cmp #$fe cmp #$fe
beq CmdKey ; command key beq CmdKey ; command key
@ -1710,7 +1711,7 @@ ltsc;_0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _a _b _c _d _e _f
; input for sending over the serial ; input for sending over the serial
; line. ; line.
; ;
; ascii = $00 means ignore key ; ascii = $ff means ignore key
; ascii = $fe means do something ; ascii = $fe means do something
; complicated (command key) ; complicated (command key)
; ------------------------------------- ; -------------------------------------
@ -1719,7 +1720,7 @@ kta ;_0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _a _b _c _d _e _f
; --- Control chars ------------------------------------------------ ; --- Control chars ------------------------------------------------
; {←} {↓} {↑} ; {←} {↓} {↑}
; ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O ; ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O
.byt $00,$01,$02,$03,$04,$05,$06,$07,$fe,$09,$fe,$fe,$0c,$0d,$0e,$0f ; 0_ .byt $00,$01,$02,$03,$04,$05,$06,$07,$fe,$09,$fe,$fe,$0c,$0d,$0e,$0f ; 0_
; {→} ; {→}
; ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_ ; ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_

View File

@ -24,15 +24,16 @@ kname: .byte "K:",155
; outputs: A contains ASCII value of key just pressed ; outputs: A contains ASCII value of key just pressed
get_key: get_key:
jsr get_key_if_available jsr get_key_if_available
beq get_key bcc get_key
rts rts
; inputs: none ; inputs: none
; outputs: A contains ASCII value of key just pressed (0 if no key pressed) ; outputs: sec if key pressed, clear otherwise
; A contains ASCII value of key just pressed
get_key_if_available: get_key_if_available:
lda CH ; GLOBAL VARIABLE FOR KEYBOARD lda CH ; GLOBAL VARIABLE FOR KEYBOARD
cmp #255 cmp #255
beq @nokey beq no_key
ldx iocb ; K: already open? ldx iocb ; K: already open?
bne @read bne @read
ldx #$40 ; IOCB to use for keyboard input ldx #$40 ; IOCB to use for keyboard input
@ -55,16 +56,14 @@ get_key_if_available:
jsr CIOV ; vector to CIO jsr CIOV ; vector to CIO
ldx #255 ldx #255
stx CH ; GLOBAL VARIABLE FOR KEYBOARD stx CH ; GLOBAL VARIABLE FOR KEYBOARD
rts sec
@nokey:
lda #0
rts rts
; process inbound ip packets while waiting for a keypress ; process inbound ip packets while waiting for a keypress
get_key_ip65: get_key_ip65:
jsr ip65_process jsr ip65_process
jsr get_key_if_available jsr get_key_if_available
beq get_key_ip65 bcc get_key_ip65
rts rts
;check whether the abort key is being pressed ;check whether the abort key is being pressed
@ -72,6 +71,7 @@ get_key_ip65:
;outputs: sec if abort key pressed, clear otherwise ;outputs: sec if abort key pressed, clear otherwise
check_for_abort_key: check_for_abort_key:
; TODO: implement actual check ; TODO: implement actual check
no_key:
clc clc
rts rts
@ -82,16 +82,16 @@ check_for_abort_key:
; Version 1.1 (the "License"); you may not use this file except in ; 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 ; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/ ; http://www.mozilla.org/MPL/
; ;
; Software distributed under the License is distributed on an "AS IS" ; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the ; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations ; License for the specific language governing rights and limitations
; under the License. ; under the License.
; ;
; The Original Code is ip65. ; The Original Code is ip65.
; ;
; The Initial Developer of the Original Code is Jonno Downes, ; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com. ; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009 ; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved. ; Jonno Downes. All Rights Reserved.
; -- LICENSE END -- ; -- LICENSE END --

View File

@ -24,21 +24,26 @@ get_key:
sty $cc ; cursor on sty $cc ; cursor on
@loop: @loop:
jsr get_key_if_available jsr get_key_if_available
beq @loop bcc @loop
ldy #1 ldy #1
sty $cc ; cursor off sty $cc ; cursor off
rts rts
; use C64 Kernel ROM function to read a key ; use C64 Kernel ROM function to read a key
; inputs: none ; inputs: none
; outputs: A contains ASCII value of key just pressed (0 if no key pressed) ; outputs: sec if key pressed, clear otherwise
get_key_if_available = $f142 ; not officially documented - where F13E (GETIN) falls through to if device # is 0 (KEYBD) ; A contains ASCII value of key just pressed
get_key_if_available:
jsr $f142 ; not officially documented - where F13E (GETIN) falls through to if device # is 0 (KEYBD)
beq no_key
sec
rts
; process inbound ip packets while waiting for a keypress ; process inbound ip packets while waiting for a keypress
get_key_ip65: get_key_ip65:
jsr ip65_process jsr ip65_process
jsr get_key_if_available jsr get_key_if_available
beq get_key_ip65 bcc get_key_ip65
rts rts
; check whether the abort key is being pressed ; check whether the abort key is being pressed
@ -47,16 +52,16 @@ get_key_ip65:
check_for_abort_key: check_for_abort_key:
lda $cb ; current key pressed lda $cb ; current key pressed
cmp abort_key cmp abort_key
bne @not_abort bne no_key
@flush_loop: @flush_loop:
jsr get_key_if_available jsr get_key_if_available
bne @flush_loop bcs @flush_loop
lda $cb ; current key pressed lda $cb ; current key pressed
cmp abort_key cmp abort_key
beq @flush_loop beq @flush_loop
sec sec
rts rts
@not_abort: no_key:
clc clc
rts rts

View File

@ -16,7 +16,7 @@ abort_key: .byte $18 ; RUN/STOP
.code .code
; use Vic 20 Kernel ROM function to read a key ; use VIC 20 Kernel ROM function to read a key
; inputs: none ; inputs: none
; outputs: A contains ASCII value of key just pressed ; outputs: A contains ASCII value of key just pressed
get_key: get_key:
@ -24,21 +24,26 @@ get_key:
sty $cc ; cursor on sty $cc ; cursor on
@loop: @loop:
jsr get_key_if_available jsr get_key_if_available
beq @loop bcc @loop
ldy #1 ldy #1
sty $cc ; cursor off sty $cc ; cursor off
rts rts
; use VIC 20 Kernel ROM function to read a key ; use VIC 20 Kernel ROM function to read a key
; inputs: none ; inputs: none
; outputs: A contains ASCII value of key just pressed (0 if no key pressed) ; outputs: sec if key pressed, clear otherwise
get_key_if_available = $f1f9 ; not officially documented - where F1f5 (GETIN) falls through to if device # is 0 (KEYBD) ; 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
; process inbound ip packets while waiting for a keypress ; process inbound ip packets while waiting for a keypress
get_key_ip65: get_key_ip65:
jsr ip65_process jsr ip65_process
jsr get_key_if_available jsr get_key_if_available
beq get_key_ip65 bcc get_key_ip65
rts rts
; check whether the abort key is being pressed ; check whether the abort key is being pressed
@ -47,16 +52,16 @@ get_key_ip65:
check_for_abort_key: check_for_abort_key:
lda $cb ; current key pressed lda $cb ; current key pressed
cmp abort_key cmp abort_key
bne @not_abort bne no_key
@flush_loop: @flush_loop:
jsr get_key_if_available jsr get_key_if_available
bne @flush_loop bcs @flush_loop
lda $cb ; current key pressed lda $cb ; current key pressed
cmp abort_key cmp abort_key
beq @flush_loop beq @flush_loop
sec sec
rts rts
@not_abort: no_key:
clc clc
rts rts