-- wiresDefs2.mesa
WiresDefs:DEFINITIONS=BEGIN
OnI:TYPE=PROCEDURE[i:INTEGER];
CR:CHARACTER=’
;
-- Stuff for Graphics
Hop:TYPE=INTEGER;
Circuit:TYPE=INTEGER;
GridXY:TYPE=INTEGER;
Dir:TYPE={h,v,none};
Direction:TYPE={h,v};
Loc:TYPE=[0..128);
Slot: TYPE={chanA,gate,chanB,none};
Contact:TYPE=Slot[chanA..chanB];
OrientState:TYPE={none,unkn,gHorr,aLeft,cLeft,gVert,aDown,cDown};
RedOrient:TYPE={none,ul,lr,both};
Color:TYPE={none,r,g,b,y};
Way:TYPE={l,r,u,d,none};
Twist:TYPE={none,n,b,f,s,a};
topCircuit:Circuit=1000;
nullCircuit:Circuit=topCircuit;
nullTransistor:Transistor=[nullCircuit,nullCircuit,nullCircuit];
--nilOrientation:OrientData=
-- [state:unkn,red:none,num:0,leftSeg:NIL,rightSeg:NIL,
-- upSeg:NIL,downSeg:NIL];
terminalHop:Hop=10000;
nilOrient:Orient=[NIL,0];
Where: TYPE=RECORD[h,l:BOOLEAN,x,y:[0..128)];
-- h => horizontal, l => level=blue
Node: TYPE=RECORD[s:SegPtr,hop:Hop,
back:NodePtr,normal,movingLD,l:BOOLEAN,contact: Slot];
Follow: TYPE=RECORD[s:SegPtr];
Location: TYPE=RECORD[contact:Contact,i,j:Loc];
Coords: TYPE=RECORD[d:Dir,x,y:Loc];
Transistor:TYPE=RECORD[a,b,c:Circuit];
Wire: TYPE=RECORD[a,b:Location,c:Color,l,circuit:Circuit];
Orient: TYPE=RECORD[seg:SegPtr,num:[0..16)];
OrientData:TYPE=RECORD[state: OrientState,pullup,pullupToC: BOOLEAN,
num: INTEGER,leftSeg,rightSeg,upSeg,downSeg:Seg];
Seg: TYPE=RECORD[circuit:Circuit,xy:Where,
w:Way,
c:Color,
nc,bc,ac,dummy,dogF,dogS:BOOLEAN,
next,back,first,second,across:SegPtr,
major,minorF,minorS: INTEGER];
-- dummy => not really part of a wire
-- nc,bc,ac => connected to next,back,across (levels) resp.
-- way is defined only for dummies
WirePtr: TYPE=POINTER TO Wire;
OrientPtr:TYPE=POINTER TO Orient;
OrientDataPtr:TYPE=POINTER TO OrientData;
NodePtr: TYPE=POINTER TO Node;
FollowPtr:TYPE=POINTER TO Follow;
SegPtr: TYPE=POINTER TO Seg;
--CIRCUITS
EnumerateWires:PROCEDURE[call:PROCEDURE[INTEGER,WirePtr]];
MakeWireList:PROCEDURE[BOOLEAN];
PrintWireList:PROCEDURE;
ChangeWireScale:PROCEDURE;
WireLength: PROCEDURE[i,j: Location] RETURNS[INTEGER];
--CONTROL
AllocateStuffForCreate:PROCEDURE;
RecoverStuffInCreate: PROCEDURE;
--GRID
EnumerateGrid:PROCEDURE[call:PROCEDURE[i,j:INTEGER]];
EnumerateGridPlusOne:PROCEDURE[call:PROCEDURE[i,j:INTEGER]];
EnumerateGridPlusTwo:PROCEDURE[call:PROCEDURE[i,j:INTEGER]];
ClearGrid:PROCEDURE[i,j:INTEGER];
EnumerateSide:PROCEDURE[call:PROCEDURE[INTEGER]];
EnumerateSidePlusOne:PROCEDURE[call:PROCEDURE[INTEGER]];
EnumerateSidePlusTwo:PROCEDURE[call:PROCEDURE[INTEGER]];
--INPUT STUFF
GetInput:PROCEDURE[BOOLEAN,STRING];
--PRINTING
PrintG:PROCEDURE;
--GRAPHICS
PutBox:PROCEDURE[color:Color,x,y,m,n:CARDINAL];
-- Graphics Display Procedures
DoOutputs: PROCEDURE[name:STRING,limitX,limitY:INTEGER];
-- Segs
InitSegs:PROCEDURE;
ShowSeg:PROCEDURE[s:SegPtr] RETURNS[INTEGER];
PrintSegs:PROCEDURE;
SetPullup:PROCEDURE[Location];
PrintOneSeg:PROCEDURE[s:SegPtr];
SetSeg:PROCEDURE[from:NodePtr,col:Color, circuit: Circuit,old: SegPtr,
tieN,tieB:BOOLEAN] RETURNS[SegPtr];
SetInitialSegment:PROCEDURE[l:Location,n:NodePtr,circuit: Circuit]
RETURNS[BOOLEAN,BOOLEAN];
SetFinalSegment:PROCEDURE[l:Location,s:SegPtr,n:NodePtr,circuit: Circuit];
AddToSeg: PROCEDURE RETURNS[ret: SegPtr];
IllegalSeg: PROCEDURE[s: SegPtr] RETURNS[BOOLEAN];
--Stks
GenerateCoordinates: PROCEDURE RETURNS[limitX,limitY: INTEGER];
PlotSegs:PROCEDURE;
--orient
--NextOrient:PROCEDURE[Orient,Location] RETURNS[Orient];
EnumerateOrient:PUBLIC PROCEDURE[Location,PROCEDURE[SegPtr, Contact]
RETURNS[BOOLEAN]] RETURNS[BOOLEAN];
PrintOrientations: PROCEDURE[i,j:INTEGER];
PrintStubs: PROCEDURE[i,j: INTEGER];
--Control
AllocateStuffForSeg:PROCEDURE;
RecoverStuffInSeg: PROCEDURE;
debugPrint:BOOLEAN;
side:Loc;
maxSide:Loc=10;
gridType:TYPE=ARRAY (0..maxSide) OF ARRAY (0..maxSide) OF Transistor;
grid:POINTER TO gridType;
END..