; TITLE "S0FILEIO - Syslib 4.0" NAME ('FIO0') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from S0FILEIO.Z80 V 1.2 by Al Dunsmuir/Richard Conn ; Date : 17 Sep 89 ; Version : 1.3 ; Module : S0FILEIO ; Abstract: This module contains the routines FI0$OPEN, F0$GET, ; FI0$CLOSE, FO0$OPEN, F0$PUT, and FO0$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 FI0$OPEN, F0$GET, FI0$CLOSE PUBLIC FO0$OPEN, F0$PUT, FO0$CLOSE ; External References EXT FI$OPEN, F$GET, FI$CLOSE EXT FO$OPEN, F$PUT, FO$CLOSE .Z80 CSEG ;=============================================================== ; NAME - FI0$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 ;=============================================================== FI0$OPEN: PUSH HL ; Save user Regs CALL SIBUFR ; Get FI0 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 - FO0$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 ;=============================================================== FO0$OPEN: PUSH HL ; Save user REG CALL SOBUFR ; Get FO0 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 - F0$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 ;=============================================================== F0$GET: PUSH HL ; Save user REG CALL SIBUFR ; Get FI0 table address & set flag JP F$GET ; Perform function ;=============================================================== ; NAME - F0$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 ;=============================================================== F0$PUT: PUSH HL ; Save user REG PUSH AF ; Save character CALL SOBUFR ; Get FO0 table address & set flag POP AF ; Restore character JP F$PUT ; Perform function ;=============================================================== ; NAME - FI0$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 ;=============================================================== FI0$CLOSE: PUSH HL ; Save user REG CALL SIBUFR ; Get FI0 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 - FO0$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 ;=============================================================== FO0$CLOSE: PUSH HL ; Save user REG CALL SOBUFR ; Get FO0 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,FI0$TBL ; Get FI0 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,FO0$TBL ; Get FO0 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 F0 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 FI0$TBL: I0$FLG: DEFS 1 ; Input file opened flag (0=NO) I0$CNT: DEFS 1 ; Input char count I0$PTR: DEFS 2 ; Input char ptr I0$FCB: DEFS 36 ; Input file FCB I0$BUF: DEFS 128 ; Input Buffer FO0$TBL: O0$FLG: DEFS 1 ; Output file opened flag (0=NO) O0$CNT: DEFS 1 ; Output char count O0$PTR: DEFS 2 ; Output char ptr O0$FCB: DEFS 36 ; Output file FCB O0$BUF: DEFS 128 ; Output Buffer END