mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-19 12:31:56 +00:00
599 lines
8.3 KiB
Plaintext
599 lines
8.3 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
BUF.InsertA sta TmpByte
|
||
|
||
cpy #255
|
||
beq .8
|
||
|
||
>LDYAI 1
|
||
jsr BUF.BufPtrSetup
|
||
bcs .9
|
||
|
||
inx
|
||
bne .1
|
||
inc
|
||
|
||
.1 stx BufPtrDst
|
||
sta BufPtrDst+1
|
||
|
||
jsr BUF.MoveForwardTail
|
||
|
||
.2 lda TmpByte
|
||
sta (BufPtr)
|
||
|
||
inc FileLen
|
||
bne .3
|
||
inc FileLen+1
|
||
|
||
.3 jmp SCRN.Unsaved
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.InsertTAB >LDA.G FileX
|
||
and #TABMASK
|
||
bne .1
|
||
|
||
lda #TABLEN
|
||
|
||
.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
|
||
bcc .5
|
||
|
||
inc FileLen+1
|
||
|
||
.5 jsr SCRN.UpdateStatusBar
|
||
|
||
jmp SCRN.Unsaved
|
||
|
||
.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
|
||
iny
|
||
bne .1
|
||
inc
|
||
|
||
.1 >STYA BufPtr
|
||
|
||
lda (BufPtrDst)
|
||
pha Save deleted char for later
|
||
|
||
jsr BUF.MoveBackTail
|
||
|
||
lda FileLen
|
||
bne .5
|
||
dec FileLen+1
|
||
.5 dec FileLen
|
||
|
||
jsr BUF.ResetSel
|
||
pla Get back deleted char
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.InsertClipboard
|
||
>LDA.G hClipBoard
|
||
beq .8
|
||
|
||
>SYSCALL GetMemPtr
|
||
>STYA ClipboardPtr
|
||
|
||
jsr BUF.ComputeCOffset
|
||
|
||
lda FileLen
|
||
clc
|
||
>ADC.G ClipboardLen
|
||
pha
|
||
lda FileLen+1
|
||
iny
|
||
adc (pData),y
|
||
ply
|
||
|
||
cpy BufLen
|
||
sbc BufLen+1
|
||
bcs .8
|
||
|
||
>LDYA.G ClipboardLen
|
||
jsr BUF.BufPtrSetup
|
||
bcs .9
|
||
|
||
pha
|
||
txa
|
||
clc
|
||
>ADC.G ClipboardLen
|
||
sta BufPtrDst
|
||
pla
|
||
>ADC.G ClipboardLen+1
|
||
sta BufPtrDst+1
|
||
|
||
jsr BUF.MoveForwardTail
|
||
|
||
>LDA.G ClipboardLen
|
||
eor #$ff
|
||
tax
|
||
|
||
iny
|
||
lda (pData),y ClipboardLen+1
|
||
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 >LDA.G ClipboardLen
|
||
clc
|
||
adc FileLen
|
||
sta FileLen
|
||
|
||
iny
|
||
lda (pData),y
|
||
adc FileLen+1
|
||
sta FileLen+1
|
||
|
||
jsr SCRN.UpdateStatusBar
|
||
|
||
jmp SCRN.Unsaved
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
BUF.DelSel jsr BUF.GetSelLen
|
||
bcs .8
|
||
|
||
>LDA.G SelStart
|
||
clc
|
||
>ADC.G BufBase
|
||
sta BufPtrDst
|
||
|
||
>LDA.G SelStart+1
|
||
>ADC.G BufBase+1
|
||
sta BufPtrDst+1
|
||
|
||
lda BufPtrDst
|
||
clc
|
||
adc SelLen
|
||
sta BufPtr
|
||
|
||
lda BufPtrDst+1
|
||
adc SelLen+1
|
||
sta BufPtr+1
|
||
|
||
jsr BUF.MoveBackTail
|
||
|
||
lda FileLen
|
||
sec
|
||
sbc SelLen
|
||
sta FileLen
|
||
|
||
lda FileLen+1
|
||
sbc SelLen+1
|
||
sta FileLen+1
|
||
|
||
jsr SCRN.UpdateStatusBar
|
||
|
||
jsr SCRN.Unsaved
|
||
|
||
jsr BUF.ResetSel
|
||
jmp SCRN.CursorAdjust
|
||
|
||
.8 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
|
||
|
||
clc
|
||
>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.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
|
||
beq .3
|
||
dex
|
||
bne .2
|
||
|
||
pla
|
||
dec
|
||
pha
|
||
|
||
.2 iny
|
||
bne .1
|
||
inc BufPtr+1
|
||
inc BufPtrDst+1
|
||
bra .1
|
||
|
||
.3 lda (BufPtr),y
|
||
sta (BufPtrDst),y
|
||
|
||
inx
|
||
bne .4
|
||
|
||
pla
|
||
inc
|
||
beq .8
|
||
|
||
pha
|
||
|
||
.4 tya
|
||
bne .5
|
||
|
||
dec BufPtr+1
|
||
dec BufPtrDst+1
|
||
|
||
.5 dey
|
||
|
||
bra .3
|
||
|
||
.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 Requested Line
|
||
stx BUF.TmpLine1+1
|
||
|
||
stz BUF.TmpLine2
|
||
stz BUF.TmpLine2+1
|
||
|
||
stz BUF.LOffset
|
||
stz BUF.LOffset+1
|
||
|
||
>LDYA.G BufBase
|
||
>STYA BufPtr
|
||
|
||
.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.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
|
||
*--------------------------------------
|
||
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
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/BIN/EDIT.S.BUF
|
||
LOAD USR/SRC/BIN/EDIT.S
|
||
ASM
|