mirror of
https://github.com/libretro/pcsx2.git
synced 2024-11-28 20:00:44 +00:00
GregMiscellaneous: zzogl-pg: Create ZZKick.cpp & ZZKick.h, and move appropriate code there.
git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@3929 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
9bde4de02a
commit
d114ae7e93
@ -72,6 +72,7 @@ set(zzoglSources
|
||||
ZZoglShoots.cpp
|
||||
ZZoglVB.cpp
|
||||
ZZKeyboard.cpp
|
||||
ZZKick.cpp
|
||||
ZZLog.cpp)
|
||||
|
||||
# zzogl headers
|
||||
@ -94,6 +95,7 @@ set(zzoglHeaders
|
||||
zerogs.h
|
||||
zpipe.h
|
||||
ZZoglCRTC.h
|
||||
ZZKick.h
|
||||
ZZoglMath.h
|
||||
ZZoglShaders.h
|
||||
ZZoglShoots.h
|
||||
|
@ -144,6 +144,8 @@
|
||||
</Unit>
|
||||
<Unit filename="../../ZZGl.h" />
|
||||
<Unit filename="../../ZZKeyboard.cpp" />
|
||||
<Unit filename="../../ZZKick.cpp" />
|
||||
<Unit filename="../../ZZKick.h" />
|
||||
<Unit filename="../../ZZLog.cpp" />
|
||||
<Unit filename="../../ZZLog.h" />
|
||||
<Unit filename="../../ZZoglCRTC.cpp" />
|
||||
|
@ -28,9 +28,7 @@
|
||||
#ifdef USE_OLD_REGS
|
||||
#include "Regs.h"
|
||||
#else
|
||||
|
||||
const u32 g_primmult[8] = { 1, 2, 2, 3, 3, 3, 2, 0xff };
|
||||
const u32 g_primsub[8] = { 1, 2, 1, 3, 1, 1, 2, 0 };
|
||||
#include "ZZKick.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4244)
|
||||
@ -46,28 +44,6 @@ u32 s_uClampData[2] = {0, };
|
||||
|
||||
//u32 results[65535] = {0, };
|
||||
|
||||
// return true if triangle SHOULD be painted.
|
||||
// My brain hurts. --arcum42
|
||||
|
||||
// return true if triangle SHOULD be painted.
|
||||
inline bool NoHighlights(int i)
|
||||
{
|
||||
// This is hack-code, I still in search of correct reason, why some triangles should not be drawn.
|
||||
|
||||
int dummy = 0;
|
||||
|
||||
u32 resultA = prim->iip + (2 * (prim->tme)) + (4 * (prim->fge)) + (8 * (prim->abe)) + (16 * (prim->aa1)) + (32 * (prim->fst)) + (64 * (prim->ctxt)) + (128 * (prim->fix));
|
||||
|
||||
const pixTest curtest = vb[i].test;
|
||||
|
||||
u32 result = curtest.ate + ((curtest.atst) << 1) +((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst)<< 9);
|
||||
|
||||
if ((resultA == 0x310a) && (result == 0x0)) return false; // Radiata Stories
|
||||
|
||||
//Old code
|
||||
return (!(conf.settings().xenosaga_spec) || !vb[i].zbuf.zmsk || prim->iip) ;
|
||||
}
|
||||
|
||||
void __gifCall GIFPackedRegHandlerNull(const u32* data)
|
||||
{
|
||||
FUNCLOG
|
||||
@ -127,24 +103,6 @@ void __gifCall GIFPackedRegHandlerUV(const u32* data)
|
||||
ZZLog::Greg_Log("Packed UV: 0x%x, 0x%x", r->U, r->V);
|
||||
}
|
||||
|
||||
void __gifCall KickVertex(bool adc)
|
||||
{
|
||||
FUNCLOG
|
||||
if (++gs.primC >= (int)g_primmult[prim->prim])
|
||||
{
|
||||
if (!adc && NoHighlights(prim->ctxt)) (*drawfn[prim->prim])();
|
||||
|
||||
gs.primC -= g_primsub[prim->prim];
|
||||
|
||||
if (adc && prim->prim == 5)
|
||||
{
|
||||
/* tri fans need special processing */
|
||||
if (gs.nTriFanVert == gs.primIndex)
|
||||
gs.primIndex = gs.primNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __gifCall GIFPackedRegHandlerXYZF2(const u32* data)
|
||||
{
|
||||
FUNCLOG
|
||||
|
@ -24,12 +24,10 @@
|
||||
|
||||
#include "zerogs.h"
|
||||
#include "targets.h"
|
||||
#include "ZZKick.h"
|
||||
|
||||
#ifdef USE_OLD_REGS
|
||||
|
||||
const u32 g_primmult[8] = { 1, 2, 2, 3, 3, 3, 2, 0xff };
|
||||
const u32 g_primsub[8] = { 1, 2, 1, 3, 1, 1, 2, 0 };
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4244)
|
||||
#endif
|
||||
@ -44,44 +42,6 @@ u32 s_uClampData[2] = {0, };
|
||||
|
||||
//u32 results[65535] = {0, };
|
||||
|
||||
// return true if triangle SHOULD be painted.
|
||||
inline bool NoHighlights(int i)
|
||||
{
|
||||
// This is hack-code, I still in search of correct reason, why some triangles should not be drawn.
|
||||
|
||||
int dummy = 0;
|
||||
|
||||
u32 resultA = prim->iip + (2 * (prim->tme)) + (4 * (prim->fge)) + (8 * (prim->abe)) + (16 * (prim->aa1)) + (32 * (prim->fst)) + (64 * (prim->ctxt)) + (128 * (prim->fix));
|
||||
|
||||
// if ( results[resultA] == 0 ) {
|
||||
// results[resultA] = 1;
|
||||
// ZZLog::Error_Log("%x = %d %d %d %d %d %d %d %d \n", resultA, prim->iip, (prim->tme), (prim->fge), (prim->abe) , (prim->aa1) ,(prim->fst), (prim->ctxt), (prim->fix)) ;
|
||||
// }
|
||||
// if (resultA == 0xb && vb[i].zbuf.zmsk ) return false; //ATF
|
||||
|
||||
const pixTest curtest = vb[i].test;
|
||||
|
||||
u32 result = curtest.ate + ((curtest.atst) << 1) +((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst)<< 9);
|
||||
// if (resultA == 0xb)
|
||||
// if ( results[result] == 0) {
|
||||
// results[result] = 1;
|
||||
// ZZLog::Error_Log("0x%x = %d %d %d %d %d %d %d %d ", result, curtest.ate, curtest.atst, curtest.aref, curtest.afail, curtest.date, curtest.datm, curtest.zte, curtest.ztst);
|
||||
// }
|
||||
|
||||
//if (result == 0x50b && vb[i].zbuf.zmsk ) return false; //ATF
|
||||
//if ((resultA == 0x3a2a || resultA == 0x312a) && (result == 0x302 || result == 0x700) && (vb[i].zbuf.zmsk)) return false; // Silent Hill:SM and Front Mission 5, result != 0x300
|
||||
//if (((resultA == 0x3100) || (resultA == 0x3108)) && ((result == 0x54c) || (result == 0x50c)) && (vb[i].zbuf.zmsk)) return false; // Okage
|
||||
|
||||
if ((resultA == 0x310a) && (result == 0x0)) return false; // Radiata Stories
|
||||
|
||||
//if (resultA == 0x3a6a && (result == 0x300 || result == 0x500) && vb[i].zbuf.zmsk) return false; // Okami, result != 0x30d
|
||||
|
||||
//if ((resultA == 0x300b) && (result == 0x300) && vb[i].zbuf.zmsk) return false; // ATF, but no Melty Blood
|
||||
|
||||
// Old code
|
||||
return (!(conf.settings().xenosaga_spec) || !vb[i].zbuf.zmsk || prim->iip) ;
|
||||
}
|
||||
|
||||
void __gifCall GIFPackedRegHandlerNull(const u32* data)
|
||||
{
|
||||
FUNCLOG
|
||||
@ -124,35 +84,6 @@ void __gifCall GIFPackedRegHandlerUV(const u32* data)
|
||||
gs.vertexregs.v = data[1] & 0x3fff;
|
||||
}
|
||||
|
||||
void __forceinline KICK_VERTEX2()
|
||||
{
|
||||
FUNCLOG
|
||||
|
||||
if (++gs.primC >= (int)g_primmult[prim->prim])
|
||||
{
|
||||
if (NoHighlights(prim->ctxt)) (*drawfn[prim->prim])();
|
||||
|
||||
gs.primC -= g_primsub[prim->prim];
|
||||
}
|
||||
}
|
||||
|
||||
void __forceinline KICK_VERTEX3()
|
||||
{
|
||||
FUNCLOG
|
||||
|
||||
if (++gs.primC >= (int)g_primmult[prim->prim])
|
||||
{
|
||||
gs.primC -= g_primsub[prim->prim];
|
||||
|
||||
if (prim->prim == 5)
|
||||
{
|
||||
/* tri fans need special processing */
|
||||
if (gs.nTriFanVert == gs.primIndex)
|
||||
gs.primIndex = gs.primNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __gifCall GIFPackedRegHandlerXYZF2(const u32* data)
|
||||
{
|
||||
FUNCLOG
|
||||
|
355
plugins/zzogl-pg/opengl/ZZKick.cpp
Normal file
355
plugins/zzogl-pg/opengl/ZZKick.cpp
Normal file
@ -0,0 +1,355 @@
|
||||
/* ZZ Open GL graphics plugin
|
||||
* Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
|
||||
* Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "ZZKick.h"
|
||||
#include "zerogs.h"
|
||||
|
||||
const u32 g_primmult[8] = { 1, 2, 2, 3, 3, 3, 2, 0xff };
|
||||
const u32 g_primsub[8] = { 1, 2, 1, 3, 1, 1, 2, 0 };
|
||||
|
||||
DrawFn drawfn[8] = { KickDummy, KickDummy, KickDummy, KickDummy,
|
||||
KickDummy, KickDummy, KickDummy, KickDummy
|
||||
};
|
||||
|
||||
void init_drawfn()
|
||||
{
|
||||
drawfn[0] = KickPoint;
|
||||
drawfn[1] = KickLine;
|
||||
drawfn[2] = KickLine;
|
||||
drawfn[3] = KickTriangle;
|
||||
drawfn[4] = KickTriangle;
|
||||
drawfn[5] = KickTriangleFan;
|
||||
drawfn[6] = KickSprite;
|
||||
drawfn[7] = KickDummy;
|
||||
}
|
||||
|
||||
void clear_drawfn()
|
||||
{
|
||||
|
||||
drawfn[0] = KickDummy;
|
||||
drawfn[1] = KickDummy;
|
||||
drawfn[2] = KickDummy;
|
||||
drawfn[3] = KickDummy;
|
||||
drawfn[4] = KickDummy;
|
||||
drawfn[5] = KickDummy;
|
||||
drawfn[6] = KickDummy;
|
||||
drawfn[7] = KickDummy;
|
||||
}
|
||||
|
||||
__forceinline void MOVZ(VertexGPU *p, u32 gsz, const VB& curvb)
|
||||
{
|
||||
p->z = (curvb.zprimmask == 0xffff) ? min((u32)0xffff, gsz) : gsz;
|
||||
}
|
||||
|
||||
__forceinline void MOVFOG(VertexGPU *p, Vertex gsf)
|
||||
{
|
||||
p->f = ((s16)(gsf).f << 7) | 0x7f;
|
||||
}
|
||||
|
||||
// return true if triangle SHOULD be painted.
|
||||
// Hackish and should be replaced.
|
||||
bool __forceinline NoHighlights(int i)
|
||||
{
|
||||
// This is hack-code, I still in search of correct reason, why some triangles should not be drawn.
|
||||
|
||||
int dummy = 0;
|
||||
|
||||
u32 resultA = prim->iip + (2 * (prim->tme)) + (4 * (prim->fge)) + (8 * (prim->abe)) + (16 * (prim->aa1)) + (32 * (prim->fst)) + (64 * (prim->ctxt)) + (128 * (prim->fix));
|
||||
|
||||
const pixTest curtest = vb[i].test;
|
||||
|
||||
u32 result = curtest.ate + ((curtest.atst) << 1) +((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst)<< 9);
|
||||
|
||||
if ((resultA == 0x310a) && (result == 0x0)) return false; // Radiata Stories
|
||||
|
||||
//Old code
|
||||
return (!(conf.settings().xenosaga_spec) || !vb[i].zbuf.zmsk || prim->iip) ;
|
||||
}
|
||||
|
||||
void __forceinline KICK_VERTEX2()
|
||||
{
|
||||
FUNCLOG
|
||||
|
||||
if (++gs.primC >= (int)g_primmult[prim->prim])
|
||||
{
|
||||
if (NoHighlights(prim->ctxt)) (*drawfn[prim->prim])();
|
||||
|
||||
gs.primC -= g_primsub[prim->prim];
|
||||
}
|
||||
}
|
||||
|
||||
void __forceinline KICK_VERTEX3()
|
||||
{
|
||||
FUNCLOG
|
||||
|
||||
if (++gs.primC >= (int)g_primmult[prim->prim])
|
||||
{
|
||||
gs.primC -= g_primsub[prim->prim];
|
||||
|
||||
if (prim->prim == 5)
|
||||
{
|
||||
/* tri fans need special processing */
|
||||
if (gs.nTriFanVert == gs.primIndex)
|
||||
gs.primIndex = gs.primNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __forceinline KickVertex(bool adc)
|
||||
{
|
||||
FUNCLOG
|
||||
if (++gs.primC >= (int)g_primmult[prim->prim])
|
||||
{
|
||||
if (!adc && NoHighlights(prim->ctxt)) (*drawfn[prim->prim])();
|
||||
|
||||
gs.primC -= g_primsub[prim->prim];
|
||||
|
||||
if (adc && prim->prim == 5)
|
||||
{
|
||||
/* tri fans need special processing */
|
||||
if (gs.nTriFanVert == gs.primIndex)
|
||||
gs.primIndex = gs.primNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void SET_VERTEX(VertexGPU *p, int Index, const VB& curvb)
|
||||
{
|
||||
int index = Index;
|
||||
p->x = ((((int)gs.gsvertex[index].x - curvb.offset.x) >> 1) & 0xffff);
|
||||
p->y = ((((int)gs.gsvertex[index].y - curvb.offset.y) >> 1) & 0xffff);
|
||||
p->f = ((s16)gs.gsvertex[index].f << 7) | 0x7f;
|
||||
|
||||
MOVZ(p, gs.gsvertex[index].z, curvb);
|
||||
|
||||
p->rgba = prim->iip ? gs.gsvertex[index].rgba : gs.rgba;
|
||||
|
||||
// This code is somehow incorrect
|
||||
// if ((gs.texa.aem) && ((p->rgba & 0xffffff ) == 0))
|
||||
// p->rgba = 0;
|
||||
|
||||
if (conf.settings().texa)
|
||||
{
|
||||
u32 B = ((p->rgba & 0xfe000000) >> 1) +
|
||||
(0x01000000 * curvb.fba.fba) ;
|
||||
p->rgba = (p->rgba & 0xffffff) + B;
|
||||
}
|
||||
|
||||
if (prim->tme)
|
||||
{
|
||||
if (prim->fst)
|
||||
{
|
||||
p->s = (float)gs.gsvertex[index].u * fiTexWidth[prim->ctxt];
|
||||
p->t = (float)gs.gsvertex[index].v * fiTexHeight[prim->ctxt];
|
||||
p->q = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->s = gs.gsvertex[index].s;
|
||||
p->t = gs.gsvertex[index].t;
|
||||
p->q = gs.gsvertex[index].q;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static __forceinline void OUTPUT_VERT(VertexGPU vert, u32 id)
|
||||
{
|
||||
#ifdef WRITE_PRIM_LOGS
|
||||
ZZLog::Prim_Log("%c%d(%d): xyzf=(%4d,%4d,0x%x,%3d), rgba=0x%8.8x, stq = (%2.5f,%2.5f,%2.5f)\n",
|
||||
id == 0 ? '*' : ' ', id, prim->prim, vert.x / 8, vert.y / 8, vert.z, vert.f / 128,
|
||||
vert.rgba, Clamp(vert.s, -10, 10), Clamp(vert.t, -10, 10), Clamp(vert.q, -10, 10));
|
||||
#endif
|
||||
}
|
||||
|
||||
void KickPoint()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 1);
|
||||
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(1);
|
||||
|
||||
int last = gs.primNext(2);
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
SET_VERTEX(&p[0], last, curvb);
|
||||
curvb.nCount++;
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
}
|
||||
|
||||
void KickLine()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 2);
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(2);
|
||||
|
||||
int next = gs.primNext();
|
||||
int last = gs.primNext(2);
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
SET_VERTEX(&p[0], next, curvb);
|
||||
SET_VERTEX(&p[1], last, curvb);
|
||||
|
||||
curvb.nCount += 2;
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
OUTPUT_VERT(p[1], 1);
|
||||
}
|
||||
|
||||
void KickTriangle()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 3);
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(3);
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
SET_VERTEX(&p[0], 0, curvb);
|
||||
SET_VERTEX(&p[1], 1, curvb);
|
||||
SET_VERTEX(&p[2], 2, curvb);
|
||||
|
||||
curvb.nCount += 3;
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
OUTPUT_VERT(p[1], 1);
|
||||
OUTPUT_VERT(p[2], 2);
|
||||
}
|
||||
|
||||
void KickTriangleFan()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 3);
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(3);
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
SET_VERTEX(&p[0], 0, curvb);
|
||||
SET_VERTEX(&p[1], 1, curvb);
|
||||
SET_VERTEX(&p[2], 2, curvb);
|
||||
|
||||
curvb.nCount += 3;
|
||||
|
||||
// add 1 to skip the first vertex
|
||||
|
||||
if (gs.primIndex == gs.nTriFanVert) gs.primIndex = gs.primNext();
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
OUTPUT_VERT(p[1], 1);
|
||||
OUTPUT_VERT(p[2], 2);
|
||||
}
|
||||
|
||||
void SetKickVertex(VertexGPU *p, Vertex v, int next, const VB& curvb)
|
||||
{
|
||||
SET_VERTEX(p, next, curvb);
|
||||
MOVZ(p, v.z, curvb);
|
||||
MOVFOG(p, v);
|
||||
}
|
||||
|
||||
void KickSprite()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 2);
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(6);
|
||||
int next = gs.primNext();
|
||||
int last = gs.primNext(2);
|
||||
|
||||
// sprite is too small and AA shows lines (tek4, Mana Khemia)
|
||||
gs.gsvertex[last].x += (4 * AA.x);
|
||||
gs.gsvertex[last].y += (4 * AA.y);
|
||||
|
||||
// might be bad sprite (KH dialog text)
|
||||
//if( gs.gsvertex[next].x == gs.gsvertex[last].x || gs.gsvertex[next].y == gs.gsvertex[last].y )
|
||||
//return;
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
|
||||
SetKickVertex(&p[0], gs.gsvertex[last], next, curvb);
|
||||
SetKickVertex(&p[3], gs.gsvertex[last], next, curvb);
|
||||
SetKickVertex(&p[1], gs.gsvertex[last], last, curvb);
|
||||
SetKickVertex(&p[4], gs.gsvertex[last], last, curvb);
|
||||
SetKickVertex(&p[2], gs.gsvertex[last], next, curvb);
|
||||
|
||||
p[2].s = p[1].s;
|
||||
p[2].x = p[1].x;
|
||||
|
||||
SetKickVertex(&p[5], gs.gsvertex[last], last, curvb);
|
||||
|
||||
p[5].s = p[0].s;
|
||||
p[5].x = p[0].x;
|
||||
|
||||
curvb.nCount += 6;
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
OUTPUT_VERT(p[1], 1);
|
||||
}
|
||||
|
||||
void KickDummy()
|
||||
{
|
||||
FUNCLOG
|
||||
//ZZLog::Greg_Log("Kicking bad primitive: %.8x\n", *(u32*)prim);
|
||||
}
|
49
plugins/zzogl-pg/opengl/ZZKick.h
Normal file
49
plugins/zzogl-pg/opengl/ZZKick.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* ZZ Open GL graphics plugin
|
||||
* Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
|
||||
* Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef ZZKICK_H_INCLUDED
|
||||
#define ZZKICK_H_INCLUDED
|
||||
|
||||
#include "GS.h"
|
||||
|
||||
// visible members
|
||||
typedef void (*DrawFn)();
|
||||
extern DrawFn drawfn[8];
|
||||
|
||||
// Older Kick Vertex functions.
|
||||
void __forceinline KICK_VERTEX2();
|
||||
void __forceinline KICK_VERTEX3();
|
||||
|
||||
// Newer version.
|
||||
extern void __forceinline KickVertex(bool adc);
|
||||
|
||||
extern bool __forceinline NoHighlights(int i);
|
||||
|
||||
extern void init_drawfn();
|
||||
extern void clear_drawfn();
|
||||
|
||||
extern void KickPoint();
|
||||
extern void KickLine();
|
||||
extern void KickTriangle();
|
||||
extern void KickTriangleFan();
|
||||
extern void KickSprite();
|
||||
extern void KickDummy();
|
||||
|
||||
|
||||
#endif // ZZKICK_H_INCLUDED
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "targets.h"
|
||||
#include "rasterfont.h" // simple font
|
||||
|
||||
#include "ZZKick.h"
|
||||
|
||||
// This include for windows resource file with Shaders
|
||||
#ifdef _WIN32
|
||||
@ -76,12 +76,6 @@ typedef void (APIENTRYP _PFNSWAPINTERVAL)(int);
|
||||
|
||||
map<string, GLbyte> mapGLExtensions;
|
||||
|
||||
extern void KickPoint();
|
||||
extern void KickLine();
|
||||
extern void KickTriangle();
|
||||
extern void KickTriangleFan();
|
||||
extern void KickSprite();
|
||||
extern void KickDummy();
|
||||
extern bool LoadEffects();
|
||||
extern bool ZZshLoadExtraEffects();
|
||||
extern FRAGMENTSHADER* ZZshLoadShadeEffect(int type, int texfilter, int fog, int testaem, int exactcolor, const clampInfo& clamp, int context, bool* pbFailed);
|
||||
@ -508,15 +502,8 @@ bool ZZCreate(int _width, int _height)
|
||||
if (err != GL_NO_ERROR) bSuccess = false;
|
||||
|
||||
// init draw fns
|
||||
drawfn[0] = KickPoint;
|
||||
drawfn[1] = KickLine;
|
||||
drawfn[2] = KickLine;
|
||||
drawfn[3] = KickTriangle;
|
||||
drawfn[4] = KickTriangle;
|
||||
drawfn[5] = KickTriangleFan;
|
||||
drawfn[6] = KickSprite;
|
||||
drawfn[7] = KickDummy;
|
||||
|
||||
init_drawfn();
|
||||
|
||||
SetAA(conf.aa);
|
||||
|
||||
GSsetGameCRC(g_LastCRC, conf.settings()._u32);
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include "targets.h"
|
||||
#include "GLWin.h"
|
||||
#include "ZZoglShaders.h"
|
||||
#include "ZZKick.h"
|
||||
|
||||
#ifdef ZEROGS_SSE2
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
@ -105,13 +107,6 @@ void RenderCustom(float fAlpha); // intro anim
|
||||
// Method Prototypes //
|
||||
///////////////////////
|
||||
|
||||
void KickPoint();
|
||||
void KickLine();
|
||||
void KickTriangle();
|
||||
void KickTriangleFan();
|
||||
void KickSprite();
|
||||
void KickDummy();
|
||||
|
||||
void ResolveInRange(int start, int end);
|
||||
|
||||
void ExtWrite();
|
||||
@ -121,10 +116,6 @@ void ResetRenderTarget(int index)
|
||||
FBTexture(index);
|
||||
}
|
||||
|
||||
DrawFn drawfn[8] = { KickDummy, KickDummy, KickDummy, KickDummy,
|
||||
KickDummy, KickDummy, KickDummy, KickDummy
|
||||
};
|
||||
|
||||
// does one time only initializing/destruction
|
||||
|
||||
class ZeroGSInit
|
||||
@ -266,15 +257,7 @@ void ZZReset()
|
||||
|
||||
ZZGSStateReset();
|
||||
ZZDestroy(0);
|
||||
|
||||
drawfn[0] = KickDummy;
|
||||
drawfn[1] = KickDummy;
|
||||
drawfn[2] = KickDummy;
|
||||
drawfn[3] = KickDummy;
|
||||
drawfn[4] = KickDummy;
|
||||
drawfn[5] = KickDummy;
|
||||
drawfn[6] = KickDummy;
|
||||
drawfn[7] = KickDummy;
|
||||
clear_drawfn();
|
||||
}
|
||||
|
||||
void ZZGSReset()
|
||||
@ -467,244 +450,8 @@ void RenderCustom(float fAlpha)
|
||||
// Internal Definitions //
|
||||
//////////////////////////
|
||||
|
||||
|
||||
__forceinline void MOVZ(VertexGPU *p, u32 gsz, const VB& curvb)
|
||||
{
|
||||
p->z = (curvb.zprimmask == 0xffff) ? min((u32)0xffff, gsz) : gsz;
|
||||
}
|
||||
|
||||
__forceinline void MOVFOG(VertexGPU *p, Vertex gsf)
|
||||
{
|
||||
p->f = ((s16)(gsf).f << 7) | 0x7f;
|
||||
}
|
||||
|
||||
|
||||
int Values[100] = {0, };
|
||||
|
||||
inline void SET_VERTEX(VertexGPU *p, int Index, const VB& curvb)
|
||||
{
|
||||
int index = Index;
|
||||
p->x = ((((int)gs.gsvertex[index].x - curvb.offset.x) >> 1) & 0xffff);
|
||||
p->y = ((((int)gs.gsvertex[index].y - curvb.offset.y) >> 1) & 0xffff);
|
||||
p->f = ((s16)gs.gsvertex[index].f << 7) | 0x7f;
|
||||
|
||||
MOVZ(p, gs.gsvertex[index].z, curvb);
|
||||
|
||||
p->rgba = prim->iip ? gs.gsvertex[index].rgba : gs.rgba;
|
||||
|
||||
// This code is somehow incorrect
|
||||
// if ((gs.texa.aem) && ((p->rgba & 0xffffff ) == 0))
|
||||
// p->rgba = 0;
|
||||
|
||||
if (conf.settings().texa)
|
||||
{
|
||||
u32 B = ((p->rgba & 0xfe000000) >> 1) +
|
||||
(0x01000000 * curvb.fba.fba) ;
|
||||
p->rgba = (p->rgba & 0xffffff) + B;
|
||||
}
|
||||
|
||||
if (prim->tme)
|
||||
{
|
||||
if (prim->fst)
|
||||
{
|
||||
p->s = (float)gs.gsvertex[index].u * fiTexWidth[prim->ctxt];
|
||||
p->t = (float)gs.gsvertex[index].v * fiTexHeight[prim->ctxt];
|
||||
p->q = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->s = gs.gsvertex[index].s;
|
||||
p->t = gs.gsvertex[index].t;
|
||||
p->q = gs.gsvertex[index].q;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static __forceinline void OUTPUT_VERT(VertexGPU vert, u32 id)
|
||||
{
|
||||
#ifdef WRITE_PRIM_LOGS
|
||||
ZZLog::Prim_Log("%c%d(%d): xyzf=(%4d,%4d,0x%x,%3d), rgba=0x%8.8x, stq = (%2.5f,%2.5f,%2.5f)\n",
|
||||
id == 0 ? '*' : ' ', id, prim->prim, vert.x / 8, vert.y / 8, vert.z, vert.f / 128,
|
||||
vert.rgba, Clamp(vert.s, -10, 10), Clamp(vert.t, -10, 10), Clamp(vert.q, -10, 10));
|
||||
#endif
|
||||
}
|
||||
|
||||
void KickPoint()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 1);
|
||||
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(1);
|
||||
|
||||
int last = gs.primNext(2);
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
SET_VERTEX(&p[0], last, curvb);
|
||||
curvb.nCount++;
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
}
|
||||
|
||||
void KickLine()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 2);
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(2);
|
||||
|
||||
int next = gs.primNext();
|
||||
int last = gs.primNext(2);
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
SET_VERTEX(&p[0], next, curvb);
|
||||
SET_VERTEX(&p[1], last, curvb);
|
||||
|
||||
curvb.nCount += 2;
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
OUTPUT_VERT(p[1], 1);
|
||||
}
|
||||
|
||||
void KickTriangle()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 3);
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(3);
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
SET_VERTEX(&p[0], 0, curvb);
|
||||
SET_VERTEX(&p[1], 1, curvb);
|
||||
SET_VERTEX(&p[2], 2, curvb);
|
||||
|
||||
curvb.nCount += 3;
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
OUTPUT_VERT(p[1], 1);
|
||||
OUTPUT_VERT(p[2], 2);
|
||||
}
|
||||
|
||||
void KickTriangleFan()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 3);
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(3);
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
SET_VERTEX(&p[0], 0, curvb);
|
||||
SET_VERTEX(&p[1], 1, curvb);
|
||||
SET_VERTEX(&p[2], 2, curvb);
|
||||
|
||||
curvb.nCount += 3;
|
||||
|
||||
// add 1 to skip the first vertex
|
||||
|
||||
if (gs.primIndex == gs.nTriFanVert) gs.primIndex = gs.primNext();
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
OUTPUT_VERT(p[1], 1);
|
||||
OUTPUT_VERT(p[2], 2);
|
||||
}
|
||||
|
||||
void SetKickVertex(VertexGPU *p, Vertex v, int next, const VB& curvb)
|
||||
{
|
||||
SET_VERTEX(p, next, curvb);
|
||||
MOVZ(p, v.z, curvb);
|
||||
MOVFOG(p, v);
|
||||
}
|
||||
|
||||
void KickSprite()
|
||||
{
|
||||
FUNCLOG
|
||||
assert(gs.primC >= 2);
|
||||
VB& curvb = vb[prim->ctxt];
|
||||
|
||||
curvb.FlushTexData();
|
||||
|
||||
if ((vb[!prim->ctxt].nCount > 0) && (vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp))
|
||||
{
|
||||
assert(vb[prim->ctxt].nCount == 0);
|
||||
Flush(!prim->ctxt);
|
||||
}
|
||||
|
||||
curvb.NotifyWrite(6);
|
||||
int next = gs.primNext();
|
||||
int last = gs.primNext(2);
|
||||
|
||||
// sprite is too small and AA shows lines (tek4, Mana Khemia)
|
||||
gs.gsvertex[last].x += (4 * AA.x);
|
||||
gs.gsvertex[last].y += (4 * AA.y);
|
||||
|
||||
// might be bad sprite (KH dialog text)
|
||||
//if( gs.gsvertex[next].x == gs.gsvertex[last].x || gs.gsvertex[next].y == gs.gsvertex[last].y )
|
||||
//return;
|
||||
|
||||
VertexGPU* p = curvb.pBufferData + curvb.nCount;
|
||||
|
||||
SetKickVertex(&p[0], gs.gsvertex[last], next, curvb);
|
||||
SetKickVertex(&p[3], gs.gsvertex[last], next, curvb);
|
||||
SetKickVertex(&p[1], gs.gsvertex[last], last, curvb);
|
||||
SetKickVertex(&p[4], gs.gsvertex[last], last, curvb);
|
||||
SetKickVertex(&p[2], gs.gsvertex[last], next, curvb);
|
||||
|
||||
p[2].s = p[1].s;
|
||||
p[2].x = p[1].x;
|
||||
|
||||
SetKickVertex(&p[5], gs.gsvertex[last], last, curvb);
|
||||
|
||||
p[5].s = p[0].s;
|
||||
p[5].x = p[0].x;
|
||||
|
||||
curvb.nCount += 6;
|
||||
|
||||
OUTPUT_VERT(p[0], 0);
|
||||
OUTPUT_VERT(p[1], 1);
|
||||
}
|
||||
|
||||
void KickDummy()
|
||||
{
|
||||
FUNCLOG
|
||||
//ZZLog::Greg_Log("Kicking bad primitive: %.8x\n", *(u32*)prim);
|
||||
}
|
||||
|
||||
void SetFogColor(u32 fog)
|
||||
{
|
||||
FUNCLOG
|
||||
|
@ -54,10 +54,6 @@ extern bool s_bWriteDepth;
|
||||
|
||||
extern int nBackbufferWidth, nBackbufferHeight;
|
||||
|
||||
// visible members
|
||||
typedef void (*DrawFn)();
|
||||
extern DrawFn drawfn[8];
|
||||
|
||||
extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height
|
||||
extern vector<GLuint> g_vboBuffers; // VBOs for all drawing commands
|
||||
extern GLuint vboRect;
|
||||
|
Loading…
Reference in New Issue
Block a user