A2osX/BIN/EDIT.S.FILE.txt

463 lines
6.5 KiB
Plaintext
Raw Normal View History

2019-11-06 13:14:42 +00:00
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
2021-07-03 17:18:58 +00:00
FILE.New jsr FILE.Reset
2019-12-16 13:14:11 +00:00
>LDYA L.MSG.NEWFILE
FILE.RealPath >PUSHYA
2021-07-24 20:42:23 +00:00
>PUSHWZ Allocate
2020-02-14 07:21:56 +00:00
>SYSCALL RealPath
2019-12-16 13:14:11 +00:00
bcs .9
txa
>STA.G hFileName
2019-12-17 12:28:49 +00:00
2019-11-12 16:39:22 +00:00
.9 rts
2019-11-06 13:14:42 +00:00
*--------------------------------------
FILE.Load jsr FILE.RealPath
bcs .9
2019-12-16 13:14:11 +00:00
jsr FILE.Reset
>LDYA.G LineBufBase
>STYA LineBufPtr
2020-04-02 06:32:25 +00:00
2021-07-03 17:18:58 +00:00
ldx #S.FI.T.TXT
lda #O.RDONLY
jsr FILE.OpenAX
bcs .1
2020-02-12 14:42:07 +00:00
jsr FILE.Load.TXT
2020-04-02 06:32:25 +00:00
jmp FILE.Close
2021-07-03 17:18:58 +00:00
.1 ldx #S.FI.T.ASM
2021-07-03 17:18:58 +00:00
lda #O.RDONLY
jsr FILE.OpenAX
bcs .8
2019-11-06 13:14:42 +00:00
2020-04-02 06:32:25 +00:00
jsr FILE.Load.ASM
jmp FILE.Close
2020-01-27 16:33:11 +00:00
.8 clc
.9 rts
2021-07-03 17:18:58 +00:00
*--------------------------------------
FILE.Load.TXT
2021-06-30 19:09:07 +00:00
.1 ldy #0
jsr FILE.ReadY read 256
2019-11-17 14:39:55 +00:00
bcs .7
2019-11-12 16:39:22 +00:00
2021-06-30 19:09:07 +00:00
sty TmpCount Count read
2019-11-17 14:39:55 +00:00
ldy #0
2020-01-27 16:33:11 +00:00
.2 lda (LineBufPtr),y
2019-11-17 14:39:55 +00:00
2021-06-30 19:09:07 +00:00
cmp #C.LF
bne .3
2019-11-06 16:25:00 +00:00
2019-11-17 14:39:55 +00:00
phy
2021-06-30 19:09:07 +00:00
lda #1
2019-11-12 16:39:22 +00:00
>STA.G FileType
2019-11-06 16:25:00 +00:00
2019-11-17 14:39:55 +00:00
ply
2021-07-03 17:18:58 +00:00
bra .4
2019-11-17 14:39:55 +00:00
2021-07-03 17:18:58 +00:00
.3 jsr FILE.Load.2Buf
bcs FILE.Load.RTS
2021-06-30 19:09:07 +00:00
2021-07-03 17:18:58 +00:00
.4 dec TmpCount
2021-06-30 19:09:07 +00:00
beq .1
iny
bra .2
2019-11-12 16:39:22 +00:00
2019-11-17 14:39:55 +00:00
.7 cmp #MLI.E.EOF
2019-11-12 16:39:22 +00:00
bne .9
2019-11-17 14:39:55 +00:00
.8 lda #0
sta (BufPtr)
2019-11-12 16:39:22 +00:00
clc
2021-06-30 19:09:07 +00:00
rts
2019-11-17 14:39:55 +00:00
.9 sec
2021-07-03 17:18:58 +00:00
FILE.Load.RTS rts
2019-11-06 13:14:42 +00:00
*--------------------------------------
FILE.Load.ASM lda #2
2020-02-11 16:32:33 +00:00
>STA.G FileType
2020-07-27 14:09:19 +00:00
.1 ldy #3
jsr FILE.ReadY
2020-02-11 16:32:33 +00:00
bcs .7
lda (LineBufPtr)
2020-02-11 16:32:33 +00:00
dec
dec
dec
2020-07-27 14:09:19 +00:00
tay
jsr FILE.ReadY
2020-02-11 16:32:33 +00:00
bcs .7
jsr FILE.Load.ASM.Decode
bcc .1
.7 cmp #MLI.E.EOF
bne .9
lda #0
sta (BufPtr)
clc
2021-06-30 19:09:07 +00:00
rts
2020-02-11 16:32:33 +00:00
.9 sec
.99 rts
*--------------------------------------
FILE.Load.ASM.Decode
ldy #0
.1 lda (LineBufPtr),y
2020-02-11 16:32:33 +00:00
beq .8
iny
tax
bmi .2
2021-07-03 17:18:58 +00:00
jsr FILE.Load.2Buf
2020-02-11 16:32:33 +00:00
bcc .1
2020-02-12 14:42:07 +00:00
.9 rts
2020-02-11 16:32:33 +00:00
.2 cmp #$C0 REPEAT char?
bne .5
lda (LineBufPtr),y Get Repeat Count
2020-02-11 16:32:33 +00:00
iny
tax
.4 lda (LineBufPtr),y Get Repeat Char
2020-02-11 16:32:33 +00:00
2021-07-03 17:18:58 +00:00
jsr FILE.Load.2Buf
2020-02-12 14:42:07 +00:00
bcs .9
2020-02-11 16:32:33 +00:00
dex
bne .4
2020-05-17 17:34:32 +00:00
iny Skip Repeat char
2020-02-11 16:32:33 +00:00
bra .1
.5 and #$3F Compute blank count
tax
2020-05-17 17:34:32 +00:00
.6 lda #C.SPACE
2020-02-11 16:32:33 +00:00
2021-07-03 17:18:58 +00:00
jsr FILE.Load.2Buf
2020-02-12 14:42:07 +00:00
bcs .9
2020-02-11 16:32:33 +00:00
dex
bne .6
bra .1
.8 lda #C.CR
*--------------------------------------
2021-07-03 17:18:58 +00:00
FILE.Load.2Buf phy
2020-02-11 16:32:33 +00:00
phx
2021-06-30 19:09:07 +00:00
2020-02-11 16:32:33 +00:00
sta (BufPtr)
inc BufPtr
bne .1
2021-06-30 19:09:07 +00:00
2020-02-11 16:32:33 +00:00
inc BufPtr+1
.1 inc FileLen
bne .8
2021-06-30 19:09:07 +00:00
2020-02-11 16:32:33 +00:00
inc FileLen+1
lda FileLen+1
cmp BufLen+1
bne .8
2020-05-17 17:34:32 +00:00
2020-02-11 16:32:33 +00:00
jsr BUF.BufPtr.Realloc
bcs .9
>LDA.G BufBase
* clc
adc FileLen
sta BufPtr
iny
lda (pData),y
adc FileLen+1
sta BufPtr+1
.8 clc
2021-06-30 19:09:07 +00:00
2020-02-11 16:32:33 +00:00
.9 plx
ply
2021-07-03 17:18:58 +00:00
FILE.Save.9 rts
2020-02-11 16:32:33 +00:00
*--------------------------------------
FILE.Save >LDYA.G LineBufBase
>STYA LineBufPtr
2019-11-12 16:39:22 +00:00
2019-11-17 14:39:55 +00:00
>LDA.G FileType
asl
2019-11-17 14:39:55 +00:00
tax
jmp (J.SAVE,x)
2019-11-12 16:39:22 +00:00
*--------------------------------------
2019-11-17 14:39:55 +00:00
FILE.Save.CR clc
.HS B0 BCS
FILE.Save.CRLF sec
ror TmpIndex+1
2020-07-27 14:09:19 +00:00
ldx #S.FI.T.TXT
2021-07-03 17:18:58 +00:00
lda #O.CREATE+O.WRONLY
jsr FILE.OpenAX
2020-07-27 14:09:19 +00:00
2019-12-16 13:14:11 +00:00
bcs FILE.Save.9
2019-11-06 13:14:42 +00:00
2019-11-17 14:39:55 +00:00
>LDYA.G BufBase
>STYA BufPtr
.1 lda (BufPtr)
beq .8
2022-03-24 21:12:54 +00:00
ldy #0
2019-11-06 13:14:42 +00:00
2022-03-24 21:12:54 +00:00
.2 lda (BufPtr)
beq .4
2019-11-17 14:39:55 +00:00
2022-03-24 21:12:54 +00:00
inc BufPtr
bne .3
inc BufPtr+1
.3 sta (LineBufPtr),y
iny
2019-11-17 14:39:55 +00:00
cmp #C.CR
bne .2
bit TmpIndex+1
2022-03-24 21:12:54 +00:00
bpl .4
2019-11-17 14:39:55 +00:00
lda #C.LF
sta (LineBufPtr),y
2021-07-11 11:42:12 +00:00
iny
2019-11-17 14:39:55 +00:00
2022-03-24 21:12:54 +00:00
.4 jsr FILE.WriteY
2020-07-27 14:09:19 +00:00
bcs FILE.Save.99
2019-11-06 13:14:42 +00:00
2019-11-17 14:39:55 +00:00
bra .1
2019-12-16 13:14:11 +00:00
2020-07-27 05:15:14 +00:00
.8 >STZ.G bUnSaved
2020-07-27 14:09:19 +00:00
FILE.Save.99 jmp FILE.Close
2020-07-27 05:15:14 +00:00
*--------------------------------------
2020-07-27 14:09:19 +00:00
FILE.Save.ASM stz TmpLen
2020-07-27 05:15:14 +00:00
stz TmpLen+1
2020-07-27 14:09:19 +00:00
inc TmpLen
2020-07-27 05:15:14 +00:00
2021-07-03 17:18:58 +00:00
ldx #S.FI.T.ASM
lda #O.CREATE+O.WRONLY
jsr FILE.OpenAX
2020-07-27 14:09:19 +00:00
bcs FILE.Save.99
2020-07-27 05:15:14 +00:00
>LDYA.G BufBase
>STYA BufPtr
2020-07-27 14:09:19 +00:00
.1 lda (BufPtr)
beq .8
ldy #1
lda TmpLen
sta (LineBufPtr),y
2020-07-27 14:09:19 +00:00
iny
lda TmpLen+1
sta (LineBufPtr),y
2020-07-27 14:09:19 +00:00
ldy #0
.2 iny
lda (BufPtr),y
beq .3
cmp #C.CR
bne .2
.3 ldy #3 Initial LEN
.4 lda (BufPtr)
beq .7
ldx #0
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
.40 inc BufPtr
bne .5
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
inc BufPtr+1
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
.5 cmp #C.CR
beq .7
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
cmp (BufPtr) same as next ?
bne .50 no -> flush
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
inx
cpx #$3F
bne .40
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
.50 cpx #0
beq .60 only one char....
cmp #C.SPACE
beq .61
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
cpx #3
bcs .62
2020-07-27 05:15:14 +00:00
.63 sta (LineBufPtr),y
2020-07-27 14:09:19 +00:00
iny
dex
bpl .63
bra .4
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
.62 pha
lda #$C0
sta (LineBufPtr),y
2020-07-27 14:09:19 +00:00
iny
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
txa
sta (LineBufPtr),y
2020-07-27 14:09:19 +00:00
iny
pla
sta (LineBufPtr),y
2020-07-27 14:09:19 +00:00
iny
bra .4
.61 txa
ora #$C0
.60 sta (LineBufPtr),y
2020-07-27 14:09:19 +00:00
iny
bra .4
.7 lda #0
sta (LineBufPtr),y
2020-07-27 14:09:19 +00:00
iny
tya
sta (LineBufPtr)
2020-07-27 14:09:19 +00:00
jsr FILE.WriteY
bcs FILE.Close
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
inc TmpLen
bne .1
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
inc TmpLen+1
bra .1
2020-07-27 05:15:14 +00:00
2019-12-17 12:28:49 +00:00
.8 >STZ.G bUnSaved
*--------------------------------------
FILE.Close php
pha
2019-12-16 13:14:11 +00:00
lda TmpIndex hFile
2019-12-17 12:28:49 +00:00
beq .2
2019-12-16 13:14:11 +00:00
2020-02-28 07:21:46 +00:00
>SYSCALL FClose
2019-12-16 13:14:11 +00:00
2019-12-17 12:28:49 +00:00
.2 pla
plp
rts
2019-11-17 14:39:55 +00:00
*--------------------------------------
2021-07-03 17:18:58 +00:00
FILE.OpenAX stz TmpIndex hFile
2020-07-27 14:09:19 +00:00
phx
pha
>LDA.G hFileName
>SYSCALL GetMemPtr
>PUSHYA
pla access
>PUSHA
pla type
>PUSHA
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
2021-07-03 17:18:58 +00:00
sta TmpIndex hFile
2020-07-27 14:09:19 +00:00
.9 rts
*--------------------------------------
2021-05-14 20:58:20 +00:00
FILE.ReadY phy
2021-07-03 17:18:58 +00:00
>PUSHB TmpIndex hFile
>PUSHW LineBufPtr
2021-05-14 20:58:20 +00:00
lda #0
2021-06-30 19:09:07 +00:00
ply
bne .1
inc
.1 >PUSHYA
2020-07-27 14:09:19 +00:00
>SYSCALL FRead
rts
*--------------------------------------
2021-05-14 20:58:20 +00:00
FILE.WriteY phy
2021-07-03 17:18:58 +00:00
>PUSHB TmpIndex hFile
>PUSHW LineBufPtr
2021-05-14 20:58:20 +00:00
ply
lda #0
>PUSHYA
2020-07-27 14:09:19 +00:00
>SYSCALL FWrite
FILE.WriteY.RTS rts
2020-07-27 14:09:19 +00:00
*--------------------------------------
2021-07-03 17:18:58 +00:00
FILE.Reset >LDA.G hBuf
beq .1
2019-11-12 16:39:22 +00:00
2021-07-03 17:18:58 +00:00
>SYSCALL FreeMem
.1 >STZ.G hBuf
>STA.G FileType TXT/CR
2020-01-27 16:33:11 +00:00
2021-07-03 17:18:58 +00:00
stz FileLen
stz FileLen+1
jsr BUF.ResetSel
>LDYAI FILEBUF.SIZE
2019-11-12 16:39:22 +00:00
>STYA BufLen
>SYSCALL GetMem
bcs FILE.WriteY.RTS
2019-11-15 16:15:43 +00:00
2019-11-17 14:39:55 +00:00
>STYA BufPtr
>STYA.G BufBase
2019-11-12 16:39:22 +00:00
txa
2020-01-23 14:48:22 +00:00
>STA.G hBuf
2020-02-11 16:32:33 +00:00
2021-07-03 17:18:58 +00:00
lda #0
sta (BufPtr)
jmp SCRN.UpdateStatusBar
*--------------------------------------
2019-11-06 13:14:42 +00:00
MAN
2020-07-27 14:09:19 +00:00
SAVE usr/src/bin/edit.s.file
LOAD usr/src/bin/edit.s
2019-11-06 13:14:42 +00:00
ASM