From 073813c19933d4d64a7d66edf716d8960221db0e Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 5 Sep 2021 17:04:52 -0400 Subject: [PATCH] more updates. --- vt.equ.S | 6 ++++ vt100.csi.S | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++-- vt100.ctrl.S | 13 ++++++++ vt100.esc.S | 74 ++++++++++++++++++++++++++++++++++++++++++- vt100.main.S | 38 +++++++++++++++------- 5 files changed, 205 insertions(+), 15 deletions(-) diff --git a/vt.equ.S b/vt.equ.S index 9d13b58..9953a30 100644 --- a/vt.equ.S +++ b/vt.equ.S @@ -57,4 +57,10 @@ pmod ds 2 r0 ds 2 +* saved character for cursor +cursor_saved_char ds 2 + + do *>256 + err "too big" + fin dend diff --git a/vt100.csi.S b/vt100.csi.S index 0b1797d..ba27811 100644 --- a/vt100.csi.S +++ b/vt100.csi.S @@ -475,10 +475,95 @@ csi_D csi_f csi_H ; direct cursor addressing - rts +* honors origin +* large numbers are clamped +* 0 or 1 treated as 1 (1-based counting) + +* based on testing, esc [ 253-255 H will position outside the scrolling +* region when DECOM is active (to first 3 lines, respectively) +* this is not emulated. + +* y + lda parms + beq :yy + dec +:yy bit DECOM + bmi :org + cmp #23 + blt :yyy + lda #23 +:yyy sta y + bra :x + + +:org + clc + adc DECTM + cmp DECBM + blt :org1 + lda DECBM +:org1 sta y + +* x +:x + ldx parms+1 + beq :xx + dex +:xx + cpx #79 + blt :xxx + ldx #79 +:xxx stx x + + jmp update_cursor csi_r ; scrolling region - rts +* based on testing +* esc [ n r (no second parmeter) is equivalent to esc [ n ; 24 r +* esc [ r sets scrolling region to 1 ; 24 ( in accordince with above ) +* 24 is assumed value for second parameter +* invalid parameters exit without updating + + lda parms + beq :p1 + dec parms +:p1 + + lda parms+1 + beq :p2 + dec parms+1 + bra :check + +:p2 lda #23 + sta parms+1 + +:check +* 23 max + ldx parms+0 + cmp #23+1 + bge :rts + + ldx parms+1 + cmp #23+1 + bge :rts + + +* must be at least 1 line + lda parms+1 + sec + sbc parms + beq :rts + bmi :rts + + lda parms + sta DECTM + sta y + lda parms+1 + sta DECBM + stz x + jmp update_cursor + +:rts rts csi_J ; erase rts diff --git a/vt100.ctrl.S b/vt100.ctrl.S index 5a2a166..2e11178 100644 --- a/vt100.ctrl.S +++ b/vt100.ctrl.S @@ -1,4 +1,12 @@ + lst off + cas se + rel + xc + xc + + use vt.equ + *control chars ext draw_char,update_cursor @@ -87,6 +95,11 @@ cr stz x jmp update_cursor + +so ; G1 character set +si ; G0 character set + rts + xon xoff * flow control... diff --git a/vt100.esc.S b/vt100.esc.S index 415d719..2876090 100644 --- a/vt100.esc.S +++ b/vt100.esc.S @@ -1,5 +1,5 @@ - + lst off rel xc xc @@ -161,4 +161,76 @@ vt100_esc_bad ent rts + +vt100_esc_pound ent + +* esc # 3 - make line double height (top half) +* esc # 4 - make line double height (bottom half) +* esc # 5 - make line single width, single height +* esc # 6 - make line double width + +* esc # 8 - screen alignment - fill screen with E (SGR not honored) +* based on testing, this also resets the scrolling region and homes the cursor. + +* based on testing, 0+ are term characters, 0x20-0x2f puts it in esc_bad state + + ldx #st_vt100 + sta state + + cmp #:MIN ; must be 0. + blt :bad + cmp #:MAX+1 + bge :rts + asl + tax + jmp (:table,x) + +:bad ldx #st_vt100_esc_bad + sta state +:rts rts + +:MIN equ 48 +:MAX equ 57 + +:table + dw :rts ; 0 + dw :rts ; 1 + dw :rts ; 2 + dw :rts ; 3 + dw :rts ; 4 + dw :rts ; 5 + dw :rts ; 6 + dw :rts ; 7 + dw :e ; 8 + dw :rts ; 9 + +:e rts + + +vt100_esc_lparen ent +vt100_esc_rparen ent + +* ( sets G0, ) sets G1 +* A - UK set +* B - ASCII set +* 0 - Special Graphics +* 1 - Alternate Char ROM Standard Char Set +* 2 - Alternate Char ROM Special Graphics + +* SO, aka Control-N aka 0x0e set the G1 char set +* SI, aka Control-O aka 0x0f set the G0 char set + +* not currently supported. + + ldx #st_vt100 + sta state + + cmp #'0' + blt :bad + rts + +:bad ldx #st_vt100_esc_bad + sta state +:rts rts + sav vt100.esc.L diff --git a/vt100.main.S b/vt100.main.S index 3a2123a..3a873df 100644 --- a/vt100.main.S +++ b/vt100.main.S @@ -1,3 +1,14 @@ + + lst off + cas se + rel + xc + xc + + use vt.equ + + ext update_cursor,scroll_down + vt100 mx %11 and #$7f @@ -16,6 +27,8 @@ vt100 ext vt52_esc,vt52_dca_1,vt52_dca_2 ext vt100_esc,vt100_csi,vt100_csi_2 ext vt100_esc_pound,vt100_esc_lparen,vt100_esc_rparen + ext vt100_esc_bad,vt100_csi_bad + ext char dw char dw vt52_esc @@ -28,6 +41,8 @@ vt100 dw vt100_esc_pound dw vt100_esc_lparen dw vt100_esc_rparen + dw vt100_esc_bad + dw vt100_csi_bad :ctrl_table @@ -100,24 +115,20 @@ ctrl_1a sta state rts +ctrl_08 ; back space + ldx x + beq :rts + dec x + jmp update_cursor +:rts ctrl_09 ; tab * vt100 has adjustable tabs. - ext tab_table - + ext next_tab_stop ldx x -lp: - cpx #79 - bcs :rts - lda tab_table,x - bne :hit - inx - bra :lp - + jsr next_tab_stop stx x - jmp update_cursor -:rts rts ctrl_0a ; line feed - cursor down w/ scroll ctrl_0b ; vertical tab @@ -145,3 +156,6 @@ ctrl_0c ; form feed. ctrl_0d ; carriage return - cursor to column 0. stz x jmp update_cursor + + + sav vt100.main.L