apple2js/js/cards/drivers/EmptyDriver.ts
Ian Flanigan a7bf5d025d
Split drivers into different files
Before, all of the disk drivers were in the `disk2.ts` file. With this
change, they are now in separate files with a common `types.ts` file
for shared types. Now, none of the drives depend on the `disk2.ts`
except the WOZ driver that needs access to the sequencer rom. (This
may be moved in a future refactoring.)
2022-09-24 09:51:40 +02:00

54 lines
1.2 KiB
TypeScript

import { DiskDriver, Drive, DriverState } from './types';
/** Returned state for an empty drive. */
export interface EmptyDriverState extends DriverState { }
/**
* Driver for empty drives. This implementation does nothing except keep
* the head clamped between tracks 0 and 34.
*/
export class EmptyDriver implements DiskDriver {
constructor(private readonly drive: Drive) { }
tick(): void {
// do nothing
}
onQ6Low(): void {
// do nothing
}
onQ6High(_readMode: boolean): void {
// do nothing
}
onDriveOn(): void {
// do nothing
}
onDriveOff(): void {
// do nothing
}
clampTrack(): void {
// For empty drives, the emulator clamps the track to 0 to 34,
// but real Disk II drives can seek past track 34 by at least a
// half track, usually a full track. Some 3rd party drives can
// seek to track 39.
if (this.drive.track < 0) {
this.drive.track = 0;
}
if (this.drive.track > 34) {
this.drive.track = 34;
}
}
getState() {
return {};
}
setState(_state: EmptyDriverState): void {
// do nothing
}
}