Kernel version 0.8 : Migrating CMDs to new CIO/DIR/TIME API

This commit is contained in:
Rémy GIBERT 2016-10-14 17:39:49 +02:00
parent f0659a7051
commit 9e7cf31491
8 changed files with 115 additions and 122 deletions

Binary file not shown.

Binary file not shown.

View File

@ -39,7 +39,8 @@ 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
L.TIME.Create .DA TIME.Create
L.TIME.Mod .DA TIME.Mod
.DA 0
*--------------------------------------
CS.INIT >SYSCALL SYS.GetArgC
@ -218,36 +219,14 @@ CS.RUN.DEV ldy #S.STAT.PRODOS.DEVBLOCKS+1
>SYSCALL SYS.PrintFYA
rts
*--------------------------------------
CS.RUN.DIR >PUSHW ZPPtr1
CS.RUN.DIR jsr CS.RUN.PUSHDATES
>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
CS.RUN.FILE jsr CS.RUN.PUSHDATES
lda ZPPtr2
clc
@ -274,6 +253,33 @@ CS.RUN.FILE >PUSHW L.TIME.Buffer
>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
@ -360,7 +366,7 @@ FileType2PSTR ldy #0
*--------------------------------------
CS.END
MSG.DEV >CSTRING "%15S S%d,D%d Blocks Used:%5D,Total:%5D\n"
MSG.DIR >CSTRING "/%15S <dir>\n"
MSG.DIR >CSTRING "/%15S <dir> %S %S\n"
MSG.FILE >CSTRING "%15S %S $%H %10u %S %S\n"
*--------------------------------------
PRODOS.FT.HEX .HS 0406FAFCFDE2FF
@ -372,8 +378,9 @@ PRODOS.FT.TXT >PSTRING "TXT"
>PSTRING "ATK"
>PSTRING "SYS"
PRODOS.FT.DFLT >PSTRING "$ "
TIME.Format >PSTRING "%y-%b-%d %H:%M"
TIME.Buffer .BS 16
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

View File

@ -36,7 +36,6 @@ CS.START cld
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBSTR .DA LIBSTR
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG2 .DA MSG2
@ -46,12 +45,7 @@ L.MSG5 .DA MSG5
L.MSG6 .DA MSG6
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBSTR
>SYSCALL SYS.LoadLibYA
bcs .9
sta hLIBSTR
ldy #MEM.COUNT Skip SLOT0
CS.INIT ldy #MEM.COUNT Skip SLOT0
lda (pData),y
inc
sta (pData),y
@ -79,8 +73,8 @@ CS.RUN ldy #bCANCEL
lda (pData),y
bne .1
>PUSHW L.MSG0
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LDYA L.MSG0
>SYSCALL SYS.PrintFYA
.1 ldy #MEM.COUNT
lda (pData),y
@ -129,20 +123,20 @@ CS.RUN ldy #bCANCEL
>PUSHB (pData),y
ldy #USED.COUNT
>PUSHB (pData),y
>PUSHW L.MSG2
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LDYA L.MSG2
>SYSCALL SYS.PrintFYA
>PUSHW MemMgr.HiMem
>PUSHW L.MSG3
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LDYA L.MSG3
>SYSCALL SYS.PrintFYA
>PUSHW MemMgr.Free
>PUSHW L.MSG4
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LDYA L.MSG4
>SYSCALL SYS.PrintFYA
>PUSHW MemMgr.LoMem
>PUSHW L.MSG5
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LDYA L.MSG5
>SYSCALL SYS.PrintFYA
lda MemMgr.Free
sec
@ -152,8 +146,8 @@ CS.RUN ldy #bCANCEL
sbc MemMgr.LoMem+1
>PUSHYA
>PUSHW L.MSG6
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LDYA L.MSG6
>SYSCALL SYS.PrintFYA
sec
rts
*--------------------------------------
@ -188,8 +182,8 @@ CS.RUN.PRINTMEM ldy #S.MEM.LEN
lda (pData),y
>PUSHA
>PUSHW L.MSG1
>LIBCALL hLIBSTR,LIBSTR.PRINTF
>LDYA L.MSG1
>SYSCALL SYS.PrintFYA
ldy #S.MEM.BIN
lda (ZPPTR1),y
@ -300,13 +294,10 @@ CS.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
.9 sec
rts
*--------------------------------------
CS.QUIT lda hLIBSTR
>SYSCALL SYS.UnloadLibA
clc
CS.QUIT clc
rts
*--------------------------------------
CS.END
LIBSTR >PSTRING "libstr.o"
MSG0 >CSTRING "hMem Flags PID REF PTR LEN BINPATH/DATA\n"
MSG1 >CSTRING " %03d %b %03d %03d $%H %05D "
MSG2 >CSTRING "\nAllocated hMem:%d, Total:%d\n"
@ -314,7 +305,6 @@ MSG3 >CSTRING "High Memory: $%H\n"
MSG4 >CSTRING "Free ULimit: $%H\n"
MSG5 >CSTRING "Low Memory: $%H\n"
MSG6 >CSTRING "\nFree Memory: %D Bytes.\n"
hLIBSTR .BS 1
*--------------------------------------
.DUMMY
.OR 0

