A2osX/BIN/PAK.S.txt

331 lines
5.9 KiB
Plaintext
Raw Normal View History

2019-04-03 05:51:28 +00:00
NEW
PREFIX
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
.TF BIN/PAK
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/MLI.I
.INB INC/MLI.E.I
*--------------------------------------
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
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
2019-04-17 15:31:18 +00:00
.DA #64 Stack Size
2019-04-03 05:51:28 +00:00
.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
*--------------------------------------
2019-04-05 05:59:06 +00:00
CS.INIT clc
rts
*--------------------------------------
CS.RUN >INC.G ArgIndex
2019-04-03 05:51:28 +00:00
>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
2019-04-05 05:59:06 +00:00
.9 >PUSHBI 0
2019-04-03 05:51:28 +00:00
>LDYA L.MSG.USAGE
>SYSCALL printf
lda #E.SYN
sec
2019-04-05 05:59:06 +00:00
.99 rts
2019-04-03 05:51:28 +00:00
.3 ldy OptionVars-1,x
lda #$80
sta (pData),y
2019-04-05 05:59:06 +00:00
bra CS.RUN
2019-04-03 05:51:28 +00:00
*--------------------------------------
.4 >LDA.G ArcName
bne .5
2019-04-17 15:31:18 +00:00
>LDA.G ArgIndex
>STA.G ArcName
bra CS.RUN
2019-04-03 05:51:28 +00:00
2019-04-17 15:31:18 +00:00
.5 >LDA.G hSrcBasePath
2019-04-05 05:59:06 +00:00
bne .9
2019-04-03 05:51:28 +00:00
>LDYA ZPPtr1
jsr InitSrcDirYA
2019-04-05 05:59:06 +00:00
bcc CS.RUN
2019-04-03 05:51:28 +00:00
rts
2019-04-17 15:31:18 +00:00
.8 >LDA.G ArcName
beq .9
>LDA.G hSrcBasePath
beq .9
>LDYAI 256
2019-04-03 05:51:28 +00:00
>SYSCALL getmem
bcs .99
>STYA ZPFullPath
txa
>STA.G hSrcFullPath
*--------------------------------------
2019-04-05 05:59:06 +00:00
CS.RUN.LOOP ldy #S.PS.hStdIn
2019-04-03 05:51:28 +00:00
lda (pPS),y
>SYSCALL feof
bcs .99
tay
2019-04-17 15:31:18 +00:00
beq .1
2019-04-03 05:51:28 +00:00
>SYSCALL GetChar
bcs .99
cmp #$03 Ctrl-C
2019-04-17 15:31:18 +00:00
beq .99 Abort....
2019-04-03 05:51:28 +00:00
cmp #$13 Ctrl-S
2019-04-17 15:31:18 +00:00
bne .1
2019-04-03 05:51:28 +00:00
>LDA.G bPause
eor #$ff
sta (pData),y
2019-04-17 15:31:18 +00:00
bne CS.RUN.LOOP
2019-04-03 05:51:28 +00:00
2019-04-17 15:31:18 +00:00
.1 >LDA.G bPause
bne CS.RUN.LOOP Pause...
2019-04-03 05:51:28 +00:00
jsr GetEntry
bcs .9
2019-04-17 15:31:18 +00:00
ldy #S.STAT.P.DRIVE
2019-04-03 05:51:28 +00:00
lda (ZPFileStat),y ProDOS Device ?
2019-04-17 15:31:18 +00:00
beq .5
2019-04-03 05:51:28 +00:00
2019-04-17 15:31:18 +00:00
jsr CS.RUN.DEV
bcc CS.RUN.LOOP
rts
.5 ldy #S.STAT.P.TYPE
2019-04-03 05:51:28 +00:00
lda (ZPFileStat),y
cmp #$0F Directory ?
2019-04-17 15:31:18 +00:00
bne .6
2019-04-03 05:51:28 +00:00
2019-04-17 15:31:18 +00:00
jsr CS.RUN.DIR
bcs .99
bra .8
2019-04-03 05:51:28 +00:00
2019-04-17 15:31:18 +00:00
.6 jsr CS.RUN.FILE
bcs .99
bra .8
2019-04-03 05:51:28 +00:00
.9 jsr LeaveSubDir
2019-04-17 15:31:18 +00:00
bcs .90
2019-04-03 05:51:28 +00:00
jsr BasePath..
.8 jsr GetNextEntry
2019-04-17 15:31:18 +00:00
jmp CS.RUN.LOOP
2019-04-03 05:51:28 +00:00
2019-04-17 15:31:18 +00:00
.90 lda #0
2019-04-03 05:51:28 +00:00
sec
.99 rts
*--------------------------------------
2019-04-17 15:31:18 +00:00
CS.RUN.DEV lda #E.BADPATH
sec
rts
*--------------------------------------
CS.RUN.DIR lda (ZPFileName)
cmp #'.'
beq .8
jsr CS.RUN.GetFilePath
2019-04-03 05:51:28 +00:00
>PUSHW ZPFullPath
>PUSHBI 2
>LDYA L.MSG.DIR
>SYSCALL printf
bcs .9
2019-04-17 15:31:18 +00:00
jsr CS.RUN.CheckErr
>LDA.G bRecurse
bpl .8
>LDYA ZPFileName
jsr EnterSubDirYA
rts
.8 clc
2019-04-03 05:51:28 +00:00
.9 rts
*--------------------------------------
2019-04-17 15:31:18 +00:00
CS.RUN.FILE >LDA.G hFilter
beq .3 No filter....
pha
ldy #S.STAT.FSID
lda (ZPFileStat),y
bne .1 not prodos...
pla
>SYSCALL GetMemPtr
>SYSCALL strupr
bra .2
.1 pla
>SYSCALL GetMemPtr
.2 jsr StrMatch
bcs .8 no match, skip....
.3 jsr CS.RUN.GetFilePath
2019-04-03 05:51:28 +00:00
>PUSHW ZPFullPath
>PUSHBI 2
>LDYA L.MSG.FILE
>SYSCALL printf
bcs .9
2019-04-17 15:31:18 +00:00
jsr CS.RUN.CheckErr
2019-04-03 05:51:28 +00:00
2019-04-17 15:31:18 +00:00
.8 clc
2019-04-03 05:51:28 +00:00
.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
*--------------------------------------
.INB USR/SRC/BIN/X.FILEENUM.S
*--------------------------------------
CS.END
*--------------------------------------
OptionList >PSTR "CRcr"
OptionVars .DA #bContinue,#bRecurse,#bContinue,#bRecurse
*--------------------------------------
MSG.USAGE .AS "Usage : PAK Archive [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"
2019-04-17 15:31:18 +00:00
MSG.DIR .AZ "Reading Dir:%s..."
MSG.FILE .AZ "Adding File:%s..."
2019-04-03 05:51:28 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
ArgIndex .BS 1
2019-04-17 15:31:18 +00:00
bContinue .BS 1
bRecurse .BS 1
ArcName .BS 1
bPause .BS 1
2019-04-03 05:51:28 +00:00
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
2019-04-17 15:31:18 +00:00
2019-04-03 05:51:28 +00:00
DS.END
.ED
*--------------------------------------
MAN
SAVE USR/SRC/BIN/PAK.S
ASM