[Glide64] Cleanup ucode .h files
This commit is contained in:
parent
b8cbfa30c4
commit
4fc4f921e9
|
@ -74,12 +74,10 @@ struct t3dState {
|
|||
uint32_t othermode1;
|
||||
};
|
||||
|
||||
|
||||
struct t3dTriN{
|
||||
uint8_t flag, v2, v1, v0; /* flag is which one for flat shade */
|
||||
};
|
||||
|
||||
|
||||
static void t3dProcessRDP(uint32_t a)
|
||||
{
|
||||
if (a)
|
||||
|
@ -88,10 +86,10 @@ static void t3dProcessRDP(uint32_t a)
|
|||
rdp.cmd0 = ((uint32_t*)gfx.RDRAM)[a++];
|
||||
rdp.cmd1 = ((uint32_t*)gfx.RDRAM)[a++];
|
||||
while (rdp.cmd0 + rdp.cmd1) {
|
||||
gfx_instruction[0][rdp.cmd0>>24] ();
|
||||
gfx_instruction[0][rdp.cmd0 >> 24]();
|
||||
rdp.cmd0 = ((uint32_t*)gfx.RDRAM)[a++];
|
||||
rdp.cmd1 = ((uint32_t*)gfx.RDRAM)[a++];
|
||||
uint32_t cmd = rdp.cmd0>>24;
|
||||
uint32_t cmd = rdp.cmd0 >> 24;
|
||||
if (cmd == 0xE4 || cmd == 0xE5)
|
||||
{
|
||||
rdp.cmd2 = ((uint32_t*)gfx.RDRAM)[a++];
|
||||
|
@ -105,7 +103,7 @@ static void t3dProcessRDP(uint32_t a)
|
|||
static void t3dLoadGlobState(uint32_t pgstate)
|
||||
{
|
||||
t3dGlobState *gstate = (t3dGlobState*)&gfx.RDRAM[segoffset(pgstate)];
|
||||
FRDP ("Global state. pad0: %04lx, perspNorm: %04lx, flag: %08lx\n", gstate->pad0, gstate->perspNorm, gstate->flag);
|
||||
FRDP("Global state. pad0: %04lx, perspNorm: %04lx, flag: %08lx\n", gstate->pad0, gstate->perspNorm, gstate->flag);
|
||||
rdp.cmd0 = gstate->othermode0;
|
||||
rdp.cmd1 = gstate->othermode1;
|
||||
rdp_setothermode();
|
||||
|
@ -113,7 +111,7 @@ static void t3dLoadGlobState(uint32_t pgstate)
|
|||
for (int s = 0; s < 16; s++)
|
||||
{
|
||||
rdp.segment[s] = gstate->segBases[s];
|
||||
FRDP ("segment: %08lx -> seg%d\n", rdp.segment[s], s);
|
||||
FRDP("segment: %08lx -> seg%d\n", rdp.segment[s], s);
|
||||
}
|
||||
|
||||
short scale_x = gstate->vsacle0 / 4;
|
||||
|
@ -129,7 +127,7 @@ static void t3dLoadGlobState(uint32_t pgstate)
|
|||
rdp.view_trans[1] = trans_y * rdp.scale_y;
|
||||
rdp.view_trans[2] = 32.0f * trans_z;
|
||||
rdp.update |= UPDATE_VIEWPORT;
|
||||
FRDP ("viewport scale(%d, %d, %d), trans(%d, %d, %d)\n", scale_x, scale_y, scale_z,
|
||||
FRDP("viewport scale(%d, %d, %d), trans(%d, %d, %d)\n", scale_x, scale_y, scale_z,
|
||||
trans_x, trans_y, trans_z);
|
||||
|
||||
t3dProcessRDP(segoffset(gstate->rdpCmds) >> 2);
|
||||
|
@ -143,20 +141,20 @@ static void t3d_vertex(uint32_t addr, uint32_t v0, uint32_t n)
|
|||
rdp.vn = n; // Number of vertices to copy
|
||||
n <<= 4;
|
||||
|
||||
for (uint32_t i=0; i < n; i+=16)
|
||||
for (uint32_t i = 0; i < n; i += 16)
|
||||
{
|
||||
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];
|
||||
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->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];
|
||||
|
@ -189,7 +187,7 @@ static void t3dLoadObject(uint32_t pstate, uint32_t pvtx, uint32_t ptri)
|
|||
{
|
||||
LRDP("Loading Turbo3D object\n");
|
||||
t3dState *ostate = (t3dState*)&gfx.RDRAM[segoffset(pstate)];
|
||||
rdp.cur_tile = (ostate->textureState)&7;
|
||||
rdp.cur_tile = (ostate->textureState) & 7;
|
||||
FRDP("tile: %d\n", rdp.cur_tile);
|
||||
if (rdp.tiles[rdp.cur_tile].s_scale < 0.001f)
|
||||
rdp.tiles[rdp.cur_tile].s_scale = 0.015625;
|
||||
|
@ -208,9 +206,9 @@ static void t3dLoadObject(uint32_t pstate, uint32_t pvtx, uint32_t ptri)
|
|||
rdp.cmd1 = ostate->renderState;
|
||||
uc0_setgeometrymode();
|
||||
|
||||
if (!(ostate->flag&1)) //load matrix
|
||||
if (!(ostate->flag & 1)) //load matrix
|
||||
{
|
||||
uint32_t addr = segoffset(pstate+sizeof(t3dState)) & BMASK;
|
||||
uint32_t addr = segoffset(pstate + sizeof(t3dState)) & BMASK;
|
||||
load_matrix(rdp.combined, addr);
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.combined[0][0], rdp.combined[0][1], rdp.combined[0][2], rdp.combined[0][3]);
|
||||
|
@ -229,20 +227,20 @@ static void t3dLoadObject(uint32_t pstate, uint32_t pvtx, uint32_t ptri)
|
|||
|
||||
if (ptri)
|
||||
{
|
||||
update ();
|
||||
update();
|
||||
uint32_t a = segoffset(ptri);
|
||||
for (int t=0; t < ostate->triCount; t++)
|
||||
for (int t = 0; t < ostate->triCount; t++)
|
||||
{
|
||||
t3dTriN * tri = (t3dTriN*)&gfx.RDRAM[a];
|
||||
a += 4;
|
||||
FRDP("tri #%d - %d, %d, %d\n", 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))
|
||||
rdp.tri_n ++;
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
draw_tri (v);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -255,10 +253,10 @@ static void Turbo3D()
|
|||
uint32_t a = 0, pgstate = 0, pstate = 0, pvtx = 0, ptri = 0;
|
||||
do {
|
||||
a = rdp.pc[rdp.pc_i] & BMASK;
|
||||
pgstate = ((uint32_t*)gfx.RDRAM)[a>>2];
|
||||
pstate = ((uint32_t*)gfx.RDRAM)[(a>>2)+1];
|
||||
pvtx = ((uint32_t*)gfx.RDRAM)[(a>>2)+2];
|
||||
ptri = ((uint32_t*)gfx.RDRAM)[(a>>2)+3];
|
||||
pgstate = ((uint32_t*)gfx.RDRAM)[a >> 2];
|
||||
pstate = ((uint32_t*)gfx.RDRAM)[(a >> 2) + 1];
|
||||
pvtx = ((uint32_t*)gfx.RDRAM)[(a >> 2) + 2];
|
||||
ptri = ((uint32_t*)gfx.RDRAM)[(a >> 2) + 3];
|
||||
FRDP("GlobalState: %08lx, Object: %08lx, Vertices: %08lx, Triangles: %08lx\n", pgstate, pstate, pvtx, ptri);
|
||||
if (!pstate)
|
||||
{
|
||||
|
@ -271,6 +269,6 @@ static void Turbo3D()
|
|||
// Go to the next instruction
|
||||
rdp.pc[rdp.pc_i] += 16;
|
||||
} while (pstate);
|
||||
// rdp_fullsync();
|
||||
// rdp_fullsync();
|
||||
settings.ucode = ucode_Turbo3d;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
//
|
||||
//****************************************************************
|
||||
|
||||
typedef void (*rdp_instr)();
|
||||
typedef void(*rdp_instr)();
|
||||
|
||||
// RDP graphic instructions pointer table
|
||||
|
||||
|
|
|
@ -73,39 +73,38 @@ static void rsp_vertex(int v0, int n)
|
|||
rdp.update ^= UPDATE_LIGHTS;
|
||||
|
||||
// Calculate light vectors
|
||||
for (uint32_t l=0; l<rdp.num_lights; l++)
|
||||
for (uint32_t l = 0; l < rdp.num_lights; l++)
|
||||
{
|
||||
InverseTransformVector(&rdp.light[l].dir_x, rdp.light_vector[l], rdp.model);
|
||||
NormalizeVector (rdp.light_vector[l]);
|
||||
NormalizeVector(rdp.light_vector[l]);
|
||||
}
|
||||
}
|
||||
|
||||
FRDP ("rsp:vertex v0:%d, n:%d, from: %08lx\n", v0, n, addr);
|
||||
FRDP("rsp:vertex v0:%d, n:%d, from: %08lx\n", v0, n, addr);
|
||||
|
||||
for (i=0; i < (n<<4); i+=16)
|
||||
for (i = 0; i < (n << 4); i += 16)
|
||||
{
|
||||
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];
|
||||
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->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];
|
||||
|
||||
|
||||
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);
|
||||
CalculateFog(v);
|
||||
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->screen_translated = 0;
|
||||
|
@ -117,73 +116,72 @@ static void rsp_vertex(int v0, int n)
|
|||
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 (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)
|
||||
calc_linear (v);
|
||||
calc_linear(v);
|
||||
else
|
||||
calc_sphere (v);
|
||||
calc_sphere(v);
|
||||
}
|
||||
NormalizeVector (v->vec);
|
||||
NormalizeVector(v->vec);
|
||||
|
||||
calc_light (v);
|
||||
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];
|
||||
}
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("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\n", 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);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void rsp_tri1(VERTEX **v, uint16_t linew = 0)
|
||||
{
|
||||
if (cull_tri(v))
|
||||
rdp.tri_n ++;
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
update ();
|
||||
draw_tri (v, linew);
|
||||
rdp.tri_n ++;
|
||||
update();
|
||||
draw_tri(v, linew);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
}
|
||||
|
||||
static void rsp_tri2 (VERTEX **v)
|
||||
static void rsp_tri2(VERTEX **v)
|
||||
{
|
||||
int updated = 0;
|
||||
|
||||
if (cull_tri(v))
|
||||
rdp.tri_n ++;
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
updated = 1;
|
||||
update ();
|
||||
update();
|
||||
|
||||
draw_tri (v);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v+3))
|
||||
rdp.tri_n ++;
|
||||
if (cull_tri(v + 3))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
if (!updated)
|
||||
update ();
|
||||
update();
|
||||
|
||||
draw_tri (v+3);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v + 3);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,35 +197,35 @@ static void uc0_vertex()
|
|||
|
||||
// ** Definitions **
|
||||
|
||||
void modelview_load (float m[4][4])
|
||||
void modelview_load(float m[4][4])
|
||||
{
|
||||
memcpy (rdp.model, m, 64); // 4*4*4(float)
|
||||
memcpy(rdp.model, m, 64); // 4*4*4(float)
|
||||
|
||||
rdp.update |= UPDATE_MULT_MAT | UPDATE_LIGHTS;
|
||||
}
|
||||
|
||||
void modelview_mul (float m[4][4])
|
||||
void modelview_mul(float m[4][4])
|
||||
{
|
||||
DECLAREALIGN16VAR(m_src[4][4]);
|
||||
memcpy (m_src, rdp.model, 64);
|
||||
memcpy(m_src, rdp.model, 64);
|
||||
MulMatrices(m, m_src, rdp.model);
|
||||
rdp.update |= UPDATE_MULT_MAT | UPDATE_LIGHTS;
|
||||
}
|
||||
|
||||
void modelview_push ()
|
||||
void modelview_push()
|
||||
{
|
||||
if (rdp.model_i == rdp.model_stack_size)
|
||||
{
|
||||
RDP_E ("** Model matrix stack overflow ** too many pushes\n");
|
||||
RDP_E("** Model matrix stack overflow ** too many pushes\n");
|
||||
LRDP("** Model matrix stack overflow ** too many pushes\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy (rdp.model_stack[rdp.model_i], rdp.model, 64);
|
||||
rdp.model_i ++;
|
||||
memcpy(rdp.model_stack[rdp.model_i], rdp.model, 64);
|
||||
rdp.model_i++;
|
||||
}
|
||||
|
||||
void modelview_pop (int num = 1)
|
||||
void modelview_pop(int num = 1)
|
||||
{
|
||||
if (rdp.model_i > num - 1)
|
||||
{
|
||||
|
@ -235,52 +233,52 @@ void modelview_pop (int num = 1)
|
|||
}
|
||||
else
|
||||
{
|
||||
RDP_E ("** Model matrix stack error ** too many pops\n");
|
||||
RDP_E("** Model matrix stack error ** too many pops\n");
|
||||
LRDP("** Model matrix stack error ** too many pops\n");
|
||||
return;
|
||||
}
|
||||
memcpy (rdp.model, rdp.model_stack[rdp.model_i], 64);
|
||||
memcpy(rdp.model, rdp.model_stack[rdp.model_i], 64);
|
||||
rdp.update |= UPDATE_MULT_MAT | UPDATE_LIGHTS;
|
||||
}
|
||||
|
||||
void modelview_load_push (float m[4][4])
|
||||
void modelview_load_push(float m[4][4])
|
||||
{
|
||||
modelview_push ();
|
||||
modelview_load (m);
|
||||
modelview_push();
|
||||
modelview_load(m);
|
||||
}
|
||||
|
||||
void modelview_mul_push (float m[4][4])
|
||||
void modelview_mul_push(float m[4][4])
|
||||
{
|
||||
modelview_push ();
|
||||
modelview_mul (m);
|
||||
modelview_push();
|
||||
modelview_mul(m);
|
||||
}
|
||||
|
||||
void projection_load (float m[4][4])
|
||||
void projection_load(float m[4][4])
|
||||
{
|
||||
memcpy (rdp.proj, m, 64); // 4*4*4(float)
|
||||
memcpy(rdp.proj, m, 64); // 4*4*4(float)
|
||||
|
||||
rdp.update |= UPDATE_MULT_MAT;
|
||||
}
|
||||
|
||||
void projection_mul (float m[4][4])
|
||||
void projection_mul(float m[4][4])
|
||||
{
|
||||
DECLAREALIGN16VAR(m_src[4][4]);
|
||||
memcpy (m_src, rdp.proj, 64);
|
||||
memcpy(m_src, rdp.proj, 64);
|
||||
MulMatrices(m, m_src, rdp.proj);
|
||||
rdp.update |= UPDATE_MULT_MAT;
|
||||
}
|
||||
|
||||
void load_matrix (float m[4][4], uint32_t addr)
|
||||
void load_matrix(float m[4][4], uint32_t addr)
|
||||
{
|
||||
FRDP ("matrix - addr: %08lx\n", addr);
|
||||
int x,y; // matrix index
|
||||
FRDP("matrix - addr: %08lx\n", addr);
|
||||
int x, y; // matrix index
|
||||
addr >>= 1;
|
||||
uint16_t * src = (uint16_t*)gfx.RDRAM;
|
||||
for (x=0; x<16; x+=4) { // Adding 4 instead of one, just to remove mult. later
|
||||
for (y=0; y<4; y++) {
|
||||
m[x>>2][y] = (float)(
|
||||
(((int32_t)src[(addr+x+y)^1]) << 16) |
|
||||
src[(addr+x+y+16)^1]
|
||||
for (x = 0; x < 16; x += 4) { // Adding 4 instead of one, just to remove mult. later
|
||||
for (y = 0; y < 4; y++) {
|
||||
m[x >> 2][y] = (float)(
|
||||
(((int32_t)src[(addr + x + y) ^ 1]) << 16) |
|
||||
src[(addr + x + y + 16) ^ 1]
|
||||
) / 65536.0f;
|
||||
}
|
||||
}
|
||||
|
@ -304,44 +302,44 @@ static void uc0_matrix()
|
|||
{
|
||||
case 0: // modelview mul nopush
|
||||
LRDP("modelview mul\n");
|
||||
modelview_mul (m);
|
||||
modelview_mul(m);
|
||||
break;
|
||||
|
||||
case 1: // projection mul nopush
|
||||
case 5: // projection mul push, can't push projection
|
||||
LRDP("projection mul\n");
|
||||
projection_mul (m);
|
||||
projection_mul(m);
|
||||
break;
|
||||
|
||||
case 2: // modelview load nopush
|
||||
LRDP("modelview load\n");
|
||||
modelview_load (m);
|
||||
modelview_load(m);
|
||||
break;
|
||||
|
||||
case 3: // projection load nopush
|
||||
case 7: // projection load push, can't push projection
|
||||
LRDP("projection load\n");
|
||||
projection_load (m);
|
||||
projection_load(m);
|
||||
|
||||
break;
|
||||
|
||||
case 4: // modelview mul push
|
||||
LRDP("modelview mul push\n");
|
||||
modelview_mul_push (m);
|
||||
modelview_mul_push(m);
|
||||
break;
|
||||
|
||||
case 6: // modelview load push
|
||||
LRDP("modelview load push\n");
|
||||
modelview_load_push (m);
|
||||
modelview_load_push(m);
|
||||
break;
|
||||
|
||||
default:
|
||||
FRDP_E ("Unknown matrix command, %02lx", command);
|
||||
FRDP ("Unknown matrix command, %02lx", command);
|
||||
FRDP_E("Unknown matrix command, %02lx", command);
|
||||
FRDP("Unknown matrix command, %02lx", command);
|
||||
}
|
||||
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("{%f,%f,%f,%f}\n", m[0][0], m[0][1], m[0][2], m[0][3]);
|
||||
FRDP("{%f,%f,%f,%f}\n", m[0][0], m[0][1], m[0][2], m[0][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", m[1][0], m[1][1], m[1][2], m[1][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", m[2][0], m[2][1], m[2][2], m[2][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", m[3][0], m[3][1], m[3][2], m[3][3]);
|
||||
|
@ -363,7 +361,7 @@ static void uc0_movemem()
|
|||
{
|
||||
LRDP("uc0:movemem ");
|
||||
|
||||
uint32_t i,a;
|
||||
uint32_t i, a;
|
||||
|
||||
// Check the command
|
||||
switch ((rdp.cmd0 >> 16) & 0xFF)
|
||||
|
@ -372,12 +370,12 @@ static void uc0_movemem()
|
|||
{
|
||||
a = (segoffset(rdp.cmd1) & 0xFFFFFF) >> 1;
|
||||
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a+0)^1] / 4;
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a+1)^1] / 4;
|
||||
short scale_z = ((short*)gfx.RDRAM)[(a+2)^1];
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a+4)^1] / 4;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a+5)^1] / 4;
|
||||
short trans_z = ((short*)gfx.RDRAM)[(a+6)^1];
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a + 0) ^ 1] / 4;
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a + 1) ^ 1] / 4;
|
||||
short scale_z = ((short*)gfx.RDRAM)[(a + 2) ^ 1];
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a + 4) ^ 1] / 4;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a + 5) ^ 1] / 4;
|
||||
short trans_z = ((short*)gfx.RDRAM)[(a + 6) ^ 1];
|
||||
if (settings.correct_viewport)
|
||||
{
|
||||
scale_x = abs(scale_x);
|
||||
|
@ -394,7 +392,7 @@ static void uc0_movemem()
|
|||
|
||||
rdp.update |= UPDATE_VIEWPORT;
|
||||
|
||||
FRDP ("viewport scale(%d, %d, %d), trans(%d, %d, %d), from:%08lx\n", scale_x, scale_y, scale_z,
|
||||
FRDP("viewport scale(%d, %d, %d), trans(%d, %d, %d), from:%08lx\n", scale_x, scale_y, scale_z,
|
||||
trans_x, trans_y, trans_z, rdp.cmd1);
|
||||
}
|
||||
break;
|
||||
|
@ -402,11 +400,11 @@ static void uc0_movemem()
|
|||
case 0x82:
|
||||
{
|
||||
a = segoffset(rdp.cmd1) & 0x00ffffff;
|
||||
char dir_x = ((char*)gfx.RDRAM)[(a+8)^3];
|
||||
char dir_x = ((char*)gfx.RDRAM)[(a + 8) ^ 3];
|
||||
rdp.lookat[1][0] = (float)(dir_x) / 127.0f;
|
||||
char dir_y = ((char*)gfx.RDRAM)[(a+9)^3];
|
||||
char dir_y = ((char*)gfx.RDRAM)[(a + 9) ^ 3];
|
||||
rdp.lookat[1][1] = (float)(dir_y) / 127.0f;
|
||||
char dir_z = ((char*)gfx.RDRAM)[(a+10)^3];
|
||||
char dir_z = ((char*)gfx.RDRAM)[(a + 10) ^ 3];
|
||||
rdp.lookat[1][2] = (float)(dir_z) / 127.0f;
|
||||
if (!dir_x && !dir_y)
|
||||
rdp.use_lookat = FALSE;
|
||||
|
@ -418,9 +416,9 @@ static void uc0_movemem()
|
|||
|
||||
case 0x84:
|
||||
a = segoffset(rdp.cmd1) & 0x00ffffff;
|
||||
rdp.lookat[0][0] = (float)(((char*)gfx.RDRAM)[(a+8)^3]) / 127.0f;
|
||||
rdp.lookat[0][1] = (float)(((char*)gfx.RDRAM)[(a+9)^3]) / 127.0f;
|
||||
rdp.lookat[0][2] = (float)(((char*)gfx.RDRAM)[(a+10)^3]) / 127.0f;
|
||||
rdp.lookat[0][0] = (float)(((char*)gfx.RDRAM)[(a + 8) ^ 3]) / 127.0f;
|
||||
rdp.lookat[0][1] = (float)(((char*)gfx.RDRAM)[(a + 9) ^ 3]) / 127.0f;
|
||||
rdp.lookat[0][2] = (float)(((char*)gfx.RDRAM)[(a + 10) ^ 3]) / 127.0f;
|
||||
rdp.use_lookat = TRUE;
|
||||
FRDP("lookat_x (%f, %f, %f)\n", rdp.lookat[1][0], rdp.lookat[1][1], rdp.lookat[1][2]);
|
||||
break;
|
||||
|
@ -438,25 +436,24 @@ static void uc0_movemem()
|
|||
a = segoffset(rdp.cmd1) & 0x00ffffff;
|
||||
|
||||
// Get the data
|
||||
rdp.light[i].r = (float)(((uint8_t*)gfx.RDRAM)[(a+0)^3]) / 255.0f;
|
||||
rdp.light[i].g = (float)(((uint8_t*)gfx.RDRAM)[(a+1)^3]) / 255.0f;
|
||||
rdp.light[i].b = (float)(((uint8_t*)gfx.RDRAM)[(a+2)^3]) / 255.0f;
|
||||
rdp.light[i].r = (float)(((uint8_t*)gfx.RDRAM)[(a + 0) ^ 3]) / 255.0f;
|
||||
rdp.light[i].g = (float)(((uint8_t*)gfx.RDRAM)[(a + 1) ^ 3]) / 255.0f;
|
||||
rdp.light[i].b = (float)(((uint8_t*)gfx.RDRAM)[(a + 2) ^ 3]) / 255.0f;
|
||||
rdp.light[i].a = 1.0f;
|
||||
// ** Thanks to Icepir8 for pointing this out **
|
||||
// Lighting must be signed byte instead of byte
|
||||
rdp.light[i].dir_x = (float)(((char*)gfx.RDRAM)[(a+8)^3]) / 127.0f;
|
||||
rdp.light[i].dir_y = (float)(((char*)gfx.RDRAM)[(a+9)^3]) / 127.0f;
|
||||
rdp.light[i].dir_z = (float)(((char*)gfx.RDRAM)[(a+10)^3]) / 127.0f;
|
||||
rdp.light[i].dir_x = (float)(((char*)gfx.RDRAM)[(a + 8) ^ 3]) / 127.0f;
|
||||
rdp.light[i].dir_y = (float)(((char*)gfx.RDRAM)[(a + 9) ^ 3]) / 127.0f;
|
||||
rdp.light[i].dir_z = (float)(((char*)gfx.RDRAM)[(a + 10) ^ 3]) / 127.0f;
|
||||
// **
|
||||
|
||||
//rdp.update |= UPDATE_LIGHTS;
|
||||
|
||||
FRDP ("light: n: %d, r: %.3f, g: %.3f, b: %.3f, x: %.3f, y: %.3f, z: %.3f\n",
|
||||
FRDP("light: n: %d, r: %.3f, g: %.3f, b: %.3f, x: %.3f, y: %.3f, z: %.3f\n",
|
||||
i, rdp.light[i].r, rdp.light[i].g, rdp.light[i].b,
|
||||
rdp.light_vector[i][0], rdp.light_vector[i][1], rdp.light_vector[i][2]);
|
||||
break;
|
||||
|
||||
|
||||
case 0x9E: //gSPForceMatrix command. Modification of uc2_movemem:matrix. Gonetz.
|
||||
{
|
||||
// do not update the combined matrix!
|
||||
|
@ -466,11 +463,11 @@ static void uc0_movemem()
|
|||
load_matrix(rdp.combined, addr);
|
||||
|
||||
addr = rdp.pc[rdp.pc_i] & BMASK;
|
||||
rdp.pc[rdp.pc_i] = (addr+24) & BMASK; //skip next 3 command, b/c they all are part of gSPForceMatrix
|
||||
rdp.pc[rdp.pc_i] = (addr + 24) & BMASK; //skip next 3 command, b/c they all are part of gSPForceMatrix
|
||||
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.combined[0][0], rdp.combined[0][1], rdp.combined[0][2], rdp.combined[0][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.combined[1][0], rdp.combined[1][1], rdp.combined[1][2], rdp.combined[1][3]);
|
||||
FRDP("{%f,%f,%f,%f}\n", rdp.combined[0][0], rdp.combined[0][1], rdp.combined[0][2], rdp.combined[0][3]);
|
||||
FRDP("{%f,%f,%f,%f}\n", rdp.combined[1][0], rdp.combined[1][1], rdp.combined[1][2], rdp.combined[1][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.combined[2][0], rdp.combined[2][1], rdp.combined[2][2], rdp.combined[2][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.combined[3][0], rdp.combined[3][1], rdp.combined[3][2], rdp.combined[3][3]);
|
||||
#endif
|
||||
|
@ -479,25 +476,25 @@ static void uc0_movemem()
|
|||
|
||||
//next 3 command should never appear since they will be skipped in previous command
|
||||
case 0x98:
|
||||
RDP_E ("uc0:movemem matrix 0 - ERROR!\n");
|
||||
RDP_E("uc0:movemem matrix 0 - ERROR!\n");
|
||||
LRDP("matrix 0 - IGNORED\n");
|
||||
break;
|
||||
|
||||
case 0x9A:
|
||||
RDP_E ("uc0:movemem matrix 1 - ERROR!\n");
|
||||
RDP_E("uc0:movemem matrix 1 - ERROR!\n");
|
||||
LRDP("matrix 1 - IGNORED\n");
|
||||
break;
|
||||
|
||||
case 0x9C:
|
||||
RDP_E ("uc0:movemem matrix 2 - ERROR!\n");
|
||||
RDP_E("uc0:movemem matrix 2 - ERROR!\n");
|
||||
LRDP("matrix 2 - IGNORED\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
FRDP_E ("uc0:movemem unknown (index: 0x%08lx)\n", (rdp.cmd0 >> 16) & 0xFF);
|
||||
FRDP ("unknown (index: 0x%08lx)\n", (rdp.cmd0 >> 16) & 0xFF);
|
||||
FRDP_E("uc0:movemem unknown (index: 0x%08lx)\n", (rdp.cmd0 >> 16) & 0xFF);
|
||||
FRDP("unknown (index: 0x%08lx)\n", (rdp.cmd0 >> 16) & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// uc0:displaylist - makes a call to another section of code
|
||||
|
@ -511,18 +508,18 @@ static void uc0_displaylist()
|
|||
|
||||
uint32_t push = (rdp.cmd0 >> 16) & 0xFF; // push the old location?
|
||||
|
||||
FRDP("uc0:displaylist: %08lx, push:%s", addr, push?"no":"yes");
|
||||
FRDP(" (seg %d, offset %08lx)\n", (rdp.cmd1>>24)&0x0F, rdp.cmd1&0x00FFFFFF);
|
||||
FRDP("uc0:displaylist: %08lx, push:%s", addr, push ? "no" : "yes");
|
||||
FRDP(" (seg %d, offset %08lx)\n", (rdp.cmd1 >> 24) & 0x0F, rdp.cmd1 & 0x00FFFFFF);
|
||||
|
||||
switch (push)
|
||||
{
|
||||
case 0: // push
|
||||
if (rdp.pc_i >= 9) {
|
||||
RDP_E ("** DL stack overflow **");
|
||||
RDP_E("** DL stack overflow **");
|
||||
LRDP("** DL stack overflow **\n");
|
||||
return;
|
||||
}
|
||||
rdp.pc_i ++; // go to the next PC in the stack
|
||||
rdp.pc_i++; // go to the next PC in the stack
|
||||
rdp.pc[rdp.pc_i] = addr; // jump to the address
|
||||
break;
|
||||
|
||||
|
@ -542,8 +539,8 @@ static void uc0_displaylist()
|
|||
static void uc0_tri1()
|
||||
{
|
||||
FRDP("uc0:tri1 #%d - %d, %d, %d\n", rdp.tri_n,
|
||||
((rdp.cmd1>>16) & 0xFF) / 10,
|
||||
((rdp.cmd1>>8) & 0xFF) / 10,
|
||||
((rdp.cmd1 >> 16) & 0xFF) / 10,
|
||||
((rdp.cmd1 >> 8) & 0xFF) / 10,
|
||||
(rdp.cmd1 & 0xFF) / 10);
|
||||
|
||||
VERTEX *v[3] = {
|
||||
|
@ -581,7 +578,7 @@ static void uc0_enddl()
|
|||
rdp.halt = 1;
|
||||
}
|
||||
|
||||
rdp.pc_i --;
|
||||
rdp.pc_i--;
|
||||
}
|
||||
|
||||
static void uc0_culldl()
|
||||
|
@ -594,7 +591,7 @@ static void uc0_culldl()
|
|||
FRDP("uc0:culldl start: %d, end: %d\n", vStart, vEnd);
|
||||
|
||||
if (vEnd < vStart) return;
|
||||
for (uint16_t i=vStart; i<=vEnd; i++)
|
||||
for (uint16_t i = vStart; i <= vEnd; i++)
|
||||
{
|
||||
v = &rdp.vtx[i];
|
||||
// Check if completely off the screen (quick frustrum clipping for 90 FOV)
|
||||
|
@ -614,7 +611,7 @@ static void uc0_culldl()
|
|||
}
|
||||
|
||||
LRDP(" - "); // specify that the enddl is not a real command
|
||||
uc0_enddl ();
|
||||
uc0_enddl();
|
||||
}
|
||||
|
||||
static void uc0_popmatrix()
|
||||
|
@ -626,19 +623,19 @@ static void uc0_popmatrix()
|
|||
switch (param)
|
||||
{
|
||||
case 0: // modelview
|
||||
modelview_pop ();
|
||||
modelview_pop();
|
||||
break;
|
||||
|
||||
case 1: // projection, can't
|
||||
break;
|
||||
|
||||
default:
|
||||
FRDP_E ("Unknown uc0:popmatrix command: 0x%08lx\n", param);
|
||||
FRDP ("Unknown uc0:popmatrix command: 0x%08lx\n", param);
|
||||
FRDP_E("Unknown uc0:popmatrix command: 0x%08lx\n", param);
|
||||
FRDP("Unknown uc0:popmatrix command: 0x%08lx\n", param);
|
||||
}
|
||||
}
|
||||
|
||||
static void uc6_obj_sprite ();
|
||||
static void uc6_obj_sprite();
|
||||
|
||||
static void uc0_modifyvtx(uint8_t where, uint16_t vtx, uint32_t val)
|
||||
{
|
||||
|
@ -647,7 +644,7 @@ static void uc0_modifyvtx(uint8_t where, uint16_t vtx, uint32_t val)
|
|||
switch (where)
|
||||
{
|
||||
case 0:
|
||||
uc6_obj_sprite ();
|
||||
uc6_obj_sprite();
|
||||
break;
|
||||
|
||||
case 0x10: // RGBA
|
||||
|
@ -657,25 +654,25 @@ static void uc0_modifyvtx(uint8_t where, uint16_t vtx, uint32_t val)
|
|||
v->a = (uint8_t)(val & 0xFF);
|
||||
v->shade_mod = 0;
|
||||
|
||||
FRDP ("RGBA: %d, %d, %d, %d\n", v->r, v->g, v->b, v->a);
|
||||
FRDP("RGBA: %d, %d, %d, %d\n", 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->ou = (float)((short)(val >> 16)) * scale;
|
||||
v->ov = (float)((short)(val & 0xFFFF)) * scale;
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->uv_scaled = 1;
|
||||
}
|
||||
FRDP ("u/v: (%04lx, %04lx), (%f, %f)\n", (short)(val>>16), (short)(val&0xFFFF),
|
||||
FRDP("u/v: (%04lx, %04lx), (%f, %f)\n", (short)(val >> 16), (short)(val & 0xFFFF),
|
||||
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;
|
||||
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;
|
||||
|
@ -694,16 +691,16 @@ static void uc0_modifyvtx(uint8_t where, uint16_t vtx, uint32_t val)
|
|||
if (scr_y > rdp.vi_height) v->scr_off |= 8;
|
||||
if (v->w < 0.1f) v->scr_off |= 16;
|
||||
|
||||
FRDP ("x/y: (%f, %f)\n", scr_x, scr_y);
|
||||
FRDP("x/y: (%f, %f)\n", scr_x, scr_y);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x1C: // Z screen
|
||||
{
|
||||
float scr_z = (float)((short)(val>>16));
|
||||
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;
|
||||
FRDP ("z: %f\n", scr_z);
|
||||
FRDP("z: %f\n", scr_z);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -724,7 +721,7 @@ static void uc0_moveword()
|
|||
switch (rdp.cmd0 & 0xFF)
|
||||
{
|
||||
case 0x00:
|
||||
RDP_E ("uc0:moveword matrix - IGNORED\n");
|
||||
RDP_E("uc0:moveword matrix - IGNORED\n");
|
||||
LRDP("matrix - IGNORED\n");
|
||||
break;
|
||||
|
||||
|
@ -733,21 +730,21 @@ static void uc0_moveword()
|
|||
if (rdp.num_lights > 8) rdp.num_lights = 0;
|
||||
|
||||
rdp.update |= UPDATE_LIGHTS;
|
||||
FRDP ("numlights: %d\n", rdp.num_lights);
|
||||
FRDP("numlights: %d\n", rdp.num_lights);
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
if (((rdp.cmd0>>8)&0xFFFF) == 0x04)
|
||||
if (((rdp.cmd0 >> 8) & 0xFFFF) == 0x04)
|
||||
{
|
||||
rdp.clip_ratio = sqrt((float)rdp.cmd1);
|
||||
rdp.update |= UPDATE_VIEWPORT;
|
||||
}
|
||||
FRDP ("clip %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
FRDP("clip %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
break;
|
||||
|
||||
case 0x06: // segment
|
||||
FRDP ("segment: %08lx -> seg%d\n", rdp.cmd1, (rdp.cmd0 >> 10) & 0x0F);
|
||||
if ((rdp.cmd1&BMASK)<BMASK)
|
||||
FRDP("segment: %08lx -> seg%d\n", rdp.cmd1, (rdp.cmd0 >> 10) & 0x0F);
|
||||
if ((rdp.cmd1&BMASK) < BMASK)
|
||||
rdp.segment[(rdp.cmd0 >> 10) & 0x0F] = rdp.cmd1;
|
||||
break;
|
||||
|
||||
|
@ -755,14 +752,14 @@ static void uc0_moveword()
|
|||
{
|
||||
rdp.fog_multiplier = (short)(rdp.cmd1 >> 16);
|
||||
rdp.fog_offset = (short)(rdp.cmd1 & 0x0000FFFF);
|
||||
FRDP ("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
FRDP("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0a: // moveword LIGHTCOL
|
||||
{
|
||||
int n = (rdp.cmd0&0xE000) >> 13;
|
||||
FRDP ("lightcol light:%d, %08lx\n", n, rdp.cmd1);
|
||||
int n = (rdp.cmd0 & 0xE000) >> 13;
|
||||
FRDP("lightcol light:%d, %08lx\n", n, rdp.cmd1);
|
||||
|
||||
rdp.light[n].r = (float)((rdp.cmd1 >> 24) & 0xFF) / 255.0f;
|
||||
rdp.light[n].g = (float)((rdp.cmd1 >> 16) & 0xFF) / 255.0f;
|
||||
|
@ -775,9 +772,9 @@ static void uc0_moveword()
|
|||
{
|
||||
uint16_t val = (uint16_t)((rdp.cmd0 >> 8) & 0xFFFF);
|
||||
uint16_t vtx = val / 40;
|
||||
uint8_t where = val%40;
|
||||
uint8_t where = val % 40;
|
||||
uc0_modifyvtx(where, vtx, rdp.cmd1);
|
||||
FRDP ("uc0:modifyvtx: vtx: %d, where: 0x%02lx, val: %08lx - ", vtx, where, rdp.cmd1);
|
||||
FRDP("uc0:modifyvtx: vtx: %d, where: 0x%02lx, val: %08lx - ", vtx, where, rdp.cmd1);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -786,8 +783,8 @@ static void uc0_moveword()
|
|||
break;
|
||||
|
||||
default:
|
||||
FRDP_E ("uc0:moveword unknown (index: 0x%08lx)\n", rdp.cmd0 & 0xFF);
|
||||
FRDP ("unknown (index: 0x%08lx)\n", rdp.cmd0 & 0xFF);
|
||||
FRDP_E("uc0:moveword unknown (index: 0x%08lx)\n", rdp.cmd0 & 0xFF);
|
||||
FRDP("unknown (index: 0x%08lx)\n", rdp.cmd0 & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -808,8 +805,8 @@ static void uc0_texture()
|
|||
tmp_tile->on = 1;
|
||||
tmp_tile->org_s_scale = s;
|
||||
tmp_tile->org_t_scale = t;
|
||||
tmp_tile->s_scale = (float)(s+1)/65536.0f;
|
||||
tmp_tile->t_scale = (float)(t+1)/65536.0f;
|
||||
tmp_tile->s_scale = (float)(s + 1) / 65536.0f;
|
||||
tmp_tile->t_scale = (float)(t + 1) / 65536.0f;
|
||||
tmp_tile->s_scale /= 32.0f;
|
||||
tmp_tile->t_scale /= 32.0f;
|
||||
|
||||
|
@ -825,7 +822,6 @@ static void uc0_texture()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void uc0_setothermode_h()
|
||||
{
|
||||
LRDP("uc0:setothermode_h: ");
|
||||
|
@ -855,52 +851,52 @@ static void uc0_setothermode_h()
|
|||
if (mask & 0x00000030) // alpha dither mode
|
||||
{
|
||||
rdp.alpha_dither_mode = (rdp.othermode_h >> 4) & 0x3;
|
||||
FRDP ("alpha dither mode: %s\n", str_dither[rdp.alpha_dither_mode]);
|
||||
FRDP("alpha dither mode: %s\n", str_dither[rdp.alpha_dither_mode]);
|
||||
}
|
||||
|
||||
if (mask & 0x000000C0) // rgb dither mode
|
||||
{
|
||||
uint32_t dither_mode = (rdp.othermode_h >> 6) & 0x3;
|
||||
FRDP ("rgb dither mode: %s\n", str_dither[dither_mode]);
|
||||
FRDP("rgb dither mode: %s\n", str_dither[dither_mode]);
|
||||
}
|
||||
|
||||
if (mask & 0x00003000) // filter mode
|
||||
{
|
||||
rdp.filter_mode = (int)((rdp.othermode_h & 0x00003000) >> 12);
|
||||
rdp.update |= UPDATE_TEXTURE;
|
||||
FRDP ("filter mode: %s\n", str_filter[rdp.filter_mode]);
|
||||
FRDP("filter mode: %s\n", str_filter[rdp.filter_mode]);
|
||||
}
|
||||
|
||||
if (mask & 0x0000C000) // tlut mode
|
||||
{
|
||||
rdp.tlut_mode = (uint8_t)((rdp.othermode_h & 0x0000C000) >> 14);
|
||||
FRDP ("tlut mode: %s\n", str_tlut[rdp.tlut_mode]);
|
||||
FRDP("tlut mode: %s\n", str_tlut[rdp.tlut_mode]);
|
||||
}
|
||||
|
||||
if (mask & 0x00300000) // cycle type
|
||||
{
|
||||
rdp.cycle_mode = (uint8_t)((rdp.othermode_h & 0x00300000) >> 20);
|
||||
rdp.update |= UPDATE_ZBUF_ENABLED;
|
||||
FRDP ("cycletype: %d\n", rdp.cycle_mode);
|
||||
FRDP("cycletype: %d\n", rdp.cycle_mode);
|
||||
}
|
||||
|
||||
if (mask & 0x00010000) // LOD enable
|
||||
{
|
||||
rdp.LOD_en = (rdp.othermode_h & 0x00010000) ? TRUE : FALSE;
|
||||
FRDP ("LOD_en: %d\n", rdp.LOD_en);
|
||||
FRDP("LOD_en: %d\n", rdp.LOD_en);
|
||||
}
|
||||
|
||||
if (mask & 0x00080000) // Persp enable
|
||||
{
|
||||
if (rdp.persp_supported)
|
||||
rdp.Persp_en = (rdp.othermode_h & 0x00080000) ? TRUE : FALSE;
|
||||
FRDP ("Persp_en: %d\n", rdp.Persp_en);
|
||||
FRDP("Persp_en: %d\n", rdp.Persp_en);
|
||||
}
|
||||
|
||||
uint32_t unk = mask & 0x0FFC60F0F;
|
||||
if (unk) // unknown portions, LARGE
|
||||
{
|
||||
FRDP ("UNKNOWN PORTIONS: shift: %d, len: %d, unknowns: %08lx\n", shift, len, unk);
|
||||
FRDP("UNKNOWN PORTIONS: shift: %d, len: %d, unknowns: %08lx\n", shift, len, unk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -934,15 +930,15 @@ static void uc0_setothermode_l()
|
|||
if (mask & 0x00000003) // alpha compare
|
||||
{
|
||||
rdp.acmp = rdp.othermode_l & 0x00000003;
|
||||
FRDP ("alpha compare %s\n", ACmp[rdp.acmp]);
|
||||
FRDP("alpha compare %s\n", ACmp[rdp.acmp]);
|
||||
rdp.update |= UPDATE_ALPHA_COMPARE;
|
||||
}
|
||||
|
||||
if (mask & 0x00000004) // z-src selection
|
||||
{
|
||||
rdp.zsrc = (rdp.othermode_l & 0x00000004) >> 2;
|
||||
FRDP ("z-src sel: %s\n", str_zs[rdp.zsrc]);
|
||||
FRDP ("z-src sel: %08lx\n", rdp.zsrc);
|
||||
FRDP("z-src sel: %s\n", str_zs[rdp.zsrc]);
|
||||
FRDP("z-src sel: %08lx\n", rdp.zsrc);
|
||||
rdp.update |= UPDATE_ZBUF_ENABLED;
|
||||
}
|
||||
|
||||
|
@ -953,7 +949,7 @@ static void uc0_setothermode_l()
|
|||
rdp.rm = rdp.othermode_l;
|
||||
if (settings.flame_corona && (rdp.rm == 0x00504341)) //hack for flame's corona
|
||||
rdp.othermode_l |= /*0x00000020 |*/ 0x00000010;
|
||||
FRDP ("rendermode: %08lx\n", rdp.othermode_l); // just output whole othermode_l
|
||||
FRDP("rendermode: %08lx\n", rdp.othermode_l); // just output whole othermode_l
|
||||
}
|
||||
|
||||
// there is not one setothermode_l that's not handled :)
|
||||
|
@ -1064,13 +1060,13 @@ static void uc0_line3d()
|
|||
FRDP("uc0:line3d v0:%d, v1:%d, width:%d\n", v0, v1, width);
|
||||
}
|
||||
|
||||
static void uc0_tri4 ()
|
||||
static void uc0_tri4()
|
||||
{
|
||||
// c0: 0000 0123, c1: 456789ab
|
||||
// becomes: 405 617 829 a3b
|
||||
|
||||
LRDP("uc0:tri4");
|
||||
FRDP(" #%d, #%d, #%d, #%d - %d, %d, %d - %d, %d, %d - %d, %d, %d - %d, %d, %d\n", rdp.tri_n, rdp.tri_n+1, rdp.tri_n+2, rdp.tri_n+3,
|
||||
FRDP(" #%d, #%d, #%d, #%d - %d, %d, %d - %d, %d, %d - %d, %d, %d - %d, %d, %d\n", rdp.tri_n, rdp.tri_n + 1, rdp.tri_n + 2, rdp.tri_n + 3,
|
||||
(rdp.cmd1 >> 28) & 0xF,
|
||||
(rdp.cmd0 >> 12) & 0xF,
|
||||
(rdp.cmd1 >> 24) & 0xF,
|
||||
|
@ -1102,55 +1098,55 @@ static void uc0_tri4 ()
|
|||
int updated = 0;
|
||||
|
||||
if (cull_tri(v))
|
||||
rdp.tri_n ++;
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
updated = 1;
|
||||
update ();
|
||||
update();
|
||||
|
||||
draw_tri (v);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v+3))
|
||||
rdp.tri_n ++;
|
||||
if (cull_tri(v + 3))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
if (!updated)
|
||||
{
|
||||
updated = 1;
|
||||
update ();
|
||||
update();
|
||||
}
|
||||
|
||||
draw_tri (v+3);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v + 3);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v+6))
|
||||
rdp.tri_n ++;
|
||||
if (cull_tri(v + 6))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
if (!updated)
|
||||
{
|
||||
updated = 1;
|
||||
update ();
|
||||
update();
|
||||
}
|
||||
|
||||
draw_tri (v+6);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v + 6);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v+9))
|
||||
rdp.tri_n ++;
|
||||
if (cull_tri(v + 9))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
if (!updated)
|
||||
{
|
||||
updated = 1;
|
||||
update ();
|
||||
update();
|
||||
}
|
||||
|
||||
draw_tri (v+9);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v + 9);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ static void uc1_tri1()
|
|||
rsp_tri1(v);
|
||||
}
|
||||
|
||||
static void uc1_tri2 ()
|
||||
static void uc1_tri2()
|
||||
{
|
||||
if (rdp.skip_drawing)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ static void uc1_tri2 ()
|
|||
}
|
||||
LRDP("uc1:tri2");
|
||||
|
||||
FRDP(" #%d, #%d - %d, %d, %d - %d, %d, %d\n", rdp.tri_n, rdp.tri_n+1,
|
||||
FRDP(" #%d, #%d - %d, %d, %d - %d, %d, %d\n", rdp.tri_n, rdp.tri_n + 1,
|
||||
((rdp.cmd0 >> 17) & 0x7F),
|
||||
((rdp.cmd0 >> 9) & 0x7F),
|
||||
((rdp.cmd0 >> 1) & 0x7F),
|
||||
|
@ -104,11 +104,11 @@ static void uc1_tri2 ()
|
|||
|
||||
static void uc1_line3d()
|
||||
{
|
||||
if (!settings.force_quad3d && ((rdp.cmd1&0xFF000000) == 0) && ((rdp.cmd0&0x00FFFFFF) == 0))
|
||||
if (!settings.force_quad3d && ((rdp.cmd1 & 0xFF000000) == 0) && ((rdp.cmd0 & 0x00FFFFFF) == 0))
|
||||
{
|
||||
uint16_t width = (uint16_t)(rdp.cmd1&0xFF) + 3;
|
||||
uint16_t width = (uint16_t)(rdp.cmd1 & 0xFF) + 3;
|
||||
|
||||
FRDP("uc1:line3d width: %d #%d, #%d - %d, %d\n", width, rdp.tri_n, rdp.tri_n+1,
|
||||
FRDP("uc1:line3d width: %d #%d, #%d - %d, %d\n", width, rdp.tri_n, rdp.tri_n + 1,
|
||||
(rdp.cmd1 >> 17) & 0x7F,
|
||||
(rdp.cmd1 >> 9) & 0x7F);
|
||||
|
||||
|
@ -127,7 +127,7 @@ static void uc1_line3d()
|
|||
}
|
||||
else
|
||||
{
|
||||
FRDP("uc1:quad3d #%d, #%d\n", rdp.tri_n, rdp.tri_n+1);
|
||||
FRDP("uc1:quad3d #%d, #%d\n", rdp.tri_n, rdp.tri_n + 1);
|
||||
|
||||
VERTEX *v[6] = {
|
||||
&rdp.vtx[(rdp.cmd1 >> 25) & 0x7F],
|
||||
|
@ -154,9 +154,9 @@ static void uc1_rdphalf_1()
|
|||
static void uc1_branch_z()
|
||||
{
|
||||
uint32_t addr = segoffset(branch_dl);
|
||||
FRDP ("uc1:branch_less_z, addr: %08lx\n", addr);
|
||||
FRDP("uc1:branch_less_z, addr: %08lx\n", 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;
|
||||
}
|
||||
|
|
|
@ -37,26 +37,26 @@
|
|||
//
|
||||
//****************************************************************
|
||||
|
||||
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};
|
||||
for (uint32_t l=0; l<rdp.num_lights; l++)
|
||||
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++)
|
||||
{
|
||||
if (rdp.light[l].nonblack)
|
||||
{
|
||||
float lvec[3] = {rdp.light[l].x, rdp.light[l].y, rdp.light[l].z};
|
||||
float lvec[3] = { rdp.light[l].x, rdp.light[l].y, rdp.light[l].z };
|
||||
lvec[0] -= vpos[0];
|
||||
lvec[1] -= vpos[1];
|
||||
lvec[2] -= vpos[2];
|
||||
float light_len2 = lvec[0]*lvec[0] + lvec[1]*lvec[1] + lvec[2]*lvec[2];
|
||||
float light_len2 = lvec[0] * lvec[0] + lvec[1] * lvec[1] + lvec[2] * lvec[2];
|
||||
float light_len = sqrtf(light_len2);
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("calc_point_light: len: %f, len2: %f\n", light_len, light_len2);
|
||||
#endif
|
||||
float at = rdp.light[l].ca + light_len/65535.0f*rdp.light[l].la + light_len2/65535.0f*rdp.light[l].qa;
|
||||
float at = rdp.light[l].ca + light_len / 65535.0f*rdp.light[l].la + light_len2 / 65535.0f*rdp.light[l].qa;
|
||||
if (at > 0.0f)
|
||||
light_intensity = 1/at;//DotProduct (lvec, nvec) / (light_len * normal_len * at);
|
||||
light_intensity = 1 / at;//DotProduct (lvec, nvec) / (light_len * normal_len * at);
|
||||
else
|
||||
light_intensity = 0.0f;
|
||||
}
|
||||
|
@ -75,14 +75,14 @@ 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);
|
||||
}
|
||||
|
||||
static void uc6_obj_rectangle();
|
||||
|
||||
static void uc2_vertex ()
|
||||
static void uc2_vertex()
|
||||
{
|
||||
if (!(rdp.cmd0 & 0x00FFFFFF))
|
||||
{
|
||||
|
@ -102,10 +102,10 @@ static void uc2_vertex ()
|
|||
rdp.update ^= UPDATE_LIGHTS;
|
||||
|
||||
// Calculate light vectors
|
||||
for (uint32_t l=0; l<rdp.num_lights; l++)
|
||||
for (uint32_t l = 0; l < rdp.num_lights; l++)
|
||||
{
|
||||
InverseTransformVector(&rdp.light[l].dir_x, rdp.light_vector[l], rdp.model);
|
||||
NormalizeVector (rdp.light_vector[l]);
|
||||
NormalizeVector(rdp.light_vector[l]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,11 +116,11 @@ static void uc2_vertex ()
|
|||
rdp.vn = n = (rdp.cmd0 >> 12) & 0xFF;
|
||||
rdp.v0 = v0 = ((rdp.cmd0 >> 1) & 0x7F) - n;
|
||||
|
||||
FRDP ("uc2:vertex n: %d, v0: %d, from: %08lx\n", n, v0, addr);
|
||||
FRDP("uc2:vertex n: %d, v0: %d, from: %08lx\n", n, v0, addr);
|
||||
|
||||
if (v0 < 0)
|
||||
{
|
||||
RDP_E ("** ERROR: uc2:vertex v0 < 0\n");
|
||||
RDP_E("** ERROR: uc2:vertex v0 < 0\n");
|
||||
LRDP("** ERROR: uc2:vertex v0 < 0\n");
|
||||
return;
|
||||
}
|
||||
|
@ -128,20 +128,20 @@ static void uc2_vertex ()
|
|||
uint32_t geom_mode = rdp.geom_mode;
|
||||
if ((settings.hacks&hack_Fzero) && (rdp.geom_mode & 0x40000))
|
||||
{
|
||||
if (((short*)gfx.RDRAM)[(((addr) >> 1) + 4)^1] || ((short*)gfx.RDRAM)[(((addr) >> 1) + 5)^1])
|
||||
if (((short*)gfx.RDRAM)[(((addr) >> 1) + 4) ^ 1] || ((short*)gfx.RDRAM)[(((addr) >> 1) + 5) ^ 1])
|
||||
rdp.geom_mode ^= 0x40000;
|
||||
}
|
||||
for (i=0; i < (n<<4); i+=16)
|
||||
for (i = 0; i < (n << 4); i += 16)
|
||||
{
|
||||
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];
|
||||
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->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];
|
||||
|
@ -153,7 +153,7 @@ static void uc2_vertex ()
|
|||
v->x_w = v->x * v->oow;
|
||||
v->y_w = v->y * v->oow;
|
||||
v->z_w = v->z * v->oow;
|
||||
CalculateFog (v);
|
||||
CalculateFog(v);
|
||||
|
||||
v->uv_calculated = 0xFFFFFFFF;
|
||||
v->screen_translated = 0;
|
||||
|
@ -165,13 +165,13 @@ static void uc2_vertex ()
|
|||
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 (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];
|
||||
// FRDP("Calc light. x: %f, y: %f z: %f\n", v->vec[0], v->vec[1], v->vec[2]);
|
||||
// if (!(rdp.geom_mode & 0x800000))
|
||||
{
|
||||
|
@ -179,14 +179,14 @@ static void uc2_vertex ()
|
|||
{
|
||||
if (rdp.geom_mode & 0x80000)
|
||||
{
|
||||
calc_linear (v);
|
||||
calc_linear(v);
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("calc linear: v%d - u: %f, v: %f\n", i>>4, v->ou, v->ov);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
calc_sphere (v);
|
||||
calc_sphere(v);
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("calc sphere: v%d - u: %f, v: %f\n", i>>4, v->ou, v->ov);
|
||||
#endif
|
||||
|
@ -195,20 +195,20 @@ static void uc2_vertex ()
|
|||
}
|
||||
if (rdp.geom_mode & 0x00400000)
|
||||
{
|
||||
float tmpvec[3] = {x, y, z};
|
||||
calc_point_light (v, tmpvec);
|
||||
float tmpvec[3] = { x, y, z };
|
||||
calc_point_light(v, tmpvec);
|
||||
}
|
||||
else
|
||||
{
|
||||
NormalizeVector (v->vec);
|
||||
calc_light (v);
|
||||
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];
|
||||
}
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("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\n", 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);
|
||||
|
@ -217,24 +217,24 @@ static void uc2_vertex ()
|
|||
rdp.geom_mode = geom_mode;
|
||||
}
|
||||
|
||||
static void uc2_modifyvtx ()
|
||||
static void uc2_modifyvtx()
|
||||
{
|
||||
uint8_t where = (uint8_t)((rdp.cmd0 >> 16) & 0xFF);
|
||||
uint16_t vtx = (uint16_t)((rdp.cmd0 >> 1) & 0xFFFF);
|
||||
|
||||
FRDP ("uc2:modifyvtx: vtx: %d, where: 0x%02lx, val: %08lx - ", vtx, where, rdp.cmd1);
|
||||
FRDP("uc2:modifyvtx: vtx: %d, where: 0x%02lx, val: %08lx - ", vtx, where, rdp.cmd1);
|
||||
uc0_modifyvtx(where, vtx, rdp.cmd1);
|
||||
}
|
||||
|
||||
static void uc2_culldl ()
|
||||
static void uc2_culldl()
|
||||
{
|
||||
uint16_t vStart = (uint16_t)(rdp.cmd0 & 0xFFFF) >> 1;
|
||||
uint16_t vEnd = (uint16_t)(rdp.cmd1 & 0xFFFF) >> 1;
|
||||
uint32_t cond = 0;
|
||||
FRDP ("uc2:culldl start: %d, end: %d\n", vStart, vEnd);
|
||||
FRDP("uc2:culldl start: %d, end: %d\n", vStart, vEnd);
|
||||
|
||||
if (vEnd < vStart) return;
|
||||
for (uint16_t i=vStart; i<=vEnd; i++)
|
||||
for (uint16_t i = vStart; i <= vEnd; i++)
|
||||
{
|
||||
/*
|
||||
VERTEX v = &rdp.vtx[i];
|
||||
|
@ -264,16 +264,16 @@ static void uc2_culldl ()
|
|||
}
|
||||
|
||||
LRDP(" - "); // specify that the enddl is not a real command
|
||||
uc0_enddl ();
|
||||
uc0_enddl();
|
||||
}
|
||||
|
||||
static void uc6_obj_loadtxtr ();
|
||||
static void uc6_obj_loadtxtr();
|
||||
|
||||
static void uc2_tri1()
|
||||
{
|
||||
if ((rdp.cmd0 & 0x00FFFFFF) == 0x17)
|
||||
{
|
||||
uc6_obj_loadtxtr ();
|
||||
uc6_obj_loadtxtr();
|
||||
return;
|
||||
}
|
||||
if (rdp.skip_drawing)
|
||||
|
@ -296,22 +296,22 @@ static void uc2_tri1()
|
|||
rsp_tri1(v);
|
||||
}
|
||||
|
||||
static void uc6_obj_ldtx_sprite ();
|
||||
static void uc6_obj_ldtx_rect ();
|
||||
static void uc6_obj_ldtx_sprite();
|
||||
static void uc6_obj_ldtx_rect();
|
||||
|
||||
static void uc2_quad ()
|
||||
static void uc2_quad()
|
||||
{
|
||||
if ((rdp.cmd0 & 0x00FFFFFF) == 0x2F)
|
||||
{
|
||||
uint32_t command = rdp.cmd0>>24;
|
||||
uint32_t command = rdp.cmd0 >> 24;
|
||||
if (command == 0x6)
|
||||
{
|
||||
uc6_obj_ldtx_sprite ();
|
||||
uc6_obj_ldtx_sprite();
|
||||
return;
|
||||
}
|
||||
if (command == 0x7)
|
||||
{
|
||||
uc6_obj_ldtx_rect ();
|
||||
uc6_obj_ldtx_rect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ static void uc2_quad ()
|
|||
|
||||
LRDP("uc2:quad");
|
||||
|
||||
FRDP(" #%d, #%d - %d, %d, %d - %d, %d, %d\n", rdp.tri_n, rdp.tri_n+1,
|
||||
FRDP(" #%d, #%d - %d, %d, %d - %d, %d, %d\n", rdp.tri_n, rdp.tri_n + 1,
|
||||
((rdp.cmd0 >> 17) & 0x7F),
|
||||
((rdp.cmd0 >> 9) & 0x7F),
|
||||
((rdp.cmd0 >> 1) & 0x7F),
|
||||
|
@ -344,15 +344,15 @@ static void uc2_quad ()
|
|||
rsp_tri2(v);
|
||||
}
|
||||
|
||||
static void uc6_ldtx_rect_r ();
|
||||
static void uc6_ldtx_rect_r();
|
||||
|
||||
static void uc2_line3d ()
|
||||
static void uc2_line3d()
|
||||
{
|
||||
if ( (rdp.cmd0&0xFF) == 0x2F )
|
||||
uc6_ldtx_rect_r ();
|
||||
if ((rdp.cmd0 & 0xFF) == 0x2F)
|
||||
uc6_ldtx_rect_r();
|
||||
else
|
||||
{
|
||||
FRDP("uc2:line3d #%d, #%d - %d, %d\n", rdp.tri_n, rdp.tri_n+1,
|
||||
FRDP("uc2:line3d #%d, #%d - %d, %d\n", rdp.tri_n, rdp.tri_n + 1,
|
||||
(rdp.cmd0 >> 17) & 0x7F,
|
||||
(rdp.cmd0 >> 9) & 0x7F);
|
||||
|
||||
|
@ -361,7 +361,7 @@ static void uc2_line3d ()
|
|||
&rdp.vtx[(rdp.cmd0 >> 9) & 0x7F],
|
||||
&rdp.vtx[(rdp.cmd0 >> 9) & 0x7F]
|
||||
};
|
||||
uint16_t width = (uint16_t)(rdp.cmd0 + 3)&0xFF;
|
||||
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;
|
||||
|
@ -372,30 +372,30 @@ static void uc2_line3d ()
|
|||
}
|
||||
}
|
||||
|
||||
static void uc2_special3 ()
|
||||
static void uc2_special3()
|
||||
{
|
||||
LRDP("uc2:special3\n");
|
||||
}
|
||||
|
||||
static void uc2_special2 ()
|
||||
static void uc2_special2()
|
||||
{
|
||||
LRDP("uc2:special2\n");
|
||||
}
|
||||
|
||||
static void uc2_dma_io ()
|
||||
static void uc2_dma_io()
|
||||
{
|
||||
LRDP("uc2:dma_io\n");
|
||||
}
|
||||
|
||||
static void uc2_pop_matrix ()
|
||||
static void uc2_pop_matrix()
|
||||
{
|
||||
FRDP ("uc2:pop_matrix %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
FRDP("uc2:pop_matrix %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
|
||||
// Just pop the modelview matrix
|
||||
modelview_pop (rdp.cmd1 >> 6);
|
||||
modelview_pop(rdp.cmd1 >> 6);
|
||||
}
|
||||
|
||||
static void uc2_geom_mode ()
|
||||
static void uc2_geom_mode()
|
||||
{
|
||||
// Switch around some things
|
||||
uint32_t clr_mode = (rdp.cmd0 & 0x00DFC9FF) |
|
||||
|
@ -410,7 +410,7 @@ static void uc2_geom_mode ()
|
|||
rdp.geom_mode &= clr_mode;
|
||||
rdp.geom_mode |= set_mode;
|
||||
|
||||
FRDP ("result:%08lx\n", rdp.geom_mode);
|
||||
FRDP("result:%08lx\n", rdp.geom_mode);
|
||||
|
||||
if (rdp.geom_mode & 0x00000001) // Z-Buffer enable
|
||||
{
|
||||
|
@ -481,9 +481,9 @@ static void uc2_geom_mode ()
|
|||
}
|
||||
}
|
||||
|
||||
static void uc6_obj_rectangle_r ();
|
||||
static void uc6_obj_rectangle_r();
|
||||
|
||||
static void uc2_matrix ()
|
||||
static void uc2_matrix()
|
||||
{
|
||||
if (!(rdp.cmd0 & 0x00FFFFFF))
|
||||
{
|
||||
|
@ -500,39 +500,39 @@ static void uc2_matrix ()
|
|||
{
|
||||
case 0: // modelview mul nopush
|
||||
LRDP("modelview mul\n");
|
||||
modelview_mul (m);
|
||||
modelview_mul(m);
|
||||
break;
|
||||
|
||||
case 1: // modelview mul push
|
||||
LRDP("modelview mul push\n");
|
||||
modelview_mul_push (m);
|
||||
modelview_mul_push(m);
|
||||
break;
|
||||
|
||||
case 2: // modelview load nopush
|
||||
LRDP("modelview load\n");
|
||||
modelview_load (m);
|
||||
modelview_load(m);
|
||||
break;
|
||||
|
||||
case 3: // modelview load push
|
||||
LRDP("modelview load push\n");
|
||||
modelview_load_push (m);
|
||||
modelview_load_push(m);
|
||||
break;
|
||||
|
||||
case 4: // projection mul nopush
|
||||
case 5: // projection mul push, can't push projection
|
||||
LRDP("projection mul\n");
|
||||
projection_mul (m);
|
||||
projection_mul(m);
|
||||
break;
|
||||
|
||||
case 6: // projection load nopush
|
||||
case 7: // projection load push, can't push projection
|
||||
LRDP("projection load\n");
|
||||
projection_load (m);
|
||||
projection_load(m);
|
||||
break;
|
||||
|
||||
default:
|
||||
FRDP_E ("Unknown matrix command, %02lx", command);
|
||||
FRDP ("Unknown matrix command, %02lx", command);
|
||||
FRDP_E("Unknown matrix command, %02lx", command);
|
||||
FRDP("Unknown matrix command, %02lx", command);
|
||||
}
|
||||
|
||||
#ifdef EXTREME_LOGGING
|
||||
|
@ -551,13 +551,13 @@ static void uc2_matrix ()
|
|||
#endif
|
||||
}
|
||||
|
||||
static void uc2_moveword ()
|
||||
static void uc2_moveword()
|
||||
{
|
||||
uint8_t index = (uint8_t)((rdp.cmd0 >> 16) & 0xFF);
|
||||
uint16_t offset = (uint16_t)(rdp.cmd0 & 0xFFFF);
|
||||
uint32_t data = rdp.cmd1;
|
||||
|
||||
FRDP ("uc2:moveword ");
|
||||
FRDP("uc2:moveword ");
|
||||
|
||||
switch (index)
|
||||
{
|
||||
|
@ -579,13 +579,13 @@ static void uc2_moveword ()
|
|||
int index_y = index_x >> 2;
|
||||
index_x &= 3;
|
||||
|
||||
float fpart = (rdp.cmd1>>16)/65536.0f;
|
||||
float fpart = (rdp.cmd1 >> 16) / 65536.0f;
|
||||
rdp.combined[index_y][index_x] = (float)(int)rdp.combined[index_y][index_x];
|
||||
rdp.combined[index_y][index_x] += fpart;
|
||||
|
||||
fpart = (rdp.cmd1&0xFFFF)/65536.0f;
|
||||
rdp.combined[index_y][index_x+1] = (float)(int)rdp.combined[index_y][index_x+1];
|
||||
rdp.combined[index_y][index_x+1] += fpart;
|
||||
fpart = (rdp.cmd1 & 0xFFFF) / 65536.0f;
|
||||
rdp.combined[index_y][index_x + 1] = (float)(int)rdp.combined[index_y][index_x + 1];
|
||||
rdp.combined[index_y][index_x + 1] += fpart;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -593,8 +593,8 @@ static void uc2_moveword ()
|
|||
int index_y = index_x >> 2;
|
||||
index_x &= 3;
|
||||
|
||||
rdp.combined[index_y][index_x] = (short)(rdp.cmd1>>16);
|
||||
rdp.combined[index_y][index_x+1] = (short)(rdp.cmd1&0xFFFF);
|
||||
rdp.combined[index_y][index_x] = (short)(rdp.cmd1 >> 16);
|
||||
rdp.combined[index_y][index_x + 1] = (short)(rdp.cmd1 & 0xFFFF);
|
||||
}
|
||||
|
||||
LRDP("matrix\n");
|
||||
|
@ -604,7 +604,7 @@ static void uc2_moveword ()
|
|||
case 0x02:
|
||||
rdp.num_lights = data / 24;
|
||||
rdp.update |= UPDATE_LIGHTS;
|
||||
FRDP ("numlights: %d\n", rdp.num_lights);
|
||||
FRDP("numlights: %d\n", rdp.num_lights);
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
|
@ -613,23 +613,22 @@ static void uc2_moveword ()
|
|||
rdp.clip_ratio = sqrt((float)rdp.cmd1);
|
||||
rdp.update |= UPDATE_VIEWPORT;
|
||||
}
|
||||
FRDP ("mw_clip %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
FRDP("mw_clip %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
break;
|
||||
|
||||
case 0x06: // moveword SEGMENT
|
||||
{
|
||||
FRDP ("SEGMENT %08lx -> seg%d\n", data, offset >> 2);
|
||||
if ((data&BMASK)<BMASK)
|
||||
FRDP("SEGMENT %08lx -> seg%d\n", data, offset >> 2);
|
||||
if ((data&BMASK) < BMASK)
|
||||
rdp.segment[(offset >> 2) & 0xF] = data;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 0x08:
|
||||
{
|
||||
rdp.fog_multiplier = (short)(rdp.cmd1 >> 16);
|
||||
rdp.fog_offset = (short)(rdp.cmd1 & 0x0000FFFF);
|
||||
FRDP ("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
FRDP("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
|
||||
//offset must be 0 for move_fog, but it can be non zero in Nushi Zuri 64 - Shiokaze ni Notte
|
||||
//low-level display list has setothermode commands in this place, so this is obviously not move_fog.
|
||||
|
@ -641,7 +640,7 @@ static void uc2_moveword ()
|
|||
case 0x0a: // moveword LIGHTCOL
|
||||
{
|
||||
int n = offset / 24;
|
||||
FRDP ("lightcol light:%d, %08lx\n", n, data);
|
||||
FRDP("lightcol light:%d, %08lx\n", n, data);
|
||||
|
||||
rdp.light[n].r = (float)((data >> 24) & 0xFF) / 255.0f;
|
||||
rdp.light[n].g = (float)((data >> 16) & 0xFF) / 255.0f;
|
||||
|
@ -651,7 +650,7 @@ static void uc2_moveword ()
|
|||
break;
|
||||
|
||||
case 0x0c:
|
||||
RDP_E ("uc2:moveword forcemtx - IGNORED\n");
|
||||
RDP_E("uc2:moveword forcemtx - IGNORED\n");
|
||||
LRDP("forcemtx - IGNORED\n");
|
||||
break;
|
||||
|
||||
|
@ -661,36 +660,36 @@ static void uc2_moveword ()
|
|||
|
||||
default:
|
||||
FRDP_E("uc2:moveword unknown (index: 0x%08lx, offset 0x%08lx)\n", index, offset);
|
||||
FRDP ("unknown (index: 0x%08lx, offset 0x%08lx)\n", index, offset);
|
||||
FRDP("unknown (index: 0x%08lx, offset 0x%08lx)\n", index, offset);
|
||||
}
|
||||
}
|
||||
|
||||
static void uc6_obj_movemem ();
|
||||
static void uc6_obj_movemem();
|
||||
|
||||
static void uc2_movemem ()
|
||||
static void uc2_movemem()
|
||||
{
|
||||
int idx = rdp.cmd0 & 0xFF;
|
||||
uint32_t addr = segoffset(rdp.cmd1);
|
||||
int ofs = (rdp.cmd0 >> 5) & 0x7F8;
|
||||
|
||||
FRDP ("uc2:movemem ofs:%d ", ofs);
|
||||
FRDP("uc2:movemem ofs:%d ", ofs);
|
||||
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
uc6_obj_movemem ();
|
||||
uc6_obj_movemem();
|
||||
break;
|
||||
|
||||
case 8: // VIEWPORT
|
||||
{
|
||||
uint32_t a = addr >> 1;
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a+0)^1] >> 2;
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a+1)^1] >> 2;
|
||||
short scale_z = ((short*)gfx.RDRAM)[(a+2)^1];
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a+4)^1] >> 2;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a+5)^1] >> 2;
|
||||
short trans_z = ((short*)gfx.RDRAM)[(a+6)^1];
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a + 0) ^ 1] >> 2;
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a + 1) ^ 1] >> 2;
|
||||
short scale_z = ((short*)gfx.RDRAM)[(a + 2) ^ 1];
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a + 4) ^ 1] >> 2;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a + 5) ^ 1] >> 2;
|
||||
short trans_z = ((short*)gfx.RDRAM)[(a + 6) ^ 1];
|
||||
rdp.view_scale[0] = scale_x * rdp.scale_x;
|
||||
rdp.view_scale[1] = -scale_y * rdp.scale_y;
|
||||
rdp.view_scale[2] = 32.0f * scale_z;
|
||||
|
@ -700,7 +699,7 @@ static void uc2_movemem ()
|
|||
|
||||
rdp.update |= UPDATE_VIEWPORT;
|
||||
|
||||
FRDP ("viewport scale(%d, %d, %d), trans(%d, %d, %d), from:%08lx\n", scale_x, scale_y, scale_z,
|
||||
FRDP("viewport scale(%d, %d, %d), trans(%d, %d, %d), from:%08lx\n", scale_x, scale_y, scale_z,
|
||||
trans_x, trans_y, trans_z, a);
|
||||
}
|
||||
break;
|
||||
|
@ -711,11 +710,11 @@ static void uc2_movemem ()
|
|||
|
||||
if (n < 2)
|
||||
{
|
||||
char dir_x = ((char*)gfx.RDRAM)[(addr+8)^3];
|
||||
char dir_x = ((char*)gfx.RDRAM)[(addr + 8) ^ 3];
|
||||
rdp.lookat[n][0] = (float)(dir_x) / 127.0f;
|
||||
char dir_y = ((char*)gfx.RDRAM)[(addr+9)^3];
|
||||
char dir_y = ((char*)gfx.RDRAM)[(addr + 9) ^ 3];
|
||||
rdp.lookat[n][1] = (float)(dir_y) / 127.0f;
|
||||
char dir_z = ((char*)gfx.RDRAM)[(addr+10)^3];
|
||||
char dir_z = ((char*)gfx.RDRAM)[(addr + 10) ^ 3];
|
||||
rdp.lookat[n][2] = (float)(dir_z) / 127.0f;
|
||||
rdp.use_lookat = TRUE;
|
||||
if (n == 1)
|
||||
|
@ -730,33 +729,33 @@ static void uc2_movemem ()
|
|||
if (n > 7) return;
|
||||
|
||||
// Get the data
|
||||
uint8_t col = gfx.RDRAM[(addr+0)^3];
|
||||
uint8_t col = gfx.RDRAM[(addr + 0) ^ 3];
|
||||
rdp.light[n].r = (float)col / 255.0f;
|
||||
rdp.light[n].nonblack = col;
|
||||
col = gfx.RDRAM[(addr+1)^3];
|
||||
col = gfx.RDRAM[(addr + 1) ^ 3];
|
||||
rdp.light[n].g = (float)col / 255.0f;
|
||||
rdp.light[n].nonblack += col;
|
||||
col = gfx.RDRAM[(addr+2)^3];
|
||||
col = gfx.RDRAM[(addr + 2) ^ 3];
|
||||
rdp.light[n].b = (float)col / 255.0f;
|
||||
rdp.light[n].nonblack += col;
|
||||
rdp.light[n].a = 1.0f;
|
||||
// ** Thanks to Icepir8 for pointing this out **
|
||||
// Lighting must be signed byte instead of byte
|
||||
rdp.light[n].dir_x = (float)(((char*)gfx.RDRAM)[(addr+8)^3]) / 127.0f;
|
||||
rdp.light[n].dir_y = (float)(((char*)gfx.RDRAM)[(addr+9)^3]) / 127.0f;
|
||||
rdp.light[n].dir_z = (float)(((char*)gfx.RDRAM)[(addr+10)^3]) / 127.0f;
|
||||
rdp.light[n].dir_x = (float)(((char*)gfx.RDRAM)[(addr + 8) ^ 3]) / 127.0f;
|
||||
rdp.light[n].dir_y = (float)(((char*)gfx.RDRAM)[(addr + 9) ^ 3]) / 127.0f;
|
||||
rdp.light[n].dir_z = (float)(((char*)gfx.RDRAM)[(addr + 10) ^ 3]) / 127.0f;
|
||||
uint32_t a = addr >> 1;
|
||||
rdp.light[n].x = (float)(((short*)gfx.RDRAM)[(a+4)^1]);
|
||||
rdp.light[n].y = (float)(((short*)gfx.RDRAM)[(a+5)^1]);
|
||||
rdp.light[n].z = (float)(((short*)gfx.RDRAM)[(a+6)^1]);
|
||||
rdp.light[n].ca = (float)(gfx.RDRAM[(addr+3)^3]) / 16.0f;
|
||||
rdp.light[n].la = (float)(gfx.RDRAM[(addr+7)^3]);
|
||||
rdp.light[n].qa = (float)(gfx.RDRAM[(addr+14)^3]) / 8.0f;
|
||||
rdp.light[n].x = (float)(((short*)gfx.RDRAM)[(a + 4) ^ 1]);
|
||||
rdp.light[n].y = (float)(((short*)gfx.RDRAM)[(a + 5) ^ 1]);
|
||||
rdp.light[n].z = (float)(((short*)gfx.RDRAM)[(a + 6) ^ 1]);
|
||||
rdp.light[n].ca = (float)(gfx.RDRAM[(addr + 3) ^ 3]) / 16.0f;
|
||||
rdp.light[n].la = (float)(gfx.RDRAM[(addr + 7) ^ 3]);
|
||||
rdp.light[n].qa = (float)(gfx.RDRAM[(addr + 14) ^ 3]) / 8.0f;
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("light: n: %d, pos: x: %f, y: %f, z: %f, ca: %f, la:%f, qa: %f\n",
|
||||
n, rdp.light[n].x, rdp.light[n].y, rdp.light[n].z, rdp.light[n].ca, rdp.light[n].la, rdp.light[n].qa);
|
||||
#endif
|
||||
FRDP ("light: n: %d, r: %.3f, g: %.3f, b: %.3f. dir: x: %.3f, y: %.3f, z: %.3f\n",
|
||||
FRDP("light: n: %d, r: %.3f, g: %.3f, b: %.3f. dir: x: %.3f, y: %.3f, z: %.3f\n",
|
||||
n, rdp.light[n].r, rdp.light[n].g, rdp.light[n].b,
|
||||
rdp.light[n].dir_x, rdp.light[n].dir_y, rdp.light[n].dir_z);
|
||||
}
|
||||
|
@ -778,35 +777,35 @@ static void uc2_movemem ()
|
|||
break;
|
||||
|
||||
default:
|
||||
FRDP ("uc2:matrix unknown (%d)\n", idx);
|
||||
FRDP ("** UNKNOWN %d\n", idx);
|
||||
FRDP("uc2:matrix unknown (%d)\n", idx);
|
||||
FRDP("** UNKNOWN %d\n", idx);
|
||||
}
|
||||
}
|
||||
|
||||
static void uc2_load_ucode ()
|
||||
static void uc2_load_ucode()
|
||||
{
|
||||
LRDP("uc2:load_ucode\n");
|
||||
}
|
||||
|
||||
static void uc2_rdphalf_2 ()
|
||||
static void uc2_rdphalf_2()
|
||||
{
|
||||
LRDP("uc2:rdphalf_2\n");
|
||||
}
|
||||
|
||||
static void uc2_dlist_cnt ()
|
||||
static void uc2_dlist_cnt()
|
||||
{
|
||||
uint32_t addr = segoffset(rdp.cmd1) & BMASK;
|
||||
int count = rdp.cmd0 & 0x000000FF;
|
||||
FRDP ("dl_count - addr: %08lx, count: %d\n", addr, count);
|
||||
FRDP("dl_count - addr: %08lx, count: %d\n", addr, count);
|
||||
if (addr == 0)
|
||||
return;
|
||||
|
||||
if (rdp.pc_i >= 9) {
|
||||
RDP_E ("** DL stack overflow **\n");
|
||||
RDP_E("** DL stack overflow **\n");
|
||||
LRDP("** DL stack overflow **\n");
|
||||
return;
|
||||
}
|
||||
rdp.pc_i ++; // go to the next PC in the stack
|
||||
rdp.pc_i++; // go to the next PC in the stack
|
||||
rdp.pc[rdp.pc_i] = addr; // jump to the address
|
||||
rdp.dl_count = count + 1;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
|
||||
static void uc3_vertex()
|
||||
{
|
||||
int v0 = ((rdp.cmd0 >> 16) & 0xFF)/5; // Current vertex
|
||||
int n = (uint16_t)((rdp.cmd0&0xFFFF) + 1)/0x210; // Number to copy
|
||||
int v0 = ((rdp.cmd0 >> 16) & 0xFF) / 5; // Current vertex
|
||||
int n = (uint16_t)((rdp.cmd0 & 0xFFFF) + 1) / 0x210; // Number to copy
|
||||
|
||||
if (v0 >= 32)
|
||||
v0 = 31;
|
||||
|
@ -62,36 +62,36 @@ static void uc3_vertex()
|
|||
static void uc3_tri1()
|
||||
{
|
||||
FRDP("uc3:tri1 #%d - %d, %d, %d - %08lx - %08lx\n", rdp.tri_n,
|
||||
((rdp.cmd1 >> 16) & 0xFF)/5,
|
||||
((rdp.cmd1 >> 8) & 0xFF)/5,
|
||||
((rdp.cmd1 ) & 0xFF)/5, rdp.cmd0, rdp.cmd1);
|
||||
((rdp.cmd1 >> 16) & 0xFF) / 5,
|
||||
((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]
|
||||
&rdp.vtx[((rdp.cmd1 >> 16) & 0xFF) / 5],
|
||||
&rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 5],
|
||||
&rdp.vtx[(rdp.cmd1 & 0xFF) / 5]
|
||||
};
|
||||
|
||||
rsp_tri1(v);
|
||||
}
|
||||
|
||||
static void uc3_tri2 ()
|
||||
static void uc3_tri2()
|
||||
{
|
||||
FRDP("uc3:tri2 #%d, #%d - %d, %d, %d - %d, %d, %d\n", rdp.tri_n, rdp.tri_n+1,
|
||||
((rdp.cmd0 >> 16) & 0xFF)/5,
|
||||
((rdp.cmd0 >> 8) & 0xFF)/5,
|
||||
((rdp.cmd0 ) & 0xFF)/5,
|
||||
((rdp.cmd1 >> 16) & 0xFF)/5,
|
||||
((rdp.cmd1 >> 8) & 0xFF)/5,
|
||||
((rdp.cmd1 ) & 0xFF)/5);
|
||||
FRDP("uc3:tri2 #%d, #%d - %d, %d, %d - %d, %d, %d\n", rdp.tri_n, rdp.tri_n + 1,
|
||||
((rdp.cmd0 >> 16) & 0xFF) / 5,
|
||||
((rdp.cmd0 >> 8) & 0xFF) / 5,
|
||||
((rdp.cmd0) & 0xFF) / 5,
|
||||
((rdp.cmd1 >> 16) & 0xFF) / 5,
|
||||
((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]
|
||||
&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);
|
||||
|
@ -99,15 +99,15 @@ static void uc3_tri2 ()
|
|||
|
||||
static void uc3_quad3d()
|
||||
{
|
||||
FRDP("uc3:quad3d #%d, #%d\n", rdp.tri_n, rdp.tri_n+1);
|
||||
FRDP("uc3:quad3d #%d, #%d\n", 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]
|
||||
&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);
|
||||
|
|
|
@ -67,7 +67,7 @@ static void uc4_tri1()
|
|||
|
||||
static void uc4_quad3d()
|
||||
{
|
||||
FRDP("uc4:quad3d #%d, #%d\n", rdp.tri_n, rdp.tri_n+1);
|
||||
FRDP("uc4:quad3d #%d, #%d\n", rdp.tri_n, rdp.tri_n + 1);
|
||||
|
||||
VERTEX *v[6] = {
|
||||
&rdp.vtx[((rdp.cmd1 >> 24) & 0xFF) / 5],
|
||||
|
|
|
@ -43,7 +43,7 @@ int vtx_last = 0;
|
|||
uint32_t dma_offset_mtx = 0;
|
||||
uint32_t dma_offset_vtx = 0;
|
||||
|
||||
static void uc5_dma_offsets ()
|
||||
static void uc5_dma_offsets()
|
||||
{
|
||||
dma_offset_mtx = rdp.cmd0 & 0x00FFFFFF;
|
||||
dma_offset_vtx = rdp.cmd1 & 0x00FFFFFF;
|
||||
|
@ -51,7 +51,7 @@ static void uc5_dma_offsets ()
|
|||
FRDP("uc5:dma_offsets - mtx: %08lx, vtx: %08lx\n", dma_offset_mtx, dma_offset_vtx);
|
||||
}
|
||||
|
||||
static void uc5_matrix ()
|
||||
static void uc5_matrix()
|
||||
{
|
||||
// Use segment offset to get the address
|
||||
uint32_t addr = dma_offset_mtx + (segoffset(rdp.cmd1) & BMASK);
|
||||
|
@ -78,7 +78,7 @@ static void uc5_matrix ()
|
|||
DECLAREALIGN16VAR(m[4][4]);
|
||||
load_matrix(m, addr);
|
||||
DECLAREALIGN16VAR(m_src[4][4]);
|
||||
memcpy (m_src, rdp.dkrproj[0], 64);
|
||||
memcpy(m_src, rdp.dkrproj[0], 64);
|
||||
MulMatrices(m, m_src, rdp.dkrproj[n]);
|
||||
}
|
||||
else
|
||||
|
@ -104,7 +104,7 @@ static void uc5_matrix ()
|
|||
#endif
|
||||
}
|
||||
|
||||
static void uc5_vertex ()
|
||||
static void uc5_vertex()
|
||||
{
|
||||
uint32_t addr = dma_offset_vtx + (segoffset(rdp.cmd1) & BMASK);
|
||||
|
||||
|
@ -128,19 +128,19 @@ static void uc5_vertex ()
|
|||
vtx_last = 0;
|
||||
|
||||
int first = ((rdp.cmd0 >> 9) & 0x1F) + vtx_last;
|
||||
FRDP ("uc5:vertex - addr: %08lx, first: %d, count: %d, matrix: %08lx\n", addr, first, n, cur_mtx);
|
||||
FRDP("uc5:vertex - addr: %08lx, first: %d, count: %d, matrix: %08lx\n", addr, first, n, cur_mtx);
|
||||
|
||||
int prj = cur_mtx;
|
||||
|
||||
int start = 0;
|
||||
float x, y, z;
|
||||
for (int i=first; i<first+n; i++)
|
||||
for (int i = first; i < first + n; i++)
|
||||
{
|
||||
start = (i-first) * 10;
|
||||
start = (i - first) * 10;
|
||||
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];
|
||||
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];
|
||||
|
@ -173,11 +173,11 @@ static void uc5_vertex ()
|
|||
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];
|
||||
CalculateFog (v);
|
||||
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);
|
||||
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("v%d - x: %f, y: %f, z: %f, w: %f, z_w: %f, r=%d, g=%d, b=%d, a=%d\n", i, v->x, v->y, v->z, v->w, v->z_w, v->r, v->g, v->b, v->a);
|
||||
|
@ -187,7 +187,7 @@ static void uc5_vertex ()
|
|||
vtx_last += n;
|
||||
}
|
||||
|
||||
static void uc5_tridma ()
|
||||
static void uc5_tridma()
|
||||
{
|
||||
vtx_last = 0; // we've drawn something, so the vertex index needs resetting
|
||||
if (rdp.skip_drawing)
|
||||
|
@ -205,12 +205,12 @@ static void uc5_tridma ()
|
|||
FRDP("uc5:tridma #%d - addr: %08lx, count: %d\n", rdp.tri_n, addr, num);
|
||||
|
||||
int start, v0, v1, v2, flags;
|
||||
for (int i=0; i<num; i++)
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
start = i << 4;
|
||||
v0 = gfx.RDRAM[addr+start];
|
||||
v1 = gfx.RDRAM[addr+start+1];
|
||||
v2 = gfx.RDRAM[addr+start+2];
|
||||
v0 = gfx.RDRAM[addr + start];
|
||||
v1 = gfx.RDRAM[addr + start + 1];
|
||||
v2 = gfx.RDRAM[addr + start + 2];
|
||||
|
||||
FRDP("tri #%d - %d, %d, %d\n", rdp.tri_n, v0, v1, v2);
|
||||
|
||||
|
@ -220,60 +220,60 @@ static void uc5_tridma ()
|
|||
&rdp.vtx[v2]
|
||||
};
|
||||
|
||||
flags = gfx.RDRAM[addr+start+3];
|
||||
flags = gfx.RDRAM[addr + start + 3];
|
||||
|
||||
if (flags & 0x40) { // no cull
|
||||
rdp.flags &= ~CULLMASK;
|
||||
grCullMode (GR_CULL_DISABLE);
|
||||
grCullMode(GR_CULL_DISABLE);
|
||||
}
|
||||
else { // front cull
|
||||
rdp.flags &= ~CULLMASK;
|
||||
if (rdp.view_scale[0] < 0) {
|
||||
rdp.flags |= CULL_BACK; // agh, backwards culling
|
||||
grCullMode (GR_CULL_POSITIVE);
|
||||
grCullMode(GR_CULL_POSITIVE);
|
||||
}
|
||||
else {
|
||||
rdp.flags |= CULL_FRONT;
|
||||
grCullMode (GR_CULL_NEGATIVE);
|
||||
grCullMode(GR_CULL_NEGATIVE);
|
||||
}
|
||||
}
|
||||
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;
|
||||
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;
|
||||
|
||||
v[0]->uv_calculated = 0xFFFFFFFF;
|
||||
v[1]->uv_calculated = 0xFFFFFFFF;
|
||||
v[2]->uv_calculated = 0xFFFFFFFF;
|
||||
|
||||
if (cull_tri(v))
|
||||
rdp.tri_n ++;
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
update ();
|
||||
update();
|
||||
|
||||
draw_tri (v);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void uc5_dl_in_mem ()
|
||||
static void uc5_dl_in_mem()
|
||||
{
|
||||
uint32_t addr = segoffset(rdp.cmd1) & BMASK;
|
||||
int count = (rdp.cmd0 & 0x00FF0000) >> 16;
|
||||
FRDP ("uc5:dl_in_mem - addr: %08lx, count: %d\n", addr, count);
|
||||
FRDP("uc5:dl_in_mem - addr: %08lx, count: %d\n", addr, count);
|
||||
|
||||
if (rdp.pc_i >= 9) {
|
||||
RDP_E ("** DL stack overflow **\n");
|
||||
RDP_E("** DL stack overflow **\n");
|
||||
LRDP("** DL stack overflow **\n");
|
||||
return;
|
||||
}
|
||||
rdp.pc_i ++; // go to the next PC in the stack
|
||||
rdp.pc_i++; // go to the next PC in the stack
|
||||
rdp.pc[rdp.pc_i] = addr; // jump to the address
|
||||
rdp.dl_count = count + 1;
|
||||
}
|
||||
|
@ -287,20 +287,20 @@ static void uc5_moveword()
|
|||
{
|
||||
case 0x02: // moveword matrix 2 billboard
|
||||
billboarding = (rdp.cmd1 & 1);
|
||||
FRDP ("matrix billboard - %s\n", str_offon[billboarding]);
|
||||
FRDP("matrix billboard - %s\n", str_offon[billboarding]);
|
||||
break;
|
||||
|
||||
case 0x04: // clip (verified same)
|
||||
if (((rdp.cmd0>>8)&0xFFFF) == 0x04)
|
||||
if (((rdp.cmd0 >> 8) & 0xFFFF) == 0x04)
|
||||
{
|
||||
rdp.clip_ratio = sqrt((float)rdp.cmd1);
|
||||
rdp.update |= UPDATE_VIEWPORT;
|
||||
}
|
||||
FRDP ("clip %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
FRDP("clip %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
break;
|
||||
|
||||
case 0x06: // segment (verified same)
|
||||
FRDP ("segment: %08lx -> seg%d\n", rdp.cmd1, (rdp.cmd0 >> 10) & 0x0F);
|
||||
FRDP("segment: %08lx -> seg%d\n", rdp.cmd1, (rdp.cmd0 >> 10) & 0x0F);
|
||||
rdp.segment[(rdp.cmd0 >> 10) & 0x0F] = rdp.cmd1;
|
||||
break;
|
||||
|
||||
|
@ -308,18 +308,18 @@ static void uc5_moveword()
|
|||
{
|
||||
rdp.fog_multiplier = (short)(rdp.cmd1 >> 16);
|
||||
rdp.fog_offset = (short)(rdp.cmd1 & 0x0000FFFF);
|
||||
FRDP ("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
FRDP("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
// rdp.update |= UPDATE_FOG_ENABLED;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0a: // moveword matrix select
|
||||
cur_mtx = (rdp.cmd1 >> 6) & 3;
|
||||
FRDP ("matrix select - mtx: %d\n", cur_mtx);
|
||||
FRDP("matrix select - mtx: %d\n", cur_mtx);
|
||||
break;
|
||||
|
||||
default:
|
||||
FRDP ("(unknown) %02lx - IGNORED\n", rdp.cmd0&0xFF);
|
||||
FRDP("(unknown) %02lx - IGNORED\n", rdp.cmd0 & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,13 +45,12 @@
|
|||
|
||||
uint32_t pd_col_addr = 0;
|
||||
|
||||
static void uc7_colorbase ()
|
||||
static void uc7_colorbase()
|
||||
{
|
||||
LRDP("uc7_colorbase\n");
|
||||
pd_col_addr = segoffset(rdp.cmd1);
|
||||
}
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short y;
|
||||
|
@ -62,10 +61,9 @@ typedef struct
|
|||
|
||||
short t;
|
||||
short s;
|
||||
|
||||
} vtx_uc7;
|
||||
|
||||
static void uc7_vertex ()
|
||||
static void uc7_vertex()
|
||||
{
|
||||
if (rdp.update & UPDATE_MULT_MAT)
|
||||
{
|
||||
|
@ -79,10 +77,10 @@ static void uc7_vertex ()
|
|||
rdp.update ^= UPDATE_LIGHTS;
|
||||
|
||||
// Calculate light vectors
|
||||
for (uint32_t l=0; l<rdp.num_lights; l++)
|
||||
for (uint32_t l = 0; l < rdp.num_lights; l++)
|
||||
{
|
||||
InverseTransformVector(&rdp.light[l].dir_x, rdp.light_vector[l], rdp.model);
|
||||
NormalizeVector (rdp.light_vector[l]);
|
||||
NormalizeVector(rdp.light_vector[l]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,11 +91,11 @@ static void uc7_vertex ()
|
|||
rdp.v0 = v0 = (rdp.cmd0 & 0x0F0000) >> 16;
|
||||
rdp.vn = n = ((rdp.cmd0 & 0xF00000) >> 20) + 1;
|
||||
|
||||
FRDP ("uc7:vertex n: %d, v0: %d, from: %08lx\n", n, v0, addr);
|
||||
FRDP("uc7:vertex n: %d, v0: %d, from: %08lx\n", n, v0, addr);
|
||||
|
||||
vtx_uc7 *vertex = (vtx_uc7 *)&gfx.RDRAM[addr];
|
||||
|
||||
for(i = 0; i < n; i++)
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
VERTEX *v = &rdp.vtx[v0 + i];
|
||||
x = (float)vertex->x;
|
||||
|
@ -109,7 +107,7 @@ static void uc7_vertex ()
|
|||
v->uv_scaled = 0;
|
||||
|
||||
#ifdef EXTREME_LOGGING
|
||||
// FRDP ("before: v%d - x: %f, y: %f, z: %f, flags: %04lx, ou: %f, ov: %f\n", i>>4, x, y, z, v->flags, v->ou, v->ov);
|
||||
// FRDP ("before: v%d - x: %f, y: %f, z: %f, flags: %04lx, ou: %f, ov: %f\n", i>>4, x, y, z, v->flags, v->ou, v->ov);
|
||||
#endif
|
||||
|
||||
v->x = x*rdp.combined[0][0] + y*rdp.combined[1][0] + z*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
|
@ -117,7 +115,6 @@ static void uc7_vertex ()
|
|||
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;
|
||||
|
@ -137,7 +134,7 @@ static void uc7_vertex ()
|
|||
uint8_t *color = &gfx.RDRAM[pd_col_addr + (vertex->idx & 0xff)];
|
||||
|
||||
v->a = color[0];
|
||||
CalculateFog (v);
|
||||
CalculateFog(v);
|
||||
|
||||
if (rdp.geom_mode & 0x00020000)
|
||||
{
|
||||
|
@ -147,22 +144,22 @@ static void uc7_vertex ()
|
|||
|
||||
if (rdp.geom_mode & 0x80000)
|
||||
{
|
||||
calc_linear (v);
|
||||
calc_linear(v);
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("calc linear: v%d - u: %f, v: %f\n", i>>4, v->ou, v->ov);
|
||||
FRDP("calc linear: v%d - u: %f, v: %f\n", i >> 4, v->ou, v->ov);
|
||||
#endif
|
||||
}
|
||||
else if (rdp.geom_mode & 0x40000)
|
||||
{
|
||||
calc_sphere (v);
|
||||
calc_sphere(v);
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("calc sphere: v%d - u: %f, v: %f\n", i>>4, v->ou, v->ov);
|
||||
FRDP("calc sphere: v%d - u: %f, v: %f\n", i >> 4, v->ou, v->ov);
|
||||
#endif
|
||||
}
|
||||
|
||||
NormalizeVector (v->vec);
|
||||
NormalizeVector(v->vec);
|
||||
|
||||
calc_light (v);
|
||||
calc_light(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -171,9 +168,8 @@ static void uc7_vertex ()
|
|||
v->b = color[1];
|
||||
}
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f\n", i>>4, v->x, v->y, v->z, v->w, v->ou, v->ov);
|
||||
FRDP("v%d - x: %f, y: %f, z: %f, w: %f, u: %f, v: %f\n", i >> 4, v->x, v->y, v->z, v->w, v->ou, v->ov);
|
||||
#endif
|
||||
vertex++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
uint32_t uc8_normale_addr = 0;
|
||||
float uc8_coord_mod[16];
|
||||
|
||||
static void uc8_vertex ()
|
||||
static void uc8_vertex()
|
||||
{
|
||||
if (rdp.update & UPDATE_MULT_MAT)
|
||||
{
|
||||
|
@ -59,11 +59,11 @@ static void uc8_vertex ()
|
|||
rdp.vn = n = (rdp.cmd0 >> 12) & 0xFF;
|
||||
rdp.v0 = v0 = ((rdp.cmd0 >> 1) & 0x7F) - n;
|
||||
|
||||
FRDP ("uc8:vertex n: %d, v0: %d, from: %08lx\n", n, v0, addr);
|
||||
FRDP("uc8:vertex n: %d, v0: %d, from: %08lx\n", n, v0, addr);
|
||||
|
||||
if (v0 < 0)
|
||||
{
|
||||
RDP_E ("** ERROR: uc2:vertex v0 < 0\n");
|
||||
RDP_E("** ERROR: uc2:vertex v0 < 0\n");
|
||||
LRDP("** ERROR: uc2:vertex v0 < 0\n");
|
||||
return;
|
||||
}
|
||||
|
@ -74,27 +74,27 @@ static void uc8_vertex ()
|
|||
rdp.update ^= UPDATE_LIGHTS;
|
||||
|
||||
// Calculate light vectors
|
||||
for (uint32_t l=0; l<rdp.num_lights; l++)
|
||||
for (uint32_t l = 0; l < rdp.num_lights; l++)
|
||||
{
|
||||
InverseTransformVector(&rdp.light[l].dir_x, rdp.light_vector[l], rdp.model);
|
||||
NormalizeVector (rdp.light_vector[l]);
|
||||
NormalizeVector(rdp.light_vector[l]);
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP("light_vector[%d] x: %f, y: %f, z: %f\n", l, rdp.light_vector[l][0], rdp.light_vector[l][1], rdp.light_vector[l][2]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
//*/
|
||||
for (i=0; i < (n<<4); i+=16)
|
||||
for (i = 0; i < (n << 4); i += 16)
|
||||
{
|
||||
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];
|
||||
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->a = ((uint8_t*)gfx.RDRAM)[(addr + i + 15) ^ 3];
|
||||
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("before v%d - x: %f, y: %f, z: %f\n", i>>4, x, y, z);
|
||||
|
@ -125,9 +125,9 @@ static void uc8_vertex ()
|
|||
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];
|
||||
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];
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("r: %02lx, g: %02lx, b: %02lx, a: %02lx\n", v->r, v->g, v->b, v->a);
|
||||
#endif
|
||||
|
@ -135,38 +135,38 @@ static void uc8_vertex ()
|
|||
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);
|
||||
calc_linear(v);
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("calc linear: v%d - u: %f, v: %f\n", i>>4, v->ou, v->ov);
|
||||
#endif
|
||||
}
|
||||
else if (rdp.geom_mode & 0x40000)
|
||||
{
|
||||
calc_sphere (v);
|
||||
calc_sphere(v);
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("calc sphere: v%d - u: %f, v: %f\n", i>>4, v->ou, v->ov);
|
||||
#endif
|
||||
}
|
||||
// FRDP("calc light. r: 0x%02lx, g: 0x%02lx, b: 0x%02lx, nx: %.3f, ny: %.3f, nz: %.3f\n", v->r, v->g, v->b, v->vec[0], v->vec[1], v->vec[2]);
|
||||
FRDP("v[%d] calc light. r: 0x%02lx, g: 0x%02lx, b: 0x%02lx\n", 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};
|
||||
FRDP("v[%d] calc light. r: 0x%02lx, g: 0x%02lx, b: 0x%02lx\n", 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 };
|
||||
FRDP("ambient light. r: %f, g: %f, b: %f\n", color[0], color[1], color[2]);
|
||||
float light_intensity = 0.0f;
|
||||
uint32_t l;
|
||||
if (rdp.geom_mode & 0x00400000)
|
||||
{
|
||||
NormalizeVector (v->vec);
|
||||
for (l = 0; l < rdp.num_lights-1; l++)
|
||||
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);
|
||||
FRDP("light %d, intensity : %f\n", l, light_intensity);
|
||||
if (light_intensity < 0.0f)
|
||||
continue;
|
||||
|
@ -177,7 +177,7 @@ static void uc8_vertex ()
|
|||
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 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;
|
||||
light_intensity *= p_i;
|
||||
|
@ -189,7 +189,7 @@ static void uc8_vertex ()
|
|||
color[2] += rdp.light[l].b * light_intensity;
|
||||
FRDP("light %d r: %f, g: %f, b: %f\n", 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);
|
||||
FRDP("light %d, intensity : %f\n", l, light_intensity);
|
||||
if (light_intensity > 0.0f)
|
||||
{
|
||||
|
@ -209,7 +209,7 @@ static void uc8_vertex ()
|
|||
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 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;
|
||||
FRDP("light %d, p_intensity : %f\n", l, light_intensity);
|
||||
|
@ -233,13 +233,13 @@ static void uc8_vertex ()
|
|||
}
|
||||
}
|
||||
|
||||
static void uc8_moveword ()
|
||||
static void uc8_moveword()
|
||||
{
|
||||
uint8_t index = (uint8_t)((rdp.cmd0 >> 16) & 0xFF);
|
||||
uint16_t offset = (uint16_t)(rdp.cmd0 & 0xFFFF);
|
||||
uint32_t data = rdp.cmd1;
|
||||
|
||||
FRDP ("uc8:moveword ");
|
||||
FRDP("uc8:moveword ");
|
||||
|
||||
switch (index)
|
||||
{
|
||||
|
@ -249,7 +249,7 @@ static void uc8_moveword ()
|
|||
case 0x02:
|
||||
rdp.num_lights = (data / 48);
|
||||
rdp.update |= UPDATE_LIGHTS;
|
||||
FRDP ("numlights: %d\n", rdp.num_lights);
|
||||
FRDP("numlights: %d\n", rdp.num_lights);
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
|
@ -258,12 +258,12 @@ static void uc8_moveword ()
|
|||
rdp.clip_ratio = sqrt((float)rdp.cmd1);
|
||||
rdp.update |= UPDATE_VIEWPORT;
|
||||
}
|
||||
FRDP ("mw_clip %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
FRDP("mw_clip %08lx, %08lx\n", rdp.cmd0, rdp.cmd1);
|
||||
break;
|
||||
|
||||
case 0x06: // moveword SEGMENT
|
||||
{
|
||||
FRDP ("SEGMENT %08lx -> seg%d\n", data, offset >> 2);
|
||||
FRDP("SEGMENT %08lx -> seg%d\n", data, offset >> 2);
|
||||
rdp.segment[(offset >> 2) & 0xF] = data;
|
||||
}
|
||||
break;
|
||||
|
@ -272,12 +272,12 @@ static void uc8_moveword ()
|
|||
{
|
||||
rdp.fog_multiplier = (short)(rdp.cmd1 >> 16);
|
||||
rdp.fog_offset = (short)(rdp.cmd1 & 0x0000FFFF);
|
||||
FRDP ("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
FRDP("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0c:
|
||||
RDP_E ("uc8:moveword forcemtx - IGNORED\n");
|
||||
RDP_E("uc8:moveword forcemtx - IGNORED\n");
|
||||
LRDP("forcemtx - IGNORED\n");
|
||||
break;
|
||||
|
||||
|
@ -289,28 +289,27 @@ static void uc8_moveword ()
|
|||
{
|
||||
uint8_t n = offset >> 2;
|
||||
|
||||
FRDP ("coord mod:%d, %08lx\n", n, data);
|
||||
if (rdp.cmd0&8)
|
||||
FRDP("coord mod:%d, %08lx\n", n, data);
|
||||
if (rdp.cmd0 & 8)
|
||||
return;
|
||||
uint32_t idx = (rdp.cmd0>>1)&3;
|
||||
uint32_t pos = rdp.cmd0&0x30;
|
||||
uint32_t idx = (rdp.cmd0 >> 1) & 3;
|
||||
uint32_t pos = rdp.cmd0 & 0x30;
|
||||
if (pos == 0)
|
||||
{
|
||||
uc8_coord_mod[0+idx] = (short)(rdp.cmd1>>16);
|
||||
uc8_coord_mod[1+idx] = (short)(rdp.cmd1&0xffff);
|
||||
uc8_coord_mod[0 + idx] = (short)(rdp.cmd1 >> 16);
|
||||
uc8_coord_mod[1 + idx] = (short)(rdp.cmd1 & 0xffff);
|
||||
}
|
||||
else if (pos == 0x10)
|
||||
{
|
||||
uc8_coord_mod[4+idx] = (rdp.cmd1>>16)/65536.0f;
|
||||
uc8_coord_mod[5+idx] = (rdp.cmd1&0xffff)/65536.0f;
|
||||
uc8_coord_mod[12+idx] = uc8_coord_mod[0+idx] + uc8_coord_mod[4+idx];
|
||||
uc8_coord_mod[13+idx] = uc8_coord_mod[1+idx] + uc8_coord_mod[5+idx];
|
||||
|
||||
uc8_coord_mod[4 + idx] = (rdp.cmd1 >> 16) / 65536.0f;
|
||||
uc8_coord_mod[5 + idx] = (rdp.cmd1 & 0xffff) / 65536.0f;
|
||||
uc8_coord_mod[12 + idx] = uc8_coord_mod[0 + idx] + uc8_coord_mod[4 + idx];
|
||||
uc8_coord_mod[13 + idx] = uc8_coord_mod[1 + idx] + uc8_coord_mod[5 + idx];
|
||||
}
|
||||
else if (pos == 0x20)
|
||||
{
|
||||
uc8_coord_mod[8+idx] = (short)(rdp.cmd1>>16);
|
||||
uc8_coord_mod[9+idx] = (short)(rdp.cmd1&0xffff);
|
||||
uc8_coord_mod[8 + idx] = (short)(rdp.cmd1 >> 16);
|
||||
uc8_coord_mod[9 + idx] = (short)(rdp.cmd1 & 0xffff);
|
||||
#ifdef EXTREME_LOGGING
|
||||
if (idx)
|
||||
{
|
||||
|
@ -321,35 +320,34 @@ static void uc8_moveword ()
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
FRDP_E("uc8:moveword unknown (index: 0x%08lx, offset 0x%08lx)\n", index, offset);
|
||||
FRDP ("unknown (index: 0x%08lx, offset 0x%08lx)\n", index, offset);
|
||||
FRDP("unknown (index: 0x%08lx, offset 0x%08lx)\n", index, offset);
|
||||
}
|
||||
}
|
||||
|
||||
static void uc8_movemem ()
|
||||
static void uc8_movemem()
|
||||
{
|
||||
int idx = rdp.cmd0 & 0xFF;
|
||||
uint32_t addr = segoffset(rdp.cmd1);
|
||||
int ofs = (rdp.cmd0 >> 5) & 0x3FFF;
|
||||
|
||||
FRDP ("uc8:movemem ofs:%d ", ofs);
|
||||
FRDP("uc8:movemem ofs:%d ", ofs);
|
||||
|
||||
switch (idx)
|
||||
{
|
||||
case 8: // VIEWPORT
|
||||
{
|
||||
uint32_t a = addr >> 1;
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a+0)^1] >> 2;
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a+1)^1] >> 2;
|
||||
short scale_z = ((short*)gfx.RDRAM)[(a+2)^1];
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a+4)^1] >> 2;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a+5)^1] >> 2;
|
||||
short trans_z = ((short*)gfx.RDRAM)[(a+6)^1];
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a + 0) ^ 1] >> 2;
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a + 1) ^ 1] >> 2;
|
||||
short scale_z = ((short*)gfx.RDRAM)[(a + 2) ^ 1];
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a + 4) ^ 1] >> 2;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a + 5) ^ 1] >> 2;
|
||||
short trans_z = ((short*)gfx.RDRAM)[(a + 6) ^ 1];
|
||||
rdp.view_scale[0] = scale_x * rdp.scale_x;
|
||||
rdp.view_scale[1] = -scale_y * rdp.scale_y;
|
||||
rdp.view_scale[2] = 32.0f * scale_z;
|
||||
|
@ -359,7 +357,7 @@ static void uc8_movemem ()
|
|||
|
||||
rdp.update |= UPDATE_VIEWPORT;
|
||||
|
||||
FRDP ("viewport scale(%d, %d), trans(%d, %d), from:%08lx\n", scale_x, scale_y,
|
||||
FRDP("viewport scale(%d, %d), trans(%d, %d), from:%08lx\n", scale_x, scale_y,
|
||||
trans_x, trans_y, a);
|
||||
}
|
||||
break;
|
||||
|
@ -369,11 +367,11 @@ static void uc8_movemem ()
|
|||
int n = (ofs / 48);
|
||||
if (n < 2)
|
||||
{
|
||||
char dir_x = ((char*)gfx.RDRAM)[(addr+8)^3];
|
||||
char dir_x = ((char*)gfx.RDRAM)[(addr + 8) ^ 3];
|
||||
rdp.lookat[n][0] = (float)(dir_x) / 127.0f;
|
||||
char dir_y = ((char*)gfx.RDRAM)[(addr+9)^3];
|
||||
char dir_y = ((char*)gfx.RDRAM)[(addr + 9) ^ 3];
|
||||
rdp.lookat[n][1] = (float)(dir_y) / 127.0f;
|
||||
char dir_z = ((char*)gfx.RDRAM)[(addr+10)^3];
|
||||
char dir_z = ((char*)gfx.RDRAM)[(addr + 10) ^ 3];
|
||||
rdp.lookat[n][2] = (float)(dir_z) / 127.0f;
|
||||
rdp.use_lookat = TRUE;
|
||||
if (n == 1)
|
||||
|
@ -385,37 +383,37 @@ static void uc8_movemem ()
|
|||
return;
|
||||
}
|
||||
n -= 2;
|
||||
uint8_t col = gfx.RDRAM[(addr+0)^3];
|
||||
uint8_t col = gfx.RDRAM[(addr + 0) ^ 3];
|
||||
rdp.light[n].r = (float)col / 255.0f;
|
||||
rdp.light[n].nonblack = col;
|
||||
col = gfx.RDRAM[(addr+1)^3];
|
||||
col = gfx.RDRAM[(addr + 1) ^ 3];
|
||||
rdp.light[n].g = (float)col / 255.0f;
|
||||
rdp.light[n].nonblack += col;
|
||||
col = gfx.RDRAM[(addr+2)^3];
|
||||
col = gfx.RDRAM[(addr + 2) ^ 3];
|
||||
rdp.light[n].b = (float)col / 255.0f;
|
||||
rdp.light[n].nonblack += col;
|
||||
rdp.light[n].a = 1.0f;
|
||||
rdp.light[n].dir_x = (float)(((char*)gfx.RDRAM)[(addr+8)^3]) / 127.0f;
|
||||
rdp.light[n].dir_y = (float)(((char*)gfx.RDRAM)[(addr+9)^3]) / 127.0f;
|
||||
rdp.light[n].dir_z = (float)(((char*)gfx.RDRAM)[(addr+10)^3]) / 127.0f;
|
||||
rdp.light[n].dir_x = (float)(((char*)gfx.RDRAM)[(addr + 8) ^ 3]) / 127.0f;
|
||||
rdp.light[n].dir_y = (float)(((char*)gfx.RDRAM)[(addr + 9) ^ 3]) / 127.0f;
|
||||
rdp.light[n].dir_z = (float)(((char*)gfx.RDRAM)[(addr + 10) ^ 3]) / 127.0f;
|
||||
// **
|
||||
uint32_t a = addr >> 1;
|
||||
rdp.light[n].x = (float)(((short*)gfx.RDRAM)[(a+16)^1]);
|
||||
rdp.light[n].y = (float)(((short*)gfx.RDRAM)[(a+17)^1]);
|
||||
rdp.light[n].z = (float)(((short*)gfx.RDRAM)[(a+18)^1]);
|
||||
rdp.light[n].w = (float)(((short*)gfx.RDRAM)[(a+19)^1]);
|
||||
rdp.light[n].nonzero = gfx.RDRAM[(addr+12)^3];
|
||||
rdp.light[n].x = (float)(((short*)gfx.RDRAM)[(a + 16) ^ 1]);
|
||||
rdp.light[n].y = (float)(((short*)gfx.RDRAM)[(a + 17) ^ 1]);
|
||||
rdp.light[n].z = (float)(((short*)gfx.RDRAM)[(a + 18) ^ 1]);
|
||||
rdp.light[n].w = (float)(((short*)gfx.RDRAM)[(a + 19) ^ 1]);
|
||||
rdp.light[n].nonzero = gfx.RDRAM[(addr + 12) ^ 3];
|
||||
rdp.light[n].ca = (float)rdp.light[n].nonzero / 16.0f;
|
||||
//rdp.light[n].la = rdp.light[n].ca * 1.0f;
|
||||
#ifdef EXTREME_LOGGING
|
||||
FRDP ("light: n: %d, pos: x: %f, y: %f, z: %f, w: %f, ca: %f\n",
|
||||
FRDP("light: n: %d, pos: x: %f, y: %f, z: %f, w: %f, ca: %f\n",
|
||||
n, rdp.light[n].x, rdp.light[n].y, rdp.light[n].z, rdp.light[n].w, rdp.light[n].ca);
|
||||
#endif
|
||||
FRDP ("light: n: %d, r: %f, g: %f, b: %f. dir: x: %.3f, y: %.3f, z: %.3f\n",
|
||||
FRDP("light: n: %d, r: %f, g: %f, b: %f. dir: x: %.3f, y: %.3f, z: %.3f\n",
|
||||
n, rdp.light[n].r, rdp.light[n].g, rdp.light[n].b,
|
||||
rdp.light[n].dir_x, rdp.light[n].dir_y, rdp.light[n].dir_z);
|
||||
#ifdef EXTREME_LOGGING
|
||||
for (int t=0; t < 24; t++)
|
||||
for (int t = 0; t < 24; t++)
|
||||
{
|
||||
FRDP ("light[%d] = 0x%04lx \n", t, ((uint16_t*)gfx.RDRAM)[(a+t)^1]);
|
||||
}
|
||||
|
@ -426,7 +424,7 @@ static void uc8_movemem ()
|
|||
case 14: //Normales
|
||||
{
|
||||
uc8_normale_addr = segoffset(rdp.cmd1);
|
||||
FRDP ("Normale - addr: %08lx\n", uc8_normale_addr);
|
||||
FRDP("Normale - addr: %08lx\n", uc8_normale_addr);
|
||||
#ifdef EXTREME_LOGGING
|
||||
int i;
|
||||
for (i = 0; i < 32; i++)
|
||||
|
@ -445,10 +443,9 @@ static void uc8_movemem ()
|
|||
break;
|
||||
|
||||
default:
|
||||
FRDP ("uc8:movemem unknown (%d)\n", idx);
|
||||
FRDP("uc8:movemem unknown (%d)\n", idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void uc8_tri4() //by Gugaman Apr 19 2002
|
||||
{
|
||||
|
@ -460,10 +457,10 @@ static void uc8_tri4() //by Gugaman Apr 19 2002
|
|||
|
||||
FRDP("uc8:tri4 (#%d - #%d), %d-%d-%d, %d-%d-%d, %d-%d-%d, %d-%d-%d\n",
|
||||
rdp.tri_n,
|
||||
rdp.tri_n+3,
|
||||
rdp.tri_n + 3,
|
||||
((rdp.cmd0 >> 23) & 0x1F),
|
||||
((rdp.cmd0 >> 18) & 0x1F),
|
||||
((((rdp.cmd0 >> 15) & 0x7) << 2) | ((rdp.cmd1 >> 30) &0x3)),
|
||||
((((rdp.cmd0 >> 15) & 0x7) << 2) | ((rdp.cmd1 >> 30) & 0x3)),
|
||||
((rdp.cmd0 >> 10) & 0x1F),
|
||||
((rdp.cmd0 >> 5) & 0x1F),
|
||||
((rdp.cmd0 >> 0) & 0x1F),
|
||||
|
@ -477,7 +474,7 @@ static void uc8_tri4() //by Gugaman Apr 19 2002
|
|||
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 >> 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],
|
||||
|
@ -492,55 +489,55 @@ static void uc8_tri4() //by Gugaman Apr 19 2002
|
|||
int updated = 0;
|
||||
|
||||
if (cull_tri(v))
|
||||
rdp.tri_n ++;
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
updated = 1;
|
||||
update ();
|
||||
update();
|
||||
|
||||
draw_tri (v);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v+3))
|
||||
rdp.tri_n ++;
|
||||
if (cull_tri(v + 3))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
if (!updated)
|
||||
{
|
||||
updated = 1;
|
||||
update ();
|
||||
update();
|
||||
}
|
||||
|
||||
draw_tri (v+3);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v + 3);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v+6))
|
||||
rdp.tri_n ++;
|
||||
if (cull_tri(v + 6))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
if (!updated)
|
||||
{
|
||||
updated = 1;
|
||||
update ();
|
||||
update();
|
||||
}
|
||||
|
||||
draw_tri (v+6);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v + 6);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
|
||||
if (cull_tri(v+9))
|
||||
rdp.tri_n ++;
|
||||
if (cull_tri(v + 9))
|
||||
rdp.tri_n++;
|
||||
else
|
||||
{
|
||||
if (!updated)
|
||||
{
|
||||
updated = 1;
|
||||
update ();
|
||||
update();
|
||||
}
|
||||
|
||||
draw_tri (v+9);
|
||||
rdp.tri_n ++;
|
||||
draw_tri(v + 9);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
//
|
||||
//****************************************************************
|
||||
|
||||
void uc9_rpdcmd ();
|
||||
void uc9_rpdcmd();
|
||||
|
||||
typedef float M44[4][4];
|
||||
|
||||
|
@ -50,10 +50,10 @@ struct ZSORTRDP {
|
|||
float view_trans[2];
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
} zSortRdp = {{0, 0}, {0, 0}, 0, 0};
|
||||
} zSortRdp = { { 0, 0 }, { 0, 0 }, 0, 0 };
|
||||
|
||||
//RSP command VRCPL
|
||||
static int Calc_invw (int w) {
|
||||
static int Calc_invw(int w) {
|
||||
int count, neg;
|
||||
union {
|
||||
int32_t W;
|
||||
|
@ -64,27 +64,30 @@ static int Calc_invw (int w) {
|
|||
Result.W = w;
|
||||
if (Result.UW == 0) {
|
||||
Result.UW = 0x7FFFFFFF;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (Result.W < 0) {
|
||||
neg = TRUE;
|
||||
if (Result.UHW[1] == 0xFFFF && Result.HW[0] < 0) {
|
||||
Result.W = ~Result.W + 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Result.W = ~Result.W;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
neg = FALSE;
|
||||
}
|
||||
for (count = 31; count > 0; count--) {
|
||||
if ((Result.W & (1 << count))) {
|
||||
Result.W &= (0xFFC00000 >> (31 - count) );
|
||||
Result.W &= (0xFFC00000 >> (31 - count));
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
Result.W = 0x7FFFFFFF / Result.W;
|
||||
for (count = 31; count > 0; count--) {
|
||||
if ((Result.W & (1 << count))) {
|
||||
Result.W &= (0xFFFF8000 >> (31 - count) );
|
||||
Result.W &= (0xFFFF8000 >> (31 - count));
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +98,7 @@ static int Calc_invw (int w) {
|
|||
return Result.W;
|
||||
}
|
||||
|
||||
static void uc9_draw_object (uint8_t * addr, uint32_t type)
|
||||
static void uc9_draw_object(uint8_t * addr, uint32_t type)
|
||||
{
|
||||
uint32_t textured, vnum, vsize;
|
||||
switch (type) {
|
||||
|
@ -131,13 +134,13 @@ static void uc9_draw_object (uint8_t * addr, uint32_t type)
|
|||
for (uint32_t i = 0; i < vnum; i++)
|
||||
{
|
||||
VERTEX &v = vtx[i];
|
||||
v.sx = zSortRdp.scale_x * ((short*)addr)[0^1];
|
||||
v.sy = zSortRdp.scale_y * ((short*)addr)[1^1];
|
||||
v.sx = zSortRdp.scale_x * ((short*)addr)[0 ^ 1];
|
||||
v.sy = zSortRdp.scale_y * ((short*)addr)[1 ^ 1];
|
||||
v.sz = 1.0f;
|
||||
v.r = addr[4^3];
|
||||
v.g = addr[5^3];
|
||||
v.b = addr[6^3];
|
||||
v.a = addr[7^3];
|
||||
v.r = addr[4 ^ 3];
|
||||
v.g = addr[5 ^ 3];
|
||||
v.b = addr[6 ^ 3];
|
||||
v.a = addr[7 ^ 3];
|
||||
v.flags = 0;
|
||||
v.uv_scaled = 0;
|
||||
v.uv_calculated = 0xFFFFFFFF;
|
||||
|
@ -146,16 +149,16 @@ static void uc9_draw_object (uint8_t * addr, uint32_t type)
|
|||
v.screen_translated = 2;
|
||||
if (textured)
|
||||
{
|
||||
v.ou = ((short*)addr)[4^1];
|
||||
v.ov = ((short*)addr)[5^1];
|
||||
v.ou = ((short*)addr)[4 ^ 1];
|
||||
v.ov = ((short*)addr)[5 ^ 1];
|
||||
v.w = Calc_invw(((int*)addr)[3]) / 31.0f;
|
||||
v.oow = 1.0f / v.w;
|
||||
FRDP ("v%d - sx: %f, sy: %f ou: %f, ov: %f, w: %f, r=%d, g=%d, b=%d, a=%d\n", i, v.sx/rdp.scale_x, v.sy/rdp.scale_y, v.ou*rdp.tiles[rdp.cur_tile].s_scale, v.ov*rdp.tiles[rdp.cur_tile].t_scale, v.w, v.r, v.g, v.b, v.a);
|
||||
FRDP("v%d - sx: %f, sy: %f ou: %f, ov: %f, w: %f, r=%d, g=%d, b=%d, a=%d\n", i, v.sx / rdp.scale_x, v.sy / rdp.scale_y, v.ou*rdp.tiles[rdp.cur_tile].s_scale, v.ov*rdp.tiles[rdp.cur_tile].t_scale, v.w, v.r, v.g, v.b, v.a);
|
||||
}
|
||||
else
|
||||
{
|
||||
v.oow = v.w = 1.0f;
|
||||
FRDP ("v%d - sx: %f, sy: %f r=%d, g=%d, b=%d, a=%d\n", i, v.sx/rdp.scale_x, v.sy/rdp.scale_y, v.r, v.g, v.b, v.a);
|
||||
FRDP("v%d - sx: %f, sy: %f r=%d, g=%d, b=%d, a=%d\n", i, v.sx / rdp.scale_x, v.sy / rdp.scale_y, v.r, v.g, v.b, v.a);
|
||||
}
|
||||
addr += vsize;
|
||||
}
|
||||
|
@ -168,23 +171,23 @@ static void uc9_draw_object (uint8_t * addr, uint32_t type)
|
|||
};
|
||||
if (vnum == 3)
|
||||
{
|
||||
FRDP("uc9:Tri #%d, #%d\n", rdp.tri_n, rdp.tri_n+1);
|
||||
draw_tri (pV, 0);
|
||||
rdp.tri_n ++;
|
||||
FRDP("uc9:Tri #%d, #%d\n", rdp.tri_n, rdp.tri_n + 1);
|
||||
draw_tri(pV, 0);
|
||||
rdp.tri_n++;
|
||||
}
|
||||
else
|
||||
{
|
||||
FRDP("uc9:Quad #%d, #%d\n", rdp.tri_n, rdp.tri_n+1);
|
||||
draw_tri (pV, 0);
|
||||
draw_tri (pV+1, 0);
|
||||
FRDP("uc9:Quad #%d, #%d\n", rdp.tri_n, rdp.tri_n + 1);
|
||||
draw_tri(pV, 0);
|
||||
draw_tri(pV + 1, 0);
|
||||
rdp.tri_n += 2;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t uc9_load_object (uint32_t zHeader, uint32_t * rdpcmds)
|
||||
static uint32_t uc9_load_object(uint32_t zHeader, uint32_t * rdpcmds)
|
||||
{
|
||||
uint32_t type = zHeader & 7;
|
||||
uint8_t * addr = gfx.RDRAM + (zHeader&0xFFFFFFF8);
|
||||
uint8_t * addr = gfx.RDRAM + (zHeader & 0xFFFFFFF8);
|
||||
switch (type) {
|
||||
case 1: //sh tri
|
||||
case 3: //sh quad
|
||||
|
@ -193,9 +196,9 @@ static uint32_t uc9_load_object (uint32_t zHeader, uint32_t * rdpcmds)
|
|||
if (rdp.cmd1 != rdpcmds[0])
|
||||
{
|
||||
rdpcmds[0] = rdp.cmd1;
|
||||
uc9_rpdcmd ();
|
||||
uc9_rpdcmd();
|
||||
}
|
||||
update ();
|
||||
update();
|
||||
uc9_draw_object(addr + 8, type);
|
||||
}
|
||||
break;
|
||||
|
@ -207,23 +210,23 @@ static uint32_t uc9_load_object (uint32_t zHeader, uint32_t * rdpcmds)
|
|||
if (rdp.cmd1 != rdpcmds[0])
|
||||
{
|
||||
rdpcmds[0] = rdp.cmd1;
|
||||
uc9_rpdcmd ();
|
||||
uc9_rpdcmd();
|
||||
}
|
||||
rdp.cmd1 = ((uint32_t*)addr)[2];
|
||||
if (rdp.cmd1 != rdpcmds[1])
|
||||
{
|
||||
uc9_rpdcmd ();
|
||||
uc9_rpdcmd();
|
||||
rdpcmds[1] = rdp.cmd1;
|
||||
}
|
||||
rdp.cmd1 = ((uint32_t*)addr)[3];
|
||||
if (rdp.cmd1 != rdpcmds[2])
|
||||
{
|
||||
uc9_rpdcmd ();
|
||||
uc9_rpdcmd();
|
||||
rdpcmds[2] = rdp.cmd1;
|
||||
}
|
||||
if (type)
|
||||
{
|
||||
update ();
|
||||
update();
|
||||
uc9_draw_object(addr + 16, type);
|
||||
}
|
||||
}
|
||||
|
@ -232,10 +235,10 @@ static uint32_t uc9_load_object (uint32_t zHeader, uint32_t * rdpcmds)
|
|||
return segoffset(((uint32_t*)addr)[0]);
|
||||
}
|
||||
|
||||
static void uc9_object ()
|
||||
static void uc9_object()
|
||||
{
|
||||
LRDP("uc9:object\n");
|
||||
uint32_t rdpcmds[3] = {0, 0, 0};
|
||||
uint32_t rdpcmds[3] = { 0, 0, 0 };
|
||||
uint32_t cmd1 = rdp.cmd1;
|
||||
uint32_t zHeader = segoffset(rdp.cmd0);
|
||||
while (zHeader)
|
||||
|
@ -245,17 +248,17 @@ static void uc9_object ()
|
|||
zHeader = uc9_load_object(zHeader, rdpcmds);
|
||||
}
|
||||
|
||||
static void uc9_mix ()
|
||||
static void uc9_mix()
|
||||
{
|
||||
LRDP("uc9:mix IGNORED\n");
|
||||
}
|
||||
|
||||
static void uc9_fmlight ()
|
||||
static void uc9_fmlight()
|
||||
{
|
||||
int mid = rdp.cmd0&0xFF;
|
||||
rdp.num_lights = 1 + ((rdp.cmd1>>12)&0xFF);
|
||||
uint32_t a = -1024 + (rdp.cmd1&0xFFF);
|
||||
FRDP ("uc9:fmlight matrix: %d, num: %d, dmem: %04lx\n", mid, rdp.num_lights, a);
|
||||
int mid = rdp.cmd0 & 0xFF;
|
||||
rdp.num_lights = 1 + ((rdp.cmd1 >> 12) & 0xFF);
|
||||
uint32_t a = -1024 + (rdp.cmd1 & 0xFFF);
|
||||
FRDP("uc9:fmlight matrix: %d, num: %d, dmem: %04lx\n", mid, rdp.num_lights, a);
|
||||
|
||||
M44 *m = NULL;
|
||||
switch (mid) {
|
||||
|
@ -274,37 +277,37 @@ static void uc9_fmlight ()
|
|||
break;
|
||||
}
|
||||
|
||||
rdp.light[rdp.num_lights].r = (float)(((uint8_t*)gfx.DMEM)[(a+0)^3]) / 255.0f;
|
||||
rdp.light[rdp.num_lights].g = (float)(((uint8_t*)gfx.DMEM)[(a+1)^3]) / 255.0f;
|
||||
rdp.light[rdp.num_lights].b = (float)(((uint8_t*)gfx.DMEM)[(a+2)^3]) / 255.0f;
|
||||
rdp.light[rdp.num_lights].r = (float)(((uint8_t*)gfx.DMEM)[(a + 0) ^ 3]) / 255.0f;
|
||||
rdp.light[rdp.num_lights].g = (float)(((uint8_t*)gfx.DMEM)[(a + 1) ^ 3]) / 255.0f;
|
||||
rdp.light[rdp.num_lights].b = (float)(((uint8_t*)gfx.DMEM)[(a + 2) ^ 3]) / 255.0f;
|
||||
rdp.light[rdp.num_lights].a = 1.0f;
|
||||
FRDP ("ambient light: r: %.3f, g: %.3f, b: %.3f\n", rdp.light[rdp.num_lights].r, rdp.light[rdp.num_lights].g, rdp.light[rdp.num_lights].b);
|
||||
FRDP("ambient light: r: %.3f, g: %.3f, b: %.3f\n", rdp.light[rdp.num_lights].r, rdp.light[rdp.num_lights].g, rdp.light[rdp.num_lights].b);
|
||||
a += 8;
|
||||
uint32_t i;
|
||||
for (i = 0; i < rdp.num_lights; i++)
|
||||
{
|
||||
rdp.light[i].r = (float)(((uint8_t*)gfx.DMEM)[(a+0)^3]) / 255.0f;
|
||||
rdp.light[i].g = (float)(((uint8_t*)gfx.DMEM)[(a+1)^3]) / 255.0f;
|
||||
rdp.light[i].b = (float)(((uint8_t*)gfx.DMEM)[(a+2)^3]) / 255.0f;
|
||||
rdp.light[i].r = (float)(((uint8_t*)gfx.DMEM)[(a + 0) ^ 3]) / 255.0f;
|
||||
rdp.light[i].g = (float)(((uint8_t*)gfx.DMEM)[(a + 1) ^ 3]) / 255.0f;
|
||||
rdp.light[i].b = (float)(((uint8_t*)gfx.DMEM)[(a + 2) ^ 3]) / 255.0f;
|
||||
rdp.light[i].a = 1.0f;
|
||||
rdp.light[i].dir_x = (float)(((char*)gfx.DMEM)[(a+8)^3]) / 127.0f;
|
||||
rdp.light[i].dir_y = (float)(((char*)gfx.DMEM)[(a+9)^3]) / 127.0f;
|
||||
rdp.light[i].dir_z = (float)(((char*)gfx.DMEM)[(a+10)^3]) / 127.0f;
|
||||
FRDP ("light: n: %d, r: %.3f, g: %.3f, b: %.3f, x: %.3f, y: %.3f, z: %.3f\n",
|
||||
rdp.light[i].dir_x = (float)(((char*)gfx.DMEM)[(a + 8) ^ 3]) / 127.0f;
|
||||
rdp.light[i].dir_y = (float)(((char*)gfx.DMEM)[(a + 9) ^ 3]) / 127.0f;
|
||||
rdp.light[i].dir_z = (float)(((char*)gfx.DMEM)[(a + 10) ^ 3]) / 127.0f;
|
||||
FRDP("light: n: %d, r: %.3f, g: %.3f, b: %.3f, x: %.3f, y: %.3f, z: %.3f\n",
|
||||
i, rdp.light[i].r, rdp.light[i].g, rdp.light[i].b,
|
||||
rdp.light[i].dir_x, rdp.light[i].dir_y, rdp.light[i].dir_z);
|
||||
// TransformVector(&rdp.light[i].dir_x, rdp.light_vector[i], *m);
|
||||
// TransformVector(&rdp.light[i].dir_x, rdp.light_vector[i], *m);
|
||||
InverseTransformVector(&rdp.light[i].dir_x, rdp.light_vector[i], *m);
|
||||
NormalizeVector (rdp.light_vector[i]);
|
||||
FRDP ("light vector: n: %d, x: %.3f, y: %.3f, z: %.3f\n",
|
||||
NormalizeVector(rdp.light_vector[i]);
|
||||
FRDP("light vector: n: %d, x: %.3f, y: %.3f, z: %.3f\n",
|
||||
i, rdp.light_vector[i][0], rdp.light_vector[i][1], rdp.light_vector[i][2]);
|
||||
a += 24;
|
||||
}
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
float dir_x = (float)(((char*)gfx.DMEM)[(a+8)^3]) / 127.0f;
|
||||
float dir_y = (float)(((char*)gfx.DMEM)[(a+9)^3]) / 127.0f;
|
||||
float dir_z = (float)(((char*)gfx.DMEM)[(a+10)^3]) / 127.0f;
|
||||
float dir_x = (float)(((char*)gfx.DMEM)[(a + 8) ^ 3]) / 127.0f;
|
||||
float dir_y = (float)(((char*)gfx.DMEM)[(a + 9) ^ 3]) / 127.0f;
|
||||
float dir_z = (float)(((char*)gfx.DMEM)[(a + 10) ^ 3]) / 127.0f;
|
||||
if (sqrt(dir_x*dir_x + dir_y*dir_y + dir_z*dir_z) < 0.98)
|
||||
{
|
||||
rdp.use_lookat = FALSE;
|
||||
|
@ -318,44 +321,44 @@ static void uc9_fmlight ()
|
|||
rdp.use_lookat = TRUE;
|
||||
}
|
||||
|
||||
static void uc9_light ()
|
||||
static void uc9_light()
|
||||
{
|
||||
uint32_t csrs = -1024 + ((rdp.cmd0>>12)&0xFFF);
|
||||
uint32_t nsrs = -1024 + (rdp.cmd0&0xFFF);
|
||||
uint32_t num = 1 + ((rdp.cmd1>>24)&0xFF);
|
||||
uint32_t cdest = -1024 + ((rdp.cmd1>>12)&0xFFF);
|
||||
uint32_t tdest = -1024 + (rdp.cmd1&0xFFF);
|
||||
uint32_t csrs = -1024 + ((rdp.cmd0 >> 12) & 0xFFF);
|
||||
uint32_t nsrs = -1024 + (rdp.cmd0 & 0xFFF);
|
||||
uint32_t num = 1 + ((rdp.cmd1 >> 24) & 0xFF);
|
||||
uint32_t cdest = -1024 + ((rdp.cmd1 >> 12) & 0xFFF);
|
||||
uint32_t tdest = -1024 + (rdp.cmd1 & 0xFFF);
|
||||
int use_material = (csrs != 0x0ff0);
|
||||
tdest >>= 1;
|
||||
FRDP ("uc9:light n: %d, colsrs: %04lx, normales: %04lx, coldst: %04lx, texdst: %04lx\n", num, csrs, nsrs, cdest, tdest);
|
||||
FRDP("uc9:light n: %d, colsrs: %04lx, normales: %04lx, coldst: %04lx, texdst: %04lx\n", num, csrs, nsrs, cdest, tdest);
|
||||
VERTEX v;
|
||||
for (uint32_t i = 0; i < num; i++)
|
||||
{
|
||||
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_linear (&v);
|
||||
NormalizeVector (v.vec);
|
||||
calc_light (&v);
|
||||
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_linear (&v);
|
||||
NormalizeVector(v.vec);
|
||||
calc_light(&v);
|
||||
v.a = 0xFF;
|
||||
if (use_material)
|
||||
{
|
||||
v.r = (uint8_t)(((uint32_t)v.r * gfx.DMEM[(csrs++)^3])>>8);
|
||||
v.g = (uint8_t)(((uint32_t)v.g * gfx.DMEM[(csrs++)^3])>>8);
|
||||
v.b = (uint8_t)(((uint32_t)v.b * gfx.DMEM[(csrs++)^3])>>8);
|
||||
v.a = gfx.DMEM[(csrs++)^3];
|
||||
v.r = (uint8_t)(((uint32_t)v.r * gfx.DMEM[(csrs++) ^ 3]) >> 8);
|
||||
v.g = (uint8_t)(((uint32_t)v.g * gfx.DMEM[(csrs++) ^ 3]) >> 8);
|
||||
v.b = (uint8_t)(((uint32_t)v.b * gfx.DMEM[(csrs++) ^ 3]) >> 8);
|
||||
v.a = gfx.DMEM[(csrs++) ^ 3];
|
||||
}
|
||||
gfx.DMEM[(cdest++)^3] = v.r;
|
||||
gfx.DMEM[(cdest++)^3] = v.g;
|
||||
gfx.DMEM[(cdest++)^3] = v.b;
|
||||
gfx.DMEM[(cdest++)^3] = v.a;
|
||||
((short*)gfx.DMEM)[(tdest++)^1] = (short)v.ou;
|
||||
((short*)gfx.DMEM)[(tdest++)^1] = (short)v.ov;
|
||||
gfx.DMEM[(cdest++) ^ 3] = v.r;
|
||||
gfx.DMEM[(cdest++) ^ 3] = v.g;
|
||||
gfx.DMEM[(cdest++) ^ 3] = v.b;
|
||||
gfx.DMEM[(cdest++) ^ 3] = v.a;
|
||||
((short*)gfx.DMEM)[(tdest++) ^ 1] = (short)v.ou;
|
||||
((short*)gfx.DMEM)[(tdest++) ^ 1] = (short)v.ov;
|
||||
}
|
||||
}
|
||||
|
||||
static void uc9_mtxtrnsp ()
|
||||
static void uc9_mtxtrnsp()
|
||||
{
|
||||
LRDP("uc9:mtxtrnsp - ignored\n");
|
||||
/*
|
||||
|
@ -387,14 +390,14 @@ static void uc9_mtxtrnsp ()
|
|||
*/
|
||||
}
|
||||
|
||||
static void uc9_mtxcat ()
|
||||
static void uc9_mtxcat()
|
||||
{
|
||||
LRDP("uc9:mtxcat ");
|
||||
M44 *s = NULL;
|
||||
M44 *t = NULL;
|
||||
uint32_t S = rdp.cmd0&0xF;
|
||||
uint32_t T = (rdp.cmd1>>16)&0xF;
|
||||
uint32_t D = rdp.cmd1&0xF;
|
||||
uint32_t S = rdp.cmd0 & 0xF;
|
||||
uint32_t T = (rdp.cmd1 >> 16) & 0xF;
|
||||
uint32_t D = rdp.cmd1 & 0xF;
|
||||
switch (S) {
|
||||
case 4:
|
||||
s = (M44*)rdp.model;
|
||||
|
@ -436,15 +439,15 @@ static void uc9_mtxcat ()
|
|||
|
||||
switch (D) {
|
||||
case 4:
|
||||
memcpy (rdp.model, m, 64);;
|
||||
memcpy(rdp.model, m, 64);;
|
||||
LRDP("Model\n");
|
||||
break;
|
||||
case 6:
|
||||
memcpy (rdp.proj, m, 64);;
|
||||
memcpy(rdp.proj, m, 64);;
|
||||
LRDP("Proj\n");
|
||||
break;
|
||||
case 8:
|
||||
memcpy (rdp.combined, m, 64);;
|
||||
memcpy(rdp.combined, m, 64);;
|
||||
LRDP("Comb\n");
|
||||
break;
|
||||
}
|
||||
|
@ -458,11 +461,11 @@ static void uc9_mtxcat ()
|
|||
FRDP ("{%f,%f,%f,%f}\n", rdp.proj[2][0], rdp.proj[2][1], rdp.proj[2][2], rdp.proj[2][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.proj[3][0], rdp.proj[3][1], rdp.proj[3][2], rdp.proj[3][3]);
|
||||
FRDP ("\ncombined\n{%f,%f,%f,%f}\n", rdp.combined[0][0], rdp.combined[0][1], rdp.combined[0][2], rdp.combined[0][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.combined[1][0], rdp.combined[1][1], rdp.combined[1][2], rdp.combined[1][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.combined[2][0], rdp.combined[2][1], rdp.combined[2][2], rdp.combined[2][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.combined[3][0], rdp.combined[3][1], rdp.combined[3][2], rdp.combined[3][3]);
|
||||
FRDP("{%f,%f,%f,%f}\n", rdp.combined[1][0], rdp.combined[1][1], rdp.combined[1][2], rdp.combined[1][3]);
|
||||
FRDP("{%f,%f,%f,%f}\n", rdp.combined[2][0], rdp.combined[2][1], rdp.combined[2][2], rdp.combined[2][3]);
|
||||
FRDP("{%f,%f,%f,%f}\n", rdp.combined[3][0], rdp.combined[3][1], rdp.combined[3][2], rdp.combined[3][3]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
short sy;
|
||||
|
@ -475,15 +478,15 @@ typedef struct {
|
|||
uint8_t cc;
|
||||
} zSortVDest;
|
||||
|
||||
static void uc9_mult_mpmtx ()
|
||||
static void uc9_mult_mpmtx()
|
||||
{
|
||||
//int id = rdp.cmd0&0xFF;
|
||||
int num = 1+ ((rdp.cmd1>>24)&0xFF);
|
||||
int src = -1024 + ((rdp.cmd1>>12)&0xFFF);
|
||||
int dst = -1024 + (rdp.cmd1&0xFFF);
|
||||
FRDP ("uc9:mult_mpmtx from: %04lx to: %04lx n: %d\n", src, dst, num);
|
||||
short * saddr = (short*)(gfx.DMEM+src);
|
||||
zSortVDest * daddr = (zSortVDest*)(gfx.DMEM+dst);
|
||||
int num = 1 + ((rdp.cmd1 >> 24) & 0xFF);
|
||||
int src = -1024 + ((rdp.cmd1 >> 12) & 0xFFF);
|
||||
int dst = -1024 + (rdp.cmd1 & 0xFFF);
|
||||
FRDP("uc9:mult_mpmtx from: %04lx to: %04lx n: %d\n", src, dst, num);
|
||||
short * saddr = (short*)(gfx.DMEM + src);
|
||||
zSortVDest * daddr = (zSortVDest*)(gfx.DMEM + dst);
|
||||
int idx = 0;
|
||||
zSortVDest v;
|
||||
memset(&v, 0, sizeof(zSortVDest));
|
||||
|
@ -491,9 +494,9 @@ static void uc9_mult_mpmtx ()
|
|||
//float scale_y = 4.0f/rdp.scale_y;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
short sx = saddr[(idx++)^1];
|
||||
short sy = saddr[(idx++)^1];
|
||||
short sz = saddr[(idx++)^1];
|
||||
short sx = saddr[(idx++) ^ 1];
|
||||
short sy = saddr[(idx++) ^ 1];
|
||||
short sz = saddr[(idx++) ^ 1];
|
||||
float x = sx*rdp.combined[0][0] + sy*rdp.combined[1][0] + sz*rdp.combined[2][0] + rdp.combined[3][0];
|
||||
float y = sx*rdp.combined[0][1] + sy*rdp.combined[1][1] + sz*rdp.combined[2][1] + rdp.combined[3][1];
|
||||
float z = sx*rdp.combined[0][2] + sy*rdp.combined[1][2] + sz*rdp.combined[2][2] + rdp.combined[3][2];
|
||||
|
@ -525,54 +528,53 @@ static void uc9_mult_mpmtx ()
|
|||
|
||||
daddr[i] = v;
|
||||
//memcpy(gfx.DMEM+dst+sizeof(zSortVDest)*i, &v, sizeof(zSortVDest));
|
||||
// FRDP("v%d x: %d, y: %d, z: %d -> sx: %d, sy: %d, w: %d, xi: %d, yi: %d, wi: %d, fog: %d\n", i, sx, sy, sz, v.sx, v.sy, v.invw, v.xi, v.yi, v.wi, v.fog);
|
||||
// FRDP("v%d x: %d, y: %d, z: %d -> sx: %d, sy: %d, w: %d, xi: %d, yi: %d, wi: %d, fog: %d\n", i, sx, sy, sz, v.sx, v.sy, v.invw, v.xi, v.yi, v.wi, v.fog);
|
||||
FRDP("v%d x: %d, y: %d, z: %d -> sx: %04lx, sy: %04lx, invw: %08lx - %f, xi: %04lx, yi: %04lx, wi: %04lx, fog: %04lx\n", i, sx, sy, sz, v.sx, v.sy, v.invw, w, v.xi, v.yi, v.wi, v.fog);
|
||||
}
|
||||
}
|
||||
|
||||
static void uc9_link_subdl ()
|
||||
static void uc9_link_subdl()
|
||||
{
|
||||
LRDP("uc9:link_subdl IGNORED\n");
|
||||
}
|
||||
|
||||
static void uc9_set_subdl ()
|
||||
static void uc9_set_subdl()
|
||||
{
|
||||
LRDP("uc9:set_subdl IGNORED\n");
|
||||
}
|
||||
|
||||
static void uc9_wait_signal ()
|
||||
static void uc9_wait_signal()
|
||||
{
|
||||
LRDP("uc9:wait_signal IGNORED\n");
|
||||
}
|
||||
|
||||
static void uc9_send_signal ()
|
||||
static void uc9_send_signal()
|
||||
{
|
||||
LRDP("uc9:send_signal IGNORED\n");
|
||||
}
|
||||
|
||||
void uc9_movemem ()
|
||||
void uc9_movemem()
|
||||
{
|
||||
LRDP("uc9:movemem\n");
|
||||
int idx = rdp.cmd0 & 0x0E;
|
||||
int ofs = ((rdp.cmd0>>6)&0x1ff)<<3;
|
||||
int len = (1 + ((rdp.cmd0>>15)&0x1ff))<<3;
|
||||
FRDP ("uc9:movemem ofs: %d, len: %d. ", ofs, len);
|
||||
int ofs = ((rdp.cmd0 >> 6) & 0x1ff) << 3;
|
||||
int len = (1 + ((rdp.cmd0 >> 15) & 0x1ff)) << 3;
|
||||
FRDP("uc9:movemem ofs: %d, len: %d. ", ofs, len);
|
||||
int flag = rdp.cmd0 & 0x01;
|
||||
uint32_t addr = segoffset(rdp.cmd1);
|
||||
switch (idx)
|
||||
{
|
||||
|
||||
case 0: //save/load
|
||||
if (flag == 0)
|
||||
{
|
||||
int dmem_addr = (idx<<3) + ofs;
|
||||
FRDP ("Load to DMEM. %08lx -> %08lx\n", addr, dmem_addr);
|
||||
int dmem_addr = (idx << 3) + ofs;
|
||||
FRDP("Load to DMEM. %08lx -> %08lx\n", addr, dmem_addr);
|
||||
memcpy(gfx.DMEM + dmem_addr, gfx.RDRAM + addr, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
int dmem_addr = (idx<<3) + ofs;
|
||||
FRDP ("Load from DMEM. %08lx -> %08lx\n", dmem_addr, addr);
|
||||
int dmem_addr = (idx << 3) + ofs;
|
||||
FRDP("Load from DMEM. %08lx -> %08lx\n", dmem_addr, addr);
|
||||
memcpy(gfx.RDRAM + addr, gfx.DMEM + dmem_addr, len);
|
||||
}
|
||||
break;
|
||||
|
@ -587,16 +589,16 @@ void uc9_movemem ()
|
|||
{
|
||||
case 4: // model matrix
|
||||
LRDP("Modelview load\n");
|
||||
modelview_load (m);
|
||||
modelview_load(m);
|
||||
break;
|
||||
case 6: // projection matrix
|
||||
LRDP("Projection load\n");
|
||||
projection_load (m);
|
||||
projection_load(m);
|
||||
break;
|
||||
case 8: // projection matrix
|
||||
LRDP("Combined load\n");
|
||||
rdp.update &= ~UPDATE_MULT_MAT;
|
||||
memcpy (rdp.combined, m, 64);;
|
||||
memcpy(rdp.combined, m, 64);;
|
||||
break;
|
||||
}
|
||||
#ifdef EXTREME_LOGGING
|
||||
|
@ -610,8 +612,8 @@ void uc9_movemem ()
|
|||
FRDP ("{%f,%f,%f,%f}\n", rdp.model[3][0], rdp.model[3][1], rdp.model[3][2], rdp.model[3][3]);
|
||||
FRDP ("\nproj\n{%f,%f,%f,%f}\n", rdp.proj[0][0], rdp.proj[0][1], rdp.proj[0][2], rdp.proj[0][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.proj[1][0], rdp.proj[1][1], rdp.proj[1][2], rdp.proj[1][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.proj[2][0], rdp.proj[2][1], rdp.proj[2][2], rdp.proj[2][3]);
|
||||
FRDP ("{%f,%f,%f,%f}\n", rdp.proj[3][0], rdp.proj[3][1], rdp.proj[3][2], rdp.proj[3][3]);
|
||||
FRDP("{%f,%f,%f,%f}\n", rdp.proj[2][0], rdp.proj[2][1], rdp.proj[2][2], rdp.proj[2][3]);
|
||||
FRDP("{%f,%f,%f,%f}\n", rdp.proj[3][0], rdp.proj[3][1], rdp.proj[3][2], rdp.proj[3][3]);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
@ -623,24 +625,24 @@ void uc9_movemem ()
|
|||
case 12: // VIEWPORT
|
||||
{
|
||||
uint32_t a = addr >> 1;
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a+0)^1] >> 2;
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a+1)^1] >> 2;
|
||||
short scale_z = ((short*)gfx.RDRAM)[(a+2)^1];
|
||||
rdp.fog_multiplier = ((short*)gfx.RDRAM)[(a+3)^1];
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a+4)^1] >> 2;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a+5)^1] >> 2;
|
||||
short trans_z = ((short*)gfx.RDRAM)[(a+6)^1];
|
||||
rdp.fog_offset = ((short*)gfx.RDRAM)[(a+7)^1];
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a + 0) ^ 1] >> 2;
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a + 1) ^ 1] >> 2;
|
||||
short scale_z = ((short*)gfx.RDRAM)[(a + 2) ^ 1];
|
||||
rdp.fog_multiplier = ((short*)gfx.RDRAM)[(a + 3) ^ 1];
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a + 4) ^ 1] >> 2;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a + 5) ^ 1] >> 2;
|
||||
short trans_z = ((short*)gfx.RDRAM)[(a + 6) ^ 1];
|
||||
rdp.fog_offset = ((short*)gfx.RDRAM)[(a + 7) ^ 1];
|
||||
rdp.view_scale[0] = scale_x * rdp.scale_x;
|
||||
rdp.view_scale[1] = scale_y * rdp.scale_y;
|
||||
rdp.view_scale[2] = 32.0f * scale_z;
|
||||
rdp.view_trans[0] = trans_x * rdp.scale_x;
|
||||
rdp.view_trans[1] = trans_y * rdp.scale_y;
|
||||
rdp.view_trans[2] = 32.0f * trans_z;
|
||||
zSortRdp.view_scale[0] = (float)(scale_x*4);
|
||||
zSortRdp.view_scale[1] = (float)(scale_y*4);
|
||||
zSortRdp.view_trans[0] = (float)(trans_x*4);
|
||||
zSortRdp.view_trans[1] = (float)(trans_y*4);
|
||||
zSortRdp.view_scale[0] = (float)(scale_x * 4);
|
||||
zSortRdp.view_scale[1] = (float)(scale_y * 4);
|
||||
zSortRdp.view_trans[0] = (float)(trans_x * 4);
|
||||
zSortRdp.view_trans[1] = (float)(trans_y * 4);
|
||||
zSortRdp.scale_x = rdp.scale_x / 4.0f;
|
||||
zSortRdp.scale_y = rdp.scale_y / 4.0f;
|
||||
|
||||
|
@ -657,17 +659,16 @@ void uc9_movemem ()
|
|||
|
||||
rdp.geom_mode |= 0x0200;
|
||||
|
||||
FRDP ("viewport scale(%d, %d, %d), trans(%d, %d, %d), from:%08lx\n", scale_x, scale_y, scale_z,
|
||||
FRDP("viewport scale(%d, %d, %d), trans(%d, %d, %d), from:%08lx\n", scale_x, scale_y, scale_z,
|
||||
trans_x, trans_y, trans_z, a);
|
||||
FRDP ("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
FRDP("fog: multiplier: %f, offset: %f\n", rdp.fog_multiplier, rdp.fog_offset);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
FRDP ("** UNKNOWN %d\n", idx);
|
||||
FRDP("** UNKNOWN %d\n", idx);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void uc9_setscissor()
|
||||
{
|
||||
|
|
|
@ -41,18 +41,18 @@
|
|||
//
|
||||
//****************************************************************
|
||||
|
||||
void uc9_rpdcmd ()
|
||||
void uc9_rpdcmd()
|
||||
{
|
||||
uint32_t a = segoffset(rdp.cmd1) >> 2;
|
||||
FRDP ("uc9:rdpcmd addr: %08lx\n", a);
|
||||
FRDP("uc9:rdpcmd addr: %08lx\n", a);
|
||||
if (a)
|
||||
{
|
||||
rdp.LLE = 1;
|
||||
uint32_t cmd = 0;
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
rdp.cmd0 = ((uint32_t*)gfx.RDRAM)[a++];
|
||||
cmd = rdp.cmd0>>24;
|
||||
cmd = rdp.cmd0 >> 24;
|
||||
if (cmd == 0xDF)
|
||||
break;
|
||||
rdp.cmd1 = ((uint32_t*)gfx.RDRAM)[a++];
|
||||
|
@ -63,7 +63,7 @@ void uc9_rpdcmd ()
|
|||
a++;
|
||||
rdp.cmd3 = ((uint32_t*)gfx.RDRAM)[a++];
|
||||
}
|
||||
gfx_instruction[ucode_zSort][cmd] ();
|
||||
gfx_instruction[ucode_zSort][cmd]();
|
||||
};
|
||||
rdp.LLE = 0;
|
||||
}
|
||||
|
|
|
@ -53,34 +53,34 @@ static void fb_uc2_moveword()
|
|||
{
|
||||
if (((rdp.cmd0 >> 16) & 0xFF) == 0x06) // segment
|
||||
{
|
||||
rdp.segment[((rdp.cmd0 & 0xFFFF) >> 2)&0xF] = rdp.cmd1;
|
||||
rdp.segment[((rdp.cmd0 & 0xFFFF) >> 2) & 0xF] = rdp.cmd1;
|
||||
}
|
||||
}
|
||||
|
||||
static void fb_bg_copy ()
|
||||
static void fb_bg_copy()
|
||||
{
|
||||
if (rdp.main_ci == 0)
|
||||
return;
|
||||
CI_STATUS status = rdp.frame_buffers[rdp.ci_count-1].status;
|
||||
if ( (status == ci_copy) )
|
||||
CI_STATUS status = rdp.frame_buffers[rdp.ci_count - 1].status;
|
||||
if ((status == ci_copy))
|
||||
return;
|
||||
|
||||
uint32_t addr = segoffset(rdp.cmd1) >> 1;
|
||||
uint8_t imageFmt = ((uint8_t *)gfx.RDRAM)[(((addr+11)<<1)+0)^3];
|
||||
uint8_t imageSiz = ((uint8_t *)gfx.RDRAM)[(((addr+11)<<1)+1)^3];
|
||||
uint32_t imagePtr = segoffset(((uint32_t*)gfx.RDRAM)[(addr+8)>>1]);
|
||||
FRDP ("fb_bg_copy. fmt: %d, size: %d, imagePtr %08lx, main_ci: %08lx, cur_ci: %08lx \n", imageFmt, imageSiz, imagePtr, rdp.main_ci, rdp.frame_buffers[rdp.ci_count-1].addr);
|
||||
uint8_t imageFmt = ((uint8_t *)gfx.RDRAM)[(((addr + 11) << 1) + 0) ^ 3];
|
||||
uint8_t imageSiz = ((uint8_t *)gfx.RDRAM)[(((addr + 11) << 1) + 1) ^ 3];
|
||||
uint32_t imagePtr = segoffset(((uint32_t*)gfx.RDRAM)[(addr + 8) >> 1]);
|
||||
FRDP("fb_bg_copy. fmt: %d, size: %d, imagePtr %08lx, main_ci: %08lx, cur_ci: %08lx \n", imageFmt, imageSiz, imagePtr, rdp.main_ci, rdp.frame_buffers[rdp.ci_count - 1].addr);
|
||||
|
||||
if (status == ci_main)
|
||||
{
|
||||
uint16_t frameW = ((uint16_t *)gfx.RDRAM)[(addr+3)^1] >> 2;
|
||||
uint16_t frameH = ((uint16_t *)gfx.RDRAM)[(addr+7)^1] >> 2;
|
||||
if ( (frameW == rdp.frame_buffers[rdp.ci_count-1].width) && (frameH == rdp.frame_buffers[rdp.ci_count-1].height) )
|
||||
uint16_t frameW = ((uint16_t *)gfx.RDRAM)[(addr + 3) ^ 1] >> 2;
|
||||
uint16_t frameH = ((uint16_t *)gfx.RDRAM)[(addr + 7) ^ 1] >> 2;
|
||||
if ((frameW == rdp.frame_buffers[rdp.ci_count - 1].width) && (frameH == rdp.frame_buffers[rdp.ci_count - 1].height))
|
||||
rdp.main_ci_bg = imagePtr;
|
||||
}
|
||||
else if (imagePtr >= rdp.main_ci && imagePtr < rdp.main_ci_end) //addr within main frame buffer
|
||||
{
|
||||
rdp.copy_ci_index = rdp.ci_count-1;
|
||||
rdp.copy_ci_index = rdp.ci_count - 1;
|
||||
rdp.frame_buffers[rdp.copy_ci_index].status = ci_copy;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_copy\n", rdp.copy_ci_index);
|
||||
|
||||
|
@ -95,16 +95,16 @@ static void fb_bg_copy ()
|
|||
rdp.motionblur = TRUE;
|
||||
}
|
||||
|
||||
FRDP ("Detect FB usage. texture addr is inside framebuffer: %08lx - %08lx \n", imagePtr, rdp.main_ci);
|
||||
FRDP("Detect FB usage. texture addr is inside framebuffer: %08lx - %08lx \n", imagePtr, rdp.main_ci);
|
||||
}
|
||||
else if (imagePtr == rdp.zimg)
|
||||
{
|
||||
if (status == ci_unknown)
|
||||
{
|
||||
rdp.frame_buffers[rdp.ci_count-1].status = ci_zcopy;
|
||||
rdp.tmpzimg = rdp.frame_buffers[rdp.ci_count-1].addr;
|
||||
rdp.frame_buffers[rdp.ci_count - 1].status = ci_zcopy;
|
||||
rdp.tmpzimg = rdp.frame_buffers[rdp.ci_count - 1].addr;
|
||||
if (!rdp.copy_zi_index)
|
||||
rdp.copy_zi_index = rdp.ci_count-1;
|
||||
rdp.copy_zi_index = rdp.ci_count - 1;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_zcopy\n", rdp.copy_ci_index);
|
||||
}
|
||||
}
|
||||
|
@ -117,10 +117,10 @@ static void fb_setscissor()
|
|||
{
|
||||
rdp.scissor_o.ul_x = (uint32_t)(((rdp.cmd0 & 0x00FFF000) >> 14));
|
||||
rdp.scissor_o.lr_x = (uint32_t)(((rdp.cmd1 & 0x00FFF000) >> 14));
|
||||
COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count-1];
|
||||
COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count - 1];
|
||||
if (rdp.scissor_o.lr_x - rdp.scissor_o.ul_x > (uint32_t)(cur_fb.width >> 1))
|
||||
{
|
||||
if (cur_fb.height == 0 || (cur_fb.width >= rdp.scissor_o.lr_x-1 && cur_fb.width <= rdp.scissor_o.lr_x+1))
|
||||
if (cur_fb.height == 0 || (cur_fb.width >= rdp.scissor_o.lr_x - 1 && cur_fb.width <= rdp.scissor_o.lr_x + 1))
|
||||
cur_fb.height = rdp.scissor_o.lr_y;
|
||||
}
|
||||
FRDP("fb_setscissor. lr_x = %d, lr_y = %d, fb_width = %d, fb_height = %d\n", rdp.scissor_o.lr_x, rdp.scissor_o.lr_y, cur_fb.width, cur_fb.height);
|
||||
|
@ -132,13 +132,13 @@ static void fb_uc2_movemem()
|
|||
if ((rdp.cmd0 & 0xFF) == 8)
|
||||
{
|
||||
uint32_t a = segoffset(rdp.cmd1) >> 1;
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a+0)^1] >> 2;
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a+4)^1] >> 2;
|
||||
COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count-1];
|
||||
if ( abs((int)(scale_x + trans_x - cur_fb.width)) < 3)
|
||||
short scale_x = ((short*)gfx.RDRAM)[(a + 0) ^ 1] >> 2;
|
||||
short trans_x = ((short*)gfx.RDRAM)[(a + 4) ^ 1] >> 2;
|
||||
COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count - 1];
|
||||
if (abs((int)(scale_x + trans_x - cur_fb.width)) < 3)
|
||||
{
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a+1)^1] >> 2;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a+5)^1] >> 2;
|
||||
short scale_y = ((short*)gfx.RDRAM)[(a + 1) ^ 1] >> 2;
|
||||
short trans_y = ((short*)gfx.RDRAM)[(a + 5) ^ 1] >> 2;
|
||||
uint32_t height = scale_y + trans_y;
|
||||
if (height < rdp.scissor_o.lr_y)
|
||||
cur_fb.height = height;
|
||||
|
@ -148,19 +148,19 @@ static void fb_uc2_movemem()
|
|||
|
||||
static void fb_rect()
|
||||
{
|
||||
if (rdp.frame_buffers[rdp.ci_count-1].width == 32)
|
||||
if (rdp.frame_buffers[rdp.ci_count - 1].width == 32)
|
||||
return;
|
||||
int ul_x = ((rdp.cmd1 & 0x00FFF000) >> 14);
|
||||
int lr_x = ((rdp.cmd0 & 0x00FFF000) >> 14);
|
||||
int width = lr_x-ul_x;
|
||||
int diff = abs((int)rdp.frame_buffers[rdp.ci_count-1].width - width);
|
||||
int width = lr_x - ul_x;
|
||||
int diff = abs((int)rdp.frame_buffers[rdp.ci_count - 1].width - width);
|
||||
if (diff < 4)
|
||||
{
|
||||
uint32_t lr_y = minval(rdp.scissor_o.lr_y, (rdp.cmd0 & 0xFFF) >> 2);
|
||||
if (rdp.frame_buffers[rdp.ci_count-1].height < lr_y)
|
||||
if (rdp.frame_buffers[rdp.ci_count - 1].height < lr_y)
|
||||
{
|
||||
FRDP("fb_rect. ul_x: %d, lr_x: %d, fb_height: %d -> %d\n", ul_x, lr_x, rdp.frame_buffers[rdp.ci_count-1].height, lr_y);
|
||||
rdp.frame_buffers[rdp.ci_count-1].height = lr_y;
|
||||
FRDP("fb_rect. ul_x: %d, lr_x: %d, fb_height: %d -> %d\n", ul_x, lr_x, rdp.frame_buffers[rdp.ci_count - 1].height, lr_y);
|
||||
rdp.frame_buffers[rdp.ci_count - 1].height = lr_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,21 +170,20 @@ static void fb_rdphalf_1()
|
|||
branch_dl = rdp.cmd1;
|
||||
}
|
||||
|
||||
|
||||
static void fb_settextureimage()
|
||||
{
|
||||
if (rdp.main_ci == 0)
|
||||
return;
|
||||
COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count-1];
|
||||
if ( cur_fb.status >= ci_copy )
|
||||
COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count - 1];
|
||||
if (cur_fb.status >= ci_copy)
|
||||
return;
|
||||
if (((rdp.cmd0 >> 19) & 0x03) >= 2) //check that texture is 16/32bit
|
||||
{
|
||||
int tex_format = ((rdp.cmd0 >> 21) & 0x07);
|
||||
uint32_t addr = segoffset(rdp.cmd1);
|
||||
if ( tex_format == 0 )
|
||||
if (tex_format == 0)
|
||||
{
|
||||
FRDP ("fb_settextureimage. fmt: %d, size: %d, imagePtr %08lx, main_ci: %08lx, cur_ci: %08lx \n", ((rdp.cmd0 >> 21) & 0x07), ((rdp.cmd0 >> 19) & 0x03), addr, rdp.main_ci, rdp.frame_buffers[rdp.ci_count-1].addr);
|
||||
FRDP("fb_settextureimage. fmt: %d, size: %d, imagePtr %08lx, main_ci: %08lx, cur_ci: %08lx \n", ((rdp.cmd0 >> 21) & 0x07), ((rdp.cmd0 >> 19) & 0x03), addr, rdp.main_ci, rdp.frame_buffers[rdp.ci_count - 1].addr);
|
||||
if (cur_fb.status == ci_main)
|
||||
{
|
||||
rdp.main_ci_last_tex_addr = addr;
|
||||
|
@ -198,17 +197,17 @@ static void fb_settextureimage()
|
|||
{
|
||||
if (cur_fb.status == ci_main)
|
||||
{
|
||||
rdp.copy_ci_index = rdp.ci_count-1;
|
||||
rdp.copy_ci_index = rdp.ci_count - 1;
|
||||
cur_fb.status = ci_copy_self;
|
||||
rdp.scale_x = rdp.scale_x_bak;
|
||||
rdp.scale_y = rdp.scale_y_bak;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_copy_self\n", rdp.ci_count-1);
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_copy_self\n", rdp.ci_count - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cur_fb.width == rdp.frame_buffers[rdp.main_ci_index].width)
|
||||
{
|
||||
rdp.copy_ci_index = rdp.ci_count-1;
|
||||
rdp.copy_ci_index = rdp.ci_count - 1;
|
||||
cur_fb.status = ci_copy;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_copy\n", rdp.copy_ci_index);
|
||||
if ((rdp.main_ci_last_tex_addr >= cur_fb.addr) &&
|
||||
|
@ -225,7 +224,7 @@ static void fb_settextureimage()
|
|||
}
|
||||
else if (!(settings.frame_buffer & fb_ignore_aux_copy) && cur_fb.width < rdp.frame_buffers[rdp.main_ci_index].width)
|
||||
{
|
||||
rdp.copy_ci_index = rdp.ci_count-1;
|
||||
rdp.copy_ci_index = rdp.ci_count - 1;
|
||||
cur_fb.status = ci_aux_copy;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_aux_copy\n", rdp.copy_ci_index);
|
||||
rdp.scale_x = 1.0f;
|
||||
|
@ -237,33 +236,33 @@ static void fb_settextureimage()
|
|||
FRDP("rdp.frame_buffers[%d].status = ci_aux\n", rdp.copy_ci_index);
|
||||
}
|
||||
}
|
||||
FRDP ("Detect FB usage. texture addr is inside framebuffer: %08lx - %08lx \n", addr, rdp.main_ci);
|
||||
FRDP("Detect FB usage. texture addr is inside framebuffer: %08lx - %08lx \n", addr, rdp.main_ci);
|
||||
}
|
||||
///*
|
||||
else if ((cur_fb.status != ci_main) && (addr >= rdp.zimg && addr < rdp.zimg_end))
|
||||
{
|
||||
cur_fb.status = ci_zcopy;
|
||||
if (!rdp.copy_zi_index)
|
||||
rdp.copy_zi_index = rdp.ci_count-1;
|
||||
FRDP("fb_settextureimage. rdp.frame_buffers[%d].status = ci_zcopy\n", rdp.ci_count-1);
|
||||
rdp.copy_zi_index = rdp.ci_count - 1;
|
||||
FRDP("fb_settextureimage. rdp.frame_buffers[%d].status = ci_zcopy\n", rdp.ci_count - 1);
|
||||
}
|
||||
//*/
|
||||
else if ((rdp.maincimg[0].width > 64) && (addr >= rdp.maincimg[0].addr) && (addr < (rdp.maincimg[0].addr + rdp.maincimg[0].width*rdp.maincimg[0].height*2)))
|
||||
else if ((rdp.maincimg[0].width > 64) && (addr >= rdp.maincimg[0].addr) && (addr < (rdp.maincimg[0].addr + rdp.maincimg[0].width*rdp.maincimg[0].height * 2)))
|
||||
{
|
||||
if (cur_fb.status != ci_main)
|
||||
{
|
||||
cur_fb.status = ci_old_copy;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_old_copy 1, addr:%08lx\n", rdp.ci_count-1, rdp.last_drawn_ci_addr);
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_old_copy 1, addr:%08lx\n", rdp.ci_count - 1, rdp.last_drawn_ci_addr);
|
||||
}
|
||||
rdp.read_previous_ci = TRUE;
|
||||
LRDP("read_previous_ci = TRUE\n");
|
||||
}
|
||||
else if ((addr >= rdp.last_drawn_ci_addr) && (addr < (rdp.last_drawn_ci_addr + rdp.maincimg[0].width*rdp.maincimg[0].height*2)))
|
||||
else if ((addr >= rdp.last_drawn_ci_addr) && (addr < (rdp.last_drawn_ci_addr + rdp.maincimg[0].width*rdp.maincimg[0].height * 2)))
|
||||
{
|
||||
if (cur_fb.status != ci_main)
|
||||
{
|
||||
cur_fb.status = ci_old_copy;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_old_copy 2, addr:%08lx\n", rdp.ci_count-1, rdp.last_drawn_ci_addr);
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_old_copy 2, addr:%08lx\n", rdp.ci_count - 1, rdp.last_drawn_ci_addr);
|
||||
}
|
||||
rdp.read_previous_ci = TRUE;
|
||||
LRDP("read_previous_ci = TRUE\n");
|
||||
|
@ -273,34 +272,34 @@ static void fb_settextureimage()
|
|||
{
|
||||
if ((addr >= rdp.main_ci) && (addr < rdp.main_ci_end)) //addr within main frame buffer
|
||||
{
|
||||
rdp.copy_ci_index = rdp.ci_count-1;
|
||||
rdp.black_ci_index = rdp.ci_count-1;
|
||||
rdp.copy_ci_index = rdp.ci_count - 1;
|
||||
rdp.black_ci_index = rdp.ci_count - 1;
|
||||
cur_fb.status = ci_copy_self;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_copy_self\n", rdp.ci_count-1);
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_copy_self\n", rdp.ci_count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cur_fb.status == ci_unknown)
|
||||
{
|
||||
cur_fb.status = ci_aux;
|
||||
FRDP("fb_settextureimage. rdp.frame_buffers[%d].status = ci_aux\n", rdp.ci_count-1);
|
||||
FRDP("fb_settextureimage. rdp.frame_buffers[%d].status = ci_aux\n", rdp.ci_count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void fb_loadtxtr()
|
||||
{
|
||||
if (rdp.frame_buffers[rdp.ci_count-1].status == ci_unknown)
|
||||
if (rdp.frame_buffers[rdp.ci_count - 1].status == ci_unknown)
|
||||
{
|
||||
rdp.frame_buffers[rdp.ci_count-1].status = ci_aux;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_aux\n", rdp.ci_count-1);
|
||||
rdp.frame_buffers[rdp.ci_count - 1].status = ci_aux;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_aux\n", rdp.ci_count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void fb_setdepthimage()
|
||||
{
|
||||
rdp.zimg = segoffset(rdp.cmd1) & BMASK;
|
||||
rdp.zimg_end = rdp.zimg + rdp.ci_width*rdp.ci_height*2;
|
||||
FRDP ("fb_setdepthimage. addr %08lx - %08lx\n", rdp.zimg, rdp.zimg_end);
|
||||
rdp.zimg_end = rdp.zimg + rdp.ci_width*rdp.ci_height * 2;
|
||||
FRDP("fb_setdepthimage. addr %08lx - %08lx\n", rdp.zimg, rdp.zimg_end);
|
||||
if (rdp.zimg == rdp.main_ci) //strange, but can happen
|
||||
{
|
||||
rdp.frame_buffers[rdp.main_ci_index].status = ci_unknown;
|
||||
|
@ -313,7 +312,7 @@ static void fb_setdepthimage()
|
|||
FRDP("rdp.frame_buffers[%d].status = ci_main\n", rdp.main_ci_index);
|
||||
rdp.main_ci = rdp.frame_buffers[rdp.main_ci_index].addr;
|
||||
rdp.main_ci_end = rdp.main_ci + (rdp.frame_buffers[rdp.main_ci_index].width * rdp.frame_buffers[rdp.main_ci_index].height * rdp.frame_buffers[rdp.main_ci_index].size);
|
||||
for (int i = rdp.main_ci_index+1; i < rdp.ci_count; i++)
|
||||
for (int i = rdp.main_ci_index + 1; i < rdp.ci_count; i++)
|
||||
{
|
||||
COLOR_IMAGE & fb = rdp.frame_buffers[i];
|
||||
if (fb.addr == rdp.main_ci)
|
||||
|
@ -345,9 +344,9 @@ static void fb_setcolorimage()
|
|||
rdp.cimg = segoffset(rdp.cmd1) & BMASK;
|
||||
COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count];
|
||||
cur_fb.width = (rdp.cmd0 & 0xFFF) + 1;
|
||||
if (cur_fb.width == 32 )
|
||||
if (cur_fb.width == 32)
|
||||
cur_fb.height = 32;
|
||||
else if (cur_fb.width == 16 )
|
||||
else if (cur_fb.width == 16)
|
||||
cur_fb.height = 16;
|
||||
else if (rdp.ci_count > 0)
|
||||
cur_fb.height = rdp.scissor_o.lr_y;
|
||||
|
@ -362,18 +361,18 @@ static void fb_setcolorimage()
|
|||
if (rdp.frame_buffers[0].addr == rdp.cimg)
|
||||
rdp.frame_buffers[0].height = rdp.scissor_o.lr_y;
|
||||
*/
|
||||
FRDP ("fb_setcolorimage. width: %d, height: %d, fmt: %d, size: %d, addr %08lx\n", cur_fb.width, cur_fb.height, cur_fb.format, cur_fb.size, cur_fb.addr);
|
||||
FRDP("fb_setcolorimage. width: %d, height: %d, fmt: %d, size: %d, addr %08lx\n", cur_fb.width, cur_fb.height, cur_fb.format, cur_fb.size, cur_fb.addr);
|
||||
if (rdp.cimg == rdp.zimg)
|
||||
{
|
||||
cur_fb.status = ci_zimg;
|
||||
rdp.zimg_end = rdp.zimg + cur_fb.width*rdp.scissor_o.lr_y*2;
|
||||
rdp.zimg_end = rdp.zimg + cur_fb.width*rdp.scissor_o.lr_y * 2;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_zimg\n", rdp.ci_count);
|
||||
}
|
||||
else if (rdp.cimg == rdp.tmpzimg)
|
||||
{
|
||||
cur_fb.status = ci_zcopy;
|
||||
if (!rdp.copy_zi_index)
|
||||
rdp.copy_zi_index = rdp.ci_count-1;
|
||||
rdp.copy_zi_index = rdp.ci_count - 1;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_zcopy\n", rdp.ci_count);
|
||||
}
|
||||
else if (rdp.main_ci != 0)
|
||||
|
@ -405,19 +404,18 @@ static void fb_setcolorimage()
|
|||
{
|
||||
cur_fb.status = ci_unknown;
|
||||
}
|
||||
|
||||
}
|
||||
if (rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count-1].status == ci_unknown) //status of previous fb was not changed - it is useless
|
||||
if (rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_unknown) //status of previous fb was not changed - it is useless
|
||||
{
|
||||
if (fb_hwfbe_enabled && !(settings.frame_buffer & fb_useless_is_useless))
|
||||
{
|
||||
rdp.frame_buffers[rdp.ci_count-1].status = ci_aux;
|
||||
rdp.frame_buffers[rdp.ci_count-1].changed = 0;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_aux\n", rdp.ci_count-1);
|
||||
rdp.frame_buffers[rdp.ci_count - 1].status = ci_aux;
|
||||
rdp.frame_buffers[rdp.ci_count - 1].changed = 0;
|
||||
FRDP("rdp.frame_buffers[%d].status = ci_aux\n", rdp.ci_count - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdp.frame_buffers[rdp.ci_count-1].status = ci_useless;
|
||||
rdp.frame_buffers[rdp.ci_count - 1].status = ci_useless;
|
||||
/*
|
||||
uint32_t addr = rdp.frame_buffers[rdp.ci_count-1].addr;
|
||||
for (int i = 0; i < rdp.ci_count - 1; i++)
|
||||
|
@ -429,7 +427,7 @@ static void fb_setcolorimage()
|
|||
}
|
||||
}
|
||||
//*/
|
||||
FRDP("rdp.frame_buffers[%d].status = %s\n", rdp.ci_count-1, CIStatus[rdp.frame_buffers[rdp.ci_count-1].status]);
|
||||
FRDP("rdp.frame_buffers[%d].status = %s\n", rdp.ci_count - 1, CIStatus[rdp.frame_buffers[rdp.ci_count - 1].status]);
|
||||
}
|
||||
}
|
||||
if (cur_fb.status == ci_main)
|
||||
|
|
Loading…
Reference in New Issue