2015-03-14 21:47:37 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2015-03-14 21:47:37 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.TF /A2OSX.BUILD/BIN/CHTYP
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.INB /A2OSX.BUILD/INC/MACROS.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/A2OSX.I
|
2017-08-22 06:37:03 +00:00
|
|
|
|
.INB /A2OSX.BUILD/INC/MLI.ERR.I
|
2017-04-03 15:35:03 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
X.COPY.TO.DEST .EQ 0
|
|
|
|
|
X.DELETE.SOURCE .EQ 0
|
2016-03-18 16:35:27 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
ZPPtr1 .EQ ZPBIN
|
|
|
|
|
ZPPtr2 .EQ ZPBIN+2
|
2017-04-03 15:35:03 +00:00
|
|
|
|
ZPFileName .EQ ZPBIN+4
|
|
|
|
|
ZPFileStat .EQ ZPBIN+6
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2015-11-22 22:30:06 +00:00
|
|
|
|
* File Header (16 Bytes)
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
2015-11-22 22:30:06 +00:00
|
|
|
|
.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
|
2016-03-18 16:35:27 +00:00
|
|
|
|
*--------------------------------------
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
2016-03-18 16:35:27 +00:00
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
2017-04-03 21:13:46 +00:00
|
|
|
|
L.MSG.FILE .DA MSG.FILE
|
2016-03-18 16:35:27 +00:00
|
|
|
|
L.MSG.OK .DA MSG.OK
|
|
|
|
|
L.MSG.ERR .DA MSG.ERR
|
2017-04-03 15:35:03 +00:00
|
|
|
|
L.STAT .DA STAT
|
2016-03-18 16:35:27 +00:00
|
|
|
|
L.PRODOS.FT.TXT .DA PRODOS.FT.TXT-1
|
2015-03-14 21:47:37 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
2017-04-03 15:35:03 +00:00
|
|
|
|
CS.INIT >SYSCALL GetArgC
|
|
|
|
|
sta ArgCount
|
2017-04-03 21:13:46 +00:00
|
|
|
|
cmp #1
|
|
|
|
|
beq .99
|
2016-03-20 22:17:05 +00:00
|
|
|
|
|
2017-04-03 21:13:46 +00:00
|
|
|
|
stz ArgIndex
|
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.1 dec ArgCount
|
2017-04-03 21:13:46 +00:00
|
|
|
|
beq .7
|
2016-03-18 16:35:27 +00:00
|
|
|
|
|
2017-04-03 21:13:46 +00:00
|
|
|
|
inc ArgIndex
|
|
|
|
|
lda ArgIndex
|
2017-08-24 12:46:48 +00:00
|
|
|
|
>SYSCALL GetArg.A
|
2016-03-18 16:35:27 +00:00
|
|
|
|
>STYA ZPPtr1
|
2017-04-03 15:35:03 +00:00
|
|
|
|
|
2016-03-18 16:35:27 +00:00
|
|
|
|
lda (ZPPtr1)
|
2017-04-03 15:35:03 +00:00
|
|
|
|
cmp #2
|
|
|
|
|
bne .4
|
|
|
|
|
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ldy #1
|
2016-03-18 16:35:27 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2017-04-03 15:35:03 +00:00
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
|
|
|
|
|
ldx OptionList
|
2016-03-18 16:35:27 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.2 cmp OptionList,x
|
|
|
|
|
beq .3
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 21:13:46 +00:00
|
|
|
|
.99 >LDYA L.MSG.USAGE
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2017-04-03 21:13:46 +00:00
|
|
|
|
lda #SYSMGR.ERRSYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.3 ldy OptionVars-1,x
|
|
|
|
|
lda #$80
|
2016-03-18 16:35:27 +00:00
|
|
|
|
sta (pData),y
|
2017-04-03 15:35:03 +00:00
|
|
|
|
bra .1
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 21:13:46 +00:00
|
|
|
|
.4 ldy #index
|
|
|
|
|
lda (pData),y
|
|
|
|
|
bne .5
|
|
|
|
|
|
|
|
|
|
>LDYA ZPPtr1
|
2017-04-03 15:35:03 +00:00
|
|
|
|
jsr InitSrcDirYA
|
2017-04-03 21:13:46 +00:00
|
|
|
|
bcc .1
|
|
|
|
|
rts
|
2017-04-03 15:35:03 +00:00
|
|
|
|
|
2017-04-03 21:13:46 +00:00
|
|
|
|
.5 ldy #HexFileType
|
|
|
|
|
lda (pData),y
|
|
|
|
|
bne .99
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 21:13:46 +00:00
|
|
|
|
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
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2017-04-03 15:35:03 +00:00
|
|
|
|
CS.RUN >SYSCALL GetC
|
|
|
|
|
bcs .10 no char
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
cmp #$03 Ctrl-C
|
|
|
|
|
beq .92 Abort....
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
cmp #$13 Ctrl-S
|
|
|
|
|
bne .10
|
|
|
|
|
|
|
|
|
|
ldy #bPause
|
2016-03-18 16:35:27 +00:00
|
|
|
|
lda (pData),y
|
2017-04-03 15:35:03 +00:00
|
|
|
|
eor #$ff
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bne .80
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.10 ldy #bPause
|
|
|
|
|
lda (pData),y
|
|
|
|
|
bne .80 Pause...
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
jsr GetEntry
|
|
|
|
|
bcs .9
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
ldy #hFilter
|
2016-03-18 16:35:27 +00:00
|
|
|
|
lda (pData),y
|
2017-04-03 15:35:03 +00:00
|
|
|
|
beq .4 No filter....
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2017-04-03 15:35:03 +00:00
|
|
|
|
>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
|
2016-03-18 16:35:27 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
jmp CS.RUN.DIR
|
|
|
|
|
.5 jmp CS.RUN.DEV
|
|
|
|
|
.6 jmp CS.RUN.FILE
|
2016-03-18 16:35:27 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.9 jsr LeaveSubDir
|
|
|
|
|
bcs .92
|
2016-03-18 16:35:27 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
jsr BasePath..
|
|
|
|
|
|
|
|
|
|
.8 jsr GetNextEntry
|
|
|
|
|
.80 clc
|
2015-03-14 21:47:37 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.92 lda #0
|
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
2017-04-03 21:13:46 +00:00
|
|
|
|
CS.RUN.DIR
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.8 jsr GetNextEntry
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-04-03 21:13:46 +00:00
|
|
|
|
CS.RUN.DEV
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.8 jsr GetNextEntry
|
2017-04-03 21:13:46 +00:00
|
|
|
|
clc
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-04-03 21:13:46 +00:00
|
|
|
|
CS.RUN.FILE jsr CS.RUN.GetFilePath
|
|
|
|
|
|
|
|
|
|
>PUSHWI UsrBuf256
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.FILE
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2017-04-03 21:13:46 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-04-04 13:07:58 +00:00
|
|
|
|
ldy #HexFileType
|
|
|
|
|
>PUSHB (pData),y
|
|
|
|
|
|
|
|
|
|
>PUSHWI UsrBuf256
|
|
|
|
|
>SYSCALL ChTyp
|
2017-04-03 21:13:46 +00:00
|
|
|
|
jsr CS.RUN.CheckErr
|
|
|
|
|
|
2017-04-04 13:07:58 +00:00
|
|
|
|
ldy #bRecurse
|
|
|
|
|
lda (pData),y
|
|
|
|
|
bpl .8
|
|
|
|
|
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPFileName),y
|
|
|
|
|
cmp #'.'
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
>LDYA ZPFileName
|
|
|
|
|
jsr EnterSubDirYA
|
|
|
|
|
rts
|
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.8 jsr GetNextEntry
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-04-03 21:13:46 +00:00
|
|
|
|
CS.RUN.CheckErr bcs .1
|
|
|
|
|
>LDYA L.MSG.OK
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2017-04-03 21:13:46 +00:00
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.1 pha
|
|
|
|
|
|
|
|
|
|
ldy #bContinue
|
|
|
|
|
lda (pData),y
|
|
|
|
|
bpl .2
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
>PUSHA
|
|
|
|
|
>LDYA L.MSG.ERR
|
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2017-04-03 21:13:46 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.2 lda #13
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL PutChar.A
|
2017-04-03 21:13:46 +00:00
|
|
|
|
lda #10
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL PutChar.A
|
2017-04-03 21:13:46 +00:00
|
|
|
|
pla
|
|
|
|
|
sec
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.GetFilePath
|
|
|
|
|
ldy #hSrcBasePath
|
|
|
|
|
lda (pData),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2017-04-03 21:13:46 +00:00
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHWI UsrBuf256
|
|
|
|
|
>SYSCALL PStrCpy
|
|
|
|
|
|
|
|
|
|
>PUSHW ZPFileName
|
|
|
|
|
>PUSHWI UsrBuf256
|
|
|
|
|
>SYSCALL PStrCat
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-04-03 15:35:03 +00:00
|
|
|
|
CS.DOEVENT sec
|
2015-03-14 21:47:37 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-04-03 15:35:03 +00:00
|
|
|
|
CS.QUIT jsr LeaveSubDir
|
|
|
|
|
bcc CS.QUIT
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
ldy #hFilter
|
2016-03-18 16:35:27 +00:00
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .3
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2017-04-03 15:35:03 +00:00
|
|
|
|
.3 clc
|
2016-03-18 16:35:27 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-04-03 21:13:46 +00:00
|
|
|
|
GetHexFileType lda (ZPPtr1)
|
2016-03-18 16:35:27 +00:00
|
|
|
|
cmp #3
|
|
|
|
|
bne .9
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2016-03-18 16:35:27 +00:00
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPPtr1),y
|
2017-04-03 21:13:46 +00:00
|
|
|
|
cmp #'0'
|
2016-03-18 16:35:27 +00:00
|
|
|
|
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
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2016-03-18 16:35:27 +00:00
|
|
|
|
.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
|
2015-03-14 21:47:37 +00:00
|
|
|
|
|
2016-03-18 16:35:27 +00:00
|
|
|
|
lda PRODOS.FT.ID,x
|
|
|
|
|
ldy #HexFileType
|
|
|
|
|
sta (pData),y
|
2015-03-14 21:47:37 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2016-03-18 16:35:27 +00:00
|
|
|
|
|
|
|
|
|
.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
|
2017-04-03 15:35:03 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB /A2OSX.SRC/BIN/X.FILEENUM.S
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
2017-04-03 15:35:03 +00:00
|
|
|
|
*--------------------------------------
|
2017-06-25 12:04:33 +00:00
|
|
|
|
OptionList >PSTR "CRcr"
|
|
|
|
|
OptionVars .DA #bContinue,#bRecurse,#bContinue,#bRecurse
|
2017-04-03 15:35:03 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-22 06:37:03 +00:00
|
|
|
|
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..."
|
2017-04-03 15:35:03 +00:00
|
|
|
|
STAT .BS S.STAT
|
|
|
|
|
ArgCount .BS 1
|
2017-04-03 21:13:46 +00:00
|
|
|
|
ArgIndex .BS 1
|
2016-03-18 16:35:27 +00:00
|
|
|
|
Tmp .BS 1
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-18 16:35:27 +00:00
|
|
|
|
PRODOS.FT.COUNT .EQ 7
|
2015-03-14 21:47:37 +00:00
|
|
|
|
PRODOS.FT.ID .HS 0406FAFCFDE2FF
|
2016-03-18 16:35:27 +00:00
|
|
|
|
PRODOS.FT.TXT .AS "TXT"
|
|
|
|
|
.AS "BIN"
|
|
|
|
|
.AS "S-C"
|
|
|
|
|
.AS "BAS"
|
|
|
|
|
.AS "VAR"
|
|
|
|
|
.AS "ATK"
|
|
|
|
|
.AS "SYS"
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-18 16:35:27 +00:00
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
2015-03-14 21:47:37 +00:00
|
|
|
|
DS.START
|
2017-04-03 15:35:03 +00:00
|
|
|
|
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
|
2017-04-03 21:13:46 +00:00
|
|
|
|
bContinue .BS 1
|
2017-04-03 15:35:03 +00:00
|
|
|
|
bRecurse .BS 1
|
2016-03-18 16:35:27 +00:00
|
|
|
|
HexFileType .BS 1
|
2015-03-14 21:47:37 +00:00
|
|
|
|
DS.END
|
2016-03-18 16:35:27 +00:00
|
|
|
|
.ED
|
2015-03-14 21:47:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/BIN/CHTYP.S
|
2015-03-14 21:47:37 +00:00
|
|
|
|
ASM
|