mirror of https://github.com/PCSX2/pcsx2.git
GregMiscellaneous: zzogl-pg:
* Use addvertex in register (stole from the new register code). * Use primNext at the end of KickVertex function allow to use current index in draw primitive. * Create a primPrev git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@3971 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
6eedbaf346
commit
9f2e92f31b
|
@ -515,6 +515,12 @@ typedef struct
|
||||||
return ((primIndex + inc) % ARRAY_SIZE(gsvertex));
|
return ((primIndex + inc) % ARRAY_SIZE(gsvertex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int primPrev(int dec = 1)
|
||||||
|
{
|
||||||
|
// Note: assert( dec <= ARRAY_SIZE(gsvertex) );
|
||||||
|
return ((primIndex + (ARRAY_SIZE(gsvertex) - dec)) % ARRAY_SIZE(gsvertex));
|
||||||
|
}
|
||||||
|
|
||||||
void setRGBA(u32 r, u32 g, u32 b, u32 a)
|
void setRGBA(u32 r, u32 g, u32 b, u32 a)
|
||||||
{
|
{
|
||||||
rgba = (r & 0xff) |
|
rgba = (r & 0xff) |
|
||||||
|
@ -523,23 +529,21 @@ typedef struct
|
||||||
((a & 0xff) << 24);
|
((a & 0xff) << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_vertex(u16 x, u16 y, u32 z, u16 f)
|
inline void add_vertex(u16 x, u16 y, u32 z, u16 f)
|
||||||
{
|
{
|
||||||
vertexregs.x = x;
|
vertexregs.x = x;
|
||||||
vertexregs.y = y;
|
vertexregs.y = y;
|
||||||
vertexregs.z = z;
|
vertexregs.z = z;
|
||||||
vertexregs.f = f;
|
vertexregs.f = f;
|
||||||
gsvertex[primIndex] = vertexregs;
|
gsvertex[primIndex] = vertexregs;
|
||||||
primIndex = primNext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_vertex(u16 x, u16 y, u32 z)
|
inline void add_vertex(u16 x, u16 y, u32 z)
|
||||||
{
|
{
|
||||||
vertexregs.x = x;
|
vertexregs.x = x;
|
||||||
vertexregs.y = y;
|
vertexregs.y = y;
|
||||||
vertexregs.z = z;
|
vertexregs.z = z;
|
||||||
gsvertex[primIndex] = vertexregs;
|
gsvertex[primIndex] = vertexregs;
|
||||||
primIndex = primNext();
|
|
||||||
}
|
}
|
||||||
} GSinternal;
|
} GSinternal;
|
||||||
|
|
||||||
|
|
|
@ -87,12 +87,8 @@ void __gifCall GIFPackedRegHandlerUV(const u32* data)
|
||||||
void __gifCall GIFPackedRegHandlerXYZF2(const u32* data)
|
void __gifCall GIFPackedRegHandlerXYZF2(const u32* data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
gs.vertexregs.x = (data[0] >> 0) & 0xffff;
|
GIFPackedXYZF2* r = (GIFPackedXYZF2*)(data);
|
||||||
gs.vertexregs.y = (data[1] >> 0) & 0xffff;
|
gs.add_vertex(r->X, r->Y,r->Z, r->F);
|
||||||
gs.vertexregs.z = (data[2] >> 4) & 0xffffff;
|
|
||||||
gs.vertexregs.f = (data[3] >> 4) & 0xff;
|
|
||||||
gs.gsvertex[gs.primIndex] = gs.vertexregs;
|
|
||||||
gs.primIndex = gs.primNext();
|
|
||||||
|
|
||||||
ZZKick->KickVertex(!!(data[3]>>31));
|
ZZKick->KickVertex(!!(data[3]>>31));
|
||||||
}
|
}
|
||||||
|
@ -100,11 +96,8 @@ void __gifCall GIFPackedRegHandlerXYZF2(const u32* data)
|
||||||
void __gifCall GIFPackedRegHandlerXYZ2(const u32* data)
|
void __gifCall GIFPackedRegHandlerXYZ2(const u32* data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
gs.vertexregs.x = (data[0] >> 0) & 0xffff;
|
GIFPackedXYZ2* r = (GIFPackedXYZ2*)(data);
|
||||||
gs.vertexregs.y = (data[1] >> 0) & 0xffff;
|
gs.add_vertex(r->X, r->Y,r->Z);
|
||||||
gs.vertexregs.z = data[2];
|
|
||||||
gs.gsvertex[gs.primIndex] = gs.vertexregs;
|
|
||||||
gs.primIndex = gs.primNext();
|
|
||||||
|
|
||||||
ZZKick->KickVertex(!!(data[3]>>31));
|
ZZKick->KickVertex(!!(data[3]>>31));
|
||||||
}
|
}
|
||||||
|
@ -310,7 +303,6 @@ void __gifCall GIFRegHandlerPRIM(const u32 *data)
|
||||||
//ZZLog::Warn_Log("Warning: unknown bits in prim %8.8lx_%8.8lx", data[1], data[0]);
|
//ZZLog::Warn_Log("Warning: unknown bits in prim %8.8lx_%8.8lx", data[1], data[0]);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
gs.nTriFanVert = gs.primIndex;
|
|
||||||
|
|
||||||
gs.primC = 0;
|
gs.primC = 0;
|
||||||
prim->prim = (data[0]) & 0x7;
|
prim->prim = (data[0]) & 0x7;
|
||||||
|
@ -318,6 +310,8 @@ void __gifCall GIFRegHandlerPRIM(const u32 *data)
|
||||||
gs._prim[1].prim = (data[0]) & 0x7;
|
gs._prim[1].prim = (data[0]) & 0x7;
|
||||||
gs._prim[1]._val = (data[0] >> 3) & 0xff;
|
gs._prim[1]._val = (data[0] >> 3) & 0xff;
|
||||||
|
|
||||||
|
gs.nTriFanVert = gs.primIndex;
|
||||||
|
|
||||||
Prim();
|
Prim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,12 +341,8 @@ void __gifCall GIFRegHandlerUV(const u32* data)
|
||||||
void __gifCall GIFRegHandlerXYZF2(const u32* data)
|
void __gifCall GIFRegHandlerXYZF2(const u32* data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
gs.vertexregs.x = (data[0]) & 0xffff;
|
GIFRegXYZF* r = (GIFRegXYZF*)(data);
|
||||||
gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
|
gs.add_vertex(r->X, r->Y,r->Z, r->F);
|
||||||
gs.vertexregs.z = data[1] & 0xffffff;
|
|
||||||
gs.vertexregs.f = data[1] >> 24;
|
|
||||||
gs.gsvertex[gs.primIndex] = gs.vertexregs;
|
|
||||||
gs.primIndex = gs.primNext();
|
|
||||||
|
|
||||||
ZZKick->KickVertex(false);
|
ZZKick->KickVertex(false);
|
||||||
}
|
}
|
||||||
|
@ -360,11 +350,8 @@ void __gifCall GIFRegHandlerXYZF2(const u32* data)
|
||||||
void __gifCall GIFRegHandlerXYZ2(const u32* data)
|
void __gifCall GIFRegHandlerXYZ2(const u32* data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
gs.vertexregs.x = (data[0]) & 0xffff;
|
GIFRegXYZ* r = (GIFRegXYZ*)(data);
|
||||||
gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
|
gs.add_vertex(r->X, r->Y,r->Z);
|
||||||
gs.vertexregs.z = data[1];
|
|
||||||
gs.gsvertex[gs.primIndex] = gs.vertexregs;
|
|
||||||
gs.primIndex = gs.primNext();
|
|
||||||
|
|
||||||
ZZKick->KickVertex(false);
|
ZZKick->KickVertex(false);
|
||||||
}
|
}
|
||||||
|
@ -407,12 +394,8 @@ void __gifCall GIFRegHandlerFOG(const u32* data)
|
||||||
void __gifCall GIFRegHandlerXYZF3(const u32* data)
|
void __gifCall GIFRegHandlerXYZF3(const u32* data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
gs.vertexregs.x = (data[0]) & 0xffff;
|
GIFRegXYZF* r = (GIFRegXYZF*)(data);
|
||||||
gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
|
gs.add_vertex(r->X, r->Y,r->Z, r->F);
|
||||||
gs.vertexregs.z = data[1] & 0xffffff;
|
|
||||||
gs.vertexregs.f = data[1] >> 24;
|
|
||||||
gs.gsvertex[gs.primIndex] = gs.vertexregs;
|
|
||||||
gs.primIndex = gs.primNext();
|
|
||||||
|
|
||||||
ZZKick->KickVertex(true);
|
ZZKick->KickVertex(true);
|
||||||
}
|
}
|
||||||
|
@ -420,11 +403,8 @@ void __gifCall GIFRegHandlerXYZF3(const u32* data)
|
||||||
void __gifCall GIFRegHandlerXYZ3(const u32* data)
|
void __gifCall GIFRegHandlerXYZ3(const u32* data)
|
||||||
{
|
{
|
||||||
FUNCLOG
|
FUNCLOG
|
||||||
gs.vertexregs.x = (data[0]) & 0xffff;
|
GIFRegXYZ* r = (GIFRegXYZ*)(data);
|
||||||
gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
|
gs.add_vertex(r->X, r->Y,r->Z);
|
||||||
gs.vertexregs.z = data[1];
|
|
||||||
gs.gsvertex[gs.primIndex] = gs.vertexregs;
|
|
||||||
gs.primIndex = gs.primNext();
|
|
||||||
|
|
||||||
ZZKick->KickVertex(true);
|
ZZKick->KickVertex(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,27 +60,30 @@ void __forceinline Kick::KickVertex(bool adc)
|
||||||
|
|
||||||
gs.primC -= g_primsub[prim->prim];
|
gs.primC -= g_primsub[prim->prim];
|
||||||
|
|
||||||
|
gs.primIndex = gs.primNext();
|
||||||
if (prim->prim == 5)
|
if (prim->prim == 5)
|
||||||
{
|
{
|
||||||
/* tri fans need special processing */
|
/* tri fans need special processing */
|
||||||
if (gs.nTriFanVert == gs.primIndex) gs.primIndex = gs.primNext();
|
if (gs.nTriFanVert == gs.primIndex) gs.primIndex = gs.primNext();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
gs.primIndex = gs.primNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool DO_Z_FOG>
|
template<bool DO_Z_FOG>
|
||||||
void Kick::Set_Vertex(VertexGPU *p, int i)
|
void Kick::Set_Vertex(VertexGPU *p, Vertex & gsvertex)
|
||||||
{
|
{
|
||||||
VB& curvb = vb[prim->ctxt];
|
VB& curvb = vb[prim->ctxt];
|
||||||
|
|
||||||
p->move_x(gs.gsvertex[i], curvb.offset.x);
|
p->move_x(gsvertex, curvb.offset.x);
|
||||||
p->move_y(gs.gsvertex[i], curvb.offset.y);
|
p->move_y(gsvertex, curvb.offset.y);
|
||||||
if(DO_Z_FOG) {
|
if(DO_Z_FOG) {
|
||||||
p->move_z(gs.gsvertex[i], curvb.zprimmask);
|
p->move_z(gsvertex, curvb.zprimmask);
|
||||||
p->move_fog(gs.gsvertex[i]);
|
p->move_fog(gsvertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->rgba = prim->iip ? gs.gsvertex[i].rgba : gs.rgba;
|
p->rgba = prim->iip ? gsvertex.rgba : gs.rgba;
|
||||||
|
|
||||||
if (conf.settings().texa)
|
if (conf.settings().texa)
|
||||||
{
|
{
|
||||||
|
@ -92,15 +95,15 @@ void Kick::Set_Vertex(VertexGPU *p, int i)
|
||||||
{
|
{
|
||||||
if (prim->fst)
|
if (prim->fst)
|
||||||
{
|
{
|
||||||
p->s = (float)gs.gsvertex[i].u * fiTexWidth[prim->ctxt];
|
p->s = (float)gsvertex.u * fiTexWidth[prim->ctxt];
|
||||||
p->t = (float)gs.gsvertex[i].v * fiTexHeight[prim->ctxt];
|
p->t = (float)gsvertex.v * fiTexHeight[prim->ctxt];
|
||||||
p->q = 1;
|
p->q = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p->s = gs.gsvertex[i].s;
|
p->s = gsvertex.s;
|
||||||
p->t = gs.gsvertex[i].t;
|
p->t = gsvertex.t;
|
||||||
p->q = gs.gsvertex[i].q;
|
p->q = gsvertex.q;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,13 +136,13 @@ void Kick::DrawPrim(u32 prim_type)
|
||||||
|
|
||||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||||
|
|
||||||
u32 next;
|
u32 prev;
|
||||||
u32 last;
|
u32 last;
|
||||||
switch(prim_type) {
|
switch(prim_type) {
|
||||||
case PRIM_POINT:
|
case PRIM_POINT:
|
||||||
assert(gs.primC >= 1);
|
assert(gs.primC >= 1);
|
||||||
|
|
||||||
Set_Vertex<true>(&p[0], gs.primNext(2));
|
Set_Vertex<true>(&p[0], gs.gsvertex[gs.primIndex]);
|
||||||
curvb.nCount ++;
|
curvb.nCount ++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -147,8 +150,8 @@ void Kick::DrawPrim(u32 prim_type)
|
||||||
case PRIM_LINE_STRIP:
|
case PRIM_LINE_STRIP:
|
||||||
assert(gs.primC >= 2);
|
assert(gs.primC >= 2);
|
||||||
|
|
||||||
Set_Vertex<true>(&p[0], gs.primNext());
|
Set_Vertex<true>(&p[0], gs.gsvertex[gs.primPrev()]);
|
||||||
Set_Vertex<true>(&p[1], gs.primNext(2));
|
Set_Vertex<true>(&p[1], gs.gsvertex[gs.primIndex]);
|
||||||
curvb.nCount += 2;
|
curvb.nCount += 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -157,29 +160,29 @@ void Kick::DrawPrim(u32 prim_type)
|
||||||
case PRIM_TRIANGLE_FAN:
|
case PRIM_TRIANGLE_FAN:
|
||||||
assert(gs.primC >= 3);
|
assert(gs.primC >= 3);
|
||||||
|
|
||||||
Set_Vertex<true>(&p[0], 0);
|
Set_Vertex<true>(&p[0], gs.gsvertex[0]);
|
||||||
Set_Vertex<true>(&p[1], 1);
|
Set_Vertex<true>(&p[1], gs.gsvertex[1]);
|
||||||
Set_Vertex<true>(&p[2], 2);
|
Set_Vertex<true>(&p[2], gs.gsvertex[2]);
|
||||||
curvb.nCount += 3;
|
curvb.nCount += 3;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRIM_SPRITE:
|
case PRIM_SPRITE:
|
||||||
assert(gs.primC >= 2);
|
assert(gs.primC >= 2);
|
||||||
|
|
||||||
next = gs.primNext();
|
prev = gs.primPrev();
|
||||||
last = gs.primNext(2);
|
last = gs.primIndex;
|
||||||
|
|
||||||
// sprite is too small and AA shows lines (tek4, Mana Khemia)
|
// sprite is too small and AA shows lines (tek4, Mana Khemia)
|
||||||
gs.gsvertex[last].x += (4 * AA.x);
|
gs.gsvertex[last].x += (4 * AA.x);
|
||||||
gs.gsvertex[last].y += (4 * AA.y);
|
gs.gsvertex[last].y += (4 * AA.y);
|
||||||
|
|
||||||
// might be bad sprite (KH dialog text)
|
// might be bad sprite (KH dialog text)
|
||||||
//if( gs.gsvertex[next].x == gs.gsvertex[last].x || gs.gsvertex[next].y == gs.gsvertex[last].y )
|
//if( gs.gsvertex[prev].x == gs.gsvertex[last].x || gs.gsvertex[prev].y == gs.gsvertex[last].y )
|
||||||
//return;
|
//return;
|
||||||
|
|
||||||
// process sprite as 2 triangles. The common diagonal is 0,1 and 3,4
|
// process sprite as 2 triangles. The common diagonal is 0,1 and 3,4
|
||||||
Set_Vertex<false>(&p[0], next);
|
Set_Vertex<false>(&p[0], gs.gsvertex[prev]);
|
||||||
Set_Vertex<true>(&p[1], last);
|
Set_Vertex<true>(&p[1], gs.gsvertex[last]);
|
||||||
|
|
||||||
// Only fog and Z of last vertex is valid
|
// Only fog and Z of last vertex is valid
|
||||||
p[0].z = p[1].z;
|
p[0].z = p[1].z;
|
||||||
|
|
|
@ -39,7 +39,8 @@ enum PRIM_TYPE {
|
||||||
class Kick
|
class Kick
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
template<bool DO_Z_FOG> void Set_Vertex(VertexGPU *p, int i);
|
// template<bool DO_Z_FOG> void Set_Vertex(VertexGPU *p, int i);
|
||||||
|
template<bool DO_Z_FOG> void Set_Vertex(VertexGPU *p, Vertex &gsvertex);
|
||||||
void Output_Vertex(VertexGPU vert, u32 id);
|
void Output_Vertex(VertexGPU vert, u32 id);
|
||||||
public:
|
public:
|
||||||
Kick() { }
|
Kick() { }
|
||||||
|
|
Loading…
Reference in New Issue