A2osX/BIN/EDIT.S.BUF.txt

532 lines
8.5 KiB
Plaintext
Raw Normal View History

2016-01-04 07:25:43 +00:00
PR#3
PREFIX /A2OSX.BUILD
2016-01-04 07:25:43 +00:00
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
2016-02-25 17:02:57 +00:00
BUF.InsertClipboard
ldy #hClipBoard
lda (pData),y
beq .8
2016-01-04 07:25:43 +00:00
>SYSCALL GetMemPtr.A
2016-02-25 17:02:57 +00:00
>STYA ClipboardPtr
2016-01-04 07:25:43 +00:00
2016-02-25 17:02:57 +00:00
jsr BUF.ComputeCOffset
2016-01-29 17:05:08 +00:00
ldy #FileLen
lda (pData),y
sec
ldy #ClipboardLen
adc (pData),y
pha
ldy #FileLen+1
lda (pData),y
ldy #ClipboardLen+1
adc (pData),y
ply
jsr BUF.GetNewYA
bcs .9
>LDYA BUF.COffset
>STYA TmpCount
jsr BUF.CopyCount
ldy #ClipboardLen
2016-02-25 17:02:57 +00:00
lda (pData),y
sta TmpCount
2016-01-29 17:05:08 +00:00
iny
2016-02-25 17:02:57 +00:00
lda (pData),y
sta TmpCount+1
jsr BUF.CopyClipboard
2016-01-29 17:05:08 +00:00
jsr BUF.CopyTail
2016-02-25 17:02:57 +00:00
.4 ldy #ClipboardLen+1
2016-01-29 17:05:08 +00:00
lda (pData),y
2016-02-25 17:02:57 +00:00
tax
dey
2016-01-29 17:05:08 +00:00
lda (pData),y
2016-02-25 17:02:57 +00:00
clc
ldy #FileLen
adc (pData),y
sta (pData),y
iny
txa
adc (pData),y
2016-01-29 17:05:08 +00:00
sta (pData),y
2016-02-25 17:02:57 +00:00
2016-01-29 17:05:08 +00:00
.8 clc
.9 rts
*--------------------------------------
BUF.InsertA sta TmpByte
2016-01-04 07:25:43 +00:00
jsr BUF.ComputeCOffset
cpy #255
bne .10
clc
rts
.10 ldy #FileLen
lda (pData),y
2016-01-29 17:05:08 +00:00
sec
adc #1
2016-01-04 07:25:43 +00:00
pha
iny
lda (pData),y
adc #0
ply
jsr BUF.GetNewYA
bcs .9
>LDYA BUF.COffset
>STYA TmpCount
2016-01-28 17:03:51 +00:00
.1 jsr BUF.CopyCount
2016-01-04 07:25:43 +00:00
.2 lda TmpByte
2016-02-25 17:02:57 +00:00
sta (BufPtr)
2016-01-04 07:25:43 +00:00
inc BufPtr
bne .3
inc BufPtr+1
2016-01-28 17:03:51 +00:00
.3 jsr BUF.CopyTail
2016-01-04 07:25:43 +00:00
.4 ldy #FileLen
lda (pData),y
inc
sta (pData),y
2016-01-09 22:33:47 +00:00
bne .8
2016-01-04 07:25:43 +00:00
iny
lda (pData),y
inc
sta (pData),y
2016-01-09 22:33:47 +00:00
.8 clc
.9 rts
*--------------------------------------
2016-02-25 17:02:57 +00:00
BUF.DelSel jsr BUF.GetSelLen
bcs .8
>STYA SelLen
.10 jsr BUF.ComputeCOffset
ldy #SelStart
lda (pData),y
sta TmpCount
sec
sbc BUF.COffset
iny
lda (pData),y
sta TmpCount+1
sbc BUF.COffset+1
bcs .11
ldy #FileY
lda (pData),y
sec
sbc #1
sta (pData),y
iny
lda (pData),y
sbc #0
sta (pData),y
ldy #FileX
lda #0
sta (pData),y
bra .10
.11 ldy #FileLen
lda (pData),y
sec
sbc SelLen
pha
iny
lda (pData),y
sbc SelLen+1
ply
iny
bne .1
inc
.1 jsr BUF.GetNewYA
bcs .9
jsr BUF.CopyCount
lda BufPtrBackup
clc
adc SelLen
sta BufPtrBackup
lda BufPtrBackup+1
adc SelLen+1
sta BufPtrBackup+1
jsr BUF.CopyTail
ldy #FileLen
lda (pData),y
sec
sbc SelLen
sta (pData),y
ldy #FileLen+1
lda (pData),y
sbc SelLen+1
sta (pData),y
jsr BUF.ResetSel
.8 clc
.9 rts
*--------------------------------------
2016-01-09 22:33:47 +00:00
BUF.Del ldy #FileLen
lda (pData),y
iny
ora (pData),y
bne .10
2016-01-28 17:03:51 +00:00
clc exit with A=0
2016-01-09 22:33:47 +00:00
rts
2016-01-28 17:03:51 +00:00
2016-01-22 16:29:11 +00:00
.10 jsr BUF.ComputeCOffset
lda BUF.COffset
clc
2016-01-28 17:03:51 +00:00
ldy #FileLen
2016-01-22 16:29:11 +00:00
sbc (pData),y
2016-01-28 17:03:51 +00:00
lda BUF.COffset+1
2016-01-22 16:29:11 +00:00
iny
sbc (pData),y
2016-01-28 17:03:51 +00:00
bcc .11
lda #0 exit with A=0
clc
2016-01-22 16:29:11 +00:00
rts
2016-01-28 17:03:51 +00:00
2016-01-22 16:29:11 +00:00
.11 lda (pData),y
2016-01-09 22:33:47 +00:00
pha
dey
lda (pData),y
2016-01-22 16:29:11 +00:00
tay
pla
2016-01-09 22:33:47 +00:00
jsr BUF.GetNewYA
2016-01-28 17:03:51 +00:00
bcs .9
2016-01-09 22:33:47 +00:00
>LDYA BUF.COffset
>STYA TmpCount
2016-01-28 17:03:51 +00:00
jsr BUF.CopyCount
2016-01-09 22:33:47 +00:00
2016-02-25 17:02:57 +00:00
lda (BufPtrBackup)
2016-01-28 17:03:51 +00:00
tax Save deleted char for later
2016-01-22 16:29:11 +00:00
inc BufPtrBackup
2016-01-09 22:33:47 +00:00
bne .3
inc BufPtrBackup+1
2016-01-28 17:03:51 +00:00
.3 jsr BUF.CopyTail
2016-01-09 22:33:47 +00:00
2016-01-28 17:03:51 +00:00
ldy #FileLen
2016-01-09 22:33:47 +00:00
lda (pData),y
sec
sbc #1
sta (pData),y
iny
lda (pData),y
sbc #0
sta (pData),y
2016-02-25 17:02:57 +00:00
jsr BUF.ResetSel
2016-01-28 17:03:51 +00:00
txa Get back deleted char
2016-02-25 17:02:57 +00:00
2016-01-21 07:05:23 +00:00
clc
2016-01-04 07:25:43 +00:00
.9 rts
*--------------------------------------
2016-01-29 17:05:08 +00:00
BUF.SelToClipboard
2016-02-25 17:02:57 +00:00
jsr BUF.GetSelLen
bcs .8
>STYA TmpCount
2016-01-29 17:05:08 +00:00
ldy #hClipBoard
lda (pData),y
beq .1
>SYSCALL FreeMem.A
2016-01-29 17:05:08 +00:00
.1 >LDYA TmpCount
>SYSCALL GetMem.YA
2016-01-29 17:05:08 +00:00
bcs .9
>STYA ClipboardPtr
txa
ldy #hClipBoard
sta (pData),y
ldy #ClipBoardLen
lda TmpCount
sta (pData),y
iny
lda TmpCount+1
sta (pData),y
ldy #hBuffer
lda (pData),y
>SYSCALL GetMemPtr.A
2016-01-29 17:05:08 +00:00
>STYA BufPtr
2016-02-25 17:02:57 +00:00
lda BufPtr
clc
ldy #SelStart
adc (pData),y
sta BufPtr
lda BufPtr+1
iny
adc (pData),y
sta BufPtr+1
ldy #0
2016-01-29 17:05:08 +00:00
.2 jsr DecTmpCount
beq .8
lda (BufPtr),y
sta (ClipboardPtr),y
iny
bne .2
inc BufPtr+1
inc ClipboardPtr+1
bra .2
2016-02-25 17:02:57 +00:00
jsr BUF.ResetSel
2016-01-29 17:05:08 +00:00
.8 clc
.9 rts
*--------------------------------------
2016-02-25 17:02:57 +00:00
BUF.CopyClipboard
jsr DecTmpCount
beq .9
lda (ClipboardPtr)
sta (BufPtr)
inc ClipboardPtr
bne .1
inc ClipboardPtr+1
.1 inc BufPtr
bne BUF.CopyClipboard
inc BufPtr+1
bra BUF.CopyClipboard
.9 rts
*--------------------------------------
2016-01-28 17:03:51 +00:00
BUF.CopyCount jsr DecTmpCount
beq .9
2016-02-25 17:02:57 +00:00
lda (BufPtrBackup)
sta (BufPtr)
inc BufPtrBackup
bne .1
2016-01-28 17:03:51 +00:00
inc BufPtrBackup+1
2016-02-25 17:02:57 +00:00
.1 inc BufPtr
bne BUF.CopyCount
2016-01-28 17:03:51 +00:00
inc BufPtr+1
bra BUF.CopyCount
.9 rts
*--------------------------------------
2016-02-25 17:02:57 +00:00
BUF.CopyTail lda (BufPtrBackup)
2016-01-28 17:03:51 +00:00
beq .9
2016-02-25 17:02:57 +00:00
sta (BufPtr)
inc BufPtrBackup
bne .1
2016-01-28 17:03:51 +00:00
inc BufPtrBackup+1
2016-02-25 17:02:57 +00:00
.1 inc BufPtr
bne BUF.CopyTail
2016-01-28 17:03:51 +00:00
inc BufPtr+1
bra BUF.CopyTail
.9 rts
*--------------------------------------
2016-01-04 07:25:43 +00:00
* Out : Y = Line Length
*--------------------------------------
BUF.ComputeCOffset
jsr BUF.GetLine
2016-01-04 07:25:43 +00:00
bcs .9
phy save line length
ldy #FileX
lda (pData),y
clc
adc BUF.LOffset
sta BUF.COffset
lda #0
adc BUF.LOffset+1
sta BUF.COffset+1
ply
clc
.9 rts
*--------------------------------------
BUF.GetLine ldy #FileY+1
lda (pData),y
tax
dey
lda (pData),y
2016-01-04 07:25:43 +00:00
BUF.GetLineAX >STAX BUF.TmpLine1
stz BUF.LOffset
stz BUF.LOffset+1
ldy #hBuffer
lda (pData),y
>SYSCALL GetMemPtr.A
2016-01-04 07:25:43 +00:00
>STYA BufPtr
stz BUF.TmpLine2
stz BUF.TmpLine2+1
.1 ldy #0
.2 lda (BufPtr),y
beq .7
cmp #13
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
2016-01-28 17:03:51 +00:00
bne .9
2016-01-04 07:25:43 +00:00
lda BUF.TmpLine1+1
cmp BUF.TmpLine2+1
2016-01-28 17:03:51 +00:00
bne .9
2016-01-04 07:25:43 +00:00
2016-01-28 17:03:51 +00:00
.8 clc Y = Line length
2016-01-04 07:25:43 +00:00
rts
2016-01-28 17:03:51 +00:00
.9 sec
rts
*--------------------------------------
BUF.GetCharAtY tya
clc
adc BUF.LOffset
sta BUF.COffset
lda #0
adc BUF.LOffset+1
sta BUF.COffset+1
lda (BufPtr),y
clc
2016-01-04 07:25:43 +00:00
rts
*--------------------------------------
BUF.GetNewYA >STYA TmpLen
ldy #hBufferBackup
lda (pData),y
beq .1
>SYSCALL FreeMem.A
2016-01-22 16:29:11 +00:00
.1 ldy #hBuffer
lda (pData),y
2016-01-04 07:25:43 +00:00
ldy #hBufferBackup
sta (pData),y
>SYSCALL GetMemPtr.A
2016-01-22 16:29:11 +00:00
>STYA BufPtrBackup
2016-01-04 07:25:43 +00:00
>LDYA TmpLen
>SYSCALL GetMem0.YA
2016-01-04 07:25:43 +00:00
bcs .9
2016-01-22 16:29:11 +00:00
>STYA BufPtr
2016-01-04 07:25:43 +00:00
txa
ldy #hBuffer
sta (pData),y
2016-01-22 16:29:11 +00:00
.9 rts
2016-01-04 07:25:43 +00:00
*--------------------------------------
2016-02-25 17:02:57 +00:00
BUF.ResetSel lda #0
ldy #SelStart
sta (pData),y
iny
sta (pData),y
ldy #SelEnd
sta (pData),y
iny
sta (pData),y
rts
*--------------------------------------
BUF.CheckSelected
sec
lda BUF.COffset
ldy #SelStart
sbc (pData),y
lda BUF.COffset+1
iny
sbc (pData),y
bcc .9
lda BUF.COffset
ldy #SelEnd
sbc (pData),y
lda BUF.COffset+1
iny
sbc (pData),y
rts CC if in selection
.9 sec
rts
*--------------------------------------
* Out : CC if ok, YA=SelLen
*--------------------------------------
BUF.GetSelLen ldy #SelEnd
lda (pData),y
sec
ldy #SelStart
sbc (pData),y
tax
ldy #SelEnd+1
lda (pData),y
sec
ldy #SelStart+1
sbc (pData),y
bcc .9
phx
ply
bne .8
tax
beq .9
.8 clc
rts
.9 sec
rts
*--------------------------------------
2016-01-04 07:25:43 +00:00
MAN
SAVE /A2OSX.SRC/BIN/EDIT.S.BUF
LOAD /A2OSX.SRC/BIN/EDIT.S
2016-01-04 07:25:43 +00:00
ASM