// June 23, 1978  11:29 AM			*** DEFINITIONS ***
//Edited by Lyle Ramshaw September 4, 1980  2:37 PM:
//  Changed the FontDef structure to fit in an "isArrows" flag
 
get "streams.d"

get "altoFileSys.d"

manifest [
// maximum number of things....
	maxSplineIDdefault=200
	maxTextIDdefault=100
	maxKnotsDefault=100
	maxTransfPoints=6
	maxChar=64
	maxFont=4
// brush definitions
	rBrush=0
	sBrush=1
	hBrush=2
	vBrush=3
	XdotOffset=3
	YdotOffset=6
// symbol index (ordered as in ZPFONT.ASM)
	rDotFont=0
	sDotFont=4
	hBarFont=8
	vBarFont=12
	lineFont=16
	deleteSymbol=20
	makeSymbol=21
	cyclicSymbol=22
	brushSymbol=23
	dashSymbol=24
	selectSymbol=25
	mTransf2Symbol=26
	cTransf2Symbol=27
	mTransf4Symbol=28
	cTransf4Symbol=29
	mTransf6Symbol=30
	cTransf6Symbol=31
	textSymbol=32
	blackSymbol=33
	redSymbol=34
	greenSymbol=35
	blueSymbol=36		// actually, Violet ...
	cyanSymbol=37
	magentaSymbol=38
	yellowSymbol=39
	transfSymbol0=mTransf2Symbol
// cursor index (ordered as in ZPFONT.ASM)
	standardCursor=0
	deleteCursor=1
	makeCursor=2
	cyclicCursor=3
	brushCursor=4
	dashCursor=5
	selectCursor=6
	mTransf2Cursor=7
	cTransf2Cursor=8
	mTransf4Cursor=9
	cTransf4Cursor=10
	mTransf6Cursor=11
	cTransf6Cursor=12
	textCursor=13
	blackCursor=14
	redCursor=15
	greenCursor=16
	blueCursor=17
	cyanCursor=18
	magentaCursor=19
	yellowCursor=20
	transfCursor0=mTransf2Cursor
// menu display stuff
	symbolHeight=32
	symbolWidth=2
	symbolPos=10
	symbolCount=17
//display stuff
	defaultHeight=symbolHeight*symbolCount+2
	defaultWidth=512
	XgridSpacingDefault=12
	gridSpacingDefault=16
	margin=4
	maxTextHeight=32
	lvDisplayHeader= #420
	lvAltoCursor= #431
// drawing modes
	dashOnDefault=16
	dashOffDefault=8
// spline types (procedure ParametricSpline)
	naturalSpline=0
	periodicSpline=1
// text centering modes:
	posTextCenter=1
	posTextTop=2
	posTextBottom=3
	posTextLeft=4
	posTextRight=5
// colors:
	cyan=1
	magenta=2
	yellow=4
	red=magenta+yellow
	green=cyan+yellow
	blue=cyan+magenta
	black=cyan+magenta+yellow
	]



//*********************************

structure BBC [
	function word
	spare word
	DBCA word
	DBMR word
	DLX word
	DTY word
	DW word
	DH word
	SBCA word
	SBMR word
	SLX word
	STY word
	gray↑0,3 word

	BH word			// brush height (extra; not used by BitBlt)
	]

manifest [
	lBBC= size BBC/16

	BBCreplace=0
	BBCpaint=1
	BBCinvert=2
	BBCerase=3

	BBSbitmap=0
	BBSnegBitmap=4
	BBSbrush=8
	BBSgray= 12

// curve & symbol drawing modes:
	drawMode=BBCpaint
	eraseMode=BBCerase
	XORmode=BBCinvert
	]



//*********************************

manifest [
	numberOfOverlays=5
	updateOverlay=1
	ioOverlay=2
	freeHandOverlay=3
	pressOverlay=4
	residentOverlay=5
	]

structure OVT [
	current word
	swat word
	fp @FP
	pn↑1,numberOfOverlays word
	end↑1,numberOfOverlays word
	free↑1,numberOfOverlays word
	]

manifest lOVT = size OVT/16


structure [ blank bit 15; odd bit ]


//*********************************


structure BRUSH [
	blank bit 11
	dashed bit
	[ shape bit 2
	  thickness bit 2 ] = [ drawBrush bit 4 ]
	]

structure COLOR [
	blank bit 13
	yellow bit
	magenta bit
	cyan bit
	]

