Added SA-1 NMI and fixed its override mode.

This commit is contained in:
zones 2010-11-02 22:28:27 +09:00
parent 0b95675cc8
commit 73e1f68c22
4 changed files with 28 additions and 20 deletions

View File

@ -400,7 +400,7 @@ void S9xDoHEventProcessing (void)
if (PPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight) if (PPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight)
{ {
#ifdef DEBUGGER #ifdef DEBUGGER
S9xTraceFormattedMessage("*** HDMA HC:%04d, Channel:%02x", CPU.Cycles, PPU.HDMA); S9xTraceFormattedMessage("*** HDMA Transfer HC:%04d, Channel:%02x", CPU.Cycles, PPU.HDMA);
#endif #endif
PPU.HDMA = S9xDoHDMA(PPU.HDMA); PPU.HDMA = S9xDoHDMA(PPU.HDMA);
} }
@ -544,7 +544,7 @@ void S9xDoHEventProcessing (void)
if (CPU.V_Counter == 0) if (CPU.V_Counter == 0)
{ {
#ifdef DEBUGGER #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 #endif
S9xStartHDMA(); S9xStartHDMA();
} }

View File

@ -2857,7 +2857,11 @@ void S9xOpcode_IRQ (void)
{ {
#ifdef DEBUGGER #ifdef DEBUGGER
if (CPU.Flags & TRACE_FLAG) if (CPU.Flags & TRACE_FLAG)
#ifdef SA1_OPCODES
S9xTraceMessage("*** SA1 IRQ");
#else
S9xTraceMessage("*** IRQ"); S9xTraceMessage("*** IRQ");
#endif
#endif #endif
// IRQ and NMI do an opcode fetch as their first "IO" cycle. // IRQ and NMI do an opcode fetch as their first "IO" cycle.
@ -2928,7 +2932,11 @@ void S9xOpcode_NMI (void)
{ {
#ifdef DEBUGGER #ifdef DEBUGGER
if (CPU.Flags & TRACE_FLAG) if (CPU.Flags & TRACE_FLAG)
#ifdef SA1_OPCODES
S9xTraceMessage("*** SA1 NMI");
#else
S9xTraceMessage("*** NMI"); S9xTraceMessage("*** NMI");
#endif
#endif #endif
// IRQ and NMI do an opcode fetch as their first "IO" cycle. // 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); AddCycles(2 * SLOW_ONE_CYCLE);
S9xSA1SetPCBase(Memory.FillRAM[0x2205] | (Memory.FillRAM[0x2206] << 8)); S9xSA1SetPCBase(Memory.FillRAM[0x2205] | (Memory.FillRAM[0x2206] << 8));
#else #else
if (Settings.SA1 && (Memory.FillRAM[0x2209] & 0x20)) if (Settings.SA1 && (Memory.FillRAM[0x2209] & 0x10))
{ {
OpenBus = Memory.FillRAM[0x220d]; OpenBus = Memory.FillRAM[0x220d];
AddCycles(2 * SLOW_ONE_CYCLE); AddCycles(2 * SLOW_ONE_CYCLE);

15
sa1.cpp
View File

@ -361,7 +361,7 @@ uint8 S9xGetSA1 (uint32 address)
} }
default: default:
printf("R: %04x\n", address); //printf("R: %04x\n", address);
break; break;
} }
@ -393,12 +393,10 @@ void S9xSetSA1 (uint8 byte, uint32 address)
if (byte & 0x10) if (byte & 0x10)
{ {
Memory.FillRAM[0x2301] |= 0x10; Memory.FillRAM[0x2301] |= 0x10;
#ifdef DEBUGGER
printf("###SA1 NMI\n");
#endif
if (Memory.FillRAM[0x220a] & 0x10) 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)) if (((byte ^ Memory.FillRAM[0x220a]) & 0x10) && (Memory.FillRAM[0x2301] & byte & 0x10))
{ {
#ifdef DEBUGGER SA1.Flags |= NMI_FLAG;
printf("###SA1 NMI\n"); //SA1.Executing = !SA1.Waiting;
#endif
} }
break; break;
@ -513,7 +510,7 @@ void S9xSetSA1 (uint8 byte, uint32 address)
Memory.FillRAM[0x2301] &= ~0x20; Memory.FillRAM[0x2301] &= ~0x20;
} }
if (byte & 0x10) // Clear NMI if (byte & 0x10)
Memory.FillRAM[0x2301] &= ~0x10; Memory.FillRAM[0x2301] &= ~0x10;
if (!SA1.IRQActive) if (!SA1.IRQActive)

View File

@ -229,19 +229,22 @@
void S9xSA1MainLoop (void) void S9xSA1MainLoop (void)
{ {
#if 0
if (SA1.Flags & NMI_FLAG) if (SA1.Flags & NMI_FLAG)
{ {
SA1.Flags &= ~NMI_FLAG; if (Memory.FillRAM[0x2200] & 0x10)
if (SA1.WaitingForInterrupt)
{ {
SA1.WaitingForInterrupt = FALSE; SA1.Flags &= ~NMI_FLAG;
SA1Registers.PCw++; Memory.FillRAM[0x2301] |= 0x10;
}
S9xSA1Opcode_NMI(); if (SA1.WaitingForInterrupt)
{
SA1.WaitingForInterrupt = FALSE;
SA1Registers.PCw++;
}
S9xSA1Opcode_NMI();
}
} }
#endif
if (SA1.Flags & IRQ_FLAG) if (SA1.Flags & IRQ_FLAG)
{ {