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)
This commit is contained in:
Kelvin Sherlock 2022-01-15 15:59:29 -05:00
parent f486bbfb1b
commit 1cc501e72a
4 changed files with 277 additions and 42 deletions

View File

@ -52,7 +52,8 @@ page ds 2
pages dw variables pages dw variables
dw hexdump dw hexdump_r
dw hexdump_w
dw ssc_registers dw ssc_registers
shutdown shutdown
@ -83,8 +84,7 @@ main
jsr clear_inner jsr clear_inner
ldx page ldx page
jsr (pages,x) jsr (pages,x)
* jsr variables
* jsr hexdump
:keyloop :keyloop
@ -112,14 +112,14 @@ main
dec dec
dec dec
bpl :lok bpl :lok
lda #$04 lda #$05
:lok sta page :lok sta page
bra main bra main
:right lda page :right lda page
inc inc
inc inc
cmp #$04+1 cmp #$05+1
bcc :rok bcc :rok
lda #0 lda #0
:rok sta page :rok sta page
@ -263,6 +263,7 @@ box
variables variables
php php
sep #$20 sep #$20
jsr local
jsr decanm jsr decanm
jsr dectm jsr dectm
jsr decbm jsr decbm
@ -276,10 +277,19 @@ variables
plp plp
rts 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 decanm
mx %10 mx %10
ldy #line_4+4 ldy #line_5+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+DECANM lda DPAGE+DECANM
@ -297,7 +307,7 @@ decanm
dectm dectm
mx %10 mx %10
ldy #line_5+4 ldy #line_6+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+DECTM lda DPAGE+DECTM
@ -308,7 +318,7 @@ dectm
decbm decbm
mx %10 mx %10
ldy #line_6+4 ldy #line_7+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+DECBM lda DPAGE+DECBM
@ -320,7 +330,7 @@ decbm
decom decom
mx %10 mx %10
ldy #line_7+4 ldy #line_8+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+DECOM lda DPAGE+DECOM
@ -330,7 +340,7 @@ decom
deckpam deckpam
mx %10 mx %10
ldy #line_8+4 ldy #line_9+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+DECKPAM lda DPAGE+DECKPAM
@ -340,7 +350,7 @@ deckpam
decckm decckm
mx %10 mx %10
ldy #line_9+4 ldy #line_10+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+DECCKM lda DPAGE+DECCKM
@ -351,7 +361,7 @@ decckm
decawm decawm
mx %10 mx %10
ldy #line_10+4 ldy #line_11+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+DECAWM lda DPAGE+DECAWM
@ -362,7 +372,7 @@ decawm
decscnm decscnm
mx %10 mx %10
ldy #line_11+4 ldy #line_12+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+DECSCNM lda DPAGE+DECSCNM
@ -373,7 +383,7 @@ decscnm
lnm lnm
mx %10 mx %10
ldy #line_12+4 ldy #line_13+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+LNM lda DPAGE+LNM
@ -384,7 +394,7 @@ lnm
sgr sgr
mx %10 mx %10
ldy #line_13+4 ldy #line_14+4
ldx #:str ldx #:str
jsr print_xy_str jsr print_xy_str
lda DPAGE+SGR lda DPAGE+SGR
@ -516,7 +526,8 @@ print_hex
iny iny
rts rts
hexdump
hexdump_r
* *
* $1e00 buffer * $1e00 buffer
* *
@ -528,7 +539,7 @@ hexdump
:count equ 8 :count equ 8
:row equ 10 :row equ 10
:c equ 12 :c equ 12
:ptr equ 14
mx %00 mx %00
debug hexdump debug hexdump
@ -621,6 +632,113 @@ hexdump
plp plp
rts 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" hex asc "0123456789abcdef"

View File

@ -10,7 +10,8 @@
mx %11 mx %11
ext dispatch * ext dispatch
ext write_modem
kmShift equ %0000_0001 kmShift equ %0000_0001
@ -22,6 +23,9 @@ kmUpdateMod equ %0010_0000
kmOption equ %0100_0000 kmOption equ %0100_0000
kmCommand equ %1000_0000 kmCommand equ %1000_0000
dispatch
jmp write_modem
keypress ent keypress ent
debug keypress debug keypress
lda KBD lda KBD

View File

@ -11,7 +11,7 @@
ext scroll_down ext scroll_down
ext recalc_cursor,recalc_cursor_x,recalc_cursor_y 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 keypress
ext disable_cursor,enable_cursor,cursor_vector ext disable_cursor,enable_cursor,cursor_vector
ext erase_screen,fill_screen ext erase_screen,fill_screen
@ -38,23 +38,16 @@ main debug main
loop loop
bit LOCAL jsr keypress ; check for a keypress, write data to out buffer.
bmi :kb jsr modem_io ;
jsr read_modem bcc :nope
bcc :kb
pha pha
jsr disable_cursor jsr disable_cursor
pla pla
jsr vt100 jsr vt100
:kb bra loop
jsr keypress
* :nope ; no modem data, re-enable the cursor.
* if there is pending modem data, don't re-enable the cursor yet.
*
lda read_q_head
cmp read_q_tail
bne loop
jsr enable_cursor jsr enable_cursor
bra loop bra loop
@ -189,16 +182,16 @@ reset ent
rts rts
dispatch ent *dispatch ent
mx %11 * mx %11
* a = character to xmit ** a = character to xmit
bit LOCAL * bit LOCAL
bmi :local * bmi :local
jmp write_modem * jmp write_modem
:local *:local
pha * pha
jsr disable_cursor * jsr disable_cursor
pla * pla
* fall through * fall through

View File

@ -7,6 +7,7 @@
mx %11 mx %11
cas se cas se
use vt.equ use vt.equ
use debug
SCCBREG equ $c038 SCCBREG equ $c038
SCCAREG equ $c039 SCCAREG equ $c039
@ -88,7 +89,7 @@ init_modem ent
db 9,%00_0_0_1_0_1_0 ; master interrupts enabled. db 9,%00_0_0_1_0_1_0 ; master interrupts enabled.
db -1,-1 db -1,-1
write_modem ent write_modem_sync ent
mx %11 mx %11
* a: byte to send * a: byte to send
tay ; save tay ; save
@ -110,6 +111,7 @@ write_modem ent
plp plp
rts rts
read_modem_sync ent read_modem_sync ent
* c set if data read * c set if data read
* v set if overrun * v set if overrun
@ -146,6 +148,7 @@ read_modem_sync ent
:rts rts :rts rts
write_buffer equ $1d00
read_buffer equ $1e00 read_buffer equ $1e00
modem_vector ent modem_vector ent
@ -202,6 +205,123 @@ modem_int
plb plb
rtl 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 ent
read_modem_async ent read_modem_async ent