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

Contents of /trunk/pcsx2/VUmicroMem.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (show annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 4 months ago) by william
File size: 2884 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16
17 #include "PrecompiledHeader.h"
18 #include "Common.h"
19 #include "VUmicro.h"
20
21 __aligned16 VURegs vuRegs[2];
22
23 static u8* m_vuAllMem = NULL;
24 static const uint m_vuMemSize =
25 0x1000 + // VU0micro memory
26 0x4000 + // VU0 memory
27 0x4000 + // VU1 memory
28 0x4000;
29
30 void vuMicroMemAlloc()
31 {
32 if( m_vuAllMem == NULL )
33 m_vuAllMem = vtlb_malloc( m_vuMemSize, 16 );
34
35 if( m_vuAllMem == NULL )
36 throw Exception::OutOfMemory( L"VU0 and VU1 on-chip memory" );
37
38 u8* curpos = m_vuAllMem;
39 VU0.Micro = curpos; curpos += 0x1000;
40 VU0.Mem = curpos; curpos += 0x4000;
41 VU1.Micro = curpos; curpos += 0x4000;
42 VU1.Mem = curpos;
43 //curpos += 0x4000;
44 }
45
46 void vuMicroMemShutdown()
47 {
48 // -- VTLB Memory Allocation --
49
50 vtlb_free( m_vuAllMem, m_vuMemSize );
51 m_vuAllMem = NULL;
52 }
53
54 void vuMicroMemReset()
55 {
56 pxAssume( VU0.Mem != NULL );
57 pxAssume( VU1.Mem != NULL );
58
59 memMapVUmicro();
60
61 // === VU0 Initialization ===
62 memzero(VU0.ACC);
63 memzero(VU0.VF);
64 memzero(VU0.VI);
65 VU0.VF[0].f.x = 0.0f;
66 VU0.VF[0].f.y = 0.0f;
67 VU0.VF[0].f.z = 0.0f;
68 VU0.VF[0].f.w = 1.0f;
69 VU0.VI[0].UL = 0;
70 memzero_ptr<4*1024>(VU0.Mem);
71 memzero_ptr<4*1024>(VU0.Micro);
72
73 // === VU1 Initialization ===
74 memzero(VU1.ACC);
75 memzero(VU1.VF);
76 memzero(VU1.VI);
77 VU1.VF[0].f.x = 0.0f;
78 VU1.VF[0].f.y = 0.0f;
79 VU1.VF[0].f.z = 0.0f;
80 VU1.VF[0].f.w = 1.0f;
81 VU1.VI[0].UL = 0;
82 memzero_ptr<16*1024>(VU1.Mem);
83 memzero_ptr<16*1024>(VU1.Micro);
84 }
85
86 void SaveStateBase::vuMicroFreeze()
87 {
88 FreezeTag( "vuMicro" );
89
90 pxAssume( VU0.Mem != NULL );
91 pxAssume( VU1.Mem != NULL );
92
93 Freeze(VU0.ACC);
94
95 // Seemingly silly and pointless use of temp var: GCC is unable to bind packed fields
96 // (appears to be a bug, tracked here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36566 ).
97 // Dereferencing outside the context of the function (via a temp var) seems to circumvent it. --air
98
99 u32& temp_vu0_code = VU0.code;
100 Freeze(temp_vu0_code);
101
102 FreezeMem(VU0.Mem, 4*1024);
103 FreezeMem(VU0.Micro, 4*1024);
104
105 Freeze(VU0.VF);
106 Freeze(VU0.VI);
107
108 Freeze(VU1.ACC);
109
110 u32& temp_vu1_code = VU1.code;
111 Freeze(temp_vu1_code);
112
113 FreezeMem(VU1.Mem, 16*1024);
114 FreezeMem(VU1.Micro, 16*1024);
115
116 Freeze(VU1.VF);
117 Freeze(VU1.VI);
118 }

  ViewVC Help
Powered by ViewVC 1.1.22