home *** CD-ROM | disk | FTP | other *** search
- ; Library: ZSLIB
- ; Version: 3.5
- ; Module: Z3FILE
- ; Version: 1.1
- ; Author: Gene Pizzetta
- ; Date: February 4, 1992
- ; Changes: Changed names of public and external labels.
- ;
- ; Version: 1.0 (beta release)
- ; Author: Gene Pizzetta
- ; Date: December 8, 1991
- ; Changes: Based on the SYSLIB 3.6 S3FILE module by Richard Conn, as
- ; modified by Al Dunsmuir. Now supports inter-directory
- ; I/O.
- ;
- ; FR3OPEN, F3GET, FR3CLOSE, FW3OPEN, F3PUT, FW3CLOSE -- Byte-oriented
- ; file read and write routines.
- ;
- ; FR3OPEN -- Open file for byte-oriented reading.
- ;
- ; Entry: DE = address of file control block
- ; Exit: A = 0, zero flag set (Z) if okay,
- ; A = error code, zero flag reset (NZ) if error.
- ; Uses: AF
- ; Notes: Must be logged into correct directory before calling. Only the
- ; first 12 bytes of the file control block are used and the drive byte
- ; is ignored.
- ;
- ; FW3OPEN -- Open file for byte-oriented writing.
- ;
- ; Entry: DE = address of file control block.
- ; Exit: A = 0, zero flag set (Z) if okay,
- ; A = error code, zero flag reset (NZ) if error.
- ; Uses: AF
- ; Notes: Must be logged into correct directory before calling. Only the
- ; first 12 bytes of the file control block are used and the drive byte
- ; is ignored.
- ;
- ; FR3CLOSE -- Close file after byte-oriented reading.
- ;
- ; Entry: None.
- ; Exit: A = 0, zero flag set (Z) if okay,
- ; A = error code, zero flag reset (NZ) if error.
- ; Uses: AF
- ; Notes: Read files should always be closed. Closing the file properly
- ; prepares the data blocks for using this routine to open another file,
- ; which will fail otherwise. In addition, it is required if the program
- ; will be re-executed with the ZCPR3 GO command.
- ;
- ; FW3CLOSE -- Close file after byte-oriented writing.
- ;
- ; Entry: None.
- ; Exit: A = 0, zero flag set (Z) if okay,
- ; A = error code, zero flag reset (NZ) if error.
- ; Uses: AF
- ; Notes: Write files must always be closed, otherwise the buffers will
- ; not be flushed to disk.
- ;
- ; F3GET -- Get next byte from read file.
- ;
- ; Entry: None.
- ; Exit: A = byte, zero flag set (Z) if okay,
- ; A = error code, zero flag reset (NZ) if error.
- ; Uses: AF
- ; Notes: Returns error code 4 on end of file.
- ;
- ; F3PUT -- Put a byte into write file.
- ;
- ; Entry: A = byte to put.
- ; Exit: A = byte that was put, zero flag set (Z) if okay,
- ; A = error code, zero flag reset (NZ) if error.
- ; Uses: AF
- ; Notes: Except on error, A returns the byte that was put into the write
- ; file.
- ;
- ; General Notes: Program must log into correct directory when calling
- ; corresponding open routine. After opening file, no further attention
- ; need be paid to the drive/user. Only the first 12 bytes of the user's
- ; file control block are significant (filename and filetype--the drive
- ; byte is ignored) by the open routines, so an abbreviated FCB may be
- ; used and re-used to open multiple files.
- ;
- ; The returned error codes are:
- ; 1 GET or PUT attempted on an unopened file.
- ; 2 Write file disk full (PUT).
- ; 3 Read file not found (OPEN).
- ; 4 End of read file (GET) or empty read file (OPEN).
- ; 5 Write file directory full (OPEN).
- ; 6 Error closing file (CLOSE).
- ; 7 File is already open (OPEN).
- ;
- PUBLIC FR3OPEN,F3GET,FR3CLOSE,FW3OPEN,F3PUT,FW3CLOSE
- ;
- EXTRN FR@OPEN,FW@OPEN,FR@CLOSE,FW@CLOSE,F@GET,F@PUT ; ZSLIB
- ;
- FR3OPEN:
- push hl ; save HL
- call ckrflg ; check open flag
- call FR@OPEN
- pop hl
- ret nz ; (error)
- dec a ; set open flag
- ld (R3Flg),a
- inc a
- ret
- ;
- FW3OPEN:
- push hl ; save HL
- call ckwflg ; check open flag
- call FW@OPEN
- pop hl
- ret nz ; (error)
- dec a ; set open flag
- ld (W3Flg),a
- inc a
- ret
- ;
- F3GET: push hl ; save HL
- call ckrflg ; check open flag
- jr z,gperr1 ; (file not open)
- jp F@GET ; jump and return to caller
- ;
- F3PUT: push hl ; save HL
- push af
- call ckwflg ; check open flag
- jr z,gperr ; (file not open)
- pop af
- jp F@PUT ; jump and return to caller
- ;
- gperr: pop hl ; adjust stack
- gperr1: pop hl ; restore HL
- inc a ; error code (file not open)
- ret
- ;
- FR3CLOSE:
- push hl ; save HL
- call ckrflg ; check open flag
- call nz,FR@CLOSE ; if open, close it
- pop hl
- ret nz ; (error)
- ld (R3Flg),a ; reset open flag
- ret
- ;
- FW3CLOSE:
- push hl ; save HL
- call ckwflg ; check open flag
- call nz,FW@CLOSE ; if open, close it
- pop hl
- ret nz ; (error)
- ld (W3Flg),a ; reset open flag
- ret
- ;
- ckrflg: ld hl,R3Tbl ; point to read table
- ld a,(R3Flg) ; check flag
- or a
- ret
- ;
- ckwflg: ld hl,W3Tbl ; point to write table
- ld a,(W3Flg) ; check flag
- or a
- ret
- ;
- ; Initialized flags
- ;
- R3Flg: db 0 ; read file opened flag (0=no)
- W3Flg: db 0 ; write file opened flag (0=no)
- ;
- ; Uninitialized tables and buffers (initialized by file open routines)
- ;
- DSEG
- ;
- R3Tbl:
- R3du: ds 2 ; read file drive and user
- R3cnt: ds 1 ; read file character count
- R3ptr: ds 2 ; read file character pointer
- R3fcb: ds 36 ; read file fcb
- R3buf: ds 128 ; read file buffer
- ;
- W3Tbl:
- W3du: ds 2 ; write file drive and user
- W3cnt: ds 1 ; write file character count
- W3ptr: ds 2 ; write file character pointer
- W3fcb: ds 36 ; write file fcb
- W3buf: ds 128 ; write file buffer
- ;
- end