-- procedure exporting module of silicon (pretty picture) program
-- last modified by McCreight, December 3, 1982  9:51 AM
--   to eliminate repeated objects

DIRECTORY
  SegmentDefs,
  StringDefs,
  ppddefs,
  ppdddefs,pppdefs,
  ppdefs;
ppprocs8: PROGRAM IMPORTS pppdefs EXPORTS pppdefs =
  BEGIN OPEN ppdefs, ppddefs, pppdefs, SegmentDefs;

  drPu0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO xstr object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN
    ELSE
      BEGIN
      x1: locNum = x + p.wExt;
      y1: locNum = y + p.lExt;
      middleX: locNum = x + p.size[0]/2;
      metal: Rect = [x1: middleX-2*Lambda, y1:y+p.size[1]-6*Lambda,
        x2: middleX+2*Lambda, y2: y+p.size[1]];
      pr.orArea[x1, y, x1 + p.width, y+p.size[1], dif, @pr.r];
      pr.orArea[x, y1, x + p.size[0], y1 + p.length, pol, @pr.r];
      pr.orArea[x, y, x + p.size[0], metal.y2-Lambda,
        imp, @pr.r];
      pr.orArea[metal.x1, metal.y1+2*Lambda, metal.x2, metal.y2,
        dif, @pr.r];
      pr.orArea[metal.x1, metal.y1, metal.x2, metal.y2, met, @pr.r];
      pr.saveArea[metal.x1+Lambda, metal.y1+Lambda,
        metal.x2-Lambda, metal.y2-Lambda, cut, @pr.r];
      END;
    END;

  drPu2: PUBLIC drProc =
    {drArb[drPu0, 4, ob, x, y, pr]};

  drPu4: PUBLIC drProc =
    {drArb[drPu0, 8, ob, x, y, pr]};

  drPu6: PUBLIC drProc =
    {drArb[drPu0, 12, ob, x, y, pr]};

  drWire0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO wire object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[0], y + p.size[1], p.l, @pr.r];
    END;
  drWire2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO wire object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[1], y + p.size[0], p.l, @pr.r];
    END;
  drPWire0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO wire object = LOOPHOLE[ob];
--    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
--      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x-p.surround, y-p.surround, x + p.size[0]+p.surround, y + p.size[1]+p.surround, nwel, @pr.r];
    pr.orArea[x, y, x + p.size[0], y + p.size[1], p.l, @pr.r];
    END;
  drPWire2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO wire object = LOOPHOLE[ob];
--    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
--      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    pr.orArea[x-p.surround, y-p.surround, x + p.size[1]+p.surround, y + p.size[0]+p.surround, nwel, @pr.r];
    pr.orArea[x, y, x + p.size[1], y + p.size[0], p.l, @pr.r];
    END;

  drBC0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[0], y + p.size[1], met, @pr.r];
    pr.orArea[x, y, x + p.size[0], y + p.size[1]/2, pol, @pr.r];
    pr.orArea[x, y + p.magicN*2, x + p.size[0], y + p.size[1], dif, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[0],
      y + p.magicN + p.size[0], cut, @pr.r];
    END;

  drBC2: PUBLIC drProc =
    {drArb[drBC0, 4, ob, x, y, pr]};

  drBC4: PUBLIC drProc =
    {drArb[drBC0, 8, ob, x, y, pr]};

  drBC6: PUBLIC drProc =
    {drArb[drBC0, 12, ob, x, y, pr]};

  drMDC0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[0], y + p.size[1], met2, @pr.r];
    pr.orArea[x, y, x + p.size[0], y + p.size[1], met, @pr.r];
    pr.orArea[x+p.m2Ext, y+p.m2Ext, x-p.m2Ext + p.size[0], y-p.m2Ext + p.size[1], p.l, @pr.r];
    pr.saveArea[
      x + p.c2Ext, y + p.c2Ext, x - p.c2Ext + p.size[0],
      y - p.c2Ext + p.size[1], cut2, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[0],
      y - p.magicN + p.size[1], cut, @pr.r];
    END;
  drMDC2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[1], y + p.size[0], met2, @pr.r];
    pr.orArea[x, y, x + p.size[1], y + p.size[0], met, @pr.r];
    pr.orArea[x+p.m2Ext, y+p.m2Ext, x-p.m2Ext + p.size[1], y-p.m2Ext + p.size[0], p.l, @pr.r];
    pr.saveArea[
      x + p.c2Ext, y + p.c2Ext, x - p.c2Ext + p.size[1],
      y - p.c2Ext + p.size[0], cut2, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[1],
      y - p.magicN + p.size[0], cut, @pr.r];
    END;
  drDC0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[0], y + p.size[1], met, @pr.r];
    pr.orArea[x, y, x + p.size[0], y + p.size[1], p.l, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[0],
      y - p.magicN + p.size[1], cut, @pr.r];
    END;
  drDC2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[1], y + p.size[0], met, @pr.r];
    pr.orArea[x, y, x + p.size[1], y + p.size[0], p.l, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[1],
      y - p.magicN + p.size[0], cut, @pr.r];
    END;

  drPDC0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
