Пример #1
0
/* http://wvware.sourceforge.net/caolan/Polyline.html */
static GpStatus
Polyline (MetafilePlayContext *context, BYTE *data)
{
	GpStatus status;
	int p;
	/* variable number of parameters */
	SHORT num = GETS(WP1);

#ifdef DEBUG_WMF
	printf ("Polyline %d points", num);
#endif
	SHORT x1 = GETS(WP2);
	SHORT y1 = GETS(WP3);
	int n = 4;
	for (p = 1; p < num; p++) {
		SHORT x2 = GETS(WP(n));
		n++;
		SHORT y2 = GETS(WP(n));
		n++;
#ifdef DEBUG_WMF_2
		printf ("\n\tdraw from %d,%d to %d,%d", x1, y1, x2, y2);
#endif
		GpPen *pen = gdip_metafile_GetSelectedPen (context);
		status = GdipDrawLine (context->graphics, pen, x1, y1, x2, y2);
		if (status != Ok)
			return status;

		x1 = x2;
		y1 = y2;
	}
	return Ok;
}
Пример #2
0
t_qtrn	qtrn_external_prod(const t_qtrn *const a, const t_real s)
{
	t_qtrn	ans;

	ans.type = a->type;
	if (a->type == CARTHESIAN)
	{
		X(ans) = XP(a) * s;
		Y(ans) = YP(a) * s;
		Z(ans) = ZP(a) * s;
		W(ans) = WP(a) * s;
	}
	else if (a->type == CYLINDRICAL)
	{
		QR(ans) = QRP(a) * s;
		QTHETA(ans) = QTHETAP(a);
		Z(ans) = ZP(a) * s;
		W(ans) = WP(a) * s;
	}
	else
	{
		QRHO(ans) = QRHOP(a) * s;
		QTHETA(ans) = QTHETAP(a);
		QPHI(ans) = QPHIP(a);
		W(ans) = WP(a) * s;
	}
	return (ans);
}
Пример #3
0
t_real	qtrn_get_norm(const t_qtrn *const q)
{
	if (q->type == CARTHESIAN)
		return (XP(q) * XP(q) + YP(q) * YP(q)
			+ ZP(q) * ZP(q) + WP(q) * WP(q));
	else if (q->type == CYLINDRICAL)
		return (ZP(q) * ZP(q) + QRP(q) * QRP(q));
	else
		return (QRHOP(q));
}
Пример #4
0
t_qtrn	qtrn_get_conj(const t_qtrn *const q)
{
	if (q->type == CARTHESIAN)
		return (NEW_QTRN(-XP(q), -YP(q), -ZP(q), WP(q)));
	else if (q->type == CYLINDRICAL)
		return ((t_qtrn){CYLINDRICAL, {{
			QRP(q), QTHETAP(q) + M_PI, -ZP(q), WP(q)}}});
	else
		return ((t_qtrn){SPHERICAL, {{
			QRHOP(q), QTHETAP(q) + M_PI, QPHIP(q) + M_PI, WP(q)}}});
}
Пример #5
0
Файл: walker.c Проект: hvds/seq
whp new_walker(pp_pp* pp, mpz_t limit, int invsum) {
	whp wh;
	walker* w;
	walk_result* wr;
	int numsize = pp->valnumsize;

	wh = arena_size;
	w = WP(wh);
	arena_size += walker_charsize(numsize);
	grow_arena(w, arena_size);
	w->heap = mbh_new(I2P(wh), &mbh_compare_wr);
	w->pp = pp;
	w->numsize = numsize;
	w->adder = pp->adder;
	w->cmper = pp->cmper;
	w->invsum = invsum;
	w->vecsize = (pp->valsize + 31) >> 5;
	w->arenanext = (wrhp)0;
	w->have_previous = 0;
	mpx_set_z(w_limit(w), numsize, limit);

	w_pick_arena(w, wr);
	wr->invsum = 0;
	wr->nextbit = pp->valsize;
	mpx_set_ui(wr_next_discard(w, wr), numsize, 0);
	mpx_set_ui(wr_discard_direct(w, wr), numsize, 0);
	memset(wr_vec_direct(w, wr), 0, w->vecsize * sizeof(int));
	push_heap(w, wr);

	return wh;
}
Пример #6
0
A ga(I t, I r, I n, I *s) { I k=WP(t,r,n); A z=a_malloc(k);
    AT(z)=t; AC(z)=1; AR(z)=r; AN(z)=n;
    if (r==1)      { *AS(z)=n;        }
    else if (r&&s) { ICPY(AS(z),s,r); }
    gcpush(z);
    R z;
}
Пример #7
0
A gcinit(VO) { I k=WP(BOX,1,NOBJS); A memory;
    nmem=mtop=bytes=totbytes=0;
    memory=a_malloc(k);
    AT(memory)=BOX; AR(memory)=1;
    AN(memory)=*AS(memory)=NOBJS;
    objs=AAV(memory);
    R memory;
}
Пример #8
0
void	qtrn_external_mult(t_qtrn *const a, const t_real s)
{
	if (a->type == CARTHESIAN)
	{
		XP(a) *= s;
		YP(a) *= s;
		ZP(a) *= s;
		WP(a) *= s;
	}
	else if (a->type == CYLINDRICAL)
	{
		QRP(a) *= s;
		ZP(a) *= s;
		WP(a) *= s;
	}
	else
	{
		QRHOP(a) *= s;
		WP(a) *= s;
	}
}
Пример #9
0
Файл: walker.c Проект: hvds/seq
wrhp wr_clone(whp wh, wrhp wrh) {
	walker* w = WP(wh);
	walk_result *wr, *wr2;

	w_pick_arena(w, wr2);
	/* we may attempt to clone something already released to arena, in which
	 * case pick_arena may return the same address. If so, there's nothing
	 * to do */
	wr = WRP(wh, wrh);
	if (wr2 != wr)
		memcpy(wr2, wr, wr_charsize(w));
	return WRHP(w, wr2);
}
Пример #10
0
/* http://wvware.sourceforge.net/caolan/Polygon.html */
static GpStatus
Polygon (MetafilePlayContext *context, BYTE *data, int len)
{
	GpPointF *points, *pt;
	GpStatus status;
	int p;
	/* variable number of parameters */
	SHORT num = GETS(WP1);

	/* len (in WORDs) = num (WORD) + num * (x WORD + y WORD) */
	if (num > len + 1)
		return InvalidParameter;

#ifdef DEBUG_WMF
	printf ("Polygon %d points", num);
#endif
	points = (GpPointF*) GdipAlloc (num * sizeof (GpPointF));
	if (!points)
		return OutOfMemory;

	int n = 2;
	for (p = 0, pt = points; p < num; p++, pt++) {
		pt->X = GETS(WP(n));
		n++;
		pt->Y = GETS(WP(n));
		n++;
#ifdef DEBUG_WMF
		printf ("\n\tpoly to %g,%g", pt->X, pt->Y);
#endif
	}

	status = gdip_metafile_Polygon (context, points, num);

	GdipFree (points);
	return status;
}
Пример #11
0
void tms340x0_device::write_pixel_8(offs_t offset, UINT32 data) { WP(0x08, 0xff); }
Пример #12
0
void tms340x0_device::write_pixel_4(offs_t offset, UINT32 data) { WP(0x0c, 0x0f); }
Пример #13
0
void tms340x0_device::write_pixel_2(offs_t offset, UINT32 data) { WP(0x0e, 0x03); }
Пример #14
0
/* No Raster Op + No Transparency */
void tms340x0_device::write_pixel_1(offs_t offset, UINT32 data) { WP(0x0f, 0x01); }
Пример #15
0
/* storage isn't very efficient, # of polygons, size of each polygon, data for each polygon */
static GpStatus
PolyPolygon (MetafilePlayContext *context, BYTE *data)
{
	GpStatus status = Ok;
	/* variable number of parameters */
	int poly_num = GETW(WP1);
	int i, j;
	PointFList *list = GdipAlloc (poly_num * sizeof (PointFList));
	if (!list) {
		return OutOfMemory;
	}

	PointFList *current = list;
#ifdef DEBUG_WMF
	printf ("PolyPolygon has %d polygons", poly_num);
#endif
	int n = 2;
	/* read size of each polygon and allocate the required memory */
	for (i = 0; i < poly_num; i++) {
		current->num = GETW(WP(n));
		n++;
		current->points = (GpPointF*) GdipAlloc (current->num * sizeof (GpPointF));
		if (!current->points) {
			for (j = 0; j < i; j++) {
				GdipFree (list[j].points);
			}

			GdipFree (list);
			return OutOfMemory;
		}

#ifdef DEBUG_WMF_2
		printf ("\n\tSub Polygon #%d has %d points", i, current->num);
#endif
		current++;
	}

	/* read the points for each polygons */
	current = list;
	for (i = 0; i < poly_num; i++) {
		GpPointF *pt = current->points;
		int p;
		for (p = 0; p < current->num; p++) {
			pt->X = GETW(WP(n));
			n++;
			pt->Y = GETW(WP(n));
			n++;
#ifdef DEBUG_WMF_3
			printf ("\n\t\tpoly to %g,%g", pt->X, pt->Y);
#endif
			pt++;
		}

		GpStatus s = gdip_metafile_Polygon (context, current->points, current->num);
		if (s != Ok)
			status = s;

		/* free points */
		GdipFree (current->points);
		current++;
	}

	/* all points were freed, after being drawn, so we just have to free the polygon list*/
	GdipFree (list);
	return status;
}
Пример #16
0
Файл: walker.c Проект: hvds/seq
void delete_walker(whp wh) {
	walker* w = WP(wh);

	mbh_delete(w->heap);
	arena_size = wh;
}
Пример #17
0
void CMineView::InterpModelData(UINT8 *p) 
{
	assert(p);
	assert(gModel.polys);

	while (W(p) != OP_EOF) {
		switch (W(p)) {
			// Point Definitions with Start Offset:
			// 2  UINT16      n_points       number of points
			// 4  UINT16      start_point    starting point
			// 6  UINT16      unknown
			// 8  VMS_VECTOR  pts[n_points]  x,y,z data
			case OP_DEFP_START: {
				pt0 = W(p+4);
				n_points = W(p+2);
				gModel.n_points += n_points;
				assert(W(p+6)==0);
				assert(gModel.n_points < MAX_POLY_MODEL_POINTS);
				assert(pt0+n_points < MAX_POLY_MODEL_POINTS);
				for (pt=0;pt< n_points;pt++) {
					gModel.points[pt+pt0].x = VP(p+8)[pt].x + gOffset.x;
					gModel.points[pt+pt0].y = VP(p+8)[pt].y + gOffset.y;
					gModel.points[pt+pt0].z = VP(p+8)[pt].z + gOffset.z;
				}
				SetModelPoints(pt0,pt0+n_points);
				p += W(p+2)*sizeof(VMS_VECTOR) + 8;
				break;
			}
			// Flat Shaded Polygon:
			// 2  UINT16     n_verts
			// 4  VMS_VECTOR vector1
			// 16 VMS_VECTOR vector2
			// 28 UINT16     color
			// 30 UINT16     verts[n_verts]
			case OP_FLATPOLY: {
				panel = &gModel.polys[gModel.n_polys];
				panel->n_verts = W(p+2);
				panel->offset   = *VP(p+4);
				panel->normal   = *VP(p+16);
				for (pt=0;pt<panel->n_verts;pt++) {
					panel->verts[pt] = WP(p+30)[pt];
				}
				assert(panel->n_verts>=MIN_POLY_POINTS);
				assert(panel->n_verts<=MAX_POLY_POINTS);
				assert(gModel.n_polys < MAX_POLYS);
				DrawPoly(panel);
				p += 30 + ((panel->n_verts&~1)+1)*2;
				break;
			}
			// Texture Mapped Polygon:
			// 2  UINT16     n_verts
			// 4  VMS_VECTOR vector1
			// 16 VMS_VECTOR vector2
			// 28 UINT16     nBaseTex
			// 30 UINT16     verts[n_verts]
			// -- UVL        uvls[n_verts]
			case OP_TMAPPOLY: {
				panel = &gModel.polys[gModel.n_polys];
				panel->n_verts  = W(p+2);
				assert(panel->n_verts>=MIN_POLY_POINTS);
				assert(panel->n_verts<=MAX_POLY_POINTS);
				assert(gModel.n_polys < MAX_POLYS);
				panel->offset   = *VP(p+4);
				panel->normal   = *VP(p+16);
				panel->color    = -1;
				panel->nBaseTex = W(p+28);
				panel->glow_num = glow_num;
				for (pt=0;pt<panel->n_verts;pt++) {
					panel->verts[pt] = WP(p+30)[pt];
				}
				p += 30 + ((panel->n_verts&~1)+1)*2;
				DrawPoly(panel);
				p += panel->n_verts * 12;
				break;
			}
			// Sort by Normal
			// 2  UINT16      unknown
			// 4  VMS_VECTOR  Front Model normal
			// 16 VMS_VECTOR  Back Model normal
			// 28 UINT16      Front Model Offset
			// 30 UINT16      Back Model Offset
			case OP_SORTNORM: {
				/* = W(p+2); */
				/* = W(p+4); */
				/* = W(p+16); */
				assert(W(p+2)==0);
				assert(W(p+28)>0);
				assert(W(p+30)>0);
				if ( m_matrix.CheckNormal(gpObject, VP(p+4),VP(p+16)) ) {
				  InterpModelData(p + W(p+28));
				  InterpModelData(p + W(p+30));
				} else {
				  InterpModelData(p + W(p+30));
				  InterpModelData(p + W(p+28));
				}
				p += 32;
				break;
			}
			// Call a Sub Object
			// 2  UINT16     n_anims
			// 4  VMS_VECTOR offset
			// 16 UINT16     model offset
			case OP_SUBCALL: {
				assert(W(p+16)>0);
				/* = VP(p+4) */
				gOffset.x += VP(p+4)->x;
				gOffset.y += VP(p+4)->y;
				gOffset.z += VP(p+4)->z;
				InterpModelData(p + W(p+16));
				gOffset.x -= VP(p+4)->x;
				gOffset.y -= VP(p+4)->y;
				gOffset.z -= VP(p+4)->z;
				p += 20;
				break;
			}
			// Glow Number for Next Poly
			// 2 UINTW  Glow_Value
			case OP_GLOW: {
				glow_num = W(p+2);
				p += 4;
				break;
			}
			default: {
				assert(0);
			}
		}
	}
	return;
}
Пример #18
0
Файл: walker.c Проект: hvds/seq
inline int* wr_vec(whp wh, wrhp wrh) {
	return (int*)&WRP(wh, wrh)->tail[WP(wh)->numsize * 2];
}
Пример #19
0
Файл: walker.c Проект: hvds/seq
inline mpx_t wr_discard(whp wh, wrhp wrh) {
	return (mpx_t)&WRP(wh, wrh)->tail[WP(wh)->numsize];
}
Пример #20
0
Файл: walker.c Проект: hvds/seq
void wr_clone_free(whp wh, wrhp wrh) {
	w_free_arena(WP(wh), WRP(wh, wrh));
}