z80: Resond to interrupts at the corect time

This commit is contained in:
alyosha-tas 2018-06-08 12:28:51 -04:00
parent a1d24400d0
commit 3ce546b774
3 changed files with 15 additions and 9 deletions

View File

@ -85,7 +85,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
OP_F,
OP };
BUSRQ = new ushort[] { 0, 0, 0, SPh, 0, 0, SPh, 0, 0, PCh, 0, 0, 0 };
BUSRQ = new ushort[] { I, 0, 0, SPh, 0, 0, SPh, 0, 0, PCh, 0, 0, 0 };
}
// Interrupt mode 2 uses the I vector combined with a byte on the data bus
@ -112,7 +112,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
OP_F,
OP };
BUSRQ = new ushort[] { 0, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0 ,0 ,PCh, 0, 0, 0 };
BUSRQ = new ushort[] { I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0 ,0 ,PCh, 0, 0, 0 };
}
private static ushort[] INT_vectors = new ushort[] {0x40, 0x48, 0x50, 0x58, 0x60};

View File

@ -58,7 +58,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
public const ushort WIO4 = 108;
public bool FlagI;/*, FlagI1, FlagI2, FlagI3, FlagI4, FlagI5, FlagI6;*/
public bool FlagI, FlagI1, FlagI2, FlagI3, FlagI4, FlagI5, FlagI6;
public bool FlagW; // wait flag, when set to true reads / writes will be delayed

View File

@ -159,13 +159,13 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
// Execute instructions
public void ExecuteOne()
{
/*FlagI6 = FlagI;
//FlagI6 = FlagI5;
FlagI5 = FlagI4;
FlagI4 = FlagI3;
FlagI3 = FlagI2;
FlagI2 = FlagI1;
FlagI1 = FlagI;
*/
bus_pntr++;
switch (cur_instr[instr_pntr++])
{
@ -196,7 +196,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
NMICallback();
instr_pntr = 0; bus_pntr = 0;
}
else if (iff1 && FlagI)
else if (iff1 && FlagI5)
{
iff1 = iff2 = false;
EI_pending = 0;
@ -267,7 +267,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
NMICallback();
halted = false;
}
else if (iff1 && FlagI)
else if (iff1 && FlagI5)
{
iff1 = iff2 = false;
EI_pending = 0;
@ -670,12 +670,12 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
DEC16, PCl, PCh,
DEC16, PCl, PCh,
IDLE,
DEC16, B, ALU,
IDLE,//DEC16, B, ALU,
WAIT,
OP_F,
OP};
Regs[B] = (ushort)((Regs[B] + 1) & 0xFF);
//Regs[B] = (ushort)((Regs[B] + 1) & 0xFF);
BUSRQ = new ushort[] { B, B, B, B, B, PCh, 0, 0, 0 };
@ -770,6 +770,12 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
ser.Sync("instr_swap", ref instr_swap);
ser.Sync("opcode", ref opcode);
ser.Sync("FlagI", ref FlagI);
ser.Sync("FlagI1", ref FlagI1);
ser.Sync("FlagI2", ref FlagI2);
ser.Sync("FlagI3", ref FlagI3);
ser.Sync("FlagI4", ref FlagI4);
ser.Sync("FlagI5", ref FlagI5);
ser.Sync("FlagI6", ref FlagI6);
ser.Sync("FlagW", ref FlagW);
ser.Sync("NO Preifx", ref NO_prefix);