structure SPLINE [
	selected bit 1
	tFlag bit 1
	type bit 2
	blank bit 1
	[ yellow bit
	  magenta bit
	  cyan bit ] = [ color bit 3 ]
	nBeads byte

	cyclic bit
	[ dashed bit 1
	  [ shape bit 2
	    thickness bit 2 ] = [ drawBrush bit 4] ] = [ brush bit 5 ]
	nKnots bit 10

	chain word

// x y pairs (accessible with structure XY)
	left word
	top word
	right word
	bottom word
	xSelect word
	ySelect word
	xStart word
	yStart word
	xColor word
	yColor word

// knots table starts here
	]


manifest [
	SPLINEheaderSize= offset SPLINE.left/16
	SPLINExyPairs=5
	SPLINEknotBase=SPLINEheaderSize+2*SPLINExyPairs
//spline type:
	regSpline=0
	dotSpline=1
	horSpline=2
	verSpline=3
	]

//*********************************

manifest [
	// copy field
	XYTmove=0
	XYTcopy=1
	// transf field + count field
	XYTtransf2= 0 + #20
	XYTtransf4= 2 + #40
	XYTtransf6= 4 + #60
	// transform modes (mode field)
	mTransf2Mode=XYTmove + XYTtransf2
	cTransf2Mode=XYTcopy + XYTtransf2
	mTransf4Mode=XYTmove + XYTtransf4
	cTransf4Mode=XYTcopy + XYTtransf4
	mTransf6Mode=XYTmove + XYTtransf6
	cTransf6Mode=XYTcopy + XYTtransf6
	transformModeMax=6
	]


structure XY [
	x word
	y word
	]


structure XYTABLE [
	n word

	blank bit 10
	[ npoints bit 3
	  transf bit 2
	  copy bit 1 ] = [ mode bit 6 ]

	xy0 @XY
	xy1 @XY
	xy2 @XY
	xy3 @XY
	xy4 @XY
	xy5 @XY
	]


manifest TRANSFORMtableSize=size XYTABLE/16

//*********************************


manifest BEADsize = 4

structure BEADXY [
	xDir bit 1
	deltaX bit 7
	yDir bit 1
	deltaY bit 7
	]


//*********************************

structure TEXT [
	selected bit 1
	tFlag bit 1
	skip bit 6
	[ yellow bit
	  magenta bit
	  cyan bit ] = [ color bit 3 ]
	font bit 5

	left word
	right word
	top word
	bottom word
	]


manifest TEXTblockSize=size TEXT/16


//*********************************

// IMPORTANT:
// fields "selected" & "tFlag" must be IDENTICAL
// in structures "ITEM", "SPLINE" & "TEXT"
// Bit "tFlag" is 1 for text

structure ITEM [
	selected bit 1
	tFlag bit 1
	blank bit 14
	]

// item identification conventions for splines [text]:
// id is a number between 1 & maxSplineID [maxTextID]
//  for indexing through pointer table splineTable [textTable]
// itemID = id [textFlag + id]


manifest [
	textFlag= #100000
	oneMoreTextItem= #400
	oneMoreSplineItem= 1
	]


structure itemID [
	tFlag bit 1
	blank bit 7
	id byte
	]


structure itemCOUNT [
	text byte
	spline byte
	]


structure stackCOUNT [
	code byte
	count byte
	]


//*********************************

manifest [
	HITPOINTblockSize=5
	]

structure HITPOINT [
	[ x word ] = [ x1 word ]
	[ y word ] = [ y1 word ]
	x2 word
	y2 word
	id word
	]

//*********************************

manifest [
	FONTDEFnameLength=19
	]

structure FONTDEF [
	name byte (FONTDEFnameLength+1)
	face byte
	isArrows bit
	ptSize bit 7
	dispCode word
	]

manifest [
	FONTDEFlength=size FONTDEF/16
	]

structure FONTFILE [
	current word
	buffer word
	bufferLength word
	length↑0,maxFont-1 word
	height↑0,maxFont-1 word
	baseline↑0,maxFont-1 word
	fp↑0,maxFont-1 @FP
	]

manifest [
	FONTFILElength=size FONTFILE/16
	]

// Alto font header

structure AL [
	height word
	prop bit
	baseline bit 7
	maxWidth byte
	]

//*********************************

// video camera stuff

structure CAMERA [
	top word
	bottom word
	left word
	right word
	[ xValid bit
	  blank bit 4
	  present bit 8
	  oddField bit
	  yValid bit ] = [ status word ]
	threshold word
	insideMode word
	outsideMode word
	leftSample word
	rightSample word
	]

manifest [
	camera= #177720
	altoOnly= #36
	altoAndCamera= #35
	cameraXoffset= 1
	cameraYoffset= 52
	]

//*********************************