#include "snes9x.h"
#include "memmap.h"
-//#include "cpuops.h"
#include "ppu.h"
#include "cpuexec.h"
#include "debug.h"
#include "apu.h"
#include "dma.h"
#include "fxemu.h"
+
+#if !CONF_BUILD_ASM_CPU
+#include "cpuops.h"
+#endif
+
#ifdef USE_SA1
#include "sa1.h"
#endif
+#if CONF_BUILD_ASM_CPU
#include "os9x_asm_cpu.h"
-
-
// for asm core:
uint16 mem_check=0;
-
+#endif
#if defined(__showframe__)
int framecpt=0;
#endif
-
void S9xMainLoop (void)
{
#if defined(__showframe__)
S9xMessage(0,0,stra);
#endif
-// asm_S9xMainLoop();
+#if CONF_BUILD_ASM_CPU
asmMainLoop(&CPU);
+#else
+ for (;;) {\r
+ APU_EXECUTE(1);\r
+ if (CPU.Flags) {\r
+ if (CPU.Flags & NMI_FLAG) {\r
+ if (--CPU.NMICycleCount == 0) {\r
+ CPU.Flags &= ~NMI_FLAG;\r
+ if (CPU.WaitingForInterrupt) {\r
+ CPU.WaitingForInterrupt = FALSE;\r
+ CPU.PC++;\r
+ }\r
+ S9xOpcode_NMI ();\r
+ }\r
+ }\r
+\r
+ if (CPU.Flags & IRQ_PENDING_FLAG) {\r
+ if (CPU.IRQCycleCount == 0) {\r
+ if (CPU.WaitingForInterrupt) {\r
+ CPU.WaitingForInterrupt = FALSE;\r
+ CPU.PC++;\r
+ }\r
+ if (CPU.IRQActive && !Settings.DisableIRQ) {\r
+ if (!CheckFlag(IRQ))
+ S9xOpcode_IRQ ();\r
+ } else {\r
+ CPU.Flags &= ~IRQ_PENDING_FLAG;
+ }\r
+ } else {\r
+ CPU.IRQCycleCount--;
+ }\r
+ }
+\r
+ if (CPU.Flags & SCAN_KEYS_FLAG)\r
+ break;\r
+ }\r
+\r
+#ifdef CPU_SHUTDOWN\r
+ CPU.PCAtOpcodeStart = CPU.PC;\r
+#endif\r
+ CPU.Cycles += CPU.MemSpeed;\r
+\r
+ (*ICPU.S9xOpcodes[*CPU.PC++].S9xOpcode) ();\r
+
+#ifdef USE_SA1\r
+ if (SA1.Executing)\r
+ S9xSA1MainLoop ();
+#endif
+\r
+ DO_HBLANK_CHECK ();
+ }
+#endif
Registers.PC = CPU.PC - CPU.PCBase;
//S9xPackStatus (); // not needed