22. INPUT

*------------------------------------------------------------------------------
* NAME          INPUT
*------------------------------------------------------------------------------
* DEPENDENCY    None
* PURPOSE       To obtain some input from the user via the channel ID in A0.
* DESCRIPTION   This routine allows the user to type some input into a buffer
*               (which is part of this subroutine) which allows a maximum of
*               256 bytes to be typed. A channel ID in A0 is used.
* INPUTS :
*               A0.L = Channel ID
* OUTPUTS :
*               D0 = Error code
*               D1.W = Number of characters typed EXCLUDING the ENTER character
*                      if D1.W = 0, user simply pressed ENTER.
*               A0 = Channel id (preserved)
*               A1 = Start of buffer (word count of string user typed)
*               Z flag set if no errors, unset otherwise.
*------------------------------------------------------------------------------
input       movem.l d2-d3,-(a7)         ; Preserve working registers
            lea     i_buffer+2,a1       ; Our buffer address plus 2
            move.l  a1,-(a7)            ; Save it on the stack
            moveq   #io_fline,d0        ; Input some bytes (inc linefeed)
            moveq   #256,d2             ; Buffer size maximum
            moveq   #infinite,d3        ; Inifinite timeout
            trap    #3

            move.l  (a7)+,a1            ; Restore buffer pointer
            subq.w  #1,d1               ; Subtract the linefeed character
            move.w  d1,-(a1)            ; Store length in buffer and set A1
            movem.l (a7)+,d2-d3         ; Restore those workers
            tst.l   d0                  ; Did it all work ?
            rts

i_buffer    ds.b    256+2               ; 256 chars for input plus 1 word for size.