TITLE FRAME DUMP

.mllit=1

a=1
b=2
c=3	;column count-down
d=4	;row count-down
e=5	;line-number on XGP
f=6	;TV buffer byte pointer (8 bit)
g=7	;disk buffer byte pointer (16 bit)

t=10	;temporary
u=11	;duplicity factor 1, 2 or 3

p=17

tvpage==370	;top 10 pages of core for tv

tv=tvpage*2000	;address of first word in tv screen

dskc==1

start:	move p,[-20,,pdl]

	movei u,1	;DEFAULTS TO 1
	pushj p,readnm

	skipe unames
	.suset [.ssname,,unames]
	.open dskc,dskfil
	.value

	move a,[-10,,tvpage]
	setz b,
	.call cormap
	.value

	pushj p,tblini	;initialise magic table

	movei d,455.	;455. lines to do
	movei e,400.	;two inches clear of top on XGP
	move f,[441000,,tv]	;8 bits at a shove
	cain u,1
	move f,[442000,,tv]	;16 bits at a shove

	pushj p,linout	;write out the whole frame

	move g,[442000,,dskbuf]
	movei a,2	;2 (PDP-11 words) long
	idpb a,g
	addi e,400.	;two inches clear at bottom of XGP
	move a,e
	iori a,100000	;sign-bit on -> paper cut
	idpb a,g
	move a,[-1,,dskbuf]
	.iot dskc,a	;write this record

	move g,[442000,,dskbuf]
	movei a,2	;2 (PDP11 words) long
	idpb a,g
	setz a,		;line-number=0 -> EOF
	idpb a,g
	move a,[-1,,dskbuf]
	.iot dskc,a

	.close dskc,
	.break 16,124000
	.value

linout:	pushj p,dumlin	;set up buffer pointer, enter XGP line number

	pushj p,headin	;put in heading, mode switches and so on

	pushj p,gobble	;transform the line

	cain u,3
	jrst wrtnow
	setz a,
	idpb a,g	;PDP11 words worth of white
	idpb a,g	;PDP11 words worth of white
	idpb a,g	;PDP11 words worth of white

wrtnow:	pushj p,wrtlin	;write the line
	caig u,1
	jrst gumpa
	pushj p,dumlin	;update line-number
	pushj p,wrtlin	;write it again
gumpa:	caig u,2
	jrst gumpb
	pushj p,dumlin	;update line-number
	pushj p,wrtlin	;write it again
gumpb:	sojg d,linout
	popj p,

headin:	cain u,3
	jrst imagen
	setz a,		;(0,0) enter run-length mode
	idpb a,g
	move a,lftmar
	andi a,377
	idpb a,g	;(200,0) 8 PDP11 words  worth of white
	idpb a,g	;(200,0) 8 PDP11 words  worth of white
	caie u,1
	jrst whteno
	idpb a,g	;(200,0) 8 PDP11 words  worth of white
	idpb a,g	;(200,0) 8 PDP11 words  worth of white
whteno:	setz a,		;(0,0) escape to command mode
	idpb a,g
	movei a,2
	idpb a,g	;(2,0) enter image mode - and 8 bits of white
	popj p,

imagen:	movei a,2*400		;(0,2) enter image mode
	idpb a,g
	popj p,

wrtlin:	movn a,nmbwrd(u)
	lsh a,-1
	hrlz a,a
	hrri a,dskbuf
	.iot dskc,a
	aos e		;up line-count
	popj p,

dumlin:	move g,[442000,,dskbuf]
	move a,nmbwrd(u)	;number of PDP11 words in line
	idpb a,g
	idpb e,g	;line-number
	popj p,

gobble:	movei c,44	;36. PDP10 words per line
	cain u,1
	jrst gobonc
	cain u,2
	jrst gobtwc
	jrst gobtrc

gobonc:	ildb a,f	;16 bits from tv
	circ a,-20	;reverse bits into b
	idpb b,g	;16 bits to disk
	sojg c,gobonc
	popj p,

gobtwc:	ildb a,f	;get 8 bits from tv
	move b,dbltbl(a)	;look up doubled and reversed
	idpb b,g	;put 16 bits to disk
	ildb a,f	;get 8 bits from tv
	move b,dbltbl(a)	;look up doubled and reversed
	idpb b,g	;put 16 bits to disk
	sojg c,gobtwc
	popj p,

gobtrc:	ildb a,f	;get 8 bits from TV
	move a,dbltbl(a)	;look up 24 bits
	ildb b,f	;get next 8 bits
	move b,dbltbl(b)	;look up 24 bits
	lsh b,14	;left-justify (24. + 12. = 36.)
	lshc a,-10	;move 8 across to second word
	move t,b	;save it for now
	circ a,-20	;reverse it
	idpb b,g	;put 16 bits into disk buffer
	move b,t	;next batch
	lshc a,20	;suck out 16
	move t,b	;save rest for now
	circ a,-20	;reverse it
	idpb b,g
	move b,t
	lshc a,20	;suck out remaining 16 bit
	circ a,-20	;reverse it
	idpb b,g
	sojg c,gobtrc
	popj p,

; if white-out on XGP is a problem, it may help to generate 
; white bits in duplicate and triplicate mode.

tblini:	cain u,1
	popj p,
	movei d,377
tbllup:	move a,d	;get number
	movei c,10	;8 bits to do
dbllup:	lshc a,-1	;move one bit over
	ash b,-1	;duplicate it (make lsh to generate white)
	caie u,2
	ash b,-1	;duplicate it (make lsh to generate whit)
	sojg c,dbllup
	caie u,2
	jrst shovth
	lshc a,20	;bring back into a
	circ a,-20	;reverse into b
	movem b,dbltbl(d)
	sojge d,tbllup
	popj p,

shovth:	lshc a,30
	movem a,dbltbl(d)	;store it
	sojge d,tbllup
	popj p,

readnm:	.break 12,[5,,jcl]	;get job control language
	move c,[440700,,jcl]
	movei f,dskfil+1
scanon:	move d,[440600,,g]	;first file name ?
	setz g,
cntrlp:	ildb a,c
	skipn a
	popj p,
	caig a,40
	jrst cntrlp
goblop:	cain a,":
	jrst colons
	cain a,";
	jrst semico
	cain a,"/
	jrst param
	caig a,40
	jrst spacer	;space
	caige a,140
	subi a,40	;number
	idpb a,d
	ildb a,c
	jrst goblop

spacer:	skipn g
	jrst scanon
	movem g,(f)
	movei f,dskfil+2
	jrst scanon

semico:	movem g,unames
	jrst scanon

colons:	hlrm g,dskfil	;oh, really?
	jrst scanon

param:	ildb u,c
	subi u,60
	caile u,3
	movei u,3
	skipg u
	movei u,1
	jrst spacer

dskfil:	7,,(sixbit/dsk/)
	sixbit /frame/
	sixbit />/

cormap:	setz
	'corblk
	1000,,600000
	1000,,-1
	a
	1000,,-2
	setz b

nmbwrd:	0
	2+1+4+2+44+3
	2+1+2+2+44+44+3
	2+1+44+44+44-3	;number of PDP11 words in record (better be even!)

lftmar:	200	;0 < lftmar < 400 (left margin of white)

unames:	0	;potential place for luser name

dbltbl:	block 400	;tripled up bits

dskbuf:	block 70	;65 max of 53. words

pdl:	block 20

jcl:	block 20

	-1

	end start
