@moonbase-machines/player 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["moonbase-module:apple2e/machine.js", "moonbase-module:apple2e/prodos.js", "moonbase-module:apple2e/saves.js", "moonbase-module:apple2e/screen.js", "moonbase-module:vector/pictures.js", "moonbase-module:vector/svg.js", "moonbase-module:c64/machine.js", "moonbase-module:c64/printer.js", "moonbase-module:c64/vic.js", "moonbase-module:c64/browser.js", "moonbase-module:c64/sid.js", "moonbase-module:c64/start.js", "moonbase-module:c64/d64.js", "moonbase-module:c64/saves.js", "../original.js", "../audio.js", "../parts.js", "../modal.js", "../disk/dialogs.js", "../disk/disk.js", "../disk/local.js", "../disk/memory.js", "../remake/c64-view.js", "moonbase-module:c64/paint.js", "../remake/card-view.js", "../remake/card.js", "../remake/events.js", "../remake/cards.js", "moonbase-module:apple2e/mli.js", "moonbase-module:apple2e/rom.js", "moonbase-module:c64/kernal.js", "moonbase-module:c64/drive.js", "moonbase-module:c64/basic.js", "moonbase-module:c64/numbers.js", "moonbase-module:c64/basic-rom.js", "../remake/lift.js", "moonbase-module:mos6502/disasm.js", "moonbase-module:vector/inline.js", "../remake/compile.js", "../remake/script.js", "../remake/engine.js", "moonbase-module:mos6502/cpu.js", "../remake/layout.js", "moonbase-module:vector/font.js", "../remake/load.js", "../remake/vector.js", "../remake/problems.js", "moonbase-module:vector/objects.js", "../remake/raster.js", "moonbase-module:vector/draw.js", "../remake/main.js", "../remake/scenes.js", "moonbase-module:c64/rom.js", "../remake/view.js", "moonbase-module:apple2e/colors.js", "moonbase-module:charset/font.js"],
4
- "sourcesContent": ["import { machine as m } from '@moonbase-machines/apple2e';\nexport const { Machine } = m;", "import { prodos as m } from '@moonbase-machines/apple2e';\nexport const { blank, placed, started, units } = m;", "import { saves as m } from '@moonbase-machines/apple2e';\nexport const { driveFiles, keepSaves, onDisks, withSaves } = m;", "import { screen as m } from '@moonbase-machines/apple2e';\nexport const { COLORS, colors, paint, paintHires, paintText, rowStart, screen, textRow } = m;", "import { pictures as m } from '@moonbase-machines/vector';\nexport const { pictures, shapes, windows } = m;", "import { svg as m } from '@moonbase-machines/vector';\nexport const { bounds, document, elements } = m;", "import { machine as m } from '@moonbase-machines/c64';\nexport const { C64 } = m;", "import { printer as m } from '@moonbase-machines/c64';\nexport const { Printer, WIDTH, bus, paper } = m;", "import { vic as m } from '@moonbase-machines/c64';\nexport const { HEIGHT, LEFT, PALETTE, TOP, VIC, WIDTH } = m;", "import { browser as m } from '@moonbase-machines/c64';\nexport const { keyboard, pace, painter } = m;", "import { sid as m } from '@moonbase-machines/c64';\nexport const { SID } = m;", "import { start as m } from '@moonbase-machines/c64';\nexport const { ROM_CHOICES, c64Roms, typed } = m;", "import { d64 as m } from '@moonbase-machines/c64';\nexport const { SECTORS, add, make, petsciiName, read } = m;", "import { saves as m } from '@moonbase-machines/c64';\nexport const { keepDrive } = m;", "// The original: a game's disk in the machine it was made for, its screen on a canvas, the keyboard passed\n// on, and each picture the engine draws also given as SVG over the canvas. Each game's machine is loaded when its\n// game asks for it, the Commodore 64 (@moonbase-machines/c64) or the Apple IIe (@moonbase-machines/apple2e), and not\n// the other; on moonbase's own ROMs, which need nothing of the makers'.\n//\n// await play({ data, root, disk, words, downloadDisk, roms, studies })\n// data the game's data, an absolute URL (<name>.json: its disks' files, its kind, its saves)\n// root the page's section the player is made in\n// disk the title's player's disk (disk/disk.js), opened before the player starts\n// words the page's words the player shows: { printer: { line, print, tear } }\n// downloadDisk a C64 game's disk offered to download, with what is saved on it\n// and what only a workshop has, given by its pages, never looked for here:\n// roms the makers' ROMs this machine has: an Apple game's line 1, Apple's own booting its disks,\n// { apple: { system, disk2 }, image: async name => its disk image's bytes }; a C64 game's\n// Commodore's, { choice ('commodore' or 'moonbase-petscii', @moonbase-machines/c64/start.js), load:\n// async name => a ROM's bytes }\n// studies files of its own for a C64 game's disk, a name to its bytes in base64, in the drive, not kept\nimport { Speaker } from './audio.js';\nimport { paperBox, phoneKeys, KEYS_MARKUP } from './parts.js';\n\nexport async function play({ data, root, disk, words, downloadDisk = false, roms = null, studies = null }) {\n root.classList.add('game');\n root.innerHTML = `<div class=\"stage\"><svg id=\"vector\" viewBox=\"0 0 140 192\" preserveAspectRatio=\"none\"></svg><canvas id=\"screen\" width=\"560\" height=\"384\" tabindex=\"0\"></canvas></div>\n <p class=\"options\"><span id=\"status\">Loading.</span>${KEYS_MARKUP}<label><input type=\"checkbox\" id=\"vectors\"> Draw the pictures as vectors</label><label hidden><input type=\"checkbox\" id=\"printer\" checked> Printer</label><button id=\"disk\" type=\"button\" hidden>Download the disk</button></p>`;\n root.append(paperBox(words.printer));\n const $ = id => root.querySelector('#' + id);\n const canvas = $('screen'), ctx = canvas.getContext('2d');\n phoneKeys(root, canvas.parentElement);\n // (the game's name, for a disk downloaded: its data's file's)\n const name = new URL(data).pathname.split('/').pop().replace(/\\.json$/, '');\n const parts = { name, roms, studies, disk, downloadDisk, $, canvas, ctx, layer: $('vector'), status: $('status'), vectorToggle: $('vectors'), speaker: new Speaker() };\n const game = await (await fetch(data)).json();\n if (game.kind === 'c64') await c64(game, parts); else await apple(game, parts);\n}\n\n// the screen stretched evenly: a whole number of the device's pixels to each of the machine's dots\n// (the 64's 384 by 272, the Apple's 280 by 192), so every dot is drawn the same size and a line one\n// dot thick is as thick as any other; the next whole number up from the column's width, a little\n// wider than it and centred on it, unless that is wider than the window; kept so as the window, or\n// its zoom, changes\nfunction evenly(canvas, dots, lines) {\n const stage = canvas.parentElement, column = stage.parentElement;\n const fit = () => {\n const dpr = window.devicePixelRatio || 1, pad = parseFloat(getComputedStyle(column).paddingLeft) * 2;\n const room = column.clientWidth - pad, most = document.documentElement.clientWidth - 16;\n let k = Math.ceil(room * dpr / dots - 0.01);\n if (dots * k / dpr > most) k = Math.max(1, Math.floor(most * dpr / dots));\n const w = dots * k / dpr;\n Object.assign(stage.style, { width: w + 'px', height: lines * k / dpr + 'px', aspectRatio: 'auto', marginLeft: (room - w) / 2 + 'px' });\n };\n fit();\n addEventListener('resize', fit);\n}\n\n// An Apple II game: the machine, the canvas, the keys, and the hooks for the vectors. With Apple's\n// ROMs and the game's disk images, where the page gives them (`roms`), it is line 1, the Apple itself booting the\n// disks; without them, moonbase's (line 2), the game started at once.\nasync function apple(game, { roms: makers, disk, canvas, ctx, layer, status, vectorToggle, speaker }) {\nconst [{ Machine }, { placed }, { withSaves, keepSaves, onDisks, driveFiles }, { screen }, { shapes }, { elements }] = await Promise.all([\n import('@moonbase-machines/apple2e/machine.js'), import('@moonbase-machines/apple2e/prodos.js'), import('@moonbase-machines/apple2e/saves.js'),\n import('@moonbase-machines/apple2e/screen.js'), import('@moonbase-machines/vector/pictures.js'), import('@moonbase-machines/vector/svg.js')]);\nevenly(canvas, 280, 192);\n// the title's saves on its own volume, the player's disk's (@moonbase-machines/apple2e/saves.js): on line 2 the\n// machine's files; on line 1 written onto that volume's disk before it boots, and kept as the title's DOS writes it\nconst saving = withSaves(game, disk);\nlet roms = null, disks = null;\nif (makers?.apple) try {\n roms = makers.apple;\n disks = onDisks(game, placed(saving, new Map(await Promise.all(game.images.map(async n => [n, await makers.image(n)])))), disk);\n} catch { roms = null; }\nconst m = new Machine(saving, { log: (...a) => console.log(...a), ...roms ? { roms, disks } : {} });\nconsole.log(roms ? \"line 1: Apple's ROMs, the disks booted\" : \"line 2: moonbase's machine\");\nkeepSaves(game, roms ? driveFiles(m, disks, game) : m.disk, disk);\nm.diskTime = true; // reads from the disk take the time a disk took, as the games' loading screens expect\n\n// Where the engine is hooked, found in PART0 once it is loaded, in whichever bank the game runs\n// in. The picture routine's loop draws the shapes the loader has put at $E000 one by one, so on\n// its first shape the whole picture is read for the SVG, and from there to the routine's exit,\n// which sets X to 0 and Y to $E0, the machine marks every screen byte written as the picture's.\n// The box routine, which clears the picture window, starts by keeping its three colors, and\n// there the SVG and the marks are cleared, and the window's color, in A, is kept to go under\n// the next pictures' polygons.\nlet hooked = false, window_ = 0;\nfunction hook() {\n const find = (bytes, code) => { outer: for (let a = 0x4000; a < 0x8000 - bytes.length; a++) { for (let i = 0; i < bytes.length; i++) if (bytes[i] !== null && code[a + i] !== bytes[i]) continue outer; return a; } return -1; };\n for (const code of [m.aux, m.main]) {\n const shape = find([0x20, null, null, 0x20, null, null, 0xee, null, null, 0x4c], code); // JSR fill; JSR outline; INC count; JMP loop\n const exit = find([0xa2, 0x00, 0xa0, 0xe0, 0x18, 0x60], code); // LDX #0; LDY #$E0; CLC; RTS\n const box = find([0x8d, null, null, 0x8e, null, null, 0x8c, null, null, 0xad, null, null, 0xc9, 0x80, 0xf0], code);\n if (shape < 0 || exit < 0 || box < 0) continue;\n m.cpu.hooks.set(shape, c => { if (c.read16(0x60) === 0xe000) { layer.insertAdjacentHTML('beforeend', elements(shapes(a => m.read(a), 0xe000), { background: window_ })); m.marking = 1; } return false; });\n m.cpu.hooks.set(exit, () => { m.marking = 0; return false; });\n m.cpu.hooks.set(box, c => { if (c.a !== 0x80) window_ = c.a & 15; layer.innerHTML = ''; m.owner.fill(0); return false; });\n hooked = true;\n return;\n }\n}\n\n// the keys, as the Apple II's keyboard gives them\nconst KEYS = { Escape: 27, Enter: 13, Backspace: 127, Delete: 127, ArrowLeft: 8, ArrowRight: 21, ArrowUp: 11, ArrowDown: 10, Tab: 9 };\nwindow.addEventListener('keydown', e => {\n speaker.start();\n if (e.metaKey || e.altKey || e.repeat) return; // a held key is one key\n // control with a letter is the Apple's control character: control-E opens Animal Rescue's main menu\n const k = e.ctrlKey ? (/^[a-z]$/i.test(e.key) ? e.key.toUpperCase().charCodeAt(0) & 0x1f : undefined) : KEYS[e.key] ?? (e.key.length === 1 ? e.key.charCodeAt(0) : undefined);\n if (k === undefined) return;\n console.log('key', JSON.stringify(e.key), '->', k, 'at pc $' + m.cpu.pc.toString(16));\n m.press(k); e.preventDefault();\n});\n\nconst rgba = new Uint8ClampedArray(560 * 384 * 4);\nconst image = new ImageData(rgba, 560, 384);\nconst cols = new Uint8Array(140 * 192);\nlet mode = '';\nfunction frame() {\n if (!m.halted) m.runCycles(17030); // a frame's worth of the Apple's clock, at 60 a second\n const now = `text ${m.sw.text} page2 ${m.sw.page2} hires ${m.sw.hires} dhires ${m.sw.dhires}`;\n if (now !== mode) { console.log('screen:', now, 'at pc $' + m.cpu.pc.toString(16), 'cycles', m.cpu.cycles); mode = now; }\n speaker.feed(m.clicks, m.cpu.cycles); m.clicks.length = 0;\n if (!hooked) hook();\n const text = m.sw.text;\n screen(m, rgba, { cols, owner: vectorToggle.checked && layer.innerHTML ? m.owner : null });\n ctx.putImageData(image, 0, 0);\n layer.style.visibility = vectorToggle.checked && !text ? 'visible' : 'hidden';\n status.textContent = m.halted ? 'The game has stopped: ' + m.halted + '.' : (m.idle > 2000 ? 'Waiting for a key.' : 'Running.');\n requestAnimationFrame(frame);\n}\ncanvas.addEventListener('pointerdown', () => { speaker.start(); canvas.focus(); });\ncanvas.focus();\nframe();\n}\n\n// A C64 game: on moonbase's own ROMs (@moonbase-machines/c64/rom.js), as the site has it everywhere, or on\n// Commodore's where the page gives them (`roms`) and asks for them; the machine autostarted\n// with LOAD\"name\",8,1, and RUN for a BASIC program, typed into the KERNAL's buffer, the frame on a canvas of\n// 384 by 272 doubled, the keys as the matrix and the arrows as the joystick.\nasync function c64(game, { name, roms: makers, studies, disk, downloadDisk, $, canvas, layer, status, vectorToggle, speaker }) {\n const [{ C64 }, { Printer, paper }, { WIDTH, HEIGHT }, { keyboard, painter }, { SID }, { c64Roms, typed: startTyped }, { add }, { keepDrive }] = await Promise.all([\n import('@moonbase-machines/c64/machine.js'), import('@moonbase-machines/c64/printer.js'), import('@moonbase-machines/c64/vic.js'), import('@moonbase-machines/c64/browser.js'),\n import('@moonbase-machines/c64/sid.js'), import('@moonbase-machines/c64/start.js'), import('@moonbase-machines/c64/d64.js'), import('@moonbase-machines/c64/saves.js')]);\n evenly(canvas, WIDTH, HEIGHT);\n const roms = await c64Roms(makers?.choice ?? null, makers?.load);\n if (!roms) { status.textContent = 'Commodore\\'s ROMs, asked for, are not here.'; return; }\n // a printer on device 4 (@moonbase-machines/c64/printer.js): on unless its box is off, what it prints drawn\n // below the screen as a sheet of paper, until it is torn off\n const box = $('printer'), sheet = $('paper'), shown = $('paper-box');\n try { box.checked = localStorage.getItem('printer') !== '0'; } catch {}\n box.parentElement.hidden = false;\n const printer = new Printer({ on: box.checked });\n box.addEventListener('change', () => { printer.on = box.checked; try { localStorage.setItem('printer', box.checked ? '1' : '0'); } catch {} });\n printer.changed = () => { shown.hidden = !printer.lines.length; if (printer.lines.length) paper(sheet, printer, roms.chargen); };\n $('tear').addEventListener('click', () => printer.tear());\n $('print-paper').addEventListener('click', () => window.print()); // (the sheet alone: its print style)\n const m = new C64(game, roms, { log: (...a) => console.log(...a), printer });\n // What the game SAVEs to its disk, kept on the player's disk and given back to the drive the next time\n // (@moonbase-machines/c64/saves.js)\n keepDrive(m.drive, disk);\n // (and, where the page gives them, `studies`, files of its own for the disk, a name to a file: in the drive, not\n // kept)\n const raw = t => Uint8Array.from(atob(t), c => c.charCodeAt(0));\n for (const [file, data] of Object.entries(studies ?? {})) m.drive.saved.set(file, raw(data));\n // the disk as it now stands, its own files and those saved, to download where the title offers it\n // (Crayon's): a .d64 that VICE or a real 64 can use (@moonbase-machines/c64/d64.js `add`)\n if (downloadDisk) {\n const download = $('disk');\n download.hidden = false;\n download.addEventListener('click', () => {\n const image = add(m.drive.image, [...m.drive.saved].map(([name, data]) => ({ name, data })));\n const a = Object.assign(document.createElement('a'), { href: URL.createObjectURL(new Blob([image], { type: 'application/octet-stream' })), download: name + '.d64' });\n a.click(); URL.revokeObjectURL(a.href);\n });\n }\n layer.style.display = 'none'; vectorToggle.parentElement.style.display = 'none';\n const draw = painter(canvas);\n let typing = null, typed = 0;\n const keys = keyboard(m, { onKey: () => speaker.start(), log: true });\n // once BASIC is ready, the start typed in; the KERNAL's buffer takes ten characters at a time.\n // The C64 runs 50 frames a second, so frames are run to keep up with the clock, two at most.\n let frames = 0, sid = null, started = performance.now();\n function frame() {\n const due = Math.min(2, Math.floor((performance.now() - started) / 20) - frames);\n for (let i = 0; i < due; i++) {\n m.runFrame(); frames++; keys.frame();\n if (speaker.node) {\n if (!sid) sid = new SID(speaker.rate);\n const n = Math.round(19656 / 985248 * speaker.rate), first = m.cpu.cycles - 19656;\n const wave = sid.render(n, m.sidWrites.map(([c, r, v]) => [Math.floor((c - first) / 19656 * n), r, v]));\n speaker.node.port.postMessage(wave, [wave.buffer]);\n }\n m.sidWrites.length = 0;\n }\n // (LOAD, and RUN for a BASIC program: @moonbase-machines/c64/start.js)\n if (frames >= 120 && typing === null && !typed) { typing = startTyped(m, game); typed = 1; }\n if (typing !== null && !m.ram[0xc6]) { typing = m.type(typing); if (!typing.length) typing = null; }\n draw(m.vic.frame);\n status.textContent = m.halted ? 'The game has stopped: ' + m.halted + '.' : 'Running.';\n requestAnimationFrame(frame);\n }\n canvas.focus(); frame();\n}\n", "// The speaker. The Apple II makes sound by clicking the speaker, a toggle at $C030, and the\n// machine keeps the cycle of each click. `Speaker` turns a run of cycles into a square wave\n// at the sound card's rate and plays it through a worklet, which keeps a queue of what it has\n// been given and holds the last level when the queue runs dry.\nconst CYCLES_PER_SECOND = 1020484;\n\nconst WORKLET = `\nclass SpeakerProcessor extends AudioWorkletProcessor {\n constructor() { super(); this.queue = []; this.at = 0; this.level = 0; this.port.onmessage = e => this.queue.push(e.data); }\n process(inputs, outputs) {\n const out = outputs[0][0];\n for (let i = 0; i < out.length; i++) {\n while (this.queue.length && this.at >= this.queue[0].length) { this.queue.shift(); this.at = 0; }\n if (this.queue.length) this.level = this.queue[0][this.at++];\n out[i] = this.level;\n }\n return true;\n }\n}\nregisterProcessor('speaker', SpeakerProcessor);\n`;\n\nexport class Speaker {\n constructor() { this.context = null; this.node = null; this.level = 0; this.from = null; }\n\n // start on a gesture, as browsers require\n async start() {\n if (this.context) return;\n this.context = new AudioContext();\n await this.context.audioWorklet.addModule(URL.createObjectURL(new Blob([WORKLET], { type: 'text/javascript' })));\n this.node = new AudioWorkletNode(this.context, 'speaker');\n this.node.connect(this.context.destination);\n this.rate = this.context.sampleRate;\n if (this.context.state !== 'running') await this.context.resume();\n }\n\n // the wave for the cycles from the last call up to `cycles`, given the clicks in between\n feed(clicks, cycles) {\n if (!this.node) return;\n if (this.from === null) this.from = cycles; // from when the sound starts, not from the machine's first cycle\n const perSample = CYCLES_PER_SECOND / this.rate;\n const n = Math.floor((cycles - this.from) / perSample);\n if (n <= 0) return;\n const wave = new Float32Array(n);\n let ci = 0;\n for (let i = 0; i < n; i++) {\n const t = this.from + (i + 1) * perSample;\n while (ci < clicks.length && clicks[ci] <= t) { this.level = this.level ? 0 : 0.25; ci++; }\n wave[i] = this.level;\n }\n this.from += n * perSample;\n this.node.port.postMessage(wave, [wave.buffer]);\n }\n}\n", "// The parts both players make the same: the printer's paper under the screen, and a phone's keyboard.\n//\n// paperBox(words) the paper's box (hidden until there is something printed): its line, Print and\n// Tear off, and the sheet (#paper-box, #print-paper, #tear, #paper)\n// phoneKeys(root, stage) on a phone, the Keyboard button (#keyboard) opens its keyboard on a box (#keys-box)\n// whose keys go to the window's own listener; a keyboard that names no key gives\n// its characters, passed on as keys\nexport function paperBox({ line, print, tear }) {\n const box = document.createElement('div');\n box.id = 'paper-box'; box.hidden = true;\n box.innerHTML = '<p><span></span> <button id=\"print-paper\" type=\"button\"></button> <button id=\"tear\" type=\"button\"></button></p><canvas id=\"paper\"></canvas>';\n box.querySelector('span').textContent = line;\n box.querySelector('#print-paper').textContent = print;\n box.querySelector('#tear').textContent = tear;\n return box;\n}\n\nexport function phoneKeys(root, stage) {\n const kb = root.querySelector('#keyboard'), box = root.querySelector('#keys-box');\n if (!kb || !box || !matchMedia('(pointer: coarse)').matches) return;\n kb.hidden = false;\n kb.addEventListener('click', () => box.focus());\n stage.addEventListener('click', () => box.focus());\n let unnamed = false;\n box.addEventListener('keydown', e => { unnamed = e.key === 'Unidentified'; });\n box.addEventListener('input', () => {\n if (unnamed) for (const ch of box.value) for (const t of ['keydown', 'keyup']) window.dispatchEvent(new KeyboardEvent(t, { key: ch }));\n box.value = '';\n });\n}\n\n// the options line's keyboard parts, as both players have them\nexport const KEYS_MARKUP = '<button type=\"button\" id=\"keyboard\" class=\"full\" hidden>Keyboard</button><input id=\"keys-box\" class=\"keys-box\" autocomplete=\"off\" autocapitalize=\"off\" autocorrect=\"off\" spellcheck=\"false\" aria-label=\"Keys for the game\">';\n", "// A modal window, the one way every dialog and window over a game is shown: the disk's dialogs\n// (disk/dialogs.js) and a program's own windows (Aztlan's help and About box, its macapp.js). It opens\n// inside the place it is given, the game's screen, not over the whole page: what it covers is that place\n// alone, which scrolls with it, and the rest of the page is the page's. Its frame and look are the place's\n// (a class, as Aztlan's window definition 1 has it, and the place's own styles); without a place, the page.\n//\n// const m = modal({ within, className, content, cancel })\n// within the element it opens in (positioned), else the page\n// className its frame's classes\n// content what it shows\n// cancel() what Escape does (closing it, else)\n// m.box, m.close()\n// While it is open the rest of `within` is inert, and the keys are the topmost one's, wherever the focus\n// is (WebKit leaves it on the page when a button is clicked): Escape cancels; Return presses its default\n// button (`.default`), unless on a button, or in a box that takes Return itself; Tab stays inside it. When\n// it closes the focus goes back where it was, or into the window under it.\nconst open = [];\n// (listened for from the first one opened: a module the tests load in Node, with no page)\nlet listening = false;\nconst keys = e => {\n const m = open.at(-1);\n if (!m) return;\n if (e.key === 'Escape') { e.preventDefault(); m.cancel(); }\n else if (e.key === 'Enter' && !(e.target instanceof HTMLButtonElement) && e.target.tagName !== 'TEXTAREA') {\n const d = m.box.querySelector('.default:not(:disabled)');\n if (d) { e.preventDefault(); d.click(); }\n }\n else if (e.key === 'Tab') {\n const f = focusable(m.box), at = f.indexOf(document.activeElement);\n if (f.length) { e.preventDefault(); f[(at + (e.shiftKey ? f.length - 1 : 1)) % f.length].focus(); }\n }\n // (the game under it has none of the keys)\n e.stopPropagation();\n};\nconst focusable = box => [...box.querySelectorAll('button:not(:disabled), input:not([type=hidden]):not([type=file]):not([hidden]), select:not([hidden]), [tabindex=\"0\"]')];\nconst first = box => box.querySelector('input:not([type=file]), select:not([hidden])') ?? box.querySelector('.default') ?? focusable(box)[0];\n\nexport function modal({ within = document.body, className = '', content, cancel = null }) {\n if (!listening) { document.addEventListener('keydown', keys, true); listening = true; }\n const layer = document.createElement('div');\n layer.className = 'modal-layer' + (within === document.body ? ' page' : '');\n const box = document.createElement('div');\n box.className = 'modal ' + className;\n box.setAttribute('role', 'dialog'); box.setAttribute('aria-modal', 'true');\n box.append(content); layer.append(box);\n const before = document.activeElement;\n const others = [...within.children].filter(el => !el.inert);\n for (const el of others) el.inert = true;\n within.append(layer);\n const m = {\n box,\n cancel: () => (cancel ?? m.close)(),\n close() {\n layer.remove();\n open.splice(open.indexOf(m), 1);\n for (const el of others) el.inert = false;\n const under = open.at(-1);\n (under && !under.box.contains(before) ? first(under.box) : before)?.focus?.({ preventScroll: true });\n },\n };\n open.push(m);\n // (the first box to type in or list to choose from, else the default button, has the focus)\n first(box)?.focus({ preventScroll: true });\n return m;\n}\n\n// whether a modal window is open: a game's keys and commands wait while one is\nexport const modalOpen = () => open.length > 0;\n", "// The disk's own dialogs, the same in every game that hands saving to the system (as Aztlan for Macintosh\n// handed it to the Mac's): a game is saved by name, and opened from the disk's list, or from a file\n// downloaded before. A game that asks on its own screen (the 8-bit games) keeps its own prompt; the disk\n// only keeps what it saves. Each is a modal window (../modal.js) opened where the game says, its host: in\n// its screen, in the frame its own windows have (Aztlan's, window definition 1, the Mac's dialog box), and\n// so looking as its own windows look; with no host, on the page, as the site's (site/assets/site.css).\n//\n// const { saveAs, openFrom, ask, tell } = dialogs({ within, className }) the game's host\n// await saveAs(disk, { suggested }) a name, or null: offers to replace a file of that name\n// await openFrom(disk, { file }) { name, bytes } from the disk, or null: the disk's manager, the\n// same for every game, its games listed, each to open, download\n// or delete, and a downloaded one put back on it from a file\n// (`file`, the game's own: { extension, type }, '.zip' and its type)\n// await ask(heading, body, buttons, { aside }) a dialog of a game's own: [label, value] buttons, the\n// last the default, a function's value what it returns; `aside`,\n// buttons of the dialog's own on the same line, at its left\n// await tell(heading) a word, and OK\nimport { modal } from '../modal.js';\n\nexport function dialogs({ within, className = '' } = {}) {\n function ask(heading, body, buttons, { aside = [] } = {}) {\n return new Promise(done => {\n const content = document.createElement('div'); content.className = 'disk';\n const h = document.createElement('h2'); h.textContent = heading;\n const row = document.createElement('p'); row.className = 'buttons';\n for (const [label, value] of buttons) {\n const b = Object.assign(document.createElement('button'), { type: 'button', textContent: label });\n b.onclick = async () => { m.close(); done(typeof value === 'function' ? await value() : value); };\n row.append(b);\n }\n row.lastChild?.classList.add('default');\n if (aside.length) { const left = document.createElement('span'); left.className = 'aside'; left.append(...aside); row.prepend(left); }\n content.append(h, ...body, row);\n // (Escape: nothing chosen)\n const m = modal({ within, className, content, cancel: () => { m.close(); done(null); } });\n });\n }\n const tell = heading => ask(heading, [], [['OK', null]]);\n\n async function saveAs(disk, { suggested = '' } = {}) {\n const input = Object.assign(document.createElement('input'), { value: suggested, maxLength: 31 });\n setTimeout(() => input.select());\n const label = document.createElement('label'); label.append('Save as ', input);\n const name = await ask('Save', [label, ...keptNote(disk)], [['Cancel', null], ['Save', () => input.value.trim() || null]]);\n if (!name) return null;\n if (disk.read(name) && !await ask(`Replace \"${name}\"?`, [], [['Cancel', false], ['Replace', true]])) return null;\n return name;\n }\n\n async function openFrom(disk, { file: { extension = '', type = 'application/octet-stream' } = {} } = {}) {\n const select = Object.assign(document.createElement('select'), { size: 6 });\n const note = document.createElement('p'); note.className = 'note';\n const input = Object.assign(document.createElement('input'), { type: 'file', accept: [extension, type].filter(Boolean).join(','), hidden: true });\n const button = text => Object.assign(document.createElement('button'), { type: 'button', textContent: text });\n const from = button('File\u2026'), download = button('Download'), remove = button('Delete');\n const fill = () => {\n select.replaceChildren(...disk.list().map(f => new Option(`${f.name} \u00B7 ${new Date(f.modified).toLocaleString()}`, f.name)));\n select.selectedIndex = select.options.length ? 0 : -1;\n select.hidden = !select.options.length;\n note.textContent = select.options.length ? 'On your disk:' : 'Nothing saved on your disk yet.';\n remove.disabled = download.disabled = !select.options.length;\n };\n fill();\n const chosen = ask('Open', [note, select, input, ...keptNote(disk)], [['Cancel', null], ['Open', () => select.value || null]], { aside: [from, download, remove] });\n const open = () => select.closest('.modal').querySelector('.default').click();\n // (File\u2026: a game downloaded before, put back on the disk by its file's name, and opened)\n from.onclick = () => input.click();\n input.onchange = async () => {\n const f = input.files[0], n = f.name.slice(0, f.name.length - (extension && f.name.endsWith(extension) ? extension.length : 0));\n if (disk.read(n) && !await ask(`Replace \"${n}\"?`, [], [['Cancel', false], ['Replace', true]])) return;\n disk.write(n, new Uint8Array(await f.arrayBuffer()));\n fill(); select.value = n; open();\n };\n // (a game taken off the disk as its file, to keep, or for the original: Aztlan's for Infinite Mac)\n download.onclick = () => {\n const n = select.value; if (!n) return;\n const a = Object.assign(document.createElement('a'), { href: URL.createObjectURL(new Blob([disk.read(n)], { type })), download: n + extension });\n a.click(); setTimeout(() => URL.revokeObjectURL(a.href), 1000);\n };\n // (a file deleted only once asked, in a dialog over this one, Cancel its default)\n remove.onclick = async () => {\n const n = select.value; if (!n) return;\n if (!await ask(`Delete \"${n}\"?`, [warning('It is gone from your disk for good.')], [['Delete', true], ['Cancel', false]])) return;\n await disk.remove(n); fill(); select.focus();\n };\n select.ondblclick = open;\n const name = await chosen;\n return name ? { name, bytes: disk.read(name) } : null;\n }\n return { saveAs, openFrom, ask, tell };\n}\n\nconst warning = text => Object.assign(document.createElement('p'), { className: 'note', textContent: text });\n\n// (where the browser keeps nothing, a word saying so: the game is there until the page closes)\nfunction keptNote(disk) {\n if (disk.kept) return [];\n const p = document.createElement('p'); p.className = 'note';\n p.textContent = 'This browser is not keeping files: download a game to keep it.';\n return [p];\n}\n", "// The player's disk: the files a person makes, kept by name on a disk of their own, one for each title\n// and one for each program that saves (Microsoft BASIC's tape and disk, the editors). Every game and\n// program that saves does so here, and only here; its files are its own bytes, in its own format, with\n// what the format needs beside them (`meta`, a ProDOS file's type and aux).\n//\n// A disk is read whole when it is opened, before the program starts, and kept in memory: the machines\n// read files at once, inside an instruction (@moonbase-machines/apple2e/machine.js's MLI call,\n// @moonbase-machines/c64/drive.js's find), so a read is never waited for. A write changes the copy at once and is stored behind\n// it, in order.\n//\n// const disk = await openDisk(name, { backend }) backend: local() (local.js, the default)\n// or memory() (memory.js)\n// disk.list() [{ name, size, modified, meta }], newest first\n// disk.read(name) its bytes, or null\n// disk.write(name, bytes, meta) a promise, kept when stored\n// disk.remove(name) a promise\n// disk.written() a promise: every write so far stored\n// disk.name, disk.kept the disk's name; whether its files outlast the page\n//\n// A disk's name says whose it is, so a title and a program can never share one: titleDisk(slug), a title's\n// player's, 'title/zoopak'; programDisk(name), one of the site's own programs', 'program/basic'.\n//\n// The backend is where a disk's files are kept: { kept, load(disk), put(disk, file), delete(disk, name) },\n// a file { name, bytes, meta, modified }. This browser's is local(); an account's will be the API's.\nimport { local } from './local.js';\nimport { memory } from './memory.js';\n\nexport async function openDisk(name, { backend } = {}) {\n // (a browser that keeps nothing, as a private window may: the disk in memory, and said so)\n if (!backend) { try { backend = await local(); } catch { backend = memory({ kept: false }); } }\n const files = new Map((await backend.load(name)).map(f => [f.name, f]));\n let queue = Promise.resolve();\n const later = job => (queue = queue.then(job));\n return {\n name,\n kept: backend.kept,\n list: () => [...files.values()].sort((a, b) => b.modified - a.modified).map(({ name, bytes, meta, modified }) => ({ name, size: bytes.length, modified, meta })),\n read: n => files.get(n)?.bytes ?? null,\n write(n, bytes, meta = {}) {\n const f = { name: n, bytes: Uint8Array.from(bytes), meta, modified: Date.now() };\n files.set(n, f);\n return later(() => backend.put(name, f));\n },\n remove(n) {\n files.delete(n);\n return later(() => backend.delete(name, n));\n },\n written: () => queue,\n };\n}\n\nexport const titleDisk = slug => `title/${slug}`;\nexport const programDisk = name => `program/${name}`;\n\n// a text file's bytes and back, for the programs whose files are text (UTF-8)\nexport const textBytes = s => new TextEncoder().encode(s);\nexport const bytesText = b => b ? new TextDecoder().decode(b) : null;\n", "// A disk's files kept in this browser, in IndexedDB: the database `moonbase`, its store `files`, each file\n// keyed by its account, its disk and its name. The account is `local`, this browser's own, until there\n// are accounts; theirs will be kept by the API, behind the same calls.\n//\n// await local({ account }) a backend: { kept, load(disk), put(disk, file), delete(disk, name) }\n// (named here once, for a tool that puts a file on a disk too)\nexport const DB = 'moonbase', VERSION = 1, STORE = 'files', KEY = ['account', 'disk', 'name'], ACCOUNT = 'local';\n\nconst opened = () => new Promise((done, fail) => {\n const r = indexedDB.open(DB, VERSION);\n r.onupgradeneeded = () => r.result.createObjectStore(STORE, { keyPath: KEY });\n r.onsuccess = () => done(r.result);\n r.onerror = () => fail(r.error);\n});\nconst asked = r => new Promise((done, fail) => { r.onsuccess = () => done(r.result); r.onerror = () => fail(r.error); });\n\nexport async function local({ account = ACCOUNT } = {}) {\n const db = await opened();\n const store = mode => db.transaction(STORE, mode).objectStore(STORE);\n return {\n kept: true,\n // (the disk's files: those keyed from [account, disk] up to the next disk's)\n load: async disk => (await asked(store('readonly').getAll(IDBKeyRange.bound([account, disk], [account, disk, []]))))\n .map(({ name, bytes, meta, modified }) => ({ name, bytes, meta, modified })),\n put: (disk, f) => asked(store('readwrite').put({ account, disk, ...f })),\n delete: (disk, name) => asked(store('readwrite').delete([account, disk, name])),\n };\n}\n", "// A disk's files kept in memory only, for as long as the page: for the tests, which run where there is no\n// IndexedDB, and for a browser that will keep nothing (disk.js says which, `kept`).\n//\n// memory({ kept }) a backend: { kept, load(disk), put(disk, file), delete(disk, name) }\nexport function memory({ kept = true } = {}) {\n const disks = new Map(), of = d => disks.get(d) ?? disks.set(d, new Map()).get(d);\n return {\n kept,\n load: async d => [...of(d).values()].map(f => ({ ...f, bytes: Uint8Array.from(f.bytes) })),\n put: async (d, f) => { of(d).set(f.name, { ...f, bytes: Uint8Array.from(f.bytes) }); },\n delete: async (d, n) => { of(d).delete(n); },\n };\n}\n", "// The view of a Commodore 64 title (Zoopak): the frame the VIC-II paints from the remake's\n// memory and chips (@moonbase-machines/c64/paint.js), border and all, 384 by 272 in the machine's colours. The\n// character ROM, which a text screen in the machine's own letters needs, is the one the emulator\n// is given (the page's `roms`), when it is there.\nimport { paint } from '@moonbase-machines/c64/paint.js';\nimport { PALETTE, WIDTH, HEIGHT } from '@moonbase-machines/c64/vic.js';\n\nconst NS = 'http://www.w3.org/2000/svg';\n\nexport class C64View {\n constructor(svg, { engine, chargen }) {\n this.svg = svg; this.engine = engine; this.chargen = chargen;\n svg.setAttribute('viewBox', `0 0 ${WIDTH * 2} ${HEIGHT * 2}`);\n this.canvas = document.createElement('canvas'); this.canvas.width = WIDTH; this.canvas.height = HEIGHT;\n this.image = document.createElementNS(NS, 'image');\n for (const [k, v] of Object.entries({ x: 0, y: 0, width: WIDTH * 2, height: HEIGHT * 2, preserveAspectRatio: 'none', style: 'image-rendering: pixelated' })) this.image.setAttribute(k, v);\n svg.append(this.image);\n }\n snapshot(e) { return e; }\n apply() {}\n prompts() {\n const e = this.engine, frame = paint(e.mem, e.title.chip, this.chargen, this.vic, e.title.splits);\n const ctx = this.canvas.getContext('2d'), pixels = ctx.createImageData(WIDTH, HEIGHT);\n for (let i = 0; i < frame.length; i++) { const [r, g, b] = PALETTE[frame[i]]; pixels.data.set([r, g, b, 255], i * 4); }\n ctx.putImageData(pixels, 0, 0);\n // and the border's colour on either side, where the page is wider than the frame\n this.svg.style.background = `rgb(${PALETTE[frame[0]].join(',')})`;\n this.image.setAttribute('href', this.canvas.toDataURL());\n }\n}\n", "import { paint as m } from '@moonbase-machines/c64';\nexport const { paint } = m;", "// The view of a card toolkit title (card.js): the screen as the remake's memory holds\n// it, the hi-res page the soft switches show, or the text screen, painted dot for dot as the\n// machine's page paints it (@moonbase-machines/apple2e/screen.js), 560 by 384. The toolkit's pictures are bitmaps,\n// and this is them as they are; drawing them sharper is for later.\n//\n// `inset` (a title's, its title.js), when set on: the screen's band at the top, where it is (its rows above\n// `top` all white), its dots `move` moved `by`, to make room for a mini view; `banded`, whether the band was there\n// at the last painting.\nimport { paintHires, paintText } from '@moonbase-machines/apple2e/screen.js';\n\nconst NS = 'http://www.w3.org/2000/svg';\n\nexport class CardView {\n constructor(svg, { engine, inset = null }) {\n this.svg = svg; this.engine = engine; this.inset = inset; this.insetOn = false; this.banded = false;\n svg.setAttribute('viewBox', '0 0 560 384');\n this.canvas = document.createElement('canvas'); this.canvas.width = 560; this.canvas.height = 384;\n this.image = document.createElementNS(NS, 'image');\n for (const [k, v] of Object.entries({ x: 0, y: 0, width: 560, height: 384, preserveAspectRatio: 'none', style: 'image-rendering: pixelated' })) this.image.setAttribute(k, v);\n svg.append(this.image);\n }\n snapshot(e) { return e; }\n apply() {}\n // the screen, when a run has gone as far as it goes\n prompts() {\n const mem = this.engine.mem, s = this.engine.title.screen, ctx = this.canvas.getContext('2d');\n const pixels = ctx.createImageData(560, 384);\n if (s.text) paintText(pixels.data, mem, mem, false, [0, 24]);\n else {\n const page = s.page2 ? 0x4000 : 0x2000;\n paintHires(pixels.data, mem.subarray(page, page + 0x2000));\n if (s.mixed) paintText(pixels.data, mem, mem, false, [20, 24]);\n }\n this.banded = this.insetOn && !!this.inset && band(pixels.data, this.inset);\n if (this.banded) shift(pixels.data, this.inset);\n ctx.putImageData(pixels, 0, 0);\n this.image.setAttribute('href', this.canvas.toDataURL());\n }\n}\n\n// (whether the band is on the screen: its rows above `top` white, the whole width)\nfunction band(px, { top }) {\n for (let y = 0; y < top; y++) for (let x = 0; x < 560; x++) { const i = (y * 560 + x) * 4; if (px[i] < 200 || px[i + 1] < 200 || px[i + 2] < 200) return false; }\n return true;\n}\n// (the band's rows `top` to `bottom`: the dots `move` moved `by`, white where they were)\nfunction shift(px, { top, bottom, move: [from, to], by }) {\n for (let y = top; y <= bottom; y++) {\n const row = y * 560 * 4;\n px.copyWithin(row + (from + by) * 4, row + from * 4, row + to * 4);\n if (by < 0) px.fill(255, row + (to + by) * 4, row + to * 4); else px.fill(255, row + from * 4, row + (from + by) * 4);\n }\n}\n", "// The routines of a card title, for the remake engine, as its title.js `map` names them (cards.js):\n// what each step of a script does. The toolkit's own code is lifted into scripts too, the\n// libraries beside the scenes, and a step that is one of its entries runs that code inside\n// itself, so that only the step is in the transcript, as the original's observer sees only the\n// call. What cannot be a script is here: the routines that take their data inline (fill, copy\n// and print), Applesoft's and the Monitor's routines in ROM (@moonbase-machines/apple2e/rom.js), ProDOS's calls\n// (@moonbase-machines/apple2e/mli.js), and the keyboard and the soft switches. The screen is the hi-res pages in the\n// engine's own memory, $2000 and $4000, written byte for byte as the original writes them.\nimport { describe, result, TAKES, GIVES } from './events.js';\nimport { INLINE, sectionName } from './cards.js';\nimport { Files, BLOCK, CLOCK } from '@moonbase-machines/apple2e/mli.js';\nimport { install as installRom } from '@moonbase-machines/apple2e/rom.js';\nimport { install as installKernal, VIC, VECTORS, kernalByte, KEY_TABLES } from '@moonbase-machines/c64/kernal.js';\nimport { Drive } from '@moonbase-machines/c64/drive.js';\nimport { Printer, bus } from '@moonbase-machines/c64/printer.js';\nimport { Basic } from '@moonbase-machines/c64/basic.js';\nimport { BasicError } from '@moonbase-machines/c64/numbers.js';\nimport { install as installBasicRom, printError } from '@moonbase-machines/c64/basic-rom.js';\nimport { lift, script as scriptOf, readers } from './lift.js';\n\nconst hex4 = n => n.toString(16).toUpperCase().padStart(4, '0');\n\n// The inputs of a step: numbers for the registers it takes, the carry among them, or a\n// register's own name for what it holds already. A number is a load the lifter folded into the\n// step, and the load set the flags, which a routine may test before anything sets them again\n// ($74FA tests A's): they are set as A's load set them, or else as the last register's.\nfunction inputs(e, name, args) {\n const takes = TAKES[name] || '';\n let k = 0, loaded = null;\n for (const r of takes) {\n const v = args[k++];\n if (v === undefined || v === r || typeof v === 'object') continue;\n const n = v.startsWith('$') ? e.mem[parseInt(v.slice(1), 16)] : +v;\n if (r === 'c') e.c = n & 1; else { e[r] = n & 0xff; if (loaded !== 'a') loaded = r; }\n }\n if (loaded) e.flags(e[loaded]);\n return args.slice(k);\n}\n\nexport function cardRoutines(title) {\n const toolkit = title.map;\n const c64 = title.disk.kind === 'c64';\n const files = c64 ? null : title.files ??= new Files(title.disk);\n // the soft switches: what the screen shows\n const screen = title.screen ??= { text: 1, mixed: 0, page2: 0, hires: 0 };\n // the keyboard's latch, its high bit set until $C010 is read\n let latch = 0;\n\n // The I/O page. The keyboard is read as the machine counts its reads (@moonbase-machines/apple2e/machine.js), every\n // read of $C000 and every touch of $C010 with no key waiting, and two thousand in a run stop it\n // to wait for a key (Engine.polled): so the remake waits where the original's run stopped, and\n // a scene that animates while it polls has run as many frames.\n // The language card, $C080 to $C08F: which of its two 4K banks is at $D000, and whether the card\n // or the ROM is read there. The engine has one memory, so the bank not there is kept aside and\n // swapped in when it is switched to (Pieces of Eight keeps its descriptions in one and its map\n // in the other). The card's write-protect, and the ROM's own bytes, are not kept.\n const lc = { bank: 2, read: 0, aside: new Uint8Array(0x1000) };\n const bankTo = (e, bank) => {\n if (bank === lc.bank) return;\n const here = e.mem.slice(0xd000, 0xe000); e.mem.set(lc.aside, 0xd000); lc.aside = here; lc.bank = bank;\n };\n // The Commodore 64's I/O page, $D000 to $DFFF while the 6510's port at $01 shows it there (and\n // its RAM while not): the VIC's registers, the SID's, the colours, and the two CIAs. The games\n // read the first CIA's timer and clock for their random numbers, which are the seed, as the\n // observer makes them (the pilots' observer); its keyboard and joystick lines read nothing\n // held, since the keys come through GETIN.\n const chip = title.chip = new Uint8Array(0x1000); // (the view paints from it: @moonbase-machines/c64/paint.js)\n const SEEDED = { 4: s => s & 0xff, 5: s => s >> 8 & 0xff, 8: s => (s * 7) & 0xff, 9: s => (s * 13) & 0xff };\n function io64(e, at, v) {\n const r = at & 0xfff;\n if (r < 0x400) { // the VIC, its 64 registers again every 64\n const reg = r & 0x3f;\n // the raster line, which a game waits on (Feeding Time for line 256, Petra's Dream for $D011's\n // top bit) and takes random numbers from with the CIA's: a line on at each read of $D012 or\n // $D011, whose top bit is its ninth, as the observer makes them (the pilots' observer), so\n // that both sides read the same. On the page's clock (`e.clock`), the line the original's\n // time has reached, 63 cycles each, so that a wait for one takes the time it took.\n if (v === undefined && (reg === 0x11 || reg === 0x12)) {\n e.raster = e.clock ? Math.floor(e.cycles / 63) % 312 : ((e.raster ?? 0) + 1) % 312;\n return reg === 0x12 ? e.raster & 0xff : (chip[0x11] & 0x7f) | (e.raster >> 1 & 0x80);\n }\n // which interrupt it is ($D019): the raster's, or none of the VIC's (the CIA's timer)\n if (v === undefined && reg === 0x19) return e.vicFlags ?? 0x70;\n if (v === undefined) return chip[reg];\n chip[reg] = v;\n // a raster interrupt's writes, kept by its line for the view (@moonbase-machines/c64/paint.js), until the\n // raster interrupt is turned off\n // (on the page's clock, the last whole frame's: a frame's writes are kept apart until its\n // raster comes round, routines.before, so that none lingers from a screen before)\n if (e.splitLine !== undefined && reg !== 0x19) { const s = e.clock ? (e.clock.splits ??= new Map()) : (title.splits ??= new Map()); (s.get(e.splitLine) ?? s.set(e.splitLine, new Map()).get(e.splitLine)).set(reg, v); }\n if (reg === 0x1a && !(v & 1)) title.splits?.clear();\n return;\n }\n if (r < 0x800) { const reg = 0x400 | (r & 0x1f); if (v === undefined) return chip[reg]; chip[reg] = v; e.sid?.push([e.cycles, r & 0x1f, v]); return; } // the SID\n if (r < 0xc00) { if (v === undefined) return chip[r] | 0xf0; chip[r] = v & 15; return; } // the colours\n if (r < 0xd00) { // CIA 1\n const reg = r & 15;\n if (v === undefined) return SEEDED[reg] ? SEEDED[reg](title.seed ?? 0x11) : reg < 2 ? 0xff : reg === 0x0d ? 0 : chip[0xc00 | reg];\n chip[0xc00 | reg] = v; return;\n }\n if (v === undefined) return chip[r]; chip[r] = v; // CIA 2, its first port the VIC's bank\n // (a raster interrupt's change of the bank kept with its line too, as $100: a map in a\n // bitmap above, text below, Goldfields' horse ride)\n if ((r & 15) === 0 && e.splitLine !== undefined) { const s = e.clock ? (e.clock.splits ??= new Map()) : (title.splits ??= new Map()); (s.get(e.splitLine) ?? s.set(e.splitLine, new Map()).get(e.splitLine)).set(0x100, v); }\n }\n const ioShown = e => (e.mem[1] & 3) !== 0 && (e.mem[1] & 4) !== 0;\n function io(e, at, v) {\n if (c64 && at >= 0xe000) { if (v === undefined) return kernalByte(at); e.mem[at] = v; return; } // the KERNAL's keyboard tables, RAM under them written\n if (c64) return io64(e, at, v);\n if ((at & 0xfff0) === 0xc080) { const b = at & 15; bankTo(e, b & 8 ? 1 : 2); lc.read = (b & 1) === ((b >> 1) & 1) ? 1 : 0; return 0; }\n if (at >= 0xc050 && at <= 0xc057) { const s = ['text', 'mixed', 'page2', 'hires'][(at - 0xc050) >> 1]; screen[s] = at & 1; return 0; }\n if (at === 0xc000 && v === undefined) {\n // (none, -1, read here and not at a tick, is no key, as on the original, where it is pressed as nothing)\n if (!(latch & 0x80)) { const k = e.key(); if (k !== undefined && k >= 0) latch = k | 0x80; }\n if (++e.idle > 2000) e.polled = true;\n return latch;\n }\n if (at === 0xc010) { const r = latch; if (!(latch & 0x80) && ++e.idle > 2000) e.polled = true; latch &= 0x7f; return r; }\n // the speaker, a click at the cycle it came (Engine.time)\n if (at === 0xc030) { e.clicks.push(e.cycles); return 0; }\n return 0;\n }\n\n // Applesoft's and the Monitor's routines, as the machine has them (@moonbase-machines/apple2e/rom.js), on a stand-in\n // for its processor that reads and writes the engine's memory\n let engine = null;\n const cpu = { hooks: new Map(), cycles: 0, a: 0, x: 0, y: 0, z: 0, c: 0, n: 0, v: 0, read: a => engine.mem[a], write: (a, v) => { engine.mem[a] = v & 0xff; }, nz(v) { this.n = v >> 7 & 1; this.z = v ? 0 : 1; } };\n // the bell's clicks, at their cycles from the routine's start, the engine's then (`romFrom`)\n let romFrom = 0;\n if (c64) installKernal({ cpu, read: a => engine.read(a), write: (a, v) => engine.write(a, v), drive: title.bus ??= bus(title.drive ??= new Drive(Uint8Array.from(atob(title.disk.image), ch => ch.charCodeAt(0))), title.printer ??= new Printer({ on: false })), // (the drive and a printer, device 4, on the bus: @moonbase-machines/c64/printer.js)\n // (a key let go before any scan saw it is seen once, as a tap)\n held: () => { const h = engine?.clock?.held; if (h?.up) engine.clock.held = null; if (h) h.seen = true; return h ?? null; },\n call: at => { runNow(engine, at, 'the keyboard read'); Object.assign(cpu, { a: engine.a, x: engine.x, y: engine.y, c: engine.c, z: engine.z, n: engine.n, v: engine.v }); },\n loaded: (name, from, to) => { (title.files64 ??= []).push({ name, from, to }); const script = title.fileScripts?.[name]; if (script) { const l = { script, from, to }; loaded.splice(0, Infinity, ...loaded.filter(k => k.from < l.from || k.to > l.to), l); } } });\n else installRom({ cpu, game: title.disk, sw: { lcRead: 0 }, io: a => io(engine, a), file: n => files.file(n), get files() { return files.files; }, put: (path, f) => files.put(path, f), remove: path => files.remove(path), clicks: { push: c => engine.clicks.push(engine.cycles + c - romFrom) }, log() {}, halted: false });\n const rom = (e, at) => {\n const f = cpu.hooks.get(at);\n // a Commodore 64's BASIC, which MENU runs NOTEBOOK (compiled BASIC) and ZOOTIME (BASIC) with\n if (!f && c64 && at >= 0xa000 && at < 0xc000) throw new Error('a BASIC program (Zoopak\\'s NOTEBOOK or ZOOTIME): not written yet in the remake');\n if (!f) throw new Error('no ROM routine at $' + hex4(at));\n engine = e;\n Object.assign(cpu, { a: e.a, x: e.x, y: e.y, c: e.c, z: e.z, n: e.n, v: e.v });\n // a routine that reads the keyboard (RDKEY) waits, with no key, and the step runs again\n const start = romFrom = cpu.cycles;\n const r = f(cpu);\n if (r === 'wait') return 'wait';\n // the time a routine takes, which the original took: the Monitor's WAIT counts out\n // (26 + 27A + 5A\u00B2) / 2 cycles, and the bell its 192 clicks\n // and its RTS, as the machine's hook takes it\n e.delay += (cpu.cycles - start + 6) / CLOCK * 1000; e.cycles += cpu.cycles - start + 6;\n Object.assign(e, { a: cpu.a & 0xff, x: cpu.x & 0xff, y: cpu.y & 0xff, c: cpu.c, z: cpu.z, n: cpu.n });\n if (r === 'return') return r; // (a routine that returns from its caller too: $E206 at a statement's end)\n };\n\n // Where an address of the lifted code is: a label in a script. The scenes all run at $AD00,\n // and PETPUZZLE is read over SCHOOL's end, so where scripts share an address the script is the\n // file read over it last (`loaded`, each ProDOS read of a script's file, its first and last\n // address, the newest last).\n const loaded = [];\n let index = null;\n // the scripts with a label at an address\n const labelled = (e, at) => {\n if (!index) {\n index = new Map();\n for (const name of Object.keys(e.sources)) {\n const p = e.script(name);\n for (const l of Object.keys(p.labels)) if (/^L[0-9A-F]{4}$/.test(l)) { const a = parseInt(l.slice(1), 16); (index.get(a) ?? index.set(a, []).get(a)).push(name); }\n }\n }\n return index.get(at) ?? [];\n };\n // Code a scene's lift missed, reached through a table or a vector its walk could not follow: on\n // a Commodore 64, lifted at need from the file's bytes in memory where it was loaded, with the\n // same lifter (lift.js), and said, so that the entry goes into the scene's lift.\n const atNeed = (e, at) => {\n // (or code no file put there, which a file's own code made: Goldfields' TITLE unpacks its\n // picture and code to $8000 and jumps to $7F40; from the RAM below BASIC's ROM)\n const f = title.files64?.findLast(f => f.from <= at && at <= f.to) ?? (at >= 0x0200 && at < 0xa000 ? { name: 'MEMORY', from: 0x0200, to: 0x9fff } : null);\n if (!f) return null;\n const bytes = e.mem.slice(f.from, f.to + 1), name = (title.fileScripts?.[f.name] ?? f.name) + '@' + hex4(at);\n const lifted = lift(bytes, f.from, [at], toolkit.routines, new Set(), readers(INLINE));\n e.sources[name] = scriptOf(lifted, bytes, f.from, { selfModified: true });\n index = null;\n loaded.push({ script: name, from: f.from, to: f.to });\n (title.liftedAtNeed ??= []).push(f.name + ' $' + hex4(at));\n console.warn(`lifted at need: ${f.name} from $${hex4(at)} (an entry for its scene's lift)`);\n return name;\n };\n // (on a Commodore 64, a file's scene only while that file is what is loaded there: Goldfields'\n // CODE is at $8018 when the boot calls it, and TEXT/CODE, loaded over it later, has a label there)\n const fileScripts = new Set(Object.values(title.fileScripts ?? {}));\n const present = (names, at) => !c64 ? names : names.filter(n => !fileScripts.has(n) || loaded.some(l => l.script === n && l.from <= at && at <= l.to));\n const find = (e, at) => {\n let names = present(labelled(e, at), at);\n if (!names.length && c64 && atNeed(e, at)) names = present(labelled(e, at), at);\n const over = loaded.findLast(l => names.includes(l.script) && l.from <= at && at <= l.to);\n const name = names.length > 1 ? over?.script : names[0];\n if (!name) throw new Error('no script has $' + hex4(at));\n return [name, 'L' + hex4(at)];\n };\n // an address the ROM's routine answers: above $D000, unless the card is read there and a script\n // has its code there (Pieces of Eight's PO8:BLINK, over HPOSN and DRAW); on a Commodore 64, where\n // the 6510's port shows the KERNAL ($E000 on) or BASIC ($A000 to $BFFF: Tell-A-Tale's numbers,\n // over MENU's code in the RAM under it)\n const romAt = (e, a) => c64 ? (a >= 0xe000 ? (e.mem[1] & 2) !== 0 : a >= 0xa000 && a < 0xc000 ? (e.mem[1] & 3) === 3 : a === 0x73 || a === 0x79) : a >= 0xd000 && !(lc.read && labelled(e, a).length);\n // the stir of START.SYSTEM's wait: its calls are no steps\n const stirring = step => toolkit.stir && step?.at >= toolkit.stir.from && step.at <= toolkit.stir.to;\n const emit = (e, ev, quiet) => { if (quiet) e.inside++; e.emit(ev); if (quiet) e.inside--; };\n\n // a return, as the engine's: to the caller, and out of a routine run inside a step\n const back = x => { const f = x.stack.pop(); if (f.name !== x.name) x.enter(f.name); x.pc = f.pc; if (f.inside) { x.inside--; f.done?.(x); } f.after?.(x); };\n // the town's loop, the restart and escape (into LIB4's screens) are the game going on, and run\n // as it, with no return\n const through = new Set(['town', 'restart', 'escape']);\n // The data a step takes inline, read from memory after its call as the original reads it,\n // since a scene may write into it (the name, into the text LIB.VARS prints); the script's own\n // words are what the file held, for a step with no address\n const inline = (e, step, n, args) => {\n if (step?.at == null) return args.map(h => parseInt(h, 16));\n const b = []; for (let i = 0; i < n; i++) b.push(e.mem[(step.at + 3 + i) & 0xffff]); return b;\n };\n const words = b => b.map(v => v.toString(16)).join(' ');\n // an event without where in memory its data is, for a title whose strings are not where the\n // original's are (its map's `unplaced`: Goldfields' SETNAM, its name in BASIC's strings)\n const unplaced = ev => { if (toolkit.unplaced?.includes(ev.step)) { delete ev.x; delete ev.y; } return ev; };\n // a step of the original's ROM: its event, then the routine\n // The KERNAL's calls that go through a vector in RAM, as the KERNAL's jump table does (JMP\n // ($0326) for CHROUT): where the game has pointed one at a routine of its own (Zoopak's MENU\n // draws its text into its bitmap), that routine runs, its lifted code inside the step.\n // (Not LOAD's: the emulator answers LOAD at $F49E, past its vector, as the 1541 does in\n // @moonbase-machines/c64/drive.js, so MENU's fast loader, which talks to a drive's own processor over the\n // serial lines, is set up and never run; the remake does the same.)\n const VECTORED = { chrout: [0x326, 0xf1ca], chrin: [0x324, 0xf157], getin: [0x32a, 0xf13e], save: [0x332, 0xf5ed] };\n const inRom = (name, at) => (e, args, step) => {\n inputs(e, name, args); emit(e, unplaced(describe(name, [], e, undefined, undefined, a => e.mem[a])), stirring(step));\n const v = c64 && VECTORED[name], to = v && (e.mem[v[0]] | e.mem[v[0] + 1] << 8);\n if (v && to !== v[1]) { const [script, label] = find(e, to); e.callInside(script, label, x => { if (GIVES[name]) x.emit(result(name, { a: x.a, x: x.x, y: x.y, c: x.c })); }, step?.at == null ? undefined : (step.at + 2) & 0xffff); return; }\n if (rom(e, at) === 'wait') return 'wait';\n if (GIVES[name] && c64) e.emit(result(name, { a: e.a, x: e.x, y: e.y, c: e.c }));\n };\n\n const routines = {\n // fill, copy, print and say, which take their data inline after the call, run their lifted\n // code as the other entries do: the call's frame gives the code its return address to read\n // the data from, and the code returns past it (Engine.pull, Engine.ret)\n // ProDOS: the call and its parameters' address inline; a read of a script's file is noted,\n // where it went, for the scripts that share addresses\n prodos: (e, args, step) => {\n const b = inline(e, step, 3, args), [cmd, lo, hi] = b, params = lo | hi << 8;\n emit(e, describe('prodos', [], e, words(b)), stirring(step));\n const mem = { read: a => e.mem[a], write: (a, v) => { e.mem[a] = v & 0xff; } };\n if (cmd === 0xca) {\n const ref = e.mem[params + 1], o = files.open.get(ref), to = e.mem[params + 2] | e.mem[params + 3] << 8;\n const n = o ? Math.min(e.mem[params + 4] | e.mem[params + 5] << 8, o.f.body.length - o.at) : 0;\n const script = o && title.fileScripts?.[sectionName(toolkit, a => e.mem[a], o.f.path, o.at)];\n if (script && n) {\n const l = { script, from: to, to: to + n - 1 };\n loaded.splice(0, Infinity, ...loaded.filter(k => k.from < l.from || k.to > l.to), l);\n }\n // a disk's time for the blocks read\n e.delay += Math.ceil(n / 512) * BLOCK / CLOCK * 1000;\n }\n let err = files.call(cmd, params, mem);\n e.cycles += 6; // the RTS, as the machine's hook at $BF00 takes it\n if (err === null) err = 1;\n e.a = err === 'quit' ? 0 : err; e.c = e.a ? 1 : 0; e.z = e.a ? 0 : 1;\n if (err === 'quit') e.ended = true;\n },\n // START.SYSTEM's stirring wait is over: the counts it leaves are the seed, as on the original\n stirred: e => { for (const a of toolkit.stir.counts) e.mem[a] = title.seed & 0xff; },\n hposn: inRom('hposn', 0xf411), hlin: inRom('hlin', 0xf53a), hcolor: inRom('hcolor', 0xf6f0), 'clear-page': inRom('clear-page', 0xf3f4),\n pause: inRom('pause', 0xfca8), home: inRom('home', 0xfc58), outport: inRom('outport', 0xfe95),\n // a call or a jump to an address outside the script: into the lifted code where it is, or\n // into the ROM\n 'call-engine': (e, [at], step) => {\n const a = parseInt(at.slice(1), 16);\n if (romAt(e, a)) { const r = rom(e, a); if (r === 'return') { back(e); return; } return r; }\n // (code the game has made a bare RTS since: back at once, the RTS's time taken, as\n // Detect-A-Pet's room hook at $AD03, which it sets to RTS in most rooms)\n if (!c64 && e.mem[a] === 0x60) { e.cycles += 6; return; }\n const [name, label] = find(e, a);\n e.stack.push({ name: e.name, pc: e.pc, ret: step?.at == null ? undefined : (step.at + 2) & 0xffff }); e.enter(name, label);\n },\n // a jump to one of the toolkit's entries is that step: the town's loop and the restart, which\n // never come back\n 'goto-engine': (e, [at], step) => {\n const a = parseInt(at.slice(1), 16), entry = toolkit.routines[a];\n if (entry) {\n if (through.has(entry)) return routines[entry](e, [], step);\n // a jump to a routine that comes back: it returns for the code that jumped, to its caller\n // (the ROM's SYS, on a Commodore 64, which makes it the ROM's call, and no event)\n const quiet = c64 && e.stack.at(-1)?.rom;\n if (quiet) e.inside++;\n let r; try { r = routines[entry](e, [], step); } finally { if (quiet) e.inside--; }\n const f = e.stack.at(-1);\n if (f?.inside) { const done = f.done; f.done = x => { done?.(x); back(x); }; } else back(e);\n return r;\n }\n if (romAt(e, a)) {\n if (rom(e, a) === 'wait') return 'wait';\n if (c64 && ENDS.has(a)) pullRegisters(e); // the end of an interrupt: the registers back, then its RTI\n back(e); return; // as its RTS: out of a routine it ends\n }\n e.enter(...find(e, a));\n },\n };\n\n // A Commodore 64 title's BASIC (Goldfields: its boot, GOLDFIELDS, BASIC's text, and its game,\n // GAME, Blitz!'s code), compiled to scripts whose steps the library in @moonbase-machines/c64/basic.js does,\n // the engine's `basic`. SYS runs the machine code at its address, with BASIC's text pointer\n // ($7A) at the text after it and the registers from $030C, as the ROM's SYS does; the machine\n // code reads its parameters from that text with the ROM's routines, which are answered here\n // from the parameters' expressions, compiled with the program (`params`).\n if (c64 && title.basic) {\n routines.sys = (e, at, text, step) => {\n e.mem[0x7a] = text & 0xff; e.mem[0x7b] = text >> 8;\n const m = e.mem; Object.assign(e, { a: m[0x30c], x: m[0x30d], y: m[0x30e], c: m[0x30f] & 1, z: m[0x30f] >> 1 & 1, n: m[0x30f] >> 7 });\n // and as it returns, the registers kept at $030C, as the ROM's SYS keeps them (Goldfields'\n // map reads where the digger may go from them, C = PEEK(780))\n const keep = x => { m[0x30c] = x.a; m[0x30d] = x.x; m[0x30e] = x.y; m[0x30f] = x.c | x.z << 1 | (x.i ?? 0) << 2 | (x.d ?? 0) << 3 | x.v << 6 | x.n << 7; };\n if (romAt(e, at)) { const r = rom(e, at); keep(e); return r; }\n // (the frame is the ROM's SYS, as the machine code's return address is: a jump from the\n // code to the KERNAL is the ROM's call then, as the observer sees it)\n const [name, label] = find(e, at);\n e.stack.push({ name: e.name, pc: e.pc, rom: true, after: keep }); e.enter(name, label);\n };\n // the boot's LOAD: the file, as BASIC loads it from a program, which then runs again from its\n // start with its variables kept; or, for a BASIC program loaded over it (GAME, at $0801),\n // that program from its start\n routines['basic-load'] = (e, [name, device = 1, sa = 0]) => {\n const m = e.mem; for (let k = 0; k < name.length; k++) m[0x200 + k] = name.charCodeAt(k);\n Object.assign(m, { 0xb7: name.length, 0xbb: 0x00, 0xbc: 0x02, 0xba: device, 0xb9: sa, 0xb8: 0 });\n Object.assign(e, { a: 0, x: 0x01, y: 0x08 });\n e.basic.call('load');\n const program = Object.entries(title.basic).find(([, p]) => p.file === name);\n if (sa === 0 && program) { startBasic(e, program[0]); e.enter(program[0]); return; }\n e.pc = 0;\n };\n // BASIC's routines the machine code reads its parameters with, and the rest it calls\n // (@moonbase-machines/c64/basic-rom.js), the parameters' values from the expressions compiled with the program\n installBasicRom({ cpu, read: a => engine.read(a), write: (a, v) => engine.write(a, v),\n evaluate: at => {\n const p = engine.sources[engine.basic.script]?.params?.[at];\n if (!p) throw new Error('no parameter compiled at $' + hex4(at));\n const [end, f, place] = p;\n return { value: f(engine.basic), end, place };\n } });\n }\n // A BASIC error, as the ROM's routine gives it ($A43A, through the vector at $0300 Goldfields\n // leaves the ROM's): the output back to the screen, a new line, ? and the message, ERROR, IN and\n // the \"line\", which for Blitz!'s code is its program counter at the instruction that failed,\n // then READY.; the program is over. Its output is the ROM's, through CHROUT, and no events.\n if (c64 && title.basic) routines.error = (e, err) => {\n if (!(err instanceof BasicError) || !e.basic) return false;\n engine = e;\n return printError({ cpu, write: (a, v) => { e.mem[a] = v; } }, err.message, e.basic.at);\n };\n const startBasic = (e, name) => { e.basic = new Basic(e, title.basic[name]); e.basic.script = name; };\n // every other entry of the toolkit runs its lifted code inside its step\n for (const [at, name] of Object.entries(toolkit.routines).map(([a, n]) => [+a, n])) {\n // a routine of the ROM's, above $D000, is its step in @moonbase-machines/apple2e/rom.js\n if (!routines[name] && at >= 0xd000) routines[name] = inRom(name, at);\n if (routines[name] || at >= 0xbf00) continue;\n routines[name] = (e, args, step) => {\n inputs(e, name, args);\n // the game going on from inside a routine (Escape read by the key reader): what it was\n // inside is the game's own code now, as the observer's count of calls starts again, and\n // the returns still to come give nothing\n if (through.has(name) && e.inside) { for (const f of e.stack) if (f.inside) { delete f.inside; delete f.done; } e.inside = 0; }\n // its code where the call goes, when another of the same name is elsewhere (LIB4 says its\n // messages by its own $8046, the scenes by LIB2's $144B, a JMP to $1C11): the operand of\n // the call, or else the first of that name\n const to = step?.at != null ? e.mem[(step.at + 1) & 0xffff] | e.mem[(step.at + 2) & 0xffff] << 8 : null;\n const quiet = stirring(step), entry = toolkit.routines[to] === name ? to : parseInt(Object.entries(toolkit.routines).find(([, n]) => n === name)[0]);\n if (name === 'read-key') { e.mem[toolkit.seed] = title.seed & 0xff; e.mem[toolkit.seed + 1] = title.seed >> 8; }\n // the data after the call, as the observer reads it (cards.js)\n const data = INLINE[name] && step?.at != null ? INLINE[name](a => e.mem[a & 0xffff], step.at + 3).value : undefined;\n emit(e, describe(name, [], { a: e.a, x: e.x, y: e.y, c: e.c }, data, undefined, a => e.mem[a]), quiet);\n const [script, label] = find(e, entry);\n // (escape is called, as the original's JSR: LIB4 keeps the stack with its return (TSX at\n // $8E63), and Return to present game goes back through it to where Escape was read)\n if (name === 'escape' && step?.at != null) e.stack.push({ name: e.name, pc: e.pc, ret: (step.at + 2) & 0xffff });\n if (through.has(name)) { e.enter(script, label); e.entered = entry; return; }\n // the key reader's counts of its wait are the seed again as it returns, as on the original\n const seed = x => { x.mem[toolkit.seed] = title.seed & 0xff; x.mem[toolkit.seed + 1] = title.seed >> 8; };\n e.callInside(script, label, x => { if (name === 'read-key') seed(x); if (GIVES[name] && !quiet) x.emit(result(name, { a: x.a, x: x.x, y: x.y, c: x.c })); }, step?.at == null ? undefined : (step.at + 2) & 0xffff);\n };\n }\n // A call or a jump to a label of the script's own that a file read since covers with another\n // script's code: SCHOOL's $B670 on, once PETPUZZLE is read there\n routines.elsewhere = (e, label) => {\n const at = parseInt(label.slice(1), 16), over = loaded.findLast(l => l.from <= at && at <= l.to);\n return over !== undefined && over.script !== e.name && /^L[0-9A-F]{4}$/.test(label);\n };\n // A tick (its map's `ticks`): before the scene's read of the keyboard, the run stops for a key\n // or none (-1), and the read takes it.\n // the original's code is in memory where its lines came from: the engine counts their time\n routines.timed = true;\n // how many polls with no key are a wait (its map's `polls`; a pilot's route can set the\n // engine's own, `e.polls`, for a stretch of keys: the pilots' `pollsAt`)\n routines.polls = toolkit.polls;\n routines.reads = toolkit.reads; // and how many reads of the clock are a tick of it (basic.js `ti`)\n // GETIN on the Commodore 64: the key pressed, or none; called without end while the game waits,\n // so many in a row with no key is the wait, as the observer counts them (the pilots' observer).\n // The KERNAL's buffer first, where the interrupt puts a key it holds down (MENU's), then the\n // page's keys.\n if (c64) routines.getin = e => {\n if (!e.clock && !e.i) { routines.poll(e); e.polledSince = true; }\n let k;\n if (e.mem[0xc6]) { k = e.mem[0x277]; e.mem.copyWithin(0x277, 0x278, 0x277 + e.mem[0xc6]); e.mem[0xc6]--; } else k = e.key();\n e.c = 0;\n if (k === undefined || k < 0) { e.a = e.flags(0); if (++e.idle > (e.polls ?? toolkit.polls ?? 200) && !e.clock) e.polled = true; return; }\n e.a = e.flags(k); e.idle = 0; e.emit(result('getin', { a: k }));\n // (on the page's clock the game runs on as the original did, waiting or not)\n };\n // The Commodore 64's interrupt, through $0314 sixty times a second: the KERNAL's own (the clock),\n // or a game's, which does what the game shows in time (Petra's Dream cycles its flames' colour\n // and plays its sounds; MENU's, which it goes on to, flips its title's two screens and reads the\n // joystick) and goes on to the KERNAL's end of an interrupt, its RTI, where the registers and\n // flags come back. The remake keeps no time of the machine's: it takes one at each call of GETIN,\n // as the observer has the original take it (the pilots' observer), and then the VIC's raster\n // interrupt, where the game has turned it on ($D01A), at the line it set (Find Me's split of its\n // screen into two character sets), $D019 saying which it is. On the page's clock (\n // scenes.js sets `e.clock`), each is taken as the original's chips took it: the CIA's every 16,421\n // cycles of the original's time, the raster's when its line comes (routines.before). Not while\n // the game has them masked (SEI). The routine starts as the KERNAL's own entry ($FF48) leaves\n // it, with A, X and Y pushed, and the KERNAL's end ($EA31, $EA7B, $EA7E, $EA81), or its own PLAs\n // and RTI, pulls them.\n const ENDS = new Set([0xea31, 0xea7b, 0xea7e, 0xea81]);\n // a poll's interrupts, as the observer takes them: the CIA's, then the raster's where it is on\n routines.poll = e => { routines.interrupt(e); if (chip[0x1a] & 1) routines.interrupt(e, true); };\n const pullRegisters = e => {\n for (const r of ['y', 'x', 'a']) { const f = e.stack.pop(); if (f?.a === undefined || f.name !== undefined) throw new Error('the end of an interrupt with its registers not on the stack'); e[r] = f.a; }\n };\n if (c64) routines.interrupt = (e, raster = false) => {\n if (e.i) return;\n const to = e.mem[0x314] | e.mem[0x315] << 8, kept = { a: e.a, x: e.x, y: e.y, n: e.n, z: e.z, c: e.c, v: e.v, d: e.d };\n e.vicFlags = raster ? 0xf1 : 0x70;\n if (raster) e.splitLine = chip[0x12] | (chip[0x11] & 0x80) << 1;\n try {\n if (romAt(e, to)) rom(e, to); // the KERNAL's own routine ($EA31, or past its clock, $EA34)\n else { e.i = 1; runNow(e, to, 'the interrupt routine', x => x.stack.push({ a: kept.a }, { a: kept.x }, { a: kept.y })); }\n } finally { Object.assign(e, kept); e.i = 0; e.vicFlags = e.splitLine = undefined; }\n };\n // the game's code at an address run now to its return, inside whatever is running: the\n // interrupt's routine, or one the KERNAL calls through a vector\n function runNow(e, at, what, then) {\n let over = false;\n e.callInside(...find(e, at), () => { over = true; });\n then?.(e);\n for (let n = 0; !over; n++) {\n if (n > 1e6) throw new Error(what + ' at $' + hex4(at) + ' runs on without end');\n if (e.exec(e.program.steps[e.pc]) === 'wait') throw new Error(what + ' at $' + hex4(at) + ' waits');\n }\n }\n // the length of the data after a step's call, the lifted lines leave out (Engine.cost)\n routines.inline = (e, step) => INLINE[step.words[0]] ? INLINE[step.words[0]](a => e.mem[a & 0xffff], step.at + 3).length : 0;\n // And a routine of the title's, reached by a jump or a branch with nothing running (Pieces of\n // Eight jumps to its description routine, $0A59): its step, as the observer's hook makes it\n // wherever the routine is reached from, and the frame on top, the caller of the code that\n // jumped, which the routine returns through, ends it.\n routines.before = (e, step) => {\n if (c64 && e.clock && !e.i) {\n if (e.cycles >= e.clock.irq) { e.clock.irq = Math.max(e.clock.irq + 16421, e.cycles); routines.interrupt(e); }\n // the raster's, when the line it waits for has come since the last step\n const line = Math.floor(e.cycles / 63) % 312, last = e.clock.line ?? line, target = chip[0x12] | (chip[0x11] & 0x80) << 1;\n e.clock.line = line;\n if (line < last) { title.splits = e.clock.splits ?? new Map(); e.clock.splits = new Map(); } // a frame round: its splits the view's\n if (chip[0x1a] & 1 && (last <= line ? last < target && target <= line : target > last || target <= line)) routines.interrupt(e, true);\n }\n // (the town's, the restart's and escape's own steps go on into their code: not twice)\n const at = step.start ?? step.at, named = at != null && e.inside === 0 ? toolkit.routines[at] : undefined, own = e.entered === at;\n e.entered = null;\n if (named && !own && !stirring(step)) {\n emit(e, describe(named, [], { a: e.a, x: e.x, y: e.y, c: e.c }, undefined, undefined, a => e.mem[a]));\n const f = e.stack.at(-1);\n if (f?.name !== undefined && !f.inside) { f.inside = true; f.done = x => { if (GIVES[named]) x.emit(result(named, { a: x.a, x: x.x, y: x.y, c: x.c })); }; e.inside++; }\n }\n const t = toolkit.ticks?.find(t => t.at === step.at && e.name === title.fileScripts?.[t.scene]);\n if (!t) return;\n if (e.ticking === step) { e.ticking = null; if (e.keys[0] === -1) e.keys.shift(); return; }\n e.emit({ step: 'tick' }); e.ticking = step;\n return 'wait';\n };\n // before the start: the files the machine puts in memory itself (START.SYSTEM, where ProDOS\n // would have read it), the bytes it gives (MACHID), and the I/O page\n routines.setup = e => {\n // a Commodore 64 as it is when the game's boot program starts: the 6510's port showing the\n // ROMs and the I/O page, the VIC as the KERNAL set it up and its bank the first, the screen at\n // $0400 in light blue, device 8 and secondary address 1 the last used; and the boot loaded where it goes, over the stack\n if (c64) {\n // (the compiled scenes reach only the title's `io` through the hook: it must hold all this)\n if (!title.io || title.io[0] > 0xd000 || title.io[1] < KEY_TABLES[1] - 1) throw new Error('a Commodore 64 title\\'s io must cover $D000 to the KERNAL\\'s keyboard tables');\n e.ioAt = at => (at >= 0xd000 && at <= 0xdfff && ioShown(e)) || (at >= KEY_TABLES[0] && at < KEY_TABLES[1] && (e.mem[1] & 2) !== 0);\n Object.assign(e.mem, { 0: 0x2f, 1: 0x37, 0x99: 0, 0x9a: 3, 0xb9: 1, 0xba: 8, 0x288: 4, 0x286: 14 }); // (input from the keyboard, output to the screen; LOAD\"ZOOPAK\",8,1 left device 8, secondary address 1)\n // the keyboard as the KERNAL keeps it: no key down, the cursor not blinking, a buffer of ten,\n // the repeat's counts, and the decode's vector its own\n Object.assign(e.mem, { 0xc5: 0x40, 0xcb: 0x40, 0xcc: 1, 0x289: 10, 0x28a: 0, 0x28b: 4, 0x28c: 0x10, 0x28f: 0x48, 0x290: 0xeb });\n VIC.forEach((v, i) => { chip[i] = v; }); chip[0xd00] = 0x97;\n VECTORS.forEach((v, i) => { e.mem[0x314 + 2 * i] = v & 0xff; e.mem[0x315 + 2 * i] = v >> 8; }); // the KERNAL's own vectors\n for (let i = 0; i < 1000; i++) { e.mem[0x400 + i] = 0x20; chip[0x800 + i] = 14; }\n for (const [name, at] of Object.entries(title.load ?? {})) { const raw = title.drive.find(Uint8Array.from(name, ch => ch.charCodeAt(0))).raw; e.mem.set(raw.subarray(2), at); }\n e.io = (at, v) => io(e, at, v);\n // a program in BASIC starts from BASIC's READY, RUN typed: the cursor's blink as it was then\n if (title.basic) { Object.assign(e.mem, { 0xcd: 2, 0xce: 0x20, 0xcf: 0, 0x287: 0xfe }); startBasic(e, title.start); }\n return;\n }\n for (const [path, at] of Object.entries(title.load ?? {})) e.mem.set(files.file('/' + files.volumes[0] + '/' + path).body, at);\n // a DOS 3.3 disk: what its Applesoft program did, as the machine does it (@moonbase-machines/apple2e/machine.js boot):\n // each file loaded where the program puts it, the language card's bank as it says, then the\n // card read and written in bank 1, the screen cleared, the text window from row 16, and the\n // CALL; in the time the disk took\n if (title.disk.kind === 'dos33') {\n for (let r = 0; r < 24; r++) e.mem.fill(0xa0, 0x400 + (r & 7) * 0x80 + (r >> 3) * 40, 0x400 + (r & 7) * 0x80 + (r >> 3) * 40 + 40);\n for (const [name, at, bank] of title.disk.loads) {\n if (bank) bankTo(e, bank);\n e.mem.set(files.file(name).body, at);\n }\n bankTo(e, 1); lc.read = 1;\n Object.assign(e.mem, { 0x20: 0, 0x21: 40, 0x22: 16, 0x23: 24, 0x32: 0xff });\n e.delay = 2500;\n }\n e.io = (at, v) => io(e, at, v);\n };\n return routines;\n}\n", "// What a step is, as an event: the same words for the original, where the pilot's observer sees\n// the engine's routine called, and for the remake, where a script's step runs. Two runs are the\n// same when their events are.\n\n// the registers each routine takes, in order\nexport const TAKES = {\n box: 'axy', object: 'axy', 'object-keep': 'axy', 'object-mode': 'axy', objects: 'xy', span: 'axy', random: 'a', beep: 'a',\n 'key-at': 'axy', key: 'a', multiply: 'ax', divide: 'axy', ask: 'a', 'ask-mode': 'a', 'ask-escape': 'a', rectangle: 'axy', 'read-dot': 'xy',\n problem: 'a', dot: 'axy', 'fill-rows': 'axy', part: 'a', 'rectangle-outline': 'axy', 'key-panel': 'a', 'keep-span': 'xy',\n 'put-span': 'xy', 'white-lines': 'y', 'invert-span': 'xy',\n // Animal Rescue's problems: PROB1, the chimps' tree, a box by its letter\n label: 'a', 'flip-box': 'a', 'flash-box': 'a',\n // PROB2, the elephants: a mark on the path by its place, and a jump by how far it goes\n path: 'ax', jump: 'a',\n // PROB3, the parrots' food: a box of the grid by its column and row, what shows in it, and a pair\n cell: 'axy', 'cell-box': 'axy', pair: 'a',\n // PROB4, the puzzle box: a piece by its edges, where it goes, and its color in $11\n piece: 'axy',\n // Nature Park's PROB1, the colour pattern: a shape coloured in with a pen, the shape in $0E15\n colour: 'a',\n // PROB3, the truck: a turn of its loop, which gives the key down then, or 0\n tick: '',\n // Detect-A-Pet's card toolkit (its title's map): print takes its x in X and Y, its y in A, and\n // the carry for XDRAW; HPOSN its y in A and x in X and Y; HLIN its x in A and X and y in Y\n print: 'axyc', arrow: 'a', unpack: 'y', 'load-picture': 'a', 'action-cards': 'a', 'return-key': 'a', 'space-key': 'a',\n 'wipe-rows': 'a', 'wipe-columns': 'a', 'text-card': 'a', 'fill-left': 'a', 'put-object': 'axy', 'draw-room-objects': 'yc', take: 'y',\n drop: 'y', effect: 'a', outport: 'a', cout: 'a',\n // Pieces of Eight's text: a character at the cursor, a message by its number, and a room's\n // description from one of three tables\n char: 'a', message: 'xy', describe: 'axy',\n // the Commodore 64's KERNAL (Zoopak): a character out, the cursor's place, a file's number,\n // device and secondary address, its name, a load or save, and the serial bus's bytes\n chrout: 'a', plot: 'xyc', close: 'a', chkin: 'x', chkout: 'x', setlfs: 'axy', setnam: 'axy', load: 'axy', save: 'axy', listen: 'a', second: 'a', ciout: 'a', talk: 'a', tksa: 'a', setmsg: 'a', tone: 'xy', 'load-objects': 'axy', hposn: 'axy', hlin: 'axy', hcolor: 'x', pause: 'a', 'bag-put': 'a',\n};\n\n// the inputs some problems' routines take from their own memory, at fixed addresses\nconst MEMORY = { colour: { shape: 0x0e15 }, 'card-frame': { x: 0x4078, high: 0x4079, y: 0x407a, width: 0x407b, height: 0x407c } };\n\n// the inputs some routines take from the zero page rather than the registers: the line's ends\n// and color, and a rectangle's width and height\nconst ZERO = { line: { x0: 0x00, x1: 0x01, y0: 0x02, y1: 0x03, color: 0x11 }, piece: { color: 0x11 }, rectangle: { width: 0x0e, height: 0x0f }, 'rectangle-outline': { width: 0x0e, height: 0x0f } };\n\n// A step as an event: its name, any fixed input (a panel's number), the registers it takes,\n// the zero page inputs, read through `read`, and the data it had inline (a text, a picture's\n// name, a sound).\nexport function describe(name, fixed, regs, inline, read, peek) {\n const e = { step: name };\n if (fixed.length) e.n = fixed.map(Number);\n const takes = TAKES[name];\n if (name === 'objects') e.table = '$' + ((regs.x | regs.y << 8).toString(16).toUpperCase().padStart(4, '0'));\n // object 0 or 1 puts back the ground kept under an object, where it was: what is left in X and Y\n // then is whatever the steps before left there, and is no input\n else if (name.startsWith('object') && regs.a < 2) e.a = regs.a;\n else if (takes) for (const r of takes) e[r] = regs[r];\n if ((name === 'key-at' || name === 'key') && e.a !== undefined) e.a = String.fromCharCode(e.a & 0x7f);\n if (ZERO[name] && read) for (const [k, at] of Object.entries(ZERO[name])) e[k] = read(at);\n if (MEMORY[name] && peek) for (const [k, at] of Object.entries(MEMORY[name])) e[k] = peek(at);\n if (inline !== undefined) e.words = inline;\n return e;\n}\n\n// the outputs of a routine that a scene goes on to use, recorded as it returns\nexport const GIVES = { random: 'a', ask: 'ax', 'ask-mode': 'ax', 'ask-escape': 'axc', 'wait-or-escape': 'c', problem: 'c', 'read-key': 'a', 'read-dot': 'a', multiply: 'ax', divide: 'ax', 'blink-key': 'a', 'which-box': 'xy', tick: 'a', 'choose-action': 'a', take: 'a', drop: 'a', 'show-bag': 'a', 'bag-choose': 'a', getin: 'a', acptr: 'a', readst: 'a', load: 'cxy', chrin: 'a' };\n\n// A call that does nothing is no step: the beep returns at once for A 0 ($6831 in Animal Rescue,\n// $5D12 in Nature Park), and a scene that reads keys by polling beeps each one, 0 for none, until\n// one comes. As steps those would be as many as the polls, which is how long the machine was\n// watched, not what the title did.\nexport const nothing = (name, a) => name === 'beep' && a === 0;\n\n// routines that poll for a key: each is a step only when it gives one\nexport const POLLS = new Set(['read-key', 'blink-key']);\n// routines that wait for keys; any other, while it runs, is busy, and a key pressed then is not for it\nexport const WAITS = new Set(['wait', 'wait-erase', 'wait-or-escape', 'ask', 'ask-mode', 'ask-escape', 'which-box', 'tick', 'choose-action', 'take', 'drop', 'show-bag', 'bag-choose']);\nexport function result(name, regs) {\n const e = { result: name };\n for (const r of GIVES[name]) e[r] = regs[r];\n return e;\n}\n", "// What the card engine (card.js) knows of every title it plays, the title's own map of its routines aside (its\n// title.js `map`, below): the data some routines take inline after the call, a toolkit's sections file, and the\n// Commodore 64's KERNAL as a C64 title's map names it.\n//\n// A title's `map` (its title.js): the routines its scenes call, by address, each with the name of the step it is in\n// a scene's script (`routines`); and what its engine needs beside them, as the title has it: Detect-A-Pet's `seed`\n// (where the key reader takes the random routine's seed from), `stir` (a wait for a key that stirs the random\n// routine as it polls, its counts fixed when the key comes), `ticks` (a scene's own loop that reads the keyboard each\n// frame, each pass a step `tick`), `sections` (its toolkit's sections file, below); a C64 title's `c64`, `start`,\n// `quiet` (routines polled without end, an event only when they give something), `basic`, `polls` and `unplaced`.\n\n// The data some entries take inline after the call ({ length, value }), read through `read`: fill's seven bytes,\n// copy's eight and a ProDOS call's three, as hexadecimal; print's ASCII, ending $00; a message on the text screen,\n// `say`, its text ending $00, each character's high bit turned over\nconst bytes = n => (read, at) => { const b = []; for (let k = 0; k < n; k++) b.push(read(at + k).toString(16)); return { length: n, value: b.join(' ') }; };\nexport const INLINE = {\n fill: bytes(7), copy: bytes(8), prodos: bytes(3),\n 'boot-say': (read, at) => INLINE.say(read, at),\n say(read, at) { let s = '', i = at; for (let guard = 0; guard < 1024; guard++) { const c = read(i++); if (!c) break; s += String.fromCharCode((c ^ 0x80) & 0x7f); } return { length: i - at, value: s }; },\n print(read, at) { let s = '', i = at; for (let guard = 0; guard < 256; guard++) { const c = read(i++); if (!c) break; s += String.fromCharCode(c & 0x7f); } return { length: i - at, value: s }; },\n};\n\n// A section of a toolkit's sections file (its map's `sections`: { file, lib, origin, lengths, marks, count }), by\n// X: where it starts in the file and how long it is, from the library's tables, through `read` (memory, with the\n// library there)\nexport function section(toolkit, read, x) {\n const { lengths, marks } = toolkit.sections, word = at => read(at + x) | read(at + x + 1) << 8;\n return { mark: word(marks), length: word(lengths) };\n}\n// the name of what a read of `path` from `mark` is: a section's `path:x`, or the path\nexport function sectionName(toolkit, read, path, mark) {\n const s = toolkit.sections;\n if (!s || path !== s.file) return path;\n for (let x = 0; x < s.count; x += 2) { const t = section(toolkit, read, x); if (t.length && t.mark === mark) return path + ':' + x; }\n return path;\n}\n\n// The KERNAL's jump table at $FFxx as a C64 title calls it, each entry a step answered in JavaScript\n// (@moonbase-machines/c64/kernal.js): the routines Zoopak's code calls. (Not UDTIM, $FFEA: only an interrupt routine\n// calls it, which the remake, taking keys and having no interrupts, does not run.) A title that calls more names them\n// beside these in its own map, as Goldfields does its files'.\nexport const KERNAL = {\n 0xffd2: 'chrout', 0xffe4: 'getin', 0xfff0: 'plot', 0xffcc: 'clrchn', 0xffe1: 'stop', 0xffb7: 'readst',\n 0xffba: 'setlfs', 0xffbd: 'setnam', 0xffd5: 'load', 0xffd8: 'save',\n 0xffb1: 'listen', 0xff93: 'second', 0xffa8: 'ciout', 0xffae: 'unlsn', 0xffb4: 'talk', 0xff96: 'tksa', 0xffa5: 'acptr', 0xffab: 'untlk',\n 0xffdb: 'settim', 0xffde: 'rdtim', 0xff90: 'setmsg',\n};\n", "import { mli as m } from '@moonbase-machines/apple2e';\nexport const { BLOCK, CLOCK, Files } = m;", "import { rom as m } from '@moonbase-machines/apple2e';\nexport const { install } = m;", "import { kernal as m } from '@moonbase-machines/c64';\nexport const { KEY_TABLES, VECTORS, VIC, install, kernalByte, matrixOf, screenCode } = m;", "import { drive as m } from '@moonbase-machines/c64';\nexport const { Drive } = m;", "import { basic as m } from '@moonbase-machines/c64';\nexport const { Basic } = m;", "import { numbers as m } from '@moonbase-machines/c64';\nexport const { BasicError, ERRORS, fail, fout, int16, nextRandom, scanNumber, seedRandom, val } = m;", "import { basicRom as m } from '@moonbase-machines/c64';\nexport const { evaluateInMemory, install, printError } = m;", "// The lifter: a file's 6502 walked from its entries into a scene script, a step to a line\n// (a tool prints them; the remake lifts at need in the browser, card.js).\nimport { OPS, SIZE, operand, hex } from '@moonbase-machines/mos6502/disasm.js';\nimport { INLINE as READERS } from '@moonbase-machines/vector/inline.js';\nimport { TAKES } from './events.js';\n\n// the data after a call, read from the file, with the text quoted so that it reads as one word\nexport const readers = from => Object.fromEntries(Object.entries(from).map(([k, f]) => [k, (b, at) => { const r = f(i => b[i], at); return { length: r.length, words: k === 'text' || k === 'print' || k === 'say' ? JSON.stringify(r.value) : r.value }; }]));\nconst INLINE = readers(READERS);\n\n// `stops` are addresses where data begins that is not a table of code addresses, the objects'\n// tables and the objects themselves, so that a table of addresses read from the code ends there.\nexport function lift(bytes, origin, entries, routines, stops = new Set(), inline = INLINE) {\n const INLINE = inline;\n // `seen`: every byte an instruction or its data takes, for what is left as data; an instruction\n // is walked from where it starts, which may be inside another's bytes (the BIT that skips)\n const lines = new Map(), targets = new Set(entries), seen = new Set(), queue = [...entries];\n const inFile = a => a >= origin && a < origin + bytes.length;\n while (queue.length) {\n let pc = queue.pop();\n const regs = {};\n while (inFile(pc) && !lines.has(pc)) {\n seen.add(pc);\n const at = pc - origin, op = OPS[bytes[at]];\n if (op.name === '???') { lines.set(pc, { line: '.byte $' + hex(bytes[at], 2) + ' ; not an instruction', end: pc + 1 }); break; }\n const size = SIZE[op.mode], word = bytes[at + 1] | bytes[at + 2] << 8, ins = bytes.subarray(at, at + size);\n let line = (op.name + ' ' + operand(op.mode, ins, pc)).trim(), next = pc + size, stop = false;\n if (op.mode === 'imm' && 'LDA LDX LDY'.includes(op.name)) regs[op.name[2]] = bytes[at + 1];\n else if (op.name.startsWith('T') || op.name.startsWith('IN') || op.name.startsWith('DE') || op.name.startsWith('LD') || op.name === 'PLA') delete regs[op.name.at(-1)];\n if (op.name === 'JSR' && routines[word]) {\n const r = routines[word], data = INLINE[r]?.(bytes, next - origin);\n const args = ['A', 'X', 'Y'].map(k => regs[k] === undefined ? '' : k + '=' + regs[k]).filter(Boolean).join(' ');\n line = r + (data ? ' ' + data.words : '') + (args && !data ? ' ; ' + args : '');\n if (data) next += data.length;\n for (const k in regs) delete regs[k];\n } else if (op.name === 'JSR') { if (inFile(word)) { targets.add(word); queue.push(word); } for (const k in regs) delete regs[k]; }\n else if (op.name === 'JMP' && op.mode === 'abs') { if (inFile(word)) { targets.add(word); queue.push(word); } else line += ' ; into PART0' + (routines[word] ? ', ' + routines[word] : ''); stop = true; }\n else if (op.name === 'JMP' || op.name === 'RTS' || op.name === 'RTI' || op.name === 'BRK') stop = true;\n else if (op.mode === 'rel') { const t = (pc + 2 + (bytes[at + 1] << 24 >> 24)) & 0xffff; targets.add(t); queue.push(t); }\n // a table of addresses, read low byte then high byte, LDA t,X or t,Y and then LDA t+1 the same\n // way within a few instructions: every address in it that is in the file is code to follow\n if ((op.mode === 'abx' || op.mode === 'aby') && op.name === 'LDA' && inFile(word)) {\n for (let k = at + 3; k < at + 12 && k + 2 < bytes.length; k++) {\n if (bytes[k] !== bytes[at] || (bytes[k + 1] | bytes[k + 2] << 8) !== word + 1) continue;\n const table = [];\n for (let e = word - origin; e + 1 < bytes.length && table.length < 64; e += 2) { if (table.length && stops.has(origin + e)) break; const t = bytes[e] | bytes[e + 1] << 8; if (!inFile(t)) break; table.push(t); }\n line += ' ; a table of ' + table.length + ' addresses';\n for (const t of table) { targets.add(t); queue.push(t); }\n break;\n }\n }\n lines.set(pc, { line, end: next, op: op.name, mode: op.mode, value: size === 2 ? bytes[at + 1] : word, call: op.name === 'JSR' && routines[word] ? { name: routines[word], words: INLINE[routines[word]]?.(bytes, pc + 3 - origin)?.words } : null, stop });\n for (let a = pc + 1; a < next; a++) seen.add(a);\n if (stop) break;\n pc = next;\n }\n }\n const out = [];\n let last = null;\n for (const pc of [...lines.keys()].sort((a, b) => a - b)) {\n if (last !== null && pc !== last) out.push('');\n if (targets.has(pc)) out.push('L' + hex(pc, 4) + ':');\n out.push(hex(pc, 4) + ' ' + lines.get(pc).line);\n last = lines.get(pc).end;\n }\n // what the walk never reached: tables, data, and code reached only through a table\n const left = [];\n for (let a = origin; a < origin + bytes.length; ) { if (seen.has(a)) { a++; continue; } const s = a; while (a < origin + bytes.length && !seen.has(a)) a++; left.push([s, a - s]); }\n return { listing: out.join('\\n'), left, reached: seen.size, size: bytes.length, lines, targets };\n}\n\n// The lifted code as a scene script, a step to a line, each line starting with the address it\n// came from. A call into the engine is a step with its inputs, the loads before it folded in.\n// Everything else is a statement on the registers a, x and y, the flags, and memory, written\n// $866A for an address, $86E4[y] for one indexed, and ($12)[y] for one through the zero page.\n// Each statement sets the flags as its instruction did, so a branch means what it meant:\n// a compare and the branch after it are one `if a == 1 goto L8157`, and a branch alone tests a\n// flag, `if zero goto L8157`. A jump through a table that the code writes into its own JMP is\n// `goto [$86EC y]`. The bytes the walk never reached are kept as `data` lines, up to where the\n// objects' tables begin: the objects come from those tables instead.\nexport function script({ lines, targets, left }, bytes, origin, { stops = new Set(), selfModified = false, memory = false, moved = [] } = {}) {\n const H = (n, w = 4) => '$' + hex(n, w);\n // With `selfModified`, an instruction whose operand the code writes as it runs takes it from\n // memory: an immediate is the byte at its own address, an address is [$0D19], the one the code\n // keeps there, and a jump or a call goes through it. The places written are every address a\n // store, an increment or a shift names; and `moved`, the bytes of instructions seen to change\n // as the original ran (as the pilots find them), however the code wrote them (through a pointer, as\n // Find Me does)\n const written = new Set(moved);\n if (selfModified) for (const r of lines.values()) if (/^(STA|STX|STY|INC|DEC|ASL|LSR|ROL|ROR)$/.test(r.op) && /^(abs|abx|aby)$/.test(r.mode)) written.add(r.value);\n let here = null; // the address of the instruction being written\n // `memory`: code that other files write into, as the variables' file LIB.VARS, whose every\n // instruction takes its operand from memory\n const own = () => here !== null && (memory || written.has(here + 1) || written.has(here + 2));\n const place = r => {\n const v = r.value;\n if (own() && r.mode === 'imm' && (memory || written.has(here + 1))) return H(here + 1);\n if (own() && /^(abs|abx|aby)$/.test(r.mode)) return '[' + H(here + 1) + ']' + (r.mode === 'abs' ? '' : '[' + r.mode.at(-1) + ']');\n switch (r.mode) {\n case 'imm': return String(v);\n case 'zp': return H(v, 2);\n case 'zpx': return H(v, 2) + '[x]';\n case 'zpy': return H(v, 2) + '[y]';\n case 'abs': return H(v);\n case 'abx': return H(v) + '[x]';\n case 'aby': return H(v) + '[y]';\n case 'izy': return '(' + H(v, 2) + ')[y]';\n case 'izx': return '(' + H(v, 2) + '[x])';\n case 'acc': return 'a';\n default: return '?';\n }\n };\n const label = a => 'L' + hex(a, 4);\n const branch = { BEQ: 'zero', BNE: 'not zero', BCS: 'carry', BCC: 'not carry', BMI: 'negative', BPL: 'not negative', BVS: 'overflow', BVC: 'not overflow' };\n const fused = { BEQ: '==', BNE: '!=', BCS: '>=', BCC: '<' };\n const target = (pc, r) => (pc + 2 + (r.value << 24 >> 24)) & 0xffff;\n const pcs = [...lines.keys()].sort((a, b) => a - b), out = [];\n // An instruction that runs on into the bytes of another, as BIT $01A9 runs over the LDA #1 that\n // a jump to its second byte finds: the next line is not where it goes on, so a goto says where.\n const stopsHere = r => ['JMP', 'RTS', 'RTI'].includes(r.op);\n targets = new Set(targets);\n pcs.forEach((pc, i) => { const r = lines.get(pc); if (r.op && !stopsHere(r) && i + 1 < pcs.length && r.end !== pcs[i + 1] && lines.has(r.end)) targets.add(r.end); });\n let loads = []; // immediate loads waiting to be folded into the next call\n const flush = () => { for (const [pc, reg, v] of loads) out.push(hex(pc, 4) + ' ' + reg + ' = ' + v); loads = []; };\n let last = null; // the instruction before, and where it goes on\n for (let i = 0; i < pcs.length; i++) {\n const pc = pcs[i], r = lines.get(pc), next = lines.get(pcs[i + 1]), put = s => out.push(hex(pc, 4) + ' ' + s);\n here = pc;\n if (last && last.op && !stopsHere(last) && last.end !== pc && lines.has(last.end)) { flush(); out.push(hex(last.pc, 4) + ' goto ' + label(last.end)); }\n last = { ...r, pc: pcs[i] };\n if (targets.has(pc)) { flush(); out.push(label(pc) + ':'); }\n if (!r.op) { flush(); put('asm ' + r.line); continue; }\n const reg = r.op.at(-1).toLowerCase();\n if (r.call) {\n const [name, ...fixed] = r.call.name.split(' ');\n const takes = TAKES[name] || '';\n const given = Object.fromEntries(loads.map(([, g, v]) => [g, v]));\n // loads the call does not take stay as statements, before it\n const kept = loads.filter(([, g]) => !takes.includes(g)); loads = kept; flush();\n const args = [...fixed, ...[...takes].map(g => given[g] ?? g)];\n if (name === 'objects' && given.x !== undefined && given.y !== undefined) args.splice(fixed.length, 2, H(given.x | given.y << 8));\n if (name === 'key-at' || name === 'key') args[0] = given.a !== undefined ? JSON.stringify(String.fromCharCode(given.a & 0x7f)) : args[0];\n put([name, ...args, r.call.words ?? ''].join(' ').trim());\n continue;\n }\n switch (r.op) {\n case 'LDA': case 'LDX': case 'LDY':\n if (r.mode === 'imm' && !own()) { loads = loads.filter(([, g]) => g !== reg); loads.push([pc, reg, r.value]); break; }\n // the jump through a table: LDA T,Y STA J+1 LDA T+1,Y STA J+2 J: JMP\n if (r.mode === 'aby' || r.mode === 'abx') {\n const [s1, l2, s2, j] = [1, 2, 3, 4].map(k => lines.get(pcs[i + k]));\n if (s1?.op === 'STA' && l2?.op === 'LDA' && l2.value === r.value + 1 && s2?.op === 'STA' && j?.op === 'JMP' && s1.value === pcs[i + 4] + 1 && s2.value === pcs[i + 4] + 2) {\n flush(); put('goto [' + H(r.value) + ' ' + r.mode.at(-1) + ']'); i += 4; last = null; break;\n }\n }\n flush(); put(reg + ' = ' + place(r)); break;\n case 'STA': case 'STX': case 'STY': flush(); put(place(r) + ' = ' + reg); break;\n case 'TAX': case 'TAY': case 'TXA': case 'TYA': flush(); put(r.op[2].toLowerCase() + ' = ' + r.op[1].toLowerCase()); break;\n case 'INX': case 'INY': case 'DEX': case 'DEY': flush(); put(reg + (r.op[0] === 'I' ? ' += 1' : ' -= 1')); break;\n case 'INC': case 'DEC': flush(); put(place(r) + (r.op === 'INC' ? ' += 1' : ' -= 1')); break;\n case 'CLC': case 'SEC': flush(); put('carry = ' + (r.op === 'SEC' ? 1 : 0)); break;\n case 'ADC': flush(); put('a += ' + place(r) + ' + carry'); break;\n case 'SBC': flush(); put('a -= ' + place(r) + ' + borrow'); break;\n case 'AND': flush(); put('a &= ' + place(r)); break;\n case 'ORA': flush(); put('a |= ' + place(r)); break;\n case 'EOR': flush(); put('a ^= ' + place(r)); break;\n case 'ASL': case 'LSR': case 'ROL': case 'ROR': flush(); put(place(r) + ' ' + { ASL: '<<= 1', LSR: '>>= 1', ROL: 'rotate left', ROR: 'rotate right' }[r.op]); break;\n case 'BIT': flush(); put('test ' + place(r)); break;\n case 'CMP': case 'CPX': case 'CPY': {\n flush();\n const who = r.op === 'CMP' ? 'a' : r.op[2].toLowerCase();\n if (next && fused[next.op] && !targets.has(pcs[i + 1])) { put('if ' + who + ' ' + fused[next.op] + ' ' + place(r) + ' goto ' + label(target(pcs[i + 1], next))); i++; last = { ...next, pc: pcs[i] }; }\n else put('compare ' + who + ' ' + place(r));\n break;\n }\n case 'JMP': flush(); if (r.mode === 'abs' && own()) { put('goto (' + H(pc + 1) + ')'); break; } put(r.mode === 'abs' ? (r.value >= origin && r.value < origin + bytes.length ? 'goto ' + label(r.value) : 'goto-engine ' + H(r.value)) : 'goto (' + H(r.value) + ')'); break;\n case 'JSR': flush(); if (own()) { put('call (' + H(pc + 1) + ')'); break; } put(r.value >= origin && r.value < origin + bytes.length ? 'call ' + label(r.value) : 'call-engine ' + H(r.value)); break;\n case 'RTS': flush(); put('return'); break;\n case 'PHA': case 'PLA': case 'PHP': case 'PLP': flush(); put({ PHA: 'push a', PLA: 'pull a', PHP: 'push flags', PLP: 'pull flags' }[r.op]); break;\n case 'NOP': break;\n default:\n if (branch[r.op]) { flush(); put('if ' + branch[r.op] + ' goto ' + label(target(pc, r))); break; }\n flush(); put('asm ' + r.line);\n }\n }\n flush();\n // each run of bytes the walk never reached, up to where the objects begin\n for (const [a, whole] of left) {\n let n = 0; while (n < whole && !(n && stops.has(a + n)) && !stops.has(a)) n++;\n if (!n) continue;\n const row = [];\n for (let k = 0; k < n; k += 16) row.push('data ' + H(a + k) + ' ' + Array.from(bytes.subarray(a - origin + k, a - origin + Math.min(n, k + 16)), b => hex(b, 2)).join(' '));\n out.push('', ...row);\n }\n return out.join('\\n') + '\\n';\n}\n\n", "import { disasm as m } from '@moonbase-machines/mos6502';\nexport const { OPS, SIZE, disassemble, hex, operand } = m;", "import { inline as m } from '@moonbase-machines/vector';\nexport const { INLINE, name, sound, text } = m;", "// A scene script compiled to JavaScript: moonbase-compile writes each title's scripts as modules\n// beside them (its folder's compiled/<name>.js), and the remake runs those.\n//\n// The script's statements become JavaScript on the engine's registers, flags, stack and memory,\n// each line with the script's line beside it, so the code can be read against the original's.\n// A run of statements that does nothing but compute is one block, one function, from a label\n// or the step after a jump, a call or a routine's step, to the next of those; a branch back to\n// the block's own start is a loop in it. What can stop the run stays a step of its own, as the\n// engine runs it: a routine's step (a wait for a key, a picture), and any read or write that may\n// reach the I/O page (the keyboard, read until a key comes, or a tick), so that the title waits\n// where it waited, step for step.\n//\n// Each run of lines to a branch starts with its time (Engine.time), the cycles of the original's\n// instructions there, and a branch taken adds one, as the 6502's does.\n//\n// A compiled script is { labels, data, steps, run }: the labels by step, the data put into\n// memory as the script is read, each step as [its address, its line in the scene, its text],\n// and `run`, each block's function by the index of the step it starts at: (e, s) => ..., on the\n// engine e and the script's steps s.\nimport { parse, operand, branchTaken } from './script.js';\n\nconst hex = (v, n = 2) => '0x' + v.toString(16).padStart(n, '0');\n// the I/O page, the Apple's $C000 to $C0FF unless the title gives its own (compile's `io`)\nlet IO_FROM = 0xc000, IO_TO = 0xc0ff;\nconst IO = at => at >= IO_FROM && at <= IO_TO;\n\n// an operand's address as JavaScript, and whether it may be on the I/O page: an address the\n// code keeps (($26)[y], [$0D19][x]) can be anywhere, and so can a table indexed across $C000\nfunction address(o) {\n if (o.through !== undefined) return { js: `(e.mem[${hex(o.through)}] | e.mem[${hex(o.through + 1)}] << 8) + e.y & 0xffff`, io: true };\n if (o.pair !== undefined) return { js: `e.mem[${hex(o.pair)} + e.x & 0xff] | e.mem[${hex(o.pair)} + e.x + 1 & 0xff] << 8`, io: true };\n if (o.via !== undefined) return { js: `(e.mem[${hex(o.via, 4)}] | e.mem[${hex(o.via + 1, 4)}] << 8)${o.index ? ' + e.' + o.index + ' & 0xffff' : ''}`, io: true };\n if (!o.index) return { js: hex(o.at, 4), io: IO(o.at) };\n const io = o.at <= IO_TO && o.at + 255 >= IO_FROM;\n return { js: o.at + 255 > 0xffff ? `(${hex(o.at, 4)} + e.${o.index}) & 0xffff` : `${hex(o.at, 4)} + e.${o.index}`, io };\n}\n// reading an operand, and writing one: { js, io }\n// a read for a load, a compare or the like takes a cycle more where an index carries into the\n// next page (Engine.ix); a read for a change in place (an increment, a shift) never does\nfunction get(word, timed = true) {\n const o = operand(word);\n if (o.number !== undefined) return { js: String(o.number & 0xff) };\n if (o.reg === 'carry') return { js: 'e.c' };\n if (o.reg) return { js: 'e.' + o.reg };\n const a = address(o);\n if (timed && o.through !== undefined) return { js: `e.read(e.ix(e.mem[${hex(o.through)}] | e.mem[${hex(o.through + 1)}] << 8, e.y))`, io: true };\n if (timed && o.via !== undefined && o.index) return { js: `e.read(e.ix(e.mem[${hex(o.via, 4)}] | e.mem[${hex(o.via + 1, 4)}] << 8, e.${o.index}))`, io: true };\n if (timed && o.index && !o.zp) return { js: a.io ? `e.read(e.ix(${hex(o.at, 4)}, e.${o.index}))` : `e.mem[e.ix(${hex(o.at, 4)}, e.${o.index})]`, io: a.io };\n return { js: a.io ? `e.read(${a.js})` : `e.mem[${a.js}]`, io: a.io };\n}\nfunction put(word, v) {\n const o = operand(word);\n if (o.reg) return { js: `e.${o.reg} = ${v}` };\n const a = address(o);\n return { js: a.io ? `e.write(${a.js}, ${v})` : `e.mem[${a.js}] = ${v}`, io: a.io };\n}\n// a read, then a write of the same place: { at, js(read), write(v), io }\nfunction place(word) {\n const o = operand(word);\n if (o.reg) return { pre: '', read: 'e.' + o.reg, write: v => `e.${o.reg} = ${v}` };\n const a = address(o);\n if (a.io) return { pre: `const at = ${a.js}; `, read: 'e.read(at)', write: v => `e.write(at, ${v})`, io: true };\n return { pre: '', read: `e.mem[${a.js}]`, write: v => `e.mem[${a.js}] = ${v}` };\n}\n\nconst FLAGS = { zero: 'e.z', carry: 'e.c', negative: 'e.n', overflow: 'e.v' };\nconst TESTS = { '==': 'e.z', '!=': '!e.z', '>=': 'e.c', '<': '!e.c' };\n\n// One step as JavaScript: { js, kind }. A statement's kind is 'compute', or 'io' if it may reach\n// the I/O page; a jump, a call or a return ends a block ('end'); a branch may leave it\n// ('branch', with its label); a routine's step is a block of its own ('routine').\nfunction statement(step, k) {\n const w = step.words, [first, second] = w, s = `s[${k}]`;\n const of = (...parts) => ({ js: parts.map(p => p.js ?? p).join(''), kind: parts.some(p => p.io) ? 'io' : 'compute' });\n if (second === '=' && w.length === 3) {\n const v = get(w[2]), o = operand(first);\n if (o.reg === 'carry') return of('e.c = ', v, ' & 1;');\n if (o.reg) return of(`e.${o.reg} = e.flags(`, v, ');'); // a load sets the flags, a store does not\n const p = put(first, v.js);\n return { js: p.js + ';', kind: v.io || p.io ? 'io' : 'compute' };\n }\n if (second === '+=' || second === '-=') {\n const v = get(w[2]);\n if (w.length === 3) { // an increment or a decrement\n const p = place(first);\n return { js: `${p.pre}${p.write(`e.flags(${p.read} ${second[0]} ${v.js} & 0xff)`)};`, kind: p.io || v.io ? 'io' : 'compute' };\n }\n // with the carry, as ADC and SBC: SBC adds the operand turned over\n return { js: second === '+=' ? `e.add(${v.js});` : `e.sub(${v.js});`, kind: v.io ? 'io' : 'compute' };\n }\n if (second === '&=' || second === '|=' || second === '^=') { const v = get(w[2]); return of(`e.a = e.flags(e.a ${second[0]} `, v, ');'); }\n if (second === '<<=' || second === '>>=' || second === 'rotate') {\n const p = place(first), left = second === '<<=' || w[2] === 'left';\n return { js: `${p.pre}${p.write(`e.shift(${p.read}, ${left}, ${second === 'rotate'})`)};`, kind: p.io ? 'io' : 'compute' };\n }\n switch (first) {\n case 'if': {\n const to = w.at(-1), cond = w.slice(1, -2);\n if (cond.length === 3 && /^[axy]$/.test(cond[0])) { const v = get(cond[2]); return { js: `e.compare(e.${cond[0]}, ${v.js}); if (${TESTS[cond[1]]})`, kind: 'branch', to, io: v.io }; }\n const not = cond[0] === 'not', flag = FLAGS[not ? cond[1] : cond[0]];\n if (!flag) throw new Error(step.where + ': no flag ' + cond.join(' '));\n return { js: `if (${not ? '!' : ''}${flag})`, kind: 'branch', to };\n }\n case 'goto':\n if (w[1].startsWith('(')) return { js: `return e.jumpThrough(${hex(parseInt(w[1].slice(2, -1), 16), 4)}, ${s});`, kind: 'end' };\n if (w[1].startsWith('[')) return { js: `return e.jumpTable(${hex(parseInt(w[1].slice(2), 16), 4)}, e.${w[2][0]});`, kind: 'end' };\n return { js: `return e.jump('${w[1]}', ${s});`, kind: 'end' };\n case 'call':\n if (w[1].startsWith('(')) return { js: `return e.callThrough(${hex(parseInt(w[1].slice(2, -1), 16), 4)}, ${s});`, kind: 'end' };\n return { js: `return e.call('${w[1]}', ${s});`, kind: 'end' };\n case 'return': return { js: `return e.ret(${s});`, kind: 'end' };\n case 'compare': return of(`e.compare(e.${w[1]}, `, get(w[2]), ');');\n case 'test': return of('e.test(', get(w[1]), ');');\n case 'push': return { js: `e.push(${w[1] === 'a'});`, kind: 'compute' };\n case 'pull': return { js: `e.pull(${w[1] === 'a'});`, kind: 'compute' };\n case 'asm': if (w[1] === 'RTI') return { js: `return e.ret(${s});`, kind: 'end' };\n return { js: ['TSX', 'TXS', 'CLV', 'SED', 'CLD', 'SEI', 'CLI'].includes(w[1]) ? `e.asm('${w[1]}');` : '', kind: 'compute' };\n }\n const args = w.slice(1).map(a => typeof a === 'string' ? `'${a}'` : `{ string: ${JSON.stringify(a.string)} }`).join(', ');\n return { js: `return e.routine('${first}', [${args}], ${s});`, kind: 'routine' };\n}\n\nexport function compile(source, name, { io = [0xc000, 0xc0ff] } = {}) {\n [IO_FROM, IO_TO] = io;\n const { steps, labels, data } = parse(source, name);\n const code = steps.map((step, k) => statement(step, k));\n const starts = new Set([0, ...Object.values(labels)]);\n code.forEach((c, k) => {\n if (c.kind === 'routine' || c.kind === 'io' || c.io) starts.add(k);\n if (c.kind !== 'compute' && c.kind !== 'branch' || c.io) starts.add(k + 1);\n });\n const at = Object.fromEntries(Object.entries(labels).map(([l, k]) => [k, l]));\n const blocks = [];\n for (let k = 0; k < steps.length; k++) {\n if (!starts.has(k)) continue;\n let end = k + 1;\n while (end < steps.length && !starts.has(end)) end++;\n // a branch back to the block's own start: the block is a loop\n const loops = code.slice(k, end).some(c => c.kind === 'branch' && labels[c.to] === k);\n const lines = [];\n for (let i = k; i < end; i++) {\n // the time of the lines to the next branch, or the block's end (a routine's step counts its\n // own call)\n if ((i === k || code[i - 1].kind === 'branch') && code[i].kind !== 'routine') {\n let j = i; while (j < end - 1 && code[j].kind !== 'branch') j++;\n lines.push(`e.time(s, ${i}, ${j});`);\n }\n const c = code[i], text = steps[i].at === null ? steps[i].text : steps[i].at.toString(16).toUpperCase().padStart(4, '0') + ' ' + steps[i].text;\n let js = c.js;\n if (c.kind === 'branch') {\n const t = labels[c.to];\n const more = branchTaken(steps[i]), cy = more === 1 ? 'e.cycles++' : `e.cycles += ${more}`;\n js += t === undefined ? ` { ${cy}; e.pc = e.label('${c.to}'); return; }` : t === k && loops ? ` { ${cy}; continue; }` : ` { ${cy}; e.pc = ${t}; return; }`;\n }\n if (c.kind === 'end') js = `e.pc = ${i + 1}; ` + js;\n lines.push(js ? `${js.padEnd(48)} // ${text}` : `// ${text}`);\n }\n if (code[end - 1].kind !== 'end' && code[end - 1].kind !== 'routine' && end !== k + 1) lines.push(`e.pc = ${end};`);\n const label = at[k] ? ` // ${at[k]}\\n` : '';\n // a step alone that gives what it returns: one line\n const one = lines.length === 1 && /^return (.*?);( +\\/\\/ .*)$/.exec(lines[0]);\n if (one) { blocks.push(`${label} ${`${k}: (e, s) => ${one[1]},`.padEnd(60)}${one[2].trim() ? ' ' + one[2].trim() : ''}`); continue; }\n const body = loops ? ['for (;;) {', ...lines.map(l => ' ' + l), ' break;', '}'] : lines;\n blocks.push(`${label} ${k}: (e, s) => {\\n${body.map(l => ' ' + l).join('\\n')}\\n },`);\n }\n return [\n `// ${name}, compiled from ${name}.scene by moonbase-compile (@moonbase-machines/player/remake/compile.js): compiled`,\n `// again from the scene, never edited`,\n `export default {`,\n ` labels: ${JSON.stringify(labels)},`,\n ` data: [${data.map(d => `\\n [${hex(d.at, 4)}, [${d.bytes.map(b => hex(b)).join(', ')}]],`).join('')}\\n ],`,\n ` steps: [${steps.map(s => `\\n [${s.at === null ? 'null' : hex(s.at, 4)}, ${+s.where.split(':').at(-1)}, ${JSON.stringify(s.text)}],`).join('')}\\n ],`,\n ` run: {`,\n ...blocks,\n ` },`,\n `};`,\n '',\n ].join('\\n');\n}\n", "// A scene script: the steps of a part or a problem, a step to a line, as a lifter's --script\n// writes them and as they are edited after. A line may start with the address in the original\n// it came from, which is kept so that the pilots can say where two runs part.\n//\n// L8157: a label\n// 8157 object 3 4 44 a step: the engine's work, with its inputs\n// 814F a = $8235 a statement on the registers a, x, y and memory\n// 8152 if zero goto L8157 a branch on a flag, or on a compare: if a == 1 goto L8157\n// data $86E4 01 02 03 04 bytes of the original's tables, at their addresses\n// ; a comment\n//\n// parse() gives { steps, labels, data }: each step is { at, op, args, text }.\n\nconst WORD = /\"(?:[^\"\\\\]|\\\\.)*\"|\\S+/g;\n\nexport function parse(source, name = 'script') {\n const steps = [], labels = {}, data = [];\n source.split('\\n').forEach((raw, n) => {\n const line = raw.replace(/^\\s+|\\s+$/g, '');\n if (!line || line.startsWith(';')) return;\n const where = name + ':' + (n + 1);\n let m;\n if ((m = /^(L[0-9A-F]{4}|[A-Za-z_][\\w-]*):$/.exec(line))) { labels[m[1]] = steps.length; return; }\n if ((m = /^data \\$([0-9A-F]+)((?: [0-9A-F]{2})+)$/i.exec(line))) { data.push({ at: parseInt(m[1], 16), bytes: m[2].trim().split(' ').map(h => parseInt(h, 16)) }); return; }\n m = /^([0-9A-F]{4})\\s+(.*)$/.exec(line);\n const at = m ? parseInt(m[1], 16) : null, body = m ? m[2] : line;\n steps.push({ at, words: words(body), text: body, where, index: steps.length });\n });\n return { steps, labels, data };\n}\n\n// a line's words, a quoted one as { string }\nexport const words = body => body.match(WORD).map(w => w.startsWith('\"') ? { string: JSON.parse(w) } : w);\n\n// an operand: a number, a register, a flag, or a place in memory; [$0D19] is the address the\n// code keeps at $0D19 and $0D1A, written there as it runs, as an instruction's own operand is\n// 12 a x y carry $866A $86E4[y] $12[x] ($12)[y] ($12[x]) [$0D19][y]\nexport function operand(word) {\n if (typeof word !== 'string') return { string: word.string };\n if (/^-?\\d+$/.test(word)) return { number: +word };\n if (/^[axy]$/.test(word) || word === 'carry' || word === 'borrow') return { reg: word };\n let m;\n if ((m = /^\\$([0-9A-F]+)(?:\\[([xy])\\])?$/i.exec(word))) return { at: parseInt(m[1], 16), index: m[2], zp: m[1].length <= 2 };\n if ((m = /^\\(\\$([0-9A-F]{2})\\)\\[y\\]$/i.exec(word))) return { through: parseInt(m[1], 16) };\n // ($27[x]): the address kept at the zero page's $27 plus X, as LDA ($27,X)\n if ((m = /^\\(\\$([0-9A-F]{2})\\[x\\]\\)$/i.exec(word))) return { pair: parseInt(m[1], 16) };\n if ((m = /^\\[\\$([0-9A-F]{4})\\](?:\\[([xy])\\])?$/i.exec(word))) return { via: parseInt(m[1], 16), index: m[2] };\n throw new Error('not an operand: ' + word);\n}\n\n// The cycles a branch takes more when it goes: one, and one more when it goes to another page\n// than the instruction after it. A line that compares and branches (if a != 13 goto L) is two\n// instructions, the compare's size before the branch's.\nconst SIZE = w => /^\\d+$/.test(w) || /^\\$[0-9A-F]{2}(\\[[xy]\\])?$/i.test(w) || /^\\(\\$/.test(w) ? 2 : 3;\nexport function branchTaken(step) {\n if (step.at === null) return 1;\n const w = step.words, to = parseInt(w.at(-1).slice(1), 16);\n const next = (step.at + (w.length === 6 ? SIZE(w[3]) : 0) + 2) & 0xffff;\n return /^L[0-9A-F]{4}$/.test(w.at(-1)) && (to & 0xff00) !== (next & 0xff00) ? 2 : 1;\n}\n", "// The remake engine: it runs a title's scene scripts, and everything a scene does is an event.\n// It draws nothing itself. A view listens to the events and draws them however it likes, and a\n// pilot reads them as the transcript to hold against the original's.\n//\n// A script's statements act on three registers, a, x and y, four flags, a stack, and 64K of\n// memory, as the lines they were lifted from did, so the logic of a scene is kept exactly. Its\n// steps are the engine's work, which the title's routines do: a text, a picture, a wait.\n//\n// const e = new Engine({ routines, scripts, start })\n// e.run() runs until the title waits for a key: 'idle', or 'end'\n// e.press(key) a key, as a character code; the waiting step takes it on the next run\n// e.on(event => ...)\n// e.onKey(key => ...) each key as the title's keyboard takes it (key()), apart from the events, which stay the\n// transcript; returns a function that stops it\nimport { parse, operand, words, branchTaken } from './script.js';\nimport { CYCLES } from '@moonbase-machines/mos6502/cpu.js';\n\n// what a routine throws when the title leaves what it was doing (Engine.leave)\nconst LEFT = { left: true };\n// the words that start a statement rather than a routine's step\nconst STATEMENTS = new Set(['if', 'goto', 'call', 'return', 'compare', 'test', 'asm', 'push', 'pull']);\nconst STATEMENT = step => STATEMENTS.has(step.words[0]) || /^(=|\\+=|-=|&=|\\|=|\\^=|<<=|>>=|rotate)$/.test(step.words[1]);\nconst CYCLES_PER_MS = 1020.484;\n// an instruction's size by its opcode, the 6502's: by the addressing mode its bits give\nfunction size(op) {\n if (op === 0x20) return 3;\n if (op === 0x00 || op === 0x40 || op === 0x60) return 1;\n const b = op >> 2 & 7, cc = op & 3;\n if (cc === 1) return b === 3 || b === 6 || b === 7 ? 3 : 2;\n if (b === 0) return cc === 2 || (op & 0xe0) >= 0xa0 ? 2 : 1;\n if (b === 2 || b === 6) return cc === 0 || cc === 2 ? 1 : 2;\n if (b === 4) return cc === 0 ? 2 : 2;\n return b === 3 || b === 7 ? 3 : 2;\n}\n// what the lifter leaves out of its lines: a NOP, and a load of A, X or Y, immediate, zero page\n// or absolute, or CLC or SEC, that it takes into the step after as its input\nconst LEFT_OUT = new Set([0xea, 0xa9, 0xa2, 0xa0, 0xa5, 0xa6, 0xa4, 0xad, 0xae, 0xac, 0x18, 0x38]);\nconst COMPARED = step => step.words[0] === 'if' && step.words.length === 6;\n// the return address a call leaves on the 6502's stack, its JSR's last byte\nconst returnOf = step => step?.at == null ? undefined : (step.at + 2) & 0xffff;\n// an address as a script's label, L8157\nexport const label16 = at => 'L' + at.toString(16).toUpperCase().padStart(4, '0');\n\nexport class Engine {\n constructor({ routines, scripts, start, label, memory = {} }) {\n this.routines = routines; this.sources = scripts;\n this.mem = new Uint8Array(0x10000);\n for (const [at, v] of Object.entries(memory)) this.mem[at] = v;\n this.a = 0; this.x = 0; this.y = 0;\n this.n = 0; this.z = 0; this.c = 0; this.v = 0; this.d = 0;\n this.stack = []; this.keys = []; this.listeners = []; this.takers = []; this.ended = false;\n // the time the original took, in its cycles, for a title whose code is in memory where its\n // lines came from (`timed`): each line its instruction's, and the speaker's clicks by it\n this.timed = !!routines.timed; this.cycles = 0; this.clicks = []; this.delay = 0;\n this.programs = {};\n // what the title's routines set up before the start: memory, the I/O page (`io`)\n routines.setup?.(this);\n this.enter(start, label, true);\n }\n\n on(f) { this.listeners.push(f); }\n // An event made while `inside` is above nought is part of a routine's own work, as the choice\n // PROB2 draws while its ask waits: the view draws it, but it is no step of the transcript.\n emit(event) { if (this.inside) event.inside = true; for (const f of this.listeners) f(event); }\n inside = 0;\n press(key) { this.keys.push(key); }\n key() { const k = this.keys.shift(); if (k !== undefined) for (const f of this.takers) f(k); return k; }\n onKey(f) { this.takers.push(f); return () => { this.takers = this.takers.filter(g => g !== f); }; }\n\n // start a script from its first step, or from a label in it; when it is loaded, as the original\n // loads its file, its data goes into memory, and otherwise memory is as the game left it\n enter(name, label, load = false) {\n const p = this.script(name);\n if (load) for (const d of p.data) this.mem.set(d.bytes, d.at);\n this.program = p; this.name = name; this.pc = label === undefined ? 0 : this.label(label);\n }\n // a script by its name, as written (a scene, run line by line) or compiled (compile.js)\n script(name) {\n if (this.programs[name]) return this.programs[name];\n const src = this.sources[name];\n if (src === undefined) throw new Error('no script ' + name);\n const p = this.programs[name] = typeof src === 'string' ? parse(src, name) : {\n labels: src.labels,\n data: src.data.map(([at, bytes]) => ({ at, bytes })),\n steps: src.steps.map(([at, line, text], k) => ({ at, text, where: name + ':' + line, run: src.run[k], words: words(text), index: k })),\n };\n // a step whose label is before it starts there: the lines the lifter took into it (Engine.cost)\n for (const [l, k] of Object.entries(p.labels)) { const at = /^L[0-9A-F]{4}$/.test(l) ? parseInt(l.slice(1), 16) : null; if (at !== null && p.steps[k]?.at > at) p.steps[k].start = at; if (at !== null && p.steps[k]?.at === at) p.steps[k].entered = true; }\n return p;\n }\n // Leave everything running, the scripts called and a problem with them, for a label: as the\n // original jumps to its Main Menu from the key reader, and resets the stack. The routine that\n // leaves goes no further.\n // A routine of the title's own code, run inside the step that calls it: its steps are part of\n // that step's work, and no steps of the transcript; `done` is called as it returns.\n callInside(name, label, done, ret) {\n this.stack.push({ name: this.name, pc: this.pc, inside: true, done, ret });\n this.inside++;\n this.enter(name, label);\n }\n leave(name, label) {\n this.stack = []; this.problem = null; this.waitingOn = null; this.visited = null;\n this.enter(name, label);\n throw LEFT;\n }\n // Nature Park's menus, from a key reader on control-E or control-T ($4C28): the routine that\n // read the key asks for them and waits, so that a problem it is inside goes on living; then what\n // was running is kept, with the screen, and the menus run as a routine, the A it gives them 2.\n // When they return, all is put back and the routine waits for a key again, as the original's\n // key reader comes back with none ($4C51). A visit from inside the menus keeps what was kept.\n visit(key) { this.visiting = key; }\n startVisit(here) {\n const [name, label] = this.title.visit[this.visiting];\n this.visiting = undefined;\n if (!this.visited) {\n this.visited = { name: this.name, pc: here, stack: this.stack, problem: this.problem, waitingOn: this.waitingOn, asked: this.asked, askMode: this.askMode, regs: [this.a, this.x, this.y, this.n, this.z, this.c, this.v] };\n // $4C5D: the screen kept, cleared, and the graphics shown\n this.title.raster?.keepScreen();\n this.inside++; this.emit({ step: 'keep-screen' }); this.inside--;\n this.routines.show(this, [], null);\n }\n this.stack = [{ visit: true }]; this.problem = null; this.waitingOn = null; this.asked = null;\n this.a = 2; this.c = 0;\n this.enter(name, label);\n }\n endVisit() {\n const v = this.visited;\n this.visited = null;\n // $4CFB: the screen put back, and the graphics shown\n this.title.raster?.putScreen();\n this.inside++; this.emit({ step: 'put-screen' }); this.inside--;\n this.routines.show(this, [], null);\n this.enter(v.name);\n Object.assign(this, { pc: v.pc, stack: v.stack, problem: v.problem, waitingOn: v.waitingOn, asked: v.asked, askMode: v.askMode });\n [this.a, this.x, this.y, this.n, this.z, this.c, this.v] = v.regs;\n }\n label(l) { const i = this.program.labels[l]; if (i === undefined) throw new Error(this.name + ': no label ' + l); return i; }\n\n // reading and writing an operand\n place(o) {\n if (o.through !== undefined) return ((this.mem[o.through] | this.mem[o.through + 1] << 8) + this.y) & 0xffff;\n if (o.pair !== undefined) { const z = (o.pair + this.x) & 0xff; return this.mem[z] | this.mem[(z + 1) & 0xff] << 8; }\n if (o.via !== undefined) return ((this.mem[o.via] | this.mem[o.via + 1] << 8) + (o.index ? this[o.index] : 0)) & 0xffff;\n return (o.at + (o.index ? this[o.index] : 0)) & 0xffff;\n }\n // The I/O page, $C000 to $C0FF, goes to the title's `io`, when it has one: the keyboard and the\n // soft switches that pick what the screen shows. A read of the keyboard with no key sets\n // `polled`, and the run stops there for a key, as the original's loop waits on it.\n // (the title's I/O page, `ioAt`: the Apple's $C000 to $C0FF unless the title says otherwise, as\n // the Commodore 64's $D000 to $DFFF)\n read(at) { return this.io && this.ioAt(at) ? this.io(at) & 0xff : this.mem[at]; }\n write(at, v) { if (this.io && this.ioAt(at)) this.io(at, v & 0xff); else this.mem[at] = v; }\n ioAt(at) { return (at & 0xff00) === 0xc000; }\n get(o) {\n if (o.number !== undefined) return o.number & 0xff;\n if (o.reg === 'carry') return this.c;\n if (o.reg) return this[o.reg];\n return this.read(this.place(o));\n }\n // a read for a load, a compare or the like: through an index, a cycle more when the index\n // carries into the next page, as the 6502 takes it\n load(o) {\n if (this.timed && (o.index && !o.zp || o.through !== undefined)) {\n const base = o.through !== undefined ? this.mem[o.through] | this.mem[o.through + 1] << 8 : o.via !== undefined ? this.mem[o.via] | this.mem[o.via + 1] << 8 : o.at;\n if ((base & 0xff) + this[o.index ?? 'y'] > 0xff) this.cycles++;\n }\n return this.get(o);\n }\n // an indexed address, for compiled code: the same cycle more\n ix(base, i) { if (this.timed && (base & 0xff) + i > 0xff) this.cycles++; return (base + i) & 0xffff; }\n set(o, v) {\n v &= 0xff;\n if (o.reg) { this[o.reg] = v; return; }\n this.write(this.place(o), v);\n }\n flags(v) { this.n = v >> 7 & 1; this.z = v === 0 ? 1 : 0; return v; }\n compare(r, v) { const d = (r - v) & 0x1ff; this.c = r >= v ? 1 : 0; this.flags(d & 0xff); }\n\n // The statements' work, the same for a script run line by line (exec) and one compiled to\n // JavaScript (compile.js).\n // The cycles of the lines from step i to step j of a script, the instructions' as the original\n // has them in memory at the lines' addresses, a branch taken one more (Engine.branch, and the\n // compiled branches): kept with step i, the first time, and counted toward the run's delay.\n time(s, i, j) {\n if (!this.timed) return;\n let c = s[i].cycles;\n if (c === undefined) { c = 0; for (let k = i; k <= j; k++) c += this.cost(s, k); s[i].cycles = c; }\n this.cycles += c; this.delay += c / CYCLES_PER_MS;\n }\n // A line's cycles: its instruction's, a compare and its branch both (if a != 13 goto L), and\n // those the lifter left out just before it, from where the line before ended (past the data\n // after its call, as the title reads it, `inline`): a register's load it took into the step's\n // inputs (hposn 34 57 0 was LDA, LDX, LDY and the JSR), a NOP\n cost(s, k) {\n const step = s[k], m = this.mem;\n if (step.at === null) return 0;\n let c = CYCLES[m[step.at]] + (COMPARED(step) ? 2 : 0);\n // the line before falls through to it, unless the line is where a jump comes in (its label at\n // its own address) or the line before goes elsewhere\n const prev = !step.entered && !['return', 'goto'].includes(s[k - 1]?.words[0]) ? s[k - 1] : null;\n if (step.start !== undefined || prev && prev.at !== null) {\n // from its label, where a jump comes in, or where the line before ended\n const from = step.start ?? prev.at + size(m[prev.at]) + (COMPARED(prev) ? 2 : 0) + (this.routines.inline?.(this, prev) ?? 0);\n if (from < step.at && step.at - from <= 9) {\n let more = 0, a = from;\n for (; a < step.at && LEFT_OUT.has(m[a]); a += size(m[a])) more += CYCLES[m[a]];\n if (a === step.at) c += more; // only these, or the bytes between are no code (a variable)\n }\n }\n return c;\n }\n // ADC: the sum with the carry into A, and the flags; in decimal mode (SED, as Zoopak's clocks\n // count) by the 6502's own rules, as @moonbase-machines/mos6502/cpu.js\n add(m) {\n if (this.d) {\n let lo = (this.a & 15) + (m & 15) + this.c, hi = (this.a >> 4) + (m >> 4);\n if (lo > 9) { lo -= 10; hi++; }\n this.z = ((this.a + m + this.c) & 0xff) === 0 ? 1 : 0;\n this.n = hi & 8 ? 1 : 0; this.v = (~(this.a ^ m) & (this.a ^ (hi << 4)) & 0x80) ? 1 : 0;\n if (hi > 9) { hi -= 10; this.c = 1; } else this.c = 0;\n this.a = ((hi << 4) | lo) & 0xff; return;\n }\n const a = this.a, sum = a + m + this.c;\n this.v = (~(a ^ m) & (a ^ sum) & 0x80) ? 1 : 0; this.c = sum > 0xff ? 1 : 0; this.a = this.flags(sum & 0xff);\n }\n // SBC: in binary ADC with the operand turned over; in decimal mode by the 6502's rules\n sub(m) {\n if (!this.d) return this.add(m ^ 0xff);\n let lo = (this.a & 15) - (m & 15) - (1 - this.c), hi = (this.a >> 4) - (m >> 4);\n if (lo < 0) { lo += 10; hi--; }\n const r = this.a - m - (1 - this.c); this.z = (r & 0xff) === 0 ? 1 : 0; this.n = r & 0x80 ? 1 : 0;\n this.v = ((this.a ^ m) & (this.a ^ r) & 0x80) ? 1 : 0; this.c = r >= 0 ? 1 : 0;\n if (hi < 0) hi += 10;\n this.a = ((hi << 4) | lo) & 0xff;\n }\n // ASL, LSR, ROL and ROR: the value shifted, the bit out into the carry\n shift(v, left, through) {\n const r = left ? (v << 1 | (through ? this.c : 0)) & 0xff : v >> 1 | (through && this.c ? 0x80 : 0);\n this.c = left ? v >> 7 : v & 1; return this.flags(r);\n }\n // BIT: N and V from the value, Z from it ANDed with A\n test(v) { this.n = v >> 7 & 1; this.v = v >> 6 & 1; this.z = (v & this.a) === 0 ? 1 : 0; }\n // goto a label of this script's; one that a file read since has put another script's code\n // over is that script's (the title's `elsewhere`)\n jump(l, step) {\n if (this.routines.elsewhere?.(this, l)) return this.routines['goto-engine'](this, ['$' + l.slice(1)], step);\n this.pc = this.label(l);\n }\n // goto ($8371): through the address kept at $8371 and $8372, as JMP ($8371), into this script\n // or the title's code elsewhere\n jumpThrough(t, step) {\n const l = label16(this.mem[t] | this.mem[t + 1] << 8);\n if (this.program.labels[l] === undefined && this.routines['goto-engine']) return this.routines['goto-engine'](this, ['$' + l.slice(1)], step);\n this.pc = this.label(l);\n }\n // goto [$8180 y]: through a table of addresses, the one at the index\n jumpTable(t, i) { this.pc = this.label(label16(this.mem[t + i] | this.mem[t + i + 1] << 8)); }\n call(l, step) {\n if (this.routines.elsewhere?.(this, l)) return this.routines['call-engine'](this, ['$' + l.slice(1)], step);\n this.stack.push({ name: this.name, pc: this.pc, ret: returnOf(step) }); this.pc = this.label(l);\n }\n // call ($0D19): through the address the code keeps there, into this script or another's\n callThrough(t, step) {\n const l = label16(this.mem[t] | this.mem[t + 1] << 8);\n if (this.program.labels[l] === undefined && this.routines['call-engine']) return this.routines['call-engine'](this, ['$' + l.slice(1)], step);\n this.stack.push({ name: this.name, pc: this.pc, ret: returnOf(step) }); this.pc = this.label(l);\n }\n ret(step) {\n const f = this.stack.pop();\n if (!f) throw new Error('return with nothing called');\n if (f.visit) { this.endVisit(); return; }\n const p = this.pulled;\n // two bytes pushed, an address less one, high byte first: RTS goes there, the 6502's\n // jump through a table (PHA PHA RTS, as LIB4's menu goes to its choice)\n if (f.a !== undefined && this.stack.at(-1)?.a !== undefined) {\n const hi = this.stack.pop().a, to = ((hi << 8 | f.a) + 1) & 0xffff, l = label16(to);\n // or back past the data after a call whose frame was pulled to read it (fill's, print's):\n // to the step after the call, the next in its script (which may start a little further on,\n // where the lifter took a register's load into the step that uses it)\n if (p?.ret !== undefined && to > p.ret && to - p.ret <= 0x100) {\n this.pulled = null;\n if (p.name !== this.name) this.enter(p.name);\n this.pc = p.pc;\n if (p.inside) { this.inside--; p.done?.(this); }\n return;\n }\n // or back before the call, in the script that made it, to make a call again: Detect-A-Pet's\n // disk error screens, which once the disk is back go back to the ProDOS call that failed\n // (still inside the routine, as the original's count of calls is, until the call made\n // again comes back to where the first would have: `again`)\n if (p?.ret !== undefined && to <= p.ret && p.ret - to <= 0x20 && this.script(p.name).labels[l] !== undefined) {\n this.pulled = null;\n if (p.name !== this.name) this.enter(p.name);\n this.pc = this.label(l);\n if (p.inside) this.again = this.again?.ret === p.ret ? { ...this.again, n: this.again.n + 1 } : { ret: p.ret, done: p.done, n: 1 };\n return;\n }\n if (this.program.labels[l] === undefined && this.routines['goto-engine']) return this.routines['goto-engine'](this, ['$' + l.slice(1)], step);\n this.pc = this.label(l); return;\n }\n // a routine's frame pulled and dropped, and a return from below where it was: what it was\n // inside is left now (the routine's own calls return above it)\n if (p && this.stack.length < p.depth) { this.pulled = null; if (p.inside && p.ret !== undefined) this.inside--; }\n if (f.name !== this.name) this.enter(f.name);\n this.pc = f.pc;\n // the end of a routine run inside a step (Engine.inside): what it gives, as its result; and\n // what a frame does as it is returned to (`after`: BASIC's SYS keeps the registers)\n if (f.inside) { this.inside--; f.done?.(this); }\n if (this.again && f.ret === this.again.ret) { const a = this.again; this.again = null; this.inside -= a.n; a.done?.(this); }\n f.after?.(this);\n }\n push(a) { this.stack.push(a ? { a: this.a } : { flags: [this.n, this.z, this.c, this.v] }); }\n pull(a) {\n // a call's frame is the two bytes of its return address on the original's stack, the last\n // byte of its JSR: PLA gives the low byte, then the high, and two pulls drop it, as PLA PLA\n // drops a return to go back two calls at once ($0D26), or as fill takes its data from after\n // the call; the frame is kept (`pulled`) for the return that goes back past the data\n const top = this.stack.at(-1);\n if (top && top.name !== undefined) {\n const v = top.ret === undefined ? 0 : top.half ? top.ret >> 8 : top.ret & 0xff;\n if (top.half) { this.stack.pop(); top.depth = this.stack.length; this.pulled = top; if (top.inside && top.ret === undefined) this.inside--; } else top.half = true;\n if (a) this.a = this.flags(v);\n return;\n }\n const f = this.stack.pop(); if (a) this.a = this.flags(f.a); else [this.n, this.z, this.c, this.v] = f.flags;\n }\n // the machine's own instructions a scene keeps. TSX gives the stack's place, as the\n // original's stack pointer would be with these frames on it, and keeps the frames under\n // it; TXS goes back to the frames kept at the place it is given (Detect-A-Pet's save and\n // load keep the stack page and its pointer), and to none at any other, as the town's\n // resets the stack and drops every script called. SED and CLD set decimal mode, and SEI and\n // CLI the mask a Commodore 64's interrupt waits on (card.js). The rest (a byte that\n // is no instruction) change nothing the remake holds.\n asm(op) {\n if (op === 'TSX') {\n const sp = 0xff - this.stack.reduce((n, f) => n + (f.name === undefined ? 1 : f.half ? 1 : 2), 0) & 0xff;\n (this.stacks ??= new Map()).set(sp, this.stack.map(f => ({ ...f })));\n this.x = this.flags(sp);\n }\n if (op === 'TXS') {\n const kept = this.stacks?.get(this.x);\n this.stack = kept ? kept.map(f => ({ ...f })) : []; this.visited = null; this.inside = this.stack.filter(f => f.inside).length;\n }\n if (op === 'CLV') this.v = 0; // as LIB4 does before a branch that always goes\n if (op === 'SED') this.d = 1; if (op === 'CLD') this.d = 0; // decimal mode, for ADC and SBC\n if (op === 'SEI') this.i = 1; if (op === 'CLI') this.i = 0; // interrupts masked, and not\n }\n\n // run until the title waits for a key, or `limit` steps: ten million, as Detect-A-Pet's toy\n // shop turns a screen over seven times, a byte at a time, in its own lifted code\n run(limit = 1e7) {\n // the keyboard read with no key, in this run (`io`): a run that goes on after the time the\n // original took ('pace') goes on counting, as the machine's one run would\n if (!this.pacing) this.idle = 0;\n this.pacing = false;\n this.delay ??= 0;\n for (let i = 0; i < limit; i++) {\n if (this.ended) return 'end';\n const step = this.program.steps[this.pc];\n if (!step) throw new Error(this.name + ': ran off the end');\n // the title's own word before a statement runs: a card title's tick stops there\n if (this.routines.before?.(this, step) === 'wait') return 'idle';\n const r = this.exec(step);\n if (r === 'wait') return 'idle';\n if (this.polled) { this.polled = false; return 'idle'; }\n // the time the original took, a disk's read or a wait it counted out, in milliseconds: a\n // frame's worth or more stops the run, for the page to show the screen and take the time\n if (this.delay >= 16) { this.pacing = true; return 'pace'; }\n }\n return 'steps';\n }\n\n // A step: a compiled script's own function (`run`, for a run of statements together, or a\n // routine's step), or the step's words, line by line. Only a routine's step that waits runs\n // again when the key comes.\n exec(step) {\n const here = this.pc;\n this.pc++;\n try {\n this.called = false;\n if (!step.run && STATEMENT(step)) this.time(this.program.steps, here, here);\n const r = step.run ? step.run(this, this.program.steps) : this.interpret(step);\n if (r === 'wait' && (step.run ? this.called : !STATEMENT(step))) {\n this.pc = here;\n if (this.visiting !== undefined) { this.startVisit(here); return; }\n }\n return r;\n } catch (e) {\n if (e === LEFT) { this.inside = 0; return; } // counted down as it left what it was inside\n // an error the title answers as its machine did (a BASIC program's, BASIC's message and the\n // end of the program: card.js `error`)\n if (this.routines.error?.(this, e)) { this.ended = true; return; }\n e.message = step.where + ' (' + step.text + '): ' + e.message;\n throw e;\n }\n }\n\n interpret(step) {\n const w = step.words, [first, second] = w;\n // a = $8235, $866A = a, x += 1, a &= 127, $8235 <<= 1\n if (second === '=' && w.length === 3) {\n const o = operand(first), v = this.load(operand(w[2]));\n if (o.reg === 'carry') { this.c = v & 1; return; }\n this.set(o, v); if (o.reg) this.flags(v); // a load sets the flags, a store does not\n return;\n }\n if (second === '+=' || second === '-=') {\n const o = operand(first), v = w.length === 3 ? this.get(operand(w[2])) : this.load(operand(w[2]));\n if (w.length === 3) { const r = (this.get(o) + (second === '+=' ? v : -v)) & 0xff; this.set(o, r); this.flags(r); return; } // increment or decrement\n if (second === '+=') this.add(v); else this.sub(v); return; // with the carry, as ADC and SBC\n }\n if (second === '&=' || second === '|=' || second === '^=') { const v = this.load(operand(w[2])); this.a = this.flags(second === '&=' ? this.a & v : second === '|=' ? this.a | v : this.a ^ v); return; }\n if (second === '<<=' || second === '>>=' || second === 'rotate') {\n const o = operand(first);\n this.set(o, this.shift(this.get(o), second === '<<=' || w[2] === 'left', second === 'rotate')); return;\n }\n switch (first) {\n case 'if': return this.branch(w, step);\n case 'goto':\n if (w[1].startsWith('(')) return this.jumpThrough(parseInt(w[1].slice(2, -1), 16), step);\n if (w[1].startsWith('[')) return this.jumpTable(parseInt(w[1].slice(2), 16), this[w[2][0]]);\n return this.jump(w[1], step);\n case 'call':\n if (w[1].startsWith('(')) return this.callThrough(parseInt(w[1].slice(2, -1), 16), step);\n return this.call(w[1], step);\n case 'return': return this.ret(step);\n case 'compare': this.compare(this[w[1]], this.load(operand(w[2]))); return;\n case 'test': this.test(this.get(operand(w[1]))); return;\n case 'asm': if (w[1] === 'RTI') return this.ret(step); this.asm(w[1]); return; // (RTI: the end of an interrupt's routine, card.js)\n case 'push': this.push(w[1] === 'a'); return;\n case 'pull': this.pull(w[1] === 'a'); return;\n }\n return this.routine(first, w.slice(1), step); // a quoted word comes as { string }\n }\n // a step: the title's routines do the engine's work\n routine(name, args, step) {\n const routine = this.routines[name];\n if (!routine) throw new Error('no routine ' + name);\n this.called = true;\n // the call into the toolkit, its JSR's cycles; the routine's own lines count as they run\n // and the loads the lifter took into the step (Engine.cost)\n if (step && this.timed && step.at !== null) { const c = this.cost(this.program.steps, step.index); this.cycles += c; this.delay += c / CYCLES_PER_MS; }\n return routine(this, args, step);\n }\n\n // if <flag> goto L, if not <flag> goto L, if <reg> <op> <operand> goto L\n branch(w, step) {\n const to = w.at(-1), cond = w.slice(1, -2);\n let yes;\n if (cond.length === 3 && /^[axy]$/.test(cond[0])) {\n this.compare(this[cond[0]], this.load(operand(cond[2])));\n yes = { '==': this.z, '!=': !this.z, '>=': this.c, '<': !this.c }[cond[1]];\n } else {\n const not = cond[0] === 'not', flag = not ? cond[1] : cond[0];\n const v = { zero: this.z, carry: this.c, negative: this.n, overflow: this.v }[flag];\n if (v === undefined) throw new Error('no flag ' + flag);\n yes = not ? !v : !!v;\n }\n if (yes) { this.cycles += branchTaken(step); this.pc = this.label(to); }\n }\n}\n", "import { cpu as m } from '@moonbase-machines/mos6502';\nexport const { CPU, CYCLES } = m;", "// A text laid out as the engine's text routine ($6CE2) lays it out, for the view to draw and for\n// the screen model to paint. `pen` is the text state that lasts from text to text: the pen's x and\n// y, the margin, centring, the spacing, the gap between lines, the ink and the paper. It is changed\n// here as the engine changes it.\n//\n// {0:x} the pen's x and the margin {1:y} its y, or from $C0 the line height\n// {2:n} the spacing {3:n} the gap between lines {4:c} the ink {5:c} the paper\n// {7} and {8} centring on and off {9} and {a} tall on and off {f:ch,n} a character n times\n// {d} and {e} ink 0 and ink 1 from here on {10} and {11} the big digits and back\n//\n// Returns the lines, each { top, tall, height, paper, ink, chars }, and each character { ch, x, ink },\n// its x in dots. A character's ink is undefined before the line's first color: the engine draws\n// that part in the ink the whole line ends with, which is the line's `ink`. A byte below a space\n// is a spacer, a few dots of room and nothing drawn.\nimport { width, start } from '@moonbase-machines/vector/font.js';\n\n// the screen's layout by $03E3: the window's last row, and the tops of the two boxes below it\nexport const LAYOUT = { 0x41: [116, 116, 174], 0x32: [116, 116, 160], 0x31: [130, 130, 174], 0x22: [130, 130, 160], 0x11: [158, 158, 174] };\n// the panels: the layout they set, the rows of the box they clear, from its two white rows down,\n// and its color, and the text state they leave; `more`, white rows drawn below as well. 1 to 6 are\n// Animal Rescue's, $6299 to $6395; Nature Park has the same six and eighteen more, $5712 to $58A6,\n// in families that share a body and differ in the gap and the row they leave (its title's map).\nconst gray = (layout, rows, gap, y, more) => ({ layout, rows, fill: 10, paper: 10, ink: 0, gap, y, more });\nconst blue = (layout, rows, gap, y) => ({ layout, rows, fill: 5, paper: 5, ink: 15, gap, y });\nexport const PANELS = {\n 1: gray(0x32, [116, 159], 7, 128), 2: gray(0x32, [116, 159], 33, 135),\n 3: gray(0x22, [130, 159], 5, 135), 4: gray(0x22, [130, 159], 19, 142),\n 5: blue(0x22, [160, 189], 5, 166), 6: blue(0x22, [160, 189], 19, 172),\n 7: gray(0x41, [116, 173], 5, 121), 8: gray(0x41, [116, 173], 6, 128), 9: gray(0x41, [116, 173], 7, 134), 10: gray(0x41, [116, 173], 47, 142),\n 11: gray(0x32, [116, 159], 5, 121),\n 12: gray(0x31, [130, 173], 5, 135), 13: gray(0x31, [130, 173], 7, 142), 14: gray(0x31, [130, 173], 33, 149),\n 15: gray(0x11, [158, 173], 5, 163, [174]),\n 16: blue(0x32, [160, 189], 19, 172), 17: blue(0x42, [160, 189], 19, 172),\n 18: blue(0x32, [160, 189], 5, 166), 19: blue(0x42, [160, 189], 5, 166),\n 20: blue(0x23, [160, 189], 0, 163), 21: blue(0x33, [160, 189], 0, 163), 22: blue(0x43, [160, 189], 0, 163),\n 23: blue(0x31, [174, 189], 5, 179), 24: blue(0x41, [174, 189], 5, 179),\n};\n\n// code 6: a word from a table of words, each its length then its letters, the index given or\n// read from memory\nexport function word(mem, [lo, hi, vlo, vhi]) {\n let at = lo | hi << 8, n = vhi === 0xff ? vlo : mem[vlo | vhi << 8];\n while (n-- > 0) at += mem[at] + 1;\n let s = ''; for (let k = 1; k <= mem[at]; k++) s += String.fromCharCode(mem[at + k] & 0x7f);\n return s;\n}\n// a text's words with the words code 6 takes put in, from memory as it is now\nexport const resolve = (words, mem) => words.replace(/\\{6:([0-9a-f,]+)\\}/g, (all, b) => word(mem, b.split(',').map(v => parseInt(v, 16))));\n\nexport function layout(words, pen) {\n const t = pen, lines = [];\n t.tall = false; t.margin = t.x; let height = 9, big = false;\n let line = [], ink = t.ink, marked = false;\n const flush = newline => {\n if (line.length) {\n let x = start(line.map(c => c.ch), t.spacing, t.x, t.centre);\n const chars = [];\n for (const c of line) {\n const w = width(c.ch);\n chars.push({ ch: c.ch, x, ink: c.ink });\n x += c.ch.charCodeAt(0) < 0x20 ? w : w + t.spacing;\n }\n lines.push({ top: t.y, tall: t.tall, height, paper: t.paper, ink: t.ink, chars });\n t.x = x;\n }\n line = [];\n if (newline) { t.y += (t.tall ? 2 * height : height) + t.gap; t.x = t.margin; }\n };\n // a digit in the big set is its own character, $80 and on (@moonbase-machines/vector/font.js)\n const put = ch => line.push({ ch: big && ch >= '0' && ch <= '9' ? String.fromCharCode(0x80 + ch.charCodeAt(0) - 0x30) : ch, ink: marked ? ink : undefined });\n for (let i = 0; i < words.length; i++) {\n const c = words[i];\n if (c === '\\n') { flush(true); continue; }\n if (c === '{') {\n const end = words.indexOf('}', i), [code, rest] = words.slice(i + 1, end).split(':'), b = (rest ?? '').split(',').map(v => parseInt(v, 16));\n i = end;\n switch (parseInt(code, 16)) {\n case 0: t.x = t.margin = b[0]; break;\n case 1: if (b[0] < 0xc0) t.y = b[0]; else height = b[0] - 0xc0; break;\n case 2: t.spacing = b[0]; break;\n case 3: t.gap = b[0]; break;\n case 4: t.ink = ink = b[0]; marked = true; break;\n case 5: t.paper = b[0]; break;\n case 7: t.centre = true; break;\n case 8: t.centre = false; break;\n case 9: t.tall = true; break;\n case 10: t.tall = false; break;\n case 13: ink = 0; marked = true; break;\n case 14: ink = 1; marked = true; break;\n case 16: big = true; break;\n case 17: big = false; break;\n case 15: for (let k = 0; k < (b[1] || 256); k++) put(String.fromCharCode(b[0] & 0x7f)); break;\n }\n continue;\n }\n put(c);\n }\n flush(false);\n return lines;\n}\n\n// The same codes on the text screen, where the menus and the teacher's controls are ($573D puts\n// the machine in 40 columns of text): {0:x} is the column and the margin, {1:y} the row, a new\n// line the next row at the margin, {7} centres each line in the 40 columns, and {d} and {e} turn\n// inverse on and off. Inverse has capitals only, as the text page's inverse codes do. The\n// spacing, the gap, the colors and tall mean nothing there.\n// Returns the characters as { row, col, ch, inverse }, and leaves the pen where the text ended.\nexport function textLayout(words, pen) {\n const cells = [];\n pen.inverse = false; // each text starts out of inverse ($6D02)\n let line = [];\n const flush = newline => {\n const col = pen.centre ? (40 - line.length) >> 1 : pen.x;\n line.forEach((c, k) => cells.push({ row: pen.y, col: col + k, ch: c.ch, inverse: c.inverse }));\n if (line.length) pen.x = col + line.length;\n line = [];\n if (newline) { pen.y++; pen.x = pen.margin; }\n };\n const put = ch => line.push({ ch: pen.inverse ? ch.toUpperCase() : ch, inverse: pen.inverse });\n for (let i = 0; i < words.length; i++) {\n const c = words[i];\n if (c === '\\n') { flush(true); continue; }\n if (c === '{') {\n const end = words.indexOf('}', i), [code, rest] = words.slice(i + 1, end).split(':'), b = (rest ?? '').split(',').map(v => parseInt(v, 16));\n i = end;\n switch (parseInt(code, 16)) {\n case 0: flush(false); pen.x = pen.margin = b[0]; break;\n case 1: flush(false); if (b[0] < 0xc0) pen.y = b[0]; break;\n case 7: pen.centre = true; break;\n case 8: pen.centre = false; break;\n case 13: pen.inverse = true; break;\n case 14: pen.inverse = false; break;\n case 15: for (let k = 0; k < (b[1] || 256); k++) put(String.fromCharCode(b[0] & 0x7f)); break;\n }\n continue;\n }\n put(c);\n }\n flush(false);\n return cells;\n}\n// the text state at the start, and the empty screen\nexport const textPen = () => ({ x: 0, y: 0, margin: 0, centre: false, inverse: false });\nexport const textPage = () => Array.from({ length: 24 }, () => Array.from({ length: 40 }, () => ({ ch: ' ', inverse: false })));\n", "import { font as m } from '@moonbase-machines/vector';\nexport const { GLYPHS, WIDTHS, dots, start, useFont, width } = m;", "// One way to start a title's remake, for the remake's page (main.js), a replay and Node (a pilot's observer): the\n// title's title.js, from the folder it is in, with the modules it names (its problems, its paint); its scripts,\n// compiled to JavaScript (bin/moonbase-compile.mjs) or, with `scenes`, the scene files themselves to run line by line;\n// its game's data, from where the page keeps it; and an engine made from them.\n//\n// const { title, scripts, disk, folder } = await loadTitle(folder, { data })\n// folder the title's folder, an absolute URL (its title.js, its scenes, compiled/, its own modules)\n// data its game's data, an absolute URL (<slug>.json: its disks' files, its kind, its saves)\n// title.disk = disk; title.seed = 17 (the caller's: a data disk, the seed)\n// const engine = makeEngine(title, scripts)\n// With `fixed`, a title that has a version with its bugs fixed (its title.js `fixed`, a script for each it replaces)\n// runs those scripts in place of its own. A title whose engine is its own (its title.js `engine` the name of a module\n// in its folder, not 'card' or 'vector') has no scripts here: its engine is loaded with its other modules, as\n// `title.own`, and runs the game itself (main.js).\nimport { Engine } from './engine.js';\nimport { vectorRoutines } from './vector.js';\nimport { cardRoutines } from './card.js';\nimport { started } from '@moonbase-machines/apple2e/prodos.js';\n\nconst ENGINES = { vector: vectorRoutines, card: cardRoutines };\n\n// a file read in the browser by fetch, and in Node from the disk (Node's own fs, asked of Node itself, so that the\n// browser's files import nothing of Node's)\nasync function read(url, as) {\n if (url.protocol === 'file:') { const text = globalThis.process.getBuiltinModule('node:fs').readFileSync(url, 'utf8'); return as === 'json' ? JSON.parse(text) : text; }\n const r = await fetch(url);\n if (!r.ok) throw new Error(`${url.pathname}: ${r.status}`);\n return as === 'json' ? r.json() : r.text();\n}\nconst defaultOf = async url => (await import(url.href)).default;\n\nexport async function loadTitle(folder, { data, scenes = false, fixed = false } = {}) {\n folder = new URL(folder);\n const title = { ...(await defaultOf(new URL('title.js', folder))) };\n // the modules a title has of its own, as its title.js names them (problems.js, paint.js), and its view's own\n // drawing (view.js), where it says it has one\n for (const name of title.modules ?? []) title[name] = await defaultOf(new URL(name + '.js', folder));\n if (title.view) title.viewSteps = await defaultOf(new URL('view.js', folder));\n if (!ENGINES[title.engine]) {\n title.own = await import(new URL(title.engine + '.js', folder).href);\n return { title, scripts: {}, disk: null, folder };\n }\n const scripts = Object.fromEntries(await Promise.all(title.scripts.map(async n =>\n [n, scenes ? await read(new URL(n + '.scene', folder), 'text') : await defaultOf(new URL(`compiled/${(fixed && title.fixed?.[n]) || n}.js`, folder))])));\n const disk = await read(new URL(data), 'json');\n return { title, scripts, disk, folder };\n}\n\nexport function makeEngine(title, scripts) {\n // (a ProDOS title's memory starts with what ProDOS leaves, as the original's does)\n const memory = { ...(title.disk?.kind === 'prodos' ? started(title.disk) : {}), ...title.memory };\n const engine = new Engine({ routines: ENGINES[title.engine](title), scripts, start: title.start, label: title.startLabel, memory });\n engine.title = title;\n return engine;\n}\n", "// The routines of a vector engine title, for the remake engine, as its title.js `map` names them: what each step\n// of a scene does. Each gives the event the original's routine gives\n// (events.js), does what the original did to the registers, the flags and the memory that the\n// scenes read, and paints the original's screen for the scenes that read it back. The rules for\n// the keys, the random numbers and the waits are the original's, from PART0 (docs in\n// @moonbase-machines/vector's README).\nimport { describe, result, TAKES, nothing } from './events.js';\nimport { helpers } from './problems.js';\nimport { tables, carry } from '@moonbase-machines/vector/objects.js';\nimport { pictures } from '@moonbase-machines/vector/pictures.js';\nimport { width, useFont } from '@moonbase-machines/vector/font.js';\nimport { Raster } from './raster.js';\nimport { Files } from '@moonbase-machines/apple2e/mli.js';\nimport { layout, resolve, PANELS, textLayout, textPen, textPage } from './layout.js';\n\n// A vector title's map (its title.js `map`): `volume`, its disk's volume; `objects`, the routine that sets the table\n// of objects; `seed` ({ at, used }), where the random routine keeps its seed and the byte that is $FF until its first\n// call; `menu`, the Main Menu, which the key reader jumps to on control-E; `visit` ({ at, kept, back }), a way to its\n// menus instead, the screen kept and put back (Nature Park's); `keyPanel`, the arrows' panel; `vars`, where the\n// engine keeps what the remake reads (`zero`, how far up the zero page its routines' inputs are; the screen's\n// layout; the difficulty; practice; repeats; the sound flag, on with its `soundOn` bit); `loads`, where its code\n// files load when its catalog has lost it; `askClearsCarry`, `countInX`; `modern`, characters a modern font draws\n// otherwise; `routines`, its engine's routines by address, each the name of its step; `problems`, each problem's own\n// routines that draw, by the problem's number.\n\n// A game's code files, PART0, the parts and the problems, each with the address it loads at: the map's `loads`, by\n// the file's name or its name without the digit, or else the catalog's\nexport function codeFiles(map, volume) {\n const loads = map?.loads ?? {};\n return Object.entries(volume).filter(([n]) => /^(PART|PROB)\\d$/.test(n))\n .map(([name, f]) => ({ name, bytes: Uint8Array.from(atob(f.data), c => c.charCodeAt(0)), origin: loads[name] ?? loads[name.slice(0, -1)] ?? f.aux }));\n}\n\nconst KEY = { escape: 27, space: 32, return: 13, delete: 127, left: 8, right: 21, down: 10, up: 11, menu: 5 };\n\n// the inputs of a step: numbers, a register's name, or an address for the table of objects\nfunction inputs(e, name, args) {\n const takes = TAKES[name] || '', fixed = [];\n let k = 0;\n if (name === 'panel') fixed.push(args[k++]);\n const regs = { a: e.a, x: e.x, y: e.y };\n if (name === 'objects' && args[0]?.startsWith?.('$')) { const t = parseInt(args[k++].slice(1), 16); regs.x = t & 0xff; regs.y = t >> 8; }\n else for (const r of takes) {\n const v = args[k++];\n if (v === undefined || v === r) continue;\n regs[r] = typeof v === 'object' ? v.string.charCodeAt(0) | 0x80 : v.startsWith('$') ? e.mem[parseInt(v.slice(1), 16)] : +v;\n }\n e.a = regs.a & 0xff; e.x = regs.x & 0xff; e.y = regs.y & 0xff;\n return { fixed, rest: args.slice(k) };\n}\n\n// A step that takes a key: its event once, then it waits until a key comes. Control-E, at any\n// key the original read, went to the Main Menu and dropped everything called.\nfunction waiting(e, step, name, fixed, words, take) {\n if (e.waitingOn !== step) { e.emit(describe(name, fixed, e, words)); e.waitingOn = step; e.asked = null; }\n for (;;) {\n const k = e.key();\n if (k === undefined) return 'wait';\n if (k === KEY.menu && e.title.menu) e.leave(...e.title.menu);\n if (e.title.visit?.[k]) { e.visit(k); return 'wait'; }\n if (take(k)) { e.waitingOn = null; return; }\n }\n}\n\n// $6415 calls the problem's own routines as a choice is made and taken back ($F729 and $F74B,\n// then $F776 and $F6CE, in PROB2): drawing that happens inside the ask. The problem gives them as\n// generators in e.askHooks, which run to their end here, inside, so they are drawn and no step.\nfunction quietly(e, run) {\n if (!run) return;\n e.inside++;\n try { for (let r = run.next(); !r.done; r = run.next()) if (r.value === 'wait') throw new Error('a choice drawn inside the ask cannot wait'); }\n finally { e.inside--; }\n}\n\n// The disk's objects, by the address of their table, for the carry the object routine leaves.\n// `title.disk` is the title's disk from its game's data.\nfunction objectsOf(title) {\n if (title.objectTables || !title.disk) return title.objectTables;\n const files = codeFiles(title.map, Object.values(title.disk.volumes)[0]);\n return title.objectTables = new Map(tables(files, title.map.objects).map(t => [t.address, t.objects]));\n}\n\n// The disk's pictures, by name, for the screen model\nfunction picturesOf(title) {\n if (title.pictureShapes || !title.disk) return title.pictureShapes;\n const volume = Object.values(title.disk.volumes)[0], map = new Map();\n for (const [name, f] of Object.entries(volume)) if (/^PICS\\d$/.test(name)) for (const p of pictures(Uint8Array.from(atob(f.data), c => c.charCodeAt(0)))) map.set(p.name, p.shapes);\n return title.pictureShapes = map;\n}\n\n// a picture's shapes by its name, as the disk has them, for a problem that works with them\nexport const pictureShapes = (title, name) => picturesOf(title)?.get(name.toUpperCase().replace(/_/g, ' '));\n\nexport function vectorRoutines(title) {\n // where this engine keeps its variables, and its routines' inputs in the zero page\n const V = title.map.vars, Z = z => V.zero + z;\n useFont(title.font);\n // what an object's routine leaves: the carry, and in the row its rows were counted in (zero\n // page $02 from the engine's), the row past the object's bottom, which a span after it may take\n const objectCarry = e => {\n if (e.a < 2) return; // putting ground back ends another way; no scene is known to use its carry\n const o = objectsOf(title)?.get(e.objectTable)?.find(o => o.number === e.a);\n if (o) { e.c = carry(o, e.x); e.mem[Z(0x02)] = (e.y + o.height) & 0xff; }\n };\n // The original's screen, dot for dot (raster.js), which each step paints as the original's\n // routine painted, for read-dot; and the text state that lasts from text to text.\n const raster = title.raster ??= new Raster();\n const pen = title.pen ??= { x: 0, y: 0, margin: 0, centre: false, spacing: 1, gap: 0, ink: 15, paper: 10 };\n // The text screen, where the menus are: its characters, its pen, and whether it is showing.\n // `show` ($5BA9) puts the graphics back.\n title.text ??= { showing: false, pen: textPen(), page: textPage() };\n const objectOf = (e, n) => objectsOf(title)?.get(e.objectTable)?.find(o => o.number === n);\n const drawObject = (e, how) => { if (e.a < 2) return raster.restore(); const o = objectOf(e, e.a); if (o) raster.object(o, e.x, e.y, how); };\n // a key cap at the pen, as $76F3 draws it: outlined in color 13 and filled with 1, four dots\n // wider than the glyph or than four, and the glyph in 15 from a dot on, after a spacer that\n // brings a narrow glyph to the cap's right; the pen is left two dots past the text's end\n const cap = ch => {\n const w = width(ch), x = pen.x, spacer = (w < 4 ? 4 - w : 0) + 1;\n raster.rectangle(1, x, pen.y - 2, Math.max(4, w) + 4, 11); raster.outline(13, x, pen.y - 2, Math.max(4, w) + 4, 11); // ($5C83)\n raster.glyph(ch, x + 1 + spacer, pen.y, 15, 1, 1, 8); // its text's lines are 8 high\n pen.x = x + 1 + spacer + w + 1 + 2;\n };\n // the arrows' panel, all four caps (n 0) or the nth, as the ask draws it in its arrow mode\n const keyPanel = n => {\n const k = title.map.keyPanel;\n if (!k) return;\n const c = raster.get(2, 2), { x, y } = pen;\n for (let r = k.top; r < k.top + k.rows; r++) raster.span(c, k.left, k.right, r);\n k.caps.forEach(([cx, cy, ch], i) => { if (!n || n === i + 1) { pen.x = cx; pen.y = cy; cap(String.fromCharCode(ch & 0x7f)); } });\n Object.assign(pen, { x, y });\n };\n // a text on the graphics screen, as $6CE2 paints it\n const print = (e, words) => { for (const line of layout(resolve(words, e.mem), pen)) for (const c of line.chars) raster.glyph(c.ch, c.x, line.top, c.ink ?? line.ink, line.paper, line.tall ? 2 : 1, line.height, pen.spacing); };\n // object n of the table set last, put as `how` ('whole', 'keep' or 'clear')\n const put = (e, n, x, y, how) => { const o = objectOf(e, n); if (o) raster.object(o, x, y, how); };\n // what a title's painters (titles/<title>/paint.js) paint the model with\n title.model = { raster, pen, cap, keyPanel, print, put };\n const simple = (name, draw) => (e, args, step) => {\n let { fixed, rest } = inputs(e, name, args);\n const words = rest.map(r => typeof r === 'object' ? r.string : r).join(' ');\n e.emit(describe(name, fixed, e, rest.length ? words : undefined, z => e.mem[Z(z)]));\n rest = rest.map(r => typeof r === 'object' ? r.string : r);\n draw?.(e, fixed, rest);\n };\n // $641B: A $80 asks for an arrow, $B1 to $B9 a digit from 1, any other a letter from A. The\n // key chosen is then confirmed with return, or taken back with delete or the left arrow.\n // Gives X the key's place from 0, Y twice that, and A the key, its high bit set from 'A' up.\n // Animal Rescue's leaves the carry set for a letter ($6572); Nature Park's clears it ($5A56).\n // Nature Park's $58DA, ask-escape, also takes escape, at either key, and gives A 27 and the\n // carry set, and X the keyboard's byte for it, $9B, as the key read left it ($5A58, a jump into\n // the middle of a BIT that leaves only SEC and RTS).\n const letterCarry = !title.map.askClearsCarry;\n const asking = name => (e, args, step) => {\n if (e.waitingOn !== step) inputs(e, name, args);\n const mode = e.waitingOn === step ? e.askMode : e.a;\n e.askMode = mode;\n const arrows = [KEY.left, KEY.right, KEY.down, KEY.up];\n if (mode === 0x80 && e.waitingOn !== step) keyPanel(0);\n const r = waiting(e, step, name, [], undefined, k => {\n if (name === 'ask-escape' && k === KEY.escape) { e.a = e.flags(27); e.x = 0x9b; e.c = 1; e.asked = null; return true; }\n if (e.asked === null) {\n let place = -1, key = k;\n if (mode === 0x80) { place = arrows.indexOf(k); key = 0xdb + place; if (place >= 0) keyPanel(place + 1); }\n else if (mode >= 0xb1 && mode < 0xba) { if (k >= 0x31 && k <= (mode & 0x7f)) place = k - 0x31; }\n else { key = k & 0x5f; if (key >= 0x41 && key <= (mode & 0x5f & 0x7f)) { place = key - 0x41; key |= 0x80; } }\n if (place >= 0) { e.asked = { place, key }; if (name === 'ask-mode') quietly(e, e.askHooks?.chose?.(place)); }\n return false;\n }\n if (k === KEY.return) { e.x = e.asked.place; e.y = 2 * e.x; e.a = e.asked.key; e.c = letterCarry && e.a >= 0xc1 ? 1 : 0; return true; }\n if (k === KEY.delete || k === KEY.left) { if (name === 'ask-mode') quietly(e, e.askHooks?.undo?.(e.asked.place)); if (mode === 0x80) keyPanel(0); e.asked = null; }\n return false;\n });\n if (r !== 'wait') { e.mem[V.layout] = 0x22; e.emit(result(name, e)); } // $655E: panel 6, which sets $22\n return r;\n };\n\n const routines = {\n // graphics shown: $C01D reads with its high bit set, as a scene may test before it shows them\n show: simple('show', e => { title.text.showing = false; e.mem[0xc01d] = 0x80; }),\n // $573D: the text screen cleared ($7645) and shown ($5BCB), which the view draws and is no step\n 'text-screen': e => {\n Object.assign(title.text, { showing: true, page: textPage() });\n e.mem[0xc01d] = 0;\n e.inside++; e.emit({ step: 'text-screen' }); e.inside--;\n },\n picture: simple('picture', (e, f, [name]) => { const shapes = picturesOf(title)?.get(name.toUpperCase().replace(/_/g, ' ')); if (shapes) raster.picture(shapes); }),\n box: simple('box', e => raster.box(e.mem[V.layout], e.a, e.x, e.y)),\n // a panel sets the layout it clears to, as the original's panels do ($6299 and the rest)\n panel: simple('panel', (e, [n]) => {\n const p = PANELS[n];\n if (!p) return;\n e.mem[V.layout] = p.layout;\n raster.panel(p.rows[0], p.rows[1], p.fill);\n for (const y of p.more ?? []) raster.whiteLines(y);\n Object.assign(pen, { paper: p.paper, ink: p.ink, centre: true, spacing: 1, gap: p.gap, y: p.y });\n }),\n // A code's byte may be written {3:$63D8}, and a character {$4DA5}, for a byte the scene's code\n // writes into its own text before printing it: it is read from memory when the text is shown.\n // On the text screen the text goes into its characters, and the graphics stay as they are.\n text: (e, args) => {\n const words = args[0].string\n .replace(/\\{([0-9a-f]+):([^}]*)\\}/g, (all, code, bytes) => '{' + code + ':' + bytes.split(',').map(b => b.startsWith('$') ? e.mem[parseInt(b.slice(1), 16)].toString(16) : b).join(',') + '}')\n .replace(/\\{\\$([0-9A-Fa-f]{4})\\}/g, (all, at) => String.fromCharCode(e.mem[parseInt(at, 16)] & 0x7f));\n e.emit(describe('text', [], e, words));\n if (title.text.showing) { for (const c of textLayout(resolve(words, e.mem), title.text.pen)) if (title.text.page[c.row]?.[c.col]) title.text.page[c.row][c.col] = { ch: c.ch, inverse: c.inverse }; return; }\n print(e, words);\n },\n objects: simple('objects', e => { e.objectTable = e.x | e.y << 8; }),\n // an object drawn leaves the carry the original's routine left ($6B0F), which a scene may add in\n object: simple('object', e => { drawObject(e, 'whole'); objectCarry(e); }),\n 'object-keep': simple('object-keep', e => { drawObject(e, 'keep'); objectCarry(e); }),\n // $6863: the clear color shows the ground, from a buffer of its own, and no ground is kept\n 'object-mode': simple('object-mode', e => drawObject(e, 'clear')),\n // $76ED sets the pen to X and Y, and goes on into $76F3\n 'key-at': simple('key-at', e => { pen.x = e.x; pen.y = e.y; cap(String.fromCharCode(e.a & 0x7f)); }),\n key: simple('key', e => cap(String.fromCharCode(e.a & 0x7f))),\n 'white-lines': simple('white-lines', e => raster.whiteLines(e.y)),\n 'fill-rows': simple('fill-rows', e => raster.rows(e.a, e.x, e.y, e.c)),\n span: simple('span', e => raster.span(e.a, e.x, e.y, e.mem[Z(0x02)])),\n // a dot, which returns with A its place in its group of seven times 16, and its color ($5B45)\n dot: simple('dot', e => { raster.set(e.x, e.y, e.a); e.a = (e.x % 7) << 4 | e.a & 15; }),\n line: simple('line', e => raster.line(e.mem[Z(0x11)], e.mem[Z(0x00)], e.mem[Z(0x02)], e.mem[Z(0x01)], e.mem[Z(0x03)])),\n // $67B9 fills columns x to x + $0E, both ends, down $0F rows; $677E's four lines go from x to\n // x + $0E and from y to y + $0F\n rectangle: simple('rectangle', e => raster.rectangle(e.a, e.x, e.y, e.mem[Z(0x0e)] + 1, e.mem[Z(0x0f)])),\n 'rectangle-outline': simple('rectangle-outline', e => raster.outline(e.a, e.x, e.y, e.mem[Z(0x0e)] + 1, e.mem[Z(0x0f)] + 1)),\n flash: simple('flash'),\n // $5B4C: the color of a dot of the original's screen, from the screen model\n 'read-dot': (e, args) => { inputs(e, 'read-dot', args); e.emit(describe('read-dot', [], e)); e.a = e.flags(raster.get(e.x, e.y)); e.emit(result('read-dot', e)); },\n 'key-panel': simple('key-panel', e => keyPanel(e.a)), 'keep-span': simple('keep-span'), 'put-span': simple('put-span'), 'invert-span': simple('invert-span'),\n button: simple('button'),\n // a beep of 0 does nothing, and is no step (events.js)\n beep: (e, args) => { inputs(e, 'beep', args); if (!nothing('beep', e.a)) e.emit(describe('beep', [], e)); },\n // a sound's five bytes; a byte may be an address, for one the scene's code writes before it plays\n sound: (e, args) => e.emit(describe('sound', [], e, args.map(b => b.startsWith('$') ? e.mem[parseInt(b.slice(1), 16)].toString(16) : b).join(' '))),\n // PART3's own code, written at $E000, moves the picture a step to the left: drawn, and no step\n scroll: e => { raster.scroll(); e.inside++; e.emit({ step: 'scroll' }); e.inside--; },\n // Nature Park's PART3 at $9796: the dots from `left` to `right` of rows `top` to `bottom` copied\n // `by` rows down, from the bottom row up, so the rows at the top stay to be copied again:\n // drawing, and no step\n 'shift-down': (e, args) => {\n const [left, right, top, bottom, by] = args.map(Number);\n for (let r = bottom; r >= top; r--) for (let x = left; x <= right; x++) raster.set(x, r + by, raster.get(x, r));\n e.inside++; e.emit({ step: 'shift-down', left, right, top, bottom, by }); e.inside--;\n },\n // a part's title marks where the original's loader starts a part\n part: simple('part'),\n\n // the waits, $5C23, $5C08 and $5C20: the space bar, or for the last escape too, which it\n // returns with the carry set\n wait: (e, args, step) => waiting(e, step, 'wait', [], undefined, k => k === KEY.space && (e.a = 32, e.c = 0, true)),\n 'wait-erase': (e, args, step) => waiting(e, step, 'wait-erase', [], undefined, k => k === KEY.space),\n 'wait-or-escape': (e, args, step) => {\n const r = waiting(e, step, 'wait-or-escape', [], undefined, k => (k === KEY.space || k === KEY.escape) && (e.c = k === KEY.escape ? 1 : 0, e.a = k, true));\n if (r !== 'wait') e.emit(result('wait-or-escape', e));\n return r;\n },\n\n // $641B, the ask for a key, above\n ask: asking('ask'),\n // $6415: the same, and the problem draws the choice as it is made, which is left to the view\n 'ask-mode': asking('ask-mode'),\n 'ask-escape': asking('ask-escape'),\n\n // $60C2: the seed times 259, divided by 65535 over n. The seed is at $6131 and $6130 says it is\n // in use; a pilot sets it at the first call, as it does on the original.\n random: (e, args) => {\n const { fixed } = inputs(e, 'random', args);\n e.emit(describe('random', fixed, e));\n const n = e.a;\n const { at, used } = title.map.seed;\n if (e.mem[used] === 0xff && title.seed !== undefined) { e.mem[at] = title.seed & 0xff; e.mem[at + 1] = title.seed >> 8; }\n let seed = e.mem[at] | e.mem[at + 1] << 8;\n seed = (seed * 259) & 0xffff;\n e.mem[at] = seed & 0xff; e.mem[at + 1] = seed >> 8; e.mem[used] = n;\n const q = n ? Math.floor(0xffff / n) : 0xffff;\n e.a = Math.floor(seed / q) & 0xff; e.c = 0;\n e.emit(result('random', e));\n },\n\n multiply: (e, args) => { inputs(e, 'multiply', args); e.emit(describe('multiply', [], e)); const p = e.a * e.x; e.a = p & 0xff; e.x = p >> 8; e.emit(result('multiply', e)); },\n divide: (e, args) => { inputs(e, 'divide', args); e.emit(describe('divide', [], e)); const d = e.x | e.y << 8, n = e.a || 1; e.a = Math.floor(d / n) & 0xff; e.x = d % n; e.emit(result('divide', e)); },\n\n // a problem, written by hand for the remake (its title's problems.js). It runs\n // as its own script or function and returns here; the carry comes back clear, as it does on\n // the original when the problem loaded. Nature Park's ($4DC3) takes the number of times from X\n // for a problem from the Problems menu, in place of the teacher's, until the problem is done.\n problem: (e, args, step) => {\n if (!e.problem) {\n inputs(e, 'problem', args); e.emit(describe('problem', [], e)); e.mem[V.practice] = e.c ? 0x80 : 0;\n e.repeats = e.mem[V.repeats];\n if (title.map.countInX && e.c) e.mem[V.repeats] = e.x;\n const run = title.problems?.[e.a];\n if (!run) throw new Error('problem ' + e.a + ' is not written yet');\n // the problem's file, where the loader puts it, for the tables a problem reads from it\n const file = title.disk && codeFiles(title.map, Object.values(title.disk.volumes)[0]).find(f => f.name === 'PROB' + e.a);\n if (file) e.mem.set(file.bytes, file.origin);\n e.problem = run(helpers(e, routines));\n }\n if (!e.problem.next().done) return 'wait';\n e.problem = null; e.c = 0; e.mem[V.repeats] = e.repeats; e.emit(result('problem', e));\n },\n\n // $5D66 and $5DA9: a key, as the title's own loops read it; A the key, the carry set for escape\n 'read-key': (e, args, step) => {\n if (e.waitingOn !== step) { e.waitingOn = step; e.asked = null; }\n const k = e.key();\n if (k === undefined) return 'wait';\n if (title.visit?.[k]) { e.visit(k); return 'wait'; }\n e.waitingOn = null;\n if (k === KEY.menu && title.menu) e.leave(...title.menu);\n e.a = e.flags(k & 0x7f); e.c = k === KEY.escape ? 1 : 0;\n e.emit(result('read-key', e));\n },\n\n // The loader's splash, before PART0 runs: TITLE, a double hi-res picture, until a key. The\n // original's engine is not in yet, so it is no step; the view draws it.\n splash: (e, args, step) => {\n if (e.waitingOn !== step) { e.inside++; e.emit({ step: 'splash' }); e.inside--; e.waitingOn = step; }\n if (e.key() === undefined) return 'wait';\n e.waitingOn = null;\n },\n // Nature Park's $4C00: both halves of the graphics screen cleared to black, which is no step\n 'clear-screen': e => {\n for (const row of raster.dots) row.fill(0);\n e.inside++; e.emit({ step: 'clear-screen' }); e.inside--;\n },\n\n // A delay the original made by counting X and Y down, given as the milliseconds it took: no\n // step, and nothing changes but the registers, both 0 when the count is done. The page waits.\n pause: (e, [ms]) => { e.x = 0; e.y = 0; e.flags(0); e.inside++; e.emit({ step: 'pause', ms: +ms }); e.inside--; },\n\n // End, on the Main Menu: ProDOS's quit, through $0200, and the title is over\n quit: e => { e.ended = true; },\n\n // a part of the title not written yet: the run stops here and says which\n unwritten: (e, [what]) => { throw new Error('not written yet: ' + (what?.string ?? what)); },\n\n // a jump or a call into PART0's own code, which the title's scripts have: the title's\n // `entries` say where each address is\n 'goto-engine': (e, [at]) => { const to = title.entries?.[at]; if (!to) throw new Error('no script for ' + at); e.enter(...to); },\n 'call-engine': (e, [at]) => { const to = title.entries?.[at]; if (!to) throw new Error('no script for ' + at); e.stack.push({ name: e.name, pc: e.pc }); e.enter(...to); },\n\n // the loader: part A's script, from its start, after the title has shown it\n // (and, with the disk out of its drive, it comes back, as the loader's read does with its error)\n 'load-part': (e) => {\n const volume = Object.keys(title.disk?.volumes ?? {})[0]?.toUpperCase();\n if (title.files?.out?.has(volume)) { e.a = e.flags(0x45); e.c = 1; return; }\n e.stack = []; e.enter('part' + e.a, undefined, true);\n },\n\n // Nature Park's settings written to its own disk through the loader ($08E9): ProDOS's\n // SET_FILE_INFO, answered from the disks as @moonbase-machines/apple2e/mli.js answers the original's call: the\n // write-protect error ($2B) with the tab on, no volume ($45) with the disk out of its drive,\n // and the carry set for either; clear when it goes through\n 'write-settings': e => {\n const files = title.files ??= new Files(title.disk), volume = Object.keys(title.disk.volumes)[0].toUpperCase();\n const err = files.out?.has(volume) ? 0x45 : files.disks[volume] === 'protected' ? 0x2b : 0;\n e.a = e.flags(err); e.c = err ? 1 : 0;\n },\n };\n return routines;\n}\n", "// A problem, rewritten for the remake: a generator function that takes the problem's helpers\n// and yields whenever it waits for a key. Its steps are the same routines the scripts use, so\n// they give the same events; a problem's own drawing routines are steps of their own, named in\n// its title's map (`problems`), which the view draws however it likes.\n//\n// function* (p) { yield* p.call('text', 'Hello'); const { x } = yield* p.call('ask', 202); }\nimport { describe } from './events.js';\n\nexport function helpers(e, routines) {\n const zero = e.title.map.vars.zero;\n // a step: run its routine, and wait for as long as it waits\n function* call(name, ...args) {\n const token = { words: [name] }; // what the view reads to know what the problem waits for\n const words = args.map(a => typeof a === 'string' && name === 'text' ? { string: a } : typeof a === 'number' ? String(a) : a);\n for (;;) {\n const r = routines[name](e, words, token);\n if (r !== 'wait') return { a: e.a, x: e.x, y: e.y, c: e.c };\n yield 'wait';\n }\n }\n // a problem's own drawing routine: its event, and what it leaves for the view\n // and the title's painter for it, if it has one (titles/<title>/paint.js), paints it into the\n // model of the original's screen\n const drawn = (name, a = 0, x, y) => { e.a = a & 0xff; if (x !== undefined) e.x = x & 0xff; if (y !== undefined) e.y = y & 0xff; e.title.paint?.[name]?.(e.title.model, e); e.emit(describe(name, [], e, undefined, z => e.mem[z + zero], a => e.mem[a])); };\n // A key, for a problem that reads keys itself: it waits, and the view shows what `kind` of wait\n // it is, 'wait' for the space bar's button or 'ask' for the keys e.askMode asks for.\n function* key(kind = 'wait') {\n const token = { words: [kind] };\n for (;;) {\n const k = e.key();\n // control-E: the Main Menu, from the key reader, as at any key the original read\n if (k === 5 && e.title?.menu) e.leave(...e.title.menu);\n // control-E or control-T in Nature Park: its menus, and back to waiting here\n if (e.title?.visit?.[k]) { e.visit(k); e.waitingOn = token; yield 'wait'; continue; }\n if (k !== undefined) { e.waitingOn = null; return k; }\n e.waitingOn = token;\n yield 'wait';\n }\n }\n // steps done inside a routine of the problem's own: drawn, and no steps of the transcript\n function* inside(run) { e.inside++; try { return yield* run; } finally { e.inside--; } }\n return { e, mem: e.mem, call, drawn, key, inside };\n}\n", "import { objects as m } from '@moonbase-machines/vector';\nexport const { carry, decode, put, tables } = m;", "// The original's screen, dot for dot, for the scenes that read it back. PROB6 steers Helen's car by\n// the colors of the dots ahead of it, so the remake must know what the original's screen shows\n// there, whatever the view draws. The raster is 192 rows of 140 colors, painted by each step as the\n// original's routines paint the double hi-res screen, and read by read-dot. The view never sees it.\nimport { screen, draw, line as lineDots } from '@moonbase-machines/vector/draw.js';\nimport { put } from '@moonbase-machines/vector/objects.js';\nimport { width, dots } from '@moonbase-machines/vector/font.js';\nimport { LAYOUT } from './layout.js';\n\nexport class Raster {\n constructor() { this.dots = screen(15); this.kept = null; } // $5BE1 clears the screen white\n // Nature Park's menus over a game: the screen kept and cleared to black ($4C5D), and put back\n // as it was ($4CFB), with what an object kept under it\n keepScreen() { this.screenKept = { dots: this.dots, kept: this.kept }; this.dots = screen(0); }\n putScreen() { if (this.screenKept) ({ dots: this.dots, kept: this.kept } = this.screenKept); this.screenKept = null; }\n // Animal Rescue's PART3 at $E000: rows 19 to 115 moved two bytes to the left in each half of the\n // screen. A row is 560 bits, aux and main bytes in turn, seven bits a byte and four a dot; bytes\n // 2 to 73 of the row, bits 14 to 517, take the bits 28 on, so the dots move seven, the ends half\n // way through a dot, and bytes 74 to 79 stay\n scroll() {\n for (let y = 19; y <= 115; y++) {\n const row = this.dots[y], bits = [];\n for (const c of row) bits.push(c >> 3 & 1, c >> 2 & 1, c >> 1 & 1, c & 1);\n for (let b = 14; b < 518; b++) bits[b] = bits[b + 28];\n for (let x = 0; x < 140; x++) row[x] = bits[4 * x] << 3 | bits[4 * x + 1] << 2 | bits[4 * x + 2] << 1 | bits[4 * x + 3];\n }\n }\n set(x, y, c) { if (x >= 0 && x < 140 && y >= 0 && y < 192) this.dots[y][x] = c & 15; }\n get(x, y) { return x >= 0 && x < 140 && y >= 0 && y < 192 ? this.dots[y][x] : 0; }\n // a run of a row, both ends drawn ($7947)\n span(c, left, right, y) { for (let x = left; x <= right; x++) this.set(x, y, c); }\n // rows filled across the screen, with white edge columns when `edges` ($5F4B)\n rows(c, count, first, edges) {\n for (let y = first; y < first + count; y++) { this.span(c, 0, 139, y); if (edges) { this.set(0, y, 15); this.set(139, y, 15); } }\n }\n whiteLines(y) { this.span(15, 0, 139, y); this.span(15, 0, 139, y + 1); }\n // $65D2: the window outlined in black and filled, and the two boxes, each two white rows and its\n // rows in its color with white edges; $80 leaves a part as it is\n box(layout, window, one, two) {\n const [bottom, top1, top2] = LAYOUT[layout] ?? LAYOUT[0x32];\n if (window !== 0x80) {\n this.span(0, 1, 138, 1); this.span(0, 1, 138, bottom - 1);\n for (let y = 2; y < bottom - 1; y++) { this.set(1, y, 0); this.set(138, y, 0); this.span(window, 2, 137, y); }\n }\n if (one !== 0x80) { this.whiteLines(top1); this.rows(one, top2 - top1 - 2, top1 + 2, true); }\n if (two !== 0x80) { this.whiteLines(top2); this.rows(two, 190 - top2 - 2, top2 + 2, true); }\n }\n // a panel: its box's two white rows and its rows in its color, with white edges\n panel(top, bottom, c) { this.whiteLines(top); this.rows(c, bottom - top - 1, top + 2, true); }\n picture(shapes) { draw(shapes, this.dots); }\n rectangle(c, x, y, w, h) { for (let r = y; r < y + h; r++) this.span(c, x, x + w - 1, r); }\n outline(c, x, y, w, h) { this.span(c, x, x + w - 1, y); this.span(c, x, x + w - 1, y + h - 1); for (let r = y; r < y + h; r++) { this.set(x, r, c); this.set(x + w - 1, r, c); } }\n line(c, x0, y0, x1, y1) { for (const [x, y] of lineDots(x0, y0, x1, y1)) this.set(x, y, c); }\n // An object: 'keep' keeps the ground under it, so that object 0 puts it back, and its clear\n // color shows the ground ($686F); 'clear' shows the ground and keeps none ($6863); 'whole' puts\n // it down whole, its clear color and all ($686D)\n object(o, x, y, how) {\n if (how === 'keep') this.kept = { x, y, rows: o.rows.map((row, dy) => row.map((_, dx) => this.get(x + dx, y + dy))) };\n put(this.dots, o, x, y, how === 'whole');\n }\n restore() { const k = this.kept; if (!k) return; k.rows.forEach((row, dy) => row.forEach((c, dx) => this.set(k.x + dx, k.y + dy, c))); }\n // a glyph's cell painted, ink on its dots and paper on the rest, `h` rows a glyph row, as many\n // glyph rows as the line is high; the cell takes in the spacing after the glyph, `space`\n glyph(ch, x, y, ink, paper, h = 1, height = 9, space = 0) {\n const w = width(ch);\n // a spacer, a code below $20, is that many dots of the paper\n if (ch.charCodeAt(0) < 0x20) { for (let gy = 0; gy < Math.min(9, height); gy++) for (let gx = 0; gx < w; gx++) for (let k = 0; k < h; k++) this.set(x + gx, y + gy * h + k, paper); return w; }\n const on = new Set(dots(ch).map(([gx, gy]) => gx + ',' + gy));\n for (let gy = 0; gy < Math.min(9, height); gy++) for (let gx = 0; gx < w + space; gx++) for (let k = 0; k < h; k++) this.set(x + gx, y + gy * h + k, on.has(gx + ',' + gy) ? ink : paper);\n return w;\n }\n}\n", "import { draw as m } from '@moonbase-machines/vector';\nexport const { crossings, draw, fill, inside, line, outline, screen, spans, under } = m;", "// The remake in the browser: one player for every title. The page gives it the title's folder and its game's data;\n// the player makes its part of the page, the stage the game is drawn on and the options line under it with the\n// game's status, loads the title (load.js), puts its stylesheet in the page where it has one, and hands the game to\n// its engine: the remake's own for a title of scenes, 'card' or 'vector' (scenes.js), or the title's own, a module in\n// its folder (its title.js `engine`), given the same. A failure is said in the status line.\n//\n// await play({ title, data, root, disk, preview, words, watch, claim, pace, route, mini, roms })\n// title the title's folder, an absolute URL\n// data its game's data, an absolute URL (for a title of its own engine, the folder its data is in)\n// root the page's section the player is made in\n// disk the title's player's disk (disk/disk.js), opened before the player starts\n// preview the preview's build: what only it has may be used\n// words the page's words the player shows: { printer: { line, print, tear } }\n// watch called with the game, { engine, press, quick }, for a page that follows it\n// claim k => true to take a key of the player's before the game does\n// pace how much of the original's waits: 1 all (the default), 0 none, between a part of each; read at\n// each wait\n// and what only a workshop has, given by its pages, never looked for here:\n// route a route to play first, { route, keys }: its keys, and the pilots' key handling (expand, give,\n// petscii, pollsAt)\n// mini a mini view for a title with an `inset`, (at, { memory }) => { mode(m) }\n// roms the makers' ROMs this machine has: { chargen } for a Commodore 64 title's characters\n//\n// What the engine is handed, its own engine's or the remake's, `game`: { title, scripts, disk, folder, stage,\n// options, status, fail, kept, preview, words, ...the page's options }; `stage` is its to draw in, `options` the\n// line its own controls go on, before the status.\nimport { loadTitle } from './load.js';\nimport { play as scenes } from './scenes.js';\n\nexport async function play(options) {\n const { title: folder, data, root, disk: kept, preview = false, words } = options;\n root.classList.add('remake');\n root.innerHTML = '<div class=\"stage\"></div><p class=\"options\"><span id=\"status\">Loading.</span></p>';\n const stage = root.querySelector('.stage'), line = root.querySelector('.options'), status = root.querySelector('#status');\n const fail = err => { status.textContent = 'The remake stopped: ' + err.message; status.className = 'error'; console.error(err); };\n try {\n // ?fixed: the title with its bugs fixed, for one that has such a version (its title.js `fixed`)\n const fixed = new URLSearchParams(location.search).has('fixed');\n const { title, scripts, disk } = await loadTitle(folder, { data, fixed });\n title.disk = disk;\n // the title's own styles, where it has them (its title.js `style`, a file in its folder), in place before it\n // draws by them\n if (title.style && !document.querySelector(`link[data-title=\"${title.slug}\"]`)) {\n const link = Object.assign(document.createElement('link'), { rel: 'stylesheet', href: new URL(title.style, folder).href });\n link.dataset.title = title.slug; document.head.append(link);\n await new Promise(done => { link.onload = link.onerror = done; });\n }\n const game = { ...options, title, scripts, disk, folder, data, stage, options: line, status, fail, kept, preview, words, fixed };\n await (title.own ?? { play: scenes }).play(game);\n } catch (err) { fail(err); }\n}\n", "// A title of scenes played, the remake's own engine (main.js hands it the game): its scripts on the engine, its events\n// drawn by the view, on the stage; its controls on the options line, the sound, the old style text, a C64 title's\n// printer, the bugs fixed where the title has a version so, the mini view where the page gives one. A run's events\n// are drawn one after another, with a moment for each sound and flash, so that what the original took time over takes\n// time here too.\nimport { Printer, paper } from '@moonbase-machines/c64/printer.js';\nimport { makeEngine } from './load.js';\nimport { Speaker } from '../audio.js';\nimport { SID } from '@moonbase-machines/c64/sid.js';\nimport { matrixOf } from '@moonbase-machines/c64/kernal.js';\nimport { standIn } from '@moonbase-machines/c64/rom.js';\nimport { withSaves, keepSaves } from '@moonbase-machines/apple2e/saves.js';\nimport { Drive } from '@moonbase-machines/c64/drive.js';\nimport { keepDrive } from '@moonbase-machines/c64/saves.js';\nimport { paperBox, phoneKeys, KEYS_MARKUP } from '../parts.js';\nimport { View } from './view.js';\nimport { CardView } from './card-view.js';\nimport { C64View } from './c64-view.js';\n\nexport async function play(game) {\n const { title, scripts, disk, root, stage, status, fail, kept, words, fixed } = game;\n root.classList.add('game'); // (the screen of a machine: the stage the game's own shape, player.css)\n stage.innerHTML = `<svg id=\"screen\" preserveAspectRatio=\"xMidYMid meet\" tabindex=\"0\" aria-label=\"The game's screen\"></svg>`;\n status.insertAdjacentHTML('afterend', `${KEYS_MARKUP}<label><input type=\"checkbox\" id=\"sound\"> Sound</label><label><input type=\"checkbox\" id=\"old-style\"> Old style text</label><label hidden><input type=\"checkbox\" id=\"printer\" checked> Printer</label><label hidden title=\"The game with its bugs fixed: it starts again\"><input type=\"checkbox\" id=\"fixed\"> Bugs fixed</label><label hidden>Mini view <select id=\"mini\"><option value=\"\">Off</option><option value=\"live\">Live</option><option value=\"pictures\">Pictures</option></select></label>`);\n root.append(paperBox(words.printer));\n const $ = id => root.querySelector('#' + id);\n const svg = $('screen'), soundBox = $('sound');\n phoneKeys(root, stage);\n\ntry {\n // the choice of the fixed version, where there is one: the page again, with ?fixed or without\n const fixedBox = $('fixed');\n if (fixedBox && title.fixed) {\n fixedBox.checked = fixed; fixedBox.parentElement.hidden = false;\n fixedBox.addEventListener('change', () => { const u = new URL(location.href); if (fixedBox.checked) u.searchParams.set('fixed', ''); else u.searchParams.delete('fixed'); location.href = u.href.replace('fixed=&', 'fixed&').replace(/fixed=$/, 'fixed'); });\n }\n // its view's own drawing, for a title that has one (its title.js `view`, load.js)\n const extra = title.viewSteps ?? {};\n // a Commodore 64's character ROM, for its view: Commodore's where the page gives them (`roms`), else moonbase's own\n const chargen = disk.kind === 'c64' ? game.roms?.chargen ?? standIn().chargen : null;\n\n // A printer on device 4, for a Commodore 64 title (@moonbase-machines/c64/printer.js): on unless its box is off,\n // what it prints drawn below the screen as a sheet of paper, until it is torn off\n if (disk.kind === 'c64') {\n const box = $('printer'), sheet = $('paper'), shown = $('paper-box');\n try { box.checked = localStorage.getItem('remake-printer') !== '0'; } catch {}\n box.parentElement.hidden = false;\n const printer = title.printer = new Printer({ on: box.checked });\n box.addEventListener('change', () => { printer.on = box.checked; try { localStorage.setItem('remake-printer', box.checked ? '1' : '0'); } catch {} });\n printer.changed = () => { shown.hidden = !printer.lines.length; if (printer.lines.length) paper(sheet, printer, chargen); };\n $('tear').addEventListener('click', () => printer.tear());\n $('print-paper').addEventListener('click', () => window.print()); // (the sheet alone: its print style)\n }\n // what the game saves, on the player's disk: an Apple title's data disk (@moonbase-machines/apple2e/saves.js), a\n // Commodore 64 title's drive (@moonbase-machines/c64/saves.js, the drive card.js puts on the bus)\n title.disk = withSaves(disk, kept);\n if (disk.kind === 'c64') keepDrive(title.drive = new Drive(Uint8Array.from(atob(disk.image), ch => ch.charCodeAt(0))), kept);\n const engine = makeEngine(title, scripts);\n if (title.files) keepSaves(disk, title.files, kept);\n const queue = [];\n // The view, and every event it has drawn, so that it can be drawn again from the start when\n // the old style text is turned on or off. The choice is kept in this browser.\n const oldStyleBox = $('old-style'), history = [];\n const remember = { get() { try { return localStorage.getItem('remake-old-style') === '1'; } catch { return false; } }, set(v) { try { localStorage.setItem('remake-old-style', v ? '1' : '0'); } catch {} } };\n oldStyleBox.checked = remember.get() || new URLSearchParams(location.search).has('old-style'); // ?old-style, for a screenshot\n let onView = null; // (the mini view's, given each view made)\n const makeView = () => { svg.replaceChildren(); const v = disk.kind === 'c64' ? new C64View(svg, { engine, chargen }) : title.engine === 'card' ? new CardView(svg, { engine, inset: game.mini ? title.inset : null }) : new View(svg, { disk, volume: Object.keys(disk.volumes)[0], engine, extra }); v.oldStyle = oldStyleBox.checked; onView?.(v); return v; };\n let view = makeView();\n engine.on(e => queue.push(view.snapshot({ ...e })));\n // The mini view, where the page gives one (`mini`) and the title has a place for it (its title.js `inset`): Off,\n // Live or Pictures, the choice kept in this browser; shown in the band at the top of the screen while the band is\n // there. A picture only: the game's screen otherwise as it is\n const miniBox = $('mini');\n if (title.inset && game.mini) {\n miniBox.parentElement.hidden = false;\n try { miniBox.value = localStorage.getItem('remake-mini') ?? ''; } catch {}\n const { top, bottom, view: [left, right] } = title.inset, at = document.createElement('div');\n at.className = 'mini'; at.hidden = true;\n Object.assign(at.style, { left: `${left / 5.6}%`, top: `${top / 3.84}%`, width: `${(right - left) / 5.6}%`, height: `${(bottom - top + 1) / 3.84}%` });\n svg.parentElement.append(at);\n const mini = await game.mini(at, { memory: () => engine.mem });\n // (each view's painting followed by the mini view shown or not, as the band is there or not)\n onView = v => { v.insetOn = !!miniBox.value; const prompts = v.prompts.bind(v); v.prompts = () => { prompts(); at.hidden = !(miniBox.value && v.banded); }; };\n onView(view);\n const show = () => { view.insetOn = !!miniBox.value; mini.mode(miniBox.value); view.prompts(); };\n miniBox.addEventListener('change', () => { try { localStorage.setItem('remake-mini', miniBox.value); } catch {} show(); });\n show();\n }\n oldStyleBox.addEventListener('change', () => {\n remember.set(oldStyleBox.checked);\n view = makeView();\n for (const e of history) view.apply(e);\n view.prompts();\n });\n\n // the sound: the original's are off until the teacher turns them on, at the engine's sound flag.\n // A title that keeps the original's time (a card title's, Engine.time) clicks the speaker as\n // the original did, and the clicks are played as the emulator plays them (audio.js), the\n // box the sound's on and off.\n const speaker = engine.timed ? new Speaker() : null;\n if (speaker) soundBox.checked = true;\n const hear = () => { if (disk.kind !== 'c64') speaker?.feed(soundBox.checked ? engine.clicks : [], engine.cycles); engine.clicks.length = 0; };\n const V = title.map?.vars ?? { sound: 0, soundOn: 0 };\n let audio = null;\n const tone = (from, to, ms) => {\n if (!(engine.mem[V.sound] & V.soundOn)) return;\n audio ??= new AudioContext();\n const o = audio.createOscillator(), g = audio.createGain(), t = audio.currentTime;\n o.type = 'square'; o.frequency.setValueAtTime(from, t); o.frequency.linearRampToValueAtTime(to, t + ms / 1000);\n g.gain.setValueAtTime(0.06, t); g.gain.linearRampToValueAtTime(0, t + ms / 1000);\n o.connect(g).connect(audio.destination); o.start(t); o.stop(t + ms / 1000);\n };\n const pitch = p => 16000 / (p + 8);\n soundBox.addEventListener('change', () => { if (!speaker) engine.mem[V.sound] = soundBox.checked ? V.soundOn : 0; });\n\n // how long each step takes to be seen or heard, in milliseconds\n const PACE = { sound: 220, beep: 60, 'flash-box': 60, flash: 250, object: 30, 'object-keep': 30 };\n const pace = () => game.pace ?? 1; // (the original's waits, a part of each: 1 all, 0 none; read at each wait)\n let drawing = false;\n const sleep = ms => new Promise(r => setTimeout(r, ms));\n async function runs() {\n if (drawing) return;\n drawing = true;\n try {\n for (;;) {\n const r = engine.run();\n hear();\n // the original took time here, a disk's read or a wait it counted out: the screen as it\n // is, for that long (card.js)\n if (r === 'pace') {\n for (const e of queue.splice(0)) { history.push(e); view.apply(e); }\n view.prompts(); if (!quick && pace()) await sleep(engine.delay * pace()); engine.delay = 0;\n continue;\n }\n engine.delay = 0;\n while (queue.length) {\n const e = queue.shift();\n history.push(e);\n view.apply(e);\n if (quick) continue; // (at full speed: no sound, no wait)\n if (e.step === 'sound') { const [end, start] = e.words.split(' ').map(h => parseInt(h, 16)); tone(pitch(start), pitch(end), 180); }\n if (e.step === 'beep') tone(pitch(e.a & 31) * 2, pitch(e.a & 31) * 2, 50);\n if (!pace()) continue; // (none of the original's waits: its sounds still)\n if (PACE[e.step]) await sleep(PACE[e.step] * pace());\n if (e.step === 'pause') await sleep(e.ms * pace()); // a delay the original counted out\n }\n view.prompts();\n status.textContent = r === 'end' ? 'The end.' : 'Waiting for a key.';\n if (!engine.keys.length || r === 'end') break;\n }\n } catch (err) { fail(err); }\n drawing = false;\n }\n\n // keys as the Apple's keyboard gave them\n // (a Commodore 64's in PETSCII: its cursor keys, DEL and RUN/STOP, and its letters capitals)\n const KEYS = disk.kind === 'c64'\n ? { ArrowLeft: 157, ArrowRight: 29, ArrowDown: 17, ArrowUp: 145, Enter: 13, Backspace: 20, Delete: 20, Escape: 3, ' ': 32 }\n : { ArrowLeft: 8, ArrowRight: 21, ArrowDown: 10, ArrowUp: 11, Enter: 13, Backspace: 127, Delete: 127, Escape: 27, ' ': 32 };\n let quick = false;\n const press = k => { engine.press(k); audio?.resume(); speaker?.start(); if (disk.kind !== 'c64') runs(); };\n // (a page that follows the game, the island's, given it: the engine, its memory, a key pressed as the\n // player presses one, and `quick(on)`, the game at full speed, none of its waits, to jump ahead in it)\n game.watch?.({ engine, press, quick: on => { quick = on; } });\n // A game that goes on without waiting for keys, as Nature Park's truck: each turn of its loop is\n // a step `tick`, which takes a key or none. A turn passes every 100 milliseconds, as the\n // original's took, with the key pressed since the last or still held, as the Apple's keyboard\n // told the game a key was down.\n const ticking = () => engine.waitingOn?.words?.[0] === 'tick';\n let held = null, tapped = null;\n setInterval(() => {\n if (!ticking() || drawing || engine.keys.length) return;\n const k = tapped ?? held ?? -1; tapped = null;\n press(k);\n }, 100);\n window.addEventListener('keydown', e => {\n if (e.metaKey || e.altKey) return;\n const k = e.ctrlKey ? (/^[a-z]$/i.test(e.key) ? e.key.toUpperCase().charCodeAt(0) & 0x1f : undefined) : KEYS[e.key] ?? (e.key.length === 1 ? (disk.kind === 'c64' ? e.key.toUpperCase() : e.key).charCodeAt(0) : undefined);\n if (k === undefined) return;\n e.preventDefault();\n if (ticking()) { tapped = held = k; return; }\n // a Commodore 64's key held down in its keyboard's matrix, which its KERNAL scans and repeats\n // as long as it is held, as the original's did (@moonbase-machines/c64/kernal.js); a character typed only\n // with shift into the buffer\n const m = disk.kind === 'c64' && !e.ctrlKey && matrixOf(k);\n if (m) { if (!e.repeat) { engine.clock.held = { ...m, key: e.key }; audio?.resume(); speaker?.start(); } return; }\n if (!e.repeat && !game.claim?.(k)) press(k); // (the player's key offered to the page first: `claim`, main.js)\n });\n window.addEventListener('keyup', e => {\n held = null;\n const h = engine.clock?.held;\n if (h?.key === e.key) { if (h.seen) engine.clock.held = null; else h.up = true; }\n });\n svg.addEventListener('click', e => { const key = e.target.closest('.key')?.dataset.key; if (key) press(+key); });\n svg.focus();\n // A Commodore 64 title runs on the clock, as the original did, waiting for a key or not: a\n // sixtieth of a second of the original's cycles at a time (the engine's run stops at each 16 ms of\n // them), its raster and its interrupt at the time they come (card.js), and the screen\n // painted after each. And the SID, its writes played a sixtieth of a second at a time, as the\n // emulator plays a frame's (original.js).\n if (disk.kind === 'c64') {\n // a route the page gives (`route`, a workshop's pilots' route) played first as the pilots play it, each key when\n // the game waits for one, off the clock, so that it goes where it went on both sides; then the game goes on as\n // usual\n if (game.route) {\n const { route, name: routeName, keys: { expand, give, petscii, pollsAt } } = game.route;\n title.seed = route.seed; // (RND's numbers from the route's seed, as the pilots have them)\n if (route.printer && title.printer) { title.printer.on = true; $('printer').checked = true; }\n status.textContent = 'Playing the route ' + routeName + '.';\n // (a key behind the one pressed goes into the KERNAL's buffer, as the pilots hold a key)\n const side = { press: k => engine.press(k), also: k => { const m = engine.mem, put = v => { if (m[0xc6] < 10) { m[0x277 + m[0xc6]] = v; m[0xc6]++; } }; if (engine.keys.length) put(engine.keys.shift()); put(k); } };\n const go = () => { let r; do { engine.delay = 0; r = engine.run(); } while (r === 'pace'); queue.length = 0; };\n go();\n for (const [i, [k]] of expand(route.keys).entries()) { give(side, k, petscii); engine.polls = pollsAt(route, i + 1) ?? undefined; go(); }\n engine.polls = undefined; view.prompts();\n }\n engine.sid = []; engine.clock = { irq: 0, ahead: [], since: 0 };\n let sid = null, from = null, sent = 0, stopped = false;\n status.textContent = 'Playing.';\n setInterval(() => {\n engine.delay -= 1000 / 60; // a load's time, or the last run's\n if (!stopped && !engine.ended && engine.delay < 16) {\n engine.delay = Math.max(0, engine.delay);\n // a key of ?keys when the game is waiting for one, two seconds at least after the last, as\n // a player would press them (a wait the game counts out goes on by itself on the clock)\n if (engine.clock.ahead.length && engine.idle > (engine.routines.polls ?? 200) && !engine.keys.length && ++engine.clock.since > 120) { engine.press(engine.clock.ahead.shift()); engine.clock.since = 0; }\n try { engine.run(); queue.length = 0; view.prompts(); } catch (err) { stopped = true; fail(err); }\n if (engine.ended) status.textContent = 'The end.';\n }\n if (speaker?.node && soundBox.checked) {\n sid ??= new SID(speaker.rate); from ??= performance.now();\n const n = Math.floor((performance.now() - from) / 1000 * speaker.rate) - sent;\n if (n > 0) { const wave = sid.render(n, engine.sid.map(([, r, v]) => [0, r, v])); sent += n; speaker.node.port.postMessage(wave, [wave.buffer]); }\n }\n engine.sid.length = 0;\n }, 1000 / 60);\n }\n // ?keys=space,space,right,return presses keys at the start, to go straight to a scene\n const start = new URLSearchParams(location.search).get('keys');\n if (start) for (const k of start.split(',')) { const a = { space: 32, return: 13, escape: 27, delete: 127, left: 8, right: 21, down: 10, up: 11, 'control-e': 5, 'control-t': 20, none: -1 }[k] ?? k.charCodeAt(0); if (disk.kind === 'c64') engine.clock.ahead.push({ 8: 157, 21: 29, 10: 17, 11: 145, 127: 20, 27: 3 }[a] ?? a); else engine.press(a); }\n if (disk.kind !== 'c64') runs();\n} catch (err) { fail(err); }\n}\n", "import { rom as m } from '@moonbase-machines/c64';\nexport const { STANDS_IN, install, standIn } = m;", "// The remake's view: it follows the engine's events and draws the screen as SVG, sharper than\n// the original. The screen is the original's, 140 dots across and 192 down, each dot four\n// pixels wide and two high, so the SVG is 560 by 384. Pictures are drawn from their shapes,\n// smooth; objects from their own dots; text in a system font, laid out by the engine's codes.\n//\n// The screen is kept as the original painted it: each thing drawn covers some rows, and a\n// window, a box, a panel or a fill that paints over those rows takes away what was there.\nimport { COLORS, rgb } from '@moonbase-machines/apple2e/colors.js';\nimport { pictures } from '@moonbase-machines/vector/pictures.js';\nimport { tables, put } from '@moonbase-machines/vector/objects.js';\nimport { codeFiles } from './vector.js';\nimport { elements } from '@moonbase-machines/vector/svg.js';\nimport { width, dots } from '@moonbase-machines/vector/font.js';\nimport { layout, resolve, LAYOUT, PANELS, textLayout, textPen, textPage } from './layout.js';\nimport { FONT } from '@moonbase-machines/charset/font.js';\nimport { colors } from '@moonbase-machines/apple2e/screen.js';\n\nconst NS = 'http://www.w3.org/2000/svg';\nconst X = x => x * 4, Y = y => y * 2;\nconst SANS = 'system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif';\nconst MONO = 'ui-monospace, Menlo, Consolas, \"Liberation Mono\", monospace';\n\n// The characters are the title's own. There was no Unicode in 1986: the engine's font has its\n// arrows at $5B to $5E, left, right, down and up, where ASCII has [ \\ ] and ^. The engine's own\n// font draws those characters as they are. A modern font, a system font or one from Bunny Fonts,\n// has no arrow there, so text drawn in one maps them to Unicode's arrows as it is drawn. A title's\n// own glyphs that a modern font lacks are mapped the same way, as its title says (its map's `modern`):\n// Nature Park's underline is a band of checked dots.\nconst ARROWS = ['[', '\\\\', ']', '^'];\nconst MODERN = { '[': '\u2190', '\\\\': '\u2192', ']': '\u2193', '^': '\u2191' };\n\nexport class View {\n // `svg` is the element to draw in; `disk` the title's disk from its game's data; `engine` the\n // running engine; `extra` the title's own drawing for its problems (titles/<title>/view.js)\n constructor(svg, { disk, volume, engine, extra = {}, press }) {\n this.svg = svg; this.engine = engine; this.extra = extra; this.press = press;\n svg.setAttribute('viewBox', '0 0 560 384');\n this.disk = disk.volumes[volume];\n this.pictures = new Map();\n for (const [name, f] of Object.entries(disk.volumes[volume])) if (/^PICS\\d$/.test(name)) for (const p of pictures(Uint8Array.from(atob(f.data), c => c.charCodeAt(0)))) this.pictures.set(p.name, p.shapes);\n const map = engine.title.map;\n this.vars = map.vars;\n // the title's characters a modern font would draw wrongly, and what it draws instead\n const modern = { ...MODERN, ...map.modern };\n for (let d = 0; d < 10; d++) modern[String.fromCharCode(0x80 + d)] = String(d); // the big digits\n const pattern = new RegExp('[' + Object.keys(modern).map(c => '\\\\' + c).join('') + ']', 'g');\n this.modern = s => s.replace(pattern, c => modern[c]);\n this.tables = new Map(tables(codeFiles(map, disk.volumes[volume]), map.objects).map(t => [t.address, t.objects]));\n this.items = []; // what is on the screen: { top, bottom, el }\n this.pen = { x: 0, y: 0, margin: 0, centre: false, spacing: 1, gap: 0, ink: 15, paper: 10 };\n this.window = { color: 0, bottom: 116 };\n this.shapes = []; // the shapes in the window now\n this.spaceBar = null;\n this.layer = this.el('g'); svg.append(this.layer);\n this.textScreen = this.el('g', { display: 'none' }); svg.append(this.textScreen);\n this.prompt = this.el('g'); svg.append(this.prompt);\n this.textPen = textPen(); this.textCells = textPage();\n this.rect(0, 0, 140, 192, 15, this.layer);\n }\n\n el(name, attrs = {}, parent) { const e = document.createElementNS(NS, name); for (const [k, v] of Object.entries(attrs)) e.setAttribute(k, v); parent?.append(e); return e; }\n // a flat rectangle, its edges on whole pixels: where two meet at a fraction of a pixel, the page\n // would otherwise show a hair of what lies under both\n rect(x, y, w, h, color, parent = this.layer) { return this.el('rect', { x: X(x), y: Y(y), width: X(w), height: Y(h), fill: rgb(color), 'shape-rendering': 'crispEdges' }, parent); }\n // something drawn over rows top to bottom: what it covers entirely is gone\n // Something drawn over the rows top to bottom and the columns left to right: what lies wholly\n // inside that, it covers, and is gone.\n add(top, bottom, el, { covers = true, left = 0, right = 139 } = {}) {\n if (covers) this.items = this.items.filter(i => { if (i.top >= top && i.bottom <= bottom && i.left >= left && i.right <= right) { i.el.remove(); return false; } return true; });\n this.items.push({ top, bottom, left, right, el }); this.layer.append(el);\n return el;\n }\n // something taken off the screen, and out of what the screen holds\n remove(el) { el.remove(); this.items = this.items.filter(i => i.el !== el); }\n fill(top, bottom, color, sides = true) {\n const g = this.el('g');\n this.rect(0, top, 140, bottom - top + 1, color, g);\n if (sides) { this.rect(0, top, 1, bottom - top + 1, 15, g); this.rect(139, top, 1, bottom - top + 1, 15, g); }\n this.add(top, bottom, g);\n }\n whiteLines(y) { this.add(y, y + 1, this.rect(0, y, 140, 2, 15, null)); }\n\n // What the view needs from memory as an event happens, since it draws the event later: the\n // layout, the difficulty, and the words code 6 takes from its tables.\n snapshot(e) {\n const mem = this.engine.mem;\n e.layout = mem[this.vars.layout]; e.difficulty = mem[this.vars.difficulty];\n if (e.step === 'text') e.words = resolve(e.words, mem);\n if (e.step === 'span') e.row = mem[this.vars.zero + 0x02];\n return e;\n }\n\n // an event from the engine\n apply(e) {\n this.difficulty = e.difficulty;\n if (this.spaceBar?.erase && !this.waiting()) { this.fill(this.spaceBar.y, this.spaceBar.y + 10, 5); this.spaceBar.el.remove(); this.spaceBar = null; }\n // a step the title draws itself comes first, so that no name of the view's own can take it\n const f = this.extra[e.step] ?? (typeof this[e.step] === 'function' ? this[e.step] : undefined);\n if (f) f.call(this, e);\n }\n waiting() { return this.engine.waitingOn; }\n\n // The text screen ($573D), where the menus are: 40 columns and 24 rows over the whole screen,\n // white on black. `show` ($5BA9) puts the graphics back as they were.\n 'text-screen'() {\n this.textCells = textPage();\n this.textScreen.replaceChildren(); this.rect(0, 0, 140, 192, 0, this.textScreen);\n this.textScreen.setAttribute('display', 'inline'); this.layer.setAttribute('display', 'none');\n }\n show() { this.textScreen.setAttribute('display', 'none'); this.layer.setAttribute('display', 'inline'); }\n // a character of the text screen, 14 pixels by 16, in inverse or not\n textCell(row, col, ch, inverse) {\n const old = this.textCells[row][col];\n old.el?.remove();\n const g = this.el('g', { 'data-cell': row * 40 + col }, this.textScreen), x = col * 14, y = row * 16, ink = inverse ? '#000' : '#fff';\n if (inverse) this.el('rect', { x, y, width: 14, height: 16, fill: '#fff', 'shape-rendering': 'crispEdges' }, g);\n if (this.oldStyle) {\n // the emulator's own letters, five dots by seven in a cell of seven by eight, two pixels a dot\n const glyph = FONT[ch.charCodeAt(0) - 0x20] ?? FONT[0];\n let d = ''; for (let gx = 0; gx < 5; gx++) for (let gy = 0; gy < 7; gy++) if (glyph[gx] >> gy & 1) d += `M${x + 2 + gx * 2} ${y + gy * 2}h2v2h-2z`;\n if (d) this.el('path', { d, fill: ink }, g);\n } else if (ch !== ' ') {\n const t = this.el('text', { x: x + 7, y: y + 12, fill: ink, 'font-family': MONO, 'font-size': 15, 'text-anchor': 'middle' }, g);\n t.textContent = ch;\n }\n this.textCells[row][col] = { ch, inverse, el: g };\n }\n\n // The loader's splash: TITLE, a double hi-res screen, the auxiliary half then the main, drawn\n // dot for dot as it is\n splash() {\n const f = this.disk.TITLE;\n if (!f) return;\n const bytes = Uint8Array.from(atob(f.data), c => c.charCodeAt(0)), dots = colors(bytes.subarray(0, 0x2000), bytes.subarray(0x2000));\n const rows = []; for (let y = 0; y < 192; y++) rows.push(Array.from(dots.subarray(y * 140, y * 140 + 140)));\n this.clear();\n this.add(0, 191, this.el('image', { href: this.image(rows), x: 0, y: 0, width: 560, height: 384, preserveAspectRatio: 'none', style: 'image-rendering: pixelated' }));\n }\n // Nature Park's $4C00: the screen cleared to black\n 'clear-screen'() { this.clear(); this.add(0, 191, this.rect(0, 0, 140, 192, 0, null)); }\n clear() { for (const i of this.items) i.el.remove(); this.items = []; }\n // Nature Park's menus over a game ($4C5D and $4CFB): the screen kept, cleared to black, and put\n // back as it was when they return\n 'keep-screen'() {\n this.kept = { items: this.items, pen: { ...this.pen }, window: { ...this.window }, shapes: this.shapes, spaceBar: this.spaceBar };\n for (const i of this.items) i.el.remove();\n this.items = []; this.spaceBar = null;\n this['clear-screen']();\n }\n 'put-screen'() {\n if (!this.kept) return;\n this.clear();\n const k = this.kept; this.kept = null;\n for (const i of k.items) this.layer.append(i.el);\n Object.assign(this, { items: k.items, pen: k.pen, window: k.window, shapes: k.shapes, spaceBar: k.spaceBar });\n }\n\n box({ a, x, y, layout }) {\n const [bottom, top1, top2] = LAYOUT[layout] ?? LAYOUT[0x32];\n // all three painted: the whole screen is, and nothing under it is left\n if (a !== 0x80 && x !== 0x80 && y !== 0x80) { for (const i of this.items) i.el.remove(); this.items = []; }\n if (a !== 0x80) {\n const g = this.el('g');\n this.rect(1, 1, 138, bottom - 1, a, g);\n this.el('rect', { x: X(1) + 2, y: Y(1) + 1, width: X(138) - 4, height: Y(bottom - 2) - 2, fill: 'none', stroke: 'black', 'stroke-width': 4 }, g);\n this.add(1, bottom - 1, g, { left: 1, right: 138 });\n this.window = { color: a, bottom }; this.shapes = [];\n }\n if (x !== 0x80) { this.whiteLines(top1); this.fill(top1 + 2, top2 - 1, x); }\n if (y !== 0x80) { this.whiteLines(top2); this.fill(top2 + 2, 189, y); }\n }\n panel({ n: [n] }) {\n const p = PANELS[n];\n if (!p) return;\n // the box's two white rows at its top, then the box under them\n this.whiteLines(p.rows[0]);\n this.fill(p.rows[0] + 2, p.rows[1], p.fill);\n for (const y of p.more ?? []) this.whiteLines(y);\n Object.assign(this.pen, { paper: p.paper, ink: p.ink, centre: true, spacing: 1, gap: p.gap, y: p.y });\n }\n // $E000, which PART3 writes: rows 19 to 115 moved two bytes to the left in each half of the\n // screen, four bytes of it, seven dots. Bytes 3 to 38 of a half go to 1 to 36, the dots from 3.5\n // to 129.5, and bytes 37 and 38 stay, so what is at the right is drawn again as it moves on.\n // The view draws what is in those rows again, cut to them, over them, and moves it on seven dots\n // each time; each time, the strip at the right that stays is drawn again where it came to.\n scroll() {\n const top = 19, bottom = 115, left = 3.5, right = 129.5, s = this.scrolling;\n const clipped = (x0, x1, parent) => {\n const id = 'scroll-' + (this.clipIds = (this.clipIds ?? 0) + 1);\n // from half a pixel above row 19, where a smooth line along the row reaches\n this.el('rect', { x: X(x0), y: Y(top) - 1, width: X(x1 - x0), height: Y(bottom - top + 1) + 1 }, this.el('clipPath', { id }, this.svg));\n return this.el('g', { 'clip-path': `url(#${id})` }, parent);\n };\n const under = (x0, x1) => this.items.filter(i => i !== s?.item && i.top <= bottom && i.bottom >= top && i.left <= x1 && i.right >= x0);\n if (s?.item.el.isConnected && this.items.at(-1) === s.item) {\n // the strip, where it now is in what moves: seven dots on from where it was last time\n const tile = clipped(right, right + 7, this.el('g', { transform: `translate(${X(7 * s.n)} 0)` }, s.moved));\n for (const i of under(right, right + 7)) tile.append(i.el.cloneNode(true));\n s.n++;\n s.moved.setAttribute('transform', `translate(${X(-7 * s.n)} 0)`);\n return;\n }\n const g = clipped(left, right), moved = this.el('g', { transform: `translate(${X(-7)} 0)` }, g);\n // under it all, the window's color, wide enough to lie under the strips drawn as it moves on\n this.rect(left, top, 140 * 8, bottom - top + 1, this.window.color, moved);\n for (const i of under(left, 139)) moved.append(i.el.cloneNode(true));\n this.add(top, bottom, g, { left: 4, right: 129 });\n this.scrolling = { item: this.items.at(-1), moved, n: 1 };\n }\n // Nature Park's PART3 at $9796: dots `left` to `right` of rows `top` to `bottom` copied `by`\n // rows down. As the scroll, the view draws what is in those rows again, cut to where they go and\n // moved down; at each pass after, it moves on, and the rows at the top that stay are drawn again\n // where they come to.\n 'shift-down'({ left, right, top, bottom, by }) {\n const s = this.shifting, cut = (y0, y1, parent) => {\n const id = 'shift-' + (this.clipIds = (this.clipIds ?? 0) + 1);\n this.el('rect', { x: X(left), y: Y(y0), width: X(right - left + 1), height: Y(y1 - y0) }, this.el('clipPath', { id }, this.svg));\n return this.el('g', { 'clip-path': `url(#${id})` }, parent);\n };\n const under = (y0, y1) => this.items.filter(i => i !== s?.item && i.top <= y1 && i.bottom >= y0 && i.left <= right && i.right >= left);\n if (s?.item.el.isConnected && this.items.at(-1) === s.item) {\n const tile = cut(top, top + by, this.el('g', { transform: `translate(0 ${Y(-by * s.n)})` }, s.moved));\n for (const i of under(top, top + by - 1)) tile.append(i.el.cloneNode(true));\n s.n++;\n s.moved.setAttribute('transform', `translate(0 ${Y(by * s.n)})`);\n return;\n }\n const g = cut(top + by, bottom + by + 1), moved = this.el('g', { transform: `translate(0 ${Y(by)})` }, g);\n this.rect(left, top - by * 60, right - left + 1, bottom - top + 1 + by * 61, this.window.color, moved);\n for (const i of under(top, bottom)) moved.append(i.el.cloneNode(true));\n this.add(top + by, bottom + by, g, { left, right });\n this.shifting = { item: this.items.at(-1), moved, n: 1 };\n }\n\n // A run of a row ($7947), or a dot ($5AF4), in a color. Runs one under another, the same across\n // and in the same color, are one rectangle, which grows a row at a time and covers what lies\n // wholly inside it: the racing car's square cleared, a row or a column at a time, takes the car.\n paint(color, left, right, y) {\n this.hide(left, right, y, y);\n const last = this.painted;\n if (last?.el.isConnected && last.color === color && last.left === left && last.right === right && last.bottom === y - 1) {\n last.bottom = y; last.el.setAttribute('height', Y(y - last.top + 1));\n const item = this.items.find(i => i.el === last.el);\n this.items = this.items.filter(i => { if (i !== item && i.top >= last.top && i.bottom <= y && i.left >= left && i.right <= right) { i.el.remove(); return false; } return true; });\n if (item) item.bottom = y;\n return;\n }\n const el = this.add(y, y, this.rect(left, y, right - left + 1, 1, color, null), { left, right });\n this.painted = { el, color, left, right, top: y, bottom: y };\n }\n span({ a, x, y, row }) { this.paint(a & 15, x, y, row); }\n dot({ a, x, y }) { this.paint(a & 15, x, x, y); }\n 'white-lines'({ y }) { this.whiteLines(y); }\n 'fill-rows'({ a, x, y }) { this.fill(y, y + x - 1, a); }\n\n picture({ words }) {\n const shapes = this.pictures.get(words.toUpperCase().replace(/_/g, ' '));\n if (!shapes) return; // part1.pic and the like: the loader's own names for a file of pictures\n // drawn smooth, its edges may reach past the window's rows, which the original's never do\n const id = 'window-' + this.window.bottom;\n this.clips ??= new Set();\n if (!this.clips.has(id)) this.clips.add(id), this.el('rect', { x: 0, y: 0, width: X(140), height: Y(this.window.bottom) }, this.el('clipPath', { id }, this.svg));\n const g = this.el('g', { 'clip-path': `url(#${id})` }), scaled = this.el('g', { transform: 'scale(4 2)' }, g);\n scaled.innerHTML = elements(shapes, { crisp: false });\n this.add(1, this.window.bottom - 1, g, { covers: false, left: 1, right: 138 });\n this.shapes = this.shapes.concat(shapes);\n this.picturesShapes = shapes; // the last picture's, which a problem may draw again (PROB1's colouring)\n }\n objects({ table }) { this.table = parseInt(table.slice(1), 16); }\n // how: 'whole' ($686D), 'keep' ($686F) or 'clear' ($6863), as @moonbase-machines/vector/objects.js and raster.js say\n object({ a, x, y }, how = 'whole') {\n const keep = how === 'keep', whole = how === 'whole';\n const table = this.tables.get(this.table);\n // Object 0 puts back the ground kept under the latest object drawn keeping it ($686F), which\n // takes that object away. Once put back, the ground is put back again to no further effect.\n if (a < 2) { if (this.kept?.isConnected) this.remove(this.kept); this.kept = null; return; }\n const o = table?.find(o => o.number === a);\n if (!o) return;\n // the dots of the object's clear color are left out, so the screen shows through them, but for\n // an object put down whole\n const rows = o.rows.map(row => row.map(c => !whole && c === o.clear ? undefined : c));\n const right = x + o.width - 1, bottom = y + o.height - 1;\n // An object put down whole hides every dot under it. What it leaves showing of another put\n // down whole is all of that one that stays: PROB6's car, drawn a dot on each time, leaves a\n // column of the one before, as the original's screen does, and no hair of the rest at the\n // edges of the page's pixels.\n if (whole) this.hide(x, right, y, bottom);\n const el = this.el('image', { href: this.image(rows), x: X(x), y: Y(y), width: X(o.width), height: Y(o.height), preserveAspectRatio: 'none', style: 'image-rendering: pixelated' });\n // put down whole, it hides for good whatever lies wholly inside it, as the crane its rope's dots\n this.add(y, bottom, el, { covers: whole, left: x, right });\n if (keep) this.kept = el;\n if (whole) this.items.at(-1).whole = { x, y, rows };\n }\n // The dots of objects put down whole that something opaque now covers, from column x0 to x1 and\n // row y0 to y1, taken out of their pictures: what is left of each is all of it that shows, and\n // none of what is covered shows at the edges of the page's pixels.\n hide(x0, x1, y0, y1) {\n for (const i of [...this.items]) {\n const w = i.whole;\n if (!w || w.x > x1 || w.x + w.rows[0].length - 1 < x0 || w.y > y1 || w.y + w.rows.length - 1 < y0) continue;\n let changed = false;\n const left = w.rows.map((row, dy) => row.map((c, dx) => {\n const px = w.x + dx, py = w.y + dy;\n if (c !== undefined && px >= x0 && px <= x1 && py >= y0 && py <= y1) { changed = true; return undefined; }\n return c;\n }));\n if (!changed) continue;\n if (left.every(row => row.every(c => c === undefined))) { this.remove(i.el); continue; }\n i.el.setAttribute('href', this.image(left)); w.rows = left;\n }\n }\n // rows of colors as a picture, undefined where nothing is drawn\n image(rows) {\n const canvas = document.createElement('canvas'); canvas.width = rows[0].length; canvas.height = rows.length;\n const cx = canvas.getContext('2d'), img = cx.createImageData(canvas.width, canvas.height);\n rows.forEach((row, dy) => row.forEach((c, dx) => {\n if (c === undefined) return;\n const [r, g, b] = COLORS[c]; img.data.set([r, g, b, 255], (dy * canvas.width + dx) * 4);\n }));\n cx.putImageData(img, 0, 0);\n return canvas.toDataURL();\n }\n 'object-keep'(e) { this.object(e, 'keep'); }\n 'object-mode'(e) { this.object(e, 'clear'); }\n // $76ED and $76F3: a key cap at the pen, which is left past it (vector.js)\n 'key-at'({ a, x, y }) { this.pen.x = x; this.pen.y = y; this.key({ a }); }\n key({ a }) {\n const w = width(a);\n this.cap(a, this.pen.x, this.pen.y, this.layer, true, undefined, Math.max(4, w) + 4);\n this.pen.x += 1 + (w < 4 ? 4 - w : 0) + 1 + w + 3;\n }\n\n // a key cap: outlined in blue, filled magenta, its letter white\n cap(ch, x, y, parent, add, key, wide) {\n const label = { '\\r': 'RETURN', '\\x7f': 'DELETE' }[ch] ?? ch;\n const w = wide ?? (label.length > 1 ? 32 : 7);\n const g = this.el('g', key !== undefined ? { class: 'key', 'data-key': key } : {});\n this.el('rect', { x: X(x), y: Y(y - 2), width: X(w), height: Y(11), rx: 3, fill: rgb(1), stroke: rgb(13), 'stroke-width': 3 }, g);\n if (this.oldStyle) {\n // the engine's cap: the glyph a dot in from the left, or RETURN and DELETE spelt out\n let tw = 0; for (const c of label) tw += width(c) + 1;\n this.glyphs(g, label, x + Math.max(1, Math.round((w - tw + 1) / 2)), y, 15);\n } else {\n const t = this.el('text', { x: X(x + w / 2), y: Y(y + 7), fill: rgb(15), 'font-family': SANS, 'font-size': label.length > 1 ? 13 : 16, 'font-weight': 600, 'text-anchor': 'middle' }, g);\n t.textContent = this.modern(label);\n }\n if (add) { this.add(y - 2, y + 8, g, { covers: false, left: x, right: x + w }); this.items.at(-1).cap = true; } else parent.append(g);\n return g;\n }\n\n // Text, laid out as the engine lays it out (layout.js). A line is drawn a word at a time, each\n // word where the engine's font puts it and as wide, in dots, as the engine made it: the words\n // sit where the original's did, and read sharper.\n text({ words }) {\n if (this.textScreen.getAttribute('display') !== 'none') {\n for (const c of textLayout(words, this.textPen)) if (this.textCells[c.row]?.[c.col]) this.textCell(c.row, c.col, c.ch, c.inverse);\n return;\n }\n for (const line of layout(words, this.pen)) {\n const { top, tall } = line, size = tall ? 32 : 19;\n // the paper of the line's glyphs' cells, first, as the engine paints it: a text written\n // over another takes it away\n const cells = line.chars.filter(c => c.ch.charCodeAt(0) >= 0x20);\n if (cells.length) {\n const from = Math.min(...cells.map(c => c.x)), to = Math.max(...cells.map(c => c.x + width(c.ch))) - 1, rows = Math.min(9, line.height ?? 9) * (tall ? 2 : 1);\n this.add(top, top + rows - 1, this.rect(from, top, to - from + 1, rows, line.paper, null), { left: from, right: to });\n }\n const g = this.el('g', { 'font-family': SANS, 'font-size': size, 'font-weight': tall ? 700 : 500 });\n let word = null, left = 139, right = 0;\n const end = () => {\n if (!word) return;\n left = Math.min(left, word.x); right = Math.max(right, word.x + word.width);\n if (this.oldStyle) { this.glyphs(g, word.chars, word.x, top, line.ink, tall, line.paper); word = null; return; }\n const el = this.el('text', { y: Y(top + (tall ? 15 : 7)), 'data-x': X(word.x), 'data-width': X(word.width) }, g);\n // the part of a line before its first color is drawn in the ink the whole line ends with\n for (const c of word.chars) { const span = this.el('tspan', { fill: rgb(c.ink ?? line.ink) }, el); span.textContent = this.modern(c.ch); }\n word = null;\n };\n for (const c of line.chars) {\n if (c.ch.charCodeAt(0) <= 0x20) { end(); continue; }\n word ??= { x: c.x, width: 0, chars: [] };\n word.chars.push(c); word.width = c.x + width(c.ch) - word.x;\n }\n end();\n if (g.childNodes.length) { this.add(top, top + (tall ? 16 : 8), g, { covers: false, left, right }); this.fit(g); }\n }\n }\n // Each word of a line, drawn at x 0, is measured once it is on the page and then moved to its\n // place and scaled to the width the engine gave it. Browsers differ in how they stretch text to\n // a length, and a measured scale looks the same in all of them.\n fit(g) {\n for (const el of g.querySelectorAll('text[data-width]')) {\n const natural = el.getComputedTextLength();\n if (natural > 0) el.setAttribute('transform', `translate(${el.dataset.x} 0) scale(${el.dataset.width / natural} 1)`);\n }\n }\n // The old style: the engine's own glyphs, each set dot a square, over the glyph's cell in the\n // paper color. `chars` is a string, or the characters of a line with the ink each was given\n // (the part of a line before its first color takes the ink the line ends with). Returns the\n // dot after the last glyph.\n glyphs(parent, chars, x, y, ink, tall = false, paper) {\n const list = typeof chars === 'string' ? [...chars].map(ch => ({ ch })) : chars, h = tall ? 2 : 1;\n const paths = new Map();\n for (const c of list) {\n const w = width(c.ch), colour = c.ink ?? ink;\n if (paper !== undefined) this.rect(x, y, w, 9 * h, paper, parent);\n let d = paths.get(colour) ?? '';\n for (const [gx, gy] of dots(c.ch)) d += `M${X(x + gx)} ${Y(y + gy * h)}h4v${2 * h}h-4z`;\n paths.set(colour, d);\n x += w + 1;\n }\n for (const [colour, d] of paths) if (d) this.el('path', { d, fill: rgb(colour) }, parent);\n return x;\n }\n\n // plain words at dot x and row y, in the engine's font widths with spacing 1, fitted as a text's\n write(parent, text, x, y, ink = 15) {\n if (this.oldStyle) return this.glyphs(parent, text, x, y, ink);\n const g = this.el('g', { 'font-family': SANS, 'font-size': 19, 'font-weight': 500, fill: rgb(ink) }, parent);\n for (const part of text.split(' ')) {\n if (part) {\n let w = 0; for (const ch of part) w += width(ch) + 1;\n const el = this.el('text', { y: Y(y + 7), 'data-x': X(x), 'data-width': X(w - 1) }, g);\n el.textContent = this.modern(part);\n x += w;\n }\n x += width(' ') + 1;\n }\n this.fit(g);\n return x;\n }\n\n\n line({ x0, x1, y0, y1, color }) {\n this.add(Math.min(y0, y1), Math.max(y0, y1), this.el('line', { x1: X(x0 + 0.5), y1: Y(y0 + 0.5), x2: X(x1 + 0.5), y2: Y(y1 + 0.5), stroke: rgb(color), 'stroke-width': 3, 'stroke-linecap': 'round' }), { covers: false, left: Math.min(x0, x1), right: Math.max(x0, x1) });\n }\n // $67B9 fills from column x to x + width, both ends, down `height` rows; $677E draws its four\n // lines from corner to corner, x to x + width and y to y + height\n rectangle({ a, x, y, width, height }) { this.solid(a, x, y, width + 1, height); }\n 'rectangle-outline'({ a, x, y, width, height }) {\n const w = width + 1, h = height + 1;\n this.add(y, y + h - 1, this.el('rect', { x: X(x) + 2, y: Y(y) + 1, width: X(w) - 4, height: Y(h) - 2, fill: 'none', stroke: rgb(a), 'stroke-width': 3 }), { covers: false, left: x, right: x + w - 1 });\n }\n // a rectangle w dots across and h down, filled\n solid(a, x, y, w, h) { this.add(y, y + h - 1, this.rect(x, y, w, h, a, null), { left: x, right: x + w - 1 }); }\n\n // what the view shows while the engine waits: the space bar's button, or the keys it asks for\n prompts() {\n this.prompt.replaceChildren();\n const e = this.engine, step = e.waitingOn;\n if (!step) return;\n const name = step.words?.[0] ?? step.name;\n if (name === 'wait' || name === 'wait-erase' || name === 'wait-or-escape') {\n const y = (e.mem[this.vars.layout] & 15) === 1 ? 178 : 170;\n const g = this.el('g', { class: 'key', 'data-key': 32 }, this.prompt);\n this.el('rect', { x: X(46), y: Y(y), width: X(47), height: Y(11), rx: 4, fill: rgb(1), stroke: rgb(13), 'stroke-width': 3 }, g);\n if (this.oldStyle) this.glyphs(g, 'SPACE BAR', 48, y + 2, 15);\n else { const t = this.el('text', { x: X(69.5), y: Y(y + 8), fill: rgb(15), 'font-family': SANS, 'font-size': 15, 'font-weight': 600, 'text-anchor': 'middle' }, g); t.textContent = 'SPACE BAR'; }\n this.spaceBar = { y, erase: name === 'wait-erase', el: g };\n } else if (name === 'ask' || name === 'ask-mode' || name === 'ask-escape') {\n this.rect(1, 162, 138, 28, 5, this.prompt); // box 2 inside its white edges, as panel 5 clears it\n const mode = e.askMode, keys = [];\n if (mode === 0x80) ARROWS.forEach((a, i) => keys.push([a, [8, 21, 10, 11][i]]));\n else if (mode >= 0xb1 && mode < 0xba) for (let k = 0x31; k <= (mode & 0x7f); k++) keys.push([String.fromCharCode(k), k]);\n else for (let k = 0x41; k <= (mode & 0x5f); k++) keys.push([String.fromCharCode(k), k]);\n const label = (s, x, y) => this.write(this.prompt, s, x, y);\n if (e.asked === null) {\n label('Press', 4, 166);\n keys.forEach(([s, k], i) => { if (i === keys.length - 1 && mode !== 0x80 && keys.length > 1) label('or', 31 + 10 * i, 166); this.cap(s, 31 + 10 * i + (i === keys.length - 1 && mode !== 0x80 && keys.length > 1 ? 10 : 0), 166, this.prompt, false, k); });\n if (mode === 0x80) [[58, 62], [74, 62], [66, 71], [66, 53]].forEach(([x, y], i) => this.cap(ARROWS[i], x, y, this.prompt, false, keys[i][1]));\n } else {\n const [s] = keys[e.asked.place];\n this.cap(s, 31 + 10 * e.asked.place, 166, this.prompt, false); // the chosen key stays, the rest of its row goes\n label('Press', 4, 179); this.cap('\\r', 31, 179, this.prompt, false, 13); label('or', 67, 179); this.cap('\\x7f', 78, 179, this.prompt, false, 127);\n if (mode === 0x80) this.cap(ARROWS[e.asked.place], [58, 74, 66, 66][e.asked.place], [62, 62, 71, 53][e.asked.place], this.prompt, false);\n }\n }\n }\n}\n", "import { colors as m } from '@moonbase-machines/apple2e';\nexport const { COLORS, NAMES, rgb } = m;", "import { font as m } from '@moonbase-machines/charset';\nexport const { FONT } = m;"],
5
- "mappings": ";qLAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,OAAS,WAAWC,OAAS,6BAA7B,IACeD,GADfE,GAAAC,GAAA,MACa,CAAE,QAAAH,IAAYC,MCD3B,IAAAG,GAAA,GAAAC,EAAAD,GAAA,WAAAE,GAAA,WAAAC,GAAA,YAAAC,GAAA,UAAAC,KAAA,OAAS,UAAUC,OAAS,6BAA5B,IACeJ,GAAOC,GAAQC,GAASC,GADvCE,GAAAC,GAAA,MACa,CAAE,MAAAN,GAAO,OAAAC,GA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,OAAO,OAAO,SAAS,cAAc,MAAM,EAAG,CAAE,IAAK,aAAc,KAAM,IAAI,IAAIJ,EAAM,MAAOZ,CAAM,EAAE,IAAK,CAAC,EACzHgB,EAAK,QAAQ,MAAQJ,EAAM,KAAM,SAAS,KAAK,OAAOI,CAAI,EAC1D,MAAM,IAAI,QAAQC,GAAQ,CAAED,EAAK,OAASA,EAAK,QAAUC,CAAM,CAAC,CAClE,CACA,IAAMC,EAAO,CAAE,GAAGnB,EAAS,MAAAa,EAAO,QAAAC,EAAS,KAAAC,EAAM,OAAAd,EAAQ,KAAAC,EAAM,MAAAK,EAAO,QAASC,EAAM,OAAAC,EAAQ,KAAAC,EAAM,KAAAN,EAAM,QAAAC,EAAS,MAAAC,EAAO,MAAAM,CAAM,EAC/H,MAAOC,EAAM,KAAO,CAAE,KAAMd,EAAO,GAAG,KAAKoB,CAAI,CACjD,OAASR,EAAK,CAAED,EAAKC,CAAG,CAAG,CAC7B",
6
- "names": ["machine_exports", "__export", "Machine", "m", "init_machine", "__esmMin", "prodos_exports", "__export", "blank", "placed", "started", "units", "m", "init_prodos", "__esmMin", "saves_exports", "__export", "driveFiles", "keepSaves", "onDisks", "withSaves", "m", "init_saves", "__esmMin", "screen_exports", "__export", "COLORS", "colors", "paint", "paintHires", "paintText", "rowStart", "screen", "textRow", "m", "init_screen", "__esmMin", "pictures_exports", "__export", "pictures", "shapes", "windows", "m", "init_pictures", "__esmMin", "svg_exports", "__export", "bounds", "document", "elements", "m", "init_svg", "__esmMin", "machine_exports", "__export", "C64", "m", "init_machine", "__esmMin", "printer_exports", "__export", "Printer", "WIDTH", "bus", "paper", "m", "init_printer", "__esmMin", "vic_exports", "__export", "HEIGHT", "LEFT", "PALETTE", "TOP", "VIC", "WIDTH", "m", "init_vic", "__esmMin", "browser_exports", "__export", "keyboard", "pace", "painter", "m", "init_browser", "__esmMin", "sid_exports", "__export", "SID", "m", "init_sid", "__esmMin", "start_exports", "__export", "ROM_CHOICES", "c64Roms", "typed", "m", "init_start", "__esmMin", "d64_exports", "__export", "SECTORS", "add", "make", "petsciiName", "read", "m", "init_d64", "__esmMin", "saves_exports", "__export", "keepDrive", "m", "init_saves", "__esmMin", "original_exports", "__export", "play", "audio_exports", "__export", "Speaker", "WORKLET", "Speaker", "clicks", "cycles", "perSample", "wave", "ci", "i", "t", "parts_exports", "__export", "KEYS_MARKUP", "paperBox", "phoneKeys", "line", "print", "tear", "box", "root", "stage", "kb", "unnamed", "e", "ch", "t", "play", "data", "root", "disk", "words", "downloadDisk", "roms", "studies", "KEYS_MARKUP", "paperBox", "$", "id", "canvas", "ctx", "phoneKeys", "parts", "Speaker", "game", "c64", "apple", "evenly", "dots", "lines", "stage", "column", "fit", "dpr", "pad", "room", "most", "k", "w", "makers", "layer", "status", "vectorToggle", "speaker", "Machine", "placed", "withSaves", "keepSaves", "onDisks", "driveFiles", "screen", "shapes", "elements", "saving", "disks", "n", "m", "a", "hooked", "window_", "hook", "find", "bytes", "code", "outer", "i", "shape", "exit", "box", "c", "KEYS", "e", "rgba", "image", "cols", "mode", "frame", "now", "text", "name", "C64", "Printer", "paper", "WIDTH", "HEIGHT", "keyboard", "painter", "SID", "c64Roms", "startTyped", "add", "keepDrive", "sheet", "shown", "printer", "raw", "t", "file", "download", "draw", "typing", "typed", "keys", "frames", "sid", "started", "due", "first", "wave", "r", "v", "modal_exports", "__export", "modal", "modalOpen", "open", "listening", "keys", "e", "m", "d", "f", "focusable", "at", "box", "first", "within", "className", "content", "cancel", "layer", "before", "others", "el", "under", "dialogs_exports", "__export", "dialogs", "dialogs", "within", "className", "ask", "heading", "body", "buttons", "aside", "done", "content", "h", "row", "label", "value", "b", "m", "left", "modal", "tell", "saveAs", "disk", "suggested", "input", "name", "keptNote", "openFrom", "extension", "type", "select", "note", "button", "text", "from", "download", "remove", "fill", "f", "chosen", "open", "n", "a", "warning", "p", "disk_exports", "__export", "bytesText", "openDisk", "programDisk", "textBytes", "titleDisk", "local_exports", "__export", "ACCOUNT", "DB", "KEY", "STORE", "VERSION", "local", "opened", "done", "fail", "r", "asked", "account", "db", "store", "mode", "disk", "name", "bytes", "meta", "modified", "f", "memory_exports", "__export", "memory", "kept", "disks", "of", "d", "f", "openDisk", "name", "backend", "local", "memory", "files", "f", "queue", "later", "job", "a", "b", "bytes", "meta", "modified", "n", "titleDisk", "slug", "programDisk", "textBytes", "s", "bytesText", "c64_view_exports", "__export", "C64View", "m", "paint", "init_vic", "NS", "C64View", "svg", "engine", "chargen", "WIDTH", "HEIGHT", "k", "v", "frame", "paint", "ctx", "pixels", "i", "r", "g", "b", "PALETTE", "card_view_exports", "__export", "CardView", "init_screen", "NS", "svg", "engine", "inset", "k", "v", "mem", "s", "ctx", "pixels", "paintText", "page", "paintHires", "band", "shift", "px", "top", "y", "x", "i", "bottom", "from", "to", "by", "row", "card_exports", "__export", "cardRoutines", "events_exports", "__export", "GIVES", "POLLS", "TAKES", "WAITS", "describe", "nothing", "result", "MEMORY", "ZERO", "name", "fixed", "regs", "inline", "read", "peek", "e", "takes", "r", "k", "at", "a", "cards_exports", "__export", "INLINE", "KERNAL", "section", "sectionName", "bytes", "n", "read", "at", "b", "k", "s", "i", "guard", "c", "toolkit", "x", "lengths", "marks", "word", "path", "mark", "t", "m", "BLOCK", "CLOCK", "Files", "m", "install", "m", "KEY_TABLES", "VECTORS", "VIC", "install", "kernalByte", "matrixOf", "screenCode", "m", "Drive", "init_printer", "m", "Basic", "m", "BasicError", "ERRORS", "fail", "fout", "int16", "nextRandom", "scanNumber", "seedRandom", "val", "m", "evaluateInMemory", "install", "printError", "lift_exports", "__export", "lift", "readers", "script", "m", "OPS", "SIZE", "disassemble", "hex", "operand", "m", "INLINE", "name", "sound", "text", "readers", "from", "k", "f", "b", "at", "r", "i", "INLINE", "lift", "bytes", "origin", "entries", "routines", "stops", "inline", "lines", "targets", "seen", "queue", "inFile", "a", "pc", "regs", "op", "OPS", "hex", "size", "SIZE", "word", "ins", "line", "operand", "next", "stop", "data", "args", "t", "table", "e", "out", "last", "left", "s", "script", "selfModified", "memory", "moved", "H", "n", "w", "written", "here", "own", "place", "v", "label", "branch", "fused", "target", "pcs", "stopsHere", "loads", "flush", "reg", "put", "name", "fixed", "takes", "TAKES", "given", "g", "s1", "l2", "s2", "j", "who", "whole", "row", "hex4", "n", "inputs", "e", "name", "args", "takes", "TAKES", "k", "loaded", "r", "v", "cardRoutines", "title", "toolkit", "c64", "files", "Files", "screen", "latch", "lc", "bankTo", "bank", "here", "chip", "SEEDED", "s", "io64", "at", "reg", "ioShown", "io", "kernalByte", "b", "engine", "cpu", "a", "romFrom", "install", "bus", "Drive", "ch", "Printer", "h", "runNow", "from", "to", "script", "l", "path", "f", "c", "rom", "start", "CLOCK", "index", "labelled", "p", "atNeed", "bytes", "lifted", "lift", "readers", "INLINE", "fileScripts", "present", "names", "find", "over", "romAt", "stirring", "step", "emit", "ev", "quiet", "back", "x", "through", "inline", "i", "words", "unplaced", "VECTORED", "inRom", "describe", "label", "GIVES", "result", "routines", "cmd", "lo", "hi", "params", "mem", "ref", "o", "sectionName", "BLOCK", "err", "entry", "done", "ENDS", "pullRegisters", "text", "m", "keep", "device", "sa", "program", "startBasic", "end", "place", "BasicError", "printError", "Basic", "data", "seed", "raster", "kept", "what", "then", "line", "last", "target", "named", "own", "t", "KEY_TABLES", "VIC", "VECTORS", "raw", "compile_exports", "__export", "compile", "script_exports", "__export", "branchTaken", "operand", "parse", "words", "WORD", "source", "name", "steps", "labels", "data", "raw", "n", "line", "where", "m", "h", "at", "body", "w", "word", "SIZE", "step", "to", "next", "hex", "v", "n", "IO_FROM", "IO_TO", "IO", "at", "address", "o", "io", "get", "word", "timed", "operand", "a", "put", "place", "FLAGS", "TESTS", "statement", "step", "k", "w", "first", "second", "s", "of", "parts", "p", "left", "to", "cond", "not", "flag", "args", "compile", "source", "name", "steps", "labels", "data", "parse", "code", "starts", "c", "l", "blocks", "end", "loops", "lines", "i", "j", "text", "js", "t", "more", "branchTaken", "cy", "label", "one", "body", "d", "b", "engine_exports", "__export", "Engine", "label16", "m", "CPU", "CYCLES", "LEFT", "STATEMENTS", "STATEMENT", "step", "CYCLES_PER_MS", "size", "op", "b", "cc", "LEFT_OUT", "COMPARED", "returnOf", "label16", "at", "Engine", "routines", "scripts", "start", "label", "memory", "v", "f", "event", "key", "k", "g", "name", "load", "p", "d", "src", "parse", "bytes", "line", "text", "words", "l", "done", "ret", "here", "i", "o", "z", "base", "r", "s", "j", "c", "m", "CYCLES", "prev", "from", "more", "a", "lo", "hi", "sum", "left", "through", "t", "to", "top", "sp", "n", "kept", "limit", "e", "w", "first", "second", "operand", "args", "routine", "cond", "yes", "not", "flag", "branchTaken", "layout_exports", "__export", "LAYOUT", "PANELS", "layout", "resolve", "textLayout", "textPage", "textPen", "word", "m", "GLYPHS", "WIDTHS", "dots", "start", "useFont", "width", "LAYOUT", "gray", "layout", "rows", "gap", "y", "more", "blue", "PANELS", "word", "mem", "lo", "hi", "vlo", "vhi", "at", "n", "s", "k", "resolve", "words", "all", "b", "v", "pen", "lines", "height", "big", "line", "ink", "marked", "flush", "newline", "x", "start", "c", "chars", "w", "width", "put", "ch", "i", "end", "code", "rest", "textLayout", "cells", "col", "textPen", "textPage", "load_exports", "__export", "loadTitle", "makeEngine", "vector_exports", "__export", "codeFiles", "pictureShapes", "vectorRoutines", "problems_exports", "__export", "helpers", "helpers", "e", "routines", "zero", "call", "name", "args", "token", "words", "a", "drawn", "x", "y", "describe", "z", "key", "kind", "k", "inside", "run", "m", "carry", "decode", "put", "tables", "init_pictures", "raster_exports", "__export", "Raster", "m", "crossings", "draw", "fill", "inside", "line", "outline", "screen", "spans", "under", "Raster", "screen", "y", "row", "bits", "c", "b", "x", "left", "right", "count", "first", "edges", "layout", "window", "one", "two", "bottom", "top1", "top2", "LAYOUT", "top", "shapes", "draw", "w", "h", "r", "x0", "y0", "x1", "y1", "line", "o", "how", "dy", "_", "dx", "put", "k", "ch", "ink", "paper", "height", "space", "width", "gy", "gx", "on", "dots", "codeFiles", "map", "volume", "loads", "n", "name", "f", "c", "KEY", "inputs", "e", "args", "takes", "TAKES", "fixed", "k", "regs", "t", "r", "v", "waiting", "step", "words", "take", "describe", "quietly", "run", "objectsOf", "title", "files", "tables", "picturesOf", "p", "pictures", "pictureShapes", "vectorRoutines", "V", "Z", "z", "useFont", "objectCarry", "o", "carry", "raster", "Raster", "pen", "textPen", "textPage", "objectOf", "drawObject", "how", "cap", "ch", "w", "width", "x", "spacer", "keyPanel", "y", "cx", "cy", "i", "print", "line", "layout", "resolve", "put", "simple", "draw", "rest", "letterCarry", "asking", "mode", "arrows", "place", "key", "result", "routines", "shapes", "PANELS", "all", "code", "bytes", "b", "at", "textLayout", "nothing", "left", "right", "top", "bottom", "by", "used", "seed", "q", "d", "file", "helpers", "row", "ms", "what", "to", "Files", "err", "init_prodos", "ENGINES", "vectorRoutines", "cardRoutines", "read", "url", "as", "text", "r", "defaultOf", "loadTitle", "folder", "data", "scenes", "fixed", "title", "name", "scripts", "n", "disk", "makeEngine", "memory", "started", "engine", "Engine", "main_exports", "__export", "play", "scenes_exports", "__export", "play", "init_printer", "init_sid", "m", "STANDS_IN", "install", "standIn", "init_saves", "init_saves", "view_exports", "__export", "View", "m", "COLORS", "NAMES", "rgb", "init_pictures", "init_svg", "m", "FONT", "init_screen", "NS", "X", "x", "Y", "y", "SANS", "MONO", "ARROWS", "MODERN", "View", "svg", "disk", "volume", "engine", "extra", "press", "name", "f", "p", "pictures", "c", "map", "modern", "d", "pattern", "s", "tables", "codeFiles", "t", "textPen", "textPage", "attrs", "parent", "e", "k", "v", "w", "h", "color", "rgb", "top", "bottom", "el", "covers", "left", "right", "i", "sides", "g", "mem", "resolve", "row", "col", "ch", "inverse", "ink", "glyph", "FONT", "gx", "gy", "bytes", "dots", "colors", "rows", "a", "layout", "top1", "top2", "LAYOUT", "n", "PANELS", "clipped", "x0", "x1", "id", "under", "tile", "moved", "by", "cut", "y0", "y1", "last", "item", "words", "shapes", "scaled", "elements", "table", "how", "keep", "whole", "o", "changed", "dy", "dx", "px", "py", "canvas", "cx", "img", "r", "b", "COLORS", "width", "add", "key", "wide", "label", "tw", "textLayout", "line", "tall", "size", "cells", "from", "to", "word", "end", "span", "natural", "chars", "paper", "list", "paths", "colour", "text", "part", "height", "step", "mode", "keys", "play", "game", "title", "scripts", "disk", "root", "stage", "status", "fail", "kept", "words", "fixed", "KEYS_MARKUP", "paperBox", "$", "id", "svg", "soundBox", "phoneKeys", "fixedBox", "u", "extra", "chargen", "standIn", "box", "sheet", "shown", "printer", "Printer", "paper", "withSaves", "keepDrive", "Drive", "ch", "engine", "makeEngine", "keepSaves", "queue", "oldStyleBox", "history", "remember", "v", "onView", "makeView", "C64View", "CardView", "View", "view", "e", "miniBox", "top", "bottom", "left", "right", "at", "mini", "prompts", "show", "speaker", "Speaker", "hear", "V", "audio", "tone", "from", "to", "ms", "o", "g", "t", "pitch", "p", "PACE", "pace", "drawing", "sleep", "r", "runs", "quick", "end", "start", "h", "err", "KEYS", "press", "k", "on", "ticking", "held", "tapped", "m", "matrixOf", "key", "route", "routeName", "expand", "give", "petscii", "pollsAt", "side", "put", "go", "i", "sid", "sent", "stopped", "SID", "n", "wave", "a", "play", "options", "folder", "data", "root", "kept", "preview", "words", "stage", "line", "status", "fail", "err", "fixed", "title", "scripts", "disk", "loadTitle", "link", "done", "game"]
4
+ "sourcesContent": ["import { machine as m } from '@moonbase-machines/apple2e';\nexport const { Machine } = m;", "import { prodos as m } from '@moonbase-machines/apple2e';\nexport const { blank, placed, started, units } = m;", "import { saves as m } from '@moonbase-machines/apple2e';\nexport const { driveFiles, keepSaves, onDisks, withSaves } = m;", "import { screen as m } from '@moonbase-machines/apple2e';\nexport const { COLORS, colors, paint, paintHires, paintText, rowStart, screen, textRow } = m;", "import { pictures as m } from '@moonbase-machines/vector';\nexport const { pictures, shapes, windows } = m;", "import { svg as m } from '@moonbase-machines/vector';\nexport const { bounds, document, elements } = m;", "import { machine as m } from '@moonbase-machines/c64';\nexport const { C64 } = m;", "import { printer as m } from '@moonbase-machines/c64';\nexport const { Printer, WIDTH, bus, paper } = m;", "import { vic as m } from '@moonbase-machines/c64';\nexport const { HEIGHT, LEFT, PALETTE, TOP, VIC, WIDTH } = m;", "import { browser as m } from '@moonbase-machines/c64';\nexport const { keyboard, pace, painter } = m;", "import { sid as m } from '@moonbase-machines/c64';\nexport const { SID } = m;", "import { start as m } from '@moonbase-machines/c64';\nexport const { ROM_CHOICES, c64Roms, typed } = m;", "import { d64 as m } from '@moonbase-machines/c64';\nexport const { SECTORS, add, make, petsciiName, read } = m;", "import { saves as m } from '@moonbase-machines/c64';\nexport const { keepDrive } = m;", "// The original: a game's disk in the machine it was made for, its screen on a canvas, the keyboard passed\n// on, and each picture the engine draws also given as SVG over the canvas. Each game's machine is loaded when its\n// game asks for it, the Commodore 64 (@moonbase-machines/c64) or the Apple IIe (@moonbase-machines/apple2e), and not\n// the other; on moonbase's own ROMs, which need nothing of the makers'.\n//\n// await play({ data, root, disk, words, downloadDisk, roms, studies })\n// data the game's data, an absolute URL (<name>.json: its disks' files, its kind, its saves)\n// root the page's section the player is made in\n// disk the title's player's disk (disk/disk.js), opened before the player starts\n// words the page's words the player shows: { printer: { line, print, tear } }\n// downloadDisk a C64 game's disk offered to download, with what is saved on it\n// and what only a workshop has, given by its pages, never looked for here:\n// roms the makers' ROMs this machine has: an Apple game's line 1, Apple's own booting its disks,\n// { apple: { system, disk2 }, image: async name => its disk image's bytes }; a C64 game's\n// Commodore's, { choice ('commodore' or 'moonbase-petscii', @moonbase-machines/c64/start.js), load:\n// async name => a ROM's bytes }\n// studies files of its own for a C64 game's disk, a name to its bytes in base64, in the drive, not kept\nimport { Speaker } from './audio.js';\nimport { paperBox, phoneKeys, KEYS_MARKUP } from './parts.js';\n\nexport async function play({ data, root, disk, words, downloadDisk = false, roms = null, studies = null }) {\n root.classList.add('game');\n root.innerHTML = `<div class=\"stage\"><svg id=\"vector\" viewBox=\"0 0 140 192\" preserveAspectRatio=\"none\"></svg><canvas id=\"screen\" width=\"560\" height=\"384\" tabindex=\"0\"></canvas></div>\n <p class=\"options\"><span id=\"status\">Loading.</span>${KEYS_MARKUP}<label><input type=\"checkbox\" id=\"vectors\"> Draw the pictures as vectors</label><label hidden><input type=\"checkbox\" id=\"printer\" checked> Printer</label><button id=\"disk\" type=\"button\" hidden>Download the disk</button></p>`;\n root.append(paperBox(words.printer));\n const $ = id => root.querySelector('#' + id);\n const canvas = $('screen'), ctx = canvas.getContext('2d');\n phoneKeys(root, canvas.parentElement);\n // (the game's name, for a disk downloaded: its data's file's)\n const name = new URL(data).pathname.split('/').pop().replace(/\\.json$/, '');\n const parts = { name, roms, studies, disk, downloadDisk, $, canvas, ctx, layer: $('vector'), status: $('status'), vectorToggle: $('vectors'), speaker: new Speaker() };\n const game = await (await fetch(data)).json();\n if (game.kind === 'c64') await c64(game, parts); else await apple(game, parts);\n}\n\n// the screen stretched evenly: a whole number of the device's pixels to each of the machine's dots\n// (the 64's 384 by 272, the Apple's 280 by 192), so every dot is drawn the same size and a line one\n// dot thick is as thick as any other; the next whole number up from the column's width, a little\n// wider than it and centred on it, unless that is wider than the window; kept so as the window, or\n// its zoom, changes\nfunction evenly(canvas, dots, lines) {\n const stage = canvas.parentElement, column = stage.parentElement;\n const fit = () => {\n const dpr = window.devicePixelRatio || 1, pad = parseFloat(getComputedStyle(column).paddingLeft) * 2;\n const room = column.clientWidth - pad, most = document.documentElement.clientWidth - 16;\n let k = Math.ceil(room * dpr / dots - 0.01);\n if (dots * k / dpr > most) k = Math.max(1, Math.floor(most * dpr / dots));\n const w = dots * k / dpr;\n Object.assign(stage.style, { width: w + 'px', height: lines * k / dpr + 'px', aspectRatio: 'auto', marginLeft: (room - w) / 2 + 'px' });\n };\n fit();\n addEventListener('resize', fit);\n}\n\n// An Apple II game: the machine, the canvas, the keys, and the hooks for the vectors. With Apple's\n// ROMs and the game's disk images, where the page gives them (`roms`), it is line 1, the Apple itself booting the\n// disks; without them, moonbase's (line 2), the game started at once.\nasync function apple(game, { roms: makers, disk, canvas, ctx, layer, status, vectorToggle, speaker }) {\nconst [{ Machine }, { placed }, { withSaves, keepSaves, onDisks, driveFiles }, { screen }, { shapes }, { elements }] = await Promise.all([\n import('@moonbase-machines/apple2e/machine.js'), import('@moonbase-machines/apple2e/prodos.js'), import('@moonbase-machines/apple2e/saves.js'),\n import('@moonbase-machines/apple2e/screen.js'), import('@moonbase-machines/vector/pictures.js'), import('@moonbase-machines/vector/svg.js')]);\nevenly(canvas, 280, 192);\n// the title's saves on its own volume, the player's disk's (@moonbase-machines/apple2e/saves.js): on line 2 the\n// machine's files; on line 1 written onto that volume's disk before it boots, and kept as the title's DOS writes it\nconst saving = withSaves(game, disk);\nlet roms = null, disks = null;\nif (makers?.apple) try {\n roms = makers.apple;\n disks = onDisks(game, placed(saving, new Map(await Promise.all(game.images.map(async n => [n, await makers.image(n)])))), disk);\n} catch { roms = null; }\nconst m = new Machine(saving, { log: (...a) => console.log(...a), ...roms ? { roms, disks } : {} });\nconsole.log(roms ? \"line 1: Apple's ROMs, the disks booted\" : \"line 2: moonbase's machine\");\nkeepSaves(game, roms ? driveFiles(m, disks, game) : m.disk, disk);\nm.diskTime = true; // reads from the disk take the time a disk took, as the games' loading screens expect\n\n// Where the engine is hooked, found in PART0 once it is loaded, in whichever bank the game runs\n// in. The picture routine's loop draws the shapes the loader has put at $E000 one by one, so on\n// its first shape the whole picture is read for the SVG, and from there to the routine's exit,\n// which sets X to 0 and Y to $E0, the machine marks every screen byte written as the picture's.\n// The box routine, which clears the picture window, starts by keeping its three colors, and\n// there the SVG and the marks are cleared, and the window's color, in A, is kept to go under\n// the next pictures' polygons.\nlet hooked = false, window_ = 0;\nfunction hook() {\n const find = (bytes, code) => { outer: for (let a = 0x4000; a < 0x8000 - bytes.length; a++) { for (let i = 0; i < bytes.length; i++) if (bytes[i] !== null && code[a + i] !== bytes[i]) continue outer; return a; } return -1; };\n for (const code of [m.aux, m.main]) {\n const shape = find([0x20, null, null, 0x20, null, null, 0xee, null, null, 0x4c], code); // JSR fill; JSR outline; INC count; JMP loop\n const exit = find([0xa2, 0x00, 0xa0, 0xe0, 0x18, 0x60], code); // LDX #0; LDY #$E0; CLC; RTS\n const box = find([0x8d, null, null, 0x8e, null, null, 0x8c, null, null, 0xad, null, null, 0xc9, 0x80, 0xf0], code);\n if (shape < 0 || exit < 0 || box < 0) continue;\n m.cpu.hooks.set(shape, c => { if (c.read16(0x60) === 0xe000) { layer.insertAdjacentHTML('beforeend', elements(shapes(a => m.read(a), 0xe000), { background: window_ })); m.marking = 1; } return false; });\n m.cpu.hooks.set(exit, () => { m.marking = 0; return false; });\n m.cpu.hooks.set(box, c => { if (c.a !== 0x80) window_ = c.a & 15; layer.innerHTML = ''; m.owner.fill(0); return false; });\n hooked = true;\n return;\n }\n}\n\n// the keys, as the Apple II's keyboard gives them\nconst KEYS = { Escape: 27, Enter: 13, Backspace: 127, Delete: 127, ArrowLeft: 8, ArrowRight: 21, ArrowUp: 11, ArrowDown: 10, Tab: 9 };\nwindow.addEventListener('keydown', e => {\n speaker.start();\n if (e.metaKey || e.altKey || e.repeat) return; // a held key is one key\n // control with a letter is the Apple's control character: control-E opens Animal Rescue's main menu\n const k = e.ctrlKey ? (/^[a-z]$/i.test(e.key) ? e.key.toUpperCase().charCodeAt(0) & 0x1f : undefined) : KEYS[e.key] ?? (e.key.length === 1 ? e.key.charCodeAt(0) : undefined);\n if (k === undefined) return;\n console.log('key', JSON.stringify(e.key), '->', k, 'at pc $' + m.cpu.pc.toString(16));\n m.press(k); e.preventDefault();\n});\n\nconst rgba = new Uint8ClampedArray(560 * 384 * 4);\nconst image = new ImageData(rgba, 560, 384);\nconst cols = new Uint8Array(140 * 192);\nlet mode = '';\nfunction frame() {\n if (!m.halted) m.runCycles(17030); // a frame's worth of the Apple's clock, at 60 a second\n const now = `text ${m.sw.text} page2 ${m.sw.page2} hires ${m.sw.hires} dhires ${m.sw.dhires}`;\n if (now !== mode) { console.log('screen:', now, 'at pc $' + m.cpu.pc.toString(16), 'cycles', m.cpu.cycles); mode = now; }\n speaker.feed(m.clicks, m.cpu.cycles); m.clicks.length = 0;\n if (!hooked) hook();\n const text = m.sw.text;\n screen(m, rgba, { cols, owner: vectorToggle.checked && layer.innerHTML ? m.owner : null });\n ctx.putImageData(image, 0, 0);\n layer.style.visibility = vectorToggle.checked && !text ? 'visible' : 'hidden';\n status.textContent = m.halted ? 'The game has stopped: ' + m.halted + '.' : (m.idle > 2000 ? 'Waiting for a key.' : 'Running.');\n requestAnimationFrame(frame);\n}\ncanvas.addEventListener('pointerdown', () => { speaker.start(); canvas.focus(); });\ncanvas.focus();\nframe();\n}\n\n// A C64 game: on moonbase's own ROMs (@moonbase-machines/c64/rom.js), as the site has it everywhere, or on\n// Commodore's where the page gives them (`roms`) and asks for them; the machine autostarted\n// with LOAD\"name\",8,1, and RUN for a BASIC program, typed into the KERNAL's buffer, the frame on a canvas of\n// 384 by 272 doubled, the keys as the matrix and the arrows as the joystick.\nasync function c64(game, { name, roms: makers, studies, disk, downloadDisk, $, canvas, layer, status, vectorToggle, speaker }) {\n const [{ C64 }, { Printer, paper }, { WIDTH, HEIGHT }, { keyboard, painter }, { SID }, { c64Roms, typed: startTyped }, { add }, { keepDrive }] = await Promise.all([\n import('@moonbase-machines/c64/machine.js'), import('@moonbase-machines/c64/printer.js'), import('@moonbase-machines/c64/vic.js'), import('@moonbase-machines/c64/browser.js'),\n import('@moonbase-machines/c64/sid.js'), import('@moonbase-machines/c64/start.js'), import('@moonbase-machines/c64/d64.js'), import('@moonbase-machines/c64/saves.js')]);\n evenly(canvas, WIDTH, HEIGHT);\n const roms = await c64Roms(makers?.choice ?? null, makers?.load);\n if (!roms) { status.textContent = 'Commodore\\'s ROMs, asked for, are not here.'; return; }\n // a printer on device 4 (@moonbase-machines/c64/printer.js): on unless its box is off, what it prints drawn\n // below the screen as a sheet of paper, until it is torn off\n const box = $('printer'), sheet = $('paper'), shown = $('paper-box');\n try { box.checked = localStorage.getItem('printer') !== '0'; } catch {}\n box.parentElement.hidden = false;\n const printer = new Printer({ on: box.checked });\n box.addEventListener('change', () => { printer.on = box.checked; try { localStorage.setItem('printer', box.checked ? '1' : '0'); } catch {} });\n printer.changed = () => { shown.hidden = !printer.lines.length; if (printer.lines.length) paper(sheet, printer, roms.chargen); };\n $('tear').addEventListener('click', () => printer.tear());\n $('print-paper').addEventListener('click', () => window.print()); // (the sheet alone: its print style)\n const m = new C64(game, roms, { log: (...a) => console.log(...a), printer });\n // What the game SAVEs to its disk, kept on the player's disk and given back to the drive the next time\n // (@moonbase-machines/c64/saves.js)\n keepDrive(m.drive, disk);\n // (and, where the page gives them, `studies`, files of its own for the disk, a name to a file: in the drive, not\n // kept)\n const raw = t => Uint8Array.from(atob(t), c => c.charCodeAt(0));\n for (const [file, data] of Object.entries(studies ?? {})) m.drive.saved.set(file, raw(data));\n // the disk as it now stands, its own files and those saved, to download where the title offers it\n // (Crayon's): a .d64 that VICE or a real 64 can use (@moonbase-machines/c64/d64.js `add`)\n if (downloadDisk) {\n const download = $('disk');\n download.hidden = false;\n download.addEventListener('click', () => {\n const image = add(m.drive.image, [...m.drive.saved].map(([name, data]) => ({ name, data })));\n const a = Object.assign(document.createElement('a'), { href: URL.createObjectURL(new Blob([image], { type: 'application/octet-stream' })), download: name + '.d64' });\n a.click(); URL.revokeObjectURL(a.href);\n });\n }\n layer.style.display = 'none'; vectorToggle.parentElement.style.display = 'none';\n const draw = painter(canvas);\n let typing = null, typed = 0;\n const keys = keyboard(m, { onKey: () => speaker.start(), log: true });\n // once BASIC is ready, the start typed in; the KERNAL's buffer takes ten characters at a time.\n // The C64 runs 50 frames a second, so frames are run to keep up with the clock, two at most.\n let frames = 0, sid = null, started = performance.now();\n function frame() {\n const due = Math.min(2, Math.floor((performance.now() - started) / 20) - frames);\n for (let i = 0; i < due; i++) {\n m.runFrame(); frames++; keys.frame();\n if (speaker.node) {\n if (!sid) sid = new SID(speaker.rate);\n const n = Math.round(19656 / 985248 * speaker.rate), first = m.cpu.cycles - 19656;\n const wave = sid.render(n, m.sidWrites.map(([c, r, v]) => [Math.floor((c - first) / 19656 * n), r, v]));\n speaker.node.port.postMessage(wave, [wave.buffer]);\n }\n m.sidWrites.length = 0;\n }\n // (LOAD, and RUN for a BASIC program: @moonbase-machines/c64/start.js)\n if (frames >= 120 && typing === null && !typed) { typing = startTyped(m, game); typed = 1; }\n if (typing !== null && !m.ram[0xc6]) { typing = m.type(typing); if (!typing.length) typing = null; }\n draw(m.vic.frame);\n status.textContent = m.halted ? 'The game has stopped: ' + m.halted + '.' : 'Running.';\n requestAnimationFrame(frame);\n }\n canvas.focus(); frame();\n}\n", "// The speaker. The Apple II makes sound by clicking the speaker, a toggle at $C030, and the\n// machine keeps the cycle of each click. `Speaker` turns a run of cycles into a square wave\n// at the sound card's rate and plays it through a worklet, which keeps a queue of what it has\n// been given and holds the last level when the queue runs dry.\nconst CYCLES_PER_SECOND = 1020484;\n\nconst WORKLET = `\nclass SpeakerProcessor extends AudioWorkletProcessor {\n constructor() { super(); this.queue = []; this.at = 0; this.level = 0; this.port.onmessage = e => this.queue.push(e.data); }\n process(inputs, outputs) {\n const out = outputs[0][0];\n for (let i = 0; i < out.length; i++) {\n while (this.queue.length && this.at >= this.queue[0].length) { this.queue.shift(); this.at = 0; }\n if (this.queue.length) this.level = this.queue[0][this.at++];\n out[i] = this.level;\n }\n return true;\n }\n}\nregisterProcessor('speaker', SpeakerProcessor);\n`;\n\nexport class Speaker {\n constructor() { this.context = null; this.node = null; this.level = 0; this.from = null; }\n\n // start on a gesture, as browsers require\n async start() {\n if (this.context) return;\n this.context = new AudioContext();\n await this.context.audioWorklet.addModule(URL.createObjectURL(new Blob([WORKLET], { type: 'text/javascript' })));\n this.node = new AudioWorkletNode(this.context, 'speaker');\n this.node.connect(this.context.destination);\n this.rate = this.context.sampleRate;\n if (this.context.state !== 'running') await this.context.resume();\n }\n\n // the wave for the cycles from the last call up to `cycles`, given the clicks in between\n feed(clicks, cycles) {\n if (!this.node) return;\n if (this.from === null) this.from = cycles; // from when the sound starts, not from the machine's first cycle\n const perSample = CYCLES_PER_SECOND / this.rate;\n const n = Math.floor((cycles - this.from) / perSample);\n if (n <= 0) return;\n const wave = new Float32Array(n);\n let ci = 0;\n for (let i = 0; i < n; i++) {\n const t = this.from + (i + 1) * perSample;\n while (ci < clicks.length && clicks[ci] <= t) { this.level = this.level ? 0 : 0.25; ci++; }\n wave[i] = this.level;\n }\n this.from += n * perSample;\n this.node.port.postMessage(wave, [wave.buffer]);\n }\n}\n", "// The parts both players make the same: the printer's paper under the screen, and a phone's keyboard.\n//\n// paperBox(words) the paper's box (hidden until there is something printed): its line, Print and\n// Tear off, and the sheet (#paper-box, #print-paper, #tear, #paper)\n// phoneKeys(root, stage) on a phone, the Keyboard button (#keyboard) opens its keyboard on a box (#keys-box)\n// whose keys go to the window's own listener; a keyboard that names no key gives\n// its characters, passed on as keys\nexport function paperBox({ line, print, tear }) {\n const box = document.createElement('div');\n box.id = 'paper-box'; box.hidden = true;\n box.innerHTML = '<p><span></span> <button id=\"print-paper\" type=\"button\"></button> <button id=\"tear\" type=\"button\"></button></p><canvas id=\"paper\"></canvas>';\n box.querySelector('span').textContent = line;\n box.querySelector('#print-paper').textContent = print;\n box.querySelector('#tear').textContent = tear;\n return box;\n}\n\nexport function phoneKeys(root, stage) {\n const kb = root.querySelector('#keyboard'), box = root.querySelector('#keys-box');\n if (!kb || !box || !matchMedia('(pointer: coarse)').matches) return;\n kb.hidden = false;\n kb.addEventListener('click', () => box.focus());\n stage.addEventListener('click', () => box.focus());\n let unnamed = false;\n box.addEventListener('keydown', e => { unnamed = e.key === 'Unidentified'; });\n box.addEventListener('input', () => {\n if (unnamed) for (const ch of box.value) for (const t of ['keydown', 'keyup']) window.dispatchEvent(new KeyboardEvent(t, { key: ch }));\n box.value = '';\n });\n}\n\n// the options line's keyboard parts, as both players have them\nexport const KEYS_MARKUP = '<button type=\"button\" id=\"keyboard\" class=\"full\" hidden>Keyboard</button><input id=\"keys-box\" class=\"keys-box\" autocomplete=\"off\" autocapitalize=\"off\" autocorrect=\"off\" spellcheck=\"false\" aria-label=\"Keys for the game\">';\n", "// A modal window, the one way every dialog and window over a game is shown: the disk's dialogs\n// (disk/dialogs.js) and a program's own windows (Aztlan's help and About box, its macapp.js). It opens\n// inside the place it is given, the game's screen, not over the whole page: what it covers is that place\n// alone, which scrolls with it, and the rest of the page is the page's. Its frame and look are the place's\n// (a class, as Aztlan's window definition 1 has it, and the place's own styles); without a place, the page.\n//\n// const m = modal({ within, className, content, cancel })\n// within the element it opens in (positioned), else the page\n// className its frame's classes\n// content what it shows\n// cancel() what Escape does (closing it, else)\n// m.box, m.close()\n// While it is open the rest of `within` is inert, and the keys are the topmost one's, wherever the focus\n// is (WebKit leaves it on the page when a button is clicked): Escape cancels; Return presses its default\n// button (`.default`), unless on a button, or in a box that takes Return itself; Tab stays inside it. When\n// it closes the focus goes back where it was, or into the window under it.\nconst open = [];\n// (listened for from the first one opened: a module the tests load in Node, with no page)\nlet listening = false;\nconst keys = e => {\n const m = open.at(-1);\n if (!m) return;\n if (e.key === 'Escape') { e.preventDefault(); m.cancel(); }\n else if (e.key === 'Enter' && !(e.target instanceof HTMLButtonElement) && e.target.tagName !== 'TEXTAREA') {\n const d = m.box.querySelector('.default:not(:disabled)');\n if (d) { e.preventDefault(); d.click(); }\n }\n else if (e.key === 'Tab') {\n const f = focusable(m.box), at = f.indexOf(document.activeElement);\n if (f.length) { e.preventDefault(); f[(at + (e.shiftKey ? f.length - 1 : 1)) % f.length].focus(); }\n }\n // (the game under it has none of the keys)\n e.stopPropagation();\n};\nconst focusable = box => [...box.querySelectorAll('button:not(:disabled), input:not([type=hidden]):not([type=file]):not([hidden]), select:not([hidden]), [tabindex=\"0\"]')];\nconst first = box => box.querySelector('input:not([type=file]), select:not([hidden])') ?? box.querySelector('.default') ?? focusable(box)[0];\n\nexport function modal({ within = document.body, className = '', content, cancel = null }) {\n if (!listening) { document.addEventListener('keydown', keys, true); listening = true; }\n const layer = document.createElement('div');\n layer.className = 'modal-layer' + (within === document.body ? ' page' : '');\n const box = document.createElement('div');\n box.className = 'modal ' + className;\n box.setAttribute('role', 'dialog'); box.setAttribute('aria-modal', 'true');\n box.append(content); layer.append(box);\n const before = document.activeElement;\n const others = [...within.children].filter(el => !el.inert);\n for (const el of others) el.inert = true;\n within.append(layer);\n const m = {\n box,\n cancel: () => (cancel ?? m.close)(),\n close() {\n layer.remove();\n open.splice(open.indexOf(m), 1);\n for (const el of others) el.inert = false;\n const under = open.at(-1);\n (under && !under.box.contains(before) ? first(under.box) : before)?.focus?.({ preventScroll: true });\n },\n };\n open.push(m);\n // (the first box to type in or list to choose from, else the default button, has the focus)\n first(box)?.focus({ preventScroll: true });\n return m;\n}\n\n// whether a modal window is open: a game's keys and commands wait while one is\nexport const modalOpen = () => open.length > 0;\n", "// The disk's own dialogs, the same in every game that hands saving to the system (as Aztlan for Macintosh\n// handed it to the Mac's): a game is saved by name, and opened from the disk's list, or from a file\n// downloaded before. A game that asks on its own screen (the 8-bit games) keeps its own prompt; the disk\n// only keeps what it saves. Each is a modal window (../modal.js) opened where the game says, its host: in\n// its screen, in the frame its own windows have (Aztlan's, window definition 1, the Mac's dialog box), and\n// so looking as its own windows look; with no host, on the page, as the site's (site/assets/site.css).\n//\n// const { saveAs, openFrom, ask, tell } = dialogs({ within, className }) the game's host\n// await saveAs(disk, { suggested }) a name, or null: offers to replace a file of that name\n// await openFrom(disk, { file }) { name, bytes } from the disk, or null: the disk's manager, the\n// same for every game, its games listed, each to open, download\n// or delete, and a downloaded one put back on it from a file\n// (`file`, the game's own: { extension, type }, '.zip' and its type)\n// await ask(heading, body, buttons, { aside }) a dialog of a game's own: [label, value] buttons, the\n// last the default, a function's value what it returns; `aside`,\n// buttons of the dialog's own on the same line, at its left\n// await tell(heading) a word, and OK\nimport { modal } from '../modal.js';\n\nexport function dialogs({ within, className = '' } = {}) {\n function ask(heading, body, buttons, { aside = [] } = {}) {\n return new Promise(done => {\n const content = document.createElement('div'); content.className = 'disk';\n const h = document.createElement('h2'); h.textContent = heading;\n const row = document.createElement('p'); row.className = 'buttons';\n for (const [label, value] of buttons) {\n const b = Object.assign(document.createElement('button'), { type: 'button', textContent: label });\n b.onclick = async () => { m.close(); done(typeof value === 'function' ? await value() : value); };\n row.append(b);\n }\n row.lastChild?.classList.add('default');\n if (aside.length) { const left = document.createElement('span'); left.className = 'aside'; left.append(...aside); row.prepend(left); }\n content.append(h, ...body, row);\n // (Escape: nothing chosen)\n const m = modal({ within, className, content, cancel: () => { m.close(); done(null); } });\n });\n }\n const tell = heading => ask(heading, [], [['OK', null]]);\n\n async function saveAs(disk, { suggested = '' } = {}) {\n const input = Object.assign(document.createElement('input'), { value: suggested, maxLength: 31 });\n setTimeout(() => input.select());\n const label = document.createElement('label'); label.append('Save as ', input);\n const name = await ask('Save', [label, ...keptNote(disk)], [['Cancel', null], ['Save', () => input.value.trim() || null]]);\n if (!name) return null;\n if (disk.read(name) && !await ask(`Replace \"${name}\"?`, [], [['Cancel', false], ['Replace', true]])) return null;\n return name;\n }\n\n async function openFrom(disk, { file: { extension = '', type = 'application/octet-stream' } = {} } = {}) {\n const select = Object.assign(document.createElement('select'), { size: 6 });\n const note = document.createElement('p'); note.className = 'note';\n const input = Object.assign(document.createElement('input'), { type: 'file', accept: [extension, type].filter(Boolean).join(','), hidden: true });\n const button = text => Object.assign(document.createElement('button'), { type: 'button', textContent: text });\n const from = button('File\u2026'), download = button('Download'), remove = button('Delete');\n const fill = () => {\n select.replaceChildren(...disk.list().map(f => new Option(`${f.name} \u00B7 ${new Date(f.modified).toLocaleString()}`, f.name)));\n select.selectedIndex = select.options.length ? 0 : -1;\n select.hidden = !select.options.length;\n note.textContent = select.options.length ? 'On your disk:' : 'Nothing saved on your disk yet.';\n remove.disabled = download.disabled = !select.options.length;\n };\n fill();\n const chosen = ask('Open', [note, select, input, ...keptNote(disk)], [['Cancel', null], ['Open', () => select.value || null]], { aside: [from, download, remove] });\n const open = () => select.closest('.modal').querySelector('.default').click();\n // (File\u2026: a game downloaded before, put back on the disk by its file's name, and opened)\n from.onclick = () => input.click();\n input.onchange = async () => {\n const f = input.files[0], n = f.name.slice(0, f.name.length - (extension && f.name.endsWith(extension) ? extension.length : 0));\n if (disk.read(n) && !await ask(`Replace \"${n}\"?`, [], [['Cancel', false], ['Replace', true]])) return;\n disk.write(n, new Uint8Array(await f.arrayBuffer()));\n fill(); select.value = n; open();\n };\n // (a game taken off the disk as its file, to keep, or for the original: Aztlan's for Infinite Mac)\n download.onclick = () => {\n const n = select.value; if (!n) return;\n const a = Object.assign(document.createElement('a'), { href: URL.createObjectURL(new Blob([disk.read(n)], { type })), download: n + extension });\n a.click(); setTimeout(() => URL.revokeObjectURL(a.href), 1000);\n };\n // (a file deleted only once asked, in a dialog over this one, Cancel its default)\n remove.onclick = async () => {\n const n = select.value; if (!n) return;\n if (!await ask(`Delete \"${n}\"?`, [warning('It is gone from your disk for good.')], [['Delete', true], ['Cancel', false]])) return;\n await disk.remove(n); fill(); select.focus();\n };\n select.ondblclick = open;\n const name = await chosen;\n return name ? { name, bytes: disk.read(name) } : null;\n }\n return { saveAs, openFrom, ask, tell };\n}\n\nconst warning = text => Object.assign(document.createElement('p'), { className: 'note', textContent: text });\n\n// (where the browser keeps nothing, a word saying so: the game is there until the page closes)\nfunction keptNote(disk) {\n if (disk.kept) return [];\n const p = document.createElement('p'); p.className = 'note';\n p.textContent = 'This browser is not keeping files: download a game to keep it.';\n return [p];\n}\n", "// The player's disk: the files a person makes, kept by name on a disk of their own, one for each title\n// and one for each program that saves (Microsoft BASIC's tape and disk, the editors). Every game and\n// program that saves does so here, and only here; its files are its own bytes, in its own format, with\n// what the format needs beside them (`meta`, a ProDOS file's type and aux).\n//\n// A disk is read whole when it is opened, before the program starts, and kept in memory: the machines\n// read files at once, inside an instruction (@moonbase-machines/apple2e/machine.js's MLI call,\n// @moonbase-machines/c64/drive.js's find), so a read is never waited for. A write changes the copy at once and is stored behind\n// it, in order.\n//\n// const disk = await openDisk(name, { backend }) backend: local() (local.js, the default)\n// or memory() (memory.js)\n// disk.list() [{ name, size, modified, meta }], newest first\n// disk.read(name) its bytes, or null\n// disk.write(name, bytes, meta) a promise, kept when stored\n// disk.remove(name) a promise\n// disk.written() a promise: every write so far stored\n// disk.name, disk.kept the disk's name; whether its files outlast the page\n//\n// A disk's name says whose it is, so a title and a program can never share one: titleDisk(slug), a title's\n// player's, 'title/zoopak'; programDisk(name), one of the site's own programs', 'program/basic'.\n//\n// The backend is where a disk's files are kept: { kept, load(disk), put(disk, file), delete(disk, name) },\n// a file { name, bytes, meta, modified }. This browser's is local(); an account's will be the API's.\nimport { local } from './local.js';\nimport { memory } from './memory.js';\n\nexport async function openDisk(name, { backend } = {}) {\n // (a browser that keeps nothing, as a private window may: the disk in memory, and said so)\n if (!backend) { try { backend = await local(); } catch { backend = memory({ kept: false }); } }\n const files = new Map((await backend.load(name)).map(f => [f.name, f]));\n let queue = Promise.resolve();\n const later = job => (queue = queue.then(job));\n return {\n name,\n kept: backend.kept,\n list: () => [...files.values()].sort((a, b) => b.modified - a.modified).map(({ name, bytes, meta, modified }) => ({ name, size: bytes.length, modified, meta })),\n read: n => files.get(n)?.bytes ?? null,\n write(n, bytes, meta = {}) {\n const f = { name: n, bytes: Uint8Array.from(bytes), meta, modified: Date.now() };\n files.set(n, f);\n return later(() => backend.put(name, f));\n },\n remove(n) {\n files.delete(n);\n return later(() => backend.delete(name, n));\n },\n written: () => queue,\n };\n}\n\nexport const titleDisk = slug => `title/${slug}`;\nexport const programDisk = name => `program/${name}`;\n\n// a text file's bytes and back, for the programs whose files are text (UTF-8)\nexport const textBytes = s => new TextEncoder().encode(s);\nexport const bytesText = b => b ? new TextDecoder().decode(b) : null;\n", "// A disk's files kept in this browser, in IndexedDB: the database `moonbase`, its store `files`, each file\n// keyed by its account, its disk and its name. The account is `local`, this browser's own, until there\n// are accounts; theirs will be kept by the API, behind the same calls.\n//\n// await local({ account }) a backend: { kept, load(disk), put(disk, file), delete(disk, name) }\n// (named here once, for a tool that puts a file on a disk too)\nexport const DB = 'moonbase', VERSION = 1, STORE = 'files', KEY = ['account', 'disk', 'name'], ACCOUNT = 'local';\n\nconst opened = () => new Promise((done, fail) => {\n const r = indexedDB.open(DB, VERSION);\n r.onupgradeneeded = () => r.result.createObjectStore(STORE, { keyPath: KEY });\n r.onsuccess = () => done(r.result);\n r.onerror = () => fail(r.error);\n});\nconst asked = r => new Promise((done, fail) => { r.onsuccess = () => done(r.result); r.onerror = () => fail(r.error); });\n\nexport async function local({ account = ACCOUNT } = {}) {\n const db = await opened();\n const store = mode => db.transaction(STORE, mode).objectStore(STORE);\n return {\n kept: true,\n // (the disk's files: those keyed from [account, disk] up to the next disk's)\n load: async disk => (await asked(store('readonly').getAll(IDBKeyRange.bound([account, disk], [account, disk, []]))))\n .map(({ name, bytes, meta, modified }) => ({ name, bytes, meta, modified })),\n put: (disk, f) => asked(store('readwrite').put({ account, disk, ...f })),\n delete: (disk, name) => asked(store('readwrite').delete([account, disk, name])),\n };\n}\n", "// A disk's files kept in memory only, for as long as the page: for the tests, which run where there is no\n// IndexedDB, and for a browser that will keep nothing (disk.js says which, `kept`).\n//\n// memory({ kept }) a backend: { kept, load(disk), put(disk, file), delete(disk, name) }\nexport function memory({ kept = true } = {}) {\n const disks = new Map(), of = d => disks.get(d) ?? disks.set(d, new Map()).get(d);\n return {\n kept,\n load: async d => [...of(d).values()].map(f => ({ ...f, bytes: Uint8Array.from(f.bytes) })),\n put: async (d, f) => { of(d).set(f.name, { ...f, bytes: Uint8Array.from(f.bytes) }); },\n delete: async (d, n) => { of(d).delete(n); },\n };\n}\n", "// The view of a Commodore 64 title (Zoopak): the frame the VIC-II paints from the remake's\n// memory and chips (@moonbase-machines/c64/paint.js), border and all, 384 by 272 in the machine's colours. The\n// character ROM, which a text screen in the machine's own letters needs, is the one the emulator\n// is given (the page's `roms`), when it is there.\nimport { paint } from '@moonbase-machines/c64/paint.js';\nimport { PALETTE, WIDTH, HEIGHT } from '@moonbase-machines/c64/vic.js';\n\nconst NS = 'http://www.w3.org/2000/svg';\n\nexport class C64View {\n constructor(svg, { engine, chargen }) {\n this.svg = svg; this.engine = engine; this.chargen = chargen;\n svg.setAttribute('viewBox', `0 0 ${WIDTH * 2} ${HEIGHT * 2}`);\n this.canvas = document.createElement('canvas'); this.canvas.width = WIDTH; this.canvas.height = HEIGHT;\n this.image = document.createElementNS(NS, 'image');\n for (const [k, v] of Object.entries({ x: 0, y: 0, width: WIDTH * 2, height: HEIGHT * 2, preserveAspectRatio: 'none', style: 'image-rendering: pixelated' })) this.image.setAttribute(k, v);\n svg.append(this.image);\n }\n snapshot(e) { return e; }\n apply() {}\n prompts() {\n const e = this.engine, frame = paint(e.mem, e.title.chip, this.chargen, this.vic, e.title.splits);\n const ctx = this.canvas.getContext('2d'), pixels = ctx.createImageData(WIDTH, HEIGHT);\n for (let i = 0; i < frame.length; i++) { const [r, g, b] = PALETTE[frame[i]]; pixels.data.set([r, g, b, 255], i * 4); }\n ctx.putImageData(pixels, 0, 0);\n // and the border's colour on either side, where the page is wider than the frame\n this.svg.style.background = `rgb(${PALETTE[frame[0]].join(',')})`;\n this.image.setAttribute('href', this.canvas.toDataURL());\n }\n}\n", "import { paint as m } from '@moonbase-machines/c64';\nexport const { paint } = m;", "// The view of a card toolkit title (card.js): the screen as the remake's memory holds\n// it, the hi-res page the soft switches show, or the text screen, painted dot for dot as the\n// machine's page paints it (@moonbase-machines/apple2e/screen.js), 560 by 384. The toolkit's pictures are bitmaps,\n// and this is them as they are; drawing them sharper is for later.\n//\n// `inset` (a title's, its title.js), when set on: the screen's band at the top, where it is (its rows above\n// `top` all white), its dots `move` moved `by`, to make room for a mini view; `banded`, whether the band was there\n// at the last painting.\nimport { paintHires, paintText } from '@moonbase-machines/apple2e/screen.js';\n\nconst NS = 'http://www.w3.org/2000/svg';\n\nexport class CardView {\n constructor(svg, { engine, inset = null }) {\n this.svg = svg; this.engine = engine; this.inset = inset; this.insetOn = false; this.banded = false;\n svg.setAttribute('viewBox', '0 0 560 384');\n this.canvas = document.createElement('canvas'); this.canvas.width = 560; this.canvas.height = 384;\n this.image = document.createElementNS(NS, 'image');\n for (const [k, v] of Object.entries({ x: 0, y: 0, width: 560, height: 384, preserveAspectRatio: 'none', style: 'image-rendering: pixelated' })) this.image.setAttribute(k, v);\n svg.append(this.image);\n }\n snapshot(e) { return e; }\n apply() {}\n // the screen, when a run has gone as far as it goes\n prompts() {\n const mem = this.engine.mem, s = this.engine.title.screen, ctx = this.canvas.getContext('2d');\n const pixels = ctx.createImageData(560, 384);\n if (s.text) paintText(pixels.data, mem, mem, false, [0, 24]);\n else {\n const page = s.page2 ? 0x4000 : 0x2000;\n paintHires(pixels.data, mem.subarray(page, page + 0x2000));\n if (s.mixed) paintText(pixels.data, mem, mem, false, [20, 24]);\n }\n this.banded = this.insetOn && !!this.inset && band(pixels.data, this.inset);\n if (this.banded) shift(pixels.data, this.inset);\n ctx.putImageData(pixels, 0, 0);\n this.image.setAttribute('href', this.canvas.toDataURL());\n }\n}\n\n// (whether the band is on the screen: its rows above `top` white, the whole width)\nfunction band(px, { top }) {\n for (let y = 0; y < top; y++) for (let x = 0; x < 560; x++) { const i = (y * 560 + x) * 4; if (px[i] < 200 || px[i + 1] < 200 || px[i + 2] < 200) return false; }\n return true;\n}\n// (the band's rows `top` to `bottom`: the dots `move` moved `by`, white where they were)\nfunction shift(px, { top, bottom, move: [from, to], by }) {\n for (let y = top; y <= bottom; y++) {\n const row = y * 560 * 4;\n px.copyWithin(row + (from + by) * 4, row + from * 4, row + to * 4);\n if (by < 0) px.fill(255, row + (to + by) * 4, row + to * 4); else px.fill(255, row + from * 4, row + (from + by) * 4);\n }\n}\n", "// The routines of a card title, for the remake engine, as its title.js `map` names them (cards.js):\n// what each step of a script does. The toolkit's own code is lifted into scripts too, the\n// libraries beside the scenes, and a step that is one of its entries runs that code inside\n// itself, so that only the step is in the transcript, as the original's observer sees only the\n// call. What cannot be a script is here: the routines that take their data inline (fill, copy\n// and print), Applesoft's and the Monitor's routines in ROM (@moonbase-machines/apple2e/rom.js), ProDOS's calls\n// (@moonbase-machines/apple2e/mli.js), and the keyboard and the soft switches. The screen is the hi-res pages in the\n// engine's own memory, $2000 and $4000, written byte for byte as the original writes them.\nimport { describe, result, TAKES, GIVES } from './events.js';\nimport { INLINE, sectionName } from './cards.js';\nimport { Files, BLOCK, CLOCK } from '@moonbase-machines/apple2e/mli.js';\nimport { install as installRom } from '@moonbase-machines/apple2e/rom.js';\nimport { install as installKernal, VIC, VECTORS, kernalByte, KEY_TABLES } from '@moonbase-machines/c64/kernal.js';\nimport { Drive } from '@moonbase-machines/c64/drive.js';\nimport { Printer, bus } from '@moonbase-machines/c64/printer.js';\nimport { Basic } from '@moonbase-machines/c64/basic.js';\nimport { BasicError } from '@moonbase-machines/c64/numbers.js';\nimport { install as installBasicRom, printError } from '@moonbase-machines/c64/basic-rom.js';\nimport { lift, script as scriptOf, readers } from './lift.js';\n\nconst hex4 = n => n.toString(16).toUpperCase().padStart(4, '0');\n\n// The inputs of a step: numbers for the registers it takes, the carry among them, or a\n// register's own name for what it holds already. A number is a load the lifter folded into the\n// step, and the load set the flags, which a routine may test before anything sets them again\n// ($74FA tests A's): they are set as A's load set them, or else as the last register's.\nfunction inputs(e, name, args) {\n const takes = TAKES[name] || '';\n let k = 0, loaded = null;\n for (const r of takes) {\n const v = args[k++];\n if (v === undefined || v === r || typeof v === 'object') continue;\n const n = v.startsWith('$') ? e.mem[parseInt(v.slice(1), 16)] : +v;\n if (r === 'c') e.c = n & 1; else { e[r] = n & 0xff; if (loaded !== 'a') loaded = r; }\n }\n if (loaded) e.flags(e[loaded]);\n return args.slice(k);\n}\n\nexport function cardRoutines(title) {\n const toolkit = title.map;\n const c64 = title.disk.kind === 'c64';\n const files = c64 ? null : title.files ??= new Files(title.disk);\n // the soft switches: what the screen shows\n const screen = title.screen ??= { text: 1, mixed: 0, page2: 0, hires: 0 };\n // the keyboard's latch, its high bit set until $C010 is read\n let latch = 0;\n\n // The I/O page. The keyboard is read as the machine counts its reads (@moonbase-machines/apple2e/machine.js), every\n // read of $C000 and every touch of $C010 with no key waiting, and two thousand in a run stop it\n // to wait for a key (Engine.polled): so the remake waits where the original's run stopped, and\n // a scene that animates while it polls has run as many frames.\n // The language card, $C080 to $C08F: which of its two 4K banks is at $D000, and whether the card\n // or the ROM is read there. The engine has one memory, so the bank not there is kept aside and\n // swapped in when it is switched to (Pieces of Eight keeps its descriptions in one and its map\n // in the other). The card's write-protect, and the ROM's own bytes, are not kept.\n const lc = { bank: 2, read: 0, aside: new Uint8Array(0x1000) };\n const bankTo = (e, bank) => {\n if (bank === lc.bank) return;\n const here = e.mem.slice(0xd000, 0xe000); e.mem.set(lc.aside, 0xd000); lc.aside = here; lc.bank = bank;\n };\n // The Commodore 64's I/O page, $D000 to $DFFF while the 6510's port at $01 shows it there (and\n // its RAM while not): the VIC's registers, the SID's, the colours, and the two CIAs. The games\n // read the first CIA's timer and clock for their random numbers, which are the seed, as the\n // observer makes them (the pilots' observer); its keyboard and joystick lines read nothing\n // held, since the keys come through GETIN.\n const chip = title.chip = new Uint8Array(0x1000); // (the view paints from it: @moonbase-machines/c64/paint.js)\n const SEEDED = { 4: s => s & 0xff, 5: s => s >> 8 & 0xff, 8: s => (s * 7) & 0xff, 9: s => (s * 13) & 0xff };\n function io64(e, at, v) {\n const r = at & 0xfff;\n if (r < 0x400) { // the VIC, its 64 registers again every 64\n const reg = r & 0x3f;\n // the raster line, which a game waits on (Feeding Time for line 256, Petra's Dream for $D011's\n // top bit) and takes random numbers from with the CIA's: a line on at each read of $D012 or\n // $D011, whose top bit is its ninth, as the observer makes them (the pilots' observer), so\n // that both sides read the same. On the page's clock (`e.clock`), the line the original's\n // time has reached, 63 cycles each, so that a wait for one takes the time it took.\n if (v === undefined && (reg === 0x11 || reg === 0x12)) {\n e.raster = e.clock ? Math.floor(e.cycles / 63) % 312 : ((e.raster ?? 0) + 1) % 312;\n return reg === 0x12 ? e.raster & 0xff : (chip[0x11] & 0x7f) | (e.raster >> 1 & 0x80);\n }\n // which interrupt it is ($D019): the raster's, or none of the VIC's (the CIA's timer)\n if (v === undefined && reg === 0x19) return e.vicFlags ?? 0x70;\n if (v === undefined) return chip[reg];\n chip[reg] = v;\n // a raster interrupt's writes, kept by its line for the view (@moonbase-machines/c64/paint.js), until the\n // raster interrupt is turned off\n // (on the page's clock, the last whole frame's: a frame's writes are kept apart until its\n // raster comes round, routines.before, so that none lingers from a screen before)\n if (e.splitLine !== undefined && reg !== 0x19) { const s = e.clock ? (e.clock.splits ??= new Map()) : (title.splits ??= new Map()); (s.get(e.splitLine) ?? s.set(e.splitLine, new Map()).get(e.splitLine)).set(reg, v); }\n if (reg === 0x1a && !(v & 1)) title.splits?.clear();\n return;\n }\n if (r < 0x800) { const reg = 0x400 | (r & 0x1f); if (v === undefined) return chip[reg]; chip[reg] = v; e.sid?.push([e.cycles, r & 0x1f, v]); return; } // the SID\n if (r < 0xc00) { if (v === undefined) return chip[r] | 0xf0; chip[r] = v & 15; return; } // the colours\n if (r < 0xd00) { // CIA 1\n const reg = r & 15;\n if (v === undefined) return SEEDED[reg] ? SEEDED[reg](title.seed ?? 0x11) : reg < 2 ? 0xff : reg === 0x0d ? 0 : chip[0xc00 | reg];\n chip[0xc00 | reg] = v; return;\n }\n if (v === undefined) return chip[r]; chip[r] = v; // CIA 2, its first port the VIC's bank\n // (a raster interrupt's change of the bank kept with its line too, as $100: a map in a\n // bitmap above, text below, Goldfields' horse ride)\n if ((r & 15) === 0 && e.splitLine !== undefined) { const s = e.clock ? (e.clock.splits ??= new Map()) : (title.splits ??= new Map()); (s.get(e.splitLine) ?? s.set(e.splitLine, new Map()).get(e.splitLine)).set(0x100, v); }\n }\n const ioShown = e => (e.mem[1] & 3) !== 0 && (e.mem[1] & 4) !== 0;\n function io(e, at, v) {\n if (c64 && at >= 0xe000) { if (v === undefined) return kernalByte(at); e.mem[at] = v; return; } // the KERNAL's keyboard tables, RAM under them written\n if (c64) return io64(e, at, v);\n if ((at & 0xfff0) === 0xc080) { const b = at & 15; bankTo(e, b & 8 ? 1 : 2); lc.read = (b & 1) === ((b >> 1) & 1) ? 1 : 0; return 0; }\n if (at >= 0xc050 && at <= 0xc057) { const s = ['text', 'mixed', 'page2', 'hires'][(at - 0xc050) >> 1]; screen[s] = at & 1; return 0; }\n if (at === 0xc000 && v === undefined) {\n // (none, -1, read here and not at a tick, is no key, as on the original, where it is pressed as nothing)\n if (!(latch & 0x80)) { const k = e.key(); if (k !== undefined && k >= 0) latch = k | 0x80; }\n if (++e.idle > 2000) e.polled = true;\n return latch;\n }\n if (at === 0xc010) { const r = latch; if (!(latch & 0x80) && ++e.idle > 2000) e.polled = true; latch &= 0x7f; return r; }\n // the speaker, a click at the cycle it came (Engine.time)\n if (at === 0xc030) { e.clicks.push(e.cycles); return 0; }\n return 0;\n }\n\n // Applesoft's and the Monitor's routines, as the machine has them (@moonbase-machines/apple2e/rom.js), on a stand-in\n // for its processor that reads and writes the engine's memory\n let engine = null;\n const cpu = { hooks: new Map(), cycles: 0, a: 0, x: 0, y: 0, z: 0, c: 0, n: 0, v: 0, read: a => engine.mem[a], write: (a, v) => { engine.mem[a] = v & 0xff; }, nz(v) { this.n = v >> 7 & 1; this.z = v ? 0 : 1; } };\n // the bell's clicks, at their cycles from the routine's start, the engine's then (`romFrom`)\n let romFrom = 0;\n if (c64) installKernal({ cpu, read: a => engine.read(a), write: (a, v) => engine.write(a, v), drive: title.bus ??= bus(title.drive ??= new Drive(Uint8Array.from(atob(title.disk.image), ch => ch.charCodeAt(0))), title.printer ??= new Printer({ on: false })), // (the drive and a printer, device 4, on the bus: @moonbase-machines/c64/printer.js)\n // (a key let go before any scan saw it is seen once, as a tap)\n held: () => { const h = engine?.clock?.held; if (h?.up) engine.clock.held = null; if (h) h.seen = true; return h ?? null; },\n call: at => { runNow(engine, at, 'the keyboard read'); Object.assign(cpu, { a: engine.a, x: engine.x, y: engine.y, c: engine.c, z: engine.z, n: engine.n, v: engine.v }); },\n loaded: (name, from, to) => { (title.files64 ??= []).push({ name, from, to }); const script = title.fileScripts?.[name]; if (script) { const l = { script, from, to }; loaded.splice(0, Infinity, ...loaded.filter(k => k.from < l.from || k.to > l.to), l); } } });\n else installRom({ cpu, game: title.disk, sw: { lcRead: 0 }, io: a => io(engine, a), file: n => files.file(n), get files() { return files.files; }, put: (path, f) => files.put(path, f), remove: path => files.remove(path), clicks: { push: c => engine.clicks.push(engine.cycles + c - romFrom) }, log() {}, halted: false });\n const rom = (e, at) => {\n const f = cpu.hooks.get(at);\n // a Commodore 64's BASIC, which MENU runs NOTEBOOK (compiled BASIC) and ZOOTIME (BASIC) with\n if (!f && c64 && at >= 0xa000 && at < 0xc000) throw new Error('a BASIC program (Zoopak\\'s NOTEBOOK or ZOOTIME): not written yet in the remake');\n if (!f) throw new Error('no ROM routine at $' + hex4(at));\n engine = e;\n // (the stack pointer as the call to the routine left it: the frames' place, less the call's two bytes)\n Object.assign(cpu, { a: e.a, x: e.x, y: e.y, c: e.c, z: e.z, n: e.n, v: e.v, pc: at, sp: e.sp() - 2 & 0xff });\n // a routine that reads the keyboard (RDKEY) waits, with no key, and the step runs again\n const start = romFrom = cpu.cycles;\n const r = f(cpu);\n if (r === 'wait') return 'wait';\n // the time a routine takes, which the original took: the Monitor's WAIT counts out\n // (26 + 27A + 5A\u00B2) / 2 cycles, and the bell its 192 clicks\n // and its RTS, as the machine's hook takes it\n e.delay += (cpu.cycles - start + 6) / CLOCK * 1000; e.cycles += cpu.cycles - start + 6;\n Object.assign(e, { a: cpu.a & 0xff, x: cpu.x & 0xff, y: cpu.y & 0xff, c: cpu.c, z: cpu.z, n: cpu.n });\n if (r === 'return') return r; // (a routine that returns from its caller too: $E206 at a statement's end)\n // a routine that goes on elsewhere, not back: DOS 3.3's error exit, from a command printed through COUT, to where\n // DOS goes on (rom.js `dosError`)\n if (r === false && cpu.pc !== at) return { to: cpu.pc };\n };\n\n // Where an address of the lifted code is: a label in a script. The scenes all run at $AD00,\n // and PETPUZZLE is read over SCHOOL's end, so where scripts share an address the script is the\n // file read over it last (`loaded`, each ProDOS read of a script's file, its first and last\n // address, the newest last).\n const loaded = [];\n let index = null;\n // the scripts with a label at an address\n const labelled = (e, at) => {\n if (!index) {\n index = new Map();\n for (const name of Object.keys(e.sources)) {\n const p = e.script(name);\n for (const l of Object.keys(p.labels)) if (/^L[0-9A-F]{4}$/.test(l)) { const a = parseInt(l.slice(1), 16); (index.get(a) ?? index.set(a, []).get(a)).push(name); }\n }\n }\n return index.get(at) ?? [];\n };\n // Code a scene's lift missed, reached through a table or a vector its walk could not follow: on\n // a Commodore 64, lifted at need from the file's bytes in memory where it was loaded, with the\n // same lifter (lift.js), and said, so that the entry goes into the scene's lift.\n const atNeed = (e, at) => {\n // (or code no file put there, which a file's own code made: Goldfields' TITLE unpacks its\n // picture and code to $8000 and jumps to $7F40; from the RAM below BASIC's ROM)\n const f = title.files64?.findLast(f => f.from <= at && at <= f.to) ?? (at >= 0x0200 && at < 0xa000 ? { name: 'MEMORY', from: 0x0200, to: 0x9fff } : null);\n if (!f) return null;\n const bytes = e.mem.slice(f.from, f.to + 1), name = (title.fileScripts?.[f.name] ?? f.name) + '@' + hex4(at);\n const lifted = lift(bytes, f.from, [at], toolkit.routines, new Set(), readers(INLINE));\n e.sources[name] = scriptOf(lifted, bytes, f.from, { selfModified: true });\n index = null;\n loaded.push({ script: name, from: f.from, to: f.to });\n (title.liftedAtNeed ??= []).push(f.name + ' $' + hex4(at));\n console.warn(`lifted at need: ${f.name} from $${hex4(at)} (an entry for its scene's lift)`);\n return name;\n };\n // (on a Commodore 64, a file's scene only while that file is what is loaded there: Goldfields'\n // CODE is at $8018 when the boot calls it, and TEXT/CODE, loaded over it later, has a label there)\n const fileScripts = new Set(Object.values(title.fileScripts ?? {}));\n const present = (names, at) => !c64 ? names : names.filter(n => !fileScripts.has(n) || loaded.some(l => l.script === n && l.from <= at && at <= l.to));\n const find = (e, at) => {\n let names = present(labelled(e, at), at);\n if (!names.length && c64 && atNeed(e, at)) names = present(labelled(e, at), at);\n const over = loaded.findLast(l => names.includes(l.script) && l.from <= at && at <= l.to);\n const name = names.length > 1 ? over?.script : names[0];\n if (!name) throw new Error('no script has $' + hex4(at));\n return [name, 'L' + hex4(at)];\n };\n // an address the ROM's routine answers: above $D000, unless the card is read there and a script\n // has its code there (Pieces of Eight's PO8:BLINK, over HPOSN and DRAW), or below where rom.js answers DOS's own\n // (INITIOHK, $A851) and no script has code; on a Commodore 64, where\n // the 6510's port shows the KERNAL ($E000 on) or BASIC ($A000 to $BFFF: Tell-A-Tale's numbers,\n // over MENU's code in the RAM under it)\n const romAt = (e, a) => c64 ? (a >= 0xe000 ? (e.mem[1] & 2) !== 0 : a >= 0xa000 && a < 0xc000 ? (e.mem[1] & 3) === 3 : a === 0x73 || a === 0x79) : a >= 0xd000 ? !(lc.read && labelled(e, a).length) : cpu.hooks.has(a) && !labelled(e, a).length;\n // the stir of START.SYSTEM's wait: its calls are no steps\n const stirring = step => toolkit.stir && step?.at >= toolkit.stir.from && step.at <= toolkit.stir.to;\n const emit = (e, ev, quiet) => { if (quiet) e.inside++; e.emit(ev); if (quiet) e.inside--; };\n\n // a return, as the engine's: to the caller, and out of a routine run inside a step\n const back = x => { const f = x.stack.pop(); if (f.name !== x.name) x.enter(f.name); x.pc = f.pc; if (f.inside) { x.inside--; f.done?.(x); } f.after?.(x); };\n // the town's loop, the restart and escape (into LIB4's screens) are the game going on, and run\n // as it, with no return\n const through = new Set(['town', 'restart', 'escape']);\n // The data a step takes inline, read from memory after its call as the original reads it,\n // since a scene may write into it (the name, into the text LIB.VARS prints); the script's own\n // words are what the file held, for a step with no address\n const inline = (e, step, n, args) => {\n if (step?.at == null) return args.map(h => parseInt(h, 16));\n const b = []; for (let i = 0; i < n; i++) b.push(e.mem[(step.at + 3 + i) & 0xffff]); return b;\n };\n const words = b => b.map(v => v.toString(16)).join(' ');\n // an event without where in memory its data is, for a title whose strings are not where the\n // original's are (its map's `unplaced`: Goldfields' SETNAM, its name in BASIC's strings)\n const unplaced = ev => { if (toolkit.unplaced?.includes(ev.step)) { delete ev.x; delete ev.y; } return ev; };\n // a step of the original's ROM: its event, then the routine\n // The KERNAL's calls that go through a vector in RAM, as the KERNAL's jump table does (JMP\n // ($0326) for CHROUT): where the game has pointed one at a routine of its own (Zoopak's MENU\n // draws its text into its bitmap), that routine runs, its lifted code inside the step.\n // (Not LOAD's: the emulator answers LOAD at $F49E, past its vector, as the 1541 does in\n // @moonbase-machines/c64/drive.js, so MENU's fast loader, which talks to a drive's own processor over the\n // serial lines, is set up and never run; the remake does the same.)\n const VECTORED = { chrout: [0x326, 0xf1ca], chrin: [0x324, 0xf157], getin: [0x32a, 0xf13e], save: [0x332, 0xf5ed] };\n const inRom = (name, at) => (e, args, step) => {\n inputs(e, name, args); emit(e, unplaced(describe(name, [], e, undefined, undefined, a => e.mem[a])), stirring(step));\n const v = c64 && VECTORED[name], to = v && (e.mem[v[0]] | e.mem[v[0] + 1] << 8);\n if (v && to !== v[1]) { const [script, label] = find(e, to); e.callInside(script, label, x => { if (GIVES[name]) x.emit(result(name, { a: x.a, x: x.x, y: x.y, c: x.c })); }, step?.at == null ? undefined : (step.at + 2) & 0xffff); return; }\n const r = rom(e, at);\n if (r === 'wait') return 'wait';\n // (gone on elsewhere: the code there run inside the step, the routine's return still on the stack, as the\n // original's is, until that code drops it, as Pieces of Eight's handler ($93F0) does with a TXS to the frames\n // under it, kept at their place for it (Engine.stackPage))\n if (r?.to !== undefined) {\n e.stackPage();\n e.stack.push({ name: e.name, pc: e.pc, inside: true, ret: step?.at == null ? undefined : (step.at + 2) & 0xffff }); e.inside++;\n return routines['goto-engine'](e, ['$' + hex4(r.to)], step);\n }\n if (GIVES[name] && c64) e.emit(result(name, { a: e.a, x: e.x, y: e.y, c: e.c }));\n };\n\n const routines = {\n // fill, copy, print and say, which take their data inline after the call, run their lifted\n // code as the other entries do: the call's frame gives the code its return address to read\n // the data from, and the code returns past it (Engine.pull, Engine.ret)\n // ProDOS: the call and its parameters' address inline; a read of a script's file is noted,\n // where it went, for the scripts that share addresses\n prodos: (e, args, step) => {\n const b = inline(e, step, 3, args), [cmd, lo, hi] = b, params = lo | hi << 8;\n emit(e, describe('prodos', [], e, words(b)), stirring(step));\n const mem = { read: a => e.mem[a], write: (a, v) => { e.mem[a] = v & 0xff; } };\n if (cmd === 0xca) {\n const ref = e.mem[params + 1], o = files.open.get(ref), to = e.mem[params + 2] | e.mem[params + 3] << 8;\n const n = o ? Math.min(e.mem[params + 4] | e.mem[params + 5] << 8, o.f.body.length - o.at) : 0;\n const script = o && title.fileScripts?.[sectionName(toolkit, a => e.mem[a], o.f.path, o.at)];\n if (script && n) {\n const l = { script, from: to, to: to + n - 1 };\n loaded.splice(0, Infinity, ...loaded.filter(k => k.from < l.from || k.to > l.to), l);\n }\n // a disk's time for the blocks read\n e.delay += Math.ceil(n / 512) * BLOCK / CLOCK * 1000;\n }\n let err = files.call(cmd, params, mem);\n e.cycles += 6; // the RTS, as the machine's hook at $BF00 takes it\n if (err === null) err = 1;\n e.a = err === 'quit' ? 0 : err; e.c = e.a ? 1 : 0; e.z = e.a ? 0 : 1;\n if (err === 'quit') e.ended = true;\n },\n // START.SYSTEM's stirring wait is over: the counts it leaves are the seed, as on the original\n stirred: e => { for (const a of toolkit.stir.counts) e.mem[a] = title.seed & 0xff; },\n hposn: inRom('hposn', 0xf411), hlin: inRom('hlin', 0xf53a), hcolor: inRom('hcolor', 0xf6f0), 'clear-page': inRom('clear-page', 0xf3f4),\n pause: inRom('pause', 0xfca8), home: inRom('home', 0xfc58), outport: inRom('outport', 0xfe95),\n // a call or a jump to an address outside the script: into the lifted code where it is, or\n // into the ROM\n 'call-engine': (e, [at], step) => {\n const a = parseInt(at.slice(1), 16);\n if (romAt(e, a)) { const r = rom(e, a); if (r === 'return') { back(e); return; } return r; }\n // (code the game has made a bare RTS since: back at once, the RTS's time taken, as\n // Detect-A-Pet's room hook at $AD03, which it sets to RTS in most rooms)\n if (!c64 && e.mem[a] === 0x60) { e.cycles += 6; return; }\n const [name, label] = find(e, a);\n e.stack.push({ name: e.name, pc: e.pc, ret: step?.at == null ? undefined : (step.at + 2) & 0xffff }); e.enter(name, label);\n },\n // a jump to one of the toolkit's entries is that step: the town's loop and the restart, which\n // never come back\n 'goto-engine': (e, [at], step) => {\n const a = parseInt(at.slice(1), 16), entry = toolkit.routines[a];\n if (entry) {\n if (through.has(entry)) return routines[entry](e, [], step);\n // a jump to a routine that comes back: it returns for the code that jumped, to its caller\n // (the ROM's SYS, on a Commodore 64, which makes it the ROM's call, and no event)\n const quiet = c64 && e.stack.at(-1)?.rom;\n if (quiet) e.inside++;\n let r; try { r = routines[entry](e, [], step); } finally { if (quiet) e.inside--; }\n const f = e.stack.at(-1);\n if (f?.inside) { const done = f.done; f.done = x => { done?.(x); back(x); }; } else back(e);\n return r;\n }\n if (romAt(e, a)) {\n if (rom(e, a) === 'wait') return 'wait';\n if (c64 && ENDS.has(a)) pullRegisters(e); // the end of an interrupt: the registers back, then its RTI\n back(e); return; // as its RTS: out of a routine it ends\n }\n // (code the game has written since, a JMP: on through it, as Pieces of Eight's at $A6D8, into DOS's error exit)\n if (!c64 && e.mem[a] === 0x4c && !labelled(e, a).length) return routines['goto-engine'](e, ['$' + hex4(e.mem[a + 1] | e.mem[a + 2] << 8)], step);\n e.enter(...find(e, a));\n },\n };\n\n // A Commodore 64 title's BASIC (Goldfields: its boot, GOLDFIELDS, BASIC's text, and its game,\n // GAME, Blitz!'s code), compiled to scripts whose steps the library in @moonbase-machines/c64/basic.js does,\n // the engine's `basic`. SYS runs the machine code at its address, with BASIC's text pointer\n // ($7A) at the text after it and the registers from $030C, as the ROM's SYS does; the machine\n // code reads its parameters from that text with the ROM's routines, which are answered here\n // from the parameters' expressions, compiled with the program (`params`).\n if (c64 && title.basic) {\n routines.sys = (e, at, text, step) => {\n e.mem[0x7a] = text & 0xff; e.mem[0x7b] = text >> 8;\n const m = e.mem; Object.assign(e, { a: m[0x30c], x: m[0x30d], y: m[0x30e], c: m[0x30f] & 1, z: m[0x30f] >> 1 & 1, n: m[0x30f] >> 7 });\n // and as it returns, the registers kept at $030C, as the ROM's SYS keeps them (Goldfields'\n // map reads where the digger may go from them, C = PEEK(780))\n const keep = x => { m[0x30c] = x.a; m[0x30d] = x.x; m[0x30e] = x.y; m[0x30f] = x.c | x.z << 1 | (x.i ?? 0) << 2 | (x.d ?? 0) << 3 | x.v << 6 | x.n << 7; };\n if (romAt(e, at)) { const r = rom(e, at); keep(e); return r; }\n // (the frame is the ROM's SYS, as the machine code's return address is: a jump from the\n // code to the KERNAL is the ROM's call then, as the observer sees it)\n const [name, label] = find(e, at);\n e.stack.push({ name: e.name, pc: e.pc, rom: true, after: keep }); e.enter(name, label);\n };\n // the boot's LOAD: the file, as BASIC loads it from a program, which then runs again from its\n // start with its variables kept; or, for a BASIC program loaded over it (GAME, at $0801),\n // that program from its start\n routines['basic-load'] = (e, [name, device = 1, sa = 0]) => {\n const m = e.mem; for (let k = 0; k < name.length; k++) m[0x200 + k] = name.charCodeAt(k);\n Object.assign(m, { 0xb7: name.length, 0xbb: 0x00, 0xbc: 0x02, 0xba: device, 0xb9: sa, 0xb8: 0 });\n Object.assign(e, { a: 0, x: 0x01, y: 0x08 });\n e.basic.call('load');\n const program = Object.entries(title.basic).find(([, p]) => p.file === name);\n if (sa === 0 && program) { startBasic(e, program[0]); e.enter(program[0]); return; }\n e.pc = 0;\n };\n // BASIC's routines the machine code reads its parameters with, and the rest it calls\n // (@moonbase-machines/c64/basic-rom.js), the parameters' values from the expressions compiled with the program\n installBasicRom({ cpu, read: a => engine.read(a), write: (a, v) => engine.write(a, v),\n evaluate: at => {\n const p = engine.sources[engine.basic.script]?.params?.[at];\n if (!p) throw new Error('no parameter compiled at $' + hex4(at));\n const [end, f, place] = p;\n return { value: f(engine.basic), end, place };\n } });\n }\n // A BASIC error, as the ROM's routine gives it ($A43A, through the vector at $0300 Goldfields\n // leaves the ROM's): the output back to the screen, a new line, ? and the message, ERROR, IN and\n // the \"line\", which for Blitz!'s code is its program counter at the instruction that failed,\n // then READY.; the program is over. Its output is the ROM's, through CHROUT, and no events.\n if (c64 && title.basic) routines.error = (e, err) => {\n if (!(err instanceof BasicError) || !e.basic) return false;\n engine = e;\n return printError({ cpu, write: (a, v) => { e.mem[a] = v; } }, err.message, e.basic.at);\n };\n const startBasic = (e, name) => { e.basic = new Basic(e, title.basic[name]); e.basic.script = name; };\n // every other entry of the toolkit runs its lifted code inside its step\n for (const [at, name] of Object.entries(toolkit.routines).map(([a, n]) => [+a, n])) {\n // a routine of the ROM's, above $D000, is its step in @moonbase-machines/apple2e/rom.js\n if (!routines[name] && at >= 0xd000) routines[name] = inRom(name, at);\n if (routines[name] || at >= 0xbf00) continue;\n routines[name] = (e, args, step) => {\n inputs(e, name, args);\n // the game going on from inside a routine (Escape read by the key reader): what it was\n // inside is the game's own code now, as the observer's count of calls starts again, and\n // the returns still to come give nothing\n if (through.has(name) && e.inside) { for (const f of e.stack) if (f.inside) { delete f.inside; delete f.done; } e.inside = 0; }\n // its code where the call goes, when another of the same name is elsewhere (LIB4 says its\n // messages by its own $8046, the scenes by LIB2's $144B, a JMP to $1C11): the operand of\n // the call, or else the first of that name\n const to = step?.at != null ? e.mem[(step.at + 1) & 0xffff] | e.mem[(step.at + 2) & 0xffff] << 8 : null;\n const quiet = stirring(step), entry = toolkit.routines[to] === name ? to : parseInt(Object.entries(toolkit.routines).find(([, n]) => n === name)[0]);\n if (name === 'read-key') { e.mem[toolkit.seed] = title.seed & 0xff; e.mem[toolkit.seed + 1] = title.seed >> 8; }\n // the data after the call, as the observer reads it (cards.js)\n const data = INLINE[name] && step?.at != null ? INLINE[name](a => e.mem[a & 0xffff], step.at + 3).value : undefined;\n emit(e, describe(name, [], { a: e.a, x: e.x, y: e.y, c: e.c }, data, undefined, a => e.mem[a]), quiet);\n const [script, label] = find(e, entry);\n // (escape is called, as the original's JSR: LIB4 keeps the stack with its return (TSX at\n // $8E63), and Return to present game goes back through it to where Escape was read)\n if (name === 'escape' && step?.at != null) e.stack.push({ name: e.name, pc: e.pc, ret: (step.at + 2) & 0xffff });\n if (through.has(name)) { e.enter(script, label); e.entered = entry; return; }\n // the key reader's counts of its wait are the seed again as it returns, as on the original\n const seed = x => { x.mem[toolkit.seed] = title.seed & 0xff; x.mem[toolkit.seed + 1] = title.seed >> 8; };\n e.callInside(script, label, x => { if (name === 'read-key') seed(x); if (GIVES[name] && !quiet) x.emit(result(name, { a: x.a, x: x.x, y: x.y, c: x.c })); }, step?.at == null ? undefined : (step.at + 2) & 0xffff);\n };\n }\n // A call or a jump to a label of the script's own that a file read since covers with another\n // script's code: SCHOOL's $B670 on, once PETPUZZLE is read there\n routines.elsewhere = (e, label) => {\n const at = parseInt(label.slice(1), 16), over = loaded.findLast(l => l.from <= at && at <= l.to);\n return over !== undefined && over.script !== e.name && /^L[0-9A-F]{4}$/.test(label);\n };\n // A tick (its map's `ticks`): before the scene's read of the keyboard, the run stops for a key\n // or none (-1), and the read takes it.\n // the original's code is in memory where its lines came from: the engine counts their time\n routines.timed = true;\n // how many polls with no key are a wait (its map's `polls`; a pilot's route can set the\n // engine's own, `e.polls`, for a stretch of keys: the pilots' `pollsAt`)\n routines.polls = toolkit.polls;\n routines.reads = toolkit.reads; // and how many reads of the clock are a tick of it (basic.js `ti`)\n // GETIN on the Commodore 64: the key pressed, or none; called without end while the game waits,\n // so many in a row with no key is the wait, as the observer counts them (the pilots' observer).\n // The KERNAL's buffer first, where the interrupt puts a key it holds down (MENU's), then the\n // page's keys.\n if (c64) routines.getin = e => {\n if (!e.clock && !e.i) { routines.poll(e); e.polledSince = true; }\n let k;\n if (e.mem[0xc6]) { k = e.mem[0x277]; e.mem.copyWithin(0x277, 0x278, 0x277 + e.mem[0xc6]); e.mem[0xc6]--; } else k = e.key();\n e.c = 0;\n if (k === undefined || k < 0) { e.a = e.flags(0); if (++e.idle > (e.polls ?? toolkit.polls ?? 200) && !e.clock) e.polled = true; return; }\n e.a = e.flags(k); e.idle = 0; e.emit(result('getin', { a: k }));\n // (on the page's clock the game runs on as the original did, waiting or not)\n };\n // The Commodore 64's interrupt, through $0314 sixty times a second: the KERNAL's own (the clock),\n // or a game's, which does what the game shows in time (Petra's Dream cycles its flames' colour\n // and plays its sounds; MENU's, which it goes on to, flips its title's two screens and reads the\n // joystick) and goes on to the KERNAL's end of an interrupt, its RTI, where the registers and\n // flags come back. The remake keeps no time of the machine's: it takes one at each call of GETIN,\n // as the observer has the original take it (the pilots' observer), and then the VIC's raster\n // interrupt, where the game has turned it on ($D01A), at the line it set (Find Me's split of its\n // screen into two character sets), $D019 saying which it is. On the page's clock (\n // scenes.js sets `e.clock`), each is taken as the original's chips took it: the CIA's every 16,421\n // cycles of the original's time, the raster's when its line comes (routines.before). Not while\n // the game has them masked (SEI). The routine starts as the KERNAL's own entry ($FF48) leaves\n // it, with A, X and Y pushed, and the KERNAL's end ($EA31, $EA7B, $EA7E, $EA81), or its own PLAs\n // and RTI, pulls them.\n const ENDS = new Set([0xea31, 0xea7b, 0xea7e, 0xea81]);\n // a poll's interrupts, as the observer takes them: the CIA's, then the raster's where it is on\n routines.poll = e => { routines.interrupt(e); if (chip[0x1a] & 1) routines.interrupt(e, true); };\n const pullRegisters = e => {\n for (const r of ['y', 'x', 'a']) { const f = e.stack.pop(); if (f?.a === undefined || f.name !== undefined) throw new Error('the end of an interrupt with its registers not on the stack'); e[r] = f.a; }\n };\n if (c64) routines.interrupt = (e, raster = false) => {\n if (e.i) return;\n const to = e.mem[0x314] | e.mem[0x315] << 8, kept = { a: e.a, x: e.x, y: e.y, n: e.n, z: e.z, c: e.c, v: e.v, d: e.d };\n e.vicFlags = raster ? 0xf1 : 0x70;\n if (raster) e.splitLine = chip[0x12] | (chip[0x11] & 0x80) << 1;\n try {\n if (romAt(e, to)) rom(e, to); // the KERNAL's own routine ($EA31, or past its clock, $EA34)\n else { e.i = 1; runNow(e, to, 'the interrupt routine', x => x.stack.push({ a: kept.a }, { a: kept.x }, { a: kept.y })); }\n } finally { Object.assign(e, kept); e.i = 0; e.vicFlags = e.splitLine = undefined; }\n };\n // the game's code at an address run now to its return, inside whatever is running: the\n // interrupt's routine, or one the KERNAL calls through a vector\n function runNow(e, at, what, then) {\n let over = false;\n e.callInside(...find(e, at), () => { over = true; });\n then?.(e);\n for (let n = 0; !over; n++) {\n if (n > 1e6) throw new Error(what + ' at $' + hex4(at) + ' runs on without end');\n if (e.exec(e.program.steps[e.pc]) === 'wait') throw new Error(what + ' at $' + hex4(at) + ' waits');\n }\n }\n // the length of the data after a step's call, the lifted lines leave out (Engine.cost)\n routines.inline = (e, step) => INLINE[step.words[0]] ? INLINE[step.words[0]](a => e.mem[a & 0xffff], step.at + 3).length : 0;\n // And a routine of the title's, reached by a jump or a branch with nothing running (Pieces of\n // Eight jumps to its description routine, $0A59): its step, as the observer's hook makes it\n // wherever the routine is reached from, and the frame on top, the caller of the code that\n // jumped, which the routine returns through, ends it.\n routines.before = (e, step) => {\n if (c64 && e.clock && !e.i) {\n if (e.cycles >= e.clock.irq) { e.clock.irq = Math.max(e.clock.irq + 16421, e.cycles); routines.interrupt(e); }\n // the raster's, when the line it waits for has come since the last step\n const line = Math.floor(e.cycles / 63) % 312, last = e.clock.line ?? line, target = chip[0x12] | (chip[0x11] & 0x80) << 1;\n e.clock.line = line;\n if (line < last) { title.splits = e.clock.splits ?? new Map(); e.clock.splits = new Map(); } // a frame round: its splits the view's\n if (chip[0x1a] & 1 && (last <= line ? last < target && target <= line : target > last || target <= line)) routines.interrupt(e, true);\n }\n // (the town's, the restart's and escape's own steps go on into their code: not twice)\n const at = step.start ?? step.at, named = at != null && e.inside === 0 ? toolkit.routines[at] : undefined, own = e.entered === at;\n e.entered = null;\n if (named && !own && !stirring(step)) {\n emit(e, describe(named, [], { a: e.a, x: e.x, y: e.y, c: e.c }, undefined, undefined, a => e.mem[a]));\n const f = e.stack.at(-1);\n if (f?.name !== undefined && !f.inside) { f.inside = true; f.done = x => { if (GIVES[named]) x.emit(result(named, { a: x.a, x: x.x, y: x.y, c: x.c })); }; e.inside++; }\n }\n const t = toolkit.ticks?.find(t => t.at === step.at && e.name === title.fileScripts?.[t.scene]);\n if (!t) return;\n if (e.ticking === step) { e.ticking = null; if (e.keys[0] === -1) e.keys.shift(); return; }\n e.emit({ step: 'tick' }); e.ticking = step;\n return 'wait';\n };\n // before the start: the files the machine puts in memory itself (START.SYSTEM, where ProDOS\n // would have read it), the bytes it gives (MACHID), and the I/O page\n routines.setup = e => {\n // a Commodore 64 as it is when the game's boot program starts: the 6510's port showing the\n // ROMs and the I/O page, the VIC as the KERNAL set it up and its bank the first, the screen at\n // $0400 in light blue, device 8 and secondary address 1 the last used; and the boot loaded where it goes, over the stack\n if (c64) {\n // (the compiled scenes reach only the title's `io` through the hook: it must hold all this)\n if (!title.io || title.io[0] > 0xd000 || title.io[1] < KEY_TABLES[1] - 1) throw new Error('a Commodore 64 title\\'s io must cover $D000 to the KERNAL\\'s keyboard tables');\n e.ioAt = at => (at >= 0xd000 && at <= 0xdfff && ioShown(e)) || (at >= KEY_TABLES[0] && at < KEY_TABLES[1] && (e.mem[1] & 2) !== 0);\n Object.assign(e.mem, { 0: 0x2f, 1: 0x37, 0x99: 0, 0x9a: 3, 0xb9: 1, 0xba: 8, 0x288: 4, 0x286: 14 }); // (input from the keyboard, output to the screen; LOAD\"ZOOPAK\",8,1 left device 8, secondary address 1)\n // the keyboard as the KERNAL keeps it: no key down, the cursor not blinking, a buffer of ten,\n // the repeat's counts, and the decode's vector its own\n Object.assign(e.mem, { 0xc5: 0x40, 0xcb: 0x40, 0xcc: 1, 0x289: 10, 0x28a: 0, 0x28b: 4, 0x28c: 0x10, 0x28f: 0x48, 0x290: 0xeb });\n VIC.forEach((v, i) => { chip[i] = v; }); chip[0xd00] = 0x97;\n VECTORS.forEach((v, i) => { e.mem[0x314 + 2 * i] = v & 0xff; e.mem[0x315 + 2 * i] = v >> 8; }); // the KERNAL's own vectors\n for (let i = 0; i < 1000; i++) { e.mem[0x400 + i] = 0x20; chip[0x800 + i] = 14; }\n for (const [name, at] of Object.entries(title.load ?? {})) { const raw = title.drive.find(Uint8Array.from(name, ch => ch.charCodeAt(0))).raw; e.mem.set(raw.subarray(2), at); }\n e.io = (at, v) => io(e, at, v);\n // a program in BASIC starts from BASIC's READY, RUN typed: the cursor's blink as it was then\n if (title.basic) { Object.assign(e.mem, { 0xcd: 2, 0xce: 0x20, 0xcf: 0, 0x287: 0xfe }); startBasic(e, title.start); }\n return;\n }\n for (const [path, at] of Object.entries(title.load ?? {})) e.mem.set(files.file('/' + files.volumes[0] + '/' + path).body, at);\n // a DOS 3.3 disk: what its Applesoft program did, as the machine does it (@moonbase-machines/apple2e/machine.js boot):\n // each file loaded where the program puts it, the language card's bank as it says, then the\n // card read and written in bank 1, the screen cleared, the text window from row 16, and the\n // CALL; in the time the disk took\n if (title.disk.kind === 'dos33') {\n for (let r = 0; r < 24; r++) e.mem.fill(0xa0, 0x400 + (r & 7) * 0x80 + (r >> 3) * 40, 0x400 + (r & 7) * 0x80 + (r >> 3) * 40 + 40);\n for (const [name, at, bank] of title.disk.loads) {\n if (bank) bankTo(e, bank);\n e.mem.set(files.file(name).body, at);\n }\n bankTo(e, 1); lc.read = 1;\n Object.assign(e.mem, { 0x20: 0, 0x21: 40, 0x22: 16, 0x23: 24, 0x32: 0xff });\n e.delay = 2500;\n }\n e.io = (at, v) => io(e, at, v);\n };\n return routines;\n}\n", "// What a step is, as an event: the same words for the original, where the pilot's observer sees\n// the engine's routine called, and for the remake, where a script's step runs. Two runs are the\n// same when their events are.\n\n// the registers each routine takes, in order\nexport const TAKES = {\n box: 'axy', object: 'axy', 'object-keep': 'axy', 'object-mode': 'axy', objects: 'xy', span: 'axy', random: 'a', beep: 'a',\n 'key-at': 'axy', key: 'a', multiply: 'ax', divide: 'axy', ask: 'a', 'ask-mode': 'a', 'ask-escape': 'a', rectangle: 'axy', 'read-dot': 'xy',\n problem: 'a', dot: 'axy', 'fill-rows': 'axy', part: 'a', 'rectangle-outline': 'axy', 'key-panel': 'a', 'keep-span': 'xy',\n 'put-span': 'xy', 'white-lines': 'y', 'invert-span': 'xy',\n // Animal Rescue's problems: PROB1, the chimps' tree, a box by its letter\n label: 'a', 'flip-box': 'a', 'flash-box': 'a',\n // PROB2, the elephants: a mark on the path by its place, and a jump by how far it goes\n path: 'ax', jump: 'a',\n // PROB3, the parrots' food: a box of the grid by its column and row, what shows in it, and a pair\n cell: 'axy', 'cell-box': 'axy', pair: 'a',\n // PROB4, the puzzle box: a piece by its edges, where it goes, and its color in $11\n piece: 'axy',\n // Nature Park's PROB1, the colour pattern: a shape coloured in with a pen, the shape in $0E15\n colour: 'a',\n // PROB3, the truck: a turn of its loop, which gives the key down then, or 0\n tick: '',\n // Detect-A-Pet's card toolkit (its title's map): print takes its x in X and Y, its y in A, and\n // the carry for XDRAW; HPOSN its y in A and x in X and Y; HLIN its x in A and X and y in Y\n print: 'axyc', arrow: 'a', unpack: 'y', 'load-picture': 'a', 'action-cards': 'a', 'return-key': 'a', 'space-key': 'a',\n 'wipe-rows': 'a', 'wipe-columns': 'a', 'text-card': 'a', 'fill-left': 'a', 'put-object': 'axy', 'draw-room-objects': 'yc', take: 'y',\n drop: 'y', effect: 'a', outport: 'a', cout: 'a',\n // Pieces of Eight's text: a character at the cursor, a message by its number, and a room's\n // description from one of three tables\n char: 'a', message: 'xy', describe: 'axy',\n // the Commodore 64's KERNAL (Zoopak): a character out, the cursor's place, a file's number,\n // device and secondary address, its name, a load or save, and the serial bus's bytes\n chrout: 'a', plot: 'xyc', close: 'a', chkin: 'x', chkout: 'x', setlfs: 'axy', setnam: 'axy', load: 'axy', save: 'axy', listen: 'a', second: 'a', ciout: 'a', talk: 'a', tksa: 'a', setmsg: 'a', tone: 'xy', 'load-objects': 'axy', hposn: 'axy', hlin: 'axy', hcolor: 'x', pause: 'a', 'bag-put': 'a',\n};\n\n// the inputs some problems' routines take from their own memory, at fixed addresses\nconst MEMORY = { colour: { shape: 0x0e15 }, 'card-frame': { x: 0x4078, high: 0x4079, y: 0x407a, width: 0x407b, height: 0x407c } };\n\n// the inputs some routines take from the zero page rather than the registers: the line's ends\n// and color, and a rectangle's width and height\nconst ZERO = { line: { x0: 0x00, x1: 0x01, y0: 0x02, y1: 0x03, color: 0x11 }, piece: { color: 0x11 }, rectangle: { width: 0x0e, height: 0x0f }, 'rectangle-outline': { width: 0x0e, height: 0x0f } };\n\n// A step as an event: its name, any fixed input (a panel's number), the registers it takes,\n// the zero page inputs, read through `read`, and the data it had inline (a text, a picture's\n// name, a sound).\nexport function describe(name, fixed, regs, inline, read, peek) {\n const e = { step: name };\n if (fixed.length) e.n = fixed.map(Number);\n const takes = TAKES[name];\n if (name === 'objects') e.table = '$' + ((regs.x | regs.y << 8).toString(16).toUpperCase().padStart(4, '0'));\n // object 0 or 1 puts back the ground kept under an object, where it was: what is left in X and Y\n // then is whatever the steps before left there, and is no input\n else if (name.startsWith('object') && regs.a < 2) e.a = regs.a;\n else if (takes) for (const r of takes) e[r] = regs[r];\n if ((name === 'key-at' || name === 'key') && e.a !== undefined) e.a = String.fromCharCode(e.a & 0x7f);\n if (ZERO[name] && read) for (const [k, at] of Object.entries(ZERO[name])) e[k] = read(at);\n if (MEMORY[name] && peek) for (const [k, at] of Object.entries(MEMORY[name])) e[k] = peek(at);\n if (inline !== undefined) e.words = inline;\n return e;\n}\n\n// the outputs of a routine that a scene goes on to use, recorded as it returns\nexport const GIVES = { random: 'a', ask: 'ax', 'ask-mode': 'ax', 'ask-escape': 'axc', 'wait-or-escape': 'c', problem: 'c', 'read-key': 'a', 'read-dot': 'a', multiply: 'ax', divide: 'ax', 'blink-key': 'a', 'which-box': 'xy', tick: 'a', 'choose-action': 'a', take: 'a', drop: 'a', 'show-bag': 'a', 'bag-choose': 'a', getin: 'a', acptr: 'a', readst: 'a', load: 'cxy', chrin: 'a' };\n\n// A call that does nothing is no step: the beep returns at once for A 0 ($6831 in Animal Rescue,\n// $5D12 in Nature Park), and a scene that reads keys by polling beeps each one, 0 for none, until\n// one comes. As steps those would be as many as the polls, which is how long the machine was\n// watched, not what the title did.\nexport const nothing = (name, a) => name === 'beep' && a === 0;\n\n// routines that poll for a key: each is a step only when it gives one\nexport const POLLS = new Set(['read-key', 'blink-key']);\n// routines that wait for keys; any other, while it runs, is busy, and a key pressed then is not for it\nexport const WAITS = new Set(['wait', 'wait-erase', 'wait-or-escape', 'ask', 'ask-mode', 'ask-escape', 'which-box', 'tick', 'choose-action', 'take', 'drop', 'show-bag', 'bag-choose']);\nexport function result(name, regs) {\n const e = { result: name };\n for (const r of GIVES[name]) e[r] = regs[r];\n return e;\n}\n", "// What the card engine (card.js) knows of every title it plays, the title's own map of its routines aside (its\n// title.js `map`, below): the data some routines take inline after the call, a toolkit's sections file, and the\n// Commodore 64's KERNAL as a C64 title's map names it.\n//\n// A title's `map` (its title.js): the routines its scenes call, by address, each with the name of the step it is in\n// a scene's script (`routines`); and what its engine needs beside them, as the title has it: Detect-A-Pet's `seed`\n// (where the key reader takes the random routine's seed from), `stir` (a wait for a key that stirs the random\n// routine as it polls, its counts fixed when the key comes), `ticks` (a scene's own loop that reads the keyboard each\n// frame, each pass a step `tick`), `sections` (its toolkit's sections file, below); a C64 title's `c64`, `start`,\n// `quiet` (routines polled without end, an event only when they give something), `basic`, `polls` and `unplaced`.\n\n// The data some entries take inline after the call ({ length, value }), read through `read`: fill's seven bytes,\n// copy's eight and a ProDOS call's three, as hexadecimal; print's ASCII, ending $00; a message on the text screen,\n// `say`, its text ending $00, each character's high bit turned over\nconst bytes = n => (read, at) => { const b = []; for (let k = 0; k < n; k++) b.push(read(at + k).toString(16)); return { length: n, value: b.join(' ') }; };\nexport const INLINE = {\n fill: bytes(7), copy: bytes(8), prodos: bytes(3),\n 'boot-say': (read, at) => INLINE.say(read, at),\n say(read, at) { let s = '', i = at; for (let guard = 0; guard < 1024; guard++) { const c = read(i++); if (!c) break; s += String.fromCharCode((c ^ 0x80) & 0x7f); } return { length: i - at, value: s }; },\n print(read, at) { let s = '', i = at; for (let guard = 0; guard < 256; guard++) { const c = read(i++); if (!c) break; s += String.fromCharCode(c & 0x7f); } return { length: i - at, value: s }; },\n};\n\n// A section of a toolkit's sections file (its map's `sections`: { file, lib, origin, lengths, marks, count }), by\n// X: where it starts in the file and how long it is, from the library's tables, through `read` (memory, with the\n// library there)\nexport function section(toolkit, read, x) {\n const { lengths, marks } = toolkit.sections, word = at => read(at + x) | read(at + x + 1) << 8;\n return { mark: word(marks), length: word(lengths) };\n}\n// the name of what a read of `path` from `mark` is: a section's `path:x`, or the path\nexport function sectionName(toolkit, read, path, mark) {\n const s = toolkit.sections;\n if (!s || path !== s.file) return path;\n for (let x = 0; x < s.count; x += 2) { const t = section(toolkit, read, x); if (t.length && t.mark === mark) return path + ':' + x; }\n return path;\n}\n\n// The KERNAL's jump table at $FFxx as a C64 title calls it, each entry a step answered in JavaScript\n// (@moonbase-machines/c64/kernal.js): the routines Zoopak's code calls. (Not UDTIM, $FFEA: only an interrupt routine\n// calls it, which the remake, taking keys and having no interrupts, does not run.) A title that calls more names them\n// beside these in its own map, as Goldfields does its files'.\nexport const KERNAL = {\n 0xffd2: 'chrout', 0xffe4: 'getin', 0xfff0: 'plot', 0xffcc: 'clrchn', 0xffe1: 'stop', 0xffb7: 'readst',\n 0xffba: 'setlfs', 0xffbd: 'setnam', 0xffd5: 'load', 0xffd8: 'save',\n 0xffb1: 'listen', 0xff93: 'second', 0xffa8: 'ciout', 0xffae: 'unlsn', 0xffb4: 'talk', 0xff96: 'tksa', 0xffa5: 'acptr', 0xffab: 'untlk',\n 0xffdb: 'settim', 0xffde: 'rdtim', 0xff90: 'setmsg',\n};\n", "import { mli as m } from '@moonbase-machines/apple2e';\nexport const { BLOCK, CLOCK, Files } = m;", "import { rom as m } from '@moonbase-machines/apple2e';\nexport const { install } = m;", "import { kernal as m } from '@moonbase-machines/c64';\nexport const { KEY_TABLES, VECTORS, VIC, install, kernalByte, matrixOf, screenCode } = m;", "import { drive as m } from '@moonbase-machines/c64';\nexport const { Drive } = m;", "import { basic as m } from '@moonbase-machines/c64';\nexport const { Basic } = m;", "import { numbers as m } from '@moonbase-machines/c64';\nexport const { BasicError, ERRORS, fail, fout, int16, nextRandom, scanNumber, seedRandom, val } = m;", "import { basicRom as m } from '@moonbase-machines/c64';\nexport const { evaluateInMemory, install, printError } = m;", "// The lifter: a file's 6502 walked from its entries into a scene script, a step to a line\n// (a tool prints them; the remake lifts at need in the browser, card.js).\nimport { OPS, SIZE, operand, hex } from '@moonbase-machines/mos6502/disasm.js';\nimport { INLINE as READERS } from '@moonbase-machines/vector/inline.js';\nimport { TAKES } from './events.js';\n\n// the data after a call, read from the file, with the text quoted so that it reads as one word\nexport const readers = from => Object.fromEntries(Object.entries(from).map(([k, f]) => [k, (b, at) => { const r = f(i => b[i], at); return { length: r.length, words: k === 'text' || k === 'print' || k === 'say' ? JSON.stringify(r.value) : r.value }; }]));\nconst INLINE = readers(READERS);\n\n// `stops` are addresses where data begins that is not a table of code addresses, the objects'\n// tables and the objects themselves, so that a table of addresses read from the code ends there.\nexport function lift(bytes, origin, entries, routines, stops = new Set(), inline = INLINE) {\n const INLINE = inline;\n // `seen`: every byte an instruction or its data takes, for what is left as data; an instruction\n // is walked from where it starts, which may be inside another's bytes (the BIT that skips)\n const lines = new Map(), targets = new Set(entries), seen = new Set(), queue = [...entries];\n const inFile = a => a >= origin && a < origin + bytes.length;\n while (queue.length) {\n let pc = queue.pop();\n const regs = {};\n while (inFile(pc) && !lines.has(pc)) {\n seen.add(pc);\n const at = pc - origin, op = OPS[bytes[at]];\n if (op.name === '???') { lines.set(pc, { line: '.byte $' + hex(bytes[at], 2) + ' ; not an instruction', end: pc + 1 }); break; }\n const size = SIZE[op.mode], word = bytes[at + 1] | bytes[at + 2] << 8, ins = bytes.subarray(at, at + size);\n let line = (op.name + ' ' + operand(op.mode, ins, pc)).trim(), next = pc + size, stop = false;\n if (op.mode === 'imm' && 'LDA LDX LDY'.includes(op.name)) regs[op.name[2]] = bytes[at + 1];\n else if (op.name.startsWith('T') || op.name.startsWith('IN') || op.name.startsWith('DE') || op.name.startsWith('LD') || op.name === 'PLA') delete regs[op.name.at(-1)];\n if (op.name === 'JSR' && routines[word]) {\n const r = routines[word], data = INLINE[r]?.(bytes, next - origin);\n const args = ['A', 'X', 'Y'].map(k => regs[k] === undefined ? '' : k + '=' + regs[k]).filter(Boolean).join(' ');\n line = r + (data ? ' ' + data.words : '') + (args && !data ? ' ; ' + args : '');\n if (data) next += data.length;\n for (const k in regs) delete regs[k];\n } else if (op.name === 'JSR') { if (inFile(word)) { targets.add(word); queue.push(word); } for (const k in regs) delete regs[k]; }\n else if (op.name === 'JMP' && op.mode === 'abs') { if (inFile(word)) { targets.add(word); queue.push(word); } else line += ' ; into PART0' + (routines[word] ? ', ' + routines[word] : ''); stop = true; }\n else if (op.name === 'JMP' || op.name === 'RTS' || op.name === 'RTI' || op.name === 'BRK') stop = true;\n else if (op.mode === 'rel') { const t = (pc + 2 + (bytes[at + 1] << 24 >> 24)) & 0xffff; targets.add(t); queue.push(t); }\n // a table of addresses, read low byte then high byte, LDA t,X or t,Y and then LDA t+1 the same\n // way within a few instructions: every address in it that is in the file is code to follow\n if ((op.mode === 'abx' || op.mode === 'aby') && op.name === 'LDA' && inFile(word)) {\n for (let k = at + 3; k < at + 12 && k + 2 < bytes.length; k++) {\n if (bytes[k] !== bytes[at] || (bytes[k + 1] | bytes[k + 2] << 8) !== word + 1) continue;\n const table = [];\n for (let e = word - origin; e + 1 < bytes.length && table.length < 64; e += 2) { if (table.length && stops.has(origin + e)) break; const t = bytes[e] | bytes[e + 1] << 8; if (!inFile(t)) break; table.push(t); }\n line += ' ; a table of ' + table.length + ' addresses';\n for (const t of table) { targets.add(t); queue.push(t); }\n break;\n }\n }\n lines.set(pc, { line, end: next, op: op.name, mode: op.mode, value: size === 2 ? bytes[at + 1] : word, call: op.name === 'JSR' && routines[word] ? { name: routines[word], words: INLINE[routines[word]]?.(bytes, pc + 3 - origin)?.words } : null, stop });\n for (let a = pc + 1; a < next; a++) seen.add(a);\n if (stop) break;\n pc = next;\n }\n }\n const out = [];\n let last = null;\n for (const pc of [...lines.keys()].sort((a, b) => a - b)) {\n if (last !== null && pc !== last) out.push('');\n if (targets.has(pc)) out.push('L' + hex(pc, 4) + ':');\n out.push(hex(pc, 4) + ' ' + lines.get(pc).line);\n last = lines.get(pc).end;\n }\n // what the walk never reached: tables, data, and code reached only through a table\n const left = [];\n for (let a = origin; a < origin + bytes.length; ) { if (seen.has(a)) { a++; continue; } const s = a; while (a < origin + bytes.length && !seen.has(a)) a++; left.push([s, a - s]); }\n return { listing: out.join('\\n'), left, reached: seen.size, size: bytes.length, lines, targets };\n}\n\n// The lifted code as a scene script, a step to a line, each line starting with the address it\n// came from. A call into the engine is a step with its inputs, the loads before it folded in.\n// Everything else is a statement on the registers a, x and y, the flags, and memory, written\n// $866A for an address, $86E4[y] for one indexed, and ($12)[y] for one through the zero page.\n// Each statement sets the flags as its instruction did, so a branch means what it meant:\n// a compare and the branch after it are one `if a == 1 goto L8157`, and a branch alone tests a\n// flag, `if zero goto L8157`. A jump through a table that the code writes into its own JMP is\n// `goto [$86EC y]`. The bytes the walk never reached are kept as `data` lines, up to where the\n// objects' tables begin: the objects come from those tables instead.\nexport function script({ lines, targets, left }, bytes, origin, { stops = new Set(), selfModified = false, memory = false, moved = [] } = {}) {\n const H = (n, w = 4) => '$' + hex(n, w);\n // With `selfModified`, an instruction whose operand the code writes as it runs takes it from\n // memory: an immediate is the byte at its own address, an address is [$0D19], the one the code\n // keeps there, and a jump or a call goes through it. The places written are every address a\n // store, an increment or a shift names; and `moved`, the bytes of instructions seen to change\n // as the original ran (as the pilots find them), however the code wrote them (through a pointer, as\n // Find Me does)\n const written = new Set(moved);\n if (selfModified) for (const r of lines.values()) if (/^(STA|STX|STY|INC|DEC|ASL|LSR|ROL|ROR)$/.test(r.op) && /^(abs|abx|aby)$/.test(r.mode)) written.add(r.value);\n let here = null; // the address of the instruction being written\n // `memory`: code that other files write into, as the variables' file LIB.VARS, whose every\n // instruction takes its operand from memory\n const own = () => here !== null && (memory || written.has(here + 1) || written.has(here + 2));\n const place = r => {\n const v = r.value;\n if (own() && r.mode === 'imm' && (memory || written.has(here + 1))) return H(here + 1);\n if (own() && /^(abs|abx|aby)$/.test(r.mode)) return '[' + H(here + 1) + ']' + (r.mode === 'abs' ? '' : '[' + r.mode.at(-1) + ']');\n switch (r.mode) {\n case 'imm': return String(v);\n case 'zp': return H(v, 2);\n case 'zpx': return H(v, 2) + '[x]';\n case 'zpy': return H(v, 2) + '[y]';\n case 'abs': return H(v);\n case 'abx': return H(v) + '[x]';\n case 'aby': return H(v) + '[y]';\n case 'izy': return '(' + H(v, 2) + ')[y]';\n case 'izx': return '(' + H(v, 2) + '[x])';\n case 'acc': return 'a';\n default: return '?';\n }\n };\n const label = a => 'L' + hex(a, 4);\n const branch = { BEQ: 'zero', BNE: 'not zero', BCS: 'carry', BCC: 'not carry', BMI: 'negative', BPL: 'not negative', BVS: 'overflow', BVC: 'not overflow' };\n const fused = { BEQ: '==', BNE: '!=', BCS: '>=', BCC: '<' };\n const target = (pc, r) => (pc + 2 + (r.value << 24 >> 24)) & 0xffff;\n const pcs = [...lines.keys()].sort((a, b) => a - b), out = [];\n // An instruction that runs on into the bytes of another, as BIT $01A9 runs over the LDA #1 that\n // a jump to its second byte finds: the next line is not where it goes on, so a goto says where.\n const stopsHere = r => ['JMP', 'RTS', 'RTI'].includes(r.op);\n targets = new Set(targets);\n pcs.forEach((pc, i) => { const r = lines.get(pc); if (r.op && !stopsHere(r) && i + 1 < pcs.length && r.end !== pcs[i + 1] && lines.has(r.end)) targets.add(r.end); });\n let loads = []; // immediate loads waiting to be folded into the next call\n const flush = () => { for (const [pc, reg, v] of loads) out.push(hex(pc, 4) + ' ' + reg + ' = ' + v); loads = []; };\n let last = null; // the instruction before, and where it goes on\n for (let i = 0; i < pcs.length; i++) {\n const pc = pcs[i], r = lines.get(pc), next = lines.get(pcs[i + 1]), put = s => out.push(hex(pc, 4) + ' ' + s);\n here = pc;\n if (last && last.op && !stopsHere(last) && last.end !== pc && lines.has(last.end)) { flush(); out.push(hex(last.pc, 4) + ' goto ' + label(last.end)); }\n last = { ...r, pc: pcs[i] };\n if (targets.has(pc)) { flush(); out.push(label(pc) + ':'); }\n if (!r.op) { flush(); put('asm ' + r.line); continue; }\n const reg = r.op.at(-1).toLowerCase();\n if (r.call) {\n const [name, ...fixed] = r.call.name.split(' ');\n const takes = TAKES[name] || '';\n const given = Object.fromEntries(loads.map(([, g, v]) => [g, v]));\n // loads the call does not take stay as statements, before it\n const kept = loads.filter(([, g]) => !takes.includes(g)); loads = kept; flush();\n const args = [...fixed, ...[...takes].map(g => given[g] ?? g)];\n if (name === 'objects' && given.x !== undefined && given.y !== undefined) args.splice(fixed.length, 2, H(given.x | given.y << 8));\n if (name === 'key-at' || name === 'key') args[0] = given.a !== undefined ? JSON.stringify(String.fromCharCode(given.a & 0x7f)) : args[0];\n put([name, ...args, r.call.words ?? ''].join(' ').trim());\n continue;\n }\n switch (r.op) {\n case 'LDA': case 'LDX': case 'LDY':\n if (r.mode === 'imm' && !own()) { loads = loads.filter(([, g]) => g !== reg); loads.push([pc, reg, r.value]); break; }\n // the jump through a table: LDA T,Y STA J+1 LDA T+1,Y STA J+2 J: JMP\n if (r.mode === 'aby' || r.mode === 'abx') {\n const [s1, l2, s2, j] = [1, 2, 3, 4].map(k => lines.get(pcs[i + k]));\n if (s1?.op === 'STA' && l2?.op === 'LDA' && l2.value === r.value + 1 && s2?.op === 'STA' && j?.op === 'JMP' && s1.value === pcs[i + 4] + 1 && s2.value === pcs[i + 4] + 2) {\n flush(); put('goto [' + H(r.value) + ' ' + r.mode.at(-1) + ']'); i += 4; last = null; break;\n }\n }\n flush(); put(reg + ' = ' + place(r)); break;\n case 'STA': case 'STX': case 'STY': flush(); put(place(r) + ' = ' + reg); break;\n case 'TAX': case 'TAY': case 'TXA': case 'TYA': flush(); put(r.op[2].toLowerCase() + ' = ' + r.op[1].toLowerCase()); break;\n case 'INX': case 'INY': case 'DEX': case 'DEY': flush(); put(reg + (r.op[0] === 'I' ? ' += 1' : ' -= 1')); break;\n case 'INC': case 'DEC': flush(); put(place(r) + (r.op === 'INC' ? ' += 1' : ' -= 1')); break;\n case 'CLC': case 'SEC': flush(); put('carry = ' + (r.op === 'SEC' ? 1 : 0)); break;\n case 'ADC': flush(); put('a += ' + place(r) + ' + carry'); break;\n case 'SBC': flush(); put('a -= ' + place(r) + ' + borrow'); break;\n case 'AND': flush(); put('a &= ' + place(r)); break;\n case 'ORA': flush(); put('a |= ' + place(r)); break;\n case 'EOR': flush(); put('a ^= ' + place(r)); break;\n case 'ASL': case 'LSR': case 'ROL': case 'ROR': flush(); put(place(r) + ' ' + { ASL: '<<= 1', LSR: '>>= 1', ROL: 'rotate left', ROR: 'rotate right' }[r.op]); break;\n case 'BIT': flush(); put('test ' + place(r)); break;\n case 'CMP': case 'CPX': case 'CPY': {\n flush();\n const who = r.op === 'CMP' ? 'a' : r.op[2].toLowerCase();\n if (next && fused[next.op] && !targets.has(pcs[i + 1])) { put('if ' + who + ' ' + fused[next.op] + ' ' + place(r) + ' goto ' + label(target(pcs[i + 1], next))); i++; last = { ...next, pc: pcs[i] }; }\n else put('compare ' + who + ' ' + place(r));\n break;\n }\n case 'JMP': flush(); if (r.mode === 'abs' && own()) { put('goto (' + H(pc + 1) + ')'); break; } put(r.mode === 'abs' ? (r.value >= origin && r.value < origin + bytes.length ? 'goto ' + label(r.value) : 'goto-engine ' + H(r.value)) : 'goto (' + H(r.value) + ')'); break;\n case 'JSR': flush(); if (own()) { put('call (' + H(pc + 1) + ')'); break; } put(r.value >= origin && r.value < origin + bytes.length ? 'call ' + label(r.value) : 'call-engine ' + H(r.value)); break;\n case 'RTS': flush(); put('return'); break;\n case 'PHA': case 'PLA': case 'PHP': case 'PLP': flush(); put({ PHA: 'push a', PLA: 'pull a', PHP: 'push flags', PLP: 'pull flags' }[r.op]); break;\n case 'NOP': break;\n default:\n if (branch[r.op]) { flush(); put('if ' + branch[r.op] + ' goto ' + label(target(pc, r))); break; }\n flush(); put('asm ' + r.line);\n }\n }\n flush();\n // each run of bytes the walk never reached, up to where the objects begin\n for (const [a, whole] of left) {\n let n = 0; while (n < whole && !(n && stops.has(a + n)) && !stops.has(a)) n++;\n if (!n) continue;\n const row = [];\n for (let k = 0; k < n; k += 16) row.push('data ' + H(a + k) + ' ' + Array.from(bytes.subarray(a - origin + k, a - origin + Math.min(n, k + 16)), b => hex(b, 2)).join(' '));\n out.push('', ...row);\n }\n return out.join('\\n') + '\\n';\n}\n\n", "import { disasm as m } from '@moonbase-machines/mos6502';\nexport const { OPS, SIZE, disassemble, hex, operand } = m;", "import { inline as m } from '@moonbase-machines/vector';\nexport const { INLINE, name, sound, text } = m;", "// A scene script compiled to JavaScript: moonbase-compile writes each title's scripts as modules\n// beside them (its folder's compiled/<name>.js), and the remake runs those.\n//\n// The script's statements become JavaScript on the engine's registers, flags, stack and memory,\n// each line with the script's line beside it, so the code can be read against the original's.\n// A run of statements that does nothing but compute is one block, one function, from a label\n// or the step after a jump, a call or a routine's step, to the next of those; a branch back to\n// the block's own start is a loop in it. What can stop the run stays a step of its own, as the\n// engine runs it: a routine's step (a wait for a key, a picture), and any read or write that may\n// reach the I/O page (the keyboard, read until a key comes, or a tick), so that the title waits\n// where it waited, step for step.\n//\n// Each run of lines to a branch starts with its time (Engine.time), the cycles of the original's\n// instructions there, and a branch taken adds one, as the 6502's does.\n//\n// A compiled script is { labels, data, steps, run }: the labels by step, the data put into\n// memory as the script is read, each step as [its address, its line in the scene, its text],\n// and `run`, each block's function by the index of the step it starts at: (e, s) => ..., on the\n// engine e and the script's steps s.\nimport { parse, operand, branchTaken } from './script.js';\n\nconst hex = (v, n = 2) => '0x' + v.toString(16).padStart(n, '0');\n// the I/O page, the Apple's $C000 to $C0FF unless the title gives its own (compile's `io`)\nlet IO_FROM = 0xc000, IO_TO = 0xc0ff;\nconst IO = at => at >= IO_FROM && at <= IO_TO;\n\n// an operand's address as JavaScript, and whether it may be on the I/O page: an address the\n// code keeps (($26)[y], [$0D19][x]) can be anywhere, and so can a table indexed across $C000\nfunction address(o) {\n if (o.through !== undefined) return { js: `(e.mem[${hex(o.through)}] | e.mem[${hex(o.through + 1)}] << 8) + e.y & 0xffff`, io: true };\n if (o.pair !== undefined) return { js: `e.mem[${hex(o.pair)} + e.x & 0xff] | e.mem[${hex(o.pair)} + e.x + 1 & 0xff] << 8`, io: true };\n if (o.via !== undefined) return { js: `(e.mem[${hex(o.via, 4)}] | e.mem[${hex(o.via + 1, 4)}] << 8)${o.index ? ' + e.' + o.index + ' & 0xffff' : ''}`, io: true };\n if (!o.index) return { js: hex(o.at, 4), io: IO(o.at) };\n const io = o.at <= IO_TO && o.at + 255 >= IO_FROM;\n return { js: o.at + 255 > 0xffff ? `(${hex(o.at, 4)} + e.${o.index}) & 0xffff` : `${hex(o.at, 4)} + e.${o.index}`, io };\n}\n// reading an operand, and writing one: { js, io }\n// a read for a load, a compare or the like takes a cycle more where an index carries into the\n// next page (Engine.ix); a read for a change in place (an increment, a shift) never does\nfunction get(word, timed = true) {\n const o = operand(word);\n if (o.number !== undefined) return { js: String(o.number & 0xff) };\n if (o.reg === 'carry') return { js: 'e.c' };\n if (o.reg) return { js: 'e.' + o.reg };\n const a = address(o);\n if (timed && o.through !== undefined) return { js: `e.read(e.ix(e.mem[${hex(o.through)}] | e.mem[${hex(o.through + 1)}] << 8, e.y))`, io: true };\n if (timed && o.via !== undefined && o.index) return { js: `e.read(e.ix(e.mem[${hex(o.via, 4)}] | e.mem[${hex(o.via + 1, 4)}] << 8, e.${o.index}))`, io: true };\n if (timed && o.index && !o.zp) return { js: a.io ? `e.read(e.ix(${hex(o.at, 4)}, e.${o.index}))` : `e.mem[e.ix(${hex(o.at, 4)}, e.${o.index})]`, io: a.io };\n return { js: a.io ? `e.read(${a.js})` : `e.mem[${a.js}]`, io: a.io };\n}\nfunction put(word, v) {\n const o = operand(word);\n if (o.reg) return { js: `e.${o.reg} = ${v}` };\n const a = address(o);\n return { js: a.io ? `e.write(${a.js}, ${v})` : `e.mem[${a.js}] = ${v}`, io: a.io };\n}\n// a read, then a write of the same place: { at, js(read), write(v), io }\nfunction place(word) {\n const o = operand(word);\n if (o.reg) return { pre: '', read: 'e.' + o.reg, write: v => `e.${o.reg} = ${v}` };\n const a = address(o);\n if (a.io) return { pre: `const at = ${a.js}; `, read: 'e.read(at)', write: v => `e.write(at, ${v})`, io: true };\n return { pre: '', read: `e.mem[${a.js}]`, write: v => `e.mem[${a.js}] = ${v}` };\n}\n\nconst FLAGS = { zero: 'e.z', carry: 'e.c', negative: 'e.n', overflow: 'e.v' };\nconst TESTS = { '==': 'e.z', '!=': '!e.z', '>=': 'e.c', '<': '!e.c' };\n\n// One step as JavaScript: { js, kind }. A statement's kind is 'compute', or 'io' if it may reach\n// the I/O page; a jump, a call or a return ends a block ('end'); a branch may leave it\n// ('branch', with its label); a routine's step is a block of its own ('routine').\nfunction statement(step, k) {\n const w = step.words, [first, second] = w, s = `s[${k}]`;\n const of = (...parts) => ({ js: parts.map(p => p.js ?? p).join(''), kind: parts.some(p => p.io) ? 'io' : 'compute' });\n if (second === '=' && w.length === 3) {\n const v = get(w[2]), o = operand(first);\n if (o.reg === 'carry') return of('e.c = ', v, ' & 1;');\n if (o.reg) return of(`e.${o.reg} = e.flags(`, v, ');'); // a load sets the flags, a store does not\n const p = put(first, v.js);\n return { js: p.js + ';', kind: v.io || p.io ? 'io' : 'compute' };\n }\n if (second === '+=' || second === '-=') {\n const v = get(w[2]);\n if (w.length === 3) { // an increment or a decrement\n const p = place(first);\n return { js: `${p.pre}${p.write(`e.flags(${p.read} ${second[0]} ${v.js} & 0xff)`)};`, kind: p.io || v.io ? 'io' : 'compute' };\n }\n // with the carry, as ADC and SBC: SBC adds the operand turned over\n return { js: second === '+=' ? `e.add(${v.js});` : `e.sub(${v.js});`, kind: v.io ? 'io' : 'compute' };\n }\n if (second === '&=' || second === '|=' || second === '^=') { const v = get(w[2]); return of(`e.a = e.flags(e.a ${second[0]} `, v, ');'); }\n if (second === '<<=' || second === '>>=' || second === 'rotate') {\n const p = place(first), left = second === '<<=' || w[2] === 'left';\n return { js: `${p.pre}${p.write(`e.shift(${p.read}, ${left}, ${second === 'rotate'})`)};`, kind: p.io ? 'io' : 'compute' };\n }\n switch (first) {\n case 'if': {\n const to = w.at(-1), cond = w.slice(1, -2);\n if (cond.length === 3 && /^[axy]$/.test(cond[0])) { const v = get(cond[2]); return { js: `e.compare(e.${cond[0]}, ${v.js}); if (${TESTS[cond[1]]})`, kind: 'branch', to, io: v.io }; }\n const not = cond[0] === 'not', flag = FLAGS[not ? cond[1] : cond[0]];\n if (!flag) throw new Error(step.where + ': no flag ' + cond.join(' '));\n return { js: `if (${not ? '!' : ''}${flag})`, kind: 'branch', to };\n }\n case 'goto':\n if (w[1].startsWith('(')) return { js: `return e.jumpThrough(${hex(parseInt(w[1].slice(2, -1), 16), 4)}, ${s});`, kind: 'end' };\n if (w[1].startsWith('[')) return { js: `return e.jumpTable(${hex(parseInt(w[1].slice(2), 16), 4)}, e.${w[2][0]});`, kind: 'end' };\n return { js: `return e.jump('${w[1]}', ${s});`, kind: 'end' };\n case 'call':\n if (w[1].startsWith('(')) return { js: `return e.callThrough(${hex(parseInt(w[1].slice(2, -1), 16), 4)}, ${s});`, kind: 'end' };\n return { js: `return e.call('${w[1]}', ${s});`, kind: 'end' };\n case 'return': return { js: `return e.ret(${s});`, kind: 'end' };\n case 'compare': return of(`e.compare(e.${w[1]}, `, get(w[2]), ');');\n case 'test': return of('e.test(', get(w[1]), ');');\n case 'push': return { js: `e.push(${w[1] === 'a'});`, kind: 'compute' };\n case 'pull': return { js: `e.pull(${w[1] === 'a'});`, kind: 'compute' };\n case 'asm': if (w[1] === 'RTI') return { js: `return e.ret(${s});`, kind: 'end' };\n return { js: ['TSX', 'TXS', 'CLV', 'SED', 'CLD', 'SEI', 'CLI'].includes(w[1]) ? `e.asm('${w[1]}');` : '', kind: 'compute' };\n }\n const args = w.slice(1).map(a => typeof a === 'string' ? `'${a}'` : `{ string: ${JSON.stringify(a.string)} }`).join(', ');\n return { js: `return e.routine('${first}', [${args}], ${s});`, kind: 'routine' };\n}\n\nexport function compile(source, name, { io = [0xc000, 0xc0ff] } = {}) {\n [IO_FROM, IO_TO] = io;\n const { steps, labels, data } = parse(source, name);\n const code = steps.map((step, k) => statement(step, k));\n const starts = new Set([0, ...Object.values(labels)]);\n code.forEach((c, k) => {\n if (c.kind === 'routine' || c.kind === 'io' || c.io) starts.add(k);\n if (c.kind !== 'compute' && c.kind !== 'branch' || c.io) starts.add(k + 1);\n });\n const at = Object.fromEntries(Object.entries(labels).map(([l, k]) => [k, l]));\n const blocks = [];\n for (let k = 0; k < steps.length; k++) {\n if (!starts.has(k)) continue;\n let end = k + 1;\n while (end < steps.length && !starts.has(end)) end++;\n // a branch back to the block's own start: the block is a loop\n const loops = code.slice(k, end).some(c => c.kind === 'branch' && labels[c.to] === k);\n const lines = [];\n for (let i = k; i < end; i++) {\n // the time of the lines to the next branch, or the block's end (a routine's step counts its\n // own call)\n if ((i === k || code[i - 1].kind === 'branch') && code[i].kind !== 'routine') {\n let j = i; while (j < end - 1 && code[j].kind !== 'branch') j++;\n lines.push(`e.time(s, ${i}, ${j});`);\n }\n const c = code[i], text = steps[i].at === null ? steps[i].text : steps[i].at.toString(16).toUpperCase().padStart(4, '0') + ' ' + steps[i].text;\n let js = c.js;\n if (c.kind === 'branch') {\n const t = labels[c.to];\n const more = branchTaken(steps[i]), cy = more === 1 ? 'e.cycles++' : `e.cycles += ${more}`;\n js += t === undefined ? ` { ${cy}; e.pc = e.label('${c.to}'); return; }` : t === k && loops ? ` { ${cy}; continue; }` : ` { ${cy}; e.pc = ${t}; return; }`;\n }\n if (c.kind === 'end') js = `e.pc = ${i + 1}; ` + js;\n lines.push(js ? `${js.padEnd(48)} // ${text}` : `// ${text}`);\n }\n if (code[end - 1].kind !== 'end' && code[end - 1].kind !== 'routine' && end !== k + 1) lines.push(`e.pc = ${end};`);\n const label = at[k] ? ` // ${at[k]}\\n` : '';\n // a step alone that gives what it returns: one line\n const one = lines.length === 1 && /^return (.*?);( +\\/\\/ .*)$/.exec(lines[0]);\n if (one) { blocks.push(`${label} ${`${k}: (e, s) => ${one[1]},`.padEnd(60)}${one[2].trim() ? ' ' + one[2].trim() : ''}`); continue; }\n const body = loops ? ['for (;;) {', ...lines.map(l => ' ' + l), ' break;', '}'] : lines;\n blocks.push(`${label} ${k}: (e, s) => {\\n${body.map(l => ' ' + l).join('\\n')}\\n },`);\n }\n return [\n `// ${name}, compiled from ${name}.scene by moonbase-compile (@moonbase-machines/player/remake/compile.js): compiled`,\n `// again from the scene, never edited`,\n `export default {`,\n ` labels: ${JSON.stringify(labels)},`,\n ` data: [${data.map(d => `\\n [${hex(d.at, 4)}, [${d.bytes.map(b => hex(b)).join(', ')}]],`).join('')}\\n ],`,\n ` steps: [${steps.map(s => `\\n [${s.at === null ? 'null' : hex(s.at, 4)}, ${+s.where.split(':').at(-1)}, ${JSON.stringify(s.text)}],`).join('')}\\n ],`,\n ` run: {`,\n ...blocks,\n ` },`,\n `};`,\n '',\n ].join('\\n');\n}\n", "// A scene script: the steps of a part or a problem, a step to a line, as a lifter's --script\n// writes them and as they are edited after. A line may start with the address in the original\n// it came from, which is kept so that the pilots can say where two runs part.\n//\n// L8157: a label\n// 8157 object 3 4 44 a step: the engine's work, with its inputs\n// 814F a = $8235 a statement on the registers a, x, y and memory\n// 8152 if zero goto L8157 a branch on a flag, or on a compare: if a == 1 goto L8157\n// data $86E4 01 02 03 04 bytes of the original's tables, at their addresses\n// ; a comment\n//\n// parse() gives { steps, labels, data }: each step is { at, op, args, text }.\n\nconst WORD = /\"(?:[^\"\\\\]|\\\\.)*\"|\\S+/g;\n\nexport function parse(source, name = 'script') {\n const steps = [], labels = {}, data = [];\n source.split('\\n').forEach((raw, n) => {\n const line = raw.replace(/^\\s+|\\s+$/g, '');\n if (!line || line.startsWith(';')) return;\n const where = name + ':' + (n + 1);\n let m;\n if ((m = /^(L[0-9A-F]{4}|[A-Za-z_][\\w-]*):$/.exec(line))) { labels[m[1]] = steps.length; return; }\n if ((m = /^data \\$([0-9A-F]+)((?: [0-9A-F]{2})+)$/i.exec(line))) { data.push({ at: parseInt(m[1], 16), bytes: m[2].trim().split(' ').map(h => parseInt(h, 16)) }); return; }\n m = /^([0-9A-F]{4})\\s+(.*)$/.exec(line);\n const at = m ? parseInt(m[1], 16) : null, body = m ? m[2] : line;\n steps.push({ at, words: words(body), text: body, where, index: steps.length });\n });\n return { steps, labels, data };\n}\n\n// a line's words, a quoted one as { string }\nexport const words = body => body.match(WORD).map(w => w.startsWith('\"') ? { string: JSON.parse(w) } : w);\n\n// an operand: a number, a register, a flag, or a place in memory; [$0D19] is the address the\n// code keeps at $0D19 and $0D1A, written there as it runs, as an instruction's own operand is\n// 12 a x y carry $866A $86E4[y] $12[x] ($12)[y] ($12[x]) [$0D19][y]\nexport function operand(word) {\n if (typeof word !== 'string') return { string: word.string };\n if (/^-?\\d+$/.test(word)) return { number: +word };\n if (/^[axy]$/.test(word) || word === 'carry' || word === 'borrow') return { reg: word };\n let m;\n if ((m = /^\\$([0-9A-F]+)(?:\\[([xy])\\])?$/i.exec(word))) return { at: parseInt(m[1], 16), index: m[2], zp: m[1].length <= 2 };\n if ((m = /^\\(\\$([0-9A-F]{2})\\)\\[y\\]$/i.exec(word))) return { through: parseInt(m[1], 16) };\n // ($27[x]): the address kept at the zero page's $27 plus X, as LDA ($27,X)\n if ((m = /^\\(\\$([0-9A-F]{2})\\[x\\]\\)$/i.exec(word))) return { pair: parseInt(m[1], 16) };\n if ((m = /^\\[\\$([0-9A-F]{4})\\](?:\\[([xy])\\])?$/i.exec(word))) return { via: parseInt(m[1], 16), index: m[2] };\n throw new Error('not an operand: ' + word);\n}\n\n// The cycles a branch takes more when it goes: one, and one more when it goes to another page\n// than the instruction after it. A line that compares and branches (if a != 13 goto L) is two\n// instructions, the compare's size before the branch's.\nconst SIZE = w => /^\\d+$/.test(w) || /^\\$[0-9A-F]{2}(\\[[xy]\\])?$/i.test(w) || /^\\(\\$/.test(w) ? 2 : 3;\nexport function branchTaken(step) {\n if (step.at === null) return 1;\n const w = step.words, to = parseInt(w.at(-1).slice(1), 16);\n const next = (step.at + (w.length === 6 ? SIZE(w[3]) : 0) + 2) & 0xffff;\n return /^L[0-9A-F]{4}$/.test(w.at(-1)) && (to & 0xff00) !== (next & 0xff00) ? 2 : 1;\n}\n", "// The remake engine: it runs a title's scene scripts, and everything a scene does is an event.\n// It draws nothing itself. A view listens to the events and draws them however it likes, and a\n// pilot reads them as the transcript to hold against the original's.\n//\n// A script's statements act on three registers, a, x and y, four flags, a stack, and 64K of\n// memory, as the lines they were lifted from did, so the logic of a scene is kept exactly. Its\n// steps are the engine's work, which the title's routines do: a text, a picture, a wait.\n//\n// const e = new Engine({ routines, scripts, start })\n// e.run() runs until the title waits for a key: 'idle', or 'end'\n// e.press(key) a key, as a character code; the waiting step takes it on the next run\n// e.on(event => ...)\n// e.onKey(key => ...) each key as the title's keyboard takes it (key()), apart from the events, which stay the\n// transcript; returns a function that stops it\nimport { parse, operand, words, branchTaken } from './script.js';\nimport { CYCLES } from '@moonbase-machines/mos6502/cpu.js';\n\n// what a routine throws when the title leaves what it was doing (Engine.leave)\nconst LEFT = { left: true };\n// the words that start a statement rather than a routine's step\nconst STATEMENTS = new Set(['if', 'goto', 'call', 'return', 'compare', 'test', 'asm', 'push', 'pull']);\nconst STATEMENT = step => STATEMENTS.has(step.words[0]) || /^(=|\\+=|-=|&=|\\|=|\\^=|<<=|>>=|rotate)$/.test(step.words[1]);\nconst CYCLES_PER_MS = 1020.484;\n// an instruction's size by its opcode, the 6502's: by the addressing mode its bits give\nfunction size(op) {\n if (op === 0x20) return 3;\n if (op === 0x00 || op === 0x40 || op === 0x60) return 1;\n const b = op >> 2 & 7, cc = op & 3;\n if (cc === 1) return b === 3 || b === 6 || b === 7 ? 3 : 2;\n if (b === 0) return cc === 2 || (op & 0xe0) >= 0xa0 ? 2 : 1;\n if (b === 2 || b === 6) return cc === 0 || cc === 2 ? 1 : 2;\n if (b === 4) return cc === 0 ? 2 : 2;\n return b === 3 || b === 7 ? 3 : 2;\n}\n// what the lifter leaves out of its lines: a NOP, and a load of A, X or Y, immediate, zero page\n// or absolute, or CLC or SEC, that it takes into the step after as its input\nconst LEFT_OUT = new Set([0xea, 0xa9, 0xa2, 0xa0, 0xa5, 0xa6, 0xa4, 0xad, 0xae, 0xac, 0x18, 0x38]);\nconst COMPARED = step => step.words[0] === 'if' && step.words.length === 6;\n// the return address a call leaves on the 6502's stack, its JSR's last byte\nconst returnOf = step => step?.at == null ? undefined : (step.at + 2) & 0xffff;\n// an address as a script's label, L8157\nexport const label16 = at => 'L' + at.toString(16).toUpperCase().padStart(4, '0');\n\nexport class Engine {\n constructor({ routines, scripts, start, label, memory = {} }) {\n this.routines = routines; this.sources = scripts;\n this.mem = new Uint8Array(0x10000);\n for (const [at, v] of Object.entries(memory)) this.mem[at] = v;\n this.a = 0; this.x = 0; this.y = 0;\n this.n = 0; this.z = 0; this.c = 0; this.v = 0; this.d = 0;\n this.stack = []; this.keys = []; this.listeners = []; this.takers = []; this.ended = false;\n // the time the original took, in its cycles, for a title whose code is in memory where its\n // lines came from (`timed`): each line its instruction's, and the speaker's clicks by it\n this.timed = !!routines.timed; this.cycles = 0; this.clicks = []; this.delay = 0;\n this.programs = {};\n // what the title's routines set up before the start: memory, the I/O page (`io`)\n routines.setup?.(this);\n this.enter(start, label, true);\n }\n\n on(f) { this.listeners.push(f); }\n // An event made while `inside` is above nought is part of a routine's own work, as the choice\n // PROB2 draws while its ask waits: the view draws it, but it is no step of the transcript.\n emit(event) { if (this.inside) event.inside = true; for (const f of this.listeners) f(event); }\n inside = 0;\n press(key) { this.keys.push(key); }\n key() { const k = this.keys.shift(); if (k !== undefined) for (const f of this.takers) f(k); return k; }\n onKey(f) { this.takers.push(f); return () => { this.takers = this.takers.filter(g => g !== f); }; }\n\n // start a script from its first step, or from a label in it; when it is loaded, as the original\n // loads its file, its data goes into memory, and otherwise memory is as the game left it\n enter(name, label, load = false) {\n const p = this.script(name);\n if (load) for (const d of p.data) this.mem.set(d.bytes, d.at);\n this.program = p; this.name = name; this.pc = label === undefined ? 0 : this.label(label);\n }\n // a script by its name, as written (a scene, run line by line) or compiled (compile.js)\n script(name) {\n if (this.programs[name]) return this.programs[name];\n const src = this.sources[name];\n if (src === undefined) throw new Error('no script ' + name);\n const p = this.programs[name] = typeof src === 'string' ? parse(src, name) : {\n labels: src.labels,\n data: src.data.map(([at, bytes]) => ({ at, bytes })),\n steps: src.steps.map(([at, line, text], k) => ({ at, text, where: name + ':' + line, run: src.run[k], words: words(text), index: k })),\n };\n // a step whose label is before it starts there: the lines the lifter took into it (Engine.cost)\n for (const [l, k] of Object.entries(p.labels)) { const at = /^L[0-9A-F]{4}$/.test(l) ? parseInt(l.slice(1), 16) : null; if (at !== null && p.steps[k]?.at > at) p.steps[k].start = at; if (at !== null && p.steps[k]?.at === at) p.steps[k].entered = true; }\n return p;\n }\n // Leave everything running, the scripts called and a problem with them, for a label: as the\n // original jumps to its Main Menu from the key reader, and resets the stack. The routine that\n // leaves goes no further.\n // A routine of the title's own code, run inside the step that calls it: its steps are part of\n // that step's work, and no steps of the transcript; `done` is called as it returns.\n callInside(name, label, done, ret) {\n this.stack.push({ name: this.name, pc: this.pc, inside: true, done, ret });\n this.inside++;\n this.enter(name, label);\n }\n leave(name, label) {\n this.stack = []; this.problem = null; this.waitingOn = null; this.visited = null;\n this.enter(name, label);\n throw LEFT;\n }\n // Nature Park's menus, from a key reader on control-E or control-T ($4C28): the routine that\n // read the key asks for them and waits, so that a problem it is inside goes on living; then what\n // was running is kept, with the screen, and the menus run as a routine, the A it gives them 2.\n // When they return, all is put back and the routine waits for a key again, as the original's\n // key reader comes back with none ($4C51). A visit from inside the menus keeps what was kept.\n visit(key) { this.visiting = key; }\n startVisit(here) {\n const [name, label] = this.title.visit[this.visiting];\n this.visiting = undefined;\n if (!this.visited) {\n this.visited = { name: this.name, pc: here, stack: this.stack, problem: this.problem, waitingOn: this.waitingOn, asked: this.asked, askMode: this.askMode, regs: [this.a, this.x, this.y, this.n, this.z, this.c, this.v] };\n // $4C5D: the screen kept, cleared, and the graphics shown\n this.title.raster?.keepScreen();\n this.inside++; this.emit({ step: 'keep-screen' }); this.inside--;\n this.routines.show(this, [], null);\n }\n this.stack = [{ visit: true }]; this.problem = null; this.waitingOn = null; this.asked = null;\n this.a = 2; this.c = 0;\n this.enter(name, label);\n }\n endVisit() {\n const v = this.visited;\n this.visited = null;\n // $4CFB: the screen put back, and the graphics shown\n this.title.raster?.putScreen();\n this.inside++; this.emit({ step: 'put-screen' }); this.inside--;\n this.routines.show(this, [], null);\n this.enter(v.name);\n Object.assign(this, { pc: v.pc, stack: v.stack, problem: v.problem, waitingOn: v.waitingOn, asked: v.asked, askMode: v.askMode });\n [this.a, this.x, this.y, this.n, this.z, this.c, this.v] = v.regs;\n }\n label(l) { const i = this.program.labels[l]; if (i === undefined) throw new Error(this.name + ': no label ' + l); return i; }\n\n // reading and writing an operand\n place(o) {\n if (o.through !== undefined) return ((this.mem[o.through] | this.mem[o.through + 1] << 8) + this.y) & 0xffff;\n if (o.pair !== undefined) { const z = (o.pair + this.x) & 0xff; return this.mem[z] | this.mem[(z + 1) & 0xff] << 8; }\n if (o.via !== undefined) return ((this.mem[o.via] | this.mem[o.via + 1] << 8) + (o.index ? this[o.index] : 0)) & 0xffff;\n return (o.at + (o.index ? this[o.index] : 0)) & 0xffff;\n }\n // The I/O page, $C000 to $C0FF, goes to the title's `io`, when it has one: the keyboard and the\n // soft switches that pick what the screen shows. A read of the keyboard with no key sets\n // `polled`, and the run stops there for a key, as the original's loop waits on it.\n // (the title's I/O page, `ioAt`: the Apple's $C000 to $C0FF unless the title says otherwise, as\n // the Commodore 64's $D000 to $DFFF)\n read(at) { return this.io && this.ioAt(at) ? this.io(at) & 0xff : this.mem[at]; }\n write(at, v) { if (this.io && this.ioAt(at)) this.io(at, v & 0xff); else this.mem[at] = v; }\n ioAt(at) { return (at & 0xff00) === 0xc000; }\n get(o) {\n if (o.number !== undefined) return o.number & 0xff;\n if (o.reg === 'carry') return this.c;\n if (o.reg) return this[o.reg];\n return this.read(this.place(o));\n }\n // a read for a load, a compare or the like: through an index, a cycle more when the index\n // carries into the next page, as the 6502 takes it\n load(o) {\n if (this.timed && (o.index && !o.zp || o.through !== undefined)) {\n const base = o.through !== undefined ? this.mem[o.through] | this.mem[o.through + 1] << 8 : o.via !== undefined ? this.mem[o.via] | this.mem[o.via + 1] << 8 : o.at;\n if ((base & 0xff) + this[o.index ?? 'y'] > 0xff) this.cycles++;\n }\n return this.get(o);\n }\n // an indexed address, for compiled code: the same cycle more\n ix(base, i) { if (this.timed && (base & 0xff) + i > 0xff) this.cycles++; return (base + i) & 0xffff; }\n set(o, v) {\n v &= 0xff;\n if (o.reg) { this[o.reg] = v; return; }\n this.write(this.place(o), v);\n }\n flags(v) { this.n = v >> 7 & 1; this.z = v === 0 ? 1 : 0; return v; }\n compare(r, v) { const d = (r - v) & 0x1ff; this.c = r >= v ? 1 : 0; this.flags(d & 0xff); }\n\n // The statements' work, the same for a script run line by line (exec) and one compiled to\n // JavaScript (compile.js).\n // The cycles of the lines from step i to step j of a script, the instructions' as the original\n // has them in memory at the lines' addresses, a branch taken one more (Engine.branch, and the\n // compiled branches): kept with step i, the first time, and counted toward the run's delay.\n time(s, i, j) {\n if (!this.timed) return;\n let c = s[i].cycles;\n if (c === undefined) { c = 0; for (let k = i; k <= j; k++) c += this.cost(s, k); s[i].cycles = c; }\n this.cycles += c; this.delay += c / CYCLES_PER_MS;\n }\n // A line's cycles: its instruction's, a compare and its branch both (if a != 13 goto L), and\n // those the lifter left out just before it, from where the line before ended (past the data\n // after its call, as the title reads it, `inline`): a register's load it took into the step's\n // inputs (hposn 34 57 0 was LDA, LDX, LDY and the JSR), a NOP\n cost(s, k) {\n const step = s[k], m = this.mem;\n if (step.at === null) return 0;\n let c = CYCLES[m[step.at]] + (COMPARED(step) ? 2 : 0);\n // the line before falls through to it, unless the line is where a jump comes in (its label at\n // its own address) or the line before goes elsewhere\n const prev = !step.entered && !['return', 'goto'].includes(s[k - 1]?.words[0]) ? s[k - 1] : null;\n if (step.start !== undefined || prev && prev.at !== null) {\n // from its label, where a jump comes in, or where the line before ended\n const from = step.start ?? prev.at + size(m[prev.at]) + (COMPARED(prev) ? 2 : 0) + (this.routines.inline?.(this, prev) ?? 0);\n if (from < step.at && step.at - from <= 9) {\n let more = 0, a = from;\n for (; a < step.at && LEFT_OUT.has(m[a]); a += size(m[a])) more += CYCLES[m[a]];\n if (a === step.at) c += more; // only these, or the bytes between are no code (a variable)\n }\n }\n return c;\n }\n // ADC: the sum with the carry into A, and the flags; in decimal mode (SED, as Zoopak's clocks\n // count) by the 6502's own rules, as @moonbase-machines/mos6502/cpu.js\n add(m) {\n if (this.d) {\n let lo = (this.a & 15) + (m & 15) + this.c, hi = (this.a >> 4) + (m >> 4);\n if (lo > 9) { lo -= 10; hi++; }\n this.z = ((this.a + m + this.c) & 0xff) === 0 ? 1 : 0;\n this.n = hi & 8 ? 1 : 0; this.v = (~(this.a ^ m) & (this.a ^ (hi << 4)) & 0x80) ? 1 : 0;\n if (hi > 9) { hi -= 10; this.c = 1; } else this.c = 0;\n this.a = ((hi << 4) | lo) & 0xff; return;\n }\n const a = this.a, sum = a + m + this.c;\n this.v = (~(a ^ m) & (a ^ sum) & 0x80) ? 1 : 0; this.c = sum > 0xff ? 1 : 0; this.a = this.flags(sum & 0xff);\n }\n // SBC: in binary ADC with the operand turned over; in decimal mode by the 6502's rules\n sub(m) {\n if (!this.d) return this.add(m ^ 0xff);\n let lo = (this.a & 15) - (m & 15) - (1 - this.c), hi = (this.a >> 4) - (m >> 4);\n if (lo < 0) { lo += 10; hi--; }\n const r = this.a - m - (1 - this.c); this.z = (r & 0xff) === 0 ? 1 : 0; this.n = r & 0x80 ? 1 : 0;\n this.v = ((this.a ^ m) & (this.a ^ r) & 0x80) ? 1 : 0; this.c = r >= 0 ? 1 : 0;\n if (hi < 0) hi += 10;\n this.a = ((hi << 4) | lo) & 0xff;\n }\n // ASL, LSR, ROL and ROR: the value shifted, the bit out into the carry\n shift(v, left, through) {\n const r = left ? (v << 1 | (through ? this.c : 0)) & 0xff : v >> 1 | (through && this.c ? 0x80 : 0);\n this.c = left ? v >> 7 : v & 1; return this.flags(r);\n }\n // BIT: N and V from the value, Z from it ANDed with A\n test(v) { this.n = v >> 7 & 1; this.v = v >> 6 & 1; this.z = (v & this.a) === 0 ? 1 : 0; }\n // goto a label of this script's; one that a file read since has put another script's code\n // over is that script's (the title's `elsewhere`)\n jump(l, step) {\n if (this.routines.elsewhere?.(this, l)) return this.routines['goto-engine'](this, ['$' + l.slice(1)], step);\n this.pc = this.label(l);\n }\n // goto ($8371): through the address kept at $8371 and $8372, as JMP ($8371), into this script\n // or the title's code elsewhere\n jumpThrough(t, step) {\n const l = label16(this.mem[t] | this.mem[t + 1] << 8);\n if (this.program.labels[l] === undefined && this.routines['goto-engine']) return this.routines['goto-engine'](this, ['$' + l.slice(1)], step);\n this.pc = this.label(l);\n }\n // goto [$8180 y]: through a table of addresses, the one at the index\n jumpTable(t, i) { this.pc = this.label(label16(this.mem[t + i] | this.mem[t + i + 1] << 8)); }\n call(l, step) {\n if (this.routines.elsewhere?.(this, l)) return this.routines['call-engine'](this, ['$' + l.slice(1)], step);\n this.stack.push({ name: this.name, pc: this.pc, ret: returnOf(step) }); this.pc = this.label(l);\n }\n // call ($0D19): through the address the code keeps there, into this script or another's\n callThrough(t, step) {\n const l = label16(this.mem[t] | this.mem[t + 1] << 8);\n if (this.program.labels[l] === undefined && this.routines['call-engine']) return this.routines['call-engine'](this, ['$' + l.slice(1)], step);\n this.stack.push({ name: this.name, pc: this.pc, ret: returnOf(step) }); this.pc = this.label(l);\n }\n ret(step) {\n const f = this.stack.pop();\n if (!f) throw new Error('return with nothing called');\n if (f.visit) { this.endVisit(); return; }\n const p = this.pulled;\n // two bytes pushed, an address less one, high byte first: RTS goes there, the 6502's\n // jump through a table (PHA PHA RTS, as LIB4's menu goes to its choice)\n if (f.a !== undefined && this.stack.at(-1)?.a !== undefined) {\n const hi = this.stack.pop().a, to = ((hi << 8 | f.a) + 1) & 0xffff, l = label16(to);\n // or back past the data after a call whose frame was pulled to read it (fill's, print's):\n // to the step after the call, the next in its script (which may start a little further on,\n // where the lifter took a register's load into the step that uses it)\n if (p?.ret !== undefined && to > p.ret && to - p.ret <= 0x100) {\n this.pulled = null;\n if (p.name !== this.name) this.enter(p.name);\n this.pc = p.pc;\n if (p.inside) { this.inside--; p.done?.(this); }\n return;\n }\n // or back before the call, in the script that made it, to make a call again: Detect-A-Pet's\n // disk error screens, which once the disk is back go back to the ProDOS call that failed\n // (still inside the routine, as the original's count of calls is, until the call made\n // again comes back to where the first would have: `again`)\n if (p?.ret !== undefined && to <= p.ret && p.ret - to <= 0x20 && this.script(p.name).labels[l] !== undefined) {\n this.pulled = null;\n if (p.name !== this.name) this.enter(p.name);\n this.pc = this.label(l);\n if (p.inside) this.again = this.again?.ret === p.ret ? { ...this.again, n: this.again.n + 1 } : { ret: p.ret, done: p.done, n: 1 };\n return;\n }\n if (this.program.labels[l] === undefined && this.routines['goto-engine']) return this.routines['goto-engine'](this, ['$' + l.slice(1)], step);\n this.pc = this.label(l); return;\n }\n // a routine's frame pulled and dropped, and a return from below where it was: what it was\n // inside is left now (the routine's own calls return above it)\n if (p && this.stack.length < p.depth) { this.pulled = null; if (p.inside && p.ret !== undefined) this.inside--; }\n if (f.name !== this.name) this.enter(f.name);\n this.pc = f.pc;\n // the end of a routine run inside a step (Engine.inside): what it gives, as its result; and\n // what a frame does as it is returned to (`after`: BASIC's SYS keeps the registers)\n if (f.inside) { this.inside--; f.done?.(this); }\n if (this.again && f.ret === this.again.ret) { const a = this.again; this.again = null; this.inside -= a.n; a.done?.(this); }\n f.after?.(this);\n }\n push(a) { this.stack.push(a ? { a: this.a } : { flags: [this.n, this.z, this.c, this.v] }); }\n pull(a) {\n // a call's frame is the two bytes of its return address on the original's stack, the last\n // byte of its JSR: PLA gives the low byte, then the high, and two pulls drop it, as PLA PLA\n // drops a return to go back two calls at once ($0D26), or as fill takes its data from after\n // the call; the frame is kept (`pulled`) for the return that goes back past the data\n const top = this.stack.at(-1);\n if (top && top.name !== undefined) {\n const v = top.ret === undefined ? 0 : top.half ? top.ret >> 8 : top.ret & 0xff;\n if (top.half) { this.stack.pop(); top.depth = this.stack.length; this.pulled = top; if (top.inside && top.ret === undefined) this.inside--; } else top.half = true;\n if (a) this.a = this.flags(v);\n return;\n }\n const f = this.stack.pop(); if (a) this.a = this.flags(f.a); else [this.n, this.z, this.c, this.v] = f.flags;\n }\n // the stack's place, as the original's stack pointer would be with these frames on it: each\n // frame its bytes, a call's two (its return address) and a push's one\n sp() { return 0xff - this.stack.reduce((n, f) => n + (f.name === undefined ? 1 : f.half ? 1 : 2), 0) & 0xff; }\n // the frames kept at their place, for a TXS to go back to, and their bytes in the stack page as\n // the original's are there: a call's return address, high byte first from the bottom, as JSR\n // pushes it (half of one pulled, its high byte), and a push's byte, PHP's as the 6502's (Pieces of Eight's DOS error\n // handler, $93F0, reads the return address under its own to see who called)\n stackPage() {\n const sp = this.sp();\n (this.stacks ??= new Map()).set(sp, this.stack.map(f => ({ ...f })));\n let at = 0xff;\n for (const f of this.stack) {\n const r = f.ret ?? 0;\n if (f.name === undefined) this.mem[0x100 + at--] = f.a ?? (f.flags ? f.flags[0] << 7 | f.flags[3] << 6 | 0x30 | f.flags[1] << 1 | f.flags[2] : 0);\n else { this.mem[0x100 + at--] = r >> 8; if (!f.half) this.mem[0x100 + at--] = r & 0xff; }\n }\n return sp;\n }\n // the machine's own instructions a scene keeps. TSX gives the stack's place (`stackPage`); TXS\n // goes back to the frames kept at the place it is given (Detect-A-Pet's save and\n // load keep the stack page and its pointer), and to none at any other, as the town's\n // resets the stack and drops every script called. SED and CLD set decimal mode, and SEI and\n // CLI the mask a Commodore 64's interrupt waits on (card.js). The rest (a byte that\n // is no instruction) change nothing the remake holds.\n asm(op) {\n if (op === 'TSX') this.x = this.flags(this.stackPage());\n if (op === 'TXS') {\n const kept = this.stacks?.get(this.x);\n this.stack = kept ? kept.map(f => ({ ...f })) : []; this.visited = null; this.inside = this.stack.filter(f => f.inside).length;\n }\n if (op === 'CLV') this.v = 0; // as LIB4 does before a branch that always goes\n if (op === 'SED') this.d = 1; if (op === 'CLD') this.d = 0; // decimal mode, for ADC and SBC\n if (op === 'SEI') this.i = 1; if (op === 'CLI') this.i = 0; // interrupts masked, and not\n }\n\n // run until the title waits for a key, or `limit` steps: ten million, as Detect-A-Pet's toy\n // shop turns a screen over seven times, a byte at a time, in its own lifted code\n run(limit = 1e7) {\n // the keyboard read with no key, in this run (`io`): a run that goes on after the time the\n // original took ('pace') goes on counting, as the machine's one run would\n if (!this.pacing) this.idle = 0;\n this.pacing = false;\n this.delay ??= 0;\n for (let i = 0; i < limit; i++) {\n if (this.ended) return 'end';\n const step = this.program.steps[this.pc];\n if (!step) throw new Error(this.name + ': ran off the end');\n // the title's own word before a statement runs: a card title's tick stops there\n if (this.routines.before?.(this, step) === 'wait') return 'idle';\n const r = this.exec(step);\n if (r === 'wait') return 'idle';\n if (this.polled) { this.polled = false; return 'idle'; }\n // the time the original took, a disk's read or a wait it counted out, in milliseconds: a\n // frame's worth or more stops the run, for the page to show the screen and take the time\n if (this.delay >= 16) { this.pacing = true; return 'pace'; }\n }\n return 'steps';\n }\n\n // A step: a compiled script's own function (`run`, for a run of statements together, or a\n // routine's step), or the step's words, line by line. Only a routine's step that waits runs\n // again when the key comes.\n exec(step) {\n const here = this.pc;\n this.pc++;\n try {\n this.called = false;\n if (!step.run && STATEMENT(step)) this.time(this.program.steps, here, here);\n const r = step.run ? step.run(this, this.program.steps) : this.interpret(step);\n if (r === 'wait' && (step.run ? this.called : !STATEMENT(step))) {\n this.pc = here;\n if (this.visiting !== undefined) { this.startVisit(here); return; }\n }\n return r;\n } catch (e) {\n if (e === LEFT) { this.inside = 0; return; } // counted down as it left what it was inside\n // an error the title answers as its machine did (a BASIC program's, BASIC's message and the\n // end of the program: card.js `error`)\n if (this.routines.error?.(this, e)) { this.ended = true; return; }\n e.message = step.where + ' (' + step.text + '): ' + e.message;\n throw e;\n }\n }\n\n interpret(step) {\n const w = step.words, [first, second] = w;\n // a = $8235, $866A = a, x += 1, a &= 127, $8235 <<= 1\n if (second === '=' && w.length === 3) {\n const o = operand(first), v = this.load(operand(w[2]));\n if (o.reg === 'carry') { this.c = v & 1; return; }\n this.set(o, v); if (o.reg) this.flags(v); // a load sets the flags, a store does not\n return;\n }\n if (second === '+=' || second === '-=') {\n const o = operand(first), v = w.length === 3 ? this.get(operand(w[2])) : this.load(operand(w[2]));\n if (w.length === 3) { const r = (this.get(o) + (second === '+=' ? v : -v)) & 0xff; this.set(o, r); this.flags(r); return; } // increment or decrement\n if (second === '+=') this.add(v); else this.sub(v); return; // with the carry, as ADC and SBC\n }\n if (second === '&=' || second === '|=' || second === '^=') { const v = this.load(operand(w[2])); this.a = this.flags(second === '&=' ? this.a & v : second === '|=' ? this.a | v : this.a ^ v); return; }\n if (second === '<<=' || second === '>>=' || second === 'rotate') {\n const o = operand(first);\n this.set(o, this.shift(this.get(o), second === '<<=' || w[2] === 'left', second === 'rotate')); return;\n }\n switch (first) {\n case 'if': return this.branch(w, step);\n case 'goto':\n if (w[1].startsWith('(')) return this.jumpThrough(parseInt(w[1].slice(2, -1), 16), step);\n if (w[1].startsWith('[')) return this.jumpTable(parseInt(w[1].slice(2), 16), this[w[2][0]]);\n return this.jump(w[1], step);\n case 'call':\n if (w[1].startsWith('(')) return this.callThrough(parseInt(w[1].slice(2, -1), 16), step);\n return this.call(w[1], step);\n case 'return': return this.ret(step);\n case 'compare': this.compare(this[w[1]], this.load(operand(w[2]))); return;\n case 'test': this.test(this.get(operand(w[1]))); return;\n case 'asm': if (w[1] === 'RTI') return this.ret(step); this.asm(w[1]); return; // (RTI: the end of an interrupt's routine, card.js)\n case 'push': this.push(w[1] === 'a'); return;\n case 'pull': this.pull(w[1] === 'a'); return;\n }\n return this.routine(first, w.slice(1), step); // a quoted word comes as { string }\n }\n // a step: the title's routines do the engine's work\n routine(name, args, step) {\n const routine = this.routines[name];\n if (!routine) throw new Error('no routine ' + name);\n this.called = true;\n // the call into the toolkit, its JSR's cycles; the routine's own lines count as they run\n // and the loads the lifter took into the step (Engine.cost)\n if (step && this.timed && step.at !== null) { const c = this.cost(this.program.steps, step.index); this.cycles += c; this.delay += c / CYCLES_PER_MS; }\n return routine(this, args, step);\n }\n\n // if <flag> goto L, if not <flag> goto L, if <reg> <op> <operand> goto L\n branch(w, step) {\n const to = w.at(-1), cond = w.slice(1, -2);\n let yes;\n if (cond.length === 3 && /^[axy]$/.test(cond[0])) {\n this.compare(this[cond[0]], this.load(operand(cond[2])));\n yes = { '==': this.z, '!=': !this.z, '>=': this.c, '<': !this.c }[cond[1]];\n } else {\n const not = cond[0] === 'not', flag = not ? cond[1] : cond[0];\n const v = { zero: this.z, carry: this.c, negative: this.n, overflow: this.v }[flag];\n if (v === undefined) throw new Error('no flag ' + flag);\n yes = not ? !v : !!v;\n }\n if (yes) { this.cycles += branchTaken(step); this.pc = this.label(to); }\n }\n}\n", "import { cpu as m } from '@moonbase-machines/mos6502';\nexport const { CPU, CYCLES } = m;", "// A text laid out as the engine's text routine ($6CE2) lays it out, for the view to draw and for\n// the screen model to paint. `pen` is the text state that lasts from text to text: the pen's x and\n// y, the margin, centring, the spacing, the gap between lines, the ink and the paper. It is changed\n// here as the engine changes it.\n//\n// {0:x} the pen's x and the margin {1:y} its y, or from $C0 the line height\n// {2:n} the spacing {3:n} the gap between lines {4:c} the ink {5:c} the paper\n// {7} and {8} centring on and off {9} and {a} tall on and off {f:ch,n} a character n times\n// {d} and {e} ink 0 and ink 1 from here on {10} and {11} the big digits and back\n//\n// Returns the lines, each { top, tall, height, paper, ink, chars }, and each character { ch, x, ink },\n// its x in dots. A character's ink is undefined before the line's first color: the engine draws\n// that part in the ink the whole line ends with, which is the line's `ink`. A byte below a space\n// is a spacer, a few dots of room and nothing drawn.\nimport { width, start } from '@moonbase-machines/vector/font.js';\n\n// the screen's layout by $03E3: the window's last row, and the tops of the two boxes below it\nexport const LAYOUT = { 0x41: [116, 116, 174], 0x32: [116, 116, 160], 0x31: [130, 130, 174], 0x22: [130, 130, 160], 0x11: [158, 158, 174] };\n// the panels: the layout they set, the rows of the box they clear, from its two white rows down,\n// and its color, and the text state they leave; `more`, white rows drawn below as well. 1 to 6 are\n// Animal Rescue's, $6299 to $6395; Nature Park has the same six and eighteen more, $5712 to $58A6,\n// in families that share a body and differ in the gap and the row they leave (its title's map).\nconst gray = (layout, rows, gap, y, more) => ({ layout, rows, fill: 10, paper: 10, ink: 0, gap, y, more });\nconst blue = (layout, rows, gap, y) => ({ layout, rows, fill: 5, paper: 5, ink: 15, gap, y });\nexport const PANELS = {\n 1: gray(0x32, [116, 159], 7, 128), 2: gray(0x32, [116, 159], 33, 135),\n 3: gray(0x22, [130, 159], 5, 135), 4: gray(0x22, [130, 159], 19, 142),\n 5: blue(0x22, [160, 189], 5, 166), 6: blue(0x22, [160, 189], 19, 172),\n 7: gray(0x41, [116, 173], 5, 121), 8: gray(0x41, [116, 173], 6, 128), 9: gray(0x41, [116, 173], 7, 134), 10: gray(0x41, [116, 173], 47, 142),\n 11: gray(0x32, [116, 159], 5, 121),\n 12: gray(0x31, [130, 173], 5, 135), 13: gray(0x31, [130, 173], 7, 142), 14: gray(0x31, [130, 173], 33, 149),\n 15: gray(0x11, [158, 173], 5, 163, [174]),\n 16: blue(0x32, [160, 189], 19, 172), 17: blue(0x42, [160, 189], 19, 172),\n 18: blue(0x32, [160, 189], 5, 166), 19: blue(0x42, [160, 189], 5, 166),\n 20: blue(0x23, [160, 189], 0, 163), 21: blue(0x33, [160, 189], 0, 163), 22: blue(0x43, [160, 189], 0, 163),\n 23: blue(0x31, [174, 189], 5, 179), 24: blue(0x41, [174, 189], 5, 179),\n};\n\n// code 6: a word from a table of words, each its length then its letters, the index given or\n// read from memory\nexport function word(mem, [lo, hi, vlo, vhi]) {\n let at = lo | hi << 8, n = vhi === 0xff ? vlo : mem[vlo | vhi << 8];\n while (n-- > 0) at += mem[at] + 1;\n let s = ''; for (let k = 1; k <= mem[at]; k++) s += String.fromCharCode(mem[at + k] & 0x7f);\n return s;\n}\n// a text's words with the words code 6 takes put in, from memory as it is now\nexport const resolve = (words, mem) => words.replace(/\\{6:([0-9a-f,]+)\\}/g, (all, b) => word(mem, b.split(',').map(v => parseInt(v, 16))));\n\nexport function layout(words, pen) {\n const t = pen, lines = [];\n t.tall = false; t.margin = t.x; let height = 9, big = false;\n let line = [], ink = t.ink, marked = false;\n const flush = newline => {\n if (line.length) {\n let x = start(line.map(c => c.ch), t.spacing, t.x, t.centre);\n const chars = [];\n for (const c of line) {\n const w = width(c.ch);\n chars.push({ ch: c.ch, x, ink: c.ink });\n x += c.ch.charCodeAt(0) < 0x20 ? w : w + t.spacing;\n }\n lines.push({ top: t.y, tall: t.tall, height, paper: t.paper, ink: t.ink, chars });\n t.x = x;\n }\n line = [];\n if (newline) { t.y += (t.tall ? 2 * height : height) + t.gap; t.x = t.margin; }\n };\n // a digit in the big set is its own character, $80 and on (@moonbase-machines/vector/font.js)\n const put = ch => line.push({ ch: big && ch >= '0' && ch <= '9' ? String.fromCharCode(0x80 + ch.charCodeAt(0) - 0x30) : ch, ink: marked ? ink : undefined });\n for (let i = 0; i < words.length; i++) {\n const c = words[i];\n if (c === '\\n') { flush(true); continue; }\n if (c === '{') {\n const end = words.indexOf('}', i), [code, rest] = words.slice(i + 1, end).split(':'), b = (rest ?? '').split(',').map(v => parseInt(v, 16));\n i = end;\n switch (parseInt(code, 16)) {\n case 0: t.x = t.margin = b[0]; break;\n case 1: if (b[0] < 0xc0) t.y = b[0]; else height = b[0] - 0xc0; break;\n case 2: t.spacing = b[0]; break;\n case 3: t.gap = b[0]; break;\n case 4: t.ink = ink = b[0]; marked = true; break;\n case 5: t.paper = b[0]; break;\n case 7: t.centre = true; break;\n case 8: t.centre = false; break;\n case 9: t.tall = true; break;\n case 10: t.tall = false; break;\n case 13: ink = 0; marked = true; break;\n case 14: ink = 1; marked = true; break;\n case 16: big = true; break;\n case 17: big = false; break;\n case 15: for (let k = 0; k < (b[1] || 256); k++) put(String.fromCharCode(b[0] & 0x7f)); break;\n }\n continue;\n }\n put(c);\n }\n flush(false);\n return lines;\n}\n\n// The same codes on the text screen, where the menus and the teacher's controls are ($573D puts\n// the machine in 40 columns of text): {0:x} is the column and the margin, {1:y} the row, a new\n// line the next row at the margin, {7} centres each line in the 40 columns, and {d} and {e} turn\n// inverse on and off. Inverse has capitals only, as the text page's inverse codes do. The\n// spacing, the gap, the colors and tall mean nothing there.\n// Returns the characters as { row, col, ch, inverse }, and leaves the pen where the text ended.\nexport function textLayout(words, pen) {\n const cells = [];\n pen.inverse = false; // each text starts out of inverse ($6D02)\n let line = [];\n const flush = newline => {\n const col = pen.centre ? (40 - line.length) >> 1 : pen.x;\n line.forEach((c, k) => cells.push({ row: pen.y, col: col + k, ch: c.ch, inverse: c.inverse }));\n if (line.length) pen.x = col + line.length;\n line = [];\n if (newline) { pen.y++; pen.x = pen.margin; }\n };\n const put = ch => line.push({ ch: pen.inverse ? ch.toUpperCase() : ch, inverse: pen.inverse });\n for (let i = 0; i < words.length; i++) {\n const c = words[i];\n if (c === '\\n') { flush(true); continue; }\n if (c === '{') {\n const end = words.indexOf('}', i), [code, rest] = words.slice(i + 1, end).split(':'), b = (rest ?? '').split(',').map(v => parseInt(v, 16));\n i = end;\n switch (parseInt(code, 16)) {\n case 0: flush(false); pen.x = pen.margin = b[0]; break;\n case 1: flush(false); if (b[0] < 0xc0) pen.y = b[0]; break;\n case 7: pen.centre = true; break;\n case 8: pen.centre = false; break;\n case 13: pen.inverse = true; break;\n case 14: pen.inverse = false; break;\n case 15: for (let k = 0; k < (b[1] || 256); k++) put(String.fromCharCode(b[0] & 0x7f)); break;\n }\n continue;\n }\n put(c);\n }\n flush(false);\n return cells;\n}\n// the text state at the start, and the empty screen\nexport const textPen = () => ({ x: 0, y: 0, margin: 0, centre: false, inverse: false });\nexport const textPage = () => Array.from({ length: 24 }, () => Array.from({ length: 40 }, () => ({ ch: ' ', inverse: false })));\n", "import { font as m } from '@moonbase-machines/vector';\nexport const { GLYPHS, WIDTHS, dots, start, useFont, width } = m;", "// One way to start a title's remake, for the remake's page (main.js), a replay and Node (a pilot's observer): the\n// title's title.js, from the folder it is in, with the modules it names (its problems, its paint); its scripts,\n// compiled to JavaScript (bin/moonbase-compile.mjs) or, with `scenes`, the scene files themselves to run line by line;\n// its game's data, from where the page keeps it; and an engine made from them.\n//\n// const { title, scripts, disk, folder } = await loadTitle(folder, { data })\n// folder the title's folder, an absolute URL (its title.js, its scenes, compiled/, its own modules)\n// data its game's data, an absolute URL (<slug>.json: its disks' files, its kind, its saves)\n// title.disk = disk; title.seed = 17 (the caller's: a data disk, the seed)\n// const engine = makeEngine(title, scripts)\n// With `fixed`, a title that has a version with its bugs fixed (its title.js `fixed`, a script for each it replaces)\n// runs those scripts in place of its own. A title whose engine is its own (its title.js `engine` the name of a module\n// in its folder, not 'card' or 'vector') has no scripts here: its engine is loaded with its other modules, as\n// `title.own`, and runs the game itself (main.js).\nimport { Engine } from './engine.js';\nimport { vectorRoutines } from './vector.js';\nimport { cardRoutines } from './card.js';\nimport { started } from '@moonbase-machines/apple2e/prodos.js';\n\nconst ENGINES = { vector: vectorRoutines, card: cardRoutines };\n\n// a file read in the browser by fetch, and in Node from the disk (Node's own fs, asked of Node itself, so that the\n// browser's files import nothing of Node's)\nasync function read(url, as) {\n if (url.protocol === 'file:') { const text = globalThis.process.getBuiltinModule('node:fs').readFileSync(url, 'utf8'); return as === 'json' ? JSON.parse(text) : text; }\n const r = await fetch(url);\n if (!r.ok) throw new Error(`${url.pathname}: ${r.status}`);\n return as === 'json' ? r.json() : r.text();\n}\nconst defaultOf = async url => (await import(url.href)).default;\n\nexport async function loadTitle(folder, { data, scenes = false, fixed = false } = {}) {\n folder = new URL(folder);\n const title = { ...(await defaultOf(new URL('title.js', folder))) };\n // the modules a title has of its own, as its title.js names them (problems.js, paint.js), and its view's own\n // drawing (view.js), where it says it has one\n for (const name of title.modules ?? []) title[name] = await defaultOf(new URL(name + '.js', folder));\n if (title.view) title.viewSteps = await defaultOf(new URL('view.js', folder));\n if (!ENGINES[title.engine]) {\n title.own = await import(new URL(title.engine + '.js', folder).href);\n return { title, scripts: {}, disk: null, folder };\n }\n const scripts = Object.fromEntries(await Promise.all(title.scripts.map(async n =>\n [n, scenes ? await read(new URL(n + '.scene', folder), 'text') : await defaultOf(new URL(`compiled/${(fixed && title.fixed?.[n]) || n}.js`, folder))])));\n const disk = await read(new URL(data), 'json');\n return { title, scripts, disk, folder };\n}\n\nexport function makeEngine(title, scripts) {\n // (a ProDOS title's memory starts with what ProDOS leaves, as the original's does)\n const memory = { ...(title.disk?.kind === 'prodos' ? started(title.disk) : {}), ...title.memory };\n const engine = new Engine({ routines: ENGINES[title.engine](title), scripts, start: title.start, label: title.startLabel, memory });\n engine.title = title;\n return engine;\n}\n", "// The routines of a vector engine title, for the remake engine, as its title.js `map` names them: what each step\n// of a scene does. Each gives the event the original's routine gives\n// (events.js), does what the original did to the registers, the flags and the memory that the\n// scenes read, and paints the original's screen for the scenes that read it back. The rules for\n// the keys, the random numbers and the waits are the original's, from PART0 (docs in\n// @moonbase-machines/vector's README).\nimport { describe, result, TAKES, nothing } from './events.js';\nimport { helpers } from './problems.js';\nimport { tables, carry } from '@moonbase-machines/vector/objects.js';\nimport { pictures } from '@moonbase-machines/vector/pictures.js';\nimport { width, useFont } from '@moonbase-machines/vector/font.js';\nimport { Raster } from './raster.js';\nimport { Files } from '@moonbase-machines/apple2e/mli.js';\nimport { layout, resolve, PANELS, textLayout, textPen, textPage } from './layout.js';\n\n// A vector title's map (its title.js `map`): `volume`, its disk's volume; `objects`, the routine that sets the table\n// of objects; `seed` ({ at, used }), where the random routine keeps its seed and the byte that is $FF until its first\n// call; `menu`, the Main Menu, which the key reader jumps to on control-E; `visit` ({ at, kept, back }), a way to its\n// menus instead, the screen kept and put back (Nature Park's); `keyPanel`, the arrows' panel; `vars`, where the\n// engine keeps what the remake reads (`zero`, how far up the zero page its routines' inputs are; the screen's\n// layout; the difficulty; practice; repeats; the sound flag, on with its `soundOn` bit); `loads`, where its code\n// files load when its catalog has lost it; `askClearsCarry`, `countInX`; `modern`, characters a modern font draws\n// otherwise; `routines`, its engine's routines by address, each the name of its step; `problems`, each problem's own\n// routines that draw, by the problem's number.\n\n// A game's code files, PART0, the parts and the problems, each with the address it loads at: the map's `loads`, by\n// the file's name or its name without the digit, or else the catalog's\nexport function codeFiles(map, volume) {\n const loads = map?.loads ?? {};\n return Object.entries(volume).filter(([n]) => /^(PART|PROB)\\d$/.test(n))\n .map(([name, f]) => ({ name, bytes: Uint8Array.from(atob(f.data), c => c.charCodeAt(0)), origin: loads[name] ?? loads[name.slice(0, -1)] ?? f.aux }));\n}\n\nconst KEY = { escape: 27, space: 32, return: 13, delete: 127, left: 8, right: 21, down: 10, up: 11, menu: 5 };\n\n// the inputs of a step: numbers, a register's name, or an address for the table of objects\nfunction inputs(e, name, args) {\n const takes = TAKES[name] || '', fixed = [];\n let k = 0;\n if (name === 'panel') fixed.push(args[k++]);\n const regs = { a: e.a, x: e.x, y: e.y };\n if (name === 'objects' && args[0]?.startsWith?.('$')) { const t = parseInt(args[k++].slice(1), 16); regs.x = t & 0xff; regs.y = t >> 8; }\n else for (const r of takes) {\n const v = args[k++];\n if (v === undefined || v === r) continue;\n regs[r] = typeof v === 'object' ? v.string.charCodeAt(0) | 0x80 : v.startsWith('$') ? e.mem[parseInt(v.slice(1), 16)] : +v;\n }\n e.a = regs.a & 0xff; e.x = regs.x & 0xff; e.y = regs.y & 0xff;\n return { fixed, rest: args.slice(k) };\n}\n\n// A step that takes a key: its event once, then it waits until a key comes. Control-E, at any\n// key the original read, went to the Main Menu and dropped everything called.\nfunction waiting(e, step, name, fixed, words, take) {\n if (e.waitingOn !== step) { e.emit(describe(name, fixed, e, words)); e.waitingOn = step; e.asked = null; }\n for (;;) {\n const k = e.key();\n if (k === undefined) return 'wait';\n if (k === KEY.menu && e.title.menu) e.leave(...e.title.menu);\n if (e.title.visit?.[k]) { e.visit(k); return 'wait'; }\n if (take(k)) { e.waitingOn = null; return; }\n }\n}\n\n// $6415 calls the problem's own routines as a choice is made and taken back ($F729 and $F74B,\n// then $F776 and $F6CE, in PROB2): drawing that happens inside the ask. The problem gives them as\n// generators in e.askHooks, which run to their end here, inside, so they are drawn and no step.\nfunction quietly(e, run) {\n if (!run) return;\n e.inside++;\n try { for (let r = run.next(); !r.done; r = run.next()) if (r.value === 'wait') throw new Error('a choice drawn inside the ask cannot wait'); }\n finally { e.inside--; }\n}\n\n// The disk's objects, by the address of their table, for the carry the object routine leaves.\n// `title.disk` is the title's disk from its game's data.\nfunction objectsOf(title) {\n if (title.objectTables || !title.disk) return title.objectTables;\n const files = codeFiles(title.map, Object.values(title.disk.volumes)[0]);\n return title.objectTables = new Map(tables(files, title.map.objects).map(t => [t.address, t.objects]));\n}\n\n// The disk's pictures, by name, for the screen model\nfunction picturesOf(title) {\n if (title.pictureShapes || !title.disk) return title.pictureShapes;\n const volume = Object.values(title.disk.volumes)[0], map = new Map();\n for (const [name, f] of Object.entries(volume)) if (/^PICS\\d$/.test(name)) for (const p of pictures(Uint8Array.from(atob(f.data), c => c.charCodeAt(0)))) map.set(p.name, p.shapes);\n return title.pictureShapes = map;\n}\n\n// a picture's shapes by its name, as the disk has them, for a problem that works with them\nexport const pictureShapes = (title, name) => picturesOf(title)?.get(name.toUpperCase().replace(/_/g, ' '));\n\nexport function vectorRoutines(title) {\n // where this engine keeps its variables, and its routines' inputs in the zero page\n const V = title.map.vars, Z = z => V.zero + z;\n useFont(title.font);\n // what an object's routine leaves: the carry, and in the row its rows were counted in (zero\n // page $02 from the engine's), the row past the object's bottom, which a span after it may take\n const objectCarry = e => {\n if (e.a < 2) return; // putting ground back ends another way; no scene is known to use its carry\n const o = objectsOf(title)?.get(e.objectTable)?.find(o => o.number === e.a);\n if (o) { e.c = carry(o, e.x); e.mem[Z(0x02)] = (e.y + o.height) & 0xff; }\n };\n // The original's screen, dot for dot (raster.js), which each step paints as the original's\n // routine painted, for read-dot; and the text state that lasts from text to text.\n const raster = title.raster ??= new Raster();\n const pen = title.pen ??= { x: 0, y: 0, margin: 0, centre: false, spacing: 1, gap: 0, ink: 15, paper: 10 };\n // The text screen, where the menus are: its characters, its pen, and whether it is showing.\n // `show` ($5BA9) puts the graphics back.\n title.text ??= { showing: false, pen: textPen(), page: textPage() };\n const objectOf = (e, n) => objectsOf(title)?.get(e.objectTable)?.find(o => o.number === n);\n const drawObject = (e, how) => { if (e.a < 2) return raster.restore(); const o = objectOf(e, e.a); if (o) raster.object(o, e.x, e.y, how); };\n // a key cap at the pen, as $76F3 draws it: outlined in color 13 and filled with 1, four dots\n // wider than the glyph or than four, and the glyph in 15 from a dot on, after a spacer that\n // brings a narrow glyph to the cap's right; the pen is left two dots past the text's end\n const cap = ch => {\n const w = width(ch), x = pen.x, spacer = (w < 4 ? 4 - w : 0) + 1;\n raster.rectangle(1, x, pen.y - 2, Math.max(4, w) + 4, 11); raster.outline(13, x, pen.y - 2, Math.max(4, w) + 4, 11); // ($5C83)\n raster.glyph(ch, x + 1 + spacer, pen.y, 15, 1, 1, 8); // its text's lines are 8 high\n pen.x = x + 1 + spacer + w + 1 + 2;\n };\n // the arrows' panel, all four caps (n 0) or the nth, as the ask draws it in its arrow mode\n const keyPanel = n => {\n const k = title.map.keyPanel;\n if (!k) return;\n const c = raster.get(2, 2), { x, y } = pen;\n for (let r = k.top; r < k.top + k.rows; r++) raster.span(c, k.left, k.right, r);\n k.caps.forEach(([cx, cy, ch], i) => { if (!n || n === i + 1) { pen.x = cx; pen.y = cy; cap(String.fromCharCode(ch & 0x7f)); } });\n Object.assign(pen, { x, y });\n };\n // a text on the graphics screen, as $6CE2 paints it\n const print = (e, words) => { for (const line of layout(resolve(words, e.mem), pen)) for (const c of line.chars) raster.glyph(c.ch, c.x, line.top, c.ink ?? line.ink, line.paper, line.tall ? 2 : 1, line.height, pen.spacing); };\n // object n of the table set last, put as `how` ('whole', 'keep' or 'clear')\n const put = (e, n, x, y, how) => { const o = objectOf(e, n); if (o) raster.object(o, x, y, how); };\n // what a title's painters (titles/<title>/paint.js) paint the model with\n title.model = { raster, pen, cap, keyPanel, print, put };\n const simple = (name, draw) => (e, args, step) => {\n let { fixed, rest } = inputs(e, name, args);\n const words = rest.map(r => typeof r === 'object' ? r.string : r).join(' ');\n e.emit(describe(name, fixed, e, rest.length ? words : undefined, z => e.mem[Z(z)]));\n rest = rest.map(r => typeof r === 'object' ? r.string : r);\n draw?.(e, fixed, rest);\n };\n // $641B: A $80 asks for an arrow, $B1 to $B9 a digit from 1, any other a letter from A. The\n // key chosen is then confirmed with return, or taken back with delete or the left arrow.\n // Gives X the key's place from 0, Y twice that, and A the key, its high bit set from 'A' up.\n // Animal Rescue's leaves the carry set for a letter ($6572); Nature Park's clears it ($5A56).\n // Nature Park's $58DA, ask-escape, also takes escape, at either key, and gives A 27 and the\n // carry set, and X the keyboard's byte for it, $9B, as the key read left it ($5A58, a jump into\n // the middle of a BIT that leaves only SEC and RTS).\n const letterCarry = !title.map.askClearsCarry;\n const asking = name => (e, args, step) => {\n if (e.waitingOn !== step) inputs(e, name, args);\n const mode = e.waitingOn === step ? e.askMode : e.a;\n e.askMode = mode;\n const arrows = [KEY.left, KEY.right, KEY.down, KEY.up];\n if (mode === 0x80 && e.waitingOn !== step) keyPanel(0);\n const r = waiting(e, step, name, [], undefined, k => {\n if (name === 'ask-escape' && k === KEY.escape) { e.a = e.flags(27); e.x = 0x9b; e.c = 1; e.asked = null; return true; }\n if (e.asked === null) {\n let place = -1, key = k;\n if (mode === 0x80) { place = arrows.indexOf(k); key = 0xdb + place; if (place >= 0) keyPanel(place + 1); }\n else if (mode >= 0xb1 && mode < 0xba) { if (k >= 0x31 && k <= (mode & 0x7f)) place = k - 0x31; }\n else { key = k & 0x5f; if (key >= 0x41 && key <= (mode & 0x5f & 0x7f)) { place = key - 0x41; key |= 0x80; } }\n if (place >= 0) { e.asked = { place, key }; if (name === 'ask-mode') quietly(e, e.askHooks?.chose?.(place)); }\n return false;\n }\n if (k === KEY.return) { e.x = e.asked.place; e.y = 2 * e.x; e.a = e.asked.key; e.c = letterCarry && e.a >= 0xc1 ? 1 : 0; return true; }\n if (k === KEY.delete || k === KEY.left) { if (name === 'ask-mode') quietly(e, e.askHooks?.undo?.(e.asked.place)); if (mode === 0x80) keyPanel(0); e.asked = null; }\n return false;\n });\n if (r !== 'wait') { e.mem[V.layout] = 0x22; e.emit(result(name, e)); } // $655E: panel 6, which sets $22\n return r;\n };\n\n const routines = {\n // graphics shown: $C01D reads with its high bit set, as a scene may test before it shows them\n show: simple('show', e => { title.text.showing = false; e.mem[0xc01d] = 0x80; }),\n // $573D: the text screen cleared ($7645) and shown ($5BCB), which the view draws and is no step\n 'text-screen': e => {\n Object.assign(title.text, { showing: true, page: textPage() });\n e.mem[0xc01d] = 0;\n e.inside++; e.emit({ step: 'text-screen' }); e.inside--;\n },\n picture: simple('picture', (e, f, [name]) => { const shapes = picturesOf(title)?.get(name.toUpperCase().replace(/_/g, ' ')); if (shapes) raster.picture(shapes); }),\n box: simple('box', e => raster.box(e.mem[V.layout], e.a, e.x, e.y)),\n // a panel sets the layout it clears to, as the original's panels do ($6299 and the rest)\n panel: simple('panel', (e, [n]) => {\n const p = PANELS[n];\n if (!p) return;\n e.mem[V.layout] = p.layout;\n raster.panel(p.rows[0], p.rows[1], p.fill);\n for (const y of p.more ?? []) raster.whiteLines(y);\n Object.assign(pen, { paper: p.paper, ink: p.ink, centre: true, spacing: 1, gap: p.gap, y: p.y });\n }),\n // A code's byte may be written {3:$63D8}, and a character {$4DA5}, for a byte the scene's code\n // writes into its own text before printing it: it is read from memory when the text is shown.\n // On the text screen the text goes into its characters, and the graphics stay as they are.\n text: (e, args) => {\n const words = args[0].string\n .replace(/\\{([0-9a-f]+):([^}]*)\\}/g, (all, code, bytes) => '{' + code + ':' + bytes.split(',').map(b => b.startsWith('$') ? e.mem[parseInt(b.slice(1), 16)].toString(16) : b).join(',') + '}')\n .replace(/\\{\\$([0-9A-Fa-f]{4})\\}/g, (all, at) => String.fromCharCode(e.mem[parseInt(at, 16)] & 0x7f));\n e.emit(describe('text', [], e, words));\n if (title.text.showing) { for (const c of textLayout(resolve(words, e.mem), title.text.pen)) if (title.text.page[c.row]?.[c.col]) title.text.page[c.row][c.col] = { ch: c.ch, inverse: c.inverse }; return; }\n print(e, words);\n },\n objects: simple('objects', e => { e.objectTable = e.x | e.y << 8; }),\n // an object drawn leaves the carry the original's routine left ($6B0F), which a scene may add in\n object: simple('object', e => { drawObject(e, 'whole'); objectCarry(e); }),\n 'object-keep': simple('object-keep', e => { drawObject(e, 'keep'); objectCarry(e); }),\n // $6863: the clear color shows the ground, from a buffer of its own, and no ground is kept\n 'object-mode': simple('object-mode', e => drawObject(e, 'clear')),\n // $76ED sets the pen to X and Y, and goes on into $76F3\n 'key-at': simple('key-at', e => { pen.x = e.x; pen.y = e.y; cap(String.fromCharCode(e.a & 0x7f)); }),\n key: simple('key', e => cap(String.fromCharCode(e.a & 0x7f))),\n 'white-lines': simple('white-lines', e => raster.whiteLines(e.y)),\n 'fill-rows': simple('fill-rows', e => raster.rows(e.a, e.x, e.y, e.c)),\n span: simple('span', e => raster.span(e.a, e.x, e.y, e.mem[Z(0x02)])),\n // a dot, which returns with A its place in its group of seven times 16, and its color ($5B45)\n dot: simple('dot', e => { raster.set(e.x, e.y, e.a); e.a = (e.x % 7) << 4 | e.a & 15; }),\n line: simple('line', e => raster.line(e.mem[Z(0x11)], e.mem[Z(0x00)], e.mem[Z(0x02)], e.mem[Z(0x01)], e.mem[Z(0x03)])),\n // $67B9 fills columns x to x + $0E, both ends, down $0F rows; $677E's four lines go from x to\n // x + $0E and from y to y + $0F\n rectangle: simple('rectangle', e => raster.rectangle(e.a, e.x, e.y, e.mem[Z(0x0e)] + 1, e.mem[Z(0x0f)])),\n 'rectangle-outline': simple('rectangle-outline', e => raster.outline(e.a, e.x, e.y, e.mem[Z(0x0e)] + 1, e.mem[Z(0x0f)] + 1)),\n flash: simple('flash'),\n // $5B4C: the color of a dot of the original's screen, from the screen model\n 'read-dot': (e, args) => { inputs(e, 'read-dot', args); e.emit(describe('read-dot', [], e)); e.a = e.flags(raster.get(e.x, e.y)); e.emit(result('read-dot', e)); },\n 'key-panel': simple('key-panel', e => keyPanel(e.a)), 'keep-span': simple('keep-span'), 'put-span': simple('put-span'), 'invert-span': simple('invert-span'),\n button: simple('button'),\n // a beep of 0 does nothing, and is no step (events.js)\n beep: (e, args) => { inputs(e, 'beep', args); if (!nothing('beep', e.a)) e.emit(describe('beep', [], e)); },\n // a sound's five bytes; a byte may be an address, for one the scene's code writes before it plays\n sound: (e, args) => e.emit(describe('sound', [], e, args.map(b => b.startsWith('$') ? e.mem[parseInt(b.slice(1), 16)].toString(16) : b).join(' '))),\n // PART3's own code, written at $E000, moves the picture a step to the left: drawn, and no step\n scroll: e => { raster.scroll(); e.inside++; e.emit({ step: 'scroll' }); e.inside--; },\n // Nature Park's PART3 at $9796: the dots from `left` to `right` of rows `top` to `bottom` copied\n // `by` rows down, from the bottom row up, so the rows at the top stay to be copied again:\n // drawing, and no step\n 'shift-down': (e, args) => {\n const [left, right, top, bottom, by] = args.map(Number);\n for (let r = bottom; r >= top; r--) for (let x = left; x <= right; x++) raster.set(x, r + by, raster.get(x, r));\n e.inside++; e.emit({ step: 'shift-down', left, right, top, bottom, by }); e.inside--;\n },\n // a part's title marks where the original's loader starts a part\n part: simple('part'),\n\n // the waits, $5C23, $5C08 and $5C20: the space bar, or for the last escape too, which it\n // returns with the carry set\n wait: (e, args, step) => waiting(e, step, 'wait', [], undefined, k => k === KEY.space && (e.a = 32, e.c = 0, true)),\n 'wait-erase': (e, args, step) => waiting(e, step, 'wait-erase', [], undefined, k => k === KEY.space),\n 'wait-or-escape': (e, args, step) => {\n const r = waiting(e, step, 'wait-or-escape', [], undefined, k => (k === KEY.space || k === KEY.escape) && (e.c = k === KEY.escape ? 1 : 0, e.a = k, true));\n if (r !== 'wait') e.emit(result('wait-or-escape', e));\n return r;\n },\n\n // $641B, the ask for a key, above\n ask: asking('ask'),\n // $6415: the same, and the problem draws the choice as it is made, which is left to the view\n 'ask-mode': asking('ask-mode'),\n 'ask-escape': asking('ask-escape'),\n\n // $60C2: the seed times 259, divided by 65535 over n. The seed is at $6131 and $6130 says it is\n // in use; a pilot sets it at the first call, as it does on the original.\n random: (e, args) => {\n const { fixed } = inputs(e, 'random', args);\n e.emit(describe('random', fixed, e));\n const n = e.a;\n const { at, used } = title.map.seed;\n if (e.mem[used] === 0xff && title.seed !== undefined) { e.mem[at] = title.seed & 0xff; e.mem[at + 1] = title.seed >> 8; }\n let seed = e.mem[at] | e.mem[at + 1] << 8;\n seed = (seed * 259) & 0xffff;\n e.mem[at] = seed & 0xff; e.mem[at + 1] = seed >> 8; e.mem[used] = n;\n const q = n ? Math.floor(0xffff / n) : 0xffff;\n e.a = Math.floor(seed / q) & 0xff; e.c = 0;\n e.emit(result('random', e));\n },\n\n multiply: (e, args) => { inputs(e, 'multiply', args); e.emit(describe('multiply', [], e)); const p = e.a * e.x; e.a = p & 0xff; e.x = p >> 8; e.emit(result('multiply', e)); },\n divide: (e, args) => { inputs(e, 'divide', args); e.emit(describe('divide', [], e)); const d = e.x | e.y << 8, n = e.a || 1; e.a = Math.floor(d / n) & 0xff; e.x = d % n; e.emit(result('divide', e)); },\n\n // a problem, written by hand for the remake (its title's problems.js). It runs\n // as its own script or function and returns here; the carry comes back clear, as it does on\n // the original when the problem loaded. Nature Park's ($4DC3) takes the number of times from X\n // for a problem from the Problems menu, in place of the teacher's, until the problem is done.\n problem: (e, args, step) => {\n if (!e.problem) {\n inputs(e, 'problem', args); e.emit(describe('problem', [], e)); e.mem[V.practice] = e.c ? 0x80 : 0;\n e.repeats = e.mem[V.repeats];\n if (title.map.countInX && e.c) e.mem[V.repeats] = e.x;\n const run = title.problems?.[e.a];\n if (!run) throw new Error('problem ' + e.a + ' is not written yet');\n // the problem's file, where the loader puts it, for the tables a problem reads from it\n const file = title.disk && codeFiles(title.map, Object.values(title.disk.volumes)[0]).find(f => f.name === 'PROB' + e.a);\n if (file) e.mem.set(file.bytes, file.origin);\n e.problem = run(helpers(e, routines));\n }\n if (!e.problem.next().done) return 'wait';\n e.problem = null; e.c = 0; e.mem[V.repeats] = e.repeats; e.emit(result('problem', e));\n },\n\n // $5D66 and $5DA9: a key, as the title's own loops read it; A the key, the carry set for escape\n 'read-key': (e, args, step) => {\n if (e.waitingOn !== step) { e.waitingOn = step; e.asked = null; }\n const k = e.key();\n if (k === undefined) return 'wait';\n if (title.visit?.[k]) { e.visit(k); return 'wait'; }\n e.waitingOn = null;\n if (k === KEY.menu && title.menu) e.leave(...title.menu);\n e.a = e.flags(k & 0x7f); e.c = k === KEY.escape ? 1 : 0;\n e.emit(result('read-key', e));\n },\n\n // The loader's splash, before PART0 runs: TITLE, a double hi-res picture, until a key. The\n // original's engine is not in yet, so it is no step; the view draws it.\n splash: (e, args, step) => {\n if (e.waitingOn !== step) { e.inside++; e.emit({ step: 'splash' }); e.inside--; e.waitingOn = step; }\n if (e.key() === undefined) return 'wait';\n e.waitingOn = null;\n },\n // Nature Park's $4C00: both halves of the graphics screen cleared to black, which is no step\n 'clear-screen': e => {\n for (const row of raster.dots) row.fill(0);\n e.inside++; e.emit({ step: 'clear-screen' }); e.inside--;\n },\n\n // A delay the original made by counting X and Y down, given as the milliseconds it took: no\n // step, and nothing changes but the registers, both 0 when the count is done. The page waits.\n pause: (e, [ms]) => { e.x = 0; e.y = 0; e.flags(0); e.inside++; e.emit({ step: 'pause', ms: +ms }); e.inside--; },\n\n // End, on the Main Menu: ProDOS's quit, through $0200, and the title is over\n quit: e => { e.ended = true; },\n\n // a part of the title not written yet: the run stops here and says which\n unwritten: (e, [what]) => { throw new Error('not written yet: ' + (what?.string ?? what)); },\n\n // a jump or a call into PART0's own code, which the title's scripts have: the title's\n // `entries` say where each address is\n 'goto-engine': (e, [at]) => { const to = title.entries?.[at]; if (!to) throw new Error('no script for ' + at); e.enter(...to); },\n 'call-engine': (e, [at]) => { const to = title.entries?.[at]; if (!to) throw new Error('no script for ' + at); e.stack.push({ name: e.name, pc: e.pc }); e.enter(...to); },\n\n // the loader: part A's script, from its start, after the title has shown it\n // (and, with the disk out of its drive, it comes back, as the loader's read does with its error)\n 'load-part': (e) => {\n const volume = Object.keys(title.disk?.volumes ?? {})[0]?.toUpperCase();\n if (title.files?.out?.has(volume)) { e.a = e.flags(0x45); e.c = 1; return; }\n e.stack = []; e.enter('part' + e.a, undefined, true);\n },\n\n // Nature Park's settings written to its own disk through the loader ($08E9): ProDOS's\n // SET_FILE_INFO, answered from the disks as @moonbase-machines/apple2e/mli.js answers the original's call: the\n // write-protect error ($2B) with the tab on, no volume ($45) with the disk out of its drive,\n // and the carry set for either; clear when it goes through\n 'write-settings': e => {\n const files = title.files ??= new Files(title.disk), volume = Object.keys(title.disk.volumes)[0].toUpperCase();\n const err = files.out?.has(volume) ? 0x45 : files.disks[volume] === 'protected' ? 0x2b : 0;\n e.a = e.flags(err); e.c = err ? 1 : 0;\n },\n };\n return routines;\n}\n", "// A problem, rewritten for the remake: a generator function that takes the problem's helpers\n// and yields whenever it waits for a key. Its steps are the same routines the scripts use, so\n// they give the same events; a problem's own drawing routines are steps of their own, named in\n// its title's map (`problems`), which the view draws however it likes.\n//\n// function* (p) { yield* p.call('text', 'Hello'); const { x } = yield* p.call('ask', 202); }\nimport { describe } from './events.js';\n\nexport function helpers(e, routines) {\n const zero = e.title.map.vars.zero;\n // a step: run its routine, and wait for as long as it waits\n function* call(name, ...args) {\n const token = { words: [name] }; // what the view reads to know what the problem waits for\n const words = args.map(a => typeof a === 'string' && name === 'text' ? { string: a } : typeof a === 'number' ? String(a) : a);\n for (;;) {\n const r = routines[name](e, words, token);\n if (r !== 'wait') return { a: e.a, x: e.x, y: e.y, c: e.c };\n yield 'wait';\n }\n }\n // a problem's own drawing routine: its event, and what it leaves for the view\n // and the title's painter for it, if it has one (titles/<title>/paint.js), paints it into the\n // model of the original's screen\n const drawn = (name, a = 0, x, y) => { e.a = a & 0xff; if (x !== undefined) e.x = x & 0xff; if (y !== undefined) e.y = y & 0xff; e.title.paint?.[name]?.(e.title.model, e); e.emit(describe(name, [], e, undefined, z => e.mem[z + zero], a => e.mem[a])); };\n // A key, for a problem that reads keys itself: it waits, and the view shows what `kind` of wait\n // it is, 'wait' for the space bar's button or 'ask' for the keys e.askMode asks for.\n function* key(kind = 'wait') {\n const token = { words: [kind] };\n for (;;) {\n const k = e.key();\n // control-E: the Main Menu, from the key reader, as at any key the original read\n if (k === 5 && e.title?.menu) e.leave(...e.title.menu);\n // control-E or control-T in Nature Park: its menus, and back to waiting here\n if (e.title?.visit?.[k]) { e.visit(k); e.waitingOn = token; yield 'wait'; continue; }\n if (k !== undefined) { e.waitingOn = null; return k; }\n e.waitingOn = token;\n yield 'wait';\n }\n }\n // steps done inside a routine of the problem's own: drawn, and no steps of the transcript\n function* inside(run) { e.inside++; try { return yield* run; } finally { e.inside--; } }\n return { e, mem: e.mem, call, drawn, key, inside };\n}\n", "import { objects as m } from '@moonbase-machines/vector';\nexport const { carry, decode, put, tables } = m;", "// The original's screen, dot for dot, for the scenes that read it back. PROB6 steers Helen's car by\n// the colors of the dots ahead of it, so the remake must know what the original's screen shows\n// there, whatever the view draws. The raster is 192 rows of 140 colors, painted by each step as the\n// original's routines paint the double hi-res screen, and read by read-dot. The view never sees it.\nimport { screen, draw, line as lineDots } from '@moonbase-machines/vector/draw.js';\nimport { put } from '@moonbase-machines/vector/objects.js';\nimport { width, dots } from '@moonbase-machines/vector/font.js';\nimport { LAYOUT } from './layout.js';\n\nexport class Raster {\n constructor() { this.dots = screen(15); this.kept = null; } // $5BE1 clears the screen white\n // Nature Park's menus over a game: the screen kept and cleared to black ($4C5D), and put back\n // as it was ($4CFB), with what an object kept under it\n keepScreen() { this.screenKept = { dots: this.dots, kept: this.kept }; this.dots = screen(0); }\n putScreen() { if (this.screenKept) ({ dots: this.dots, kept: this.kept } = this.screenKept); this.screenKept = null; }\n // Animal Rescue's PART3 at $E000: rows 19 to 115 moved two bytes to the left in each half of the\n // screen. A row is 560 bits, aux and main bytes in turn, seven bits a byte and four a dot; bytes\n // 2 to 73 of the row, bits 14 to 517, take the bits 28 on, so the dots move seven, the ends half\n // way through a dot, and bytes 74 to 79 stay\n scroll() {\n for (let y = 19; y <= 115; y++) {\n const row = this.dots[y], bits = [];\n for (const c of row) bits.push(c >> 3 & 1, c >> 2 & 1, c >> 1 & 1, c & 1);\n for (let b = 14; b < 518; b++) bits[b] = bits[b + 28];\n for (let x = 0; x < 140; x++) row[x] = bits[4 * x] << 3 | bits[4 * x + 1] << 2 | bits[4 * x + 2] << 1 | bits[4 * x + 3];\n }\n }\n set(x, y, c) { if (x >= 0 && x < 140 && y >= 0 && y < 192) this.dots[y][x] = c & 15; }\n get(x, y) { return x >= 0 && x < 140 && y >= 0 && y < 192 ? this.dots[y][x] : 0; }\n // a run of a row, both ends drawn ($7947)\n span(c, left, right, y) { for (let x = left; x <= right; x++) this.set(x, y, c); }\n // rows filled across the screen, with white edge columns when `edges` ($5F4B)\n rows(c, count, first, edges) {\n for (let y = first; y < first + count; y++) { this.span(c, 0, 139, y); if (edges) { this.set(0, y, 15); this.set(139, y, 15); } }\n }\n whiteLines(y) { this.span(15, 0, 139, y); this.span(15, 0, 139, y + 1); }\n // $65D2: the window outlined in black and filled, and the two boxes, each two white rows and its\n // rows in its color with white edges; $80 leaves a part as it is\n box(layout, window, one, two) {\n const [bottom, top1, top2] = LAYOUT[layout] ?? LAYOUT[0x32];\n if (window !== 0x80) {\n this.span(0, 1, 138, 1); this.span(0, 1, 138, bottom - 1);\n for (let y = 2; y < bottom - 1; y++) { this.set(1, y, 0); this.set(138, y, 0); this.span(window, 2, 137, y); }\n }\n if (one !== 0x80) { this.whiteLines(top1); this.rows(one, top2 - top1 - 2, top1 + 2, true); }\n if (two !== 0x80) { this.whiteLines(top2); this.rows(two, 190 - top2 - 2, top2 + 2, true); }\n }\n // a panel: its box's two white rows and its rows in its color, with white edges\n panel(top, bottom, c) { this.whiteLines(top); this.rows(c, bottom - top - 1, top + 2, true); }\n picture(shapes) { draw(shapes, this.dots); }\n rectangle(c, x, y, w, h) { for (let r = y; r < y + h; r++) this.span(c, x, x + w - 1, r); }\n outline(c, x, y, w, h) { this.span(c, x, x + w - 1, y); this.span(c, x, x + w - 1, y + h - 1); for (let r = y; r < y + h; r++) { this.set(x, r, c); this.set(x + w - 1, r, c); } }\n line(c, x0, y0, x1, y1) { for (const [x, y] of lineDots(x0, y0, x1, y1)) this.set(x, y, c); }\n // An object: 'keep' keeps the ground under it, so that object 0 puts it back, and its clear\n // color shows the ground ($686F); 'clear' shows the ground and keeps none ($6863); 'whole' puts\n // it down whole, its clear color and all ($686D)\n object(o, x, y, how) {\n if (how === 'keep') this.kept = { x, y, rows: o.rows.map((row, dy) => row.map((_, dx) => this.get(x + dx, y + dy))) };\n put(this.dots, o, x, y, how === 'whole');\n }\n restore() { const k = this.kept; if (!k) return; k.rows.forEach((row, dy) => row.forEach((c, dx) => this.set(k.x + dx, k.y + dy, c))); }\n // a glyph's cell painted, ink on its dots and paper on the rest, `h` rows a glyph row, as many\n // glyph rows as the line is high; the cell takes in the spacing after the glyph, `space`\n glyph(ch, x, y, ink, paper, h = 1, height = 9, space = 0) {\n const w = width(ch);\n // a spacer, a code below $20, is that many dots of the paper\n if (ch.charCodeAt(0) < 0x20) { for (let gy = 0; gy < Math.min(9, height); gy++) for (let gx = 0; gx < w; gx++) for (let k = 0; k < h; k++) this.set(x + gx, y + gy * h + k, paper); return w; }\n const on = new Set(dots(ch).map(([gx, gy]) => gx + ',' + gy));\n for (let gy = 0; gy < Math.min(9, height); gy++) for (let gx = 0; gx < w + space; gx++) for (let k = 0; k < h; k++) this.set(x + gx, y + gy * h + k, on.has(gx + ',' + gy) ? ink : paper);\n return w;\n }\n}\n", "import { draw as m } from '@moonbase-machines/vector';\nexport const { crossings, draw, fill, inside, line, outline, screen, spans, under } = m;", "// The remake in the browser: one player for every title. The page gives it the title's folder and its game's data;\n// the player makes its part of the page, the stage the game is drawn on and the options line under it with the\n// game's status, loads the title (load.js), puts its stylesheet in the page where it has one, and hands the game to\n// its engine: the remake's own for a title of scenes, 'card' or 'vector' (scenes.js), or the title's own, a module in\n// its folder (its title.js `engine`), given the same. A failure is said in the status line.\n//\n// await play({ title, data, root, disk, preview, words, watch, claim, pace, route, mini, roms })\n// title the title's folder, an absolute URL\n// data its game's data, an absolute URL (for a title of its own engine, the folder its data is in)\n// root the page's section the player is made in\n// disk the title's player's disk (disk/disk.js), opened before the player starts\n// preview the preview's build: what only it has may be used\n// words the page's words the player shows: { printer: { line, print, tear } }\n// watch called with the game, { engine, press, quick }, for a page that follows it\n// claim k => true to take a key of the player's before the game does\n// pace how much of the original's waits: 1 all (the default), 0 none, between a part of each; read at\n// each wait\n// and what only a workshop has, given by its pages, never looked for here:\n// route a route to play first, { route, keys }: its keys, and the pilots' key handling (expand, give,\n// petscii, pollsAt)\n// mini a mini view for a title with an `inset`, (at, { memory }) => { mode(m) }\n// roms the makers' ROMs this machine has: { chargen } for a Commodore 64 title's characters\n//\n// What the engine is handed, its own engine's or the remake's, `game`: { title, scripts, disk, folder, stage,\n// options, status, fail, kept, preview, words, ...the page's options }; `stage` is its to draw in, `options` the\n// line its own controls go on, before the status.\nimport { loadTitle } from './load.js';\nimport { play as scenes } from './scenes.js';\n\nexport async function play(options) {\n const { title: folder, data, root, disk: kept, preview = false, words } = options;\n root.classList.add('remake');\n root.innerHTML = '<div class=\"stage\"></div><p class=\"options\"><span id=\"status\">Loading.</span></p>';\n const stage = root.querySelector('.stage'), line = root.querySelector('.options'), status = root.querySelector('#status');\n const fail = err => { status.textContent = 'The remake stopped: ' + err.message; status.className = 'error'; console.error(err); };\n try {\n // ?fixed: the title with its bugs fixed, for one that has such a version (its title.js `fixed`)\n const fixed = new URLSearchParams(location.search).has('fixed');\n const { title, scripts, disk } = await loadTitle(folder, { data, fixed });\n title.disk = disk;\n // the title's own styles, where it has them (its title.js `style`, a file in its folder), in place before it\n // draws by them\n if (title.style && !document.querySelector(`link[data-title=\"${title.slug}\"]`)) {\n const link = Object.assign(document.createElement('link'), { rel: 'stylesheet', href: new URL(title.style, folder).href });\n link.dataset.title = title.slug; document.head.append(link);\n await new Promise(done => { link.onload = link.onerror = done; });\n }\n const game = { ...options, title, scripts, disk, folder, data, stage, options: line, status, fail, kept, preview, words, fixed };\n await (title.own ?? { play: scenes }).play(game);\n } catch (err) { fail(err); }\n}\n", "// A title of scenes played, the remake's own engine (main.js hands it the game): its scripts on the engine, its events\n// drawn by the view, on the stage; its controls on the options line, the sound, the old style text, a C64 title's\n// printer, the bugs fixed where the title has a version so, the mini view where the page gives one. A run's events\n// are drawn one after another, with a moment for each sound and flash, so that what the original took time over takes\n// time here too.\nimport { Printer, paper } from '@moonbase-machines/c64/printer.js';\nimport { makeEngine } from './load.js';\nimport { Speaker } from '../audio.js';\nimport { SID } from '@moonbase-machines/c64/sid.js';\nimport { matrixOf } from '@moonbase-machines/c64/kernal.js';\nimport { standIn } from '@moonbase-machines/c64/rom.js';\nimport { withSaves, keepSaves } from '@moonbase-machines/apple2e/saves.js';\nimport { Drive } from '@moonbase-machines/c64/drive.js';\nimport { keepDrive } from '@moonbase-machines/c64/saves.js';\nimport { paperBox, phoneKeys, KEYS_MARKUP } from '../parts.js';\nimport { View } from './view.js';\nimport { CardView } from './card-view.js';\nimport { C64View } from './c64-view.js';\n\nexport async function play(game) {\n const { title, scripts, disk, root, stage, status, fail, kept, words, fixed } = game;\n root.classList.add('game'); // (the screen of a machine: the stage the game's own shape, player.css)\n stage.innerHTML = `<svg id=\"screen\" preserveAspectRatio=\"xMidYMid meet\" tabindex=\"0\" aria-label=\"The game's screen\"></svg>`;\n status.insertAdjacentHTML('afterend', `${KEYS_MARKUP}<label><input type=\"checkbox\" id=\"sound\"> Sound</label><label><input type=\"checkbox\" id=\"old-style\"> Old style text</label><label hidden><input type=\"checkbox\" id=\"printer\" checked> Printer</label><label hidden title=\"The game with its bugs fixed: it starts again\"><input type=\"checkbox\" id=\"fixed\"> Bugs fixed</label><label hidden>Mini view <select id=\"mini\"><option value=\"\">Off</option><option value=\"live\">Live</option><option value=\"pictures\">Pictures</option></select></label>`);\n root.append(paperBox(words.printer));\n const $ = id => root.querySelector('#' + id);\n const svg = $('screen'), soundBox = $('sound');\n phoneKeys(root, stage);\n\ntry {\n // the choice of the fixed version, where there is one: the page again, with ?fixed or without\n const fixedBox = $('fixed');\n if (fixedBox && title.fixed) {\n fixedBox.checked = fixed; fixedBox.parentElement.hidden = false;\n fixedBox.addEventListener('change', () => { const u = new URL(location.href); if (fixedBox.checked) u.searchParams.set('fixed', ''); else u.searchParams.delete('fixed'); location.href = u.href.replace('fixed=&', 'fixed&').replace(/fixed=$/, 'fixed'); });\n }\n // its view's own drawing, for a title that has one (its title.js `view`, load.js)\n const extra = title.viewSteps ?? {};\n // a Commodore 64's character ROM, for its view: Commodore's where the page gives them (`roms`), else moonbase's own\n const chargen = disk.kind === 'c64' ? game.roms?.chargen ?? standIn().chargen : null;\n\n // A printer on device 4, for a Commodore 64 title (@moonbase-machines/c64/printer.js): on unless its box is off,\n // what it prints drawn below the screen as a sheet of paper, until it is torn off\n if (disk.kind === 'c64') {\n const box = $('printer'), sheet = $('paper'), shown = $('paper-box');\n try { box.checked = localStorage.getItem('remake-printer') !== '0'; } catch {}\n box.parentElement.hidden = false;\n const printer = title.printer = new Printer({ on: box.checked });\n box.addEventListener('change', () => { printer.on = box.checked; try { localStorage.setItem('remake-printer', box.checked ? '1' : '0'); } catch {} });\n printer.changed = () => { shown.hidden = !printer.lines.length; if (printer.lines.length) paper(sheet, printer, chargen); };\n $('tear').addEventListener('click', () => printer.tear());\n $('print-paper').addEventListener('click', () => window.print()); // (the sheet alone: its print style)\n }\n // what the game saves, on the player's disk: an Apple title's data disk (@moonbase-machines/apple2e/saves.js), a\n // Commodore 64 title's drive (@moonbase-machines/c64/saves.js, the drive card.js puts on the bus)\n title.disk = withSaves(disk, kept);\n if (disk.kind === 'c64') keepDrive(title.drive = new Drive(Uint8Array.from(atob(disk.image), ch => ch.charCodeAt(0))), kept);\n const engine = makeEngine(title, scripts);\n if (title.files) keepSaves(disk, title.files, kept);\n const queue = [];\n // The view, and every event it has drawn, so that it can be drawn again from the start when\n // the old style text is turned on or off. The choice is kept in this browser.\n const oldStyleBox = $('old-style'), history = [];\n const remember = { get() { try { return localStorage.getItem('remake-old-style') === '1'; } catch { return false; } }, set(v) { try { localStorage.setItem('remake-old-style', v ? '1' : '0'); } catch {} } };\n oldStyleBox.checked = remember.get() || new URLSearchParams(location.search).has('old-style'); // ?old-style, for a screenshot\n let onView = null; // (the mini view's, given each view made)\n const makeView = () => { svg.replaceChildren(); const v = disk.kind === 'c64' ? new C64View(svg, { engine, chargen }) : title.engine === 'card' ? new CardView(svg, { engine, inset: game.mini ? title.inset : null }) : new View(svg, { disk, volume: Object.keys(disk.volumes)[0], engine, extra }); v.oldStyle = oldStyleBox.checked; onView?.(v); return v; };\n let view = makeView();\n engine.on(e => queue.push(view.snapshot({ ...e })));\n // The mini view, where the page gives one (`mini`) and the title has a place for it (its title.js `inset`): Off,\n // Live or Pictures, the choice kept in this browser; shown in the band at the top of the screen while the band is\n // there. A picture only: the game's screen otherwise as it is\n const miniBox = $('mini');\n if (title.inset && game.mini) {\n miniBox.parentElement.hidden = false;\n try { miniBox.value = localStorage.getItem('remake-mini') ?? ''; } catch {}\n const { top, bottom, view: [left, right] } = title.inset, at = document.createElement('div');\n at.className = 'mini'; at.hidden = true;\n Object.assign(at.style, { left: `${left / 5.6}%`, top: `${top / 3.84}%`, width: `${(right - left) / 5.6}%`, height: `${(bottom - top + 1) / 3.84}%` });\n svg.parentElement.append(at);\n const mini = await game.mini(at, { memory: () => engine.mem });\n // (each view's painting followed by the mini view shown or not, as the band is there or not)\n onView = v => { v.insetOn = !!miniBox.value; const prompts = v.prompts.bind(v); v.prompts = () => { prompts(); at.hidden = !(miniBox.value && v.banded); }; };\n onView(view);\n const show = () => { view.insetOn = !!miniBox.value; mini.mode(miniBox.value); view.prompts(); };\n miniBox.addEventListener('change', () => { try { localStorage.setItem('remake-mini', miniBox.value); } catch {} show(); });\n show();\n }\n oldStyleBox.addEventListener('change', () => {\n remember.set(oldStyleBox.checked);\n view = makeView();\n for (const e of history) view.apply(e);\n view.prompts();\n });\n\n // the sound: the original's are off until the teacher turns them on, at the engine's sound flag.\n // A title that keeps the original's time (a card title's, Engine.time) clicks the speaker as\n // the original did, and the clicks are played as the emulator plays them (audio.js), the\n // box the sound's on and off.\n const speaker = engine.timed ? new Speaker() : null;\n if (speaker) soundBox.checked = true;\n const hear = () => { if (disk.kind !== 'c64') speaker?.feed(soundBox.checked ? engine.clicks : [], engine.cycles); engine.clicks.length = 0; };\n const V = title.map?.vars ?? { sound: 0, soundOn: 0 };\n let audio = null;\n const tone = (from, to, ms) => {\n if (!(engine.mem[V.sound] & V.soundOn)) return;\n audio ??= new AudioContext();\n const o = audio.createOscillator(), g = audio.createGain(), t = audio.currentTime;\n o.type = 'square'; o.frequency.setValueAtTime(from, t); o.frequency.linearRampToValueAtTime(to, t + ms / 1000);\n g.gain.setValueAtTime(0.06, t); g.gain.linearRampToValueAtTime(0, t + ms / 1000);\n o.connect(g).connect(audio.destination); o.start(t); o.stop(t + ms / 1000);\n };\n const pitch = p => 16000 / (p + 8);\n soundBox.addEventListener('change', () => { if (!speaker) engine.mem[V.sound] = soundBox.checked ? V.soundOn : 0; });\n\n // how long each step takes to be seen or heard, in milliseconds\n const PACE = { sound: 220, beep: 60, 'flash-box': 60, flash: 250, object: 30, 'object-keep': 30 };\n const pace = () => game.pace ?? 1; // (the original's waits, a part of each: 1 all, 0 none; read at each wait)\n let drawing = false;\n const sleep = ms => new Promise(r => setTimeout(r, ms));\n async function runs() {\n if (drawing) return;\n drawing = true;\n try {\n for (;;) {\n const r = engine.run();\n hear();\n // the original took time here, a disk's read or a wait it counted out: the screen as it\n // is, for that long (card.js)\n if (r === 'pace') {\n for (const e of queue.splice(0)) { history.push(e); view.apply(e); }\n view.prompts(); if (!quick && pace()) await sleep(engine.delay * pace()); engine.delay = 0;\n continue;\n }\n engine.delay = 0;\n while (queue.length) {\n const e = queue.shift();\n history.push(e);\n view.apply(e);\n if (quick) continue; // (at full speed: no sound, no wait)\n if (e.step === 'sound') { const [end, start] = e.words.split(' ').map(h => parseInt(h, 16)); tone(pitch(start), pitch(end), 180); }\n if (e.step === 'beep') tone(pitch(e.a & 31) * 2, pitch(e.a & 31) * 2, 50);\n if (!pace()) continue; // (none of the original's waits: its sounds still)\n if (PACE[e.step]) await sleep(PACE[e.step] * pace());\n if (e.step === 'pause') await sleep(e.ms * pace()); // a delay the original counted out\n }\n view.prompts();\n status.textContent = r === 'end' ? 'The end.' : 'Waiting for a key.';\n if (!engine.keys.length || r === 'end') break;\n }\n } catch (err) { fail(err); }\n drawing = false;\n }\n\n // keys as the Apple's keyboard gave them\n // (a Commodore 64's in PETSCII: its cursor keys, DEL and RUN/STOP, and its letters capitals)\n const KEYS = disk.kind === 'c64'\n ? { ArrowLeft: 157, ArrowRight: 29, ArrowDown: 17, ArrowUp: 145, Enter: 13, Backspace: 20, Delete: 20, Escape: 3, ' ': 32 }\n : { ArrowLeft: 8, ArrowRight: 21, ArrowDown: 10, ArrowUp: 11, Enter: 13, Backspace: 127, Delete: 127, Escape: 27, ' ': 32 };\n let quick = false;\n const press = k => { engine.press(k); audio?.resume(); speaker?.start(); if (disk.kind !== 'c64') runs(); };\n // (a page that follows the game, the island's, given it: the engine, its memory, a key pressed as the\n // player presses one, and `quick(on)`, the game at full speed, none of its waits, to jump ahead in it)\n game.watch?.({ engine, press, quick: on => { quick = on; } });\n // A game that goes on without waiting for keys, as Nature Park's truck: each turn of its loop is\n // a step `tick`, which takes a key or none. A turn passes every 100 milliseconds, as the\n // original's took, with the key pressed since the last or still held, as the Apple's keyboard\n // told the game a key was down.\n const ticking = () => engine.waitingOn?.words?.[0] === 'tick';\n let held = null, tapped = null;\n setInterval(() => {\n if (!ticking() || drawing || engine.keys.length) return;\n const k = tapped ?? held ?? -1; tapped = null;\n press(k);\n }, 100);\n window.addEventListener('keydown', e => {\n if (e.metaKey || e.altKey) return;\n const k = e.ctrlKey ? (/^[a-z]$/i.test(e.key) ? e.key.toUpperCase().charCodeAt(0) & 0x1f : undefined) : KEYS[e.key] ?? (e.key.length === 1 ? (disk.kind === 'c64' ? e.key.toUpperCase() : e.key).charCodeAt(0) : undefined);\n if (k === undefined) return;\n e.preventDefault();\n if (ticking()) { tapped = held = k; return; }\n // a Commodore 64's key held down in its keyboard's matrix, which its KERNAL scans and repeats\n // as long as it is held, as the original's did (@moonbase-machines/c64/kernal.js); a character typed only\n // with shift into the buffer\n const m = disk.kind === 'c64' && !e.ctrlKey && matrixOf(k);\n if (m) { if (!e.repeat) { engine.clock.held = { ...m, key: e.key }; audio?.resume(); speaker?.start(); } return; }\n if (!e.repeat && !game.claim?.(k)) press(k); // (the player's key offered to the page first: `claim`, main.js)\n });\n window.addEventListener('keyup', e => {\n held = null;\n const h = engine.clock?.held;\n if (h?.key === e.key) { if (h.seen) engine.clock.held = null; else h.up = true; }\n });\n svg.addEventListener('click', e => { const key = e.target.closest('.key')?.dataset.key; if (key) press(+key); });\n svg.focus();\n // A Commodore 64 title runs on the clock, as the original did, waiting for a key or not: a\n // sixtieth of a second of the original's cycles at a time (the engine's run stops at each 16 ms of\n // them), its raster and its interrupt at the time they come (card.js), and the screen\n // painted after each. And the SID, its writes played a sixtieth of a second at a time, as the\n // emulator plays a frame's (original.js).\n if (disk.kind === 'c64') {\n // a route the page gives (`route`, a workshop's pilots' route) played first as the pilots play it, each key when\n // the game waits for one, off the clock, so that it goes where it went on both sides; then the game goes on as\n // usual\n if (game.route) {\n const { route, name: routeName, keys: { expand, give, petscii, pollsAt } } = game.route;\n title.seed = route.seed; // (RND's numbers from the route's seed, as the pilots have them)\n if (route.printer && title.printer) { title.printer.on = true; $('printer').checked = true; }\n status.textContent = 'Playing the route ' + routeName + '.';\n // (a key behind the one pressed goes into the KERNAL's buffer, as the pilots hold a key)\n const side = { press: k => engine.press(k), also: k => { const m = engine.mem, put = v => { if (m[0xc6] < 10) { m[0x277 + m[0xc6]] = v; m[0xc6]++; } }; if (engine.keys.length) put(engine.keys.shift()); put(k); } };\n const go = () => { let r; do { engine.delay = 0; r = engine.run(); } while (r === 'pace'); queue.length = 0; };\n go();\n for (const [i, [k]] of expand(route.keys).entries()) { give(side, k, petscii); engine.polls = pollsAt(route, i + 1) ?? undefined; go(); }\n engine.polls = undefined; view.prompts();\n }\n engine.sid = []; engine.clock = { irq: 0, ahead: [], since: 0 };\n let sid = null, from = null, sent = 0, stopped = false;\n status.textContent = 'Playing.';\n setInterval(() => {\n engine.delay -= 1000 / 60; // a load's time, or the last run's\n if (!stopped && !engine.ended && engine.delay < 16) {\n engine.delay = Math.max(0, engine.delay);\n // a key of ?keys when the game is waiting for one, two seconds at least after the last, as\n // a player would press them (a wait the game counts out goes on by itself on the clock)\n if (engine.clock.ahead.length && engine.idle > (engine.routines.polls ?? 200) && !engine.keys.length && ++engine.clock.since > 120) { engine.press(engine.clock.ahead.shift()); engine.clock.since = 0; }\n try { engine.run(); queue.length = 0; view.prompts(); } catch (err) { stopped = true; fail(err); }\n if (engine.ended) status.textContent = 'The end.';\n }\n if (speaker?.node && soundBox.checked) {\n sid ??= new SID(speaker.rate); from ??= performance.now();\n const n = Math.floor((performance.now() - from) / 1000 * speaker.rate) - sent;\n if (n > 0) { const wave = sid.render(n, engine.sid.map(([, r, v]) => [0, r, v])); sent += n; speaker.node.port.postMessage(wave, [wave.buffer]); }\n }\n engine.sid.length = 0;\n }, 1000 / 60);\n }\n // ?keys=space,space,right,return presses keys at the start, to go straight to a scene\n const start = new URLSearchParams(location.search).get('keys');\n if (start) for (const k of start.split(',')) { const a = { space: 32, return: 13, escape: 27, delete: 127, left: 8, right: 21, down: 10, up: 11, 'control-e': 5, 'control-t': 20, none: -1 }[k] ?? k.charCodeAt(0); if (disk.kind === 'c64') engine.clock.ahead.push({ 8: 157, 21: 29, 10: 17, 11: 145, 127: 20, 27: 3 }[a] ?? a); else engine.press(a); }\n if (disk.kind !== 'c64') runs();\n} catch (err) { fail(err); }\n}\n", "import { rom as m } from '@moonbase-machines/c64';\nexport const { STANDS_IN, install, standIn } = m;", "// The remake's view: it follows the engine's events and draws the screen as SVG, sharper than\n// the original. The screen is the original's, 140 dots across and 192 down, each dot four\n// pixels wide and two high, so the SVG is 560 by 384. Pictures are drawn from their shapes,\n// smooth; objects from their own dots; text in a system font, laid out by the engine's codes.\n//\n// The screen is kept as the original painted it: each thing drawn covers some rows, and a\n// window, a box, a panel or a fill that paints over those rows takes away what was there.\nimport { COLORS, rgb } from '@moonbase-machines/apple2e/colors.js';\nimport { pictures } from '@moonbase-machines/vector/pictures.js';\nimport { tables, put } from '@moonbase-machines/vector/objects.js';\nimport { codeFiles } from './vector.js';\nimport { elements } from '@moonbase-machines/vector/svg.js';\nimport { width, dots } from '@moonbase-machines/vector/font.js';\nimport { layout, resolve, LAYOUT, PANELS, textLayout, textPen, textPage } from './layout.js';\nimport { FONT } from '@moonbase-machines/charset/font.js';\nimport { colors } from '@moonbase-machines/apple2e/screen.js';\n\nconst NS = 'http://www.w3.org/2000/svg';\nconst X = x => x * 4, Y = y => y * 2;\nconst SANS = 'system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif';\nconst MONO = 'ui-monospace, Menlo, Consolas, \"Liberation Mono\", monospace';\n\n// The characters are the title's own. There was no Unicode in 1986: the engine's font has its\n// arrows at $5B to $5E, left, right, down and up, where ASCII has [ \\ ] and ^. The engine's own\n// font draws those characters as they are. A modern font, a system font or one from Bunny Fonts,\n// has no arrow there, so text drawn in one maps them to Unicode's arrows as it is drawn. A title's\n// own glyphs that a modern font lacks are mapped the same way, as its title says (its map's `modern`):\n// Nature Park's underline is a band of checked dots.\nconst ARROWS = ['[', '\\\\', ']', '^'];\nconst MODERN = { '[': '\u2190', '\\\\': '\u2192', ']': '\u2193', '^': '\u2191' };\n\nexport class View {\n // `svg` is the element to draw in; `disk` the title's disk from its game's data; `engine` the\n // running engine; `extra` the title's own drawing for its problems (titles/<title>/view.js)\n constructor(svg, { disk, volume, engine, extra = {}, press }) {\n this.svg = svg; this.engine = engine; this.extra = extra; this.press = press;\n svg.setAttribute('viewBox', '0 0 560 384');\n this.disk = disk.volumes[volume];\n this.pictures = new Map();\n for (const [name, f] of Object.entries(disk.volumes[volume])) if (/^PICS\\d$/.test(name)) for (const p of pictures(Uint8Array.from(atob(f.data), c => c.charCodeAt(0)))) this.pictures.set(p.name, p.shapes);\n const map = engine.title.map;\n this.vars = map.vars;\n // the title's characters a modern font would draw wrongly, and what it draws instead\n const modern = { ...MODERN, ...map.modern };\n for (let d = 0; d < 10; d++) modern[String.fromCharCode(0x80 + d)] = String(d); // the big digits\n const pattern = new RegExp('[' + Object.keys(modern).map(c => '\\\\' + c).join('') + ']', 'g');\n this.modern = s => s.replace(pattern, c => modern[c]);\n this.tables = new Map(tables(codeFiles(map, disk.volumes[volume]), map.objects).map(t => [t.address, t.objects]));\n this.items = []; // what is on the screen: { top, bottom, el }\n this.pen = { x: 0, y: 0, margin: 0, centre: false, spacing: 1, gap: 0, ink: 15, paper: 10 };\n this.window = { color: 0, bottom: 116 };\n this.shapes = []; // the shapes in the window now\n this.spaceBar = null;\n this.layer = this.el('g'); svg.append(this.layer);\n this.textScreen = this.el('g', { display: 'none' }); svg.append(this.textScreen);\n this.prompt = this.el('g'); svg.append(this.prompt);\n this.textPen = textPen(); this.textCells = textPage();\n this.rect(0, 0, 140, 192, 15, this.layer);\n }\n\n el(name, attrs = {}, parent) { const e = document.createElementNS(NS, name); for (const [k, v] of Object.entries(attrs)) e.setAttribute(k, v); parent?.append(e); return e; }\n // a flat rectangle, its edges on whole pixels: where two meet at a fraction of a pixel, the page\n // would otherwise show a hair of what lies under both\n rect(x, y, w, h, color, parent = this.layer) { return this.el('rect', { x: X(x), y: Y(y), width: X(w), height: Y(h), fill: rgb(color), 'shape-rendering': 'crispEdges' }, parent); }\n // something drawn over rows top to bottom: what it covers entirely is gone\n // Something drawn over the rows top to bottom and the columns left to right: what lies wholly\n // inside that, it covers, and is gone.\n add(top, bottom, el, { covers = true, left = 0, right = 139 } = {}) {\n if (covers) this.items = this.items.filter(i => { if (i.top >= top && i.bottom <= bottom && i.left >= left && i.right <= right) { i.el.remove(); return false; } return true; });\n this.items.push({ top, bottom, left, right, el }); this.layer.append(el);\n return el;\n }\n // something taken off the screen, and out of what the screen holds\n remove(el) { el.remove(); this.items = this.items.filter(i => i.el !== el); }\n fill(top, bottom, color, sides = true) {\n const g = this.el('g');\n this.rect(0, top, 140, bottom - top + 1, color, g);\n if (sides) { this.rect(0, top, 1, bottom - top + 1, 15, g); this.rect(139, top, 1, bottom - top + 1, 15, g); }\n this.add(top, bottom, g);\n }\n whiteLines(y) { this.add(y, y + 1, this.rect(0, y, 140, 2, 15, null)); }\n\n // What the view needs from memory as an event happens, since it draws the event later: the\n // layout, the difficulty, and the words code 6 takes from its tables.\n snapshot(e) {\n const mem = this.engine.mem;\n e.layout = mem[this.vars.layout]; e.difficulty = mem[this.vars.difficulty];\n if (e.step === 'text') e.words = resolve(e.words, mem);\n if (e.step === 'span') e.row = mem[this.vars.zero + 0x02];\n return e;\n }\n\n // an event from the engine\n apply(e) {\n this.difficulty = e.difficulty;\n if (this.spaceBar?.erase && !this.waiting()) { this.fill(this.spaceBar.y, this.spaceBar.y + 10, 5); this.spaceBar.el.remove(); this.spaceBar = null; }\n // a step the title draws itself comes first, so that no name of the view's own can take it\n const f = this.extra[e.step] ?? (typeof this[e.step] === 'function' ? this[e.step] : undefined);\n if (f) f.call(this, e);\n }\n waiting() { return this.engine.waitingOn; }\n\n // The text screen ($573D), where the menus are: 40 columns and 24 rows over the whole screen,\n // white on black. `show` ($5BA9) puts the graphics back as they were.\n 'text-screen'() {\n this.textCells = textPage();\n this.textScreen.replaceChildren(); this.rect(0, 0, 140, 192, 0, this.textScreen);\n this.textScreen.setAttribute('display', 'inline'); this.layer.setAttribute('display', 'none');\n }\n show() { this.textScreen.setAttribute('display', 'none'); this.layer.setAttribute('display', 'inline'); }\n // a character of the text screen, 14 pixels by 16, in inverse or not\n textCell(row, col, ch, inverse) {\n const old = this.textCells[row][col];\n old.el?.remove();\n const g = this.el('g', { 'data-cell': row * 40 + col }, this.textScreen), x = col * 14, y = row * 16, ink = inverse ? '#000' : '#fff';\n if (inverse) this.el('rect', { x, y, width: 14, height: 16, fill: '#fff', 'shape-rendering': 'crispEdges' }, g);\n if (this.oldStyle) {\n // the emulator's own letters, five dots by seven in a cell of seven by eight, two pixels a dot\n const glyph = FONT[ch.charCodeAt(0) - 0x20] ?? FONT[0];\n let d = ''; for (let gx = 0; gx < 5; gx++) for (let gy = 0; gy < 7; gy++) if (glyph[gx] >> gy & 1) d += `M${x + 2 + gx * 2} ${y + gy * 2}h2v2h-2z`;\n if (d) this.el('path', { d, fill: ink }, g);\n } else if (ch !== ' ') {\n const t = this.el('text', { x: x + 7, y: y + 12, fill: ink, 'font-family': MONO, 'font-size': 15, 'text-anchor': 'middle' }, g);\n t.textContent = ch;\n }\n this.textCells[row][col] = { ch, inverse, el: g };\n }\n\n // The loader's splash: TITLE, a double hi-res screen, the auxiliary half then the main, drawn\n // dot for dot as it is\n splash() {\n const f = this.disk.TITLE;\n if (!f) return;\n const bytes = Uint8Array.from(atob(f.data), c => c.charCodeAt(0)), dots = colors(bytes.subarray(0, 0x2000), bytes.subarray(0x2000));\n const rows = []; for (let y = 0; y < 192; y++) rows.push(Array.from(dots.subarray(y * 140, y * 140 + 140)));\n this.clear();\n this.add(0, 191, this.el('image', { href: this.image(rows), x: 0, y: 0, width: 560, height: 384, preserveAspectRatio: 'none', style: 'image-rendering: pixelated' }));\n }\n // Nature Park's $4C00: the screen cleared to black\n 'clear-screen'() { this.clear(); this.add(0, 191, this.rect(0, 0, 140, 192, 0, null)); }\n clear() { for (const i of this.items) i.el.remove(); this.items = []; }\n // Nature Park's menus over a game ($4C5D and $4CFB): the screen kept, cleared to black, and put\n // back as it was when they return\n 'keep-screen'() {\n this.kept = { items: this.items, pen: { ...this.pen }, window: { ...this.window }, shapes: this.shapes, spaceBar: this.spaceBar };\n for (const i of this.items) i.el.remove();\n this.items = []; this.spaceBar = null;\n this['clear-screen']();\n }\n 'put-screen'() {\n if (!this.kept) return;\n this.clear();\n const k = this.kept; this.kept = null;\n for (const i of k.items) this.layer.append(i.el);\n Object.assign(this, { items: k.items, pen: k.pen, window: k.window, shapes: k.shapes, spaceBar: k.spaceBar });\n }\n\n box({ a, x, y, layout }) {\n const [bottom, top1, top2] = LAYOUT[layout] ?? LAYOUT[0x32];\n // all three painted: the whole screen is, and nothing under it is left\n if (a !== 0x80 && x !== 0x80 && y !== 0x80) { for (const i of this.items) i.el.remove(); this.items = []; }\n if (a !== 0x80) {\n const g = this.el('g');\n this.rect(1, 1, 138, bottom - 1, a, g);\n this.el('rect', { x: X(1) + 2, y: Y(1) + 1, width: X(138) - 4, height: Y(bottom - 2) - 2, fill: 'none', stroke: 'black', 'stroke-width': 4 }, g);\n this.add(1, bottom - 1, g, { left: 1, right: 138 });\n this.window = { color: a, bottom }; this.shapes = [];\n }\n if (x !== 0x80) { this.whiteLines(top1); this.fill(top1 + 2, top2 - 1, x); }\n if (y !== 0x80) { this.whiteLines(top2); this.fill(top2 + 2, 189, y); }\n }\n panel({ n: [n] }) {\n const p = PANELS[n];\n if (!p) return;\n // the box's two white rows at its top, then the box under them\n this.whiteLines(p.rows[0]);\n this.fill(p.rows[0] + 2, p.rows[1], p.fill);\n for (const y of p.more ?? []) this.whiteLines(y);\n Object.assign(this.pen, { paper: p.paper, ink: p.ink, centre: true, spacing: 1, gap: p.gap, y: p.y });\n }\n // $E000, which PART3 writes: rows 19 to 115 moved two bytes to the left in each half of the\n // screen, four bytes of it, seven dots. Bytes 3 to 38 of a half go to 1 to 36, the dots from 3.5\n // to 129.5, and bytes 37 and 38 stay, so what is at the right is drawn again as it moves on.\n // The view draws what is in those rows again, cut to them, over them, and moves it on seven dots\n // each time; each time, the strip at the right that stays is drawn again where it came to.\n scroll() {\n const top = 19, bottom = 115, left = 3.5, right = 129.5, s = this.scrolling;\n const clipped = (x0, x1, parent) => {\n const id = 'scroll-' + (this.clipIds = (this.clipIds ?? 0) + 1);\n // from half a pixel above row 19, where a smooth line along the row reaches\n this.el('rect', { x: X(x0), y: Y(top) - 1, width: X(x1 - x0), height: Y(bottom - top + 1) + 1 }, this.el('clipPath', { id }, this.svg));\n return this.el('g', { 'clip-path': `url(#${id})` }, parent);\n };\n const under = (x0, x1) => this.items.filter(i => i !== s?.item && i.top <= bottom && i.bottom >= top && i.left <= x1 && i.right >= x0);\n if (s?.item.el.isConnected && this.items.at(-1) === s.item) {\n // the strip, where it now is in what moves: seven dots on from where it was last time\n const tile = clipped(right, right + 7, this.el('g', { transform: `translate(${X(7 * s.n)} 0)` }, s.moved));\n for (const i of under(right, right + 7)) tile.append(i.el.cloneNode(true));\n s.n++;\n s.moved.setAttribute('transform', `translate(${X(-7 * s.n)} 0)`);\n return;\n }\n const g = clipped(left, right), moved = this.el('g', { transform: `translate(${X(-7)} 0)` }, g);\n // under it all, the window's color, wide enough to lie under the strips drawn as it moves on\n this.rect(left, top, 140 * 8, bottom - top + 1, this.window.color, moved);\n for (const i of under(left, 139)) moved.append(i.el.cloneNode(true));\n this.add(top, bottom, g, { left: 4, right: 129 });\n this.scrolling = { item: this.items.at(-1), moved, n: 1 };\n }\n // Nature Park's PART3 at $9796: dots `left` to `right` of rows `top` to `bottom` copied `by`\n // rows down. As the scroll, the view draws what is in those rows again, cut to where they go and\n // moved down; at each pass after, it moves on, and the rows at the top that stay are drawn again\n // where they come to.\n 'shift-down'({ left, right, top, bottom, by }) {\n const s = this.shifting, cut = (y0, y1, parent) => {\n const id = 'shift-' + (this.clipIds = (this.clipIds ?? 0) + 1);\n this.el('rect', { x: X(left), y: Y(y0), width: X(right - left + 1), height: Y(y1 - y0) }, this.el('clipPath', { id }, this.svg));\n return this.el('g', { 'clip-path': `url(#${id})` }, parent);\n };\n const under = (y0, y1) => this.items.filter(i => i !== s?.item && i.top <= y1 && i.bottom >= y0 && i.left <= right && i.right >= left);\n if (s?.item.el.isConnected && this.items.at(-1) === s.item) {\n const tile = cut(top, top + by, this.el('g', { transform: `translate(0 ${Y(-by * s.n)})` }, s.moved));\n for (const i of under(top, top + by - 1)) tile.append(i.el.cloneNode(true));\n s.n++;\n s.moved.setAttribute('transform', `translate(0 ${Y(by * s.n)})`);\n return;\n }\n const g = cut(top + by, bottom + by + 1), moved = this.el('g', { transform: `translate(0 ${Y(by)})` }, g);\n this.rect(left, top - by * 60, right - left + 1, bottom - top + 1 + by * 61, this.window.color, moved);\n for (const i of under(top, bottom)) moved.append(i.el.cloneNode(true));\n this.add(top + by, bottom + by, g, { left, right });\n this.shifting = { item: this.items.at(-1), moved, n: 1 };\n }\n\n // A run of a row ($7947), or a dot ($5AF4), in a color. Runs one under another, the same across\n // and in the same color, are one rectangle, which grows a row at a time and covers what lies\n // wholly inside it: the racing car's square cleared, a row or a column at a time, takes the car.\n paint(color, left, right, y) {\n this.hide(left, right, y, y);\n const last = this.painted;\n if (last?.el.isConnected && last.color === color && last.left === left && last.right === right && last.bottom === y - 1) {\n last.bottom = y; last.el.setAttribute('height', Y(y - last.top + 1));\n const item = this.items.find(i => i.el === last.el);\n this.items = this.items.filter(i => { if (i !== item && i.top >= last.top && i.bottom <= y && i.left >= left && i.right <= right) { i.el.remove(); return false; } return true; });\n if (item) item.bottom = y;\n return;\n }\n const el = this.add(y, y, this.rect(left, y, right - left + 1, 1, color, null), { left, right });\n this.painted = { el, color, left, right, top: y, bottom: y };\n }\n span({ a, x, y, row }) { this.paint(a & 15, x, y, row); }\n dot({ a, x, y }) { this.paint(a & 15, x, x, y); }\n 'white-lines'({ y }) { this.whiteLines(y); }\n 'fill-rows'({ a, x, y }) { this.fill(y, y + x - 1, a); }\n\n picture({ words }) {\n const shapes = this.pictures.get(words.toUpperCase().replace(/_/g, ' '));\n if (!shapes) return; // part1.pic and the like: the loader's own names for a file of pictures\n // drawn smooth, its edges may reach past the window's rows, which the original's never do\n const id = 'window-' + this.window.bottom;\n this.clips ??= new Set();\n if (!this.clips.has(id)) this.clips.add(id), this.el('rect', { x: 0, y: 0, width: X(140), height: Y(this.window.bottom) }, this.el('clipPath', { id }, this.svg));\n const g = this.el('g', { 'clip-path': `url(#${id})` }), scaled = this.el('g', { transform: 'scale(4 2)' }, g);\n scaled.innerHTML = elements(shapes, { crisp: false });\n this.add(1, this.window.bottom - 1, g, { covers: false, left: 1, right: 138 });\n this.shapes = this.shapes.concat(shapes);\n this.picturesShapes = shapes; // the last picture's, which a problem may draw again (PROB1's colouring)\n }\n objects({ table }) { this.table = parseInt(table.slice(1), 16); }\n // how: 'whole' ($686D), 'keep' ($686F) or 'clear' ($6863), as @moonbase-machines/vector/objects.js and raster.js say\n object({ a, x, y }, how = 'whole') {\n const keep = how === 'keep', whole = how === 'whole';\n const table = this.tables.get(this.table);\n // Object 0 puts back the ground kept under the latest object drawn keeping it ($686F), which\n // takes that object away. Once put back, the ground is put back again to no further effect.\n if (a < 2) { if (this.kept?.isConnected) this.remove(this.kept); this.kept = null; return; }\n const o = table?.find(o => o.number === a);\n if (!o) return;\n // the dots of the object's clear color are left out, so the screen shows through them, but for\n // an object put down whole\n const rows = o.rows.map(row => row.map(c => !whole && c === o.clear ? undefined : c));\n const right = x + o.width - 1, bottom = y + o.height - 1;\n // An object put down whole hides every dot under it. What it leaves showing of another put\n // down whole is all of that one that stays: PROB6's car, drawn a dot on each time, leaves a\n // column of the one before, as the original's screen does, and no hair of the rest at the\n // edges of the page's pixels.\n if (whole) this.hide(x, right, y, bottom);\n const el = this.el('image', { href: this.image(rows), x: X(x), y: Y(y), width: X(o.width), height: Y(o.height), preserveAspectRatio: 'none', style: 'image-rendering: pixelated' });\n // put down whole, it hides for good whatever lies wholly inside it, as the crane its rope's dots\n this.add(y, bottom, el, { covers: whole, left: x, right });\n if (keep) this.kept = el;\n if (whole) this.items.at(-1).whole = { x, y, rows };\n }\n // The dots of objects put down whole that something opaque now covers, from column x0 to x1 and\n // row y0 to y1, taken out of their pictures: what is left of each is all of it that shows, and\n // none of what is covered shows at the edges of the page's pixels.\n hide(x0, x1, y0, y1) {\n for (const i of [...this.items]) {\n const w = i.whole;\n if (!w || w.x > x1 || w.x + w.rows[0].length - 1 < x0 || w.y > y1 || w.y + w.rows.length - 1 < y0) continue;\n let changed = false;\n const left = w.rows.map((row, dy) => row.map((c, dx) => {\n const px = w.x + dx, py = w.y + dy;\n if (c !== undefined && px >= x0 && px <= x1 && py >= y0 && py <= y1) { changed = true; return undefined; }\n return c;\n }));\n if (!changed) continue;\n if (left.every(row => row.every(c => c === undefined))) { this.remove(i.el); continue; }\n i.el.setAttribute('href', this.image(left)); w.rows = left;\n }\n }\n // rows of colors as a picture, undefined where nothing is drawn\n image(rows) {\n const canvas = document.createElement('canvas'); canvas.width = rows[0].length; canvas.height = rows.length;\n const cx = canvas.getContext('2d'), img = cx.createImageData(canvas.width, canvas.height);\n rows.forEach((row, dy) => row.forEach((c, dx) => {\n if (c === undefined) return;\n const [r, g, b] = COLORS[c]; img.data.set([r, g, b, 255], (dy * canvas.width + dx) * 4);\n }));\n cx.putImageData(img, 0, 0);\n return canvas.toDataURL();\n }\n 'object-keep'(e) { this.object(e, 'keep'); }\n 'object-mode'(e) { this.object(e, 'clear'); }\n // $76ED and $76F3: a key cap at the pen, which is left past it (vector.js)\n 'key-at'({ a, x, y }) { this.pen.x = x; this.pen.y = y; this.key({ a }); }\n key({ a }) {\n const w = width(a);\n this.cap(a, this.pen.x, this.pen.y, this.layer, true, undefined, Math.max(4, w) + 4);\n this.pen.x += 1 + (w < 4 ? 4 - w : 0) + 1 + w + 3;\n }\n\n // a key cap: outlined in blue, filled magenta, its letter white\n cap(ch, x, y, parent, add, key, wide) {\n const label = { '\\r': 'RETURN', '\\x7f': 'DELETE' }[ch] ?? ch;\n const w = wide ?? (label.length > 1 ? 32 : 7);\n const g = this.el('g', key !== undefined ? { class: 'key', 'data-key': key } : {});\n this.el('rect', { x: X(x), y: Y(y - 2), width: X(w), height: Y(11), rx: 3, fill: rgb(1), stroke: rgb(13), 'stroke-width': 3 }, g);\n if (this.oldStyle) {\n // the engine's cap: the glyph a dot in from the left, or RETURN and DELETE spelt out\n let tw = 0; for (const c of label) tw += width(c) + 1;\n this.glyphs(g, label, x + Math.max(1, Math.round((w - tw + 1) / 2)), y, 15);\n } else {\n const t = this.el('text', { x: X(x + w / 2), y: Y(y + 7), fill: rgb(15), 'font-family': SANS, 'font-size': label.length > 1 ? 13 : 16, 'font-weight': 600, 'text-anchor': 'middle' }, g);\n t.textContent = this.modern(label);\n }\n if (add) { this.add(y - 2, y + 8, g, { covers: false, left: x, right: x + w }); this.items.at(-1).cap = true; } else parent.append(g);\n return g;\n }\n\n // Text, laid out as the engine lays it out (layout.js). A line is drawn a word at a time, each\n // word where the engine's font puts it and as wide, in dots, as the engine made it: the words\n // sit where the original's did, and read sharper.\n text({ words }) {\n if (this.textScreen.getAttribute('display') !== 'none') {\n for (const c of textLayout(words, this.textPen)) if (this.textCells[c.row]?.[c.col]) this.textCell(c.row, c.col, c.ch, c.inverse);\n return;\n }\n for (const line of layout(words, this.pen)) {\n const { top, tall } = line, size = tall ? 32 : 19;\n // the paper of the line's glyphs' cells, first, as the engine paints it: a text written\n // over another takes it away\n const cells = line.chars.filter(c => c.ch.charCodeAt(0) >= 0x20);\n if (cells.length) {\n const from = Math.min(...cells.map(c => c.x)), to = Math.max(...cells.map(c => c.x + width(c.ch))) - 1, rows = Math.min(9, line.height ?? 9) * (tall ? 2 : 1);\n this.add(top, top + rows - 1, this.rect(from, top, to - from + 1, rows, line.paper, null), { left: from, right: to });\n }\n const g = this.el('g', { 'font-family': SANS, 'font-size': size, 'font-weight': tall ? 700 : 500 });\n let word = null, left = 139, right = 0;\n const end = () => {\n if (!word) return;\n left = Math.min(left, word.x); right = Math.max(right, word.x + word.width);\n if (this.oldStyle) { this.glyphs(g, word.chars, word.x, top, line.ink, tall, line.paper); word = null; return; }\n const el = this.el('text', { y: Y(top + (tall ? 15 : 7)), 'data-x': X(word.x), 'data-width': X(word.width) }, g);\n // the part of a line before its first color is drawn in the ink the whole line ends with\n for (const c of word.chars) { const span = this.el('tspan', { fill: rgb(c.ink ?? line.ink) }, el); span.textContent = this.modern(c.ch); }\n word = null;\n };\n for (const c of line.chars) {\n if (c.ch.charCodeAt(0) <= 0x20) { end(); continue; }\n word ??= { x: c.x, width: 0, chars: [] };\n word.chars.push(c); word.width = c.x + width(c.ch) - word.x;\n }\n end();\n if (g.childNodes.length) { this.add(top, top + (tall ? 16 : 8), g, { covers: false, left, right }); this.fit(g); }\n }\n }\n // Each word of a line, drawn at x 0, is measured once it is on the page and then moved to its\n // place and scaled to the width the engine gave it. Browsers differ in how they stretch text to\n // a length, and a measured scale looks the same in all of them.\n fit(g) {\n for (const el of g.querySelectorAll('text[data-width]')) {\n const natural = el.getComputedTextLength();\n if (natural > 0) el.setAttribute('transform', `translate(${el.dataset.x} 0) scale(${el.dataset.width / natural} 1)`);\n }\n }\n // The old style: the engine's own glyphs, each set dot a square, over the glyph's cell in the\n // paper color. `chars` is a string, or the characters of a line with the ink each was given\n // (the part of a line before its first color takes the ink the line ends with). Returns the\n // dot after the last glyph.\n glyphs(parent, chars, x, y, ink, tall = false, paper) {\n const list = typeof chars === 'string' ? [...chars].map(ch => ({ ch })) : chars, h = tall ? 2 : 1;\n const paths = new Map();\n for (const c of list) {\n const w = width(c.ch), colour = c.ink ?? ink;\n if (paper !== undefined) this.rect(x, y, w, 9 * h, paper, parent);\n let d = paths.get(colour) ?? '';\n for (const [gx, gy] of dots(c.ch)) d += `M${X(x + gx)} ${Y(y + gy * h)}h4v${2 * h}h-4z`;\n paths.set(colour, d);\n x += w + 1;\n }\n for (const [colour, d] of paths) if (d) this.el('path', { d, fill: rgb(colour) }, parent);\n return x;\n }\n\n // plain words at dot x and row y, in the engine's font widths with spacing 1, fitted as a text's\n write(parent, text, x, y, ink = 15) {\n if (this.oldStyle) return this.glyphs(parent, text, x, y, ink);\n const g = this.el('g', { 'font-family': SANS, 'font-size': 19, 'font-weight': 500, fill: rgb(ink) }, parent);\n for (const part of text.split(' ')) {\n if (part) {\n let w = 0; for (const ch of part) w += width(ch) + 1;\n const el = this.el('text', { y: Y(y + 7), 'data-x': X(x), 'data-width': X(w - 1) }, g);\n el.textContent = this.modern(part);\n x += w;\n }\n x += width(' ') + 1;\n }\n this.fit(g);\n return x;\n }\n\n\n line({ x0, x1, y0, y1, color }) {\n this.add(Math.min(y0, y1), Math.max(y0, y1), this.el('line', { x1: X(x0 + 0.5), y1: Y(y0 + 0.5), x2: X(x1 + 0.5), y2: Y(y1 + 0.5), stroke: rgb(color), 'stroke-width': 3, 'stroke-linecap': 'round' }), { covers: false, left: Math.min(x0, x1), right: Math.max(x0, x1) });\n }\n // $67B9 fills from column x to x + width, both ends, down `height` rows; $677E draws its four\n // lines from corner to corner, x to x + width and y to y + height\n rectangle({ a, x, y, width, height }) { this.solid(a, x, y, width + 1, height); }\n 'rectangle-outline'({ a, x, y, width, height }) {\n const w = width + 1, h = height + 1;\n this.add(y, y + h - 1, this.el('rect', { x: X(x) + 2, y: Y(y) + 1, width: X(w) - 4, height: Y(h) - 2, fill: 'none', stroke: rgb(a), 'stroke-width': 3 }), { covers: false, left: x, right: x + w - 1 });\n }\n // a rectangle w dots across and h down, filled\n solid(a, x, y, w, h) { this.add(y, y + h - 1, this.rect(x, y, w, h, a, null), { left: x, right: x + w - 1 }); }\n\n // what the view shows while the engine waits: the space bar's button, or the keys it asks for\n prompts() {\n this.prompt.replaceChildren();\n const e = this.engine, step = e.waitingOn;\n if (!step) return;\n const name = step.words?.[0] ?? step.name;\n if (name === 'wait' || name === 'wait-erase' || name === 'wait-or-escape') {\n const y = (e.mem[this.vars.layout] & 15) === 1 ? 178 : 170;\n const g = this.el('g', { class: 'key', 'data-key': 32 }, this.prompt);\n this.el('rect', { x: X(46), y: Y(y), width: X(47), height: Y(11), rx: 4, fill: rgb(1), stroke: rgb(13), 'stroke-width': 3 }, g);\n if (this.oldStyle) this.glyphs(g, 'SPACE BAR', 48, y + 2, 15);\n else { const t = this.el('text', { x: X(69.5), y: Y(y + 8), fill: rgb(15), 'font-family': SANS, 'font-size': 15, 'font-weight': 600, 'text-anchor': 'middle' }, g); t.textContent = 'SPACE BAR'; }\n this.spaceBar = { y, erase: name === 'wait-erase', el: g };\n } else if (name === 'ask' || name === 'ask-mode' || name === 'ask-escape') {\n this.rect(1, 162, 138, 28, 5, this.prompt); // box 2 inside its white edges, as panel 5 clears it\n const mode = e.askMode, keys = [];\n if (mode === 0x80) ARROWS.forEach((a, i) => keys.push([a, [8, 21, 10, 11][i]]));\n else if (mode >= 0xb1 && mode < 0xba) for (let k = 0x31; k <= (mode & 0x7f); k++) keys.push([String.fromCharCode(k), k]);\n else for (let k = 0x41; k <= (mode & 0x5f); k++) keys.push([String.fromCharCode(k), k]);\n const label = (s, x, y) => this.write(this.prompt, s, x, y);\n if (e.asked === null) {\n label('Press', 4, 166);\n keys.forEach(([s, k], i) => { if (i === keys.length - 1 && mode !== 0x80 && keys.length > 1) label('or', 31 + 10 * i, 166); this.cap(s, 31 + 10 * i + (i === keys.length - 1 && mode !== 0x80 && keys.length > 1 ? 10 : 0), 166, this.prompt, false, k); });\n if (mode === 0x80) [[58, 62], [74, 62], [66, 71], [66, 53]].forEach(([x, y], i) => this.cap(ARROWS[i], x, y, this.prompt, false, keys[i][1]));\n } else {\n const [s] = keys[e.asked.place];\n this.cap(s, 31 + 10 * e.asked.place, 166, this.prompt, false); // the chosen key stays, the rest of its row goes\n label('Press', 4, 179); this.cap('\\r', 31, 179, this.prompt, false, 13); label('or', 67, 179); this.cap('\\x7f', 78, 179, this.prompt, false, 127);\n if (mode === 0x80) this.cap(ARROWS[e.asked.place], [58, 74, 66, 66][e.asked.place], [62, 62, 71, 53][e.asked.place], this.prompt, false);\n }\n }\n }\n}\n", "import { colors as m } from '@moonbase-machines/apple2e';\nexport const { COLORS, NAMES, rgb } = m;", "import { font as m } from '@moonbase-machines/charset';\nexport const { FONT } = m;"],
5
+ "mappings": ";qLAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,OAAS,WAAWC,OAAS,6BAA7B,IACeD,GADfE,GAAAC,GAAA,MACa,CAAE,QAAAH,IAAYC,MCD3B,IAAAG,GAAA,GAAAC,EAAAD,GAAA,WAAAE,GAAA,WAAAC,GAAA,YAAAC,GAAA,UAAAC,KAAA,OAAS,UAAUC,OAAS,6BAA5B,IACeJ,GAAOC,GAAQC,GAASC,GADvCE,GAAAC,GAAA,MACa,CAAE,MAAAN,GAAO,OAAAC,GAAQ,QAAAC,GAAS,MAAAC,IAAUC,MCDjD,IAAAG,GAAA,GAAAC,EAAAD,GAAA,gBAAAE,GAAA,cAAAC,GAAA,YAAAC,GAAA,cAAAC,KAAA,OAAS,SAASC,OAAS,6BAA3B,IACeJ,GAAYC,GAAWC,GAASC,GAD/CE,GAAAC,GAAA,MACa,CAAE,WAAAN,GAAY,UAAAC,GAAW,QAAAC,GAAS,UAAAC,IAAcC,MCD7D,IAAAG,GAAA,GAAAC,EAAAD,GAAA,YAAAE,GAAA,WAAAC,GAAA,UA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,EAAM,OAAAd,EAAQ,KAAAC,EAAM,MAAAK,EAAO,QAASC,EAAM,OAAAC,EAAQ,KAAAC,EAAM,KAAAN,EAAM,QAAAC,EAAS,MAAAC,EAAO,MAAAM,CAAM,EAC/H,MAAOC,EAAM,KAAO,CAAE,KAAMd,EAAO,GAAG,KAAKoB,CAAI,CACjD,OAASR,EAAK,CAAED,EAAKC,CAAG,CAAG,CAC7B",
6
+ "names": ["machine_exports", "__export", "Machine", "m", "init_machine", "__esmMin", "prodos_exports", "__export", "blank", "placed", "started", "units", "m", "init_prodos", "__esmMin", "saves_exports", "__export", "driveFiles", "keepSaves", "onDisks", "withSaves", "m", "init_saves", "__esmMin", "screen_exports", "__export", "COLORS", "colors", "paint", "paintHires", "paintText", "rowStart", "screen", "textRow", "m", "init_screen", "__esmMin", "pictures_exports", "__export", "pictures", "shapes", "windows", "m", "init_pictures", "__esmMin", "svg_exports", "__export", "bounds", "document", "elements", "m", "init_svg", "__esmMin", "machine_exports", "__export", "C64", "m", "init_machine", "__esmMin", "printer_exports", "__export", "Printer", "WIDTH", "bus", "paper", "m", "init_printer", "__esmMin", "vic_exports", "__export", "HEIGHT", "LEFT", "PALETTE", "TOP", "VIC", "WIDTH", "m", "init_vic", "__esmMin", "browser_exports", "__export", "keyboard", "pace", "painter", "m", "init_browser", "__esmMin", "sid_exports", "__export", "SID", "m", "init_sid", "__esmMin", "start_exports", "__export", "ROM_CHOICES", "c64Roms", "typed", "m", "init_start", "__esmMin", "d64_exports", "__export", "SECTORS", "add", "make", "petsciiName", "read", "m", "init_d64", "__esmMin", "saves_exports", "__export", "keepDrive", "m", "init_saves", "__esmMin", "original_exports", "__export", "play", "audio_exports", "__export", "Speaker", "WORKLET", "Speaker", "clicks", "cycles", "perSample", "n", "wave", "ci", "i", "t", "parts_exports", "__export", "KEYS_MARKUP", "paperBox", "phoneKeys", "line", "print", "tear", "box", "root", "stage", "kb", "unnamed", "e", "ch", "t", "play", "data", "root", "disk", "words", "downloadDisk", "roms", "studies", "KEYS_MARKUP", "paperBox", "$", "id", "canvas", "ctx", "phoneKeys", "parts", "Speaker", "game", "c64", "apple", "evenly", "dots", "lines", "stage", "column", "fit", "dpr", "pad", "room", "most", "k", "w", "makers", "layer", "status", "vectorToggle", "speaker", "Machine", "placed", "withSaves", "keepSaves", "onDisks", "driveFiles", "screen", "shapes", "elements", "saving", "disks", "n", "m", "a", "hooked", "window_", "hook", "find", "bytes", "code", "outer", "i", "shape", "exit", "box", "c", "KEYS", "e", "rgba", "image", "cols", "mode", "frame", "now", "text", "name", "C64", "Printer", "paper", "WIDTH", "HEIGHT", "keyboard", "painter", "SID", "c64Roms", "startTyped", "add", "keepDrive", "sheet", "shown", "printer", "raw", "t", "file", "download", "draw", "typing", "typed", "keys", "frames", "sid", "started", "due", "first", "wave", "r", "v", "modal_exports", "__export", "modal", "modalOpen", "open", "listening", "keys", "e", "m", "d", "f", "focusable", "at", "box", "first", "within", "className", "content", "cancel", "layer", "before", "others", "el", "under", "dialogs_exports", "__export", "dialogs", "dialogs", "within", "className", "ask", "heading", "body", "buttons", "aside", "done", "content", "h", "row", "label", "value", "b", "m", "left", "modal", "tell", "saveAs", "disk", "suggested", "input", "name", "keptNote", "openFrom", "extension", "type", "select", "note", "button", "text", "from", "download", "remove", "fill", "f", "chosen", "open", "n", "a", "warning", "p", "disk_exports", "__export", "bytesText", "openDisk", "programDisk", "textBytes", "titleDisk", "local_exports", "__export", "ACCOUNT", "DB", "KEY", "STORE", "VERSION", "local", "opened", "done", "fail", "r", "asked", "account", "db", "store", "mode", "disk", "name", "bytes", "meta", "modified", "f", "memory_exports", "__export", "memory", "kept", "disks", "of", "d", "f", "n", "openDisk", "name", "backend", "local", "memory", "files", "f", "queue", "later", "job", "a", "b", "bytes", "meta", "modified", "n", "titleDisk", "slug", "programDisk", "textBytes", "s", "bytesText", "c64_view_exports", "__export", "C64View", "m", "paint", "init_vic", "NS", "C64View", "svg", "engine", "chargen", "WIDTH", "HEIGHT", "k", "v", "frame", "paint", "ctx", "pixels", "i", "r", "g", "b", "PALETTE", "card_view_exports", "__export", "CardView", "init_screen", "NS", "svg", "engine", "inset", "k", "v", "mem", "s", "ctx", "pixels", "paintText", "page", "paintHires", "band", "shift", "px", "top", "y", "x", "bottom", "from", "to", "by", "row", "card_exports", "__export", "cardRoutines", "events_exports", "__export", "GIVES", "POLLS", "TAKES", "WAITS", "describe", "nothing", "result", "MEMORY", "ZERO", "name", "fixed", "regs", "inline", "read", "peek", "e", "takes", "r", "k", "at", "a", "cards_exports", "__export", "INLINE", "KERNAL", "section", "sectionName", "bytes", "read", "at", "b", "k", "s", "i", "guard", "c", "toolkit", "x", "lengths", "marks", "word", "path", "mark", "t", "m", "BLOCK", "CLOCK", "Files", "m", "install", "m", "KEY_TABLES", "VECTORS", "VIC", "install", "kernalByte", "matrixOf", "screenCode", "m", "Drive", "init_printer", "m", "Basic", "m", "BasicError", "ERRORS", "fail", "fout", "int16", "nextRandom", "scanNumber", "seedRandom", "val", "m", "evaluateInMemory", "install", "printError", "lift_exports", "__export", "lift", "readers", "script", "m", "OPS", "SIZE", "disassemble", "hex", "operand", "m", "INLINE", "name", "sound", "text", "readers", "from", "k", "f", "b", "at", "r", "i", "INLINE", "lift", "bytes", "origin", "entries", "routines", "stops", "inline", "lines", "targets", "seen", "queue", "inFile", "a", "pc", "regs", "op", "OPS", "hex", "size", "SIZE", "word", "ins", "line", "operand", "next", "stop", "data", "args", "t", "table", "e", "out", "last", "left", "s", "script", "selfModified", "memory", "moved", "H", "n", "w", "written", "here", "own", "place", "v", "label", "branch", "fused", "target", "pcs", "stopsHere", "loads", "flush", "reg", "put", "name", "fixed", "takes", "TAKES", "given", "g", "s1", "l2", "s2", "j", "who", "whole", "row", "hex4", "inputs", "e", "name", "args", "takes", "TAKES", "k", "loaded", "r", "v", "n", "cardRoutines", "title", "toolkit", "c64", "files", "Files", "screen", "latch", "lc", "bankTo", "bank", "here", "chip", "SEEDED", "s", "io64", "at", "reg", "ioShown", "io", "kernalByte", "b", "engine", "cpu", "a", "romFrom", "install", "bus", "Drive", "ch", "Printer", "h", "runNow", "from", "to", "script", "l", "path", "f", "c", "rom", "start", "CLOCK", "index", "labelled", "p", "atNeed", "bytes", "lifted", "lift", "readers", "INLINE", "fileScripts", "present", "names", "find", "over", "romAt", "stirring", "step", "emit", "ev", "quiet", "back", "x", "through", "inline", "i", "words", "unplaced", "VECTORED", "inRom", "describe", "label", "GIVES", "result", "routines", "cmd", "lo", "hi", "params", "mem", "ref", "o", "sectionName", "BLOCK", "err", "entry", "done", "ENDS", "pullRegisters", "text", "m", "keep", "device", "sa", "program", "startBasic", "end", "place", "BasicError", "printError", "Basic", "data", "seed", "raster", "kept", "what", "then", "line", "last", "target", "named", "own", "t", "KEY_TABLES", "VIC", "VECTORS", "raw", "compile_exports", "__export", "compile", "script_exports", "__export", "branchTaken", "operand", "parse", "words", "WORD", "source", "name", "steps", "labels", "data", "raw", "n", "line", "where", "m", "h", "at", "body", "w", "word", "SIZE", "step", "to", "next", "hex", "v", "n", "IO_FROM", "IO_TO", "IO", "at", "address", "o", "io", "get", "word", "timed", "operand", "a", "put", "place", "FLAGS", "TESTS", "statement", "step", "k", "w", "first", "second", "s", "of", "parts", "p", "left", "to", "cond", "not", "flag", "args", "compile", "source", "name", "steps", "labels", "data", "parse", "code", "starts", "c", "l", "blocks", "end", "loops", "lines", "i", "j", "text", "js", "t", "more", "branchTaken", "cy", "label", "one", "body", "d", "b", "engine_exports", "__export", "Engine", "label16", "m", "CPU", "CYCLES", "LEFT", "STATEMENTS", "STATEMENT", "step", "CYCLES_PER_MS", "size", "op", "b", "cc", "LEFT_OUT", "COMPARED", "returnOf", "label16", "at", "Engine", "routines", "scripts", "start", "label", "memory", "v", "f", "event", "key", "k", "g", "name", "load", "p", "d", "src", "parse", "bytes", "line", "text", "words", "l", "done", "ret", "here", "i", "o", "z", "base", "r", "s", "j", "c", "m", "CYCLES", "prev", "from", "more", "a", "lo", "hi", "sum", "left", "through", "t", "to", "top", "n", "sp", "kept", "limit", "e", "w", "first", "second", "operand", "args", "routine", "cond", "yes", "not", "flag", "branchTaken", "layout_exports", "__export", "LAYOUT", "PANELS", "layout", "resolve", "textLayout", "textPage", "textPen", "word", "m", "GLYPHS", "WIDTHS", "dots", "start", "useFont", "width", "LAYOUT", "gray", "layout", "rows", "gap", "y", "more", "blue", "PANELS", "word", "mem", "lo", "hi", "vlo", "vhi", "at", "n", "s", "k", "resolve", "words", "all", "b", "v", "pen", "lines", "height", "big", "line", "ink", "marked", "flush", "newline", "x", "start", "c", "chars", "w", "width", "put", "ch", "i", "end", "code", "rest", "textLayout", "cells", "col", "textPen", "textPage", "load_exports", "__export", "loadTitle", "makeEngine", "vector_exports", "__export", "codeFiles", "pictureShapes", "vectorRoutines", "problems_exports", "__export", "helpers", "helpers", "e", "routines", "zero", "call", "name", "args", "token", "words", "a", "drawn", "x", "y", "describe", "z", "key", "kind", "k", "inside", "run", "m", "carry", "decode", "put", "tables", "init_pictures", "raster_exports", "__export", "Raster", "m", "crossings", "draw", "fill", "inside", "line", "outline", "screen", "spans", "under", "Raster", "screen", "y", "row", "bits", "c", "b", "x", "left", "right", "count", "first", "edges", "layout", "window", "one", "two", "bottom", "top1", "top2", "LAYOUT", "top", "shapes", "draw", "w", "h", "r", "x0", "y0", "x1", "y1", "line", "o", "how", "dy", "_", "dx", "put", "k", "ch", "ink", "paper", "height", "space", "width", "gy", "gx", "on", "dots", "codeFiles", "map", "volume", "loads", "n", "name", "f", "c", "KEY", "inputs", "e", "args", "takes", "TAKES", "fixed", "k", "regs", "t", "r", "v", "waiting", "step", "words", "take", "describe", "quietly", "run", "objectsOf", "title", "files", "tables", "picturesOf", "p", "pictures", "pictureShapes", "vectorRoutines", "V", "Z", "z", "useFont", "objectCarry", "o", "carry", "raster", "Raster", "pen", "textPen", "textPage", "objectOf", "drawObject", "how", "cap", "ch", "w", "width", "x", "spacer", "keyPanel", "y", "cx", "cy", "i", "print", "line", "layout", "resolve", "put", "simple", "draw", "rest", "letterCarry", "asking", "mode", "arrows", "place", "key", "result", "routines", "shapes", "PANELS", "all", "code", "bytes", "b", "at", "textLayout", "nothing", "left", "right", "top", "bottom", "by", "used", "seed", "q", "d", "file", "helpers", "row", "ms", "what", "to", "Files", "err", "init_prodos", "ENGINES", "vectorRoutines", "cardRoutines", "read", "url", "as", "text", "r", "defaultOf", "loadTitle", "folder", "data", "scenes", "fixed", "title", "name", "scripts", "n", "disk", "makeEngine", "memory", "started", "engine", "Engine", "main_exports", "__export", "play", "scenes_exports", "__export", "play", "init_printer", "init_sid", "m", "STANDS_IN", "install", "standIn", "init_saves", "init_saves", "view_exports", "__export", "View", "m", "COLORS", "NAMES", "rgb", "init_pictures", "init_svg", "m", "FONT", "init_screen", "NS", "X", "x", "Y", "y", "SANS", "MONO", "ARROWS", "MODERN", "View", "svg", "disk", "volume", "engine", "extra", "press", "name", "f", "p", "pictures", "c", "map", "modern", "d", "pattern", "s", "tables", "codeFiles", "t", "textPen", "textPage", "attrs", "parent", "e", "k", "v", "w", "h", "color", "rgb", "top", "bottom", "el", "covers", "left", "right", "i", "sides", "g", "mem", "resolve", "row", "col", "ch", "inverse", "ink", "glyph", "FONT", "gx", "gy", "bytes", "dots", "colors", "rows", "a", "layout", "top1", "top2", "LAYOUT", "n", "PANELS", "clipped", "x0", "x1", "id", "under", "tile", "moved", "by", "cut", "y0", "y1", "last", "item", "words", "shapes", "scaled", "elements", "table", "how", "keep", "whole", "o", "changed", "dy", "dx", "px", "py", "canvas", "cx", "img", "r", "b", "COLORS", "width", "add", "key", "wide", "label", "tw", "textLayout", "line", "tall", "size", "cells", "from", "to", "word", "end", "span", "natural", "chars", "paper", "list", "paths", "colour", "text", "part", "height", "step", "mode", "keys", "play", "game", "title", "scripts", "disk", "root", "stage", "status", "fail", "kept", "words", "fixed", "KEYS_MARKUP", "paperBox", "$", "id", "svg", "soundBox", "phoneKeys", "fixedBox", "u", "extra", "chargen", "standIn", "box", "sheet", "shown", "printer", "Printer", "paper", "withSaves", "keepDrive", "Drive", "ch", "engine", "makeEngine", "keepSaves", "queue", "oldStyleBox", "history", "remember", "v", "onView", "makeView", "C64View", "CardView", "View", "view", "e", "miniBox", "top", "bottom", "left", "right", "at", "mini", "prompts", "show", "speaker", "Speaker", "hear", "V", "audio", "tone", "from", "to", "ms", "o", "g", "t", "pitch", "p", "PACE", "pace", "drawing", "sleep", "r", "runs", "quick", "end", "start", "h", "err", "KEYS", "press", "k", "on", "ticking", "held", "tapped", "m", "matrixOf", "key", "route", "routeName", "expand", "give", "petscii", "pollsAt", "side", "put", "go", "i", "sid", "sent", "stopped", "SID", "n", "wave", "a", "play", "options", "folder", "data", "root", "kept", "preview", "words", "stage", "line", "status", "fail", "err", "fixed", "title", "scripts", "disk", "loadTitle", "link", "done", "game"]
7
7
  }