move direct page so it's accessible to CDA

CDA shows direct page variables
move SCC setup to be table-based
esc c reset support.
This commit is contained in:
Kelvin Sherlock 2021-10-25 13:17:47 -04:00
parent c470e945ec
commit 0d64af63d2
6 changed files with 353 additions and 125 deletions

View File

@ -18,6 +18,7 @@ st_vt100_csi_bad equ 22
ESC equ $1b
DPAGE equ $1f00
dum 0
state ds 2

View File

@ -9,6 +9,7 @@
tbx on ; qasm
use apple2gs.equ
use vt.equ
* alternate character set
@ -25,6 +26,13 @@
* 40-column control panel
* TODO - if 80 column set in preferences, draw centered in 80-column mode
dum 0
* cda direct page variables
ptr ds 2
dend
init_cda ent
php
rep #$30
@ -60,6 +68,7 @@ start
jsr clear
jsr box
jsr content
:keyloop
@ -95,15 +104,15 @@ box
* top line
lda #"_ "
sta $0400+38
sta |line_0+38
lda #" _"
sta $0400
sta |line_0
lda #"__"
ldx #34
]loop sta $0400+2,x
]loop sta |line_0+2,x
dex
dex
bpl ]loop
@ -111,15 +120,15 @@ box
* bottom line.
* 'L' = $4c = _ but high
lda #'L '!$8000 ; keep ' ' high ascii.
sta $07d0+38
sta |line_23+38
lda #' L'!$0080 ; keep ' ' high ascii.
sta $07d0
sta |line_23
lda #'LL'
ldx #34
]loop sta $07d0+2,x
]loop sta |line_23+2,x
dex
dex
bpl ]loop
@ -150,14 +159,14 @@ box
* title
ldx #36
]loop lda :title,x
sta |$0480+1,x
sta |line_1+1,x
dex
dex
bpl ]loop
lda #'LL'
ldx #36
]loop sta |$0500+1,x
]loop sta |line_2+1,x
dex
dex
bpl ]loop
@ -165,7 +174,7 @@ box
* bottom instructions
ldx #:instr_len-2
]loop lda :instr,x
sta |$0750+1,x
sta |line_22+1,x
dex
dex
bpl ]loop
@ -187,6 +196,181 @@ box
ds 38-18,' '
* print variables.
content
php
sep #$20
jsr decanm
jsr dectm
jsr decbm
jsr decom
jsr deckpam
jsr decckm
jsr decawm
jsr decscnm
jsr lnm
plp
rts
decanm
mx %10
ldy #line_4+4
ldx #:str
jsr print_xy_str
lda DECANM
bmi :100
ldx #:vt52
jmp print_xy_str
:100 ldx #:vt100
jmp print_xy_str
:str asc "DECANM: ",00
:vt100 asc "vt100",00
:vt52 asc "vt52",00
dectm
mx %10
ldy #line_5+4
ldx #:str
jsr print_xy_str
lda DPAGE+DECTM
inc
jmp print_number
:str asc "DECTM: ",00
decbm
mx %10
ldy #line_6+4
ldx #:str
jsr print_xy_str
lda DPAGE+DECBM
inc
jmp print_number
:str asc "DECBM: ",00
decom
mx %10
ldy #line_7+4
ldx #:str
jsr print_xy_str
lda DPAGE+DECOM
inc
jmp print_number
:str asc "DECOM: ",00
deckpam
mx %10
ldy #line_8+4
ldx #:str
jsr print_xy_str
lda DPAGE+DECKPAM
jmp print_check
:str asc "DECKPAM: ",00
decckm
mx %10
ldy #line_9+4
ldx #:str
jsr print_xy_str
lda DPAGE+DECCKM
jmp print_check
:str asc "DECCKM: ",00
decawm
mx %10
ldy #line_10+4
ldx #:str
jsr print_xy_str
lda DPAGE+DECAWM
jmp print_check
:str asc "DECAWM: ",00
decscnm
mx %10
ldy #line_10+4
ldx #:str
jsr print_xy_str
lda DPAGE+DECSCNM
jmp print_check
:str asc "DECSCNM: ",00
lnm
mx %10
ldy #line_12+4
ldx #:str
jsr print_xy_str
lda DPAGE+LNM
jmp print_check
:str asc "LNM: ",00
print_xy_str
mx %10
:loop lda |$0,x
beq :end
sta |$0,y
inx
iny
bra :loop
:end
rts
print_check
mx %10
bmi :set
ldx #:off
jmp print_xy_str
:set ldx #:on
jmp print_xy_str
:on asc "on",00
:off asc "off",00
print_number
mx %10
cmp #20
bcs :2
cmp #10
bcs :1
:0 ora #"0"
sta |$0,y
iny
rts
:2 pha
lda #"2"
sta |$0,y
iny
pla
sec
sbc #20
bra :0
:1 pha
lda #"1"
sta |$0,y
iny
pla
sec
sbc #10
bra :0
text
dw $0400
dw $0480
@ -215,4 +399,30 @@ text
line_0 equ $0400
line_1 equ $0480
line_2 equ $0500
line_3 equ $0580
line_4 equ $0600
line_5 equ $0680
line_6 equ $0700
line_7 equ $0780
line_8 equ $0428
line_9 equ $04a8
line_10 equ $0528
line_11 equ $05a8
line_12 equ $0628
line_13 equ $06a8
line_14 equ $0728
line_15 equ $07a8
line_16 equ $0450
line_17 equ $04d0
line_18 equ $0550
line_19 equ $05d0
line_20 equ $0650
line_21 equ $06d0
line_22 equ $0750
line_23 equ $07d0
sav vt100.cda.L

