mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-03 12:06:05 +00:00
403 lines
6.9 KiB
Plaintext
403 lines
6.9 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF BIN/CHTYP
|
||
*--------------------------------------
|
||
.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
|
||
*--------------------------------------
|
||
ZPPtr1 .EQ ZPBIN
|
||
ZPPtr2 .EQ ZPBIN+2
|
||
ZPFileName .EQ ZPBIN+4
|
||
ZPFileStat .EQ ZPBIN+6
|
||
ZPFullPath .EQ ZPBIN+8
|
||
*--------------------------------------
|
||
* 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 CS
|
||
.DA DS.END-DS.START DS
|
||
.DA #16 SS
|
||
.DA #10 ZP
|
||
.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.FILE .DA MSG.FILE
|
||
L.MSG.OK .DA MSG.OK
|
||
L.MSG.ERR .DA MSG.ERR
|
||
L.PRODOS.FT.TXT .DA PRODOS.FT.TXT
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT
|
||
.1 >INC.G ArgCount
|
||
>SYSCALL ArgV
|
||
bcs .7
|
||
>STYA ZPPtr1
|
||
|
||
lda (ZPPtr1)
|
||
cmp #'-'
|
||
bne .4
|
||
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
|
||
ldx OptionList
|
||
|
||
.2 cmp OptionList,x
|
||
beq .3
|
||
dex
|
||
bne .2
|
||
|
||
.99 >PUSHBI 0
|
||
>LDYA L.MSG.USAGE
|
||
>SYSCALL printf
|
||
lda #E.SYN
|
||
sec
|
||
rts
|
||
|
||
.3 ldy OptionVars-1,x
|
||
lda #$80
|
||
sta (pData),y
|
||
bra .1
|
||
|
||
.4 ldy #index
|
||
lda (pData),y
|
||
bne .5
|
||
|
||
>LDYA ZPPtr1
|
||
jsr InitSrcDirYA
|
||
bcc .1
|
||
rts
|
||
|
||
.5 ldy #HexFileType
|
||
lda (pData),y
|
||
bne .99
|
||
|
||
jsr GetHexFileType
|
||
bcs .99
|
||
bra .1
|
||
|
||
.7 ldy #index processed all args
|
||
lda (pData),y
|
||
beq .99 , no src ? ERROR
|
||
|
||
ldy #HexFileType
|
||
lda (pData),y
|
||
beq .99 we also have a TYPE
|
||
|
||
>LDYAI 256
|
||
>SYSCALL getmem
|
||
bcs .99
|
||
>STYA ZPFullPath
|
||
txa
|
||
>STA.G hSrcFullPath
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN ldy #S.PS.hStdIn
|
||
lda (pPS),y
|
||
>SYSCALL feof
|
||
bcs .99
|
||
|
||
tay
|
||
bne .10
|
||
|
||
>SYSCALL GetChar
|
||
bcs .99
|
||
|
||
cmp #$03 Ctrl-C
|
||
beq .92 Abort....
|
||
|
||
cmp #$13 Ctrl-S
|
||
bne .10
|
||
|
||
>LDA.G bPause
|
||
eor #$ff
|
||
sta (pData),y
|
||
bne .80
|
||
|
||
.10 >LDA.G bPause
|
||
bne .80 Pause...
|
||
|
||
jsr GetEntry
|
||
bcs .9
|
||
|
||
jsr FilterMatch
|
||
bcs .8 no match, skip....
|
||
|
||
ldy #S.STAT.P.DRIVE
|
||
lda (ZPFileStat),y ProDOS Device ?
|
||
bne CS.RUN.DEV
|
||
|
||
ldy #S.STAT.P.TYPE
|
||
lda (ZPFileStat),y
|
||
cmp #$0F Directory ?
|
||
bne CS.RUN.FILE
|
||
|
||
jmp CS.RUN.DIR
|
||
|
||
.9 jsr LeaveSubDir
|
||
bcs .92
|
||
|
||
jsr BasePath..
|
||
|
||
.8 jsr GetNextEntry
|
||
.80 clc
|
||
rts
|
||
|
||
.92 lda #0
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.RUN.DIR
|
||
CS.RUN.DEV
|
||
.8 jsr GetNextEntry
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN.FILE jsr CS.RUN.GetFilePath
|
||
|
||
>PUSHW ZPFullPath
|
||
|
||
>PUSHBI 2
|
||
>LDYA L.MSG.FILE
|
||
>SYSCALL printf
|
||
bcs .9
|
||
|
||
ldy #HexFileType
|
||
>PUSHB (pData),y
|
||
|
||
>LDYA ZPFullPath
|
||
>SYSCALL ChTyp
|
||
jsr CS.RUN.CheckErr
|
||
|
||
>LDA.G bRecurse
|
||
bpl .8
|
||
|
||
lda (ZPFileName)
|
||
cmp #'.'
|
||
beq .8
|
||
|
||
>LDYA ZPFileName
|
||
jsr EnterSubDirYA
|
||
rts
|
||
|
||
.8 jsr GetNextEntry
|
||
clc
|
||
.9 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
|
||
*--------------------------------------
|
||
GetHexFileType ldy #$ff
|
||
|
||
.10 iny
|
||
lda (ZPPtr1),y
|
||
bne .10
|
||
|
||
cpy #3
|
||
bne .9
|
||
|
||
lda (ZPPtr1)
|
||
cmp #'0'
|
||
bne .1
|
||
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
jsr IsDigit16
|
||
bcs .9
|
||
asl
|
||
asl
|
||
asl
|
||
asl
|
||
>STA.G HexFileType
|
||
|
||
ldy #2
|
||
lda (ZPPtr1),y
|
||
jsr IsDigit16
|
||
bcs .9
|
||
|
||
>ORA.G HexFileType
|
||
sta (pData),y
|
||
clc
|
||
rts
|
||
|
||
.1 ldx #0
|
||
>LDYA L.PRODOS.FT.TXT
|
||
>STYA ZPPtr2
|
||
|
||
.2 ldy #2
|
||
|
||
.21 lda (ZPPtr1),y
|
||
cmp #'a'
|
||
bcc .4
|
||
cmp #'z'+1
|
||
bcs .4
|
||
eor #$20
|
||
|
||
.4 cmp (ZPPtr2),y
|
||
bne .5
|
||
dey
|
||
bpl .21
|
||
|
||
lda PRODOS.FT.ID,x
|
||
>STA.G HexFileType
|
||
clc
|
||
rts
|
||
|
||
.5 clc
|
||
lda ZPPtr2
|
||
adc #3
|
||
sta ZPPtr2
|
||
lda ZPPtr2+1
|
||
adc #0
|
||
sta ZPPtr2+1
|
||
inx
|
||
cpx #PRODOS.FT.COUNT
|
||
bne .2
|
||
|
||
.9 sec
|
||
rts
|
||
*---------------------------------------
|
||
IsDigit16 cmp #'0'
|
||
bcc .9
|
||
cmp #'9'+1
|
||
bcc .8
|
||
|
||
cmp #'A'
|
||
bcc .9
|
||
cmp #'F'+1
|
||
bcc .1
|
||
|
||
cmp #'a'
|
||
bcc .9
|
||
cmp #'f'+1
|
||
bcs .9
|
||
|
||
eor #$20
|
||
|
||
.1
|
||
* clc
|
||
sbc #'A'-11 cc so A->10 (11-CC)
|
||
clc
|
||
|
||
.8 and #$0F
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
.INB USR/SRC/BIN/X.FILEENUM.S
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
OptionList >PSTR "CRcr"
|
||
OptionVars .DA #bContinue,#bRecurse,#bContinue,#bRecurse
|
||
*--------------------------------------
|
||
MSG.USAGE .AS "Usage : CHTYP [File *,? wildcards allowed] [File type]\r\n"
|
||
.AS " File types : 0xx (Hexadecimal byte),SYS,TXT...\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.FILE .AZ "CHTYP File:%S..."
|
||
*--------------------------------------
|
||
PRODOS.FT.COUNT .EQ 6
|
||
PRODOS.FT.ID .HS 0406FAFCFDFF
|
||
PRODOS.FT.TXT .AS "TXT"
|
||
.AS "BIN"
|
||
.AS "ASM"
|
||
.AS "BAS"
|
||
.AS "VAR"
|
||
.AS "SYS"
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
ArgCount .BS 1
|
||
|
||
hFullPath .BS 1
|
||
hSrcFullPath .BS 1
|
||
STAT .BS S.STAT
|
||
Index .BS 1
|
||
hDIRs .BS X.MAX.RECURSE
|
||
hDIRENTs .BS X.MAX.RECURSE
|
||
oDIRENTs .BS X.MAX.RECURSE*2
|
||
hSrcBasePath .BS 1
|
||
hFilter .BS 1
|
||
bPause .BS 1
|
||
bContinue .BS 1
|
||
bRecurse .BS 1
|
||
HexFileType .BS 1
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/BIN/CHTYP.S
|
||
ASM
|