2017-10-16 15:41:48 +00:00
|
|
|
|
NEW
|
2019-04-10 07:45:09 +00:00
|
|
|
|
AUTO 3,1
|
2017-10-16 15:41:48 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.TF BIN/UNPAK
|
2017-10-16 15:41:48 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-23 15:28:42 +00:00
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.INB INC/MLI.E.I
|
2019-09-25 15:34:43 +00:00
|
|
|
|
.INB INC/PAK.I
|
2018-02-09 16:02:47 +00:00
|
|
|
|
*--------------------------------------
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
|
|
|
|
ZPPtr1 .BS 2
|
2019-09-24 15:25:07 +00:00
|
|
|
|
ZPPtr2 .BS 2
|
2019-09-23 14:08:17 +00:00
|
|
|
|
|
2019-09-24 15:25:07 +00:00
|
|
|
|
ZPInBufPtr .BS 2
|
|
|
|
|
ZPOutBufPtr .BS 2
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
2019-09-24 15:25:07 +00:00
|
|
|
|
ZPnCnt .BS 2
|
|
|
|
|
ZPInMask .BS 1
|
2019-10-14 05:23:09 +00:00
|
|
|
|
ZPBLOfsLBits .BS 1
|
|
|
|
|
ZPBLOfsHBits .BS 1
|
|
|
|
|
ZPBLLenBits .BS 1
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
|
|
|
|
ZPInBufLen .BS 2
|
|
|
|
|
ZPOutBufLen .BS 2
|
|
|
|
|
|
|
|
|
|
ZPFullPathPtr .BS 2
|
|
|
|
|
ZPRelPathPtr .BS 2
|
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
ZS.END .ED
|
2018-02-09 16:02:47 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-16 15:41:48 +00:00
|
|
|
|
* 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 #64 SS
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
2017-10-16 15:41:48 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
2019-10-03 06:25:27 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-16 15:41:48 +00:00
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
2019-09-23 14:08:17 +00:00
|
|
|
|
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.E.IARC .DA MSG.E.IARC
|
2017-10-16 15:41:48 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
2019-09-20 15:15:06 +00:00
|
|
|
|
CS.INIT clc
|
|
|
|
|
rts
|
2018-02-05 16:25:25 +00:00
|
|
|
|
*--------------------------------------
|
2019-09-23 14:08:17 +00:00
|
|
|
|
CS.RUN >LDYAI CHNK.SIZE
|
|
|
|
|
>SYSCALL getmem
|
|
|
|
|
bcs .9
|
|
|
|
|
>STYA ZPInBufPtr
|
|
|
|
|
txa
|
|
|
|
|
>STA.G hInBuf
|
|
|
|
|
|
|
|
|
|
lda #1
|
|
|
|
|
>SYSCALL Argv
|
2019-10-14 15:58:16 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
jsr CS.RUN.OpenArc
|
|
|
|
|
bcs .9
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
>LDYAI 256
|
|
|
|
|
>SYSCALL getmem
|
|
|
|
|
bcs .9
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
>STYA ZPFullPathPtr
|
|
|
|
|
txa
|
|
|
|
|
>STA.G hFullPath
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
lda #2
|
|
|
|
|
>SYSCALL Argv
|
|
|
|
|
bcc .1
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
ldy #S.PS.hCWD
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL getmemptr
|
|
|
|
|
|
|
|
|
|
.1 jsr CS.RUN.SetupPath
|
|
|
|
|
|
|
|
|
|
>LDYAI CHNK.SIZE
|
|
|
|
|
>SYSCALL getmem
|
|
|
|
|
bcs .9
|
2019-10-15 15:32:50 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
txa
|
|
|
|
|
>STA.G hOutBuf
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.LOOP
|
|
|
|
|
bcs .9
|
2018-02-05 16:25:25 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
lda #0
|
|
|
|
|
sec
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
.99 >PUSHBI 0
|
2019-09-20 15:15:06 +00:00
|
|
|
|
>LDYA L.MSG.USAGE
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
lda #E.SYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-09-23 14:08:17 +00:00
|
|
|
|
CS.RUN.SetupPath
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
sta (ZPFullPathPtr),y
|
|
|
|
|
bne .2
|
|
|
|
|
dey
|
|
|
|
|
lda #'/'
|
|
|
|
|
cmp (ZPFullPathPtr),y
|
|
|
|
|
beq .3
|
|
|
|
|
iny
|
|
|
|
|
sta (ZPFullPathPtr),y
|
|
|
|
|
.3 tya
|
|
|
|
|
sec
|
|
|
|
|
adc ZPFullPathPtr
|
|
|
|
|
sta ZPRelPathPtr
|
|
|
|
|
lda #0
|
|
|
|
|
adc ZPFullPathPtr+1
|
|
|
|
|
sta ZPRelPathPtr+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.LOOP jsr CS.RUN.GetByte
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
.10 cmp #CHNK.T.DIR
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.GetFileName
|
2019-10-17 10:36:45 +00:00
|
|
|
|
bcs .99
|
2019-09-23 14:08:17 +00:00
|
|
|
|
ldx #0
|
|
|
|
|
jsr CS.RUN.PrintFN
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.CheckDir
|
|
|
|
|
bcs .99
|
|
|
|
|
>LDYA L.MSG.OK
|
|
|
|
|
>SYSCALL puts
|
|
|
|
|
bra CS.RUN.LOOP
|
|
|
|
|
clc
|
|
|
|
|
.99 rts
|
2019-10-14 05:23:09 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.9 jmp CS.RUN.E.IARC
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.1 cmp #CHNK.T.FILE
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.GetFileType
|
2019-10-17 10:36:45 +00:00
|
|
|
|
bcs .99
|
2019-09-23 14:08:17 +00:00
|
|
|
|
|
|
|
|
|
jsr CS.RUN.GetFileName
|
2019-10-17 10:36:45 +00:00
|
|
|
|
bcs .99
|
2019-09-23 14:08:17 +00:00
|
|
|
|
|
|
|
|
|
ldx #2
|
|
|
|
|
jsr CS.RUN.PrintFN
|
|
|
|
|
jsr CS.RUN.OpenFile
|
2019-10-17 10:36:45 +00:00
|
|
|
|
bcs .99
|
2019-09-23 14:08:17 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
jsr CS.RUN.GetByte DATA
|
|
|
|
|
bcs .8 eof
|
|
|
|
|
.2 cmp #CHNK.T.DATA
|
|
|
|
|
bne .3 Could be a 0 byte file
|
|
|
|
|
|
2019-10-16 14:31:49 +00:00
|
|
|
|
.20 lda #'.'
|
|
|
|
|
>SYSCALL putchar
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.GetByte DataLen LO
|
2019-10-17 10:36:45 +00:00
|
|
|
|
bcs .99
|
2019-10-14 15:58:16 +00:00
|
|
|
|
sta ZPInBufLen
|
2019-09-23 14:08:17 +00:00
|
|
|
|
|
2019-10-14 15:58:16 +00:00
|
|
|
|
jsr CS.RUN.GetByte DataLen HI
|
2019-10-17 10:36:45 +00:00
|
|
|
|
bcs .99
|
2019-10-14 15:58:16 +00:00
|
|
|
|
sta ZPInBufLen+1
|
2019-10-16 14:31:49 +00:00
|
|
|
|
|
2019-10-14 15:58:16 +00:00
|
|
|
|
jsr CS.RUN.ReadData
|
2019-10-17 10:36:45 +00:00
|
|
|
|
bcs .99
|
2019-10-14 05:23:09 +00:00
|
|
|
|
|
2019-10-16 14:31:49 +00:00
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPInBufPtr),y
|
2019-10-14 15:58:16 +00:00
|
|
|
|
sta ZPOutBufLen
|
|
|
|
|
|
2019-10-16 14:31:49 +00:00
|
|
|
|
iny
|
2019-10-14 15:58:16 +00:00
|
|
|
|
lda (ZPInBufPtr),y
|
|
|
|
|
sta ZPOutBufLen+1
|
2019-10-15 06:43:24 +00:00
|
|
|
|
|
2019-10-15 15:32:50 +00:00
|
|
|
|
>LDA.G hOutBuf
|
|
|
|
|
>SYSCALL getmemptr
|
|
|
|
|
>STYA ZPOutBufPtr
|
|
|
|
|
|
2019-10-14 15:58:16 +00:00
|
|
|
|
jsr X.Unpak
|
2019-10-16 20:42:21 +00:00
|
|
|
|
bcs .9
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
jsr CS.RUN.WriteFile
|
2019-10-17 10:36:45 +00:00
|
|
|
|
bcs .99
|
2019-10-16 14:31:49 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
jsr CS.RUN.GetByte
|
|
|
|
|
bcs .8
|
2019-10-16 14:31:49 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
cmp #CHNK.T.DATA
|
|
|
|
|
beq .20
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.3 pha
|
|
|
|
|
jsr .8
|
|
|
|
|
pla
|
2019-10-14 15:58:16 +00:00
|
|
|
|
jmp .10
|
2019-09-23 14:08:17 +00:00
|
|
|
|
|
|
|
|
|
.8 >LDA.G hFile
|
|
|
|
|
>SYSCALL fclose
|
|
|
|
|
>LDYA L.MSG.OK
|
|
|
|
|
>SYSCALL puts
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.PrintFN >PUSHW ZPFullPathPtr
|
|
|
|
|
>PUSHBI 2
|
|
|
|
|
>LDYA L.MSG.DIR,x
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2019-09-23 14:08:17 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.OpenArc pha
|
|
|
|
|
>PUSHWZ Aux type
|
|
|
|
|
>PUSHBI $CF PAK
|
|
|
|
|
>PUSHBI O.RDONLY
|
|
|
|
|
pla
|
|
|
|
|
>SYSCALL FOpen
|
|
|
|
|
bcs .9
|
|
|
|
|
>STA.G hArcFile
|
|
|
|
|
pha
|
|
|
|
|
>PUSHWI 3
|
|
|
|
|
>PUSHW ZPInBufPtr
|
|
|
|
|
pla
|
|
|
|
|
>SYSCALL fread
|
|
|
|
|
bcs .9
|
|
|
|
|
cpy #3
|
|
|
|
|
bne .99
|
|
|
|
|
dey
|
|
|
|
|
.1 lda MSG.PAK,y
|
|
|
|
|
cmp (ZPInBufPtr),y
|
|
|
|
|
bne .99
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
.99
|
2019-10-16 20:42:21 +00:00
|
|
|
|
CS.RUN.E.IARC >PUSHBI 0
|
|
|
|
|
>LDYA L.MSG.E.IARC
|
|
|
|
|
>SYSCALL printf
|
2019-09-23 14:08:17 +00:00
|
|
|
|
lda #E.SYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.GetFileType
|
|
|
|
|
>PUSHWI 3
|
|
|
|
|
>PUSHEA.G FileType
|
|
|
|
|
>LDA.G hArcFile
|
|
|
|
|
>SYSCALL fread
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.GetFileName
|
|
|
|
|
jsr CS.RUN.GetByte
|
|
|
|
|
bcs .9
|
|
|
|
|
tay
|
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHW ZPRelPathPtr
|
|
|
|
|
>LDA.G hArcFile
|
|
|
|
|
>SYSCALL fread
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPRelPathPtr),y
|
|
|
|
|
|
2019-10-03 06:25:27 +00:00
|
|
|
|
* clc
|
|
|
|
|
.9 rts
|
2019-09-23 14:08:17 +00:00
|
|
|
|
*--------------------------------------
|
2019-10-14 15:58:16 +00:00
|
|
|
|
CS.RUN.ReadData >PUSHW ZPInBufLen
|
2019-10-16 14:31:49 +00:00
|
|
|
|
>LDA.G hInBuf
|
|
|
|
|
>SYSCALL getmemptr
|
|
|
|
|
>STYA ZPInBufPtr
|
|
|
|
|
>PUSHYA
|
2019-09-23 14:08:17 +00:00
|
|
|
|
>LDA.G hArcFile
|
|
|
|
|
>SYSCALL fread
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.GetByte >LDA.G hArcFile
|
|
|
|
|
>SYSCALL getc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.CheckDir >PUSHEA.G STAT
|
|
|
|
|
>LDYA ZPFullPathPtr
|
|
|
|
|
>SYSCALL stat
|
|
|
|
|
bcc .1
|
|
|
|
|
|
|
|
|
|
>LDYA ZPFullPathPtr
|
|
|
|
|
>SYSCALL mkdir
|
|
|
|
|
|
|
|
|
|
rts
|
2019-10-14 05:23:09 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.1 ldy #STAT+S.STAT.P.TYPE
|
|
|
|
|
lda (pData),y
|
|
|
|
|
cmp #$F
|
|
|
|
|
bne .99
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2019-10-14 05:23:09 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.99 lda #MLI.E.INVPATH
|
|
|
|
|
sec
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.OpenFile >PUSHW.G FileAuxType
|
|
|
|
|
>PUSHB.G FileType
|
|
|
|
|
>PUSHBI O.CREATE+O.WRONLY+O.TRUNC
|
|
|
|
|
>LDYA ZPFullPathPtr
|
|
|
|
|
>SYSCALL FOpen
|
|
|
|
|
bcs .9
|
|
|
|
|
>STA.G hFile
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.WriteFile
|
2019-10-14 15:58:16 +00:00
|
|
|
|
>PUSHW ZPOutBufLen
|
2019-10-15 15:32:50 +00:00
|
|
|
|
>LDA.G hOutBuf
|
|
|
|
|
>SYSCALL getmemptr
|
|
|
|
|
>PUSHYA
|
2019-09-23 14:08:17 +00:00
|
|
|
|
>LDA.G hFile
|
|
|
|
|
>SYSCALL fwrite
|
|
|
|
|
rts
|
2018-02-09 16:02:47 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-16 15:41:48 +00:00
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-09-23 14:08:17 +00:00
|
|
|
|
CS.QUIT >LDA.G hFile
|
2018-02-05 16:25:25 +00:00
|
|
|
|
beq .1
|
2019-09-23 14:08:17 +00:00
|
|
|
|
>SYSCALL fclose
|
2019-10-14 05:23:09 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.1 >LDA.G hFullPath
|
2018-02-05 16:25:25 +00:00
|
|
|
|
beq .2
|
2019-10-14 05:23:09 +00:00
|
|
|
|
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.2 >LDA.G hOutBuf
|
|
|
|
|
beq .3
|
2019-10-14 05:23:09 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
|
.3 >LDA.G hInBuf
|
|
|
|
|
beq .4
|
2019-10-14 05:23:09 +00:00
|
|
|
|
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2019-10-14 05:23:09 +00:00
|
|
|
|
|
2019-09-23 14:08:17 +00:00
|
|
|
|
.4 >LDA.G hArcFile
|
|
|
|
|
beq .8
|
|
|
|
|
>SYSCALL fclose
|
|
|
|
|
|
2019-09-20 15:15:06 +00:00
|
|
|
|
.8 clc
|
2017-10-16 15:41:48 +00:00
|
|
|
|
rts
|
2019-09-24 15:25:07 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB USR/SRC/SHARED/X.UNPAK.S
|
2017-10-16 15:41:48 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
2019-09-23 14:08:17 +00:00
|
|
|
|
MSG.USAGE .AZ "Usage : UNPAK Archive [DstDir]\r\n"
|
|
|
|
|
MSG.DIR .AZ "Creating Dir:%s..."
|
|
|
|
|
MSG.FILE .AZ "Extracting File:%s..."
|
|
|
|
|
MSG.OK .AZ "[OK]"
|
2019-10-16 20:42:21 +00:00
|
|
|
|
MSG.E.IARC .AZ "\r\nInvalid/corrupt archive"
|
2019-09-23 14:08:17 +00:00
|
|
|
|
MSG.PAK .AS "PAK"
|
2017-10-16 15:41:48 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2019-09-23 14:08:17 +00:00
|
|
|
|
hArcFile .BS 1
|
|
|
|
|
hFullPath .BS 1
|
|
|
|
|
hInBuf .BS 1
|
|
|
|
|
hOutBuf .BS 1
|
|
|
|
|
hFile .BS 1
|
|
|
|
|
FileType .BS 1
|
|
|
|
|
FileAuxType .BS 2
|
|
|
|
|
STAT .BS S.STAT
|
2017-10-16 15:41:48 +00:00
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2019-09-23 14:08:17 +00:00
|
|
|
|
SAVE USR/SRC/BIN/UNPAK.S
|
2017-10-16 15:41:48 +00:00
|
|
|
|
ASM
|