LilyPad: fix0red the save state reload crash (memset overflow randomly null'ed the global dm variable and other things).

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@799 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gabest11 2009-03-16 22:17:50 +00:00
parent 7c00edfc07
commit d2ef4099fc
4 changed files with 64 additions and 60 deletions

View File

@ -373,22 +373,22 @@ void GSDrawScanlineCodeGenerator::Init(int params)
if(m_sel.fb)
{
if(m_sel.edge)
if(m_sel.edge || m_sel.tfx != TFX_NONE)
{
movaps(xmm4, xmmword[ebx + 32]); // v.t
}
cvttps2dq(xmm4, xmm4);
if(m_sel.edge)
{
pshufhw(xmm3, xmm4, _MM_SHUFFLE(2, 2, 2, 2));
pshufd(xmm3, xmm3, _MM_SHUFFLE(3, 3, 3, 3));
psrlw(xmm3, 9);
pshufhw(xmm4, xmm4, _MM_SHUFFLE(2, 2, 2, 2));
pshufd(xmm4, xmm4, _MM_SHUFFLE(3, 3, 3, 3));
movdqa(xmmword[&m_env.temp.cov], xmm4);
movdqa(xmmword[&m_env.temp.cov], xmm3);
}
if(m_sel.tfx != TFX_NONE)
{
movaps(xmm4, xmmword[ebx + 32]); // v.t
if(m_sel.fst)
{
// GSVector4i vti(vt);

View File

@ -478,6 +478,8 @@ void GSRasterizer::DrawTriangleSection(int top, int bottom, GSVertexSW& l, const
GSVertexSW scan = l + dscan * (lrmax - l.p).xxxx();
ASSERT(m_dsf.ssl);
m_dsf.ssl(right, left, top, scan);
}
}
@ -519,6 +521,8 @@ void GSRasterizer::DrawTriangleSection(int top, int bottom, GSVertexSW& l, const
GSVertexSW scan = l + dscan * (lrmax - l.p).xxxx();
ASSERT(m_dsf.ssl);
m_dsf.ssl(right, left, top, scan);
}
}
@ -667,28 +671,29 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
edge += dedge * (tbmax.wwww() - edge.p.yyyy());
}
GSVector4i p = GSVector4i(edge.p.upl(dedge.p) * 0x10000);
int x = p.extract32<0>();
int dx = p.extract32<1>();
if(side)
{
while(1)
{
do
{
if((top % m_threads) == m_id)
int xi = x >> 16;
int xf = x & 0xffff;
if(scissor.x <= xi && xi < scissor.z && (xi % m_threads) == m_id)
{
GSVector4 p = edge.p.ceil();
if(((fscissor.xxxx() < p) & (p <= fscissor.zzzz())).mask() & 1)
{
GSVector4 coverage = (p - edge.p).xxxx();
edge.t = edge.t.xyxy(edge.t.uph(coverage * 0x80)); // coverage => t.w
int x = GSVector4i(p).extract32<0>() - 1;
m_stats.pixels++;
m_dsf.ssle(x + 1, x, top, edge);
}
edge.t.u32[3] = (0x10000 - xf) & 0xffff;
m_dsf.ssle(xi + 1, xi, top, edge);
edge.t.u32[3] = 0;
}
}
while(0);
@ -696,6 +701,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
if(++top >= bottom) break;
edge += dedge;
x += dx;
}
}
else
@ -704,22 +710,18 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
{
do
{
if((top % m_threads) == m_id)
int xi = (x >> 16) + 1;
int xf = x & 0xffff;
if(scissor.x <= xi && xi < scissor.z && (xi % m_threads) == m_id)
{
GSVector4 p = edge.p.floor();
if(((fscissor.xxxx() <= p) & (p < fscissor.zzzz())).mask() & 1)
{
GSVector4 coverage = (edge.p - p).xxxx();
edge.t = edge.t.xyxy(edge.t.uph(coverage * 0x80)); // coverage => t.w
int x = GSVector4i(p).extract32<0>() + 1;
m_stats.pixels++;
m_dsf.ssle(x + 1, x, top, edge);
}
edge.t.u32[3] = xf;
m_dsf.ssle(xi + 1, xi, top, edge);
edge.t.u32[3] = 0;
}
}
while(0);
@ -727,6 +729,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
if(++top >= bottom) break;
edge += dedge;
x += dx;
}
}
}
@ -766,28 +769,29 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
edge += dedge * (lrmax.yyyy() - edge.p.xxxx());
}
GSVector4i p = GSVector4i(edge.p.upl(dedge.p) * 0x10000);
int y = p.extract32<2>();
int dy = p.extract32<3>();
if(side)
{
while(1)
{
do
{
GSVector4 p = edge.p.ceil();
int yi = y >> 16;
int yf = y & 0xffff;
if(((fscissor.yyyy() < p) & (p <= fscissor.wwww())).mask() & 2)
if(scissor.y <= yi && yi < scissor.w && (yi % m_threads) == m_id)
{
int y = GSVector4i(p).extract32<1>() - 1;
if((y % m_threads) == m_id)
{
GSVector4 coverage = (p - edge.p).yyyy();
edge.t = edge.t.xyxy(edge.t.uph(coverage * 0x80)); // coverage => t.w
m_stats.pixels++;
m_dsf.ssle(left + 1, left, y, edge);
}
edge.t.u32[3] = (0x10000 - yf) & 0xffff;
m_dsf.ssle(left + 1, left, yi, edge);
edge.t.u32[3] = 0;
}
}
while(0);
@ -795,6 +799,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
if(++left >= right) break;
edge += dedge;
y += dy;
}
}
else
@ -803,22 +808,18 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
{
do
{
GSVector4 p = edge.p.floor();
int yi = (y >> 16) + 1;
int yf = y & 0xffff;
if(((fscissor.yyyy() <= p) & (p < fscissor.wwww())).mask() & 2)
if(scissor.y <= yi && yi < scissor.w && (yi % m_threads) == m_id)
{
int y = GSVector4i(p).extract32<1>() + 1;
if((y % m_threads) == m_id)
{
GSVector4 coverage = (edge.p - p).yyyy();
edge.t = edge.t.xyxy(edge.t.uph(coverage * 0x80)); // coverage => t.w
m_stats.pixels++;
m_dsf.ssle(left + 1, left, y, edge);
}
edge.t.u32[3] = yf;
m_dsf.ssle(left + 1, left, yi, edge);
edge.t.u32[3] = 0;
}
}
while(0);
@ -826,6 +827,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
if(++left >= right) break;
edge += dedge;
y += dy;
}
}
}

View File

@ -107,6 +107,8 @@ GSState::GSState(BYTE* base, bool mt, void (*irq)(), int nloophack)
BUSDIR = (GSRegBUSDIR*)(base + GS_BUSDIR);
SIGLBLID = (GSRegSIGLBLID*)(base + GS_SIGLBLID);
memset(PMODE, 0, 0x1100);
PRIM = &m_env.PRIM;
// CSR->rREV = 0x20;
m_env.PRMODECONT.AC = 1;

View File

@ -568,7 +568,7 @@ inline void ResetVibrate(int port, int slot) {
}
void ResetPad(int port, int slot) {
memset(&pads[port][slot], 0, sizeof(pads[0]));
memset(&pads[port][slot], 0, sizeof(pads[0][0]));
pads[port][slot].mode = MODE_DIGITAL;
pads[port][slot].umask[0] = pads[port][slot].umask[1] = 0xFF;
ResetVibrate(port, slot);