A2osX/BIN/EDIT.S.SCRN.txt
2019-11-20 17:37:09 +01:00

576 lines
9.0 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.UpdateTopBar
>PUSHBI 1
>PUSHBI 1
>PUSHBI 2
>LDYA L.MSG.GOTOXY
>SYSCALL printf
bcs .9
>LDYA.G LineBufBase
>STYA LineBufPtr
>LDA.G FileType
tax
>PUSHW L.MSG.FILETYPES,x
>LDA.G hFileName
beq .1
>SYSCALL GetMemPtr
bra .2
.1 >LDYA L.MSG.NEWFILE
.2 >PUSHYA
>PUSHBI 4
>PUSHW L.MSG.TOPBAR
>LDYA LineBufPtr
>SYSCALL sprintf
bcs .9
>LDA.G bSaved
bne .8
ldy #255
.3 iny
lda (LineBufPtr),y
bne .3
lda #'!'
sta (LineBufPtr),y
iny
lda #0
sta (LineBufPtr),y
.8 jmp SCRN.LineBufOutBar
.9 rts
*--------------------------------------
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 SCRN.UpdateStatusBar
bcs SCRN.UpdateMain.9
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.LineBufInitNorm
ldy #$ff
.10 iny
lda SEQ.EDIT,y
beq .11
jsr SCRN.ToLineBuf
bra .10
.11 >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 #0
lda bSelected
eor #$ff
sta bSelected
bpl .1
ldy #6
.1 lda SEQ.NORM,y
beq .8
jsr SCRN.ToLineBuf
iny
bra .1
.8
SCRN.ToggleSel.RTS
rts
*--------------------------------------
SCRN.UpdateStatusBar
>LDYA.G LineBufBase
>STYA LineBufPtr
>PUSHBI 1
>PUSHB.G ScreenH
>PUSHBI 2
>LDYA L.MSG.GOTOXY
>SYSCALL printf
bcs SCRN.ToggleSel.RTS
>LDA.G PromptMode
bne .2
>LDA.G FileY
tax
iny
lda (pData),y
inx
bne .1
inc
.1 >PUSHA
txa
>PUSHA
>LDA.G FileX
inc
>PUSHA
>PUSHW BUF.COffset
>PUSHW FileLen
>PUSHBI 7
bra SCRN.UpdateStatusBarOut
*--------------------------------------
.2 eor #PromptModeHelp
beq .3
>PUSHW pData
lda #2
.3 >PUSHA
bra SCRN.UpdateStatusBarOut
*--------------------------------------
SCRN.UpdateStatusBarErrA
>PUSHA
>PUSHBI 1
ldx #10
bra SCRN.UpdateStatusBarOutErr
SCRN.UpdateStatusBarOut
ldy #PromptMode
lda (pData),y
tax
SCRN.UpdateStatusBarOutErr
>PUSHW L.MSG.STATUSBAR,x
>LDYA LineBufPtr
>SYSCALL sprintf
SCRN.LineBufOutBar
>LDA.G ScreenW
tax
ldy #0
.1 lda (LineBufPtr),y
beq .2
iny
dex
bne .1
bra .4
.2 lda #C.SPACE
.3 sta (LineBufPtr),y
iny
dex
bne .3
lda #0
sta (LineBufPtr),y
.4 >PUSHW.G LineBufBase
>PUSHBI 2
>LDYA L.SEQ.BAR
>SYSCALL printf
bcs .9
.9 rts
*--------------------------------------
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.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
jsr SCRN.UpdateStatusBar
bcs .9
jmp SCRN.GotoCurXCurY
*--------------------------------------
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.LineBufInitNorm
clc
.HS B0 BCS
SCRN.LineBufInitInv
sec
>LDYA.G LineBufBase
>STYA LineBufPtr
ldy #0
bcc .1
ldy #SEQ.INV-SEQ.NORM
.1 lda SEQ.NORM,y
.2 jsr SCRN.ToLineBuf
iny
lda SEQ.NORM,y
bne .2
rts
*--------------------------------------
SCRN.ToLineBuf sta (LineBufPtr)
inc LineBufPtr
bne .8
inc LineBufPtr+1
.8 rts
*--------------------------------------
SCRN.LineBufOut lda #0
jsr SCRN.ToLineBuf
>PUSHBI 0
>LDYA.G LineBufBase
>SYSCALL printf
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/EDIT.S.SCRN
LOAD USR/SRC/BIN/EDIT.S
ASM