Kernel version 0.8 : Migrating LS to new DIR/TIME API

This commit is contained in:
Rémy GIBERT 2016-10-13 18:00:27 +02:00
parent 754d3ec7f3
commit b9a3c10329
5 changed files with 227 additions and 64 deletions

Binary file not shown.

Binary file not shown.

View File

@ -33,40 +33,83 @@ CS.START cld
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.MSG.VOL .DA MSG.VOL
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.Buffer .DA TIME.Buffer
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBSTR
>SYSCALL SYS.LoadLibYA
sta hLIBSTR
>SYSCALL SYS.GetArgC
CS.INIT >SYSCALL SYS.GetArgC
cmp #1
bne .1
ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>SYSCALL SYS.NewPStrYA no arg, go get current prefix
stx hFullPath
bra .2
>SYSCALL SYS.OPENDIRYA
bcc .8 A=hDir
.99 rts
.1 lda #1
>SYSCALL SYS.GetArgA
>SYSCALL SYS.GetFullPathYA
stx hFullPath
.2 >SYSCALL SYS.OPENDIRYA
bcs .99
ldy #hDIR
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
jsr .99
lda (pPs)
ora #S.PS.F.EVENT Now accept events
@ -75,7 +118,7 @@ CS.INIT >LDYA L.LIBSTR
clc
rts
.99 pha
.9 pha
lda hFullPath
>SYSCALL SYS.FreeMemA
pla
@ -105,9 +148,9 @@ CS.RUN ldy #bCANCEL
.3 lda (ZPPtr1)
beq .8
beq .8 No more entry..exit
lda ZPPtr1
lda ZPPtr1 set Ptr2=Ptr1+LEN-> S.STAT
sec
adc (ZPPtr1)
sta ZPPtr2
@ -115,31 +158,32 @@ CS.RUN ldy #bCANCEL
adc #0
sta ZPPtr2+1
ldy #S.STAT.PRODOS.TYPE
lda (ZPPtr2),y
cmp #$0F Directory ?
bne .31
ldy #hFilter
lda (pData),y
beq .4 No filter....
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>PUSHW ZPPtr1
>LDYA L.MSG.DIR
>SYSCALL SYS.PrintFYA
>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
.31 ldy #S.STAT.PRODOS.AUXTYPE+1
.5 ldy #S.STAT.PRODOS.TYPE
lda (ZPPtr2),y
>PUSHA
dey
lda (ZPPtr2),y
>PUSHA
cmp #$0F Directory ?
bne .6
jsr CS.RUN.DIR
bra .7
dey
lda (ZPPtr2),y
jsr FileType2PSTR
>PUSHYA
>PUSHW ZPPtr1
>LDYA L.MSG.FILE
>SYSCALL SYS.PrintFYA
.6 jsr CS.RUN.FILE
.7 lda ZPPtr2
clc
@ -155,6 +199,81 @@ CS.RUN ldy #bCANCEL
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 >PUSHW ZPPtr1
>LDYA L.MSG.DIR
>SYSCALL SYS.PrintFYA
rts
*--------------------------------------
CS.RUN.FILE >PUSHW L.TIME.Buffer
>PUSHW L.TIME.Format
lda ZPPtr2
clc
adc #S.STAT.MTIME
tay
lda ZPPtr2+1
adc #0
>PUSHYA
>SYSCALL SYS.PStrFTime
>PUSHW L.TIME.Buffer ModTime
>PUSHW L.TIME.Buffer
>PUSHW L.TIME.Format
lda ZPPtr2
clc
adc #S.STAT.CTIME
tay
lda ZPPtr2+1
adc #0
>PUSHYA
>SYSCALL SYS.PStrFTime
>PUSHW L.TIME.Buffer Create Time
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.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
lda (pEvent),y
ldy #S.PS.hINDEV
@ -198,15 +317,12 @@ CS.QUIT ldy #hDIR
>SYSCALL SYS.CLOSEDIRA
ldy #hDIRPATH
ldy #hFilter
lda (pData),y
beq .3
>SYSCALL SYS.FreeMemA
.3 lda hLIBSTR
>SYSCALL SYS.UnloadLibA
clc
.3 clc
rts
*--------------------------------------
FileType2PSTR ldy #0
@ -243,10 +359,9 @@ FileType2PSTR ldy #0
rts
*--------------------------------------
CS.END
LIBSTR >PSTRING "libstr.o"
MSG.VOL >CSTRING "/%S\n"
MSG.DEV >CSTRING "%15S S%d,D%d Blocks Used:%5D,Total:%5D\n"
MSG.DIR >CSTRING "/%15S <dir>\n"
MSG.FILE >CSTRING "%15S %S $%H\n"
MSG.FILE >CSTRING "%15S %S $%H %10u %S %S\n"
*--------------------------------------
PRODOS.FT.HEX .HS 0406FAFCFDE2FF
PRODOS.FT.TXT >PSTRING "TXT"
@ -257,17 +372,18 @@ PRODOS.FT.TXT >PSTRING "TXT"
>PSTRING "ATK"
>PSTRING "SYS"
PRODOS.FT.DFLT >PSTRING "$ "
TIME.Format >PSTRING "%y-%b-%b %H:%M"
TIME.Buffer .BS 16
HEXDIGIT .AS '0123456789ABCDEF'
hLIBSTR .BS 1
hFullPath .BS 1
STAT .BS S.STAT
*--------------------------------------
.DUMMY
.OR 0
DS.START
hDIRPATH .BS 1
hDIR .BS 1
hVOLHEADER .BS 1
hDIRHEADER .BS 1
hFilter .BS 1
bSTOP .BS 1
bCANCEL .BS 1
DS.END

