:TITLE[DisplayDefs];*Last edited by Fiala 3 September 1981

SetTask[DisplayTask];
*Definitions for Pilot UTVFC

Set[vCReg,0];
*Control register
Set[vfCReg,Add[LShift[DisplayTask,4],0]];
*For IOFetch4 to vCReg
MC[ClrNC,1]; MC[AllowWU,2]; MC[OddFld,4]; MC[VS,10]; MC[Blank,20];
MC[BlackBackground,100]; MC[IncNC,200];
MC[AllowWU&Blank,AllowWU,Blank]; MC[OddFld&Blank,OddFld,Blank];
MC[ClrNC&Blank,ClrNC,Blank]; MC[IncNC&Blank,IncNC,Blank];
Set[vBufStart,1];
*Buffer Starting Address
Set[vHCRam,2];
*Horizontal control ram
Set[vLdIAR,3];
*IAR[0:5] ← Start[0:5] (data is ignored)
Set[vCursor0,4];
*Channel 0 Cursor control register
*Set[vCursor1,5];
*Channel 1 Cursor control register
Set[vCursorMem0,6];
*Channel 0 Cursor Memory
*Set[vCursorMem1,7];
*Channel 1 Cursor Memory
Set[vBuf0,10];
*Channel 0 data buffer--use with Output
Set[vfBuf0,Add[LShift[DisplayTask,4],10]]; *Channel 0 data buffer for IOFetch
*Channel 1, 2, and 3 data buffers are 11, 12, and 13 (unused)

*Note: because more than 20b registers, DisplayTask must be even.
*To use fewer registers, consider the following possibilities:
* (1) Combine vMouseDx/y into a single register with two eight-bit fields;
* (2) Replace the vCSB and vKeyboard base registers by a single base register,
*probably using 177020 and 420 as alternating values (adds about 5 mi);
* (3) If the CSL monitor code were eliminated, then vDBuf0 and vDBuf1 would
*no longer be needed during the visible scan and might be freed by recoding
*the vertical blanking activities;
* (4) vButtons could be eliminated by preserving the six bits in vCR[2:7] and
*vBadCnt can be eliminated.

Set[vRB,LShift[And[DisplayTask,3],4]];
*enforces register allocation conventions

RV4[vDBuf0,vDBuf1,vDBuf2,vDBuf3,Add[vRB,0]];
*general temporaries
RV2[vBitmap,vBitmapHi,Add[vRB,2]];
**NOTE: overlaps vDBuf2 and vDBuf3
RV2[vKeyboard,vKeyboardHi,Add[vRB,4]];
*vKeyboardHi .eq. MDShi
Set[KeyboardAddress,177030];
*Keyboard words start at 177034
*Buttons are written at 177033 and
*177030-177032 are smashable.
RV[vSLC,Add[vRB,6]];
*"Scan Line Count"
RV[vCursorY,Add[vRB,7]];
RV[vCR,Add[vRB,10]];
*Copy of hardware control register
RV[vMouseDx,Add[vRB,11]];
RV[vMouseDy,Add[vRB,12]];
RV[vCursorControl,Add[vRB,13]];
RV[vMsg,Add[vRB,14]];
RV[vCnt,Add[vRB,15]];
RV[vButtons,Add[vRB,16]];
*This one needed only for LF keyboard
RV[vBadCnt,Add[vRB,16]];
*This one needed only for CSL keyboard
*Counts bad end flag events in bits 0:7,
*message type 0 events in bits 8:15d.
* (can deimplement if desired)
RV[vKeyBuffer,Add[vRB,17]];
RV2[vCSB,vCSBHi,Add[vRB,20]];
*vCSBHi .eq. MDShi
Set[CSBaddress,420];
*Offsets from CSB
Set[DCBptr,0];
*DCB is in MDS
Set[DCBFlags,1];
*Offset of flags word from beginning of DCB
MC[DCBBackground,40000];
*0 => white background
Set[DCBBitmapPtr,4];
*Offset of bitmap pointer from beginning of DCB
Set[InterruptMask,1];
Set[MouseX,4];
Set[MouseY,5];
Set[CursorX,6];
Set[CursorY,7];
MC[CursorBitmap,11];
RV[vMsgStatus,Add[vRB,22]];


:IF[LFMonitor]; *********************************
MC[WordsPerLine,100];
*64d words/scanline
Set[vStart,0];
MC[vVSStart,11];
*Nscanlines - 1 before start of vert sync field B
*(+1 added for field A).
MC[vSyncLength,2];
*Nscanlines - 17d in which vert sync asserted
*Spec is 18 lines of vertical sync/field
MC[vBlankLength,14];
*Nscanlines - 3 after vert sync before starting frame
:ELSE; ******************************************
MC[WordsPerLine,46];
*38d words/scanline
Set[vStart,15000];
MC[vVSStart,1];
*Nscanlines - 1 before start of vert sync field B
*(+1 added for field A).
MC[vSyncLength,0];
*Nscanlines - 17d in which vert sync asserted
MC[vBlankLength,13];
*Nscanlines - 3 after vert sync before starting frame
:ENDIF; *****************************************

MC[ZeroDataBuffer,177400];
*Area in last 64k that contains 20B zeroes

*These are the Alto-compatible numbers
Set[MaxScanLines,624];
*no. visible scan lines per field/2
*(= 808 visible scanlines/screen = Alto compatible)