Debian Codegraph @

mednafen/hw_cpu/v810/v810_cpu.cpp

raw symbols SCIP
1 /* V810 Emulator
2 *
3 * Copyright (C) 2006 David Tucker
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 /* Alternatively, the V810 emulator code(and all V810 emulation header files) can be used/distributed under the following license(you can adopt either
21 license exclusively for your changes by removing one of these license headers, but it's STRONGLY preferable
22 to keep your changes dual-licensed as well):
23
24 This Reality Boy emulator is copyright (C) David Tucker 1997-2008, all rights
25 reserved. You may use this code as long as you make no money from the use of
26 this code and you acknowledge the original author (Me). I reserve the right to
27 dictate who can use this code and how (Just so you don't do something stupid
28 with it).
29 Most Importantly, this code is swap ware. If you use It send along your new
30 program (with code) or some other interesting tidbits you wrote, that I might be
31 interested in.
32 This code is in beta, there are bugs! I am not responsible for any damage
33 done to your computer, reputation, ego, dog, or family life due to the use of
34 this code. All source is provided as is, I make no guaranties, and am not
35 responsible for anything you do with the code (legal or otherwise).
36 Virtual Boy is a trademark of Nintendo, and V810 is a trademark of NEC. I am
37 in no way affiliated with either party and all information contained hear was
38 found freely through public domain sources.
39 */
40
41 //////////////////////////////////////////////////////////
42 // CPU routines
43
44 #include <boolean.h>cxx . . $ `<file>/boolean.h`/
45
46 #include "../../mednafen.h"cxx . . $ `<file>/mednafen/mednafen.h`/
47 #include "../../masmem.h"cxx . . $ `<file>/mednafen/masmem.h`/
48
49 //#include "pcfx.h"
50 //#include "debug.h"
51
52 #include <string.h>
53 #include <errno.h>
54
55 #include "v810_opt.h"cxx . . $ `<file>/mednafen/hw_cpu/v810/v810_opt.h`/
56 #include "v810_cpu.h"cxx . . $ `<file>/mednafen/hw_cpu/v810/v810_cpu.h`/
57 #include "v810_cpuD.h"cxx . . $ `<file>/mednafen/hw_cpu/v810/v810_cpuD.h`/
58
59 //#include "fpu-new/softfloat.h"
60
61 V810cxx . . $ V810#::V810cxx . . $ V810#V810(49f6e7a06ebc5aa8).()
62 {
63 #ifdef WANT_DEBUGGER
64 CPUHook = NULL;
65 ADDBT = NULL;
66 #endif
67
68 MemRead8cxx . . $ V810#MemRead8. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
69 MemRead16cxx . . $ V810#MemRead16. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
70 MemRead32cxx . . $ V810#MemRead32. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
71
72 IORead8cxx . . $ V810#IORead8. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
73 IORead16cxx . . $ V810#IORead16. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
74 IORead32cxx . . $ V810#IORead32. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
75
76 MemWrite8cxx . . $ V810#MemWrite8. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
77 MemWrite16cxx . . $ V810#MemWrite16. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
78 MemWrite32cxx . . $ V810#MemWrite32. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
79
80 IOWrite8cxx . . $ V810#IOWrite8. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
81 IOWrite16cxx . . $ V810#IOWrite16. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
82 IOWrite32cxx . . $ V810#IOWrite32. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
83
84 memset(FastMapcxx . . $ V810#FastMap., 0, sizeof(FastMapcxx . . $ V810#FastMap.));
85
86 memset(MemReadBus32cxx . . $ V810#MemReadBus32., 0, sizeof(MemReadBus32cxx . . $ V810#MemReadBus32.));
87 memset(MemWriteBus32cxx . . $ V810#MemWriteBus32., 0, sizeof(MemWriteBus32cxx . . $ V810#MemWriteBus32.));
88
89 v810_timestampcxx . . $ V810#v810_timestamp. = 0;
90 next_event_tscxx . . $ V810#next_event_ts. = 0x7FFFFFFF;
91 }
92
93 V810cxx . . $ V810#::~cxx . . $ V810#`~V810`(ced63f7c635d850d).V810cxx . . $ V810#()
94 {
95
96 }
97
98 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void V810cxx . . $ V810#::RecalcIPendingCachecxx . . $ V810#RecalcIPendingCache(49f6e7a06ebc5aa8).(void)
99 {
100 IPendingCachecxx . . $ V810#IPendingCache. = 0;
101
102 // Of course don't generate an interrupt if there's not one pending!
103 if(ilevelcxx . . $ V810#ilevel. < 0)
104 return;
105
106 // If CPU is halted because of a fatal exception, don't let an interrupt
107 // take us out of this halted status.
108 if(Haltedcxx . . $ V810#Halted. == HALT_FATAL_EXCEPTIONcxx . . $ V810#HALT_FATAL_EXCEPTION.)
109 return;
110
111 // If the NMI pending, exception pending, and/or interrupt disabled bit
112 // is set, don't accept any interrupts.
113 if(S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] & (PSW_NPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:60:9`! | PSW_EPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:61:9`! | PSW_IDcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:65:9`!))
114 return;
115
116 // If the interrupt level is lower than the interrupt enable level, don't
117 // accept it.
118 if(ilevelcxx . . $ V810#ilevel. < (int)((S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] & PSW_IAcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:54:9`!) >> 16))
119 return;
120
121 IPendingCachecxx . . $ V810#IPendingCache. = 0xFF;
122 }
123
124
125 // TODO: "An interrupt that occurs during restore/dump/clear operation is internally held and is accepted after the
126 // operation in progress is finished. The maskable interrupt is held internally only when the EP, NP, and ID flags
127 // of PSW are all 0."
128 //
129 // This behavior probably doesn't have any relevance on the PC-FX, unless we're sadistic
130 // and try to restore cache from an interrupt acknowledge register or dump it to a register
131 // controlling interrupt masks... I wanna be sadistic~
132
133 void V810cxx . . $ V810#::CacheClearcxx . . $ V810#CacheClear(89f8e5bd0b04bfaa).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, uint32cxx . . $ uint32# start, uint32cxx . . $ uint32# count)
134 {
135 //printf("Cache clear: %08x %08x\n", start, count);
136 for(uint32cxx . . $ uint32# i = 0; i < count && (i + start) < 128; i++)
137 memset(&Cachecxx . . $ V810#Cache.[i + start], 0, sizeof(V810_CacheEntry_tcxx . . $ V810#V810_CacheEntry_t#));
138 }
139
140 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void V810cxx . . $ V810#::CacheOpMemStorecxx . . $ V810#CacheOpMemStore(89f8e5bd0b04bfaa).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, uint32cxx . . $ uint32# A, uint32cxx . . $ uint32# V)
141 {
142 if(MemWriteBus32cxx . . $ V810#MemWriteBus32.[A >> 24])
143 {
144 timestamp += 2;
145 MemWrite32cxx . . $ V810#MemWrite32.(timestamp, A, V);
146 }
147 else
148 {
149 timestamp += 2;
150 MemWrite16cxx . . $ V810#MemWrite16.(timestamp, A, V & 0xFFFF);
151
152 timestamp += 2;
153 MemWrite16cxx . . $ V810#MemWrite16.(timestamp, A | 2, V >> 16);
154 }
155 }
156
157 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! uint32cxx . . $ uint32# V810cxx . . $ V810#::CacheOpMemLoadcxx . . $ V810#CacheOpMemLoad(82a8994e9c9c69b7).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, uint32cxx . . $ uint32# A)
158 {
159 if(MemReadBus32cxx . . $ V810#MemReadBus32.[A >> 24])
160 {
161 timestamp += 2;
162 return(MemRead32cxx . . $ V810#MemRead32.(timestamp, A));
163 }
164 else
165 {
166 uint32cxx . . $ uint32# ret;
167
168 timestamp += 2;
169 ret = MemRead16cxx . . $ V810#MemRead16.(timestamp, A);
170
171 timestamp += 2;
172 ret |= MemRead16cxx . . $ V810#MemRead16.(timestamp, A | 2) << 16;
173 return(ret);
174 }
175 }
176
177 void V810cxx . . $ V810#::CacheDumpcxx . . $ V810#CacheDump(6700383502b9ef47).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, const uint32cxx . . $ uint32# SA)
178 {
179 printf("Cache dump: %08x\n", SA);
180
181 for(int i = 0; i < 128; i++)
182 {
183 CacheOpMemStorecxx . . $ V810#CacheOpMemStore(89f8e5bd0b04bfaa).(timestamp, SA + i * 8 + 0, Cachecxx . . $ V810#Cache.[i].datacxx . . $ V810#$anonymous_type_5#data.[0]);
184 CacheOpMemStorecxx . . $ V810#CacheOpMemStore(89f8e5bd0b04bfaa).(timestamp, SA + i * 8 + 4, Cachecxx . . $ V810#Cache.[i].datacxx . . $ V810#$anonymous_type_5#data.[1]);
185 }
186
187 for(int i = 0; i < 128; i++)
188 {
189 uint32cxx . . $ uint32# icht = Cachecxx . . $ V810#Cache.[i].tagcxx . . $ V810#$anonymous_type_5#tag. | ((int)Cachecxx . . $ V810#Cache.[i].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[0] << 22) | ((int)Cachecxx . . $ V810#Cache.[i].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[1] << 23);
190
191 CacheOpMemStorecxx . . $ V810#CacheOpMemStore(89f8e5bd0b04bfaa).(timestamp, SA + 1024 + i * 4, icht);
192 }
193
194 }
195
196 void V810cxx . . $ V810#::CacheRestorecxx . . $ V810#CacheRestore(6700383502b9ef47).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, const uint32cxx . . $ uint32# SA)
197 {
198 printf("Cache restore: %08x\n", SA);
199
200 for(int i = 0; i < 128; i++)
201 {
202 Cachecxx . . $ V810#Cache.[i].datacxx . . $ V810#$anonymous_type_5#data.[0] = CacheOpMemLoadcxx . . $ V810#CacheOpMemLoad(82a8994e9c9c69b7).(timestamp, SA + i * 8 + 0);
203 Cachecxx . . $ V810#Cache.[i].datacxx . . $ V810#$anonymous_type_5#data.[1] = CacheOpMemLoadcxx . . $ V810#CacheOpMemLoad(82a8994e9c9c69b7).(timestamp, SA + i * 8 + 4);
204 }
205
206 for(int i = 0; i < 128; i++)
207 {
208 uint32cxx . . $ uint32# icht;
209
210 icht = CacheOpMemLoadcxx . . $ V810#CacheOpMemLoad(82a8994e9c9c69b7).(timestamp, SA + 1024 + i * 4);
211
212 Cachecxx . . $ V810#Cache.[i].tagcxx . . $ V810#$anonymous_type_5#tag. = icht & ((1 << 22) - 1);
213 Cachecxx . . $ V810#Cache.[i].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[0] = (icht >> 22) & 1;
214 Cachecxx . . $ V810#Cache.[i].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[1] = (icht >> 23) & 1;
215 }
216 }
217
218
219 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! uint32cxx . . $ uint32# V810cxx . . $ V810#::RDCACHEcxx . . $ V810#RDCACHE(82a8994e9c9c69b7).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, uint32cxx . . $ uint32# addr)
220 {
221 const int CI = (addr >> 3) & 0x7F;
222 const int SBI = (addr & 4) >> 2;
223
224 if(Cachecxx . . $ V810#Cache.[CI].tagcxx . . $ V810#$anonymous_type_5#tag. == (addr >> 10))
225 {
226 if(!Cachecxx . . $ V810#Cache.[CI].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[SBI])
227 {
228 timestamp += 2; // or higher? Penalty for cache miss seems to be higher than having cache disabled.
229 if(MemReadBus32cxx . . $ V810#MemReadBus32.[addr >> 24])
230 Cachecxx . . $ V810#Cache.[CI].datacxx . . $ V810#$anonymous_type_5#data.[SBI] = MemRead32cxx . . $ V810#MemRead32.(timestamp, addr & ~0x3);
231 else
232 {
233 timestamp++;
234 Cachecxx . . $ V810#Cache.[CI].datacxx . . $ V810#$anonymous_type_5#data.[SBI] = MemRead16cxx . . $ V810#MemRead16.(timestamp, addr & ~0x3) | ((MemRead16cxx . . $ V810#MemRead16.(timestamp, (addr & ~0x3) | 0x2) << 16));
235 }
236 Cachecxx . . $ V810#Cache.[CI].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[SBI] = true;
237 }
238 }
239 else
240 {
241 Cachecxx . . $ V810#Cache.[CI].tagcxx . . $ V810#$anonymous_type_5#tag. = addr >> 10;
242
243 timestamp += 2; // or higher? Penalty for cache miss seems to be higher than having cache disabled.
244 if(MemReadBus32cxx . . $ V810#MemReadBus32.[addr >> 24])
245 Cachecxx . . $ V810#Cache.[CI].datacxx . . $ V810#$anonymous_type_5#data.[SBI] = MemRead32cxx . . $ V810#MemRead32.(timestamp, addr & ~0x3);
246 else
247 {
248 timestamp++;
249 Cachecxx . . $ V810#Cache.[CI].datacxx . . $ V810#$anonymous_type_5#data.[SBI] = MemRead16cxx . . $ V810#MemRead16.(timestamp, addr & ~0x3) | ((MemRead16cxx . . $ V810#MemRead16.(timestamp, (addr & ~0x3) | 0x2) << 16));
250 }
251 //Cache[CI].data[SBI] = MemRead32(timestamp, addr & ~0x3);
252 Cachecxx . . $ V810#Cache.[CI].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[SBI] = true;
253 Cachecxx . . $ V810#Cache.[CI].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[SBI ^ 1] = false;
254 }
255
256 //{
257 // // Caution: This can mess up DRAM page change penalty timings
258 // uint32 dummy_timestamp = 0;
259 // if(Cache[CI].data[SBI] != mem_rword(addr & ~0x3, dummy_timestamp))
260 // {
261 // printf("Cache/Real Memory Mismatch: %08x %08x/%08x\n", addr & ~0x3, Cache[CI].data[SBI], mem_rword(addr & ~0x3, dummy_timestamp));
262 // }
263 //}
264
265 return(Cachecxx . . $ V810#Cache.[CI].datacxx . . $ V810#$anonymous_type_5#data.[SBI]);
266 }
267
268 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! uint16cxx . . $ uint16# V810cxx . . $ V810#::RDOPcxx . . $ V810#RDOP(8e177301105cc1fb).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, uint32cxx . . $ uint32# addr, uint32cxx . . $ uint32# meow)
269 {
270 uint16cxx . . $ uint16# ret;
271
272 if(S_REGcxx . . $ V810#S_REG.[CHCWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:50:9`!] & 0x2)
273 {
274 uint32cxx . . $ uint32# d32 = RDCACHEcxx . . $ V810#RDCACHE(82a8994e9c9c69b7).(timestamp, addr);
275 ret = d32 >> ((addr & 2) * 8);
276 }
277 else
278 {
279 timestamp += meow; //++;
280 ret = MemRead16cxx . . $ V810#MemRead16.(timestamp, addr);
281 }
282 return(ret);
283 }
284
285 #define BRANCH_ALIGN_CHECKcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:285:9`!(x) { if((S_REG[CHCWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:50:9`!] & 0x2) && (x & 0x2)) { ADDCLOCKcxx . . $ `mednafen/hw_cpu/v810/v810_oploop.inc:35:13`!(1); } }
286
287 // Reinitialize the defaults in the CPU
288 void V810cxx . . $ V810#::Resetcxx . . $ V810#Reset(49f6e7a06ebc5aa8).()
289 {
290 #ifdef WANT_DEBUGGER
291 if(ADDBT)
292 ADDBT(GetPC(), 0xFFFFFFF0, 0xFFF0);
293 #endif
294 memset(&Cachecxx . . $ V810#Cache., 0, sizeof(Cachecxx . . $ V810#Cache.));
295
296 memset(P_REGcxx . . $ V810#P_REG., 0, sizeof(P_REGcxx . . $ V810#P_REG.));
297 memset(S_REGcxx . . $ V810#S_REG., 0, sizeof(S_REGcxx . . $ V810#S_REG.));
298 memset(Cachecxx . . $ V810#Cache., 0, sizeof(Cachecxx . . $ V810#Cache.));
299
300 P_REGcxx . . $ V810#P_REG.[0] = 0x00000000;
301 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(0xFFFFFFF0);
302
303 S_REGcxx . . $ V810#S_REG.[ECRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:46:9`!] = 0x0000FFF0;
304 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] = 0x00008000;
305
306 if(VBModecxx . . $ V810#VBMode.)
307 S_REGcxx . . $ V810#S_REG.[PIRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:48:9`!] = 0x00005346;
308 else
309 S_REGcxx . . $ V810#S_REG.[PIRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:48:9`!] = 0x00008100;
310
311 S_REGcxx . . $ V810#S_REG.[TKCWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:49:9`!] = 0x000000E0;
312 Haltedcxx . . $ V810#Halted. = HALT_NONEcxx . . $ V810#HALT_NONE.;
313 ilevelcxx . . $ V810#ilevel. = -1;
314
315 lastopcxx . . $ V810#lastop. = 0;
316
317 in_bstrcxx . . $ V810#in_bstr. = false;
318
319 RecalcIPendingCachecxx . . $ V810#RecalcIPendingCache(49f6e7a06ebc5aa8).();
320 }
321
322 bool V810cxx . . $ V810#::Initcxx . . $ V810#Init(6f292f52d6600187).(V810_Emu_Modecxx . . $ V810_Emu_Mode# mode, bool vb_mode)
323 {
324 EmuModecxx . . $ V810#EmuMode. = mode;
325 VBModecxx . . $ V810#VBMode. = vb_mode;
326
327 in_bstrcxx . . $ V810#in_bstr. = false;
328 in_bstr_tocxx . . $ V810#in_bstr_to. = 0;
329
330 if(mode == V810_EMU_MODE_FASTcxx . . $ V810_EMU_MODE_FAST.)
331 {
332 memset(DummyRegioncxx . . $ V810#DummyRegion., 0, V810_FAST_MAP_PSIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:14:9`!);
333
334 for(unsigned int i = V810_FAST_MAP_PSIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:14:9`!; i < V810_FAST_MAP_PSIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:14:9`! + V810_FAST_MAP_TRAMPOLINE_SIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:15:9`!; i += 2)
335 {
336 DummyRegioncxx . . $ V810#DummyRegion.[i + 0] = 0;
337 DummyRegioncxx . . $ V810#DummyRegion.[i + 1] = 0x36 << 2;
338 }
339
340 for(uint64cxx . . $ uint64# A = 0; A < (1ULL << 32); A += V810_FAST_MAP_PSIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:14:9`!)
341 FastMapcxx . . $ V810#FastMap.[A / V810_FAST_MAP_PSIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:14:9`!] = DummyRegioncxx . . $ V810#DummyRegion. - A;
342 }
343
344 return(true);
345 }
346
347 void V810cxx . . $ V810#::Killcxx . . $ V810#Kill(49f6e7a06ebc5aa8).(void)
348 {
349 for(unsigned int i = 0; i < FastMapAllocListcxx . . $ V810#FastMapAllocList..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); i++)
350 freecxx . . $ free(bd21765a0afc8e3c).(FastMapAllocListcxx . . $ V810#FastMapAllocList.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]);
351
352 FastMapAllocListcxx . . $ V810#FastMapAllocList..clearcxx . . $ std/vector#clear(ced63f7c635d850d).();
353 }
354
355 void V810cxx . . $ V810#::SetIntcxx . . $ V810#SetInt(d4f767463ce0a6b3).(int level)
356 {
357 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(level >= -1 && level <= 15);
358
359 ilevelcxx . . $ V810#ilevel. = level;
360 RecalcIPendingCachecxx . . $ V810#RecalcIPendingCache(49f6e7a06ebc5aa8).();
361 }
362
363 uint8cxx . . $ uint8# *V810cxx . . $ V810#::SetFastMapcxx . . $ V810#SetFastMap(4852f981d5b5a637).(uint32cxx . . $ uint32# addresses[], uint32cxx . . $ uint32# length, unsigned int num_addresses, const char *name)
364 {
365 uint8cxx . . $ uint8# *ret = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
366
367 for(unsigned int i = 0; i < num_addresses; i++)
368 {
369 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!((addresses[i] & (V810_FAST_MAP_PSIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:14:9`! - 1)) == 0);
370 }
371 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!((length & (V810_FAST_MAP_PSIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:14:9`! - 1)) == 0);
372
373 if(!(ret = (uint8cxx . . $ uint8# *)malloccxx . . $ malloc(9f008b2a9698428b).(length + V810_FAST_MAP_TRAMPOLINE_SIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:15:9`!)))
374 {
375 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
376 }
377
378 for(unsigned int i = length; i < length + V810_FAST_MAP_TRAMPOLINE_SIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:15:9`!; i += 2)
379 {
380 ret[i + 0] = 0;
381 ret[i + 1] = 0x36 << 2;
382 }
383
384 for(unsigned int i = 0; i < num_addresses; i++)
385 {
386 for(uint64cxx . . $ uint64# addr = addresses[i]; addr != (uint64cxx . . $ uint64#)addresses[i] + length; addr += V810_FAST_MAP_PSIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:14:9`!)
387 {
388 //printf("%08x, %d, %s\n", addr, length, name);
389
390 FastMapcxx . . $ V810#FastMap.[addr / V810_FAST_MAP_PSIZEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:14:9`!] = ret - addresses[i];
391 }
392 }
393
394 FastMapAllocListcxx . . $ V810#FastMapAllocList..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(ret);
395
396 return(ret);
397 }
398
399
400 void V810cxx . . $ V810#::SetMemReadBus32cxx . . $ V810#SetMemReadBus32(f2ac3508b56cd10).(uint8cxx . . $ uint8# A, bool value)
401 {
402 MemReadBus32cxx . . $ V810#MemReadBus32.[A] = value;
403 }
404
405 void V810cxx . . $ V810#::SetMemWriteBus32cxx . . $ V810#SetMemWriteBus32(f2ac3508b56cd10).(uint8cxx . . $ uint8# A, bool value)
406 {
407 MemWriteBus32cxx . . $ V810#MemWriteBus32.[A] = value;
408 }
409
410 void V810cxx . . $ V810#::SetMemReadHandlerscxx . . $ V810#SetMemReadHandlers(9cb6d09b7e005094).(uint8cxx . . $ uint8# MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*read8)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#), uint16cxx . . $ uint16# MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*read16)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#), uint32cxx . . $ uint32# MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*read32)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#))
411 {
412 MemRead8cxx . . $ V810#MemRead8. = read8;
413 MemRead16cxx . . $ V810#MemRead16. = read16;
414 MemRead32cxx . . $ V810#MemRead32. = read32;
415 }
416
417 void V810cxx . . $ V810#::SetMemWriteHandlerscxx . . $ V810#SetMemWriteHandlers(14e671c2544e4d03).(void MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*write8)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#, uint8cxx . . $ uint8#), void MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*write16)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#, uint16cxx . . $ uint16#), void MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*write32)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#, uint32cxx . . $ uint32#))
418 {
419 MemWrite8cxx . . $ V810#MemWrite8. = write8;
420 MemWrite16cxx . . $ V810#MemWrite16. = write16;
421 MemWrite32cxx . . $ V810#MemWrite32. = write32;
422 }
423
424 void V810cxx . . $ V810#::SetIOReadHandlerscxx . . $ V810#SetIOReadHandlers(9cb6d09b7e005094).(uint8cxx . . $ uint8# MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*read8)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#), uint16cxx . . $ uint16# MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*read16)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#), uint32cxx . . $ uint32# MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*read32)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#))
425 {
426 IORead8cxx . . $ V810#IORead8. = read8;
427 IORead16cxx . . $ V810#IORead16. = read16;
428 IORead32cxx . . $ V810#IORead32. = read32;
429 }
430
431 void V810cxx . . $ V810#::SetIOWriteHandlerscxx . . $ V810#SetIOWriteHandlers(14e671c2544e4d03).(void MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*write8)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#, uint8cxx . . $ uint8#), void MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*write16)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#, uint16cxx . . $ uint16#), void MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*write32)(v810_timestamp_tcxx . . $ v810_timestamp_t# &, uint32cxx . . $ uint32#, uint32cxx . . $ uint32#))
432 {
433 IOWrite8cxx . . $ V810#IOWrite8. = write8;
434 IOWrite16cxx . . $ V810#IOWrite16. = write16;
435 IOWrite32cxx . . $ V810#IOWrite32. = write32;
436 }
437
438
439 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void V810cxx . . $ V810#::SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(uint32cxx . . $ uint32# n, bool condition)
440 {
441 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] &= ~n;
442
443 if(condition)
444 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= n;
445 }
446
447 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void V810cxx . . $ V810#::SetSZcxx . . $ V810#SetSZ(cb2f890c2fdad230).(uint32cxx . . $ uint32# value)
448 {
449 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Zcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:78:9`!, !value);
450 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Scxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:77:9`!, value & 0x80000000);
451 }
452
453 #ifdef WANT_DEBUGGER
454 void V810::CheckBreakpoints(void (*callback)(int type, uint32 address, uint32 value, unsigned int len), uint16 MDFN_FASTCALL (*peek16)(const v810_timestamp_t, uint32), uint32 MDFN_FASTCALL (*peek32)(const v810_timestamp_t, uint32))
455 {
456 unsigned int opcode;
457 uint16 tmpop;
458 uint16 tmpop_high;
459 int32 ws_dummy = v810_timestamp;
460 uint32 tmp_PC = GetPC();
461
462 tmpop = peek16(ws_dummy, tmp_PC);
463 tmpop_high = peek16(ws_dummy, tmp_PC + 2);
464
465 opcode = tmpop >> 10;
466
467 // Uncomment this out later if necessary.
468 //if((tmpop & 0xE000) == 0x8000) // Special opcode format for
469 // opcode = (tmpop >> 9) & 0x7F; // type III instructions.
470
471 switch(opcode)
472 {
473 case CAXI: break;
474
475 default: break;
476
477 case LD_B: callback(BPOINT_READ, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFF, 0, 1); break;
478 case LD_H: callback(BPOINT_READ, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFE, 0, 2); break;
479 case LD_W: callback(BPOINT_READ, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFC, 0, 4); break;
480
481 case ST_B: callback(BPOINT_WRITE, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFF, P_REG[(tmpop >> 5) & 0x1F] & 0x00FF, 1); break;
482 case ST_H: callback(BPOINT_WRITE, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFE, P_REG[(tmpop >> 5) & 0x1F] & 0xFFFF, 2); break;
483 case ST_W: callback(BPOINT_WRITE, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFC, P_REG[(tmpop >> 5) & 0x1F], 4); break;
484
485 case IN_B: callback(BPOINT_IO_READ, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFF, 0, 1); break;
486 case IN_H: callback(BPOINT_IO_READ, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFE, 0, 2); break;
487 case IN_W: callback(BPOINT_IO_READ, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFC, 0, 4); break;
488
489 case OUT_B: callback(BPOINT_IO_WRITE, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFF, P_REG[(tmpop >> 5) & 0x1F] & 0xFF, 1); break;
490 case OUT_H: callback(BPOINT_IO_WRITE, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFE, P_REG[(tmpop >> 5) & 0x1F] & 0xFFFF, 2); break;
491 case OUT_W: callback(BPOINT_IO_WRITE, (sign_16(tmpop_high)+P_REG[tmpop & 0x1F])&0xFFFFFFFC, P_REG[(tmpop >> 5) & 0x1F], 4); break;
492 }
493
494 }
495 #endif
496
497 #define SetPREGcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:497:9`!(n, val) { P_REG[n] = val; }
498
499 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void V810cxx . . $ V810#::SetSREGcxx . . $ V810#SetSREG(89f8e5bd0b04bfaa).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, unsigned int which, uint32cxx . . $ uint32# value)
500 {
501 switch(which)
502 {
503 default: // Reserved
504 printf("LDSR to reserved system register: 0x%02x : 0x%08x\n", which, value);
505 break;
506
507 case ECRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:46:9`!: // Read-only
508 break;
509
510 case PIRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:48:9`!: // Read-only (obviously)
511 break;
512
513 case TKCWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:49:9`!: // Read-only
514 break;
515
516 case EIPSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:41:9`!:
517 case FEPSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:44:9`!:
518 S_REGcxx . . $ V810#S_REG.[which] = value & 0xFF3FF;
519 break;
520
521 case PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!:
522 S_REGcxx . . $ V810#S_REG.[which] = value & 0xFF3FF;
523 RecalcIPendingCachecxx . . $ V810#RecalcIPendingCache(49f6e7a06ebc5aa8).();
524 break;
525
526 case EIPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:40:9`!:
527 case FEPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:43:9`!:
528 S_REGcxx . . $ V810#S_REG.[which] = value & 0xFFFFFFFE;
529 break;
530
531 case ADDTREcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:51:9`!:
532 S_REGcxx . . $ V810#S_REG.[ADDTREcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:51:9`!] = value & 0xFFFFFFFE;
533 printf("Address trap(unemulated): %08x\n", value);
534 break;
535
536 case CHCWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:50:9`!:
537 S_REGcxx . . $ V810#S_REG.[CHCWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:50:9`!] = value & 0x2;
538
539 switch(value & 0x31)
540 {
541 default: printf("Undefined cache control bit combination: %08x\n", value);
542 break;
543
544 case 0x00: break;
545
546 case 0x01: CacheClearcxx . . $ V810#CacheClear(89f8e5bd0b04bfaa).(timestamp, (value >> 20) & 0xFFF, (value >> 8) & 0xFFF);
547 break;
548
549 case 0x10: CacheDumpcxx . . $ V810#CacheDump(6700383502b9ef47).(timestamp, value & ~0xFF);
550 break;
551
552 case 0x20: CacheRestorecxx . . $ V810#CacheRestore(6700383502b9ef47).(timestamp, value & ~0xFF);
553 break;
554 }
555 break;
556 }
557 }
558
559 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! uint32cxx . . $ uint32# V810cxx . . $ V810#::GetSREGcxx . . $ V810#GetSREG(2141b656ce2cc063).(unsigned int which)
560 {
561 uint32cxx . . $ uint32# ret;
562
563 if(which != 24 && which != 25 && which >= 8)
564 {
565 printf("STSR from reserved system register: 0x%02x", which);
566 }
567
568 ret = S_REGcxx . . $ V810#S_REG.[which];
569
570 return(ret);
571 }
572
573 #define RB_SETPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:573:9`!(new_pc_raw) \
574 { \
575 const uint32 new_pc = new_pc_raw; /* So RB_SETPC(RB_GETPC()) won't mess up */ \
576 if(RB_AccurateMode) \
577 PC = new_pc; \
578 else \
579 { \
580 PC_ptr = &FastMap[(new_pc) >> V810_FAST_MAP_SHIFTcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:13:9`!][(new_pc)]; \
581 PC_base = PC_ptr - (new_pc); \
582 } \
583 }
584
585 #define RB_PCRELCHANGEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:585:9`!(delta) { \
586 if(RB_AccurateMode) \
587 PC += (delta); \
588 else \
589 { \
590 uint32 PC_tmp = RB_GETPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:604:9`!(); \
591 PC_tmp += (delta); \
592 RB_SETPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:573:9`!(PC_tmp); \
593 } \
594 }
595
596 #define RB_INCPCBY2cxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:596:9`!() { if(RB_AccurateMode) PC += 2; else PC_ptr += 2; }
597 #define RB_INCPCBY4cxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:597:9`!() { if(RB_AccurateMode) PC += 4; else PC_ptr += 4; }
598
599 #define RB_DECPCBY2cxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:599:9`!() { if(RB_AccurateMode) PC -= 2; else PC_ptr -= 2; }
600 #define RB_DECPCBY4cxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:600:9`!() { if(RB_AccurateMode) PC -= 4; else PC_ptr -= 4; }
601
602
603 // Define accurate mode defines
604 #define RB_GETPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:604:9`!() PC
605 #ifdef _MSC_VER
606 #define RB_RDOP(PC_offset) RDOP(timestamp, PC + PC_offset)
607 #else
608 #define RB_RDOPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:608:9`!(PC_offset, ...) RDOP(timestamp, PC + PC_offset, ## __VA_ARGS__)
609 #endif
610
611 void V810cxx . . $ V810#::Run_Accuratecxx . . $ V810#Run_Accurate(ff6bf48c415fb7b4).(int32cxx . . $ int32# MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*event_handler)(const v810_timestamp_tcxx . . $ v810_timestamp_t# timestamp))
612 {
613 const bool RB_AccurateMode = true;
614
615 #define RB_ADDBTcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:615:10`!(n,o,p)
616 #define RB_CPUHOOKcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:616:10`!(n)
617
618 #include "v810_oploop.inc"cxx . . $ `<file>/mednafen/hw_cpu/v810/v810_oploop.inc`/
619
620 #undef RB_CPUHOOKcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:616:10`!
621 #undef RB_ADDBTcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:615:10`!
622 }
623
624 #ifdef WANT_DEBUGGER
625
626 /* Make sure class member variable v810_timestamp is synchronized to our local copy, since we'll read it externally if a system
627 reset/power occurs when in step mode or similar.
628 */
629 #define RB_CPUHOOK_DBG(n) { if(CPUHook) { v810_timestamp = timestamp_rl; CPUHook(timestamp_rl, n); } }
630
631 void V810::Run_Accurate_Debug(int32 MDFN_FASTCALL (*event_handler)(const v810_timestamp_t timestamp))
632 {
633 const bool RB_AccurateMode = true;
634
635 #define RB_ADDBT(n,o,p) { if(ADDBT) ADDBT(n,o,p); }
636 /* Make sure class member variable v810_timestamp is synchronized to our local copy, since we'll read it externally if a system
637 reset/power occurs when in step mode or similar.
638 */
639 #define RB_CPUHOOK(n) RB_CPUHOOK_DBG(n)
640 #define RB_DEBUGMODE
641
642 #include "v810_oploop.inc"
643
644 #undef RB_DEBUGMODE
645 #undef RB_CPUHOOK
646 #undef RB_ADDBT
647 }
648 #endif
649
650 //
651 // Undefine accurate mode defines
652 //
653 #undef RB_GETPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:604:9`!
654 #undef RB_RDOPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:608:9`!
655
656
657
658 //
659 // Define fast mode defines
660 //
661 #define RB_GETPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:661:9`!() ((uint32)(PC_ptr - PC_base))
662
663 #ifdef _MSC_VER
664 #define RB_RDOP(PC_offset, b) LoadU16_LE((uint16 *)&PC_ptr[PC_offset])
665 #else
666 #define RB_RDOPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:666:9`!(PC_offset, ...) LoadU16_LE((uint16 *)&PC_ptr[PC_offset])
667 #endif
668
669 void V810cxx . . $ V810#::Run_Fastcxx . . $ V810#Run_Fast(ff6bf48c415fb7b4).(int32cxx . . $ int32# MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*event_handler)(const v810_timestamp_tcxx . . $ v810_timestamp_t# timestamp))
670 {
671 const bool RB_AccurateMode = false;
672
673 #define RB_ADDBTcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:673:10`!(n,o,p)
674 #define RB_CPUHOOKcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:674:10`!(n)
675
676 #include "v810_oploop.inc"cxx . . $ `<file>/mednafen/hw_cpu/v810/v810_oploop.inc`/
677
678 #undef RB_CPUHOOKcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:674:10`!
679 #undef RB_ADDBTcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:673:10`!
680 }
681
682 #ifdef WANT_DEBUGGER
683 void V810::Run_Fast_Debug(int32 MDFN_FASTCALL (*event_handler)(const v810_timestamp_t timestamp))
684 {
685 const bool RB_AccurateMode = false;
686
687 #define RB_ADDBT(n,o,p) { if(ADDBT) ADDBT(n,o,p); }
688 #define RB_CPUHOOK(n) RB_CPUHOOK_DBG(n)
689 #define RB_DEBUGMODE
690
691 #include "v810_oploop.inc"
692
693 #undef RB_DEBUGMODE
694 #undef RB_CPUHOOK
695 #undef RB_ADDBT
696 }
697 #endif
698
699 //
700 // Undefine fast mode defines
701 //
702 #undef RB_GETPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:661:9`!
703 #undef RB_RDOPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:666:9`!
704
705 v810_timestamp_tcxx . . $ v810_timestamp_t# V810cxx . . $ V810#::Runcxx . . $ V810#Run(4d2abde9c7a0c9b3).(int32cxx . . $ int32# MDFN_FASTCALLcxx . . $ `mednafen/mednafen-types.h:27:13`! (*event_handler)(const v810_timestamp_tcxx . . $ v810_timestamp_t# timestamp))
706 {
707 Runningcxx . . $ V810#Running. = true;
708
709 #ifdef WANT_DEBUGGER
710 if(CPUHook || ADDBT)
711 {
712 if(EmuMode == V810_EMU_MODE_FAST)
713 Run_Fast_Debug(event_handler);
714 else
715 Run_Accurate_Debug(event_handler);
716 }
717 else
718 #endif
719 {
720 if(EmuModecxx . . $ V810#EmuMode. == V810_EMU_MODE_FASTcxx . . $ V810_EMU_MODE_FAST.)
721 Run_Fastcxx . . $ V810#Run_Fast(ff6bf48c415fb7b4).(event_handler);
722 else
723 Run_Accuratecxx . . $ V810#Run_Accurate(ff6bf48c415fb7b4).(event_handler);
724 }
725 return(v810_timestampcxx . . $ V810#v810_timestamp.);
726 }
727
728 void V810cxx . . $ V810#::Exitcxx . . $ V810#Exit(49f6e7a06ebc5aa8).(void)
729 {
730 Runningcxx . . $ V810#Running. = false;
731 }
732
733 #ifdef WANT_DEBUGGER
734 void V810::SetCPUHook(void (*newhook)(const v810_timestamp_t timestamp, uint32 PC), void (*new_ADDBT)(uint32 old_PC, uint32 new_PC, uint32))
735 {
736 CPUHook = newhook;
737 ADDBT = new_ADDBT;
738 }
739 #endif
740
741 uint32cxx . . $ uint32# V810cxx . . $ V810#::GetPCcxx . . $ V810#GetPC(db52760e79bf9054).(void)
742 {
743 if(EmuModecxx . . $ V810#EmuMode. == V810_EMU_MODE_ACCURATEcxx . . $ V810_EMU_MODE_ACCURATE.)
744 return(PCcxx . . $ V810#PC.);
745 else
746 {
747 return(PC_ptrcxx . . $ V810#PC_ptr. - PC_basecxx . . $ V810#PC_base.);
748 }
749 }
750
751 void V810cxx . . $ V810#::SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(uint32cxx . . $ uint32# new_pc)
752 {
753 if(EmuModecxx . . $ V810#EmuMode. == V810_EMU_MODE_ACCURATEcxx . . $ V810_EMU_MODE_ACCURATE.)
754 PCcxx . . $ V810#PC. = new_pc;
755 else
756 {
757 PC_ptrcxx . . $ V810#PC_ptr. = &FastMapcxx . . $ V810#FastMap.[new_pc >> V810_FAST_MAP_SHIFTcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:13:9`!][new_pc];
758 PC_basecxx . . $ V810#PC_base. = PC_ptrcxx . . $ V810#PC_ptr. - new_pc;
759 }
760 }
761
762 uint32cxx . . $ uint32# V810cxx . . $ V810#::GetPRcxx . . $ V810#GetPR(2141b656ce2cc063).(const unsigned int which)
763 {
764 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(which <= 0x1F);
765
766
767 return(which ? P_REGcxx . . $ V810#P_REG.[which] : 0);
768 }
769
770 void V810cxx . . $ V810#::SetPRcxx . . $ V810#SetPR(b4d55b1286ff73e8).(const unsigned int which, uint32cxx . . $ uint32# value)
771 {
772 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(which <= 0x1F);
773
774 if(which)
775 P_REGcxx . . $ V810#P_REG.[which] = value;
776 }
777
778 uint32cxx . . $ uint32# V810cxx . . $ V810#::GetSRcxx . . $ V810#GetSR(2141b656ce2cc063).(const unsigned int which)
779 {
780 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(which <= 0x1F);
781
782 return(GetSREGcxx . . $ V810#GetSREG(2141b656ce2cc063).(which));
783 }
784
785 void V810cxx . . $ V810#::SetSRcxx . . $ V810#SetSR(b4d55b1286ff73e8).(const unsigned int which, uint32cxx . . $ uint32# value)
786 {
787 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(which <= 0x1F);
788
789 // SetSREG(timestamp, which, value);
790 }
791
792
793 #define BSTR_OP_MOVcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:793:9`! dst_cache &= ~(1 << dstoff); dst_cache |= ((src_cache >> srcoff) & 1) << dstoff;
794 #define BSTR_OP_NOTcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:794:9`! dst_cache &= ~(1 << dstoff); dst_cache |= (((src_cache >> srcoff) & 1) ^ 1) << dstoff;
795
796 #define BSTR_OP_XORcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:796:9`! dst_cache ^= ((src_cache >> srcoff) & 1) << dstoff;
797 #define BSTR_OP_ORcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:797:9`! dst_cache |= ((src_cache >> srcoff) & 1) << dstoff;
798 #define BSTR_OP_ANDcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:798:9`! dst_cache &= ~((((src_cache >> srcoff) & 1) ^ 1) << dstoff);
799
800 #define BSTR_OP_XORNcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:800:9`! dst_cache ^= (((src_cache >> srcoff) & 1) ^ 1) << dstoff;
801 #define BSTR_OP_ORNcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:801:9`! dst_cache |= (((src_cache >> srcoff) & 1) ^ 1) << dstoff;
802 #define BSTR_OP_ANDNcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:802:9`! dst_cache &= ~(((src_cache >> srcoff) & 1) << dstoff);
803
804 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! uint32cxx . . $ uint32# V810cxx . . $ V810#::BSTR_RWORDcxx . . $ V810#BSTR_RWORD(82a8994e9c9c69b7).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, uint32cxx . . $ uint32# A)
805 {
806 if(MemReadBus32cxx . . $ V810#MemReadBus32.[A >> 24])
807 {
808 timestamp += 2;
809 return(MemRead32cxx . . $ V810#MemRead32.(timestamp, A));
810 }
811 else
812 {
813 uint32cxx . . $ uint32# ret;
814
815 timestamp += 2;
816 ret = MemRead16cxx . . $ V810#MemRead16.(timestamp, A);
817
818 timestamp += 2;
819 ret |= MemRead16cxx . . $ V810#MemRead16.(timestamp, A | 2) << 16;
820 return(ret);
821 }
822 }
823
824 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void V810cxx . . $ V810#::BSTR_WWORDcxx . . $ V810#BSTR_WWORD(89f8e5bd0b04bfaa).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, uint32cxx . . $ uint32# A, uint32cxx . . $ uint32# V)
825 {
826 if(MemWriteBus32cxx . . $ V810#MemWriteBus32.[A >> 24])
827 {
828 timestamp += 2;
829 MemWrite32cxx . . $ V810#MemWrite32.(timestamp, A, V);
830 }
831 else
832 {
833 timestamp += 2;
834 MemWrite16cxx . . $ V810#MemWrite16.(timestamp, A, V & 0xFFFF);
835
836 timestamp += 2;
837 MemWrite16cxx . . $ V810#MemWrite16.(timestamp, A | 2, V >> 16);
838 }
839 }
840
841 #define DO_BSTRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:841:9`!(op) { \
842 while(len) \
843 { \
844 if(!have_src_cache) \
845 { \
846 have_src_cache = true; \
847 src_cache = BSTR_RWORD(timestamp, src); \
848 } \
849 \
850 if(!have_dst_cache) \
851 { \
852 have_dst_cache = true; \
853 dst_cache = BSTR_RWORD(timestamp, dst); \
854 } \
855 \
856 op; \
857 srcoff = (srcoff + 1) & 0x1F; \
858 dstoff = (dstoff + 1) & 0x1F; \
859 len--; \
860 \
861 if(!srcoff) \
862 { \
863 src += 4; \
864 have_src_cache = false; \
865 } \
866 \
867 if(!dstoff) \
868 { \
869 BSTR_WWORD(timestamp, dst, dst_cache); \
870 dst += 4; \
871 have_dst_cache = false; \
872 if(timestamp >= next_event_ts) \
873 break; \
874 } \
875 } \
876 if(have_dst_cache) \
877 BSTR_WWORD(timestamp, dst, dst_cache); \
878 }
879
880 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! bool V810cxx . . $ V810#::Do_BSTR_Searchcxx . . $ V810#Do_BSTR_Search(9000eba7d97a8080).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, const int inc_mul, unsigned int bit_test)
881 {
882 uint32cxx . . $ uint32# srcoff = (P_REGcxx . . $ V810#P_REG.[27] & 0x1F);
883 uint32cxx . . $ uint32# len = P_REGcxx . . $ V810#P_REG.[28];
884 uint32cxx . . $ uint32# bits_skipped = P_REGcxx . . $ V810#P_REG.[29];
885 uint32cxx . . $ uint32# src = (P_REGcxx . . $ V810#P_REG.[30] & 0xFFFFFFFC);
886 bool found = false;
887
888 #if 0
889 // TODO: Better timing.
890 if(!in_bstr) // If we're just starting the execution of this instruction(kind of spaghetti-code), so FIXME if we change
891 // bstr handling in v810_oploop.inc
892 {
893 timestamp += 13 - 1;
894 }
895 #endif
896
897 while(len)
898 {
899 if(!have_src_cachecxx . . $ V810#have_src_cache.)
900 {
901 have_src_cachecxx . . $ V810#have_src_cache. = true;
902 timestamp++;
903 src_cachecxx . . $ V810#src_cache. = BSTR_RWORDcxx . . $ V810#BSTR_RWORD(82a8994e9c9c69b7).(timestamp, src);
904 }
905
906 if(((src_cachecxx . . $ V810#src_cache. >> srcoff) & 1) == bit_test)
907 {
908 found = true;
909
910 /* Fix the bit offset and word address to "1 bit before" it was found */
911 srcoff -= inc_mul * 1;
912 if(srcoff & 0x20) /* Handles 0x1F->0x20(0x00) and 0x00->0xFFFF... */
913 {
914 src -= inc_mul * 4;
915 srcoff &= 0x1F;
916 }
917 break;
918 }
919 srcoff = (srcoff + inc_mul * 1) & 0x1F;
920 bits_skipped++;
921 len--;
922
923 if(!srcoff)
924 {
925 have_src_cachecxx . . $ V810#have_src_cache. = false;
926 src += inc_mul * 4;
927 if(timestamp >= next_event_tscxx . . $ V810#next_event_ts.)
928 break;
929 }
930 }
931
932 P_REGcxx . . $ V810#P_REG.[27] = srcoff;
933 P_REGcxx . . $ V810#P_REG.[28] = len;
934 P_REGcxx . . $ V810#P_REG.[29] = bits_skipped;
935 P_REGcxx . . $ V810#P_REG.[30] = src;
936
937
938 if(found) // Set Z flag to 0 if the bit was found
939 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Zcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:78:9`!, 0);
940 else if(!len) // ...and if the search is over, and the bit was not found, set it to 1
941 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Zcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:78:9`!, 1);
942
943 if(found) // Bit found, so don't continue the search.
944 return(false);
945
946 return((bool)len); // Continue the search if any bits are left to search.
947 }
948
949 bool V810cxx . . $ V810#::bstr_subopcxx . . $ V810#bstr_subop(b52c1fabab6edf50).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, int sub_op, int arg1)
950 {
951 if((sub_op >= 0x10) || (!(sub_op & 0x8) && sub_op >= 0x4))
952 {
953 printf("%08x\tBSR Error: %04x\n", PCcxx . . $ V810#PC.,sub_op);
954
955 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(GetPCcxx . . $ V810#GetPC(db52760e79bf9054).() - 2);
956 Exceptioncxx . . $ V810#Exception(272d193675e92631).(INVALID_OP_HANDLER_ADDRcxx . . $ INVALID_OP_HANDLER_ADDR., ECODE_INVALID_OPcxx . . $ ECODE_INVALID_OP.);
957
958 return(false);
959 }
960
961 // printf("BSTR: %02x, %02x %02x; src: %08x, dst: %08x, len: %08x\n", sub_op, P_REG[27], P_REG[26], P_REG[30], P_REG[29], P_REG[28]);
962
963 if(sub_op & 0x08)
964 {
965 uint32cxx . . $ uint32# dstoff = (P_REGcxx . . $ V810#P_REG.[26] & 0x1F);
966 uint32cxx . . $ uint32# srcoff = (P_REGcxx . . $ V810#P_REG.[27] & 0x1F);
967 uint32cxx . . $ uint32# len = P_REGcxx . . $ V810#P_REG.[28];
968 uint32cxx . . $ uint32# dst = (P_REGcxx . . $ V810#P_REG.[29] & 0xFFFFFFFC);
969 uint32cxx . . $ uint32# src = (P_REGcxx . . $ V810#P_REG.[30] & 0xFFFFFFFC);
970
971 #if 0
972 // Be careful not to cause 32-bit integer overflow, and careful about not shifting by 32.
973 // TODO:
974
975 // Read src[0], src[4] into shifter.
976 // Read dest[0].
977 DO_BSTR_PROLOGUE(); // if(len) { blah blah blah masking blah }
978 src_cache = BSTR_RWORD(timestamp, src);
979
980 if((uint64)(srcoff + len) > 0x20)
981 src_cache |= (uint64)BSTR_RWORD(timestamp, src + 4) << 32;
982
983 dst_cache = BSTR_RWORD(timestamp, dst);
984
985 if(len)
986 {
987 uint32 dst_preserve_mask;
988 uint32 dst_change_mask;
989
990 dst_preserve_mask = (1U << dstoff) - 1;
991
992 if((uint64)(dstoff + len) < 0x20)
993 dst_preserve_mask |= ((1U << ((0x20 - (dstoff + len)) & 0x1F)) - 1) << (dstoff + len);
994
995 dst_change_mask = ~dst_preserve_mask;
996
997 src_cache = BSTR_RWORD(timestamp, src);
998 src_cache |= (uint64)BSTR_RWORD(timestamp, src + 4) << 32;
999 dst_cache = BSTR_RWORD(timestamp, dst);
1000
1001 dst_cache = (dst_cache & dst_preserve_mask) | ((dst_cache OP_THINGY_HERE (src_cache >> srcoff)) & dst_change_mask);
1002 BSTR_WWORD(timestamp, dst, dst_cache);
1003
1004 if((uint64)(dstoff + len) < 0x20)
1005 {
1006 srcoff += len;
1007 dstoff += len;
1008 len = 0;
1009 }
1010 else
1011 {
1012 srcoff += (0x20 - dstoff);
1013 dstoff = 0;
1014 len -= (0x20 - dstoff);
1015 dst += 4;
1016 }
1017
1018 if(srcoff >= 0x20)
1019 {
1020 srcoff &= 0x1F;
1021 src += 4;
1022
1023 if(len)
1024 {
1025 src_cache >>= 32;
1026 src_cache |= (uint64)BSTR_RWORD(timestamp, src + 4) << 32;
1027 }
1028 }
1029 }
1030
1031 DO_BSTR_PRIMARY(); // while(len >= 32) (do allow interruption; interrupt and emulator-return -
1032 // they must be handled differently!)
1033 while(len >= 32)
1034 {
1035 dst_cache = BSTR_RWORD(timestamp, dst);
1036 dst_cache = OP_THINGY_HERE(dst_cache, src_cache >> srcoff);
1037 BSTR_WWORD(timestamp, dst, dst_cache);
1038 len -= 32;
1039 dst += 4;
1040 src += 4;
1041 src_cache >>= 32;
1042 src_cache |= (uint64)BSTR_RWORD(timestamp, src + 4) << 32;
1043 }
1044
1045 DO_BSTR_EPILOGUE(); // if(len) { blah blah blah masking blah }
1046 if(len)
1047 {
1048 uint32 dst_preserve_mask;
1049 uint32 dst_change_mask;
1050
1051 dst_preserve_mask = (1U << ((0x20 - len) & 0x1F) << len;
1052 dst_change_mask = ~dst_preserve_mask;
1053
1054 dst_cache = BSTR_RWORD(timestamp, dst);
1055 dst_cache = OP_THINGY_HERE(dst_cache, src_cache >> srcoff);
1056 BSTR_WWORD(timestamp, dst, dst_cache);
1057 dstoff += len;
1058 srcoff += len;
1059
1060 if(srcoff >= 0x20)
1061 {
1062 srcoff &= 0x1F;
1063 src += 4;
1064 }
1065 len = 0;
1066 }
1067 #endif
1068
1069 switch(sub_op)
1070 {
1071 case ORBSUcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:144:17`!: DO_BSTRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:841:9`!(BSTR_OP_ORcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:797:9`!); break;
1072
1073 case ANDBSUcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:145:17`!: DO_BSTRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:841:9`!(BSTR_OP_ANDcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:798:9`!); break;
1074
1075 case XORBSUcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:146:17`!: DO_BSTRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:841:9`!(BSTR_OP_XORcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:796:9`!); break;
1076
1077 case MOVBSUcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:147:17`!: DO_BSTRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:841:9`!(BSTR_OP_MOVcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:793:9`!); break;
1078
1079 case ORNBSUcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:148:17`!: DO_BSTRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:841:9`!(BSTR_OP_ORNcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:801:9`!); break;
1080
1081 case ANDNBSUcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:149:17`!: DO_BSTRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:841:9`!(BSTR_OP_ANDNcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:802:9`!); break;
1082
1083 case XORNBSUcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:150:17`!: DO_BSTRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:841:9`!(BSTR_OP_XORNcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:800:9`!); break;
1084
1085 case NOTBSUcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:151:17`!: DO_BSTRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:841:9`!(BSTR_OP_NOTcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:794:9`!); break;
1086 }
1087
1088 P_REGcxx . . $ V810#P_REG.[26] = dstoff;
1089 P_REGcxx . . $ V810#P_REG.[27] = srcoff;
1090 P_REGcxx . . $ V810#P_REG.[28] = len;
1091 P_REGcxx . . $ V810#P_REG.[29] = dst;
1092 P_REGcxx . . $ V810#P_REG.[30] = src;
1093
1094 return((bool)P_REGcxx . . $ V810#P_REG.[28]);
1095 }
1096 else
1097 {
1098 printf("BSTR Search: %02x\n", sub_op);
1099 }
1100
1101 return(Do_BSTR_Searchcxx . . $ V810#Do_BSTR_Search(9000eba7d97a8080).(timestamp, ((sub_op & 1) ? -1 : 1), (sub_op & 0x2) >> 1));
1102 }
1103
1104 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void V810cxx . . $ V810#::SetFPUOPNonFPUFlagscxx . . $ V810#SetFPUOPNonFPUFlags(cb2f890c2fdad230).(uint32cxx . . $ uint32# result)
1105 {
1106 // Now, handle flag setting
1107 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_OVcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:76:9`!, 0);
1108
1109 if(!(result & 0x7FFFFFFF)) // Check to see if exponent and mantissa are 0
1110 {
1111 // If Z flag is set, S and CY should be clear, even if it's negative 0(confirmed on real thing with subf.s, at least).
1112 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Zcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:78:9`!, 1);
1113 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Scxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:77:9`!, 0);
1114 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_CYcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:75:9`!, 0);
1115 }
1116 else
1117 {
1118 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Zcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:78:9`!, 0);
1119 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Scxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:77:9`!, result & 0x80000000);
1120 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_CYcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:75:9`!, result & 0x80000000);
1121 }
1122 //printf("MEOW: %08x\n", S_REG[PSW] & (PSW_S | PSW_CY));
1123 }
1124
1125 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! bool V810cxx . . $ V810#::CheckFPInputExceptioncxx . . $ V810#CheckFPInputException(dfa6e707f7696010).(uint32cxx . . $ uint32# fpval)
1126 {
1127 // Zero isn't a subnormal! (OR IS IT *DUN DUN DUNNN* ;b)
1128 if(!(fpval & 0x7FFFFFFF))
1129 return(false);
1130
1131 switch((fpval >> 23) & 0xFF)
1132 {
1133 case 0x00: // Subnormal
1134 case 0xFF: // NaN or infinity
1135 {
1136 //puts("New FPU FRO");
1137
1138 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_FROcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:67:9`!;
1139
1140 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(GetPCcxx . . $ V810#GetPC(db52760e79bf9054).() - 4);
1141 Exceptioncxx . . $ V810#Exception(272d193675e92631).(FPU_HANDLER_ADDRcxx . . $ FPU_HANDLER_ADDR., ECODE_FROcxx . . $ ECODE_FRO.);
1142 }
1143 return(true); // Yes, exception occurred
1144 }
1145 return(false); // No, no exception occurred.
1146 }
1147
1148 bool V810cxx . . $ V810#::FPU_DoesExceptionKillResultcxx . . $ V810#FPU_DoesExceptionKillResult(c9857a73d68e59ba).(void)
1149 {
1150 if(float_exception_flags & float_flag_invalid)
1151 return(true);
1152
1153 if(float_exception_flags & float_flag_divbyzero)
1154 return(true);
1155
1156
1157 // Return false here, so that the result of this calculation IS put in the output register.
1158 // (Incidentally, to get the result of operations on overflow to match a real V810, required a bit of hacking of the SoftFloat code to "wrap" the exponent
1159 // on overflow,
1160 // rather than generating an infinity. The wrapping behavior is specified in IEE 754 AFAIK, and is useful in cases where you divide a huge number
1161 // by another huge number, and fix the result afterwards based on the number of overflows that occurred. Probably requires some custom assembly code,
1162 // though. And it's the kind of thing you'd see in an engineering or physics program, not in a perverted video game :b).
1163 // Oh, and just a note to self, FPR is NOT set when an overflow occurs. Or it is in certain cases?
1164 if(float_exception_flags & float_flag_overflow)
1165 return(false);
1166
1167 return(false);
1168 }
1169
1170 void V810cxx . . $ V810#::FPU_DoExceptioncxx . . $ V810#FPU_DoException(49f6e7a06ebc5aa8).(void)
1171 {
1172 if(float_exception_flags & float_flag_invalid)
1173 {
1174 //puts("New FPU Invalid");
1175
1176 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_FIVcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:68:9`!;
1177
1178 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(GetPCcxx . . $ V810#GetPC(db52760e79bf9054).() - 4);
1179 Exceptioncxx . . $ V810#Exception(272d193675e92631).(FPU_HANDLER_ADDRcxx . . $ FPU_HANDLER_ADDR., ECODE_FIVcxx . . $ ECODE_FIV.);
1180
1181 return;
1182 }
1183
1184 if(float_exception_flags & float_flag_divbyzero)
1185 {
1186 //puts("New FPU Divide by Zero");
1187
1188 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_FZDcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:70:9`!;
1189
1190 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(GetPCcxx . . $ V810#GetPC(db52760e79bf9054).() - 4);
1191 Exceptioncxx . . $ V810#Exception(272d193675e92631).(FPU_HANDLER_ADDRcxx . . $ FPU_HANDLER_ADDR., ECODE_FZDcxx . . $ ECODE_FZD.);
1192
1193 return;
1194 }
1195
1196 if(float_exception_flags & float_flag_underflow)
1197 {
1198 //puts("New FPU Underflow");
1199
1200 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_FUDcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:72:9`!;
1201 }
1202
1203 if(float_exception_flags & float_flag_inexact)
1204 {
1205 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_FPRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:73:9`!;
1206 //puts("New FPU Precision Degradation");
1207 }
1208
1209 // FPR can be set along with overflow, so put the overflow exception handling at the end here(for Exception() messes with PSW).
1210 if(float_exception_flags & float_flag_overflow)
1211 {
1212 //puts("New FPU Overflow");
1213
1214 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_FOVcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:71:9`!;
1215
1216 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(GetPCcxx . . $ V810#GetPC(db52760e79bf9054).() - 4);
1217 Exceptioncxx . . $ V810#Exception(272d193675e92631).(FPU_HANDLER_ADDRcxx . . $ FPU_HANDLER_ADDR., ECODE_FOVcxx . . $ ECODE_FOV.);
1218 }
1219 }
1220
1221 bool V810cxx . . $ V810#::IsSubnormalcxx . . $ V810#IsSubnormal(dfa6e707f7696010).(uint32cxx . . $ uint32# fpval)
1222 {
1223 if( ((fpval >> 23) & 0xFF) == 0 && (fpval & ((1 << 23) - 1)) )
1224 return(true);
1225
1226 return(false);
1227 }
1228
1229 INLINEcxx . . $ `mednafen/mednafen-types.h:21:11`! void V810cxx . . $ V810#::FPU_Math_Templatecxx . . $ V810#FPU_Math_Template(1534797a8d4dd0af).(float32 (*func)(float32, float32), uint32cxx . . $ uint32# arg1, uint32cxx . . $ uint32# arg2)
1230 {
1231 if(CheckFPInputExceptioncxx . . $ V810#CheckFPInputException(dfa6e707f7696010).(P_REGcxx . . $ V810#P_REG.[arg1]) || CheckFPInputExceptioncxx . . $ V810#CheckFPInputException(dfa6e707f7696010).(P_REGcxx . . $ V810#P_REG.[arg2]))
1232 {
1233
1234 }
1235 else
1236 {
1237 uint32cxx . . $ uint32# result;
1238
1239 float_exception_flags = 0;
1240 result = func(P_REGcxx . . $ V810#P_REG.[arg1], P_REGcxx . . $ V810#P_REG.[arg2]);
1241
1242 if(IsSubnormalcxx . . $ V810#IsSubnormal(dfa6e707f7696010).(result))
1243 {
1244 float_exception_flags |= float_flag_underflow;
1245 float_exception_flags |= float_flag_inexact;
1246 }
1247
1248 //printf("Result: %08x, %02x; %02x\n", result, (result >> 23) & 0xFF, float_exception_flags);
1249
1250 if(!FPU_DoesExceptionKillResultcxx . . $ V810#FPU_DoesExceptionKillResult(c9857a73d68e59ba).())
1251 {
1252 // Force it to +/- zero before setting S/Z based off of it(confirmed with subf.s on real V810, at least).
1253 if(float_exception_flags & float_flag_underflow)
1254 result &= 0x80000000;
1255
1256 SetFPUOPNonFPUFlagscxx . . $ V810#SetFPUOPNonFPUFlags(cb2f890c2fdad230).(result);
1257 SetPREGcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:497:9`!(arg1, result);
1258 }
1259 FPU_DoExceptioncxx . . $ V810#FPU_DoException(49f6e7a06ebc5aa8).();
1260 }
1261 }
1262
1263 void V810cxx . . $ V810#::fpu_subopcxx . . $ V810#fpu_subop(987d23217e21f876).(v810_timestamp_tcxx . . $ v810_timestamp_t# &timestamp, int sub_op, int arg1, int arg2)
1264 {
1265 //printf("FPU: %02x\n", sub_op);
1266 if(VBModecxx . . $ V810#VBMode.)
1267 {
1268 switch(sub_op)
1269 {
1270 case XBcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:163:17`!: timestamp++; // Unknown
1271 P_REGcxx . . $ V810#P_REG.[arg1] = (P_REGcxx . . $ V810#P_REG.[arg1] & 0xFFFF0000) | ((P_REGcxx . . $ V810#P_REG.[arg1] & 0xFF) << 8) | ((P_REGcxx . . $ V810#P_REG.[arg1] & 0xFF00) >> 8);
1272 return;
1273
1274 case XHcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:164:17`!: timestamp++; // Unknown
1275 P_REGcxx . . $ V810#P_REG.[arg1] = (P_REGcxx . . $ V810#P_REG.[arg1] << 16) | (P_REGcxx . . $ V810#P_REG.[arg1] >> 16);
1276 return;
1277
1278 // Does REV use arg1 or arg2 for the source register?
1279 case REVcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:165:17`!: timestamp++; // Unknown
1280 printf("Revvie bits\n");
1281 {
1282 // Public-domain code snippet from: http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
1283 uint32cxx . . $ uint32# v = P_REGcxx . . $ V810#P_REG.[arg2]; // 32-bit word to reverse bit order
1284
1285 // swap odd and even bits
1286 v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1);
1287 // swap consecutive pairs
1288 v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2);
1289 // swap nibbles ...
1290 v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4);
1291 // swap bytes
1292 v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8);
1293 // swap 2-byte long pairs
1294 v = ( v >> 16 ) | ( v << 16);
1295
1296 P_REGcxx . . $ V810#P_REG.[arg1] = v;
1297 }
1298 return;
1299
1300 case MPYHWcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:167:17`!: timestamp += 9 - 1; // Unknown?
1301 P_REGcxx . . $ V810#P_REG.[arg1] = (int32cxx . . $ int32#)(int16cxx . . $ int16#)(P_REGcxx . . $ V810#P_REG.[arg1] & 0xFFFF) * (int32cxx . . $ int32#)(int16cxx . . $ int16#)(P_REGcxx . . $ V810#P_REG.[arg2] & 0xFFFF);
1302 return;
1303 }
1304 }
1305
1306 switch(sub_op)
1307 {
1308 // Virtual-Boy specific(probably!)
1309 default:
1310 {
1311 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(GetPCcxx . . $ V810#GetPC(db52760e79bf9054).() - 4);
1312 Exceptioncxx . . $ V810#Exception(272d193675e92631).(INVALID_OP_HANDLER_ADDRcxx . . $ INVALID_OP_HANDLER_ADDR., ECODE_INVALID_OPcxx . . $ ECODE_INVALID_OP.);
1313 }
1314 break;
1315
1316 case CVT_WScxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:157:17`!:
1317 timestamp += 5;
1318 {
1319 uint32cxx . . $ uint32# result;
1320
1321 float_exception_flags = 0;
1322 result = int32_to_float32((int32cxx . . $ int32#)P_REGcxx . . $ V810#P_REG.[arg2]);
1323
1324 if(!FPU_DoesExceptionKillResultcxx . . $ V810#FPU_DoesExceptionKillResult(c9857a73d68e59ba).())
1325 {
1326 SetPREGcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:497:9`!(arg1, result);
1327 SetFPUOPNonFPUFlagscxx . . $ V810#SetFPUOPNonFPUFlags(cb2f890c2fdad230).(result);
1328 }
1329 else
1330 {
1331 puts("Exception on CVT.WS?????"); // This shouldn't happen, but just in case there's a bug...
1332 }
1333 FPU_DoExceptioncxx . . $ V810#FPU_DoException(49f6e7a06ebc5aa8).();
1334 }
1335 break; // End CVT.WS
1336
1337 case CVT_SWcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:158:17`!:
1338 timestamp += 8;
1339 if(CheckFPInputExceptioncxx . . $ V810#CheckFPInputException(dfa6e707f7696010).(P_REGcxx . . $ V810#P_REG.[arg2]))
1340 {
1341
1342 }
1343 else
1344 {
1345 int32cxx . . $ int32# result;
1346
1347 float_exception_flags = 0;
1348 result = float32_to_int32(P_REGcxx . . $ V810#P_REG.[arg2]);
1349
1350 if(!FPU_DoesExceptionKillResultcxx . . $ V810#FPU_DoesExceptionKillResult(c9857a73d68e59ba).())
1351 {
1352 SetPREGcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:497:9`!(arg1, result);
1353 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_OVcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:76:9`!, 0);
1354 SetSZcxx . . $ V810#SetSZ(cb2f890c2fdad230).(result);
1355 }
1356 FPU_DoExceptioncxx . . $ V810#FPU_DoException(49f6e7a06ebc5aa8).();
1357 }
1358 break; // End CVT.SW
1359
1360 case ADDF_Scxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:159:17`!: timestamp += 8;
1361 FPU_Math_Templatecxx . . $ V810#FPU_Math_Template(1534797a8d4dd0af).(float32_add, arg1, arg2);
1362 break;
1363
1364 case SUBF_Scxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:160:17`!: timestamp += 11;
1365 FPU_Math_Templatecxx . . $ V810#FPU_Math_Template(1534797a8d4dd0af).(float32_sub, arg1, arg2);
1366 break;
1367
1368 case CMPF_Scxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:155:17`!: timestamp += 6;
1369 // Don't handle this like subf.s because the flags
1370 // have slightly different semantics(mostly regarding underflow/subnormal results) (confirmed on real V810).
1371 if(CheckFPInputExceptioncxx . . $ V810#CheckFPInputException(dfa6e707f7696010).(P_REGcxx . . $ V810#P_REG.[arg1]) || CheckFPInputExceptioncxx . . $ V810#CheckFPInputException(dfa6e707f7696010).(P_REGcxx . . $ V810#P_REG.[arg2]))
1372 {
1373
1374 }
1375 else
1376 {
1377 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_OVcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:76:9`!, 0);
1378
1379 if(float32_eq(P_REGcxx . . $ V810#P_REG.[arg1], P_REGcxx . . $ V810#P_REG.[arg2]))
1380 {
1381 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Zcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:78:9`!, 1);
1382 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Scxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:77:9`!, 0);
1383 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_CYcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:75:9`!, 0);
1384 }
1385 else
1386 {
1387 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Zcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:78:9`!, 0);
1388
1389 if(float32_lt(P_REGcxx . . $ V810#P_REG.[arg1], P_REGcxx . . $ V810#P_REG.[arg2]))
1390 {
1391 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Scxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:77:9`!, 1);
1392 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_CYcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:75:9`!, 1);
1393 }
1394 else
1395 {
1396 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_Scxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:77:9`!, 0);
1397 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_CYcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:75:9`!, 0);
1398 }
1399 }
1400 } // else of if(CheckFP...
1401 break;
1402
1403 case MULF_Scxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:161:17`!: timestamp += 7;
1404 FPU_Math_Templatecxx . . $ V810#FPU_Math_Template(1534797a8d4dd0af).(float32_mul, arg1, arg2);
1405 break;
1406
1407 case DIVF_Scxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:162:17`!: timestamp += 43;
1408 FPU_Math_Templatecxx . . $ V810#FPU_Math_Template(1534797a8d4dd0af).(float32_div, arg1, arg2);
1409 break;
1410
1411 case TRNC_SWcxx . . $ `mednafen/hw_cpu/v810/v810_opt.h:166:17`!:
1412 timestamp += 7;
1413
1414 if(CheckFPInputExceptioncxx . . $ V810#CheckFPInputException(dfa6e707f7696010).(P_REGcxx . . $ V810#P_REG.[arg2]))
1415 {
1416
1417 }
1418 else
1419 {
1420 int32cxx . . $ int32# result;
1421
1422 float_exception_flags = 0;
1423 result = float32_to_int32_round_to_zero(P_REGcxx . . $ V810#P_REG.[arg2]);
1424
1425 if(!FPU_DoesExceptionKillResultcxx . . $ V810#FPU_DoesExceptionKillResult(c9857a73d68e59ba).())
1426 {
1427 SetPREGcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.cpp:497:9`!(arg1, result);
1428 SetFlagcxx . . $ V810#SetFlag(ee2069353d7cc01f).(PSW_OVcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:76:9`!, 0);
1429 SetSZcxx . . $ V810#SetSZ(cb2f890c2fdad230).(result);
1430 }
1431 FPU_DoExceptioncxx . . $ V810#FPU_DoException(49f6e7a06ebc5aa8).();
1432 }
1433 break; // end TRNC.SW
1434 }
1435 }
1436
1437 // Generate exception
1438 void V810cxx . . $ V810#::Exceptioncxx . . $ V810#Exception(272d193675e92631).(uint32cxx . . $ uint32# handler, uint16cxx . . $ uint16# eCode)
1439 {
1440 // Exception overhead is unknown.
1441
1442 #ifdef WANT_DEBUGGER
1443 if(ADDBT)
1444 {
1445 uint32 old_PC = GetPC();
1446
1447 if((eCode & 0xFFE0) == 0xFFA0) // Trap instruction(PC is pointing to next instruction at this point)
1448 old_PC -= 2;
1449
1450 ADDBT(old_PC, handler, eCode);
1451 }
1452 #endif
1453
1454 printf("Exception: %08x %04x\n", handler, eCode);
1455
1456 // Invalidate our bitstring state(forces the instruction to be re-read, and the r/w buffers reloaded).
1457 in_bstrcxx . . $ V810#in_bstr. = false;
1458 have_src_cachecxx . . $ V810#have_src_cache. = false;
1459 have_dst_cachecxx . . $ V810#have_dst_cache. = false;
1460
1461 if(S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] & PSW_NPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:60:9`!) // Fatal exception
1462 {
1463 printf("Fatal exception; Code: %08x, ECR: %08x, PSW: %08x, PC: %08x\n", eCode, S_REGcxx . . $ V810#S_REG.[ECRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:46:9`!], S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!], PCcxx . . $ V810#PC.);
1464 Haltedcxx . . $ V810#Halted. = HALT_FATAL_EXCEPTIONcxx . . $ V810#HALT_FATAL_EXCEPTION.;
1465 IPendingCachecxx . . $ V810#IPendingCache. = 0;
1466 return;
1467 }
1468 else if(S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] & PSW_EPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:61:9`!) //Double Exception
1469 {
1470 S_REGcxx . . $ V810#S_REG.[FEPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:43:9`!] = GetPCcxx . . $ V810#GetPC(db52760e79bf9054).();
1471 S_REGcxx . . $ V810#S_REG.[FEPSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:44:9`!] = S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!];
1472
1473 S_REGcxx . . $ V810#S_REG.[ECRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:46:9`!] = (S_REGcxx . . $ V810#S_REG.[ECRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:46:9`!] & 0xFFFF) | (eCode << 16);
1474 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_NPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:60:9`!;
1475 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_IDcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:65:9`!;
1476 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] &= ~PSW_AEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:63:9`!;
1477
1478 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(0xFFFFFFD0);
1479 IPendingCachecxx . . $ V810#IPendingCache. = 0;
1480 return;
1481 }
1482 else // Regular exception
1483 {
1484 S_REGcxx . . $ V810#S_REG.[EIPCcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:40:9`!] = GetPCcxx . . $ V810#GetPC(db52760e79bf9054).();
1485 S_REGcxx . . $ V810#S_REG.[EIPSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:41:9`!] = S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!];
1486 S_REGcxx . . $ V810#S_REG.[ECRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:46:9`!] = (S_REGcxx . . $ V810#S_REG.[ECRcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:46:9`!] & 0xFFFF0000) | eCode;
1487 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_EPcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:61:9`!;
1488 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] |= PSW_IDcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:65:9`!;
1489 S_REGcxx . . $ V810#S_REG.[PSWcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:47:9`!] &= ~PSW_AEcxx . . $ `mednafen/hw_cpu/v810/v810_cpu.h:63:9`!;
1490
1491 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(handler);
1492 IPendingCachecxx . . $ V810#IPendingCache. = 0;
1493 return;
1494 }
1495 }
1496
1497 int V810cxx . . $ V810#::StateActioncxx . . $ V810#StateAction(a45b884b8cf568d5).(StateMemcxx . . $ StateMem# *sm, int load, int data_only)
1498 {
1499 uint32cxx . . $ uint32# *cache_tag_temp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1500 uint32cxx . . $ uint32# *cache_data_temp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1501 bool *cache_data_valid_temp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1502 uint32cxx . . $ uint32# PC_tmp = GetPCcxx . . $ V810#GetPC(db52760e79bf9054).();
1503
1504 if(EmuModecxx . . $ V810#EmuMode. == V810_EMU_MODE_ACCURATEcxx . . $ V810_EMU_MODE_ACCURATE.)
1505 {
1506 cache_tag_temp = (uint32cxx . . $ uint32# *)malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(uint32cxx . . $ uint32# *) * 128);
1507 cache_data_temp = (uint32cxx . . $ uint32# *)malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(uint32cxx . . $ uint32# *) * 128 * 2);
1508 cache_data_valid_temp = (bool *)malloccxx . . $ malloc(9f008b2a9698428b).(sizeof(bool *) * 128 * 2);
1509
1510 if(!cache_tag_temp || !cache_data_temp || !cache_data_valid_temp)
1511 {
1512 if(cache_tag_temp)
1513 freecxx . . $ free(bd21765a0afc8e3c).(cache_tag_temp);
1514
1515 if(cache_data_temp)
1516 freecxx . . $ free(bd21765a0afc8e3c).(cache_data_temp);
1517
1518 if(cache_data_valid_temp)
1519 freecxx . . $ free(bd21765a0afc8e3c).(cache_data_valid_temp);
1520
1521 return(0);
1522 }
1523 if(!load)
1524 {
1525 for(int i = 0; i < 128; i++)
1526 {
1527 cache_tag_temp[i] = Cachecxx . . $ V810#Cache.[i].tagcxx . . $ V810#$anonymous_type_5#tag.;
1528
1529 cache_data_temp[i * 2 + 0] = Cachecxx . . $ V810#Cache.[i].datacxx . . $ V810#$anonymous_type_5#data.[0];
1530 cache_data_temp[i * 2 + 1] = Cachecxx . . $ V810#Cache.[i].datacxx . . $ V810#$anonymous_type_5#data.[1];
1531
1532 cache_data_valid_temp[i * 2 + 0] = Cachecxx . . $ V810#Cache.[i].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[0];
1533 cache_data_valid_temp[i * 2 + 1] = Cachecxx . . $ V810#Cache.[i].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[1];
1534 }
1535 }
1536 else // If we're loading, go ahead and clear the cache temporaries,
1537 // in case the save state was saved while in fast mode
1538 // and the cache data isn't present and thus won't be loaded.
1539 {
1540 memset(cache_tag_temp, 0, sizeof(uint32cxx . . $ uint32#) * 128);
1541 memset(cache_data_temp, 0, sizeof(uint32cxx . . $ uint32#) * 128 * 2);
1542 memset(cache_data_valid_temp, 0, sizeof(bool) * 128 * 2);
1543 }
1544 }
1545
1546 int32cxx . . $ int32# next_event_ts_delta = next_event_tscxx . . $ V810#next_event_ts. - v810_timestampcxx . . $ V810#v810_timestamp.;
1547
1548 SFORMATcxx . . $ SFORMAT# StateRegs[] =
1549 {
1550 SFARRAY32cxx . . $ `mednafen/state.h:84:9`!(P_REG, 32),
1551 SFARRAY32cxx . . $ `mednafen/state.h:84:9`!(S_REG, 32),
1552 SFVARNcxx . . $ `mednafen/state.h:71:9`!(PC_tmp, "PC"),
1553 SFVARcxx . . $ `mednafen/state.h:72:9`!(Halted),
1554
1555 SFVARcxx . . $ `mednafen/state.h:72:9`!(lastop),
1556
1557 SFARRAY32cxx . . $ `mednafen/state.h:84:9`!(cache_tag_temp, 128),
1558 SFARRAY32cxx . . $ `mednafen/state.h:84:9`!(cache_data_temp, 128 * 2),
1559 SFARRAYBcxx . . $ `mednafen/state.h:78:9`!(cache_data_valid_temp, 128 * 2),
1560
1561 SFVARcxx . . $ `mednafen/state.h:72:9`!(ilevel), // Perhaps remove in future?
1562 SFVARcxx . . $ `mednafen/state.h:72:9`!(next_event_ts_delta),
1563
1564 // Bitstring stuff:
1565 SFVARcxx . . $ `mednafen/state.h:72:9`!(src_cache),
1566 SFVARcxx . . $ `mednafen/state.h:72:9`!(dst_cache),
1567 SFVARcxx . . $ `mednafen/state.h:72:9`!(have_src_cache),
1568 SFVARcxx . . $ `mednafen/state.h:72:9`!(have_dst_cache),
1569 SFVARcxx . . $ `mednafen/state.h:72:9`!(in_bstr),
1570 SFVARcxx . . $ `mednafen/state.h:72:9`!(in_bstr_to),
1571
1572 SFENDcxx . . $ `mednafen/state.h:96:9`!
1573 };
1574
1575 int ret = MDFNSS_StateActioncxx . . $ MDFNSS_StateAction(3f628545d3b0df83).(sm, load, data_only, StateRegs, "V810");
1576
1577 if(load)
1578 {
1579 // std::max is sanity check for a corrupted save state to not crash emulation,
1580 // std::min<int64>(0x7FF... is a sanity check and for the case where next_event_ts is set to an extremely large value to
1581 // denote that it's not happening anytime soon, which could cause an overflow if our current timestamp is larger
1582 // than what it was when the state was saved.
1583 next_event_tscxx . . $ V810#next_event_ts. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).<int64cxx . . $ int64#>(v810_timestampcxx . . $ V810#v810_timestamp., stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<int64cxx . . $ int64#>(0x7FFFFFFF, (int64cxx . . $ int64#)v810_timestampcxx . . $ V810#v810_timestamp. + next_event_ts_delta));
1584
1585 RecalcIPendingCachecxx . . $ V810#RecalcIPendingCache(49f6e7a06ebc5aa8).();
1586
1587 SetPCcxx . . $ V810#SetPC(cb2f890c2fdad230).(PC_tmp);
1588 if(EmuModecxx . . $ V810#EmuMode. == V810_EMU_MODE_ACCURATEcxx . . $ V810_EMU_MODE_ACCURATE.)
1589 {
1590 for(int i = 0; i < 128; i++)
1591 {
1592 Cachecxx . . $ V810#Cache.[i].tagcxx . . $ V810#$anonymous_type_5#tag. = cache_tag_temp[i];
1593
1594 Cachecxx . . $ V810#Cache.[i].datacxx . . $ V810#$anonymous_type_5#data.[0] = cache_data_temp[i * 2 + 0];
1595 Cachecxx . . $ V810#Cache.[i].datacxx . . $ V810#$anonymous_type_5#data.[1] = cache_data_temp[i * 2 + 1];
1596
1597 Cachecxx . . $ V810#Cache.[i].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[0] = cache_data_valid_temp[i * 2 + 0];
1598 Cachecxx . . $ V810#Cache.[i].data_validcxx . . $ V810#$anonymous_type_5#data_valid.[1] = cache_data_valid_temp[i * 2 + 1];
1599
1600 //printf("%d %08x %08x %08x %d %d\n", i, Cache[i].tag << 10, Cache[i].data[0], Cache[i].data[1], Cache[i].data_valid[0], Cache[i].data_valid[1]);
1601 }
1602 }
1603 }
1604
1605 if(EmuModecxx . . $ V810#EmuMode. == V810_EMU_MODE_ACCURATEcxx . . $ V810_EMU_MODE_ACCURATE.)
1606 {
1607 freecxx . . $ free(bd21765a0afc8e3c).(cache_tag_temp);
1608 freecxx . . $ free(bd21765a0afc8e3c).(cache_data_temp);
1609 freecxx . . $ free(bd21765a0afc8e3c).(cache_data_valid_temp);
1610 }
1611
1612 return(ret);
1613 }