View File

@ -455,8 +455,13 @@ S.STAT.BLOCKS .EQ 34 DWORD
S.STAT.BLKSIZE .EQ 38 WORD
S.STAT.PRODOS.TYPE .EQ 40 BYTE
S.STAT.PRODOS.AUXTYPE .EQ 41 WORD
S.STAT.PRODOS.SLOT .EQ 42
S.STAT.PRODOS.DRIVE .EQ 43
S.STAT.PRODOS.DEVSTATUS .EQ 44
S.STAT.PRODOS.DEVCNFLCT .EQ 45
S.STAT.PRODOS.DEVBLOCKS .EQ 46
*
S.STAT .EQ 43
S.STAT .EQ 48
*--------------------------------------
* S.FILE for FOPEN,FREAD......
*--------------------------------------

View File

@ -14,7 +14,7 @@ AUTO 6
*--------------------------------------
K.OPENDIRYA jsr PFT.CheckPathYA
>STYA ZPQuickPtr2
>STYA MLICALL.PARAMS+1 For MLIOPEN
>STYA MLICALL.PARAMS+1 For GETFILEINFO,MLIOPEN
>PUSHWI S.DIR.PRODOS
>PUSHBI S.MEM.F.INIT0
@ -36,7 +36,13 @@ K.OPENDIRYA jsr PFT.CheckPathYA
sec
.9 rts
.7 >PUSHWI 1024 get a ProDOS IOBUF
.7 >MLICALL MLIGETFILEINFO
bcs .98 file/dir does not exists....quit
lda MLICALL.PARAMS+4
cmp #$0F Directory ?
bne .98
>PUSHWI 1024 get a ProDOS IOBUF
>PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE
jsr K.GetMem
bcs .98
@ -152,7 +158,7 @@ K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
tax
>LDYAI ZPQuickPtr4 Store actual PTR for MLIGETFILEINFO
>LDYA ZPQuickPtr4 Store actual PTR for MLIGETFILEINFO
>STYA MLICALL.PARAMS+1
txa
@ -169,9 +175,32 @@ K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
dex
bne .4
>MLICALL MLIGETFILEINFO
bcs .80
jsr K.READDIRA.ClrStat
lda (ZPQuickPtr2)
asl DRIVE in Carry
pha
lda #0
rol
inc
sta KrnBuf256+S.STAT.PRODOS.DRIVE
pla
lsr CC
lsr
lsr
lsr
lsr
sta KrnBuf256+S.STAT.PRODOS.SLOT
>MLICALL MLIGETFILEINFO
sta KrnBuf256+S.STAT.PRODOS.DEVSTATUS
bcs .80
>LDYA MLICALL.PARAMS+5 AUXTYPE=TOTAL BLOCKS
>STYA KrnBuf256+S.STAT.PRODOS.DEVBLOCKS
>LDYA MLICALL.PARAMS+8
>STYA KrnBuf256+S.STAT.BLOCKS
.80 jsr K.READDIRA.ADDSTAT
@ -453,6 +482,23 @@ K.READDIRA.ADDF jsr K.READDIRA.AddFNToBuf
lda (ZPQuickPtr3),y
sta KrnBuf256+S.STAT.PRODOS.TYPE
ldy #$13 blocks_used
lda (ZPQuickPtr3),y
sta KrnBuf256+S.STAT.BLOCKS
iny
lda (ZPQuickPtr3),y
sta KrnBuf256+S.STAT.BLOCKS+1
iny $15 EOF
lda (ZPQuickPtr3),y
sta KrnBuf256+S.STAT.SIZE
iny
lda (ZPQuickPtr3),y
sta KrnBuf256+S.STAT.SIZE+1
iny
lda (ZPQuickPtr3),y
sta KrnBuf256+S.STAT.SIZE+2
ldy #$1F auxtype
lda (ZPQuickPtr3),y
sta KrnBuf256+S.STAT.PRODOS.AUXTYPE
@ -481,7 +527,7 @@ K.READDIRA.ClrStat
ldx #S.STAT-1
.1 stz KrnBuf256,x
dey
dex
bpl .1
rts
*--------------------------------------
@ -506,19 +552,15 @@ K.READDIRA.AddToBuf
bne .8
inc ZPQuickPtr4+1
.8 rts
*--------------------------------------
ldy #S.STAT.BLKSIZE+1
lda #2 Block size is $200 for ProDOS
sta (ZPQuickPtr3),y
*--------------------------------------
* In :
* A = hDIR
*--------------------------------------
K.CLOSEDIRA jsr PFT.CheckDirA
pha
sta K.OPENDIRYA.hDIR
jsr K.GetMemPtrA
>STYA ZPQuickPtr1
K.CLOSEDIRA.1 ldy #S.DIR.PRODOS.REF
lda (ZPQuickPtr1),y
beq .1
@ -530,7 +572,7 @@ K.CLOSEDIRA.1 ldy #S.DIR.PRODOS.REF
beq .2
jsr K.FreeMemA
.2 pla
.2 lda K.OPENDIRYA.hDIR
jsr K.FreeMemA
clc
rts