home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / PCLO3.0R.DMS / in.adf / PlotSource / plot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-07-23  |  39.6 KB  |  1,766 lines

  1.  
  2.  
  3. #include "exec/types.h"
  4. #include "exec/nodes.h"
  5. #include "exec/lists.h"
  6. #include "exec/ports.h"
  7. #include "exec/libraries.h"
  8. #include "exec/devices.h"
  9. #include "exec/io.h"
  10. #include "devices/serial.h"
  11. #include "lattice/stdio.h"
  12.  
  13. struct IOExtSer *IORser;
  14. struct MsgPort *port;
  15. char buffer[200];
  16. extern struct MsgPort *CreatePort();
  17. extern struct IORequest *CreateExtIO();
  18. UBYTE *bdtop,*fatrec;              /* pointer to layer information */
  19. int random,rdmuse,xcfac,ycfac,res,shearing,camrdy,tofile;
  20. int xcept1,xcept2,xcept3,xcept4;
  21. int fillmem[4];
  22. UBYTE xname[20],bdname[80],fname[80],tname[80],choice[20],outfile[80];
  23. UBYTE plotype;
  24. FILE *outfp;
  25.  
  26. main()
  27.    {
  28.    int error;
  29.    unsigned long rbl,brk,baud,rwl,wwl,sf,t0,t1;
  30.  
  31.       printf("\033[42m\033[33m                                  \033[0m\n");
  32.       printf("\033[42m\033[33m \033[41m SoftCircuits, Inc -- PLOT v1.3 \033[42m \033[0m\n");
  33.       printf("\033[42m\033[33m                                  \033[0m\n");
  34.  
  35.       xcfac=0;
  36.       ycfac=0;
  37.       random=1;
  38.       res=0;
  39.       xcept1=99;
  40.       xcept2=99;
  41.       xcept3=99;
  42.       xcept4=99;
  43.  
  44. retry:
  45.       printf("\nEnter board name: ");
  46.       gets(&fname[0]);
  47.       if (strlen(&fname[0]) == 0)
  48.          {
  49.             printf("Illegal filename\n");
  50.             exit(10);
  51.          }
  52.  
  53.       printf("\nSelect plot Options; Enter a numeral\n");
  54.       printf("         [ 0 ]   Plot TOP layer\n");
  55.       printf("         [ 1 ]   Plot BOTTOM layer\n");
  56.       printf("         [ 2 ]   Plot PADs only\n");
  57.       printf("         [ 3 ]   Plot TOP layer -- NO PADS\n");
  58.       printf("         [ 4 ]   Plot BOTTOM layer -- NO PADS\n");
  59.       printf("         [ 5 ]   Plot SILKSCREEN only\n");
  60.       printf("Select; ");
  61.       gets(&choice[0]);
  62.  
  63.       switch(choice[0])
  64.          {
  65.             case '0':
  66.                {
  67.                   strcpy(&xname[0],".layer1");
  68.                   break;
  69.                }
  70.             case '1':
  71.                {
  72.                   strcpy(&xname[0],".layer2");
  73.                   break;
  74.                }
  75.             case '2':
  76.                {
  77.                   strcpy(&xname[0],".layer1");
  78.                   break;
  79.                }
  80.             case '3':
  81.                {
  82.                   strcpy(&xname[0],".layer1");
  83.                   break;
  84.                }
  85.             case '4':
  86.                {
  87.                   strcpy(&xname[0],".layer2");
  88.                   break;
  89.                }
  90.             case '5':
  91.                {
  92.                   strcpy(&xname[0],".silk");
  93.                   break;
  94.                }
  95.             default:
  96.                {
  97.                   printf("Illegal choice\n");
  98.                   exit(20);
  99.                }
  100.          }
  101.  
  102.       plotype=choice[0];
  103.       shearing=0;
  104.       if (plotype == '5') goto skipshear;
  105.  
  106.       printf("\nPlot shear lines?\n");
  107.       printf("(Y or N): ");
  108.       gets(&choice[0]);
  109.       switch(choice[0])
  110.          {
  111.             case 'y':
  112.             case 'Y':
  113.                {
  114.                   shearing=1;
  115.                   break;
  116.                }
  117.             case 'n':
  118.             case 'N':
  119.                {
  120.                   shearing=0;
  121.                   break;
  122.                }
  123.             default:
  124.                {
  125.                   printf("Illegal choice\n");
  126.                   exit(20);
  127.                }
  128.          }
  129.  
  130. skipshear:
  131.  
  132.       printf("\nSelect plot quality\n");
  133.       printf("        [ 0 ]    Camera ready\n");
  134.       printf("        [ 1 ]    Check plot\n");
  135.       printf("Select: ");
  136.       gets(&choice[0]);
  137.       switch(choice[0])
  138.          {
  139.             case '0':
  140.                {
  141.                   camrdy='1';
  142.                   break;
  143.                }
  144.             case '1':
  145.                {
  146.                   camrdy='0';
  147.                   break;
  148.                }
  149.             default:
  150.                {
  151.                   printf("Illegal choice\n");
  152.                   exit(20);
  153.                }
  154.          }
  155.  
  156.       res=2;
  157.       if (camrdy == '1') goto nolores;
  158.  
  159.       printf("\nSelect plot size option:\n");
  160.       printf("        [ 2 ]    2:1 plotting\n");
  161.       printf("        [ 1 ]    1:1 plotting\n");
  162.       printf("Select: ");
  163.       gets(&choice[0]);
  164.  
  165.       switch(choice[0])
  166.          {
  167.             case '1':
  168.                {
  169.                   res=1;
  170.                   break;
  171.                }
  172.             case '2':
  173.                {
  174.                   res=2;
  175.                   break;
  176.                }
  177.             default:
  178.                {
  179.                   printf("Illegal choice\n");
  180.                   exit(20);
  181.                }
  182.          }
  183.  
  184. nolores:
  185.  
  186.       printf("Select output target:\n");
  187.       printf("        [ 0 ]    Output to Plotter\n");
  188.       printf("        [ 1 ]    Output to File\n");
  189.       printf("Select: ");
  190.       gets(&choice[0]);
  191.       switch(choice[0])
  192.          {
  193.             case '0':
  194.                {
  195.                   tofile=0;
  196.                   break;
  197.                }
  198.             case '1':
  199.                {
  200.                   tofile=1;
  201.                   printf("Enter file name: ");
  202.                   gets(&outfile[0]);
  203.                   break;
  204.                }
  205.             default:
  206.                {
  207.                   printf("Illegal choice;\n");
  208.                   exit(20);
  209.                }
  210.          }
  211.  
  212.       printf("\nconfiguration is as follows -- is this correct?\n\n");
  213.       printf("File to plot = '\033[1m\033[33m%s\033[0m'\n",&fname[0]);
  214.       printf("Shear lines  = \033[1m\033[33m");
  215.       if (shearing == 0)
  216.          {
  217.             printf(" not");
  218.          }
  219.       printf(" plotted\033[0m\n");
  220.       printf("Resolved at  =  \033[1m\033[33m");
  221.       switch(res)
  222.          {
  223.             case 1:
  224.                {
  225.                   printf("1:1\n");
  226.                   break;
  227.                }
  228.             case 2:
  229.                {
  230.                   printf("2:1\n");
  231.                   break;
  232.                }
  233.          }
  234.       printf("\033[0mQuality      =  \033[1m\033[33m");
  235.       switch(camrdy)
  236.          {
  237.             case '0':
  238.                {
  239.                   printf("Check plot\n");
  240.                   break;
  241.                }
  242.             case '1':
  243.                {
  244.                   printf("Camera ready\n");
  245.                   break;
  246.                }
  247.          }
  248.  
  249.  
  250.       printf("\033[0mItem to plot =  \033[1m\033[33m");
  251.       switch(plotype)
  252.          {
  253.             case '0':
  254.                {
  255.                   printf("the TOP layer.\n");
  256.                   break;
  257.                }
  258.             case '1':
  259.                {
  260.                   printf("the BOTTOM layer.\n");
  261.                   break;
  262.                }
  263.             case '2':
  264.                {
  265.                   printf("the PADs only. (No trace information)\n");
  266.                   break;
  267.                }
  268.             case '3':
  269.                {
  270.                   printf("the TOP layer; NO PADS\n");
  271.                   break;
  272.                }
  273.             case '4':
  274.                {
  275.                   printf("the BOTTOM layer; NO PADS\n");
  276.                   break;
  277.                }
  278.             case '5':
  279.                {
  280.                   printf("the SILKSCREEN\n");
  281.                }
  282.          }
  283.  
  284.       printf("\033[0mPlot output  =  \033[1m\033[33m");
  285.       switch(tofile)
  286.          {
  287.             case 0:
  288.                {
  289.                   printf("the Plotter\n");
  290.                   break;
  291.                }
  292.             case 1:
  293.                {
  294.                   printf("the file: \033[0m'\033[1m\033[33m");
  295.                   printf(&outfile[0]);
  296.                   printf("\033[0m'\n");
  297.                   break;
  298.                }
  299.          }
  300.  
  301. what:
  302.       printf("\033[0m\nEnter 'Y' or 'N': ");
  303.       gets(&choice[0]);
  304.       switch(choice[0])
  305.          {
  306.             case 'y':
  307.             case 'Y':
  308.                {
  309.                   break;
  310.                }
  311.             case 'n':
  312.             case 'N':
  313.                {
  314.                   goto retry;
  315.                }
  316.             default:
  317.                {
  318.                   goto what;
  319.                }
  320.          }
  321.  
  322.       if ((bdtop=(UBYTE*)calloc(65536,1))==NULL)
  323.          {
  324.             printf("layer memory allocation failed -- Not Enough Memory");
  325.             exit(0);
  326.          }
  327.       if ((fatrec=(UBYTE*)calloc(65536,1))==NULL)
  328.          {
  329.             printf("working memory allocation failed -- Not Enough Memory");
  330.             exit(20);
  331.          }
  332.  
  333.       if (tofile==1) goto skipserial;
  334.  
  335.       port = CreatePort(SERIALNAME,0);
  336.       if (port == NULL)
  337.          {
  338.             printf("\nProblems during CreatePort\n");
  339.             exit(100);
  340.          }
  341.       IORser = (struct IOExtSer*)CreateExtIO(port,sizeof(struct IOExtSer));
  342.       if (IORser == NULL)
  343.          {
  344.             printf("Problems during CreateExtIO\n");
  345.             goto cleanup1;
  346.          }
  347. open:
  348.       if ((error=OpenDevice(SERIALNAME,0,IORser,0)) != 0)
  349.          {
  350.             printf("Serial device did not open\n");
  351.             goto cleanup1;
  352.          }
  353.       rbl=4096;
  354.       rwl=0x08;
  355.       wwl=0x08;
  356.       brk=75000;
  357.       baud=9600;
  358.       sf=0x00;
  359.       t0=0x51040303;
  360.       t1=0x03030303;
  361.  
  362.       if ((error=SetParams(IORser,rbl,rwl,wwl,brk,baud,sf,t0,t1)) != 0)
  363.          {
  364.             printf("SetParams returned an error\n");
  365.             goto cleanup2;
  366.          }
  367.  
  368. skipserial:
  369.       if (tofile==1)
  370.          {
  371.             if (outfp=fopen(&outfile[0],"w"))
  372.                {
  373.                   printf("Plot output file opened successfully\n");
  374.                }
  375.             else
  376.                {
  377.                   printf("file open failed on plot write!\n");
  378.                   exit(20);
  379.                }
  380.          }
  381.       if (loadbd()==0)
  382.          {
  383.             goto cleanup2;
  384.          }
  385.       if (plotype != '5')
  386.          {
  387.             printf("Processing requested file; --Stand by--\n");
  388.             flipfn();
  389.             justfn();
  390.          }
  391.  
  392.       if (tofile==0)
  393.          {
  394.             printf("Output to plotter beginning now\n");
  395.          }
  396.       else
  397.          {
  398.             printf("Output to file beginning now\n");
  399.          }
  400.       if (plotype != '5')
  401.          {
  402.             plotfn();
  403.          }
  404.       else
  405.          {
  406.             silkfn();
  407.          }
  408.       printf("Output stream completed\n");
  409.  
  410. cleanup2:
  411.       if (tofile==0) CloseDevice(IORser);
  412. cleanup1:
  413.       if (tofile==0) DeletePort(port);
  414.       if (tofile==1) fclose(outfp);
  415.       exit(0);
  416.    }
  417.  
  418. flipfn()
  419.    {
  420.    int xpos,ypos,ypod;
  421.    UBYTE temp;
  422.       for (xpos=0; xpos<256; xpos++)
  423.          {
  424.             ypod=255;
  425.             for (ypos=0; ypos<128; ypos++)
  426.                {
  427.                   temp=(UBYTE)vtxlate(bdtop[xpos+(ypos*256)]);
  428.                   bdtop[xpos+(256*ypos)]=(UBYTE)vtxlate(bdtop[xpos+(256*ypod)]);
  429.                   bdtop[xpos+(256*ypod)]=(UBYTE)temp;
  430.                   ypod--;
  431.                }
  432.          }
  433.    }
  434.  
  435. justfn()
  436.    {
  437.    int limits,xlow,ylow;
  438.       limits=vcheck(bdtop);
  439.       xlow =(limits >> 24) & 255;
  440.       ylow =(limits >>  8) & 255;
  441.       txmove(xlow);
  442.       tymove(ylow);
  443.    }
  444.  
  445. txmove(xlow)
  446.    int xlow;
  447.    {
  448.    int xsrc,xdst,ypos;
  449.       for (ypos=0; ypos<256; ypos++)
  450.          {
  451.             xdst=0;
  452.             xsrc=xlow;
  453.             while(xsrc < 256)
  454.                {
  455.                   bdtop[xdst+(ypos*256)]=bdtop[xsrc+(256*ypos)];
  456.                   xsrc++;
  457.                   xdst++;
  458.                }
  459.             while(xdst < 256)
  460.                {
  461.                   bdtop[xdst+(256+ypos)]=0;
  462.                   xdst++;
  463.                }
  464.          }
  465.    }
  466.  
  467. tymove(ylow)
  468.    int ylow;
  469.    {
  470.    int xpos,ydst,ysrc;
  471.       for (xpos=0; xpos<256; xpos++)
  472.          {
  473.             ysrc=ylow;
  474.             ydst=0;
  475.             while(ysrc < 256)
  476.                {
  477.                   bdtop[xpos+(256*ydst)]=bdtop[xpos+(256*ysrc)];
  478.                   ysrc++;
  479.                   ydst++;
  480.                }
  481.             while(ydst < 256)
  482.                {
  483.                   bdtop[xpos+(256*ydst)]=0;
  484.                   ydst++;
  485.                }
  486.          }
  487.    }
  488.  
  489. churfn(xpos,ypos,data)
  490.    int xpos,ypos,data;
  491.    {
  492.    UBYTE tbuff[80];
  493.    int tmp;
  494.       if (xpos < 0)
  495.          {
  496.             return(0);
  497.          }
  498.       if (ypos < 0)
  499.          {
  500.             return(0);
  501.          }
  502.       if (data == 0)
  503.          {
  504.             return(0);
  505.          }
  506.       if (data > 31)
  507.          {
  508.             xcfac=0;
  509.             ycfac=0;
  510.             move(xpos,ypos);
  511.             strcpy(&tbuff[0],"S11 ");
  512.             tmp=strlen(&tbuff[0]);
  513.             tbuff[tmp]=(UBYTE)data;
  514.             tbuff[tmp+1]=(UBYTE)'_';
  515.             tbuff[tmp+2]=(UBYTE)' ';
  516.             tbuff[tmp+3]=0;
  517.             spurt(&tbuff[0]);
  518.             return(0);
  519.          }
  520.       linedraw(xpos,ypos,data);
  521.    }
  522.  
  523. linedraw(xpos,ypos,data)
  524.    int xpos,ypos,data;
  525.    {
  526.       xcfac=0;
  527.       ycfac=0;
  528.       spurt("U A ");
  529.       move(xpos,ypos);
  530.       switch(data)
  531.          {
  532.             case 26: /* vert line  */
  533.                {
  534.                   spurt("R 0,-10 D 0,20 U A ");
  535.                   break;
  536.                }
  537.             case 27: /* horz line */
  538.                {
  539.                   spurt("R -10,0 D 20,0 U A ");
  540.                   break;
  541.                }
  542.             case 28: /* bot left */
  543.                {
  544.                   spurt("R 0,10 D 0,-10 10,0 U A "); /*tl*/
  545.                   break;
  546.                }
  547.             case 29: /* bot right */
  548.                {
  549.                   spurt("R -10,0 D 10,0 0,10 U A "); /*tr*/
  550.                   break;
  551.                }
  552.             case 30: /* top left */
  553.                {
  554.                   spurt("R 0,-10 D 0,10 10,0 U A "); /*bl*/
  555.                   break;
  556.                }
  557.             case 31: /* top right */
  558.                {
  559.                   spurt("R 0,-10 D 0,10 -10,0 U A"); /*br*/
  560.                   break;
  561.                }
  562.          }
  563.    }
  564.  
  565. fxmin()
  566.    {
  567.    int xpos,ypos;
  568.       for (xpos=0; xpos<256; xpos++)
  569.          {
  570.             for (ypos=0; ypos<256; ypos++)
  571.                {
  572.                   if (chread(xpos,ypos,bdtop) != 0)
  573.                      {
  574.                         return(xpos);
  575.                      }
  576.                }
  577.          }
  578.       return(-1);
  579.    }
  580.  
  581. fymax()
  582.    {
  583.    int xpos,ypos;
  584.       for (ypos=255; ypos>=0; ypos--)
  585.          {
  586.             for (xpos=0; xpos<256; xpos++)
  587.                {
  588.                   if (chread(xpos,ypos,bdtop) != 0)
  589.                      {
  590.                         return(ypos);
  591.                      }
  592.                }
  593.          }
  594.       return(-1);
  595.    }
  596.  
  597. silkfn()
  598.    {
  599.    int xpos,ypos,ymax,xmin;
  600.       ymax=fymax();
  601.       xmin=fxmin();
  602.       if (xmin == -1)
  603.          {
  604.             printf("No Silkscreen data found\n");
  605.             return(0);
  606.          }
  607.       if (ymax == -1)
  608.          {
  609.             printf("No Silkscreen data found\n");
  610.             return(0);
  611.          }
  612.       spurt(";:");
  613.       if (res==1)
  614.          {
  615.             spurt("ECx "); /* 1:1 plot... (IOLINE type plotter only) */
  616.          }
  617.       else
  618.          {
  619.             spurt("EC5 "); /* 2:1 plot... */
  620.          }
  621.       spurt("V8 A 100,100 S12 SoftCircuits, Inc --- Plot of: ");
  622.       spurt(&fname[0]);
  623.       spurt(&xname[0]);
  624.       spurt("_ U");
  625.       for (xpos=0; xpos<256; xpos++)
  626.          {
  627.             for (ypos=0; ypos<256; ypos++)
  628.                {
  629.                   churfn(xpos-xmin,ypos-(255-ymax),chread(xpos,(255-ypos),bdtop));
  630.                }
  631.          }
  632.    }
  633.  
  634. plotfn()
  635.    {
  636.       spurt(";:");
  637.       if (res==1)
  638.          {
  639.             spurt("ECx "); /* 1:1 plot... */
  640.          }
  641.       else
  642.          {
  643.             spurt("EC5 "); /* 2:1 plot... */
  644.          }
  645.       spurt("V8 A 100,100 S12 SoftCircuits, Inc --- Plot of: ");
  646.       spurt(&fname[0]);
  647.       spurt(&xname[0]);
  648.       spurt("_ U");
  649.       if (shearing == 1)
  650.          {
  651.             doshear();
  652.          }
  653.       if (plotype < '3')
  654.          {
  655.             doholes();
  656.          }
  657.       if (plotype != '2')
  658.          {
  659.             dostrat();
  660.             doang();
  661.             dotease();
  662.             dofat();
  663.             dosinglefat();
  664.             dofill();
  665.             dotrimpads();
  666.          }
  667.    }
  668.  
  669. dosinglefat()
  670.    {
  671.    int xpos,ypos;
  672.       spurt("V3 ");
  673.       for (xpos=0; xpos<=255; xpos++)
  674.          {
  675.             for (ypos=0; ypos<=255; ypos++)
  676.                {
  677.                   if (bdtop[(256*ypos)+xpos] == 1)
  678.                      {
  679.                         if (fatrec[(256*ypos)+xpos] == 0)
  680.                            {
  681.                               fatrec[(256*ypos)+xpos] = 1;
  682.                               doafat(xpos,ypos);
  683.                            }
  684.                      }
  685.                }
  686.          }
  687.    }
  688.  
  689. dotease()
  690.    {
  691.    int xpos,ypos;
  692.       for (xpos=0; xpos<=255; xpos++)
  693.          {
  694.             for (ypos=0; ypos<=255; ypos++)
  695.                {
  696.                   tdraw(xpos,ypos,bdtop[(ypos*256)+xpos]);
  697.                }
  698.          }
  699.    }
  700.  
  701. tdraw(xpos,ypos,data)
  702.    int xpos,ypos,data;
  703.    {
  704.       if ( (data < 10) || (data > 13) )
  705.          {
  706.             return(0);
  707.          }
  708.       xcfac=0;
  709.       ycfac=0;
  710.       move(xpos,ypos);
  711.       if (data == 10) /* top t */
  712.          {
  713.             spurt("R D 0,-9 A U ");
  714.          }
  715.       if (data == 11) /* bot t */
  716.          {
  717.             spurt("R D 0,9 A U ");
  718.          }
  719.       if (data == 12) /* left t */
  720.          {
  721.             spurt("R D -9,0 A U ");
  722.          }
  723.       if (data == 13) /* rite t */
  724.          {
  725.             spurt("R D 9,0 A U ");
  726.          }
  727.    }
  728.  
  729. doang()
  730.    {
  731.    int xpos,ypos;
  732.       for (xpos=0; xpos<=255; xpos++)
  733.          {
  734.             for (ypos=0; ypos<=255; ypos++)
  735.                {
  736.                   angpuke(xpos,ypos,bdtop[(ypos*256)+xpos]);
  737.                }
  738.          }
  739.    }
  740.  
  741. angpuke(xpos,ypos,data)
  742.    int xpos,ypos,data;
  743.    {
  744.       if (data > 5)
  745.          {
  746.             if (data < 10)
  747.                {
  748.                   angpump(xpos,ypos,data);
  749.                   return(0);
  750.                }
  751.          }
  752.       if (data == 2) /* dual: te/bw */
  753.          {
  754.             angpump(xpos,ypos,9);
  755.             angpump(xpos,ypos,8);
  756.             return(0);
  757.          }
  758.       if (data == 3) /* dual: tw/be */
  759.          {
  760.             angpump(xpos,ypos,6);
  761.             angpump(xpos,ypos,7);
  762.             return(0);
  763.          }
  764.    }
  765.  
  766. rdrd(xpos,ypos)
  767.    int xpos,ypos;
  768.    {
  769.       if (xpos < 0) return(0);
  770.       if (ypos < 0) return(0);
  771.       if (xpos > 255) return(0);
  772.       if (ypos > 255) return(0);
  773.       return((int)bdtop[xpos+(ypos*256)]);
  774.    }
  775.  
  776. angpump(xpos,ypos,data)
  777.    int xpos,ypos,data;
  778.    {
  779.       xcfac=0;
  780.       ycfac=-10;
  781.       spurt("U ");
  782.       move(xpos,ypos);
  783.       spurt("R ");
  784.       ycfac=0;
  785.       switch(data)
  786.          {
  787.             case 6: /* NW */
  788.                {
  789.                   if (rdrd(xpos,ypos-1) == 1)
  790.                      {
  791.                         spurt("D 0,-3 0,3 ");
  792.                      }
  793.                   spurt("D -10,10 ");
  794.                   if (rdrd(xpos-1,ypos) == 1)
  795.                      {
  796.                         spurt("-3,0 ");
  797.                      }
  798.                   break;
  799.                }
  800.             case 7: /* SE */
  801.                {
  802.                   spurt("10,10 D ");
  803.                   if (rdrd(xpos+1,ypos) == 1)
  804.                      {
  805.                         spurt("3,0 -3,0 ");
  806.                      }
  807.                   spurt("-10,10 ");
  808.                   if (rdrd(xpos,ypos+1) == 1)
  809.                      {
  810.                         spurt("0,3 ");
  811.                      }
  812.                   break;
  813.                }
  814.             case 8: /* SW */
  815.                {
  816.                   spurt("-10,10 D ");
  817.                   if (rdrd(xpos-1,ypos) == 1)
  818.                      {
  819.                         spurt("-3,0 3,0 ");
  820.                      }
  821.                   spurt("10,10 ");
  822.                   if (rdrd(xpos,ypos+1) == 1)
  823.                      {
  824.                         spurt("0,3 ");
  825.                      }
  826.                   break;
  827.                }
  828.             case 9: /* NE */
  829.                {
  830.                   if (rdrd(xpos,ypos-1) == 1)
  831.                      {
  832.                         spurt("D 0,-3 0,3 ");
  833.                      }
  834.                   spurt("D 10,10 ");
  835.                   if (rdrd(xpos+1,ypos) == 1)
  836.                      {
  837.                         spurt("3,0 ");
  838.                      }
  839.                   break;
  840.                }
  841.          }
  842.       spurt("U A ");
  843.    }
  844.  
  845. dofill()
  846.    {
  847.    int xpos,ypos;
  848.       for (xpos=0; xpos<=255; xpos++)
  849.          {
  850.             for (ypos=0; ypos<=255; ypos++)
  851.                {
  852.                   fillcell(xpos,ypos);
  853.                }
  854.          }
  855.    }
  856.  
  857. fillcell(xpos,ypos)
  858.    int xpos,ypos;
  859.    {
  860.       if (rdrd(xpos,ypos) != 1)
  861.          {
  862.             trfill(xpos,ypos);
  863.             brfill(xpos,ypos);
  864.             tlfill(xpos,ypos);
  865.             blfill(xpos,ypos);
  866.             xcfac=0;
  867.             ycfac=0;
  868.          }
  869.    }
  870.  
  871. dtrfill(xpos,ypos)
  872.    int xpos,ypos;
  873.    {
  874.       xcfac=10;
  875.       ycfac=-10;
  876.       move(xpos,ypos);
  877.       spurt("D R 0,10 -10,-10, 10,0 -3,3 0,3 -3,-3 3,0 A U ");
  878.    }
  879.  
  880. dbrfill(xpos,ypos)
  881.    int xpos,ypos;
  882.    {
  883.       xcfac=10;
  884.       ycfac=10;
  885.       move(xpos,ypos);
  886.       spurt("D R 0,-10 -10,10 10,0 3,-3 0,3 -3,3 3,0 A U ");
  887.    }
  888.  
  889. dtlfill(xpos,ypos)
  890.    int xpos,ypos;
  891.    {
  892.       xcfac=-10;
  893.       ycfac=-10;
  894.       move(xpos,ypos);
  895.       spurt("D R 10,0 -10,10 0,-10 3,3 3,0 -3,3 0,-3 A U ");
  896.    }
  897.  
  898. dblfill(xpos,ypos)
  899.    int xpos,ypos;
  900.    {
  901.       xcfac=-10;
  902.       ycfac=10;
  903.       move(xpos,ypos);
  904.       spurt("D R 0,-10 10,10 -10,0 3,-3 0,-3 3,3 -3,0 A U ");
  905.    }
  906.  
  907. okck(xpos,ypos)
  908.    int xpos,ypos;
  909.    {
  910.       if (rdrd(xpos,ypos) == 1) return(1);
  911.       if (rdrd(xpos,ypos) > 14)
  912.          {
  913.             if (rdrd(xpos,ypos) != 17)
  914.                {
  915.                   return(1);
  916.                }
  917.          }
  918.       return(0);
  919.    }
  920.  
  921. trfill(xpos,ypos)
  922.    int xpos,ypos;
  923.    {
  924.       if (okck(xpos+1,ypos) == 1)
  925.          {
  926.             if (okck(xpos+1,ypos-1) == 1)
  927.                {
  928.                   if (okck(xpos,ypos-1) == 1)
  929.                      {
  930.                         dtrfill(xpos,ypos);
  931.                      }
  932.                }
  933.          }
  934.    }
  935.  
  936. brfill(xpos,ypos)
  937.    int xpos,ypos;
  938.    {
  939.       if (okck(xpos+1,ypos) == 1)
  940.          {
  941.             if (okck(xpos+1,ypos+1) == 1)
  942.                {
  943.                   if (okck(xpos,ypos+1) == 1)
  944.                      {
  945.                         dbrfill(xpos,ypos);
  946.                      }
  947.                }
  948.          }
  949.    }
  950.  
  951. tlfill(xpos,ypos)
  952.    int xpos,ypos;
  953.    {
  954.       if (okck(xpos-1,ypos) == 1)
  955.          {
  956.             if (okck(xpos-1,ypos-1) == 1)
  957.                {
  958.                   if (okck(xpos,ypos-1) == 1)
  959.                      {
  960.                         dtlfill(xpos,ypos);
  961.                      }
  962.                }
  963.          }
  964.    }
  965.  
  966. blfill(xpos,ypos)
  967.    int xpos,ypos;
  968.    {
  969.       if (okck(xpos-1,ypos) == 1)
  970.          {
  971.             if (okck(xpos-1,ypos+1) == 1)
  972.                {
  973.                   if (okck(xpos,ypos+1) == 1)
  974.                      {
  975.                         dblfill(xpos,ypos);
  976.                      }
  977.                }
  978.          }
  979.    }
  980.  
  981. dostrat()
  982.    {
  983.    int xpos,ypos;
  984.    spurt("L0 ");
  985.       ycfac=-10;
  986.       xcept1=12;
  987.       xcept2=13;
  988.       xcept3=14;
  989.       for (xpos=0; xpos<=255; xpos++)
  990.          {
  991.             drawvsh(xpos,4,1);
  992.          }
  993.       ycfac=0;
  994.       xcfac=-10;
  995.       xcept1=10;
  996.       xcept2=11;
  997.       xcept3=14;
  998.       for (ypos=0; ypos<=255; ypos++)
  999.          {
  1000.             drawhsh(ypos,5,1);
  1001.          }
  1002.       xcfac=0;
  1003.       xcept1=99;
  1004.       xcept2=99;
  1005.       xcept3=99;
  1006.    }
  1007.  
  1008. doshear()
  1009.    {
  1010.    int xpos,ypos;
  1011.       spurt("L7 ");
  1012.       ycfac=-10;
  1013.       for (xpos=0; xpos<=255; xpos++)
  1014.          {
  1015.             drawvsh(xpos,17,0);
  1016.          }
  1017.       ycfac=0;
  1018.       xcfac=-10;
  1019.       for (ypos=0; ypos<=255; ypos++)
  1020.          {
  1021.             drawhsh(ypos,17,0);
  1022.          }
  1023.       xcfac=0;
  1024.       spurt("L0 ");
  1025.    }
  1026.  
  1027. drawhsh(stroke,type,resval)
  1028.    int stroke,type,resval;
  1029.    {
  1030.    int now,later,online,count;
  1031.       now=0;
  1032.       count=resval;
  1033.       later=0;
  1034.       online=0;
  1035. hsh1:
  1036.       if ((bdtop[(stroke*256)+now] == type)
  1037.            ||
  1038.           (bdtop[(stroke*256)+now] == xcept1)
  1039.            ||
  1040.           (bdtop[(stroke*256)+now] == xcept2)
  1041.            ||
  1042.           (bdtop[(stroke*256)+now] == xcept3)  )
  1043.          {
  1044.             if (online != 1)
  1045.                {
  1046.                   count=resval;
  1047.                   online=1;
  1048.                   later=now;
  1049.                }
  1050.             else
  1051.                {
  1052.                   count++;
  1053.                }
  1054.          }
  1055.       else
  1056.          {
  1057.             if (online == 1)
  1058.                {
  1059.                   if (count != 0)
  1060.                      {
  1061.                         spurt("U ");
  1062.                         move(later,stroke);
  1063.                         spurt("D ");
  1064.                         move(now,stroke);
  1065.                      }
  1066.                   online=0;
  1067.                }
  1068.             count=resval;
  1069.          }
  1070.       if (++now < 256) goto hsh1;
  1071.    }
  1072.  
  1073. drawvsh(stroke,type,resval)
  1074.    int stroke,type,resval;
  1075.    {
  1076.    int now,later,online,count;
  1077.       now=0;
  1078.       count=resval;
  1079.       later=0;
  1080.       online=0;
  1081. vsh1:
  1082.       if ((bdtop[(now*256)+stroke] == type)
  1083.            ||
  1084.           (bdtop[(now*256)+stroke] == xcept1)
  1085.            ||
  1086.           (bdtop[(now*256)+stroke] == xcept2)
  1087.            ||
  1088.           (bdtop[(now*256)+stroke] == xcept3)  )
  1089.          {
  1090.             if (online != 1)
  1091.                {
  1092.                   count=resval;
  1093.                   online=1;
  1094.                   later=now;
  1095.                }
  1096.             else
  1097.                {
  1098.                   count++;
  1099.                }
  1100.          }
  1101.       else
  1102.          {
  1103.             if (online == 1)
  1104.                {
  1105.                   if (count != 0)
  1106.                      {
  1107.                         spurt("U ");
  1108.                         move(stroke,later);
  1109.                         spurt("D ");
  1110.                         move(stroke,now);
  1111.                      }
  1112.                   online=0;
  1113.                }
  1114.             count=resval;
  1115.          }
  1116.       if (++now < 256) goto vsh1;
  1117.    }
  1118.  
  1119. dotrimpads()
  1120.    {
  1121.    int xpos,ypos;
  1122.       for (xpos=0; xpos<=255; xpos++)
  1123.          {
  1124.             for (ypos=0; ypos<=255; ypos++)
  1125.                {
  1126.                   exfortrim(xpos,ypos);
  1127.                }
  1128.          }
  1129.    }
  1130.  
  1131. exfortrim(xpos,ypos)
  1132.    int xpos,ypos;
  1133.    {
  1134.       switch(bdtop[(ypos*256)+xpos])
  1135.          {
  1136.             case 15:
  1137.             case 16:
  1138.             case 19:
  1139.                {
  1140.                   if (xpos > 0) /* look to the left for fatcell */
  1141.                      {
  1142.                         if (bdtop[(ypos*256)+(xpos-1)]==1)
  1143.                            {
  1144.                               move(xpos,ypos);
  1145.                               spurt("R -5,-5 D -5,-5 U A ");
  1146.                               move(xpos,ypos);
  1147.                               spurt("R -5,5 D -5,5 U A ");
  1148.                            }
  1149.                      }
  1150.                   if (xpos < 255) /* look to the right for a fatcell */
  1151.                      {
  1152.                         if (bdtop[(ypos*256)+(xpos+1)]==1)
  1153.                            {
  1154.                               move(xpos,ypos);
  1155.                               spurt("R 5,-5 D 5,-5 U A ");
  1156.                               move(xpos,ypos);
  1157.                               spurt("R 5,5 D 5,5 U A ");
  1158.                            }
  1159.                      }
  1160.                   if (ypos > 0) /* look to the top for a fatcell */
  1161.                      {
  1162.                         if (bdtop[((ypos-1)*256)+xpos]==1)
  1163.                            {
  1164.                               move(xpos,ypos);
  1165.                               spurt("R -5,-5 D -5,-5 U A ");
  1166.                               move(xpos,ypos);
  1167.                               spurt("R 5,-5 D 5,-5 U A ");
  1168.                            }
  1169.                      }
  1170.                   if (ypos < 255) /* look to the bottom for a fatcell */
  1171.                      {
  1172.                         if (bdtop[((ypos+1)*256)+xpos]==1)
  1173.                            {
  1174.                               move(xpos,ypos);
  1175.                               spurt("R -5,5 D -5,5 U A ");
  1176.                               move(xpos,ypos);
  1177.                               spurt("R 5,5 D 5,5 U A ");
  1178.                            }
  1179.                      }
  1180.                }
  1181.          }
  1182.    }
  1183.  
  1184. doholes()
  1185.    {
  1186.    int xpos,ypos;
  1187.       for (xpos=0; xpos<=255; xpos=xpos+2)
  1188.          {
  1189.             for (ypos=0; ypos<=255; ypos++)
  1190.                {
  1191.                   if (bdtop[(ypos*256)+xpos] > 14)
  1192.                      {
  1193.                         drawhole(xpos,ypos,bdtop[(256*ypos)+xpos]);
  1194.                      }
  1195.                }
  1196.             for (ypos=255; ypos>=0; ypos--)
  1197.                {
  1198.                   if (bdtop[(ypos*256)+xpos+1] > 14)
  1199.                      {
  1200.                         drawhole(xpos+1,ypos,bdtop[(256*ypos)+xpos+1]);
  1201.                      }
  1202.                }
  1203.          }
  1204.    }
  1205.  
  1206. drawhole(xpos,ypos,data)
  1207.    int xpos,ypos,data;
  1208.    {
  1209.       if (camrdy == '1')
  1210.          {
  1211.             drawhcam(xpos,ypos,data);
  1212.          }
  1213.       else
  1214.          {
  1215.             drawhchk(xpos,ypos,data);
  1216.          }
  1217.    }
  1218.  
  1219. /* camera-ready vias */
  1220. dnvhole(xpos,ypos)
  1221.    int xpos,ypos;
  1222.    {
  1223.       spurt("CC ");
  1224.       xmove(xpos,ypos);
  1225.       spurt(",9 ");
  1226.       spurt("CC ");
  1227.       xmove(xpos,ypos);
  1228.       spurt(",6 ");
  1229.    }
  1230.  
  1231. /* camera-ready pads */
  1232. dnhole(xpos,ypos)
  1233.    int xpos,ypos;
  1234.    {
  1235.       spurt("CC ");
  1236.       xmove(xpos,ypos);
  1237.       spurt(",10 ");
  1238.       spurt("CC ");
  1239.       xmove(xpos,ypos);
  1240.       spurt(",6 ");
  1241.    }
  1242.  
  1243. /* camera-ready pin-ones */
  1244. dnonehole(xpos,ypos)
  1245.    int xpos,ypos;
  1246.    {
  1247.       spurt("CC ");
  1248.       xmove(xpos,ypos);
  1249.       spurt(",10 ");
  1250.       spurt("CC ");
  1251.       xmove(xpos,ypos);
  1252.       spurt(",6 ");
  1253.    }
  1254.  
  1255. drawhcam(xpos,ypos,data)
  1256.    int xpos,ypos,data;
  1257.    {
  1258.        if (data == 15) /* normal pad */
  1259.          {
  1260.             dnhole(xpos,ypos);
  1261.          }
  1262.       if (data == 16) /* feedthru */
  1263.          {
  1264.             dnvhole(xpos,ypos);
  1265.          }
  1266.       if (data == 18) /* drill hole marker */
  1267.          {
  1268.             spurt("CC ");
  1269.             xmove(xpos,ypos);
  1270.             spurt(",3 ");
  1271.             spurt("R D -10,-10 20,20 U -20,0 D 20,-20 U A ");
  1272.          }
  1273.       if (data == 19) /* pin one */
  1274.          {
  1275.             dnonehole(xpos,ypos);
  1276.          }
  1277.    }
  1278.  
  1279. drawhchk(xpos,ypos,data)
  1280.    int xpos,ypos,data;
  1281.    {
  1282.        if (data == 15) /* normal pad */
  1283.          {
  1284.             spurt("CC ");
  1285.             xmove(xpos,ypos);
  1286.             spurt(",10 ");
  1287.          }
  1288.       if (data == 16) /* feedthru */
  1289.          {
  1290.             spurt("CC ");
  1291.             xmove(xpos,ypos);
  1292.             spurt(",10 ");
  1293.          }
  1294.       if (data == 18) /* drill hole marker */
  1295.          {
  1296.             spurt("CC ");
  1297.             xmove(xpos,ypos);
  1298.             spurt(",3 ");
  1299.             spurt("R D -10,-10 20,20 U -20,0 D 20,-20 U A ");
  1300.          }
  1301.       if (data == 19) /* pin one */
  1302.          {
  1303.             spurt("CC ");
  1304.             xmove(xpos,ypos);
  1305.             spurt(",10 ");
  1306.             spurt("CC ");
  1307.             xmove(xpos,ypos);
  1308.             spurt(",5 ");
  1309.  
  1310. /*            move(xpos,ypos);
  1311.             spurt("R -10,-10 D 20,0 0,20 -20,0 0,-20 U A ");*/
  1312.          }
  1313.    }
  1314.  
  1315. nfy()
  1316.    {
  1317.    int i;
  1318.       for (i=0; i<125000; i++);
  1319.    }
  1320.  
  1321. nfx()
  1322.    {
  1323.    int i;
  1324.       for (i=0; i<64000; i++);
  1325.    }
  1326.  
  1327. scale(value,cfac)
  1328.    int value,cfac;
  1329.    {
  1330.       value=(20*value)+300+cfac;
  1331.       return(value);
  1332.    }
  1333.  
  1334. move(xpos,ypos) /* send "x,y " */
  1335.    int xpos,ypos;
  1336.    {
  1337.       xmove(xpos,ypos);
  1338.       spurt(" ");
  1339.    }
  1340.  
  1341. xmove(xpos,ypos) /* send "x,y" */
  1342.    int xpos,ypos;
  1343.    {
  1344.    UBYTE xtxt[20],ytxt[20];
  1345.       stci_d(&xtxt[0],scale(xpos,xcfac),19);
  1346.       stci_d(&ytxt[0],scale(ypos,ycfac),19);
  1347.       spurt(&xtxt[0]);
  1348.       spurt(",");
  1349.       spurt(&ytxt[0]);
  1350.    }
  1351.  
  1352. spurt(ptr)
  1353.    UBYTE *ptr;
  1354.    {
  1355.       if (tofile==0)
  1356.          {
  1357.             WriteSer(IORser,ptr,-1);
  1358.          }
  1359.       else
  1360.          {
  1361.             sendfile(ptr);
  1362.          }
  1363.    }
  1364.  
  1365. sendfile(ptr)
  1366.    UBYTE *ptr;
  1367.    {
  1368.    UBYTE plotcell;
  1369. notdone:
  1370.       plotcell=*ptr++;
  1371.       if (plotcell==0)
  1372.          {
  1373.             return(0);
  1374.          }
  1375.       if (fwrite(&plotcell,1,1,outfp) != 1)
  1376.          {
  1377.             fclose(outfp);
  1378.             printf("Write to plotter output file failed!\n");
  1379.             exit(20);
  1380.          }
  1381.       goto notdone;
  1382.    }
  1383.  
  1384. WriteSer(io,data,length)
  1385.    struct IOExtSer *io;
  1386.    char *data;
  1387.    int length;
  1388.    {
  1389.    int error;
  1390.       io->IOSer.io_Data=(APTR*)data;
  1391.       io->IOSer.io_Length=length;
  1392.       io->IOSer.io_Command=CMD_WRITE;
  1393.       if ((error=DoIO(io)) != 0)
  1394.          {
  1395.             printf("serial device write error %ld\n",error);
  1396.          }
  1397.       return(error);
  1398.    }
  1399.  
  1400. SetParams(io,rbuf_len,rlen,wlen,brk,baud,sf,ta0,ta1)
  1401.    struct IOExtSer *io;
  1402.    unsigned long rbuf_len,brk,baud,ta0,ta1;
  1403.    unsigned char rlen,wlen,sf;
  1404.    {
  1405.    int error;
  1406.       io->io_CtlChar              = 0x11130000;
  1407.       io->io_ReadLen              = rlen;
  1408.       io->io_BrkTime              = brk;
  1409.       io->io_Baud                 = baud;
  1410.       io->io_WriteLen             = wlen;
  1411.       io->io_StopBits             = 0x01;
  1412.       io->io_RBufLen              = rbuf_len;
  1413.       io->io_SerFlags             = sf;
  1414.       io->IOSer.io_Command        = SDCMD_SETPARAMS;
  1415.       io->io_TermArray.TermArray0 = ta0;
  1416.       io->io_TermArray.TermArray1 = ta1;
  1417.  
  1418.       if ((error=DoIO(io)) != 0)
  1419.          {
  1420.             printf("serial device SetParams error %ld \n",error);
  1421.          }
  1422.       return(error);
  1423.    }
  1424.  
  1425.  
  1426. /*
  1427.  * board  load
  1428.  */
  1429.  
  1430. loadbd()
  1431.    {
  1432.    FILE *fp;
  1433.  
  1434.       strcpy(&tname[0],"boardlib/");
  1435.       strcat(&tname[0],&fname[0]);
  1436.       strcat(&tname[0],&xname[0]);
  1437.  
  1438.       if (fp = fopen(&tname[0],"r"))
  1439.          {
  1440.             printf("Please wait -- loading '%s'\n",&tname[0]);
  1441.             if (plotype != '5')
  1442.                {
  1443.                   fread(&rdmuse,4,1,fp);                  /* get file encryptor */
  1444.                   if (fread(bdtop,65536,1,fp) != 1)
  1445.                      {
  1446.                         printf("file error - entire file not loaded\n");
  1447.                         return(0);
  1448.                      }
  1449.                }
  1450.             else
  1451.                {
  1452.                   if (fread(bdtop,4,1,fp) != 1)
  1453.                      {
  1454.                         printf("file error - entire file not loaded\n");
  1455.                         return(0);
  1456.                      }
  1457.                   if (fread(bdtop,49152,1,fp) != 1)
  1458.                      {
  1459.                         printf("file error - entire file not loaded\n");
  1460.                         return(0);
  1461.                      }
  1462.                }
  1463.             fclose(fp);
  1464.             if (plotype != '5')
  1465.                {
  1466.                   encode(rdmuse,bdtop);
  1467.                }
  1468.             return(1);
  1469.          }
  1470.       else
  1471.          {
  1472.             printf("'%s' file not found\n",&tname[0]);
  1473.             return(0);
  1474.          }
  1475.    }
  1476.  
  1477.  
  1478.  
  1479. permute()
  1480.    {
  1481.       random=random+random+random+random+random;
  1482.    }
  1483.  
  1484. remute()
  1485.    {
  1486.    int tmp,indux;
  1487.       tmp=((random >> 8) & 0xFF)+157;
  1488.       for (indux=0; indux<tmp; indux++)
  1489.          {
  1490.             permute();
  1491.          }
  1492.       rdmuse=random;
  1493.    }
  1494.  
  1495. dofat()
  1496.    {
  1497.    int xpos,ypos;
  1498.       spurt("L0 ");
  1499.       for (xpos=0; xpos<=255; xpos++)
  1500.          {
  1501.             drawvfat(xpos,1,0);
  1502.          }
  1503.       for (ypos=0; ypos<=255; ypos++)
  1504.          {
  1505.             drawhfat(ypos,1,0);
  1506.          }
  1507.    }
  1508.  
  1509. drawhfat(stroke,type,resval)
  1510.    int stroke,type,resval;
  1511.    {
  1512.    int asub,aadd,now,later,online,count;
  1513.       now=0;
  1514.       count=resval;
  1515.       later=0;
  1516.       online=0;
  1517. hfat1:
  1518.       if ((bdtop[(stroke*256)+now] == type))
  1519.          {
  1520.             if (online != 1)
  1521.                {
  1522.                   count=resval;
  1523.                   online=1;
  1524.                   later=now;
  1525.                }
  1526.             else
  1527.                {
  1528.                   count++;
  1529.                }
  1530.          }
  1531.       else
  1532.          {
  1533.             if (online == 1)
  1534.                {
  1535.                   if (count > 2)
  1536.                      {
  1537.                         asub=2;
  1538.                         aadd=1;
  1539.                         if (bdread(now,stroke) > 14)      asub=1;
  1540.                         if (bdread(later-1,stroke) > 14)  aadd=0;
  1541.                         hstreamfat(stroke,now-asub,later+aadd);
  1542.                      }
  1543.                   online=0;
  1544.                }
  1545.             count=resval;
  1546.          }
  1547.       if (++now < 256) goto hfat1;
  1548.    }
  1549.  
  1550. drawvfat(stroke,type,resval)
  1551.    int stroke,type,resval;
  1552.    {
  1553.    int asub,aadd,now,later,online,count;
  1554.       now=0;
  1555.       count=resval;
  1556.       later=0;
  1557.       online=0;
  1558. vfat1:
  1559.       if ((bdtop[(now*256)+stroke] == type))
  1560.          {
  1561.             if (online != 1)
  1562.                {
  1563.                   count=resval;
  1564.                   online=1;
  1565.                   later=now;
  1566.                }
  1567.             else
  1568.                {
  1569.                   count++;
  1570.                }
  1571.          }
  1572.       else
  1573.          {
  1574.             if (online == 1)
  1575.                {
  1576.                   if (count > 2)
  1577.                      {
  1578.                         asub=2;
  1579.                         aadd=1;
  1580.                         if (bdread(stroke,now) > 14)       asub=1;
  1581.                         if (bdread(stroke,later-1) > 14)   aadd=0;
  1582.                         vstreamfat(stroke,now-asub,later+aadd);
  1583.                      }
  1584.                   online=0;
  1585.                }
  1586.             count=resval;
  1587.          }
  1588.       if (++now < 256) goto vfat1;
  1589.    }
  1590.  
  1591. bdread(xpos,ypos)
  1592.    int xpos,ypos;
  1593.    {
  1594.    int data;
  1595.       data=(UBYTE)bdtop[xpos+(ypos*256)];
  1596.       return(data);
  1597.    }
  1598.  
  1599. vstreamfat(xpos,ypostart,yposend)
  1600.    int xpos,ypostart,yposend;
  1601.    {
  1602.    int j;
  1603.    UBYTE yvector[20],xvector[20];
  1604.       for (j=yposend; j<=ypostart; j++)
  1605.          {
  1606.             fatrec[xpos+(j*256)]=1;
  1607.          }
  1608.       xcfac=-10;
  1609.       ycfac=-10;
  1610.       move(xpos,yposend);
  1611.       spurt("R ");
  1612.       stci_d(&yvector[0],((ypostart-yposend)*20)+23,18);
  1613.       stci_d(&xvector[0],0,18);
  1614.          for (j=0; j<6; j++)
  1615.             {
  1616.                spurt("D 0,");
  1617.                spurt(&yvector[0]);
  1618.                spurt(" U 4,-");
  1619.                spurt(&yvector[0]);
  1620.                spurt(" ");
  1621.             }
  1622.       spurt("A ");
  1623.       xcfac=0;
  1624.       ycfac=0;
  1625.    }
  1626.  
  1627. doafat(xpos,ypos)
  1628.    int xpos,ypos;
  1629.    {
  1630.       int i;
  1631.       ycfac=-10;    /*(10)*/
  1632.       xcfac=0;
  1633.       move(xpos,ypos);
  1634.       spurt("R D");
  1635. /* draw central diamond: */
  1636.       spurt("10,10 ");
  1637.       spurt("-10,10 ");
  1638.       spurt("-10,-10 ");
  1639.       spurt("10,-10 ");
  1640.       spurt("0,5 ");
  1641.       spurt("5,5 ");
  1642.       spurt("-5,5 ");
  1643.       spurt("-5,-5 ");
  1644.       spurt("5,-5 ");
  1645.       spurt("0,6 U ");
  1646.  
  1647. /* draw up to four sets of corners: */
  1648.       for (i=0; i<4; i++)
  1649.          {
  1650.             fillmem[i]=0;
  1651.          }
  1652.       xcfac=-10;
  1653.       if (  (bdread(xpos+1,ypos) == 1)
  1654.          || (bdread(xpos+1,ypos) >= 15)  )
  1655.          {
  1656.             filltr(xpos,ypos);
  1657.             fillbr(xpos,ypos);
  1658.          }
  1659.       if (  (bdread(xpos-1,ypos) == 1)
  1660.          || (bdread(xpos-1,ypos) >= 15)  )
  1661.          {
  1662.             filltl(xpos,ypos);
  1663.             fillbl(xpos,ypos);
  1664.          }
  1665.       if (  (bdread(xpos,ypos+1) == 1)
  1666.          || (bdread(xpos,ypos+1) >= 15)  )
  1667.          {
  1668.             fillbl(xpos,ypos);
  1669.             fillbr(xpos,ypos);
  1670.          }
  1671.       if (  (bdread(xpos,ypos-1) == 1)
  1672.          || (bdread(xpos,ypos-1) >= 15)  )
  1673.          {
  1674.             filltl(xpos,ypos);
  1675.             filltr(xpos,ypos);
  1676.          }
  1677. /* terminate fatcell draw mode */
  1678.       spurt("U A ");
  1679.       xcfac=0;
  1680.       ycfac=0;
  1681.    }
  1682.  
  1683. filltl(xpos,ypos)
  1684.    int xpos,ypos;
  1685.    {
  1686.       if (fillmem[0] != 0) return(0);
  1687.       spurt("A U");
  1688.       move(xpos,ypos);
  1689.       spurt("R ");
  1690.       spurt("D ");
  1691.       spurt("7,0 -7,7 0,-7 4,4 "); /*(7)*/
  1692.       spurt("4,0 -4,4 0,-4 ");
  1693.       fillmem[0]=1;
  1694.    }
  1695.  
  1696. filltr(xpos,ypos)
  1697.    int xpos,ypos;
  1698.    {
  1699.       if (fillmem[1] != 0) return(0);
  1700.       spurt("A U ");
  1701.       move(xpos,ypos);
  1702.       spurt("R 13,0 "); /*(8)*/
  1703.       spurt("D ");
  1704.       spurt("7,0 0,7 -7,-7 4,4 "); /*(3,4)*/
  1705.       spurt("0,4 -4,-4 4,0 ");
  1706.  
  1707.       fillmem[1]=1;
  1708.    }
  1709.  
  1710. fillbr(xpos,ypos)
  1711.    int xpos,ypos;
  1712.    {
  1713.       if (fillmem[2] != 0) return(0);
  1714.       spurt("A U ");
  1715.       move(xpos,ypos);
  1716.       spurt("R 20,20 ");/*(15,15)*/
  1717.       spurt("D ");
  1718.       spurt("0,-7 -7,7 7,0 -4,-4 ");
  1719.       spurt("0,-4  -4,4 4,0 ");
  1720.       fillmem[2]=1;
  1721.    }
  1722.  
  1723. fillbl(xpos,ypos)
  1724.    int xpos,ypos;
  1725.    {
  1726.       if (fillmem[3] != 0) return(0);
  1727.       spurt("A U ");
  1728.       move(xpos,ypos);
  1729.       spurt("R 0,20 ");/*(15)*/
  1730.       spurt("D ");
  1731.       spurt("7,0 -7,-7 0,7 4,-4 ");
  1732.       spurt("4,0 -4,-4 0,4 ");
  1733.       fillmem[3]=1;
  1734.    }
  1735.  
  1736.  
  1737.  
  1738. hstreamfat(ypos,xpostart,xposend)
  1739.    int ypos,xpostart,xposend;
  1740.    {
  1741.    int j;
  1742.    UBYTE yvector[20],xvector[20];
  1743.       for (j=xposend; j<=xpostart; j++)
  1744.          {
  1745.             fatrec[j+(ypos*256)]=1;
  1746.          }
  1747.       xcfac=-10;
  1748.       ycfac=-10;
  1749.       move(xposend,ypos);
  1750.       spurt("R ");
  1751.       stci_d(&xvector[0],((xpostart-xposend)*20)+23,18);
  1752.       stci_d(&yvector[0],0,18);
  1753.          for (j=0; j<6; j++)
  1754.             {
  1755.                spurt("D ");
  1756.                spurt(&xvector[0]);
  1757.                spurt(",0 U -");
  1758.                spurt(&xvector[0]);
  1759.                spurt(",4 ");
  1760.             }
  1761.       spurt("A ");
  1762.       xcfac=0;
  1763.       ycfac=0;
  1764.    }
  1765.  
  1766.