Google
 

Trailing-Edge - PDP-10 Archives - BB-K818A-BM_1981 - sources/t20m.mac
There are no other files named t20m.mac in the archive.
;ADD ^C TRAPPING
;<ECG.FLEISCHER.GE>T20M.MAC.10, 18-Aug-80 17:25:33, EDIT BY ECG.FLEISCHER
;TTY STUFF:  CLEAR PAUSE ON END-OF-PAGE, SET PAUSE ON COMMAND
;SUPPRESS ECHOING OF GS,RS,US

;TOPS-20 MACRO support for GIGI Graphics Editor
;Rick Ace  NYIT

	SALL
	SEARCH MONSYM,MACSYM
	TITLE T20M

	EXTERN FLUSHO		;FLUSH PUTC OUTPUT TO TTY OR DISK FILE
	EXTERN TTYRES		;RESTORE TTY PARAMETERS BEFORE EXITING

CCCHN==0			;PSI CHANNEL FOR ^C TRAPPING

R0==0
T1==1
T2==2
T3==3
T4==4
AP==16				;FORTRAN ARGUMENT-LIST POINTER


;DATA AREAS FOR TEXTI JSYS

TIBI:	EXP TIBSZ-1		;INITIAL VALUES FOR ARG BLOCK
	RD%BEL+RD%CRF+RD%JFN
	.PRIIN,,.PRIOU		;JFNS
	-1,,IBUF		;DESTINATION STRING
	EXP IBUFSZ*5		;# OF BYTES IN DEST STRING
	-1,,IBUF		;BEGINNING OF DEST BUFFER
	POINT 36,0		;PROMPT STRING
TIBSZ==.-TIBI
IBUFSZ==^D25
TIB:	BLOCK TIBSZ		;TEXTI ARGUMENT BLOCK
IBUF:	BLOCK IBUFSZ		;TYPEIN BUFFER

;MISCELLANEOUS DATA

FF:	EXP -1			;FIRST-TIME FLAG
ORGMOD:	BLOCK 1			;ORIGINAL TTY MODES
EOP:	BLOCK 1			;INITIAL SETTING OF PAUSE ON END-OF-PAGE
SUBTTL Graphics Editor MACRO Subroutines

;FIRSTX - THIS CODE GETS EXECUTED ONCE, WHEN THE PROGRAM STARTS.  THE FIRST
;	  THING THE MAIN PROGRAM SHOULD DO IS CALL UTTY, WHICH CALLS FIRSTX.

FIRSTX:

;SET UP PROPER TRANSLATION OF CONTROL CHARACTERS BY TOPS-20

	MOVEI T1,.PRIOU
	RFCOC
	TRO 3,2B19		;SEND REAL ESCAPES, NOT $
	TRZ 3,1B19
	TRZ 3,3B21+3B23+3B25+3B27 ;DON'T ECHO FS, GS, RS, US
	SFCOC

;REMEMBER CURRENT SETTING OF PAUSE ON END-OF-PAGE

	MOVEI T1,.CTTRM
	MOVEI T2,.MORXO
	MTOPR			;READ INITIAL SETTING OF PAUSE ON E-O-P
	MOVEM T3,EOP		;REMEMBER IT

;TRAP ^C; I.E., WHEN USER TYPES ^C, JUMP TO CCHDLR ROUTINE
;CAREFUL!!!  THIS STUFF CAN POTENTIALLY INTERFERE WITH PA1050, WHICH
;OWNS THE SOFTWARE INTERRUPT (PSI) SYSTEM FOR THIS PROCESS

	MOVE T1,[.TICCC,,CCCHN]	;TERMINAL CODE ,, PSI CHANNEL #
	ATI			;PUT ^C ON PSI CHANNEL
	 ERJMP NOCC		;IGNORE IF NO ^C CAPABILITY

;DO THE REMAINDER OF THE PSI WORK TO TRAP ^C

	MOVEI T1,.FHSLF
	RIR			;GET CHNTAB ADDRESS IN RH(T2)
	HRRZS T2		;CLEAR LH
	MOVE T3,[1,,CCHDLR]	;GET LEVEL# ,, HANDLER ADDRESS
	MOVEM T3,CCCHN(T2)	;STUFF IT IN CHNTAB
	MOVX T2,1B<CCCHN>	;GET BIT CORRESPONDING TO CHANNEL #
	AIC			;TURN THAT CHANNEL ON
NOCC:
	RET

;**************************************************************************

;CCHDLR - THIS CODE IS ENTERED AT INTERRUPT LEVEL 1 WHEN THE USER TYPES ^C.
;	  IT JUST RESTORES AS MUCH TERMINAL STUFF AS POSSIBLE AND EXITS.

CCHDLR:	CALL FLUSHO		;FLUSH ANY CURRENT OUTPUT TO THE TTY
	CALL TTYRES		;CALL GE ROUTINE TO RESTORE STUFF
	HALTF			;HALT
	JRST .-1		;EXIT IF USER TYPES "CONTINUE"
;INTEGER FUNCTION GETLIN(PROMPT,BUFFER,MAXC)
; CHAR PROMPT(len1)	#PROMPT STRING
; CHAR BUFFER(len2)	#TEXT RETURNED WITH TRAILING Newline AND Eos
; INT MAXC		#SIZE OF BUFFER (len1)
;RETURNS: LENGTH OF STRING INCLUDING Newline, BUT NOT INCLUDING Eos

