コード例 #1
0
ファイル: font.c プロジェクト: AKuHAK2/ps2sdk
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]);
}
コード例 #2
0
ファイル: lists.c プロジェクト: TheKeyboardist/interface
qword_t *list_display(qword_t *q, int context, list_t *list, fsfont_t *font)
{

	int i;
	int entry_height;

	int entry_start = 0;

	vertex_t position;
	color_t regular_color;
	color_t selection_color;

	entry_t *entry;

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

	selection_color.r = 0x80;
	selection_color.g = 0x80;
	selection_color.b = 0x00;
	selection_color.a = 0x80;
	selection_color.q = 1.0f;

	position.x = (float)list->x;
	position.z = 6;

	entry = *(list->entries);

	// Make it so selection scrolls forward at 10 entries from bottom
	if (list->selection > list->display - 10)
	{
		entry_start = list->selection - 10;
	}

	// Make it so selection scrolls to bottom of list at end of list
	if (list->num > list->display)
	{
		if (list->selection >= list->num - 10)
		{
			entry_start = list->num - list->display;
		}
	}

	//printf("entry_start = %d\n", entry_start);

	for (i = 0; i < list->display; i++)
	{

		if (i >= list->num)
		{
			break;
		}

		entry = list->entries[entry_start + i];

		if (entry == NULL)
		{
			break;
		}
	
		entry_height = list->y + (i * font->height);
		position.y = (float)entry_height;

		if((entry_start+i) == list->selection)
		{
			q = fontstudio_print_string(q,0,entry,LEFT_ALIGN,&position,&selection_color,font);
		}
		else
		{
			q = fontstudio_print_string(q,0,entry,LEFT_ALIGN,&position,&regular_color,font);
		}

	}

	return q;

}