// SCV.DFS -- Scan Converter Definitions
//

//Conditional compilation to decide how to handle splines.
// Set SplineHandling to one of the three:

manifest	[
	NoSplines=0	//Do not include spline code
	AdditiveSplines=1	//"Section and interpolate" spline code
	RecursiveSplines=2	//"Recursive" spline code

	SplineHandling=AdditiveSplines	//You set this!
	]

// Define values of "guard" numbers
// (a temporary measure -- the "gr" and "ls" compares
// in QuickSort and Putsegment (sdirmin,sdirmax
// compares, and also the "for s=l to r" loop)
// will not work correctly for +inf=#77777 and -inf=#100000)
// Following gives a range of -16000 < x < 16000

manifest [
	plusinfinity=#37777
	minusinfinity=#140000
	]

// Structure for talking about scan-converting an object:

structure SCV: [
	Smin word	//Bounding box of object
	Smax word
	Rmin word
	Rmax word	//"
	Object word	//Object descriptor
	Error word	//Error (currently, just no more core)
	Sbegin word	//S value to begin scan-conversion.
	Send word	// and end.
	IntPtr word	//Pointer to first intersection.
	IntCnt word	//Count of intersections.
	]


// Following are included so privileged souls can read things from
// the internal data structure, or use accumulators with confidence.

structure HD: [
	next	word	//pointer to next in list
	type	word	//type of thing (LINEtype or SPLINEtype)
	smin	word	//low value of s for this part
	smax	word	//high value of s for this part
	]

structure LINE: [	//block for a line descriptor
	@HD
	x	word 2	//current x
	dx	word 2	//delta
	]

structure SPLINE: [	//block for a spline
	@HD
	t0	word 2
	dt	word 2
	coeffs	word 8*2
	]

structure RSPLINE: [	//Recursive spline evaluation
	@HD
	str	word 2	//Order is important (initial stack order)
	gstr	word 2
	stl	word 2
	gstl	word 2

	rtr	word 2	//R direction, F(tr)
	grtr	word 2	// correction @ tr
	rtl	word 2	// F(tl)
	grtl	word 2	// correction @ tl
	]

//Floating-point AC's dedicated

manifest [
	t1=8
	t2=9
	t3=10
	t4=11

//*** Order of following definitions is important ***
//Coefficients for the spline (also range of T)
	esd=12		// D    (scan direction)
	erd=13		//      (run direction)
	esc=14		// C  (coeff t)
	erc=15
	esb=16		// B  (coeff t↑2)
	erb=17
	esa=18		// A  (coeff t↑3)
	era=19
	tminac=20	//Min value of parameter T
	tmaxac=21	//   and max value

//Current, old points
	csac=22		//Current point, scan direction
	crac=23		//  "            run direction
	osac=24		//Old point, scan direction
	orac=25		//  "        run direction
//*** End of order-important stuff ***

//Ac's for holding the "first" point from a MoveTo
	fsac=26
	frac=27

//Matrix coefficients (second char is row, third is column)
// (defined in order of SCVMatrix arguments)
	sssac=28
	ssrac=29
	srsac=30
	srrac=31

//Ac's during scan-conversion.
//	esd to era are same
//	t1-t4 are used.
	tt1=csac
	tt2=crac
	tt3=osac

// "Types" for object blocks (HD)

	LINEtype=0
	SPLINEtype=1
	]