/[pcsx2_0.9.7]/trunk/pcsx2/x86/microVU_Execute.inl
ViewVC logotype

Contents of /trunk/pcsx2/x86/microVU_Execute.inl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File size: 4938 byte(s)
re-commit (had local access denied errors when committing)
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 #pragma once
17
18 //------------------------------------------------------------------
19 // Dispatcher Functions
20 //------------------------------------------------------------------
21
22 // Generates the code for entering recompiled blocks
23 void mVUdispatcherA(mV) {
24 mVU->startFunct = x86Ptr;
25
26 // Backup cpu state
27 xPUSH(ebp);
28 xPUSH(ebx);
29 xPUSH(esi);
30 xPUSH(edi);
31
32 // Align the stackframe (GCC only, since GCC assumes stackframe is always aligned)
33 #ifdef __GNUC__
34 xSUB(esp, 12);
35 #endif
36
37 // __fastcall = The caller has already put the needed parameters in ecx/edx:
38 if (!isVU1) { xCALL(mVUexecuteVU0); }
39 else { xCALL(mVUexecuteVU1); }
40
41 // Load VU's MXCSR state
42 xLDMXCSR(g_sseVUMXCSR);
43
44 // Load Regs
45 #if 1 // CHECK_MACROVU0 - Always on now
46 xMOV(gprF0, ptr32[&mVU->regs().VI[REG_STATUS_FLAG].UL]);
47 xMOV(gprF1, gprF0);
48 xMOV(gprF2, gprF0);
49 xMOV(gprF3, gprF0);
50 #else
51 mVUallocSFLAGd((uptr)&mVU->regs().VI[REG_STATUS_FLAG].UL, 1);
52 #endif
53
54 xMOVAPS(xmmT1, ptr128[&mVU->regs().VI[REG_MAC_FLAG].UL]);
55 xSHUF.PS(xmmT1, xmmT1, 0);
56 xMOVAPS(ptr128[mVU->macFlag], xmmT1);
57
58 xMOVAPS(xmmT1, ptr128[&mVU->regs().VI[REG_CLIP_FLAG].UL]);
59 xSHUF.PS(xmmT1, xmmT1, 0);
60 xMOVAPS(ptr128[mVU->clipFlag], xmmT1);
61
62 xMOVAPS(xmmT1, ptr128[&mVU->regs().VI[REG_P].UL]);
63 xMOVAPS(xmmPQ, ptr128[&mVU->regs().VI[REG_Q].UL]);
64 xSHUF.PS(xmmPQ, xmmT1, 0); // wzyx = PPQQ
65
66 // Jump to Recompiled Code Block
67 xJMP(eax);
68 }
69
70 // Generates the code to exit from recompiled blocks
71 void mVUdispatcherB(mV) {
72 mVU->exitFunct = x86Ptr;
73
74 // Load EE's MXCSR state
75 xLDMXCSR(g_sseMXCSR);
76
77 // __fastcall = The first two DWORD or smaller arguments are passed in ECX and EDX registers;
78 // all other arguments are passed right to left.
79 if (!isVU1) { xCALL(mVUcleanUpVU0); }
80 else { xCALL(mVUcleanUpVU1); }
81
82 // Unalign the stackframe:
83 #ifdef __GNUC__
84 xADD( esp, 12 );
85 #endif
86
87 // Restore cpu state
88 xPOP(edi);
89 xPOP(esi);
90 xPOP(ebx);
91 xPOP(ebp);
92
93 xRET();
94
95 pxAssertDev(xGetPtr() < (mVU->dispCache + mVUdispCacheSize), "microVU: Dispatcher generation exceeded reserved cache area!");
96 }
97
98 //------------------------------------------------------------------
99 // Execution Functions
100 //------------------------------------------------------------------
101
102 // Executes for number of cycles
103 _mVUt void* __fastcall mVUexecute(u32 startPC, u32 cycles) {
104
105 microVU* mVU = mVUx;
106 //DevCon.WriteLn("microVU%x: startPC = 0x%x, cycles = 0x%x", vuIndex, startPC, cycles);
107
108 mVU->cycles = cycles;
109 mVU->totalCycles = cycles;
110
111 xSetPtr(mVU->prog.x86ptr); // Set x86ptr to where last program left off
112 return mVUsearchProg<vuIndex>(startPC, (uptr)&mVU->prog.lpState); // Find and set correct program
113 }
114
115 //------------------------------------------------------------------
116 // Cleanup Functions
117 //------------------------------------------------------------------
118
119 _mVUt void mVUcleanUp() {
120 microVU* mVU = mVUx;
121 //mVUprint("microVU: Program exited successfully!");
122 //mVUprint("microVU: VF0 = {%x,%x,%x,%x}", mVU->regs().VF[0].UL[0], mVU->regs().VF[0].UL[1], mVU->regs().VF[0].UL[2], mVU->regs().VF[0].UL[3]);
123 //mVUprint("microVU: VI0 = %x", mVU->regs().VI[0].UL);
124
125 mVU->prog.x86ptr = x86Ptr;
126
127 if ((xGetPtr() < mVU->prog.x86start) || (xGetPtr() >= mVU->prog.x86end)) {
128 Console.WriteLn(vuIndex ? Color_Orange : Color_Magenta, "microVU%d: Program cache limit reached.", mVU->index);
129 mVU->reset();
130 }
131
132 mVU->cycles = mVU->totalCycles - mVU->cycles;
133 mVU->regs().cycle += mVU->cycles;
134 cpuRegs.cycle += ((mVU->cycles < 3000) ? mVU->cycles : 3000) * EmuConfig.Speedhacks.VUCycleSteal;
135 //static int ax = 0; ax++;
136 //if (!(ax % 100000)) {
137 // for (u32 i = 0; i < (mVU->progSize / 2); i++) {
138 // if (mVUcurProg.block[i]) {
139 // mVUcurProg.block[i]->printInfo(i*8);
140 // }
141 // }
142 //}
143 }
144
145 //------------------------------------------------------------------
146 // Caller Functions
147 //------------------------------------------------------------------
148
149 void* __fastcall mVUexecuteVU0(u32 startPC, u32 cycles) { return mVUexecute<0>(startPC, cycles); }
150 void* __fastcall mVUexecuteVU1(u32 startPC, u32 cycles) { return mVUexecute<1>(startPC, cycles); }
151 void __fastcall mVUcleanUpVU0() { mVUcleanUp<0>(); }
152 void __fastcall mVUcleanUpVU1() { mVUcleanUp<1>(); }

  ViewVC Help
Powered by ViewVC 1.1.22