View File

@ -11,6 +11,7 @@
ext recalc_cursor,recalc_cursor_x,recalc_cursor_y
ext scroll_up,scroll_down
ext reset
vt100_esc ent
* #[()=>cH78DEM
@ -206,8 +207,8 @@ esc_M ; reverse index
:rts rts
esc_c ; reset terminal.
rts
esc_c ; TODO - reset terminal.
jmp reset
vt100_esc_bad ent
@ -294,6 +295,7 @@ vt100_esc_rparen ent
* SI, aka Control-O aka 0x0f set the G0 char set
* not currently supported.
* TODO - mouse text support?
ldx #st_vt100
stx state

View File

@ -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
ext write_modem,read_modem,init_modem,modem_vector,reset_modem_buffer
ext keypress
ext disable_cursor,enable_cursor,cursor_vector
ext erase_screen,fill_screen
@ -25,6 +25,9 @@ main debug main
xce
cli
pea DPAGE
pld
jsr init
jsr enable_cursor
@ -51,6 +54,7 @@ loop
init
mx %11
lda #" "
jsr fill_screen ; erase first to prevent flash if going 40->80 columns.
@ -116,6 +120,68 @@ init
jsr init_cda
rts
reset ent
mx %11
php
* disable 1-sec interrupt...
lda #4
trb VGCINT ; disable 1-sec interrupt.
stz SCANINT ; reset 1-sec interrupt
lda #" "
jsr fill_screen ; erase first to prevent flash if going 40->80 columns.
rep #$30
ldx #254
:zloop stz 0,x
dex
dex
bpl :zloop
lda #$0400
sta cursor_base
lda #$01
sta cursor_base+2
lda #" " ; 16-bit
sta erase_char
lda #$0080
sta cursor_state
lda #0 ; clear high byte
sep #$30
lda #"_"
sta cursor_char
lda #23
sta DECBM
lda #$80
sta DECANM
lda #st_vt100
sta state
jsr init_tabs
* jsr enable_cursor
jsr reset_modem_buffer
lda #4
tsb VGCINT ; enable 1-sec interrupt.
stz SCANINT ; reset 1-sec interrupt
plp
rts
dispatch ent
mx %11

View File

