; TITLE "S1FILEIO - Syslib 4.0" NAME ('FIO1') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from S1FILEIO.Z80 V 1.2 by Al Dunsmuir/Richard Conn ; Date : 17 Sep 89 ; Version : 1.3 ; Module : S1FILEIO ; Abstract: This module contains the routines FI1$OPEN, F1$GET, ; FI1$CLOSE, FO1$OPEN, F1$PUT, and FO1$CLOSE which implement ; a character-oriented IO capability. Input and Output file ; capability can be individually assigned, and are inter- ; nally controlled. ; NOTE: This module CAN'T be placed in ROM because of data in CSEG ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC FI1$OPEN, F1$GET, FI1$CLOSE PUBLIC FO1$OPEN, F1$PUT, FO1$CLOSE ; External References EXT FI$OPEN, F$GET, FI$CLOSE EXT FO$OPEN, F$PUT, FO$CLOSE .Z80 CSEG ;=============================================================== ; NAME - FI1$OPEN ; Entry: DE - Points to FCB for requested file ; Exit : AF - A = 0 and Zero Flag Set (Z) if Ok ; A = Error Code and Zero Flag Reset (NZ) if Error ; Uses : AF ; Special Requirements: None ;=============================================================== FI1$OPEN: PUSH HL ; Save user Regs CALL SIBUFR ; Get FI1 table address. CALL FI$OPEN ; Perform Open function POP HL ; Restore entry HL RET NZ ; ..return if error condition CPL ; Else change 00 to FF LD (FIFLG),A ; Save it locally CPL ; ..return back to 0 status RET ; ...and quit ;=============================================================== ; NAME - FO1$OPEN ; Entry: DE - Points to FCB for requested file ; Exit : AF - A = 0 and Zero Flag Set (Z) if Ok ; A = Error Code and Zero Flag Reset (NZ) if Error ; Uses : AF ; Special Requirements: None ;=============================================================== FO1$OPEN: PUSH HL ; Save user REG CALL SOBUFR ; Get FO1 table address. CALL FO$OPEN ; Perform Open function POP HL ; Restore entry HL RET NZ ; ..return if error condition CPL ; Else change 00 to FF LD (FOFLG),A ; Save it locally CPL ; ..return back to 0 status RET ; ...and quit ;=============================================================== ; NAME - F1$GET ; Entry: - None ; Exit : AF - A = Input Character and Zero Flag Set (Z) if Ok ; A = Error Code and Zero Flag Reset (NZ) if Error ; Uses : AF ; Special Requirements: None ;=============================================================== F1$GET: PUSH HL ; Save user REG CALL SIBUFR ; Get FI1 table address & set flag JP F$GET ; Perform function ;=============================================================== ; NAME - F1$PUT ; Entry: A - Contains the character to Put to the file ; Exit : AF - A = 0 and Zero Flag Set (Z) if Ok ; A = Error Code and Zero Flag Reset (NZ) if Error ; Uses : AF ; Special Requirements: None ;=============================================================== F1$PUT: PUSH HL ; Save user REG PUSH AF ; Save character CALL SOBUFR ; Get FO1 table address & set flag POP AF ; Restore character JP F$PUT ; Perform function ;=============================================================== ; NAME - FI1$CLOSE ; Entry: - None ; Exit : AF - A = 0 and Zero Flag Set (Z) if Ok ; A = Error Code and Zero Flag Reset (NZ) if Error ; Uses : AF ; Special Requirements: None ;=============================================================== FI1$CLOSE: PUSH HL ; Save user REG CALL SIBUFR ; Get FI1 table address & set flag CALL NZ,FI$CLOSE ; Perform function if so POP HL ; Restore entry HL RET NZ ; ..return if error LD (FIFLG),A ; Else clear file active flag RET ; ..and quit ;=============================================================== ; NAME - FO1$CLOSE ; Entry: - None ; Exit : AF - A = 0 and Zero Flag Set (Z) if Ok ; A = Error Code and Zero Flag Reset (NZ) if Error ; Uses : AF ; Special Requirements: None ;=============================================================== FO1$CLOSE: PUSH HL ; Save user REG CALL SOBUFR ; Get FO1 table address & set flag CALL NZ,FO$CLOSE ; Perform function if so POP HL ; Restore entry HL RET NZ ; ..return if error LD (FOFLG),A ; Else clear file active flag RET ; ..and quit ;..... ; Set up pointers and transfer local flags to DSEG buffers SIBUFR: LD HL,FI1$TBL ; Get FI1 table address. LD A,(FIFLG) ; Get local file open flag LD (HL),A ; ..and initialize DSEG buffer OR A ; Is File Open? RET SOBUFR: LD HL,FO1$TBL ; Get FO1 table address. LD A,(FOFLG) ; Get Output status flag LD (HL),A ; ..and set in DSEG OR A ; Is File Open? RET ;==== Init Table and Buffers for F1 Routines ==== FIFLG: DEFB 0 ; Input file active flag in CSEG FOFLG: DEFB 0 ; Output file active flag in CSEG DSEG ; Tables here and init w/code FI1$TBL: I1$FLG: DEFS 1 ; Input file opened flag (1=NO) I1$CNT: DEFS 1 ; Input char count I1$PTR: DEFS 2 ; Input char ptr I1$FCB: DEFS 36 ; Input file FCB I1$BUF: DEFS 128 ; Input Buffer FO1$TBL: O1$FLG: DEFS 1 ; Output file opened flag (0=NO) O1$CNT: DEFS 1 ; Output char count O1$PTR: DEFS 2 ; Output char ptr O1$FCB: DEFS 36 ; Output file FCB O1$BUF: DEFS 128 ; Output Buffer END