A2osX/BIN/EDIT.S.FILE.txt

552 lines
7.7 KiB
Plaintext
Raw Normal View History

2019-11-06 13:14:42 +00:00
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
2019-12-16 13:14:11 +00:00
FILE.New jsr BUF.ResetSel
2019-12-17 12:28:49 +00:00
jsr SCRN.UpdateStatusBar
2019-12-16 13:14:11 +00:00
>LDYA L.MSG.NEWFILE
2020-02-14 07:21:56 +00:00
FILE.New.1 >PUSHYA
>PUSHWI 0 Allocate
>SYSCALL RealPath
2019-12-16 13:14:11 +00:00
bcs .9
txa
>STA.G hFileName
2020-01-26 19:36:49 +00:00
>LDYAI 1024
2019-11-12 16:39:22 +00:00
>STYA BufLen
>SYSCALL GetMem
bcs .9
2019-11-17 14:39:55 +00:00
>STYA BufPtr
2019-11-15 16:15:43 +00:00
>STYA.G BufBase
2019-11-12 16:39:22 +00:00
txa
2020-01-23 14:48:22 +00:00
>STA.G hBuf FileLen already set to 0
2019-11-12 16:39:22 +00:00
lda #0
sta (BufPtr)
stz FileLen
2019-11-06 13:14:42 +00:00
stz FileLen+1
2019-11-27 16:47:13 +00:00
2019-12-17 12:28:49 +00:00
jsr SCRN.Home
clc
2019-11-12 16:39:22 +00:00
.9 rts
2019-11-06 13:14:42 +00:00
*--------------------------------------
2019-11-12 16:39:22 +00:00
FILE.Load jsr BUF.ResetSel
2019-12-17 12:28:49 +00:00
jsr SCRN.UpdateStatusBar
2019-12-16 13:14:11 +00:00
2019-11-06 13:14:42 +00:00
>LDA.G hFileName
>SYSCALL GetMemPtr
2020-02-14 07:21:56 +00:00
>PUSHYA
>PUSHEA.G STATBUF
2020-02-28 16:30:16 +00:00
>SYSCALL Stat
2019-12-16 13:14:11 +00:00
bcc .1
>LDA.G hFileName
>SYSCALL GetMemPtr
2020-02-14 07:21:56 +00:00
jmp FILE.New.1
2019-11-12 16:39:22 +00:00
2020-02-12 14:42:07 +00:00
.1 >LDYAI 256
>SYSCALL GetMem
2020-04-02 06:32:25 +00:00
bcs .99
2019-11-06 13:14:42 +00:00
2020-02-12 14:42:07 +00:00
>STYA ZPPTR1
stx TmpByte
>LDA.G STATBUF+S.STAT.P.TYPE
cmp #S.FI.T.TXT
bne .2
2020-04-02 06:32:25 +00:00
2020-02-12 14:42:07 +00:00
jsr FILE.Load.TXT
2020-04-02 06:32:25 +00:00
jmp FILE.Close
2019-11-06 13:14:42 +00:00
2020-02-12 14:42:07 +00:00
.2 cmp #$FA S-C/ASM?
2020-04-02 06:32:25 +00:00
bne .9
2020-02-12 14:42:07 +00:00
2020-04-02 06:32:25 +00:00
jsr FILE.Load.ASM
jmp FILE.Close
2020-02-12 14:42:07 +00:00
2020-04-02 06:32:25 +00:00
.9 lda TmpByte
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2020-02-12 14:42:07 +00:00
2020-04-02 06:32:25 +00:00
lda #MLI.E.INCFF
sec
.99 rts
2019-11-12 16:39:22 +00:00
*--------------------------------------
FILE.Load.TXT stz FileLen
stz FileLen+1
2019-11-06 13:14:42 +00:00
2019-12-17 12:28:49 +00:00
jsr SCRN.Home
2019-11-12 16:39:22 +00:00
stz TmpIndex hFile
2019-11-06 13:14:42 +00:00
2019-11-12 16:39:22 +00:00
>STZ.G FileType
2019-11-06 13:14:42 +00:00
2020-02-11 16:32:33 +00:00
ldx #S.FI.T.TXT
jsr FILE.OpenTypeX
2020-01-27 16:33:11 +00:00
bcs .99
2019-11-06 16:25:00 +00:00
2020-02-14 07:21:56 +00:00
>PUSHA
2020-01-27 16:33:11 +00:00
>PUSHEA.G STATBUF
2020-02-14 07:21:56 +00:00
2020-02-28 16:30:16 +00:00
>SYSCALL FStat
2020-01-27 16:33:11 +00:00
bcs .99
2019-11-17 14:39:55 +00:00
2020-01-27 16:33:11 +00:00
jsr FILE.GetBuffer
.99 bcs .9
2020-07-27 14:09:19 +00:00
.1 ldy #254
jsr FILE.ReadY
2019-11-17 14:39:55 +00:00
bcs .7
2019-11-12 16:39:22 +00:00
lda #0
sta (ZPPTR1),y Y = line len
2020-01-27 16:33:11 +00:00
2019-11-17 14:39:55 +00:00
ldx #0
ldy #0
2020-01-27 16:33:11 +00:00
2019-11-12 16:39:22 +00:00
lda (ZPPTR1)
2019-11-17 14:39:55 +00:00
beq .8
2019-11-12 16:39:22 +00:00
eor #C.LF
bne .2
2019-11-06 16:25:00 +00:00
2019-11-17 14:39:55 +00:00
phy
2019-11-12 16:39:22 +00:00
lda #2
>STA.G FileType
2019-11-06 16:25:00 +00:00
2019-11-17 14:39:55 +00:00
ply
iny
2019-11-12 16:39:22 +00:00
2019-11-17 14:39:55 +00:00
.2 lda (ZPPTR1),y
beq .4
sta (BufPtr)
inc BufPtr
bne .3
inc BufPtr+1
.3 inx
iny
bra .2
.4 txa
clc
adc FileLen
sta FileLen
bcc .1
inc FileLen+1
2019-11-12 16:39:22 +00:00
bra .1
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
2019-11-17 14:39:55 +00:00
.HS B0 BCS
.9 sec
2020-04-02 06:32:25 +00:00
rts
2019-11-06 13:14:42 +00:00
*--------------------------------------
2020-02-11 16:32:33 +00:00
FILE.Load.ASM stz FileLen
stz FileLen+1
lda #4
>STA.G FileType
lda #8
jsr FILE.GetBufferA 2k buffer
bcs .9
ldx #$FA
jsr FILE.OpenTypeX
bcs .99
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 (ZPPTR1)
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
.HS B0 BCS
.9 sec
.99 rts
*--------------------------------------
FILE.Load.ASM.Decode
ldy #0
2020-02-28 16:30:16 +00:00
.1 lda (ZPPTR1),y
2020-02-11 16:32:33 +00:00
beq .8
iny
tax
bmi .2
jsr FILE.Load.ASM.2Buf
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
2020-02-28 16:30:16 +00:00
lda (ZPPTR1),y Get Repeat Count
2020-02-11 16:32:33 +00:00
iny
tax
2020-05-17 17:34:32 +00:00
.4 lda (ZPPTR1),y Get Repeat Char
2020-02-11 16:32:33 +00:00
2020-05-17 17:34:32 +00:00
jsr FILE.Load.ASM.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
2020-05-17 17:34:32 +00:00
jsr FILE.Load.ASM.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
*--------------------------------------
FILE.Load.ASM.2Buf
phy
phx
sta (BufPtr)
inc BufPtr
bne .1
inc BufPtr+1
.1 inc FileLen
bne .8
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
.9 plx
ply
rts
*--------------------------------------
2019-11-17 14:39:55 +00:00
FILE.Save >LDYAI 256
>SYSCALL GetMem
2019-12-16 13:14:11 +00:00
bcs FILE.Save.9
2019-11-17 14:39:55 +00:00
>STYA ZPPTR1
stx TmpByte
2019-11-12 16:39:22 +00:00
2019-11-17 14:39:55 +00:00
>LDA.G FileType
tax
2019-11-12 16:39:22 +00:00
2019-11-17 14:39:55 +00:00
jmp (J.SAVE,x)
2020-07-27 05:15:14 +00:00
2019-12-16 13:14:11 +00:00
FILE.Save.9 rts
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
jsr FILE.CreateTypeX
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
ldy #$ff
2019-11-06 13:14:42 +00:00
2019-11-17 14:39:55 +00:00
.2 iny
lda (BufPtr),y
sta (ZPPTR1),y
beq .3
cmp #C.CR
bne .2
iny
bit TmpIndex+1
bpl .3
iny
lda #C.LF
sta (ZPPTR1),y
.3 tya
beq .8
clc
adc BufPtr
sta BufPtr
2020-07-27 14:09:19 +00:00
bcc .7
2019-11-17 14:39:55 +00:00
inc BufPtr+1
2020-07-27 14:09:19 +00:00
.7 jsr FILE.WriteY
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
2020-07-27 14:09:19 +00:00
ldx #$FA S-C/ASM
jsr FILE.CreateTypeX
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 (ZPPTR1),y
iny
lda TmpLen+1
sta (ZPPTR1),y
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
2020-07-27 14:09:19 +00:00
.63 sta (ZPPTR1),y
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 (ZPPTR1),y
iny
2020-07-27 05:15:14 +00:00
2020-07-27 14:09:19 +00:00
txa
sta (ZPPTR1),y
iny
pla
sta (ZPPTR1),y
iny
bra .4
.61 txa
ora #$C0
.60 sta (ZPPTR1),y
iny
bra .4
.7 lda #0
sta (ZPPTR1),y
iny
tya
sta (ZPPTR1)
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
lda TmpByte
beq .1
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2019-12-16 13:14:11 +00:00
2019-12-17 12:28:49 +00:00
.1 lda TmpIndex
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
*--------------------------------------
2020-07-27 14:09:19 +00:00
FILE.OpenTypeX lda #O.RDONLY
bra FILE.Open
FILE.CreateTypeX
lda #O.CREATE+O.WRONLY
FILE.Open stz TmpIndex
phx
pha
>LDA.G hFileName
>SYSCALL GetMemPtr
>PUSHYA
pla access
>PUSHA
pla type
>PUSHA
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
sta TmpIndex
.9 rts
*--------------------------------------
2021-05-14 20:58:20 +00:00
FILE.ReadY phy
>PUSHB TmpIndex
2020-07-27 14:09:19 +00:00
>PUSHW ZPPTR1
2021-05-14 20:58:20 +00:00
ply
lda #0
>PUSHYA
2020-07-27 14:09:19 +00:00
>SYSCALL FRead
rts
*--------------------------------------
2021-05-14 20:58:20 +00:00
FILE.WriteY phy
>PUSHB TmpIndex
2020-07-27 14:09:19 +00:00
>PUSHW ZPPTR1
2021-05-14 20:58:20 +00:00
ply
lda #0
>PUSHYA
2020-07-27 14:09:19 +00:00
>SYSCALL FWrite
rts
*--------------------------------------
2019-11-12 16:39:22 +00:00
FILE.GetBuffer >LDA.G STATBUF+S.STAT.SIZE+3
dey
ora (pData),y
2020-02-11 16:32:33 +00:00
bne FILE.GetBuffer.9
2019-11-12 16:39:22 +00:00
dey
lda (pData),y Size HI
2020-01-27 16:33:11 +00:00
inc
inc
2020-02-11 16:32:33 +00:00
FILE.GetBufferA ldy #0 Size LO
2019-11-12 16:39:22 +00:00
>STYA BufLen
>SYSCALL GetMem
bcs .99
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
.99 rts
2019-11-12 16:39:22 +00:00
2020-02-11 16:32:33 +00:00
FILE.GetBuffer.9
lda #E.FTB
2019-11-12 16:39:22 +00:00
sec
2020-02-11 16:32:33 +00:00
rts
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