コード例 #1
0
ファイル: plugin.c プロジェクト: magcius/plymouth
static void
view_free (view_t *view)
{
        ply_entry_free (view->entry);
        ply_label_free (view->message_label);
        free_stars (view);

        free (view);
}
コード例 #2
0
ファイル: bouboule.c プロジェクト: Bluerise/bitrig-xenocara
static void
free_bouboule(StarField *sp)
{
	free_stars(sp);
	sinfree(&(sp->x));
	sinfree(&(sp->y));
	sinfree(&(sp->z));
	sinfree(&(sp->sizex));
	sinfree(&(sp->sizey));
	sinfree(&(sp->thetax));
	sinfree(&(sp->thetay));
	sinfree(&(sp->thetaz));
}
コード例 #3
0
ファイル: room.c プロジェクト: oitofelix/mininim
void
draw_room (ALLEGRO_BITMAP *bitmap, int room,
           enum em em, enum vm vm)
{
  struct pos p; new_pos (&p, &global_level, room, -1, -1);

  for (p.floor = FLOORS; p.floor >= -1; p.floor--)
    for (p.place = -1; p.place < PLACES; p.place++) {
      draw_conbg (bitmap, &p, em, vm);
      free_stars (&p);
    }

  for (p.floor = FLOORS; p.floor >= -1; p.floor--)
    for (p.place = -1; p.place <= PLACES; p.place++)
      draw_confg (bitmap, &p, em, vm);
}
コード例 #4
0
ファイル: bouboule.c プロジェクト: Bluerise/bitrig-xenocara
void
init_bouboule(ModeInfo * mi)
/***************/

