.Title	DATSUB - Subroutine to print day and date at top of VT100 terminal
.Enabl	lc,gbl
.Nlist	bex,toc

.Sbttl	V3	13-Jan-83

.Mcall	.ttyou,.exit,.print,.settop

jsw=44
b.tspm=10000			;Suppress echoing of type-ahead
.asect
.=jsw
b.tspm
.psect

.macro	copy	string,?x
	mov	#string,r0
x:	movb	(r0)+,(r1)+
	bgt	x
	dec	r1
.endm



Datsub::
	bis	b.tspm,@#jsw	;Just in case!

	mov	#40,r0		;Set up lines full of spaces
	mov	limit+2,r1
	mov	#250.,r2	;250 characters ought to do us.
1$:	movb	r0,(r1)+
	dec	r2
	bne	1$

	.settop	r1		;If error, too bloody bad.

	mov	limit+2,r1	;SET UP TOP LINE
	movb	#xoff,(r1)+	;Suppress type-in
	copy	t$norg		;No origin
	copy	t$home		;Top of screen
	copy	t$dht		;Double height, top half
	copy	t$rv		;Reverse video
	copy	t$bold		;Bold

	mov	r1,r5		;Save for working out length of day name.

	mov	#datblk,r2
	call	rsdat		;Get system date
	call	iday		;Get day of week
	mov	r0,r4
	call	wday		;Insert name of day.

	sub	r1,r5		;Negative name of day length.

	copy	t$nv		;Normal video for spaces

	add	#29.,r5		;Over to right margin less room for date
	cmp	day,#10.	;If day < 10 add extra space
	bge	2$
	inc	r5
2$:	movb	#40,(r1)	;(remove terminator)
	add	r5,r1

	copy	t$rv
	copy	t$bold

	call	wdat		;Date
	copy	crlf

	copy	t$dhb		;SECOND LINE

	mov	#datblk,r2
	mov	r4,r0
	call	wday		;Insert name of day.

	copy	t$nv		;Normal video for spaces
	movb	#40,(r1)	;(remove terminator)
	add	r5,r1

	copy	t$rv
	copy	t$bold
	call	wdat		;Date
	copy	crlf
	copy	t$dclr		;Clear to end of screen
	copy	t$nv
	copy	t$orig
	clrb	(r1)

	.print	limit+2

	mov	(pc)+,r0
	.byte	3,24.
	call	ttscrl
10$:
	.ttyou	#xon
	bic	#b.tspm,@#jsw
	return

limit:	.limit
crlf:	.byte	cr,lf,0

.end
