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

Annotation of /trunk/pcsx2/VUmicroMem.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (hide annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (9 years, 11 months ago) by william
File size: 3229 byte(s)
committing r3113 initial commit again...
1 william 31 /* 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     static u8* m_vuAllMem = NULL;
22     static const uint m_vuMemSize =
23     0x1000 + // VU0micro memory
24     0x4000+0x800 + // VU0 memory and VU1 registers
25     0x4000 + // VU1 memory
26     0x4000;
27    
28     void vuMicroMemAlloc()
29     {
30     if( m_vuAllMem == NULL )
31     m_vuAllMem = vtlb_malloc( m_vuMemSize, 16 );
32    
33     if( m_vuAllMem == NULL )
34     throw Exception::OutOfMemory( "vuMicroMemInit > Failed to allocate VUmicro memory." );
35    
36     jASSUME( sizeof( VURegs ) <= 0x800 );
37    
38     u8* curpos = m_vuAllMem;
39     VU0.Micro = curpos; curpos += 0x1000;
40     VU0.Mem = curpos; curpos += 0x4000;
41     g_pVU1 = (VURegs*)curpos; curpos += 0x800;
42     VU1.Micro = curpos; curpos += 0x4000;
43     VU1.Mem = curpos;
44     //curpos += 0x4000;
45     }
46    
47     void vuMicroMemShutdown()
48     {
49     // -- VTLB Memory Allocation --
50    
51     vtlb_free( m_vuAllMem, m_vuMemSize );
52     m_vuAllMem = NULL;
53     g_pVU1 = NULL;
54     }
55    
56     void vuMicroMemReset()
57     {
58     jASSUME( VU0.Mem != NULL );
59     jASSUME( VU1.Mem != NULL );
60    
61     memMapVUmicro();
62    
63     // === VU0 Initialization ===
64     memzero(VU0.ACC);
65     memzero(VU0.VF);
66     memzero(VU0.VI);
67     VU0.VF[0].f.x = 0.0f;
68     VU0.VF[0].f.y = 0.0f;
69     VU0.VF[0].f.z = 0.0f;
70     VU0.VF[0].f.w = 1.0f;
71     VU0.VI[0].UL = 0;
72     memzero_ptr<4*1024>(VU0.Mem);
73     memzero_ptr<4*1024>(VU0.Micro);
74    
75     /* this is kinda tricky, maxmem is set to 0x4400 here,
76     tho it's not 100% accurate, since the mem goes from
77     0x0000 - 0x1000 (Mem) and 0x4000 - 0x4400 (VU1 Regs),
78     i guess it shouldn't be a problem,
79     at least hope so :) (linuz)
80     */
81     VU0.maxmem = 0x4800-4; //We are allocating 0x800 for vu1 reg's
82     VU0.maxmicro = 0x1000-4;
83     VU0.vuExec = vu0Exec;
84     VU0.vifRegs = vif0Regs;
85    
86     // === VU1 Initialization ===
87     memzero(VU1.ACC);
88     memzero(VU1.VF);
89     memzero(VU1.VI);
90     VU1.VF[0].f.x = 0.0f;
91     VU1.VF[0].f.y = 0.0f;
92     VU1.VF[0].f.z = 0.0f;
93     VU1.VF[0].f.w = 1.0f;
94     VU1.VI[0].UL = 0;
95     memzero_ptr<16*1024>(VU1.Mem);
96     memzero_ptr<16*1024>(VU1.Micro);
97    
98     VU1.maxmem = 0x4000-4;//16*1024-4;
99     VU1.maxmicro = 0x4000-4;
100     // VU1.VF = (VECTOR*)(VU0.Mem + 0x4000);
101     // VU1.VI = (REG_VI*)(VU0.Mem + 0x4200);
102     VU1.vuExec = vu1Exec;
103     VU1.vifRegs = vif1Regs;
104     }
105    
106     void SaveStateBase::vuMicroFreeze()
107     {
108     FreezeTag( "vuMicro" );
109    
110     jASSUME( VU0.Mem != NULL );
111     jASSUME( VU1.Mem != NULL );
112    
113     Freeze(VU0.ACC);
114     Freeze(VU0.code);
115     FreezeMem(VU0.Mem, 4*1024);
116     FreezeMem(VU0.Micro, 4*1024);
117    
118     Freeze(VU0.VF);
119     Freeze(VU0.VI);
120    
121     Freeze(VU1.ACC);
122     Freeze(VU1.code);
123     FreezeMem(VU1.Mem, 16*1024);
124     FreezeMem(VU1.Micro, 16*1024);
125    
126     Freeze(VU1.VF);
127     Freeze(VU1.VI);
128     }

  ViewVC Help
Powered by ViewVC 1.1.22