View File

@ -451,13 +451,13 @@ DEC2HEX stz HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
bcs .9 overflow!!!
* bcs .9 overflow!!!
asl HEXBUF HEXBUF * 4 -> HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
bcs .9 overflow!!!
* bcs .9 overflow!!!
pla HEXBUF * 4 + HEXBUF -> HEXBUF
adc HEXBUF
@ -471,13 +471,13 @@ DEC2HEX stz HEXBUF
pla
adc HEXBUF+3
sta HEXBUF+3
bcs .99 overflow!!!
* bcs .99 overflow!!!
asl HEXBUF HEXBUF * 10 -> HEXBUF
rol HEXBUF+1
rol HEXBUF+2
rol HEXBUF+3
bcs .99 overflow!!!
* bcs .99 overflow!!!
inx
lda ASCBUF,x
@ -496,11 +496,11 @@ DEC2HEX stz HEXBUF
bne .1
rts
.9 pla discard saved HEXBUF
pla
pla
pla
.99 rts
*.9 pla discard saved HEXBUF
* pla
* pla
* pla
*.99 rts
*--------------------------------------
*ACCESS .AS "drwxrwxrwx"
HEXBUF .BS 4 32 bits max

View File

@ -22,7 +22,7 @@ K.OPENDIRYA jsr PFT.CheckPathYA
bcs .9
>STYA ZPQuickPtr1
stx K.OPENDIRYA.hDIR
stx K.READDIRA.hDir
lda (ZPQuickPtr2)
cmp #1 One char ?
@ -59,7 +59,7 @@ K.OPENDIRYA jsr PFT.CheckPathYA
ldy #S.DIR.PRODOS.REF
sta (ZPQuickPtr1),y
.8 lda K.OPENDIRYA.hDIR
.8 lda K.READDIRA.hDir
clc
rts
@ -69,24 +69,25 @@ K.OPENDIRYA jsr PFT.CheckPathYA
sec
.99 rts
*--------------------------------------
K.OPENDIRYA.hDIR .BS 1
*--------------------------------------
* In :
* A = hDIR
* Out :
* CC : X = hDIREND, Y,A = PTR to S.DIRENT
* CS : A = EC, A = 0 : no more entry
*--------------------------------------
K.READDIRA.hDir .BS 1
K.READDIRA.hMem .BS 1
K.READDIRA.hDIRENT .BS 1
K.READDIRA.BufSize .BS 2
K.READDIRA.EL .BS 1
K.READDIRA.EBP .BS 1
K.READDIRA.EC .BS 2
K.READDIRA.ECIB .BS 1
K.READDIRA.EC2Return .BS 1
*--S.DIR Cache ------------------------
K.READDIRA.EL .BS 1
K.READDIRA.EPB .BS 1
K.READDIRA.EC .BS 2
*--------------------------------------
K.READDIRA jsr PFT.CheckDirA
sta K.READDIRA.hDir
jsr K.GetMemPtrA
>STYA ZPQuickPtr1
@ -227,9 +228,7 @@ K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
tax
jmp K.GetMemPtrA
*--------------------------------------
K.READDIRA.DIR ldy #S.DIR.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1
K.READDIRA.DIR sta MLICALL.PARAMS+1 A=#S.DIR.PRODOS.REF
>PUSHWI 512 Get a 512 bytes buffer for reading dir...
>PUSHBI 0
@ -284,12 +283,12 @@ K.READDIRA.DIR ldy #S.DIR.PRODOS.REF
bpl .3
.4 ldx K.READDIRA.EC
cpx K.READDIRA.EBP
cpx K.READDIRA.EPB
lda K.READDIRA.EC+1
sbc #0
bcc .5 We have less than EPB to read
ldx K.READDIRA.EBP
ldx K.READDIRA.EPB
.5 stx K.READDIRA.ECIB
stz K.READDIRA.EC2Return
@ -341,15 +340,17 @@ K.READDIRA.DIR1 lda (ZPQuickPtr2) X = EntryCount In This Block
.8 dex
bne K.READDIRA.DIR1
* pass #2 Fill Buffer...
* pass #2 Fill Buffer...(ZPQuickPtr1 & Ptr2 can now be trashed)
K.READDIRA.DIR2 jsr K.READDIRA.GetBuf
bcs .98
ldy #S.DIR.PRODOS.EL Check if first run....
lda (ZPQuickPtr1),y
bne .73
* ldy #S.DIR.PRODOS.EL Check if first run....
* lda (ZPQuickPtr1),y
* bne .73
.71 lda (ZPQuickPtr3)
beq .78 Empty slot, skip
lda (ZPQuickPtr3)
and #$F0
cmp #$F0 Vol Header ?
bne .72
@ -362,20 +363,20 @@ K.READDIRA.DIR2 jsr K.READDIRA.GetBuf
jsr K.READDIRA.ADD..
bra .78
.73 lda K.READDIRA.EC
.73 lda K.READDIRA.EC Regular FILE/DIR
sec
sbc #1
sta K.READDIRA.EC
bcs .74
lda K.READDIRA.EC+1
sbc #0
sta K.READDIRA.EC+1 CC, we reached $ffff
bcc .80 no more file to list...
.74 lda (ZPQuickPtr3)
beq .78
jsr K.READDIRA.AddFNToBuf
jsr K.READDIRA.ClrStat
lda (ZPQuickPtr3)
and #$F0
cmp #$D0 Directory ?
bne .75
@ -392,12 +393,16 @@ K.READDIRA.DIR2 jsr K.READDIRA.GetBuf
inc ZPQuickPtr3+1
.79 dec K.READDIRA.ECIB
bne .72
bne .71
.80
* lda #0 S.MEM.F.INIT0 already did this
* sta (ZPQuickPtr4) Ending 0
lda K.READDIRA.hDir Restore ZPQuickPtr1 trashed by STR API calls
jsr K.GetMemPtrA
>STYA ZPQuickPtr1
ldx #3
ldy #S.DIR.PRODOS.EL+3
@ -437,41 +442,28 @@ K.READDIRA.ADD. ldx #1 filename="1."
K.READDIRA.ADD..
ldx #2 filename="2.."
txa
jsr K.READDIRA.AddToBuf
lda #'.' filename="1."
jsr K.READDIRA.AddToBuf Add LEN
lda #'.'
.1 jsr K.READDIRA.AddToBuf
.1 jsr K.READDIRA.AddToBuf Add X dot(s)
dex
bne .1
jsr K.READDIRA.ClrStat
lda #$0F
sta KrnBuf256+S.STAT.PRODOS.TYPE
* ldy #$25 total_blocks
* lda (ZPQuickPtr3),y
* sta KrnBuf256+S.STAT.BLOCKS
* iny
* lda (ZPQuickPtr3),y
* sta KrnBuf256+S.STAT.BLOCKS+1
bra K.READDIRA.ADDSTAT
*--------------------------------------
K.READDIRA.ADDD jsr K.READDIRA.AddFNToBuf
jsr K.READDIRA.ClrStat
lda #$0F
K.READDIRA.ADDD lda #$0F
sta KrnBuf256+S.STAT.PRODOS.TYPE
bra K.READDIRA.ADDSTAT
*--------------------------------------
K.READDIRA.ADDF jsr K.READDIRA.AddFNToBuf
jsr K.READDIRA.ClrStat
ldx #ADDF.DST-ADDF.SRC
K.READDIRA.ADDF ldx #ADDF.DST-ADDF.SRC
.1 ldy ADDF.SRC-1,x
lda (ZPQuickPtr3),y
ldy ADDF.DST-1,x
@ -540,7 +532,7 @@ K.READDIRA.ConvertTime
lda ZPQuickPtr3+1
adc #0
>PUSHYA
jmp K.PTime2Time
jmp K.PTime2Time Will destroy Ptr1 & Ptr2 !!!!
*--------------------------------------
ADDF.SRC .HS 1013141516171f20
ADDF.DST .DA #S.STAT.PRODOS.TYPE,#S.STAT.BLOCKS,#S.STAT.BLOCKS+1
@ -551,7 +543,7 @@ ADDF.DST .DA #S.STAT.PRODOS.TYPE,#S.STAT.BLOCKS,#S.STAT.BLOCKS+1
* A = hDIR
*--------------------------------------
K.CLOSEDIRA jsr PFT.CheckDirA
sta K.OPENDIRYA.hDIR
sta K.READDIRA.hDir
jsr K.GetMemPtrA
>STYA ZPQuickPtr1
@ -566,7 +558,7 @@ K.CLOSEDIRA.1 ldy #S.DIR.PRODOS.REF
beq .2
jsr K.FreeMemA
.2 lda K.OPENDIRYA.hDIR
.2 ldaK.READDIRA.hDir
jsr K.FreeMemA
clc
rts

