Introduced constructor to raise the ProDOS 8 file level - and extended the destructor to restore the file level again. This is a prerequisite to allow the upcoming exec() to open a file before the destructors run and continue reading from of it after the destructors have run.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4955 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
ol.sc
2011-01-29 21:43:26 +00:00
parent 9e31f7fb63
commit 110f911ccb
2 changed files with 43 additions and 10 deletions

View File

@@ -3,15 +3,13 @@
;
; int open (const char* name, int flags, ...);
;
; Be sure to keep the value priority of closeallfiles lower than that of
; closeallstreams (which is the high level C file I/O counterpart and must be
; called before closeallfiles).
.export _open, closedirect, freebuffer
.export __filetype, __auxtype
.constructor raisefilelevel
.destructor closeallfiles, 5
.import pushname, popname
.import pushname, popname, __dos_type
.import iobuf_alloc, iobuf_free
.import addysp, incsp4, incaxy, pushax, popax
@@ -21,6 +19,17 @@
.include "mli.inc"
.include "filedes.inc"
.segment "INIT"
raisefilelevel:
; Raise file level
lda __dos_type
beq :+
inc LEVEL
: rts
.code
_open:
; Throw away all parameters except name
; and flags occupying together 4 bytes
@@ -209,10 +218,6 @@ freebuffer:
ldx fdtab + FD::BUFFER+1,y
jmp iobuf_free
closeallfiles:
; All open files
lda #$00
closedirect:
; Set fd
sta mliparam + MLI::CLOSE::REF_NUM
@@ -222,6 +227,17 @@ closedirect:
ldx #CLOSE_COUNT
jmp callmli
closeallfiles:
; All open files with current level (or higher)
lda #$00
jsr closedirect
; Restore original file level
lda __dos_type
beq :+
dec LEVEL
: rts
.data
CREATE: .byte %11000011 ; ACCESS: Standard full access