
TITLE New, exquisitely tasteful, BABBLE  (MARC 10/10/76)

.MLLIT==1
A=1
B=2
C=3
D=4
E=5
F=6
I=11
J=12

THIS=7
LAST=10
PLAYER=13

P=17

PKPAGE==293.
RECLEN==6
NMSLOT==0
PRSLOT==1
SCSLOT==2
MXSLOT==3
RKSLOT==4
PCSLOT==5

TVI==1
TYOC==0
TYIC==2

LOC 42
	JSR	TSINT
LOC 100

TVNAME:	SIXBIT /FILE/
BABNAM:	.FNAM2
PEEKSW:	0
RNDFLG:	0
REPTSW:	0
HPOS:	0
SUM:	0
MAXPRG:	0
NAME:	0
VERBOS:	0
PASSES:	0
RANK:	0
RUMODE:	0
UMODE:	PCSLOT
MODE:	PCSLOT
XUNAME:	0
PDL:	BLOCK	40
JCL:	BLOCK	16
NUM:	0
SWITCH:	0
PRUNE:	0
SLEEPR:	150.

SORTLN==<1024./3>
SORTBL:	BLOCK SORTLN

SCOROF==671.
TELEOF==335.

TSINT:	0			;HERE TO CATCH INT. CHARS
	0
	MOVEI	B,TYIC
	.ITYIC	B,
	 .VALUE
	CAIN	B,19.
	 JRST	[MOVEI B,"T
		 .IOT TYOC,B
		 JRST TSINT1]
	CAIN	B,7.
	 JRST	[.RESET	TYOC,
		 .RESET	TYIC,
	 	 .VALUE	[ASCIZ /:
*ERROR*
CONTROL-G?
LISTENING-AT-LEVEL 2 PROCESS 1

:KILL
/]]
	CAIL	B,"0
	 CAILE	B,"9
	  JRST  TSINT2
	.DISMIS TSINT+1
	SUBI	B,"0
	SKIPN	B
	ADDI	B,1
	IMULI	B,30.
	MOVEM	B,SLEEPR
	.DISMIS	[TVPEEK]	

TSINT2:	CAIE	B,"P
	 CAIN	B,"p
	  JRST	[.RESET TYIC,
		 .VALUE [ASCIZ /J/]
		 .DISMIS [TVPEEK]]
	CAIE	B,"Q
	 CAIN	B,"q
	  JRST	TSINT1
	.DISMIS	TSINT+1 

TSINT1:	.RESET	TYOC,		;FLUSH OUTPUT
	.RESET	TYIC,		;AND INPUT
	.BREAK	16,40000

START:	.BREAK	12,[5,,JCL]
	MOVE	P,[-40,,PDL-1]
	PUSHJ	P,TTYOPN
	PUSHJ	P,JCLHAK
	MOVE	A,UMODE
	MOVEM	A,RUMODE
	.CALL	[SETZ
		 SIXBIT /OPEN/
		 1000,,TVI
		 5000,,6
		 [SIXBIT /DSK/]
		 [SIXBIT /TV/]
		 TVNAME
		 SETZ [SIXBIT /MADMAN/]]
	 .VALUE
	.SUSET	[.RXUNAM,,XUNAME]
	.CALL	[SETZ
		 SIXBIT /CORBLK/
		 1000,,10000
		 [-1]
		 1000,,2
		 1000,,TVI
		 SETZI PKPAGE]
	 .VALUE
	.CLOSE	TVI,
	.SUSET	[.RJNAME,,A]
	CAMN	A,[SIXBIT /TVPEEK/]
	 JRST	TVPEEK
	JRST	BABBIN		 

TVPEEK:	SETOM	PEEKSW
	SKIPE	REPTSW
	OCTLP	"C
	OASC	[ASCIZ /
TVPEEK/]
	PUSHJ	P,HEADER
	MOVEI	B,TVBEG+7
	MOVEI	C,84.
PEEKLP:	SKIPE	(B)
	 JRST	PEKEND
	SKIPN	RNDFLG
	OASCR	[ASCIZ /
Player	   Status           Entered/]
	SETOM	RNDFLG
	SKIPN	1(B)
	 JRST	[OASC [ASCIZ /HACKER      Password/]
		 JRST PEKDAT]
	SETZM	HPOS
	OSIX	1(B)
	MOVE	A,1(B)
	OHPOS	6.
	CAME	A,[SIXBIT /JMB/]
	 CAMN	A,[SIXBIT /MARC/]
	  OASC	[ASCIZ / */]
	CAMN	A,[SIXBIT /TAA/]
	 OASC	[ASCIZ / */]
	OHPOS	9.
	SKIPGE	TELEOF+3(B)
	OASCI	"T
	OHPOS	11.
	HLRZ	A,3(B)
	LSH	A,1
	OASC	STBL(A)	
	OHPOS	20.
	HLRZ	A,3(B)
	CAIE	A,1
	 CAIN	A,9.
	  JRST	[HRRZ D,3(B)
		 SKIPN D
	 	 JRST PEKDAT
		 OASCI "#
		 ODEC D
		 JRST PEKDAT]
	CAIE	A,4
	 JRST	PEKDAT		 
	HRRZ	C,3(B)
	SKIPN	C
	JRST	PEKDAT
	LSH	C,1
	OASC	TTBL-2(C)
