68000: interrupt support.

gen: fire vertical interrupt, now some games show sega logo before immediately crashing!
This commit is contained in:
beirich 2011-10-08 15:44:41 +00:00
parent 18a3f3f87a
commit ccea71e74d
2 changed files with 19 additions and 4 deletions

View File

@ -15,7 +15,6 @@ namespace BizHawk.Emulation.CPUs.M68K
// Status Registers
int InterruptMaskLevel;
bool s, m;
int usp, ssp;
@ -83,6 +82,8 @@ namespace BizHawk.Emulation.CPUs.M68K
}
}
public int Interrupt { get; set; }
// Memory Access
public Func<int, sbyte> ReadByte;
public Func<int, short> ReadWord;
@ -124,6 +125,19 @@ namespace BizHawk.Emulation.CPUs.M68K
PendingCycles += cycles;
while (PendingCycles > 0)
{
if (Interrupt > 0 && (Interrupt > InterruptMaskLevel || Interrupt > 7))
{
Log.Error("CPU","****** ENTER INTERRUPT {0} *******", Interrupt);
int sr = SR; // capture current SR.
S = true; // switch to supervisor mode, if not already in it.
A[7].s32 -= 4; // Push PC on stack
WriteLong(A[7].s32, PC);
A[7].s32 -= 2; // Push SR on stack
WriteLong(A[7].s32, sr);
PC = ReadLong((24 + Interrupt) * 4); // Jump to interrupt vector
Interrupt = 0; // "ack" interrupt. Note: this is wrong.
}
int prevCycles = PendingCycles;
Log.Note("CPU", State());
op = (ushort)ReadWord(PC);
@ -137,9 +151,10 @@ namespace BizHawk.Emulation.CPUs.M68K
public string State()
{
string a = Disassemble(PC).ToString().PadRight(64);
//string a = string.Format("{0:X6}: {1:X4}", PC, ReadWord(PC)).PadRight(64);
string b = string.Format("D0:{0:X8} D1:{1:X8} D2:{2:X8} D3:{3:X8} D4:{4:X8} D5:{5:X8} D6:{6:X8} D7:{7:X8} ", D[0].u32, D[1].u32, D[2].u32, D[3].u32, D[4].u32, D[5].u32, D[6].u32, D[7].u32);
string c = string.Format("A0:{0:X8} A1:{1:X8} A2:{2:X8} A3:{3:X8} A4:{4:X8} A5:{5:X8} A6:{6:X8} A7:{7:X8} ", A[0].u32, A[1].u32, A[2].u32, A[3].u32, A[4].u32, A[5].u32, A[6].u32, A[7].u32);
string d = string.Format("SR:{0:X4} Pending {1} Cycles {2}", SR, PendingCycles, TotalExecutedCycles);
string d = string.Format("SR:{0:X4} Pending {1}", SR, PendingCycles);
return a + b + c + d;
}
}

View File

@ -107,8 +107,8 @@ namespace BizHawk.Emulation.Consoles.Sega
{
MainCPU.ExecuteCycles(16);// stupid crap to sync with genesis plus for log testing
// End-frame stuff
/*if (VDP.VInterruptEnabled)
MainCPU.Interrupt(6);*/
if (VDP.VInterruptEnabled)
MainCPU.Interrupt = 6;
if (Z80Runnable)
SoundCPU.Interrupt = true;