Esempio n. 1
0
IMAGE Difference (IMAGE a, IMAGE b)
{
	IMAGE t=0;
	int i=0, j=0, rmax=0, rmin=0, cmax=0, cmin=0;

	MinMax (a, b, &rmax, &cmax, &rmin, &cmin);
	t = newimage (rmax-rmin+1, cmax-cmin+1);   
	t->info->oi = -rmin;    t->info->oj = -cmin;
	if (t == 0)
	{
		printf ("Out of storage in Difference!\n");
		exit (1);
	}

	for (i=rmin; i<rmax; i++)
	{
	  for (j=cmin; j< cmax; j++)
	  {
	    if (pget(a,i,j)==1 && pget(b,i,j)!=1)
		  pset (t, i, j, 1);
	    else  pset (t, i, j, 0); 
	  }
	}
	return t;
}
Esempio n. 2
0
int solvefrom(int x, int y) {
    int i;
    static int solved=0;
    static int solvedepth=0;
    if(solved) return(1);
    solvedepth++;
    if(solvedepth>h) h=solvedepth;
    pset(x,y,fg);
    sprintf(status," %d,%d Depth:%d  ",x,y,solvedepth);
    showstatus(1);
    if(x>=(width-4)) {
        solved=1;
        sprintf(status,"Solved! Depth:%d ",solvedepth);
        showstatus(0);
        return(1);
    }
    for(i=0; i<4; i++) {
        if(ppoint(x+sx[i]/2,y+sy[i]/2)==(fg^31)) {
            if(solvefrom(x+sx[i]/2,y+sy[i]/2)) {
                if(button==0 && solved==0) nap(delay);
                solvedepth--;
                return(1);
            }
        }
    }
    pset(x,y,fg^31);
    if(button==0) nap(delay);
    solvedepth--;
    return(0);
}
Esempio n. 3
0
int utag(BW *bw)
{
	BW *pbw;

	pbw = wmkpw(bw->parent, joe_gettext(_("Tag search: ")), &taghist, dotag, NULL, NULL, tag_cmplt, NULL, NULL, locale_map, 0);
	if (pbw && joe_isalnum_(bw->b->o.charmap,brch(bw->cursor))) {
		P *p = pdup(bw->cursor, "utag");
		P *q = pdup(p, "utag");
		int c;

		while (joe_isalnum_(bw->b->o.charmap,(c = prgetc(p))))
			/* do nothing */;
		if (c != NO_MORE_DATA) {
			pgetc(p);
		}
		pset(q, p);
		while (joe_isalnum_(bw->b->o.charmap,(c = pgetc(q))))
			/* do nothing */;
		if (c != NO_MORE_DATA) {
			prgetc(q);
		}
		binsb(pbw->cursor, bcpy(p, q));
		pset(pbw->cursor, pbw->b->eof);
		pbw->cursor->xcol = piscol(pbw->cursor);
		prm(p);
		prm(q);
	}
	if (pbw) {
		return 0;
	} else {
		return -1;
	}
}
Esempio n. 4
0
P *pbop(BW *bw, P *p)
{
	long indent;
	long prelen;
	P *last;

	p_goto_bol(p);
	indent = nindent(bw, p, 0);
	prelen = prefix(bw, p, 0);
	last = pdup(p, USTR "pbop");
	while (!pisbof(p) && (!within || !markb || p->byte > markb->byte)) {
		long ind;
		long len;

		pprevl(p);
		p_goto_bol(p);
		ind = nindent(bw, p, 0);
		len = prefix(bw, p, 0);
		if (pisnpara(bw, p) || len != prelen) {
			pset(p, last);
			break;
		}
		if (ind > indent) {
/*
			int ok = 1;
			P *q = pdup(p, USTR "pbop");
			if (pprevl(q)) {
				p_goto_bol(q);
				if (nindent(bw, q, 0) == ind)
					ok = 0;
			}
			prm(q);
			if (!ok)
				pnextl(p);
*/
			break;
		}
		if (ind < indent) {
			pset(p, last);
			break;
			/* if (pisbof(p)) {
				break;
			}
			pprevl(p);
			p_goto_bol(p);
			if (pisnpara(bw, p)) {
				pnextl(p);
				break;
			} else {
				pnextl(p);
				pnextl(p);
				break;
			} */
		}
		pset(last, p);
	}
	prm(last);
	return p;
}
Esempio n. 5
0
void usersolve() {
    x=5;
    y=6;
    ox=x;
    oy=y;
    steps=0;
    r=1;
    m=0;
    while((x!=width-3) && (button==0)) {
        expose();
        XQueryPointer(display,main_win,&root,&win,&root_x,&root_y,&win_x,&win_y,&mask);
        while(ox!=x || oy!=y) {
            steps++;
            pset(ox,oy,7);
            px[m]=ox;
            py[m]=oy;
            if(m<maxdepth) m++;
            sprintf(status," Steps: %d",steps);
            showstatus(0);
            if(ox!=x) ox=x;
            else oy=y;
        }
        pset(ox,oy,7);
        ox=x;
        oy=y;
        pset(x,y,(fg+1)&31);
        if((x>win_x/mag) && (ppoint(x-1,y)!=bg)) x--;
        if((x<win_x/mag) && (ppoint(x+1,y)!=bg)) x++;
        if((y>win_y/mag) && (ppoint(x,y-1)!=bg)) y--;
        if((y<win_y/mag) && (ppoint(x,y+1)!=bg)) y++;
        nap(50);
    }
    if(x==width-3) {
        code=rand();
        sprintf(status," %d Steps! Code:%04X ",steps,code);
        showstatus(0);
        i=0;
        c=1;
        button=0;
        while(button==0) {
            pset(ox,oy,c);
            ox=px[i];
            oy=py[i];
            pset(ox,oy,0);
            i++;
            if(i>=m) {
                i=0;
                c=(c+1)&31;
                if(c==bg) c=(c+1)&31;
            }
            expose();
            nap(20);
        }
    }
    waitnobutton();
}
Esempio n. 6
0
/*---------------------------------------------------------------------
                  Make a line on the screen
  ---------------------------------------------------------------------*/