GETLIN::PUSH P,T1		;SAVE T1-T4
	PUSH P,T2
	PUSH P,T3
	PUSH P,T4
	PUSH P,AP
	MOVEI AP,[0]
	CALL FLUSHO		;FLUSH ANY PENDING OUTPUT
	POP P,AP
	MOVE T1,[TIBI,,TIB]	;COPY SKELETON TEXTI BLOCK TO TIB
	BLT T1,TIB+TIBSZ-1
	MOVE T1,0(AP)		;GET ADDRESS OF PROMPT STRING
	HRRM T1,TIB+.RDRTY	;STORE PTR TO PROMPT IN ARG BLOCK
	MOVE T1,TIB+.RDRTY	;GET POINTER TO PROMPT STRING
	PSOUT			;WRITE PROMPT
	MOVEI T1,TIB		;GET ADDR OF TEXTI ARG BLOCK
	TEXTI			;READ REPLY
	 JFCL

;NOW TRANSFER THE INPUT TO THE CALLER'S BUFFER

	MOVEI R0,1		;FUNCTION VALUE
	MOVE T1,[POINT 7,IBUF]	;GET POINTER TO TYPED-IN TEXT
	MOVE T3,1(AP)		;GET ADDRESS OF DESTINATION
GL1:	ILDB T2,T1		;GET TYPED-IN CHARACTER
	CAML R0,@2(AP)		;COUNT EXCEEDED?
	MOVEI T2,.CHLFD		;YES, SIMULATE END-OF-LINE
	MOVEM T2,(T3)		;TRANSFER IT TO CALLER'S BUFFER
	AOS T3			;BUMP DESTINATION POINTER
	CAIE T2,.CHLFD		;N/L ?
	AOJA R0,GL1		;NO, KEEP LOOPING
	SETZM 1(T3)		;APPEND Eos
	POP P,T4		;RESTORE T1-T4
	POP P,T3
	POP P,T2
	POP P,T1
	RET
;SUBROUTINE TTSOUT(STRING,CRLFF)
; CHAR STRING(Arbitrary)	#STRING TO BE WRITTEN, NULL-TERMINATED
; INT CRLFF			#IF != 0, WRITE CRLF AFTER STRING

TTSOUT::MOVE T1,0(AP)		;GET ADDRESS OF PROMPT STRING
	HRLI T1,(POINT 36)	;MAKE A BYTE POINTER
	PSOUT			;WRITE TO TERMINAL
	HRROI T1,[ASCIZ/
/]
	SKIPE @1(AP)		;WANT CRLF?
	PSOUT			;YES, DO IT
	RET
;SUBROUTINE UTTY(FUNCTION)
; PERFORMS VARIOUS OPERATING-SYSTEM-DEPENDENT TERMINAL FUNCTIONS
; SEE GDEF FOR FUNCTION CODE DEFINITIONS

UTTY::	AOSG FF			;FIRST TIME?
	CALL FIRSTX		;YES, CALL ONE-SHOT CODE
	MOVEI 1,.PRIIN
	RFMOD			;GET TTY MODES IN T2
	SKIPG FF		;FIRST TIME?
	MOVEM T2,ORGMOD		;YES, REMEMBER ORIGINAL TTY MODES
	MOVE T4,@0(AP)		;GET FUNCTION CODE
	JRST UTV(T4)		;DISPATCH
UTV:	0
	JRST [	MOVE 2,ORGMOD	;1 RESTORE ALL
		STPAR
		MOVEI T1,.CTTRM	;RESTORE INITIAL SETTING OF PAUSE ON E-O-P
		MOVEI T2,.MOXOF
		SKIPE T3,EOP	;WAS IT ON INITIALLY?
		MTOPR		;YES, TURN IT ON
		RET]
	JRST [	TXZ 2,TT%WID	;2 CLEAR OPERATING-SYSTEM WRAPAROUND
		TXO 2,TT%PGM	;  ALSO SET TERMINAL PAUSE ON COMMAND
		STPAR
		SKIPN EOP	;PAUSING ON END-OF-PAGE?
		RET		;NO, RETURN
		MOVEI T1,.CTTRM	;YES, HAVE TO CLEAR THAT
		MOVEI T2,.MOXOF
		MOVEI T3,.MOOFF
		MTOPR		;TURN OFF PAUSE ON END-OF-PAGE
		RET]
	JRST UTV+1		;3 RESTORE O/S AUTOWRAP (HACK)
	JRST [	TXZ 2,TT%ECO	;4 CLEAR ECHO
		SFMOD
		RET]
	JRST [	TXO 2,TT%ECO	;5 SET ECHO
		SFMOD
		RET]
;INTEGER FUNCTION IAND(ARG1,ARG2)
;		  IEOR(ARG1,ARG2)
;		  IOR(ARG1,ARG2)
; RETURNS LOGICAL "AND", "EOR", OR "OR" OF ARGUMENTS

IAND::	MOVE 0,@0(AP)
	AND 0,@1(AP)
	RET

IEOR::	MOVE 0,@0(AP)
	XOR 0,@1(AP)
	RET

IOR::	MOVE 0,@0(AP)
	OR 0,@1(AP)
	RET

	END