// mdecl.d


// Basic display region structure

manifest [ MaxNRegions = 70 ]

structure Rgn:
[	DispDirty
		bit	// 1 if this region should paint during next
			// display loop.  This should only be set using
			// MarkRgnDispDirty(R)

	aLineX	bit 7	//Absolute locations
	aCharX	byte

	Height	byte	//Size
	Width	byte

	// The region reference point is in the upper left hand
	// corner of the region.

	// assorted procedures

	Paint	word	// Paint(Rgn) called to paint this region.
			// Paint should use PaintRgnLine to do the
			// actual painting.  Only called if DispDirty
			// is true, or if regions have been restructured

	Select	word	// Select(R, InR, MB, MBunion, rLx, rCx) is
			// called when R is initially selected by mouse.
			//	InR is the region mouse actually
			//		pointing to
			//	MB is current value of mouse buttons
			//	MBunion is union of all mouse buttons
			//		down since last all up
			//	rLx is current cursor relative LineX
			//	rCx is current cursor relative CharX

	MChange	word	// MChange(R, InR, MB, MBunion, rLx, rCx) is
			// called when ever the mouse parameters 
			// change.  R is the selected region.

	deSelect	word	// deSelect(R) is called when R was the
			// selected region, and is no more.
	]

structure [ CV↑0,100	byte ]	//Indexes ControlV!I to get index in
				//RegionTable for char. pos.


structure MDFS :
[	Rgn		@Rgn
	mIn		bit
	Letter		bit 7	//Letter for command files
	LineN		byte	//Line number for command files
	TextLines	word
	MaxH		byte
	MaxW		byte
	inLine		word
	ProcV		word
	ProcNMax	word
	SizeV		word
	SelectedItem	word
	Arg		word
	deSelect	word
]

// MDISP stuff needed by initialization
structure LCB:
[	DispCtrlBlock	word
	BitBuffer	word
	PrevLCB		word
	Hover2		word
]

manifest
[	BBLink = 0
	BBSize = 1
	DASTART = #420
	IntVec = #501
	IntActive = #453
	VertIntChan = 2
	HTab = 2		//HTab*16 raster points skipped/scan line
	SkipScanLines = 150
	LineSeparation = 2	//Not used yet
	PFVecSize = 50; EvecSize = 10
]


manifest [ MaxEveryTime = 4 ]


// Information returned by EvalAText

manifest [ maxsymlen = 13; RegTypeStorage = 1; MemTypeStorage = 2 ]

structure AVal:
[	SName	word	(maxsymlen/2)+1
	X		byte		//RegX or MemX
	TypeStorage	bit 7
//Items below only apply to MemTypeStorage
	Sign		bit		//1 if offset can be signed
	Offset		word	2	//Displacement relative to symbol
	Addr		word	2	//Real memory address
]

manifest [ ValSize = 5 ]

structure MPD :
[	Idle		bit	//1 means empty
	NoName		bit	//1 means name not printed
	MenuMode	bit 6
	Phase		byte
	Rabove		word
	MDFS		word
	TextSpace	word
	Value		word ValSize
	AVal		@AVal
]


// MMENU stuff
structure Action :
[	Name	word
	lvProc	word
	lvMProc	word
	Arg	word
	Char	word	//Char typed after ";" which invokes action
]

manifest [ MaxActions = 100; MaxMenus = 125; MaxLineN = 20 ]

// Symbol Table

// Types of symbol table entries
manifest [
//	Undefined = 0	// for nullstring
	MemSymb = 1	// a memory definition
	RegSymb = 2	// a register definition
	AddrSymb = 3	// an address definition--one word value
	LAddrSymb = 4	// an address definition--two word value
	]


structure Symb :
[ M: 	[	// a memory definition
	Type		byte	//One of the above types
	X		byte	//MemX
	BitWidth	word	//width of a memory word
	Hsize		word	//High part of nwords in memory
	Size		word	//Low part of nwords in the memory
	]

= R:	[	// a register definition
	Type		byte	//One of the above types
	X		byte	//RegX
	BitWidth	word	//width of the register
	]

= A:	[	// an address symbol
	Type		byte	//One of the above types
	X		byte	//MemX
	A2		word	//address
	]

= LA:	[	// a long address symbol
	Type		byte	//One of the above types
	X		byte	//MemX
	A1		word	//high part of address
	A2		word	//low part of address
	]
]

structure BH :		// Block head
[	BlockAddr	word
	Dirty		word
	NPages		word
	LastPntr	word
	FirstRcd	word
]

manifest
[	NPagesPerStandardBlock = 4	//Typically 7 words/symbol
	NPagesPerHeadBlock = 1		//Roughly 6 words/standard block
	MaxBlockPages = 100
	PageSize = 256
]


// Generally useful structure
structure [ lh byte; rh byte ]