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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | 37x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 629x 1798516x 470380x 264x 236x 8x 20x 148x 37x 37x 37x 415x 415x 1814x 1814x 1737x 2243x 6x 37x 37x 37x 37x 37x 37x 37x 37x 37x 37x 43x 37x 629x 629x 629x 37x | import { NoiseAwareWdFdc } from "./wd-fdc.js";
import { NoiseAwareIntelFdc } from "./intel-fdc.js";
import * as opcodes from "./6502.opcodes.js";
import { AtomCpu6502, Cpu6502 } from "./6502.js";
import { BBC, stringToBBCKeys } from "./keymap.js";
import { ATOM, stringToATOMKeys } from "./keymap-atom.js";
const CpuModel = Object.freeze({
MOS6502: 0,
CMOS65C02: 1,
CMOS65C12: 2,
});
/**
* Describes what a machine *is*: which CPU, which ROMs, which disc controller.
* Anything a user can turn on and off for a session (second processor, Econet,
* Music 5000, teletext adaptor) belongs in the emulation config passed to Cpu6502.
*
* Instances are shared process-wide via `allModels` and frozen, so they can be handed
* to any number of machines without one session's settings leaking into the next.
*/
class Model {
constructor({
name,
shortName = name,
synonyms,
os,
cpuModel,
isMaster,
isAtom,
swram,
fdc,
cmosOverride,
banks,
clockMhz,
} = {}) {
Iif (!(clockMhz > 0)) throw new Error(`Model ${name} has no clock speed`);
this.name = name;
this.shortName = shortName;
this.synonyms = synonyms;
this.os = os;
this.clockMhz = clockMhz;
this.banks = banks;
this._cpuModel = cpuModel;
this.isMaster = isMaster;
this.isAtom = !!isAtom;
// The one place the two machine families part: everything else asks the model.
this.Cpu = this.isAtom ? AtomCpu6502 : Cpu6502;
this.keys = this.isAtom ? ATOM : BBC;
this.stringToKeys = this.isAtom ? stringToATOMKeys : stringToBBCKeys;
// The OS write-character vector, watched to capture what the machine prints.
this.wrchvAddress = this.isAtom ? 0x0208 : 0x020e;
// Where the machine sits waiting for a key: BASIC's read loop, or on the Atom the kernel's
// wait-for-key scan at $FEA7. The scan before it at $FE9F only checks every key is up, and a
// 100 ms debounce delay follows, during which a key pressed is not seen.
this.idleAddress = this.isAtom ? 0xfea7 : isMaster ? 0xe7e6 : 0xe581;
// The Atom ROM polls its keyboard once per VSync, so pasted keys need longer apart.
this.pasteKeyDelayMs = this.isAtom ? 80 : 50;
// Two of those 60 Hz scans, 33 ms, with margin: the ROM wants a key seen up
// twice before it takes the next.
this.pasteReleaseGapMs = this.isAtom ? 40 : 0;
this.Fdc = fdc;
this.swram = swram;
this.isTest = false;
this.cmosOverride = cmosOverride;
}
/**
* How many CPU cycles this machine runs in a second. Everything that
* converts between real time and emulated cycles should ask here rather
* than assuming a clock speed.
*/
get cyclesPerSecond() {
return this.clockMhz * 1000 * 1000;
}
get nmos() {
return this._cpuModel === CpuModel.MOS6502;
}
get opcodesFactory() {
switch (this._cpuModel) {
case CpuModel.MOS6502:
return opcodes.Cpu6502;
case CpuModel.CMOS65C02:
return opcodes.Cpu65c02;
case CpuModel.CMOS65C12:
return opcodes.Cpu65c12;
}
throw new Error("Unknown CPU model");
}
}
function pickAdfs(cmos) {
cmos[19] = (cmos[19] & 0xf0) | 13;
return cmos;
}
function pickAnfs(cmos) {
cmos[19] = (cmos[19] & 0xf0) | 8;
return cmos;
}
function pickDfs(cmos) {
cmos[19] = (cmos[19] & 0xf0) | 9;
return cmos;
}
function atomModel({ name, synonyms, os, banks }) {
return new Model({
name,
shortName: "Atom",
synonyms,
os,
cpuModel: CpuModel.MOS6502,
isMaster: false,
clockMhz: 1,
isAtom: true,
swram: beebSwram,
fdc: NoiseAwareIntelFdc,
banks,
});
}
// TODO(#1066) semi-bplus-style to get swram for exile hardcoded here
const beebSwram = [
true,
true,
true,
true, // Dunjunz variants. Exile (not picky).
true,
true,
true,
true, // Crazee Rider.
false,
false,
false,
false,
false,
false,
false,
false,
];
const masterSwram = [
false,
false,
false,
false,
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
];
export const allModels = [
new Model({
name: "BBC B with 8271 (DFS 1.2)",
shortName: "BBC B",
synonyms: ["B-DFS1.2", "BBC B with DFS 1.2"],
os: ["os.rom", "BASIC.ROM", "b/DFS-1.2.rom"],
cpuModel: CpuModel.MOS6502,
isMaster: false,
clockMhz: 2,
swram: beebSwram,
fdc: NoiseAwareIntelFdc,
}),
new Model({
name: "BBC B with 8271 (DFS 0.9)",
shortName: "BBC B",
synonyms: ["B-DFS0.9", "B", "BBC B with DFS 0.9"],
os: ["os.rom", "BASIC.ROM", "b/DFS-0.9.rom"],
cpuModel: CpuModel.MOS6502,
isMaster: false,
clockMhz: 2,
swram: beebSwram,
fdc: NoiseAwareIntelFdc,
}),
new Model({
name: "BBC B with 1770 (DFS)",
shortName: "BBC B",
synonyms: ["B1770"],
os: ["os.rom", "BASIC.ROM", "b1770/dfs1770.rom", "b1770/zADFS.ROM"],
cpuModel: CpuModel.MOS6502,
isMaster: false,
clockMhz: 2,
swram: beebSwram,
fdc: NoiseAwareWdFdc,
}),
// putting ADFS in a higher ROM slot gives it priority
new Model({
name: "BBC B with 1770 (ADFS)",
shortName: "BBC B",
synonyms: ["B1770A"],
os: ["os.rom", "BASIC.ROM", "b1770/zADFS.ROM", "b1770/dfs1770.rom"],
cpuModel: CpuModel.MOS6502,
isMaster: false,
clockMhz: 2,
swram: beebSwram,
fdc: NoiseAwareWdFdc,
}),
new Model({
name: "BBC Master 128 (DFS)",
shortName: "Master 128",
synonyms: ["Master"],
os: ["master/mos3.20"],
cpuModel: CpuModel.CMOS65C12,
isMaster: true,
clockMhz: 2,
swram: masterSwram,
fdc: NoiseAwareWdFdc,
cmosOverride: pickDfs,
}),
new Model({
name: "BBC Master 128 (ADFS)",
shortName: "Master 128",
synonyms: ["MasterADFS"],
os: ["master/mos3.20"],
cpuModel: CpuModel.CMOS65C12,
isMaster: true,
clockMhz: 2,
swram: masterSwram,
fdc: NoiseAwareWdFdc,
cmosOverride: pickAdfs,
}),
new Model({
name: "BBC Master 128 (ANFS)",
shortName: "Master 128",
synonyms: ["MasterANFS"],
os: ["master/mos3.20"],
cpuModel: CpuModel.CMOS65C12,
isMaster: true,
clockMhz: 2,
swram: masterSwram,
fdc: NoiseAwareWdFdc,
cmosOverride: pickAnfs,
}),
// Atom OS ROM layout: Block F (kernel), E (DOS/MMC), D (FP), C (BASIC).
// Empty strings represent unpopulated ROM slots.
atomModel({
name: "Acorn Atom (MMC)",
synonyms: ["Atom"],
os: ["atom/Atom_Kernel_E.rom", "atom/ATMMC3E.rom", "atom/Atom_FloatingPoint.rom", "atom/Atom_Basic.rom"],
// Utility ROMs in banks 0 and 1 of Block A (0xA000-0xAFFF), up to 8 banks.
// Bank selected by Branquart latch at 0xBFFF (bits 0-3 = bank, bit 6 = lock).
banks: ["atom/PCHARME.ROM", "atom/gags.rom"],
}),
atomModel({
name: "Acorn Atom (Tape)",
synonyms: ["Atom-Tape"],
os: ["atom/Atom_Kernel.rom", "", "", "atom/Atom_Basic.rom"],
}),
atomModel({
name: "Acorn Atom (Tape with FP)",
synonyms: ["Atom-Tape-FP"],
os: ["atom/Atom_Kernel.rom", "", "atom/Atom_FloatingPoint.rom", "atom/Atom_Basic.rom"],
}),
atomModel({
name: "Acorn Atom (DOS)",
synonyms: ["Atom-DOS"],
os: ["atom/Atom_Kernel.rom", "atom/Atom_DOS.rom", "atom/Atom_FloatingPoint.rom", "atom/Atom_Basic.rom"],
}),
// Neither can be selected as a model: they are fitted to one, by the configuration builder later.
new Model({
name: "Tube65C02",
synonyms: [],
os: ["tube/6502Tube.rom"],
// The production wedge's GTE 65SC02 has no Rockwell bit instructions.
cpuModel: CpuModel.CMOS65C12,
isMaster: false,
clockMhz: 3,
}),
new Model({
name: "Tube65C102",
synonyms: [],
os: ["tube/65C102Tube.rom"],
// Boards are reported with both Rockwell and GTE parts, so keep the superset of the two
// until #756 lets the fitted co-processor be chosen.
cpuModel: CpuModel.CMOS65C02,
isMaster: false,
clockMhz: 4,
}),
];
export function findModel(name) {
name = name.toLowerCase();
for (let i = 0; i < allModels.length; ++i) {
const model = allModels[i];
if (model.name.toLowerCase() === name) return model;
for (let j = 0; j < model.synonyms.length; ++j) {
if (model.synonyms[j].toLowerCase() === name) return model;
}
}
return null;
}
export const DefaultModel = findModel("B-DFS1.2");
export const TEST_6502 = new Model({
name: "TEST",
synonyms: ["TEST"],
os: [],
clockMhz: 2,
cpuModel: CpuModel.MOS6502,
isMaster: false,
swram: beebSwram,
fdc: NoiseAwareIntelFdc,
});
TEST_6502.isTest = true;
export const TEST_65C02 = new Model({
name: "TEST",
synonyms: ["TEST"],
os: [],
clockMhz: 2,
cpuModel: CpuModel.CMOS65C02,
isMaster: false,
swram: masterSwram,
fdc: NoiseAwareIntelFdc,
});
TEST_65C02.isTest = true;
export const TEST_65C12 = new Model({
name: "TEST",
synonyms: ["TEST"],
os: [],
clockMhz: 2,
cpuModel: CpuModel.CMOS65C12,
isMaster: false,
swram: masterSwram,
fdc: NoiseAwareIntelFdc,
});
TEST_65C12.isTest = true;
export const basicOnly = new Model({
name: "Basic only",
clockMhz: 2,
synonyms: ["Basic only"],
os: ["master/mos3.20"],
cpuModel: CpuModel.CMOS65C12,
isMaster: true,
swram: masterSwram,
fdc: NoiseAwareWdFdc,
});
/**
* The second processors jsbeeb emulates: the external 3MHz box, and the Master Turbo's
* internal 4MHz board. Machine-building code passes one of these as the emulation config's
* `tube`, so that 6502.js needn't import this module and close an import cycle via the FDC
* modules.
*/
export const TubeModel = findModel("Tube65C02");
export const TurboTubeModel = findModel("Tube65C102");
/** @returns {Model} the second processor sold for this machine: the Turbo board for a Master. */
export function tubeModelFor(model) {
return model.isMaster ? TurboTubeModel : TubeModel;
}
// After the isTest assignments above, so those still apply.
for (const model of [...allModels, TEST_6502, TEST_65C02, TEST_65C12, basicOnly]) {
Object.freeze(model.os);
Object.freeze(model.synonyms);
Object.freeze(model);
}
Object.freeze(allModels);
|