All files / src fake6502.js

83.33% Statements 5/6
100% Branches 11/11
66.66% Functions 2/3
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35              11x 11x     157x 157x                                       2x    
// Fakes out various 6502s for testing purposes.
 
import { FakeAtomVideo, FakeVideo } from "./video.js";
import { FakeSoundChip } from "./soundchip.js";
import { TEST_6502, TEST_65C02, TEST_65C12, tubeModelFor } from "./models.js";
import { machineSpec, nullIo } from "./machine-spec.js";
 
const fakeVideo = new FakeVideo();
const soundChip = new FakeSoundChip();
 
export function fake6502(model, opts = {}) {
    model = model || TEST_6502;
    return new model.Cpu(model, {
        ...nullIo({
            video: opts.video ?? (model.isAtom ? new FakeAtomVideo() : fakeVideo),
            soundChip: opts.soundChip ?? soundChip,
        }),
        config: machineSpec({
            tube: opts.tube ? tubeModelFor(model) : null,
            tubeCpuMultiplier: opts.tubeCpuMultiplier,
            cpuMultiplier: opts.cpuMultiplier,
            hasTeletextAdaptor: opts.hasTeletextAdaptor,
        }),
        cycleAccurate: opts.cycleAccurate,
    });
}
 
export function fake65C02() {
    return fake6502(TEST_65C02);
}
 
export function fake65C12() {
    return fake6502(TEST_65C12);
}