	.TITLE	PULSE
/
/  27 FEB 76 (PDH) CHANGE SELECTIVE REPLAY PHILOSOPHY
/  25 FEB 76 (PDH) REPLAY CORRECT NUMBER OF FRAMES
/  19 FEB 76 (PDH) CONTINUE IMPLEMENTATION OF RE-START CODING
/   6 FEB 76 (PDH) ALLOW RE-START OF PREVIOUSLY STORED DISPLAY FILES
/  16 AUG 74 (PDH) CALL 'FSYNC' FROM WATRAN, ALSO
/  14 AUG 74 (PDH) ALLOW REPLAY FILE SIZE OF 254 MAXIMUM
/  10 JUL 74 (PDH) HAVE 'PULSE' CALL 'FSYNC' FOR 8 USEC CLOCK
/  12 MAR 74 (PDH) ADD MORE VERBOSITY TO WARNING MESSAGE
/  25 FEB 74 (PDH) ISSUE WARNING IF DISK NOT DK4
/  20 FEB 74 (PDH) CONDITIONALIZE FOR WATRAN USE
/
/  A ROUTINE TO AID ANIMATION
/  BY  SAVAGE & COOK FEB.70
/
IDVE=700501
IDHE=701001
IDRA=700512
IDLA=700606
IDCF=700704
STP=002000
DJP=400000
SUB=160000
/
IDX=ISZ				/ INDEX POINTER, SKIP NOT EXPECTED
/
AUTO14=14			/AUTO-INDEX
AUTO15=15
TTO=-3
DK=2
/
	.IODEV	TTO,DK
/
	.GLOBL	PULSE,DSPLAY,BEGIN,FSYNC,FWAIT,CLEAR,FILER
	.IFUND	F4
	.GLOBL	.ARG,DRAWS,.INTRP,.NEXT
MM=100000			/ INTERPRETER DATA MODE MULTIPLIER
OP=10000			/ INTERPRETER OP CODE MULTIPLIER
AUTO10=10
	.ENDC
	.IFDEF	F4
	.GLOBL	.DA,DRAW
.ARG=.DA
DRAWS=DRAW
	.ENDC
/
/  AC 16: UP - STORE; DOWN - CHECK AC 17
/  AC 17: UP - REPLAY; DOWN - RETURN
/
	.EJECT
PULSE	XX
	JMS*	.ARG
	JMP	.SETUP	
