So, it'll be up to me to make a directory. My first instinct was to load the directory in with the KERNAL's LOAD. Problem with that is, with things like SD2IEC, it's very easy to wind up with a bigger directory than the 3583 bytes a cartridge will have available. So I want to use CHRIN to bring it in one byte at a time.
Right now, my directory program runs forever. The Programmer's Reference Guide suggests CMP #CR to determine when CHRIN is done, and this doesn't make sense when you're CHRINing a BASIC program. I tried BCS, and, sadly, carry is not set when there's nothing else to do.
Here's what I have right now:
Code: Select all
Dir: lda #1 ; SETNAM - (1) Set name length
ldx #<lfs+1 ; - Set name as the $ used below
ldy #>lfs+1 ; ,,
jsr SETNAM ; ,,
lfs: lda #"$" ; SETLFS - Set file number as $
ldx #8 ; - Device number
ldy #0 ; - Command
jsr SETLFS ; ,,
jsr OPEN
ldx #"$"
jsr CHKIN
-loop: jsr CHRIN
bcs done
jsr CHROUT
jmp loop
done: jsr CLRCHN
lda #"$"
jsr CLOSE
rts
Anyway, do I just have to look for the zeroes? I guess I can stop at the first BASIC line that fails to contain a matching pair of quotation marks.
It seems weird that the KERNAL wouldn't be able to handle EOF in some way.