more csi stuff

This commit is contained in:
Kelvin Sherlock 2021-09-04 20:27:42 -04:00
parent 492a3bfbec
commit 1eaaf3aaaf

View File

@ -1,5 +1,7 @@
lst off
cas se
rel rel
xc xc
@ -7,33 +9,9 @@
use vt.equ use vt.equ
ext update_cursor,reset_tab,reset_all_tabs
vt100_csi ent vt100_csi ent
inc state
inc state
stz pcount
stz parms
stz parms+1 ; some assume 2 parms.
stz pmod
tay ; save for modifier
cmp #:MIN
blt :bad
cmp #:MAX+1
bge :bad
sec
sbc #:MIN
asl
tax
jmp (:table,x)
:bad
ldx #st_vt100
stx state
:rts rts
:table
* 0123456789;ycnlhgrqJKmABCDHf * 0123456789;ycnlhgrqJKmABCDHf
* based on testing - * based on testing -
@ -45,6 +23,34 @@ vt100_csi ent
* < = > ? are allowed as an initial modifier but only '?' is private * < = > ? are allowed as an initial modifier but only '?' is private
* a mis-placed < = > ? will prevent 0x20-0x2f from terminating the sequence. * a mis-placed < = > ? will prevent 0x20-0x2f from terminating the sequence.
inc state
inc state
stz pcount
stz parms
stz parms+1 ; some assume 2 parms.
stz pmod
* tay ; save for modifier
cmp #:MIN
blt :end
cmp #:MAX+1
bge :end
sec
sbc #:MIN
asl
tax
jmp (:table,x)
*
:end
ldx #st_vt100
stx state
:rts rts
:MIN equ 48 :MIN equ 48
:MAX equ 121 :MAX equ 121
:table :table
@ -60,68 +66,68 @@ vt100_csi ent
dw :digit ; 9 dw :digit ; 9
dw digit ; : dw digit ; :
dw semi dw semi
dw :rts ; < dw :rts ; <
dw :rts ; = dw :rts ; =
dw :rts ; > dw :rts ; >
dw :modifier ; ? dw :modifier ; ?
dw $0 ; @ dw :end ; @
dw $0 ; A dw csi_A ; A
dw $0 ; B dw csi_B ; B
dw $0 ; C dw csi_C ; C
dw $0 ; D dw csi_D ; D
dw $0 ; E dw :end ; E
dw $0 ; F dw :end ; F
dw $0 ; G dw :end ; G
dw $0 ; H dw csi_H ; H
dw $0 ; I dw :end ; I
dw $0 ; J dw csi_J ; J
dw $0 ; K dw csi_K ; K
dw $0 ; L dw :end ; L
dw $0 ; M dw :end ; M
dw $0 ; N dw :end ; N
dw $0 ; O dw :end ; O
dw $0 ; P dw :end ; P
dw $0 ; Q dw :end ; Q
dw $0 ; R dw :end ; R
dw $0 ; S dw :end ; S
dw $0 ; T dw :end ; T
dw $0 ; U dw :end ; U
dw $0 ; V dw :end ; V
dw $0 ; W dw :end ; W
dw $0 ; X dw :end ; X
dw $0 ; Y dw :end ; Y
dw $0 ; Z dw :end ; Z
dw $0 ; [ dw :end ; [
dw $0 ; \ dw :end ; \
dw $0 ; ] dw :end ; ]
dw $0 ; ^ dw :end ; ^
dw $0 ; _ dw :end ; _
dw $0 ; ` dw :end ; `
dw $0 ; a dw :end ; a
dw $0 ; b dw :end ; b
dw $0 ; c dw csi_c ; c
dw $0 ; d dw :end ; d
dw $0 ; e dw :end ; e
dw $0 ; f dw csi_f ; f
dw $0 ; g dw csi_g ; g
dw $0 ; h dw csi_h ; h
dw $0 ; i dw :end ; i
dw $0 ; j dw :end ; j
dw $0 ; k dw :end ; k
dw $0 ; l dw csi_l ; l
dw $0 ; m dw csi_m ; m
dw $0 ; n dw csi_n ; n
dw $0 ; o dw :end ; o
dw $0 ; p dw :end ; p
dw $0 ; q dw csi_q ; q
dw $0 ; r dw csi_r ; r
dw $0 ; s dw :end ; s
dw $0 ; t dw :end ; t
dw $0 ; u dw :end ; u
dw $0 ; v dw :end ; v
dw $0 ; w dw :end ; w
dw $0 ; x dw :end ; x
dw $0 ; y dw csi_y ; y
:digit :digit
@ -129,25 +135,26 @@ vt100_csi ent
sta parms sta parms
rts rts
:modifier :modifier
ldx #$40 ; bit -> v lda #$80
stx pmod sta pmod
rts rts
vt100_csi_bad ent
cmp #'@'
blt :rts
ldx #st_vt100
stx state
:rts rts
vt100_csi_2 ent vt100_csi_2 ent
; if < '0' and invalid modifier, don't terminate. cmp #:MIN
bit pmod blt :end
bmi :badmod
cmp #'@'
blt :0
ldx #st_vt100
stx state
:0 cmp #:MIN
blt :bad
cmp #:MAX+1 cmp #:MAX+1
bge :bad bge :end
sec sec
sbc #:MIN sbc #:MIN
jmp (:table,x) jmp (:table,x)
@ -156,7 +163,7 @@ vt100_csi_2 ent
cmp #'@' cmp #'@'
blt :rts blt :rts
:bad :end
ldx #st_vt100 ldx #st_vt100
stx state stx state
:rts rts :rts rts
@ -180,20 +187,78 @@ vt100_csi_2 ent
dw :modifier ; = dw :modifier ; =
dw :modifier ; > dw :modifier ; >
dw :modifier ; ? dw :modifier ; ?
dw :end ; @
dw csi_A ; A
dw csi_B ; B
dw csi_C ; C
dw csi_D ; D
dw :end ; E
dw :end ; F
dw :end ; G
dw csi_H ; H
dw :end ; I
dw csi_J ; J
dw csi_K ; K
dw :end ; L
dw :end ; M
dw :end ; N
dw :end ; O
dw :end ; P
dw :end ; Q
dw :end ; R
dw :end ; S
dw :end ; T
dw :end ; U
dw :end ; V
dw :end ; W
dw :end ; X
dw :end ; Y
dw :end ; Z
dw :end ; [
dw :end ; \
dw :end ; ]
dw :end ; ^
dw :end ; _
dw :end ; `
dw :end ; a
dw :end ; b
dw csi_c ; c
dw :end ; d
dw :end ; e
dw csi_f ; f
dw csi_g ; g
dw csi_h ; h
dw :end ; i
dw :end ; j
dw :end ; k
dw csi_l ; l
dw csi_m ; m
dw csi_n ; n
dw :end ; o
dw :end ; p
dw csi_q ; q
dw csi_r ; r
dw :end ; s
dw :end ; t
dw :end ; u
dw :end ; v
dw :end ; w
dw :end ; x
dw csi_y ; y
:modifier :modifier
lda #$80 ldx #st_vt100_csi_bad
sta pmod stx state
rts rts
semi semi
ldx pcount ldx pcount
cpx #MAX_PCOUNT cpx #MAX_PCOUNT
bge :rts bge :big
inx inx
stx pcount stx pcount
stz parms,x :big stz parms,x
:rts rts :rts rts
* parameter digit. clamped to 255 (250+ rounds up to 255) * parameter digit. clamped to 255 (250+ rounds up to 255)
@ -209,9 +274,9 @@ digit
bge :v bge :v
tay tay
lda :table,y lda :mult,y
* clc ; cleared via cmp * clc ; cleared via cmp
adc r1 adc r0
sta parms,x sta parms,x
@ -222,21 +287,19 @@ digit
sta parms,x sta parms,x
rts rts
:table da 0,10,20,30,40,50,60,70,80,90 :mult da 0,10,20,30,40,50,60,70,80,90
da 100,110,120,130,140,150,160,170,180,190 da 100,110,120,130,140,150,160,170,180,190
da 200,210,220,230,240,250 da 200,210,220,230,240,250
csi_h
set_mode
; esc [ ... h (vt100) ; esc [ ... h (vt100)
; esc [ ? ... h (private) ; esc [ ? ... h (private)
ldy #$80 ldy #$80
bra mode_common bra mode_common
reset_mode csi_l
; esc [ ... l (vt100) ; esc [ ... l (vt100)
; esc [ ? ... l (private) ; esc [ ? ... l (private)
ldy #0 ldy #0
@ -248,7 +311,7 @@ mode_common
cmp #:MIN cmp #:MIN
blt :next blt :next
cmp #:MAX+1 cmp #:MAX+1
bgt :next bge :next
phx phx
asl asl
tax tax
@ -290,14 +353,14 @@ mode_common
mode_DECCKM mode_DECCKM
bit pmod bit pmod
bvc :rts bpl :rts
sty DECCKM sty DECCKM
:rts rts :rts rts
mode_DECANM mode_DECANM
bit pmod bit pmod
bvc :rts bpl :rts
sty DECANM sty DECANM
cpy #0 cpy #0
@ -315,7 +378,7 @@ mode_DECANM
mode_DECSCNM mode_DECSCNM
bit pmod bit pmod
bvc :rts bpl :rts
* todo - invert on-screen characters? * todo - invert on-screen characters?
sty DECSCNM sty DECSCNM
@ -323,7 +386,7 @@ mode_DECSCNM
mode_DECOM mode_DECOM
bit pmod bit pmod
bvc :rts bpl :rts
sty DECOM sty DECOM
; move to the new home position ; move to the new home position
@ -342,27 +405,27 @@ mode_DECOM
mode_DECAWM mode_DECAWM
bit pmod bit pmod
bvc :rts bpl :rts
sty DECAWM sty DECAWM
:rts rts :rts rts
mode_DECARM mode_DECARM
bit pmod bit pmod
bvc :rts bpl :rts
sty DECARM sty DECARM
:rts rts :rts rts
mode_LNM mode_LNM
bit pmod bit pmod
bvs :rts bmi :rts
sty LNM sty LNM
:rts rts :rts rts
char_attr csi_m
* esc [ ... m * esc [ ... m
inc pcount inc pcount
ldx #0 ldx #0
@ -373,7 +436,6 @@ char_attr
lda SGR lda SGR
and :and,y and :and,y
ora :or,y ora :or,y
lda :table,y
sta SGR sta SGR
:next inx :next inx
@ -389,25 +451,45 @@ char_attr
reset_tab csi_g
* ESC H - set tab at current column [vt100.s]
* ESC [ g, ESC [ 0 g - clear tab at column * ESC [ g, ESC [ 0 g - clear tab at column
* ESC [ 3 g - clear all tabs * ESC [ 3 g - clear all tabs
lda parm lda parms
beq :0 beq :0
cmp #3 cmp #3
beq :3 beq :3
rts rts
:0
ldx x :0 ldx x
stz tabs,x jmp reset_tab
:3 jmp reset_all_tabs
* cursor movement.
csi_A
csi_B
csi_C
csi_D
rts rts
:3
ldx #80-1 csi_f
:loop stz tabs,x csi_H ; direct cursor addressing
dex rts
bpl :loop
csi_r ; scrolling region
rts
csi_J ; erase
rts
csi_K ; erase
rts
csi_q ; LEDs
rts
csi_n ; status report
csi_c ; what are you?
csi_y ; invoke confidence test
rts rts
sav vt100.csi.L sav vt100.csi.L