mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
badc2fdb74
A test data set was published at https://github.com/TomHarte/ProcessorTests which contain cycle traces of instructions for various versions of the 6502. This adds a test harness that reads those data files, and adjusts the CPU6502 behavior to match the behavior of the vanilla and WDC 65C02 test data. Also converts the existing CPU tests to Typescript, and fixes any inconsistencies that came up from the new behaviors.
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import CPU6502 from '../js/cpu6502';
|
|
// From https://github.com/Klaus2m5/6502_65C02_functional_tests
|
|
import Test6502 from './roms/6502test';
|
|
import Test65C02 from './roms/65C02test';
|
|
|
|
import { toHex } from '../js/util';
|
|
|
|
describe('CPU', function () {
|
|
let cpu: CPU6502;
|
|
let lastPC = 0;
|
|
let done = false;
|
|
|
|
function traceCB() {
|
|
const pc = cpu.getPC();
|
|
done = lastPC == pc;
|
|
lastPC = pc;
|
|
}
|
|
|
|
describe('6502', function () {
|
|
it('completes the test ROM', function () {
|
|
cpu = new CPU6502();
|
|
const test = new Test6502();
|
|
cpu.addPageHandler(test);
|
|
cpu.setPC(0x400);
|
|
|
|
do {
|
|
cpu.stepCyclesDebug(1000, traceCB);
|
|
} while (!done);
|
|
|
|
expect(toHex(lastPC)).toEqual(toHex(0x3469));
|
|
});
|
|
});
|
|
|
|
describe('65C02', function () {
|
|
it('completes the test ROM', function () {
|
|
cpu = new CPU6502({'65C02': true});
|
|
const test = new Test65C02();
|
|
cpu.addPageHandler(test);
|
|
cpu.setPC(0x400);
|
|
|
|
do {
|
|
cpu.stepCyclesDebug(1000, traceCB);
|
|
} while (!done);
|
|
|
|
expect(toHex(lastPC)).toEqual(toHex(0x24f1));
|
|
});
|
|
});
|
|
});
|