// Page 1 reserved locations - from Alto hardware manual, Appendix B
// and passim

manifest [

// display
	DBchainHead = #420		// pointer to DB
	verticalFieldInterrupt = #421	// 60 times a second

// cursor
	cursorX = #426
	cursorY = #427
	cursorBitMap = #431		// up to #450

// mouse
	mouseX = #424			// hardware increments or
	mouseY = #425			// decrements these words

// disk
	nextDiskCommand = #521		// pointer to DCB
	diskStatus = #522			// @DS
	lastDiskAddress = #523		// @DA
	sectorInterrupts = #524

// interrupts
	wakeupsWaiting = #452		// bit 1 goes to
					// interruptvector!1
	activeInterrupts = #453
	interruptedPC = #500
	interruptVector = #500		// #501 to #517

// interval timer
	timerInterruptTime = #525		// interrupt occurs when AC1
					// after RCLK equals this word
					// in the 10 msb
	timerInterrupts = #423
	timerData = #422

// miscellaneous
	realTimeClock = #430		// units are 1024/30*875
					// seconds or about 38 ms
	trapPC = #527
	trapVec = #530			// up to #567
	convertMaskTable = #460		// up to #477; the convert ins-
					// truction requires that
					// convertMaskTable!n=
					// (2**(n+1))-1

	]




//	Table 4.1: Page 1 reserved locations  {next page}

// minimal structure for a stream
structure ST[
	blank word
	open word
	close word
	gets word
	puts word
	reset word
	putback word
	error word
	endof word
	stateof word
	blank word
	blank word
	blank word
	type word
	]
manifest lST=size ST/16

// 	Table 4.2 Basic stream structures; see section 4.1 {next page}
// disk address
structure DA[
	sector bit 4
	track bit 9
	head bit 1
	disk bit 1
	restore bit 1
	]

// disk header
structure DH[
	packId word
	diskAddress @DA
	]

// serial number
structure SN[
		[
		directory bit 1
		random bit 1
		part1 bit 14
		]
	= word1 word
	part2 word
	]

// disk label
structure DL[
	next word				// disk address of next file
					// page, or 0
	previous word			// disk address of previous
					// file page, or 0
	fileId word 3 =
		[
		serialNumber @SN
		version word
		]
	page word				// leader is page 0, first data
					// page is page 1
	numberOfCharacters word		// between 0 and 512 inclusive.
					// ne 512 only on last page
	blank word
	]
manifest lDL=size DL/16

//	Table 4.3: Disk format; see section 4.2 {next page}
// disk status word.  See hardware manual for detailed definitions
structure DS[
	sector bit 4
	done bit 4
	seekFailed bit
	seekInProgress bit
	notReady bit
	dataLate bit
	noTransfer bit
	checksumError bit
	finalStatus bit 2
	]

// disk command
structure DC[
	seal bit 8			// must be #110
	headerAction bit 2
	labelAction bit 2
	dataAction bit 2
	seekOnly bit 1
	exchangeDisks bit 1		// disk controller inverts
					// DCB.diskAddress if this bit 
					// is set
	]
// possible disk actions in command word
manifest [ diskRead = 0; diskCheck = 1; diskWrite = 2]

// disk command block
structure DCB[
	nextCommand word
	status @DS			// set when command is completed
	command @DC
	headerAddress word		// these are memory addresses
	labelAddress word
	dataAddress word
	noErrorInterrupts word
	errorInterrupts word
	header @DH =
		[
		blank word
		diskAddress @DA
		]
	]
manifest lDCB=size DCB/16

//	Table 4.4: Disk commands; see section 4.3 {next page}
// Bcpl string
structure STRING[
	length byte
	body ↑ 0,255 byte
	]


// file identifier
structure FID[
	serialNumber @SN
	version word
	fileNumber word
	diskAddress @DA			// virtual disk address
	name @STRING
	]



//	Table 4.5: File identifier; see section 4.4




// directory entry
structure DE[
	type bit 6
	nwords bit 10			// number of words in the entry
	fid @FID
	]
// directory entry types
manifest [ DEfree = 0; DEfile = 1; DElink = 2 ]


//	Table 4.6: Directory format; see section 4.4 {next page}
// display band control block
structure DB[
	next word
	resolution bit 1			// 0=high
	background bit 1			// 0=white
	indentation bit 6			// in units of 16 dots
	width bit 8			// likewise; must be even
	bitMapAddress word		// must be even
	height word			// in double scan lines
	]
manifest lDB=size DB/16


//	Table 4.7: Display control; see section 4.5




// font character descriptor.  If p points to a FCD, then
// p!(-p>>FCD.height) contains the first scan line of the character
// stored in the font, p!(-1) the last
structure FCD[
	[ blank bit 11; width bit 4 ] =
	[ blank bit 7; extension bit 8 ]
	noExtension bit 1			// previous field is width if
					// this is 1; otherwise it is
					// extension and the width is 16
	displacement bit 8		// character is pushed down this
					// far
	height bit 8			// number of scan lines (words)
					// of bit map stored for this
					// character
	]

// font
structure FONT[
	height word			// height of tallest character,
					// in scan lines, including min-
					// imum inter-line space. Must
					// be even
	variableWidth bit 1
	blank bit 7
	width bit 8			// includes inter-character
					// spacing; maximum width if
					// font is variable-width
// The font pointer given to CREATES must point to the next word
	characterFCDpointers ↑ 0,255 word // self-relative pointers to
					// FCDs for 256 characters
	extensionFCDpointers word	// likewise for extensions; as
					// many words as needed.
					// the FCDs follow immediately
	]


//	Table 4.8: Standard Alto fonts; see section 4.5 {next page}
// Bcpl frame
structure F[
	callersFrame word
	savedPC word			// this frame's PC is stored
					// here during a call
	temp word				// temporary storage; free
					// during calls
	extraArguments word		// see manual for details
	formals word			 // the formal parameters are
					// stored in successive words
					// starting here.
	]


//	Table 4.9: Bcpl frame structure; see section 4.6 {next page} 



// layout vector passed to the program on startup
structure BLV[
	overlayAddress ↑ 0, 25 word
	startOfStatics word		// address of first static
	endOfStatics word			// address of last static
	startOfCode word			// address of first word of code
	afterLastCodeWord word		// 1 + largest address at which
					// code is loaded (normally
					// endCode is the same, and the
					// system treats that value
					// as the end of the program)
	endCode word			// first location which may be 
					// used for data; used by the
					// system to set EndCode
	blank word
	]



//	Table 4.10: Bcpl layout vector



// format of an Alto save file
structure SV[
	H [				// header
	  startingAddress word		// initial value for PC. 
					// Loader sets this to
					// SV.BLV.startOfCode
	  length word			// unused
	  type word			// should be 0 for an ordinary
					// save file
	  blank ↑ 1, 11 word
	  ]
	BLV @BLV				// Bcpl layout vector
	page0 ↑ 0, #277 word		// The first #16 words are 
					// ignored; the rest are used to
					// set words #16 to #277 of
					// memory
	statics ↑ 0, 0 word		// actually there are
					// (BLV.endOfStatics -
					// BLV.startOfStatics + 1)
					// words here
	code ↑ 0, 0 word			// actually there are 
					// (BLV.endCode-BLV.startOfCode)
					// words here
	end word
	]



//	Table 4.11: Alto save file {next page}