/[pcsx2_0.9.7]/trunk/pcsx2/VU.h
ViewVC logotype

Annotation of /trunk/pcsx2/VU.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (hide annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (10 years, 2 months ago) by william
File MIME type: text/plain
File size: 4423 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
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     #pragma once
17     #include "Vif.h"
18    
19     enum VURegFlags
20     {
21     REG_STATUS_FLAG = 16,
22     REG_MAC_FLAG = 17,
23     REG_CLIP_FLAG = 18,
24     REG_ACC_FLAG = 19, // dummy flag that indicates that VFACC is written/read (nothing to do with VI[19])
25     REG_R = 20,
26     REG_I = 21,
27     REG_Q = 22,
28     REG_P = 23, // only exists in micromode
29     REG_VF0_FLAG = 24, // dummy flag that indicates VF0 is read (nothing to do with VI[24])
30     REG_TPC = 26,
31     REG_CMSAR0 = 27,
32     REG_FBRST = 28,
33     REG_VPU_STAT = 29,
34     REG_CMSAR1 = 31
35     };
36    
37     //interpreter hacks, WIP
38     //#define INT_VUSTALLHACK //some games work without those, big speedup
39     //#define INT_VUDOUBLEHACK
40    
41     enum VUStatus {
42     VU_Ready = 0,
43     VU_Run = 1,
44     VU_Stop = 2,
45     };
46    
47     union VECTOR {
48     struct {
49     float x,y,z,w;
50     } f;
51     struct {
52     u32 x,y,z,w;
53     } i;
54    
55     float F[4];
56    
57 william 62 u128 UQ;
58     s128 SQ;
59 william 31 u64 UD[2]; //128 bits
60     s64 SD[2];
61     u32 UL[4];
62     s32 SL[4];
63     u16 US[8];
64     s16 SS[8];
65     u8 UC[16];
66     s8 SC[16];
67     };
68    
69     struct REG_VI {
70     union {
71     float F;
72     s32 SL;
73     u32 UL;
74     s16 SS[2];
75     u16 US[2];
76     s8 SC[4];
77     u8 UC[4];
78     };
79     u32 padding[3]; // needs padding to make them 128bit; VU0 maps VU1's VI regs as 128bits to addr 0x4xx0 in
80     // VU0 mem, with only lower 16 bits valid, and the upper 112bits are hardwired to 0 (cottonvibes)
81     };
82    
83     //#define VUFLAG_BREAKONMFLAG 0x00000001
84     #define VUFLAG_MFLAGSET 0x00000002
85    
86     struct fdivPipe {
87     int enable;
88     REG_VI reg;
89     u32 sCycle;
90     u32 Cycle;
91     u32 statusflag;
92     };
93    
94     struct efuPipe {
95     int enable;
96     REG_VI reg;
97     u32 sCycle;
98     u32 Cycle;
99     };
100    
101     struct fmacPipe {
102     int enable;
103     int reg;
104     int xyzw;
105     u32 sCycle;
106     u32 Cycle;
107     u32 macflag;
108     u32 statusflag;
109     u32 clipflag;
110     };
111    
112     struct ialuPipe {
113     int enable;
114     int reg;
115     u32 sCycle;
116     u32 Cycle;
117     };
118    
119 william 62 struct __aligned16 VURegs {
120 william 31 VECTOR VF[32]; // VF and VI need to be first in this struct for proper mapping
121     REG_VI VI[32]; // needs to be 128bit x 32 (cottonvibes)
122 william 62
123 william 31 VECTOR ACC;
124     REG_VI q;
125     REG_VI p;
126    
127 william 62 uint idx; // VU index (0 or 1)
128 william 31
129 william 62 // flags/cycle are needed by VIF dma code, so they have to be here (for now)
130     // We may replace these by accessors in the future, if merited.
131 william 31 u32 cycle;
132     u32 flags;
133    
134 william 62 // Current opcode being interpreted or recompiled (this var is used by Interps and superVU
135     // but not microVU. Would like to have it local to their respective classes... someday)
136     u32 code;
137 william 31
138 william 62 // branch/branchpc are used by interpreter only, but making them local to the interpreter
139     // classes requires considerable code refactoring. Maybe later. >_<
140     u32 branch;
141     u32 branchpc;
142    
143     // MAC/Status flags -- these are used by interpreters and superVU, but are kind of hacky
144     // and shouldn't be relied on for any useful/valid info. Would like to move them out of
145     // this struct eventually.
146     u32 macflag;
147     u32 statusflag;
148     u32 clipflag;
149    
150 william 31 u8 *Mem;
151     u8 *Micro;
152    
153 william 62 u32 ebit;
154 william 31
155     fmacPipe fmac[8];
156     fdivPipe fdiv;
157     efuPipe efu;
158     ialuPipe ialu[8];
159    
160 william 62 VURegs()
161 william 31 {
162 william 62 Mem = NULL;
163     Micro = NULL;
164 william 31 }
165 william 62
166     bool IsVU1() const;
167     bool IsVU0() const;
168    
169     VIFregisters& GetVifRegs() const
170     {
171     return IsVU1() ? vif1Regs : vif0Regs;
172     }
173 william 31 };
174 william 62
175 william 31 enum VUPipeState
176     {
177     VUPIPE_NONE = 0,
178     VUPIPE_FMAC,
179     VUPIPE_FDIV,
180     VUPIPE_EFU,
181     VUPIPE_IALU,
182     VUPIPE_BRANCH,
183     VUPIPE_XGKICK
184     };
185    
186 william 62 extern __aligned16 VURegs vuRegs[2];
187 william 31
188 william 62 // Obsolete(?) -- I think I'd rather use vu0Regs/vu1Regs or actually have these explicit to any
189     // CPP file that needs them only. --air
190     static VURegs& VU0 = vuRegs[0];
191     static VURegs& VU1 = vuRegs[1];
192 william 31
193 william 62 // Do not use __fi here because it fires 'multiple definition' error in GCC
194     inline bool VURegs::IsVU1() const { return this == &vuRegs[1]; }
195     inline bool VURegs::IsVU0() const { return this == &vuRegs[0]; }
196 william 31
197     extern u32* GET_VU_MEM(VURegs* VU, u32 addr);
198    

  ViewVC Help
Powered by ViewVC 1.1.22