Skip to content

Commit

Permalink
Demo: Stop using keypress functions of webAGC
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfranzl committed Sep 12, 2021
1 parent 2b2728b commit 2ec5141
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import AGCErasableMemory from './agc_erasable_memory.js';
import AGCChannel from './agc_channel.js';
import DskyPcKeyboardInterface from './dsky_pc_keyboard_interface.js';

const proceedBit = 0o20000;

function toAGCBinaryString(value) {
return value.toString(2).padStart(15, '0');
}
Expand Down Expand Up @@ -50,12 +52,13 @@ export default class Demo {
// setTimeout(() => this.dskyPcKeyboardInterface.type('V16 N65 E '), 12000);

setTimeout(() => {
this.agc.writeIo(0o32, this.agc.state.channels[0o32] | proceedBit);

// Delay start to a time when the browser has finished loading all the other stuff; otherwise
// the setInterval interval can be nuch longer than 20ms, observed up to 140ms.
document.getElementById('clock_divisor').value = 32;
document.getElementById('clock_divisor').dispatchEvent(new Event('change'));
document.getElementById('agc_state').innerHTML = 'running';
this.agc.proceedKeyPress(1); // is it 0 or 1??
}, 1000);
}

Expand Down Expand Up @@ -147,11 +150,17 @@ export default class Demo {
this.dsky = document.createElement('dsky-interface');

this.dsky.addEventListener('keypress', ({ detail }) => {
this.agc.keyPress(detail);
this.channelEls[0o15]?.setAttribute('data-state', toAGCBinaryString(detail));
if (detail) // Ignore key releases. Luminary099 expects this (KEY REL light).
this.agc.writeIo(0o15, detail);
});

this.dsky.addEventListener('proceed', ({ detail }) => this.agc.proceedKeyPress(detail));
this.dsky.addEventListener('proceed', ({ detail }) => {
if (detail)
this.agc.writeIo(0o32, this.agc.state.channels[0o32] | proceedBit);
else
this.agc.writeIo(0o32, this.agc.state.channels[0o32] & ~proceedBit);
});
}

#configureClockDivisor() {
Expand Down

0 comments on commit 2ec5141

Please sign in to comment.