! The ILAP contact symbols

%include "nmos.inc"

{#########################################################################}
{#                                                                       #}
{#      This program is part of the ILAP library, and was written in     #}
{#   The Department of Computer Science at the University of Edinburgh   #}
{#       (James Clerk Maxwell Building, Kings Buildings, Edinburgh)      #}
{#                                                                       #}
{#   This software is available free to other educational establisments  #}
{#   but the University of Edinburgh, retains all commercial rights.     #}
{#   It is a condition of having this software is that the sources are   #}
{#   not passed on to any other site, and that Edinburgh University is   #}
{#   given credit in any re-implementations of any of the algorithms     #}
{#   used, or articles published which refer to the software.            #}
{#                                                                       #}
{#   There is no formal support for this software, but any bugs should   #}
{#   be reported to Gordon Hughes or David Rees at the above address,    #}
{#   and these are likely to be fixed in a future release.               #}
{#                                                                       #}
{#########################################################################}

! There now follows some tables which define the symbols -
! The max length of each contact symbol is -
%const %integer sym len = 4

%const %integer  subc start = 1
%const %integer    dm start = subc start + sym len * 5
%const %integer    pm start = dm start + sym len * 5
%const %integer  pdms start = pm start + sym len * 5
%const %integer  pdmn start = pdms start + sym len * 5
%const %integer  pdmw start = pdmn start + sym len * 5
%const %integer  pdme start = pdmw start + sym len * 5
%const %integer pdbns start = pdme start + sym len * 5
%const %integer pdbew start = pdbns start + sym len * 5
%const %integer  pdcn start = pdbew start + sym len * 5
%const %integer  pdcs start = pdcn start + sym len * 5
%const %integer  pdce start = pdcs start + sym len * 5
%const %integer  pdcw start = pdce start + sym len * 5
%const %integer  pdbn start = pdcw start + sym len * 5
%const %integer  pdbs start = pdbn start + sym len * 5
%const %integer  pdbe start = pdbs start + sym len * 5
%const %integer  pdbw start = pdbe start + sym len * 5

! Format of the array is 4 lines of the form <layer> <-dx> <dy> <dx> <dy> per bax in the symbol.

%const %byte %integer %array contactsa (1:pdbw start + sym len * 5 - 1) =
 {subc}  'S', 2, 2, 2, 2, 'M', 2, 2, 2, 2, 'C', 1, 1, 1, 1, 'Z', 0, 0, 0, 0,
 {dm}    'M', 2, 2, 2, 2, 'D', 2, 2, 2, 2, 'C', 1, 1, 1, 1, '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bw}  'D', 3, 1, 2, 1, 'P', 1, 2, 1, 2, 'B', 3, 2, 2, 2, 'I', 3, 2, 2, 2

%routine draw contact (%integer start, x, y)
   %integer I
   %string (4) temp
   temp = c layer
   %for I = 1, 1, sym len %cycle
        %if contactsa (start) # 'Z' %start
            layer (to string (contactsa(start)))
            box (x - contactsa(start+1), y - contactsa(start+2), x + contactsa(start+3), y + contactsa(start+4))
        %finish
        start = start + 5
   %repeat
   layer (temp)
%end

%external %routine subc %alias "ILAP_SUBC" (%integer x, y)
   draw contact (subc start, x, y)
%end

%externalroutine dm %alias "ILAP_DM" (%integer x,y)
   draw contact (dm start, x, y)
%end

%externalroutine pm %alias "ILAP_PM" (%integer x,y)
   draw contact (pm start, x, y)
%end

%externalroutine pdms %alias "ILAP_PDMS" (%integer x, y)
   draw contact (pdms start, x, y)
%end

%externalroutine pdmn %alias "ILAP_PDMN" (%integer x, y)
   draw contact (pdmn start, x, y)
%end

%externalroutine pdmw %alias "ILAP_PDMW" (%integer x, y)
   draw contact (pdmw start, x, y)
%end

%externalroutine pdme %alias "ILAP_PDME" (%integer x, y)
   draw contact (pdme start, x, y)
%end

%external %routine pdbns %alias "ILAP_PDBNS" (%integer x, y)
   draw contact (pdbns start, x, y)
%end

%external %routine pdbew %alias "ILAP_PDBEW" (%integer x, y)
   draw contact (pdbew start, x, y)
%end

%external %routine pdcn %alias "ILAP_PDCN" (%integer x, y)
   draw contact (pdcn start, x, y)
%end

%external %routine pdcs %alias "ILAP_PDCS" (%integer x, y)
   draw contact (pdcs start, x, y)
%end

%external %routine pdce %alias "ILAP_PDCE" (%integer x, y)
   draw contact (pdce start, x, y)
%end

%external %routine pdcw %alias "ILAP_PDCW" (%integer x, y)
   draw contact (pdcw start, x, y)
%end

%external %routine pdbn %alias "ILAP_PDBN" (%integer x, y)
   draw contact (pdbn start, x, y)
%end

%external %routine pdbs %alias "ILAP_PDBS" (%integer x, y)
   draw contact (pdbs start, x, y)
%end

%external %routine pdbe %alias "ILAP_PDBE" (%integer x, y)
   draw contact (pdbe start, x, y)
%end

%external %routine pdbw %alias "ILAP_PDBW" (%integer x, y)
   draw contact (pdbw start, x, y)
%end

%end %of %file
