mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-28 10:52:33 +00:00
433 lines
7.2 KiB
Plaintext
433 lines
7.2 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF bin/chtyp
|
||
*--------------------------------------
|
||
.INB inc/macros.i
|
||
.INB inc/a2osx.i
|
||
.INB inc/mli.i
|
||
.INB inc/mli.e.i
|
||
*--------------------------------------
|
||
X.ENTER.SUBDIR .EQ 0
|
||
X.COPY.TO.DEST .EQ 0
|
||
X.DELETE.SOURCE .EQ 0
|
||
X.RESET.SRC.DIR .EQ 0
|
||
*--------------------------------------
|
||
* Zero Page Segment, up to 32 bytes
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR ZPBIN
|
||
ZS.START
|
||
|
||
ZPPtr1 .BS 2
|
||
ZPPtr2 .BS 2
|
||
ZPFileName .BS 2
|
||
ZPFileStat .BS 2
|
||
|
||
ZPFullPath .BS 2
|
||
|
||
ArgIndex .BS 1
|
||
HexFileType .BS 1
|
||
|
||
hSrcFullPath .BS 1
|
||
bPause .BS 1
|
||
|
||
bContinue .BS 1
|
||
bRecurse .BS 1
|
||
|
||
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 S.PS.F.EVENT
|
||
.DA #0
|
||
.DA CS.END-CS.START Code Size (without Constants)
|
||
.DA DS.END-DS.START Data SegmentSize
|
||
.DA #16 Stack Size
|
||
.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.FILE .DA MSG.FILE
|
||
L.MSG.OK .DA MSG.OK
|
||
L.MSG.ERR .DA MSG.ERR
|
||
L.PRODOS.FT.TXT .DA PRODOS.FT.TXT
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN inc ArgIndex
|
||
lda ArgIndex
|
||
>SYSCALL ArgV
|
||
bcs .7
|
||
|
||
>STYA ZPPtr1
|
||
lda (ZPPtr1)
|
||
cmp #'-'
|
||
bne .4
|
||
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
|
||
ldx #OptionVars-OptionList-1
|
||
.2 cmp OptionList,x
|
||
beq .3
|
||
|
||
dex
|
||
bne .2
|
||
|
||
.99 >LDYA L.MSG.USAGE
|
||
>SYSCALL PutS
|
||
lda #E.SYN
|
||
sec
|
||
rts
|
||
|
||
.3 ldy OptionVars,x
|
||
lda #$80
|
||
sta $0,y
|
||
bra CS.RUN
|
||
*--------------------------------------
|
||
.4 lda HexFileType
|
||
bne .5
|
||
|
||
jsr GetHexFileType
|
||
bcs .99
|
||
bra CS.RUN
|
||
|
||
.5 >LDA.G hSrcBasePath
|
||
bne .99
|
||
|
||
>LDYA ZPPtr1
|
||
jsr X.InitSrcDirYA
|
||
bcs .99
|
||
bra CS.RUN
|
||
*--------------------------------------
|
||
.7 >LDA.G hSrcBasePath
|
||
beq .99 no src ? ERROR
|
||
|
||
lda HexFileType
|
||
beq .99 we also have a TYPE
|
||
|
||
>LDYAI 256
|
||
>SYSCALL GetMem
|
||
bcs .99
|
||
>STYA ZPFullPath
|
||
stx hSrcFullPath
|
||
*--------------------------------------
|
||
CS.RUN.LOOP ldy #S.PS.hStdIn
|
||
lda (pPS),y
|
||
>SYSCALL FEOF
|
||
bcs .99
|
||
|
||
tay
|
||
bne .1
|
||
|
||
>SYSCALL GetChar
|
||
bcs .99
|
||
|
||
cmp #$03 Ctrl-C
|
||
beq .99 Abort....
|
||
|
||
cmp #$13 Ctrl-S
|
||
bne .1
|
||
|
||
lda bPause
|
||
eor #$ff
|
||
sta bPause
|
||
bne CS.RUN.LOOP
|
||
|
||
.1 bit bPause
|
||
bmi CS.RUN.LOOP Pause...
|
||
*--------------------------------------
|
||
jsr X.GetEntry
|
||
bcs CS.RUN.LEAVE
|
||
|
||
jsr X.IncludeMatch
|
||
bcs CS.RUN.NEXT no match, skip....
|
||
|
||
ldy #S.STAT.MODE+1
|
||
lda (ZPFileStat),y
|
||
and #$70
|
||
bne .5 REG file ?
|
||
|
||
jsr CS.RUN.FILE
|
||
bcc CS.RUN.NEXT
|
||
rts
|
||
|
||
.5 cmp /S.STAT.MODE.DIR DIR ?
|
||
bne .6
|
||
|
||
jsr CS.RUN.DIR
|
||
bcc CS.RUN.NEXT
|
||
rts
|
||
|
||
.6 lda #MLI.E.UNSUPST
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.RUN.NEXT jsr X.GetNextEntry
|
||
bcc CS.RUN.LOOP
|
||
|
||
CS.RUN.LEAVE jsr X.LeaveSubDir
|
||
bcs .90
|
||
|
||
jsr X.BasePath..
|
||
|
||
jmp CS.RUN.NEXT
|
||
|
||
.90 lda #0
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.RUN.DIR bit bRecurse
|
||
bpl .8
|
||
|
||
lda (ZPFileName)
|
||
cmp #'.'
|
||
bne .1
|
||
|
||
ldy #1
|
||
lda (ZPFileName),y
|
||
beq .8
|
||
|
||
cmp #'.'
|
||
bne .1
|
||
|
||
iny
|
||
lda (ZPFileName),y
|
||
beq .8
|
||
|
||
.1 jsr CS.RUN.GetFilePath
|
||
|
||
>LDYA ZPFileName
|
||
jmp X.EnterSubDirYA
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.FILE jsr X.IncludeMatch
|
||
bcs .8 no match, skip....
|
||
|
||
jsr CS.RUN.GetFilePath
|
||
|
||
>PUSHW L.MSG.FILE
|
||
>PUSHW ZPFullPath
|
||
>PUSHBI 2
|
||
>SYSCALL PrintF
|
||
bcs .9
|
||
|
||
>PUSHW ZPFullPath
|
||
|
||
>PUSHB HexFileType
|
||
|
||
>SYSCALL ChTyp
|
||
jsr CS.RUN.CheckErr
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN.CheckErr bcs .1
|
||
|
||
>LDYA L.MSG.OK
|
||
>SYSCALL PutS
|
||
rts
|
||
|
||
.1 pha
|
||
>PUSHW L.MSG.ERR
|
||
pla
|
||
pha
|
||
>PUSHA
|
||
>PUSHBI 1
|
||
>SYSCALL PrintF
|
||
|
||
lda bContinue
|
||
eor #$80
|
||
asl
|
||
pla
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.GetFilePath
|
||
>PUSHW ZPFullPath
|
||
>LDA.G hSrcBasePath
|
||
>SYSCALL GetMemPtr
|
||
>PUSHYA
|
||
>SYSCALL StrCpy
|
||
|
||
>PUSHW ZPFullPath
|
||
>PUSHW ZPFileName
|
||
>SYSCALL StrCat
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT jsr X.LeaveSubDir
|
||
bcc CS.QUIT
|
||
|
||
>LDA.G hInclude
|
||
beq .1
|
||
|
||
>SYSCALL FreeMem
|
||
|
||
.1 lda hSrcFullPath
|
||
beq .8
|
||
|
||
>SYSCALL FreeMem
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
GetHexFileType ldy #$ff
|
||
|
||
.10 iny
|
||
lda (ZPPtr1),y
|
||
bne .10
|
||
|
||
cpy #3
|
||
bne .9
|
||
|
||
lda (ZPPtr1)
|
||
cmp #'0'
|
||
bne .1
|
||
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
jsr IsDigit16
|
||
bcs .9
|
||
|
||
asl
|
||
asl
|
||
asl
|
||
asl
|
||
sta HexFileType
|
||
|
||
iny
|
||
lda (ZPPtr1),y
|
||
jsr IsDigit16
|
||
bcs .9
|
||
|
||
tsb HexFileType
|
||
* clc
|
||
rts
|
||
|
||
.1 ldx #0
|
||
|
||
>LDYA L.PRODOS.FT.TXT
|
||
>STYA ZPPtr2
|
||
|
||
.2 ldy #2
|
||
|
||
.21 lda (ZPPtr1),y
|
||
cmp #'a'
|
||
bcc .4
|
||
|
||
cmp #'z'+1
|
||
bcs .4
|
||
|
||
eor #$20
|
||
|
||
.4 cmp (ZPPtr2),y
|
||
bne .5
|
||
|
||
dey
|
||
bpl .21
|
||
|
||
lda PRODOS.FT.HEX,x
|
||
sta HexFileType
|
||
clc
|
||
rts
|
||
|
||
.5 clc
|
||
lda ZPPtr2
|
||
adc #3
|
||
sta ZPPtr2
|
||
bcc .6
|
||
|
||
inc ZPPtr2+1
|
||
|
||
.6 inx
|
||
cpx #PRODOS.FT.TXT-PRODOS.FT.HEX
|
||
bne .2
|
||
|
||
.9 sec
|
||
rts
|
||
*---------------------------------------
|
||
IsDigit16 cmp #'0'
|
||
bcc .9
|
||
|
||
cmp #'9'+1
|
||
bcc .8
|
||
|
||
cmp #'A'
|
||
bcc .9
|
||
|
||
cmp #'F'+1
|
||
bcc .1
|
||
|
||
cmp #'a'
|
||
bcc .9
|
||
|
||
cmp #'f'+1
|
||
bcs .9
|
||
|
||
eor #$20
|
||
.1
|
||
* clc
|
||
sbc #'A'-11 cc so A->10 (11-CC)
|
||
clc
|
||
|
||
.8 and #$0F
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
.INB usr/src/shared/x.fileenum.s
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
OptionList .AS "CRcr"
|
||
OptionVars .DA #bContinue,#bRecurse,#bContinue,#bRecurse
|
||
*--------------------------------------
|
||
MSG.USAGE .CS "Usage : CHTYP type [File *,? wildcards allowed]\r\n"
|
||
.CS " type : 0xx (Hexadecimal byte),SYS,TXT...\r\n"
|
||
.CS " -C : Continue on error\r\n"
|
||
.CZ " -R : Recurse subdirectories\r\n"
|
||
MSG.OK .CZ "[OK]"
|
||
MSG.ERR .CZ "[%h]\r\n"
|
||
MSG.FILE .CZ "CHTYP File:%S..."
|
||
*--------------------------------------
|
||
PRODOS.FT.HEX .HS 0406FAFCFDCBCCCFFF
|
||
PRODOS.FT.TXT .AS "TXT"
|
||
.AS "BIN"
|
||
.AS "ASM"
|
||
.AS "BAS"
|
||
.AS "VAR"
|
||
.AS "PIX"
|
||
.AS "FON"
|
||
.AS "PAK"
|
||
.AS "SYS"
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START .INB usr/src/shared/x.fileenum.g
|
||
DS.END .ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/chtyp.s
|
||
ASM
|