;***************************************************************************
; AAA.M68  -  Alphanso's Assembler Assylum Universal file
;
;       by Dave Heyliger - AMUS Staff
;       last update     01/07/87
;
;       Functions:      PRTTAB - acts just like PRINT TAB (#,#) from BASIC
;                       NOECHO - turns off keyboard echoing
;                       ECHO   - turns keyboard echoing back on
;                       ONEKEY - makes the KBD call 1 character to D1
;                       MLTKEY - makes the KBD call multiple keys, A2 pointer
;                       CLRCTC - Clear a pending ^C from within the program
;                       NOCTC  - "set" NOCTRLC
;                       CTC    - "set" CTRLC
;                       HEX    - "set" HEX
;                       OCTAL  - "set" OCTAL
;
;       Note: place assembled AAA.UNV in the MAC: account, DSK0:[7,7]
;***************************************************************************

UNIVERSAL

DEFINE  PRTTAB  AA,BB
        PUSH    D1
        MOVB    #AA,D1
        LSLW    D1,#10
        MOVB    #BB,D1
        TCRT
        POP     D1
ENDM

DEFINE  NOECHO                  ;makes keyboard entries "invisible"
        PUSH    A6              ;"black box"
        JOBIDX  A6              ;give A6 the JOBIDX
        MOV     JOBTRM(A6),A6   ;A6 points to the Terminal Status Word
        ORW     #T$ECS,@A6      ;second bit now contains a "1" (no echo)
        POP     A6              ;restore original
ENDM

DEFINE  ECHO                    ;turns ECHO back on for keyboard input
        PUSH    A6              ;"black box"
        PUSH    D4
        JOBIDX  A6              ;get the JOBIDX
        MOV     JOBTRM(A6),A6   ;A6 points to the Terminal Status Word
        MOVW    #T$ECS,D4       ;D4 contains 00000010
        COMW    D4              ;D4 contains 11111101
        ANDW    D4,@A6          ;second bit now contains a "0"
        POP     D4              ;restore originals
        POP     A6
ENDM

DEFINE  ONEKEY                  ;makes KBD only accept one key (D1 holds it)
        PUSH    A6              ;"black box"
        JOBIDX  A6              ;get JCB pointer
        MOV     JOBTRM(A6),A6   ;A6 holds pointer to TSW
        ORW     #T$IMI,@A6      ;set "one key" for KBD (D1 will hold char.)
        POP     A6              ;restore original
ENDM

DEFINE  MLTKEY                  ;multiple keystrokes on KBD call (A2 pointer)
        PUSH    A6              ;"black box"
        PUSH    D4
        JOBIDX  A6
        MOV     JOBTRM(A6),A6   ;A6 holds pointer to TSW
        MOVW    #T$IMI,D4       ;we will complement this value
        COMW    D4              ;to set up the AND so as to
        ANDW    D4,@A6          ;turn off the T$IMI bit (back to normal mode)
        POP     D4              ;restore originals
        POP     A6
ENDM

DEFINE  CLRCTC                  ;clear out a ^C when user hits one (fool them)
        PUSH    A6              ;"black box"
        PUSH    D7
        TYPECR  ^C              ;simulates user "exiting" by displaying a ^C
        JOBIDX  A6              ;A6 now contains pointer to JOBIDX (JOBSTS)
        MOVW    #J.CCC,D7       ;Reg. D7 contains ^C abort flag
        COMW    D7              ;logical one's complement (0->1 and 1->0)
        ANDW    D7,@A6          ;flag is now turned OFF
        POP     D7              ;restore originalS
        POP     A6
ENDM

DEFINE  NOCTC                   ;"set noctrlc"
        PUSH    A6              ;"black box"
        PUSH    D7
        JOBIDX  A6              ;point to JOBIDX (JOBSTS)
        LEA     A6,JOBTYP(A6)   ;A6 points to JOBTYP word
        MOVW    #J.CCA,D7       ;Reg. D7 contains ^C enable flag
        COMW    D7              ;flip the bits
        ANDW    D7,@A6          ;^C disabled
        POP     D7              ;restore originals
        POP     A6
ENDM

DEFINE  CTC                     ;"set ctrlc"
        PUSH    A6              ;"black box"
        JOBIDX  A6              ;point to JOBIDX (JOBSTS)
        LEA     A6,JOBTYP(A6)   ;A6 points to JOBTYP word
        ORW     #J.CCA,@A6      ;^C set
        POP     A6              ;restore original
ENDM

DEFINE  HEX                     ;set binary output to HEX
        PUSH    A6              ;"black box"
        JOBIDX  A6              ;point to JOBIDX (JOBSTS)
        LEA     A6,JOBTYP(A6)   ;A6 points to JOBTYP word
        ORW     #J.HEX,@A6      ;HEX set
        POP     A6              ;restore original
ENDM

DEFINE  OCTAL                   ;set OCTAL
        PUSH    A6              ;"black box"
        PUSH    D7
        JOBIDX  A6              ;point to JOBIDX (JOBSTS)
        LEA     A6,JOBTYP(A6)   ;A6 points to JOBTYP word
        MOVW    #J.HEX,D7       ;get the flag number
        COMW    D7              ;flip the bits
        ANDW    D7,@A6          ;OCTAL set
        POP     D7              ;restore original
        POP     A6
ENDM