// MDecl.d--definitions for machine-independent part of Midas
//	Last edited: 30 November 1979

// Basic display region structure

manifest [ get "MMenus.d" ]
manifest [ MaxNRegions = 70; MenRgn = 0; TextRgn = 1; NopRgn = 2 ]
manifest [ get "MAsmCommon.d" ]

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

	Type	bit 2	// Type of region (MenRgn or TextRgn)
	aLineX	bit 6	//Absolute locations
	aCharX	bit 7

	Height	byte	//Size
	Width	byte

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

structure [ CV↑0,100	byte ]	//Same as OS STRING structure


//MDFS only referenced in MINIT1, MMENU, MMPRGN, and MMPRGNOV (?).
//The structure is preceded by the following vectors:
//	ProcVec		MDFS.ProcNMax words
//			Word 0 contains count of items and words 1 to count
//			contain pointers to actions.
//	SizeVec		(MDFS.Rgn.Height+MDFS.ProcNMax) rshift 1 words
//			Vector of subvectors for each of MDFS.Rgn.Height
//			lines.  Byte 0 of each subvector is item count;
//			bytes 1 to count are nchars in ScreenTV for the
//			corresponding action name.
//	TextLines	MDFS.Rgn.Height words
//			The words in TextLines count characters in ScreenTV
//			for lines of the region
structure MDFS :
[	Rgn		@Rgn
	mIn		bit
	Letter		bit 7	//Letter for command files
	LineN		byte	//Line number for command files
	inLine		byte
	ProcNMax	byte	//Max count for ProcV+1
	SelectedItem	byte
	garb		bit 5
	MenuMode	bit 3	//0=idle, 1=standard menu, 2=address menu
				//3=radix menu, 4=display mode menu
]


// Information returned by EvalAText
manifest [ maxsymlen = 13; RegTypeStorage = 1; MemTypeStorage = 2 ]

structure AVal:
[	SName	word	(maxsymlen/2)+1
	X		byte		//RegX or MemX
	Radix		bit 2		//Coded 0=octal, 1=decimal, 2=hex
	DisplayMode	bit 3		//Coded 0=numeric, 1=SearchBlocks,
					//2=symbolic
	TypeStorage	bit 2
//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
]

//Total storage for a name-value menu is 5 for MDFS, 4 for Valsize,
//12 for AVal, 2 here, 5 for ProcVec, 3 for SizeVec, 1 for TextVec.
//Total = 32 words.  Hence, the total storage for
//a display structure of 3 columns x 20 items/column is 60*32 words or
//1920 words.
//The code relies on the fact that a pointer to an MPD is a pointer to an
//MDFS is a pointer to a RGN.  The TextLines, SizeVec, and ProcVec stuff
//precedes the pointer, as discussed previously.
structure MPD:
[	MDFS		@MDFS
	NoName		bit	//1 means name not printed
	TextSpace	bit 7	//Width in characters
	Extension	bit 4	//Non-0 is extension of item above it
	Prelim		bit 2	//0=$ (normal),
				//1=$~ (value unknown),
				//2=$* (value has changed),
				//3=$& (**not used**)
	RebuildText	bit
	AlwaysUpdate	bit
	Value		word ValSize
	AVal		@AVal
]


structure dcb:
[	Link	word	//Points at next 4-word DCB or 0 if last in list
	BufC	word	//(HTab lshift 8)  % #40000 if black %
			//NwdsPerScanLine if bit buffer
	Buffer	word	//Points at bit buffer (Buffer!-2 and Buffer!-1
			//are a list structure used by MDISP)
	Height	word	//Height/2
]


// MDISP stuff needed by initialization
structure LCB:
[	Line	@dcb
	Sepr	@dcb
]

manifest
[	BBLink = 0
	BBSize = 1
	DASTART = #420
	IntVec = #501
	IntActive = #453
	VertIntChan = 2
	HTab = 1		//HTab*16 raster points skipped/scan line

	MaxEveryTime = 4

	MaxMenus = 125
]


structure Action:		//Must agree with stuff in xxActions.asm
[	Name		word
	lvProc		word
	lvMProc		word
	Arg		word
	ifPassive	bit 1	//Action in command menu when passive
	ifActive	bit 1	//Action in command menu when active
	ifEsc		bit 1	//If remembered for <esc> execution
	ifNoRes		bit 1	//Don't reset comment streams before action
	ifResEsc	bit 1	//Reset <esc> action to Noop
	ifTO		bit 1	//Requires preceding TimeOut in comfile
	ifFlags		bit 2	//More flags
	Char		byte	//Char typed after ";" which invokes action
]

// 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
	]


//The total storage for a symbol in the symbol table is:
//  1 word for the pointer + the symbol block it points to:
//    The string name followed by:
//	2 words/memory
//	2 words/register
//	3 words/address
//	4 words/long address
structure Symb :
[ M: 	[	// a memory definition
	Type		byte	//One of the above types
	X		byte	//MemX
	]

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

= 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
[	LastPntr	word
	FirstRcd	word
]

manifest
[	OtherToken = 1	//Constants used by ChkToken
	BlankToken = 2
	LimitToken = 3
	SignToken = 4
	LParToken = 5
	RParToken = 6
	CommaToken = 7
	OctToken = 10B
	DecToken = 20B
	HexToken = 40B
	SymbToken = 100B
	DotToken = 200B
	MarkedOct = 400B
	MarkedDec = 1000B
	MarkedHex = 2000B
]


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


//MidasSwat parameters for machine-independent .bcpl files.
//Error strings are in Midas.Errors.
//By convention these numbers are less than 1000; .asm file
//error numbers are in masmcommon.d are between 1000 and 1999.
manifest
[	BadSaveStateFP = 0
	BadRestoreStateFP = 1
	MidasIncompatible = 2
	StateFileClobbered = 3
	BadOverlayCall = 4
	NoOD = 5
	BadOvlRelease = 6
	SwapOutCall = 7
	RTablesInconsistent = 8
	MTablesInconsistent = 9
	NonXFile = 10
	CreateFailed = 11
	BadSwitch = 12
	OvlScanFailure = 13
	LUEBug = 14
	IllegalChars = 15
	TooManyNames = 16
	MSymInitBug = 17
	VSEmsg = 18
	TMAforSaveStatics = 19
	StateBlockTiny = 20
	TooManyRgns = 21
	BadNewRegionArgs = 22
	BadMenuName = 23
	DuplicateMenuName = 24
	BadMPDInit = 25
	NoComCm = 26
	IllStorageType = 27
	NoFreeBlock = 28
	UndefStrategy = 29
	BadHeadUpdate = 30
	BadBlockUpdate = 31
	BlockSplitBug = 32
	BadSymOrder = 33
	SymTabOvf = 34
	BadBlockAddr = 35
	NBitsG32 = 36
	BadRadix = 37
	NoFreeBB = 38
	BadFontChar = 39
	ETLOvf = 40
	BadArgforRETL = 41
	ActionOVF = 42
	TooManyActions = 43
	BadExtension = 44
	BadModeTable = 45
	SmallsysZone = 46
	CFileRetn = 47
	BadFixupFile = 48
	TestAsmEdit = 49
	NoFixups = 50
	NoCompare = 51
	ImpBinScan = 52
]