--    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
--      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[0], y + p.size[1], met, @pr.r];
    pr.orArea[x, y, x + p.size[0], y + p.size[1], p.l, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[0],
      y - p.magicN + p.size[1], cut, @pr.r];
    pr.orArea[x-p.surround, y-p.surround, x + p.size[0]+p.surround, y + p.size[1]+p.surround, nwel, @pr.r];
    END;
  drPDC2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
--    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
--      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[1], y + p.size[0], met, @pr.r];
    pr.orArea[x, y, x + p.size[1], y + p.size[0], p.l, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[1],
      y - p.magicN + p.size[0], cut, @pr.r];
    pr.orArea[x-p.surround, y-p.surround, x + p.size[1]+p.surround, y + p.size[0]+p.surround, nwel, @pr.r];
    END;
  drMPDC0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
--    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
--      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[0], y + p.size[1], met2, @pr.r];
    pr.orArea[x, y, x + p.size[0], y + p.size[1], met, @pr.r];
    pr.orArea[x+p.m2Ext, y+p.m2Ext, x-p.m2Ext + p.size[0], y-p.m2Ext + p.size[1], p.l, @pr.r];
    pr.saveArea[
      x + p.c2Ext, y + p.c2Ext, x - p.c2Ext + p.size[0],
      y - p.c2Ext + p.size[1], cut2, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[0],
      y - p.magicN + p.size[1], cut, @pr.r];
    pr.orArea[x-p.surround+p.m2Ext, y-p.surround+p.m2Ext, x + p.size[0]+p.surround-p.m2Ext, y + p.size[1]+p.surround-p.m2Ext, nwel, @pr.r];
    END;
  drMPDC2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