View File

@ -298,26 +298,26 @@ K.PStrFTime.JMPH .DA /K.PStrFTime.A
.DA /K.PStrFTime.Y
.DA /K.PStrFTime.YY
*--------------------------------------
K.PStrFTime.A ldx #3 Max Len
K.PStrFTime.A ldx #3 Short day of week, 3 chars...
.HS 2C Bit abs
K.PStrFTime.AA ldx #15
K.PStrFTime.AA ldx #15 full DoW
>LDYAI K.PStrFTime.DAY
>STYA ZPQuickPtr4
ldy #S.Time.WDAY
bra K.PStrFTime.STR
K.PStrFTime.B ldx #3
K.PStrFTime.B ldx #3 Short Month, 3 chars....
.HS 2C Bit abs
K.PStrFTime.BB ldx #15
K.PStrFTime.BB ldx #15 full Month....
>LDYAI K.PStrFTime.MON
>STYA ZPQuickPtr4
ldy #S.Time.MONTH
K.PStrFTime.STR lda (ZPQuickPtr1),y get required S.Time field value
tay
beq .8 Illegal value
beq .9 Illegal value
.1 dey range 0..x
beq .2
@ -342,9 +342,11 @@ K.PStrFTime.STR lda (ZPQuickPtr1),y get required S.Time field value
tay
dex
bne .3
.8 rts
.9 lda #'?'
jmp K.PStrFTime.addChar
K.PStrFTime.D ldy #S.Time.DAY
bra K.PStrFTime.addDecPtr1Y
K.PStrFTime.HH ldy #S.Time.HOUR
@ -382,6 +384,7 @@ K.PStrFTime.addDecPtr1Y
K.PStrFTime.addDecA
sta K.PStrFTime.BIN
stz K.PStrFTime.DEC
sed
ldx #8
@ -393,17 +396,18 @@ K.PStrFTime.addDecA
dex
bne .1
cld
* lda K.PStrFTime.DEC already in A
pha
lsr
lsr
lsr
lsr
ora #$30
jsr K.PStrFTime.addChar
lda K.PStrFTime.DEC
pla
and #$0f
ora #$30
*--------------------------------------

View File

@ -14,9 +14,9 @@ DAY0 .EQ 4 day 0 was a thursday
*--------------------------------------
* K.TimeYA get System Time
* In :
* Y,A = PTR to K.Time
* Y,A = PTR to S.TIME
* Out :
* K.Time filled with ProDOS MLI date/time
* S.TIME filled with System date/time
*--------------------------------------
K.TimeYA >STYA ZPQuickPtr2
>MLICALL MLIGETTIME
@ -26,7 +26,7 @@ K.TimeYA >STYA ZPQuickPtr2
*--------------------------------------
* In :
* PULLW = Src PDATE/TIME (DWORD)
* PULLW = Dst PTR To K.Time
* PULLW = Dst PTR To S.TIME
*--------------------------------------
K.PTime2Time >PULLW ZPQuickPtr1
>PULLW ZPQuickPtr2
@ -163,7 +163,7 @@ K.ComputeWDAY lda #3 Thursday : 4 (-1 for mod 7)
* K.CTime2Time
* In :
* PULLW = Src CTIME DWORD
* PULLW = Dst PTR To K.Time
* PULLW = Dst PTR To S.TIME
*--------------------------------------
K.CTime2Time >PULLW ZPQuickPtr1
>PULLW ZPQuickPtr2