mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
551 lines
9.8 KiB
Plaintext
551 lines
9.8 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BUILD/BIN/LS
|
||
*--------------------------------------
|
||
.INB /A2OSX.BUILD/INC/MACROS.I
|
||
.INB /A2OSX.BUILD/INC/A2OSX.I
|
||
.INB /A2OSX.BUILD/INC/MLI.ERR.I
|
||
*--------------------------------------
|
||
X.COPY.TO.DEST .EQ 0
|
||
X.DELETE.SOURCE .EQ 0
|
||
*--------------------------------------
|
||
MAX.COL .EQ 4
|
||
*--------------------------------------
|
||
ZPPtr1 .EQ ZPBIN
|
||
ZPPtr2 .EQ ZPBIN+2
|
||
ZPFileName .EQ ZPBIN+4
|
||
ZPFileStat .EQ ZPBIN+6
|
||
*--------------------------------------
|
||
* 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 #16 SS
|
||
.DA #8 ZP
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.MSG.DEVEXT .DA MSG.DEVEXT
|
||
L.MSG.DIR .DA MSG.DIR
|
||
L.MSG.ENTER .DA MSG.ENTER
|
||
L.MSG.DIREXT .DA MSG.DIREXT
|
||
L.MSG.FILE .DA MSG.FILE
|
||
L.MSG.FILEEXT .DA MSG.FILEEXT
|
||
L.PRODOS.FT.TXT .DA PRODOS.FT.TXT
|
||
L.FMT.DateTime .DA FMT.DateTime
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT
|
||
.1 >INC.G ArgCount
|
||
>SYSCALL GetArg.A
|
||
bcs .6
|
||
>STYA ZPPtr1
|
||
|
||
lda (ZPPtr1)
|
||
cmp #'-'
|
||
bne .4
|
||
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
ldx OptionList
|
||
|
||
.2 cmp OptionList,x
|
||
beq .3
|
||
dex
|
||
bne .2
|
||
|
||
lda #K.E.SYN
|
||
sec
|
||
rts
|
||
|
||
.3 ldy OptionVars-1,x
|
||
lda #$80
|
||
sta (pData),y
|
||
bra .1
|
||
|
||
.4 >LDYA ZPPtr1
|
||
jsr InitSrcDirYA
|
||
bcs .9
|
||
|
||
bra .1 scan for any other args
|
||
|
||
.6 >LDA.G index do we have a Source dir ?
|
||
bne .8
|
||
|
||
.7 ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>SYSCALL GetMemPtr.A
|
||
jsr InitSrcDirYA
|
||
bcs .9
|
||
|
||
.8
|
||
* lda (pPs)
|
||
* ora #S.PS.F.EVENT Now accept events
|
||
* sta (pPs)
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN >SYSCALL GetChar
|
||
bcs .10 no char
|
||
|
||
cmp #$03 Ctrl-C
|
||
beq .92 Abort....
|
||
|
||
cmp #$13 Ctrl-S
|
||
bne .10
|
||
|
||
>LDA.G bPause
|
||
eor #$ff
|
||
sta (pData),y
|
||
bne .80
|
||
|
||
.10 >LDA.G bPause
|
||
bne .80 Pause...
|
||
|
||
jsr GetEntry
|
||
bcs .9
|
||
|
||
>LDA.G hFilter
|
||
beq .4 No filter....
|
||
|
||
>SYSCALL GetMemPtr.A
|
||
>PUSHYA
|
||
>PUSHW ZPFileName
|
||
>SYSCALL StrMatch
|
||
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
|
||
|
||
jmp CS.RUN.DIR
|
||
.5 jmp CS.RUN.DEV
|
||
.6 jmp CS.RUN.FILE
|
||
|
||
.9 ldy #bLong
|
||
lda (pData),y
|
||
bmi .91
|
||
|
||
jsr CS.RUN.NewLine
|
||
bcs .99
|
||
|
||
.91 jsr LeaveSubDir
|
||
bcs .92
|
||
|
||
jsr BasePath..
|
||
|
||
.8 jsr GetNextEntry
|
||
.80 clc
|
||
rts
|
||
|
||
.92 lda #0
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.RUN.DEV ldy #bLong
|
||
lda (pData),y
|
||
bpl CS.RUN.DIR
|
||
|
||
ldy #S.STAT.P.DEVBLOCKS+1
|
||
>PUSHB (ZPFileStat),y
|
||
dey
|
||
>PUSHB (ZPFileStat),y
|
||
ldy #S.STAT.BLOCKS+1
|
||
>PUSHB (ZPFileStat),y
|
||
dey
|
||
>PUSHB (ZPFileStat),y
|
||
|
||
ldy #S.STAT.P.DRIVE
|
||
>PUSHB (ZPFileStat),y
|
||
dey SLOT
|
||
>PUSHB (ZPFileStat),y
|
||
|
||
>PUSHW ZPFileName
|
||
>LDYA L.MSG.DEVEXT
|
||
>SYSCALL PrintF.YA
|
||
bcs .9
|
||
|
||
ldy #bRecurse
|
||
lda (pData),y
|
||
bpl .8
|
||
|
||
>LDYA ZPFileName
|
||
jsr EnterSubDirYA
|
||
bcs .9
|
||
jsr CS.RUN.ENTER.MSG
|
||
rts
|
||
|
||
.8 jsr GetNextEntry
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN.DIR >LDA.G bAllmostAll
|
||
bmi .10
|
||
|
||
lda (ZPFileName)
|
||
cmp #'.'
|
||
beq .5
|
||
|
||
.10 >LDA.G bLong
|
||
bmi .4
|
||
|
||
>PUSHW ZPFileName
|
||
>LDYA L.MSG.DIR
|
||
>SYSCALL PrintF.YA
|
||
bcs .9
|
||
|
||
ldy #0
|
||
|
||
.1 iny
|
||
lda (ZPFileName),y
|
||
bne .1
|
||
|
||
.11 iny
|
||
cpy #19
|
||
bcs .2
|
||
lda #' '
|
||
phy
|
||
>SYSCALL PutChar.A
|
||
ply
|
||
bcc .11
|
||
rts
|
||
|
||
.2 jsr CS.RUN.UpdateColCnt
|
||
bcc .5
|
||
rts
|
||
|
||
.4 jsr CS.RUN.PUSHDATES
|
||
|
||
jsr Mod2CSTR
|
||
>PUSHEA.G MOD File Mod
|
||
|
||
>PUSHW ZPFileName
|
||
>LDYA L.MSG.DIREXT
|
||
>SYSCALL PrintF.YA
|
||
bcs .9
|
||
|
||
.5 ldy #bRecurse
|
||
lda (pData),y
|
||
bpl .8
|
||
|
||
lda (ZPFileName)
|
||
cmp #'.'
|
||
beq .8
|
||
|
||
jsr CS.RUN.NewLine
|
||
bcs .9
|
||
|
||
>LDYA ZPFileName
|
||
jsr EnterSubDirYA
|
||
bcs .9
|
||
jsr CS.RUN.ENTER.MSG
|
||
rts
|
||
|
||
.8 jsr GetNextEntry
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN.FILE ldy #bLong
|
||
lda (pData),y
|
||
bmi .8
|
||
|
||
>PUSHW ZPFileName
|
||
>LDYA L.MSG.FILE
|
||
>SYSCALL PrintF.YA
|
||
bcs .9
|
||
|
||
jsr CS.RUN.UpdateColCnt
|
||
jsr GetNextEntry
|
||
clc
|
||
rts
|
||
|
||
.8 jsr CS.RUN.PUSHDATES
|
||
|
||
lda ZPFileStat
|
||
clc
|
||
adc #S.STAT.SIZE
|
||
tay
|
||
lda ZPFileStat+1
|
||
adc #0
|
||
>PUSHYA File Size
|
||
|
||
jsr Mod2CSTR
|
||
>PUSHEA.G MOD File Mod
|
||
|
||
ldy #S.STAT.P.AUXTYPE+1
|
||
lda (ZPFileStat),y
|
||
>PUSHA
|
||
dey
|
||
lda (ZPFileStat),y
|
||
>PUSHA AuxType
|
||
|
||
dey
|
||
lda (ZPFileStat),y
|
||
jsr FileType2PSTR
|
||
>PUSHYA Type
|
||
|
||
>PUSHW ZPFileName
|
||
>LDYA L.MSG.FILEEXT
|
||
>SYSCALL PrintF.YA
|
||
bcs .9
|
||
|
||
jsr GetNextEntry
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN.PUSHDATES
|
||
ldx #$ff
|
||
ldy #TIME.Mod-1 Set NODATE as default
|
||
|
||
.10 inx
|
||
iny
|
||
lda MSG.NODATE,x
|
||
sta (pData),y
|
||
bne .10
|
||
|
||
ldx #$ff
|
||
ldy #TIME.Create-1 Set NODATE as default
|
||
|
||
.11 inx
|
||
iny
|
||
lda MSG.NODATE,x
|
||
sta (pData),y
|
||
bne .11
|
||
|
||
ldy #S.STAT.MTIME+S.TIME.MONTH
|
||
lda (ZPFileStat),y
|
||
beq .1 Month=0.....invalid date/time
|
||
|
||
>PUSHEA.G TIME.Mod
|
||
>PUSHW L.FMT.DateTime
|
||
lda ZPFileStat
|
||
clc
|
||
adc #S.STAT.MTIME
|
||
tay
|
||
lda ZPFileStat+1
|
||
adc #0
|
||
>PUSHYA
|
||
>SYSCALL StrFTime
|
||
|
||
.1 ldy #S.STAT.CTIME+S.TIME.MONTH
|
||
lda (ZPFileStat),y
|
||
beq .2 Month=0.....invalid date/time
|
||
|
||
>PUSHEA.G TIME.Create
|
||
>PUSHW L.FMT.DateTime
|
||
lda ZPFileStat
|
||
clc
|
||
adc #S.STAT.CTIME
|
||
tay
|
||
lda ZPFileStat+1
|
||
adc #0
|
||
>PUSHYA
|
||
>SYSCALL StrFTime
|
||
|
||
.2 >PUSHEA.G TIME.Mod
|
||
>PUSHEA.G TIME.Create
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.UpdateColCnt
|
||
ldy #ColCount
|
||
lda (pData),y
|
||
inc
|
||
sta (pData),y
|
||
cmp #MAX.COL
|
||
bne CS.RUN.NewLine.8
|
||
|
||
lda #0
|
||
sta (pData),y
|
||
bra CS.RUN.NewLine.1
|
||
*--------------------------------------
|
||
CS.RUN.NewLine ldy #ColCount
|
||
lda (pData),y
|
||
beq CS.RUN.NewLine.8
|
||
CS.RUN.NewLine.1
|
||
lda #13
|
||
>SYSCALL PutChar.A
|
||
lda #10
|
||
>SYSCALL PutChar.A
|
||
rts
|
||
CS.RUN.NewLine.8
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.ENTER.MSG
|
||
ldy #hSrcBasePath
|
||
lda (pData),y
|
||
>SYSCALL GetMemPtr.A
|
||
>PUSHYA
|
||
>LDYA L.MSG.ENTER
|
||
>SYSCALL PrintF.YA
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT jsr LeaveSubDir
|
||
bcc CS.QUIT
|
||
|
||
ldy #hFilter
|
||
lda (pData),y
|
||
beq .3
|
||
>SYSCALL FreeMem.A
|
||
|
||
.3 clc
|
||
rts
|
||
*--------------------------------------
|
||
FileType2PSTR ldy #0
|
||
|
||
.1 cmp PRODOS.FT.HEX,y
|
||
beq .2
|
||
|
||
iny
|
||
cpy #PRODOS.FT.TXT-PRODOS.FT.HEX
|
||
bne .1
|
||
|
||
pha
|
||
lsr
|
||
lsr
|
||
lsr
|
||
lsr
|
||
tax
|
||
lda HEXDIGIT,x
|
||
sta PRODOS.FT.DFLT+2
|
||
|
||
pla
|
||
and #$0F
|
||
tax
|
||
lda HEXDIGIT,x
|
||
sta PRODOS.FT.DFLT+3
|
||
|
||
.2 tya
|
||
asl
|
||
asl CC
|
||
adc L.PRODOS.FT.TXT
|
||
tay
|
||
lda L.PRODOS.FT.TXT+1
|
||
adc #0
|
||
rts
|
||
*--------------------------------------
|
||
Mod2CSTR ldy #S.STAT.MODE+1
|
||
lda (ZPFileStat),y
|
||
|
||
lsr
|
||
lsr
|
||
lsr
|
||
lsr
|
||
tax
|
||
lda TYPES,x
|
||
>STA.G MOD
|
||
|
||
ldx #0
|
||
|
||
ldy #S.STAT.MODE
|
||
lda (ZPFileStat),y
|
||
|
||
ldy #MOD+1
|
||
|
||
.1 lsr
|
||
pha
|
||
|
||
lda #'-'
|
||
bcc .2
|
||
lda ACCESS,x
|
||
|
||
.2 sta (pData),y
|
||
iny
|
||
|
||
pla
|
||
|
||
inx
|
||
cpx #8
|
||
bne .1
|
||
|
||
.3 ldy #S.STAT.MODE+1
|
||
lda (ZPFileStat),y
|
||
lsr
|
||
lda #'-'
|
||
|
||
bcc .4
|
||
lda ACCESS,x
|
||
|
||
.4 >STA.G MOD+9
|
||
|
||
rts
|
||
*--------------------------------------
|
||
.INB /A2OSX.SRC/BIN/X.FILEENUM.S
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
OptionList >PSTR "ALRalr"
|
||
OptionVars .DA #bAllmostAll,#bLong,#bRecurse,#bAllmostAll,#bLong,#bRecurse
|
||
*--------------------------------------
|
||
MSG.DEVEXT >CSTR "%15s S%d,D%d Blocks Used:%5D Total:%5D\r\n"
|
||
MSG.DIR >CSTR "\e[32m%s/\e[0m"
|
||
MSG.ENTER >CSTR "Directory:%s\r\n"
|
||
MSG.DIREXT >CSTR "\e[32m%16s\e[0m <dir> %s %s %s\r\n"
|
||
MSG.FILE >CSTR "%19s"
|
||
MSG.FILEEXT >CSTR "%15s %S $%H %s %10u %s %s\r\n"
|
||
*--------------------------------------
|
||
PRODOS.FT.HEX .HS 0406FAFCFDE2FF
|
||
PRODOS.FT.TXT >PSTR "TXT"
|
||
>PSTR "BIN"
|
||
>PSTR "ASM"
|
||
>PSTR "BAS"
|
||
>PSTR "VAR"
|
||
>PSTR "ATK"
|
||
>PSTR "SYS"
|
||
PRODOS.FT.DFLT >PSTR "$ "
|
||
MSG.NODATE >CSTR " <No-Date> "
|
||
FMT.DateTime >CSTR "%d-%b-%y %H:%M"
|
||
HEXDIGIT .AS '0123456789ABCDEF'
|
||
TYPES .AS "-dbclssp"
|
||
ACCESS .AS "rwxrwxrwx"
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
ArgCount .BS 1
|
||
|
||
MOD .BS 11 drwxrwxrwx0
|
||
TIME.Create .BS 20
|
||
TIME.Mod .BS 20
|
||
|
||
hFilter .BS 1
|
||
bPause .BS 1
|
||
bAllmostAll .BS 1
|
||
bLong .BS 1
|
||
bRecurse .BS 1
|
||
|
||
ColCount .BS 1
|
||
|
||
.INB /A2OSX.SRC/BIN/X.FILEENUM.G
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/BIN/LS.S
|
||
ASM
|