2016-10-18 06:26:24 +00:00
|
|
|
|
PR#3
|
|
|
|
|
PREFIX /A2OSX.SRC
|
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2016-10-19 15:47:53 +00:00
|
|
|
|
* Uses: (pData)
|
2016-11-08 16:56:05 +00:00
|
|
|
|
* hDIRs .BS X.MAX.RECURSE+1
|
|
|
|
|
* hDIRENTs .BS X.MAX.RECURSE+1
|
|
|
|
|
* hSrcBasePath .BS 1
|
|
|
|
|
* hDstBasePath .BS 1 (optional)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DO X.DST.BASE.PATH=1
|
|
|
|
|
InitDstDirYA >SYSCALL GetFullPathYA
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
stx .90+1
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
.5 >PUSHWI 256
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>SYSCALL GetMem Get a 256 buffer to store DstBasePath
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr2
|
|
|
|
|
txa
|
|
|
|
|
ldy #hDstBasePath
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
sta (ZPPtr2)
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.6 lda (ZPPtr1),y
|
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
dey
|
|
|
|
|
bne .6
|
|
|
|
|
|
2016-11-13 21:03:31 +00:00
|
|
|
|
lda (ZPPtr2)
|
|
|
|
|
tay
|
|
|
|
|
lda #'/'
|
|
|
|
|
cmp (ZPPtr2),y
|
|
|
|
|
beq .7
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
tya
|
|
|
|
|
sta (ZPPtr2)
|
|
|
|
|
|
|
|
|
|
.7 jsr .9 Cleanup
|
2016-11-08 16:56:05 +00:00
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.99 rts
|
|
|
|
|
|
|
|
|
|
.9 pha
|
|
|
|
|
.90 lda #$ff self modified
|
|
|
|
|
>SYSCALL FreeMemA
|
|
|
|
|
pla
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.FIN
|
2016-10-19 15:47:53 +00:00
|
|
|
|
*--------------------------------------
|
2016-11-03 07:29:24 +00:00
|
|
|
|
InitSrcDirPatYA ldx #$80
|
|
|
|
|
.HS 2C bit abs
|
|
|
|
|
InitSrcDirYA ldx #0
|
|
|
|
|
stx .11+1
|
|
|
|
|
>SYSCALL GetFullPathYA
|
2016-10-20 16:04:35 +00:00
|
|
|
|
bcc .10
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.10 stx .90+1
|
2016-10-19 15:47:53 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #1
|
|
|
|
|
beq .5 we have '/'
|
|
|
|
|
|
2016-11-03 07:29:24 +00:00
|
|
|
|
.11 lda #$ff Self Modified
|
|
|
|
|
bmi .1 Force using pattern
|
|
|
|
|
|
2016-10-19 15:47:53 +00:00
|
|
|
|
>PUSHW L.STAT
|
|
|
|
|
>PUSHW ZPPtr1
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL STAT
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
2016-11-03 07:29:24 +00:00
|
|
|
|
bcs .1 File/DIR does not exists, go extract pattern
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
|
|
|
|
lda STAT+S.STAT.PRODOS.TYPE
|
|
|
|
|
cmp #$0f
|
2016-10-20 16:04:35 +00:00
|
|
|
|
beq .5 TYPE=DIR, do not extract wildcard
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
|
|
|
|
.1 lda (ZPPtr1)
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPPtr1),y search backward for a /
|
|
|
|
|
cmp #'/'
|
|
|
|
|
beq .3
|
|
|
|
|
dey
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
.3 tya
|
|
|
|
|
cmp (ZPPtr1)
|
2016-10-20 16:04:35 +00:00
|
|
|
|
beq .5 Make sure at least one char
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
phy save / pos to trunk string later
|
|
|
|
|
|
|
|
|
|
.4 iny
|
|
|
|
|
inx
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
sta UsrBuf256,x
|
|
|
|
|
tya
|
|
|
|
|
cmp (ZPPtr1)
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
pla get back / pos
|
|
|
|
|
sta (ZPPtr1) trunk it for Opendir
|
|
|
|
|
|
|
|
|
|
stx UsrBuf256
|
|
|
|
|
>LDYAI UsrBuf256
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL NewPstrYA
|
2016-10-19 15:47:53 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
txa
|
|
|
|
|
ldy #hFilter
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
.5 >PUSHWI 256
|
|
|
|
|
>PUSHBI 0
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL GetMem Get a 256 buffer to store BasePath
|
2016-10-19 15:47:53 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr2
|
|
|
|
|
txa
|
2016-11-08 16:56:05 +00:00
|
|
|
|
ldy #hSrcBasePath
|
2016-10-19 15:47:53 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2016-11-03 07:29:24 +00:00
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
sta (ZPPtr2)
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.6 lda (ZPPtr1),y
|
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
dey
|
|
|
|
|
bne .6
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
|
|
|
|
>LDYA ZPPtr1
|
2016-10-26 20:51:06 +00:00
|
|
|
|
>SYSCALL OpenDirYA
|
|
|
|
|
|
2016-10-19 15:47:53 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
ldy #hDIRs
|
2016-10-28 09:37:57 +00:00
|
|
|
|
sta (pData),y set hDIRs[0] = Src Hdir
|
2016-10-20 16:04:35 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
ldy #index
|
|
|
|
|
lda #1
|
2016-10-28 09:37:57 +00:00
|
|
|
|
sta (pData),y index=hDIRs[0]
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
|
|
|
|
jsr .9 Cleanup
|
|
|
|
|
|
|
|
|
|
clc
|
2016-10-20 16:04:35 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2016-10-19 15:47:53 +00:00
|
|
|
|
.9 pha
|
|
|
|
|
.90 lda #$ff self modified
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL FreeMemA
|
2016-10-19 15:47:53 +00:00
|
|
|
|
pla
|
|
|
|
|
sec
|
2016-10-28 09:37:57 +00:00
|
|
|
|
InitSrcDirYA.RTS
|
2016-10-19 15:47:53 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-10-26 20:51:06 +00:00
|
|
|
|
GetNextEntry ldy #index
|
2016-10-25 06:58:15 +00:00
|
|
|
|
lda (pData),y
|
2016-10-26 20:51:06 +00:00
|
|
|
|
tax keep index for later
|
|
|
|
|
clc
|
|
|
|
|
adc #hDIRENTs-1
|
2016-10-25 06:58:15 +00:00
|
|
|
|
tay
|
|
|
|
|
lda (pData),y
|
2016-10-26 20:51:06 +00:00
|
|
|
|
bne .1 we have a buffer to scan
|
2016-10-25 06:58:15 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
txa get back index....
|
|
|
|
|
clc
|
|
|
|
|
adc #hDIRs-1
|
|
|
|
|
tay
|
|
|
|
|
lda (pData),y
|
2016-10-25 06:58:15 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
>SYSCALL ReadDirA
|
2016-10-28 09:37:57 +00:00
|
|
|
|
bcs InitSrcDirYA.RTS
|
2016-10-26 20:51:06 +00:00
|
|
|
|
>STYA ZPPtr1
|
2016-10-25 06:58:15 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
ldy #index
|
|
|
|
|
lda (pData),y
|
|
|
|
|
pha save index for later
|
|
|
|
|
clc
|
|
|
|
|
adc #hDIRENTs-1
|
|
|
|
|
tay
|
2016-10-28 09:37:57 +00:00
|
|
|
|
txa get hDIRENT in A
|
2016-10-26 20:51:06 +00:00
|
|
|
|
sta (pData),y
|
2016-10-25 06:58:15 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
pla get back index
|
|
|
|
|
asl
|
|
|
|
|
adc #oDIRENTs-1 and reset offset for this buffer
|
|
|
|
|
tay
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
bra .2
|
|
|
|
|
|
|
|
|
|
.1 >SYSCALL GetMemPtrA
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
ldy #index
|
|
|
|
|
lda (pData),y
|
|
|
|
|
asl
|
2016-10-28 09:37:57 +00:00
|
|
|
|
adc #oDIRENTs-1 CC from ASL
|
2016-10-26 20:51:06 +00:00
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
lda ZPPtr1
|
|
|
|
|
* clc from ADC
|
|
|
|
|
adc (pData),y
|
|
|
|
|
sta ZPPtr1
|
|
|
|
|
|
|
|
|
|
lda ZPPtr1+1
|
|
|
|
|
iny
|
|
|
|
|
adc (pData),y
|
|
|
|
|
sta ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPPtr1) first/next DIRENT
|
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
sta (pData),y reset offset...
|
|
|
|
|
dey
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
ldy #index
|
|
|
|
|
lda (pData),y
|
|
|
|
|
clc
|
|
|
|
|
adc #hDIRENTs-1
|
|
|
|
|
tay
|
|
|
|
|
lda (pData),y
|
|
|
|
|
pha
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y reset hDIRENT
|
|
|
|
|
pla
|
|
|
|
|
>SYSCALL FreeMemA discard hDIRENT
|
|
|
|
|
|
|
|
|
|
bra GetNextEntry ...startover
|
|
|
|
|
|
|
|
|
|
.8 ldy #index
|
|
|
|
|
lda (pData),y
|
|
|
|
|
asl
|
|
|
|
|
adc #oDIRENTs-1
|
|
|
|
|
tay
|
2016-10-28 09:37:57 +00:00
|
|
|
|
|
|
|
|
|
lda (ZPPtr1) Add file len+1...
|
2016-10-26 20:51:06 +00:00
|
|
|
|
sec
|
2016-10-28 09:37:57 +00:00
|
|
|
|
adc #S.STAT +S.STAT
|
|
|
|
|
|
|
|
|
|
* clc from ADC
|
|
|
|
|
adc (pData),y Make oDIRENTs[i] point to next DIRENT
|
2016-10-26 20:51:06 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
lda (pData),y
|
|
|
|
|
adc #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2016-10-28 09:37:57 +00:00
|
|
|
|
lda ZPPtr1 set Ptr2=Ptr1+LEN-> S.STAT
|
|
|
|
|
sec
|
|
|
|
|
adc (ZPPtr1)
|
|
|
|
|
sta ZPPtr2
|
|
|
|
|
lda ZPPtr1+1
|
|
|
|
|
adc #0
|
|
|
|
|
sta ZPPtr2+1
|
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
clc
|
2016-10-28 09:37:57 +00:00
|
|
|
|
rts
|
2016-10-25 06:58:15 +00:00
|
|
|
|
*--------------------------------------
|
2016-10-20 16:04:35 +00:00
|
|
|
|
EnterSubDirYA >STYA ZPPtr2 save SUBDIR for StrCat
|
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
ldy #index
|
2016-10-20 16:04:35 +00:00
|
|
|
|
lda (pData),y
|
2016-11-08 16:56:05 +00:00
|
|
|
|
cmp #X.MAX.RECURSE
|
2016-10-26 20:51:06 +00:00
|
|
|
|
beq .9
|
2016-10-20 16:04:35 +00:00
|
|
|
|
|
2016-11-08 16:56:05 +00:00
|
|
|
|
ldy #hSrcBasePath
|
2016-11-13 21:03:31 +00:00
|
|
|
|
jsr EnterSubDirYA.1
|
2016-10-26 20:51:06 +00:00
|
|
|
|
|
2016-10-20 16:04:35 +00:00
|
|
|
|
>LDYA ZPPtr1
|
2016-10-26 20:51:06 +00:00
|
|
|
|
>SYSCALL OpenDirYA
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
bcs .9
|
2016-10-20 16:04:35 +00:00
|
|
|
|
pha
|
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
ldy #index
|
2016-10-20 16:04:35 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
inc
|
|
|
|
|
sta (pData),y
|
2016-10-26 20:51:06 +00:00
|
|
|
|
tax
|
|
|
|
|
* clc from BCS
|
|
|
|
|
adc #hDIRs-1
|
2016-10-20 16:04:35 +00:00
|
|
|
|
tay
|
|
|
|
|
pla
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
txa make sure hDIRENTs[i] is closed
|
|
|
|
|
adc #hDIRENTs-1
|
|
|
|
|
tay
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2016-11-13 21:03:31 +00:00
|
|
|
|
.DO X.DST.BASE.PATH=1
|
|
|
|
|
ldy #hDstBasePath
|
|
|
|
|
jsr EnterSubDirYA.1
|
|
|
|
|
.FIN
|
|
|
|
|
|
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
.9 rts
|
2016-11-13 21:03:31 +00:00
|
|
|
|
|
|
|
|
|
EnterSubDirYA.1 lda (pData),y
|
|
|
|
|
>SYSCALL GetMemPtrA
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1 save full path
|
|
|
|
|
|
|
|
|
|
>PUSHW ZPPtr2
|
|
|
|
|
>PUSHW ZPPtr1
|
|
|
|
|
>SYSCALL PStrCat
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
inc
|
|
|
|
|
tay
|
|
|
|
|
sta (ZPPtr1)
|
|
|
|
|
lda #'/'
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
rts
|
2016-10-19 15:47:53 +00:00
|
|
|
|
*--------------------------------------
|
2016-10-26 20:51:06 +00:00
|
|
|
|
LeaveSubDir ldy #index
|
2016-10-19 15:47:53 +00:00
|
|
|
|
lda (pData),y
|
2016-10-26 20:51:06 +00:00
|
|
|
|
beq .9
|
|
|
|
|
clc
|
|
|
|
|
adc #hDIRs-1
|
2016-10-20 16:04:35 +00:00
|
|
|
|
tay
|
|
|
|
|
lda (pData),y
|
2016-10-26 20:51:06 +00:00
|
|
|
|
pha
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
pla
|
|
|
|
|
>SYSCALL CloseDirA
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
ldy #index
|
|
|
|
|
lda (pData),y
|
|
|
|
|
dec
|
|
|
|
|
sta (pData),y
|
2016-11-01 21:37:12 +00:00
|
|
|
|
bne .8
|
|
|
|
|
|
2016-11-08 16:56:05 +00:00
|
|
|
|
ldy #hSrcBasePath
|
2016-11-01 21:37:12 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
>SYSCALL FreeMemA
|
2016-10-30 18:19:43 +00:00
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2016-11-01 21:37:12 +00:00
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
2016-10-30 18:19:43 +00:00
|
|
|
|
*--------------------------------------
|
2016-11-13 21:03:31 +00:00
|
|
|
|
BasePath.. .DO X.DST.BASE.PATH=1
|
|
|
|
|
ldy #hDstBasePath
|
|
|
|
|
jsr BasePath..1
|
|
|
|
|
.FIN
|
|
|
|
|
ldy #hSrcBasePath
|
|
|
|
|
|
|
|
|
|
BasePath..1 lda (pData),y
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL GetMemPtrA
|
2016-10-30 18:19:43 +00:00
|
|
|
|
|
2016-10-20 16:04:35 +00:00
|
|
|
|
>STYA ZPPtr1 save full path
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1) get len
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.1 dey At first run, discard ending /
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
cmp #'/'
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
sta (ZPPtr1) cut DIR2/ from /dir1/DIR2/
|
2016-10-19 15:47:53 +00:00
|
|
|
|
|
2016-10-26 20:51:06 +00:00
|
|
|
|
rts
|
2016-10-18 06:26:24 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2016-10-30 22:23:18 +00:00
|
|
|
|
SAVE BIN/X.FILEENUM.S
|