void
line(int x0, int y0, int x1, int y1, u16 color)
{
  int	dx, dy, sx, sy, i, e;
  int	 x = x0;
  int	 y = y0;

  if (x1-x0 > 0){
    sx = 1;
    dx = x1-x0;
  } else if (x1-x0 < 0) {
    sx = -1;
    dx = x0-x1;
  } else {
    sx = 0;
    dx = 0;
  }

  if (y1-y0 > 0){
    sy = 1;
    dy = y1-y0;
  } else if (y1-y0 < 0) {
    sy = -1;
    dy = y0-y1;
  } else {
    sy = 0;
    dy = 0;
  }

  if (dx >= dy) {
    e = -dx;
    for (i=0; i<= dx; i++){
      pset(x, y, color);
      x += sx;
      e += 2*dy;
      if (e>=0) {
	y += sy;
	e -= 2*dx;
      }
    }
  } else {
    e = -dy;
    for (i = 0; i <= dy; i ++){
      pset(x, y, color);
      y += sy;
      e += 2*dx;
      if (e >= 0) {
	x += sx;
	e -= 2*dy;
      }
    }
  }    
} 
unsigned char print_char(char txt, char text_color, char *x_pos, char *y_pos, char inverted)
{
    short text_array_offset = (txt - 32)*5, j;
    char k, temp;
	
    
    if (txt == 10)
    {
        y_pos += 8;
        return(0);
    }

    else if (txt == 13)
    {
        x_pos = 0;
        return(0);
    }

    for (j = text_array_offset; j < text_array_offset+5; j++)
    {
        temp = text_array[j];
        
        for (k = 0; k < 8; k++)
        {
			if(inverted==0){
				if ((temp & 0x80) == 0x80) pset(text_color, *y_pos + k, *x_pos + j + 2 - text_array_offset);
				temp <<= 1;
			}
			else if(inverted==1){
				if ((temp & 0x01) == 0x01) pset(text_color, *y_pos + j + 2 - text_array_offset, *x_pos + k);
				temp >>= 1;	
			}
        }

    }

	if(inverted==0){
		if ((*x_pos + 12) > 132) *x_pos = 0, *y_pos += 8;
		else *x_pos += 6;
	}
	else if(inverted==1){
		if ((*y_pos + 12) > 132) *y_pos = 0, *x_pos += 8;
		else *y_pos += 6;	
	}

    if ((*y_pos + 8) > 132)
    {
        //clear_screen();
        return 1;
    }
    else return 0;

}
Esempio n. 8
0
/*---------------------------------------------------------------------
                  Make a circle on the screen
  ---------------------------------------------------------------------*/