@ -32,138 +32,72 @@ SerFlag equ $e10104 ;
init_modem ent
* sep #$30
php
sei
stz q_head
stz q_tail
* reset channel B (modem port)
ldx #9
lda #%01_0_1_0_0_0_1
stx SCCBREG
sta SCCBREG
nop
nop
* x16 clock mode, 1 stop bit, no parity
ldx #4
lda #%01_00_01_0_0
stx SCCBREG
sta SCCBREG
* 8 bits/char, rx disabled.
ldx #3
lda #%11_0_0_0_0_0_0
stx SCCBREG
sta SCCBREG
* 8 data bits, RTS
ldx #5
lda #%0_11_0_0_0_1_0
stx SCCBREG
sta SCCBREG
* bit 7 = 1 for printer port, 0 for modem port.
* 5/6 = (%10) rcv clock = br output
* 4/3 = (%10) tx clock = br output
ldx #11
lda #%0_10_10_0_00
stx SCCBREG
sta SCCBREG
* 9600 baud
ldx #12
lda #10
stx SCCBREG
sta SCCBREG
* 9600 baud
ldx #13
lda #0
stx SCCBREG
sta SCCBREG
* disable baud rate generator
ldx #14
lda #0
stx SCCBREG
sta SCCBREG
* enable baud rate generator
ldx #14
lda #%000_0_0_0_0_1
stx SCCBREG
sta SCCBREG
* 8 bits/char, rx enabled.
ldx #3
lda #%11_0_0_0_0_0_1
stx SCCBREG
sta SCCBREG
* 8 data bits, tx enabled, RTS
ldx #5
lda #%0_11_0_1_0_1_0
stx SCCBREG
sta SCCBREG
* disable interrupts
ldx #15
lda #0
stx SCCBREG
sta SCCBREG
* reset ext/status interrupts
lda SCCBREG ; sync access
ldx #0
lda #%00_010_0_00
stx SCCBREG
]loop
lda :table,x
bmi :done
sta SCCBREG
* enable interrupts
ldx #1
* lda #0
lda #%0_0_0_10_0_0_0 ; inr on rx or special condition.
stx SCCBREG
inx
lda :table,x
sta SCCBREG
* reset ch b ptr to 0?
lda SCCBREG
* no vector, master interrupts enabled
ldx #9
lda #%00_0_0_1_0_1_0
stx SCCBREG
sta SCCBREG
nop
nop
inx
bra ]loop
:done
* adjust SerFlag so serial IRQs will be handled.
lda >SerFlag
ora #%00_000_111 ; channel B interrupts.
sta >SerFlag
plp
rts
:table ; register, value
* db 9,%01_0_1_0_0_0_1 ; reset channel B (modem port) - handled @ startup.
db 4,%01_00_01_0_0 ; x16 clock, 1 stop bit, no parity
db 3,%11_0_0_0_0_0_0 ; 8 bits, rx disabled
db 5,%0_11_0_0_0_1_0 ; 8 bits, RTS
db 11,%0_10_10_0_00 ; modem port, rcv/tx clock = br
db 12,10 ; 9600 baud (low)
db 13,0 ; 9600 baud (high)
db 14,0 ; disable baud rate generator
db 14,%000_0_0_0_0_1 ; enable baud rate generator
db 3,%11_0_0_0_0_0_1 ; 8 bits, rx enabled
db 5,%0_11_0_1_0_1_0 ; 8 bits, tx enabled, RTS
db 15,0 ; disable external interrupts
db 0,%00_010_0_00 ; reset ext/status interrupts
db 1,%0_0_0_10_0_0_0 ; interrupts on rx or special condition
db 9,%00_0_0_1_0_1_0 ; master interrupts enabled.
db -1,-1
write_modem ent
mx %11
* a: byte to send
tay ; save
* ldx #0
php
:mask = %0010_0100 ; tx buffer empty, clear to send
:wait stz SCCBREG
:wait
cli ; guard scc register access.
sei
stz SCCBREG
lda SCCBREG
and #:mask
cmp #:mask
bne :wait
sty SCCBDATA
plp
rts
read_modem_sync ent
@ -183,9 +117,7 @@ read_modem_sync ent
lda SCCBREG
and #%0010_0000
beq :ok
* indicate overrun...
lda #"x"
sta |$07d0+20
* clear the overrun
lda #$30 ; reg0, error reset.
sta SCCBREG
@ -198,17 +130,13 @@ read_modem_sync ent
lda SCCBDATA
* debugging...
ldx :debug
sta $1e00,x
inc :debug
sec
:rts rts
:debug ds 2
buffer equ $1d00
buffer equ $1e00
modem_vector ent
jml modem_int
@ -219,6 +147,7 @@ modem_int
* a/x/y don't need to be preserved.
* return carry clear if handled, carry set if not.
* doesn't access direct page.
* check/clear overrun?
mx %11
@ -285,6 +214,15 @@ read_modem_async ent
clc
rts
reset_modem_buffer ent
mx %11
php
sei
stz q_head
stz q_tail
plp
rts
q_head ds 2
q_tail ds 2
*buffer ds 256

View File

@ -100,11 +100,20 @@ cursor_int
mx %11
phb
phd
phk
plb
* check if CDA active.
* $ff = inactive, $00 = active
lda >NumInts
bpl :rts
pea DPAGE
pld
ldy cursor_offset
lda cursor_state
@ -125,6 +134,8 @@ cursor_int
sta [cursor_base],y
:rts stz SCANINT ; reset 1-sec interrupt
pld
plb
clc
rtl