A2osX/BIN/CHTYP.S.txt

391 lines
6.9 KiB
Plaintext
Raw Normal View History

PR#3
PREFIX /A2OSX.BUILD
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/BIN/CHTYP
*--------------------------------------
.INB /A2OSX.BUILD/INC/MACROS.I
.INB /A2OSX.BUILD/INC/A2OSX.I
.INB /A2OSX.BUILD/INC/MLI.ERR.I
*--------------------------------------
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
*--------------------------------------
* 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 Length To Relocate
.DA DS.END-DS.START Data Segment to Allocate
.DA 0
.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.STAT .DA STAT
L.PRODOS.FT.TXT .DA PRODOS.FT.TXT-1
.DA 0
*--------------------------------------
CS.INIT >SYSCALL GetArgC
sta ArgCount
cmp #1
beq .99
2016-03-20 22:17:05 +00:00
stz ArgIndex
.1 dec ArgCount
beq .7
inc ArgIndex
lda ArgIndex
>SYSCALL GetArg.A
>STYA ZPPtr1
lda (ZPPtr1)
cmp #2
bne .4
ldy #1
lda (ZPPtr1),y
cmp #'-'
bne .4
iny
lda (ZPPtr1),y
ldx OptionList
.2 cmp OptionList,x
beq .3
dex
bne .2
.99 >LDYA L.MSG.USAGE
>SYSCALL PrintF.YA
lda #SYSMGR.ERRSYN
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
clc
rts
*--------------------------------------
CS.RUN >SYSCALL GetC
bcs .10 no char
cmp #$03 Ctrl-C
beq .92 Abort....
cmp #$13 Ctrl-S
bne .10
ldy #bPause
lda (pData),y
eor #$ff
sta (pData),y
bne .80
.10 ldy #bPause
lda (pData),y
bne .80 Pause...
jsr GetEntry
bcs .9
ldy #hFilter
lda (pData),y
beq .4 No filter....
>SYSCALL GetMemPtr.A
>PUSHYA
>PUSHW ZPFileName
>SYSCALL PStrMatch
bcs .8 no match, skip....
.4 ldy #S.STAT.P.DRIVE
lda (ZPFileStat),y ProDOS Device ?
bne .5
ldy #S.STAT.P.TYPE
lda (ZPFileStat),y
cmp #$0F Directory ?
bne .6
jmp CS.RUN.DIR
.5 jmp CS.RUN.DEV
.6 jmp CS.RUN.FILE
.9 jsr LeaveSubDir
bcs .92
jsr BasePath..
.8 jsr GetNextEntry
.80 clc
rts
.92 lda #0
sec
.99 rts
*--------------------------------------
CS.RUN.DIR
.8 jsr GetNextEntry
clc
.9 rts
*--------------------------------------
CS.RUN.DEV
.8 jsr GetNextEntry
clc
.9 rts
*--------------------------------------
CS.RUN.FILE jsr CS.RUN.GetFilePath
>PUSHWI UsrBuf256
>LDYA L.MSG.FILE
>SYSCALL PrintF.YA
bcs .9
ldy #HexFileType
>PUSHB (pData),y
>PUSHWI UsrBuf256
>SYSCALL ChTyp
jsr CS.RUN.CheckErr
ldy #bRecurse
lda (pData),y
bpl .8
ldy #1
lda (ZPFileName),y
cmp #'.'
beq .8
>LDYA ZPFileName
jsr EnterSubDirYA
rts
.8 jsr GetNextEntry
clc
.9 rts
*--------------------------------------
CS.RUN.CheckErr bcs .1
>LDYA L.MSG.OK
>SYSCALL PrintF.YA
rts
.1 pha
ldy #bContinue
lda (pData),y
bpl .2
pla
>PUSHA
>LDYA L.MSG.ERR
>SYSCALL PrintF.YA
bcs .9
rts
.2 lda #13
>SYSCALL PutChar.A
lda #10
>SYSCALL PutChar.A
pla
sec
.9 rts
*--------------------------------------
CS.RUN.GetFilePath
ldy #hSrcBasePath
lda (pData),y
>SYSCALL GetMemPtr.A
>PUSHYA
>PUSHWI UsrBuf256
>SYSCALL PStrCpy
>PUSHW ZPFileName
>PUSHWI UsrBuf256
>SYSCALL PStrCat
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT jsr LeaveSubDir
bcc CS.QUIT
ldy #hFilter
lda (pData),y
beq .3
>SYSCALL FreeMem.A
.3 clc
rts
*--------------------------------------
GetHexFileType lda (ZPPtr1)
cmp #3
bne .9
ldy #1
lda (ZPPtr1),y
cmp #'0'
bne .1
iny
lda (ZPPtr1),y
cmp #'0'
bcc .9
cmp #'9'+1
bcs .9
asl
asl
asl
asl
sta Tmp
iny
lda (ZPPtr1),y
cmp #'0'
bcc .9
cmp #'9'+1
bcs .9
and #$F
ora Tmp
ldy #HexFileType
sta (pData),y
clc
rts
.1 ldx #0
>LDYA L.PRODOS.FT.TXT
>STYA ZPPtr2
.2 ldy #3
.21 lda (ZPPtr1),y
cmp #'a'
bcc .3
cmp #'z'+1
bcs .3
eor #$20
.3 cmp (ZPPtr2),y
bne .4
dey
bne .21
lda PRODOS.FT.ID,x
ldy #HexFileType
sta (pData),y
clc
rts
.4 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
*--------------------------------------
.INB /A2OSX.SRC/BIN/X.FILEENUM.S
*--------------------------------------
CS.END
*--------------------------------------
OptionList >PSTR "CRcr"
OptionVars .DA #bContinue,#bRecurse,#bContinue,#bRecurse
*--------------------------------------
MSG.USAGE >CSTR "Usage : CHTYP [File *,? wildcards allowed] [File type : 0HH, SYS,TXT....]\r\n -C : Continue on error\r\n -R : Recurse subdirectories\r\n"
MSG.OK >CSTR "[Ok]\r\n"
MSG.ERR >CSTR "[%h]\r\n"
MSG.FILE >CSTR "CHTYP File:%S..."
STAT .BS S.STAT
ArgCount .BS 1
ArgIndex .BS 1
Tmp .BS 1
*--------------------------------------
PRODOS.FT.COUNT .EQ 7
PRODOS.FT.ID .HS 0406FAFCFDE2FF
PRODOS.FT.TXT .AS "TXT"
.AS "BIN"
.AS "S-C"
.AS "BAS"
.AS "VAR"
.AS "ATK"
.AS "SYS"
*--------------------------------------
.DUMMY
.OR 0
DS.START
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 /A2OSX.SRC/BIN/CHTYP.S
ASM