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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 15x 1x 15x 809x 269x 807x 267x 250x | import { Cmos } from "./cmos.js";
import { FakeDdNoise } from "./ddnoise.js";
import { FakeMusic5000 } from "./music5000.js";
import { FakeRelayNoise } from "./relaynoise.js";
import { FakeSoundChip } from "./soundchip.js";
import { FakeVideo } from "./video.js";
const NullUserPort = {
write() {},
read() {
return 0xff;
},
};
const SpecDefaults = {
keyLayout: "physical",
cpuMultiplier: 1,
tubeCpuMultiplier: 1,
videoCyclesBatch: 0,
tube: null,
hasMusic5000: false,
hasTeletextAdaptor: false,
extraRoms: [],
userPort: NullUserPort,
printerPort: null,
getGamepads: () => [],
debugFlags: { logFdcCommands: false, logFdcStateChanges: false },
};
/**
* What a machine is fitted with and how it is driven, complete and frozen:
* every field is present, an unknown one is an error, and an undefined
* override means the default. It is the `config` a CPU is built with.
*/
export function machineSpec(overrides = {}) {
const unknown = Object.keys(overrides).filter((field) => !Object.hasOwn(SpecDefaults, field));
if (unknown.length) throw new Error(`Unknown machine spec fields: ${unknown.join(", ")}`);
const given = Object.fromEntries(Object.entries(overrides).filter(([, value]) => value !== undefined));
return Object.freeze({
...SpecDefaults,
...given,
extraRoms: Object.freeze([...(given.extraRoms ?? SpecDefaults.extraRoms)]),
debugFlags: Object.freeze({ ...SpecDefaults.debugFlags, ...given.debugFlags }),
});
}
/** Peripherals that go nowhere, for a machine run headless. */
export function nullIo({ video = new FakeVideo(), soundChip = new FakeSoundChip() } = {}) {
return {
dbgr: { setCpu() {} },
video,
soundChip,
ddNoise: new FakeDdNoise(),
relayNoise: new FakeRelayNoise(),
music5000: new FakeMusic5000(),
cmos: new Cmos(),
econet: null,
};
}
|