TITLE PSEUDO-TTY HACK

A=1
B=2
C=3
D=4
P=17

TYI==1
TYO==2
PYI==3
PYO==4

GO:	MOVEI P,PDL-1
	.SUSET [.SMSK2,,[1_TYI+1_PYI+1_TYO]]
	.OPEN TYI,[SIXBIT /  $TTY/]
	 .LOSE %LSFIL
	.OPEN TYO,[SIXBIT /  %TTY/]
 	 .LOSE %LSFIL
	.OPEN PYI,[SIXBIT /   STY/]
	 .LOSE %LSFIL
	.OPEN PYO,[SIXBIT /  %STY/]
	 .LOSE %LSFIL
	.IOT PYO,[^Z]
	JFCL
	.HANG			;WAIT, AND WAIT, AND WAIT...


ZZ==.
LOC 42
	JSR TSINT
LOC ZZ
TSINT:	0
	0
	MOVE B,TSINT
	TRNE B,1_TYO
	 PUSHJ P,MORINT
	TRNE B,1_TYI
	 PUSHJ P,INTYI
	TRNE B,1_PYI
	 PUSHJ P,INPYI
	.DISMISS TSINT+1

INPYI:	PUSH P,TSINT+1
	.SUSET [.SDF2,,[1_PYI]]
	.SUSET [.SPICLR,,[-1]]
LP:	.IOT PYI,C
	JUMPL C,OUT		;THAT WASN'T REALLY A CHARACTER
	.IOT TYO,C
	JRST LP

CPOPJ:	POPJ P,

INTYI:	PUSH P,C
	MOVEI C,TYI
	.ITYIC C,
	 JRST POPCJ		;NOT REALLY A CHARACTER THERE
	.IOT TYI,C
	.IOT PYO,C
	JRST POPCJ

OUT:	.SUSET [.SPICLR,,[0]]
	.SUSET [.SDF2,,[0]]
	POP P,TSINT+1
	POPJ P,

MORINT:	PUSH P,C
	MOVEI C,[ASCIZ /--MORE--/]
	PUSHJ P,TYPSTR
	.IOT TYI,C
	PUSH P,C
	MOVEI C,[ASCIZ /
/]
	PUSHJ P,TYPSTR
	POP P,C
	CAIE C,40
	 CAIN C,177
	  CAIA
	.IOT PYO,C
POPCJ:	POP P,C
	POPJ P,

TYPSTR:	HRLI C,440700
TYPST1:	ILDB D,C
	JUMPE D,CPOPJ
	.IOT TYO,D
	JRST TYPST1

PDL:	BLOCK 50

END GO
