From 6e0de284e08c3f78c43ca3d4a8e3aaf89717f04e Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Fri, 17 Sep 2021 19:50:56 -0400 Subject: [PATCH] more vt100 code to handle DECAWM mode, bit 7 of x ($80 + 79) indicates a wrap is imminent, as opposed to just being in column 79. backspace, etc will drop back to column 78 (based on testing). --- vt.equ.S | 13 +++++++++++-- vt100.csi.S | 2 ++ vt100.ctrl.S | 5 ++++- vt100.esc.S | 6 +++++- vt100.link.S | 23 +++++++++++++---------- vt100.main.S | 20 +++++++++++++------- vt100.tabs.S | 32 ++++++++++++++++---------------- vt100.vt52.S | 20 +++++++++++++------- 8 files changed, 77 insertions(+), 44 deletions(-) diff --git a/vt.equ.S b/vt.equ.S index 9953a30..57798d4 100644 --- a/vt.equ.S +++ b/vt.equ.S @@ -20,6 +20,7 @@ ESC equ $1b state ds 2 x ds 2 y ds 2 + DECTM ds 2 ; top margin DECBM ds 2 ; bottom margin @@ -55,10 +56,18 @@ pcount ds 2 parms ds MAX_PCOUNT pmod ds 2 +; scratch registers r0 ds 2 -* saved character for cursor -cursor_saved_char ds 2 + +cursor_saved_char ds 2 ; saved char under the cursor +cursor_base ds 4 +cursor_offset ds 2 +cursor_char ds 2 ; cursor character +cursor_state ds 2 ; on/off/disabled. + +draw_inverse ds 2 ; flag to draw inverse +erase_char ds 2 ; clear character do *>256 err "too big" diff --git a/vt100.csi.S b/vt100.csi.S index ba27811..973fe1d 100644 --- a/vt100.csi.S +++ b/vt100.csi.S @@ -9,6 +9,8 @@ use vt.equ + mx %11 + ext update_cursor,reset_tab,reset_all_tabs vt100_csi ent diff --git a/vt100.ctrl.S b/vt100.ctrl.S index 2e11178..46851b0 100644 --- a/vt100.ctrl.S +++ b/vt100.ctrl.S @@ -67,12 +67,15 @@ bs * backspace, no wrap lda x beq :rts - dec x + and #$7f + dec + sta x jmp update_cursor :rts rts tab * go to next tab stop +* tab at 80 does not reset overflow. rts lf diff --git a/vt100.esc.S b/vt100.esc.S index 2876090..7fe4607 100644 --- a/vt100.esc.S +++ b/vt100.esc.S @@ -6,6 +6,9 @@ use vt.equ + mx %11 + + vt100_esc ent * #[()=>cH78DEM * based on testing, unspecified chars in the 0x20-0x2f range cause it to gobble @@ -13,7 +16,6 @@ vt100_esc ent * esc 1 -> hangs? [undocumented] - ldx #st_vt100 stx state @@ -137,7 +139,9 @@ esc_gt ; exit alternate keypad mode esc_H ; set tab stop ext set_tab ldx x + bmi :rts jmp set_tab +:rts rts esc_E ; next line stz x diff --git a/vt100.link.S b/vt100.link.S index 6276036..eeb4c38 100644 --- a/vt100.link.S +++ b/vt100.link.S @@ -1,22 +1,25 @@ ovr all - * binary linker lkv 0 org $6000 - asm boot.S - asm vt100.ctrl.S +* asm boot.S +* asm vt100.ctrl.S + asm vt100.esc.S + asm vt100.tabs.S + asm vt100.vt52.S + asm vt100.csi.S + asm vt100.screen.S - - lnk boot.S - pos ; reset +* lnk boot.S +* pos ; reset - pos EMU_SIZE -EMU_SIZE ext -EMU_BLOCKS geq EMU_SIZE+511\512 +* pos EMU_SIZE +*EMU_SIZE ext +*EMU_BLOCKS geq EMU_SIZE+511\512 - sav vt100.bin \ No newline at end of file +* sav vt100.bin \ No newline at end of file diff --git a/vt100.main.S b/vt100.main.S index 3a873df..3a80fd7 100644 --- a/vt100.main.S +++ b/vt100.main.S @@ -104,6 +104,7 @@ ctrl_18 ctrl_1a * vt100 - abort current escape sequence * and display error character. +* TODO - display error character (mouse text) lda DECANM bne :vt52 lda #st_vt100 @@ -116,9 +117,11 @@ ctrl_1a rts ctrl_08 ; back space - ldx x + lda x beq :rts - dec x + and #$7f + dec + sta x jmp update_cursor :rts @@ -126,9 +129,11 @@ ctrl_09 ; tab * vt100 has adjustable tabs. ext next_tab_stop ldx x + bmi :rts jsr next_tab_stop stx x jmp update_cursor +:rts rts ctrl_0a ; line feed - cursor down w/ scroll ctrl_0b ; vertical tab @@ -136,18 +141,19 @@ ctrl_0c ; form feed. * if LNM is active, equivalent to CR, LF - lda #LNM - bne :lnm + bit #LNM + bpl :lf stz x -:lnm +:lf lda y - cmp #23 + cmp #DECBM blt :simple - lda #" " + lda #" " ; needs to factor in reverse video sta cursor_saved_char jmp scroll_down +* if LNM mode, need to update cursor as well. :simple inc y diff --git a/vt100.tabs.S b/vt100.tabs.S index 5e21e12..46f4616 100644 --- a/vt100.tabs.S +++ b/vt100.tabs.S @@ -1,30 +1,29 @@ - + lst off rel xc xc use vt.equ + mx %11 init_tabs ent - - ldx #80 -:loop stz tabs,x + ldx #80-1 +:zloop stz tabs,x dex + bpl :zloop + + lda #$80 + ldy #8 +:loop ldx :table,y + sta tabs,x + dey bpl :loop - lda #72 - ldy #$80 -:tloop tax - sty tabs,x - sec - sbc #8 - bne :tloop - rts -*:table db 8*1,8*2,8*3,8*4,8*5,8*6,8*7,8*8*,8*9 +:table db 8*1,8*2,8*3,8*4,8*5,8*6,8*7,8*8*,8*9 set_tab ent * input x = x @@ -58,8 +57,9 @@ next_tab_stop ent * input x = x * ldx x - cpx 79 - bge :80 + inx + cpx #79 + bge :79 :loop bit tabs,x bmi :rts @@ -68,7 +68,7 @@ next_tab_stop ent bcc :loop -:80 ldx #80 +:79 ldx #79 :rts rts diff --git a/vt100.vt52.S b/vt100.vt52.S index 1fd464e..d7687ab 100644 --- a/vt100.vt52.S +++ b/vt100.vt52.S @@ -1,16 +1,20 @@ -* -* vt52 emulation for the vt100 -* -* ESC < exits - lst off rel xc xc - use vt.equ + mx %11 + +* +* vt52 emulation for the vt100 +* +* ESC < exits + + + + ext update_cursor,write_modem,draw_char @@ -129,7 +133,9 @@ esc_D ; cursor left lda x beq :rts - dec x + and #$7f + dec + sta x jmp update_cursor :rts rts