Code: Select all
for (i = 0; i < mdl->numObjects; ++i)
{
pl2Object *obj = mdl->objects[i];
pl2Vertex *vert = &(obj->verts[0]);
pgeVertTNV *tvert = &(obj->tverts[0]);
for (j = 0; j < obj->numVerts; ++j)
{
ScePspFVector4 v = { vert->x, vert->y, vert->z, 1 };
ScePspFVector4 n = { vert->nx, vert->ny, vert->nz, 0 };
__asm__ volatile(
"vzero.t C200\n" // C300 = new vertex
"vzero.t C210\n" // C310 = new normal
"ulv.q C220, 0 + %0\n" // C320 = original vertex
"ulv.q C230, 0 + %1\n" // C330 = original normal
:: "m"(v), "m"(n));
for (k = 0; k < 3; ++k)
{
if (vert->bones[k] == 0xff) break;
__asm__ volatile(
"ulv.q C000, 0 + %0\n" // M000 = transform matrix
"ulv.q C010, 16 + %0\n"
"ulv.q C020, 32 + %0\n"
"ulv.q C030, 48 + %0\n"
"lv.s S110, 0 + %1\n" // S110 = weight
"vtfm4.q C100, M000, C220\n" // C100 = [ transform matrix ] [ original vertex ]
"vscl.t C100, C100, S110\n" // add weighted value to new vertex
"vadd.t C200, C200, C100\n"
"vtfm4.q C100, M000, C230\n" // C100 = [ transform matrix ] [ original normal ]
"vscl.t C100, C100, S110\n" // add weighted value to new normal
"vadd.t C210, C210, C100\n"
: : "m"(tfm[vert->bones[k]]), "m"(vert->weight[k]));
}
__asm__ volatile(
"vdot.t S000, C210, C210\n" // normalize new normal
"vrsq.s S000, S000\n"
"vscl.t C210[-1:1,-1:1,-1:1], C210, S000\n"
"sv.s S200, 0 + %0\n" // store new vertex
"sv.s S201, 0 + %1\n"
"sv.s S202, 0 + %2\n"
"sv.s S210, 0 + %3\n" // store new normal
"sv.s S211, 0 + %4\n"
"sv.s S212, 0 + %5\n"
: "=m" (tvert->x), "=m" (tvert->y), "=m" (tvert->z),
"=m" (tvert->nx), "=m" (tvert->ny), "=m" (tvert->nz));
tvert->u = vert->u;
tvert->v = vert->v;
++vert; ++tvert;
}
}