ACT	0			/UNKNOWN PARAMETER
FRMCNT	0			/FRAME COUNTER
/
.SETUP	CAL
ACSAVE	16
OUT	IDVE
FULL	VIOL
LASTFL	CAL
ONSWIT	16
SIZE	IDHE
ADDR	VIOL
END	DBK
TEMPAD	JMS	CK4DK4		/USER INTERVENTION REQUIRED IF NOT DK4
CNT	DZM*	FRMCNT		/INITIALIZE FRAME COUNTER TO 0
COUNT	LAC	.+2
CNTR	DAC	.SETUP		/BYPASS SETUP AFTER 1ST TIME
SWIT	JMP	PAST
BLKSIZ
/*
	.IFUND	F4
PAST	DZM	CALLED		/ INDICATE INTERPRETER NOT CALLED
	.ENDC
	.IFDEF	F4
PAST=.
	.ENDC
PAST1	LAC*	ACT		/ GET FUNCTION CODE
	SAD	(1
	JMP	SEARCH
	SAD	(2
	JMP	NXFRAME
/
	LAS
	RTR
	SZL
	JMP	DISK		/ AC 16 UP
	SPA
	JMP	REPLAY		/ ONLY AC 17 UP
	JMP*	PULSE		/ NEITHER 16 OR 17 UP.  RETURN
/
	.EJECT
SEARCH	.INIT	DK,0,SEARCH	/ INITIALIZE FOR INPUT
	LAC	(NOP
	DAC	DISK		/ ENABLE OUTPUT INITIALIZATION
	LAW	-1077
	DAC	CNT		/ TERMINATE SEARCH AT END OF LOGICAL UNIT
	DZM*	FRMCNT		/ INITIALIZE FRAME COUNT
	DZM	TRSRCH+2
	IDX	TRSRCH+2	/ BEGIN SEARCH AT BLOCK 1
TRSRCH	.TRAN	DK,0,1,FILE1,64	/ 1/4 BLOCK SPEEDS UP PROCESS
	LAC	TRSRCH+2
	DAC	WRITE+2		/ UPDATE BLOCK POINTER IN 'SAVE' SECTION
	IDX	TRSRCH+2	/ NEXT BLOCK
	IDX*	FRMCNT		/ UPDATE FRAME COUNT
	.WAIT	DK
	LAC	FILE1
	SAD	LSTFRAME	/ CHECK FOR LAST BLOCK STORED
	JMP*	PULSE		/ LEAVE WHEN FOUND
/
	ISZ	CNT
	JMP	TRSRCH
	DZM	WRITE+2		/ NO STORED FRAMES.  RESET TO BLOCK 0,
	DZM*	FRMCNT		/ AND ZERO FRAME COUNTER
	JMP*	PULSE
/
	.EJECT
NXFRAME	LAW	-1
	TAD	WRITE+2
	CMA
	TAD*	FRMCNT		/ FRMCNT - (HIGHEST BLOCK)
	SPA!CLC
	JMP	NOTBIG
	TAD	WRITE+2		/ SUPPLIED BLOCK NUMBER IS TOO BIG
	SKP
NOTBIG	TAD*	FRMCNT		/ (BLOCK NUMBER) = FRMCNT - 1
	SPA			/ ENSURE POSITIVE BLOCK NUMBER
	CLA			/ DELIVER BLOCK 0 IF -VE FRAME COUNT
	DAC	TRNEXT+2
	.INIT	DK,0,NXFRAME
	LAC	(NOP
	DAC	DISK		/ ENABLE OUTPUT INITIALIZATION
TRNEXT	.TRAN	DK,0,0,FILE2,256  / INPUT REQUESTED FRAME
	.IFUND	F4
	LAC	(3		/ PREPARE TO DELETE PREVIOUSLY FETCHED FILE
	DAC	FCN
	JMS	CALINT		/ FIRE UP INTERPRETER
	62*OP	1
	43*OP	DSPLAY-T	/ CALL DSPLAY (3,32767,ERR, . . .)
	DARGS-T
	74*OP			/ RETURN TO MACHINE CODE
	LAC	(1
	DAC	FCN		/ PREPARE TO ADD NEW FILE
	.ENDC
	.IFDEF	F4
	JMS*	DSPLAY
	JMP	SRCH2
	(3
	(77777
	REPEAT			/ USED AS ERROR RETURN
	.ENDC
SRCH2	LAC*	FILER
	TAD	(1
	DAC	ADDR		/ ADDRESS OF ANTI-SWIM BIT IN BASIC FILE
	LAC*	ADDR
	DAC	LASTFL		/ SAVE ANTI-SWIM STATUS
	JMS*	CLEAR		/ 'CLEAR' TURNS OFF ALL FILES
	LAC	LASTFL
	DAC*	ADDR		/ RESTORE ANTI-SWIM
	.WAIT	DK		/ NOW WAIT FOR FRAME TO COME IN, THEN
	.IFUND	F4
	JMS	CALINT
	62*OP	2
	43*OP	DSPLAY-T	/ CALL DSPLAY (1,32767,ERR,FILE2,1,258)
	DARGS-T
	76*OP	1		/ RETURN TO CALLING PROGRAM
	.ENDC
	.IFDEF	F4
	JMS*	DSPLAY
	JMP	XIT1
	(1
	(77777			/ 32767
	REPEAT
	IVEC2
	(1
	(402
XIT1	JMP*	PULSE
	.ENDC
/
	.EJECT
/  HIGH SPEED CLOCK (VIA 'FSYNC & FWAIT) TIMES REPLAY.
/
DISK	NOP			/CHANGED TO ' JMP DRAW1' AS REQUIRED.
	.INIT	DK,1,PAST	/INITIALIZE DISK FOR OUTPUT
	LAC	(FILE1-1	/POINT TO FIRST BUFFER
	DAC	ADDR
	LAC	.+2		/BRANCH AROUND .INIT
	DAC	DISK
	JMP	DRAW1
	.EJECT
/  SEARCH DSPLAY FOR FILES THAT ARE TURNED ON.
/  SEE USER'S MANUAL REGARDING 'DISPLAY FILE MANAGEMENT PHILOSOPHY'
/
DRAW1	LAC	ADDR
	DAC*	(AUTO15
	LAW	-376		/ MAXIMUM SIZE OF FILE WE CAN
	DAC	BLKSIZ		/ STORE IN 1 BLOCK
	LAC*	BEGIN
	DAC	TEMPAD		/ADDRESS OF 1ST DISPLAY FILE
BLOCK	LAC*	TEMPAD	/1ST WORD
	DAC	FULL		/ONLY BIT 0 SIGNIFICANT
	RAL			/SHIFT AC 1 TO AC 0
	DAC	LASTFL		/ONLY BIT 0 SIGNIFICANT HERE ALSO
	RAR			/SHIFT BACK TO THE WAY IT WAS
	AND	(77777		/REMOVE POSSIBLE EXTRA BITS
	DAC	SIZE		/SAVE SIZE OF DISPLAY FILE.
	IDX	TEMPAD		/POINT TO 2ND WORD OF 'DISPLY' FILE
/
/  PROCEED TO GET FILES
/
	LAC	FULL		/HAVE WE AN OCCUPIED BLOCK?
	SMA
	JMP	ENDCHK		/NO.  PERFORM CHECK FOR END OF AREA
	LAC*	TEMPAD		/IS THIS BLOCK TURNED ON?
	SMA
	JMP	ENDCHK		/NO.
/
/  FILE IS PRESENT AND TURNED ON.  MOVE IT TO DISK BUFFER.
/
	LAC	SIZE
	SAD	(5
	JMP	ENDCHK	/  ZERO LENGTH FILE CHECK
	LAC	TEMPAD
	TAD	(1
	DAC*	(AUTO14		/LOAD ADDRESS OF 1ST DISPLAY WORD
	TAD	SIZE
	TAD	(-5
	DAC	END	/LAST ADRS TO BE TRANS.
/
/  LOAD TO FILE1
/
DUMP	LAC*	AUTO14		/MOVE DISPLAY FILE TO DISK BUFFER
	DAC*	AUTO15
	ISZ	BLKSIZ		/ HAVE WE RUN OUT OF ROOM ON THIS BLOCK?
	SKP
	JMP	OVRFLOW		/ YES.  WRAP UP THE BLOCK.
	LAC*	(AUTO14		/ NO.  HAVE WE MOVED ENTIRE FILE YET?
	SAD	END
	JMP	ENDCHK		/YES.
	JMP	DUMP
	.EJECT
/
/  CHECK FOR END; SET TEMPAD;  CONTINUE
/
ENDCHK	LAC	LASTFL		/IS THIS THE LAST 'DISPLY' FILE?
	SPA!CLC			/SET AC=-1 FOR LATER
	JMP	FILL		/LAST FILE.  TIDY UP & WRITE TO DISK.
	TAD	TEMPAD
	TAD	SIZE		/ TEMPAD = TEMPAD + SIZE -1
	DAC	TEMPAD		/POINTS TO NEXT FILE
	JMP	BLOCK	/ BACK FOR MORE DATA.
/
FILL	DZM*	AUTO15		/ ZERO REST OF BUFFER
	ISZ	BLKSIZ
	JMP	FILL
/
OVRFLOW	LAC	(400000		/ ESCAPE FROM VECTOR MODE
	DAC*	AUTO15		/ (MOST PROBABLE CASE)
	LAC	(STP		/PUT STOP CODE AT END OF DISPLAY FILE
	DAC*	AUTO15
/
/
/  PLACE ONTO DISK
/
WRITE	.TRAN	DK,1,0,FILE1,257	/WRITE OUT BUFFER
	.WAIT	DK
	IDX*	FRMCNT		/COUNT NUMBER OF FRAMES RECORDED.
	LAC	WRITE+2
	SAD	(1076		/END OF DISK?
	SKP
	JMP	INC		/NO.
	LAW	-1		/YES.  RESTART AT BLOCK 0.
INC	TAD	(1
	DAC	WRITE+2
/
/  NOW CHECK AC 17
/
	LAS
	RAR
	SNL			/DO WE DO A REPLAY?
	JMP*	PULSE		/NO. EXIT.
	.EJECT
/  REPLAY SECTION
/
REPLAY	LAW	-2		/ MUST HAVE RECORDED AT LEAST 2 FRAMES
	TAD*	FRMCNT		/ BEFORE REPLAY IS PERMISSIBLE.
	SPA			/ OTHERWISE, MASS CONFUSION RESULTS!!!
	JMP*	PULSE
	LAC*	FRMCNT		/ GET FRAME COUNT FROM USER.
	DAC	CNT		/INITIALLY ASSUME FRAME COUNT LESS THAN
	CMA			/1076.  WE WANT TO VIEW ONLY TO END OF
	TAD	(1		/RECORDED MATERIAL.
	TAD	(1076		/ 1076 - FRMCNT
	SMA			/IF 'FRMCNT' IS GREATER THAN 1076, USE
	JMP	SET		/1076 AS MAX BLOCK COUNT.
	LAC	(1076
	DAC	CNT
SET	JMS*	DRAWS		/CONNECT MINI FILE TO DRAW
	JMP	.+4
	IVECT
	(1
	(4
	LAC	(STP		/NOW STOP DISPLAY IN MINI FILE.
	DAC	PAR
CHECX	IDRA			/WAIT FOR DISPLAY TO STOP
	SAD	(PAR+1
	SKP
	JMP	CHECX
/
/  PREPARE TO START
/
	DZM	TR1+2		/BEGIN 'TR1' AT BLOCK 0
	DZM	TR2+2
	IDX	TR2+2		/BEGIN 'TR2' AT BLOCK 1
IC=REPEAT		/ INNOCUOUS PLACE FOR UNUSED RETURNED ARGUMENT
	.IFUND	F4
	JMS	CALINT		/ CALL WATRAN INTERPRETER WITH
	43*OP	FSYNC-T		/ CALL FSYNC (5208,IC)
	ARGS-T
	74*OP			/ RETURN TO ASSEMBLER
	.ENDC
	.IFDEF	F4
	JMS*	FSYNC		/ USE SYSTEM ROUTINE FOR TIME SYNCHRONIZATION
	JMP	.+3
	L5208			/ 41.664 MSEC = 1/24 SEC
	IC
	.ENDC
	.EJECT
READY	.INIT	DK,0,PAST	/INITIALIZE DISK FOR INPUT
TR1	.TRAN	DK,0,0,FILE1,256  /READ INTO BUFFER 1
	.WAIT	DK
	JMS*	FWAIT		/WAIT FOR CLOCK TO EXPIRE
	LAC	(FILE1
	IDLA			/START DISPLAY IN BUFFER 1
	DZM	SWIT
	IDX	TR1+2
	LAC	TR1+2
	IDX	TR1+2
	SAD	CNT		/HAVE ALL FRAMES BEEN SEEN?
	JMS	REPEAT
TR2	.TRAN	DK,0,1,FILE2,256
	.WAIT	DK
	JMS*	FWAIT	/LET OTHER FILE COME TO STOP
	LAC	(FILE2
	IDLA
	ISZ	SWIT
	IDX	TR2+2
	LAC	TR2+2
	IDX	TR2+2
	SAD	CNT
	JMS	REPEAT
	JMP	TR1	/NEXT FRAME
	.EJECT
REPEAT	XX
	LAS
	RAR
	SNL
	JMP	DONE		/AC SW 17 = 0.  ALL DONE.  EXIT REPLAY.
	DZM	TR1+2
	DZM	TR2+2
	LAC	SWIT
	SZA
	JMP	REVERS
	ISZ	TR1+2
	SKP
REVERS	ISZ	TR2+2
	JMP*	REPEAT
/
/
/  INTERRUPT PROCESSOR
/
VIOL	DAC	ACSAVE		/ EDGE INTERRUPT.  SAVE AC
	LAC*	(0
	DAC	OUT
	LAW	-1
	DAC	END
	IDCF			/ CLEAR EDGE FLAG
	LAC	ACSAVE		/ RESTORE AC
	ION
	DBR
	XCT	.+1
	JMP*	OUT
	.EJECT
DONE	LAC	(NOP
	DAC	DISK	/ALLOW DISK IN INIT
/
/  TURN ON DISPLAY,  TURN OFF ENTRANCE STOP.
/
	ISZ	PAR		/THE DELAY BY THE TIME 'PAR' COUNTS
	JMP	.-1		/DOWN WILL BE ABOUT RIGHT.
	LAC	(PAR		/RESTART DISPLAY IN MAIN SEQUENCE.
	IDLA
	JMS*	DRAWS		/NOW REMOVE SMALL DISPLAY FILE
	JMP	.+4
	IVECT
	(1
	(0
	.IFDEF	F4
	JMP*	PULSE	/EXIT
	.ENDC
	.IFUND	F4
	JMS	CALINT		/ RE-ENTER INTERPRETIVE CODE
	76*OP	1		/ RETURN
	.ENDC
/
/  SUBROUTINE TO FIRE UP THE INTERPRETER.  INSTRUCTION FOLLOWING
/  CALLING POINT IS IN INTERPRETER CODE.
/
CALINT	XX
	LAC	CALLED		/ HAVE WE ALREADY CALLED INTERPRETER?
	SZA!CLC
	JMP	CALLED		/ YES.  DON'T DO IT TWICE
	DAC	CALLED		/ SET 'INTERPRETER CALLED' FLAG
	JMS*	.INTRP
	T
	S-1
S	74*OP			/ RETURN IMMEDIATELY TO MACHINE CODE
CALLED	LAW	-1		/ CLEARED ON ENTRY TO 'PULSE'
	TAD	CALINT		/ LOAD AUTO10 WITH RETURN ADDRESS
	DAC*	(AUTO10
	JMP*	.NEXT		/ PROCEED AS IF NORMAL WATRAN
	.EJECT
/  STORAGE AND MINI DISPLAY FILE
/
IVECT	IN			/ADDRESS NEEDED FOR DRAW
IVEC2	FILE2-1
/
IN	0			/MINI DISPLAY FILE
PAR	0			/EITHER 0 OR 'STP'
CONTRL	SUB
OUTS	DJP	PAR
/
/  OTABLE FOR WATRAN VERSION
/
	.IFUND	F4
T	0; 0; 0
	.ASCII	'PULSE'
FCN
L1	1
L402	402
L32767	77777
DARGS	.
	3*MM+L.FCN
	3*MM+L.32K
	3*MM+L.ERR
	3*MM+L.IVEC
	3*MM+L.1
	3*MM+L.402
	6*MM
L.FCN	-1+FCN
L.32K	-1+L32767
L.ERR	-1+REPEAT
L.IVEC	-1+FILE2-1
L.1	-1+L1
L.402	-1+L402
/
ARGS	.
	3*MM+L.5208
	3*MM+L.IC		/ ARGUMENTS FOR 'CALL FSYNC'
	6*MM
/
L.5208	-1+L5208
L.IC	-1+IC
	.ENDC
	.DEC
L5208	5208			/ NUMBER FOR 41.664 MSEC = 1/24 SEC
	.OCT
/
/  THIS IS THE ROUTINE TO VALIDATE THE DISK BEING USED.  IF
/  THE DISK IS DK4, NO OPERATOR INTERVENTION IS REQUIRED, OTHERWISE
/  THE OPERATOR MUST 'GO' OR JOB WILL BE ABORTED.
/  THIS ROUTINE RESIDES IN THE DISPLAY BUFFERS, AND IS OVERLAYED.
/
CK4DK4	XX
INIT	.INIT	DK,1,PAST	/INITIALIZE DISK
UNIT=INIT+1
	LAC	UNIT		/UNIT RETURNED IN BITS 0-2 OF '.INIT+1'
	RTL; RTL		/SHIFT UNIT NUMBER TO AC 15-17
	AND	(7
	SAD	(4		/IS DISK DK4?
	JMP*	CK4DK4		/YES.  RETURN.
/
	.CLOSE	TTO		/CR,LF
	.WRITE	TTO,2,MSG1,0	/ISSUE WARNING MESSAGES
	.WRITE	TTO,2,MSG2,0
	.WRITE	TTO,2,MSG3,0
	.WRITE	TTO,2,MSG4,0
	.WRITE	TTO,2,MSG5,0
	.WRITE	TTO,2,MSG6,0
	.READ	TTO,2,FILE2,34	/READ RESPONSE
	.WAIT	TTO
	777760
	AND	FILE2+2		/GET 1ST 2 CHARACTERS
	SAD	CH.GO		/IS IT 'GO' TO PROCEDE?
	JMP*	CK4DK4		/YES.  RETURN
	.WRITE	TTO,2,INVALD,0	/TELL USER ABOUT JOB ABORT.
	.WAIT	TTO
	.EXIT			/INDICATE ERROR IN RESPONSE AND EXIT
/
MSG1	M1-.*400+2; 0
	.ASCII	'*** WARNING ***  REPLAY DISK NOT DK4!!!  THE PRESENT '
	.ASCII	'ASSIGNMENT WILL'<15>
M1=.
/
MSG2	M2-.*400+2; 0
	.ASCII	'PROBABLY USE DK6 AS THE REPLAY DISK, WHICH RESULTS '
	.ASCII	'IN THE VERY REAL'<15>
M2=.
/
MSG3	M3-.*400+2; 0
	.ASCII	'POSSIBILITY OF LOSING FILES THE NEXT TIME YOU EDIT.'<15>
M3=.
/
MSG4	M4-.*400+2; 0
	.ASCII	'     IT IS STRONGLY RECOMMENDED THAT YOU RETURN TO '
	.ASCII	'MONITOR AND:'<15>
M4=.
/
MSG5	M5-.*400+2; 0
	.ASCII	'   '<12>'$A DK4 2'<11><12>'THIS WILL ALSO ELIMINATE '
	.ASCII	'THIS WARNING.  HOWEVER, IF YOU'<15>
M5=.
/
MSG6	M6-.*400+2; 0
	.ASCII	'STILL WISH TO CONTINUE WITH THE '
	.ASCII	"PRESENT ASSIGNMENT, TYPE '"
CH.GO	.ASCII	"GO"<0>"'."<15>
M6=.
/
INVALD	IV-.*400+2; 0
	.ASCII	'INVALID RESPONSE'<11>'*** JOB ABORT***'<15>
IV=.
/
	.LOC	CK4DK4
/
	.BLOCK	1		/ WORD NEEDED BY 'DRAW'
FILE2	.BLOCK	400
FILE1	.BLOCK	400
LSTFRAM	402000			/ THIS IS A STATUS WORD WRITTEN TO DISK
	.END
