;***************************************************************************;
;                                                                           ;
;                                     C                                     ;
;             completely clear the screen and all message lines             ;
;                                                                           ;
;***************************************************************************;
;This program is useful when you bomb out of a program and need to clear
;not just the screen, but also the the top and bottom function key lines,
;turn off split screen mode, turn on the cursor, and so forth.
;
;Written by David Pallmann, UltraSoft Corporation.  Freeware.
;
;1.0(100)  14-Apr-88  created. /DFP

       SEARCH  SYS
       SEARCH  SYSSYM

       VMAJOR=1
       VMINOR=0
       VSUB=0
       VEDIT=100.
       VWHO=0

       .OFINI
       .OFDEF  TRMFLG,TC.SIZ
       .OFSIZ  MEMSIZ

DEFINE  T$FUNC  N
       MOVW    #-1_8.+N,D1
       TCRT
       ENDM

DEFINE  BIT     SRC,DST
       MOV     DST,D7
       AND     SRC,D7
       ENDM

DEFINE  MOVWL   SRC,DST
       CLR     D7
       MOVW    SRC,D7
       MOV     D7,DST
       ENDM

START:  PHDR    -2,,PH$REE!PH$REU       ; reenant, reusable, runs logged out
       GETIMP  MEMSIZ,A5               ; grab some memory
       TRMCHR  TRMFLG(A5)              ; get terminal characteristics

UNSPLIT:
       T$FUNC  56.                     ; turn off split screen

STATUS:
       BIT     #TD$STS,TRMFLG(A5)      ; status line capability?
       BEQ     CLEAR                   ;  no

TOP:    MOVWL   TRMFLG+TC.TSL(A5),D0    ; get size of top status line
       BEQ     UNSHIFTED               ;  zero
       T$FUNC  63.                     ; address top status line
       TYPESP                          ; address first cursor position
10$:    TYPESP                          ; clear space
       SOB     D0,10$                  ; loop till all clear
       T$FUNC  129.                    ; end status line

UNSHIFTED:
       MOVWL   TRMFLG+TC.USL(A5),D0    ; get size of unshifted status line
       BEQ     SHIFTED                 ;  zero
       T$FUNC  54.                     ; address unshifted status line
       TYPESP                          ; address first cursor position
10$:    TYPESP                          ; clear space
       SOB     D0,10$                  ; loop till all clear
       T$FUNC  129.                    ; end status line

SHIFTED:
       MOVWL   TRMFLG+TC.SSL(A5),D0    ; get size of shifted status line
       BEQ     CLEAR                   ;  zero
       T$FUNC  55.                     ; address shifted status line
       TYPESP                          ; address first cursor position
10$:    TYPESP                          ; clear space
       SOB     D0,10$                  ; loop till all clear
       T$FUNC  129.                    ; end status line

CLEAR:  T$FUNC  12.                     ; high intensity
       T$FUNC  28.                     ; cursor on
       T$FUNC  37.                     ; screen on
       T$FUNC  0                       ; clear the screen
       EXIT                            ; exit to AMOS

       END