diff --git a/cpuexec.cpp b/cpuexec.cpp index 1b9d892b..1537aeaf 100644 --- a/cpuexec.cpp +++ b/cpuexec.cpp @@ -400,7 +400,7 @@ void S9xDoHEventProcessing (void) if (PPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight) { #ifdef DEBUGGER - S9xTraceFormattedMessage("*** HDMA HC:%04d, Channel:%02x", CPU.Cycles, PPU.HDMA); + S9xTraceFormattedMessage("*** HDMA Transfer HC:%04d, Channel:%02x", CPU.Cycles, PPU.HDMA); #endif PPU.HDMA = S9xDoHDMA(PPU.HDMA); } @@ -544,7 +544,7 @@ void S9xDoHEventProcessing (void) if (CPU.V_Counter == 0) { #ifdef DEBUGGER - S9xTraceFormattedMessage("*** HDMA Init HC:%04d, Channel:%02x", CPU.Cycles, PPU.HDMA); + S9xTraceFormattedMessage("*** HDMA Init HC:%04d, Channel:%02x", CPU.Cycles, PPU.HDMA); #endif S9xStartHDMA(); } diff --git a/cpuops.cpp b/cpuops.cpp index ea8d8653..5cabf9e2 100644 --- a/cpuops.cpp +++ b/cpuops.cpp @@ -2857,7 +2857,11 @@ void S9xOpcode_IRQ (void) { #ifdef DEBUGGER if (CPU.Flags & TRACE_FLAG) + #ifdef SA1_OPCODES + S9xTraceMessage("*** SA1 IRQ"); + #else S9xTraceMessage("*** IRQ"); + #endif #endif // IRQ and NMI do an opcode fetch as their first "IO" cycle. @@ -2928,7 +2932,11 @@ void S9xOpcode_NMI (void) { #ifdef DEBUGGER if (CPU.Flags & TRACE_FLAG) + #ifdef SA1_OPCODES + S9xTraceMessage("*** SA1 NMI"); + #else S9xTraceMessage("*** NMI"); + #endif #endif // IRQ and NMI do an opcode fetch as their first "IO" cycle. @@ -2949,7 +2957,7 @@ void S9xOpcode_NMI (void) AddCycles(2 * SLOW_ONE_CYCLE); S9xSA1SetPCBase(Memory.FillRAM[0x2205] | (Memory.FillRAM[0x2206] << 8)); #else - if (Settings.SA1 && (Memory.FillRAM[0x2209] & 0x20)) + if (Settings.SA1 && (Memory.FillRAM[0x2209] & 0x10)) { OpenBus = Memory.FillRAM[0x220d]; AddCycles(2 * SLOW_ONE_CYCLE); diff --git a/sa1.cpp b/sa1.cpp index f8d8892c..813051dc 100644 --- a/sa1.cpp +++ b/sa1.cpp @@ -361,7 +361,7 @@ uint8 S9xGetSA1 (uint32 address) } default: - printf("R: %04x\n", address); + //printf("R: %04x\n", address); break; } @@ -393,12 +393,10 @@ void S9xSetSA1 (uint8 byte, uint32 address) if (byte & 0x10) { Memory.FillRAM[0x2301] |= 0x10; - #ifdef DEBUGGER - printf("###SA1 NMI\n"); - #endif if (Memory.FillRAM[0x220a] & 0x10) { - // + SA1.Flags |= NMI_FLAG; + SA1.Executing = !SA1.Waiting && SA1.S9xOpcodes; } } @@ -487,9 +485,8 @@ void S9xSetSA1 (uint8 byte, uint32 address) if (((byte ^ Memory.FillRAM[0x220a]) & 0x10) && (Memory.FillRAM[0x2301] & byte & 0x10)) { - #ifdef DEBUGGER - printf("###SA1 NMI\n"); - #endif + SA1.Flags |= NMI_FLAG; + //SA1.Executing = !SA1.Waiting; } break; @@ -513,7 +510,7 @@ void S9xSetSA1 (uint8 byte, uint32 address) Memory.FillRAM[0x2301] &= ~0x20; } - if (byte & 0x10) // Clear NMI + if (byte & 0x10) Memory.FillRAM[0x2301] &= ~0x10; if (!SA1.IRQActive) diff --git a/sa1cpu.cpp b/sa1cpu.cpp index dd79509e..b90092fb 100644 --- a/sa1cpu.cpp +++ b/sa1cpu.cpp @@ -229,19 +229,22 @@ void S9xSA1MainLoop (void) { -#if 0 if (SA1.Flags & NMI_FLAG) { - SA1.Flags &= ~NMI_FLAG; - if (SA1.WaitingForInterrupt) + if (Memory.FillRAM[0x2200] & 0x10) { - SA1.WaitingForInterrupt = FALSE; - SA1Registers.PCw++; - } + SA1.Flags &= ~NMI_FLAG; + Memory.FillRAM[0x2301] |= 0x10; - S9xSA1Opcode_NMI(); + if (SA1.WaitingForInterrupt) + { + SA1.WaitingForInterrupt = FALSE; + SA1Registers.PCw++; + } + + S9xSA1Opcode_NMI(); + } } -#endif if (SA1.Flags & IRQ_FLAG) {