Skip to content

Commit

Permalink
improved diskio.diskname() error detection
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Dec 29, 2024
1 parent f786f60 commit 099fe28
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
23 changes: 14 additions & 9 deletions compiler/res/prog8lib/cx16/diskio.p8
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,20 @@ io_error:
}

sub diskname() -> uword {
; returns disk label name or 0 if error
cbm.SETNAM(3, "$")
; -- Returns pointer to disk name string or 0 if failure.

cbm.SETNAM(1, "$")
cbm.SETLFS(READ_IO_CHANNEL, drivenumber, 0)
ubyte status = 1
void cbm.OPEN() ; open 12,8,0,"$=c"
bool okay = false
void cbm.OPEN() ; open 12,8,0,"$"
if_cs
goto io_error
reset_read_channel()

void cbm.CHRIN()
if cbm.READST()!=0
goto io_error

while cbm.CHRIN()!='"' {
; skip up to entry name
}
Expand All @@ -130,14 +135,14 @@ io_error:
}
cx16.r0++
}
status = cbm.READST()
okay = true

io_error:
cbm.CLRCHN()
cbm.CLRCHN() ; restore default i/o devices
cbm.CLOSE(READ_IO_CHANNEL)
if status!=0 and status & $40 == 0
return 0
return list_filename
if okay
return &list_filename
return 0
}

; internal variables for the iterative file lister / loader
Expand Down
6 changes: 4 additions & 2 deletions compiler/res/prog8lib/shared_cbm_diskio.p8
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ io_error:
goto io_error
reset_read_channel()

void cbm.CHRIN()
if cbm.READST()!=0
goto io_error

while cbm.CHRIN()!='"' {
; skip up to entry name
}
if cbm.READST()!=0
goto io_error

cx16.r0 = &list_filename
repeat {
Expand Down
6 changes: 6 additions & 0 deletions docs/source/todo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ TODO
Future Things and Ideas
^^^^^^^^^^^^^^^^^^^^^^^

- why is this code so much larger with charpos variable, than with just using cx16.r0L ?
ubyte charpos
for charpos in DIALOG_TOPX+1 to DIALOG_TOPX+30 {
txt.setchr(charpos, cx16.r1L, txt.getchr(charpos, cx16.r1L) ^ 128)
}

- support &, &< and &> on array elements from split word arrays too not just the array as a whole (to get rid of the error "&< is only valid on array variables"
and "cannot take the adress of a word element that is in a split-word array" and the TODOS "address of element of a split word array")
- after that: fix leftover asmgen split word array todo's
Expand Down

0 comments on commit 099fe28

Please sign in to comment.