diff --git a/libsrc/cbm/filename.s b/libsrc/cbm/filename.s index 284ea736d..0674db07e 100644 --- a/libsrc/cbm/filename.s +++ b/libsrc/cbm/filename.s @@ -6,7 +6,7 @@ .export fnparse, fnparsename, fnset .export fnadd, fnaddmode, fncomplete, fndefunit - .export fnunit, fnlen, fncmd, fnbuf + .export fnunit, fnlen, fnisfile, fncmd, fnbuf .import SETNAM .import __curunit, __filetype @@ -106,10 +106,30 @@ drivedone: lda #2 ; Length of drive spec sta fnlen -; Copy the name into the file name buffer. The subroutine returns an error -; code in A and zero flag set if the were no errors. +; Assume this is a standard file on disk - jmp fnparsename + sta fnisfile + +; Special treatment for directory. If the file name is "$", things are +; actually different: $ is directory for unit 0, $0 dito, $1 is directory +; for unit 1. For simplicity, we won't check anything else if the first +; character of the file name is '$'. + + lda (ptr1),y ; Get first character + cmp #'$' ; + bne fnparsename + +; Juggle stuff + + ldx fnbuf+0 ; unit + stx fnbuf+1 + sta fnbuf+0 + +; No need to check the name. Length is already 2 + + lda #0 ; ok flag + sta fnisfile ; This is not a real file + rts .endproc @@ -163,10 +183,11 @@ fnadd: ldx fnlen .bss -fnunit: .res 1 -fnlen: .res 1 +fnunit: .res 1 +fnlen: .res 1 +fnisfile: .res 1 ; Flags standard file (as opposed to "$") .data -fncmd: .byte 's' ; Use as scratch command -fnbuf: .res 35 ; Either 0:0123456789012345,t,m - ; Or 0:0123456789012345=0123456789012345 +fncmd: .byte 's' ; Use as scratch command +fnbuf: .res 35 ; Either 0:0123456789012345,t,m + ; Or 0:0123456789012345=0123456789012345 diff --git a/libsrc/cbm/open.s b/libsrc/cbm/open.s index df6634593..f217068d2 100644 --- a/libsrc/cbm/open.s +++ b/libsrc/cbm/open.s @@ -15,7 +15,7 @@ .import addysp, popax .import scratch, fnparse, fnaddmode, fncomplete, fnset .import opencmdchannel, closecmdchannel, readdiskerror - .import fnunit + .import fnunit, fnisfile .import _close .importzp sp, tmp2, tmp3 @@ -158,7 +158,10 @@ common: sta tmp3 clc adc #LFN_OFFS ldx fnunit - tay ; Use the LFN also as SA + ldy fnisfile ; Is this a standard file on disk? + beq nofile ; Branch if not + tay ; Use the LFN also as SA for files +nofile: ; ... else use SA=0 (read) jsr SETLFS ; Set the file params jsr OPEN