/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/zzogl-pg/opengl/Regs.cpp
ViewVC logotype

Diff of /branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/zzogl-pg/opengl/Regs.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/zzogl-pg/opengl/Regs.cpp	2010/12/26 16:21:07	313
+++ branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/plugins/zzogl-pg/opengl/Regs.cpp	2010/12/26 18:56:19	314
@@ -22,14 +22,12 @@
 #include "Regs.h"
 #include "PS2Etypes.h"
 
-#include "zerogs.h"
 #include "targets.h"
+#include "ZZoglVB.h"
+#include "ZZoglDrawing.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 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 && ZeroGS::vb[i].zbuf.zmsk ) return false; //ATF
-
-	const pixTest curtest = ZeroGS::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 && ZeroGS::vb[i].zbuf.zmsk ) return false; //ATF
-	//if ((resultA == 0x3a2a || resultA == 0x312a) && (result == 0x302 || result == 0x700) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Silent Hill:SM and Front Mission 5, result != 0x300
-	//if (((resultA == 0x3100) || (resultA == 0x3108)) && ((result == 0x54c) || (result == 0x50c)) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Okage
-
-	if ((resultA == 0x310a) && (result == 0x0)) return false; // Radiata Stories
-
-	//if (resultA == 0x3a6a && (result == 0x300 || result == 0x500) && ZeroGS::vb[i].zbuf.zmsk) return false; // Okami, result != 0x30d
-
-	//if ((resultA == 0x300b) && (result == 0x300) && ZeroGS::vb[i].zbuf.zmsk) return false; // ATF, but no Melty Blood
-
-//	Old code
-	return (!(conf.settings().xenosaga_spec) || !ZeroGS::vb[i].zbuf.zmsk || prim->iip) ;
-}
-
 void __gifCall GIFPackedRegHandlerNull(const u32* data)
 {
 	FUNCLOG
@@ -90,10 +50,13 @@
 
 // All these just call their non-packed equivalent.
 void __gifCall GIFPackedRegHandlerPRIM(const u32* data) { GIFRegHandlerPRIM(data); }
-void __gifCall GIFPackedRegHandlerTEX0_1(const u32* data) { GIFRegHandlerTEX0_1(data); }
-void __gifCall GIFPackedRegHandlerTEX0_2(const u32* data) { GIFRegHandlerTEX0_2(data); }
-void __gifCall GIFPackedRegHandlerCLAMP_1(const u32* data) { GIFRegHandlerCLAMP_1(data); }
-void __gifCall GIFPackedRegHandlerCLAMP_2(const u32* data) { GIFRegHandlerCLAMP_2(data); }
+
+template <u32 ctxt>
+void __gifCall GIFPackedRegHandlerTEX0(const u32* data) { GIFRegHandlerTEX0<ctxt>(data); }
+
+template <u32 ctxt>
+void __gifCall GIFPackedRegHandlerCLAMP(const u32* data) { GIFRegHandlerCLAMP<ctxt>(data); }
+
 void __gifCall GIFPackedRegHandlerXYZF3(const u32* data) { GIFRegHandlerXYZF3(data); }
 void __gifCall GIFPackedRegHandlerXYZ3(const u32* data) { GIFRegHandlerXYZ3(data); }
 
@@ -124,72 +87,22 @@
 	gs.vertexregs.v = data[1] & 0x3fff;
 }
 
