cram-basic.mjs (2361B)
1 // ExelBASIC + Exelmémoire (EXL 100) : les commandes ajoutées par CROS (CROS, LOAD, MERGE, RESTORE, EOF) 2 // et SAVE vers le volume. Captures : prompt BASIC, après CROS, après Échap, après SAVE, DIR dans CROS. 3 // node test/cram-basic.mjs [base-url] 4 import { open, sleep } from './cdp.mjs'; 5 6 const base = process.argv[2] ?? 'http://127.0.0.1:8195'; 7 const url = base + '/?game=exl100&rom=/roms/exl100.zip&exelmem=1&args=' + encodeURIComponent('--tape /roms/cartridges/exelbasic.bin'); 8 const page = await open(url, { width: 900, height: 1100 }); 9 await page.evaluate(`localStorage.removeItem('exl100.cram.exl100')`); 10 await page.evaluate('location.reload()'); 11 12 const ev = (type, k, code, vk, mods = 0) => 13 page.send('Input.dispatchKeyEvent', { type, key: k, code, windowsVirtualKeyCode: vk, modifiers: mods }); 14 const key = async (k, code, vk, hold = 80, gap = 400) => { await ev('keyDown', k, code, vk); await sleep(hold); await ev('keyUp', k, code, vk); await sleep(gap); }; 15 const enter = () => key('Enter', 'Enter', 13); 16 const esc = () => key('Escape', 'Escape', 27); 17 const quote = async () => { // " de l'EXL 100 = Shift+3, avec une vraie touche Shift maintenue 18 await ev('keyDown', 'Shift', 'ShiftLeft', 16); await sleep(80); 19 await ev('keyDown', '"', 'Digit3', 51, 8); await sleep(80); await ev('keyUp', '"', 'Digit3', 51, 8); await sleep(80); 20 await ev('keyUp', 'Shift', 'ShiftLeft', 16); await sleep(400); 21 }; 22 const type = async (s) => { 23 for (const ch of s) { 24 if (ch === '"') await quote(); 25 else if (ch === ' ') await key(' ', 'Space', 32); 26 else if (ch === '=') await key('=', 'Equal', 187); 27 else if (/[0-9]/.test(ch)) await key(ch, 'Digit' + ch, ch.charCodeAt(0)); 28 else await key(ch.toLowerCase(), 'Key' + ch.toUpperCase(), ch.toUpperCase().charCodeAt(0)); 29 } 30 }; 31 32 await sleep(9000); 33 await page.screenshot('/tmp/b-0-basic.png'); 34 await type('CROS'); await enter(); await sleep(3000); 35 await page.screenshot('/tmp/b-1-cros.png'); 36 await esc(); await sleep(2500); 37 await page.screenshot('/tmp/b-2-back.png'); 38 await type('10 A=1'); await enter(); await sleep(500); 39 await type('SAVE "T"'); await enter(); await sleep(5000); 40 await page.screenshot('/tmp/b-3-save.png'); 41 await type('CROS'); await enter(); await sleep(3000); 42 await type('DIR'); await enter(); await sleep(2500); 43 await page.screenshot('/tmp/b-4-dir.png'); 44 page.close();