/*-
 *  The stars init part was first inspirated from the net3d game starfield
 * code.  But net3d starfield is not really 3d starfield, and I needed real 3d,
 * so only remains the net3d starfield initialization main idea, that is
 * the stars distribution on a sphere (theta and omega computing)
 */
{
	StarField  *sp;
	int         size = MI_SIZE(mi);
	int         i;
	double      theta, omega;

	if (starfield == NULL) {
		if ((starfield = (StarField *) calloc(MI_NUM_SCREENS(mi),
						sizeof (StarField))) == NULL)
			return;
	}
	sp = &starfield[MI_SCREEN(mi)];

	sp->width = MI_WIDTH(mi);
	sp->height = MI_HEIGHT(mi);

	/* use the right `black' pixel values: */
	if (MI_IS_INSTALL(mi) && MI_IS_USE3D(mi)) {
		MI_CLEARWINDOWCOLOR(mi, MI_NONE_COLOR(mi));
	} else {
		MI_CLEARWINDOW(mi);
	}

	if (size < -MINSIZE)
		sp->max_star_size = NRAND(-size - MINSIZE + 1) + MINSIZE;
	else if (size < MINSIZE)
		sp->max_star_size = MINSIZE;
	else
		sp->max_star_size = size;

	sp->NbStars = MI_COUNT(mi);
	if (sp->NbStars < -MINSTARS) {
		free_stars(sp);
		sp->NbStars = NRAND(-sp->NbStars - MINSTARS + 1) + MINSTARS;
	} else if (sp->NbStars < MINSTARS)
		sp->NbStars = MINSTARS;

	/* We get memory for lists of objects */
	if (sp->star == NULL) {
		if ((sp->star = (Star *) malloc(sp->NbStars *
				sizeof (Star))) == NULL) {
			free_bouboule(sp);
			return;
		}
	}
	if (sp->xarc == NULL) {
		if ((sp->xarc = (XArc *) malloc(sp->NbStars *
				sizeof (XArc))) == NULL) {
			free_bouboule(sp);
			return;
		}
	}
	if (MI_IS_USE3D(mi) && sp->xarcleft == NULL) {
		if ((sp->xarcleft = (XArc *) malloc(sp->NbStars *
				sizeof (XArc))) == NULL) {
			free_bouboule(sp);
			return;
		}
	}
#if ((USEOLDXARCS == 1) || (ADAPT_ERASE == 1))
	if (sp->oldxarc == NULL) {
		if ((sp->oldxarc = (XArc *) malloc(sp->NbStars *
				sizeof (XArc))) == NULL) {
			free_bouboule(sp);
			return;
		}
	}
	if (MI_IS_USE3D(mi) && sp->oldxarcleft == NULL) {
		if ((sp->oldxarcleft = (XArc *) malloc(sp->NbStars *
				sizeof (XArc))) == NULL) {
			free_bouboule(sp);
			return;
		}
	}
#endif

	{
		/* We initialize evolving variables */
		if (!sininit(&sp->x,
			NRAND(3142) / 1000.0, M_PI / (NRAND(100) + 100.0),
			((double) sp->width) / 4.0,
			3.0 * ((double) sp->width) / 4.0,
			POSCANRAND)) {
		    free_bouboule(sp);
		    return;
		}
		if (!sininit(&sp->y,
			NRAND(3142) / 1000.0, M_PI / (NRAND(100) + 100.0),
			((double) sp->height) / 4.0,
			3.0 * ((double) sp->height) / 4.0,
			POSCANRAND)) {
		    free_bouboule(sp);
		    return;
		}

		/* for z, we have to ensure that the bouboule does not get behind */
		/* the eyes of the viewer.  His/Her eyes are at 0.  Because the */
		/* bouboule uses the x-radius for the z-radius, too, we have to */
		/* use the x-values. */
		if (!sininit(&sp->z,
			NRAND(3142) / 1000.0, M_PI / (NRAND(100) + 100.0),
			((double) sp->width / 2.0 + MINZVAL),
			((double) sp->width / 2.0 + MAXZVAL),
			POSCANRAND)) {
		    free_bouboule(sp);
		    return;
		}


		if (!sininit(&sp->sizex,
			NRAND(3142) / 1000.0, M_PI / (NRAND(100) + 100.0),
			MIN(((double) sp->width) - sp->x.value,
			    sp->x.value) / 5.0,
			MIN(((double) sp->width) - sp->x.value,
			    sp->x.value),
			SIZECANRAND)) {
		    free_bouboule(sp);
		    return;
		}

		if (!sininit(&sp->sizey,
			NRAND(3142) / 1000.0, M_PI / (NRAND(100) + 100.0),
			MAX(sp->sizex.value / MAX_SIZEX_SIZEY,
			    sp->sizey.maximum / 5.0),
			MIN(sp->sizex.value * MAX_SIZEX_SIZEY,
			    MIN(((double) sp->height) -
				sp->y.value,
				sp->y.value)),
			SIZECANRAND)) {
		    free_bouboule(sp);
		    return;
		}

		if (!sininit(&sp->thetax,
			NRAND(3142) / 1000.0, M_PI / (NRAND(200) + 200.0),
			-M_PI, M_PI,
			THETACANRAND)) {
		    free_bouboule(sp);
		    return;
		}
		if (!sininit(&sp->thetay,
			NRAND(3142) / 1000.0, M_PI / (NRAND(200) + 200.0),
			-M_PI, M_PI,
			THETACANRAND)) {
		    free_bouboule(sp);
		    return;
		}
		if (!sininit(&sp->thetaz,
			NRAND(3142) / 1000.0, M_PI / (NRAND(400) + 400.0),
			-M_PI, M_PI,
			THETACANRAND)) {
		    free_bouboule(sp);
		    return;
		}
	}
	for (i = 0; i < sp->NbStars; i++) {
		Star       *star;
		XArc       *arc, *arcleft = (XArc *) NULL;

#if ((USEOLDXARCS == 1) || (ADAPT_ERASE == 1))
		XArc       *oarc, *oarcleft = (XArc *) NULL;

#endif

		star = &(sp->star[i]);
		arc = &(sp->xarc[i]);
		if (MI_IS_USE3D(mi))
			arcleft = &(sp->xarcleft[i]);
#if ((USEOLDXARCS == 1) || (ADAPT_ERASE == 1))
		oarc = &(sp->oldxarc[i]);
		if (MI_IS_USE3D(mi))
			oarcleft = &(sp->oldxarcleft[i]);
#endif
		/* Elevation and bearing of the star */
		theta = dtor((NRAND(1800)) / 10.0 - 90.0);
		omega = dtor((NRAND(3600)) / 10.0 - 180.0);

		/* Stars coordinates in a 3D space */
		star->x = cos(theta) * sin(omega);
		star->y = sin(omega) * sin(theta);
		star->z = cos(omega);

		/* We set the stars size */
		star->size = NRAND(2 * sp->max_star_size);
		if (star->size < sp->max_star_size)
			star->size = 0;
		else
			star->size -= sp->max_star_size;

		/* We set default values for the XArc lists elements, but offscreen */
		arc->x = MI_WIDTH(mi);
		arc->y = MI_HEIGHT(mi);
		if (MI_IS_USE3D(mi)) {
			arcleft->x = MI_WIDTH(mi);
			arcleft->y = MI_HEIGHT(mi);
		}
#if ((USEOLDXARCS == 1) || (ADAPT_ERASE == 1))
		oarc->x = MI_WIDTH(mi);
		oarc->y = MI_HEIGHT(mi);
		if (MI_IS_USE3D(mi)) {
			oarcleft->x = MI_WIDTH(mi);
			oarcleft->y = MI_HEIGHT(mi);
		}
#endif
		arc->width = 2 + star->size;
		arc->height = 2 + star->size;
		if (MI_IS_USE3D(mi)) {
			arcleft->width = 2 + star->size;
			arcleft->height = 2 + star->size;
		}
#if ((USEOLDXARCS == 1) || (ADAPT_ERASE == 1))
		oarc->width = 2 + star->size;
		oarc->height = 2 + star->size;
		if (MI_IS_USE3D(mi)) {
			oarcleft->width = 2 + star->size;
			oarcleft->height = 2 + star->size;
		}
#endif

		arc->angle1 = 0;
		arc->angle2 = 360 * 64;
		if (MI_IS_USE3D(mi)) {
			arcleft->angle1 = 0;
			arcleft->angle2 = 360 * 64;
		}
#if ((USEOLDXARCS == 1) || (ADAPT_ERASE == 1))
		oarc->angle1 = 0;
		oarc->angle2 = 360 * 64;	/* ie. we draw whole disks:
						 * from 0 to 360 degrees */
		if (MI_IS_USE3D(mi)) {
			oarcleft->angle1 = 0;
			oarcleft->angle2 = 360 * 64;
		}
#endif
	}

	if (MI_NPIXELS(mi) > 2)
		sp->colorp = NRAND(MI_NPIXELS(mi));
	/* We set up the starfield color */
	if (!MI_IS_USE3D(mi) && MI_NPIXELS(mi) > 2)
		sp->color = MI_PIXEL(mi, sp->colorp);
	else
		sp->color = MI_WHITE_PIXEL(mi);

#if (ADAPT_ERASE == 1)
	/* We initialize the adaptation code for screen erasing */
	sp->hasbeenchecked = ADAPT_CHECKS * 2;
	sp->rect_time = 0;
	sp->xarc_time = 0;
#endif
}