A2osX/BIN/FORTH.S.CL.txt

287 lines
4.1 KiB
Plaintext
Raw Normal View History

2020-11-19 15:34:02 +00:00
NEW
AUTO 3,1
*--------------------------------------
2021-06-05 15:48:54 +00:00
CL.PrintPrompt >PUSHW L.MSG.PROMPT
>PUSHBI 0
>SYSCALL PrintF
rts
*--------------------------------------
2020-11-19 15:34:02 +00:00
CL.READN0A tax
CL.READN0X >PUSHW ZPCLBuf
>PUSHW L.FMT.Byte
txa
>PUSHA
>PUSHBI 1
>SYSCALL SPrintF
bcs .9
dec CL.bReady
2020-11-19 15:34:02 +00:00
* clc
.9 rts
*--------------------------------------
CL.CHARIN tax
bit CL.bEscMode \e ?
bpl .4
cpx #'['
beq .8 \e[
stz CL.bEscMode
txa
ldx #EscChars.Cnt-1
.1 cmp EscChars,x
beq .2
dex
bpl .1
.8 clc
rts invalid \e[ sequence
2020-11-19 15:34:02 +00:00
.2 lda CL.MaxCnt
bne .3
2020-11-19 15:34:02 +00:00
lda EscChars.Remap,x
bra CL.READN0A
2020-11-19 15:34:02 +00:00
.3 txa
asl
tax
jmp (J.ESC,x)
*--------------------------------------
.4 cpx #C.ESC
bne .5
lda #$ff
sta CL.bEscMode
clc
rts
.5 lda CL.MaxCnt
beq CL.READN0X
2020-11-19 15:34:02 +00:00
cpx #C.SPACE
bcc CL.CHARIN.CTRL
cpx #C.DEL
bne CL.Insert
*--------------------------------------
* Erase char BEFORE cursor
*--------------------------------------
lda CL.Len
beq .8
2020-11-19 15:34:02 +00:00
lda CL.Ptr
beq .8
jsr CL.BS.OUT
2020-11-19 15:34:02 +00:00
dec CL.Ptr
jmp CL.DEL
*--------------------------------------
CL.Insert ldy CL.Len
cpy CL.MaxCnt
beq .8 Buffer full, discard...
iny
sty CL.Len
.1 dey
lda (ZPCLBuf),y Move from Ptr To end of buffer forward...
iny
sta (ZPCLBuf),y
dey
cpy CL.Ptr
bne .1
txa
sta (ZPCLBuf),y
>SYSCALL PutChar
bcs .9
inc CL.Ptr
2020-11-19 15:34:02 +00:00
jsr CL.PrintEOL
bcs .9
2020-11-19 15:34:02 +00:00
2020-12-02 15:22:57 +00:00
lda CL.MaxCnt
dec MaxCnt = 1, don't wait for CR
2020-11-19 15:34:02 +00:00
bne .8
dec CL.bReady
2020-11-19 15:34:02 +00:00
.8 clc
.9 rts
2020-11-19 15:34:02 +00:00
*--------------------------------------
CL.CHARIN.CTRL cpx #C.CR
beq .70
2020-11-19 15:34:02 +00:00
cpx #C.EOF
beq .71
2020-11-19 15:34:02 +00:00
cpx #3 Ctrl-C
beq CL.CLR
2021-06-05 15:48:54 +00:00
cpx #C.TAB
bne .1
jmp HIS.Select
.1 cpx #26 Ctrl-Z
2020-11-19 15:34:02 +00:00
bne .8
jmp CL.SUPPR
.70 jsr CheckLFAfterCR
2020-11-19 15:34:02 +00:00
bcs .9
.71 dec CL.bReady
2020-11-19 15:34:02 +00:00
.8 clc
2020-11-19 15:34:02 +00:00
.9 rts
*--------------------------------------
CL.CLR lda (ZPCLBuf)
beq CL.Reset.1
.1 lda CL.Ptr
cmp CL.Len
beq .2
inc CL.Ptr
2020-11-19 15:34:02 +00:00
jsr CL.FS.OUT
bcc .1
rts
2020-11-19 15:34:02 +00:00
.2 ldy #0
.3 lda #C.DEL
sta (ZPCLBuf),y
iny
lda (ZPCLBuf),y
bne .3
2021-06-05 15:48:54 +00:00
jsr CL.Print
2020-11-19 15:34:02 +00:00
*--------------------------------------
CL.Reset lda #0
sta (ZPCLBuf)
2020-11-19 15:34:02 +00:00
CL.Reset.1 ldx #CL.Ptr
2020-11-19 15:34:02 +00:00
.1 stz 0,x
inx
cpx #CL.bEscMode+1
bne .1
>LDYA ZPCLBuf
>STYA ZPCLBufPtr
CL.Reset.8 clc
2020-11-19 15:34:02 +00:00
rts
*--------------------------------------
CL.BS lda CL.Ptr
beq CL.Reset.8
2020-11-19 15:34:02 +00:00
dec CL.Ptr
CL.BS.OUT lda #C.BS
2020-11-19 15:34:02 +00:00
>SYSCALL PutChar
rts
2020-11-19 15:34:02 +00:00
*--------------------------------------
CL.FS lda CL.Ptr
2020-11-19 15:34:02 +00:00
cmp CL.Len
beq CL.Reset.8
2020-11-19 15:34:02 +00:00
inc
sta CL.Ptr
CL.FS.OUT lda #C.ESC
>SYSCALL PutChar
lda #'['
>SYSCALL PutChar
2020-11-19 15:34:02 +00:00
lda #'C'
>SYSCALL PutChar
rts
2020-11-19 15:34:02 +00:00
*--------------------------------------
* Erase char UNDER cursor
*--------------------------------------
CL.SUPPR lda CL.Len
beq CL.Reset.8
2020-11-19 15:34:02 +00:00
lda CL.Ptr
cmp CL.Len
beq CL.Reset.8
2020-11-19 15:34:02 +00:00
*--------------------------------------
CL.DEL ldy CL.Ptr
.1 iny
lda (ZPCLBuf),y
dey
sta (ZPCLBuf),y
iny
cpy CL.Len
bne .1
dec CL.Len
*--------------------------------------
CL.PrintEOL ldy CL.Ptr
2020-11-19 15:34:02 +00:00
.1 cpy CL.Len
beq .8
2020-11-19 15:34:02 +00:00
phy
2020-11-19 15:34:02 +00:00
lda (ZPCLBuf),y
>SYSCALL PutChar
ply
bcs .9
iny
2020-11-19 15:34:02 +00:00
bra .1
.2 lda #C.SPACE
>SYSCALL PutChar
bcs .9
2020-11-19 15:34:02 +00:00
jsr CL.BS.OUT
bcs .9
2020-11-19 15:34:02 +00:00
ldy CL.Ptr
.3 cpy CL.Len
beq .8
phy
jsr CL.BS.OUT
ply
bcs .9
iny
2020-11-19 15:34:02 +00:00
bra .3
.8 clc
.9 rts
2020-11-19 15:34:02 +00:00
*--------------------------------------
2021-06-05 15:48:54 +00:00
CL.Print ldy #S.PS.hStdOut
2020-11-19 15:34:02 +00:00
lda (pPS),y
>PUSHA
>PUSHW ZPCLBuf
>SYSCALL FPutS
rts
*--------------------------------------
MAN
SAVE usr/src/bin/forth.s.cl
LOAD usr/src/bin/forth.s
ASM