apple2js/test/cpu.spec.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-03-27 04:02:27 +00:00
import CPU6502 from '../js/cpu6502';
import Test6502 from './roms/6502test';
import Test65C02 from './roms/65C02test';
2019-03-27 04:02:27 +00:00
2019-10-08 05:18:15 +00:00
import { toHex } from '../js/util';
describe('CPU', function () {
var cpu;
var lastPC = 0;
var done = false;
2019-03-27 04:02:27 +00:00
function traceCB() {
var pc = cpu.getPC();
done = lastPC == pc;
lastPC = pc;
}
2019-03-27 04:02:27 +00:00
describe('6502', function () {
it('completes the test ROM', function () {
cpu = new CPU6502();
var test = new Test6502();
cpu.addPageHandler(test);
cpu.setPC(0x400);
do {
cpu.stepCyclesDebug(1000, traceCB);
} while (!done);
2019-10-08 05:18:15 +00:00
expect(toHex(lastPC)).toEqual(toHex(0x3469));
2019-03-27 04:02:27 +00:00
});
});
describe('65C02', function () {
it('completes the test ROM', function () {
cpu = new CPU6502({'65C02': true});
var test = new Test65C02();
cpu.addPageHandler(test);
cpu.setPC(0x400);
do {
cpu.stepCyclesDebug(1000, traceCB);
} while (!done);
2019-10-08 05:18:15 +00:00
expect(toHex(lastPC)).toEqual(toHex(0x24f1));
2019-03-27 04:02:27 +00:00
});
});
});