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

Contents of /trunk/pcsx2/R3000AInterpreter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (show annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 5 months ago) by william
File size: 4220 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 "IopCommon.h"
19
20 using namespace R3000A;
21
22 // Used to flag delay slot instructions when throwig exceptions.
23 bool iopIsDelaySlot = false;
24
25 static bool branch2 = 0;
26 static u32 branchPC;
27
28 static void doBranch(s32 tar); // forward declared prototype
29
30 /*********************************************************
31 * Register branch logic *
32 * Format: OP rs, offset *
33 *********************************************************/
34
35 void psxBGEZ() // Branch if Rs >= 0
36 {
37 if (_i32(_rRs_) >= 0) doBranch(_BranchTarget_);
38 }
39
40 void psxBGEZAL() // Branch if Rs >= 0 and link
41 {
42 if (_i32(_rRs_) >= 0)
43 {
44 _SetLink(31);
45 doBranch(_BranchTarget_);
46 }
47 }
48
49 void psxBGTZ() // Branch if Rs > 0
50 {
51 if (_i32(_rRs_) > 0) doBranch(_BranchTarget_);
52 }
53
54 void psxBLEZ() // Branch if Rs <= 0
55 {
56 if (_i32(_rRs_) <= 0) doBranch(_BranchTarget_);
57 }
58 void psxBLTZ() // Branch if Rs < 0
59 {
60 if (_i32(_rRs_) < 0) doBranch(_BranchTarget_);
61 }
62
63 void psxBLTZAL() // Branch if Rs < 0 and link
64 {
65 if (_i32(_rRs_) < 0)
66 {
67 _SetLink(31);
68 doBranch(_BranchTarget_);
69 }
70 }
71
72 /*********************************************************
73 * Register branch logic *
74 * Format: OP rs, rt, offset *
75 *********************************************************/
76
77 void psxBEQ() // Branch if Rs == Rt
78 {
79 if (_i32(_rRs_) == _i32(_rRt_)) doBranch(_BranchTarget_);
80 }
81
82 void psxBNE() // Branch if Rs != Rt
83 {
84 if (_i32(_rRs_) != _i32(_rRt_)) doBranch(_BranchTarget_);
85 }
86
87 /*********************************************************
88 * Jump to target *
89 * Format: OP target *
90 *********************************************************/
91 void psxJ()
92 {
93 // check for iop module import table magic
94 u32 delayslot = iopMemRead32(psxRegs.pc);
95 if (delayslot >> 16 == 0x2400 && irxImportExec(irxImportLibname(psxRegs.pc), delayslot & 0xffff))
96 return;
97
98 doBranch(_JumpTarget_);
99 }
100
101 void psxJAL()
102 {
103 _SetLink(31);
104 doBranch(_JumpTarget_);
105 }
106
107 /*********************************************************
108 * Register jump *
109 * Format: OP rs, rd *
110 *********************************************************/
111 void psxJR()
112 {
113 doBranch(_u32(_rRs_));
114 }
115
116 void psxJALR()
117 {
118 if (_Rd_)
119 {
120 _SetLink(_Rd_);
121 }
122 doBranch(_u32(_rRs_));
123 }
124
125 ///////////////////////////////////////////
126 // These macros are used to assemble the repassembler functions
127
128 static __fi void execI()
129 {
130 psxRegs.code = iopMemRead32(psxRegs.pc);
131
132 PSXCPU_LOG("%s", disR3000AF(psxRegs.code, psxRegs.pc));
133
134 psxRegs.pc+= 4;
135 psxRegs.cycle++;
136 iopCycleEE-=8;
137
138 psxBSC[psxRegs.code >> 26]();
139 }
140
141
142 static void doBranch(s32 tar) {
143 branch2 = iopIsDelaySlot = true;
144 branchPC = tar;
145 execI();
146 PSXCPU_LOG( "\n" );
147 iopIsDelaySlot = false;
148 psxRegs.pc = branchPC;
149
150 iopEventTest();
151 }
152
153 static void intAlloc() {
154 }
155
156 static void intReset() {
157 }
158
159 static void intExecute() {
160 for (;;) execI();
161 }
162
163 static s32 intExecuteBlock( s32 eeCycles )
164 {
165 iopBreak = 0;
166 iopCycleEE = eeCycles;
167
168 while (iopCycleEE > 0){
169 branch2 = 0;
170 while (!branch2) {
171 execI();
172 }
173 }
174 return iopBreak + iopCycleEE;
175 }
176
177 static void intClear(u32 Addr, u32 Size) {
178 }
179
180 static void intShutdown() {
181 }
182
183 R3000Acpu psxInt = {
184 intAlloc,
185 intReset,
186 intExecute,
187 intExecuteBlock,
188 intClear,
189 intShutdown
190 };

  ViewVC Help
Powered by ViewVC 1.1.22