fixed diskio directory block sizes

This commit is contained in:
Irmen de Jong 2020-12-08 01:02:38 +01:00
parent 329b28cad1
commit 8af17c295a
2 changed files with 81 additions and 12 deletions

View File

@ -25,7 +25,9 @@ diskio {
; while not key pressed / EOF encountered, read data. ; while not key pressed / EOF encountered, read data.
ubyte status = c64.READST() ubyte status = c64.READST()
while not status { while not status {
txt.print_uw(mkword(c64.CHRIN(), c64.CHRIN())) ubyte low = c64.CHRIN()
ubyte high = c64.CHRIN()
txt.print_uw(mkword(high, low))
txt.chrout(' ') txt.chrout(' ')
ubyte @zp char ubyte @zp char
do { do {
@ -97,10 +99,18 @@ io_error:
void c64.CHRIN() ; skip the 4 prologue bytes void c64.CHRIN() ; skip the 4 prologue bytes
} }
ubyte disk_name = true
while not c64.READST() { while not c64.READST() {
@(blocksizesptr) = c64.CHRIN() if disk_name {
@(blocksizesptr+1) = c64.CHRIN() void c64.CHRIN()
blocksizesptr += 2 void c64.CHRIN()
}
else {
@(blocksizesptr) = c64.CHRIN()
@(blocksizesptr+1) = c64.CHRIN()
blocksizesptr += 2
}
; read until the filename starts after the first " ; read until the filename starts after the first "
while c64.CHRIN()!='\"' { while c64.CHRIN()!='\"' {
@ -108,15 +118,33 @@ io_error:
goto io_error goto io_error
} }
ubyte char repeat {
do { ubyte char = c64.CHRIN()
char = c64.CHRIN() ;if_z
@(filenamesbufferptr) = char ; break ; TODO fix assembly code generation for this
if char=='\"'
break
if not disk_name {
@(filenamesbufferptr) = char
filenamesbufferptr++
}
}
if not disk_name {
@(filenamesbufferptr) = 0
filenamesbufferptr++ filenamesbufferptr++
} until char==0 num_files++
num_files++ }
; read the rest of the entry until the end
do {
ubyte char2 = c64.CHRIN()
char2++ ; TODO fix condition test problem with ldx
} until char2==1
void c64.CHRIN() ; skip 2 bytes void c64.CHRIN() ; skip 2 bytes
void c64.CHRIN() void c64.CHRIN()
disk_name = false
} }
io_error: io_error:
@ -127,7 +155,7 @@ io_error:
sub status(ubyte drivenumber) { sub status(ubyte drivenumber) {
; -- display the disk drive's current status message ; -- display the disk drive's current status message
c64.SETNAM(0, $0000) c64.SETNAM(0, filename)
c64.SETLFS(15, drivenumber, 15) c64.SETLFS(15, drivenumber, 15)
void c64.OPEN() ; open 15,8,15 void c64.OPEN() ; open 15,8,15
if_cs if_cs

View File

@ -3,6 +3,38 @@
%import floats %import floats
%zeropage basicsafe %zeropage basicsafe
%import test_stack %import test_stack
%option no_sysinit
errors {
sub tofix() {
while c64.CHRIN() {
; TODO: the loop condition isn't properly tested because a ldx is in the way before the beq
}
repeat {
ubyte char2 = c64.CHRIN()
if char2==0 ; TODO condition not properly tested after optimizing because there's only a sta char2 before it (works without optimizing)
break
}
repeat {
ubyte char3 = c64.CHRIN()
if_z
break ; TODO wrong jump asm generated, works fine if you use a label instead to jump to
}
; TODO fix undefined symbol:
repeat {
ubyte char = c64.CHRIN()
; ...
}
; do {
; char = c64.CHRIN() ; TODO fix undefined symbol error, should refer to 'char' above in the subroutine's scope
; } until char==0
}
}
main { main {
sub start() { sub start() {
@ -12,20 +44,27 @@ main {
txt.print("result: ") txt.print("result: ")
txt.print_ub(result) txt.print_ub(result)
txt.chrout('\n') txt.chrout('\n')
test_stack.test()
diskio.status(8) diskio.status(8)
txt.chrout('\n') txt.chrout('\n')
txt.chrout('\n') txt.chrout('\n')
txt.chrout('\n') txt.chrout('\n')
test_stack.test()
return
const ubyte max_files = 10 const ubyte max_files = 10
uword[max_files] blocks uword[max_files] blocks
str filenames = "?????????????????" * max_files str filenames = "?????????????????" * max_files
ubyte num_files = diskio.listfiles(8, ".bin", true, filenames, blocks, max_files) ubyte num_files=0
; num_files = diskio.listfiles(8, ".bin", true, filenames, blocks, max_files)
txt.print("num files: ") txt.print("num files: ")
txt.print_ub(num_files) txt.print_ub(num_files)
txt.chrout('\n') txt.chrout('\n')
test_stack.test()
if num_files>0 { if num_files>0 {
ubyte i ubyte i
uword filenameptr = &filenames uword filenameptr = &filenames
@ -39,5 +78,7 @@ main {
filenameptr += strlen(filenameptr) + 1 filenameptr += strlen(filenameptr) + 1
} }
} }
test_stack.test()
} }
} }