6502: All non-writes are affected by RDY.

This commit is contained in:
Anthony Konzel 2016-03-09 20:12:49 -06:00
parent bd7e10af6b
commit aa83c33c58
1 changed files with 85 additions and 65 deletions

View File

@ -534,7 +534,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502
void FetchDummy() void FetchDummy()
{ {
DummyReadMemory(PC); DummyReadMemory(PC);
} }
public void Execute(int cycles) public void Execute(int cycles)
@ -1152,45 +1152,59 @@ namespace BizHawk.Emulation.Cores.Components.M6502
} }
void RelBranch_Stage3() void RelBranch_Stage3()
{ {
FetchDummy(); rdy_freeze = !RDY;
alu_temp = (byte)PC + (int)(sbyte)opcode2; if (RDY)
PC &= 0xFF00; {
PC |= (ushort)((alu_temp & 0xFF)); FetchDummy();
if (alu_temp.Bit(8)) alu_temp = (byte)PC + (int)(sbyte)opcode2;
{ PC &= 0xFF00;
//we need to carry the add, and then we'll be ready to fetch the next instruction PC |= (ushort)((alu_temp & 0xFF));
opcode = VOP_RelativeStuff2; if (alu_temp.Bit(8))
mi = -1; {
} //we need to carry the add, and then we'll be ready to fetch the next instruction
else opcode = VOP_RelativeStuff2;
{ mi = -1;
//to pass cpu_interrupts_v2/5-branch_delays_irq we need to handle a quirk here }
//if we decide to interrupt in the next cycle, this condition will cause it to get deferred by one instruction else
if (!interrupt_pending) {
branch_irq_hack = true; //to pass cpu_interrupts_v2/5-branch_delays_irq we need to handle a quirk here
} //if we decide to interrupt in the next cycle, this condition will cause it to get deferred by one instruction
if (!interrupt_pending)
} branch_irq_hack = true;
}
}
}
void RelBranch_Stage4() void RelBranch_Stage4()
{ {
FetchDummy(); rdy_freeze = !RDY;
if (alu_temp.Bit(31)) if (RDY)
PC = (ushort)(PC - 0x100); {
else PC = (ushort)(PC + 0x100); FetchDummy();
if (alu_temp.Bit(31))
PC = (ushort)(PC - 0x100);
} else PC = (ushort)(PC + 0x100);
}
}
void NOP() void NOP()
{ {
} rdy_freeze = !RDY;
void DecS() }
void DecS()
{ {
S--; rdy_freeze = !RDY;
} if (RDY)
{
S--;
}
}
void IncS() void IncS()
{ {
S++; rdy_freeze = !RDY;
} if (RDY)
{
S++;
}
}
void JSR() void JSR()
{ {
rdy_freeze = !RDY; rdy_freeze = !RDY;
@ -2041,35 +2055,50 @@ namespace BizHawk.Emulation.Cores.Components.M6502
} }
void Imp_ASL_A() void Imp_ASL_A()
{ {
FetchDummy(); rdy_freeze = !RDY;
FlagC = (A & 0x80) != 0; if (RDY)
A = (byte)(A << 1); {
NZ_A(); FetchDummy();
} FlagC = (A & 0x80) != 0;
A = (byte)(A << 1);
NZ_A();
}
}
void Imp_ROL_A() void Imp_ROL_A()
{ {
FetchDummy(); rdy_freeze = !RDY;
temp8 = A; if (RDY)
A = (byte)((A << 1) | (P & 1)); {
FlagC = (temp8 & 0x80) != 0; FetchDummy();
NZ_A(); temp8 = A;
} A = (byte)((A << 1) | (P & 1));
FlagC = (temp8 & 0x80) != 0;
NZ_A();
}
}
void Imp_ROR_A() void Imp_ROR_A()
{ {
FetchDummy(); rdy_freeze = !RDY;
temp8 = A; if (RDY)
A = (byte)((A >> 1) | ((P & 1) << 7)); {
FlagC = (temp8 & 1) != 0; FetchDummy();
NZ_A(); temp8 = A;
} A = (byte)((A >> 1) | ((P & 1) << 7));
FlagC = (temp8 & 1) != 0;
NZ_A();
}
}
void Imp_LSR_A() void Imp_LSR_A()
{ {
FetchDummy(); rdy_freeze = !RDY;
FlagC = (A & 1) != 0; if (RDY)
A = (byte)(A >> 1); {
NZ_A(); FetchDummy();
FlagC = (A & 1) != 0;
} A = (byte)(A >> 1);
NZ_A();
}
}
void JMP_abs() void JMP_abs()
{ {
rdy_freeze = !RDY; rdy_freeze = !RDY;
@ -2082,8 +2111,6 @@ namespace BizHawk.Emulation.Cores.Components.M6502
void IncPC() void IncPC()
{ {
PC++; PC++;
} }
void ZP_RMW_Stage3() void ZP_RMW_Stage3()
{ {
@ -2097,21 +2124,18 @@ namespace BizHawk.Emulation.Cores.Components.M6502
void ZP_RMW_Stage5() void ZP_RMW_Stage5()
{ {
WriteMemory(opcode2, (byte)alu_temp); WriteMemory(opcode2, (byte)alu_temp);
} }
void ZP_RMW_INC() void ZP_RMW_INC()
{ {
WriteMemory(opcode2, (byte)alu_temp); WriteMemory(opcode2, (byte)alu_temp);
alu_temp = (byte)((alu_temp + 1) & 0xFF); alu_temp = (byte)((alu_temp + 1) & 0xFF);
P = (byte)((P & 0x7D) | TableNZ[alu_temp]); P = (byte)((P & 0x7D) | TableNZ[alu_temp]);
} }
void ZP_RMW_DEC() void ZP_RMW_DEC()
{ {
WriteMemory(opcode2, (byte)alu_temp); WriteMemory(opcode2, (byte)alu_temp);
alu_temp = (byte)((alu_temp - 1) & 0xFF); alu_temp = (byte)((alu_temp - 1) & 0xFF);
P = (byte)((P & 0x7D) | TableNZ[alu_temp]); P = (byte)((P & 0x7D) | TableNZ[alu_temp]);
} }
void ZP_RMW_ASL() void ZP_RMW_ASL()
{ {
@ -2120,7 +2144,6 @@ namespace BizHawk.Emulation.Cores.Components.M6502
FlagC = (value8 & 0x80) != 0; FlagC = (value8 & 0x80) != 0;
alu_temp = value8 = (byte)(value8 << 1); alu_temp = value8 = (byte)(value8 << 1);
P = (byte)((P & 0x7D) | TableNZ[value8]); P = (byte)((P & 0x7D) | TableNZ[value8]);
} }
void ZP_RMW_SRE() void ZP_RMW_SRE()
{ {
@ -2163,7 +2186,6 @@ namespace BizHawk.Emulation.Cores.Components.M6502
alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7)); alu_temp = value8 = (byte)((value8 >> 1) | ((P & 1) << 7));
FlagC = (temp8 & 1) != 0; FlagC = (temp8 & 1) != 0;
P = (byte)((P & 0x7D) | TableNZ[value8]); P = (byte)((P & 0x7D) | TableNZ[value8]);
} }
void ZP_RMW_ROL() void ZP_RMW_ROL()
{ {
@ -2172,7 +2194,6 @@ namespace BizHawk.Emulation.Cores.Components.M6502
alu_temp = value8 = (byte)((value8 << 1) | (P & 1)); alu_temp = value8 = (byte)((value8 << 1) | (P & 1));
FlagC = (temp8 & 0x80) != 0; FlagC = (temp8 & 0x80) != 0;
P = (byte)((P & 0x7D) | TableNZ[value8]); P = (byte)((P & 0x7D) | TableNZ[value8]);
} }
void ZP_RMW_SLO() void ZP_RMW_SLO()
{ {
@ -2198,7 +2219,6 @@ namespace BizHawk.Emulation.Cores.Components.M6502
FlagC = (temp8 & 0x80) != 0; FlagC = (temp8 & 0x80) != 0;
A &= value8; A &= value8;
NZ_A(); NZ_A();
} }
void AbsIdx_Stage3_Y() void AbsIdx_Stage3_Y()
{ {