A2osX/BIN/EDIT.S.SCRN.txt
2019-11-06 17:25:00 +01:00

541 lines
8.3 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
jsr SCRN.UpdateViewPort
bcs .9
jsr SCRN.UpdateMain
.9 rts
*--------------------------------------
SCRN.Home lda #0
ldy #FileX
.1 sta (pData),y
iny
cpy #CurX
bne .1
inc
sta (pData),y CurX
iny
sta (pData),y CurY
rts
*--------------------------------------
SCRN.UpdateTopBar
jsr SCRN.LineBufInit
>PUSHBI 1
>PUSHBI 1
>PUSHBI 2
>LDYA L.MSG.GOTOXY
>SYSCALL printf
bcs .9
>LDA.G hFileName
beq .1
>SYSCALL GetMemPtr
bra .2
.1 >LDYA L.MSG.NEWFILE
.2 >PUSHYA
>PUSHBI 2
>PUSHW L.MSG.TOPBAR
>LDYA ZPPTR1
>SYSCALL sprintf
bcs .9
>LDA.G bSaved
bne .8
ldy #255
.3 iny
lda (ZPPTR1),y
bne .3
lda #'!'
sta (ZPPTR1),y
iny
lda #0
sta (ZPPTR1),y
.8 jmp SCRN.LineBufOutBar
.9 rts
*--------------------------------------
SCRN.UpdateMain >LDA.G ScreenY
sta TmpIndex
iny
lda (pData),y
sta TmpIndex+1
lda #0
sta TmpByte
>LDA.G ViewPortH
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
jmp SCRN.GotoCurXCurY
.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
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.LineBufInit
ldy #$ff
.10 iny
lda SEQ.EDIT,y
beq .11
jsr SCRN.ToLineBuf
bra .10
.11 ldy #0
>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 lda #0
jsr SCRN.ToLineBuf
>PUSHBI 0
>LDYA LineBufPtr
>SYSCALL printf
.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
jsr SCRN.LineBufInit
>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 ZPPTR1
>SYSCALL sprintf
SCRN.LineBufOutBar
>LDA.G ScreenW
tax
ldy #0
.1 lda (ZPPTR1),y
beq .2
iny
dex
bne .1
bra .4
.2 lda #C.SPACE
.3 sta (ZPPTR1),y
iny
dex
bne .3
lda #0
sta (ZPPTR1),y
.4 >PUSHW LineBufPtr
>PUSHBI 2
>LDYA L.SEQ.BAR
>SYSCALL printf
bcs .9
jmp SCRN.GotoCurXCurY
.9 rts
*--------------------------------------
SCRN.CursorAdjust
.1 jsr BUF.ComputeCOffset
bcc .8
>DECW.G FileY
>STZ.G FileX
bra .1
.8 rts
*--------------------------------------
SCRN.LineBufInit
>LDYA LineBufPtr
>STYA ZPPTR1
rts
*--------------------------------------
SCRN.ToLineBuf sta (ZPPTR1)
inc ZPPTR1
bne .8
inc ZPPTR1+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 >LDA.G ScreenX
>ADC.G ScreenW
dec
>CMP.G FileX
bcs .3 out of right border ?
>INC.G ScreenX
sec
ror bRepaint
bra .2
.3 ldy #FileY+1
lda (pData),y
tax
dey
lda (pData),y A,X = FileY
ldy #ScreenY
cmp (pData),y
iny
txa
sbc (pData),y
bcs .4 out of top border ?
>DECW.G ScreenY move viewport up one line....
bit bRepaint
bmi .3 skip scroll, will be repainted later
jsr SCRN.scrollDn ...and move content one line down
bcc .3
rts
.4 ldy #ScreenY+1
lda (pData),y
tax
dey
lda (pData),y
>ADC.G ViewPortHm1
bcc .5
inx
.5 ldy #FileY A,X = screen bottom
clc
sbc (pData),y
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 .4
jsr SCRN.scrollUp ...and move content one line up
bcc .4
.9 rts
.6 >LDA.G FileX
>SBC.G ScreenX
>STA.G CurX
>LDA.G FileY
>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 >LDA.G CurX
inc
>PUSHA
>LDA.G CurY
inc
inc
>PUSHA
>PUSHBI 2
>LDYA L.SEQ.SCROLLUP
>SYSCALL printf
bcs .9
ldy #ScreenY+1
lda (pData),y
tax
dey
lda (pData),y
>ADC.G ViewPortHm1
bcc .1
inx
.1 jsr BUF.GetLineAX
bcs .9
>LDA.G ViewPortHm1
jmp SCRN.UpdateLineAtALenY
.9 rts
*--------------------------------------
SCRN.scrollDn >LDA.G CurX
inc
>PUSHA
>LDA.G CurY
inc
inc
>PUSHA
>PUSHBI 2
>LDYA L.SEQ.SCROLLDN
>SYSCALL printf
bcs .9
ldy #ScreenY+1
lda (pData),y
tax
dey
lda (pData),y
jsr BUF.GetLineAX
bcs .9
lda #0
jmp SCRN.UpdateLineAtALenY
.9 rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/EDIT.S.SCRN
LOAD USR/SRC/BIN/EDIT.S
ASM