Example #1
0
int draw_convert_xyz(xyz_t *output, float x, float y, int z, int count, vertex_f_t *vertices)
{

	int i;

	int center_x;
	int center_y;

	unsigned int max_z;

	center_x = ftoi4(x);
	center_y = ftoi4(y);

	max_z = 1 << (z - 1);

	// For each colour...
	for (i=0;i<count;i++)
	{

		// Calculate the XYZ values.
		output[i].x = (short)((vertices[i].x + 1.0f) * center_x);
		output[i].y = (short)((vertices[i].y + 1.0f) * -center_y);
		output[i].z = (unsigned int)((vertices[i].z + 1.0f) * max_z);

	}

	// End function.
	return 0;

}
Example #2
0
qword_t *draw_fontx_char(qword_t *q, unsigned short c, vertex_t *v0, fontx_t *fontx)
{

	u64 pdw;
	u64 *dw = (u64 *)q;

	char *char_offset;
	int i, j;
	int x,y,z;
	int xi,yi;

	x = ftoi4(v0->x);
	y = ftoi4(v0->y);
	z = v0->z;

	fontx_hdr* fontx_header = (fontx_hdr*)fontx->font;

	char_offset = fontx_get_char(fontx,c);

	if (!char_offset)
	{

		return q;

	}

	for (i=0;i<fontx_header->height;i++)
	{

		// Increment one row down
		yi = y + (i << 4);

		for (j=0;j < fontx->rowsize;j++)
		{

			// Increment one row right
			xi = x + (j << 7);
			dw = draw_fontx_row(dw,char_offset[(i*fontx->rowsize) + j],xi,yi,z,fontx->bold);

		}

	}

	if ((u32)dw % 16)
	{

		pdw = *(dw-1);
		*dw++ = pdw;

	}

	q = (qword_t*)dw;

	return q;

}
Example #3
0
qword_t *draw_fontstudio_char(qword_t *q, unsigned int c, vertex_t *v0, fsfont_t *font)
{

	int x,y;

	x = ftoi4(v0->x);
	y = ftoi4(v0->y);

	q->dw[0] = GIF_SET_UV(font->chardata[c].u1,font->chardata[c].v1);
	q->dw[1] = GIF_SET_XYZ(x + 32759,y + 32759,v0->z);
	q++;

	q->dw[0] = GIF_SET_UV(font->chardata[c].u2, font->chardata[c].v2);
	q->dw[1] = GIF_SET_XYZ(x + (int)((font->chardata[c].width*font->scale)*16.0f) + 32777,y + (int)((font->chardata[c].height*font->scale)*16.0f) + 32777,v0->z);
	q++;

	return q;

}
Example #4
0
void VuxPers(VU_VECTOR *v0, VU_SXYZ *sxyz0)
{



    if(vu_projection_type==0)
    {

        sxyz0->x = ftoi4( (vu_projection * v0->x / (v0->z))		+vu_offset_x);
        sxyz0->y = ftoi4(-(vu_projection * v0->y / (v0->z))		+vu_offset_y);
        sxyz0->z = 0xffffff-(short)(float)v0->z;
    }
    else	// use projection matrix
    {

        sxyz0->x = ftoi4( (((v0->x)/(v0->w))*vu_near_plane_w)	+vu_offset_x);
        sxyz0->y = ftoi4(-(((v0->y)/(v0->w))*vu_near_plane_h)	+vu_offset_y);

        (int)sxyz0->z =  (int)(-(v0->z/v0->w) * 0xffff);
    }
}
Example #5
0
int fontstudio_parse_ini(fsfont_t *font, char *ini, float tex_width, float tex_height)
{

	int i;

	char *temp0;
	char *temp1;

	temp0 = ini;

	temp1 = strtok(temp0,"=");
	if (temp1 == NULL)
	{
		printf("Error parsing number of chars.\n");
		return -1;
	}
	temp0 += strlen(temp1)+1;

	font->totalchars = (int)strtol(temp0,NULL,10);

	temp1 = strtok(temp0,"=");
	if (temp1 == NULL)
	{
		printf("Error parsing space width.\n");
		return -1;
	}
	temp0 += strlen(temp1)+1;

	font->spacewidth = (int)strtol(temp0,NULL,10);

	font->charmap = (unsigned short*)malloc(sizeof(short)*font->totalchars);

	if (font->charmap == NULL)
	{

		//131 kilobytes of memory
		printf("Error allocated %d bytes of memory.\n", sizeof(short)*font->totalchars);
		return -1;

	}

	// Clear memory
	memset(font->charmap,0,sizeof(short)*font->totalchars);

	font->chardata = (inidata_t*)malloc(sizeof(inidata_t)*font->totalchars);

	if (font->chardata == NULL)
	{

		printf("Error allocating %d bytes of memory.\n", sizeof(inidata_t)*font->totalchars);
		free(font->charmap);
		return -1;

	}

	// Clear memory
	memset(font->chardata,0,sizeof(inidata_t)*font->totalchars);

	for (i = 0; i < font->totalchars; i++)
	{

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing Char for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->charmap[i] = (int)strtol(temp0,NULL,10);

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing A for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].A = (int)strtol(temp0,NULL,10);

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing B for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].B = (int)strtol(temp0,NULL,10);

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing C for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].C = (int)strtol(temp0,NULL,10);

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing ox for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].ox = (int)strtol(temp0,NULL,10);

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing oy for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].oy = (int)strtol(temp0,NULL,10);

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing Wid for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].width = (int)strtol(temp0,NULL,10);

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing Hgt for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].height = (int)strtol(temp0,NULL,10);

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing X1 for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].u1 = ftoi4(((float)(strtod(temp0,NULL) * tex_width)));

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing Y1 for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].v1 = ftoi4(((float)(strtod(temp0,NULL) * tex_height)));

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing X2 for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].u2 = ftoi4(((float)(strtod(temp0,NULL) * tex_width)));

		temp1 = strtok(temp0,"=");
		if (temp1 == NULL)
		{

			printf("Error parsing Y2 for char %d.\n", i);
			free(font->charmap);
			free(font->chardata);
			return -1;

		}
		temp0 += strlen(temp1)+1;
		font->chardata[i].v2 = ftoi4(((float)(strtod(temp0,NULL) * tex_height)));
	}

	return 0;

}
Example #6
0
int VuxPersClip3(VU_VECTOR *v0, VU_VECTOR *v1, VU_VECTOR *v2, VU_SXYZ *sxyz0, VU_SXYZ *sxyz1, VU_SXYZ *sxyz2)
{



    if(vu_projection_type==0)
    {
        //v0
        sxyz0->x = ftoi4( (vu_projection * v0->x / (v0->z))		+vu_offset_x);
        sxyz0->y = ftoi4(-(vu_projection * v0->y / (v0->z))		+vu_offset_y);
        sxyz0->z = 0xffffff - (short)(float)v0->z;

        //v1
        sxyz1->x = ftoi4( (vu_projection * v1->x / (v1->z))		+vu_offset_x);
        sxyz1->y = ftoi4(-(vu_projection * v1->y / (v1->z))		+vu_offset_y);
        sxyz1->z = 0xffffff - (short)(float)v1->z;

        //v2
        sxyz2->x = ftoi4( (vu_projection * v2->x / (v2->z))		+vu_offset_x);
        sxyz2->y = ftoi4(-(vu_projection * v2->y / (v2->z))		+vu_offset_y);
        sxyz2->z = 0xffffff - (short)(float)v2->z;
    }
    else	// use projection matrix
    {
        sxyz0->x = ftoi4( (((v0->x)/(v0->w))*vu_near_plane_w)	+vu_offset_x);
        sxyz0->y = ftoi4(-(((v0->y)/(v0->w))*vu_near_plane_h)	+vu_offset_y);
        (int)sxyz0->z =  (int)(-(v0->z/v0->w) * 0xffff);

        sxyz1->x = ftoi4( (((v1->x)/(v1->w))*vu_near_plane_w)	+vu_offset_x);
        sxyz1->y = ftoi4(-(((v1->y)/(v1->w))*vu_near_plane_h)	+vu_offset_y);
        (int)sxyz1->z =  (int)(-(v1->z/v1->w) * 0xffff);

        sxyz2->x = ftoi4( (((v2->x)/(v2->w))*vu_near_plane_w)	+vu_offset_x);
        sxyz2->y = ftoi4(-(((v2->y)/(v2->w))*vu_near_plane_h)	+vu_offset_y);
        (int)sxyz2->z =  (int)(-(v2->z/v2->w) * 0xffff);
    }


    return VuxClipSxyz(sxyz0, sxyz1, sxyz2);
}