2021-12-22 18:37:05 +00:00
|
|
|
import CPU6502, { FLAVOR_ROCKWELL_65C02 } from '../js/cpu6502';
|
2021-10-13 16:15:29 +00:00
|
|
|
// From https://github.com/Klaus2m5/6502_65C02_functional_tests
|
2019-10-17 03:18:53 +00:00
|
|
|
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';
|
|
|
|
|
2019-12-03 02:53:47 +00:00
|
|
|
describe('CPU', function () {
|
2020-11-07 16:54:49 +00:00
|
|
|
let cpu: CPU6502;
|
|
|
|
let lastPC = 0;
|
|
|
|
let done = false;
|
2019-03-27 04:02:27 +00:00
|
|
|
|
2019-09-19 01:46:26 +00:00
|
|
|
function traceCB() {
|
2020-11-07 23:49:05 +00:00
|
|
|
const pc = cpu.getPC();
|
2022-05-18 15:19:45 +00:00
|
|
|
done = lastPC === pc;
|
2019-09-19 01:46:26 +00:00
|
|
|
lastPC = pc;
|
|
|
|
}
|
2019-03-27 04:02:27 +00:00
|
|
|
|
|
|
|
describe('6502', function () {
|
|
|
|
it('completes the test ROM', function () {
|
|
|
|
cpu = new CPU6502();
|
2020-11-07 23:49:05 +00:00
|
|
|
const test = new Test6502();
|
2019-03-27 04:02:27 +00:00
|
|
|
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 () {
|
2021-12-22 18:37:05 +00:00
|
|
|
cpu = new CPU6502({ flavor: FLAVOR_ROCKWELL_65C02 });
|
2020-11-07 23:49:05 +00:00
|
|
|
const test = new Test65C02();
|
2019-03-27 04:02:27 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|