A2osX/BIN/EDIT.S.BUF.txt

599 lines
8.3 KiB
Plaintext
Raw Normal View History

2016-01-04 07:25:43 +00:00
NEW
2019-05-27 06:01:59 +00:00
AUTO 3,1
2016-01-04 07:25:43 +00:00
.LIST OFF
*--------------------------------------
2019-11-15 16:15:43 +00:00
BUF.InsertA sta TmpByte
2019-11-17 14:39:55 +00:00
2019-11-15 16:15:43 +00:00
cpy #255
beq .8
2019-11-17 14:39:55 +00:00
>LDYAI 1
jsr BUF.BufPtrSetup
bcs .9
2019-11-15 16:15:43 +00:00
inx
bne .1
inc
2019-11-17 14:39:55 +00:00
2019-11-15 16:15:43 +00:00
.1 stx BufPtrDst
sta BufPtrDst+1
jsr BUF.MoveForwardTail
.2 lda TmpByte
sta (BufPtr)
inc FileLen
2019-12-16 13:14:11 +00:00
bne .3
2019-11-15 16:15:43 +00:00
inc FileLen+1
2019-12-17 12:28:49 +00:00
.3 jmp SCRN.Unsaved
2019-12-16 13:14:11 +00:00
2019-11-15 16:15:43 +00:00
.8 clc
.9 rts
*--------------------------------------
2019-11-17 14:39:55 +00:00
BUF.InsertTAB >LDA.G FileX
and #TABMASK
bne .1
lda #TABLEN
2019-11-15 16:15:43 +00:00
2019-11-17 14:39:55 +00:00
.1 sta TmpByte
jsr BUF.ComputeCOffset
tya
sec
adc TmpByte
bcs .8
ldy TmpByte
lda #0
jsr BUF.BufPtrSetup
bcs .9
pha
txa
clc
adc TmpByte
sta BufPtrDst
pla
adc #0
sta BufPtrDst+1
jsr BUF.MoveForwardTail
lda #C.SPACE
ldy TmpByte
dey
.2 sta (BufPtr),y
dey
bpl .2
.4 lda FileLen
clc
adc TmpByte
sta FileLen
2019-12-16 13:14:11 +00:00
bcc .5
2019-11-17 14:39:55 +00:00
inc FileLen+1
2019-12-17 12:28:49 +00:00
.5 jsr SCRN.UpdateStatusBar
2019-12-16 13:14:11 +00:00
jmp SCRN.Unsaved
2019-11-17 14:39:55 +00:00
.8 clc
.9 rts
*--------------------------------------
BUF.DelCharAtCursor
lda BUF.COffset
clc
>ADC.G BufBase
sta BufPtrDst
lda BUF.COffset+1
>ADC.G BufBase+1
sta BufPtrDst+1
>LDYA BufPtrDst
2019-11-15 16:15:43 +00:00
iny
bne .1
inc
.1 >STYA BufPtr
2019-11-18 16:40:32 +00:00
lda (BufPtrDst)
2019-11-17 14:39:55 +00:00
pha Save deleted char for later
2019-11-15 16:15:43 +00:00
jsr BUF.MoveBackTail
lda FileLen
bne .5
dec FileLen+1
.5 dec FileLen
jsr BUF.ResetSel
pla Get back deleted char
clc
.9 rts
*--------------------------------------
2016-02-25 17:02:57 +00:00
BUF.InsertClipboard
2019-11-04 07:21:40 +00:00
>LDA.G hClipBoard
2016-02-25 17:02:57 +00:00
beq .8
2019-11-04 07:21:40 +00:00
2018-07-18 15:30:42 +00:00
>SYSCALL GetMemPtr
2016-02-25 17:02:57 +00:00
>STYA ClipboardPtr
2019-11-17 14:39:55 +00:00
2016-02-25 17:02:57 +00:00
jsr BUF.ComputeCOffset
2019-11-06 13:14:42 +00:00
lda FileLen
2019-12-07 09:54:33 +00:00
clc
2019-11-17 14:39:55 +00:00
>ADC.G ClipboardLen
2016-01-29 17:05:08 +00:00
pha
2019-11-06 13:14:42 +00:00
lda FileLen+1
2019-05-27 15:37:31 +00:00
iny
2016-01-29 17:05:08 +00:00
adc (pData),y
ply
2019-11-04 07:21:40 +00:00
2019-11-17 14:39:55 +00:00
cpy BufLen
sbc BufLen+1
2019-12-07 09:54:33 +00:00
bcs .8
2019-11-04 07:21:40 +00:00
2019-11-17 14:39:55 +00:00
>LDYA.G ClipboardLen
jsr BUF.BufPtrSetup
bcs .9
pha
txa
2016-02-25 17:02:57 +00:00
clc
2019-11-17 14:39:55 +00:00
>ADC.G ClipboardLen
sta BufPtrDst
pla
>ADC.G ClipboardLen+1
sta BufPtrDst+1
2019-11-04 13:41:58 +00:00
2019-11-17 14:39:55 +00:00
jsr BUF.MoveForwardTail
2019-11-04 13:41:58 +00:00
2019-12-07 09:54:33 +00:00
>LDA.G ClipboardLen
2019-11-17 14:39:55 +00:00
eor #$ff
tax
2019-12-07 09:54:33 +00:00
iny
lda (pData),y ClipboardLen+1
2019-11-17 14:39:55 +00:00
eor #$ff
pha
2019-11-04 13:41:58 +00:00
2019-11-17 14:39:55 +00:00
ldy #0
.1 inx
2019-11-04 13:41:58 +00:00
bne .2
2019-11-17 14:39:55 +00:00
pla
inc
beq .3
pha
.2 lda (ClipboardPtr),y
sta (BufPtr),y
iny
2019-11-04 13:41:58 +00:00
bne .1
2019-11-17 14:39:55 +00:00
inc ClipboardPtr+1
inc BufPtr+1
bra .1
2019-11-04 13:41:58 +00:00
2019-11-17 14:39:55 +00:00
.3 >LDA.G ClipboardLen
2019-11-04 13:41:58 +00:00
clc
2019-11-17 14:39:55 +00:00
adc FileLen
2019-11-06 13:14:42 +00:00
sta FileLen
2019-11-04 13:41:58 +00:00
2019-11-17 14:39:55 +00:00
iny
lda (pData),y
adc FileLen+1
sta FileLen+1
2019-12-17 12:28:49 +00:00
jsr SCRN.UpdateStatusBar
jmp SCRN.Unsaved
2019-11-04 13:41:58 +00:00
.8 clc
2019-11-17 14:39:55 +00:00
.9 rts
2019-11-04 13:41:58 +00:00
*--------------------------------------
2016-02-25 17:02:57 +00:00
BUF.DelSel jsr BUF.GetSelLen
bcs .8
2019-12-07 09:54:33 +00:00
>LDA.G SelStart
2019-11-17 14:39:55 +00:00
clc
>ADC.G BufBase
sta BufPtrDst
2019-11-04 07:21:40 +00:00
2019-12-07 09:54:33 +00:00
>LDA.G SelStart+1
2019-11-17 14:39:55 +00:00
>ADC.G BufBase+1
sta BufPtrDst+1
lda BufPtrDst
2016-02-25 17:02:57 +00:00
clc
adc SelLen
2019-11-17 14:39:55 +00:00
sta BufPtr
lda BufPtrDst+1
2016-02-25 17:02:57 +00:00
adc SelLen+1
2019-11-17 14:39:55 +00:00
sta BufPtr+1
jsr BUF.MoveBackTail
2019-11-04 07:21:40 +00:00
2019-11-06 13:14:42 +00:00
lda FileLen
2016-02-25 17:02:57 +00:00
sec
sbc SelLen
2019-11-06 13:14:42 +00:00
sta FileLen
2019-11-17 14:39:55 +00:00
2019-11-06 13:14:42 +00:00
lda FileLen+1
2016-02-25 17:02:57 +00:00
sbc SelLen+1
2019-11-06 13:14:42 +00:00
sta FileLen+1
2016-02-25 17:02:57 +00:00
2019-12-17 12:28:49 +00:00
jsr SCRN.UpdateStatusBar
jsr SCRN.Unsaved
2016-02-25 17:02:57 +00:00
jsr BUF.ResetSel
2019-11-17 14:39:55 +00:00
jmp SCRN.CursorAdjust
2016-02-25 17:02:57 +00:00
.8 clc
2019-10-03 06:25:27 +00:00
.9 rts
2016-02-25 17:02:57 +00:00
*--------------------------------------
2016-01-29 17:05:08 +00:00
BUF.SelToClipboard
2016-02-25 17:02:57 +00:00
jsr BUF.GetSelLen
bcs .8
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
>LDA.G hClipBoard
2016-01-29 17:05:08 +00:00
beq .1
2019-11-04 07:21:40 +00:00
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2019-05-29 15:21:14 +00:00
>STZ.G hClipBoard
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
.1 >LDYA SelLen
2018-07-18 15:30:42 +00:00
>SYSCALL GetMem
2016-01-29 17:05:08 +00:00
bcs .9
2019-11-04 07:21:40 +00:00
2016-01-29 17:05:08 +00:00
>STYA ClipboardPtr
txa
2019-05-27 15:37:31 +00:00
>STA.G hClipBoard
2019-11-04 07:21:40 +00:00
>LDA.G hBuffer
2018-07-18 15:30:42 +00:00
>SYSCALL GetMemPtr
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
pha
tya
2019-11-04 13:41:58 +00:00
2019-11-13 16:33:29 +00:00
clc
2019-05-27 15:37:31 +00:00
>ADC.G SelStart
2016-02-25 17:02:57 +00:00
sta BufPtr
2019-05-27 15:37:31 +00:00
pla
2019-11-04 13:41:58 +00:00
iny SelStart+1
adc (pData),y
2016-02-25 17:02:57 +00:00
sta BufPtr+1
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
lda SelLen
2019-11-04 07:21:40 +00:00
>STA.G ClipBoardLen
2019-05-27 15:37:31 +00:00
eor #$ff
tax
iny
2019-05-29 15:21:14 +00:00
lda SelLen+1
2019-05-27 15:37:31 +00:00
sta (pData),y
eor #$ff
pha
2019-11-04 07:21:40 +00:00
2016-02-25 17:02:57 +00:00
ldy #0
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
.2 inx
bne .3
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
pla
inc
2019-05-29 15:21:14 +00:00
beq .8
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
pha
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
.3 lda (BufPtr),y
2016-01-29 17:05:08 +00:00
sta (ClipboardPtr),y
iny
bne .2
2019-11-04 07:21:40 +00:00
2016-01-29 17:05:08 +00:00
inc BufPtr+1
inc ClipboardPtr+1
bra .2
2016-02-25 17:02:57 +00:00
2016-01-29 17:05:08 +00:00
.8 clc
.9 rts
*--------------------------------------
2016-02-25 17:02:57 +00:00
BUF.CopyClipboard
2019-05-27 15:37:31 +00:00
>LDA.G ClipboardLen
2019-05-24 15:26:07 +00:00
eor #$ff
tax
2019-05-27 15:37:31 +00:00
iny
2019-05-24 15:26:07 +00:00
lda (pData),y
eor #$ff
2019-05-27 15:37:31 +00:00
pha
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
ldy #0
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
.1 inx
2019-05-24 15:26:07 +00:00
bne .2
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
pla
inc
beq .3
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
pha
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
.2 lda (ClipboardPtr),y
sta (BufPtr),y
iny
2019-05-24 15:26:07 +00:00
bne .1
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
inc ClipboardPtr+1
2016-02-25 17:02:57 +00:00
inc BufPtr+1
2019-05-24 15:26:07 +00:00
bra .1
2019-11-04 07:21:40 +00:00
2019-05-27 15:37:31 +00:00
.3 tya
clc
adc ClipboardPtr
sta ClipboardPtr
2019-06-03 15:50:41 +00:00
bcc BUF.CopyAddY
2019-05-27 15:37:31 +00:00
inc ClipboardPtr+1
2019-11-04 07:21:40 +00:00
2019-06-03 15:50:41 +00:00
BUF.CopyAddY tya
2019-05-27 15:37:31 +00:00
clc
adc BufPtr
sta BufPtr
2019-06-03 15:50:41 +00:00
bcc .2
2019-05-27 15:37:31 +00:00
inc BufPtr+1
2019-06-03 15:50:41 +00:00
.2 rts
2016-02-25 17:02:57 +00:00
*--------------------------------------
2019-11-15 16:15:43 +00:00
BUF.MoveBackTail
ldy #0
lda BufPtr+1
pha
.1 lda (BufPtr),y
sta (BufPtrDst),y
beq .8
iny
bne .1
inc BufPtr+1
inc BufPtrDst+1
bra .1
.8 pla
sta BufPtr+1
rts
*--------------------------------------
BUF.MoveForwardTail
ldy #0
ldx #$ff
phx
.1 lda (BufPtr),y
2019-11-17 14:39:55 +00:00
beq .3
2019-11-15 16:15:43 +00:00
dex
bne .2
pla
dec
pha
.2 iny
bne .1
inc BufPtr+1
inc BufPtrDst+1
bra .1
2019-11-17 14:39:55 +00:00
.3 lda (BufPtr),y
2019-11-15 16:15:43 +00:00
sta (BufPtrDst),y
inx
bne .4
pla
inc
beq .8
2019-11-17 14:39:55 +00:00
2019-11-15 16:15:43 +00:00
pha
2019-11-17 14:39:55 +00:00
.4 tya
bne .5
dec BufPtr+1
dec BufPtrDst+1
.5 dey
bra .3
2019-11-15 16:15:43 +00:00
2019-06-03 15:50:41 +00:00
.8 rts
2016-01-28 17:03:51 +00:00
*--------------------------------------
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
2019-08-26 09:26:42 +00:00
2016-01-04 07:25:43 +00:00
phy save line length
2019-08-26 09:26:42 +00:00
2019-11-04 07:21:40 +00:00
>LDA.G FileX
2019-11-12 16:39:22 +00:00
* clc
2016-01-04 07:25:43 +00:00
adc BUF.LOffset
sta BUF.COffset
2019-08-26 09:26:42 +00:00
2016-01-04 07:25:43 +00:00
lda #0
adc BUF.LOffset+1
sta BUF.COffset+1
2019-08-26 09:26:42 +00:00
2016-01-04 07:25:43 +00:00
ply
2019-08-26 09:26:42 +00:00
2016-01-04 07:25:43 +00:00
clc
.9 rts
*--------------------------------------
2019-11-04 07:21:40 +00:00
BUF.GetNextLine sec
.HS 90 BCC
BUF.GetLine clc
>LDA.G FileY
adc #0
pha
iny
lda (pData),y
2019-11-04 07:21:40 +00:00
adc #0
tax
2019-11-04 07:21:40 +00:00
pla
2019-11-13 16:33:29 +00:00
BUF.GetLineAX sta BUF.TmpLine1 Requested Line
stx BUF.TmpLine1+1
2016-01-04 07:25:43 +00:00
2019-11-13 16:33:29 +00:00
stz BUF.TmpLine2
stz BUF.TmpLine2+1
2016-01-04 07:25:43 +00:00
stz BUF.LOffset
stz BUF.LOffset+1
2019-11-17 14:39:55 +00:00
>LDYA.G BufBase
2016-01-04 07:25:43 +00:00
>STYA BufPtr
2019-11-04 07:21:40 +00:00
2016-01-04 07:25:43 +00:00
.1 ldy #0
2019-11-04 07:21:40 +00:00
2016-01-04 07:25:43 +00:00
.2 lda (BufPtr),y
beq .7
2019-11-04 07:21:40 +00:00
2019-05-25 19:24:07 +00:00
cmp #C.CR
2016-01-04 07:25:43 +00:00
beq .3
iny
bne .2
.3 lda BUF.TmpLine1
cmp BUF.TmpLine2
bne .4
2019-11-04 07:21:40 +00:00
2016-01-04 07:25:43 +00:00
lda BUF.TmpLine1+1
cmp BUF.TmpLine2+1
beq .8
2019-11-04 07:21:40 +00:00
2016-01-04 07:25:43 +00:00
.4 tya
sec
adc BufPtr
sta BufPtr
bcc .5
inc BufPtr+1
2019-11-04 07:21:40 +00:00
2016-01-04 07:25:43 +00:00
.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
2019-11-04 07:21:40 +00:00
2016-01-04 07:25:43 +00:00
.7 lda BUF.TmpLine1
cmp BUF.TmpLine2
2016-01-28 17:03:51 +00:00
bne .9
2019-11-04 07:21:40 +00:00
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
2019-11-04 07:21:40 +00:00
2016-01-28 17:03:51 +00:00
.8 clc Y = Line length
2016-01-04 07:25:43 +00:00
rts
2019-11-04 07:21:40 +00:00
2016-01-28 17:03:51 +00:00
.9 sec
rts
*--------------------------------------
2019-05-29 15:21:14 +00:00
BUF.ResetSel lda #$ff
ldy #SelStart
2019-05-28 16:00:53 +00:00
2019-05-29 15:21:14 +00:00
sta (pData),y
2019-05-28 16:00:53 +00:00
iny
2019-05-29 15:21:14 +00:00
sta (pData),y
2019-05-28 16:00:53 +00:00
2019-05-29 15:21:14 +00:00
iny #SelEnd
2019-11-04 07:21:40 +00:00
inc lda #0
2019-05-29 15:21:14 +00:00
sta (pData),y
iny
sta (pData),y
2016-02-25 17:02:57 +00:00
rts
*--------------------------------------
BUF.CheckSelected
2019-05-28 16:00:53 +00:00
lda BUF.COffset
2019-05-29 15:21:14 +00:00
ldy #SelStart
2019-05-24 15:26:07 +00:00
cmp (pData),y
2019-05-28 16:00:53 +00:00
lda BUF.COffset+1
2019-05-29 15:21:14 +00:00
iny
2016-02-25 17:02:57 +00:00
sbc (pData),y
2019-05-29 15:21:14 +00:00
bcc .9 CC:COffset < SelStart
2019-11-04 07:21:40 +00:00
2019-05-28 16:00:53 +00:00
iny #SelEnd
2019-05-29 15:21:14 +00:00
lda (pData),y
clc
sbc BUF.COffset
2016-02-25 17:02:57 +00:00
iny
2019-05-29 15:21:14 +00:00
lda (pData),y
sbc BUF.COffset+1
* CC:SelEnd < COffset
.9 lda #0
ror $80 = selected
2016-02-25 17:02:57 +00:00
rts
*--------------------------------------
BUF.GetSelLen ldy #SelEnd
lda (pData),y
sec
ldy #SelStart
sbc (pData),y
2019-05-29 15:21:14 +00:00
sta SelLen
2016-02-25 17:02:57 +00:00
tax
ldy #SelEnd+1
lda (pData),y
2019-05-29 15:21:14 +00:00
2016-02-25 17:02:57 +00:00
ldy #SelStart+1
sbc (pData),y
2019-05-29 15:21:14 +00:00
sta SelLen+1
2016-02-25 17:02:57 +00:00
bcc .9
2019-12-07 09:54:33 +00:00
2016-02-25 17:02:57 +00:00
bne .8
2019-05-29 15:21:14 +00:00
txa
2016-02-25 17:02:57 +00:00
beq .9
2019-12-07 09:54:33 +00:00
2016-02-25 17:02:57 +00:00
.8 clc
rts
2019-12-07 09:54:33 +00:00
2016-02-25 17:02:57 +00:00
.9 sec
rts
*--------------------------------------
2019-11-17 14:39:55 +00:00
BUF.BufPtrSetup lda BUF.COffset
clc
>ADC.G BufBase
sta BufPtr
tax
lda BUF.COffset+1
>ADC.G BufBase+1
sta BufPtr+1
clc
rts
*--------------------------------------
2016-01-04 07:25:43 +00:00
MAN
2019-02-01 16:32:29 +00:00
SAVE USR/SRC/BIN/EDIT.S.BUF
LOAD USR/SRC/BIN/EDIT.S
2016-01-04 07:25:43 +00:00
ASM