1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-24 11:31:31 +00:00

Add provisions to open a disk directory using open().

git-svn-id: svn://svn.cc65.org/cc65/trunk@5663 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2012-05-29 20:52:18 +00:00
parent 4663245219
commit 64d3d9e41f
2 changed files with 35 additions and 11 deletions

View File

@ -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

View File

@ -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