mirror of
https://github.com/cc65/cc65.git
synced 2024-11-19 21:32:19 +00:00
Don't add a mode when opening files for reading
git-svn-id: svn://svn.cc65.org/cc65/trunk@2014 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
c8d76046cb
commit
e39b1c963e
@ -4,7 +4,7 @@
|
|||||||
; File name handling for CBM file I/O
|
; File name handling for CBM file I/O
|
||||||
;
|
;
|
||||||
|
|
||||||
.export fnparse, fnset, fncomplete
|
.export fnparse, fnset, fnaddmode, fncomplete
|
||||||
.export fnunit, fnlen, fncmd, fnbuf
|
.export fnunit, fnlen, fncmd, fnbuf
|
||||||
|
|
||||||
.import SETNAM
|
.import SETNAM
|
||||||
@ -94,8 +94,7 @@ nameok: ldx fnlen
|
|||||||
cpx #18 ; Maximum length reached?
|
cpx #18 ; Maximum length reached?
|
||||||
bcs invalidname
|
bcs invalidname
|
||||||
lda (ptr1),y ; Reload char
|
lda (ptr1),y ; Reload char
|
||||||
sta fnbuf,x ; Store into buffer
|
jsr fnadd ; Add character to name
|
||||||
inc fnlen ; Count characters
|
|
||||||
iny ; Next char from name
|
iny ; Next char from name
|
||||||
bne nameloop ; Branch always
|
bne nameloop ; Branch always
|
||||||
|
|
||||||
@ -127,27 +126,28 @@ namedone:
|
|||||||
;--------------------------------------------------------------------------
|
;--------------------------------------------------------------------------
|
||||||
; fncomplete: Complete a filename by adding ",t,m" where t is the file type
|
; fncomplete: Complete a filename by adding ",t,m" where t is the file type
|
||||||
; and m is the access mode passed in in the A register
|
; and m is the access mode passed in in the A register
|
||||||
|
;
|
||||||
|
; fnaddmode: Add ",m" to a filename, where "m" is passed in A
|
||||||
|
|
||||||
.proc fncomplete
|
fncomplete:
|
||||||
|
|
||||||
pha ; Save mode
|
pha ; Save mode
|
||||||
ldx fnlen
|
jsr fnaddcomma ; Add a comma
|
||||||
lda #','
|
lda __filetype
|
||||||
sta fnbuf,x
|
jsr fnadd ; Add the type
|
||||||
inx
|
pla
|
||||||
lda __filetype
|
fnaddmode:
|
||||||
sta fnbuf,x
|
pha
|
||||||
inx
|
jsr fnaddcomma
|
||||||
lda #','
|
pla
|
||||||
sta fnbuf,x
|
|
||||||
inx
|
|
||||||
pla
|
|
||||||
sta fnbuf,x
|
|
||||||
inx
|
|
||||||
stx fnlen
|
|
||||||
rts
|
|
||||||
|
|
||||||
.endproc
|
fnadd: ldx fnlen
|
||||||
|
inc fnlen
|
||||||
|
sta fnbuf,x
|
||||||
|
rts
|
||||||
|
|
||||||
|
fnaddcomma:
|
||||||
|
lda #','
|
||||||
|
bne fnadd
|
||||||
|
|
||||||
;--------------------------------------------------------------------------
|
;--------------------------------------------------------------------------
|
||||||
; Data
|
; Data
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
.import SETLFS, OPEN, CLOSE
|
.import SETLFS, OPEN, CLOSE
|
||||||
.import addysp, popax
|
.import addysp, popax
|
||||||
.import scratch, fnparse, fncomplete, fnset
|
.import scratch, fnparse, fnaddmode, fncomplete, fnset
|
||||||
.import opencmdchannel, closecmdchannel, readdiskerror
|
.import opencmdchannel, closecmdchannel, readdiskerror
|
||||||
.import __oserror
|
.import __oserror
|
||||||
.import fnunit
|
.import fnunit
|
||||||
@ -109,7 +109,7 @@ notrunc:
|
|||||||
bne append ; Branch if yes
|
bne append ; Branch if yes
|
||||||
ldx #'w'
|
ldx #'w'
|
||||||
append: txa
|
append: txa
|
||||||
jsr fncomplete
|
jsr fncomplete ; Add type and mode to the name
|
||||||
|
|
||||||
; Setup the real open flags
|
; Setup the real open flags
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ append: txa
|
|||||||
; Read bit is set. Add an 'r' to the name
|
; Read bit is set. Add an 'r' to the name
|
||||||
|
|
||||||
doread: lda #'r'
|
doread: lda #'r'
|
||||||
jsr fncomplete
|
jsr fnaddmode ; Add the mode to the name
|
||||||
lda #LFN_READ
|
lda #LFN_READ
|
||||||
|
|
||||||
; Common read/write code. Flags in A, handle in tmp2
|
; Common read/write code. Flags in A, handle in tmp2
|
||||||
|
Loading…
Reference in New Issue
Block a user