12. FILE_CLOSE

*------------------------------------------------------------------------------
* NAME          FILE_CLOSE
*------------------------------------------------------------------------------
* DEPENDENCY    None
* PURPOSE       Close the channel passed in A0
* DESCRIPTION   Close the file channel whose QDOS ID is in A0. To prevent
*               any original QL systems from serious problems, checks for #0
*               being closed and ignores it.
* INPUTS :
*               A0.L = Channel ID to be closed
* OUTPUTS :
*               D0 is preserved as IO_CLOSE does not return errors except NOT
*               OPEN and we ignore these here ! The Z flag is indeterminate
*               after this subroutine.
*               A0.L is returned 'undefined' to avoid using the channel again !
*------------------------------------------------------------------------------
file_close  cmpa.l  #0,a0               ; Test for SuperBasic #0
            beq.s   fc_exit             ; Ignore it
            move.l  d0,-(a7)            ; Preserve the worker
            moveq   #io_close,d0        ; Prepare to close it
            trap    #2                  ; Close it
            move.l  (a7)+,d0            ; Restore the worker
fc_exit     rts