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 fnparse, fnparsename, fnset
.export fnadd, fnaddmode, fncomplete, fndefunit .export fnadd, fnaddmode, fncomplete, fndefunit
.export fnunit, fnlen, fncmd, fnbuf .export fnunit, fnlen, fnisfile, fncmd, fnbuf
.import SETNAM .import SETNAM
.import __curunit, __filetype .import __curunit, __filetype
@ -106,10 +106,30 @@ drivedone:
lda #2 ; Length of drive spec lda #2 ; Length of drive spec
sta fnlen sta fnlen
; Copy the name into the file name buffer. The subroutine returns an error ; Assume this is a standard file on disk
; code in A and zero flag set if the were no errors.
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 .endproc
@ -165,6 +185,7 @@ fnadd: ldx fnlen
fnunit: .res 1 fnunit: .res 1
fnlen: .res 1 fnlen: .res 1
fnisfile: .res 1 ; Flags standard file (as opposed to "$")
.data .data
fncmd: .byte 's' ; Use as scratch command fncmd: .byte 's' ; Use as scratch command

View File

@ -15,7 +15,7 @@
.import addysp, popax .import addysp, popax
.import scratch, fnparse, fnaddmode, fncomplete, fnset .import scratch, fnparse, fnaddmode, fncomplete, fnset
.import opencmdchannel, closecmdchannel, readdiskerror .import opencmdchannel, closecmdchannel, readdiskerror
.import fnunit .import fnunit, fnisfile
.import _close .import _close
.importzp sp, tmp2, tmp3 .importzp sp, tmp2, tmp3
@ -158,7 +158,10 @@ common: sta tmp3
clc clc
adc #LFN_OFFS adc #LFN_OFFS
ldx fnunit 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 SETLFS ; Set the file params
jsr OPEN jsr OPEN