	.NLIST BEX
	.TITLE DIS -- BAR GRAPH DISPLAY ROUTINE
;
;        COPYRIGHT (c) 1979,1978 BY
;        DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS,  U.S.A
;
;
;        THIS SOFTWARE IS FURNISHED UNDER A LICENCE  AND  MAY
;        BE USED AND COPIED ONLY IN ACCORDANCE WITH THE TERMS
;        OF  SUCH LICENCE AND WITH THE INCLUSION OF THE ABOVE
;        COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY OTHER COPIES
;        THEREOF  MAY  NOT  BE  PROVIDED  OR  OTHERWISE  MADE
;        AVAILABLE  TO  ANY  OTHER  PERSON.   NO TITLE TO AND
;        OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERED.
;
;
;        THE INFORMATION  IN  THIS  SOFTWARE  IS  SUBJECT  TO
;        CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS
;        A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
;
;
;        DIGITAL ASSUMES NO RESPONSIBILITY  FOR  THE  USE  OR
;        RELIABILITY  OF  ITS  SOFTWARE ON EQUIPMENT WHICH IS
;        NOT SUPPLIED BY DIGITAL.
;
;        THIS SOFTWARE IS SUPPLIED UNSUPPORTED BY DIGITAL AND
;        NO LIABILITY, SUPPORT, OR APPROVAL OF THIS  SOFTWARE
;        EITHER EXPRESS OR IMPLIED, WILL  BE  UNDERTAKEN   BY
;        DIGITAL UNDER ANY CIRCUMSTANCES.
;
;		AUTHOR:  P. G. VISCAROLA
;			 DEC, EDUCATIONAL SERVICES
;		DATE:    10-NOV-78
;
; Modified:
;
; 001	02-May-1981  Bruce C. Wright	Various modifications to
;					work with screen package,
;					on non-VTxx terminals.
; 002	19-Oct-1981  Bruce C. Wright	Added capability for use
;					of line drawing character
;					set on terminals which have it.
;
	.SBTTL  FUNCTIONAL DESCRIPTION
	.PAGE
;	*** DIS -- SUBROUTINE TO DISPLAY A PERCENTAGE BAR GRAPH
;
;	THIS SUBROUTINE IS CALLED TO DISPLAY A BAR GRAPH OF A PERCENTAGE
;	(WITH QUADS), ROUNDED TO THE NEAREST 2%, ON THE CURRENT LINE OF
;	THE GRAPH.
;
;	INPUTS:
;		R0 - INDEX INTO THE DISPLAY TABLES
;		R1 - PERCENTAGE TO DISPLAY
;	OUTPUTS:
;		NONE
;
; THE DISPLAY TABLES ARE:
;	BASEX		X COORDINATE BASE OF LINE
;	BASEY		Y COORDINATE BASE OF LINE
;	DISTAB		CURRENT LENGTH OF THIS DISPLAY LINE
;
; REGISTER TWO IS PRESERVED AS A POINTER TO THE ARGUMENT LIST
; IN THE MAIN PROGRAM.  ALL OTHER REGISTERS ARE CLOBBERED.
;
;
	.SBTTL DATA AREAS
	.PAGE
; DATA AREAS:
;
; BUFFER FOR "POSITION CURSOR AND DELETE TO END OF LINE"
GRAPH:	.BLKB	60.		; Space for quad characters.
 
	.even

	.SBTTL MAIN LINE CODE
	.PAGE
DIS::
	MOV	R2,-(SP)		; SAVE REGISTER THREE
	MOV	R0,R5			; SAVE THE INDEX
	CLR	R0			; SET UP FOR THE DIVIDE
	TST	R1			; Is it negative?
	BPL	2$			; J if not.
	CLR	R1			; Make it 0 if so.
2$:	DIV	#2,R0			; NUMBER OF QUADS TO OUTPUT
	MOV	R0,R3			; SAVE NUMBER OF 2%'S TO DISPLAY
	MOV	DISTAB(R5),R2		; GET THE NUMBER OF QUADS CURRENTLY
					;  BEING DISPLAYED.
	CMP	R0,R2			; COMPARE IT WITH THE NUMBER TO DISPLAY
	BEQ	DONE			; IF SAME, NO CHANGE
	BLT	10$			; IF FEWER TO DISPLAY, BRANCH

; THE NUMBER OF QUADS TO BE DISPLAYED IS MORE THAN CURRENTLY IN GRAPH
	SUB	R2,R0			; QUADS TO ADD TO LINE
	mov	r0,-(sp)		; Remember the  number.
	MOVB	BASEX(R5),r2		; Y POSITION
	MOV	BASEY(R5),r1		; X POSITION
	ADD	DISTAB(R5),r1
	mov	#5,r0			; Get LUN.
	call	$scadr			; Address the screen.
	mov	#graph,r1		;++002 Point to the quad buffer.
	mov	#50.,r2			;++002 Get size of buffer.
3$:	movb	li.qua,(r1)+		;++002 Construct buffer.
	sob	r2,3$			;++002 And loop.
	mov	li.beg,r1		;++002 Get enter graphics mode sequence
	clr	r2			;++002 0-trailed
	call	$scout			;++002 Output it.
	mov	#graph,r1		;++002 Point to graph.
	mov	(sp)+,r2		;++002 Recover length of buffer.
	call	$scout			;++002 Output the quads.
	mov	li.end,r1		;++002 Get exit graphics mode sequence
	clr	r2			;++002 0-trailed
	call	$scout			;++002 Output it.
	br	done			; And leave.

; THE NUMBER OF QUADS TO DISPLAY IS LESS THAN CURRENTLY IN GRAPH
10$:	MOVB	BASEX(R5),r2		; GET THE Y POSITION
	MOV	BASEY(R5),R4		; AND THE X POSITION
	ADD	R0,R4			; TO BE END OF QUADS THIS ROW
	movb 	r4,r1			; Get end of bar this row.
	mov	#5,r0			; Get the LUN
	call	$sceol			; And clear to end-of-line.
	BR	DONE			; WE'RE DONE

DONE:	MOV	R3,DISTAB(R5)		; SAVE NUMBER OF QUADS BEING DISPLAYED
	MOV	(SP)+,R2		; RESTORE THE SAVED REGISTER
	RETURN				; BACK TO CALLER
	.END
