A2osX/LIB/LIBTUI.S.CTX.txt

352 lines
5.2 KiB
Plaintext
Raw Normal View History

NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
CTX.Init >LDYA L.SEQ.INIT
jsr CTX.fputs
bcs .99
>LDYAI S.CTX
>SYSCALL2 GetMem
bcs .99
>STYA ZPCtxPtr
txa
>PUSHA hCTX
lda #0
>PUSHA Init Counter
ldy #S.CTX-1
.10 sta (ZPCtxPtr),y
dey
bpl .10
jsr CTX.GetC.Reset
.1 >SLEEP
jsr CTX.GetC
bcs .98
beq .2
jsr CTX.PutC
bcs .98
.2 ldy #S.CTX.W
lda (ZPCtxPtr),y
bne .8
lda (pStack)
dec
sta (pStack)
bne .1
lda #80
ldy #S.CTX.W
sta (ZPCtxPtr),y
lda #24
iny S.CTX.H
sta (ZPCtxPtr),y
.8 inc pStack Discard counter
>PULLA hCTX
clc
.99 rts
.98 pha
inc pStack Discard counter
>PULLA hCTX
>SYSCALL2 FreeMem
pla
sec
rts
*--------------------------------------
CTX.Close >SYSCALL2 FreeMem
>LDYA L.SEQ.CLOSE
jsr CTX.fputs
clc
CTX.Close.RTS rts
*--------------------------------------
CTX.GetC ldx ZPCtxPtr
phx
ldx ZPCtxPtr+1
phx
ldx ZPObjPtr
phx
ldx ZPObjPtr+1
phx
>SYSCALL GetChar
plx
stx ZPObjPtr+1
plx
stx ZPObjPtr
plx
stx ZPCtxPtr+1
plx
stx ZPCtxPtr
bcs CTX.Close.RTS
tax
ldy #S.CTX.bEscMode
lda (ZPCtxPtr),y
beq .20
bmi .40 IAC mode
iny S.CTX.InBufPtr
lda (ZPCtxPtr),y
cpx #'[' CSI ?
bne .12
cmp #S.CTX.InBufPtr
bne .49 buffer not empty...bad SEQ
.12 jsr CTX.GetC.ToBuf
bcs .49 Buffer Full
cpx #'['
beq .18
cpx #64
bcs CTX.GetC.ESCSEQ if CC, not a letter...SEQ is incomplete
.18 lda #0
clc
rts
*--------------------------------------
.20 cpx #C.ESC
bne .30
inc A = $01
bra .31
*--------------------------------------
.30 cpx #IAC
bne .38
dec A = $FF
.31 jsr CTX.GetC.SetMode
lda #0
clc
rts
*--------------------------------------
.38 txa
clc
.39 rts
*--------------------------------------
.40 jsr CTX.GetC.ToBuf
bcs .49 Buffer Full
cpy #S.CTX.InBuf First char...
beq .48
ldy #S.CTX.InBuf
lda (ZPCtxPtr),y
cmp #SB First char is SB ?
bne CTX.GetC.IACSEQ no ...
cpx #SE is SE after SB ..... ?
bne .48
bra CTX.GetC.IACSEQ yes, we have IAC SB .....SE
.49 jsr CTX.GetC.Reset
.48 lda #0
clc
rts
*--------------------------------------
CTX.GetC.ESCSEQ cmp #S.CTX.InBuf+2
bcs .2
ldy #ESC.Out-ESC.In-1
txa
.1 cmp ESC.In,y
beq .7
dey
bpl .1
bra .6
*--------------------------------------
* \e[xxx;yyyR
*--------------------------------------
.2 cpx #'R' Response to cursor position query?
bne .6
lda #S.CTX.InBuf+1 skip ESC [
jsr CTX.GetC.GetCtxEA
>PUSHYA
>PUSHW L.FMT.ESCCSI.R
lda #S.CTX.H
jsr CTX.GetC.GetCtxEA
>PUSHYA
lda #S.CTX.W
jsr CTX.GetC.GetCtxEA
>PUSHYA
>PUSHBI 4 2 pointers
>SYSCALL2 sscanf
.6 ldx #0
bra .8
.7 ldx ESC.Out,y
.8 jsr CTX.GetC.Reset
txa
clc
rts
*--------------------------------------
* IAC SB TN.O.NAWS ww ww hh hh IAC SE
*--------------------------------------
CTX.GetC.IACSEQ ldy #S.CTX.InBuf
lda (ZPCtxPtr),y
cmp #SB
bne .8
iny
lda (ZPCtxPtr),y
cmp #TN.O.NAWS
bne .8
iny
lda (ZPCtxPtr),y
bne .8
iny
lda (ZPCtxPtr),y
cmp #80
bcs .1
lda #80
.1 tax
iny
lda (ZPCtxPtr),y
bne .8
iny
lda (ZPCtxPtr),y
cmp #24
bcs .2
lda #24
.2 ldy #S.CTX.H
sta (ZPCtxPtr),y
dey S.CTX.W
txa
sta (ZPCtxPtr),y
jsr CTX.GetC.Reset
lda #EV.RESIZE
clc
rts
.8 jsr CTX.GetC.Reset
lda #0
clc
rts
*--------------------------------------
CTX.GetC.Reset lda #0
CTX.GetC.SetMode
ldy #S.CTX.bEscMode
sta (ZPCtxPtr),y
iny Y = S.CTX.InBufPtr
tya
sta (ZPCtxPtr),y
rts
*--------------------------------------
CTX.GetC.GetCtxEA
clc
adc ZPCtxPtr
tay
lda ZPCtxPtr+1
adc #0
.9 rts
*--------------------------------------
CTX.GetC.ToBuf ldy #S.CTX.InBufPtr
lda (ZPCtxPtr),y
cmp #S.CTX.EndBuf buffer full
bcs .9
phy
inc
tay
txa
sta (ZPCtxPtr),y
tya
ply
sta (ZPCtxPtr),y
* clc
.9 rts
*--------------------------------------
CTX.PutC ldx ZPCtxPtr
phx
ldx ZPCtxPtr+1
phx
ldx ZPObjPtr
phx
ldx ZPObjPtr+1
phx
>SYSCALL PutChar
plx
stx ZPObjPtr+1
plx
stx ZPObjPtr
plx
stx ZPCtxPtr+1
plx
stx ZPCtxPtr
rts
*--------------------------------------
CTX.fputs dec pStack
>PUSHYA
ldy #S.PS.hStdOut
lda (pPS),y
ldy #2
sta (pStack),y
>SYSCALL fputs
rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.ctx
LOAD usr/src/lib/libtui.s
ASM