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.
ubyte status = c64.READST()
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(' ')
ubyte @zp char
do {
@ -97,10 +99,18 @@ io_error:
void c64.CHRIN() ; skip the 4 prologue bytes
}
ubyte disk_name = true
while not c64.READST() {
@(blocksizesptr) = c64.CHRIN()
@(blocksizesptr+1) = c64.CHRIN()
blocksizesptr += 2
if disk_name {
void c64.CHRIN()
void c64.CHRIN()
}
else {
@(blocksizesptr) = c64.CHRIN()
@(blocksizesptr+1) = c64.CHRIN()
blocksizesptr += 2
}
; read until the filename starts after the first "
while c64.CHRIN()!='\"' {
@ -108,15 +118,33 @@ io_error:
goto io_error
}
ubyte char
do {
char = c64.CHRIN()
@(filenamesbufferptr) = char
repeat {
ubyte char = c64.CHRIN()
;if_z
; 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++
} 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()
disk_name = false
}
io_error:
@ -127,7 +155,7 @@ io_error:
sub status(ubyte drivenumber) {
; -- display the disk drive's current status message
c64.SETNAM(0, $0000)
c64.SETNAM(0, filename)
c64.SETLFS(15, drivenumber, 15)
void c64.OPEN() ; open 15,8,15
if_cs

View File

@ -3,6 +3,38 @@
%import floats
%zeropage basicsafe
%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 {
sub start() {
@ -12,20 +44,27 @@ main {
txt.print("result: ")
txt.print_ub(result)
txt.chrout('\n')
test_stack.test()
diskio.status(8)
txt.chrout('\n')
txt.chrout('\n')
txt.chrout('\n')
test_stack.test()
return
const ubyte max_files = 10
uword[max_files] blocks
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_ub(num_files)
txt.chrout('\n')
test_stack.test()
if num_files>0 {
ubyte i
uword filenameptr = &filenames
@ -39,5 +78,7 @@ main {
filenameptr += strlen(filenameptr) + 1
}
}
test_stack.test()
}
}