A2osX/BIN/CHMOD.S.txt

309 lines
6.0 KiB
Plaintext
Raw Normal View History

2019-04-19 05:42:43 +00:00
NEW
2019-05-02 09:52:32 +00:00
AUTO 3,1
2019-04-19 05:42:43 +00:00
.LIST OFF
.OP 65C02
.OR $2000
.TF BIN/CHMOD
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/MLI.I
.INB INC/MLI.E.I
*--------------------------------------
2019-04-30 16:08:47 +00:00
X.ENTER.SUBDIR .EQ 0
2019-04-19 05:42:43 +00:00
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
ZPMode .BS 2
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.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 >INC.G ArgIndex
>SYSCALL ArgV
bcs .8
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
ldy #1
lda (ZPPtr1),y
ldx OptionList
.2 cmp OptionList,x
beq .3
dex
bne .2
.9 >PUSHBI 0
>LDYA L.MSG.USAGE
>SYSCALL printf
lda #E.SYN
sec
.99 rts
.3 ldy OptionVars-1,x
lda #$80
sta (pData),y
bra CS.RUN
*--------------------------------------
.4 >LDA.G StrMode
bne .5
>LDA.G ArgIndex
>STA.G StrMode
bra CS.RUN
.5 >LDA.G hSrcBasePath
bne .9
>LDYA ZPPtr1
jsr InitSrcDirYA
bcc CS.RUN
rts
.8 >LDA.G StrMode
beq .9
jsr CS.RUN.Str2Mode
bcs .9
>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
2019-05-02 09:52:32 +00:00
bne .1
2019-04-19 05:42:43 +00:00
>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 .9
ldy #S.STAT.P.DRIVE
lda (ZPFileStat),y ProDOS Device ?
beq .5
jsr CS.RUN.DEV
bcc CS.RUN.LOOP
rts
.5 ldy #S.STAT.P.TYPE
lda (ZPFileStat),y
cmp #$0F Directory ?
bne .6
jsr CS.RUN.DIR
bcs .99
2019-10-03 06:25:27 +00:00
bra .8
2019-04-19 05:42:43 +00:00
.6 jsr CS.RUN.FILE
bcs .99
2019-10-03 06:25:27 +00:00
bra .8
2019-04-19 05:42:43 +00:00
.9 jsr LeaveSubDir
bcs .90
jsr BasePath..
.8 jsr GetNextEntry
jmp CS.RUN.LOOP
.90 lda #0
sec
.99 rts
*--------------------------------------
CS.RUN.DEV lda #E.BADPATH
2019-10-03 06:25:27 +00:00
sec
2019-04-19 05:42:43 +00:00
rts
*--------------------------------------
CS.RUN.DIR >LDA.G bRecurse
bpl .8
lda (ZPFileName)
cmp #'.'
beq .8
jsr CS.RUN.GetFilePath
>PUSHW ZPFullPath
>PUSHBI 2
>LDYA L.MSG.DIR
>SYSCALL printf
bcs .9
>PUSHW ZPMode
>LDYA ZPFullPath
>SYSCALL chmod
jsr CS.RUN.CheckErr
>LDYA ZPFileName
jsr EnterSubDirYA
rts
.8 clc
.9 rts
*--------------------------------------
2019-04-30 16:08:47 +00:00
CS.RUN.FILE jsr FilterMatch
2019-04-19 05:42:43 +00:00
bcs .8 no match, skip....
2019-04-30 16:08:47 +00:00
jsr CS.RUN.GetFilePath
2019-04-19 05:42:43 +00:00
>PUSHW ZPFullPath
>PUSHBI 2
>LDYA L.MSG.FILE
>SYSCALL printf
bcs .9
>PUSHW ZPMode
>LDYA ZPFullPath
>SYSCALL chmod
jsr CS.RUN.CheckErr
.8 clc
.9 rts
*--------------------------------------
CS.RUN.Str2Mode >SYSCALL ArgV
>STYA ZPPtr1
ldy #$ff
.1 iny
lda (ZPPtr1),y
bne .1
cpy #3
bne .9
stz ZPMode
stz ZPMode+1
dey
.2 lda (ZPPtr1),y
cmp #'0'
bcc .9
cmp #'7'+1
bcs .9
asl ZPMode
rol ZPMode+1
asl ZPMode
rol ZPMode+1
asl ZPMode
rol ZPMode+1
and #7
clc
adc ZPMode
sta ZPMode
bcc .3
inc ZPMode+1
.3 dey
bpl .2
clc
rts
.9 sec
rts
*--------------------------------------
CS.RUN.CheckErr bcs .1
>LDYA L.MSG.OK
>SYSCALL puts
rts
.1 pha
>PUSHA
>PUSHBI 1
>LDYA L.MSG.ERR
>SYSCALL printf
>LDA.G bContinue
eor #$80
asl
pla
rts
*--------------------------------------
CS.RUN.GetFilePath
>LDA.G hSrcBasePath
>SYSCALL GetMemPtr
>PUSHYA
>LDYA ZPFullPath
>SYSCALL StrCpy
>PUSHW ZPFileName
>LDYA ZPFullPath
>SYSCALL StrCat
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/BIN/X.FILEENUM.S
*--------------------------------------
CS.END
*--------------------------------------
OptionList >PSTR "CRcr"
OptionVars .DA #bContinue,#bRecurse,#bContinue,#bRecurse
*--------------------------------------
MSG.USAGE .AS "Usage : CHMOD mode [File *,? wildcards allowed]\r\n"
.AS " -C : Continue on error\r\n"
.AZ " -R : Recurse subdirectories\r\n"
MSG.OK .AZ "[OK]"
MSG.ERR .AZ "[%h]\r\n"
MSG.DIR .AZ "Reading Dir:%s..."
MSG.FILE .AZ "Adding File:%s..."
*--------------------------------------
.DUMMY
.OR 0
DS.START
ArgIndex .BS 1
bContinue .BS 1
bRecurse .BS 1
StrMode .BS 1
bPause .BS 1
hSrcFullPath .BS 1
2019-10-08 12:47:47 +00:00
.INB USR/SRC/BIN/X.FILEENUM.G
2019-04-19 05:42:43 +00:00
DS.END
.ED
*--------------------------------------
MAN
SAVE USR/SRC/BIN/CHMOD.S
ASM