public void ROL_AbsoluteX_ApplyCarry() { var mapper = new NROM(new byte[] { 0x3E, 0x02, 0xC0, 0xFF }, null); var cpu = new Core(mapper) { X = 1 }; cpu.Status.Carry = true; cpu.Tick(); //Verify Registers //Not modified //Verify Cycles Assert.AreEqual(7u, cpu.Cycles); //Verify Flags Assert.AreEqual(true, cpu.Status.Carry); Assert.AreEqual(true, cpu.Status.Negative); //Verify Memory Values Assert.AreEqual(0xFF, cpu.CPUMemory.ReadByte(0xC003)); //Verify Stack //Not modified }
public void CMP_IndirectIndexed_PageBoundary_Carry_Zero() { var mapper = new NROM(new byte[] { 0xD1, 0x00 }, null); var cpu = new Core(mapper) { A = 0x7E, Y = 1 }; cpu.CPUMemory.WriteByte(0x00, 0xFF); cpu.CPUMemory.WriteByte(0x01, 0x00); cpu.CPUMemory.WriteByte(0x100, 0x7E); cpu.Tick(); //Verify Register Values Assert.AreEqual(0x7E, cpu.A); //Verify Cycles Assert.AreEqual(6u, cpu.Cycles); //Verify Flags Assert.AreEqual(true, cpu.Status.Zero); Assert.AreEqual(true, cpu.Status.Carry); Assert.AreEqual(false, cpu.Status.Negative); }
public void PHP_Implied() { var mapper = new NROM(new byte[] { 0x08 }, null); var cpu = new Core(mapper); //Set all statuses to true cpu.Status.Zero = true; cpu.Status.Carry = true; cpu.Status.DecimalMode = true; cpu.Status.InterruptDisable = true; cpu.Status.Negative = true; cpu.Status.Overflow = true; cpu.Tick(); //Verify Registers //Not Modified //Verify Cycles Assert.AreEqual(3u, cpu.Cycles); //Verify Flags //Not Modified //Verify Stack Assert.AreEqual(0xFF, cpu.CPUMemory.ReadByte(Core.STACK_BASE + cpu.SP + 1)); }
public void ROL_Accumulator_SetCarry() { var mapper = new NROM(new byte[] { 0x2A }, null); var cpu = new Core(mapper) { A = 0xFF }; cpu.Status.Carry = false; cpu.Tick(); //Verify Registers Assert.AreEqual(0xFE, cpu.A); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); //Verify Flags Assert.AreEqual(true, cpu.Status.Carry); Assert.AreEqual(true, cpu.Status.Negative); //Verify Stack //Not modified }
public void LSR_ZeroPageX_Clear() { var mapper = new NROM(new byte[] { 0x56, 0x00 }, null); var cpu = new Core(mapper) { X = 1 }; cpu.CPUMemory.WriteByte(0x01, 0x80); cpu.Tick(); //Verify Memory Values Assert.AreNotEqual(0x80, cpu.CPUMemory.ReadByte(0x01)); Assert.AreEqual(0x40, cpu.CPUMemory.ReadByte(0x01)); //Verify Cycles Assert.AreEqual(6u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Zero); Assert.AreEqual(false, cpu.Status.Negative); Assert.AreEqual(false, cpu.Status.Carry); }
public void ORA_IndirectIndexed_Negative() { var mapper = new NROM(new byte[] { 0x11, 0x00 }, null); var cpu = new Core(mapper) { A = 0xAA, Y = 1 }; cpu.CPUMemory.WriteByte(0x00, 0x01); cpu.CPUMemory.WriteByte(0x01, 0x00); cpu.CPUMemory.WriteByte(0x02, 0x55); cpu.Tick(); //Verify Register Values Assert.AreNotEqual(0xAA, cpu.A); Assert.AreEqual(0xFF, cpu.A); //Verify Cycles Assert.AreEqual(5u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Zero); Assert.AreEqual(true, cpu.Status.Negative); }
public void BCC_CarryClear_PageBoundary() { var mapper = new NROM(new byte[] { 0x00 }, null); var cpu = new Core(mapper); cpu.CPUMemory.WriteByte(0xF0, 0x90); cpu.CPUMemory.WriteByte(0xF1, 0x79); cpu.CPUMemory.WriteByte(0xF2, 0x00); cpu.Status.Carry = false; cpu.PC = 0xF0; cpu.Tick(); //Verify Memory Values Assert.AreNotEqual(0x00, cpu.PC); Assert.AreEqual(0x16B, cpu.PC); //0xF0 + 0x79 + 2 bytes for instruction //Verify Cycles Assert.AreEqual(4u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Zero); Assert.AreEqual(false, cpu.Status.Carry); Assert.AreEqual(false, cpu.Status.Negative); }
public void PLA_Implied() { //Test Program // PHA -- Pushes value of 1 to stack // LDA 0x00 -- Loads 0x00 into the accumulator // PLA -- Pops the value of 1 from stack to accumulator var mapper = new NROM(new byte[] { 0x48, 0xA9, 0x00, 0x68 }, null); var cpu = new Core(mapper) { A = 0x01 }; var test = new byte[] { }; cpu.Tick(3); //Verify Registers //Not Modified //Verify Cycles Assert.AreEqual(9u, cpu.Cycles); //Verify Flags //Not Modified //Verify Stack Assert.AreEqual(0x01, cpu.A); }
public void ROR_Accumulator_Negative_ApplyCarry() { var mapper = new NROM(new byte[] { 0x6A }, null); var cpu = new Core(mapper) { A = 0x00 }; cpu.Status.Carry = true; cpu.Tick(); //Verify Registers Assert.AreEqual(0x80, cpu.A); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Carry); Assert.AreEqual(true, cpu.Status.Negative); Assert.AreEqual(false, cpu.Status.Zero); //Verify Stack //Not modified }
public void ROR_ZeroPageX_SetCarry() { var mapper = new NROM(new byte[] { 0x76, 0x00 }, null); var cpu = new Core(mapper) { X = 1 }; cpu.CPUMemory.WriteByte(0x01, 0x03); cpu.Tick(); //Verify Registers //Not modified //Verify Cycles Assert.AreEqual(6u, cpu.Cycles); //Verify Flags Assert.AreEqual(true, cpu.Status.Carry); Assert.AreEqual(false, cpu.Status.Negative); Assert.AreEqual(false, cpu.Status.Zero); //Verify Memory Values Assert.AreEqual(0x01, cpu.CPUMemory.ReadByte(0x01)); //Verify Stack //Not modified }
public void ROR_Absolute_SetNegative_ApplyCarry() { var mapper = new NROM(new byte[] { 0x6E, 0x03, 0xC0, 0x00 }, null); var cpu = new Core(mapper); cpu.Status.Carry = true; cpu.Tick(); //Verify Registers //Not modified //Verify Cycles Assert.AreEqual(6u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Carry); Assert.AreEqual(true, cpu.Status.Negative); Assert.AreEqual(false, cpu.Status.Zero); //Verify Memory Values Assert.AreEqual(0x80, cpu.CPUMemory.ReadByte(0xC003)); //Verify Stack //Not modified }
public void ROR_AbsoluteX_Clear() { var mapper = new NROM(new byte[] { 0x7E, 0x02, 0xC0, 0x02 }, null); var cpu = new Core(mapper) { X = 1 }; cpu.Tick(); //Verify Registers //Not modified //Verify Cycles Assert.AreEqual(7u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Carry); Assert.AreEqual(false, cpu.Status.Negative); Assert.AreEqual(false, cpu.Status.Zero); //Verify Memory Values Assert.AreEqual(0x01, cpu.CPUMemory.ReadByte(0xC003)); //Verify Stack //Not modified }
public void LDA_IndirectIndexed_BigY_PageBoundary_Clear() { var mapper = new NROM(new byte[] { 0xB1, 0x00 }, null); var cpu = new Core(mapper) { Y = 3 }; cpu.CPUMemory.WriteByte(0x00, 0xFE); cpu.CPUMemory.WriteByte(0x01, 0x00); cpu.CPUMemory.WriteByte(0x101, 0x01); cpu.Tick(); //Verify Memory Values Assert.AreNotEqual(0x00, cpu.A); Assert.AreEqual(0x01, cpu.A); //Verify Cycles Assert.AreEqual(6u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Zero); Assert.AreEqual(false, cpu.Status.Negative); }
public void EOR_IndexedIndirect_Zero() { var mapper = new NROM(new byte[] { 0x41, 0x00 }, null); var cpu = new Core(mapper) { A = 0xFF, X = 1 }; cpu.CPUMemory.WriteByte(0x00, 0x00); cpu.CPUMemory.WriteByte(0x01, 0x03); cpu.CPUMemory.WriteByte(0x02, 0x00); cpu.CPUMemory.WriteByte(0x03, 0xFF); cpu.Tick(); //Verify Register Values Assert.AreNotEqual(0xFF, cpu.A); Assert.AreEqual(0x00, cpu.A); //Verify Cycles Assert.AreEqual(6u, cpu.Cycles); //Verify Flags Assert.AreEqual(true, cpu.Status.Zero); Assert.AreEqual(false, cpu.Status.Negative); }
public void ROL_ZeroPage_ApplyCarry() { var mapper = new NROM(new byte[] { 0x26, 0x00 }, null); var cpu = new Core(mapper); cpu.CPUMemory.WriteByte(0x00, 0xFF); cpu.Status.Carry = true; cpu.Tick(); //Verify Registers //Not modified //Verify Cycles Assert.AreEqual(5u, cpu.Cycles); //Verify Flags Assert.AreEqual(true, cpu.Status.Carry); Assert.AreEqual(true, cpu.Status.Negative); //Verify Memory Values Assert.AreEqual(0xFF, cpu.CPUMemory.ReadByte(0x00)); //Verify Stack //Not modified }
public void NOP_Implied() { var mapper = new NROM(new byte[] { 0xEA }, null); var cpu = new Core(mapper); cpu.Tick(); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); }
public void JMP_Indirect_PageBoundaryBug() { var mapper = new NROM(new byte[] { 0x6C, 0xFF, 0xC0 }, null); var cpu = new Core(mapper); cpu.Tick(); //Verify Register Values Assert.AreNotEqual(0x00, cpu.PC); Assert.AreEqual(0x6C00, cpu.PC); //Verify Cycles Assert.AreEqual(5u, cpu.Cycles); }
public void JMP_Absolute() { var mapper = new NROM(new byte[] { 0x4C, 0x0F, 0xC0 }, null); var cpu = new Core(mapper); cpu.Tick(); //Verify Register Values Assert.AreNotEqual(0xC000, cpu.PC); Assert.AreEqual(0xC00F, cpu.PC); //Verify Cycles Assert.AreEqual(3u, cpu.Cycles); }
public void CLV_Overflow() { var mapper = new NROM(new byte[] { 0xB8 }, null); var cpu = new Core(mapper); cpu.Status.Overflow = true; cpu.Tick(); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Overflow); }
public void CLC_Carry() { var mapper = new NROM(new byte[] { 0x18 }, null); var cpu = new Core(mapper); cpu.Status.Carry = true; cpu.Tick(); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Carry); }
public void CLI_Interrupt() { var mapper = new NROM(new byte[] { 0x58 }, null); var cpu = new Core(mapper); cpu.Status.InterruptDisable = true; cpu.Tick(); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.InterruptDisable); }
public void CLD_Decimal() { var mapper = new NROM(new byte[] { 0xD8 }, null); var cpu = new Core(mapper); cpu.Status.DecimalMode = true; cpu.Tick(); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.DecimalMode); }
public void BNE_ZeroClear() { var mapper = new NROM(new byte[] { 0xD0, 0x0A, 0x00 }, null); var cpu = new Core(mapper); cpu.Tick(); //Verify Memory Values Assert.AreNotEqual(0xC000, cpu.PC); Assert.AreEqual(0xC00C, cpu.PC); //Verify Cycles Assert.AreEqual(3u, cpu.Cycles); //Verify Flags //Not Modified }
public void LDX_Immediate_Negative() { var mapper = new NROM(new byte[] { 0xA2, 0x80 }, null); var cpu = new Core(mapper); cpu.Tick(); //Verify Memory Values Assert.AreNotEqual(0x00, cpu.X); Assert.AreEqual(0x80, cpu.X); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Zero); Assert.AreEqual(true, cpu.Status.Negative); }
public void LDX_Absolute_Clear() { var mapper = new NROM(new byte[] { 0xAE, 0x03, 0xC0, 0x01 }, null); var cpu = new Core(mapper); cpu.Tick(); //Verify Memory Values Assert.AreNotEqual(0x00, cpu.X); Assert.AreEqual(0x01, cpu.X); //Verify Cycles Assert.AreEqual(4u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Zero); Assert.AreEqual(false, cpu.Status.Negative); }
public void INC_Absolute_Zero() { var mapper = new NROM(new byte[] { 0xEE, 0x03, 0xC0, 0xFF }, null); var cpu = new Core(mapper); cpu.Tick(); //Verify Memory Values Assert.AreNotEqual(0xFF, cpu.CPUMemory.ReadByte(0xC003)); Assert.AreEqual(0x00, cpu.CPUMemory.ReadByte(0xC003)); //Verify Cycles Assert.AreEqual(6u, cpu.Cycles); //Verify Flags Assert.AreEqual(true, cpu.Status.Zero); Assert.AreEqual(false, cpu.Status.Negative); }
public void CPY_Absolute_Carry() { var mapper = new NROM(new byte[] { 0xCC, 0x03, 0xC0, 0x7E }, null); var cpu = new Core(mapper) { Y = 0x7F }; cpu.Tick(); //Verify Cycles Assert.AreEqual(4u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Negative); Assert.AreEqual(true, cpu.Status.Carry); Assert.AreEqual(false, cpu.Status.Zero); }
public void CPX_Immediate_Carry() { var mapper = new NROM(new byte[] { 0xE0, 0x7E }, null); var cpu = new Core(mapper) { X = 0x7F }; cpu.Tick(); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Negative); Assert.AreEqual(true, cpu.Status.Carry); Assert.AreEqual(false, cpu.Status.Zero); }
public void BVS_OverflowClear() { var mapper = new NROM(new byte[] { 0x70, 0x0A, 0x00 }, null); var cpu = new Core(mapper); cpu.Status.Overflow = false; cpu.Tick(); //Verify Memory Values Assert.AreNotEqual(0xC000, cpu.PC); Assert.AreEqual(0xC002, cpu.PC); //Verify Cycles Assert.AreEqual(2u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Overflow); }
public void LSR_Absolute_Clear() { var mapper = new NROM(new byte[] { 0x4E, 0x03, 0xC0, 0x80 }, null); var cpu = new Core(mapper); cpu.Tick(); //Verify Memory Values Assert.AreNotEqual(0x80, cpu.CPUMemory.ReadByte(0xC003)); Assert.AreEqual(0x40, cpu.CPUMemory.ReadByte(0xC003)); //Verify Cycles Assert.AreEqual(6u, cpu.Cycles); //Verify Flags Assert.AreEqual(false, cpu.Status.Zero); Assert.AreEqual(false, cpu.Status.Negative); Assert.AreEqual(false, cpu.Status.Carry); }