;*; Updated on 22-May-91 at 12:10 PM by John Paiement; edit time: 0:01:15
; [100]  - Created
; [101]  - Added rubout to entry processing
; [102]  - Modified screen draw module to TCRT codes to prevent awkward displays

    VMAJOR=1.
    VMINOR=0.
    VEDIT=102.

    .OFINI                                     ; Define buffers
    .OFDEF  BUFFER,32.                 ; Input buffer
    .OFDEF  BUF2,16                    ; Output buffer
    .OFDEF  BASE,1                     ; Current base
    .OFDEF  FUNC,1                     ; Current function
    .OFDEF  NOINP,1                    ; Process of input flag
    .OFDEF  XITFLG,1                   ; Program exit flag
    .OFDEF  INVAL,6                    ; Input value
    .OFDEF  ACCUM,6                    ; Current accumulated value
    .OFDEF  MEMVAL,6                   ; Current memory contents
    .OFDEF  DISVAL,6                   ; Value to be displayed
    .OFDEF  BYPASS,1                   ; Bypass buffer manipulation
    .OFDEF  RADIN,4                    ; Buffer for rad conversion
       .OFDEF  NFLAG,1                         ; Flag to indicate negative value
    .OFSIZ  IMPSIZ                     ; Allocate impure area


; Base constants
       DECN=0.
       HEXN=1.
       OCTN=2.
       RADN=3.
       BINN=4.
       PPNN=5.

; Function constants

       ADDF=1.
       SUBF=2.
       MULF=3.
       DIVF=4.
       ANDF=5.
       ORF =6.
       NOTF=7.
       XORF=8.


; Character constants

       ESC=27.
       CR=13.
       RUB=127.                                                ; [101]
       BELL=7.
       COMA=44.
       PERD=46.
       TAB=9.
       ZERO=48.
       ONE=49.
       SEVN=55.
       NINE=57.
       F=70.
       A=65.

; Process characters
       CLRM=20.                                                ;  clear memory
       CLRD=25.                                                ;  clear display

       LAND=1.                                         ;   logical functions
       LOR=15.                                         ; 
       LNOT=14.                                                ; 
       LXOR=24.                                                ; 

       MFNC=16.                                                ;  memory functions

       PLUS=43.                                                ; +
       MINS=45.                                                ; -
       TIMS=42.                                                ; *
       DIVS=47.                                                ; /
       EQLS=61.                                                ; =
       OBKT=91.                                                ; [
       CBKT=93.                                                ; ]

; -------------------------------------------------------------
;
; MACRO DELARATIONS
;

DEFINE  CLS                             ; Clear screen
       MOV             #65280.,D1
       TCRT
ENDM


DEFINE  DRWBOX  AA,BB,CC
;
; draw a box at AA,BB of CC height/width codes from table B-5
;
       MOVB            #AA,D1                   ; Position cursor to top left
       LSLW            D1,#8.                   ; Hand corner of of box
       MOVB            #BB,D1
       TCRT

       MOV             #65372.,D1               ; Box draw call
       TCRT
       TYPE            <CC>                     ; Height & width codes
       EVEN
ENDM


DEFINE  HORZLN  AA,BB,CC
;
; Draw a graphic line at AA,BB of CC columns ( line_len - 1)
;
       PRTTAB  AA,BB
       PRTTAB  -1,23.                          ; Set line draw mode
       MOV             #CC,D1
       PRTTAB  -1,44.                          ; Left side connector
00$$:
       PRTTAB  -1,46.                          ; Horizontal line character
       DEC             D1
       BNE             00$$

       PRTTAB  -1,43.                          ; Right side connector
       PRTTAB  -1,24.                          ; End line draw

ENDM


DEFINE  GRFCHR  AA,BB,CC
;
; Draw graphics character CC at AA,BB
;
       PRTTAB  AA,BB
       PRTTAB  -1,23.                          ; Line draw mode
       PRTTAB  -1,CC
       PRTTAB  -1,24.                          ; End line draw
ENDM



DEFINE  SCROFF
;
; Turn off screen display
;
       MOV             #65316.,D1                ; Blank screen code
       TCRT
ENDM


DEFINE  SCRON
;
; Turn on screen display
;
       MOV             #65317.,D1                ; Screen on code
       TCRT
ENDM


DEFINE PRTTAB AA,BB
;
; Emulate the print tab(x,x) function
;
       PUSH            D1
       MOVB            #AA,D1                   ; First param in MSB
       LSLW            D1,#8.
       MOVB            #BB,D1                   ; Second param in LSB
       TCRT
       POP              D1
ENDM


DEFINE WINROW AA
;
; Position cursor at row AA, col (D2)
;
       PUSH            D1
       MOVB            #AA,D1                   ; First param in MSB
       LSLW            D1,#8.
       MOVB            D2,D1                    ; Second param in LSB
       TCRT
       POP             D1
ENDM


DEFINE ROWCOL
;
; Emulate the print tab(x,x) function where row is already set at 5
; and offset by BASE(A5) * to by A2.  Column is passed in D2
;
       MOVB            #5,D1
       ADDB            BASE(A5),D1
       LSLW            D1,#8.
       MOVB            D2,D1
       TCRT
ENDM



DEFINE  ONEKEY
;
; Make KBD call only accept 1 key  ( from Assembler Programming by D. Heyliger )
;
       JOBIDX  A6
       MOV             JOBTRM(A6),A6
       ORW             #T$IMI,@A6
ENDM


DEFINE  ECHO
;
; Enable terminal echo of input  ( from Assembler Programming by D. Heyliger )
;
       JOBIDX  A6
       MOV             JOBTRM(A6),A6
       MOVW            #T$ECS,D1
       COMW            D1
       ANDW            D1,@A6
ENDM


DEFINE  SETHEX
;
; Set JOBTYP for hex output
;
       JOBIDX  A6
       MOVW            JOBTYP(A6),D1
       ORW             #J.HEX,D1
       MOVW            D1,JOBTYP(A6)
ENDM


DEFINE  SETOCT
;
; Set for JOBTYP octal output
;
       JOBIDX  A6
       MOVW            JOBTYP(A6),D1
       MOVW            #J.HEX,D4
       COMW            D4
       ANDW            D4,D1
       MOVW            D1,JOBTYP(A6)
ENDM


DEFINE  CLRBUF
;
; Clear input buffer
;
       LEA             A2,BUFFER(A5)
       MOV             #0,(A2)+
       MOV             #0,(A2)+
       MOV             #0,(A2)+
       MOV             #0,@A2
ENDM


DEFINE  CLRVAL
;
; Clear input float value
;
       LEA             A2,INVAL(A5)
       MOV             #0,(A2)+
       MOVW            #0,@A2
ENDM


DEFINE  CLRACC
;
; Clear accumulator float value
;
       LEA             A2,ACCUM(A5)
       MOV             #0,(A2)+
       MOVW            #0,@A2
ENDM