/COPYRIGHT BY DIGITAL EQUIPMENT CORPORATION 1969
/BASIC CHARACTER GENERATOR
/WRITTEN BY MURRAY RUBEN AS PART OF THE KV8/I SOFTWARE.

LOCATE=1000

*LOCATE
/NOTE: THIS MAIN PROGRAM BEGINS AT 1000 WHICH IS ONLY
/AN ARBITRARY NUMBER. ROUTINE IS 332 DECIMAL LOCATIONS LONG.
DSPY,	0	/CALL WITH ASCII CHAR IN ACCUMULATOR
	JMS I SRCHI	/IS IT A SEARCH CHARACTER?
	TAD I SAVE2	/CHECK FOR CONTROL CHAR
	TAD M240
	SPA CLA
	JMP I DSPY	/IGNORE CONTROL CHAR (NO ECHO)
	TAD I SAVE2
	JMS OUTCHM	/OUTPUT TO DISPLAY
DSPYI,	JMP I DSPY	/EXIT WITH AC=0

/THE FOLLOWING IS A "SHORT" DATA AREA:
M240,	-240
SAVE2,	SAVE1	/ANOTHER TEMPORARY STORAGE AREA.
SRCHI,	SEARCH
M7,	-7
M14,	-14
TOP,	506	/TOPMOST LINE OF THE SCREEN.


/ROUTINE -RESET- ACCOMPLISHES THE "VERTAB" FUNCTION (CTRL/K).
RESET,	TAD TOP	/ERASE SCREEN, RESET INTGEGRATORS AND CPR TO TOP LEFT
	6066	/EXECUTE 
	DCA Y0	/SET Y TO TOP
CR,	TAD Y0
	TAD M14
	DCA Y0
	TAD MARGIN
XCUTE,	DCA X0
	TAD M240
	JMP DSPYI-1	/SET INTEGRATORS TO "MARGIN".

SYNC,	TAD M7	/"SYNCHRONIZE"  A STABLIZING FUNCTION .
	TAD X0
	JMP XCUTE

/VARIABLES USED BY CHARACTER GENERATOR
X0,	-400	/X CHARACTER POSITION REGISTER
Y0,	512	/Y CHARACTER POSITION REGISTER
A,	0	/CONTROL WORD
B,	0	/MASK WORD
C,	0	/MASK POINTER
H,	0	/HALFWORD SWITCH

/CONSTANTS
C7,	7
C77,	77
CEX,	400
SAR1,	SAR
MASKS,	MASK0-1