-void __forceinline KICK_VERTEX2()
-{
-	FUNCLOG
-
-	if (++gs.primC >= (int)g_primmult[prim->prim])
-	{
-		if (NoHighlights(prim->ctxt)) (*ZeroGS::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
-	gs.vertexregs.x = (data[0] >> 0) & 0xffff;
-	gs.vertexregs.y = (data[1] >> 0) & 0xffff;
-	gs.vertexregs.z = (data[2] >> 4) & 0xffffff;
-	gs.vertexregs.f = (data[3] >> 4) & 0xff;
-	gs.gsvertex[gs.primIndex] = gs.vertexregs;
-	gs.primIndex = gs.primNext();
+	GIFPackedXYZF2* r = (GIFPackedXYZF2*)(data);
+	gs.add_vertex(r->X, r->Y,r->Z, r->F);
 
-	if (data[3] & 0x8000)
-	{
-		KICK_VERTEX3();
-	}
-	else
-	{
-		KICK_VERTEX2();
-	}
+    ZZKick->KickVertex(((data[3]>>15) & 0x1));
 }
 
 void __gifCall GIFPackedRegHandlerXYZ2(const u32* data)
 {
 	FUNCLOG
-	gs.vertexregs.x = (data[0] >> 0) & 0xffff;
-	gs.vertexregs.y = (data[1] >> 0) & 0xffff;
-	gs.vertexregs.z = data[2];
-	gs.gsvertex[gs.primIndex] = gs.vertexregs;
-	gs.primIndex = gs.primNext();
+	GIFPackedXYZ2* r = (GIFPackedXYZ2*)(data);
+	gs.add_vertex(r->X, r->Y,r->Z);
 
-	if (data[3] & 0x8000)
-	{
-		KICK_VERTEX3();
-	}
-	else
-	{
-		KICK_VERTEX2();
-	}
+    ZZKick->KickVertex(((data[3]>>15) & 0x1));
 }
 
 void __gifCall GIFPackedRegHandlerFOG(const u32* data)
@@ -213,155 +126,6 @@
 	FUNCLOG
 }
 
-void tex0Write(int i, const u32 *data)
-{
-	FUNCLOG
-	u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
-
-	if (m_Blocks[psm].bpp == 0)
-	{
-		// kh and others
-		return;
-	}
-
-	ZeroGS::vb[i].uNextTex0Data[0] = data[0];
-	ZeroGS::vb[i].uNextTex0Data[1] = data[1];
-	ZeroGS::vb[i].bNeedTexCheck = 1;
-
-	// don't update unless necessary
-
-	if (PSMT_ISCLUT(psm))
-	{
-		if (ZeroGS::CheckChangeInClut(data[1], psm))
-		{
-			// loading clut, so flush whole texture
-			ZeroGS::vb[i].FlushTexData();
-		}
-
-		// check if csa is the same!! (ffx bisaid island, grass)
-		else if ((data[1] & CPSM_CSA_BITMASK) != (ZeroGS::vb[i].uCurTex0Data[1] & CPSM_CSA_BITMASK))
-		{
-			ZeroGS::Flush(i); // flush any previous entries
-		}
-	}
-}
-
-void tex2Write(int i, const u32 *data)
-{
-	FUNCLOG
-	tex0Info& tex0 = ZeroGS::vb[i].tex0;
-
-	ZeroGS::vb[i].FlushTexData();
-
-	u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
-
-	u32* s_uTex0Data = ZeroGS::vb[i].uCurTex0Data;
-
-	// don't update unless necessary
-//	if( ZZOglGet_psm_TexBitsFix(*s_uTex0Data) == ZZOglGet_psm_TexBitsFix(data[0]) ) { // psm is the same
-	if (ZZOglAllExceptClutIsSame(s_uTex0Data, data))
-	{
-		if (!PSMT_ISCLUT(psm)) return;
-
-		// have to write the CLUT again if changed
-		if (ZZOglClutMinusCLDunchanged(s_uTex0Data, data))
-		{
-			tex0.cld = ZZOglGet_cld_TexBits(data[1]);
-
-			if (tex0.cld != 0)
-			{
-				ZeroGS::texClutWrite(i);
-				// invalidate to make sure target didn't change!
-				ZeroGS::vb[i].bVarsTexSync = false;
-			}
-
-			return;
-		}
-	}
-
-	ZeroGS::Flush(i);
-
-	ZeroGS::vb[i].bVarsTexSync = false;
-	ZeroGS::vb[i].bTexConstsSync = false;
-
-	s_uTex0Data[0] = (s_uTex0Data[0] & ~0x03f00000) | (psm << 20);
-	s_uTex0Data[1] = (s_uTex0Data[1] & 0x1f) | (data[1] & ~0x1f);
-
-	tex0.psm = ZZOglGet_psm_TexBitsFix(data[0]);
-
-	if (PSMT_ISCLUT(tex0.psm)) ZeroGS::CluttingForFlushedTex(&tex0, data[1], i);
-}
-
-__forceinline void frameWrite(int i, const u32 *data)
-{
-	FUNCLOG
-	frameInfo& gsfb = ZeroGS::vb[i].gsfb;
-
-	if ((gsfb.fbp == ZZOglGet_fbp_FrameBitsMult(data[0])) &&
-			(gsfb.fbw == ZZOglGet_fbw_FrameBitsMult(data[0])) &&
-			(gsfb.psm == ZZOglGet_psm_FrameBits(data[0])) &&
-			(gsfb.fbm == ZZOglGet_fbm_FrameBits(data[0])))
-	{
-		return;
-	}
-
-	ZeroGS::FlushBoth();
-
-	gsfb.fbp = ZZOglGet_fbp_FrameBitsMult(data[0]);
-	gsfb.fbw = ZZOglGet_fbw_FrameBitsMult(data[0]);
-	gsfb.psm = ZZOglGet_psm_FrameBits(data[0]);
-	gsfb.fbm = ZZOglGet_fbm_FrameBitsFix(data[0], data[1]);
-	gsfb.fbh = ZZOglGet_fbh_FrameBitsCalc(data[0]);
-//	gsfb.fbhCalc = gsfb.fbh;
-
-	ZeroGS::vb[i].bNeedFrameCheck = 1;
-}
-
-__forceinline void testWrite(int i, const u32 *data)
-{
-	FUNCLOG
-	pixTest* test = &ZeroGS::vb[i].test;
-
-	if ((*(u32*)test & 0x0007ffff) == (data[0] & 0x0007ffff)) return;
-
-	ZeroGS::Flush(i);
-
-	*(u32*)test = data[0];
-
-//  test.ate   = (data[0]	  ) & 0x1;
-//  test.atst  = (data[0] >>  1) & 0x7;
-//  test.aref  = (data[0] >>  4) & 0xff;
-//  test.afail = (data[0] >> 12) & 0x3;
-//  test.date  = (data[0] >> 14) & 0x1;
-//  test.datm  = (data[0] >> 15) & 0x1;
-//  test.zte   = (data[0] >> 16) & 0x1;
-//  test.ztst  = (data[0] >> 17) & 0x3;
-}
-
-#ifndef __LINUX__
-__forceinline 
-#endif
-void clampWrite(int i, const u32 *data)
-{
-	FUNCLOG
-	clampInfo& clamp = ZeroGS::vb[i].clamp;
-
-	if ((s_uClampData[i] != data[0]) || (((clamp.minv >> 8) | (clamp.maxv << 2)) != (data[1]&0x0fff)))
-	{
-		ZeroGS::Flush(i);
-		s_uClampData[i] = data[0];
-
-		clamp.wms  = (data[0]) & 0x3;
-		clamp.wmt  = (data[0] >>  2) & 0x3;
-		clamp.minu = (data[0] >>  4) & 0x3ff;
-		clamp.maxu = (data[0] >> 14) & 0x3ff;
-		clamp.minv = ((data[0] >> 24) & 0xff) | ((data[1] & 0x3) << 8);
-		clamp.maxv = (data[1] >> 2) & 0x3ff;
-
-		ZeroGS::vb[i].bTexConstsSync = false;
-	}
-}
-
 void __gifCall GIFRegHandlerNull(const u32* data)
 {
 	FUNCLOG
@@ -387,15 +151,18 @@
 		//ZZLog::Warn_Log("Warning: unknown bits in prim %8.8lx_%8.8lx", data[1], data[0]);
 	//}
 
-	gs.nTriFanVert = gs.primIndex;
 
 	gs.primC = 0;
-	prim->prim = (data[0]) & 0x7;
-	gs._prim[0].prim = (data[0]) & 0x7;
-	gs._prim[1].prim = (data[0]) & 0x7;
+    u16 prim_type = (data[0]) & 0x7;
+	prim->prim = prim_type;
+	gs._prim[0].prim = prim_type;
+	gs._prim[1].prim = prim_type;
 	gs._prim[1]._val = (data[0] >> 3) & 0xff;
 
-	ZeroGS::Prim();
+    gs.new_tri_fan = !(prim_type ^ PRIM_TRIANGLE_FAN);
+    ZZKick->DirtyValidPrevPrim();
+
+	Prim();
 }
 
 void __gifCall GIFRegHandlerRGBAQ(const u32* data)
@@ -424,62 +191,81 @@
 void __gifCall GIFRegHandlerXYZF2(const u32* data)
 {
 	FUNCLOG
-	gs.vertexregs.x = (data[0]) & 0xffff;
-	gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
-	gs.vertexregs.z = data[1] & 0xffffff;
-	gs.vertexregs.f = data[1] >> 24;
-	gs.gsvertex[gs.primIndex] = gs.vertexregs;
-	gs.primIndex = gs.primNext();
+	GIFRegXYZF* r = (GIFRegXYZF*)(data);
+	gs.add_vertex(r->X, r->Y,r->Z, r->F);
 
-	KICK_VERTEX2();
+    ZZKick->KickVertex(false);
 }
 
 void __gifCall GIFRegHandlerXYZ2(const u32* data)
 {
 	FUNCLOG
-	gs.vertexregs.x = (data[0]) & 0xffff;
-	gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
-	gs.vertexregs.z = data[1];
-	gs.gsvertex[gs.primIndex] = gs.vertexregs;
-	gs.primIndex = gs.primNext();
+	GIFRegXYZ* r = (GIFRegXYZ*)(data);
+	gs.add_vertex(r->X, r->Y,r->Z);
 
-	KICK_VERTEX2();
+    ZZKick->KickVertex(false);
 }
 
-void __gifCall GIFRegHandlerTEX0_1(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerTEX0(const u32* data)
 {
 	FUNCLOG
+	
+	if (!NoHighlights(ctxt)) return;
+	
+	u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
 
-	if (!NoHighlights(0)) return;
+	if (m_Blocks[psm].bpp == 0)
+	{
+		// kh and others
+		return;
+	}
 
-	tex0Write(0, data);
-}
+	vb[ctxt].uNextTex0Data[0] = data[0];
+	vb[ctxt].uNextTex0Data[1] = data[1];
+	vb[ctxt].bNeedTexCheck = 1;
 
-void __gifCall GIFRegHandlerTEX0_2(const u32* data)
-{
-	FUNCLOG
+	// don't update unless necessary
 
-	if (!NoHighlights(1)) return;
+	if (PSMT_ISCLUT(psm))
+	{
+		if (CheckChangeInClut(data[1], psm))
+		{
+			// loading clut, so flush whole texture
+			vb[ctxt].FlushTexData();
+		}
 
-	tex0Write(1, data);
+		// check if csa is the same!! (ffx bisaid island, grass)
+		else if ((data[1] & CPSM_CSA_BITMASK) != (vb[ctxt].uCurTex0Data[1] & CPSM_CSA_BITMASK))
+		{
+			Flush(ctxt); // flush any previous entries
+		}
+	}
 }
 
-void __gifCall GIFRegHandlerCLAMP_1(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerCLAMP(const u32* data)
 {
 	FUNCLOG
+	
+	if (!NoHighlights(ctxt)) return;
+	
+	clampInfo& clamp = vb[ctxt].clamp;
 
-	if (!NoHighlights(0)) return;
-
-	clampWrite(0, data);
-}
-
-void __gifCall GIFRegHandlerCLAMP_2(const u32* data)
-{
-	FUNCLOG
+	if ((s_uClampData[ctxt] != data[0]) || (((clamp.minv >> 8) | (clamp.maxv << 2)) != (data[1]&0x0fff)))
+	{
+		Flush(ctxt);
+		s_uClampData[ctxt] = data[0];
 
-	if (!NoHighlights(1)) return;
+		clamp.wms  = (data[0]) & 0x3;
+		clamp.wmt  = (data[0] >>  2) & 0x3;
+		clamp.minu = (data[0] >>  4) & 0x3ff;
+		clamp.maxu = (data[0] >> 14) & 0x3ff;
+		clamp.minv = ((data[0] >> 24) & 0xff) | ((data[1] & 0x3) << 8);
+		clamp.maxv = (data[1] >> 2) & 0x3ff;
 
-	clampWrite(1, data);
+		vb[ctxt].bTexConstsSync = false;
+	}
 }
 
 void __gifCall GIFRegHandlerFOG(const u32* data)
@@ -492,26 +278,19 @@
 void __gifCall GIFRegHandlerXYZF3(const u32* data)
 {
 	FUNCLOG
-	gs.vertexregs.x = (data[0]) & 0xffff;
-	gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
-	gs.vertexregs.z = data[1] & 0xffffff;
-	gs.vertexregs.f = data[1] >> 24;
-	gs.gsvertex[gs.primIndex] = gs.vertexregs;
-	gs.primIndex = gs.primNext();
+	GIFRegXYZF* r = (GIFRegXYZF*)(data);
+	gs.add_vertex(r->X, r->Y,r->Z, r->F);
 
-	KICK_VERTEX3();
+    ZZKick->KickVertex(true);
 }
 
 void __gifCall GIFRegHandlerXYZ3(const u32* data)
 {
 	FUNCLOG
-	gs.vertexregs.x = (data[0]) & 0xffff;
-	gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
-	gs.vertexregs.z = data[1];
-	gs.gsvertex[gs.primIndex] = gs.vertexregs;
-	gs.primIndex = gs.primNext();
+	GIFRegXYZ* r = (GIFRegXYZ*)(data);
+	gs.add_vertex(r->X, r->Y,r->Z);
 
-	KICK_VERTEX3();
+    ZZKick->KickVertex(true);
 }
 
 void __gifCall GIFRegHandlerNOP(const u32* data)
@@ -519,19 +298,22 @@
 	FUNCLOG
 }
 
-void tex1Write(int i, const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerTEX1(const u32* data)
 {
 	FUNCLOG
-	tex1Info& tex1 = ZeroGS::vb[i].tex1;
+	
+	if (!NoHighlights(ctxt)) return;
+	
+	tex1Info& tex1 = vb[ctxt].tex1;
 
 	if (conf.bilinear == 1 && (tex1.mmag != ((data[0] >>  5) & 0x1) || tex1.mmin != ((data[0] >>  6) & 0x7)))
 	{
-		ZeroGS::Flush(i);
-		ZeroGS::vb[i].bVarsTexSync = false;
+		Flush(ctxt);
+		vb[ctxt].bVarsTexSync = false;
 	}
 
 	tex1.lcm  = (data[0]) & 0x1;
-
 	tex1.mxl  = (data[0] >>  2) & 0x7;
 	tex1.mmag = (data[0] >>  5) & 0x1;
 	tex1.mmin = (data[0] >>  6) & 0x7;
@@ -540,58 +322,64 @@
 	tex1.k	= (data[1] >> 4) & 0xff;
 }
 
-void __gifCall GIFRegHandlerTEX1_1(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerTEX2(const u32* data)
 {
 	FUNCLOG
+	
+	tex0Info& tex0 = vb[ctxt].tex0;
 
-	if (!NoHighlights(0)) return;
+	vb[ctxt].FlushTexData();
 
-	tex1Write(0, data);
-}
+	u32 psm = ZZOglGet_psm_TexBitsFix(data[0]);
 
-void __gifCall GIFRegHandlerTEX1_2(const u32* data)
-{
-	FUNCLOG
+	u32* s_uTex0Data = vb[ctxt].uCurTex0Data;
 
-	if (!NoHighlights(1)) return;
+	// don't update unless necessary
+//	if( ZZOglGet_psm_TexBitsFix(*s_uTex0Data) == ZZOglGet_psm_TexBitsFix(data[0]) ) { // psm is the same
+	if (ZZOglAllExceptClutIsSame(s_uTex0Data, data))
+	{
+		if (!PSMT_ISCLUT(psm)) return;
 
-	tex1Write(1, data);
-}
+		// have to write the CLUT again if changed
+		if (ZZOglClutMinusCLDunchanged(s_uTex0Data, data))
+		{
+			tex0.cld = ZZOglGet_cld_TexBits(data[1]);
 
-void __gifCall GIFRegHandlerTEX2_1(const u32* data)
-{
-	FUNCLOG
-	tex2Write(0, data);
-}
+			if (tex0.cld != 0)
+			{
+				texClutWrite(ctxt);
+				// invalidate to make sure target didn't change!
+				vb[ctxt].bVarsTexSync = false;
+			}
 
-void __gifCall GIFRegHandlerTEX2_2(const u32* data)
-{
-	FUNCLOG
-	tex2Write(1, data);
-}
+			return;
+		}
+	}
 
-void __gifCall GIFRegHandlerXYOFFSET_1(const u32* data)
-{
-	FUNCLOG
-	// eliminator low 4 bits for now
-	ZeroGS::vb[0].offset.x = (data[0]) & 0xffff;
-	ZeroGS::vb[0].offset.y = (data[1]) & 0xffff;
+	Flush(ctxt);
 
-//  if( !conf.interlace ) {
-//	  ZeroGS::vb[0].offset.x &= ~15;
-//	  ZeroGS::vb[0].offset.y &= ~15;
-//  }
+	vb[ctxt].bVarsTexSync = false;
+	vb[ctxt].bTexConstsSync = false;
+
+	s_uTex0Data[0] = (s_uTex0Data[0] & ~0x03f00000) | (psm << 20);
+	s_uTex0Data[1] = (s_uTex0Data[1] & 0x1f) | (data[1] & ~0x1f);
+
+	tex0.psm = ZZOglGet_psm_TexBitsFix(data[0]);
+
+	if (PSMT_ISCLUT(tex0.psm)) CluttingForFlushedTex(&tex0, data[1], ctxt);
 }
 
-void __gifCall GIFRegHandlerXYOFFSET_2(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerXYOFFSET(const u32* data)
 {
 	FUNCLOG
-	ZeroGS::vb[1].offset.x = (data[0]) & 0xffff;
-	ZeroGS::vb[1].offset.y = (data[1]) & 0xffff;
+	vb[ctxt].offset.x = (data[0]) & 0xffff;
+	vb[ctxt].offset.y = (data[1]) & 0xffff;
 
 //  if( !conf.interlace ) {
-//	  ZeroGS::vb[1].offset.x &= ~15;
-//	  ZeroGS::vb[1].offset.y &= ~15;
+//	  vb[1].offset.x &= ~15;
+//	  vb[1].offset.y &= ~15;
 //  }
 }
 
@@ -601,7 +389,7 @@
 	gs.prac = data[0] & 0x1;
 	prim = &gs._prim[gs.prac];
 
-	ZeroGS::Prim();
+	Prim();
 }
 
 void __gifCall GIFRegHandlerPRMODE(const u32* data)
@@ -609,15 +397,15 @@
 	FUNCLOG
 	gs._prim[0]._val = (data[0] >> 3) & 0xff;
 
-	if (gs.prac == 0) ZeroGS::Prim();
+	if (gs.prac == 0) Prim();
 }
 
 void __gifCall GIFRegHandlerTEXCLUT(const u32* data)
 {
 	FUNCLOG
 
-	ZeroGS::vb[0].FlushTexData();
-	ZeroGS::vb[1].FlushTexData();
+	vb[0].FlushTexData();
+	vb[1].FlushTexData();
 
 	gs.clut.cbw = ((data[0]) & 0x3f) * 64;
 	gs.clut.cou = ((data[0] >>  6) & 0x3f) * 16;
@@ -627,29 +415,18 @@
 void __gifCall GIFRegHandlerSCANMSK(const u32* data)
 {
 	FUNCLOG
-//  ZeroGS::FlushBoth();
-//  ZeroGS::ResolveC(&ZeroGS::vb[0]);
-//  ZeroGS::ResolveZ(&ZeroGS::vb[0]);
+//  FlushBoth();
+//  ResolveC(&vb[0]);
+//  ResolveZ(&vb[0]);
 
 	gs.smask = data[0] & 0x3;
 }
 
-void __gifCall GIFRegHandlerMIPTBP1_1(const u32* data)
-{
-	FUNCLOG
-	miptbpInfo& miptbp0 = ZeroGS::vb[0].miptbp0;
-	miptbp0.tbp[0] = (data[0]) & 0x3fff;
-	miptbp0.tbw[0] = (data[0] >> 14) & 0x3f;
-	miptbp0.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
-	miptbp0.tbw[1] = (data[1] >>  2) & 0x3f;
-	miptbp0.tbp[2] = (data[1] >>  8) & 0x3fff;
-	miptbp0.tbw[2] = (data[1] >> 22) & 0x3f;
-}
-
-void __gifCall GIFRegHandlerMIPTBP1_2(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerMIPTBP1(const u32* data)
 {
 	FUNCLOG
-	miptbpInfo& miptbp0 = ZeroGS::vb[1].miptbp0;
+	miptbpInfo& miptbp0 = vb[ctxt].miptbp0;
 	miptbp0.tbp[0] = (data[0]) & 0x3fff;
 	miptbp0.tbw[0] = (data[0] >> 14) & 0x3f;
 	miptbp0.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
@@ -658,22 +435,11 @@
 	miptbp0.tbw[2] = (data[1] >> 22) & 0x3f;
 }
 
-void __gifCall GIFRegHandlerMIPTBP2_1(const u32* data)
-{
-	FUNCLOG
-	miptbpInfo& miptbp1 = ZeroGS::vb[0].miptbp1;
-	miptbp1.tbp[0] = (data[0]) & 0x3fff;
-	miptbp1.tbw[0] = (data[0] >> 14) & 0x3f;
-	miptbp1.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
-	miptbp1.tbw[1] = (data[1] >>  2) & 0x3f;
-	miptbp1.tbp[2] = (data[1] >>  8) & 0x3fff;
-	miptbp1.tbw[2] = (data[1] >> 22) & 0x3f;
-}
-
-void __gifCall GIFRegHandlerMIPTBP2_2(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerMIPTBP2(const u32* data)
 {
 	FUNCLOG
-	miptbpInfo& miptbp1 = ZeroGS::vb[1].miptbp1;
+	miptbpInfo& miptbp1 = vb[ctxt].miptbp1;
 	miptbp1.tbp[0] = (data[0]) & 0x3fff;
 	miptbp1.tbw[0] = (data[0] >> 14) & 0x3f;
 	miptbp1.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
@@ -692,35 +458,35 @@
 
 	if (*(u32*)&newinfo != *(u32*)&gs.texa)
 	{
-		ZeroGS::FlushBoth();
+		FlushBoth();
 		
 		*(u32*)&gs.texa = *(u32*) & newinfo;
 		
 		gs.texa.fta[0] = newinfo.ta[0] / 255.0f;
 		gs.texa.fta[1] = newinfo.ta[1] / 255.0f;
 
-		ZeroGS::vb[0].bTexConstsSync = false;
-		ZeroGS::vb[1].bTexConstsSync = false;
+		vb[0].bTexConstsSync = false;
+		vb[1].bTexConstsSync = false;
 	}
 }
 
 void __gifCall GIFRegHandlerFOGCOL(const u32* data)
 {
 	FUNCLOG
-	ZeroGS::SetFogColor(data[0]&0xffffff);
+	SetFogColor(data[0]&0xffffff);
 }
 
 void __gifCall GIFRegHandlerTEXFLUSH(const u32* data)
 {
 	FUNCLOG
-	ZeroGS::SetTexFlush();
+	SetTexFlush();
 }
 
-void __gifCall GIFRegHandlerSCISSOR_1(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerSCISSOR(const u32* data)
 {
 	FUNCLOG
-	Rect2& scissor = ZeroGS::vb[0].scissor;
-
+	Rect2& scissor = vb[ctxt].scissor;
 	Rect2 newscissor;
 
 	newscissor.x0 = ((data[0]) & 0x7ff) << 3;
@@ -731,72 +497,32 @@
 	if (newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
 			newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
 	{
-		ZeroGS::Flush(0);
-		scissor = newscissor;
-		ZeroGS::vb[0].bNeedFrameCheck = 1;
-	}
-}
-
-void __gifCall GIFRegHandlerSCISSOR_2(const u32* data)
-{
-	FUNCLOG
-	Rect2& scissor = ZeroGS::vb[1].scissor;
-
-	Rect2 newscissor;
-
-	newscissor.x0 = ((data[0]) & 0x7ff) << 3;
-	newscissor.x1 = ((data[0] >> 16) & 0x7ff) << 3;
-	newscissor.y0 = ((data[1]) & 0x7ff) << 3;
-	newscissor.y1 = ((data[1] >> 16) & 0x7ff) << 3;
-
-	if (newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
-			newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0)
-	{
-		ZeroGS::Flush(1);
+		Flush(ctxt);
 		scissor = newscissor;
 
 		// flush everything
-		ZeroGS::vb[1].bNeedFrameCheck = 1;
-	}
-}
-
-void __gifCall GIFRegHandlerALPHA_1(const u32* data)
-{
-	FUNCLOG
-	alphaInfo newalpha;
-	newalpha.abcd = *(u8*)data;
-	newalpha.fix = *(u8*)(data + 1);
-
-	if (*(u16*)&newalpha != *(u16*)&ZeroGS::vb[0].alpha)
-	{
-		ZeroGS::Flush(0);
-
-		if (newalpha.a == 3) newalpha.a = 0;
-		if (newalpha.b == 3) newalpha.b = 0;
-		if (newalpha.c == 3) newalpha.c = 0;
-		if (newalpha.d == 3) newalpha.d = 0;
-
-		*(u16*)&ZeroGS::vb[0].alpha = *(u16*) & newalpha;
+		vb[ctxt].bNeedFrameCheck = 1;
 	}
 }
 
-void __gifCall GIFRegHandlerALPHA_2(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerALPHA(const u32* data)
 {
 	FUNCLOG
 	alphaInfo newalpha;
 	newalpha.abcd = *(u8*)data;
 	newalpha.fix = *(u8*)(data + 1);
 
-	if (*(u16*)&newalpha != *(u16*)&ZeroGS::vb[1].alpha)
+	if (*(u16*)&newalpha != *(u16*)&vb[ctxt].alpha)
 	{
-		ZeroGS::Flush(1);
+		Flush(ctxt);
 
 		if (newalpha.a == 3) newalpha.a = 0;
 		if (newalpha.b == 3) newalpha.b = 0;
 		if (newalpha.c == 3) newalpha.c = 0;
 		if (newalpha.d == 3) newalpha.d = 0;
 
-		*(u16*)&ZeroGS::vb[1].alpha = *(u16*) & newalpha;
+		*(u16*)&vb[ctxt].alpha = *(u16*) & newalpha;
 	}
 }
 
@@ -817,91 +543,81 @@
 	gs.colclamp = data[0] & 0x1;
 }
 
-void __gifCall GIFRegHandlerTEST_1(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerTEST(const u32* data)
 {
 	FUNCLOG
-	testWrite(0, data);
-}
+	
+	pixTest* test = &vb[ctxt].test;
 
-void __gifCall GIFRegHandlerTEST_2(const u32* data)
-{
-	FUNCLOG
-	testWrite(1, data);
+	if ((*(u32*)test & 0x0007ffff) == (data[0] & 0x0007ffff)) return;
+
+	Flush(ctxt);
+
+	*(u32*)test = data[0];
+
+//  test.ate   = (data[0]	  ) & 0x1;
+//  test.atst  = (data[0] >>  1) & 0x7;
+//  test.aref  = (data[0] >>  4) & 0xff;
+//  test.afail = (data[0] >> 12) & 0x3;
+//  test.date  = (data[0] >> 14) & 0x1;
+//  test.datm  = (data[0] >> 15) & 0x1;
+//  test.zte   = (data[0] >> 16) & 0x1;
+//  test.ztst  = (data[0] >> 17) & 0x3;
 }
 
 void __gifCall GIFRegHandlerPABE(const u32* data)
 {
 	FUNCLOG
-	//ZeroGS::SetAlphaChanged(0, GPUREG_PABE);
-	//ZeroGS::SetAlphaChanged(1, GPUREG_PABE);
-	ZeroGS::FlushBoth();
+	//SetAlphaChanged(0, GPUREG_PABE);
+	//SetAlphaChanged(1, GPUREG_PABE);
+	FlushBoth();
 
 	gs.pabe = *data & 0x1;
 }
 
-void __gifCall GIFRegHandlerFBA_1(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerFBA(const u32* data)
 {
 	FUNCLOG
 	
-	ZeroGS::FlushBoth();
-	ZeroGS::vb[0].fba.fba = *data & 0x1;
-}
-
-void __gifCall GIFRegHandlerFBA_2(const u32* data)
-{
-	FUNCLOG
-	
-	ZeroGS::FlushBoth();
+	FlushBoth();
 	
-	ZeroGS::vb[1].fba.fba = *data & 0x1;
-}
-
-void __gifCall GIFRegHandlerFRAME_1(const u32* data)
-{
-	FUNCLOG
-	frameWrite(0, data);
-}
-
-void __gifCall GIFRegHandlerFRAME_2(const u32* data)
-{
-	FUNCLOG
-	frameWrite(1, data);
+	vb[ctxt].fba.fba = *data & 0x1;
 }
 
-void __gifCall GIFRegHandlerZBUF_1(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerFRAME(const u32* data)
 {
 	FUNCLOG
-	zbufInfo& zbuf = ZeroGS::vb[0].zbuf;
-
-	int psm = (0x30 | ((data[0] >> 24) & 0xf));
+	
+	frameInfo& gsfb = vb[ctxt].gsfb;
 
-	if (zbuf.zbp == (data[0] & 0x1ff) * 32 &&
-			zbuf.psm == psm &&
-			zbuf.zmsk == (data[1] & 0x1))
+	if ((gsfb.fbp == ZZOglGet_fbp_FrameBitsMult(data[0])) &&
+			(gsfb.fbw == ZZOglGet_fbw_FrameBitsMult(data[0])) &&
+			(gsfb.psm == ZZOglGet_psm_FrameBits(data[0])) &&
+			(gsfb.fbm == ZZOglGet_fbm_FrameBits(data[0])))
 	{
 		return;
 	}
 
-	// error detection
-	if (m_Blocks[psm].bpp == 0) return;
-
-	ZeroGS::FlushBoth();
+	FlushBoth();
 
-	zbuf.zbp = (data[0] & 0x1ff) * 32;
-	zbuf.psm = 0x30 | ((data[0] >> 24) & 0xf);
-	zbuf.zmsk = data[1] & 0x1;
-
-	ZeroGS::vb[0].zprimmask = 0xffffffff;
-
-	if (zbuf.psm > 0x31) ZeroGS::vb[0].zprimmask = 0xffff;
+	gsfb.fbp = ZZOglGet_fbp_FrameBitsMult(data[0]);
+	gsfb.fbw = ZZOglGet_fbw_FrameBitsMult(data[0]);
+	gsfb.psm = ZZOglGet_psm_FrameBits(data[0]);
+	gsfb.fbm = ZZOglGet_fbm_FrameBitsFix(data[0], data[1]);
+	gsfb.fbh = ZZOglGet_fbh_FrameBitsCalc(data[0]);
+//	gsfb.fbhCalc = gsfb.fbh;
 
-	ZeroGS::vb[0].bNeedZCheck = 1;
+	vb[ctxt].bNeedFrameCheck = 1;
 }
 
-void __gifCall GIFRegHandlerZBUF_2(const u32* data)
+template <u32 ctxt>
+void __gifCall GIFRegHandlerZBUF(const u32* data)
 {
 	FUNCLOG
-	zbufInfo& zbuf = ZeroGS::vb[1].zbuf;
+	zbufInfo& zbuf = vb[ctxt].zbuf;
 
 	int psm = (0x30 | ((data[0] >> 24) & 0xf));
 
@@ -915,18 +631,16 @@
 	// error detection
 	if (m_Blocks[psm].bpp == 0) return;
 
-	ZeroGS::FlushBoth();
+	FlushBoth();
 
 	zbuf.zbp = (data[0] & 0x1ff) * 32;
-
 	zbuf.psm = 0x30 | ((data[0] >> 24) & 0xf);
-
 	zbuf.zmsk = data[1] & 0x1;
 
-	ZeroGS::vb[1].bNeedZCheck = 1;
-	ZeroGS::vb[1].zprimmask = 0xffffffff;
+	vb[ctxt].bNeedZCheck = 1;
+	vb[ctxt].zprimmask = 0xffffffff;
 
-	if (zbuf.psm > 0x31) ZeroGS::vb[1].zprimmask = 0xffff;
+	if (zbuf.psm > 0x31) vb[ctxt].zprimmask = 0xffff;
 }
 
 void __gifCall GIFRegHandlerBITBLTBUF(const u32* data)
@@ -969,11 +683,11 @@
 	{
 
 		case 0: // host->loc
-			gs.imageTransfer = -1;
+			TerminateHostLocal();
 			break;
 
 		case 1: // loc->host
-			ZeroGS::TerminateLocalHost();
+			TerminateLocalHost();
 			break;
 	}
 
@@ -990,15 +704,15 @@
 		switch (gs.imageTransfer)
 		{
 			case 0: // host->loc
-				ZeroGS::InitTransferHostLocal();
+				InitTransferHostLocal();
 				break;
 
 			case 1: // loc->host
-				ZeroGS::InitTransferLocalHost();
+				InitTransferLocalHost();
 				break;
 
 			case 2:
-				ZeroGS::TransferLocalLocal();
+				TransferLocalLocal();
 				break;
 
 			case 3:
@@ -1024,7 +738,7 @@
 
 	if (gs.imageTransfer == 0)
 	{
-		ZeroGS::TransferHostLocal(data, 2);
+		TransferHostLocal(data, 2);
 	}
 	else
 	{
@@ -1127,10 +841,10 @@
 	g_GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV;
 	g_GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2;
 	g_GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2;
-	g_GIFPackedRegHandlers[GIF_REG_TEX0_1] = &GIFPackedRegHandlerTEX0_1;
-	g_GIFPackedRegHandlers[GIF_REG_TEX0_2] = &GIFPackedRegHandlerTEX0_2;
-	g_GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP_1;
-	g_GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP_2;
+	g_GIFPackedRegHandlers[GIF_REG_TEX0_1] = &GIFPackedRegHandlerTEX0<0>;
+	g_GIFPackedRegHandlers[GIF_REG_TEX0_2] = &GIFPackedRegHandlerTEX0<1>;
+	g_GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>;
+	g_GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>;
 	g_GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG;
 	g_GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3;
 	g_GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3;
@@ -1148,47 +862,47 @@
 	g_GIFRegHandlers[GIF_A_D_REG_UV] = &GIFRegHandlerUV;
 	g_GIFRegHandlers[GIF_A_D_REG_XYZF2] = &GIFRegHandlerXYZF2;
 	g_GIFRegHandlers[GIF_A_D_REG_XYZ2] = &GIFRegHandlerXYZ2;
-	g_GIFRegHandlers[GIF_A_D_REG_TEX0_1] = &GIFRegHandlerTEX0_1;
-	g_GIFRegHandlers[GIF_A_D_REG_TEX0_2] = &GIFRegHandlerTEX0_2;
-	g_GIFRegHandlers[GIF_A_D_REG_CLAMP_1] = &GIFRegHandlerCLAMP_1;
-	g_GIFRegHandlers[GIF_A_D_REG_CLAMP_2] = &GIFRegHandlerCLAMP_2;
+	g_GIFRegHandlers[GIF_A_D_REG_TEX0_1] = &GIFRegHandlerTEX0<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_TEX0_2] = &GIFRegHandlerTEX0<1>;
+	g_GIFRegHandlers[GIF_A_D_REG_CLAMP_1] = &GIFRegHandlerCLAMP<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_CLAMP_2] = &GIFRegHandlerCLAMP<1>;
 	g_GIFRegHandlers[GIF_A_D_REG_FOG] = &GIFRegHandlerFOG;
 	g_GIFRegHandlers[GIF_A_D_REG_XYZF3] = &GIFRegHandlerXYZF3;
 	g_GIFRegHandlers[GIF_A_D_REG_XYZ3] = &GIFRegHandlerXYZ3;
 	g_GIFRegHandlers[GIF_A_D_REG_NOP] = &GIFRegHandlerNOP;
-	g_GIFRegHandlers[GIF_A_D_REG_TEX1_1] = &GIFRegHandlerTEX1_1;
-	g_GIFRegHandlers[GIF_A_D_REG_TEX1_2] = &GIFRegHandlerTEX1_2;
-	g_GIFRegHandlers[GIF_A_D_REG_TEX2_1] = &GIFRegHandlerTEX2_1;
-	g_GIFRegHandlers[GIF_A_D_REG_TEX2_2] = &GIFRegHandlerTEX2_2;
-	g_GIFRegHandlers[GIF_A_D_REG_XYOFFSET_1] = &GIFRegHandlerXYOFFSET_1;
-	g_GIFRegHandlers[GIF_A_D_REG_XYOFFSET_2] = &GIFRegHandlerXYOFFSET_2;
+	g_GIFRegHandlers[GIF_A_D_REG_TEX1_1] = &GIFRegHandlerTEX1<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_TEX1_2] = &GIFRegHandlerTEX1<1>;
+	g_GIFRegHandlers[GIF_A_D_REG_TEX2_1] = &GIFRegHandlerTEX2<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_TEX2_2] = &GIFRegHandlerTEX2<1>;
+	g_GIFRegHandlers[GIF_A_D_REG_XYOFFSET_1] = &GIFRegHandlerXYOFFSET<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_XYOFFSET_2] = &GIFRegHandlerXYOFFSET<1>;
 	g_GIFRegHandlers[GIF_A_D_REG_PRMODECONT] = &GIFRegHandlerPRMODECONT;
 	g_GIFRegHandlers[GIF_A_D_REG_PRMODE] = &GIFRegHandlerPRMODE;
 	g_GIFRegHandlers[GIF_A_D_REG_TEXCLUT] = &GIFRegHandlerTEXCLUT;
 	g_GIFRegHandlers[GIF_A_D_REG_SCANMSK] = &GIFRegHandlerSCANMSK;
-	g_GIFRegHandlers[GIF_A_D_REG_MIPTBP1_1] = &GIFRegHandlerMIPTBP1_1;
-	g_GIFRegHandlers[GIF_A_D_REG_MIPTBP1_2] = &GIFRegHandlerMIPTBP1_2;
-	g_GIFRegHandlers[GIF_A_D_REG_MIPTBP2_1] = &GIFRegHandlerMIPTBP2_1;
-	g_GIFRegHandlers[GIF_A_D_REG_MIPTBP2_2] = &GIFRegHandlerMIPTBP2_2;
+	g_GIFRegHandlers[GIF_A_D_REG_MIPTBP1_1] = &GIFRegHandlerMIPTBP1<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_MIPTBP1_2] = &GIFRegHandlerMIPTBP1<1>;
+	g_GIFRegHandlers[GIF_A_D_REG_MIPTBP2_1] = &GIFRegHandlerMIPTBP2<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_MIPTBP2_2] = &GIFRegHandlerMIPTBP2<1>;
 	g_GIFRegHandlers[GIF_A_D_REG_TEXA] = &GIFRegHandlerTEXA;
 	g_GIFRegHandlers[GIF_A_D_REG_FOGCOL] = &GIFRegHandlerFOGCOL;
 	g_GIFRegHandlers[GIF_A_D_REG_TEXFLUSH] = &GIFRegHandlerTEXFLUSH;
-	g_GIFRegHandlers[GIF_A_D_REG_SCISSOR_1] = &GIFRegHandlerSCISSOR_1;
-	g_GIFRegHandlers[GIF_A_D_REG_SCISSOR_2] = &GIFRegHandlerSCISSOR_2;
-	g_GIFRegHandlers[GIF_A_D_REG_ALPHA_1] = &GIFRegHandlerALPHA_1;
-	g_GIFRegHandlers[GIF_A_D_REG_ALPHA_2] = &GIFRegHandlerALPHA_2;
+	g_GIFRegHandlers[GIF_A_D_REG_SCISSOR_1] = &GIFRegHandlerSCISSOR<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_SCISSOR_2] = &GIFRegHandlerSCISSOR<1>;
+	g_GIFRegHandlers[GIF_A_D_REG_ALPHA_1] = &GIFRegHandlerALPHA<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_ALPHA_2] = &GIFRegHandlerALPHA<1>;
 	g_GIFRegHandlers[GIF_A_D_REG_DIMX] = &GIFRegHandlerDIMX;
 	g_GIFRegHandlers[GIF_A_D_REG_DTHE] = &GIFRegHandlerDTHE;
 	g_GIFRegHandlers[GIF_A_D_REG_COLCLAMP] = &GIFRegHandlerCOLCLAMP;
-	g_GIFRegHandlers[GIF_A_D_REG_TEST_1] = &GIFRegHandlerTEST_1;
-	g_GIFRegHandlers[GIF_A_D_REG_TEST_2] = &GIFRegHandlerTEST_2;
+	g_GIFRegHandlers[GIF_A_D_REG_TEST_1] = &GIFRegHandlerTEST<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_TEST_2] = &GIFRegHandlerTEST<1>;
 	g_GIFRegHandlers[GIF_A_D_REG_PABE] = &GIFRegHandlerPABE;
-	g_GIFRegHandlers[GIF_A_D_REG_FBA_1] = &GIFRegHandlerFBA_1;
-	g_GIFRegHandlers[GIF_A_D_REG_FBA_2] = &GIFRegHandlerFBA_2;
-	g_GIFRegHandlers[GIF_A_D_REG_FRAME_1] = &GIFRegHandlerFRAME_1;
-	g_GIFRegHandlers[GIF_A_D_REG_FRAME_2] = &GIFRegHandlerFRAME_2;
-	g_GIFRegHandlers[GIF_A_D_REG_ZBUF_1] = &GIFRegHandlerZBUF_1;
-	g_GIFRegHandlers[GIF_A_D_REG_ZBUF_2] = &GIFRegHandlerZBUF_2;
+	g_GIFRegHandlers[GIF_A_D_REG_FBA_1] = &GIFRegHandlerFBA<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_FBA_2] = &GIFRegHandlerFBA<1>;
+	g_GIFRegHandlers[GIF_A_D_REG_FRAME_1] = &GIFRegHandlerFRAME<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_FRAME_2] = &GIFRegHandlerFRAME<1>;
+	g_GIFRegHandlers[GIF_A_D_REG_ZBUF_1] = &GIFRegHandlerZBUF<0>;
+	g_GIFRegHandlers[GIF_A_D_REG_ZBUF_2] = &GIFRegHandlerZBUF<1>;
 	g_GIFRegHandlers[GIF_A_D_REG_BITBLTBUF] = &GIFRegHandlerBITBLTBUF;
 	g_GIFRegHandlers[GIF_A_D_REG_TRXPOS] = &GIFRegHandlerTRXPOS;
 	g_GIFRegHandlers[GIF_A_D_REG_TRXREG] = &GIFRegHandlerTRXREG;
@@ -1237,8 +951,8 @@
 		g_GIFPackedRegHandlers[GIF_REG_UV] = &GIFPackedRegHandlerUV;
 		g_GIFPackedRegHandlers[GIF_REG_XYZF2] = &GIFPackedRegHandlerXYZF2;
 		g_GIFPackedRegHandlers[GIF_REG_XYZ2] = &GIFPackedRegHandlerXYZ2;
-		g_GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP_1;
-		g_GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP_2;
+		g_GIFPackedRegHandlers[GIF_REG_CLAMP_1] = &GIFPackedRegHandlerCLAMP<0>;
+		g_GIFPackedRegHandlers[GIF_REG_CLAMP_2] = &GIFPackedRegHandlerCLAMP<1>;
 		g_GIFPackedRegHandlers[GIF_REG_FOG] = &GIFPackedRegHandlerFOG;
 		g_GIFPackedRegHandlers[GIF_REG_XYZF3] = &GIFPackedRegHandlerXYZF3;
 		g_GIFPackedRegHandlers[GIF_REG_XYZ3] = &GIFPackedRegHandlerXYZ3;

 

  ViewVC Help
Powered by ViewVC 1.1.22