;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;       Hangup.lit
;       Toggles RTS on AM-300 board so modem can be disconnected under
;       software/hardware control
;
;       Works from command mode, or in CMD file etc.
;       Runs logged out so will run after logoff
;       Author Cary Fitch,   CARY/AM,   Written: long ago and far away
;

       SEARCH SYS
       SEARCH SYSSYM
       SEARCH TRM

       PHDR    -2,PV$PRV,PH$REE!PH$REU ; runs logged out,
                               ; reentrent, reuseable

       JOBIDX                  ; get job pointer
       MOV     JOBTRM(A6),A5   ; get term pointer
       MOV     T.IDV(A5),A4    ; get idv pointer
       CMPW    -4(A4),#[AM3]   ; is first half of idv right?
       BNE     FINI            ; only works with am300
       CMPW    -2(A4),#[00 ]   ; is second half also ok?
       BNE     FINI            ; yes, so continue
       CMPW    JOBNAM(A6),#[PHO]       ; is first three letters PHO?
       BNE     FINI            ; if jobname doesn't start with PHO(ne) don't
                               ;  do this....cause it it not a remote job.
;       CRLF                    ; or any other advisements you might want to
;       TYPECR  <AMUS Network disconnecting...> ; stick in here
;       SLEEP   #20000.         ; let message finish
       MOVB    #0,D1
       BCALL   SENDIT          ; send the command
       SLEEP   #1000.          ; sleep a while so modem will go away
       MOVB    #205,D1         ; set modem enable flag
       BCALL   SENDIT          ; send the command
FINI:   EXIT                    ; end of program

SENDIT:
       MOV     T.IHW(A5),A4    ; hardware address into A4
       MOV     T.IHM(A5),D3    ; index port number into D3, and
       AND     #7,D3           ; strip to port number only, and
       MOVB    D3,4(A4)        ; select port.
       MOVB    #11,1(A4)       ; set command mode?, and
       MOVB    D1,@A4          ; forward the command, which
                               ; may set an interrupt, so...
       MOVB    #20,4(A4)       ; clear am300 interrupts.
       RTN
       END