PEKDAT:	OHPOS	27.
	MOVE	A,2(B)
	PUSHJ	P,PDATE
	OASCR	[0]
PEKEND:	ADDI	B,4
	SOJGE	C,PEEKLP
	SKIPN	RNDFLG
	OASC	[ASCIZ /No TRIVIAtors./]
	OASCR	[0]
	SKIPN	REPTSW
	.BREAK	16,40000
	OCTLP	"E
	MOVE	A,SLEEPR
	.SLEEP	A,
	JRST	TVPEEK
	
HEADER:	OASC	[ASCIZ / Version /]
	OSIX	BABNAM
	OASC	[ASCIZ /  It is now/]
	.CALL	RQDATE
	 .VALUE
	PUSHJ	P,PDATE
	OASCI	".
	OASCR	[0]
	POPJ	P,

RQDATE:	SETZ
	SIXBIT /RQDATE/
	MOVEM	A
	SETZM

;HERE TO MUNG THE PLAYER NAMES INTO THE RIGHT SLOTS

BABBIN:	OASC	[ASCIZ /BABBLE/]
	PUSHJ	P,HEADER
	MOVEI	A,SORTBL		;TOP OF NEW TABLE
	MOVE	B,TVBEG+3
	MOVEM	B,MAXPRG
	MOVEI	B,TVBEG+7		;TOP OF PEEK PAGE
	MOVEI	C,84.			;COUNTER OF PLAYERS
MOVLP:	SKIPN	D,1(B)
	 JRST	SORTEM
	MOVEM	D,NMSLOT(A)	
	MOVE	D,SCOROF+2(B)		;PROGRESS
	MOVEM	D,PRSLOT(A)
	MOVE	D,SCOROF+3(B)		;SCORE
	MOVE	E,SCOROF+4(B)		;MAXIMUM
	MOVEM	D,SCSLOT(A)
	MOVEM	E,MXSLOT(A)
	FDVR	D,E
	FMPRI	D,(1000.0)
	MULI	D,400
	TSC	D,D
	ASH	E,-243(D)
	SKIPN	SCOROF+4(B)
	MOVE	E,[-1]
	MOVEM	E,PCSLOT(A)
	SETZM	RKSLOT(A)		;EMPTY SLOT
	ADDI	B,4
	ADDI	A,RECLEN
	SOJGE	C,MOVLP


;HERE TO SORT THE LOSERS

SORTEM:	AOS	PASSES
	MOVEI	B,SORTBL+RECLEN		;START OF 2ND ENTRY
	MOVEI	A,SORTBL
	ADD	A,MODE
	MOVE	LAST,(A)		;FIRST ONE
	SETZM	SWITCH

LOOP:	MOVE	A,B
	ADD	A,MODE
	MOVE	THIS,(A)
	SKIPN	(B)
	 JRST	ELOOP
	SKIPN	MODE
	 JRST	[CAML THIS,LAST
		 JRST LOOP1
		 JRST LOOP1+1]
	CAMG	THIS,LAST
LOOP1:	 JRST	[MOVE LAST,THIS
		 ADDI B,RECLEN
		 JRST LOOP]
	AOS	SWITCH

	HRLI	B,-RECLEN		;SWITCH!
XLOOP:	MOVE	A,-RECLEN(B)
	EXCH	A,(B)
	MOVEM	A,-RECLEN(B)
	AOBJN	B,XLOOP
	JRST	LOOP

ELOOP:	SKIPE	SWITCH
	 JRST	SORTEM
	MOVE	B,UMODE
	JUMPL	B,BABBLE
	CAIN	B,PCSLOT		;SCORE MODE IS NORMAL
	 JRST	[SETOM MODE
		 JRST BABBLE]		;PRINT RIGHT AWAY
	SETZ	B,
	MOVEI	A,SORTBL

RLOOP:	AOJ	B,
	SKIPN	NMSLOT(A)
	 JRST	RLOOP1
	MOVEM	B,4(A)			;CRASH THE LOCK SLOT!	
	ADDI	A,RECLEN
	JRST	RLOOP