/THIS IS THE ROUTINE WHICH DEALS WITH THE "MASK" AND
/"DISPATCH" CONTROL WORDS FOR THE ACTUAL DETERMINATION
/AND EXECUTION OF THE APPROPRIATE VECTOR STROKES TO 
/BE DISPLAYED ON THE SCOPE.....
OUTCHM,	0	/DISPLAY CHARCTER. ENTER WITH ASCII 240-337
	AND C77	/MASK TO 6 BITS
	CLL RAL	/*2
	TAD SAR1	/ADD DISPATCH
	DCA A
	TAD I A	/THIS IS MASK WORD
	AND C7	/MASK OFF MASK BITS
	CLL RAL	/*2
	DCA B
	TAD B
	CLL RAL	/*4
	TAD B	/*6 NOW
	TAD MASKS	/6 TIMES MASK + MASK HEAD POINTER
	DCA C	/PTR FOR MASK ADDRESSES
	TAD I A
	CLL RAR
	DCA B	/SETS INTENSIFY BLANKING BITS, FIRST ALWAYS BLANKED
	ISZ A
	TAD I A
	DCA A	/RETRIEVE CONTROL WORD
	DCA H	/SETS LEFT HALF
	TAD X0
	TAD C7
	DCA X0	/CHAR ADVANCE

VA,	TAD H
	CIA
	DCA H	/RESET HALFWORD SWITCH
	ISZ H
	ISZ C	/ADVANCE PTR ON ZERO H
	TAD A
	SNA	/TEST NEXT CONTROL BIT
	JMP I OUTCHM	/ZERO MEANS ALL VECTORS WERE EXECUTED, SO EXIT
	CLL RAL
	DCA A	/NEXT CONTROL BIT IN LINK
MARGIN,	SNL	/THIS IS THE Y0 "MARGIN" POINTER IN 2'S COMP..
	JMP VA	/NOT AN EXECUTION

	TAD C6064	/INITIALIZE VOUT
	DCA VSTATE
	TAD H	/0 IF RIGHT HALF, 1 IF LEFT HALF
	CLL RAR	/INTO LINK
	TAD I C	/GET MASK ADDRESS
	SNL
	JMP .+4	/R.H.
	CLL RTR
	RTR
	RTR	/L.H.
	DCA I SAVE2

	TAD I SAVE2
	RTR
	RAR
	AND C7
	TAD X0	/ADD X MASK TO CPR
	JMS VOUT	/LOAD X ABSOLUTE
	TAD I SAVE2
	AND C7
	TAD Y0	/ADD Y MASK TO CPR
	JMS VOUT	/LOAD Y ABSOLUTE

	TAD B
	CLL RAL
	DCA B	/RETRIEVE NEXT BLANKING BIT INTO LINK
	RAL	/AND THEN INTO BIT 11
	TAD CEX	/EXECUTE ABSOLUTE (VISIBLE) VECTOR
	JMS VOUT
	JMP VA	/BACK FOR MORE VECTORS

/THIS IS THE ROUTINE WHICH ACTUALLY EXECUTES THE 
/STROKES, POINT DISPLAYS, AND OTHER FUNCTIONS FOR
/THE KV8/I CONTROLLER...
/DISPLAY OUTPUT AUTO SEQUENCING ROUTINE:
VOUT,	0
	6071	/WAIT FOR READY FLAG
	JMP .-1
VSTATE,	6064	/AUTO SEQUENCED INSTRUCTION
	ISZ VSTATE	/SEQUENCE
	CLA
	JMP I VOUT
C6064,	6064	/INITIALIZED TO LOAD X


/THE FOLLOWING ROUTINE EXECUTES THE "TAB" FUNCTION
/OF MOVING ALONG THE LINE TO THE NEXT TAB STOP.
/TAB STOPS ARE LOCATED EVERY 10 SPACES ALONG
/THE LINE FROM THE LEFT MARGIN.
TAB,	TAD TABHD	/ADVANCE X0.
	DCA A

TAB1,	ISZ A		/TO NEXT TAB STOP.
	TAD I A
	SNA		/END OF LIST=END OF LINE SO DO CRLF.
	JMP CR

	CIA
	TAD X0		/TEST X0 WITH THE TAB STOP LIST.
	SMA CLA
	JMP TAB1	/NOT BIG ENOUGH SO TRY AGAIN.

	TAD I A		/O.K.	SET THE TAB AND RESET INTEGRATORS.
	JMP XCUTE

TABHD,	TABS-1	/HEAD OF TAB STOP TABLE..
/THE FOLLOWING IS THE ACTUAL "TABS STOP" LIST:

TABS=.
	-252
	-144
	-36
	50
	156
	264

	0	/ZERO ENDS THE LIST..

/THE FOLLOWING "SEARCH" ROUTINE CHECKS THE INPUT
/ASCII CODE AGAINST THE "ACTIVE" CONTROL CHARACTERS.
SEARCH,	0	/SEARCH ROUTINE.
	DCA SAVE1	/SAVE THE INPUT ASCII CHARACTER
	TAD SRCH3
	DCA PTR

SRCH2,	ISZ PTR	/FOLLOW ALONG DOWN THE CHARACTER TABLE.
	TAD I PTR	/BRING IN A LIST ELEMENT
	SNA
	JMP I SEARCH	/END OF TABLE FOUND AND NO MATCH!

	CIA	/COMPLEMENT TO TEST.
	ISZ PTR
	TAD SAVE1	/NOW TEST AGAINST THE "CHAR".
	SZA CLA
	JMP SRCH2	/NO MATCH FOUND SO TRY AGAIN!

	TAD I PTR	/"MATCH FOUND" !!
	DCA SEARCH	/DO DOUBLE INDIRECT JUMP
	JMP I SEARCH	/FROM DLIST POINTER.

/CONSTANTS FOR THE ABOVE
SAVE1,	0	/TEMP STORAGE AREA.
SRCH3,	DLIST-1	/BEGINNING OF THE CONTROL CHAR. TEST LIST.

/THE FOLLOWING PARTS ARE THE CHARACTER TABLES FOR THE CHARACTER
/GENERATOR .

/CHARACTER MASK COORDINATES


MASK0,	0301	/D,J,5,&,%,]
2143
4145
2705
0747
0301
MASK1,	0701	/L,U,V,W,X,Y,I,T,N,M,0,1,(,),]
0706
2447
2724
2141
0147
MASK2,	0141	/2,S,4,9,7,Z,$,/,\,<,>
0747
4404
0747
0141
2127
MASK3,	0424	/A,C,E,F,G,H,K,0,Q,R,P,3,6,8,L,B
3444
4147
0701
4144
2404
MASK4,	2622	/^,B.A.,-,+,*
4305
4503
0426
4404

PTR,	0	/TEMP POINTER CELL USED IN "SEARCH" ROUTINE.

MASK5,	4525	/@,#,=
0503
2343
4721
2707
0141
MASK6,	0627	/",',;,:,?,!,,,
2525
4524
2323
1121
2147
SAR=.	/CHARACTER DISPATCH TABLE
7745	/@
6347
5603	/A
4760
7703	/B
2175
7003	/C
0170
7700	/D
3551
5603	/E
5170
5403	/F
5160
7603	/G
0176
5203	/H
4760
5201	/I
1156
7000	/J
5404
6503	/K
6172
6003	/L
0070
7401	/M
3304
7001	/N
3005
7403	/O
0370
7403	/P
4560
7603	/Q
2370
7503	/R
4572
7602	/S
6360
5001	/T
1150
7001	/U
6005
6001	/V
4011
7401	/W
6205
5001	/X
1007
6401	/Y
1330
7002	/Z
0074
7001	/[
0154
4002	/\
0044
7000	/]
3050
5404	/^
6070
6404	/B.A.
2074


0000	/SP
7000	/EXECUTE 3 "INVISIBLE" VECTOR STROKES.
5006	/!
2046
5006	/"
3201
5245	/#
5572
7642	/$
6363
6740	/%
1675
6760	/&
3637
4006	/'
3000
6001	/(
0124
6001	/)
1202
5204	/*
7700
5004	/+
6014
4006	/,
0030
4004	/-
0014
4006	/.
0060
4002	//
4400
7601	/0
3107
6401	/1
0456
7602	/2
1714
5503	/3
4770
6402	/4
0364
7600	/5
3434
7603	/6
0175
6002	/7
0070
5703	/8
4770
7402	/9
0364
5006	/:
1460
5006	/;
1430
6002	/<
2120
5005	/=
5500
6002	/>
4240
7506	/?
6346
/THIS IS THE LAST OF THE CHARACTER DISPATCH TABLE.....

DLIST=.	/TABLE OF ACTIVE CONTROL CHARACTERS.
	215
	CR	/CARRIAGE RETURN
	213
	RESET	/VERTAB FUNCTION OF ERASE AND RESET INTEGRATORS.
	377
	DSPYI	/RUB OUT (IGNORED)
	375
	DSPYI	/ALT MODE KEY (IGNORED)
	211
	TAB	/HT
	237
	SYNC	/SYNC (CTRL/SHIFT/O) FUNCTION TO STABLIZE.

	0	/ZERO ENDS THE LIST....

/IT ALSO FINISHES THE CHARACTER GENERATOR PROGRAM.....

END=.
$
