Esempio n. 1
0
void draw_box(Var* obj, int x, int y, float ignore, char* out)
{
	int i, j, k;
	int v;

	for (j = 0; j < y; j++) {
		for (i = 0; i < x; i++) {
			v = extract_int(obj, cpos(i, j, 0, obj));
			if (v != ignore && v > 0) {
				for (k = -v; k <= v; k++) {
					if (i + k >= 0 && i + k < x) {
						if (j - v >= 0 && j - v < y) {
							out[cpos(i + k, j - v, 0, obj)] = 1;
						}
						if (j + v >= 0 && j + v < y) {
							out[cpos(i + k, j + v, 0, obj)] = 1;
						}
					}
					if (j + k >= 0 && j + k < y) {
						if (i - v >= 0 && i - v < x) {
							out[cpos(i - v, j + k, 0, obj)] = 1;
						}
						if (i + v >= 0 && i + v < x) {
							out[cpos(i + v, j + k, 0, obj)] = 1;
						}
					}
				}
			}
		}
	}
}
Esempio n. 2
0
File: pe.c Progetto: rosrad/go-rep
static void
addsymtable(void)
{
	IMAGE_SECTION_HEADER *h;
	int i, size;
	LSym *s;
	
	fh.NumberOfSymbols = sizeof(symlabels)/sizeof(symlabels[0]);
	size = nextsymoff + 4 + 18*fh.NumberOfSymbols;
	h = addpesection(".symtab", size, size);
	h->Characteristics = IMAGE_SCN_MEM_READ|
		IMAGE_SCN_MEM_DISCARDABLE;
	chksectoff(h, cpos());
	fh.PointerToSymbolTable = cpos();
	
	// put COFF symbol table
	for (i=0; i<fh.NumberOfSymbols; i++) {
		s = linkrlookup(ctxt, symlabels[i], 0);
		strnput(s->name, 8);
		lputl(datoff(s->value));
		wputl(textsect);
		wputl(0x0308);  // "array of structs"
		cput(2);        // storage class: external
		cput(0);        // no aux entries
	}

	// put COFF string table
	lputl(nextsymoff + 4);
	for (i=0; i<nextsymoff; i++)
		cput(symnames[i]);
	strnput("", h->SizeOfRawData - size);
}
Esempio n. 3
0
void
elfrelocsect(Section *sect, Sym *first)
{
	Sym *sym, *rs;
	int32 eaddr;
	Reloc *r;
	int64 add;

	// If main section is SHT_NOBITS, nothing to relocate.
	// Also nothing to relocate in .shstrtab.
	if(sect->vaddr >= sect->seg->vaddr + sect->seg->filelen)
		return;
	if(strcmp(sect->name, ".shstrtab") == 0)
		return;

	sect->reloff = cpos();
	for(sym = first; sym != nil; sym = sym->next) {
		if(!sym->reachable)
			continue;
		if(sym->value >= sect->vaddr)
			break;
	}
	
	eaddr = sect->vaddr + sect->len;
	for(; sym != nil; sym = sym->next) {
		if(!sym->reachable)
			continue;
		if(sym->value >= eaddr)
			break;
		cursym = sym;
		
		for(r = sym->r; r < sym->r+sym->nr; r++) {
			// Ignore relocations handled by reloc already.
			switch(r->type) {
			case D_SIZE:
				continue;
			case D_ADDR:
			case D_PCREL:
				if(r->sym->type == SCONST)
					continue;
				break;
			}

			add = r->add;
			rs = r->sym;
			while(rs->outer != nil) {
				add += rs->value - rs->outer->value;
				rs = rs->outer;
			}
				
			if(rs->elfsym == 0)
				diag("reloc %d to non-elf symbol %s (rs=%s) %d", r->type, r->sym->name, rs->name, rs->type);

			if(elfreloc1(r, sym->value - sect->vaddr + r->off, rs->elfsym, add) < 0)
				diag("unsupported obj reloc %d/%d to %s", r->type, r->siz, r->sym->name);
		}
	}
		
	sect->rellen = cpos() - sect->reloff;
}	
Esempio n. 4
0
Var* ff_fft(vfuncptr func, Var* arg)
{
	Var *real = NULL, *img = NULL;
	double* data;
	int i, j, n, x, y, z;
	COMPLEX *in, *out;

	Alist alist[4];
	alist[0]      = make_alist("real", ID_VAL, NULL, &real);
	alist[1]      = make_alist("img", ID_VAL, NULL, &img);
	alist[2].name = NULL;

	if (parse_args(func, arg, alist) == 0) return (NULL);

	if (real == NULL && img == NULL) {
		parse_error("%s: No real or imaginary objects specified\n", func->name);
		return (NULL);
	}
	x = GetSamples(V_SIZE(real), V_ORG(real));
	y = GetLines(V_SIZE(real), V_ORG(real));
	z = GetBands(V_SIZE(real), V_ORG(real));

	if (img == NULL && x == 2) {
		n   = y * z;
		in  = (COMPLEX*)calloc(n, sizeof(COMPLEX));
		out = (COMPLEX*)calloc(n, sizeof(COMPLEX));
		for (i = 0; i < y; i++) {
			for (j = 0; j < z; j++) {
				in[i].re = extract_double(real, cpos(0, i, j, real));
				in[i].im = extract_double(real, cpos(1, i, j, real));
			}
		}
	} else {
		n   = V_DSIZE(real);
		in  = (COMPLEX*)calloc(n, sizeof(COMPLEX));
		out = (COMPLEX*)calloc(n, sizeof(COMPLEX));
		for (i = 0; i < n; i++) {
			in[i].re = extract_double(real, i);
			in[i].im = (img == NULL ? 0.0 : extract_double(img, i));
		}
	}

	if (func->fdata == (void*)1) {
		fft(in, n, out);
	} else {
		rft(in, n, out);
	}

	data = (double*)calloc(n * 2, sizeof(double));

	for (i = 0; i < n; i++) {
		data[i * 2]     = out[i].re;
		data[i * 2 + 1] = out[i].im;
	}
	return (newVal(BSQ, 2, n, 1, DV_DOUBLE, data));
}
Esempio n. 5
0
// Third   Step      of     the    saito   algorithm     using      the
//[Meijster/Roerdnik/Hesselink] optimization
void phaseSaitoZ(Var* vxy, Var* vxyz)
{
	int dx       = GetX(vxy);
	int dy       = GetY(vxy);
	int* sdt_xy  = V_DATA(vxy);
	int* sdt_xyz = V_DATA(vxyz);
	int x, y;
	for (y = 0; y < dy; y++) {
		for (x = 0; x < dx; x++) {
			sdt_xyz[cpos(x, y, 0, vxyz)] = sqrt(F(0, 0, sdt_xy[cpos(x, y, 0, vxy)]));
		}
	}
}
Esempio n. 6
0
/* Reset modes */
void lmode(void)
{
    switch(parry[0])
    {
    case 1:
        mapplication=0;
        break;
    case 3:
        ttyinit();
        break;
    case 4:
        minsert=0;
        break;
    case 6:
        dowrap=0;
        minmargins=0;
        parry[0]=0;
        parry[1]=0;
        pos();
        break;
    case 7:
        dowrap=0;
        mautowrap=0;
        break;
    case 20:
        mnl=0;
        break;
    case 25:
        minvisable=1;
        cpos(width,height);
        break;
    }
}
Esempio n. 7
0
/* Cursor left */
void left(void)
{
    if(!parry[0]) ++parry[0];
    if(parry[0]>x) x=0;
    else x-=parry[0];
    if(!minvisable) cpos(x,y);
}
Esempio n. 8
0
int read_editor_help (void)
{
   FILE *fp;
   int i;
   char linea[128];

   strcpy (linea, text_path);
   strcat (linea, "FSHELP");

   if ((fp = get_system_file (linea)) == NULL) {
      strcpy (linea, config->glob_text_path);
      strcat (linea, "FSHELP");

      if ((fp = get_system_file (linea)) == NULL)
         return (0);
   }

   i = 6;

   while (fgets (linea, 120, fp) != NULL) {
      while (strlen (linea) > 0 && (linea[strlen (linea) - 1] == 0x0D || linea[strlen (linea) - 1] == 0x0A))
         linea[strlen (linea) -1] = '\0';

      cpos (i++, (usr.width ? (usr.width - 1) : 79) - strlen (linea));
      m_print ("\026\001\007%s", linea);
   }

   fclose (fp);
   input (linea, 0);

   return (-1);
}
Esempio n. 9
0
int
c_changed_pos (struct changed_pos *cp0, struct changed_pos *cp1)
{
  int c = cpos (&cp0->p, &cp1->p);
  if (c) return c;
  else return cint ((int *) &cp0->reason, (int *) &cp1->reason);
}
Esempio n. 10
0
void edupd(int flg)
{
	W *w;
	int wid, hei;

	if (dostaupd) {
		staupd = 1;
		dostaupd = 0;
	}
	ttgtsz(&wid, &hei);
	if (nresize(maint->t, wid, hei)) {
		sresize(maint);
#ifdef MOUSE_GPM
		gpm_mx = wid;
		gpm_my = hei;
#endif
	}
	dofollows();
	ttflsh();
	nscroll(maint->t, BG_COLOR(bg_text));
	help_display(maint);
	w = maint->curwin;
	do {
		if (w->y != -1) {
			if (w->object && w->watom->disp)
				w->watom->disp(w->object, flg);
			msgout(w);
		}
		w = (W *) (w->link.next);
	} while (w != maint->curwin);
	cpos(maint->t, maint->curwin->x + maint->curwin->curx, maint->curwin->y + maint->curwin->cury);
	staupd = 0;
}
Esempio n. 11
0
/**
* @brief Finds the queued command that would be canceled by the Command c
* @return An iterator located at the command, or commandQue.end() if no such queued command exsists
**/
std::deque<Command>::iterator CCommandAI::GetCancelQueued(Command &c){
	if(!commandQue.empty()){
		std::deque<Command>::iterator ci=commandQue.end();
		do{
			--ci;			//iterate from the end and dont check the current order
			if((ci->id==c.id || (c.id<0 && ci->id<0)) && ci->params.size()==c.params.size()){
				if(c.params.size()==1){			//we assume the param is a unit of feature id
					if(ci->params[0]==c.params[0]){
						return ci;
					}
				} else if(c.params.size()>=3){		//we assume this means that the first 3 makes a position
					float3 cpos(c.params[0],c.params[1],c.params[2]);
					float3 cipos(ci->params[0],ci->params[1],ci->params[2]);
					if(c.id < 0){
						UnitDef* u1 = unitDefHandler->GetUnitByID(-c.id);
						UnitDef* u2 = unitDefHandler->GetUnitByID(-ci->id);
						if(u1 && u2
							&& fabs(cpos.x-cipos.x)*2 <= max(u1->xsize, u2->xsize)*SQUARE_SIZE
							&& fabs(cpos.z-cipos.z)*2 <= max(u1->ysize, u2->ysize)*SQUARE_SIZE)
						{
							return ci;
						}
					} else {
                        if((cpos-cipos).SqLength2D()<17*17){
							return ci;
						}
					}
				}
			}
		}while(ci!=commandQue.begin());
	}
	return commandQue.end();
}
Esempio n. 12
0
void AcceptDialog::_update_child_rect() {
	Size2 label_size=label->get_minimum_size();
	if (label->get_text().empty()) {
		label_size.height = 0;
	}
	int margin = get_constant("margin","Dialogs");
	Size2 size = get_size();
	Size2 hminsize = hbc->get_combined_minimum_size();

	Vector2 cpos(margin,margin+label_size.height);
	Vector2 csize(size.x-margin*2,size.y-margin*3-hminsize.y-label_size.height);

	if (child) {

		child->set_pos(cpos);
		child->set_size(csize);
	}

	cpos.y+=csize.y+margin;
	csize.y=hminsize.y;

	hbc->set_pos(cpos);
	hbc->set_size(csize);

}
Esempio n. 13
0
File: pe.c Progetto: rosrad/go-rep
void
addpersrc(void)
{
	IMAGE_SECTION_HEADER *h;
	uchar *p;
	uint32 val;
	Reloc *r;

	if(rsrcsym == nil)
		return;
	
	h = addpesection(".rsrc", rsrcsym->size, rsrcsym->size);
	h->Characteristics = IMAGE_SCN_MEM_READ|
		IMAGE_SCN_MEM_WRITE | IMAGE_SCN_CNT_INITIALIZED_DATA;
	chksectoff(h, cpos());
	// relocation
	for(r=rsrcsym->r; r<rsrcsym->r+rsrcsym->nr; r++) {
		p = rsrcsym->p + r->off;
		val = h->VirtualAddress + r->add;
		// 32-bit little-endian
		p[0] = val;
		p[1] = val>>8;
		p[2] = val>>16;
		p[3] = val>>24;
	}
	cwrite(rsrcsym->p, rsrcsym->size);
	strnput("", h->SizeOfRawData - rsrcsym->size);

	// update data directory
	dd[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = h->VirtualAddress;
	dd[IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = h->VirtualSize;
}
Esempio n. 14
0
/* Cursor right */
void right(void)
{
    if(!parry[0]) ++parry[0];
    x+=parry[0];
    if(x>=width) x=width-1;
    if(!minvisable) cpos(x,y);
}
Esempio n. 15
0
void fullscreen_editor (void)
{
   char *p = "\026\001\020\234^X=Down  ^E=Up  ^S=Left  ^D=Right  ^Z=Save  ^K?=Help";

   cls();

   change_attr (BLUE|_LGREY);
   del_line ();
   m_print (" * %s\n", sys.msg_name);

   msg_attrib (&msg, last_msg + 1, 0, 0);

   change_attr (RED|_BLUE);
   del_line ();
   cpos (5, (usr.width ? usr.width : 80) - strlen (p) - 1 + 4);
   m_print (p);

   change_attr (CYAN|_BLACK);
   m_print (bbstxt[B_ONE_CR]);

   fulleditor = 1;
   XON_DISABLE ();
   _BRK_DISABLE ();

   edit_file ("MSGTMP", usr.len - 5, usr.width ? (usr.width - 1) : 79);

   fulleditor = 0;
   XON_ENABLE ();
   _BRK_ENABLE ();
}
Esempio n. 16
0
/* Set modes */
void hmode(void)
{
    switch(parry[0])
    {
    case 1:
        mapplication=1;
        break;
    case 3:
        ttyinit();
        break;
    case 4:
        minsert=1;
        break;
    case 6:
        dowrap=0;
        minmargins=1;
        parry[0]=0;
        parry[1]=0;
        pos();
        break;
    case 7:
        mautowrap=1;
        break;
    case 20:
        mnl=1;
        break;
    case 25:
        minvisable=0;
        cpos(x,y);
        break;
    }
}
Esempio n. 17
0
void
codeblk(int64 addr, int64 size)
{
	LSym *sym;
	int64 eaddr, n;
	uchar *q;

	if(debug['a'])
		Bprint(&bso, "codeblk [%#x,%#x) at offset %#llx\n", addr, addr+size, cpos());

	blk(ctxt->textp, addr, size);

	/* again for printing */
	if(!debug['a'])
		return;

	for(sym = ctxt->textp; sym != nil; sym = sym->next) {
		if(!sym->reachable)
			continue;
		if(sym->value >= addr)
			break;
	}

	eaddr = addr + size;
	for(; sym != nil; sym = sym->next) {
		if(!sym->reachable)
			continue;
		if(sym->value >= eaddr)
			break;

		if(addr < sym->value) {
			Bprint(&bso, "%-20s %.8llux|", "_", (vlong)addr);
			for(; addr < sym->value; addr++)
				Bprint(&bso, " %.2ux", 0);
			Bprint(&bso, "\n");
		}

		Bprint(&bso, "%.6llux\t%-20s\n", (vlong)addr, sym->name);
		n = sym->size;
		q = sym->p;

		while(n >= 16) {
			Bprint(&bso, "%.6ux\t%-20.16I\n", addr, q);
			addr += 16;
			q += 16;
			n -= 16;
		}
		if(n > 0)
			Bprint(&bso, "%.6ux\t%-20.*I\n", addr, (int)n, q);
		addr += n;
	}

	if(addr < eaddr) {
		Bprint(&bso, "%-20s %.8llux|", "_", (vlong)addr);
		for(; addr < eaddr; addr++)
			Bprint(&bso, " %.2ux", 0);
	}
	Bflush(&bso);
}
Esempio n. 18
0
/* Cursor up */
void up(void)
{
    if(y<stop)
    {
        if(!parry[0]) ++parry[0];
        if(parry[0]>y) y=0;
        else y-=parry[0];
        if(!minvisable) cpos(x,y);
    }
    else
    {
        if(!parry[0]) ++parry[0];
        if(parry[0]>y-stop) y=stop;
        else y-=parry[0];
        if(!minvisable) cpos(x,y);
    }
}
Esempio n. 19
0
/* Cursor down */
void down(void)
{
    if(y>sbot)
    {
        if(!parry[0]) ++parry[0];
        y+=parry[0];
        if(y>=height) y=height-1;
        if(!minvisable) cpos(x,y);
    }
    else
    {
        if(!parry[0]) ++parry[0];
        y+=parry[0];
        if(y>sbot) y=sbot;
        if(!minvisable) cpos(x,y);
    }
}
Esempio n. 20
0
/* Backspace */
void bs(void)
{
    if(x)
    {
        --x;
        if(!minvisable) cpos(x,y);
    }
}
Esempio n. 21
0
/* Cursor to next tab stop */
void tab(void)
{
    if(dowrap) wrap();
    while(x!=width-1) if(tabs[++x]) goto done;
    dowrap=1;
done:
    if(!minvisable) cpos(x,y);
}
Esempio n. 22
0
void
elfrelocsect(Section *sect, Sym *first)
{
	Sym *sym;
	int32 eaddr;
	Reloc *r;

	// If main section is SHT_NOBITS, nothing to relocate.
	// Also nothing to relocate in .shstrtab.
	if(sect->vaddr >= sect->seg->vaddr + sect->seg->filelen)
		return;
	if(strcmp(sect->name, ".shstrtab") == 0)
		return;

	sect->reloff = cpos();
	for(sym = first; sym != nil; sym = sym->next) {
		if(!sym->reachable)
			continue;
		if(sym->value >= sect->vaddr)
			break;
	}
	
	eaddr = sect->vaddr + sect->len;
	for(; sym != nil; sym = sym->next) {
		if(!sym->reachable)
			continue;
		if(sym->value >= eaddr)
			break;
		cursym = sym;
		
		for(r = sym->r; r < sym->r+sym->nr; r++) {
			if(r->done)
				continue;
			if(r->xsym == nil) {
				diag("missing xsym in relocation");
				continue;
			}
			if(r->xsym->elfsym == 0)
				diag("reloc %d to non-elf symbol %s (outer=%s) %d", r->type, r->sym->name, r->xsym->name, r->sym->type);
			if(elfreloc1(r, sym->value+r->off - sect->vaddr) < 0)
				diag("unsupported obj reloc %d/%d to %s", r->type, r->siz, r->sym->name);
		}
	}
		
	sect->rellen = cpos() - sect->reloff;
}	
Esempio n. 23
0
void ScatterBiasArea(int roi, float scan_width, int steps, int samples, int qi_it, float angstep)
{
	std::vector<float> u=linspace(roi/2-scan_width/2,roi/2+scan_width/2, steps);
	
	QTrkComputedConfig cfg;
	cfg.width=cfg.height=roi;
	cfg.qi_angstep_factor = angstep;
	cfg.qi_iterations = qi_it;
	cfg.qi_angular_coverage = 0.7f;
	cfg.qi_roi_coverage = 1;
	cfg.qi_radial_coverage = 1.5f;
	cfg.qi_minradius=0;
	cfg.zlut_minradius=0;
	cfg.zlut_angular_coverage = 0.7f;
	cfg.zlut_roi_coverage = 1;
	cfg.zlut_radial_coverage = 1.5f;
	cfg.zlut_minradius = 0;
	cfg.qi_minradius = 0;
	cfg.com_bgcorrection = 0;
	cfg.xc1_profileLength = roi*0.8f;
	cfg.xc1_profileWidth = roi*0.2f;
	cfg.xc1_iterations = 1;
	cfg.Update();

	ImageData lut,orglut = ReadLUTFile("10x.radialzlut#4");
	vector3f ct(roi/2,roi/2,lut.h/2 + 0.123f);
	float dx = scan_width/steps;

	QueuedCPUTracker trk(cfg);
	ResampleLUT(&trk, &orglut, orglut.h, &lut);
	int maxval = 10000;

	ImageData tmp=ImageData::alloc(roi,roi);
	GenerateImageFromLUT(&tmp, &lut, 0, cfg.zlut_maxradius, vector3f(roi/2,roi/2,lut.h/2));
	ApplyPoissonNoise(tmp, maxval);

	std::string fn = SPrintf( "sb_area_roi%d_scan%d_steps%d_qit%d_N%d", roi, (int)scan_width, steps, qi_it, samples);
	WriteJPEGFile( (fn + ".jpg").c_str(), tmp);
	tmp.free();

	fn += ".txt";
	for (int y=0;y<steps;y++)  {
		for (int x=0;x<steps;x++)
		{
			vector3f cpos( (x+0.5f-steps/2) * dx, (y+0.5f-steps/2) * dx, 0 );

			cfg.qi_iterations = qi_it;
			auto r= AccBiasTest(orglut, &trk, samples, cpos+ct, vector3f(), 0, maxval, qi_it < 0 ? LT_XCor1D : 0);
			
			float row[] = { r.acc.x, r.acc.y, r.acc.z, r.bias.x, r.bias.y, r.bias.z,  r.crlb.x, r.crlb.z, samples };
			WriteArrayAsCSVRow(fn.c_str(), row, 9, x+y>0);

			dbgprintf("X=%d,Y=%d\n", x,y);
		}
	}
	orglut.free();
	lut.free();
}
Esempio n. 24
0
void ODE_Link::setAbsVelocity(hrp::Vector3& v, hrp::Vector3& w){
    dBodySetAngularVel(bodyId, w[0], w[1], w[2]);
    hrp::Vector3 p;
    hrp::Matrix33 R;
    getTransform(p, R);
    hrp::Vector3 cpos(R*C);
    hrp::Vector3 _v(v + w.cross(cpos));
    dBodySetLinearVel(bodyId, _v[0], _v[1], _v[2]);
}
Esempio n. 25
0
void draw_circle(Var* obj, int x, int y, float ignore, char* out)
{
	int i, j;
	int r;
	double f, ir;
	double c, s;
	int ic, js;

	for (j = 0; j < y; j++) {
		for (i = 0; i < x; i++) {
			r = extract_int(obj, cpos(i, j, 0, obj));
			if (r != ignore && r > 0) {
				ir = 1.0 / r;
				for (f = 0; f < M_PI_2; f += ir / 2) {
					c  = rint(cos(f) * r);
					s  = rint(sin(f) * r);
					ic = i + c;
					js = j + s;
					if (ic >= 0 && ic < x && js >= 0 && js < y) {
						out[cpos(ic, js, 0, obj)] = 1;
					}

					ic = i - c;
					js = j - s;
					if (ic >= 0 && ic < x && js >= 0 && js < y) {
						out[cpos(ic, js, 0, obj)] = 1;
					}

					ic = i + c;
					js = j - s;
					if (ic >= 0 && ic < x && js >= 0 && js < y) {
						out[cpos(ic, js, 0, obj)] = 1;
					}

					ic = i - c;
					js = j + s;
					if (ic >= 0 && ic < x && js >= 0 && js < y) {
						out[cpos(ic, js, 0, obj)] = 1;
					}
				}
			}
		}
	}
}
Esempio n. 26
0
File: pe.c Progetto: rosrad/go-rep
void
addexports(void)
{
	IMAGE_SECTION_HEADER *sect;
	IMAGE_EXPORT_DIRECTORY e;
	int size, i, va, va_name, va_addr, va_na, v;

	size = sizeof e + 10*nexport + strlen(outfile) + 1;
	for(i=0; i<nexport; i++)
		size += strlen(dexport[i]->extname) + 1;
	
	if (nexport == 0)
		return;
		
	sect = addpesection(".edata", size, size);
	sect->Characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA|IMAGE_SCN_MEM_READ;
	chksectoff(sect, cpos());
	va = sect->VirtualAddress;
	dd[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = va;
	dd[IMAGE_DIRECTORY_ENTRY_EXPORT].Size = sect->VirtualSize;

	va_name = va + sizeof e + nexport*4;
	va_addr = va + sizeof e;
	va_na = va + sizeof e + nexport*8;

	e.Characteristics = 0;
	e.MajorVersion = 0;
	e.MinorVersion = 0;
	e.NumberOfFunctions = nexport;
	e.NumberOfNames = nexport;
	e.Name = va + sizeof e + nexport*10; // Program names.
	e.Base = 1;
	e.AddressOfFunctions = va_addr;
	e.AddressOfNames = va_name;
	e.AddressOfNameOrdinals = va_na;
	// put IMAGE_EXPORT_DIRECTORY
	for (i=0; i<sizeof(e); i++)
		cput(((char*)&e)[i]);
	// put EXPORT Address Table
	for(i=0; i<nexport; i++)
		lputl(dexport[i]->value - PEBASE);		
	// put EXPORT Name Pointer Table
	v = e.Name + strlen(outfile)+1;
	for(i=0; i<nexport; i++) {
		lputl(v);
		v += strlen(dexport[i]->extname)+1;
	}
	// put EXPORT Ordinal Table
	for(i=0; i<nexport; i++)
		wputl(i);
	// put Names
	strnput(outfile, strlen(outfile)+1);
	for(i=0; i<nexport; i++)
		strnput(dexport[i]->extname, strlen(dexport[i]->extname)+1);
	strnput("", sect->SizeOfRawData - size);
}
Esempio n. 27
0
float interp_nn(float x1, float y1, Var* obj, float ignore)
{
	int w    = GetX(obj);
	int h    = GetY(obj);
	float ix = floor(x1);
	float iy = floor(y1);

	if (x1 < 0 || x1 >= w || y1 < 0 || y1 >= h) return (ignore);
	return (extract_float(obj, cpos(ix, iy, 0, obj)));
}
Esempio n. 28
0
void type(unsigned char c)
{
    if(dowrap) wrap();
    screen[x+y*width]=c+attrib;
    if(x!=width-1) {
        ++x;
        if(!minvisable) cpos(x,y);
    }
    else if(mautowrap) dowrap=1;
}
Esempio n. 29
0
Var* ff_radial_symmetry2(vfuncptr func, Var* arg)
{
	Var *obj = NULL, *rval = NULL;
	float ignore = FLT_MIN;
	float* out;
	int x, y, z, i, j;
	int size  = 0;
	int width = 0, height = 0;
	Window* w;

	Alist alist[9];
	alist[0]      = make_alist("object", ID_VAL, NULL, &obj);
	alist[1]      = make_alist("x", DV_INT32, NULL, &width);
	alist[2]      = make_alist("y", DV_INT32, NULL, &height);
	alist[3]      = make_alist("size", DV_INT32, NULL, &size);
	alist[4]      = make_alist("ignore", DV_FLOAT, NULL, &ignore);
	alist[5].name = NULL;

	if (parse_args(func, arg, alist) == 0) return (NULL);

	if (obj == NULL) {
		parse_error("%s: No object specified\n", func->name);
		return (NULL);
	}

	if (size) {
		width  = size;
		height = size;
	}

	if (width <= 0 || height <= 0) {
		parse_error("%s: Invalid size specified (%dx%d)\n", func->name, width, height);
		return (NULL);
	}

	x = GetX(obj);
	y = GetY(obj);
	z = GetZ(obj);
	w = create_window(width, height, DV_FLOAT);

	out  = calloc((size_t)x * (size_t)y, sizeof(float));
	rval = newVal(BSQ, x, y, 1, DV_FLOAT, out);

	for (i = 0; i < x; i += 1) {
		load_window(w, obj, i, 0, ignore);
		for (j = 0; j < y; j += 1) {
			if (j) roll_window(w, obj, i, j, ignore);

			out[cpos(i, j, 0, rval)] = radial_symmetry2(w->row, width, height, ignore);
		}
	}

	free_window(w);
	return (rval);
}
Esempio n. 30
0
static void
addexcept(IMAGE_SECTION_HEADER *text)
{
	IMAGE_SECTION_HEADER *pdata, *xdata;
	vlong startoff;
	uvlong n;
	LSym *sym;

	USED(text);
	if(thechar != '6')
		return;

	// write unwind info
	sym = linklookup(ctxt, "runtime.sigtramp", 0);
	startoff = cpos();
	lputl(9);	// version=1, flags=UNW_FLAG_EHANDLER, rest 0
	lputl(sym->value - PEBASE);
	lputl(0);

	n = cpos() - startoff;
	xdata = addpesection(".xdata", n, n);
	xdata->Characteristics = IMAGE_SCN_MEM_READ|
		IMAGE_SCN_CNT_INITIALIZED_DATA;
	chksectoff(xdata, startoff);
	strnput("", xdata->SizeOfRawData - n);

	// write a function table entry for the whole text segment
	startoff = cpos();
	lputl(text->VirtualAddress);
	lputl(text->VirtualAddress + text->VirtualSize);
	lputl(xdata->VirtualAddress);

	n = cpos() - startoff;
	pdata = addpesection(".pdata", n, n);
	pdata->Characteristics = IMAGE_SCN_MEM_READ|
		IMAGE_SCN_CNT_INITIALIZED_DATA;
	chksectoff(pdata, startoff);
	strnput("", pdata->SizeOfRawData - n);

	dd[IMAGE_DIRECTORY_ENTRY_EXCEPTION].VirtualAddress = pdata->VirtualAddress;
	dd[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size = pdata->VirtualSize;
}