home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / MISC / NERVES.ZIP / NO87 / DATAMOD.C next >
Encoding:
C/C++ Source or Header  |  1990-12-27  |  16.7 KB  |  805 lines

  1. #include "defn.h"
  2. #include "nsdata.c"
  3. #include "proto.h"
  4.  
  5. void datamod(void) /* allows user to modify/add/delete neuron data */
  6.  {
  7.   enum asc_val asc;
  8.   enum ext_val ext;
  9.   char str[41];
  10.   char *p;
  11.   int newneur;
  12.   FILE *file;
  13.   int i,j,done,line,cc,newcon;
  14.   struct neuron *np,tn;
  15.   struct con *cp,*tc,*cq,*cs;
  16.   struct Iint ti;
  17.   double d;
  18.  
  19.   /* modify data */
  20. start:
  21.   clrscr();
  22.   textattr(BLUE + (LIGHTGRAY<<4));
  23.   gotoxy(1,24);
  24.   cputs(" ^S-Save file   Esc-Main menu                                                   ");
  25.   textattr(LIGHTGRAY);
  26. getname:
  27.   clrline(1);
  28.   gotoxy(1,1);
  29.   cputs("Neuron name: ");
  30.   i = 0;
  31.   while (!i)
  32.    i = bioskey(1);
  33.   asc = i & 0xff;
  34.   if (asc == ESC)
  35.    { /* return to main menu without saving */
  36.     bioskey(0);
  37.     return; /* go to main menu */
  38.    }
  39.   else
  40.    if (asc == CTRLS)
  41.     { /* save file */
  42.      bioskey(0);
  43.      /* count neurons */
  44.      for (i=0, j=0, np=ns; i<nn; i++, np++)
  45.       if (np->name[0])
  46.        j++;
  47.      clrscr();
  48.      if (neurfname[0])
  49.       {
  50.        cprintf("Save to %s? ",neurfname);
  51.        i = toupper(bioskey(0) & 0xff);
  52.       }
  53.      if (!neurfname[0] || i != 'Y')
  54.       {
  55.        gotoxy(1,1);
  56.        cputs("Enter file spec:                                      ");
  57.        gotoxy(18,1);
  58.        str[0] = 38;
  59.        p = cgets(str);
  60.        strcpy(neurfname,p);
  61.       }
  62.      file = fopen(neurfname,"wb");
  63.      fwrite(&j,2,1,file);
  64.      for (i=0, np=ns; i<nn; i++, np++)
  65.       if (np->name[0])
  66.        {
  67.     fwrite(np,27,1,file);
  68.     if (np->Iint)
  69.      j = (int)np->Iint - (int)Iinta + 1;
  70.     else
  71.      j = 0;
  72.     fwrite(&j,2,1,file);
  73.     fwrite(&(np->Isens),18,1,file);
  74.     if (np->con)
  75.      j = (int)np->con - (int)cona + 1;
  76.     else
  77.      j = 0;
  78.     fwrite(&j,2,1,file);
  79.        }
  80.      fwrite(&ni,2,1,file);
  81.      for (i=0; i<ni; i++)
  82.       fwrite(Iinta+i,19,1,file);
  83.      fwrite(&nc,2,1,file);
  84.      for (i=0, cp=cona; i<nc; i++, cp++)
  85.       {
  86.        fwrite(cp,sizeof(struct con)-6,1,file);
  87.        if (cp->next)
  88.     j = (int)cp->next - (int)cona + 1;
  89.        else
  90.     j = 0;
  91.        fwrite(&j,2,1,file);
  92.       }
  93.      fclose(file);
  94.      return; /* go to main menu */
  95.     }
  96.   else
  97.    { /* neuron name input */
  98.     str[0] = 7;
  99.     p = cgets(str);
  100.     if ((*p == '?' || *p == '/') && *(p+1) == 0)
  101.      { /* list neuron names */
  102.       for (np=ns, i=0, j=0; i<nn && j<10; j++)
  103.        for (line=3; line<24 && i<nn; line++, i++, np++)
  104.     {
  105.      gotoxy(1+j*8,line);
  106.      while (!np->name[0] && i<nn)
  107.       {
  108.        np++;
  109.        i++;
  110.       }
  111.      if (i<nn)
  112.       cprintf("%s",np->name);
  113.     }
  114.       goto getname;
  115.      }
  116.     else
  117.      if (!*p)
  118.       goto getname;
  119.      else
  120.       {
  121.        for (np=ns, i=0; i<nn; i++, np++)
  122.     if (!strncmp(p,np->name,6))
  123.      break;
  124.        if (i == nn)
  125.     {
  126.      gotoxy(1,2);
  127.      cputs("Neuron not found; create new neuron? ");
  128.      if (toupper(bioskey(0) & 0xff) != 'Y')
  129.       goto getname;
  130.      newneur = TRUE;
  131.      nn++;
  132.     }
  133.        else
  134.     newneur = FALSE;
  135.       }
  136.     /* save neuron's data in temporary storage */
  137.     tn = *np;
  138.     if (newneur)
  139.      strcpy(tn.name,p);
  140.     if (np->Iint)
  141.      ti = *(np->Iint);
  142.     else
  143.      ti = *(Iinta + ni);
  144.     for (cp=np->con, tc=cona+nc, cc=0; cp!=NULL; cp=cp->next, cc++, tc++)
  145.      *tc = *cp;
  146.     tc = cona+nc;
  147.  
  148.     ndisp(tn,ti,3); /* display neuron's parameters */
  149.  
  150.     /* modify parameters */
  151.     line = 3;
  152.     done = FALSE;
  153.     while(!done)
  154.      {
  155.       i = 0;
  156.       while(!i)
  157.        i = bioskey(1);
  158.       asc = i & 0xff;
  159.       if (asc)
  160.        {
  161.     if (asc < 32)
  162.      {
  163.       bioskey(0);
  164.       switch(asc)
  165.        {
  166.         case CTRLD: /* delete neuron */
  167.          if (!strcmp(tn.name,np->name)) /* if existing neuron, delete */
  168.           np->name[0] = 0;
  169.          if (newneur)
  170.           nn--;
  171.          goto start;
  172.         case CTRLS: /* save neuron */
  173.  
  174.              /* convert to integer values */
  175.          tn.iGmem = tn.Gmem * 1e8 + .5;
  176.          tn.iCmem = tn.Cmem * 1e11 + .5;
  177.          tn.iVt = tn.Vt * 1e6 + fsgn(tn.Vt)*.5;
  178.          tn.iFmin = tn.Fmin * 10000 + .5;
  179.          tn.iGain = tn.Gain * 1e-2 + .5;
  180.          tn.ipI[0] = tn.pI[0] * 1e13 + fsgn(tn.pI[0])*.5;
  181.          tn.ipI[1] = tn.pI[1] * 1e13 + fsgn(tn.pI[1])*.5;
  182.          tn.imconst = tn.mconst * 1e1 + fsgn(tn.mconst)*.5;
  183.          ti.iIL = ti.IL * 1e11 + fsgn(ti.IL)*.5;
  184.          if (ti.type == 0)
  185.           ti.ipL[0] = ti.pL[0] * 1e6 + fsgn(ti.pL[0])*.5;
  186.          else
  187.           ti.ipL[0] = ti.pL[0] * 1e3 + .5;
  188.          ti.ipL[1] = ti.pL[1] * 1e3 + .5;
  189.          ti.ipL[2] = ti.pL[2] * 1e2 + .5;
  190.          ti.iIH = ti.IH * 1e11 + fsgn(ti.IH)*.5;
  191.          ti.ipH[0] = ti.pH[0] * 1e3 + .5;
  192.          ti.ipH[1] = ti.pH[1] * 1e3 + .5;
  193.          for (cq=tc, j=0; j<cc; cq++, j++)
  194.           {
  195.            cq->iIsr = cq->Isr * 1e10 + fsgn(cq->Isr)*.5;
  196.            cq->iIcr = cq->Icr * 1e10 + fsgn(cq->Icr)*.5;
  197.           }
  198.  
  199.          if (!newneur && strcmp(np->name,tn.name))
  200.           { /* copied neuron */
  201.            if (tn.Iint)
  202.         tn.Iint = Iinta+ni;
  203.            np = ns + nn;
  204.            np->Iint = 0;
  205.            np->con = 0;
  206.            nn++;
  207.           }
  208.          if (!np->con)
  209.           newcon = TRUE;
  210.          else
  211.           newcon = FALSE;
  212.          if (!np->Iint && tn.Iint)
  213.           ni++;
  214.          *(np) = tn;
  215.          if (tn.Iint)
  216.           *tn.Iint = ti;
  217.          j = 0;
  218.          cq = tc;
  219.          if (!newcon)
  220.           for (cp=np->con; cp!=NULL && j<cc; cp=cs, cq++, j++)
  221.            {
  222.         cs = cp->next;
  223.         *cp = *cq;
  224.         if (j == cc-1)
  225.          cp->next = NULL;
  226.         else
  227.          if (cs == NULL && j < cc-1)
  228.           cp->next = cona + nc;
  229.          else
  230.           cp->next = cs;
  231.            }
  232.              if (cp == NULL)
  233.           {
  234.            if (j != cc)
  235.         {
  236.          for (cp=cona+nc, i=0; j<cc; cp++, j++, cq++, i++)
  237.           {
  238.            if (!newcon)
  239.             *cp = *cq;
  240.            cp->next = cp + 1;
  241.           }
  242.          (cp-1)->next = NULL;
  243.          if (newcon)
  244.           np->con = cona + nc;
  245.          nc += i;
  246.         }
  247.           }
  248.          goto start;
  249.         case CR:
  250.          switch (line)
  251.           {
  252.            case 8: /* Intrinsic current type */
  253.         if (!tn.Iint)
  254.          {
  255.           tn.Iint = Iinta + ni;
  256.           ti.type = 0;
  257.          }
  258.         else
  259.          if (ti.type == 0)
  260.           ti.type = 1;
  261.          else
  262.           tn.Iint = NULL;
  263.         ndisp(tn,ti,line);
  264.                 break;
  265.            case 16: /* Sensory current function */
  266.         tn.Isens++;
  267.         if (tn.Isens > 6)
  268.          tn.Isens = 0;
  269.         ndisp(tn,ti,line);
  270.         break;
  271.            case 19: /* motor output type */
  272.         tn.mtype++;
  273.         if (tn.mtype > 2)
  274.          tn.mtype = 0;
  275.         ndisp(tn,ti,line);
  276.         break;
  277.            case 20: /* motor output sub type */
  278.         if (tn.mtype == 1)
  279.          {
  280.           tn.mname++;
  281.           if (tn.mname > 2)
  282.            tn.mname = 0;
  283.          }
  284.         else
  285.          if (tn.mtype == 2)
  286.           tn.mname = !tn.mname;
  287.          else
  288.           break;
  289.         ndisp(tn,ti,line);
  290.         break;
  291.            case 22: /* Switch to connections page */
  292.         conmod(tn.name,tc,&cc);
  293.         ndisp(tn,ti,3);
  294.         line = 3;
  295.         break;
  296.            default:
  297.         if (line < 22)
  298.          line++;
  299.         else
  300.          line = 1;
  301.         gotoxy(40,line);
  302.         break;
  303.           }
  304.          break;
  305.         case ESC:
  306.          if (newneur)
  307.           nn--;
  308.          goto start;
  309.         default:
  310.          break;
  311.        }
  312.      }
  313.     else
  314.      { /* process input */
  315.       if (line <= 7 ||
  316.          (tn.Iint && line >= 9 && line <= 15 &&
  317.           !(line == 12 && ti.type == 1)) ||
  318.          (tn.Isens && (line == 17) || (tn.Isens == OS && line == 18)) ||
  319.          (tn.mtype && (line == 21)))
  320.        { /* get numerical input */
  321.         gotoxy(40,line);
  322.         cputs("                   ");
  323.         gotoxy(40,line);
  324.         if (line == 1)
  325.          str[0] = 7;
  326.         else
  327.          str[0] = 15;
  328.         p = cgets(str);
  329.         if (line == 1)
  330.          {
  331.           strcpy(tn.name,p);
  332.           line = 3;
  333.           gotoxy(40,3);
  334.          }
  335.         else
  336.          {
  337.           d = atof(p);
  338.           gotoxy(40,line);
  339.           if (line == 18 || line == 17)
  340.            cprintf("%.4f",d);
  341.           else
  342.            cprintf("%.2f",d);
  343.           switch (line)
  344.            {
  345.         case 3: /* Gmem */
  346.          tn.Gmem = d * 1e-6;
  347.          break;
  348.         case 4: /* Cmem */
  349.          tn.Cmem = d * 1e-9;
  350.          break;
  351.         case 5: /* Vt */
  352.          tn.Vt = d * 1e-3;
  353.          break;
  354.         case 6: /* Fmin */
  355.          tn.Fmin = d;
  356.          break;
  357.         case 7: /* Gain */
  358.          tn.Gain = d * 1e3;
  359.          break;
  360.         case 9: /* IL */
  361.          ti.IL = d * 1e-9;
  362.          break;
  363.         case 10:
  364.          ti.pL[0] = d * 1e-3;
  365.          break;
  366.         case 11:
  367.          ti.pL[1] = d * 1e-3;
  368.          break;
  369.         case 12:
  370.          ti.pL[2] = d;
  371.          break;
  372.         case 13:
  373.          ti.IH = d * 1e-9;
  374.          break;
  375.         case 14:
  376.          ti.pH[0] = d * 1e-3;
  377.          break;
  378.         case 15:
  379.          ti.pH[1] = d * 1e-3;
  380.          break;
  381.         case 17:
  382.          tn.pI[0] = d * 1e-9;
  383.          break;
  384.         case 18:
  385.          tn.pI[1] = d * 1e-9;
  386.          break;
  387.         case 21:
  388.          tn.mconst = d;
  389.          break;
  390.         default:
  391.          break;
  392.            }
  393.           if (line < 22)
  394.            line++;
  395.           else
  396.            line = 3;
  397.           gotoxy(40,line);
  398.          }
  399.        }
  400.       else
  401.        bioskey(0);
  402.      }
  403.        }
  404.       else
  405.        {
  406.     ext = i>>8;
  407.     bioskey(0);
  408.     switch(ext)
  409.      {
  410.       case UP:
  411.        if (line > 1)
  412.         line--;
  413.        else
  414.         line = 22;
  415.        gotoxy(40,line);
  416.        break;
  417.       case DOWN:
  418.        if (line < 22)
  419.         line++;
  420.        else
  421.         line = 1;
  422.        gotoxy(40,line);
  423.        break;
  424.       default:
  425.        break;
  426.      }
  427.        }
  428.      }
  429.    }
  430.  }
  431.  
  432. void ndisp(struct neuron tn,struct Iint ti,int line)
  433.  { /* displays neuron parameters */
  434.  
  435.   clrscr();
  436.   cputs("Neuron name:");
  437.   gotoxy(40,1);
  438.   cprintf("%s",tn.name);
  439.   gotoxy(1,2);
  440.   cputs("Parameters:");
  441.   gotoxy(3,3);
  442.   cputs("Membrane conductance, Gmem [microS]:");
  443.   gotoxy(40,3);
  444.   cprintf("%.2f",tn.Gmem * 1e6);
  445.   gotoxy(3,4);
  446.   cputs("Membrane capacitance, Cmem [nanoF]:");
  447.   gotoxy(40,4);
  448.   cprintf("%.2f",tn.Cmem * 1e9);
  449.   gotoxy(3,5);
  450.   cputs("Threshold voltage, Vt [milliV]:");
  451.   gotoxy(40,5);
  452.   cprintf("%.2f",tn.Vt * 1e3);
  453.   gotoxy(3,6);
  454.   cputs("Minimum firing frequency, Fmin:");
  455.   gotoxy(40,6);
  456.   cprintf("%.2f",tn.Fmin);
  457.   gotoxy(3,7);
  458.   cputs("Gain [1/milliV]:");
  459.   gotoxy(40,7);
  460.   cprintf("%.2f",tn.Gain * 1e-3);
  461.   gotoxy(1,8);
  462.   cputs("Intrinsic current:");
  463.   gotoxy(40,8);
  464.   if (tn.Iint == NULL)
  465.    cputs("OFF");
  466.   else
  467.    {
  468.     if (ti.type == 0)
  469.      cputs("NON-RANDOM");
  470.     else
  471.      cputs("RANDOM");
  472.     gotoxy(3,9);
  473.     cputs("Low intrinsic current, LIC [nanoA]:");
  474.     gotoxy(40,9);
  475.     cprintf("%.2f",ti.IL * 1e9);
  476.     gotoxy(5,10);
  477.     if (ti.type == 0)
  478.      {
  479.       cputs("Threshold voltage [milliV]:");
  480.       gotoxy(40,10);
  481.       cprintf("%.2f",ti.pL[0] * 1e3);
  482.       gotoxy(5,11);
  483.       cputs("Base duration [millisec]:");
  484.       gotoxy(40,11);
  485.       cprintf("%.2f",ti.pL[1] * 1e3);
  486.       gotoxy(5,12);
  487.       cputs("Multiplier:");
  488.       gotoxy(40,12);
  489.       cprintf("%.2f",ti.pL[2]);
  490.      }
  491.     else
  492.      {
  493.       cputs("Minimum duration [millisec]:");
  494.       gotoxy(40,10);
  495.       cprintf("%.2f",ti.pL[0] * 1e3);
  496.       gotoxy(5,11);
  497.       cputs("Maximum duration [millisec]:");
  498.       gotoxy(40,11);
  499.       cprintf("%.2f",ti.pL[1] * 1e3);
  500.      }
  501.     gotoxy(3,13);
  502.     cputs("High intrinsic current, HIC [nanoA]:");
  503.     gotoxy(40,13);
  504.     cprintf("%.2f",ti.IH * 1e9);
  505.     gotoxy(5,14);
  506.     if (ti.type == 0)
  507.      {
  508.       cputs("Duration [millisec]:");
  509.       gotoxy(40,14);
  510.       cprintf("%.2f",ti.pH[0] * 1e3);
  511.      }
  512.     else
  513.      {
  514.       cputs("Minimum duration [millisec]:");
  515.       gotoxy(40,14);
  516.       cprintf("%.2f",ti.pH[0] * 1e3);
  517.       gotoxy(5,15);
  518.       cputs("Maximum duration [millisec]:");
  519.       gotoxy(40,15);
  520.       cprintf("%.2f",ti.pH[1] * 1e3);
  521.      }
  522.    }
  523.   gotoxy(1,16);
  524.   cputs("Sensory current function:");
  525.   gotoxy(40,16);
  526.   switch (tn.Isens)
  527.    {
  528.     case NONE:
  529.      cputs("NONE");
  530.      break;
  531.     case LAF:
  532.      cputs("LEG ANGLE FORWARD");
  533.      break;
  534.     case LAB:
  535.      cputs("LEG ANGLE BACKWARD");
  536.      break;
  537.     case AC:
  538.      cputs("ANTENNA CONTACT");
  539.      break;
  540.     case OS:
  541.      cputs("ODOR STRENGTH");
  542.      break;
  543.     case EC:
  544.      cputs("ENERGY CAPICITY");
  545.      break;
  546.     case MC:
  547.      cputs("MOUTH CONTACT");
  548.      break;
  549.    }
  550.   if (tn.Isens)
  551.    {
  552.     gotoxy(3,17);
  553.     cputs("Sensory current parameter 1 [nanoA]:");
  554.     gotoxy(40,17);
  555.     cprintf("%.4f",tn.pI[0] * 1e9);
  556.     if (tn.Isens == OS)
  557.      {
  558.       gotoxy(3,18);
  559.       cputs("Sensory current parameter 2 [nanoA]:");
  560.       gotoxy(40,18);
  561.       cprintf("%.4f",tn.pI[1] * 1e9);
  562.      }
  563.    }
  564.   gotoxy(1,19);
  565.   cputs("Motor output type:");
  566.   gotoxy(40,19);
  567.   if (tn.mtype == 0)
  568.    cputs("NONE");
  569.   else
  570.    {
  571.     if (tn.mtype == 1)
  572.      {
  573.       cputs("FORCE");
  574.       gotoxy(5,20);
  575.       cputs("Force type:");
  576.       gotoxy(40,20);
  577.       if (tn.mname == 0)
  578.        cputs("Forward");
  579.       else
  580.        if (tn.mname == 1)
  581.     cputs("Backward");
  582.        else
  583.     cputs("Lateral");
  584.       gotoxy(5,21);
  585.       cputs("Firing frequency multiplier:");
  586.       gotoxy(40,21);
  587.       cprintf("%.2f",tn.mconst);
  588.      }
  589.     else
  590.      {
  591.       cputs("STATE");
  592.       gotoxy(5,20);
  593.       cputs("State type:");
  594.       gotoxy(40,20);
  595.       if (tn.mname == 0)
  596.        cputs("Foot");
  597.       else
  598.        cputs("Mouth");
  599.       gotoxy(5,21);
  600.       cputs("Firing frequency threshold");
  601.       gotoxy(40,21);
  602.       cprintf("%.2f",tn.mconst);
  603.      }
  604.    }
  605.   gotoxy(1,22);
  606.   cputs("Connections:");
  607.   gotoxy(40,22);
  608.   cputs("MODIFY");
  609.   textattr(BLUE + (LIGHTGRAY<<4));
  610.   gotoxy(1,24);
  611.   cputs(" ^D-Delete neuron   ^S-Save neuron   Esc-New neuron                             ");
  612.   gotoxy(40,line);
  613.   textattr(LIGHTGRAY);
  614.  }
  615.  
  616. void conmod(char *nname,struct con *tc,int *cc)
  617.  { /* allows modification of neurons connections */
  618.   int i,j,done,line,field;
  619.   struct con *cp;
  620.   enum asc_val asc;
  621.   enum ext_val ext;
  622.   char str[10],*p;
  623.   double d;
  624.  
  625.   line = 3;
  626.   field = 0;
  627.   condisp(nname,tc,*cc,line,field);
  628.   done = FALSE;
  629.   while (!done)
  630.    {
  631.     cp = tc + line - 3;
  632.     i = 0;
  633.     while (!i)
  634.      i = bioskey(1);
  635.     asc = i & 0xff;
  636.     if (asc)
  637.      {
  638.       if (asc < 32)
  639.        {
  640.     bioskey(0);
  641.     switch (asc)
  642.      {
  643.       case CTRLD: /* delete connection */
  644.        for (j=line, cp=tc+line-2; j<=*cc+2; j++, cp++)
  645.         *(cp-1) = *cp;
  646.        (*cc)--;
  647.        condisp(nname,tc,*cc,line,field);
  648.        break;
  649.       case CR: /* change type */
  650.        if (field == 2)
  651.         {
  652.          cp->ctype++;
  653.          if (cp->ctype > 2)
  654.           cp->ctype = 0;
  655.          condisp(nname,tc,*cc,line,field);
  656.         }
  657.        else
  658.         if (cp->ctype == 1 && field == 5)
  659.          {
  660.           cp->U = !cp->U;
  661.           gotoxy(3 + field*10,line);
  662.           cprintf("%d",cp->U);
  663.           gotoxy(3 + field*10,line);
  664.          }
  665.        break;
  666.       case ESC: /* back to parameters */
  667.        done = TRUE;
  668.        break;
  669.       default:
  670.        break;
  671.      }
  672.        }
  673.       else
  674.        { /* enter connection data */
  675.     if (field == 2 || (field > 2 && !cp->ctype) || field == 5)
  676.      bioskey(0);
  677.     else
  678.      {
  679.       gotoxy(3 + field*10,line);
  680.       cputs("          ");
  681.       gotoxy(3 + field*10,line);
  682.       str[0] = 7;
  683.       p = cgets(str);
  684.       if (field == 1 || field == 4)
  685.        {
  686.         d = atof(p);
  687.         gotoxy(3 + field*10,line);
  688.         cprintf("%.2f",d);
  689.        }
  690.       switch (field)
  691.        {
  692.         case 0: /* sending neuron */
  693.          strcpy(cp->sname,p);
  694.          if (line == *cc + 3)
  695.           {
  696.            (*cc)++; /* add a new connection */
  697.            cp->Isr = 0.;
  698.            cp->ctype = 0;
  699.            cp->cname[0] = 0;
  700.            cp->Icr = 0;
  701.            cp->U = 0;
  702.            condisp(nname,tc,*cc,line,field);
  703.           }
  704.          break;
  705.         case 1: /* sending current */
  706.          cp->Isr = d * 1e-9;
  707.          break;
  708.         case 3: /* compound neuron */
  709.          strcpy(cp->cname,p);
  710.          break;
  711.         case 4: /* compound current */
  712.          cp->Icr = d * 1e-9;
  713.          break;
  714.        }
  715.       field++;
  716.       if (field > 5)
  717.        {
  718.         field = 0;
  719.         line++;
  720.        }
  721.       gotoxy(3 + field*10,line);
  722.      }
  723.        }
  724.      }
  725.     else
  726.      {
  727.       ext = i>>8;
  728.       bioskey(0);
  729.       switch (ext)
  730.        {
  731.     case UP:
  732.      if (line > 3)
  733.       line--;
  734.      else
  735.       {
  736.        line = *cc + 3;
  737.        if (line > 23);
  738.         line = 23;
  739.       }
  740.      break;
  741.     case DOWN:
  742.      if (line < *cc + 3 && line < 23)
  743.       line++;
  744.      else
  745.       line = 3;
  746.      break;
  747.     case RIGHT:
  748.      if (field < 5)
  749.       field++;
  750.      else
  751.       field = 0;
  752.      break;
  753.     case LEFT:
  754.      if (field > 0)
  755.       field--;
  756.      else
  757.       field = 5;
  758.      break;
  759.     default:
  760.      break;
  761.        }
  762.       gotoxy(3 + field*10,line);
  763.      }
  764.    }
  765.  }
  766.  
  767. void condisp(char *nname,struct con *tc,int cc,int line,int field)
  768.   { /* displays current neuron's connections */
  769.    int i;
  770.    struct con *cp;
  771.  
  772.    clrscr();
  773.    cprintf("Neuron name: %s",nname);
  774.    gotoxy(3,2);
  775.    cputs("Sending   Current   Type      Compound  Current   State");
  776.    for (i=0, cp=tc; i<cc; i++, cp++)
  777.     {
  778.      gotoxy(3,i+3);
  779.      cprintf("%-6s    %.2f",cp->sname,cp->Isr*1e9);
  780.      gotoxy(23,i+3);
  781.      if (cp->ctype == 0)
  782.       cputs("DIRECT");
  783.      else
  784.       if (cp->ctype == 1)
  785.        cputs("GATED");
  786.       else
  787.        cputs("MODULATED");
  788.      if (cp->ctype)
  789.       {
  790.        gotoxy(33,i+3);
  791.        cprintf("%-6s    %.2f",cp->cname,cp->Icr*1e9);
  792.        if (cp->ctype == 1)
  793.     {
  794.      gotoxy(53,i+3);
  795.      cprintf("%d",cp->U);
  796.     }
  797.       }
  798.     }
  799.    textattr(BLUE + (LIGHTGRAY<<4));
  800.    gotoxy(1,24);
  801.    cputs(" ^D-Delete connection   Esc-Return to parameters                                ");
  802.    textattr(LIGHTGRAY);
  803.    gotoxy(3 + field*10,line);
  804.  }
  805.