/[pcsx2_0.9.7]/trunk/pcsx2/VUmicroMem.cpp
ViewVC logotype

Diff of /trunk/pcsx2/VUmicroMem.cpp

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

--- trunk/pcsx2/VUmicroMem.cpp	2010/09/07 03:24:11	31
+++ trunk/pcsx2/VUmicroMem.cpp	2010/09/07 11:08:22	62
@@ -18,10 +18,12 @@
 #include "Common.h"
 #include "VUmicro.h"
 
+__aligned16 VURegs vuRegs[2];
+
 static u8* m_vuAllMem = NULL;
 static const uint m_vuMemSize =
 	0x1000 +					// VU0micro memory
-	0x4000+0x800 +				// VU0 memory and VU1 registers
+	0x4000 +					// VU0 memory
 	0x4000 +					// VU1 memory
 	0x4000;
 
@@ -31,14 +33,11 @@
 		m_vuAllMem = vtlb_malloc( m_vuMemSize, 16 );
 
 	if( m_vuAllMem == NULL )
-		throw Exception::OutOfMemory( "vuMicroMemInit > Failed to allocate VUmicro memory." );
-
-	jASSUME( sizeof( VURegs ) <= 0x800 );
+		throw Exception::OutOfMemory( L"VU0 and VU1 on-chip memory" );
 
 	u8* curpos = m_vuAllMem;
 	VU0.Micro	= curpos; curpos += 0x1000;
 	VU0.Mem		= curpos; curpos += 0x4000;
-	g_pVU1		= (VURegs*)curpos; curpos += 0x800;
 	VU1.Micro	= curpos; curpos += 0x4000;
 	VU1.Mem		= curpos;
 	 //curpos += 0x4000;
@@ -50,13 +49,12 @@
 
 	vtlb_free( m_vuAllMem, m_vuMemSize );
 	m_vuAllMem = NULL;
-	g_pVU1 = NULL;
 }
 
 void vuMicroMemReset()
 {
-	jASSUME( VU0.Mem != NULL );
-	jASSUME( VU1.Mem != NULL );
+	pxAssume( VU0.Mem != NULL );
+	pxAssume( VU1.Mem != NULL );
 
 	memMapVUmicro();
 
@@ -72,17 +70,6 @@
 	memzero_ptr<4*1024>(VU0.Mem);
 	memzero_ptr<4*1024>(VU0.Micro);
 
-	/* this is kinda tricky, maxmem is set to 0x4400 here,
-	   tho it's not 100% accurate, since the mem goes from
-	   0x0000 - 0x1000 (Mem) and 0x4000 - 0x4400 (VU1 Regs),
-	   i guess it shouldn't be a problem,
-	   at least hope so :) (linuz)
-	*/
-	VU0.maxmem = 0x4800-4; //We are allocating 0x800 for vu1 reg's
-	VU0.maxmicro = 0x1000-4;
-	VU0.vuExec = vu0Exec;
-	VU0.vifRegs = vif0Regs;
-
 	// === VU1 Initialization ===
 	memzero(VU1.ACC);
 	memzero(VU1.VF);
@@ -94,24 +81,24 @@
 	VU1.VI[0].UL = 0;
 	memzero_ptr<16*1024>(VU1.Mem);
 	memzero_ptr<16*1024>(VU1.Micro);
-
-	VU1.maxmem   = 0x4000-4;//16*1024-4;
-	VU1.maxmicro = 0x4000-4;
-//	VU1.VF       = (VECTOR*)(VU0.Mem + 0x4000);
-//	VU1.VI       = (REG_VI*)(VU0.Mem + 0x4200);
-	VU1.vuExec   = vu1Exec;
-	VU1.vifRegs  = vif1Regs;
 }
 
 void SaveStateBase::vuMicroFreeze()
 {
 	FreezeTag( "vuMicro" );
 
-	jASSUME( VU0.Mem != NULL );
-	jASSUME( VU1.Mem != NULL );
+	pxAssume( VU0.Mem != NULL );
+	pxAssume( VU1.Mem != NULL );
 
 	Freeze(VU0.ACC);
-	Freeze(VU0.code);
+
+	// Seemingly silly and pointless use of temp var:  GCC is unable to bind packed fields
+	// (appears to be a bug, tracked here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36566 ).
+	// Dereferencing outside the context of the function (via a temp var) seems to circumvent it. --air
+	
+	u32& temp_vu0_code = VU0.code;
+	Freeze(temp_vu0_code);
+
 	FreezeMem(VU0.Mem,   4*1024);
 	FreezeMem(VU0.Micro, 4*1024);
 
@@ -119,7 +106,10 @@
 	Freeze(VU0.VI);
 
 	Freeze(VU1.ACC);
-	Freeze(VU1.code);
+
+	u32& temp_vu1_code = VU1.code;
+	Freeze(temp_vu1_code);
+
 	FreezeMem(VU1.Mem,   16*1024);
 	FreezeMem(VU1.Micro, 16*1024);
 

 

  ViewVC Help
Powered by ViewVC 1.1.22