A2osX/BIN/EDIT.S.SCRN.txt
2020-01-23 15:48:22 +01:00

632 lines
10 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
SCRN.Init >LDA.G ScreenH
dec
>PUSHA
>PUSHBI 1
>LDYA L.SEQ.INIT
>SYSCALL printf
bcs .9
jsr SCRN.Home
jsr SCRN.UpdateMainAndStatus
bcs .9
jmp SCRN.UpdateTopBar
.9 rts
*--------------------------------------
SCRN.Home lda #0
ldy #FileX Zero FileXY,ScreenXY & CurXY
.1 sta (pData),y
iny
cpy #CurY+1
bne .1
rts
*--------------------------------------
SCRN.ResetScrollRgn
>LDA.G ScreenH
dec
>PUSHA
>PUSHBI 1
>LDYA L.SEQ.SCROLLRGN
>SYSCALL printf
rts
*--------------------------------------
SCRN.UnSaved >LDA.G bUnSaved
bne .8
dec
sta (pData),y
bra SCRN.UpdateTopBar
.8 clc
rts
*--------------------------------------
SCRN.UpdateTopBar
lda #$ff
>STA.G bUpdateTop
clc
rts
*--------------------------------------
SCRN.UpdateTopBarAsync
>LDA.G bUpdateTop
bpl .8
lda #0
sta (pData),y
jsr SCRN.LineBufInitBar
ldx #SEQ.CURSAVE-SEQS
jsr SCRN.SEQS.ToLineBuf
ldy #1
jsr SCRN.LineBufGotoLineY
bcs .9
>LDA.G ScreenW
tax
lda #C.SPACE
.1 jsr SCRN.ToLineBuf
dex
bne .1
lda #C.CR
jsr SCRN.ToLineBuf
>LDA.G bUnSaved
beq .2
lda #'!'
jsr SCRN.ToLineBuf
.2 >LDA.G FileType
tax
>PUSHW L.MSG.FILETYPES,x
>LDA.G hFileName
>SYSCALL GetMemPtr
>PUSHYA
>PUSHBI 4
>PUSHW L.MSG.TOPBAR
jsr SCRN.LineBufSprintf
bcs .9
ldx #SEQ.CURRESTORE-SEQS
jsr SCRN.SEQS.ToLineBuf
jmp SCRN.LineBufOut
.8 clc
.9 rts
*--------------------------------------
SCRN.UpdateViewPort
stz bRepaint
.1 >LDA.G FileX
>CMP.G ScreenX
bcs .2 out of left border ?
>DEC.G ScreenX yes
sec
ror bRepaint
bra .1
.2 bit bRepaint
bmi .30
.21 >LDA.G ScreenX
clc
>ADC.G ScreenW
dec
>CMP.G FileX
bcs .3 out of right border ?
>INC.G ScreenX
sec
ror bRepaint
bra .21
.3 bit bRepaint
.30 bmi .6
.31 >LDA.G FileY+1
tax
dey
lda (pData),y A,X = FileY
>CMP.G ScreenY
iny
txa
sbc (pData),y
bcs .4 out of top border ?
>DECW.G ScreenY move viewport up one line....
bit bRepaint
bmi .31 skip scroll, will be repainted later
jsr SCRN.scrollDn ...and move content one line down
bcc .31
rts
.4 bit bRepaint
bmi .6
.41 >LDA.G ScreenY+1
tax
dey
lda (pData),y
clc
>ADC.G ViewPortHm1
bcc .5
inx
.5 >CMP.G FileY A,X = screen bottom
txa
iny FileY > screen bottom ?
sbc (pData),y
bcs .6 CS : fileY>= screen bottom
>INCW.G ScreenY move viewport down one line....
bit bRepaint
bmi .41
jsr SCRN.scrollUp ...and move content one line up
bcc .41
.9 rts
.6 >LDA.G FileX
sec
>SBC.G ScreenX
>STA.G CurX
>LDA.G FileY
sec
>SBC.G ScreenY
>STA.G CurY
jsr BUF.ComputeCOffset
jsr SCRN.GotoCurXCurY
bit bRepaint
bmi SCRN.UpdateMain
jmp SCRN.UpdateStatusBar
*--------------------------------------
SCRN.UpdateMainAndStatus
jsr SCRN.UpdateStatusBar
*--------------------------------------
SCRN.UpdateMain >LDA.G ScreenY
sta TmpIndex
iny
lda (pData),y
sta TmpIndex+1
stz TmpByte
>LDA.G ViewPortH
bra SCRN.UpdateMain.1
SCRN.UpdateLast >LDA.G ViewPortHm1
sta TmpByte
clc
>ADC.G ScreenY
sta (pData),y
iny
lda (pData),y
adc #0
sta (pData),y
lda #1
SCRN.UpdateMain.1
sta TmpCount
.1 lda TmpIndex
ldx TmpIndex+1
jsr BUF.GetLineAX Y = line length
bcs .5
lda TmpByte
jsr SCRN.UpdateLineAtALenY
bcs SCRN.UpdateMain.9
.3 inc TmpByte
inc TmpIndex
bne .4
inc TmpIndex+1
.4 dec TmpCount
bne .1
bra .8
.5 ldx #0
ldy TmpByte
jsr SCRN.GotoXY
bcs SCRN.UpdateMain.9
>PUSHBI 0
>LDYA L.SEQ.CEOL
>SYSCALL printf
bcs SCRN.UpdateMain.9
inc TmpByte
dec TmpCount
bne .5
.8 jsr BUF.ComputeCOffset
jmp SCRN.GotoCurXCurY
SCRN.UpdateMain.9
rts
*--------------------------------------
SCRN.UpdateCurrentEOL
jsr SCRN.LineBufInitEdit
bra SCRN.UpdateLineAtBufPtr
*--------------------------------------
SCRN.UpdateCurrentLine
>LDA.G ScreenY+1
tax
dey
lda (pData),y
clc
>ADC.G CurY
bcc .1
inx
.1 jsr BUF.GetLineAX
bcs SCRN.UpdateMain.9
phy
>LDA.G CurY
ply
*--------------------------------------
* A = Target Screen Y position
* BufPtr = Text line start, Y = len
*--------------------------------------
SCRN.UpdateLineAtALenY
sty TmpLen
inc
inc
sta TmpLen+1
jsr SCRN.LineBufInitEdit
ldy TmpLen+1
jsr SCRN.LineBufGotoLineY
>LDA.G ScreenX
cmp TmpLen
bcs SCRN.UpdateLineAtBufPtr.END
tay
clc
adc BUF.LOffset
sta BUF.COffset
lda #0
adc BUF.LOffset+1
sta BUF.COffset+1
tya
* clc
adc BufPtr
sta BufPtr
bcc .2
inc BufPtr+1
.2
SCRN.UpdateLineAtBufPtr
>LDA.G ScreenW
tax
stz bSelected
.2 lda (BufPtr)
beq .8
cmp #C.CR
beq .8
jsr BUF.CheckSelected
eor bSelected
bpl .5
jsr SCRN.ToggleSel
.5 lda (BufPtr)
cmp #'\'
beq .50
cmp #'%'
bne .51
.50 pha
lda #'\'
jsr SCRN.ToLineBuf
pla
.51 jsr SCRN.ToLineBuf
inc BufPtr
bne .6
inc BufPtr+1
.6 inc BUF.COffset
bne .7
inc BUF.COffset+1
.7 dex
bne .2
.8 bit bSelected
bpl SCRN.UpdateLineAtBufPtr.END
jsr SCRN.ToggleSel
SCRN.UpdateLineAtBufPtr.END
ldx #SEQ.CEOL-SEQS
jsr SCRN.SEQS.ToLineBuf
jmp SCRN.LineBufOut
*--------------------------------------
SCRN.ToggleSel ldy #SEQ.NORM-SEQS
lda bSelected
eor #$ff
sta bSelected
bpl .1
ldy #SEQ.INV-SEQS
.1 lda SEQS,y
beq .8
jsr SCRN.ToLineBuf
iny
bra .1
.8
SCRN.ToggleSel.RTS
rts
*--------------------------------------
SCRN.UpdateStatusBar
lda #$ff
>STA.G bUpdateStatus
clc
rts
*--------------------------------------
SCRN.UpdateStatusBarAsync
>LDA.G bUpdateStatus
bpl .8
lda #0
sta (pData),y
jsr SCRN.ResetStatusBar
>LDA.G FileY
tax
iny
lda (pData),y
inx
bne .2
inc
.2 >PUSHA
txa
>PUSHA
>LDA.G FileX
inc
>PUSHA
>PUSHW BUF.COffset
>PUSHW FileLen
>PUSHBI 7
>PUSHW L.MSG.STATUSBAR
jsr SCRN.LineBufSprintf
bcs .9
ldx #SEQ.CURRESTORE-SEQS
jsr SCRN.SEQS.ToLineBuf
jmp SCRN.LineBufOut
.8 clc
.9 rts
*--------------------------------------
SCRN.ResetStatusBar
jsr SCRN.LineBufInitBar
ldx #SEQ.CURSAVE-SEQS
jsr SCRN.SEQS.ToLineBuf
>LDA.G ScreenH
tay
jsr SCRN.LineBufGotoLineY
>LDA.G ScreenW
tax
lda #C.SPACE
.1 jsr SCRN.ToLineBuf
dex
bne .1
lda #C.CR
jmp SCRN.ToLineBuf
*--------------------------------------
SCRN.CursorAdjust
.1 jsr BUF.ComputeCOffset
bcc .8
>DECW.G FileY
>STZ.G FileX
bra .1
.8 rts
*--------------------------------------
SCRN.GotoCurXCurY
ldy #CurX
lda (pData),y
tax
ldy #CurY
lda (pData),y
tay
SCRN.GotoXY txa
inc
>PUSHA
tya
inc
inc
>PUSHA
>PUSHBI 2
>LDYA L.MSG.GOTOXY
>SYSCALL printf
rts
*--------------------------------------
SCRN.scrollUp >PUSHBI 0
>LDYA L.SEQ.SCROLLUP
>SYSCALL printf
bcs .9
>LDA.G ScreenY+1
tax
dey
lda (pData),y
* clc
>ADC.G ViewPortHm1
bcc .1
inx
.1 jsr BUF.GetLineAX
bcs .9
phy
>LDA.G ViewPortHm1
ply
jmp SCRN.UpdateLineAtALenY
.9 rts
*--------------------------------------
SCRN.scrollDn >PUSHBI 0
>LDYA L.SEQ.SCROLLDN
>SYSCALL printf
bcs .9
>LDA.G ScreenY+1
tax
dey
lda (pData),y
jsr BUF.GetLineAX
bcs .9
lda #0
jsr SCRN.UpdateLineAtALenY
.9 rts
*--------------------------------------
SCRN.LineBufInitBar
phx
ldx #SEQ.BAR-SEQS
bra SCRN.LineBufInit
SCRN.LineBufInitDlg
phx
ldx #SEQ.DLG-SEQS
bra SCRN.LineBufInit
SCRN.LineBufInitLBL
phx
ldx #SEQ.DLG.LBL-SEQS
bra SCRN.LineBufInit
SCRN.LineBufInitTB
phx
ldx #SEQ.DLG.TB-SEQS
bra SCRN.LineBufInit
SCRN.LineBufInitBut
phx
ldx #SEQ.DLG.BUT-SEQS
bra SCRN.LineBufInit
SCRN.LineBufInitEdit
phx
ldx #SEQ.EDIT-SEQS
bra SCRN.LineBufInit
SCRN.LineBufInitNorm
phx
ldx #SEQ.NORM-SEQS
bra SCRN.LineBufInit
SCRN.LineBufInitInv
phx
ldx #SEQ.INV-SEQS
SCRN.LineBufInit
>LDYA.G LineBuf
>STYA LineBufPtr
jsr SCRN.SEQS.ToLineBuf
plx
rts
*--------------------------------------
SCRN.SEQS.ToLineBuf
lda SEQS,x
.1 jsr SCRN.ToLineBuf
inx
lda SEQS,x
bne .1
rts
*--------------------------------------
SCRN.LineBufGotoLineY
>PUSHBI 1
tya
>PUSHA
>PUSHBI 2
>PUSHW L.MSG.GOTOXY
*--------------------------------------
SCRN.LineBufSprintf
>LDYA LineBufPtr
>SYSCALL sprintf
bcs .9
tya
clc
adc LineBufPtr
sta LineBufPtr
bcc .9
inc LineBufPtr+1
clc
.9 rts
*--------------------------------------
SCRN.ToLineBuf sta (LineBufPtr)
inc LineBufPtr
bne .8
inc LineBufPtr+1
.8 rts
*--------------------------------------
SCRN.LineBufOut lda #0
sta (LineBufPtr)
>PUSHBI 0
>LDYA.G LineBuf
>SYSCALL printf
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/EDIT.S.SCRN
LOAD USR/SRC/BIN/EDIT.S
ASM