Blinkenlights

This commit is contained in:
Will Scullin 2022-06-04 12:48:14 -07:00
parent c83af0eeeb
commit 7a9c0aa9d0
No known key found for this signature in database
GPG Key ID: 26DCD1042C6638CD

View File

@ -129,6 +129,8 @@ export default class SmartPort implements Card, MassStorage<BlockFormat>, Restor
private rom: rom;
private disks: BlockDisk[] = [];
private busy: boolean[] = [];
private busyTimeout: ReturnType<typeof setTimeout>[] = [];
constructor(
private cpu: CPU6502,
@ -150,6 +152,18 @@ export default class SmartPort implements Card, MassStorage<BlockFormat>, Restor
// debug.apply(this, arguments);
}
private driveLight(drive: DriveNumber) {
if (!this.busy[drive]) {
this.busy[drive] = true;
this.callbacks?.driveLight(drive, true);
}
clearTimeout(this.busyTimeout[drive]);
this.busyTimeout[drive] = setTimeout(() => {
this.busy[drive] = false;
this.callbacks?.driveLight(drive, false);
}, 100);
}
/*
* dumpBlock
*/
@ -220,6 +234,7 @@ export default class SmartPort implements Card, MassStorage<BlockFormat>, Restor
}
// debug('read', '\n' + dumpBlock(drive, block));
this.driveLight(drive);
for (let idx = 0; idx < 512; idx++) {
buffer.writeByte(this.disks[drive].blocks[block][idx]);
@ -254,6 +269,7 @@ export default class SmartPort implements Card, MassStorage<BlockFormat>, Restor
}
// debug('write', '\n' + dumpBlock(drive, block));
this.driveLight(drive);
for (let idx = 0; idx < 512; idx++) {
this.disks[drive].blocks[block][idx] = buffer.readByte();