mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-23 07:35:19 +00:00
548 lines
7.9 KiB
Plaintext
548 lines
7.9 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
BUF.InsertClipboard
|
||
>LDA.G hClipBoard
|
||
beq .8
|
||
|
||
>SYSCALL GetMemPtr
|
||
>STYA ClipboardPtr
|
||
jsr BUF.ComputeCOffset
|
||
|
||
lda BufLen
|
||
sec
|
||
ldy #ClipboardLen
|
||
adc (pData),y
|
||
pha
|
||
lda BufLen+1
|
||
iny
|
||
adc (pData),y
|
||
ply
|
||
jsr BUF.GetNewYA
|
||
bcs .9
|
||
|
||
>LDYA BUF.COffset
|
||
jsr BUF.Start2YA
|
||
|
||
jsr BUF.CopyClipboard
|
||
jsr BUF.CopyTail
|
||
|
||
>LDA.G ClipboardLen
|
||
clc
|
||
adc BufLen
|
||
sta BufLen
|
||
|
||
iny
|
||
lda (pData),y
|
||
adc BufLen+1
|
||
sta BufLen+1
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.InsertTAB jsr BUF.ComputeCOffset
|
||
cpy #256-TABLEN
|
||
beq .8
|
||
|
||
lda BufLen
|
||
sec
|
||
adc #TABLEN
|
||
tay
|
||
lda BufLen+1
|
||
adc #0
|
||
|
||
jsr BUF.GetNewYA
|
||
bcs .9
|
||
|
||
>LDYA BUF.COffset
|
||
jsr BUF.Start2YA
|
||
|
||
ldy #TABLEN
|
||
lda #C.SPACE
|
||
|
||
.1 sta (BufPtr)
|
||
inc BufPtr
|
||
bne .2
|
||
inc BufPtr+1
|
||
|
||
.2 dey
|
||
bne .1
|
||
|
||
.3 jsr BUF.CopyTail
|
||
|
||
.4 lda BufLen
|
||
clc
|
||
adc #TABLEN
|
||
sta BufLen
|
||
bcc .8
|
||
|
||
inc BufLen+1
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.InsertA sta TmpByte
|
||
jsr BUF.ComputeCOffset
|
||
cpy #255
|
||
beq .8
|
||
|
||
lda BufLen
|
||
clc
|
||
adc #2
|
||
tay
|
||
lda BufLen+1
|
||
adc #0
|
||
|
||
jsr BUF.GetNewYA
|
||
bcs .9
|
||
|
||
>LDYA BUF.COffset
|
||
jsr BUF.Start2YA
|
||
|
||
.2 lda TmpByte
|
||
sta (BufPtr)
|
||
inc BufPtr
|
||
bne .3
|
||
inc BufPtr+1
|
||
|
||
.3 jsr BUF.CopyTail
|
||
|
||
.4 inc BufLen
|
||
bne .8
|
||
inc BufLen+1
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.DelSel jsr BUF.GetSelLen
|
||
bcs .8
|
||
|
||
lda BufLen
|
||
sec
|
||
sbc SelLen
|
||
tay
|
||
lda BufLen+1
|
||
sbc SelLen+1
|
||
iny
|
||
bne .1
|
||
inc
|
||
|
||
.1 jsr BUF.GetNewYA
|
||
bcs .9
|
||
|
||
>LDYA.G SelStart
|
||
jsr BUF.Start2YA
|
||
lda BufPtrBackup
|
||
clc
|
||
adc SelLen
|
||
sta BufPtrBackup
|
||
lda BufPtrBackup+1
|
||
adc SelLen+1
|
||
sta BufPtrBackup+1
|
||
jsr BUF.CopyTail
|
||
|
||
lda BufLen
|
||
sec
|
||
sbc SelLen
|
||
sta BufLen
|
||
lda BufLen+1
|
||
sbc SelLen+1
|
||
sta BufLen+1
|
||
|
||
jsr BUF.ResetSel
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* Erase char at CurXY
|
||
*--------------------------------------
|
||
BUF.DelCharAtCursor
|
||
>LDYA BufLen
|
||
jsr BUF.GetNewYA BufferLen-1
|
||
bcs .9
|
||
|
||
>LDYA BUF.COffset
|
||
jsr BUF.Start2YA
|
||
|
||
.3 lda (BufPtrBackup)
|
||
pha Save deleted char for later
|
||
|
||
inc BufPtrBackup
|
||
bne .4
|
||
inc BufPtrBackup+1
|
||
|
||
.4 jsr BUF.CopyTail
|
||
|
||
lda BufLen
|
||
bne .5
|
||
dec BufLen+1
|
||
.5 dec BufLen
|
||
|
||
jsr BUF.ResetSel
|
||
pla Get back deleted char
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.SelToClipboard
|
||
jsr BUF.GetSelLen
|
||
bcs .8
|
||
|
||
>LDA.G hClipBoard
|
||
beq .1
|
||
|
||
>SYSCALL FreeMem
|
||
>STZ.G hClipBoard
|
||
|
||
.1 >LDYA SelLen
|
||
>SYSCALL GetMem
|
||
bcs .9
|
||
|
||
>STYA ClipboardPtr
|
||
txa
|
||
>STA.G hClipBoard
|
||
|
||
>LDA.G hBuffer
|
||
>SYSCALL GetMemPtr
|
||
|
||
pha
|
||
tya
|
||
|
||
>ADC.G SelStart
|
||
sta BufPtr
|
||
|
||
pla
|
||
iny SelStart+1
|
||
adc (pData),y
|
||
sta BufPtr+1
|
||
|
||
lda SelLen
|
||
>STA.G ClipBoardLen
|
||
|
||
eor #$ff
|
||
tax
|
||
iny
|
||
lda SelLen+1
|
||
sta (pData),y
|
||
eor #$ff
|
||
pha
|
||
|
||
ldy #0
|
||
|
||
.2 inx
|
||
bne .3
|
||
|
||
pla
|
||
inc
|
||
beq .8
|
||
|
||
pha
|
||
|
||
.3 lda (BufPtr),y
|
||
sta (ClipboardPtr),y
|
||
iny
|
||
bne .2
|
||
|
||
inc BufPtr+1
|
||
inc ClipboardPtr+1
|
||
bra .2
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.CopyClipboard
|
||
>LDA.G ClipboardLen
|
||
eor #$ff
|
||
tax
|
||
iny
|
||
lda (pData),y
|
||
eor #$ff
|
||
pha
|
||
|
||
ldy #0
|
||
|
||
.1 inx
|
||
bne .2
|
||
|
||
pla
|
||
inc
|
||
beq .3
|
||
|
||
pha
|
||
|
||
.2 lda (ClipboardPtr),y
|
||
sta (BufPtr),y
|
||
iny
|
||
bne .1
|
||
|
||
inc ClipboardPtr+1
|
||
inc BufPtr+1
|
||
bra .1
|
||
|
||
.3 tya
|
||
clc
|
||
adc ClipboardPtr
|
||
sta ClipboardPtr
|
||
bcc BUF.CopyAddY
|
||
inc ClipboardPtr+1
|
||
|
||
BUF.CopyAddY tya
|
||
clc
|
||
adc BufPtr
|
||
sta BufPtr
|
||
bcc .2
|
||
inc BufPtr+1
|
||
.2 rts
|
||
*--------------------------------------
|
||
BUF.Start2YA eor #$ff
|
||
pha
|
||
tya
|
||
eor #$ff
|
||
tax
|
||
|
||
ldy #0
|
||
|
||
.1 inx
|
||
bne .2
|
||
pla
|
||
inc
|
||
beq .3
|
||
|
||
pha
|
||
|
||
.2 lda (BufPtrBackup),y
|
||
sta (BufPtr),y
|
||
iny
|
||
bne .1
|
||
|
||
inc BufPtrBackup+1
|
||
inc BufPtr+1
|
||
bra .1
|
||
|
||
.3 tya
|
||
clc
|
||
adc BufPtrBackup
|
||
sta BufPtrBackup
|
||
bcc BUF.CopyAddY
|
||
inc BufPtrBackup+1
|
||
bra BUF.CopyAddY
|
||
*--------------------------------------
|
||
BUF.CopyTail ldy #0
|
||
|
||
.1 lda (BufPtrBackup),y
|
||
sta (BufPtr),y
|
||
beq .8
|
||
|
||
iny
|
||
bne .1
|
||
|
||
inc BufPtrBackup+1
|
||
inc BufPtr+1
|
||
bra .1
|
||
|
||
.8 rts
|
||
*--------------------------------------
|
||
* Out : Y = Line Length
|
||
*--------------------------------------
|
||
BUF.ComputeCOffset
|
||
jsr BUF.GetLine
|
||
bcs .9
|
||
|
||
phy save line length
|
||
|
||
>LDA.G FileX
|
||
clc
|
||
adc BUF.LOffset
|
||
sta BUF.COffset
|
||
|
||
lda #0
|
||
adc BUF.LOffset+1
|
||
sta BUF.COffset+1
|
||
|
||
ply
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.GetNextLine sec
|
||
.HS 90 BCC
|
||
|
||
BUF.GetLine clc
|
||
>LDA.G FileY
|
||
adc #0
|
||
pha
|
||
iny
|
||
lda (pData),y
|
||
adc #0
|
||
tax
|
||
pla
|
||
|
||
BUF.GetLineAX sta BUF.TmpLine1
|
||
stx BUF.TmpLine1+1
|
||
|
||
stz BUF.LOffset
|
||
stz BUF.LOffset+1
|
||
|
||
>LDA.G hBuffer
|
||
>SYSCALL GetMemPtr
|
||
>STYA BufPtr
|
||
|
||
stz BUF.TmpLine2
|
||
stz BUF.TmpLine2+1
|
||
|
||
.1 ldy #0
|
||
|
||
.2 lda (BufPtr),y
|
||
beq .7
|
||
|
||
cmp #C.CR
|
||
beq .3
|
||
iny
|
||
bne .2
|
||
|
||
.3 lda BUF.TmpLine1
|
||
cmp BUF.TmpLine2
|
||
bne .4
|
||
|
||
lda BUF.TmpLine1+1
|
||
cmp BUF.TmpLine2+1
|
||
beq .8
|
||
|
||
.4 tya
|
||
sec
|
||
adc BufPtr
|
||
sta BufPtr
|
||
bcc .5
|
||
inc BufPtr+1
|
||
|
||
.5 tya
|
||
sec
|
||
adc BUF.LOffset
|
||
sta BUF.LOffset
|
||
bcc .6
|
||
inc BUF.LOffset+1
|
||
|
||
.6 inc BUF.TmpLine2
|
||
bne .1
|
||
inc BUF.TmpLine2+1
|
||
bra .1
|
||
|
||
.7 lda BUF.TmpLine1
|
||
cmp BUF.TmpLine2
|
||
bne .9
|
||
|
||
lda BUF.TmpLine1+1
|
||
cmp BUF.TmpLine2+1
|
||
bne .9
|
||
|
||
.8 clc Y = Line length
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
BUF.GetNewYA tax In 256 bytes page to avoid fragmentation
|
||
|
||
tya
|
||
beq .10
|
||
inx
|
||
|
||
.10 phx
|
||
|
||
>LDA.G hBufferBackup
|
||
beq .1
|
||
|
||
>SYSCALL FreeMem
|
||
|
||
.1 >LDA.G hBuffer
|
||
>STA.G hBufferBackup
|
||
|
||
>SYSCALL GetMemPtr
|
||
>STYA BufPtrBackup
|
||
|
||
>STZ.G hBuffer
|
||
|
||
pla
|
||
ldy #0
|
||
|
||
>SYSCALL GetMem
|
||
bcs .9
|
||
>STYA BufPtr
|
||
txa
|
||
>STA.G hBuffer
|
||
|
||
>LDA.G bSaved
|
||
beq .8
|
||
|
||
lda #0
|
||
sta (pData),y
|
||
|
||
jsr SCRN.UpdateTopBar
|
||
bcs .9
|
||
.8
|
||
* clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.ResetSel lda #$ff
|
||
ldy #SelStart
|
||
|
||
sta (pData),y
|
||
iny
|
||
sta (pData),y
|
||
|
||
iny #SelEnd
|
||
inc lda #0
|
||
sta (pData),y
|
||
iny
|
||
sta (pData),y
|
||
rts
|
||
*--------------------------------------
|
||
BUF.CheckSelected
|
||
lda BUF.COffset
|
||
ldy #SelStart
|
||
cmp (pData),y
|
||
lda BUF.COffset+1
|
||
iny
|
||
sbc (pData),y
|
||
bcc .9 CC:COffset < SelStart
|
||
|
||
iny #SelEnd
|
||
lda (pData),y
|
||
clc
|
||
sbc BUF.COffset
|
||
iny
|
||
lda (pData),y
|
||
sbc BUF.COffset+1
|
||
* CC:SelEnd < COffset
|
||
.9 lda #0
|
||
ror $80 = selected
|
||
rts
|
||
*--------------------------------------
|
||
BUF.GetSelLen ldy #SelEnd
|
||
lda (pData),y
|
||
sec
|
||
ldy #SelStart
|
||
sbc (pData),y
|
||
|
||
sta SelLen
|
||
tax
|
||
ldy #SelEnd+1
|
||
lda (pData),y
|
||
|
||
ldy #SelStart+1
|
||
sbc (pData),y
|
||
sta SelLen+1
|
||
bcc .9
|
||
bne .8
|
||
txa
|
||
beq .9
|
||
.8 clc
|
||
rts
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/BIN/EDIT.S.BUF
|
||
LOAD USR/SRC/BIN/EDIT.S
|
||
ASM
|