void
circle(int x0, int y0, int r, u16 color)
{
  int	x, y, f;

  x = r;
  y = 0;
  f = -2 * r + 3;
  
  while (x >= y) {
    pset(x0 + x, y0 + y, color);
    pset(x0 - x, y0 + y, color);
    pset(x0 + x, y0 - y, color);
    pset(x0 - x, y0 - y, color);
    pset(x0 + y, y0 + x, color);
    pset(x0 - y, y0 + x, color);
    pset(x0 + y, y0 - x, color);
    pset(x0 - y, y0 - x, color);
    if (f >= 0) {
      x --;
      f -= x*4;
    }
    y++;
    f += 4*y + 2;
  }
}
Esempio n. 9
0
IMAGE Intersection (IMAGE a, IMAGE b)
{
	IMAGE t=0;
	int i=0, j=0, rmin=0, rmax=0, cmin=0, cmax=0;

	MinMax (a, b, &rmax, &cmax, &rmin, &cmin);
	t = newimage (rmax-rmin, cmax-cmin);
	t->info->oi = -rmin; t->info->oj = -cmin;
	for (i=rmin; i<rmax; i++)
	  for (j=cmin; j< cmax; j++)
	    if (pget(a,i,j)==1 && pget(b,i,j)==1)
		pset(t, i,j,1);
	    else pset (t, i, j, 0);
	return t;
}
Esempio n. 10
0
static long parserr(B *b)
{
	P *p = pdup(b->bof, USTR "parserr");
	P *q = pdup(p, USTR "parserr");
	long nerrs = 0;

	if (b->scratch && b->name[0] == '*') {
		/* "* Build Log *", "* Grep Log *" */
	 	b->changed = 0;
	}
	freeall();
	if (errbuf != b) {
		if (errp != NULL) {
			prm(errp);
			errp = NULL;
		}
		errbuf = b;
	}
	do {
		unsigned char *s;

		pset(q, p);
		p_goto_eol(p);
		s = brvs(q, (int) (p->byte - q->byte));
		if (s) {
			nerrs += parseit(b->o.charmap, s, q->line, (b->parseone ? b->parseone : parseone));
			vsrm(s);
		}
	} while (pgetc(p) != NO_MORE_DATA);
	prm(p);
	prm(q);
	return nerrs;
}
Esempio n. 11
0
void HBase::addVector3Data(const char * dataName, unsigned count)
{	
	VerticesHDataset pset(dataName);
	pset.setNumVertices(count);
	pset.create(fObjectId);
	pset.close();
}
Esempio n. 12
0
static int CVSpgmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
                        N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp1,
                        N_Vector vtemp2, N_Vector vtemp3)
{
  booleantype jbad, jok;
  realtype dgamma;
  int  ier;
  CVSpgmrMem cvspgmr_mem;

  cvspgmr_mem = (CVSpgmrMem) lmem;

  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
  dgamma = ABS((gamma/gammap) - ONE);
  jbad = (nst == 0) || (nst > nstlpre + CVSPGMR_MSBPRE) ||
    ((convfail == CV_FAIL_BAD_J) && (dgamma < CVSPGMR_DGMAX)) ||
    (convfail == CV_FAIL_OTHER);
  *jcurPtr = jbad;
  jok = !jbad;

  /* Call pset routine and possibly reset jcur */
  ier = pset(tn, ypred, fpred, jok, jcurPtr, gamma, P_data, 
             vtemp1, vtemp2, vtemp3);
  if (jbad) *jcurPtr = TRUE;

  /* If jcur = TRUE, increment npe and save nst value */
  if (*jcurPtr) {
    npe++;
    nstlpre = nst;
  }

  /* Return the same value ier that pset returned */
  last_flag = ier;
  return(ier);
}
Esempio n. 13
0
static void cdata(B *b, unsigned char *dat, int siz)
{
	P *q = pdup(b->eof, USTR "cdata");
	P *r = pdup(b->eof, USTR "cdata");
	long byte = q->byte;
	unsigned char bf[1024];
	int x, y;

	for (x = y = 0; x != siz; ++x) {
		if (dat[x] == 13 || dat[x] == 0) {
			;
		} else if (dat[x] == 8 || dat[x] == 127) {
			if (y) {
				--y;
			} else {
				pset(q, r);
				prgetc(q);
				bdel(q, r);
				--byte;
			}
		} else if (dat[x] == 7) {
			ttputc(7);
		} else {
			bf[y++] = dat[x];
		}
	}
	if (y) {
		binsm(r, bf, y);
	}
	prm(r);
	prm(q);

	cfollow(b,byte);
	undomark();
}
Esempio n. 14
0
void box(int xx1, int yy1, int x2, int y2, int color) {
    int i,x,y,w,h;
    x=xx1<x2?xx1:x2;
    y=yy1<y2?yy1:y2;
    w=abs(x2-xx1);
    h=abs(y2-yy1);
    for(i=x; i<=x+w; i++) {
        pset(i,y,color);
        pset(i,y+h,color);
    }
    for(i=y; i<=y+h; i++) {
        pset(x,i,color);
        pset(x+w,i,color);
    }
    expose();
}
Esempio n. 15
0
//////////////////////////////////////////////////////////////////////////////
// Name:                         displayCells
// Purpose:
//    Display all cells based on their current states.
// Parameters: None
// Returns:    None
void displayCells()
{

    unsigned int w, h;

    // Display Cells
    for (h = 0; h < HEIGHT; h++)
        for (w = 0; w < WIDTH; w++)
        {
            if (Cells[w][h].state == STATE_ALIVE)
                pset(w, h, CELL_COLOR);
            else
                pset(w, h, BG_COLOR);
        }
    return;
}
Esempio n. 16
0
static int IDASpbcgSetup(IDAMem IDA_mem, 
                         N_Vector yy_p, N_Vector yp_p, N_Vector rr_p, 
                         N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
{
  int retval;
  IDASpilsMem idaspils_mem;

  idaspils_mem = (IDASpilsMem) lmem;

  /* Call user setup routine pset and update counter npe */
  retval = pset(tn, yy_p, yp_p, rr_p, cj, pdata,
                tmp1, tmp2, tmp3);
  npe++;

  if (retval < 0) {
    IDAProcessError(IDA_mem, SPBCG_PSET_FAIL_UNREC, "IDASPBCG", "IDASpbcgSetup", MSGS_PSET_FAILED);
    last_flag = SPBCG_PSET_FAIL_UNREC;
    return(-1);
  }
  if (retval > 0) {
    last_flag = SPBCG_PSET_FAIL_REC;
    return(+1);
  }

  last_flag = SPBCG_SUCCESS;

  return(0);
}
Esempio n. 17
0
int unextpos(W *w, int k)
{
	BW *bw;
	WIND_BW(bw, w);

      lp:
	if (curpos->link.next != &pos && curpos != &pos) {
		curpos = curpos->link.next;
		if (!curpos->p || !curpos->w) {
			goto lp;
		}
		if (!(curpos->w->watom->what & (TYPETW|TYPEPW)))
			goto lp;
		bw = (BW *)curpos->w->object;
		if (bw->b != curpos->p->b)
			goto lp;
		if (w->t->curwin == curpos->w && curpos->p->byte == ((BW *) w->t->curwin->object)->cursor->byte) {
			goto lp;
		}
		if (w->t->curwin != curpos->w) {
			w->t->curwin = curpos->w;
			if (w->t->curwin->y == -1) {
				wfit(w->t);
			}
		}
		w = w->t->curwin;
		bw = (BW *) w->object;
		if (bw->cursor->byte != curpos->p->byte) {
			pset(bw->cursor, curpos->p);
		}
		return 0;
	} else {
		return -1;
	}
}
Esempio n. 18
0
void fire()									/********火焰动画********/
{
	unsigned int x,y,c;
	setmode();
	for (x=1;x<=32;x++)
	{
		setpal(x,    x*2-1, 0,     0    );
		setpal(x+32, 63,    x*2-1, 0    );
		setpal(x+64, 63,    63,    x*2-1);
		setpal(x+96, 63,    63,    63   );
	}

	while(bioskey(1)==0)
	{
		for (x=0;x<320;x+=2)
		{
			for (y=1;y<=202;y+=2)
			{
				c=(point(x,y)+point(x+2,y)+point(x,y+2)+point(x+2,y+2))>>2;
				if (c--)
				{
					poke(0xa000,(y-2)*320+x,(c<<8)+c);
					poke(0xa000,(y-1)*320+x,(c<<8)+c);
				}
			}
		y-=2;
		pset(x,y,random(320));
		}
	}
	getch();
	closemode();
}
Esempio n. 19
0
int do_interface(void)
{
    int i = 0;
    int pcm = 0;
    int pno = 0;
    int recv_length = 0;
    float val = 0;
    unsigned char buf[128];

    InitUart2(9600);
    //InitUart2(115200);

    while(1)
    {
        SendUart2("123456789012345678901234", 20);
        recv_length = RecvUart2(buf, 128);
        pset(1, 1, 1);
        sleep(1);
        //SendUart2("test uart2", 10);
        SendUart2("123456789012345678901234", 20);
        recv_length = RecvUart2(buf, 128);
        pset(1, 2, 1);
        sleep(1);
        //SendUart2("test uart2", 10);
        SendUart2("123456789012345678901234", 20);
        recv_length = RecvUart2(buf, 128);
        pset(1, 3, 1);
        sleep(1);
        //SendUart2("test uart2", 10);
        SendUart2("123456789012345678901234", 20);
        recv_length = RecvUart2(buf, 128);
        pset(1, 4, 1);
        sleep(1);
    }

    val = pget(1, 1);
    printf("val = %f\n", val);
    val = pget(1, 2);
    printf("val = %f\n", val);
    val = pget(1, 3);
    printf("val = %f\n", val);
    val = pget(1, 4);
    printf("val = %f\n", val);

    printf("short = %d\n", sizeof(unsigned short));
}
Esempio n. 20
0
void bmp24::resize(int w, int h, unsigned bc) {
  w=(w+3)&~3;
  size=w*3*h;
  unsigned char* nd=new unsigned char[size];
  for(int y=0; y<height && y<h; y++)
    memcpy(nd+y*w*3,data+y*width*3,(w<width?w:width)*3);
  delete data; data=nd;
  int oldw=width, oldh=height;
  width=w; height=h;
  for(int y=0; y<oldh; y++)
    for(int x=oldw; x<width; x++)
      pset(x,y,bc);
  for(int y=oldh; y<height; y++)
    for(int x=0; x<width; x++)
      pset(x,y,bc);
  flen=offs+size;
}
Esempio n. 21
0
void aftermove(W *w, P *p)
{
	if (pos.link.prev != &pos && pos.link.prev->w == w && pos.link.prev->p && oabs(pos.link.prev->p->line - p->line) < 3) {
		poffline(pset(pos.link.prev->p, p));
	} else {
		markpos(w, p);
	}
}
Esempio n. 22
0
void draw(void *_prms)
{
  param_set *p = (param_set *) _prms;
  static double y[2 * WD], v[2 * WD];
  int i;
  static int poincare = 0;

  for (i = 0; i < 2 * WD - 1; i++) {
    y[i] = y[i + 1];
    v[i] = v[i + 1];
  }
  y[2 * WD - 1] = p->r[0];
  v[2 * WD - 1] = p->r[1];

  /* y-t chart */
  gclr(*p->win);
  newcolor(*p->win, "gold");
  drawline(*p->win, MG, 0, 2 * WD + MG, 0);
  newcolor(*p->win, ECTRL_FGCOLOR);
  for (i = 0; i < 2 * WD; i++) {
    pset(*p->win, MG + i, y[i] * HT * SCY);
  }
  copylayer(*p->win, 1, 0);

  /* phase chart */
  if (*p->clr2 == 1) {
    gclr(*p->win2);
    *p->clr2 = 0;
  }
  for (i = 0; i < 2 * WD; i++) {
    pset(*p->win2, y[i] * HT * SCY, v[i] * SCV);
  }
  copylayer(*p->win2, 1, 0);

  /* poincare chart */
  if (*p->clr3 == 1) {
    gclr(*p->win3);
    *p->clr3 = 0;
  }
  if (poincare % 50 == 0) {
    pset(*p->win3, y[2 * WD - 1] * HT * SCY, v[2 * WD - 1] * SCV);
    copylayer(*p->win3, 1, 0);
  }
  poincare++;
}
Esempio n. 23
0
/*
 * Initialize the Macintosh lomem variables, or some of them anyways.
 * Debugging weird errors revealed that A/UX actually cares about
 * some of them.
 */
static void _init_macintosh_lomem_globals (const uint32_t offset)
{
    /*
     * FIXME: explain what I'm doing here
     */
    
    uint32_t i;
    
    // Fill the entire lomem space with 0xBB to make debugging easier
    // if somebody tries to read an uninitialized lomem value
//    for (i=0; i<0x4000; i++)
//        pset(offset + i, 1, 0xBB);
    
    // There are the lomem globals that matter, apparently
    
    pset(offset+0x12f, 1, 0x02);       // CPUFlag = 0x02 (MC68020)
    pset(offset+0x31a, 4, 0x00ffffff); // Lo3Bytes (always 0x00ffffff)
    pset(offset+0x28e, 2, 0x3fff);     // ROM85 (always 0x3fff, I think?)
    // universal info ptr. is allowed to be null on Mac II, (I THINK)
    pset(offset+0xdd8, 4, 0);
    pset(offset+0x1d4, 4, 0x50000000); // VIA (via1 ptr)
    pset(offset+0x1d8, 4, 0x50004000); // SCC
    
    #define hwCbSCSI (1<<15)
    #define hwCbClock (1<<14)
    #define hwCbExPRAM (1<<13)
    #define hwCbFPU (1<<12)
    #define hwCbMMU (1<<11)
    #define hwCbADB (1<<10)
    #define hwCbAUX (1<<9) /* not sure if I need to set this one */
    const uint16_t HWCfgFlags = hwCbSCSI | hwCbClock | hwCbFPU | hwCbMMU | hwCbADB;
    pset(offset+0xb22, 2, HWCfgFlags); // HWCfgFlags
}
Esempio n. 24
0
void HBase::writeVector3Data(const char * dataName, unsigned count, Vector3F *value, HDataset::SelectPart * part)
{
    VerticesHDataset pset(dataName);
	pset.setNumVertices(count);	
	pset.open(fObjectId);

	if(!pset.write((char *)value, part)) std::cout<<dataName<<" write failed";
	pset.close();
}
Esempio n. 25
0
void HBase::writeCharData(const char * dataName, unsigned count, char *value, HDataset::SelectPart * part)
{
	HCharData pset(dataName);
	pset.setNumChars(count);	
	pset.open(fObjectId);

	if(!pset.write((char *)value, part)) std::cout<<dataName<<" write failed";
	pset.close();
}
Esempio n. 26
0
main(int argc,char *argv[])
{
	int	minr=999,ming=999,minb=999;
	int	maxr=0,maxg=0,maxb=0;
	int	a,b,c;
	int	xr,xg,xb;
	int	div=1;
	int	x,y;
	long	start=0;
	char far *vram=(char far *)0xa0000000;
	FILE	*f1;
	if(argc==1)
	{
		printf("usage: VIEWPAL <filename> [byte to start] [4 to divide]\n");
		return(0);
	}
	f1=fopen(argv[1],"rb");
	if(f1==NULL) return(0);
	if(argc>=3) start=atol(argv[2]);
	if(argc>=4) { div=4; }
	fseek(f1,start,SEEK_SET);
	reg.x.ax=0x13;
	int86(0x10,&reg,&reg);
	
	for(y=0;y<16;y++) for(x=0;x<16;x++)
	{
		a=x*16+y;
		for(b=0;b<4;b++) for(c=0;c<4;c++)
		{
			pset(x*4+b,y*4+c,a);
		}
	}
	outp(0x3c8,0);
	for(a=0;a<256;a++)
	{
		xr=getc(f1)/div;
		xg=getc(f1)/div;
		xb=getc(f1)/div;
		outp(0x3c9,xr);
		outp(0x3c9,xg);
		outp(0x3c9,xb);
		if(xr<minr) minr=xr;
		if(xg<ming) ming=xg;
		if(xb<minb) minb=xb;
		if(xr>maxr) maxr=xr;
		if(xg>maxg) maxg=xg;
		if(xb>maxb) maxb=xb;
	}
	fclose(f1);
	
	getch();
	reg.x.ax=0x3;
	int86(0x10,&reg,&reg);
	printf("Min: R:%-3i G:%-3i B:%-3i\n",minr,ming,minb);
	printf("Max: R:%-3i G:%-3i B:%-3i\n",maxr,maxg,maxb);
}
Esempio n. 27
0
static void cdata(B *b, unsigned char *dat, int siz)
{
	if (b->vt) { /* ANSI terminal emulator */
		MACRO *m;
		do {
			cready(b, b->vt->vtcur->byte);

			m = vt_data(b->vt, &dat, &siz);

			cfollow(b, b->vt, b->vt->vtcur->byte);
			undomark();
			if (m) {
				/* only do this if cursor is on window */
				if ((maint->curwin->watom->what & TYPETW) && ((BW *)maint->curwin->object)->b == b) {
					exmacro(m, 1);
					edupd(1);
				}
				rmmacro(m);
			}
		} while (m);
	} else { /* Dumb terminal */
		P *q = pdup(b->eof, USTR "cdata");
		P *r = pdup(b->eof, USTR "cdata");
		off_t byte = q->byte;
		unsigned char bf[1024];
		int x, y;
		cready(b, byte);
		for (x = y = 0; x != siz; ++x) {
			if (dat[x] == 13 || dat[x] == 0) {
				;
			} else if (dat[x] == 8 || dat[x] == 127) {
				if (y) {
					--y;
				} else {
					pset(q, r);
					prgetc(q);
					bdel(q, r);
					--byte;
				}
			} else if (dat[x] == 7) {
				ttputc(7);
			} else {
				bf[y++] = dat[x];
			}
		}
		if (y) {
			binsm(r, bf, y);
		}
		prm(r);
		prm(q);
		cfollow(b, NULL, b->eof->byte);
		undomark();
	}
}
Esempio n. 28
0
void gen(int m, int p)  {
	if(m > k)  {
		pset();
		return;
	}

	for(int i = p + 1; i <= n; ++i)  {
		a[m] = i;
		gen(m + 1, i);
		a[m] = 0;
	}
}
Esempio n. 29
0
char HBase::readCharData(const char * dataName, unsigned count, char *dst, HDataset::SelectPart * part)
{
	HCharData pset(dataName);
	pset.setNumChars(count);
	if(!pset.open(fObjectId)) {
		std::cout<<dataName<<" open failed";
		return 0;
	}
	pset.read((char *)dst, part);
	pset.close();
	return 1;
}
Esempio n. 30
0
static uint32_t _load_aux_kernel(shoebill_control_t *control, coff_file *coff, uint32_t *_pc)
{
    uint32_t j, i, pc = 0xffffffff;
    for (i = 0; i < coff->num_sections; i++) {
        coff_section *s = &coff->sections[i];
        
        // Don't load a "copy" segment
        if (s->flags & coff_copy)
            continue;
        
        if ((s->flags & coff_text) || (s->flags & coff_data)) {
            /* copy text or data section */
            
            for (j = 0; j < s->sz; j++)
                pset(s->p_addr+j, 1, s->data[j]);
            
            if (strcmp(s->name, "pstart") == 0)
                pc = s->p_addr;
        }
        else if (s->flags & coff_bss) {
            /* Create an empty .bss segment */
            
            for (j = 0; j < s->sz; j++)
                pset(s->p_addr+j, 1, 0);
        }
    }
    
    if (pc == 0xffffffff) {
        sprintf(control->error_msg, "This unix kernel doesn't contain a pstart segment\n");
        return 0;
    }

    *_pc = pc; // Entry point to the kernel
    
    return 1;
    
fail:
    return 0;
}