;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                                                    ;
;       CRTO Subroutine For Use In AlphaBASIC                        ;
;       Written By Stephen Caldwell 9/8/85                           ;
;       (213)947-3771                                                ;
;                                                                    ;
;       This subroutine will put a user defined message on 24,1      ;
;       ending with the message Any Key to Continue and then wait    ;
;       for keyboard input. If there is no message line 24 will not  ;
;       at the begining. This is handy if the user wants to display  ;
;       system error codes.                                          ;
;       On exit line 24 will be cleare                               ;
;                                                                    ;
; Example 1:                                                         ;
;       xcall CRTO,"File's Full must be expanded"                    ;
; Example 2:                                                         ;
;       ?tab(24,1);"Error #";ERR : xcall CRTO                        ;
;                                                                    ;
; This subroutine is donated to all AMUS members and must not be     ;
; sold.                                                              ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SEARCH  SYS
SEARCH  SYSSYM
SEARCH  TRM
COPY    XCALL

OBJNAM  CRTO.SBR

VMAJOR=2
VMINOR=0
VEDIT=0

OFINI
OFDEF   DATA,50.
OFSIZ   IMPSIZ

PHDR    -1,0,PH$REE!PH$REU              ; Reentrant and Reusable

DEFINE  CRT     ROW,COL,SAVE
       IF      NB,SAVE,PUSH D1
       MOVW    #ROW_10+COL,D1
       TCRT
       IF      NB,SAVE,POP D1
       ENDM

SAV:    JOBIDX  A0                      ; A0 indexes JCB
       LEA     A1,DATA                 ; A1 indexes local storage area
       MOV     JOBBAS(A0),(A1)+        ; save partition base
       MOV     JOBSIZ(A0),(A1)+        ; save partition size
       MOV     SP,(A1)+                ; save stack pointer
       MOV     A4,JOBBAS(A0)           ; set temporary base of partition
       MOV     A5,D0                   ; D0 contains end of free memory
       SUB     A4,D0                   ; D0 contains amount of free memory
       SUB     #4,D0                   ; subtract 4 to be safe
       MOV     D0,JOBSIZ(A0)           ; set temporary partition size
       CLR     @A4                     ; do a .DEL *.* on new partition
       MOV     4(A3),A2                ; A2 points to user message


       MOVB    #7,D1                   ; Prepare to beep
       TTY                             ; beep
       CRT     -1,29.                  ; Turn cursor off
       LIN                             ; Is there a message?
       JEQ     NOMSG                   ; No. Don't clear line 24 to start
       CRT     24.,1                   ; TAB(24,1)
       CRT     -1,9.                   ; TAB(-1,9)
       TTYL    @A2                     ; Put user message on screen
NOMSG:  CRT     24.,60.                 ; Tab(24,60)
       TYPE    <Any Key to Continue.>  ; Put my message on screen
       JOBIDX  A6                      ; Put the Terminal into
       MOV     JOBTRM(A6),A5           ;     Image Mode,
       ORW     #T$IMI!T$ECS,@A5        ;     with No Echo
       KBD     RETURN                  ; Get keyboard input
       CRT     24.,1                   ; TAB(24,1)
       CRT     -1,9.                   ; TAB(-1,9)
       CRT     -1,28.                  ; Turn cursor on
       JMP     RESTOR

RETURN: ANDW    #^CT$IMI!T$ECS,@A5      ; Put Terminal back to normal mode
;restore context

RESTOR: JOBIDX  A0                      ; A0 indexes JCB
       LEA     A1,DATA                 ; A1 indexes local storage area
       MOV     (A1)+,JOBBAS(A0)        ; restore partition base
       MOV     (A1)+,JOBSIZ(A0)        ; restore partition size
       MOV     (A1)+,SP                ; restore stack pointer

       RTN                             ; Return to AlphaBasic

       END