full keypad support

This commit is contained in:
Kelvin Sherlock 2021-04-19 16:46:01 -04:00
parent 4823852c6b
commit dbda9761c5

129
vt52.S
View File

@ -21,6 +21,7 @@ START equ *
* *
* *
ESC equ $1b
SET80VID equ $c00d SET80VID equ $c00d
@ -159,7 +160,7 @@ keypress
:remap :remap
lda :arrowtable+1,x lda :arrowtable+1,x
sta key sta key
lda #$1b lda #ESC
jsr dispatch jsr dispatch
bra :ctrl bra :ctrl
@ -187,41 +188,104 @@ keypress
rts rts
keypad keypad
* 0-9, Enter, . PF1-3 are the only valid keypad keys
lda mode
bit #mAltKeyPad
beq :normal
lda key lda key
cmp #'0' cmp #:MIN
bcc :notnum bcc :rts
cmp #'9'+1 cmp #:MAX+1
bcs :notnum bcc :ok
:qq :rts rts
* 0-9 sends ESC ? p-y which is num | 0x40 :ok
lda #$1b tay ; save
jsr dispatch sec
lda #'?' sbc #:MIN
jsr dispatch tax
lda key lda :table,x
ora #$40 beq :rts ; dead
jmp dispatch bmi :normal
:notnum :pf
cmp #$0d bit mode ; don't bother in local mode
beq :qq bmi :rts
cmp #'.' pha ; save
beq :qq lda #ESC
jsr write_modem
pla ; restore
jmp write_modem
:normal :normal
* todo - PF1/2/3 should send ESC P/Q/R ; y still has key value
lda key lda mode
and #mAltKeyPad
bne :alt
tya
jmp dispatch
:alt
phy ; save
bit mode
bmi :local
lda #ESC
jsr write_modem
lda #'?'
jsr write_modem
:local
pla
ora #$40
jmp dispatch jmp dispatch
:table db $1b,'P' :MIN equ 13
db '=','Q' :MAX equ 61
db '/','R'
; 0x80 = ESC ? c + $40 in alt mode
:table
db $80 ; ^M Enter -> \r, ESC ? M
db $0 ; ^N
db $0 ; ^O
db $0 ; ^P
db $0 ; ^Q
db $0 ; ^R
db $0 ; ^S
db $0 ; ^T
db $0 ; ^U
db $0 ; ^V
db $0 ; ^W
db $0 ; ^X
db $0 ; ^Y
db $0 ; ^Z
db 'P' ; ^[ PF1 -> ESC P
db $0 ; ^\
db $0 ; ^]
db $0 ; ^^
db $0 ; ^_
db $0 ;
db $0 ; !
db $0 ; "
db $0 ; #
db $0 ; $
db $0 ; %
db $0 ; &
db $0 ; '
db $0 ; (
db $0 ; )
db $0 ; *
db $0 ; +
db $0 ; ,
db $0 ; -
db $80 ; .
db 'R' ; / PF3 -> ESC R
db $80 ; 0
db $80 ; 1
db $80 ; 2
db $80 ; 3
db $80 ; 4
db $80 ; 5
db $80 ; 6
db $80 ; 7
db $80 ; 8
db $80 ; 9
db $0 ; :
db $0 ; ;
db $0 ; <
db 'Q' ; = PF2 -> ESC Q
@ -480,7 +544,6 @@ clear_eol
sta [text01],y sta [text01],y
sta (text00),y sta (text00),y
iny iny
cpy #40
bra :even bra :even
:rts plp :rts plp
rts rts
@ -958,7 +1021,7 @@ esc_Z ; identify terminal.
; return ESC / K ; return ESC / K
bit mode bit mode
bmi :local bmi :local
lda #$1b lda #ESC
jsr write_modem jsr write_modem
lda #'/' lda #'/'
jsr write_modem jsr write_modem