| ... | ... |
@@ -175,8 +175,7 @@ |
| 175 | 175 |
Nintendo Co., Limited and its subsidiary companies. |
| 176 | 176 |
***********************************************************************************/ |
| 177 | 177 |
|
| 178 |
-#ifndef _CPUEXEC_H_ |
|
| 179 |
-#define _CPUEXEC_H_ |
|
| 178 |
+#pragma once |
|
| 180 | 179 |
|
| 181 | 180 |
#include "ppu.h" |
| 182 | 181 |
|
| ... | ... |
@@ -297,5 +296,3 @@ inline void S9xCheckInterrupts() |
| 297 | 296 |
|
| 298 | 297 |
CPU.IRQLastState = thisIRQ; |
| 299 | 298 |
} |
| 300 |
- |
|
| 301 |
-#endif |
| ... | ... |
@@ -175,14 +175,10 @@ |
| 175 | 175 |
Nintendo Co., Limited and its subsidiary companies. |
| 176 | 176 |
***********************************************************************************/ |
| 177 | 177 |
|
| 178 |
- |
|
| 179 | 178 |
#ifndef _CPUEXEC_H_ |
| 180 | 179 |
#define _CPUEXEC_H_ |
| 181 | 180 |
|
| 182 | 181 |
#include "ppu.h" |
| 183 |
-#ifdef DEBUGGER |
|
| 184 |
-#include "debug.h" |
|
| 185 |
-#endif |
|
| 186 | 182 |
|
| 187 | 183 |
struct SOpcodes |
| 188 | 184 |
{
|
| ... | ... |
@@ -191,59 +187,57 @@ struct SOpcodes |
| 191 | 187 |
|
| 192 | 188 |
struct SICPU |
| 193 | 189 |
{
|
| 194 |
- struct SOpcodes *S9xOpcodes; |
|
| 195 |
- uint8_t *S9xOpLengths; |
|
| 196 |
- uint8_t _Carry; |
|
| 197 |
- uint8_t _Zero; |
|
| 198 |
- uint8_t _Negative; |
|
| 199 |
- uint8_t _Overflow; |
|
| 200 |
- uint32_t ShiftedPB; |
|
| 201 |
- uint32_t ShiftedDB; |
|
| 202 |
- uint32_t Frame; |
|
| 203 |
- uint32_t FrameAdvanceCount; |
|
| 190 |
+ SOpcodes *S9xOpcodes; |
|
| 191 |
+ uint8_t *S9xOpLengths; |
|
| 192 |
+ uint8_t _Carry; |
|
| 193 |
+ uint8_t _Zero; |
|
| 194 |
+ uint8_t _Negative; |
|
| 195 |
+ uint8_t _Overflow; |
|
| 196 |
+ uint32_t ShiftedPB; |
|
| 197 |
+ uint32_t ShiftedDB; |
|
| 204 | 198 |
}; |
| 205 | 199 |
|
| 206 |
-extern struct SICPU ICPU; |
|
| 200 |
+extern SICPU ICPU; |
|
| 207 | 201 |
|
| 208 |
-extern struct SOpcodes S9xOpcodesE1[256]; |
|
| 209 |
-extern struct SOpcodes S9xOpcodesM1X1[256]; |
|
| 210 |
-extern struct SOpcodes S9xOpcodesM1X0[256]; |
|
| 211 |
-extern struct SOpcodes S9xOpcodesM0X1[256]; |
|
| 212 |
-extern struct SOpcodes S9xOpcodesM0X0[256]; |
|
| 213 |
-extern struct SOpcodes S9xOpcodesSlow[256]; |
|
| 214 |
-extern uint8_t S9xOpLengthsM1X1[256]; |
|
| 215 |
-extern uint8_t S9xOpLengthsM1X0[256]; |
|
| 216 |
-extern uint8_t S9xOpLengthsM0X1[256]; |
|
| 217 |
-extern uint8_t S9xOpLengthsM0X0[256]; |
|
| 202 |
+extern SOpcodes S9xOpcodesE1[256]; |
|
| 203 |
+extern SOpcodes S9xOpcodesM1X1[256]; |
|
| 204 |
+extern SOpcodes S9xOpcodesM1X0[256]; |
|
| 205 |
+extern SOpcodes S9xOpcodesM0X1[256]; |
|
| 206 |
+extern SOpcodes S9xOpcodesM0X0[256]; |
|
| 207 |
+extern SOpcodes S9xOpcodesSlow[256]; |
|
| 208 |
+extern uint8_t S9xOpLengthsM1X1[256]; |
|
| 209 |
+extern uint8_t S9xOpLengthsM1X0[256]; |
|
| 210 |
+extern uint8_t S9xOpLengthsM0X1[256]; |
|
| 211 |
+extern uint8_t S9xOpLengthsM0X0[256]; |
|
| 218 | 212 |
|
| 219 | 213 |
void S9xMainLoop(); |
| 220 | 214 |
void S9xReset(); |
| 221 |
-void S9xSoftReset(); |
|
| 222 | 215 |
void S9xDoHEventProcessing(); |
| 223 | 216 |
|
| 224 |
-static inline void S9xUnpackStatus() |
|
| 217 |
+#include "65c816.h" |
|
| 218 |
+ |
|
| 219 |
+inline void S9xUnpackStatus() |
|
| 225 | 220 |
{
|
| 226 |
- ICPU._Zero = (Registers.PL & Zero) == 0; |
|
| 227 |
- ICPU._Negative = (Registers.PL & Negative); |
|
| 228 |
- ICPU._Carry = (Registers.PL & Carry); |
|
| 229 |
- ICPU._Overflow = (Registers.PL & Overflow) >> 6; |
|
| 221 |
+ ICPU._Zero = !(Registers.P.B.l & Zero); |
|
| 222 |
+ ICPU._Negative = Registers.P.B.l & Negative; |
|
| 223 |
+ ICPU._Carry = Registers.P.B.l & Carry; |
|
| 224 |
+ ICPU._Overflow = (Registers.P.B.l & Overflow) >> 6; |
|
| 230 | 225 |
} |
| 231 | 226 |
|
| 232 |
-static inline void S9xPackStatus() |
|
| 227 |
+inline void S9xPackStatus() |
|
| 233 | 228 |
{
|
| 234 |
- Registers.PL &= ~(Zero | Negative | Carry | Overflow); |
|
| 235 |
- Registers.PL |= ICPU._Carry | ((ICPU._Zero == 0) << 1) | (ICPU._Negative & 0x80) | (ICPU._Overflow << 6); |
|
| 229 |
+ Registers.P.B.l &= ~(Zero | Negative | Carry | Overflow); |
|
| 230 |
+ Registers.P.B.l |= ICPU._Carry | ((!ICPU._Zero) << 1) | (ICPU._Negative & 0x80) | (ICPU._Overflow << 6); |
|
| 236 | 231 |
} |
| 237 | 232 |
|
| 238 |
-static inline void S9xFixCycles() |
|
| 233 |
+inline void S9xFixCycles() |
|
| 239 | 234 |
{
|
| 240 | 235 |
if (CheckEmulation()) |
| 241 | 236 |
{
|
| 242 | 237 |
ICPU.S9xOpcodes = S9xOpcodesE1; |
| 243 | 238 |
ICPU.S9xOpLengths = S9xOpLengthsM1X1; |
| 244 | 239 |
} |
| 245 |
- else |
|
| 246 |
- if (CheckMemory()) |
|
| 240 |
+ else if (CheckMemory()) |
|
| 247 | 241 |
{
|
| 248 | 242 |
if (CheckIndex()) |
| 249 | 243 |
{
|
| ... | ... |
@@ -271,16 +265,16 @@ static inline void S9xFixCycles() |
| 271 | 265 |
} |
| 272 | 266 |
} |
| 273 | 267 |
|
| 274 |
-static inline void S9xCheckInterrupts() |
|
| 268 |
+inline void S9xCheckInterrupts() |
|
| 275 | 269 |
{
|
| 276 |
- bool thisIRQ = PPU.HTimerEnabled || PPU.VTimerEnabled; |
|
| 270 |
+ bool thisIRQ = PPU.HTimerEnabled || PPU.VTimerEnabled; |
|
| 277 | 271 |
|
| 278 | 272 |
if (CPU.IRQLine && thisIRQ) |
| 279 | 273 |
CPU.IRQTransition = true; |
| 280 | 274 |
|
| 281 | 275 |
if (PPU.HTimerEnabled) |
| 282 | 276 |
{
|
| 283 |
- int32_t htimepos = PPU.HTimerPosition; |
|
| 277 |
+ int32_t htimepos = PPU.HTimerPosition; |
|
| 284 | 278 |
if (CPU.Cycles >= Timings.H_Max) |
| 285 | 279 |
htimepos += Timings.H_Max; |
| 286 | 280 |
|
| ... | ... |
@@ -290,22 +284,16 @@ static inline void S9xCheckInterrupts() |
| 290 | 284 |
|
| 291 | 285 |
if (PPU.VTimerEnabled) |
| 292 | 286 |
{
|
| 293 |
- int32_t vcounter = CPU.V_Counter; |
|
| 287 |
+ int32_t vcounter = CPU.V_Counter; |
|
| 294 | 288 |
if (CPU.Cycles >= Timings.H_Max) |
| 295 |
- vcounter++; |
|
| 289 |
+ ++vcounter; |
|
| 296 | 290 |
|
| 297 | 291 |
if (vcounter != PPU.VTimerPosition) |
| 298 | 292 |
thisIRQ = false; |
| 299 | 293 |
} |
| 300 | 294 |
|
| 301 | 295 |
if (!CPU.IRQLastState && thisIRQ) |
| 302 |
- {
|
|
| 303 |
-#ifdef DEBUGGER |
|
| 304 |
- S9xTraceFormattedMessage("--- /IRQ High->Low prev HC:%04d curr HC:%04d HTimer:%d Pos:%04d VTimer:%d Pos:%03d",
|
|
| 305 |
- CPU.PrevCycles, CPU.Cycles, PPU.HTimerEnabled, PPU.HTimerPosition, PPU.VTimerEnabled, PPU.VTimerPosition); |
|
| 306 |
-#endif |
|
| 307 | 296 |
CPU.IRQLine = true; |
| 308 |
- } |
|
| 309 | 297 |
|
| 310 | 298 |
CPU.IRQLastState = thisIRQ; |
| 311 | 299 |
} |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,313 @@ |
| 1 |
+/*********************************************************************************** |
|
| 2 |
+ Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. |
|
| 3 |
+ |
|
| 4 |
+ (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), |
|
| 5 |
+ Jerremy Koot (jkoot@snes9x.com) |
|
| 6 |
+ |
|
| 7 |
+ (c) Copyright 2002 - 2004 Matthew Kendora |
|
| 8 |
+ |
|
| 9 |
+ (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) |
|
| 10 |
+ |
|
| 11 |
+ (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) |
|
| 12 |
+ |
|
| 13 |
+ (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) |
|
| 14 |
+ |
|
| 15 |
+ (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), |
|
| 16 |
+ Kris Bleakley (codeviolation@hotmail.com) |
|
| 17 |
+ |
|
| 18 |
+ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), |
|
| 19 |
+ Nach (n-a-c-h@users.sourceforge.net), |
|
| 20 |
+ |
|
| 21 |
+ (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) |
|
| 22 |
+ |
|
| 23 |
+ (c) Copyright 2006 - 2007 nitsuja |
|
| 24 |
+ |
|
| 25 |
+ (c) Copyright 2009 - 2011 BearOso, |
|
| 26 |
+ OV2 |
|
| 27 |
+ |
|
| 28 |
+ |
|
| 29 |
+ BS-X C emulator code |
|
| 30 |
+ (c) Copyright 2005 - 2006 Dreamer Nom, |
|
| 31 |
+ zones |
|
| 32 |
+ |
|
| 33 |
+ C4 x86 assembler and some C emulation code |
|
| 34 |
+ (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), |
|
| 35 |
+ Nach, |
|
| 36 |
+ zsKnight (zsknight@zsnes.com) |
|
| 37 |
+ |
|
| 38 |
+ C4 C++ code |
|
| 39 |
+ (c) Copyright 2003 - 2006 Brad Jorsch, |
|
| 40 |
+ Nach |
|
| 41 |
+ |
|
| 42 |
+ DSP-1 emulator code |
|
| 43 |
+ (c) Copyright 1998 - 2006 _Demo_, |
|
| 44 |
+ Andreas Naive (andreasnaive@gmail.com), |
|
| 45 |
+ Gary Henderson, |
|
| 46 |
+ Ivar (ivar@snes9x.com), |
|
| 47 |
+ John Weidman, |
|
| 48 |
+ Kris Bleakley, |
|
| 49 |
+ Matthew Kendora, |
|
| 50 |
+ Nach, |
|
| 51 |
+ neviksti (neviksti@hotmail.com) |
|
| 52 |
+ |
|
| 53 |
+ DSP-2 emulator code |
|
| 54 |
+ (c) Copyright 2003 John Weidman, |
|
| 55 |
+ Kris Bleakley, |
|
| 56 |
+ Lord Nightmare (lord_nightmare@users.sourceforge.net), |
|
| 57 |
+ Matthew Kendora, |
|
| 58 |
+ neviksti |
|
| 59 |
+ |
|
| 60 |
+ DSP-3 emulator code |
|
| 61 |
+ (c) Copyright 2003 - 2006 John Weidman, |
|
| 62 |
+ Kris Bleakley, |
|
| 63 |
+ Lancer, |
|
| 64 |
+ z80 gaiden |
|
| 65 |
+ |
|
| 66 |
+ DSP-4 emulator code |
|
| 67 |
+ (c) Copyright 2004 - 2006 Dreamer Nom, |
|
| 68 |
+ John Weidman, |
|
| 69 |
+ Kris Bleakley, |
|
| 70 |
+ Nach, |
|
| 71 |
+ z80 gaiden |
|
| 72 |
+ |
|
| 73 |
+ OBC1 emulator code |
|
| 74 |
+ (c) Copyright 2001 - 2004 zsKnight, |
|
| 75 |
+ pagefault (pagefault@zsnes.com), |
|
| 76 |
+ Kris Bleakley |
|
| 77 |
+ Ported from x86 assembler to C by sanmaiwashi |
|
| 78 |
+ |
|
| 79 |
+ SPC7110 and RTC C++ emulator code used in 1.39-1.51 |
|
| 80 |
+ (c) Copyright 2002 Matthew Kendora with research by |
|
| 81 |
+ zsKnight, |
|
| 82 |
+ John Weidman, |
|
| 83 |
+ Dark Force |
|
| 84 |
+ |
|
| 85 |
+ SPC7110 and RTC C++ emulator code used in 1.52+ |
|
| 86 |
+ (c) Copyright 2009 byuu, |
|
| 87 |
+ neviksti |
|
| 88 |
+ |
|
| 89 |
+ S-DD1 C emulator code |
|
| 90 |
+ (c) Copyright 2003 Brad Jorsch with research by |
|
| 91 |
+ Andreas Naive, |
|
| 92 |
+ John Weidman |
|
| 93 |
+ |
|
| 94 |
+ S-RTC C emulator code |
|
| 95 |
+ (c) Copyright 2001 - 2006 byuu, |
|
| 96 |
+ John Weidman |
|
| 97 |
+ |
|
| 98 |
+ ST010 C++ emulator code |
|
| 99 |
+ (c) Copyright 2003 Feather, |
|
| 100 |
+ John Weidman, |
|
| 101 |
+ Kris Bleakley, |
|
| 102 |
+ Matthew Kendora |
|
| 103 |
+ |
|
| 104 |
+ Super FX x86 assembler emulator code |
|
| 105 |
+ (c) Copyright 1998 - 2003 _Demo_, |
|
| 106 |
+ pagefault, |
|
| 107 |
+ zsKnight |
|
| 108 |
+ |
|
| 109 |
+ Super FX C emulator code |
|
| 110 |
+ (c) Copyright 1997 - 1999 Ivar, |
|
| 111 |
+ Gary Henderson, |
|
| 112 |
+ John Weidman |
|
| 113 |
+ |
|
| 114 |
+ Sound emulator code used in 1.5-1.51 |
|
| 115 |
+ (c) Copyright 1998 - 2003 Brad Martin |
|
| 116 |
+ (c) Copyright 1998 - 2006 Charles Bilyue' |
|
| 117 |
+ |
|
| 118 |
+ Sound emulator code used in 1.52+ |
|
| 119 |
+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) |
|
| 120 |
+ |
|
| 121 |
+ SH assembler code partly based on x86 assembler code |
|
| 122 |
+ (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) |
|
| 123 |
+ |
|
| 124 |
+ 2xSaI filter |
|
| 125 |
+ (c) Copyright 1999 - 2001 Derek Liauw Kie Fa |
|
| 126 |
+ |
|
| 127 |
+ HQ2x, HQ3x, HQ4x filters |
|
| 128 |
+ (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) |
|
| 129 |
+ |
|
| 130 |
+ NTSC filter |
|
| 131 |
+ (c) Copyright 2006 - 2007 Shay Green |
|
| 132 |
+ |
|
| 133 |
+ GTK+ GUI code |
|
| 134 |
+ (c) Copyright 2004 - 2011 BearOso |
|
| 135 |
+ |
|
| 136 |
+ Win32 GUI code |
|
| 137 |
+ (c) Copyright 2003 - 2006 blip, |
|
| 138 |
+ funkyass, |
|
| 139 |
+ Matthew Kendora, |
|
| 140 |
+ Nach, |
|
| 141 |
+ nitsuja |
|
| 142 |
+ (c) Copyright 2009 - 2011 OV2 |
|
| 143 |
+ |
|
| 144 |
+ Mac OS GUI code |
|
| 145 |
+ (c) Copyright 1998 - 2001 John Stiles |
|
| 146 |
+ (c) Copyright 2001 - 2011 zones |
|
| 147 |
+ |
|
| 148 |
+ |
|
| 149 |
+ Specific ports contains the works of other authors. See headers in |
|
| 150 |
+ individual files. |
|
| 151 |
+ |
|
| 152 |
+ |
|
| 153 |
+ Snes9x homepage: http://www.snes9x.com/ |
|
| 154 |
+ |
|
| 155 |
+ Permission to use, copy, modify and/or distribute Snes9x in both binary |
|
| 156 |
+ and source form, for non-commercial purposes, is hereby granted without |
|
| 157 |
+ fee, providing that this license information and copyright notice appear |
|
| 158 |
+ with all copies and any derived work. |
|
| 159 |
+ |
|
| 160 |
+ This software is provided 'as-is', without any express or implied |
|
| 161 |
+ warranty. In no event shall the authors be held liable for any damages |
|
| 162 |
+ arising from the use of this software or it's derivatives. |
|
| 163 |
+ |
|
| 164 |
+ Snes9x is freeware for PERSONAL USE only. Commercial users should |
|
| 165 |
+ seek permission of the copyright holders first. Commercial use includes, |
|
| 166 |
+ but is not limited to, charging money for Snes9x or software derived from |
|
| 167 |
+ Snes9x, including Snes9x or derivatives in commercial game bundles, and/or |
|
| 168 |
+ using Snes9x as a promotion for your commercial product. |
|
| 169 |
+ |
|
| 170 |
+ The copyright holders request that bug fixes and improvements to the code |
|
| 171 |
+ should be forwarded to them so everyone can benefit from the modifications |
|
| 172 |
+ in future versions. |
|
| 173 |
+ |
|
| 174 |
+ Super NES and Super Nintendo Entertainment System are trademarks of |
|
| 175 |
+ Nintendo Co., Limited and its subsidiary companies. |
|
| 176 |
+ ***********************************************************************************/ |
|
| 177 |
+ |
|
| 178 |
+ |
|
| 179 |
+#ifndef _CPUEXEC_H_ |
|
| 180 |
+#define _CPUEXEC_H_ |
|
| 181 |
+ |
|
| 182 |
+#include "ppu.h" |
|
| 183 |
+#ifdef DEBUGGER |
|
| 184 |
+#include "debug.h" |
|
| 185 |
+#endif |
|
| 186 |
+ |
|
| 187 |
+struct SOpcodes |
|
| 188 |
+{
|
|
| 189 |
+ void (*S9xOpcode)(); |
|
| 190 |
+}; |
|
| 191 |
+ |
|
| 192 |
+struct SICPU |
|
| 193 |
+{
|
|
| 194 |
+ struct SOpcodes *S9xOpcodes; |
|
| 195 |
+ uint8_t *S9xOpLengths; |
|
| 196 |
+ uint8_t _Carry; |
|
| 197 |
+ uint8_t _Zero; |
|
| 198 |
+ uint8_t _Negative; |
|
| 199 |
+ uint8_t _Overflow; |
|
| 200 |
+ uint32_t ShiftedPB; |
|
| 201 |
+ uint32_t ShiftedDB; |
|
| 202 |
+ uint32_t Frame; |
|
| 203 |
+ uint32_t FrameAdvanceCount; |
|
| 204 |
+}; |
|
| 205 |
+ |
|
| 206 |
+extern struct SICPU ICPU; |
|
| 207 |
+ |
|
| 208 |
+extern struct SOpcodes S9xOpcodesE1[256]; |
|
| 209 |
+extern struct SOpcodes S9xOpcodesM1X1[256]; |
|
| 210 |
+extern struct SOpcodes S9xOpcodesM1X0[256]; |
|
| 211 |
+extern struct SOpcodes S9xOpcodesM0X1[256]; |
|
| 212 |
+extern struct SOpcodes S9xOpcodesM0X0[256]; |
|
| 213 |
+extern struct SOpcodes S9xOpcodesSlow[256]; |
|
| 214 |
+extern uint8_t S9xOpLengthsM1X1[256]; |
|
| 215 |
+extern uint8_t S9xOpLengthsM1X0[256]; |
|
| 216 |
+extern uint8_t S9xOpLengthsM0X1[256]; |
|
| 217 |
+extern uint8_t S9xOpLengthsM0X0[256]; |
|
| 218 |
+ |
|
| 219 |
+void S9xMainLoop(); |
|
| 220 |
+void S9xReset(); |
|
| 221 |
+void S9xSoftReset(); |
|
| 222 |
+void S9xDoHEventProcessing(); |
|
| 223 |
+ |
|
| 224 |
+static inline void S9xUnpackStatus() |
|
| 225 |
+{
|
|
| 226 |
+ ICPU._Zero = (Registers.PL & Zero) == 0; |
|
| 227 |
+ ICPU._Negative = (Registers.PL & Negative); |
|
| 228 |
+ ICPU._Carry = (Registers.PL & Carry); |
|
| 229 |
+ ICPU._Overflow = (Registers.PL & Overflow) >> 6; |
|
| 230 |
+} |
|
| 231 |
+ |
|
| 232 |
+static inline void S9xPackStatus() |
|
| 233 |
+{
|
|
| 234 |
+ Registers.PL &= ~(Zero | Negative | Carry | Overflow); |
|
| 235 |
+ Registers.PL |= ICPU._Carry | ((ICPU._Zero == 0) << 1) | (ICPU._Negative & 0x80) | (ICPU._Overflow << 6); |
|
| 236 |
+} |
|
| 237 |
+ |
|
| 238 |
+static inline void S9xFixCycles() |
|
| 239 |
+{
|
|
| 240 |
+ if (CheckEmulation()) |
|
| 241 |
+ {
|
|
| 242 |
+ ICPU.S9xOpcodes = S9xOpcodesE1; |
|
| 243 |
+ ICPU.S9xOpLengths = S9xOpLengthsM1X1; |
|
| 244 |
+ } |
|
| 245 |
+ else |
|
| 246 |
+ if (CheckMemory()) |
|
| 247 |
+ {
|
|
| 248 |
+ if (CheckIndex()) |
|
| 249 |
+ {
|
|
| 250 |
+ ICPU.S9xOpcodes = S9xOpcodesM1X1; |
|
| 251 |
+ ICPU.S9xOpLengths = S9xOpLengthsM1X1; |
|
| 252 |
+ } |
|
| 253 |
+ else |
|
| 254 |
+ {
|
|
| 255 |
+ ICPU.S9xOpcodes = S9xOpcodesM1X0; |
|
| 256 |
+ ICPU.S9xOpLengths = S9xOpLengthsM1X0; |
|
| 257 |
+ } |
|
| 258 |
+ } |
|
| 259 |
+ else |
|
| 260 |
+ {
|
|
| 261 |
+ if (CheckIndex()) |
|
| 262 |
+ {
|
|
| 263 |
+ ICPU.S9xOpcodes = S9xOpcodesM0X1; |
|
| 264 |
+ ICPU.S9xOpLengths = S9xOpLengthsM0X1; |
|
| 265 |
+ } |
|
| 266 |
+ else |
|
| 267 |
+ {
|
|
| 268 |
+ ICPU.S9xOpcodes = S9xOpcodesM0X0; |
|
| 269 |
+ ICPU.S9xOpLengths = S9xOpLengthsM0X0; |
|
| 270 |
+ } |
|
| 271 |
+ } |
|
| 272 |
+} |
|
| 273 |
+ |
|
| 274 |
+static inline void S9xCheckInterrupts() |
|
| 275 |
+{
|
|
| 276 |
+ bool thisIRQ = PPU.HTimerEnabled || PPU.VTimerEnabled; |
|
| 277 |
+ |
|
| 278 |
+ if (CPU.IRQLine && thisIRQ) |
|
| 279 |
+ CPU.IRQTransition = true; |
|
| 280 |
+ |
|
| 281 |
+ if (PPU.HTimerEnabled) |
|
| 282 |
+ {
|
|
| 283 |
+ int32_t htimepos = PPU.HTimerPosition; |
|
| 284 |
+ if (CPU.Cycles >= Timings.H_Max) |
|
| 285 |
+ htimepos += Timings.H_Max; |
|
| 286 |
+ |
|
| 287 |
+ if (CPU.PrevCycles >= htimepos || CPU.Cycles < htimepos) |
|
| 288 |
+ thisIRQ = false; |
|
| 289 |
+ } |
|
| 290 |
+ |
|
| 291 |
+ if (PPU.VTimerEnabled) |
|
| 292 |
+ {
|
|
| 293 |
+ int32_t vcounter = CPU.V_Counter; |
|
| 294 |
+ if (CPU.Cycles >= Timings.H_Max) |
|
| 295 |
+ vcounter++; |
|
| 296 |
+ |
|
| 297 |
+ if (vcounter != PPU.VTimerPosition) |
|
| 298 |
+ thisIRQ = false; |
|
| 299 |
+ } |
|
| 300 |
+ |
|
| 301 |
+ if (!CPU.IRQLastState && thisIRQ) |
|
| 302 |
+ {
|
|
| 303 |
+#ifdef DEBUGGER |
|
| 304 |
+ S9xTraceFormattedMessage("--- /IRQ High->Low prev HC:%04d curr HC:%04d HTimer:%d Pos:%04d VTimer:%d Pos:%03d",
|
|
| 305 |
+ CPU.PrevCycles, CPU.Cycles, PPU.HTimerEnabled, PPU.HTimerPosition, PPU.VTimerEnabled, PPU.VTimerPosition); |
|
| 306 |
+#endif |
|
| 307 |
+ CPU.IRQLine = true; |
|
| 308 |
+ } |
|
| 309 |
+ |
|
| 310 |
+ CPU.IRQLastState = thisIRQ; |
|
| 311 |
+} |
|
| 312 |
+ |
|
| 313 |
+#endif |