We are hiring ! See our job offers.
Raw File
tvbug.118
TITLE TVBUG

.MLLIT==1

TTYI==1
TTYO==2
DSKI==3
DSKO==4

MAPSIZ==3		; SIZE OF BLOCK IN LINE MAP

; OFFSETS INTO LINE BLOCK IN MAP
BUF==0			; SAVED BYTE POINTER TO ^M TERMINATING LINE
HP==1			; HORIZONTAL POSITION
CHAR==2			; # OF CHARACTERS ON LINE

O=0
A=1
B=2
C=3
D=4
E=5
F=6
CCT=7			; COUNT OF CHARACTERS IN BUFFER
BUFPTR=10		; BYTE POINTER TO LAST CHARACTER IN BUFFER
CHPOS=11		; HPOS ON CURRENT LINE
CCHARS=12		; # OF CHARACTERS ON CURRENT LINE
PREV=13			; POINTER TO ENTRY IN LINE MAP FOR PREVIOUS LINE
P=17

SUBTTL	MACROS

DEFINE ECHO
	.IOT TTYO,A
TERMIN

; LOSSAGES
DEFINE FATINS NAME\
	.VALUE	[ASCIZ /: FATAL ERROR -- !NAME!
/]
TERMIN

; DECREMENT BYTE POINTER
DEFINE DBP AC
	ADD	AC,[70000,,]
	TLNE	AC,400000
	ADD	AC,[347777,,-1]
TERMIN

LOC	40
	0
	JSR	UUOH
	JSR	TSINT
LOC	100

	SUBTTL	VARIABLES

PDL:	BLOCK	30
INPBUF:	BLOCK	200.		; TTY INPUT BUFFER
INBLEN:	5*.-5*INPBUF		; # OF CHARACTERS ALLOWABLE
LINMAP:
INPPTR:	440700,,INPBUF		; BYTE POINTER TO START OF INPUT BUFFER
	BLOCK	199.		; LINE MAP
MAPLEN:	MAPSIZ*LINMAP-MAPSIZ*.,,LINMAP		; AOBJN POINTER TO LINE MAP STORAGE

DBUF:	BLOCK	200.		; BUFFER FOR COPYING FILES TO TTY
DBUFLN==.-DBUF
DBUFPT:	440700,,DBUF		; BYTE POINTER TO FILE BUFFER
PDLPTR:	-30,,PDL-1		; INITIAL PDL POINTER
JCL:	BLOCK	20.		; FOR JCL

DHEAD:	ASCIZ	/TRIVIA is already down, but please describe your bug./
HEADER:	ASCIZ	/Please describe your bug./
PRMPT:	ASCIZ	/Message:  /

