A2osX/BIN/EDIT.S.SCRN.txt
2019-12-16 14:14:11 +01:00

582 lines
9.2 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.UpdateTopBar
bcs .9
jmp SCRN.UpdateMain
.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
jsr SCRN.LineBufInitBar
>PUSHBI 1
>PUSHBI 1
>PUSHBI 2
>PUSHW L.MSG.GOTOXY
jsr SCRN.LineBufSprintf
bcs .9
>LDA.G ScreenW
tax
lda #C.SPACE
.1 jsr SCRN.ToLineBuf
dex
bne .1
lda #C.CR
jsr SCRN.ToLineBuf
>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
>LDA.G bUnSaved
beq .8
lda #'*'
jsr SCRN.ToLineBuf
.8 jmp SCRN.LineBufOut
.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
bit bRepaint
bpl .7
jsr SCRN.UpdateMain
bcs .9
.7 jsr BUF.ComputeCOffset
jmp SCRN.GotoCurXCurY
*--------------------------------------
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.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
stz bSelected
sty TmpLen
ldx #0
tay
jsr SCRN.GotoXY
bcs SCRN.UpdateMain.9
jsr SCRN.LineBufInitEdit
ldy #$ff
>LDA.G ScreenW
tax
>LDA.G ScreenX
cmp TmpLen
bcs .8
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 .1
inc BufPtr+1
.1 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 .1
.8 bit bSelected
bpl .80
jsr SCRN.ToggleSel
.80 jmp SCRN.LineBufOut
.9 rts
*--------------------------------------
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
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
.9 rts
*--------------------------------------
SCRN.ResetStatusBar
jsr SCRN.LineBufInitBar
>PUSHBI 1
>PUSHB.G ScreenH
>PUSHBI 2
>PUSHW L.MSG.GOTOXY
jsr SCRN.LineBufSprintf
>LDA.G ScreenW
tax
lda #C.SPACE
.1 jsr SCRN.ToLineBuf
dex
bne .1
lda #C.CR
jsr SCRN.ToLineBuf
jmp SCRN.LineBufOut
*--------------------------------------
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
>LDA.G ViewPortHm1
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
jmp 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 LineBufBase
>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.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 LineBufBase
>SYSCALL printf
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/EDIT.S.SCRN
LOAD USR/SRC/BIN/EDIT.S
ASM