perm filename COPY.MAC[X,AIL] blob sn#000820 filedate 1973-08-19 generic text, type T, neo UTF8
	TITLE	COPY

; THIS PROGRAM COPIES A MASTER SAIL DISTRIBUTION TAPE
;  (556 BPI, 7-TRACK) TO A SLAVE TAPE IN THE SAME MODE.

; TO USE, DO THE FOLLOWING
; GET THE ASCII TEXT ON THE PAPER TAPE MARKED COPY.MAC 
;  ONTO THE DISK AS COPY.MAC OR SOMETHING.
; MOUNT THE MASTER TAPE ON MTA0:, RING OUT
; MOUNT THE SLAVE  TAPE ON MTA1:, RING IN

; EX COPY.MAC

; THE PROGRAM SHOULD RESPOND BY FURIOUSLY SPINNING ABOUT
; 1200 FEET OF EACH TAPE, PRINTING OUT TWO "ON COURSE"
; MESSAGES ALONG THE WAY.  IT WILL THEN REWIND BOTH TAPES
; AND EXIT.

; IF ANY ERROR MESSAGES OCCUR, DO YOUR BEST.


START:	JSP	3,MTINI	;INIT TAPES
	MTAPE	1,1	;REWIND BOTH
	MTAPE 	2,1
	JSP	1,COPY	;COPY ONE "LOGICAL TAPE"
	OUTSTR	[ASCIZ /MAIN FILES COPIED
/]
	JSP	3,MTINI	;INIT AGAIN
	MTAPE	1,16	;ADVANCE OUTPUT PAST 2D TAPE MARK (SEE BELOW)
	JSP	1,COPY	;COPY ONE "LOGICAL TAPE"
	OUTSTR	[ASCIZ /AUXILLIARY FILES COPIED
/]
	MTAPE	1,1	;REWIND ALL AGAIN
	MTAPE	2,1
	CALLI		;CLEAR CHANNELS
	CALLI	12	;AND QUIT


COPY:	MOVEI	11,0	;TOTAL FILE WORD COUNT
	JSP	2,COPY11;COPY ONE FILE
	JUMPE	11,(1)	;DONE WITH ONE LOGICAL TAPE (NO DATA IN FILE)
			; INPUT TAPE POSITIONED BEYOND BOTH EOT TAPE MARKS
			; OUTPUT TAPE POSITIONED BETWEEN THE TWO TAPE MARKS
	CLOSE	1,0	;DONE WITH THIS FILE, COPY THE NEXT
	JSP	3,MTINI
	JRST	COPY

COPY11:	SETZB	10,EOFWRD;10 IS BUF WORD COUNT, EOFWRD IS EOF FLAG
	MOVEI	7,0	;INDEX INTO BUF
COPY1:	SOSG	IBUF+2	;END OF BUFFER?
	IN	2,0	;PREPARE AN INPUT BUFFER
	JRST	OK
	STATZ	2,20000	;CHECK EOF
	JRST	EOF	;EOF
	OUTSTR	[ASCIZ /MAG-TAPE INPUT ERROR -- WILL GO ON ANYWAY
/]
OK:	ILDB	6,IBUF+1;GET WORD
	ADDI	10,1
	ADDI	11,1
	MOVEM	6,BUF(7);PUT WORD INTO BUFFER
	CAIN	10,↑D5000
	JRST	EOB
	AOJA	7,COPY1

EOF:	SETOM	EOFWRD	;REALLY REACHED EOF
EOB:	MOVEI	7,0	;RESET POINTER
EOBB:	SOJL	10,EOW	;DONE WITH BUFFER
	MOVE	6,BUF(7);GET WORD
	SOSG	OBUF+2	;THE INTERMEDIATE BUFFERING (VIA BUF) IS DONE
	OUT	1,0	;TO MAKE TAPE OPERATIONS AS EFFICIENT AS
	JRST	OKO	;POSSIBLE (PREVENT JERKINESS)
	OUTSTR	[ASCIZ /MAG-TAPE OUTPUT ERROR -- WILL GO ON ANYWAY
/]
OKO:	IDPB	6,OBUF+1;WRITE WORD
	AOJA	7,EOBB	;LOOP
EOW:	SKIPN	EOFWRD
	JRST	COPY11
	JRST	(2)	;DONE THIS FILE

MTINI:	CALLI	0	;RESET JOBFF, CHANNELS
	INIT	1,414	;OUTPUT FILE AT 556 BPI
	SIXBIT	/MTA1/
	XWD	OBUF,0
	JRST	ERROR1
	INIT	2,414	;SPECIAL MODE BITS TO GET 556 BPI
	SIXBIT	/MTA0/	;OR WHATEVER
	IBUF
	JRST	ERROR2
	OUTBUF	1,5
	INBUF	2,5
	JRST	(3)


ERROR1:	SKIPA	1,[[ASCIZ /CAN'T INIT MTA1 FOR OUTPUT/]]
ERROR2:	MOVEI	1,[ASCIZ /CAN'T INIT MTA0 FOR INPUT/]
	OUTSTR	(1)
	OUTSTR	[BYTE (7) 15,12]
	CALLI 	12

OBUF:	BLOCK	3
IBUF:	BLOCK	3
EOFWRD:0
BUF:	BLOCK	↑D5010
	END	START