:TITLE[DisplayDefs];*Ed Fiala 4 May 1982

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)

*To use fewer registers, consider the following possibilities:
* (1) 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;
* (2) vButtons could be eliminated by preserving the six bits in vCR[2:7].

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
*The CSB extends from 177700 to 177737.
RV2[vCSB,vCSBHi,Add[vRB,4]];
*vCSBHi .eq. 0
Set[CSBaddress,177700];
*Offsets from CSB
Set[DCBptr,0];
*DCB is in 0 to 177777
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[CursorX,2];
Set[CursorY,3];
Set[MouseX,4];
Set[MouseY,5];
*6 is smashable
*7 is mouse buttons
*10-16 are Keyboard table words 0 to 6
*17 unused
MC[CursorBitmap,20];
*177720 to 177737
*177400 to 177477 contain zeroes.
RV[vSLC,Add[vRB,6]];
*"Scan Line Count"
RV[vCursorY,Add[vRB,7]];
RV[vCR,Add[vRB,10]];
*Copy of hardware control register
RV[vMouseDxy,Add[vRB,11]];
RV[vMsgStatus,Add[vRB,12]];
RV[vCursorControl,Add[vRB,13]];
RV[vMsg,Add[vRB,14]];
RV[vCnt,Add[vRB,15]];
RV[vButtons,Add[vRB,16]];
RV[vKeyBuffer,Add[vRB,17]];

: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)