/DECMATE II GRAPHICS PRIMITIVES
/	0055A	16-AUG-84	/FIELD FIX LOST IN CONVERSION	
VER=	0055			/LATEST VERSION NUMBER OF THE PROGRAM
/
/ VERSION 55 - 31 JUL 84 - KAH - ADD MONOCHROME MAP FOR NEW BOARDS;
/				 LOAD COLOR OR MONOCHROME MAP WHEN 'GRAPHICS
/				 TO MONOCHROME MONITOR' SELECTION CHANGED.
/ VERSION 54 - 27 JUL 84 - KAH - ADD DECMATE III AND NEW/OLD GRAPHICS BOARD
/				 TESTS TO DO THE RIGHT THING;
/				 MODIFY POWER-UP ROUTINE TO HANDLE WHATEVER
/				 COMBINATION OF DECMATE AND BOARD WE FIND;
/				 MODIFY CONFIGURATION SET-UP TO HANDLE WHATEVER
/				 COMBINATION OF DECMATE AND BOARD WE FIND;
/				 ADD COLOR MAP INITIALIZATION FOR NEW BOARD.
/ VERSION 53 - 16 JUL 83 - KAH - USE TEXT PIXEL VECTORS FOR 45 DEGREE CELL
/				 ROTATION (HAD FORCED TO 0 DEGREE PIXEL
/				 VECTORS).
/ VERSION 52 - 02 JUL 84 - KAH - CHANGE SCREEN ERASE TO AVOID 32 PIXELS AT
/				 RIGHT OF SCREEN (DO ONLY 800, NOT 832);
/				 CLIP NUMBER OF DOTS TO DRAW IF TEXT CELL IS
/				 LARGER THAN UNIT SIZE.
/ VERSION 51 - 18 JUN 84 - KAH - PREVENT SYSTEM CRASH ON LARGE TEXT SIZES BY
/				 ADDING AN UNSIGNED DIVIDE ROUTINE (HAD GOTTEN
/				 OVERFLOW IN PREVIOUS MULTIPLY);
/				 TRUNCATE TEXT CELL AND UNIT DIMENSIONS TO 400
/				 DECIMAL ON INPUT TO PREVENT OVERFLOW IN LATER
/				 CALCULATIONS.
/				 ** VERSION 50 IN FIELD TEST VERSION 43 **
/ VERSION 50 - 16 MAY 84 - KAH - ALLOW CURSOR TO BE DISPLAYED IN W(N1) MODE.
/ VERSION 47 - 14 MAY 84 - KAH - FIX UPSIDE-DOWN CHARACTERS (HAD HORZONTAL
/				 BARS IN THEM);
/				 TEST FOR GRAPHICS BOARD PRESENT AND IGNORE
/				 SUBSEQUENT REQUESTS IF NO BOARD;
/				 AVOID DRAWING CHARACTER DOTS BELOW CELL
/				 HEIGHT.
/ VERSION 46 - 09 MAY 84 - KAH - GET CELL WIDTH IN PHYSICAL PIXELS FOR TEXT
/				 APRON (HAD BEEN LOGICAL PIXELS, DOING TOO MUCH
/				 ON BASELINE ANGLES OF 90 AND 270).
/ VERSION 45 - 04 MAY 84 - KAH - ADD BIT<06> TO COMMAND 34'S SETUP WORD FOR
/				 REQUESTING A RESYNCHRONIZATION OF THE VIDEOS
/				 (NEEDED WHEN COLUMN WIDTH CHANGES);
/				 ADD DOCUMENTATION ON GRAPHICS BOARD REGISTERS.
/ VERSION 44 - 01 MAY 84 - KAH - DON'T DRAW TEXT OUTSIDE SCREEN.
/ VERSION 43 - 23 APR 84 - KAH - CHANGE CURSOR TO A CROSS-HAIR;
/				 HANDLE NEGATIVE ANGLES FOR TEXT CHARACTER
/				 ORIENTATION AND BASELINE ANGLE;
/				 EXTEND SCREEN ERASE TO GET EXTRA 32 PIXELS
/				 AT RIGHT OF SCREEN;
/				 ENSURE CURRENT POSITION LEFT AT STARTING
/				 POINT OF A CLOSED CURVE.

/ VERSION 42 - 17 APR 84 - KAH - PRELIMINARY WORK TO ALLOW CHARACTER
/				 CLIPPING (HORIZONTAL APRON).
/ VERSION 41 - 13 APR 84 - KAH - USE MINIMUM OF EIGHT DOTS FOR CHARACTER
/				 UNIT WIDTH WHEN CELL ROTATION IS 90 OR 270;
/				 AVOID DRAWING CHARACTER CELL APRON IF CELL
/				 ALREADY FULL (OR OVERFULL).
/ VERSION 40 - 05 APR 84 - KAH - CHANGE READ SCREEN FROM DMAR TO RDAT
/				 (HAD MISREAD SCREEN DATA SOMETIMES);
/				 COMPLEMENT ALL PLANES FOR COMPLEMENT WRITING
/				 MODE;
/				 CHANGE POWER-ON SYNCH ARGS TO AVOID SCREEN
/				 TEARING, CAN DO CAUSE NO LONGER USING DMA;
/				 CHANGE TEST FOR SPEEDY TEXT TO INCLUDE NEGATE
/				 OFF;
/				 MOVE COMMAND DISPATCH TABLE TO TABLE FIELD
/				 TO MAKE ROOM FOR CODE.
/ VERSION 37 - 18 FEB 84 - KAH - SPEED TEXT DRAWING IN REPLACE WRITING MODE
/				 AND NON-ITALICIZED BY DRAWING CELL FIRST AND
/				 DRAWING CHARACTER IN OVERLAR MODE SECOND;
/				 SPEED UP TEXT DRAWING BY CHECKING IF REMAINING
/				 DOTS IN CHARACTER ROW ARE ZERO, IF SO THEN
/				 DO THEM WITH THE CELL APRON.
/ VERSION 36 - 17 FEB 84 - KAH - ADD TEXT DISABLE AND GRAPHICS DISABLE TO
/				 THE 'PASS SETUP PARAMS' COMMAND;
/				 FIX TEXT SAVE/RESTORE COMMANDS.
/ VERSION 35 - 15 FEB 84 - KAH - INVERT CURSOR ORIENTATION ONLY WHEN
/				 ABOUT TO GO OFF SCREEN;
/				 RELEASED WITH VERSION 17-F PRE-FIELD TEST.
/ VERSION 34 - 14 FEB 84 - KAH - USE TEXT CELL SIZE AND ORIENTATION FOR
/				 TEXT PIXEL VECTORS AND LINE FEEDS.
/ VERSION 33 - 13 FEB 84 - KAH - FIX TEXT 'DOT' DRAWING;
/				 DRAW EACH CHARACTER 'DOT ROW' TO CELL
/				 BOUNDARY.
/ VERSION 32 - 13 FEB 84 - KAH - FIX DISPLAY OF SMALL CHARACTER DESCENDERS;
/				 COMBINE LIKE DOTS FOR DRAWING SMALL CHARACTERS.
/ VERSION 31 - 09 FEB 84 - KAH - FIX SCREEN ERASE AND ERASE MODE WRITING;
/				 FIX SHADE WITH PATTERN;
/				 TREAT CHARACTER ROTATIONS OF 45 DEGREES AS
/				 THE NEXT LOWER 90 DEGREE ANGLE;
/				 DRAW CORRECT SIZE OF CHARCTER 'DOTS';
/				 AVOID DRAWING 'DOTS' THAT WILL HAVE NO
/				 AFFECT;
/				 COMBINE 'DOTS' BEFORE DRAWING SMALL CHARACTERS;
/				 FIX 'DOT' SIZE IN ITALIC CHARACTERS.

/ VERSION 30 - 05 FEB 84 - KAH - CHANGE TEXT DISPLAY TO DRAW DOTS;
/				 WRITE ALL FOUR REGISTERS TWO (TO ALLOW FOR
/				 LATER GRAPHICS DISABLE);
/				 CHANGE POWERUP CODE TO WRITE ALL REGISTERS TWO;
/				 FIX DIVIDE AND MULTIP ROUTINES;
/				 INITIALIZE NEW TEXT PARAMS AT POWERON;
/				 INCREASE TEXT OPTION SAVE BUFFER SIZE;
/				 FIX SETUP TO ALLOW GRAPHICS TO MONOCHROME;
/				 COPY PRAM STRING IN 'DRAW' SO ORIGINAL
/				 STRING IS UNCHANGED.
/ VERSION 27 - 03 FEB 84 - KAH - FIX COPYING OF TEXT PARAMS;
/				 TRY TO FIX TEXT PIXEL VECTORS;
/				 PRE-COMPUTE TEXT DRAWING PARAMETERS;
/				 CHANGE CURSOR PATTERN FOR SYMMETRY.
/ VERSION 26 - 30 JAN 84 - KAH - FIX TEST FOR REPLACE MODE IN 'DRAW';
/				 COPY TEXT PARAMS TO MAIN FIELD WHEN CHANGED;
/				 USE NEW SET OF TEXT PARAMS;
/				 DELETE CHECK FOR TEXT ON SCREEN;
/				 DELETE CHECK FOR ITALIC AND CELL ROTATION;
/				 FIX TEXT PIXEL VECTORING;
/				 ENLARGE CURSOR.
/ VERSION 25 - 27 JAN 84 - KAH - FIX DISPATCH TO NEW FIELD;
/				 FIX HANDLING OF TEXT PARAMETERS;
/				 USE DEFUALTS FOR INVALID PARAMETERS;
/				 SPEED UP 'DRAW' BY PASSING PRAM STRING
/				 SEPARATELY;
/				 CHANGE TEST FOR REPLACE MODE IN 'DRAW';
/				 ADD INITIALIZE ROUTINE FOR TABFLD CODE;
/				 ADD SAVE/RESTORE TEXT OPTIONS COMMANDS;
/				 DELETE UNUSED CODE (GETDEG, CSETUP, TIMSIZ);
/				 CHANGE TEXT PIXEL VECTOR CODE;
/				 REMOVE ZOOM FROM DISPLAY TEXT CODE.
/ VERSION 24 - 23 JAN 84 - KAH - FIX SCREEN ERASE;
/				 ADD NEW TEXT PARAMS OPCODE (42.);
/				 DELETE OLD TEXT PARAMS ROUTINES;
/				 DELETE TEXT OPTIONS SAVE/RESTORE ROUTINES;
/				 IGNORE ITALICS FOR TEXT PIXEL VECTORING;
/				 PARAMETERIZE GDC COMMAND STRINGS TO ALLOW
/				 FUTURE PERFORMANCE BOOST.
/ VERSION 23 - 19 JAN 84 - KAH - EXPECT 8X10 CHARACTERS IN BITMAP;
/				 DELETE REFERENCES TO ALPHABET EXTENT;
/				 SCREEN ERASE GETS APRON, TOO;
/				 ADD 'HT' SUPPORT IN TEXT STRING;
/				 DON'T MOVE CURSOR AT START/END OF TEXT;
/				 TURN CURSOR OVER AT BOTTOM OF SCREEN.
/
/ 15-DECEMBER-1983  BRUCE R. HANSEN - PASSED VERSION 22 TO KENNY HOUSE.

/

	IFNDEF CONDOR	<
PRMFLD=	3			/FIELD OF THE PRIMITIVE ROUTINES
PBMFLD=	5			/PANEL RAM CHARACTER BIT MAP FIELD
PRGFLD=	PRMFLD^10		/USED BY CDF INSTRUCTIONS & PANEL RAM REQUEST
TABFLD=	5			/EXTRA FIELD FOR USER CODE
TBLFLD=	TABFLD^10
			>	/END IFNDEF CONDOR

	FIELD	PRMFLD
NOPUNCH
	PWRUP		/OPCODE=00	HARDWARE POWER UP
	POSTN1		/OPCODE=01	MOVE TO SPECIFIED POSITION
	SVTMPW		/OPCODE=02	SAVE TEMPORARY WRITE OPTIONS
	RSTMPW		/OPCODE=03	RESTORE TEMPORARY WRITE OPTIONS
	GETVEC		/OPCODE=04	DRAW A VECTOR
	GTNEGM		/OPCODE=05	DISABLE/ENABLE NEGATE MODE
	SCRNER		/OPCODE=06	SCREEN ERASE
	GETDRG		/OPCODE=07	SET DISPLAY REGION - SCREEN TO BALCK
	GTBGRD		/OPCODE=08	SELECT BACKGROUND COLOR
	GTFGRD		/OPCODE=09	SELECT FOREGROUND COLOR
	GTWRTM		/OPCODE=10	SET WRITING MODE
	GTLTXT		/OPCODE=11	SET LINE TEXTURE
	GTSHDY		/OPCODE=12	SHADE TO Y
	GTSHDO		/OPCODE=13	TURN SHADING OFF
	SCRDMP		/OPCODE=14	SCREEN SIXEL DUMP
	DRWARC		/OPCODE=15	CENTER ARC
	CRVBGN		/OPCODE=16	CURVE BEGIN OPEN
	CRVCLS		/OPCODE=17	CURVE BEGIN CLOSED
	CRVCNT		/OPCODE=18	CURVE CONTINUE
	CRVEND		/OPCODE=19	CURVE END
	GTPLNS		/OPCODE=20	GET PLANE SELECT MASK WORD
	GETTXT		/OPCODE=21	DISPLAY CHARACTER
	DMYSUB		/OPCODE=22	NOP (WAS CELL CURSOR MOVEMENT)
	GTCSIZ		/OPCODE=23	CLEAR ALPHABET
	DMYSUB		/OPCODE=24	NOP (WAS CELL DISPLAY SIZE (ZOOM))
	DMYSUB		/OPCODE=25	NOP (WAS CELL ROTATION)
	DMYSUB		/OPCODE=26	NOP (WAS CELL ITALIC)
	DMYSUB		/OPCODE=27	NOP (WAS SELECT ALPHABET FOR DISPLAY)
	GTCBMP		/OPCODE=28	LOAD CHARACTER BIT MAP
	INIT		/OPCODE=29	SOFTWARE INITIALIZE
	MORCOD		/OPCODE=30	SAVE TEXT OPTIONS
	MORCOD		/OPCODE=31	RESTORE TEXT OPTIONS
	RETPOS		/OPCODE=32	REQUEST CURSOR POSITION
	TRMNTE		/OPCODE=33	TERMINATE GRAPHICS (INIT-CURSOR OFF)
	SETUP		/OPCODE=34	SETUP - CURSOR + GRAPHICS/TEXT SCREEN
	DMYSUB		/OPCODE=35	NOP - NO OPERATION
	GTLMLT		/OPCODE=36	SELECT LINE PATTERN MULTIPLIER
	RETREG		/OPCODE=37	RETURN CO-ORDINATES OF LOGICAL SCREEN
	GTTXTR		/OPCODE=38	SET TEXT REFERENCE POSITION
	RSTCUR		/OPCODE=39	RESTORE CURSOR AFTER TEXT STRING
	GTXTPV		/OPCODE=40	TEXT PIXEL VECTOR MOVEMENT
	DMYSUB		/OPCODE=41	DRAW MARKER
	MORCOD		/OPCODE=42	TEXT PARAMETER SETUP
ENPUNCH

/ -----------------------------
/ GRAPHICS BOARD REGISTER USAGE
/ -----------------------------
/
/ STATUS REGISTER (READ ONLY)
/
/ BIT	MEANING
/ 11	1=DATA READY, 0=NO DATA READY OR DATA BEING TRANSFERRED
/ 10	1=FIFO FULL, 0=FIFO NOT FULL
/ 09	1=FIFO EMPTY, 0=FIFO NOT EMPTY
/ 08	1=DRAWING IN PROGRESS, DRAWING NOT IN PROGRESS OR END OF LINE
/ 07	1=DMA TRANSFER IN PROGRESS, 0=DMA TRANSFER NOT IN PROGRESS
/ 06	1=VERTICAL RETRACE IN PROGRESS, 0=VERTICAL RETRACE NOT IN PROGRESS
/ 05	1=HORIZONTAL RETRACE IN PROGRESS, 0=HORIZ RETRACE NOT IN PROGRESS
/ 04	1=LIGHT PEN DETECT -- NOT IMPLEMENTED --
/ 03	1=DMA DATA READY, 0=NO DMA DATA READY
/ 00-02	UNUSED
/
/
/ REGISTER ONE
/
/ BIT	MEANING
/ 10-11	WRITE-BACK REGISTER
/ 08-09	WRITE-BACK REGISTER
/ 06-07	WRITE-BACK REGISTER
/ 04-05	REGISTER TWO ADDRESS
/ 03	1=EXTERNAL SYNC, 0=INTERNAL SYNCH
/ 02	1=ENABLE COMPOSITE VIDEO TO SBC (GRAPHICS TO MONOCHROME)
/ 01	UNUSED
/ 00	1=ENABLE VIDEO (GRAPHICS ENABLE)
/
/
/ REGISTER TWO
/
/ BIT	MEANING
/ 09-11	D-TO-A FOR GREEN GUN
/ 08	1=ENABLE SBC VIDEO (TEXT) TO GREEN
/ 05-07	D-TO-A FOR RED GUN
/ 04	1=ENABLE SBC VIDEO (TEXT) TO RED
/ 01-03	D-TO-A FOR BLUE GUN
/ 00	1-ENABLE SBC VIDEO (TEXT) TO BLUE

/ CHARACTER BIT MAPS (7-BY-9 CHARACTER FONT)
/
/		   TOP
/
/		00 000 000
/		XX XXX XX0
/		XX XXX XX0
/		XX XXX XX0
/	RIGHT	XX XXX XX0   LEFT
/		XX XXX XX0
/		XX XXX XX0
/		XX XXX XX0
/		XX XXX XX0   (DESCENDER)
/		XX XXX XX0   (DESCENDER)
/
/		  BOTTOM
/
/	/*/*/* EQUATES /*/*/*
/
PR3=	6236			/PANEL REQUEST FOR BLOCK MOVE
SRNLHX=	0			/LEFT  HORIZONTAL X PHYSICAL CO-ORDINATE
SRNRHX=	1440			/RIGHT HORIZONTAL X PHYSICAL CO-ORDINATE +1
SRNUVY=	0			/UPPER VERTICAL Y PHYSICAL CO-ORDINATE
SRNLVY=	740			/LOWER VERTICAL Y PHYSICAL CO-ORDINATE +1
SE=	6			/OPERATION CODE FOR SCREEN ERASE
PWR=	0			/OPERATION CODE FOR POWER UP

	*0000
GRFX,	7777		/GRAPHICS BOARD PRESENT?  (0=NO, -1=YES)
			/  ASSUME PRESENT UNTIL TESTED AT POWERON CLEAR.
GOBTYP,	0		/GRAPHICS OPTION BOARD TYPE
			/  (0=OLD BOARD, 1= NEW BOARD)
DECMAT,	0		/DECMATE SYSTEM TYPE (0=DECMATE II, 1=DECMATE III)
/
	*7
VERNUM,	VER			/LATEST VERSION NUMBER OF PROGRAM
AUTO10,	0
AUTO11,	0
AUTO12,	0
AUTO13,	0
AUTO14,	0
AUTO15,	0
AUTO16,	0
AUTO17,	0
/
ACHW,	0
ACLW,	0
MQHW,	0
MQLW,	0
SRH,	0
SRL,	0
OPCODE,	0			/OPERATION CODE OF FUNCTION BEING EXECUTED
REG1HI,	0			/HIGH SIX BITS OF GRAPHICS REGISTER ONE,

/
GETPRM=	JMS  I  .		/GET A PARAMETER FROM THE CALLING FIELD
	XGTPRM
PUTPRM=	JMS  I  .		/STORE PARAMETER INTO CALLING FIELD
	XPTPRM
GETXY1=	JMS  I  .		/GET CO-ORDINATES X1 AND Y1 FROM CALLING FIELD
	POSTN1
GETXY2=	JMS  I  .		/GET CO-ORDINATES X2 AND Y2 FROM CALLING FIELD
	POSTN2
CHKXY1=	JMS  I  .		/CHECK POSITION OF X1 AND Y1 - RETURN WITH FLAGS
	XY1CHK
DRWVEC=	JMS  I  .		/DRAW A VECTOR OR SHADE TO Y REFERENCE
	LINE
FAREA=	JMS  I  .		/FILL AREA SPECIFIED WITH COLOR
	XAREA
SENDIT=	JMS  I  .		/SEND COMMANDS TO GDC (ADDRESS FOLLOWS CALL)
	SENDAL
DRAWIT=	JMS  I  .		/DRAW THE SPECIFIED FIGURE
	DRAW
ERASE=	JMS  I  .		/ERASE THE SCREEN
	XERASE
BLDPOS=	JMS  I  .		/BUILD A CURSOR POSITION STRING
	DOPOS
SGNCHK=	JMS  I  .		/ADD TWO 12 BIT NUMBERS CHECKING FOR OVERFLOW
	XSGNCK
DBLADD=	JMS  I  .		/DOUBLE PRECISSION SIGNED ADD
	TADD
DBLSUB=	JMS  I  .		/DOUBLE PRECISSION SIGNED SUBTRACTION
	TSUB
DBLMTY=	JMS  I  .		/DOUBLE PRECISSION SIGNED MULTIPLY
	TMPY
DBLDIV=	JMS  I  .		/DOUBLE PRECISSION SIGNED DIVIDE
	TDIV
CNVDBL=	JMS  I  .		/CONVERT SINGLE PRECISSION TO DOUBLE
	CDBLW
MINMAX=	JMS  I  .		/CHECK VALUES TO BE WITHIN RANGE
	XMNMAX
LDREG1=	JMS  I  .		/LOAD GRAPHICS REGISTER 1
	WGREG1
LDREG2=	JMS  I  .		/LOAD GRAPHICS REGISTER 2
	WGREG2

/
K0007,	0007
K0010,	0010
K0012,	0012
K0017,	0017
K0077,	0077
K0177,	0177
K0377,	0377
M0001,	-0001
M0004,	-0004
M0010,	-0010
/
PTABLE,	0		/ADDRESS OF CALLING FIELDS PARAMETER TABLE
/
INITSZ=	BEGIN-INDEX-1	/SIZE OF AREA TO INIT WHEN CALLED BY OPCODE "INIT"
BEGIN,
XPOS1,	0		/CURRENT HORIZONTAL POSITION IN PIXELS (0 - 799.)
YPOS1,	0		/CURRENT VERTICAL POSITION IN PIXELS (0 - 239.)
XFLAG1,	0		/POSITION OF X C0-ORDINATE TO SCREEN
YFLAG1,	0		/POSITION OF Y CO-ORDINATE TO SCREEN
XPOS2,	0		/TEMPORARY HORIZONTAL POSITION
YPOS2,	0		/TEMPORARY VERTICAL POSITION
XFLAG2,	0		/POSITION OF X CO-ORDINATE TO SCREEN
YFLAG2,	0		/POSITION OF Y CO-ORDINATE TO SCREEN
XTEMP1,	0		/SAVED "FROM" X CO-ORDINATE
XTEMP2,	0		/SAVED "TO"   X CO-ORDINATE
PYPOS1,	0		/PHYSICAL Y POSITION 1 ON SCREEN LOGICAL/2
PYPOS2,	0		/PHYSICAL Y POSITION 2 ON SCREEN LOGICAL/2
LININD,	0		/USED TO INDICATE WHERABOUTS OF LINE
DEGRES,	0		/# OF DEGREES IN A CIRCLE OR ARC
REMAIN,	0		/USED IN CURVE FITTING
SEG,	0		/USED IN CURVE FITTING
DDCHAR,	0		/GRAPHIC DISPLAY CHARACTER
MODX,	0		/MODULAR X
MODY,	0		/MODULAR Y/2
/
SLPDXH,	0		/DOUBLE PRECISION WORD FOR DELTAX (HIGH WORD)
SLPDXL,	0		/LOW WORD
SLPDYH,	0		/DOUBLE PRECISION WORD FOR DELTAY (HIGH WORD)
SLPDYL,	0		/LOW WORD
SLPOFS,	0		/INDICATES TYPE OF LINE AND DIRECTION OF SLOPE
XDIF,	0		/INDICATES X TRAVERSING DIRECTION
YDIF,	0		/INDICATES Y TRAVERSING DIRECTION

/*/*/*	WARNING - THIS TABLE MUST REMAIN IN THIS ORDER */*/*/
/
MINX,	SRNLHX		/MINIMUM VALUE OF X CO-ORDINATE
MAXX,	SRNRHX		/MAXIMUM VALUE OF X CO-ORDINATE +1 (800.)
MINY,	SRNUVY		/MINIMUM VALUE OF Y CO-ORDINATE
MAXY,	SRNLVY		/MAXIMUM VALUE OF Y CO-ORDINATE +1 (480.)
/
/*/*/*/ WARNING - WARNING DO NOT MOVE ORDER OF FOLLOWING LOCATIONS */*/*/*/
/		WRITE OPTIONS GET SAVED AND RESTORED
/
TMPSIZ=	YREF+1-FCOLOR
SVRSTF,	0		/TEMP WRITE OPTION SAVE/RESTORE FLAG
FCOLOR,	17		/CURRENT FOREGROUND COLOR (0 - 17 OCTAL)
COLORM,	17		/COLOR PLANE MASK WORD    (0 TO 17 OCTAL)
LINTXT,	377		/LINE TEXTURE
PATMLT,	1		/LINE PATTERN MULTIPLIER
ARETXT,	0		/AREA TEXTURE
ACHRST,	0		/AREA TEXTURE ALPHABET
NEGFLG,	0		/NEGATIVE WRITING MODE FLAG
WRMODE,	0		/WRITING MODE (0=OVERLAY, 1=REPLACE, 2=COMPLEMENT,
			/  3=ERASE)
SHDFLG,	0		/SHADE FLAG 0=OFF 1=ON
YREFLN,	0		/Y REFERENCE LINE USED FOR SHADING
YREFLG,	0		/Y REFERENCE FLAG INDICATING LINES POSITION
YREF,	0		/Y REFERENCE CLIPPED CO-ORDINATE
/
/*/*/*	WARNING - DO NOT MOVE ORDER OF FOLLOWING LOCATIONS /*/*/*
/		TEXT OPTIONS GET SAVED AND RESTORED
/
QCHRST,	0		/ALPHABET SELECTED
QCELRT,	0		/CELL ROTATION
QCELHT,	0		/CELL HEIGHT
QCELWD,	0		/CELL WIDTH
QUNIHT,	0		/UNIT HEIGHT
QUNIWD,	0		/UNIT WIDTH
QCELIT,	0		/CELL ITALIC
QCELFG,	0		/BASELINE ANGLE VS ABSOLUTE ESCAPEMENT FLAG
QBASAN,	0		/BASELINE ANGLE
QXESC,	0		/X CHARACTER ESCAPEMENT
QYESC,	0		/Y CHARACTER ESCAPEMENT
QXLFES,	0		/X LINE FEED ESCAPEMENT
QYLFES,	0		/Y LINE FEED ESCAPEMENT
QDOTSH,	0		/NUMBER OF DOTS IN CHARACTER HEIGHT
QDOTSW,	0		/NUMBER OF DOTS IN CHARACTER WIDTH
QDTHTC,	0		/NUMBER OF DOTS IN CELL HEIGHT (THAT FIT)
QDTWDC,	0		/NUMBER OF DOTS IN CELL WIDTH (THAT FIT)
QTXTDC,	0		/1X CHARACTER DOT WIDTH
QTXTD,	0		/2X CHARACTER DOT HEIGHT
TXTSXP,	0		/X TEXT REFERENCE STARTING POSITION
TXTSYP,	0		/Y TEXT REFERENCE STARTING POSITION
BCOLOR,	0		/CURRENT BACKGROUND COLOR (0 - 17 OCTAL)
PRTBCL,	0		/BACKGROUND COLOR OF LAST SCREEN ERASE (SIXEL DUMPING)
CLSCRV,	0		/INITIALIZE CLOSE CURVE TO FALSE
INDEX,	0		/INITIALIZE INDEX/CURVE IN PROGRESS FLAG
CURFLG,	1		/CURSOR FLAG
TEMP,	0		/TEMPORARY VARIABLE FOR GENERAL USE

/ --------------------------------------------------------------------
/ OLDFLD - CHANGE DATA FIELD TO FIELD WHICH CALLED GRAPHICS PRIMITIVES
/ --------------------------------------------------------------------

OLDFLD,	0
	CDF	00		/THIS GETS MODIFIED
	JMP  I  OLDFLD		/RETURN
/
/
/ -------------------
/ ----- EQUATES -----
/ -------------------
/
	IFNDEF CONDOR <
AC0001=	7301
AC0002=	7305
AC0003=	7325
AC0004=	7307
AC0006=	7327
AC0010=	7315
AC0100=	7303
AC3777=	7350
AC4000=	7330
AC7775=	7346
AC7776=	7344
AC7777=	7340
			>	/END IFNDEF CONDOR
	IFDEF CONDOR	<
	AC1=	7301
	AC100=	7303
	AC4K=	7330
	ACNEG1=	7340
			>	/END IFDEF CONDOR
/
R3L=	7014
/
GRDR=	6150		/GRAPHICS OPTION DMA READ
GRDW=	6151		/GRAPHICS OPTION DMA WRITE
GRGR=	6154		/GRAPHICS OPTION GDC READ
GRGW=	6155		/GRAPHICS OPTION GDC WRITE
GRW1=	6156		/GRAPHICS OPTION WRITE REGISTER ONE
GRW2=	6157		/GRAPHICS OPTION WRITE REGISTER TWO
/
/ ----- END EQUATES -----

	*200		/EXECUTABLE CODE

/ ------------------------------------------------------------------------
/ PRIMS - BEGINNING OF THE GRAPHIC PRIMITIVE SUBROUTINES
/ ------------------------------------------------------------------------
/
/	TAD	(TABLE		/ADDRESS OF PARAMETER TABLE
/	CIF	PRGFLD		/CHANGE I.F. TO GRAPHICS PRIMITIVES
/	JMS  I  (PRIMS		/GO TO GRAPHIC PRIMITVE ROUTINE

PRIMS,	0
	DCA	PTABLE		/SAVE ADDRESS OF PARAMETER TABLE
	RDF			/READ THE CALLING FIELDS DATA FIELD
	TAD	KCDF		/CREATE A CDF INSTRUCTION TO IT
	DCA	OLDFLD+1	/SAVE THE CDF INSTRUCTION
	AC0002			/MAKE A CDF CIF INSTRUCTION TO CALLING FIELD
	TAD	OLDFLD+1	/
	DCA	CHGFLD		/SAVE CIF CDF INSTRUCTION BACK TO CALLING FIELD
	TAD	GRFX		/CHECK IF OPTION BOARD PRESENT
	SNA CLA
	JMP	CHGFLD		/IF NOT, IGNORE THIS REQUEST
	GETPRM			/GET THE OPERATION CODE FROM THE TABLE
	DCA	OPCODE		/SAVE THE OPERATION CODE
	CLA	CLL
	TAD	OPCODE		/GET THE OPERATION CODE
	TAD	LSTV0C		/CHECK IT AGAINST LAST VALID OPERATION CODE
	SZL	CLA		/SKIP IF VALID
	JMP	CHGFLD		/UNIMPLEMENTED OPERATION CODE - EXIT
	TAD	ADTBLE		/GET THE ADDRESS OF THE DESPATCH TABLE
	TAD	OPCODE		/ADD OFFSET INTO TABLE
	DCA	PRIMRT		/SAVE THE TABLE ADDRESS
	CDF	TBLFLD		/TABLE FIELD FOR ADDRESS
	TAD  I  PRIMRT		/GET THE ADDRESS TO DISPATCH TO
	CDF	PRGFLD		/BACK TO THIS FIELD
	DCA	PRIMRT		/SAVE THE DISPATCH ADDRESS
	JMS  I  CURSOR		/GO TURN CURSOR OFF IF SET
	JMS  I  PRIMRT		/GO TO GRAPHIC PRIMITIVE SUBROUTINE
	JMS  I  CURSOR		/TURN THE CURSOR ON IF ENABLED
CHGFLD,	CIF!CDF	00		/CHANGE INSTRUCTION AND DATA FIELD TO CALLING FIELD
	CLA	CLL		/EXIT WITH AC AND LINK CLEARED
	JMP  I  PRIMS		/RETURN TO CALLING FIELD

PRIMRT,	0			/ADDRESS OF GRAPHIC SUBROUTINE TO BE EXECUTED
KCDF,	CDF	00
ADTBLE,	DTABLE			/ADDRESS OF DISPATCH TABLE ADDRESSES
LSTV0C,	DTABLE-EDTBLE-1		/# OF LAST VALID OPCODE IN TABLE
CURSOR,	XCURSR			/ROUTINE TO TURN CURSOR ON OR OFF

/----------------------------------------------------------------------------
/ XGTPRM - GET A PARAMETER FROM THE CALLING FIELDS PARAMETER TABLE
/-----------------------------------------------------------------------------

XGTPRM,	0
	CLA	CLL
	JMS	OLDFLD		/CHANGE DATA FIELD TO CALLING FIELD
	TAD  I  PTABLE		/GET THE PARAMETER
	CDF	PRGFLD		/CHANGE DATA FIELD BACK TO THIS FIELD
	ISZ	PTABLE		/UPDATE POINTER TO NEXT PARAMETER
	JMP  I  XGTPRM		/RETURN WITH PARAMTER IN THE AC

/------------------------------------------------------------------------------
/ GTAREA - GET AREA PARAMETERS FROM CALLING FIELD + FILL AREA WITH SPECIFIED COLORL
/------------------------------------------------------------------------------
/
/GTAREA, 0
/	GETXY1			/GET THE "FROM" X AND Y CO-ORDINATES
/	GETXY2			/GET THE "TO"   X AND Y CO-ORDINATES
/	TAD	SHDFLG		/GET THE PRESENT SHADE FLAG
/	DCA	GETVEC		/SAVE IN TEMP
/	DCA	SHDFLG		/TURN SHADING OFF
/	FAREA			/GO FILL AREA WITH PREVIOUSLY DEFINED COLOR
/	TAD	GETVEC		/GET THE SHADE FLAG SAVED
/	DCA	SHDFLG		/RESTORE ORIGINAL VALUE
/	JMP  I  GTAREA		/RETURN

/------------------------------------------------------------------------------
/ POSTN2 - GET CO-ORDINATES X2 AND Y2 FROM THE CALLING FIELD
/------------------------------------------------------------------------------

POSTN2,	0
	GETPRM			/GET  THE "TO" X POSITION
	DCA	XPOS2		/SAVE THE "TO" X POSITION
	GETPRM			/GET  THE "TO" Y POSITION
	DCA	YPOS2		/SAVE THE "TO" Y POSITION
	JMP  I  POSTN2
/
/ -------------------------
/ DMYSUB - DUMMY SUBROUTINE
/ -------------------------
/
DMYSUB,	0
/
	JMP I	DMYSUB		/JUST RETURN

/ --------------------------------------------------------
/ MORCOD - DISPATCH TO ANOTHER FIELD FOR OPCODE PROCESSING
/ --------------------------------------------------------
/
MORCOD,	0
/
	CLA CLL
	TAD	OPCODE		/PASS OPCODE TO OTHER FIELD
	DCA	MORCD4
	TAD	OLDFLD+1	/PASS ORIGINAL CALLING FIELD
	DCA	MORCD5
	TAD	PTABLE		/PASS ADDRESS OF CONTROL BLOCK
	DCA	MORCD6
/
	CDF	PRGFLD		/ENSURE CURRENT DATA FIELD OK
	CIF	TBLFLD		/SET INSTRUCTION FIELD FOR MORE CODE
	JMS I	PTPRIM		/CALL OTHER FIELD FOR DISPATCH
MORCD4,	0			/  WITH OPCODE
MORCD5,	0			/  AND FIELD OF CONTROL BLOCK
MORCD6,	0			/  AND ADDRESS OF CONTROL BLOCK
/
	CLA CLL
	JMP I	MORCOD		/RETURN
/
/
PTPRIM,	ZENTRY			/** ENTRY POINT IN ANOTHER FIELD **

/------------------------------------------------------------------------------
/ GTFGRD - GET THE FOREGROUND COLOR AND SWITCH BIT 0 WITH BIT 2
/------------------------------------------------------------------------------
/
GTFGRD,	0
	JMS  I  GTCOLR		/GET FOREGROUND FROM CALLING FIELD
	FCOLOR
	JMP  I  GTFGRD		/EXIT BACK TO CALLING FIELD

/-------------------------------------------------------------------------------
/ GTBGRD - GET BACKGROUND COLOR AND SWITCH BIT 0 WITH BIT 2
/-------------------------------------------------------------------------------
/
GTBGRD,	0
	JMS  I  GTCOLR		/GET BACKGROUND COLOR FROM CALLING FIELD
	BCOLOR
	JMP  I  GTBGRD		/EXIT BACK TO CALLING FIELD

/-------------------------------------------------------------------------------
/ GTPLNS - GET COLOR PLANE MASK WORD AND SWITCH BIT 0 WITH BIT 2
/------------------------------------------------------------------------------
/
GTPLNS,	0
	JMS  I  GTCOLR		/GET PLANE SELECT MASK WORD
	COLORM
	JMP  I  GTPLNS		/EXIT BACK TO CALLING FIELD
/
GTCOLR,	GTCPLN			/ROUTINE TO GET COLOR PLANE AND SWITCH BITS
/

/ -----------------------------------------------------------------------------
/ POSTN1 - POSITION CURSOR - GET CO-ORDINATES X1 AND Y1 FROM CALLING FIELD
/ -----------------------------------------------------------------------------
/
POSTN1,	0
	GETPRM			/GET THE NEW X POSITION
	DCA	XPOS1		/SAVE THE NEW X POSITION
	GETPRM			/GET THE NEW Y POSITION
	DCA	YPOS1		/SAVE THE NEW Y POSITION
	JMP  I  POSTN1		/RETURN


/---------------------------------------------------------------------------------
/ SCRNER - SCREEN ERASE - FILL CLIPPING REGION WITH PREVIOUS SPECIFIED COLOR
/-------------------------------------------------------------------------------

SCRNER,	0
	TAD	BCOLOR		/GET THE PRESENT BACKGROUND COLOR
	DCA	PRTBCL		/SAVE FOR SIXEL DUMPING OF SCREEN
	TAD	WRMODE		/GET THE PRESENT WRITING MODE
	DCA	SAVWRM		/SAVE IT IN CASE NOT OVERLAY MODE
	DCA	WRMODE		/SET WRITING MODE TO OVERLAY
	DCA	SHDFLG		/TURN SHADING OFF IF IT WAS ENABLED
/
	SENDIT			/FLASH MODE - SCREEN DISABLED
	SCRNOF
/
	DRAWIT			/FILL ENTIRE VISIBLE SCREEN WITH COLOR
	SHOME
	SSCRNE
	TXTPT1
/
	SENDIT			/EXIT FLASH MODE SCREEN ENABLED
	SCRNON
/
	TAD	SAVWRM		/GET THE SAVED WRITING MODE
	DCA	WRMODE		/RESTORE IT
/
	JMP I  SCRNER		/EXIT
/
SAVWRM,	0			/SAVED WRITING MODE BEFORE ERASE SCREEN

/-----------------------------------------------------------------------------
/ TRVLIN - CHECK IF LINE TRUE VERTICAL LINE WITH SHADING ON + COMP MODE
/------------------------------------------------------------------------------
/
TRVLIN,	0
	TAD	XTEMP1		/GET THE ORIGINAL FROM "X" CO-ORDINATE
	CIA			/NEGATE IT
	TAD	XPOS1		/CKECK IT AGAINST POSSIBLE CLIPPED CO-ORDINATE
	SZA	CLA		/SKIP IF THE SAME
	JMP	NOTTVL		/EXIT CALL+1 - NOT TRUE VERTICAL LINE
	TAD	XTEMP2		/GET THE ORIGIANL TO "X" CO-ORDIANTE
	CIA			/NEGATE IT
	TAD	XPOS2		/CHECK IT AGAINST POSSIBLE CLIPPED CO-ORDINATE
	SNA	CLA		/EXIT CALL+1 - NOT TRUE VERTICAL LINE
	ISZ	TRVLIN		/EXIT CALL+2 - THIS LINE IS TRUELY VERTICAL
NOTTVL,	JMP  I  TRVLIN		/EXIT BACK TO CALLER
/
/
/ --------------------------
/ CHRPAT - CHARACTER PATTERN
/ --------------------------
/
CHRPAT,	ZBLOCK	0012		/TEN BYTES

	PAGE
/-------------------------------------------------------------------------------
/ GTSHDO - TURN SHADING OFF
/------------------------------------------------------------------------------
/
GTSHDO,	0
	DCA	SHDFLG		/CLEAR THE SHADE FLAG - ALL SHADING OFF
	DCA	ARETXT		/CLEAR AREA TEXTURE (SAFETY - NOT NEEDED)
	JMS  I  SUPDTP		/RESET THE LINE PATTERN FOR DRAWING
	JMP  I  GTSHDO		/RETURN BACK TO CALLER
/
SUPDTP,	UPDPAT

/-------------------------------------------------------------------------------
/ GETDRG - GET DISPLAY REGION PARAMETERS FROM THE CALLING FIELD
/-------------------------------------------------------------------------------

GETDRG,	0
	GETPRM			/GET THE LEFT HORIZONTAL X
	DCA	MINX		/SAVE IT
	GETPRM			/GET THE UPPER VERTICAL Y
	DCA	MINY		/SAVE IT
	GETPRM			/GET THE RIGHT HORIZONTAL X
	DCA	MAXX		/SAVE IT
	GETPRM			/GET THE LOWER RIGHT VERTICAL Y
	DCA	MAXY		/SAVE IT
/
	MINMAX			/CHECK IF LEFT X DEFINED ON PHYSICAL SCREEN
	MINX			/ADDRESS OF DATA TO BE CHECKED
	DRFLG1			/ADDRESS OF FLAG TO BE RETURNED
	DRLX			/ADDRESS OF PHYSICAL SCREEN LEFT X
	DRRX			/ADDRESS OF PHYSICAL SCREEN RIGHT X
	MINMAX			/CHECK IF RIGHT X DEFINED ON PHYSICAL SCREEN
	MAXX			/ADDRESS OF DATA TO BE CHECKED
	DRFLG2			/ADDRESS OF FLAG TO BE RETURNED
	DRLX			/ADDRESS OF PHYSICAL SCREEN LEFT X
	DRRX			/ADDRESS OF PHYSICAL SCREEN RIGHT X
	MINMAX			/CHECK IF UPPER Y DEFINED ON PHYSICAL SCREEN
	MINY			/ADDRESS OF DATA TO BE COMPARED
	DRFLG3			/ADDRESS OF DATA TO BE COMPARED
	DRUY			/ADDRESS OF PHYSICAL SCREEN UPPER Y
	DRLY			/ADDRESS OF PHYSICAL SCREEN LOWER Y
	MINMAX			/CHECK IF LOWER Y DEFINED ON PHYSICAL SCREEN
	MAXY			/ADDRESS OF DATA TO BE COMPARED
	DRFLG4			/ADDRESS OF FLAG TO BE RETURNED
	DRUY			/ADDRESS OF PHYSICAL SCREEN UPPER LEFT
	DRLY			/ADDRESS OF PHYSICAL SCREEN LOWER RIGHT
	TAD	DRFLG1		/CHECK IF ALL CO-ORDINATES SPECIFED ON SCREEN
	TAD	DRFLG2		/
	TAD	DRFLG3		/
	TAD	DRFLG4		/
	SZA	CLA		/SKIP IF ALL CO-ORDINATES ON SCREEN
	JMP	DRDFLT		/SPECIFIED CO-ORDINATE(S) NOT ON SCREEN
	TAD	MAXX		/CHECK IF MAXIMUM X > MINIMUM X SPECIFIED
	CIA
	TAD	MINX
	SMA	CLA		/SKIP IF MAX X > MIN X
	JMP	DRDFLT		/MIN X >= MAX X
	TAD	MAXY		/CHECK IF MAXIMUM Y > MINIMUM Y SPECIFIED
	CIA
	TAD	MINY
	SMA	CLA		/SKIP IF MAX Y > MIN Y
	JMP	DRDFLT		/MIN Y >= MAX Y
	ISZ	MAXX		/UPDATE X MAX TO PHYSICAL SCREEN +1
	ISZ	MAXY		/UPDATE Y MAX TO PHYSICAL SCREEN +1
	JMP	DRCURP		/GO INITIALIZE CURRENT POSITION TO LEFT TOP
/
DRDFLT,	JMS	DFLTRG		/GO SETUP DEFAULT DISPLAY REGION
/
DRCURP,	JMS	HOMEPS
	JMP  I  GETDRG		/EXIT - SCREEN REGION SETUP
/
DRFLG1,	0
DRFLG2,	0
DRFLG3,	0
DRFLG4,	0
/
/	/*/*/* WARNING THIS TABLE MUST REMAIN IN THIS ORDER */*/*/
/
DRLX,	SRNLHX			/PHYSICAL SCREEN LEFT X CO-ORDINATE
DRRX,	SRNRHX			/PHYSICAL SCREEN RIGHT X CO-ORDINATE+1
DRUY,	SRNUVY			/PHYSICAL SCREEN UPPER Y CO-ORDINATE
DRLY,	SRNLVY			/PHYSICAL SCREEN LOWER Y CO-ORDINATE+1
/
/ -----------------------------------------
/ DFLTRG - COPY DEFAULT SCREEN REGION
/ -----------------------------------------
/
DFLTRG,	0
	TAD	M0004		/NUMBER OF WORDS TO BE MOVED
	JMS  I  DCOPY		/COPY DEFAULT SCREEN REGION TO WORKING REGION
	DRLX-1			/ADDRESS -1 OF DATA TO BE MOVED
	MINX-1			/ADDRESS -1 OF WHERE DATA IS TO BE STORED
	JMP  I  DFLTRG		/EXIT
/
DCOPY,	COPDAT			/MOVE DATA FROM A TO B
/
/ --------------------------------------------
/ HOMEPS - HOME CURSOR TO UPPER LEFT OF SCREEN
/ --------------------------------------------
/
HOMEPS,	0
	TAD	MINX		/REPOSITION CURSOR TO UPPER LEFT
	DCA	XPOS1		/
	TAD	MINY		/
	DCA	YPOS1
	JMP  I  HOMEPS		/EXIT

/-------------------------------------------------------------------------------
/ INIT - INITIALIZE THE GRAPHIC MODULE AND GRAPHIC ROUTINES
/-------------------------------------------------------------------------------

INIT,	0
	TAD	SZINIT		/GET THE SIZE OF MEMORY TO BE INITIALIZED
	DCA	AUTO11		/SAVE THE COUNTER
	TAD	INITBG		/GET STARTING ADDRESS-1 OF INIT AREA
	DCA	AUTO10		/SAVE ADDRESS-1
INITLP,	DCA  I  AUTO10		/CLEAR THE WORD
	ISZ	AUTO11		/DONE ?
	JMP	INITLP		/NO - CLEAR NEXT WORD
	JMS	DFLTRG		/SETUP DEFAULT SCREEN REGIONS
	ERASE			/ERASE THE ENTIRE PHYSICAL SCREEN TO BLACK
	JMS	HOMEPS		/HOME THE CURSOR POSITION TO UPPER LEFT
	TAD	K0017		/INITIALIZE FOREGROUND COLOR TO WHITE
	DCA	FCOLOR		/
	TAD	K0017		/INITIALIZE COLOR MASK TO WRITE ALL PLANES
	DCA	COLORM		/
	TAD	K0377		/INITIALIZE LINE TEXTURE
	DCA	LINTXT		/
	CLA CLL IAC		/INITIALIZE LINE PATTERN MULTIPLIER
	DCA	PATMLT		/
	JMS  I  INITPT		/INITIALIZE LINE PATTERN WORDS
/
	CIF CDF	TBLFLD		/OTHER FIELD FOR INITIALIZATION
	JMS I	XZINIT
/
	AC1			/CLEAR ALPHABET ONE
	JMS I	CSTCLR
	AC0002			/CLEAR ALPHABET TWO
	JMS I	CSTCLR
	AC0003			/CLEAR ALPHABET THREE
	JMS I	CSTCLR
/
	JMP  I  INIT		/RETURN BACK TO CALLER
/
SZINIT,	INITSZ			/SIZE OF AREA TO BE ZEROED
INITBG,	BEGIN-1			/STARTING ADDRESS-1 OF AREA TO BE CLEARED
INITPT,	UPDPAT			/ROUTINE TO LOAD LINE PRAM'S WITH LINE TEXTURE
CSTCLR,	CLRCST			/ROUTINE TO LOAD CHAR SET WITH ERROR CHAR'S
XZINIT,	ZINIT			/ROUTINE TO INITIALIZE TABFLD CODE

/-----------------------------------------------------------------------------
/ XY1CHK - CHECK POSITION IF XPOS1 AND YPOS1 - RETURN WITH FLAGS IN AC
/-------------------------------------------------------------------------------
/
XY1CHK,	0
/
	MINMAX			/CHECK IF STARTING X POSITION ON THE SCREEN
	XPOS1
	XFLAG1
	MINX
	MAXX
/
	MINMAX			/CHECK IF STARTING Y POSITION ON THE SCREEN
	YPOS1
	YFLAG1
	MINY
	MAXY
/
	TAD	XFLAG1		/CHECK IF STARTING POSITION ON SCREEN
	TAD	YFLAG1		/
	JMP  I  XY1CHK		/EXIT WITH STARTING POSITION FLAGS IN AC

	PAGE
/-----------------------------------------------------------------------------
/ GETTXT - GET GRAPHIC TEXT CHAR AND POSITION - CHECK IF DISPLAYABLE
/-----------------------------------------------------------------------------

GETTXT,	0
/
	GETPRM			/GET THE CHAR FROM CALLING FIELD
	DCA	DDCHAR		/SAVE IT FOR DISPLAYING
	JMS  I  ACKCHR		/CHECK IF CHAR WITHIN ALPHABET EXTENT
	SNA	CLA		/SKIP IF NON-PRINTING CHAR
	JMP	FITTXT		/GO DRAW THE PRINTING CHARACTER
	TAD	LEGCHR		/GET ADDRESS -1 OF LEGAL CONTROL CHARS
	DCA	AUTO10		/SAVE THE ADDRESS-1
TXTLUP,	TAD  I  AUTO10		/CHECK IF TERMINATOR OF TABLE
	SNA			/SKIP IF NOT TERMINATOR
	JMP	TXTERR		/CHAR NOT FOUND IN TABLE - SETUP ERROR CHAR
	TAD	DDCHAR		/ADD CHARACTER TO NEGATED TABLE CHARACTER
	SZA			/SKIP IF COMPARISON
	ISZ	AUTO10		/OTHERWISE UPDATE LOOKUP ADDRESS BY 1
	SZA	CLA		/SKIP IF VALID COMPARE
	JMP	TXTLUP		/INVALID COMPARE - CHECK CHAR AGAINST NEXT
	TAD  I  AUTO10		/GET THE CHAR FUNCTION DISPATCH ADDRESS
	DCA	GTCRA		/SAVE THE DISPATCH ADDRESS
	JMS  I  GTCRA		/GO DO THE CHAR FUNCTION IMPLIED
	JMP	NOTEXT		/EXIT - CHAR WAS CR, LF, BS, HT
TXTERR,	TAD	K0177		/GET THE ERROR CHARACTER
	DCA	DDCHAR		/SAVE IT FOR DISPLAY
/
FITTXT,	CDF	TBLFLD		/CHANGE FIELD FOR DATA
	TAD	XPOS1		/GET CURRENT POSITION
	TAD I	XDELX		/ADD WIDTH-1 OF CHAR
	DCA	XPOS2		/SAVE FOR 'WILL'IT FIT' TEST
	TAD	YPOS1		/GET CURRENT POSITION
	TAD I	XDELY		/ADD HEIGHT-2 OF CHAR
	DCA	YPOS2		/SAVE FOR 'WILL IT FIT' TEST
	CDF	PRGFLD		/BACK TO THIS FIELD
/
	JMS I	XXCHKC		/CHECK IF CHARACTER FITS ENTIRELY ON SCREEN
	JMP	GETTX6		/YES, CONTINUE WITH THE CHARACTER
	JMP	GETTX8		/NO, JUST MOVE A SPACE
	JMP	GETTX8		/NO, JUST MOVE A SPACE
/
GETTX6,	CIF	TBLFLD		/AUXILIARY FIELD FOR ROUTINE
	JMS I	XXSAVM		/SAVE WRITING, NEGATE, SHADE MODES
	DCA	SHDFLG		/TURN SHADING OFF
/
	JMS I	XSPDTX		/DRAW CHARACTER CELL IF OK TO DO SO
/
	JMS  I  XDTEXT		/GO DRAW THE GRAPHIC CHARACTER
	JMS I	XCURRS		/RESTORE ORIGINAL CURSOR POSITION
	CIF	TBLFLD		/AUXILIARY FIELD FOR ROUTINE
	JMS I	XXRESM		/RESTORE WRITING, NEGATE, SHADE MODES
/
GETTX8,	JMS I	XFSPAC		/POSITION CURSOR ONE SPACE FORWARD
/
NOTEXT,	JMP  I  GETTXT		/RETURN BACK TO CALLER
/
XDTEXT,	DTEXT
XCURRS,	CURRST
XFSPAC,	FSPACE
LEGCHR,	CHRLEG-1
ACKCHR,	CHKCHR
XSPDTX,	SPDTXT
GTCRA,	0
XDELX,	DELX
XDELY,	DELY
XXCHKC,	CHKCLP
XXSAVM,	SAVMOD
XXRESM,	RESMOD

/-------------------------------------------------------------------------------
/ SETUP - HANDLE SETUP PARAMETERS
/-------------------------------------------------------------------------------
/
/ THE ARGUMENT BITS INDICATE STATES:
/	AC<11>	1=CURSOR ENABLED, 0=CURSOR DISABLED
/	AC<10>	1=GRAPHICS ON MONOCHROME MONITOR, 0=NO
/	AC<09>	1=TEXT ON COLOR MONITOR, 0=NO TEXT ON COLOR MONITOR
/	AC<08>	1=DISABLE GRAPHICS, 0=ENABLE GRAPHICS
/	AC<07>	1=DISABLE TEXT, 0=ENABLE TEXT
/	AC<06>	1=RESYNCH VIDEOS, 0=DON'T BOTHER
/
SETUP,	0
	GETPRM			/GET SETUP PARAMETER FROM CALLING FIELD
	DCA	SETUPW		/SAVE ARGUMENT
/
	AC1			/CHECK IF GRAPHICS CURSOR ENABLED
	AND	SETUPW
	SNA CLA			/CHECK IF CURSOR ENABLED
	AC1			/IF SO, MAKE A ONE, ELSE MAKE A ZERO
	DCA	CURFLG		/SAVE IN CURSOR FLAG
/
	TAD	GOBTYP		/CHECK TYPE OF GRAPHICS BOARD TO HANDLE
	SNA CLA			/  MONITOR CONFIGURATION
	JMP	SETUP1		/GO HANDLE OLD BOARD
/
	CIF	TBLFLD		/NEW BOARD, CALL ROUTINE IN OTHER FIELD
	JMS I	XDM3ST		/  TO HANDLE MONITOR CONFIGURATION
/
	JMP	SETU1D		/GO CONTINUE WITH SETUP
/
				/OLD GRAPHICS BOARD
SETUP1,	AC0002			/CHECK IF GRAPHICS ON MONOCHROME MONITOR
	AND	SETUPW
	SZA CLA
	TAD	K1000S		/YES, SET UP FOR REG11 = 5000
	TAD	K4000		/  OR IF NOT, REG11 = 4000
	DCA	REG1HI		/SAVE FOR LATER USE
/
	AC0004			/CHECK IF TEXT ON COLOR MONITOR
	AND	SETUPW
	SZA CLA
	TAD	K4210		/IF SO, READY TO MAKE A 7777
	TAD	K3567		/  OR IF NOT, MAKE A 3567
	DCA	SETUP6		/SAVE INLINE FOR LATER EXECUTION
	LDREG2			/WRITE TO REGISTER TWO TO HANDLE TEXT DEST
SETUP6,	0			/REG 2 VALUE (MODIFIED IN CODE)
/
SETU1D,	AC0010			/CHECK IF GRAPHICS DISABLED
	AND	SETUPW
	SZA CLA
	JMP	SETUP2		/YES, GO DISABLE GRAPHICS
	SENDIT			/NO, ENABLE GRAPHICS
	SCRNON
	JMP	SETUP4
SETUP2,	SENDIT
	SCRNOF
/
SETUP4,	TAD	KKK20		/CHECK IF TEXT DISABLED
	AND	SETUPW
	SZA CLA
	AC1			/YES, READY TO DISABLE TEXT
	PR3			/  OR ENABLE TEXT VIA THIS PRQ
	0001			/  TO TELL SLUSHWARE ABOUT
	7777			/  VIDEO VISIBILITY
/
	LDREG1			/WRITE TO REGISTER ONE
	71			/  TO HANDLE GRAPHICS DESTINATION
/
/
	TAD	KKK40		/CHECK IF RESYNCHRONIZATION REQUIRED
	AND	SETUPW
	SNA CLA
	JMP	SETUP8		/IF NOT, JUST GO RETURN
	JMS I	XSYNCH		/IF SO, GO DO IT
/
SETUP8,	JMP I  SETUP		/EXIT - CURSOR,GRAPHIC AND TEXT SCREEN SELECTED
/
/
SETUPW,	0
K4000,	4000
K1000S,	1000
K3567,	3567
K4210,	4210
KKK20,	0020
KKK40,	0040
XSYNCH,	SYNCH
XDM3ST,	DM3SET

	PAGE
/------------------------------------------------------------------------------
/ UPDPAT - COPY OR REPLICATE BYTE TO TWO WORDS DEPENDENT ON MULTIPLIER
/-------------------------------------------------------------------------------
/
UPDPAT,	0
	TAD	LPATAD		/GET ADDRESS OF GDC LINE PATTERN
	DCA	UPDTMP		/SAVE THE ADDRESS AS WORKING ADDRESS
	CLA CLL CMA		/CHECK PATTERN MULTIPLIER
	TAD	PATMLT		/
	SZA	CLA		/WAS IT A ONE ?
	JMP	PATDBL		/NO - GO REPLICATE THE PATTERN TO TWO WORDS
	TAD	LINTXT		/GET THE LINE TEXTURE
	DCA  I  UPDTMP		/SAVE THE FIRST BYTE
	ISZ	UPDTMP		/UPDATE POINTER TO 2ND BYTE
	TAD	LINTXT		/GET THE BASE LINE TEXTURE
	DCA  I  UPDTMP		/SAVE THE SECOND BYE AS SAME AS FIRST
	JMP  I  UPDPAT		/RETURN BACK TO CALLER
/
PATDBL,	CLA CLL CMA RAL		/-2
	DCA	UPDCN1		/TWO WORD BYTE COUNTER
	TAD	LINTXT		/GET THE BASE LINE TEXTURE
	DCA	LINTMP		/SAVE AS WORKING LINE PATTERN
UPDLP1,	TAD	M0004		/SETUP 4 BIT TO 8 BIT COUNT
	DCA	UPDCN2		/SAVE COUNTER
UPDLP2,	DCA  I  UPDTMP		/SAVE NEW 8 BIT PATTERN
	TAD	LINTMP		/GET THE WORKING PATTERN
	CLL	RAR		/BUT LEAST SIGNIFICANT BIT INTO LINK
	DCA	LINTMP		/SAVE THE NEW WORKING PATTERN
	TAD  I  UPDTMP		/GET THE NEW 8 BIT PATTERN
	RAR			/MOVE LINK INTO SIGN BIT
	SPA			/CHECK IF SIGN BIT SET
	CML			/YES REPLICATE A 1 INTO SIGN BIT
	RAR			/INITIAL PATTERN NOW REPLICATED
	ISZ	UPDCN2		/DONE ALL 4 BITS
	JMP	UPDLP2		/NO - DO NEXT BIT
	CLL	RTR		/MOVE PATTERN INTO LEAST SIGNIFICANT 8
	CLL	RTR		/
	DCA  I  UPDTMP		/SAVE THIS AS NEW PATTERN WORD
	ISZ	UPDTMP		/UPDATE ADDRESS TO NEXT PATTERN WORD
	ISZ	UPDCN1		/DONE BOTH WORDS ?
	JMP	UPDLP1		/NO - GO DO SECOND WORD OF PATTERN
	JMP  I  UPDPAT		/EXIT BACK TO CALLER
/
LPATAD,	LINPAT+1		/ADDRESS OF GDC LINE PATTERN
UPDTMP,	0			/POINTER TO GDC 2 WORD LINE PATTERN
UPDCN1,	0			/USED TO COUNT THE TWO WORDS
UPDCN2,	0			/USED TO COUNT THE? BIT TO 8 BIT REPLICATION
LINTMP,	0			/WORKING LINE PATTERN
/

/------------------------------------------------------------------------------
/ TEXT CARRIAGE RETURN ROUTINE
/-------------------------------------------------------------------------------
/
CARGRT,	0
	TAD	TXTSXP		/GET STARTING X POSITION OF PRESENT LINE
	DCA	XPOS1		/SAVE AS CURRENT X
	TAD	TXTSYP		/GET STARTING Y POSITION OF PRESENT LINE
	DCA	YPOS1		/SAVE AS CURRENT Y
	JMP  I  CARGRT		/EXIT - CARRAIGE RETURN FUNCTION PERFORMED

/------------------------------------------------------------------------------
/ TEXT BACKSPACE ROUTINE
/------------------------------------------------------------------------------
/
BACKSP,	0
	TAD	QXESC		/GET THE X ESCAPEMENT
	CIA			/NEGATE IT
	JMS	UPDATX		/GO UPDATE THE CURRENT X POSITION
	TAD	QYESC		/GET THE Y ESCAPEMENT
	CIA			/NEGATE IT
	JMS	UPDATY		/GO UPDATE THE CURRENT Y POSITION
	JMP  I  BACKSP		/EXIT - BACKSPACE FUNCTION PERFORMED

/-----------------------------------------------------------------------------
/ TEXT LINEFEED ROUTINE
/-----------------------------------------------------------------------------
/
LNFEED,	0
	TAD	QXLFES		/GET THE X LF ESCAPEMENT
	JMS	UPDATX		/UPDATE CURRENT X POSITION
	TAD	QYLFES		/GET THE Y LF ESCAPEMENT
	JMS	UPDATY		/UPDATE CURRENT Y POSITION
	TAD	QXLFES		/GET THE X LF ESCAPEMENT
	SGNCHK			/GO ADD/SUB IT FROM STARTING X POSITION
	TXTSXP			/ADDRESS OF SECOND WORD TO ADD
	DCA	TXTSXP		/SACE THE UPDATED X TEXT STARTING POSITION
	TAD	QYLFES		/GET THE Y LF ESCAPEMENT
	SGNCHK			/GO ADD/SUB IT FROM STARTING Y POSITION
	TXTSYP			/ADDRESS OF SECOND WORD TO ADD
	DCA	TXTSYP		/SAVE THE UPDATED Y TEXT STARTING POSITION
	JMP  I  LNFEED		/EXIT

/ -----------------------------------------
/ UPDATX - UPDATE X POSITION BY VALUE IN AC
/ -----------------------------------------
/
UPDATX,	0
	SGNCHK			/GO ADD/SUB IT FROM THE CURRENT X POSITION
	XPOS1			/ADDRESS OF SECOND WORD TO ADD
	DCA	XPOS1		/SAVE THE RESULT AS NEW X POSITION
	JMP  I  UPDATX
/
/ -----------------------------------------
/ UPDATY - UPDATE Y POSITION BY VALUE IN AC
/ -----------------------------------------
UPDATY,	0
	SGNCHK			/GO ADD/SUB IT FROM THE CURRENT Y POSITION
	YPOS1			/ADDRESS OF SECOND WORD TO ADD
	DCA	YPOS1		/SAVE THE RESULT AS NEW Y POSITION
	JMP  I  UPDATY
/
/ ---------------------------------------
/LOOKUP TABLE FOR SPECIAL TEXT CHARACTERS
/ ---------------------------------------
/
CHRLEG,	-15			/NEGATED CARRAIGE RETURN
	CARGRT			/CARRAIGE ROUTINE ADDRESS
	-12			/NEGATED LINEFEED
	LNFEED			/LINEFEED ROUTINE ADDRESS
	-10			/NEGATED BACKSPACE
	BACKSP			/BACKSPACE ROUTINE ADDRESS
	-11			/NEGATED HORIZONTAL TAB
	FSPACE			/FORWARD SPACE (NON-PRINTING)
	0			/TERMINATOR


/ -----------------------------------
/ FSPACE - NON-PRINTING FORWARD SPACE
/ -----------------------------------
/
FSPACE,	0
/
	TAD	QXESC		/GET THE X ESCAPEMENT BETWEEN CHARACTERS
	JMS 	UPDATX		/GO UPDATE CURRENT X POSITION
	TAD	QYESC		/GET THE Y ESCAPEMENT BETWEEN CHARACTERS
	JMS	UPDATY		/GO UPDATE CURRENT Y POSITION
/
	JMP I	FSPACE		/RETURN

/ ----------------------------------------
/ STCHAR - START CHARACTER PRECOMPUTATIONS
/ ----------------------------------------
/
STCHAR,	0
/
	CLA CLL
	TAD	QCHRST		/GET ADDRESS OF CHARACTER IN PANEL RAM
	JMS I	XGETAD
	DCA	STCHA2		/SAVE FOR BLOCK MOVE TO USER MEMORY
/
	PR3			/BLOCK MOVE PANEL-TO-USER
	5000+PRGFLD+PBMFLD
STCHA2,	0			/BECOMES ADDRESS IN PANEL MEMORY
	CHRPAT
	-0012
	7777
/
	JMS I	XSAVCU		/SAVE CURRENT POSITION
/
	TAD	M0010		/CHECK IF HEIGHT SO SMALL THAT HALF-HEIGHT
	TAD	QDOTSH		/  CHARACTERS ARE NEEDED
	SMA CLA
	JMP	STCHA4		/NO, GO CHECK WIDTH
	CIF CDF	TBLFLD		/YES, GO TO OTHER FIELD
	JMS I	XBYTCM		/  TO COMBINE BYTES
/
STCHA4,	TAD	M0010		/CHECK IF WIDTH SO SMALL THAT HALF-WIDTH
	TAD	QDOTSW		/  CHARACTERS ARE NEEDED
	SMA CLA
	JMP	STCHA6		/NO, GO RETURN
	CIF CDF	TBLFLD		/YES, GO TO OTHER FIELD
	JMS I	XBITCM		/  TO COMBINE BITS
/
STCHA6,	JMP I	STCHAR		/RETURN
/
/
XGETAD,	GETADR
XSAVCU,	SAVCUR
XBYTCM,	BYTCMB
XBITCM,	BITCMB
/
/
/----------------------------------------------------------------------------
/ GET VECTOR PARAMETERS FROM CALLING FIELD AND DRAW THE VECTOR
/------------------------------------------------------------------------------

GETVEC,	0
	GETXY2			/GET THE "TO" X AND Y CO-ORDINATES
	DRWVEC			/DRAW THE VECTOR
	JMP  I  GETVEC		/EXIT

	PAGE
/ ---------------------------
/ DTEXT - DISPLAY A CHARACTER
/ ---------------------------
/
DTEXT,	0
/
	JMS I	XSTCHA		/DO SOME PRE-COMPUTATION FOR THIS CHARACTER
/
	TAD	QDTHTC		/GET NUMBER OF DOTS HIGH
	CIA			/COMPLEMENT FOR LOOP CONTROL
	DCA	QDTHCT		/SAVE FOR LOOP COUNTER
/
	TAD	PCHRPT		/SET UP POINTER TO CHARACTER DATA
	DCA	DTEXTM
/
				/PREBUILD PART OF FIGS FOR THIS CHARACTER
	TAD	K0020		/BUILD P1, AREA FILL
	TAD	QCELRT		/  AND CELL ROTATION
	DCA I	PSTXT1		/  PUT INTO FIGS STRING
/
DTEXT3,	TAD	XPOS1		/SAVE START OF THIS ROW OF DOTS
	DCA	XPOS2
	TAD	YPOS1
	DCA	YPOS2
/
	JMS I	XSTROW		/BUILD PART OF FIGS STRING FOR THIS ROW
/
	TAD	QDTWDC		/GET NUMBER OF DOTS WIDE
	CIA			/NEGATE FOR LOOP CONTROL
	DCA	DTXTM4		/SAVE FOR CONTROL
				/  OF CUMULATIVE DOTS WRITTEN ON A LINE
/
	TAD I	DTEXTM		/DETERMINE SENSE OF FIRST 'DOT
	CLL RAR			/  BY ROTATING INTO LINK
	DCA I	DTEXTM		/  SAVE ROTATED PATTERN
	RAR			/  AND MOVE BIT INTO SIGN
	DCA	DTXTM5		/  SAVE SENSE OF 'PREVIOUS SENSE FLAG'

DTEXT5,	BLDPOS			/CREATE CURSOR POSITION STRING FOR THESE DOTS
	SPOSIT
/
	TAD I	DTEXTM		/CHECK IF ONLY ZERO DOTS LEFT
	TAD	DTXTM5		/  AND THAT'S WHAT WE'RE COLLECTING
	SNA CLA
	JMP	DTXT10		/YES, GO DRAW TO CELL APRON
/
	DCA	DTXTM3		/ASSUME NO DOTS-IN-A-ROW YET
/
DTXT5D,	CDF	TBLFLD		/SET UP TO GET DATA FROM TABLE FIELD
	TAD I	QKXW		/GET X MOTION PER COLUMN
	TAD	XPOS1		/  AND ADD IT TO X POSITION
	DCA	XPOS1
	TAD I	QKYW		/GET Y MOTION PER COLUMN
	TAD	YPOS1		/  AND ADD IT TO Y
	DCA	YPOS1
	CDF	PRGFLD		/BACK TO THIS FIELD
/
	ISZ	DTXTM3		/INCREMENT COUNT OF DOTS
/
	TAD I	DTEXTM		/GET A DOT TO CHECK
	CLL RAR			/  INTO LINK
	DCA I	DTEXTM		/SAVE ROTATED PATTERN
	RAR			/ROTATE DOT INTO SIGN BIT
	TAD	DTXTM5		/COMPARE WITH PREVIOUS SENSE
	SPA CLA			/TWO +'S OR TWO -'S YIELD + RESULT HERE
	JMP	DTXT5E		/DOTS DON'T MATCH, GO DRAW WHAT WE HAVE
/
	TAD	DTXTM3		/CHECK IF CURRENT DOT COUNT
	TAD	DTXTM4		/  AND THE DOTS ALREADY DRAWN
	SPA CLA			/  ARE ALL THE DOTS THERE ARE
	JMP	DTXT5D		/IF NOT DONE, GO BACK TO DO SOME MORE
				/HAVE ACCUMULATED LIKE DOTS
DTXT5E,	TAD	DTXTM5		/CHECK SENSE OF 'DOTS' TO BE DRAWN
	SPA CLA			/  (SIGN BIT ON -> DOTS ON)
	TAD	PTXPT1		/POINT TO PRAM FOR ON BIT
	TAD	PTXPT0		/POINT TO PRAM STRING FOR OFF BIT
	DCA	DTEXT7		/SAVE POINTER FOR 'DRAW' CALL
/
	TAD	DTXTM5		/CHECK SENSE OF 'DOTS' TO BE DRAWN
	SPA CLA			/  TO SEE IF WE CAN SKIP DRAWING
	JMP	DTXT5B		/BIT ON
	TAD I	XSKIP0		/BIT OFF, CHECK THE ZERO BIT SKIP FLAG
	SKP			/GO TEST THE SKIP FALG
DTXT5B,	TAD I	XSKIP1		/BIT ON, CHECK THE ONE BIT SKIP FLAG
	SZA CLA			/CHECK THE APPROPRIATE SKIP FLAG
	JMP	DTXT7B		/NO NEED TO DRAW THIS DOT
/
				/THIS DOT WILL SHOW, MUST DRAW IT
	TAD	PSTXDC		/COMPLETE THE FIGS STRING FOR THIS DOT
	DCA	AUTO10		/POINT TO THE TEXT FIGS STRING
/
	TAD	DTXTM3		/GET NUMBER OF DOTS ACROSS
	CIA			/  FOR CONTROL OF ADD COUNTER (MULTIPLY)
	DCA	TEMP
/
DTXT5F,	TAD	QTXTDC		/ADD WIDTH OF DOT
	ISZ	TEMP		/LOOP ON ADD UNTIL PRODUCT GENERATED
	JMP	DTXT5F
	TAD	M0001		/(-1 FOR GDC DC PARAMETER)
	JMS I	XXSAVD		/SAVE PRODUCT AS FIGS DC PARAMETER
/
	DRAWIT			/DRAW SOMETHING
	SPOSIT			/  AT THIS POSITION
PSTEXT,	STEXT			/  WITH FIGS/GCHRD FOR AREA FILL
DTEXT7,	0			/  WITH THESE PARAMETERS (MODIFIED IN CODE)
/
DTXT7B,	AC4K			/INVERT SENSE OF DOT TO MATCH
	TAD	DTXTM5		/  BY INVERTING SIGN BIT
	DCA	DTXTM5
/
	TAD	DTXTM3		/KEEP TRACK OF ALL DOTS WRITTEN
	TAD	DTXTM4
	DCA	DTXTM4
/
	TAD	DTXTM4		/CHECK IF DONE ALL DOTS IN THIS ROW
	SPA CLA
	JMP	DTEXT5		/NOT YET, GO DO SOME MORE
/
DTXT10,	JMS I	XTXTAP		/GO DRAW TO END OF ROW IN CELL
/
	CDF	TBLFLD		/SET UP TO GET DATA FROM TABLE FIELD
	TAD I	QKXH		/GET X MOTION PER ROW
	TAD	XPOS2		/  AND ADD IT TO X POSITION OF LAST ROW START
	DCA	XPOS1
	TAD I	QKYH		/GET Y MOTION PER ROW
	TAD	YPOS2		/  AND ADD IT TO Y
	DCA	YPOS1
	CDF	PRGFLD		/BACK TO THIS FIELD
/
	ISZ	DTEXTM		/INCREMENT POINTER TO CHARACTER BYTES
/
	ISZ	QDTHCT		/INCREMENT THROUGH ROW DOTS
	JMP	DTEXT3		/  UNTIL ALL COLUMNS DONE
/
	JMP I	DTEXT		/RETURN
/
/
K0020,	0020
DTEXTM,	0
DTXTM3,	0
DTXTM4,	0
DTXTM5,	0
QDTHCT,	0
XXSAVD,	SAVEDX
XSTCHA,	STCHAR
XTXTAP,	TXTAPR
PSTXDC,	STEXT+1
PTXPT0,	TXTPT0
PTXPT1,	TXTPT1-TXTPT0
PCHRPT,	CHRPAT
QKXW,	ZXKI
QKXH,	ZXKJ
QKYW,	ZYKI
QKYH,	ZYKJ
XSKIP0,	SKIP0
XSKIP1,	SKIP1
PSTXT1,	STEXT+1
XSTROW,	STROW

	PAGE
/-------------------------------------------------------------------------------
/ GTSHDY - ENABLE SHADING TO Y - SET Y REFERENCE LINE
/------------------------------------------------------------------------------
/
GTSHDY,	0
	CLA CLL IAC		/GET INDICATOR FOR SHADE TO Y
	DCA	SHDFLG		/SAVE INDICATOR
	GETPRM			/GET THE Y REFERENCE LINE FROM CALLER
	DCA	YREFLN		/SAVE IT
	MINMAX			/GO CHECK WHERABOUTS OF LINE ON SCREEN
	YREFLN			/ADDRESS OF LINE TO CHECK
	YREFLG			/ADDRESS OF FLAG
	MINY			/ADDRESS OF MINIMUM ALLOWED
	MAXY			/ADDRESS OF MAX+1 ALLOWED
	TAD	YREFLG		/GET THE Y REFERENCE FLAG
	SNA			/SKIP IF Y REFERENCE ON THE SCREEN
	JMP	SHDY2		/GO SETUP WORKING Y REFERENCE
	IAC			/CHECK IF Y REF AFTER SCREEN
	SZA	CLA		/SKIP IF AFTER
	JMP	SHDY1		/NO - Y REF IS BEFORE THE SCREEN
	CLA CLL CMA		/SETUP TO GET MAXY-1
	TAD	MAXY		/MAX Y CO-ORDINATE ALLOWED
	SKP
SHDY1,	TAD	MINY		/MINIMUM Y ALLOWED
	SKP
SHDY2,	TAD	YREFLN		/ACTUAL Y REFERNECE
	DCA	YREF		/SAVE AS NEW Y REFERNECE
	GETPRM			/GET SHADE CHARACTER IF ANY FROM CALLING FIELD
	AND	K0377		/MASK TO 8 BITS
	DCA	ARETXT		/SAVE AS SHADE CHAR IF NOT 0
	TAD	QCHRST		/GET THE CURRENLY SELECTED ALPHABET
	DCA	ACHRST		/SAVE IT - TO GET THE SHADE CHAR IF SELECTED
	JMS  I  XSHDTX		/GO SETUP FOR AREA SHADING WITH LINE OR CHAR
	JMP  I  GTSHDY		/RETURN BACK TO THE CALLER
/
XSHDTX,	GTATXT

/-------------------------------------------------------------------------------
/ RETREG - RETURN TO CALLER THE CO-ORDINATES OF THE LOGICAL SCREEN
/-------------------------------------------------------------------------------
/
RETREG,	0
	TAD	M0004		/SETUP TO RETURN 4 VALUES
	JMS	MOVEIT		/GO MOVE 4 PARAMETERS
	LREGIN			/ADDRESS OF DATA TO BE MOVED
	JMP  I  RETREG		/EXIT

/------------------------------------------------------------------------------
/ RETPOS - RETURN CO-ORDINATES OF THE CURRENT CURSOR POSITION
/------------------------------------------------------------------------------
/
RETPOS,	0
	CLA CLL CMA RAL		/-2
	JMS	MOVEIT		/GO MOVE 2 PARAMETERS TO CALLER
	XPOS1			/FROM XPOS1 AND YPOS1 LOCATION
	JMP  I  RETPOS

/------------------------------------------------------------------------------
/ XPTPRM - STORE PARAMETER INTO CALLING FIELD AND UPDATE CALLING FIELDS POINTER
/------------------------------------------------------------------------------
/
XPTPRM,	0
	JMS	OLDFLD		/CHANGE DATA FIELD TO CALLING FIELD
	DCA  I  PTABLE		/GIVE PARAMETER TO CLLING FIELD
	CDF	PRGFLD		/RESTORE THIS FIELDS DATA FIELD
	ISZ	PTABLE		/UPDATE CALLING FIELDS POINTER
	JMP  I  XPTPRM		/EXIT

/------------------------------------------------------------------------------
/ MOVEIT - RETURN VALUES BACK TO CALLING FIELD
/------------------------------------------------------------------------------
/
MOVEIT,	0
	DCA	MOVCNT		/SAVE THE NUMBER OF PARAMETERS TO MOVE
	TAD  I  MOVEIT		/GET THE ADDRESS OF PARAMETERS TO MOVE
	DCA	MOVPNT		/SAVE THE POINTER
	ISZ	MOVEIT		/BUMP POINTER FOR RETURN
MOVLOP,	TAD  I  MOVPNT		/GET THE PARAMETER
	PUTPRM			/STORE PARAMETER IN CALLING FIELD
	ISZ	MOVPNT		/UPDATE THIS FIELDS POINTER
	ISZ	MOVCNT		/DONE ?
	JMP	MOVLOP		/NO - MOVE NEXT PARAMETER INTO CALLING FIELD
	JMP  I  MOVEIT		/RETURN BACK TO CALLER
/
MOVCNT,	0
MOVPNT,	0

/------------------------------------------------------------------------------
/ CLRCST - LOAD SPECIFIED CHARACTER SET WITH ERROR CHARACTER (96 CHARACTERS)
/------------------------------------------------------------------------------
/
CLRCST,	0
	SNA			/SKIP IF NOT US ASCII CHAR SET
	JMP  I  CLRCST		/EXIT - CAN NOT CLEAR US ASCII CHAR SET
	DCA	CSCLR		/SAVE THE CHAR SET TO BE CLEARED
	TAD	K40CS		/INITIALIZE THE STARTING CHARACTER TO 40
	DCA	DDCHAR
	TAD	M140		/SETUP COUNTER TO LOAD 96 CHARACTERS
	DCA	CSCNT1		/SAVE CHARACTER SET COUNTER
CLRCS1,	TAD	CSCLR		/GET THE CHARACTER SET TO BE CLEARED
	JMS  I  XGTADR		/GET THE BASE ADDRESS OF CHAR SET TO BE INIT'ED
	DCA	CLRCS2		/SAVE THE BASE ADDRESS
	PR3			/BLOCK MOVE FROM THIS FIELD TO PANEL RAM
	PBMFLD+4000+PRGFLD	/	FIELD REF FIX FOR WPS		/C055A
	CHARER			/ADDRESS IN THIS FIELD OF DATA TO BE MOVED
CLRCS2,	0			/PANEL RAM ADDRESS - WHERE TO STORE ERROR CHAR
	-12			/NUMBER OF WORDS TO BE MOVED
	7777			/TERMINATOR
	ISZ	DDCHAR		/UPDATE THE CHARACTER BY 1
	ISZ	CSCNT1		/DONE FILLING CHARACTER SET ?
	JMP	CLRCS1		/NO - CLEAR NEXT GRAPHIC CHARACTER
	JMP  I  CLRCST		/EXIT - THE SPECIFIED CHAR SET NOW CLEARED
/
XGTADR,	GETADR
CSCLR,	0
CSCNT1,	0
M140,	-140
K40CS,	40
CHARER,	377; 377; 377; 377; 377; 377; 377; 377; 377; 377

/-------------------------------------------------------------------------------
/ GTCPLN - EXCHANGE BITS 0 AND 2 IN THE COLOR PLANE AND PLANE MASK WORDS
/------------------------------------------------------------------------------
/
GTCPLN,	0
	TAD  I  GTCPLN		/GET THE ADDRESS OF WORD TO BE MODIFIED
	DCA	CPLNAD		/SAVE THE ADDRESS
	ISZ	GTCPLN		/UPDATE THE RETURN POINTER
	GETPRM			/GET COLOR PLANE SELECTION FROM CALLING FIELD
	DCA  I  CPLNAD		/SAVE THE SPECIFIED COLOR PLANE
	TAD  I  CPLNAD		/GET THE COLOR PLANE SELECTION
	AND	C7760		/CHECK TO SEE IF OUT GREATER THEN 17
	SZA	CLA		/SKIP IF LESS THEN 17
	TAD	K0017		/GREATER THEN 17 - DEFAULT TO ALL PLANES ON
	SZA
	DCA  I  CPLNAD		/SAVE THE DEFAULT COLOR PLANE SELECTION
	AC1			/MASK OUT BIT<11>
	AND  I  CPLNAD		/ OF THE COLOR OR PLANE MASK WORD
	CLL	RTL		/PUT IT IN BIT 2
	DCA	XCHGTM		/SAVE IN TEMP
	AC0004			/MASK TO BIT<09>
	AND  I  CPLNAD		/ OF THE COLOR OR PLANE MASK WORD
	RTR			/PUT BIT 2 INTO BIT 0
	TAD	XCHGTM		/ADD PREVIOUSLY SWAPPED BIT TO IT
	DCA	XCHGTM		/SAVE SWAPPED VALUE
	TAD  I  CPLNAD		/GET THE INITIAL WORD
	AND	K0012		/KEEP INTINSITY AND RED PLANE
	TAD	XCHGTM		/ADD THE SWAPPED BITS BACK INTO WORD
	DCA  I  CPLNAD		/SAVE THE NEW VALUE WITH THE SWAPPED BITS
	JMP  I  GTCPLN		/EXIT BACK TO CALLER
/
CPLNAD,	0
XCHGTM,	0
C7760,	7760

	PAGE
/------------------------------------------------------------------------------
/ GTCSIZ - CLEAR SPECIFIED ALPHABET BIT-MAP
/--------------------------------------------------------------------------------
/
GTCSIZ,	0
	GETPRM			/GET SPECIFIED ALPHABET FROM CALLING FIELD
	SNA	SPA		/SKIP IF ALPHABET >0
	JMP	GTCSZE		/EXIT - LESS THEN OR EQUAL TO ZERO
	DCA	CSIZAB		/SAVE THE SPECIFIED ALPHABET
	CLA CLL CMA RTL		/-3
	TAD	CSIZAB		/GET THE SPECIFIED ALPHABET
	SMA SZA	CLA		/SKIP IF ALPHABET SPECIFIED = 1, 2 OR 3
	JMP	GTCSZE		/EXIT - ALPHABET SELECTED OUT OF RANGE
	TAD	CSIZAB		/GET THE SPECIFIED ALPHABET
	JMS  I  SIZCLR		/GO LOAD SPECIFED ALPHABET WITH ERROR BIT MAP
GTCSZE,	CLA	CLL
	JMP  I  GTCSIZ		/EXIT BACK TO CALLING FIELD
/
SIZCLR,	CLRCST			/ROUTINE TO LOAD CHAR SET WITH ERROR BIT MAP
CSIZAB,	0
CSIZFG,	0
/
/
/ ----------------------------------------
/ SSCRNE - COMMAND STRING FOR SCREEN ERASE
/ ----------------------------------------
/
SSCRNE,	514; 020; 037; 003; 360; 000; 360; 000
	550
	7777

/------------------------------------------------------------------------------
/ GTTXTR - GET TEXT REFERENCE POSITION FOR CARRAIGE RETURN AND LINE FEEDS
/-------------------------------------------------------------------------------
/
GTTXTR,	0
	TAD	XPOS1		/GET THE CURRENT X POSITION
	DCA	TXTSXP		/SAVE IT
	TAD	YPOS1		/GET THE CURRENT Y POSITION
	DCA	TXTSYP		/SAVE IT
/
	ACNEG1			/CHECK IF REPLACE, NON-ITALIC, NON-NEGATE
	TAD	WRMODE		/  TO SKIP ZERO DOTS, CAUSE
	SZA CLA			/  THEY ARE HANDLED BY SPECIAL CODE
	JMP	GTTXT2		/NOT REPLACE, GO DO NORMAL STUFF HERE
	TAD	QCELIT		/IS REPLACE, CHECK ALSO FOR NON-ITALIC
	SZA CLA
	JMP	GTTXT2		/ITALIC, GO DO NORMAL STUFF
	TAD	NEGFLG		/REPLACE, NON-ITALIC, CHECK FOR NON-NEGATE
	SNA CLA
	JMP	GTTXT3		/AHA!  SKIP ZEROES
/
GTTXT2,	TAD	NEGFLG		/CHECK IF ZERO DOTS CAN BE IGNORED
	SZA CLA			/  CAN IGNORE, IF W(N0,V) OR W(N0,C)
	JMP	GTTXT4		/NEGATE ON, MUST DRAW
	AC1			/NEGATE OFF, CHECK WRITING MODE
	AND	WRMODE		/  FOR OVERLAY OR COMPLEMENT (LSB SET)
	SNA CLA
GTTXT3,	ACNEG1			/CAN IGNORE ZEROES
GTTXT4,	DCA	SKIP0		/MARK FLAG
/
	TAD	NEGFLG		/CHECK IF ONE DOTS CAN BE IGNORED
	SNA CLA			/  CAN IGNORE, IF W(N1,V) OR W(N1,C)
	JMP	GTTXT6		/NEGATE OFF, MUST DRAW
	AC1			/NEGATE ON, CHECK WRITING MODE
	AND	WRMODE		/  FOR OVERLAY OR COMPLEMENT (LSB SET)
	SNA CLA
	ACNEG1			/CAN IGNORE ONES
GTTXT6,	DCA	SKIP1		/MARK FLAG
/
	JMP  I  GTTXTR		/EXIT
/
/
SKIP0,	0			/DON'T DRAW ZERO DOTS FLAG (0=DRAW, -1=DON'T)
SKIP1,	0			/DON'D DRAW ONE DOTS FLAG (0=DRAW, -1=DON'T)

/------------------------------------------------------------------------------
/ GTCBMP - LOAD USER DEFINED BIT MAP CHARACTER TO ALPHABET 1, 2 OR 3
/------------------------------------------------------------------------------
/
GTCBMP,	0
	GETPRM			/GET THE SELECTED ALPHABET FOR LOADING
	SNA	SPA		/CHECK IF GREATER THEN ZERO
	JMP	EXITLM		/LESS THEN 0 OR 0 - EXIT INVALID ALPHABET
	DCA	CSIZAB		/SAVE THE SELECTED ALPHABET
	CLA CLL CMA RTL		/-3
	TAD	CSIZAB		/CHECK IF ALPHABET 1, 2 OR 3
	SMA SZA	CLA		/SKIP IF VALID ALPHABET SELECTED FOR LOADING
	JMP	EXITLM		/INVALID ALPHABET SELECTED FOR LOADING - EXIT
	GETPRM			/GET THE BIT MAP CHARACTER TO BE LOADED
	DCA	DDCHAR		/SAVE IT
	JMS	CHKCHR		/CHECK SELECTED CHAR FOR RANGE
	SZA	CLA		/SKIP IF CHAR WITHIN EXTENT OF ALPHABET
	JMP	EXITLM		/EXIT - CHAR SPECIFIED OUTSIDE OF EXTENT
	CLA	CMA		/GET ADDRESS -1 OF WHERE TO STORE UPDATED CHAR
	TAD	CHRSTR		/ADDRESS OF WHERE TO STORE UPDATED CHAR
	DCA	AUTO12		/SAVE ADDRESS-1
	TAD	M12BMP		/SETUP TO MOVE TEN PARTS OF BIT MAP CHAR
	DCA	GTCBTM		/SAVE COUNTER
CBMPLP,	JMS	GETPAT		/GET PART OF CHAR BIT MAP FROM CALLING FIELD
	DCA  I  AUTO12		/SAVE THE BIT MAP CHAR ROW IN CHAR STORAGE AREA
	ISZ	GTCBTM		/DONE ?
	JMP	CBMPLP		/NO - LOAD NEXT PART OF CHAR
	TAD	CSIZAB		/GET THE SELECTED ALPHABET
	JMS  I  BGTADR		/GO GET ADDRESS OF BIT MAP CHAR IN PANEL RAM
	DCA	CBMPAD		/SAVE THE ADDRESS TO BIT MAP CHAR IN PANEL RAM
	PR3			/BLOCK MOVE FROM THIS FIELD TO PANEL RAM
	PBMFLD+4000+PRGFLD	/	FIELD REF FIX FOR WPS		/C055A
CHRSTR,	ARRAY			/ADDRESS OF WHERE UPDATED BIT MAP CHAR STORED
CBMPAD,	0			/ADDRESS OF WHERE TO STORE CHAR IN PANEL RAM
M12BMP,	-12			/NUMBER OR WORDS TO MOVE
	7777			/TERMINATOR
EXITLM,	CLA	CLL		/NEEDED FOR EXIT
	JMP  I  GTCBMP		/EXIT

CHKCHR,	0
/
	MINMAX			/CHECK SELECTED CHAR TO BE WITHIN CHAR EXTENT
	DDCHAR			/ADDRESS OF CHAR TO BE CHECKED
	CSIZFG			/ADDRESS OF FLAG USED IN COMPARISONS
	K0040			/MINIMUM ALLOWED CHARACTER
	K0177			/MAXIMUM ALLOWED CHARACTER (+1)
	TAD	CSIZFG		/GET THE COMPARISON FLAG
	JMP  I  CHKCHR		/EXIT WITH AC=VALIDITY OF CHAR EXTENT
/
BGTADR,	GETADR
GTCBTM,	0
K0040,	0040

/------------------------------------------------------------------------------
/ GETPAT - GET LINE TEXTURE OR ROW OF CHAR BIT MAP AND CREATE MIRROR IMAGE OF IT
/------------------------------------------------------------------------------
/
GETPAT,	0
	GETPRM			/GET PART OF CHAR BIT MAP FROM CALLING FIELD
	AND	K0377		/MASK TO EIGHT BITS
	DCA	GTTXTR		/SAVE THE BIT MAP CHARACTER ROW
	TAD	M0010		/SETUP TO ROTATE LSB TO MSB FOR GDC
	DCA	GETPTM		/SAVE COUNTER FOR 8 BIT SHIFTING
	DCA	GETPT1		/CLEAR NEW BIT MAP CHARACTER ROW
CBMPL1,	TAD	GTTXTR		/GET THE CHARACTER ROW TO BE SHIFTED
	CLL	RAR		/SHIFT LSB TO LINK
	DCA	GTTXTR		/SAVE THE SHIFTED CHARACTER ROW
	TAD	GETPT1		/GET THE NEW CHARACTER ROW
	RAL			/SHIFT LSB OF ORIGINAL TO MSB OF REAL ROW
	DCA	GETPT1		/SAVE THE NEW CHARACTER ROW
	ISZ	GETPTM		/DONE ALL 8 BITS?
	JMP	CBMPL1		/NO - SHIFT NEXT BIT UP
	TAD	GETPT1		/GET THE MIRROW IMAGE OF ORIGINAL CHAR ROW
	JMP  I  GETPAT		/EXIT WITH MIRROR IMAGE OF PATTERN IN AC
/
/
GETPTM,	0
GETPT1,	0

	PAGE
/------------------------------------------------------------------------------
/ GTATXT - GET AREA TEXTURE - SHADING CHARACTER
/------------------------------------------------------------------------------
/
GTATXT,	0
	TAD	SHDFLG		/GET THE SHADE FLAG
	SZA	CLA		/SKIP IF NOT SET
	JMP	SHDING		/SHADING IS TURNED ON
	JMS  I  AUPDPT		/GO UPDATE THE LINE PATTERN
	JMP  I  GTATXT		/EXIT LINE PATTERN RESET
SHDING,	TAD	ARETXT		/GET THE AREA TEXTURE
	SZA			/SKIP IF SHADING WITH LINE PATTERN
	JMP	SWITHC		/SHADING IS WITH CHARACTER
	TAD	M0010		/BUILD A CHAR BIT MAP WITH LINE TEXTURE
	DCA	ABITCT		/SAVE THE 8 BIT COUNTER
	TAD	SHDCHR		/GET ADDRESS OF SHADE BIT MAP CHAR
	DCA	SALPHA		/SAVE THE ADDRESS
	TAD	LINTXT		/GET PRESENT LINE TEXTURE - DISREGARDING MULT
	DCA	TEMP		/SAVE IT
LTXTLP,	TAD	TEMP		/GET THE WORKING LINE PATTERN ROW
	CLL	RAR		/SHIFT RIGHT TO THE LINK
	DCA	TEMP		/SAVE UPDATED ROW PATTERN
	SZL			/SKIP IF BIT 11 WAS A 0
	TAD	K0377		/LOAD BIT MAP WITH ALL ONES
	DCA  I  SALPHA		/SAVE 1'S OR 0'S AS BIT MAP CHAR ROW
	ISZ	SALPHA		/UPDATE BIT MAP ROW POINTER
	ISZ	ABITCT		/UPDATE BIT COUNTER
	JMP	LTXTLP		/GO GET NEXT ROW OF BITS
	JMP  I  GTATXT		/EXIT LINE PATTERN BIT MAP CHARACTER BUILT
SWITHC,	DCA	DDCHAR		/SAVE THE SHADE CHARACTER
	JMS  I  BCKCHR		/CHECK CHAR FOR RANGE
	SNA	CLA		/SKIP IF INVALID CHARACTER
	JMP	GTSCHR		/GO GET THE BIT MAP FOR SHADE CHARACTER
	TAD	K0177		/GREATER THEN EXTENT - DEFAULT TO 177
	DCA	DDCHAR		/SAVE THE DEFAULT CHARACTER
GTSCHR,	TAD	ACHRST		/GET THE SELECTED ALPHABET
	JMS  I  AGTADR		/GET PANEL RAM CHAR BIT MAP ADDRESS
	DCA	SHDTXT		/SAVE THE ADDRESS
	PR3			/GET CHAR BIT MAP FROM PANEL RAM
	5000+PRGFLD+PBMFLD	/BLOCK MOVE FROM PANEL RAM TO THIS FIELD
SHDTXT,	0			/ADDRESS IN PANEL RAM OF BIT MAP CHAR
SHDCHR,	CHRBMP			/ADDRESS IN THIS FIELD TO STORE BIT MAP
	-10			/NUMBER OF WORDS TO BE MOVED
	7777			/TERMINATOR
	JMP  I  GTATXT		/EXIT - CHAR BIT MAP SAVED
/
AUPDPT,	UPDPAT
SCOPY,	COPDAT
AGTADR,	GETADR
BCKCHR,	CHKCHR
ATXTPT,	DRWPRM+1
ABITCT,	0
SALPHA,	0
K0200,	200

/-----------------------------------------------------------------------------
/ GTXTPV - TEXT PIXEL VECTOR MOVEMENT AROUND A CHARACTER
/------------------------------------------------------------------------------
/
GTXTPV,	0
/
	GETPRM			/GET THE PIXEL VECTOR DIRECTION
	DCA	GTXTTM		/SAVE IT
/
	TAD	GTXTTM		/GET DIRECTION
	CIF CDF	TBLFLD		/CALL ROUTINE IN TABFLD
	JMS I	XTXTXP		/  TO DETERMINE DELTA X
	JMS I	TUPDTX		/CHANGE X POSITION
/
	TAD	GTXTTM		/GET DIRECTION
	CIF CDF	TBLFLD		/CALL ROUTINE IN TABFLD
	JMS I	XTXTYP		/  TO DETERMINE DELTA Y
	JMS I	TUPDTY		/CHANGE Y POSITION
/
	JMP I	GTXTPV		/RETURN
/
/
GTXTTM,	0
TUPDTX,	UPDATX
TUPDTY,	UPDATY
XTXTXP,	TXTXPV
XTXTYP,	TXTYPV

/------------------------------------------------------------------------------
/ LDATXT - SETUP GDC'S AREA PARAMETERS WITH SHADE PATTERN
/------------------------------------------------------------------------------
/
LDATXT,	0
	TAD	XPOS1		/GET THE CURRENT X POSITION
	AND	K0007		/MASK TO LOWER 3 BITS
	DCA	MODX		/SAVE IT
	TAD	YPOS1		/GET THE CURRENT Y CO-ORDINATE
	CLL	RAR		/DIVIDE IT BY 2
	IAC			/ADD 1
	AND	K0007		/MASK TO LOWER 3 BITS
	DCA	MODY		/SAVE IT
	CLA CLL CMA		/GET ADDRESS -1 OF SHADE PATTERN BUFFER
	TAD	SHDCHR		/
	TAD	MODY		/ADD MODULAR Y OFFSET TO ADDRESS
	DCA	ATXTP0		/SAVE ADDRESS -1 OF STARTING BIT MAP PATTERN
	TAD	M0010		/INITIALIZE TO MOVE 8 WORDS
	TAD	MODY		/UPDATE COUNTER BY MODULAR Y OFFSET
	JMS  I  SCOPY		/COPY ALL OR PART OF BIT MAP PATTERN
ATXTP0,	0			/ADDRESS-1 OF SOURCE (MODIFIED IN CODE)
	DRWPRM			/ADDRESS-1 OF DESTINATION
	TAD	AUTO11		/GET ADDRESS-1 OF NEXT AREA TO STORE DATA
	DCA	ATXTP1		/SAVE ADDRESS-1 OF NEXT BUFFER STORAGE
	TAD	M0010		/CALCULATE REMIANING BYTES TO MOVE
	TAD	MODY		/ADD MODULAR Y OFFSET TO IT
	CIA			/NEGATE IT
	TAD	M0010		/SUBTRACT THIS FROM NUMBER OF INITIAL WORDS
	SNA			/SKIP IF MORE OF PATTERN TO BE MOVED
	JMP	AFLIP		/GO FLIP BITS BASED ON X OFFSET
	JMS  I  SCOPY		/COPY START OF BIT MAP TO END OF AREA BIT MAP
	CHRBMP-1		/ADDRESS-1 OF SHADE PATTERN BUFFER
ATXTP1,	0			/ADDRESS-1 OF DESTINATION (MODIFIED IN CODE)
AFLIP,	TAD	M0010		/GET NUMBER OF BYTES TO BE SHUFFLED
	DCA	TEMP		/SAVE THE NUMBER OF BYTES TO SHUFFLE
	TAD	ATXTPT		/GET BASE ADDRESS OF BIT MAP CHARACTER
	DCA	SALPHA		/SAVE THE ADDRESS OF WORD TO BE SHIFTED
SHUFLP,	TAD	MODX		/GET THE OFFSET
	SNA			/SKIP IF NOT 0
	JMP  I  LDATXT		/EXIT - SHIFTING OF BITS NOT NEEDED
	CIA			/NEGATE OFFSET
	DCA	ABITCT		/SAVE AS BIT SHIFT COUNTER
	TAD  I  SALPHA		/GET THE PATTERN TO BE UPDATED
SHFTIT,	CLL	RAR		/SHIFT RIGHT INTO LINK
	SZL			/SKIP IF LINK = ZERO
	TAD	K0200		/IF NOT 0 - REPLICATE BIT INTO LSB POSITION
	ISZ	ABITCT		/UPDATE THE BIT SHIFT COUNTER
	JMP	SHFTIT		/GO SHIFT AND REPLICATE AGAIN
	DCA  I  SALPHA		/SAVE THE SHUFFLED PATTERN
	ISZ	SALPHA		/UPDATE POINTER TO WORDS TO BE SHUFFLED
	ISZ	TEMP		/UPDATE NUMBER OF BYTES TO SHUFFLE
	JMP	SHUFLP		/NOT DONE - SHUFFLE NEXT WORD
	JMP  I  LDATXT		/EXIT FOR NOW - NO ROOM LEFT

/ ------------------------------------------------------
/ PUTXYS -
/ ------------------------------------------------------
/
PUTXYS,	0
/
	CLL RAL			/MULTIPLY BY TWO TO THE SET OFFSET
	TAD	PNTARY		/ADD BASE ADDRESS OF ARRAY
	DCA	TEMP		/SAVE POINTER TO X AND Y SET
/
	TAD I	XPNTX		/GET THE X COORDINATE
	DCA I	TEMP		/SAVE IT IN THE ARRAY
/
	ISZ	TEMP		/UPDATE POINTER TO Y ELEMENT
/
	TAD I	XPNTY		/GET THE Y COORDINATE
	DCA I	TEMP		/PUT IT IN THE ARRAY
/
	JMP I	PUTXYS		/RETURN
/
/
XPNTX,	PNTX
XPNTY,	PNTY
PNTARY,	ARRAY

	PAGE
/-----------------------------------------------------------------------------
/ DRWARC - DRAW AN ARC OR A CIRCLE <XCENTR><YCENTR><# OF DEGREES>
/
/	INPUT:		CENTER X AND Y CO-ORDINATES
/			NUMBER OF PLUS OR MINUS DEGREES IN ARC/CIRCLE (360)
/	ASSUMED:	CURRENT CURSOR POSITION <XPOS1,YPOS1> ON CIRCUMFERENCE
/-----------------------------------------------------------------------------
/
DRWARC,	0
	GETPRM			/GET CENTER X FROM CALLING FIELD
	DCA	XCENTR		/SAVE IT
	GETPRM			/GET CENTER Y FROM CALLING FIELD
	DCA	YCENTR		/SAVE IT
	GETPRM			/GET + OR - # OF DEGREES IN ARC/CIRCLE
	SNA			/SKIP IF NUMBER OF DEGREES > 0
	JMP  I  DRWARC		/EXIT - 0 DEGREES SPECIFIED
	DCA	DEGRES		/SAVE IT
	TAD	XCENTR		/CREATE THE X RADIUS
	CIA			/
	SGNCHK			/ADD TWO NUMBERS CHECKING FOR OVERFLOW
	XPOS1			/
	DCA	XRAD		/XRAD = XPOS1-XCENTR
	TAD	YCENTR		/CREATE THE Y RADIUS
	CIA			/
	SGNCHK			/ADD TWO NUMBERS CHECKING FOR OVERFLOW
	YPOS1			/
	DCA	YRAD		/YRAD = YPOS1-YCENTR
	JMS	ARCPNT		/GENERATE 4 POINTS 90 DEGREES APART
	JMS  I  GODRWA		/GO DRAW THE ARC
	DCA	INDEX		/SET CURVE TO BE NOT IN PROGRESS
	DCA	CLSCRV		/SET CLOSE CURVE=FALSE
	JMP  I  DRWARC		/EXIT
/
GODRWA,	ARCDRW
XCENTR,	0
YCENTR,	0
XRAD,	0
YRAD,	0

/------------------------------------------------------------------------------
/ ARCPNT - PICK 4 POINTS 90 DEGREES APART TO BE USED IN ARC/CIRCLE DRAWING
/------------------------------------------------------------------------------
/
ARCPNT,	0
	TAD	DEGRES		/USE THE SIGN OF DEGREES TO INDICATE DIRECTION
	SMA	CLA		/IF NEGITIVE STORE X AND Y IN SET 0
	CLA CLL IAC RAL		/ELSE STORE X+Y IN SET 2 OF ARRAY
	DCA	INDEX		/SAVE THE ARRAY INDEX TO THE SET TO UPDATE
	TAD	YRAD		/GET THE Y RADIUS
	JMS	STPNTX		/PNTX = XCENTR+YRAD
	TAD	XRAD		/GET THE Y RADIUS
	CIA			/NEGATE IT
	JMS	STPNTY		/PNTY = YCENTR-XRAD
	JMS	PUTPNT		/STORE X AND Y IN ARRAY SET 0 OR 2
	CLA CLL IAC		/SETUP INDEX FOR SET 1
	DCA	INDEX		/SAVE THE INDEX
	TAD	XPOS1		/GET THE CURRENT X POSITION
	DCA	PNTX		/SAVE IT
	TAD	YPOS1		/GET THE CURRENT Y POSITION
	DCA	PNTY		/SAVE IT
	JMS	PUTPNT		/STORE X AND Y IN ARRAY SET 1
	TAD	DEGRES		/GET THE SIGN OF THE DEGREES
	SPA	CLA		/IF POSITIVE STORE X AND Y IN ARRAY SET 0
	CLA CLL IAC RAL		/ELSE STORE X AND Y IN ARRAY SET 2
	DCA	INDEX		/SAVE INDEX INTO ARRAY SET 0 OR 2
	TAD	YRAD		/GET THE Y RADIUS
	CIA			/NEGATE IT
	JMS	STPNTX		/PNTX = XCENTR-YRAD
	TAD	XRAD		/GET THE X RADIUS
	JMS	STPNTY		/PNTY = YCENTR+XRAD
	JMS	PUTPNT		/STORE X AND Y IN ARRAY SET 0 OR 2
	CLA CLL CML IAC RAL	/INITIALIZE INDEX TO SET 3
	DCA	INDEX		/SAVE THE INDEX
	TAD	XRAD		/GET THE X RADIUS
	CIA			/NEGATE IT
	JMS	STPNTX		/PNTX = XCENTR-XRAD
	TAD	YRAD		/GET THE Y RADIUS
	CIA			/NEGATE IT
	JMS	STPNTY		/PNTY = YCENTR-YRAD
	JMS	PUTPNT		/STORE THE POINTS IN ARRAY SET 3
	ISZ	INDEX		/INDEX NOW EQUALS 4
	JMP  I  ARCPNT		/EXIT 4 POINTS 90 DEGREES APART SAVED IN ARRAY

STPNTX,	0
	SGNCHK			/ADD/SUB XRAD/YRAD FROM XCENTR
	XCENTR
	DCA	PNTX		/SAVE THE RESULT OF ADD OR SUBTRACT
	JMP  I  STPNTX
/
STPNTY,	0
	SGNCHK			/ADD/SUB XRAD/YRAD FROM YCENTR
	YCENTR
	DCA	PNTY		/SAVE THE RESULT OF ADD OR SUBTRACT
	JMP  I  STPNTY
/
PUTPNT,	0
	TAD	INDEX		/GET THE INDEX INTO ARRAY
	JMS I	XPTXYS		/GO STORE POINTS IN DRAW ARRAY
	CLA CLL CMA RTL		/-3
	TAD	INDEX		/GET THE INDEX INTO THE ARRAY
	SMA	CLA		/SKIP IF INDEX = 0 TO 2
	JMP  I  PUTPNT		/EXIT - INDEX = 3
	CLA CLL IAC RTL		/AC=4
	TAD	INDEX		/ADD INDEX TO 4 - OFFSET TO POSITION ARRAY
	JMS I	XPTXYS		/GO STORE POINTS IN POSITION ARRAY
	JMP  I  PUTPNT		/EXIT - DRAW AND POSITION ARRAYS UPDATED
/
/
PNTX,	0
PNTY,	0
XPTXYS,	PUTXYS

/ -----------------------------------------------------------
/ TXTAPR - DRAW CHARACTER ROW FROM END OF UNIT TO END OF CELL
/ -----------------------------------------------------------
/
TXTAPR,	0			/DRAW TEXT APRON
/
	TAD I	XXSKP0		/CHECK IF ZERO DATA TO BE WRITTEN
	SZA CLA
	JMP	TXTAP8		/NO, GO RETURN
/
	BLDPOS			/BUILD A CURSOR POSITION STRING
	SPOSIT
/
	AC1			/BUILD A FIGS DC PARAMETER
	TAD	TXTAP6		/POINT TO FIGS STRING
	DCA	AUTO10
/
				/CALCULATE NUMBER OF PIXELS NOT YET DONE
	TAD	QDTWDC		/GET NUMBER DOTS IN CELL
	TAD I	PDTXM4		/SUBTRACT NUMBER DOTS IN CELL NOT YET DONE
	SNA
	JMP	TXTAP4		/IF NO DOTS DONE, GO GET CELL WIDTH IN PIXELS
/
	CIA
	DCA I	PDTXM4		/SAVE NEGATIVE OF NUMBER OF DOTS DONE
TXTAP1,	TAD	QTXTDC		/ADD NUMBER PIXELS PER DOT DONE
	ISZ I	PDTXM4
	JMP	TXTAP1
	CIA
TXTAP4,	CDF	TBLFLD		/OTHER FIELD FOR # PHYSICAL PIXELS
	TAD I	XGDCWD		/SUBTRACT PIXELS DONE FROM CELL WIDTH
	CDF	PRGFLD		/BACK TO THIS FIELD
	SPA SNA			/CHECK IF ANY PIXELS TO DO
	JMP	TXTAP8		/NO, DON'T BOTHER DRAWING
	TAD	M0001		/GDC USES #DOTS-1
	JMS I	XXXSVD		/SAVE PARAMETER IN FIGS STRING
/
	DRAWIT			/DRAW
	SPOSIT
TXTAP6,	STEXT
	TXTPT0
/
TXTAP8,	CLA CLL
	JMP I	TXTAPR		/RETURN
/
/
XXXSVD,	SAVEDX
XXSKP0,	SKIP0
PDTXM4,	DTXTM4
XGDCWD,	ZGDCWD

	PAGE
/-------------------------------------------------------------------------------
/ ARCDRW - CALCULATE QUADRANTS,# 10 DEGREE SEGMENTS,# DEG IN LAST SEG -DRAW ARC
/------------------------------------------------------------------------------
/
ARCDRW,	0
	TAD	DEGRES		/GET NUMBER + OR - DEGREES IN THE ARC
	SPA			/SKIP IF POSITIVE
	CIA			/MAKE DEGREES ABSOLUTE
	DCA	DEGRES		/SAVE THE ABSOLUTE VALUE OF DEGREES
	TAD	M550		/-360 DECIMAL
	TAD	DEGRES		/GET NUMBER OF DEGREES IN ARC
	SNA	CLA		/SKIP IF NOT CIRCLE
	CLA CLL CMA		/CLOSE CURVE = TRUE (CIRCLE)
	DCA	CLSCRV		/CLOSE CURVE = FALSE IF NOT 360 DEGREES
	DCA	QUADRT		/CLEAR THE NUMBER OF QUADRANTS IN ARC
	CLA CLL CMA		/GET NUMBER OF DEGREES -1
	TAD	DEGRES
ARCDW1,	TAD	M132		/DIVIDE (DEGREES-1)/90
	SPA			/DONE DIVIDING ?
	JMP	ARCDW2		/YES - GO ADD 1 TO QUADRANT
	ISZ	QUADRT		/UPDATE THE QUADRANT BY 1
	JMP	ARCDW1		/GO DO THE DIVIDE AGAIN
ARCDW2,	ISZ	QUADRT		/ADD 1 MORE TO QUADRANT
	IAC			/UPDATE REMAINDER OF DIVISIION BY 1
	TAD	K132		/ADD 90 DEGREES BACK ONTO REMAIDER (DEG=1 TO 90)
	DCA	DEGRES		/SAVE NUMBER OF DEGREES IN THE LAST SEGMENT
	DCA	LASSEG		/CLEAR # OF SEGMENTS IN LAST ARC
	CLA CLL CMA		/GET NUMBER OF REMAINING DEGREES -1
	TAD	DEGRES		/
ARCDW3,	TAD	M12ARC		/DIVIDE (DEGREES-1)/10
	SPA			/DONE DIVIDING
	JMP	ARCDW4		/YES - GO ADD 1 TO LAST SEGMENT COUNT
	ISZ	LASSEG		/UPDATE # OF SEGMENTS IN LAST QUADRANT BY 1
	JMP	ARCDW3		/GO DIVIDE AGAIN BY SUBTRACTING 10
ARCDW4,	ISZ	LASSEG		/ADD 1 MORE TO # OF LAST SEGMENTS
	IAC			/UPDATE REMAINDER OF DIVISION BY 1
	TAD	K12ARC		/ADD 10 DEGREES BACK ON
	DCA	DEGRES		/SAVE THIS # OF REMAINING CORDS
	TAD	QUADRT		/GET THE NUMBER OF QUADRANTS
	CIA			/NEGATE IT
	DCA	QUADRT		/USE NEGATED QUADRT AS COUNTER
	TAD	BASARY		/GET THE BASE ADDRESS OF THE ARRAY
	DCA	DRWPNT		/SAVE IT

ARCDW5,	ISZ	QUADRT		/CHECK IF DOING THE LAST QUADRANT
	JMP	ARCDW7		/NO - GO DRAW THIS QUADRANT
	TAD	LASSEG		/GET THE # OF SEGMENTS IN LAST QUADRANT
	DCA	SEG		/SAVE IT
	TAD	DEGRES		/GET # OF CORDS IN LAST SEG
	DCA	REMAIN		/SAVE IT
	TAD	DRWPNT		/GET POINTER TO 4 SETS OF X AND Y POINTS
	DCA	ARCDW6		/SAVE IT
	JMS  I  DOCURV		/GO DRAW THE LAST ARC
ARCDW6,	0			/BASE ADDRESS OF THE 4 POINTS IN ARRAY
	JMP  I  ARCDRW		/EXIT - CURVE HAS BEEN COMPLETED
ARCDW7,	TAD	DRWPNT		/GET THE BASE ARRAY ADDRESS OF THE 4 POINTS
	JMS  I  FLARC		/GO DRAW A FULL ARC
	ISZ	DRWPNT		/UPDATE THE BASE ADDRESS BY 2
	ISZ	DRWPNT		/
	JMP	ARCDW5		/GO DO NEXT QUADRANT
/
DOCURV,	XCURVE
FLARC,	FULARC
BASARY,	ARRAY
DRWPNT,	0
QUADRT,	0
LASSEG,	0
M550,	-550
M132,	-132
K132,	132
M12ARC,	-12
K12ARC,	12

/------------------------------------------------------------------------------
/ XCURVE - ROUTINE TO DO CURVE INTERPOLATION AND DRAW THE CURVE
/-------------------------------------------------------------------------------
/
XCURVE,	0
	TAD  I  XCURVE		/GET THE BASE ADDRESS OF THE 4 POINTS
	DCA  I  XPTADR		/SAVE BASE ADDRESS OF 4 SETS OF CO-ORDINATES
	ISZ	XCURVE		/UPDATE POINTER FOR RETURN
	DCA  I  XCI		/CLEAR COLUMN INDEX INTO ITERPOLATION ARRAY
CRVLP1,	TAD  I  XPTADR		/SETUP FOR X INTERPOLATION ON 4 POINTS
	JMS  I  ACSUM		/GO DO INTERPOLATION FOR X
	XPOS1			/ADDRESS OF CURRENT X
	DCA	XPOS2		/SAVE THE "TO" X POSITION
	CLA CLL IAC		/SETUP FOR Y INTERPOLATION ON 4 POINTS
	TAD  I  XPTADR		/POINT TO BASE Y CO-ORDINATE
	JMS  I  ACSUM		/GO DO INTERPOLATION FOR Y
	YPOS1			/ADDRESS OF CURRENT Y
	DCA	YPOS2		/SAVE THE "TO" Y POSITION
	DRWVEC			/GO DRAW NTH OF 8 SEGMENTS
	ISZ  I  XCI		/UPDATE THE COLUMN INDEX
	TAD  I  XCI		/GET THE UPDATED INDEX
	CIA			/NEGATE IT
	TAD	SEG		/GET THE NUMBER OF SEGMENTS
	SZA	CLA		/SKIP IF DONE
	JMP	CRVLP1		/GO INTERPOLATE FOR NEXT SEGMENT
	JMP  I  XCURVE		/EXIT
/
XPTADR,	PNTADR
ACSUM,	ACUSUM
XCI,	CI

/-----------------------------------------------------------------------------
/ INTRPT - CURVE FITTING INTERPOLATION TABLE
/------------------------------------------------------------------------------
/
DECIMAL
INTRPT,	-9
	125
	13
	-1
	-14
	117
	29
	-4
	-16
	104
	48
	-8
	-15
	87
	68
	-12
	-12
	68
	87
	-15
	-8
	48
	104
	-16
	-4
	29
	117
	-14
	-1
	13
	125
	-9
	0
	0
	128
	0
OCTAL

	PAGE
/-------------------------------------------------------------------------------
/ CRVBGN - CURVE BEGIN OPEN
/------------------------------------------------------------------------------
/
CRVBGN,	0
	DCA	CLSCRV		/CLOSE CURVE=FALSE (CRVBGN) - TRUE (CRVCLS)
	DCA	INDEX		/INITIALIZE INDEX TO FIRST ELEMENT
	JMS	SVPOSA		/SAVE X AND Y IN POSITION ARRAY
	JMS	SVDRWA		/SAVE X AND Y IN DRAW ARRAY
	ISZ	INDEX		/UPDATE ARRAY INDEX BY 1
	JMP  I  CRVBGN		/EXIT - CURVE BEGIN OPEN

/-------------------------------------------------------------------------------
/ CRVCLS - CURVE BEGIN CLOSED
/------------------------------------------------------------------------------
/
CRVCLS,	0
	CLA CLL CMA		/SET CLOSE CURVE FLAG = TRUE
	JMS	CRVBGN		/GO DO SAME OPERATION AS CURE BEGIN OPEN
	JMP  I  CRVCLS		/EXIT CURVE BEGIN CLOSED
/
SVPOSA,	0			/SAVE X AND Y CO-ORDINATES IN POSITION ARRAY
	CLA CLL IAC RTL		/AC=4 OFFSET INDEX INTO POSITION ARRAY
	TAD	INDEX		/GET THE ARRAY INDEX
	JMS	STORXY		/GET CO-ORDINATES AND STORE IN POSITION ARRAY
	JMP  I  SVPOSA		/EXIT
/
SVDRWA,	0			/SAVE X AND Y CO-ORDINATES IN DRAW ARRAY
	TAD	INDEX		/GET THE ARRAY INDEX
	JMS	STORXY		/GET CO-ORDINATES AND STORE IN POSITION ARRAY
	JMP  I  SVDRWA		/EXIT
/
STORXY,	0			/STORE X AND Y CO-ORDINATES IN ARRAY
	CLL	RAL		/MULTIPLY INDEX BY 2 TO GET TO CORRECT SET
	TAD	ADRARY		/ADD BASE ADDRESS OF ARRAY TO INDEX
	DCA	ELMPOS		/SAVE AS ADDRESS OF FIRST ELEMENT (X)
	GETPRM			/GET THE X CO-ORDINATE FROM CALLING FIELD
	DCA  I  ELMPOS		/SAVE IT
	ISZ	ELMPOS		/UPDATE POINTER TO Y ELEMENT
	GETPRM			/GET THE Y CO-ORDINATE FROM CALLING FIELD
	DCA  I  ELMPOS		/SAVE IT
	CLA CLL CMA RAL		/-2 RESET POINTER TO CALLING FIELDS PARAMETERS
	TAD	PTABLE		/ADDRESS OF CALLING FIELDS CONTROL BLOCK
	DCA	PTABLE		/RESTORE ORIGINAL POINTER TO PARAMETERS
	JMP  I  STORXY		/EXIT X AND Y CO-ORDINATES SAVED

/-------------------------------------------------------------------------------
/ CRVCNT - CURVE CONTINUE
/-------------------------------------------------------------------------------
/
CRVCNT,	0
	TAD	INDEX		/GET CURVE IN PROGRESS FLAG
	SZA	CLA		/SKIP IF NOT PREVIOUS CLOSE/OPEN CURVE
	JMP	CRVCT1		/CURVE IN PROGRESS - CONTINUE
	GETXY2			/GET THE "TO" CO-ORDINATES
	DRWVEC			/DRAW THE VECTOR TO IT FROM WHEREVER WE ARE
	JMP  I  CRVCNT		/EXIT - VECTOR DRAWN
CRVCT1,	CLA CLL CMA RTL		/-3
	TAD	INDEX		/GET THE INDEX INTO THE ARRAY
	SMA SZA CLA		/SKIP IF INDEX = 1, 2 OR 3
	JMS	MOVDWN		/INDEX>=4 - MOVE ELEMENTS IN DRAW ARRAY DOWN
	CLA CLL CMA RTL		/-3
	TAD	INDEX		/GET THE PRESENT ARRAY INDEX
	SPA	CLA		/SKIP IF 3 OR GREATER
	JMS	SVPOSA		/SAVE NEW X AND Y CO-ORDINATES IN POSITION ARRAY
	JMS	SVDRWA		/SAVE NEW X AND Y CO-ORDINATES IN DRAW ARRAY
	CLA CLL CMA		/-1
	TAD	INDEX		/GET THE ARRAY INDEX
	SNA	CLA		/SKIP IF INDEX WAS NOT EQUAL TO 1
	GETXY1			/USE THESE CO-ORDINATES AS FIRST POINT OF CURVE
	ISZ	INDEX		/UPDATE THE INDEX INTO ARRAY BY 1 (4 IS MAX)
	TAD	INDEX		/GET THE UPDATED ARRAY INDEX
	TAD	M0004		/SUBTRACT 4 FROM IT
	SPA	CLA		/SKIP IF UPDATED INDEX = 4 OR GREATER
	JMP  I  CRVCNT		/EXIT - UPDATED INDEX < 4
	TAD	ADRARY		/BASE ADDRESS OF 4 POINTS TO INTERPOLATE ON
	JMS I	XFULAR		/GO SETUP FOR A FULL ARC
	JMP  I  CRVCNT		/EXIT CURVE CONTINUE
/
ADRARY,	ARRAY
ELMPOS,	0
XFULAR,	FULARC

/------------------------------------------------------------------------------
/ CRVEND - CURVE END - COMPLETES CURVE IN PROGRESS
/------------------------------------------------------------------------------
/
CRVEND,	0
	TAD	ADRARY		/GET THE BASE ADDRESS OF WORKING 4 POINTS
	DCA	ELMPOS		/SAVE IT
	TAD	INDEX		/GET THE CURVE IN PROGRESS FLAG
	SNA	CLA		/SKIP IF A CURVE WAS IN PROGRESS
	JMP	EXTEND		/EXIT - BAD CALL NO CURVE BEGIN CALL MADE
	TAD	CLSCRV		/GET CLOSE CURVE FLAG
	SMA	CLA		/SKIP IF CLOSE CURVE = TRUE
	JMP	CRVUPP		/OPEN CURVE - UPDATE POSITION TO LAST GIVEN
	TAD	INDEX		/GET THE ARRAY INDEX
	TAD	M0004		/CHECK IF 4 POINTS MINIMUM RECEIVED
	SZA	CLA		/SKIP IF YES - GO FINISH CURVE
	JMP	CRVEN6		/NO - UPDATE POSITION TO FIRST GIVEN
	CLA CLL CMA RTL		/-3
	DCA	MOVDWN		/SAVE COUNTER TO INCLUDE 1ST 3 POSITIONS GIVEN
CRVEOC,	ISZ	ELMPOS		/UPDATE ARRAY POINTER TO INCLUDE 1ST GIVEN PT.
	ISZ	ELMPOS		/
	TAD	ELMPOS		/GET BASE ADDRESS OF 4 POINTS TO INTERPOLATE ONE
	JMS I	XFULAR		/GO DRAW THE FULL ARC
	ISZ	MOVDWN		/INCLUDED 1ST 3 POSITIONS?
	JMP	CRVEOC		/NO - INCLUDE 2ND OR THIRD POSITION GIVEN
	AC7776			/GET A MINUS TWO (BECOMES -3) FOR START POINT
/
CRVUPP,	TAD	M0001		/SUBTRACT 1 FROM THE PRESENT ARRAY INDEX
	TAD	INDEX		/
CRVEN6,	CLL	RAL		/MULTIPLY BY 2 TO GET CORRECT X + Y SET
	TAD	ELMPOS		/ADD BASE ADDRESS OF 4 POINTS
	DCA	ELMPOS		/SAVE POINTER TO X AND Y ELEMENTS
	TAD  I  ELMPOS		/GET THE X ELEMENT
	DCA	XPOS1		/SAVE AS PRESENT X
	ISZ	ELMPOS		/UPDATE POINTER TO Y ELEMENT
	TAD  I  ELMPOS		/GET THE Y ELEMENT
	DCA	YPOS1		/SAVE AS PRESENT Y
EXTEND,	DCA	INDEX		/CLEAR CURVE IN PROGRESS AND ARRAY INDEX
	DCA	CLSCRV		/SET CLOSE CURVE TO FALSE
	JMP  I  CRVEND		/EXIT - CURVE END

/------------------------------------------------------------------------------
/ MOVDWN - MOVE TOP 3 SETS OF CO-ORDINATES DOWN IN DRAW ARRAY + ADD NEW SET
/------------------------------------------------------------------------------
/
MOVDWN,	0
	TAD	ADRARY		/GET BASE ADDRESS OF ARRAY
	TAD	M0001		/RESULT = ADDRESS OF DRAW ARRAY -1
	DCA	AUTO11		/SAVE ADDRESS OF DRAW ARRAY -1
	CLA CLL IAC RAL		/AC = 2
	TAD	AUTO11		/RESULT = ADDRESS OF DRAW ARRAY 2ND ELEMENT-1
	DCA	AUTO10		/SAVE THE ADDRESS
	CLA CLL CMA RTL		/AC = -3
	DCA	INDEX		/SETUP TO MOVE 3 SET OF CO-ORDINATES DOWN
	CLA	CLL		/NEEDED TO CLEAR THE LINK
MOVDN1,	TAD  I  AUTO10		/GET ELEMENT TO BE MOVED
	DCA  I  AUTO11		/OVERLAY EXISTING ELEMENT
	CML			/USED AS SET COUNTER
	SZL			/SKIP IF X AND Y CO-ORDINATES MOVED
	JMP	MOVDN1		/SET NOT MOVED - NOW MOVE Y CO-ORDINATE
	ISZ	INDEX		/DONE MOVING ALL 3 SETS
	JMP	MOVDN1		/NO - MOVE NEXT SET OF CO-ORDINATES DOWN
	CLA CLL CML IAC RAL	/AC=3
	DCA	INDEX		/SET INDEX INTO ARRAY = 3 FOR 4TH POSITION
	JMP  I  MOVDWN		/EXIT - 3 SETS OF CO-ORDINATES MOVED DOWN

	PAGE
/-------------------------------------------------------------------------------
/ ACUSUM - CURVE INTERPOLATION ROUTINE
/------------------------------------------------------------------------------
/
ACUSUM,	0			/GET X OR Y CO-ORDINATE BY INTERPOLATION
	DCA	BASADR		/SAVE BASE ADDRESS OF X OR Y ELEMENT
	TAD  I  ACUSUM		/GET ADDRESS OF CURRENT X OR Y POSITION
	DCA	CRNTXY		/SAVE IT
	ISZ	ACUSUM		/UPDATE POINTER FOR RETURN
	DCA	SUM3		/CLEAR THE ACCUMULATIVE 4 WORD SUM
	DCA	SUM2		/
	DCA	SUM1		/
	DCA	SUM0		/
	DCA	J		/CLEAR THE WORKING INDEX
ACSMLP,	TAD	J		/GET THE WORKING INDEX
	CLL	RAL		/MULTIPLY BY 2 TO GET ELEMENT INDEX
	TAD	BASADR		/ADD BASE ADDRESS OF 4 POINT ARRAY
	DCA	PNTELM		/SAVE POINTER TO X OR Y ELEMENT
	TAD  I  PNTELM		/GET THE X OR Y ELEMENT
	DCA	PNTELM		/SAVE THE X OR Y ELEMENT
	CNVDBL			/CONVERT X OR Y ELEMENT TO DOUBLE PRECISSION
	PNTELM			/ADDRESS OF WORD TO BE SIGNED EXTEND
	PTELMH			/HIGH WORD ADDRESS OF WHERE TO STORE RESULT
	TAD	CI		/GET COLUMN INDEX INTO INTERPOLATION ARRAY
	CLL	RTL		/MULTIPLY BY 4
	TAD	J		/ADD THE ELEMENT INDEX TO IT
	TAD	BASITR		/ADD BASE ADDRESS OF INTERPOLATION ARRAY
	DCA	ITRELM		/SAVE POINTER TO INTERPOLATION ELEMENT
	TAD  I  ITRELM		/GET THE X OR Y ELEMENT
	DCA	ITRELM
	CNVDBL			/CONVERT INTERPOLATION ELEMENT TO SIGN EXTEND
	ITRELM			/ADDRESS OF WORD TO BE CONVERTED
	ITELMH			/HIGH WORD ADDRESS OF WHERE TO STORE RESULTS
	DBLMTY			/MULITPY CO-ORDINATE BY INTERPOLATION VALUE
	PTELMH			/ADDRESS OF TWO WORD MULTIPLICAND
	ITELMH			/ADDRESS OF TWO WORD MULTIPLIER
	CLA	CLL		/ADD RESULT OF MULTIPLICATION TO TOTAL SUM
	TAD	SUM0		/ADD LEAST SIGNIFICANT WORDS
	TAD	MQLW
	DCA	SUM0		/SAVE RESULT
	GLK			/GET THE CARRY
	TAD	MQHW		/ADD NEXT SIGNIFICANT WORDS
	TAD	SUM1		/
	DCA	SUM1		/SAVE THE RESULT
	GLK			/GET THE CARRY
	TAD	ACLW		/ADD NEXT SIGNIFICANT WORDS
	TAD	SUM2		/
	DCA	SUM2		/SAVE THE RESULT
	GLK			/GET THE CARRY
	TAD	ACHW		/ADD THE MOST SIGNIFICANT BITS
	TAD	SUM3		/
	DCA	SUM3		/SAVE THE FINL RESULT

	ISZ	J		/UPDATE THE WORKING INDEX
	TAD	J		/GET TEH UPDATED INDEX
	TAD	M0004		/CHECK IF DONE ALL 4 POINTS
	SZA	CLA		/SKIP IF DONE
	JMP	ACSMLP		/NOT DONE - DO NEXT POINT OF INTERPOLATION
	TAD	SUM3		/MOVE ACCUMULATIVE SUM TO 4 WORD ACCUMULATOR
	DCA	ACHW		/
	TAD	SUM2		/
	DCA	ACLW		/
	TAD	SUM1		/
	DCA	MQHW		/
	TAD	SUM0		/
	DCA	MQLW		/
	DBLDIV			/DIVIDE ACCUMULATVE SUM BY 128
	CRVDVH			/ADDRESS OF 2 WORD DIVISOR
	CLA	CMA		/GET LAST SEGMENT -1
	TAD	SEG		/
	CIA			/NEGATE IT
	TAD	CI		/GET THE CURRENT COLUMN INDEX
	SZA	CLA		/DOING THE LAST SEGMENT OF THE ARC
	JMP	NOTLAS		/NO - GO CHECK X OR Y FOR OVERFLOW
	TAD	MQHW		/SETUP FOR SUBTRACT BY COPYING QUOTIENT ABOVE
	DCA	ACHW		/
	TAD	MQLW		/
	DCA	ACLW		/
	CNVDBL			/CONVERT CURRENT X OR Y TO SIGN EXTENSION
CRNTXY,	0			/ADDRESS OF WORD TO BE CONVERTED
	PTELMH			/ADDRESS OF WHERE TO STORE CURRENT X OR Y
	DBLSUB			/SUBTRACT CURRENT POSITION FROM INTERPOLATED
	PTELMH			/ADDRESS OF DOUBLE WORD TO BE SUBTRACTER
	ITELMH			/ADDRESS OF WHERE TO STORE RESULT
	CNVDBL			/CONVERT REMANING CORDS TO DOUBLE PRECISION
	REMAIN			/ADDRESS OF WORD TO BE CONVERTED
	SUM3			/ADDRESS OF WHERE TO STORE THE RESULT
	DBLMTY			/MULT DELTA X OR Y BY NUMBER OF REMAINING CORDS
	ITELMH			/ADDRESS OF TWO WORD DELTA X OR Y
	SUM3			/ADDRESS OF TWO WORD MULTIPIER
	DBLDIV			/DIVIDE (DELTA X OR Y * REMAIN)/10
	CRD10H			/ADDRESS OF TWO WORD DIVISOR
	TAD	MQHW		/SETUP FOR ADDITION - COPY QUOTIENT
	DCA	ACHW
	TAD	MQLW
	DCA	ACLW
	DBLADD			/ADD CURRENT X OR Y TO THE RESULT OF ABOVE
	PTELMH			/ADDRESS OF TWO WORD CURRENT POSITION
	MQHW			/ADDRESS OF WHERE TO STORE 2 WORD RESULT

NOTLAS,	TAD	MQHW		/GET HIGH WORD OF QUOTIENT
	SMA			/SKIP IF NEGATIVE
	JMP	ACSM1		/POSITIVE - CHECK FOR POSITVE OVERFLOW
	CMA			/TRY TO MAKE AC A ZERO
	SNA	CLA		/SKIP IF OVERFLOW ERROR
	TAD	MQLW		/GET THE LOW WORD
	SMA			/SKIP IF LOW WORD NEGATIVE
	CLA CLL CML RAR		/DEFAULT NUMBER TO -2047
	JMP  I  ACUSUM		/EXIT WITH X OR Y VALUE IN AC
ACSM1,	SZA	CLA		/SKIP IF HIGH WORD EUALS ZERO
	JMP	ACSM2		/WORD TO LARGE - DEFAULT TO MAX
	TAD	MQLW		/GET THE LOW WORD
	SPA			/SKIP IF LOW WORD VALID
ACSM2,	AC3777			/DEFALUT NUMBER TO +2027
	JMP  I  ACUSUM		/EXIT
/
PNTADR,	0
BASITR,	INTRPT
CI,	0
J,	0
BASADR,	0
PNTELM,	0
ITRELM,	0
PTELMH,	0; 0
ITELMH,	0; 0
CRVDVH,	0000; 0200
CRD10H,	0000; 0012
SUM3,	0
SUM2,	0
SUM1,	0
SUM0,	0

	PAGE
/------------------------------------------------------------------------------
/ RSTCUR - RESTORE CURSOR TO CORRECT POSITION AT END OF TEXT STRING
/------------------------------------------------------------------------------
/
/ DOES NOTHING FOR NOW, CHANGED VERSION 23, KAH
/
RSTCUR,	0
	CLA CLL
	JMP  I  RSTCUR
/
/
/
/
/------------------------------------------------------------------------------
/ GTNEGM - DISABLE/ENABLE NEGATE MODE
/------------------------------------------------------------------------------
/
GTNEGM,	0
	GETPRM			/GET NEGATE SELECTION FROM CALLING FIELD
	DCA	NEGFLG		/NOT NEGATED=0 - NEGATED<>0
	JMP  I  GTNEGM		/EXIT
/
/

/------------------------------------------------------------------------------
/ XAREA - DRAW A FILLED RECTANGLE
/------------------------------------------------------------------------------
/
XAREA,	0
	CLA	CLL
	TAD	XPOS2		/GET THE NEW "TO" X CO-ORDINATE AND SAVE
	DCA	ARXPOS		/SAVE IT
	TAD	YPOS2		/GET THE NEW "TO" Y CO-ORDINATE AND SAVE
	DCA	ARYPOS		/SAVE IT
	JMS  I  ARECLP		/GO CHECK IF CLIPPING NEEDED ON AREA FILL
	JMP	NOAREA		/AREA OUTSIDE OF CLIPPING REGION
	TAD	YPOS1		/GET THE 1ST LOGICAL Y CO-ORDINATE
	CLL	RAR		/DIVIDE BY 2
	DCA	PYPOS1		/SAVE IT
	TAD	YPOS2		/GET THE 2ND LOGICAL Y CO-ORDINATE
	CLL	RAR		/DIVIDE BY 2
	DCA	PYPOS2		/SAVE IT
	BLDPOS			/CREATE POSITION CURSOR STRING
	SPOSIT
	TAD	PSAREA		/GET ADDRESS OF STRING
	DCA	AUTO10
/
/ CREATE THE FIGS STRING
/
	TAD	PYPOS2		/SVAE  YPOS1 - YPOS2 AS P2 AND P3 (DC)
	CIA
	TAD	PYPOS1
	JMS I	XSAVED
	TAD	XPOS1		/TEMP=XPOS2 - XPOS1 +1
	CIA
	TAD	XPOS2
	IAC
	DCA	ARTEMP
	TAD	ARTEMP		/SAVE TEMP AS P4 AND P5 (D)
	JMS I	XSAVED
	TAD	ARTEMP		/SAVE TEMP AS P6 AND P7 (D2)
	JMS I	XSAVED

/ DRAW THE FILLED AREA
/
	DRAWIT			/DRAW AN AREA
	SPOSIT			/  AT THIS POSITION
	SAREA			/  AS A FILLED AREA
	AREPAT
NOAREA,	CLA	CLL
	TAD	ARXPOS		/RESET ENDING CO-ORDINATES AS "TO" CO-ORDINATES
	DCA	XPOS1
	TAD	ARYPOS
	DCA	YPOS1
	JMP  I  XAREA		/RETURN
/
ARXPOS,	0
ARYPOS,	0
ARECLP,	ARCLIP
ARTEMP,	0
PSAREA,	SAREP1
XSAVED,	SAVEDX

/ -----------------------------------------------------------------------------
/ GETADR - CREATE ADDRESS OF CHARACTER BIT MAP FROM CHARACTER CODE AND ALPHABET
/ -----------------------------------------------------------------------------
/
GETADR,	0			/GET ADDRESS OF CHAR BIT MAP IN PANEL RAM
	TAD	PALPHT		/ADD POINTER TO CHARACTER SET SELECTED
	DCA	GETATM		/SAVE THE POINTER TO THE CHAR SET BASE ADDRESS
	TAD	DDCHAR		/GET THE GRAPHIC CHAR TO BE DISPLAYED
	TAD	M0040		/ADJUST FOR OFFSET INTO CHAR SET BIT MAP
	DCA	GETAT1		/MULTIPLY BY TEN DECIMAL
	TAD	GETAT1
	CLL RTL
	TAD	GETAT1
	CLL RAL
	TAD  I  GETATM		/ADD BASE ADDRESS OF CHAR SET TO CHAR OFFSET
	JMP  I  GETADR		/EXIT - WITH ADDDRESS OF CHAR BIT MAP IN AC
/
PALPHT,	ALPHTA
ALPHTA,	000; 1700; 3600; 5500
GETATM,	0
M0040,	-40
GETAT1,	0
/
/
/ -----------------------------
/ ARRAY - GENERAL PURPOSE ARRAY
/ -----------------------------
/
ARRAY,	ZBLOCK	16
/
/
/
/-----------------------------------------------------------------------------
/ WMDSLN - DETERMINE IF SHADE TO Y REFERENCE OR Y REFERENCE -2
/-------------------------------------------------------------------------------
/
WMDSLN,	0
	CLA CLL CMA RAL		/-2
	TAD	WRMODE		/GET THE CURRENT WRITING MODE
	SZA	CLA		/SKIP IF WRITING MODE = COMPLEMENT
	JMP  I  WMDSLN		/NOT COMPLEMENT - SHADE TO REFERENCE LINE
	CLA CLL IAC		/SETUP TO CHECK IF Y REFERENCE AFTER SCREEN
	TAD	YREFLG		/GET THE Y REFERENCE FLAG
	SZA	CLA		/SKIP IF AFTER - SHADE TO Y REFERNECE LINE
	CLA CLL CMA RAL		/BEFORE OR ON - SHADE TO Y REFERENCE -2
	JMP  I  WMDSLN		/EXIT TO GET THE Y REFERENCE LINE

/ ---------------------------
/ TEXT GDC PARAMETERS STRINGS
/ ---------------------------
/
/ FOR ZERO BITS
/
TXTPT0,	570; 0; 0; 0; 0; 0; 0; 0; 0
	7777
/
/ FOR ONE BITS
/
TXTPT1,	570; 377; 377; 377; 377; 377; 377; 377; 377
	7777
/
/ ----------------
/ TEXT FIGS STRING
/ ----------------
/
STEXT,	514; 020; 0; 0; 1; 0; 1; 0		/FIGS (MODIFIED IN CODE)
	550					/GCHRD
	7777					/TERMINATOR

	PAGE
/--------------------------------------------------------------------------------
/ LINCHK - ROUTINE TO DETERMINE THE LINES IDENTITY
/------------------------------------------------------------------------------
/	ON EXIT LOCATION "SLPOFS" = ONE OF THE FOLLOWING:
/
/		SLOPE=0 SLOPING DOWNWARD TO LEFT -SLOPE
/		SLOPE=1 SLOPING DOWNWARD TO RIGHT +SLOPE
/		SLOPE=2 SLOPING UPWARD TO LEFT +SLOPE
/		SLOPE=3 SLOPING UPWARD TO RIGHT -SLOPE
/		SLOPE=4 VERTICAL LINE
/		SLOPE=5 HORIZONTAL LINE
/		SLOPE=6 DOT
/
LINCHK,	0
	JMS	CHKY12		/GO CHECK IF Y1 = Y2 AND RETURN WITH SLOPE
	CLA	CLL		/NEEDED HERE
	CNVDBL			/CONVERT SINGLE WORD TO DOUBLE
	XPOS1			/ADDRESS OF WORD TO BE CONVERTED
	TDBLWH			/ADDRESS OF WHERE TO STORE CONVERTED WORD
	CNVDBL			/CONVERT SINGLE WORD TO DOUBLE
	XPOS2			/ADDRESS OF WORD TO BE CONVERTED
	ACHW			/WHERE TO STORE WORDS - SETUP FOR SUBTRACTION
	DBLSUB			/GO GENERATE DELTAX (XPOS2 - XPOS1)
	TDBLWH			/ADDRESS OF WORD TO BE SUBTRACTED
	SLPDXH			/ADDRESS OF WHERE RESULT IS TO BE STORED
/
	CNVDBL			/CONVERT SINGLE WORD TO DOUBLE
	YPOS1			/ADDRESS OF WORD TO BE CONVERTED
	TDBLWH			/ADDRESS OF WHERE TO STORE CONVERTED WORD
	CNVDBL			/CONVERT SINGLE WORD TO DOUBLE
	YPOS2			/ADDRESS OF WORD TO BE CONVERTED
	ACHW			/WHERE TO STORE WORDS - SETUP FOR SUBTRACTION
	DBLSUB			/GO GENERATE DELTAY (YPOS2 - YPOS1)
	TDBLWH			/ADDRESS OF WORD TO BE SUBTRACTED
	SLPDYH			/ADDRESS OF WHERE RESULT IS TO BE STORED
/
	DCA	SLPOFS		/INITIALIZE THE SLOPE OFFSET
	TAD	SLPDXH		/CHECK IF VERTICAL LINE
	SZA	CLA
	JMP	LNCHK1		/IF NOT 0 THEN CHECK FOR HORIZONTAL LINE
	TAD	SLPDXL		/
	SNA	CLA		/SKIP IF NOT VERTICAL LINE
	ISZ	SLPOFS		/INDICATE A VERTICAL LINE
LNCHK1,	TAD	SLPDYH		/CHECK IF A HORIZONTAL LINE
	SZA	CLA
	JMP	LNCHK2		/IF <> 0 CHECK IF LINE PREVIOUS LINE HORIZONTAL
	TAD	SLPDYL		/
	SZA	CLA		/SKIP IF A HORIZONTAL LINE
	JMP	LNCHK2		/NO HORIZONTAL LINE - CONTINUE
	ISZ	SLPOFS		/0 TO 1 OR 1 TO 2
	ISZ	SLPOFS		/1 TO 2 OR 2 TO 3
LNCHK2,	TAD	SLPOFS		/GET THE SLOPE INDICATOR
	SZA	CLA		/SKIP IF NOT A HORIZONTAL,VERTICAL OR DOT LINE
	AC0003			/ADD 3 TO NUMBER
	TAD	SLPOFS		/GET THE SLOPE INDICATOR
	SZA			/SKIP IF NONE OF THE ABOVE
	JMP	LNCHK3		/GO SAVE SLOPE INDICATOR FOR ABOVE TYPE LINES
/
	TAD	SLPDXH		/CHECK IF SLOPING TO LEFT OR RIGHT
	SMA	CLA		/SKIP IF LEFT X1 > X2
	AC1			/TO THE RIGHT X1 < X2
	DCA	SLPOFS		/SAVE THE SLOPE FLAG
	TAD	SLPDYH		/CHECK IF SLOPING DOWN OR UP
	SPA	CLA		/SKIP IF DOWN Y1 < Y2
	AC0002			/UP Y1 > Y2
	TAD	SLPOFS		/GET THE PREVIOUS SLOPE FROM X
LNCHK3,	DCA	SLPOFS		/SAVE THE SLOPE FLAG
	DCA	XDIF		/CLEAR X AND Y TRAVERSING DIRECTIONS
	DCA	YDIF		/
	TAD	SLPOFS		/GET THE LINE INDICATOR
	TAD	M0006		/CHECK IF A DOT
	SNA	CLA		/SKIP IF NOT A DOT
	JMP	LNCHKE		/NO - THE LINE IS A DOT  - EXIT
	TAD	SLPDXH		/GET THE HIGH WORD OF X CALCULATED SLOPE
	SPA	CLA		/SKIP IF POSITIVE X1 < X2
	CLA CLL CMA RAL		/SET X TRAVERSING DIRECTION = -1
	IAC			/SET X TRAVERSING DIRECTION = +1
	DCA	XDIF		/SAVE THE X TRAVERSING DIRECTION
	TAD	SLPDYH		/GET THE HIGH WORD OF Y CALCULATED SLOPE
	SPA	CLA		/SKIP IF POSITVE Y1 < Y2
	CLA CLL CMA RAL		/SEY Y TRAVERSING DIRECTION = -1
	IAC			/SET Y TRAVERSING DIRECTION = +1
	DCA	YDIF		/SAVE THE Y TRAVERSING DIRECTION
	TAD	SLPOFS		/GET THE LINE INDICATOR
	TAD	M0004		/CHECK IF LINE HORIZONTAL OR VERTICAL
	SPA			/SKIP IF HORIZONTAL OR VERTICAL LINE
	JMP	LNCHKE		/EXIT NOT HORIZONTAL OR VERTICAL
	SNA			/SKIP IF HORIZONTAL LINE
	DCA	XDIF		/VERTICAL LINE - CLEAR X TRAVERSING DIRECTION
	SZA	CLA		/SKIP IF VERTICAL LINE
	DCA	YDIF		/HORIZONTAL LINE - CLEAR Y TRAVERSING DIRECTION
LNCHKE,	CLA	CLL		/NEEDED TO CLEAN UP THE AC
	JMP  I  LINCHK		/EXIT BACK TO CALLER
/
TDBLWH,	0; 0
M0006,	-0006

/-----------------------------------------------------------------------------
/ CHKY12 - CHECK IF Y1/2 = Y2/2 - IF YES SET Y1=Y2 - RETURN WITH SLOPE IN AC
/------------------------------------------------------------------------------

CHKY12,	0
	TAD	YPOS1		/GET Y POSITION 1
	CLL	RAR		/DIVIDE IT BY 2
	DCA	HALFY1		/SAVE Y1/2
	TAD	YPOS2		/GET Y POSITION 2\
	CLL	RAR		/DIVIDE BY 2 TO GET EQIVALENT RASTER LINE
	DCA	HALFY2		/SAVE Y2/2
	TAD	HALFY1		/COMPARE Y1/2 AGAINST Y2/2
	CIA
	TAD	HALFY2		/GET IT
	SZA			/ARE THE TWO POINTS EQUAL
	JMP  I  CHKY12		/NO - EXIT
	TAD	YPOS2		/YES THEN MAKE 1ST Y POSITION = "TO" Y
	DCA	YPOS1		/SAME RASTER LINE
	JMP  I  CHKY12		/EXIT Y1=Y2 NOW
/
HALFY1,	0
HALFY2,	0

/------------------------------------------------------------------------------
/ OVRLAY - OVERLAY EQ1 AND EQ2 POINTERS
/------------------------------------------------------------------------------
/
OVRLAY,	0
	DCA	AUTO10		/SAVE THE POINTER TO OVERLAY TABLE
	TAD	M0005		/SETUP TO OVERLAY 5 ADDRESS IN EQUATION
	DCA	OVRCNT		/SAVE THE OVERLY COUNTER
OVRLY1,	TAD  I  AUTO10		/GET THE ADRESS TO BE OVERLAYED FROM TABLE
	DCA	OVRTMP		/SAVE THE ADDRESS
	TAD	OVRADR		/GET THE ADDRESS TO OVERLAY
	DCA  I  OVRTMP		/OVERLAY EQUATION'S ADDRESS
	ISZ	OVRCNT		/DONE ?
	JMP	OVRLY1		/NO - OVERLAY NEXT ADDRESS
	JMP  I  OVRLAY		/RETURN
/
OVRADR,	0
OVRCNT,	0
OVRTMP,	0
M0005,	-0005

/-----------------------------------------------------------------------------
/ DHVLIN - DOT - HORIZONTAL - VERTICAL LINE CHECK -(IGNORE VERT IF COMP MODE)
/------------------------------------------------------------------------------
/
DHVLIN,	0
	TAD	M0004		/-4
	TAD	SLPOFS		/GET THE LINE INDICATOR
	SPA			/SKIP IF DOT, HORIZONTAL OR VERTICAL LINE
	JMP	SLPEXT		/EXIT CALL +1 FOR A SLOPED LINE
	SZA	CLA		/SKIP IF VERTICAL LINE
	JMP	DHVEXT		/EXIT CALL+3 FOR A DOT AND HORIZONTAL LINE
	CLA CLL CMA RAL		/-2
	TAD	WRMODE		/GET THE WRITING MODE
	SNA	CLA		/EXIT CALL+3 IF NOT COMPLEMENT MODE
	JMS  I  XTRVLN		/COMP MODE - RET CALL+1 OR CALL+2(TRUE VERT)
DHVEXT,	ISZ	DHVLIN		/EXIT - DOT,HORIZONTAL,VERTICAL(NOT COMP)
	ISZ	DHVLIN		/EXIT - VERTICAL LINE COMPLEMENT MODE
SLPEXT,	CLA	CLL		/EXIT - SLOPED LINE
	JMP  I  DHVLIN		/EXIT BACK TO CALL+1, CALL+2 OR CALL+3
/
XTRVLN,	TRVLIN			/GO CHECK IF TRUE VERTICAL LINE

	PAGE
/------------------------------------------------------------------------------
/ LINE - CHECK IF LINE CAN BE DRAWN - CLIP LINE - SHADE TO Y - DRAW LINE
/------------------------------------------------------------------------------
/
LINE,	0
	CLA	CLL
	TAD	XPOS1
	DCA	UNMODX
	TAD	YPOS1
	DCA	UNMODY
	JMS  I  CHKLIN		/GO CHECK FOR TYPE OF LINE AND SLOPE
	JMS  I  POSNEW		/GO UPDATE POSITION TO FIRST DRAWING POSITION
	JMS  I  CHKLIN		/GO CHECK FOR TYPE OF LINE AND SLOPE AGAIN
	TAD	XPOS1		/GET THE "FROM" X POSITION
	DCA	XTEMP1		/SAVE IT
	TAD	YPOS1		/GET THE "FROM "Y" POSITION
	DCA	YTEMP1		/SAVE IT
	TAD	XPOS2		/GET THE "TO" X CO-ORDINATE
	DCA	XTEMP2		/SAVE IT
	TAD	YPOS2		/GET THE "TO" Y CO-ORDINATE
	DCA	YTEMP2		/SAVE IT
	CLA CLL CMA RTL		/INITIALIZE TRY COUNTER TO -3
	DCA	TRYCNT		/SAVE THE COUNTER
TRYAGN,	JMS  I  XCKCLP		/GO CHECK POSITION OF CO-ORDINATES
	JMP	SHDLIN		/ALL POINT ON SCREEN - GO CHECK IF SHADE OR LINE
	JMP	LINOUT		/POINTS TO LEFT,RIGHT,ABOVE OR BELOW SCREEN
	JMS  I  LINCLP		/GO DO LINE CLIPPING TO SCREEN REGION
	SKP	CLA		/SLOPED LINE OFF SCREEN - INVISIBLE LINE
	JMP	SHDLIN		/CO-ORDINATES CLIPPED - GO CHECK IF SHADING
/
	TAD	SHDFLG		/GET THE SHADE FLAG
	SNA	CLA		/SKIP IF SHADING IS ENABLED
	JMP	NOLINE		/LINE OFF THE SCREEN - EXIT LINE INVISIBLE
	ISZ	TRYCNT		/CHECK TO SEE IF THIRD TRY
	SKP	CLA		/SKIP IF NOT 3RD
	JMP	NOLINE		/LINE OFF SCREEN - CAN'T DRAW IT
	TAD	XFLAG1		/CHECK IF X POS1 IS ON THE SCREEN
	SNA	CLA		/SKIP IF NOT
	JMP	Y2INTR		/IT IS - USE Y INTERCEPT VALUE FOR YPOS2
	TAD	XFLAG2		/CHECK IF XPOS2 ON THE SCREEN
	SZA	CLA		/SKIP IF IT IS
	JMP	Y2INTR		/IT ISN'T - USE Y INTERCEPT FOR YPOS2
	TAD  I  EQ1SVX		/GET XPOS1 ASSUMED INTERCEPT VALUE
	DCA	XPOS1		/SAVE IT
	TAD  I  EQ1SVY		/GET YPOS1 INTERCEPT VALUE
	DCA	YPOS1		/SAVE IT
	JMP	TRYAGN		/GO TRY AGAIN - SHOULD RETURN TO LINOUT
Y2INTR,	TAD  I  EQ3SVX		/GET XPOS2 ASSUMED INTERCEPT VALUE
	DCA	XPOS2		/SAVE IT
	TAD  I  EQ3SVY		/GET YPOS2 INTERCEPT VALUE
	DCA	YPOS2		/SAVE IT
	JMP	TRYAGN		/GO TRY AGAIN - SHOULD RETURN TO LINOUT
/
LINOUT,	TAD	SHDFLG		/GET THE SHADE FLAG
	SNA	CLA		/SKIP IF SHADING IS ENABLED
	JMP	NOLINE		/LINE TO LEFT,RIGHT,TOP OR BOTTOM OF SCREEN
	CLA CLL CMA RTL		/-3 CHECK IF LINE TO LEFT OR RIGHT
	TAD	LININD		/GET THE LINE INDICATOR
	SPA			/SKIP IF BEFORE OR AFTER SCREEN
	JMP	NOLINE		/LINE TO LEFT OR RIGHT - CAN NOT DRAW OR SHADE
	SZA	CLA		/SKIP IF LINE AFTER THE SCREEN
	JMS  I  XWMDSL		/GET Y REFERENCE LINE OFFSET (0 OR -2)
	SGNCHK			/ADD THE TWO NUMBERS CHECKING FOR OVERFLOW
	YREFLN			/ADDRESS OF SECOND NUMBER TO ADD
	DCA	YPOS2		/SAVE IT
	FAREA			/GO DO AREA FILL
	JMP	NOLINE		/EXIT - SHADING COMPLETE FOR LINE OFF SCREEN
/
SHDLIN,	JMS  I  CHKLIN		/RECALCULTATE TYPE OF LINE
	TAD	SHDFLG		/GET THE SHADE FLAG
	SZA	CLA		/IS SHADE TO Y ENABLED
	JMP	SHADIT		/YES - GO SHADE TO Y REFERENCE LINE
	JMS  I  XDRWLN		/GO DRAW THE LINE
	JMP	NOLINE		/GO RESTORE LAST POSITION OF LINE TO PRESENT
SHADIT,	JMS  I  DOSHDE		/GO DO LINE SHADING - SHADE TO Y
NOLINE,	CLA	CLL		/CLEAN UP THE AC - NEEDED
	TAD	XTEMP2		/GET THE SAVED "TO" X CO-ORDINATE
	DCA	XPOS1		/SAVE AS PRESENT X
	TAD	YTEMP2		/GET THE SAVED "TO" Y CO-ORDINATE
	DCA	YPOS1		/SAVE AS PRESENT Y
	JMP  I  LINE		/EXIT BACK TO CALLER
/
TRYCNT,	0			/NUMBER OF TRIES WHEN LINE OFF SCREEN (SHADE)
CHKLIN,	LINCHK			/ROUTINE TO CHECK TYPE OF LINE AND SLOPE DIR
POSNEW,	NEWPOS			/ROUTINE TO CALCULATE STARTING DRAWING POSITION
XCKCLP,	CHKCLP			/ROUTINE TO CHECK CO-ORDINATES OF LINE
LINCLP,	LNSLOP			/ROUTINE TO DO ACTUAL LINE CLIPPING
XDRWLN,	DRWLIN			/ROUTINE TO DO ACTUAL LINE DRAWING
DOSHDE,	SHADE			/ROUTINE TO SHADE TO Y REFERENCE
EQ1SVX,	EQ1ASX
EQ1SVY,	EQ1YL			/ADDRESS OF EQ1 Y INTERCEPT POINT
EQ3SVX,	EQ3ASX
EQ3SVY,	EQ3YL			/ADDRESS OF EQ3 Y INTERCEPT POINT
YTEMP1,	0			/SAVED "FROM" Y CO-ORDINATE
YTEMP2,	0			/SAVED "TO" Y CO-ORDINATE
UNMODX,	0
UNMODY,	0
/

/-----------------------------------------------------------------------------
/ WSHADL - CHOOSE WHICH SHADE LINE TO USE TO DRAW TO REFERENCE
/------------------------------------------------------------------------------
/
WSHADL,	0
	TAD	YREF		/GET THE Y REFERENCE
	CLL	RAR		/DIVIDE IT BY 2
	CIA			/NEGATE IT FOR COMPARISONS LATER
	DCA	NEGHYR		/SAVE NEGATED YREF/2
	JMS  I  Y12CHK		/IF Y1/2 = Y2/2 THEN Y1=Y2 - SLOPE RETURNED
	SPA	CLA		/IS Y1/2 <= Y2/2 ?
	JMP	SHADV2		/NO Y1/2 > Y2/2 - GO CHECK THESE POSITIONS TO YREF
	TAD	NEGHYR		/GET NEGATED YREF/2 - CHECK IF YREF/2 <= Y1/2
	TAD  I  HLFYP1		/Y1/2
	SMA	CLA		/IS YREF<=Y1
	JMP	SHADV1		/YES - SET "FROM" Y TO Y REFERENCE
	TAD	NEGHYR		/CHECK IF Y2/2 <= VREF/2
	TAD  I  HLFYP2		/ Y2/2
	SMA SZA CLA		/Y2 <= YREF ?
	JMP	SHADVL		/NO-GO DRAW VERTICAL LINE - IT CROSSES REFERENCE
	JMS  I  XWMDSL		/GO GET Y REFERENCE LINE OFFSET (0 OR -2)
SHADV4,	TAD	YREF		/
	DCA	YPOS2		/SET "TO" CO-ORDINATE TO REF OR REF -2
	JMP	SHADVL		/GO DRAW VERTICAL LINE TO Y REFERENCE LINE
SHADV2,	TAD	NEGHYR		/CHECK IF Y1/2 <= YREF/2
	TAD  I  HLFYP1		/ Y1/2
	SMA SZA CLA		/IS Y1<=YREF ?
	JMP	SHADV3		/NO - GO CHECK IF YREF<=Y2
	JMS  I  XWMDSL		/GO GET Y REFERNECE LINE OFFSET (0 OR -2)
SHADV1,	TAD	YREF		/
	DCA	YPOS1		/SET "FROM" CO-ORDINATE TO REF OR REF -2
	JMP	SHADVL		/GO DRAW VERTICAL LINE FROM Y REFERENCE
SHADV3,	TAD	NEGHYR		/CHECK IF YREF/2 <= Y2/2
	TAD  I  HLFYP2
	SMA	CLA		/IS YREF<=Y2 ?
	JMP	SHADV4		/YES - SET "TO" CO-ORDINATE TO Y REFERENCE
SHADVL,	JMP  I  WSHADL		/EXIT
/
XWMDSL,	WMDSLN
Y12CHK,	CHKY12
NEGHYR,	0
HLFYP1,	HALFY1
HLFYP2,	HALFY2

	PAGE
/-----------------------------------------------------------------------------
/ SHADE - SHADE ALL LINES TO A Y REFERENCE LINE
/--------------------------------------------------------------------------------
/
SHADE,	0
	JMS  I  XDHVLN		/GO CHECK TYPE OF LINE AND WRITING MODE
	JMP	SHADE1		/SLOPED LINE
	JMP  I  SHADE		/VERTICAL LINE AND COMPLEMENT MODE EXIT
	TAD	XTEMP1		/GET THE REAL "FROM" X POSITION
	DCA	XPOS1		/SAVE IT
	TAD	XTEMP2		/GET THE REAL "TO" X POSITION
	DCA	XPOS2		/SAVE IT
	FAREA			/DO AREA FILL OF HORIZONTAL,VERITCAL,DOT LINE
	JMP  I  SHADE		/EXIT HORIZONTAL LINE OR DOT SHADING DONE
/
SHADE1,	DCA	MQLW		/MULTIPLY DELTAY BY 4096
	TAD	SLPDYL		/
	DCA	MQHW		/*4096
	TAD	SLPDYH		/
	DCA	ACLW		/SIGN EXTENTION*4096
	TAD	SLPDYH		/SIGN EXTEND THE SIGN EXTENTION
	SPA	CLA		/SKIP IF POSITIVE SLOPE
	CLA	CMA		/NEGATIVE SLOPE
	DCA	ACHW		/SAVE THE SIGN EXTENTION WORD
	DBLDIV			/DIVDE DELTAY*4096/DELTAX
	SLPDXH			/ADDRESS OF DELTAX
	TAD	XDIF		/GET THE X TRANSVERSAL DIRECTION
	SMA	CLA		/SKIP IF GOING RIGHT TO LEFT
	JMP	SHADE3		/GOING LEFT TO RIGHT
	JMS  I  LCOMP		/NEGATE THE SLOPE
	MQHW			/ADDRESS OF QUOTIENT
SHADE3,	TAD	MQHW		/GET THE HIGH WORD OF QUOTIENT
	DCA	LSLOPH		/SAVE IT
	TAD	MQLW		/GET THE LOW WORD OF QUOTIENT
	DCA	LSLOPL		/SAVE IT
/
	TAD	YPOS1		/GET THE FIRST Y POSTION
	DCA	YIH		/SAVE AS Y1*4096
	DCA	YIL		/
	TAD	XPOS1		/GET THE STARTING X POSITION
	DCA	XI		/SAVE IT
	TAD	YPOS1		/GET THE STARTING Y
	DCA	YI		/SAVE IT
	TAD	XPOS2		/GET THE ENDING X POSITION ON THE SCREEN
	DCA	ENDX		/SACE IT FOR COMPARISONS
/
	TAD	XPOS1		/CHECK IF STARTING X = REAL STARTING X
	CIA
	TAD	XTEMP1		/REAL X
	SNA	CLA		/ARE THEY EQUAL
	JMP	SHADE5		/YES - THEN START SHADING WITH LINES HERE
	TAD	XDIF		/+/- X - UPDATE X SO THAT AREA FILL WON'T OVRLY
	CIA
	TAD	XPOS1		/UPDATE X POSITION BY + OR - ONE
	DCA	XPOS1		/SAVE THE UPDATED X POSITION
	TAD	XTEMP1		/GET THE REAL X
	DCA	XPOS2		/SAVE IT
	TAD	YREF		/GET THE Y REFERENCE LINE
	DCA	YPOS2		/SAVE IT
	FAREA			/GO DO AREA FILLING FOR PART OF LINE OFF SCREEN
	TAD	XI		/GET THE STARTING X
	DCA	XPOS1		/RESTORE IT FOR LINE SHADING ON THE SCREEN
/
SHADE5,	TAD	YIH		/SEUP "FROM" Y
	DCA	YPOS1
	TAD	XPOS1		/SETUP "TO" X FROM THE "FROM" X
	DCA	XPOS2
	TAD	YREF		/SETUP "TO" Y
	DCA	YPOS2
	JMS  I  CHKREF		/GO CHECK WHICH REFERENCE LINE TO DRAW TO
	FAREA			/GO DRAW THE LINE
	TAD	YIH		/RESTORE Y POSITION 1
	DCA	YPOS1
	TAD	XPOS1		/CHECK IF DONE SHADING
	CIA
	TAD	ENDX
	SNA	CLA		/SKIP IF MORE LINES TO SHADE
	JMP	SHADE6		/GO FINISH THE SHADING WITH AREA FILLS
	TAD	XPOS1		/GET THE PRESENT X POSITION
	TAD	XDIF		/UPDATE IT BY +1 OT -1
	DCA	XPOS1		/SAVE AS NEW X POSITION
	TAD	YIH		/SETUP FIRST WORD OF DOUBLE PRECISION ADD
	DCA	ACHW
	TAD	YIL
	DCA	ACLW
	DBLADD			/ADD YI + SLOPE
	LSLOPH			/ADDRESS OF SECOND WORD TO ADD
	YIH			/STORE RESULTS OF ADDITION IN THIS ADDRESS
	MINMAX
	YIH
	YIHFLG
	MINY
	MAXY
	TAD	YIHFLG		/CHECK UPDATED YIH TO STILL BE ON THE SCREEN
	SNA	CLA		/SKIP IF NOT
	JMP	SHADE5		/GO DRAW THIS LINE AND CHECK IF DONE
	CLA CLL CMA		/-1
	ISZ	YIHFLG		/CHECK IF BEFORE THE SCREEN
	SKP	CLA		/BEFORE THE SCREEN - CLEAR THE AC
	TAD	MAXY		/RESET YIH TO THE BOUNDRY
	ISZ	YIHFLG		/NOW SKIP IF BEFORE THE SCREEN
	SKP
	TAD	MINY		/RESET TO BEGINNING OF THE SCREEN
	DCA	YIH		/RESTORE YIH TO THE SCREEN BOUNDRY
	JMP	SHADE5		/GO DRAW THIS LINE AND CHECK IF DONE
/
SHADE6,	TAD	XPOS1		/CHECK IF ENDING SHADE X = REAL ENDING X
	CIA
	TAD	XTEMP2		/REAL X
	SNA	CLA		/ARE THEY EQUAL
	JMP  I  SHADE		/YES - EXIT COMPLETE LINE NOW DRAWN
	TAD	XPOS1		/GET THE CURRENT X POSITION
	TAD	XDIF		/+/- X SO THAT AREA FILL WON'T OVERLAY LAST X
	DCA	XPOS1		/SAVE IT
	TAD	XTEMP2		/GET THE REAL ENDING X
	DCA	XPOS2		/SAVE IT
	TAD	YREF		/GET THE Y REFERENCE LINE
	DCA	YPOS2		/SAVE IT
	FAREA			/GO DO AREA FILL FOR PART OF LINE OFF SCREEN
	JMP  I  SHADE
/
XDHVLN,	DHVLIN			/CHECK TYPE OF LINE AND WRITING MODE IF VERTICAL
CHKREF,	WSHADL			/GO CHECK WHICH REFERENCE LINE TO SHADE TO
YIHFLG,	0
LCOMP,	COMP
ENDX,	0
XI,	0
YI,	0
YIH,	0
YIL,	0
LSLOPH,	0
LSLOPL,	0

/------------------------------------------------------------------------------
/ TRMNTE - TERMINATE GRAPHICS - SCREEN ERASED - CURSOR DISABLED - INIT SOFTWARE
/------------------------------------------------------------------------------
/
TRMNTE,	0
	JMS  I  XPWRUP		/DISABLE CURSOR - RESET TEXT AND GRAPHIC SCREENS
	JMS  I  XINIT		/INIT SOFTWARE,CHAR SETS, AND CLEAR SCREEN
	JMP  I  TRMNTE		/EXIT
/
XPWRUP,	PWRUP			/DISABLE CURSOR - HARDWARE RESET
XINIT,	INIT			/INITIALIZE GRAPHICS SOFTWARE

	PAGE
/-----------------------------------------------------------------------------
/ DRWLIN - SETUP GDC LINE DRAWING PARAMETERS AND DRAW THE LINE
/-----------------------------------------------------------------------------
/
DRWLIN,	0
	TAD	YPOS1		/GET THE 1ST LOGICAL Y CO-ORDINATE OF LINE
	CLL	RAR		/DIVIDE IT BY TWO
	DCA	PYPOS1		/SAVE AS PHYSICAL Y CO-ORDINATE
	TAD	YPOS2		/GET THE 2ND LOGICAL Y CO-ORDINATE OF LINE
	CLL	RAR		/DIVIDE IT BY TWO
	DCA	PYPOS2		/SAVE AS PHYSICAL Y CO-ORDINATE
	BLDPOS			/CREATE POSITION CURSOR STRING
	SPOSIT
/
/ CREATE THE FIGS STRING
/
	TAD	PSLINE		/GET ADDRESS OF STRING
	DCA	AUTO10
	TAD	XPOS1		/DELTAX = XPOS2 - XPOS1
	CIA
	TAD	XPOS2
	DCA	DELTAX
	TAD	PYPOS1		/DELTAY = YPOS2 - YPOS1
	CIA
	TAD	PYPOS2
	DCA	DELTAY
	TAD	DELTAX		/CHECK IF RIGHT OR LEFT FOR OCTANT SELECTION
	SMA CLA
	AC1			/BIT <11> SET/RESET ACCORDINGLY
	DCA	OFFSET
	TAD	DELTAY		/CHECK IF UP OR DOWN FOR OCTANT SELECTION
	SPA CLA			/(DOWN IS +Y, REMEMBER)
	AC0002			/BIT <10> SET/RESET ACCORDINGLY
	TAD	OFFSET
	DCA	OFFSET
	TAD	DELTAX		/ABS(DELTAX)
	SPA
	CIA
	DCA	DELTAX
	TAD	DELTAY		/ABS(DELTAY)
	SPA
	CIA
	DCA	DELTAY
	TAD	DELTAY		/ABS(DELTAX) - ABS(DELTAY)
	CIA
	TAD	DELTAX
	DCA	DIFABS
	TAD	DIFABS		/CHECK IF STEEP OR GRADUAL FOR OCTANT SELECTION
	SMA CLA
	AC0004			/BIT <09> SET/RESET ACCORDINGLY
	TAD	OFFSET
	DCA	OFFSET
	TAD	DIFABS		/DETERMINE INDEPENDENT AXIS (LARGER OF X OR Y)
	SMA CLA
	JMP	LINE2		/GO DO X AS INDEPENDENT AXIS
	TAD	DELTAY		/DO Y AS INDEPENDENT AXIS
	DCA	DELTAI
	TAD	DELTAX
	DCA	DELTAD
	JMP	LINE4
LINE2,	TAD	DELTAX		/DO X AS INDEPENDENT AXIS
	DCA	DELTAI
	TAD	DELTAY
	DCA	DELTAD
LINE4,	TAD	POCTAN		/DETERMINE OCTANT FROM DIRECTIONS
	TAD	OFFSET
	DCA	OFFSET		/GETS THE ADDRESS OF OCTANT NUMBER
	TAD I	OFFSET		/GETS THE OCTANT NUMBER
	TAD	K0010		/MAKES A 'LINE' COMMAND
	DCA I	AUTO10		/SAVE AS P1
	TAD	DELTAI		/SAVE ABS(DELTAI) AS P2 AND P3 (DC)
	JMS  I  LSAVDX
	TAD	DELTAD		/SAVE 2*ABS(DELTAD) - ABS(DELTAI)
	CLL RAL			/  AS P4 AND P5 (D)
	CIA
	TAD	DELTAI
	CIA
	JMS  I  LSAVDX
	TAD	DELTAI		/SAVE 2*(ABS(DELTAD) - ABS(DELTAI))
	CIA			/  AS P6 AND P7 (D2)
	TAD	DELTAD
	CLL RAL
	JMS  I  LSAVDX
	TAD	DELTAD		/SAVE 2*(ABS(DELTAD)) AS P8 AND P9 (D1)
	CLL RAL
	JMS  I  LSAVDX
/
/ DRAW THE LINE
/
	DRAWIT			/DRAW A LINE
	SPOSIT			/  AT THIS POSITION
	SLINE			/  AS A LINE
	LINPAT
/
	CLA CLL
	JMP I	DRWLIN		/RETURN
/
LSAVDX,	SAVEDX
PSLINE,	SLINE
POCTAN,	OCTANT
OCTANT,	7; 0; 4; 3; 6; 1; 5; 2
DELTAX,	0
DELTAY,	0
DELTAI,	0
DELTAD,	0
OFFSET,	0
DIFABS,	0
/
SAVCUR,	0			/SAVE PRESENT CURSOR POSITION (SCREEN DUMP)
	TAD	XPOS1		/GET THE PRESENT X POSITION
	DCA	SAVX1		/SAVE IT
	TAD	YPOS1		/GET THE PRESENT Y POSITION
	DCA	SAVY1		/SAVE IT
	JMP  I  SAVCUR		/EXIT PRESENT CURSOR POSITION SAVED

CURRST,	0			/RESTORE PRESENT CURSOR POSITION (SCREEN DUMP)
	TAD	SAVX1		/GET THE CURSOR X POSITION SAVED
	DCA	XPOS1		/RESTORE THE X POSITION
	TAD	SAVY1		/GET THE CURSOR Y POSITION SAVED
	DCA	YPOS1		/RESTORE THE Y POSITION
	JMP  I  CURRST		/EXIT CURSOR POSITION RESTORED
/
SAVX1,	0
SAVY1,	0
/
SSET,	443; 7777		/WDAT COMMAND FOR 'SET'
SCLEAR,	442; 7777		/WDAT COMMAND FOR 'RESET'
SCOMP,	441; 7777		/WDAT COMMAND FOR 'COMP'
/
/ TABLE OF THE LOGICAL SCREEN REGION CO-ORDINATES
/
LREGIN,	SRNLHX			/LEFT HORIZONTAL X
	SRNUVY			/UPPER VERTICAL Y
	SRNRHX-1		/RIGHT HORIZONTAL X
	SRNLVY-1		/LOWER VERTICAL Y

	PAGE
/-----------------------------------------------------------------------------
/ ARCLIP - ROUTINE TO DO CLIPPING OF X AND Y CO-ORDINATES FOR AREA FILLS
/-----------------------------------------------------------------------------

ARCLIP,	0
	JMS  I  ACKCLP		/CHECK IF CLIPPING OF CO-ORDINATES NEEDED
	JMP	AREXIT		/ALL POINTS ON SCREEN - GO CHECK DIRECTION
	JMP	AREANO		/AREA OFF THE SCREEN - CAN'T DO AREA FILL
	JMS  I  XVCLP		/GO DO VERTICAL CLIPPING IF NEEDED
	JMS  I  XHCLP		/GO DO HORIZONTAL CLIPPING IF NEEDED
AREXIT,	ISZ	ARCLIP		/BUMP RETURN TO DO AREA FILL
/
	TAD	XPOS2		/CHECK IF XPOS2 > XPOS1
	CIA
	TAD	XPOS1
	SPA	CLA		/SKIP IF XPOS1 >= XPOS2
	JMP	ARYCHK		/VALUES IN CORRECT SEQUENCE - GO CHECK Y VALUES
	TAD	XPOS2		/EXCHANGE XPOS2 WITH XPOS1
	DCA	TEMPAR		/SAVE XPOS2
	TAD	XPOS1
	DCA	XPOS2		/XPOS2 GET VALUE OF XPOS1
	TAD	TEMPAR
	DCA	XPOS1		/XPOS1 GET VALUE OF XPOS2
ARYCHK,	JMS  I  ACKREF		/GO CHECK SHADING AND REFERENCE LINE
	TAD	YPOS2		/CHECK IF YPOS2 > YPOS1
	CIA
	TAD	YPOS1
	SMA	CLA		/SKIP IF YPOS2 > YPOS1
	JMP	AREANO		/VALUES IN CORRECT SEQUENCE - GO DO AREA FILL
	TAD	YPOS2		/EXCHANGE YPOS2 WITH YPOS1
	DCA	TEMPAR		/SAVE YPOS2
	TAD	YPOS1
	DCA	YPOS2		/YPOS2 GET VALUE OF YPOS1
	TAD	TEMPAR
	DCA	YPOS1		/YPOS1 GET VALUE OF YPOS2
/
AREANO,	JMP  I  ARCLIP		/HERE IF NO AREA FILL TO BE DONE - RETURN CALL +1
/
XVCLP,	VCLIP			/VERTICAL LINE CLIPPING ROUTINE
XHCLP,	HCLIP			/HORIZONTAL LINE CLIPPING ROUTINE
ACKCLP,	CHKCLP			/ROUTINE TO CHECK IF CLIPPING NEEDED
ACKREF,	REFACK
TEMPAR,	0

/-----------------------------------------------------------------------------
/ NEWPOS - CALCULATE FIRST DRAWING POSITION FOR LINE
/--------------------------------------------------------------------------------
/
NEWPOS,	0
	TAD	SHDFLG		/GET THE SHADE FLAG
	SNA	CLA		/SKIP IF SET
	JMP	GTNWPS		/GO GET NEXT DRAWING POSITION
	CLA CLL CMA RAL		/-2
	TAD	WRMODE		/GET THE CURRENT WRITING MODE
	SNA	CLA		/SKIP IF WRITING MODE NOT COMPLEMENT MODE
	JMP	GTNWPS		/COMPLEMENT MODE - GET NEXT DRAWING POSITION
	ISZ	NEWPOS		/UPDATE POINTER - NO NEED TO CHECK LINE AGAIN
	JMP  I  NEWPOS		/EXIT TO CALLER +2
GTNWPS,	TAD	SLPOFS		/GET THE LINE TYPE AND SLOPE INDICATOR
	TAD	MM0006		/CHECK IF THE LINE IS A DOT
	SNA			/SKIP IF NOT A DOT
	JMP  I  NEWPOS		/A DOT EXISTS - USE THIS AS DRAWING POSITION
	IAC			/UPDATE LINE TYPE INDICATOR
	SZA			/IS THE LINE A HORIZONTAL LINE
	JMP	NWPOS0		/NO - GO CHECK IF VERTICAL LINE
NEWPS,	CLA			/NEEDED FOR ANOTHER ENTRANCE FROM SAME ROUTINE
	TAD	XPOS1		/YES - GET PRESENT STARTING X POSITION
	TAD	XDIF		/GET THE TRAVERSING X OFFSET
	DCA	XPOS1		/SAVE THIS AS THE NEW STARTING X POSITION
	JMP  I  NEWPOS		/EXIT - STARTING X POSITION UPDATED
NWPOS0,	IAC			/UPDATE THE LINE TYPE INDICATOR
	SZA	CLA		/IS THE LINE A VERTICAL LINE ?
	JMP	NWPOS3		/NO - THEN A SLOPED LINE NEED Y INTERCEPT
NWPOS1,	JMS  I  NWPOSY		/GO UPDATE THE Y POSITION BY 1 OR 2
	JMP  I  NEWPOS		/EXIT
NWPOS3,	TAD	SHDFLG		/GET THE SHADE FLAG
	SZA	CLA		/IS SHADING TURNED ON
	JMP	NWPOS6		/YES - GO CALCULATE Y INTERCEPT
	TAD	SLPDXH		/SETUP TO DO DELTAX-DELTAY SUBRACTION
	DCA	ACHW		/
	TAD	SLPDXL		/
	DCA	ACLW		/
	TAD	ACHW		/GET DELTAX VALUE SAVED
	SMA	CLA		/IS IT NEGATIVE
	JMP	NWPOS4		/NO - GO GET DELTAY/2
	JMS  I  NPCOMP		/YES - MAKE IT ABSOLUTE
	ACHW
NWPOS4,	CLA	CLL		/DIVIDE DELTAY BY 2 MAINTAING THE SIGN
	TAD	SLPDYH		/GET THE HIGH WORD OF DELTAY
	SPA			/SKIP IF WORD POSITIVE LINK ALREADY CLEARED
	CML			/REPLICATE THE NEGATIVE SIGN BIT
	RAR			/DIVIDE HIGH WORD BY 2 - LINK = LSB
	DCA	NWPSYH		/SAVE THIS AS NEW HIGH WORD/2
	TAD	SLPDYL		/GET THE LOW WORD OF DELTAY
	RAR			/DIVIDE IT BY 2 - LSB IS LOST
	DCA	NWPSYL		/SAVE THIS AS FINAL DELTAY/2
	TAD	NWPSYH		/GET DELTAY/2 HIGH WORD
	SMA	CLA		/IS IT NEGATIVE
	JMP	NWPOS5		/NO - GO SUBTRACT DELTAY FROM DELTAX
	JMS  I  NPCOMP		/MAKE DELTAY POSITIVE
	NWPSYH
NWPOS5,	DBLSUB			/SUBRACT DELTAY FROM DELTAX (DELTAX-DELTAY)
	NWPSYH			/ADDRESS OF WORD TO BE SUBRACTED
	NWPSYH			/ADDRESS OF WHERE TO STORE RESULTS
	TAD	NWPSYH		/GET THE HIGH WORD OF THE SUBTRACTION
	SMA	SZA		/DELTAY >= DELTAX
	JMP	NEWPS		/NO - GO INCREASE X POSITON
	SZA	CLA		/SKIP IF DELTA X COULD = DELTA Y
	JMP	NWPOS1		/HIGH WORD INDICATES DELTAX < DELTAY
	TAD	NWPSYL		/CHECK THE LOW WORD TO MAKE SURE
	SZA	CLA		/SKIP IF DELTA X = DELTAY
	JMP	NEWPS		/LOW WORD INDICATES DELTAX > DELTAY
	TAD	XPOS1		/UPDATE THE X POSITION BY 1
	TAD	XDIF		/
	DCA	XPOS1		/SAVE THE UPDATED X POSITION
	JMP	NWPOS1		/GO UPDATE THE Y POSITION BY + OR - 2
NWPOS6,	TAD	XPOS1		/GET THE STARTING X POSITION
	TAD	XDIF		/UPDATE IT BY + OR - ONE
	DCA	NWPOSX		/SAVE IT FOR CALCULATING THE Y INTERCEPT
	JMS  I  POSEQY		/GO CALCULATE THE Y INTERCEPT OF THIS LINE
	XPOS1			/STARTING X POSITION
	YPOS1			/STARTING Y POSITION
NWPOSX,	0			/ASSUMED X
NWPSYH,	0			/CALCULATED Y INTERCEPT HIGH WORD
NWPSYL,	0			/CALCULATED Y INTERCEPT LOW WORD
	0			/EQUATIONS FLAG WORD
	TAD	NWPOSX		/GET THE NEW X
	DCA	XPOS1		/SAVE THE UPDATED X
	TAD	XPOS1		/CHECK TO SEE IF XPOS1 =XPOS2
	CIA
	TAD	XPOS2		/
	SNA	CLA		/ARE THEY EQUAL ?
	JMP	NWPOS1		/YES - GO UPDATE Y BY 1 OR 2
	TAD	NWPSYL		/GET THE Y INTERCEPT VALUE CALCULATED
	DCA	YPOS1		/SAVE AS THE NEW STARTING Y POSITION
	JMP  I  NEWPOS		/EXIT BACK TO CALLING ROUTINE
/
POSEQY,	EQ1
NPCOMP,	COMP			/2'S COMPLEMENT 2 WORD SIGNED NUMBER
MM0006,	-0006
NWPOSY,	POSYNW			/ROUTINE TO UPDATE Y BY 1 OR 2

	PAGE
/-----------------------------------------------------------------------------
/ CHKCLP - ROUTINE TO CHECK IF CLIPPING NEEDED
/	RETURN CALL +1 - ALL POINTS ON THE SCREEN
/	RETURN CALL +2 - POINTS TO LEFT,RIGHT,ABOVE OR BELOW SCREEN (INVISIBLE)
/	RETURN CALL +3 - CLIPPING OF POINTS TO SCREEN BOUNDRY NEEDED
/-----------------------------------------------------------------------------

CHKCLP,	0
	DCA	LININD		/INDICATE THAT ALL POINTS ON SCREEN
	MINMAX			/GO CHECK FINAL X CO-ORDINATE
	XPOS2			/CO-ORDINATE ADDRESS
	XFLAG2			/RETURN VALUE (-2 < MIN) (-1 > MAX) (0=VALID)
	MINX			/ADDRESS OF MINIMUM X CO-ORDINATE ALLOWED
	MAXX			/ADDRESS OF MAXIMUM X CO-ORDINATE ALLOWED +1
	MINMAX			/GO CHECK FINAL Y CO-ORDINATE
	YPOS2			/CO-ORDIANTE ADDRESS
	YFLAG2			/RETURN VALUE (-2 < MIN) (-1 > MAX) (0=VALID)
	MINY			/ADDRESS OF MINIMUM Y CO-ORDIANTE ALLOWED
	MAXY			/ADDRESS OF MAXIMUM Y CO-ORDINATE ALLOWED +1
	CHKXY1			/CHECK STARTING POINTS - FLAGS RETURNED IN AC
	TAD	XFLAG2		/ADD ENDING POINT FLAGS TO STARTING POINT
	TAD	YFLAG2		/
	SNA	CLA		/SKIP IF NOT ON SCREEN
	JMP	CLPEXT		/GO DO THE LINE - POINTS ARE VALID
	AC0004			/CHECK IF LINE ON LEFT OF SCREEN
	TAD	XFLAG1		/
	TAD	XFLAG2		/
	SNA			/SKIP IF NOT ON LEFT SIDE OF SCREEN
	JMP	LNLEFT		/LINE ON LEFT - CAN NOT DRAW IT
	CLL	RTR		/CHECK IF LINE ON RIGHT OF SCREEN
	SZA	CLA		/SKIP IF POINTS MAY BE ON RIGHT SIDE
	JMP	CLIPVT		/POINTS NOT ON RIGHT - DO FURTHER CHECKING
	TAD	XFLAG1		/CHECK IF XPOS1 ON SCREEN
	SNA	CLA		/SKIP IF NOT
	JMP	CLIPVT		/ONE POINT ON AND ONE POINT BEFORE
	TAD	XFLAG2		/CHECK IF XPOS2 ON SCREEN
	SZA	CLA		/SKIP IF ONE POINT ON AND ONE POINT OFF
	JMP	LNRGHT		/BOTH POINTS ON RIGHT SIDE OF SCREEN
CLIPVT,	AC0004			/CHECK IF LINE BEFORE TOP OF SCREEN
	TAD	YFLAG1		/
	TAD	YFLAG2		/
	SNA			/SKIP IF NOT BEFORE TOP OF SCREEN
	JMP	LNBFOR		/LINE BEFORE TOP - CAN NOT DRAW IT
	CLL	RTR		/CHECK IF LINE BEYOND BOTTOM OF SCREEN
	SZA	CLA		/SKIP IF BOTH POINTS COULD BE BEYOND BOTTOM
	JMP	LNCLPN		/CONTINUE BOTH POINTS ARE NOT BEYOND BOTTOM
	TAD	YFLAG1		/CHECK IF YPOS1 BEYOND BOTTOM
	SNA	CLA		/SKIP IF BEYOND OR BEFORE BOTTOM
	JMP	LNCLPN		/ONE POINT ON AND ONE POINT OFF SCREEN - CONT
	TAD	YFLAG2		/CHECK IF THIS POINT ON OR OFF SCREEN
	SZA	CLA		/SKIP IF POINT ON SCREEN
	JMP	LNAFTR		/BOTH POINTS BEYOND BOTTOM OF SCREEN
/
LNCLPN,	ISZ	LININD		/CLIPPING OF THE LINE NEEDED	5
LNBFOR,	ISZ	LININD		/LINE BEFORE THE SCREEN		4
LNAFTR,	ISZ	LININD		/LINE AFTER  THE SCREEN		3
LNRGHT,	ISZ	LININD		/LINE RIGHT  OF  SCREEN		2
LNLEFT,	ISZ	LININD		/LINE LEFT   OF  SCREEN		1
	TAD	LININD		/GET THE LINE INDICATOR
	TAD	MM0005		/CHECK IF CLIPPING NEEDED OR LINE INVISIBLE
	SNA	CLA		/SKIP IF LINE INVISIBLE
	ISZ	CHKCLP		/CLIPPING NEEDED
	ISZ	CHKCLP		/LINE INVISIBLE
CLPEXT,	JMP  I  CHKCLP		/LINE VALID  ON  SCREEN		0
/
/
MM0005,	-0005

/-----------------------------------------------------------------------------
/ HCLIP/VCLIP - ROUTINES TO DO HORIZONTAL AND VERTICAL CLIPPING OF LINES/AREAS
/-----------------------------------------------------------------------------
/
HCLIP,	0
	TAD	HCLIP		/GET CALLING ADDRESS
	DCA	VCLIP		/SAVE FOR RETURN
	TAD	AHCTBL		/GET ADDRESS OF HORIZONTAL CLIPPING TABLE
	JMP	HVCLIP		/GO DO HORIZONTAL LINE CLIPPING
/
VCLIP,	0
	TAD	AVCTBL		/GET ADDRESS OF VERTICAL CLIPPING TABLE
HVCLIP,	DCA	HVTMP1		/SAVE THE ADDRESS OF THE TABLE
	CLA CLL CMA RAL		/SETUP TO DO TWO SETS OF X OR Y CO-ORDINATES
	DCA	HVTMP4		/SAVE THE LOOP COUNTER
HVCLP1,	TAD	M0004		/SETUP TO MOVE 4 ENTRIES FROM TABLE
	DCA	HVTMP3		/SAVE THE MOVE COUNTER
	TAD	AHVFLG		/GET THE ADDRESS OF BUFFER FOR DATA
	DCA	HVTMP2		/SAVE THE ADDRESS OF THE BUFFER
HVCLP2,	TAD  I  HVTMP1		/GET ADDRESS FROM THE TABLE
	DCA  I  HVTMP2		/SAVE IN WORKING BUFFER
	ISZ	HVTMP1		/UPDATE THE TABLE AND BUFFER POINTERS
	ISZ	HVTMP2		/
	ISZ	HVTMP3		/DONE ALL 4 MOVES?
	JMP	HVCLP2		/NO - MOVE THE NEXT WORD
/
	TAD  I  HVFLG		/GET THE X OR Y POSITIONS FLAG
	SNA			/CHECK IF POINT IS ON THE SCREEN
	JMP	HVCLP4		/YES - THIS POINT ON THE SCREEN - EXIT
	IAC			/CHECK IF BEYOND THE SCREEN
	SZA	CLA		/IF 0 THEN BEYOND THE BOTTOM OF SCREEN
	JMP	HVCLP3		/CO-ORDINATE BEFORE THE SCREEN
	CLA CLL CMA		/SUBTRACT 1 FROM MAXIMUM CO-ORDINATE
	TAD  I  HVMAX		/GET MAXIMUM ALLOWED +1
	SKP			/GO SAVE AS NEW CO-ORDINATE
HVCLP3,	TAD  I  HVMIN		/GET THE MINIMUM ALLOWED CO-ORDINATE
	DCA  I  HVPOS		/SAVE THIS AS NEW CO-ORDINATE
/
HVCLP4,	ISZ	HVTMP4		/DONE BOTH SETS OF CO-ORDINATES
	JMP	HVCLP1		/NO DO NEXT CO-ORDINATE
	JMP  I  VCLIP		/RETURN BACK TO CALLING ROUTINE
/
HVTMP1,	0			/HORIZONTAL OR VERTICAL TABLE POINTER
HVTMP2,	0			/BUFFER POINTER TO WORKING VARIABLES
HVTMP3,	0			/WORD MOVE COUNTER
HVTMP4,	0			/CO-ORDINATE SET COUNTER
/
HVFLG,	0			/X OR Y SCREEN POSITION FLAG ADDRESS
HVPOS,	0			/X OR Y CO-ORDINATE ADDRESS
HVMIN,	0			/X OR Y MINIMUM ALLOWED CO-ORDINATE ADDRESS
HVMAX,	0			/X OR Y MAXIMUM ALLOWED CO-ORDINATE ADDRESS
/
/
HCTBL,	XFLAG1
	XPOS1
	MINX
	MAXX
	XFLAG2
	XPOS2
	MINX
	MAXX
/
VCTBL,	YFLAG1
	YPOS1
	MINY
	MAXY
	YFLAG2
	YPOS2
	MINY
	MAXY

AHCTBL,	HCTBL
AVCTBL,	VCTBL
AHVFLG,	HVFLG

/------------------------------------------------------------------------------
/ GTLTXT - GET THE LINE TEXTURE - COPY OR REPLICATE BYTE TO TWO BYTES
/-------------------------------------------------------------------------------
/
GTLTXT,	0
	JMS  I  XGTPAT		/GET LINE TEXTURE AND DO MIRROR IMAGE OF IT
	DCA	LINTXT		/SAVE THE LINE TEXTURE PATTERN
	JMS I	XUPDPA		/GO UPDATE THE LINE DRAWING PATTERN
	JMP  I  GTLTXT		/EXIT BACK TO CALLER
/
XGTPAT,	GETPAT			/GET MIRROR IMAGE OF SPECIFIED LINE TEXTURE
XUPDPA,	UPDPAT

	PAGE
/-----------------------------------------------------------------------------
/ LNSLOP - ROUTINE TO DO CLIPPING OF X AND Y CO-ORDINATES FOR SLOPPED LINES
/-----------------------------------------------------------------------------

LNSLOP,	0
	CLA	CLL
	DCA	INVISB		/INITIALIZE LINE TO BE VISIBLE
	TAD	MMM006		/SETUP TO CHECK WHICH TYPE OF LINE (6-0)
	TAD	SLPOFS		/GET THE LINE INDICATOR AND SLOPE FLAG
	SZA			/SKIP IF A DOT
	JMP	RTSLP1		/NOT A DOT - CHECK IF HORIZONTAL LINE
	JMS  I  XHCLIP		/GO DO HORIZONTAL LINE CLIPPING
	JMS  I  XVCLIP		/GO DO VERTICAL LINE CLIPPING
	JMP	EXSLOP		/EXIT THE CLIPPING ROUTINE
RTSLP1,	IAC			/
	SZA			/CHECK IF LINE A HORIZONTAL LINE
	JMP	RTSLP2		/NOT HORIZONTAL - GO CHECK IF VERTICAL
	JMS  I  XHCLIP		/GO DO HORIZONTAL LINE CLIPPING
	JMP	EXSLOP		/EXIT THE CLIPPING ROUTINE
RTSLP2,	IAC			/
	SZA			/CHECK IF LINE A VERTICAL LINE
	JMP	RTSLP3		/NOT A VERTICAL LINE - GO CHECK SLOPES
	JMS  I  XVCLIP		/GO DO VERTICAL LINE CLIPPING
	JMP	EXSLOP
RTSLP3,	IAC			/
	SZA			/LINE UPWARDS TO THE RIGHT ?
	JMP	RTSLP4		/NO
	TAD	MINX
	DCA  I  EQ1VAL		/SAVE 1ST POSSIBLE INTERSECTION POINT X1,Y1
	CLA	CMA
	TAD	MAXY
	DCA  I  EQ2VAL		/SAVE 2ND POSSIBLE INTERSECTION POINT X1,Y1
	CLA	CMA
	TAD	MAXX
	DCA  I  EQ3VAL		/SAVE 1ST POSSIBLE INTERSECTION POINT OF X2,Y2
	TAD	MINY
	DCA  I  EQ4VAL		/SAVE 2ND POSSIBLE INTERSECTION POINT OF X2,Y2
	JMP	CHKSLP		/GO CALCULATE AND CHECK NEW SLOPE CO-ORDINATES
RTSLP4,	IAC
	SZA			/LINE UPWARD AND TO THE LEFT
	JMP	RTSLP5		/NO
	CLA	CMA
	TAD	MAXX
	DCA  I  EQ1VAL		/SAVE 1ST POSSIBLE INTERSECTION POINT OF X1,Y1
	CLA	CMA
	TAD	MAXY
	DCA  I  EQ2VAL		/SAVE 2ND POSSIBLE INTERSECTION POINT OF X1,Y1
	TAD	MINX
	DCA  I  EQ3VAL		/SAVE 1ST POSSIBLE INTERSECTION POINT OF X2,Y2
	TAD	MINY
	DCA  I  EQ4VAL		/SAVE 2ND POSSIBLE INTERSECTION POINT OF X2,Y2
	JMP	CHKSLP		/GO CALCULATE AND CHECK NEW SLOPE CO-ORDINATES

/
RTSLP5,	IAC
	SZA	CLA		/LINE DOWNWARD TO THE RIGHT
	JMP	RTSLP6		/NO - MUST BE DOWNWARD TO THE LEFT
	TAD	MINX
	DCA  I  EQ1VAL		/SAVE 1ST POSSIBLE INTERSECTION POINT OF X1,Y1
	TAD	MINY
	DCA  I  EQ2VAL		/SAVE 2ND POSSIBLE INTERSECTION POINT OF X1,Y1
	CLA	CMA
	TAD	MAXX
	DCA  I  EQ3VAL		/SAVE 1ST POSSIBLE INTERSECTION POINT OF X2,Y2
	CLA	CMA
	TAD	MAXY
	DCA  I  EQ4VAL		/SAVE 2ND POSSIBLE INTERSECTION POINT OF X2,Y2
	JMP	CHKSLP		/GO CALCULATE AND CHECK NEW SLOPE CO-ORDINATES
RTSLP6,	CLA	CMA		/LINE DOWNWARD TO LEFT
	TAD	MAXX
	DCA  I  EQ1VAL		/SAVE 1ST POSSIBLE INTERSECTION POINT OF X1,Y1
	TAD	MINY
	DCA  I  EQ2VAL		/SAVE 2ND POSSIBLE INTERSECTION POINT OF X1,Y1
	TAD	MINX
	DCA  I  EQ3VAL		/SAVE 1ST POSSIBLE INTERSECTION POINT OF X2,Y2
	CLA	CMA
	TAD	MAXY
	DCA  I  EQ4VAL		/SAVE 2ND POSSIBLE INTERSECTION POINT OF X2,Y2
CHKSLP,	TAD	XPOS1		/SAVE XPOS1 INCASE INVISIBLE LINE
	DCA	RTSLX1		/
	TAD	YPOS1		/SAVE YPOS1 INCASE OF INVISIBLE LINE
	DCA	RTSLY1		/
	TAD	XPOS2		/SAVE XPOS2 INCASE INVISIBLE LINE
	DCA	RTSLX2		/
	TAD	YPOS2		/SAVE YPOS2 INCASE INVISIBLE LINE
	DCA	RTSLY2		/
/
	JMS  I  NEWXYS		/GO CALCULATE NEW X AND Y CO-ORDINATES
/
EXSLOP,	TAD	INVISB		/GET THE INVISABLE FLAG
	SNA			/SKIP IF THE LINE WAS INVISIBLE
	ISZ	LNSLOP		/VALID LINE - UPDATE RETURN POINTER
	SNA	CLA
	JMP  I  LNSLOP		/EXIT - POINTS HAVE BEEN CLIPPED
	TAD	RTSLX1		/RESTORE ORIGINAL X POSITION 1
	DCA	XPOS1
	TAD	RTSLY1		/RESTORE ORIGINAL Y POSITION 1
	DCA	YPOS1
	TAD	RTSLX2
	DCA	XPOS2
	TAD	RTSLY2
	DCA	YPOS2
	JMP  I  LNSLOP		/RETURN - CO-ORDINATES CLIPPED IF NECCESSARY
/
MMM006,	-0006
INVISB,	0
NEWXYS,	CALXYS
XHCLIP,	HCLIP
XVCLIP,	VCLIP
RTSLX1,	0
RTSLY1,	0
RTSLX2,	0
RTSLY2,	0
EQ1VAL,	EQ1ASX
EQ2VAL,	EQ2ASY
EQ3VAL,	EQ3ASX
EQ4VAL,	EQ4ASY
/
REFACK,	0
	TAD	SHDFLG		/IS SHADING TURNED ON
	SZA	CLA		/SKIP IF NOT
	JMS  I  XWSHDL		/GO CHECK TO SEE WHICH REFERNECE LINE
	JMP  I  REFACK
/
XWSHDL,	WSHADL
/
POSYNW,	0			/UPDATE CURRENT Y POSITION BY 1 OR 2
	CLA CLL CMA RAL		/SETUP TO ADD TO STARTING Y POSITION TWICE
	DCA	INVISB		/SAVE COUNTER IN TEMPORARY LOCATION
NWPOS2,	TAD	YPOS1		/GET THE PRESENT Y POSITION
	TAD	YDIF		/GET THE TRAVERSING Y POSITION
	DCA	YPOS1		/SAVE THE UPDATED Y POSITION
	TAD	YPOS1		/CHECK THAT Y1 DOESN'T EXCEED Y2
	CIA
	TAD	YPOS2
	SNA	CLA		/IS Y1 = Y2
	JMP  I  POSYNW		/YES THEN EXIT CAN'T UPDATE PAST
	ISZ	INVISB		/DONE UPDATING STARTING Y POSITION
	JMP	NWPOS2		/NO - UPDATE Y ONCE MORE
	JMP  I  POSYNW		/EXIT - STARTING Y POSITION UPDATED

	PAGE
/-----------------------------------------------------------------------------
/ EQ1 - SOLVE Y GIVEN X FOR POINTS X1,Y1 -  Y = ((DELTAY*NEW DELTA X)/DELTAX)+Y1
/-----------------------------------------------------------------------------

EQ1,	0
	TAD  I  EQ1		/GET THE STARTING/ENDING X POSITION
	DCA	EQ1X12		/SAVE IT
	ISZ	EQ1		/UPDATE POINTER
	TAD  I  EQ1		/GET THE STARTING/ENDING Y POSITION
	DCA	EQ1Y12		/SAVE IT
	ISZ	EQ1		/UPDATE POINTER
	TAD  I  EQ1		/GET MIN OR MAX LOGICAL X
	DCA	EQX1		/SAVE THIS AS POSSIBLE NEW X1
	ISZ	EQ1		/UPDATE POINTER TO WHERE 2 WORD Y TO BE SAVED
	TAD	EQ1		/GET ADDRESS OF WHERE HIGH Y IS TO BE SAVED
	DCA  I  EQOVAD		/SAVE THE ADDRESS
	ISZ	EQ1		/UPDATE POINTER TO LOW WORD OF SAVED Y
	TAD	EQ1		/GET ADDRESS OF WHERE LOW Y IS TO BE SAVED
	DCA	EQ1MD6		/SAVE ADDRESS FOR MINMAX CHECKING
	ISZ	EQ1		/MOVE POINTER TO FLAG WORD
	TAD	EQ1		/GET ADDRESS OF FLAG WORD
	DCA	EQ1MD7		/SAVE FLAG WORD ADDRESS
	ISZ	EQ1		/UPDATE POINTER FOR RETURN
	CLA CLL IAC		/INITILAIZE FLAG - NUMBER TO LARGE
	DCA  I  EQ1MD7		/SAVE THE FLAG WORD
	TAD	EQ1TAB		/GET ADDRESS-1 OF EQUATION 1'S OVERLAY TABLE
	JMS  I  EQOVRL		/GO OVERLAY ADDRESSES IN EQUATION 1
	CNVDBL			/CONVERT XPOS1 TO DOUBLE PRECISION WORD
EQ1X12,	XPOS1			/ADDRESS OF WORD TO BE CONVERTED
EQ1MD1,	EQ1YH			/ADDRESS OF WHERE TO STORE WORD
	CNVDBL			/CONVERT ASSUMED X TO DOUBLE PRECISION
	EQX1			/ADDRESS OF WORD TO BE CONVERTED
	ACHW			/WHERE TO STORE IT - SETUP FOR SUBTRACTION
	DBLSUB			/NEW DELTAX = (ASSUMED X - XPOS1)
EQ1MD2,	EQ1YH			/ADDRESS OF WORD TO BE SUBTRACTED
EQ1MD3,	EQ1YH			/WHERE TO STORE RESULTS OF SUBTRACTION
	DBLMTY			/DELTAY * NEW DELTAX
	SLPDYH			/ADDRESS OF 2 WORD MULTIPLICAND
EQ1MD4,	EQ1YH			/ADDRESS OF 2 WORD MULTIPLIER
	DBLDIV			/(DELTAY*NEW DELATAX)/DELTAX
	SLPDXH			/ADDRESS OF DOUBLE WORD DIVISOR
	CNVDBL			/CONVERT YPOS1 TO DOUBLE PRECISION WORD
EQ1Y12,	YPOS1			/ADDRESS OF WORD TO BE CONVERTED
	ACHW			/WHERE TO STORE WORD - SETUP FOR ADDITION
	DBLADD			/Y=Y1+(DELTAY*NEW DELTAX)/DELTAX
	MQHW			/ADDRESS OF QUOTIENT FROM DIVISION
EQ1MD5,	EQ1YH			/STORE RESULTS OF ADDITION AT THIS ADDRESS

	TAD  I  EQ1MD5		/GET THE HIGH WORD OF CALCULATED Y
	SZA	CLA		/SKIP IF NUMBER < 4096 AND NOT NEGATIVE
	JMP	EQ1RET		/NUMBER TO BIG OR NEGATIVE
	TAD  I  EQ1MD6		/GET THE LOW WORD OF CALCULATED Y
	SPA	CLA		/SKIP IF <= 2047
	JMP	EQ1RET		/NUMBER TO BIG
	MINMAX			/GO VALIDATE NEW Y POINT CALCULATED
EQ1MD6,	EQ1YL
EQ1MD7,	EQ1FLG
	MINY
	MAXY
EQ1RET,	CLA	CLL		/NEEDED TO CLEAN UP THE AC ON EXIT
	JMP  I  EQ1		/EXIT BACK TO CHECK NEXT SET OF POINTS
/
EQOVAD,	OVRADR
EQOVRL,	OVRLAY
EQ1TAB,	EQ1TBL-1
EQ2TAB,	EQ2TBL-1

/-----------------------------------------------------------------------------
/ EQ2 - ASSUME Y CALCULATE X FOR X1,Y1 -  X = ((DELTAX*NEW DELTA Y)/DELTAY)+X1
/-----------------------------------------------------------------------------

EQ2,	0
	TAD  I  EQ2		/GET THE STARTING/ENDING X POSITION
	DCA	EQ2X12		/SAVE IT
	ISZ	EQ2		/UPDATE POINTER
	TAD  I  EQ2		/GET THE STARTING/ENDING Y POSITION
	DCA	EQ2Y12		/SAVE IT
	ISZ	EQ2		/UPDATE POINTER
	TAD  I  EQ2		/GET MIN OR MAX ASSUMED Y
	DCA	EQY1		/SAVE AS POSSIBLE NEW Y
	ISZ	EQ2		/UPDATE POINTER TO ADDRESS OF WHERE TO STORE X
	TAD	EQ2		/GET ADDRESS OF WHERE HIGH X IS TO BE SAVED
	DCA  I  EQOVAD		/SAVE THE ADDRESS
	ISZ	EQ2		/UPDATE POINTER TO LOW WORD OF SAVED X
	TAD	EQ2		/GET ADDRESS OF WHERE LOW X IS TO BE SAVED
	DCA	EQ2MD6		/SAVE ADDRESS FOR MINMAX CHECKING
	ISZ	EQ2		/MOVE POINTER TO FLAG WORD
	TAD	EQ2		/GET ADDRESS OF FLAG WORD
	DCA	EQ2MD7		/SAVE FLAG WORD ADDRESS
	ISZ	EQ2		/UPDATE POINTER FOR RETURN
	CLA CLL IAC		/INITILAIZE FLAG - NUMBER TO LARGE
	DCA  I  EQ2MD7		/SAVE THE FLAG WORD
	TAD	EQ2TAB		/GET ADDRESS-1 OF EQUATION 1'S OVERLAY TABLE
	JMS  I  EQOVRL		/GO OVERLAY ADDRESSES IN EQUATION 1
	CNVDBL			/CONVERT YPOS1 TO DOUBLE PRECISION WORD
EQ2Y12,	YPOS1			/ADDRESS OF WORD TO BE CONVERTED
EQ2MD1,	EQ1XH			/ADDRESS OF WHERE TO STORE WORD
	CNVDBL			/CONVERT ASSUMED Y TO DOUBLE PRECISION
	EQY1			/ADDRESS OF WORD TO BE CONVERTED
	ACHW			/WHERE TO STORE IT - SETUP FOR SUBTRACTION
	DBLSUB			/NEW DELTAY = (ASSUMED Y - YPOS1)
EQ2MD2,	EQ1XH			/ADDRESS OF WORD TO BE SUBTRACTED
EQ2MD3,	EQ1XH			/WHERE TO STORE RESULTS OF SUBTRACTION
	DBLMTY			/DELTAX * NEW DELTAY
	SLPDXH			/ADDRESS OF 2 WORD MULTIPLICAND
EQ2MD4,	EQ1XH			/ADDRESS OF 2 WORD MULTIPLIER
	DBLDIV			/(DELTAX*NEW DELTAY)/DELTAY
	SLPDYH			/ADDRESS OF DOUBLE WORD DIVISOR
	CNVDBL			/CONVERT XPOS1 TO DOUBLE PRECISION WORD
EQ2X12,	XPOS1			/ADDRESS OF WORD TO BE CONVERTED
	ACHW			/WHERE TO STORE WORDS - SETUP FOR ADDITION
	DBLADD			/X=X1+(DELTAX*NEW DELTAY)/DELTAY
	MQHW			/ADDRESS OF RESULT FROM DIVISION
EQ2MD5,	EQ1XH			/ADDRESS OF WHERE RESULT IS TO BE STORED

	TAD  I  EQ2MD5		/GET THE HIGH WORD OF CALCULATED X
	SZA	CLA		/SKIP IF NUMBER < 4096 AND NOT NEGATIVE
	JMP	EQ2RET		/NUMBER TO BIG OR NEGATIVE
	TAD  I  EQ2MD6		/GET THE LOW WORD OF CALCULATED X
	SPA	CLA		/SKIP IF <= 2047
	JMP	EQ2RET		/NUMBER TO BIG
	MINMAX			/GO VALIDATE THE X CO-ORDINATE CALCULATED
EQ2MD6,	EQ1XL
EQ2MD7,	EQ2FLG
	MINX
	MAXX
EQ2RET,	CLA	CLL		/NEEDED TO CLEANUP AC ON EXIT
	JMP  I  EQ2		/EXIT TO CALL+2 FOR VALID POINTS +3 FOR INVALID
/
EQX1,	0			/NEW X TO REPLACE X1
EQY1,	0			/NEW Y TO REPLACE Y1
/
EQ1TBL,	EQ1MD1
	EQ1MD2
	EQ1MD3
	EQ1MD4
	EQ1MD5
/
EQ2TBL,	EQ2MD1
	EQ2MD2
	EQ2MD3
	EQ2MD4
	EQ2MD5

	PAGE
/----------------------------------------------------------------------------
/ CALXYS - CALCULATE NEW X AND Y CO-ORDINATES OF SCREEN BOUNDRIES
/-----------------------------------------------------------------------------
/
CALXYS,	0
	TAD	OLDX
	DCA	EQ1ORX
	TAD	OLDY
	DCA	EQ1ORY
	TAD	OLDX
	DCA	EQ2ORX
	TAD	OLDY
	DCA	EQ2ORY
	TAD	SHDFLG
	SNA	CLA
	JMP	CHKSL0
	TAD	NEWX
	DCA	EQ1ORX
	TAD	NEWX
	DCA	EQ2ORX
	TAD	NEWY
	DCA	EQ1ORY
	TAD	NEWY
	DCA	EQ2ORY
CHKSL0,	TAD	XFLAG1		/CHECK IF POINTS X1,Y1 ARE ON SCREEN
	TAD	YFLAG1		/
	SNA	CLA
	JMP	CHKSL1		/VALID SCREEN CO-ORDINATES - GO CHECK X2,Y2
	JMS  I  RTEQ1		/SOLVE EQUATION FOR Y
EQ1ORX,	UNMODX			/ORIGINAL STARTING X POSITION
EQ1ORY,	UNMODY			/ORIGINAL STARTING Y POSITION
EQ1ASX,	0			/ASSUMED X VALUE ON SCREEN
EQ1YH,	0			/HIGH WORD - CALCULATED Y
EQ1YL,	0			/LOW  WORD - CALCULATED Y
EQ1FLG,	0			/EQUATION 1 FALG WORD (-2 TO 2)
	TAD	EQ1FLG		/GET FLAG FROM Y CALCULATION
	SZA	CLA		/SKIP IF CO-ORDINATES ON THE SCREEN
	JMP	CALXY1		/NOT ON SCREEN - TRY CALCULATING FOR X
	TAD	EQ1ASX		/GET THE ASSUMED X
	DCA	XPOS1		/SAVE AS NEW XPOS1 ?
	TAD	EQ1YL		/GET THE CALCULATED Y
	DCA	YPOS1		/SAVE AS NEW YPOS1 ?
	JMP	CHKSL1		/GO CHECK X2 AND Y2 CO-ORDINATES
CALXY1,	JMS  I  RTEQ2		/SOLVE EQUATION FOR X
EQ2ORX,	UNMODX			/ORIGINAL STARTING X POSITION
EQ2ORY,	UNMODY			/ORIGINAL STARTING Y POSITION
EQ2ASY,	0			/ASSUMED Y VALUE ON THE SCREEN
EQ1XH,	0			/HIGH WORD - CALCULATED X
EQ1XL,	0			/LOW  WORD - CALCULATED X
EQ2FLG,	0			/EQUATION 2 FLAG WORD (-2 TO 2)

	TAD	EQ2FLG		/GET FLAG FROM X CALCULATION
	SZA	CLA		/SKIP IF CO-ORDINATES ON THE SCREEN
	JMP	CALXY2		/POINTS X1,Y1 NOT ON SCREEN SET LINE=INVISIBLE
	TAD	EQ1XL		/GET THE CALCULATED X
	DCA	XPOS1		/SAVE AS NEW XPOS1 ?
	TAD	EQ2ASY		/GET THE ASSUMED Y
	DCA	YPOS1		/SAVE AS NEW Y ?
	SKP	CLA		/GO CHECK CO-ORDINATES X2,Y2
CALXY2,	ISZ  I  ELNINV		/INVISIBLE LINE - SET FLAG TO INDICATE THIS
/
CHKSL1,	TAD	XFLAG2		/CHECK IF POINTS X2,Y2 ARE ON SCREEN
	TAD	YFLAG2		/
	SNA	CLA
	JMP	CALXYE		/THESE POINTS ARE ON SCREEN - EXIT AND DRAW LINE
	JMS  I  RTEQ1		/SOLVE EQUATION FOR Y
	RTSLX2			/ORIGINAL ENDING X POSITION
	RTSLY2			/ORIGINAL ENDING Y POSITION
EQ3ASX,	0			/ASSUMED X VALUE ON THE SCREEN
	0			/HIGH WORD - CALCULATED Y
EQ3YL,	0			/LOW  WORD - CALCULATED Y
EQ3FLG,	0			/EQUATION 3 FALG WORD (-2 TO 2)
	TAD	EQ3FLG		/GET FLAG FROM Y CALCULATION
	SZA	CLA		/SKIP IF POINTS ARE VALID
	JMP	CALXY3		/INVALID POINTS - GO CALCULTE FOR X
	TAD	EQ3ASX		/GET THE ASSUMED X
	DCA	XPOS2		/SAVE AS POSSIBLE XPOS2 ?
	TAD	EQ3YL		/GET THE CALCULATED Y
	DCA	YPOS2		/SAVE AS POSSIBLE YPOS2 ?
	JMP	CALXYE		/EXIT - X2,Y2 CLIPPED TO THE SCREEN
CALXY3,	JMS  I  RTEQ2		/SOLVE EQUATION FOR X
	RTSLX2			/ORIGINAL ENDING X POSITION
	RTSLY2			/ORIGINAL ENDING Y POSITION
EQ4ASY,	0			/ASSUMED Y VALUE ON THE SCREEN
	0			/HIGH WORD - CALCULATED X
EQ4XL,	0			/LOW  WORD - CALCULATED X
EQ4FLG,	0			/EQUATION 4 FLAG WORD (-2 TO 2)
	TAD	EQ4FLG		/GET FLAG FROM X CALCULATION
	SZA	CLA		/SKIP IF CO-ORDINATES ON THE SCREEN
	JMP	CALXY4		/X2,Y2 NOT ON SCREEN SET LINE=INVISIBLE
	TAD	EQ4XL		/GET THE CALCULATED X
	DCA	XPOS2		/SAVE AS XPOS2 ?
	TAD	EQ4ASY		/GET THE ASSUMED Y
	DCA	YPOS2		/SAVE AS YPOS2 ?
	SKP	CLA
CALXY4,	ISZ  I  ELNINV		/UPDATE FALG INDICATING LINE IS INVISIBLE
CALXYE,	JMP  I  CALXYS		/EXIT BACK TO CALLER
/
ELNINV,	INVISB			/ADDRESS OF FLAG INDICATING LINE INVISIBLE
RTEQ1,	EQ1
RTEQ2,	EQ2
OLDX,	UNMODX
OLDY,	UNMODY
NEWX,	XPOS1
NEWY,	YPOS1

/ --------------------------------------------
/ SAVEDX - SAVE A PARAMETER ON THE FIGS STRING
/ --------------------------------------------
/
SAVEDX,	0
	DCA	SAVETM		/SAVE THE PARAMETER
	TAD	SAVETM		/PUT LOW EIGHT BITS ON STRING
	AND	K0377
	DCA I	AUTO10
	TAD	SAVETM		/PUT HIGH FOUR BITS ON STRING (EXTEND SIGN)
	BSW
	RTR
	AND	K0017
	DCA	SAVETM
	TAD	K0010
	AND	SAVETM
	SZA CLA
	TAD	K0060
	TAD	SAVETM
	DCA I	AUTO10
	JMP I	SAVEDX
/
SAVETM,	0
K0060,	0060
/
/
/
/
/ ----------------------------------
/ FULARC - DRAW A SEGMENT OF A CURVE
/ ----------------------------------
/
FULARC,	0
	DCA	ARCARY		/SAVE THE BASE ADDRESS OF THE 4 POINTS
	TAD	K0012		/INITIALIZE DRAW CURVE COUNT
	DCA	REMAIN		/SAVE IT
	TAD	K11CRV		/INITIALIZE NUMBER OF SEGMENTS TO DRAW
	DCA	SEG		/SAVE THE SEGMENT COUNTER
	JMS  I  CRVDRW		/GO INTERPOLATE AND DRAW CURVE
ARCARY,	0			/BASE ADDRESS OF 4 POINTS TO INTERPOLATE
	JMP  I  FULARC		/ARC HAS BEEN DRAWN EXIT
/
/
K11CRV,	11
CRVDRW,	XCURVE

	PAGE
/ --------------------------------
/ DRAW - DRAW THE SPECIFIED FIGURE
/ --------------------------------
/
/ CALLING FORMAT:	DRAWIT
/			<ADDRESS_OF_CURS_STRING>
/			<ADDRESS_OF_FIGS_FIGD_STRING>
/			<ADDRESS_OF_PRAM_STRING>
/
DRAW,	0
	CLA CLL
	TAD I	DRAW		/GET ADDRESS OF CURS STRING
	DCA	DRAW7		/  FOR ISSUING LATER
	ISZ	DRAW		/INCREMENT TO NEXT ARGUMENT
/
	TAD I	DRAW		/GET ADDRESS OF FIGS/FIGD STRING
	DCA	DRAW9		/  FOR ISSUING LATER
	ISZ	DRAW		/INCREMENT TO NEXT ARGUMENT
/
	TAD I	DRAW		/GET ADDRESS OF PRAM STRING
	DCA	DRAWT5		/  FOR ISSUING LATER
	ISZ	DRAW		/UPDATE POINTER FOR RETURN
/
	JMS I	XCOPPR		/COPY PRAMS TO LOCAL STRING
/
	TAD	WRMODE		/CHECK IF REPLACE MODE TO COUNT PASSES
	CIA			/  (MUST DO TWO PASSES IF REPLACE)
	DCA	DRWCNT		/SAVE AS LOOP CONTROL (NOT A COUNTER)
/
	TAD	COLORM		/GET THE PLANE SELECT MASK WORD
	DCA	DRAWT4		/SAVE THE PLANE SELECT MASK WORD
NOTCOM,	TAD	BCOLOR		/GET THE BACKGROUND COLOR
	DCA	DRAWTM		/SAVE IT AS THE POTENTIAL WRITING COLOR
	TAD	OPCODE		/GET THE OPERATION CODE BEING EXECUTED
	TAD	OPCDSE		/CHECK IT AGAINST SCREEN ERASE OPCODE
	SNA	CLA		/SKIP IF COMMAND NOT SCREEN ERASE
	JMP	DRAWSE		/SCREEN ERASE - ERASE TO BACKGROUND COLOR
	CLA CLL CMA RTL		/-3
	TAD	WRMODE		/GET THE WRITING MODE
	SNA	CLA		/IS WRITING MODE = ERASE
	JMP	WMERAS		/YES - GO LOAD PRAMS WITH ALL ONES
	TAD	SHDFLG		/GET THE SHADE FLAG
	SZA	CLA		/SKIP IF SHADING NOT TURNED ON
	JMS  I  SHDPAT		/SHADING ON - SETUP SHADE PATTERN
	TAD	FCOLOR		/CHANGE WRITING COLOR TO FOREGROUND COLOR
	DCA	DRAWTM		/SAVE THE WRITING COLOR
	JMP	DRAW1		/GO CHECK IF NEGATE MODE

WMERAS,	JMS  I  DRWONE		/LOAD ALL PRAMS WITH 377
	TAD	NEGFLG		/GET THE NEGATIVE WRITING MODE FLAG
	SNA	CLA		/SKIP IF SET
	JMP	DRAWSE		/NOT SET - GO DO ERASE WITH BACKGROUND COLOR
	TAD	FCOLOR		/GET THE FOREGROUND COLOR
	DCA	DRAWTM		/SAVE IT
	JMP	DRAWSE		/NEGATE ON - GO DO ERASE IN FOREGROUND COLOR
DRAW1,	TAD	NEGFLG		/GET THE NEGATIVE WRITING MODE FLAG
	SZA	CLA		/SKIP IF NOT SET
DRAW1A,	JMS  I  DRWCOM		/GO COMPLEMENT THE WRITING PATTERN
DRAWSE,	SENDIT			/SEND PRAMS STRING TO GDC
	DRWPRM
/
	TAD	M0004		/SET UP FOR FOUR PLANES
	DCA	DRAWT1
	DCA	DRAW8		/SET UP FOR GREEN PLANE (00) FIRST
	AC0002			/GET ADDRESS OF COLOR PARAMETER IN CURS STRING
	TAD	DRAW7
	DCA	DRAWT2
	TAD I	DRAWT2		/GET COLOR PARAMETER
	DCA	DRAWT3		/SAVE IT
	TAD	DRAWT3		/GET IT AGAIN
	AND	K0077		/MASK TO GREEN PLANE
	DCA I	DRAWT2		/AND PUT IT BACK
/
DRAW2,	TAD	DRAWT4		/GET THE PLANE SELECT MASK WORD
	CLL	RAR		/PUT PLANE SELECT BIT INTO LINK
	DCA	DRAWT4		/SAVE THE UPDATED MASK WORD FOR NEXT PLANE
	SNL			/SKIP IF PLANE IS TO BE MODIFIED
	JMP	DRAW10		/PLANE PROTECTED - CAN NOT MODIFY IT
	CLA CLL CMA RAL		/-2
	TAD	WRMODE		/GET THE PRESENT WRITING MODE
	SZA	CLA		/SKIP IF WRITING MODE = COMPLEMENT
	JMP	DRAW3		/NOT COMPLEMENT - CONTINUE
	SENDIT			/COMPLEMENT, SET UP TO COMPLEMNT SPECIFIED PLANES
	SCOMP			/
	JMP	DRAW6		/GO WRITE THE PLANE IN COMPLEMENT MODE
DRAW3,	TAD  	DRAWTM		/ROTATE COLOR PLANE INTO LINK
	CLL	RAR
	SZL	CLA		/CHECK IF WRITE OR ERASE FOR THIS PLANE
	JMP	DRAW4
	SENDIT			/ERASE, SET UP TO RESET THE SPECIFIED PLANE
	SCLEAR
	JMP	DRAW6

DRAW4,	SENDIT			/WRITE, SET UP TO SET THE SPECIFIED PLANE
	SSET
/
DRAW6,	SENDIT			/SEND CURSOR SPECIFY COMMAND TO GDC
DRAW7,	0			/(BECOMES ADDRESS OF CURS STRING)
/
	LDREG1			/SELECT THE WRITE PLANES
DRAW8,	0			/(BECOMES A PLANE SELECT)
/
	SENDIT			/SEND THE FIGS, FIGD STRING
DRAW9,	0			/(BECOMES ADDRESS OF COMMAND STRING)
/
DRAW10,	TAD  	DRAWTM		/ROTATE COLOR MAP THROUGH LINK
	CLL	RAR
	DCA  	DRAWTM
	TAD	DRAW8		/SPECIFY THE NEXT PLANE FOR REG 1 WRITING
	TAD	K0025
	DCA	DRAW8
	AC100			/SPECIFY THE NEXT PLANE IN CURS STRING
	TAD I	DRAWT2
	DCA I	DRAWT2
	ISZ	DRAWT1		/WRITTEN ALL PLANES
	JMP	DRAW2		/NO DO NEXT PLANE
/
	TAD	DRAWT3		/RESTORE ORIGINAL VALUE
	DCA  I  DRAWT2		/
/
	ISZ	DRWCNT		/CHECK IF REPLACE MODE FIRST PASS
	JMP	DRWEXT		/NOT REPLACE - GO RESTORE PRAM'S
/
				/REPLACE MODE - DO ANOTHER PASS
	TAD	BCOLOR		/GET THE BACKGROUND COLOR
	DCA	DRAWTM		/SAVE IT
	TAD	COLORM		/GET THE COLOR PLANE MASK WORD
	DCA	DRAWT4		/SAVE IT
	JMP	DRAW1A		/REPLACE MODE - GO WRITE PLANES IN BACKGROUND
/
DRWEXT,	JMP I	DRAW		/RETURN
/
OPCDSE,	-SE			/OPERATION CODE FOR SCREEN ERASE (NEGATIVE)
XCOPPR,	COPPRM			/ROUTINE TO COPY PRAM STRING
DRWONE,	LODPRM			/ROUTINE TO LOAD PRAM'S WITH ONES
DRWCOM,	COMPRM			/ROUTINE TO COMPLEMENT PRAM'S
SHDPAT,	LDATXT			/ROUTINE TO LOAD THE SHADE PATTERN
DRAWTM,	0			/COLOR TO BE USED IN GRAPHIC WRITING
DRAWT1,	0			/USED AS PLANE WRITTEN COUNTER
DRAWT2,	0			/ADDRESS OF CURSOR COLOR PLANE SELECT PARAMETER
DRAWT3,	0			/USED AS TEMP FOR COLOR PLANE SELECT PARAMETER
DRAWT4,	0			/USED AS TEMP FOR COLOR PLANE MASK WORD
DRAWT5,	0			/USED AS POINTER TO CALLERS PRAM STRING
K0025,	25			/USED TO SELECT REG 1 COLOR PLANES
DRWCNT,	0			/LOOP CONTROL FLAG

/-------------------------------------------------------------------------------
/ GTWRTM - GET WRITING MODE - 0=OVERLAY 1=REPLACE 2=COMPLEMENT 3=ERASE
/------------------------------------------------------------------------------
/
GTWRTM,	0
	GETPRM			/GET PARAMETER FROM CALLING FIELD
	CLL			/CLEAR THE LINK
	TAD	M0004		/IF NUMBER NEGATIVE OR > 3 THEN ILLEGAL
	SZL			/SKIP IF VALID WRITING MODE
	JMP	GTWEXT		/INVALID WRITING MODE SELECTED - EXIT
	TAD	K4WM		/RESTORE THE ORIGINAL NUMBER
	DCA	WRMODE		/SAVE AS THE NEW WRITIMG MODE
GTWEXT,	CLA	CLL		/NEEDED FOR ILLEGAL PARAMETER
	JMP  I  GTWRTM		/EXIT BACK TO CALLER
/
K4WM,	4

	PAGE
/-----------------------------------------------------------------------------
/ XMNMAX - CHECK CO-ORDINATE TO BE TO THE LEFT, RIGHT ABOVE, BELOW OR ON
/          THE SCREEN.
/
/
/	MINMAX		CALL MINIMUM/MAXIMUM CHECK ROUTINE
/	XY		ADDRESS OF WORD TO BE CHECKED
/	FLAG		ADDRESS OF X OR Y FLAG
/	MIN		ADDRESS OF LOCATION CONTAINING MINIMUM VALUE ALLOWED
/	MAX		ADDRESS OF LOCATION CONTAINING MAXIMUM VALUE ALLOWED+1
/
/	FLAG
/	     -2		IF CO-ORDINATE IS LESS THEN MINIMUM
/	     -1		IF CO-ORDINATE IS GREATER THEN OR EQUAL MAXIMUM+1
/	      0		IF CO-ORDINATE IS ON THE SCREEN
/-----------------------------------------------------------------------------
/
XMNMAX,	0
	CLA	CLL
	TAD  I  XMNMAX		/GET ADDRESS OF VALUE FOR COMPARISONS
	DCA	MVALUE		/SAVE THE ADDRESS
	ISZ	XMNMAX		/UPDATE PARAMETER POINTER
	TAD  I  XMNMAX		/GET ADDRESS OF FLAG
	DCA	MFLAG		/SAVE THE ADDRESS OF THE FLAG
	CLA CLL CMA RAL		/INITIALIZE THE FLAG TO BE LESS THEN MINIMUM
	DCA  I  MFLAG		/SAVE THE FLAG AS BEING LESS THEN MIN
	ISZ	XMNMAX		/UPDATE THE PARAMETER POINTER
	TAD  I  XMNMAX		/GET THE ADDRESS OF THE MINIMUM
	DCA	MLIMIT		/SAVE THE ADDRESS
	ISZ	XMNMAX		/UPDATE THE PARAMTER POINTER
	TAD  I  MVALUE		/CHECK IF THE SIGN IS NEGATIVE
	SPA	CLA		/IF NOT - THEN CHECK IF BEFORE DISPLAY REGION
	JMP	MEXIT		/POINT DEFINITELY BEFORE THE SCREEN - EXIT
	TAD  I  MLIMIT		/GET THE LOWER LIMIT
	CIA			/NEGATE IT
	TAD  I  MVALUE		/GET THE CO-ORDINATE VLAUE
	SPA	CLA		/SKIP IF GREATER THEN MINIMUM
	JMP	MEXIT		/EXIT VALUE LESS THEN MIN - FLAG = -2
	ISZ  I  MFLAG		/UPDATE THE FLAG TO BE GREATER THEN MAX
	TAD  I  XMNMAX		/GET THE ADDRESS OF THE MAXIMUM ALLOWED
	DCA	MLIMIT		/SAVE THE ADDRESS
	TAD  I  MLIMIT		/GET THE MAXIMUM ALLOWED VALUE +1
	CIA			/NEGATE IT
	TAD  I  MVALUE		/GET THE CO-ORDINATE VLAUE
	SPA	CLA		/SKIP IF VALUE >= MAXIMUM +1
	DCA  I  MFLAG		/THIS CO-ORDINATE IS VALID FLAG = 0
MEXIT,	ISZ	XMNMAX		/UPDATE THE RETURN POINTER
	JMP  I  XMNMAX		/EXIT BACK TO CALLER
/
MVALUE,	0			/POINTER TO CO-ORDINATE
MFLAG,	0			/POINTER TO CO-ORDINATES FLAG
MLIMIT,	0			/POINTER TO MIN OR MAX COMPARISON VALUES

/ ---------------------------------------------
/ COPPRM - COPY PRAM STRING FROM USER TO 'DRAW'
/ ---------------------------------------------
/
COPPRM,	0
/
	ACNEG1			/GET POINTER (-1) TO USER STRING
	TAD I	XDRWT5
	DCA	AUTO10
/
	ACNEG1			/GET POINTER (-1) TO DRAW'S STRING
	TAD	XDRWPR
	DCA	AUTO11
/
COPPR2,	TAD I	AUTO10		/GET A WORD
	SPA			/CHECK FOR TERMINATOR (7777)
	JMP	COPPR4		/IS TERMINATOR, GO FINISH
	DCA I	AUTO11		/NOT YET DONE, SAVE THE WORD
	JMP	COPPR2		/  AND TRY ANOTHER
/
COPPR4,	DCA I	AUTO11		/SAVE THE TERMINATOR, TOO
/
	JMP I	COPPRM		/RETURN
/
/
XDRWT5,	DRAWT5
/
/
/ ------------------
/ COPDAT - MOVE DATA
/ ------------------
/
COPDAT,	0
	DCA	COPCNT		/SAVE THE NUMBER OF WORDS TO COPY
	TAD  I  COPDAT		/GET ADDRESS OF DATA TO BE MOVED
	DCA	AUTO10		/SAVE ADDRESS -1
	ISZ	COPDAT
	TAD  I  COPDAT		/GET ADDRESS OF WHERE TO STORE DATA
	DCA	AUTO11		/SAVE ADDRESS -1
	ISZ	COPDAT		/UPDATE THE RETURN POINTER
COPLOP,	TAD  I  AUTO10		/GET THE WORD TO BE MOVED
	DCA  I  AUTO11		/MOVE THE WORD
	ISZ	COPCNT		/DONE ?
	JMP	COPLOP		/NO - MOVE NEXT WORD
	JMP  I  COPDAT		/EXIT
/
COPCNT,	0

/-------------------------------------------------------------------------------
/ LODPRM - LOAD PRAM STRING WITH 0377'S
/------------------------------------------------------------------------------
/
LODPRM,	0
/
	TAD	XDRWPR		/GET ADDRESS OF PRAM STRING
	DCA	AUTO10
	TAD	XDRWPR		/GET IT AGAIN
	DCA	AUTO11
/
LODPR2,	TAD I	AUTO10		/GET A PARAMETER FROM STRING
	SPA			/CHECK IF TERMINATOR (7777)
	JMP	LODPR4		/FINISH UP, IF SO
/
	CLA CLL
	TAD	K0377		/NOT YET AT TERMINATOR, GET A 0377
	DCA I	AUTO11		/PUT IT INTO PRAM STRING
/
	JMP 	LODPR2		/REPEAT UNTIL STRING TERMINATED
/
LODPR4,	DCA I	AUTO11		/PACK AWAY THE TERMINATOR
	JMP I	LODPRM		/RETURN
/
/
XDRWPR,	DRWPRM			/POINTER TO ADDRESS OF PRAM STRING
/
/

/-------------------------------------------------------------------------------
/ COMPRM - COMPLEMENT PRAM STRING
/-------------------------------------------------------------------------------
/
COMPRM,	0
/
	TAD	XDRWPR		/GET ADDRESS OF PRAM STRING
	DCA	AUTO10
	TAD	XDRWPR		/GET ADDRESS AGAIN
	DCA	AUTO11
/
COMPR2,	TAD I	AUTO10		/GET A PARAMETER FROM THE STRING
	SPA			/CHECK IF TERMINATOR
	JMP	COMPR4		/IF SO, FINISH UP
/
	CMA			/NOT YET TERMINATOR, COMPLEMENT ARGUMENT
	AND	K0377		/MASK TO EIGHT BITS
	DCA I	AUTO11		/PUT BACK INTO STRING
	JMP	COMPR2		/REPEAT UNTIL TERMINATOR
/
COMPR4,	DCA I	AUTO11		/PACK AWAY TERMINATOR
	JMP I	COMPRM		/RETURN

/
/
AREPAT,	570; 377; 377; 377; 377; 377; 377; 377; 377	/PRAM (GETS MODIFIED)
	7777
SAREA,	514
SAREP1,	22; 0; 0; 0; 0; 0; 0				/FIGS
	550						/GCHRD
	7777						/TERMINATOR
/
/
DRWPRM,	ZBLOCK	0012		/STORAGE FOR 'DRAW'S PRAM STRING
				/(THIS IS BIG ENOUGH FOR LONGEST PRAM STRING)
/
/ POSITION CURSOR
/
SPOSIT,	511; 0; 0; 0		/MODIFIED IN CODE
	7777

	PAGE
/------------------------------------------------------------------------------
/ XSGNCK - ADD TWO NUMBERS - IF LIKE SIGNS AND OPPOSITE SIGN ON RESULT - INVALID
/          ON EXIT AC= RESULT OF ADDITION OR DEFAULT VALUES IF OVERFLOW
/-------------------------------------------------------------------------------
/
XSGNCK,	0
	DCA	NUM1		/SAVE THE FIRST NUMBER TO ADD
	CLA CLL CMA RAL		/-2
	DCA	SGNFLG		/SET THE SIGN FLAG
	TAD  I  XSGNCK		/GET THE ADDRESS OF THE SECOND NUMBER TO ADD
	DCA	ADDNUM		/SAVE THE ADDRESS
	ISZ	XSGNCK		/UPDATE POINTER FOR RETURN
	TAD  I  ADDNUM		/GET THE SECOND NUMBER
	SMA			/CHECK IF SIGN IS MINUS
	JMP	POSCHK		/NO - SIGN IS POSITIVE
	DCA	ADDNUM		/SAVE THE SECOND NUMBER
	TAD	NUM1		/GET THE FIRST NUMBER
	SPA			/IS IT POSITIVE ?
	ISZ	SGNFLG		/NO - THEN TWO NEGATVE NUMBERS BEING ADDED
	TAD	ADDNUM		/ADD THE SECOND NUMBER TO THE FIRST
	SPA			/POSITVE RESULT
	JMP	ADDOK		/RESULT NEGATIVE - NO FURTHER CHECKING NEEDED
	JMP	CKLSGN		/GO CHECK IF TWO NUMBERS HAD LIKE SIGNS
POSCHK,	DCA	ADDNUM		/SAVE THE SECOND NUMBER
	TAD	NUM1		/GET THE FIRST NUMBER
	SMA			/IS IT NEGATIVE ?
	ISZ	SGNFLG		/NO - THEN TWO POSITIVE NUMBERS BEING ADDED
	TAD	ADDNUM		/ADD SECOND NUMBER TO FIRST
	SMA			/NEGATIVE RESULT
	JMP	ADDOK		/POSITVE RESULT - NO FURTHER CHECKING NEEDED
CKLSGN,	CLL	CML		/SET LINK IN CASE NUMBERS CAUSED OVERFLOW
	ISZ	SGNFLG		/SKIP IF THERE WAS AN OVERFLOW
ADDOK,	CLL			/NO - NUMBERS ADDED ARE OK
	SNL			/SKIP IF AN OVERFLOW ERROR EXISTS
	JMP  I  XSGNCK		/LINK=0 FOR VALID ADD - LINK=1 ON OVERFLOW
	CLA
	TAD	ADDNUM		/GET ONE OF THE NUMBERS
	SPA	CLA		/CHECK ITS SIGN
	IAC			/DEFAULT VALUE TO -2048
	TAD	C3777		/DEFAULT VALUE TO +2047
	JMP  I  XSGNCK		/EXIT BACK WITH DEFAULT VALUE IN AC
/
NUM1,	0
ADDNUM,	0
SGNFLG,	0
C3777,	3777

/ ----------------------------------------------------------
/ SENDAL - SEND COMMANDS AND DATA TO THE GRAPHICS CONTROLLER
/ ----------------------------------------------------------
/
/ COMMANDS AND DATA ARE IN A STRING WHOSE ADDRESS FOLLOWS CALL
/ A 7777 TERMINATES THE STRING
/
SENDAL,	0
/
	CLA CLL			/GET STRING ADDRESS
	TAD I	SENDAL
	TAD	M0001		/BACK UP STRING POINTER
	DCA	AUTO10
/
	ISZ	SENDAL		/INCREMENT TO CORRECT RETURN ADDRESS
/
SENDA2,	TAD I	AUTO10		/GET A VALUE
	IAC			/CHECK FOR TERMINATOR
	SNA
	JMP I	SENDAL		/RETURN IF TERMINATOR
/
	TAD	M0001		/RESTORE VALUE
	AND	K0777		/MASK TO NINE BITS
	DCA	STEMP
/
SENDA4,	GRGR			/READ STATUS
	RTR			/ROTATE 'FIFO FULL' TO LINK
	SZL CLA
	JMP	SENDA4		/LOOP ON STATUS CHECK UNTIL ROOM IN FIFO
/
	TAD	STEMP		/GET THE VALUE BACK
	GRGW			/SEND TO GDC
	CLA
	JMP	SENDA2		/LOOP THROUGH VALUES TO SEND
/
STEMP,	0
K0777,	0777

/ ----------------------------------------
/ SLINE - GDC FIGS STRING FOR LINE DRAWING
/ ----------------------------------------
/
SLINE,	514; 10; 0; 0; 0; 0; 0; 0; 0; 0		/FIGS (MODIFIED IN CODE)
	554					/FIGD
	7777					/TERMINATOR

/----------------------------------------------------------------------------
/ XCURSR - TURN THE GRAPHIC CURSOR ON OR OFF
/-----------------------------------------------------------------------------
/
XCURSR,	0
	TAD	PWRUPF			/GET THE POWER UP FLAG
	CIA				/NEGATE IT
	TAD	OPCODE			/CHECK IT AGAINST PRESENT OPCODE
	SNA	CLA			/SKIP IF NOT POWER UP
	JMP  I  XCURSR			/EXIT
	TAD	CURFLG			/GET THE CURSOR FLAG
	SPA	CLA			/SKIP IF NOT TURNED ON
	JMP	OFFON			/CURSOR ON - UNCONDITIONALLY CLEAR IT
	CLA CLL IAC			/SETUP TO CHECK IF CURSOR ENABLED
	AND	CURFLG			/MASK TO CURSOR ENABLE/DISABLE BIT
	SZA	CLA			/SKIP IF ENABLED
	JMP  I  XCURSR			/EXIT - CURSOR DISABLED
OFFON,	CHKXY1				/CHECK STARTING POINTS - FLAGS RETURNED
	SZA	CLA			/SKIP IF BOTH POINTS ON SCREEN
	JMP  I  XCURSR			/EXIT - CURSOR OFF THE SCREEN
	TAD	CURFLG			/GET THE CURSOR FLAG AGAIN
	CLL	RAL			/PUT OFF ON BIT INTO LINK
	CML				/COMPLEMENT IT
	RAR				/RESTORE WORD WITH OFF/ON COMPLEMENTED
	DCA	CURFLG			/SAVE THE UPDATED CURSOR FLAG
/
	CIF	TBLFLD			/AUXILIARY FIELD FOR ROUTINE
	JMS I	XSAVMO			/SAVE WRITING MODES
/
	AC0002				/FORCE WRITING MODE TO 'COMPLEMENT'
	DCA	WRMODE
	DCA	NEGFLG			/FORCE NEGATE MODE OFF
	DCA	SHDFLG			/FORCE SHADE MODE OFF
/
	AC0010			/SET UP INITIAL DIRECTION FOR FIRST 'HAIR'
	DCA I	XCRSRD
/
	BLDPOS				/BUILD THE CURSOR POSITION
	CURCUR				/ADDRESS OF GRAPHIC CURSOR STRING
/
	TAD	M0004			/DO FOUR 'HAIRS'
	DCA	XCURTM
/
XCURS4,	DRAWIT				/TURN THE CURSOR ON/OFF
	CURCUR
	CURFIG
	CURPRA
/
	AC0002				/ROTATE 'HAIR' 90 DEGREES
	TAD I	XCRSRD
	DCA I	XCRSRD			/  BY CHANGING FIGS DIRECTION
/
	ISZ	XCURTM			/INCREMENT THROUGH ALL FOUR 'HAIRS'
	JMP	XCURS4
/
	CIF	TBLFLD			/AUXILIARY FIELD FOR ROUTINE
	JMS I	XRESMO			/RESTORE ORIGINAL WRITING MODES
/
	JMP  I  XCURSR			/EXIT
/
PWRUPF,	PWR				/POWER UP OPERATION CODE
M0700,	-0700
M40,	-0040
K20,	0020
XCURTM,	0
XCRSRD,	CURFIG+1
XSAVMO,	SAVMOD
XRESMO,	RESMOD

	PAGE
/ ---------------------------------------------------------------------------
/ XERASE - ERASE THE GRAPHICS SCREEN
/ ---------------------------------------------------------------------------
/
XERASE,	0
	SENDIT			/CURSOR TO HOME
	SHOME
	LDREG1			/SELECT PLANES 1, 2, AND 3
	71
	SENDIT			/ERASE THE SCREEN
	SERASE
	JMP I	XERASE		/RETURN

/-------------------------------------------------------------------------------
/ DOPOS - BUILD A COMMAND TO POSITION THE CURSOR
/ -----------------------------------------------------------------------------
/
DOPOS,	0
	CLA	CLL
	TAD	YPOS1		/GET THE LOGICAL Y CO-ORDINATE POSITION
	CLL	RAR		/DIVIDE IT BY 2
	DCA	PYPOS1		/SAVE FOR FURTHER USE AS PHYSICAL Y CO-ORDINATE
	TAD I	DOPOS		/GET ADDRESS OF 'CURS' COMMAND STRING
	DCA	AUTO10		/  INTO AUTOINCREMENTING REGISTER
	ISZ	DOPOS		/INCREMENT TO CORRECT RETURN ADDRESS
	TAD	XPOS1		/BUILD 'P1' ARGUMENT FROM X AND Y POSITIONS
	RTR
	RTR
	AND	K0077
	DCA	DOTEMP
	TAD	PYPOS1
	BSW
	AND	K0300
	TAD	DOTEMP
	DCA I	AUTO10
	TAD	PYPOS1		/BUILD 'P2' ARGUMENT FROM Y POSITION
	RTR
	AND	K0077
	DCA I	AUTO10
	TAD	XPOS1		/BUILD 'P3' ARGUMENT FROM X POSITION
	RTL
	RTL
	AND	K0360
	DCA I	AUTO10
	JMP I	DOPOS		/RETURN
/
DOTEMP,	0
K0300,	300
K0360,	360

/-------------------------------------------------------------------------------
/ GTLMLT - GET LINE MULTIPLIER - 0 OR 1 =1 2 OR GREATER IMPLIES 2
/-------------------------------------------------------------------------------
/
GTLMLT,	0
	GETPRM			/GET LINE PATTERN MULTIPLIER FROM CALLING FIELD
	SNA	SPA		/SKIP IF NUMBER GREATER THEN 0
	CLA	IAC		/WAS 0 OR LESS - DEFAULT TO 1
	DCA	PATMLT		/SAVE THE PATTERN MULTIPLIER
	JMS I	XXUPDP		/GO UPDATE THE LINE DRAWING PATTERN
	JMP  I  GTLMLT		/EXIT BACK TO CALLER
/
/
XXUPDP,	UPDPAT

/-----------------------------------------------------------------------------
/ SCRDMP - RDAT READ FOR SCREEN DUMP
/------------------------------------------------------------------------------
/
/ CONTROL BLOCK:
/	0024		/COMMAND 20. - READ PIXELS FROM SCREEN
/	X-POSITION
/	Y-POSITION
/	48.-WORD BLOCK FOR RETURN DATA
/	BACKGROUND COLOR OF LAST SCREEN ERASE

SCRDMP,	0
	JMS  I  XSVCUR		/SAVE PRESENT CURSOR POSITION
	GETXY1			/GET X AND Y POSITIONS FROM CALLER
	BLDPOS			/CREATE 'POSITION CURSOR' STRING
	SCRDS2
	TAD	M0004		/SET UP FOR FOUR PLANES
	DCA	SCRDT3
	DCA	SCRDM2		/ENSURE STARTING WITH GREEN PLANE
SCRDM1,	LDREG1			/ENSURE READING FROM CORRECT PLANE
SCRDM2,	00			/(MODIFIED IN CODE)
	TAD	M14
	DCA	SCRDT1		/SET UP FOR COUNT OF 12. BYTES
	SENDIT			/SET UP FOR DMA READ
	SCRDS2
SCRDM5,	GRGR			/READ GDC'S STATUS
	RAR			/ROTATE DATA READY BIT TO LINK
	SNL CLA
	JMP	SCRDM5		/LOOP UNTIL IT'S SET
	TAD	KK0400		/FORCE A FIFO READ
	GRGR			/READ BYTE FROM FIFO
	AND	K0377		/MASK TO A BYTE
	PUTPRM			/PUT IN CALLER'S CONTROL BLOCK
	ISZ	SCRDT1		/INCREMENT COUNTER
	JMP	SCRDM5		/LOOP THROUGH READ OF THIS PLANE
	TAD	KKK25		/UPDATE THE PLANE
	TAD	SCRDM2		/BUMP REGISTER ONE TO NEXT PLANE
	DCA	SCRDM2
	AC100			/BUMP CURSOR POSITION TO CORRECT PLANE
	TAD	SCRDS2+2	/
	DCA	SCRDS2+2
	ISZ	SCRDT3		/INCREMENT THROUGH PLANE COUNTER
	JMP	SCRDM1
	TAD	PRTBCL		/GET THE LAST SCREEN ERASE BACKGROUND COLOR
	PUTPRM			/PUT IT IN THE CALLER'S CONTROL BLOCK
	JMS  I  XRSCUR		/RESTORE THE ORIGINAL CURSOR POSITION
	JMP I	SCRDMP		/RETURN
/
SCRDS2,	511; 0; 0; 0			/CURS TO HOME
	512; 377; 377			/MASK
	514; 0; 6; 0			/FIGS
	640				/RDAT
	7777
/
XSVCUR,	SAVCUR			/SAVE THE PRESENT CURSOR POSITION
XRSCUR,	CURRST			/RESTORE CURSOR PPOSITION SAVED
SCRDT1,	0
SCRDT3,	0
KK0400,	0400
KKK25,	25
M14,	-14
/
CURCUR,	511; 0; 0; 0			/'CURSOR' CURSOR STRING
	7777
/
CURPRA,	570; 377; 377			/'CURSOR' PRAM - SOLID LINE
	7777
/
					/'CURSOR' FIGS
CURFIG,	514; 10; 10; 0; 370; 77; 360; 77; 0; 0
	554
	7777
/
DUMMY,	570			/DUMMY COMMAND BEFORE LOADING REGISTER 1
	7777

	PAGE
/------------------------------------------------------------------------------
/ SVTMPW - SAVE WRITE OPTIONS
/------------------------------------------------------------------------------
/
SVTMPW,	0
	TAD	SVRSTF			/GET THE WRITE OPTION'S SAVE/RESTORE FLAG
	SZA	CLA			/SKIP IF OPTIONS NOT SAVED PREVIOUSLY
	JMP  I  SVTMPW			/EXIT - OPTIONS ALREADY SAVED
	ISZ	SVRSTF			/SET FLAG EQUAL SAVE
	TAD	MWOSVT			/GET NUMBER OF WORDS TO SAVE
	JMS  I  XCOPY			/GO STORE THE WRITE OPTIONS
	FCOLOR-1			/ADDRESS -1 OF WORDS TO BE SAVED
	WOPTBF-1			/ADDRESS -1 OF WHERE TO STORE WRITE OPTIONS
	JMP  I  SVTMPW			/EXIT - WRITE OPTIONS SAVED

/------------------------------------------------------------------------------
/ RSTMPW - RESTORE WRITE OPTIONS
/------------------------------------------------------------------------------
/
RSTMPW,	0
	TAD	SVRSTF			/GET THE SAVE/RESTORE FLAG
	SNA	CLA			/SKIP IF WRITE OPTIONS SAVES PREVIOUSLY
	JMP  I  RSTMPW			/EXIT
	DCA	SVRSTF			/SET SAVE-RESTORE FLAG=RESTORE
	TAD	MWOSVT			/GET NUMBER OF WORDS TO BE RESTORED
	JMS  I  XCOPY			/GO RESTORE WRITE OPTIONS SAVED
	WOPTBF-1			/ADDRESS -1  OF WRITE OPTION BUFFER
	FCOLOR-1			/ADDRESS -1 OF WHERE TO RESTORE OPTIONS
	JMS  I  XUPDPT			/GO REBUILD THE LINE PATTERN
	JMP  I  RSTMPW			/EXIT - WRITE OPTIONS RESTORED
/
XCOPY,	COPDAT
XUPDPT,	GTATXT
MWOSVT,	-TMPSIZ
/
CHRBMP,	ZBLOCK	10		/AREA PATTERN FOR SHADING
/
SHOME,	511; 0; 0; 0		/MOVE CURSOR HOME
	7777

/-----------------------------------------------------------------------------
/ PRIMRT -  SUBROUTINES FOR GRAPHIC PRIMITIVES
/		DBLADD		/DOUBLE PRECISION ADD - RESULT IN ACHW + ACLW
/		DBLSUB		/DOUBLE PRECISION SUB - RESULT IN ACHW + ACLW
/		DBLMTY		/DOUBLE PRECISION SIGN MULT - RESULT ACH-MQL
/		DBLDIV		/DOUBLE PRECISION SIGN DIVIDE - RESULT MQH-MQL
/		CNVDBL		/CONVERT SINGLE WORD TO DOUBLE PRECISION WORD
/
/-----------------------------------------------------------------------------

/-----------------------------------------------------------------------------
/ RNDOFF - ROUND UP THE QUOTIENT FROM THE DOUBLE PRECISION SIGNED DIVIDE
/-----------------------------------------------------------------------------
/
RNDOFF,	0
	TAD	SRH		/GET THE HIGH WORD OF POSITIVE DIVISOR
	CLL	RAR		/DIVIDE IT BY 2 - LINK AS LSB OF DIVIDE
	DCA	SRH		/SAVE THE HIGH WORD OF DIVISOR
	TAD	SRL		/GET THE LOW WORD OF DIVISOR
	RAR			/DIVIDE IT BY 2 ADDING IN LSB FROM HIGH WORD
	DCA	SRL		/SAVE THE LOW WORD OF DIVISOR
	DBLSUB			/SUBRACT (DIVISION REMAINDER-DIVISOR/2)
	SRH			/ADDRESS OF DIVISOR/2
	SRH			/WHERE TO STORE RESULT OF SUBTRACTION
	TAD	SRH		/GET HIGH WORD RESULT OF SUBTRACTION
	SMA	SZA		/SKIP IF DIVISOR/2 >= REMAINDER
	JMP	RNDUP1		/DIVISOR/2 < REMAINDER - GO ROUND UP QUOTIENT
	SZA	CLA		/CHECK ID DIVISOR/2 <= REMAINDER
	JMP	RNDEXT		/EXIT - DIVISOR/2 > REMAINDER
RNDUP1,	ISZ	MQLW		/UPDATE LOW WORD OF QUOTIENT
	SKP	CLA		/SKIP IF NO OVERFLOW
	ISZ	MQHW		/UPDATE HIGH WORD OF QUOTIENT IF OVERFLOW
	NOP			/SAFETY
RNDEXT,	CLA	CLL		/EXIT WITH AC AND LINK CLEARED
	JMP  I  RNDOFF		/EXIT BACK TO DIVISION ROUTINE

/-----------------------------------------------------------------------------
/ TADD - DOUBLE PRECISION ADDITION ROUTINE
/-----------------------------------------------------------------------------
/
/	SETUP LOCATIONS ACHW AND ACLW PRIOR TO ENTRANCE
/	DBLADD
/	ADDR1		/ADDRESS OF DATA TO BE ADDED
/	ADDR2		/ADDRESS OF WHERE TO STORE RESULTS OF ADD
/
TADD,	0
	CLA	CLL
	TAD  I  TADD		/GET ADDRESS OF ADDEND
	JMS	GET		/MOVE ADDEND TO SR
	JMS	ADDS		/ADD SR TO AC
	ISZ	TADD		/UPDATE RETURN POINTER
	TAD  I  TADD		/ADDRESS OF WHERE RESULT IS TO BE STORED
	JMS	PUT		/STORE THE DATA
	ISZ	TADD		/UPDATE POINTER FOR RETURN
	JMP  I  TADD		/RETURN - RESULTS IN ACH AND ACL

/-------------------------------------------------------------------------------
/ TSUB - SIGNED DOUBLE PRECISION SUBTRACTION ROUTINE
/-------------------------------------------------------------------------------
/
/	SETUP LOCATIONS ACHW AND ACLW WITH INITIAL DATA BEFORE SUBTRACTION
/	DBLSUB			/CALL THE SUBTRACTION ROUTINE
/	ADDR1			/ADDRESS OF DATA TO BE SUBTRACTED (HIGH WORD)
/	ADDR2			/ADDRESS OF WHERE TO STORE RESULTS OF SUB
/
TSUB,	0
	CLA	CLL
	TAD  I  TSUB		/GET ADDRESS OF SUBTRAHEND
	JMS	GET		/MOVE SUBTRAHEND TO SR
	JMS	COMP		/COMPLEMENT SR
	SRH			/ADDRESS OF DATA TO BE COMPLEMENTED
	JMS	ADDS		/ADD SR TO AC
	ISZ	TSUB		/UPDATE RETURN POINTER
	TAD  I  TSUB		/GET ADDRESS OF WHERE TO STORE RESULTS
	JMS	PUT		/GO STORE THE RESULTS
	ISZ	TSUB		/UPDATE THE RETURN POINTER
	JMP  I  TSUB		/EXIT - RESULTS OF SUB IN ACH AND ACL

/
/ ROUTINE TO GET HIGH AND LOW WORD OF DATA AND STORE IN SRH AND SRL
/
GET,	0
	DCA	ERAS		/SAVE THE ADDRESS
	TAD  I  ERAS		/GET HIGH WORD
	DCA	SRH		/SAVE
	ISZ	ERAS		/MOVE POINTER TO LOW WORD
	TAD  I  ERAS		/GET TEH LOW WORD
	DCA	SRL		/SAVE
	JMP  I  GET		/EXIT - SRH AND SRL LOADED

/
/ ROUTINE TO STORE DATA INTO CALLING SPECIFIED ADDRESS
/
PUT,	0
	DCA	ERAS		/SAVE THE ADDRESS OF WHERE TO STORE DATA
	TAD	ACHW		/GET THE HIGH ORDER RESULT
	DCA  I  ERAS		/PUT IN CALLING ROUTINES SPECIFIED ADDRESS
	ISZ	ERAS		/UPDATE ADDRESS TO LOW WORD
	TAD	ACLW		/GET THE LOW ORDER RESULT
	DCA  I  ERAS		/PUT IT IN CALLING ROUTINES SPECIFIED ADDRESS
	JMP  I  PUT		/EXIT

/
/ ROUTINE TO ADD THE TWO 24 BIT WORDS
/
ADDS,	0
	CLA	CLL
	TAD	ACLW		/GET LOW ORDER WORD
	TAD	SRL		/GET LOW ORDER OF ADDEND
	DCA	ACLW		/SAVE THE RESULT
	GLK			/GET THE CARRY
	TAD	ACHW		/ADD IT TO HIGH ORDER WORD
	TAD	SRH		/ADD THAT TO HIGH ORDER ADDEND
	DCA	ACHW		/SAVE THE RESULT
	JMP  I  ADDS		/EXIT

/
/ ROUTINE TO COMPLEMENT THE 24 BIT WORD
/
COMP,	0
	CLA CLL IAC		/1
	TAD  I  COMP		/+HIGH ORDER ADDRESS
	DCA	ERAS		/SAVE AS LOW ORDER WORD ADDRESS
	TAD  I  ERAS		/GET THE LOW ORDER WORD
	CIA			/NEGATE IT
	DCA  I  ERAS		/SAVE THE LOW ORDER PRODUCT
	GLK			/GET THE CARRY BIT
	DCA	ERAS		/SAVE IT
	TAD  I  COMP		/GET THE HIGH ORDER WORD ADDRESS
	DCA	ERASX		/SAVE THE ADDRESS
	TAD  I  ERASX		/GET THE HIGH ORDER WORD
	CMA			/1'S COMPLEMENT IT
	TAD	ERAS		/ADD CARRY TO IT
	DCA  I  ERASX		/SAVE THE NEW HIGH ORDER WORD
	ISZ	COMP		/UPDATE POINTER FOR RETURN
	JMP  I  COMP		/RETURN
/
ERASX,	0
ERAS,	0

	PAGE
/
/-----------------------------------------------------------------------------
/ TMPY - DOUBLE PRECISION SIGNED MULTIPLY - RETURN WITH RESULTS IN ACHW-MQLW
/-----------------------------------------------------------------------------
/
/	DBLMTY			/CALL DOUBLE PRECISION SIGNED MULTIPLY
/	ADDR1			/ADDRESS OF DOUBLE WORD MULTIPLICAND
/	ADDR2			/ADDRESS OF DOUBLE WORD MULTIPLIER
/
/	RETURN WITH RESULTS IN ACWH-MQLW

TMPY,	0
	CLA	CLL
	TAD  I  TMPY		/GET ADDRESS OF HIGH WORD MULTIPLICAND
	DCA	MERAS		/SAVE IT
	TAD  I  MERAS		/GET HIGH ORDER WORD MULTIPLICAND
	DCA	MQHW		/SAVE IT
	ISZ	MERAS		/POINT TO LOW WORD MULTIPLICAND
	TAD  I  MERAS		/GET LOW ORDER WORD MULTIPLICAND
	DCA	MQLW		/SAVE IT
	ISZ	TMPY		/INDEX OVER ADDRESS
	DCA	ACLW		/CLEAR LOW WORD OF AC
	DCA	ACHW		/CLEAR HIGH WORD OF AC
	DCA	MSIGN		/SET SIGN OF RESULT SWITCH
	TAD  I  TMPY		/GET ADDRESS OF MULTIPLIER
	DCA	MERAS		/SAVE IT
	TAD  I  MERAS		/GET HIGH WORD OF MULTIPLIER
	DCA	SRH		/SAVE IT
	ISZ	TMPY		/UPDATE THE RETURN POINTER
	ISZ	MERAS		/POINT TO LOW WORD OF MULTIPLIER
	TAD  I  MERAS		/GET LOW WORD OF MULTIPLIER
	DCA	SRL		/SAVE IT
	TAD	MQHW		/HIGH ORDER MULTIPLICAND
	SMA	CLA		/IS IT NEGATIVE
	JMP	TMPY1		/NO
	ISZ	MSIGN		/YES - SET SIGN SWITCH
	JMS  I  XCOMP		/GO COMPLEMENT THE MULTIPLICAND
	MQHW			/ADDRESS OF DATA TO BE COMPLEMENTED
TMPY1,	TAD	SRH		/HIGH ORDER MULTIPLIER
	SMA	CLA		/IS IT NEGATIVE
	JMP	TMPY2		/NO
	ISZ	MSIGN		/YES - SET SIGN SWITCH
	JMS  I  XCOMP		/GO COMPLEMENT MULTIPLIER
	SRH
TMPY2,	TAD	M30		/-24
	DCA	MSHCT		/-24 TO SHIFT COUNTER

/ THIS IS THE MULTIPLICATION LOOP
/

MLP,	CLA	CLL
	TAD	MQLW		/LOW ORDER MQ
	RAR			/OBTAIN RIGHTMOST BIT
	SNL			/WAS IT A 1
	JMP	MSHFT		/NO .... JUST SHIFT
	CLA	CLL		/YES ... ADD SR TO AC
	TAD	ACLW		/LOW ORDER ADD
	TAD	SRL		/
	DCA	ACLW		/SAVE TRE RESULT
	GLK			/GET THE CARRY
	TAD	ACHW		/HIGH ORDER ADD
	TAD	SRH		/
	DCA	ACHW		/SAVE THE RESULT
/
/ NOW SHIFT AC AND MQ RIGHT ONE PLACE
/ AS A 48 BIT REGISTER
/
MSHFT,	CLA	CLL
	DCA	MERAS		/ZERO SHIFT BIT LOC
	TAD	AMSHCT		/ADDRESS OF HIGH ORDER AC-1
	DCA	AUTO16		/SAVE TO AUTO INDEX REGISTER 6
	TAD	AMSHCT		/ADDRESS OF HIGH ORDER AC-1
	DCA	AUTO17		/SAVE TO AUTO INDEX REGISTER 7
	TAD	M0004		/-4
	DCA	MERASX		/SAVE WORD COUNT
MSHFT1,	TAD  I  AUTO16		/GET WORD
	RAR			/SHIFT RIGHT 1
	TAD	MERAS		/+ BIT SHIFTED OUT OF LAST WORD
	DCA  I  AUTO17		/SAVE TO SAME WORD
	RAR			/CARRY TO HIGH ORDER AC
	DCA	MERAS		/TO BIT LOST LOCATION
	ISZ	MERASX		/INDEX ON # OF WORDS IN AC-MQ (4)
	JMP	MSHFT1		/RETURN FOR NEXT WORD
	ISZ	MSHCT		/INDEX ON SHIFT COUNTER
	JMP	MLP		/RETURN FOR MORE
/
/ OVER WITH MULTIPLICATION
/ NOW SET SIGN OF RESULT
/
	CLA	CLL
	TAD	MSIGN		/GET THE SIGN
	RAR			/SHIFT RIGHT ONE
	SNL	CLA		/WAS IT AND ODD NO
	JMP  I  TMPY		/NO...RETURN WITH POSITIVE NUMBER IN AC-MQ
	JMS	C48		/YES..COMPLEMENT 48 BIT PRODUCT
	JMP  I  TMPY		/RETURN WITH COMPLEMENTED PRODUCT IN AC-MQ

/ SUBROUTINE TO COMPLEMENT AC AND MQ
/ AS 1 48 BIT REGISTER
/
C48,	0
	CLA	CLL
	TAD	M0004		/SETUP FOR 4 WORDS
	DCA	MERAS		/SAVE COUNTER
	TAD	AMQLW		/GET ADDRESS OF LOW WORD MQ
	DCA	MERASX		/SAVE IT
	TAD	MQLW		/GET LOW ORDER MQ
	CIA			/NEGATE IT
	JMP	C48B		/ENTER LOOP IN MIDDLE
/
C48A,	CLA CMA CLL CML		/
	TAD	MERASX		/-1+ADDRESS OF CURRENT REGISTER
	DCA	MERASX		/NEW ADDRESS
	TAD  I  MERASX		/CONTENTS OF CURRENT REGISTER
	CMA			/1'S COMP IT
	TAD	MSIGN		/+OVERFLOW BIT
C48B,	DCA  I  MERASX		/BACK TO REGISTER
	GLK			/OVERFLOW BIT
	DCA	MSIGN		/SAVE OVERFLOW BIT
	ISZ	MERAS		/UPDATE WORD COUNTER
	JMP	C48A		/RETURN FOR MORE
	JMP  I  C48		/RETURN WITH COMP # IN AC-MQ
MERASX,	0
MERAS,	0
MSIGN,	0
M30,	-30
MSHCT,	0
/
AMSHCT,	ACHW-1
AMQLW,	MQLW
XCOMP,	COMP
/

/
/-----------------------------------------------------------------------------
/ CDBLW - CONVERT SINGLE WORD TO DOUBLE PRECISION NUMBER WITH SIGN EXTENSION
/-----------------------------------------------------------------------------
/
/	CNVDBL		/CONVERT SINGLE TO DOUBLE WORD WITH SIGN EXTENSION
/	ADDR1		/ADDRESS OF WORD TO BE CONVERTED
/	ADDR2		/ADDRESS OF WHERE TO STORE CONVERTED WORDS (HIGH,LOW)
/

CDBLW,	0
	TAD  I  CDBLW		/GET ADDRESS OF WORD TO BE CONVERTED
	DCA	CDBLW1		/SAVE ADDRESS
	ISZ	CDBLW		/UPDATE POINTER
	TAD  I  CDBLW		/GET THE ADDRESS OF WHERE TO STORE WORDS
	DCA	CDBLW2		/SAVE THE ADDRESS
	ISZ	CDBLW		/UPDATE POINTER FOR RETURN
	TAD  I  CDBLW1		/GET THE WORD TO BE CONVERTED
	SPA	CLA		/SIGN EXTEND IT ?
	CLA CLL CMA		/YES
	DCA  I  CDBLW2		/SAVE THE SIGN EXTENSION
	ISZ	CDBLW2		/UPDATE POINTER TO LOW PART OF WORD
	TAD  I  CDBLW1		/GET THE WORD TO BE CONVERTED
	DCA  I  CDBLW2		/STORE IT AS LOW PART OF DOUBLE WORD
	JMP  I  CDBLW		/EXIT - WORD CONVERTED TO DOUBLE PRECISION
/
CDBLW1,	0
CDBLW2,	0
/
SCRNON,	417; 26			/SCREEN FLASH MODE OFF, SCREEN ENABLE
	7777
/
SCRNOF,	416; 6			/SCREEN FLASH MODE ON AND SCREEN DISABLE
	7777
/

	PAGE
/-----------------------------------------------------------------------------
/ TDIV - DOUBLE PRECISION SIGNED DIVIDE - QUOTIENT IN MQ - REMAINDER IN ACHW-ACLW
/-----------------------------------------------------------------------------
/
/	SETUP ACHW-MQLW PRIOR TO CALL (48 BIT WORD)
/	DBLDIV		/CALL DOUBLE PRECISION DIVIDE
/	ADDR1		/ADDRESS OF DOUBLE WORD DIVISOR
/---NOTE:-----DIVIDE BY 0 NOT CHECKED - PROTECTED BY CODE OUTSIDE OF ROUTINE----

TDIV,	0
	CLA	CLL
	DCA	DSGN		/INITIALIZE SIGN FLAG
	TAD  I  TDIV		/GET ADDRESS OF DIVISOR
	DCA	TERAS		/SAVE THE ADDRESS OF HIGH ORDER DIVISOR
	ISZ	TDIV		/UPDATE RETURN POINTER FOR EXIT
	TAD  I  TERAS		/GET HIGH ORDER DIVISOR
	DCA	SRH		/SAVE THE HIGH ORDER DIVISOR
	ISZ	TERAS		/UPDATE POINTER TO LOW ORDER WORD
	TAD  I  TERAS		/GET THE LOW ORDER DIVISOR
	DCA	SRL		/SAVE THE LOW WORD DIVISOR
/
/ NOW CHECK THE SIGN ON EVERYTHING
/
	TAD	ACHW		/GET THE HIGH ORDER AC
	SMA	CLA		/IS IT NEGATIVE
	JMP	.+3		/NO
	ISZ	DSGN		/YES ... SET SIGN SWITCH
	JMS  I  IC48		/YES - COMPLEMENT 48 BIT WORD
	TAD	SRH		/COPY SR TO -SR (MSR)
	DCA	MSRH		/SAVE
	TAD	SRL		/LOW WORD
	DCA	MSRL		/SAVE IT
	TAD	SRH		/GET HIGH ORDER SR
	SMA	CLA		/IS IT NEGATIVE
	JMP	.+5		/NO....COMPLEMENT -SR
	ISZ	DSGN		/YES...SET SIGN SWITCH
	JMS  I  ICOM		/COMPLEMENT SR
	SRH
	JMP	.+3
	JMS  I  ICOM		/COMPLEMENT MSR IF POSITIVE
	MSRH

/
/ CHECK IF DIVISOR IS LARGER THEN DIVIDEND
/
	TAD	ACHW		/GET MOST SIGNIFICANT WORD
	SZA	CLA		/NON - ZERO
	JMP	DODIVD		/YES - DEFINATELY BIGGER
	TAD	ACLW		/GET NEXT LEAST SIGNIFICANT WORD
	SZA	CLA		/NON-ZERO
	JMP	DODIVD		/YES - DEFINATELY BIGGER THEN DIVISOR
	TAD	MQHW		/GET THE 3RD WORD OF DIVIDEND
	SMA	CLA		/CHECK IF MSB SET
	JMP	.+4		/NO - GO CHECK IF DIVISOR <= DIVIDEND
	TAD	SRH		/CHECK IF DIVISOR MSB SET
	SMA	CLA		/SKIP IF YES - THEN OK TO DO REGULAR CHECK
	JMP	DODIVD		/DIVIDEND DEFINATELY BIGGER THEN DIVISOR
	TAD	SRH		/GET THE DIVISOR
	CIA			/NEGATE IT
	TAD	MQHW		/GET NEXT SIGNIFICANT WORD OF DIVIDEND
	SPA			/DIVISOR > DIVIDEND
	JMP	RSLT0		/YES - FRACTION RETURN WITH RESULT OF 0
	SZA	CLA		/HIGH WORD OF DIVISOR = 3RD WORD OF DIVIDEND
	JMP	DODIVD		/NO - DIVISOR < DIVIDEND
	TAD	MQLW		/GET THE FORTH WORD OF DIVIDEND
	SMA	CLA		/CHECK IF MSB SET
	JMP	.+4		/NO - GO CHECK IF DIVISOR <= DIVIDEND
	TAD	SRL		/CHECK IF DIVISOR MSB SET
	SMA	CLA		/SKIP IF YES - GO CHECK LOW WORD OF DIVIDEND
	JMP	DODIVD		/DIVIDEND DEFINITELY BIGGER THEN DIVISOR
	TAD	SRL		/LOW WORD OF DIVISOR
	CIA			/NEGATE IT
	TAD	MQLW		/LOW WORD OF DIVIDEND
	SMA	CLA		/DIVISOR > DIVIDEND
	JMP	DODIVD		/NO DIVISOR <= DIVIDEND
RSLT0,	CLA	CLL
	TAD	MQHW		/GET THIRD WORD OF DIVIDEND
	DCA	ACHW		/SAVE IT AS A REMAINDER
	TAD	MQLW		/GET FORTH WORD OF DIVIDEND
	DCA	ACLW		/SAVE IT AS A REMAINDER
	DCA	MQHW		/ZERO THE 24 BIT QUOTIENT
	DCA	MQLW		/
	JMP	DIVEND		/GO DO ROUND OFF IF NEEDED

DODIVD,	TAD	DM30		/-24
	DCA	DSHC		/-24 TO SHIFT COUNTER

/ THIS BEGINS THE ACTUAL DIVIDE
/
/ FIRST SHIFT AC-MQ LEFT ONE PLACE
/

DLP,	CLA CLL CML		/SET THE LINK
	TAD	M0004		/-4
	DCA	TERAS		/SAVE TO INDEX LOCATION
	TAD	DMQLW		/ADDRESS OF LOW ORDER MQ
	DCA	TERASX		/SAVE TO ADDRESS INDEX LOCATION
/
DLP1,	CLA	CML
	TAD  I  TERASX		/WORD FROM 48 BIT REGISTER
	RAL			/SHIFT LEFT ONE
	DCA  I  TERASX		/SAVE AS NEW WORD
	CLA	CMA		/-1
	TAD	TERASX		/ADDRESS OF PRESENT WORD
	DCA	TERASX		/SAVE AS TO LOOK AT NEW WORD
	ISZ	TERAS		/DONE ALL 4 WORDS
	JMP	DLP1		/NO - DO NEXT PART OF 48 BIT WORD
/
/ CHECK TO SEE IF AC >= SR
/
	CLA	CLL
	TAD	SRH		/-HIGH ORDER SR
	CIA
	TAD	ACHW		/+HIGH ORDER AC
	SNA
	JMP	.+4		/MORE TESTS IF HIGH ORDER EQUAL
	SMA	CLA		/IS AC>SR
	JMP	SRTC		/YES...GO DO SUBTRACT
	JMP	INDX		/NO ...GO TO INDEX SHIFT COUNTER
	CLA	CLL
	TAD	SRL		/-LOW ORDER SR
	CMA CML IAC		/USE LINK AS 13 BIT AC
	TAD	ACLW		/+LOW ORDER AC
	SZL	CLA		/LINK IS SIGN BIT ... IS AC>=SR
	JMP	INDX		/NO ... INDEX SHIFT COUNTER

/ NOW SUBTRACT SR FROM THE AC
/
SRTC,	CLA	CLL
	TAD	ACLW		/LOW ORDER
	TAD	MSRL		/
	DCA	ACLW		/SAVE
	GLK			/GET THE CARRY
	TAD	ACHW		/HIGH ORDER
	TAD	MSRH
	DCA	ACHW		/SAVE
	ISZ	MQLW		/INDEX LOW ORDER MQ TO ACOUNT FOR DIVISION
INDX,	ISZ	DSHC		/UPDATE SHIFT COUNTER
	JMP	DLP		/DO IT AGAIN
/
/ DIVISION COMPLETE
/ CHECK THE SIGN OF THE RESULT
/
DIVEND,	JMS  I  XRNDOF		/GO ROUND UP QUOTIENT IF NEEDED
	TAD	DSGN		/GET THE SIGN FLAG
	RAR			/IS IT ODD
	SNL	CLA		/
	JMP  I  TDIV		/NO.... RESULT + .... EXIT
	JMS  I  ICOM		/YES... COMPLEMENT RESULT
	MQHW
	JMP  I  TDIV		/EXIT MQ CONTAINS THE QUOTIENT
/
DM30,	-30
ICOM,	COMP
IC48,	C48
DSHC,	0
MSRH,	0
MSRL,	0
DSGN,	0
TERASX,	0
TERAS,	0
/
DMQLW,	MQLW
XRNDOF,	RNDOFF
/

	PAGE
/
/ SPOC - POWER-ON-CLEAR GDC INITIALIZATION STRING
/
SPOC2N,
SPOC2O,	417; 26; 62; 143; 4; 3; 3; 360; 114; 7777	/SYNC(DMII OLD BOARD)
SPOC3N,	417; 26; 62; 143; 4; 4; 3; 360; 110; 7777	/SYNC(DMIII NEW BOARD)
/
SPOC,	557						/VSYNC
	507; 100					/PITCH
	560; 0; 0; 0; 17; 0; 0; 0; 0			/PRAM
	513; 0						/CCHAR
	506; 0						/ZOOM
	553						/START
	511; 0; 0; 0					/CURS TO HOME
	7777						/TERMINATOR

/ ERASE THE SCREEN
/
SERASE,	514; 2; 377; 77					/FIGS
	512; 377; 377					/MASK
	440; 0; 0					/WDAT (REPLACE MODE)
	7777						/TERMINATOR
/
/ LINE PARAMETERS
/
LINPAT,	570; 377; 377			/PRAM (MODIFIED IN CODE)
	7777				/TERMINATOR

/ --------------------------------------------------------------------
/ SPDTXT - SPECIAL CASE CODE FOR CHARACTER IN REPLACE AND NON-ITALIC
/ --------------------------------------------------------------------
/
SPDTXT,	0
	TAD	QCELIT		/CHECK IF ITALICIZED
	SZA CLA
	JMP	SPDTX8		/YES, CAN'T TAKE ADVANTAGE OF THIS CODE
/
	ACNEG1			/CHECK IF REPLACE WRITING MODE
	TAD	WRMODE
	SZA CLA
	JMP	SPDTX8		/NO, CAN'T TAKE ADVANTAGE
/
	TAD	NEGFLG		/CHECK IF ALSO NON-NEGATE
	SZA CLA
	JMP	SPDTX8		/NO, CAN'T TAKE ADVANTAGE
/
	TAD	PPSTEX		/OK TO DRAW CELL FIRST, BUILD FIGS STRING
	DCA	AUTO10
/
	TAD	KK0020		/P1 = AREA FILL AND DIRECTION
	TAD	QCELRT
	DCA I	AUTO10
/
	CDF	TBLFLD		/GET PHYSICAL HEIGHT AND WIDTH
	TAD I	PGDCHT		/HEIGHT
	DCA	TEMP		/SAVE FOR A WHILE
	ACNEG1
	TAD I	PGDCWD		/WIDTH
	CDF	PRGFLD
	JMS I	XXXXSD		/DC = WIDTH-1
/
	TAD	TEMP		/D = HEIGHT
	JMS I	XXXXSD
/
	TAD	TEMP		/D2 = HEIGHT
	JMS I	XXXXSD
/
	BLDPOS			/BUILD THE CURS STRING
	SPOSIT
/
	DRAWIT			/DRAW THE CELL
	SPOSIT
PPSTEX,	STEXT
	TXTPT0
/
	DCA	WRMODE		/FORCE OVERLAY MODE FOR THE REMAINDER
				/  OF THIS CHARACTER DRAW
SPDTX8,	JMP I	SPDTXT		/RETURN
/
KK0020,	0020
XXXXSD,	SAVEDX
PGDCWD,	ZGDCWD
PGDCHT,	ZGDCHT

/ -------------------------------------------------------
/ STROW - DO SOME PRELIMINARY WORK FOR THIS CHARACTER ROW
/ -------------------------------------------------------
/
/
STROW,	0
/
	TAD	PSTXT3		/POINT INTO FIGS STRING
	DCA	AUTO10
/
	AC0004			/CHECK TEXT BASELINE ANGLE
	AND	QCELRT
	CLL RTR			/UPSIDE DOWN MAKES A ONE
	TAD	YPOS1		/CHECK Y POSITION TO SEE HOW BIG DOT IS
	AND	K0001		/ODD SIZES GET A LITTLE BIGGER OR SMALLER
	TAD	QTXTD		/  NOTE ONLY VERTICAL DIRECTION REQUIRES THIS
	CLL RAR			/DIVIDE BY TWO
	DCA	TEMP		/SAVE FOR SENDING TWICE
/
	TAD	TEMP		/GET HEIGHT OF DOT
	JMS I	XXSVDX		/SAVE AS FIGS D PARAMETER
/
	TAD	TEMP		/GET HEIGHT OF DOT AGAIN
	JMS I	XXSVDX		/SAVE AS FIGS D2 PARAMETER
/
	JMP I	STROW		/RETURN
/
/
XXSVDX,	SAVEDX
PSTXT3,	STEXT+3
K0001,	0001

WOPTBF,	ZBLOCK	14		/WRITE OPTIONS BUFFER
/
/
	PAGE
/-----------------------------------------------------------------------------
/ PWRUP - POWER-UP-CLEAR
/------------------------------------------------------------------------------
/
/ INITIALIZES GRAPHICS BOARD REGISTERS ONE AND TWO,
/ SENDS INITIALIZATION CODE TO THE GDC CONTROLLER
/
PWRUP,	0
/
	AC1			/DISABLE THE CURSOR UNTIL AFTER INIT SEQ
	DCA	CURFLG		/SAVE THE CURSOR FLAG
/
	CIF	TBLFLD		/AUXILIARY FIELD FOR ROUTINE
	JMS I	XPWRAU
/
	TAD	GRFX		/CHECK IF BOARD PRESENT
	SNA CLA
	JMP	PWRUP9		/IF NOT, SKIP REST OF POWER-ON
/
	TAD	PSPOC		/GET APPROPRIATE SYNC STRING
	TAD	DECMAT		/  BASED ON DECMATE II OR III
	TAD	GOBTYP		/  AND ON GRAPHICS OPTION BOARD TYPE
	DCA	TEMP		/SAVE ADDRESS IN TABLE
	TAD I	TEMP		/GET STRING ADDRESS FROM TABLE
	DCA	PWRUP4		/SAVE FOR SUBSEQUENT EXECUTION
/
	SENDIT			/SEND SYNC STRING
PWRUP4,	0			/(BECOMES POINTER TO SYNC STRING)
	SENDIT			/SEND REMAINDER OF POC STRING
	SPOC
/
	JMS	WVSYNC		/WAIT FOR TWO VERTICAL SYNC'S
/
	TAD	GOBTYP		/CHECK TYPE OF BOARD
	SZA CLA
	TAD	K3000		/NEW BOARD, BUILD A 7000
	TAD	KK4000		/  OR OLD BOARD MAKES A 4000
	DCA	REG1HI		/SAVE AS REG 1 VALUE
	JMS	SYNCH		/SYNCHRONIZE THE TWO VIDEOS
/
	TAD	GOBTYP		/CHECK TYPE OF BOARD
	SZA CLA
	JMP	PWRUP9		/NEW BOARD, ALL DONE
/
	LDREG2			/WRITE REGISTER TWO FOR OLD BOARD
	3567			/ (NO TEXT TO COLOR)
/
PWRUP9,	JMP I	PWRUP		/RETURN
/
/
PSPOC,	SPOCLS
SPOCLS,	SPOC2O			/DECMATE II OLD BOARD
	SPOC2N			/DECMATE II NEW BOARD
	SPOC3N			/DECMATE III NEW BOARD
KK4000,	4000
K3000,	3000
XPWRAU,	PWRAUX

/ --------------------------------------------
/ SYNCH - SYNCHRONIZE GRAPHICS AND TEXT VIDEOS
/ --------------------------------------------
/
SYNCH,	0
/
	TAD	K1400		/SET GRAPHICS BOARD FOR EXTERNAL SYNC
	GRW1
/
	JMS	WVSYNC		/WAIT FOR TWO VERTICAL SYNCS
/
	TAD	KK1000		/DESELECT VERTICAL SYNC
	GRW1
/
	LDREG1			/LOAD REGISTER 1
	71			/ALSO PLANES 3, 2, AND 1
/
	JMP I	SYNCH		/RETURN
/
/
K1400,	1400
KK1000,	1000

/-----------------------------------------------------------------------------
/ WVSYNC - WAIT FOR TWO VERTICAL SYNC'S TO SYNC UP GDC AND EXTERNAL HARDWARE
/-----------------------------------------------------------------------------

WVSYNC,	0
	CLA	CLL		/CLEAR THE LINK - USED TO COUNT
WVSYN1,	GRGR			/READ THE STATUS REGISTER
	BSW			/PUT VERTICAL SYNC INTO SIGN BIT
	SMA	CLA		/SKIP IF A ONE
	JMP	WVSYN1		/NOT A ONE - WAIT FOR IT TO SET
WVSYN2,	GRGR			/READ VERTICAL SYNC
	BSW			/PUT VERTICAL SYNC INTO SIGN BIT
	SPA	CLA		/WAIT FOR VERTICAL SYNC TO GO AWAY
	JMP	WVSYN2		/NOT A ZERO - WAIT FOR IT TO CLEAR
	CML			/COMPLEMENT THE LINK
	SZL			/SKIP IF 2ND TIME THROUGH THE LOOP
	JMP	WVSYN1		/1ST TIME - WAIT FOR ANOTHER VERTICAL SYNC
	JMP  I  WVSYNC		/EXIT - 2 VERTICAL SYNC'S OCCURED

/ -------------------------------------
/ WGREG1 - WRITE TO GRAPHICS REGISTER 1
/ ------------------------------------
/
/ THE VALUE TO WRITE FOLLOWS THE CALL
/
WGREG1,	0
	CLA CLL
	SENDIT			/SEND A DUMMY COMMAND TO GDC
	DUMMY
WTDON1,	GRGR			/ROTATE FIFO EMPTY TO LINK
	RTR
	RAR
	SNL	CLA
	JMP	WTDON1		/NOT EMPTY YET - WAIT AGAIN
	TAD  I  WGREG1		/GET THE VALUE TO BE WRITTEN
	AND	K0077		/MASK TO LOW SIX BITS
	TAD	REG1HI		/SET APPROPRIATE HIGH SIX BITS
	DCA	REG11		/SAVE FOR USE BY REG 2 ROUTINE
	TAD	REG11
	GRW1			/WRIE DATA TO REGISTER 1
	CLA	CLL
	ISZ	WGREG1		/UPDATE THE RETURN POINTER
	JMP  I  WGREG1		/RETURN

/ ------------------------------------
/ WGREG2 - WRITE TO GRAPHICS REGISTER 2
/ ------------------------------------
/
/ THE VALUE TO WRITE FOLLOWS THE CALL
/
WGREG2,	0
	CLA CLL
	TAD I	WGREG2			/GET THE VALUE TO WRITE
	ISZ	WGREG2			/INCREMENT TO CORRECT RETURN ADDRESS
	DCA	REG12			/SAVE IT
/
	TAD	M0004			/SET UP COUNTER FOR ALL 4 REGS 2
	DCA	R2CNTR
/
	DCA	R2PTR			/POINT TO REG 2A FIRST
/
WGRG2A,	TAD	REG11			/REG 1 POINTS TO REG 2
	TAD	R2PTR
	GRW1				/WRITE REG 1
/
	CLA CLL
	TAD	REG12			/GET VALUE TO WRITE TO REG 2
	GRW2				/AND WRITE IT
/
	AC100				/BUMP REG 1 POINTER TO NEXT REG 2
	TAD	R2PTR
	DCA	R2PTR
/
	ISZ	R2CNTR			/LOOP THROUGH ALL FOUR REGS 2
	JMP	WGRG2A
/
	TAD	REG11			/ENSURE REG1 POINTS TO REG 2A
	GRW1
	CLA CLL
/
	JMP I	WGREG2			/RETURN
/
/
REG11,	0
REG12,	0
R2PTR,	0
R2CNTR,	0

/ ANOTHER FIELD OF CODE
/
/ TO AVOID CONFLICT WITH REGIS MODULE, WHICH SHARES THIS FIELD, USE PAGE ZERO
/ ADDRESSES ABOVE 0060 ONLY, USE AUTOINDEXING REGISTERS 0017 DOWNWARD, USE
/ MEMORY ABOVE ADDRESS 4000 ONLY.
/
	FIELD	TABFLD
/
	*0060			/PAGE ZERO VARIABLES, CONSTANTS, DATA, ETC.
/
ZOPCOD,	0			/CURRENT OPCODE
ZCBFLD,	0			/FIELD OF CONTROL BLOCK (^10)
ZCBPTR,	0			/ADDRESS OF CONTROL BLOCK
/
TXTSIZ=	ZTXTD-ZCHRST+1
ZTXTSZ=	ZYPV2-ZCHRST+1
/
ZCHRST,	0			/DISPLAY ALPHABET
ZCELRT,	0			/CELL ROTATION (0 - 359 DEGREES AT ENTRY,
				/  SIMPLIFY TO 0 - 7)
ZCELHT,	0			/CELL HEIGHT IN LOGICAL PIXELS
ZCELWD,	0			/CELL WIDTH IN LOGICAL PIXELS
ZUNIHT,	0			/UNIT HEIGHT IN LOGICAL PIXELS
ZUNIWD,	0			/UNIT WIDTH IN LOGICAL PIXELS
ZCELIT,	0			/CELL ITALIC (0 - 359 DEGREES AT ENTRY,
				/  SIMPLIFY TO -2, -1, 0, +1, +2)
ZCELFG,	0			/FLAG FOR CHARACTER ESCAPEMENT:
				/  0000 - BASELINE ANGLE,
				/  7777 - ABSOLUTE ESCAPEMENT,
				/  0001 - NO CHANGE
ZBASAN,	0			/BASELINE ANGLE (0 - 359 DEGREES AT ENTRY,
				/  SIMPLIFY TO 0 - 7)
ZXESC,	0			/X ESCAPEMENT IN LOGICAL PIXELS
ZYESC,	0			/Y ESCAPEMENT IN LOGICAL PIXELS
ZXLFES,	0			/X LINEFEED ESCAPEMENT IN LOGICAL PIXELS
ZYLFES,	0			/Y LINEFEED ESCAPEMENT IN LOGICAL PIXELS
DOTSHI,	0			/# DOTS DOWN CHARACTER
DOTSWD,	0			/# DOTS ACROSS CHARACTER
DTHTCL,	0			/# DOTS DOWN CELL (THAT FIT)
DTWDCL,	0			/# DOTS ACROSS CELL (THAT FIT)
ZTXTDC,	0			/1X DOT WIDTH
ZTXTD,	0			/2X DOT HEIGHT
/
ZXKI,	0			/X DISPLACEMENT PER CHARACTER DOT COLUMN
ZXKJ,	0			/X DISPLACEMENT PER CHARACTER DOT ROW
ZYKI,	0			/Y DISPLACEMENT PER CHARACTER DOT COLUMN
ZYKJ,	0			/Y DISPLACEMENT PER CHARACTER DOT ROW
/
ZXUNHT,	0			/X COMPONENT OF UNIT HEIGHT
ZXUNWD,	0			/X COMPONENT OF UNIT WIDTH
ZYUNHT,	0			/Y COMPONENT OF UNIT HEIGHT
ZYUNWD,	0			/Y COMPONENT OF UNIT WIDTH
/
ZGDCWD,	0			/PHYSICAL CELL WIDTH
ZGDCHT,	0			/PHYSICAL CELL HEIGHT
/
DELX,	0			/X DIMENSION OF CELL (-1)
DELY,	0			/Y DIMENSION OF CELL (-2)
/
ZXCLWD,	0			/X COMPONENT OF CELL WIDTH
ZXCLHT,	0			/X COMPONENT OF CELL HEIGHT
ZYCLWD,	0			/Y COMPONENT OF CELL WIDTH
ZYCLHT,	0			/Y COMPONENT OF CELL HEIGHT
/
ZPVROT,	0			/CELL ROTATION FOR TEXT PIXEL VECTORS
ZXPV0,	0			/X COMPONENT OF TEXT PIXEL VECTOR '0'
ZXPV2,	0			/X COMPONENT OF TEXT PIXEL VECTOR '2'
ZYPV0,	0			/Y COMPONENT OF TEXT PIXEL VECTOR '0'
ZYPV2,	0			/Y COMPONENT OF TEXT PIXEL VECTOR '2'
/
SIGNFG,	0			/SIGN FLAG FOR MULT AND DIV  (LSB COUNTS)
/
ZTEMP,	0			/TEMPORARY VARIABLES
ZTEMP1,	0
/
XZGTPR,	ZGTPRM
XROTAT,	ROTATE
XMOVE,	MOVE
/
ZKCDF,	CDF
/
ZK0002,	0002
ZK0004,	0004
ZK0005,	0005
ZK0007,	0007
ZK0010,	0010
ZK0011,	0011
ZK0012,	0012
ZK0024,	0024
ZK0026,	0026
ZK0036,	0036
ZK0070,	0070
ZK0550,	0550
/
ZM0004,	-0004
ZM0005,	-0005
ZM0010,	-0010
ZM0012,	-0012
ZM0015,	-0015
ZM0020,	-0020
ZM0024,	-0024
ZM0036,	-0036
ZM0055,	-0055
ZM0550,	-0550

	*ZENTRY			/BEGINNING OF CODE IN THIS FIELD
/
/ -------------------------------
/ ZENTRY - ENTRY POINT DISPATCHER
/ -------------------------------
/
/ CALLING FORMAT:
/	DATA FIELD = CALLING FIELD
/	INSTRUCTION FIELD = THIS FIELD
/	JMS I	(ZENTRY
/	OPCODE
/	FIELD OF CONTROL BLOCK
/	ADDRESS OF CONTROL BLOCK
/
ZENTRY,	0
/
	CLA CLL
	TAD I	ZENTRY		/GET OPCODE FROM CALLING FIELD
	DCA	ZOPCOD		/SAVE IT
	ISZ	ZENTRY		/BUMP ADDRESS
/
	TAD I	ZENTRY		/GET CONTROL BLOCK FIELD
	AND	ZK0070		/MASK TO FIELD BITS
	DCA	ZCBFLD		/SAVE IT
	ISZ	ZENTRY
/
	TAD I	ZENTRY		/GET CONTROL BLOCK POINTER
	DCA	ZCBPTR		/SAVE IT
	ISZ	ZENTRY		/BUMP TO CORRECT RETURN ADDRESS
/
	CDF	TBLFLD		/NOW SET TO OUR DATA FIELD
/
	TAD	ZOPCOD		/SET UP FOR DISPATCH TO PRIMITIVE ROUTINE
	TAD	PZTABL		/  BY ADDING OPCODE TO TABLE BASE ADDRESS
	DCA	ZTEMP		/SAVE POINTER TO ROUTINE ADDRESS
	TAD I	ZTEMP		/GET ROUTINE ADDRESS
	DCA	ZTEMP		/SAVE IT
	JMS I	ZTEMP		/CALL THAT ROUTINE
/
	CLA CLL
	CDF CIF	PRGFLD		/SET DATA AND INSTRUCTIONS TO BASE
				/  PRIMITIVES FIELD
	JMP I	ZENTRY		/RETURN TO BASE PRIMITIVES
/
/
PZTABL,	ZTABLE

/ --------------------------------------------------
/ NRMANG - NORMALIZE ANGLE TO 0 THROUGH 359. DEGREES
/ --------------------------------------------------
/
NRMANG,	0
/
NRMAN2,	SPA		/CHECK IF ANGLE NEGATIVE
	JMP	NRMAN4	/IF SO, GO MAKE IT POSITIVE
	TAD	ZM0550	/IF NOT, ADD -360. UNTIL IT IS
	JMP	NRMAN2	/REPEAT UNTIL ANGLE IS NEGATIVE
/
NRMAN4,	SMA		/CHECK IF ANGLE NEGATIVE
	JMP	NRMAN6	/IF NOT, THEN ITS OK
	TAD	ZK0550	/IF SO, ADD +360. UNTIL ITS POSITIVE
	JMP	NRMAN4	/REPEAT UNITL ANGLE IS POSITIVE
/
NRMAN6,	JMP I	NRMANG	/RETURN WITH NORMALIZED ANGLE

/ ----------------------------------
/ TXTSTP - GET TEXT SETUP PARAMETERS
/ ----------------------------------
/
TXTSTP,	0
/
	CLA CLL
	JMS I	XZGTPR		/GET THE DISPLAY ALPHABET
	SPA			/ENSURE IN THE RANGE 0 - 3
	CLA			/TOO LOW, DEFAULT TO ZERO
	TAD	ZM0004		/CHECK HIGH RANGE NOW
	SMA
	JMP	TXTS90		/TOO HIGH, ABORT
	TAD	ZK0004		/RESTORE ALPHABET NUMBER
	DCA	ZCHRST		/SAVE IT
/
	JMS I	XZGTPR		/GET THE CELL ROTATION ANGLE
	JMS	NRMANG		/NORMALIZE TO 0. TO 359. DEGREES
	DCA	ZCELRT		/SAVE IT
/
	JMS I	XZGTPR		/GET THE CELL HEIGHT
	SMA			/CHECK IF POSITIVE
	JMP	TXTST2		/OK
	CLA			/TOO LOW, DEFAULT TO 20.
	TAD	ZK0024
TXTST2,	JMS	CLP620		/ENSURE VALUE NOT OVER 400.
	DCA	ZCELHT		/SAVE IT
/
	JMS I	XZGTPR		/GET THE CELL WIDTH
	SMA			/CHECK IF POSITIVE
	JMP	TXTST4		/OK
	CLA			/TOO LOW, DEFAULT TO 9.
	TAD	ZK0011
TXTST4,	JMS	CLP620		/ENSURE VALUE NOT OVER 400.
	DCA	ZCELWD
/
	JMS I	XZGTPR		/GET THE UNIT HEIGHT
	SMA			/CHECK IF POSITIVE
	JMP	TXTST6		/OK
	CLA			/TOO LOW, DEFAULT TO 20.
	TAD	ZK0024
TXTST6,	JMS	CLP620		/ENSURE VALUE NOT OVER 400.
	DCA	ZUNIHT		/SAVE IT
/
	JMS I	XZGTPR		/GET THE UNIT WIDTH
	SPA			/CHECK IF POSITIVE
	AC0010			/TOO LOW, DEFAULT TO 8.
	JMS	CLP620		/ENSURE VALUE NOT OVER 400.
	DCA	ZUNIWD
/
	JMS I	XZGTPR		/GET THE CELL ITALIC ANGLE
	DCA	ZCELIT		/SAVE IT
/
	JMS I	XZGTPR		/GET THE FLAG FOR ESCAPEMENT SPECIFIER
	DCA	ZCELFG		/SAVE IT
/
	TAD	ZCELFG		/CHECK IF BASELINE ANGLE SPECIFIED
	SZA CLA
	JMP	TXTS10		/NO, SKIP TO CHECK FOR ABSOLUTE ESCAPEMENT
/
	JMS I	XZGTPR		/GET THE BASELINE ANGLE
	JMS	NRMANG		/NORMALIZE TO 0. TO 359. DEGREES
	DCA	ZBASAN		/SAVE IT
	JMP	TXTS20		/SKIP AROUND
/
TXTS10,	TAD	ZCELFG		/CHECK IF ABSOLUTE ESCAPEMENT SPECIFIED
	SMA CLA
	JMP	TXTS20		/NO, SKIP AROUND
/
	JMS I	XZGTPR		/GET THE X ESCAPEMENT
	DCA	ZXESC		/SAVE IT
/
	JMS I	XZGTPR		/GET THE Y ESCAPEMENT
	DCA	ZYESC		/SAVE IT
/
TXTS20,	JMS	ZSIMPL		/CREATE WORKING PARAMETERS FROM ARGUMENTS
/
	JMS I	XZCOPY		/COPY TEXT PARAMETERS TO MAIN FIELD FOR USE
/
TXTS90,	CLA CLL			/THAT'S ALL
	JMP I	TXTSTP		/RETURN
/
/
XZCOPY,	ZCOPYT

/ -------------------------------------------------------
/ CLP620 - CLIP VALUE IN AC TO 400 DECIMAL (IF OVER 400.)
/ -------------------------------------------------------
/
CLP620,	0
/
	SPA		/CHECK IF AC > 2047.
	JMP	CL620A	/IF SO, GO FORCE TO 400.
/
	TAD	ZM0620	/CHECK IF AC > 400.
	SMA
CL620A,	CLA		/AC TOO BIG, ENSURE LATER CORRECTION MAKES 400.
	TAD	ZK0620	/RESTORE AC (MAY BE CHANGED TO 400.)
	JMP I	CLP620	/RETURN WITH VALUE IN AC
/
/
ZK0620,	0620
ZM0620,	-0620

/ ---------------------------------------------------
/ ZGTPRM - GET PARAMETERS FROM ORIGINAL CALLING FIELD
/ ---------------------------------------------------
/
ZGTPRM,	0
/
	CLA CLL
	TAD	ZCBFLD		/CREATE A CDF INSTRUCTION
	TAD	ZKCDF		/  FOR THE ORIGINAL CALLING FIELD
	DCA	ZGTPR4		/SAVE INSTRUCTION IN LINE
/
ZGTPR4,	0			/BECOMES CDF INSTRUCTION
/
	TAD I	ZCBPTR		/GET A WORD FROM THAT FIELD
	ISZ	ZCBPTR		/BUMP POINTER FOR NEXT CALL, IF ANY
	CDF	TBLFLD		/SET BACK TO OUR OWN DATA FIELD
/
	JMP I	ZGTPRM		/RETURN WITH PARAMETERS IN AC
/
/
/
/
/ -------------------------------------------------------------
/ ZSIMPL - SIMPLIFY ARGUMENTS FROM TEXT PARAMETER SETUP COMMAND
/ -------------------------------------------------------------
/
ZSIMPL,	0
	JMS I	X2SIMP		/HANDLE CELL SIZING AND ROTATION
/
	JMS I	X3SIMP		/HANDLE CELL ESCAPEMENTS
/
	JMS I	X4SIMP		/PRECOMPUTE TEXT DOT DRAWING PARAMETERS
/
	JMS I	X5SIMP		/PRECOMPUTE TEXT PIXEL VECTOR DISPLACEMENTS
/
	JMS I	X6SIMP		/PRECOMPUTE CELL BOUNDARIES
/
	JMP I	ZSIMPL		/RETURN
/
/
X2SIMP,	Z2SIMP
X3SIMP,	Z3SIMP
X4SIMP,	Z4SIMP
X5SIMP,	Z5SIMP
X6SIMP,	Z6SIMP

	PAGE
/
/ ----------------------------------------
/ Z2SIMP - SIMPLIFY CELL SIZING PARAMETERS
/ ----------------------------------------
/
Z2SIMP,	0
/
				/SIMPLIFY CELL ROTATION FROM DEGREES
				/  TO OCTANT (0 DEG -> 0,
				/             45 DEG -> 1, ETC.)
	DCA	ZTEMP		/INITIALIZE WORKING OCTANT NUMBER
	TAD	ZCELRT		/GET ANGLE IN DEGREES
ZSIMP2,	TAD	ZM0055		/KEEP SUBTRACTING 45. DEGREES
	SPA
	JMP	ZSIMP4		/UNTIL ANGLE IS NEGATIVE
/
	ISZ	ZTEMP		/INCREMENT OCTANT NUMBER FOR EACH SUBTRACTION
				/(NEVER SKIPS)
	JMP	ZSIMP2		/GO BACK TO SUBTRACT ANOTHER 45. DEGREES
/
ZSIMP4,	CLA CLL
	TAD	ZTEMP			/HAVE OCTANT
	AND	ZK0007		/MASK TO APPROPRIATE BITS
	DCA	ZPVROT		/SAVE FOR LATER TECT PIXEL VECTOR COMPUTATIONS
/
	AC0006			/KNOW THE OCTANT BY NOW, MASK TO NEXT LOWER
	AND	ZTEMP		/  QUADRANT
	DCA	ZCELRT		/SAVE IT FOR USE BY TEXT ROUTINES
/
				/SIMPLIFY UNIT HEIGHT BY ROUNDING TO
				/  ACTUAL WORKING VALUE
				/  0     ->  20. (DEFAULT)
				/  1-19  ->  10.
				/  20-29 ->  20.
	DCA	ZTEMP1		/INITIALIZE WORKING QUOTIENT (FOR #/10.)
	TAD	ZUNIHT		/CHECK IF HEIGHT SPECIFIED AS 0 (DEFAULT)
	SNA
	TAD	ZK0024		/IF SO, USE DEFAULT
/
ZSIMP6,	TAD	ZM0012		/KEEP SUBTRACTING 10. 'PIXELS'
	SPA			/  UNTIL HEIGHT IS NEGATIVE
	JMP	ZSIMP8
/
	ISZ	ZTEMP1		/INCREMENT WORKING QUOTIENT
				/(NEVER SKIPS)
	JMP	ZSIMP6		/GO BACK TO SUBTRACT ANOTHER 10.
/
ZSIMP8,	CLA CLL			/KNOW HOW MANY TENS THERE ARE IN HEIGHT
	TAD	ZTEMP1
	SNA			/CHECK IF HALF HEIGHT (0-9 PIXELS ->10.)
	AC1			/IF SO, MAKE HALF HEIGHT
	DCA	ZTEMP1
/
	TAD	ZTEMP1		/MULTIPLY BY 10. TO GET LOGICAL PIXELS
	CLL RTL
	TAD	ZTEMP1
	CLL RAL
	DCA	ZUNIHT		/SAVE IT

				/SIMPLIFY UNIT WIDTH BY ROUNDING TO
				/  ACTUAL WORKING VALUE
				/  0     ->   8. (DEFAULT)
				/  1-7   ->   4. (OR 8. IF 90 ROT)
				/  8-15  ->   8.
	DCA	ZTEMP1		/INITIALIZE WORKING QUOTIENT (FOR #/8.)
	TAD	ZUNIWD		/CHECK IF WIDTH SPECIFIED AS 0 (DEFAULT)
	SNA
	TAD	ZK0010		/IF SO, USE DEFAULT
/
ZSIM10,	TAD	ZM0010		/KEEP SUBTRACTING 8. 'PIXELS'
	SPA			/  UNTIL WIDTH IS NEGATIVE
	JMP	ZSIM12
/
	ISZ	ZTEMP1		/INCREMENT WORKING QUOTIENT
				/(NEVER SKIPS)
	JMP	ZSIM10		/GO BACK TO SUBTRACT ANOTHER 8.
/
ZSIM12,	CLA CLL			/KNOW HOW MANY EIGHTS THERE ARE IN WIDTH
	TAD	ZTEMP1		/MULTIPLY BY 8. TO GET LOGICAL PIXELS
	CLL R3L
	SNA			/CHECK IF HALF WIDTH
	AC0004			/SET HALF WIDTH IF SO
	DCA	ZUNIWD		/SAVE IT
/
	AC0002			/CHECK IF CHARACTER ROTATION 90 OR 270
	AND	ZCELRT		/(WILL BE 2,3,6,7 IF SO)
	SNA CLA
	JMP	ZSIMI3		/NO, ALL DONE WITH WIDTH
	TAD	ZM0004		/YES, CHECK IF WIDTH IS FOUR
	TAD	ZUNIWD
	SZA CLA
	JMP	ZSIMI3		/NO, ALL DONE WITH WIDTH
	AC0010			/YES, CAN'T USE FOUR WITH THIS ROTATION
	DCA	ZUNIWD		/  USE EIGHT INSTEAD

				/SIMPLIFY CELL ITALIC ANGLE FROM DEGREES TO
				/  ACTUAL WORKING VALUE
				/  0 DEGREES -> 0,
				/  1 - 30 DEGREES -> +1,
				/  >= 31 DEGREES -> +2,
				/  -1 - -30 DEGREES -> -1,
				/  <= -31 DEGREES -> -2
ZSIMI3,	TAD	ZCELIT		/GET ITALIC ANGLE IN DEGREES
	SNA			/CHECK FOR ZERO
	JMP	ZSIM18		/IS ZERO, GO SAVE A ZERO
/
	TAD	ZK0036		/CHECK IF LESS THAN -30 DEGREES
	SMA
	JMP	ZSIM14		/NO, GO CHECK SOME MORE
	AC7776			/YES, SAVE A NEGATIVE TWO
	JMP	ZSIM18
/
ZSIM14,	TAD	ZM0036		/CHECK IF BETWEEN -30 AND -1 (INCLUSIVE)
	SMA
	JMP	ZSIM16		/NO, GO CHECK SOME MORE
	ACNEG1			/YES, SAVE A NEGATIVE ONE
	JMP	ZSIM18
/
ZSIM16,	TAD	ZM0036		/CHECK IF BETWEEN +1 AND +30 (INCLUSIVE)
	SMA CLA			/SKIP IF SO
	AC1			/IS GREATERTHAN/EQUAL TO +31
	IAC			/MAKES 1 - 30 INTO +1, >= 31 INTO +2
ZSIM18,	DCA	ZCELIT		/SAVE THE SIMPLIFIED CELL ITALIC

				/DETERMINE NUMBER OF DOTS TO DRAW
				/  FOR EACH DIRECTION
	AC0010			/ASSUME OK TO DRAW EIGHT DOTS ACROSS
	DCA	DOTSWD
	TAD	ZK0012		/ASSUME OK TO DRAW TEN DOTS UP AND DOWN
	DCA	DOTSHI
/
	AC0002			/CHECK IF CELL ROTATION IS 0 OR 180
	AND	ZCELRT		/(ARE CODED AS 0 AND 4)
	SZA CLA
	JMP	Z2SM20		/MUST BE 90 OR 270
/
	TAD	ZM0010		/CHECK IF WIDTH < EIGHT
	TAD	ZUNIWD
	SMA CLA
	JMP	Z2SM10		/NO, GO CHECK HEIGHT
	AC0004			/WIDTH TOO SMALL, DRAW ONLY FOUR DOTS
	DCA	DOTSWD
/
Z2SM10,	TAD	ZM0024		/CHECK IF HEIGHT < TWENTY
	TAD	ZUNIHT
	SMA CLA
	JMP	Z2SM40		/NO, THAT'S ALL HERE
	TAD	ZK0005		/HEIGHT TOO SMALL, DRAW ONLY FIVE DOTS HIGH
	DCA	DOTSHI
	JMP	Z2SM40		/THAT'S ALL HERE
/
Z2SM20,	TAD	ZM0020		/CHECK IF WIDTH < SIXTEEN
	TAD	ZUNIWD
	SMA CLA
	JMP	Z2SM30		/NO, GO CHECK HEIGHT
	AC0004			/WIDTH TOO SMALL, DRAW ONLY FOUR DOTS
	DCA	DOTSWD
/
Z2SM30,	TAD	ZM0012		/CHECK IF HEIGHT < TEN
	TAD	ZUNIHT
	SMA CLA
	JMP	Z2SM40		/NO, THAT'S ALL HERE
	TAD	ZK0005		/HEIGHT TOO SMALL, DRAW ONLY FIVE DOTS HIGH
	DCA	DOTSHI
/
Z2SM40,	JMP I	Z2SIMP		/RETURN

	PAGE
/
/ ---------------------------------
/ Z3SIMP - SIMPLIFY CELL ESCAPEMENT
/ ---------------------------------
/
Z3SIMP,	0
/
				/CHECK IF BASELINE ANGLE SPECIFIED
	TAD	ZCELFG		/GET THE FLAG
	SZA CLA			/CHECK FOR ZERO
	JMP	ZSIM50		/NOT SPECIFIED, NO NEED TO SIMPLIFY ESCAPEMENT
/
				/SIMPLIFY BASELINE ANGLE FROM DEGREES
				/  TO OCTANT SELECTION
	DCA	ZTEMP		/INITIALIZE WORKING QUOTIENT
	TAD	ZBASAN		/GET THE BASELINE ANGLE IN DEGREES
	TAD	ZK0026		/OFFSET FOR ROUNDING
ZSIM20,	TAD	ZM0055		/KEEP SUBTRACTING 45. DEGREES
	SPA			/  UNTIL ANGLE IS NEGATIVE
	JMP	ZSIM22
	ISZ	ZTEMP		/INCREMENT COUNTER OF 45. DEGREES CHUNKS
	JMP	ZSIM20		/GO BACK TO SUBTRACT SOME MORE
/
ZSIM22,	CLA CLL
	TAD	ZTEMP		/GET THE QUOTIENT
	AND	ZK0007		/ENSURE A VALID OCTANT SELECTION
	DCA	ZBASAN		/SAVE AS SIMPLFIED BASELINE OCTANT
/
	TAD	ZBASAN		/GET OCTANT
	JMS	ROTATE		/CREATE X ESCAPEMENT
	XESCTB			/  FROM 'FORWARD' MOTION
	ZCELWD			/  AND CELL WIDTH
	DCA	ZXESC		/SAVE X ESCAPEMENT

	TAD	ZBASAN		/GET OCTANT
	JMS	ROTATE		/CREATE Y ESCAPEMENT
	YESCTB			/  FROM 'FORWARD' MOTION
	ZCELWD			/  AND CELL WIDTH
	DCA	ZYESC		/SAVE Y ESCAPEMENT
/
ZSIM50,	TAD	ZPVROT		/GET CELL ROTATION
	JMS	ROTATE		/CREATE X LINE FEED
	XLFTAB			/  FROM 'DOWNWARD' MOTION
	ZCELHT			/  AND CELL HEIGHT
	DCA	ZXLFES		/SAVE X LINE FEED
/
	TAD	ZPVROT		/GET CELL ROTATION
	JMS	ROTATE		/CREATE Y LINE FEED
	YLFTAB			/  FROM 'DOWNWARD' MOTION
	ZCELHT			/  AND CELL HEIGHT
	DCA	ZYLFES		/SAVE Y LINE FEED
/
				/GET X AND Y COMPONENTS OF
				/  UNIT HEIGHT AND WIDTH
	TAD	ZCELRT		/GET OCTANT
	JMS I	XROTAT		/CREATE X UNIT WIDTH
	XESCTB			/  FROM FORWARD DISPLACEMENT
	ZUNIWD			/  AND UNIT WIDTH
	DCA	ZXUNWD		/SAVE IT
/
	TAD	ZCELRT		/GET OCTANT
	JMS I	XROTAT		/CREATE X UNIT HEIGHT
	YESCTB			/  FROM UPWARD DISPLACEMENT
	ZUNIHT			/  AND UNIT HEIGHT
	CIA			/2'S COMPLEMENT (???)
	DCA	ZXUNHT		/SAVE IT
/
	TAD	ZCELRT		/GET OCTANT
	JMS I	XROTAT		/CREATE Y UNIT WIDTH
	YESCTB			/  FROM 'UPWARD' DISPLACEMENT
	ZUNIWD			/  AND UNIT WIDTH
	DCA	ZYUNWD		/SAVE IT
/
	TAD	ZCELRT		/GET OCTANT
	JMS I	XROTAT		/CREATE Y UNIT HEIGHT
	XESCTB			/  FROM 'FORWARD' DISPLACEMENT
	ZUNIHT			/  AND UNIT HEIGHT
	DCA	ZYUNHT		/SAVE IT
/
	JMP I	Z3SIMP		/RETURN
/
/
XESCTB,	1			/X ESCAPEMENT TABLE (MOTION IN X DIRECTION
	1			/  AS MULTIPLE OF CELL WIDTH)
YESCTB,	0			/Y ESCAPEMENT TABLE (OFFSET INTO X TABLE)
	-1
	-1
	-1
	0
	1
	1
	1
/
XLFTAB,	0			/X LINEFEED TABLE (MOTION IN X DIRECTION
	1			/  AS MULTIPLE OF CELL HEIGHT)
YLFTAB,	1			/Y LINEFEED TABLE (OFFSET INTO X TABLE)
	1
	0
	-1
	-1
	-1
	0
	1

/ ------------------------------------------------
/ ROTATE - CREATE A DISPLACEMENT FOR TEXT MOVEMENT
/ ------------------------------------------------
/
/ CALL:	JMS	ROTATE
/	<ADDRESS OF DISPLACEMENT TABLE>
/	<ADDRESS OF BASIC DISPLACEMENT VALUE>
/
ROTATE,	0
/
	DCA	ROTATM		/SAVE OCTANT NUMBER (INDEX INTO TABLE)
/
	TAD I	ROTATE		/GET ADDRESS OF TABLE
	DCA	ROTAT1
	ISZ	ROTATE		/BUMP POINTER TO NEXT ARGUMENT
/
	TAD I	ROTATE		/GET ADDRESS OF DISPLACEMENT
	DCA	ROTAT2
	ISZ	ROTATE		/BUMP FOR RETURN ADDRESS
/
	TAD	ROTATM		/POINT INTO TABLE WITH INDEX
	TAD	ROTAT1		/  PLUS TABLE BASE ADDRESS
	DCA	ROTAT3		/SAVE ADDRESS INTO TABLE
	TAD I	ROTAT3		/GET VALUE FROM TABLE
	SNA			/CHECK IF ZERO
	JMP	ROTA20		/IF SO, RESULT IS A ZERO
/
	SPA CLA			/CHECK IF POSITIVE
	JMP	ROTA10		/IF NOT, GO USE DISPLACEMENT TIMES (-1)
/
	TAD I	ROTAT2		/TABLE VALUE POSITIVE, USE STRAIGHT DISPLACEMENT
	JMP	ROTA20
/
ROTA10,	TAD I	ROTAT2		/NEGATIVE, 2'S COMPLEMENT DISPLACEMENT
	CIA
ROTA20,	JMP I	ROTATE		/RETURN WITH RESULTING DISPLACEMENT
/
/
ROTATM,	0
ROTAT1,	0
ROTAT2,	0
ROTAT3,	0

/ -------------------------
/ ZDMYSB - DUMMY SUBROUTINE
/ -------------------------
/
ZDMYSB,	0
/
	CLA CLL
	JMP I	ZDMYSB		/DO NOTHING BUT RETURN
/
/
/ -------------------------------------
/ ZINIT - INITIALIZE CODE IN THIS FIELD
/ -------------------------------------
/
ZINIT,	0
/
	CLA CLL
	JMS I	XMOVE		/COPY DEFAULT PARAMTERS INTO TEXT OPTIONS
	TXTINI-1		/  FROM DEFAULT STORAGE
	ZCHRST-1		/  TO ACTIVE STORAGE
	ZTXTSZ			/  THIS MANY WORDS
/
	JMS I	XXZCOP		/COPY TEXT PARAMS TO MAIN FIELD FOR USE
/
	JMS I	XSTXTO		/SAVE TEXT OPTIONS
/
	CIF CDF	PRGFLD		/RETURN TO MAIN FIELD OF PRIMITIVES
	JMP I	ZINIT		/RETURN
/
/
XSTXTO,	STXTOP
XXZCOP,	ZCOPYT

	PAGE
/
/ --------------------------------------------------------
/ Z5SIMP - PRECOMPUTE DISPLACEMENTS FOR TEXT PIXEL VECTORS
/ --------------------------------------------------------
/
Z5SIMP,	0
/
	TAD	ZCELRT		/GET CELL ROTATION
	JMS I	XROTAT
	XESCTB
	ZCELWD
	DCA	ZXCLWD		/NOW HAVE X COMPONENT OF CELL WIDTH
/
	TAD	ZCELRT
	JMS I	XROTAT
	YESCTB
	ZCELHT
	CIA			/COMPLEMENT
	DCA	ZXCLHT		/NOW HAVE X COMPONENT OF CELL HEIGHT
/
	TAD	ZCELRT
	JMS I	XROTAT
	YESCTB
	ZCELWD
	DCA	ZYCLWD		/NOW HAVE Y COMPONENT OF CELL WIDTH
/
	TAD	ZCELRT
	JMS I	XROTAT
	XESCTB
	ZCELHT
	DCA	ZYCLHT		/NOW HAVE Y COMPONENT OF CELL HEIGHT
/
	TAD	ZYCLWD		/BUILD PHYSICAL WIDTH FROM X AND Y COMPONENTS
	SPA			/FORCE ABSOLUTE VALUE
	CIA
	CLL RAR
	TAD	ZXCLWD
	SPA			/FORCE ABSOLUTE VALUE
	CIA
	DCA	ZGDCWD		/WIDTH = Y/2 + X
/
	TAD	ZYCLHT		/BUILD PHYSICAL HEIGHT FROM X AND Y COMPONENTS
	SPA			/FORCE ABSOLUTE VALUE
	CIA
	CLL RAR
	TAD	ZXCLHT
	SPA			/FORCE ABSOLUTE VALUE
	CIA
	DCA	ZGDCHT		/HEIGHT = Y/2 + X
/
/
	JMP I	Z5SIMP		/RETURN

/ -----------------------------------------------
/ TXTXPV - CREATE X DISPLACEMENT FOR TEXT PIXEL VECTOR
/ -----------------------------------------------
/
TXTXPV,	0
/
	DCA	ZTEMP		/SAVE OCTANT NUMBER
/
	CIF CDF	TBLFLD		/FORCE TO THIS FIELD
/
	TAD	ZTEMP		/GET OCTANT NUMBER
	JMS I	XROTAT		/CREATE 'FORWARD' CONTRIBUTION
	XESCTB			/  FROM 'FORWARD' TABLE
	ZXPV0			/  AND 'FORWARD' DISPLACEMENT
	DCA	TXTXP1		/SAVE THE 'FORWARD' CONTRIBUTION
/
	TAD	ZTEMP		/GET OCTANT NUMBER
	JMS I	XROTAT		/CREATE 'UPWARD' CONTRIBUTION
	YESCTB			/  FROM 'UPWARD' TABLE
	ZXPV2			/  AND 'UPWARD' DISPLACEMENT
	TAD	TXTXP1		/ADD THE 'FORWARD' CONTRIBUTION
	CLL			/DIVIDE BY TWO
	SPA			/ENSURE SIGN EXTENDED PROPERLY
	CML
	RAR
/
	CIF CDF	PRGFLD		/SET UP FOR RETURN TO PRIMS MAIN FIELD
/
	JMP I	TXTXPV		/RETURN WITH X TEXT PV DISPLACEMENT
/
/
TXTXP1,	0

/ -----------------------------------------------
/ TXTYPV - CREATE Y DISPLACEMENT FOR TEXT PIXEL VECTOR
/ -----------------------------------------------
/
TXTYPV,	0
/
	DCA	ZTEMP		/SAVE OCTANT NUMBER
/
	CIF CDF	TBLFLD		/FORCE TO THIS FIELD
/
	TAD	ZTEMP		/GET OCTANT NUMBER
	JMS I	XROTAT		/CREATE 'FORWARD' CONTRIBUTION
	XESCTB			/  FROM 'FORWARD' TABLE
	ZYPV0			/  AND 'FORWARD' DISPLACEMENT
	DCA	TXTYP1		/SAVE THE 'FORWARD' CONTRIBUTION
/
	TAD	ZTEMP		/GET OCTANT NUMBER
	JMS I	XROTAT		/CREATE 'UPWARD' CONTRIBUTION
	YESCTB			/  FROM 'UPWARD' TABLE
	ZYPV2			/  AND 'UPWARD' DISPLACEMENT
	TAD	TXTYP1		/ADD THE 'FORWARD' CONTRIBUTION
	CLL			/DIVIDE BY TWO
	SPA			/ENSURE SIGN EXTENDED PROPERLY
	CML
	RAR
/
	CIF CDF	PRGFLD		/SET UP FOR RETURN TO PRIMS MAIN FIELD
/
	JMP I	TXTYPV		/RETURN WITH X TEXT PV DISPLACEMENT
/
/
TXTYP1,	0

/ --------------------------
/ STXTOP - SAVE TEXT OPTIONS
/ --------------------------
/
STXTOP,	0
	JMS I	XMOVE		/MOVE MEMORY AROUND
	ZCHRST-1		/  FROM ACTIVE TEXT OPTIONS
	TXTSAV-1		/  TO SAVE BUFFER
	ZTXTSZ			/  THIS MANY WORDS
/
	JMP I	STXTOP		/RETURN
/
/
/ --------------------------
/ RTXTOP - RESTORE TEXT OPTIONS
/ --------------------------
/
RTXTOP,	0
	JMS I	XMOVE		/MOVE MEMORY AROUND
	TXTSAV-1		/  FROM SAVE BUFFER
	ZCHRST-1		/  TO ACTIVE TEXT OPTIONS
	ZTXTSZ			/  THIS MANY WORDS
/
	JMS	ZCOPYT		/COPY PARAMETERS TO MAIN FIELD
/
	JMP I	RTXTOP		/RETURN
/
/
/ -----------------------------------------
/ZCOPYT - COPY TEXT PARAMETERS TO MAIN FIELD
/ -----------------------------------------
/
ZCOPYT,	0
	TAD	PZCHRS		/POINT TO TEXT PARAMS IN THIS FIELD
	DCA	AUTO17
/
	TAD	PQCHRS		/POINT TO TEXT PARAMS IN MAIN FIELD
	DCA	AUTO16
/
	TAD	MTXTSZ		/GET COUNT OF WORDS TO MOVE
	DCA	ZTEMP
/
ZCOPY2,	TAD I	AUTO17		/GET A WORD FROM HERE
	CDF	PRGFLD		/MAIN FIELD
	DCA I	AUTO16		/PUT THE WORD THERE
	CDF	TBLFLD		/THIS FIELD
	ISZ	ZTEMP		/INCREMENT COUNTER
	JMP	ZCOPY2		/  UNTIL EXHAUSTED
/
	JMP I	ZCOPYT		/RETURN
/
PZCHRS,	ZCHRST-1
PQCHRS,	QCHRST-1
MTXTSZ,	-TXTSIZ

/ ------------------
/ MOVE - MOVE MEMORY
/ ------------------
/
/ CALL:	JMS	MOVE
/	<ADDRESS-1 OF SOURCE DATA>
/	<ADDRESS-1 OF DESTINATION DATA>
/	<WORD COUNT>
/
MOVE,	0
/
	CLA CLL
	TAD I	MOVE		/GET POINTER TO SOURCE
	DCA	AUTO17
	ISZ	MOVE
/
	TAD I	MOVE		/GET POINTER TO DESTINATION
	DCA	AUTO16
	ISZ	MOVE
/
	TAD I	MOVE		/GET WORD COUNT
	CIA			/2'S COMPLEMENT FOR LOOP CONTROL
	DCA	ZTEMP
	ISZ	MOVE
/
MOVE4,	TAD I	AUTO17		/GET FROM SOURCE
	DCA I	AUTO16		/PUT TO DESTINATION
	ISZ	ZTEMP		/INCREMENT COUNTER
	JMP	MOVE4		/LOOP UNTIL COUNTER EXHAUSTED
/
	JMP I	MOVE		/RETURN

	PAGE
/
/ -------------------
/ TEXT OPTION BUFFERS
/ -------------------
/
				/INITIALIZE BUFFER FOR TEXT OPTIONS
TXTINI,	0
	0
	12
	11
	12
	10
	0
	1
	0
	11
	0
	0
	24
	12
	10
	12
	10
	1
	2
	1
	0
	0
	2
	0
	10
	24
	0
	11
	12
	10
	22
	11
	0
	0
	24
	0
	11
	0
	0
	24
/
/
TXTSAV,	ZBLOCK	ZTXTSZ		/SAVE BUFFER FOR TEXT PARAMETERS

	PAGE
/ ---------------------------------------------
/ SAVMOD - SAVE WRITING, NEGATE AND SHADE MODES
/ ---------------------------------------------
/
/ CALLED FROM MAIN FIELD ONLY
/ DATA FIELD MUST POINT TO MAIN FIELD AT ENTRY
/
SAVMOD,	0
/
	TAD I	XWRMOD		/SAVE WRITING MODE
	DCA	SAVMTM
/
	TAD I	XNEGFL		/SAVE NEGATE MODE
	DCA	SAVMT1
/
	TAD I	XSHDFL		/SAVE SHADE MODE
	DCA	SAVMT2
/
	CIF CDF	PRGFLD		/BACK TO MAIN FIELD
	JMP I	SAVMOD		/RETURN
/
/
SAVMTM,	0
SAVMT1,	0
SAVMT2,	0
XWRMOD,	WRMODE
XNEGFL,	NEGFLG
XSHDFL,	SHDFLG
/
/
/ ------------------------------------------------
/ RESMOD - RESTORE WRITING, NEGATE AND SHADE MODES
/ ------------------------------------------------
/
RESMOD,	0
/
	TAD	SAVMTM		/RESTORE WRITING MODE
	DCA I	XWRMOD
/
	TAD	SAVMT1		/RESTORE NEGATE MODE
	DCA I	XNEGFL
/
	TAD	SAVMT2		/RESTORE SHADE MODE
	DCA I	XSHDFL
/
	CIF CDF	PRGFLD		/MAIN FIELD
	JMP I	RESMOD		/RETURN

	PAGE
/ -------------------------------------------------------------------
/ Z4SIMP - PRECOMPUTE X AND Y COMPONENTS OF CHARACTER DOT POSITIONING
/ -------------------------------------------------------------------
/
Z4SIMP,	0
/
	JMS I	XDIVID		/X MOTION PER COLUMN = ZXUNWD/DOTSWD
	ZXUNWD
	DOTSWD
	DCA	ZXKI		/SAVE IT
/
	JMS I	XDIVID		/Y MOTION PER COLUMN = ZYUNWD/DOTSWD
	ZYUNWD
	DOTSWD
	DCA	ZYKI		/SAVE IT
/
	JMS I	XDIVID		/X MOTION PER ROW = ZXUNHT/DOTSHI
	ZXUNHT
	DOTSHI
	DCA	ZXKJ		/SAVE FOR NOW
/
	JMS I	XDIVID		/Y MOTION PER ROW = ZYUNHT/DOTSHI
	ZYUNHT
	DOTSHI
	DCA	ZYKJ		/SAVE FOR NOW
/
	TAD	ZXKJ		/CALCULATE 2X DOT 'HEIGHT' FOR FIGS D AND D2
	SPA			/  FROM 2(X_HEIGHT)+(Y_HEIGHT)
	CIA			/ENSURE ABSOLUTE VALUE
	CLL RAL			/TIMES TWO
	DCA	ZTEMP		/SAVE TWICE X FOR A WHILE
	TAD	ZYKJ		/GET Y COMPONENT
	SPA			/ENSURE ABSOLUTE VALUE
	CIA
	TAD	ZTEMP		/COMBINE X AND Y VALUES
	DCA	ZTXTD		/  AS SOMETHING TO WORK WITH LATER
/
	TAD	ZYKI		/CALCULATE DOT 'WIDTH' FOR FIGS DC
	SPA			/ENSURE ABSOLUTE VALUE
	CIA
	CLL RAR			/DIVIDE Y COMPONENT BY TWO (LOG TO PHYS)
	DCA	ZTEMP		/SAVE FOR A WHILE
	TAD	ZXKI		/GET X COMPONENT
	SPA
	CIA
	TAD	ZTEMP		/COMBINE WITH Y VALUE
	DCA	ZTXTDC		/  FOR LATER CONSTRUCTION OF FIGS STRING

	JMS I	XMULTI		/X MOTION PER ROW AFFECTED BY ITALICS
	ZCELIT
	ZXKI
	TAD	ZXKJ		/  ADDITIVE COMPONENTS
	DCA	ZXKJ		/SAVE REAL VALUE
/
	JMS I	XMULTI		/Y MOTION PER ROW AFFECTED BY ITALICS
	ZCELIT
	ZYKI
	TAD	ZYKJ		/  ADDITIVE COMPONENTS
	DCA	ZYKJ		/SAVE REAL VALUE
/
	JMS I	XMULTI		/# DOTS THAT FIT IN CELL WIDTH
	DOTSWD
	ZCELWD
	DCA	DTWDCL
	JMS I	XUNDIV		/UNSIGNED DIVIDE FOR GREATER RANGE
	DTWDCL
	ZUNIWD
	DCA	DTWDCL		/(CELL WIDTH * # DOTS) / (UNIT WIDTH)
/
	TAD	DOTSWD		/CHECK IF TOO MANY DOTS
	CIA
	TAD	DTWDCL
	SPA CLA
	JMP	Z4SIM2		/NO, USE WHAT WAS CALCULATED
	TAD	DOTSWD		/YES, CAN ONLY USE THIS MANY
	DCA	DTWDCL
/
Z4SIM2,	JMS I	XMULTI		/# DOTS THAT FIT IN CELL HEIGHT
	DOTSHI
	ZCELHT
	DCA	DTHTCL
	JMS I	XUNDIV		/UNSIGNED DIVIDE FOR GREATER RANGE
	DTHTCL
	ZUNIHT
	DCA	DTHTCL		/(CELL HEIGHT * # DOTS) / (UNIT HEIGHT)
/
	TAD	DOTSHI		/CHECK IF TOO MANY DOTS
	CIA
	TAD	DTHTCL
	SPA CLA
	JMP	Z4SIM8		/NO, USE WHAT WAS CALCULATED
	TAD	DOTSHI		/YES, CAN ONLY USE THIS MANY
	DCA	DTHTCL
/
Z4SIM8,	JMP I	Z4SIMP		/RETURN
/
/
XMULTI,	MULTIP
XUNDIV,	UNSDIV
XDIVID,	DIVIDE

	PAGE
/ --------------------------------
/ DIVIDE - SINGLE PRECISION DIVIDE
/ --------------------------------
/
/ CALL:	JMS	DIVIDE
/	<POINTER TO NUMERATOR>
/	<POINTER TO DENOMINATOR>
/	..RESULT IN AC
/
/ ATTEMPT TO DIVIDE BY ZERO RESULTS IN ZERO.
/ ALL NUMBERS ARE ASSUMED TO BE 2'S COMPLEMENT NOTATION (-2048 -> +2047)
/
DIVIDE,	0
/
	CLA CLL
	TAD I	DIVIDE		/GET ADDRESS OF NUMERATOR
	ISZ	DIVIDE		/BUMP POINTER TO NEXT ARGUMENT
	DCA	NMRTR
	TAD I	NMRTR		/GET NUMERATOR
	DCA	NMRTR		/SAVE IT
/
	TAD I	DIVIDE		/GET ADDRESS OF DENOMINATOR
	ISZ	DIVIDE		/BUMP POINTER TO RETURN ADDRESS
	DCA	DNMNTR
	TAD I	DNMNTR		/GET DENOMINATOR
	SNA			/CHECK IF ZERO
	JMP I	DIVIDE		/CAN'T DIVIDE BY ZERO, RETURN WITH AC=0000
	DCA	DNMNTR		/NON-ZERO, SAVE IT
/
	DCA	SIGNFG		/ASSUME BOTH VARIABLES POSITIVE
/
	TAD	NMRTR		/CHECK IF NUMERATOR NEGATIVE
	SMA
	JMP	DIVID2		/NO
	CIA			/YES, 2'S COMPLEMENT
	DCA	NMRTR		/SAVE IT
	ISZ	SIGNFG		/MARK SIGN FLAG (LSB)
DIVID2,	CLA
	TAD	DNMNTR		/CHECK IF DENOMINATOR NEGATIVE
	SMA
	JMP	DIVID4		/NO
	CIA			/YES, 2'S COMPLEMENT
	DCA	DNMNTR		/SAVE IT
	ISZ	SIGNFG		/MARK SIGN FLAG

DIVID4,	CLA
	TAD	DNMNTR		/GET NEGATIVE DENOMINATOR FOR REPEATED SUBTRACT
	CIA
	DCA	NDNMNT
/
	DCA	QUOTNT		/CLEAR QUOTIENT (COUNTER OF SUBTRACTS)
/
	TAD	NMRTR		/GET NUMERATOR
DIVID6,	TAD	NDNMNT		/SUBTRACT DENOMINATOR
	SPA			/CHECK IF TOO MUCH
	JMP	DIVID8		/YES, GO FINISH
	ISZ	QUOTNT		/STILL MORE TO GO, INCREMENT QUOTIENT
	NOP			/JUST IN CASE
	JMP	DIVID6		/KEEP SUBTRACTING UNTIL DONE
/
DIVID8,	CLA
	TAD	SIGNFG		/CHECK IF WE NEED TO CHANGE SIGN OF RESULT
	RAR			/GET THE IMPORTANT BIT INTO LINK
	CLA
	TAD	QUOTNT		/GET THE RESULT
	SZL			/DO WE HAVE TO COMPLEMENT?
	CIA			/YES (ONLY ONE OF NUM AND DENOM WAS NEGATIVE)
	JMP I	DIVIDE		/RETURN WITH RESULT IN AC
/
/
NMRTR,	0
DNMNTR,	0
NDNMNT,	0
QUOTNT,	0

/ -----------------------------------
/ Z6SIMP - PRECOMPUTE CELL BOUNDARIES
/ -----------------------------------
/
Z6SIMP,	0
/
	ACNEG1			/GET RELATIVE X_WIDTH OF CHAR
	TAD	ZXCLWD		/  FROM X_WIDTH
	TAD	ZXCLHT		/  AND X_HEIGHT
	SPA			/CHECK IF NEGATIVE DIMENSION
	TAD	ZK0002		/IF SO, MUST MOVE TOWARD ZERO
	DCA	DELX		/SAVE
/
	AC7776			/GET RELATIVE Y_WIDTH OF CHAR
	TAD	ZYCLWD		/  FROM Y_WIDTH
	TAD	ZYCLHT		/  AND Y_HEIGHT
	SPA			/CHECK IF NEGATIVE DIMENSION
	TAD	ZK0004		/IF SO, MUST MOVE TOWARD ZERO
	DCA	DELY		/SAVE
/
	TAD	ZPVROT		/GET CELL ROTATION
	JMS I	XROTAT
	XESCTB
	ZCELWD
	DCA	ZXPV0		/NOW HAVE X COMPONENT OF CELL WIDTH
/
	TAD	ZPVROT
	JMS I	XROTAT
	YESCTB
	ZCELHT
	CIA			/COMPLEMENT
	DCA	ZXPV2		/NOW HAVE X COMPONENT OF CELL HEIGHT
/
	TAD	ZPVROT
	JMS I	XROTAT
	YESCTB
	ZCELWD
	DCA	ZYPV0		/NOW HAVE Y COMPONENT OF CELL WIDTH
/
	TAD	ZPVROT
	JMS I	XROTAT
	XESCTB
	ZCELHT
	DCA	ZYPV2		/NOW HAVE Y COMPONENT OF CELL HEIGHT
/
	JMP I	Z6SIMP		/RETURN

	PAGE
/ --------------------------------
/ MULTIP - SINGLE PRECISION MULTIP
/ --------------------------------
/
/ CALL:	JMS	MULTIP
/	<POINTER TO MULTIPLIER>
/	<POINTER TO MULTIPLICAND>
/	..RESULT IN AC
/
/ ALL NUMBERS ARE ASSUMED TO BE 2'S COMPLEMENT NOTATION (-2048 -> +2047)
/
MULTIP,	0
/
	CLA CLL
	TAD I	MULTIP		/GET ADDRESS OF MULTIPLIER
	ISZ	MULTIP		/BUMP POINTER TO NEXT ARGUMENT
	DCA	MLTPLR
	TAD I	MLTPLR		/GET MULTIPLIER
	DCA	MLTPLR		/SAVE IT
/
	TAD I	MULTIP		/GET ADDRESS OF MULTIPLICAND
	ISZ	MULTIP		/BUMP POINTER TO RETURN ADDRESS
	DCA	MLTPLC
	TAD I	MLTPLC		/GET MULTIPLICAND
	SNA			/CHECK IF ZERO
	JMP I	MULTIP		/RETURN WITH AC=0000
	DCA	MLTPLC		/NON-ZERO, SAVE IT
/
	DCA	SIGNFG		/ASSUME BOTH VARIABLES POSITIVE
/
	TAD	MLTPLR		/CHECK IF MULTIPLIER ZERO
	SNA
	JMP I	MULTIP		/YES, RETURN WITH AC=0000
	SMA			/CHECK IF MULTIPLIER NEGATIVE
	JMP	MULTP2		/NO
	CIA			/YES, 2'S COMPLEMENT
	DCA	MLTPLR		/SAVE IT
	ISZ	SIGNFG		/MARK SIGN FLAG (LSB)
/
MULTP2,	CLA
	TAD	MLTPLC		/CHECK IF MULTIPLICAND NEGATIVE
	SMA
	JMP	MULTP4		/NO
	CIA			/YES, 2'S COMPLEMENT
	DCA	MLTPLC		/SAVE IT
	ISZ	SIGNFG		/MARK SIGN FLAG

MULTP4,	CLA
	TAD	MLTPLC		/GET NEGATIVE MULTIPLICAND FOR REPEATED ADD
	CIA
	DCA	NMLTPC
/
MULTP6,	TAD	MLTPLR		/ADD MULTIPLIER
	ISZ	NMLTPC		/INCREMENT THROUGH ALL ADDS REQUIRED
	JMP	MULTP6
	DCA	PRODCT		/SAVE RESULT AS PRODUCT
/
MULTP8,	TAD	SIGNFG		/CHECK IF WE NEED TO CHANGE SIGN OF RESULT
	RAR			/GET THE IMPORTANT BIT INTO LINK
	CLA
	TAD	PRODCT		/GET THE RESULT
	SZL			/DO WE HAVE TO COMPLEMENT?
	CIA			/YES (ONLY ONE OF MULTIPLIERS WAS NEGATIVE)
	JMP I	MULTIP		/RETURN WITH RESULT IN AC
/
/
MLTPLR,	0
MLTPLC,	0
NMLTPC,	0
PRODCT,	0

/ -------------------------------------------
/ BITCMB - COMBINE BITS OF A CHARACTER BITMAP
/ -------------------------------------------
/
BITCMB,	0
/
	CLA CLL
	TAD	PPCHPT		/POINT TO CHARACTER PATTERN
	DCA	AUTO17		/  FOR SOURCE
	TAD	PPCHPT		/AND AGAIN FOR DESTINATION
	DCA	AUTO16
	TAD	ZM0012		/GET COUNT OF BYTES
	DCA	ZTEMP
/
	CDF	PRGFLD		/DATA FROM MAIN PRIM FIELD
/
BITCM4,	TAD	ZM0004		/GET COUNT OF RESULTING BITS
	DCA	ZTEMP1
	DCA	ZTEMP3		/CLEAR STORAGE FOR BIT-COMBINED BYTE
	TAD I	AUTO17		/GET A BYTE
	DCA	ZTEMP2		/SAVE FOR USE HERE
/
BITCM6,	AC0003			/MASK OFF LOW TWO BITS (TWO MAKE ONE)
	AND	ZTEMP2		/  OF THE ORIGINAL BYTE
	CLL			/FORCE LINK TO MATCH THE LOW TWO BITS
	SZA CLA
	CML
	TAD	ZTEMP3		/GET WORKING RESULT
	RAR			/ROTATE BIT INTO IT
	DCA	ZTEMP3		/SAVE FOR SOME MORE
/
	TAD	ZTEMP2		/GET ORIGINAL BYTE (ROTATED)
	RTR			/ROTATE BY TWO
	DCA	ZTEMP2		/SAVE FOR NEXT CHECK
/
	ISZ	ZTEMP1		/INCREMENT THROUGH BITS IN RESULT
	JMP	BITCM6		/  UNTIL DONE
/
	TAD	ZTEMP3		/RIGHT JUSTIFY RESULTING BYTE
	BSW
	CLL RTR
	DCA I	AUTO16		/PUT BACK INTO PATTERN
/
	ISZ	ZTEMP		/INCREMENT THROUGH BYTES
	JMP	BITCM4		/  UNTIL DONE
/
	CIF CDF	PRGFLD		/BACK TO MAIN FIELD
/
	JMP I	BITCMB		/RETURN

/ -------------------------------------------
/ BYTCMB - COMBINE BYTES OF CHARACTER BIT MAP
/ -------------------------------------------
/
BYTCMB,	0
/
	CLA CLL
	TAD	PPCHPT		/POINT TO CHARACTER BIT MAP
	DCA	AUTO17		/  FOR SOURCE
	TAD	PPCHPT		/AND AGAIN
	DCA	AUTO16		/  FOR DESTINATION
	TAD	ZM0005		/GET COUNTER FOR RESULTING BYTES
	DCA	ZTEMP
/
	CDF	PRGFLD		/MAIN FIELD OF PRIMS FOR DATA
/
BYTCM4,	TAD I	AUTO17		/GET A BYTE
	MQL			/SAVE IN MQ
	TAD I	AUTO17		/GET NEXT BYTE OF PAIR
	MQA			/'OR' WITH PREVIOUS BYTE
	DCA I	AUTO16		/SAVE RESULTING BYTE
/
	ISZ	ZTEMP		/INCREMENT THROUGH BYTES
	JMP	BYTCM4		/  UNITL DONE
/
	CIF CDF	PRGFLD		/BACK TO PRIM MAIN FIELD
/
	JMP I	BYTCMB		/RETURN
/
/
PPCHPT,	CHRPAT-1
ZTEMP2,	0
ZTEMP3,	0

	PAGE
/ --------------------------------
/ UNSDIV - UNSIGNED SINGLE PRECISION DIVIDE
/ --------------------------------
/
/ CALL:	JMS	UNSDIV
/	<POINTER TO NUMERATOR>
/	<POINTER TO DENOMINATOR>
/	..RESULT IN AC
/
/ ATTEMPT TO DIVIDE BY ZERO RESULTS IN ZERO.
/ ALL NUMBERS ARE ASSUMED TO BE POSITIVE (0000 -> +4095)
/
UNSDIV,	0
/
	CLA CLL
	TAD I	UNSDIV		/GET ADDRESS OF NUMERATOR
	ISZ	UNSDIV		/BUMP POINTER TO NEXT ARGUMENT
	DCA	UNMRTR
	TAD I	UNMRTR		/GET NUMERATOR
	DCA	UNMRTR		/SAVE IT
/
	TAD I	UNSDIV		/GET ADDRESS OF DENOMINATOR
	ISZ	UNSDIV		/BUMP POINTER TO RETURN ADDRESS
	DCA	UDNMNT
	TAD I	UDNMNT		/GET DENOMINATOR
	SNA			/CHECK IF ZERO
	JMP I	UNSDIV		/CAN'T UNSDIV BY ZERO, RETURN WITH AC=0000
	DCA	UDNMNT		/NON-ZERO, SAVE IT
/
	CLA
	TAD	UDNMNT		/GET NEGATIVE DENOMINATOR FOR REPEATED SUBTRACT
	CIA
	DCA	UNDNMN
/
	DCA	UQUOTN		/CLEAR QUOTIENT (COUNTER OF SUBTRACTS)
/
	TAD	UNMRTR		/GET NUMERATOR
	SMA			/CHECK IF > 2047.
	JMP	UNSDV6		/IF NOT, GO HANDLE LOW RANGE
				/ELSE, HANDLE HIGH RANGE
UNSDV5,	TAD	UNDNMN		/SUBTRACT DENOMINATOR
	SMA			/CHECK IF STILL IN HIGH RANGE
	JMP	UNSDV7		/IF NOT, GO HANDLE LOW RANGE
	ISZ	UQUOTN		/MORE TO GO, INCREMENT QUOTIENT
	NOP			/(JUST IN CASE)
	JMP	UNSDV5		/LOOP THROUGH HIGH RANGE
/
UNSDV6,	TAD	UNDNMN		/SUBTRACT DENOMINATOR
	SPA			/CHECK IF TOO MUCH
	JMP	UNSDV8		/YES, GO FINISH
UNSDV7,	ISZ	UQUOTN		/STILL MORE TO GO, INCREMENT QUOTIENT
	NOP			/JUST IN CASE
	JMP	UNSDV6		/KEEP SUBTRACTING UNTIL DONE
/
UNSDV8,	CLA
	TAD	UQUOTN		/GET THE RESULT
	JMP I	UNSDIV		/RETURN WITH RESULT IN AC
/
/
UNMRTR,	0
UDNMNT,	0
UNDNMN,	0
UQUOTN,	0

	PAGE
/ --------------------------------------------------------------------
/ PWRAUX - POWER-ON CLEAR ROUTINE IN AUXILIARY FIELD (NO ROOM IN MAIN)
/ --------------------------------------------------------------------
/
PWRAUX,	0
/
	TAD	K1000		/INTERNAL SYNC
	GRW1
/
	AC100			/GET A RESET COMMAND (0400)
	CLL RTL
	GRGW			/ISSUE IT TO GDC
/
	AC7775			/WAIT ABOUT 40 MS (THREE LOOPS)
	DCA	PWRATM
	DCA	PWRAT1
PWRAU2,	ISZ	PWRAT1
	JMP	PWRAU2
	ISZ	PWRATM
	JMP	PWRAU2
/
	GRGR			/CHECK GDC STATUS
	AND	K0234		/MASK TO BITS THAT COUNT
	TAD	MM0004		/CHECK FOR CORRECT STATUS
	SNA CLA
	ACNEG1			/MARK BOARD PRESENT (7777)
	CDF	PRGFLD
	DCA I	XGRFX		/  OR NOT PRESENT (0000)
	CDF	TBLFLD
/
	PR3			/FIND OUT IF DECMATE II OR III
	5001+TBLFLD		/  BY READING SLUSHWARE'S MEMORY
	0021
	PWRATM			/ROM FIRMWARE ID INTO TEMPORARY
	-1
	7777
/
	TAD	PWRATM		/CHECK IF DECMATE II (+) OR III (-)
	SPA CLA
	AC1			/MARK DECMATE III (0001)
	CDF	PRGFLD
	DCA I	XDECMA		/  OR DECMATE II (0000)
	CDF	TBLFLD
/
	GRDR			/CHECK IF NEW GRAPHICS BOARD
	SKP CLA			/(A NEW BOARD WILL SKIP)
	AC1			/MARK AS NEW BOARD (0001)
	CDF	PRGFLD
	DCA I	XGOBTY		/  OR OLD BOARD (0000)
	TAD I	XGOBTY
	CDF	TBLFLD
/
	SNA CLA
	JMP	PWRAU8		/IF OLD BOARD, WE'RE ALL DONE
/
	JMS	R2INIT		/INITIALIZE OUTPUT MAP FOR NEW BOARD
/
PWRAU8,	CIF CDF	PRGFLD		/MAIN FIELD
	JMP I	PWRAUX		/RETURN
/
PWRATM,	0
PWRAT1,	0
K1000,	1000
K0234,	0234
MM0004,	-0004
XGRFX,	GRFX
XDECMA,	DECMAT
XGOBTY,	GOBTYP

/ --------------------------------------------------------------------
/ R2INIT - INITIALIZE OUTPUT MAP FOR NEW STYLE DYNAMIC MAPPED GRAPHICS
/ --------------------------------------------------------------------
/
R2INIT,	0
/
	CLA CLL
	CDF	PRGFLD		/DETERMINE IF GRAPHICS TO MONO
	TAD I	XSETUW		/  TO SELECT COLOR OR MONO MAP
	CDF	TBLFLD
	AND	ZK0002		/MASK SETUP WORD TO 'GRAPH_TO_MONO' BIT
	CLL RAR			/MAKE A 0000 OR A 0001
	TAD	PR2TAB		/ADD BASE ADDRESS OF TABLE OF TABLE POINTERS
	DCA	R2INTM		/SAVE ADDRESS
	TAD I	R2INTM		/GET ADDRESS OF MAP TABLE
	DCA	AUTO10		/  INTO AUTOINCREMENTING REGISTER
/
	TAD	K4100		/POINT REG 1 AT FIRST REG 2
	DCA	R2INTM
	TAD	M0020		/GET COUNT OF MAP ENTRIES
	DCA	R2INT1
R2INI6,	TAD	R2INTM		/SELECT A MAP INDEX WITH REG 1
	GRW1
	CLA CLL
	TAD I	AUTO10		/GET ITS VALUE
	GRW2			/  INTO REG 2
	CLA CLL
	ISZ	R2INTM		/BUMP POINTER THROUGH MAP
	NOP
	ISZ	R2INT1		/LOOP THROUGH MAP
	JMP	R2INI6		/  UNTIL FULL
/
	JMP I	R2INIT		/RETURN
/
/
K4100,	4100
M0020,	-0020
XSETUW,	SETUPW
R2INTM,	0
R2INT1,	0
PR2TAB,	R2TABS
R2TABS,	R2CTAB-1
	R2MTAB-1
/
			/COLOR MAP
R2CTAB,	0000		/DARK BLACK
	0012		/DARK GREEN
	0240		/DARK RED
	0252		/DARK YELLOW
	5000		/DARK BLUE
	5012		/DARK CYAN
	5240		/DARK MAGENTA
	3567		/DARK GREY
	5252		/BRIGHT GREY
	0017		/BRIGHT GREEN
	0360		/BRIGHT RED
	0377		/BRIGHT YELLOW
	7400		/BRIGHT BLUE
	7417		/BRIGHT CYAN
	7760		/BRIGHT MAGENTA
	7777		/BRIGHT WHITE
/
			/MONOCHROME MAP
R2MTAB,	0000
	2104
	1042
	3146
	0421
	2525
	1463
	3567
	4210
	6314
	5252
	7356
	4631
	6735
	5673
	7777

	PAGE
/ ---------------------------------------------------------
/ DM3SET - SET UP FOR NEW STYLE DYNAMIC COLOR MAPPED BOARDS
/ ---------------------------------------------------------
/
DM3SET,	0
/
	RDF			/GET CALLING FIELD FOR RETURN
	TAD	ZKCDIF		/MAKE A 'CDF CIF' INSTRUCTION
	DCA	DM3ST9		/  FOR LATER EXECUTION
/
	TAD I	XXSETW		/GET USER'S SETUP WORD
	DCA	DM3STM
	CDF	TBLFLD
/
	AC0006			/NEW BOARD, DETERMINE REG 1 VALUE
	AND	DM3STM		/  FROM USER'S SETUP WORD
	CLL RAR			/ADJUST FOR USE AS TABLE OFFSET
	TAD	PNWBST		/ADD BASE ADDRESS OF NEW BOARD SETUP TABLE
	DCA	DM3ST1		/SAVE ADDRESS INTO TABLE
	TAD I	DM3ST1		/GET VALUE FROM TABLE
	CDF	PRGFLD
	DCA I	XREG1H		/SAVE AS REGISTER ONE VALUE
	CDF	TBLFLD
/
	AC0002			/CHECK IF 'GRAPHICS TO MONO' SELECTION CHANGED
	AND 	DM3STM		/  BY LOOKING AT LATEST BIT
	CIA			/  AND COMPARING
	TAD	SAVGTM		/  TO PREVIOUS SELECTION
	SZA
	JMS I	XR2INI		/NEW SELECTION, LOAD OUTPUT MAP
/
	AC0002			/SAVE CURRENT 'GRAPHICS TO MONO' SELECTION
	AND	DM3STM
	DCA	SAVGTM
/
DM3ST9,	0			/BECOMES 'CDF CIF' TO CALLING FIELD
	JMP I	DM3SET		/RETURN
/
/
DM3STM,	0
DM3ST1,	0
SAVGTM,	0			/SAVED 'GRAPHICS TO MONO' SELECTION
XREG1H,	REG1HI
ZKCDIF,	CDF CIF
XXSETW,	SETUPW
XR2INI,	R2INIT
/
PNWBST,	NWBSET			/POINTER TO NEW GRAPHICS BOARD REG 1 VALUES
NWBSET,	6200			/MONO=TEXT, COLOR=GRAPHICS
	7000			/MON0=TEXT+GRAPHICS, COLOR=GRAPHICS
	6000			/MONO=TEXT, COLOR=TEXT AND GRAPHICS
	6000			/ILLEGAL, ASSUME TEXT TO BOTH MONITORS

	PAGE
/
/ --------------------------------------------------------------------
/ ZTABLE - DISPATCH TABLE FOR PRIMITIVE COMMANDS HANDLED IN THIS FIELD
/ --------------------------------------------------------------------
/
ZTABLE,	ZDMYSB		/00
	ZDMYSB		/01
	ZDMYSB		/02
	ZDMYSB		/03
	ZDMYSB		/04
	ZDMYSB		/05
	ZDMYSB		/06
	ZDMYSB		/07
	ZDMYSB		/08
	ZDMYSB		/09
	ZDMYSB		/10
	ZDMYSB		/11
	ZDMYSB		/12
	ZDMYSB		/13
	ZDMYSB		/14
	ZDMYSB		/15
	ZDMYSB		/16
	ZDMYSB		/17
	ZDMYSB		/18
	ZDMYSB		/19
	ZDMYSB		/20
	ZDMYSB		/21
	ZDMYSB		/22
	ZDMYSB		/23
	ZDMYSB		/24
	ZDMYSB		/25
	ZDMYSB		/26
	ZDMYSB		/27
	ZDMYSB		/28
	ZDMYSB		/29
	STXTOP		/30 - SAVE TEXT OPTIONS
	RTXTOP		/31 - RESTORE TEXT OPTIONS
	ZDMYSB		/32
	ZDMYSB		/33
	ZDMYSB		/34
	ZDMYSB		/35
	ZDMYSB		/36
	ZDMYSB		/37
	ZDMYSB		/38
	ZDMYSB		/39
	ZDMYSB		/40
	ZDMYSB		/41
	TXTSTP		/42 - SETUP TEXT PARAMETERS

/ ------------------------------------------------------------
/ DTABLE - DISPATCH TABLE FOR PRIMITIVE COMMANDS IN MAIN FIELD
/ ------------------------------------------------------------
/
DTABLE,	PWRUP	/ ------------- /00 - INITIALIZE HARDWARE (POWER-UP/POWER DOWN)
	POSTN1	/ ------------- /01 - POSITION - MOVE TO SPECIFIED POSITION
	SVTMPW	/ -------------	/02 - SAVE WRITE OPTIONS
	RSTMPW	/ -------------	/03 - RESTORE WRITE OPTIONS
	GETVEC	/ ------------- /04 - VECTOR
	GTNEGM	/ -------------	/05 - ENABLE/DISABLE NEGATE MODE
	SCRNER	/ ------------- /06 - SCREEN ERASE - FILL CLIP REGION TO COLOR
	GETDRG	/ ------------- /07 - SET DISPLAY REGION - CLEAR SCREEN TO BLACK
	GTBGRD	/ ------------- /08 - SELECT BACKGROUND COLOR
	GTFGRD	/ ------------- /09 - SELECT FOREGROUND COLOR
	GTWRTM	/ ------------- /10 - SET WRITING MODE
	GTLTXT	/ ------------- /11 - SET LINE TEXTURE
	GTSHDY	/ ------------- /12 - SHADE TO Y - ENABLE/DISABLE SHADE CHAR
	GTSHDO	/ ------------- /13 - SHADE OFF
	SCRDMP	/ ------------- /14 - SCREEN SIXEL DUMP
	DRWARC	/ ------------- /15 - CENTER ARC
	CRVBGN	/ ------------- /16 - CURVE BEGIN OPEN
	CRVCLS	/ ------------- /17 - CURVE BEGIN CLOSED
	CRVCNT	/ ------------- /18 - CURVE CONTINUE
	CRVEND	/ ------------- /19 - CURVE END
	GTPLNS	/ ------------- /20 - GET PLANE SELECT MASK WORD
	GETTXT	/ ------------- /21 - DISPLAY CHAR
	DMYSUB	/ ------------- /22 - NOP
	GTCSIZ	/ ------------- /23 - CLEAR ALPHABET BIT-MAP
	DMYSUB	/ ------------- /24 - NOP
	DMYSUB	/ ------------- /25 - NOP
	DMYSUB	/ ------------- /26 - NOP
	DMYSUB	/ ------------- /27 - NOP
	GTCBMP	/ ------------- /28 - LOAD CHARACTER
	INIT	/ ------------- /29 - INITIALIZE
	MORCOD	/ -------------	/30 - SAVE TEXT OPTIONS
	MORCOD	/ -------------	/31 - RESTORE TEXT OPTIONS
	RETPOS	/ ------------- /32 - REQUEST POSITION
	TRMNTE	/ -------------	/33 - TERMINATE
	SETUP	/ ------------- /34 - SETUP - CURSOR + GRAPHIC/TEXT SCREEN
	DMYSUB	/ ------------- /35 - NOP - NO OPERATION
	GTLMLT	/ ------------- /36 - SELECT LINE PATTERN MULTIPLIER
	RETREG	/ ------------- /37 - RETURN CO-ORDINATES OF LOGICAL SCREEN
	GTTXTR	/ ------------- /38 - GET TEXT REFERENCE POSITION
	RSTCUR	/ ------------- /39 - RESTORE CURSOR AFTER TEXT STRING
	GTXTPV	/ -------------	/40 - TEXT PIXEL VECTOR MOVEMENT
	DMYSUB	/ -------------	/41 - DRAW MARKER
EDTBLE,	MORCOD	/ -------------	/42 - TEXT PARAMETER SETUP

/**************************************************
/ FOLLOWING CODE ADDED TO MAKE WPS COMPATIBLE
/**************************************************
	PAGE					/ADFB
	EJECT					/ADFB
/ ADDED FROM VT125 BITMAP TABLE  KNOWN AS ALFBIT
/THIS TABLE EVENTUALLY STORED IN PANEL MEMORY DURING VT125 CX MODE
/
/
/ ---------------------------------------------------
/
/ ---------------------------------------------------
/ CHARMP - CHARACTER BIT MAPS (7-BY-9 CHARACTER FONT)
/ ---------------------------------------------------
/
/		   TOP
/
/		00 000 000
/		XX XXX XX0
/		XX XXX XX0
/		XX XXX XX0
/	RIGHT	XX XXX XX0   LEFT
/		XX XXX XX0
/		XX XXX XX0
/		XX XXX XX0
/		XX XXX XX0    (DESCENDER)
/		XX XXX XX0    (DESCENDER)
/
/		  BOTTOM
/
	FIELD 2
	*0200
CHARMP,	000; 000; 000; 000; 000; 000; 000; 000; 000; 000	/SPACE
	000; 020; 020; 020; 020; 020; 000; 020; 000; 000	/EXCLAMATION
	000; 000; 110; 110; 110; 000; 000; 000; 000; 000	/DOUBLE QUOTE
	000; 044; 044; 176; 044; 176; 044; 044; 000; 000	/NUMBER SIGN
	000; 020; 174; 022; 174; 220; 174; 020; 000; 000	/DOLLAR
	000; 206; 106; 040; 020; 010; 304; 302; 000; 000	/PER CENTUM
	000; 034; 042; 042; 034; 242; 102; 274; 000; 000	/AMPERSAND
	000; 060; 020; 010; 000; 000; 000; 000; 000; 000	/APOSTROPHE
	000; 040; 020; 010; 010; 010; 020; 040; 000; 000	/LEFT PAREN
	000; 010; 020; 040; 040; 040; 020; 010; 000; 000	/RIGHT PAREN
	000; 000; 104; 050; 376; 050; 104; 000; 000; 000	/ASTERISK
	000; 000; 020; 020; 376; 020; 020; 000; 000; 000	/PLUS
	000; 000; 000; 000; 000; 000; 030; 010; 004; 000	/COMMA
	000; 000; 000; 000; 376; 000; 000; 000; 000; 000	/MINUS
	000; 000; 000; 000; 000; 000; 030; 030; 000; 000	/PERIOD
	000; 200; 100; 040; 020; 010; 004; 002; 000; 000	/SLASH
	000; 070; 104; 202; 202; 202; 104; 070; 000; 000	/ZERO (0)
	000; 020; 030; 024; 020; 020; 020; 174; 000; 000	/ONE (1)
	000; 074; 102; 200; 160; 014; 002; 376; 000; 000	/TWO (2)
	000; 376; 100; 040; 160; 200; 202; 174; 000; 000	/THREE (3)
	000; 040; 060; 050; 044; 376; 040; 040; 000; 000	/FOUR (4)
	000; 376; 002; 172; 206; 200; 202; 174; 000; 000	/FIVE (5)
	000; 170; 204; 002; 172; 206; 204; 170; 000; 000	/SIX (6)
	000; 376; 200; 100; 040; 020; 010; 004; 000; 000	/SEVEN (7)
	000; 174; 202; 202; 174; 202; 202; 174; 000; 000	/EIGHT (8)
	000; 074; 102; 302; 274; 200; 102; 074; 000; 000	/NINE (9)
	000; 000; 030; 030; 000; 000; 030; 030; 000; 000	/COLON
	000; 000; 030; 030; 000; 000; 030; 010; 004; 000	/SEMICOLON
	000; 200; 040; 010; 002; 010; 040; 200; 000; 000	/LEFT ANGLE
	000; 000; 000; 374; 000; 374; 000; 000; 000; 000	/EQUALS
	000; 002; 010; 040; 200; 040; 010; 002; 000; 000	/RIGHT ANGLE
	000; 174; 202; 140; 020; 020; 000; 020; 000; 000	/QUESTION MARK
	000; 374; 202; 242; 222; 162; 002; 002; 174; 000	/COMMERCIAL AT
	000; 020; 050; 104; 202; 376; 202; 202; 000; 000	/CAPITAL A
	000; 176; 204; 204; 174; 204; 204; 176; 000; 000	/CAPITAL B
	000; 170; 204; 002; 002; 002; 204; 170; 000; 000	/CAPITAL C
	000; 076; 104; 204; 204; 204; 104; 076; 000; 000	/CAPITAL D
	000; 376; 002; 002; 076; 002; 002; 376; 000; 000	/CAPITAL E
	000; 376; 002; 002; 076; 002; 002; 002; 000; 000	/CAPITAL F
	000; 170; 204; 002; 002; 342; 204; 170; 000; 000	/CAPITAL G
	000; 202; 202; 202; 376; 202; 202; 202; 000; 000	/CAPITAL H
	000; 174; 020; 020; 020; 020; 020; 174; 000; 000	/CAPITAL I
	000; 340; 100; 100; 100; 100; 102; 074; 000; 000	/CAPITAL J
	000; 202; 142; 032; 006; 032; 142; 202; 000; 000	/CAPITAL K
	000; 002; 002; 002; 002; 002; 002; 376; 000; 000	/CAPITAL L
	000; 202; 306; 252; 222; 202; 202; 202; 000; 000	/CAPITAL M
	000; 202; 206; 212; 222; 242; 302; 202; 000; 000	/CAPITAL N
	000; 174; 202; 202; 202; 202; 202; 174; 000; 000	/CAPITAL O
	000; 176; 202; 202; 176; 002; 002; 002; 000; 000	/CAPITAL P
	000; 174; 202; 202; 202; 242; 102; 274; 000; 000	/CAPITAL Q
	000; 176; 202; 202; 176; 042; 102; 202; 000; 000	/CAPITAL R
	000; 174; 202; 002; 174; 200; 202; 174; 000; 000	/CAPITAL S
	000; 376; 020; 020; 020; 020; 020; 020; 000; 000	/CAPITAL T
	000; 202; 202; 202; 202; 202; 202; 174; 000; 000	/CAPITAL U
	000; 202; 202; 104; 104; 050; 050; 020; 000; 000	/CAPITAL V
	000; 202; 202; 202; 222; 222; 252; 104; 000; 000	/CAPITAL W
	000; 202; 104; 050; 020; 050; 104; 202; 000; 000	/CAPITAL X
	000; 202; 104; 050; 020; 020; 020; 020; 000; 000	/CAPITAL Y
	000; 376; 100; 040; 020; 010; 004; 376; 000; 000	/CAPITAL Z
	000; 170; 010; 010; 010; 010; 010; 170; 000; 000	/LEFT BRACKET
	000; 002; 004; 010; 020; 040; 100; 200; 000; 000	/BACKSLASH (\)
	000; 074; 040; 040; 040; 040; 040; 074; 000; 000	/RIGHT BRACKET
	000; 020; 050; 104; 202; 000; 000; 000; 000; 000	/CARET (^)
	000; 000; 000; 000; 000; 000; 000; 000; 376; 000	/UNDERSCORE
	000; 030; 020; 040; 000; 000; 000; 000; 000; 000	/ACCENT GRAVE
	000; 000; 000; 174; 200; 374; 202; 174; 000; 000	/SMALL A
	000; 002; 002; 172; 206; 202; 206; 172; 000; 000	/SMALL B
	000; 000; 000; 170; 204; 002; 004; 370; 000; 000	/SMALL C
	000; 200; 200; 374; 302; 202; 302; 374; 000; 000	/SMALL D
	000; 000; 000; 174; 202; 376; 002; 174; 000; 000	/SMALL E
	000; 160; 210; 010; 076; 010; 010; 010; 000; 000	/SMALL F
	000; 000; 200; 374; 202; 202; 374; 200; 202; 174	/SMALL G
	000; 002; 002; 172; 206; 202; 202; 202; 000; 000	/SMALL H
	000; 020; 000; 030; 020; 020; 020; 174; 000; 000	/SMALL I
	000; 200; 000; 200; 200; 200; 200; 202; 202; 174	/SMALL J
	000; 002; 002; 042; 022; 016; 042; 202; 000; 000	/SMALL K
	000; 030; 020; 020; 020; 020; 020; 174; 000; 000	/SMALL L
	000; 000; 000; 106; 252; 222; 222; 222; 000; 000	/SMALL M
	000; 000; 000; 172; 206; 202; 202; 202; 000; 000	/SMALL N
	000; 000; 000; 174; 202; 202; 202; 174; 000; 000	/SMALL O
	000; 000; 000; 176; 202; 202; 176; 002; 002; 002	/SMALL P
	000; 000; 000; 374; 202; 202; 374; 200; 200; 200	/SMALL Q
	000; 000; 000; 162; 214; 004; 004; 004; 000; 000	/SMALL R
	000; 000; 000; 174; 002; 174; 200; 174; 000; 000	/SMALL S
	000; 010; 010; 076; 010; 010; 110; 060; 000; 000	/SMALL T
	000; 000; 000; 102; 102; 102; 102; 274; 000; 000	/SMALL U
	000; 000; 000; 202; 202; 104; 050; 020; 000; 000	/SMALL V
	000; 000; 000; 202; 202; 222; 252; 104; 000; 000	/SMALL W
	000; 000; 000; 102; 044; 030; 044; 102; 000; 000	/SMALL X
	000; 000; 000; 202; 202; 302; 274; 200; 202; 174	/SMALL Y
	000; 000; 000; 376; 100; 060; 010; 376; 000; 000	/SMALL Z
	000; 340; 020; 020; 014; 020; 020; 340; 000; 000	/LEFT BRACE
	000; 020; 020; 020; 020; 020; 020; 020; 000; 000	/VERTICAL BAR
	000; 016; 020; 020; 140; 020; 020; 016; 000; 000	/RIGHT BRACE
	000; 214; 222; 142; 000; 000; 000; 000; 000; 000	/TILDE
	377; 377; 377; 377; 377; 377; 377; 377; 377; 377	/ERROR CHARACTER

