Ejemplo n.º 1
0
void draw_init_env()
{

	framebuffer_t frame;
	zbuffer_t z;

	packet_t *packet = packet_init(16,PACKET_NORMAL);

	qword_t *q = packet->data;

	frame.width = 640;
	frame.height = 448;
	frame.psm = GS_PSM_32;
	frame.mask = 0;
	frame.address = graph_vram_allocate(frame.width,frame.height,frame.psm,GRAPH_ALIGN_PAGE);

	z.enable = 0;
	z.method = ZTEST_METHOD_GREATER;
	z.address = 0;
	z.mask = 1;
	z.zsm = 0;

	graph_initialize(frame.address,640,448,GS_PSM_32,0,0);

	q = draw_setup_environment(q,0,&frame,&z);

	q = draw_finish(q);

	dma_channel_send_normal(DMA_CHANNEL_GIF,packet->data, q - packet->data, 0,0);
	dma_wait_fast();

	packet_free(packet);

}
Ejemplo n.º 2
0
void run_demo(packet_t *packet)
{

	int context = 0;

	vertex_t v0;

	color_t c0;
	color_t c1;

	texbuffer_t texbuf;
	clutbuffer_t clut;
	lod_t lod;

	packet_t *packets[2];
	packet_t *current;

	packets[0] = packet_init(10000,PACKET_NORMAL);
	packets[1] = packet_init(10000,PACKET_NORMAL);

	// Use linear filtering for good scaling results
	lod.calculation = LOD_USE_K;
	lod.max_level = 0;
	lod.mag_filter = LOD_MAG_LINEAR;
	lod.min_filter = LOD_MIN_LINEAR;
	lod.l = 0;
	lod.k = 0;

	texbuf.width = 512;
	texbuf.psm = GS_PSM_4;
	texbuf.address = myaddress;

	texbuf.info.width = draw_log2(512);
	texbuf.info.height = draw_log2(256);
	texbuf.info.components = TEXTURE_COMPONENTS_RGBA;
	texbuf.info.function = TEXTURE_FUNCTION_MODULATE;

	clut.storage_mode = CLUT_STORAGE_MODE1;
	clut.start = 0;

	clut.psm = GS_PSM_32;
	clut.load_method = CLUT_LOAD;
	clut.address = clutaddress;

	v0.x = 320.0f;
	v0.y = 240.0f;
	v0.z = 4;

	c0.r = 0xFF;
	c0.g = 0xFF;
	c0.b = 0xFF;
	c0.a = 0x80;
	c0.q = 1.0f;

	c1.r = 0xFF;
	c1.g = 0x00;
	c1.b = 0x00;
	c1.a = 0x40;
	c1.q = 1.0f;

	// UTF-8
	unsigned char str0[] = { 0x61, 0x62, 0xC2, 0xA9, 0x78, 0xC2, 0xA5, 0xC2, 0xB2, '\0'};

	// Shift-JIS
	unsigned char str1[] = {0x81, 0xBC, 0x93, 0xF1, 0x93, 0xF1, 0x93, 0xF1, 0x81, 0x69, 0x81, 0x40, 0x81,
							0x4F, 0x83, 0xD6, 0x81, 0x4F, 0x81, 0x6A, 0x93, 0xF1, 0x81, 0xBD, 0x0D, '\0' };

	qword_t *q = packet->data;

	while(1)
	{

		current = packets[context];
		q = current->data;

		q = draw_clear(q,0,0,0,640.0f,448.0f,0x40,0x40,0x40);

		q = draw_texture_sampling(q,0,&lod);
		q = draw_texturebuffer(q,0,&texbuf,&clut);

		impress.scale = 3.0f;

		q = fontx_print_sjis(q,0,str1,CENTER_ALIGN,&v0,&c0,&krom_u,&krom_k);
		q = fontstudio_print_string(q,0,str0,CENTER_ALIGN,&v0,&c1,&impress);

		q = draw_finish(q);

		dma_wait_fast();
		dma_channel_send_normal(DMA_CHANNEL_GIF,current->data, q - current->data, 0,0);

		draw_wait_finish();

		context ^= 1;

		graph_wait_vsync();

	}

	free(packets[0]);
	free(packets[1]);
}
Ejemplo n.º 3
0
void bdd_plot_vec (FILE *fp,
		   BDDPTR *f_vec,
		   int size,
		   int max_x, int max_y,
		   char *(*name_func) ())
{
  int i;
  float xf, incr;
  int x;

  if (!f_vec)
    return;

  /* Watch out: constant don't have valid position. */
  if (size == 1 && !BDD_VOID_P (f_vec[0]) && !BDD_CONST_P (f_vec[0])) {
    x = POSITION_F (f_vec[0]);
    incr = 0.0;
  }
  else {
    x = 0;
    if (size > max_x) {
      max_x = size;
      incr = 1;
    }
    else
      incr = (max_x + 1) / size;
  }

  draw_start (fp, max_x, max_y);

  xf = 0.0;

  for (i = 0; i < size; i++) {
    BDDPTR f = f_vec[i];

    draw_func_name (fp, x, i);

    if (BDD_VOID_P (f))
      draw_void (fp, x, 0);
    else
    if (BDD_0_P (f)) {
/*      draw_initial_edge (fp, x, x, 1, 0, 0);*/
      draw_const (fp, x, 0, 0);
    }
    else
    if (BDD_1_P (f)) {
/*      draw_initial_edge (fp, x, x, 1, 0, 0);*/
      draw_const (fp, x, 0, 1);
    }
    else
    if (BDD_X_P (f)) {
/*      draw_initial_edge (fp, x, x, 1, 0, 0);*/
      draw_const (fp, x, 0, 2);
    }
    else {
      /* Draw initial edge to top variable node of f: */
      /* First check whether this is a negative edge: */
      /* BDD_NEG_P (f) */

      draw_initial_edge (fp, x, POSITION_F (f), LEVEL_F (f), BDD_NEG_P (f),
			 BDD_I_INV_EDGE_P (f));
      plot_fp = fp;
      plot_name = name_func ? name_func : default_plot_name;
      if (!BDD_MARK (f))
	bdd_traverse_pre (f, plot_node);
    }
    if (i < size-1) {
      xf += incr;
      x = xf;
    }
  } /*for*/

  for (i = 0; i < size; i++) {
    BDDPTR f = f_vec[i];

    if (!BDD_VOID_P (f) && BDD_MARK (f))
      /* Let's be nice (and safe) and clear all aux fields.
	 Already encountered segmentation violation once...
      */
      bdd_traverse_pre (f, bdd_reinit_aux1_and_aux2_action);
  }

  draw_finish (fp);
}