mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-22 16:31:07 +00:00
456 lines
7.9 KiB
Plaintext
456 lines
7.9 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF bin/attr
|
||
*--------------------------------------
|
||
.INB inc/macros.i
|
||
.INB inc/a2osx.i
|
||
.INB inc/mli.i
|
||
.INB inc/mli.e.i
|
||
*--------------------------------------
|
||
X.ENTER.SUBDIR .EQ 0
|
||
X.COPY.TO.DEST .EQ 0
|
||
X.DELETE.SOURCE .EQ 0
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR ZPBIN
|
||
ZS.START
|
||
ZPPtr1 .BS 2
|
||
ZPPtr2 .BS 2
|
||
ZPFileName .BS 2
|
||
ZPFileStat .BS 2
|
||
ZPFullPath .BS 2
|
||
|
||
ArgIndex .BS 1
|
||
bWrite .BS 1
|
||
AttrAND .BS 1
|
||
AttrORA .BS 1
|
||
ZS.END .ED
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
jmp (.1,x)
|
||
.DA #$61 6502,Level 1 (65c02)
|
||
.DA #1 BIN Layout Version 1
|
||
.DA 0
|
||
.DA CS.END-CS.START Code Size (without Constants)
|
||
.DA DS.END-DS.START Data SegmentSize
|
||
.DA #64 Stack Size
|
||
.DA #ZS.END-ZS.START Zero Page Size
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.MSG.USAGE .DA MSG.USAGE
|
||
L.MSG.DIRDUMP .DA MSG.DIRDUMP
|
||
L.MSG.FILEDUMP .DA MSG.FILEDUMP
|
||
L.MSG.DIR .DA MSG.DIR
|
||
L.MSG.FILE .DA MSG.FILE
|
||
L.MSG.OK .DA MSG.OK
|
||
L.MSG.ERR .DA MSG.ERR
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN dec AttrAND set mask = $ff
|
||
|
||
inc ArgIndex
|
||
lda ArgIndex
|
||
>SYSCALL ArgV
|
||
bcs .8
|
||
|
||
>STYA ZPPtr1
|
||
lda (ZPPtr1)
|
||
cmp #'-'
|
||
beq .1
|
||
|
||
cmp #'+'
|
||
bne .4
|
||
|
||
.1 jsr CS.RUN.CheckSwitch
|
||
bcc CS.RUN
|
||
|
||
.9 >PUSHW L.MSG.USAGE
|
||
>PUSHBI 0
|
||
>SYSCALL PrintF
|
||
lda #E.SYN
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
.4 >LDA.G hSrcBasePath
|
||
bne .9
|
||
|
||
>LDYA ZPPtr1
|
||
jsr InitSrcDirYA
|
||
bcc CS.RUN
|
||
rts
|
||
|
||
.8 >LDA.G hSrcBasePath
|
||
beq .9
|
||
|
||
>LDYAI 256
|
||
>SYSCALL GetMem
|
||
bcs .99
|
||
|
||
>STYA ZPFullPath
|
||
txa
|
||
>STA.G hSrcFullPath
|
||
*--------------------------------------
|
||
CS.RUN.LOOP ldy #S.PS.hStdIn
|
||
lda (pPS),y
|
||
>SYSCALL FEOF
|
||
bcs .99
|
||
|
||
tay
|
||
bne .1
|
||
|
||
>SYSCALL GetChar
|
||
bcs .99
|
||
|
||
cmp #$03 Ctrl-C
|
||
beq .99 Abort....
|
||
|
||
cmp #$13 Ctrl-S
|
||
bne .1
|
||
|
||
>LDA.G bPause
|
||
eor #$ff
|
||
sta (pData),y
|
||
bne CS.RUN.LOOP
|
||
|
||
.1 >LDA.G bPause
|
||
bne CS.RUN.LOOP Pause...
|
||
*--------------------------------------
|
||
jsr GetEntry
|
||
bcs CS.RUN.LEAVE
|
||
|
||
ldy #S.STAT.MODE+1
|
||
lda (ZPFileStat),y
|
||
and #$70
|
||
bne .5 REG file ?
|
||
|
||
jsr CS.RUN.FILE
|
||
bcc CS.RUN.NEXT
|
||
rts
|
||
|
||
.5 cmp /S.STAT.MODE.DIR DIR ?
|
||
beq .6
|
||
|
||
cmp /S.STAT.MODE.BDEV VOL ?
|
||
bne .9
|
||
|
||
.6 jsr CS.RUN.DIR
|
||
bcc CS.RUN.NEXT
|
||
rts
|
||
|
||
.9 lda #MLI.E.UNSUPST
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.RUN.NEXT jsr GetNextEntry
|
||
bcc CS.RUN.LOOP
|
||
|
||
CS.RUN.LEAVE jsr LeaveSubDir
|
||
bcs .90
|
||
|
||
jsr BasePath..
|
||
|
||
jmp CS.RUN.NEXT
|
||
|
||
.90 lda #0
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.RUN.DIR lda (ZPFileName)
|
||
cmp #'.'
|
||
bne .1
|
||
|
||
ldy #1
|
||
lda (ZPFileName),y
|
||
beq .8
|
||
|
||
cmp #'.'
|
||
bne .1
|
||
|
||
iny
|
||
lda (ZPFileName),y
|
||
beq .8
|
||
|
||
.1 jsr FilterMatch
|
||
bcs .8
|
||
|
||
jsr CS.RUN.GetFilePath
|
||
bcs .9
|
||
|
||
bit bWrite
|
||
bpl .2
|
||
|
||
>PUSHW L.MSG.DIR
|
||
>PUSHW ZPFullPath
|
||
>PUSHBI 2
|
||
>SYSCALL PrintF
|
||
bcs .9
|
||
|
||
jsr CS.RUN.SetAttr
|
||
bcc .7
|
||
|
||
rts
|
||
|
||
.2 >PUSHW L.MSG.DIRDUMP
|
||
|
||
jsr Access2CSTR
|
||
|
||
>PUSHW ZPFullPath
|
||
>PUSHBI 4
|
||
>SYSCALL PrintF
|
||
bcs .9
|
||
|
||
.7 >LDA.G bRecurse
|
||
bpl .8
|
||
|
||
>LDYA ZPFileName
|
||
jmp EnterSubDirYA
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN.FILE jsr FilterMatch
|
||
bcs .8
|
||
|
||
jsr CS.RUN.GetFilePath
|
||
bcs .9
|
||
|
||
bit bWrite
|
||
bpl .2
|
||
|
||
>PUSHW L.MSG.FILE
|
||
>PUSHW ZPFullPath
|
||
>PUSHBI 2
|
||
>SYSCALL PrintF
|
||
|
||
jmp CS.RUN.SetAttr
|
||
|
||
.2 >PUSHW L.MSG.FILEDUMP
|
||
|
||
jsr Access2CSTR
|
||
|
||
>PUSHW ZPFullPath
|
||
>PUSHBI 4
|
||
>SYSCALL PrintF
|
||
.9 rts
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.SetAttr >PUSHW ZPFullPath
|
||
|
||
ldy #S.STAT.P.ACCESS
|
||
lda (ZPFileStat),y
|
||
|
||
and AttrAND
|
||
ora AttrORA
|
||
>PUSHA
|
||
>SYSCALL SetAttr
|
||
bcs .1
|
||
|
||
>LDYA L.MSG.OK
|
||
>SYSCALL PutS
|
||
rts
|
||
|
||
.1 pha
|
||
>PUSHW L.MSG.ERR
|
||
pla
|
||
pha
|
||
>PUSHA
|
||
>PUSHBI 1
|
||
>SYSCALL PrintF
|
||
>LDA.G bContinue
|
||
eor #$80
|
||
asl
|
||
pla
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.GetFilePath
|
||
>PUSHW ZPFullPath
|
||
>LDA.G hSrcBasePath
|
||
>SYSCALL GetMemPtr
|
||
>PUSHYA
|
||
>SYSCALL StrCpy
|
||
|
||
>PUSHW ZPFullPath
|
||
>PUSHW ZPFileName
|
||
>SYSCALL StrCat
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.CheckSwitch
|
||
ldy #2
|
||
lda (ZPPtr1),y
|
||
bne .4
|
||
|
||
lda (ZPPtr1)
|
||
cmp #'-'
|
||
bne .9
|
||
|
||
dey
|
||
lda (ZPPtr1),y
|
||
|
||
ldx #OptionVars-OptionList-1
|
||
|
||
.2 cmp OptionList,x
|
||
beq .3
|
||
dex
|
||
bpl .2
|
||
|
||
.9 sec
|
||
rts
|
||
|
||
.3 ldy OptionVars,x
|
||
lda #$80
|
||
sta (pData),y
|
||
clc
|
||
rts
|
||
|
||
.4 iny
|
||
lda (ZPPtr1),y
|
||
bne .9
|
||
|
||
>LDYA ZPPtr1
|
||
>SYSCALL StrUpr
|
||
|
||
ldx #AttrMask-AttrList2-1
|
||
|
||
.5 ldy #1
|
||
lda (ZPPtr1),y
|
||
cmp AttrList1,x
|
||
bne .6
|
||
|
||
iny
|
||
lda (ZPPtr1),y
|
||
cmp AttrList2,x
|
||
beq .7
|
||
|
||
.6 dex
|
||
bpl .5
|
||
sec
|
||
rts
|
||
|
||
.7 sec
|
||
ror bWrite
|
||
|
||
lda (ZPPtr1)
|
||
cmp #'-'
|
||
beq .8
|
||
|
||
lda AttrMask,x
|
||
tsb AttrORA
|
||
clc
|
||
rts
|
||
|
||
.8 lda AttrMask,x
|
||
trb AttrAND
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
Access2CSTR ldy #S.STAT.P.ACCESS
|
||
lda (ZPFileStat),y
|
||
|
||
ldy #ATTR+15
|
||
ldx #15
|
||
|
||
.1 lsr
|
||
pha
|
||
bcc .2
|
||
|
||
lda ATTRS,x
|
||
sta (pData),y
|
||
dex
|
||
dey
|
||
lda ATTRS,x
|
||
sta (pData),y
|
||
bra .3
|
||
|
||
.2 lda #'-'
|
||
sta (pData),y
|
||
dex
|
||
dey
|
||
sta (pData),y
|
||
|
||
.3 pla
|
||
|
||
dey
|
||
dex
|
||
bpl .1
|
||
|
||
>PUSHEA.G ATTR
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT jsr LeaveSubDir
|
||
bcc CS.QUIT
|
||
>LDA.G hFilter
|
||
beq .1
|
||
>SYSCALL FreeMem
|
||
.1 >LDA.G hSrcFullPath
|
||
beq .8
|
||
>SYSCALL FreeMem
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
.INB usr/src/shared/x.fileenum.s
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
OptionList .AS "CRcr"
|
||
OptionVars .DA #bContinue,#bRecurse,#bContinue,#bRecurse
|
||
AttrList1 .AS "DRBIWR"
|
||
AttrList2 .AS "EENNRD"
|
||
AttrMask .DA #S.FI.A.D,#S.FI.A.RN,#S.FI.A.B,#S.FI.A.I,#S.FI.A.W,#S.FI.A.R
|
||
*--------------------------------------
|
||
ATTRS .AS "DeReBn----InWrRd"
|
||
*--------------------------------------
|
||
MSG.USAGE .AS "Usage : ATTR File(s) (*,? wildcards allowed)\r\n"
|
||
.AS " -C : Continue on error\r\n"
|
||
.AS " -R : Recurse subdirectories\r\n"
|
||
.AS "+|-De : Destroy enable\r\n"
|
||
.AS "+|-Re : Rename enable\r\n"
|
||
.AS "+|-Bn : Backup needed\r\n"
|
||
.AS "+|-In : Invisible\r\n"
|
||
.AS "+|-Wr : Write enable\r\n"
|
||
.AZ "+|-Rd : Read enable\r\n"
|
||
*--------------------------------------
|
||
MSG.OK .AZ "[OK]"
|
||
MSG.ERR .AZ "[%h]\r\n"
|
||
MSG.DIRDUMP .AZ "%s %s/\r\n"
|
||
MSG.FILEDUMP .AZ "%s %s\r\n"
|
||
MSG.DIR .AZ "Dir :%s..."
|
||
MSG.FILE .AZ "File:%s..."
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
bContinue .BS 1
|
||
bRecurse .BS 1
|
||
|
||
bPause .BS 1
|
||
hSrcFullPath .BS 1
|
||
|
||
ATTR .BS 17
|
||
|
||
.INB usr/src/shared/x.fileenum.g
|
||
|
||
DS.END .ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/attr.s
|
||
ASM
|