|
|
|
|
|
|
|
|
cpu.memory.load(0xFFFC, [0x00, 0x00]); |
|
|
cpu.memory.load(0xFFFC, [0x00, 0x00]); |
|
|
|
|
|
|
|
|
it("Resetting (IRQ Disabled flag must be on", function(){ |
|
|
it("Resetting (IRQ Disabled flag must be on", function(){ |
|
|
cpu.reset(); |
|
|
|
|
|
|
|
|
cpu.reset = true; |
|
|
|
|
|
tick(); // One tick to handle resets. |
|
|
expect(cpu.I).to.equal(1); |
|
|
expect(cpu.I).to.equal(1); |
|
|
expect(cpu.PC).to.equal(0); // Test program counter set to the vector stored at 0xFFFC - 0xFFFD |
|
|
expect(cpu.PC).to.equal(0); // Test program counter set to the vector stored at 0xFFFC - 0xFFFD |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it("CLC / SEC", function(){ |
|
|
it("CLC / SEC", function(){ |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.load(0, [0x18, 0x38]); |
|
|
cpu.memory.load(0, [0x18, 0x38]); |
|
|
cpu.reset(); |
|
|
|
|
|
|
|
|
cpu.reset = true; |
|
|
|
|
|
tick(); // reset. |
|
|
tick(); tick(); // Two ticks to process opcode. |
|
|
tick(); tick(); // Two ticks to process opcode. |
|
|
expect(cpu.C).to.equal(0); |
|
|
expect(cpu.C).to.equal(0); |
|
|
tick(); tick(); |
|
|
tick(); tick(); |
|
|
|
|
|
|
|
|
it("CLI / SEI", function(){ |
|
|
it("CLI / SEI", function(){ |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.load(0, [0x58, 0x78]); |
|
|
cpu.memory.load(0, [0x58, 0x78]); |
|
|
cpu.reset(); |
|
|
|
|
|
|
|
|
cpu.reset = true; |
|
|
|
|
|
tick(); |
|
|
tick(); tick(); |
|
|
tick(); tick(); |
|
|
expect(cpu.I).to.equal(0); |
|
|
expect(cpu.I).to.equal(0); |
|
|
tick(); tick(); |
|
|
tick(); tick(); |
|
|
|
|
|
|
|
|
it("CLD / SED", function(){ |
|
|
it("CLD / SED", function(){ |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.load(0, [0xD8, 0xF8]); |
|
|
cpu.memory.load(0, [0xD8, 0xF8]); |
|
|
cpu.reset(); |
|
|
|
|
|
|
|
|
cpu.reset = true; |
|
|
|
|
|
tick(); |
|
|
tick(); tick(); |
|
|
tick(); tick(); |
|
|
expect(cpu.D).to.equal(0); |
|
|
expect(cpu.D).to.equal(0); |
|
|
tick(); tick(); |
|
|
tick(); tick(); |
|
|
|
|
|
|
|
|
it("CLV", function(){ |
|
|
it("CLV", function(){ |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.load(0, [0xB8]); |
|
|
cpu.memory.load(0, [0xB8]); |
|
|
cpu.reset(); |
|
|
|
|
|
|
|
|
cpu.reset = true; |
|
|
|
|
|
tick(); |
|
|
tick(); tick(); |
|
|
tick(); tick(); |
|
|
expect(cpu.V).to.equal(0); |
|
|
expect(cpu.V).to.equal(0); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it("LDA Immediate", function(){ |
|
|
it("LDA Immediate", function(){ |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.clearPage(0); |
|
|
cpu.memory.load(0, [0xA9, 0x01, 0xA9, 0xBB]); |
|
|
cpu.memory.load(0, [0xA9, 0x01, 0xA9, 0xBB]); |
|
|
cpu.reset(); |
|
|
|
|
|
|
|
|
cpu.reset = true; |
|
|
|
|
|
tick(); |
|
|
tick(); |
|
|
tick(); |
|
|
tick(); |
|
|
tick(); |
|
|
expect(cpu.A).to.equal(0x01); |
|
|
expect(cpu.A).to.equal(0x01); |
|
|
|
|
|
|
|
|
// ADC $01 |
|
|
// ADC $01 |
|
|
// ADC $01 |
|
|
// ADC $01 |
|
|
cpu.memory.load(0, [0x18, 0xB8, 0xD8, 0x58, 0xA9, 0x00, 0x69, 0x01, 0x69, 0x01]); |
|
|
cpu.memory.load(0, [0x18, 0xB8, 0xD8, 0x58, 0xA9, 0x00, 0x69, 0x01, 0x69, 0x01]); |
|
|
cpu.reset(); |
|
|
|
|
|
|
|
|
cpu.reset = true; |
|
|
|
|
|
tick(); |
|
|
// Getting through the 4 clear flag calls. Each should take 2 ticks. |
|
|
// Getting through the 4 clear flag calls. Each should take 2 ticks. |
|
|
tick(); tick(); tick(); tick(); tick(); tick(); tick(); tick(); |
|
|
tick(); tick(); tick(); tick(); tick(); tick(); tick(); tick(); |
|
|
// Next two ticks for the LDA call |
|
|
// Next two ticks for the LDA call |
|
|
|
|
|
|
|
|
// SBC $01 |
|
|
// SBC $01 |
|
|
// SBC $01 |
|
|
// SBC $01 |
|
|
cpu.memory.load(0, [0x38, 0xB8, 0xD8, 0x58, 0xA9, 0x00, 0xE9, 0x01, 0xE9, 0x01]); |
|
|
cpu.memory.load(0, [0x38, 0xB8, 0xD8, 0x58, 0xA9, 0x00, 0xE9, 0x01, 0xE9, 0x01]); |
|
|
cpu.reset(); |
|
|
|
|
|
|
|
|
cpu.reset = true; |
|
|
|
|
|
tick(); |
|
|
// Getting through the 1 set and 3 clear flag calls. Each should take 2 ticks. |
|
|
// Getting through the 1 set and 3 clear flag calls. Each should take 2 ticks. |
|
|
tick(); tick(); tick(); tick(); tick(); tick(); tick(); tick(); |
|
|
tick(); tick(); tick(); tick(); tick(); tick(); tick(); tick(); |
|
|
// Next two ticks for the LDA call |
|
|
// Next two ticks for the LDA call |