RLOOP1:	MOVE	A,UMODE
	MOVEM	A,MODE
	SETOM	UMODE
	JRST	SORTEM


;HERE TO PRINT THE BABBLE

BABBLE:	OASC	[ASCIZ /
TRIVIA Statistics sorted by /]
	MOVE	A,RUMODE
	LSH	A,1
	OASC	BYTBL(A)
	OASC    [ASCIZ/   High question = /]
	ODEC	MAXPRG
	MOVE	B,MAXPRG
	LSH	B,-4
	MOVEM	B,MINPRG		
	OASC	[ASCIZ /

Rank     Nut      Score    Maximum   Average  Progress
====	=====     =====    =======   =======  ========
/]
	MOVEI	PLAYER,SORTBL
	SETZM	RANK

PLOOP0:	MOVEI	0,5
	MOVEM	0,TENCNT

PLOOP:	AOS	RANK
	SKIPN	NMSLOT(PLAYER)
	 JRST	DONE
	MOVE	B,PRSLOT(PLAYER)
	MOVE	A,NMSLOT(PLAYER)
	CAMN	A,XUNAME
	 JRST	[CAMG B,MINPRG
		 OASCR [0]
		 JRST PLOOPA]
	MOVE	A,VERBOS			;IN VERBOSE MODE
	JUMPN	A,PLOOPA
	CAMG	B,MINPRG
	 JRST	[ADDI PLAYER,RECLEN
		 JRST PLOOP]
PLOOPA:	MOVE	A,MODE
	JUMPL	A,[MOVE B,RANK
		   JRST PLOOPB]
	MOVE	B,4(PLAYER)
PLOOPB:	ODEC	B
	OASC	[ASCIZ /. 	/]
	OSIX	NMSLOT(PLAYER)
	OHPOS	17.
	MOVE	D,SCSLOT(PLAYER)
	PUSHJ	P,PFLOAT
	OHPOS	27.
	MOVE	D,MXSLOT(PLAYER)
	PUSHJ	P,PFLOAT
	OHPOS	38.
	MOVE	D,PCSLOT(PLAYER)
	JUMPL	D,[SKIPE MXSLOT(PLAYER)
		   JRST PLOOPC
		   OASC [ASCIZ /----/]
		   JRST PLOOPD]
PLOOPC:	OASCI	".
	CAIGE	D,100.
	 OASCI	"0
	CAIGE	D,10.
	 OASCI	"0
	ODEC	D
PLOOPD:	OHPOS	48.
	MOVE	D,PRSLOT(PLAYER)
	CAIGE	D,100.
	 OASCI	40
	CAIGE	D,10.
	 OASCI	40
	ODEC	D
	OASCR	[0]
	ADDI	PLAYER,RECLEN
	SOSE	TENCNT
	 JRST	PLOOP	
	OASCR	[0]
	JRST	PLOOP0

PFLOAT:	MOVE	A,D
	MULI	A,400
	TSC	A,A
	ASH	B,-243(A)
	CAIGE	B,100.
	 OASCI	40
	CAIGE	B,10.
	 OASCI	40
	ODEC	B	
	IDIVI	B,400000
	FSC	C,233
	FSBR	D,C
	FMPRI	D,(1000.0)
	MULI	D,400
	TSC	D,D
	ASH	E,-243(D)
	OASCI	".
	CAIGE	E,100.
	 OASCI	"0
	CAIGE	E,10.
	 OASCI	"0
	ODEC	E
	POPJ	P,

MINPRG:	0
TENCNT:	0

DONE:	OASCR	[0]
	.BREAK	16,40000

