mirror of
https://github.com/irmen/prog8.git
synced 2025-02-18 05:30:34 +00:00
fix diskio.diskname(). cx16: add diskio.curdir()
This commit is contained in:
parent
7ee162d98b
commit
ba25b7fee6
@ -73,39 +73,42 @@ io_error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub diskname() -> uword {
|
sub diskname() -> uword {
|
||||||
; -- Returns pointer to disk name string or 0 if failure.
|
; returns disk label name or 0 if error
|
||||||
|
cbm.SETNAM(3, "$")
|
||||||
cbm.SETNAM(1, "$")
|
cbm.SETLFS(12, diskio.drivenumber, 0)
|
||||||
cbm.SETLFS(12, drivenumber, 0)
|
ubyte status = 1
|
||||||
ubyte okay = false
|
void cbm.OPEN() ; open 12,8,0,"$=c"
|
||||||
void cbm.OPEN() ; open 12,8,0,"$"
|
|
||||||
if_cs
|
if_cs
|
||||||
goto io_error
|
goto io_error
|
||||||
void cbm.CHKIN(12) ; use #12 as input channel
|
void cbm.CHKIN(12) ; use #12 as input channel
|
||||||
if_cs
|
if_cs
|
||||||
goto io_error
|
goto io_error
|
||||||
|
|
||||||
repeat 6 {
|
while cbm.CHRIN()!='"' {
|
||||||
void cbm.CHRIN() ; skip the 6 prologue bytes
|
; skip up to entry name
|
||||||
}
|
}
|
||||||
if cbm.READST()!=0
|
|
||||||
goto io_error
|
|
||||||
|
|
||||||
cx16.r0 = &list_filename
|
cx16.r0 = &diskio.list_filename
|
||||||
repeat {
|
repeat {
|
||||||
@(cx16.r0) = cbm.CHRIN()
|
@(cx16.r0) = cbm.CHRIN()
|
||||||
if @(cx16.r0)==0
|
if @(cx16.r0)=='"' {
|
||||||
|
@(cx16.r0) = ' '
|
||||||
|
while @(cx16.r0)==' ' and cx16.r0>=&diskio.list_filename {
|
||||||
|
@(cx16.r0) = 0
|
||||||
|
cx16.r0--
|
||||||
|
}
|
||||||
break
|
break
|
||||||
|
}
|
||||||
cx16.r0++
|
cx16.r0++
|
||||||
}
|
}
|
||||||
okay = true
|
status = cbm.READST()
|
||||||
|
|
||||||
io_error:
|
io_error:
|
||||||
cbm.CLRCHN() ; restore default i/o devices
|
cbm.CLRCHN()
|
||||||
cbm.CLOSE(12)
|
cbm.CLOSE(12)
|
||||||
if okay
|
if status and status & $40 == 0
|
||||||
return &list_filename
|
|
||||||
return 0
|
return 0
|
||||||
|
return diskio.list_filename
|
||||||
}
|
}
|
||||||
|
|
||||||
; internal variables for the iterative file lister / loader
|
; internal variables for the iterative file lister / loader
|
||||||
@ -684,6 +687,75 @@ internal_vload:
|
|||||||
send_command(list_filename)
|
send_command(list_filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub curdir() -> uword {
|
||||||
|
; return current directory name or 0 if error
|
||||||
|
; special X16 dos command to only return the current path in the entry list (R42+)
|
||||||
|
const ubyte MAX_PATH_LEN=80
|
||||||
|
uword reversebuffer = memory("curdir_buffer", MAX_PATH_LEN, 0)
|
||||||
|
cx16.r12 = reversebuffer + MAX_PATH_LEN-1
|
||||||
|
@(cx16.r12)=0
|
||||||
|
cbm.SETNAM(3, "$=c")
|
||||||
|
cbm.SETLFS(12, diskio.drivenumber, 0)
|
||||||
|
void cbm.OPEN() ; open 12,8,0,"$=c"
|
||||||
|
if_cs
|
||||||
|
goto io_error
|
||||||
|
void cbm.CHKIN(12) ; use #12 as input channel
|
||||||
|
if_cs
|
||||||
|
goto io_error
|
||||||
|
|
||||||
|
repeat 6 {
|
||||||
|
void cbm.CHRIN()
|
||||||
|
}
|
||||||
|
while cbm.CHRIN() {
|
||||||
|
; skip first line (drive label)
|
||||||
|
}
|
||||||
|
while cbm.CHRIN()!='"' {
|
||||||
|
; skip to first name
|
||||||
|
}
|
||||||
|
ubyte status = cbm.READST()
|
||||||
|
cx16.r10 = &list_filename
|
||||||
|
while status==0 {
|
||||||
|
repeat {
|
||||||
|
@(cx16.r10) = cbm.CHRIN()
|
||||||
|
if @(cx16.r10)==0
|
||||||
|
break
|
||||||
|
cx16.r10++
|
||||||
|
}
|
||||||
|
while @(cx16.r10)!='"' and cx16.r10>=&list_filename {
|
||||||
|
@(cx16.r10)=0
|
||||||
|
cx16.r10--
|
||||||
|
}
|
||||||
|
@(cx16.r10)=0
|
||||||
|
prepend(list_filename)
|
||||||
|
cx16.r10 = &list_filename
|
||||||
|
while cbm.CHRIN()!='"' and status==0 {
|
||||||
|
status = cbm.READST()
|
||||||
|
; skipping up to next entry name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
io_error:
|
||||||
|
cbm.CLRCHN()
|
||||||
|
cbm.CLOSE(12)
|
||||||
|
if status and status & $40 == 0
|
||||||
|
return 0
|
||||||
|
if @(cx16.r12)==0 {
|
||||||
|
cx16.r12--
|
||||||
|
@(cx16.r12)='/'
|
||||||
|
}
|
||||||
|
return cx16.r12
|
||||||
|
|
||||||
|
sub prepend(str dir) {
|
||||||
|
if dir[0]=='/' and dir[1]==0
|
||||||
|
return
|
||||||
|
cx16.r9L = string.length(dir)
|
||||||
|
cx16.r12 -= cx16.r9L
|
||||||
|
sys.memcopy(dir, cx16.r12, cx16.r9L)
|
||||||
|
cx16.r12--
|
||||||
|
@(cx16.r12)='/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub relabel(str name) {
|
sub relabel(str name) {
|
||||||
; -- change the disk label.
|
; -- change the disk label.
|
||||||
list_filename[0] = 'r'
|
list_filename[0] = 'r'
|
||||||
|
@ -84,8 +84,8 @@ io_error:
|
|||||||
if_cs
|
if_cs
|
||||||
goto io_error
|
goto io_error
|
||||||
|
|
||||||
repeat 6 {
|
while cbm.CHRIN()!='"' {
|
||||||
void cbm.CHRIN() ; skip the 6 prologue bytes
|
; skip up to entry name
|
||||||
}
|
}
|
||||||
if cbm.READST()!=0
|
if cbm.READST()!=0
|
||||||
goto io_error
|
goto io_error
|
||||||
@ -93,8 +93,14 @@ io_error:
|
|||||||
cx16.r0 = &list_filename
|
cx16.r0 = &list_filename
|
||||||
repeat {
|
repeat {
|
||||||
@(cx16.r0) = cbm.CHRIN()
|
@(cx16.r0) = cbm.CHRIN()
|
||||||
if @(cx16.r0)==0
|
if @(cx16.r0)=='"' {
|
||||||
|
@(cx16.r0) = ' '
|
||||||
|
while @(cx16.r0)==' ' and cx16.r0>=&diskio.list_filename {
|
||||||
|
@(cx16.r0) = 0
|
||||||
|
cx16.r0--
|
||||||
|
}
|
||||||
break
|
break
|
||||||
|
}
|
||||||
cx16.r0++
|
cx16.r0++
|
||||||
}
|
}
|
||||||
okay = true
|
okay = true
|
||||||
|
1
compiler/res/prog8lib/virtual/diskio.p8
Normal file
1
compiler/res/prog8lib/virtual/diskio.p8
Normal file
@ -0,0 +1 @@
|
|||||||
|
; there is no diskio yet for the VM target.
|
@ -1 +1 @@
|
|||||||
9.0
|
9.1-dev
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.10 (py3)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -1,6 +1,14 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
|
- c64 fix diskio.diskname
|
||||||
|
|
||||||
|
- fix undefined symbol error for sub curdir() -> str { return "todo" }
|
||||||
|
- fix placeholder error for
|
||||||
|
str result = "todo" , sub curdir() -> str { return result }
|
||||||
|
|
||||||
|
- document some library modules better (diskio, etc)
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,34 +1,17 @@
|
|||||||
%import textio
|
%import textio
|
||||||
|
%import diskio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
str name1 = "name1"
|
|
||||||
str name2 = "name2"
|
|
||||||
|
|
||||||
uword[] @split names = [name1, name2, "name3"]
|
txt.print("pwd: ")
|
||||||
|
txt.print(diskio.curdir())
|
||||||
uword ww
|
txt.print("\ndisk name: ")
|
||||||
; for ww in names {
|
uword name = diskio.diskname()
|
||||||
; txt.print(ww)
|
if name
|
||||||
; txt.spc()
|
txt.print(name)
|
||||||
; }
|
else
|
||||||
; txt.nl()
|
txt.print("!error!")
|
||||||
ubyte idx=1
|
|
||||||
names[idx] = $20ff
|
|
||||||
txt.print_uwhex(names[1], true)
|
|
||||||
names[idx]++
|
|
||||||
txt.print_uwhex(names[1], true)
|
|
||||||
names[idx]--
|
|
||||||
txt.print_uwhex(names[1], true)
|
|
||||||
|
|
||||||
names = [1111,2222,3333]
|
|
||||||
for ww in names {
|
|
||||||
txt.print_uw(ww)
|
|
||||||
txt.spc()
|
|
||||||
}
|
|
||||||
txt.nl()
|
|
||||||
txt.print("end.")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user