From 1cc501e72a8079327cff381e146220223d219990 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sat, 15 Jan 2022 15:59:29 -0500 Subject: [PATCH] buffer outgoing keystrokes this also adds a hexdump in the CDA for the outgoing buffer in local mode, "incoming" data is read from the outgoing buffer. Currently data is (potentially) sent on each run of the main loop. I thought about using the TX empty interrupt but it still needs to be kicked off at some point (unlike incoming data) --- vt100.cda.S | 152 ++++++++++++++++++++++++++++++++++++++++++++------ vt100.key.S | 6 +- vt100.main.S | 39 ++++++------- vt100.modem.S | 122 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 277 insertions(+), 42 deletions(-) diff --git a/vt100.cda.S b/vt100.cda.S index a4074c0..1b347a4 100644 --- a/vt100.cda.S +++ b/vt100.cda.S @@ -52,7 +52,8 @@ page ds 2 pages dw variables - dw hexdump + dw hexdump_r + dw hexdump_w dw ssc_registers shutdown @@ -83,8 +84,7 @@ main jsr clear_inner ldx page jsr (pages,x) -* jsr variables -* jsr hexdump + :keyloop @@ -112,14 +112,14 @@ main dec dec bpl :lok - lda #$04 + lda #$05 :lok sta page bra main :right lda page inc inc - cmp #$04+1 + cmp #$05+1 bcc :rok lda #0 :rok sta page @@ -263,6 +263,7 @@ box variables php sep #$20 + jsr local jsr decanm jsr dectm jsr decbm @@ -276,10 +277,19 @@ variables plp rts +local + mx %10 + ldy #line_4+4 + ldx #:str + jsr print_xy_str + lda DPAGE+LOCAL + jmp print_on_off + +:str asc "LOCAL: ",00 decanm mx %10 - ldy #line_4+4 + ldy #line_5+4 ldx #:str jsr print_xy_str lda DPAGE+DECANM @@ -297,7 +307,7 @@ decanm dectm mx %10 - ldy #line_5+4 + ldy #line_6+4 ldx #:str jsr print_xy_str lda DPAGE+DECTM @@ -308,7 +318,7 @@ dectm decbm mx %10 - ldy #line_6+4 + ldy #line_7+4 ldx #:str jsr print_xy_str lda DPAGE+DECBM @@ -320,7 +330,7 @@ decbm decom mx %10 - ldy #line_7+4 + ldy #line_8+4 ldx #:str jsr print_xy_str lda DPAGE+DECOM @@ -330,7 +340,7 @@ decom deckpam mx %10 - ldy #line_8+4 + ldy #line_9+4 ldx #:str jsr print_xy_str lda DPAGE+DECKPAM @@ -340,7 +350,7 @@ deckpam decckm mx %10 - ldy #line_9+4 + ldy #line_10+4 ldx #:str jsr print_xy_str lda DPAGE+DECCKM @@ -351,7 +361,7 @@ decckm decawm mx %10 - ldy #line_10+4 + ldy #line_11+4 ldx #:str jsr print_xy_str lda DPAGE+DECAWM @@ -362,7 +372,7 @@ decawm decscnm mx %10 - ldy #line_11+4 + ldy #line_12+4 ldx #:str jsr print_xy_str lda DPAGE+DECSCNM @@ -373,7 +383,7 @@ decscnm lnm mx %10 - ldy #line_12+4 + ldy #line_13+4 ldx #:str jsr print_xy_str lda DPAGE+LNM @@ -384,7 +394,7 @@ lnm sgr mx %10 - ldy #line_13+4 + ldy #line_14+4 ldx #:str jsr print_xy_str lda DPAGE+SGR @@ -516,7 +526,8 @@ print_hex iny rts -hexdump + +hexdump_r * * $1e00 buffer * @@ -528,7 +539,7 @@ hexdump :count equ 8 :row equ 10 :c equ 12 - +:ptr equ 14 mx %00 debug hexdump @@ -621,6 +632,113 @@ hexdump plp rts + +hexdump_w +* +* $1d00 buffer +* + +:screen equ 0 +:screen2 equ 2 +:offset equ 4 +:ptr equ 6 +:count equ 8 +:row equ 10 +:c equ 12 +:ptr equ 14 + + mx %00 + debug hexdump + + php + lda #0 + + stz :offset + + sep #$20 + + ldx #4*2 + stx :row + + lda DPAGE+write_q_tail + sec + sbc #8*16 + sta :offset + + + +:one_row + + ldx :row + ldy text,x + sty :screen + sty :screen2 + + + + lda #8 + sta :count + +:one_byte + + ldx :offset + lda $1d00,x + + sta :c + lsr + lsr + lsr + lsr + tax + lda hex,x + ldy :screen + sta |$04,y + iny + lda :c + and #$0f + tax + lda hex,x + sta |$04,y + iny + lda #" " + sta |$04,y + iny + sty :screen + + +* ascii + ldx #"." + lda :c + cmp #$20 + blt :dot + cmp #$80 + bcs :dot + ora #$80 + tax +:dot + txa + ldy :screen2 + sta |8*3+4,y + iny + sty :screen2 + + + inc :offset + dec :count + bne :one_byte + + + ldx :row + inx + inx + stx :row + cpx #20*2 + bcc :one_row + + plp + rts + + hex asc "0123456789abcdef" diff --git a/vt100.key.S b/vt100.key.S index d72adf1..409064c 100644 --- a/vt100.key.S +++ b/vt100.key.S @@ -10,7 +10,8 @@ mx %11 - ext dispatch +* ext dispatch + ext write_modem kmShift equ %0000_0001 @@ -22,6 +23,9 @@ kmUpdateMod equ %0010_0000 kmOption equ %0100_0000 kmCommand equ %1000_0000 +dispatch + jmp write_modem + keypress ent debug keypress lda KBD diff --git a/vt100.main.S b/vt100.main.S index bace64e..a8c8a1a 100644 --- a/vt100.main.S +++ b/vt100.main.S @@ -11,7 +11,7 @@ ext scroll_down ext recalc_cursor,recalc_cursor_x,recalc_cursor_y - ext write_modem,read_modem,init_modem,modem_vector,reset_modem_buffer + ext modem_io,init_modem,modem_vector,reset_modem_buffer ext keypress ext disable_cursor,enable_cursor,cursor_vector ext erase_screen,fill_screen @@ -38,23 +38,16 @@ main debug main loop - bit LOCAL - bmi :kb - jsr read_modem - bcc :kb + jsr keypress ; check for a keypress, write data to out buffer. + jsr modem_io ; + bcc :nope pha jsr disable_cursor pla jsr vt100 -:kb - jsr keypress + bra loop -* -* if there is pending modem data, don't re-enable the cursor yet. -* - lda read_q_head - cmp read_q_tail - bne loop +:nope ; no modem data, re-enable the cursor. jsr enable_cursor bra loop @@ -189,16 +182,16 @@ reset ent rts -dispatch ent - mx %11 -* a = character to xmit - bit LOCAL - bmi :local - jmp write_modem -:local - pha - jsr disable_cursor - pla +*dispatch ent +* mx %11 +** a = character to xmit +* bit LOCAL +* bmi :local +* jmp write_modem +*:local +* pha +* jsr disable_cursor +* pla * fall through diff --git a/vt100.modem.S b/vt100.modem.S index 7daa20b..a8ff523 100644 --- a/vt100.modem.S +++ b/vt100.modem.S @@ -7,6 +7,7 @@ mx %11 cas se use vt.equ + use debug SCCBREG equ $c038 SCCAREG equ $c039 @@ -88,7 +89,7 @@ init_modem ent db 9,%00_0_0_1_0_1_0 ; master interrupts enabled. db -1,-1 -write_modem ent +write_modem_sync ent mx %11 * a: byte to send tay ; save @@ -110,6 +111,7 @@ write_modem ent plp rts + read_modem_sync ent * c set if data read * v set if overrun @@ -146,6 +148,7 @@ read_modem_sync ent :rts rts +write_buffer equ $1d00 read_buffer equ $1e00 modem_vector ent @@ -202,6 +205,123 @@ modem_int plb rtl + + +modem_io ent + debug modem_io + + mx %11 + php + sei + bit LOCAL + bmi :local + +:write +* send any outbound data... + +:mask = %0010_0100 ; tx buffer empty, clear to send + ldx write_q_tail + cpx write_q_head + beq :read + + lda SCCBREG ; sync + stz SCCBREG + lda SCCBREG + and #:mask + cmp #:mask + bne :read + +* ldx write_q_tail + lda write_buffer,x + sta SCCBDATA + inc write_q_tail +:read + ldx read_q_tail + cpx read_q_head + beq :nope + lda read_buffer,x + inc read_q_tail + plp + sec + rts + +:nope + plp + clc + rts + + +:local + ldx write_q_tail + cpx write_q_head + beq :nope + lda write_buffer,x + inc write_q_tail + plp + sec + rts + + + +write_modem ent +write_modem_async ent + + mx %11 + php + sei + +* bit LOCAL +* bmi :local + + ldx write_q_head + sta write_buffer,x + inc write_q_head + plp + rts +*:local +* ldx read_q_head +* sta read_buffer,x +* inc read_q_head +* plp +* rts + + +write_modem_str ent + +; y = address of string (0-terminated) +; inc write_q_head vs inx +; because it wraps at $ff + + mx %10 + php + sei +* bit LOCAL +* bmi :local + +:loop lda |$0000,y + beq :fini + ldx write_q_head + sta write_buffer,x + inc write_q_head + iny + bra :loop + +*:local lda |$0000,y +* beq :fini +* ldx read_q_head +* sta read_buffer,x +* inc read_q_head +* iny +* bra :local + + +:fini + plp + rts + + + + read_modem ent read_modem_async ent