mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-03 12:06:05 +00:00
293 lines
4.7 KiB
Plaintext
293 lines
4.7 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
CL.Init >LDYAI 256
|
||
>SYSCALL GetMem
|
||
bcs .9
|
||
>STYA ZPCLBuf
|
||
txa
|
||
>STA.G CL.hCLBuf
|
||
.9 rts
|
||
*--------------------------------------
|
||
CL.Quit >LDA.G CL.hCLBuf
|
||
beq .9
|
||
>SYSCALL FreeMem
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
CL.PrintPrompt >LDYA L.PS1
|
||
|
||
>SYSCALL ExpandStr
|
||
bcs .9
|
||
phx
|
||
pha
|
||
>PUSHBI 0
|
||
pla
|
||
>SYSCALL printf
|
||
pla
|
||
>SYSCALL FreeMem
|
||
.1 >PUSHBI 0
|
||
>LDYA L.MSG.PROMPT
|
||
>SYSCALL printf
|
||
.9 rts
|
||
*--------------------------------------
|
||
CL.READN0X txa
|
||
CL.READN0A >PUSHA
|
||
>PUSHBI 1
|
||
>PUSHW L.FMT.Byte
|
||
>LDYA ZPCLBuf
|
||
>SYSCALL sprintf
|
||
bcs .9
|
||
|
||
lda #$ff
|
||
>STA.G CL.bReady
|
||
* clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CL.CHARIN tax
|
||
|
||
>LDA.G CL.bEscMode \e ?
|
||
beq .13
|
||
|
||
cpx #'['
|
||
beq .8 \e[
|
||
|
||
lda #0
|
||
sta (pData),y Y=bEscMode
|
||
txa
|
||
|
||
ldx #EscChars.Cnt-1
|
||
|
||
.17 cmp EscChars,x
|
||
beq .18
|
||
|
||
dex
|
||
bpl .17
|
||
|
||
.8 rts invalid \e[ sequence
|
||
|
||
.18 >LDA.G READ.N
|
||
bne .19
|
||
|
||
lda EscChars.Remap,x
|
||
bra CL.READN0A
|
||
|
||
.19 txa
|
||
asl
|
||
tax
|
||
jmp (J.ESC,x)
|
||
*--------------------------------------
|
||
.13 cpx #C.ESC
|
||
bne .11
|
||
|
||
lda #$ff
|
||
>STA.G CL.bEscMode
|
||
clc
|
||
rts
|
||
|
||
.11 >LDA.G READ.N
|
||
beq CL.READN0X
|
||
|
||
cpx #C.SPACE
|
||
bcc CL.CHARIN.CTRL
|
||
|
||
.1 cpx #C.DEL
|
||
bne CL.Insert
|
||
*--------------------------------------
|
||
* Erase char BEFORE cursor
|
||
*--------------------------------------
|
||
>LDA.G CL.Len
|
||
beq .8
|
||
>LDA.G CL.Ptr
|
||
beq .8
|
||
|
||
lda #C.BS
|
||
>SYSCALL PutChar
|
||
|
||
>DEC.G CL.Ptr
|
||
jmp CL.DEL
|
||
*--------------------------------------
|
||
CL.Insert >LDA.G CL.Len
|
||
>CMP.G READ.N
|
||
beq .8 Buffer full, discard...
|
||
|
||
inc
|
||
>STA.G CL.Len
|
||
|
||
pha
|
||
.1 ply
|
||
dey
|
||
lda (ZPCLBuf),y Move from Ptr To end of buffer forward...
|
||
iny
|
||
sta (ZPCLBuf),y
|
||
dey
|
||
phy
|
||
tya
|
||
>CMP.G CL.Ptr
|
||
bne .1
|
||
|
||
ply Y=CL.Ptr
|
||
* >LDA.G CL.Ptr
|
||
|
||
txa
|
||
sta (ZPCLBuf),y
|
||
>INC.G CL.Ptr
|
||
|
||
>LDA.G bREAD.S
|
||
bmi .7
|
||
txa
|
||
>SYSCALL PutChar
|
||
jsr CL.PrintEOL
|
||
|
||
.7 >LDA.G READ.N READ N = 1, don't wait for CR
|
||
dec
|
||
bne .8
|
||
lda #$ff
|
||
>STA.G CL.bReady
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CL.CHARIN.CTRL cpx #C.CR
|
||
beq .18
|
||
|
||
cpx #C.EOF
|
||
beq .18
|
||
|
||
cpx #3 Ctrl-C
|
||
beq CL.CLR
|
||
|
||
cpx #26 Ctrl-Z
|
||
bne .8
|
||
jmp CL.SUPPR
|
||
|
||
.18 jsr CheckLFAfterCR Check for any extra LF
|
||
bcs .9
|
||
|
||
lda #$ff
|
||
>STA.G CL.bReady
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CL.CLR lda (ZPCLBuf)
|
||
beq CL.RESET.1
|
||
|
||
.1 >LDA.G CL.Ptr
|
||
>CMP.G CL.Len
|
||
beq .2
|
||
inc
|
||
>STA.G CL.Ptr
|
||
lda #C.FS
|
||
>SYSCALL PutChar
|
||
bra .1
|
||
|
||
.2 ldy #0
|
||
|
||
.3 lda #C.DEL
|
||
sta (ZPCLBuf),y
|
||
|
||
iny
|
||
lda (ZPCLBuf),y
|
||
bne .3
|
||
|
||
jsr CL.PrintCLBuf
|
||
*--------------------------------------
|
||
CL.RESET lda #0
|
||
sta (ZPCLBuf)
|
||
|
||
CL.RESET.1 >STA.G CL.Ptr
|
||
>STA.G CL.Len
|
||
>STA.G CL.bReady
|
||
>STA.G CL.bEscMode
|
||
rts
|
||
|
||
*ldy #CL.Ptr
|
||
|
||
*.1 sta (pData),y
|
||
* iny
|
||
* cpx #CL.bEscMode+1
|
||
* bne .1
|
||
|
||
rts
|
||
*--------------------------------------
|
||
CL.BS >LDA.G CL.Ptr
|
||
beq .9
|
||
dec
|
||
sta (pData),y
|
||
lda #C.BS
|
||
>SYSCALL PutChar
|
||
.9 rts
|
||
*--------------------------------------
|
||
CL.NAK >LDA.G CL.Ptr
|
||
>CMP.G CL.Len
|
||
beq .9
|
||
inc
|
||
>STA.G CL.Ptr
|
||
lda #C.FS
|
||
>SYSCALL PutChar
|
||
.9 rts
|
||
*--------------------------------------
|
||
* Erase char UNDER cursor
|
||
*--------------------------------------
|
||
CL.SUPPR >LDA.G CL.Len
|
||
beq CL.PrintEOL.8
|
||
>LDA.G CL.Ptr
|
||
>CMP.G CL.Len
|
||
beq CL.PrintEOL.8
|
||
*--------------------------------------
|
||
CL.DEL pha
|
||
.1 ply
|
||
iny
|
||
lda (ZPCLBuf),y
|
||
dey
|
||
sta (ZPCLBuf),y
|
||
iny
|
||
phy
|
||
tya
|
||
|
||
>CMP.G CL.Len
|
||
bne .1
|
||
pla
|
||
>DEC.G CL.Len
|
||
*--------------------------------------
|
||
CL.PrintEOL >LDA.G CL.Ptr
|
||
.1 >CMP.G CL.Len
|
||
beq .2
|
||
pha
|
||
tay
|
||
lda (ZPCLBuf),y
|
||
>SYSCALL PutChar
|
||
pla
|
||
inc
|
||
bra .1
|
||
|
||
.2 lda #' '
|
||
>SYSCALL PutChar
|
||
>LDA.G CL.Ptr
|
||
.3 >CMP.G CL.Len
|
||
beq .4
|
||
pha
|
||
lda #C.BS
|
||
>SYSCALL PutChar
|
||
pla
|
||
inc
|
||
bra .3
|
||
.4 lda #C.BS
|
||
>SYSCALL PutChar
|
||
|
||
CL.PrintEOL.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CL.PrintCLBuf >LDYA ZPCLBuf
|
||
>PUSHYA
|
||
ldy #S.PS.hStdOut
|
||
lda (pPs),y
|
||
>SYSCALL fputs
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/BIN/SH.S.CL
|
||
LOAD USR/SRC/BIN/SH.S
|
||
ASM
|