ALLOW:	-1			; IF -1, TRIVIA IS NOT ALREADY DOWN
MAINT:	0			; IF XUNAME IS MARC OR TAA
XUNAME:	0
INTALL:	0			; IF -1, CTRL-S WORKS
QMODE:	0			; CTRL-Q TYPED
TTYOPT:	0
LSTERR:	0
LETRUB:	0			; IF -1, %TOERS IS ON FOR THIS TTY
XCTRUB:	0			; PUSHJ XCT'ED TO DO RUBOUTS
DSKIOT:	.IOT	DSKO,A
DSKUPA:	.IOT	DSKO,["^]
TTYIOT:	.IOT	TTYO,A
TTYUPA:	.IOT	TTYO,["^]
XCTIOT:	0			; XCT'ED BY UUO'S
XCTUPA:	0
UUOD:	0
UUOE:	0
BASE:	0
HPOS:	0
CTRLJ:	0			; PRINT ^M^J FOR CRLF INSTEAD OF JUST ^M



START:	MOVE	P,PDLPTR
	PUSHJ	P,TTYOPN
	MOVE	O,TTYIOT	; SET UP OUTPUT INSTRUCTIONS FOR UUO'S
	MOVEM	O,XCTIOT
	MOVE	O,TTYUPA
	MOVEM	O,XCTUPA
	SETOM	ALLOW
	.SUSET	[.RXUNAME,,A]
	MOVEM	A,XUNAME
	CAME	A,[SIXBIT /MARC/]	; FOR SPECIAL HACKS
	 CAMN	A,[SIXBIT /TAA/]
	  JRST	[SETOM	MAINT
		 PUSHJ	P,JCLRED
		  JRST	STCONT
		 JRST	KILL]
STCONT:	MOVEM	A,XUNAME
	MOVEI	A,HEADER
	.CALL	[SETZ		; SEE IF TRIVIA DOWN
		 SIXBIT /OPEN/
		 [.BII,,DSKI]
		 [SIXBIT /DSK/]
		 [SIXBIT /TRIVIA/]
		 [SIXBIT /DEATH/]
		 SETZ [SIXBIT /_MSGS_/]]	; IS IT ALREADY DOWN?
	 JRST	PHEAD
	.CLOSE	DSKI,
	SETZM	ALLOW		; IF SO, TURKEY CAN'T BRING IT DOWN
	MOVEI	A,DHEAD
PHEAD:	OASCR	(A)

; READER
READ:	SETZ	CCT,		; INITIALIZE CHARACTER COUNT
	MOVE	BUFPTR,INPPTR	; INITIALIZE BYTE POINTER TO INPUT BUFFER
	SETZB	CCHARS,CHPOS
	MOVE	PREV,MAPLEN
PPRMPT:	OASCR	PRMPT		; PRINT PROMPT
GETCHR:	.IOT	TTYI,A		; GET CHAR IN A
	SKIPE	QMODE		; QUOTE THIS CHARACTER
	 JRST	QHACK
	CAIGE	A,34
	 JRST	@CHNDTB(A)
	CAIN	A,177		; RUBOUT
	 JRST	DORUB
	CAIN	A,"?		; MUST BE FIRST CHARACTER TO BE SPECIAL
	 JRST	DOHELP
DOECHO:	ECHO
DEPCHR:	SETZM	QMODE
DEPCH1:	PUSHJ	P,GETSIZ	; # OF POSITIONS OCCUPIED BY CHARACTER
	ADD	CHPOS,B		; CURRENT HPOS
	ADDI	CCHARS,1	; # OF CHARACTERS ON CURRENT LINE
	ADDI	CCT,1		; TOTAL # OF CHARACTERS IN BUFFER
	CAML	CCT,INBLEN	; NUMBER OF SPACES IN INPUT BUFFER
	 JRST	AGC
	IDPB	A,BUFPTR
	JRST	GETCHR

; DISPATCH TABLE FOR HANDLING OF CONTROL CHARACTERS (0-33)
CHNDTB:	CLRBUF			; CTRL-@:  CLEAR BUFFER
	DOECHO
	DOECHO
	DOECHO			; CTRL-C
	PRTBUF			; CTRL-D
	DOECHO
	DOECHO
	DIE			; CTRL-G
	DOECHO
	DOECHO
	DOECHO			; CTRL-J
	DOECHO
	CLRSCR			; CTRL-L
	CRLFHK			; CTRL-M
	DOECHO
	DOECHO
	ICTLP			; CTRL-P
	QSETUP			; CTRL-Q
	DOECHO
	CLRBUF			; CTRL-S
	DOECHO
	DOECHO
	DOECHO
	WDKILL			; CTRL-W
	LNKILL			; CTRL-X
	DOECHO
	DOECHO
	PTMAIL			; ALTMODE


SUBTTL	SPECIAL READER ROUTINES

; HANDLE CARRIAGE RETURN	
CRLFHK:	ECHO
	ADDI	CCT,1
	IDPB	A,BUFPTR
	ADD	PREV,[MAPSIZ,,MAPSIZ]	; SAVE AWAY THIS LINE
	JUMPGE	PREV,GROLIN		; OUT OF SPACE IN LINE MAP
	MOVEM	BUFPTR,BUF(PREV)
	MOVEM	CHPOS,HP(PREV)
	MOVEM	CCHARS,CHAR(PREV)
	SETZB	CCHARS,CHPOS
CRLDON:	MOVEI	A,^J		; PUT ^J IN BUFFER
	JRST	DEPCHR

; CTRL-Q TYPED
QSETUP:	SETOM	QMODE
	ECHO
	JRST	GETCHR

; QUOTE A CHARACTER
QHACK:	SKIPE	LETRUB		; ERASE CTRL-Q
	 JRST	[OCTLP "X
		 OCTLP "X
		 JRST .+1]
	CAIN	A,^M		; CAN'T QUOTE CARRIAGE RETURN
	 JRST	CRLFHK
	JRST	DOECHO

; CLEAR SCREEN AND REDISPLAY BUFFER
CLRSCR:	OCTLP	"C		; FOR CTRL-L
	JRST	RREP

; REDISPLAY BUFFER
PRTBUF:	ECHO			; FOR CTRL-D
	OASCR	[0]
RREP:	OASCR	PRMPT
	PUSHJ	P,BUFPRT
	JRST	GETCHR

BUFPRT:	PUSH	P,A		; PRINT CONTENTS OF INPUT BUFFER
	PUSH	P,B
	MOVE	A,INPPTR	; POINTER TO BEGINNING OF INPUT
	MOVE	B,CCT		; # OF CHARACTERS
	.CALL	[SETZ
		 SIXBIT /SIOT/
		 MOVEI	TTYO
		 A
		 SETZ	B]
	 .LOSE	1000
	POP	P,B
	POP	P,A
	POPJ	P,

; CTRL-P STORED AS ^PP IN INPUT BUFFER, SO WILL REDISPLAY NICELY
ICTLP:	OCTLP	"P		; FOR CONTROL-P
	IDPB	A,BUFPTR
	ADDI	CCHARS,2
	ADDI	CCT,2
	ADDI	CHPOS,2
	MOVEI	A,"P
	IDPB	A,BUFPTR
	JRST	GETCHR

; START OVER ON INPUT
CLRBUF:	OASCR	[0]		; FOR CTRL-@ AND CTRL-S
	JRST	READ

; IF ? IS FIRST CHARACTER, PRINT INSTRUCTIONS
DOHELP:	JUMPN	CCT,DOECHO
	OASCR	HLPMSG
	JRST	PPRMPT

HLPMSG:	ASCIZ	/Please describe as completely as possible the bug you
encountered.  Useful characters:
  ctrl-@:  Clears buffer
  ctrl-D:  Redisplays buffer
  ctrl-G:  Kills the program
  ctrl-L:  Clears screen and redisplays buffer
  ctrl-Q:  Quotes next character
  ctrl-W:  Deletes last word in buffer
  ctrl-X:  Deletes last line in buffer
  altmode: Terminates message
  rubout:  Deletes last character in buffer
/


	SUBTTL	RUBOUT HANDLERS

; COME HERE FOR RUBOUTS
DORUB:	PUSHJ	P,RUBBER
	 JRST	READ		; IF NOTHING TO RUBOUT
	JRST	GETCHR

; COMMON CODE FOR RUBOUTS
RUBBER:	SOJL	CCT,CPOPJ
	PUSH	P,A
	LDB	A,BUFPTR	; VICTIM
	SUBI	CCHARS,1
	DBP	BUFPTR		; UPDATE BYTE POINTER TO INPUT
	XCT	XCTRUB		; TO RUBECH OR RUBFLS, DEPENDING ON %TOERS
	POP	P,A
POPJ1:	AOS	(P)		; SKIP RETURN IF SOMETHING WAS RUBBED OUT
CPOPJ:	POPJ	P,

; RUBOUT CODE FOR PRINTING TERMINALS--CRETINOUS
RUBECH:	CAIN	A,177		; ECHO A RUBOUT
	 JRST	[OASC	[ASCIZ /^?/]
		 POPJ	P,]
	CAIN	A,^J
	 JRST	RECHLF
	CAIN	A,P
	 JRST	RECHP
RUBEC1:	OASCI	(A)		; ECHO THE CHARACTER RUBBED OUT
	POPJ	P,

; RUB OUT A P
RECHP:	LDB	O,BUFPTR
	CAIE	O,^P
	 JRST	RUBEC1
	SUBI	CCHARS,1
	SUBI	CCT,1
	DBP	BUFPTR
	OCTLP	"P
	POPJ	P,

; RUBOUT A LF
RECHLF:	LDB	A,BUFPTR
	CAIN	A,^M
	 JRST	RECHCR
	MOVEI	A,^J
	.IOT	TTYO,A
	POPJ	P,

; RUBOUT A CR
RECHCR:	DBP	BUFPTR
	SUBI	CCT,1
	MOVE	CHPOS,HP(PREV)
	MOVE	CCHARS,CHAR(PREV)
	SUB	PREV,[MAPSIZ,,MAPSIZ]
	OASCR	[0]
	POPJ	P,


; RUBOUT CODE FOR DISPLAYS
RUBFLS:	CAIN	A,177		; RUBOUT MAY BE TWO POSITIONS
	 JRST	TSTSAI
	CAIN	A,"P		; P REQUIRES SPECIAL HANDLING SINCE ^P-->^PP
	 JRST	RUBP
	CAIL	A,40		; SPACE (AND ABOVE?) ALWAYS ONE POSITION
	 JRST	RUBONE
	CAIN	A,^I		; TABS REQUIRE SPECIAL HANDLING
	 JRST	RUBTAB
	CAIN	A,^J		; MAY INDICATE CRLF
	 JRST	RUBLF
	CAIN	A,^H		; BECAUSE AOS HORIZONTAL POSITION
	 JRST	RUBBCK
TSTSAI:	MOVE	O,TTYOPT
	TLNE	O,%TOSAI
	 JRST	RUBONE
	CAIN	A,177		; RUBOUT TAKES TWO POSITIONS
	 JRST	RUBTWO
	CAIN	A,33		; ALTMODE TAKES ONE POSITION
	 JRST	RUBONE
RUBTWO:	OCTLP	"X		; DO THE RUBOUT(S)
	SUBI	CHPOS,1
RUBONE:	OCTLP	"X
	SUBI	CHPOS,1
	POPJ	P,

; SPECIAL ROUTINES FOR RUBBING OUT RANDOMNESS

; RUBOUT BACKSPACE
RUBBCK:	ADDI	CHPOS,1
	LDB	O,BUFPTR	; ECHO CHARACTER BEFORE BACKSPACE
	.IOT	TTYO,O
	POPJ	P,

; RUBOUT TAB
RUBTAB:	PUSH	P,B
	PUSH	P,C
	PUSH	P,D
	MOVE	C,BUF(PREV)	; GET BEGINNING OF THIS LINE
	MOVE	O,CCHARS	; # OF CHARACTERS ON THIS LINE
	SETZ	D,		; ACCUMULATE HORIZONTAL POSITION
RTABLP:	ILDB	A,C
	PUSHJ	P,GETSIZ	; SIZE OF CHARACTER
	ADD	D,B
	SOJG	O,RTABLP
	MOVE	CHPOS,D		; NEW HORIZONTAL POSITION
	ADDI	D,8
	OCTLP	"H		; ^PH FOLLOWED BY HPOS+8
	.IOT	TTYO,D
	POP	P,D
	POP	P,C
	POP	P,B
	POPJ	P,

; RUBOUT LINEFEED:  EITHER LINESTARVE OR FLUSH CRLF
RUBLF:	LDB	A,BUFPTR
	CAIN	A,^M		; IS BUFFER ^M^J
	 JRST	RUBCRL
	OCTLP	"U		; DO LINE STARVE
	POPJ	P,

; RUBOUT CRLF
RUBCRL:	DBP	BUFPTR		; GET RID OF ^M
	SUBI	CCT,1
	MOVE	CHPOS,HP(PREV)	; GET DATA FOR PREVIOUS LINE
	MOVE	CCHARS,CHAR(PREV)
	SUB	PREV,[MAPSIZ,,MAPSIZ]
	OCTLP	"U		;  GO TO PREVIOUS LINE
	OCTLP	"H		; GO TO END
	MOVEI	A,8(CHPOS)
	.IOT	TTYO,A
	POPJ	P,

; HANDLE CTRL-X:  KILL THIS LINE
LNKILL:	MOVE	BUFPTR,BUF(PREV)
	CAME	PREV,MAPLEN		; FIRST LINE
	 JRST	LNNORM
	SETZB	CCT,CCHARS		; SO CLEAR EVERYTHING
	SETZ	CHPOS,
	JRST	LNMUNG
LNNORM:	IBP	BUFPTR			; GET PAST CTRL-J
	SUBI	CCT,-1(CCHARS)		; UPDATE CCT
	SETZ	CHPOS,			; UPDATE CURRENT LINE
	MOVEI	CCHARS,1		; BECAUSE CTRL-J IS ON LINE
LNMUNG:	SKIPN	LETRUB			; IF CAN'T DO %TOERS, JUST ECHO CRLF
	 JRST	[OASCR	[ASCIZ / XXX?/]
		 JRST	GETCHR]
	OCTLP	"H			; GO TO BEGINNING OF LINE
	.IOT	TTYO,[8]
	OCTLP	"L			; AND KILL TO END
	JRST	GETCHR

; HANDLE CTRL-W--KILL WORD
WDKILL:	PUSH	P,A
WLOP1:	JUMPE	CCT,WLEAVE		; FLUSH INVISIBLE CHARACTERS
	LDB	A,BUFPTR
	CAIE	A,^I
	 CAIN	A,^J
	  JRST	WRUB
	CAIE	A,40
	 CAIN	A,^H
	  JRST	WRUB
	JRST	WLOP2
WRUB:	PUSHJ	P,RUBBER
	 JRST	WLEAVE
	JRST	WLOP1
WLOP2:	JUMPE	CCT,WLEAVE		; THEN FLUSH TO INVISIBLE CHARACTER
	PUSHJ	P,RUBBER
	 JRST	WLEAVE
	LDB	A,BUFPTR
	CAIE	A,^I
	 CAIN	A,^J
	  JRST	WLEAVE
	CAIN	A,40
	 JRST	WLEAVE
	JRST	WLOP2
WLEAVE:	POP	P,A
	JRST	GETCHR

; RUBOUT P
RUBP:	LDB	O,BUFPTR
	CAIE	O,^P		; IF PRECEDED BY CTRL-P
	 JRST	RUBONE
	SUBI	CCHARS,1
	SUBI	CCT,1
	DBP	BUFPTR
	JRST	RUBTWO


; GET SIZE OF CHARACTER.  CHAR IN A, SIZE RETURNED IN B.
GETSIZ:	CAIGE	A,40
	 JRST	GETSZ1
	MOVEI	B,1
	POPJ	P,
GETSZ1:	MOVE	B,TTYOPT
	TLNE	B,%TOSAI	; OF %TOSAI, SIZE IS ONE
	 JRST	[MOVEI B,1
		 POPJ P,]
	PUSH	P,C
	PUSH	P,A
	MOVE	C,[000300,,CHRTAB(A)]	; GET DIGIT FROM TABLE
	IDIVI	A,14
	IMULI	B,-3
	ADDI	B,33.
	DPB	B,[360600,,C]
	LDB	B,C
	CAIG	B,4			; > 4==>CODE TO FIND SIZE
	 JRST	GETLEV
	JRST	@SPCHR-5(B)
GETLEV:	POP	P,A
GETLV1:	POP	P,C
	POPJ	P,

; TABLE OF CHARACTER SIZES
CHRTAB:	222222205602
	202222222222
	224122240000

; DISPATCH TABLE FOR SPECIAL SIZES
SPCHR:	CTHSIZ
	CTISIZ

; BACKSPACE IS -1
CTHSIZ:	SETO	B,
	JRST	GETLEV

; TAB GOES TO NEXT MULTIPLE OF 8
CTISIZ:	MOVE	C,CHPOS
	ANDI	C,7
	MOVNS	C
	MOVEI	B,10(C)
	JRST	GETLEV



; FINISH
PTMAIL:	ECHO				; ECHO THE ALTMODE
	SETOM	INTALL
	SKIPN	ALLOW
	 JRST	PRINTR
	OASC	[ASCIZ	/
Should TRIVIA be brought down? (y,n,?,a):  /]
	.IOT	TTYI,A			; READ COMMAND
	ECHO
	CAIN	A,"?			; PRINT HELP MESSAGE
	 JRST	PRTCOM
	CAIN	A,^F			; PRINT MADMAN;TVLOSE >
	 JRST	PRTFIL
	CAIN	A,^L
	 JRST	[SKIPE	LETRUB
		 OCTLP	"C
		 JRST	PTMAIL]
	CAIE	A,"N			; NOT BROUGHT DOWN
	 CAIN	A,"n
	  JRST	PRINTR
	CAIE	A,"F
	 CAIN	A,"f
	  JRST	PRINTR
	CAIE	A,"Y			; BROUGHT DOWN
	 CAIN	A,"y
	  JRST	KILL
	CAIE	A,"T
	 CAIN	A,"t
	  JRST	KILL
	CAIE	A,"A			; APPEND TO MESSAGE
	 CAIN	A,"a
	  JRST	APPEND
	JRST	PTMAIL

PRTCOM:	OASCR	[ASCIZ	/
?  prints this
A  allows you to modify your bug description
Y  brings TRIVIA down.  If you are not sure whether this should be done,
   read MADMAN;TVLOSE >.  Type ctrl-F to have the file printed.
N  sends bug mail, but does not bring TRIVIA down./]
	JRST	PTMAIL

; PRINT MADMAN;TVLOSE >
PRTFIL:	OASCR	[0]
	.CALL	[SETZ
		 SIXBIT	/OPEN/
		 [.BII,,DSKI]
		 [SIXBIT /DSK/]
		 [SIXBIT /TVLOSE/]
		 [SIXBIT />/]
		 SETZ	[SIXBIT /MADMAN/]]
	 .LOSE	1000
	.CALL	[SETZ
		 SIXBIT	/FILLEN/
		 MOVEI	DSKI
		 SETZM	C]
	 .LOSE	1000
	IDIVI	C,DBUFLN		; # OF ITERATIONS NEEDED
	JUMPE	D,PFLOOP
	ADDI	C,1
PFLOOP:	MOVE	A,[-DBUFLN,,DBUF]
	.IOT	DSKI,A			; IOT IN FIRST PART
	SOJE	C,CTCHAK
	MOVEI	O,5*DBUFLN
DOSIOT:	MOVE	B,DBUFPT
	.CALL	[SETZ			; PRINT IT TO TTY
		 SIXBIT	/SIOT/
		 MOVEI	TTYO
		 B
		 SETZ	O]
	 .LOSE	1000
	JUMPN	C,PFLOOP
	JRST	PTMAIL
CTCHAK:	HLRE	B,A
	MOVEI	O,DBUFLN
	ADD	O,B
	IMULI	O,5
	MOVEI	D,5
	SUBI	A,1
	HRLI	A,010700
CTCLOP:	LDB	B,A
	CAIE	B,^C
	 CAIN	B,0
	  CAIA
	JRST	DOSIOT
	DBP	A
	SUBI	O,1
	SOJG	D,CTCLOP
	JRST	DOSIOT
		 
APPEND:	OASC	[ASCIZ	/Append to message:/]
	LDB	O,BUFPTR		; IF ALREADY CRLF, DON'T ADD ONE
	CAIN	O,^J
	 JRST	[OASCR	[0]
		 JRST	GETCHR]
	MOVEI	A,^M
	SETZM	INTALL			; DON'T ALLOW INTERRUPTS
	JRST	CRLFHK

; PRINT FILE AND DON'T KILL TRIVIA
PRINTR:	PUSHJ	P,PRINT
	.CLOSE	DSKO,
DIE:	.BREAK	16,160000

; PRINT FILE--TO PRINT1 IF CHANNEL ALREADY OPEN
PRINT:	.CALL	[SETZ
		 SIXBIT	/OPEN/
		 [1,,DSKO]
		 [SIXBIT /DSK/]
		 [SIXBIT /TVLOSS/]
		 [SIXBIT />/]
		 SETZ [SIXBIT /TAA/]]
	 .LOSE	1000
PRINT1:	MOVE	O,DSKIOT		; SET UP FOR UUO'
	MOVEM	O,XCTIOT
	MOVE	O,DSKUPA
	MOVEM	O,XCTUPA
	SETOM	CTRLJ
	OSIX	XUNAME			; THE CULPRIT
	OASCI	^I
	PUSHJ	P,PDSKDA		; TIME OF LOSSAGE
	OASC	[ASCIZ	/
/]
	MOVE	A,INPPTR
	MOVE	B,CCT
	.CALL	[SETZ			; PRINT MESSAGE
		 SIXBIT /SIOT/
		 MOVEI	DSKO
		 A
		 SETZ	B]
	 .LOSE	1000
	MOVE	O,TTYIOT
	MOVEM	O,XCTIOT
	SETZM	CTRLJ
	SKIPN	MAINT
	 OASCR	[ASCIZ	/
Thank you for your help./]		; LEAVES CHANNEL OPEN
	POPJ	P,

; KILL TRIVIA BEFORE PRINTING MESSAGE
KILL:	PUSHJ	P,MSGBLS		; MUST BE AT LEAST 10. VISIBLE CHARACTERS
	 .BREAK	16,160000
	.CALL	[SETZ
		 SIXBIT	/OPEN/
		 [1,,DSKO]
		 [SIXBIT /DSK/]
		 [SIXBIT /TRIVIA/]
		 [SIXBIT /DEATH/]
		 SETZ	[SIXBIT /_MSGS_/]]
	 .LOSE	1000
	MOVE	O,XUNAME
	SKIPE	MAINT
	 JRST	[PUSHJ	P,PRINT1
		 JRST	KILFIN]
	.CLOSE	DSKO,
	PUSHJ	P,PRINT
	SETOM	CTRLJ
	MOVE	O,DSKIOT
	MOVEM	O,XCTIOT
	OASC	[ASCIZ	/
TRIVIA brought down./]
KILFIN:	.CLOSE	DSKO,
	.BREAK	16,160000

; SKIP RETURNS IF > 10 VISIBLE CHARACTERS
MSGBLS:	PUSH	P,A
	PUSH	P,B
	PUSH	P,C
	MOVEI	C,10.
	MOVE	A,INPPTR
	MOVE	B,CCT
BLSLOP:	ILDB	O,A
	CAILE	O,33		; VISIBLE?
	 CAIN	O,40
	  JRST	BLSEND
	SOJE	B,BLSOUT	; IF JUMPS, RAN OUT OF CHARACTERS BEFORE 10 VISIBLE
	SOJG	C,BLSLOP
	AOS	-3(P)		; FOUND 10, SO SKIP RETURN
	JRST	BLSOUT
BLSEND:	SOJG	B,BLSLOP
BLSOUT:	POP	P,C
	POP	P,B
	POP	P,A
	POPJ	P,
	

;START-UP
TTYOPN:	.CALL	[SETZ
		 SIXBIT "OPEN"
		 [TTYI]
		 [SIXBIT "TTY"]
		 [SIXBIT "DIRED"]
		 [SIXBIT "INTTY"]
		 SETZB LSTERR]
	 .LOSE	1000
	.CALL	[SETZ
		 SIXBIT "OPEN"
		 [4001,,TTYO]	; display mode == %TIDIS
		 [SIXBIT "TTY"]
		 [SIXBIT "DIRED"]
		 [SIXBIT "OUTTTY"]
		 SETZB LSTERR]
	 .LOSE	1000
	.CALL	[SETZ
		 'CNSGET
		 [TTYO]
		 MOVEM ; vsize
		 MOVEM ; hsize
		 MOVEM ; tctyp
		 MOVEM ; ttycom
		 MOVEM TTYOPT
		 SETZB LSTERR]
	 .LOSE	1000
	.SUSET	[.SIMSK2,,[1_TTYI]]
	.CALL	TTYSET	    	; SET UP TTY TO TAKE CONTROL CHARACTERS
	 .LOSE	1000
	MOVE	A,TTYOPT	; SET UP RUBOUT HANDLERS
	MOVE	[PUSHJ P,RUBECH]
	TLNE	A,%TOERS
	 JRST	[SETOM	LETRUB
		 MOVE	[PUSHJ P,RUBFLS]
		 JRST	.+1]
	MOVEM	XCTRUB
	POPJ 	P,
	
; SET UP TTY SO EVERYTHING ACTIVATES, ^G AND ^S INTERRUPT
TTYSET:	SETZ
	SIXBIT /TTYSET/
	1000,,TTYI
	[020202,,020202]
	SETZ [030202,,020202]

; JCL HACKER.  ONLY USED IF MAINT SET.

JCLRED:	.SUSET	[.ROPTIO,,A]
	TLNN	A,OPTCMD
	 POPJ	P,			; NO JCL
	.BREAK	12,[5,,JCL]
	MOVE	B,[440700,,JCL]
	ILDB	A,B			; GET FIRST CHARACTER
	CAIN	A,"'			; ' MEANS THIS IS THE MESSAGE
	 JRST	JCLMSG
	SUBI	A,"0
	MOVE	B,CANNED(A)
	HRLI	B,440700		; POINTER TO CANNED MESSAGE INSTEAD
JCLMSG:	MOVEM	B,INPPTR		; FOR THE BENEFIT OF THE FILE PRINTER
	SETZM	CCT
JCLOOP:	ILDB	A,B
	JUMPE	A,POPJ1
	CAIN	A,^M
	 JRST	POPJ1
	AOJA	CCT,JCLOOP

; CANNED MESSAGES
CANNED:	[ASCIZ	/TRIVIA down for data-base maintenance.  Back very shortly./]
	[ASCIZ	/TRIVIA down due to data-base lossage.  Have patience./]

SUBTTL	UUOS

; TYPEOUT UUOS (STRAIGHT FROM DIRED, WITH SOME HELP FROM PDL)

UUOCT==0
UUOTAB:	JRST	ILUUO
	IRPS	X,,[ODEC OBPTR OHPOS OCTLP OALIGN OSIX OASC OASCI OASCR OSIXS]
	UUOCT==UUOCT+1
	X=UUOCT_33
	JRST	U!X
	TERMIN

UUOMAX==.-UUOTAB

UUOH:	0
	PUSH	P,A
	PUSH	P,B
	PUSH	P,C
	PUSH	P,D
	MOVEI	@40			; GET EFF ADDR. OF UUO
	MOVEM	UUOE
	MOVE	@0
	MOVEM	UUOD			; CONTENTS OF EFF ADR
	MOVE	B,UUOE			; EFF ADR
	LDB	A,[270400,,40]		; GET UUO AC,
	LDB	C,[330600,,40]		; OP CODE
	CAIL	C,UUOMAX
	MOVEI	C,0	; GRT=>ILLEGAL
	JRST	@UUOTAB(C)	; GO TO PROPER ROUT

UUORET: POP	P,D
	POP	P,C
	POP	P,B
	POP	P,A		; RESTORE AC'S
	JRST	2,@UUOH

ILUUO:	FATINS	ILLEGAL UUO
UOBPTR:	MOVEI	C,0
	MOVE	B,UUOD
	JRST	UOASC1
UOASCR:	SKIPA	C,[^M]	; CR FOR END OF TYPE
UOASC:	MOVEI	C,0	; NO CR
	HRLI	B,440700	; MAKE ASCII POINTER
UOASC1:	ILDB	A,B	; GET CHAR
	JUMPE	A,.+3	; FINISH?
	PUSHJ	P,IOTA
	JRST	.-3	; AND GET ANOTHER
	SKIPE	A,C	; GET SAVED CR?
	PUSHJ	P,IOTA
	JRST	UUORET

UOASCC:	HRLI	B,440700	; MAKE ASCII POINTER
UOAS1C:	ILDB	A,B		; GET CHAR
	CAIN	A,^C
	JRST	UUORET
	PUSHJ	P,IOTA
	JRST	UOAS1C		; AND GET ANOTHER

UOCTLP:	MOVEI	A,^P
	PUSHJ	P,IOTA1

UOASCI:	MOVE	A,B		; PRT ASCII IMMEDIATE
	PUSHJ	P,IOTA
	JRST	UUORET

UOSIX:	MOVE	B,UUOD
USXOOP:	JUMPE	B,UUORET
	LDB	A,[360600,,B]
	ADDI	A,40
	PUSHJ	P,IOTA
	LSH	B,6
	JRST	USXOOP

UOSIXS:	MOVE	A,[440600,,UUOD]
USLOOP:	ILDB	C,A
	ADDI	C,40
	PUSHJ	P,IOTC
	TLNE	A,770000
	JRST	USLOOP
	JRST	UUORET

UOHPOS:	SUB	B,HPOS
	JUMPLE	B,UOASCI
UOHPO1:	MOVEI	A,40
	PUSHJ	P,IOTA
	SOJG	B,UOHPO1
	JRST	UUORET

POWER:	0 ? 1 ? 10. ? 100. ? 1000. ? 10000. ? 100000. ? 1000000.

UOALIG:	MOVE	D,UUOD
	ANDI	A,7
	MOVE	A,POWER(A)
	MOVEI	C,40
UOALI1:	CAMLE	A,D
	PUSHJ	P,IOTC
	IDIVI	A,10.
	CAIE	A,1
	 JRST	UOALI1
	SETZ	A,

UODEC:	SKIPA	C,[10.]	; GET BASE FOR DECIMAL
UOOCT:	MOVEI	C,8.	; OCTAL BASE
	MOVE	B,UUOD	; GET ACTUAL WORD TO PRT
	JRST	.+3	; JOIN CODE
UODECI:	SKIPA	C,[10.]	; DECIMAL
UOOCTI:	MOVEI	C,8.
	MOVEM	C,BASE
	SKIPN	A
	HRREI	A,-1	; A=DIGIT COUNT
	PUSHJ	P,UONUM	; PRINT NUMBR
	JRST	UUORET

UONUM:	IDIV	B,BASE
	HRLM	C,(P)		; SAVE DIGIT
	SOJE	A,UONUM1	; DONE IF 0
	SKIPG	A		; + => MORE
	SKIPE	B		; - => B=0 => DONE
	PUSHJ	P,UONUM		; ELSE MORE
UONUM1:	HLRZ	C,(P)		; RETREIVE DIGITS
	ADDI	C,"0		; MAKE TO ASCII
	CAILE	C,"9		; IS IT GOOD DIG
	ADDI	C,"A-"9-1	; MAKE HEX DIGIT
	PUSHJ	P,IOTC
	POPJ	P,		; RET

IOTC:	PUSH	P,A
	MOVE	A,C
	PUSHJ	P,IOTA
	JRST	POPAJ

IOTA:	CAIN	A,^P
	JRST	IOTAP
IOTA1:	SKIPN	CTRLJ
	 JRST	[CAIN A,^J
	 	  POPJ P,
		 JRST .+1]
	XCT	XCTIOT
	CAIN	A,^I
	 JRST	[MOVE A,HPOS
		 ADDI A,10
		 ANDI A,7770
		 MOVEM A,HPOS
		 POPJ P,]
	AOS	HPOS
	CAIE	A,^M
	 POPJ	P,
	SETZM	HPOS
	POPJ	P,
IOTAP:	XCT	XCTUPA
	ADDI	A,100
	JRST	IOTA1

POPAJ:	POP	P,A
	POPJ	P,

; PRINT DISK FORMAT DATE.
PDSKDA:	PUSH	P,A
	PUSH	P,B
	.CALL	[SETZ
		 SIXBIT	/RQDATE/
		 SETZM	A]
	 .LOSE	1000
	LDB	B,[220500,,A]		; GET DAY OF MONTH
	ODEC	B
	OASCI	40
	LDB	B,[270400,,A]		; GET MONTH
	OASC	@MONTHS-1(B)
	OASC	[ASCIZ / 19/]
	LDB	B,[330700,,A]		; YEAR
	ODEC	B
	OASC	[ASCIZ /  /]
	TLZ	A,-1
	ASH	A,-1
	IDIVI	A,3600.			; # HOURS AFTER MIDNIGHT IN A
	CAIN	A,0
	 ODEC	"0
	ODEC	A
	OASCI	":
	MOVE	A,B
	IDIVI	A,60.
	CAIGE	A,10.
	 OASCI	"0
	ODEC	A
	OASCI	":
	CAIGE	B,10.
	 OASCI	"0
	ODEC	B
	POP	P,B
	POP	P,A
	POPJ	P,

MONTHS:	[ASCIZ	/January/]
	[ASCIZ	/February/]
	[ASCIZ	/March/]
	[ASCIZ	/April/]
	[ASCIZ	/May/]
	[ASCIZ	/June/]
	[ASCIZ	/July/]
	[ASCIZ	/August/]
	[ASCIZ	/September/]
	[ASCIZ	/October/]
	[ASCIZ	/November/]
	[ASCIZ	/December/]


; INTERRUPT HANDLER

TSINT:	0
TSINTR:	0
	EXCH	A,TSINT
	TLNN	A,400000
	 .VALUE
	TRNN	A,1_TTYI
	 JRST	TSOUT
	MOVEI	A,TTYI
	.ITYIC	A,
	 JRST	TSOUT
	CAIN	A,^G
	 .BREAK	16,60000
	SKIPN	INTALL
	 JRST	TSOUT
	CAIE	A,^S
	 JRST	TSOUT
	.RESET	TTYI,
	MOVE	P,PDLPTR
	OASCR	[0]
	.DISMIS	[PTMAIL]
TSOUT:	EXCH	A,TSINT
	.DISMIS	TSINTR	

CONSTA
VARIAB
END START
back to top