TTYOPN:	.CALL   [SETZ
		 SIXBIT	/OPEN/
		 5000,,4001
		 1000,,TYOC
		 SETZ [SIXBIT /TTY   /]]
	 .VALUE
	.OPEN	TYIC,[.UAI,,'TTY]
	 .VALUE
	.SUSET	[.SIMSK2,,[4]]
	.CALL	TTYSET	    	;SET UP TTY TO TAKE CONTROL-S
	 .VALUE
	.CALL	CNSGET
	 .VALUE
	CAIN	A,3
	 OCTLP	"C
	POPJ	P,

CNSGET:	SETZ
	SIXBIT /CNSGET/
	MOVEI TYIC
	MOVEM 
	MOVEM	
	SETZM A

TTYSET:	SETZ
	SIXBIT	/TTYSET/
	MOVEI TYIC
	TTYS1
	SETZ TTYS2

TTYS1:	002121,,000000
TTYS2:	210000,,000000


JCLHAK:	MOVE	E,[440700,,JCL]
JCLHK1:	ILDB	0,E
	CAIE	0,15
	 CAIN	0,0
	  POPJ	P,
	CAIE	0,"D
	 CAIN	0,"d
	  JRST	[MOVE A,[SIXBIT /FOO/]
		 MOVEM A,TVNAME
		 JRST JCLHAK+1]
	CAIE	0,"S
	 CAIN	0,"s
	  JRST	[MOVEI A,SCSLOT
		 MOVEM A,UMODE
		 JRST JCLHAK+1]
	CAIE	0,"a
	 CAIN	0,"A
	  JRST	[MOVEI A,NMSLOT
		 MOVEM A,UMODE
		 JRST JCLHAK+1]
	CAIE	0,"p
	 CAIN	0,"P
	  JRST	[MOVEI A,PRSLOT
		 MOVEM A,UMODE
		 JRST JCLHAK+1]
	CAIE	0,"m
	 CAIN	0,"M
	  JRST	[MOVEI A,MXSLOT
		 MOVEM A,UMODE
		 JRST JCLHAK+1]
	CAIE	0,"v
	 CAIN	0,"V
	  JRST	[SETOM	VERBOS
		 JRST JCLHAK+1]
	CAIE	0,"R
	 CAIN	0,"r
	  JRST	[SETOM  REPTSW
		 JRST JCLHAK+1]
	MOVE	A,0
	OASC	[ASCIZ /
Ignored switch - /]
	OASCI	(A)
	OASCR	[0]
	JRST	JCLHAK+1		

BADNUM:	.VALUE [ASCIZ /:BAD JCL BARF BARF BARF
:KILL
/]

;PAGE DEFINITIONS

TVPAGE==<<.+1777>/2000>+1
TVBEG==TVPAGE*2000

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

ZZZ==.
        LOC 40
        0
        JSR UUOH
        LOC ZZZ
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:	.VALUE [ASCIZ /:ILLEGAL UUO/]
UOBPTR:	MOVEI C,0
	MOVE B,@40
	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:	CAIN A,^J
	 POPJ P,
	.IOT TYOC,A
	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:	.IOT TYOC,["^]
	ADDI A,100
	JRST IOTA1

POPAJ:	POP P,A
	POPJ P,

;HERE TO PRINT DATES (AS IN TRIVIA) DATE IS IN A

PDATE:	PUSH	P,B
	PUSH	P,C
	HRRZ	E,A
	OASC	[ASCIZ / /]
	LDB	B,[270400,,A]
	LSH	B,1
	OASC	MTBL-2(B)
	OASC	[ASCIZ / /]
	LDB	B,[220500,,A]
	ODEC	B
	OASC	[ASCIZ / at /]
	MOVE	C,E
	IDIVI	C,7200.
	CAIGE	C,12.
	 JRST	PDATE1
	SUBI	C,12.
	SKIPA	F,[ASCIZ / PM/]
PDATE1:	 MOVE	F,[ASCIZ / AM/]	
	SKIPN	C
	 MOVEI	C,12.
	ODEC	C
	OASCI 	":
	IDIVI	D,120.
	CAIGE	D,10.
	 OASCI	"0
	ODEC	D
	OASC	F		
	POP	P,C
	POP	P,B
	POPJ	P,	
	
MTBL:	ASCIZ 	/January/
	ASCIZ	/February/
	ASCIZ	/March /
	ASCIZ	/April /
	ASCIZ	/May   /
	ASCIZ	/June  /
	ASCIZ	/July  /
	ASCIZ	/August/
	ASCIZ	/September/
	ASCIZ	/October/
	ASCIZ	/November/
	ASCIZ	/December/

STBL:	ASCIZ	/Grade /
	ASCIZ	/Answer/
	ASCIZ	/Babble/
	ASCIZ	/Read mail/
	ASCIZ	/Make  /
	ASCIZ	/Peek  /
	ASCIZ	/Start up/
	ASCIZ	/P.score/
	ASCIZ	/Command/
	ASCIZ	/Update/
	ASCIZ	/Status/
	ASCIZ	/FLUSH /
	ASCIZ	/ERROR /
	ASCIZ	/SHOUT /
	
TTBL:	ASCIZ	/ZORK! /
	ASCIZ	/Long  /
	ASCIZ	/Match /
	ASCIZ	/M.C.  /
	ASCIZ	&T/F   &
	ASCIZ	/ZORK! /
	ASCIZ	/Simple/

BYTBL:	ASCIZ	/NAME  /
	ASCIZ	/PROGRESS/
	ASCIZ	/SCORE /
	ASCIZ	/MAXIMUM/
	ASCIZ	/LOSSAGE/
	ASCIZ	/AVERAGE/


	END START
