mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 22:54:59 +00:00
402 lines
7.3 KiB
Plaintext
402 lines
7.3 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BOOT/BIN/LS
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
.INB INC/LIBSTR.I
|
||
*--------------------------------------
|
||
ZPPtr1 .EQ ZPBIN
|
||
ZPPtr2 .EQ ZPBIN+2
|
||
*--------------------------------------
|
||
* 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 Code Length To Relocate
|
||
.DA DS.END-DS.START Data Segment to Allocate
|
||
.DA 0
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.MSG.DEV .DA MSG.DEV
|
||
L.MSG.DIR .DA MSG.DIR
|
||
L.MSG.FILE .DA MSG.FILE
|
||
L.PRODOS.FT.TXT .DA PRODOS.FT.TXT
|
||
L.STAT .DA STAT
|
||
L.TIME.Format .DA TIME.Format
|
||
L.TIME.Create .DA TIME.Create
|
||
L.TIME.Mod .DA TIME.Mod
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT >SYSCALL SYS.GetArgC
|
||
cmp #1
|
||
bne .1
|
||
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>SYSCALL SYS.OPENDIRYA
|
||
bcc .8 A=hDir
|
||
.99 rts
|
||
|
||
.1 lda #1
|
||
>SYSCALL SYS.GetArgA
|
||
|
||
>SYSCALL SYS.GetFullPathYA
|
||
bcs .99
|
||
stx hFullPath
|
||
>STYA ZPPtr1
|
||
|
||
>PUSHW L.STAT
|
||
>PUSHW ZPPtr1
|
||
>SYSCALL SYS.STAT
|
||
|
||
bcc .7 File exists, do not extract wildcard
|
||
|
||
lda (ZPPtr1)
|
||
tay
|
||
|
||
.2 lda (ZPPtr1),y search backward for a /
|
||
cmp #'/'
|
||
beq .3
|
||
dey
|
||
bne .2
|
||
|
||
.3 tya
|
||
cmp (ZPPtr1)
|
||
beq .7 Make sure at least one char
|
||
|
||
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
|
||
>SYSCALL SYS.NewPstrYA
|
||
bcs .9
|
||
txa
|
||
ldy #hFilter
|
||
sta (pData),y
|
||
|
||
.7 >LDYA ZPPtr1
|
||
>SYSCALL SYS.OPENDIRYA
|
||
bcs .9
|
||
|
||
jsr .9 Cleanup
|
||
|
||
.8 ldy #hDIR A=hDir
|
||
sta (pData),y
|
||
|
||
lda (pPs)
|
||
ora #S.PS.F.EVENT Now accept events
|
||
sta (pPs)
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 pha
|
||
lda hFullPath
|
||
>SYSCALL SYS.FreeMemA
|
||
pla
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN ldy #bCANCEL
|
||
lda (pData),y
|
||
beq .1
|
||
sec
|
||
rts
|
||
|
||
.1 ldy #bSTOP
|
||
lda (pData),y
|
||
beq .2
|
||
clc
|
||
rts
|
||
|
||
.2 ldy #hDIR
|
||
lda (pData),y
|
||
>SYSCALL SYS.READDIRA
|
||
bcc .20
|
||
rts
|
||
|
||
.20 phx Save hDIRENT
|
||
>STYA ZPPtr1
|
||
|
||
.3 lda (ZPPtr1)
|
||
|
||
beq .8 No more entry..exit
|
||
|
||
lda ZPPtr1 set Ptr2=Ptr1+LEN-> S.STAT
|
||
sec
|
||
adc (ZPPtr1)
|
||
sta ZPPtr2
|
||
lda ZPPtr1+1
|
||
adc #0
|
||
sta ZPPtr2+1
|
||
|
||
ldy #hFilter
|
||
lda (pData),y
|
||
beq .4 No filter....
|
||
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>PUSHYA
|
||
>PUSHW ZPPtr1
|
||
>SYSCALL SYS.PStrMatch
|
||
bcs .7 no match, skip....
|
||
|
||
.4 ldy #S.STAT.PRODOS.DRIVE
|
||
lda (ZPPtr2),y ProDOS Device ?
|
||
beq .5
|
||
|
||
jsr CS.RUN.DEV
|
||
bra .7
|
||
|
||
.5 ldy #S.STAT.PRODOS.TYPE
|
||
lda (ZPPtr2),y
|
||
cmp #$0F Directory ?
|
||
bne .6
|
||
|
||
jsr CS.RUN.DIR
|
||
bra .7
|
||
|
||
.6 jsr CS.RUN.FILE
|
||
|
||
.7 lda ZPPtr2
|
||
clc
|
||
adc #S.STAT
|
||
sta ZPPtr1
|
||
lda ZPPtr2+1
|
||
adc #0
|
||
sta ZPPtr1+1
|
||
bra .3
|
||
|
||
.8 pla
|
||
>SYSCALL SYS.FreeMemA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.DEV ldy #S.STAT.PRODOS.DEVBLOCKS+1
|
||
>PUSHB (ZPPtr2),y
|
||
dey
|
||
>PUSHB (ZPPtr2),y
|
||
ldy #S.STAT.BLOCKS+1
|
||
>PUSHB (ZPPtr2),y
|
||
dey
|
||
>PUSHB (ZPPtr2),y
|
||
|
||
ldy #S.STAT.PRODOS.DRIVE
|
||
>PUSHB (ZPPtr2),y
|
||
dey SLOT
|
||
>PUSHB (ZPPtr2),y
|
||
|
||
>PUSHW ZPPtr1
|
||
>LDYA L.MSG.DEV
|
||
>SYSCALL SYS.PrintFYA
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.DIR jsr CS.RUN.PUSHDATES
|
||
|
||
>PUSHW ZPPtr1
|
||
>LDYA L.MSG.DIR
|
||
>SYSCALL SYS.PrintFYA
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.FILE jsr CS.RUN.PUSHDATES
|
||
|
||
lda ZPPtr2
|
||
clc
|
||
adc #S.STAT.SIZE
|
||
tay
|
||
lda ZPPtr2+1
|
||
adc #0
|
||
>PUSHYA File Size
|
||
|
||
ldy #S.STAT.PRODOS.AUXTYPE+1
|
||
lda (ZPPtr2),y
|
||
>PUSHA
|
||
dey
|
||
lda (ZPPtr2),y
|
||
>PUSHA AuxType
|
||
|
||
dey
|
||
lda (ZPPtr2),y
|
||
jsr FileType2PSTR
|
||
>PUSHYA Type
|
||
|
||
>PUSHW ZPPtr1
|
||
>LDYA L.MSG.FILE
|
||
>SYSCALL SYS.PrintFYA
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.PUSHDATES
|
||
>PUSHW L.TIME.Mod
|
||
>PUSHW L.TIME.Format
|
||
lda ZPPtr2
|
||
clc
|
||
adc #S.STAT.MTIME
|
||
tay
|
||
lda ZPPtr2+1
|
||
adc #0
|
||
>PUSHYA
|
||
>SYSCALL SYS.PStrFTime
|
||
|
||
>PUSHW L.TIME.Create
|
||
>PUSHW L.TIME.Format
|
||
lda ZPPtr2
|
||
clc
|
||
adc #S.STAT.CTIME
|
||
tay
|
||
lda ZPPtr2+1
|
||
adc #0
|
||
>PUSHYA
|
||
>SYSCALL SYS.PStrFTime
|
||
|
||
>PUSHW L.TIME.Mod ModTime
|
||
>PUSHW L.TIME.Create Create Time
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
|
||
lda (pEvent),y
|
||
ldy #S.PS.hINDEV
|
||
cmp (pPs),y
|
||
bne .9
|
||
|
||
lda (pEvent)
|
||
and #S.EVT.F.KEY is it a KEY event?
|
||
beq .9
|
||
|
||
ldy #S.EVT.DATAHI is it an O or SAPPLE key ?
|
||
lda (pEvent),y
|
||
bne .9
|
||
|
||
ldy #S.EVT.DATALO
|
||
lda (pEvent),y
|
||
cmp #$03 Ctrl-C
|
||
bne .1
|
||
|
||
lda #$FF
|
||
ldy #bCANCEL
|
||
sta (pData),y
|
||
bra .8
|
||
|
||
.1 cmp #$13 Ctrl-S
|
||
bne .8
|
||
|
||
ldy #bSTOP
|
||
lda (pData),y
|
||
eor #$FF
|
||
sta (pData),y
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT ldy #hDIR
|
||
lda (pData),y
|
||
|
||
>SYSCALL SYS.CLOSEDIRA
|
||
|
||
ldy #hFilter
|
||
lda (pData),y
|
||
beq .3
|
||
>SYSCALL SYS.FreeMemA
|
||
|
||
.3 clc
|
||
rts
|
||
*--------------------------------------
|
||
FileType2PSTR ldy #0
|
||
|
||
.1 cmp PRODOS.FT.HEX,y
|
||
beq .3
|
||
|
||
.2 iny
|
||
cpy #PRODOS.FT.TXT-PRODOS.FT.TXT
|
||
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
|
||
|
||
.3 tya
|
||
asl
|
||
asl CC
|
||
adc L.PRODOS.FT.TXT
|
||
tay
|
||
lda L.PRODOS.FT.TXT+1
|
||
adc #0
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
MSG.DEV >CSTRING "%15S S%d,D%d Blocks Used:%5D,Total:%5D\n"
|
||
MSG.DIR >CSTRING "/%15S <dir> %S %S\n"
|
||
MSG.FILE >CSTRING "%15S %S $%H %10u %S %S\n"
|
||
*--------------------------------------
|
||
PRODOS.FT.HEX .HS 0406FAFCFDE2FF
|
||
PRODOS.FT.TXT >PSTRING "TXT"
|
||
>PSTRING "BIN"
|
||
>PSTRING "S-C"
|
||
>PSTRING "BAS"
|
||
>PSTRING "VAR"
|
||
>PSTRING "ATK"
|
||
>PSTRING "SYS"
|
||
PRODOS.FT.DFLT >PSTRING "$ "
|
||
TIME.Format >PSTRING "%d-%b-%Y %H:%M"
|
||
TIME.Create .BS 20
|
||
TIME.Mod .BS 20
|
||
HEXDIGIT .AS '0123456789ABCDEF'
|
||
hFullPath .BS 1
|
||
STAT .BS S.STAT
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
hDIRPATH .BS 1
|
||
hDIR .BS 1
|
||
hFilter .BS 1
|
||
bSTOP .BS 1
|
||
bCANCEL .BS 1
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE BIN/LS.S
|
||
ASM
|