Beispiel #1
0
static int do_char(WINDOW *win, int width, int *i, int *y, int *x, char *str)
{
    if (!str[*i]) {
        return -1;
    } else if (str[*i] == '\\') {
        (*i)++;
        putxy(win, width, i, y, x, &str[*i]);
    } else if (str[*i] == '%') {
        (*i)++;
        if (!str[(*i)])
            return -1;
        else
            style_box(win, str[*i]);
    } else if (str[*i] == ' ') {
        int tmp = theme_strlen(&str[*i + 1], ' ');
        if ((tmp >= (width - *x)) && (tmp < width)) {
            (*i)++;
            return -2;
        }
        else
            putxy(win, width, i, y, x, &str[*i]);
    } else if(putxy(win, width, i, y, x, &str[*i]))
        return -2;

    return 0;
}
Beispiel #2
0
void timer_handler ( struct regs* r ) {
    dump_regs = *r;
    T.ticks++;
    if ( T.ticks % 1000 == 0 ) {
        T.uptime++;
        clock++;

        s = clock % 60;
        m = ( clock / 60 ) % 60;
        h = ( ( clock / 60 ) / 60 ) % 24;
        tsp[4] = s / 10;
        tsp[5] = s % 10;
        tsp[2] = m / 10;
        tsp[3] = m % 10;
        tsp[0] = h / 10;
        tsp[1] = h % 10;
        settextcolor ( 6, 0 );
        putxy ( 48 + tsp[0], 5, 2 );
        putxy ( 48 + tsp[1], 6, 2 );
        putxy ( ':', 7, 2 );
        putxy ( 48 + tsp[2], 8, 2 );
        putxy ( 48 + tsp[3], 9, 2 );
        putxy ( ':', 10, 2 );
        putxy ( 48 + tsp[4], 11, 2 );
        putxy ( 48 + tsp[5], 12, 2 );
        settextcolor ( forecolor, 0 );
    }
}
Beispiel #3
0
void MainScreen(char *InstallName) {
   char fromdrive[2], todrive[3], tmp1[3], topath[9], tmp[9], drive[2];
   EditClass EditToDrive(WINDOW_LEFT+26,WINDOW_TOP+3,1, DEF_DRIVE);
   EditClass EditPath(WINDOW_LEFT+32,WINDOW_TOP+4,8, DEF_DIRECTORY);
   char ok;

   sprintf(fromdrive, "%c", getdisk()+'A');
   strcpy(todrive, "C");
   strcpy(tmp, "\\EDIR");
   _setcursortype(_NORMALCURSOR);
   putxy(WINDOW_LEFT+3,WINDOW_TOP+2,0,STANDARD,"Installing from drive %c:", fromdrive[0]);
   putxy(WINDOW_LEFT+3,WINDOW_TOP+3,0,STANDARD,"Install to what drive?  :");
   putxy(WINDOW_LEFT+3,WINDOW_TOP+4,0,STANDARD,"Install to what directory?  :", topath);
   EditToDrive.Display();
   EditPath.Display();
   putxy(WINDOW_LEFT+30, WINDOW_TOP+4, 0, STANDARD, "%c", toupper(todrive[0]));
   strcpy(todrive, EditToDrive.GetInput());
   putxy(WINDOW_LEFT+30, WINDOW_TOP+4, 0, STANDARD, "%c", toupper(todrive[0]));
   strcpy(tmp, EditPath.GetInput());
   descr(NULL);
   sprintf(topath, "%c:%s", todrive[0], tmp);
   putxy(WINDOW_LEFT+3,WINDOW_TOP+5,0,STANDARD,"Is this ok (Y/N/Q)? ");
   ok = (int) tolower((char) getch());
   if(ok == 121) {
      if(CheckDrive(todrive[0], "Invalid disk drive to copy files to") == 1) {
	 _setcursortype(_NOCURSOR);
	 putxy(WINDOW_LEFT+3,WINDOW_TOP+5,0,STANDARD,"Please wait...installing files...");
	 sprintf(tmp1, "%c:", fromdrive[0]);
	 docopy(tmp1, topath, InstallName);
	 getch();
      }
      else MainScreen(InstallName);
   }
   else if(ok == 113);
   else {
      putxy(WINDOW_LEFT+3,WINDOW_TOP+5,0,STANDARD,"%s", space(20));
      MainScreen(InstallName);
   }
}
Beispiel #4
0
gaint gxsflw (gaint i, gaint j, gaint iside) {
 
/* Follow a shaded outline to the end.  Close it if necessary by 
   following around undef areas and around the grid border.         */ 
 
/* The grid box:

              (f3)
     p4      side 3     p3
        x ------------ x
        |              |
 side 4 |              | side 2
  (f4)  |              |  (f2)
        |              |
        x ------------ x
      p1    side 1      p2
             (f1)
                                                                     */
 
gaint *f1,*f2,*f3,*f4,*ff,*fu,*fd,*fl,*fr; 
gaint cnt,rc,isave,jsave,uflag,ucflg,bflag,k; 
gadouble *p1,*p2,*p3,*p4;
gadouble x,y;
 
  isave = i; jsave = j;
  uflag = 0;
  bndflg = 0;

  bflag = 0;
  if (iside==1) goto side1;              /* Jump in based on side    */
  if (iside==2) goto side2;
  if (iside==3) goto side3;
  if (iside==4) goto side4;
  bflag = 1;
  if (iside==5) goto br;
  if (iside==6) goto tr;
  if (iside==7) goto lu;
  if (iside==8) goto ru;
  if (iside==9) goto ur;
  if (iside==10) goto uu;
  printf ("Logic error 40 in gxshad\n");
  return (1);
 
  /* Calculate entry point in the current grid box, then move to the
     next grid box based on the exit side.                           */
 
  side1:                                 /* Enter side 1             */

    if (i<imn || i>(imx-1) || j<jmn || j>jmx) {
      printf ("logic error 12 in gxshad\n");
      printf ("  side1, %i %i \n",i,j);
      return(1);
    }

    p1 = gr + (imax*(j-1)+i-1);
    p2 = p1+1;
    x = (gadouble)i + (val-*p1)/(*p2-*p1);  /* Calculate entry point    */
    y = (gadouble)j;
    rc = putxy(x,y);                     /* Put points in buffer     */
    if (rc) return(rc);
    f1 = flgh + (imax*(j-1)+i-1);
    if (*f1==1 || *f1==7) goto done;     /* We may be done           */
    if (*f1>5 && !uflag) {               /* Entered an undef box?    */
      if (*f1==9) {
        printf ("Logic error 4 in gxshad: %i %i\n",i,j);
        return(1);
      }
      *f1 = 7;                           /* Indicate we were here    */
      if (*p1>val) {
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto uleft;                      
      } else {
        i++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto uright;
      }
    }              
    if (*f1==8) *f1 = 7;                 /* Indicate we were here    */
    else *f1 = 1;
    uflag = 0;
    if (j+1>jmx) {                       /* At top boundry?          */
      if (*p1>val) {
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto tleft;                      
      } else {
        i++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto tright;
      }
    }

    /* Check for exit side.  Also check for col.                    */

    p3 = p2+imax;
    p4 = p3-1;
    if ( (*p2<=val && *p3>val) || (*p2>val && *p3<=val) ) {
      if ( (*p3<=val && *p4>val) || (*p3>val && *p4<=val) ) { 
        if (!spathl(*p1, *p2, *p3, *p4)) {
          i--;
          goto side2;                    /* Exiting 4, go enter 2  */
        }
      }
      i++;
      goto side4;                        /* Exiting 2, go enter 4  */
    }
    if ( (*p3<=val && *p4>val) || (*p3>val && *p4<=val) ) {
      j++;
      goto side1;                        /* Exiting 3, go enter 1  */
    }
    if ( (*p4<=val && *p1>val) || (*p4>val && *p1<=val) ) {
      i--;
      goto side2;                        /* Exiting 4, go enter 2  */
    }
    printf ("Logic error 8 in gxshad\n");
    return(1);
 
  side2:                                 /* Enter side 2           */

    if (i<(imn-1) || i>(imx-1) || j<jmn || j>(jmx-1)) {
      printf ("logic error 12 in gxshad\n");
      printf ("  side2, %i %i \n",i,j);
      return(1);
    }

    p2 = gr + (imax*(j-1)+i);
    p3 = p2+imax;
    x = (gadouble)(i+1);
    y = (gadouble)j + (val-*p2)/(*p3-*p2);  /* Calculate entry point    */
    rc = putxy(x,y);                     /* Put points in buffer     */
    if (rc) return(rc);
    f2 = flgv + (imax*(j-1)+i);
    if (*f2==1 || *f2==7) goto done;     /* We may be done           */
    if (*f2>5 && !uflag) {               /* Entered an undef box?    */
      if (*f2==9) {
        printf ("Logic error 4 in gxshad: %i %i\n",i,j);
        printf ("Side 2, entered %i \n",iside);
        return(1);
      }
      *f2 = 7;                           /* Indicate we were here    */
      if (*p2>val) {
        i++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto udown;                      
      } else {
        i++; j++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto uup;
      }
    }
    if (*f2==8) *f2 = 7;                 /* Indicate we were here    */
    else *f2 = 1;
    uflag = 0;
    if (i<imn) {                         /* At left boundry?         */
      if (*p2>val) {
        i++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto ldown;                      
      } else {
        i++; j++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto lup;
      }
    }

    /* Check for exit side.  Also check for col.                    */

    p1 = p2-1;
    p4 = p3-1;
    if ( (*p3<=val && *p4>val) || (*p3>val && *p4<=val) ) {
      if ( (*p4<=val && *p1>val) || (*p4>val && *p1<=val) ) { 
        if (spathl(*p1, *p2, *p3, *p4)) {
          j--;
          goto side3;                    /* Exiting 1, go enter 3  */
        }
      }
      j++;
      goto side1;                        /* Exiting 3, go enter 1  */
    }
    if ( (*p4<=val && *p1>val) || (*p4>val && *p1<=val) ) {
      i--;
      goto side2;                        /* Exiting 4, go enter 2  */
    }
    if ( (*p1<=val && *p2>val) || (*p1>val && *p2<=val) ) {
      j--;
      goto side3;                        /* Exiting 1, go enter 3  */
    }
    printf ("Logic error 8 in gxshad\n");
    return(1);
 
  side3:                                 /* Enter side 3             */

    if (i<imn || i>(imx-1) || j<(jmn-1) || j>(jmx-1)) {
      printf ("logic error 12 in gxshad\n");
      printf ("  side3, %i %i \n",i,j);
      return(1);
    }

    p3 = gr + (imax*(j)+i);
    p4 = p3-1;
    x = (gadouble)i + (val-*p4)/(*p3-*p4);  /* Calculate entry point    */
    y = (gadouble)(j+1);
    rc = putxy(x,y);                     /* Put points in buffer     */
    if (rc) return(rc);
    f3 = flgh + (imax*(j)+i-1);
    if (*f3==1 || *f3==7) goto done;     /* We may be done           */
    if (*f3>5 && !uflag) {               /* Entered an undef box?    */
      if (*f3==9) {
        printf ("Logic error 4 in gxshad: %i %i\n",i,j);
        printf ("Side 3, entered %i \n",iside);
        return(1);
      }
      *f3 = 7;                           /* Indicate we were here    */
      if (*p3>val) {
        i++; j++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto uright;                     
      } else {
        j++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto uleft;
      }
    }
    if (*f3==8) *f3 = 7;                 /* Indicate we were here    */
    else *f3 = 1;
    uflag = 0;
    if (j<jmn) {                         /* At bottom boundry?       */
      if (*p3>val) {
        i++; j++; 
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto bright;                     
      } else {
        j++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto bleft; 
      }
    }

    /* Check for exit side.  Also check for col.                    */

    p1 = p4-imax;
    p2 = p1+1;
    if ( (*p1<=val && *p4>val) || (*p1>val && *p4<=val) ) {
      if ( (*p1<=val && *p2>val) || (*p1>val && *p2<=val) ) { 
        if (!spathl(*p1, *p2, *p3, *p4)) {
          i++;
          goto side4;                    /* Exiting 2, go enter 4  */
        }
      }
      i--;
      goto side2;                        /* Exiting 4, go enter 2  */
    }
    if ( (*p1<=val && *p2>val) || (*p1>val && *p2<=val) ) {
      j--;
      goto side3;                        /* Exiting 1, go enter 3  */
    }
    if ( (*p2<=val && *p3>val) || (*p2>val && *p3<=val) ) {
      i++;
      goto side4;                        /* Exiting 2, go enter 4  */
    }
    printf ("Logic error 8 in gxshad\n");
    return(1);
 
  side4:                                 /* Enter side 4           */

    if (i<1 || i>imax || j<1 || j>(jmax-1)) {
      printf ("logic error 12 in gxshad\n");
      printf ("  side4, %i %i \n",i,j);
      printf (" imax, jmax = %i %i \n",imax,jmax);
      return(1);
    }

    p1 = gr + (imax*(j-1)+i-1);
    p4 = p1+imax;
    x = (gadouble)i;
    y = (gadouble)j + (val-*p1)/(*p4-*p1);  /* Calculate entry point    */
    rc = putxy(x,y);                     /* Put points in buffer     */
    if (rc) return(rc);
    f4 = flgv + ((j-1)*imax+i-1);
    if (*f4==1 || *f4==7) goto done;     /* We may be done           */
    if (*f4>5 && !uflag) {               /* Entered an undef box?    */
      if (*f4==9) {
        printf ("Logic error 4 in gxshad: %i %i\n",i,j);
        printf ("Side 4, entered %i \n",iside);
        return(1);
      }
      *f4 = 7;                           /* Indicate we were here    */
      if (*p1>val) {
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto udown;                      
      } else {
        j++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto uup;
      }
    }
    if (*f4==8) *f4 = 7;                 /* Indicate we were here    */
    else *f4 = 1;
    uflag = 0;
    if (i+1>imx) {                       /* At right boundry?        */
      if (*p1>val) {
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto rdown;                      
      } else {
        j++;
        rc = putxy((gadouble)i,(gadouble)j);
        if (rc) return(rc);
        goto rup;
      }
    }

    /* Check for exit side.  Also check for col.                    */

    p2 = p1+1;
    p3 = p4+1;
    if ( (*p1<=val && *p2>val) || (*p1>val && *p2<=val) ) {
      if ( (*p2<=val && *p3>val) || (*p2>val && *p3<=val) ) { 
        if (spathl(*p1, *p2, *p3, *p4)) {
          j++;
          goto side1;                    /* Exiting 3, go enter 1  */
        }
      }
      j--;
      goto side3;                        /* Exiting 1, go enter 3  */
    }
    if ( (*p2<=val && *p3>val) || (*p2>val && *p3<=val) ) {
      i++;
      goto side4;                        /* Exiting 2, go enter 4  */
    }
    if ( (*p3<=val && *p4>val) || (*p3>val && *p4<=val) ) {
      j++;
      goto side1;                        /* Exiting 3, go enter 1  */
    }
    printf ("Logic error 8 in gxshad\n");
    return(1);

  /* At an undefined boundry and last moved towards the left.  */

  uleft:

    bndflg = 1;
    if (bflag && i==isave && j==jsave) goto done;
    if (j<(jmn+1)||j>jmx-1) {
      printf ("Logic error 16 in gxshad\n");
      return (1);
    }
    fu = flgv + ((j-1)*imax+i-1);
    fd = fu-imax;
    if (i==imn) {
      if ((*fu>5 && *fd>5) || (*fu<5 && *fd<5)) {
        printf ("Logic error 20 in gxshad\n");
        return (1);
      }
      if (*fu>5) goto ldown;
      else goto lup;
    }
    ff = flgh + ((j-1)*imax+i-2);
    cnt=0;
    if (*ff==7 || *ff==8) cnt++;
    if (*fu==7 || *fu==8) cnt++;
    if (*fd==7 || *fd==8) cnt++;
    if (cnt==2 || cnt==0) {
      printf ("Logic error 24 in gxshad\n");
      return (1);
    }
    ucflg = 0;
    if (cnt==3) ucflg = undcol(i,j);
    if (ucflg==9) return(1);
    if (!ucflg && (*ff==7 || *ff==8)) {
      i--;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        if (*fu>5) {
          j--;
          goto side3;
        } else goto side1;
      }
      *ff = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto uleft;
    }
    if (ucflg!=2 && (*fd==7 || *fd==8)) {
      j--;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        if (ucflg || *fu==9) {
          goto side4;
        } else {
          i--;
          goto side2;
        }
      }
      *fd = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto udown;
    }
    if (ucflg!=1 && (*fu==7 || *fu==8)) {
      j++;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        if (ucflg || *fd==9) {
          j--;
          goto side4;
        } else {
          i--; j--; 
          goto side2;
        }
      }
      *fu = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto uup;
    }
    printf ("Logic error 28 in gxshad\n");
    return(1);
     
  /* At an undefined boundry and last moved towards the right. */

  uright:

    if (bflag && i==isave && j==jsave) goto done;

  ur:

    bndflg = 1;
    if (j<(jmn+1)||j>jmx-1) {
      printf ("Logic error 16 in gxshad\n");
      return (1);
    }
    fu = flgv + ((j-1)*imax+i-1);
    fd = fu-imax;
    if (i==imx) {
      if ((*fu>5 && *fd>5) || (*fu<5 && *fd<5)) {
        printf ("Logic error 20 in gxshad\n");
        return (1);
      }
      if (*fu>5) goto rdown;
      else goto rup;
    }
    ff = flgh + ((j-1)*imax+i-1);
    cnt=0;
    if (*ff==7 || *ff==8) cnt++;
    if (*fd==7 || *fd==8) cnt++;
    if (*fu==7 || *fu==8) cnt++;
    if (cnt==2 || cnt==0) {
      printf ("Logic error 24 in gxshad\n");
      return (1);
    }
    ucflg = 0;
    if (cnt==3) ucflg = undcol(i,j);
    if (ucflg==9) return(1);
    if (!ucflg && (*ff==7 || *ff==8)) {
      i++;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        i--;
        if (*fu>5) {
          j--;
          goto side3;
        } else goto side1;
      }
      *ff = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto uright;
    }
    if (ucflg!=1 && (*fd==7 || *fd==8)) {
      j--;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1; 
        if (ucflg || *fu==9) {
          i--;
          goto side2;
        } else {
          goto side4;
        }
      }
      *fd = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto udown;
    }
    if (ucflg!=2 && (*fu==7 || *fu==8)) {
      j++;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        if (ucflg || *fd==9) {
          i--; j--;
          goto side2;
        } else {
          j--; 
          goto side4;
        }
      }
      *fu = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto uup;
    }
    printf ("Logic error 28 in gxshad\n");
    return(1);
     
  /* At an undefined boundry and last moved towards the top.   */

  uup:

    if (bflag && i==isave && j==jsave) goto done;

  uu:

    bndflg = 1;
    if (i<(imn+1)||i>imx-1) {
      printf ("Logic error 16 in gxshad\n");
      return (1);
    }
    fr = flgh + ((j-1)*imax+i-1);
    fl = fr-1;
    if (j==jmx) {
      if ((*fr>5 && *fl>5) || (*fr<5 && *fl<5)) {
        printf ("Logic error 20 in gxshad\n");
        return (1);
      }
      if (*fr>5) goto tleft;
      else goto tright;
    }
    ff = flgv + ((j-1)*imax+i-1);
    cnt=0;
    if (*ff==7 || *ff==8) cnt++;
    if (*fr==7 || *fr==8) cnt++;
    if (*fl==7 || *fl==8) cnt++;
    if (cnt==2 || cnt==0) {
      printf ("Logic error 24 in gxshad\n");
      return (1);
    }
    ucflg = 0;
    if (cnt==3) ucflg = undcol(i,j);
    if (ucflg==9) return(1);
    if (!ucflg && (*ff==7 || *ff==8)) {
      j++;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        j--;
        uflag = 1;
        if (*fr>5) {
          i--;
          goto side2;
        }
        else goto side4;
      }
      *ff = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto uup;   
    }
    if (ucflg!=2 && (*fr==7 || *fr==8)) {
      i++;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        if (ucflg || *fl==9) {
          i--; j--;
          goto side3;
        } else {
          i--;
          goto side1;
        }
      }
      *fr = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto uright;
    }
    if (ucflg!=1 && (*fl==7 || *fl==8)) {
      i--;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        if (ucflg || *fr==9) {
          j--;
          goto side3;
        } else {
          goto side1;
        }
      }
      *fl = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto uleft;
    }
    printf ("Logic error 28 in gxshad\n");
    return(1);
     
  /* At an undefined boundry and last moved towards the bottom.  */

  udown:

    bndflg = 1;
    if (bflag && i==isave && j==jsave) goto done;
    if (i<(imn+1)||i>imx-1) {
      printf ("Logic error 16 in gxshad\n");
      return (1);
    }
    fr = flgh + ((j-1)*imax+i-1);
    fl = fr-1;
    if (j==jmn) {
      if ((*fr>5 && *fl>5) || (*fr<5 && *fl<5)) {
        printf ("Logic error 20 in gxshad\n");
        return (1);
      }
      if (*fr>5) goto bleft;
      else goto bright;
    }
    ff = flgv + ((j-2)*imax+i-1);
    cnt=0;
    if (*ff==7 || *ff==8) cnt++;
    if (*fr==7 || *fr==8) cnt++;
    if (*fl==7 || *fl==8) cnt++;
    if (cnt==2 || cnt==0) {
      printf ("Logic error 24 in gxshad\n");
      return (1);
    }
    ucflg = 0;
    if (cnt==3) ucflg = undcol(i,j);
    if (ucflg==9) return(1);
    if (!ucflg && (*ff==7 || *ff==8)) {
      j--;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        if (*fr>5) {
          i--;
          goto side2;
        }
        else goto side4;
      }
      *ff = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto udown;   
    }
    if (ucflg!=1 && (*fr==7 || *fr==8)) {
      i++;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        if (ucflg || *fl==9) {
          i--;
          goto side1;
        } else {
          i--; j--;
          goto side3;
        }
      }
      *fr = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto uright;
    }
    if (ucflg!=2 && (*fl==7 || *fl==8)) {
      i--;
      p1 = gr + ((j-1)*imax+i-1);
      if (*p1<=val) {
        uflag = 1;
        if (ucflg || *fr==9) {
          goto side1;
        } else {
          j--;
          goto side3;
        }
      }
      *fl = 7;
      rc = putxy((gadouble)i,(gadouble)j);
      if (rc) return(rc);
      goto uleft;
    }
    printf ("Logic error 28 in gxshad\n");
    return(1);

  /* Follow grid boundry until we hit a missing data area, or until
     we hit the restart of the contour line.                         */

  tright:

    if (bflag && i==isave && j==jsave) goto done;

  tr:

    bndflg = 1; 
    if (i==imx) goto rdown;
    ff = flgh + ((j-1)*imax+i-1);
    if (*ff>5) goto udown;
    i++;
    p1 = gr + ((j-1)*imax+i-1);
    if (*p1<=val) {
      j--; i--;
      goto side3;
    }
    *ff = 1;
    rc = putxy((gadouble)i,(gadouble)j);
    if (rc) return(rc);
    goto tright;

  tleft:

    bndflg = 1;
    if (bflag && i==isave && j==jsave) goto done;
    if (i==imn) goto ldown;
    ff = flgh + ((j-1)*imax+i-2);
    if (*ff>5) goto udown;
    i--;
    p1 = gr + ((j-1)*imax+i-1);
    if (*p1<=val) {
      j--;
      goto side3;
    }
    *ff = 1;
    rc = putxy((gadouble)i,(gadouble)j);
    if (rc) return(rc);
    goto tleft; 

  bright:

    if (bflag && i==isave && j==jsave) goto done;

  br:

    bndflg = 1;
    if (i==imx) goto rup;
    ff = flgh + ((j-1)*imax+i-1);
    if (*ff>5) goto uup;
    i++;
    p1 = gr + ((j-1)*imax+i-1);
    if (*p1<=val) {
      i--;
      goto side1;
    }
    *ff = 1;
    rc = putxy((gadouble)i,(gadouble)j);
    if (rc) return(rc);
    goto bright;

  bleft:

    bndflg = 1;
    if (bflag && i==isave && j==jsave) goto done;
    if (i==imn) goto lup;
    ff = flgh + ((j-1)*imax+i-2);
    if (*ff>5) goto uup;
    i--;
    p1 = gr + ((j-1)*imax+i-1);
    if (*p1<=val) {
      goto side1;
    }
    *ff = 1;
    rc = putxy((gadouble)i,(gadouble)j);
    if (rc) return(rc);
    goto bleft; 
     
  rup:

    if (bflag && i==isave && j==jsave) goto done;

  ru:

    bndflg = 1;
    if (j==jmx) goto tleft;
    ff = flgv + ((j-1)*imax+i-1);
    if (*ff>5) goto uleft;
    j++;
    p1 = gr + ((j-1)*imax+i-1);
    if (*p1<=val) {
      j--; i--;
      goto side2;
    }
    *ff = 1;
    rc = putxy((gadouble)i,(gadouble)j);
    if (rc) return(rc);
    goto rup;   
     
  rdown:

    bndflg = 1;
    if (bflag && i==isave && j==jsave) goto done;
    if (j==jmn) goto bleft;
    ff = flgv + ((j-2)*imax+i-1);
    if (*ff>5) goto uleft;
    j--;
    p1 = gr + ((j-1)*imax+i-1);
    if (*p1<=val) {
      i--;
      goto side2;
    }
    *ff = 1;
    rc = putxy((gadouble)i,(gadouble)j);
    if (rc) return(rc);
    goto rdown; 
     
  lup:

    if (bflag && i==isave && j==jsave) goto done;

  lu:

    bndflg = 1;
    if (j==jmx) goto tright;
    ff = flgv + ((j-1)*imax+i-1);
    if (*ff>5) goto uright;
    j++;
    p1 = gr + ((j-1)*imax+i-1);
    if (*p1<=val) {
      j--; 
      goto side4;
    }
    *ff = 1;
    rc = putxy((gadouble)i,(gadouble)j);
    if (rc) return(rc);
    goto lup;   
     
  ldown:

    bndflg = 1;
    if (bflag && i==isave && j==jsave) goto done;
    if (j==jmn) goto bright;
    ff = flgv + ((j-2)*imax+i-1);
    if (*ff>5) goto uright;
    j--;
    p1 = gr + ((j-1)*imax+i-1);
    if (*p1<=val) {
      goto side4;
    }
    *ff = 1;
    rc = putxy((gadouble)i,(gadouble)j);
    if (rc) return(rc);
    goto ldown; 
     
  done:

  shdcmp();
  if (xycnt<4) goto cont;
  if (shdmax()) {
    for (k=0; k<xycnt; k++) {
      gxconv(*(xybuf+(k*2)),*(xybuf+(k*2+1)),&x,&y,3);
      *(xybuf+(k*2)) = x;
      *(xybuf+(k*2+1)) = y;
    }
    gxcolr (color);
    gxfill (xybuf, xycnt);
  } else {
    xystk[stkcnt] = (gadouble *)malloc(sizeof(gadouble)*(xycnt+1)*2);
    if (xystk[stkcnt]==NULL) {
      printf ("Memory allocation error in gxshad: stack buffer\n");
      return (1);
    }
    xypnt = xystk[stkcnt];
    *xypnt = (gadouble)(xycnt)+0.1;
    *(xypnt+1) = (gadouble)(prvclr)+0.1;
    xypnt+=2;
    for (k=0; k<xycnt; k++) {
      *(xypnt+(k*2)) = *(xybuf+(k*2));
      *(xypnt+(k*2+1)) = *(xybuf+(k*2+1));
    }
    stkcnt++;
    if (stkcnt>=XYBMAX) {
      printf ("Buffer stack limit exceeded in gxshad\n");
      return(1);
    }
  }

cont:
  xycnt = 0;
  return (0);

}