--    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
--      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[1], y + p.size[0], met2, @pr.r];
    pr.orArea[x, y, x + p.size[1], y + p.size[0], met, @pr.r];
    pr.orArea[x+p.m2Ext, y+p.m2Ext, x-p.m2Ext + p.size[1], y-p.m2Ext + p.size[0], p.l, @pr.r];
    pr.saveArea[
      x + p.c2Ext, y + p.c2Ext, x - p.c2Ext + p.size[1],
      y - p.c2Ext + p.size[0], cut2, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[1],
      y - p.magicN + p.size[0], cut, @pr.r];
    pr.orArea[x-p.surround+p.m2Ext, y-p.surround+p.m2Ext, x + p.size[1]+p.surround-p.m2Ext, y + p.size[0]+p.surround-p.m2Ext, nwel, @pr.r];
    END;

  drMM0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[0], y + p.size[1], met, @pr.r];
    pr.orArea[x, y, x + p.size[0], y + p.size[1], met2, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[0],
      y - p.magicN + p.size[1], cut2, @pr.r];
    END;
  drMM2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    pr.orArea[x, y, x + p.size[1], y + p.size[0], met, @pr.r];
    pr.orArea[x, y, x + p.size[1], y + p.size[0], met2, @pr.r];
    pr.saveArea[
      x + p.magicN, y + p.magicN, x - p.magicN + p.size[1],
      y - p.magicN + p.size[0], cut2, @pr.r];
    END;

  drBuC0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x+p.wExt,y,x+p.size[0]-p.wExt+p.magicN,y+p.size[1], pol, @pr.r];
    pr.orArea[x,y+p.lExt,x+p.size[0],y+p.size[1]-p.lExt, dif, @pr.r];
    pr.saveArea[x,y,x+p.size[0],y+p.size[1],bur,@pr.r];
    END;
  drBuC2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    pr.orArea[x,y+p.wExt,x+p.size[1],y+p.size[0]-p.wExt+p.magicN,pol,@pr.r];
    pr.orArea[x+p.lExt,y,x+p.size[1]-p.lExt,y+p.size[0],dif,@pr.r];
    pr.saveArea[x,y,x+p.size[1],y+p.size[0],bur,@pr.r];
    END;
  drBuC4: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    pr.orArea[x+p.wExt-p.magicN,y,x+p.size[0]-p.wExt,y+p.size[1], pol, @pr.r];
    pr.orArea[x,y+p.lExt,x+p.size[0],y+p.size[1]-p.lExt, dif, @pr.r];
    pr.saveArea[x,y,x+p.size[0],y+p.size[1],bur,@pr.r];
    END;
  drBuC6: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO cont object = LOOPHOLE[ob];
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    pr.orArea[x,y+p.wExt-p.magicN,x+p.size[1],y+p.size[0]-p.wExt,pol,@pr.r];
    pr.orArea[x+p.lExt,y,x+p.size[1]-p.lExt,y+p.size[0],dif,@pr.r];
    pr.saveArea[x,y,x+p.size[1],y+p.size[0],bur,@pr.r];
    END;

  drBus0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO bus object = LOOPHOLE[ob];
    len,wid:INTEGER;
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    wid←p.wwidth;
    len←p.firstLength;
    y←y+p.offsetFirst;
    THROUGH [0..p.wCnt) DO
      pr.orArea[x,y,x+wid,y+len,p.l,@pr.r];
      x←x+p.wspace;
      y←y+p.topIncr;
      len←len+p.lenIncr;
    ENDLOOP;
    END;
  drBus2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO bus object = LOOPHOLE[ob];
    len,wid:INTEGER;
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    wid←p.wwidth;
    len←p.firstLength;
    x←x+p.size[1]-len-p.offsetFirst;
    THROUGH [0..p.wCnt) DO
      pr.orArea[x,y,x+len,y+wid,p.l,@pr.r];
      y←y+p.wspace;
      x←x-p.topIncr-p.lenIncr;
      len←len+p.lenIncr;
    ENDLOOP;
    END;
  drBus4: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO bus object = LOOPHOLE[ob];
    len,wid:INTEGER;
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    wid←p.wwidth;
    len←p.firstLength;
    x←x+p.size[0]-wid;
    y←y+p.size[1]-len-p.offsetFirst;
    THROUGH [0..p.wCnt) DO
      pr.orArea[x,y,x+wid,y+len,p.l,@pr.r];
      x←x-p.wspace;
      y←y-p.topIncr-p.lenIncr;
      len←len+p.lenIncr;
    ENDLOOP;
    END;
  drBus6: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO bus object = LOOPHOLE[ob];
    len,wid:INTEGER;
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    wid←p.wwidth;
    len←p.firstLength;
    x←x+p.offsetFirst;
    y←y+p.size[0]-wid;
    THROUGH [0..p.wCnt) DO
      pr.orArea[x,y,x+len,y+wid,p.l,@pr.r];
      y←y-p.wspace;
      x←x+p.topIncr;
      len←len+p.lenIncr;
    ENDLOOP;
    END;
  drBusR0: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO bus object = LOOPHOLE[ob];
    len,wid:INTEGER;
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    wid←p.wwidth;
    len←p.firstLength;
    y←y+p.offsetFirst;
    x←x+p.size[0]-wid;
    THROUGH [0..p.wCnt) DO
      pr.orArea[x,y,x+wid,y+len,p.l,@pr.r];
      x←x-p.wspace;
      y←y+p.topIncr;
      len←len+p.lenIncr;
    ENDLOOP;
    END;
  drBusR2: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO bus object = LOOPHOLE[ob];
    len,wid:INTEGER;
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    wid←p.wwidth;
    len←p.firstLength;
    x←x+p.offsetFirst;
    THROUGH [0..p.wCnt) DO
      pr.orArea[x,y,x+len,y+wid,p.l,@pr.r];
      y←y+p.wspace;
      x←x+p.topIncr;
      len←len+p.lenIncr;
    ENDLOOP;
    END;
  drBusR4: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO bus object = LOOPHOLE[ob];
    len,wid:INTEGER;
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[0] < pr.r.x1
      OR y + p.size[1] < pr.r.y1 THEN RETURN;
    wid←p.wwidth;
    len←p.firstLength;
    y←y+p.size[1]-len-p.offsetFirst;
    THROUGH [0..p.wCnt) DO
      pr.orArea[x,y,x+wid,y+len,p.l,@pr.r];
      x←x+p.wspace;
      y←y-p.topIncr-p.lenIncr;
      len←len+p.lenIncr;
    ENDLOOP;
    END;
  drBusR6: PUBLIC drProc =
    BEGIN
    p: LONG POINTER TO bus object = LOOPHOLE[ob];
    len,wid:INTEGER;
    IF x > pr.r.x2 OR y > pr.r.y2 OR x + p.size[1] < pr.r.x1
      OR y + p.size[0] < pr.r.y1 THEN RETURN;
    wid←p.wwidth;
    len←p.firstLength;
    x←x+p.size[1]-len-p.offsetFirst;
    y←y+p.size[0]-wid;
    THROUGH [0..p.wCnt) DO
      pr.orArea[x,y,x+len,y+wid,p.l,@pr.r];
      y←y-p.wspace;
      x←x-p.topIncr-p.lenIncr;
      len←len+p.lenIncr;
    ENDLOOP;
    END;

  END.