[Video] make rdp.vtx private
This commit is contained in:
parent
f9c6df3e8d
commit
35f4b1f8c6
|
@ -22,13 +22,13 @@ extern "C" {
|
|||
#include "3dmath.h"
|
||||
#include "trace.h"
|
||||
|
||||
void calc_light(VERTEX *v)
|
||||
void calc_light(VERTEX &v)
|
||||
{
|
||||
float light_intensity = 0.0f;
|
||||
register float color[3] = { rdp.light[rdp.num_lights].r, rdp.light[rdp.num_lights].g, rdp.light[rdp.num_lights].b };
|
||||
for (uint32_t l = 0; l < rdp.num_lights; l++)
|
||||
{
|
||||
light_intensity = DotProduct(rdp.light_vector[l], v->vec);
|
||||
light_intensity = DotProduct(rdp.light_vector[l], v.vec);
|
||||
|
||||
if (light_intensity > 0.0f)
|
||||
{
|
||||
|
@ -42,13 +42,12 @@ void calc_light(VERTEX *v)
|
|||
if (color[1] > 1.0f) color[1] = 1.0f;
|
||||
if (color[2] > 1.0f) color[2] = 1.0f;
|
||||
|
||||
v->r = (uint8_t)(color[0] * 255.0f);
|
||||
v->g = (uint8_t)(color[1] * 255.0f);
|
||||
v->b = (uint8_t)(color[2] * 255.0f);
|
||||
v.r = (uint8_t)(color[0] * 255.0f);
|
||||
v.g = (uint8_t)(color[1] * 255.0f);
|
||||
v.b = (uint8_t)(color[2] * 255.0f);
|
||||
}
|
||||
|
||||
//*
|
||||
void calc_linear(VERTEX *v)
|
||||
void calc_linear(VERTEX &v)
|
||||
{
|
||||
if (g_settings->force_calc_sphere())
|
||||
{
|
||||
|
@ -57,8 +56,8 @@ void calc_linear(VERTEX *v)
|
|||
}
|
||||
DECLAREALIGN16VAR(vec[3]);
|
||||
|
||||
TransformVector(v->vec, vec, rdp.model);
|
||||
// TransformVector (v->vec, vec, rdp.combined);
|
||||
TransformVector(v.vec, vec, rdp.model);
|
||||
// TransformVector (v.vec, vec, rdp.combined);
|
||||
NormalizeVector(vec);
|
||||
float x, y;
|
||||
if (!rdp.use_lookat)
|
||||
|
@ -84,14 +83,14 @@ void calc_linear(VERTEX *v)
|
|||
if (rdp.cur_cache[0])
|
||||
{
|
||||
// scale >> 6 is size to map to
|
||||
v->ou = (acosf(-x) / 3.141592654f) * (rdp.tiles(rdp.cur_tile).org_s_scale >> 6);
|
||||
v->ov = (acosf(-y) / 3.141592654f) * (rdp.tiles(rdp.cur_tile).org_t_scale >> 6);
|
||||
v.ou = (acosf(-x) / 3.141592654f) * (rdp.tiles(rdp.cur_tile).org_s_scale >> 6);
|
||||
v.ov = (acosf(-y) / 3.141592654f) * (rdp.tiles(rdp.cur_tile).org_t_scale >> 6);
|
||||
}
|
||||
v->uv_scaled = 1;
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc linear u: %f, v: %f", v->ou, v->ov);
|
||||
v.uv_scaled = 1;
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc linear u: %f, v: %f", v.ou, v.ov);
|
||||
}
|
||||
|
||||
void calc_sphere(VERTEX *v)
|
||||
void calc_sphere(VERTEX &v)
|
||||
{
|
||||
WriteTrace(TraceRDP, TraceDebug, "calc_sphere");
|
||||
DECLAREALIGN16VAR(vec[3]);
|
||||
|
@ -106,8 +105,8 @@ void calc_sphere(VERTEX *v)
|
|||
s_scale = rdp.tiles(rdp.cur_tile).org_s_scale >> 6;
|
||||
t_scale = rdp.tiles(rdp.cur_tile).org_t_scale >> 6;
|
||||
}
|
||||
TransformVector(v->vec, vec, rdp.model);
|
||||
// TransformVector (v->vec, vec, rdp.combined);
|
||||
TransformVector(v.vec, vec, rdp.model);
|
||||
// TransformVector (v.vec, vec, rdp.combined);
|
||||
NormalizeVector(vec);
|
||||
float x, y;
|
||||
if (!rdp.use_lookat)
|
||||
|
@ -120,10 +119,10 @@ void calc_sphere(VERTEX *v)
|
|||
x = DotProduct(rdp.lookat[0], vec);
|
||||
y = DotProduct(rdp.lookat[1], vec);
|
||||
}
|
||||
v->ou = (x * 0.5f + 0.5f) * s_scale;
|
||||
v->ov = (y * 0.5f + 0.5f) * t_scale;
|
||||
v->uv_scaled = 1;
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc sphere u: %f, v: %f", v->ou, v->ov);
|
||||
v.ou = (x * 0.5f + 0.5f) * s_scale;
|
||||
v.ov = (y * 0.5f + 0.5f) * t_scale;
|
||||
v.uv_scaled = 1;
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc sphere u: %f, v: %f", v.ou, v.ov);
|
||||
}
|
||||
|
||||
float DotProductC(register float *v1, register float *v2)
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
void calc_light (VERTEX *v);
|
||||
void calc_linear (VERTEX *v);
|
||||
void calc_sphere (VERTEX *v);
|
||||
void calc_light(VERTEX &v);
|
||||
void calc_linear(VERTEX &v);
|
||||
void calc_sphere(VERTEX &v);
|
||||
|
||||
void math_init();
|
||||
|
||||
|
|
|
@ -191,17 +191,17 @@ bool CRDP::init()
|
|||
return false;
|
||||
}
|
||||
};
|
||||
vtx = new VERTEX[MAX_VTX];
|
||||
if (vtx == NULL)
|
||||
m_vtx = new VERTEX[MAX_VTX];
|
||||
if (m_vtx == NULL)
|
||||
{
|
||||
free();
|
||||
return false;
|
||||
}
|
||||
memset(vtx, 0, sizeof(VERTEX)*MAX_VTX);
|
||||
memset(m_vtx, 0, sizeof(VERTEX)*MAX_VTX);
|
||||
// set all vertex numbers
|
||||
for (int i = 0; i < MAX_VTX; i++)
|
||||
{
|
||||
vtx[i].number = i;
|
||||
m_vtx[i].number = i;
|
||||
}
|
||||
|
||||
frame_buffers = new COLOR_IMAGE[NUMTEXBUF + 2];
|
||||
|
@ -239,10 +239,10 @@ void CRDP::free()
|
|||
cur_cache[i] = 0;
|
||||
cur_cache_n[i] = 0;
|
||||
}
|
||||
if (vtx != NULL)
|
||||
if (m_vtx != NULL)
|
||||
{
|
||||
delete[] vtx;
|
||||
vtx = NULL;
|
||||
delete[] m_vtx;
|
||||
m_vtx = NULL;
|
||||
}
|
||||
|
||||
if (frame_buffers != NULL)
|
||||
|
|
|
@ -359,6 +359,7 @@ public:
|
|||
bool init();
|
||||
void free();
|
||||
|
||||
inline VERTEX & vtx(int index) const { return m_vtx[index]; }
|
||||
inline TILE & tiles(int index) { return m_tiles[index]; }
|
||||
// Clipping
|
||||
int clip; // clipping flags
|
||||
|
@ -375,7 +376,9 @@ public:
|
|||
int n_cached[MAX_TMU];
|
||||
|
||||
// Vertices
|
||||
VERTEX *vtx; //[MAX_VTX]
|
||||
private:
|
||||
VERTEX * m_vtx; //[MAX_VTX]
|
||||
public:
|
||||
int v0, vn;
|
||||
|
||||
COLOR_IMAGE *frame_buffers; //[NUMTEXBUF+2]
|
||||
|
@ -683,19 +686,19 @@ __inline void AddOffset(VERTEX *v, int n)
|
|||
}
|
||||
}
|
||||
|
||||
__inline void CalculateFog(VERTEX *v)
|
||||
__inline void CalculateFog(VERTEX &v)
|
||||
{
|
||||
if (rdp.flags & FOG_ENABLED)
|
||||
{
|
||||
if (v->w < 0.0f)
|
||||
v->f = 0.0f;
|
||||
if (v.w < 0.0f)
|
||||
v.f = 0.0f;
|
||||
else
|
||||
v->f = minval(255.0f, maxval(0.0f, v->z_w * rdp.fog_multiplier + rdp.fog_offset));
|
||||
v->a = (uint8_t)v->f;
|
||||
v.f = minval(255.0f, maxval(0.0f, v.z_w * rdp.fog_multiplier + rdp.fog_offset));
|
||||
v.a = (uint8_t)v.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
v->f = 1.0f;
|
||||
v.f = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,41 +121,41 @@ static void t3d_vertex(uint32_t addr, uint32_t v0, uint32_t n)
|
|||
|
||||
for (uint32_t i = 0; i < n; i += 16)
|
||||
{
|
||||
VERTEX *v = &rdp.vtx[v0 + (i >> 4)];
|
||||
VERTEX &v = rdp.vtx(v0 + (i >> 4));
|
||||
x = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 0) ^ 1];
|
||||
y = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 1) ^ 1];
|
||||
z = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 2) ^ 1];
|
||||
v->flags = ((uint16_t*)gfx.RDRAM)[(((addr + i) >> 1) + 3) ^ 1];
|
||||
v->ou = 2.0f * (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 4) ^ 1];
|
||||
v->ov = 2.0f * (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 5) ^ 1];
|
||||
v->uv_scaled = 0;
|
||||
v->r = ((uint8_t*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v->g = ((uint8_t*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v->b = ((uint8_t*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
v->a = ((uint8_t*)gfx.RDRAM)[(addr + i + 15) ^ 3];
|
||||
v.flags = ((uint16_t*)gfx.RDRAM)[(((addr + i) >> 1) + 3) ^ 1];
|
||||
v.ou = 2.0f * (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 4) ^ 1];
|
||||
v.ov = 2.0f * (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 5) ^ 1];
|
||||
v.uv_scaled = 0;
|
||||
v.r = ((uint8_t*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v.g = ((uint8_t*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v.b = ((uint8_t*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
v.a = ((uint8_t*)gfx.RDRAM)[(addr + i + 15) ^ 3];
|
||||
|
||||
v->x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v->y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v->z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v->w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
v.x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v.y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v.z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v.w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
|
||||
if (fabs(v->w) < 0.001) v->w = 0.001f;
|
||||
v->oow = 1.0f / v->w;
|
||||
v->x_w = v->x * v->oow;
|
||||
v->y_w = v->y * v->oow;
|
||||
v->z_w = v->z * v->oow;
|
||||
if (fabs(v.w) < 0.001) v.w = 0.001f;
|
||||
v.oow = 1.0f / v.w;
|
||||
v.x_w = v.x * v.oow;
|
||||
v.y_w = v.y * v.oow;
|
||||
v.z_w = v.z * v.oow;
|
||||
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->screen_translated = 0;
|
||||
v->shade_mod = 0;
|
||||
v.uv_calculated = 0xFFFFFFFF;
|
||||
v.screen_translated = 0;
|
||||
v.shade_mod = 0;
|
||||
|
||||
v->scr_off = 0;
|
||||
if (v->x < -v->w) v->scr_off |= 1;
|
||||
if (v->x > v->w) v->scr_off |= 2;
|
||||
if (v->y < -v->w) v->scr_off |= 4;
|
||||
if (v->y > v->w) v->scr_off |= 8;
|
||||
if (v->w < 0.1f) v->scr_off |= 16;
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f, f: %f, z_w: %f, r=%d, g=%d, b=%d, a=%d", i >> 4, v->x, v->y, v->z, v->w, v->ou*rdp.tiles(rdp.cur_tile).s_scale, v->ov*rdp.tiles(rdp.cur_tile).t_scale, v->f, v->z_w, v->r, v->g, v->b, v->a);
|
||||
v.scr_off = 0;
|
||||
if (v.x < -v.w) v.scr_off |= 1;
|
||||
if (v.x > v.w) v.scr_off |= 2;
|
||||
if (v.y < -v.w) v.scr_off |= 4;
|
||||
if (v.y > v.w) v.scr_off |= 8;
|
||||
if (v.w < 0.1f) v.scr_off |= 16;
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f, f: %f, z_w: %f, r=%d, g=%d, b=%d, a=%d", i >> 4, v.x, v.y, v.z, v.w, v.ou*rdp.tiles(rdp.cur_tile).s_scale, v.ov*rdp.tiles(rdp.cur_tile).t_scale, v.f, v.z_w, v.r, v.g, v.b, v.a);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,12 +206,12 @@ static void t3dLoadObject(uint32_t pstate, uint32_t pvtx, uint32_t ptri)
|
|||
t3dTriN * tri = (t3dTriN*)&gfx.RDRAM[a];
|
||||
a += 4;
|
||||
WriteTrace(TraceRDP, TraceDebug, "tri #%d - %d, %d, %d", t, tri->v0, tri->v1, tri->v2);
|
||||
VERTEX *v[3] = { &rdp.vtx[tri->v0], &rdp.vtx[tri->v1], &rdp.vtx[tri->v2] };
|
||||
if (cull_tri(v))
|
||||
VERTEX *vtx[3] = { &rdp.vtx(tri->v0), &rdp.vtx(tri->v1), &rdp.vtx(tri->v2) };
|
||||
if (cull_tri(vtx))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
draw_tri(v);
|
||||
draw_tri(vtx);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,45 +54,45 @@ void rsp_vertex(int v0, int n)
|
|||
|
||||
for (i = 0; i < (n << 4); i += 16)
|
||||
{
|
||||
VERTEX *v = &rdp.vtx[v0 + (i >> 4)];
|
||||
VERTEX &v = rdp.vtx(v0 + (i >> 4));
|
||||
x = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 0) ^ 1];
|
||||
y = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 1) ^ 1];
|
||||
z = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 2) ^ 1];
|
||||
v->flags = ((uint16_t*)gfx.RDRAM)[(((addr + i) >> 1) + 3) ^ 1];
|
||||
v->ou = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 4) ^ 1];
|
||||
v->ov = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 5) ^ 1];
|
||||
v->uv_scaled = 0;
|
||||
v->a = ((uint8_t*)gfx.RDRAM)[(addr + i + 15) ^ 3];
|
||||
v.flags = ((uint16_t*)gfx.RDRAM)[(((addr + i) >> 1) + 3) ^ 1];
|
||||
v.ou = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 4) ^ 1];
|
||||
v.ov = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 5) ^ 1];
|
||||
v.uv_scaled = 0;
|
||||
v.a = ((uint8_t*)gfx.RDRAM)[(addr + i + 15) ^ 3];
|
||||
|
||||
v->x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v->y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v->z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v->w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
v.x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v.y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v.z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v.w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
|
||||
if (fabs(v->w) < 0.001) v->w = 0.001f;
|
||||
v->oow = 1.0f / v->w;
|
||||
v->x_w = v->x * v->oow;
|
||||
v->y_w = v->y * v->oow;
|
||||
v->z_w = v->z * v->oow;
|
||||
if (fabs(v.w) < 0.001) v.w = 0.001f;
|
||||
v.oow = 1.0f / v.w;
|
||||
v.x_w = v.x * v.oow;
|
||||
v.y_w = v.y * v.oow;
|
||||
v.z_w = v.z * v.oow;
|
||||
CalculateFog(v);
|
||||
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->screen_translated = 0;
|
||||
v->shade_mod = 0;
|
||||
v.uv_calculated = 0xFFFFFFFF;
|
||||
v.screen_translated = 0;
|
||||
v.shade_mod = 0;
|
||||
|
||||
v->scr_off = 0;
|
||||
if (v->x < -v->w) v->scr_off |= 1;
|
||||
if (v->x > v->w) v->scr_off |= 2;
|
||||
if (v->y < -v->w) v->scr_off |= 4;
|
||||
if (v->y > v->w) v->scr_off |= 8;
|
||||
if (v->w < 0.1f) v->scr_off |= 16;
|
||||
// if (v->z_w > 1.0f) v->scr_off |= 32;
|
||||
v.scr_off = 0;
|
||||
if (v.x < -v.w) v.scr_off |= 1;
|
||||
if (v.x > v.w) v.scr_off |= 2;
|
||||
if (v.y < -v.w) v.scr_off |= 4;
|
||||
if (v.y > v.w) v.scr_off |= 8;
|
||||
if (v.w < 0.1f) v.scr_off |= 16;
|
||||
// if (v.z_w > 1.0f) v.scr_off |= 32;
|
||||
|
||||
if (rdp.geom_mode & 0x00020000)
|
||||
{
|
||||
v->vec[0] = ((char*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v->vec[1] = ((char*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v->vec[2] = ((char*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
v.vec[0] = ((char*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v.vec[1] = ((char*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v.vec[2] = ((char*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
if (rdp.geom_mode & 0x40000)
|
||||
{
|
||||
if (rdp.geom_mode & 0x80000)
|
||||
|
@ -100,17 +100,17 @@ void rsp_vertex(int v0, int n)
|
|||
else
|
||||
calc_sphere(v);
|
||||
}
|
||||
NormalizeVector(v->vec);
|
||||
NormalizeVector(v.vec);
|
||||
|
||||
calc_light(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
v->r = ((uint8_t*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v->g = ((uint8_t*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v->b = ((uint8_t*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
v.r = ((uint8_t*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v.g = ((uint8_t*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v.b = ((uint8_t*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
}
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f, f: %f, z_w: %f, r=%d, g=%d, b=%d, a=%d", i >> 4, v->x, v->y, v->z, v->w, v->ou*rdp.tiles(rdp.cur_tile).s_scale, v->ov*rdp.tiles(rdp.cur_tile).t_scale, v->f, v->z_w, v->r, v->g, v->b, v->a);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f, f: %f, z_w: %f, r=%d, g=%d, b=%d, a=%d", i >> 4, v.x, v.y, v.z, v.w, v.ou*rdp.tiles(rdp.cur_tile).s_scale, v.ov*rdp.tiles(rdp.cur_tile).t_scale, v.f, v.z_w, v.r, v.g, v.b, v.a);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,24 +500,24 @@ void uc0_tri1()
|
|||
((rdp.cmd1 >> 8) & 0xFF) / 10,
|
||||
(rdp.cmd1 & 0xFF) / 10);
|
||||
|
||||
VERTEX *v[3] = {
|
||||
&rdp.vtx[((rdp.cmd1 >> 16) & 0xFF) / 10],
|
||||
&rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 10],
|
||||
&rdp.vtx[(rdp.cmd1 & 0xFF) / 10]
|
||||
VERTEX *vtx[3] = {
|
||||
&rdp.vtx(((rdp.cmd1 >> 16) & 0xFF) / 10),
|
||||
&rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 10),
|
||||
&rdp.vtx((rdp.cmd1 & 0xFF) / 10)
|
||||
};
|
||||
if (g_settings->hacks(CSettings::hack_Makers))
|
||||
{
|
||||
rdp.force_wrap = FALSE;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (v[i]->ou < 0.0f || v[i]->ov < 0.0f)
|
||||
if (vtx[i]->ou < 0.0f || vtx[i]->ov < 0.0f)
|
||||
{
|
||||
rdp.force_wrap = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
rsp_tri1(v);
|
||||
rsp_tri1(vtx);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -543,24 +543,23 @@ void uc0_culldl()
|
|||
uint8_t vStart = (uint8_t)((rdp.cmd0 & 0x00FFFFFF) / 40) & 0xF;
|
||||
uint8_t vEnd = (uint8_t)(rdp.cmd1 / 40) & 0x0F;
|
||||
uint32_t cond = 0;
|
||||
VERTEX *v;
|
||||
|
||||
WriteTrace(TraceRDP, TraceDebug, "uc0:culldl start: %d, end: %d", vStart, vEnd);
|
||||
|
||||
if (vEnd < vStart) return;
|
||||
for (uint16_t i = vStart; i <= vEnd; i++)
|
||||
{
|
||||
v = &rdp.vtx[i];
|
||||
VERTEX &v = rdp.vtx(i);
|
||||
// Check if completely off the screen (quick frustrum clipping for 90 FOV)
|
||||
if (v->x >= -v->w)
|
||||
if (v.x >= -v.w)
|
||||
cond |= 0x01;
|
||||
if (v->x <= v->w)
|
||||
if (v.x <= v.w)
|
||||
cond |= 0x02;
|
||||
if (v->y >= -v->w)
|
||||
if (v.y >= -v.w)
|
||||
cond |= 0x04;
|
||||
if (v->y <= v->w)
|
||||
if (v.y <= v.w)
|
||||
cond |= 0x08;
|
||||
if (v->w >= 0.1f)
|
||||
if (v.w >= 0.1f)
|
||||
cond |= 0x10;
|
||||
|
||||
if (cond == 0x1F)
|
||||
|
@ -595,7 +594,7 @@ void uc6_obj_sprite();
|
|||
|
||||
void uc0_modifyvtx(uint8_t where, uint16_t vtx, uint32_t val)
|
||||
{
|
||||
VERTEX *v = &rdp.vtx[vtx];
|
||||
VERTEX &v = rdp.vtx(vtx);
|
||||
|
||||
switch (where)
|
||||
{
|
||||
|
@ -604,48 +603,48 @@ void uc0_modifyvtx(uint8_t where, uint16_t vtx, uint32_t val)
|
|||
break;
|
||||
|
||||
case 0x10: // RGBA
|
||||
v->r = (uint8_t)(val >> 24);
|
||||
v->g = (uint8_t)((val >> 16) & 0xFF);
|
||||
v->b = (uint8_t)((val >> 8) & 0xFF);
|
||||
v->a = (uint8_t)(val & 0xFF);
|
||||
v->shade_mod = 0;
|
||||
v.r = (uint8_t)(val >> 24);
|
||||
v.g = (uint8_t)((val >> 16) & 0xFF);
|
||||
v.b = (uint8_t)((val >> 8) & 0xFF);
|
||||
v.a = (uint8_t)(val & 0xFF);
|
||||
v.shade_mod = 0;
|
||||
|
||||
WriteTrace(TraceRDP, TraceDebug, "RGBA: %d, %d, %d, %d", v->r, v->g, v->b, v->a);
|
||||
WriteTrace(TraceRDP, TraceDebug, "RGBA: %d, %d, %d, %d", v.r, v.g, v.b, v.a);
|
||||
break;
|
||||
|
||||
case 0x14: // ST
|
||||
{
|
||||
float scale = rdp.Persp_en ? 0.03125f : 0.015625f;
|
||||
v->ou = (float)((short)(val >> 16)) * scale;
|
||||
v->ov = (float)((short)(val & 0xFFFF)) * scale;
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->uv_scaled = 1;
|
||||
v.ou = (float)((short)(val >> 16)) * scale;
|
||||
v.ov = (float)((short)(val & 0xFFFF)) * scale;
|
||||
v.uv_calculated = 0xFFFFFFFF;
|
||||
v.uv_scaled = 1;
|
||||
}
|
||||
WriteTrace(TraceRDP, TraceDebug, "u/v: (%04lx, %04lx), (%f, %f)", (short)(val >> 16), (short)(val & 0xFFFF),
|
||||
v->ou, v->ov);
|
||||
v.ou, v.ov);
|
||||
break;
|
||||
|
||||
case 0x18: // XY screen
|
||||
{
|
||||
float scr_x = (float)((short)(val >> 16)) / 4.0f;
|
||||
float scr_y = (float)((short)(val & 0xFFFF)) / 4.0f;
|
||||
v->screen_translated = 2;
|
||||
v->sx = scr_x * rdp.scale_x + rdp.offset_x;
|
||||
v->sy = scr_y * rdp.scale_y + rdp.offset_y;
|
||||
if (v->w < 0.01f)
|
||||
v.screen_translated = 2;
|
||||
v.sx = scr_x * rdp.scale_x + rdp.offset_x;
|
||||
v.sy = scr_y * rdp.scale_y + rdp.offset_y;
|
||||
if (v.w < 0.01f)
|
||||
{
|
||||
v->w = 1.0f;
|
||||
v->oow = 1.0f;
|
||||
v->z_w = 1.0f;
|
||||
v.w = 1.0f;
|
||||
v.oow = 1.0f;
|
||||
v.z_w = 1.0f;
|
||||
}
|
||||
v->sz = rdp.view_trans[2] + v->z_w * rdp.view_scale[2];
|
||||
v.sz = rdp.view_trans[2] + v.z_w * rdp.view_scale[2];
|
||||
|
||||
v->scr_off = 0;
|
||||
if (scr_x < 0) v->scr_off |= 1;
|
||||
if (scr_x > rdp.vi_width) v->scr_off |= 2;
|
||||
if (scr_y < 0) v->scr_off |= 4;
|
||||
if (scr_y > rdp.vi_height) v->scr_off |= 8;
|
||||
if (v->w < 0.1f) v->scr_off |= 16;
|
||||
v.scr_off = 0;
|
||||
if (scr_x < 0) v.scr_off |= 1;
|
||||
if (scr_x > rdp.vi_width) v.scr_off |= 2;
|
||||
if (scr_y < 0) v.scr_off |= 4;
|
||||
if (scr_y > rdp.vi_height) v.scr_off |= 8;
|
||||
if (v.w < 0.1f) v.scr_off |= 16;
|
||||
|
||||
WriteTrace(TraceRDP, TraceDebug, "x/y: (%f, %f)", scr_x, scr_y);
|
||||
}
|
||||
|
@ -654,8 +653,8 @@ void uc0_modifyvtx(uint8_t where, uint16_t vtx, uint32_t val)
|
|||
case 0x1C: // Z screen
|
||||
{
|
||||
float scr_z = (float)((short)(val >> 16));
|
||||
v->z_w = (scr_z - rdp.view_trans[2]) / rdp.view_scale[2];
|
||||
v->z = v->z_w * v->w;
|
||||
v.z_w = (scr_z - rdp.view_trans[2]) / rdp.view_scale[2];
|
||||
v.z = v.z_w * v.w;
|
||||
WriteTrace(TraceRDP, TraceDebug, "z: %f", scr_z);
|
||||
}
|
||||
break;
|
||||
|
@ -769,8 +768,7 @@ void uc0_texture()
|
|||
|
||||
rdp.update |= UPDATE_TEXTURE;
|
||||
|
||||
WriteTrace(TraceRDP, TraceDebug, "uc0:texture: tile: %d, mipmap_lvl: %d, on: %d, s_scale: %f, t_scale: %f",
|
||||
tile, rdp.mipmap_level, on, tmp_tile->s_scale, tmp_tile->t_scale);
|
||||
WriteTrace(TraceRDP, TraceDebug, "uc0:texture: tile: %d, mipmap_lvl: %d, on: %d, s_scale: %f, t_scale: %f", tile, rdp.mipmap_level, on, tmp_tile->s_scale, tmp_tile->t_scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1003,15 +1001,15 @@ void uc0_line3d()
|
|||
uint32_t v1 = ((rdp.cmd1 >> 8) & 0xff) / 10;
|
||||
uint16_t width = (uint16_t)(rdp.cmd1 & 0xFF) + 3;
|
||||
|
||||
VERTEX *v[3] = {
|
||||
&rdp.vtx[v1],
|
||||
&rdp.vtx[v0],
|
||||
&rdp.vtx[v0]
|
||||
VERTEX *vtx[3] = {
|
||||
&rdp.vtx(v1),
|
||||
&rdp.vtx(v0),
|
||||
&rdp.vtx(v0)
|
||||
};
|
||||
uint32_t cull_mode = (rdp.flags & CULLMASK) >> CULLSHIFT;
|
||||
rdp.flags |= CULLMASK;
|
||||
rdp.update |= UPDATE_CULL_MODE;
|
||||
rsp_tri1(v, width);
|
||||
rsp_tri1(vtx, width);
|
||||
rdp.flags ^= CULLMASK;
|
||||
rdp.flags |= cull_mode << CULLSHIFT;
|
||||
rdp.update |= UPDATE_CULL_MODE;
|
||||
|
@ -1039,35 +1037,35 @@ void uc0_tri4()
|
|||
(rdp.cmd0 >> 0) & 0xF,
|
||||
(rdp.cmd1 >> 0) & 0xF);
|
||||
|
||||
VERTEX *v[12] = {
|
||||
&rdp.vtx[(rdp.cmd1 >> 28) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd0 >> 12) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd1 >> 24) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd1 >> 20) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd0 >> 8) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd1 >> 16) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd1 >> 12) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd0 >> 4) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd1 >> 8) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd1 >> 4) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd0 >> 0) & 0xF],
|
||||
&rdp.vtx[(rdp.cmd1 >> 0) & 0xF],
|
||||
VERTEX *vtx[12] = {
|
||||
&rdp.vtx((rdp.cmd1 >> 28) & 0xF),
|
||||
&rdp.vtx((rdp.cmd0 >> 12) & 0xF),
|
||||
&rdp.vtx((rdp.cmd1 >> 24) & 0xF),
|
||||
&rdp.vtx((rdp.cmd1 >> 20) & 0xF),
|
||||
&rdp.vtx((rdp.cmd0 >> 8) & 0xF),
|
||||
&rdp.vtx((rdp.cmd1 >> 16) & 0xF),
|
||||
&rdp.vtx((rdp.cmd1 >> 12) & 0xF),
|
||||
&rdp.vtx((rdp.cmd0 >> 4) & 0xF),
|
||||
&rdp.vtx((rdp.cmd1 >> 8) & 0xF),
|
||||
&rdp.vtx((rdp.cmd1 >> 4) & 0xF),
|
||||
&rdp.vtx((rdp.cmd0 >> 0) & 0xF),
|
||||
&rdp.vtx((rdp.cmd1 >> 0) & 0xF),
|
||||
};
|
||||
|
||||
int updated = 0;
|
||||
|
||||
if (cull_tri(v))
|
||||
if (cull_tri(vtx))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
updated = 1;
|
||||
update();
|
||||
|
||||
draw_tri(v);
|
||||
draw_tri(vtx);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v + 3))
|
||||
if (cull_tri(vtx + 3))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
|
@ -1077,11 +1075,11 @@ void uc0_tri4()
|
|||
update();
|
||||
}
|
||||
|
||||
draw_tri(v + 3);
|
||||
draw_tri(vtx + 3);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v + 6))
|
||||
if (cull_tri(vtx + 6))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
|
@ -1091,11 +1089,11 @@ void uc0_tri4()
|
|||
update();
|
||||
}
|
||||
|
||||
draw_tri(v + 6);
|
||||
draw_tri(vtx + 6);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v + 9))
|
||||
if (cull_tri(vtx + 9))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
|
@ -1105,7 +1103,7 @@ void uc0_tri4()
|
|||
update();
|
||||
}
|
||||
|
||||
draw_tri(v + 9);
|
||||
draw_tri(vtx + 9);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
}
|
|
@ -45,13 +45,13 @@ void uc1_tri1()
|
|||
((rdp.cmd1 >> 9) & 0x7F),
|
||||
((rdp.cmd1 >> 1) & 0x7F), rdp.cmd0, rdp.cmd1);
|
||||
|
||||
VERTEX *v[3] = {
|
||||
&rdp.vtx[(rdp.cmd1 >> 17) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 1) & 0x7F]
|
||||
VERTEX *vtx[3] = {
|
||||
&rdp.vtx((rdp.cmd1 >> 17) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 9) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 1) & 0x7F)
|
||||
};
|
||||
|
||||
rsp_tri1(v);
|
||||
rsp_tri1(vtx);
|
||||
}
|
||||
|
||||
void uc1_tri2()
|
||||
|
@ -71,16 +71,16 @@ void uc1_tri2()
|
|||
((rdp.cmd1 >> 9) & 0x7F),
|
||||
((rdp.cmd1 >> 1) & 0x7F));
|
||||
|
||||
VERTEX *v[6] = {
|
||||
&rdp.vtx[(rdp.cmd0 >> 17) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 1) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 17) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 1) & 0x7F]
|
||||
VERTEX *vtx[6] = {
|
||||
&rdp.vtx((rdp.cmd0 >> 17) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd0 >> 9) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd0 >> 1) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 17) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 9) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 1) & 0x7F)
|
||||
};
|
||||
|
||||
rsp_tri2(v);
|
||||
rsp_tri2(vtx);
|
||||
}
|
||||
|
||||
void uc1_line3d()
|
||||
|
@ -93,15 +93,15 @@ void uc1_line3d()
|
|||
(rdp.cmd1 >> 17) & 0x7F,
|
||||
(rdp.cmd1 >> 9) & 0x7F);
|
||||
|
||||
VERTEX *v[3] = {
|
||||
&rdp.vtx[(rdp.cmd1 >> 17) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 9) & 0x7F]
|
||||
VERTEX *vtx[3] = {
|
||||
&rdp.vtx((rdp.cmd1 >> 17) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 9) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 9) & 0x7F)
|
||||
};
|
||||
uint32_t cull_mode = (rdp.flags & CULLMASK) >> CULLSHIFT;
|
||||
rdp.flags |= CULLMASK;
|
||||
rdp.update |= UPDATE_CULL_MODE;
|
||||
rsp_tri1(v, width);
|
||||
rsp_tri1(vtx, width);
|
||||
rdp.flags ^= CULLMASK;
|
||||
rdp.flags |= cull_mode << CULLSHIFT;
|
||||
rdp.update |= UPDATE_CULL_MODE;
|
||||
|
@ -110,16 +110,16 @@ void uc1_line3d()
|
|||
{
|
||||
WriteTrace(TraceRDP, TraceDebug, "uc1:quad3d #%d, #%d", rdp.tri_n, rdp.tri_n + 1);
|
||||
|
||||
VERTEX *v[6] = {
|
||||
&rdp.vtx[(rdp.cmd1 >> 25) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 17) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 1) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 25) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 9) & 0x7F]
|
||||
VERTEX *vtx[6] = {
|
||||
&rdp.vtx((rdp.cmd1 >> 25) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 17) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 9) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 1) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 25) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 9) & 0x7F)
|
||||
};
|
||||
|
||||
rsp_tri2(v);
|
||||
rsp_tri2(vtx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ void uc1_branch_z()
|
|||
uint32_t addr = segoffset(branch_dl);
|
||||
WriteTrace(TraceRDP, TraceDebug, "uc1:branch_less_z, addr: %08lx", addr);
|
||||
uint32_t vtx = (rdp.cmd0 & 0xFFF) >> 1;
|
||||
if (fabs(rdp.vtx[vtx].z) <= (rdp.cmd1/*&0xFFFF*/))
|
||||
if (fabs(rdp.vtx(vtx).z) <= (rdp.cmd1/*&0xFFFF*/))
|
||||
{
|
||||
rdp.pc[rdp.pc_i] = addr;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "3dmath.h"
|
||||
#include "ucode00.h"
|
||||
|
||||
static void calc_point_light(VERTEX *v, float * vpos)
|
||||
static void calc_point_light(VERTEX & v, float * vpos)
|
||||
{
|
||||
float light_intensity = 0.0f;
|
||||
register float color[3] = { rdp.light[rdp.num_lights].r, rdp.light[rdp.num_lights].g, rdp.light[rdp.num_lights].b };
|
||||
|
@ -55,9 +55,9 @@ static void calc_point_light(VERTEX *v, float * vpos)
|
|||
if (color[1] > 1.0f) color[1] = 1.0f;
|
||||
if (color[2] > 1.0f) color[2] = 1.0f;
|
||||
|
||||
v->r = (uint8_t)(color[0] * 255.0f);
|
||||
v->g = (uint8_t)(color[1] * 255.0f);
|
||||
v->b = (uint8_t)(color[2] * 255.0f);
|
||||
v.r = (uint8_t)(color[0] * 255.0f);
|
||||
v.g = (uint8_t)(color[1] * 255.0f);
|
||||
v.b = (uint8_t)(color[2] * 255.0f);
|
||||
}
|
||||
|
||||
void uc6_obj_rectangle();
|
||||
|
@ -112,46 +112,46 @@ void uc2_vertex()
|
|||
}
|
||||
for (i = 0; i < (n << 4); i += 16)
|
||||
{
|
||||
VERTEX *v = &rdp.vtx[v0 + (i >> 4)];
|
||||
VERTEX & v = rdp.vtx(v0 + (i >> 4));
|
||||
x = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 0) ^ 1];
|
||||
y = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 1) ^ 1];
|
||||
z = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 2) ^ 1];
|
||||
v->flags = ((uint16_t*)gfx.RDRAM)[(((addr + i) >> 1) + 3) ^ 1];
|
||||
v->ou = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 4) ^ 1];
|
||||
v->ov = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 5) ^ 1];
|
||||
v->uv_scaled = 0;
|
||||
v->a = ((uint8_t*)gfx.RDRAM)[(addr + i + 15) ^ 3];
|
||||
v.flags = ((uint16_t*)gfx.RDRAM)[(((addr + i) >> 1) + 3) ^ 1];
|
||||
v.ou = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 4) ^ 1];
|
||||
v.ov = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 5) ^ 1];
|
||||
v.uv_scaled = 0;
|
||||
v.a = ((uint8_t*)gfx.RDRAM)[(addr + i + 15) ^ 3];
|
||||
|
||||
v->x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v->y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v->z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v->w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
v.x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v.y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v.z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v.w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
|
||||
if (fabs(v->w) < 0.001) v->w = 0.001f;
|
||||
v->oow = 1.0f / v->w;
|
||||
v->x_w = v->x * v->oow;
|
||||
v->y_w = v->y * v->oow;
|
||||
v->z_w = v->z * v->oow;
|
||||
if (fabs(v.w) < 0.001) v.w = 0.001f;
|
||||
v.oow = 1.0f / v.w;
|
||||
v.x_w = v.x * v.oow;
|
||||
v.y_w = v.y * v.oow;
|
||||
v.z_w = v.z * v.oow;
|
||||
CalculateFog(v);
|
||||
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->screen_translated = 0;
|
||||
v->shade_mod = 0;
|
||||
v.uv_calculated = 0xFFFFFFFF;
|
||||
v.screen_translated = 0;
|
||||
v.shade_mod = 0;
|
||||
|
||||
v->scr_off = 0;
|
||||
if (v->x < -v->w) v->scr_off |= 1;
|
||||
if (v->x > v->w) v->scr_off |= 2;
|
||||
if (v->y < -v->w) v->scr_off |= 4;
|
||||
if (v->y > v->w) v->scr_off |= 8;
|
||||
if (v->w < 0.1f) v->scr_off |= 16;
|
||||
// if (v->z_w > 1.0f) v->scr_off |= 32;
|
||||
v.scr_off = 0;
|
||||
if (v.x < -v.w) v.scr_off |= 1;
|
||||
if (v.x > v.w) v.scr_off |= 2;
|
||||
if (v.y < -v.w) v.scr_off |= 4;
|
||||
if (v.y > v.w) v.scr_off |= 8;
|
||||
if (v.w < 0.1f) v.scr_off |= 16;
|
||||
// if (v.z_w > 1.0f) v.scr_off |= 32;
|
||||
|
||||
if (rdp.geom_mode & 0x00020000)
|
||||
{
|
||||
v->vec[0] = ((char*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v->vec[1] = ((char*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v->vec[2] = ((char*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
// WriteTrace(TraceRDP, TraceDebug, "Calc light. x: %f, y: %f z: %f", v->vec[0], v->vec[1], v->vec[2]);
|
||||
v.vec[0] = ((char*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v.vec[1] = ((char*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v.vec[2] = ((char*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
// WriteTrace(TraceRDP, TraceDebug, "Calc light. x: %f, y: %f z: %f", v.vec[0], v.vec[1], v.vec[2]);
|
||||
// if (!(rdp.geom_mode & 0x800000))
|
||||
{
|
||||
if (rdp.geom_mode & 0x40000)
|
||||
|
@ -159,12 +159,12 @@ void uc2_vertex()
|
|||
if (rdp.geom_mode & 0x80000)
|
||||
{
|
||||
calc_linear(v);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc linear: v%d - u: %f, v: %f", i >> 4, v->ou, v->ov);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc linear: v%d - u: %f, v: %f", i >> 4, v.ou, v.ov);
|
||||
}
|
||||
else
|
||||
{
|
||||
calc_sphere(v);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc sphere: v%d - u: %f, v: %f", i >> 4, v->ou, v->ov);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc sphere: v%d - u: %f, v: %f", i >> 4, v.ou, v.ov);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,17 +175,17 @@ void uc2_vertex()
|
|||
}
|
||||
else
|
||||
{
|
||||
NormalizeVector(v->vec);
|
||||
NormalizeVector(v.vec);
|
||||
calc_light(v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
v->r = ((uint8_t*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v->g = ((uint8_t*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v->b = ((uint8_t*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
v.r = ((uint8_t*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v.g = ((uint8_t*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v.b = ((uint8_t*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
}
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f, f: %f, z_w: %f, r=%d, g=%d, b=%d, a=%d", i >> 4, v->x, v->y, v->z, v->w, v->ou*rdp.tiles(rdp.cur_tile).s_scale, v->ov*rdp.tiles(rdp.cur_tile).t_scale, v->f, v->z_w, v->r, v->g, v->b, v->a);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f, f: %f, z_w: %f, r=%d, g=%d, b=%d, a=%d", i >> 4, v.x, v.y, v.z, v.w, v.ou*rdp.tiles(rdp.cur_tile).s_scale, v.ov*rdp.tiles(rdp.cur_tile).t_scale, v.f, v.z_w, v.r, v.g, v.b, v.a);
|
||||
}
|
||||
rdp.geom_mode = geom_mode;
|
||||
}
|
||||
|
@ -209,29 +209,31 @@ void uc2_culldl()
|
|||
if (vEnd < vStart) return;
|
||||
for (uint16_t i = vStart; i <= vEnd; i++)
|
||||
{
|
||||
VERTEX & v = rdp.vtx(i);
|
||||
/*
|
||||
VERTEX v = &rdp.vtx[i];
|
||||
// Check if completely off the screen (quick frustrum clipping for 90 FOV)
|
||||
if (v->x >= -v->w)
|
||||
if (v.x >= -v.w)
|
||||
cond |= 0x01;
|
||||
if (v->x <= v->w)
|
||||
if (v.x <= v.w)
|
||||
cond |= 0x02;
|
||||
if (v->y >= -v->w)
|
||||
if (v.y >= -v.w)
|
||||
cond |= 0x04;
|
||||
if (v->y <= v->w)
|
||||
if (v.y <= v.w)
|
||||
cond |= 0x08;
|
||||
if (v->w >= 0.1f)
|
||||
if (v.w >= 0.1f)
|
||||
cond |= 0x10;
|
||||
|
||||
if (cond == 0x1F)
|
||||
return;
|
||||
//*/
|
||||
|
||||
WriteTrace(TraceRDP, TraceVerbose, " v[%d] = (%02f, %02f, %02f, 0x%02lx)", i, rdp.vtx[i].x, rdp.vtx[i].y, rdp.vtx[i].w, rdp.vtx[i].scr_off);
|
||||
WriteTrace(TraceRDP, TraceVerbose, " v[%d] = (%02f, %02f, %02f, 0x%02lx)", i, v.x, v.y, v.w, v.scr_off);
|
||||
|
||||
cond |= (~rdp.vtx[i].scr_off) & 0x1F;
|
||||
cond |= (~v.scr_off) & 0x1F;
|
||||
if (cond == 0x1F)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
WriteTrace(TraceRDP, TraceDebug, " - "); // specify that the enddl is not a real command
|
||||
|
@ -258,13 +260,13 @@ void uc2_tri1()
|
|||
((rdp.cmd0 >> 9) & 0x7F),
|
||||
((rdp.cmd0 >> 1) & 0x7F));
|
||||
|
||||
VERTEX *v[3] = {
|
||||
&rdp.vtx[(rdp.cmd0 >> 17) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 1) & 0x7F]
|
||||
VERTEX *vtx[3] = {
|
||||
&rdp.vtx((rdp.cmd0 >> 17) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd0 >> 9) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd0 >> 1) & 0x7F)
|
||||
};
|
||||
|
||||
rsp_tri1(v);
|
||||
rsp_tri1(vtx);
|
||||
}
|
||||
|
||||
void uc6_obj_ldtx_sprite();
|
||||
|
@ -303,16 +305,17 @@ void uc2_quad()
|
|||
((rdp.cmd1 >> 9) & 0x7F),
|
||||
((rdp.cmd1 >> 1) & 0x7F));
|
||||
|
||||
VERTEX *v[6] = {
|
||||
&rdp.vtx[(rdp.cmd0 >> 17) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 1) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 17) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 1) & 0x7F]
|
||||
VERTEX *vtx[6] =
|
||||
{
|
||||
&rdp.vtx((rdp.cmd0 >> 17) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd0 >> 9) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd0 >> 1) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 17) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 9) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd1 >> 1) & 0x7F)
|
||||
};
|
||||
|
||||
rsp_tri2(v);
|
||||
rsp_tri2(vtx);
|
||||
}
|
||||
|
||||
void uc6_ldtx_rect_r();
|
||||
|
@ -327,16 +330,17 @@ void uc2_line3d()
|
|||
(rdp.cmd0 >> 17) & 0x7F,
|
||||
(rdp.cmd0 >> 9) & 0x7F);
|
||||
|
||||
VERTEX *v[3] = {
|
||||
&rdp.vtx[(rdp.cmd0 >> 17) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 9) & 0x7F]
|
||||
VERTEX *vtx[3] =
|
||||
{
|
||||
&rdp.vtx((rdp.cmd0 >> 17) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd0 >> 9) & 0x7F),
|
||||
&rdp.vtx((rdp.cmd0 >> 9) & 0x7F)
|
||||
};
|
||||
uint16_t width = (uint16_t)(rdp.cmd0 + 3) & 0xFF;
|
||||
uint32_t cull_mode = (rdp.flags & CULLMASK) >> CULLSHIFT;
|
||||
rdp.flags |= CULLMASK;
|
||||
rdp.update |= UPDATE_CULL_MODE;
|
||||
rsp_tri1(v, width);
|
||||
rsp_tri1(vtx, width);
|
||||
rdp.flags ^= CULLMASK;
|
||||
rdp.flags |= cull_mode << CULLSHIFT;
|
||||
rdp.update |= UPDATE_CULL_MODE;
|
||||
|
|
|
@ -46,13 +46,13 @@ void uc3_tri1()
|
|||
((rdp.cmd1 >> 8) & 0xFF) / 5,
|
||||
((rdp.cmd1) & 0xFF) / 5, rdp.cmd0, rdp.cmd1);
|
||||
|
||||
VERTEX *v[3] = {
|
||||
&rdp.vtx[((rdp.cmd1 >> 16) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 5],
|
||||
&rdp.vtx[(rdp.cmd1 & 0xFF) / 5]
|
||||
VERTEX *vtx[3] = {
|
||||
&rdp.vtx(((rdp.cmd1 >> 16) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 5),
|
||||
&rdp.vtx((rdp.cmd1 & 0xFF) / 5)
|
||||
};
|
||||
|
||||
rsp_tri1(v);
|
||||
rsp_tri1(vtx);
|
||||
}
|
||||
|
||||
void uc3_tri2()
|
||||
|
@ -65,30 +65,30 @@ void uc3_tri2()
|
|||
((rdp.cmd1 >> 8) & 0xFF) / 5,
|
||||
((rdp.cmd1) & 0xFF) / 5);
|
||||
|
||||
VERTEX *v[6] = {
|
||||
&rdp.vtx[((rdp.cmd0 >> 16) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd0 >> 8) & 0xFF) / 5],
|
||||
&rdp.vtx[(rdp.cmd0 & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 16) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 5],
|
||||
&rdp.vtx[(rdp.cmd1 & 0xFF) / 5]
|
||||
VERTEX *vtx[6] = {
|
||||
&rdp.vtx(((rdp.cmd0 >> 16) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd0 >> 8) & 0xFF) / 5),
|
||||
&rdp.vtx((rdp.cmd0 & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 16) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 5),
|
||||
&rdp.vtx((rdp.cmd1 & 0xFF) / 5)
|
||||
};
|
||||
|
||||
rsp_tri2(v);
|
||||
rsp_tri2(vtx);
|
||||
}
|
||||
|
||||
void uc3_quad3d()
|
||||
{
|
||||
WriteTrace(TraceRDP, TraceDebug, "uc3:quad3d #%d, #%d", rdp.tri_n, rdp.tri_n + 1);
|
||||
|
||||
VERTEX *v[6] = {
|
||||
&rdp.vtx[((rdp.cmd1 >> 24) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 16) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 5],
|
||||
&rdp.vtx[(rdp.cmd1 & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 24) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 5]
|
||||
VERTEX *vtx[6] = {
|
||||
&rdp.vtx(((rdp.cmd1 >> 24) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 16) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 5),
|
||||
&rdp.vtx((rdp.cmd1 & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 24) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 5)
|
||||
};
|
||||
|
||||
rsp_tri2(v);
|
||||
rsp_tri2(vtx);
|
||||
}
|
|
@ -36,27 +36,27 @@ void uc4_tri1()
|
|||
WriteTrace(TraceRDP, TraceDebug, "uc4:tri1 #%d - %d, %d, %d", rdp.tri_n,
|
||||
v1, v2, v3);
|
||||
|
||||
VERTEX *v[3] = {
|
||||
&rdp.vtx[v1],
|
||||
&rdp.vtx[v2],
|
||||
&rdp.vtx[v3]
|
||||
VERTEX *vtx[3] = {
|
||||
&rdp.vtx(v1),
|
||||
&rdp.vtx(v2),
|
||||
&rdp.vtx(v3)
|
||||
};
|
||||
|
||||
rsp_tri1(v);
|
||||
rsp_tri1(vtx);
|
||||
}
|
||||
|
||||
void uc4_quad3d()
|
||||
{
|
||||
WriteTrace(TraceRDP, TraceDebug, "uc4:quad3d #%d, #%d", rdp.tri_n, rdp.tri_n + 1);
|
||||
|
||||
VERTEX *v[6] = {
|
||||
&rdp.vtx[((rdp.cmd1 >> 24) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 16) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 24) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 5],
|
||||
&rdp.vtx[(rdp.cmd1 & 0xFF) / 5]
|
||||
VERTEX *vtx[6] = {
|
||||
&rdp.vtx(((rdp.cmd1 >> 24) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 16) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 24) & 0xFF) / 5),
|
||||
&rdp.vtx(((rdp.cmd1 >> 8) & 0xFF) / 5),
|
||||
&rdp.vtx((rdp.cmd1 & 0xFF) / 5)
|
||||
};
|
||||
|
||||
rsp_tri2(v);
|
||||
rsp_tri2(vtx);
|
||||
}
|
|
@ -118,49 +118,49 @@ void uc5_vertex()
|
|||
for (int i = first; i < first + n; i++)
|
||||
{
|
||||
start = (i - first) * 10;
|
||||
VERTEX *v = &rdp.vtx[i];
|
||||
VERTEX &v = rdp.vtx(i);
|
||||
x = (float)((short*)gfx.RDRAM)[(((addr + start) >> 1) + 0) ^ 1];
|
||||
y = (float)((short*)gfx.RDRAM)[(((addr + start) >> 1) + 1) ^ 1];
|
||||
z = (float)((short*)gfx.RDRAM)[(((addr + start) >> 1) + 2) ^ 1];
|
||||
|
||||
v->x = x*rdp.dkrproj[prj][0][0] + y*rdp.dkrproj[prj][1][0] + z*rdp.dkrproj[prj][2][0] + rdp.dkrproj[prj][3][0];
|
||||
v->y = x*rdp.dkrproj[prj][0][1] + y*rdp.dkrproj[prj][1][1] + z*rdp.dkrproj[prj][2][1] + rdp.dkrproj[prj][3][1];
|
||||
v->z = x*rdp.dkrproj[prj][0][2] + y*rdp.dkrproj[prj][1][2] + z*rdp.dkrproj[prj][2][2] + rdp.dkrproj[prj][3][2];
|
||||
v->w = x*rdp.dkrproj[prj][0][3] + y*rdp.dkrproj[prj][1][3] + z*rdp.dkrproj[prj][2][3] + rdp.dkrproj[prj][3][3];
|
||||
v.x = x*rdp.dkrproj[prj][0][0] + y*rdp.dkrproj[prj][1][0] + z*rdp.dkrproj[prj][2][0] + rdp.dkrproj[prj][3][0];
|
||||
v.y = x*rdp.dkrproj[prj][0][1] + y*rdp.dkrproj[prj][1][1] + z*rdp.dkrproj[prj][2][1] + rdp.dkrproj[prj][3][1];
|
||||
v.z = x*rdp.dkrproj[prj][0][2] + y*rdp.dkrproj[prj][1][2] + z*rdp.dkrproj[prj][2][2] + rdp.dkrproj[prj][3][2];
|
||||
v.w = x*rdp.dkrproj[prj][0][3] + y*rdp.dkrproj[prj][1][3] + z*rdp.dkrproj[prj][2][3] + rdp.dkrproj[prj][3][3];
|
||||
|
||||
if (billboarding)
|
||||
{
|
||||
v->x += rdp.vtx[0].x;
|
||||
v->y += rdp.vtx[0].y;
|
||||
v->z += rdp.vtx[0].z;
|
||||
v->w += rdp.vtx[0].w;
|
||||
v.x += rdp.vtx(0).x;
|
||||
v.y += rdp.vtx(0).y;
|
||||
v.z += rdp.vtx(0).z;
|
||||
v.w += rdp.vtx(0).w;
|
||||
}
|
||||
|
||||
if (fabs(v->w) < 0.001) v->w = 0.001f;
|
||||
v->oow = 1.0f / v->w;
|
||||
v->x_w = v->x * v->oow;
|
||||
v->y_w = v->y * v->oow;
|
||||
v->z_w = v->z * v->oow;
|
||||
if (fabs(v.w) < 0.001) v.w = 0.001f;
|
||||
v.oow = 1.0f / v.w;
|
||||
v.x_w = v.x * v.oow;
|
||||
v.y_w = v.y * v.oow;
|
||||
v.z_w = v.z * v.oow;
|
||||
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->screen_translated = 0;
|
||||
v->shade_mod = 0;
|
||||
v.uv_calculated = 0xFFFFFFFF;
|
||||
v.screen_translated = 0;
|
||||
v.shade_mod = 0;
|
||||
|
||||
v->scr_off = 0;
|
||||
if (v->x < -v->w) v->scr_off |= 1;
|
||||
if (v->x > v->w) v->scr_off |= 2;
|
||||
if (v->y < -v->w) v->scr_off |= 4;
|
||||
if (v->y > v->w) v->scr_off |= 8;
|
||||
if (v->w < 0.1f) v->scr_off |= 16;
|
||||
if (fabs(v->z_w) > 1.0) v->scr_off |= 32;
|
||||
v.scr_off = 0;
|
||||
if (v.x < -v.w) v.scr_off |= 1;
|
||||
if (v.x > v.w) v.scr_off |= 2;
|
||||
if (v.y < -v.w) v.scr_off |= 4;
|
||||
if (v.y > v.w) v.scr_off |= 8;
|
||||
if (v.w < 0.1f) v.scr_off |= 16;
|
||||
if (fabs(v.z_w) > 1.0) v.scr_off |= 32;
|
||||
|
||||
v->r = ((uint8_t*)gfx.RDRAM)[(addr + start + 6) ^ 3];
|
||||
v->g = ((uint8_t*)gfx.RDRAM)[(addr + start + 7) ^ 3];
|
||||
v->b = ((uint8_t*)gfx.RDRAM)[(addr + start + 8) ^ 3];
|
||||
v->a = ((uint8_t*)gfx.RDRAM)[(addr + start + 9) ^ 3];
|
||||
v.r = ((uint8_t*)gfx.RDRAM)[(addr + start + 6) ^ 3];
|
||||
v.g = ((uint8_t*)gfx.RDRAM)[(addr + start + 7) ^ 3];
|
||||
v.b = ((uint8_t*)gfx.RDRAM)[(addr + start + 8) ^ 3];
|
||||
v.a = ((uint8_t*)gfx.RDRAM)[(addr + start + 9) ^ 3];
|
||||
CalculateFog(v);
|
||||
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, z_w: %f, r=%d, g=%d, b=%d, a=%d", i, v->x, v->y, v->z, v->w, v->z_w, v->r, v->g, v->b, v->a);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, z_w: %f, r=%d, g=%d, b=%d, a=%d", i, v.x, v.y, v.z, v.w, v.z_w, v.r, v.g, v.b, v.a);
|
||||
}
|
||||
|
||||
vtx_last += n;
|
||||
|
@ -193,10 +193,10 @@ void uc5_tridma()
|
|||
|
||||
WriteTrace(TraceRDP, TraceDebug, "tri #%d - %d, %d, %d", rdp.tri_n, v0, v1, v2);
|
||||
|
||||
VERTEX *v[3] = {
|
||||
&rdp.vtx[v0],
|
||||
&rdp.vtx[v1],
|
||||
&rdp.vtx[v2]
|
||||
VERTEX *vtx[3] = {
|
||||
&rdp.vtx(v0),
|
||||
&rdp.vtx(v1),
|
||||
&rdp.vtx(v2)
|
||||
};
|
||||
|
||||
flags = gfx.RDRAM[addr + start + 3];
|
||||
|
@ -218,24 +218,24 @@ void uc5_tridma()
|
|||
}
|
||||
start += 4;
|
||||
|
||||
v[0]->ou = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 5] / 32.0f;
|
||||
v[0]->ov = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 4] / 32.0f;
|
||||
v[1]->ou = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 3] / 32.0f;
|
||||
v[1]->ov = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 2] / 32.0f;
|
||||
v[2]->ou = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 1] / 32.0f;
|
||||
v[2]->ov = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 0] / 32.0f;
|
||||
vtx[0]->ou = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 5] / 32.0f;
|
||||
vtx[0]->ov = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 4] / 32.0f;
|
||||
vtx[1]->ou = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 3] / 32.0f;
|
||||
vtx[1]->ov = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 2] / 32.0f;
|
||||
vtx[2]->ou = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 1] / 32.0f;
|
||||
vtx[2]->ov = (float)((short*)gfx.RDRAM)[((addr + start) >> 1) + 0] / 32.0f;
|
||||
|
||||
v[0]->uv_calculated = 0xFFFFFFFF;
|
||||
v[1]->uv_calculated = 0xFFFFFFFF;
|
||||
v[2]->uv_calculated = 0xFFFFFFFF;
|
||||
vtx[0]->uv_calculated = 0xFFFFFFFF;
|
||||
vtx[1]->uv_calculated = 0xFFFFFFFF;
|
||||
vtx[2]->uv_calculated = 0xFFFFFFFF;
|
||||
|
||||
if (cull_tri(v))
|
||||
if (cull_tri(vtx))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
update();
|
||||
|
||||
draw_tri(v);
|
||||
draw_tri(vtx);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,71 +72,71 @@ void uc7_vertex()
|
|||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
VERTEX *v = &rdp.vtx[v0 + i];
|
||||
VERTEX &v = rdp.vtx(v0 + i);
|
||||
x = (float)vertex->x;
|
||||
y = (float)vertex->y;
|
||||
z = (float)vertex->z;
|
||||
v->flags = 0;
|
||||
v->ou = (float)vertex->s;
|
||||
v->ov = (float)vertex->t;
|
||||
v->uv_scaled = 0;
|
||||
v.flags = 0;
|
||||
v.ou = (float)vertex->s;
|
||||
v.ov = (float)vertex->t;
|
||||
v.uv_scaled = 0;
|
||||
|
||||
WriteTrace(TraceRDP, TraceVerbose, "before: v%d - x: %f, y: %f, z: %f, flags: %04lx, ou: %f, ov: %f", i >> 4, x, y, z, v->flags, v->ou, v->ov);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "before: v%d - x: %f, y: %f, z: %f, flags: %04lx, ou: %f, ov: %f", i >> 4, x, y, z, v.flags, v.ou, v.ov);
|
||||
|
||||
v->x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v->y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v->z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v->w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
v.x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v.y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v.z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v.w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
|
||||
if (fabs(v->w) < 0.001) v->w = 0.001f;
|
||||
v->oow = 1.0f / v->w;
|
||||
v->x_w = v->x * v->oow;
|
||||
v->y_w = v->y * v->oow;
|
||||
v->z_w = v->z * v->oow;
|
||||
if (fabs(v.w) < 0.001) v.w = 0.001f;
|
||||
v.oow = 1.0f / v.w;
|
||||
v.x_w = v.x * v.oow;
|
||||
v.y_w = v.y * v.oow;
|
||||
v.z_w = v.z * v.oow;
|
||||
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->screen_translated = 0;
|
||||
v.uv_calculated = 0xFFFFFFFF;
|
||||
v.screen_translated = 0;
|
||||
|
||||
v->scr_off = 0;
|
||||
if (v->x < -v->w) v->scr_off |= 1;
|
||||
if (v->x > v->w) v->scr_off |= 2;
|
||||
if (v->y < -v->w) v->scr_off |= 4;
|
||||
if (v->y > v->w) v->scr_off |= 8;
|
||||
if (v->w < 0.1f) v->scr_off |= 16;
|
||||
v.scr_off = 0;
|
||||
if (v.x < -v.w) v.scr_off |= 1;
|
||||
if (v.x > v.w) v.scr_off |= 2;
|
||||
if (v.y < -v.w) v.scr_off |= 4;
|
||||
if (v.y > v.w) v.scr_off |= 8;
|
||||
if (v.w < 0.1f) v.scr_off |= 16;
|
||||
|
||||
uint8_t *color = &gfx.RDRAM[pd_col_addr + (vertex->idx & 0xff)];
|
||||
|
||||
v->a = color[0];
|
||||
v.a = color[0];
|
||||
CalculateFog(v);
|
||||
|
||||
if (rdp.geom_mode & 0x00020000)
|
||||
{
|
||||
v->vec[0] = (char)color[3];
|
||||
v->vec[1] = (char)color[2];
|
||||
v->vec[2] = (char)color[1];
|
||||
v.vec[0] = (char)color[3];
|
||||
v.vec[1] = (char)color[2];
|
||||
v.vec[2] = (char)color[1];
|
||||
|
||||
if (rdp.geom_mode & 0x80000)
|
||||
{
|
||||
calc_linear(v);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc linear: v%d - u: %f, v: %f", i >> 4, v->ou, v->ov);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc linear: v%d - u: %f, v: %f", i >> 4, v.ou, v.ov);
|
||||
}
|
||||
else if (rdp.geom_mode & 0x40000)
|
||||
{
|
||||
calc_sphere(v);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc sphere: v%d - u: %f, v: %f", i >> 4, v->ou, v->ov);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc sphere: v%d - u: %f, v: %f", i >> 4, v.ou, v.ov);
|
||||
}
|
||||
|
||||
NormalizeVector(v->vec);
|
||||
NormalizeVector(v.vec);
|
||||
|
||||
calc_light(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
v->r = color[3];
|
||||
v->g = color[2];
|
||||
v->b = color[1];
|
||||
v.r = color[3];
|
||||
v.g = color[2];
|
||||
v.b = color[1];
|
||||
}
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f", i >> 4, v->x, v->y, v->z, v->w, v->ou, v->ov);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f", i >> 4, v.x, v.y, v.z, v.w, v.ou, v.ov);
|
||||
vertex++;
|
||||
}
|
||||
}
|
|
@ -61,86 +61,86 @@ void uc8_vertex()
|
|||
//*/
|
||||
for (i = 0; i < (n << 4); i += 16)
|
||||
{
|
||||
VERTEX *v = &rdp.vtx[v0 + (i >> 4)];
|
||||
VERTEX & v = rdp.vtx(v0 + (i >> 4));
|
||||
x = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 0) ^ 1];
|
||||
y = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 1) ^ 1];
|
||||
z = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 2) ^ 1];
|
||||
v->flags = ((uint16_t*)gfx.RDRAM)[(((addr + i) >> 1) + 3) ^ 1];
|
||||
v->ou = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 4) ^ 1];
|
||||
v->ov = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 5) ^ 1];
|
||||
v->uv_scaled = 0;
|
||||
v->a = ((uint8_t*)gfx.RDRAM)[(addr + i + 15) ^ 3];
|
||||
v.flags = ((uint16_t*)gfx.RDRAM)[(((addr + i) >> 1) + 3) ^ 1];
|
||||
v.ou = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 4) ^ 1];
|
||||
v.ov = (float)((short*)gfx.RDRAM)[(((addr + i) >> 1) + 5) ^ 1];
|
||||
v.uv_scaled = 0;
|
||||
v.a = ((uint8_t*)gfx.RDRAM)[(addr + i + 15) ^ 3];
|
||||
|
||||
WriteTrace(TraceRDP, TraceVerbose, "before v%d - x: %f, y: %f, z: %f", i >> 4, x, y, z);
|
||||
v->x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v->y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v->z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v->w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
v.x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
v.y = x*rdp.combined[0][1] + y*rdp.combined[1][1] + z*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
v.z = x*rdp.combined[0][2] + y*rdp.combined[1][2] + z*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
v.w = x*rdp.combined[0][3] + y*rdp.combined[1][3] + z*rdp.combined[2][3] + rdp.combined[3][3];
|
||||
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f, flags: %d", i >> 4, v->x, v->y, v->z, v->w, v->ou, v->ov, v->flags);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f, flags: %d", i >> 4, v.x, v.y, v.z, v.w, v.ou, v.ov, v.flags);
|
||||
|
||||
if (fabs(v->w) < 0.001) v->w = 0.001f;
|
||||
v->oow = 1.0f / v->w;
|
||||
v->x_w = v->x * v->oow;
|
||||
v->y_w = v->y * v->oow;
|
||||
v->z_w = v->z * v->oow;
|
||||
if (fabs(v.w) < 0.001) v.w = 0.001f;
|
||||
v.oow = 1.0f / v.w;
|
||||
v.x_w = v.x * v.oow;
|
||||
v.y_w = v.y * v.oow;
|
||||
v.z_w = v.z * v.oow;
|
||||
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->screen_translated = 0;
|
||||
v->shade_mod = 0;
|
||||
v.uv_calculated = 0xFFFFFFFF;
|
||||
v.screen_translated = 0;
|
||||
v.shade_mod = 0;
|
||||
|
||||
v->scr_off = 0;
|
||||
if (v->x < -v->w) v->scr_off |= 1;
|
||||
if (v->x > v->w) v->scr_off |= 2;
|
||||
if (v->y < -v->w) v->scr_off |= 4;
|
||||
if (v->y > v->w) v->scr_off |= 8;
|
||||
if (v->w < 0.1f) v->scr_off |= 16;
|
||||
v.scr_off = 0;
|
||||
if (v.x < -v.w) v.scr_off |= 1;
|
||||
if (v.x > v.w) v.scr_off |= 2;
|
||||
if (v.y < -v.w) v.scr_off |= 4;
|
||||
if (v.y > v.w) v.scr_off |= 8;
|
||||
if (v.w < 0.1f) v.scr_off |= 16;
|
||||
///*
|
||||
v->r = ((uint8_t*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v->g = ((uint8_t*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v->b = ((uint8_t*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
WriteTrace(TraceRDP, TraceVerbose, "r: %02lx, g: %02lx, b: %02lx, a: %02lx", v->r, v->g, v->b, v->a);
|
||||
v.r = ((uint8_t*)gfx.RDRAM)[(addr + i + 12) ^ 3];
|
||||
v.g = ((uint8_t*)gfx.RDRAM)[(addr + i + 13) ^ 3];
|
||||
v.b = ((uint8_t*)gfx.RDRAM)[(addr + i + 14) ^ 3];
|
||||
WriteTrace(TraceRDP, TraceVerbose, "r: %02lx, g: %02lx, b: %02lx, a: %02lx", v.r, v.g, v.b, v.a);
|
||||
|
||||
if ((rdp.geom_mode & 0x00020000))
|
||||
{
|
||||
uint32_t shift = v0 << 1;
|
||||
v->vec[0] = ((char*)gfx.RDRAM)[(uc8_normale_addr + (i >> 3) + shift + 0) ^ 3];
|
||||
v->vec[1] = ((char*)gfx.RDRAM)[(uc8_normale_addr + (i >> 3) + shift + 1) ^ 3];
|
||||
v->vec[2] = (char)(v->flags & 0xff);
|
||||
v.vec[0] = ((char*)gfx.RDRAM)[(uc8_normale_addr + (i >> 3) + shift + 0) ^ 3];
|
||||
v.vec[1] = ((char*)gfx.RDRAM)[(uc8_normale_addr + (i >> 3) + shift + 1) ^ 3];
|
||||
v.vec[2] = (char)(v.flags & 0xff);
|
||||
|
||||
if (rdp.geom_mode & 0x80000)
|
||||
{
|
||||
calc_linear(v);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc linear: v%d - u: %f, v: %f", i >> 4, v->ou, v->ov);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc linear: v%d - u: %f, v: %f", i >> 4, v.ou, v.ov);
|
||||
}
|
||||
else if (rdp.geom_mode & 0x40000)
|
||||
{
|
||||
calc_sphere(v);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc sphere: v%d - u: %f, v: %f", i >> 4, v->ou, v->ov);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "calc sphere: v%d - u: %f, v: %f", i >> 4, v.ou, v.ov);
|
||||
}
|
||||
WriteTrace(TraceRDP, TraceDebug, "v[%d] calc light. r: 0x%02lx, g: 0x%02lx, b: 0x%02lx", i >> 4, v->r, v->g, v->b);
|
||||
WriteTrace(TraceRDP, TraceDebug, "v[%d] calc light. r: 0x%02lx, g: 0x%02lx, b: 0x%02lx", i >> 4, v.r, v.g, v.b);
|
||||
float color[3] = { rdp.light[rdp.num_lights].r, rdp.light[rdp.num_lights].g, rdp.light[rdp.num_lights].b };
|
||||
WriteTrace(TraceRDP, TraceDebug, "ambient light. r: %f, g: %f, b: %f", color[0], color[1], color[2]);
|
||||
float light_intensity = 0.0f;
|
||||
uint32_t l;
|
||||
if (rdp.geom_mode & 0x00400000)
|
||||
{
|
||||
NormalizeVector(v->vec);
|
||||
NormalizeVector(v.vec);
|
||||
for (l = 0; l < rdp.num_lights - 1; l++)
|
||||
{
|
||||
if (!rdp.light[l].nonblack)
|
||||
continue;
|
||||
light_intensity = DotProduct(rdp.light_vector[l], v->vec);
|
||||
light_intensity = DotProduct(rdp.light_vector[l], v.vec);
|
||||
WriteTrace(TraceRDP, TraceDebug, "light %d, intensity : %f", l, light_intensity);
|
||||
if (light_intensity < 0.0f)
|
||||
continue;
|
||||
//*
|
||||
if (rdp.light[l].ca > 0.0f)
|
||||
{
|
||||
float vx = (v->x + uc8_coord_mod[8])*uc8_coord_mod[12] - rdp.light[l].x;
|
||||
float vy = (v->y + uc8_coord_mod[9])*uc8_coord_mod[13] - rdp.light[l].y;
|
||||
float vz = (v->z + uc8_coord_mod[10])*uc8_coord_mod[14] - rdp.light[l].z;
|
||||
float vw = (v->w + uc8_coord_mod[11])*uc8_coord_mod[15] - rdp.light[l].w;
|
||||
float vx = (v.x + uc8_coord_mod[8])*uc8_coord_mod[12] - rdp.light[l].x;
|
||||
float vy = (v.y + uc8_coord_mod[9])*uc8_coord_mod[13] - rdp.light[l].y;
|
||||
float vz = (v.z + uc8_coord_mod[10])*uc8_coord_mod[14] - rdp.light[l].z;
|
||||
float vw = (v.w + uc8_coord_mod[11])*uc8_coord_mod[15] - rdp.light[l].w;
|
||||
float len = (vx*vx + vy*vy + vz*vz + vw*vw) / 65536.0f;
|
||||
float p_i = rdp.light[l].ca / len;
|
||||
if (p_i > 1.0f) p_i = 1.0f;
|
||||
|
@ -153,7 +153,7 @@ void uc8_vertex()
|
|||
color[2] += rdp.light[l].b * light_intensity;
|
||||
WriteTrace(TraceRDP, TraceDebug, "light %d r: %f, g: %f, b: %f", l, color[0], color[1], color[2]);
|
||||
}
|
||||
light_intensity = DotProduct(rdp.light_vector[l], v->vec);
|
||||
light_intensity = DotProduct(rdp.light_vector[l], v.vec);
|
||||
WriteTrace(TraceRDP, TraceDebug, "light %d, intensity : %f", l, light_intensity);
|
||||
if (light_intensity > 0.0f)
|
||||
{
|
||||
|
@ -169,10 +169,10 @@ void uc8_vertex()
|
|||
{
|
||||
if (rdp.light[l].nonblack && rdp.light[l].nonzero)
|
||||
{
|
||||
float vx = (v->x + uc8_coord_mod[8])*uc8_coord_mod[12] - rdp.light[l].x;
|
||||
float vy = (v->y + uc8_coord_mod[9])*uc8_coord_mod[13] - rdp.light[l].y;
|
||||
float vz = (v->z + uc8_coord_mod[10])*uc8_coord_mod[14] - rdp.light[l].z;
|
||||
float vw = (v->w + uc8_coord_mod[11])*uc8_coord_mod[15] - rdp.light[l].w;
|
||||
float vx = (v.x + uc8_coord_mod[8])*uc8_coord_mod[12] - rdp.light[l].x;
|
||||
float vy = (v.y + uc8_coord_mod[9])*uc8_coord_mod[13] - rdp.light[l].y;
|
||||
float vz = (v.z + uc8_coord_mod[10])*uc8_coord_mod[14] - rdp.light[l].z;
|
||||
float vw = (v.w + uc8_coord_mod[11])*uc8_coord_mod[15] - rdp.light[l].w;
|
||||
float len = (vx*vx + vy*vy + vz*vz + vw*vw) / 65536.0f;
|
||||
light_intensity = rdp.light[l].ca / len;
|
||||
if (light_intensity > 1.0f) light_intensity = 1.0f;
|
||||
|
@ -187,10 +187,10 @@ void uc8_vertex()
|
|||
if (color[0] > 1.0f) color[0] = 1.0f;
|
||||
if (color[1] > 1.0f) color[1] = 1.0f;
|
||||
if (color[2] > 1.0f) color[2] = 1.0f;
|
||||
v->r = (uint8_t)(((float)v->r)*color[0]);
|
||||
v->g = (uint8_t)(((float)v->g)*color[1]);
|
||||
v->b = (uint8_t)(((float)v->b)*color[2]);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "color after light: r: 0x%02lx, g: 0x%02lx, b: 0x%02lx", v->r, v->g, v->b);
|
||||
v.r = (uint8_t)(((float)v.r)*color[0]);
|
||||
v.g = (uint8_t)(((float)v.g)*color[1]);
|
||||
v.b = (uint8_t)(((float)v.b)*color[2]);
|
||||
WriteTrace(TraceRDP, TraceVerbose, "color after light: r: 0x%02lx, g: 0x%02lx, b: 0x%02lx", v.r, v.g, v.b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -425,18 +425,18 @@ void uc8_tri4() //by Gugaman Apr 19 2002
|
|||
((rdp.cmd1 >> 0) & 0x1F));
|
||||
|
||||
VERTEX *v[12] = {
|
||||
&rdp.vtx[(rdp.cmd0 >> 23) & 0x1F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 18) & 0x1F],
|
||||
&rdp.vtx[((((rdp.cmd0 >> 15) & 0x7) << 2) | ((rdp.cmd1 >> 30) & 0x3))],
|
||||
&rdp.vtx[(rdp.cmd0 >> 10) & 0x1F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 5) & 0x1F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 0) & 0x1F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 25) & 0x1F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 20) & 0x1F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 15) & 0x1F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 10) & 0x1F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 5) & 0x1F],
|
||||
&rdp.vtx[(rdp.cmd1 >> 0) & 0x1F]
|
||||
&rdp.vtx((rdp.cmd0 >> 23) & 0x1F),
|
||||
&rdp.vtx((rdp.cmd0 >> 18) & 0x1F),
|
||||
&rdp.vtx(((((rdp.cmd0 >> 15) & 0x7) << 2) | ((rdp.cmd1 >> 30) & 0x3))),
|
||||
&rdp.vtx((rdp.cmd0 >> 10) & 0x1F),
|
||||
&rdp.vtx((rdp.cmd0 >> 5) & 0x1F),
|
||||
&rdp.vtx((rdp.cmd0 >> 0) & 0x1F),
|
||||
&rdp.vtx((rdp.cmd1 >> 25) & 0x1F),
|
||||
&rdp.vtx((rdp.cmd1 >> 20) & 0x1F),
|
||||
&rdp.vtx((rdp.cmd1 >> 15) & 0x1F),
|
||||
&rdp.vtx((rdp.cmd1 >> 10) & 0x1F),
|
||||
&rdp.vtx((rdp.cmd1 >> 5) & 0x1F),
|
||||
&rdp.vtx((rdp.cmd1 >> 0) & 0x1F)
|
||||
};
|
||||
|
||||
int updated = 0;
|
||||
|
|
|
@ -316,10 +316,10 @@ void uc9_light()
|
|||
v.vec[0] = ((char*)gfx.DMEM)[(nsrs++) ^ 3];
|
||||
v.vec[1] = ((char*)gfx.DMEM)[(nsrs++) ^ 3];
|
||||
v.vec[2] = ((char*)gfx.DMEM)[(nsrs++) ^ 3];
|
||||
calc_sphere(&v);
|
||||
calc_sphere(v);
|
||||
// calc_linear (&v);
|
||||
NormalizeVector(v.vec);
|
||||
calc_light(&v);
|
||||
calc_light(v);
|
||||
v.a = 0xFF;
|
||||
if (use_material)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue